svgtopt/SVG/SVGImpl/src/SvgHkernelementimpl.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 #if !defined(__E32BASE_H__)
       
    20 #include <e32base.h>
       
    21 #endif
       
    22 #include "SvgHkernelementimpl.h"
       
    23 #include "SVGDocumentImpl.h"
       
    24 #include "SVGSchemaData.h"
       
    25 
       
    26 #include "GfxAffineTransform.h"
       
    27 
       
    28 
       
    29 #ifdef SVG_FONTS_INCLUDE
       
    30 
       
    31 // ---------------------------------------------------------------------------
       
    32 // Two phase construction
       
    33 // ---------------------------------------------------------------------------
       
    34 CSvgHkernElementImpl* CSvgHkernElementImpl::NewL(  const TUint8 aElemID,
       
    35                                                 CSvgDocumentImpl* aDoc )
       
    36     {
       
    37     CSvgHkernElementImpl*self    = new ( ELeave ) CSvgHkernElementImpl( aDoc );
       
    38     CleanupStack::PushL( self );
       
    39     self->ConstructL( aElemID);
       
    40     CleanupStack::Pop();
       
    41 
       
    42     return self;
       
    43     }
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 // ---------------------------------------------------------------------------
       
    48 CSvgHkernElementImpl* CSvgHkernElementImpl::NewLC(  const TUint8 aElemID,
       
    49                                                  CSvgDocumentImpl* aDoc )
       
    50     {
       
    51     CSvgHkernElementImpl*self    = new ( ELeave ) CSvgHkernElementImpl( aDoc );
       
    52     CleanupStack::PushL( self );
       
    53     self->ConstructL(  aElemID );
       
    54 
       
    55     return self;
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 // ---------------------------------------------------------------------------
       
    61 void CSvgHkernElementImpl::ConstructL(  const TUint8 aElemID)
       
    62     {
       
    63     CSvgElementImpl::InitializeL( aElemID );
       
    64 
       
    65 	#ifdef SVG_FLOAT_BUILD
       
    66     iK = TFloatFixPt(0.0f);
       
    67 	#else
       
    68     iK = TFloatFixPt( 0 ,ETrue);
       
    69 	#endif
       
    70 
       
    71     iG1 = HBufC::NewL( 0 );
       
    72     iG2 = HBufC::NewL( 0 );
       
    73     iU1 = HBufC::NewL( 0 );
       
    74     iU2 = HBufC::NewL( 0 );
       
    75 
       
    76     iReqAttrFlag=KSVG_HKERN_ELEMFLAG;
       
    77 
       
    78     }
       
    79 
       
    80 
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 //
       
    84 // ---------------------------------------------------------------------------
       
    85 CSvgHkernElementImpl::~CSvgHkernElementImpl()
       
    86     {
       
    87     if ( iG1 )
       
    88         {
       
    89         delete iG1;
       
    90         iG1 = NULL;
       
    91         }
       
    92 
       
    93     if ( iG2 )
       
    94         {
       
    95         delete iG2;
       
    96         iG2 = NULL;
       
    97         }
       
    98 
       
    99     if ( iU1 )
       
   100         {
       
   101         delete iU1;
       
   102         iU1 = NULL;
       
   103         }
       
   104 
       
   105     if (iU2)
       
   106         {
       
   107         delete iU2;
       
   108         iU2 = NULL;
       
   109         }
       
   110     }
       
   111 
       
   112 // ===================================
       
   113 // From SVG DOM
       
   114 // ===================================
       
   115 
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 // ---------------------------------------------------------------------------
       
   119 TFloatFixPt CSvgHkernElementImpl::GetK()
       
   120     {
       
   121     return iK;
       
   122     }
       
   123 
       
   124 
       
   125 // ===================================
       
   126 // From MXmlElement
       
   127 // ===================================
       
   128 
       
   129 // ---------------------------------------------------------------------------
       
   130 //
       
   131 // ---------------------------------------------------------------------------
       
   132 TInt CSvgHkernElementImpl::SetAttributeL( const TDesC& aName,
       
   133                                          const TDesC& aValue )
       
   134     {
       
   135 
       
   136 
       
   137 
       
   138     CSvgElementImpl::SetAttributeL(aName,aValue);
       
   139 
       
   140     return KErrNone;
       
   141     }
       
   142 
       
   143 
       
   144 TInt  CSvgHkernElementImpl::SetAttributeDesL( const TInt aNameId, const TDesC& aValue )
       
   145 {
       
   146     switch (aNameId)
       
   147         {
       
   148         case KAtrG1:
       
   149                         delete iG1;
       
   150                         iG1 = NULL;
       
   151                         iG1 = aValue.AllocL();
       
   152                         break;
       
   153         case KAtrG2:
       
   154                         delete iG2;
       
   155                         iG2 = NULL;
       
   156                         iG2 = aValue.AllocL();
       
   157                         break;
       
   158         case KAtrU1:
       
   159                         delete iU1;
       
   160                         iU1 = NULL;
       
   161                         iU1 = aValue.AllocL();
       
   162                         break;
       
   163         case KAtrU2:
       
   164                         delete iU2;
       
   165                         iU2 = NULL;
       
   166                         iU2 = aValue.AllocL();
       
   167                         break;
       
   168         case KAtrK:
       
   169                         {
       
   170                         TLex    lString ( aValue );
       
   171                         TReal32 lVal;
       
   172                         if( lString.Val( lVal, '.' ) != KErrNone )
       
   173                             lVal = 0;
       
   174                         iK = (TFloatFixPt) lVal;
       
   175                         iReqAttrFlag = 0;
       
   176                         break;
       
   177                         }
       
   178         default:        return CSvgElementImpl::SetAttributeDesL( aNameId, aValue );
       
   179 
       
   180         }
       
   181     return KErrNone;
       
   182 }
       
   183 
       
   184 
       
   185 // From MXmlElementOpt
       
   186 // ---------------------------------------------------------------------------
       
   187 //
       
   188 // ---------------------------------------------------------------------------
       
   189 TInt CSvgHkernElementImpl::GetAttributeFloat( const TInt aNameId,
       
   190                                              TFloatFixPt& aValue )
       
   191     {
       
   192     switch ( aNameId )
       
   193         {
       
   194         case KAtrK:
       
   195         aValue = GetK();
       
   196         break;
       
   197         default:
       
   198         return CSvgElementImpl::GetAttributeFloat( aNameId, aValue );
       
   199         }
       
   200 
       
   201     return KErrNone;
       
   202     }
       
   203 
       
   204 // ---------------------------------------------------------------------------
       
   205 //
       
   206 // ---------------------------------------------------------------------------
       
   207 TInt CSvgHkernElementImpl::SetAttributeFloatL( const TInt aNameId,
       
   208                                              const TFloatFixPt aValue )
       
   209     {
       
   210     switch ( aNameId )
       
   211         {
       
   212         case KAtrK:
       
   213         iK= aValue;
       
   214         break;
       
   215         default:
       
   216         return CSvgElementImpl::SetAttributeFloatL( aNameId, aValue );
       
   217         }
       
   218 
       
   219     return KErrNone;
       
   220     }
       
   221 
       
   222 // ---------------------------------------------------------------------------
       
   223 //
       
   224 // ---------------------------------------------------------------------------
       
   225 TInt CSvgHkernElementImpl::GetAttributeDes( const TInt aNameId, TPtrC16& aValue )
       
   226     {
       
   227     switch ( aNameId )
       
   228         {
       
   229         case KAtrG1:
       
   230         if ( iG1->Length() > 0 )
       
   231             {
       
   232             aValue.Set( *iG1 );
       
   233             break;
       
   234             }
       
   235         else
       
   236             return KErrNoAttribute;
       
   237         case KAtrG2:
       
   238         if ( iG2->Length() > 0 )
       
   239             {
       
   240             aValue.Set( *iG2 );
       
   241             break;
       
   242             }
       
   243         else
       
   244             return KErrNoAttribute;
       
   245         case KAtrU1:
       
   246         if ( iU1->Length() > 0 )
       
   247             {
       
   248             aValue.Set( *iU1 );
       
   249             break;
       
   250             }
       
   251         else
       
   252             return KErrNoAttribute;
       
   253         case KAtrU2:
       
   254         if ( iU2->Length() > 0 )
       
   255             {
       
   256             aValue.Set( *iU2 );
       
   257             break;
       
   258             }
       
   259         else
       
   260             return KErrNoAttribute;
       
   261 
       
   262         default:
       
   263         return CSvgElementImpl::GetAttributeDes( aNameId, aValue );
       
   264         }
       
   265     return KErrNone;
       
   266     }
       
   267 
       
   268 
       
   269 // ===================================
       
   270 // From CSvgElementImpl
       
   271 // ===================================
       
   272 
       
   273 // ---------------------------------------------------------------------------
       
   274 // perform a deep clone of this object
       
   275 // ---------------------------------------------------------------------------
       
   276 MXmlElement* CSvgHkernElementImpl::CloneL(MXmlElement*)
       
   277     {
       
   278     return NULL;
       
   279     }
       
   280 
       
   281 // ---------------------------------------------------------------------------
       
   282 //
       
   283 // ---------------------------------------------------------------------------
       
   284 TBool CSvgHkernElementImpl::DrawL( CGfx2dGc* /* aGc */,
       
   285                                   CSvgElementImpl* /* aElement */ )
       
   286     {
       
   287     return EFalse;
       
   288     }
       
   289 
       
   290 
       
   291 
       
   292 // ---------------------------------------------------------------------------
       
   293 //
       
   294 // ---------------------------------------------------------------------------
       
   295 
       
   296 CSvgHkernElementImpl::CSvgHkernElementImpl( CSvgDocumentImpl* aDoc )
       
   297     {
       
   298     SetOwnerDocument(aDoc);
       
   299     }
       
   300 
       
   301 void CSvgHkernElementImpl::Print( TBool aIsEncodeOn )
       
   302 {
       
   303 	if (!aIsEncodeOn)
       
   304 	{
       
   305 		#ifdef _DEBUG
       
   306 		RDebug::Printf("<hkern u1=\"hmm\" u2=\"hmm\" g1=\"hmm\" g2=\"hmm\" k=\"%d\" \\>", /*iU1->Des(), iU2->Des(), iG1->Des(), iG2->Des(),*/ (int)iK);
       
   307 		#endif
       
   308 	}
       
   309 }
       
   310 
       
   311 #endif    //ifdef SVG_FONTS_INCLUDE