LCOV - code coverage report
Current view: top level - xmloff/source/transform - MetaTContext.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 26 36 72.2 %
Date: 2015-06-13 12:38:46 Functions: 5 11 45.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 <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 "MutableAttrList.hxx"
      30             : #include "MetaTContext.hxx"
      31             : 
      32             : using namespace ::xmloff::token;
      33             : using namespace ::com::sun::star::uno;
      34             : using namespace ::com::sun::star::xml::sax;
      35             : 
      36             : XMLTokenEnum aMetaTokens[] =
      37             : {
      38             :     XML_GENERATOR,
      39             :     XML_TITLE,
      40             :     XML_DESCRIPTION,
      41             :     XML_SUBJECT,
      42             :     XML_INITIAL_CREATOR,
      43             :     XML_CREATION_DATE,
      44             :     XML_CREATOR,
      45             :     XML_DATE,
      46             :     XML_PRINTED_BY,
      47             :     XML_PRINT_DATE,
      48             :     XML_KEYWORD,
      49             :     XML_LANGUAGE,
      50             :     XML_EDITING_CYCLES,
      51             :     XML_EDITING_DURATION,
      52             :     XML_HYPERLINK_BEHAVIOUR,
      53             :     XML_AUTO_RELOAD,
      54             :     XML_TEMPLATE,
      55             :     XML_USER_DEFINED,
      56             :     XML_DOCUMENT_STATISTIC,
      57             :     XML_TOKEN_END
      58             : };
      59             : 
      60           0 : TYPEINIT1( XMLMetaTransformerContext, XMLTransformerContext );
      61             : 
      62           3 : XMLMetaTransformerContext::XMLMetaTransformerContext( XMLTransformerBase& rImp,
      63             :                                                 const OUString& rQName ) :
      64           3 :     XMLTransformerContext( rImp, rQName )
      65             : {
      66           3 : }
      67             : 
      68           6 : XMLMetaTransformerContext::~XMLMetaTransformerContext()
      69             : {
      70           6 : }
      71             : 
      72          17 : XMLTransformerContext *XMLMetaTransformerContext::CreateChildContext(
      73             :             sal_uInt16 /*nPrefix*/,
      74             :             const OUString& rLocalName,
      75             :             const OUString& rQName,
      76             :             const Reference< XAttributeList >& )
      77             : {
      78             :     XMLPersTextContentTContext *pContext =
      79          17 :         new XMLPersTextContentTContext( GetTransformer(), rQName );
      80          17 :     XMLMetaContexts_Impl::value_type aVal( rLocalName, pContext );
      81          17 :     m_aContexts.insert( aVal );
      82             : 
      83          17 :     return pContext;
      84             : }
      85             : 
      86           3 : void XMLMetaTransformerContext::EndElement()
      87             : {
      88             :     // export everything in the correct order
      89           3 :     OUString aKeywordsQName;
      90           3 :     XMLTokenEnum *pToken = aMetaTokens;
      91          63 :     while( *pToken != XML_TOKEN_END )
      92             :     {
      93          57 :         const OUString& rToken = GetXMLToken( *pToken );
      94             :         XMLMetaContexts_Impl::const_iterator aIter =
      95          57 :             m_aContexts.find( rToken );
      96          57 :         if( aIter != m_aContexts.end() )
      97             :         {
      98          17 :             if( XML_KEYWORD == *pToken )
      99             :             {
     100           0 :                 aKeywordsQName =
     101           0 :                     GetTransformer().GetNamespaceMap().GetQNameByKey(
     102           0 :                             XML_NAMESPACE_META, GetXMLToken(XML_KEYWORDS ) );
     103             : 
     104             :                 Reference< XAttributeList > xAttrList =
     105           0 :                     new XMLMutableAttributeList;
     106           0 :                 GetTransformer().GetDocHandler()->startElement( aKeywordsQName,
     107           0 :                                                             xAttrList );
     108             :             }
     109             : 
     110             :             // All elements may occur multiple times
     111             :             XMLMetaContexts_Impl::const_iterator aEndIter =
     112          17 :                 m_aContexts.upper_bound( rToken );
     113          51 :             while( aIter != aEndIter )
     114             :             {
     115          17 :                 (*aIter).second->Export();
     116          17 :                 ++aIter;
     117             :             }
     118             : 
     119          17 :             if( XML_KEYWORD == *pToken )
     120           0 :                 GetTransformer().GetDocHandler()->endElement( aKeywordsQName );
     121             :         }
     122          57 :         pToken++;
     123             :     }
     124             : 
     125           3 :     GetTransformer().GetDocHandler()->endElement( GetQName() );
     126           3 : }
     127             : 
     128           0 : void XMLMetaTransformerContext::Characters( const OUString& )
     129             : {
     130             :     // ignore them
     131           0 : }
     132             : 
     133             : 
     134             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11