widgetmodel/alfwidgetmodel/src/alftextvisualattributesetter.cpp
branchRCL_3
changeset 19 4ea6f81c838a
parent 17 514d98f21c43
child 20 0e9bb658ef58
equal deleted inserted replaced
17:514d98f21c43 19:4ea6f81c838a
     1 /*
       
     2 * Copyright (c) 2007 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:   Implements attributesetters for text.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //widget model includes
       
    20 #include "alf/alfattributecontainer.h"
       
    21 #include "alf/alfattributevaluetype.h"
       
    22 #include "alf/alfattribute.h"
       
    23 #include "alf/alftextvisualattributesetter.h"
       
    24 #include <alf/alfvisualexception.h>
       
    25 #include <alf/alfdataexception.h>
       
    26 #include <alf/alfattributeexception.h>
       
    27 #include <alf/alfwidgetenvextension.h>
       
    28 
       
    29 
       
    30 //osn includes
       
    31 #include <osn/ustring.h>
       
    32 
       
    33 //alf includes
       
    34 #include <alf/alfenv.h>
       
    35 #include <alf/alftextvisual.h>
       
    36 #include <alf/alftexture.h>
       
    37 #include <alf/alfeventhandler.h>
       
    38 #include <alf/alfevent.h>
       
    39 
       
    40 //dui includes
       
    41 #include "alf/attrproperty.h"
       
    42 
       
    43 //other includes
       
    44 #include <libc/string.h>
       
    45 #include <utf.h>
       
    46 
       
    47 
       
    48 //namespaces
       
    49 using namespace osncore;
       
    50 using namespace duiuimodel::textvisualattributes;
       
    51 using namespace duiuimodel::commonvisualattributes;
       
    52 using namespace duiuimodel::layoutattributes;
       
    53 
       
    54 namespace Alf
       
    55     {
       
    56 
       
    57 
       
    58 // ======== MEMBER FUNCTIONS ========
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // Constructor.
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 OSN_EXPORT AlfTextVisualAttributeSetter::AlfTextVisualAttributeSetter()
       
    65     {
       
    66     }
       
    67 
       
    68 // ---------------------------------------------------------------------------
       
    69 // Destructor.
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 OSN_EXPORT AlfTextVisualAttributeSetter::~AlfTextVisualAttributeSetter()
       
    73     {
       
    74     }
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // Sets Attribute Value. Delegates based on attribute Category.
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 OSN_EXPORT void AlfTextVisualAttributeSetter::setAttributeValue (
       
    81     CAlfVisual &aVisual,
       
    82     AlfAttributeContainer* aContainer,
       
    83     IAlfMap* aData )
       
    84     {
       
    85     CAlfTextVisual* textVisual = dynamic_cast<CAlfTextVisual*> ( &aVisual );
       
    86 
       
    87     if ( !textVisual )
       
    88         {
       
    89         ALF_THROW ( AlfVisualException, EInvalidVisual, "AlfTextVisualAttributeSetter" )
       
    90         }
       
    91 
       
    92     AlfCommonVisualAttributeSetter::setAttributeValue(aVisual,
       
    93             aContainer, aData);
       
    94     }
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // Deprecated
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 OSN_EXPORT TAlfCommand* AlfTextVisualAttributeSetter::createCommand (
       
   101     CAlfVisual& /*aVisual*/, AlfAttributeContainer* /*aContainer*/,
       
   102     IAlfMap* /*aData*/, int /*aTransitionTime*/, CAlfVisual* /*aRefVisual*/ )
       
   103     {
       
   104     //deprecated
       
   105     TAlfCommand* cmd = NULL;
       
   106     return cmd;
       
   107     }
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // Sends a command to Env
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 OSN_EXPORT void AlfTextVisualAttributeSetter::createAndSendCommands (
       
   114     CAlfVisual& aVisual,
       
   115     AlfAttributeContainer* aContainer,
       
   116     CAlfVisual* aRefVisual )
       
   117     {
       
   118     //ShadowOpacity command can be sent as a TAlfCustomEventCommand
       
   119 
       
   120     AlfCommonVisualAttributeSetter::createAndSendCommands (
       
   121         aVisual, aContainer, aRefVisual );
       
   122     }
       
   123 
       
   124 
       
   125 // ---------------------------------------------------------------------------
       
   126 // Sets dynamic attributes to visual
       
   127 // ---------------------------------------------------------------------------
       
   128 //
       
   129 void AlfTextVisualAttributeSetter::handleDynamicAttribute ( CAlfVisual &aVisual, 
       
   130 	                                                        AlfAttribute& aAttr, 
       
   131 	                                                        AlfAttributeContainer& aContainer)
       
   132     {
       
   133     const char* attrName = aAttr.name();
       
   134     CAlfTextVisual* textVisual = dynamic_cast<CAlfTextVisual*> ( &aVisual );
       
   135     if(textVisual == 0)
       
   136         {
       
   137         return;
       
   138         }
       
   139 
       
   140     if ( !strcmp ( attrName, KShadowOpacity ) )
       
   141         {
       
   142         TAlfTimedValue tVal ( ( TReal32 ) aAttr.getSourceValue()->realValue() );
       
   143         tVal.SetTarget ( ( TReal32 ) aAttr.getTargetValue()->realValue(), ( TInt ) aAttr.getTime() );
       
   144         tVal.SetStyle ( aAttr.getInterpolationStyle() );
       
   145         tVal.SetMappingFunctionIdentifier ( aAttr.getMappingFunctionId());
       
   146         textVisual->SetShadowOpacity ( tVal );
       
   147         }
       
   148     else
       
   149         {
       
   150         AlfCommonVisualAttributeSetter::handleDynamicAttribute( aVisual, aAttr, aContainer);
       
   151         }
       
   152     }
       
   153 
       
   154 // ---------------------------------------------------------------------------
       
   155 // Sets static attributes to visual
       
   156 // ---------------------------------------------------------------------------
       
   157 //
       
   158 void AlfTextVisualAttributeSetter::handleStaticAttribute( CAlfVisual& aVisual, 
       
   159                                                           AlfAttribute& aAttr, 
       
   160                                                           AlfAttributeContainer& aContainer)
       
   161     {
       
   162     const char* attrName = aAttr.name();
       
   163     CAlfTextVisual* textVisual = dynamic_cast<CAlfTextVisual*> ( &aVisual );
       
   164     if (!textVisual)
       
   165         {
       
   166         ALF_THROW ( AlfDataException, ECommonError, "AlfTextVisualAttributeSetter" )
       
   167         }
       
   168 
       
   169     if ( !strcmp ( attrName, KLineWrap ) )
       
   170         {
       
   171         textVisual->SetWrapping ( (CAlfTextVisual::TLineWrap)aAttr.intValue() );
       
   172         }
       
   173 
       
   174     else if ( !strcmp ( attrName, KLineSpacing ) )
       
   175     	{
       
   176         try
       
   177             {
       
   178             AlfAttribute* linespacingunitsAttr = &aContainer.getAttributeByName ( KLineSpacingUnits );
       
   179 
       
   180             //a line spacing units attribute was found
       
   181             textVisual->SetLineSpacing ( aAttr.intValue(), 
       
   182             	(CAlfTextVisual::TLineSpacingUnits)linespacingunitsAttr->intValue() );
       
   183             }
       
   184 
       
   185         catch ( AlfDataException& e )
       
   186             {
       
   187             //a line spacing units attribute was not found or it was of invalid data type... Use default...
       
   188             textVisual->SetLineSpacing ( aAttr.intValue() );
       
   189             }
       
   190         }
       
   191 
       
   192     else if ( !strcmp ( attrName, KPreconfiguredStyle ) )
       
   193         {
       
   194         try
       
   195             {
       
   196             AlfAttribute* backgroundtypeAttr = &aContainer.getAttributeByName ( KBackgroundType );
       
   197 
       
   198             //a background type attribute was found
       
   199             textVisual->SetStyle ( ( TAlfPreconfiguredTextStyle ) aAttr.intValue(), 
       
   200             	(TAlfBackgroundType)backgroundtypeAttr->intValue() );
       
   201             }
       
   202         catch ( AlfDataException& e )
       
   203             {
       
   204             //no background type attribute found or it was of invalid data type... Use default...
       
   205             textVisual->SetStyle ( ( TAlfPreconfiguredTextStyle ) aAttr.intValue() );
       
   206             }
       
   207         }
       
   208     else if ( !strcmp ( attrName, KText ) )
       
   209         {
       
   210         TPtrC8 src;
       
   211         src.Set ( ( TUint8* ) aAttr.stringValue().getUtf8() );
       
   212         HBufC* desC = NULL;
       
   213         
       
   214         TRAPD(err1, desC = CnvUtfConverter::ConvertToUnicodeFromUtf8L ( src ));
       
   215         if (err1 != KErrNone)
       
   216             {
       
   217             ALF_THROW ( AlfDataException, ECommonError, "AlfTextVisualAttributeSetter" )
       
   218             }
       
   219 
       
   220         if ( desC )
       
   221             {
       
   222             TRAPD(err2, textVisual->SetTextL ( *desC ));
       
   223             delete desC;
       
   224             if (err2 != KErrNone)
       
   225                 {
       
   226                 ALF_THROW ( AlfDataException, ECommonError, "AlfTextVisualAttributeSetter" )
       
   227                 }
       
   228             }
       
   229         }
       
   230     else if ( !strcmp ( attrName, KTextSkinColorId ) )
       
   231         {
       
   232 	     
       
   233 	        
       
   234 	    // Retrieve Skin Color Table index
       
   235 	    try
       
   236 	    	{
       
   237 	    	// colorIndex will not be null. Throws if attribute not found.
       
   238 	    	AlfAttribute* colorIndex = &aContainer.getAttributeByName ( KTextColorSkinIndex );
       
   239 	    	setTextSkinColor(*textVisual, aAttr.stringValue().getUtf8(), colorIndex->stringValue().getUtf8()); 
       
   240 	    	}
       
   241 	    catch(AlfDataException& e)
       
   242 	    	{
       
   243 	    	// Error in getting the color index. use default value.	  
       
   244 	    	setTextSkinColor(*textVisual, aAttr.stringValue().getUtf8());	
       
   245 	    	}
       
   246 	    	
       
   247         }
       
   248     else if (!strcmp (attrName, KLocalisationText) ) // Support for Localised text
       
   249         {
       
   250         
       
   251         AlfAttribute* langAttr=NULL;
       
   252         AlfAttribute* varArgsAttr=NULL;
       
   253 	   
       
   254         // Get the language attribute
       
   255 	    try
       
   256 	    	{
       
   257 	    	// Retrieve the language attribute.	
       
   258 	    	langAttr = &aContainer.getAttributeByName ( KLang );
       
   259 	    	}
       
   260 	    catch(AlfDataException& e)
       
   261 	    	{
       
   262 	    	// Nothing to do here. just continue.
       
   263 	    	}
       
   264 	    
       
   265 	    // Get the varargs attribute.
       
   266 	    try
       
   267 	    	{
       
   268 	    	varArgsAttr = &aContainer.getAttributeByName ( KVarArgs );
       
   269 	    	}
       
   270 	    catch(AlfDataException& e)
       
   271 	    	{
       
   272 	    	// Nothing to do here. just continue.
       
   273 	    	}
       
   274 	    setLocalisedText(*textVisual,aAttr.stringValue().getUtf8(),langAttr,varArgsAttr);	
       
   275 	    
       
   276         }
       
   277     else if ( !strcmp ( attrName, KTextColor ) )
       
   278         {
       
   279         if ( 4 == aAttr.getTargetValueCount() && AlfAttributeValueType::EInt == aAttr.type(0) && 
       
   280              AlfAttributeValueType::EInt == aAttr.type(1) && AlfAttributeValueType::EInt == aAttr.type(2) && 
       
   281              AlfAttributeValueType::EInt == aAttr.type(3))
       
   282             {
       
   283             TRgb color ( aAttr.intValue(0), aAttr.intValue(1), aAttr.intValue(2), aAttr.intValue(3) );
       
   284             textVisual->SetColor( color );
       
   285             }
       
   286         else
       
   287             {
       
   288             ALF_THROW ( AlfAttributeException, EInvalidAttribute, "AlfTextVisualAttributeSetter" );
       
   289             }
       
   290         }
       
   291     else if ( !strcmp ( attrName, KTextColorSkinIndex ) )
       
   292         {
       
   293         // Do nothing.
       
   294         // This attribute will be used in some other iteration in the
       
   295         // else-if block that uses KTextSkinColorId
       
   296         }
       
   297     else if ( !strcmp ( attrName, KBackgroundType ) )
       
   298         {
       
   299         // Can not do anything with background type alone.
       
   300         // Do nothing.
       
   301         // This attribute will be used in some other iteration in the
       
   302         // else-if block that uses KPreconfiguredStyle
       
   303         }
       
   304     else if ( !strcmp ( attrName, KLineSpacingUnits ) )
       
   305         {
       
   306         // Can not do anything with line spacing units alone.
       
   307         // Do nothing.
       
   308         // This attribute will be used in some other iteration in the
       
   309         // else-if block that uses KLineSpacing
       
   310         }
       
   311     else if ( !strcmp ( attrName, KStyle ) )
       
   312         {
       
   313         textVisual->SetTextStyle ( aAttr.intValue() );
       
   314         }
       
   315     else if ( !strcmp ( attrName, KFont ) )
       
   316         {
       
   317         //not supported, no API in textvisual
       
   318         }
       
   319     else if ( !strcmp ( attrName, KVerticalAlign ) )
       
   320         {
       
   321         AlfAttribute* horzalignAttr = &aContainer.getAttributeByName ( KHorizontalAlign );
       
   322         //will throw if attribute is not found
       
   323 
       
   324         textVisual->SetAlign ( ( TAlfAlignHorizontal ) horzalignAttr->intValue(),
       
   325                                ( TAlfAlignVertical ) aAttr.intValue() );
       
   326         }
       
   327     else if ( !strcmp ( attrName, KHorizontalAlign ) )
       
   328         {
       
   329         // Do nothing.
       
   330         // This attribute will be used in some other iteration in the
       
   331         // else-if block that uses KVerticalAlign
       
   332         }
       
   333     else if ( !strcmp ( attrName, KMaxLineCount ) )
       
   334         {
       
   335         if (aAttr.type(0) == AlfAttributeValueType::EInt)
       
   336             {
       
   337             textVisual->SetMaxLineCount ( aAttr.intValue() );
       
   338             }
       
   339         else if (aAttr.type(0) == AlfAttributeValueType::EFloat)
       
   340             {
       
   341             textVisual->SetMaxLineCount ( aAttr.realValue() );
       
   342             }
       
   343         else
       
   344             {
       
   345             ALF_THROW ( AlfAttributeException, EInvalidAttribute, "AlfTextVisualAttributeSetter" );            
       
   346             }
       
   347         
       
   348         }
       
   349     else if ( !strcmp ( attrName, KEnableShadow ) )
       
   350         {
       
   351         int enableShadow = aAttr.intValue();
       
   352         TBool flag = ETrue;                      //Assume true for any non-zero value.
       
   353         if ( 0 == enableShadow )
       
   354         	{
       
   355         	flag = EFalse;
       
   356         	}
       
   357         textVisual->EnableShadow ( flag );
       
   358         }
       
   359     else
       
   360         {
       
   361         AlfCommonVisualAttributeSetter::handleStaticAttribute(
       
   362             aVisual, aAttr, aContainer);
       
   363         }
       
   364     }
       
   365 
       
   366 // ---------------------------------------------------------------------------
       
   367 // Sets dynamic attributes to visual from data
       
   368 // ---------------------------------------------------------------------------
       
   369 //
       
   370 void AlfTextVisualAttributeSetter::handleDynamicDataAttribute (
       
   371     CAlfVisual &aVisual, AlfAttribute& aAttr,
       
   372     AlfAttributeContainer& aContainer, IAlfMap* aData )
       
   373     {
       
   374     //Shadow opacity can be supported
       
   375     AlfCommonVisualAttributeSetter::handleDynamicDataAttribute(aVisual, aAttr,
       
   376             aContainer, aData);
       
   377     }
       
   378 
       
   379 // ---------------------------------------------------------------------------
       
   380 // Sets static attributes to visual  from data
       
   381 // ---------------------------------------------------------------------------
       
   382 //
       
   383 void AlfTextVisualAttributeSetter::handleStaticDataAttribute ( CAlfVisual &aVisual, AlfAttribute& aAttr, AlfAttributeContainer& aContainer, IAlfMap* aData )
       
   384     {
       
   385     const char* dataField = aAttr.getDataField();
       
   386 
       
   387 	// throw if datafield name or data is not set
       
   388     if ( !dataField )
       
   389     	{
       
   390     	ALF_THROW ( AlfDataException, ECommonError, "AlfTextVisualAttributeSetter" )
       
   391     	}
       
   392 
       
   393     if (!aData)
       
   394     	{
       
   395     	ALF_THROW ( AlfDataException, ECommonError, "AlfTextVisualAttributeSetter" )
       
   396     	}
       
   397 
       
   398     IAlfVariantType* data = aData->item ( UString(dataField));
       
   399     const char* attrName = aAttr.name();
       
   400 
       
   401     CAlfTextVisual* textVisual = dynamic_cast<CAlfTextVisual*> ( &aVisual );
       
   402     if(textVisual == 0)
       
   403         {
       
   404         ALF_THROW ( AlfDataException, ECommonError, "AlfTextVisualAttributeSetter" )
       
   405         }
       
   406 
       
   407     if ( !strcmp ( attrName, KLineWrap ) )
       
   408         {
       
   409         if ( data && data->type() == IAlfVariantType::EInt )
       
   410             {
       
   411             textVisual->SetWrapping ( ( CAlfTextVisual::TLineWrap ) data->integer() );
       
   412             }
       
   413         }
       
   414     else if ( !strcmp ( attrName, KText ) )
       
   415         {
       
   416         if ( data && data->type() == IAlfVariantType::EString )
       
   417             {
       
   418             TPtrC8 src;
       
   419             src.Set ( ( TUint8* ) data->string().getUtf8() );
       
   420             HBufC* desC = NULL;
       
   421             TRAPD(err1, desC = CnvUtfConverter::ConvertToUnicodeFromUtf8L ( src ));
       
   422             if (err1 != KErrNone)
       
   423             	{
       
   424             	ALF_THROW ( AlfDataException, ECommonError, "AlfTextVisualAttributeSetter" )
       
   425             	}
       
   426 
       
   427             if ( desC )
       
   428                 {
       
   429                 TRAPD(err2, textVisual->SetTextL ( *desC ));
       
   430                 delete desC;
       
   431                 if (err2 != KErrNone) 
       
   432                 	{
       
   433                 	ALF_THROW ( AlfDataException, ECommonError, "AlfTextVisualAttributeSetter" )
       
   434                 	}
       
   435                 }
       
   436             }
       
   437         }
       
   438     else if (!strcmp (attrName, KLocalisationText) ) // Support for Localised text
       
   439         {           
       
   440             
       
   441         AlfAttribute* langAttr=NULL;
       
   442         AlfAttribute* varArgsAttr=NULL;            
       
   443 	        
       
   444 	    	// Retrieve the language attribute.
       
   445 	    	if ( data && data->type() == IAlfVariantType::EString )
       
   446 	    		{   		
       
   447 	    	
       
   448 	    		try
       
   449 	    			{
       
   450 	    			langAttr = &aContainer.getAttributeByName ( KLang );
       
   451 	    			}
       
   452 	    		catch(AlfDataException& e)
       
   453 	    			{
       
   454 	    			// Nothing to do here .Just continue.
       
   455 	    			}
       
   456 	    		try
       
   457 	    			{
       
   458 	    			varArgsAttr = &aContainer.getAttributeByName ( KVarArgs );	    			
       
   459 	    			}
       
   460 	    		catch(AlfDataException& e)
       
   461 	    			{
       
   462 	    			// Nothing to do here .Just continue.
       
   463 	    			}
       
   464 	    		setLocalisedText(*textVisual, data->string().getUtf8(),langAttr,varArgsAttr); 
       
   465 	    		}	    		
       
   466 	    		
       
   467         }
       
   468 
       
   469     else if ( !strcmp ( attrName, KTextColor ) )
       
   470         {
       
   471         if ( data && data->type() == IAlfVariantType::EContainer )
       
   472             {
       
   473             IAlfContainer* dataContainer = data->container();
       
   474 
       
   475             if ( 4 != dataContainer -> count() )
       
   476             	{
       
   477             	ALF_THROW ( AlfDataException, EInvalidAttribute, "AlfTextVisualAttributeSetter" )
       
   478             	}
       
   479 
       
   480             IAlfVariantType* red = dataContainer->item ( 0 ); //red
       
   481             IAlfVariantType* green = dataContainer->item ( 1 ); //green
       
   482             IAlfVariantType* blue = dataContainer->item ( 2 ); //blue
       
   483             IAlfVariantType* alpha = dataContainer->item ( 3 ); //alpha
       
   484 
       
   485             if ( red && IAlfVariantType::EInt == red->type() && 
       
   486                  green && IAlfVariantType::EInt == green->type() && 
       
   487                  blue && IAlfVariantType::EInt == blue->type() && 
       
   488                  alpha && IAlfVariantType::EInt == alpha->type() )
       
   489                 {
       
   490                 TRgb color ( red->integer(), green->integer(), blue->integer(), alpha->integer() );
       
   491                 textVisual->SetColor ( color );
       
   492                 }
       
   493             }
       
   494         }
       
   495     else if ( !strcmp ( attrName, KTextSkinColorId ) )
       
   496         {
       
   497         if ( data && data->type() == IAlfVariantType::EString )
       
   498             {
       
   499             
       
   500             try
       
   501     			{
       
   502 		 		// Retrieve skin color table index			
       
   503     			AlfAttribute* colorIndex = &aContainer.getAttributeByName(
       
   504 					KTextColorSkinIndex); // colorIndex will not be null. Throws if not found.
       
   505 					
       
   506 				const char* colorIndexDataField = colorIndex->getDataField();
       
   507 				IAlfVariantType* colorIndexData =
       
   508 					aData->item(UString(colorIndexDataField));
       
   509 				if(colorIndexData && colorIndexData->type() == IAlfVariantType::EString)
       
   510 					{
       
   511     				setTextSkinColor(*textVisual, data->string().getUtf8(),
       
   512     								 colorIndexData->string().getUtf8());
       
   513     				}
       
   514     			}
       
   515     		catch(AlfDataException& e)
       
   516     			{
       
   517     			// No color index found. Use default value. 	
       
   518     			setTextSkinColor(*textVisual, data->string().getUtf8());	    				
       
   519     			}
       
   520     			
       
   521             }
       
   522         }
       
   523     else if ( !strcmp ( attrName, KTextColorSkinIndex ) )
       
   524         {
       
   525         // Handled in KTextSkinColorId case above.
       
   526         }
       
   527     else if ( !strcmp ( attrName, KPreconfiguredStyle ) )
       
   528         {
       
   529         try
       
   530             {
       
   531             AlfAttribute* backgroundtypeAttribute = &aContainer.getAttributeByName ( KBackgroundType );
       
   532             const char* backgroundDataField = backgroundtypeAttribute->getDataField();
       
   533             IAlfVariantType* backgroundData = aData->item ( UString(backgroundDataField) );
       
   534 
       
   535             if ( data && data->type() == IAlfVariantType::EInt && backgroundData && backgroundData->type() == IAlfVariantType::EInt )
       
   536                 {
       
   537                 //a valid background type attribute was found
       
   538                 textVisual->SetStyle ( ( TAlfPreconfiguredTextStyle ) data->integer(), ( TAlfBackgroundType ) data->integer() );
       
   539                 }
       
   540             }
       
   541         catch ( AlfDataException& e )
       
   542             {
       
   543             if ( data && data->type() == IAlfVariantType::EInt )
       
   544                 {
       
   545                 //no valid background type attribute found... Use default...
       
   546                 textVisual->SetStyle ( ( TAlfPreconfiguredTextStyle ) data->integer() );
       
   547                 }
       
   548             }
       
   549         }
       
   550     else if ( !strcmp ( attrName, KBackgroundType ) )
       
   551         {
       
   552         // Can not do anything with background type alone.
       
   553         // Do nothing.
       
   554         // This attribute will be used in some other iteration in the
       
   555         // else-if block that uses KPreconfiguredStyle
       
   556         }
       
   557     else if ( !strcmp ( attrName, KLineSpacing ) )
       
   558         {
       
   559         try
       
   560             {
       
   561             AlfAttribute* linespacingunitsAttribute = &aContainer.getAttributeByName ( KBackgroundType );
       
   562             const char* linespacingunitsDataField = linespacingunitsAttribute->getDataField();
       
   563             IAlfVariantType* linespacingunitsData = aData->item ( UString(linespacingunitsDataField) );
       
   564 
       
   565             if ( data && data->type() == IAlfVariantType::EInt && linespacingunitsData && linespacingunitsData->type() == IAlfVariantType::EInt )
       
   566                 {
       
   567                 //a valid line spacing units attribute was found
       
   568                 textVisual->SetLineSpacing ( data->integer(), ( CAlfTextVisual::TLineSpacingUnits ) linespacingunitsData->integer() );
       
   569                 }
       
   570             }
       
   571         catch ( AlfDataException& e )
       
   572             {
       
   573             if ( data && data->type() == IAlfVariantType::EInt )
       
   574                 {
       
   575                 //a valid line spacing units attribute was not found... Use default...
       
   576                 textVisual->SetLineSpacing ( data->integer() );
       
   577                 }
       
   578             }
       
   579         }
       
   580     else if ( !strcmp ( attrName, KLineSpacingUnits ) )
       
   581         {
       
   582         // Can not do anything with line spacing units alone.
       
   583         // Do nothing.
       
   584         // This attribute will be used in some other iteration in the
       
   585         // else-if block that uses KLineSpacing
       
   586         }
       
   587     else if ( !strcmp ( attrName, KStyle ) )
       
   588         {
       
   589         if ( data && data->type() == IAlfVariantType::EInt )
       
   590             {
       
   591             textVisual->SetTextStyle ( data->integer() );
       
   592             }
       
   593         }
       
   594     else if ( !strcmp ( attrName, KFont ) )
       
   595         {
       
   596         //not supported, no API in textvisual
       
   597         }
       
   598     else if ( !strcmp ( attrName, KVerticalAlign ) )
       
   599         {
       
   600         //will throw if horizontal align is not found
       
   601         AlfAttribute* horzAlignAttribute = &aContainer.getAttributeByName ( KHorizontalAlign );
       
   602         const char* horzAlignDataField = horzAlignAttribute->getDataField();
       
   603         IAlfVariantType* horzAlignData = aData->item ( UString(horzAlignDataField) );
       
   604 
       
   605         if ( data && data->type() == IAlfVariantType::EInt && horzAlignData && horzAlignData->type() == IAlfVariantType::EInt )
       
   606             {
       
   607             textVisual->SetAlign ( ( TAlfAlignHorizontal ) horzAlignData->integer(),
       
   608                                    ( TAlfAlignVertical ) data->integer() );
       
   609             }
       
   610         }
       
   611     else if ( !strcmp ( attrName, KHorizontalAlign ) )
       
   612         {
       
   613         // Do nothing.
       
   614         // This attribute will be used in some other iteration in the
       
   615         // else-if block that uses KVerticalAlign
       
   616         }
       
   617     else if ( !strcmp ( attrName, KMaxLineCount ) )
       
   618         {
       
   619         if ( data && data->type() == IAlfVariantType::EInt )
       
   620             {
       
   621             textVisual->SetMaxLineCount ( data->integer() );
       
   622             }
       
   623 
       
   624         }
       
   625     else if ( !strcmp ( attrName, KEnableShadow ) )
       
   626         {
       
   627         if ( data && data->type() == IAlfVariantType::EBool )
       
   628             {
       
   629             textVisual->EnableShadow ( data->boolean() );
       
   630             }
       
   631         }
       
   632     else
       
   633         {
       
   634         AlfCommonVisualAttributeSetter::handleStaticDataAttribute (
       
   635             aVisual, aAttr, aContainer, aData );
       
   636         }
       
   637     }
       
   638     
       
   639 
       
   640 // ---------------------------------------------------------------------------
       
   641 // Localisation attribute setter helper method. Helper Method.
       
   642 // ---------------------------------------------------------------------------
       
   643 //    
       
   644 void AlfTextVisualAttributeSetter::setLocalisedText(CAlfVisual& /*aVisual*/,const char* /*aLocId*/,AlfAttribute* /*aLangAttr*/,AlfAttribute* /*aVarArgsAttr*/)
       
   645 	{
       
   646  	}
       
   647 
       
   648 
       
   649 
       
   650 // ---------------------------------------------------------------------------
       
   651 // Helper Method for setting skin color.
       
   652 // ---------------------------------------------------------------------------
       
   653 //
       
   654 void AlfTextVisualAttributeSetter::setTextSkinColor(CAlfTextVisual& /*aTextVisual*/, const Utf8* /*aColorTable*/, 
       
   655 																const char* /*aColorIndex*/)
       
   656 	{
       
   657 	}
       
   658 
       
   659     } // namespace Alf
       
   660     
       
   661 // End of file