1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: toolboxdocumenthandler.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef __FRAMEWORK_CLASSES_TOOLBOXDOCUMENTHANDLER_HXX_
32 #define __FRAMEWORK_CLASSES_TOOLBOXDOCUMENTHANDLER_HXX_
34 #include <classes/toolboxconfiguration.hxx>
36 //_________________________________________________________________________________________________________________
38 //_________________________________________________________________________________________________________________
40 #ifndef __COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
41 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
44 //_________________________________________________________________________________________________________________
46 //_________________________________________________________________________________________________________________
47 #include <threadhelp/threadhelpbase.hxx>
48 #include <rtl/ustring.hxx>
49 #include <cppuhelper/weak.hxx>
51 #ifndef __SGI_STL_HASH_MAP
56 //_________________________________________________________________________________________________________________
58 //_________________________________________________________________________________________________________________
62 //*****************************************************************************************************************
63 // Hash code function for using in all hash maps of follow implementation.
65 class OReadToolBoxDocumentHandler
: public ::com::sun::star::xml::sax::XDocumentHandler
,
66 private ThreadHelpBase
, // Struct for right initalization of lock member! Must be first of baseclasses.
67 public ::cppu::OWeakObject
70 enum ToolBox_XML_Entry
73 TB_ELEMENT_TOOLBARITEM
,
74 TB_ELEMENT_TOOLBARSPACE
,
75 TB_ELEMENT_TOOLBARBREAK
,
76 TB_ELEMENT_TOOLBARSEPARATOR
,
80 TB_ATTRIBUTE_ITEMBITS
,
89 enum ToolBox_XML_Namespace
93 TB_XML_NAMESPACES_COUNT
96 OReadToolBoxDocumentHandler( ToolBoxDescriptor
& aToolBoxItems
);
97 virtual ~OReadToolBoxDocumentHandler();
100 virtual void SAL_CALL
acquire() throw()
101 { OWeakObject::acquire(); }
102 virtual void SAL_CALL
release() throw()
103 { OWeakObject::release(); }
104 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface(
105 const ::com::sun::star::uno::Type
& rType
) throw( ::com::sun::star::uno::RuntimeException
);
108 virtual void SAL_CALL
startDocument(void)
109 throw ( ::com::sun::star::xml::sax::SAXException
,
110 ::com::sun::star::uno::RuntimeException
);
112 virtual void SAL_CALL
endDocument(void)
113 throw( ::com::sun::star::xml::sax::SAXException
,
114 ::com::sun::star::uno::RuntimeException
);
116 virtual void SAL_CALL
startElement(
117 const rtl::OUString
& aName
,
118 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
> &xAttribs
)
119 throw( ::com::sun::star::xml::sax::SAXException
,
120 ::com::sun::star::uno::RuntimeException
);
122 virtual void SAL_CALL
endElement(const rtl::OUString
& aName
)
123 throw( ::com::sun::star::xml::sax::SAXException
,
124 ::com::sun::star::uno::RuntimeException
);
126 virtual void SAL_CALL
characters(const rtl::OUString
& aChars
)
127 throw( ::com::sun::star::xml::sax::SAXException
,
128 ::com::sun::star::uno::RuntimeException
);
130 virtual void SAL_CALL
ignorableWhitespace(const rtl::OUString
& aWhitespaces
)
131 throw( ::com::sun::star::xml::sax::SAXException
,
132 ::com::sun::star::uno::RuntimeException
);
134 virtual void SAL_CALL
processingInstruction(const rtl::OUString
& aTarget
,
135 const rtl::OUString
& aData
)
136 throw( ::com::sun::star::xml::sax::SAXException
,
137 ::com::sun::star::uno::RuntimeException
);
139 virtual void SAL_CALL
setDocumentLocator(
140 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XLocator
> &xLocator
)
141 throw( ::com::sun::star::xml::sax::SAXException
,
142 ::com::sun::star::uno::RuntimeException
);
145 ::rtl::OUString
getErrorLineString();
147 class ToolBoxHashMap
: public ::std::hash_map
< ::rtl::OUString
,
150 ::std::equal_to
< ::rtl::OUString
> >
155 ToolBoxHashMap().swap( *this );
159 sal_Bool m_bToolBarStartFound
;
160 sal_Bool m_bToolBarEndFound
;
161 sal_Bool m_bToolBarItemStartFound
;
162 sal_Bool m_bToolBarSpaceStartFound
;
163 sal_Bool m_bToolBarBreakStartFound
;
164 sal_Bool m_bToolBarSeparatorStartFound
;
165 ToolBoxHashMap m_aToolBoxMap
;
166 ToolBoxDescriptor
& m_aToolBoxItems
;
167 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XLocator
> m_xLocator
;
169 sal_Int32 m_nHashCode_Style_Radio
;
170 sal_Int32 m_nHashCode_Style_Auto
;
171 sal_Int32 m_nHashCode_Style_Left
;
172 sal_Int32 m_nHashCode_Style_AutoSize
;
173 sal_Int32 m_nHashCode_Style_DropDown
;
174 sal_Int32 m_nHashCode_Style_Repeat
;
177 class OWriteToolBoxDocumentHandler
: private ThreadHelpBase
// Struct for right initalization of lock member! Must be first of baseclasses.
180 OWriteToolBoxDocumentHandler(
181 const ToolBoxDescriptor
& aToolBoxItems
,
182 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XDocumentHandler
> );
183 virtual ~OWriteToolBoxDocumentHandler();
185 void WriteToolBoxDocument() throw
186 ( ::com::sun::star::xml::sax::SAXException
,
187 ::com::sun::star::uno::RuntimeException
);
190 virtual void WriteToolBoxItem( const ToolBoxItemDescriptor
* ) throw
191 ( ::com::sun::star::xml::sax::SAXException
,
192 ::com::sun::star::uno::RuntimeException
);
194 virtual void WriteToolBoxSpace() throw
195 ( ::com::sun::star::xml::sax::SAXException
,
196 ::com::sun::star::uno::RuntimeException
);
198 virtual void WriteToolBoxBreak() throw
199 ( ::com::sun::star::xml::sax::SAXException
,
200 ::com::sun::star::uno::RuntimeException
);
202 virtual void WriteToolBoxSeparator() throw
203 ( ::com::sun::star::xml::sax::SAXException
,
204 ::com::sun::star::uno::RuntimeException
);
206 const ToolBoxDescriptor
& m_aToolBoxItems
;
207 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XDocumentHandler
> m_xWriteDocumentHandler
;
208 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
> m_xEmptyList
;
209 ::rtl::OUString m_aXMLToolbarNS
;
210 ::rtl::OUString m_aXMLXlinkNS
;
211 ::rtl::OUString m_aAttributeType
;
212 ::rtl::OUString m_aAttributeURL
;
215 } // namespace framework