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_MENUDOCUMENTHANDLER_HXX
21 #define INCLUDED_FRAMEWORK_INC_XML_MENUDOCUMENTHANDLER_HXX
23 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
24 #include <com/sun/star/container/XIndexContainer.hpp>
25 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
26 #include <com/sun/star/beans/PropertyValue.hpp>
27 #include <com/sun/star/uno/Sequence.h>
28 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <rtl/ustring.hxx>
31 #include <cppuhelper/implbase1.hxx>
32 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
33 #include <framework/fwedllapi.h>
37 class FWE_DLLPUBLIC ReadMenuDocumentHandlerBase
:
38 public ::cppu::WeakImplHelper1
< ::com::sun::star::xml::sax::XDocumentHandler
>
41 ReadMenuDocumentHandlerBase();
42 virtual ~ReadMenuDocumentHandlerBase();
45 virtual void SAL_CALL
startDocument()
46 throw ( ::com::sun::star::xml::sax::SAXException
,
47 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
= 0;
49 virtual void SAL_CALL
endDocument()
50 throw( ::com::sun::star::xml::sax::SAXException
,
51 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
= 0;
53 virtual void SAL_CALL
startElement(
54 const OUString
& aName
,
55 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
> &xAttribs
)
56 throw( ::com::sun::star::xml::sax::SAXException
,
57 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
= 0;
59 virtual void SAL_CALL
endElement(const OUString
& aName
)
60 throw( ::com::sun::star::xml::sax::SAXException
,
61 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
= 0;
63 virtual void SAL_CALL
characters(const OUString
& aChars
)
64 throw( ::com::sun::star::xml::sax::SAXException
,
65 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
= 0;
67 virtual void SAL_CALL
ignorableWhitespace(const OUString
& aWhitespaces
)
68 throw( ::com::sun::star::xml::sax::SAXException
,
69 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
71 virtual void SAL_CALL
processingInstruction(const OUString
& aTarget
,
72 const OUString
& aData
)
73 throw( ::com::sun::star::xml::sax::SAXException
,
74 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
76 virtual void SAL_CALL
setDocumentLocator(
77 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XLocator
> &xLocator
)
78 throw( ::com::sun::star::xml::sax::SAXException
,
79 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
82 OUString
getErrorLineString();
84 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XLocator
> m_xLocator
;
85 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XDocumentHandler
> m_xReader
;
86 void initPropertyCommon( com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
> &rProps
,
87 const OUString
&rCommandURL
, const OUString
&rHelpId
,
88 const OUString
&rLabel
, sal_Int16 nItemStyleBits
);
92 OUString m_aContainer
;
94 OUString m_aCommandURL
;
98 class FWE_DLLPUBLIC OReadMenuDocumentHandler
: public ReadMenuDocumentHandlerBase
101 OReadMenuDocumentHandler(
102 const com::sun::star::uno::Reference
< com::sun::star::container::XIndexContainer
>& rItemContainer
);
103 virtual ~OReadMenuDocumentHandler();
106 virtual void SAL_CALL
startDocument()
107 throw ( ::com::sun::star::xml::sax::SAXException
,
108 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
110 virtual void SAL_CALL
endDocument()
111 throw( ::com::sun::star::xml::sax::SAXException
,
112 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
114 virtual void SAL_CALL
startElement(
115 const OUString
& aName
,
116 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
> &xAttribs
)
117 throw( ::com::sun::star::xml::sax::SAXException
,
118 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
120 virtual void SAL_CALL
endElement(const OUString
& aName
)
121 throw( ::com::sun::star::xml::sax::SAXException
,
122 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
124 virtual void SAL_CALL
characters(const OUString
& aChars
)
125 throw( ::com::sun::star::xml::sax::SAXException
,
126 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
131 com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexContainer
> m_xMenuBarContainer
;
132 com::sun::star::uno::Reference
< ::com::sun::star::lang::XSingleComponentFactory
> m_xContainerFactory
;
133 }; // OReadMenuDocumentHandler
135 class FWE_DLLPUBLIC OReadMenuBarHandler
: public ReadMenuDocumentHandlerBase
139 const com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexContainer
>& rMenuBarContainer
,
140 const com::sun::star::uno::Reference
< ::com::sun::star::lang::XSingleComponentFactory
>& rContainerFactory
);
141 virtual ~OReadMenuBarHandler();
144 virtual void SAL_CALL
startDocument()
145 throw ( ::com::sun::star::xml::sax::SAXException
,
146 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
148 virtual void SAL_CALL
endDocument()
149 throw( ::com::sun::star::xml::sax::SAXException
,
150 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
152 virtual void SAL_CALL
startElement(
153 const OUString
& aName
,
154 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
> &xAttribs
)
155 throw( ::com::sun::star::xml::sax::SAXException
,
156 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
158 virtual void SAL_CALL
endElement(const OUString
& aName
)
159 throw( ::com::sun::star::xml::sax::SAXException
,
160 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
162 virtual void SAL_CALL
characters(const OUString
& aChars
)
163 throw( ::com::sun::star::xml::sax::SAXException
,
164 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
169 com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexContainer
> m_xMenuBarContainer
;
170 com::sun::star::uno::Reference
< ::com::sun::star::lang::XSingleComponentFactory
> m_xContainerFactory
;
171 }; // OReadMenuBarHandler
173 class FWE_DLLPUBLIC OReadMenuHandler
: public ReadMenuDocumentHandlerBase
176 OReadMenuHandler( const com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexContainer
>& rMenuContainer
,
177 const com::sun::star::uno::Reference
< ::com::sun::star::lang::XSingleComponentFactory
>& rContainerFactory
);
178 virtual ~OReadMenuHandler();
181 virtual void SAL_CALL
startDocument()
182 throw ( ::com::sun::star::xml::sax::SAXException
,
183 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
185 virtual void SAL_CALL
endDocument()
186 throw( ::com::sun::star::xml::sax::SAXException
,
187 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
189 virtual void SAL_CALL
startElement(
190 const OUString
& aName
,
191 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
> &xAttribs
)
192 throw( ::com::sun::star::xml::sax::SAXException
,
193 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
195 virtual void SAL_CALL
endElement(const OUString
& aName
)
196 throw( ::com::sun::star::xml::sax::SAXException
,
197 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
199 virtual void SAL_CALL
characters(const OUString
& aChars
)
200 throw( ::com::sun::star::xml::sax::SAXException
,
201 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
205 bool m_bMenuPopupMode
;
206 com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexContainer
> m_xMenuContainer
;
207 com::sun::star::uno::Reference
< ::com::sun::star::lang::XSingleComponentFactory
> m_xContainerFactory
;
208 }; // OReadMenuHandler
210 class FWE_DLLPUBLIC OReadMenuPopupHandler
: public ReadMenuDocumentHandlerBase
213 OReadMenuPopupHandler( const com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexContainer
>& rMenuContainer
,
214 const com::sun::star::uno::Reference
< ::com::sun::star::lang::XSingleComponentFactory
>& rContainerFactory
);
215 virtual ~OReadMenuPopupHandler();
218 virtual void SAL_CALL
startDocument()
219 throw ( ::com::sun::star::xml::sax::SAXException
,
220 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
222 virtual void SAL_CALL
endDocument()
223 throw ( ::com::sun::star::xml::sax::SAXException
,
224 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
226 virtual void SAL_CALL
startElement(
227 const OUString
& aName
,
228 const ::com::sun::star::uno::Reference
<
229 ::com::sun::star::xml::sax::XAttributeList
> &xAttribs
)
230 throw ( ::com::sun::star::xml::sax::SAXException
,
231 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
233 virtual void SAL_CALL
endElement(const OUString
& aName
)
234 throw ( ::com::sun::star::xml::sax::SAXException
,
235 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
237 virtual void SAL_CALL
characters(const OUString
& aChars
)
238 throw ( ::com::sun::star::xml::sax::SAXException
,
239 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
242 enum NextElementClose
{ ELEM_CLOSE_NONE
, ELEM_CLOSE_MENUITEM
, ELEM_CLOSE_MENUSEPARATOR
};
246 com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexContainer
> m_xMenuContainer
;
247 com::sun::star::uno::Reference
< ::com::sun::star::lang::XSingleComponentFactory
> m_xContainerFactory
;
248 com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> m_xComponentContext
;
249 NextElementClose m_nNextElementExpected
;
250 }; // OReadMenuPopupHandler
252 class FWE_DLLPUBLIC OWriteMenuDocumentHandler
255 OWriteMenuDocumentHandler(
256 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
>& rMenuBarContainer
,
257 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XDocumentHandler
>& rDocumentHandler
);
258 virtual ~OWriteMenuDocumentHandler();
260 void WriteMenuDocument() throw
261 ( ::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
263 void WriteMenu( const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
>& rSubMenuContainer
) throw
264 ( ::com::sun::star::xml::sax::SAXException
, ::com::sun::star::uno::RuntimeException
);
266 void WriteMenuItem( const OUString
& aCommandURL
, const OUString
& aLabel
, const OUString
& aHelpURL
, sal_Int16 nStyle
= 0 );
267 void WriteMenuSeparator();
269 com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
> m_xMenuBarContainer
;
270 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XDocumentHandler
> m_xWriteDocumentHandler
;
271 ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
> m_xEmptyList
;
272 OUString m_aAttributeType
;
275 } // namespace framework
277 #endif // INCLUDED_FRAMEWORK_INC_XML_MENUDOCUMENTHANDLER_HXX
279 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */