svgtopt/SVG/SVGImpl/src/SVGScriptElementImpl.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 #include "SVGScriptElementImpl.h"
       
    20 #include "SVGDocumentImpl.h"
       
    21 #include "SVGEngineImpl.h"
       
    22 
       
    23 // ---------------------------------------------------------------------------
       
    24 // Two phase construction
       
    25 // ---------------------------------------------------------------------------
       
    26 CSvgScriptElementImpl* CSvgScriptElementImpl::NewL( TUint8 aElementId, CSvgDocumentImpl* aDocument )
       
    27     {
       
    28     CSvgScriptElementImpl*  self = new ( ELeave ) CSvgScriptElementImpl( aDocument );
       
    29     CleanupStack::PushL( self );
       
    30     self->ConstructL( aElementId );
       
    31     CleanupStack::Pop();
       
    32     return self;
       
    33     }
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 // ---------------------------------------------------------------------------
       
    38 CSvgScriptElementImpl::~CSvgScriptElementImpl()
       
    39     {
       
    40     delete iScript;
       
    41     delete iXLink;
       
    42     }
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 // ---------------------------------------------------------------------------
       
    47 const HBufC8* CSvgScriptElementImpl::GetScript()
       
    48     {
       
    49     return iScript;
       
    50     }
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // Script has "type" and "xlink:href" attributes
       
    54 // ---------------------------------------------------------------------------
       
    55 TInt CSvgScriptElementImpl::SetAttributeL( const TDesC& aName, const TDesC& aValue )
       
    56 {
       
    57     _LIT( KXlink, "xlink:href" );
       
    58     _LIT( KType, "type" );
       
    59     if ( aName == KXlink )
       
    60     {
       
    61         delete iXLink;
       
    62         iXLink = NULL;
       
    63         iXLink = aValue.Alloc();
       
    64         FetchExternalScriptL();
       
    65     }
       
    66     else if ( aName == KType )
       
    67     {
       
    68         // ignore
       
    69     }
       
    70 
       
    71     return KErrNone;
       
    72 }
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 // ---------------------------------------------------------------------------
       
    77 void CSvgScriptElementImpl::SetScriptL( const TDesC& aScriptString )
       
    78     {
       
    79     // Already have script from xlink:href
       
    80     if ( iXLink != NULL && iScript != NULL )
       
    81         {
       
    82         return;
       
    83         }
       
    84 
       
    85     delete iScript;
       
    86     iScript = NULL;
       
    87     iScript = HBufC8::NewL( aScriptString.Length() );
       
    88     iScript->Des().Copy( aScriptString );
       
    89     }
       
    90 
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 // ---------------------------------------------------------------------------
       
    94 CSvgScriptElementImpl::CSvgScriptElementImpl( CSvgDocumentImpl* aDocument )
       
    95     {
       
    96     iScript = NULL;
       
    97     iDocument = aDocument;
       
    98     }
       
    99 
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 // ---------------------------------------------------------------------------
       
   103 void CSvgScriptElementImpl::ConstructL( TUint8 aElementId )
       
   104     {
       
   105     CSvgElementImpl::InitializeL( aElementId );
       
   106     }
       
   107 
       
   108 // ---------------------------------------------------------------------------
       
   109 //
       
   110 // ---------------------------------------------------------------------------
       
   111 void CSvgScriptElementImpl::FetchExternalScriptL()
       
   112     {
       
   113     	
       
   114   	// Presently SVGT Engine is not supporting expernal script.
       
   115   	// This requires script engine which has capability to change DOM.
       
   116   	/*
       
   117     if ( iXLink != NULL && iDocument != NULL && iDocument->Engine() != NULL )
       
   118         {
       
   119         iScript = iDocument->Engine()->FetchExternalDataL( *iXLink );
       
   120         }
       
   121     */
       
   122     }
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 //
       
   126 // ---------------------------------------------------------------------------
       
   127 void CSvgScriptElementImpl::Print( TBool aIsEncodeOn )
       
   128 {
       
   129 	if (!aIsEncodeOn)
       
   130 	{
       
   131 		#ifdef _DEBUG
       
   132 		RDebug::Printf("<script xlink:href=\"hmm\">"/*, iXLink*/);
       
   133 		RDebug::Printf("hmm"/*, iScript*/);
       
   134 		RDebug::Printf("</script",this);
       
   135 		#endif
       
   136 	}
       
   137 }