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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 #if !defined(__E32STD_H__)
22 #if !defined(__E32BASE_H__)
25 #if !defined(__GDI_H__)
28 #if !defined(__APADBASE_H__)
33 class TApaModelDoorFactory;
35 class CApaModelHeader;
36 class MApaModelHeaderFactory;
38 // classes referenced:
42 class CStreamDictionary;
44 class TApaAppIdentifier;
48 class TApaModelDoorFactory : public MPictureFactory
49 // Recognizes KUidPictureTypeDoor and creates CApaModelDoor pictures
50 /** A factory class for instantiating and restoring an application's door using
51 the application's model.
57 IMPORT_C TApaModelDoorFactory(const MApaModelHeaderFactory* aFactory);
59 // from MPictureFactory
60 IMPORT_C void NewPictureL(TPictureHeader& aPictureHeader,const CStreamStore& aPictureStore)const; // used to create CApaDoor's during document restore only
62 const MApaModelHeaderFactory* iHeaderFactory;
63 TInt iTApaModelDoorFactory_Reserved1;
67 class CApaModelDoor : public CApaDoorBase
68 /** A persistent representation of a door that also acts as a wrapper around an
71 The class allows embedded data to be manipulated without requiring the whole
72 associated application.
78 IMPORT_C static CApaModelDoor* NewL(CApaModelHeader* aHeader);
79 IMPORT_C static CApaModelDoor* NewLC(CApaModelHeader* aHeader);
80 IMPORT_C static CApaModelDoor* NewL(const CStreamStore& aStore,TStreamId aHeadStreamId,const MApaModelHeaderFactory* aFactory);
82 /** Gets the application model wrapper object.
84 @return A pointer to the application model wrapper object. */
85 inline CApaModelHeader* ModelHeader() { return iModelHeader; }
87 /** Sets the format of the door.
89 @param aFormat The format for the graphical representation of the embedded
91 inline void SetFormat(TFormat aFormat) { iFormat = aFormat; }
93 IMPORT_C TStreamId StoreL(CStreamStore& aStore) const;
94 IMPORT_C void RestoreL(const CStreamStore& aStore,TStreamId aHeadStreamId,const MApaModelHeaderFactory* aFactory);
96 IMPORT_C ~CApaModelDoor();
99 IMPORT_C void DetachFromStoreL(TDetach /*aDegree*/=EDetachFull); //lint !e1735 Virtual function has default parameter - Inherited from CPicture, must be fixed there
100 IMPORT_C void ExternalizeL(RWriteStream& aStream)const;
101 IMPORT_C void Draw(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect,MGraphicsDeviceMap* aMap)const;
102 IMPORT_C void GetOriginalSizeInTwips(TSize& aSize)const;
103 IMPORT_C void SetScaleFactor(TInt aScaleFactorWidth,TInt aScaleFactorHeight);
104 IMPORT_C TInt ScaleFactorWidth()const;
105 IMPORT_C TInt ScaleFactorHeight()const;
109 CApaModelDoor(CApaModelHeader* aHeader);
111 static CStreamDictionary* ReadStreamDictionaryLC(const CStreamStore& aSourceStore,TStreamId aStreamId);
112 static void CopyStoreL(const CEmbeddedStore& aSourceStore,RWriteStream& aTargetStream);
113 void InternalizeModelL(const MApaModelHeaderFactory& aFactory);
116 TSize GlassDoorSize()const;
118 CApaModelHeader* iModelHeader;
119 CEmbeddedStore* iStore;
121 CBufSeg* iStoreHost; // the host for the embedded store, if the door has been detached from its originating store
125 class CApaModelHeader : public CBase
126 // Abstract wrapper for an applications model - used for file format conversion etc
127 /** An interface class that acts as a wrapper for an application model.
129 This is also known as an application model header.
131 The class provides the knowledge for internalizing and externalizing an application
132 model's data. An instance of the class is used by CApaModelDoor.
134 A concrete implementation of the class must be supplied by the application
135 model (not the application UI). An instance of the class is constructed by
136 a factory object that implements the MApaModelHeaderFactory interface; the
137 factory object is also supplied by the application model (not the application
143 @see TApaModelDoorFactory
144 @see MApaModelHeaderFactory */
147 /** Stores the model and its components in the specified store.
149 @param aStore The store in which the model's components are to be stored.
150 @param aDict The stream dictionary into which stream IDs and associated UIDs
152 virtual void StoreL(CStreamStore& aStore,CStreamDictionary& aDict) const=0;
153 /** Gets the identity of the application associated with the application model.
155 @return The application identity. */
156 virtual TApaAppIdentifier AppId()const=0;
157 /** Restores the model to the specified degree.
159 An implementation of this function should propagate this call to all components
162 @param aDegree The degree to which restoration is needed. */
163 virtual void DetachFromStoreL(CPicture::TDetach aDegree)=0;
165 IMPORT_C CApaModelHeader();
167 IMPORT_C virtual void Reserved_1();
168 IMPORT_C virtual void Reserved_2();
170 TInt iCApaModelHeader_Reserved1;
175 class MApaModelHeaderFactory
176 /** An interface class that applications implement to construct an application model
177 wrapper object, also known as the application model header.
181 @see CApaModelHeader */
184 /** Creates and returns an application model wrapper object.
186 @param aStore The store containing model data.
187 @param aDict The stream dictionary.
188 @param aAppId The application's identity held as a stream in the application's
190 @return A pointer to the new application model wrapper object. */
191 virtual CApaModelHeader* NewHeaderL(const CStreamStore& aStore,const CStreamDictionary& aDict,const TApaAppIdentifier& aAppId)const=0;
193 IMPORT_C MApaModelHeaderFactory();
195 IMPORT_C virtual void MApaModelHeaderFactory_Reserved1();
196 IMPORT_C virtual void MApaModelHeaderFactory_Reserved2();
198 TInt iMApaModelHeaderFactory_Reserved1;