Branch data Line data Source code
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 : : #ifndef XMLSCRIPT_XMLBAS_IMPORT_HXX
21 : : #define XMLSCRIPT_XMLBAS_IMPORT_HXX
22 : :
23 : : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
24 : : #include <com/sun/star/document/XImporter.hpp>
25 : : #include <com/sun/star/frame/XModel.hpp>
26 : : #include <com/sun/star/lang/XServiceInfo.hpp>
27 : : #include <com/sun/star/script/XLibraryContainer2.hpp>
28 : : #include <com/sun/star/uno/XComponentContext.hpp>
29 : : #include <com/sun/star/xml/input/XRoot.hpp>
30 : : #include <cppuhelper/implbase1.hxx>
31 : : #include <cppuhelper/implbase3.hxx>
32 : : #include <osl/mutex.hxx>
33 : : #include <rtl/ustrbuf.hxx>
34 : :
35 : :
36 : : //.........................................................................
37 : : namespace xmlscript
38 : : {
39 : : //.........................................................................
40 : :
41 : : // =============================================================================
42 : : // class BasicElementBase
43 : : // =============================================================================
44 : :
45 : : class BasicImport;
46 : :
47 : : typedef ::cppu::WeakImplHelper1<
48 : : ::com::sun::star::xml::input::XElement > BasicElementBase_BASE;
49 : :
50 : : class BasicElementBase : public BasicElementBase_BASE
51 : : {
52 : : protected:
53 : : BasicImport* m_pImport;
54 : : BasicElementBase* m_pParent;
55 : : ::rtl::OUString m_aLocalName;
56 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes > m_xAttributes;
57 : :
58 : : bool getBoolAttr( sal_Bool* pRet, const ::rtl::OUString& rAttrName,
59 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes >& xAttributes,
60 : : sal_Int32 nUid );
61 : :
62 : : public:
63 : : BasicElementBase( const ::rtl::OUString& rLocalName,
64 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes >& xAttributes,
65 : : BasicElementBase* pParent, BasicImport* pImport );
66 : : virtual ~BasicElementBase();
67 : :
68 : : // XElement
69 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XElement > SAL_CALL getParent()
70 : : throw (::com::sun::star::uno::RuntimeException);
71 : : virtual ::rtl::OUString SAL_CALL getLocalName()
72 : : throw (::com::sun::star::uno::RuntimeException);
73 : : virtual sal_Int32 SAL_CALL getUid()
74 : : throw (::com::sun::star::uno::RuntimeException);
75 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes > SAL_CALL getAttributes()
76 : : throw (::com::sun::star::uno::RuntimeException);
77 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XElement > SAL_CALL startChildElement(
78 : : sal_Int32 nUid, const ::rtl::OUString& rLocalName,
79 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes >& xAttributes )
80 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
81 : : virtual void SAL_CALL characters( const ::rtl::OUString& rChars )
82 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
83 : : virtual void SAL_CALL ignorableWhitespace(
84 : : const ::rtl::OUString& rWhitespaces )
85 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
86 : : virtual void SAL_CALL processingInstruction(
87 : : const ::rtl::OUString& rTarget, const ::rtl::OUString& rData )
88 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
89 : : virtual void SAL_CALL endElement()
90 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
91 : : };
92 : :
93 : :
94 : : // =============================================================================
95 : : // class BasicLibrariesElement
96 : : // =============================================================================
97 : :
98 [ # # ]: 0 : class BasicLibrariesElement : public BasicElementBase
99 : : {
100 : : private:
101 : : ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer2 > m_xLibContainer;
102 : :
103 : : public:
104 : : BasicLibrariesElement( const ::rtl::OUString& rLocalName,
105 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes >& xAttributes,
106 : : BasicElementBase* pParent, BasicImport* pImport,
107 : : const ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer2 >& rxLibContainer );
108 : :
109 : : // XElement
110 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XElement > SAL_CALL startChildElement(
111 : : sal_Int32 nUid, const ::rtl::OUString& rLocalName,
112 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes >& xAttributes )
113 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
114 : : virtual void SAL_CALL endElement()
115 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
116 : : };
117 : :
118 : :
119 : : // =============================================================================
120 : : // class BasicEmbeddedLibraryElement
121 : : // =============================================================================
122 : :
123 [ # # ]: 0 : class BasicEmbeddedLibraryElement : public BasicElementBase
124 : : {
125 : : private:
126 : : ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer2 > m_xLibContainer;
127 : : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xLib;
128 : : ::rtl::OUString m_aLibName;
129 : : bool m_bReadOnly;
130 : :
131 : : public:
132 : : BasicEmbeddedLibraryElement( const ::rtl::OUString& rLocalName,
133 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes >& xAttributes,
134 : : BasicElementBase* pParent, BasicImport* pImport,
135 : : const ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer2 >& rxLibContainer,
136 : : const ::rtl::OUString& rLibName, bool bReadOnly );
137 : :
138 : : // XElement
139 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XElement > SAL_CALL startChildElement(
140 : : sal_Int32 nUid, const ::rtl::OUString& rLocalName,
141 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes >& xAttributes )
142 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
143 : : virtual void SAL_CALL endElement()
144 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
145 : : };
146 : :
147 : :
148 : : // =============================================================================
149 : : // class BasicModuleElement
150 : : // =============================================================================
151 : :
152 [ # # ]: 0 : class BasicModuleElement : public BasicElementBase
153 : : {
154 : : private:
155 : : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xLib;
156 : : ::rtl::OUString m_aName;
157 : :
158 : : public:
159 : : BasicModuleElement( const ::rtl::OUString& rLocalName,
160 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes >& xAttributes,
161 : : BasicElementBase* pParent, BasicImport* pImport,
162 : : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxLib,
163 : : const ::rtl::OUString& rName );
164 : :
165 : : // XElement
166 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XElement > SAL_CALL startChildElement(
167 : : sal_Int32 nUid, const ::rtl::OUString& rLocalName,
168 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes >& xAttributes )
169 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
170 : : virtual void SAL_CALL endElement()
171 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
172 : : };
173 : :
174 : :
175 : : // =============================================================================
176 : : // class BasicSourceCodeElement
177 : : // =============================================================================
178 : :
179 [ # # ]: 0 : class BasicSourceCodeElement : public BasicElementBase
180 : : {
181 : : private:
182 : : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xLib;
183 : : ::rtl::OUString m_aName;
184 : : ::rtl::OUStringBuffer m_aBuffer;
185 : :
186 : : public:
187 : : BasicSourceCodeElement( const ::rtl::OUString& rLocalName,
188 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes >& xAttributes,
189 : : BasicElementBase* pParent, BasicImport* pImport,
190 : : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxLib,
191 : : const ::rtl::OUString& rName );
192 : :
193 : : // XElement
194 : : virtual void SAL_CALL characters( const ::rtl::OUString& rChars )
195 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
196 : : virtual void SAL_CALL endElement()
197 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
198 : : };
199 : :
200 : :
201 : : // =============================================================================
202 : : // class BasicImport
203 : : // =============================================================================
204 : :
205 : : typedef ::cppu::WeakImplHelper1<
206 : : ::com::sun::star::xml::input::XRoot > BasicImport_BASE;
207 : :
208 : : class BasicImport : public BasicImport_BASE
209 : : {
210 : : friend class BasicElementBase;
211 : : friend class BasicLibrariesElement;
212 : : friend class BasicEmbeddedLibraryElement;
213 : : friend class BasicModuleElement;
214 : :
215 : : private:
216 : : sal_Int32 XMLNS_UID;
217 : : sal_Int32 XMLNS_XLINK_UID;
218 : : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel;
219 : : sal_Bool m_bOasis;
220 : :
221 : : public:
222 : : BasicImport( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel, sal_Bool bOasis );
223 : : virtual ~BasicImport();
224 : :
225 : : // XRoot
226 : : virtual void SAL_CALL startDocument(
227 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XNamespaceMapping >& xNamespaceMapping )
228 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
229 : : virtual void SAL_CALL endDocument()
230 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
231 : : virtual void SAL_CALL processingInstruction(
232 : : const ::rtl::OUString& rTarget, const ::rtl::OUString& rData )
233 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
234 : : virtual void SAL_CALL setDocumentLocator(
235 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >& xLocator )
236 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
237 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XElement > SAL_CALL startRootElement(
238 : : sal_Int32 nUid, const ::rtl::OUString& rLocalName,
239 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::input::XAttributes >& xAttributes )
240 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
241 : : };
242 : :
243 : :
244 : : // =============================================================================
245 : : // class XMLBasicImporterBase
246 : : // =============================================================================
247 : :
248 : : typedef ::cppu::WeakImplHelper3<
249 : : ::com::sun::star::lang::XServiceInfo,
250 : : ::com::sun::star::document::XImporter,
251 : : ::com::sun::star::xml::sax::XDocumentHandler > XMLBasicImporterBase_BASE;
252 : :
253 : : class XMLBasicImporterBase : public XMLBasicImporterBase_BASE
254 : : {
255 : : private:
256 : : ::osl::Mutex m_aMutex;
257 : : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
258 : : ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xHandler;
259 : : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel;
260 : : sal_Bool m_bOasis;
261 : :
262 : : public:
263 : : XMLBasicImporterBase(
264 : : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, sal_Bool bOasis );
265 : : virtual ~XMLBasicImporterBase();
266 : :
267 : : // XServiceInfo
268 : : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
269 : : throw (::com::sun::star::uno::RuntimeException);
270 : :
271 : : // XImporter
272 : : virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& rxDoc )
273 : : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
274 : :
275 : : // XDocumentHandler
276 : : virtual void SAL_CALL startDocument()
277 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
278 : : virtual void SAL_CALL endDocument()
279 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
280 : : virtual void SAL_CALL startElement( const ::rtl::OUString& aName,
281 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttribs )
282 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
283 : : virtual void SAL_CALL endElement( const ::rtl::OUString& aName )
284 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
285 : : virtual void SAL_CALL characters( const ::rtl::OUString& aChars )
286 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
287 : : virtual void SAL_CALL ignorableWhitespace( const ::rtl::OUString& aWhitespaces )
288 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
289 : : virtual void SAL_CALL processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData )
290 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
291 : : virtual void SAL_CALL setDocumentLocator( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >& xLocator )
292 : : throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
293 : : };
294 : :
295 : :
296 : : // =============================================================================
297 : : // class XMLBasicImporter
298 : : // =============================================================================
299 : :
300 : : class XMLBasicImporter : public XMLBasicImporterBase
301 : : {
302 : : public:
303 : : XMLBasicImporter(
304 : : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
305 : : virtual ~XMLBasicImporter();
306 : :
307 : : // XServiceInfo
308 : : virtual ::rtl::OUString SAL_CALL getImplementationName( )
309 : : throw (::com::sun::star::uno::RuntimeException);
310 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
311 : : throw (::com::sun::star::uno::RuntimeException);
312 : : };
313 : :
314 : :
315 : : // =============================================================================
316 : : // class XMLOasisBasicImporter
317 : : // =============================================================================
318 : :
319 : : class XMLOasisBasicImporter : public XMLBasicImporterBase
320 : : {
321 : : public:
322 : : XMLOasisBasicImporter(
323 : : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
324 : : virtual ~XMLOasisBasicImporter();
325 : :
326 : : // XServiceInfo
327 : : virtual ::rtl::OUString SAL_CALL getImplementationName( )
328 : : throw (::com::sun::star::uno::RuntimeException);
329 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
330 : : throw (::com::sun::star::uno::RuntimeException);
331 : : };
332 : :
333 : : //.........................................................................
334 : : } // namespace xmlscript
335 : : //.........................................................................
336 : :
337 : : #endif // XMLSCRIPT_XMLBAS_IMPORT_HXX
338 : :
339 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|