LCOV - code coverage report
Current view: top level - xmlscript/source/xmlflat_imexp - xmlbas_import.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 4 0.0 %
Date: 2014-04-14 Functions: 0 8 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10