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