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