svgtopt/SVG/SVGImpl/src/SVGDefsElementImpl.cpp
changeset 0 d46562c3d99d
equal deleted inserted replaced
-1:000000000000 0:d46562c3d99d
       
     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 
       
    20 
       
    21 #if !defined(__E32BASE_H__)
       
    22 #include <e32base.h>
       
    23 #endif
       
    24 #include "SVGDefsElementImpl.h"
       
    25 #include "SVGElementImpl.h"
       
    26 #include "SVGDocumentImpl.h"
       
    27 #include "SVGSchemaData.h"
       
    28 
       
    29 #include "GfxAffineTransform.h"
       
    30 
       
    31 // *******************************************************
       
    32 // Constructor/deconstructor
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 // ---------------------------------------------------------------------------
       
    37 CSvgDefsElementImpl* CSvgDefsElementImpl::NewL( const TUint8 aElemID,
       
    38                                                 CSvgDocumentImpl* aDoc )
       
    39     {
       
    40     CSvgDefsElementImpl*self    = new ( ELeave ) CSvgDefsElementImpl( aDoc );
       
    41     CleanupStack::PushL( self );
       
    42     self->ConstructL( aElemID );
       
    43     CleanupStack::Pop();
       
    44 
       
    45     return self;
       
    46     }
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 // ---------------------------------------------------------------------------
       
    51 CSvgDefsElementImpl* CSvgDefsElementImpl::NewLC( const TUint8 aElemID,
       
    52                                                  CSvgDocumentImpl* aDoc )
       
    53     {
       
    54     CSvgDefsElementImpl*self    = new ( ELeave ) CSvgDefsElementImpl( aDoc );
       
    55     CleanupStack::PushL( self );
       
    56     self->ConstructL( aElemID );
       
    57 
       
    58     return self;
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 // ---------------------------------------------------------------------------
       
    64 CSvgDefsElementImpl::~CSvgDefsElementImpl()
       
    65     {
       
    66     }
       
    67 
       
    68 // *******************************************************
       
    69 // From MXmlElement
       
    70 
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 // ---------------------------------------------------------------------------
       
    74 TInt CSvgDefsElementImpl::SetAttributeL( const TDesC& aName,
       
    75                                          const TDesC& aValue )
       
    76     {
       
    77 
       
    78     if ( this->SetLangSpaceAttributeL( aName, aValue ) )
       
    79         {
       
    80         return KErrNone;
       
    81         }
       
    82 
       
    83 
       
    84 
       
    85     if ( this->SetTransform( aName, aValue ) )
       
    86         {
       
    87         return KErrNone;
       
    88         }
       
    89 
       
    90     if ( this->SetTestAttributeL( aName, aValue ) )
       
    91         {
       
    92         return KErrNone;
       
    93         }
       
    94 
       
    95     if ( SetIdandXmlbaseL( aName, aValue ) )
       
    96         {
       
    97         return KErrNone;
       
    98         }
       
    99 
       
   100     return KErrNone;
       
   101     }
       
   102 
       
   103 
       
   104 // From MXmlElementOpt
       
   105 
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 // ---------------------------------------------------------------------------
       
   109 TInt CSvgDefsElementImpl::GetAttributeFloat( const TInt aNameId,
       
   110                                              TFloatFixPt& aValue )
       
   111     {
       
   112     switch ( aNameId )
       
   113         {
       
   114         case KAtrRefX:
       
   115             {
       
   116             TFloatFixPt          xmin( KMAXFLOATFIX ), x; // 0x7fff is the maximum integer in TFixPt
       
   117             CSvgElementImpl* lNewElement = ( CSvgElementImpl* ) FirstChild();
       
   118             while ( lNewElement != NULL )
       
   119                 {
       
   120                 lNewElement->GetAttributeFloat( KAtrRefX, x );
       
   121                 if ( x < xmin )
       
   122                     xmin = x;
       
   123                 lNewElement = ( CSvgElementImpl * )
       
   124                               lNewElement->NextSibling();
       
   125                 }
       
   126             aValue = xmin;
       
   127             }
       
   128         break;
       
   129         case KAtrRefY:
       
   130             {
       
   131             TFloatFixPt          ymin( KMAXFLOATFIX ), y; // 0x7fff is the maximum integer in TFixPt
       
   132             CSvgElementImpl*lNewElement = ( CSvgElementImpl* ) FirstChild();
       
   133             while ( lNewElement != NULL )
       
   134                 {
       
   135                 lNewElement->GetAttributeFloat( KAtrRefY, y );
       
   136                 if ( y < ymin )
       
   137                     ymin = y;
       
   138                 lNewElement = ( CSvgElementImpl * )
       
   139                               lNewElement->NextSibling();
       
   140                 }
       
   141             aValue = ymin;
       
   142             }
       
   143         break;
       
   144         default:
       
   145         return CSvgElementImpl::GetAttributeFloat( aNameId, aValue );
       
   146         }
       
   147     return KErrNone;
       
   148     }
       
   149 
       
   150 // *******************************************************
       
   151 // From CSvgElementImpl
       
   152 
       
   153 // perform a deep clone of this object
       
   154 // ---------------------------------------------------------------------------
       
   155 //
       
   156 // ---------------------------------------------------------------------------
       
   157 MXmlElement* CSvgDefsElementImpl::CloneL(MXmlElement*)
       
   158     {
       
   159     return NULL;
       
   160     }
       
   161 
       
   162 // ---------------------------------------------------------------------------
       
   163 //
       
   164 // ---------------------------------------------------------------------------
       
   165 TBool CSvgDefsElementImpl::DrawL( CGfx2dGc*  /* aGc */,
       
   166                                   CSvgElementImpl* /* aElement */ )
       
   167     {
       
   168     return EFalse;
       
   169     }
       
   170 
       
   171 
       
   172 // *******************************************************
       
   173 // Private
       
   174 
       
   175 // ---------------------------------------------------------------------------
       
   176 //
       
   177 // ---------------------------------------------------------------------------
       
   178 void CSvgDefsElementImpl::ConstructL( const TUint8 aElemID )
       
   179     {
       
   180     CSvgElementImpl::InitializeL( aElemID );
       
   181     }
       
   182 
       
   183 // ---------------------------------------------------------------------------
       
   184 //
       
   185 // ---------------------------------------------------------------------------
       
   186 CSvgDefsElementImpl::CSvgDefsElementImpl( CSvgDocumentImpl* aDoc )
       
   187     {
       
   188     	SetOwnerDocument( aDoc );
       
   189     }
       
   190 
       
   191 // ---------------------------------------------------------------------------
       
   192 //
       
   193 // ---------------------------------------------------------------------------
       
   194 void CSvgDefsElementImpl::Print( TBool aIsEncodeOn )
       
   195 {	
       
   196 	if (!aIsEncodeOn)
       
   197 	{
       
   198 		#ifdef _DEBUG
       
   199 		RDebug::Printf("<defs>");
       
   200 		//something in def here
       
   201 		RDebug::Printf("</defs>");
       
   202 		#endif
       
   203 	}
       
   204 }