williamr@2: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@4: // under the terms of "Eclipse Public License v1.0" williamr@2: // which accompanies this distribution, and is available williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@4: // apamdr.h williamr@2: // williamr@2: williamr@2: #ifndef __APAMDR_H__ williamr@2: #define __APAMDR_H__ williamr@2: williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: class RReadStream; williamr@2: class RWriteStream; williamr@2: class CStreamStore; williamr@2: class CStreamDictionary; williamr@2: class CEmbeddedStore; williamr@2: class TApaAppIdentifier; williamr@4: class MApaModelHeaderFactory; williamr@4: class CApaModelHeader; williamr@2: williamr@2: williamr@2: /** A factory class for instantiating and restoring an application's door using williamr@2: the application's model. williamr@2: williamr@2: @publishedAll williamr@2: @released */ williamr@4: class TApaModelDoorFactory : public MPictureFactory williamr@4: // Recognizes KUidPictureTypeDoor and creates CApaModelDoor pictures williamr@2: { williamr@2: public: williamr@2: IMPORT_C TApaModelDoorFactory(const MApaModelHeaderFactory* aFactory); williamr@4: public: // from MPictureFactory williamr@4: IMPORT_C void NewPictureL(TPictureHeader& aPictureHeader, const CStreamStore& aPictureStore) const; // used to create CApaDoor's during document restore only williamr@2: private: williamr@2: const MApaModelHeaderFactory* iHeaderFactory; williamr@2: TInt iTApaModelDoorFactory_Reserved1; williamr@2: }; williamr@2: williamr@2: williamr@2: /** A persistent representation of a door that also acts as a wrapper around an williamr@2: application's model. williamr@2: williamr@2: The class allows embedded data to be manipulated without requiring the whole williamr@2: associated application. williamr@2: williamr@2: @publishedAll williamr@2: @released */ williamr@4: class CApaModelDoor : public CApaDoorBase williamr@2: { williamr@2: public: williamr@2: IMPORT_C static CApaModelDoor* NewL(CApaModelHeader* aHeader); williamr@2: IMPORT_C static CApaModelDoor* NewLC(CApaModelHeader* aHeader); williamr@4: IMPORT_C static CApaModelDoor* NewL(const CStreamStore& aStore, TStreamId aHeadStreamId, const MApaModelHeaderFactory* aFactory); williamr@4: williamr@2: /** Gets the application model wrapper object. williamr@2: williamr@2: @return A pointer to the application model wrapper object. */ williamr@2: inline CApaModelHeader* ModelHeader() { return iModelHeader; } williamr@2: williamr@2: /** Sets the format of the door. williamr@2: williamr@2: @param aFormat The format for the graphical representation of the embedded williamr@2: document. */ williamr@2: inline void SetFormat(TFormat aFormat) { iFormat = aFormat; } williamr@2: IMPORT_C TStreamId StoreL(CStreamStore& aStore) const; williamr@2: IMPORT_C void RestoreL(const CStreamStore& aStore,TStreamId aHeadStreamId,const MApaModelHeaderFactory* aFactory); williamr@2: IMPORT_C ~CApaModelDoor(); williamr@4: public: // from CPicture williamr@2: IMPORT_C void DetachFromStoreL(TDetach /*aDegree*/=EDetachFull); //lint !e1735 Virtual function has default parameter - Inherited from CPicture, must be fixed there williamr@2: IMPORT_C void ExternalizeL(RWriteStream& aStream)const; williamr@2: IMPORT_C void Draw(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect,MGraphicsDeviceMap* aMap)const; williamr@2: IMPORT_C void GetOriginalSizeInTwips(TSize& aSize)const; williamr@2: IMPORT_C void SetScaleFactor(TInt aScaleFactorWidth,TInt aScaleFactorHeight); williamr@2: IMPORT_C TInt ScaleFactorWidth()const; williamr@2: IMPORT_C TInt ScaleFactorHeight()const; williamr@2: private: williamr@2: CApaModelDoor(); williamr@2: CApaModelDoor(CApaModelHeader* aHeader); williamr@2: static CStreamDictionary* ReadStreamDictionaryLC(const CStreamStore& aSourceStore,TStreamId aStreamId); williamr@2: static void CopyStoreL(const CEmbeddedStore& aSourceStore,RWriteStream& aTargetStream); williamr@2: void InternalizeModelL(const MApaModelHeaderFactory& aFactory); williamr@4: private: // from CApaDoorBase williamr@2: TSize GlassDoorSize()const; williamr@2: private: williamr@2: CApaModelHeader* iModelHeader; williamr@2: CEmbeddedStore* iStore; williamr@2: TSize iScaleFactor; williamr@2: CBufSeg* iStoreHost; // the host for the embedded store, if the door has been detached from its originating store williamr@2: }; williamr@2: williamr@2: williamr@2: // Abstract wrapper for an applications model - used for file format conversion etc williamr@2: /** An interface class that acts as a wrapper for an application model. williamr@2: williamr@2: This is also known as an application model header. williamr@2: williamr@2: The class provides the knowledge for internalizing and externalizing an application williamr@2: model's data. An instance of the class is used by CApaModelDoor. williamr@2: williamr@2: A concrete implementation of the class must be supplied by the application williamr@2: model (not the application UI). An instance of the class is constructed by williamr@2: a factory object that implements the MApaModelHeaderFactory interface; the williamr@2: factory object is also supplied by the application model (not the application williamr@2: UI). williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: @see CApaModelDoor williamr@2: @see TApaModelDoorFactory williamr@2: @see MApaModelHeaderFactory */ williamr@4: class CApaModelHeader : public CBase williamr@2: { williamr@2: public: williamr@2: /** Stores the model and its components in the specified store. williamr@2: williamr@2: @param aStore The store in which the model's components are to be stored. williamr@2: @param aDict The stream dictionary into which stream IDs and associated UIDs williamr@2: are put. */ williamr@4: virtual void StoreL(CStreamStore& aStore, CStreamDictionary& aDict) const = 0; williamr@2: /** Gets the identity of the application associated with the application model. williamr@2: williamr@2: @return The application identity. */ williamr@4: virtual TApaAppIdentifier AppId() const = 0; williamr@2: /** Restores the model to the specified degree. williamr@2: williamr@2: An implementation of this function should propagate this call to all components williamr@2: of the model. williamr@2: williamr@2: @param aDegree The degree to which restoration is needed. */ williamr@4: virtual void DetachFromStoreL(CPicture::TDetach aDegree) = 0; williamr@2: protected: williamr@2: IMPORT_C CApaModelHeader(); williamr@2: private: williamr@2: IMPORT_C virtual void Reserved_1(); williamr@2: IMPORT_C virtual void Reserved_2(); williamr@2: private: williamr@2: TInt iCApaModelHeader_Reserved1; williamr@2: }; williamr@4: williamr@2: williamr@2: /** An interface class that applications implement to construct an application model williamr@2: wrapper object, also known as the application model header. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: @see CApaModelHeader */ williamr@4: class MApaModelHeaderFactory williamr@2: { williamr@2: public: williamr@2: /** Creates and returns an application model wrapper object. williamr@2: williamr@2: @param aStore The store containing model data. williamr@2: @param aDict The stream dictionary. williamr@2: @param aAppId The application's identity held as a stream in the application's williamr@2: store williamr@2: @return A pointer to the new application model wrapper object. */ williamr@4: virtual CApaModelHeader* NewHeaderL(const CStreamStore& aStore, const CStreamDictionary& aDict, const TApaAppIdentifier& aAppId) const = 0; williamr@2: protected: williamr@2: IMPORT_C MApaModelHeaderFactory(); williamr@2: private: williamr@2: IMPORT_C virtual void MApaModelHeaderFactory_Reserved1(); williamr@2: IMPORT_C virtual void MApaModelHeaderFactory_Reserved2(); williamr@2: private: williamr@2: TInt iMApaModelHeaderFactory_Reserved1; williamr@2: }; williamr@2: williamr@2: williamr@2: #endif