LCOV - code coverage report
Current view: top level - xmlscript/source/xmlmod_imexp - xmlmod_import.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 55 0.0 %
Date: 2014-04-14 Functions: 0 20 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 "imp_share.hxx"
      21             : #include "xml_import.hxx"
      22             : 
      23             : namespace xmlscript
      24             : {
      25             : 
      26           0 : Reference< xml::input::XElement > ModuleElement::getParent()
      27             :     throw (RuntimeException, std::exception)
      28             : {
      29           0 :     return static_cast< xml::input::XElement * >( _pParent );
      30             : }
      31           0 : OUString ModuleElement::getLocalName()
      32             :     throw (RuntimeException, std::exception)
      33             : {
      34           0 :     return _aLocalName;
      35             : }
      36           0 : sal_Int32 ModuleElement::getUid()
      37             :     throw (RuntimeException, std::exception)
      38             : {
      39           0 :     return _pImport->XMLNS_SCRIPT_UID;
      40             : }
      41           0 : Reference< xml::input::XAttributes > ModuleElement::getAttributes()
      42             :     throw (RuntimeException, std::exception)
      43             : {
      44           0 :     return _xAttributes;
      45             : }
      46             : 
      47           0 : void ModuleElement::ignorableWhitespace(
      48             :     OUString const & /*rWhitespaces*/ )
      49             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
      50             : {
      51             :     // not used
      52           0 : }
      53             : 
      54           0 : void ModuleElement::characters( OUString const & rChars )
      55             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
      56             : {
      57           0 :     _StrBuffer.append( rChars );
      58           0 : }
      59             : 
      60           0 : void ModuleElement::processingInstruction(
      61             :     OUString const & /*rTarget*/, OUString const & /*rData*/ )
      62             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
      63             : {
      64           0 : }
      65             : 
      66           0 : void ModuleElement::endElement()
      67             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
      68             : {
      69           0 :     _pImport->mrModuleDesc.aCode = _StrBuffer.makeStringAndClear();
      70           0 : }
      71             : 
      72           0 : Reference< xml::input::XElement > ModuleElement::startChildElement(
      73             :     sal_Int32 /*nUid*/, OUString const & /*rLocalName*/,
      74             :     Reference< xml::input::XAttributes > const & /*xAttributes*/ )
      75             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
      76             : {
      77           0 :     throw xml::sax::SAXException("unexpected element!", Reference< XInterface >(), Any() );
      78             : }
      79             : 
      80           0 : ModuleElement::ModuleElement(
      81             :     OUString const & rLocalName,
      82             :     Reference< xml::input::XAttributes > const & xAttributes,
      83             :     ModuleElement * pParent, ModuleImport * pImport )
      84             :     SAL_THROW(())
      85             :     : _pImport( pImport )
      86             :     , _pParent( pParent )
      87             :     , _aLocalName( rLocalName )
      88           0 :     , _xAttributes( xAttributes )
      89             : {
      90           0 :     _pImport->acquire();
      91             : 
      92           0 :     if (_pParent)
      93             :     {
      94           0 :         _pParent->acquire();
      95             :     }
      96           0 : }
      97             : 
      98           0 : ModuleElement::~ModuleElement()
      99             :     SAL_THROW(())
     100             : {
     101           0 :     _pImport->release();
     102             : 
     103           0 :     if (_pParent)
     104             :     {
     105           0 :         _pParent->release();
     106             :     }
     107             : 
     108             : #if OSL_DEBUG_LEVEL > 1
     109             :     OString aStr( OUStringToOString( _aLocalName, RTL_TEXTENCODING_ASCII_US ) );
     110             :     SAL_INFO("xmlscript.xmlmod", "ModuleElement::~ModuleElement(): " << aStr.getStr() );
     111             : #endif
     112           0 : }
     113             : 
     114             : // XRoot
     115             : 
     116           0 : void ModuleImport::startDocument(
     117             :     Reference< xml::input::XNamespaceMapping > const & xNamespaceMapping )
     118             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
     119             : {
     120           0 :     XMLNS_SCRIPT_UID = xNamespaceMapping->getUidByUri( XMLNS_SCRIPT_URI );
     121           0 :     XMLNS_LIBRARY_UID = xNamespaceMapping->getUidByUri( XMLNS_LIBRARY_URI );
     122           0 :     XMLNS_XLINK_UID = xNamespaceMapping->getUidByUri( XMLNS_XLINK_URI );
     123           0 : }
     124             : 
     125           0 : void ModuleImport::endDocument()
     126             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
     127             : {
     128             :     // ignored
     129           0 : }
     130             : 
     131           0 : void ModuleImport::processingInstruction(
     132             :     OUString const & /*rTarget*/, OUString const & /*rData*/ )
     133             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
     134             : {
     135           0 : }
     136             : 
     137           0 : void ModuleImport::setDocumentLocator(
     138             :     Reference< xml::sax::XLocator > const & /*xLocator*/ )
     139             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
     140             : {
     141           0 : }
     142             : 
     143           0 : Reference< xml::input::XElement > ModuleImport::startRootElement(
     144             :     sal_Int32 nUid, OUString const & rLocalName,
     145             :     Reference< xml::input::XAttributes > const & xAttributes )
     146             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
     147             : {
     148           0 :     if (XMLNS_SCRIPT_UID != nUid)
     149             :     {
     150           0 :         throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() );
     151             :     }
     152             :     // window
     153           0 :     else if ( rLocalName == "module" )
     154             :     {
     155           0 :         mrModuleDesc.aName = xAttributes->getValueByUidName( XMLNS_SCRIPT_UID, "name" );
     156           0 :         mrModuleDesc.aLanguage = xAttributes->getValueByUidName( XMLNS_SCRIPT_UID, "language" );
     157           0 :         mrModuleDesc.aModuleType = xAttributes->getValueByUidName( XMLNS_SCRIPT_UID, "moduleType" );
     158             : 
     159           0 :         return new ModuleElement( rLocalName, xAttributes, 0, this );
     160             :     }
     161             :     else
     162             :     {
     163           0 :         throw xml::sax::SAXException("illegal root element (expected module) given: " + rLocalName, Reference< XInterface >(), Any() );
     164             :     }
     165             : }
     166           0 : ModuleImport::~ModuleImport()
     167             :     SAL_THROW(())
     168             : {
     169             : #if OSL_DEBUG_LEVEL > 1
     170             :     SAL_INFO("xmlscript.xmlmod", "ModuleImport::~ModuleImport()." );
     171             : #endif
     172           0 : }
     173             : 
     174             : Reference< xml::sax::XDocumentHandler >
     175           0 : SAL_CALL importScriptModule( ModuleDescriptor& rMod )
     176             :     SAL_THROW( (Exception) )
     177             : {
     178             :     return ::xmlscript::createDocumentHandler(
     179           0 :         static_cast< xml::input::XRoot * >( new ModuleImport( rMod ) ) );
     180             : }
     181             : 
     182             : }
     183             : 
     184             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10