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

Generated by: LCOV version 1.11