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: toolboxlayoutdocumenthandler.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_TOOLBOXLAYOUTDOCUMENTHANDLER_HXX_
32 #define __FRAMEWORK_CLASSES_TOOLBOXLAYOUTDOCUMENTHANDLER_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 OReadToolBoxLayoutDocumentHandler
: 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 ToolBoxLayout_XML_Entry
72 TBL_ELEMENT_TOOLBARLAYOUTS
,
73 TBL_ELEMENT_TOOLBARLAYOUT
,
74 TBL_ELEMENT_TOOLBARCONFIGITEMS
,
75 TBL_ELEMENT_TOOLBARCONFIGITEM
,
77 TBL_ATTRIBUTE_TOOLBARNAME
,
78 TBL_ATTRIBUTE_CONTEXT
,
79 TBL_ATTRIBUTE_FLOATINGLINES
,
80 TBL_ATTRIBUTE_DOCKINGLINES
,
82 TBL_ATTRIBUTE_FLOATING
,
83 TBL_ATTRIBUTE_FLOATINGPOSLEFT
,
84 TBL_ATTRIBUTE_FLOATINGPOSTOP
,
85 TBL_ATTRIBUTE_VISIBLE
,
87 TBL_ATTRIBUTE_USERDEFNAME
,
91 enum ToolBox_XML_Namespace
94 TBL_XML_NAMESPACES_COUNT
97 OReadToolBoxLayoutDocumentHandler( ToolBoxLayoutDescriptor
& aToolBoxLayoutItems
);
98 virtual ~OReadToolBoxLayoutDocumentHandler();
101 virtual void SAL_CALL
acquire() throw()
102 { OWeakObject::acquire(); }
103 virtual void SAL_CALL
release() throw()
104 { OWeakObject::release(); }
105 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface(
106 const ::com::sun::star::uno::Type
& rType
) throw( ::com::sun::star::uno::RuntimeException
);
109 virtual void SAL_CALL
startDocument(void)
110 throw ( ::com::sun::star::xml::sax::SAXException
,
111 ::com::sun::star::uno::RuntimeException
);
113 virtual void SAL_CALL
endDocument(void)
114 throw( ::com::sun::star::xml::sax::SAXException
,
115 ::com::sun::star::uno::RuntimeException
);
117 virtual void SAL_CALL
startElement(
118 const rtl::OUString
& aName
,
119 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
> &xAttribs
)
120 throw( ::com::sun::star::xml::sax::SAXException
,
121 ::com::sun::star::uno::RuntimeException
);
123 virtual void SAL_CALL
endElement(const rtl::OUString
& aName
)
124 throw( ::com::sun::star::xml::sax::SAXException
,
125 ::com::sun::star::uno::RuntimeException
);
127 virtual void SAL_CALL
characters(const rtl::OUString
& aChars
)
128 throw( ::com::sun::star::xml::sax::SAXException
,
129 ::com::sun::star::uno::RuntimeException
);
131 virtual void SAL_CALL
ignorableWhitespace(const rtl::OUString
& aWhitespaces
)
132 throw( ::com::sun::star::xml::sax::SAXException
,
133 ::com::sun::star::uno::RuntimeException
);
135 virtual void SAL_CALL
processingInstruction(const rtl::OUString
& aTarget
,
136 const rtl::OUString
& aData
)
137 throw( ::com::sun::star::xml::sax::SAXException
,
138 ::com::sun::star::uno::RuntimeException
);
140 virtual void SAL_CALL
setDocumentLocator(
141 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XLocator
> &xLocator
)
142 throw( ::com::sun::star::xml::sax::SAXException
,
143 ::com::sun::star::uno::RuntimeException
);
146 ::rtl::OUString
getErrorLineString();
148 class ToolBoxLayoutHashMap
: public ::std::hash_map
< ::rtl::OUString
,
149 ToolBoxLayout_XML_Entry
,
151 ::std::equal_to
< ::rtl::OUString
> >
156 ToolBoxLayoutHashMap().swap( *this );
160 sal_Bool m_bToolBarLayoutsStartFound
;
161 sal_Bool m_bToolBarLayoutsEndFound
;
162 sal_Bool m_bToolBarLayoutStartFound
;
163 sal_Bool m_bToolBarConfigListStartFound
;
164 sal_Bool m_bToolBarConfigItemStartFound
;
165 ToolBoxLayoutHashMap m_aToolBoxMap
;
166 ToolBoxLayoutDescriptor
& m_aToolBoxItems
;
167 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XLocator
> m_xLocator
;
170 class OWriteToolBoxLayoutDocumentHandler
: private ThreadHelpBase
// Struct for right initalization of lock member! Must be first of baseclasses.
173 OWriteToolBoxLayoutDocumentHandler(
174 const ToolBoxLayoutDescriptor
& aToolBoxLayoutItems
,
175 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XDocumentHandler
> );
176 virtual ~OWriteToolBoxLayoutDocumentHandler();
178 void WriteToolBoxLayoutDocument() throw
179 ( ::com::sun::star::xml::sax::SAXException
,
180 ::com::sun::star::uno::RuntimeException
);
183 virtual void WriteToolBoxLayoutItem( const ToolBoxLayoutItemDescriptor
* ) throw
184 ( ::com::sun::star::xml::sax::SAXException
,
185 ::com::sun::star::uno::RuntimeException
);
187 const ToolBoxLayoutDescriptor
& m_aToolBoxLayoutItems
;
188 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XDocumentHandler
> m_xWriteDocumentHandler
;
189 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
> m_xEmptyList
;
190 ::rtl::OUString m_aXMLToolbarNS
;
191 ::rtl::OUString m_aAttributeType
;
192 ::rtl::OUString m_aTrueValue
;
193 ::rtl::OUString m_aFalseValue
;
196 } // namespace framework