LCOV - code coverage report
Current view: top level - xmloff/source/transform - ControlOASISTContext.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 67 0.0 %
Date: 2014-04-14 Functions: 0 10 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 "MutableAttrList.hxx"
      21             : #include <xmloff/xmlnmspe.hxx>
      22             : #include <xmloff/nmspmap.hxx>
      23             : #include "ActionMapTypesOASIS.hxx"
      24             : #include "AttrTransformerAction.hxx"
      25             : #include "TransformerActions.hxx"
      26             : #include "TransformerBase.hxx"
      27             : #include "ControlOASISTContext.hxx"
      28             : 
      29             : using namespace ::com::sun::star::uno;
      30             : using namespace ::com::sun::star::xml::sax;
      31             : using namespace ::xmloff::token;
      32             : 
      33           0 : TYPEINIT1( XMLControlOASISTransformerContext, XMLTransformerContext );
      34             : 
      35           0 : XMLControlOASISTransformerContext::XMLControlOASISTransformerContext(
      36             :         XMLTransformerBase& rImp,
      37             :         const OUString& rQName,
      38             :         sal_Bool bCreateControl ) :
      39             :     XMLTransformerContext( rImp, rQName ),
      40           0 :     m_aElemQName( rImp.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_FORM,
      41           0 :                             ::xmloff::token::GetXMLToken( XML_CONTROL ) ) ),
      42           0 :     m_bCreateControl( bCreateControl )
      43             : {
      44           0 : }
      45             : 
      46           0 : XMLControlOASISTransformerContext::~XMLControlOASISTransformerContext()
      47             : {
      48           0 : }
      49             : 
      50           0 : void XMLControlOASISTransformerContext::StartElement(
      51             :     const Reference< XAttributeList >& rAttrList )
      52             : {
      53             : 
      54             :     XMLTransformerActions *pActions =
      55           0 :         GetTransformer().GetUserDefinedActions( OASIS_FORM_CONTROL_ACTIONS );
      56             :     OSL_ENSURE( pActions, "go no actions" );
      57             : 
      58           0 :     Reference< XAttributeList > xAttrList( rAttrList );
      59           0 :     XMLMutableAttributeList *pMutableAttrList = 0;
      60             : //      GetTransformer().ProcessAttrList( xAttrList, OOO_SHAPE_ACTIONS,
      61             : //                                        sal_True );
      62             : 
      63             :     XMLMutableAttributeList *pControlMutableAttrList =
      64           0 :         m_bCreateControl ? new XMLMutableAttributeList : 0;
      65           0 :     Reference< XAttributeList > xControlAttrList( pControlMutableAttrList );
      66             : 
      67           0 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
      68           0 :     for( sal_Int16 i=0; i < nAttrCount; i++ )
      69             :     {
      70           0 :         const OUString& rAttrName = xAttrList->getNameByIndex( i );
      71           0 :         OUString aLocalName;
      72             :         sal_uInt16 nPrefix =
      73           0 :             GetTransformer().GetNamespaceMap().GetKeyByAttrName( rAttrName,
      74           0 :                                                                  &aLocalName );
      75           0 :         XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
      76             :         XMLTransformerActions::const_iterator aIter =
      77           0 :             pActions->find( aKey );
      78           0 :         if( !(aIter == pActions->end() ) )
      79             :         {
      80           0 :             if( !pMutableAttrList )
      81             :             {
      82             :                 pMutableAttrList =
      83           0 :                     new XMLMutableAttributeList( rAttrList );
      84           0 :                 xAttrList = pMutableAttrList;
      85             :             }
      86           0 :             const OUString& rAttrValue = xAttrList->getValueByIndex( i );
      87           0 :             switch( (*aIter).second.m_nActionType )
      88             :             {
      89             :             case XML_ATACTION_MOVE_TO_ELEM:
      90           0 :                 if( m_bCreateControl )
      91             :                 {
      92             :                     pControlMutableAttrList->AddAttribute( rAttrName,
      93           0 :                                                            rAttrValue );
      94           0 :                     pMutableAttrList->RemoveAttributeByIndex( i );
      95           0 :                     --i;
      96           0 :                     --nAttrCount;
      97             :                 }
      98           0 :                 break;
      99             :             case XML_ATACTION_RENAME_REMOVE_NAMESPACE_PREFIX:
     100             :                 {
     101           0 :                     OUString aAttrValue( rAttrValue );
     102             :                     sal_uInt16 nValPrefix =
     103           0 :                         static_cast<sal_uInt16>( (*aIter).second.m_nParam2 );
     104           0 :                     GetTransformer().RemoveNamespacePrefix( aAttrValue,
     105           0 :                                                             nValPrefix );
     106             :                     OUString aNewAttrQName(
     107           0 :                         GetTransformer().GetNamespaceMap().GetQNameByKey(
     108           0 :                             (*aIter).second.GetQNamePrefixFromParam1(),
     109             :                             ::xmloff::token::GetXMLToken(
     110           0 :                                 (*aIter).second.GetQNameTokenFromParam1()) ) );
     111           0 :                     if( m_bCreateControl )
     112             :                     {
     113             :                         pControlMutableAttrList->AddAttribute( aNewAttrQName,
     114           0 :                                                                aAttrValue );
     115           0 :                         pMutableAttrList->RemoveAttributeByIndex( i );
     116           0 :                         --i;
     117           0 :                         --nAttrCount;
     118             :                     }
     119             :                     else
     120             :                     {
     121             :                         pMutableAttrList->RenameAttributeByIndex( i,
     122           0 :                                                               aNewAttrQName );
     123           0 :                         pMutableAttrList->SetValueByIndex( i, aAttrValue );
     124           0 :                     }
     125             :                 }
     126             :             case XML_ATACTION_URI_OASIS:
     127             :                 {
     128           0 :                     OUString aAttrValue( rAttrValue );
     129           0 :                     if( GetTransformer().ConvertURIToOOo( aAttrValue,
     130           0 :                            static_cast< sal_Bool >((*aIter).second.m_nParam1)) )
     131           0 :                         pMutableAttrList->SetValueByIndex( i, aAttrValue );
     132             :                 }
     133           0 :                 break;
     134             :             default:
     135             :                 OSL_ENSURE( !this, "unknown action" );
     136           0 :                 break;
     137           0 :             }
     138             :         }
     139           0 :     }
     140             : 
     141           0 :     if( m_bCreateControl )
     142           0 :         GetTransformer().GetDocHandler()->startElement( m_aElemQName,
     143           0 :                                                         xControlAttrList );
     144           0 :     XMLTransformerContext::StartElement( xAttrList );
     145           0 : }
     146             : 
     147           0 : void XMLControlOASISTransformerContext::EndElement()
     148             : {
     149           0 :     XMLTransformerContext::EndElement();
     150           0 :     if( m_bCreateControl )
     151           0 :         GetTransformer().GetDocHandler()->endElement( m_aElemQName );
     152           0 : }
     153             : 
     154             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10