1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * Static utility class for manipulating SMIL DOM |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef __UNISMILUTILS_H |
|
22 #define __UNISMILUTILS_H |
|
23 |
|
24 // ========== INCLUDE FILES ================================ |
|
25 #include <gdi.h> |
|
26 |
|
27 #include <MsgMedia.hrh> |
|
28 |
|
29 #include <UniModelConst.h> |
|
30 |
|
31 // ========== CONSTANTS ==================================== |
|
32 |
|
33 // SMIL ELEMENTS |
|
34 _LIT(KSMILWREleBody, "body"); |
|
35 _LIT(KSMILWREleHead, "head"); |
|
36 _LIT(KSMILWREleLayout, "layout"); |
|
37 _LIT(KSMILWRElePar, "par"); |
|
38 _LIT(KSMILWREleRegion, "region"); |
|
39 _LIT(KSMILWREleRoot_layout, "root-layout"); |
|
40 _LIT(KSMILWREleSeq, "seq"); |
|
41 _LIT(KSMILWREleSmil, "smil"); |
|
42 _LIT(KSMILWREleMeta, "meta"); |
|
43 _LIT(KSMILWREleTrans, "transition"); |
|
44 |
|
45 // Media types |
|
46 _LIT(KSMILWREleAnimation, "animation"); |
|
47 _LIT(KSMILWREleAudio, "audio"); |
|
48 _LIT(KSMILWREleImg, "img"); |
|
49 _LIT(KSMILWREleRef, "ref"); |
|
50 _LIT(KSMILWREleText, "text"); |
|
51 _LIT(KSMILWREleTextstream, "textstream"); |
|
52 _LIT(KSMILWREleVideo, "video"); |
|
53 |
|
54 // SMIL PARAMS |
|
55 _LIT(KSMILWRParaId, "id" ); |
|
56 _LIT(KSMILWRParaName, "name"); |
|
57 _LIT(KSMILWRParaContent, "content"); |
|
58 _LIT(KSMILWRParaRegion, "region"); |
|
59 _LIT(KSMILWRParaBgColor, "backgroundColor"); |
|
60 _LIT(KSMILWRParaSrc, "src"); |
|
61 _LIT(KSMILWRParaFit, "fit"); |
|
62 _LIT(KSMILWRParaDur, "dur"); |
|
63 _LIT(KSMILWRParaType, "type"); // Transition |
|
64 _LIT(KSMILWRParaSubType, "subtype"); // Transition |
|
65 _LIT(KSMILWRParaTransIn, "transIn" ); |
|
66 _LIT(KSMILWRParaTransOut, "transOut" ); |
|
67 _LIT(KSMILWRParaBegin, "begin" ); |
|
68 _LIT(KSMILWRParaEnd, "end" ); |
|
69 |
|
70 // Text color mediaparam format: |
|
71 // <param name="foreground-color" value="#000000"/> |
|
72 _LIT ( KSMILWREleParam, "param" ); |
|
73 // _LIT ( KSMILWRParaName, "name" ); Already defined |
|
74 _LIT ( KSMILWRParaValue, "value" ); |
|
75 |
|
76 // Region dimensions |
|
77 _LIT(KSMILWRParaWidth, "width"); |
|
78 _LIT(KSMILWRParaHeight, "height"); |
|
79 _LIT(KSMILWRParaTop, "top"); |
|
80 _LIT(KSMILWRParaLeft, "left"); |
|
81 _LIT(KSMILWRParaBottom, "bottom"); |
|
82 _LIT(KSMILWRParaRight, "right"); |
|
83 |
|
84 // Region ID's |
|
85 _LIT(KSMILWRRegIDImage, "Image"); |
|
86 _LIT(KSMILWRRegIDVideo, "Video"); |
|
87 _LIT(KSMILWRRegIDText, "Text"); |
|
88 |
|
89 // TEMPORARY - To recognise template |
|
90 _LIT(KSMILMetaSmilProfile, "SMILProfile"); |
|
91 _LIT(KSMILMetaSmilProfileValue, "3GPP-SMIL-Rel-5"); |
|
92 |
|
93 |
|
94 // ========== MACROS ======================================= |
|
95 |
|
96 // ========== DATA TYPES =================================== |
|
97 |
|
98 // ========== FUNCTION PROTOTYPES ========================== |
|
99 |
|
100 // ========== FORWARD DECLARATIONS ========================= |
|
101 class CMDXMLNode; |
|
102 class CMDXMLDocument; |
|
103 |
|
104 // ========== CLASS DECLARATION ============================ |
|
105 |
|
106 /** |
|
107 * Static utility class for manipulating SMIL DOM |
|
108 * |
|
109 * @lib UniDataModel.lib |
|
110 * @since 3.1 |
|
111 */ |
|
112 class UniSmilUtils |
|
113 { |
|
114 |
|
115 public: |
|
116 |
|
117 /** |
|
118 * StringToIntValue |
|
119 * Convert a descriptor to TInt |
|
120 * |
|
121 * @since 3.1 |
|
122 * @param aString IN: to be converted |
|
123 * @param aDefault IN: default value to return if conversion fails |
|
124 * @return converted value |
|
125 */ |
|
126 static TInt StringToIntValue( const TDesC& aString, TInt aDefault ); |
|
127 |
|
128 /** |
|
129 * IsMediaElem |
|
130 * Checks if node is mediaobject |
|
131 * |
|
132 * @since 3.1 |
|
133 * @param aNodePtr IN: node to check |
|
134 * @return ETrue node is media objects, EFalse otherwise |
|
135 */ |
|
136 static TBool IsMediaElem( CMDXMLNode *aNodePtr ); |
|
137 |
|
138 /** |
|
139 * NextNode |
|
140 * Finds the next node in DOM in order |
|
141 * 1. Child nodes of the ref node first |
|
142 * 2. Then siblings of the ref node |
|
143 * 3. If ref node has no childs or siblings moves up to |
|
144 * parent node and continues there |
|
145 * 4. Returns NULL at the end of the document. |
|
146 * |
|
147 * @since 3.1 |
|
148 * @param aRefNode IN: current node |
|
149 * @return next node in presentation |
|
150 */ |
|
151 static CMDXMLNode* NextNode( CMDXMLNode* aRefNode ); |
|
152 |
|
153 /** |
|
154 * RemoveChilds |
|
155 * Removes all childs and childs of childs etc. from given node |
|
156 * |
|
157 * @since 3.1 |
|
158 * @param IN aParent, node whos childs are to be removed |
|
159 */ |
|
160 static void RemoveChilds( CMDXMLNode* aParent ); |
|
161 |
|
162 /** |
|
163 * MediaElemType |
|
164 * Gets the media type of the object (text, img, video etc) |
|
165 * |
|
166 * @since 3.1 |
|
167 * @param IN aNodePtr, media object node |
|
168 * @return mediatype. EMsgMediaUnknown if node is not media object. |
|
169 */ |
|
170 static TMsgMediaType MediaElemType( CMDXMLNode* aNodePtr ); |
|
171 |
|
172 /** |
|
173 * Gets the id value of the node. |
|
174 * |
|
175 * @since 3.1 |
|
176 * @param IN aNodePtr, element |
|
177 * @param OUT aId, id of the element if found, empty otherwise. |
|
178 * @return KErrNone if found. KErrNotFound if element but no id, |
|
179 * KErrNotSupported if not element. |
|
180 */ |
|
181 static TInt GetId( CMDXMLNode* aNodePtr, TPtrC& aId ); |
|
182 |
|
183 /** |
|
184 * Gets the name and content of the metatag i.e. <meta name="x1" content="x2" /> |
|
185 * |
|
186 * @since 3.1 |
|
187 * @param IN aNodePtr, must be element |
|
188 * @param OUT aName, name of the metatag. Value is garbage if function |
|
189 * returns KErrNotFound |
|
190 * @param OUT aContent, content of the metatag. Value is garbage if function |
|
191 * returns KErrNotFound |
|
192 * @return KErrNone if both ok. KErrNotFound otherwise. |
|
193 */ |
|
194 static TInt GetMetaTag( |
|
195 CMDXMLNode* aNodePtr, |
|
196 TPtrC& aName, |
|
197 TPtrC& aContent ); |
|
198 |
|
199 /** |
|
200 * Gets the region id i.e. region="xx" value of the node. |
|
201 * Node must be media element node. |
|
202 * |
|
203 * @since 3.1 |
|
204 * @param IN aNodePtr, media element |
|
205 * @param OUT aId, regoin id of the element if found, empty otherwise. |
|
206 * @return KErrNone if found. KErrNotSupported if not media element, |
|
207 * KErrNotFound if no region specified. |
|
208 */ |
|
209 static TInt GetRegionId( CMDXMLNode* aNodePtr, TPtrC& aId ); |
|
210 |
|
211 /** |
|
212 * Gets the location string from nodes src parameter. |
|
213 * |
|
214 * @since 3.1 |
|
215 * @param aNodePtr, media element |
|
216 * @return value of the location string. |
|
217 */ |
|
218 static TPtrC GetSrcL( CMDXMLNode* aNodePtr ); |
|
219 |
|
220 /** |
|
221 * Gets SMIL type of the document. |
|
222 * Tries to validate document according to conformance document requirements |
|
223 * and SmilEditor template requirements. |
|
224 * |
|
225 * @since 3.1 |
|
226 * @param aDom Root node of the document tree. |
|
227 * @return Smil type of the document. |
|
228 */ |
|
229 static TUniSmilType GetSmilTypeL( CMDXMLDocument* aDom ); |
|
230 |
|
231 /** |
|
232 * Gets SMIL type of the document. |
|
233 * Tries to validate document according to SmilEditor template requirements. |
|
234 * |
|
235 * @since 3.1 |
|
236 * @param aDom Root node of the document tree. |
|
237 * @return ETrue if document is template SMIL. |
|
238 */ |
|
239 static TBool IsTemplateSmil( CMDXMLDocument* aDom ); |
|
240 |
|
241 }; |
|
242 |
|
243 #endif // __UNISMILUTILS_H |
|