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.
23 class CEikApplication;
24 class CApaWindowGroupName;
27 /** The base class for all GUI applications' documents.
29 In file-based applications, the document represents the data that relates to a
30 particular instance of the application, and should handle storing and restoring
31 it. In all applications, whether file-based or not, the document is used to create
34 A class derived from CEikDocument must be defined by each GUI application, and minimally
35 it must implement CreateAppUiL(). Note that UIs may implement their own document base class,
36 derived from CEikDocument, which applications may need to derive from instead.
38 The document is created by the application's CreateDocumentL() function.
42 @see CEikApplication::CreateDocumentL()
44 class CEikDocument : public CApaDocument, public MSaveObserver
46 public: // new functions
47 /** Constructs the application UI.
49 This function is called by the UI framework during application start-up. It should
50 only carry out first phase construction of the app UI, in other words, using new(ELeave).
51 It should not call the app UI's ConstructL(), because the UI framework is responsible
52 for this. Note also that the UI framework takes ownership of the app UI, so the
53 document does not need to destroy it.
55 @return A partially-constructed app UI object. */
56 virtual CEikAppUi* CreateAppUiL()=0;
57 IMPORT_C virtual CFileStore* OpenFileL(TBool aDoOpen,const TDesC& aFilename,RFs& aFs);
58 IMPORT_C void PrepareToEditL(MApaEmbeddedDocObserver* aObserver,TBool aReadOnly);
59 IMPORT_C void PrepareToEditL();
60 IMPORT_C void SetAppFileMode(TUint aMode);
61 IMPORT_C TUint AppFileMode() const;
62 IMPORT_C virtual void UpdateTaskNameL(CApaWindowGroupName* aWgName);
63 IMPORT_C const TApaAppCaption& AppCaption() const;
64 IMPORT_C void SetChanged(TBool aHasChanged);
65 IMPORT_C void SetEditStoreL(CStreamStore* aStore);
66 void SetEditStoreWithoutAppUiNotificationL(CStreamStore* aStore);
67 inline CStreamStore* EditStore() const;
68 IMPORT_C ~CEikDocument();
69 public: // from MSaveObserver
70 IMPORT_C virtual void SaveL(MSaveObserver::TSaveType aSaveType);
71 public: // from CApaDocument
72 IMPORT_C void NewDocumentL();
73 IMPORT_C CFileStore* CreateFileStoreLC(RFs& aFs,const TDesC& aFileName);
74 IMPORT_C void EditL(MApaEmbeddedDocObserver* aObserver,TBool aReadOnly=EFalse);
75 IMPORT_C void PrintL(const CStreamStore& aSourceStore);
76 IMPORT_C void SaveL();
77 IMPORT_C void StoreL(CStreamStore& aStore,CStreamDictionary& aStreamDic) const;
78 IMPORT_C void RestoreL(const CStreamStore& aStore,const CStreamDictionary& aStreamDic);
79 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
80 IMPORT_C TBool IsEmpty() const;
81 IMPORT_C TBool HasChanged() const;
82 IMPORT_C virtual void ValidatePasswordL() const; // return EFalse if there *is* a password *and* the user doesn't get it right, ETrue otherwise (ie they get it right or there isn't one). Returns ETrue by default
84 IMPORT_C CEikDocument();
85 IMPORT_C CEikDocument(CEikApplication& aApp);
87 IMPORT_C virtual void OpenFileL(CFileStore*& aFileStore, RFile& aFile);
90 // reserved functions from CApaDocument
91 IMPORT_C virtual void Reserved_2();
93 /** A pointer to the app UI which the document is associated with. */
95 /** A pointer to the file store object which is used to edit the document. */
96 CStreamStore* iEditStore;
100 friend class CEikAppUi;
103 /** A pointer to the application process associated with this document.
107 #define iEikProcess ((CEikProcess*)Process())
109 /** A pointer to the application that created this document.
113 #define iEikApplication ((CEikApplication*)Application())
115 /** The default size in twips of icons that represent embedded objects.
119 #define KDefaultIconicDoorSize TSize(500,500)
122 /** Gets the file store object which is used to edit the document.
124 @return A pointer to the file store object which is used to edit the document. */
125 inline CStreamStore* CEikDocument::EditStore() const
126 { return(iEditStore); }
128 #endif // __EIKDOC_H__