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

Generated by: LCOV version 1.10