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

Generated by: LCOV version 1.10