svgtopt/SVG/SVGImpl/src/SVGVectorCssValueImpl.cpp
changeset 46 88edb906c587
equal deleted inserted replaced
-1:000000000000 46:88edb906c587
       
     1 /*
       
     2 * Copyright (c) 2003 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:  SVG Implementation source file
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifdef _DEBUG
       
    20 #if !defined(__E32DEBUG_H__)
       
    21 #include <e32debug.h>
       
    22 #endif
       
    23 #endif
       
    24 
       
    25 #include "SVGVectorCssValueImpl.h"
       
    26 #include "SVGPointLexer.h"
       
    27 
       
    28 
       
    29 
       
    30 
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 // ---------------------------------------------------------------------------
       
    34 CVectorCssValueImpl::~CVectorCssValueImpl()
       
    35     {
       
    36     if ( iValue )
       
    37         {
       
    38         iValue->Reset();
       
    39         delete iValue;
       
    40         iValue = NULL;
       
    41         }
       
    42     }
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 // ---------------------------------------------------------------------------
       
    47 void CVectorCssValueImpl::Value( CArrayFix<TFloatFixPt>*& aArray )
       
    48     {
       
    49     aArray = iValue;
       
    50 
       
    51     }
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 // ---------------------------------------------------------------------------
       
    56 CArrayFix<TFloatFixPt>* CVectorCssValueImpl::Value( )
       
    57     {
       
    58     return iValue;
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 // ---------------------------------------------------------------------------
       
    64 TInt CVectorCssValueImpl::SetValueL( const TDesC& aValue )
       
    65     {
       
    66 
       
    67     if ( iValue )
       
    68         {
       
    69         iValue->Reset();
       
    70         delete iValue;
       
    71         iValue = NULL;
       
    72         }
       
    73     iValue = new ( ELeave ) CArrayFixFlat<TFloatFixPt>( 1 );
       
    74 
       
    75 
       
    76     TSvgPointLexer svgplex( aValue );
       
    77 
       
    78     while ( !svgplex.IsDone() )
       
    79         {
       
    80         TChar com = ',';
       
    81         TFloatFixPt dashf;
       
    82         TInt32 rslt = svgplex.GetNext( com, dashf );
       
    83         if ( rslt != KErrNone )
       
    84             {
       
    85             break;
       
    86             }
       
    87         iValue->AppendL( dashf );
       
    88         }
       
    89         svgplex.Cleanup();
       
    90 
       
    91     return KErrNone;
       
    92     }
       
    93 
       
    94 
       
    95 // *******************************************************
       
    96 // Private
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 // ---------------------------------------------------------------------------
       
   101 CVectorCssValueImpl::CVectorCssValueImpl():iValue( NULL )
       
   102     {
       
   103     }
       
   104 // ---------------------------------------------------------------------------
       
   105 //
       
   106 // ---------------------------------------------------------------------------
       
   107 CVectorCssValueImpl::CVectorCssValueImpl(CArrayFix<TFloatFixPt>* aValue  ):iValue( aValue )
       
   108     {
       
   109     }
       
   110 
       
   111 // ---------------------------------------------------------------------------
       
   112 // function for encoding
       
   113 // ---------------------------------------------------------------------------
       
   114 void  CVectorCssValueImpl::SetValueL( CArrayFix<TFloatFixPt>*& aValue )
       
   115     {
       
   116      if ( iValue )
       
   117         {
       
   118         iValue->Reset();
       
   119         delete iValue;
       
   120         iValue = NULL;
       
   121         }
       
   122 
       
   123     iValue= aValue;
       
   124     }
       
   125 
       
   126 // ---------------------------------------------------------------------------
       
   127 // function for encoding
       
   128 // ---------------------------------------------------------------------------
       
   129 void  CVectorCssValueImpl::CloneValueL( CArrayFix<TFloatFixPt>*& aValue )
       
   130     {
       
   131      if ( iValue )
       
   132         {
       
   133         iValue->Reset();
       
   134         delete iValue;
       
   135         iValue = NULL;
       
   136         }
       
   137 
       
   138 	iValue = new ( ELeave ) CArrayFixFlat<TFloatFixPt>( 1 );
       
   139 	
       
   140 	TInt valCnt = aValue->Count();
       
   141 	for (TInt i=0; i < valCnt; i++)
       
   142 	{
       
   143 		iValue->AppendL( aValue->At(i) );
       
   144 	}
       
   145 
       
   146     }
       
   147     
       
   148 // ---------------------------------------------------------------------------
       
   149 //
       
   150 // ---------------------------------------------------------------------------
       
   151 TBool CVectorCssValueImpl::IsEqual( CCssValue* aValue )
       
   152 {
       
   153 	if (((CVectorCssValueImpl*)aValue)->iValue == iValue)
       
   154 	{
       
   155 		return ETrue;
       
   156 	}
       
   157 
       
   158 	return EFalse;
       
   159 }
       
   160 
       
   161 void CVectorCssValueImpl::Print()
       
   162 {
       
   163 	#ifdef _DEBUG
       
   164 	
       
   165 	TInt valCnt = iValue->Count();
       
   166 	for (TInt i=0; i < valCnt; i++)
       
   167 	{
       
   168 		RDebug::Printf("%d, ", (int)(iValue->At(i)));
       
   169 	}
       
   170 	#endif
       
   171 }