LCOV - code coverage report
Current view: top level - xmlscript/source/xmlflat_imexp - xmlbas_export.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 83 202 41.1 %
Date: 2012-08-25 Functions: 12 24 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 81 471 17.2 %

           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                 :            : #include "xmlbas_export.hxx"
      21                 :            : #include "xmlscript/xmlns.h"
      22                 :            : #include "xmlscript/xml_helper.hxx"
      23                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      24                 :            : #include <com/sun/star/lang/XMultiComponentFactory.hpp>
      25                 :            : #include <com/sun/star/script/XLibraryContainer2.hpp>
      26                 :            : #include <com/sun/star/script/XLibraryContainerPassword.hpp>
      27                 :            : #include <com/sun/star/document/XEmbeddedScripts.hpp>
      28                 :            : #include <cppuhelper/implementationentry.hxx>
      29                 :            : 
      30                 :            : using namespace ::com::sun::star;
      31                 :            : using namespace ::com::sun::star::lang;
      32                 :            : using namespace ::com::sun::star::uno;
      33                 :            : 
      34                 :            : 
      35                 :            : //.........................................................................
      36                 :            : namespace xmlscript
      37                 :            : {
      38                 :            : //.........................................................................
      39                 :            : 
      40                 :            :     // =============================================================================
      41                 :            :     // component operations
      42                 :            :     // =============================================================================
      43                 :            : 
      44                 :          2 :     ::rtl::OUString getImplementationName_XMLBasicExporter()
      45                 :            :     {
      46                 :            :         static ::rtl::OUString* pImplName = 0;
      47         [ +  - ]:          2 :         if ( !pImplName )
      48                 :            :         {
      49 [ +  - ][ +  - ]:          2 :             ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
      50         [ +  - ]:          2 :             if ( !pImplName )
      51                 :            :             {
      52 [ +  - ][ +  - ]:          2 :                 static ::rtl::OUString aImplName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.xmlscript.XMLBasicExporter" ) );
         [ +  - ][ #  # ]
      53                 :          2 :                 pImplName = &aImplName;
      54         [ +  - ]:          2 :             }
      55                 :            :         }
      56                 :          2 :         return *pImplName;
      57                 :            :     }
      58                 :            : 
      59                 :            :     // -----------------------------------------------------------------------------
      60                 :            : 
      61                 :          0 :     Sequence< ::rtl::OUString > getSupportedServiceNames_XMLBasicExporter()
      62                 :            :     {
      63                 :            :         static Sequence< ::rtl::OUString >* pNames = 0;
      64         [ #  # ]:          0 :         if ( !pNames )
      65                 :            :         {
      66 [ #  # ][ #  # ]:          0 :             ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
      67         [ #  # ]:          0 :             if ( !pNames )
      68                 :            :             {
      69 [ #  # ][ #  # ]:          0 :                 static Sequence< ::rtl::OUString > aNames(1);
         [ #  # ][ #  # ]
      70 [ #  # ][ #  # ]:          0 :                 aNames.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.XMLBasicExporter" ) );
      71                 :          0 :                 pNames = &aNames;
      72         [ #  # ]:          0 :             }
      73                 :            :         }
      74                 :          0 :         return *pNames;
      75                 :            :     }
      76                 :            : 
      77                 :            :     // -----------------------------------------------------------------------------
      78                 :            : 
      79                 :          2 :     ::rtl::OUString getImplementationName_XMLOasisBasicExporter()
      80                 :            :     {
      81                 :            :         static ::rtl::OUString* pImplName = 0;
      82         [ +  - ]:          2 :         if ( !pImplName )
      83                 :            :         {
      84 [ +  - ][ +  - ]:          2 :             ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
      85         [ +  - ]:          2 :             if ( !pImplName )
      86                 :            :             {
      87 [ +  - ][ +  - ]:          2 :                 static ::rtl::OUString aImplName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.xmlscript.XMLOasisBasicExporter" ) );
         [ +  - ][ #  # ]
      88                 :          2 :                 pImplName = &aImplName;
      89         [ +  - ]:          2 :             }
      90                 :            :         }
      91                 :          2 :         return *pImplName;
      92                 :            :     }
      93                 :            : 
      94                 :            :     // -----------------------------------------------------------------------------
      95                 :            : 
      96                 :          2 :     Sequence< ::rtl::OUString > getSupportedServiceNames_XMLOasisBasicExporter()
      97                 :            :     {
      98                 :            :         static Sequence< ::rtl::OUString >* pNames = 0;
      99         [ +  - ]:          2 :         if ( !pNames )
     100                 :            :         {
     101 [ +  - ][ +  - ]:          2 :             ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
     102         [ +  - ]:          2 :             if ( !pNames )
     103                 :            :             {
     104 [ +  - ][ +  - ]:          2 :                 static Sequence< ::rtl::OUString > aNames(1);
         [ +  - ][ #  # ]
     105 [ +  - ][ +  - ]:          2 :                 aNames.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.XMLOasisBasicExporter" ) );
     106                 :          2 :                 pNames = &aNames;
     107         [ +  - ]:          2 :             }
     108                 :            :         }
     109                 :          2 :         return *pNames;
     110                 :            :     }
     111                 :            : 
     112                 :            : 
     113                 :            :     // =============================================================================
     114                 :            :     // XMLBasicExporterBase
     115                 :            :     // =============================================================================
     116                 :            : 
     117                 :          4 :     XMLBasicExporterBase::XMLBasicExporterBase( const Reference< XComponentContext >& rxContext, sal_Bool bOasis )
     118                 :            :         :m_xContext( rxContext )
     119         [ +  - ]:          4 :         ,m_bOasis( bOasis )
     120                 :            :     {
     121                 :          4 :     }
     122                 :            : 
     123                 :            :     // -----------------------------------------------------------------------------
     124                 :            : 
     125         [ +  - ]:          4 :     XMLBasicExporterBase::~XMLBasicExporterBase()
     126                 :            :     {
     127         [ -  + ]:          4 :     }
     128                 :            : 
     129                 :            :     // -----------------------------------------------------------------------------
     130                 :            :     // XServiceInfo
     131                 :            :     // -----------------------------------------------------------------------------
     132                 :            : 
     133                 :          0 :     sal_Bool XMLBasicExporterBase::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
     134                 :            :     {
     135         [ #  # ]:          0 :         Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() );
     136                 :          0 :         const ::rtl::OUString* pNames = aNames.getConstArray();
     137                 :          0 :         const ::rtl::OUString* pEnd = pNames + aNames.getLength();
     138 [ #  # ][ #  # ]:          0 :         for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
                 [ #  # ]
     139                 :            :             ;
     140                 :            : 
     141         [ #  # ]:          0 :         return pNames != pEnd;
     142                 :            :     }
     143                 :            : 
     144                 :            :     // -----------------------------------------------------------------------------
     145                 :            :     // XInitialization
     146                 :            :     // -----------------------------------------------------------------------------
     147                 :            : 
     148                 :          4 :     void XMLBasicExporterBase::initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException)
     149                 :            :     {
     150         [ +  - ]:          4 :         ::osl::MutexGuard aGuard( m_aMutex );
     151                 :            : 
     152         [ +  - ]:          4 :         if ( aArguments.getLength() == 1 )
     153                 :            :         {
     154         [ +  - ]:          4 :             aArguments[0] >>= m_xHandler;
     155                 :            : 
     156         [ -  + ]:          4 :             if ( !m_xHandler.is() )
     157                 :            :             {
     158                 :            :                 throw RuntimeException(
     159                 :            :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XMLBasicExporterBase::initialize: invalid argument format!" ) ),
     160 [ #  # ][ #  # ]:          0 :                     Reference< XInterface >() );
     161                 :            :             }
     162                 :            :         }
     163                 :            :         else
     164                 :            :         {
     165                 :            :             throw RuntimeException(
     166                 :            :                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XMLBasicExporterBase::initialize: invalid number of arguments!" ) ),
     167 [ #  # ][ #  # ]:          0 :                 Reference< XInterface >() );
     168         [ +  - ]:          4 :         }
     169                 :          4 :     }
     170                 :            : 
     171                 :            :     // -----------------------------------------------------------------------------
     172                 :            :     // XExporter
     173                 :            :     // -----------------------------------------------------------------------------
     174                 :            : 
     175                 :          4 :     void XMLBasicExporterBase::setSourceDocument( const Reference< XComponent >& rxDoc )
     176                 :            :         throw (IllegalArgumentException, RuntimeException)
     177                 :            :     {
     178         [ +  - ]:          4 :         ::osl::MutexGuard aGuard( m_aMutex );
     179                 :            : 
     180         [ +  - ]:          4 :         m_xModel.set( rxDoc, UNO_QUERY );
     181                 :            : 
     182         [ -  + ]:          4 :         if ( !m_xModel.is() )
     183                 :            :         {
     184                 :            :             throw IllegalArgumentException(
     185                 :            :                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XMLBasicExporter::setSourceDocument: no document model!" ) ),
     186 [ #  # ][ #  # ]:          0 :                 Reference< XInterface >(), 1 );
     187         [ +  - ]:          4 :         }
     188                 :          4 :     }
     189                 :            : 
     190                 :            :     // -----------------------------------------------------------------------------
     191                 :            :     // XFilter
     192                 :            :     // -----------------------------------------------------------------------------
     193                 :            : 
     194                 :          4 : sal_Bool XMLBasicExporterBase::filter( const Sequence< beans::PropertyValue >& /*aDescriptor*/ )
     195                 :            :         throw (RuntimeException)
     196                 :            :     {
     197         [ +  - ]:          4 :         ::osl::MutexGuard aGuard( m_aMutex );
     198                 :            : 
     199                 :          4 :         sal_Bool bReturn = sal_True;
     200                 :            : 
     201                 :            :         try
     202                 :            :         {
     203         [ +  - ]:          4 :             if ( m_xHandler.is() )
     204                 :            :             {
     205 [ +  - ][ +  - ]:          4 :                 m_xHandler->startDocument();
     206                 :            : 
     207                 :            :                 // ooo/script prefix and URI
     208                 :          4 :                 ::rtl::OUString aPrefix;
     209                 :          4 :                 ::rtl::OUString aURI;
     210         [ +  - ]:          4 :                 if ( m_bOasis )
     211                 :            :                 {
     212         [ +  - ]:          4 :                     aPrefix = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_OOO_PREFIX ) );
     213         [ +  - ]:          4 :                     aURI = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_OOO_URI ) );
     214                 :            :                 }
     215                 :            :                 else
     216                 :            :                 {
     217         [ #  # ]:          0 :                     aPrefix = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_SCRIPT_PREFIX ) );
     218         [ #  # ]:          0 :                     aURI = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_SCRIPT_URI ) );
     219                 :            :                 }
     220                 :            : 
     221                 :            :                 // ooo/script:libraries element
     222                 :          4 :                 ::rtl::OUString aLibContElementName( aPrefix );
     223         [ +  - ]:          4 :                 aLibContElementName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":libraries" ) );
     224         [ +  - ]:          4 :                 XMLElement* pLibContElement = new XMLElement( aLibContElementName );
     225 [ +  - ][ +  - ]:          4 :                 Reference< xml::sax::XAttributeList > xLibContAttribs( pLibContElement );
     226                 :            : 
     227                 :            :                 // ooo/script namespace attribute
     228                 :            :                 pLibContElement->addAttribute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "xmlns:" ) ) + aPrefix,
     229 [ +  - ][ +  - ]:          4 :                     aURI );
     230                 :            : 
     231                 :            :                 // xlink namespace attribute
     232                 :            :                 pLibContElement->addAttribute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "xmlns:" XMLNS_XLINK_PREFIX ) ),
     233 [ +  - ][ +  - ]:          4 :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_XLINK_URI ) ) );
                 [ +  - ]
     234                 :            : 
     235                 :            :                 // <ooo/script:libraries...
     236 [ +  - ][ +  - ]:          4 :                 m_xHandler->ignorableWhitespace( ::rtl::OUString() );
     237 [ +  - ][ +  - ]:          4 :                 m_xHandler->startElement( aLibContElementName, xLibContAttribs );
     238                 :            : 
     239                 :          4 :                 Reference< script::XLibraryContainer2 > xLibContainer;
     240                 :            : 
     241                 :            :                 // try the XEmbeddedScripts interface
     242         [ +  - ]:          4 :                 Reference< document::XEmbeddedScripts > xDocumentScripts( m_xModel, UNO_QUERY );
     243         [ +  - ]:          4 :                 if ( xDocumentScripts.is() )
     244 [ +  - ][ +  - ]:          4 :                     xLibContainer.set( xDocumentScripts->getBasicLibraries().get() );
         [ +  - ][ +  - ]
                 [ +  - ]
     245                 :            : 
     246         [ -  + ]:          4 :                 if ( !xLibContainer.is() )
     247                 :            :                 {
     248                 :            :                     // try the "BasicLibraries" property (old-style, for compatibility)
     249         [ #  # ]:          0 :                     Reference< beans::XPropertySet > xPSet( m_xModel, UNO_QUERY );
     250         [ #  # ]:          0 :                     if ( xPSet.is() )
     251 [ #  # ][ #  # ]:          0 :                         xPSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicLibraries" ) ) ) >>= xLibContainer;
         [ #  # ][ #  # ]
     252                 :            :                 }
     253                 :            : 
     254                 :            :                 OSL_ENSURE( xLibContainer.is(), "XMLBasicExporterBase::filter: nowhere to export to!" );
     255                 :            : 
     256         [ +  - ]:          4 :                 if ( xLibContainer.is() )
     257                 :            :                 {
     258 [ +  - ][ +  - ]:          4 :                     Sequence< ::rtl::OUString > aLibNames = xLibContainer->getElementNames();
     259                 :          4 :                     sal_Int32 nLibCount = aLibNames.getLength();
     260                 :          4 :                     const ::rtl::OUString* pLibNames = aLibNames.getConstArray();
     261         [ -  + ]:          4 :                     for ( sal_Int32 i = 0 ; i < nLibCount ; ++i )
     262                 :            :                     {
     263                 :          0 :                         ::rtl::OUString aLibName( pLibNames[i] );
     264                 :            : 
     265 [ #  # ][ #  # ]:          0 :                         if ( xLibContainer->hasByName( aLibName ) )
                 [ #  # ]
     266                 :            :                         {
     267         [ #  # ]:          0 :                             ::rtl::OUString aTrueStr( RTL_CONSTASCII_USTRINGPARAM( "true" ) );
     268                 :            : 
     269 [ #  # ][ #  # ]:          0 :                             if ( xLibContainer->isLibraryLink( aLibName ) )
                 [ #  # ]
     270                 :            :                             {
     271                 :            :                                 // ooo/script:library-linked element
     272                 :          0 :                                 ::rtl::OUString aLibElementName( aPrefix );
     273         [ #  # ]:          0 :                                 aLibElementName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":library-linked" ) );
     274         [ #  # ]:          0 :                                 XMLElement* pLibElement = new XMLElement( aLibElementName );
     275                 :          0 :                                 Reference< xml::sax::XAttributeList > xLibAttribs;
     276 [ #  # ][ #  # ]:          0 :                                 xLibAttribs = static_cast< xml::sax::XAttributeList* >( pLibElement );
     277                 :            : 
     278                 :            :                                 // ooo/script:name attribute
     279                 :            :                                 pLibElement->addAttribute( aPrefix + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":name" ) ),
     280 [ #  # ][ #  # ]:          0 :                                     aLibName );
     281                 :            : 
     282 [ #  # ][ #  # ]:          0 :                                 ::rtl::OUString aLinkURL( xLibContainer->getLibraryLinkURL( aLibName ) );
     283         [ #  # ]:          0 :                                 if ( !aLinkURL.isEmpty() )
     284                 :            :                                 {
     285                 :            :                                     // xlink:href attribute
     286                 :            :                                     pLibElement->addAttribute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_XLINK_PREFIX ":href" ) ),
     287 [ #  # ][ #  # ]:          0 :                                         aLinkURL );
     288                 :            : 
     289                 :            :                                     // xlink:type attribute
     290                 :            :                                     pLibElement->addAttribute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_XLINK_PREFIX ":type" ) ),
     291 [ #  # ][ #  # ]:          0 :                                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "simple" ) ) );
                 [ #  # ]
     292                 :            :                                 }
     293                 :            : 
     294 [ #  # ][ #  # ]:          0 :                                 if ( xLibContainer->isLibraryReadOnly( aLibName ) )
                 [ #  # ]
     295                 :            :                                 {
     296                 :            :                                     // ooo/script:readonly attribute
     297                 :            :                                     pLibElement->addAttribute( aPrefix + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":readonly" ) ),
     298 [ #  # ][ #  # ]:          0 :                                         aTrueStr );
     299                 :            :                                 }
     300                 :            : 
     301                 :            :                                 // <ooo/script:library-linked...
     302 [ #  # ][ #  # ]:          0 :                                 m_xHandler->ignorableWhitespace( ::rtl::OUString() );
     303 [ #  # ][ #  # ]:          0 :                                 m_xHandler->startElement( aLibElementName, xLibAttribs );
     304                 :            : 
     305                 :            :                                 // ...ooo/script:library-linked>
     306 [ #  # ][ #  # ]:          0 :                                 m_xHandler->ignorableWhitespace( ::rtl::OUString() );
     307 [ #  # ][ #  # ]:          0 :                                 m_xHandler->endElement( aLibElementName );
     308                 :            :                             }
     309                 :            :                             else
     310                 :            :                             {
     311                 :            :                                 // ooo/script:library-embedded element
     312                 :          0 :                                 ::rtl::OUString aLibElementName( aPrefix );
     313         [ #  # ]:          0 :                                 aLibElementName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":library-embedded" ) );
     314         [ #  # ]:          0 :                                 XMLElement* pLibElement = new XMLElement( aLibElementName );
     315                 :          0 :                                 Reference< xml::sax::XAttributeList > xLibAttribs;
     316 [ #  # ][ #  # ]:          0 :                                 xLibAttribs = static_cast< xml::sax::XAttributeList* >( pLibElement );
     317                 :            : 
     318                 :            :                                 // ooo/script:name attribute
     319                 :            :                                 pLibElement->addAttribute( aPrefix + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":name" ) ),
     320 [ #  # ][ #  # ]:          0 :                                     aLibName );
     321                 :            : 
     322 [ #  # ][ #  # ]:          0 :                                 if ( xLibContainer->isLibraryReadOnly( aLibName ) )
                 [ #  # ]
     323                 :            :                                 {
     324                 :            :                                     // ooo/script:readonly attribute
     325                 :            :                                     pLibElement->addAttribute( aPrefix + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":readonly" ) ),
     326 [ #  # ][ #  # ]:          0 :                                         aTrueStr );
     327                 :            :                                 }
     328                 :            : 
     329                 :            :                                 // TODO: password protected libraries
     330         [ #  # ]:          0 :                                 Reference< script::XLibraryContainerPassword > xPasswd( xLibContainer, UNO_QUERY );
     331 [ #  # ][ #  # ]:          0 :                                 if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) )
         [ #  # ][ #  # ]
                 [ #  # ]
     332                 :          0 :                                     continue;
     333                 :            : 
     334                 :            :                                 // <ooo/script:library-embedded...
     335 [ #  # ][ #  # ]:          0 :                                 m_xHandler->ignorableWhitespace( ::rtl::OUString() );
     336 [ #  # ][ #  # ]:          0 :                                 m_xHandler->startElement( aLibElementName, xLibAttribs );
     337                 :            : 
     338 [ #  # ][ #  # ]:          0 :                                 if ( !xLibContainer->isLibraryLoaded( aLibName ) )
                 [ #  # ]
     339 [ #  # ][ #  # ]:          0 :                                     xLibContainer->loadLibrary( aLibName );
     340                 :            : 
     341                 :          0 :                                 Reference< container::XNameContainer > xLib;
     342 [ #  # ][ #  # ]:          0 :                                 xLibContainer->getByName( aLibName ) >>= xLib;
                 [ #  # ]
     343                 :            : 
     344         [ #  # ]:          0 :                                 if ( xLib.is() )
     345                 :            :                                 {
     346 [ #  # ][ #  # ]:          0 :                                     Sequence< ::rtl::OUString > aModNames = xLib->getElementNames();
     347                 :          0 :                                     sal_Int32 nModCount = aModNames.getLength();
     348                 :          0 :                                     const ::rtl::OUString* pModNames = aModNames.getConstArray();
     349         [ #  # ]:          0 :                                     for ( sal_Int32 j = 0 ; j < nModCount ; ++j )
     350                 :            :                                     {
     351                 :          0 :                                         ::rtl::OUString aModName( pModNames[j] );
     352 [ #  # ][ #  # ]:          0 :                                         if ( xLib->hasByName( aModName ) )
                 [ #  # ]
     353                 :            :                                         {
     354                 :            :                                             // ooo/script:module element
     355                 :          0 :                                             ::rtl::OUString aModElementName( aPrefix );
     356         [ #  # ]:          0 :                                             aModElementName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":module" ) );
     357         [ #  # ]:          0 :                                             XMLElement* pModElement = new XMLElement( aModElementName );
     358                 :          0 :                                             Reference< xml::sax::XAttributeList > xModAttribs;
     359 [ #  # ][ #  # ]:          0 :                                             xModAttribs = static_cast< xml::sax::XAttributeList* >( pModElement );
     360                 :            : 
     361                 :            :                                             // ooo/script:name attribute
     362                 :            :                                             pModElement->addAttribute( aPrefix + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":name" ) ),
     363 [ #  # ][ #  # ]:          0 :                                                 aModName );
     364                 :            : 
     365                 :            :                                             // <ooo/script:module...
     366 [ #  # ][ #  # ]:          0 :                                             m_xHandler->ignorableWhitespace( ::rtl::OUString() );
     367 [ #  # ][ #  # ]:          0 :                                             m_xHandler->startElement( aModElementName, xModAttribs );
     368                 :            : 
     369                 :            :                                             // ooo/script:source-code element
     370                 :          0 :                                             ::rtl::OUString aSourceElementName( aPrefix );
     371         [ #  # ]:          0 :                                             aSourceElementName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":source-code" ) );
     372         [ #  # ]:          0 :                                             XMLElement* pSourceElement = new XMLElement( aSourceElementName );
     373                 :          0 :                                             Reference< xml::sax::XAttributeList > xSourceAttribs;
     374 [ #  # ][ #  # ]:          0 :                                             xSourceAttribs = static_cast< xml::sax::XAttributeList* >( pSourceElement );
     375                 :            : 
     376                 :            :                                             // <ooo/script:source-code...
     377 [ #  # ][ #  # ]:          0 :                                             m_xHandler->ignorableWhitespace( ::rtl::OUString() );
     378 [ #  # ][ #  # ]:          0 :                                             m_xHandler->startElement( aSourceElementName, xSourceAttribs );
     379                 :            : 
     380                 :            :                                             // module data
     381                 :            :                                             // TODO: write encrypted data for password protected libraries
     382                 :          0 :                                             ::rtl::OUString aSource;
     383 [ #  # ][ #  # ]:          0 :                                             xLib->getByName( aModName ) >>= aSource;
     384 [ #  # ][ #  # ]:          0 :                                             m_xHandler->characters( aSource );
     385                 :            : 
     386                 :            :                                             // TODO: <ooo/script:byte-code>
     387                 :            : 
     388                 :            :                                             // ...ooo/script:source-code>
     389 [ #  # ][ #  # ]:          0 :                                             m_xHandler->ignorableWhitespace( ::rtl::OUString() );
     390 [ #  # ][ #  # ]:          0 :                                             m_xHandler->endElement( aSourceElementName );
     391                 :            : 
     392                 :            :                                             // ...ooo/script:module>
     393 [ #  # ][ #  # ]:          0 :                                             m_xHandler->ignorableWhitespace( ::rtl::OUString() );
     394 [ #  # ][ #  # ]:          0 :                                             m_xHandler->endElement( aModElementName );
     395                 :            :                                         }
     396         [ #  # ]:          0 :                                     }
     397                 :            :                                 }
     398                 :            : 
     399                 :            :                                 // ...ooo/script:library-embedded>
     400 [ #  # ][ #  # ]:          0 :                                 m_xHandler->ignorableWhitespace( ::rtl::OUString() );
     401 [ #  # ][ #  # ]:          0 :                                 m_xHandler->endElement( aLibElementName );
         [ #  # ][ #  # ]
                 [ #  # ]
     402         [ #  # ]:          0 :                             }
     403                 :            :                         }
     404 [ #  # ][ +  - ]:          4 :                     }
     405                 :            :                 }
     406                 :            : 
     407                 :            :                 // ...ooo/script:libraries>
     408 [ +  - ][ +  - ]:          4 :                 m_xHandler->ignorableWhitespace( ::rtl::OUString() );
     409 [ +  - ][ +  - ]:          4 :                 m_xHandler->endElement( aLibContElementName );
     410                 :            : 
     411 [ +  - ][ +  - ]:          4 :                 m_xHandler->endDocument();
           [ #  #  #  #  
                      # ]
     412                 :            :             }
     413                 :            :         }
     414         [ #  # ]:          0 :         catch ( const container::NoSuchElementException& e )
     415                 :            :         {
     416                 :            :             OSL_TRACE( "XMLBasicExporterBase::filter: caught NoSuchElementException reason %s",
     417                 :            :                 ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
     418                 :          0 :             bReturn = sal_False;
     419                 :            :         }
     420         [ #  # ]:          0 :         catch ( const lang::IllegalArgumentException& e )
     421                 :            :         {
     422                 :            :             OSL_TRACE( "XMLBasicExporterBase::filter: caught IllegalArgumentException reason %s",
     423                 :            :                 ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
     424                 :          0 :             bReturn = sal_False;
     425                 :            :         }
     426         [ #  # ]:          0 :         catch ( const lang::WrappedTargetException& e )
     427                 :            :         {
     428                 :            :             OSL_TRACE( "XMLBasicExporterBase::filter: caught WrappedTargetException reason %s",
     429                 :            :                 ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
     430                 :          0 :             bReturn = sal_False;
     431                 :            :         }
     432         [ #  # ]:          0 :         catch ( const xml::sax::SAXException& e )
     433                 :            :         {
     434                 :            :             OSL_TRACE( "XMLBasicExporterBase::filter: caught SAXException reason %s",
     435                 :            :                 ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
     436                 :          0 :             bReturn = sal_False;
     437                 :            :         }
     438                 :            : 
     439         [ +  - ]:          4 :         return bReturn;
     440                 :            :     }
     441                 :            : 
     442                 :            :     // -----------------------------------------------------------------------------
     443                 :            : 
     444                 :          0 :     void XMLBasicExporterBase::cancel()
     445                 :            :         throw (RuntimeException)
     446                 :            :     {
     447 [ #  # ][ #  # ]:          0 :         ::osl::MutexGuard aGuard( m_aMutex );
     448                 :            : 
     449                 :            :         // cancel export
     450                 :          0 :     }
     451                 :            : 
     452                 :            : 
     453                 :            :     // =============================================================================
     454                 :            :     // XMLBasicExporter
     455                 :            :     // =============================================================================
     456                 :            : 
     457                 :          0 :     XMLBasicExporter::XMLBasicExporter( const Reference< XComponentContext >& rxContext )
     458                 :          0 :         :XMLBasicExporterBase( rxContext, sal_False )
     459                 :            :     {
     460                 :          0 :     }
     461                 :            : 
     462                 :            :     // -----------------------------------------------------------------------------
     463                 :            : 
     464                 :          0 :     XMLBasicExporter::~XMLBasicExporter()
     465                 :            :     {
     466         [ #  # ]:          0 :     }
     467                 :            : 
     468                 :            :     // -----------------------------------------------------------------------------
     469                 :            :     // XServiceInfo
     470                 :            :     // -----------------------------------------------------------------------------
     471                 :            : 
     472                 :          0 :     ::rtl::OUString XMLBasicExporter::getImplementationName(  ) throw (RuntimeException)
     473                 :            :     {
     474                 :          0 :         return getImplementationName_XMLBasicExporter();
     475                 :            :     }
     476                 :            : 
     477                 :            :     // -----------------------------------------------------------------------------
     478                 :            : 
     479                 :          0 :     Sequence< ::rtl::OUString > XMLBasicExporter::getSupportedServiceNames(  ) throw (RuntimeException)
     480                 :            :     {
     481                 :          0 :         return getSupportedServiceNames_XMLBasicExporter();
     482                 :            :     }
     483                 :            : 
     484                 :            : 
     485                 :            :     // =============================================================================
     486                 :            :     // XMLOasisBasicExporter
     487                 :            :     // =============================================================================
     488                 :            : 
     489                 :          4 :     XMLOasisBasicExporter::XMLOasisBasicExporter( const Reference< XComponentContext >& rxContext )
     490                 :          4 :         :XMLBasicExporterBase( rxContext, sal_True )
     491                 :            :     {
     492                 :          4 :     }
     493                 :            : 
     494                 :            :     // -----------------------------------------------------------------------------
     495                 :            : 
     496                 :          4 :     XMLOasisBasicExporter::~XMLOasisBasicExporter()
     497                 :            :     {
     498         [ -  + ]:          8 :     }
     499                 :            : 
     500                 :            :     // -----------------------------------------------------------------------------
     501                 :            :     // XServiceInfo
     502                 :            :     // -----------------------------------------------------------------------------
     503                 :            : 
     504                 :          0 :     ::rtl::OUString XMLOasisBasicExporter::getImplementationName(  ) throw (RuntimeException)
     505                 :            :     {
     506                 :          0 :         return getImplementationName_XMLOasisBasicExporter();
     507                 :            :     }
     508                 :            : 
     509                 :            :     // -----------------------------------------------------------------------------
     510                 :            : 
     511                 :          0 :     Sequence< ::rtl::OUString > XMLOasisBasicExporter::getSupportedServiceNames(  ) throw (RuntimeException)
     512                 :            :     {
     513                 :          0 :         return getSupportedServiceNames_XMLOasisBasicExporter();
     514                 :            :     }
     515                 :            : 
     516                 :            : 
     517                 :            :     // =============================================================================
     518                 :            :     // component operations
     519                 :            :     // =============================================================================
     520                 :            : 
     521                 :          0 :     Reference< XInterface > SAL_CALL create_XMLBasicExporter(
     522                 :            :         Reference< XComponentContext > const & xContext )
     523                 :            :         SAL_THROW(())
     524                 :            :     {
     525 [ #  # ][ #  # ]:          0 :         return static_cast< lang::XTypeProvider * >( new XMLBasicExporter( xContext ) );
     526                 :            :     }
     527                 :            : 
     528                 :            :     // -----------------------------------------------------------------------------
     529                 :            : 
     530                 :          4 :     Reference< XInterface > SAL_CALL create_XMLOasisBasicExporter(
     531                 :            :         Reference< XComponentContext > const & xContext )
     532                 :            :         SAL_THROW(())
     533                 :            :     {
     534 [ +  - ][ +  - ]:          4 :         return static_cast< lang::XTypeProvider * >( new XMLOasisBasicExporter( xContext ) );
     535                 :            :     }
     536                 :            : 
     537                 :            :     // -----------------------------------------------------------------------------
     538                 :            : 
     539                 :            : //.........................................................................
     540                 :            : }   // namespace xmlscript
     541                 :            : //.........................................................................
     542                 :            : 
     543                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10