idlehomescreen/xmluirendering/dom/src/xndomproperty.cpp
changeset 2 08c6ee43b396
parent 0 f72a12da539e
equal deleted inserted replaced
1:5315654608de 2:08c6ee43b396
    28 // CXnDomProperty::CXnDomProperty
    28 // CXnDomProperty::CXnDomProperty
    29 // C++ default constructor can NOT contain any code, that
    29 // C++ default constructor can NOT contain any code, that
    30 // might leave.
    30 // might leave.
    31 // -----------------------------------------------------------------------------
    31 // -----------------------------------------------------------------------------
    32 //
    32 //
    33 CXnDomProperty::CXnDomProperty( CXnDomStringPool& aStringPool ):
    33 CXnDomProperty::CXnDomProperty( CXnDomStringPool* aStringPool ):
    34     iStringPool( aStringPool )
    34     iStringPool( aStringPool )
    35     {
    35     {
    36     }
    36     }
    37 // -----------------------------------------------------------------------------
    37 // -----------------------------------------------------------------------------
    38 // CXnDomProperty::CXnDomProperty
    38 // CXnDomProperty::CXnDomProperty
    40 // might leave.
    40 // might leave.
    41 // -----------------------------------------------------------------------------
    41 // -----------------------------------------------------------------------------
    42 //
    42 //
    43 CXnDomProperty::CXnDomProperty( 
    43 CXnDomProperty::CXnDomProperty( 
    44     TInt16 aStringPoolIndex, 
    44     TInt16 aStringPoolIndex, 
    45     CXnDomStringPool& aStringPool ):
    45     CXnDomStringPool* aStringPool ):
    46     iStringPool( aStringPool ),
    46     iStringPool( aStringPool ),
    47     iNameRef( aStringPoolIndex )
    47     iNameRef( aStringPoolIndex )
    48     {
    48     {
    49     }    
    49     }    
    50 // -----------------------------------------------------------------------------
    50 // -----------------------------------------------------------------------------
    52 // Symbian 2nd phase constructor can leave.
    52 // Symbian 2nd phase constructor can leave.
    53 // -----------------------------------------------------------------------------
    53 // -----------------------------------------------------------------------------
    54 //
    54 //
    55 void CXnDomProperty::ConstructL( const TDesC8& aName )
    55 void CXnDomProperty::ConstructL( const TDesC8& aName )
    56     {
    56     {
    57     iNameRef = iStringPool.AddStringL( aName );
    57     iNameRef = iStringPool->AddStringL( aName );
    58     iPropValList = CXnDomList::NewL( CXnDomList::EPropertyValueList, iStringPool );
    58     iPropValList = CXnDomList::NewL( CXnDomList::EPropertyValueList, iStringPool );
    59     }
    59     }
    60 // -----------------------------------------------------------------------------
    60 // -----------------------------------------------------------------------------
    61 // CXnDomProperty::ConstructL
    61 // CXnDomProperty::ConstructL
    62 // Symbian 2nd phase constructor can leave.
    62 // Symbian 2nd phase constructor can leave.
    71 // Two-phased constructor.
    71 // Two-phased constructor.
    72 // -----------------------------------------------------------------------------
    72 // -----------------------------------------------------------------------------
    73 //
    73 //
    74 EXPORT_C CXnDomProperty* CXnDomProperty::NewL( 
    74 EXPORT_C CXnDomProperty* CXnDomProperty::NewL( 
    75     const TDesC8& aName,
    75     const TDesC8& aName,
    76     CXnDomStringPool& aStringPool )
    76     CXnDomStringPool* aStringPool )
    77     {
    77     {
    78     CXnDomProperty* self = new( ELeave ) CXnDomProperty( aStringPool );
    78     CXnDomProperty* self = new( ELeave ) CXnDomProperty( aStringPool );
    79     
    79     
    80     CleanupStack::PushL( self );
    80     CleanupStack::PushL( self );
    81     self->ConstructL( aName );
    81     self->ConstructL( aName );
    89 // Two-phased stream constructor.
    89 // Two-phased stream constructor.
    90 // -----------------------------------------------------------------------------
    90 // -----------------------------------------------------------------------------
    91 //
    91 //
    92 CXnDomProperty* CXnDomProperty::NewL( 
    92 CXnDomProperty* CXnDomProperty::NewL( 
    93     RReadStream& aStream, 
    93     RReadStream& aStream, 
    94     CXnDomStringPool& aStringPool )
    94     CXnDomStringPool* aStringPool )
    95     {
    95     {
    96     CXnDomProperty* self = 
    96     CXnDomProperty* self = 
    97         new( ELeave ) CXnDomProperty( aStringPool );
    97         new( ELeave ) CXnDomProperty( aStringPool );
    98     
    98     
    99     CleanupStack::PushL( self );
    99     CleanupStack::PushL( self );
   108 // Two-phased constructor.
   108 // Two-phased constructor.
   109 // -----------------------------------------------------------------------------
   109 // -----------------------------------------------------------------------------
   110 //
   110 //
   111 EXPORT_C CXnDomProperty* CXnDomProperty::NewL( 
   111 EXPORT_C CXnDomProperty* CXnDomProperty::NewL( 
   112     TInt16 aStringPoolIndex,
   112     TInt16 aStringPoolIndex,
   113     CXnDomStringPool& aStringPool )
   113     CXnDomStringPool* aStringPool )
   114     {
   114     {
   115     CXnDomProperty* self = 
   115     CXnDomProperty* self = 
   116         new (ELeave) CXnDomProperty( aStringPoolIndex, aStringPool );
   116         new (ELeave) CXnDomProperty( aStringPoolIndex, aStringPool );
   117     CleanupStack::PushL( self );
   117     CleanupStack::PushL( self );
   118     self->ConstructL();
   118     self->ConstructL();
   155 // CXnDomProperty::CloneL
   155 // CXnDomProperty::CloneL
   156 // -----------------------------------------------------------------------------
   156 // -----------------------------------------------------------------------------
   157 //
   157 //
   158 EXPORT_C CXnDomProperty* CXnDomProperty::CloneL( CXnDomStringPool& aStringPool )
   158 EXPORT_C CXnDomProperty* CXnDomProperty::CloneL( CXnDomStringPool& aStringPool )
   159     {
   159     {
   160     const TDesC8& name = iStringPool.String( iNameRef );
   160     const TDesC8& name = iStringPool->String( iNameRef );
   161     CXnDomProperty* clone = CXnDomProperty::NewL( name, aStringPool );
   161     CXnDomProperty* clone = CXnDomProperty::NewL( name, &aStringPool );
   162     CleanupStack::PushL(clone);
   162     CleanupStack::PushL(clone);
   163     
   163     
   164     TInt count( iPropValList->Length() );
   164     TInt count( iPropValList->Length() );
   165     for (TInt i = 0; i < count; ++i)
   165     for (TInt i = 0; i < count; ++i)
   166         {
   166         {
   180 // CXnDomProperty::Name
   180 // CXnDomProperty::Name
   181 // -----------------------------------------------------------------------------
   181 // -----------------------------------------------------------------------------
   182 //
   182 //
   183 EXPORT_C const TDesC8& CXnDomProperty::Name()
   183 EXPORT_C const TDesC8& CXnDomProperty::Name()
   184     {
   184     {
   185     return iStringPool.String( iNameRef );
   185     return iStringPool->String( iNameRef );
   186     }
   186     }
   187 
   187 
   188 // -----------------------------------------------------------------------------
   188 // -----------------------------------------------------------------------------
   189 // CXnDomProperty::PropertyValue
   189 // CXnDomProperty::PropertyValue
   190 // -----------------------------------------------------------------------------
   190 // -----------------------------------------------------------------------------
   223 
   223 
   224 // -----------------------------------------------------------------------------
   224 // -----------------------------------------------------------------------------
   225 // CXnDomProperty::StringPool
   225 // CXnDomProperty::StringPool
   226 // -----------------------------------------------------------------------------
   226 // -----------------------------------------------------------------------------
   227 //        
   227 //        
   228 EXPORT_C CXnDomStringPool& CXnDomProperty::StringPool() const
   228 EXPORT_C CXnDomStringPool* CXnDomProperty::StringPool() const
   229     {
   229     {
   230     return iStringPool;
   230     return iStringPool;
   231     }                      
   231     }                      
   232 // -----------------------------------------------------------------------------
   232 // -----------------------------------------------------------------------------
   233 // CXnDomProperty::StringPoolIndex
   233 // CXnDomProperty::StringPoolIndex
   235 //        
   235 //        
   236 EXPORT_C TInt16 CXnDomProperty::StringPoolIndex()const
   236 EXPORT_C TInt16 CXnDomProperty::StringPoolIndex()const
   237     {
   237     {
   238     return iNameRef;    
   238     return iNameRef;    
   239     }
   239     }
       
   240 
       
   241 // -----------------------------------------------------------------------------
       
   242 // CXnDomProperty::SwapStringPoolL
       
   243 // -----------------------------------------------------------------------------
       
   244 //
       
   245 EXPORT_C void CXnDomProperty::SwapStringPoolL( CXnDomStringPool* aStringPool )
       
   246     {
       
   247     if( !aStringPool )
       
   248         {
       
   249         User::Leave( KErrArgument );
       
   250         }
       
   251     
       
   252     iNameRef = aStringPool->AddStringL( iStringPool->String( iNameRef ) );
       
   253 
       
   254     TInt count = iPropValList->Length();
       
   255     for( TInt i = 0; i < count; i++ )
       
   256         {
       
   257         CXnDomPropertyValue* val =
       
   258                 static_cast<CXnDomPropertyValue*>( iPropValList->Item(i) );
       
   259         val->SwapStringPoolL( aStringPool );
       
   260         }
       
   261 
       
   262     iStringPool = aStringPool;
       
   263     }
       
   264 
   240 // -----------------------------------------------------------------------------
   265 // -----------------------------------------------------------------------------
   241 // CXnDomProperty::PseudoClass
   266 // CXnDomProperty::PseudoClass
   242 // -----------------------------------------------------------------------------
   267 // -----------------------------------------------------------------------------
   243 //
   268 //
   244 EXPORT_C CXnDomProperty::TPseudoClass CXnDomProperty::PseudoClass() const
   269 EXPORT_C CXnDomProperty::TPseudoClass CXnDomProperty::PseudoClass() const
   286 // CXnDomProperty::InternalizeL
   311 // CXnDomProperty::InternalizeL
   287 // -----------------------------------------------------------------------------
   312 // -----------------------------------------------------------------------------
   288 //
   313 //
   289 void CXnDomProperty::InternalizeL( RReadStream& aStream )
   314 void CXnDomProperty::InternalizeL( RReadStream& aStream )
   290     {
   315     {
   291     iNameRef = aStream.ReadInt16L() + iStringPool.Offset();
   316     iNameRef = aStream.ReadInt16L();
   292     iPropValList = CXnDomList::NewL( aStream, iStringPool );
   317     iPropValList = CXnDomList::NewL( aStream, iStringPool );
   293     
   318     
   294     iInherited =  TBool( aStream.ReadInt8L() );
   319     iInherited =  TBool( aStream.ReadInt8L() );
   295     iPseudoClass = TPseudoClass( aStream.ReadInt8L() );
   320     iPseudoClass = TPseudoClass( aStream.ReadInt8L() );
   296     }
   321     }