LCOV - code coverage report
Current view: top level - libreoffice/xmloff/source/script - xmlbasici.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 73 0.0 %
Date: 2012-12-27 Functions: 0 14 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 "xmlbasici.hxx"
      21             : #include <xmloff/attrlist.hxx>
      22             : #include <xmloff/nmspmap.hxx>
      23             : #include <xmloff/xmlimp.hxx>
      24             : 
      25             : using namespace ::com::sun::star;
      26             : using namespace ::com::sun::star::uno;
      27             : 
      28             : 
      29             : // =============================================================================
      30             : // XMLBasicImportContext
      31             : // =============================================================================
      32             : 
      33           0 : XMLBasicImportContext::XMLBasicImportContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
      34             :         const Reference< frame::XModel >& rxModel )
      35             :     :SvXMLImportContext( rImport, nPrfx, rLName )
      36           0 :     ,m_xModel( rxModel )
      37             : {
      38           0 :     Reference< lang::XMultiServiceFactory > xMSF = GetImport().getServiceFactory();
      39           0 :     if ( xMSF.is() )
      40             :     {
      41           0 :         m_xHandler.set( xMSF->createInstance(
      42           0 :             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.XMLOasisBasicImporter" ) ) ),
      43           0 :             UNO_QUERY );
      44             :     }
      45             : 
      46           0 :     if ( m_xHandler.is() )
      47             :     {
      48           0 :         Reference< document::XImporter > xImporter( m_xHandler, UNO_QUERY );
      49           0 :         if ( xImporter.is() )
      50             :         {
      51           0 :             Reference< lang::XComponent > xComp( m_xModel, UNO_QUERY );
      52           0 :             xImporter->setTargetDocument( xComp );
      53           0 :         }
      54           0 :     }
      55           0 : }
      56             : 
      57             : // -----------------------------------------------------------------------------
      58             : 
      59           0 : XMLBasicImportContext::~XMLBasicImportContext()
      60             : {
      61           0 : }
      62             : 
      63             : // -----------------------------------------------------------------------------
      64             : 
      65           0 : SvXMLImportContext* XMLBasicImportContext::CreateChildContext(
      66             :     sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName,
      67             :     const Reference< xml::sax::XAttributeList >& )
      68             : {
      69           0 :     SvXMLImportContext* pContext = 0;
      70             : 
      71           0 :     if ( m_xHandler.is() )
      72           0 :         pContext = new XMLBasicImportChildContext( GetImport(), nPrefix, rLocalName, m_xHandler );
      73             : 
      74           0 :     if ( !pContext )
      75           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
      76             : 
      77           0 :     return pContext;
      78             : }
      79             : 
      80             : // -----------------------------------------------------------------------------
      81             : 
      82           0 : void XMLBasicImportContext::StartElement(
      83             :     const Reference< xml::sax::XAttributeList >& rxAttrList )
      84             : {
      85           0 :     if ( m_xHandler.is() )
      86             :     {
      87           0 :         m_xHandler->startDocument();
      88             : 
      89             :         // copy namespace declarations
      90           0 :         SvXMLAttributeList* pAttrList = new SvXMLAttributeList( rxAttrList );
      91           0 :         Reference< xml::sax::XAttributeList > xAttrList( pAttrList );
      92           0 :         const SvXMLNamespaceMap& rNamespaceMap = GetImport().GetNamespaceMap();
      93           0 :         sal_uInt16 nPos = rNamespaceMap.GetFirstKey();
      94           0 :         while ( nPos != USHRT_MAX )
      95             :         {
      96           0 :             ::rtl::OUString aAttrName( rNamespaceMap.GetAttrNameByKey( nPos ) );
      97           0 :             if ( xAttrList->getValueByName( aAttrName ).isEmpty() )
      98           0 :                 pAttrList->AddAttribute( aAttrName, rNamespaceMap.GetNameByKey( nPos ) );
      99           0 :             nPos = rNamespaceMap.GetNextKey( nPos );
     100           0 :         }
     101             : 
     102           0 :         m_xHandler->startElement(
     103           0 :             GetImport().GetNamespaceMap().GetQNameByKey( GetPrefix(), GetLocalName() ),
     104           0 :             xAttrList );
     105             :     }
     106           0 : }
     107             : 
     108             : // -----------------------------------------------------------------------------
     109             : 
     110           0 : void XMLBasicImportContext::EndElement()
     111             : {
     112           0 :     if ( m_xHandler.is() )
     113             :     {
     114           0 :         m_xHandler->endElement(
     115           0 :             GetImport().GetNamespaceMap().GetQNameByKey( GetPrefix(), GetLocalName() ) );
     116           0 :         m_xHandler->endDocument();
     117             :     }
     118           0 : }
     119             : 
     120             : // -----------------------------------------------------------------------------
     121             : 
     122           0 : void XMLBasicImportContext::Characters( const ::rtl::OUString& rChars )
     123             : {
     124           0 :     if ( m_xHandler.is() )
     125           0 :         m_xHandler->characters( rChars );
     126           0 : }
     127             : 
     128             : 
     129             : // =============================================================================
     130             : // XMLBasicImportChildContext
     131             : // =============================================================================
     132             : 
     133           0 : XMLBasicImportChildContext::XMLBasicImportChildContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
     134             :         const Reference< xml::sax::XDocumentHandler >& rxHandler )
     135             :     :SvXMLImportContext( rImport, nPrfx, rLName )
     136           0 :     ,m_xHandler( rxHandler )
     137             : {
     138           0 : }
     139             : 
     140             : // -----------------------------------------------------------------------------
     141             : 
     142           0 : XMLBasicImportChildContext::~XMLBasicImportChildContext()
     143             : {
     144           0 : }
     145             : 
     146             : // -----------------------------------------------------------------------------
     147             : 
     148           0 : SvXMLImportContext* XMLBasicImportChildContext::CreateChildContext(
     149             :     sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName,
     150             :     const Reference< xml::sax::XAttributeList >& )
     151             : {
     152           0 :     return new XMLBasicImportChildContext( GetImport(), nPrefix, rLocalName, m_xHandler );
     153             : }
     154             : 
     155             : // -----------------------------------------------------------------------------
     156             : 
     157           0 : void XMLBasicImportChildContext::StartElement(
     158             :     const Reference< xml::sax::XAttributeList >& xAttrList )
     159             : {
     160           0 :     if ( m_xHandler.is() )
     161             :     {
     162           0 :         m_xHandler->startElement(
     163           0 :             GetImport().GetNamespaceMap().GetQNameByKey( GetPrefix(), GetLocalName() ),
     164           0 :             xAttrList );
     165             :     }
     166           0 : }
     167             : 
     168             : // -----------------------------------------------------------------------------
     169             : 
     170           0 : void XMLBasicImportChildContext::EndElement()
     171             : {
     172           0 :     if ( m_xHandler.is() )
     173             :     {
     174           0 :         m_xHandler->endElement(
     175           0 :             GetImport().GetNamespaceMap().GetQNameByKey( GetPrefix(), GetLocalName() ) );
     176             :     }
     177           0 : }
     178             : 
     179             : // -----------------------------------------------------------------------------
     180             : 
     181           0 : void XMLBasicImportChildContext::Characters( const ::rtl::OUString& rChars )
     182             : {
     183           0 :     if ( m_xHandler.is() )
     184           0 :         m_xHandler->characters( rChars );
     185           0 : }
     186             : 
     187             : // -----------------------------------------------------------------------------
     188             : 
     189             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10