|
1 /* |
|
2 * Copyright (c) 2003 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: smilparser declaration |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef SMILPARSER_H |
|
21 #define SMILPARSER_H |
|
22 |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <s32strm.h> |
|
26 #include <gdi.h> |
|
27 |
|
28 class CSmilTimeContainer; |
|
29 class CSmilMedia; |
|
30 class CSmilRegion; |
|
31 class CSmilPresentation; |
|
32 class CSmilAnchor; |
|
33 class CSmilArea; |
|
34 class CSmilTransition; |
|
35 class CSmilObject; |
|
36 class MSmilPlayer; |
|
37 |
|
38 class CMDXMLDocument; |
|
39 |
|
40 template <class T> class CLinkedList; |
|
41 |
|
42 /** |
|
43 * SMIL2 semantical parser class |
|
44 */ |
|
45 |
|
46 class CSmilParser : public CBase |
|
47 { |
|
48 public: |
|
49 /** |
|
50 * Parser phase one constructor |
|
51 * |
|
52 * Takes the player interface object as a parameter. This interface |
|
53 * is used by the parser for reporting parse errors and for getting values |
|
54 * of the content control attributes. It is also passed to the created |
|
55 * presentation object. |
|
56 */ |
|
57 IMPORT_C static CSmilParser* NewL(MSmilPlayer* aPlayer); |
|
58 |
|
59 /** |
|
60 * Destructor. |
|
61 */ |
|
62 virtual ~CSmilParser(); |
|
63 |
|
64 /** |
|
65 * Parses the given SMIL source, constructing the presentation object. |
|
66 * The given base URL is used for resolving the URLs in the presentation. |
|
67 * |
|
68 * Verbose parse error messages are available through the MSmilPlayer interface. |
|
69 */ |
|
70 IMPORT_C CSmilPresentation* ParseL(const TDesC& aSmil, const TDesC& aBaseUrl); |
|
71 |
|
72 /** |
|
73 * Parses the given SMIL document, constructing the presentation object. |
|
74 * The given base URL is used for resolving the URLs in the presentation. |
|
75 */ |
|
76 IMPORT_C CSmilPresentation* ParseL(const CMDXMLDocument* aSmilDoc, const TDesC& aBaseUrl); |
|
77 |
|
78 /** |
|
79 * Parses a CSS2 style color value ("red", "green", "#ffcc44", ...) |
|
80 * The aTransparent flag is set if the parsing fails |
|
81 */ |
|
82 IMPORT_C |
|
83 static TRgb ParseColor( const TDesC& aString, TBool& aTransparent ); |
|
84 |
|
85 /** |
|
86 * Enables the layout scaling. This functionality shrinks the layout |
|
87 * so that it fits the screensize while maintaining the original aspect |
|
88 * ratio. Images and other media is not scaled unless scaling is |
|
89 * is enabled by the fit attribute of the region element of the source |
|
90 * document. |
|
91 */ |
|
92 //inline void SetLayoutScalingEnabled(TBool aScale); |
|
93 IMPORT_C void SetMaxDownUpScaling( TReal32 aDown, TReal32 aUp ); |
|
94 |
|
95 public: |
|
96 |
|
97 void BeginElementL(const TDesC& aName); |
|
98 |
|
99 void EndElementL(const TDesC& aName); |
|
100 |
|
101 void AttributeValueL(const TDesC& aName, const TDesC& aValue); |
|
102 |
|
103 void AttributesEndL(TInt aCount); |
|
104 |
|
105 TBool CheckSystemAttribute(const TDesC& aName, const TDesC& aValue); |
|
106 |
|
107 private: |
|
108 |
|
109 virtual void ConstructL(MSmilPlayer* aPlayer); |
|
110 |
|
111 void Init(); |
|
112 |
|
113 void ParseTimeListL( const TDesC& aString, TBool aBegin ); |
|
114 |
|
115 static TReal32 StringToRealValue( const TDesC& aString, TReal32 aDefault ); |
|
116 static TInt StringToIntValue( const TDesC& aString, TInt aDefault ); |
|
117 |
|
118 enum TParseState |
|
119 { |
|
120 EInitial, ESmil, EHead, ELayout, ELayoutFinished, EHeadFinished, EBody, EBodyFinished, ESmilFinished |
|
121 }; |
|
122 |
|
123 |
|
124 CSmilParser(); |
|
125 |
|
126 CSmilObject* iCurrent; |
|
127 CSmilTimeContainer* iTimeContainer; |
|
128 CSmilRegion* iCurrentRegion; |
|
129 CSmilTransition* iCurrentTransition; |
|
130 CSmilAnchor* iAnchor; |
|
131 CSmilArea* iArea; |
|
132 |
|
133 TParseState iState; |
|
134 |
|
135 MSmilPlayer* iPlayer; |
|
136 CSmilPresentation* iPresentation; |
|
137 |
|
138 TPtrC iTag; |
|
139 |
|
140 struct Switch { TInt depth; TBool done; }; |
|
141 |
|
142 CLinkedList<Switch>* iSwitchStack; |
|
143 |
|
144 TInt iDepth; |
|
145 TInt iIgnoreDepth; |
|
146 TBool iSkipContent; |
|
147 TBool iUnknownElement; |
|
148 |
|
149 struct Namespace { HBufC* name; HBufC* uri;}; |
|
150 |
|
151 CLinkedList<Namespace>* iNamespaces; |
|
152 |
|
153 TPtrC iParamName; |
|
154 TPtrC iParamValue; |
|
155 |
|
156 TBool iScalingEnabled; |
|
157 |
|
158 TInt iTimegraphSize; |
|
159 |
|
160 TReal iDown; |
|
161 TReal iUp; |
|
162 |
|
163 }; |
|
164 |
|
165 |
|
166 #include <smilparser.inl> |
|
167 #include <smilplayerinterface.h> |
|
168 #endif |