34
|
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: Property's value encapsulation.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#ifndef XN_DOM_PROPERTY_VALUE_H
|
|
21 |
#define XN_DOM_PROPERTY_VALUE_H
|
|
22 |
|
|
23 |
// INCLUDES
|
|
24 |
#include <e32base.h>
|
|
25 |
#include <s32strm.h>
|
|
26 |
#include "mxndomlistitem.h"
|
|
27 |
|
|
28 |
|
|
29 |
//CLASS FORWARD
|
|
30 |
class CXnDomStringPool;
|
|
31 |
class TRgb;
|
|
32 |
// CLASS DECLARATION
|
|
33 |
|
|
34 |
/**
|
|
35 |
* @ingroup group_domdocument
|
|
36 |
* Serializable class to hold property's value.
|
|
37 |
*
|
|
38 |
* @lib XnDomDocument.lib
|
|
39 |
* @since Series 60 3.1
|
|
40 |
*/
|
|
41 |
class CXnDomPropertyValue : public CBase, public MXnDomListItem
|
|
42 |
{
|
|
43 |
public: //Enumerations
|
|
44 |
|
|
45 |
/**
|
|
46 |
* CSS Primitive value type
|
|
47 |
*/
|
|
48 |
enum TPrimitiveValueType
|
|
49 |
{
|
|
50 |
EUnknown = 0,
|
|
51 |
ENumber,
|
|
52 |
EPercentage,
|
|
53 |
EEms,
|
|
54 |
EExs,
|
|
55 |
EPx,
|
|
56 |
ECm,
|
|
57 |
EMm,
|
|
58 |
EIn,
|
|
59 |
EPt,
|
|
60 |
EPc,
|
|
61 |
EDeg,
|
|
62 |
ERad,
|
|
63 |
EGrad,
|
|
64 |
EMs,
|
|
65 |
ES,
|
|
66 |
EHz,
|
|
67 |
EKHz,
|
|
68 |
EDimension,
|
|
69 |
EString,
|
|
70 |
EUri,
|
|
71 |
EIdent,
|
|
72 |
EAttr,
|
|
73 |
ECounter,
|
|
74 |
ERect,
|
|
75 |
ERgbColor,
|
|
76 |
ERgbaColor,
|
|
77 |
EFunction,
|
|
78 |
EUnitValue
|
|
79 |
};
|
|
80 |
|
|
81 |
/**
|
|
82 |
* Ident type
|
|
83 |
*/
|
|
84 |
enum TIdentType
|
|
85 |
{
|
|
86 |
ENotSet = 0,
|
|
87 |
EAuto,
|
|
88 |
ENone,
|
|
89 |
EInherit
|
|
90 |
};
|
|
91 |
|
|
92 |
public: // Constructors and destructor
|
|
93 |
|
|
94 |
/**
|
|
95 |
* Two-phased constructor.
|
|
96 |
*/
|
|
97 |
IMPORT_C static CXnDomPropertyValue* NewL( CXnDomStringPool* aStringPool );
|
|
98 |
|
|
99 |
/**
|
|
100 |
* Two-phased stream constructor.
|
|
101 |
*/
|
|
102 |
static CXnDomPropertyValue* NewL(
|
|
103 |
RReadStream& aStream,
|
|
104 |
CXnDomStringPool* aStringPool );
|
|
105 |
|
|
106 |
/**
|
|
107 |
* Destructor.
|
|
108 |
*/
|
|
109 |
IMPORT_C virtual ~CXnDomPropertyValue();
|
|
110 |
|
|
111 |
public: // New functions
|
|
112 |
/**
|
|
113 |
* Clone property value.
|
|
114 |
* @since Series 60 3.1
|
|
115 |
* @return Pointer to a property value. Ownership is transferred to a caller
|
|
116 |
*/
|
|
117 |
IMPORT_C CXnDomPropertyValue* CloneL();
|
|
118 |
|
|
119 |
/**
|
|
120 |
* Clone property value.
|
|
121 |
* @since Series 60 3.1
|
|
122 |
* @param aStringPool StringPool clone which holds actual strings.
|
|
123 |
* @return Pointer to a property value. Ownership is transferred to a caller
|
|
124 |
*/
|
|
125 |
CXnDomPropertyValue* CloneL( CXnDomStringPool& aStringPool );
|
|
126 |
|
|
127 |
/**
|
|
128 |
* Release object's data.
|
|
129 |
* @since Series 60 3.1
|
|
130 |
*/
|
|
131 |
IMPORT_C void ReleaseData();
|
|
132 |
|
|
133 |
/**
|
|
134 |
* Get the property's value. If value type is not recognized,
|
|
135 |
* function will leave with KErrNotSupported.
|
|
136 |
* @since Series 60 3.1
|
|
137 |
* @return Property's value
|
|
138 |
*/
|
|
139 |
IMPORT_C TReal FloatValueL() const;
|
|
140 |
|
|
141 |
/**
|
|
142 |
* Set the property's value based on a given type. If type is not recognized,
|
|
143 |
* function will leave with KErrNotSupported.
|
|
144 |
* @since Series 60 3.1
|
|
145 |
* @param aValueType Type of a value.
|
|
146 |
* @param aFloatValue Property's value.
|
|
147 |
*/
|
|
148 |
IMPORT_C void SetFloatValueL( TPrimitiveValueType aValueType, TReal aFloatValue );
|
|
149 |
|
|
150 |
/**
|
|
151 |
* Get the property's string value. If value is not a string type,
|
|
152 |
* function will leave with KErrNotSupported.
|
|
153 |
* @since Series 60 3.1
|
|
154 |
* @return Pointer to the property's string value.
|
|
155 |
*/
|
|
156 |
IMPORT_C const TDesC8& StringValueL() ;
|
|
157 |
|
|
158 |
/**
|
|
159 |
* Get the property's string value. If value is not a string type,
|
|
160 |
* function will return KNullDesC8.
|
|
161 |
* @since Series 60 5.0
|
|
162 |
* @return Reference to string.
|
|
163 |
*/
|
|
164 |
IMPORT_C const TDesC8& StringValue() ;
|
|
165 |
|
|
166 |
/**
|
|
167 |
* Set the property's string value based on a given type. If type is not recognized,
|
|
168 |
* function will leave with KErrNotSupported.
|
|
169 |
* @since Series 60 3.1
|
|
170 |
* @param aValueType Type of a value.
|
|
171 |
* @param aStringValue Property's string value.
|
|
172 |
*/
|
|
173 |
IMPORT_C void SetStringValueL(
|
|
174 |
TPrimitiveValueType aValueType,
|
|
175 |
const TDesC8& aStringValue );
|
|
176 |
|
|
177 |
/**
|
|
178 |
* Get the property's color value.
|
|
179 |
* @since Series 60 3.1
|
|
180 |
* @return Property's color value (TRgb).
|
|
181 |
*/
|
|
182 |
IMPORT_C const TRgb& RgbColorValueL() const;
|
|
183 |
|
|
184 |
/**
|
|
185 |
* Sets the RGB Color value
|
|
186 |
* @since Series 60 3.1
|
|
187 |
* @param aRgb Instance of TRgb.
|
|
188 |
*/
|
|
189 |
IMPORT_C void SetRgbColorL( const TRgb& aRgb );
|
|
190 |
|
|
191 |
/**
|
|
192 |
* Returns the primitive value type
|
|
193 |
* @since Series 60 3.1
|
|
194 |
* @return Primitive value type
|
|
195 |
*/
|
|
196 |
IMPORT_C TPrimitiveValueType PrimitiveValueType() const;
|
|
197 |
|
|
198 |
/**
|
|
199 |
* Checks if string value is "inherit"
|
|
200 |
* @since Series 60 3.1
|
|
201 |
* @return ETrue if TPrimitiveValueType::EIdent and string value is "inherit".
|
|
202 |
*/
|
|
203 |
IMPORT_C TBool IsInheritIdent();
|
|
204 |
|
|
205 |
/**
|
|
206 |
* Checks if string value is "auto"
|
|
207 |
* @since Series 60 3.1
|
|
208 |
* @return ETrue if TPrimitiveValueType::EIdent and string value is "auto".
|
|
209 |
*/
|
|
210 |
IMPORT_C TBool IsAutoIdent();
|
|
211 |
|
|
212 |
/**
|
|
213 |
* Checks if string value is "none"
|
|
214 |
* @since Series 60 3.1
|
|
215 |
* @return ETrue if TPrimitiveValueType::EIdent and string value is "none".
|
|
216 |
*/
|
|
217 |
IMPORT_C TBool IsNoneIdent();
|
|
218 |
|
|
219 |
/**
|
|
220 |
* Set the property's string pool index
|
|
221 |
* @since Series 60 3.1
|
|
222 |
* @param aValueType Type of a value.
|
|
223 |
* @param aStringPoolIndex String pool index.
|
|
224 |
*/
|
|
225 |
IMPORT_C void SetStringPoolIndexL(
|
|
226 |
TPrimitiveValueType aValueType,
|
|
227 |
TInt16 aStringPoolIndex );
|
|
228 |
|
|
229 |
/**
|
|
230 |
* Get the property's string pool index. If type is not string,
|
|
231 |
* function will leave with KErrNotSupported.
|
|
232 |
* @since Series 60 3.1
|
|
233 |
* @return String pool index.
|
|
234 |
*/
|
|
235 |
IMPORT_C TInt16 StringPoolIndexL()const;
|
|
236 |
|
|
237 |
/**
|
|
238 |
* Swap used string pool.
|
|
239 |
*
|
|
240 |
* @param aStringPool New string pool to be used.
|
|
241 |
* Ownership not transferred!
|
|
242 |
*/
|
|
243 |
IMPORT_C void SwapStringPoolL( CXnDomStringPool* aStringPool );
|
|
244 |
|
|
245 |
public: //From MXnDomListItem
|
|
246 |
/**
|
|
247 |
* Documented in MXnDomListItem::Size
|
|
248 |
*/
|
|
249 |
TInt Size()const;
|
|
250 |
|
|
251 |
/**
|
|
252 |
* Documented in MXnDomListItem::ExternalizeL
|
|
253 |
*/
|
|
254 |
void ExternalizeL( RWriteStream& aStream ) const;
|
|
255 |
|
|
256 |
/**
|
|
257 |
* Documented in MXnDomListItem::InternalizeL
|
|
258 |
*/
|
|
259 |
void InternalizeL( RReadStream& aStream );
|
|
260 |
|
|
261 |
|
|
262 |
/**
|
|
263 |
* Documented in MXnDomListItem::Name
|
|
264 |
*/
|
|
265 |
const TDesC8& Name(){ return KNullDesC8; }
|
|
266 |
|
|
267 |
private:
|
|
268 |
|
|
269 |
/**
|
|
270 |
* C++ default constructor.
|
|
271 |
*/
|
|
272 |
CXnDomPropertyValue( CXnDomStringPool* aStringPool );
|
|
273 |
|
|
274 |
/**
|
|
275 |
* By default Symbian 2nd phase constructor is private.
|
|
276 |
*/
|
|
277 |
void ConstructL();
|
|
278 |
|
|
279 |
|
|
280 |
private: // Data
|
|
281 |
|
|
282 |
// union containing the primitive value data,
|
|
283 |
// this is an union for memory consumption optimization reasons
|
|
284 |
union
|
|
285 |
{
|
|
286 |
// rgba color
|
|
287 |
TRgb* iRgbColor;
|
|
288 |
|
|
289 |
// Real value
|
|
290 |
TReal* iRealValue;
|
|
291 |
|
|
292 |
// String reference
|
|
293 |
TInt16 iStringRef;
|
|
294 |
|
|
295 |
// Constant string value
|
|
296 |
TPtrC* iUnknownValue;
|
|
297 |
|
|
298 |
} iData;
|
|
299 |
|
|
300 |
//String pool
|
|
301 |
CXnDomStringPool* iStringPool;
|
|
302 |
|
|
303 |
// primitive value type
|
|
304 |
TPrimitiveValueType iPrimitiveValueType;
|
|
305 |
|
|
306 |
//Flag to identify ident
|
|
307 |
TIdentType iIdent;
|
|
308 |
|
|
309 |
};
|
|
310 |
|
|
311 |
#endif // XN_DOM_PROPERTY_VALUE_H
|
|
312 |
|
|
313 |
// End of File
|