appfw/apparchitecture/inc/APAMDR.H
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // apamdr.h
       
    15 //
       
    16 
       
    17 #ifndef __APAMDR_H__
       
    18 #define __APAMDR_H__
       
    19 
       
    20 #include <e32std.h>
       
    21 #include <e32base.h>
       
    22 #include <gdi.h>
       
    23 #include <apadbase.h>
       
    24 
       
    25 class RReadStream;
       
    26 class RWriteStream;
       
    27 class CStreamStore;
       
    28 class CStreamDictionary;
       
    29 class CEmbeddedStore;
       
    30 class TApaAppIdentifier;
       
    31 class MApaModelHeaderFactory;
       
    32 class CApaModelHeader;
       
    33 
       
    34 
       
    35 /** A factory class for instantiating and restoring an application's door using 
       
    36 the application's model. 
       
    37 
       
    38 @publishedAll 
       
    39 @released */
       
    40 class TApaModelDoorFactory : public MPictureFactory
       
    41 // Recognizes KUidPictureTypeDoor and creates CApaModelDoor pictures
       
    42 	{
       
    43 public:
       
    44 	IMPORT_C TApaModelDoorFactory(const MApaModelHeaderFactory* aFactory);
       
    45 public:	// from MPictureFactory
       
    46 	IMPORT_C void NewPictureL(TPictureHeader& aPictureHeader, const CStreamStore& aPictureStore) const; // used to create CApaDoor's during document restore only 
       
    47 private:
       
    48 	const MApaModelHeaderFactory* iHeaderFactory;
       
    49 	TInt iTApaModelDoorFactory_Reserved1;
       
    50 	};
       
    51 
       
    52 
       
    53 /** A persistent representation of a door that also acts as a wrapper around an 
       
    54 application's model.
       
    55 
       
    56 The class allows embedded data to be manipulated without requiring the whole 
       
    57 associated application. 
       
    58 
       
    59 @publishedAll 
       
    60 @released */
       
    61 class CApaModelDoor : public CApaDoorBase
       
    62 	{
       
    63 public:
       
    64 	IMPORT_C static CApaModelDoor* NewL(CApaModelHeader* aHeader);
       
    65 	IMPORT_C static CApaModelDoor* NewLC(CApaModelHeader* aHeader);
       
    66 	IMPORT_C static CApaModelDoor* NewL(const CStreamStore& aStore, TStreamId aHeadStreamId, const MApaModelHeaderFactory* aFactory);
       
    67 
       
    68 	/** Gets the application model wrapper object.
       
    69 	
       
    70 	@return A pointer to the application model wrapper object. */
       
    71 	inline CApaModelHeader* ModelHeader() { return iModelHeader; }
       
    72 	
       
    73 	/** Sets the format of the door.
       
    74 	
       
    75 	@param aFormat The format for the graphical representation of the embedded 
       
    76 	document. */
       
    77 	inline void SetFormat(TFormat aFormat) { iFormat = aFormat; }
       
    78 	IMPORT_C TStreamId StoreL(CStreamStore& aStore) const;
       
    79 	IMPORT_C void RestoreL(const CStreamStore& aStore,TStreamId aHeadStreamId,const MApaModelHeaderFactory* aFactory);
       
    80 	IMPORT_C ~CApaModelDoor();
       
    81 public:	// from CPicture
       
    82 	IMPORT_C void DetachFromStoreL(TDetach /*aDegree*/=EDetachFull); //lint !e1735 Virtual function has default parameter - Inherited from CPicture, must be fixed there
       
    83 	IMPORT_C void ExternalizeL(RWriteStream& aStream)const;
       
    84 	IMPORT_C void Draw(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect,MGraphicsDeviceMap* aMap)const; 
       
    85 	IMPORT_C void GetOriginalSizeInTwips(TSize& aSize)const;
       
    86 	IMPORT_C void SetScaleFactor(TInt aScaleFactorWidth,TInt aScaleFactorHeight); 
       
    87 	IMPORT_C TInt ScaleFactorWidth()const; 
       
    88 	IMPORT_C TInt ScaleFactorHeight()const;
       
    89 private:
       
    90 	CApaModelDoor();
       
    91 	CApaModelDoor(CApaModelHeader* aHeader);
       
    92 	static CStreamDictionary* ReadStreamDictionaryLC(const CStreamStore& aSourceStore,TStreamId aStreamId);
       
    93 	static void CopyStoreL(const CEmbeddedStore& aSourceStore,RWriteStream& aTargetStream);
       
    94 	void InternalizeModelL(const MApaModelHeaderFactory& aFactory);
       
    95 private: // from CApaDoorBase
       
    96 	TSize GlassDoorSize()const;
       
    97 private:
       
    98 	CApaModelHeader* iModelHeader;
       
    99 	CEmbeddedStore* iStore;
       
   100 	TSize iScaleFactor;
       
   101 	CBufSeg* iStoreHost; // the host for the embedded store, if the door has been detached from its originating store
       
   102 	};
       
   103 
       
   104 
       
   105 // Abstract wrapper for an applications model - used for file format conversion etc
       
   106 /** An interface class that acts as a wrapper for an application model.
       
   107 
       
   108 This is also known as an application model header.
       
   109 
       
   110 The class provides the knowledge for internalizing and externalizing an application 
       
   111 model's data. An instance of the class is used by CApaModelDoor.
       
   112 
       
   113 A concrete implementation of the class must be supplied by the application 
       
   114 model (not the application UI). An instance of the class is constructed by 
       
   115 a factory object that implements the MApaModelHeaderFactory interface; the 
       
   116 factory object is also supplied by the application model (not the application 
       
   117 UI).
       
   118 
       
   119 @publishedAll
       
   120 @released
       
   121 @see CApaModelDoor
       
   122 @see TApaModelDoorFactory
       
   123 @see MApaModelHeaderFactory */
       
   124 class CApaModelHeader : public CBase
       
   125 	{
       
   126 public:
       
   127 	/** Stores the model and its components in the specified store.
       
   128 	
       
   129 	@param aStore The store in which the model's components are to be stored.
       
   130 	@param aDict The stream dictionary into which stream IDs and associated UIDs 
       
   131 	are put. */
       
   132 	virtual void StoreL(CStreamStore& aStore, CStreamDictionary& aDict) const = 0;
       
   133 	/** Gets the identity of the application associated with the application model.
       
   134 	
       
   135 	@return The application identity. */
       
   136 	virtual TApaAppIdentifier AppId() const = 0;
       
   137 	/** Restores the model to the specified degree.
       
   138 	
       
   139 	An implementation of this function should propagate this call to all components 
       
   140 	of the model.
       
   141 	
       
   142 	@param aDegree The degree to which restoration is needed. */
       
   143 	virtual void DetachFromStoreL(CPicture::TDetach aDegree) = 0;
       
   144 protected:
       
   145 	IMPORT_C CApaModelHeader();
       
   146 private:
       
   147 	IMPORT_C virtual void Reserved_1();
       
   148 	IMPORT_C virtual void Reserved_2();
       
   149 private:
       
   150 	TInt iCApaModelHeader_Reserved1;
       
   151 	};
       
   152 	
       
   153 
       
   154 /** An interface class that applications implement to construct an application model 
       
   155 wrapper object, also known as the application model header.
       
   156 
       
   157 @publishedAll
       
   158 @released
       
   159 @see CApaModelHeader */
       
   160 class MApaModelHeaderFactory
       
   161 	{
       
   162 public:	
       
   163 	/** Creates and returns an application model wrapper object.
       
   164 	
       
   165 	@param aStore The store containing model data.
       
   166 	@param aDict The stream dictionary. 
       
   167 	@param aAppId The application's identity held as a stream in the application's 
       
   168 	store
       
   169 	@return A pointer to the new application model wrapper object. */
       
   170 	virtual CApaModelHeader* NewHeaderL(const CStreamStore& aStore, const CStreamDictionary& aDict, const TApaAppIdentifier& aAppId) const = 0;
       
   171 protected:
       
   172 	IMPORT_C MApaModelHeaderFactory();
       
   173 private:
       
   174 	IMPORT_C virtual void MApaModelHeaderFactory_Reserved1();
       
   175 	IMPORT_C virtual void MApaModelHeaderFactory_Reserved2();
       
   176 private:
       
   177 	TInt iMApaModelHeaderFactory_Reserved1;
       
   178 	};
       
   179 
       
   180 
       
   181 #endif