1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_FRAMEWORK_INC_XML_TOOLBOXDOCUMENTHANDLER_HXX
21 #define INCLUDED_FRAMEWORK_INC_XML_TOOLBOXDOCUMENTHANDLER_HXX
23 #include <framework/toolboxconfiguration.hxx>
25 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
26 #include <com/sun/star/beans/PropertyValue.hpp>
28 #include <rtl/ustring.hxx>
29 #include <cppuhelper/implbase1.hxx>
31 #include <framework/fwedllapi.h>
35 // Hash code function for using in all hash maps of follow implementation.
37 class FWE_DLLPUBLIC OReadToolBoxDocumentHandler
:
38 public ::cppu::WeakImplHelper1
< ::com::sun::star::xml::sax::XDocumentHandler
>
41 enum ToolBox_XML_Entry
44 TB_ELEMENT_TOOLBARITEM
,
45 TB_ELEMENT_TOOLBARSPACE
,
46 TB_ELEMENT_TOOLBARBREAK
,
47 TB_ELEMENT_TOOLBARSEPARATOR
,
51 TB_ATTRIBUTE_ITEMBITS
,
62 enum ToolBox_XML_Namespace
66 TB_XML_NAMESPACES_COUNT
69 OReadToolBoxDocumentHandler( const ::com::sun::star::uno::Reference
< com::sun::star::container::XIndexContainer
>& rItemContainer
);
70 virtual ~OReadToolBoxDocumentHandler();
73 virtual void SAL_CALL
startDocument()
74 throw ( ::com::sun::star::xml::sax::SAXException
,
75 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
77 virtual void SAL_CALL
endDocument()
78 throw( ::com::sun::star::xml::sax::SAXException
,
79 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
81 virtual void SAL_CALL
startElement(
82 const OUString
& aName
,
83 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
> &xAttribs
)
84 throw( ::com::sun::star::xml::sax::SAXException
,
85 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
87 virtual void SAL_CALL
endElement(const OUString
& aName
)
88 throw( ::com::sun::star::xml::sax::SAXException
,
89 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
91 virtual void SAL_CALL
characters(const OUString
& aChars
)
92 throw( ::com::sun::star::xml::sax::SAXException
,
93 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
95 virtual void SAL_CALL
ignorableWhitespace(const OUString
& aWhitespaces
)
96 throw( ::com::sun::star::xml::sax::SAXException
,
97 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
99 virtual void SAL_CALL
processingInstruction(const OUString
& aTarget
,
100 const OUString
& aData
)
101 throw( ::com::sun::star::xml::sax::SAXException
,
102 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
104 virtual void SAL_CALL
setDocumentLocator(
105 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XLocator
> &xLocator
)
106 throw( ::com::sun::star::xml::sax::SAXException
,
107 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
110 OUString
getErrorLineString();
112 class ToolBoxHashMap
: public std::unordered_map
<OUString
,
115 std::equal_to
< OUString
> >
120 ToolBoxHashMap().swap( *this );// get rid of reserved capacity
124 bool m_bToolBarStartFound
: 1;
125 bool m_bToolBarEndFound
: 1;
126 bool m_bToolBarItemStartFound
: 1;
127 bool m_bToolBarSpaceStartFound
: 1;
128 bool m_bToolBarBreakStartFound
: 1;
129 bool m_bToolBarSeparatorStartFound
: 1;
130 ToolBoxHashMap m_aToolBoxMap
;
131 com::sun::star::uno::Reference
< com::sun::star::container::XIndexContainer
> m_rItemContainer
;
132 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XLocator
> m_xLocator
;
134 sal_Int32 m_nHashCode_Style_Radio
;
135 sal_Int32 m_nHashCode_Style_Auto
;
136 sal_Int32 m_nHashCode_Style_Left
;
137 sal_Int32 m_nHashCode_Style_AutoSize
;
138 sal_Int32 m_nHashCode_Style_DropDown
;
139 sal_Int32 m_nHashCode_Style_Repeat
;
140 sal_Int32 m_nHashCode_Style_DropDownOnly
;
141 sal_Int32 m_nHashCode_Style_Text
;
142 sal_Int32 m_nHashCode_Style_Image
;
148 OUString m_aIsVisible
;
149 OUString m_aCommandURL
;
152 class FWE_DLLPUBLIC OWriteToolBoxDocumentHandler
155 OWriteToolBoxDocumentHandler(
156 const ::com::sun::star::uno::Reference
< com::sun::star::container::XIndexAccess
>& rItemAccess
,
157 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XDocumentHandler
>& rDocumentHandler
);
158 virtual ~OWriteToolBoxDocumentHandler();
160 void WriteToolBoxDocument() throw
161 ( ::com::sun::star::xml::sax::SAXException
,
162 ::com::sun::star::uno::RuntimeException
);
165 void WriteToolBoxItem( const OUString
& aCommandURL
, const OUString
& aLabel
, const OUString
& aHelpURL
, const OUString
& aTooltip
, sal_Int16 nStyle
,
166 sal_Int16 nWidth
, bool bVisible
) throw
167 ( ::com::sun::star::xml::sax::SAXException
,
168 ::com::sun::star::uno::RuntimeException
);
170 void WriteToolBoxSpace() throw
171 ( ::com::sun::star::xml::sax::SAXException
,
172 ::com::sun::star::uno::RuntimeException
);
174 void WriteToolBoxBreak() throw
175 ( ::com::sun::star::xml::sax::SAXException
,
176 ::com::sun::star::uno::RuntimeException
);
178 void WriteToolBoxSeparator() throw
179 ( ::com::sun::star::xml::sax::SAXException
,
180 ::com::sun::star::uno::RuntimeException
);
182 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XDocumentHandler
> m_xWriteDocumentHandler
;
183 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
> m_xEmptyList
;
184 com::sun::star::uno::Reference
< com::sun::star::container::XIndexAccess
> m_rItemAccess
;
185 OUString m_aXMLToolbarNS
;
186 OUString m_aXMLXlinkNS
;
187 OUString m_aAttributeType
;
188 OUString m_aAttributeURL
;
191 } // namespace framework
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */