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

Generated by: LCOV version 1.10