idlehomescreen/xmluirendering/dom/src/xndompropertyvalue.cpp
changeset 2 08c6ee43b396
parent 0 f72a12da539e
equal deleted inserted replaced
1:5315654608de 2:08c6ee43b396
    34 // CXnDomPropertyValue::CXnDomPropertyValue
    34 // CXnDomPropertyValue::CXnDomPropertyValue
    35 // C++ default constructor can NOT contain any code, that
    35 // C++ default constructor can NOT contain any code, that
    36 // might leave.
    36 // might leave.
    37 // -----------------------------------------------------------------------------
    37 // -----------------------------------------------------------------------------
    38 //
    38 //
    39 CXnDomPropertyValue::CXnDomPropertyValue( CXnDomStringPool& aStringPool ):
    39 CXnDomPropertyValue::CXnDomPropertyValue( CXnDomStringPool* aStringPool ):
    40     iStringPool( aStringPool ),	
    40     iStringPool( aStringPool ),	
    41     iPrimitiveValueType( (TPrimitiveValueType)KErrNotFound )
    41     iPrimitiveValueType( (TPrimitiveValueType)KErrNotFound )
    42     {
    42     {
    43     }
    43     }
    44 
    44 
    55 // CXnDomPropertyValue::NewL
    55 // CXnDomPropertyValue::NewL
    56 // Two-phased constructor.
    56 // Two-phased constructor.
    57 // -----------------------------------------------------------------------------
    57 // -----------------------------------------------------------------------------
    58 //
    58 //
    59 EXPORT_C CXnDomPropertyValue* CXnDomPropertyValue::NewL( 
    59 EXPORT_C CXnDomPropertyValue* CXnDomPropertyValue::NewL( 
    60     CXnDomStringPool& aStringPool )
    60     CXnDomStringPool* aStringPool )
    61     {
    61     {
    62     CXnDomPropertyValue* self = new( ELeave ) CXnDomPropertyValue( aStringPool );
    62     CXnDomPropertyValue* self = new( ELeave ) CXnDomPropertyValue( aStringPool );
    63     
    63     
    64     CleanupStack::PushL( self );
    64     CleanupStack::PushL( self );
    65     self->ConstructL();
    65     self->ConstructL();
    72 // Two-phased stream constructor.
    72 // Two-phased stream constructor.
    73 // -----------------------------------------------------------------------------
    73 // -----------------------------------------------------------------------------
    74 //
    74 //
    75 CXnDomPropertyValue* CXnDomPropertyValue::NewL( 
    75 CXnDomPropertyValue* CXnDomPropertyValue::NewL( 
    76     RReadStream& aStream,
    76     RReadStream& aStream,
    77     CXnDomStringPool& aStringPool )
    77     CXnDomStringPool* aStringPool )
    78     {
    78     {
    79     CXnDomPropertyValue* self = new( ELeave ) CXnDomPropertyValue( aStringPool );
    79     CXnDomPropertyValue* self = new( ELeave ) CXnDomPropertyValue( aStringPool );
    80     
    80     
    81     CleanupStack::PushL( self );
    81     CleanupStack::PushL( self );
    82     aStream >> *self;
    82     aStream >> *self;
   160 // Make a copy from this object
   160 // Make a copy from this object
   161 // -----------------------------------------------------------------------------
   161 // -----------------------------------------------------------------------------
   162 //
   162 //
   163 CXnDomPropertyValue* CXnDomPropertyValue::CloneL( CXnDomStringPool& aStringPool )
   163 CXnDomPropertyValue* CXnDomPropertyValue::CloneL( CXnDomStringPool& aStringPool )
   164     {
   164     {
   165     CXnDomPropertyValue* clone = CXnDomPropertyValue::NewL( aStringPool );
   165     CXnDomPropertyValue* clone = CXnDomPropertyValue::NewL( &aStringPool );
   166     CleanupStack::PushL( clone );
   166     CleanupStack::PushL( clone );
   167     clone->iPrimitiveValueType = iPrimitiveValueType;
   167     clone->iPrimitiveValueType = iPrimitiveValueType;
   168     
   168     
   169     
   169     
   170     switch( iPrimitiveValueType )
   170     switch( iPrimitiveValueType )
   197 	    case EIdent:
   197 	    case EIdent:
   198 	    case EUri:
   198 	    case EUri:
   199 	    case EAttr:
   199 	    case EAttr:
   200 	    case EUnknown:
   200 	    case EUnknown:
   201 	        {
   201 	        {
   202 	        const TDesC8& value = iStringPool.String( iData.iStringRef );
   202 	        const TDesC8& value = iStringPool->String( iData.iStringRef );
   203             clone->iData.iStringRef = aStringPool.AddStringL( value );
   203             clone->iData.iStringRef = aStringPool.AddStringL( value );
   204 	        clone->iIdent = iIdent;
   204 	        clone->iIdent = iIdent;
   205 	        break;
   205 	        break;
   206 	        }
   206 	        }
   207 
   207 
   325 	        User::Leave( KErrNotSupported );
   325 	        User::Leave( KErrNotSupported );
   326 	        break;
   326 	        break;
   327         }
   327         }
   328     
   328     
   329     
   329     
   330     return iStringPool.String( iData.iStringRef );
   330     return iStringPool->String( iData.iStringRef );
   331     }
   331     }
   332 // -----------------------------------------------------------------------------
   332 // -----------------------------------------------------------------------------
   333 // const TDesC& CXnDomPropertyValue::StringValue
   333 // const TDesC& CXnDomPropertyValue::StringValue
   334 // Returns the string value
   334 // Returns the string value
   335 // -----------------------------------------------------------------------------
   335 // -----------------------------------------------------------------------------
   350             return KNullDesC8;
   350             return KNullDesC8;
   351            
   351            
   352         }
   352         }
   353     
   353     
   354     
   354     
   355     return iStringPool.String( iData.iStringRef );
   355     return iStringPool->String( iData.iStringRef );
   356     }
   356     }
   357 // -----------------------------------------------------------------------------
   357 // -----------------------------------------------------------------------------
   358 // TReal CXnDomPropertyValue::SetStringValueL
   358 // TReal CXnDomPropertyValue::SetStringValueL
   359 // Sets the string value
   359 // Sets the string value
   360 // -----------------------------------------------------------------------------
   360 // -----------------------------------------------------------------------------
   380         }
   380         }
   381     
   381     
   382     ReleaseData();
   382     ReleaseData();
   383     
   383     
   384     iPrimitiveValueType = aValueType;
   384     iPrimitiveValueType = aValueType;
   385     TInt stringRef = iStringPool.AddStringL( aStringValue );
   385     TInt stringRef = iStringPool->AddStringL( aStringValue );
   386     iData.iStringRef = stringRef;
   386     iData.iStringRef = stringRef;
   387     
   387     
   388     if ( aStringValue.Compare( KAuto ) == 0 )
   388     if ( aStringValue.Compare( KAuto ) == 0 )
   389         {
   389         {
   390         iIdent = EAuto;
   390         iIdent = EAuto;
   570 	    default:
   570 	    default:
   571 	         User::Leave( KErrNotSupported );
   571 	         User::Leave( KErrNotSupported );
   572         }
   572         }
   573     return iData.iStringRef;    
   573     return iData.iStringRef;    
   574     }
   574     }
   575     
   575 
       
   576 // -----------------------------------------------------------------------------
       
   577 // CXnDomPropertyValue::SwapStringPoolL
       
   578 // -----------------------------------------------------------------------------
       
   579 //
       
   580 EXPORT_C void CXnDomPropertyValue::SwapStringPoolL( CXnDomStringPool* aStringPool )
       
   581     {
       
   582     if( !aStringPool )
       
   583         {
       
   584         User::Leave( KErrArgument );
       
   585         }
       
   586 
       
   587     if( iPrimitiveValueType == EString ||
       
   588         iPrimitiveValueType == EIdent ||
       
   589         iPrimitiveValueType == EUri ||
       
   590         iPrimitiveValueType == EAttr ||
       
   591         iPrimitiveValueType == EUnknown )
       
   592         {
       
   593         if( iData.iStringRef != NULL &&
       
   594             iData.iStringRef != -1 )
       
   595             {
       
   596             iData.iStringRef =
       
   597                     aStringPool->AddStringL( iStringPool->String( iData.iStringRef ) );
       
   598             }
       
   599         }
       
   600     
       
   601     iStringPool = aStringPool;
       
   602     }
       
   603 
   576 // -----------------------------------------------------------------------------
   604 // -----------------------------------------------------------------------------
   577 // CXnDomPropertyValue::Size()const
   605 // CXnDomPropertyValue::Size()const
   578 // Count size of this object's data.
   606 // Count size of this object's data.
   579 // -----------------------------------------------------------------------------
   607 // -----------------------------------------------------------------------------
   580 //
   608 //
   731 	    case EUri:
   759 	    case EUri:
   732 	    case EAttr:
   760 	    case EAttr:
   733 	    case EUnknown:
   761 	    case EUnknown:
   734             {
   762             {
   735             aStream >> iData.iStringRef;
   763             aStream >> iData.iStringRef;
   736             iData.iStringRef += iStringPool.Offset();
       
   737             iIdent = static_cast<TIdentType>( aStream.ReadInt8L() );
   764             iIdent = static_cast<TIdentType>( aStream.ReadInt8L() );
   738             }
   765             }
   739             break;
   766             break;
   740         case ERgbColor:
   767         case ERgbColor:
   741         case ERgbaColor:
   768         case ERgbaColor: