1*ecfe53c5SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ecfe53c5SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ecfe53c5SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ecfe53c5SAndrew Rist  * distributed with this work for additional information
6*ecfe53c5SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ecfe53c5SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ecfe53c5SAndrew Rist  * "License"); you may not use this file except in compliance
9*ecfe53c5SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ecfe53c5SAndrew Rist  *
11*ecfe53c5SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ecfe53c5SAndrew Rist  *
13*ecfe53c5SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ecfe53c5SAndrew Rist  * software distributed under the License is distributed on an
15*ecfe53c5SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ecfe53c5SAndrew Rist  * KIND, either express or implied.  See the License for the
17*ecfe53c5SAndrew Rist  * specific language governing permissions and limitations
18*ecfe53c5SAndrew Rist  * under the License.
19*ecfe53c5SAndrew Rist  *
20*ecfe53c5SAndrew Rist  *************************************************************/
21*ecfe53c5SAndrew Rist 
22*ecfe53c5SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _XMLOFF_TRANSFORMERACTIONS_HXX
25cdf0e10cSrcweir #define _XMLOFF_TRANSFORMERACTIONS_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <rtl/ustring.hxx>
28cdf0e10cSrcweir #include <xmloff/nmspmap.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <hash_map>
31cdf0e10cSrcweir #include "TransformerActionInit.hxx"
32cdf0e10cSrcweir #include "TransformerAction.hxx"
33cdf0e10cSrcweir 
34cdf0e10cSrcweir struct NameKey_Impl
35cdf0e10cSrcweir {
36cdf0e10cSrcweir 	sal_uInt16 m_nPrefix;
37cdf0e10cSrcweir 	::rtl::OUString m_aLocalName;
38cdf0e10cSrcweir 
NameKey_ImplNameKey_Impl39cdf0e10cSrcweir 	inline NameKey_Impl( sal_uInt16 nPrfx,
40cdf0e10cSrcweir 						 ::xmloff::token::XMLTokenEnum eLclNm ) :
41cdf0e10cSrcweir 		m_nPrefix( nPrfx ),
42cdf0e10cSrcweir 		m_aLocalName( ::xmloff::token::GetXMLToken( eLclNm ) )
43cdf0e10cSrcweir 	{
44cdf0e10cSrcweir 	}
45cdf0e10cSrcweir 
NameKey_ImplNameKey_Impl46cdf0e10cSrcweir 	inline NameKey_Impl( sal_uInt16 nPrfx, const ::rtl::OUString& rLclNm ) :
47cdf0e10cSrcweir 		m_nPrefix( nPrfx ),
48cdf0e10cSrcweir 		m_aLocalName( rLclNm )
49cdf0e10cSrcweir 	{
50cdf0e10cSrcweir 	}
51cdf0e10cSrcweir 
NameKey_ImplNameKey_Impl52cdf0e10cSrcweir 	inline NameKey_Impl() :
53cdf0e10cSrcweir 		m_nPrefix( XML_NAMESPACE_UNKNOWN )
54cdf0e10cSrcweir 	{
55cdf0e10cSrcweir 	}
56cdf0e10cSrcweir 
SetLocalNameNameKey_Impl57cdf0e10cSrcweir 	inline void SetLocalName( ::xmloff::token::XMLTokenEnum eLclNm )
58cdf0e10cSrcweir 	{
59cdf0e10cSrcweir 		m_aLocalName = ::xmloff::token::GetXMLToken( eLclNm );
60cdf0e10cSrcweir 	}
61cdf0e10cSrcweir };
62cdf0e10cSrcweir 
63cdf0e10cSrcweir // -----------------------------------------------------------------------------
64cdf0e10cSrcweir 
65cdf0e10cSrcweir struct NameHash_Impl
66cdf0e10cSrcweir {
67cdf0e10cSrcweir 	inline size_t operator()( const NameKey_Impl& r ) const;
68cdf0e10cSrcweir 	inline bool operator()( const NameKey_Impl& r1,
69cdf0e10cSrcweir 				   			const NameKey_Impl& r2 ) const;
70cdf0e10cSrcweir };
71cdf0e10cSrcweir 
operator ()(const NameKey_Impl & r) const72cdf0e10cSrcweir inline size_t NameHash_Impl::operator()( const NameKey_Impl& r ) const
73cdf0e10cSrcweir {
74cdf0e10cSrcweir 	return static_cast< size_t >( r.m_nPrefix ) +
75cdf0e10cSrcweir 		   static_cast< size_t >( r.m_aLocalName.hashCode() );
76cdf0e10cSrcweir }
77cdf0e10cSrcweir 
operator ()(const NameKey_Impl & r1,const NameKey_Impl & r2) const78cdf0e10cSrcweir inline bool NameHash_Impl::operator()(
79cdf0e10cSrcweir 		const NameKey_Impl& r1,
80cdf0e10cSrcweir 		const NameKey_Impl& r2 ) const
81cdf0e10cSrcweir {
82cdf0e10cSrcweir 	return r1.m_nPrefix == r2.m_nPrefix && r1.m_aLocalName == r2.m_aLocalName;
83cdf0e10cSrcweir }
84cdf0e10cSrcweir 
85cdf0e10cSrcweir // -----------------------------------------------------------------------------
86cdf0e10cSrcweir 
87cdf0e10cSrcweir struct TransformerAction_Impl
88cdf0e10cSrcweir {
89cdf0e10cSrcweir 	sal_uInt32 m_nActionType;
90cdf0e10cSrcweir 	sal_uInt32 m_nParam1;
91cdf0e10cSrcweir 	sal_uInt32 m_nParam2;
92cdf0e10cSrcweir 	sal_uInt32 m_nParam3;
93cdf0e10cSrcweir 
TransformerAction_ImplTransformerAction_Impl94cdf0e10cSrcweir 	inline TransformerAction_Impl( sal_uInt32 nActnTp, sal_uInt32 nPrm1,
95cdf0e10cSrcweir 								   sal_uInt32 nPrm2, sal_uInt32 nPrm3 ) :
96cdf0e10cSrcweir 		m_nActionType( nActnTp ),
97cdf0e10cSrcweir 		m_nParam1( nPrm1 ),
98cdf0e10cSrcweir 		m_nParam2( nPrm2 ),
99cdf0e10cSrcweir 		m_nParam3( nPrm3 )
100cdf0e10cSrcweir 	{
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 	}
TransformerAction_ImplTransformerAction_Impl103cdf0e10cSrcweir 	inline TransformerAction_Impl() :
104cdf0e10cSrcweir 		m_nActionType( XML_TACTION_EOT ),
105cdf0e10cSrcweir 		m_nParam1( 0 ),
106cdf0e10cSrcweir 		m_nParam2( 0 ),
107cdf0e10cSrcweir 		m_nParam3( 0 )
108cdf0e10cSrcweir 	{
109cdf0e10cSrcweir 	}
110cdf0e10cSrcweir 
GetQNamePrefixFromParam1TransformerAction_Impl111cdf0e10cSrcweir 	sal_uInt16 GetQNamePrefixFromParam1() const
112cdf0e10cSrcweir 	{
113cdf0e10cSrcweir 		return static_cast< sal_uInt16 >( m_nParam1 >> 16 );
114cdf0e10cSrcweir 	}
115cdf0e10cSrcweir 
GetQNamePrefixFromParam2TransformerAction_Impl116cdf0e10cSrcweir 	sal_uInt16 GetQNamePrefixFromParam2() const
117cdf0e10cSrcweir 	{
118cdf0e10cSrcweir 		return static_cast< sal_uInt16 >( m_nParam2 >> 16 );
119cdf0e10cSrcweir 	}
120cdf0e10cSrcweir 
GetQNamePrefixFromParam3TransformerAction_Impl121cdf0e10cSrcweir 	sal_uInt16 GetQNamePrefixFromParam3() const
122cdf0e10cSrcweir 	{
123cdf0e10cSrcweir 		return static_cast< sal_uInt16 >( m_nParam3 >> 16 );
124cdf0e10cSrcweir 	}
125cdf0e10cSrcweir 
GetQNameTokenFromParam1TransformerAction_Impl126cdf0e10cSrcweir 	::xmloff::token::XMLTokenEnum GetQNameTokenFromParam1() const
127cdf0e10cSrcweir 	{
128cdf0e10cSrcweir 		return static_cast< ::xmloff::token::XMLTokenEnum>( m_nParam1 & 0xffff );
129cdf0e10cSrcweir 	}
130cdf0e10cSrcweir 
GetQNameTokenFromParam2TransformerAction_Impl131cdf0e10cSrcweir 	::xmloff::token::XMLTokenEnum GetQNameTokenFromParam2() const
132cdf0e10cSrcweir 	{
133cdf0e10cSrcweir 		return static_cast< ::xmloff::token::XMLTokenEnum>( m_nParam2 & 0xffff );
134cdf0e10cSrcweir 	}
135cdf0e10cSrcweir 
GetQNameTokenFromParam3TransformerAction_Impl136cdf0e10cSrcweir 	::xmloff::token::XMLTokenEnum GetQNameTokenFromParam3() const
137cdf0e10cSrcweir 	{
138cdf0e10cSrcweir 		return static_cast< ::xmloff::token::XMLTokenEnum>( m_nParam3 & 0xffff );
139cdf0e10cSrcweir 	}
140cdf0e10cSrcweir 
141cdf0e10cSrcweir };
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 
144cdf0e10cSrcweir // -----------------------------------------------------------------------------
145cdf0e10cSrcweir 
146cdf0e10cSrcweir class XMLTransformerActions :
147cdf0e10cSrcweir 	public ::std::hash_map< NameKey_Impl, TransformerAction_Impl,
148cdf0e10cSrcweir 						    NameHash_Impl, NameHash_Impl >
149cdf0e10cSrcweir {
150cdf0e10cSrcweir public:
151cdf0e10cSrcweir 	XMLTransformerActions( XMLTransformerActionInit *pInit );
152cdf0e10cSrcweir 	~XMLTransformerActions();
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 	void Add( XMLTransformerActionInit *pInit );
155cdf0e10cSrcweir };
156cdf0e10cSrcweir 
157cdf0e10cSrcweir #endif	//  _XMLOFF_TRANSFORMERACTIONS_HXX
158