LCOV - code coverage report
Current view: top level - xmloff/source/transform - FrameOOoTContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 42 63 66.7 %
Date: 2012-08-25 Functions: 5 13 38.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 32 84 38.1 %

           Branch data     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                 :         17 : XMLFrameOOoTransformerContext::XMLFrameOOoTransformerContext(
      39                 :            :         XMLTransformerBase& rImp,
      40                 :            :         const OUString& rQName ) :
      41                 :            :     XMLPersElemContentTContext( rImp, rQName ),
      42                 :         17 :     m_aElemQName( rImp.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW,
      43   [ +  -  +  - ]:         34 :                             ::xmloff::token::GetXMLToken( XML_FRAME ) ) )
      44                 :            : {
      45                 :         17 : }
      46                 :            : 
      47                 :         17 : XMLFrameOOoTransformerContext::~XMLFrameOOoTransformerContext()
      48                 :            : {
      49         [ -  + ]:         34 : }
      50                 :            : 
      51                 :         17 : void XMLFrameOOoTransformerContext::StartElement(
      52                 :            :     const Reference< XAttributeList >& rAttrList )
      53                 :            : {
      54                 :            : 
      55                 :            :     XMLTransformerActions *pActions =
      56         [ +  - ]:         17 :         GetTransformer().GetUserDefinedActions( OOO_FRAME_ATTR_ACTIONS );
      57                 :            :     OSL_ENSURE( pActions, "go no actions" );
      58                 :            : 
      59                 :         17 :     Reference< XAttributeList > xAttrList( rAttrList );
      60                 :            :     XMLMutableAttributeList *pMutableAttrList =
      61                 :         17 :         GetTransformer().ProcessAttrList( xAttrList, OOO_SHAPE_ACTIONS,
      62         [ +  - ]:         17 :                                           sal_True );
      63         [ -  + ]:         17 :     if( !pMutableAttrList )
      64         [ #  # ]:          0 :         pMutableAttrList = new XMLMutableAttributeList( rAttrList );
      65 [ +  - ][ +  - ]:         17 :     xAttrList = pMutableAttrList;
      66                 :            : 
      67                 :            :     XMLMutableAttributeList *pFrameMutableAttrList =
      68         [ +  - ]:         17 :         new XMLMutableAttributeList;
      69 [ +  - ][ +  - ]:         17 :     Reference< XAttributeList > xFrameAttrList( pFrameMutableAttrList );
      70                 :            : 
      71 [ +  - ][ +  - ]:         17 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
                 [ +  - ]
      72         [ +  + ]:        188 :     for( sal_Int16 i=0; i < nAttrCount; i++ )
      73                 :            :     {
      74 [ +  - ][ +  - ]:        171 :         const OUString& rAttrName = xAttrList->getNameByIndex( i );
      75                 :        171 :         OUString aLocalName;
      76                 :            :         sal_uInt16 nPrefix =
      77                 :        171 :             GetTransformer().GetNamespaceMap().GetKeyByAttrName( rAttrName,
      78         [ +  - ]:        171 :                                                                  &aLocalName );
      79                 :        171 :         XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
      80                 :            :         XMLTransformerActions::const_iterator aIter =
      81         [ +  - ]:        171 :             pActions->find( aKey );
      82 [ +  + ][ +  - ]:        171 :         if( !(aIter == pActions->end() ) )
      83                 :            :         {
      84 [ +  - ][ +  - ]:        151 :             const OUString& rAttrValue = xAttrList->getValueByIndex( i );
      85 [ +  - ][ +  - ]:        151 :             switch( (*aIter).second.m_nActionType )
      86                 :            :             {
      87                 :            :             case XML_ATACTION_MOVE_TO_ELEM:
      88         [ +  - ]:        151 :                 pFrameMutableAttrList->AddAttribute( rAttrName, rAttrValue );
      89         [ +  - ]:        151 :                 pMutableAttrList->RemoveAttributeByIndex( i );
      90                 :        151 :                 --i;
      91                 :        151 :                 --nAttrCount;
      92                 :        151 :                 break;
      93                 :            :             default:
      94                 :            :                 OSL_ENSURE( !this, "unknown action" );
      95                 :          0 :                 break;
      96                 :        151 :             }
      97                 :            :         }
      98                 :        171 :     }
      99                 :            : 
     100         [ +  - ]:         17 :     GetTransformer().GetDocHandler()->startElement( m_aElemQName,
     101         [ +  - ]:         17 :                                                     xFrameAttrList );
     102         [ +  - ]:         17 :     XMLTransformerContext::StartElement( xAttrList );
     103                 :         17 : }
     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                 :         17 : void XMLFrameOOoTransformerContext::EndElement()
     146                 :            : {
     147                 :         17 :     XMLTransformerContext::EndElement();
     148                 :         17 :     ExportContent();
     149                 :         17 :     GetTransformer().GetDocHandler()->endElement( m_aElemQName );
     150                 :         17 : }
     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