|
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" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __APAMDR_H__ |
|
17 #define __APAMDR_H__ |
|
18 |
|
19 #if !defined(__E32STD_H__) |
|
20 #include <e32std.h> |
|
21 #endif |
|
22 #if !defined(__E32BASE_H__) |
|
23 #include <e32base.h> |
|
24 #endif |
|
25 #if !defined(__GDI_H__) |
|
26 #include <gdi.h> |
|
27 #endif |
|
28 #if !defined(__APADBASE_H__) |
|
29 #include <apadbase.h> |
|
30 #endif |
|
31 |
|
32 // classes defined: |
|
33 class TApaModelDoorFactory; |
|
34 class CApaModelDoor; |
|
35 class CApaModelHeader; |
|
36 class MApaModelHeaderFactory; |
|
37 // |
|
38 // classes referenced: |
|
39 class RReadStream; |
|
40 class RWriteStream; |
|
41 class CStreamStore; |
|
42 class CStreamDictionary; |
|
43 class CEmbeddedStore; |
|
44 class TApaAppIdentifier; |
|
45 // |
|
46 |
|
47 |
|
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. |
|
52 |
|
53 @publishedAll |
|
54 @released */ |
|
55 { |
|
56 public: |
|
57 IMPORT_C TApaModelDoorFactory(const MApaModelHeaderFactory* aFactory); |
|
58 // |
|
59 // from MPictureFactory |
|
60 IMPORT_C void NewPictureL(TPictureHeader& aPictureHeader,const CStreamStore& aPictureStore)const; // used to create CApaDoor's during document restore only |
|
61 private: |
|
62 const MApaModelHeaderFactory* iHeaderFactory; |
|
63 TInt iTApaModelDoorFactory_Reserved1; |
|
64 }; |
|
65 |
|
66 |
|
67 class CApaModelDoor : public CApaDoorBase |
|
68 /** A persistent representation of a door that also acts as a wrapper around an |
|
69 application's model. |
|
70 |
|
71 The class allows embedded data to be manipulated without requiring the whole |
|
72 associated application. |
|
73 |
|
74 @publishedAll |
|
75 @released */ |
|
76 { |
|
77 public: |
|
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); |
|
81 // |
|
82 /** Gets the application model wrapper object. |
|
83 |
|
84 @return A pointer to the application model wrapper object. */ |
|
85 inline CApaModelHeader* ModelHeader() { return iModelHeader; } |
|
86 |
|
87 /** Sets the format of the door. |
|
88 |
|
89 @param aFormat The format for the graphical representation of the embedded |
|
90 document. */ |
|
91 inline void SetFormat(TFormat aFormat) { iFormat = aFormat; } |
|
92 // |
|
93 IMPORT_C TStreamId StoreL(CStreamStore& aStore) const; |
|
94 IMPORT_C void RestoreL(const CStreamStore& aStore,TStreamId aHeadStreamId,const MApaModelHeaderFactory* aFactory); |
|
95 // |
|
96 IMPORT_C ~CApaModelDoor(); |
|
97 // |
|
98 // from CPicture |
|
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; |
|
106 // |
|
107 private: |
|
108 CApaModelDoor(); |
|
109 CApaModelDoor(CApaModelHeader* aHeader); |
|
110 // |
|
111 static CStreamDictionary* ReadStreamDictionaryLC(const CStreamStore& aSourceStore,TStreamId aStreamId); |
|
112 static void CopyStoreL(const CEmbeddedStore& aSourceStore,RWriteStream& aTargetStream); |
|
113 void InternalizeModelL(const MApaModelHeaderFactory& aFactory); |
|
114 // |
|
115 // from CApaDoorBase |
|
116 TSize GlassDoorSize()const; |
|
117 private: |
|
118 CApaModelHeader* iModelHeader; |
|
119 CEmbeddedStore* iStore; |
|
120 TSize iScaleFactor; |
|
121 CBufSeg* iStoreHost; // the host for the embedded store, if the door has been detached from its originating store |
|
122 }; |
|
123 |
|
124 |
|
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. |
|
128 |
|
129 This is also known as an application model header. |
|
130 |
|
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. |
|
133 |
|
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 |
|
138 UI). |
|
139 |
|
140 @publishedAll |
|
141 @released |
|
142 @see CApaModelDoor |
|
143 @see TApaModelDoorFactory |
|
144 @see MApaModelHeaderFactory */ |
|
145 { |
|
146 public: |
|
147 /** Stores the model and its components in the specified store. |
|
148 |
|
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 |
|
151 are put. */ |
|
152 virtual void StoreL(CStreamStore& aStore,CStreamDictionary& aDict) const=0; |
|
153 /** Gets the identity of the application associated with the application model. |
|
154 |
|
155 @return The application identity. */ |
|
156 virtual TApaAppIdentifier AppId()const=0; |
|
157 /** Restores the model to the specified degree. |
|
158 |
|
159 An implementation of this function should propagate this call to all components |
|
160 of the model. |
|
161 |
|
162 @param aDegree The degree to which restoration is needed. */ |
|
163 virtual void DetachFromStoreL(CPicture::TDetach aDegree)=0; |
|
164 protected: |
|
165 IMPORT_C CApaModelHeader(); |
|
166 private: |
|
167 IMPORT_C virtual void Reserved_1(); |
|
168 IMPORT_C virtual void Reserved_2(); |
|
169 private: |
|
170 TInt iCApaModelHeader_Reserved1; |
|
171 }; |
|
172 |
|
173 |
|
174 |
|
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. |
|
178 |
|
179 @publishedAll |
|
180 @released |
|
181 @see CApaModelHeader */ |
|
182 { |
|
183 public: |
|
184 /** Creates and returns an application model wrapper object. |
|
185 |
|
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 |
|
189 store |
|
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; |
|
192 protected: |
|
193 IMPORT_C MApaModelHeaderFactory(); |
|
194 private: |
|
195 IMPORT_C virtual void MApaModelHeaderFactory_Reserved1(); |
|
196 IMPORT_C virtual void MApaModelHeaderFactory_Reserved2(); |
|
197 private: |
|
198 TInt iMApaModelHeaderFactory_Reserved1; |
|
199 }; |
|
200 |
|
201 |
|
202 #endif |