LCOV - code coverage report
Current view: top level - xmlscript/source/xmlmod_imexp - xmlmod_import.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 35 55 63.6 %
Date: 2014-04-11 Functions: 12 20 60.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        4930 : void ModuleElement::characters( OUString const & rChars )
      55             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
      56             : {
      57        4930 :     _StrBuffer.append( rChars );
      58        4930 : }
      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          36 : void ModuleElement::endElement()
      67             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
      68             : {
      69          36 :     _pImport->mrModuleDesc.aCode = _StrBuffer.makeStringAndClear();
      70          36 : }
      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          36 : 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          36 :     , _xAttributes( xAttributes )
      89             : {
      90          36 :     _pImport->acquire();
      91             : 
      92          36 :     if (_pParent)
      93             :     {
      94           0 :         _pParent->acquire();
      95             :     }
      96          36 : }
      97             : 
      98         108 : ModuleElement::~ModuleElement()
      99             :     SAL_THROW(())
     100             : {
     101          36 :     _pImport->release();
     102             : 
     103          36 :     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          72 : }
     113             : 
     114             : // XRoot
     115             : 
     116          36 : void ModuleImport::startDocument(
     117             :     Reference< xml::input::XNamespaceMapping > const & xNamespaceMapping )
     118             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
     119             : {
     120          36 :     XMLNS_SCRIPT_UID = xNamespaceMapping->getUidByUri( XMLNS_SCRIPT_URI );
     121          36 :     XMLNS_LIBRARY_UID = xNamespaceMapping->getUidByUri( XMLNS_LIBRARY_URI );
     122          36 :     XMLNS_XLINK_UID = xNamespaceMapping->getUidByUri( XMLNS_XLINK_URI );
     123          36 : }
     124             : 
     125          36 : void ModuleImport::endDocument()
     126             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
     127             : {
     128             :     // ignored
     129          36 : }
     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          36 : void ModuleImport::setDocumentLocator(
     138             :     Reference< xml::sax::XLocator > const & /*xLocator*/ )
     139             :     throw (xml::sax::SAXException, RuntimeException, std::exception)
     140             : {
     141          36 : }
     142             : 
     143          36 : 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          36 :     if (XMLNS_SCRIPT_UID != nUid)
     149             :     {
     150           0 :         throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() );
     151             :     }
     152             :     // window
     153          36 :     else if ( rLocalName == "module" )
     154             :     {
     155          36 :         mrModuleDesc.aName = xAttributes->getValueByUidName( XMLNS_SCRIPT_UID, "name" );
     156          36 :         mrModuleDesc.aLanguage = xAttributes->getValueByUidName( XMLNS_SCRIPT_UID, "language" );
     157          36 :         mrModuleDesc.aModuleType = xAttributes->getValueByUidName( XMLNS_SCRIPT_UID, "moduleType" );
     158             : 
     159          72 :         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          72 : ModuleImport::~ModuleImport()
     167             :     SAL_THROW(())
     168             : {
     169             : #if OSL_DEBUG_LEVEL > 1
     170             :     SAL_INFO("xmlscript.xmlmod", "ModuleImport::~ModuleImport()." );
     171             : #endif
     172          72 : }
     173             : 
     174             : Reference< xml::sax::XDocumentHandler >
     175          36 : SAL_CALL importScriptModule( ModuleDescriptor& rMod )
     176             :     SAL_THROW( (Exception) )
     177             : {
     178             :     return ::xmlscript::createDocumentHandler(
     179          36 :         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