svgtviewer/SvgtViewerPlugin/SVGCodecInc/SVGCodec.h
branchRCL_3
changeset 14 20b99a6d6175
parent 0 632761c941a7
equal deleted inserted replaced
13:e52958d06c29 14:20b99a6d6175
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  SVGT codec for reading the file header & data.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef SVGCODEC_H
       
    20 #define SVGCODEC_H
       
    21 
       
    22 #include <imagecodec.h>
       
    23 #include <imagedata.h>
       
    24 #include <SVGRequestObserver.h>
       
    25 #include <SVGListener.h>
       
    26 
       
    27 
       
    28 class CSvgEngineInterfaceImpl;
       
    29 class CFbsBitmap;
       
    30 class TFrameInfo;
       
    31 class TSVGFrameInfo;
       
    32 class MSvgError;
       
    33 class CGulIcon;
       
    34 
       
    35 // SVG Read codec.
       
    36 class CSvgReadCodec : public CImageProcessorReadCodec
       
    37                        ,public MSvgRequestObserver
       
    38                        , public MSvgLoadingListener
       
    39 
       
    40     {
       
    41 public:
       
    42     enum TDownloadNeeded 
       
    43         {
       
    44         // The uri refers to a local image file
       
    45         ELocalImageFile,
       
    46         // The uri refers to a remote image file
       
    47         ERemoteImageFile,
       
    48         // The uri doesnt refer to an image file
       
    49         ENotAnImageFile
       
    50         };
       
    51     
       
    52     enum TImagesLocation
       
    53         {
       
    54         EPhoneMemory,
       
    55         EMemoryCard
       
    56         };
       
    57 public:
       
    58 
       
    59     /**
       
    60     * Static constructor. Creates and returns a pointer to CSvgReadCodec
       
    61     * @since 3.1
       
    62     * @return Pointer to the read codec instance.
       
    63     */
       
    64     static CSvgReadCodec* NewL(const TSize& aSize);
       
    65 
       
    66     /**
       
    67     * Destructor.
       
    68     */
       
    69     virtual ~CSvgReadCodec();
       
    70 
       
    71     /**
       
    72     * Sets the SVG presentation data
       
    73     * @since 3.1
       
    74     * @param aFileData  SVG presentation file data
       
    75     */
       
    76     void SetFileDataL( const TDesC8& aFileData );
       
    77     
       
    78 public: //From MSvgRequestObserver
       
    79     void UpdateScreen();
       
    80 
       
    81     TBool ScriptCall( const TDesC& aScript, CSvgElementImpl* aCallerElement );
       
    82 
       
    83     TInt FetchImage( const TDesC& aUri, RFs& aSession, RFile& aFileHandle ) ;
       
    84     TInt CSvgReadCodec::FetchFont( const TDesC& /* aUri */, 
       
    85                                     RFs& /* aSession */, RFile& /* aFileHandle */ );
       
    86 
       
    87     void GetSmilFitValue( TDes& aSmilValue );
       
    88 
       
    89     void UpdatePresentation( const TInt32&  aNoOfAnimation );        
       
    90 
       
    91 public: //User methods
       
    92     void PrepareEngine();
       
    93     TSize ContentSize() const;
       
    94     void GenerateThumbnailL(CFbsBitmap* aFrame, CFbsBitmap* aFrameMask);
       
    95     TDownloadNeeded IsDownloadNeededL( const TDesC& aUri ) const;
       
    96     TBool GetLocalFile( const TDesC& aUri, 
       
    97                                     TDes& aFileName ,
       
    98                                     const TDesC& aRefPath ) const;
       
    99     
       
   100     HBufC* GetImagesPath( CSvgReadCodec::TImagesLocation aImagesLocation) const;
       
   101     
       
   102 protected:
       
   103     // From CImageProcessorReadCodec
       
   104     /**
       
   105     * Performs initial processing of image data and mask bitmaps.
       
   106 	* @param	aFrameInfo
       
   107 	        A reference to a TFrameInfo object.
       
   108 	* @param	aFrameImageData
       
   109 	        A reference to a CFrameImageData object.
       
   110 	* @param	aDisableErrorDiffusion
       
   111 	        A flag indicating whether error diffusion should be disabled.
       
   112 	* @param	aDestination
       
   113 	        The destination bitmap.
       
   114 	* @param	aDestinationMask
       
   115 	        The destination mask bitmap.
       
   116     */
       
   117     virtual void InitFrameL(TFrameInfo& aFrameInfo, CFrameImageData& aFrameImageData, TBool aDisableErrorDiffusion, CFbsBitmap& aDestination, CFbsBitmap* aDestinationMask);
       
   118     
       
   119 	/**
       
   120 	* Processes the frame data contained in aSrc.
       
   121  	* This is a pure virtual function that each derived class must implement.
       
   122 	* @param  aSrc
       
   123 	*       A reference to the buffer containing the frame data.
       
   124     *
       
   125 	* @return	The current frame state after processing.
       
   126 	*/
       
   127     
       
   128     virtual TFrameState ProcessFrameL(TBufPtr8& aSrc);
       
   129 
       
   130 private:
       
   131     
       
   132     /**
       
   133     * Precesses the SVG presentation file data
       
   134     */
       
   135     void DoProcessL();
       
   136     
       
   137     /**
       
   138     * Default constructor
       
   139     * @param aSize specifies the thubnail size
       
   140     */
       
   141     CSvgReadCodec(const TSize& aSize);
       
   142 
       
   143     void ConstructL();
       
   144     void InitializeEngineL();
       
   145     /**
       
   146     * Deletes the structures associated with the engine
       
   147     * viz. The Frame List, Mask List, Delay Interval List, 
       
   148     * The DOM for the content and the Engine Implementation itself
       
   149     */
       
   150     void DeleteEngine();
       
   151 // From MSvgLoadingListener    
       
   152 public:
       
   153     /**
       
   154      * Query the listener if every element is to be reported or only
       
   155      * the children of <svg> tag.
       
   156      *
       
   157      * @since 1.0
       
   158      * @return : ETrue if every element is to be reported, otherwise
       
   159      *           only the children of <svg> are reported.
       
   160      */
       
   161     TBool ReportAllElements();
       
   162 
       
   163     /**
       
   164      * Query the listener if client will call 'AssignImageData' to decode images
       
   165      * separately from parsing.  This is used to avoid non-thread-safe calls in
       
   166      * creating bitmap and decoding images, which must be executed in the main thread.
       
   167      *
       
   168      * @since 1.0
       
   169      * @return : ETrue to use 'ImageDataReference' instead of 'FetchImage'.
       
   170      */
       
   171     TBool WillAssignImageData();
       
   172 
       
   173     /**
       
   174      * Callback when the href:xlink attribute is encountered for the <image>
       
   175      * element.  This method is used to notify clients of image data references
       
   176      * needed by <image> element.  This method is called only when 'WillAssignImageData'
       
   177      * returns ETrue.
       
   178      *
       
   179      * @since 1.0
       
   180      * @return : none.
       
   181      */
       
   182     void ImageDataReference( const TDesC& aUri );
       
   183 
       
   184     /**
       
   185      * Notified when the start of a svg document(<svg> tag) is encountered.
       
   186      *
       
   187      * @since 1.0
       
   188      * @return : For future use.  Value is ignored.
       
   189      */
       
   190     TBool DocumentStart() ;
       
   191 
       
   192     /**
       
   193      * Notified when the end of a svg document(</svg> tag) is encountered.
       
   194      *
       
   195      * @since 1.0
       
   196      * @return : For future use.  Value is ignored.
       
   197      */
       
   198     TBool DocumentEnd();
       
   199 
       
   200     /**
       
   201      * Notified when the start of a svg element is encountered.
       
   202      *
       
   203      * @since 1.0
       
   204      * @param : aTagName -- name of svg tag
       
   205      * @param : aAttributeList -- attribute list.
       
   206      * @return : For future use.  Value is ignored.
       
   207      */
       
   208     TBool ElementStart( const TDesC& aTagName,
       
   209                                 MSvgAttributeList& aAttributeList);
       
   210 
       
   211     /**
       
   212      * Notified when the end of a svg element is encountered.
       
   213      * activated.
       
   214      *
       
   215      * @since 1.0
       
   216      * @param : aTagName -- name of svg tag
       
   217      * @return : For future use.  Value is ignored.
       
   218      */
       
   219     TBool ElementEnd( const TDesC& aTagName );
       
   220 
       
   221     /**
       
   222      * Notified when an external data is needed by the svg document,
       
   223      * such as a image-file or an embedded svg-file.
       
   224      *
       
   225      * @since 1.0
       
   226      * @param : aUri -- URI string of external data
       
   227      * @return : For future use.  Value is ignored.
       
   228      */
       
   229     TBool ExternalDataRequested( const TDesC& aUri );
       
   230 
       
   231     /**
       
   232      * Notified when an external data has been retrieved,
       
   233      * such as a image-file or an embedded svg-file.
       
   234      *
       
   235      * @since 1.0
       
   236      * @param : aUri -- URI string of external data
       
   237      * @return : For future use.  Value is ignored.
       
   238      */
       
   239     TBool ExternalDataReceived( const TDesC& aUri );
       
   240 
       
   241     /**
       
   242      * Notified when an external data request has failed.
       
   243      *
       
   244      * @since 1.0
       
   245      * @param : aUri -- URI string of external data
       
   246      * @return : For future use.  Value is ignored.
       
   247      */
       
   248     TBool ExternalDataRequestFailed( const TDesC& aUri );
       
   249 
       
   250     /**
       
   251      * Notified when an unsupported element is encountered.
       
   252      *
       
   253      * @since 1.0
       
   254      * @param : aTagName -- tag name of element
       
   255      * @param : aAttributeList -- attribute list.
       
   256      * @return : For future use.  Value is ignored.
       
   257      */
       
   258     TBool UnsupportedElement( const TDesC& aTagName,
       
   259                                       MSvgAttributeList& aAttributeList );
       
   260 
       
   261     void ImagesLoaded(TInt aError);
       
   262     void GetNewDataPosition(TInt &aPosition, TInt &aLength);
       
   263     
       
   264 private:    // Data
       
   265     // Dummy Bitmap used by SVG Engine to render content.
       
   266     CFbsBitmap* iSVGTBitMapDummy;
       
   267 
       
   268     // SVG Engine Interface Implementation pointer
       
   269     CSvgEngineInterfaceImpl* iSvgModule;
       
   270     
       
   271     //Frame Array
       
   272     RPointerArray<CFbsBitmap> iFrameList;
       
   273     RPointerArray<CFbsBitmap> iMaskList;
       
   274     RArray<TUint> iDelayList;
       
   275     
       
   276     // SVG Thumbnail Handle
       
   277     TInt iThumbnailHandle;
       
   278       
       
   279     // SVGT content filename descriptor
       
   280     HBufC8* iFileData;
       
   281     TSize iContentSize;
       
   282     MSvgError* iPrepareDomResult;
       
   283     
       
   284     TBool iImagesPresent;
       
   285     
       
   286     TBool iImagesLoaded;
       
   287 
       
   288     TSize iOriginalSize;
       
   289     };
       
   290 
       
   291 #endif  //SVGCODEC_H