OWLNext 7.0
Borland's Object Windows Library for the modern age
|
Derived from TStorageDocument, TOleDocument implements the document half of the Doc/View pair. More...
#include <ocf/oledoc.h>
Public Member Functions | |
TOleDocument (owl::TDocument *parent=0) | |
Constructs a TOleDocument object associated with the given parent TDocument object. | |
~TOleDocument () | |
Destroys the TOleDocument object. | |
Accessors | |
void | SetOcDoc (TOcDocument *doc) |
Sets the ObjectComponents document associated with this TOleDocument object. | |
TOcDocument * | GetOcDoc () |
Returns the ObjectComponents document associated with this TOleDocument object. | |
TOcApp * | GetOcApp () |
Returns the ObjectComponents application associated with this TOleDocument object. | |
Overridables: | |
bool | Commit (bool force) |
Commits the current document's data to storage. | |
bool | Open (int mode, LPCTSTR path=0) |
Loads the embedded objects, if any, using the path specified in path. | |
bool | Close () |
Ensures that the IStorage is released properly and disconnects any active server in the document. | |
bool | InitDoc () |
Overrides the TDocument::InitDoc function and creates or opens a compound file so that there is an IStorage associated with this document's embedded objects. | |
bool | CanClose () |
Prepares the document for closing. | |
bool | Revert (bool clear) |
Performs the reverse of Commit. | |
bool | SetStorage (IStorage *stg, bool remember=true) |
Attaches the IStorage pointer (stg) to this document. | |
bool | RestoreStorage () |
Restores the original root IStorage before the save operation. | |
bool | ReleaseDoc () |
Releases the ObjectComponents document when the server is finished using the document. | |
virtual void | PreOpen () |
Before the document is actually opened, PreOpen gives the derived class a chance to perform a particular operation; for example, setting a different open mode for the compound document. | |
virtual bool | Read () |
Loads the embedded objects from the compound file. | |
virtual bool | Write () |
Saves the embedded objects to the compound file. | |
virtual bool | CommitSelection (TOleWindow &oleWin, void *userData) |
Virtual function to be overriden in TOleDocument-derived class which serves or supports linking to portions of a document's data. | |
Utilities | |
bool | PathChanged () |
Checks to see if the current document's path is the same as the TOcDocument's path. | |
void | OleViewClose () |
Shuts down the TOleView's. | |
Public Member Functions inherited from ocf::TStorageDocument | |
TStorageDocument (owl::TDocument *parent=0) | |
Construct a default Storage document object. | |
~TStorageDocument () | |
owl::TInStream * | InStream (int omode, LPCTSTR strmId=0) |
owl::TOutStream * | OutStream (int omode, LPCTSTR strmId=0) |
bool | Open (int omode, LPCTSTR stgId) |
Open the compound file with a given path. | |
bool | Close () |
bool | Commit (bool force=false) |
bool | CommitTransactedStorage () |
bool | Revert (bool clear=false) |
bool | SetDocPath (LPCTSTR path) |
bool | IsOpen () |
Return 'true' if the storage document object has opened an OLE storage. | |
int | FindProperty (LPCTSTR name) |
int | PropertyFlags (int index) |
LPCTSTR | PropertyName (int index) |
int | PropertyCount () |
Return the number of properties supported by the storage document object. | |
int | GetProperty (int index, void *dest, int textlen=0) |
bool | SetProperty (int index, const void *src) |
virtual IStorage * | GetNewStorage () |
Get a new IStorage, typically in a SaveAs situation. | |
IStorage * | GetStorage () |
Return the IStorage interface pointer currently associated with the storage document object. | |
virtual bool | OpenHandle (int omode, HANDLE hGlobal) |
Create an IStorage based on a memory handle. | |
virtual bool | SetHandle (int omode, HANDLE hGlobal, bool create=false, bool remember=false) |
Replace the IStorage with an istorage based on a memory handle. | |
virtual bool | GetHandle (HGLOBAL *handle) |
Get the global handle from ILockBytes. | |
Public Member Functions inherited from owl::TDocument | |
TDocument (TDocument *parent=nullptr) | |
Although you do not create a TDocument object directly, you must call the constructor when you create a derived class. | |
virtual | ~TDocument () |
Deletes a TDocument object. | |
TInStream * | InStream (int mode, const tstring &streamId) |
TOutStream * | OutStream (int mode, const tstring &streamId) |
bool | Open (int mode, const tstring &path) |
virtual TDocument & | RootDocument () |
Returns the this pointer as the root document. | |
TDocManager & | GetDocManager () |
Returns a pointer to the current document manager. | |
void | SetDocManager (TDocManager &dm) |
Sets the current document manager to the argument dm. | |
TDocument * | GetParentDoc () |
Returns either the parent document of the current document or 0 if there is no parent document. | |
TDocTemplate * | GetTemplate () |
Gets the template used for document creation. | |
bool | SetTemplate (TDocTemplate *tpl) |
Sets the document template. | |
LPCTSTR | GetDocPath () const |
Returns the directory path for the document. | |
bool | SetDocPath (const tstring &path) |
LPCTSTR | GetTitle () const |
Returns the title of the document. | |
virtual void | SetTitle (LPCTSTR title) |
Sets the title of the document. | |
void | SetTitle (const tstring &title) |
virtual bool | IsDirty () |
Also queries doc and view hierarchy. | |
void | SetDirty (bool dirty=true) |
Updates the document's dirty flag using the specified parameter. | |
virtual bool | HasFocus (HWND hwnd) |
Document (or child doc) has Focus. | |
virtual TDocument * | DocWithFocus (HWND hwnd) |
Return pointer to this document or one of its child documents if the spcecified window parameter is a view associated with the document. | |
bool | NotifyViews (int eventId, TParam2=0, TView *exclude=nullptr) |
Notifies the views of this document, and the views of any child documents, of a change. | |
bool | NotifyOwnViews (int eventId, TParam2=0, TView *exclude=nullptr) |
Notifies the views of this document of a change. | |
TView * | QueryViews (int eventId, TParam2=0, TView *exclude=nullptr) |
Queries the views of the current document, and the views of any child documents, about a specified event. | |
virtual uint | PostError (uint sid, uint choice=MB_OK) |
Posts the error message passed as a string resource ID in sid. | |
int | FindProperty (const tstring &name) |
TList & | GetChildren () |
Return reference to the children document list. | |
TView * | GetViewList () const |
Return pointer to the head of the link list of views associated with this document. | |
TView * | NextView (const TView *view) |
Gets the next view in the list of views. Holds 0 if none exists. | |
TStream * | GetStreamList () const |
Returns head of the link list of streams associated with this document. | |
TStream * | NextStream (const TStream *strm) |
Gets the next entry in the stream. Holds 0 if none exists. | |
void * | GetTag () const |
Returns pointer to user-defined data [i.e. tag] attached to this document. | |
void | SetTag (void **tag) |
Attach an arbitrary (user-defined) pointer with this document. | |
int | GetOpenMode () const |
Gets the mode and protection flag values for the current document. | |
void | SetOpenMode (int mode) |
Sets the mode and protection flag values for the current document. | |
TView * | InitView (TView *view) |
called from template InitView | |
bool | IsEmbedded () const |
Returns true if the document is embedded in an OLE 2 container. | |
void | SetEmbedded (bool embed) |
Marks the document as being embedded in an OLE 2 container. | |
TDocument (TDocManager *docMan) | |
create a dummy document to hold docmgr | |
Public Member Functions inherited from owl::TStreamableBase | |
virtual | ~TStreamableBase () |
Additional Inherited Members | |
Public Types inherited from ocf::TStorageDocument | |
enum | TStgDocProp { PrevProperty = owl::TDocument::NextProperty-1 , CreateTime , ModifyTime , AccessTime , StorageSize , IStorageInstance , NextProperty } |
Public Types inherited from owl::TDocument | |
enum | TDocProp { PrevProperty = 0 , DocumentClass , TemplateName , ViewCount , StoragePath , DocTitle , NextProperty } |
These property values, which describe the basic properties of a document, are available in classes derived from TDocument. More... | |
typedef TList | List |
Protected Member Functions inherited from ocf::TStorageDocument | |
int | GetThisOpen () |
Return the mode bits used to open the storage currently associated with this storage object. | |
IStorage * | GetOrgStorageI () |
Return a pointer to the original IStorage interface associated with this storage document object. | |
ILockBytes * | GetLockBytes () |
Return a pointer to the ILockBytes interface currently being used by this storage document object. | |
Protected Member Functions inherited from owl::TDocument | |
virtual void | AttachStream (TStream &strm) |
called from TStream constructor | |
void | DestroyViews () |
Destroys the views attached to this document. | |
void | DestroyChildren () |
Destroy children first if we have any. | |
Derived from TStorageDocument, TOleDocument implements the document half of the Doc/View pair.
It manages the document's data while the corresponding TOleView object determines how the data is displayed on the screen. Basically, TOleDocument is a TStorageDocument with a knowledge of TOcDocument through its pointer to TOcDocument.
TOleDocument is responsible for creating compound documents, closing documents, reading documents from storage, and writing documents to storage. In the case of a server, the document consists of a single object. In the case of a container, the document can consist of one or more embedded objects (also referred to as parts).
To accomplish these tasks, TOleDocument talks to the underlying ObjectComponents classes through the use of functions such as GetOcApp, GetOcDoc, and SetOcDoc.
ocf::TOleDocument::TOleDocument | ( | owl::TDocument * | parent = 0 | ) |
Constructs a TOleDocument object associated with the given parent TDocument object.
Definition at line 29 of file oledoc.cpp.
ocf::TOleDocument::~TOleDocument | ( | ) |
Destroys the TOleDocument object.
In the case of an OLE container, the compound file remains open until all the views shut down.
Definition at line 41 of file oledoc.cpp.
|
virtual |
Prepares the document for closing.
Before closing the current document, checks to see if all child documents can be closed. If any child returns false, CanClose returns false and aborts the process. If all children return true, CanClose checks to see if the document has been changed. If so, it asks the user to save the document, discard any changes, or cancel the operation. If the document has not been changed and all child documents return true, this CanClose function returns true, thus indicating that the document can be closed. CanClose also calls ReleaseDoc on its associated ObjectComponents document to make sure that all the embedded objects are closed properly.
Reimplemented from owl::TDocument.
Definition at line 58 of file oledoc.cpp.
References ocf::amExeMode, owl::TDocument::CanClose(), CHECK, GetOcApp(), owl::TDocument::GetViewList(), owl::TDocument::IsEmbedded(), and TYPESAFE_DOWNCAST.
|
virtual |
Ensures that the IStorage is released properly and disconnects any active server in the document.
A compound file must be closed before it is reopened.
Reimplemented from owl::TDocument.
Definition at line 107 of file oledoc.cpp.
References ocf::TOcDocument::Close(), ocf::TStorageDocument::Close(), and OleViewClose().
Commits the current document's data to storage.
If force is true and the data is not dirty, all data is written to storage and Commit returns true. If force is false, the data is written only if it is dirty.
Reimplemented from owl::TDocument.
Definition at line 218 of file oledoc.cpp.
References ocf::TStorageDocument::Commit(), and Write().
|
inlinevirtual |
TOcApp * ocf::TOleDocument::GetOcApp | ( | ) |
Returns the ObjectComponents application associated with this TOleDocument object.
Definition at line 317 of file oledoc.cpp.
References owl::TDocument::GetDocManager(), and TYPESAFE_DOWNCAST.
|
inline |
Returns the ObjectComponents document associated with this TOleDocument object.
|
virtual |
Overrides the TDocument::InitDoc function and creates or opens a compound file so that there is an IStorage associated with this document's embedded objects.
Uses a TOcDocument object to perform the actual interaction with the OLE IStorage and IStream interfaces, which are ultimately responsible for establishing the relationship between a compound file and its storage.
Reimplemented from owl::TDocument.
Definition at line 184 of file oledoc.cpp.
References owl::TDocument::GetDocPath(), GetOcApp(), owl::TDocument::GetOpenMode(), ocf::TStorageDocument::IsOpen(), owl::ofNoCreate, owl::ofTemporary, ocf::TStorageDocument::Open(), PreOpen(), owl::TDocument::SetOpenMode(), ocf::TOcDocument::SetStorage(), and ocf::TOcDocument.
void ocf::TOleDocument::OleViewClose | ( | ) |
Shuts down the TOleView's.
Definition at line 90 of file oledoc.cpp.
References owl::TDocument::GetViewList(), and TYPESAFE_DOWNCAST.
Loads the embedded objects, if any, using the path specified in path.
mode is a combination of bits that specify how the embedded objects are opened (for example, read only, read/write, and so on). By default, objects are opened in ofReadWrite and ofTransacted modes.
Reimplemented from owl::TDocument.
Definition at line 233 of file oledoc.cpp.
References Read(), and ocf::TStorageDocument::SetDocPath().
bool ocf::TOleDocument::PathChanged | ( | ) |
Checks to see if the current document's path is the same as the TOcDocument's path.
If the paths are not the same, PathChanged returns true.
Definition at line 244 of file oledoc.cpp.
References _tcsicmp, owl::TDocument::GetDocPath(), and ocf::TOcDocument::GetName().
|
virtual |
Before the document is actually opened, PreOpen gives the derived class a chance to perform a particular operation; for example, setting a different open mode for the compound document.
Definition at line 171 of file oledoc.cpp.
References owl::ofReadWrite, owl::ofTransacted, and owl::TDocument::SetOpenMode().
|
virtual |
Loads the embedded objects from the compound file.
A container should call this function to load any embedded objects.
Definition at line 284 of file oledoc.cpp.
References ocf::TOcDocument::LoadParts().
|
virtual |
Releases the ObjectComponents document when the server is finished using the document.
Reimplemented from ocf::TStorageDocument.
Definition at line 121 of file oledoc.cpp.
References IStorage, PRECONDITION, ocf::TStorageDocument::ReleaseDoc(), and ocf::TOcDocument::SetStorage().
|
virtual |
Restores the original root IStorage before the save operation.
Reimplemented from ocf::TStorageDocument.
Definition at line 155 of file oledoc.cpp.
References PRECONDITION, ocf::TOcDocument::RestoreStorage(), and ocf::TStorageDocument::RestoreStorage().
Performs the reverse of Commit.
Revert cancels any changes made to the document since the last time the document was saved to storage.
Reimplemented from owl::TDocument.
Definition at line 296 of file oledoc.cpp.
References InitDoc(), Open(), ReleaseDoc(), owl::TDocument::Revert(), and owl::TDocument::SetDirty().
|
inline |
Sets the ObjectComponents document associated with this TOleDocument object.
Attaches the IStorage pointer (stg) to this document.
If successful, SetStorage returns true.
Reimplemented from ocf::TStorageDocument.
Definition at line 136 of file oledoc.cpp.
References PRECONDITION, ocf::TStorageDocument::SetStorage(), and ocf::TOcDocument::SetStorage().
|
virtual |
Saves the embedded objects to the compound file.
A container should call this function to save its embedded objects to storage.
Definition at line 253 of file oledoc.cpp.
References owl::TDocument::GetDocPath(), ocf::TStorageDocument::GetNewStorage(), owl::TDocument::IsEmbedded(), IStorage, PathChanged(), ocf::TOcDocument::SaveParts(), and ocf::TOcDocument::SetName().