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