26 constexpr _TCHAR DocStreamName_[] =
_T(
"OcDocument");
30 constexpr auto MaxPartNameSize_ = 32;
39 Name(fileName?fileName:
_T(
"")),
49 bool createNew =
ToBool(!fileName || !fileName[0]);
51 TRACEX(OcfRefCount, 1,
"TOcDocument() @" << (
void*)
this);
60 Name(fileName?fileName:
_T(
"")),
75 TRACEX(OcfRefCount, 1,
"TOcDocument() @" << (
void*)
this);
94 if (Storage && storage == Storage->GetIStorage())
102 OrgStorage = Storage;
130 Storage = OrgStorage;
174 oldStorage = Storage;
181 if (!
HRSucceeded(Storage->Stat(&statstg, STATFLAG_NONAME)))
184 TOcStream stream(*Storage, DocStreamName_,
true, statstg.grfMode);
190 ulong value = PartCollection.Count();
203 part.
Save(sameAsLoaded, remember));
216 Storage = oldStorage;
243 if (!
HRSucceeded(Storage->Stat(&statstg, STATFLAG_NONAME)))
247 TOcStream stream(*Storage, DocStreamName_,
false, statstg.grfMode);
261 PartCollection.Clear();
265 for (
int i = (
int)value; i; i--) {
266 char name[MaxPartNameSize_ + 1];
274 if (len < 0 || len > MaxPartNameSize_) {
333 LinkCollection.Clear();
355 if (!Name.empty() && ActiveView)
356 ActiveView->Rename();
#define PRECONDITION(condition)
#define TRACEX(group, level, message)
ILinkable abstract base class.
virtual HRESULT _IFUNC OnRename(IBLinkable *pContainer, LPCOLESTR name)=0
void SetActiveView(TOcView *view)
void RenameParts(IBRootLinkable *bLDocumentI)
bool SaveParts(IStorage *storage=0, bool sameAsLoaded=true, bool remember=true)
Save the embedded parts to the provided storage.
friend class _ICLASS TOcView
TOcDocument(TOcApp &app, LPCTSTR fileName=0)
void SetStorage(IStorage *storage, bool remember=true)
Set the storage for this document.
bool SaveToFile(LPCTSTR newName)
Perform saveas operation.
bool RestoreStorage()
Restore the original root IStorage before the save operation.
bool LoadParts()
Loads the parts from the current storage into the PartCollection.
void SetName(const owl::tstring &newName)
Notify container that doc pathname has changed.
Link Viewer object for a server document.
void Disconnect()
Disconnect from the client site.
OC part class represents an embeded or linked part in a document.
bool Close()
Disconnect servers by closing & releasing our BOle helper.
TOcPart(TOcDocument &document, int id=0)
Construct a new part with a given temp id Must call Init method to complete initialization.
bool Save(bool SameAsLoad=true, bool remember=true)
Save this part to storage.
HRESULT _IFUNC QueryInterface(const GUID &iid, void **iface)
TOcStorage(LPCTSTR fileName, bool create, owl::uint32 mode=STGM_READWRITE|STGM_TRANSACTED)
HRESULT Write(void const *pv, owl::ulong cb, owl::ulong *written=0)
HRESULT Read(void *pv, owl::ulong cb, owl::ulong *read=0)
Array of pointers of simple types.
int Length() const
The length in characters of this string.
Include for OC, gets common headers when precompiled headers are enabled.
Object Component Framework (COM encapsulation).
bool HRSucceeded(HRESULT hr)
TOcPartCollection::Iterator TOcPartCollectionIter
TOcLinkCollection::Iterator TOcLinkCollectionIter
Iterator for view collection.
auto to_tstring(const T &v) -> tstring
DIAG_DECLARE_GROUP(OwlThread)
Definition of TOcApp application connection class.
Definition of TOcDocument Class.
interface _ICLASS IStorage
Definition of TOcPart class.
Definition of TOcRemView Class.
Definition of TOcStorage & TOcStream classes.
Low level OLE Utility class definitions.
General definitions used by all ObjectWindows programs.