widgetmodel/alfwidgetmodel/src/alfcurvepathlayoutattributesetter.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 curvePathLayout.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 //includes
       
    21 
       
    22 //widget model includes
       
    23 #include "alf/alfattributecontainer.h"
       
    24 #include "alf/alfattributevaluetype.h"
       
    25 #include "alf/alfattribute.h"
       
    26 #include "alf/alfcurvepathlayoutattributesetter.h"
       
    27 #include <alf/alfvisualexception.h>
       
    28 #include <alf/alfdataexception.h>
       
    29 #include <alf/alfattributeexception.h>
       
    30 
       
    31 
       
    32 //osn includes
       
    33 #include <osn/ustring.h>
       
    34 
       
    35 //alf includes
       
    36 #include <alf/alfenv.h>
       
    37 #include <alf/alfcurvepathlayout.h>
       
    38 #include <alf/alfcurvepath.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 //namespaces
       
    48 
       
    49 using namespace osncore;
       
    50 
       
    51 using namespace duiuimodel::commonvisualattributes;
       
    52 
       
    53 using namespace duiuimodel::layoutattributes;
       
    54 
       
    55 using namespace duiuimodel::curvepathattributes;
       
    56 
       
    57 
       
    58 namespace Alf
       
    59     {
       
    60 
       
    61 static void throwIfErr ( int aErr )
       
    62     {
       
    63     if (aErr!=KErrNone)
       
    64         {
       
    65         ALF_THROW ( AlfAttributeException, aErr,
       
    66                     "AlfCurvePathLayoutAttributeSetter")
       
    67         }
       
    68     }
       
    69 
       
    70 // ======== MEMBER FUNCTIONS ========
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // Constructor.
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 OSN_EXPORT AlfCurvePathLayoutAttributeSetter::
       
    77 AlfCurvePathLayoutAttributeSetter()
       
    78     {
       
    79     }
       
    80 
       
    81 // ---------------------------------------------------------------------------
       
    82 // Destructor.
       
    83 // ---------------------------------------------------------------------------
       
    84 //
       
    85 OSN_EXPORT AlfCurvePathLayoutAttributeSetter::
       
    86 ~AlfCurvePathLayoutAttributeSetter()
       
    87     {
       
    88     }
       
    89 
       
    90 
       
    91 // ---------------------------------------------------------------------------
       
    92 // Sets Attribute Value. Delegates based on attribute Category.
       
    93 // ---------------------------------------------------------------------------
       
    94 //
       
    95 OSN_EXPORT void AlfCurvePathLayoutAttributeSetter::setAttributeValue (
       
    96     CAlfVisual &aVisual,
       
    97     AlfAttributeContainer* aContainer,
       
    98     IAlfMap* aData )
       
    99     {
       
   100 
       
   101     CAlfCurvePathLayout* curvepathlayout =
       
   102         dynamic_cast<CAlfCurvePathLayout*>(&aVisual);
       
   103 
       
   104     if ( !curvepathlayout )
       
   105         {
       
   106         ALF_THROW ( AlfVisualException, EInvalidVisual,
       
   107                     "AlfCurvePathLayoutAttributeSetter" )
       
   108         }
       
   109 
       
   110     curvepathlayout->CurvePath().Reset();
       
   111 
       
   112     AlfCommonLayoutAttributeSetter::setAttributeValue(aVisual, aContainer,
       
   113             aData);
       
   114 
       
   115     }
       
   116 
       
   117 // ---------------------------------------------------------------------------
       
   118 // Deprecated
       
   119 // ---------------------------------------------------------------------------
       
   120 //
       
   121 OSN_EXPORT TAlfCommand* AlfCurvePathLayoutAttributeSetter::createCommand (
       
   122     CAlfVisual& /*aVisual*/,
       
   123     AlfAttributeContainer* /*aContainer*/,
       
   124     IAlfMap* /*aData*/,
       
   125     int /*aTransitionTime*/,
       
   126     CAlfVisual* /*aRefVisual*/ )
       
   127     {
       
   128     //deprecated
       
   129     TAlfCommand* cmd = NULL;
       
   130     return cmd;
       
   131     }
       
   132 
       
   133 // ---------------------------------------------------------------------------
       
   134 // Sends a command to Env
       
   135 // ---------------------------------------------------------------------------
       
   136 //
       
   137 OSN_EXPORT void AlfCurvePathLayoutAttributeSetter::createAndSendCommands (
       
   138     CAlfVisual& aVisual,
       
   139     AlfAttributeContainer* aContainer,
       
   140     CAlfVisual* aRefVisual )
       
   141     {
       
   142     //SetOffset in CAlfCurvePath can be sent as a TAlfCustomEventCommand
       
   143 
       
   144     AlfCommonLayoutAttributeSetter::createAndSendCommands (
       
   145         aVisual, aContainer, aRefVisual );
       
   146     }
       
   147 
       
   148 
       
   149 // ---------------------------------------------------------------------------
       
   150 // Sets dynamic attributes to visual
       
   151 // ---------------------------------------------------------------------------
       
   152 //
       
   153 void AlfCurvePathLayoutAttributeSetter::handleDynamicAttribute (
       
   154     CAlfVisual &aVisual,
       
   155     AlfAttribute& aAttr,
       
   156     AlfAttributeContainer& aContainer)
       
   157     {
       
   158     CAlfCurvePathLayout* curvepathlayout =
       
   159         dynamic_cast<CAlfCurvePathLayout*>(&aVisual);
       
   160     if(!curvepathlayout)
       
   161         {
       
   162         return;
       
   163         }
       
   164 
       
   165     const char* attrName = aAttr.name();
       
   166 
       
   167     if ( !strcmp ( attrName, KOffsetX ) ||!strcmp ( attrName, KOffsetY ) )
       
   168         {
       
   169         // throws if attribute is not found
       
   170         AlfAttribute& offsety = aContainer.getAttributeByName ( KOffsetY );
       
   171         AlfAttribute& offsetx = aContainer.getAttributeByName ( KOffsetX );
       
   172 
       
   173         TAlfTimedPoint offset((TReal32)offsetx.getSourceValue()->realValue(),
       
   174                               (TReal32)offsety.getSourceValue()->realValue());
       
   175 
       
   176         offset.iX.SetTarget((TReal32)offsetx.getTargetValue()->realValue(),
       
   177                             offsetx.getTime());
       
   178 
       
   179         offset.iY.SetTarget((TReal32)offsety.getTargetValue()->realValue(),
       
   180                             offsety.getTime());
       
   181 
       
   182         offset.iX.SetStyle ( offsetx.getInterpolationStyle() );
       
   183         offset.iY.SetStyle ( offsety.getInterpolationStyle() );
       
   184 
       
   185         offset.iX.SetMappingFunctionIdentifier(
       
   186             offsetx.getMappingFunctionId());
       
   187         offset.iY.SetMappingFunctionIdentifier(
       
   188             offsety.getMappingFunctionId());
       
   189 
       
   190         curvepathlayout->CurvePath().SetOffset( offset );
       
   191         offsetx.setDirty(false);
       
   192         offsety.setDirty(false);
       
   193         }
       
   194     else
       
   195         {
       
   196         AlfCommonLayoutAttributeSetter::handleDynamicAttribute(
       
   197             aVisual, aAttr, aContainer);
       
   198         }
       
   199     }
       
   200 
       
   201 // ---------------------------------------------------------------------------
       
   202 // Sets static attributes to visual
       
   203 // ---------------------------------------------------------------------------
       
   204 //
       
   205 void AlfCurvePathLayoutAttributeSetter::handleStaticAttribute (
       
   206     CAlfVisual &aVisual,
       
   207     AlfAttribute& aAttr,
       
   208     AlfAttributeContainer& aContainer)
       
   209     {
       
   210 
       
   211     CAlfCurvePathLayout* curvepathlayout =
       
   212         dynamic_cast<CAlfCurvePathLayout*>(&aVisual);
       
   213     if(!curvepathlayout)
       
   214         {
       
   215         return;
       
   216         }
       
   217 
       
   218     const char* attrName = aAttr.name();
       
   219 
       
   220     if ( !strcmp ( attrName, KEnableLoop ) )
       
   221         {
       
   222         // if value is not int, then use default parameter of EnableLoop
       
   223         if ( AlfAttributeValueType::EInt != aAttr.type() )
       
   224             {
       
   225             curvepathlayout->CurvePath().EnableLoop();
       
   226             }
       
   227 
       
   228         else
       
   229             {
       
   230             int enableLoop = aAttr.intValue();
       
   231             TBool flag = ETrue;      //Assume true for any non-zero value.
       
   232             if ( 0 == enableLoop )
       
   233                 {
       
   234                 flag = EFalse;
       
   235                 }
       
   236             curvepathlayout->CurvePath().EnableLoop( flag );
       
   237             }
       
   238         }
       
   239 
       
   240     else if ( !strcmp ( attrName, KOrigin ) )
       
   241         {
       
   242         curvepathlayout->CurvePath().SetOrigin( aAttr.realValue() );
       
   243         }
       
   244 
       
   245     else if ( !strcmp ( attrName, KOffsetX ) || !strcmp ( attrName, KOffsetY ) )
       
   246         {
       
   247         // throws if attribute is not found
       
   248         AlfAttribute& offsety = aContainer.getAttributeByName ( KOffsetY );
       
   249         AlfAttribute& offsetx = aContainer.getAttributeByName ( KOffsetX );
       
   250 
       
   251         TAlfTimedPoint offset( offsetx.realValue(), offsety.realValue());
       
   252         curvepathlayout->CurvePath().SetOffset ( offset );
       
   253         offsety.setDirty(false);
       
   254         offsetx.setDirty(false);
       
   255         }
       
   256     else if ( !strcmp ( attrName, KLine ) )
       
   257         {
       
   258         // This multi-value attribute has to be filled in this order:
       
   259         // startx,starty,endx,endy,linelength
       
   260 
       
   261         if ( 5 != aAttr.getTargetValueCount())
       
   262             {
       
   263             ALF_THROW ( AlfAttributeException, EInvalidAttribute,
       
   264                         "AlfCurvePathLayoutAttributeSetter" );
       
   265             }
       
   266 
       
   267         float startx = this->floatOrInt( aAttr, 0 );
       
   268         float starty = this->floatOrInt( aAttr, 1 );
       
   269         float endx   = this->floatOrInt( aAttr, 2 );
       
   270         float endy   = this->floatOrInt( aAttr, 3 );
       
   271         float len    = aAttr.realValue(4);
       
   272 
       
   273         TRAPD(err1,curvepathlayout->CurvePath().AppendLineL(
       
   274                   TAlfRealPoint(startx,starty),
       
   275                   TAlfRealPoint(endx,endy),len )
       
   276              );
       
   277         throwIfErr(err1);
       
   278         }
       
   279 
       
   280     else if ( !strcmp ( attrName, KArc ) )
       
   281         {
       
   282         // This multi-value attribute has to be filled in this order:
       
   283         // arcoriginx,arcoriginy,archorzradius,arcvertradius,arcstartangle,
       
   284         // arcendangle,arclength
       
   285 
       
   286         if ( 7 != aAttr.getTargetValueCount())
       
   287             {
       
   288             ALF_THROW ( AlfAttributeException, EInvalidAttribute,
       
   289                         "AlfCurvePathLayoutAttributeSetter" );
       
   290             }
       
   291 
       
   292         float originx    = this->floatOrInt( aAttr, 0 );
       
   293         float originy    = this->floatOrInt( aAttr, 1 );
       
   294         float horzradius = this->floatOrInt( aAttr, 2 );
       
   295         float vertradius = this->floatOrInt( aAttr, 3 );
       
   296         float startangle = aAttr.realValue(4);
       
   297         float endangle   = aAttr.realValue(5);
       
   298         float len        = aAttr.realValue(6);
       
   299         TRAPD(err1,curvepathlayout->CurvePath().AppendArcL(
       
   300                   TAlfRealPoint(originx,originy),
       
   301                   TAlfRealSize(horzradius,vertradius),
       
   302                   startangle,endangle,len));
       
   303         throwIfErr(err1);
       
   304         }
       
   305 
       
   306     else
       
   307         {
       
   308         AlfCommonLayoutAttributeSetter::handleStaticAttribute (
       
   309             aVisual, aAttr, aContainer);
       
   310         }
       
   311     }
       
   312 // ---------------------------------------------------------------------------
       
   313 // Sets dynamic attributes to visual from data
       
   314 // ---------------------------------------------------------------------------
       
   315 //
       
   316 void AlfCurvePathLayoutAttributeSetter::handleDynamicDataAttribute (
       
   317     CAlfVisual &aVisual,
       
   318     AlfAttribute& aAttr,
       
   319     AlfAttributeContainer& aContainer,
       
   320     IAlfMap* aData )
       
   321     {
       
   322     CAlfCurvePathLayout* curvepathlayout =
       
   323         dynamic_cast<CAlfCurvePathLayout*> ( &aVisual );
       
   324     if ( !curvepathlayout )
       
   325         {
       
   326         ALF_THROW ( AlfDataException, ECommonError, "AlfCurvePathLayoutAttributeSetter" )
       
   327         }        
       
   328 
       
   329     const char* attrName = aAttr.name();
       
   330     const char* dataField = aAttr.getDataField();
       
   331 
       
   332     if ( !dataField )
       
   333         {
       
   334         ALF_THROW ( AlfDataException, ECommonError, "AlfCurvePathLayoutAttributeSetter" )
       
   335         }
       
   336 
       
   337     if (!aData)
       
   338         {
       
   339         ALF_THROW ( AlfDataException, ECommonError,
       
   340                     "AlfCurvePathLayoutAttributeSetter" )
       
   341         }
       
   342 
       
   343     IAlfVariantType* data = aData->item ( UString(dataField) );
       
   344 
       
   345     if (data)
       
   346         {
       
   347         const char* attrName = aAttr.name();
       
   348 
       
   349         if ( !strcmp ( attrName, KOffsetX ) )
       
   350             {
       
   351             // throws if attribute not found
       
   352             AlfAttribute& offsety = aContainer.getAttributeByName( KOffsetY );
       
   353 
       
   354             const char* offsetyDataField = offsety.getDataField();
       
   355             if ( !offsetyDataField )
       
   356                 {
       
   357                 ALF_THROW ( AlfDataException,
       
   358                             ECommonError, "AlfCurvePathLayoutAttributeSetter")
       
   359                 }
       
   360 
       
   361             IAlfVariantType* offsetyData = aData->item ( UString(offsetyDataField) );
       
   362 
       
   363             if ( data->type() == IAlfVariantType::EReal &&
       
   364                     offsetyData && offsetyData->type() == IAlfVariantType::EReal)
       
   365                 {
       
   366                 // The time value is in the attribute? Is it not
       
   367                 // part of data as well?
       
   368                 TAlfTimedPoint offset;
       
   369                 offset.iX.SetTarget(data->real(), aAttr.getTime());
       
   370                 offset.iX.SetStyle ( aAttr.getInterpolationStyle() );
       
   371                 offset.iX.SetMappingFunctionIdentifier (aAttr.getMappingFunctionId());
       
   372 
       
   373                 offset.iY.SetTarget(offsetyData->real(), offsety.getTime());
       
   374                 offset.iY.SetStyle ( offsety.getInterpolationStyle() );
       
   375                 offset.iY.SetMappingFunctionIdentifier (
       
   376                     offsety.getMappingFunctionId());
       
   377 
       
   378                 curvepathlayout->CurvePath().SetOffset( offset );
       
   379                 }
       
   380             }
       
   381 
       
   382         else if ( !strcmp ( attrName, KOffsetY ) )
       
   383             {
       
   384             //Make sure X Attribute also exists, but do nothing.
       
   385             //Actual values will be set in the iteration that checks
       
   386             //for KOffsetX
       
   387             aContainer.getAttributeByName ( KOffsetX );
       
   388             //will throw if attribute is not found
       
   389             }
       
   390 
       
   391         else
       
   392             {
       
   393             AlfCommonLayoutAttributeSetter::handleDynamicDataAttribute(
       
   394                 aVisual, aAttr, aContainer, aData);
       
   395             }
       
   396         }
       
   397     }
       
   398 
       
   399 // ---------------------------------------------------------------------------
       
   400 // Sets static attributes to visual  from data
       
   401 // ---------------------------------------------------------------------------
       
   402 //
       
   403 void AlfCurvePathLayoutAttributeSetter::handleStaticDataAttribute (
       
   404     CAlfVisual &aVisual,
       
   405     AlfAttribute& aAttr,
       
   406     AlfAttributeContainer& aContainer,
       
   407     IAlfMap* aData )
       
   408     {
       
   409     CAlfCurvePathLayout* curvepathlayout =
       
   410         dynamic_cast<CAlfCurvePathLayout*> ( &aVisual );
       
   411     if(!curvepathlayout)
       
   412         {
       
   413         ALF_THROW ( AlfDataException, ECommonError,
       
   414                             "AlfCurvePathLayoutAttributeSetter" )
       
   415         }
       
   416     const char* attrName = aAttr.name();
       
   417 
       
   418     const char* dataField = aAttr.getDataField();
       
   419 
       
   420     if ( !dataField )
       
   421         {
       
   422         ALF_THROW ( AlfDataException, ECommonError,
       
   423                     "AlfCurvePathLayoutAttributeSetter" )
       
   424         }
       
   425 
       
   426     if (!aData)
       
   427         {
       
   428         ALF_THROW ( AlfDataException, ECommonError,
       
   429                     "AlfCurvePathLayoutAttributeSetter" )
       
   430         }
       
   431 
       
   432     IAlfVariantType* data = aData->item ( UString(dataField) );
       
   433 
       
   434     if ( data )
       
   435         {
       
   436 
       
   437         if ( !strcmp ( attrName, KEnableLoop ) )
       
   438             {
       
   439             // if value is not bool, then use default parameter of EnableLoop
       
   440             if ( data->type() != IAlfVariantType::EBool )
       
   441                 {
       
   442                 curvepathlayout->CurvePath().EnableLoop();
       
   443                 }
       
   444             else
       
   445                 {
       
   446                 curvepathlayout->CurvePath().EnableLoop( data->boolean() );
       
   447                 }
       
   448             }
       
   449 
       
   450         else if ( !strcmp ( attrName, KOrigin ) )
       
   451             {
       
   452             if ( data->type() == IAlfVariantType::EReal )
       
   453                 {
       
   454                 float origin =  data->real() ;
       
   455                 curvepathlayout->CurvePath().SetOrigin ( origin );
       
   456                 }
       
   457             }
       
   458 
       
   459         else if ( !strcmp ( attrName, KOffsetX ) )
       
   460             {
       
   461             AlfAttribute& offsety
       
   462             = aContainer.getAttributeByName ( KOffsetY );
       
   463             //will throw if attribute is not found
       
   464 
       
   465             const char* offsetyDataField = offsety.getDataField();
       
   466             if ( !offsetyDataField )
       
   467                 {
       
   468                 ALF_THROW ( AlfDataException,
       
   469                             ECommonError, "AlfCurvePathLayoutAttributeSetter")
       
   470                 }
       
   471 
       
   472             IAlfVariantType* offsetyData = aData->item ( UString(offsetyDataField) );
       
   473 
       
   474             if ( data->type() == IAlfVariantType::EReal &&
       
   475                     offsetyData && offsetyData->type() == IAlfVariantType::EReal)
       
   476                 {
       
   477                 TAlfTimedPoint offset( data->real(), offsetyData->real());
       
   478                 curvepathlayout->CurvePath().SetOffset( offset );
       
   479                 }
       
   480             }
       
   481 
       
   482         else if ( !strcmp ( attrName, KOffsetY ) )
       
   483             {
       
   484             //Make sure X Attribute also exists, but do nothing.
       
   485             //Actual values will be set in the iteration that checks for
       
   486             //KOffsetX
       
   487             aContainer.getAttributeByName( KOffsetX );
       
   488             //will throw if attribute is not found
       
   489             }
       
   490 
       
   491         else if ( !strcmp ( attrName, KLine ) )
       
   492             {
       
   493 
       
   494             //if not a container, dont proceed
       
   495             if (!(data->type() == IAlfVariantType::EContainer))
       
   496                 {
       
   497                 return;
       
   498                 }
       
   499 
       
   500             IAlfContainer* container = data->container();
       
   501             //if all item are not present, throw
       
   502             if (container->count() != 5)
       
   503                 {
       
   504                 ALF_THROW ( AlfAttributeException, EInvalidAttribute,
       
   505                             "AlfCurvePathLayoutAttributeSetter" );
       
   506                 }
       
   507 
       
   508             IAlfVariantType* lineStartXvalue = container->item(0);
       
   509             IAlfVariantType* lineStartYvalue = container->item(1);
       
   510             IAlfVariantType* lineEndXvalue = container->item(2);
       
   511             IAlfVariantType* lineEndYvalue = container->item(3);
       
   512             IAlfVariantType* lineLengthvalue = container->item(4);
       
   513 
       
   514             float startx = this->floatOrIntFromData( lineStartXvalue);
       
   515             float starty = this->floatOrIntFromData( lineStartYvalue);
       
   516             float endx   = this->floatOrIntFromData( lineEndXvalue  );
       
   517             float endy   = this->floatOrIntFromData( lineEndYvalue  );
       
   518             float len    = float(lineLengthvalue->real());
       
   519             TRAPD(err1,
       
   520                   curvepathlayout->CurvePath().AppendLineL(
       
   521                       TAlfRealPoint(startx,starty),
       
   522                       TAlfRealPoint(endx,endy),len)
       
   523                  );
       
   524             throwIfErr(err1);
       
   525             }
       
   526 
       
   527         else if ( !strcmp ( attrName, KArc ) )
       
   528             {
       
   529 
       
   530             //if not a container, dont proceed
       
   531             if (!(data->type() == IAlfVariantType::EContainer))
       
   532                 {
       
   533                 return;
       
   534                 }
       
   535 
       
   536             IAlfContainer* container = data->container();
       
   537 
       
   538             //if all item are not present, throw
       
   539             if (container->count() != 7)
       
   540                 {
       
   541                 ALF_THROW ( AlfAttributeException, EInvalidAttribute,
       
   542                             "AlfCurvePathLayoutAttributeSetter" );
       
   543                 }
       
   544 
       
   545             IAlfVariantType* arcOriginXValue = container->item(0);
       
   546             IAlfVariantType* arcOriginYValue = container->item(1);
       
   547             IAlfVariantType* archorzradiusValue = container->item(2);
       
   548             IAlfVariantType* arcvertradiusValue = container->item(3);
       
   549             IAlfVariantType* arcstartangleValue = container->item(4);
       
   550             IAlfVariantType* arcendangleValue = container->item(5);
       
   551             IAlfVariantType* arclengthValue = container->item(6);
       
   552 
       
   553             float originx    = this->floatOrIntFromData( arcOriginXValue);
       
   554             float originy    = this->floatOrIntFromData( arcOriginYValue);
       
   555             float horzradius = this->floatOrIntFromData( archorzradiusValue);
       
   556             float vertradius = this->floatOrIntFromData( arcvertradiusValue);
       
   557             float startangle = float(arcstartangleValue->real());
       
   558             float endangle   = float(arcendangleValue->real());
       
   559             float len        = float(arclengthValue->real());
       
   560             TRAPD(err1,
       
   561                   curvepathlayout->CurvePath().AppendArcL(
       
   562                       TAlfRealPoint(originx,originy),
       
   563                       TAlfRealSize(horzradius,vertradius),
       
   564                       startangle,endangle,len));
       
   565             throwIfErr(err1);
       
   566             }
       
   567         else
       
   568             {
       
   569             AlfCommonLayoutAttributeSetter::handleStaticDataAttribute (
       
   570                 aVisual, aAttr, aContainer, aData );
       
   571             }
       
   572         }
       
   573     }
       
   574 
       
   575 // ---------------------------------------------------------------------------
       
   576 // Check if data in the attribute is int or float.
       
   577 // Return the value as a float value
       
   578 // ---------------------------------------------------------------------------
       
   579 //
       
   580 float AlfCurvePathLayoutAttributeSetter::floatOrInt(
       
   581     const AlfAttribute& aAttr,
       
   582     int aIndex)
       
   583     {
       
   584     if (aAttr.type(aIndex) == AlfAttributeValueType::EInt)
       
   585         {
       
   586         return float(aAttr.intValue(aIndex));
       
   587         }
       
   588     else if (aAttr.type(aIndex) == AlfAttributeValueType::EFloat)
       
   589         {
       
   590         return aAttr.realValue(aIndex); //will throw an exception i
       
   591         }
       
   592     else
       
   593         {
       
   594         ALF_THROW ( AlfAttributeException,
       
   595                     ECommonError, "AlfCurvePathLayoutAttributeSetter" );
       
   596         }
       
   597     }
       
   598 
       
   599 
       
   600 // ---------------------------------------------------------------------------
       
   601 // Check if data in the variant type is int or float.
       
   602 // Return the value as a float value
       
   603 // ---------------------------------------------------------------------------
       
   604 //
       
   605 float AlfCurvePathLayoutAttributeSetter::floatOrIntFromData(
       
   606     IAlfVariantType* aData)
       
   607     {
       
   608     if (IAlfVariantType::EInt == aData->type())
       
   609         {
       
   610         return float(aData->integer());
       
   611         }
       
   612     else if (IAlfVariantType::EReal == aData->type())
       
   613         {
       
   614         return aData->real();; //will throw an exception i
       
   615         }
       
   616     else
       
   617         {
       
   618         ALF_THROW ( AlfAttributeException,
       
   619                     ECommonError, "AlfCurvePathLayoutAttributeSetter" );
       
   620         }
       
   621     }
       
   622 
       
   623     } // namespace Alf
       
   624 // End of file
       
   625 
       
   626 
       
   627 
       
   628 
       
   629