LCOV - code coverage report
Current view: top level - xmloff/source/transform - TransformerActions.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 25 29 86.2 %
Date: 2012-08-25 Functions: 12 14 85.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 4 75.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef _XMLOFF_TRANSFORMERACTIONS_HXX
      30                 :            : #define _XMLOFF_TRANSFORMERACTIONS_HXX
      31                 :            : 
      32                 :            : #include <rtl/ustring.hxx>
      33                 :            : #include <xmloff/nmspmap.hxx>
      34                 :            : 
      35                 :            : #include <boost/unordered_map.hpp>
      36                 :            : #include "TransformerActionInit.hxx"
      37                 :            : #include "TransformerAction.hxx"
      38                 :            : 
      39                 :     253673 : struct NameKey_Impl
      40                 :            : {
      41                 :            :     sal_uInt16 m_nPrefix;
      42                 :            :     ::rtl::OUString m_aLocalName;
      43                 :            : 
      44                 :            :     inline NameKey_Impl( sal_uInt16 nPrfx,
      45                 :            :                          ::xmloff::token::XMLTokenEnum eLclNm ) :
      46                 :            :         m_nPrefix( nPrfx ),
      47                 :            :         m_aLocalName( ::xmloff::token::GetXMLToken( eLclNm ) )
      48                 :            :     {
      49                 :            :     }
      50                 :            : 
      51                 :      27742 :     inline NameKey_Impl( sal_uInt16 nPrfx, const ::rtl::OUString& rLclNm ) :
      52                 :            :         m_nPrefix( nPrfx ),
      53                 :      27742 :         m_aLocalName( rLclNm )
      54                 :            :     {
      55                 :      27742 :     }
      56                 :            : 
      57                 :        855 :     inline NameKey_Impl() :
      58                 :        855 :         m_nPrefix( XML_NAMESPACE_UNKNOWN )
      59                 :            :     {
      60                 :        855 :     }
      61                 :            : 
      62                 :      56133 :     inline void SetLocalName( ::xmloff::token::XMLTokenEnum eLclNm )
      63                 :            :     {
      64                 :      56133 :         m_aLocalName = ::xmloff::token::GetXMLToken( eLclNm );
      65                 :      56133 :     }
      66                 :            : };
      67                 :            : 
      68                 :            : // -----------------------------------------------------------------------------
      69                 :            : 
      70                 :            : struct NameHash_Impl
      71                 :            : {
      72                 :            :     inline size_t operator()( const NameKey_Impl& r ) const;
      73                 :            :     inline bool operator()( const NameKey_Impl& r1,
      74                 :            :                                const NameKey_Impl& r2 ) const;
      75                 :            : };
      76                 :            : 
      77                 :      87481 : inline size_t NameHash_Impl::operator()( const NameKey_Impl& r ) const
      78                 :            : {
      79                 :            :     return static_cast< size_t >( r.m_nPrefix ) +
      80                 :      87481 :            static_cast< size_t >( r.m_aLocalName.hashCode() );
      81                 :            : }
      82                 :            : 
      83                 :      13052 : inline bool NameHash_Impl::operator()(
      84                 :            :         const NameKey_Impl& r1,
      85                 :            :         const NameKey_Impl& r2 ) const
      86                 :            : {
      87 [ +  + ][ +  - ]:      13052 :     return r1.m_nPrefix == r2.m_nPrefix && r1.m_aLocalName == r2.m_aLocalName;
      88                 :            : }
      89                 :            : 
      90                 :            : // -----------------------------------------------------------------------------
      91                 :            : 
      92                 :            : struct TransformerAction_Impl
      93                 :            : {
      94                 :            :     sal_uInt32 m_nActionType;
      95                 :            :     sal_uInt32 m_nParam1;
      96                 :            :     sal_uInt32 m_nParam2;
      97                 :            :     sal_uInt32 m_nParam3;
      98                 :            : 
      99                 :            :     inline TransformerAction_Impl( sal_uInt32 nActnTp, sal_uInt32 nPrm1,
     100                 :            :                                    sal_uInt32 nPrm2, sal_uInt32 nPrm3 ) :
     101                 :            :         m_nActionType( nActnTp ),
     102                 :            :         m_nParam1( nPrm1 ),
     103                 :            :         m_nParam2( nPrm2 ),
     104                 :            :         m_nParam3( nPrm3 )
     105                 :            :     {
     106                 :            : 
     107                 :            :     }
     108                 :       5351 :     inline TransformerAction_Impl() :
     109                 :            :         m_nActionType( XML_TACTION_EOT ),
     110                 :            :         m_nParam1( 0 ),
     111                 :            :         m_nParam2( 0 ),
     112                 :       5351 :         m_nParam3( 0 )
     113                 :            :     {
     114                 :       5351 :     }
     115                 :            : 
     116                 :       1038 :     sal_uInt16 GetQNamePrefixFromParam1() const
     117                 :            :     {
     118                 :       1038 :         return static_cast< sal_uInt16 >( m_nParam1 >> 16 );
     119                 :            :     }
     120                 :            : 
     121                 :         12 :     sal_uInt16 GetQNamePrefixFromParam2() const
     122                 :            :     {
     123                 :         12 :         return static_cast< sal_uInt16 >( m_nParam2 >> 16 );
     124                 :            :     }
     125                 :            : 
     126                 :          0 :     sal_uInt16 GetQNamePrefixFromParam3() const
     127                 :            :     {
     128                 :          0 :         return static_cast< sal_uInt16 >( m_nParam3 >> 16 );
     129                 :            :     }
     130                 :            : 
     131                 :       1038 :     ::xmloff::token::XMLTokenEnum GetQNameTokenFromParam1() const
     132                 :            :     {
     133                 :       1038 :         return static_cast< ::xmloff::token::XMLTokenEnum>( m_nParam1 & 0xffff );
     134                 :            :     }
     135                 :            : 
     136                 :         12 :     ::xmloff::token::XMLTokenEnum GetQNameTokenFromParam2() const
     137                 :            :     {
     138                 :         12 :         return static_cast< ::xmloff::token::XMLTokenEnum>( m_nParam2 & 0xffff );
     139                 :            :     }
     140                 :            : 
     141                 :          0 :     ::xmloff::token::XMLTokenEnum GetQNameTokenFromParam3() const
     142                 :            :     {
     143                 :          0 :         return static_cast< ::xmloff::token::XMLTokenEnum>( m_nParam3 & 0xffff );
     144                 :            :     }
     145                 :            : 
     146                 :            : };
     147                 :            : 
     148                 :            : 
     149                 :            : // -----------------------------------------------------------------------------
     150                 :            : 
     151                 :            : class XMLTransformerActions :
     152                 :            :     public ::boost::unordered_map< NameKey_Impl, TransformerAction_Impl,
     153                 :            :                             NameHash_Impl, NameHash_Impl >
     154                 :            : {
     155                 :            : public:
     156                 :            :     XMLTransformerActions( XMLTransformerActionInit *pInit );
     157                 :            :     ~XMLTransformerActions();
     158                 :            : 
     159                 :            :     void Add( XMLTransformerActionInit *pInit );
     160                 :            : };
     161                 :            : 
     162                 :            : #endif  //  _XMLOFF_TRANSFORMERACTIONS_HXX
     163                 :            : 
     164                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10