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

Generated by: LCOV version 1.10