LCOV - code coverage report
Current view: top level - xmloff/source/transform - NotesTContext.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 80 0.0 %
Date: 2014-04-14 Functions: 0 12 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 <com/sun/star/xml/sax/SAXParseException.hpp>
      21             : #include <com/sun/star/xml/sax/SAXException.hpp>
      22             : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
      23             : #include <com/sun/star/xml/sax/XAttributeList.hpp>
      24             : #include <xmloff/nmspmap.hxx>
      25             : #include <xmloff/xmltoken.hxx>
      26             : #include <xmloff/xmlnmspe.hxx>
      27             : 
      28             : #include "TransformerBase.hxx"
      29             : #include "TransformerActions.hxx"
      30             : #include "AttrTransformerAction.hxx"
      31             : #include "ActionMapTypesOASIS.hxx"
      32             : #include "MutableAttrList.hxx"
      33             : #include "RenameElemTContext.hxx"
      34             : #include "FlatTContext.hxx"
      35             : 
      36             : #include "NotesTContext.hxx"
      37             : 
      38             : using namespace ::xmloff::token;
      39             : using namespace ::com::sun::star::uno;
      40             : using namespace ::com::sun::star::xml::sax;
      41             : 
      42           0 : TYPEINIT1( XMLNotesTransformerContext, XMLPersElemContentTContext );
      43             : 
      44           0 : XMLNotesTransformerContext::XMLNotesTransformerContext(
      45             :         XMLTransformerBase& rImp,
      46             :         const OUString& rQName,
      47             :         XMLTokenEnum eToken, sal_Bool bPersistent ) :
      48             :     XMLPersElemContentTContext( rImp, rQName ),
      49             :     m_bEndNote( sal_False ),
      50             :     m_bPersistent( bPersistent ),
      51           0 :     m_eTypeToken( eToken )
      52             : {
      53           0 : }
      54             : 
      55           0 : XMLNotesTransformerContext::~XMLNotesTransformerContext()
      56             : {
      57           0 : }
      58             : 
      59           0 : void XMLNotesTransformerContext::StartElement(
      60             :         const Reference< XAttributeList >& rAttrList )
      61             : {
      62             :     XMLTransformerActions *pActions =
      63           0 :         GetTransformer().GetUserDefinedActions( OASIS_NOTES_ACTIONS );
      64             :     OSL_ENSURE( pActions, "go no actions" );
      65             : 
      66           0 :     Reference< XAttributeList > xAttrList( rAttrList );
      67           0 :     XMLMutableAttributeList *pMutableAttrList = 0;
      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 :             const OUString& rAttrValue = xAttrList->getValueByIndex( i );
      82             : 
      83           0 :             if( !pMutableAttrList )
      84             :             {
      85             :                 pMutableAttrList =
      86           0 :                     new XMLMutableAttributeList( xAttrList );
      87           0 :                 xAttrList = pMutableAttrList;
      88             :             }
      89           0 :             switch( (*aIter).second.m_nActionType )
      90             :             {
      91             :             case XML_ATACTION_STYLE_FAMILY:
      92             :                 {
      93           0 :                     if( IsXMLToken( rAttrValue, XML_FOOTNOTE ) )
      94             :                     {
      95             :                     }
      96           0 :                     else if( IsXMLToken( rAttrValue, XML_ENDNOTE ) )
      97             :                     {
      98           0 :                         m_bEndNote = sal_True;
      99             :                     }
     100           0 :                     pMutableAttrList->RemoveAttributeByIndex( i );
     101           0 :                     --i;
     102           0 :                     --nAttrCount;
     103             :                 }
     104           0 :                 break;
     105             :             case XML_ATACTION_DECODE_STYLE_NAME:
     106             :             case XML_ATACTION_DECODE_STYLE_NAME_REF:
     107             :                 {
     108           0 :                     OUString aAttrValue( rAttrValue );
     109           0 :                     if( GetTransformer().DecodeStyleName(aAttrValue) )
     110           0 :                         pMutableAttrList->SetValueByIndex( i, aAttrValue );
     111             :                 }
     112           0 :                 break;
     113           0 :             }
     114             :         }
     115           0 :     }
     116             : 
     117           0 :     XMLTokenEnum eToken = XML_FOOTNOTE;
     118           0 :     switch( m_eTypeToken )
     119             :     {
     120             :     case XML_NOTE:
     121           0 :         eToken = (m_bEndNote ? XML_ENDNOTE : XML_FOOTNOTE);
     122           0 :         break;
     123             :     case XML_NOTES_CONFIGURATION:
     124             :         eToken = (m_bEndNote ? XML_ENDNOTES_CONFIGURATION
     125           0 :                              : XML_FOOTNOTES_CONFIGURATION);
     126           0 :         break;
     127             :     case XML_NOTE_REF:
     128           0 :         eToken = (m_bEndNote ? XML_ENDNOTE_REF : XML_FOOTNOTE_REF);
     129           0 :         break;
     130             :     default:
     131             :         OSL_ENSURE( XML_NOTE==m_eTypeToken, "invalid note type" );
     132           0 :         break;
     133             :     }
     134             : 
     135           0 :     SetExportQName( GetTransformer().GetNamespaceMap().GetQNameByKey(
     136             :                             XML_NAMESPACE_TEXT,
     137           0 :                             ::xmloff::token::GetXMLToken( eToken ) ) );
     138           0 :     if( m_bPersistent )
     139           0 :         XMLPersElemContentTContext::StartElement( xAttrList );
     140             :     else
     141           0 :         GetTransformer().GetDocHandler()->startElement( GetExportQName(),
     142           0 :                                                         xAttrList );
     143           0 : }
     144             : 
     145           0 : void XMLNotesTransformerContext::EndElement()
     146             : {
     147           0 :     if( m_bPersistent )
     148             :     {
     149           0 :         XMLPersElemContentTContext::EndElement();
     150             :     }
     151             :     else
     152             :     {
     153           0 :         GetTransformer().GetDocHandler()->endElement( GetExportQName() );
     154             :     }
     155           0 : }
     156             : 
     157           0 : XMLTransformerContext *XMLNotesTransformerContext::CreateChildContext(
     158             :         sal_uInt16 nPrefix,
     159             :         const OUString& rLocalName,
     160             :         const OUString& rQName,
     161             :         const Reference< XAttributeList >& rAttrList )
     162             : {
     163           0 :     XMLTransformerContext *pContext = 0;
     164           0 :     if( XML_NOTE == m_eTypeToken )
     165             :     {
     166           0 :         if( XML_NAMESPACE_TEXT == nPrefix )
     167             :         {
     168           0 :             XMLTokenEnum eToken ( XML_TOKEN_INVALID );
     169           0 :             if( IsXMLToken( rLocalName, XML_NOTE_CITATION ) )
     170             :             {
     171             :                 eToken = m_bEndNote ? XML_ENDNOTE_CITATION
     172           0 :                                   : XML_FOOTNOTE_CITATION;
     173             :             }
     174           0 :             else if( IsXMLToken( rLocalName, XML_NOTE_BODY ) )
     175             :             {
     176             :                 eToken = m_bEndNote ? XML_ENDNOTE_BODY
     177           0 :                                   : XML_FOOTNOTE_BODY;
     178             :             }
     179             : 
     180           0 :             if( XML_TOKEN_INVALID != eToken )
     181             :             {
     182           0 :                 if( m_bPersistent  )
     183             :                 {
     184             :                     pContext = new XMLPersTextContentTContext(
     185           0 :                                     GetTransformer(), rQName,
     186             :                                     XML_NAMESPACE_TEXT,
     187           0 :                                     eToken );
     188           0 :                     AddContent( pContext );
     189             : 
     190             :                 }
     191             :                 else
     192             :                 {
     193             :                     pContext = new XMLRenameElemTransformerContext(
     194           0 :                                     GetTransformer(), rQName,
     195             :                                     XML_NAMESPACE_TEXT,
     196           0 :                                     eToken );
     197             :                 }
     198             :             }
     199             :         }
     200             :     }
     201             : 
     202           0 :     if( !pContext )
     203             :     {
     204             :         pContext = m_bPersistent
     205             :                         ? XMLPersElemContentTContext::CreateChildContext(
     206           0 :                                 nPrefix, rLocalName, rQName, rAttrList )
     207             :                         : XMLTransformerContext::CreateChildContext(
     208           0 :                                 nPrefix, rLocalName, rQName, rAttrList );
     209             :     }
     210             : 
     211           0 :     return pContext;
     212             : }
     213             : 
     214           0 : sal_Bool XMLNotesTransformerContext::IsPersistent() const
     215             : {
     216           0 :     return m_bPersistent;
     217             : }
     218             : 
     219             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10