|
1 /* |
|
2 * Copyright (c) 2005,2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Represents a Css property. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "xndomproperty.h" |
|
22 #include "xndompropertyvalue.h" |
|
23 #include "xndomlist.h" |
|
24 #include "xndomstringpool.h" |
|
25 |
|
26 // ============================ MEMBER FUNCTIONS =============================== |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CXnDomProperty::CXnDomProperty |
|
29 // C++ default constructor can NOT contain any code, that |
|
30 // might leave. |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 CXnDomProperty::CXnDomProperty( CXnDomStringPool* aStringPool ): |
|
34 iStringPool( aStringPool ) |
|
35 { |
|
36 } |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CXnDomProperty::CXnDomProperty |
|
39 // C++ default constructor can NOT contain any code, that |
|
40 // might leave. |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CXnDomProperty::CXnDomProperty( |
|
44 TInt16 aStringPoolIndex, |
|
45 CXnDomStringPool* aStringPool ): |
|
46 iStringPool( aStringPool ), |
|
47 iNameRef( aStringPoolIndex ) |
|
48 { |
|
49 } |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CXnDomProperty::ConstructL |
|
52 // Symbian 2nd phase constructor can leave. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 void CXnDomProperty::ConstructL( const TDesC8& aName ) |
|
56 { |
|
57 iNameRef = iStringPool->AddStringL( aName ); |
|
58 iPropValList = CXnDomList::NewL( CXnDomList::EPropertyValueList, iStringPool ); |
|
59 } |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CXnDomProperty::ConstructL |
|
62 // Symbian 2nd phase constructor can leave. |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 void CXnDomProperty::ConstructL() |
|
66 { |
|
67 iPropValList = CXnDomList::NewL( CXnDomList::EPropertyValueList, iStringPool ); |
|
68 } |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CXnDomProperty::NewL |
|
71 // Two-phased constructor. |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 EXPORT_C CXnDomProperty* CXnDomProperty::NewL( |
|
75 const TDesC8& aName, |
|
76 CXnDomStringPool* aStringPool ) |
|
77 { |
|
78 CXnDomProperty* self = new( ELeave ) CXnDomProperty( aStringPool ); |
|
79 |
|
80 CleanupStack::PushL( self ); |
|
81 self->ConstructL( aName ); |
|
82 CleanupStack::Pop( self ); |
|
83 |
|
84 return self; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CXnDomProperty::NewL |
|
89 // Two-phased stream constructor. |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 CXnDomProperty* CXnDomProperty::NewL( |
|
93 RReadStream& aStream, |
|
94 CXnDomStringPool* aStringPool ) |
|
95 { |
|
96 CXnDomProperty* self = |
|
97 new( ELeave ) CXnDomProperty( aStringPool ); |
|
98 |
|
99 CleanupStack::PushL( self ); |
|
100 |
|
101 aStream >> *self; |
|
102 CleanupStack::Pop( self ); |
|
103 |
|
104 return self; |
|
105 } |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CXnDomProperty::NewL |
|
108 // Two-phased constructor. |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 EXPORT_C CXnDomProperty* CXnDomProperty::NewL( |
|
112 TInt16 aStringPoolIndex, |
|
113 CXnDomStringPool* aStringPool ) |
|
114 { |
|
115 CXnDomProperty* self = |
|
116 new (ELeave) CXnDomProperty( aStringPoolIndex, aStringPool ); |
|
117 CleanupStack::PushL( self ); |
|
118 self->ConstructL(); |
|
119 CleanupStack::Pop( self ); |
|
120 return self; |
|
121 } |
|
122 // Destructor |
|
123 EXPORT_C CXnDomProperty::~CXnDomProperty() |
|
124 { |
|
125 delete iPropValList; |
|
126 } |
|
127 // ----------------------------------------------------------------------------- |
|
128 // CXnDomProperty::CloneL |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 EXPORT_C CXnDomProperty* CXnDomProperty::CloneL() |
|
132 { |
|
133 CXnDomProperty* clone = new (ELeave)CXnDomProperty( iStringPool ); |
|
134 CleanupStack::PushL(clone); |
|
135 |
|
136 clone->iPropValList = CXnDomList::NewL( CXnDomList::EPropertyValueList, iStringPool ); |
|
137 clone->iNameRef = iNameRef; |
|
138 |
|
139 TInt count( iPropValList->Length() ); |
|
140 for (TInt i = 0; i < count; ++i) |
|
141 { |
|
142 CXnDomPropertyValue* val = static_cast<CXnDomPropertyValue*>( iPropValList->Item(i) ); |
|
143 CXnDomPropertyValue* cloneVal = val->CloneL(); |
|
144 CleanupStack::PushL( cloneVal ); |
|
145 clone->iPropValList->AddItemL( cloneVal ); |
|
146 CleanupStack::Pop( cloneVal ); |
|
147 } |
|
148 clone->iInherited = iInherited; |
|
149 clone->iPseudoClass = iPseudoClass; |
|
150 CleanupStack::Pop(clone); |
|
151 return clone; |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CXnDomProperty::CloneL |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 EXPORT_C CXnDomProperty* CXnDomProperty::CloneL( CXnDomStringPool& aStringPool ) |
|
159 { |
|
160 const TDesC8& name = iStringPool->String( iNameRef ); |
|
161 CXnDomProperty* clone = CXnDomProperty::NewL( name, &aStringPool ); |
|
162 CleanupStack::PushL(clone); |
|
163 |
|
164 TInt count( iPropValList->Length() ); |
|
165 for (TInt i = 0; i < count; ++i) |
|
166 { |
|
167 CXnDomPropertyValue* val = static_cast<CXnDomPropertyValue*>( iPropValList->Item(i) ); |
|
168 CXnDomPropertyValue* cloneVal = val->CloneL( aStringPool ); |
|
169 CleanupStack::PushL( cloneVal ); |
|
170 clone->iPropValList->AddItemL( cloneVal ); |
|
171 CleanupStack::Pop( cloneVal ); |
|
172 } |
|
173 clone->iInherited = iInherited; |
|
174 clone->iPseudoClass = iPseudoClass; |
|
175 CleanupStack::Pop(clone); |
|
176 return clone; |
|
177 } |
|
178 |
|
179 // ----------------------------------------------------------------------------- |
|
180 // CXnDomProperty::Name |
|
181 // ----------------------------------------------------------------------------- |
|
182 // |
|
183 EXPORT_C const TDesC8& CXnDomProperty::Name() |
|
184 { |
|
185 return iStringPool->String( iNameRef ); |
|
186 } |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // CXnDomProperty::PropertyValue |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 EXPORT_C CXnDomList& CXnDomProperty::PropertyValueList() |
|
193 { |
|
194 return *iPropValList; |
|
195 } |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // CXnDomProperty::IsValueSet |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 EXPORT_C TBool CXnDomProperty::IsValueSet() |
|
202 { |
|
203 return (iPropValList->Length() > 0); |
|
204 } |
|
205 |
|
206 |
|
207 // ----------------------------------------------------------------------------- |
|
208 // CXnDomProperty::Inherited |
|
209 // ----------------------------------------------------------------------------- |
|
210 // |
|
211 EXPORT_C TBool CXnDomProperty::Inherited() |
|
212 { |
|
213 return iInherited; |
|
214 } |
|
215 // ----------------------------------------------------------------------------- |
|
216 // CXnDomProperty::SetInherited |
|
217 // ----------------------------------------------------------------------------- |
|
218 // |
|
219 EXPORT_C void CXnDomProperty::SetInherited( TBool aInherited ) |
|
220 { |
|
221 iInherited = aInherited; |
|
222 } |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // CXnDomProperty::StringPool |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 EXPORT_C CXnDomStringPool* CXnDomProperty::StringPool() const |
|
229 { |
|
230 return iStringPool; |
|
231 } |
|
232 // ----------------------------------------------------------------------------- |
|
233 // CXnDomProperty::StringPoolIndex |
|
234 // ----------------------------------------------------------------------------- |
|
235 // |
|
236 EXPORT_C TInt16 CXnDomProperty::StringPoolIndex()const |
|
237 { |
|
238 return iNameRef; |
|
239 } |
|
240 |
|
241 // ----------------------------------------------------------------------------- |
|
242 // CXnDomProperty::SwapStringPoolL |
|
243 // ----------------------------------------------------------------------------- |
|
244 // |
|
245 EXPORT_C void CXnDomProperty::SwapStringPoolL( CXnDomStringPool* aStringPool ) |
|
246 { |
|
247 if( !aStringPool ) |
|
248 { |
|
249 User::Leave( KErrArgument ); |
|
250 } |
|
251 |
|
252 iNameRef = aStringPool->AddStringL( iStringPool->String( iNameRef ) ); |
|
253 |
|
254 TInt count = iPropValList->Length(); |
|
255 for( TInt i = 0; i < count; i++ ) |
|
256 { |
|
257 CXnDomPropertyValue* val = |
|
258 static_cast<CXnDomPropertyValue*>( iPropValList->Item(i) ); |
|
259 val->SwapStringPoolL( aStringPool ); |
|
260 } |
|
261 |
|
262 iStringPool = aStringPool; |
|
263 } |
|
264 |
|
265 // ----------------------------------------------------------------------------- |
|
266 // CXnDomProperty::PseudoClass |
|
267 // ----------------------------------------------------------------------------- |
|
268 // |
|
269 EXPORT_C CXnDomProperty::TPseudoClass CXnDomProperty::PseudoClass() const |
|
270 { |
|
271 return iPseudoClass; |
|
272 } |
|
273 |
|
274 // ----------------------------------------------------------------------------- |
|
275 // CXnDomProperty::SetPseudoClass |
|
276 // ----------------------------------------------------------------------------- |
|
277 // |
|
278 EXPORT_C void CXnDomProperty::SetPseudoClass( TPseudoClass aPseudoClass ) |
|
279 { |
|
280 iPseudoClass = aPseudoClass; |
|
281 } |
|
282 |
|
283 // ----------------------------------------------------------------------------- |
|
284 // CXnDomProperty::Size |
|
285 // ----------------------------------------------------------------------------- |
|
286 // |
|
287 TInt CXnDomProperty::Size() const |
|
288 { |
|
289 TInt size( 0 ); |
|
290 |
|
291 size += sizeof(TInt16); //iNameRef |
|
292 size += iPropValList->Size(); |
|
293 size += sizeof(TInt8); //iInherited |
|
294 size += sizeof(TInt8); //iPseudoClass |
|
295 |
|
296 return size; |
|
297 } |
|
298 |
|
299 // ----------------------------------------------------------------------------- |
|
300 // CXnDomProperty::ExternalizeL |
|
301 // ----------------------------------------------------------------------------- |
|
302 // |
|
303 void CXnDomProperty::ExternalizeL( RWriteStream& aStream ) const |
|
304 { |
|
305 aStream.WriteInt16L( iNameRef ); |
|
306 aStream << *iPropValList; |
|
307 aStream.WriteInt8L( iInherited ); |
|
308 aStream.WriteInt8L( iPseudoClass ); |
|
309 } |
|
310 // ----------------------------------------------------------------------------- |
|
311 // CXnDomProperty::InternalizeL |
|
312 // ----------------------------------------------------------------------------- |
|
313 // |
|
314 void CXnDomProperty::InternalizeL( RReadStream& aStream ) |
|
315 { |
|
316 iNameRef = aStream.ReadInt16L(); |
|
317 iPropValList = CXnDomList::NewL( aStream, iStringPool ); |
|
318 |
|
319 iInherited = TBool( aStream.ReadInt8L() ); |
|
320 iPseudoClass = TPseudoClass( aStream.ReadInt8L() ); |
|
321 } |
|
322 |
|
323 // End of File |