83
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2004 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: ODT parser
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include <aisystemuids.hrh>
|
|
18 |
#include <xnextrenderingpluginadapter.h>
|
|
19 |
#include <ecom/ecom.h>
|
|
20 |
#include <ecom/implementationinformation.h>
|
|
21 |
|
|
22 |
#include "xnextrenderingpluginwrapper.h"
|
|
23 |
|
|
24 |
#include "xnodt.h"
|
|
25 |
#include "xndomdocument.h"
|
|
26 |
#include "xndomnode.h"
|
|
27 |
#include "xndomattribute.h"
|
|
28 |
#include "xndomlist.h"
|
|
29 |
#include "xnnode.h"
|
|
30 |
|
|
31 |
#include "xnecomhandler.h"
|
|
32 |
#include "xnuiengine.h"
|
|
33 |
#include "xntype.h"
|
|
34 |
#include "xncontroladapter.h"
|
|
35 |
#include "xnviewcontroladapter.h"
|
|
36 |
#include "xnpopupcontroladapter.h"
|
|
37 |
#include "xnwidgetextensionadapter.h"
|
|
38 |
#include "xnscrollablecontroladapter.h"
|
|
39 |
#include "xnlistquerydialogadapter.h"
|
|
40 |
|
|
41 |
#include "xncomponent.h"
|
|
42 |
#include "xncomponentnodeimpl.h"
|
|
43 |
#include "xnviewnodeimpl.h"
|
|
44 |
#include "xnviewsnodeimpl.h"
|
|
45 |
#include "xnproperty.h"
|
|
46 |
#include "xncomponentfactory.h"
|
|
47 |
#include "xnarray.h"
|
|
48 |
#include "xnviewmanager.h"
|
|
49 |
#include "xnplugindata.h"
|
|
50 |
#include "xnrootdata.h"
|
|
51 |
#include "xnviewdata.h"
|
|
52 |
|
|
53 |
#include "xnodtparser.h"
|
|
54 |
|
|
55 |
_LIT8( KWidgetBgSkinId, "SKIN(268458534 9916)" );
|
|
56 |
|
|
57 |
// CONSTANTS
|
|
58 |
_LIT8( KXMLUIMLNodeName, "xmluiml" );
|
|
59 |
_LIT8( KViewsNodeName, "views" );
|
|
60 |
_LIT8( KViewNodeName, "view" );
|
|
61 |
_LIT8( KBoxNodeName, "box" );
|
|
62 |
_LIT8( KButtonNodeName, "button" );
|
|
63 |
_LIT8( KStylusPopupNodeName, "styluspopup" );
|
|
64 |
_LIT8( KImageNodeName, "image" );
|
|
65 |
_LIT8( KTooltipNodeName, "tooltip" );
|
|
66 |
_LIT8( KMenuBarNodeName, "menubar" );
|
|
67 |
_LIT8( KMenuNodeName, "menu" );
|
|
68 |
_LIT8( KMenuItemNodeName, "menuitem" );
|
|
69 |
_LIT8( KDynMenuItemNodeName, "dynmenuitem" );
|
|
70 |
_LIT8( KWidgetMenuItemNodeName, "widgetmenuitem" );
|
|
71 |
_LIT8( KActionsNodeName, "actions" );
|
|
72 |
_LIT8( KActionNodeName, "action" );
|
|
73 |
_LIT8( KTriggerNodeName, "trigger" );
|
|
74 |
_LIT8( KEventNodeName, "event" );
|
|
75 |
_LIT8( KTextNodeName, "text" );
|
|
76 |
_LIT8( KMarqueeNodeName, "marquee" );
|
|
77 |
_LIT8( KObjectNodeName, "object" );
|
|
78 |
_LIT8( KTracksterNodeName, "trackster" );
|
|
79 |
_LIT8( KPropertyNodeName, "property" );
|
|
80 |
_LIT8( KConfigurationNodeName, "configuration" );
|
|
81 |
_LIT8( KNewstickerNodeName, "newsticker" );
|
|
82 |
_LIT8( KAttributeNodeName, "attribute" );
|
|
83 |
_LIT8( KItemNodeName, "item" );
|
|
84 |
_LIT8( KDescNodeName, "desc" );
|
|
85 |
_LIT8( KTextZoomNodeName, "textzoom" );
|
|
86 |
_LIT8( KVolumeControlNodeName, "volumecontrol" );
|
|
87 |
_LIT8( KPluginNodeName, "plugin" );
|
|
88 |
_LIT8( KWidgetNodeName, "widget" );
|
|
89 |
_LIT8( KSliderNodeName, "slider" );
|
|
90 |
_LIT8( KClockNodeName, "clock" );
|
|
91 |
_LIT8( KSoftkeyNodeName,"softkey" );
|
|
92 |
_LIT8( KConditionalTrigger,"conditional" );
|
|
93 |
_LIT8( KCondtionalOn, "true" );
|
|
94 |
_LIT8( KListQueryDialogNodeName, "listquerydialog" );
|
|
95 |
_LIT8( KSettingsConfigurationNodeName, "settingsconfiguration" );
|
|
96 |
_LIT8( KContentSourceNodeName, "contentsource" );
|
|
97 |
_LIT8( KMenuExtensionNodeName, "menuextension" );
|
|
98 |
_LIT8( KWidgetExtensionNodeName, "widgetextension" );
|
|
99 |
_LIT8( KTextEditorNodeName, "texteditor" );
|
|
100 |
_LIT8( KActionsHandlerNodeName, "actionshandler" );
|
|
101 |
_LIT8( KScrollableBoxNodeName, "scrollablebox" );
|
|
102 |
_LIT8( KPopUpNodeName, "popup" );
|
|
103 |
|
|
104 |
// LOCAL FUNCTION PROTOTYPES
|
|
105 |
#ifdef _XN3_DEBUG_
|
|
106 |
#include <flogger.h>
|
|
107 |
#include <utf.h>
|
|
108 |
static void PrintDomL( CXnDomDocument* aDomDocument );
|
|
109 |
#endif
|
|
110 |
|
|
111 |
static CXnNode* BuildRootNodeL( CXnUiEngine& aEngine );
|
|
112 |
|
|
113 |
static CXnNode* FindAncestorWhoActAsParent( CXnDomNode& aSource );
|
|
114 |
|
|
115 |
static TBool CreateTriggerInLayoutNodeTree( CXnDomNode& aSource );
|
|
116 |
|
|
117 |
static void CopyPropertiesFromDomNodeToNodeL(
|
|
118 |
CXnNode& aTarget,
|
|
119 |
CXnDomNode& aSource,
|
|
120 |
CXnDomStringPool& aStringPool );
|
|
121 |
static CXnNode* ConstructNodeFromPluginL(
|
|
122 |
CXnEcomHandler& aEcomHandler,
|
|
123 |
CXnDomNode& aSource );
|
|
124 |
static CXnNode* ConstructKnownBuiltinNodeL( CXnDomNode& aSource );
|
|
125 |
static CXnNode* ConstructGeneralNodeL( CXnDomNode& aSource );
|
|
126 |
|
|
127 |
// ============================= LOCAL FUNCTIONS ===============================
|
|
128 |
|
|
129 |
|
|
130 |
// ----------------------------------------------------------------------------
|
|
131 |
// CleanupResetAndDestroy()
|
|
132 |
// ----------------------------------------------------------------------------
|
|
133 |
//
|
|
134 |
template<class T>
|
|
135 |
static void CleanupResetAndDestroy( TAny* aObj )
|
|
136 |
{
|
|
137 |
if( aObj )
|
|
138 |
{
|
|
139 |
static_cast<T*>( aObj )->ResetAndDestroy();
|
|
140 |
}
|
|
141 |
}
|
|
142 |
|
|
143 |
// ----------------------------------------------------------------------------
|
|
144 |
// CleanupResetAndDestroyPushL
|
|
145 |
// ----------------------------------------------------------------------------
|
|
146 |
//
|
|
147 |
template<class T>
|
|
148 |
static void CleanupResetAndDestroyPushL(T& aArray)
|
|
149 |
{
|
|
150 |
CleanupStack::PushL( TCleanupItem( &CleanupResetAndDestroy<T>, &aArray ) );
|
|
151 |
}
|
|
152 |
|
|
153 |
#ifdef _XN3_DEBUG_
|
|
154 |
_LIT( KLogFolder," xnlayoutengine" );
|
|
155 |
_LIT( KLogDom, "dom.log" );
|
|
156 |
#define _LOGT( aDescription ) RFileLogger::Write( \
|
|
157 |
KLogFolder, KLogDom, EFileLoggingModeOverwrite, aDescription );
|
|
158 |
#define _LOGTFRM1( a, b ) RFileLogger::WriteFormat( \
|
|
159 |
KLogFolder, KLogDom, EFileLoggingModeOverwrite, ( a ), ( b ) )
|
|
160 |
#define _LOGTFRM2( a, b, c ) RFileLogger::WriteFormat( \
|
|
161 |
KLogFolder, KLogDom, EFileLoggingModeOverwrite, ( a ), ( b ), ( c ) );
|
|
162 |
#define _LOGTFRM3( a, b, c, d ) RFileLogger::WriteFormat( \
|
|
163 |
KLogFolder, KLogDom, EFileLoggingModeOverwrite, ( a ), ( b ), ( c ), ( d ) );
|
|
164 |
static const TInt GetNodeDepth( CXnDomNode *aNode )
|
|
165 |
{
|
|
166 |
TInt depth = 0;
|
|
167 |
CXnDomNode* node( aNode );
|
|
168 |
while ( node )
|
|
169 |
{
|
|
170 |
node = node->Parent();
|
|
171 |
if ( node )
|
|
172 |
{
|
|
173 |
depth++;
|
|
174 |
}
|
|
175 |
}
|
|
176 |
return depth;
|
|
177 |
}
|
|
178 |
|
|
179 |
//-----------------------------------------------------------------------------
|
|
180 |
// ----------------------------------------------------------------------------
|
|
181 |
//
|
|
182 |
static HBufC8* GetFixedTextLC(
|
|
183 |
const TDesC8& aText,
|
|
184 |
const TInt aDepth,
|
|
185 |
const TDesC8& aDelim )
|
|
186 |
{
|
|
187 |
HBufC8 *buf = HBufC8::NewL( aDepth * aDelim.Length() + aText.Length() + 1 );
|
|
188 |
TInt i = 0;
|
|
189 |
for ( ; i < aDepth; i++ )
|
|
190 |
{
|
|
191 |
buf->Des().Append( aDelim );
|
|
192 |
}
|
|
193 |
buf->Des().Append( aText );
|
|
194 |
return buf;
|
|
195 |
}
|
|
196 |
|
|
197 |
//-----------------------------------------------------------------------------
|
|
198 |
// ----------------------------------------------------------------------------
|
|
199 |
//
|
|
200 |
static void PrintDomL( CXnDomDocument* aDomDocument )
|
|
201 |
{
|
|
202 |
__UHEAP_MARK;
|
|
203 |
TInt attrCount( 0 );
|
|
204 |
TInt propCount( 0 );
|
|
205 |
|
|
206 |
CXnDomDepthIterator* iter =
|
|
207 |
CXnDomDepthIterator::NewL( *aDomDocument->RootNode() );
|
|
208 |
CleanupStack::PushL( iter );
|
|
209 |
|
|
210 |
_LIT8( KDelim, "\t" );
|
|
211 |
CXnDomNode* nodeParent( NULL );
|
|
212 |
CXnDomNode* node = iter->First();
|
|
213 |
while ( node )
|
|
214 |
{
|
|
215 |
const TInt depth = GetNodeDepth( node );
|
|
216 |
|
|
217 |
HBufC8 *nameBuf = GetFixedTextLC( node->Name(), depth, KDelim );
|
|
218 |
CleanupStack::PushL( nameBuf );
|
|
219 |
const TDesC8& name = nameBuf->Des();
|
|
220 |
|
|
221 |
HBufC8 *nsBuf = GetFixedTextLC( node->Namespace(), depth, KDelim );
|
|
222 |
CleanupStack::PushL( nsBuf );
|
|
223 |
const TDesC8& ns = nsBuf->Des();
|
|
224 |
|
|
225 |
_LOGTFRM2( _L8( "%S -------------------------- %S\n" ), &name, &ns );
|
|
226 |
|
|
227 |
CXnDomList& attrList = node->AttributeList();
|
|
228 |
TInt length( attrList.Length() );
|
|
229 |
attrCount += length;
|
|
230 |
|
|
231 |
for ( TInt i = 0; i < length; i++ )
|
|
232 |
{
|
|
233 |
CXnDomAttribute* attr = static_cast< CXnDomAttribute* >(
|
|
234 |
attrList.Item( i ) );
|
|
235 |
|
|
236 |
HBufC8 *attrBuf = GetFixedTextLC( attr->Name(), depth, KDelim );
|
|
237 |
CleanupStack::PushL( attrBuf );
|
|
238 |
const TDesC8& attrName = attrBuf->Des();
|
|
239 |
|
|
240 |
const TDesC8& attrValue = attr->Value();
|
|
241 |
|
|
242 |
_LOGTFRM2( _L8( "%S=%S\n" ), &attrName, &attrValue );
|
|
243 |
|
|
244 |
CleanupStack::PopAndDestroy( attrBuf );
|
|
245 |
}
|
|
246 |
|
|
247 |
if ( node->Parent() )
|
|
248 |
{
|
|
249 |
nodeParent = node;
|
|
250 |
}
|
|
251 |
node = iter->NextL();
|
|
252 |
|
|
253 |
CleanupStack::PopAndDestroy( nsBuf );
|
|
254 |
CleanupStack::PopAndDestroy( nameBuf );
|
|
255 |
}
|
|
256 |
CleanupStack::PopAndDestroy( iter );
|
|
257 |
|
|
258 |
_LOGTFRM1( _L8( "****DOM Size: %d ****\n" ), aDomDocument->Size() );
|
|
259 |
_LOGTFRM1( _L8( "****DOM Node Count: %d ****\n" ), aDomDocument->DomNodeCount() );
|
|
260 |
_LOGTFRM1( _L8( "****DOM Attribute Count: %d ****\n" ), attrCount );
|
|
261 |
__UHEAP_MARKEND;
|
|
262 |
}
|
|
263 |
|
|
264 |
#endif
|
|
265 |
// -----------------------------------------------------------------------------
|
|
266 |
// BuildRootNodeL()
|
|
267 |
// Builds root node
|
|
268 |
// -----------------------------------------------------------------------------
|
|
269 |
//
|
|
270 |
static CXnNode* BuildRootNodeL( CXnUiEngine& aEngine )
|
|
271 |
{
|
|
272 |
CXnType* type = CXnType::NewL( KXMLUIMLNodeName );
|
|
273 |
CleanupStack::PushL( type );
|
|
274 |
|
|
275 |
CXnNodeImpl* impl = CXnNodeImpl::NewL( type );
|
|
276 |
|
|
277 |
CleanupStack::Pop( type );
|
|
278 |
CleanupStack::PushL( impl );
|
|
279 |
|
|
280 |
CXnNode* node = CXnNode::NewL();
|
|
281 |
node->SetRootNodeImpl( impl );
|
|
282 |
CleanupStack::Pop( impl );
|
|
283 |
|
|
284 |
node->SetUiEngine( aEngine );
|
|
285 |
|
|
286 |
return node;
|
|
287 |
}
|
|
288 |
|
|
289 |
// -----------------------------------------------------------------------------
|
|
290 |
// -----------------------------------------------------------------------------
|
|
291 |
//
|
|
292 |
CXnNode* FindAncestorWhoActAsParent( CXnDomNode& aSource )
|
|
293 |
{
|
|
294 |
CXnNode* ret( NULL );
|
|
295 |
CXnDomNode* parent = aSource.Parent();
|
|
296 |
|
|
297 |
while ( !ret && parent )
|
|
298 |
{
|
|
299 |
ret = parent->LayoutNode();
|
|
300 |
parent = parent->Parent();
|
|
301 |
}
|
|
302 |
return ret;
|
|
303 |
}
|
|
304 |
|
|
305 |
// -----------------------------------------------------------------------------
|
|
306 |
// -----------------------------------------------------------------------------
|
|
307 |
//
|
|
308 |
TBool CreateTriggerInLayoutNodeTree( CXnDomNode& aSource )
|
|
309 |
{
|
|
310 |
TBool ret( EFalse );
|
|
311 |
|
|
312 |
CXnDomAttribute* attribute = static_cast< CXnDomAttribute* >(
|
|
313 |
aSource.AttributeList().FindByName( KConditionalTrigger ) );
|
|
314 |
|
|
315 |
if ( attribute && attribute->Value() == KCondtionalOn )
|
|
316 |
{
|
|
317 |
ret = ETrue;
|
|
318 |
}
|
|
319 |
return ret;
|
|
320 |
}
|
|
321 |
|
|
322 |
// -----------------------------------------------------------------------------
|
|
323 |
// CopyDomPropertiesFromDomNodeToNodeL
|
|
324 |
// -----------------------------------------------------------------------------
|
|
325 |
//
|
|
326 |
static void CopyDomPropertiesFromDomNodeToNodeL(
|
|
327 |
CXnNode& aTarget,
|
|
328 |
CXnDomNode& aSource )
|
|
329 |
{
|
|
330 |
CXnDomList& propertyList = aSource.PropertyList();
|
|
331 |
for ( TInt count = propertyList.Length() - 1; count >= 0; --count )
|
|
332 |
{
|
|
333 |
CXnDomProperty* domProperty = static_cast< CXnDomProperty* >(
|
|
334 |
propertyList.Item( count ) );
|
|
335 |
CXnProperty* property = CXnProperty::NewSharedL( domProperty );
|
|
336 |
CleanupStack::PushL( property );
|
|
337 |
aTarget.InitializePropertyL( property );
|
|
338 |
CleanupStack::Pop( property );
|
|
339 |
}
|
|
340 |
}
|
|
341 |
|
|
342 |
// -----------------------------------------------------------------------------
|
|
343 |
// CopyDomAtributesFromDomNodeToNodeL
|
|
344 |
// -----------------------------------------------------------------------------
|
|
345 |
//
|
|
346 |
static void CopyDomAttributesFromDomNodeToNodeL(
|
|
347 |
CXnNode& aTarget,
|
|
348 |
CXnDomNode& aSource,
|
|
349 |
CXnDomStringPool& aStringPool )
|
|
350 |
{
|
|
351 |
CXnDomList& attributeList = aSource.AttributeList();
|
|
352 |
for ( TInt count = attributeList.Length() - 1; count >= 0; --count )
|
|
353 |
{
|
|
354 |
CXnDomAttribute* attribute = static_cast< CXnDomAttribute* >(
|
|
355 |
attributeList.Item( count ) );
|
|
356 |
#ifdef _DEBUG
|
|
357 |
const TDesC8& name = attribute->Name();
|
|
358 |
const TDesC8& attrValue = attribute->Value();
|
|
359 |
#endif
|
|
360 |
if ( attribute->ValueStringPoolIndex() == KErrNotFound )
|
|
361 |
{
|
|
362 |
continue;
|
|
363 |
}
|
|
364 |
|
|
365 |
if ( attribute->NameStringPoolIndex() == KErrNotFound )
|
|
366 |
{
|
|
367 |
continue;
|
|
368 |
}
|
|
369 |
CXnDomProperty* clone =
|
|
370 |
CXnDomProperty::NewL( attribute->NameStringPoolIndex(), &aStringPool );
|
|
371 |
CleanupStack::PushL( clone );
|
|
372 |
CXnDomPropertyValue* propertyValue =
|
|
373 |
CXnDomPropertyValue::NewL( &aStringPool );
|
|
374 |
CleanupStack::PushL( propertyValue );
|
|
375 |
propertyValue->SetStringPoolIndexL(
|
|
376 |
CXnDomPropertyValue::EString, attribute->ValueStringPoolIndex() );
|
|
377 |
CXnDomList& propertyList = clone->PropertyValueList();
|
|
378 |
propertyList.AddItemL( propertyValue );
|
|
379 |
CleanupStack::Pop( propertyValue );
|
|
380 |
CXnProperty* property = CXnProperty::NewL( clone );
|
|
381 |
CleanupStack::Pop( clone );
|
|
382 |
CleanupStack::PushL( property );
|
|
383 |
aTarget.InitializePropertyL( property );
|
|
384 |
CleanupStack::Pop( property );
|
|
385 |
}
|
|
386 |
|
|
387 |
//aSource.DeleteAttributeList();
|
|
388 |
// delete attributes from dom node tree
|
|
389 |
if ( aSource.Name() != KTriggerNodeName )
|
|
390 |
{
|
|
391 |
CXnDomList& attrList = aSource.AttributeList();
|
|
392 |
while ( attrList.Length() )
|
|
393 |
{
|
|
394 |
attrList.DeleteItem( attrList.Length() - 1 );
|
|
395 |
}
|
|
396 |
}
|
|
397 |
}
|
|
398 |
|
|
399 |
// -----------------------------------------------------------------------------
|
|
400 |
// CopyPropertiesFromDomNodeToNodeL
|
|
401 |
// -----------------------------------------------------------------------------
|
|
402 |
//
|
|
403 |
static void CopyPropertiesFromDomNodeToNodeL(
|
|
404 |
CXnNode& aTarget,
|
|
405 |
CXnDomNode& aSource,
|
|
406 |
CXnDomStringPool& aStringPool )
|
|
407 |
{
|
|
408 |
CopyDomPropertiesFromDomNodeToNodeL( aTarget, aSource );
|
|
409 |
CopyDomAttributesFromDomNodeToNodeL( aTarget, aSource, aStringPool );
|
|
410 |
}
|
|
411 |
|
|
412 |
// -----------------------------------------------------------------------------
|
|
413 |
// ConstructNodeFromPluginL
|
|
414 |
// -----------------------------------------------------------------------------
|
|
415 |
//
|
|
416 |
static CXnNode* ConstructNodeFromPluginL(
|
|
417 |
CXnEcomHandler& aEcomHandler,
|
|
418 |
CXnDomNode& aSource )
|
|
419 |
{
|
|
420 |
CXnNode* returnValue = NULL;
|
|
421 |
const TDesC8& name = aSource.Name();
|
|
422 |
|
|
423 |
CXnArray* componentFactories = CXnArray::NewL();
|
|
424 |
CleanupStack::PushL( componentFactories );
|
|
425 |
|
|
426 |
TUid interfaceUid = { AI3_RENDERING_PLUGIN_ECOM_FACTORY_UID };
|
|
427 |
aEcomHandler.PluginsL( interfaceUid, name, *componentFactories );
|
|
428 |
TInt count = componentFactories->Container().Count();
|
|
429 |
TBool componentNodeImplNeeded = ETrue;
|
|
430 |
// invoke factory chain
|
|
431 |
for ( TInt i = 0; i < count; ++i )
|
|
432 |
{
|
|
433 |
MXnComponentFactory* factory = static_cast< MXnComponentFactory* >(
|
|
434 |
componentFactories->Container()[i] );
|
|
435 |
componentNodeImplNeeded = factory->DoesNodeNeedComponentImplL( name );
|
|
436 |
}
|
|
437 |
CleanupStack::PopAndDestroy( componentFactories );
|
|
438 |
if ( componentNodeImplNeeded )
|
|
439 |
{
|
|
440 |
CXnType* type = CXnType::NewL( name );
|
|
441 |
CleanupStack::PushL( type );
|
|
442 |
CXnComponentNodeImpl* impl = CXnComponentNodeImpl::NewL( type );
|
|
443 |
CleanupStack::Pop( type );
|
|
444 |
CleanupStack::PushL( impl );
|
|
445 |
returnValue = CXnNode::NewL();
|
|
446 |
returnValue->SetComponentNodeImpl( impl );
|
|
447 |
CleanupStack::Pop( impl );
|
|
448 |
}
|
|
449 |
else
|
|
450 |
{
|
|
451 |
if ( name == KActionsNodeName ||
|
|
452 |
name == KActionNodeName ||
|
|
453 |
name == KEventNodeName ||
|
|
454 |
name == KTriggerNodeName ||
|
|
455 |
name == KMenuNodeName ||
|
|
456 |
name == KMenuItemNodeName ||
|
|
457 |
name == KPropertyNodeName ||
|
|
458 |
name == KSoftkeyNodeName )
|
|
459 |
{
|
|
460 |
return ConstructGeneralNodeL( aSource );
|
|
461 |
}
|
|
462 |
}
|
|
463 |
return returnValue;
|
|
464 |
}
|
|
465 |
|
|
466 |
// -----------------------------------------------------------------------------
|
|
467 |
// ConstructKnownBuiltinNodeL
|
|
468 |
// -----------------------------------------------------------------------------
|
|
469 |
//
|
|
470 |
static CXnNode* ConstructKnownBuiltinNodeL( CXnDomNode& aSource )
|
|
471 |
{
|
|
472 |
CXnNode* returnValue = NULL;
|
|
473 |
const TDesC8& name = aSource.Name();
|
|
474 |
if ( name == KMenuNodeName ||
|
|
475 |
name == KMenuItemNodeName ||
|
|
476 |
name == KPropertyNodeName ||
|
|
477 |
name == KSoftkeyNodeName ||
|
|
478 |
name == KTriggerNodeName )
|
|
479 |
{
|
|
480 |
return ConstructGeneralNodeL( aSource );
|
|
481 |
}
|
|
482 |
CXnType* type = CXnType::NewL( name );
|
|
483 |
CleanupStack::PushL( type );
|
|
484 |
if ( name == KViewsNodeName )
|
|
485 |
{
|
|
486 |
CXnViewsNodeImpl* impl = CXnViewsNodeImpl::NewL( type );
|
|
487 |
CleanupStack::Pop( type );
|
|
488 |
CleanupStack::PushL( impl );
|
|
489 |
returnValue = CXnNode::NewL();
|
|
490 |
returnValue->SetViewsNodeImpl( impl );
|
|
491 |
CleanupStack::Pop( impl );
|
|
492 |
}
|
|
493 |
else if ( name == KViewNodeName )
|
|
494 |
{
|
|
495 |
CXnViewNodeImpl* impl = CXnViewNodeImpl::NewL( type );
|
|
496 |
CleanupStack::Pop( type );
|
|
497 |
CleanupStack::PushL( impl );
|
|
498 |
returnValue = CXnNode::NewL();
|
|
499 |
returnValue->SetViewNodeImpl( impl );
|
|
500 |
CleanupStack::Pop( impl );
|
|
501 |
}
|
|
502 |
else if ( name == KBoxNodeName ||
|
|
503 |
name == KButtonNodeName ||
|
|
504 |
name == KImageNodeName ||
|
|
505 |
name == KMenuBarNodeName ||
|
|
506 |
name == KTooltipNodeName ||
|
|
507 |
name == KMarqueeNodeName ||
|
|
508 |
name == KTextNodeName ||
|
|
509 |
name == KObjectNodeName ||
|
|
510 |
name == KTracksterNodeName ||
|
|
511 |
name == KNewstickerNodeName ||
|
|
512 |
name == KSliderNodeName ||
|
|
513 |
name == KClockNodeName ||
|
|
514 |
name == KStylusPopupNodeName ||
|
|
515 |
name == KPopUpNodeName ||
|
|
516 |
name == KWidgetExtensionNodeName ||
|
|
517 |
name == KTextEditorNodeName )
|
|
518 |
{
|
|
519 |
CXnComponentNodeImpl* impl = CXnComponentNodeImpl::NewL( type );
|
|
520 |
CleanupStack::Pop( type ) ;
|
|
521 |
CleanupStack::PushL( impl );
|
|
522 |
returnValue = CXnNode::NewL();
|
|
523 |
returnValue->SetComponentNodeImpl( impl );
|
|
524 |
CleanupStack::Pop( impl );
|
|
525 |
}
|
|
526 |
else
|
|
527 |
{
|
|
528 |
CleanupStack::PopAndDestroy( type );
|
|
529 |
|
|
530 |
if ( name == KVolumeControlNodeName ||
|
|
531 |
name == KWidgetNodeName ||
|
|
532 |
name == KPluginNodeName )
|
|
533 |
{
|
|
534 |
CXnType* type = CXnType::NewL( KBoxNodeName );
|
|
535 |
CleanupStack::PushL( type );
|
|
536 |
CXnComponentNodeImpl* impl = CXnComponentNodeImpl::NewL( type );
|
|
537 |
CleanupStack::Pop( type );
|
|
538 |
CleanupStack::PushL( impl );
|
|
539 |
returnValue = CXnNode::NewL();
|
|
540 |
returnValue->SetComponentNodeImpl( impl );
|
|
541 |
CleanupStack::Pop( impl );
|
|
542 |
}
|
|
543 |
}
|
|
544 |
return returnValue;
|
|
545 |
}
|
|
546 |
|
|
547 |
// -----------------------------------------------------------------------------
|
|
548 |
// ConstructGeneralNodeL
|
|
549 |
// -----------------------------------------------------------------------------
|
|
550 |
//
|
|
551 |
static CXnNode* ConstructGeneralNodeL( CXnDomNode& aSource )
|
|
552 |
{
|
|
553 |
CXnType* type = CXnType::NewL( aSource.Name() );
|
|
554 |
CleanupStack::PushL( type );
|
|
555 |
CXnNodeImpl* impl = CXnNodeImpl::NewL( type );
|
|
556 |
CleanupStack::Pop( type );
|
|
557 |
CleanupStack::PushL( impl );
|
|
558 |
CXnNode* tmpNode = CXnNode::NewL();
|
|
559 |
tmpNode->SetImpl( impl );
|
|
560 |
CleanupStack::Pop( impl );
|
|
561 |
return tmpNode;
|
|
562 |
}
|
|
563 |
|
|
564 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
565 |
|
|
566 |
// -----------------------------------------------------------------------------
|
|
567 |
// CXnODTParser::NewL
|
|
568 |
// Two-phased constructor.
|
|
569 |
// -----------------------------------------------------------------------------
|
|
570 |
//
|
|
571 |
CXnODTParser* CXnODTParser::NewL( CXnViewManager& aManager,
|
|
572 |
CXnEcomHandler& aEcomHandler )
|
|
573 |
{
|
|
574 |
CXnODTParser* self = new ( ELeave ) CXnODTParser( aManager, aEcomHandler );
|
|
575 |
|
|
576 |
CleanupStack::PushL( self );
|
|
577 |
self->ConstructL();
|
|
578 |
CleanupStack::Pop( self );
|
|
579 |
|
|
580 |
return self;
|
|
581 |
}
|
|
582 |
|
|
583 |
// -----------------------------------------------------------------------------
|
|
584 |
// CXnODTParser::CXnODTParser
|
|
585 |
// C++ default constructor can NOT contain any code, that
|
|
586 |
// might leave.
|
|
587 |
// -----------------------------------------------------------------------------
|
|
588 |
//
|
|
589 |
CXnODTParser::CXnODTParser( CXnViewManager& aManager,
|
|
590 |
CXnEcomHandler& aEcomHandler )
|
|
591 |
: iManager( aManager ), iUiEngine( aManager.UiEngine() ),
|
|
592 |
iEcomHandler( aEcomHandler )
|
|
593 |
{
|
|
594 |
}
|
|
595 |
|
|
596 |
// -----------------------------------------------------------------------------
|
|
597 |
// CXnODTParser::~CXnODTParser
|
|
598 |
// Destructor.
|
|
599 |
// -----------------------------------------------------------------------------
|
|
600 |
//
|
|
601 |
CXnODTParser::~CXnODTParser()
|
|
602 |
{
|
|
603 |
}
|
|
604 |
|
|
605 |
// -----------------------------------------------------------------------------
|
|
606 |
// CXnODTParser::ConstructL
|
|
607 |
// Symbian 2nd phase constructor can leave.
|
|
608 |
// -----------------------------------------------------------------------------
|
|
609 |
//
|
|
610 |
void CXnODTParser::ConstructL()
|
|
611 |
{
|
|
612 |
}
|
|
613 |
|
|
614 |
// -----------------------------------------------------------------------------
|
|
615 |
// CXnODTParser::LoadRootL
|
|
616 |
// -----------------------------------------------------------------------------
|
|
617 |
//
|
|
618 |
void CXnODTParser::LoadRootL( CXnRootData& aRootData, TUid /*aAppUid*/ )
|
|
619 |
{
|
|
620 |
CXnDomNode* root( aRootData.Owner() );
|
|
621 |
|
|
622 |
CXnDomStringPool* sp( root->StringPool() );
|
|
623 |
|
|
624 |
CXnAppUiAdapter& appui( iManager.AppUiAdapter() );
|
|
625 |
|
|
626 |
// Build root
|
|
627 |
CXnNode* node( BuildRootNodeL( iUiEngine ) );
|
|
628 |
|
|
629 |
// Let root nodes to know each other
|
|
630 |
CXnDomNode* dom( aRootData.ODT()->DomDocument().RootNode() );
|
|
631 |
dom->SetLayoutNode( node );
|
|
632 |
node->SetDomNode( dom );
|
|
633 |
|
|
634 |
CreateNodesL( root, *sp, aRootData );
|
|
635 |
|
|
636 |
// root doesn't have any controls
|
|
637 |
|
|
638 |
aRootData.SetOccupied();
|
|
639 |
}
|
|
640 |
|
|
641 |
// -----------------------------------------------------------------------------
|
|
642 |
// CXnODTParser::LoadViewL
|
|
643 |
// -----------------------------------------------------------------------------
|
|
644 |
//
|
|
645 |
void CXnODTParser::LoadViewL( CXnViewData& aViewData )
|
|
646 |
{
|
|
647 |
// <view> element
|
|
648 |
CXnDomNode* view( aViewData.Node() );
|
|
649 |
|
|
650 |
CXnDomStringPool* sp( view->StringPool() );
|
|
651 |
|
|
652 |
// from <view> element
|
|
653 |
CreateNodesL( view, *sp, aViewData );
|
|
654 |
CreateControlsL( view, aViewData );
|
|
655 |
|
|
656 |
// By default make controls invisible
|
|
657 |
CXnControlAdapter* adapter( view->LayoutNode()->Control() );
|
|
658 |
|
|
659 |
if( adapter )
|
|
660 |
{
|
|
661 |
adapter->MakeVisible( EFalse );
|
|
662 |
}
|
|
663 |
|
|
664 |
aViewData.SetOccupied();
|
|
665 |
}
|
|
666 |
|
|
667 |
// -----------------------------------------------------------------------------
|
|
668 |
// CXnODTParser::DestroyView
|
|
669 |
// -----------------------------------------------------------------------------
|
|
670 |
//
|
|
671 |
void CXnODTParser::DestroyView( CXnViewData& aViewData )
|
|
672 |
{
|
|
673 |
CXnNode* view( aViewData.Node()->LayoutNode() );
|
|
674 |
|
|
675 |
// Destroy view and all its child nodes
|
|
676 |
CXnNode* parent( view->Parent() );
|
|
677 |
|
|
678 |
RPointerArray< CXnNode >& children( parent->Children() );
|
|
679 |
|
|
680 |
TInt index( children.Find( view ) );
|
|
681 |
|
|
682 |
if ( index != KErrNotFound )
|
|
683 |
{
|
|
684 |
children.Remove( index );
|
|
685 |
|
|
686 |
delete view;
|
|
687 |
view = NULL;
|
|
688 |
|
|
689 |
CXnDomNode* owner( aViewData.Owner() );
|
|
690 |
owner->DeleteChild( aViewData.Node() );
|
|
691 |
}
|
|
692 |
}
|
|
693 |
|
|
694 |
// -----------------------------------------------------------------------------
|
|
695 |
// CXnODTParser::LoadWidgetL
|
|
696 |
// -----------------------------------------------------------------------------
|
|
697 |
//
|
|
698 |
void CXnODTParser::LoadWidgetL( CXnPluginData& aPluginData )
|
|
699 |
{
|
|
700 |
if ( aPluginData.Empty() )
|
|
701 |
{
|
|
702 |
// Holds "empty" widget
|
|
703 |
return;
|
|
704 |
}
|
|
705 |
|
|
706 |
// <widget> element
|
|
707 |
CXnDomNode* widget( aPluginData.Node() );
|
|
708 |
|
|
709 |
CXnDomStringPool* sp( widget->StringPool() );
|
|
710 |
|
|
711 |
// from <widget> element
|
|
712 |
CreateNodesL( widget, *sp, aPluginData );
|
|
713 |
CreateControlsL( widget, aPluginData );
|
|
714 |
|
|
715 |
HandleWidgetBackgroundL( widget->LayoutNode() );
|
|
716 |
|
|
717 |
// By default make controls invisible
|
|
718 |
CXnControlAdapter* adapter( widget->LayoutNode()->Control() );
|
|
719 |
|
|
720 |
if( adapter )
|
|
721 |
{
|
|
722 |
adapter->MakeVisible( EFalse );
|
|
723 |
}
|
|
724 |
|
|
725 |
aPluginData.SetOccupied();
|
|
726 |
}
|
|
727 |
|
|
728 |
// -----------------------------------------------------------------------------
|
|
729 |
// CXnODTParser::DestroyWidget
|
|
730 |
// -----------------------------------------------------------------------------
|
|
731 |
//
|
|
732 |
void CXnODTParser::DestroyWidgetL( CXnPluginData& aPluginData )
|
|
733 |
{
|
|
734 |
CXnViewData& parent(
|
|
735 |
static_cast< CXnViewData& >( *aPluginData.Parent() ) );
|
|
736 |
|
|
737 |
// Check is any of plugin data's controls in views draw chain and remove
|
|
738 |
CXnControlAdapter* control( parent.Node()->LayoutNode()->Control() );
|
|
739 |
|
|
740 |
RPointerArray< CXnControlAdapter >& controls( control->ChildAdapters() );
|
|
741 |
|
|
742 |
RPointerArray< CXnControlAdapter > pluginControls;
|
|
743 |
CleanupClosePushL( pluginControls );
|
|
744 |
|
|
745 |
aPluginData.ControlsL( pluginControls );
|
|
746 |
|
|
747 |
// Remove from view chain if found
|
|
748 |
for ( TInt i = 0; i < pluginControls.Count(); i++ )
|
|
749 |
{
|
|
750 |
CXnControlAdapter* control( pluginControls[i] );
|
|
751 |
|
|
752 |
TInt index( controls.Find( control ) );
|
|
753 |
|
|
754 |
if ( index != KErrNotFound )
|
|
755 |
{
|
|
756 |
controls.Remove( index );
|
|
757 |
}
|
|
758 |
}
|
|
759 |
|
|
760 |
CleanupStack::PopAndDestroy( &pluginControls );
|
|
761 |
|
|
762 |
CXnNode* widgetNode( aPluginData.Node()->LayoutNode() );
|
|
763 |
|
|
764 |
CXnNode* owner( widgetNode->Parent() );
|
|
765 |
|
|
766 |
CXnControlAdapter* widgetControl( widgetNode->Control() );
|
|
767 |
|
|
768 |
RPointerArray< CXnControlAdapter >&
|
|
769 |
childAdapters( owner->Control()->ChildAdapters() );
|
|
770 |
|
|
771 |
childAdapters.Remove( childAdapters.Find( widgetControl ) );
|
|
772 |
|
|
773 |
childAdapters.Compress();
|
|
774 |
|
|
775 |
RPointerArray< CXnNode >& children( owner->Children() );
|
|
776 |
|
|
777 |
TInt index( children.Find( widgetNode ) );
|
|
778 |
|
|
779 |
// Destroy widget and all its child nodes
|
|
780 |
if ( index != KErrNotFound )
|
|
781 |
{
|
|
782 |
children.Remove( index );
|
|
783 |
|
|
784 |
delete widgetNode;
|
|
785 |
widgetNode = NULL;
|
|
786 |
|
|
787 |
CXnDomNode* owner( aPluginData.Owner() );
|
|
788 |
owner->DeleteChild( aPluginData.Node() );
|
|
789 |
}
|
|
790 |
}
|
|
791 |
|
|
792 |
// -----------------------------------------------------------------------------
|
|
793 |
// CXnODTParser::CreateNodesL
|
|
794 |
// Creates node tree
|
|
795 |
// -----------------------------------------------------------------------------
|
|
796 |
//
|
|
797 |
void CXnODTParser::CreateNodesL(
|
|
798 |
CXnDomNode* aSourceNode,
|
|
799 |
CXnDomStringPool& aSp,
|
|
800 |
CXnPluginData& aPluginData )
|
|
801 |
{
|
|
802 |
if ( aSourceNode )
|
|
803 |
{
|
|
804 |
ConstructNodeL( *aSourceNode, aSp, aPluginData );
|
|
805 |
|
|
806 |
CXnDomList& childList( aSourceNode->ChildNodes() );
|
|
807 |
|
|
808 |
TInt count( childList.Length() );
|
|
809 |
|
|
810 |
for ( TInt i = 0; i < count; ++i )
|
|
811 |
{
|
|
812 |
CreateNodesL(
|
|
813 |
static_cast< CXnDomNode* >( childList.Item( i ) ),
|
|
814 |
aSp, aPluginData );
|
|
815 |
}
|
|
816 |
}
|
|
817 |
}
|
|
818 |
|
|
819 |
// -----------------------------------------------------------------------------
|
|
820 |
// CXnODTParser::ConstructNodeL
|
|
821 |
// Creates layout node and control for it
|
|
822 |
// -----------------------------------------------------------------------------
|
|
823 |
//
|
|
824 |
void CXnODTParser::ConstructNodeL(
|
|
825 |
CXnDomNode& aSource,
|
|
826 |
CXnDomStringPool& aSp,
|
|
827 |
CXnPluginData& aPluginData )
|
|
828 |
{
|
|
829 |
const TDesC8& name( aSource.Name() );
|
|
830 |
|
|
831 |
if ( name == KActionsNodeName ||
|
|
832 |
name == KActionNodeName ||
|
|
833 |
name == KEventNodeName ||
|
|
834 |
name == KXMLUIMLNodeName ||
|
|
835 |
name == KAttributeNodeName ||
|
|
836 |
name == KItemNodeName )
|
|
837 |
{
|
|
838 |
return;
|
|
839 |
}
|
|
840 |
|
|
841 |
if ( name == KTriggerNodeName )
|
|
842 |
{
|
|
843 |
if ( !CreateTriggerInLayoutNodeTree( aSource ) )
|
|
844 |
{
|
|
845 |
return;
|
|
846 |
}
|
|
847 |
}
|
|
848 |
|
|
849 |
const TDesC8& parentName( aSource.Parent()->Name() );
|
|
850 |
|
|
851 |
if ( name == KPropertyNodeName &&
|
|
852 |
( parentName == KTriggerNodeName ||
|
|
853 |
parentName == KEventNodeName ||
|
|
854 |
parentName == KPropertyNodeName ||
|
|
855 |
parentName == KAttributeNodeName ) )
|
|
856 |
{
|
|
857 |
return;
|
|
858 |
}
|
|
859 |
|
|
860 |
CXnNode* node( ConstructKnownBuiltinNodeL( aSource ) );
|
|
861 |
|
|
862 |
if ( !node )
|
|
863 |
{
|
|
864 |
node = ConstructNodeFromPluginL( iEcomHandler, aSource );
|
|
865 |
|
|
866 |
if ( !node )
|
|
867 |
{
|
|
868 |
node = ConstructGeneralNodeL( aSource );
|
|
869 |
|
|
870 |
if ( !node )
|
|
871 |
{
|
|
872 |
return;
|
|
873 |
}
|
|
874 |
}
|
|
875 |
}
|
|
876 |
|
|
877 |
if ( name == KMenuBarNodeName ||
|
|
878 |
name == KListQueryDialogNodeName ||
|
|
879 |
name == KMenuNodeName ||
|
|
880 |
name == KMenuItemNodeName ||
|
|
881 |
name == KDynMenuItemNodeName ||
|
|
882 |
name == KWidgetMenuItemNodeName ||
|
|
883 |
name == KPropertyNodeName ||
|
|
884 |
name == KDescNodeName ||
|
|
885 |
name == KTextZoomNodeName ||
|
|
886 |
name == KConfigurationNodeName ||
|
|
887 |
name == KSoftkeyNodeName ||
|
|
888 |
name == KTriggerNodeName ||
|
|
889 |
name == KSettingsConfigurationNodeName ||
|
|
890 |
name == KContentSourceNodeName ||
|
|
891 |
name == KMenuExtensionNodeName ||
|
|
892 |
name == KStylusPopupNodeName ||
|
|
893 |
name == KActionsHandlerNodeName )
|
|
894 |
{
|
|
895 |
node->SetLayoutCapable( EFalse );
|
|
896 |
}
|
|
897 |
|
|
898 |
CXnNode* parent( FindAncestorWhoActAsParent( aSource ) );
|
|
899 |
|
|
900 |
if( !parent )
|
|
901 |
{
|
|
902 |
delete node;
|
|
903 |
|
|
904 |
return;
|
|
905 |
}
|
|
906 |
|
|
907 |
parent->AddChildL( node );
|
|
908 |
|
|
909 |
if ( !parent->IsLayoutCapable() )
|
|
910 |
{
|
|
911 |
node->SetLayoutCapable( EFalse );
|
|
912 |
}
|
|
913 |
|
|
914 |
aSource.SetLayoutNode( node );
|
|
915 |
node->SetDomNode( &aSource );
|
|
916 |
|
|
917 |
node->SetUiEngine( iUiEngine );
|
|
918 |
|
|
919 |
CopyPropertiesFromDomNodeToNodeL( *node, aSource, aSp );
|
|
920 |
|
|
921 |
if ( name == KTriggerNodeName )
|
|
922 |
{
|
|
923 |
if ( iUiEngine.IsEditMode() )
|
|
924 |
{
|
|
925 |
node->SetStateL( XnPropertyNames::style::common::KEdit );
|
|
926 |
}
|
|
927 |
}
|
|
928 |
|
|
929 |
// Mark adaptive layoutable nodes
|
|
930 |
TInt adaptive( XnAdaptive::ENone );
|
|
931 |
|
|
932 |
CXnProperty* width( node->WidthL() );
|
|
933 |
|
|
934 |
if ( width )
|
|
935 |
{
|
|
936 |
const TDesC8& w( width->StringValue() );
|
|
937 |
|
|
938 |
if ( w == XnPropertyNames::style::common::KAdaptive )
|
|
939 |
{
|
|
940 |
adaptive = XnAdaptive::EWidth;
|
|
941 |
}
|
|
942 |
}
|
|
943 |
|
|
944 |
CXnProperty* height( node->HeightL() );
|
|
945 |
|
|
946 |
if ( height )
|
|
947 |
{
|
|
948 |
const TDesC8& h( height->StringValue() );
|
|
949 |
|
|
950 |
if ( h == XnPropertyNames::style::common::KAdaptive )
|
|
951 |
{
|
|
952 |
adaptive |= XnAdaptive::EHeight;
|
|
953 |
}
|
|
954 |
}
|
|
955 |
|
|
956 |
if ( adaptive != XnAdaptive::ENone )
|
|
957 |
{
|
|
958 |
node->SetAdaptiveL( adaptive );
|
|
959 |
}
|
|
960 |
|
|
961 |
// Collect nodes, which nav-index property is 'appearance' to
|
|
962 |
// an array
|
|
963 |
CXnProperty* navindex( node->NavIndexL() );
|
|
964 |
|
|
965 |
if ( navindex &&
|
|
966 |
navindex->StringValue() == XnPropertyNames::style::common::KAppearance )
|
|
967 |
{
|
|
968 |
aPluginData.SetAppearanceNodeL( node );
|
|
969 |
}
|
|
970 |
|
|
971 |
// Collect initial focus nodes.
|
|
972 |
CXnProperty* initialFocusProp( node->InitialFocusL() );
|
|
973 |
|
|
974 |
if ( initialFocusProp )
|
|
975 |
{
|
|
976 |
aPluginData.SetInitialFocusNodeL( node );
|
|
977 |
}
|
|
978 |
}
|
|
979 |
|
|
980 |
// -----------------------------------------------------------------------------
|
|
981 |
// CXnODTParser::CreateControlsL()
|
|
982 |
// Run control creation 1st phase
|
|
983 |
// -----------------------------------------------------------------------------
|
|
984 |
//
|
|
985 |
void CXnODTParser::CreateControlsL( CXnDomNode* aNode,
|
|
986 |
CXnPluginData& aPluginData )
|
|
987 |
{
|
|
988 |
if ( aNode )
|
|
989 |
{
|
|
990 |
ConstructControlL( aNode->LayoutNode(), aPluginData );
|
|
991 |
|
|
992 |
CXnDomList& childList( aNode->ChildNodes() );
|
|
993 |
|
|
994 |
TInt count( childList.Length() );
|
|
995 |
|
|
996 |
for ( TInt i = 0; i < count; ++i )
|
|
997 |
{
|
|
998 |
CreateControlsL(
|
|
999 |
static_cast< CXnDomNode* >( childList.Item( i ) ), aPluginData );
|
|
1000 |
}
|
|
1001 |
}
|
|
1002 |
}
|
|
1003 |
|
|
1004 |
// -----------------------------------------------------------------------------
|
|
1005 |
// CXnODTParser::ConstructControlL()
|
|
1006 |
// Run control creation 1st phase
|
|
1007 |
// -----------------------------------------------------------------------------
|
|
1008 |
//
|
|
1009 |
void CXnODTParser::ConstructControlL( CXnNode* aNode,
|
|
1010 |
CXnPluginData& aPluginData )
|
|
1011 |
{
|
|
1012 |
if( !aNode )
|
|
1013 |
{
|
|
1014 |
return;
|
|
1015 |
}
|
|
1016 |
|
|
1017 |
CXnComponentNodeImpl* impl( aNode->ComponentNodeImpl() );
|
|
1018 |
CXnViewNodeImpl* viewImpl( aNode->ViewNodeImpl() );
|
|
1019 |
|
|
1020 |
TBool needsCreation( EFalse );
|
|
1021 |
|
|
1022 |
if ( ( impl && impl->DoesComponentNeedCreation() ) || viewImpl )
|
|
1023 |
{
|
|
1024 |
needsCreation = ETrue;
|
|
1025 |
}
|
|
1026 |
|
|
1027 |
const TDesC8& name( aNode->Type()->Type() );
|
|
1028 |
|
|
1029 |
if ( needsCreation )
|
|
1030 |
{
|
|
1031 |
// Try if builtin control can be created
|
|
1032 |
if ( !CreateBuiltInControlL( *aNode, name ) )
|
|
1033 |
{
|
|
1034 |
// Not builtin, invoke factory chain
|
|
1035 |
CreateFactoryControlL( *aNode, name );
|
|
1036 |
}
|
|
1037 |
|
|
1038 |
// Fill plugin data
|
|
1039 |
aPluginData.SetControlL( aNode );
|
|
1040 |
}
|
|
1041 |
|
|
1042 |
if ( name == KContentSourceNodeName )
|
|
1043 |
{
|
|
1044 |
aPluginData.SetContentSourceNodeL( aNode );
|
|
1045 |
}
|
|
1046 |
}
|
|
1047 |
|
|
1048 |
// -----------------------------------------------------------------------------
|
|
1049 |
// CXnODTParser::CreateExternalControlL()
|
|
1050 |
// Creates external control
|
|
1051 |
// -----------------------------------------------------------------------------
|
|
1052 |
//
|
|
1053 |
TBool CXnODTParser::CreateExternalControlL( CXnNode& aNode,
|
|
1054 |
const TDesC8& aName )
|
|
1055 |
{
|
|
1056 |
CXnExtRenderingPluginAdapter* adapter( NULL );
|
|
1057 |
|
|
1058 |
// Get implementations via ECom
|
|
1059 |
RImplInfoPtrArray plugins;
|
|
1060 |
CleanupResetAndDestroyPushL( plugins );
|
|
1061 |
|
|
1062 |
REComSession::ListImplementationsL(
|
|
1063 |
TUid::Uid( AI3_EXTERNAL_RENDERING_PLUGIN_ECOM_UID ), plugins );
|
|
1064 |
|
|
1065 |
for( TInt i = 0; i < plugins.Count(); i++ )
|
|
1066 |
{
|
|
1067 |
CImplementationInformation* information( plugins[i] );
|
|
1068 |
|
|
1069 |
if( information->DataType().Compare( aName ) == 0 )
|
|
1070 |
{
|
|
1071 |
adapter = CXnExtRenderingPluginAdapter::NewL(
|
|
1072 |
information->ImplementationUid() );
|
|
1073 |
break;
|
|
1074 |
}
|
|
1075 |
}
|
|
1076 |
CleanupStack::PopAndDestroy(); // plugins
|
|
1077 |
|
|
1078 |
if( adapter )
|
|
1079 |
{
|
|
1080 |
CXnComponent* component = CXnComponent::NewL();
|
|
1081 |
CleanupStack::PushL( component );
|
|
1082 |
|
|
1083 |
CXnControlAdapter* parentAdapter( NULL );
|
|
1084 |
|
|
1085 |
// Find parent control
|
|
1086 |
CXnNode* parent( aNode.Parent() );
|
|
1087 |
|
|
1088 |
for ( ; parent; parent = parent->Parent() )
|
|
1089 |
{
|
|
1090 |
parentAdapter = parent->Control();
|
|
1091 |
|
|
1092 |
if ( parentAdapter )
|
|
1093 |
{
|
|
1094 |
break;
|
|
1095 |
}
|
|
1096 |
}
|
|
1097 |
|
|
1098 |
if( parentAdapter )
|
|
1099 |
{
|
|
1100 |
CXnExtRenderingPluginWrapper* wrapper =
|
|
1101 |
CXnExtRenderingPluginWrapper::NewL( aNode.PluginIfL(), *adapter );
|
|
1102 |
CleanupStack::PushL( wrapper );
|
|
1103 |
|
|
1104 |
parentAdapter->AppendChildL( *wrapper, aNode );
|
|
1105 |
CleanupStack::Pop( wrapper );
|
|
1106 |
|
|
1107 |
component->SetControlAdapter( wrapper );
|
|
1108 |
|
|
1109 |
aNode.ComponentNodeImpl()->SetComponent( component );
|
|
1110 |
|
|
1111 |
component->SetNode( aNode.PluginIfL() );
|
|
1112 |
|
|
1113 |
wrapper->SetComponent( component );
|
|
1114 |
|
|
1115 |
wrapper->SetComponentsToInheritVisibility( ETrue );
|
|
1116 |
|
|
1117 |
wrapper->ActivateL();
|
|
1118 |
|
|
1119 |
CleanupStack::Pop( component );
|
|
1120 |
|
|
1121 |
return ETrue;
|
|
1122 |
}
|
|
1123 |
else
|
|
1124 |
{
|
|
1125 |
CleanupStack::Pop( component );
|
|
1126 |
return EFalse;
|
|
1127 |
}
|
|
1128 |
}
|
|
1129 |
else
|
|
1130 |
{
|
|
1131 |
return EFalse;
|
|
1132 |
}
|
|
1133 |
}
|
|
1134 |
|
|
1135 |
// CXnODTParser::CreateFactoryControlL()
|
|
1136 |
// Creates factory control
|
|
1137 |
// -----------------------------------------------------------------------------
|
|
1138 |
//
|
|
1139 |
void CXnODTParser::CreateFactoryControlL( CXnNode& aNode,
|
|
1140 |
const TDesC8& aName )
|
|
1141 |
{
|
|
1142 |
CXnArray* factories = CXnArray::NewL();
|
|
1143 |
CleanupStack::PushL( factories );
|
|
1144 |
|
|
1145 |
TUid interfaceUid = { AI3_RENDERING_PLUGIN_ECOM_FACTORY_UID };
|
|
1146 |
|
|
1147 |
iEcomHandler.PluginsL( interfaceUid, aName, *factories );
|
|
1148 |
|
|
1149 |
CXnComponent* component( NULL );
|
|
1150 |
|
|
1151 |
TInt count( factories->Container().Count() );
|
|
1152 |
|
|
1153 |
// Invoke factory chain
|
|
1154 |
for ( TInt i = 0; i < count; i++ )
|
|
1155 |
{
|
|
1156 |
MXnComponentFactory* factory =
|
|
1157 |
static_cast< MXnComponentFactory* >(
|
|
1158 |
( factories->Container() )[i] );
|
|
1159 |
|
|
1160 |
if ( factory->CreateXnComponentL( aNode.PluginIfL(), component ) ==
|
|
1161 |
MXnComponentFactory::EXnFactoryResponseComponentConstructed )
|
|
1162 |
|
|
1163 |
{
|
|
1164 |
// All done
|
|
1165 |
break;
|
|
1166 |
}
|
|
1167 |
}
|
|
1168 |
|
|
1169 |
CleanupStack::PopAndDestroy( factories );
|
|
1170 |
}
|
|
1171 |
|
|
1172 |
// -----------------------------------------------------------------------------
|
|
1173 |
// CXnODTParser::CreateBuiltInControlL()
|
|
1174 |
// Creates builtin control
|
|
1175 |
// -----------------------------------------------------------------------------
|
|
1176 |
//
|
|
1177 |
TBool CXnODTParser::CreateBuiltInControlL( CXnNode& aNode,
|
|
1178 |
const TDesC8& aName )
|
|
1179 |
{
|
|
1180 |
if ( aName != KBoxNodeName && aName != KButtonNodeName &&
|
|
1181 |
aName != KStylusPopupNodeName && aName != KScrollableBoxNodeName&&
|
|
1182 |
aName != KWidgetExtensionNodeName &&
|
|
1183 |
aName != KPopUpNodeName && aName != KViewNodeName &&
|
|
1184 |
aName != XnPropertyNames::listquerydialog::KListQueryDialog )
|
|
1185 |
{
|
|
1186 |
return CreateExternalControlL( aNode, aName );
|
|
1187 |
}
|
|
1188 |
|
|
1189 |
CXnComponent* component = CXnComponent::NewL();
|
|
1190 |
CleanupStack::PushL( component );
|
|
1191 |
|
|
1192 |
CXnControlAdapter* parentAdapter( NULL );
|
|
1193 |
|
|
1194 |
CXnProperty* position( aNode.PositionL() );
|
|
1195 |
|
|
1196 |
if ( position )
|
|
1197 |
{
|
|
1198 |
const TDesC8& value( position->StringValue() );
|
|
1199 |
|
|
1200 |
if ( value == XnPropertyNames::style::common::position::KFloating )
|
|
1201 |
{
|
|
1202 |
// Find view node and append floating control to its compound
|
|
1203 |
for ( CXnNode* node = &aNode; node; node = node->Parent() )
|
|
1204 |
{
|
|
1205 |
if ( node->ViewNodeImpl() )
|
|
1206 |
{
|
|
1207 |
parentAdapter = node->Control();
|
|
1208 |
|
|
1209 |
break;
|
|
1210 |
}
|
|
1211 |
}
|
|
1212 |
}
|
|
1213 |
}
|
|
1214 |
|
|
1215 |
if ( !parentAdapter )
|
|
1216 |
{
|
|
1217 |
// Find parent control
|
|
1218 |
CXnNode* parent( aNode.Parent() );
|
|
1219 |
|
|
1220 |
for ( ; parent; parent = parent->Parent() )
|
|
1221 |
{
|
|
1222 |
parentAdapter = parent->Control();
|
|
1223 |
|
|
1224 |
if ( parentAdapter )
|
|
1225 |
{
|
|
1226 |
break;
|
|
1227 |
}
|
|
1228 |
}
|
|
1229 |
}
|
|
1230 |
|
|
1231 |
CXnControlAdapter* adapter( NULL );
|
|
1232 |
|
|
1233 |
if( aName == KViewNodeName )
|
|
1234 |
{
|
|
1235 |
adapter = CXnViewControlAdapter::NewL( aNode.PluginIfL() );
|
|
1236 |
CleanupStack::PushL( adapter );
|
|
1237 |
}
|
|
1238 |
else if( aName == KStylusPopupNodeName )
|
|
1239 |
{
|
|
1240 |
adapter = CXnPopupControlAdapter::NewL( aNode.PluginIfL() );
|
|
1241 |
CleanupStack::PushL( adapter );
|
|
1242 |
}
|
|
1243 |
else if( aName == KWidgetExtensionNodeName ||
|
|
1244 |
aName == KPopUpNodeName )
|
|
1245 |
{
|
|
1246 |
adapter = CXnWidgetExtensionAdapter::NewL( aNode.PluginIfL() );
|
|
1247 |
CleanupStack::PushL( adapter );
|
|
1248 |
CXnProperty* prop = CXnProperty::NewL(
|
|
1249 |
XnPropertyNames::style::common::KPosition,
|
|
1250 |
XnPropertyNames::style::common::position::KFloating,
|
|
1251 |
CXnDomPropertyValue::EString,
|
|
1252 |
*aNode.UiEngine()->ODT()->DomDocument().StringPool() );
|
|
1253 |
CleanupStack::PushL( prop );
|
|
1254 |
aNode.SetPropertyL( prop );
|
|
1255 |
CleanupStack::Pop( prop );
|
|
1256 |
}
|
|
1257 |
else if( aName == KScrollableBoxNodeName )
|
|
1258 |
{
|
|
1259 |
adapter = CXnScrollableControlAdapter::NewL( aNode.PluginIfL() );
|
|
1260 |
CleanupStack::PushL( adapter );
|
|
1261 |
}
|
|
1262 |
else if( aName == XnPropertyNames::listquerydialog::KListQueryDialog )
|
|
1263 |
{
|
|
1264 |
CleanupStack::PopAndDestroy( component );
|
|
1265 |
CXnListQueryDialog* listQuery = CXnListQueryDialog::NewL();
|
|
1266 |
component = static_cast<CXnComponent*>( listQuery );
|
|
1267 |
CleanupStack::PushL( component );
|
|
1268 |
adapter = CXnListQueryDialogAdapter::NewL( aNode.PluginIfL() );
|
|
1269 |
CleanupStack::PushL( adapter );
|
|
1270 |
}
|
|
1271 |
else
|
|
1272 |
{
|
|
1273 |
adapter = CXnControlAdapter::NewL( aNode.PluginIfL() );
|
|
1274 |
CleanupStack::PushL( adapter );
|
|
1275 |
}
|
|
1276 |
|
|
1277 |
if ( parentAdapter )
|
|
1278 |
{
|
|
1279 |
parentAdapter->AppendChildL( *adapter, aNode );
|
|
1280 |
}
|
|
1281 |
|
|
1282 |
component->SetControlAdapter( adapter ); // ovnership transferred
|
|
1283 |
CleanupStack::Pop( adapter );
|
|
1284 |
|
|
1285 |
__ASSERT_DEBUG( adapter, User::Leave( KErrGeneral ) );
|
|
1286 |
|
|
1287 |
if( aName == KViewNodeName )
|
|
1288 |
{
|
|
1289 |
aNode.ViewNodeImpl()->SetComponent( component );
|
|
1290 |
}
|
|
1291 |
else
|
|
1292 |
{
|
|
1293 |
aNode.ComponentNodeImpl()->SetComponent( component );
|
|
1294 |
}
|
|
1295 |
|
|
1296 |
component->SetNode( aNode.PluginIfL() );
|
|
1297 |
|
|
1298 |
adapter->SetComponent( component );
|
|
1299 |
|
|
1300 |
adapter->SetComponentsToInheritVisibility( ETrue );
|
|
1301 |
|
|
1302 |
adapter->ActivateL();
|
|
1303 |
|
|
1304 |
CleanupStack::Pop( component );
|
|
1305 |
|
|
1306 |
return ETrue;
|
|
1307 |
}
|
|
1308 |
|
|
1309 |
// --------------------------------------------------------------------------
|
|
1310 |
// CXnODTParser::HandleWidgetBackgroundL()
|
|
1311 |
//
|
|
1312 |
// --------------------------------------------------------------------------
|
|
1313 |
//
|
|
1314 |
void CXnODTParser::HandleWidgetBackgroundL( CXnNode* aWidgetNode )
|
|
1315 |
{
|
|
1316 |
if( aWidgetNode )
|
|
1317 |
{
|
|
1318 |
CXnUiEngine* uiengine = aWidgetNode->UiEngine();
|
|
1319 |
CXnProperty* bgImageProp = aWidgetNode->BackgroundImageL();
|
|
1320 |
CXnProperty* bgColorProp = aWidgetNode->BackgroundColorL();
|
|
1321 |
|
|
1322 |
// Set default bg color if it has not been defined by a widget
|
|
1323 |
if( !bgImageProp && !bgColorProp && uiengine )
|
|
1324 |
{
|
|
1325 |
CXnDomPropertyValue* value = CXnDomPropertyValue::NewL(
|
|
1326 |
uiengine->ODT()->DomDocument().StringPool() );
|
|
1327 |
CleanupStack::PushL( value );
|
|
1328 |
value->SetStringValueL( CXnDomPropertyValue::EString, KWidgetBgSkinId );
|
|
1329 |
|
|
1330 |
CXnProperty* bgColor = CXnProperty::NewL(
|
|
1331 |
XnPropertyNames::appearance::common::KBackGroundColor,
|
|
1332 |
value, *uiengine->ODT()->DomDocument().StringPool() );
|
|
1333 |
|
|
1334 |
CleanupStack::Pop( value );
|
|
1335 |
CleanupStack::PushL( bgColor );
|
|
1336 |
aWidgetNode->SetPropertyL( bgColor );
|
|
1337 |
CleanupStack::Pop( bgColor );
|
|
1338 |
}
|
|
1339 |
}
|
|
1340 |
}
|
|
1341 |
|
|
1342 |
// End of file
|
|
1343 |
|