1f8e07b45SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f8e07b45SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f8e07b45SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f8e07b45SAndrew Rist  * distributed with this work for additional information
6f8e07b45SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f8e07b45SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f8e07b45SAndrew Rist  * "License"); you may not use this file except in compliance
9f8e07b45SAndrew Rist  * with the License.  You may obtain a copy of the License at
10f8e07b45SAndrew Rist  *
11f8e07b45SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12f8e07b45SAndrew Rist  *
13f8e07b45SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f8e07b45SAndrew Rist  * software distributed under the License is distributed on an
15f8e07b45SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f8e07b45SAndrew Rist  * KIND, either express or implied.  See the License for the
17f8e07b45SAndrew Rist  * specific language governing permissions and limitations
18f8e07b45SAndrew Rist  * under the License.
19f8e07b45SAndrew Rist  *
20f8e07b45SAndrew Rist  *************************************************************/
21f8e07b45SAndrew Rist 
22f8e07b45SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef __FRAMEWORK_XML_TOOLBOXDOCUMENTHANDLER_HXX_
25cdf0e10cSrcweir #define __FRAMEWORK_XML_TOOLBOXDOCUMENTHANDLER_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <framework/toolboxconfiguration.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir //_________________________________________________________________________________________________________________
30cdf0e10cSrcweir //  interface includes
31cdf0e10cSrcweir //_________________________________________________________________________________________________________________
32cdf0e10cSrcweir #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
33cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir //_________________________________________________________________________________________________________________
36cdf0e10cSrcweir //  other includes
37cdf0e10cSrcweir //_________________________________________________________________________________________________________________
38cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx>
39cdf0e10cSrcweir #include <rtl/ustring.hxx>
40cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
41cdf0e10cSrcweir #include <stdtypes.h>
42cdf0e10cSrcweir #include <framework/fwedllapi.h>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir //_________________________________________________________________________________________________________________
45cdf0e10cSrcweir //  namespace
46cdf0e10cSrcweir //_________________________________________________________________________________________________________________
47cdf0e10cSrcweir 
48cdf0e10cSrcweir namespace framework{
49cdf0e10cSrcweir 
50cdf0e10cSrcweir //*****************************************************************************************************************
51cdf0e10cSrcweir // Hash code function for using in all hash maps of follow implementation.
52cdf0e10cSrcweir 
53cdf0e10cSrcweir class FWE_DLLPUBLIC OReadToolBoxDocumentHandler : private ThreadHelpBase,   // Struct for right initalization of lock member! Must be first of baseclasses.
54cdf0e10cSrcweir                                     public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XDocumentHandler >
55cdf0e10cSrcweir {
56cdf0e10cSrcweir     public:
57cdf0e10cSrcweir         enum ToolBox_XML_Entry
58cdf0e10cSrcweir         {
59cdf0e10cSrcweir             TB_ELEMENT_TOOLBAR,
60cdf0e10cSrcweir             TB_ELEMENT_TOOLBARITEM,
61cdf0e10cSrcweir             TB_ELEMENT_TOOLBARSPACE,
62cdf0e10cSrcweir             TB_ELEMENT_TOOLBARBREAK,
63cdf0e10cSrcweir             TB_ELEMENT_TOOLBARSEPARATOR,
64cdf0e10cSrcweir             TB_ATTRIBUTE_TEXT,
65cdf0e10cSrcweir             TB_ATTRIBUTE_BITMAP,
66cdf0e10cSrcweir             TB_ATTRIBUTE_URL,
67cdf0e10cSrcweir             TB_ATTRIBUTE_ITEMBITS,
68cdf0e10cSrcweir             TB_ATTRIBUTE_VISIBLE,
69cdf0e10cSrcweir             TB_ATTRIBUTE_WIDTH,
70cdf0e10cSrcweir             TB_ATTRIBUTE_USER,
71cdf0e10cSrcweir             TB_ATTRIBUTE_HELPID,
72cdf0e10cSrcweir             TB_ATTRIBUTE_STYLE,
73cdf0e10cSrcweir             TB_ATTRIBUTE_UINAME,
74cdf0e10cSrcweir             TB_ATTRIBUTE_TOOLTIP,
75cdf0e10cSrcweir 			TB_XML_ENTRY_COUNT
76cdf0e10cSrcweir 		};
77cdf0e10cSrcweir 
78cdf0e10cSrcweir         enum ToolBox_XML_Namespace
79cdf0e10cSrcweir         {
80cdf0e10cSrcweir             TB_NS_TOOLBAR,
81cdf0e10cSrcweir             TB_NS_XLINK,
82cdf0e10cSrcweir             TB_XML_NAMESPACES_COUNT
83cdf0e10cSrcweir         };
84cdf0e10cSrcweir 
85cdf0e10cSrcweir         OReadToolBoxDocumentHandler( const ::com::sun::star::uno::Reference< com::sun::star::container::XIndexContainer >& rItemContainer );
86cdf0e10cSrcweir         virtual ~OReadToolBoxDocumentHandler();
87cdf0e10cSrcweir 
88cdf0e10cSrcweir         // XDocumentHandler
89cdf0e10cSrcweir         virtual void SAL_CALL startDocument(void)
90cdf0e10cSrcweir         throw ( ::com::sun::star::xml::sax::SAXException,
91cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException );
92cdf0e10cSrcweir 
93cdf0e10cSrcweir         virtual void SAL_CALL endDocument(void)
94cdf0e10cSrcweir         throw(  ::com::sun::star::xml::sax::SAXException,
95cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException );
96cdf0e10cSrcweir 
97cdf0e10cSrcweir         virtual void SAL_CALL startElement(
98cdf0e10cSrcweir             const rtl::OUString& aName,
99cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs)
100cdf0e10cSrcweir         throw(  ::com::sun::star::xml::sax::SAXException,
101cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException );
102cdf0e10cSrcweir 
103cdf0e10cSrcweir         virtual void SAL_CALL endElement(const rtl::OUString& aName)
104cdf0e10cSrcweir         throw(  ::com::sun::star::xml::sax::SAXException,
105cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException );
106cdf0e10cSrcweir 
107cdf0e10cSrcweir         virtual void SAL_CALL characters(const rtl::OUString& aChars)
108cdf0e10cSrcweir         throw(  ::com::sun::star::xml::sax::SAXException,
109cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException );
110cdf0e10cSrcweir 
111cdf0e10cSrcweir         virtual void SAL_CALL ignorableWhitespace(const rtl::OUString& aWhitespaces)
112cdf0e10cSrcweir         throw(  ::com::sun::star::xml::sax::SAXException,
113cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException );
114cdf0e10cSrcweir 
115cdf0e10cSrcweir         virtual void SAL_CALL processingInstruction(const rtl::OUString& aTarget,
116cdf0e10cSrcweir                                                     const rtl::OUString& aData)
117cdf0e10cSrcweir         throw(  ::com::sun::star::xml::sax::SAXException,
118cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException );
119cdf0e10cSrcweir 
120cdf0e10cSrcweir         virtual void SAL_CALL setDocumentLocator(
121cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > &xLocator)
122cdf0e10cSrcweir         throw(  ::com::sun::star::xml::sax::SAXException,
123cdf0e10cSrcweir                 ::com::sun::star::uno::RuntimeException );
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     private:
126cdf0e10cSrcweir         ::rtl::OUString getErrorLineString();
127cdf0e10cSrcweir 
128cdf0e10cSrcweir         class ToolBoxHashMap : public ::std::hash_map<  ::rtl::OUString                 ,
129cdf0e10cSrcweir                                                         ToolBox_XML_Entry               ,
130*5758ad8cSAriel Constenla-Haile                                                         rtl::OUStringHash,
131cdf0e10cSrcweir                                                         ::std::equal_to< ::rtl::OUString >  >
132cdf0e10cSrcweir         {
133cdf0e10cSrcweir             public:
free()134cdf0e10cSrcweir                 inline void free()
135cdf0e10cSrcweir                 {
136cdf0e10cSrcweir                     ToolBoxHashMap().swap( *this );
137cdf0e10cSrcweir                 }
138cdf0e10cSrcweir         };
139cdf0e10cSrcweir 
140cdf0e10cSrcweir         sal_Bool                                                                        m_bToolBarStartFound : 1;
141cdf0e10cSrcweir         sal_Bool                                                                        m_bToolBarEndFound : 1;
142cdf0e10cSrcweir         sal_Bool                                                                        m_bToolBarItemStartFound : 1;
143cdf0e10cSrcweir         sal_Bool                                                                        m_bToolBarSpaceStartFound : 1;
144cdf0e10cSrcweir         sal_Bool                                                                        m_bToolBarBreakStartFound : 1;
145cdf0e10cSrcweir         sal_Bool                                                                        m_bToolBarSeparatorStartFound : 1;
146cdf0e10cSrcweir         ToolBoxHashMap                                                                  m_aToolBoxMap;
147cdf0e10cSrcweir         com::sun::star::uno::Reference< com::sun::star::container::XIndexContainer >    m_rItemContainer;
148cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >        m_xLocator;
149cdf0e10cSrcweir 
150cdf0e10cSrcweir         sal_Int32                                                                       m_nHashCode_Style_Radio;
151cdf0e10cSrcweir         sal_Int32                                                                       m_nHashCode_Style_Auto;
152cdf0e10cSrcweir         sal_Int32                                                                       m_nHashCode_Style_Left;
153cdf0e10cSrcweir         sal_Int32                                                                       m_nHashCode_Style_AutoSize;
154cdf0e10cSrcweir         sal_Int32                                                                       m_nHashCode_Style_DropDown;
155cdf0e10cSrcweir         sal_Int32                                                                       m_nHashCode_Style_Repeat;
156cdf0e10cSrcweir         sal_Int32                                                                       m_nHashCode_Style_DropDownOnly;
157cdf0e10cSrcweir         sal_Int32                                                                       m_nHashCode_Style_Text;
158cdf0e10cSrcweir         sal_Int32                                                                       m_nHashCode_Style_Image;
159cdf0e10cSrcweir 		rtl::OUString                                                                   m_aType;
160cdf0e10cSrcweir 		rtl::OUString                                                                   m_aLabel;
161cdf0e10cSrcweir 		rtl::OUString                                                                   m_aStyle;
162cdf0e10cSrcweir 		rtl::OUString                                                                   m_aHelpURL;
163cdf0e10cSrcweir         rtl::OUString                                                                   m_aTooltip;
164cdf0e10cSrcweir 		rtl::OUString                                                                   m_aIsVisible;
165cdf0e10cSrcweir 		rtl::OUString                                                                   m_aCommandURL;
166cdf0e10cSrcweir };
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 
169cdf0e10cSrcweir class FWE_DLLPUBLIC OWriteToolBoxDocumentHandler : private ThreadHelpBase   // Struct for right initalization of lock member! Must be first of baseclasses.
170cdf0e10cSrcweir {
171cdf0e10cSrcweir     public:
172cdf0e10cSrcweir             OWriteToolBoxDocumentHandler(
173cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >& rItemAccess,
174cdf0e10cSrcweir             ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler >& rDocumentHandler );
175cdf0e10cSrcweir         virtual ~OWriteToolBoxDocumentHandler();
176cdf0e10cSrcweir 
177cdf0e10cSrcweir         void WriteToolBoxDocument() throw
178cdf0e10cSrcweir 			( ::com::sun::star::xml::sax::SAXException,
179cdf0e10cSrcweir 			  ::com::sun::star::uno::RuntimeException );
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 	protected:
182cdf0e10cSrcweir         virtual void WriteToolBoxItem( const rtl::OUString& aCommandURL, const rtl::OUString& aLabel, const rtl::OUString& aHelpURL, const rtl::OUString& aTooltip, sal_Int16 nStyle,
183cdf0e10cSrcweir                                        sal_Int16 nWidth, sal_Bool bVisible ) throw
184cdf0e10cSrcweir             ( ::com::sun::star::xml::sax::SAXException,
185cdf0e10cSrcweir               ::com::sun::star::uno::RuntimeException );
186cdf0e10cSrcweir 
187cdf0e10cSrcweir         virtual void WriteToolBoxSpace() throw
188cdf0e10cSrcweir             ( ::com::sun::star::xml::sax::SAXException,
189cdf0e10cSrcweir               ::com::sun::star::uno::RuntimeException );
190cdf0e10cSrcweir 
191cdf0e10cSrcweir         virtual void WriteToolBoxBreak() throw
192cdf0e10cSrcweir             ( ::com::sun::star::xml::sax::SAXException,
193cdf0e10cSrcweir               ::com::sun::star::uno::RuntimeException );
194cdf0e10cSrcweir 
195cdf0e10cSrcweir         virtual void WriteToolBoxSeparator() throw
196cdf0e10cSrcweir             ( ::com::sun::star::xml::sax::SAXException,
197cdf0e10cSrcweir               ::com::sun::star::uno::RuntimeException );
198cdf0e10cSrcweir 
199cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler >    m_xWriteDocumentHandler;
200cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >      m_xEmptyList;
201cdf0e10cSrcweir         com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >           m_rItemAccess;
202cdf0e10cSrcweir         ::rtl::OUString                                                                     m_aXMLToolbarNS;
203cdf0e10cSrcweir         ::rtl::OUString                                                                     m_aXMLXlinkNS;
204cdf0e10cSrcweir         ::rtl::OUString                                                                     m_aAttributeType;
205cdf0e10cSrcweir         ::rtl::OUString                                                                     m_aAttributeURL;
206cdf0e10cSrcweir };
207cdf0e10cSrcweir 
208cdf0e10cSrcweir } // namespace framework
209cdf0e10cSrcweir 
210cdf0e10cSrcweir #endif
211