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

Generated by: LCOV version 1.10