idlehomescreen/xmluirendering/dom/src/xndomdocument.cpp
changeset 2 08c6ee43b396
parent 0 f72a12da539e
equal deleted inserted replaced
1:5315654608de 2:08c6ee43b396
    51 //
    51 //
    52 EXPORT_C CXnDomNode* CXnDomDocument::CreateElementNSL( 
    52 EXPORT_C CXnDomNode* CXnDomDocument::CreateElementNSL( 
    53     const TDesC8& aName, 
    53     const TDesC8& aName, 
    54     const TDesC8& aNamespace )
    54     const TDesC8& aNamespace )
    55     {
    55     {
    56     return CXnDomNode::NewL( aName, aNamespace, *iDomStringPool );
    56     return CXnDomNode::NewL( aName, aNamespace, iDomStringPool );
    57     }
    57     }
    58 // -----------------------------------------------------------------------------
    58 // -----------------------------------------------------------------------------
    59 // CXnDomDocument::CXnDomDocument
    59 // CXnDomDocument::CXnDomDocument
    60 // C++ default constructor can NOT contain any code, that
    60 // C++ default constructor can NOT contain any code, that
    61 // might leave.
    61 // might leave.
    71 // -----------------------------------------------------------------------------
    71 // -----------------------------------------------------------------------------
    72 //
    72 //
    73 void CXnDomDocument::ConstructL()
    73 void CXnDomDocument::ConstructL()
    74     {
    74     {
    75     iDomStringPool = CXnDomStringPool::NewL();
    75     iDomStringPool = CXnDomStringPool::NewL();
       
    76     // Add KNullDesC8 to string pool index 0 for safety reasons.
       
    77     // Some components use 0 as initial value for their string references.
       
    78     iDomStringPool->AddStringL( KNullDesC8 );
    76     }
    79     }
    77 
    80 
    78 // -----------------------------------------------------------------------------
    81 // -----------------------------------------------------------------------------
    79 // CXnDomDocument::NewL
    82 // CXnDomDocument::NewL
    80 // Two-phased constructor.
    83 // Two-phased constructor.
   189         }
   192         }
   190     
   193     
   191     TBool rootNodeExist( aStream.ReadInt8L() );
   194     TBool rootNodeExist( aStream.ReadInt8L() );
   192     if ( rootNodeExist )
   195     if ( rootNodeExist )
   193         {    
   196         {    
   194         iRootNode = CXnDomNode::NewL( aStream, *iDomStringPool );
   197         iRootNode = CXnDomNode::NewL( aStream, iDomStringPool );
   195         }
   198         }
   196     }          
   199     }          
   197 
   200 
   198 // -----------------------------------------------------------------------------
   201 // -----------------------------------------------------------------------------
   199 // CXnDomDocument::SetRootNode
   202 // CXnDomDocument::SetRootNode
   271 
   274 
   272 // -----------------------------------------------------------------------------
   275 // -----------------------------------------------------------------------------
   273 // CXnDomDocument::StringPool
   276 // CXnDomDocument::StringPool
   274 // -----------------------------------------------------------------------------
   277 // -----------------------------------------------------------------------------
   275 //
   278 //
   276 EXPORT_C CXnDomStringPool& CXnDomDocument::StringPool() const
   279 EXPORT_C CXnDomStringPool* CXnDomDocument::StringPool() const
   277     {
   280     {
   278     return *iDomStringPool;
   281     return iDomStringPool;
   279     }
   282     }
   280 
   283 
   281 // -----------------------------------------------------------------------------
   284 // -----------------------------------------------------------------------------
   282 // CXnDomDocument::ReadL
   285 // CXnDomDocument::ReadL
   283 // Read contents from a stream.
   286 // Read contents from a stream.
   284 // -----------------------------------------------------------------------------
   287 // -----------------------------------------------------------------------------
   285 //
   288 //
   286 EXPORT_C CXnDomNode* CXnDomDocument::ReadL( 
   289 EXPORT_C CXnDomNode* CXnDomDocument::ReadL( 
   287     RReadStream& aStream )
   290     RReadStream& aStream )
   288     { 
   291     {    
   289     CXnDomNode* rootNode = NULL;
   292     CXnDomStringPool* localStringPool = CXnDomStringPool::NewL( ETrue );
   290     
   293     CleanupStack::PushL( localStringPool );
   291     aStream >> *iDomStringPool;
   294     aStream >> *localStringPool;
       
   295     
       
   296     iDomStringPool->AddAllL( *localStringPool );
       
   297     
       
   298     CXnDomNode* rootNode = NULL;    
   292     
   299     
   293     TBool rootNodeExist( aStream.ReadInt8L() );
   300     TBool rootNodeExist( aStream.ReadInt8L() );
   294     if ( rootNodeExist )
   301     if ( rootNodeExist )
   295         {
   302         {
   296         rootNode = CXnDomNode::NewL( aStream, *iDomStringPool );
   303         rootNode = CXnDomNode::NewL( aStream, localStringPool );
   297         }
   304         CleanupStack::PushL( rootNode );
       
   305         rootNode->SwapStringPoolL( iDomStringPool );   
       
   306         CleanupStack::Pop( rootNode );
       
   307         }
       
   308         
       
   309     CleanupStack::PopAndDestroy( localStringPool );
   298     
   310     
   299     return rootNode;
   311     return rootNode;
   300     }
   312     }
   301 
   313 
   302 //  End of File  
   314 //  End of File