LibreOffice Module framework (master) 1
menudocumenthandler.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
23#include <com/sun/star/container/XIndexContainer.hpp>
24#include <com/sun/star/lang/XSingleComponentFactory.hpp>
25#include <com/sun/star/beans/PropertyValue.hpp>
26#include <com/sun/star/uno/Sequence.h>
27#include <com/sun/star/uno/XComponentContext.hpp>
28
29#include <rtl/ustring.hxx>
31
32namespace framework{
33
34class ReadMenuDocumentHandlerBase : public ::cppu::WeakImplHelper< css::xml::sax::XDocumentHandler >
35{
36 public:
38 virtual ~ReadMenuDocumentHandlerBase() override;
39
40 // XDocumentHandler
41 virtual void SAL_CALL startDocument() override = 0;
42
43 virtual void SAL_CALL endDocument() override = 0;
44
45 virtual void SAL_CALL startElement(
46 const OUString& aName,
47 const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override = 0;
48
49 virtual void SAL_CALL endElement(const OUString& aName) override = 0;
50
51 virtual void SAL_CALL characters(const OUString& aChars) override = 0;
52
53 virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override;
54
55 virtual void SAL_CALL processingInstruction(const OUString& aTarget,
56 const OUString& aData) override;
57
58 virtual void SAL_CALL setDocumentLocator(
59 const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override;
60
61 protected:
62 OUString getErrorLineString();
63
64 css::uno::Reference< css::xml::sax::XLocator > m_xLocator;
65 css::uno::Reference< css::xml::sax::XDocumentHandler> m_xReader;
66 void initPropertyCommon( css::uno::Sequence< css::beans::PropertyValue > &rProps,
67 const OUString &rCommandURL, const OUString &rHelpId,
68 const OUString &rLabel, sal_Int16 nItemStyleBits );
69 private:
70 OUString m_aType;
71 OUString m_aLabel;
72 OUString m_aContainer;
73 OUString m_aHelpURL;
74 OUString m_aCommandURL;
75 OUString m_aStyle;
76};
77
79{
80 public:
82 const css::uno::Reference< css::container::XIndexContainer >& rItemContainer );
83 virtual ~OReadMenuDocumentHandler() override;
84
85 // XDocumentHandler
86 virtual void SAL_CALL startDocument() override;
87
88 virtual void SAL_CALL endDocument() override;
89
90 virtual void SAL_CALL startElement(
91 const OUString& aName,
92 const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override;
93
94 virtual void SAL_CALL endElement(const OUString& aName) override;
95
96 virtual void SAL_CALL characters(const OUString& aChars) override;
97
98 private:
102 css::uno::Reference< css::container::XIndexContainer > m_xMenuBarContainer;
103 css::uno::Reference< css::lang::XSingleComponentFactory > m_xContainerFactory;
104}; // OReadMenuDocumentHandler
105
107{
108 public:
110 const css::uno::Reference< css::container::XIndexContainer >& rMenuBarContainer,
111 const css::uno::Reference< css::lang::XSingleComponentFactory >& rContainerFactory );
112 virtual ~OReadMenuBarHandler() override;
113
114 // XDocumentHandler
115 virtual void SAL_CALL startDocument() override;
116
117 virtual void SAL_CALL endDocument() override;
118
119 virtual void SAL_CALL startElement(
120 const OUString& aName,
121 const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override;
122
123 virtual void SAL_CALL endElement(const OUString& aName) override;
124
125 virtual void SAL_CALL characters(const OUString& aChars) override;
126
127 private:
130 css::uno::Reference< css::container::XIndexContainer > m_xMenuBarContainer;
131 css::uno::Reference< css::lang::XSingleComponentFactory > m_xContainerFactory;
132}; // OReadMenuBarHandler
133
135{
136 public:
137 OReadMenuHandler( const css::uno::Reference< css::container::XIndexContainer >& rMenuContainer,
138 const css::uno::Reference< css::lang::XSingleComponentFactory >& rContainerFactory );
139 virtual ~OReadMenuHandler() override;
140
141 // XDocumentHandler
142 virtual void SAL_CALL startDocument() override;
143
144 virtual void SAL_CALL endDocument() override;
145
146 virtual void SAL_CALL startElement(
147 const OUString& aName,
148 const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override;
149
150 virtual void SAL_CALL endElement(const OUString& aName) override;
151
152 virtual void SAL_CALL characters(const OUString& aChars) override;
153
154 private:
157 css::uno::Reference< css::container::XIndexContainer > m_xMenuContainer;
158 css::uno::Reference< css::lang::XSingleComponentFactory > m_xContainerFactory;
159}; // OReadMenuHandler
160
162{
163 public:
164 OReadMenuPopupHandler( const css::uno::Reference< css::container::XIndexContainer >& rMenuContainer,
165 const css::uno::Reference< css::lang::XSingleComponentFactory >& rContainerFactory );
166 virtual ~OReadMenuPopupHandler() override;
167
168 // XDocumentHandler
169 virtual void SAL_CALL startDocument() override;
170
171 virtual void SAL_CALL endDocument() override;
172
173 virtual void SAL_CALL startElement(
174 const OUString& aName,
175 const css::uno::Reference<
176 css::xml::sax::XAttributeList > &xAttribs) override;
177
178 virtual void SAL_CALL endElement(const OUString& aName) override;
179
180 virtual void SAL_CALL characters(const OUString& aChars) override;
181
182 private:
184
187 css::uno::Reference< css::container::XIndexContainer > m_xMenuContainer;
188 css::uno::Reference< css::lang::XSingleComponentFactory > m_xContainerFactory;
189 css::uno::Reference< css::uno::XComponentContext > m_xComponentContext;
191}; // OReadMenuPopupHandler
192
194{
195 public:
197 const css::uno::Reference< css::container::XIndexAccess >& rMenuBarContainer,
198 const css::uno::Reference< css::xml::sax::XDocumentHandler >& rDocumentHandler,
199 bool bIsMenuBar );
201
204 void WriteMenuDocument();
205 private:
208 void WriteMenu( const css::uno::Reference< css::container::XIndexAccess >& rSubMenuContainer );
209
210 void WriteMenuItem( const OUString& aCommandURL, const OUString& aLabel, const OUString& aHelpURL, sal_Int16 nStyle );
211 void WriteMenuSeparator();
212
213 css::uno::Reference< css::container::XIndexAccess > m_xMenuBarContainer;
214 css::uno::Reference< css::xml::sax::XDocumentHandler > m_xWriteDocumentHandler;
215 css::uno::Reference< css::xml::sax::XAttributeList > m_xEmptyList;
217};
218
219} // namespace framework
220
221/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::lang::XSingleComponentFactory > m_xContainerFactory
virtual void SAL_CALL characters(const OUString &aChars) override
virtual void SAL_CALL startDocument() override
virtual void SAL_CALL endElement(const OUString &aName) override
virtual void SAL_CALL startElement(const OUString &aName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override
virtual void SAL_CALL endDocument() override
css::uno::Reference< css::container::XIndexContainer > m_xMenuBarContainer
OReadMenuBarHandler(const css::uno::Reference< css::container::XIndexContainer > &rMenuBarContainer, const css::uno::Reference< css::lang::XSingleComponentFactory > &rContainerFactory)
virtual void SAL_CALL startDocument() override
css::uno::Reference< css::lang::XSingleComponentFactory > m_xContainerFactory
virtual void SAL_CALL startElement(const OUString &aName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override
virtual void SAL_CALL characters(const OUString &aChars) override
virtual void SAL_CALL endDocument() override
OReadMenuDocumentHandler(const css::uno::Reference< css::container::XIndexContainer > &rItemContainer)
virtual void SAL_CALL endElement(const OUString &aName) override
css::uno::Reference< css::container::XIndexContainer > m_xMenuBarContainer
virtual void SAL_CALL startElement(const OUString &aName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override
virtual void SAL_CALL characters(const OUString &aChars) override
virtual void SAL_CALL startDocument() override
css::uno::Reference< css::lang::XSingleComponentFactory > m_xContainerFactory
OReadMenuHandler(const css::uno::Reference< css::container::XIndexContainer > &rMenuContainer, const css::uno::Reference< css::lang::XSingleComponentFactory > &rContainerFactory)
virtual void SAL_CALL endDocument() override
virtual void SAL_CALL endElement(const OUString &aName) override
css::uno::Reference< css::container::XIndexContainer > m_xMenuContainer
virtual void SAL_CALL characters(const OUString &aChars) override
css::uno::Reference< css::uno::XComponentContext > m_xComponentContext
virtual void SAL_CALL startElement(const OUString &aName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override
virtual void SAL_CALL endDocument() override
virtual void SAL_CALL startDocument() override
virtual void SAL_CALL endElement(const OUString &aName) override
OReadMenuPopupHandler(const css::uno::Reference< css::container::XIndexContainer > &rMenuContainer, const css::uno::Reference< css::lang::XSingleComponentFactory > &rContainerFactory)
css::uno::Reference< css::container::XIndexContainer > m_xMenuContainer
css::uno::Reference< css::lang::XSingleComponentFactory > m_xContainerFactory
void WriteMenu(const css::uno::Reference< css::container::XIndexAccess > &rSubMenuContainer)
css::uno::Reference< css::xml::sax::XDocumentHandler > m_xWriteDocumentHandler
void WriteMenuItem(const OUString &aCommandURL, const OUString &aLabel, const OUString &aHelpURL, sal_Int16 nStyle)
css::uno::Reference< css::xml::sax::XAttributeList > m_xEmptyList
OWriteMenuDocumentHandler(const css::uno::Reference< css::container::XIndexAccess > &rMenuBarContainer, const css::uno::Reference< css::xml::sax::XDocumentHandler > &rDocumentHandler, bool bIsMenuBar)
css::uno::Reference< css::container::XIndexAccess > m_xMenuBarContainer
virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override
virtual void SAL_CALL endElement(const OUString &aName) override=0
virtual void SAL_CALL endDocument() override=0
virtual void SAL_CALL ignorableWhitespace(const OUString &aWhitespaces) override
virtual void SAL_CALL startDocument() override=0
void initPropertyCommon(css::uno::Sequence< css::beans::PropertyValue > &rProps, const OUString &rCommandURL, const OUString &rHelpId, const OUString &rLabel, sal_Int16 nItemStyleBits)
virtual void SAL_CALL startElement(const OUString &aName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override=0
virtual void SAL_CALL characters(const OUString &aChars) override=0
css::uno::Reference< css::xml::sax::XDocumentHandler > m_xReader
virtual void SAL_CALL processingInstruction(const OUString &aTarget, const OUString &aData) override
css::uno::Reference< css::xml::sax::XLocator > m_xLocator
OUString aName
None
OUString aLabel