Adding files needed to break SVGEngine dependency on MediaClientAudio.dll.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/breakdeps/SVGDocumentImpl.cpp Fri Oct 15 09:48:18 2010 +0100
@@ -0,0 +1,2647 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: SVG Implementation source file
+ *
+*/
+
+
+#include <utf.h>
+#include <s32mem.h>
+
+#include "SVGContentHandler.h"
+#include "Svgdecoder.h"
+
+#include "SVGDocumentImpl.h"
+#include "SVGEngineImpl.h"
+#include "SVGSvgElementImpl.h"
+#include "SVGLineElementImpl.h"
+#include "SVGRectElementImpl.h"
+#include "SVGCircleElementImpl.h"
+#include "SVGEllipseElementImpl.h"
+#include "SVGPolylineElementImpl.h"
+#include "SVGGElementImpl.h"
+#include "SVGPathElementImpl.h"
+#include "SVGMpathElementImpl.h"
+#include "SVGSchemaData.h"
+#include "SVGTextElementImpl.h"
+#include "SVGImageElementImpl.h"
+#include "SVGUseElementImpl.h"
+#include "SVGAElementImpl.h"
+#include "SVGStyleElementImpl.h"
+#include "SVGForeignObjectElementImpl.h"
+#include "SVGSetElementImpl.h"
+#include "SVGAnimateTransformElementImpl.h"
+#include "SVGAnimateElementImpl.h"
+#include "SVGAnimateMotionElementImpl.h"
+#include "SVGAnimationElementImpl.h"
+#include "SVGMetadataElementImpl.h"
+#include "SVGDescElementImpl.h"
+#include "SVGDefsElementImpl.h"
+#include "SVGTitleElementImpl.h"
+#include "SVGFontElementImpl.h"
+#include "SVGFontFaceElementImpl.h"
+#include "SVGGlyphElementImpl.h"
+#include "SVGMissingGlyphElementImpl.h"
+#include "SvgHkernelementimpl.h"
+
+#include "SVGLinearGradientElementImpl.h"
+#include "SVGRadialGradientElementImpl.h"
+#include "SvgStopElementImpl.h"
+#include "SVGDiscardElementImpl.h"
+#include "SVGScriptElementImpl.h"
+
+#include "SVGAudioElementImpl.h"
+
+//#ifdef RD_SVGT_MEDIAANIMATION_SUPPORT
+#include "SVGMediaAnimationElementImpl.h"
+//#endif
+#include "SVGTextAreaElementImpl.h"
+#include "SVGSolidColorElementImpl.h"
+
+#include "SVGFloatCssValueImpl.h"
+
+#include "SVGEventHandler.h"
+#include "SVGErrorImpl.h"
+#include "SVGFontHashMap.h"
+#include "SVGTimeContainer.h"
+#include <ezgzip.h>
+
+#include <caf/caf.h>
+#include <bautils.h>
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+CSvgDocumentImpl* CSvgDocumentImpl::NewL( CSvgBitmapFontProvider* aSvgBitmapFontProvider, const TBool aHasParent,
+ const TSvgSyncBehaviour aSyncBehavDefault,
+ const TInt32 aSyncTolDefault )
+ {
+ CSvgDocumentImpl* self = new ( ELeave ) CSvgDocumentImpl(aSvgBitmapFontProvider,
+ aHasParent, aSyncBehavDefault, aSyncTolDefault );
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop();
+
+ return self;
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+CSvgDocumentImpl* CSvgDocumentImpl::NewLC( CSvgBitmapFontProvider* aSvgBitmapFontProvider, const TBool aHasParent,
+ const TSvgSyncBehaviour aSyncBehavDefault,
+ const TInt32 aSyncTolDefault )
+ {
+ CSvgDocumentImpl* self = new ( ELeave ) CSvgDocumentImpl(aSvgBitmapFontProvider,
+ aHasParent, aSyncBehavDefault, aSyncTolDefault );
+ CleanupStack::PushL( self );
+ self->ConstructL();
+
+ return self;
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::ConstructL()
+ {
+ iSchemaData = CSvgSchemaData::NewL();
+
+
+ iEventHandler = CSvgEventHandler::NewL();
+
+ // create CSvgErrorImpl object
+// iSvgError = CSvgErrorImpl::NewL();
+ iIsInteractive = EFalse;
+ iHasGroupOpacity = EFalse;
+
+
+// iImageHashMap = CSvgImageHashMap::NewL();
+ iFontHashMap = CSvgFontHashMap::NewL();
+
+ iMemoryManager = CSvgMemoryManager::NewL();
+
+ iTimeForJSR226 = 0;
+ // Create the time container used for Runtime Sync
+ iTimeContainer = CSvgTimeContainer::NewL( this, iHasParent );
+
+ // Add to the time container
+ iTimeContainer->AddTimedEntityL( this );
+
+ //set media state to ready as default for document
+ iTimeContainer->TimedEntityReady( this );
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+CSvgDocumentImpl::CSvgDocumentImpl( CSvgBitmapFontProvider* aSvgBitmapFontProvider, const TBool aHasParent,
+ const TSvgSyncBehaviour aSyncBehavDefault,
+ const TInt32 aSyncTolDefault ) :
+ iInitSortList( ETrue ),
+ iReqExReqFtrSysLTested( EFalse ),
+ iFinishedParsing( EFalse ),
+ iFontHashMap( NULL ),
+ iEngine(NULL),
+ iMultipleRendering( EFalse ),
+ iHasGradientElement( EFalse ),
+ iIsThumbNailMode( EFalse ),
+ iIsDRMProtected( EFalse ),
+ iHasParent( aHasParent ),
+ iSyncBehaviorDefault(
+ aSyncBehavDefault ),
+ iSyncToleranceDefault(
+ aSyncTolDefault),
+ iSvgBitmapFontProvider(aSvgBitmapFontProvider)
+
+
+
+ {
+ SetDRMMode( ETrue );
+ SetDRMRights( ETrue );
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+CSvgDocumentImpl::~CSvgDocumentImpl()
+ {
+ if ( iTimeContainer )
+ {
+ // Stop timer and reset time
+ iTimeContainer->UserStop();
+ iTimeContainer->UserResetTime();
+ }
+
+ if (iPerfText)
+ {
+ delete iPerfText;
+ iPerfText = NULL;
+ }
+
+ if( iSchemaData )
+ {
+ delete iSchemaData;
+ iSchemaData = NULL;
+ }
+
+ if( iEventHandler )
+ {
+ delete iEventHandler;
+ iEventHandler = NULL ;
+ }
+
+// if( iSvgError )
+// {
+// delete iSvgError;
+// iSvgError = NULL;
+// }
+
+ if( iRootElement )
+ {
+ delete iRootElement;
+ iRootElement = NULL;
+ }
+
+/* if ( iImageHashMap )
+ {
+ //probably should check to verify that the image ptrs
+ //in this have had their images deleted somehow to be safe
+ delete iImageHashMap;
+ iImageHashMap = NULL;
+ } */
+
+ if ( iFontHashMap )
+ {
+ delete iFontHashMap;
+ iFontHashMap = NULL;
+ }
+ iSvgMouseListeners.Close();
+
+ iSvgAnimations.Close();
+
+ if ( iXmlHandler )
+ {
+ delete iXmlHandler;
+ }
+
+ if ( iError )
+ {
+ delete iError;
+ }
+
+ if ( iMemoryManager )
+ {
+ delete iMemoryManager;
+ }
+
+ delete iTimeContainer;
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::SetEngine( CSvgEngineImpl* aEngine )
+ {
+ iEngine = aEngine;
+ // Propogate this to all child documentsas well
+ // Only animation elements currently possess a new document
+ // Locate all the active animation elements
+ RPointerArray<CSvgElementImpl> lAnimationEleList;
+
+ FindAllElements(
+ (CSvgElementImpl* )RootElement(),
+ KSvgMediaAnimationElement, lAnimationEleList );
+ // Set the engine on the child documents associated with the animation elements as well
+ TInt lAnimationEleCnt = lAnimationEleList.Count();
+ for ( TInt lCurAnimationEle = 0; lCurAnimationEle < lAnimationEleCnt; lCurAnimationEle++ )
+ {
+ CSvgMediaAnimationElementImpl* lAnimationElement =
+ (CSvgMediaAnimationElementImpl* )lAnimationEleList[ lCurAnimationEle ];
+ CSvgDocumentImpl* lChildDoc = lAnimationElement->GetChildDocument();
+ if ( lChildDoc )
+ {
+ lChildDoc->SetEngine( aEngine );
+ }
+ }
+ lAnimationEleList.Close();
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+CSvgEngineImpl* CSvgDocumentImpl::Engine()
+ {
+ return iEngine;
+ }
+
+//***********************************************************************
+// From MXmlDocument
+//
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+MXmlElement* CSvgDocumentImpl::CreateElementL( const TDesC& aTagName )
+ {
+
+ TInt position = iSchemaData->GetSVGElementId(aTagName);
+
+ if ( position == KErrNotFound )
+ {
+ return NULL;
+ }
+
+ return CreateElementL( position );
+
+ }
+
+ // ==========================================================================
+// Need method description
+// ==========================================================================
+MXmlElement* CSvgDocumentImpl::CreateElementL(const TUint8 aTagName )
+ {
+
+ TInt position = (TInt) aTagName;
+
+ //##4 this uses the rearrangement of elements, all these elements are same as g element
+ // same constructor
+ //
+ // =====> creating fake G elements to take the place of others...
+ //
+ //need to remove G elements as place holders that is a bad idea
+
+ if( position >= KSvgAltglyphElement && position <= KSvgViewElement )
+ {
+ return ( MXmlElement * ) CSvgGElementImpl::NewL( (TUint8) position, this );
+ }
+
+ switch ( position )
+ {
+
+ case KSvgPathElement:
+ // path
+ return ( MXmlElement * ) CSvgPathElementImpl::NewL( (TUint8) position, this );
+
+ case KSvgStopElement:
+ // stop
+ return ( MXmlElement * ) CSvgStopElementImpl::NewL((TUint8) position,this);
+
+ case KSvgLinearGradientElement:
+ // linearGradient
+ return ( MXmlElement * ) CSvgLinearGradientElementImpl::NewL((TUint8) position,this);
+
+ case KSvgRectElement:
+ // rect
+ return ( MXmlElement * ) CSvgRectElementImpl::NewL( (TUint8) position, this );
+
+ case KSvgPolygonElement:
+ // polygon
+ return ( MXmlElement * ) CSvgPolylineElementImpl::NewL( (TUint8) position, this );
+
+ case KSvgSvgElement:
+ // svg
+ return ( MXmlElement * ) CSvgSvgElementImpl::NewL( (TUint8) position, this );
+
+ case KSvgRadialGradientElement:
+ // radialGradient
+ return ( MXmlElement * ) CSvgRadialGradientElementImpl::NewL((TUint8) position,this);
+
+ case KSvgCircleElement:
+ // circle
+ return ( MXmlElement * ) CSvgCircleElementImpl::NewL( (TUint8) position, this );
+
+ case KSvgLineElement:
+ // line
+ return ( MXmlElement * ) CSvgLineElementImpl::NewL( (TUint8) position,this );
+
+ case KSvgPolylineElement:
+ // polyline
+ return ( MXmlElement * ) CSvgPolylineElementImpl::NewL( (TUint8) position, this );
+
+ case KSvgEllipseElement:
+ // ellipse
+ return ( MXmlElement * ) CSvgEllipseElementImpl::NewL( (TUint8) position, this );
+
+ case KSvgDefsElement:
+ // defs
+ return ( MXmlElement * ) CSvgDefsElementImpl::NewL((TUint8) position, this);
+
+ case KSvgForeignObjectElement:
+ // foreignObject
+ return ( MXmlElement * ) CSvgForeignObjectElementImpl::NewL((TUint8) position, this);
+
+ case KSvgStyleElement:
+ // style
+ return ( MXmlElement * ) CSvgStyleElementImpl::NewL( (TUint8) position, this );
+
+ case KSvgUseElement:
+ // use
+ return ( MXmlElement * ) CSvgUseElementImpl::NewL( (TUint8) position, this );
+
+ case KSvgImageElement:
+ // image
+ return ( MXmlElement * ) CSvgImageElementImpl::NewL( (TUint8) position, this );
+
+ case KSvgAnimateColorElement:
+ // animateColor
+ case KSvgAnimateElement:
+ {
+ // animate
+ CSvgAnimateElementImpl* lAnimateElement = CSvgAnimateElementImpl::NewL( (TUint8) position, this );
+ iSvgAnimations.Append(lAnimateElement);
+ return ( MXmlElement * ) lAnimateElement;
+ }
+
+ case KSvgSetElement:
+ // set
+ return ( MXmlElement * ) CSvgSetElementImpl::NewL( (TUint8) position, this );
+
+ case KSvgMpathElement:
+ // mPath
+ return ( MXmlElement * ) CSvgMpathElementImpl::NewL( (TUint8) position, this );
+
+ case KSvgDiscardElement:
+ // discard
+ return ( MXmlElement * ) CSvgDiscardElementImpl::NewL( (TUint8) position, this );
+
+ /* case KSvgAnimationElement:
+ {
+ // animation
+ CSvgAnimationElementImpl* lAnimationElementImpl = CSvgAnimationElementImpl::NewL( (TUint8) position, this );
+ iSvgAnimations.Append( lAnimationElementImpl );
+ return ( MXmlElement * ) lAnimationElementImpl;
+ }
+*/
+ case KSvgScriptElement:
+ {
+ // script
+ return ( MXmlElement * ) CSvgScriptElementImpl::NewL((TUint8) position,this);
+ }
+
+ case KSvgSolidColorElement:
+ // solidColor
+ return ( MXmlElement * ) CSvgSolidColorElementImpl::NewL((TUint8) position,this);
+
+ case KSvgMetadataElement:
+ // metaData
+ return ( MXmlElement * ) CSvgMetadataElementImpl::NewL((TUint8) position, this);
+
+ case KSvgDescElement:
+ // desc
+ return ( MXmlElement * ) CSvgDescElementImpl::NewL((TUint8) position, this);
+
+ case KSvgTitleElement:
+ // title
+ return ( MXmlElement * ) CSvgTitleElementImpl::NewL((TUint8) position, this);
+
+ case KSvgTextElement:
+ // text
+ //add in the boolean thing here....
+ return ( MXmlElement * ) CSvgTextElementImpl::NewL( (TUint8) position, this );
+
+ case KSvgTextAreaElement:
+ {
+ // textArea
+ return ( MXmlElement * ) CSvgTextAreaElementImpl::NewL((TUint8) position,this);
+ }
+
+ case KSvgAnimateMotionElement:
+ {
+ // animateMotion
+ CSvgAnimateMotionElementImpl* lAnimateMotionElement = CSvgAnimateMotionElementImpl::NewL( (TUint8) position, this );
+ iSvgAnimations.Append(lAnimateMotionElement);
+ return ( MXmlElement * ) lAnimateMotionElement;
+ }
+
+ case KSvgAnimateTransformElement:
+ {
+ // animateTransform
+ CSvgAnimateTransformElementImpl* lAnimateTransformElement = CSvgAnimateTransformElementImpl::NewL( (TUint8) position, this );
+ iSvgAnimations.Append(lAnimateTransformElement);
+ return ( MXmlElement * ) lAnimateTransformElement;
+ }
+
+ case KSvgGlyphElement:
+ // glyph
+#ifdef SVG_FONTS_INCLUDE
+ return ( MXmlElement * ) CSvgGlyphElementImpl::NewL( (TUint8) position, this );
+#else
+ return ( MXmlElement * ) CSvgGElementImpl::NewL( _L( "g" ),(TUint8) position, this );
+#endif
+ case KSvgFontElement:
+ // font
+#ifdef SVG_FONTS_INCLUDE
+ return ( MXmlElement * ) CSvgFontElementImpl::NewL( (TUint8) position, this );
+#else
+ return ( MXmlElement * ) CSvgGElementImpl::NewL( _L( "g" ),(TUint8) position, this );
+#endif
+
+ case KSvgAElement:
+ // a
+ return ( MXmlElement * ) CSvgAElementImpl::NewL( (TUint8) position, this );
+
+ case KSvgFontfaceElement:
+ // font-face
+#ifdef SVG_FONTS_INCLUDE
+ return ( MXmlElement * ) CSvgFontFaceElementImpl::NewL( (TUint8) position, this );
+#else
+ return ( MXmlElement * ) CSvgGElementImpl::NewL( _L( "g" )(TUint8) position, this );
+#endif
+
+ case KSvgMissingglyphElement:
+ // missing-glyph
+#ifdef SVG_FONTS_INCLUDE
+ return ( MXmlElement * ) CSvgMissingGlyphElementImpl::NewL( (TUint8) position, this );
+#else
+ return ( MXmlElement * ) CSvgGElementImpl::NewL( _L( "g" )(TUint8) position, this );
+#endif
+
+ case KSvgHkernElement:
+ // hkern
+#ifdef SVG_FONTS_INCLUDE
+ return ( MXmlElement * ) CSvgHkernElementImpl::NewL( (TUint8) position, this );
+#else
+ return ( MXmlElement * ) CSvgGElementImpl::NewL( _L( "g" )(TUint8) position, this );
+#endif
+
+ case KSvgAudioElement:
+ {
+ CSvgAudioElementImpl* lAudioElement = CSvgAudioElementImpl::NewL( (TUint8) position, this );
+ iSvgAnimations.Append(lAudioElement);
+ return ( MXmlElement * ) lAudioElement;
+ }
+//#ifdef RD_SVGT_MEDIAANIMATION_SUPPORT
+ case KSvgMediaAnimationElement:
+ {
+ CSvgMediaAnimationElementImpl* lMediaAnimationElement = CSvgMediaAnimationElementImpl::NewL( (TUint8) position, this );
+ iSvgAnimations.Append(lMediaAnimationElement);
+ return ( MXmlElement * ) lMediaAnimationElement;
+ }
+//#endif
+
+ } // for switch
+
+ return NULL;
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+TInt CSvgDocumentImpl::CreateAttribute( const TDesC& /* aName */ )
+ {
+ return KErrNone;
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+MXmlElement* CSvgDocumentImpl::GetElementById( const TDesC& aElementId )
+ {
+ if(iRootElement)
+ {
+ const TDesC* myId = iRootElement->Id();
+
+ if (myId)
+ {
+ if (myId->Length() > 0)
+ {
+ if ( *myId == aElementId )
+ {
+ return iRootElement;
+ }
+ }
+ }
+
+ MXmlElement* element = SearchElementById( iRootElement, aElementId );
+
+ return element;
+ }
+ else
+ {
+ return NULL;
+ }
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+TInt CSvgDocumentImpl::GetNumberOfIds(MXmlElement* aElement)
+{
+ TInt count = 0;
+
+ CSvgElementImpl* child = ( CSvgElementImpl* ) aElement->FirstChild();
+ while ( child != NULL )
+ {
+ const TDesC* lPtr = child->Id();
+
+ if (lPtr)
+ {
+ count++;
+ }
+ // search children
+ TInt inside_count = GetNumberOfIds( child );
+ if ( inside_count > 0 )
+ {
+ count = count + inside_count;
+ }
+ // search siblings
+
+ child = ( CSvgElementImpl * ) child->NextSibling();
+ }
+
+ return count;
+}
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+TDesC* CSvgDocumentImpl::GetId(TInt index)
+{
+ TDesC* id = NULL;
+ RPointerArray<TDesC> ids;
+
+ FindAllIds( (CSvgElementImpl*)RootElement(), ids );
+
+ if (index < ids.Count())
+ {
+ id = ids[index];
+ }
+
+ ids.Close();
+
+ return id;
+}
+
+// ==========================================================================
+// // Return all elements of the given type
+// ==========================================================================
+void CSvgDocumentImpl::FindAllIds( CSvgElementImpl* aStartElement, RPointerArray<TDesC>& aList )
+{
+ if ( aStartElement == NULL )
+ return;
+
+ CSvgElementImpl* child = (CSvgElementImpl*)aStartElement->FirstChild();
+ while ( child != NULL )
+ {
+ // add to list if child is found
+ const TDesC* myId = child->Id();
+
+ if ( myId )
+ aList.Append( myId );
+
+ // find in grandchildren
+ FindAllIds( child, aList );
+ child = (CSvgElementImpl*)child->NextSibling();
+ }
+}
+
+
+//***********************************************************************
+// From MSvgDocument
+//
+
+
+
+//
+// ==========================================================================
+// Need method description
+// ==========================================================================
+TDesC& CSvgDocumentImpl::GetUrl()
+ {
+ return iUri;
+ }
+
+// ==========================================================================
+// // Returns the value of the current focus index.
+// ==========================================================================
+
+TInt32 CSvgDocumentImpl::GetCurFocusIndex()
+{
+ return iCurObjIdx;
+}
+
+
+// ==========================================================================
+// // Increment the focus index by one value
+// ==========================================================================
+
+TInt32 CSvgDocumentImpl::IncCurFocusIndex()
+{
+ return ++iCurObjIdx;
+}
+
+// ==========================================================================
+// // Decrement the focus index by one value
+// ==========================================================================
+TInt32 CSvgDocumentImpl::DecCurFocusIndex()
+{
+ return --iCurObjIdx;
+}
+
+// ==========================================================================
+// // Sets the focus index to the given value
+// ==========================================================================
+void CSvgDocumentImpl::SetCurFocusIndex(TInt32 aVal)
+{
+ iCurObjIdx = aVal;
+}
+
+// ==========================================================================
+// // Returns the current focus object
+// ==========================================================================
+CSvgElementImpl* CSvgDocumentImpl::GetCurFocusObject()
+{
+ return iCurrentFocusObject;
+}
+
+// ==========================================================================
+// // Sets the current focus element to the element specified
+// ==========================================================================
+void CSvgDocumentImpl::SetCurFocusObject(CSvgElementImpl* aElement)
+{
+ iCurrentFocusObject = aElement;
+}
+
+//
+// ==========================================================================
+// Need method description
+// ==========================================================================
+EXPORT_C MXmlElement* CSvgDocumentImpl::RootElement()
+ {
+ return iRootElement;
+ }
+
+//***********************************************************************
+//
+//
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+MXmlElement* CSvgDocumentImpl::SearchElementById( MXmlElement* aElement,
+ const TDesC& aElementId )
+ {
+ CSvgElementImpl* child = ( CSvgElementImpl* ) aElement->FirstChild();
+ while ( child != NULL )
+ {
+ const TDesC* lPtr = child->Id();
+
+ if (lPtr)
+ {
+ if ( *lPtr == aElementId )
+ {
+ return child;
+ }
+ }
+ // search children
+ MXmlElement* childrenMatch = SearchElementById( child, aElementId );
+ if ( childrenMatch != NULL )
+ {
+ return childrenMatch;
+ }
+ // search siblings
+
+ child = ( CSvgElementImpl * ) child->NextSibling();
+
+ }
+ return NULL;
+ }
+
+
+
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+MXmlElement* CSvgDocumentImpl::AppendChildL( MXmlElement* aNewChild )
+ {
+
+ if ( aNewChild && ((CXmlElementImpl*)aNewChild)->ElemID() == KSvgSvgElement )
+
+ {
+ // Set new node as the root element, if it is
+ if ( iRootElement )
+ {
+ return NULL;
+ }
+ iRootElement = (CSvgElementImpl *) aNewChild;
+
+ // Set the new node's next sibling
+ aNewChild->SetNextSibling( NULL );
+ }
+ else
+ {
+ return NULL;
+ }
+
+ return aNewChild;
+ }
+
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+CSvgSchemaData* CSvgDocumentImpl::SchemaData()
+ {
+ return iSchemaData;
+ }
+
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::SetUri( const TDesC& aUri )
+ {
+ iUri.Zero();
+ iUri.Copy(aUri);
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::GetUri( TDes& aUri )
+ {
+ aUri.Zero();
+ aUri.Copy(iUri);
+ }
+
+// ==========================================================================
+// Register an element for receiving events using the event mask
+// ==========================================================================
+void CSvgDocumentImpl::AddToEventReceiverListL( MSvgEventReceiver* aElement,
+ TUint8 aEventMask)
+ {
+ if (iEventHandler != NULL)
+ iEventHandler->AddToEventReceiverListL( aElement, aEventMask );
+ }
+
+// ==========================================================================
+// Register an element for receiving events and events using the event mask
+// ==========================================================================
+void CSvgDocumentImpl::AddToEventReceiverListL( MSvgEventReceiver* aElement,
+ TSvgEvent aEvent,
+ TUint8 aEventMask)
+ {
+ if (iEventHandler != NULL)
+ iEventHandler->AddToEventReceiverListL( aElement,aEvent,aEventMask );
+ }
+
+// ==========================================================================
+// Unregister an element for receiving events using the event mask
+// ==========================================================================
+void CSvgDocumentImpl::RemoveFromEventReceiverList( MSvgEventReceiver* aElement )
+ {
+ if (iEventHandler != NULL)
+ iEventHandler->RemoveFromEventReceiverList( aElement );
+ }
+
+// ==========================================================================
+// Provide event handler the event timing information for the
+// completion of event.
+// ==========================================================================
+void CSvgDocumentImpl::AddEventBeginTime(MSvgEventReceiver* aElement, TUint32 aTime, MSvgEventReceiver* aTargetElement )
+ {
+ if (iEventHandler != NULL)
+ iEventHandler->AddEventBeginTime( aElement, aTime, aTargetElement );
+ }
+
+// ==========================================================================
+// Sort the events in a time scale according to their absolute start
+// and finish times
+// ==========================================================================
+void CSvgDocumentImpl::SortEventList()
+ {
+ if (iEventHandler != NULL)
+ iEventHandler->SortEventList();
+ }
+
+//
+// ==========================================================================
+// Returns an element that is registered for the given event mask and
+// is the first one starting from the given index (either up or down the
+// list based on the aNext parameter)
+// ==========================================================================
+CSvgElementImpl* CSvgDocumentImpl::GetEventReceiverElement(TInt32 aIndex, TBool aNext, TUint8 aEventMask, TInt32& aNewIndex)
+ {
+ if (iEventHandler != NULL)
+ {
+ return (CSvgElementImpl*)iEventHandler->GetEventReceiver(aIndex, aNext, aEventMask, aNewIndex);
+ }
+ else
+ return NULL;
+
+ }
+
+// ==========================================================================
+// Is Animation file
+// ==========================================================================
+TBool CSvgDocumentImpl::IsAnimationFile()
+ {
+ if( (iEventHandler != NULL) && iEventHandler->Count() )
+ return ETrue;
+ else
+ return EFalse;
+ }
+
+// ==========================================================================
+// IsValidSubEventMask
+// ==========================================================================
+TBool CSvgDocumentImpl::IsValidSubEventMask(TUint16 aSubEventMask)
+ {
+ if(iEventHandler)
+ {
+ return(iEventHandler->IsValidSubEventMask(aSubEventMask));
+ }
+ else
+ {
+ return EFalse;
+ }
+ }
+// ==========================================================================
+// Set DRM Mode
+// ==========================================================================
+
+void CSvgDocumentImpl::SetDRMMode(TBool aEnable)
+ {
+ iDrmEnable = aEnable;
+ }
+// ==========================================================================
+// Set DRM Mode
+// ==========================================================================
+void CSvgDocumentImpl::Reset(MSvgEvent *aEvent)
+ {
+ if ( iAnimationResetNeeded && iEventHandler != NULL )
+ {
+ iEventHandler->Reset( aEvent );
+ iAnimationResetNeeded = EFalse;
+ }
+ }
+// ==========================================================================
+// Set DRM Mode
+// ==========================================================================
+TBool CSvgDocumentImpl::SvgElementPresent(CSvgElementImpl* aElement)
+{
+ if(iRootElement == NULL) return EFalse;
+ if ( ( ( CSvgElementImpl * ) iRootElement ) == aElement )
+ {
+ return ETrue;
+ }
+
+ return SearchByPointer(iRootElement, aElement);
+
+}
+// ==========================================================================
+// Set DRM Mode
+// ==========================================================================
+TBool CSvgDocumentImpl::SearchByPointer(CSvgElementImpl* aParent, CSvgElementImpl* aElement)
+{
+ CSvgElementImpl* child = ( CSvgElementImpl* ) aParent->FirstChild();
+ while ( child != NULL )
+ {
+
+ if ( child == aElement )
+ {
+ return ETrue;
+ }
+ // search children
+ TBool result = SearchByPointer( child, aElement );
+ if (result)
+ {
+ return ETrue;
+ }
+ // search siblings
+ child = ( CSvgElementImpl * ) child->NextSibling();
+ }
+ return EFalse;
+}
+// ==========================================================================
+// Set DRM Mode
+// ==========================================================================
+void CSvgDocumentImpl::SetFocusElement(CXmlElementImpl* aElement )
+{
+ iCurrentFocusObject = (CSvgElementImpl*)aElement;
+}
+// ==========================================================================
+// Set DRM Mode
+// ==========================================================================
+CXmlElementImpl* CSvgDocumentImpl::GetFocusElement()
+{
+ return (CXmlElementImpl*) iCurrentFocusObject;
+}
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::ReInitialize()
+ {
+ if(iMultipleRendering)
+ {
+ if (iEventHandler != NULL)
+ iEventHandler->ReInitialize();
+ }
+ else
+ {
+ iMultipleRendering= ETrue;
+ }
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::Load( const TDesC& aFileName, CSvgErrorImpl& aError )
+{
+ aError.SetErrorCode( ESvgNoError );
+
+ RFs session;
+ OpenSession( session, aError );
+ if ( aError.HasError() )
+ return;
+
+ RFile fileHandle;
+ TInt openError = fileHandle.Open( session, aFileName, EFileRead );
+ if ( openError != KErrNone )
+ {
+ PrepareError( aError, ESvgUnknown, openError,
+ _L( "Fail to open file for reading: " ), aFileName );
+ session.Close();
+ return;
+ }
+ else
+ {
+ Load( fileHandle, aError );
+ session.Close();
+ }
+}
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::Load( const TDesC8& aByteData, CSvgErrorImpl& aError, TBool aRemoveFalseSwitchElements )
+{
+ aError.SetErrorCode( ESvgNoError );
+
+ //-------------------------------------------------------------------
+ // Byte array is gzipped and/or drm:
+ // Write buffer to file:
+ // a) GZip only has filename function to unzip
+ // b) Drm only has file-handle to decrypt
+ //-------------------------------------------------------------------
+ if ( IsGzipContent( aByteData ) ||
+ ( iDrmEnable && IsDRMContent( aByteData ) ) )
+ {
+ RFs session;
+ OpenSession( session, aError );
+ if ( aError.HasError() )
+ return;
+
+ // Write byte-array to temp file
+ TFileName zippedTempFilename;
+ if ( WriteToTempFile( session, aByteData, zippedTempFilename, aError ) != KErrNone )
+ {
+ session.Close();
+ return;
+ }
+ Load( zippedTempFilename, aError );
+ session.Delete( zippedTempFilename );
+ session.Close();
+ }
+ //-------------------------------------------------------------------
+ // byte-array is neither gzipped nor DRM encrypted
+ //-------------------------------------------------------------------
+ else
+ {
+ iIsDRMProtected = EFalse;
+ iEventHandler->Reset();
+ TRAPD(error,ProcessSvgContentL( aByteData, aError, aRemoveFalseSwitchElements ));
+ if ( error != KErrNone )
+ {
+ PrepareError( aError, ESvgNoMemory, error,
+ _L( "Out of Memory: " ),
+ _L( "Instantiating Parser" ) );
+ }
+
+ iInitialDrawFlag = ETrue;
+ iFinishedParsing = ETrue;
+
+ }
+}
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::Load( RFile& aFileHandle, CSvgErrorImpl& aError )
+{
+ aError.SetErrorCode( ESvgNoError );
+
+ RFs session;
+ OpenSession( session, aError );
+ if ( !aError.HasError() )
+ {
+ Load( session, aFileHandle, aError );
+ session.Close();
+ }
+}
+// -----------------------------------------------------------------------------
+// CSvgDocumentImpl::ParentTimeContainerTick
+// From MSvgTimedEntityInterface
+// -----------------------------------------------------------------------------
+//
+void CSvgDocumentImpl::ParentTimeContainerTick(
+ TSvgTick aTick ) // Current tick information
+ {
+ TBool lDoRedraw = ETrue;
+ if ( iHasParent )
+ {
+ // Do not redraw in child document to avoid
+ // double redraws.
+ lDoRedraw = EFalse;
+ }
+ // Create timer event and propogate to engine
+ TSvgTimerEvent lTimerEvent( aTick.iParentTcTick );
+ // Send to engine to process the timer event
+ TRAPD( lProcEvtErr, Engine()->ProcessEventL(
+ this, &lTimerEvent, lDoRedraw ) );
+ if ( lProcEvtErr != KErrNone )
+ {
+ // Error Processing
+ }
+ }
+
+// -----------------------------------------------------------------------------
+// CSvgDocumentImpl::GetEntitySyncBehavior
+// From MSvgTimedEntityInterface
+// -----------------------------------------------------------------------------
+//
+TSvgSyncBehaviour CSvgDocumentImpl::GetEntitySyncBehavior()
+ {
+ // Document is locked with the parent tc timeline
+ return ESvgSyncLocked;
+ }
+
+
+// -----------------------------------------------------------------------------
+// CSvgDocumentImpl::GetEntityCurrentTime
+// From MSvgTimedEntityInterface
+// -----------------------------------------------------------------------------
+//
+void CSvgDocumentImpl::GetEntityCurrentTime( TUint32&
+ /* aEntityCurTime */) // Current Entity Time in msecs.
+ {
+ }
+
+// -----------------------------------------------------------------------------
+// CSvgDocumentImpl::GetCnfSyncMasterStatus
+// From MSvgTimedEntityInterface
+// -----------------------------------------------------------------------------
+//
+void CSvgDocumentImpl::GetCnfSyncMasterStatus(
+ TBool& aIsSyncMaster ) // Indicates whether the element is configured as
+ // Sync Master.
+ {
+ // Document can never be a sync master
+ aIsSyncMaster = EFalse;
+ }
+
+// -----------------------------------------------------------------------------
+// CSvgDocumentImpl::GetCurSyncMasterStatus
+// From MSvgTimedEntityInterface
+// -----------------------------------------------------------------------------
+void CSvgDocumentImpl::GetCurSyncMasterStatus(
+ TBool& aIsSyncMaster ) // Indicates whether the element is currrently
+ // Sync Master.
+ {
+ // Document can never be a sync master
+ aIsSyncMaster = EFalse;
+ }
+
+
+// -----------------------------------------------------------------------------
+// CSvgDocumentImpl::SetCurSyncMasterStatus
+// From MSvgTimedEntityInterface
+// -----------------------------------------------------------------------------
+void CSvgDocumentImpl::SetCurSyncMasterStatus(
+ TBool /*aSyncMasterStatus */) // Indicates whether the element is
+ // currrently Sync Master.
+ {
+ // Document sync master status is always false as it can never be
+ // a sync master
+ }
+
+// -----------------------------------------------------------------------------
+// CSvgDocumentImpl::CanGenerateTick
+// From MSvgTimedEntityInterface
+// -----------------------------------------------------------------------------
+TBool CSvgDocumentImpl::CanGenerateTick()
+ {
+ // Document cannot generate tick, as it is not a inherently timed element
+ return EFalse;
+ }
+
+// -----------------------------------------------------------------------------
+// CSvgDocumentImpl::CanUseParentTick
+// From MSvgTimedEntityInterface
+// -----------------------------------------------------------------------------
+TBool CSvgDocumentImpl::CanUseParentTick()
+ {
+ // Return True as document can always use parent tick to
+ // advance itself
+ return ( ETrue );
+ }
+
+// -----------------------------------------------------------------------------
+// CSvgDocumentImpl::ResyncTimedEntity
+// From MSvgTimedEntityInterface
+// -----------------------------------------------------------------------------
+void CSvgDocumentImpl::ResyncTimedEntity(
+ TUint32 /*aSynctime*/ ) // Time for resync in msecs.
+ {
+ }
+
+
+
+// -----------------------------------------------------------------------------
+// CSvgDocumentImpl::PauseTimedEntity
+// From MSvgTimedEntityInterface
+// -----------------------------------------------------------------------------
+void CSvgDocumentImpl::PauseTimedEntity()
+ {
+
+ }
+
+// -----------------------------------------------------------------------------
+// CSvgDocumentImpl::ResumeTimedEntity
+// From MSvgTimedEntityInterface
+// -----------------------------------------------------------------------------
+void CSvgDocumentImpl::ResumeTimedEntity()
+ {
+
+ }
+
+// -----------------------------------------------------------------------------
+// CSvgDocumentImpl::StopTimedEntity
+// From MSvgTimedEntityInterface
+// -----------------------------------------------------------------------------
+void CSvgDocumentImpl::StopTimedEntity()
+ {
+ iEventHandler->ResetTimes();
+ }
+
+
+//From MSvgTimedEntityInterface
+TSvgObjectType CSvgDocumentImpl::ObjectType()
+{
+ return ESvgDocumentElement;
+}
+
+
+//returns the child time container of the element
+//used in timecontainer
+CSvgTimeContainer* CSvgDocumentImpl::GetChildTimeContainer()
+{
+ return NULL;
+}
+
+
+//if node has a child
+// visit the child call postorder on that
+//add current node
+//if there are siblings
+// visit all siblings
+void CSvgDocumentImpl::ParsePostOrderMediaElements( CSvgElementImpl* aRoot,
+ RPointerArray<CSvgElementImpl>& aPostOrderList)
+ {
+ if ( !aRoot )
+ {
+ return;
+ }
+
+ CSvgElementImpl* lNodePtr = ( CSvgElementImpl* )aRoot->FirstChild();
+ while ( lNodePtr != NULL )
+ {
+ ParsePostOrderMediaElements( lNodePtr, aPostOrderList );
+ lNodePtr = (CSvgElementImpl* )(lNodePtr->NextSibling() );
+ }
+
+ // Add only media elements, currently animation and audio
+ if ( aRoot->ElemID() == KSvgMediaAnimationElement ||
+ aRoot->ElemID() == KSvgAudioElement )
+ {
+ aPostOrderList.Append( aRoot );
+ }
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::Load( RFs& aSession, RFile& aFileHandle, CSvgErrorImpl& aError )
+{
+ iEventHandler->Reset();
+
+ RFile ungzippedFile;
+ RFile* fileHandle = &aFileHandle;
+ TFileName tempFilename;
+ TBool needToDeleteTempFile = EFalse;
+ iIsDRMProtected = EFalse;
+
+ //************************************************
+ // Check for gzip format: write to temp file
+ //************************************************
+ // Ignore Gzip content due to platform security: uncompressed file must be created
+ if ( IsGzipContent( aFileHandle ) )
+ {
+ //************************************************
+ // Ungzipped content may be DRM or txt-svg or binary-svg
+ //************************************************
+ needToDeleteTempFile = ETrue;
+ if ( !ProcessGZipContent( aSession, aFileHandle, tempFilename, aError ) )
+ return;
+
+ // Open ungzipped file
+ TInt openError = ungzippedFile.Open( aSession, tempFilename, EFileRead );
+ if ( openError != KErrNone )
+ {
+ // couldn't open temp file for writing
+ PrepareError( aError, ESvgUnknown, openError,
+ _L( "Loading GZipped SVG File failed: " ),
+ _L( "Error Opening Temp File for Reading." ) );
+
+ // Delete uncompress temp file if needed
+ if ( needToDeleteTempFile )
+ aSession.Delete( tempFilename );
+ return;
+ }
+ fileHandle = &ungzippedFile;
+ }
+
+ HBufC8* svgByteArray = NULL;
+ //************************************************
+ // Decrypt DRM
+ //************************************************
+ if ( iDrmEnable && IsDRMContent( *fileHandle ) )
+ {
+ TRAPD( drmError, svgByteArray = ProcessDRMContentL( *fileHandle, aError ) );
+ if ( drmError != KErrNone )
+ {
+ PrepareError( aError, ESvgNoMemory, drmError,
+ _L( "Out of Memory: " ),
+ _L( "Instantiating DRM Decoder" ) );
+ return;
+ }
+ // drm failed, error should already be set
+ else if ( svgByteArray == NULL )
+ {
+ return;
+ }
+
+ if ( needToDeleteTempFile && ( drmError || svgByteArray == NULL ) )
+ {
+ aSession.Delete( tempFilename );
+ }
+ iIsDRMProtected = ETrue;
+ }
+ // Read Non encrypted data
+ else
+ {
+ //************************************************
+ // Read plain file: txt-svg or binary-svg
+ //************************************************
+ TInt fileLength = 0;
+ fileHandle->Size( fileLength );
+ TRAPD( error, svgByteArray = HBufC8::NewL( fileLength ) );
+ if ( error != NULL )
+ {
+ PrepareError( aError, ESvgNoMemory, error,
+ _L( "Out of Memory" ),
+ _L( "Allocating byte-array for data" ) );
+ if ( needToDeleteTempFile )
+ {
+ aSession.Delete( tempFilename );
+ }
+ return;
+ }
+ TInt pos = 0;
+ fileHandle->Seek( ESeekStart, pos );
+ TPtr8 des = svgByteArray->Des();
+ TInt readError = fileHandle->Read( des );
+ if ( readError != KErrNone )
+ {
+ PrepareError( aError, ESvgUnknown, readError,
+ _L( "Reading SVG File Failed." ), _L( "" ) );
+ delete svgByteArray;
+ if ( needToDeleteTempFile )
+ {
+ aSession.Delete( tempFilename );
+ }
+ return;
+ }
+ }
+
+ //************************************************
+ // Parser binary or plain svg content
+ //************************************************
+ TRAPD( svgError, ProcessSvgContentL( *svgByteArray, aError ) );
+ if ( svgError != KErrNone || ( aError.HasError() && !aError.IsWarning() ) )
+ {
+ delete svgByteArray;
+ if ( !aError.HasError() )
+ {
+ PrepareError( aError, ESvgNoMemory, svgError,
+ _L( "Out of Memory: " ),
+ _L( "Instantiating SVG ContentHandler/Decoder" ) );
+ }
+ if ( needToDeleteTempFile )
+ aSession.Delete( tempFilename );
+ return;
+ }
+
+ iInitialDrawFlag = ETrue;
+ iFinishedParsing = ETrue;
+
+ delete svgByteArray;
+
+
+ // Delete uncompress temp file if needed
+ if ( needToDeleteTempFile )
+ {
+ // Close only when file handle is for temp file
+ fileHandle->Close();
+ aSession.Delete( tempFilename );
+ }
+
+ // Prepare engine to draw document
+ LoadingCompleted();
+}
+
+// ==========================================================================
+// Need method description
+// Leaves only when allocating memory fails
+// Reports other errors
+// ==========================================================================
+void CSvgDocumentImpl::ProcessSvgContentL( const TDesC8& aByteArray, CSvgErrorImpl& aError, TBool aRemoveFalseSwitchElements )
+{
+ //************************************************
+ // Determine binary or xml svg file
+ //************************************************
+ if ( IsBinarySvg( aByteArray ) )
+ {
+ TInt error = KErrNone;
+ CSvgDecoder* decoder = CSvgDecoder::NewL( aByteArray );
+
+ TRAP( error, iRootElement = decoder->StartDecodingL( this, aError ) );
+ if ( error != KErrNone || iRootElement == NULL && !aError.HasError() )
+ {
+ if ( error != KErrNone )
+ {
+ PrepareError( aError, ESvgbFileNotValid, error,
+ _L( "Invalid binary file." ), _L( "" ) );
+ }
+ }
+ delete decoder;
+ }
+ else
+ {
+ iXmlHandler = CSvgContentHandler::NewL( aRemoveFalseSwitchElements );
+ iRootElement = iXmlHandler->ParseByteData( this, aByteArray, aError );
+ delete iXmlHandler;
+ iXmlHandler = NULL;
+ }
+}
+
+// ==========================================================================
+// JSR226 only!!
+// Allows filling of document from JSR side with 16 bit string instead of 8
+//
+// ==========================================================================
+void CSvgDocumentImpl::Load16BitString( const TDesC16& aSvgString, CSvgErrorImpl& aError, TBool aRemoveFalseSwitchElements )
+{
+ aError.SetErrorCode( ESvgNoError );
+
+ iIsDRMProtected = EFalse;
+
+ if (iEventHandler)
+ iEventHandler->Reset();
+ TRAPD(error,Process16BitSvgContentL( aSvgString, aError, aRemoveFalseSwitchElements ));
+ if ( error != KErrNone )
+ {
+ PrepareError( aError, ESvgNoMemory, error,
+ _L( "Out of Memory: " ),
+ _L( "Instantiating Parser" ) );
+ }
+
+ iInitialDrawFlag = ETrue;
+ iFinishedParsing = ETrue;
+}
+
+void CSvgDocumentImpl::Process16BitSvgContentL( const TDesC16& aSvgString, CSvgErrorImpl& aError, TBool aRemoveFalseSwitchElements )
+{
+ iXmlHandler = CSvgContentHandler::NewL( aRemoveFalseSwitchElements );
+ iRootElement = iXmlHandler->Parse16BitData( this, aSvgString, aError );
+ delete iXmlHandler;
+ iXmlHandler = NULL;
+}
+// END OF JSR226 ONLY
+// ==========================================================================
+
+// ==========================================================================
+void CSvgDocumentImpl::CancelParsing()
+ {
+ // Check if there is animation element in the parent svg
+ RPointerArray<CSvgElementImpl> lAnimationEleList;
+ FindAllElements((CSvgElementImpl* )RootElement(),
+ KSvgMediaAnimationElement, lAnimationEleList );
+ TInt lAnimationEleCnt = lAnimationEleList.Count();
+ for ( TInt lCurAnimationEle = 0;
+ lCurAnimationEle < lAnimationEleCnt; lCurAnimationEle++ )
+ {
+ CSvgMediaAnimationElementImpl* lAnimationElement =
+ (CSvgMediaAnimationElementImpl* )lAnimationEleList[ lCurAnimationEle ];
+ CSvgDocumentImpl* lChildDoc = lAnimationElement->GetChildDocument();
+ if ( lChildDoc )
+ {
+ lChildDoc->CancelParsing(); // Cancel parsing on child svg
+ }
+ }
+ lAnimationEleList.Close();
+ if ( iXmlHandler )
+ {
+ iXmlHandler->CancelParsing();
+ }
+ }
+
+// ==========================================================================
+TBool CSvgDocumentImpl::IsParsing()
+ {
+ // xml handler is set to NULL after parsing
+ return iXmlHandler != NULL;
+ }
+
+//***************************************************************************
+// The function isGroupOpacity checks to see if there is a valid opacity
+// attribute.
+//***************************************************************************
+
+TBool CSvgDocumentImpl::isGroupOpacity( CSvgElementImpl* aElement )
+{
+ TBool lReturnValue = EFalse;
+ CCssValue* lCssValue = NULL;
+
+ aElement->FindProperty( KCSS_ATTR_GROUP_OPACITY, lCssValue, aElement );
+ if ( lCssValue )
+ {
+ if ( ((CFloatCssValueImpl*)lCssValue)->Value() != KFloatFixOne )
+ {
+ // valid opacity value
+ lReturnValue = ETrue;
+ }
+ }
+
+ return lReturnValue;
+}
+
+
+// ==========================================================================
+// Pre-condition: content is DRM
+// The content of a DRM may be svg-text or svg-bin
+// Leaves only for memory allocation failure
+// ==========================================================================
+HBufC8* CSvgDocumentImpl::ProcessDRMContentL( RFile& aFileHandle, CSvgErrorImpl& aError )
+{
+ // Open File Content and Data
+ ContentAccess::CContent* content = ContentAccess::CContent::NewLC(
+ aFileHandle );
+ // Note: very important to use EView and NOT EPlay
+ ContentAccess::CData* data = content->OpenContentLC( ContentAccess::EView );
+
+ // Read Length of Content
+ TInt length = 0;
+ TRAPD( sizeError, data->DataSizeL( length ) );
+ // Cannot get length of data
+ if ( sizeError != KErrNone )
+ {
+ ProcessDRMError( sizeError, aError );
+ CleanupStack::PopAndDestroy( 2 );
+ return NULL;
+ }
+
+ // Allocate Memory for Content: no leavable command after this
+ // so, pushing onto cleanup stack not needed
+ HBufC8* buffer = HBufC8::NewL( length );
+
+ TPtr8 des = buffer->Des();
+ TInt readError = data->Read( des );
+
+ // Check for read error
+ if ( readError != KErrNone )
+ {
+ ProcessDRMError( readError, aError );
+ CleanupStack::PopAndDestroy( 2 );
+ delete buffer;
+ return NULL;
+ }
+ // Only consume rights when not in thumb nail mode
+ else if ( !iIsThumbNailMode )
+ {
+ // Do not consume drm rights if iDrmRightsConsumptionEnabled is EFalse
+ if(iDrmRightsConsumptionEnabled)
+ {
+ TInt intentError = data->ExecuteIntent( ContentAccess::EView );
+ if ( intentError != KErrNone )
+ {
+ ProcessDRMError( readError, aError );
+ aError.SetIsWarning( ETrue );
+ }
+ }
+ }
+ CleanupStack::PopAndDestroy( 2 );
+ return buffer;
+}
+
+// ==========================================================================
+// Un-gzip to a temp file and return the name of temp file
+// ==========================================================================
+TBool CSvgDocumentImpl::ProcessGZipContent( RFs& aSession,
+ RFile& aGZipFileHandle,
+ TFileName& aUnzippedFileName ,
+ CSvgErrorImpl& aError )
+{
+ // Write data to temp file: gzip does not have function to read RFile
+ TFileName gzipFilename;
+ if ( WriteToTempFile( aSession, aGZipFileHandle, gzipFilename, aError ) != KErrNone )
+ return EFalse;
+
+ TBool result = ProcessGZipContent( aSession, gzipFilename, aUnzippedFileName, aError );
+
+ // Delete temp gzipped file
+ aSession.Delete( gzipFilename );
+
+ return result;
+}
+
+// ==========================================================================
+// Uncompress to a temporary file
+// ==========================================================================
+TBool CSvgDocumentImpl::ProcessGZipContent( RFs& aSession,
+ TFileName& aZippedFileName,
+ TFileName& aUnzippedFileName ,
+ CSvgErrorImpl& aError )
+{
+ // Create ungzipped temp file
+ TFileName path;
+ GetProcessPrivatePath( aSession, path );
+ RFile gzipOutputFile;
+ TInt replaceError = gzipOutputFile.Temp( aSession, path, aUnzippedFileName, EFileWrite );
+ if ( replaceError != KErrNone )
+ {
+ // couldn't open temp file for writing
+ PrepareError( aError, ESvgUnknown, replaceError,
+ _L( "Failed to create file or unGZip: " ), aUnzippedFileName );
+ return EFalse;
+ }
+
+ // okay so far, uncompressing
+ CEZGZipToFile* uncompressor = NULL;
+ TRAPD( uncompressorError,
+ uncompressor = CEZGZipToFile::NewL( aSession, aZippedFileName, gzipOutputFile ) )
+ if ( uncompressorError != KErrNone )
+ {
+ PrepareError( aError, ESvgUnknown, uncompressorError,
+ _L( "Out of memory: " ),
+ _L( "Instantiating GZip decompressor" ) );
+ gzipOutputFile.Close();
+ aSession.Delete( aUnzippedFileName );
+
+ return EFalse;
+ }
+
+ // Decompress file
+ TBool done = EFalse;
+ while ( !done )
+ {
+ TRAPD( inflateError, done = !uncompressor->InflateL() );
+ if ( inflateError != KErrNone )
+ {
+ PrepareError( aError, ESvgUnknown, inflateError,
+ _L( "Uncompressing GZip file failed." ), _L( "" ) );
+ delete uncompressor;
+ gzipOutputFile.Close();
+ aSession.Delete( aUnzippedFileName );
+
+ return EFalse;
+ }
+ }
+
+ gzipOutputFile.Close();
+ delete uncompressor;
+
+ return ETrue;
+}
+
+// ==========================================================================
+// Error codes taken from caf/content.h
+// ==========================================================================
+void CSvgDocumentImpl::ProcessDRMError( TInt errorCode, CSvgErrorImpl& aError )
+{
+ if ( errorCode == KErrNone )
+ return;
+
+ if ( errorCode == KErrNotFound )
+ {
+ aError.SetDescription( _L( "Content Not Found" ) );
+ }
+ else if ( errorCode == KErrCAPendingRights )
+ {
+ aError.SetDescription( _L( "Rights Have Not Arrived" ) );
+ }
+ else if ( errorCode == KErrCANoPermission )
+ {
+ aError.SetDescription( _L( "No Permission to Play Content" ) );
+ }
+ else if ( errorCode == KErrCANoRights )
+ {
+ aError.SetDescription( _L( "No Rights Exists for Content" ) );
+ }
+ else if ( errorCode == KErrCANotSupported )
+ {
+ aError.SetDescription( _L( "Unable to Open Content" ) );
+ }
+ else if ( errorCode == KErrPermissionDenied )
+ {
+ aError.SetDescription( _L( "No Permission to Open Content" ) );
+ }
+ else if ( errorCode == KErrAccessDenied )
+ {
+ aError.SetDescription( _L( "Content Already in Use or No DRM Capability" ) );
+ }
+ else if ( errorCode == KErrCASizeNotDetermined )
+ {
+ aError.SetDescription( _L( "Cannot Determine Size of Content" ) );
+ }
+ else
+ {
+ aError.SetDescription( _L( "Unknown DRM Error" ) );
+ }
+ aError.SetIsWarning( EFalse );
+ aError.SetErrorCode( ESvgDRMFailure );
+ aError.SetSystemErrorCode( errorCode );
+}
+
+// ==========================================================================
+// Returns true if the first two bytes of the given file could be a gzip file.
+// This function is modified from the function in EZGZipFile class.
+// ==========================================================================
+TBool CSvgDocumentImpl::IsGzipContent( RFile& aFileHandle )
+{
+ TUint8 ids[2];
+ TPtr8 des( ids, 0, sizeof( TUint8 ) * 2 );
+
+ if ( aFileHandle.Read( des ) != KErrNone )
+ return EFalse;
+
+ // reset to start of file
+ TInt zero = 0;
+ aFileHandle.Seek( ESeekStart, zero );
+ return ( ids[0] == 31 && ids[1] == 139 );
+// return ( ids[0] == EZGZipFile::ID1 && ids[1] == EZGZipFile::ID2 );
+}
+
+// ==========================================================================
+// Returns whether the byte-array header matches a GZIP signature
+// ==========================================================================
+TBool CSvgDocumentImpl::IsGzipContent( const TDesC8& aByteArray )
+{
+ return aByteArray.Length() >= 2 &&
+ aByteArray[0] == 31 && aByteArray[1] == 139;
+// aByteArray[0] == EZGZipFile::ID1 && aByteArray[1] == EZGZipFile::ID2;
+}
+
+// ==========================================================================
+// Returns whether the byte-array header matches a SVG binary signature
+// ==========================================================================
+TBool CSvgDocumentImpl::IsBinarySvg( const TDesC8& aByteArray )
+{
+ //const TUint32 KBinaryFile = 66737868;
+ //const TUint32 KBinaryFile2 = 66737869;
+
+ if ((aByteArray.Length() >= 4 &&
+ aByteArray[0] == 0xCC && aByteArray[1] == 0x56 &&
+ aByteArray[2] == 0xFA && aByteArray[3] == 0x03) ||
+ (aByteArray.Length() >= 4 &&
+ aByteArray[0] == 0xCD && aByteArray[1] == 0x56 &&
+ aByteArray[2] == 0xFA && aByteArray[3] == 0x03) ||
+ (aByteArray.Length() >= 4 &&
+ aByteArray[0] == 0xCE && aByteArray[1] == 0x56 &&
+ aByteArray[2] == 0xFA && aByteArray[3] == 0x03) ||
+ (aByteArray.Length() >= 4 &&
+ aByteArray[0] == 0xCF && aByteArray[1] == 0x56 &&
+ aByteArray[2] == 0xFA && aByteArray[3] == 0x03) )
+ {
+ return ETrue;
+ }
+ else
+ {
+ return EFalse;
+ }
+}
+
+// ==========================================================================
+// Returns whether the file header matches a DRM signature
+// ==========================================================================
+TBool CSvgDocumentImpl::IsDRMContent( RFile& aFileHandle )
+{
+ TUint8 ids[2];
+ TPtr8 des( ids, 0, sizeof( TUint8 ) * 2 );
+
+ if ( aFileHandle.Read( des ) != KErrNone )
+ return EFalse;
+
+ // reset to start of file
+ TInt zero = 0;
+ aFileHandle.Seek( ESeekStart, zero );
+ return ( ids[0] == 0x01 && ids[1] == 0x0D );
+}
+
+// ==========================================================================
+// Returns whether the file header matches a DRM signature
+// ==========================================================================
+TBool CSvgDocumentImpl::IsDRMContent( const TDesC8& aByteArray )
+{
+ return ( aByteArray.Length() > 1 && aByteArray[0] == 0x01 && aByteArray[1] == 0x0D );
+}
+
+// ==========================================================================
+// Generate the "c:/private/<sid>" directory name
+// ==========================================================================
+TInt CSvgDocumentImpl::GetProcessPrivatePath( RFs& aSession, TFileName& aPath )
+{
+ aSession.PrivatePath( aPath );
+ aPath.Insert( 0, _L( "c:" ) );
+ return KErrNone;
+}
+
+// ==========================================================================
+// Create "c:/private/<sid>" directory if it does not already exist
+// ==========================================================================
+TInt CSvgDocumentImpl::CreateProcessPrivateDirectory( RFs& aSession, TFileName& aPath )
+{
+ GetProcessPrivatePath( aSession, aPath );
+ return ( !BaflUtils::FolderExists( aSession, aPath ) ) ? aSession.MkDir( aPath ) : KErrNone;
+}
+
+// ==========================================================================
+// Open a file session, error is indicated in aError
+// ==========================================================================
+void CSvgDocumentImpl::OpenSession( RFs& aSession, CSvgErrorImpl& aError )
+{
+ TInt error = aSession.Connect();
+ if ( error != KErrNone )
+ {
+ // couldn't open temp file for writing
+ PrepareError( aError, ESvgUnknown, error,
+ _L( "Connecting File Session Failed." ), _L( "" ) );
+ }
+}
+
+// ==========================================================================
+// Session must be opened successfully
+// File name of temp file is store in aFilename
+// ==========================================================================
+TInt CSvgDocumentImpl::WriteToTempFile( RFs& aSession, const TDesC8& aByteArray,
+ TFileName& aFilename, CSvgErrorImpl& aError )
+{
+ // Create temporary file for byte-array
+ TFileName path;
+ CreateProcessPrivateDirectory( aSession, path );
+ RFile writeFile;
+ TInt tempError = writeFile.Temp( aSession, path, aFilename, EFileWrite );
+ if ( tempError != KErrNone )
+ {
+ PrepareError( aError, ESvgUnknown, tempError,
+ _L( "Failed open temp file to write data." ), aFilename );
+ return tempError;
+ }
+
+ // Write byte-array to file
+ TInt writeError = writeFile.Write( aByteArray );
+ if ( writeError != KErrNone )
+ {
+ PrepareError( aError, ESvgUnknown, writeError,
+ _L( "Failed to write data to temp file." ), aFilename );
+ writeFile.Close();
+ aSession.Delete( aFilename );
+ return writeError;
+ }
+ writeFile.Flush();
+ writeFile.Close();
+
+ return KErrNone;
+}
+
+// ==========================================================================
+// Session must be opened successfully
+// File name of temp file is store in aFilename
+// ==========================================================================
+TInt CSvgDocumentImpl::WriteToTempFile( RFs& aSession, RFile& aFileHandle,
+ TFileName& aFilename, CSvgErrorImpl& aError )
+{
+ // Create temporary file for byte-array
+ TFileName path;
+ CreateProcessPrivateDirectory( aSession, path );
+ RFile writeFile;
+ TInt tempError = writeFile.Temp( aSession, path, aFilename, EFileWrite );
+ if ( tempError != KErrNone )
+ {
+ PrepareError( aError, ESvgUnknown, tempError,
+ _L( "Failed open temp file to write data." ), path );
+ return tempError;
+ }
+
+ // Write data to temp file
+ TInt size;
+ TInt sizeError = aFileHandle.Size( size );
+ if ( sizeError != KErrNone )
+ {
+ PrepareError( aError, ESvgUnknown, sizeError,
+ _L( "Failed to get data length of file." ), aFilename );
+ aSession.Delete( aFilename );
+ return sizeError;
+ }
+
+ TBuf8<1024> buffer;
+ TInt bytesCopied = 0;
+ while ( bytesCopied < size )
+ {
+ buffer.Zero();
+ TInt bytesToCopy = ( size - bytesCopied < 1024 ) ? size - bytesCopied : 1024;
+ // read data
+ TInt readError = aFileHandle.Read( buffer, bytesToCopy );
+ if ( readError != KErrNone )
+ {
+ PrepareError( aError, ESvgUnknown, readError,
+ _L( "Failed to read data to copy to temp file: " ), aFilename );
+ writeFile.Close();
+ aSession.Delete( aFilename );
+ return readError;
+ }
+ // write data
+ TInt writeError = writeFile.Write( buffer, bytesToCopy );
+ if ( writeError != KErrNone )
+ {
+ PrepareError( aError, ESvgUnknown, writeError,
+ _L( "Failed to write to temp file: " ), aFilename );
+ writeFile.Close();
+ aSession.Delete( aFilename );
+ return writeError;
+ }
+ bytesCopied += bytesToCopy;
+ }
+
+ writeFile.Flush();
+ writeFile.Close();
+
+ return KErrNone;
+}
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::PrepareError( CSvgErrorImpl& aError,
+ TSvgErrorCode aSvgErrorCode,
+ TInt aSystemErrorCode,
+ const TDesC& aMsg1,
+ const TDesC& aMsg2 )
+{
+ aError.SetDescription( aMsg1, aMsg2 );
+ aError.SetErrorCode( aSvgErrorCode );
+ aError.SetSystemErrorCode( aSystemErrorCode );
+ aError.SetIsWarning( EFalse );
+}
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::LoadingCompleted()
+{
+ if ( iEngine != NULL && iEngine->GraphicsContext() != NULL )
+ {
+ iEngine->GraphicsContext()->SetDoDithering( iHasGradientElement );
+ }
+}
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::SetThumbNailMode( TBool aThumbNailMode )
+{
+ iIsThumbNailMode = aThumbNailMode;
+}
+
+//==========================================================================
+// CSvgDocumentImpl::SetDRMRights( TBool aEnable )
+//==========================================================================
+void CSvgDocumentImpl::SetDRMRights( TBool aEnable)
+{
+ iDrmRightsConsumptionEnabled = aEnable;
+}
+// ==========================================================================
+// Need method description
+// ==========================================================================
+TBool CSvgDocumentImpl::IsThumbNailOnly()
+{
+ return iIsThumbNailMode && iIsDRMProtected;
+}
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::SetWasPrepared( TBool aBool )
+{
+ iWasPrepared = aBool;
+
+}
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+TBool CSvgDocumentImpl::WasPrepared()
+{
+ return iWasPrepared;
+}
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::SetLoadingListeners( const RPointerArray<MSvgLoadingListener>* aList )
+ {
+ iLoadingListeners = aList;
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+const RPointerArray<MSvgLoadingListener>* CSvgDocumentImpl::GetLoadingListeners()
+ {
+ return iLoadingListeners;
+ }
+
+/*---------------------------MouseListener---------------------------*/
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::AddInternalMouseListener( const MSvgMouseListener* aListener )
+ {
+ TInt index = iSvgMouseListeners.Find( aListener );
+ if ( aListener != NULL && index == KErrNotFound )
+ {
+ iSvgMouseListeners.Append( aListener );
+ }
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::RemoveInternalMouseListener( const MSvgMouseListener* aListener )
+ {
+ TInt index = iSvgMouseListeners.Find( aListener );
+ if ( index != KErrNotFound )
+ {
+ iSvgMouseListeners.Remove( index );
+ }
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+TInt CSvgDocumentImpl::MouseInternalListenerCount()
+ {
+ return iSvgMouseListeners.Count();
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::NotifyInternalMousePressed( RPointerArray<CSvgElementImpl>& aElements,
+ TInt aX, TInt aY )
+ {
+
+ for ( TInt i = 0; i < iSvgMouseListeners.Count(); i++ )
+ {
+ iSvgMouseListeners[i]->MousePressed( aElements, aX, aY );
+ }
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::NotifyInternalMouseReleased( RPointerArray<CSvgElementImpl>& aElements,
+ TInt aX, TInt aY )
+ {
+
+ for ( TInt i = 0; i < iSvgMouseListeners.Count(); i++ )
+ {
+ iSvgMouseListeners[i]->MouseReleased( aElements, aX, aY );
+ }
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::NotifyInternalMouseEntered( RPointerArray<CSvgElementImpl>& aElements,
+ TInt aX, TInt aY )
+ {
+
+ for ( TInt i = 0; i < iSvgMouseListeners.Count(); i++ )
+ {
+ iSvgMouseListeners[i]->MouseEntered( aElements, aX, aY );
+ }
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::NotifyInternalMouseExited( RPointerArray<CSvgElementImpl>& aElements,
+ TInt aX, TInt aY )
+ {
+
+ for ( TInt i = 0; i < iSvgMouseListeners.Count(); i++ )
+ {
+ iSvgMouseListeners[i]->MouseExited( aElements, aX, aY );
+ }
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::NotifyInternalMouseMoved( RPointerArray<CSvgElementImpl>& aElements,
+ TInt aX, TInt aY )
+ {
+
+ for ( TInt i = 0; i < iSvgMouseListeners.Count(); i++ )
+ {
+ iSvgMouseListeners[i]->MouseMoved( aElements, aX, aY );
+ }
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::NotifyDocumentStart()
+ {
+ if ( iLoadingListeners != NULL )
+ {
+ TInt loadingListenersCnt = iLoadingListeners->Count();
+ for ( TInt i = 0; i < loadingListenersCnt; i++ )
+ {
+ (*iLoadingListeners)[i]->DocumentStart();
+ }
+ }
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::NotifyDocumentEnd()
+ {
+ if ( iLoadingListeners != NULL )
+ {
+ TInt loadingListenersCnt = iLoadingListeners->Count();
+ for ( TInt i = 0; i < loadingListenersCnt; i++ )
+ {
+ (*iLoadingListeners)[i]->DocumentEnd();
+ }
+ }
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::NotifyElementStart( const TDesC& aTagName,
+ MSvgAttributeList& aAttributeList,
+ TBool aIsSvgChild )
+ {
+ // Do not send back attribute list if content was decrypted
+ // from DRM protected content.
+ if ( iLoadingListeners != NULL && !iIsDRMProtected )
+ {
+ TInt loadingListenersCnt = iLoadingListeners->Count();
+ for ( TInt i = 0; i < loadingListenersCnt; i++ )
+ {
+ if ( aIsSvgChild || (*iLoadingListeners)[i]->ReportAllElements() )
+ {
+ (*iLoadingListeners)[i]->ElementStart( aTagName, aAttributeList );
+ }
+ }
+ }
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::NotifyElementEnd( const TDesC& aTagName, TBool aIsSvgChild )
+ {
+ if ( iLoadingListeners != NULL )
+ {
+ TInt loadingListenersCnt = iLoadingListeners->Count();
+ for ( TInt i = 0; i < loadingListenersCnt; i++ )
+ {
+ if ( aIsSvgChild || (*iLoadingListeners)[i]->ReportAllElements() )
+ {
+ (*iLoadingListeners)[i]->ElementEnd( aTagName );
+ }
+ }
+ }
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::NotifyUnsupportedElement( const TDesC& aTagName,
+ MSvgAttributeList& aAttributeList )
+ {
+ if ( iLoadingListeners != NULL )
+ {
+ TInt loadingListenersCnt = iLoadingListeners->Count();
+ for ( TInt i = 0; i < loadingListenersCnt; i++ )
+ {
+ (*iLoadingListeners)[i]->UnsupportedElement( aTagName, aAttributeList );
+ }
+ }
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::NotifyExternalDataRequested( const TDesC& aUri )
+ {
+ if ( iLoadingListeners != NULL )
+ {
+ TInt loadingListenersCnt = iLoadingListeners->Count();
+ for ( TInt i = 0; i < loadingListenersCnt; i++ )
+ {
+ (*iLoadingListeners)[i]->ExternalDataRequested( aUri );
+ }
+ }
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::NotifyExternalDataReceived( const TDesC& aUri )
+ {
+ if ( iLoadingListeners != NULL )
+ {
+ TInt loadingListenersCnt = iLoadingListeners->Count();
+ for ( TInt i = 0; i < loadingListenersCnt; i++ )
+ {
+ (*iLoadingListeners)[i]->ExternalDataReceived( aUri );
+ }
+ }
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+void CSvgDocumentImpl::NotifyExternalDataRequestFailed( const TDesC& aUri )
+ {
+ if ( iLoadingListeners != NULL )
+ {
+ TInt loadingListenersCnt = iLoadingListeners->Count();
+ for ( TInt i = 0; i < loadingListenersCnt; i++ )
+ {
+ (*iLoadingListeners)[i]->ExternalDataRequestFailed( aUri );
+ }
+ }
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+TUint32 CSvgDocumentImpl::IsIndefiniteAnimation()
+ {
+ if ( !iCheckedAnimationDuration )
+ {
+ AnimationDuration();
+ }
+ // special value for indefinite animation
+ return ( iAnimationDuration == KIndefiniteAnimationDuration );
+ }
+
+// ==========================================================================
+// Need method description
+// ==========================================================================
+TUint32 CSvgDocumentImpl::AnimationDuration()
+ {
+ if ( iCheckedAnimationDuration )
+ {
+ return IsIndefiniteAnimation() ? 0xFFFFFFFF : iAnimationDuration;
+ }
+ else if ( iRootElement == NULL )
+ {
+ return 0;
+ }
+
+ if ( iIsInteractive )
+ {
+ // If there is interactivity in the content, set the animation
+ // duration to indefinite so that the timer continues to run.
+ iAnimationDuration = KIndefiniteAnimationDuration;
+ }
+ else
+ {
+ iAnimationDuration = SubtreeDuration( iRootElement );
+ }
+
+ iCheckedAnimationDuration = ETrue;
+ return IsIndefiniteAnimation() ? 0xFFFFFFFF : iAnimationDuration;
+ }
+
+// ==========================================================================
+// Return the longest animation in subtree
+// ==========================================================================
+TUint32 CSvgDocumentImpl::SubtreeDuration( CSvgElementImpl* aRootElement )
+ {
+ TUint dur = 0;
+
+ if ( aRootElement->IsAnimatedElement() )
+ {
+ dur = ( ( CSvgAnimationBase * ) aRootElement )->CompleteDuration();
+ }
+
+ else if ( aRootElement->ElemID() == KSvgDiscardElement )
+ {
+ dur = ((CSvgDiscardElementImpl*)aRootElement)->AbsoluteBeginTime();
+ }
+
+ // check child duration
+ TUint childDur;
+ CSvgElementImpl* child = (CSvgElementImpl*)aRootElement->FirstChild();
+ while ( child != NULL )
+ {
+ childDur = SubtreeDuration( child );
+ if ( childDur > dur )
+ {
+ dur = childDur;
+ }
+ child = (CSvgElementImpl*)child->NextSibling();
+ }
+ return dur;
+ }
+
+// ==========================================================================
+// notified from outside (AppendChild/RemoveChild)
+// ==========================================================================
+void CSvgDocumentImpl::ElementAppendedOrRemoved()
+ {
+ // Clear flag to retrieve animation duration on AnimationDuration() call
+ iCheckedAnimationDuration = EFalse;
+ }
+
+// ==========================================================================
+// Return all elements of the given type
+// or all of the elements if the type = -1
+// ==========================================================================
+void CSvgDocumentImpl::FindAllElements( CSvgElementImpl* aStartElement, TInt aElementId,
+ RPointerArray<CSvgElementImpl>& aList,
+ TSvgSearchFlags aFlags )
+ {
+ if ( aStartElement == NULL )
+ return;
+
+ CSvgElementImpl* child = (CSvgElementImpl*)aStartElement->FirstChild();
+ while ( child != NULL )
+ {
+ // add to list if child is found
+ if ( child->ElemID() == aElementId || aElementId == -1 )
+ aList.Append( child );
+
+ // find in grandchildren
+ if ( aFlags & ESvgSearchExcludeUseSubtree )
+ {
+ // If Exclude Use Subtree, ignore the subtree under use element
+ if ( child->ElemID() != KSvgUseElement )
+ {
+ FindAllElements( child, aElementId, aList, aFlags );
+ }
+ }
+ else
+ {
+ FindAllElements( child, aElementId, aList, aFlags );
+ }
+ child = (CSvgElementImpl*)child->NextSibling();
+ }
+ }
+
+// ==========================================================================
+// ImageLoadingObserver interface method
+// ==========================================================================
+void CSvgDocumentImpl::ImageLoadingCompleted( TInt aError )
+ {
+ iImageElementCnt--;
+
+ if ( iLoadingListeners != NULL && iImageElementCnt == 0)
+ {
+ TInt loadingListenersCnt = iLoadingListeners->Count();
+ for ( TInt i = 0; i < loadingListenersCnt; i++ )
+ {
+ (*iLoadingListeners)[i]->ImagesLoaded(aError);
+ }
+ }
+
+
+ }
+
+// ==========================================================================
+// Loops through the tree and prints out all of the elements
+// (almost regenerating the DOM tree)
+//
+// ==========================================================================
+void CSvgDocumentImpl::PrintAllElements( CSvgElementImpl* aStartElement )
+{
+ if ( aStartElement == NULL )
+ return;
+
+ aStartElement->Print( EFalse );
+ //===> comment the styles out to generate true SVG content
+ // aStartElement->PrintStyleProperties();
+
+ CSvgElementImpl* child = (CSvgElementImpl*)aStartElement->FirstChild();
+ PrintAllElements( child );
+
+ child = (CSvgElementImpl*)aStartElement->NextSibling();
+ PrintAllElements( child );
+}
+
+TBool CSvgDocumentImpl::HasError()
+ {
+ return iError && iError->HasError();
+ }
+
+MSvgError* CSvgDocumentImpl::GetError()
+ {
+ return iError;
+ }
+
+void CSvgDocumentImpl::SetIsWarning( TBool aIsWarning )
+{
+ if (iError)
+ {
+ iError->SetIsWarning( aIsWarning );
+ }
+}
+void CSvgDocumentImpl::SetError( TInt aErrorType, const TDesC& aMsg1, const TDesC& aMsg2 )
+ {
+ if ( !iError )
+ {
+ TRAPD( error, iError = CSvgErrorImpl::NewL() );
+ if ( error != KErrNone )
+ {
+ return;
+ }
+ PrepareError( *iError, ESvgUnknown, aErrorType, aMsg1, aMsg2 );
+ iError->SetIsWarning( ETrue );
+ }
+ }
+
+
+// ---------------------------------------------------------------------------
+// Accessor funciton for SyncBehaviorDefault value
+// ---------------------------------------------------------------------------
+TSvgSyncBehaviour CSvgDocumentImpl::SyncBehaviorDefault()
+ {
+ return iSyncBehaviorDefault;
+ }
+
+// ---------------------------------------------------------------------------
+// Accessor funciton for SyncBehaviorDefault value
+// ---------------------------------------------------------------------------
+TUint32 CSvgDocumentImpl::SyncToleranceDefault()
+ {
+ return iSyncToleranceDefault;
+ }
+
+// ---------------------------------------------------------------------------
+// CSvgDocumentImpl::SetCurrentTime
+// Set Function for the document's current time
+// ---------------------------------------------------------------------------
+void CSvgDocumentImpl::SetCurrentTime( TInt32 aCurTime )
+ {
+ if ( iTimeContainer )
+ {
+ iTimeContainer->SetCurrentTime( aCurTime );
+ }
+ }
+
+// ---------------------------------------------------------------------------
+// CSvgDocumentImpl::CurrentTime
+// Accessor for the Document's current time
+// ---------------------------------------------------------------------------
+TInt32 CSvgDocumentImpl::CurrentTime()
+ {
+ if ( iTimeContainer )
+ {
+ return iTimeContainer->CurrentTime();
+ }
+ return KErrGeneral;
+ }
+
+// ---------------------------------------------------------------------------
+// CSvgDocumentImpl::SetSyncBehavior
+// Set the Synchronised behaviour for the time container
+// ---------------------------------------------------------------------------
+void CSvgDocumentImpl::SetTCSyncBehavior( const TSvgSyncBehaviour aValue )
+ {
+ if ( iTimeContainer )
+ {
+ iTimeContainer->SetSyncBehavior( aValue );
+ }
+ }
+
+// ---------------------------------------------------------------------------
+// CSvgDocumentImpl::SetSyncTolerance
+// Set the Synchronised Tolerance for the time container
+// ---------------------------------------------------------------------------
+void CSvgDocumentImpl::SetTCSyncTolerance( const TUint32 aValue )
+ {
+ if ( iTimeContainer )
+ {
+ iTimeContainer->SetSyncTolerance( aValue );
+ }
+ }
+
+// ---------------------------------------------------------------------------
+// CSvgDocumentImpl::SetSyncMaster
+// Set the time container as Synchronised Master
+// ---------------------------------------------------------------------------
+void CSvgDocumentImpl::SetTCSyncMaster( const TBool aValue )
+ {
+ if ( iTimeContainer )
+ {
+ iTimeContainer->SetSyncMaster( aValue );
+ }
+ }
+
+// -----------------------------------------------------------------------------
+// CSvgDocumentImpl::TimeContainer
+// Accessor for time container
+// -----------------------------------------------------------------------------
+//
+CSvgTimeContainer* CSvgDocumentImpl::TimeContainer()
+ {
+ return iTimeContainer;
+ }
+
+void CSvgDocumentImpl::DocumentTransform(TGfxAffineTransform& aTr)
+ {
+ iTransformMatrix = aTr;
+ }
+
+TGfxAffineTransform CSvgDocumentImpl::GetDocumentTransform()
+ {
+ return iTransformMatrix;
+ }
+
+
+CSvgBitmapFontProvider * CSvgDocumentImpl::GetBitmapFontProvider()
+{
+ return iSvgBitmapFontProvider ;
+}
+
+// -----------------------------------------------------------------------------
+// CSvgDocumentImpl::SvgHasAnimationElement
+// Checks if Document has Animation Element
+// -----------------------------------------------------------------------------
+
+TBool CSvgDocumentImpl::SvgHasAnimationElement()
+ {
+ RPointerArray<CSvgElementImpl> lAnimationEleList;
+ FindAllElements((CSvgElementImpl* )RootElement(),
+ KSvgMediaAnimationElement, lAnimationEleList );
+ TInt lAnimationEleCnt = lAnimationEleList.Count();
+ lAnimationEleList.Close();
+ if ( lAnimationEleCnt > 0 )
+ {
+ return ETrue;
+ }
+
+ return EFalse;
+
+ }
+
+// -----------------------------------------------------------------------------
+// CSvgDocumentImpl::IsDocumentContentInteractive
+// Checks if Document content is InterActive
+// -----------------------------------------------------------------------------
+
+TBool CSvgDocumentImpl::IsDocumentContentInteractive()
+ {
+ RPointerArray<CSvgElementImpl> elements;
+ FindAllElements( (CSvgElementImpl* )RootElement(),
+ KSvgAElement, elements );
+ if ( elements.Count() != 0 )
+ {
+ elements.Close();
+ return ETrue;
+ }
+ elements.Close();
+
+ if ( iIsInteractive )
+ return ETrue;
+
+ // Check if animation element is there
+ RPointerArray<CSvgElementImpl> lAnimationEleList;
+ FindAllElements((CSvgElementImpl* )RootElement(),
+ KSvgMediaAnimationElement, lAnimationEleList );
+
+ // If no animation element is present then return EFalse
+ TInt lAnimationEleCnt = lAnimationEleList.Count();
+ if ( lAnimationEleCnt == 0 )
+ {
+ lAnimationEleList.Close();
+ return EFalse;
+ }
+
+ // Check all animation element and if any child svg has ..
+ // interactive content then return ETrue
+ for ( TInt lCurAnimationEle = 0;
+ lCurAnimationEle < lAnimationEleCnt; lCurAnimationEle++ )
+ {
+ CSvgMediaAnimationElementImpl* lAnimationElement =
+ (CSvgMediaAnimationElementImpl* )lAnimationEleList[ lCurAnimationEle ];
+ CSvgDocumentImpl* lChildDoc = lAnimationElement->GetChildDocument();
+ // if child svg has interavitve content then return
+ if(lChildDoc && lChildDoc->iIsInteractive)
+ {
+ lAnimationEleList.Close();
+ return ETrue;
+ }
+ }
+
+ lAnimationEleList.Close();
+ return EFalse;
+
+ }
+
+
+void CSvgDocumentImpl::SetImageElementsCount(TInt aCnt)
+ {
+ iImageElementCnt = aCnt;
+ }
+
+TInt CSvgDocumentImpl::GetImageElementsCount()
+ {
+ return iImageElementCnt;
+ }
+// End of file
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/breakdeps/SVGEngine.mmp Fri Oct 15 09:48:18 2010 +0100
@@ -0,0 +1,285 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: This mmp file generates makefile for SVG Engine
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+ALWAYS_BUILD_AS_ARM
+OPTION_REPLACE ARMCC --cpu 5T -O3 -Otime
+TARGET SVGEngine.dll
+TARGETTYPE dll
+
+
+VENDORID VID_DEFAULT
+
+UID 0x1000008D 0x101F856E
+
+
+ #if defined( ARMCC )
+ deffile ../eabi/SVGENGINE-OpenVG.def
+ #elif defined( WINSCW )
+ deffile ../BWINSCW/SVGENGINE-OpenVG.def
+ #elif defined( WINS )
+ deffile ../bwins/SVGENGINE-OpenVG.def
+ #else
+ deffile ../bmarm/SVGENGINE-OpenVG.def
+ #endif
+
+CAPABILITY CAP_GENERAL_DLL DRM
+
+SOURCEPATH ../src
+
+//SOURCE SVGEngineMain.cpp
+SOURCE SVGEngineImpl.cpp
+SOURCE SVGEngineInterfaceImpl.cpp
+SOURCE SVGTimer.cpp
+SOURCE SVGEventHandler.cpp
+SOURCE SVGEvent.cpp
+SOURCE SVGContentHandler.cpp
+SOURCE SvgBitmapFontProvider.cpp
+//SOURCE SVGXmlParser.cpp
+SOURCE SVGAttributeVerifier.cpp
+SOURCE SVGErrorImpl.cpp
+SOURCE Svgdecoder.cpp
+SOURCE SVGFourPointRect.cpp
+
+SOURCEPATH ../../SVGImpl/src
+
+SOURCE SVGElementImpl.cpp
+SOURCE SVGDocumentImpl.cpp
+SOURCE SVGDOMImplementationImpl.cpp
+
+// Structure Elements
+SOURCE Svgsvgelementimpl.cpp
+SOURCE SVGGElementImpl.cpp
+SOURCE SVGUseElementImpl.cpp
+SOURCE SVGStyleElementImpl.cpp
+SOURCE SVGForeignObjectElementImpl.cpp
+SOURCE SVGTitleElementImpl.cpp
+SOURCE SVGMetadataElementImpl.cpp
+SOURCE SVGDefsElementImpl.cpp
+SOURCE SVGDescElementImpl.cpp
+
+// Hyper linking
+SOURCE SVGAElementImpl.cpp
+SOURCE SVGUriReferenceImpl.cpp
+
+// Basic Shape Elements
+SOURCE SVGLineElementImpl.cpp
+SOURCE SVGRectElementImpl.cpp
+SOURCE SVGCircleElementImpl.cpp
+SOURCE SVGEllipseElementImpl.cpp
+SOURCE SVGPolylineElementImpl.cpp
+SOURCE SVGPathElementImpl.cpp
+SOURCE SVGMpathElementImpl.cpp
+
+// Text and Image Elements
+SOURCE SVGTextElementImpl.cpp
+SOURCE SVGTextAreaElementImpl.cpp
+SOURCE SVGImageElementImpl.cpp
+
+//Font Elements
+SOURCE SVGFontElementImpl.cpp
+SOURCE SVGFontFaceElementImpl.cpp
+SOURCE SVGGlyphElementImpl.cpp
+SOURCE SVGMissingGlyphElementImpl.cpp
+SOURCE SvgHkernelementimpl.cpp
+
+// Animation Elements
+SOURCE SVGAnimationBase.cpp
+SOURCE SVGSetElementImpl.cpp
+SOURCE SVGAnimateElementImpl.cpp
+SOURCE SVGAnimateTransformElementImpl.cpp
+SOURCE SVGAnimateMotionElementImpl.cpp
+SOURCE SVGDiscardElementImpl.cpp
+SOURCE SVGAnimationElementImpl.cpp
+
+// Gradient Elements
+SOURCE SVGLinearGradientElementImpl.cpp
+SOURCE SVGGradientElementImpl.cpp
+SOURCE SVGRadialGradientElementImpl.cpp
+SOURCE SVGStopElementImpl.cpp
+
+SOURCE SVGSolidColorElementImpl.cpp
+SOURCE SVGScriptElementImpl.cpp
+
+// CSS Classes
+SOURCE SVGClrCssValueImpl.cpp
+SOURCE SVGPaintCssValueImpl.cpp
+SOURCE SVGIntCssValueImpl.cpp
+SOURCE SVGFloatCssValueImpl.cpp
+SOURCE SVGStrCssValueImpl.cpp
+SOURCE SVGVectorCssValueImpl.cpp
+//SOURCE SVGCssStyleDeclarationImpl.cpp
+SOURCE SVGEventAttributes.cpp
+
+// Transform Classes
+SOURCE SVGTransformListImpl.cpp
+SOURCE SVGTransformableImpl.cpp
+
+// Switch Related Classes
+SOURCE SVGTestsImpl.cpp
+
+// XML Language Space Class
+SOURCE SVGLangSpaceImpl.cpp
+
+// Viewbox Classes
+SOURCE SVGFitToViewBoxImpl.cpp
+SOURCE SVGPreserveAspectRatioImpl.cpp
+
+// Utility Classes
+SOURCE SVGPointLexer.cpp
+SOURCE SVGSchemaData.cpp
+SOURCE SVGPathDataParser.cpp
+SOURCE SVGAnimTimeController.cpp
+SOURCE SVGStringTokenizer.cpp
+SOURCE SVGRelToAbsPath.cpp
+SOURCE SVGAnimTimingParser.cpp
+SOURCE SVGImageHashMap.cpp
+SOURCE SVGFontHashMap.cpp
+SOURCE SVGMemoryManager.cpp
+SOURCE SVGColor.cpp
+SOURCE SVGTokenizer.cpp
+
+// Media Element Classes
+SOURCE SVGAudioElementImpl.cpp
+SOURCE SVGMediaAnimationElementImpl.cpp
+SOURCE SVGMediaElementBase.cpp
+SOURCE SVGTimeContainer.cpp
+SOURCE SVGLockedRealTimeEntity.cpp
+
+SOURCEPATH ../../Xmldomimpl/src
+
+SOURCE SVGXmlElementImpl.cpp
+
+
+USERINCLUDE ../inc
+USERINCLUDE ../../Xmldomimpl/inc
+USERINCLUDE ../../SVGImpl/inc/SVGDOM
+USERINCLUDE ../../SVGImpl/inc
+USERINCLUDE ../../../VGRenderer/inc
+
+// This is a SYSTEMINCLUDE macro containing the middleware
+// layer specific include directories
+MW_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE /epoc32/include/libc
+
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY cone.lib
+LIBRARY euser.lib
+LIBRARY bafl.lib
+LIBRARY efsrv.lib
+LIBRARY fbscli.lib
+LIBRARY estor.lib
+LIBRARY gdi.lib
+
+// Library for image converter utilities
+//LIBRARY MediaClientImage.lib
+LIBRARY ImageConversion.lib
+
+// Library for XML Parser utilities
+LIBRARY XMLINTERFACE.lib
+
+
+// CXML parser
+//LIBRARY CXMLParser.lib
+// For CnvUtfConverter class
+LIBRARY charconv.lib
+
+//#include <oem/DRM.mmp>
+//#if !defined(__DRM_FULL)
+
+//LIBRARY DrmParsers.lib DrmDcf.lib DrmRights.lib DrmServerInterfaces.lib
+//LIBRARY DRMCommon.lib
+
+LIBRARY estlib.lib
+//#endif
+
+// Base64 Encoding
+LIBRARY imut.lib
+
+// GZip library
+LIBRARY EZLib.lib
+
+// CAF library: for DRM
+LIBRARY caf.lib
+
+LIBRARY mediaclientaudio.lib
+// Added for localized bidirectional textArea wrapping support
+LIBRARY avkon.lib
+
+//--------------------------------------------
+// Graphics library Information--------
+//LIBRARY Gfx2D.lib
+//--------------------------------------------
+SOURCEPATH ../../../gfx2d/src
+SOURCE GfxMath.c
+SOURCE GfxFloatFixPt.cpp
+SOURCE Gfxtrignometric.cpp
+/* this file is needed for ADS, RVCT, or GCC builds (mem operation wrappers) */
+SOURCE RastSymbianWrapper.cpp
+
+// GFXGC source files
+SOURCEPATH ../../../gfx2d/src/GfxGc
+SOURCE GfxStroke.cpp
+SOURCE GfxColor.cpp
+SOURCE GfxRenderingHints.cpp
+SOURCE GfxGradientPaint.cpp
+SOURCE Gfx2dGcOpenVG.cpp
+SOURCE Gfx2dGc.cpp
+
+
+// GFXGEOM source files
+SOURCEPATH ../../../gfx2d/src/GfxGeom
+SOURCE GfxEllipse2D.cpp
+SOURCE GfxEllipseIteratorP.cpp
+SOURCE GfxFlatteningPathIterator.cpp
+SOURCE GfxGeneralPath.cpp
+SOURCE GfxGeneralPathIteratorP.cpp
+SOURCE GfxRectangle2D.cpp
+SOURCE GfxRectangleIteratorP.cpp
+SOURCE GfxRectangularShape.cpp
+SOURCE GfxRoundRectangle2D.cpp
+SOURCE GfxRoundRectangleIteratorP.cpp
+SOURCE GfxLine2D.cpp
+SOURCE GfxLineIteratorP.cpp
+SOURCE GfxAffineTransform.cpp
+SOURCE GfxPoint2D.cpp
+
+// GFXIMAGE source files
+SOURCEPATH ../../../gfx2d/src/GfxImage
+SOURCE GfxImageTransformer.cpp
+
+// Internal Rendering Engine source files
+SOURCEPATH ../../../gfx2d/src/GfxRenderer
+SOURCE GfxRendererInfoP.cpp
+
+
+USERINCLUDE ../../../gfx2d/inc
+
+
+LIBRARY VGRenderer.lib
+
+
+LIBRARY eikcore.lib
+LIBRARY bitgdi.lib
+LIBRARY hal.lib
+//--------------------------------------------
+// End of Graphics library Information--------
+//--------------------------------------------
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/breakdeps/SVGEngineImpl.cpp Fri Oct 15 09:48:18 2010 +0100
@@ -0,0 +1,3190 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: SVG Engine source file
+ *
+*/
+
+
+
+
+#if !defined(__E32BASE_H__)
+#include <e32base.h>
+#endif
+
+#include <utf.h>
+#include <s32mem.h>
+
+#include "SVGDOMImplementationImpl.h"
+#include "SVGElementImpl.h"
+#include "SVGDocumentImpl.h"
+#include "SVGSvgElementImpl.h"
+#include "SVGUseElementImpl.h"
+#include "SVGAnimationElementImpl.h"
+#include "SVGTextElementImpl.h"
+
+#include "SVGAudioElementImpl.h"
+
+
+#include "Gfx2dGcOpenVG.h"
+
+#include "SVGSchemaData.h"
+#include "SVGPathElementImpl.h"
+#include "SVGAnimationBase.h"
+#include "SVGElementTimeControl.h"
+
+#include "SVGRequestObserver.h"
+#include "SVGHyperlinkListener.h"
+#include "SVGListener.h"
+#include "SVGAnimationListener.h"
+#include "SVGAElementImpl.h"
+#include "SVGTextAreaElementImpl.h"
+
+#include "SVGTimer.h"
+#include "SVGEventHandler.h"
+#include "SVGEngineImpl.h"
+#include "SVGErrorImpl.h"
+
+#include "SVGFloatCssValueImpl.h"
+#include "SVGTimeContainer.h"
+#include "SVGMediaAnimationElementImpl.h"
+
+// Constants
+// length of </text>
+const TInt KClosingTextTagLength = 7;
+// Length of </textArea>
+const TInt KClosingTextAreaTagLength = 11;
+// Length of <
+const TInt KClosingBracesLength = 1;
+// Number of chars to be converted at a time to Unicode
+const TInt KMaxConversionChars = 20;
+_LIT(KClosingTextTag,"</text>");
+_LIT(KClosingTextAreaTag,"</textArea>");
+_LIT(KClosingBraces,">");
+
+// ---------------------------------------------------------------------------
+// Two phase constructor for this class
+// JSR 226 API
+// ---------------------------------------------------------------------------
+CSvgEngineImpl* CSvgEngineImpl::NewL(CSvgBitmapFontProvider *aSvgBitmapFontProvider)
+ {
+ CSvgEngineImpl* self = new ( ELeave ) CSvgEngineImpl();
+ CleanupStack::PushL( self );
+ self->ConstructL(aSvgBitmapFontProvider);
+ CleanupStack::Pop();
+ return self;
+ }
+
+
+// --------------------------------------------------------------------------
+// CSvgEngineImpl* CSvgEngineImpl::NewLC()
+// ---------------------------------------------------------------------------
+CSvgEngineImpl* CSvgEngineImpl::NewLC(CSvgBitmapFontProvider *aSvgBitmapFontProvider)
+ {
+ CSvgEngineImpl* self = new ( ELeave ) CSvgEngineImpl();
+ CleanupStack::PushL( self );
+ self->ConstructL(aSvgBitmapFontProvider);
+ return self;
+ }
+
+// --------------------------------------------------------------------------
+// CSvgEngineImpl::CSvgEngineImpl() : iTextAreaHandle( NULL ),
+// ---------------------------------------------------------------------------
+CSvgEngineImpl::CSvgEngineImpl() : iTextAreaHandle( NULL ),
+ iRequestObserver( NULL ),
+ iFrameBuffer( NULL ),
+ iFrameBufferSize(TSize(0,0)),
+ iFontHashMap ( NULL ),
+ iSvgDocument( NULL ),
+ iBackgroundColor(0x00000000),
+ iShowDebugInfo( EFalse ),
+ iSvgEngineState(ESVGEngineNotStarted),
+ iTimeoutSeconds( 0 ),
+ iRenderQuality(2), // Set To Rendering quality "high"
+ iCustomOption( ETrue ),
+ iFrameBufferOverridesViewport( EFalse ),
+ iClientDefinedViewPort(EFalse)
+
+ {
+ }
+
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::ConstructL()
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::ConstructL(CSvgBitmapFontProvider *aSvgBitmapFontProvider)
+ {
+ iGfxContext = NULL;
+
+ iSvgBitmapFontProvider = aSvgBitmapFontProvider ;
+ // create CSvgErrorImpl object
+ iSvgError = CSvgErrorImpl::NewL();
+
+ iFontHashMap = CSvgFontHashMap::NewL();
+
+ SetIgnoreUpdateScreen( EFalse );
+
+ // The iCustomOption need to be initialized for JSR
+
+ iCustomOption = ETrue;
+
+ }
+
+
+
+// ---------------------------------------------------------------------------
+// Two phase constructor for this class
+// Accepts a frame buffer and a MSvgRequestObserver object from the client
+// Buffer is used for rasterization of SVG content
+// Observer object, if provided, is used for notifying the client on updates
+// ---------------------------------------------------------------------------
+CSvgEngineImpl* CSvgEngineImpl::NewL( CFbsBitmap* aFrameBuffer,
+ MSvgRequestObserver* aReqObserver, TFontSpec& aFontSpec, CSvgBitmapFontProvider* aSvgBitmapFontProvider )
+ {
+ CSvgEngineImpl* self = new ( ELeave ) CSvgEngineImpl( aFrameBuffer,
+ aReqObserver );
+ CleanupStack::PushL( self );
+ self->ConstructL(aFontSpec, aSvgBitmapFontProvider);
+ CleanupStack::Pop();
+
+ return self;
+ }
+
+
+// ---------------------------------------------------------------------------
+// Two phase constructor for this class
+// Accepts a frame buffer and a MSvgRequestObserver object from the client
+// Buffer is used for rasterization of SVG content
+// Observer object, if provided, is used for notifying the client on updates
+// ---------------------------------------------------------------------------
+CSvgEngineImpl* CSvgEngineImpl::NewLC( CFbsBitmap* aFrameBuffer,
+ MSvgRequestObserver* aReqObserver, TFontSpec& aFontSpec, CSvgBitmapFontProvider* aSvgBitmapFontProvider )
+ {
+ CSvgEngineImpl* self = new ( ELeave ) CSvgEngineImpl( aFrameBuffer, aReqObserver );
+ CleanupStack::PushL( self );
+ self->ConstructL(aFontSpec, aSvgBitmapFontProvider);
+
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// Symbian style private method that is used to construct heap objects
+// Builds the Graphics device objects with the client's frame buffer info
+// Builds the event handler object
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::ConstructL( TFontSpec& aFontSpec, CSvgBitmapFontProvider* aSvgBitmapFontProvider)
+ {
+ iBitmapFontSpec = aFontSpec;
+// iGfxContext is created through CSvgEngineInterfaceImpl::ConstructL
+ // iGfxContext = CGfx2dGcVGR::NewL( iFrameBuffer->SizeInPixels(), iBitmapFontSpec );
+ iSvgBitmapFontProvider = aSvgBitmapFontProvider ;
+
+ iGfxContext = CGfx2dGcOpenVG::NewL( iFrameBuffer->SizeInPixels(), iBitmapFontSpec, iSvgBitmapFontProvider );
+ // create CSvgErrorImpl object
+ iSvgError = CSvgErrorImpl::NewL();
+ iFontHashMap = CSvgFontHashMap::NewL();
+ iSvgNames = new (ELeave) CDesC16ArrayFlat(5);
+ }
+
+// ---------------------------------------------------------------------------
+CSvgEngineImpl* CSvgEngineImpl::NewL( CFbsBitmap* aFrameBuffer,
+ MSvgRequestObserver* aReqObserver, TFontSpec& aFontSpec, CSvgBitmapFontProvider* aSvgBitmapFontProvider ,SVGRendererId aRendererType)
+ {
+ CSvgEngineImpl* self = new ( ELeave ) CSvgEngineImpl( aFrameBuffer,
+ aReqObserver );
+ CleanupStack::PushL( self );
+ self->ConstructL(aFontSpec, aSvgBitmapFontProvider,aRendererType);
+ CleanupStack::Pop();
+
+ return self;
+ }
+
+
+// ---------------------------------------------------------------------------
+// Two phase constructor for this class
+// Accepts a frame buffer and a MSvgRequestObserver object from the client
+// Buffer is used for rasterization of SVG content
+// Observer object, if provided, is used for notifying the client on updates.
+//This contains the renderer selector parameter
+// ---------------------------------------------------------------------------
+CSvgEngineImpl* CSvgEngineImpl::NewLC( CFbsBitmap* aFrameBuffer,
+ MSvgRequestObserver* aReqObserver, TFontSpec& aFontSpec, CSvgBitmapFontProvider* aSvgBitmapFontProvider,SVGRendererId aRendererType )
+ {
+ CSvgEngineImpl* self = new ( ELeave ) CSvgEngineImpl( aFrameBuffer, aReqObserver );
+ CleanupStack::PushL( self );
+ self->ConstructL(aFontSpec, aSvgBitmapFontProvider,aRendererType);
+
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// Symbian style private method that is used to construct heap objects
+// Builds the Graphics device objects with the client's frame buffer info
+// Builds the event handler object.
+//This contains the renderer selector parameter NGA
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::ConstructL( TFontSpec& aFontSpec, CSvgBitmapFontProvider* aSvgBitmapFontProvider,SVGRendererId aRendererType)
+ {
+ iBitmapFontSpec = aFontSpec;
+// iGfxContext is created through CSvgEngineInterfaceImpl::ConstructL
+ // iGfxContext = CGfx2dGcVGR::NewL( iFrameBuffer->SizeInPixels(), iBitmapFontSpec );
+ iSvgBitmapFontProvider = aSvgBitmapFontProvider ;
+
+ iGfxContext = CGfx2dGcOpenVG::NewL( iFrameBufferSize, iBitmapFontSpec, iSvgBitmapFontProvider ,aRendererType);
+ // create CSvgErrorImpl object
+ iSvgError = CSvgErrorImpl::NewL();
+ iFontHashMap = CSvgFontHashMap::NewL();
+ iSvgNames = new (ELeave) CDesC16ArrayFlat(5);
+ }
+
+
+// ---------------------------------------------------------------------------
+// Private constructor
+// Initializes private attributes
+// ---------------------------------------------------------------------------
+CSvgEngineImpl::CSvgEngineImpl( CFbsBitmap* aFrameBuffer,
+ MSvgRequestObserver* aReqObserver ) : iTextAreaHandle( NULL ),
+ iRequestObserver( aReqObserver ),
+ iFrameBuffer( aFrameBuffer ),
+ iFrameBufferSize(TSize(0,0)),
+ iFontHashMap ( NULL),
+ iSvgDocument( NULL ),
+ iBackgroundColor(0x00000000),
+ iShowDebugInfo( EFalse ),
+ iSvgEngineState(ESVGEngineNotStarted),
+ iCustomOption( ETrue ),
+ iFrameBufferOverridesViewport( EFalse )
+
+
+ {
+ if(aFrameBuffer && aFrameBuffer->Handle()>0)
+ {
+ iFrameBufferSize = aFrameBuffer->SizeInPixels();
+ }
+ }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+CSvgEngineImpl::~CSvgEngineImpl()
+ {
+ Destroy();
+
+ if ( iFontHashMap )
+ {
+ delete iFontHashMap;
+ iFontHashMap = NULL;
+ }
+
+ iSvgTextBoundingBoxes.ResetAndDestroy();
+ iSvgTextBoundingBoxes.Close();
+
+ if ( iGfxContext )
+ {
+ delete iGfxContext;
+ iGfxContext = NULL;
+ }
+ if ( iSvgError )
+ {
+ delete iSvgError;
+ iSvgError = NULL;
+ }
+ if (iTextAreaHandle)
+ {
+ delete iTextAreaHandle;
+ iTextAreaHandle = NULL;
+ }
+
+ iTextAreaListeners.Close();
+ iTextListeners.Close();
+ iHyperlinkListeners.Close();
+ iAnimationListeners.Close();
+ iSvgMouseListeners.Close();
+ iInteractiveElementListeners.Close();
+ delete iSvgNames;
+ }
+
+// ---------------------------------------------------------------------------
+// Draws aRootElement and calls itself for children.
+// Handles switch element differently, as it only draws one of its children.
+// ---------------------------------------------------------------------------
+
+void CSvgEngineImpl::DrawElementsL( CSvgElementImpl* aRootElement)
+ {
+ if ( aRootElement != NULL)
+ {
+ TInt32 displayValue = 0;
+ // while we have next elements
+ CSvgElementImpl* newElement = aRootElement;
+ while( newElement != NULL )
+ {
+ if(newElement->GetAttributeIntL( KCSS_ATTR_DISPLAY, displayValue ) == KErrNoAttribute)
+ {
+ newElement = ( CSvgElementImpl* ) newElement->FirstChild();
+ while ( newElement != NULL )
+ {
+ DrawElementsL( newElement );
+ newElement = ( CSvgElementImpl * ) newElement->NextSibling();
+ }
+ return;
+ }
+
+ if(displayValue != KDisplayEnumNone) // is it a hidden element
+ {
+ CCssValue* CssValue = NULL;
+ TReal32 opacity = 1;
+
+ // check visisbility
+ TInt32 visbilityValue = 0;
+ TInt visibility = newElement->GetAttributeIntL( KCSS_ATTR_VISIBILITY, visbilityValue );
+
+ newElement->FindProperty( KCSS_ATTR_GROUP_OPACITY, CssValue, newElement );
+ if ( CssValue )
+ {
+ opacity = ((CFloatCssValueImpl*)CssValue)->Value();
+ }
+
+ if( opacity != 1 && !newElement->IsInherited( KCSS_ATTR_GROUP_OPACITY ) )
+ {
+ iGfxContext->BindToImageL();
+ // Group opacity
+ if ( newElement->ElemID() == KSvgGElement && newElement->FirstChild() )
+ {
+ // recurse with right context.
+ DrawElementsL( ( CSvgElementImpl* )newElement->FirstChild());
+ }
+ // Element opacity
+ else
+ {
+ TBool canDraw = ETrue;
+ if( (visibility == KErrNone) && (visbilityValue == 0) )
+ {
+ canDraw = newElement->DrawL( iGfxContext, NULL ) ;
+ }
+ if( canDraw && newElement->FirstChild() )
+ {
+ DrawElementsL( ( CSvgElementImpl* )newElement->FirstChild() );
+ }
+ }
+
+ // Blend opacity context buffer with parent's gfx context buffer
+ iGfxContext->UnbindFromImageL( opacity );
+ }
+ else // no opacity or is inherited from above....
+ {
+ TBool canDraw = ETrue;
+ if( (visibility == KErrNone) && (visbilityValue == 0) )
+ {
+ canDraw = newElement->DrawL(iGfxContext, NULL );
+ }
+ if( canDraw && newElement->FirstChild() )
+ {
+ DrawElementsL( ( CSvgElementImpl* )newElement->FirstChild());
+ }
+ }
+ }
+ newElement = ( CSvgElementImpl * )newElement->NextSibling();
+
+ }// end while....
+ }
+ }
+
+//--------------------------------------------------------------------
+//CFbsBitmap* CSvgEngineImpl::CreateOpacityFrameBufferL()
+//--------------------------------------------------------------------
+CFbsBitmap* CSvgEngineImpl::CreateOpacityFrameBufferL()
+{
+ CFbsBitmap* bitmap = new ( ELeave ) CFbsBitmap();
+
+ if ( iFrameBuffer != NULL )
+ {
+/*NGA reverse*/if ( bitmap->Create( iFrameBufferSize, EColor16MU ) != KErrNone )
+ {
+ delete bitmap;
+ bitmap = NULL;
+ }
+ }
+ return bitmap;
+ }
+
+// ---------------------------------------------------------------------------
+// Copy 32-bit buffer
+// ---------------------------------------------------------------------------
+
+void CSvgEngineImpl::CopyBuffer( TUint32* aSrc, TUint32* aDest, const TSize aSize )
+ {
+ if ( aSrc && aDest )
+ {
+ Mem::Copy( aDest, aSrc, aSize.iWidth * aSize.iHeight * sizeof( TUint32 ) );
+ }
+ }
+
+// ---------------------------------------------------------------------------
+// Positions the root element and calls itself (recursively) for all the
+// descendant elements
+// CTM stands for 'Current Transformation Matrix'.
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::UpdateCTM(CSvgDocumentImpl* aSvgDocument)
+ {
+
+ if (aSvgDocument)
+ {
+ ((CSvgElementImpl*)aSvgDocument->RootElement())->UpdateCTM();
+ }
+
+
+ }
+
+// ---------------------------------------------------------------------------
+// Initializes the SVG Engine primarily with width and height informtion
+// This is based on the attribute specifications for the root 'svg' element
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::InitializeEngineL()
+ {
+ // VIEWBOX
+ // If x, y, w, h of outmost svg not defined, then put default values: 0 0 100% 100%
+ // return;
+ // Set locale, so that there is no thousands separator
+
+ if( !iSvgDocument )
+ return;
+
+ iSvgDocument->iInitialDrawFlag = ETrue;
+ if(!((CSvgSvgElementImpl *)(iSvgDocument->RootElement()))->iIsWidthSet)
+ {
+ ((CSvgSvgElementImpl *)(iSvgDocument->RootElement()))->iIsWidthSet = ETrue;
+ }
+ if(!((CSvgSvgElementImpl *)(iSvgDocument->RootElement()))->iIsHeightSet)
+ {
+ ((CSvgSvgElementImpl *)(iSvgDocument->RootElement()))->iIsHeightSet = ETrue;
+ }
+
+ TLocale locale; // locale object
+ locale.SetCurrencyTriadsAllowed( EFalse ); // change setting
+ TSize lSize = GetSize();
+ iSvgDocument->iReqExReqFtrSysLTested = EFalse;
+ if ( iSvgDocument->RootElement() != NULL &&
+ ((CSvgElementImpl*)iSvgDocument->RootElement())->ElemID() == KSvgSvgElement )
+
+ {
+ // Scale width & height to fit to screen size
+ CSvgSvgElementImpl* el = ( CSvgSvgElementImpl* )
+ (iSvgDocument->RootElement());
+ TFloatFixPt width, height;
+ TInt widthInt, heightInt;
+ TFloatFixPt scrnW( lSize.iWidth ), scrnH( lSize.iHeight );
+ TFloatFixPt zero ( 0 );
+
+ if ( iFrameBufferOverridesViewport )
+ {
+ //special case for Aknicon
+ //the don't care what the contents viewport is they just want it to scale to the framebuffer's size
+ width = scrnW;
+ height= scrnH;
+ }
+ else
+ {
+ //bitmap from the client overrides width height specified in svg
+
+ if(iViewPortListener != NULL)
+ {
+ TInt tempWidth=0,tempHeight=0;
+ iViewPortListener->GetViewPort(
+ ((CSvgSvgElementImpl *)(iSvgDocument->RootElement()))->iWidthInUserCoordinate,
+ ((CSvgSvgElementImpl *)(iSvgDocument->RootElement()))->iHeightInUserCoordinate,
+ ((CSvgSvgElementImpl *)(iSvgDocument->RootElement()))->iWidthInPercentage,
+ ((CSvgSvgElementImpl *)(iSvgDocument->RootElement()))->iHeightInPercentage,
+ tempWidth,
+ tempHeight);
+
+ width = (TFloatFixPt) tempWidth;
+ height = (TFloatFixPt) tempHeight;
+
+ //used in SetWindowViewportTrans of svgSvgElementImpl
+ iClientDefinedViewPort = ETrue;
+
+ }
+ else
+ {
+
+ TReal32 per = 100;
+ if(((CSvgSvgElementImpl *)(iSvgDocument->RootElement()))->iWidthInPercentage)
+ {
+ width = ( TFloatFixPt ) (( lSize.iWidth/per ) * ((CSvgSvgElementImpl *)(iSvgDocument->RootElement()))->iWidthInUserCoordinate);
+ }
+ else
+ {
+ width = (TFloatFixPt) (((CSvgSvgElementImpl *)(iSvgDocument->RootElement()))->iWidthInUserCoordinate);
+ }
+
+ if(((CSvgSvgElementImpl *)(iSvgDocument->RootElement()))->iHeightInPercentage)
+ {
+ height = ( TFloatFixPt ) (( lSize.iHeight/per ) * ((CSvgSvgElementImpl *)(iSvgDocument->RootElement()))->iHeightInUserCoordinate);
+ }
+ else
+ {
+ height = (TFloatFixPt) (((CSvgSvgElementImpl *)(iSvgDocument->RootElement()))->iHeightInUserCoordinate);
+ }
+
+ //default to XmidYmid_meet
+ TSvgPreserveAspectAlignType lPreserverAspectAlignment = ESvgPreserveAspectRatio_XmidYmid;
+ TSvgMeetOrSliceType lMeetOrSlice = ESvgMeetOrSlice_Meet;
+
+ MSvgPreserveAspectRatio* aPreserveAspectRatio;
+ el->GetPreserveAspectRatio(aPreserveAspectRatio);
+
+ if (aPreserveAspectRatio)
+ {
+ lPreserverAspectAlignment = aPreserveAspectRatio->GetAlign();
+ lMeetOrSlice = aPreserveAspectRatio->GetMeetOrSlice();
+
+ //el->SetPreserveAspectRatioL( lPreserverAspectAlignment, lMeetOrSlice);
+ if( lPreserverAspectAlignment == ESvgPreserveAspectRatio_None && lMeetOrSlice == ESvgMeetOrSlice_Meet )
+ {
+ width = scrnW;
+ height = scrnH;
+ }
+ }
+
+ if( lMeetOrSlice == ESvgMeetOrSlice_Meet && !(lPreserverAspectAlignment == ESvgPreserveAspectRatio_None) )
+ {
+ widthInt = ( TInt ) width;
+ heightInt = ( TInt ) height;
+
+ // to avoid division by zero.
+ TInt rh = lSize.iWidth ;
+ if (widthInt != 0)
+ {
+ rh = heightInt* lSize.iWidth / widthInt;
+ }
+
+ if ( rh <= lSize.iHeight )
+ {
+ width = scrnW;
+ height = TFloatFixPt( rh );
+ }
+ else
+ {
+ // to avoid division by zero.
+ if (heightInt != 0)
+ {
+ width = TFloatFixPt( ((TReal32)(widthInt * lSize.iHeight)) / heightInt );
+ }
+ height = scrnH;
+ }
+ }
+ else if( lMeetOrSlice == ESvgMeetOrSlice_Slice )
+ {
+ widthInt = ( TInt ) width;
+ heightInt = ( TInt ) height;
+
+ // to avoid division by zero.
+ TInt rh = lSize.iWidth ;
+ if (widthInt != 0)
+ {
+ rh = heightInt* lSize.iWidth / widthInt;
+ }
+
+ if ( rh <= lSize.iHeight )
+ {
+ // to avoid division by zero.
+ if (heightInt != 0)
+ {
+ width = TFloatFixPt( ((TReal32)(widthInt * lSize.iHeight)) / heightInt );
+ }
+ height = scrnH;
+
+ }
+ else
+ {
+ width = scrnW;
+ height = TFloatFixPt( rh );
+ }
+ }
+ else
+ {
+ }
+ }//Normal viewer| end of else
+ }
+
+ if ( ( width <= zero ) || ( height <= zero ) ) //.
+ {
+ width = 0;
+ height = 0;
+ return;
+ }
+ // Set initial viewport
+ el->SetAttributeFloatL( KAtrX, zero );
+ el->SetAttributeFloatL( KAtrY, zero );
+ el->SetAttributeFloatL( KAtrWidth, width );
+ el->SetAttributeFloatL( KAtrHeight, height );
+ }
+ }
+
+
+
+
+
+// ---------------------------------------------------------------------------
+// This method is called after the SVG file is read and all elements are
+// constructed
+// It also looks for rendering properties such as Anti Aliasing at this
+// point
+// It calibrates the system for rasterization quality based on contents
+// ---------------------------------------------------------------------------
+TBool CSvgEngineImpl::StartFrameLoopL()
+ {
+ if( iRequestObserver != NULL )
+ {
+ if(iSvgDocument != NULL && iSvgDocument->iEventHandler != NULL)
+ {
+ iRequestObserver->UpdatePresentation(
+ iSvgDocument->iEventHandler->AnimationElementsCount());
+ }
+ }
+ if(iSvgDocument != NULL)
+ {
+ if ( iSvgDocument->RootElement() )
+ {
+ InitializeEngineL(); // set the viewport and viewbox
+ return ETrue;
+ }
+ }
+ return EFalse;
+ }
+// ---------------------------------------------------------------------------
+// UpdatePresentation()
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::UpdatePresentation(const TInt32& aParam)
+ {
+ if( iRequestObserver != NULL )
+ {
+ iRequestObserver->UpdatePresentation (aParam);
+ }
+ }
+
+
+//---------------------------------------------------------------------------
+// SetRenderingQuality
+//
+// @param : aRenderQuality
+// The function is called from JSR226 API. Specific to M2G/JSR226 only.
+//---------------------------------------------------------------------------
+void CSvgEngineImpl::SetRenderingQuality( const TInt32 aRenderQuality)
+{
+ // Bydefault iRenderQuality is set to 2 i.e. Rendering Quality high.
+
+ if( iRenderQuality != aRenderQuality )
+ {
+ iRenderQuality = aRenderQuality;
+
+ if( iGfxContext )
+ {
+ iGfxContext->SetAntialiasingMode( iRenderQuality );
+ }
+ }
+}
+
+
+// ---------------------------------------------------------------------------
+// Invalidate the current raster (and frame buffer) and
+// update the buffer with new raster.
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::RedrawL()
+ {
+ // Clear the frame buffer
+ if( iGfxContext && iSvgDocument)
+ {
+ // Set Clipping rectangle
+ CSvgSvgElementImpl* el = ( CSvgSvgElementImpl* ) (iSvgDocument->RootElement());
+ if ( !el )
+ {
+ return; // No DOM tree, nothing to draw.
+ }
+
+
+
+ // If viewBox has been set and width or height is zero
+ // Do not render the content
+ TGfxRectangle2D viewBoxRect;
+ if(el->GetViewBox(viewBoxRect))
+ {
+ if(viewBoxRect.iWidth == TFloatFixPt(0) ||
+ viewBoxRect.iHeight == TFloatFixPt(0))
+ {
+ return;
+ }
+ }
+
+ iGfxContext->SetupContextL();
+ iGfxContext->Clear(iBackgroundColor);
+ iGfxContext->SetFillOpacity( 1.0f );
+ iGfxContext->SetStrokeOpacity( 1.0f );
+
+ TFloatFixPt width, height;
+ el->GetAttributeFloat( KAtrWidth, width );
+ el->GetAttributeFloat( KAtrHeight, height );
+ TGfxRectangle2D clipRect ( 0, 0, width, height );
+ iGfxContext->SetClip( clipRect );
+ iClipRect = clipRect;
+
+ UpdateCTM(iSvgDocument);
+
+ iSvgDocument->iIsRendering = ETrue;
+ DrawElementsL( (CSvgElementImpl*)iSvgDocument->RootElement());
+ iSvgDocument->iIsRendering = EFalse;
+
+ iGfxContext->Flush();
+
+ // Get the redering result onto CFbsBitmap.
+ if(iFrameBufferSize.iWidth > 0)
+ iGfxContext->UpdateFramebufferL( iFrameBuffer, iMask,iFrameBufferSize,iRenderDspMode,iMaskDspMode );
+ else
+ iGfxContext->UpdateFramebufferL( iFrameBuffer, iMask );
+
+ if ( !iIgnoreUpdateScreen && iRequestObserver != NULL )
+ {
+ iRequestObserver->UpdateScreen();
+ }
+ if ( iSvgDocument->iInitSortList )
+ {
+ iSvgDocument->SortEventList();
+ }
+ else
+ {
+ iSvgDocument->iInitSortList=EFalse;
+ }
+ }
+ }
+
+// ---------------------------------------------------------------------------
+// Delete the objects associated with the last loaded SVG file
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::Destroy()
+ {
+ //if ( iSvgDocument )
+ // {
+ // Stop timer and reset time
+ // iSvgDocument->TimeContainer()->UserStop();
+ // iSvgDocument->TimeContainer()->UserResetTime();
+ // }
+ }
+
+
+// ---------------------------------------------------------------------------
+// Set the URI information
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::LinkRequest( const TDesC& aUri )
+ {
+ iLinkUri.Set( aUri );
+ }
+// ---------------------------------------------------------------------------
+// Set the Link:Show information
+// ---------------------------------------------------------------------------
+
+
+void CSvgEngineImpl::LinkRequestWithShow(const TDesC& aUri ,const TDesC& aLinkShow )
+ {
+ iLinkUri.Set( aUri );
+ iLinkShow.Set( aLinkShow );
+ }
+
+// ---------------------------------------------------------------------------
+// Initiate the process of getting an svg font from the client
+// ---------------------------------------------------------------------------
+TBool CSvgEngineImpl::FetchFont( const TDesC& aUri, RFs& aSession, RFile& aFileHandle )
+ {
+ if ( iRequestObserver == NULL )
+ {
+ return EFalse;
+ }
+ else
+ {
+ if (iRequestObserver->FetchFont( aUri, aSession, aFileHandle ) == KErrNone)
+ {
+ return ETrue;
+ }
+ return EFalse;
+ }
+ }
+
+// ---------------------------------------------------------------------------
+// Initiate the process of getting an embedded image from the client
+// ---------------------------------------------------------------------------
+TBool CSvgEngineImpl::FetchImage( const TDesC& aUri, RFs& aSession, RFile& aFileHandle )
+ {
+ if ( iRequestObserver == NULL )
+ {
+ return EFalse;
+ }
+ else
+ {
+ if (iRequestObserver->FetchImage( aUri, aSession, aFileHandle ) == KErrNone)
+ {
+ return ETrue;
+ }
+ return EFalse;
+ }
+ }
+
+// ---------------------------------------------------------------------------
+// Accessor for Graphics Context object
+// ---------------------------------------------------------------------------
+CGfx2dGc* CSvgEngineImpl::GraphicsContext()
+ {
+ return iGfxContext;
+ }
+
+// ---------------------------------------------------------------------------
+// Accessor for the Engine's current time
+// ---------------------------------------------------------------------------
+TInt32 CSvgEngineImpl::CurrentTIme()
+ {
+ if ( iSvgDocument )
+ {
+ return iSvgDocument->CurrentTime();
+ }
+ return KErrGeneral;
+ }
+
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::ImageLoadingCompleted( TInt /* aErrorStatus */ )
+// ---------------------------------------------------------------------------
+// ImageLoadingObserver interface
+void CSvgEngineImpl::ImageLoadingCompleted( TInt /* aErrorStatus */ )
+{
+ TRAP_IGNORE(RedrawL());
+ //aErrorStatus = 0;
+}
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::UpdatePath( CGfxGeneralPath* hPath, CSvgElementImpl* hElement )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::UpdatePath( CGfxGeneralPath* hPath, CSvgElementImpl* hElement )
+{
+ if ((hElement != NULL) && (hElement->ElemID() == KSvgPathElement))
+ {
+ TRAPD(error,hElement->SetAttributePathL(KAtrData, hPath));
+ if ( error != KErrNone )
+ {
+ // Error Processing
+ return;
+ }
+ }
+
+}
+
+// ---------------------------------------------------------------------------
+// Accessor for the document object for the currently loaded SVG source
+// ---------------------------------------------------------------------------
+CSvgDocumentImpl* CSvgEngineImpl::Document()
+ {
+ return iSvgDocument;
+ }
+
+// ---------------------------------------------------------------------------
+// Restrict Thumbnail documents
+// Do not render to frame buffer when is in thumbnail mode and
+// frame buffer size width or height is larger than 80x80.
+// ---------------------------------------------------------------------------
+TBool CSvgEngineImpl::PassesThumbNailRestriction()
+{
+ if ( iSvgDocument && iFrameBuffer && iSvgDocument->IsThumbNailOnly() )
+ {
+ TSize size = iFrameBuffer->SizeInPixels();
+ if ( size.iWidth > 80 || size.iHeight > 80 )
+ {
+ return EFalse;
+ }
+ }
+ return ETrue;
+}
+
+//***************************************************************
+// Event handling
+// ---------------------------------------------------------------------------
+// Initiate the process of handling an event from the client for the
+// SVG source
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::ProcessEventL( CSvgDocumentImpl* aSvgDocument,
+ MSvgEvent* aEvent, TBool aRedraw )
+ {
+ // Check for Thumbnail restrictions
+ if ( !PassesThumbNailRestriction() )
+ {
+ return;
+ }
+
+ // Timer event
+ //if(!aEvent || !iGfxContext)
+ if(!aEvent)
+ return;
+ if ( aEvent->EventType() == ESvgEngineEventTimer )
+ {
+ // Update current time
+ if ( aSvgDocument )
+ {
+ aSvgDocument->SetCurrentTime(
+ ( ( MSvgTimerEvent * ) aEvent )->Time() );
+ }
+ }
+
+ if( aSvgDocument && aSvgDocument->iEventHandler)
+ {
+ if (( aSvgDocument->iEventHandler->ProcessEventL( aEvent ) ||
+ aSvgDocument->iInitialDrawFlag) && aEvent->EventType() == ESvgEngineEventTimer )
+ {
+
+ if(aSvgDocument->iInitSortList)
+ {
+ aSvgDocument->SortEventList();
+ aSvgDocument->iInitSortList = EFalse;
+ }
+ aSvgDocument->iInitialDrawFlag = EFalse;
+ aSvgDocument->iEventHandler->DoAnimProcL(aEvent);
+
+ if (aRedraw)
+ {
+ // Redraw is performed for iSvgDocument
+ RedrawL();
+ }
+ }
+ else
+ {
+ // this is to keep the dom in its final state.
+ if(aEvent->EventType() == ESvgEngineEventTimer)
+ {
+ aSvgDocument->iEventHandler->DoAnimProcL(aEvent);
+ }
+
+ }
+
+ // Process Link
+ if ( aEvent->EventMask() == KSvgEventMaskExternalUI )
+ {
+ if ( iLinkUri.Length() > 0 )
+ {
+ DoHyperLinkingL();
+ // reset link description
+ iLinkUri.Set( NullString );
+ }
+ }
+ }
+
+// Show FPS debug info. note. only write data to STI port
+#ifdef _DEBUG
+
+ if ( aEvent->EventType() == ESvgEngineInternalEvent )
+ {
+ MSvgInternalEvent* evt = ( MSvgInternalEvent* ) aEvent;
+ if (evt->SvgEvent() == ESvgEventEndEvent)
+ {
+ iAnimationState = KAnimFinished;
+ return;
+ }
+ else
+ if (evt->SvgEvent() == ESvgEventBeginEvent)
+ {
+ iAnimationState = KAnimActive;
+ return;
+ }
+
+ }
+
+ // time display for debug
+ if ( iShowDebugInfo && iGfxContext && aEvent->EventType() == ESvgEngineEventTimer
+ && iAnimationState != KAnimFinished /*&& iTimer*/)
+ {
+ TInt fps = iSvgDocument->TimeContainer()->UserFps() / 10; //iTimer->Fps() / 10;
+ _LIT(msg, "\n%3d.%d\n");
+ RDebug::Print(msg, fps, iSvgDocument->TimeContainer()->UserFps()
+ - fps * 10 );
+
+ }
+#endif //_DEBUG
+
+ }
+
+
+// ---------------------------------------------------------------------------
+// This method is for future extension, in which an external script engine
+// could be used to evaluate a script description.
+// ---------------------------------------------------------------------------
+TBool CSvgEngineImpl::ScriptCall( const TDesC& aScript,
+ CSvgElementImpl* aCallerElement )
+ {
+ if ( iRequestObserver == NULL )
+ {
+ return EFalse;
+ }
+ else
+ {
+ return iRequestObserver->ScriptCall( aScript, aCallerElement );
+ }
+ }
+
+
+//***************************************************************
+//
+// ---------------------------------------------------------------------------
+// Obtain the longest duration for an animation given document
+// NULL will assume the attached document.
+// ---------------------------------------------------------------------------
+TUint32 CSvgEngineImpl::Duration( CSvgDocumentImpl* aDocument )
+ {
+ if ( aDocument == NULL )
+ {
+ if ( iSvgDocument == NULL )
+ {
+ return 0;
+ }
+ return iSvgDocument->AnimationDuration();
+ }
+ return aDocument->AnimationDuration();
+ }
+
+//*******************************************************/
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::SwitchDebugInfo()
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::SwitchDebugInfo(TBool debug)
+ {
+ iShowDebugInfo = debug;
+ }
+
+void CSvgEngineImpl::CustomOption(TBool aCustomOption )
+ {
+ iCustomOption = aCustomOption;
+ delete iGfxContext;
+ iGfxContext = NULL;
+
+/*NGA reverse*/ TRAP_IGNORE( iGfxContext = CGfx2dGcOpenVG::NewL( iFrameBufferSize, iBitmapFontSpec, iSvgBitmapFontProvider ));
+
+
+ }
+
+
+
+
+// ---------------------------------------------------------------------------
+// Initiate the process of opening and reading an embedded hyperlink
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::DoHyperLinkingL()
+ {
+
+ if( iSvgDocument == NULL )
+ return;
+
+ // Not full support of XPointer
+
+ _LIT( KTmpHttp, "http:" );
+ _LIT( KTmpFile, "file:" );
+ _LIT( KTmpHash, "#" );
+ _LIT( KTmpSvgView, "SvgView" );
+ if ( iLinkUri.Left( 1 ) == KTmpHash )
+ {
+ // internal linking
+ // Extract id
+ TLex lex ( iLinkUri );
+ lex.Inc(); // skip '#'
+ lex.Mark();
+ while ( !lex.Eos() && lex.Peek().IsAlpha() )
+ lex.Inc();
+ TPtrC targetId = lex.MarkedToken();
+ if ( targetId == KTmpSvgView )
+ {
+ // need to parse next token = {viewBoxSpec| preserveAspectRatioSpec
+ // |transformSpec|zoomAndPanSpec|viewTargetSpec}
+
+ // Not yet supported
+ }
+ else
+ {
+
+ CSvgElementImpl*targetElement = ( CSvgElementImpl* )
+ iSvgDocument->GetElementById( targetId );
+ if ( targetElement == NULL )
+ return;
+
+ if ( targetElement->IsAnimatedElement( ) )
+ {
+ // start animation
+ ( ( CSvgAnimationBase * ) targetElement )->BeginElementL();
+ }
+ else
+ {
+ }
+ }
+ }
+ else if ( iLinkUri.Length() >= 5 )
+ {
+ if ( iLinkUri.Left( 5 ) == KTmpHttp || iLinkUri.Left( 5 ) == KTmpFile )
+ {
+ // notify observer of desire to follow http link
+ NotifyHyperlinkActivated( iLinkUri );
+ }
+ else
+ {
+ // notify observer of desire to follow link
+ if ( iLinkShow.Length() > 0 )
+ NotifyHyperlinkActivatedWithShow( iLinkUri, iLinkShow );
+ else
+ NotifyHyperlinkActivated( iLinkUri );
+ }
+ }
+ else if ( iLinkUri.Length() > 0 )
+ {
+ // notify observer of desire to follow link
+ if ( iLinkShow.Length() > 0 )
+ NotifyHyperlinkActivatedWithShow( iLinkUri, iLinkShow );
+ else
+ NotifyHyperlinkActivated( iLinkUri );
+ }
+ }
+
+// ---------------------------------------------------------------------------
+// Dump a completed raster to the off screen buffer provided by the
+// client
+// ---------------------------------------------------------------------------
+TInt CSvgEngineImpl::RenderFileToBuffer( const TDesC8& aSvgData,
+ CFbsBitmap* aFrameBuffer,
+ CFbsBitmap* aMask,
+ TBool aPreserveAspectRatio )
+ {
+ if ( !iGfxContext )
+ {
+ return EFalse;
+ }
+
+ CFbsBitmap* OrgFrameBuffer;
+ CFbsBitmap* OrgMask;
+ OrgFrameBuffer = iFrameBuffer;
+ OrgMask = iMask;
+ CSvgDocumentImpl* lsvgorgdoc = iSvgDocument;
+ // We have moved all the leaving functions into RenderFileL
+ TRAPD(err,RenderFileL(aSvgData,aFrameBuffer,aMask,aPreserveAspectRatio));
+ // No matter what...whether the RenderFileL returns properly or leave we need to set the
+ //GDI context back to the original frame buffer and mask... and set back the engine to
+ //how it was before all this happened..
+
+ SetDocument(lsvgorgdoc);
+ lsvgorgdoc->SetEngine(this);
+ // the setGDIContextL error is a very serious error and if it occurs then
+ // there is no way of recovery.
+ TRAP_IGNORE(SetGdiContextL(OrgFrameBuffer,OrgMask));
+ //So we are propagating the more probable error of the two which is the leaving of
+ // RenderFileL.
+ return err;
+ }
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+// Helper leaving function for the function RenderFileToBuffer.
+// The actual rendering happens in this function..while the calling function uses this to
+// render the file.
+// ---------------------------------------------------------------------------
+
+
+void CSvgEngineImpl::RenderFileL( const TDesC8& aSvgData,
+ CFbsBitmap* aFrameBuffer,
+ CFbsBitmap* aMask,
+ TBool aPreserveAspectRatio)
+
+{
+ CFont *lFont = iGfxContext->Font();
+ TFontSpec lFontSpec = lFont->FontSpecInTwips();
+
+ TSize imageSize;
+ imageSize = aFrameBuffer->SizeInPixels();
+ //iFrameBuffer = aFrameBuffer;
+
+ SetGdiContextL(aFrameBuffer, aMask);
+ CSvgDocumentImpl* lSvgDocument = CSvgDocumentImpl::NewLC(iSvgBitmapFontProvider);
+ SetDocument(lSvgDocument);
+ lSvgDocument->SetEngine(this);
+
+ // fileHandle is valid from client
+ lSvgDocument->Load( aSvgData, *iSvgError );
+ if ( iSvgError->HasError() && !iSvgError->IsWarning() )
+ {
+ CleanupStack::PopAndDestroy(1);
+ return;
+ }
+
+ StartFrameLoopL();
+ CSvgSvgElementImpl* lRoot = (CSvgSvgElementImpl*)lSvgDocument->RootElement();
+ _LIT( KPreserveAspectRatio, "preserveAspectRatio" );
+
+ if(lRoot)
+ {
+ if ( aPreserveAspectRatio )
+ {
+ _LIT( KXMidYMid, "xMidYMid" );
+ lRoot->SetAttributeL( KPreserveAspectRatio, KXMidYMid );
+ lRoot->SetWidth( imageSize.iWidth );
+ lRoot->SetHeight( imageSize.iHeight );
+ }
+ else {
+ _LIT( KNone, "none" );
+ lRoot->SetAttributeL( KPreserveAspectRatio, KNone );
+ lRoot->SetWidth( imageSize.iWidth );
+ lRoot->SetHeight( imageSize.iHeight );
+ }
+ RedrawL();
+ }
+ CleanupStack::PopAndDestroy( 1 );
+}
+
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+// Generate a mask bitmap from alpha channel of the framebuffer.
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::GenerateMask(CFbsBitmap* aMask)
+ {
+ if ( iGfxContext )
+ {
+ iGfxContext->GenerateMask( aMask );
+ }
+ }
+
+//
+// ---------------------------------------------------------------------------
+// set background color
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::SetBackgroundColor(TUint32 aRGBA8888Color)
+ {
+ iBackgroundColor = aRGBA8888Color;
+ }
+
+//
+// ---------------------------------------------------------------------------
+// Get Size of render buffer
+// ---------------------------------------------------------------------------
+TSize CSvgEngineImpl::GetSize()
+ {
+ return iFrameBufferSize;
+
+
+
+ }
+
+
+//
+// ---------------------------------------------------------------------------
+// Return SVG Engine State
+// ---------------------------------------------------------------------------
+
+TSvgEngineState CSvgEngineImpl::SVGEngineState()
+ {
+ return iSvgEngineState;
+ }
+
+//
+// ---------------------------------------------------------------------------
+// Set SVG Engine State
+// ---------------------------------------------------------------------------
+
+void CSvgEngineImpl::SetSVGEngineState(TSvgEngineState aState)
+ {
+ iSvgEngineState = aState;
+ if( iSvgEngineState == ESVGEnginePaused )
+ {
+ if ( iSvgDocument )
+ {
+ iSvgDocument->TimeContainer()->UserPause();
+ NotifyAnimationPaused();
+ }
+ }
+ else if( iSvgEngineState == ESVGEngineRunning )
+ {
+ if (iSvgDocument && iSvgDocument->IsAnimationFile())
+ {
+ iSvgDocument->TimeContainer()->UserResume();
+ }
+ }
+ else if(iSvgEngineState == ESVGEngineStopped )
+ {
+ if ( iSvgDocument )
+ {
+ iSvgDocument->TimeContainer()->UserStop();
+ }
+
+ }
+ }
+
+void CSvgEngineImpl::SeekEngine( TUint32 aTime)
+ {
+ iSvgEngineState = ESVGEngineRunning;
+ if ( iSvgDocument )
+ {
+ iSvgDocument->TimeContainer()->UserSeek( aTime );
+ }
+ }
+
+void CSvgEngineImpl::ResetTimer()
+ {
+ if ( iSvgDocument )
+ {
+ iSvgDocument->TimeContainer()->UserResetTime();
+ }
+ }
+
+// ---------------------------------------------------------------------------
+// SetGdiContext File
+// ---------------------------------------------------------------------------
+
+void CSvgEngineImpl::SetGdiContextL(CFbsBitmap* aCurrentBitmap, CFbsBitmap* aMask)
+ {
+ // Handle for both Non-NULL and NULL parameter
+ iFrameBuffer = aCurrentBitmap;
+ iMask = aMask;
+
+ if ( aCurrentBitmap )
+ {
+ if ( !iGfxContext )
+ {
+ iGfxContext = CGfx2dGcOpenVG::NewL( iFrameBuffer->SizeInPixels(), iBitmapFontSpec, iSvgBitmapFontProvider );
+
+ // The API is called Only in case of JSR226. Incase if the midlet developer
+ // has changed the RedenderQuality of the midlet.ByDefualt the value of
+ // iRenderQuality is 2 i.e. VG_RENDERING_QUALITY_BETTER.
+ iGfxContext->SetAntialiasingMode( iRenderQuality );
+ }
+ else
+ {
+ iGfxContext->ChangeBufferSizeL( iFrameBuffer->SizeInPixels() );
+ }
+ }
+ else if ( iGfxContext )
+ {
+ iGfxContext->ChangeBufferSizeL( TSize( 0,0 ) );
+ }
+ }
+
+// ---------------------------------------------------------------------------
+// void CSvgEngineImpl::StartEngine(CSvgErrorImpl* aError)
+// ---------------------------------------------------------------------------
+
+void CSvgEngineImpl::StartEngine(CSvgErrorImpl* aError)
+ {
+ if ( !iFrameBuffer || !iSvgDocument )
+ {
+ return;
+ }
+
+ iMouseoverElement = NULL;
+ if ( ((iFrameBufferSize.iHeight <= 0 )||(iFrameBufferSize.iWidth <= 0 )) &&(( iFrameBuffer->SizeInPixels().iWidth == 0 ) ||
+ ( iFrameBuffer->SizeInPixels().iHeight == 0) ))
+ {
+ return;
+ }
+
+ TBool initialized = EFalse;
+
+ TRAPD( initError, initialized = StartFrameLoopL() );
+
+ if ( initError != KErrNone || !initialized )
+ {
+ return;
+ }
+
+ // Get the Engine State to Running
+ SetSVGEngineState(ESVGEngineRunning);
+
+ // Document is an animation
+ if( iSvgDocument->IsAnimationFile() )
+ {
+ { // Atleast first frame should get drawn
+ TRAPD(error, RedrawL() );
+ {
+ if ( error != KErrNone && aError != NULL )
+ {
+ if( error == KErrNoMemory )
+ {
+ CSvgDocumentImpl::PrepareError( *aError, ESvgNoMemory, error,
+ _L( "Unable to Draw: " ),
+ _L( "" ) );
+ return;
+ }
+
+ CSvgDocumentImpl::PrepareError( *aError, ESvgUnknown, error,
+ _L( "Unable to Draw: " ),
+ _L( "" ) );
+ return;
+ }
+ }
+
+ }
+
+ iSvgDocument->TimeContainer()->UserPlay();
+ iSvgDocument->iAnimationResetNeeded = ETrue;
+ }
+ // Static svg file
+ else
+ {
+ TRAPD(error, RedrawL() );
+ {
+ if ( error != KErrNone && aError != NULL )
+ {
+ if( error == KErrNoMemory )
+ {
+ CSvgDocumentImpl::PrepareError( *aError, ESvgNoMemory, error,
+ _L( "Unable to Draw: " ),
+ _L( "" ) );
+ return;
+ }
+
+ CSvgDocumentImpl::PrepareError( *aError, ESvgUnknown, error,
+ _L( "Unable to Draw: " ),
+ _L( "" ) );
+ return;
+ }
+ }
+ }
+ }
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::RenderFrame( TUint aCurrentTime )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::RenderFrame( TUint aCurrentTime )
+ {
+ if ( !iFrameBuffer || !iSvgDocument ||
+ iFrameBuffer->SizeInPixels().iWidth == 0 || iFrameBuffer->SizeInPixels().iHeight == 0 )
+ {
+ return;
+ }
+
+ if ( aCurrentTime == 0 )
+ {
+ SeekEngine( 0 );
+ }
+
+ iMouseoverElement = NULL;
+
+ CSvgSvgElementImpl* rootElement = (CSvgSvgElementImpl*)iSvgDocument->RootElement();
+
+ if (rootElement == NULL)
+ {
+ return;
+ }
+
+ TGfxRectangle2D viewBoxRect;
+ if (rootElement->GetViewBox(viewBoxRect))
+ {
+ //viewbox has been defined or set already
+ if (viewBoxRect.iWidth == TFloatFixPt(0) || viewBoxRect.iHeight == TFloatFixPt(0))
+ {
+ //viewbox has no area so dont render
+ return;
+ }
+ }
+
+ if( iRequestObserver && iSvgDocument->iEventHandler )
+ {
+ iRequestObserver->UpdatePresentation( iSvgDocument->iEventHandler->AnimationElementsCount() );
+ }
+
+ iSvgDocument->iInitialDrawFlag = ETrue;
+
+ // Fix for animation element for testApp
+ TSvgTick lTick;
+ lTick.iRealTimeTick = aCurrentTime;
+ lTick.iParentTcTick = 0;
+ iSvgDocument->TimeContainer()->ParentTimeContainerTick(lTick) ;
+ // Fix for animation element for testApp
+ }
+
+
+// ---------------------------------------------------------------------------
+// Set SvgEngine Document
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::SetDocument(CSvgDocumentImpl* aDocument)
+ {
+ iSvgDocument = aDocument;
+ }
+
+
+// ---------------------------------------------------------------------------
+// Change the duration of the timer
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::ChangeDuration( TUint32 aTimerDuration )
+ {
+ if ( iSvgDocument )
+ {
+ iSvgDocument->TimeContainer()->UserChangeFrameDuration(
+ aTimerDuration );
+
+ // Check if there is animation element in the parent svg
+ RPointerArray<CSvgElementImpl> lAnimationEleList;
+ iSvgDocument->FindAllElements((CSvgElementImpl* )iSvgDocument->RootElement(),
+ KSvgMediaAnimationElement, lAnimationEleList );
+ TInt lAnimationEleCnt = lAnimationEleList.Count();
+ for ( TInt lCurAnimationEle = 0;
+ lCurAnimationEle < lAnimationEleCnt; lCurAnimationEle++ )
+ {
+ CSvgMediaAnimationElementImpl* lAnimationElement =
+ (CSvgMediaAnimationElementImpl* )lAnimationEleList[ lCurAnimationEle ];
+ CSvgDocumentImpl* lChildDoc = lAnimationElement->GetChildDocument();
+ if ( lChildDoc )
+ {
+ lChildDoc->TimeContainer()->UserChangeFrameDuration(
+ aTimerDuration ); // Change Frame duration for child svg
+ }
+ }
+ lAnimationEleList.Close();
+ }
+ }
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::Resume(TInt32 aTime)
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::Resume(TInt32 aTime)
+ {
+ if ( iSvgDocument )
+ {
+ iSvgDocument->TimeContainer()->UserResume( aTime );
+ }
+ }
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::FindBBoxesForRotatedText( const TDesC& aSearchString,
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::FindBBoxesForRotatedText( const TDesC& aSearchString,
+ RPointerArray<MRect>& aBoundingBoxes,
+ RArray<TPtrC>& aTexts,
+ RArray<TInt>& aElementIds,
+ TBool aCaseSensitive )
+{
+ if ( iSvgDocument == NULL )
+ return;
+
+ if ( iSvgTextBoundingBoxes.Count() > 0 )
+ {
+ iSvgTextBoundingBoxes.ResetAndDestroy();
+ }
+
+ // Find all text elements
+ HBufC* searchStr = aSearchString.AllocLC();
+ TPtr searchStrPtr = searchStr->Des();
+ RPointerArray<CSvgElementImpl> textElements;
+ iSvgDocument->FindAllElements( (CSvgElementImpl* )iSvgDocument->RootElement(),
+ KSvgTextElement, textElements );
+ // Himanshu: Find all animation elements
+ RPointerArray<CSvgElementImpl> lAllAnimationElements;
+ iSvgDocument->FindAllElements( (CSvgElementImpl*)iSvgDocument->RootElement(),
+ KSvgMediaAnimationElement,
+ lAllAnimationElements );
+ TInt lAllAnimationEleCnt = lAllAnimationElements.Count();
+ for ( TInt i = 0; i < lAllAnimationEleCnt; i++ )
+ {
+ CSvgMediaAnimationElementImpl* element = (CSvgMediaAnimationElementImpl*)lAllAnimationElements[i];
+ CSvgDocumentImpl* ldoc = element->GetChildDocument();
+ if(ldoc)
+ {
+ // Find all text elements in child document
+ ldoc->FindAllElements( (CSvgElementImpl*)ldoc->RootElement(),
+ KSvgTextElement,
+ textElements );
+ }
+
+ }
+ lAllAnimationElements.Close();
+
+ TSvgFourPointRect boundingBox;
+ TInt textEleCnt = textElements.Count();
+ for ( TInt i = 0; i < textEleCnt; i++ )
+ {
+ CSvgTextElementImpl* textElement = (CSvgTextElementImpl*)textElements[i];
+ TPtrC remainder( textElement->GetText() );
+
+ TInt index = ( aCaseSensitive ) ? remainder.Find( aSearchString ) :
+ remainder.FindF( aSearchString );
+
+ // continue to next element if nothing found
+ if ( index == KErrNotFound )
+ continue;
+
+ searchStrPtr.Copy( remainder.Mid(index,aSearchString.Length()) );
+ // Get the bounding box for the whole text element
+ textElement->GetFourPointBBox( boundingBox );
+
+ // Get bounding box for every occurrence
+ TReal32 textAdvance = (TReal32)(textElement->TextAdvance( *searchStr, index ));
+ TReal32 leftAdvance = 0.0f;
+ //TReal32 aHeight = textElement->Ascent() + textElement->Descent();
+
+ while ( index != KErrNotFound )
+ {
+ // Calculate boundingbox for searched-text
+ // indeterminate results with a string only one character long
+ leftAdvance = leftAdvance + (TReal32)(textElement->TextAdvance( remainder.Left( index )));
+
+ // need to setup slope calculation here to determine where the new
+ // four point rect should be for partial pieces of text
+
+ // need to do something for both vertical and horizontal text 0 and na slopes
+
+ TReal32 dy = (TReal32)boundingBox.iPoint2.iY - (TReal32)boundingBox.iPoint1.iY;
+ TReal32 dx = (TReal32)boundingBox.iPoint2.iX - (TReal32)boundingBox.iPoint1.iX;
+
+ double aSlopeRan;
+ Math::ATan(aSlopeRan, dy, dx);
+
+ double aSinVal;
+ Math::Sin(aSinVal, aSlopeRan);
+
+ double aCosVal;
+ Math::Cos(aCosVal, aSlopeRan);
+
+
+ TReal32 x1 = aCosVal * leftAdvance + (TReal32)boundingBox.iPoint1.iX;
+ TReal32 x3 = aCosVal * leftAdvance + (TReal32)boundingBox.iPoint3.iX;
+ TReal32 y1 = aSinVal * leftAdvance + (TReal32)boundingBox.iPoint1.iY;
+ TReal32 y3 = aSinVal * leftAdvance + (TReal32)boundingBox.iPoint3.iY;
+
+ TReal32 x2 = aCosVal * textAdvance + x1;
+ TReal32 x4 = aCosVal * textAdvance + x3;
+
+ TReal32 y2 = aSinVal * textAdvance + y1;
+ TReal32 y4 = aSinVal * textAdvance + y3;
+
+ TSvgFourPointRect* bbox = NULL;
+
+ TRAP_IGNORE( bbox = new (ELeave) TSvgFourPointRect( TPoint(x1, y1),
+ TPoint(x2, y2),
+ TPoint(x3, y3),
+ TPoint(x4, y4)) );
+
+ if ( !bbox )
+ {
+ #ifdef _DEBUG
+ RDebug::Printf("Four Point Rect Failed: Out of Memory");
+ #endif
+ return;
+ }
+
+ // store bound box pointers to go back to client
+ aBoundingBoxes.Append( (MRect*)bbox );
+
+ iSvgTextBoundingBoxes.Append( bbox );
+
+ // store point to text
+ aTexts.Append( TPtrC( textElement->GetText() ) );
+ aElementIds.Append( (TInt)textElement );
+
+ remainder.Set( remainder.Right( remainder.Length() - index - aSearchString.Length() ) );
+ leftAdvance = leftAdvance + textAdvance;
+ index = ( aCaseSensitive ) ? remainder.Find( aSearchString ) :
+ remainder.FindF( aSearchString );
+ }
+ }
+ CleanupStack::PopAndDestroy(searchStr);
+ textElements.Close();
+}
+
+//this is the old 2point rect way that only works for horizontal text
+/*void CSvgEngineImpl::FindBBoxesForHorizontalText( const TDesC& aSearchString,
+ RArray<TRect>& aBoundingBoxes,
+ RArray<TPtrC>& aTexts,
+ RArray<TInt>& aElementIds,
+ TBool aCaseSensitive )
+{
+ if ( iSvgDocument == NULL )
+ return;
+
+ // Find all text elements
+ RPointerArray<CSvgElementImpl> textElements;
+ iSvgDocument->FindAllElements( (CSvgElementImpl* )iSvgDocument->RootElement(),
+ KSvgTextElement, textElements );
+
+ TGfxRectangle2D boundingBox;
+ for ( TInt i = 0; i < textElements.Count(); i++ )
+ {
+ CSvgTextElementImpl* textElement = (CSvgTextElementImpl*)textElements[i];
+ TPtrC remainder( textElement->GetText() );
+
+ TInt index = ( aCaseSensitive ) ? remainder.Find( aSearchString ) :
+ remainder.FindF( aSearchString );
+
+ // continue to next element if nothing found
+ if ( index == KErrNotFound )
+ continue;
+
+ // Get the bounding box for the whole text element
+ textElement->GetBBox( boundingBox );
+
+ // Get bounding box for every occurrence
+ TFloatFixPt textAdvance = textElement->TextAdvance( aSearchString, index );
+ TFloatFixPt leftAdvance = 0.0f;
+ while ( index != KErrNotFound )
+ {
+ // Calculate boundingbox for searched-text
+ leftAdvance = leftAdvance + textElement->TextAdvance( remainder.Left( index ), index );
+
+ TRect bbox( (TInt)boundingBox.iX + (TInt)leftAdvance,
+ (TInt)boundingBox.iY,
+ (TInt)boundingBox.iX + (TInt)leftAdvance + (TInt)textAdvance,
+ (TInt)boundingBox.iY + (TInt)boundingBox.iHeight );
+
+ // store bound box
+ aBoundingBoxes.Append( bbox );
+
+ // store point to text
+ aTexts.Append( TPtrC( textElement->GetText() ) );
+ aElementIds.Append( (TInt)textElement );
+
+ remainder.Set( remainder.Right( remainder.Length() - index - aSearchString.Length() ) );
+ leftAdvance = leftAdvance + textAdvance;
+ index = ( aCaseSensitive ) ? remainder.Find( aSearchString ) :
+ remainder.FindF( aSearchString );
+ }
+ }
+ textElements.Close();
+}
+*/
+
+/************************ HyperLinking Functions ***********************/
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::CheckForHyperlinkMouseover( TInt aX, TInt aY )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::CheckForHyperlinkMouseover( TInt aX, TInt aY )
+{
+ if ( iHyperlinkListeners.Count() == 0 )
+ return;
+
+ if ( iSvgDocument == NULL )
+ return;
+
+ // Gather <a> elements if first time
+ RPointerArray<CSvgElementImpl> iAElementList;
+ if ( iAElementList.Count() == 0 )
+ {
+ iSvgDocument->FindAllElements( (CSvgElementImpl* )iSvgDocument->RootElement(),
+ KSvgAElement, iAElementList );
+ }
+
+ // find the bounding box containing point
+ TGfxPoint2D point( aX, aY );
+ TGfxRectangle2D boundingBox;
+ TInt aEleListCnt = iAElementList.Count();
+ for ( TInt i = 0; i < aEleListCnt; i++ )
+ {
+ CSvgElementImpl* element = iAElementList[i];
+ CSvgGElementImpl::GetGroupBounding( boundingBox, element );
+ if ( boundingBox.Contains( point ) )
+ {
+ // no existing mouse over element: notify HyperlinkEntered
+ if ( iMouseoverElement == NULL )
+ {
+ NotifyHyperlinkEntered( element->Href() );
+ }
+ // otherwise: notify HyperlinkExited, HyperlinkEntered
+ else if ( iMouseoverElement != element )
+ {
+ NotifyHyperlinkExited( iMouseoverElement->Href() );
+ NotifyHyperlinkEntered( element->Href() );
+ }
+ iMouseoverElement = element;
+ return;
+ }
+ }
+
+ // no bounding box containing point: notify HyperlinkExited
+ if ( iMouseoverElement != NULL )
+ {
+ NotifyHyperlinkExited( iMouseoverElement->Href() );
+ iMouseoverElement = NULL;
+ }
+
+ iAElementList.Close();
+}
+
+/*-------------------------Animation Listeners-----------------------------*/
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::AddAnimationListener( MSvgAnimationListener* aListener )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::AddAnimationListener( MSvgAnimationListener* aListener )
+{
+ if ( aListener != NULL && iAnimationListeners.Find( aListener ) == KErrNotFound )
+ iAnimationListeners.Append( aListener );
+
+}
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::RemoveAnimationListener( MSvgAnimationListener* aListener )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::RemoveAnimationListener( MSvgAnimationListener* aListener )
+{
+ TInt index = iAnimationListeners.Find( aListener );
+ if ( index != KErrNotFound )
+ iAnimationListeners.Remove( index );
+}
+
+/*-------------------------Animation listener notification to client-------*/
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyAnimationStarted()
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyAnimationStarted()
+{
+
+ TBool isAnimationIndefinite = EFalse;
+ if ( ( iSvgDocument == NULL ) || ( iSvgDocument->RootElement() == NULL ) ||
+ ( iAnimationListeners.Count() == 0 ) )
+ {
+ return;
+ }
+
+ RPointerArray<CSvgElementImpl> AnimationElementList;
+
+ iSvgDocument->FindAllElements( (CSvgElementImpl* )iSvgDocument->RootElement(),
+ KSvgSetElement, AnimationElementList );
+ iSvgDocument->FindAllElements( (CSvgElementImpl* )iSvgDocument->RootElement(),
+ KSvgAnimateElement, AnimationElementList );
+ iSvgDocument->FindAllElements( (CSvgElementImpl* )iSvgDocument->RootElement(),
+ KSvgAnimateMotionElement, AnimationElementList );
+ iSvgDocument->FindAllElements( (CSvgElementImpl* )iSvgDocument->RootElement(),
+ KSvgAnimateTransformElement, AnimationElementList );
+ iSvgDocument->FindAllElements( (CSvgElementImpl* )iSvgDocument->RootElement(),
+ KSvgAnimateColorElement, AnimationElementList );
+
+ if ( AnimationElementList.Count() != 0 )
+ {
+ TInt animationEleListCnt = AnimationElementList.Count();
+ for ( TInt i=0; i < animationEleListCnt; i++ )
+ {
+ CSvgElementImpl * element = AnimationElementList[i];
+ if ( ((CSvgAnimationBase *)element)->CompleteDuration() == KTimeIndefinite )
+ {
+ isAnimationIndefinite = ETrue;
+ break;
+ }
+ }
+
+ }
+ AnimationElementList.Close();
+
+ TInt animationListenersCnt = iAnimationListeners.Count();
+ for ( TInt i = 0; i < animationListenersCnt; i++ )
+ iAnimationListeners[i]->AnimationStarted( isAnimationIndefinite );
+
+
+}
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyAnimationPaused()
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyAnimationPaused()
+{
+ TInt animationListenersCnt = iAnimationListeners.Count();
+ for ( TInt i = 0; i < animationListenersCnt; i++ )
+ iAnimationListeners[i]->AnimationPaused();
+}
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyAnimationEnded()
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyAnimationEnded()
+{
+ if ( ( iSvgDocument == NULL ) || ( iSvgDocument->RootElement() == NULL ) ||
+ ( iAnimationListeners.Count() == 0 ) )
+ {
+ return;
+ }
+ #if 0
+ RPointerArray<CSvgElementImpl> AnimationElementList;
+
+ FindAllElements( (CSvgElementImpl* )iSvgDocument->RootElement(),
+ KSvgSetElement, AnimationElementList );
+ FindAllElements( (CSvgElementImpl* )iSvgDocument->RootElement(),
+ KSvgAnimateElement, AnimationElementList );
+ FindAllElements( (CSvgElementImpl* )iSvgDocument->RootElement(),
+ KSvgAnimateMotionElement, AnimationElementList );
+ FindAllElements( (CSvgElementImpl* )iSvgDocument->RootElement(),
+ KSvgAnimateTransformElement, AnimationElementList );
+ FindAllElements( (CSvgElementImpl* )iSvgDocument->RootElement(),
+ KSvgAnimateColorElement, AnimationElementList );
+
+ if ( AnimationElementList.Count() != 0 )
+ {
+ TInt animationEleListCnt = AnimationElementList.Count();
+ for ( TInt i=0; i < animationEleListCnt; i++ )
+ {
+ CSvgElementImpl * element = AnimationElementList[i];
+ if ( ((CSvgAnimationBase *)element)->iAnimStatus == KAnimActive )
+ {
+ AnimationElementList.Close();
+ return;
+ }
+ }
+
+ }
+ AnimationElementList.Close();
+#endif
+
+ TInt animationListenersCnt = iAnimationListeners.Count();
+ for ( TInt i = 0; i < animationListenersCnt; i++ )
+ iAnimationListeners[i]->AnimationEnded();
+
+}
+
+/*------------------Register Client Text Area listeners----------------------------*/
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::AddTextAreaListener( MSvgTextAreaListener* aListener )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::AddTextAreaListener( MSvgTextAreaListener* aListener )
+{
+ if ( aListener != NULL && iTextAreaListeners.Find( aListener ) == KErrNotFound )
+ {
+ iTextAreaListeners.Append( aListener );
+ }
+}
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::RemoveTextAreaListener( MSvgTextAreaListener* aListener )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::RemoveTextAreaListener( MSvgTextAreaListener* aListener )
+{
+ TInt index = iTextAreaListeners.Find( aListener );
+ if ( index != KErrNotFound )
+ {
+ iTextAreaListeners.Remove( index );
+ }
+}
+
+/*----------------Text Area listener notification to client--------------*/
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyTextAreaEntered( CSvgTextAreaElementImpl* aTextAreaHandle )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyTextAreaEntered( CSvgTextAreaElementImpl* aTextAreaHandle )
+{
+ TInt textAreaListenersCnt = iTextAreaListeners.Count();
+ for (TInt i=0; i < textAreaListenersCnt; i++)
+ {
+ iTextAreaListeners[i]->TextAreaEntered( (TInt)aTextAreaHandle);
+ }
+}
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyTextAreaExited( CSvgTextAreaElementImpl* aTextAreaHandle )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyTextAreaExited( CSvgTextAreaElementImpl* aTextAreaHandle )
+{
+ TInt textAreaListenersCnt = iTextAreaListeners.Count();
+ for (TInt i=0; i < textAreaListenersCnt; i++)
+ {
+ iTextAreaListeners[i]->TextAreaExited( (TInt)aTextAreaHandle);
+ }
+}
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyTextAreaActivated( CSvgTextAreaElementImpl* aTextAreaHandle )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyTextAreaActivated( CSvgTextAreaElementImpl* aTextAreaHandle )
+{
+ TInt textAreaListenersCnt = iTextAreaListeners.Count();
+ for (TInt i=0; i < textAreaListenersCnt; i++)
+ {
+ iTextAreaListeners[i]->TextAreaActivated( (TInt)aTextAreaHandle );
+ }
+}
+
+/*------------------Register Client Text listeners----------------------------*/
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::AddTextListener( MSvgTextListener* aListener )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::AddTextListener( MSvgTextListener* aListener )
+{
+ if ( aListener != NULL && iTextListeners.Find( aListener ) == KErrNotFound )
+ {
+ iTextListeners.Append( aListener );
+ }
+}
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::RemoveTextListener( MSvgTextListener* aListener )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::RemoveTextListener( MSvgTextListener* aListener )
+{
+ TInt index = iTextListeners.Find( aListener );
+ if ( index != KErrNotFound )
+ {
+ iTextListeners.Remove( index );
+ }
+}
+
+/*----------------Text listener notification to client--------------*/
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyTextEntered( CSvgTextElementImpl* aTextHandle )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyTextEntered( CSvgTextElementImpl* aTextHandle )
+{
+ TInt textListenersCnt = iTextListeners.Count();
+ for (TInt i=0; i < textListenersCnt; i++)
+ {
+ iTextListeners[i]->TextEntered( (TInt)aTextHandle);
+ }
+}
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyTextExited( CSvgTextElementImpl* aTextHandle )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyTextExited( CSvgTextElementImpl* aTextHandle )
+{
+ TInt textListenersCnt = iTextListeners.Count();
+ for (TInt i=0; i < textListenersCnt; i++)
+ {
+ iTextListeners[i]->TextExited( (TInt)aTextHandle);
+ }
+}
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyTextActivated( CSvgTextElementImpl* aTextHandle )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyTextActivated( CSvgTextElementImpl* aTextHandle )
+{
+ TInt textListenersCnt = iTextListeners.Count();
+ for (TInt i=0; i < textListenersCnt; i++)
+ {
+ iTextListeners[i]->TextActivated( (TInt)aTextHandle );
+ }
+}
+
+/*---------------------Register Client Hyperlink listeners----------------------------*/
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::AddHyperlinkListener( MSvgHyperlinkListener* aListener )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::AddHyperlinkListener( MSvgHyperlinkListener* aListener )
+{
+ if ( aListener != NULL && iHyperlinkListeners.Find( aListener ) == KErrNotFound )
+ iHyperlinkListeners.Append( aListener );
+}
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::RemoveHyperlinkListener( MSvgHyperlinkListener* aListener )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::RemoveHyperlinkListener( MSvgHyperlinkListener* aListener )
+{
+ TInt index = iHyperlinkListeners.Find( aListener );
+ if ( index != KErrNotFound )
+ iHyperlinkListeners.Remove( index );
+}
+
+void CSvgEngineImpl::AddViewPortListener(MSvgViewPortListener* aListener)
+{
+ if ( aListener != NULL )
+ {
+ iViewPortListener = aListener ;
+ }
+
+}
+
+
+void CSvgEngineImpl::RemoveViewPortListener(MSvgViewPortListener*
+ /* aListener */ )
+{
+ if(iViewPortListener != NULL)
+ {
+ iViewPortListener = NULL;
+ }
+}
+/*----------------Hyperlink listener notification to client--------------*/
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyHyperlinkEntered( CSvgAElementImpl* aAElementHandle )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyHyperlinkEntered( CSvgAElementImpl* aAElementHandle )
+{
+ TInt hyperLinkListenersCnt = iHyperlinkListeners.Count();
+ for ( TInt i = 0; i < hyperLinkListenersCnt; i++ )
+ {
+ if (aAElementHandle)
+ {
+ iHyperlinkListeners[i]->LinkEntered( aAElementHandle->Href() );
+ }
+ }
+}
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyHyperlinkEntered( const TDesC& aUri )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyHyperlinkEntered( const TDesC& aUri )
+{
+ TInt hyperLinkListenersCnt = iHyperlinkListeners.Count();
+ for ( TInt i = 0; i < hyperLinkListenersCnt; i++ )
+ {
+ iHyperlinkListeners[i]->LinkEntered( aUri );
+ }
+}
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyHyperlinkExited( CSvgAElementImpl* aAElementHandle )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyHyperlinkExited( CSvgAElementImpl* aAElementHandle )
+{
+ TInt hyperLinkListenersCnt = iHyperlinkListeners.Count();
+ for ( TInt i = 0; i < hyperLinkListenersCnt; i++ )
+ {
+ if (aAElementHandle)
+ {
+ iHyperlinkListeners[i]->LinkExited( aAElementHandle->Href() );
+ }
+ }
+}
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyHyperlinkExited( const TDesC& aUri )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyHyperlinkExited( const TDesC& aUri )
+{
+ TInt hyperLinkListenersCnt = iHyperlinkListeners.Count();
+ for ( TInt i = 0; i < hyperLinkListenersCnt; i++ )
+ {
+ iHyperlinkListeners[i]->LinkExited( aUri );
+ }
+}
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyHyperlinkActivated( CSvgAElementImpl* aAElementHandle )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyHyperlinkActivated( CSvgAElementImpl* aAElementHandle )
+{
+ if ( !aAElementHandle ||
+ aAElementHandle->Href().Length() == 0 ||
+ aAElementHandle->Href()[0] == '#' )
+ {
+ return;
+ }
+
+ TInt hyperLinkListenersCnt = iHyperlinkListeners.Count();
+ for ( TInt i = 0; i < hyperLinkListenersCnt; i++ )
+ {
+ iHyperlinkListeners[i]->LinkActivated( aAElementHandle->Href() );
+ }
+}
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyHyperlinkActivated( const TDesC& aUri )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyHyperlinkActivated( const TDesC& aUri )
+{
+ TInt hyperLinkListenersCnt = iHyperlinkListeners.Count();
+ for ( TInt i = 0; i < hyperLinkListenersCnt; i++ )
+ {
+ iHyperlinkListeners[i]->LinkActivated( aUri );
+ }
+}
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyHyperlinkActivatedWithShow( const TDesC& aUri, const TDesC& aShow )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyHyperlinkActivatedWithShow( const TDesC& aUri, const TDesC& aShow )
+{
+ TInt hyperLinkListenersCnt = iHyperlinkListeners.Count();
+ for ( TInt i = 0; i < hyperLinkListenersCnt; i++ )
+ iHyperlinkListeners[i]->LinkActivatedWithShow( aUri, aShow );
+}
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyElementActivatedLinkEntered( CSvgElementImpl* aElement)
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyElementActivatedLinkEntered( CSvgElementImpl* aElement)
+ {
+ if(iMouseoverElement == NULL)
+ {
+ const TDesC* myId = aElement->Id();
+
+ if (myId)
+ NotifyHyperlinkEntered( *(myId));
+ iMouseoverElement = aElement;
+ }
+ }
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyElementActivatedLinkExited( CSvgElementImpl* aElement)
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyElementActivatedLinkExited( CSvgElementImpl* aElement)
+ {
+ if(iMouseoverElement == aElement )
+ {
+ const TDesC* myId = aElement->Id();
+
+ if (myId)
+ NotifyHyperlinkExited( *(myId));
+ iMouseoverElement = NULL;
+ }
+ }
+void CSvgEngineImpl::GetViewPort(TInt getWidth, TInt getHeight, TBool isWidthInPer, TBool isHeightInPer, TInt &setWidth, TInt &setHeight)
+{
+ if(iViewPortListener != NULL)
+ {
+ iViewPortListener->GetViewPort(getWidth, getHeight, isWidthInPer, isHeightInPer, setWidth, setHeight);
+ }
+}
+
+/*------------------Register Client Interactive Element listeners------------*/
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::AddInteractiveElementListener(
+// MSvgInteractiveElementListener* aListener )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::AddInteractiveElementListener(
+ MSvgInteractiveElementListener* aListener )
+ {
+ if (
+ aListener != NULL &&
+ iInteractiveElementListeners.Find( aListener ) == KErrNotFound )
+ {
+ iInteractiveElementListeners.Append( aListener );
+ }
+ }
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::RemoveInteractiveElementListener(
+// MSvgInteractiveElementListener* aListener )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::RemoveInteractiveElementListener(
+ MSvgInteractiveElementListener* aListener )
+ {
+ TInt index = iInteractiveElementListeners.Find( aListener );
+ if ( index != KErrNotFound )
+ {
+ iInteractiveElementListeners.Remove( index );
+ }
+ }
+
+/*-----------Interactive Element listener notification to client------------*/
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyInteractiveElementEntered(CSvgElementImpl* aElement)
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyInteractiveElementEntered(
+ CSvgElementImpl* aElement)
+ {
+ TUint16 lsubeventmask=0;
+ TBool linteractivity;
+ linteractivity=this->iSvgDocument->iEventHandler->
+ CheckInteractivityAndGetSubEventMask(aElement,lsubeventmask);
+ if(linteractivity)
+ {
+ TInt linteractiveElementListenersCnt = iInteractiveElementListeners.Count();
+ for ( TInt i = 0; i < linteractiveElementListenersCnt; i++ )
+ {
+ const TDesC* myId = aElement->Id();
+ TPtrC16 ptr;
+ if(myId)
+ {
+ ptr.Set(*myId);
+ }
+ else
+ {
+ _LIT(KEmptyString,"");
+ ptr.Set( KEmptyString);
+ }
+ iInteractiveElementListeners[i]->InteractiveElementEntered(
+ ptr,lsubeventmask );
+ }
+ }
+ }
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyInteractiveElementExited(CSvgElementImpl* aElement)
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyInteractiveElementExited(CSvgElementImpl* aElement)
+ {
+ TInt linteractiveElementListenersCnt = iInteractiveElementListeners.Count();
+ for ( TInt i = 0; i < linteractiveElementListenersCnt; i++ )
+ {
+ const TDesC* myId = aElement->Id();
+ TPtrC16 ptr;
+ if(myId)
+ {
+ ptr.Set(*myId);
+ }
+ else
+ {
+ _LIT(KEmptyString,"");
+ ptr.Set(KEmptyString);
+ }
+ iInteractiveElementListeners[i]->InteractiveElementExited(ptr);
+ }
+ }
+
+// ---------------------------------------------------------------------------
+// Set SVG Dimension to frame buffer size
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::SetSvgDimensionToFrameBufferL(TUint aWidth, TUint aHeight)
+ {
+ if (iSvgDocument == NULL ) return;
+ if (iSvgDocument->RootElement() != NULL)
+ {
+ CSvgElementImpl* theElement = (CSvgElementImpl*)(iSvgDocument->RootElement());
+ ((CSvgSvgElementImpl*)theElement)->iWidthInUserCoordinate = 0;
+ ((CSvgSvgElementImpl*)theElement)->iHeightInUserCoordinate = 0;
+ TFloatFixPt wFix( (TInt)aWidth );
+ TFloatFixPt hFix( (TInt)aHeight );
+ theElement->SetAttributeFloatL(KAtrWidth, wFix );
+ theElement->SetAttributeFloatL(KAtrHeight, hFix );
+ }
+
+ }
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::SetMediaTime(TUint32 aTimeInMilliSeconds)
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::SetMediaTime(TUint32 aTimeInMilliSeconds)
+ {
+ // Set Current Time in the document
+ if(iSvgDocument != NULL)
+ {
+ //iSvgDocument->SetCurrentTime( aTimeInMilliSeconds );
+
+ iSvgDocument->iAnimationResetNeeded = ETrue;
+ }
+ if(this->iSvgDocument && this->iSvgDocument->iEventHandler)
+ {
+ this->iSvgDocument->iEventHandler->SetCurrentTime(aTimeInMilliSeconds);
+ }
+ // Find all animation elements in the document
+ RPointerArray<CSvgElementImpl> lAnimationEleList;
+ if(iSvgDocument)
+ {
+ iSvgDocument->FindAllElements((CSvgElementImpl* )iSvgDocument->RootElement(),
+ KSvgMediaAnimationElement, lAnimationEleList );
+ TInt lAnimationEleCnt = lAnimationEleList.Count();
+ for ( TInt lCurAnimationEle = 0;
+ lCurAnimationEle < lAnimationEleCnt; lCurAnimationEle++ )
+ {
+ CSvgMediaAnimationElementImpl* lAnimationElement =
+ (CSvgMediaAnimationElementImpl* )lAnimationEleList[ lCurAnimationEle ];
+ CSvgDocumentImpl* lChildDoc = lAnimationElement->GetChildDocument();
+ if ( lChildDoc )
+ {
+ lChildDoc->iAnimationResetNeeded = ETrue;
+ if ( lChildDoc->iEventHandler )
+ {
+ lChildDoc->iEventHandler->SetCurrentTime(aTimeInMilliSeconds);
+ }
+
+ }
+ }
+ lAnimationEleList.Close();
+
+ }
+ this->SetSVGEngineState(ESVGEnginePaused);
+ this->SeekEngine(aTimeInMilliSeconds);
+
+ }
+
+// --------------------------------------------------------------------------
+// TBool CSvgEngineImpl::IsElementVisible( TInt aElementId )
+// ---------------------------------------------------------------------------
+TBool CSvgEngineImpl::IsElementVisible( TInt aElementId )
+ {
+ if ( aElementId == 0 || iFrameBuffer == NULL )
+ {
+ return EFalse;
+ }
+
+ CSvgElementImpl* element = (CSvgElementImpl*)aElementId;
+
+ TInt32 visibleAttribute = -1;
+
+ TRAPD(error,element->GetAttributeIntL( KCSS_ATTR_VISIBILITY, visibleAttribute ));
+ if (error != KErrNone)
+ {
+ // error processing
+ }
+
+
+ return visibleAttribute == 0;
+ }
+
+// Set whether to call request observer's UpdateScreen method
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::SetIgnoreUpdateScreen( TBool aBool )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::SetIgnoreUpdateScreen( TBool aBool )
+{
+ iIgnoreUpdateScreen = aBool;
+}
+
+/*---------------------------MouseListener---------------------------*/
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::AddMouseListener( const MSvgMouseListener* aListener )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::AddMouseListener( const MSvgMouseListener* aListener )
+ {
+ TInt index = iSvgMouseListeners.Find( aListener );
+ if ( aListener != NULL && index == KErrNotFound )
+ {
+ iSvgMouseListeners.Append( aListener );
+ }
+ }
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::RemoveMouseListener( const MSvgMouseListener* aListener )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::RemoveMouseListener( const MSvgMouseListener* aListener )
+ {
+ TInt index = iSvgMouseListeners.Find( aListener );
+ if ( index != KErrNotFound )
+ {
+ iSvgMouseListeners.Remove( index );
+ }
+ }
+
+// --------------------------------------------------------------------------
+// TInt CSvgEngineImpl::MouseListenerCount()
+// ---------------------------------------------------------------------------
+TInt CSvgEngineImpl::MouseListenerCount()
+ {
+ return iSvgMouseListeners.Count();
+ }
+
+/*-------------MouseListener Notifications back to client---------------------------*/
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyMousePressed( RPointerArray<CSvgElementImpl>& aElements,
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyMousePressed( RPointerArray<CSvgElementImpl>& aElements,
+ TInt aX, TInt aY )
+ {
+ TInt svgMouseListenersCnt = iSvgMouseListeners.Count();
+ for ( TInt i = 0; i < svgMouseListenersCnt; i++ )
+ {
+ iSvgMouseListeners[i]->MousePressed( aElements, aX, aY );
+ }
+ }
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyMouseReleased( RPointerArray<CSvgElementImpl>& aElements,
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyMouseReleased( RPointerArray<CSvgElementImpl>& aElements,
+ TInt aX, TInt aY )
+ {
+ TInt svgMouseListenersCnt = iSvgMouseListeners.Count();
+ for ( TInt i = 0; i < svgMouseListenersCnt; i++ )
+ {
+ iSvgMouseListeners[i]->MouseReleased( aElements, aX, aY );
+ }
+ }
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyMouseEntered( RPointerArray<CSvgElementImpl>& aElements,
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyMouseEntered( RPointerArray<CSvgElementImpl>& aElements,
+ TInt aX, TInt aY )
+ {
+ TInt svgMouseListenersCnt = iSvgMouseListeners.Count();
+ for ( TInt i = 0; i < svgMouseListenersCnt; i++ )
+ {
+ iSvgMouseListeners[i]->MouseEntered( aElements, aX, aY );
+ }
+ }
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyMouseExited( RPointerArray<CSvgElementImpl>& aElements,
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyMouseExited( RPointerArray<CSvgElementImpl>& aElements,
+ TInt aX, TInt aY )
+ {
+ TInt svgMouseListenersCnt = iSvgMouseListeners.Count();
+ for ( TInt i = 0; i < svgMouseListenersCnt; i++ )
+ {
+ iSvgMouseListeners[i]->MouseExited( aElements, aX, aY );
+ }
+ }
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::NotifyMouseMoved( RPointerArray<CSvgElementImpl>& aElements,
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::NotifyMouseMoved( RPointerArray<CSvgElementImpl>& aElements,
+ TInt aX, TInt aY )
+ {
+ TInt svgMouseListenersCnt = iSvgMouseListeners.Count();
+ for ( TInt i = 0; i < svgMouseListenersCnt; i++ )
+ {
+ iSvgMouseListeners[i]->MouseMoved( aElements, aX, aY );
+ }
+ }
+
+/*---------------------------------------------------------------------*/
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::GetViewableElementsAtPoint( RPointerArray<CSvgElementImpl>& aElements, TInt aX, TInt aY )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::GetViewableElementsAtPoint( CSvgDocumentImpl* aSvgDocument, RPointerArray<CSvgElementImpl>& aElements, TInt aX, TInt aY )
+ {
+ if ( aSvgDocument == NULL )
+ return;
+
+ //JSR226 Change this could slow down event handling but it seems to be required to work
+ UpdateCTM(aSvgDocument);
+
+ // Gather all "viewable" elements
+ RPointerArray<CSvgElementImpl> iViewableElementList;
+ if ( iViewableElementList.Count() == 0 )
+ {
+ FindAllViewableElements( (CSvgElementImpl* )aSvgDocument->RootElement(),
+ iViewableElementList );
+ }
+
+ // find the bounding box containing point
+ TGfxPoint2D point( aX, aY );
+ TGfxRectangle2D boundingBox;
+ TInt viewableEleListCnt = iViewableElementList.Count();
+ for ( TInt i = 0; i < viewableEleListCnt; i++ )
+ {
+ CSvgElementImpl* element = iViewableElementList[i];
+ element->GetBBox( boundingBox );
+ if ( boundingBox.Contains( point ) )
+ {
+ aElements.Append( element );
+ }
+ }
+ // Display of list
+ iViewableElementList.Close();
+ }
+
+// Return all viewable elements
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::FindAllViewableElements( CSvgElementImpl* aStartElement,
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::FindAllViewableElements( CSvgElementImpl* aStartElement,
+ RPointerArray<CSvgElementImpl>& iElementList )
+ {
+ if ( aStartElement == NULL )
+ return;
+ // The child elements of the defs element should not be viewable. skip the
+ // tree traversing if the element id is defs element
+ if(aStartElement->ElemID() == KSvgDefsElement)
+ return;
+
+ CSvgElementImpl* child = (CSvgElementImpl*)aStartElement->FirstChild();
+ while ( child != NULL )
+ {
+ // add to list if child is found
+ TInt32 displayValue = 0;
+ TRAP_IGNORE(child->GetAttributeIntL( KCSS_ATTR_DISPLAY, displayValue ));
+ if ( child->IsViewable() && child->IsVisible() && displayValue != KDisplayEnumNone )
+ {
+ //JSR226 CHANGE do we care if multiple signals are sent to some elements - would be faster without this check
+ if ( iElementList.Find( child ) == KErrNotFound )
+ {
+ iElementList.Append( child );
+ }
+ }
+ // find in grandchildren
+ FindAllViewableElements( child, iElementList );
+ child = (CSvgElementImpl*)child->NextSibling();
+ }
+ }
+
+// Return all non-viewable elements
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::FindAllNonViewableElements( CSvgElementImpl* aStartElement,
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::FindAllNonViewableElements( CSvgElementImpl* aStartElement,
+ RPointerArray<CSvgElementImpl>& iElementList )
+ {
+ if ( aStartElement == NULL )
+ return;
+
+ CSvgElementImpl* child = (CSvgElementImpl*)aStartElement->FirstChild();
+ while ( child != NULL )
+ {
+ // add to list if child is found
+ if ( !child->IsViewable() && !child->IsVisible() )
+ iElementList.Append( child );
+
+ // find in grandchildren
+ FindAllNonViewableElements( child, iElementList );
+ child = (CSvgElementImpl*)child->NextSibling();
+ }
+ }
+
+/**
+ * Return the data pointed to by the given URI string,
+ * from an external source.
+ */
+// --------------------------------------------------------------------------
+// HBufC8* CSvgEngineImpl::FetchExternalDataL( const TDesC& aUri )
+// ---------------------------------------------------------------------------
+HBufC8* CSvgEngineImpl::FetchExternalDataL( const TDesC& aUri )
+ {
+ if ( iRequestObserver == NULL )
+ {
+ #ifdef _DEBUG
+ RDebug::Printf("CSvgEngineImpl::FetchExternalData--requestobserver is NULL\n");
+ #endif //_DEBUG
+ return NULL;
+ }
+ // Connect session
+ RFs session;
+ TInt connectError = session.Connect();
+ if ( connectError != KErrNone )
+ {
+ #ifdef _DEBUG
+ RDebug::Printf("CSvgEngineImpl::FetchExternalData--session.Connect() failed: %d\n", connectError );
+ #endif //_DEBUG
+ return NULL;
+ }
+
+ RFile fileHandle;
+ // Check for FetchImage error code
+ TInt fetchError = iRequestObserver->FetchImage( aUri, session, fileHandle );
+ if ( fetchError != KErrNone )
+ {
+ #ifdef _DEBUG
+ RDebug::Printf("CSvgEngineImpl::FetchExternalData--FetchImage error: %d\n", fetchError );
+ #endif //_DEBUG
+ session.Close();
+ return NULL;
+ }
+
+ // Read file size
+ TInt fileSize = 0;
+ TInt sizeError = fileHandle.Size( fileSize );
+ if ( sizeError != KErrNone )
+ {
+ #ifdef _DEBUG
+ RDebug::Printf("CSvgEngineImpl::FetchExternalData--fileHandle.Size error: %d\n", sizeError );
+ #endif //_DEBUG
+ session.Close();
+ return NULL;
+ }
+
+ // Allocate memory for file
+ HBufC8* data = HBufC8::NewL( fileSize );
+ TPtr8 des = data->Des();
+ TInt readError = fileHandle.Read( des );
+ if ( readError != KErrNone )
+ {
+ #ifdef _DEBUG
+ RDebug::Printf("CSvgEngineImpl::FetchExternalData--fileHandle.Read error: %d\n", readError );
+ #endif //_DEBUG
+ session.Close();
+ delete data;
+ return NULL;
+ }
+
+ // Successful
+ session.Close();
+ return data;
+ }
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::SetAudioVolume( TInt aPercentage );
+// --------------------------------------------------------------------------
+void CSvgEngineImpl::SetAudioVolume( TInt aPercentage )
+ {
+
+ if ( !iSvgDocument )
+ {
+ return;
+ }
+ // Locate all the active audio elements
+ RPointerArray<CSvgElementImpl> lAudioElementList;
+
+ iSvgDocument->FindAllElements(
+ (CSvgElementImpl* )iSvgDocument->RootElement(),
+ KSvgAudioElement, lAudioElementList );
+ // Set the volume on each audio element
+ TInt lAudEleCnt = lAudioElementList.Count();
+ for ( TInt lCurAudioEle = 0; lCurAudioEle < lAudEleCnt; lCurAudioEle++ )
+ {
+ CSvgAudioElementImpl* lAudioElement = (CSvgAudioElementImpl*)lAudioElementList[ lCurAudioEle ];
+ lAudioElement->SetVolume( aPercentage );
+ }
+ lAudioElementList.Close();
+ }
+
+// --------------------------------------------------------------------------
+// TBool CSvgEngineImpl::ReadyToRender()
+// ---------------------------------------------------------------------------
+TBool CSvgEngineImpl::ReadyToRender()
+ {
+ return iSvgDocument != NULL;
+ }
+
+// --------------------------------------------------------------------------
+// TBool CSvgEngineImpl::IsEndedWithCompleteTextTag( TDes &BufferPtr,
+// TInt EndOffset)
+// ---------------------------------------------------------------------------
+TBool CSvgEngineImpl::IsEndedWithCompleteTextTag(TDes &aBufferPtr,TInt aEndOffset)
+ {
+ TChar KOpeningBrace = '<';
+ TChar KSlash = '/';
+
+ // This function searches the buffer in reverse order from the end offset
+ // to check whether the last element had a complete text tag.
+ // eg. of complete text tags
+ // <text>Hello</text>
+ // <text></text>
+ // eg. of an incomplete text tag
+ // <text />
+
+ TPtrC currentSelectionPtr = aBufferPtr.Left( aEndOffset );
+ TInt OpeningBracePos = currentSelectionPtr.LocateReverse( KOpeningBrace );
+ TInt SlashPos = currentSelectionPtr.LocateReverse( KSlash );
+ TBool retVal = EFalse;
+
+ // In case of a complete text tag the opening brace is one position behind
+ // slash.
+ if ( SlashPos == ( OpeningBracePos + 1 ) )
+ {
+ retVal = ETrue;
+ }
+
+ return retVal;
+ }
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::SaveSvgL( const TDesC& aFileName )
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::SaveSvgL( const TDesC& aFileName )
+ {
+ RFs lFs;
+ RFileWriteStream lStream;
+ TInt error ;
+ TChar KOpeningBrace = '<';
+ TChar KSlash = '/';
+ // Connect to File Server to write the changed content to a file
+ CleanupClosePushL(lFs);
+ User::LeaveIfError(lFs.Connect() );
+
+ TBool isOpened = EFalse;
+ error = lFs.IsFileOpen( aFileName, isOpened ) ;
+ // dont leave if file doesnt exist or there is no error
+ if(error!= KErrNone && error!=KErrNotFound)
+ {
+ //usually will come here with KErrNotFound
+ //since file wont exist
+ User::Leave(error);
+ }
+
+ if ( isOpened )
+ {
+ #ifdef _DEBUG
+ RDebug::Printf( "Cannot SaveSvgL: File is still opened: ");
+ RDebug::RawPrint( aFileName );
+ #endif
+ CleanupStack::PopAndDestroy(1);
+ return;
+ }
+
+ // Try to create the write stream using the file name
+ if ( lStream.Create( lFs, aFileName, EFileWrite ) != KErrNone )
+ {
+ // If creation fails, file exists already, try to open the
+ // existing file
+ User::LeaveIfError( lStream.Open(lFs, aFileName, EFileWrite) );
+ }
+ CleanupClosePushL(lStream);
+
+ // Array to store list of all editable elements
+ RPointerArray<CSvgElementImpl> lTextElementList;
+
+ FindEditableElements( (CSvgElementImpl* )iSvgDocument->RootElement(),
+ lTextElementList );
+ CleanupClosePushL(lTextElementList);
+ TInt index=0, startoffset = 0, endoffset = 0;
+
+ // The content of the file is stored in the root <svg> node
+ HBufC* lBufferContent = ((CSvgSvgElementImpl* )iSvgDocument->RootElement())->iContent;
+
+
+
+ // While there are remaining editable elements do
+ while(index < lTextElementList.Count())
+ {
+ TBool EndedWithCompleteTextTag= true;
+ TInt OrgLength;
+
+ if ( lTextElementList[index]->ElemID() == KSvgTextElement )
+ {
+ // If the element is a <text> element invoke element specific function
+ // to retrieve the offset and original length
+ endoffset = ((CSvgTextElementImpl *)lTextElementList[index])->iOffset;
+ OrgLength = ((CSvgTextElementImpl *)lTextElementList[index])->GetOrgLength();
+ }
+ else
+ {
+ // If the element is a <textArea> element invoke element specific function
+ // to retrieve the offset and original length
+ endoffset = ((CSvgTextAreaElementImpl *)lTextElementList[index])->iOffset;
+ OrgLength = ((CSvgTextAreaElementImpl *)lTextElementList[index])->GetOrgLength();
+ }
+
+ // These are the cases which have to be processed
+ // a. Text Element: No Closing Tag: <text ... />
+ // b. Text Element: No CData : <text ...></text>
+ // c. Text Element: CData : <text ...>Sample Text</text>
+ // d. TextArea Element: No Closing Tag: <textArea ... />
+ // e. TextArea Element: No CData: <textArea ...></textArea>
+ // f. TextArea Element: CData: <textArea ...>Sample TextArea</textArea>
+ // -> for a,b,d,e the endoffset represents the offset after the closing braces.
+ // for e.g. <text ... />
+ // ^
+ // <text></text>
+ // ^
+ // -> for c,f the EndOffset represents the offset to the first character in
+ // content.
+ // <text>Hello</text>
+ //
+ // ^
+ if(!OrgLength)
+ {
+ //case a,b,d,e
+ TPtr BufferPtr=lBufferContent->Des();
+ EndedWithCompleteTextTag = IsEndedWithCompleteTextTag(BufferPtr,endoffset);
+ if ( EndedWithCompleteTextTag )
+ {
+ // case b,e
+ if(endoffset < startoffset)
+ {
+ User::Leave(KErrNotFound);
+ }
+ TPtrC lPtrtoPresentText = lBufferContent->Mid( startoffset, ( endoffset - startoffset ) );
+ //end offset modified ot point to <text></text>
+ // ^
+ endoffset = startoffset + lPtrtoPresentText.LocateReverse( KOpeningBrace );
+ }
+ else
+ {
+ //case a,d
+ if(endoffset < startoffset)
+ {
+ User::Leave(KErrNotFound);
+ }
+ TPtrC lPtrtoPresentText = lBufferContent->Mid( startoffset, ( endoffset - startoffset ) );
+ endoffset = startoffset + lPtrtoPresentText.LocateReverse( KSlash );
+ //end offset modified ot point to <text/>
+ // ^
+ }
+ }
+ if(endoffset < startoffset)
+ {
+ User::Leave(KErrNotFound);
+ }
+ TPtrC lPtrtoWrBuffer = lBufferContent->Mid( startoffset, ( endoffset - startoffset ) );
+ TInt lWrBufLength = lPtrtoWrBuffer .Length();
+ User::LeaveIfError(WriteToStream(lStream,lPtrtoWrBuffer));
+ // If it was a text element ...
+ if ( lTextElementList[index]->ElemID() == KSvgTextElement )
+ {
+ HBufC *lBufTextContent= NULL;
+ //make startoffset point to opening tag '<' or '/' in case of a,d
+ TPtrC lPtrtoTextContent= ( (CSvgTextElementImpl* ) lTextElementList[ index ] )->GetText();
+ startoffset = endoffset + ( (CSvgTextElementImpl* ) lTextElementList[ index ] )->iOrgLength;
+ lBufTextContent = TextTagProcessingL(&lPtrtoTextContent,
+ startoffset,OrgLength,EndedWithCompleteTextTag);
+ CleanupStack::PushL(lBufTextContent);
+ TPtr lTempPtr(lBufTextContent->Des());
+ lPtrtoTextContent.Set(lTempPtr);
+ User::LeaveIfError(WriteToStream(lStream,lPtrtoTextContent));
+ CleanupStack::PopAndDestroy(lBufTextContent);
+ }
+ else
+ {
+ HBufC *lBufTextAreaContent= NULL;
+ HBufC* lBufPresentText = NULL;
+ TInt textlength = ((CSvgTextAreaElementImpl *)lTextElementList[index])->GetLength();
+ lBufTextAreaContent = HBufC::NewLC( textlength );
+
+ TPtr lPtrtoGetTextAreaContent = lBufTextAreaContent->Des();
+ ((CSvgTextAreaElementImpl *)lTextElementList[index])->GetText( lPtrtoGetTextAreaContent );
+ TPtrC lPtrtoTextAreaContent=lPtrtoGetTextAreaContent;
+ startoffset = endoffset + ((CSvgTextAreaElementImpl *)lTextElementList[index])->iOrgLength;
+ lBufPresentText = TextAreaTagProcessingL(&lPtrtoTextAreaContent,startoffset,OrgLength,EndedWithCompleteTextTag);
+ CleanupStack::PushL(lBufPresentText);
+ TPtr lTempPtr(lBufPresentText->Des());
+ lPtrtoTextAreaContent.Set(lTempPtr);
+ User::LeaveIfError(WriteToStream(lStream,lPtrtoTextAreaContent));
+ CleanupStack::PopAndDestroy(lBufPresentText);
+ CleanupStack::PopAndDestroy(lBufTextAreaContent);
+ }
+ index++;
+ }
+
+ // Done using the list, close the list to avoid a memory leak
+ CleanupStack::PopAndDestroy(&lTextElementList);
+
+ // After processing all the editable text elements, are there any characters in the buffer
+ if( startoffset < lBufferContent->Length() )
+ {
+ TPtrC lPtrtoRemainText = lBufferContent->Mid(startoffset,(lBufferContent->Length()-startoffset));
+ User::LeaveIfError(WriteToStream(lStream,lPtrtoRemainText));
+ }
+
+ // Close the stream
+ CleanupStack::PopAndDestroy(&lStream);
+
+ // Close the file server session
+ CleanupStack::PopAndDestroy(&lFs);
+ }
+
+//-----------------------------------------------------------------------------
+//Function to process the text and add tags at the end
+//HBufC* CSvgEngineImpl::TextTagProcessing(TPtr* aCData, TInt aStartOffset, TInt aOrgLength,
+// TBool aEndingWithTag)
+//-----------------------------------------------------------------------------
+
+HBufC* CSvgEngineImpl::TextTagProcessingL(TPtrC* aCData,
+ TInt &aStartOffset, TInt aOrgLength,TBool aEndingWithTag)
+ {
+ HBufC * lTextContentBuffer = NULL;
+ TPtrC lPtrToTextContent(*aCData) ;
+ //Ending with complete text tag and original length is 0
+ if( aEndingWithTag && aOrgLength == 0 )
+ {//case b
+ lTextContentBuffer = HBufC::NewLC(aCData->Length()
+ + KClosingTextTagLength );
+ TPtr lPtrToTempBuf(lTextContentBuffer->Des());//point to buffer
+ lPtrToTempBuf.Append(*aCData);//append cdata
+ lPtrToTempBuf.Append(KClosingTextTag);//append closing text tag
+ aStartOffset += KClosingTextTagLength;
+ }
+ else if( !aEndingWithTag && aOrgLength == 0 )
+ {//case a
+ lTextContentBuffer = HBufC::NewLC(aCData->Length()
+ + KClosingTextTagLength
+ + KClosingBracesLength );
+ TPtr lPtrToTempBuf(lTextContentBuffer->Des());//point to buffer
+ lPtrToTempBuf.Append(KClosingBraces);
+ lPtrToTempBuf.Append(*aCData);//append cdata
+ lPtrToTempBuf.Append(KClosingTextTag);//append closing text tag
+ aStartOffset += 2;// the length of /> which is 2 characters.
+ }
+ else if(aEndingWithTag && aOrgLength!= 0)
+ {
+ lTextContentBuffer = HBufC::NewLC(aCData->Length()
+ + KClosingTextTagLength );
+ TPtr lPtrToTempBuf(lTextContentBuffer->Des());//point to buffer
+ lPtrToTempBuf.Append(*aCData);//append cdata
+ lPtrToTempBuf.Append(KClosingTextTag);//append closing text tag
+ aStartOffset += KClosingTextTagLength ;
+ }
+ else
+ {
+ //i.e !aEndingWithTag && OrgLength!=0
+ //this case should never occur
+ //becoz there is no possibility of
+ //the quoted kind of text content definition in xml as shown below
+ //"<text /> this is a text content"
+ }
+ // Pop the buffer from the cleanup stack as ownership is transferred
+ // to caller
+ CleanupStack::Pop(lTextContentBuffer);
+ return lTextContentBuffer;
+
+ }
+
+//-----------------------------------------------------------------------------
+//Function to process the text and add tags at the end
+//HBufC* CSvgEngineImpl::TextAreaTagProcessing(TPtr* aCData, TInt aStartOffset, TInt aOrgLength,
+// TBool aEndingWithTag)
+//-----------------------------------------------------------------------------
+
+HBufC* CSvgEngineImpl::TextAreaTagProcessingL(TPtrC* aCData, TInt &aStartOffset, TInt aOrgLength,
+ TBool aEndingWithTag)
+ {
+ HBufC * lTextAreaContentBuffer = NULL;
+ TPtrC lPtrToTextAreaContent(*aCData) ;
+
+
+ //Ending with complete text tag and original length is 0
+ if( aEndingWithTag && aOrgLength == 0 )
+ {//case e
+ lTextAreaContentBuffer = HBufC::NewLC(aCData->Length()
+ + KClosingTextAreaTagLength);
+ TPtr lPtrToTempBuf(lTextAreaContentBuffer->Des());//point to buffer
+ lPtrToTempBuf.Append(*aCData);//append cdata
+ lPtrToTempBuf.Append(KClosingTextAreaTag);//append closing text tag
+ aStartOffset += KClosingTextAreaTagLength;
+ }
+ else if( !aEndingWithTag && aOrgLength == 0 )
+ {//case d
+ lTextAreaContentBuffer = HBufC::NewLC(aCData->Length()
+ + KClosingBracesLength
+ + KClosingTextAreaTagLength );
+ TPtr lPtrToTempBuf(lTextAreaContentBuffer->Des());//point to buffer
+ lPtrToTempBuf.Append(KClosingBraces);
+ lPtrToTempBuf.Append(*aCData);//append cdata
+ lPtrToTempBuf.Append(KClosingTextAreaTag);//append closing text tag
+ aStartOffset += 2;// the length of /> which is 2 characters.
+ }
+ else if(aEndingWithTag && aOrgLength!= 0)
+ {//case f
+ lTextAreaContentBuffer = HBufC::NewLC(aCData->Length()
+ + KClosingTextAreaTagLength );
+ TPtr lPtrToTempBuf(lTextAreaContentBuffer->Des());//point to buffer
+ lPtrToTempBuf.Append(*aCData);//append cdata
+ lPtrToTempBuf.Append(KClosingTextAreaTag);//append closing text tag
+ aStartOffset += KClosingTextAreaTagLength;
+ }
+ else
+ {
+ //i.e !aEndingWithTag && OrgLength!=0
+ //this case should never occur
+ //becoz there is no possibility of
+ //the quoted kind of text content definition in xml as shown below
+ //"<textArea /> this is a text content"
+ }
+ // Pop the buffer from the cleanup stack as ownership is transferred
+ // to caller
+ CleanupStack::Pop(lTextAreaContentBuffer);
+ return lTextAreaContentBuffer;
+
+ }
+
+
+//-----------------------------------------------------------------------------
+//Function to Write the buffer to the stream.
+//In SaveSVGL while editing text - used to write partial buffers into the stream.
+//TInt CSvgEngineImpl::WriteToStream(RFileWriteStream* aStream,TPtrC aWriteBuffer)
+//-----------------------------------------------------------------------------
+TInt CSvgEngineImpl::WriteToStream(RFileWriteStream &aStream,TPtrC aWriteBuffer)
+ {
+ // Create a small output buffer
+ TBuf8<KMaxConversionChars> outputBuffer;
+
+ for(;;) // conversion loop
+ {
+ // Start conversion. When the output buffer is full, return the
+ // number of characters that were not converted
+ const TInt returnValue = CnvUtfConverter::ConvertFromUnicodeToUtf8(
+ outputBuffer, // Destination
+ aWriteBuffer ); // Source
+
+
+ // check to see that the descriptor isn’t corrupt - return with
+ // err if it is
+ if ( returnValue == CnvUtfConverter::EErrorIllFormedInput )
+ {
+ return( KErrCorrupt );
+ }
+ else
+ {
+ if ( returnValue < 0 ) // future-proof against "TError" expanding
+ {
+ return( KErrGeneral );
+ }
+ }
+
+ // Store the converted contents of the output buffer into the stream
+ TRAPD( err1, aStream.WriteL( outputBuffer ) );
+ if ( err1 )
+ {
+ #ifdef _DEBUG
+ RDebug::Printf("CSvgEngineImpl::WriteToStream error trapped=%d", err1);
+ return err1;
+ #endif
+ }
+
+ // Finish conversion if there are no unconverted characters in the
+ // remainder buffer
+ if ( returnValue == 0 )
+ {
+ break;
+ }
+
+ // Remove the converted source text from the remainder buffer.
+ // The remainder buffer is then fed back into loop
+ aWriteBuffer.Set( aWriteBuffer.Right( returnValue ));
+ }
+ return KErrNone;
+ }
+
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::FindEditableElements( CSvgElementImpl* aStartElement,
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::FindEditableElements( CSvgElementImpl* aStartElement,
+ RPointerArray<CSvgElementImpl>& aList )
+ {
+ if ( aStartElement == NULL )
+ {
+ return;
+ }
+
+ CSvgElementImpl* child = (CSvgElementImpl*)aStartElement->FirstChild();
+ while ( child != NULL )
+ {
+ // add to list if child is found
+ if ( child->ElemID() == KSvgTextElement || child->ElemID() == KSvgTextAreaElement )
+ aList.Append( child );
+
+ // find in grandchildren if element is not a textArea
+ if ( child->ElemID() != KSvgTextAreaElement )
+ {
+ FindEditableElements( child, aList );
+ }
+ child = (CSvgElementImpl*)child->NextSibling();
+ }
+}
+TBool CSvgEngineImpl::IsSVGEnginePaused()
+{
+ return (iSvgEngineState == ESVGEnginePaused );
+
+}
+
+// --------------------------------------------------------------------------
+// void CSvgEngineImpl::ResetContext()
+// ---------------------------------------------------------------------------
+void CSvgEngineImpl::ResetContext()
+{
+ if( iGfxContext )
+ {
+ iGfxContext->DestroyContext();
+ }
+}
+
+void CSvgEngineImpl::SetBitmapHeader(const TDesC* aHeaderData)
+ {
+ if (iGfxContext)
+ {
+ ((CGfx2dGcOpenVG *)iGfxContext)->SetBitmapHeader(aHeaderData);
+ }
+ }
+//NGA
+// ---------------------------------------------------------------------------
+// SetGdiContext File
+// ---------------------------------------------------------------------------
+
+void CSvgEngineImpl::SetGdiContextL(CFbsBitmap* aCurrentBitmap, CFbsBitmap* aMask,TSize aCurrentBitmapSize,TDisplayMode aRenderDspMode,TDisplayMode aMaskDspMode)
+
+ {
+ // Handle for both Non-NULL and NULL parameter
+ iFrameBufferSize = aCurrentBitmapSize;
+ iRenderDspMode = aRenderDspMode;
+ iMaskDspMode = aMaskDspMode;
+ iFrameBuffer = aCurrentBitmap;
+ iMask = aMask;
+
+ if ( aCurrentBitmapSize.iWidth > 0 && aCurrentBitmapSize.iHeight > 0 )
+ {
+ if ( !iGfxContext )
+ {
+ iGfxContext = CGfx2dGcOpenVG::NewL( aCurrentBitmapSize, iBitmapFontSpec, iSvgBitmapFontProvider,1 );
+ }
+ else
+ {
+ iGfxContext->ChangeBufferSizeL( aCurrentBitmapSize );
+ }
+ }
+ else if ( iGfxContext )
+ {
+ iGfxContext->ChangeBufferSizeL( TSize( 1, 1 ) );
+ }
+ }
+const TPtrC8 CSvgEngineImpl::TLVEncodedData() const
+ {
+ return (iGfxContext->TLVEncodedData());
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/breakdeps/Svgdecoder.cpp Fri Oct 15 09:48:18 2010 +0100
@@ -0,0 +1,4422 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: SVG Engine source file
+ *
+*/
+
+#include <e32def.h>
+#include <e32base.h>
+#include <s32mem.h>
+#include "Svgdecoder.h"
+#include "SVGClrCssValueImpl.h"
+#include "SVGFloatCssValueImpl.h"
+#include "SVGIntCssValueImpl.h"
+#include "SVGStrCssValueImpl.h"
+#include "SVGVectorCssValueImpl.h"
+#include "GfxAffineTransform.h"
+#include "SVGTextElementImpl.h"
+#include "SVGFontFaceElementImpl.h"
+#include "SvgStopElementImpl.h"
+#include "SVGUseElementImpl.h"
+#include "SVGAnimationBase.h"
+#include "SVGAnimateMotionElementImpl.h"
+#include "SVGMpathElementImpl.h"
+#include "SVGGradientElementImpl.h"
+#include "SVGDiscardElementImpl.h"
+#include "SVGMediaElementBase.h"
+#include "SVGMediaAnimationElementImpl.h"
+#include "SVGTimedEntityInterface.h"
+#include "SVGAudioElementImpl.h"
+
+#include "SVGDocumentImpl.h"
+#include "SVGEngineImpl.h"
+#include "SVGMemoryManager.h"
+
+#include <languages.hrh>
+
+_LIT(OFFSET, "offset");
+_LIT(ZEROVALUE, "0");
+
+// --------------------------------------------------------------------------
+// CSvgDecoder* CSvgDecoder::NewL(const TDesC& aFileName )
+// ---------------------------------------------------------------------------
+CSvgDecoder* CSvgDecoder::NewL(const TDesC& aFileName )
+{
+ CSvgDecoder *self = new (ELeave) CSvgDecoder();
+
+ CleanupStack::PushL(self);
+
+ self->ConstructL(aFileName);
+
+ CleanupStack::Pop();
+
+ return self;
+}
+
+
+// --------------------------------------------------------------------------
+// void CSvgDecoder::ConstructL(const TDesC& aFileName)
+// ---------------------------------------------------------------------------
+void CSvgDecoder::ConstructL(const TDesC& aFileName)
+{
+ User::LeaveIfError(iFs.Connect() );
+ User::LeaveIfError (iFStream.Open(iFs, aFileName, EFileRead));
+ iStream= iFStream;
+
+ /*Arrays Added For forward referencing in USE and Animate elements*/
+ iUseElementArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
+ iUseElementArray->Reset();
+
+ iAnimRefElementArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
+ iAnimRefElementArray->Reset();
+}
+
+
+// --------------------------------------------------------------------------
+// CSvgDecoder* CSvgDecoder::NewL(const TDesC8& aByteData )
+// ---------------------------------------------------------------------------
+CSvgDecoder* CSvgDecoder::NewL(const TDesC8& aByteData )
+{
+ CSvgDecoder *self = new (ELeave) CSvgDecoder();
+
+ CleanupStack::PushL(self);
+
+ self->ConstructL(aByteData);
+
+ CleanupStack::Pop();
+
+ return self;
+}
+
+
+// --------------------------------------------------------------------------
+// void CSvgDecoder::ConstructL(const TDesC8& aByteData)
+// ---------------------------------------------------------------------------
+void CSvgDecoder::ConstructL(const TDesC8& aByteData)
+{
+ iDStream.Open(aByteData);
+ iStream= iDStream;
+
+ iUseElementArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
+ iUseElementArray->Reset();
+
+ iAnimRefElementArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
+ iAnimRefElementArray->Reset();
+
+ // added to hold switch element handles so we can go back and delete false children of the switch
+ iSwitchElementArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
+ iSwitchElementArray->Reset();
+
+ // Arrays added to reset event listeners for animation element
+ iAnimationElementArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
+ iAnimationElementArray->Reset();
+
+ //added to hold elements with required features, attributes, or sys language
+ //so we can go back and delete the ones that dont pass at the start.
+ iReqFetAttSysArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
+ iReqFetAttSysArray->Reset();
+}
+
+
+// --------------------------------------------------------------------------
+// CSvgDecoder::CSvgDecoder()
+// ---------------------------------------------------------------------------
+CSvgDecoder::CSvgDecoder()
+ :iRootElement( NULL ),
+ iIsAnimElement(EFalse),
+ iIsFixPt(EFalse),
+ iIsRGB(EFalse),
+ iEmbeddedImagesCount(0)
+
+{
+}
+
+
+// --------------------------------------------------------------------------
+// CSvgDecoder::~CSvgDecoder()
+// ---------------------------------------------------------------------------
+CSvgDecoder::~CSvgDecoder()
+{
+ iStream.Close();
+ iDStream.Close();
+ iFStream.Close();
+
+ iFs.Close();
+
+ if(iUseElementArray)
+ {
+ iUseElementArray->Reset();
+ iUseElementArray->Close();
+ delete iUseElementArray;
+ iUseElementArray = NULL;
+ }
+
+ if(iAnimRefElementArray)
+ {
+ iAnimRefElementArray->Reset();
+ iAnimRefElementArray->Close();
+ delete iAnimRefElementArray;
+ iAnimRefElementArray = NULL;
+ }
+
+ if(iSwitchElementArray)
+ {
+ iSwitchElementArray->Close();
+ delete iSwitchElementArray;
+ }
+ if (iReqFetAttSysArray)
+ {
+ iReqFetAttSysArray->Close();
+ delete iReqFetAttSysArray;
+ }
+ if(iAnimationElementArray)
+ {
+ iAnimationElementArray->Reset();
+ iAnimationElementArray->Close();
+ delete iAnimationElementArray;
+ }
+
+ iImageElements.Close();
+
+}
+
+
+// --------------------------------------------------------------------------
+// TDesC& CSvgDecoder::DecodeTDesCLC()
+// ---------------------------------------------------------------------------
+TDesC& CSvgDecoder::DecodeTDesCLC()
+{
+
+ TUint8 lUniCodeLen = 2;
+
+ TUint8 uStrLen;
+ iStream >> uStrLen ;
+ HBufC *lBuf = NULL;
+
+ if (uStrLen)
+ {
+
+ lBuf = HBufC::NewLC(uStrLen/lUniCodeLen);
+ TPtr lTmp= lBuf->Des();
+ iStream.ReadL (lTmp, (TInt) (uStrLen/lUniCodeLen));
+ }
+
+ else
+ {
+ lBuf = HBufC::NewLC(0);
+ }
+
+ return (TDesC &) *lBuf;
+}
+
+// --------------------------------------------------------------------------
+// TDesC& CSvgDecoder::DecodeImageEmbeddedTDesCLC()
+// ---------------------------------------------------------------------------
+TDesC& CSvgDecoder::DecodeImageEmbeddedTDesCLC()
+{
+
+// TUint8 lUniCodeLen = 2;
+
+ TInt32 lImageSize;
+ iStream >> lImageSize ;
+
+ HBufC *lBuf = NULL;
+ HBufC8* lBuffer =NULL;
+
+ if (lImageSize)
+ {
+ lBuffer = HBufC8::NewLC(lImageSize);
+ TPtr8 lTemp= lBuffer->Des();
+ iStream.ReadL (lTemp, (TInt) (lImageSize));
+
+ lBuf = HBufC::NewLC(lImageSize);
+ TPtr lTmp= lBuf->Des();
+ lTmp.Copy(lTemp);
+ }
+
+ else
+ {
+ lBuffer = HBufC8::NewLC(0);
+ lBuf = HBufC::NewLC(0);
+ }
+
+
+ return (TDesC &) *lBuf;
+}
+
+
+
+// ==========================================================================
+// Decodig Attribute
+// ==========================================================================
+TInt CSvgDecoder::DecodeAttributeL(const TUint16 aName)
+ {
+
+ if( DecodePresentationAttributeL (aName) ||
+ DecodeSVGTAttributeL (aName) ||
+ DecodeSvgElementAttributeL (aName) ||
+ DecodeIdAndXmlAttributeL ( aName ) ||
+ DecodeUriRefAttributeL ( aName ) ||
+ DecodeAnimationAttributeL (aName) ||
+ DecodeTransformAttributeL (aName) ||
+ DecodeLangSpaceAttributeL (aName) ||
+ DecodeTestAttributeL ( aName ) ||
+ DecodeDiscardAttributeL ( aName )
+ )
+ {
+ return KErrNone;
+ }
+ else
+ {
+ return KErrNotFound;
+ }
+ }
+
+
+
+// --------------------------------------------------------------------------
+// TBool CSvgDecoder::DecodePresentationAttributeL(const TUint16 aName)
+// ---------------------------------------------------------------------------
+TBool CSvgDecoder::DecodePresentationAttributeL(const TUint16 aName)
+ {
+
+ if(aName<=KCSS_MAX_ATTR)
+ {
+
+ if (aName== KCSS_ATTR_FILL )
+ {
+
+ CCssValue* tParentValue = NULL;
+ CCssValue* tValue = NULL;
+
+ iCurrentElement->FindProperty (KCSS_ATTR_FILL,tValue);
+
+ if(iCurrentElement!= iRootElement)
+ {
+ iCurrentParentElement->FindProperty (KCSS_ATTR_FILL,tParentValue);
+ }
+
+ if (tParentValue == tValue || tValue == NULL)
+ {
+ if (iDocument)
+ {
+ tValue = iDocument->iMemoryManager->GetCssPaintObjectL(iCurrentElement);
+ }
+ SetPaintValueL (tValue);
+ iCurrentElement->SetPresentationAttribute (KCSS_ATTR_FILL,tValue);
+ }
+ else
+ {
+ SetPaintValueL (tValue);
+ }
+
+ return ETrue;
+ }
+
+ if (aName== KCSS_ATTR_STROKE || aName== KCSS_ATTR_COLOR)
+ {
+ return DecodeColorCssValueL(aName);
+ }
+
+ if (aName== KCSS_ATTR_GROUP_OPACITY)
+ {
+ iDocument->iHasGroupOpacity = ETrue;
+ return DecodeFloatCssValueL(aName);
+ }
+ if (aName== KCSS_ATTR_FILL_OPACITY ||
+ aName== KCSS_ATTR_STROKE_OPACITY ||
+ aName== KCSS_ATTR_STROKEWIDTH ||
+ aName== KCSS_ATTR_FONTSIZE ||
+ aName== KCSS_ATTR_STROKE_MITERLIMIT ||
+ aName== KCSS_ATTR_STROKE_DASHOFFSET
+ )
+
+ {
+ return DecodeFloatCssValueL(aName);
+ }
+
+ if (aName== KCSS_ATTR_VISIBILITY ||
+ aName== KCSS_ATTR_FONTSTYLE ||
+ aName== KCSS_ATTR_FONTWEIGHT ||
+ aName== KCSS_ATTR_DISPLAY ||
+ aName== KCSS_ATTR_TEXTANCHOR ||
+ aName== KCSS_ATTR_TEXTDECORATION
+ )
+
+ {
+ return DecodeIntCssValueL(aName);
+ }
+
+ if (aName== KCSS_ATTR_FONTFAMILY ||
+ aName== KCSS_ATTR_FILLRULE ||
+ aName== KCSS_ATTR_STROKE_LINECAP ||
+ aName== KCSS_ATTR_STROKE_LINEJOIN
+ )
+
+ {
+ return DecodeStringCssValueL(aName);
+ }
+
+
+ if (aName== KCSS_ATTR_STROKE_DASHARRAY)
+ {
+ CArrayFix<TFloatFixPt>* lArrayFix;
+ TInt8 lCount;
+ iStream >> lCount;
+ if (lCount)
+ {
+ lArrayFix= new ( ELeave ) CArrayFixFlat<TFloatFixPt>( lCount );
+ }
+ else
+ {
+ lArrayFix= new ( ELeave ) CArrayFixFlat<TFloatFixPt>( 1 );
+ }
+
+ CleanupStack::PushL(lArrayFix); //cleanup
+
+ TFloatFixPt lTempFix;
+ TReal32 lTempReal;
+
+ for(TInt8 i=0; i<lCount; i++)
+ {
+ if (iIsFixPt)
+ {
+ //was encoded as fixed point
+ lTempFix.iValue = iStream.ReadInt32L();
+ lArrayFix->AppendL( lTempFix );
+ }
+ else
+ {
+ //was encoded as floats
+
+ iStream >> lTempReal;
+ lArrayFix->AppendL( (TFloatFixPt) lTempReal);
+ }
+ }
+
+ CCssValue* tParentValue = NULL;
+ CCssValue* tValue = NULL;
+
+ iCurrentElement->FindProperty ((TInt8)aName,tValue);
+
+ if(iCurrentElement!= iRootElement)
+ {
+ iCurrentParentElement->FindProperty ((TInt8)aName,tParentValue);
+ }
+
+ if ( tParentValue == tValue || tValue == NULL )
+ {
+ // This attribute is inherited from parent, or not
+ // defined in parent
+ if ( iDocument )
+ {
+ // Create a new Vector object and clone lArrayFix
+ tValue = iDocument->iMemoryManager->GetCssVectorObjectL( lArrayFix );
+ // Associate tValue with the current element
+ iCurrentElement->SetPresentationAttribute ( ( TInt8 ) aName,tValue );
+ }
+ // tValue contains a copy of lArrayFix, hence lArrayFix is not needed
+ // anymore.
+ // tValue is owned by the element.
+ CleanupStack::PopAndDestroy( lArrayFix ); //cleanup
+ }
+ else
+ {
+ // stroke dash array was already present in the element
+ // SetValueL function takes ownership of lArrayFix
+ ((CVectorCssValueImpl*)tValue)->SetValueL ( lArrayFix );
+ // No need to destroy lArrayFix as it is now owned
+ // by the element.
+ CleanupStack::Pop( lArrayFix ); //cleanup
+ }
+
+
+ return ETrue;
+
+ }
+
+ else
+ {
+ return ETrue;
+ }
+
+ }
+
+ else
+ {
+ return EFalse;
+ }
+
+ }
+
+
+// --------------------------------------------------------------------------
+// TBool CSvgDecoder::DecodeSVGTAttributeL(const TUint16 aName)
+// ---------------------------------------------------------------------------
+TBool CSvgDecoder::DecodeSVGTAttributeL(const TUint16 aName)
+ {
+
+ if( (iCurrentElement->ElemID() == KSvgSvgElement) &&
+ ( aName== KAtrWidth || aName== KAtrHeight ) )
+ {
+ TUint8 lFlag;
+
+ iStream >> lFlag ;
+
+ if (iIsFixPt)
+ {
+ TFloatFixPt lAtrValue;
+ lAtrValue.iValue = iStream.ReadInt32L();
+
+ // Flag is used to ckech whether height and width are percentage or not.
+ if(lFlag)
+ {
+ if(aName == KAtrWidth)
+ {
+ ((CSvgSvgElementImpl *)iCurrentElement)->iWidthInPercentage = ETrue;
+ ((CSvgSvgElementImpl *)iCurrentElement)->iWidthInUserCoordinate = lAtrValue;
+ }
+ else if(aName == KAtrHeight)
+ {
+ ((CSvgSvgElementImpl *)iCurrentElement)->iHeightInPercentage = ETrue;
+ ((CSvgSvgElementImpl *)iCurrentElement)->iHeightInUserCoordinate = lAtrValue;
+ }
+ }
+ else
+ {
+ if(aName == KAtrWidth)
+ {
+ ((CSvgSvgElementImpl *)iCurrentElement)->iWidthInPercentage = EFalse;
+ }
+ else if(aName == KAtrHeight)
+ {
+ ((CSvgSvgElementImpl *)iCurrentElement)->iHeightInPercentage = EFalse;
+ }
+ iCurrentElement->SetAttributeFloatL( (TInt)aName, lAtrValue );
+ }
+ }
+ else
+ {
+ TReal32 lAtrValue;
+ iStream >> lAtrValue;
+
+ // Flag is used to ckech whether height and width are percentage or not.
+ if(lFlag)
+ {
+ if(aName == KAtrWidth)
+ {
+ ((CSvgSvgElementImpl *)iCurrentElement)->iWidthInPercentage = ETrue;
+ ((CSvgSvgElementImpl *)iCurrentElement)->iWidthInUserCoordinate = lAtrValue;
+ }
+ else if (aName == KAtrHeight)
+ {
+ ((CSvgSvgElementImpl *)iCurrentElement)->iHeightInPercentage = ETrue;
+ ((CSvgSvgElementImpl *)iCurrentElement)->iHeightInUserCoordinate = lAtrValue;
+ }
+
+ }
+ else
+ {
+ if(aName == KAtrWidth)
+ {
+ ((CSvgSvgElementImpl *)iCurrentElement)->iWidthInPercentage = EFalse;
+ }
+ else if(aName == KAtrHeight)
+ {
+ ((CSvgSvgElementImpl *)iCurrentElement)->iHeightInPercentage = EFalse;
+ }
+ iCurrentElement->SetAttributeFloatL( (TInt)aName, (TFloatFixPt)lAtrValue );
+ }
+ }
+
+ return ETrue;
+ }
+
+ if(iCurrentElement->ElemID() == KSvgTextElement)
+ {
+ if (aName== KAtrX || aName== KAtrY)
+ {
+ CArrayFixFlat<TFloatFixPt>* lArrayFix;
+ TInt8 lCount;
+ iStream >> lCount;
+ if (lCount)
+ {
+ lArrayFix= new ( ELeave ) CArrayFixFlat<TFloatFixPt>( lCount );
+ }
+ else
+ {
+ lArrayFix= new ( ELeave ) CArrayFixFlat<TFloatFixPt>( 1 );
+ }
+
+ CleanupStack::PushL(lArrayFix); //cleanup
+
+ for(TInt8 i=0; i<lCount; i++)
+ {
+ if (iIsFixPt)
+ {
+ TFloatFixPt lTemp;
+ lTemp.iValue = iStream.ReadInt32L();
+ lArrayFix->AppendL( lTemp );
+ }
+ else
+ {
+ TReal32 lTemp;
+ iStream >> lTemp ;
+ lArrayFix->AppendL( (TFloatFixPt) lTemp);
+ }
+
+ }
+
+ ((CSvgTextElementImpl*)iCurrentElement)->SetXYArray(aName,lArrayFix);
+ CleanupStack::Pop(lArrayFix); //cleanup
+ return ETrue;
+ }
+ }
+
+
+ if( aName<KSvgFloatAttrEndIndex ||
+ aName== KAtrFx ||
+ aName== KAtrFy ||
+ aName== KAtrOffset ||
+ aName== KAtrStopOpacity
+ )
+ {
+
+ return DecodeAttributeFloatL(aName);
+ }
+
+ else if(aName == KAtrK)
+ {
+ iCurrentElement->iReqAttrFlag =0;
+ return DecodeAttributeFloatL(aName);
+ }
+
+ else if( aName<= KSvgDesAttrEndIndex ||
+ aName== KAtrMedia ||
+ aName== KAtrTitle
+ )
+ {
+
+ return DecodeAttributeDesL(aName);
+ }
+ else if (aName== KAtrVolume)
+ {
+ if (iIsFixPt)
+ {
+ TFloatFixPt lTemp;
+ lTemp.iValue = iStream.ReadInt32L();
+ TBuf<16> lTemp2;
+ _LIT(KAudioLevelFormat, "%f");
+ lTemp2.Format(KAudioLevelFormat, (float)lTemp );
+ //lTemp2.AppendNum((float)lTemp );
+ ((CSvgAudioElementImpl *)iCurrentElement)->SetAttributeL (_L("volume"),lTemp2);
+ }
+ else
+ {
+ TReal32 lTemp;
+ iStream >> lTemp;
+ TBuf<16> lTemp2;
+ _LIT(KAudioLevelFormat, "%f");
+ lTemp2.Format(KAudioLevelFormat, (float)lTemp );
+ //lTemp2.AppendNum(lTemp);
+ ((CSvgAudioElementImpl *)iCurrentElement)->SetAttributeL (_L("volume"),lTemp2);
+ }
+ return ETrue;
+ }
+ else if (aName== KAtrAudioLevel)
+ {
+ if (iIsFixPt)
+ {
+ TFloatFixPt lTemp;
+ lTemp.iValue = iStream.ReadInt32L();
+ TBuf<16> lTemp2;
+ _LIT(KAudioLevelFormat, "%f");
+ lTemp2.Format(KAudioLevelFormat, (float)lTemp );
+ //lTemp2.AppendNum((float)lTemp );
+ ((CSvgAudioElementImpl *)iCurrentElement)->SetAttributeL (_L("audio-level"),lTemp2);
+ }
+ else
+ {
+ TReal32 lTemp;
+ iStream >> lTemp;
+ TBuf<16> lTemp2;
+ _LIT(KAudioLevelFormat, "%f");
+ lTemp2.Format(KAudioLevelFormat, (float)lTemp );
+ //lTemp2.AppendNum(lTemp);
+ ((CSvgAudioElementImpl *)iCurrentElement)->SetAttributeL (_L("audio-level"),lTemp2);
+ }
+ return ETrue;
+ }
+
+ switch( aName )
+ {
+ case KAtrType:
+ {
+ if(iCurrentElement->ElemID()== KSvgAnimateTransformElement)
+ {
+ if (iCurrentElement->iReqAttrFlag == KAtrSVGTrf)
+ {
+ iCurrentElement->iReqAttrFlag=KAtrAttributeName;
+ }
+ else
+ {
+ iCurrentElement->iReqAttrFlag= 0;
+ }
+ TUint8 lType, lSize;
+ iStream >> lType;
+ ((CSvgAnimationBase*)iCurrentElement)->SetAttributeType(lType);
+ iStream >> lSize;
+ ((CSvgAnimateTransformElementImpl*)iCurrentElement)->SetMatrixDataSize(lSize);
+ return ETrue;
+ }
+ else if(iCurrentElement->ElemID()== KSvgAudioElement)
+ {
+ TPtrC lPtr(DecodeTDesCLC());
+ ((CSvgAudioElementImpl*)iCurrentElement)->SetAttributeL(_L("type"),lPtr);
+ CleanupStack::PopAndDestroy( 1 );
+ return ETrue;
+ }
+ else
+ {
+ return DecodeAttributeDesL(aName);
+ }
+ }
+
+ case KAtrCdata:
+ {
+ if ( iCurrentElement->ElemID() == KSvgTextElement )
+ {
+ // DecodeTDesCLC() allocates the string on the cleanup stack
+ // and advances the file pointer beyond the CData
+ // SetTextL() makes a copy of the CData in the text element.
+ ( ( CSvgTextElementImpl* )iCurrentElement )->SetTextL(
+ DecodeTDesCLC() );
+ }
+ else
+ {
+ // Skip the CData
+ DecodeTDesCLC();
+ }
+ // Free the CData allocated inside DecodeTDesCLC()
+ CleanupStack::PopAndDestroy( 1 );
+ return ETrue;
+ }
+
+ case KAtrD:
+ case KAtrPoints:
+ {
+ iCurrentElement->iReqAttrFlag = 0;
+ return DecodeAttributePathL(aName);
+ }
+
+ case KAtrSpreadMethods:
+ case KAtrGradientUnits:
+ {
+ return DecodeAttributeIntL(aName);
+ }
+
+ case KAtrRotate:
+ {
+ // for AnimateMotion Element
+ if (iCurrentElement->ElemID()== KSvgAnimateMotionElement)
+ {
+ TInt16 lRotate;
+ iStream >> lRotate;
+ ((CSvgAnimateMotionElementImpl*)iCurrentElement)->SetAnimRotate(lRotate);
+ }
+
+ // For Text Element
+ else
+ {
+ TInt8 lCount;
+ CArrayFixFlat<TReal32>* lArray;
+ iStream >> lCount;
+ if(lCount)
+ {
+ lArray= new ( ELeave ) CArrayFixFlat<TReal32>( lCount );
+ CleanupStack::PushL(lArray); //cleanup
+ for (TInt i=0; i<lCount; i++)
+ {
+ TReal32 lTemp;
+ iStream >> lTemp;
+ lArray->AppendL((TReal32) lTemp);
+ }
+
+ if ( iCurrentElement->ElemID() == KSvgTextElement )
+ {
+ ((CSvgTextElementImpl*)iCurrentElement)->SetRotateArray (lArray);
+ }
+
+ CleanupStack::Pop(lArray); //cleanup
+ }
+ }
+
+ return ETrue;
+ }
+
+ case KAtrStopColor:
+ {
+ TUint32 lColor;
+ iStream >> lColor;
+ // Shift from XBGR to XRGB
+ if(!iIsRGB)
+ {
+ lColor = ( lColor & 0xFF000000) |
+ ( (lColor & 0x00FF0000) >> 16 ) |
+ ( lColor & 0x0000FF00 ) |
+ ( (lColor & 0x000000FF) << 16 );
+ }
+
+ if ( iCurrentElement->ElemID() == KSvgStopElement )
+ {
+ ((CSvgStopElementImpl*)iCurrentElement)->SetStopColorL(lColor);
+ }
+
+ return ETrue;
+ }
+
+ default:
+ {
+ return EFalse;
+ }
+ }
+ }
+
+// --------------------------------------------------------------------------
+// TBool CSvgDecoder::DecodeAnimationAttributeL(const TUint16 aName)
+// ---------------------------------------------------------------------------
+TBool CSvgDecoder::DecodeAnimationAttributeL(const TUint16 aName)
+ {
+
+ if (aName== KAtrAttributeName)
+ {
+ TUint16 lAtrId;
+ TUint8 lType;
+ iStream >> lAtrId;
+
+ // For Animate Transform element
+ if (iCurrentElement->ElemID()== KSvgAnimateTransformElement)
+ {
+ // Attribute Id of the animate transform has been changed. For binary compatibility
+ if (lAtrId == KAtrTransform )
+ {
+ lAtrId= KAtrAnimateTransformAttrId;
+ }
+ ((CSvgAnimationBase*)iCurrentElement)->SetAttributeId(lAtrId);
+
+ if (iCurrentElement->iReqAttrFlag == KAtrSVGTrf)
+ {
+ iCurrentElement->iReqAttrFlag=KAtrType;
+ }
+ else
+ {
+ iCurrentElement->iReqAttrFlag= 0;
+ }
+ }
+
+ //For other animation elements
+ else
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetAttributeId(lAtrId);
+ iCurrentElement->iReqAttrFlag= 0;
+ iStream >> lType;
+ ((CSvgAnimationBase*)iCurrentElement)->SetAttributeType(lType);
+ ((CSvgAnimationBase*)iCurrentElement)->GetAttrValueL();
+ }
+ return ETrue;
+ }
+
+ if (aName== KAtrBegin)
+ {
+ // Although discard element belongs to animation, the discard element isn't
+ // necessary inherited from giant AnimationBase, so handle attribute separately.
+ //
+ if ( iCurrentElement->ElemID() == KSvgDiscardElement /*||
+ iCurrentElement->ElemID() == KSvgMediaAnimationElement*/ )
+ {
+ return EFalse;
+ }
+
+ TInt8 lCheck, lCount;
+ iStream >> lCheck;
+ // Flag is used to check for Indefinite value.
+ if(lCheck)
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetAbsoluteBeginTime(KTimeIndefinite);
+ ((CSvgAnimationBase*)iCurrentElement)->SetBeginTime(KTimeIndefinite);
+ }
+ else
+ {
+ CArrayFixFlat<CSvgAnimationBase::TEventListItem>* lEventList;
+ RArray<TInt32>* lTimeList;
+ // event list
+ iStream >> lCount;
+ if (lCount)
+ {
+ lEventList= new (ELeave) CArrayFixFlat<CSvgAnimationBase::TEventListItem>(lCount);
+ }
+ else
+ {
+ lEventList= new (ELeave) CArrayFixFlat<CSvgAnimationBase::TEventListItem>(1);
+ }
+
+ CleanupStack::PushL(lEventList); //cleanup
+
+ for( TInt i=0; i<lCount; i++)
+ {
+ CSvgAnimationBase::TEventListItem lItem;
+ TInt32 lTime;
+ iStream >> lTime;
+ lItem.iTime= lTime;
+
+ TInt32 lOffset;
+ iStream >> lOffset;
+ lItem.iOffset= lOffset;
+
+ if (iIsFixPt)
+ {
+ TFloatFixPt temp;
+ temp.iValue = iStream.ReadInt32L();
+ lItem.iRepeatValue = (TReal32)temp;
+ }
+ else
+ {
+ TReal32 lValue;
+ iStream >> lValue;
+ lItem.iRepeatValue= lValue;
+ }
+
+
+ TPtrC lPtr(DecodeTDesCLC());
+ // check for the use of unique Id of the target element
+ if(lPtr == _L("unid"))
+ {
+ lItem.iTargetElement = (((CSvgAnimationBase*)iCurrentElement)->GetTargetElem());
+ lItem.iReferenceElemeId= NULL;
+ }
+ else
+ {
+ // get element by id and append its pointer.
+
+ // there can be an issue if the id is not found. in case of forward reference.
+ // for this we will store the id if it is not found at this time.
+ lItem.iTargetElement = (CSvgElementImpl*)iDocument->GetElementById( lPtr );
+ if( lItem.iTargetElement == NULL)
+ {
+ // this indicates that this is a forward reference in case of begin.
+
+ lItem.iReferenceElemeId = lPtr.AllocL();
+ }
+ else
+ {
+ // otherwise the element is found and we
+ // do not need to keep iReferenceElemeId so
+ // make it NULL;
+ lItem.iReferenceElemeId = NULL;
+ }
+ }
+
+ CleanupStack::PopAndDestroy( 1 );
+
+ TUint16 lCode;
+ iStream >> lCode;
+ lItem.iAccessKeyCode= lCode;
+
+ TInt8 lEvent;
+ iStream >> lEvent;
+ lItem.iEvent= (TSvgEvent) lEvent;
+
+ switch(lItem.iEvent)
+ {
+ case ESvgEventKey:
+ case ESvgEventNone:
+ {
+ lItem.iTargetElement =NULL;
+ break;
+ }
+ }
+ lEventList->AppendL((CSvgAnimationBase::TEventListItem) lItem);
+ }
+
+ ((CSvgAnimationBase*)iCurrentElement)->SetEventList(lEventList);
+ CleanupStack::Pop(lEventList); //cleanup
+
+ //begin time list
+ iStream >> lCount;
+ if (lCount)
+ {
+ lTimeList= new (ELeave) RArray<TInt32>(lCount);
+ }
+ else
+ {
+ lTimeList= new (ELeave) RArray<TInt32>(1);
+ }
+
+ // For proper cleanup
+ ((CSvgAnimationBase*)iCurrentElement)->SetBeginTimeList(lTimeList);
+ lTimeList->AppendL(NULL);
+ lTimeList->Remove(0);
+
+ for( TInt i=0; i<lCount; i++)
+ {
+ TInt32 lTime;
+ iStream >> lTime;
+ lTimeList->AppendL( (TInt32) lTime);
+ }
+
+ TInt32 lTime;
+ iStream >> lTime;
+ ((CSvgAnimationBase*)iCurrentElement)->SetAbsoluteBeginTime(lTime);
+ iStream >> lTime;
+ ((CSvgAnimationBase*)iCurrentElement)->SetBeginTime(lTime);
+
+
+ iStream >> lCheck;
+ // flag to ckeck Adding to the Reciever EventList
+ if(lCheck)
+ {
+ iDocument->AddToEventReceiverListL( iCurrentElement,
+ KSvgEventMaskExternalUI );
+ }
+ }
+ return ETrue;
+ }
+
+
+ if (aName== KAtrEnd) //End Time
+ {
+ TInt8 lCheck;
+ iStream >> lCheck;
+
+ // Flag is used to check for Indefinite value
+ if(lCheck)
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetEndTime(KTimeIndefinite);
+ }
+ else
+ {
+ CArrayFixFlat<CSvgAnimationBase::TEventListItem>* lTimeList;
+ // event list
+
+ lTimeList= new (ELeave) CArrayFixFlat<CSvgAnimationBase::TEventListItem>(1);
+ CleanupStack::PushL(lTimeList); //cleanup
+
+ CSvgAnimationBase::TEventListItem lItem;
+ TInt8 lEvent;
+ iStream >> lEvent;
+ lItem.iEvent = (TSvgEvent) lEvent;
+
+ if (iIsFixPt)
+ {
+ TFloatFixPt temp;
+ temp.iValue = iStream.ReadInt32L();
+ lItem.iRepeatValue = (TReal32)temp;
+ }
+ else
+ {
+ TReal32 lValue;
+ iStream >> lValue;
+ lItem.iRepeatValue= lValue;
+ }
+
+
+ TPtrC lPtr( DecodeTDesCLC() );
+
+ if (lPtr == _L("unid") )
+ {
+ lItem.iTargetElement = ((CSvgAnimationBase*)iCurrentElement)->GetTargetElem();
+ lItem.iReferenceElemeId = NULL;
+ }
+ else
+ {
+ // get element by id and append its pointer.
+ lItem.iTargetElement = ( CSvgElementImpl * )
+ iDocument->GetElementById( lPtr );
+ if(lItem.iTargetElement == NULL)
+ {
+ lItem.iReferenceElemeId = lPtr.AllocL();
+ }
+ else
+ {
+ // Set the iEndReferenceElemeId to NULL:
+ lItem.iReferenceElemeId = NULL;
+ }
+ }
+
+ CleanupStack::PopAndDestroy( 1 );
+
+ switch ( lItem.iEvent )
+ {
+ case ESvgEventKey:
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetEndTime(KTimeIndefinite ); // same as indefinite
+
+ TUint16 lCode;
+ iStream >> lCode;
+ lItem.iAccessKeyCode= lCode;
+ lItem.iTargetElement =NULL;
+ iDocument->AddToEventReceiverListL( iCurrentElement,
+ KSvgEventMaskExternalUI );
+ break;
+ }
+ case ESvgEventWallClock:
+ // not supported yet
+ break;
+ case ESvgEventNone:
+ {
+ TInt32 lTime;
+ iStream >> lTime;
+ lItem.iTime= lTime;
+ ((CSvgAnimationBase*)iCurrentElement)->AddEndTime(lTime);
+ lItem.iTargetElement =NULL;
+ break;
+ }
+ default:
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetEndTime( KTimeIndefinite ); // same as indifinite
+ TInt32 lOffset;
+ iStream >> lOffset;
+ lItem.iOffset= lOffset;
+
+ lItem.iTime = KTimeIndefinite;
+ iDocument->AddToEventReceiverListL( iCurrentElement,
+ KSvgEventMaskInternal );
+ }
+
+ }
+ lTimeList->AppendL( (CSvgAnimationBase::TEventListItem) lItem);
+ ((CSvgAnimationBase*)iCurrentElement)->SetEndTimeList( lTimeList);
+ CleanupStack::Pop(lTimeList); //cleanup
+
+ }
+
+ return ETrue;
+ }
+
+////////// for multiple end times
+
+ if (aName== KMultipleEndTime)
+ {
+ TInt8 lCount;
+
+ CArrayFixFlat<CSvgAnimationBase::TEventListItem>* lTimeList;
+ // event list
+ iStream >> lCount;
+ if (lCount)
+ {
+ lTimeList= new (ELeave) CArrayFixFlat<CSvgAnimationBase::TEventListItem>(lCount);
+ }
+ else
+ {
+ lTimeList= new (ELeave) CArrayFixFlat<CSvgAnimationBase::TEventListItem>(1);
+ }
+
+ CleanupStack::PushL(lTimeList); //cleanup
+
+ for( TInt i=0; i<lCount; i++)
+ {
+ CSvgAnimationBase::TEventListItem lItem;
+ TInt32 lTime;
+ iStream >> lTime;
+ lItem.iTime= lTime;
+
+ TInt32 lOffset;
+ iStream >> lOffset;
+ lItem.iOffset= lOffset;
+
+ if (iIsFixPt)
+ {
+ TFloatFixPt temp;
+ temp.iValue = iStream.ReadInt32L();
+ lItem.iRepeatValue = (TReal32)temp;
+ }
+ else
+ {
+ TReal32 lValue;
+ iStream >> lValue;
+ lItem.iRepeatValue= lValue;
+ }
+
+
+ TPtrC lPtr(DecodeTDesCLC());
+ // check for the use of unique Id of the target element
+ if(lPtr == _L("unid"))
+ {
+ lItem.iTargetElement = (((CSvgAnimationBase*)iCurrentElement)->GetTargetElem());
+ lItem.iReferenceElemeId= NULL;
+ }
+ else
+ {
+ // get element by id and append its pointer.
+ // there can be an issue if the id is not found. in case of forward reference.
+ // for this we will store the id if it is not found at this time.
+ lItem.iTargetElement = (CSvgElementImpl*)iDocument->GetElementById( lPtr );
+ if( lItem.iTargetElement == NULL)
+ {
+ // this indicates that this is a forward reference in case of begin.
+
+ lItem.iReferenceElemeId = lPtr.AllocL();
+ }
+ else
+ {
+ // otherwise the element is found and we
+ // do not need to keep iReferenceElemeId so
+ // make it NULL;
+ lItem.iReferenceElemeId = NULL;
+ }
+ }
+
+ CleanupStack::PopAndDestroy( 1 );
+
+ TUint16 lCode;
+ iStream >> lCode;
+ lItem.iAccessKeyCode= lCode;
+
+ TInt8 lEvent;
+ iStream >> lEvent;
+ lItem.iEvent= (TSvgEvent) lEvent;
+
+ switch ( lItem.iEvent )
+ {
+ case ESvgEventKey:
+ lItem.iTargetElement =NULL;
+ ((CSvgAnimationBase*)iCurrentElement)->SetEndTime( KTimeIndefinite ); // same as indefinite
+
+ iDocument->AddToEventReceiverListL( iCurrentElement,
+ KSvgEventMaskExternalUI );
+ break;
+
+ case ESvgEventWallClock:
+ // not supported yet
+ break;
+
+ case ESvgEventNone:
+ lItem.iTargetElement =NULL;
+ // Simple Offset-value
+ ((CSvgAnimationBase*)iCurrentElement)->AddEndTime( lItem.iTime );
+
+ break;
+
+ default:
+ // <id>.<event> +/- <offeset>
+ ((CSvgAnimationBase*)iCurrentElement)->SetEndTime( KTimeIndefinite ); // same as indifinite
+
+ iDocument->AddToEventReceiverListL( iCurrentElement,
+ KSvgEventMaskInternal );
+ }
+
+ lTimeList->AppendL((CSvgAnimationBase::TEventListItem) lItem);
+ }
+
+ ((CSvgAnimationBase*)iCurrentElement)->SetEndTimeList(lTimeList);
+ CleanupStack::Pop(lTimeList); //cleanup
+
+
+
+
+ return ETrue;
+ }
+
+
+ if (aName== KAtrDur)
+ {
+ TInt32 lTime;
+ TInt8 lCheck;
+ iStream >> lTime;
+ ((CSvgAnimationBase*)iCurrentElement)->SetDurationTime(lTime);
+ iStream >> lCheck;
+ // Flag is used to check for Indefinite value
+ if(lCheck)
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetBeginTime(KTimeIndefinite);
+ }
+ return ETrue;
+ }
+
+ if (aName== KAtrFrom)
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetFromFlag();
+
+ //For Animate Transform element
+ if(iCurrentElement->ElemID()== KSvgAnimateTransformElement)
+ {
+ CSvgAnimateTransformElementImpl::TMatrixData lMatrix;
+
+ if (iIsFixPt)
+ {
+ for (TInt i=0; i<3; i++)
+ {
+ lMatrix.iData[i].iValue = iStream.ReadInt32L();
+ }
+ }
+ else
+ {
+ TReal32 lTemp;
+ for (TInt i=0; i<3; i++)
+ {
+ iStream >> lTemp;
+ lMatrix.iData[i]= (TFloatFixPt) lTemp;
+ }
+ }
+
+ ((CSvgAnimateTransformElementImpl*)iCurrentElement)->SetMatrixData(0,lMatrix);
+ }
+
+ // for other Animation elements
+ else
+ {
+
+ TUint8 lType;
+ iStream >>lType;
+ ((CSvgAnimationBase*)iCurrentElement)->SetAttributeType(lType);
+ switch ( lType )
+ {
+ case KSvgTypeOpacity:
+ case KSvgTypeLength:
+ {
+ if (iIsFixPt)
+ {
+ TFloatFixPt lValue;
+ lValue.iValue = iStream.ReadInt32L();
+ ((CSvgAnimationBase*)iCurrentElement)->SetFromFloat(lValue);
+ }
+ else
+ {
+ TReal32 lValue;
+ iStream >> lValue;
+ ((CSvgAnimationBase*)iCurrentElement)->SetFromFloat((TFloatFixPt)lValue);
+ }
+
+ break;
+ }
+ case KSvgTypeList:
+ case KSvgTypePath:
+ {
+ CGfxGeneralPath* lPath;
+ DecodeAnimationPathL(lPath);
+ ((CSvgAnimationBase*)iCurrentElement)->SetFromPathL(lPath);
+ break;
+ }
+ case KSvgTypeColor:
+ {
+ TInt32 lColor;
+ iStream >> lColor;
+ // Shift from XBGR to XRGB
+ if(!iIsRGB)
+ {
+ lColor = ( lColor & 0xFF000000) |
+ ( (lColor & 0x00FF0000) >> 16 ) |
+ ( lColor & 0x0000FF00 ) |
+ ( (lColor & 0x000000FF) << 16 );
+ }
+ ((CSvgAnimationBase*)iCurrentElement)->SetFromInt(lColor);
+ break;
+ }
+ case KSvgTypeTextAnchor:
+ case KSvgTypeGradientUnits:
+ case KSvgTypeSpreadMethod:
+ case KSvgTypeInteger:
+ case KSvgTypeDisplay:
+ case KSvgTypeVisibility:
+ {
+ TInt32 lTemp;
+ iStream >> lTemp;
+ ((CSvgAnimationBase*)iCurrentElement)->SetFromInt(lTemp);
+ break;
+ }
+
+ // viewBox attribute
+ case KSvgTypeViewBox:
+ {
+
+ if (iIsFixPt)
+ {
+ TGfxRectangle2D temp;
+ temp.iX.iValue = iStream.ReadInt32L();
+
+ temp.iY.iValue = iStream.ReadInt32L();
+ temp.iWidth.iValue = iStream.ReadInt32L();
+ temp.iHeight.iValue = iStream.ReadInt32L();
+
+ ((CSvgAnimationBase*)iCurrentElement)->SetFromViewBox(temp);
+ }
+ else
+ {
+ TReal32 lValue;
+ TGfxRectangle2D temp;
+
+ this->iStream >> lValue;
+ temp.iX = (TFloatFixPt) lValue;
+ this->iStream >> lValue;
+ temp.iY = (TFloatFixPt) lValue;
+ this->iStream >> lValue;
+ temp.iWidth = (TFloatFixPt) lValue;
+ this->iStream >> lValue;
+ temp.iHeight = (TFloatFixPt) lValue;
+
+ ((CSvgAnimationBase*)iCurrentElement)->SetFromViewBox(temp);
+ }
+ break;
+ }
+ }
+ }
+ return ETrue;
+ }
+
+ if (aName== KAtrTo)
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetToFlag();
+
+ // For Animate Transform
+ if(iCurrentElement->ElemID()== KSvgAnimateTransformElement)
+ {
+ if( ((CSvgAnimationBase*)iCurrentElement)->GetFromFlag() )
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetAdditive(KAdditiveSum);
+ }
+ CSvgAnimateTransformElementImpl::TMatrixData lMatrix;
+
+ if (iIsFixPt)
+ {
+ for (TInt i=0; i<3; i++)
+ {
+ lMatrix.iData[i].iValue = iStream.ReadInt32L();
+ }
+ }
+ else
+ {
+ TReal32 lTemp;
+ for (TInt i=0; i<3; i++)
+ {
+ iStream >> lTemp;
+ lMatrix.iData[i]= (TFloatFixPt) lTemp;
+ }
+ }
+
+ ((CSvgAnimateTransformElementImpl*)iCurrentElement)->SetMatrixData(1,lMatrix);
+ ((CSvgAnimateTransformElementImpl*)iCurrentElement)->SetAccumMatrix();
+ }
+
+ // for Other Animation Elements
+ else
+ {
+ TUint8 lType;
+ iStream >>lType;
+ ((CSvgAnimationBase*)iCurrentElement)->SetAttributeType(lType);
+ switch ( lType )
+ {
+ case KSvgTypeOpacity:
+ case KSvgTypeLength:
+ {
+
+ if (iIsFixPt)
+ {
+ TFloatFixPt lValue;
+ lValue.iValue = iStream.ReadInt32L();
+ ((CSvgAnimationBase*)iCurrentElement)->SetToFloat(lValue);
+ }
+ else
+ {
+ TReal32 lValue;
+ iStream >> lValue;
+ ((CSvgAnimationBase*)iCurrentElement)->SetToFloat((TFloatFixPt)lValue);
+ }
+
+ break;
+ }
+ case KSvgTypeList:
+ case KSvgTypePath:
+ {
+ CGfxGeneralPath* lPath;
+ DecodeAnimationPathL(lPath);
+ ((CSvgAnimationBase*)iCurrentElement)->SetToPath(lPath);
+ break;
+ }
+ case KSvgTypeColor:
+ {
+ TInt32 lColor;
+ iStream >> lColor;
+ // Shift from XBGR to XRGB
+ if(!iIsRGB)
+ {
+ lColor = ( lColor & 0xFF000000) |
+ ( (lColor & 0x00FF0000) >> 16 ) |
+ ( lColor & 0x0000FF00 ) |
+ ( (lColor & 0x000000FF) << 16 );
+ }
+ ((CSvgAnimationBase*)iCurrentElement)->SetToInt(lColor);
+ break;
+ }
+ case KSvgTypeTextAnchor:
+ case KSvgTypeGradientUnits:
+ case KSvgTypeSpreadMethod:
+ case KSvgTypeInteger:
+ case KSvgTypeDisplay:
+ case KSvgTypeVisibility:
+ {
+ TInt32 lTemp;
+ iStream >> lTemp;
+ ((CSvgAnimationBase*)iCurrentElement)->SetToInt(lTemp);
+ break;
+ }
+
+ // viewBox attribute
+ case KSvgTypeViewBox:
+ {
+ if (iIsFixPt)
+ {
+ TGfxRectangle2D temp;
+ temp.iX.iValue = iStream.ReadInt32L();
+ temp.iY.iValue = iStream.ReadInt32L();
+ temp.iWidth.iValue = iStream.ReadInt32L();
+ temp.iHeight.iValue = iStream.ReadInt32L();
+
+ ((CSvgAnimationBase*)iCurrentElement)->SetToViewBox(temp);
+ }
+ else
+ {
+ TReal32 lValue;
+ TGfxRectangle2D temp;
+
+ this->iStream >> lValue;
+ temp.iX = (TFloatFixPt) lValue;
+ this->iStream >> lValue;
+ temp.iY = (TFloatFixPt) lValue;
+ this->iStream >> lValue;
+ temp.iWidth = (TFloatFixPt) lValue;
+ this->iStream >> lValue;
+ temp.iHeight = (TFloatFixPt) lValue;
+
+ ((CSvgAnimationBase*)iCurrentElement)->SetToViewBox(temp);
+ }
+
+ break;
+ }
+
+ }
+ }
+ return ETrue;
+
+ }
+
+ if (aName== KAtrBy) //by
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetByFlag();
+
+ // For Animate Transform
+ if(iCurrentElement->ElemID()== KSvgAnimateTransformElement)
+ {
+ if( ((CSvgAnimationBase*)iCurrentElement)->GetFromFlag() )
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetAdditive(KAdditiveSum);
+ }
+ CSvgAnimateTransformElementImpl::TMatrixData lMatrix;
+
+ if (iIsFixPt)
+ {
+ for (TInt i=0; i<3; i++)
+ {
+ lMatrix.iData[i].iValue = iStream.ReadInt32L();
+ }
+ }
+ else
+ {
+ TReal32 lTemp;
+ for (TInt i=0; i<3; i++)
+ {
+ iStream >> lTemp;
+ lMatrix.iData[i]= (TFloatFixPt) lTemp;
+ }
+ }
+
+ ((CSvgAnimateTransformElementImpl*)iCurrentElement)->SetMatrixData(1,lMatrix);
+ }
+
+ // for Other Animation Elements
+ else
+ {
+ TUint8 lType;
+ iStream >>lType;
+ ((CSvgAnimationBase*)iCurrentElement)->SetAttributeType(lType);
+ switch ( lType )
+ {
+ case KSvgTypeOpacity:
+ case KSvgTypeLength:
+ {
+ if (iIsFixPt)
+ {
+ TFloatFixPt lValue;
+ lValue.iValue = iStream.ReadInt32L();
+
+ ((CSvgAnimationBase*)iCurrentElement)->SetToFloat( lValue );
+ if( ((CSvgAnimationBase*)iCurrentElement)->GetFromFlag() )
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetAdditive(KAdditiveSum);
+ ((CSvgAnimationBase*)iCurrentElement)->SetFromFlag();
+ ((CSvgAnimationBase*)iCurrentElement)->SetFromFloat((TFloatFixPt)0);
+ }
+ }
+ else
+ {
+ TReal32 lValue;
+ iStream >> lValue;
+
+ ((CSvgAnimationBase*)iCurrentElement)->SetToFloat((TFloatFixPt)lValue);
+ if( ((CSvgAnimationBase*)iCurrentElement)->GetFromFlag() )
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetAdditive(KAdditiveSum);
+ ((CSvgAnimationBase*)iCurrentElement)->SetFromFlag();
+ ((CSvgAnimationBase*)iCurrentElement)->SetFromFloat((TFloatFixPt)0);
+ }
+ }
+
+ break;
+ }
+ case KSvgTypeList:
+ case KSvgTypePath:
+ {
+ CGfxGeneralPath* lPath;
+ DecodeAnimationPathL(lPath);
+ ((CSvgAnimationBase*)iCurrentElement)->SetToPath(lPath);
+ break;
+ }
+
+ case KSvgTypeColor:
+ {
+ TInt32 lColor;
+ iStream >> lColor;
+ // Shift from XBGR to XRGB
+ if(!iIsRGB)
+ {
+ lColor = ( lColor & 0xFF000000) |
+ ( (lColor & 0x00FF0000) >> 16 ) |
+ ( lColor & 0x0000FF00 ) |
+ ( (lColor & 0x000000FF) << 16 );
+ }
+ ((CSvgAnimationBase*)iCurrentElement)->SetToInt(lColor);
+ if( ((CSvgAnimationBase*)iCurrentElement)->GetFromFlag() )
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetFromInt((TInt32)0);
+ }
+ break;
+ }
+ case KSvgTypeTextAnchor:
+ case KSvgTypeGradientUnits:
+ case KSvgTypeSpreadMethod:
+ case KSvgTypeInteger:
+ {
+ TInt32 lTemp;
+ iStream >> lTemp;
+ ((CSvgAnimationBase*)iCurrentElement)->SetToInt(lTemp);
+ if( ((CSvgAnimationBase*)iCurrentElement)->GetFromFlag() )
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetAdditive(KAdditiveSum);
+ ((CSvgAnimationBase*)iCurrentElement)->SetFromFlag();
+ ((CSvgAnimationBase*)iCurrentElement)->SetFromInt((TInt32)0);
+ }
+ break;
+ }
+
+ case KSvgTypeDisplay:
+ case KSvgTypeVisibility:
+ {
+ TInt32 lTemp;
+ iStream >> lTemp;
+ ((CSvgAnimationBase*)iCurrentElement)->SetToInt(lTemp);
+ break;
+ }
+
+ // viewBox attribute
+ case KSvgTypeViewBox:
+ {
+ if (iIsFixPt)
+ {
+ TGfxRectangle2D temp;
+ temp.iX.iValue = iStream.ReadInt32L();
+ temp.iY.iValue = iStream.ReadInt32L();
+ temp.iWidth.iValue = iStream.ReadInt32L();
+ temp.iHeight.iValue = iStream.ReadInt32L();
+
+ ((CSvgAnimationBase*)iCurrentElement)->SetToViewBox(temp);
+ }
+ else
+ {
+ TReal32 lValue;
+ TGfxRectangle2D temp;
+
+ iStream >> lValue;
+ temp.iX = (TFloatFixPt) lValue;
+ iStream >> lValue;
+ temp.iY = (TFloatFixPt) lValue;
+ iStream >> lValue;
+ temp.iWidth = (TFloatFixPt) lValue;
+ iStream >> lValue;
+ temp.iHeight = (TFloatFixPt) lValue;
+
+ ((CSvgAnimationBase*)iCurrentElement)->SetToViewBox(temp);
+ }
+
+ if( ((CSvgAnimationBase*)iCurrentElement)->GetFromFlag() )
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetAdditive(KAdditiveSum);
+ ((CSvgAnimationBase*)iCurrentElement)->SetFromFlag();
+ ((CSvgAnimationBase*)iCurrentElement)->SetFromViewBox
+ (TGfxRectangle2D( 0, 0, 0, 0 ) );
+ }
+ break;
+ }
+ }
+ }
+ return ETrue;
+
+ }
+
+
+ if (aName== KAtrValues) // values
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetFromFlag();
+ ((CSvgAnimationBase*)iCurrentElement)->SetValuesFlag();
+
+ // For Animate Transform
+ if(iCurrentElement->ElemID()== KSvgAnimateTransformElement)
+ {
+ TUint16 lCount;
+ RArray<CSvgAnimateTransformElementImpl::TMatrixData>* lValues= NULL;
+
+ iStream >>lCount;
+ if (lCount)
+ {
+ lValues= new (ELeave) RArray<CSvgAnimateTransformElementImpl::TMatrixData>(lCount);
+ }
+ else
+ {
+ lValues= new (ELeave) RArray<CSvgAnimateTransformElementImpl::TMatrixData>(1);
+ }
+
+ // for proper cleanup
+ ((CSvgAnimateTransformElementImpl*)iCurrentElement)->SetTransformValues(lValues);
+ CSvgAnimateTransformElementImpl::TMatrixData lMatrix1;
+ lValues->AppendL(lMatrix1);
+ lValues->Remove(0);
+
+ for (TInt i=0; i<lCount; i++)
+ {
+ CSvgAnimateTransformElementImpl::TMatrixData lMatrix;
+
+ if (iIsFixPt)
+ {
+ for (TInt i=0; i<3; i++)
+ {
+ lMatrix.iData[i].iValue = iStream.ReadInt32L();
+ }
+ }
+ else
+ {
+ TReal32 lTemp;
+ for (TInt i=0; i<3; i++)
+ {
+ iStream >> lTemp;
+ lMatrix.iData[i]= (TFloatFixPt) lTemp;
+ }
+ }
+
+ lValues->AppendL( (CSvgAnimateTransformElementImpl::TMatrixData) lMatrix);
+ }
+ if(iCurrentElement->ElemID()== KSvgAnimateTransformElement)
+ {
+ ((CSvgAnimateTransformElementImpl*)iCurrentElement)->SetAccumMatrix();
+ }
+ }
+
+
+ // For other Animation elements
+ else
+ {
+ TUint8 lType;
+ iStream >>lType;
+ ((CSvgAnimationBase*)iCurrentElement)->SetAttributeType(lType);
+ switch ( lType )
+ {
+ case KSvgTypeOpacity:
+ case KSvgTypeLength:
+ {
+ RArray<TFloatFixPt>* lArray;
+ TUint16 lCount;
+ iStream >> lCount;
+ if (lCount)
+ {
+ lArray= new (ELeave) RArray<TFloatFixPt>(lCount);
+ }
+ else
+ {
+ lArray= new (ELeave) RArray<TFloatFixPt>(1);
+ }
+
+ // for proper cleanup
+ ((CSvgAnimationBase*)iCurrentElement)->SetFloatValuesArray(lArray);
+ lArray->AppendL(NULL);
+ lArray->Remove(0);
+
+ TFloatFixPt lValueFix;
+ TReal32 lValueFloat;
+
+ for(TInt i=0; i<lCount; i++)
+ {
+
+ if(iIsFixPt)
+ {
+ lValueFix.iValue = iStream.ReadInt32L();
+ lArray->AppendL( lValueFix );
+ }
+ else
+ {
+ iStream >> lValueFloat;
+ lArray->AppendL((TFloatFixPt) lValueFloat);
+ }
+
+ }
+ break;
+ }
+ case KSvgTypeList:
+ case KSvgTypePath:
+ {
+ TUint16 lCount;
+ RPointerArray<CGfxGeneralPath>* lArray;
+ iStream >> lCount;
+ if (lCount)
+ {
+ lArray= new (ELeave) RPointerArray<CGfxGeneralPath>(lCount);
+ }
+ else
+ {
+ lArray= new (ELeave) RPointerArray<CGfxGeneralPath>(1);
+ }
+
+ // for proper cleanup
+ ((CSvgAnimationBase*)iCurrentElement)->ResetFloatValuesArray();
+ ((CSvgAnimationBase*)iCurrentElement)->SetPathValuesArray(lArray);
+ lArray->AppendL(NULL);
+ lArray->Remove(0);
+ for(TInt i=0; i<lCount; i++)
+ {
+ CGfxGeneralPath* lPath;
+ DecodeAnimationPathL(lPath);
+ lArray->AppendL( (CGfxGeneralPath*)lPath );
+ }
+ break;
+ }
+
+ case KSvgTypeColor:
+ {
+ RArray<TInt32>* lArray;
+ TUint16 lCount;
+ iStream >> lCount;
+ if (lCount)
+ {
+ lArray= new (ELeave) RArray<TInt32>(lCount);
+ }
+ else
+ {
+ lArray= new (ELeave) RArray<TInt32>(1);
+ }
+
+ // for proper cleanup
+ ((CSvgAnimationBase*)iCurrentElement)->ResetFloatValuesArray();
+ ((CSvgAnimationBase*)iCurrentElement)->SetIntValuesArray(lArray);
+ lArray->AppendL(NULL);
+ lArray->Remove(0);
+
+ for(TInt i=0; i<lCount; i++)
+ {
+ TInt32 lColor;
+ iStream >> lColor;
+ if(!iIsRGB)
+ {
+ lColor = ( lColor & 0xFF000000) |
+ ( (lColor & 0x00FF0000) >> 16 ) |
+ ( lColor & 0x0000FF00 ) |
+ ( (lColor & 0x000000FF) << 16 );
+ }
+ lArray->AppendL((TInt32) lColor);
+ }
+ break;
+ }
+
+ case KSvgTypeGradientUnits:
+ case KSvgTypeSpreadMethod:
+ case KSvgTypeInteger:
+ case KSvgTypeDisplay:
+ case KSvgTypeVisibility:
+ case KSvgTypeTextAnchor:
+ {
+ RArray<TInt32>* lArray;
+ TUint16 lCount;
+ iStream >> lCount;
+ if (lCount)
+ {
+ lArray= new (ELeave) RArray<TInt32>(lCount);
+ }
+ else
+ {
+ lArray= new (ELeave) RArray<TInt32>(1);
+ }
+
+ // for proper cleanup
+ ((CSvgAnimationBase*)iCurrentElement)->ResetFloatValuesArray();
+ ((CSvgAnimationBase*)iCurrentElement)->SetIntValuesArray(lArray);
+ lArray->AppendL(NULL);
+ lArray->Remove(0);
+
+ for(TInt i=0; i<lCount; i++)
+ {
+ TInt32 lValue;
+ iStream >> lValue;
+ lArray->AppendL((TInt32) lValue);
+ }
+ break;
+ }
+
+ // viewBox
+ case KSvgTypeViewBox:
+ {
+ RArray<TGfxRectangle2D>* lArray;
+ TUint16 lCount;
+ iStream >> lCount;
+ if (lCount)
+ {
+ lArray= new (ELeave) RArray<TGfxRectangle2D>(lCount);
+ }
+ else
+ {
+ lArray= new (ELeave) RArray<TGfxRectangle2D>(1);
+ }
+ TGfxRectangle2D temp1;
+ // for proper cleanup
+ ((CSvgAnimationBase*)iCurrentElement)->SetViewBoxValuesArray(lArray);
+ lArray->AppendL(temp1);
+ lArray->Remove(0);
+
+
+ TGfxRectangle2D temp;
+ TReal32 lValueFloat;
+ for(TInt i=0; i<lCount; i++)
+ {
+
+ if (iIsFixPt)
+ {
+ temp.iX.iValue = iStream.ReadInt32L();
+ temp.iY.iValue = iStream.ReadInt32L();
+ temp.iWidth.iValue = iStream.ReadInt32L();
+ temp.iHeight.iValue = iStream.ReadInt32L();
+
+ lArray->AppendL((TGfxRectangle2D) temp);
+ }
+ else
+ {
+ iStream >> lValueFloat;
+ temp.iX = (TFloatFixPt) lValueFloat;
+ iStream >> lValueFloat;
+ temp.iY = (TFloatFixPt) lValueFloat;
+ iStream >> lValueFloat;
+ temp.iWidth = (TFloatFixPt) lValueFloat;
+ iStream >> lValueFloat;
+ temp.iHeight = (TFloatFixPt) lValueFloat;
+
+ lArray->AppendL((TGfxRectangle2D) temp);
+ }
+ }
+ break;
+ }
+ }
+ }
+ return ETrue;
+
+ }
+
+ // Used to set the Fill attribute of Animation elements
+ if (aName== KAnimFreeze)
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetAnimFreeze();
+ return ETrue;
+ }
+
+ if (aName== KAtrRepeatDur)
+ {
+ TUint32 lDur;
+ iStream >> lDur;
+ ((CSvgAnimationBase*)iCurrentElement)->SetRepeatDuration(lDur);
+ return ETrue;
+ }
+
+ if (aName== KAtrRepeatCount)
+ {
+
+ if (iIsFixPt)
+ {
+ TFloatFixPt lCount;
+ lCount.iValue = iStream.ReadInt32L();
+ ((CSvgAnimationBase*)iCurrentElement)->SetRepeatCount(lCount.iValue);
+ }
+ else
+ {
+ TReal32 lCount;
+ iStream >> lCount;
+ ((CSvgAnimationBase*)iCurrentElement)->SetRepeatCount(lCount);
+ }
+
+ return ETrue;
+ }
+
+ if (aName== KAtrRestart)
+ {
+ TUint8 lMode;
+ iStream >> lMode;
+ ((CSvgAnimationBase*)iCurrentElement)->SetRestartMode((TRestartMode)lMode);
+ return ETrue;
+ }
+
+ if (aName== KAtrAccumulate)
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetAccumulate(KAccumSum);
+ return ETrue;
+ }
+
+ if (aName== KAtrAdditive)
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetAdditive(KAdditiveSum);
+ return ETrue;
+ }
+
+ if (aName== KAtrCalcMode)
+ {
+ TUint8 lMode;
+ iStream >> lMode;
+ ((CSvgAnimationBase*)iCurrentElement)->SetCalcMode((TAnimCalcMode) lMode);
+ return ETrue;
+ }
+
+ if (aName== KAtrKeyTimes)
+ {
+ TUint16 lCount;
+ RArray<CSvgAnimTimeController::TKeyTime>* lArray;
+ iStream >> lCount;
+ if (lCount)
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetKeyTimeFlag();
+ lArray= new (ELeave) RArray<CSvgAnimTimeController::TKeyTime>(lCount);
+ }
+ else
+ {
+ lArray= new (ELeave) RArray<CSvgAnimTimeController::TKeyTime>(1);
+ }
+ CSvgAnimTimeController::TKeyTime lTime1;
+ // for proper cleanup
+ ((CSvgAnimationBase*)iCurrentElement)->SetKeyTimeArray(lArray);
+ lArray->AppendL(lTime1);
+ lArray->Remove(0);
+
+ for (TInt i=0; i<lCount; i++)
+ {
+ TUint8 lTemp;
+ CSvgAnimTimeController::TKeyTime lTime;
+ iStream >> lTemp;
+ lTime.iX = (TUint16) (lTemp);
+ iStream >> lTemp;
+ lTime.iY = (TUint16) (lTemp);
+ lArray->AppendL( (CSvgAnimTimeController::TKeyTime) lTime);
+ }
+ return ETrue;
+ }
+
+ if (aName== KAtrKeySplines)
+ {
+ TUint16 lCount;
+ RArray<CSvgAnimTimeController::TKeyTime>* lArray;
+ RArray<TUint32>* lAnimArray;
+
+ // keyTime Array
+ iStream >> lCount;
+ if (lCount)
+ {
+ lArray= new (ELeave) RArray<CSvgAnimTimeController::TKeyTime>(lCount);
+ }
+ else
+ {
+ lArray= new (ELeave) RArray<CSvgAnimTimeController::TKeyTime>(1);
+ }
+ CSvgAnimTimeController::TKeyTime lTime1;
+ // for proper cleanup
+ ((CSvgAnimationBase*)iCurrentElement)->SetKeyTimeArray(lArray);
+ lArray->AppendL(lTime1);
+ lArray->Remove(0);
+ for (TInt i=0; i<lCount; i++)
+ {
+ TUint8 lTemp;
+ CSvgAnimTimeController::TKeyTime lTime;
+ iStream >> lTemp;
+ lTime.iX = (TUint16) (lTemp);
+ iStream >> lTemp;
+ lTime.iY = (TUint16) (lTemp);
+ lArray->AppendL( (CSvgAnimTimeController::TKeyTime) lTime);
+ }
+
+ //AnimTime Array
+ iStream >> lCount;
+ if (lCount)
+ {
+ lAnimArray = new (ELeave) RArray<TUint32>(lCount);
+ }
+ else
+ {
+ lAnimArray= new (ELeave) RArray<TUint32>(1);
+ }
+
+ ((CSvgAnimationBase*)iCurrentElement)->SetAnimTimeArray(lAnimArray);
+ lAnimArray->AppendL(NULL);
+ lAnimArray->Remove(0);
+
+ for (TInt i=0; i<lCount; i++)
+ {
+ TUint8 lTemp;
+ iStream >> lTemp;
+ lAnimArray->AppendL( (TUint32) lTemp);
+ }
+ return ETrue;
+ }
+
+
+ // Animate motion Element is handled here
+ if (aName== KAtrAnimateMotion)
+ {
+ DecodeAttributePathL(KAtrAnimateMotion);
+ TUint8 lFlag;
+ iStream >> lFlag;
+ if(lFlag == KAtrAdditiveSet)
+ {
+ iCurrentElement->iReqAttrFlag= 0;
+ ((CSvgAnimationBase*)iCurrentElement)->SetAdditive(KAdditiveSum);
+ return ETrue;
+ }
+ iCurrentElement->iReqAttrFlag= lFlag;
+ return ETrue;
+ }
+
+ if (aName== KAtrXlinkhref)
+ {
+ _LIT( KXlink, "xlink:href" );
+ TPtrC lPtr(DecodeTDesCLC());
+ CSvgMediaAnimationElementImpl* mediaElement = static_cast<CSvgMediaAnimationElementImpl*>(iCurrentElement);
+ mediaElement->SetAttributeL(KXlink, lPtr);
+ CleanupStack::PopAndDestroy(1);
+ return ETrue;
+ }
+
+ if( aName == KAtrSyncBehavior )
+ {
+ TUint8 syncBehavior;
+ iStream>>syncBehavior;
+ ((CSvgMediaElementBase*)iCurrentElement)->SetSyncBehavior( (TSvgSyncBehaviour) syncBehavior );
+ return ETrue;
+ }
+ else if( aName == KAtrSyncTolerance)
+ {
+ TUint8 syncTolerance;
+ iStream>>syncTolerance;
+ ((CSvgMediaElementBase*)iCurrentElement)->SetSyncTolerance( syncTolerance, EFalse );
+ return ETrue;
+ }
+ else if( aName == KAtrSyncMaster )
+ {
+ TUint8 syncMaster ;
+ iStream>>syncMaster ;
+ ((CSvgMediaElementBase*)iCurrentElement)->SetSyncMaster( syncMaster );
+ return ETrue;
+ }
+
+ return EFalse;
+ }
+
+
+
+// --------------------------------------------------------------------------
+// TBool CSvgDecoder::DecodeSvgElementAttributeL(const TUint16 aName)
+// ---------------------------------------------------------------------------
+TBool CSvgDecoder::DecodeSvgElementAttributeL(const TUint16 aName)
+ {
+ if ( ( aName<= KSvgSVGAttrEndIndex) ||
+ ( aName == KAtrSyncBehaviorDefault ) || // To support backward compatibility
+ ( aName == KAtrSyncToleranceDefault ))
+ {
+
+ if (aName== KAtrViewBox)
+ {
+ TGfxRectangle2D lRect;
+
+ if (iIsFixPt)
+ {
+ lRect.iX.iValue = iStream.ReadInt32L();
+ lRect.iY.iValue = iStream.ReadInt32L();
+ lRect.iWidth.iValue = iStream.ReadInt32L();
+ lRect.iHeight.iValue = iStream.ReadInt32L();
+
+ ((CSvgSvgElementImpl *)iCurrentElement)->SetViewBoxL(lRect);
+ }
+ else
+ {
+ TReal32 lTemp;
+
+ iStream >> lTemp;
+ lRect.iX= (TFloatFixPt) lTemp;
+ iStream >> lTemp;
+ lRect.iY= (TFloatFixPt) lTemp;
+ iStream >> lTemp;
+ lRect.iWidth= (TFloatFixPt) lTemp;
+ iStream >> lTemp;
+ lRect.iHeight= (TFloatFixPt) lTemp;
+
+ ((CSvgSvgElementImpl *)iCurrentElement)->SetViewBoxL(lRect);
+ }
+ return ETrue;
+ }
+
+ if (aName== KAtrBaseProfile)
+ {
+ ((CSvgSvgElementImpl *)iCurrentElement)->SetBaseProfileL(DecodeTDesCLC());
+ CleanupStack::PopAndDestroy( 1 );
+ return ETrue;
+ }
+
+ if (aName== KAtrVersion)
+ {
+
+ if (iIsFixPt)
+ {
+ TFloatFixPt lTemp;
+ lTemp.iValue = iStream.ReadInt32L();
+ TBuf<16> lTemp2;
+ lTemp2.AppendNum( (float)lTemp );
+ ((CSvgSvgElementImpl *)iCurrentElement)->SetVersion (lTemp2);
+ }
+ else
+ {
+ TReal32 lTemp;
+ iStream >> lTemp;
+ TBuf<16> lTemp2;
+ lTemp2.AppendNum(lTemp);
+ ((CSvgSvgElementImpl *)iCurrentElement)->SetVersion (lTemp2);
+ }
+
+ return ETrue;
+
+ /*
+ ((CSvgSvgElementImpl *)iCurrentElement)->SetVersion (DecodeTDesCLC());
+ CleanupStack::PopAndDestroy( 1 );
+ return ETrue;
+ */
+ }
+
+ if (aName== KAtrZoomAndPan)
+ {
+ TInt8 lTemp;
+ iStream >> lTemp;
+ TSvgZoomAndPanType lType= (TSvgZoomAndPanType) lTemp;
+ ((CSvgSvgElementImpl *)iCurrentElement)->SetZoomAndPan(lType);
+ return ETrue;
+ }
+
+ if (aName== KAtrPreserveAspectRatio)
+ {
+ if (iCurrentElement->ElemID()== KSvgSvgElement)
+ {
+ TInt8 lTemp;
+ iStream >> lTemp;
+ TSvgPreserveAspectAlignType lAType= (TSvgPreserveAspectAlignType) lTemp;
+ iStream >> lTemp;
+ TSvgMeetOrSliceType lMType= (TSvgMeetOrSliceType) lTemp;
+ ((CSvgSvgElementImpl *)iCurrentElement)->SetPreserveAspectRatioL(lAType, lMType);
+ return ETrue;
+ }
+ else if(iCurrentElement->ElemID()== KSvgMediaAnimationElement)
+ {
+ TInt8 lTemp;
+ iStream >> lTemp;
+ TSvgPreserveAspectAlignType lAType= (TSvgPreserveAspectAlignType) lTemp;
+ iStream >> lTemp;
+ TSvgMeetOrSliceType lMType= (TSvgMeetOrSliceType) lTemp;
+ ((CSvgMediaAnimationElementImpl*)iCurrentElement)->SetPreserveAspectRatioL(lAType, lMType);
+ return ETrue;
+ }
+ else
+ {
+ ((CSvgImageElementImpl *)iCurrentElement)->SetParL(DecodeTDesCLC());
+ CleanupStack::PopAndDestroy( 1 );
+ return ETrue;
+ }
+ }
+
+ if( aName == KAtrSyncBehaviorDefault )
+ {
+ TUint8 syncBehaviorDefault;
+ iStream>>syncBehaviorDefault;
+ ((CSvgSvgElementImpl*)iCurrentElement)->SetSyncBehaviorDefault( (TSvgSyncBehaviour) syncBehaviorDefault );
+ return ETrue;
+ }
+ else if( aName == KAtrSyncToleranceDefault )
+ {
+ TUint8 syncToleranceDefault;
+ iStream>>syncToleranceDefault;
+ ((CSvgSvgElementImpl*)iCurrentElement)->SetSyncToleranceDefault( syncToleranceDefault );
+ return ETrue;
+ }
+ else
+ {
+ return EFalse;
+ }
+ }
+
+ else
+ {
+ return EFalse;
+ }
+ }
+
+
+
+// --------------------------------------------------------------------------
+// TBool CSvgDecoder::DecodeLangSpaceAttributeL(const TUint16 aName)
+// ---------------------------------------------------------------------------
+TBool CSvgDecoder::DecodeLangSpaceAttributeL(const TUint16 aName)
+ {
+ if (aName<= KSvgLangAttrEndIndex)
+ {
+
+ if (aName== KAtrXmlLang)
+ {
+ iCurrentElement->SetXMLLangL (DecodeTDesCLC());
+ CleanupStack::PopAndDestroy( 1 );
+ return ETrue;
+ }
+
+ if (aName== KAtrXmlSpace)
+ {
+ iCurrentElement->SetXMLSpaceL (DecodeTDesCLC());
+ CleanupStack::PopAndDestroy( 1 );
+ return ETrue;
+ }
+
+ else
+ {
+ return EFalse;
+ }
+ }
+
+ else
+ {
+ return EFalse;
+ }
+ }
+
+
+
+// --------------------------------------------------------------------------
+// TBool CSvgDecoder::DecodeTransformAttributeL(const TUint16 aName)
+// ---------------------------------------------------------------------------
+TBool CSvgDecoder::DecodeTransformAttributeL(const TUint16 aName)
+ {
+
+ if (aName== KAtrTransform)
+ {
+
+ if (iIsFixPt)
+ {
+ TUint32 lTemp1;
+ TGfxAffineTransform lTransform;
+
+ lTransform.iM00.iValue = iStream.ReadInt32L();
+ lTransform.iM01.iValue = iStream.ReadInt32L();
+ lTransform.iM02.iValue = iStream.ReadInt32L();
+ lTransform.iM10.iValue = iStream.ReadInt32L();
+ lTransform.iM11.iValue = iStream.ReadInt32L();
+ lTransform.iM12.iValue = iStream.ReadInt32L();
+ iStream >> lTemp1;
+ lTransform.iTransType= (TGfxTransformType) lTemp1;
+
+ iCurrentElement->SetTransformList(lTransform);
+ }
+ else
+ {
+ TReal32 lTemp;
+ TUint32 lTemp1;
+ TGfxAffineTransform lTransform;
+
+ iStream >> lTemp;
+ lTransform.iM00= (TFloatFixPt) lTemp;
+ iStream >> lTemp;
+ lTransform.iM01= (TFloatFixPt) lTemp;
+ iStream >> lTemp;
+ lTransform.iM02= (TFloatFixPt) lTemp;
+ iStream >> lTemp;
+ lTransform.iM10= (TFloatFixPt) lTemp;
+ iStream >> lTemp;
+ lTransform.iM11= (TFloatFixPt) lTemp;
+ iStream >> lTemp;
+ lTransform.iM12= (TFloatFixPt) lTemp;
+ iStream >> lTemp1;
+ lTransform.iTransType= (TGfxTransformType) lTemp1;
+
+ iCurrentElement->SetTransformList(lTransform);
+ }
+
+ return ETrue;
+ }
+
+ else if ( aName== KAtrGradientTransform)
+ {
+
+ if (iIsFixPt)
+ {
+ SVGReal lMatrix[2][3];
+
+ TFloatFixPt lTemp;
+ lTemp.iValue = iStream.ReadInt32L();
+ lMatrix[0][0]= lTemp.iValue;
+ lTemp.iValue = iStream.ReadInt32L();
+ lMatrix[0][1]= lTemp.iValue;
+ lTemp.iValue = iStream.ReadInt32L();
+ lMatrix[0][2]= lTemp.iValue;
+ lTemp.iValue = iStream.ReadInt32L();
+ lMatrix[1][0]= lTemp.iValue;
+ lTemp.iValue = iStream.ReadInt32L();
+ lMatrix[1][1]= lTemp.iValue;
+ lTemp.iValue = iStream.ReadInt32L();
+ lMatrix[1][2]= lTemp.iValue;
+
+ ((CSvgGradientElementImpl*)iCurrentElement)->SetGradientTransMatrix(lMatrix);
+ }
+ else
+ {
+ TReal32 lTemp;
+ SVGReal lMatrix[2][3];
+
+ iStream >> lTemp;
+ lMatrix[0][0]= (SVGReal) lTemp;
+ iStream >> lTemp;
+ lMatrix[0][1]= (SVGReal) lTemp;
+ iStream >> lTemp;
+ lMatrix[0][2]= (SVGReal) lTemp;
+ iStream >> lTemp;
+ lMatrix[1][0]= (SVGReal) lTemp;
+ iStream >> lTemp;
+ lMatrix[1][1]= (SVGReal) lTemp;
+ iStream >> lTemp;
+ lMatrix[1][2]= (SVGReal) lTemp;
+
+ ((CSvgGradientElementImpl*)iCurrentElement)->SetGradientTransMatrix(lMatrix);
+ }
+
+ return ETrue;
+ }
+
+
+
+ else
+ {
+ return EFalse;
+ }
+ }
+
+
+
+// --------------------------------------------------------------------------
+// TBool CSvgDecoder::DecodeTestAttributeL(const TUint16 aName)
+// ---------------------------------------------------------------------------
+TBool CSvgDecoder::DecodeTestAttributeL(const TUint16 aName)
+ {
+ if(aName<= KSvgTestAttrEndIndex)
+ {
+
+ if (
+ aName== KAtrRequiredFeatures ||
+ aName== KAtrRequiredExtensions ||
+ aName== KAtrSystemLanguage
+ )
+ {
+ CDesCArrayFlat* lFeatures;
+ TInt8 lCount;
+ iStream >> lCount;
+ if(lCount)
+ {
+ lFeatures= new ( ELeave ) CDesCArrayFlat( lCount );
+ }
+ else
+ {
+ lFeatures= new ( ELeave ) CDesCArrayFlat( 1 );
+ }
+
+ CleanupStack::PushL(lFeatures); //cleanup
+
+ for(TInt8 i=0; i<lCount; i++)
+ {
+ lFeatures->AppendL((const TDesC&)DecodeTDesCLC());
+ CleanupStack::PopAndDestroy( 1 );
+ }
+
+ iCurrentElement->CreateSvgTestL(aName); //instantiates iSvgTest
+ if (aName== KAtrRequiredFeatures)
+ {
+ iCurrentElement->SetRequiredFeatures (lFeatures);
+ }
+ else if (aName== KAtrRequiredExtensions)
+ {
+ iCurrentElement->SetRequiredExtensions (lFeatures);
+ }
+ else
+ {
+ iCurrentElement->SetSystemLanguage (lFeatures);
+ }
+
+ CleanupStack::Pop(lFeatures); //cleanup
+
+ return ETrue;
+ }
+
+ else
+ {
+ return EFalse;
+ }
+ }
+
+ else
+ {
+ return EFalse;
+ }
+ }
+
+
+
+
+// --------------------------------------------------------------------------
+// TBool CSvgDecoder::DecodeIdAndXmlAttributeL(const TUint16 aName)
+// ---------------------------------------------------------------------------
+TBool CSvgDecoder::DecodeIdAndXmlAttributeL(const TUint16 aName)
+ {
+
+ if (aName== KAtrId)
+ {
+ iCurrentElement->SetIdandXmlbaseL( _L("id"), DecodeTDesCLC());
+ CleanupStack::PopAndDestroy( 1 );
+ return ETrue;
+ }
+
+ if (aName== KAtrXmlBase)
+ {
+ iCurrentElement->SetIdandXmlbaseL( _L("xml:base"), DecodeTDesCLC());
+ CleanupStack::PopAndDestroy( 1 );
+ return ETrue;
+ }
+
+ else
+ {
+ return EFalse;
+ }
+ }
+
+
+
+
+// --------------------------------------------------------------------------
+// TBool CSvgDecoder::DecodeUriRefAttributeL(const TUint16 aName)
+// ---------------------------------------------------------------------------
+TBool CSvgDecoder::DecodeUriRefAttributeL(const TUint16 aName)
+ {
+ if (aName<= KSvgUriAttrEndIndex)
+ {
+ if (aName== KAtrXlinkhref)
+ {
+ // Although discard element belongs to animation, the discard element isn't
+ // necessary inherited from giant AnimationBase, so handle attribute separately.
+ //
+ if ( iCurrentElement->ElemID() == KSvgDiscardElement || iCurrentElement->ElemID() == KSvgMediaAnimationElement )
+ return EFalse;
+
+ TPtrC lPtr(DecodeTDesCLC());
+ /*Code modified for Forward refrence support in animation*/
+ iCurrentElement->SetUriRefDesL (aName, lPtr );
+ // For Animation Elements
+ if(iIsAnimElement)
+ {
+ CSvgElementImpl* lElement;
+ lElement= (CSvgElementImpl*) iDocument->GetElementById(lPtr);
+ if(lElement)
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetTarget(lElement);
+ }
+ else
+ {
+ if (!iAnimRefElementArray)
+ {
+ iAnimRefElementArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
+ }
+ iAnimRefElementArray->AppendL((CSvgElementImpl*)iCurrentElement);
+ }
+
+ CleanupStack::PopAndDestroy( 1 );
+ return ETrue;
+ }
+
+
+ //Only for Image Element
+ if (iCurrentElement->ElemID() == KSvgImageElement)
+ {
+ ((CSvgImageElementImpl*)iCurrentElement)->SetUriL(lPtr);
+ iImageElements.Append((CSvgImageElementImpl*)iCurrentElement);
+ }
+ CleanupStack::PopAndDestroy( 1 );
+
+ // setting reference element of use Element
+ if (iCurrentElement->ElemID() == KSvgUseElement)
+ {
+ if( ((CSvgUseElementImpl*)iCurrentElement)->SetRefElemById
+ (DecodeTDesCLC()) != KErrNone)
+ {
+ // if it is null reallocate the memeory again.
+ if (!iUseElementArray)
+ {
+ iUseElementArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
+ }
+ iUseElementArray->AppendL((CSvgElementImpl*)iCurrentElement);
+ }
+ CleanupStack::PopAndDestroy( 1 );
+ return ETrue;
+ }
+// for future animation element
+// else if (iCurrentElement->ElemID() == KSvgAnimationElement)
+// {
+// if( ((CSvgAnimationElementImpl*)iCurrentElement)->SetRefElemById
+// (DecodeTDesCLC()) == KErrNone)
+// {
+ // if it is null reallocate the memeory again.
+// if (!iAnimationElementArray)
+// {
+// iAnimationElementArray = new (ELeave)RPointerArray<CSvgElementImpl> (1);
+// }
+// User::LeaveIfError(iAnimationElementArray->Append((CSvgElementImpl*)iCurrentElement));
+// }
+// CleanupStack::PopAndDestroy( 1 );
+// return ETrue;
+// }
+
+ // setting Path of Mpath element
+ if (iCurrentElement->ElemID() == KSvgMpathElement)
+ {
+ iCurrentElement->iReqAttrFlag =0;
+ TInt8 lCheck;
+ iStream >> lCheck;
+ // Flag is used to check the validity of reference element
+ if (lCheck)
+ {
+ ((CSvgMpathElementImpl*)iCurrentElement)->SetAttributePathByIdL(DecodeTDesCLC());
+ CleanupStack::PopAndDestroy( 1 );
+ }
+ }
+
+ return ETrue;
+ }
+
+ else if (aName== KAtrXlinkactuate ||
+ aName== KAtrXlinkarcrole ||
+ aName== KAtrXlinkrole ||
+ aName== KAtrXlinktitle ||
+ aName== KAtrXlinktype ||
+ aName== KAtrXlinkshow
+ )
+ {
+ iCurrentElement->SetUriRefDesL (aName, DecodeTDesCLC() );
+ CleanupStack::PopAndDestroy( 1 );
+ return ETrue;
+ }
+
+ else
+ {
+ return EFalse;
+ }
+ }
+
+ else if (aName== KXlinkhrefImageEmbedded)
+ {
+ TPtrC lPtr(DecodeImageEmbeddedTDesCLC());
+
+ iCurrentElement->SetUriRefDesL (aName, lPtr );
+
+ //Only for Image Element
+ if (iCurrentElement->ElemID() == KSvgImageElement)
+ {
+ // Keep track of embedded images
+ iEmbeddedImagesCount++;
+ ((CSvgImageElementImpl*)iCurrentElement)->SetUriL(lPtr);
+ ((CSvgImageElementImpl*)iCurrentElement)->LoadUriL();
+ }
+ CleanupStack::PopAndDestroy( 2 );
+ return ETrue;
+ }
+ else
+ {
+ return EFalse;
+ }
+ }
+
+
+// --------------------------------------------------------------------------
+// TBool CSvgDecoder::DecodeDiscardAttributeL (const TUint16& aName)
+// ---------------------------------------------------------------------------
+TBool CSvgDecoder::DecodeDiscardAttributeL (const TUint16& aName)
+ {
+ if ( iCurrentElement->ElemID() != KSvgDiscardElement )
+ return EFalse;
+
+ TInt8 lCheck;
+ TInt16 lTemp;
+
+ if (aName== KAtrBegin)
+ {
+ // Flag is used to check for SyncValue flag.
+ iStream >> lCheck;
+ if ( lCheck )
+ {
+ ((CSvgDiscardElementImpl*)iCurrentElement)->SetSyncValueDefined(ETrue);
+ }
+ else
+ {
+ ((CSvgDiscardElementImpl*)iCurrentElement)->SetSyncValueDefined(EFalse);
+ }
+
+ // Flag is used to check for EventValue flag.
+ iStream >> lCheck;
+ if ( lCheck )
+ {
+ ((CSvgDiscardElementImpl*)iCurrentElement)->SetEventValueDefined(ETrue);
+ }
+ else
+ {
+ ((CSvgDiscardElementImpl*)iCurrentElement)->SetEventValueDefined(EFalse);
+ }
+
+
+ // Flag is used to check for SyncElement's id.
+ iStream >> lCheck;
+ if ( lCheck )
+ {
+ TPtrC lPtr(DecodeTDesCLC());
+ ((CSvgDiscardElementImpl*)iCurrentElement)->SetBeginSyncElementId(lPtr);
+ CleanupStack::PopAndDestroy( 1 );
+ }
+
+
+ iStream >> lTemp;
+ ((CSvgDiscardElementImpl*)iCurrentElement)->SetAbsoluteBeginTime(lTemp);
+
+ iStream >> lTemp;
+ ((CSvgDiscardElementImpl*)iCurrentElement)->SetRefBeginTime(lTemp);
+
+ iStream >> lTemp;
+ ((CSvgDiscardElementImpl*)iCurrentElement)->SetKeyValue(lTemp);
+
+ iStream >> lTemp;
+ ((CSvgDiscardElementImpl*)iCurrentElement)->SetBeginReferenceEvent((TSvgEvent)lTemp);
+
+ }
+ else
+ if (aName== KAtrXlinkhref)
+ {
+ // Flag is used to check for HrefValue flag.
+ iStream >> lCheck;
+ if ( lCheck )
+ {
+ ((CSvgDiscardElementImpl*)iCurrentElement)->SetHrefValueDefined(ETrue);
+ TPtrC lPtr(DecodeTDesCLC());
+ ((CSvgDiscardElementImpl*)iCurrentElement)->SetTargetId(lPtr);
+ CleanupStack::PopAndDestroy( 1 );
+ }
+ else
+ ((CSvgDiscardElementImpl*)iCurrentElement)->SetHrefValueDefined(EFalse);
+
+ }
+
+ return ETrue;
+ }
+
+
+
+// --------------------------------------------------------------------------
+// TBool CSvgDecoder::DecodeAttributeFloatL(const TUint16 aName)
+// ---------------------------------------------------------------------------
+TBool CSvgDecoder::DecodeAttributeFloatL(const TUint16 aName)
+ {
+ if (iIsFixPt)
+ {
+ TFloatFixPt lTemp;
+ lTemp.iValue = iStream.ReadInt32L();
+ iCurrentElement->SetAttributeFloatL( (TInt)aName, lTemp );
+ }
+ else
+ {
+ TReal32 lTemp;
+ iStream >> lTemp;
+ iCurrentElement->SetAttributeFloatL( (TInt)aName, (TFloatFixPt)lTemp );
+ }
+
+ return ETrue;
+ }
+
+
+
+// --------------------------------------------------------------------------
+// TBool CSvgDecoder::DecodeAttributeIntL(const TUint16 aName)
+// ---------------------------------------------------------------------------
+TBool CSvgDecoder::DecodeAttributeIntL(const TUint16 aName)
+ {
+ TInt8 lTemp;
+ iStream >> lTemp;
+ iCurrentElement->SetAttributeIntL( (TInt)aName, (TInt32)lTemp );
+ return ETrue;
+ }
+
+
+// --------------------------------------------------------------------------
+// TBool CSvgDecoder::DecodeAttributePathL(const TUint16 aName)
+// ---------------------------------------------------------------------------
+TBool CSvgDecoder::DecodeAttributePathL(const TUint16 aName)
+ {
+ CGfxGeneralPath* lPath;
+ DecodeAnimationPathL(lPath);
+
+ iCurrentElement->SetAttributePathRef( (TInt)aName, lPath);
+
+ return ETrue;
+ }
+
+
+// --------------------------------------------------------------------------
+// void CSvgDecoder::DecodeAnimationPathL(CGfxGeneralPath*& aPath)
+// ---------------------------------------------------------------------------
+void CSvgDecoder::DecodeAnimationPathL(CGfxGeneralPath*& aPath)
+ {
+
+ aPath = CGfxGeneralPath::NewLC();
+
+ {
+ const TInt KLargePathTypeCount = 4*256;
+
+ TUint16 typeCount = 0;
+ iStream >> typeCount;
+
+ /******************************************************************/
+ // Path Type
+ /******************************************************************/
+ RArray<TUint32>* pathTypeArray = NULL;
+ // Put path-type-array to path to handle cleanup
+ if ( typeCount == 0 )
+ {
+ pathTypeArray = new (ELeave)RArray<TUint32>( 1 );
+ aPath->SetPointTypeArrayRef( pathTypeArray );
+ }
+ else
+ {
+ pathTypeArray = new (ELeave)RArray<TUint32>( typeCount );
+ aPath->SetPointTypeArrayRef( pathTypeArray );
+ }
+
+ // Occurs only for very large paths
+ if ( typeCount > KLargePathTypeCount )
+ {
+ TUint8* byteData = new (ELeave) TUint8[typeCount];
+ CleanupArrayDeletePushL( byteData );
+
+ iStream.ReadL( byteData, typeCount );
+
+ for ( TInt i = 0; i < typeCount; i++ )
+ {
+
+ if(byteData[i] == EGfxEncodedSegMoveTo)
+ {
+ byteData[i] = EGfxSegMoveTo;
+ }
+ else if(byteData[i] == EGfxEncodedSegLineTo )
+ {
+ byteData[i] = EGfxSegLineTo;
+ }
+ else if(byteData[i] == EGfxEncodedSegQuadTo)
+ {
+ byteData[i] = EGfxSegQuadTo;
+ }
+ else if(byteData[i] == EGfxEncodedSegCubicTo)
+ {
+ byteData[i] = EGfxSegCubicTo;
+ }
+ else if(byteData[i] == EGfxEncodedSegClose)
+ {
+ byteData[i] = EGfxSegClose;
+ }
+ // Path will close RArray if Leave occurs
+ pathTypeArray->AppendL( byteData[i] );
+ }
+ //Transfering ownership to Path
+ aPath->PathSegmentTypeArray(byteData);
+ aPath->Count(typeCount);
+ CleanupStack::Pop( 1 );
+ //delete [] byteData;
+ }
+ else
+ {
+ TUint8 *byteData = new (ELeave) TUint8[KLargePathTypeCount];
+ CleanupArrayDeletePushL( byteData );
+ iStream.ReadL( byteData, typeCount );
+ for ( TInt i = 0; i < typeCount; i++ )
+ {
+
+ if(byteData[i] == EGfxEncodedSegMoveTo)
+ {
+ byteData[i] = EGfxSegMoveTo;
+ }
+ else if(byteData[i] == EGfxEncodedSegLineTo )
+ {
+ byteData[i] = EGfxSegLineTo;
+ }
+ else if(byteData[i] == EGfxEncodedSegQuadTo)
+ {
+ byteData[i] = EGfxSegQuadTo;
+ }
+ else if(byteData[i] == EGfxEncodedSegCubicTo)
+ {
+ byteData[i] = EGfxSegCubicTo;
+ }
+ else if(byteData[i] == EGfxEncodedSegClose)
+ {
+ byteData[i] = EGfxSegClose;
+ }
+ // Path will close RArray if Leave occurs
+ pathTypeArray->AppendL( byteData[i] );
+ }
+ aPath->PathSegmentTypeArray(byteData);
+ aPath->Count(typeCount);
+ CleanupStack::Pop( 1 );
+ }
+ }
+
+ /******************************************************************/
+ // Path Points
+ /******************************************************************/
+ {
+ const TInt KLargePathPointsCount = 256;
+
+ TUint16 valueCount = 0;
+ iStream >> valueCount;
+
+ RArray<TFloatFixPt>* pathPointsArray = NULL;
+
+ if ( valueCount == 0 )
+ {
+ pathPointsArray = new (ELeave)RArray<TFloatFixPt>( 1 );
+ aPath->SetPointCoordsArrayRef( pathPointsArray );
+ }
+ else
+ {
+ pathPointsArray = new (ELeave)RArray<TFloatFixPt>( valueCount );
+ aPath->SetPointCoordsArrayRef( pathPointsArray );
+ }
+
+ if ( valueCount > KLargePathPointsCount )
+ {
+ if (iIsFixPt)
+ {
+ TFloatFixPt* fixedData = new (ELeave) TFloatFixPt[valueCount];
+ CleanupArrayDeletePushL( fixedData );
+
+ TInt byteCount = sizeof( TFloatFixPt ) * valueCount;
+ iStream.ReadL( (TUint8*)fixedData, byteCount );
+
+ for ( TInt i = 0; i < valueCount; i++ )
+ {
+ // Path will close RArray if Leave occurs
+ pathPointsArray->AppendL( fixedData[i] );
+ }
+
+ CleanupStack::Pop( 1 ); // fixedData
+ delete [] fixedData;
+ }
+ else
+ {
+ TReal32* real32Data = new (ELeave) TReal32[valueCount];
+ CleanupArrayDeletePushL( real32Data );
+
+ TInt byteCount = sizeof( TReal32 ) * valueCount;
+ iStream.ReadL( (TUint8*)real32Data, byteCount );
+
+ for ( TInt i = 0; i < valueCount; i++ )
+ {
+ // Path will close RArray if Leave occurs
+ pathPointsArray->AppendL( (TFloatFixPt)real32Data[i] );
+ }
+
+ CleanupStack::Pop( 1 ); // real32Data
+ delete [] real32Data;
+ }
+ }
+ else
+ {
+ if (iIsFixPt)
+ {
+ TFloatFixPt fixedData[KLargePathPointsCount];
+ TInt byteCount = sizeof( TFloatFixPt ) * valueCount;
+ iStream.ReadL( (TUint8*)fixedData, byteCount );
+
+ for ( TInt i = 0; i < valueCount; i++ )
+ {
+ pathPointsArray->AppendL( fixedData[i] );
+ }
+ }
+ else
+ {
+ TReal32 real32Data[KLargePathPointsCount];
+ TInt byteCount = sizeof( TReal32 ) * valueCount;
+ iStream.ReadL( (TUint8*)real32Data, byteCount );
+
+ for ( TInt i = 0; i < valueCount; i++ )
+ {
+ pathPointsArray->AppendL( (TFloatFixPt)real32Data[i] );
+ }
+ }
+ }
+
+ }
+
+ CleanupStack::Pop( 1 ); // aPath
+ }
+
+
+// --------------------------------------------------------------------------
+// TBool CSvgDecoder::DecodeAttributeDesL(const TUint16 aName)
+// ---------------------------------------------------------------------------
+TBool CSvgDecoder::DecodeAttributeDesL(const TUint16 aName)
+ {
+ iCurrentElement->SetAttributeDesL ((TInt)aName, DecodeTDesCLC());
+ CleanupStack::PopAndDestroy( 1 );
+ return ETrue;
+ }
+
+// --------------------------------------------------------------------------
+// TBool CSvgDecoder::DecodeStringCssValueL(const TUint16 aName)
+// ---------------------------------------------------------------------------
+TBool CSvgDecoder::DecodeStringCssValueL(const TUint16 aName)
+ {
+
+ CCssValue* tParentValue = NULL;
+ CCssValue* tValue = NULL;
+
+ iCurrentElement->FindProperty ((TInt8)aName,tValue);
+
+ TPtrC lPtr(DecodeTDesCLC());
+
+ if(iCurrentElement->ElemID() == KSvgFontfaceElement)
+ {
+ ((CSvgFontFaceElementImpl *)iCurrentElement)->SetFontFamilyL(lPtr);
+ }
+
+ if(iCurrentElement!= iRootElement)
+ {
+ iCurrentParentElement->FindProperty ((TInt8)aName,tParentValue);
+ }
+
+ if (tParentValue == tValue || tValue == NULL)
+ {
+
+ if (iDocument)
+ {
+ tValue = iDocument->iMemoryManager->GetCssStrObjectL( lPtr );
+ }
+
+
+
+ CleanupStack::PopAndDestroy( 1 );// cleanup : for lPtr
+ iCurrentElement->SetPresentationAttribute ((TInt8)aName,tValue);
+ }
+ else
+ {
+ ((CStrCssValueImpl*)tValue)->SetValueL ( lPtr );
+ CleanupStack::PopAndDestroy( 1 );
+ }
+
+ return ETrue;
+ }
+
+
+
+// --------------------------------------------------------------------------
+// TBool CSvgDecoder::DecodeIntCssValueL(const TUint16 aName)
+// ---------------------------------------------------------------------------
+TBool CSvgDecoder::DecodeIntCssValueL(const TUint16 aName)
+ {
+
+ TInt32 lInt32;
+ iStream >> lInt32;
+
+ CCssValue* tParentValue = NULL;
+ CCssValue* tValue = NULL;
+
+ iCurrentElement->FindProperty ((TInt8)aName,tValue);
+
+ if(iCurrentElement!= iRootElement)
+ {
+ iCurrentParentElement->FindProperty ((TInt8)aName,tParentValue);
+ }
+
+ if (tParentValue == tValue || tValue == NULL)
+ {
+
+ if (iDocument)
+ {
+ tValue = iDocument->iMemoryManager->GetCssIntObjectL( (TInt)lInt32 );
+ }
+
+ iCurrentElement->SetPresentationAttribute ((TInt8)aName,tValue);
+ }
+ else
+ {
+ ((CIntCssValueImpl*)tValue)->SetValueL ((TInt)lInt32);
+ }
+
+ return ETrue;
+ }
+
+
+// --------------------------------------------------------------------------
+// TBool CSvgDecoder::DecodeFloatCssValueL(const TUint16 aName)
+// ---------------------------------------------------------------------------
+TBool CSvgDecoder::DecodeFloatCssValueL(const TUint16 aName)
+ {
+
+ if (iIsFixPt)
+ {
+ TFloatFixPt lFixed;
+ lFixed.iValue = iStream.ReadInt32L();
+
+ CCssValue* tParentValue = NULL;
+ CCssValue* tValue = NULL;
+
+ iCurrentElement->FindProperty ((TInt8)aName,tValue);
+
+ if(iCurrentElement!= iRootElement)
+ {
+ iCurrentParentElement->FindProperty ((TInt8)aName,tParentValue);
+ }
+
+ if (tParentValue == tValue || tValue == NULL)
+ {
+ if (iDocument)
+ {
+ tValue = iDocument->iMemoryManager->GetCssFloatObjectL( lFixed );
+ }
+
+ iCurrentElement->SetPresentationAttribute ((TInt8)aName,tValue);
+ }
+ else
+ {
+ ((CFloatCssValueImpl*)tValue)->SetValueL ( lFixed );
+ }
+ }
+ else
+ {
+ TReal32 lFlt32;
+ iStream >> lFlt32;
+
+ CCssValue* tParentValue = NULL;
+ CCssValue* tValue = NULL;
+
+ iCurrentElement->FindProperty ((TInt8)aName,tValue);
+
+ if(iCurrentElement!= iRootElement)
+ {
+ iCurrentParentElement->FindProperty ((TInt8)aName,tParentValue);
+ }
+
+ if (tParentValue == tValue || tValue == NULL)
+ {
+ if (iDocument)
+ {
+ tValue = iDocument->iMemoryManager->GetCssFloatObjectL((TFloatFixPt)lFlt32);
+ }
+
+ iCurrentElement->SetPresentationAttribute ((TInt8)aName,tValue);
+ }
+ else
+ {
+ ((CFloatCssValueImpl*)tValue)->SetValueL ((TFloatFixPt)lFlt32);
+ }
+ }
+
+ return ETrue;
+ }
+
+
+// --------------------------------------------------------------------------
+// TBool CSvgDecoder::DecodeColorCssValueL(const TUint16 aName)
+// ---------------------------------------------------------------------------
+TBool CSvgDecoder::DecodeColorCssValueL(const TUint16 aName)
+ {
+ TUint32 lColor;
+ iStream >> lColor;
+
+ // Shift from XBGR to XRGB
+ if(!iIsRGB)
+ {
+ lColor = ( lColor & 0xFF000000) |
+ ( (lColor & 0x00FF0000) >> 16 ) |
+ ( lColor & 0x0000FF00 ) |
+ ( (lColor & 0x000000FF) << 16 );
+ }
+
+ CCssValue* tParentValue = NULL;
+ CCssValue* tValue = NULL;
+
+ iCurrentElement->FindProperty ((TInt8)aName,tValue);
+
+ if(iCurrentElement!= iRootElement)
+ {
+ iCurrentParentElement->FindProperty ((TInt8)aName,tParentValue);
+ }
+
+ if (tParentValue == tValue || tValue == NULL)
+ {
+ if ( iDocument )
+ {
+ tValue = iDocument->iMemoryManager->GetCssClrObjectL();
+
+ CleanupStack::PushL(tValue); //cleanup
+
+ ((CClrCssValueImpl*)tValue)->CloneRGBValueL (lColor);
+ iCurrentElement->SetPresentationAttribute ((TInt8)aName,tValue);
+ CleanupStack::Pop(tValue); //cleanup
+ }
+ }
+ else
+ {
+ ((CClrCssValueImpl*)tValue)->CloneRGBValueL (lColor);
+ }
+
+ return ETrue;
+ }
+
+
+
+// --------------------------------------------------------------------------
+// void CSvgDecoder::SetPaintValueL (CCssValue*& aValue)
+// ---------------------------------------------------------------------------
+void CSvgDecoder::SetPaintValueL (CCssValue*& aValue)
+ {
+ TUint8 lCheckGradient;
+ iStream >> lCheckGradient;
+
+ if( lCheckGradient)
+ {
+ ((CPaintCssValueImpl *)aValue)->SetUrlflag();
+ ((CPaintCssValueImpl *)aValue)->SetUrlIdL( DecodeTDesCLC() );
+ CleanupStack::PopAndDestroy( 1 );
+ }
+ else
+ {
+ TUint32 lColor;
+ iStream >> lColor;
+ // Shift from XBGR to ARGB
+ if(!iIsRGB)
+ {
+ lColor = ( lColor & 0xFF000000) |
+ ( (lColor & 0x00FF0000) >> 16 ) |
+ ( lColor & 0x0000FF00 ) |
+ ( (lColor & 0x000000FF) << 16 );
+ }
+ ((CPaintCssValueImpl *)aValue)->CloneRGBValueL (lColor);
+ }
+ }
+
+
+
+
+
+// ==========================================================================
+// Start Decoding
+// ==========================================================================
+CSvgElementImpl* CSvgDecoder::StartDecodingL(CSvgDocumentImpl *aDocument,
+ CSvgErrorImpl& aError )
+ {
+
+ iDocument= aDocument;
+
+ iSvgError = &aError;
+ aError.SetErrorCode( ESvgNoError );
+
+ TUint32 lValidBinary;
+ iStream >> lValidBinary;
+
+ if (lValidBinary != KBinaryFile &&
+ lValidBinary != KBinaryFile2 &&
+ lValidBinary != KBinaryFile3 &&
+ lValidBinary != KBinaryFile4)
+ {
+ iSvgError->SetErrorCode ( ESvgbFileNotValid );
+ iSvgError->SetDescription( _L( "Not a valid binary file." ) );
+ iSvgError->SetIsWarning( EFalse );
+ return NULL;
+ }
+
+ if (lValidBinary == KBinaryFile2)
+ {
+ iIsFixPt = ETrue;
+ iIsRGB = EFalse;
+ }
+
+ if (lValidBinary == KBinaryFile3)
+ {
+ iIsFixPt = ETrue;
+ iIsRGB = ETrue;
+ }
+
+ if(lValidBinary == KBinaryFile4)
+ {
+ iIsFixPt = EFalse;
+ iIsRGB = ETrue;
+ }
+
+ TUint8 lElemId;
+ TUint16 lAttrName;
+
+ MXmlElement* newElement;
+
+ iStream >> lElemId;
+ while (lElemId != KEndSvgFile)
+ {
+
+ // checks end of element
+ while (lElemId==KEndElemIndex)
+ {
+ if ( iCurrentParentElement != iRootElement )
+ {
+ // Depth is decreased, so the current parent should be one level up
+ iCurrentParentElement = ( CSvgElementImpl * )
+ iCurrentParentElement->ParentNode();
+ }
+
+ iStream >> lElemId;
+ }
+
+ // checks for Cdata
+ if (lElemId == KCDataPresent)
+ {
+ iCurrentElement= iCurrentParentElement;
+ DecodeAttributeL((TUint16)KAtrCdata);
+ iStream >> lElemId;
+ continue;
+ }
+
+
+
+ //checks end of file.
+ if (lElemId == KEndSvgFile)
+ {
+ break;
+ }
+
+
+ newElement = iDocument->CreateElementL( lElemId );
+
+ if( newElement == NULL)
+ {
+ User::Leave(KErrCorrupt);
+ }
+
+ iCurrentElement = ( CSvgElementImpl * ) newElement;
+
+
+ if ( lElemId == KSvgSvgElement && !iRootElement )
+ {
+ iRootElement = iCurrentElement;
+
+ //CleanupStack::PushL(iRootElement);
+ iDocument->AppendChildL( newElement );
+ //CleanupStack::Pop(iRootElement);
+
+ }
+ // for all other elements
+ else
+ {
+ iCurrentParentElement->AppendChildL( newElement );
+ }
+
+ // Setting target element for animations
+ if( iCurrentElement->IsAnimatedElement() )
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetTarget( iCurrentParentElement);
+ // For media elements do not set iIsAnimElement as
+ // the Xlink:Href is for external files rather
+ // than internal elements
+ if (!( iCurrentElement->ElemID() >= KSvgMediaElemsStartIndex &&
+ iCurrentElement->ElemID() <= KSvgMediaElemsEndIndex ) )
+ {
+ iIsAnimElement= ETrue;
+ }
+ }
+
+
+ iStream >> lAttrName;
+
+ // for attribute list.
+ while (lAttrName!= KStartNewElem)
+ {
+ DecodeAttributeL(lAttrName);
+ iStream >> lAttrName;
+ }
+ if( iCurrentElement->ElemID() == KSvgStopElement)
+ {
+ if( ((CSvgElementImpl*)iCurrentElement->ParentNode()) != NULL )
+ {
+ if((((((CSvgElementImpl*)iCurrentElement->ParentNode())->ElemID()) == KSvgRadialGradientElement) ||
+ ((((CSvgElementImpl*)iCurrentElement->ParentNode())->ElemID()) == KSvgLinearGradientElement) ) )
+ {
+ CSvgGradientElementImpl *parent = ((CSvgGradientElementImpl *)iCurrentElement->ParentNode());
+
+ if(parent)
+ {
+ // Initialize the offset value to 0 if its still -1.
+ TFloatFixPt lOffsetValue;
+ TFloatFixPt lDefaultOffsetValue(-1);
+ TBuf<6> lAttributeName;
+ TBuf<1> lValueBuffer;
+
+ lAttributeName.Append(OFFSET);
+ lValueBuffer.Append(ZEROVALUE);
+
+ ((CSvgStopElementImpl*)iCurrentElement)->GetOffset( lOffsetValue );
+
+ // Offset Value of -1 indicates that Offset Attribute is not declared in
+ // stop element.
+ if( lOffsetValue == lDefaultOffsetValue )
+ {
+ // Deliberately calling SetAttributeL in place of SetAttributeFloatL as the latter inturn
+ // calls UpdateOffsetValues which should be called on any Stop element once it is added to
+ // to the Stop element array Owned by parent Gradient element.
+ ((CSvgStopElementImpl*)iCurrentElement)->SetAttributeL( lAttributeName, lValueBuffer );
+ }
+
+ // The function not only adds the element in Stop element array but also
+ // adjusts the offset values of all the previously added elements such that
+ // each gradient offset value is greater than the previous gradient stop's
+ // offset value.It calls UpdateOffsetValues to adjust the values.
+ ((CSvgGradientElementImpl *)parent)->AddStopElementInArray((CSvgStopElementImpl*)iCurrentElement);
+ }
+ }
+ }
+ }
+
+
+ if (iCurrentElement->ElemID() == KSvgUseElement)
+ {
+ ((CSvgUseElementImpl *)iCurrentElement)->SetReferenceElementL();
+ }
+/* else if (iCurrentElement->ElemID() == KSvgAnimationElement)
+ {
+ ((CSvgAnimationElementImpl *)iCurrentElement)->SetReferenceElementL();
+ if(((CSvgAnimationElementImpl *)iCurrentElement)->RecursionVariable())
+ {
+ iSvgError->SetErrorCode( ESvgDocumentNotValid );
+ iSvgError->SetIsWarning( EFalse );
+ iSvgError->SetDescription( _L( "Invalid Document \n" ) );
+ iSvgError->AppendDescription( _L("Animation element in loop") );
+ return iRootElement;
+ }
+ }
+*/
+ if (iCurrentElement->HasAnyTests())
+ {
+ iReqFetAttSysArray->AppendL(iCurrentElement);
+ }
+
+ if (iCurrentElement->ElemID() == KSvgSwitchElement)
+ {
+ iSwitchElementArray->AppendL(iCurrentElement);
+ }
+
+ // For DOM reuse
+ if( iCurrentElement->IsAnimatedElement() )
+ {
+ ((CSvgAnimationBase*)iCurrentElement)->SetOriginalValues_DOMReuse() ;
+ iAnimationElementArray->AppendL(iCurrentElement);
+ }
+
+
+ if( iCurrentElement->ElemID() >= KSvgLinearGradientElement &&
+ iCurrentElement->ElemID() <= KSvgStopElement )
+ {
+ iCurrentElement->SetAttributeIntL(KCSS_ATTR_DISPLAY,0);
+ }
+
+ if ( iCurrentElement->ElemID() == KSvgMpathElement &&
+ iCurrentParentElement->ElemID() == KSvgAnimateMotionElement &&
+ iSvgError->ErrorCode() == ESvgMissingRequiredAttribute &&
+ iSvgError->IsWarning()
+ )
+
+
+ {
+ iSvgError->SetErrorCode( ESvgNoError );
+ // add to event receiver list will have only one copy
+ iDocument->AddToEventReceiverListL( iCurrentParentElement, KSvgEventMaskTimer );
+ }
+
+ CheckRequiredAttributesL( lElemId);
+ iIsAnimElement= EFalse;
+
+ iCurrentParentElement = iCurrentElement;
+
+ iStream >> lElemId;
+
+ }
+ //Load Images
+
+ TInt lImageElementCnt = iImageElements.Count();
+ TInt lTotalImagesCount = lImageElementCnt + iEmbeddedImagesCount;
+ iDocument->SetImageElementsCount(lTotalImagesCount);
+ for( TInt index = 0 ; index < lImageElementCnt ; index++)
+ {
+ iImageElements[index]->LoadUriL();
+ }
+
+ if(iUseElementArray)
+ {
+ // support for forward reference in use element
+ TInt lCount = iUseElementArray->Count();
+ TInt lIndex= 0;
+ while(lIndex < lCount)
+ {
+ TPtrC tPtr2 = ((CSvgElementImpl*)iUseElementArray->operator[](lIndex))->Href();
+ TInt Pos1= tPtr2.Locate('#');
+ HBufC* tBufC = HBufC::NewLC( tPtr2.Length() );
+ TPtr tPtr3 ( tBufC->Des() );
+ tPtr3.Copy( tPtr2 );
+ tPtr3.TrimAll();
+ // remove '#'
+ if(Pos1 != KErrNotFound)
+ {
+ tPtr3.Delete(Pos1,1);
+ }
+ if(((CSvgUseElementImpl *)iUseElementArray->operator[](lIndex))->SetRefElemById(tPtr3) != KErrNotFound)
+ {
+ ((CSvgUseElementImpl *)iUseElementArray->operator[](lIndex))->SetReferenceElementL();
+
+ }
+ lIndex++;
+ CleanupStack::PopAndDestroy( 1 );
+ }
+ }
+ // support for forward reference in use element
+ if(iAnimRefElementArray)
+ {
+ TInt lCount = iAnimRefElementArray->Count();
+ TInt lIndex= 0;
+ while(lIndex < lCount)
+ {
+ TPtrC tPtr2 = ((CSvgElementImpl*)iAnimRefElementArray->operator[](lIndex))->Href();
+ ((CSvgAnimationBase *)iAnimRefElementArray->operator[](lIndex))->SetRefElemById(tPtr2);
+ lIndex++;
+ }
+ }
+
+ // For Animation elements
+ if (iAnimationElementArray)
+ {
+ TInt lCount = iAnimationElementArray->Count();
+ TInt lIndex = 0;
+ while(lIndex < lCount)
+ {
+ ((CSvgAnimationBase *)iAnimationElementArray->operator[](lIndex))->CheckBeginTime();
+ lIndex ++;
+ }
+ }
+ // Reset iCurrentElement, as it is no longer used
+ iCurrentElement = NULL;
+ RemoveFalseElements();
+ RemoveFalseSwitchCases();
+
+ return iRootElement;
+ }
+
+
+
+// --------------------------------------------------------------------------
+// void CSvgDecoder::CheckRequiredAttributesL(const TUint8 aName )
+// ---------------------------------------------------------------------------
+void CSvgDecoder::CheckRequiredAttributesL(const TUint8 aName )
+ {
+
+
+ if( iCurrentElement->iReqAttrFlag != 0)
+
+ {
+
+ iSvgError->SetErrorCode( ESvgMissingRequiredAttribute );
+ iSvgError->SetIsWarning( ETrue );
+ iSvgError->SetDescription( _L( "Missing required attribute \"" ) );
+ switch(iCurrentElement->iReqAttrFlag)
+ {
+ case KSVG_PATH_ELEMFLAG:
+ iSvgError->AppendDescription( _L("d") );
+ break;
+ case KAtrWidth:
+ iSvgError->AppendDescription( _L("width") );
+ break;
+ case KAtrHeight:
+ iSvgError->AppendDescription( _L("height") );
+ break;
+ case KSVG_POLYLINE_ELEMFLAG:
+ iSvgError->AppendDescription( _L("points") );
+ break;
+ case KAtrRy:
+ iSvgError->AppendDescription( _L("Ry") );
+ break;
+ case KAtrRx:
+ iSvgError->AppendDescription( _L("Rx") );
+ break;
+ case KAtrSVGRec:
+ iSvgError->AppendDescription( _L("width") );
+ iSvgError->AppendDescription( _L( "\" and \"" ) );
+ iSvgError->AppendDescription(_L("height"));
+ break;
+ case KAtrSVGElp:
+ iSvgError->AppendDescription( _L("Rx") );
+ iSvgError->AppendDescription( _L( "\" and \"" ) );
+ iSvgError->AppendDescription(_L("Ry"));
+ break;
+ case KAtrSVGTrf:
+ iSvgError->AppendDescription( _L("attributeName") );
+ iSvgError->AppendDescription( _L( "\" and \"" ) );
+ iSvgError->AppendDescription(_L("type"));
+ break;
+ case KSVG_ANIMATE_ELEMFLAG:
+ iSvgError->AppendDescription( _L("attributeName") );
+ break;
+ case KSVG_CIRCLE_ELEMFLAG:
+ iSvgError->AppendDescription( _L("r") );
+ break;
+ case KSVG_HKERN_ELEMFLAG:
+ iSvgError->AppendDescription( _L("k") );
+ break;
+ case KAtrType:
+ iSvgError->AppendDescription( _L("type") );
+ break;
+ case KAtrXlinkhref:
+ iSvgError->AppendDescription (_L("Xlink:href"));
+ break;
+ case KAtrSVGAmo:
+ iSvgError->AppendDescription( _L("path") );
+ ((CSvgDocumentImpl*)iDocument)->RemoveFromEventReceiverList( iCurrentElement );
+ break;
+ case KAtrToBy:
+ iSvgError->AppendDescription( _L("to/by") );
+ ((CSvgDocumentImpl*)iDocument)->RemoveFromEventReceiverList( iCurrentElement );
+ break;
+ }
+ iSvgError->AppendDescription( _L( "\" for <" ) );
+ // access schema data to get the name of the attribute which is missing
+ // currently the error msg doesnt not report the name of the attribute
+
+ TBuf<20> lElemName = _L("svg");
+ ((CSvgDocumentImpl*)iDocument)->SchemaData()->GetSVGElementName(aName,lElemName);
+ iSvgError->AppendDescription( lElemName );
+ iSvgError->AppendDescription( _L( ">." ) );
+ // turn off element
+
+ ((CSvgElementImpl*)iCurrentElement)->SetTurnOff( ETrue );
+
+ ((CSvgElementImpl*)iCurrentElement)->SetPropertyL(KCSS_ATTR_DISPLAY,_L("none"));
+
+
+ }
+ }
+
+//---------------------------------------------------
+//Removal of elements that dont pass
+//required extensions, required features, and system language
+//requirements
+//switch statement is special case were only the first one
+//that passes these requirements will be used so toss the rest
+//---------------------------------------------------
+void CSvgDecoder::RemoveFalseElements()
+ {
+ if (iReqFetAttSysArray == NULL)
+ {
+ // Error Case
+ return;
+ }
+
+ //loop through the list of elements with required features, attributes, or sys language
+ TInt reqFetSysArrayCnt = iReqFetAttSysArray->Count();
+ while ( reqFetSysArrayCnt > 0 )
+ {
+ CSvgElementImpl* lCurElement = ( CSvgElementImpl* )
+ iReqFetAttSysArray->operator[]( reqFetSysArrayCnt - 1 );
+
+ if ( lCurElement != NULL )
+ {
+ CSvgElementImpl* lCurParent = ( CSvgElementImpl* )
+ lCurElement->ParentNode();
+
+ //just a normal element check it and remove it if it doesnt pass
+ TBool lResult = EFalse;
+ TRAPD( error, lResult = VerifyReqExReqFtrSysL( lCurElement ) );
+ if ( error == KErrNone && !lResult )
+ {
+ // Remove internal references to the element about to be
+ // removed
+ // This function would also remove the lCurElement from
+ // iReqFetAttSysArray.
+ RemoveInternalReferences( lCurElement );
+ //element doesnt have proper required extension, attributes, or system language
+ lCurParent->RemoveChild( lCurElement );
+ delete (CXmlElementImpl*)lCurElement;
+ lCurElement = NULL;
+ }
+ else
+ {
+ // Remove the last element from the array as it is processed
+ iReqFetAttSysArray->Remove( reqFetSysArrayCnt - 1 );
+ } // if ( error == KErrNone && !lResult )
+ }
+ else
+ {
+ // Remove the last element from the array as it is processed
+ iReqFetAttSysArray->Remove( reqFetSysArrayCnt - 1 );
+ } // if ( lCurElement != NULL )
+ // Update the count of elements in the array
+ reqFetSysArrayCnt = iReqFetAttSysArray->Count();
+ } // while ( reqFetSysArrayCnt > 0 )
+ // Clear the array as it is no longer required.
+ iReqFetAttSysArray->Reset();
+ }
+
+// --------------------------------------------------------------------------
+// void CSvgDecoder::RemoveFalseSwitchCases()
+// ---------------------------------------------------------------------------
+void CSvgDecoder::RemoveFalseSwitchCases()
+ {
+ if (iSwitchElementArray == NULL)
+ {
+ // Error Case
+ return;
+ }
+
+ TInt switchEleArrayCnt = iSwitchElementArray->Count();
+ while ( switchEleArrayCnt > 0 )
+ {
+ TBool foundTrue = EFalse;
+ CSvgElementImpl* curSwitchElem = ( CSvgElementImpl* )
+ iSwitchElementArray->operator[]( switchEleArrayCnt - 1 );
+
+ if ( curSwitchElem != NULL )
+ {
+ //get the first child...which is where the first
+ CSvgElementImpl* curCaseElem = (CSvgElementImpl*)curSwitchElem->FirstChild();
+
+ while ( curCaseElem != NULL )
+ {
+ CSvgElementImpl* nextCaseElem = (CSvgElementImpl*)curCaseElem->NextSibling();
+ // foundTrue is set to TRUE when an element whose test passes is found. The
+ // subsequent elements are to be removed.
+ if ( foundTrue )
+ {
+ // Remove internal references of the element from
+ // decoder's lists
+ RemoveInternalReferences( curCaseElem );
+ //already found the true case in the switch delete the rest
+ curSwitchElem->RemoveChild( curCaseElem );
+ delete ( CXmlElementImpl* )curCaseElem;
+ curCaseElem = NULL;
+ }
+ else
+ {
+ TBool lResult = EFalse;
+ TRAPD(error, lResult = VerifyReqExReqFtrSysL(curCaseElem));
+ if ( error == KErrNone && !lResult )
+ {
+ // Remove internal references of the element from
+ // decoder's lists
+ RemoveInternalReferences( curCaseElem );
+ //this element doesnt meet the switch requirements delete it and its children
+ curSwitchElem->RemoveChild(curCaseElem);
+ delete (CXmlElementImpl*)curCaseElem;
+ curCaseElem = NULL;
+ }
+ else
+ {
+ //one evaluated to true so keep it but go ahead and delete the rest in the switch
+ //should only be one child for switch in end
+ foundTrue = ETrue;
+ } // if ( error == KErrNone && !lResult )
+ } // if ( foundTrue )
+ // Proceed checking the next sibling
+ curCaseElem = nextCaseElem;
+ } // while ( curCaseElem != NULL )
+ } // if ( curSwitchElem != NULL )
+ // Remove the last switch element which was processed
+ iSwitchElementArray->Remove( switchEleArrayCnt - 1 );
+ // Update the count of the array
+ switchEleArrayCnt = iSwitchElementArray->Count();
+ } // while ( switchEleArrayCnt > 0 )
+ // Clear the array as it is no longer needed
+ iSwitchElementArray->Reset();
+ }
+
+//---------------------------------------------------
+//Check to see
+//required extensions, required features, and system language
+//requirements
+//---------------------------------------------------
+TBool CSvgDecoder::VerifyReqExReqFtrSysL( CSvgElementImpl* aElement )
+{
+ const CDesCArrayFlat* tempTestArray = NULL; // 'const' keyword added due to S60 (CW) build team recommendation
+
+ TBool doDraw = ETrue;
+
+ // First check for requiredExtensions
+ aElement->GetRequiredExtensions( tempTestArray );
+
+ if ( tempTestArray && tempTestArray->MdcaCount() )
+ {
+ // Check for all entries in requiredExtensions
+
+ TInt lCount = tempTestArray->MdcaCount();
+
+ for ( TInt i = 0; i < lCount; i++ )
+ {
+ TPtrC tmpPtr = tempTestArray->MdcaPoint( i );
+ if ( tmpPtr.Length() )
+ {
+ doDraw = EFalse;
+ break;
+ }
+ else if ( aElement->HasExtension( tmpPtr ) == EFalse )
+ {
+ doDraw = EFalse;
+ break;
+ }
+ }
+ }
+
+ // Second, check for requiredFeatures
+ aElement->GetRequiredFeatures( tempTestArray );
+ if ( tempTestArray && tempTestArray->MdcaCount() && doDraw)
+ {
+ // Check for all entries in requiredFeatures
+ TInt lCount = tempTestArray->MdcaCount();
+ for ( TInt i = 0; i < lCount; i++ )
+ {
+ TPtrC tmpPtr = tempTestArray->MdcaPoint( i );
+ if ( aElement->HasFeature( tmpPtr ) == EFalse )
+ {
+ doDraw = EFalse;
+ break;
+ }
+ }
+ }
+
+ TBufC<5> iSystemLanguage;
+ SystemLanguage( iSystemLanguage.Des() );
+
+ // Third, check for systemLanguage
+ // Future enhancement: System language doesnt need to be stored in seperate array indexes
+ // could have just stored it as one big string and use findf without the loop
+ aElement->GetSystemLanguage( tempTestArray );
+ TBool doDrawSystem = EFalse;
+ if ( tempTestArray && tempTestArray->MdcaCount() && doDraw)
+ {
+ TInt lCount = tempTestArray->MdcaCount();
+
+ for ( TInt i = 0; i < lCount; i++ )
+ {
+ TPtrC tmpPtr = tempTestArray->MdcaPoint( i );
+
+ if ( tmpPtr.FindF( iSystemLanguage ) >= 0 )
+ {
+ doDrawSystem = ETrue;
+ break;
+ }
+ }
+
+ if (doDrawSystem == EFalse)
+ {
+ doDraw = EFalse;
+ }
+ }
+
+ return doDraw;
+}
+
+// --------------------------------------------------------------------------
+// void CSvgDecoder::SystemLanguage( TPtr aValue )
+// ---------------------------------------------------------------------------
+void CSvgDecoder::SystemLanguage( TPtr aValue )
+ {
+ _LIT( KEn, "en" );
+ _LIT( KFr, "fr" );
+ _LIT( KDe, "de" );
+ _LIT( KEs, "es" );
+
+ _LIT( KAf, "af" );
+ _LIT( KAm, "am" );
+ _LIT( KAr, "ar" );
+ _LIT( KBg, "bg" );
+ _LIT( KBn, "bn" );
+ _LIT( KBo, "bo" );
+ _LIT( KCa, "ca" );
+ _LIT( KCs, "cs" );
+ _LIT( KCy, "cy" );
+ _LIT( KDa, "da" );
+ _LIT( KEl, "el" );
+ _LIT( KEt, "et" );
+ _LIT( KFa, "fa" );
+ _LIT( KFi, "fi" );
+ _LIT( KGa, "ga" );
+ _LIT( KGd, "gd" );
+ _LIT( KGu, "gu" );
+ _LIT( KHe, "he" );
+ _LIT( KHi, "hi" );
+ _LIT( KHu, "hu" );
+ _LIT( KHr, "hr" );
+ _LIT( KHy, "hy" );
+ _LIT( KId, "id" );
+ _LIT( KIs, "is" );
+ _LIT( KIt, "it" );
+ _LIT( KJa, "ja" );
+ _LIT( KKa, "ka" );
+ _LIT( KKk, "kk" );
+ _LIT( KKm, "km" );
+ _LIT( KKn, "kn" );
+ _LIT( KKo, "ko" );
+ _LIT( KLo, "lo" );
+ _LIT( KLt, "lt" );
+ _LIT( KLv, "lv" );
+ _LIT( KMk, "mk" );
+ _LIT( KMl, "ml" );
+ _LIT( KMn, "mn" );
+ _LIT( KMo, "mo" );
+ _LIT( KMr, "mr" );
+ _LIT( KMs, "ms" );
+ _LIT( KMy, "my" );
+ _LIT( KNo, "no" );
+ _LIT( KNl, "nl" );
+ _LIT( KPa, "pa" );
+ _LIT( KPl, "pl" );
+ _LIT( KPt, "pt" );
+ _LIT( KRo, "ro" );
+ _LIT( KRu, "ru" );
+ _LIT( KSi, "si" );
+ _LIT( KSk, "sk" );
+ _LIT( KSl, "sl" );
+ _LIT( KSo, "so" );
+ _LIT( KSr, "sr" );
+ _LIT( KSq, "sq" );
+ _LIT( KSv, "sv" );
+ _LIT( KSw, "sw" );
+ _LIT( KTa, "ta" );
+ _LIT( KTe, "te" );
+ _LIT( KTh, "th" );
+ _LIT( KTi, "ti" );
+ _LIT( KTk, "tk" );
+ _LIT( KTl, "tl" );
+ _LIT( KTr, "tr" );
+ _LIT( KUk, "uk" );
+ _LIT( KUr, "ur" );
+ _LIT( KVi, "vi" );
+ //_LIT( KZh, "zh" );
+ _LIT( KZu, "zu" );
+
+ _LIT( KEnB, "en-UK");
+ _LIT( KEnUS, "en-US");
+ _LIT( KZhTW, "zh-TW");
+ _LIT( KZhHK, "zh-HK");
+ _LIT( KZhCN, "zh-CN");
+ _LIT( KFrCA, "fr-CA");
+ _LIT( KPtBR, "pt-BR");
+ _LIT( KEnTW, "en-TW");
+ _LIT( KEnHK, "en-HK");
+ _LIT( KEnCN, "en-CN");
+ _LIT( KEnJP, "en-JP");
+ _LIT( KEnTH, "en-TH");
+ _LIT( KEsAR, "es-AR");
+ _LIT( KMsAP, "ms-AP");
+ _LIT( KEnAP, "en-AP" ); // KLangApacEnglish
+ _LIT( KIdAP, "id-AP" ); // KLangApacIndonesian
+ _LIT( KEu, "eu" ); // KLangBasque
+ _LIT( KGl, "gl" ); // KLangGalician
+
+ _LIT(KDefault, "qqqqq");
+
+ switch ( User::Language() )
+ {
+ case ELangTest:
+ aValue = KEn;
+ break;
+
+ case ELangEnglish:
+ aValue = KEnB;
+ break;
+ case ELangAmerican:
+ aValue = KEnUS;
+ break;
+ case ELangAustralian:
+ case ELangNewZealand:
+ case ELangCanadianEnglish:
+ case ELangSouthAfricanEnglish:
+ case ELangInternationalEnglish:
+ aValue = KEn;
+ break;
+
+ case ELangFrench:
+ case ELangSwissFrench:
+ case ELangBelgianFrench:
+ aValue = KFr;
+ break;
+
+ case ELangGerman:
+ case ELangAustrian:
+ case ELangSwissGerman:
+ aValue = KDe;
+ break;
+
+ case ELangSpanish:
+ case ELangInternationalSpanish:
+ aValue = KEs;
+ break;
+
+ case ELangLatinAmericanSpanish:
+ aValue = KEsAR;
+ break;
+
+ case ELangItalian:
+ case ELangSwissItalian:
+ aValue = KIt;
+ break;
+
+ case ELangSwedish:
+ case ELangFinlandSwedish:
+ aValue = KSv;
+ break;
+
+ case ELangDanish:
+ aValue = KDa;
+ break;
+
+ case ELangNorwegian:
+ case ELangNorwegianNynorsk:
+ aValue = KNo;
+ break;
+
+ case ELangFinnish:
+ aValue = KFi;
+ break;
+
+ case ELangBrazilianPortuguese:
+ aValue = KPtBR;
+ break;
+
+ case ELangPortuguese:
+ aValue = KPt;
+ break;
+
+ case ELangTurkish:
+ case ELangCyprusTurkish:
+ aValue = KTr;
+ break;
+
+ case ELangIcelandic:
+ aValue = KIs;
+ break;
+
+ case ELangRussian:
+ case ELangBelarussian:
+ aValue = KRu;
+ break;
+
+ case ELangHungarian:
+ aValue = KHu;
+ break;
+
+ case ELangDutch:
+ case ELangBelgianFlemish:
+ aValue = KNl;
+ break;
+
+ case ELangCzech:
+ aValue = KCs;
+ break;
+
+ case ELangSlovak:
+ aValue = KSk;
+ break;
+
+ case ELangPolish:
+ aValue = KPl;
+ break;
+
+ case ELangSlovenian:
+ aValue = KSl;
+ break;
+
+ case ELangPrcChinese:
+ aValue = KZhCN;
+ break;
+ case ELangTaiwanChinese:
+ aValue = KZhTW;
+ break;
+ case ELangHongKongChinese:
+ aValue = KZhHK;
+ break;
+
+ case ELangJapanese:
+ aValue = KJa;
+ break;
+
+ case ELangThai:
+ aValue = KTh;
+ break;
+
+ case ELangAfrikaans:
+ aValue = KAf;
+ break;
+
+ case ELangAlbanian:
+ aValue = KSq;
+ break;
+
+ case ELangAmharic:
+ aValue = KAm;
+ break;
+
+ case ELangArabic:
+ aValue = KAr;
+ break;
+
+ case ELangArmenian:
+ aValue = KHy;
+ break;
+
+ case ELangTagalog:
+ aValue = KTl;
+ break;
+
+ case ELangBengali:
+ aValue = KBn;
+ break;
+
+ case ELangBulgarian:
+ aValue = KBg;
+ break;
+
+ case ELangBurmese:
+ aValue = KMy;
+ break;
+
+ case ELangCatalan:
+ aValue = KCa;
+ break;
+
+ case ELangCroatian:
+ aValue = KHr;
+ break;
+
+ case ELangEstonian:
+ aValue = KEt;
+ break;
+
+ case ELangFarsi:
+ aValue = KFa;
+ break;
+
+ case ELangCanadianFrench:
+ aValue = KFrCA;
+ break;
+
+ case ELangScotsGaelic:
+ aValue = KGd;
+ break;
+
+ case ELangGeorgian:
+ aValue = KKa;
+ break;
+
+ case ELangGreek:
+ case ELangCyprusGreek:
+ aValue = KEl;
+ break;
+
+ case ELangGujarati:
+ aValue = KGu;
+ break;
+
+ case ELangHebrew:
+ aValue = KHe;
+ break;
+
+ case ELangHindi:
+ aValue = KHi;
+ break;
+
+ case ELangIndonesian:
+ aValue = KId;
+ break;
+
+ case ELangIrish:
+ aValue = KGa;
+ break;
+
+ case ELangKannada :
+ aValue = KKn;
+ break;
+
+
+ case ELangKazakh:
+ aValue = KKk;
+ break;
+
+ case ELangKhmer:
+ aValue = KKm;
+ break;
+
+ case ELangKorean:
+ aValue = KKo;
+ break;
+
+ case ELangLao:
+ aValue = KLo;
+ break;
+
+ case ELangLatvian:
+ aValue = KLv;
+ break;
+
+ case ELangLithuanian:
+ aValue = KLt;
+ break;
+
+ case ELangMacedonian:
+ aValue = KMk;
+ break;
+
+ case ELangMalay:
+ aValue = KMs;
+ break;
+
+ case ELangMalayalam:
+ aValue = KMl;
+ break;
+
+ case ELangMarathi:
+ aValue = KMr;
+ break;
+
+ case ELangMoldavian:
+ aValue = KMo;
+ break;
+
+ case ELangMongolian:
+ aValue = KMn;
+ break;
+
+ case ELangPunjabi:
+ aValue = KPa;
+ break;
+
+ case ELangRomanian:
+ aValue = KRo;
+ break;
+
+ case ELangSerbian:
+ aValue = KSr;
+ break;
+
+ case ELangSinhalese:
+ aValue = KSi;
+ break;
+
+ case ELangSomali:
+ aValue = KSo;
+ break;
+
+ case ELangSwahili:
+ aValue = KSw;
+ break;
+
+ case ELangTamil:
+ aValue = KTa;
+ break;
+
+ case ELangTelugu:
+ aValue = KTe;
+ break;
+
+ case ELangTibetan:
+ aValue = KBo;
+ break;
+
+ case ELangTigrinya:
+ aValue = KTi;
+ break;
+
+ case ELangTurkmen:
+ aValue = KTk;
+ break;
+
+ case ELangUkrainian:
+ aValue = KUk;
+ break;
+
+ case ELangUrdu:
+ aValue = KUr;
+ break;
+
+ case ELangVietnamese:
+ aValue = KVi;
+ break;
+
+ case ELangWelsh:
+ aValue = KCy;
+ break;
+
+ case ELangZulu:
+ aValue = KZu;
+ break;
+
+ // from \\epoc32\\include\\oem\\languages.hrh
+
+ case KLangTaiwanEnglish:
+ aValue = KEnTW;
+ break;
+
+ case KLangHongKongEnglish:
+ aValue = KEnHK;
+ break;
+
+ case KLangPrcEnglish:
+ aValue = KEnCN;
+ break;
+
+ case KLangJapaneseEnglish:
+ aValue = KEnJP;
+ break;
+
+ case KLangThaiEnglish:
+ aValue = KEnTH;
+ break;
+
+ case KLangApacMalay:
+ aValue = KMsAP;
+ break;
+
+ case KLangApacEnglish:
+ {
+ aValue = KEnAP;
+ break;
+ }
+ case KLangApacIndonesian:
+ {
+ aValue = KIdAP;
+ break;
+ }
+ case KLangBasque:
+ {
+ aValue = KEu;
+ break;
+ }
+ case KLangGalician:
+ {
+ aValue = KGl;
+ break;
+ }
+
+ // Cingular English
+ case 6154:
+ aValue = KEnUS;
+ break;
+
+ default:
+ aValue = KDefault;
+ break;
+ }
+ }
+
+// --------------------------------------------------------------------------
+// TInt CSvgDecoder::RemoveInternalReferences( CSvgElementImpl* )
+// ---------------------------------------------------------------------------
+void CSvgDecoder::RemoveInternalReferences( CSvgElementImpl* aElement )
+ {
+ // Remove the references of aElement in content handler's lists
+
+ // Use Elements
+ TInt lIndex = 0;
+ if ( aElement->ElemID() == KSvgUseElement )
+ {
+ lIndex = iUseElementArray->Find( aElement );
+ if ( lIndex != KErrNotFound )
+ {
+ iUseElementArray->Remove( lIndex );
+ }
+ }
+ else if ( aElement->ElemID() == KSvgSwitchElement )
+ {
+ // Switch Elements
+ lIndex = iSwitchElementArray->Find( aElement );
+ if ( lIndex != KErrNotFound )
+ {
+ iSwitchElementArray->Remove( lIndex );
+ }
+ }
+ else if ( aElement->IsAnimatedElement() )
+ {
+ // Animation elements include animate* elements, set,
+ // "animation", audio elements etc.
+ lIndex = iAnimationElementArray->Find( aElement );
+ if ( lIndex != KErrNotFound )
+ {
+ iAnimationElementArray->Remove( lIndex );
+ }
+ lIndex = iAnimRefElementArray->Find( aElement );
+ if ( lIndex != KErrNotFound )
+ {
+ iAnimRefElementArray->Remove( lIndex );
+ }
+ }
+ // Elements with test attributes - requiredFeatures,
+ // requiredExtensions, systemLanguage
+ lIndex = iReqFetAttSysArray->Find( aElement );
+ if ( lIndex != KErrNotFound )
+ {
+ iReqFetAttSysArray->Remove( lIndex );
+ }
+
+ // Remove Internal references of subtree elements as well
+ CSvgElementImpl* lChild = ( CSvgElementImpl* )aElement->FirstChild();
+ while ( lChild != NULL )
+ {
+ RemoveInternalReferences( lChild );
+ lChild = ( CSvgElementImpl* )lChild->NextSibling();
+ }
+
+ }