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_XML_TOOLBOXDOCUMENTHANDLER_HXX_
32 #define __FRAMEWORK_XML_TOOLBOXDOCUMENTHANDLER_HXX_
34 #include <xml/toolboxconfiguration.hxx>
36 //_________________________________________________________________________________________________________________
38 //_________________________________________________________________________________________________________________
39 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
40 #include <com/sun/star/beans/PropertyValue.hpp>
42 //_________________________________________________________________________________________________________________
44 //_________________________________________________________________________________________________________________
45 #include <threadhelp/threadhelpbase.hxx>
46 #include <rtl/ustring.hxx>
47 #include <cppuhelper/implbase1.hxx>
50 //_________________________________________________________________________________________________________________
52 //_________________________________________________________________________________________________________________
56 //*****************************************************************************************************************
57 // Hash code function for using in all hash maps of follow implementation.
59 class OReadToolBoxDocumentHandler
: private ThreadHelpBase
, // Struct for right initalization of lock member! Must be first of baseclasses.
60 public ::cppu::WeakImplHelper1
< ::com::sun::star::xml::sax::XDocumentHandler
>
63 enum ToolBox_XML_Entry
66 TB_ELEMENT_TOOLBARITEM
,
67 TB_ELEMENT_TOOLBARSPACE
,
68 TB_ELEMENT_TOOLBARBREAK
,
69 TB_ELEMENT_TOOLBARSEPARATOR
,
73 TB_ATTRIBUTE_ITEMBITS
,
83 enum ToolBox_XML_Namespace
87 TB_XML_NAMESPACES_COUNT
90 OReadToolBoxDocumentHandler( const ::com::sun::star::uno::Reference
< com::sun::star::container::XIndexContainer
>& rItemContainer
);
91 virtual ~OReadToolBoxDocumentHandler();
94 virtual void SAL_CALL
startDocument(void)
95 throw ( ::com::sun::star::xml::sax::SAXException
,
96 ::com::sun::star::uno::RuntimeException
);
98 virtual void SAL_CALL
endDocument(void)
99 throw( ::com::sun::star::xml::sax::SAXException
,
100 ::com::sun::star::uno::RuntimeException
);
102 virtual void SAL_CALL
startElement(
103 const rtl::OUString
& aName
,
104 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
> &xAttribs
)
105 throw( ::com::sun::star::xml::sax::SAXException
,
106 ::com::sun::star::uno::RuntimeException
);
108 virtual void SAL_CALL
endElement(const rtl::OUString
& aName
)
109 throw( ::com::sun::star::xml::sax::SAXException
,
110 ::com::sun::star::uno::RuntimeException
);
112 virtual void SAL_CALL
characters(const rtl::OUString
& aChars
)
113 throw( ::com::sun::star::xml::sax::SAXException
,
114 ::com::sun::star::uno::RuntimeException
);
116 virtual void SAL_CALL
ignorableWhitespace(const rtl::OUString
& aWhitespaces
)
117 throw( ::com::sun::star::xml::sax::SAXException
,
118 ::com::sun::star::uno::RuntimeException
);
120 virtual void SAL_CALL
processingInstruction(const rtl::OUString
& aTarget
,
121 const rtl::OUString
& aData
)
122 throw( ::com::sun::star::xml::sax::SAXException
,
123 ::com::sun::star::uno::RuntimeException
);
125 virtual void SAL_CALL
setDocumentLocator(
126 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XLocator
> &xLocator
)
127 throw( ::com::sun::star::xml::sax::SAXException
,
128 ::com::sun::star::uno::RuntimeException
);
131 ::rtl::OUString
getErrorLineString();
133 class ToolBoxHashMap
: public ::std::hash_map
< ::rtl::OUString
,
136 ::std::equal_to
< ::rtl::OUString
> >
141 ToolBoxHashMap().swap( *this );
145 sal_Bool m_bToolBarStartFound
: 1;
146 sal_Bool m_bToolBarEndFound
: 1;
147 sal_Bool m_bToolBarItemStartFound
: 1;
148 sal_Bool m_bToolBarSpaceStartFound
: 1;
149 sal_Bool m_bToolBarBreakStartFound
: 1;
150 sal_Bool m_bToolBarSeparatorStartFound
: 1;
151 ToolBoxHashMap m_aToolBoxMap
;
152 com::sun::star::uno::Reference
< com::sun::star::container::XIndexContainer
> m_rItemContainer
;
153 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XLocator
> m_xLocator
;
155 sal_Int32 m_nHashCode_Style_Radio
;
156 sal_Int32 m_nHashCode_Style_Auto
;
157 sal_Int32 m_nHashCode_Style_Left
;
158 sal_Int32 m_nHashCode_Style_AutoSize
;
159 sal_Int32 m_nHashCode_Style_DropDown
;
160 sal_Int32 m_nHashCode_Style_Repeat
;
161 sal_Int32 m_nHashCode_Style_DropDownOnly
;
162 rtl::OUString m_aType
;
163 rtl::OUString m_aLabel
;
164 rtl::OUString m_aStyle
;
165 rtl::OUString m_aHelpURL
;
166 rtl::OUString m_aIsVisible
;
167 rtl::OUString m_aCommandURL
;
171 class OWriteToolBoxDocumentHandler
: private ThreadHelpBase
// Struct for right initalization of lock member! Must be first of baseclasses.
174 OWriteToolBoxDocumentHandler(
175 const ::com::sun::star::uno::Reference
< com::sun::star::container::XIndexAccess
>& rItemAccess
,
176 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XDocumentHandler
>& rDocumentHandler
);
177 virtual ~OWriteToolBoxDocumentHandler();
179 void WriteToolBoxDocument() throw
180 ( ::com::sun::star::xml::sax::SAXException
,
181 ::com::sun::star::uno::RuntimeException
);
184 virtual void WriteToolBoxItem( const rtl::OUString
& aCommandURL
, const rtl::OUString
& aLabel
, const rtl::OUString
& aHelpURL
,
185 sal_Int16 nWidth
, sal_Bool bVisible
) throw
186 ( ::com::sun::star::xml::sax::SAXException
,
187 ::com::sun::star::uno::RuntimeException
);
189 virtual void WriteToolBoxSpace() throw
190 ( ::com::sun::star::xml::sax::SAXException
,
191 ::com::sun::star::uno::RuntimeException
);
193 virtual void WriteToolBoxBreak() throw
194 ( ::com::sun::star::xml::sax::SAXException
,
195 ::com::sun::star::uno::RuntimeException
);
197 virtual void WriteToolBoxSeparator() throw
198 ( ::com::sun::star::xml::sax::SAXException
,
199 ::com::sun::star::uno::RuntimeException
);
201 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XDocumentHandler
> m_xWriteDocumentHandler
;
202 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
> m_xEmptyList
;
203 com::sun::star::uno::Reference
< com::sun::star::container::XIndexAccess
> m_rItemAccess
;
204 ::rtl::OUString m_aXMLToolbarNS
;
205 ::rtl::OUString m_aXMLXlinkNS
;
206 ::rtl::OUString m_aAttributeType
;
207 ::rtl::OUString m_aAttributeURL
;
210 } // namespace framework