Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef __FRAMEWORK_XML_TOOLBOXDOCUMENTHANDLER_HXX_
30 : : #define __FRAMEWORK_XML_TOOLBOXDOCUMENTHANDLER_HXX_
31 : :
32 : : #include <framework/toolboxconfiguration.hxx>
33 : :
34 : : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
35 : : #include <com/sun/star/beans/PropertyValue.hpp>
36 : :
37 : : #include <threadhelp/threadhelpbase.hxx>
38 : : #include <rtl/ustring.hxx>
39 : : #include <cppuhelper/implbase1.hxx>
40 : : #include <stdtypes.h>
41 : : #include <framework/fwedllapi.h>
42 : :
43 : : namespace framework{
44 : :
45 : : //*****************************************************************************************************************
46 : : // Hash code function for using in all hash maps of follow implementation.
47 : :
48 : : class FWE_DLLPUBLIC OReadToolBoxDocumentHandler : private ThreadHelpBase, // Struct for right initalization of lock member! Must be first of baseclasses.
49 : : public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XDocumentHandler >
50 : : {
51 : : public:
52 : : enum ToolBox_XML_Entry
53 : : {
54 : : TB_ELEMENT_TOOLBAR,
55 : : TB_ELEMENT_TOOLBARITEM,
56 : : TB_ELEMENT_TOOLBARSPACE,
57 : : TB_ELEMENT_TOOLBARBREAK,
58 : : TB_ELEMENT_TOOLBARSEPARATOR,
59 : : TB_ATTRIBUTE_TEXT,
60 : : TB_ATTRIBUTE_BITMAP,
61 : : TB_ATTRIBUTE_URL,
62 : : TB_ATTRIBUTE_ITEMBITS,
63 : : TB_ATTRIBUTE_VISIBLE,
64 : : TB_ATTRIBUTE_WIDTH,
65 : : TB_ATTRIBUTE_USER,
66 : : TB_ATTRIBUTE_HELPID,
67 : : TB_ATTRIBUTE_STYLE,
68 : : TB_ATTRIBUTE_UINAME,
69 : : TB_ATTRIBUTE_TOOLTIP,
70 : : TB_XML_ENTRY_COUNT
71 : : };
72 : :
73 : : enum ToolBox_XML_Namespace
74 : : {
75 : : TB_NS_TOOLBAR,
76 : : TB_NS_XLINK,
77 : : TB_XML_NAMESPACES_COUNT
78 : : };
79 : :
80 : : OReadToolBoxDocumentHandler( const ::com::sun::star::uno::Reference< com::sun::star::container::XIndexContainer >& rItemContainer );
81 : : virtual ~OReadToolBoxDocumentHandler();
82 : :
83 : : // XDocumentHandler
84 : : virtual void SAL_CALL startDocument(void)
85 : : throw ( ::com::sun::star::xml::sax::SAXException,
86 : : ::com::sun::star::uno::RuntimeException );
87 : :
88 : : virtual void SAL_CALL endDocument(void)
89 : : throw( ::com::sun::star::xml::sax::SAXException,
90 : : ::com::sun::star::uno::RuntimeException );
91 : :
92 : : virtual void SAL_CALL startElement(
93 : : const rtl::OUString& aName,
94 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs)
95 : : throw( ::com::sun::star::xml::sax::SAXException,
96 : : ::com::sun::star::uno::RuntimeException );
97 : :
98 : : virtual void SAL_CALL endElement(const rtl::OUString& aName)
99 : : throw( ::com::sun::star::xml::sax::SAXException,
100 : : ::com::sun::star::uno::RuntimeException );
101 : :
102 : : virtual void SAL_CALL characters(const rtl::OUString& aChars)
103 : : throw( ::com::sun::star::xml::sax::SAXException,
104 : : ::com::sun::star::uno::RuntimeException );
105 : :
106 : : virtual void SAL_CALL ignorableWhitespace(const rtl::OUString& aWhitespaces)
107 : : throw( ::com::sun::star::xml::sax::SAXException,
108 : : ::com::sun::star::uno::RuntimeException );
109 : :
110 : : virtual void SAL_CALL processingInstruction(const rtl::OUString& aTarget,
111 : : const rtl::OUString& aData)
112 : : throw( ::com::sun::star::xml::sax::SAXException,
113 : : ::com::sun::star::uno::RuntimeException );
114 : :
115 : : virtual void SAL_CALL setDocumentLocator(
116 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > &xLocator)
117 : : throw( ::com::sun::star::xml::sax::SAXException,
118 : : ::com::sun::star::uno::RuntimeException );
119 : :
120 : : private:
121 : : ::rtl::OUString getErrorLineString();
122 : :
123 [ + - ]: 452 : class ToolBoxHashMap : public ::boost::unordered_map< ::rtl::OUString ,
124 : : ToolBox_XML_Entry ,
125 : : OUStringHashCode ,
126 : : ::std::equal_to< ::rtl::OUString > >
127 : : {
128 : : public:
129 : : inline void free()
130 : : {
131 : : ToolBoxHashMap().swap( *this );
132 : : }
133 : : };
134 : :
135 : : sal_Bool m_bToolBarStartFound : 1;
136 : : sal_Bool m_bToolBarEndFound : 1;
137 : : sal_Bool m_bToolBarItemStartFound : 1;
138 : : sal_Bool m_bToolBarSpaceStartFound : 1;
139 : : sal_Bool m_bToolBarBreakStartFound : 1;
140 : : sal_Bool m_bToolBarSeparatorStartFound : 1;
141 : : ToolBoxHashMap m_aToolBoxMap;
142 : : com::sun::star::uno::Reference< com::sun::star::container::XIndexContainer > m_rItemContainer;
143 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > m_xLocator;
144 : :
145 : : sal_Int32 m_nHashCode_Style_Radio;
146 : : sal_Int32 m_nHashCode_Style_Auto;
147 : : sal_Int32 m_nHashCode_Style_Left;
148 : : sal_Int32 m_nHashCode_Style_AutoSize;
149 : : sal_Int32 m_nHashCode_Style_DropDown;
150 : : sal_Int32 m_nHashCode_Style_Repeat;
151 : : sal_Int32 m_nHashCode_Style_DropDownOnly;
152 : : sal_Int32 m_nHashCode_Style_Text;
153 : : sal_Int32 m_nHashCode_Style_Image;
154 : : rtl::OUString m_aType;
155 : : rtl::OUString m_aLabel;
156 : : rtl::OUString m_aStyle;
157 : : rtl::OUString m_aHelpURL;
158 : : rtl::OUString m_aTooltip;
159 : : rtl::OUString m_aIsVisible;
160 : : rtl::OUString m_aCommandURL;
161 : : };
162 : :
163 : :
164 : : class FWE_DLLPUBLIC OWriteToolBoxDocumentHandler : private ThreadHelpBase // Struct for right initalization of lock member! Must be first of baseclasses.
165 : : {
166 : : public:
167 : : OWriteToolBoxDocumentHandler(
168 : : const ::com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >& rItemAccess,
169 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler >& rDocumentHandler );
170 : : virtual ~OWriteToolBoxDocumentHandler();
171 : :
172 : : void WriteToolBoxDocument() throw
173 : : ( ::com::sun::star::xml::sax::SAXException,
174 : : ::com::sun::star::uno::RuntimeException );
175 : :
176 : : protected:
177 : : virtual void WriteToolBoxItem( const rtl::OUString& aCommandURL, const rtl::OUString& aLabel, const rtl::OUString& aHelpURL, const rtl::OUString& aTooltip, sal_Int16 nStyle,
178 : : sal_Int16 nWidth, sal_Bool bVisible ) throw
179 : : ( ::com::sun::star::xml::sax::SAXException,
180 : : ::com::sun::star::uno::RuntimeException );
181 : :
182 : : virtual void WriteToolBoxSpace() throw
183 : : ( ::com::sun::star::xml::sax::SAXException,
184 : : ::com::sun::star::uno::RuntimeException );
185 : :
186 : : virtual void WriteToolBoxBreak() throw
187 : : ( ::com::sun::star::xml::sax::SAXException,
188 : : ::com::sun::star::uno::RuntimeException );
189 : :
190 : : virtual void WriteToolBoxSeparator() throw
191 : : ( ::com::sun::star::xml::sax::SAXException,
192 : : ::com::sun::star::uno::RuntimeException );
193 : :
194 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xWriteDocumentHandler;
195 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > m_xEmptyList;
196 : : com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > m_rItemAccess;
197 : : ::rtl::OUString m_aXMLToolbarNS;
198 : : ::rtl::OUString m_aXMLXlinkNS;
199 : : ::rtl::OUString m_aAttributeType;
200 : : ::rtl::OUString m_aAttributeURL;
201 : : };
202 : :
203 : : } // namespace framework
204 : :
205 : : #endif
206 : :
207 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|