InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IDocumentUtils Class Referenceabstract

#include <IDocumentUtils.h>

Inheritance diagram for IDocumentUtils:
IPMUnknown

Public Types

enum  { kDefaultIID = IID_IDOCUMENTUTILS }
 
enum  WhatToClose {
  kCloseDocOnly = (1 << 0), kCloseLibrariesOnly = (1 << 1), kCloseBooksOnly = (1 << 2), kCloseBooksAndLibrariesOnly = (kCloseBooksOnly | kCloseLibrariesOnly),
  kCloseDocAndBooks = (kCloseDocOnly | kCloseBooksOnly), kCloseDocAndLibraries = (kCloseDocOnly | kCloseLibrariesOnly), kCloseAll = (kCloseDocOnly | kCloseBooksOnly | kCloseLibrariesOnly)
}
 
enum  {
  kCropProxyImages = (1 << 0), kResampleProxiesOfScaledImages = (1 << 1), kDeleteUnusedMasterPages = (1 << 2), kDeleteUnusedSwatches = (1 << 3),
  kDeleteUnusedXMLTags = (1 << 4), kDeleteUnusedLayers = (1 << 5), kOptimizeEverything = 0xFFFF
}
 
enum  PromptForSave { kDontSaveAll, kAsk, kSaveAll, kSaveAllDontAsk }
 

Public Member Functions

virtual bool16 CheckOnClose (IDocument *doc, bool16 allowCancel=kTrue)=0
 
virtual ErrorCode DoSaveAs (IDocument *doc)=0
 
virtual ErrorCode DoSave (IDocument *doc)=0
 
virtual ErrorCode DoSaveACopy (IDocument *doc)=0
 
virtual bool16 IsAnyDocModified (void)=0
 
virtual bool16 SaveAll (void)=0
 
virtual bool16 SaveAllModified (bool16 abortOnErr=kFalse, bool16 reportErrs=kFalse, bool16 saveUntitled=kFalse)=0
 
virtual bool16 CloseAll (bool16 allowCancel=kTrue, bool16 prompt=kTrue, WhatToClose closeWhat=kCloseDocOnly)=0
 
virtual ErrorCode ProcessCloseAllAndQuit (bool16 allowCancel=kTrue, PromptForSave prompt=kAsk)=0
 
virtual ErrorCode ScheduleCloseAllAndQuit (bool16 allowCancel=kTrue, PromptForSave prompt=kAsk, ICommand::Priority priority=ICommand::kLowPriority)=0
 
virtual IDocFileHandlerQueryDocFileHandler (const UIDRef &doc)=0
 
virtual IDataBase::DBResultCode DocDBCallback (int32 stepsDone, int32 stepCount)=0
 
virtual bool OptimizeForSize (IDocument *doc, uint32 options)=0
 
virtual void LogAndSetDBError (ErrorCode errCode, IDataBase *db)=0
 
virtual void LogAndSetDBError (ErrorCode errCode, const IDFile *file, IDataBase *db)=0
 
virtual void GetTQMissingFontsOnDoc (IDocument *doc, std::vector< std::string > &fontAvailableOnTQ)=0
 
virtual ErrorCode ValidateDocumentStructures (IDataBase *db, ClassID validateClassID=0)=0
 
- Public Member Functions inherited from IPMUnknown
virtual IPMUnknownQueryInterface (PMIID interfaceID) const =0
 
virtual void AddRef () const =0
 
virtual void Release () const =0
 

Detailed Description

Interface containing various utility methods for documents.

Member Enumeration Documentation

anonymous enum

File Size Optimization options.

Prompt options for saving modified documents before close.

Close options for the CloseAll method.

Member Function Documentation

virtual bool16 IDocumentUtils::CheckOnClose (IDocumentdoc,
bool16 allowCancel = kTrue 
)
pure virtual

Check if the document is saved before close document window, if the document is modified, prompt for save.

Parameters
docThe document about to close
allowCancelif allow cancel save
Returns
kTrue if the document is not modified or is saved kFalse if document is modified and save is cancelled.
virtual bool16 IDocumentUtils::CloseAll (bool16 allowCancel = kTrue,
bool16 prompt = kTrue,
WhatToClose closeWhat = kCloseDocOnly 
)
pure virtual

CloseAll closes all open documents. This optionally includes books and libraries.

Parameters
allowCancelCan this close be cancelled.
promptShould users be allowed to save modified documents.
closeWhat[IN] - Indicates which combination of Document, Books and Libraries to close.
Returns
kTrue if the operation was succesful, kFalse if an error ocurred.
Postcondition
All documents up until error will be closed.
virtual ErrorCode IDocumentUtils::DoSave (IDocumentdoc)
pure virtual

Save the document

Parameters
docThe document to save
Returns
Global Errorcode after save
virtual ErrorCode IDocumentUtils::DoSaveACopy (IDocumentdoc)
pure virtual

Save document a copy. The differences between SaveACopy and SaveAs are:

  • SaveACopy() save another copy to disk, IDocument still refers to current document
  • SaveAs() leave current document unchanged (and closed), but IDocument refers to newly saved file.
    Parameters
    docthe document to save a copy
    Returns
    Global ErrorCode after SaveACopy
virtual ErrorCode IDocumentUtils::DoSaveAs (IDocumentdoc)
pure virtual

Save the document as a new file. Will brought up save as dialog by calling IDocFileHandler::SaveAs()

Parameters
docThe document to save as
Returns
Global Errorcode after save-as.
virtual void IDocumentUtils::GetTQMissingFontsOnDoc (IDocumentdoc,
std::vector< std::string > & fontAvailableOnTQ 
)
pure virtual

Gets the missing font list from the document which are available on TypeQuest

Parameters
doc[IN]: The document to get missing font list from.
fontAvailableOnTQ[IN]: Vector to store missing fonts list on TQ
virtual bool16 IDocumentUtils::IsAnyDocModified (void )
pure virtual

If any open document is modified

Returns
kTrue if any opend document is modifed, otherwise kFalse
virtual void IDocumentUtils::LogAndSetDBError (ErrorCode errCode,
IDataBasedb 
)
pure virtual

FOR INTERNAL USE ONLY. Log the database open failure and set the global error state

Parameters
errCode[IN]: the errorCode to set
db[IN],:The database of the document
virtual void IDocumentUtils::LogAndSetDBError (ErrorCode errCode,
const IDFilefile,
IDataBasedb 
)
pure virtual

FOR INTERNAL USE ONLY. Log the database open failure and set the global error state

Parameters
errCode[IN]: the errorCode to set
db[IN],:The database of the document
virtual bool IDocumentUtils::OptimizeForSize (IDocumentdoc,
uint32 options 
)
pure virtual

Attempt to decrease the total binary file size of the given document.

Parameters
doc[IN]: The document to optimize.
options[IN]: How to optimize
Returns
true if optimizations were found, false otherwise.
virtual ErrorCode IDocumentUtils::ProcessCloseAllAndQuit (bool16 allowCancel = kTrue,
PromptForSave prompt = kAsk 
)
pure virtual

Process close all documents, books, and libraries, then schedule a quit of the application.

Parameters
allowCancelCan this close be cancelled.
promptShould users be allowed to save modified documents.
Returns
kSuccess or an error code.
virtual IDocFileHandler* IDocumentUtils::QueryDocFileHandler (const UIDRefdoc)
pure virtual

Query DocFileHandler of the document. This mean we may have different DocFileHanders which could be specified in IID_ICLASSIDDATA in DocumentBoss

Parameters
docthe document UIDRef
Returns
IDocFileHandler for the given document.
virtual bool16 IDocumentUtils::SaveAll (void )
pure virtual

Save all documents

Returns
kTrue if all document successfully save kFalse if any error ocuurred during save, (and leaving remaining document not saved)
virtual bool16 IDocumentUtils::SaveAllModified (bool16 abortOnErr = kFalse,
bool16 reportErrs = kFalse,
bool16 saveUntitled = kFalse 
)
pure virtual

Save all modified document

Parameters
abortOnErrif kTrue, stop saving other documents when error occurs if kFalse(default), contunue to save other documents when encounter an error
reportErrsif kTrue, bring up alert when error if kFalse, don't alert
saveUntitledif kTrue, also save Untitled (never saved) documents if kFalse, don't save Untiled documents
Returns
If all modified document saved without error.
virtual ErrorCode IDocumentUtils::ScheduleCloseAllAndQuit (bool16 allowCancel = kTrue,
PromptForSave prompt = kAsk,
ICommand::Priority priority = ICommand::kLowPriority 
)
pure virtual

Schedule close all documents, books, and libraries, then schedule a quit of the application.

Parameters
allowCancelCan this close be cancelled.
promptShould users be allowed to save modified documents.
priorityat which the scheduled command should be processed.
Returns
kSuccess or an error code.
virtual ErrorCode IDocumentUtils::ValidateDocumentStructures (IDataBasedb,
ClassID validateClassID = 0 
)
pure virtual

Validate document structures

Parameters
dbThe database of the document
validateClassIDClassID for validator Boss, for specific validation, 0 for all registered validators.
Returns
ErrorCode. Check result.