idlehomescreen/xmluirendering/uiengine/src/xnodtparser.cpp
changeset 0 f72a12da539e
child 2 08c6ee43b396
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     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 "xnpopupcontroladapter.h"
       
    36 #include "xnwidgetextensionadapter.h"
       
    37 #include "xnscrollablecontroladapter.h"
       
    38 #include "xnlistquerydialogadapter.h"
       
    39 
       
    40 #include "xncomponent.h"
       
    41 #include "xncomponentnodeimpl.h"
       
    42 #include "xnviewnodeimpl.h"
       
    43 #include "xnviewsnodeimpl.h"
       
    44 #include "xnproperty.h"
       
    45 #include "xncomponentfactory.h"
       
    46 #include "xnarray.h"
       
    47 #include "xnviewmanager.h"
       
    48 #include "xnplugindata.h"
       
    49 #include "xnrootdata.h"
       
    50 #include "xnviewdata.h"
       
    51 
       
    52 #include "xnodtparser.h"
       
    53 
       
    54 _LIT8( KWidgetBgSkinId, "SKIN(268458534 9886)" );
       
    55 
       
    56 // CONSTANTS
       
    57 _LIT8( KXMLUIMLNodeName, "xmluiml" );
       
    58 _LIT8( KViewsNodeName, "views" );
       
    59 _LIT8( KViewNodeName, "view" );
       
    60 _LIT8( KBoxNodeName, "box" );
       
    61 _LIT8( KButtonNodeName, "button" );
       
    62 _LIT8( KStylusPopupNodeName, "styluspopup" );
       
    63 _LIT8( KListNodeName, "list" );
       
    64 _LIT8( KGridNodeName, "grid" );
       
    65 _LIT8( KImageNodeName, "image" );
       
    66 _LIT8( KTooltipNodeName, "tooltip" );
       
    67 _LIT8( KMenuBarNodeName, "menubar" );
       
    68 _LIT8( KMenuNodeName, "menu" );
       
    69 _LIT8( KMenuItemNodeName, "menuitem" );
       
    70 _LIT8( KDynMenuItemNodeName, "dynmenuitem" );
       
    71 _LIT8( KWidgetMenuItemNodeName, "widgetmenuitem" );
       
    72 _LIT8( KActionsNodeName, "actions" );
       
    73 _LIT8( KActionNodeName, "action" );
       
    74 _LIT8( KTriggerNodeName, "trigger" );
       
    75 _LIT8( KEventNodeName, "event" );
       
    76 _LIT8( KTextNodeName, "text" );
       
    77 _LIT8( KGridCellTemplateNodeName, "gridcelltemplate" );
       
    78 _LIT8( KListRowTemplateNodeName, "listrowtemplate" );
       
    79 _LIT8( KMarqueeNodeName, "marquee" );
       
    80 _LIT8( KObjectNodeName, "object" );
       
    81 _LIT8( KTracksterNodeName, "trackster" );
       
    82 _LIT8( KPropertyNodeName, "property" );
       
    83 _LIT8( KConfigurationNodeName, "configuration" );
       
    84 _LIT8( KNewstickerNodeName, "newsticker" );
       
    85 _LIT8( KAttributeNodeName, "attribute" );
       
    86 _LIT8( KItemNodeName, "item" );
       
    87 _LIT8( KDescNodeName, "desc" );
       
    88 _LIT8( KTextZoomNodeName, "textzoom" );
       
    89 _LIT8( KVolumeControlNodeName, "volumecontrol" );
       
    90 _LIT8( KPluginNodeName, "plugin" );
       
    91 _LIT8( KWidgetNodeName, "widget" );
       
    92 _LIT8( KSliderNodeName, "slider" );
       
    93 _LIT8( KClockNodeName, "clock" );
       
    94 _LIT8( KSoftkeyNodeName,"softkey" );
       
    95 _LIT8( KConditionalTrigger,"conditional" );
       
    96 _LIT8( KCondtionalOn, "true" );
       
    97 _LIT8( KListQueryDialogNodeName, "listquerydialog" );
       
    98 _LIT8( KSettingsConfigurationNodeName, "settingsconfiguration" );
       
    99 _LIT8( KContentSourceNodeName, "contentsource" );
       
   100 _LIT8( KMenuExtensionNodeName, "menuextension" );
       
   101 _LIT8( KWidgetExtensionNodeName, "widgetextension" );
       
   102 _LIT8( KTextEditorNodeName, "texteditor" );
       
   103 _LIT8( KActionsHandlerNodeName, "actionshandler" );
       
   104 _LIT8( KScrollableBoxNodeName, "scrollablebox" );
       
   105 _LIT8( KPopUpNodeName, "popup" );
       
   106 
       
   107 // LOCAL FUNCTION PROTOTYPES
       
   108 #ifdef _XN3_DEBUG_
       
   109 #include <flogger.h>
       
   110 #include <utf.h>
       
   111 static void PrintDomL( CXnDomDocument* aDomDocument );
       
   112 #endif
       
   113 
       
   114 static CXnNode* BuildRootNodeL( CXnUiEngine& aEngine );         
       
   115 
       
   116 static CXnNode* FindAncestorWhoActAsParent( CXnDomNode& aSource );
       
   117 
       
   118 static TBool CreateTriggerInLayoutNodeTree( CXnDomNode& aSource );
       
   119 
       
   120 static void CopyPropertiesFromDomNodeToNodeL(
       
   121     CXnNode& aTarget,
       
   122     CXnDomNode& aSource,
       
   123     CXnDomStringPool& aStringPool );
       
   124 static CXnNode* ConstructNodeFromPluginL(
       
   125     CXnEcomHandler& aEcomHandler,
       
   126     CXnDomNode& aSource );
       
   127 static CXnNode* ConstructKnownBuiltinNodeL( CXnDomNode& aSource );
       
   128 static CXnNode* ConstructGeneralNodeL( CXnDomNode& aSource );
       
   129 
       
   130 // ============================= LOCAL FUNCTIONS ===============================
       
   131 
       
   132     
       
   133 // ----------------------------------------------------------------------------
       
   134 // CleanupResetAndDestroy()
       
   135 // ----------------------------------------------------------------------------
       
   136 //
       
   137 template<class T>
       
   138 static void CleanupResetAndDestroy( TAny* aObj )
       
   139     {
       
   140     if( aObj )
       
   141         {
       
   142         static_cast<T*>( aObj )->ResetAndDestroy();
       
   143         }
       
   144     }  
       
   145 
       
   146 // ----------------------------------------------------------------------------
       
   147 // CleanupResetAndDestroyPushL
       
   148 // ----------------------------------------------------------------------------
       
   149 //
       
   150 template<class T>
       
   151 static void CleanupResetAndDestroyPushL(T& aArray)
       
   152     {
       
   153     CleanupStack::PushL( TCleanupItem( &CleanupResetAndDestroy<T>, &aArray ) );
       
   154     }  
       
   155 
       
   156 #ifdef _XN3_DEBUG_
       
   157 _LIT( KLogFolder," xnlayoutengine" );
       
   158 _LIT( KLogDom, "dom.log" );
       
   159 #define _LOGT( aDescription ) RFileLogger::Write( \
       
   160     KLogFolder, KLogDom, EFileLoggingModeOverwrite, aDescription );
       
   161 #define _LOGTFRM1( a, b ) RFileLogger::WriteFormat( \
       
   162     KLogFolder, KLogDom, EFileLoggingModeOverwrite, ( a ), ( b ) )
       
   163 #define _LOGTFRM2( a, b, c ) RFileLogger::WriteFormat( \
       
   164     KLogFolder, KLogDom, EFileLoggingModeOverwrite, ( a ), ( b ), ( c ) );
       
   165 #define _LOGTFRM3( a, b, c, d ) RFileLogger::WriteFormat( \
       
   166     KLogFolder, KLogDom, EFileLoggingModeOverwrite, ( a ), ( b ), ( c ), ( d ) );
       
   167 static const TInt GetNodeDepth( CXnDomNode *aNode )
       
   168     {
       
   169     TInt depth = 0;
       
   170     CXnDomNode* node( aNode );
       
   171     while ( node )
       
   172         {
       
   173         node = node->Parent();
       
   174         if ( node )
       
   175             {
       
   176             depth++;
       
   177             }
       
   178         }
       
   179     return depth;
       
   180     }
       
   181 
       
   182 //-----------------------------------------------------------------------------
       
   183 // ----------------------------------------------------------------------------
       
   184 //
       
   185 static HBufC8* GetFixedTextLC(
       
   186     const TDesC8& aText,
       
   187     const TInt aDepth,
       
   188     const TDesC8& aDelim )
       
   189     {
       
   190     HBufC8 *buf = HBufC8::NewL( aDepth * aDelim.Length() + aText.Length() + 1 );
       
   191     TInt i = 0;
       
   192     for ( ; i < aDepth; i++ )
       
   193         {
       
   194         buf->Des().Append( aDelim );
       
   195         }
       
   196     buf->Des().Append( aText );
       
   197     return buf;
       
   198     }
       
   199 
       
   200 //-----------------------------------------------------------------------------
       
   201 // ----------------------------------------------------------------------------
       
   202 //
       
   203 static void PrintDomL( CXnDomDocument* aDomDocument )
       
   204     {
       
   205 __UHEAP_MARK;
       
   206     TInt attrCount( 0 );
       
   207     TInt propCount( 0 );
       
   208 
       
   209     CXnDomDepthIterator* iter = 
       
   210             CXnDomDepthIterator::NewL( *aDomDocument->RootNode() );
       
   211     CleanupStack::PushL( iter );
       
   212 
       
   213     _LIT8( KDelim, "\t" );
       
   214     CXnDomNode* nodeParent( NULL );
       
   215     CXnDomNode* node = iter->First();
       
   216     while ( node )
       
   217         {
       
   218         const TInt depth = GetNodeDepth( node );
       
   219 
       
   220         HBufC8 *nameBuf = GetFixedTextLC( node->Name(), depth, KDelim );
       
   221         CleanupStack::PushL( nameBuf );
       
   222         const TDesC8& name = nameBuf->Des();
       
   223 
       
   224         HBufC8 *nsBuf = GetFixedTextLC( node->Namespace(), depth, KDelim );
       
   225         CleanupStack::PushL( nsBuf );
       
   226         const TDesC8& ns = nsBuf->Des();
       
   227 
       
   228         _LOGTFRM2( _L8( "%S -------------------------- %S\n" ), &name, &ns );
       
   229 
       
   230         CXnDomList& attrList = node->AttributeList();
       
   231         TInt length( attrList.Length() );
       
   232         attrCount += length;
       
   233 
       
   234         for ( TInt i = 0; i < length; i++ )
       
   235             {
       
   236             CXnDomAttribute* attr = static_cast< CXnDomAttribute* >(
       
   237                 attrList.Item( i ) );
       
   238 
       
   239             HBufC8 *attrBuf = GetFixedTextLC( attr->Name(), depth,  KDelim );
       
   240             CleanupStack::PushL( attrBuf );
       
   241             const TDesC8& attrName = attrBuf->Des();
       
   242 
       
   243             const TDesC8& attrValue = attr->Value();
       
   244 
       
   245             _LOGTFRM2( _L8( "%S=%S\n" ), &attrName, &attrValue );
       
   246 
       
   247             CleanupStack::PopAndDestroy( attrBuf );
       
   248             }
       
   249 
       
   250         if ( node->Parent() )
       
   251             {
       
   252             nodeParent = node;
       
   253             }
       
   254         node = iter->NextL();
       
   255 
       
   256         CleanupStack::PopAndDestroy( nsBuf );
       
   257         CleanupStack::PopAndDestroy( nameBuf );
       
   258         }
       
   259     CleanupStack::PopAndDestroy( iter );
       
   260 
       
   261     _LOGTFRM1( _L8( "****DOM Size: %d ****\n" ), aDomDocument->Size() );
       
   262     _LOGTFRM1( _L8( "****DOM Node Count: %d ****\n" ), aDomDocument->DomNodeCount() );
       
   263     _LOGTFRM1( _L8( "****DOM Attribute Count: %d ****\n" ), attrCount );
       
   264 __UHEAP_MARKEND;
       
   265     }
       
   266 
       
   267 #endif
       
   268 // -----------------------------------------------------------------------------
       
   269 // BuildRootNodeL()
       
   270 // Builds root node
       
   271 // -----------------------------------------------------------------------------
       
   272 //
       
   273 static CXnNode* BuildRootNodeL( CXnUiEngine& aEngine )           
       
   274     {
       
   275     CXnType* type = CXnType::NewL( KXMLUIMLNodeName );
       
   276     CleanupStack::PushL( type );
       
   277 
       
   278     CXnNodeImpl* impl = CXnNodeImpl::NewL( type ); 
       
   279         
       
   280     CleanupStack::Pop( type );
       
   281     CleanupStack::PushL( impl );
       
   282 
       
   283     CXnNode* node = CXnNode::NewL();
       
   284     node->SetRootNodeImpl( impl );
       
   285     CleanupStack::Pop( impl );
       
   286 
       
   287     node->SetUiEngine( aEngine );
       
   288     
       
   289     return node;
       
   290     }
       
   291 
       
   292 // -----------------------------------------------------------------------------
       
   293 // -----------------------------------------------------------------------------
       
   294 //
       
   295 CXnNode* FindAncestorWhoActAsParent( CXnDomNode& aSource )
       
   296     {
       
   297     CXnNode* ret( NULL );
       
   298     CXnDomNode* parent = aSource.Parent();
       
   299 
       
   300     while ( !ret && parent )
       
   301         {
       
   302         ret = parent->LayoutNode();
       
   303         parent = parent->Parent();
       
   304         }
       
   305     return ret;
       
   306     }
       
   307 
       
   308 // -----------------------------------------------------------------------------
       
   309 // -----------------------------------------------------------------------------
       
   310 //
       
   311 TBool CreateTriggerInLayoutNodeTree( CXnDomNode& aSource )
       
   312     {
       
   313     TBool ret( EFalse );
       
   314 
       
   315     CXnDomAttribute* attribute = static_cast< CXnDomAttribute* >(
       
   316         aSource.AttributeList().FindByName( KConditionalTrigger ) );
       
   317 
       
   318     if ( attribute && attribute->Value() == KCondtionalOn )
       
   319         {
       
   320         ret = ETrue;
       
   321         }
       
   322     return ret;
       
   323     }
       
   324 
       
   325 // -----------------------------------------------------------------------------
       
   326 // CopyDomPropertiesFromDomNodeToNodeL
       
   327 // -----------------------------------------------------------------------------
       
   328 //
       
   329 static void CopyDomPropertiesFromDomNodeToNodeL(
       
   330     CXnNode& aTarget,
       
   331     CXnDomNode& aSource )
       
   332     {
       
   333     CXnDomList& propertyList = aSource.PropertyList();
       
   334     for ( TInt count = propertyList.Length() - 1; count >= 0; --count )
       
   335         {
       
   336         CXnDomProperty* domProperty = static_cast< CXnDomProperty* >(
       
   337             propertyList.Item( count ) );
       
   338         CXnProperty* property = CXnProperty::NewSharedL( domProperty );
       
   339         CleanupStack::PushL( property );
       
   340         aTarget.InitializePropertyL( property );
       
   341         CleanupStack::Pop( property );
       
   342         }
       
   343     }
       
   344 
       
   345 // -----------------------------------------------------------------------------
       
   346 // CopyDomAtributesFromDomNodeToNodeL
       
   347 // -----------------------------------------------------------------------------
       
   348 //
       
   349 static void CopyDomAttributesFromDomNodeToNodeL(
       
   350     CXnNode& aTarget,
       
   351     CXnDomNode& aSource,
       
   352     CXnDomStringPool& aStringPool )
       
   353     {
       
   354     CXnDomList& attributeList = aSource.AttributeList();
       
   355     for ( TInt count = attributeList.Length() - 1; count >= 0; --count )
       
   356         {
       
   357         CXnDomAttribute* attribute = static_cast< CXnDomAttribute* >(
       
   358             attributeList.Item( count ) );
       
   359 #ifdef _DEBUG
       
   360         const TDesC8& name = attribute->Name();
       
   361         const TDesC8& attrValue = attribute->Value();
       
   362 #endif
       
   363         if ( attribute->ValueStringPoolIndex() == KErrNotFound )
       
   364             {
       
   365             continue;
       
   366             }
       
   367 
       
   368         if ( attribute->NameStringPoolIndex() == KErrNotFound )
       
   369             {
       
   370             continue;
       
   371             }
       
   372          CXnDomProperty* clone =
       
   373             CXnDomProperty::NewL( attribute->NameStringPoolIndex(), aStringPool );
       
   374         CleanupStack::PushL( clone );
       
   375         CXnDomPropertyValue* propertyValue =
       
   376             CXnDomPropertyValue::NewL( aStringPool );
       
   377         CleanupStack::PushL( propertyValue );
       
   378         propertyValue->SetStringPoolIndexL(
       
   379             CXnDomPropertyValue::EString, attribute->ValueStringPoolIndex() );
       
   380         CXnDomList& propertyList = clone->PropertyValueList();
       
   381         propertyList.AddItemL( propertyValue );
       
   382         CleanupStack::Pop( propertyValue );
       
   383         CXnProperty* property = CXnProperty::NewL( clone );
       
   384         CleanupStack::Pop( clone );
       
   385         CleanupStack::PushL( property );
       
   386         aTarget.InitializePropertyL( property );
       
   387         CleanupStack::Pop( property );
       
   388         }
       
   389 
       
   390     //aSource.DeleteAttributeList();
       
   391     // delete attributes from dom node tree
       
   392     if ( aSource.Name() != KTriggerNodeName )
       
   393         {
       
   394         CXnDomList& attrList = aSource.AttributeList();
       
   395         while ( attrList.Length() )
       
   396             {
       
   397             attrList.DeleteItem( attrList.Length() - 1 );
       
   398             }
       
   399         }
       
   400     }
       
   401 
       
   402 // -----------------------------------------------------------------------------
       
   403 // CopyPropertiesFromDomNodeToNodeL
       
   404 // -----------------------------------------------------------------------------
       
   405 //
       
   406 static void CopyPropertiesFromDomNodeToNodeL(
       
   407     CXnNode& aTarget,
       
   408     CXnDomNode& aSource,
       
   409     CXnDomStringPool& aStringPool )
       
   410     {
       
   411     CopyDomPropertiesFromDomNodeToNodeL( aTarget, aSource );
       
   412     CopyDomAttributesFromDomNodeToNodeL( aTarget, aSource, aStringPool );
       
   413     }
       
   414 
       
   415 // -----------------------------------------------------------------------------
       
   416 // ConstructNodeFromPluginL
       
   417 // -----------------------------------------------------------------------------
       
   418 //
       
   419 static CXnNode* ConstructNodeFromPluginL(
       
   420     CXnEcomHandler& aEcomHandler,
       
   421     CXnDomNode& aSource )
       
   422     {
       
   423     CXnNode* returnValue = NULL;
       
   424     const TDesC8& name = aSource.Name();
       
   425 
       
   426     CXnArray* componentFactories = CXnArray::NewL();
       
   427     CleanupStack::PushL( componentFactories );
       
   428 
       
   429     TUid interfaceUid = { AI3_RENDERING_PLUGIN_ECOM_FACTORY_UID };
       
   430     aEcomHandler.PluginsL( interfaceUid, name, *componentFactories );
       
   431     TInt count = componentFactories->Container().Count();
       
   432     TBool componentNodeImplNeeded = ETrue;
       
   433     // invoke factory chain
       
   434     for ( TInt i = 0; i < count; ++i )
       
   435         {
       
   436         MXnComponentFactory* factory = static_cast< MXnComponentFactory* >(
       
   437             componentFactories->Container()[i] );
       
   438         componentNodeImplNeeded = factory->DoesNodeNeedComponentImplL( name );
       
   439         }
       
   440     CleanupStack::PopAndDestroy( componentFactories );
       
   441     if ( componentNodeImplNeeded )
       
   442         {
       
   443         CXnType* type = CXnType::NewL( name );
       
   444         CleanupStack::PushL( type );
       
   445         CXnComponentNodeImpl* impl = CXnComponentNodeImpl::NewL( type );
       
   446         CleanupStack::Pop( type );
       
   447         CleanupStack::PushL( impl );
       
   448         returnValue = CXnNode::NewL();
       
   449         returnValue->SetComponentNodeImpl( impl );
       
   450         CleanupStack::Pop( impl );
       
   451         }
       
   452     else
       
   453         {
       
   454         if ( name == KActionsNodeName ||
       
   455              name == KActionNodeName ||
       
   456              name == KEventNodeName ||
       
   457              name == KTriggerNodeName ||
       
   458              name == KMenuNodeName ||
       
   459              name == KMenuItemNodeName ||
       
   460              name == KPropertyNodeName ||
       
   461              name == KSoftkeyNodeName )
       
   462             {
       
   463             return ConstructGeneralNodeL( aSource );
       
   464             }
       
   465         }
       
   466     return returnValue;
       
   467     }
       
   468 
       
   469 // -----------------------------------------------------------------------------
       
   470 // ConstructKnownBuiltinNodeL
       
   471 // -----------------------------------------------------------------------------
       
   472 //
       
   473 static CXnNode* ConstructKnownBuiltinNodeL( CXnDomNode& aSource )
       
   474     {
       
   475     CXnNode* returnValue = NULL;
       
   476     const TDesC8& name = aSource.Name();
       
   477     if ( name == KMenuNodeName ||
       
   478          name == KMenuItemNodeName ||
       
   479          name == KPropertyNodeName ||
       
   480          name == KSoftkeyNodeName ||
       
   481          name == KTriggerNodeName )
       
   482         {
       
   483         return ConstructGeneralNodeL( aSource );
       
   484         }
       
   485     CXnType* type = CXnType::NewL( name );
       
   486     CleanupStack::PushL( type );
       
   487     if ( name == KViewsNodeName )
       
   488         {
       
   489         CXnViewsNodeImpl* impl = CXnViewsNodeImpl::NewL( type );
       
   490         CleanupStack::Pop( type );
       
   491         CleanupStack::PushL( impl );
       
   492         returnValue = CXnNode::NewL();
       
   493         returnValue->SetViewsNodeImpl( impl );
       
   494         CleanupStack::Pop( impl );
       
   495         }
       
   496     else if ( name == KViewNodeName )
       
   497         {
       
   498         CXnViewNodeImpl* impl = CXnViewNodeImpl::NewL( type );
       
   499         CleanupStack::Pop( type );
       
   500         CleanupStack::PushL( impl );
       
   501         returnValue = CXnNode::NewL();
       
   502         returnValue->SetViewNodeImpl( impl );
       
   503         CleanupStack::Pop( impl );
       
   504         }
       
   505     else if ( name == KGridCellTemplateNodeName ||
       
   506               name == KListRowTemplateNodeName ||
       
   507               name == KBoxNodeName ||
       
   508               name == KButtonNodeName ||
       
   509               name == KListNodeName ||
       
   510               name == KGridNodeName ||
       
   511               name == KImageNodeName ||
       
   512               name == KMenuBarNodeName ||
       
   513               name == KTooltipNodeName ||
       
   514               name == KMarqueeNodeName ||
       
   515               name == KTextNodeName ||
       
   516               name == KObjectNodeName ||
       
   517               name == KTracksterNodeName ||
       
   518               name == KNewstickerNodeName ||
       
   519               name == KSliderNodeName ||
       
   520               name == KClockNodeName ||
       
   521               name == KStylusPopupNodeName ||
       
   522               name == KPopUpNodeName ||
       
   523               name == KWidgetExtensionNodeName ||
       
   524               name == KTextEditorNodeName )
       
   525         {
       
   526         CXnComponentNodeImpl* impl = CXnComponentNodeImpl::NewL( type );
       
   527         CleanupStack::Pop( type ) ;
       
   528         CleanupStack::PushL( impl );
       
   529         returnValue = CXnNode::NewL();
       
   530         returnValue->SetComponentNodeImpl( impl );
       
   531         CleanupStack::Pop( impl );
       
   532         }
       
   533     else
       
   534         {
       
   535         CleanupStack::PopAndDestroy( type );
       
   536 
       
   537         if ( name == KVolumeControlNodeName ||
       
   538              name == KWidgetNodeName ||
       
   539              name == KPluginNodeName )
       
   540             {
       
   541             CXnType* type = CXnType::NewL( KBoxNodeName );
       
   542             CleanupStack::PushL( type );
       
   543             CXnComponentNodeImpl* impl = CXnComponentNodeImpl::NewL( type );
       
   544             CleanupStack::Pop( type );
       
   545             CleanupStack::PushL( impl );
       
   546             returnValue = CXnNode::NewL();
       
   547             returnValue->SetComponentNodeImpl( impl );
       
   548             CleanupStack::Pop( impl );
       
   549             }
       
   550         }
       
   551     return returnValue;
       
   552     }
       
   553 
       
   554 // -----------------------------------------------------------------------------
       
   555 // ConstructGeneralNodeL
       
   556 // -----------------------------------------------------------------------------
       
   557 //
       
   558 static CXnNode* ConstructGeneralNodeL( CXnDomNode& aSource )
       
   559     {
       
   560     CXnType* type = CXnType::NewL( aSource.Name() );
       
   561     CleanupStack::PushL( type );
       
   562     CXnNodeImpl* impl = CXnNodeImpl::NewL( type );
       
   563     CleanupStack::Pop( type );
       
   564     CleanupStack::PushL( impl );
       
   565     CXnNode* tmpNode = CXnNode::NewL();
       
   566     tmpNode->SetImpl( impl );
       
   567     CleanupStack::Pop( impl );
       
   568     return tmpNode;
       
   569     }
       
   570 
       
   571 // ============================ MEMBER FUNCTIONS ===============================
       
   572 
       
   573 // -----------------------------------------------------------------------------
       
   574 // CXnODTParser::NewL
       
   575 // Two-phased constructor.
       
   576 // -----------------------------------------------------------------------------
       
   577 //
       
   578 CXnODTParser* CXnODTParser::NewL( CXnViewManager& aManager,
       
   579     CXnEcomHandler& aEcomHandler )
       
   580     {
       
   581     CXnODTParser* self = new ( ELeave ) CXnODTParser( aManager, aEcomHandler ); 
       
   582             
       
   583     CleanupStack::PushL( self );
       
   584     self->ConstructL();
       
   585     CleanupStack::Pop( self );
       
   586 
       
   587     return self;
       
   588     }
       
   589 
       
   590 // -----------------------------------------------------------------------------
       
   591 // CXnODTParser::CXnODTParser
       
   592 // C++ default constructor can NOT contain any code, that
       
   593 // might leave.
       
   594 // -----------------------------------------------------------------------------
       
   595 //
       
   596 CXnODTParser::CXnODTParser( CXnViewManager& aManager,
       
   597     CXnEcomHandler& aEcomHandler )
       
   598     : iManager( aManager ), iUiEngine( aManager.UiEngine() ),
       
   599       iEcomHandler( aEcomHandler )
       
   600     {
       
   601     }
       
   602 
       
   603 // -----------------------------------------------------------------------------
       
   604 // CXnODTParser::~CXnODTParser
       
   605 // Destructor.
       
   606 // -----------------------------------------------------------------------------
       
   607 //
       
   608 CXnODTParser::~CXnODTParser()
       
   609     {
       
   610     }
       
   611 
       
   612 // -----------------------------------------------------------------------------
       
   613 // CXnODTParser::ConstructL
       
   614 // Symbian 2nd phase constructor can leave.
       
   615 // -----------------------------------------------------------------------------
       
   616 //
       
   617 void CXnODTParser::ConstructL()
       
   618     {
       
   619     }
       
   620 
       
   621 // -----------------------------------------------------------------------------
       
   622 // CXnODTParser::LoadRootL
       
   623 // -----------------------------------------------------------------------------
       
   624 //
       
   625 void CXnODTParser::LoadRootL( CXnRootData& aRootData, TUid /*aAppUid*/ )        
       
   626     {    
       
   627     CXnDomNode* root( aRootData.Owner() );
       
   628     
       
   629     CXnDomStringPool& sp( root->StringPool() );
       
   630     
       
   631     CXnAppUiAdapter& appui( iManager.AppUiAdapter() );
       
   632     
       
   633     // Build root
       
   634     CXnNode* node( BuildRootNodeL( iUiEngine ) );
       
   635     
       
   636     // Let root nodes to know each other
       
   637     CXnDomNode* dom( aRootData.ODT()->DomDocument().RootNode() );    
       
   638     dom->SetLayoutNode( node );
       
   639     node->SetDomNode( dom );
       
   640         
       
   641     CreateNodesL( root, sp, aRootData );
       
   642 
       
   643     // root doesn't have any controls   
       
   644     
       
   645     aRootData.SetOccupied();
       
   646     }
       
   647 
       
   648 // -----------------------------------------------------------------------------
       
   649 // CXnODTParser::LoadViewL
       
   650 // -----------------------------------------------------------------------------
       
   651 //
       
   652 void CXnODTParser::LoadViewL( CXnViewData& aViewData )
       
   653     {    
       
   654     // <view> element
       
   655     CXnDomNode* view( aViewData.Node() );
       
   656     
       
   657     CXnDomStringPool& sp( view->StringPool() );
       
   658 
       
   659     // from <view> element
       
   660     CreateNodesL( view, sp, aViewData );       
       
   661     CreateControlsL( view, aViewData );
       
   662 
       
   663     // By default make controls invisible
       
   664     CXnControlAdapter* adapter( view->LayoutNode()->Control() );
       
   665     
       
   666     if( adapter )
       
   667         {
       
   668         adapter->MakeVisible( EFalse );
       
   669         }    
       
   670         
       
   671     aViewData.SetOccupied();
       
   672     }
       
   673 
       
   674 // -----------------------------------------------------------------------------
       
   675 // CXnODTParser::DestroyView
       
   676 // -----------------------------------------------------------------------------
       
   677 //
       
   678 void CXnODTParser::DestroyView( CXnViewData& aViewData )
       
   679     {
       
   680     CXnNode* view( aViewData.Node()->LayoutNode() );
       
   681     
       
   682     // Destroy view and all its child nodes
       
   683     CXnNode* parent( view->Parent() );
       
   684     
       
   685     RPointerArray< CXnNode >& children( parent->Children() );
       
   686     
       
   687     TInt index( children.Find( view ) );
       
   688     
       
   689     if ( index != KErrNotFound )
       
   690         {
       
   691         children.Remove( index );
       
   692         
       
   693         delete view;
       
   694         view = NULL;
       
   695         
       
   696         CXnDomNode* owner( aViewData.Owner() );
       
   697         owner->DeleteChild( aViewData.Node() );
       
   698         }    
       
   699     }
       
   700 
       
   701 // -----------------------------------------------------------------------------
       
   702 // CXnODTParser::LoadWidgetL
       
   703 // -----------------------------------------------------------------------------
       
   704 //
       
   705 void CXnODTParser::LoadWidgetL( CXnPluginData& aPluginData )
       
   706     {   
       
   707     if ( aPluginData.Empty() )
       
   708         {
       
   709         // Holds "empty" widget
       
   710         return;
       
   711         }
       
   712     
       
   713     // <widget> element
       
   714     CXnDomNode* widget( aPluginData.Node() );
       
   715     
       
   716     CXnDomStringPool& sp( widget->StringPool() );
       
   717 
       
   718     // from <widget> element 
       
   719     CreateNodesL( widget, sp, aPluginData );           
       
   720     CreateControlsL( widget, aPluginData );    
       
   721 
       
   722     HandleWidgetBackgroundL( widget->LayoutNode() );
       
   723 
       
   724     // By default make controls invisible
       
   725     CXnControlAdapter* adapter( widget->LayoutNode()->Control() );
       
   726     
       
   727     if( adapter )
       
   728         {
       
   729         adapter->MakeVisible( EFalse );
       
   730         }   
       
   731     
       
   732     aPluginData.SetOccupied();
       
   733     }
       
   734 
       
   735 // -----------------------------------------------------------------------------
       
   736 // CXnODTParser::DestroyWidget
       
   737 // -----------------------------------------------------------------------------
       
   738 //
       
   739 void CXnODTParser::DestroyWidgetL( CXnPluginData& aPluginData )
       
   740     {
       
   741     CXnViewData& parent( 
       
   742         static_cast< CXnViewData& >( *aPluginData.Parent() ) );
       
   743     
       
   744     // Check is any of plugin data's controls in views draw chain and remove
       
   745     CXnControlAdapter* control( parent.Node()->LayoutNode()->Control() );
       
   746 
       
   747     RPointerArray< CXnControlAdapter >& controls( control->ChildAdapters() );
       
   748 
       
   749     RPointerArray< CXnControlAdapter > pluginControls;
       
   750     CleanupClosePushL( pluginControls );
       
   751 
       
   752     aPluginData.ControlsL( pluginControls );
       
   753 
       
   754     // Remove from view chain if found
       
   755     for ( TInt i = 0; i < pluginControls.Count(); i++ )
       
   756         {
       
   757         CXnControlAdapter* control( pluginControls[i] );
       
   758 
       
   759         TInt index( controls.Find( control ) );
       
   760 
       
   761         if ( index != KErrNotFound )
       
   762             {
       
   763             controls.Remove( index );
       
   764             }
       
   765         }
       
   766 
       
   767     CleanupStack::PopAndDestroy( &pluginControls );
       
   768     
       
   769     CXnNode* widgetNode( aPluginData.Node()->LayoutNode() );
       
   770         
       
   771     CXnNode* owner( widgetNode->Parent() );
       
   772     
       
   773     RPointerArray< CXnNode >& children( owner->Children() );
       
   774     
       
   775     TInt index( children.Find( widgetNode ) );
       
   776     
       
   777     // Destroy widget and all its child nodes
       
   778     if ( index != KErrNotFound )
       
   779         {
       
   780         children.Remove( index );
       
   781         
       
   782         delete widgetNode;
       
   783         widgetNode = NULL;
       
   784        
       
   785         CXnDomNode* owner( aPluginData.Owner() );
       
   786         owner->DeleteChild( aPluginData.Node() );
       
   787         }
       
   788     
       
   789     owner->Control()->RemoveChildAdapters();
       
   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         CXnExtRenderingPluginWrapper* wrapper = 
       
  1099         	CXnExtRenderingPluginWrapper::NewL( aNode.PluginIfL(), *adapter );
       
  1100         CleanupStack::PushL( wrapper );
       
  1101 
       
  1102         parentAdapter->AppendChildL( *wrapper, aNode );
       
  1103         CleanupStack::Pop( wrapper );
       
  1104         
       
  1105         component->SetControlAdapter( wrapper );
       
  1106 
       
  1107         aNode.ComponentNodeImpl()->SetComponent( component );
       
  1108 
       
  1109         component->SetNode( aNode.PluginIfL() );
       
  1110 
       
  1111         wrapper->SetComponent( component );
       
  1112 
       
  1113         wrapper->SetComponentsToInheritVisibility( ETrue );
       
  1114 
       
  1115         wrapper->ActivateL();
       
  1116         
       
  1117         CleanupStack::Pop( component );
       
  1118 
       
  1119         return ETrue;
       
  1120         }
       
  1121     else
       
  1122         {
       
  1123         return EFalse;
       
  1124         }
       
  1125     }
       
  1126 
       
  1127 // CXnODTParser::CreateFactoryControlL()
       
  1128 // Creates factory control
       
  1129 // -----------------------------------------------------------------------------
       
  1130 //
       
  1131 void CXnODTParser::CreateFactoryControlL( CXnNode& aNode,
       
  1132     const TDesC8& aName )
       
  1133     {
       
  1134     CXnArray* factories = CXnArray::NewL();
       
  1135     CleanupStack::PushL( factories );
       
  1136 
       
  1137     TUid interfaceUid = { AI3_RENDERING_PLUGIN_ECOM_FACTORY_UID };
       
  1138 
       
  1139     iEcomHandler.PluginsL( interfaceUid, aName, *factories );
       
  1140 
       
  1141     CXnComponent* component( NULL );
       
  1142 
       
  1143     TInt count( factories->Container().Count() );
       
  1144     
       
  1145     // Invoke factory chain
       
  1146     for ( TInt i = 0; i < count; i++ )
       
  1147         {
       
  1148         MXnComponentFactory* factory =
       
  1149             static_cast< MXnComponentFactory* >(
       
  1150                 ( factories->Container() )[i] );
       
  1151                  
       
  1152         if ( factory->CreateXnComponentL( aNode.PluginIfL(), component ) == 
       
  1153             MXnComponentFactory::EXnFactoryResponseComponentConstructed )
       
  1154              
       
  1155             {
       
  1156             // All done
       
  1157             break;
       
  1158             }
       
  1159         }
       
  1160 
       
  1161     CleanupStack::PopAndDestroy( factories );
       
  1162     }
       
  1163 
       
  1164 // -----------------------------------------------------------------------------
       
  1165 // CXnODTParser::CreateBuiltInControlL()
       
  1166 // Creates builtin control
       
  1167 // -----------------------------------------------------------------------------
       
  1168 //
       
  1169 TBool CXnODTParser::CreateBuiltInControlL( CXnNode& aNode,
       
  1170     const TDesC8& aName )
       
  1171     {
       
  1172     if ( aName != KBoxNodeName && aName != KButtonNodeName &&
       
  1173          aName != KStylusPopupNodeName && aName != KScrollableBoxNodeName&& 
       
  1174          aName != KWidgetExtensionNodeName && 
       
  1175                   aName != KPopUpNodeName &&
       
  1176 		 aName != XnPropertyNames::listquerydialog::KListQueryDialog )         
       
  1177         {
       
  1178         return CreateExternalControlL( aNode, aName );
       
  1179         }
       
  1180 
       
  1181     CXnComponent* component = CXnComponent::NewL();
       
  1182     CleanupStack::PushL( component );
       
  1183 
       
  1184     CXnControlAdapter* parentAdapter( NULL );
       
  1185 
       
  1186     CXnProperty* position( aNode.PositionL() );
       
  1187 
       
  1188     if ( position )
       
  1189         {
       
  1190         const TDesC8& value( position->StringValue() );
       
  1191 
       
  1192         if ( value == XnPropertyNames::style::common::position::KFloating )
       
  1193             {
       
  1194             // Find view node and append floating control to its compound
       
  1195             for ( CXnNode* node = &aNode; node; node = node->Parent() )
       
  1196                 {
       
  1197                 if ( node->ViewNodeImpl() )
       
  1198                     {
       
  1199                     parentAdapter = node->Control();
       
  1200 
       
  1201                     break;
       
  1202                     }
       
  1203                 }
       
  1204             }
       
  1205         }
       
  1206 
       
  1207     if ( !parentAdapter )
       
  1208         {
       
  1209         // Find parent control
       
  1210         CXnNode* parent( aNode.Parent() );
       
  1211 
       
  1212         for ( ; parent; parent = parent->Parent() )
       
  1213             {
       
  1214             parentAdapter = parent->Control();
       
  1215 
       
  1216             if ( parentAdapter )
       
  1217                 {
       
  1218                 break;
       
  1219                 }
       
  1220             }
       
  1221         }
       
  1222 
       
  1223     CXnControlAdapter* adapter( NULL );
       
  1224     
       
  1225     if( aName == KStylusPopupNodeName )
       
  1226         {
       
  1227         adapter = CXnPopupControlAdapter::NewL( aNode.PluginIfL() );
       
  1228         CleanupStack::PushL( adapter );
       
  1229         }
       
  1230     else if( aName == KWidgetExtensionNodeName ||
       
  1231              aName == KPopUpNodeName )
       
  1232         {               
       
  1233         adapter = CXnWidgetExtensionAdapter::NewL( aNode.PluginIfL() );
       
  1234         CleanupStack::PushL( adapter );        
       
  1235         CXnProperty* prop = CXnProperty::NewL( 
       
  1236             XnPropertyNames::style::common::KPosition,
       
  1237             XnPropertyNames::style::common::position::KFloating,
       
  1238             CXnDomPropertyValue::EString, 
       
  1239             aNode.UiEngine()->ODT()->DomDocument().StringPool() );
       
  1240         CleanupStack::PushL( prop );
       
  1241         aNode.SetPropertyL( prop );                    
       
  1242         CleanupStack::Pop( prop );                                                        
       
  1243         }
       
  1244     else if( aName == KScrollableBoxNodeName )
       
  1245         {               
       
  1246         adapter = CXnScrollableControlAdapter::NewL( aNode.PluginIfL() );
       
  1247         CleanupStack::PushL( adapter );
       
  1248         }
       
  1249     else if( aName == XnPropertyNames::listquerydialog::KListQueryDialog )
       
  1250         {
       
  1251         CleanupStack::PopAndDestroy( component );
       
  1252         CXnListQueryDialog* listQuery = CXnListQueryDialog::NewL();
       
  1253         component = static_cast<CXnComponent*>( listQuery );
       
  1254         CleanupStack::PushL( component );
       
  1255         adapter = CXnListQueryDialogAdapter::NewL( aNode.PluginIfL() );
       
  1256         CleanupStack::PushL( adapter );
       
  1257         }
       
  1258     else
       
  1259         {
       
  1260         adapter = CXnControlAdapter::NewL( aNode.PluginIfL() );
       
  1261         CleanupStack::PushL( adapter );
       
  1262         }
       
  1263     
       
  1264     parentAdapter->AppendChildL( *adapter, aNode );
       
  1265     CleanupStack::Pop( adapter );
       
  1266     
       
  1267     component->SetControlAdapter( adapter );
       
  1268 
       
  1269     aNode.ComponentNodeImpl()->SetComponent( component );
       
  1270 
       
  1271     component->SetNode( aNode.PluginIfL() );
       
  1272 
       
  1273     adapter->SetComponent( component );
       
  1274 
       
  1275     adapter->SetComponentsToInheritVisibility( ETrue );
       
  1276 
       
  1277     adapter->ActivateL();
       
  1278     
       
  1279     CleanupStack::Pop( component );
       
  1280 
       
  1281     return ETrue;
       
  1282     }
       
  1283 
       
  1284 // --------------------------------------------------------------------------
       
  1285 // CXnODTParser::HandleWidgetBackgroundL()
       
  1286 //
       
  1287 // --------------------------------------------------------------------------
       
  1288 //
       
  1289 void CXnODTParser::HandleWidgetBackgroundL( CXnNode* aWidgetNode )
       
  1290     {
       
  1291     if( aWidgetNode )
       
  1292         {
       
  1293         CXnUiEngine* uiengine = aWidgetNode->UiEngine();
       
  1294         CXnProperty* bgImageProp = aWidgetNode->BackgroundImageL();
       
  1295         CXnProperty* bgColorProp = aWidgetNode->BackgroundColorL();
       
  1296         
       
  1297         // Set default bg color if it has not been defined by a widget
       
  1298         if( !bgImageProp && !bgColorProp && uiengine )
       
  1299             {
       
  1300             CXnDomPropertyValue* value = CXnDomPropertyValue::NewL(
       
  1301                 uiengine->ODT()->DomDocument().StringPool() );
       
  1302             CleanupStack::PushL( value );
       
  1303             value->SetStringValueL( CXnDomPropertyValue::EString, KWidgetBgSkinId );
       
  1304         
       
  1305             CXnProperty* bgColor = CXnProperty::NewL(
       
  1306                 XnPropertyNames::appearance::common::KBackGroundColor,
       
  1307                 value, uiengine->ODT()->DomDocument().StringPool() );
       
  1308         
       
  1309             CleanupStack::Pop( value );
       
  1310             CleanupStack::PushL( bgColor );
       
  1311             aWidgetNode->SetPropertyL( bgColor );
       
  1312             CleanupStack::Pop( bgColor );
       
  1313             }
       
  1314         }
       
  1315     }
       
  1316 
       
  1317 // End of file
       
  1318