LCOV - code coverage report
Current view: top level - xmloff/source/transform - TransformerActions.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 30 30 100.0 %
Date: 2015-06-13 12:38:46 Functions: 14 14 100.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             : #ifndef INCLUDED_XMLOFF_SOURCE_TRANSFORM_TRANSFORMERACTIONS_HXX
      21             : #define INCLUDED_XMLOFF_SOURCE_TRANSFORM_TRANSFORMERACTIONS_HXX
      22             : 
      23             : #include <rtl/ustring.hxx>
      24             : #include <xmloff/nmspmap.hxx>
      25             : #include "TransformerActionInit.hxx"
      26             : #include "TransformerAction.hxx"
      27             : #include <unordered_map>
      28             : 
      29      191560 : struct NameKey_Impl
      30             : {
      31             :     sal_uInt16 m_nPrefix;
      32             :     OUString m_aLocalName;
      33             : 
      34             :     inline NameKey_Impl( sal_uInt16 nPrfx,
      35             :                          ::xmloff::token::XMLTokenEnum eLclNm ) :
      36             :         m_nPrefix( nPrfx ),
      37             :         m_aLocalName( ::xmloff::token::GetXMLToken( eLclNm ) )
      38             :     {
      39             :     }
      40             : 
      41       18775 :     inline NameKey_Impl( sal_uInt16 nPrfx, const OUString& rLclNm ) :
      42             :         m_nPrefix( nPrfx ),
      43       18775 :         m_aLocalName( rLclNm )
      44             :     {
      45       18775 :     }
      46             : 
      47         501 :     inline NameKey_Impl() :
      48         501 :         m_nPrefix( XML_NAMESPACE_UNKNOWN )
      49             :     {
      50         501 :     }
      51             : 
      52       43003 :     inline void SetLocalName( ::xmloff::token::XMLTokenEnum eLclNm )
      53             :     {
      54       43003 :         m_aLocalName = ::xmloff::token::GetXMLToken( eLclNm );
      55       43003 :     }
      56             : };
      57             : 
      58             : struct NameHash_Impl
      59             : {
      60             :     inline size_t operator()( const NameKey_Impl& r ) const;
      61             :     inline bool operator()( const NameKey_Impl& r1,
      62             :                                const NameKey_Impl& r2 ) const;
      63             : };
      64             : 
      65       63234 : inline size_t NameHash_Impl::operator()( const NameKey_Impl& r ) const
      66             : {
      67      126468 :     return static_cast< size_t >( r.m_nPrefix ) +
      68      126468 :            static_cast< size_t >( r.m_aLocalName.hashCode() );
      69             : }
      70             : 
      71       10327 : inline bool NameHash_Impl::operator()(
      72             :         const NameKey_Impl& r1,
      73             :         const NameKey_Impl& r2 ) const
      74             : {
      75       10327 :     return r1.m_nPrefix == r2.m_nPrefix && r1.m_aLocalName == r2.m_aLocalName;
      76             : }
      77             : 
      78             : struct TransformerAction_Impl
      79             : {
      80             :     sal_uInt32 m_nActionType;
      81             :     sal_uInt32 m_nParam1;
      82             :     sal_uInt32 m_nParam2;
      83             :     sal_uInt32 m_nParam3;
      84             : 
      85             :     inline TransformerAction_Impl( sal_uInt32 nActnTp, sal_uInt32 nPrm1,
      86             :                                    sal_uInt32 nPrm2, sal_uInt32 nPrm3 ) :
      87             :         m_nActionType( nActnTp ),
      88             :         m_nParam1( nPrm1 ),
      89             :         m_nParam2( nPrm2 ),
      90             :         m_nParam3( nPrm3 )
      91             :     {
      92             : 
      93             :     }
      94        2120 :     inline TransformerAction_Impl() :
      95             :         m_nActionType( XML_TACTION_EOT ),
      96             :         m_nParam1( 0 ),
      97             :         m_nParam2( 0 ),
      98        2120 :         m_nParam3( 0 )
      99             :     {
     100        2120 :     }
     101             : 
     102         812 :     sal_uInt16 GetQNamePrefixFromParam1() const
     103             :     {
     104         812 :         return static_cast< sal_uInt16 >( m_nParam1 >> 16 );
     105             :     }
     106             : 
     107          14 :     sal_uInt16 GetQNamePrefixFromParam2() const
     108             :     {
     109          14 :         return static_cast< sal_uInt16 >( m_nParam2 >> 16 );
     110             :     }
     111             : 
     112          10 :     sal_uInt16 GetQNamePrefixFromParam3() const
     113             :     {
     114          10 :         return static_cast< sal_uInt16 >( m_nParam3 >> 16 );
     115             :     }
     116             : 
     117         812 :     ::xmloff::token::XMLTokenEnum GetQNameTokenFromParam1() const
     118             :     {
     119         812 :         return static_cast< ::xmloff::token::XMLTokenEnum>( m_nParam1 & 0xffff );
     120             :     }
     121             : 
     122          14 :     ::xmloff::token::XMLTokenEnum GetQNameTokenFromParam2() const
     123             :     {
     124          14 :         return static_cast< ::xmloff::token::XMLTokenEnum>( m_nParam2 & 0xffff );
     125             :     }
     126             : 
     127          10 :     ::xmloff::token::XMLTokenEnum GetQNameTokenFromParam3() const
     128             :     {
     129          10 :         return static_cast< ::xmloff::token::XMLTokenEnum>( m_nParam3 & 0xffff );
     130             :     }
     131             : 
     132             : };
     133             : 
     134             : class XMLTransformerActions :
     135             :     public std::unordered_map< NameKey_Impl, TransformerAction_Impl,
     136             :                             NameHash_Impl, NameHash_Impl >
     137             : {
     138             : public:
     139             :     explicit XMLTransformerActions( XMLTransformerActionInit *pInit );
     140             :     ~XMLTransformerActions();
     141             : 
     142             :     void Add( XMLTransformerActionInit *pInit );
     143             : };
     144             : 
     145             : #endif // INCLUDED_XMLOFF_SOURCE_TRANSFORM_TRANSFORMERACTIONS_HXX
     146             : 
     147             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11