LCOV - code coverage report
Current view: top level - xmloff/source/script - xmlscripti.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 48 0.0 %
Date: 2014-04-14 Functions: 0 10 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             : #include <xmloff/xmlscripti.hxx>
      21             : #include <xmloff/xmlnmspe.hxx>
      22             : #include <xmloff/xmltoken.hxx>
      23             : #include <xmloff/xmlimp.hxx>
      24             : #include <xmloff/nmspmap.hxx>
      25             : #include <xmloff/XMLEventsImportContext.hxx>
      26             : #include "xmlbasici.hxx"
      27             : 
      28             : #include <com/sun/star/document/XEventsSupplier.hpp>
      29             : #include <com/sun/star/document/XEmbeddedScripts.hpp>
      30             : 
      31             : using namespace com::sun::star;
      32             : using namespace com::sun::star::uno;
      33             : using namespace com::sun::star::lang;
      34             : using namespace com::sun::star::frame;
      35             : using namespace com::sun::star::document;
      36             : using namespace com::sun::star::xml::sax;
      37             : using namespace ::xmloff::token;
      38             : 
      39             : // XMLScriptChildContext: context for <office:script> element
      40             : 
      41             : class XMLScriptChildContext : public SvXMLImportContext
      42             : {
      43             : private:
      44             :     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >                 m_xModel;
      45             :     ::com::sun::star::uno::Reference< ::com::sun::star::document::XEmbeddedScripts >    m_xDocumentScripts;
      46             :     OUString m_aLanguage;
      47             : 
      48             : public:
      49             :     XMLScriptChildContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
      50             :         const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>& rxModel,
      51             :         const OUString& rLanguage );
      52             :     virtual ~XMLScriptChildContext();
      53             : 
      54             :     virtual SvXMLImportContext* CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName,
      55             :         const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ) SAL_OVERRIDE;
      56             : 
      57             :     virtual void EndElement() SAL_OVERRIDE;
      58             : };
      59             : 
      60           0 : XMLScriptChildContext::XMLScriptChildContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
      61             :         const Reference< frame::XModel >& rxModel, const OUString& rLanguage )
      62             :     :SvXMLImportContext( rImport, nPrfx, rLName )
      63             :     ,m_xModel( rxModel )
      64             :     ,m_xDocumentScripts( rxModel, UNO_QUERY )
      65           0 :     ,m_aLanguage( rLanguage )
      66             : {
      67           0 : }
      68             : 
      69           0 : XMLScriptChildContext::~XMLScriptChildContext()
      70             : {
      71           0 : }
      72             : 
      73           0 : SvXMLImportContext* XMLScriptChildContext::CreateChildContext(
      74             :     sal_uInt16 nPrefix, const OUString& rLocalName,
      75             :     const Reference< xml::sax::XAttributeList >& xAttrList )
      76             : {
      77           0 :     SvXMLImportContext* pContext = NULL;
      78             : 
      79           0 :     if ( m_xDocumentScripts.is() )
      80             :     {   // document supports embedding scripts/macros
      81           0 :         OUString aBasic( GetImport().GetNamespaceMap().GetPrefixByKey( XML_NAMESPACE_OOO ) );
      82           0 :         aBasic += ":Basic";
      83             : 
      84           0 :         if ( m_aLanguage == aBasic && nPrefix == XML_NAMESPACE_OOO && IsXMLToken( rLocalName, XML_LIBRARIES ) )
      85           0 :             pContext = new XMLBasicImportContext( GetImport(), nPrefix, rLocalName, m_xModel );
      86             :     }
      87             : 
      88           0 :     if ( !pContext )
      89           0 :         pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
      90             : 
      91           0 :     return pContext;
      92             : }
      93             : 
      94           0 : void XMLScriptChildContext::EndElement()
      95             : {
      96           0 : }
      97             : 
      98             : // XMLScriptContext: context for <office:scripts> element
      99             : 
     100           0 : XMLScriptContext::XMLScriptContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
     101             :         const Reference<XModel>& rDocModel )
     102             :     :SvXMLImportContext( rImport, nPrfx, rLName )
     103           0 :     ,m_xModel( rDocModel )
     104             : {
     105           0 : }
     106             : 
     107           0 : XMLScriptContext::~XMLScriptContext()
     108             : {
     109           0 : }
     110             : 
     111           0 : SvXMLImportContext* XMLScriptContext::CreateChildContext(
     112             :     sal_uInt16 nPrefix, const OUString& rLName,
     113             :     const Reference<XAttributeList>& xAttrList )
     114             : {
     115           0 :     SvXMLImportContext* pContext = NULL;
     116             : 
     117           0 :     if ( nPrefix == XML_NAMESPACE_OFFICE )
     118             :     {
     119           0 :         if ( IsXMLToken( rLName, XML_EVENT_LISTENERS ) )
     120             :         {
     121           0 :             Reference< XEventsSupplier> xSupplier( GetImport().GetModel(), UNO_QUERY );
     122           0 :             pContext = new XMLEventsImportContext( GetImport(), nPrefix, rLName, xSupplier );
     123             :         }
     124           0 :         else if ( IsXMLToken( rLName, XML_SCRIPT ) )
     125             :         {
     126           0 :             OUString aAttrName( GetImport().GetNamespaceMap().GetPrefixByKey( XML_NAMESPACE_SCRIPT ) );
     127           0 :             aAttrName += ":language";
     128           0 :             if ( xAttrList.is() )
     129             :             {
     130           0 :                 OUString aLanguage = xAttrList->getValueByName( aAttrName );
     131             : 
     132           0 :                 if ( m_xModel.is() )
     133             :                 {
     134           0 :                     uno::Sequence< beans::PropertyValue > aMedDescr = m_xModel->getArgs();
     135           0 :                     sal_Int32 nNewLen = aMedDescr.getLength() + 1;
     136           0 :                     aMedDescr.realloc( nNewLen );
     137           0 :                     aMedDescr[nNewLen-1].Name = "BreakMacroSignature";
     138           0 :                     aMedDescr[nNewLen-1].Value <<= (sal_Bool)sal_True;
     139           0 :                     m_xModel->attachResource( m_xModel->getURL(), aMedDescr );
     140             : 
     141           0 :                     pContext = new XMLScriptChildContext( GetImport(), nPrefix, rLName, m_xModel, aLanguage );
     142           0 :                 }
     143           0 :             }
     144             :         }
     145             :     }
     146             : 
     147           0 :     if ( !pContext )
     148           0 :         pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLName, xAttrList);
     149             : 
     150           0 :     return pContext;
     151             : }
     152             : 
     153           0 : void XMLScriptContext::EndElement()
     154             : {
     155           0 : }
     156             : 
     157             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10