LCOV - code coverage report
Current view: top level - xmloff/source/script - xmlscripti.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 7 48 14.6 %
Date: 2012-08-25 Functions: 4 10 40.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 82 1.2 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <xmloff/xmlscripti.hxx>
      31                 :            : #include "xmloff/xmlnmspe.hxx"
      32                 :            : #include <xmloff/xmltoken.hxx>
      33                 :            : #include <xmloff/xmlimp.hxx>
      34                 :            : #include <xmloff/nmspmap.hxx>
      35                 :            : #include <xmloff/XMLEventsImportContext.hxx>
      36                 :            : #include "xmlbasici.hxx"
      37                 :            : 
      38                 :            : #include <com/sun/star/document/XEventsSupplier.hpp>
      39                 :            : #include <com/sun/star/document/XEmbeddedScripts.hpp>
      40                 :            : 
      41                 :            : using ::rtl::OUString;
      42                 :            : using namespace com::sun::star;
      43                 :            : using namespace com::sun::star::uno;
      44                 :            : using namespace com::sun::star::lang;
      45                 :            : using namespace com::sun::star::frame;
      46                 :            : using namespace com::sun::star::document;
      47                 :            : using namespace com::sun::star::xml::sax;
      48                 :            : using namespace ::xmloff::token;
      49                 :            : 
      50                 :            : using rtl::OUString;
      51                 :            : 
      52                 :            : // =============================================================================
      53                 :            : // XMLScriptChildContext: context for <office:script> element
      54                 :            : // =============================================================================
      55                 :            : 
      56                 :            : class XMLScriptChildContext : public SvXMLImportContext
      57                 :            : {
      58                 :            : private:
      59                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >                 m_xModel;
      60                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::document::XEmbeddedScripts >    m_xDocumentScripts;
      61                 :            :     ::rtl::OUString m_aLanguage;
      62                 :            : 
      63                 :            : public:
      64                 :            :     XMLScriptChildContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
      65                 :            :         const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>& rxModel,
      66                 :            :         const ::rtl::OUString& rLanguage );
      67                 :            :     virtual ~XMLScriptChildContext();
      68                 :            : 
      69                 :            :     virtual SvXMLImportContext* CreateChildContext( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName,
      70                 :            :         const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
      71                 :            : 
      72                 :            :     virtual void EndElement();
      73                 :            : };
      74                 :            : 
      75                 :            : // -----------------------------------------------------------------------------
      76                 :            : 
      77                 :          0 : XMLScriptChildContext::XMLScriptChildContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
      78                 :            :         const Reference< frame::XModel >& rxModel, const ::rtl::OUString& rLanguage )
      79                 :            :     :SvXMLImportContext( rImport, nPrfx, rLName )
      80                 :            :     ,m_xModel( rxModel )
      81                 :            :     ,m_xDocumentScripts( rxModel, UNO_QUERY )
      82         [ #  # ]:          0 :     ,m_aLanguage( rLanguage )
      83                 :            : {
      84                 :          0 : }
      85                 :            : 
      86                 :            : // -----------------------------------------------------------------------------
      87                 :            : 
      88                 :          0 : XMLScriptChildContext::~XMLScriptChildContext()
      89                 :            : {
      90         [ #  # ]:          0 : }
      91                 :            : 
      92                 :            : // -----------------------------------------------------------------------------
      93                 :            : 
      94                 :          0 : SvXMLImportContext* XMLScriptChildContext::CreateChildContext(
      95                 :            :     sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName,
      96                 :            :     const Reference< xml::sax::XAttributeList >& xAttrList )
      97                 :            : {
      98                 :          0 :     SvXMLImportContext* pContext = NULL;
      99                 :            : 
     100         [ #  # ]:          0 :     if ( m_xDocumentScripts.is() )
     101                 :            :     {   // document supports embedding scripts/macros
     102         [ #  # ]:          0 :         ::rtl::OUString aBasic( GetImport().GetNamespaceMap().GetPrefixByKey( XML_NAMESPACE_OOO ) );
     103         [ #  # ]:          0 :         aBasic += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":Basic" ) );
     104                 :            : 
     105 [ #  # ][ #  # ]:          0 :         if ( m_aLanguage == aBasic && nPrefix == XML_NAMESPACE_OOO && IsXMLToken( rLocalName, XML_LIBRARIES ) )
         [ #  # ][ #  # ]
                 [ #  # ]
     106 [ #  # ][ #  # ]:          0 :             pContext = new XMLBasicImportContext( GetImport(), nPrefix, rLocalName, m_xModel );
     107                 :            :     }
     108                 :            : 
     109         [ #  # ]:          0 :     if ( !pContext )
     110                 :          0 :         pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
     111                 :            : 
     112                 :          0 :     return pContext;
     113                 :            : }
     114                 :            : 
     115                 :            : // -----------------------------------------------------------------------------
     116                 :            : 
     117                 :          0 : void XMLScriptChildContext::EndElement()
     118                 :            : {
     119                 :          0 : }
     120                 :            : 
     121                 :            : // =============================================================================
     122                 :            : // XMLScriptContext: context for <office:scripts> element
     123                 :            : // =============================================================================
     124                 :            : 
     125                 :        181 : XMLScriptContext::XMLScriptContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
     126                 :            :         const Reference<XModel>& rDocModel )
     127                 :            :     :SvXMLImportContext( rImport, nPrfx, rLName )
     128                 :        181 :     ,m_xModel( rDocModel )
     129                 :            : {
     130                 :        181 : }
     131                 :            : 
     132                 :            : // -----------------------------------------------------------------------------
     133                 :            : 
     134                 :        181 : XMLScriptContext::~XMLScriptContext()
     135                 :            : {
     136         [ -  + ]:        362 : }
     137                 :            : 
     138                 :            : // -----------------------------------------------------------------------------
     139                 :            : 
     140                 :          0 : SvXMLImportContext* XMLScriptContext::CreateChildContext(
     141                 :            :     sal_uInt16 nPrefix, const OUString& rLName,
     142                 :            :     const Reference<XAttributeList>& xAttrList )
     143                 :            : {
     144                 :          0 :     SvXMLImportContext* pContext = NULL;
     145                 :            : 
     146         [ #  # ]:          0 :     if ( nPrefix == XML_NAMESPACE_OFFICE )
     147                 :            :     {
     148         [ #  # ]:          0 :         if ( IsXMLToken( rLName, XML_EVENT_LISTENERS ) )
     149                 :            :         {
     150         [ #  # ]:          0 :             Reference< XEventsSupplier> xSupplier( GetImport().GetModel(), UNO_QUERY );
     151 [ #  # ][ #  # ]:          0 :             pContext = new XMLEventsImportContext( GetImport(), nPrefix, rLName, xSupplier );
     152                 :            :         }
     153         [ #  # ]:          0 :         else if ( IsXMLToken( rLName, XML_SCRIPT ) )
     154                 :            :         {
     155         [ #  # ]:          0 :             ::rtl::OUString aAttrName( GetImport().GetNamespaceMap().GetPrefixByKey( XML_NAMESPACE_SCRIPT ) );
     156         [ #  # ]:          0 :             aAttrName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":language" ) );
     157         [ #  # ]:          0 :             if ( xAttrList.is() )
     158                 :            :             {
     159 [ #  # ][ #  # ]:          0 :                 ::rtl::OUString aLanguage = xAttrList->getValueByName( aAttrName );
     160                 :            : 
     161         [ #  # ]:          0 :                 if ( m_xModel.is() )
     162                 :            :                 {
     163 [ #  # ][ #  # ]:          0 :                     uno::Sequence< beans::PropertyValue > aMedDescr = m_xModel->getArgs();
     164                 :          0 :                     sal_Int32 nNewLen = aMedDescr.getLength() + 1;
     165         [ #  # ]:          0 :                     aMedDescr.realloc( nNewLen );
     166 [ #  # ][ #  # ]:          0 :                     aMedDescr[nNewLen-1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BreakMacroSignature" ) );
     167 [ #  # ][ #  # ]:          0 :                     aMedDescr[nNewLen-1].Value <<= (sal_Bool)sal_True;
     168 [ #  # ][ #  # ]:          0 :                     m_xModel->attachResource( m_xModel->getURL(), aMedDescr );
         [ #  # ][ #  # ]
     169                 :            : 
     170 [ #  # ][ #  # ]:          0 :                     pContext = new XMLScriptChildContext( GetImport(), nPrefix, rLName, m_xModel, aLanguage );
                 [ #  # ]
     171                 :          0 :                 }
     172                 :          0 :             }
     173                 :            :         }
     174                 :            :     }
     175                 :            : 
     176         [ #  # ]:          0 :     if ( !pContext )
     177                 :          0 :         pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLName, xAttrList);
     178                 :            : 
     179                 :          0 :     return pContext;
     180                 :            : }
     181                 :            : 
     182                 :            : // -----------------------------------------------------------------------------
     183                 :            : 
     184                 :        181 : void XMLScriptContext::EndElement()
     185                 :            : {
     186                 :        181 : }
     187                 :            : 
     188                 :            : // -----------------------------------------------------------------------------
     189                 :            : 
     190                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10