LCOV - code coverage report
Current view: top level - libreoffice/xmloff/source/transform - FrameOOoTContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 63 0.0 %
Date: 2012-12-27 Functions: 0 13 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 "FrameOOoTContext.hxx"
      21             : #include "IgnoreTContext.hxx"
      22             : #include "MutableAttrList.hxx"
      23             : #include "xmloff/xmlnmspe.hxx"
      24             : #include <xmloff/nmspmap.hxx>
      25             : #include "ActionMapTypesOOo.hxx"
      26             : #include "AttrTransformerAction.hxx"
      27             : #include "ElemTransformerAction.hxx"
      28             : #include "TransformerActions.hxx"
      29             : #include "TransformerBase.hxx"
      30             : 
      31             : using ::rtl::OUString;
      32             : using namespace ::com::sun::star::uno;
      33             : using namespace ::com::sun::star::xml::sax;
      34             : using namespace ::xmloff::token;
      35             : 
      36           0 : TYPEINIT1( XMLFrameOOoTransformerContext, XMLPersElemContentTContext );
      37             : 
      38           0 : XMLFrameOOoTransformerContext::XMLFrameOOoTransformerContext(
      39             :         XMLTransformerBase& rImp,
      40             :         const OUString& rQName ) :
      41             :     XMLPersElemContentTContext( rImp, rQName ),
      42           0 :     m_aElemQName( rImp.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW,
      43           0 :                             ::xmloff::token::GetXMLToken( XML_FRAME ) ) )
      44             : {
      45           0 : }
      46             : 
      47           0 : XMLFrameOOoTransformerContext::~XMLFrameOOoTransformerContext()
      48             : {
      49           0 : }
      50             : 
      51           0 : void XMLFrameOOoTransformerContext::StartElement(
      52             :     const Reference< XAttributeList >& rAttrList )
      53             : {
      54             : 
      55             :     XMLTransformerActions *pActions =
      56           0 :         GetTransformer().GetUserDefinedActions( OOO_FRAME_ATTR_ACTIONS );
      57             :     OSL_ENSURE( pActions, "go no actions" );
      58             : 
      59           0 :     Reference< XAttributeList > xAttrList( rAttrList );
      60             :     XMLMutableAttributeList *pMutableAttrList =
      61           0 :         GetTransformer().ProcessAttrList( xAttrList, OOO_SHAPE_ACTIONS,
      62           0 :                                           sal_True );
      63           0 :     if( !pMutableAttrList )
      64           0 :         pMutableAttrList = new XMLMutableAttributeList( rAttrList );
      65           0 :     xAttrList = pMutableAttrList;
      66             : 
      67             :     XMLMutableAttributeList *pFrameMutableAttrList =
      68           0 :         new XMLMutableAttributeList;
      69           0 :     Reference< XAttributeList > xFrameAttrList( pFrameMutableAttrList );
      70             : 
      71           0 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
      72           0 :     for( sal_Int16 i=0; i < nAttrCount; i++ )
      73             :     {
      74           0 :         const OUString& rAttrName = xAttrList->getNameByIndex( i );
      75           0 :         OUString aLocalName;
      76             :         sal_uInt16 nPrefix =
      77           0 :             GetTransformer().GetNamespaceMap().GetKeyByAttrName( rAttrName,
      78           0 :                                                                  &aLocalName );
      79           0 :         XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
      80             :         XMLTransformerActions::const_iterator aIter =
      81           0 :             pActions->find( aKey );
      82           0 :         if( !(aIter == pActions->end() ) )
      83             :         {
      84           0 :             const OUString& rAttrValue = xAttrList->getValueByIndex( i );
      85           0 :             switch( (*aIter).second.m_nActionType )
      86             :             {
      87             :             case XML_ATACTION_MOVE_TO_ELEM:
      88           0 :                 pFrameMutableAttrList->AddAttribute( rAttrName, rAttrValue );
      89           0 :                 pMutableAttrList->RemoveAttributeByIndex( i );
      90           0 :                 --i;
      91           0 :                 --nAttrCount;
      92           0 :                 break;
      93             :             default:
      94             :                 OSL_ENSURE( !this, "unknown action" );
      95           0 :                 break;
      96           0 :             }
      97             :         }
      98           0 :     }
      99             : 
     100           0 :     GetTransformer().GetDocHandler()->startElement( m_aElemQName,
     101           0 :                                                     xFrameAttrList );
     102           0 :     XMLTransformerContext::StartElement( xAttrList );
     103           0 : }
     104             : 
     105           0 : XMLTransformerContext *XMLFrameOOoTransformerContext::CreateChildContext(
     106             :         sal_uInt16 nPrefix,
     107             :         const OUString& rLocalName,
     108             :         const OUString& rQName,
     109             :         const Reference< XAttributeList >& rAttrList )
     110             : {
     111           0 :     XMLTransformerContext *pContext = 0;
     112             : 
     113             :     XMLTransformerActions *pActions =
     114           0 :         GetTransformer().GetUserDefinedActions( OOO_FRAME_ELEM_ACTIONS );
     115             :     OSL_ENSURE( pActions, "go no actions" );
     116           0 :     XMLTransformerActions::key_type aKey( nPrefix, rLocalName );
     117           0 :     XMLTransformerActions::const_iterator aIter = pActions->find( aKey );
     118             : 
     119           0 :     if( !(aIter == pActions->end()) )
     120             :     {
     121           0 :         switch( (*aIter).second.m_nActionType )
     122             :         {
     123             :         case XML_ETACTION_COPY:
     124             :         case XML_ETACTION_COPY_TEXT:
     125             :         case XML_ETACTION_RENAME_ELEM:
     126             :             // the ones in the list have to be persistent
     127             : 
     128             :             pContext = XMLPersElemContentTContext::CreateChildContext(
     129           0 :                            nPrefix, rLocalName, rQName, rAttrList );
     130           0 :             break;
     131             :         default:
     132             :             OSL_ENSURE( !this, "unknown action" );
     133           0 :             break;
     134             :         }
     135             :     }
     136             : 
     137             :     // default is copying
     138           0 :     if( !pContext )
     139             :         pContext = XMLTransformerContext::CreateChildContext(
     140           0 :                     nPrefix, rLocalName, rQName, rAttrList );
     141             : 
     142           0 :     return pContext;
     143             : }
     144             : 
     145           0 : void XMLFrameOOoTransformerContext::EndElement()
     146             : {
     147           0 :     XMLTransformerContext::EndElement();
     148           0 :     ExportContent();
     149           0 :     GetTransformer().GetDocHandler()->endElement( m_aElemQName );
     150           0 : }
     151             : 
     152           0 : void XMLFrameOOoTransformerContext::Characters( const OUString& rChars )
     153             : {
     154           0 :     XMLTransformerContext::Characters( rChars );
     155           0 : }
     156             : 
     157           0 : sal_Bool XMLFrameOOoTransformerContext::IsPersistent() const
     158             : {
     159             :     // this context stores some of its child elements, but is not persistent
     160             :     // itself.
     161           0 :     return sal_False;
     162             : }
     163             : 
     164             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10