InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
PstLstDocObserver Class Reference
Inheritance diagram for PstLstDocObserver:
CObserverIObserverIPMUnknown

Public Member Functions

 PstLstDocObserver (IPMUnknown *boss)
 
virtual ~PstLstDocObserver ()
 
void AutoAttach ()
 
void AutoDetach ()
 
virtual void Update (const ClassID &theChange, ISubject *theSubject, const PMIID &protocol, void *changedBy)
 
- Public Member Functions inherited from CObserver
 CObserver (IPMUnknown *boss, PMIID interfaceID=IID_IOBSERVER)
 
IChangeManagerGetChangeManager () const
 
virtual void SetAttachIID (PMIID iid)
 
virtual PMIID GetAttachIID () const
 
virtual void SetEnabled (bool16 state)
 
virtual bool16 IsEnabled () const
 
virtual void LazyUpdate (ISubject *theSubject, const PMIID &protocol, const LazyNotificationData *data)
 

Protected Member Functions

void AttachDocument (IDocument *iDocument)
 
void DetachDocument (IDocument *iDocument)
 
void HandlePageItemDeleted (void *changedBy)
 

Additional Inherited Members

- Public Types inherited from IObserver
enum  { kDefaultIID = IID_IOBSERVER }
 
- Protected Attributes inherited from CObserver
bool16 fDetachSubjectsOnDelete
 
PMIID fAttachIID
 
const UIDRef fThisRef
 
bool16 fEnabled
 

Detailed Description

This observer observes the front document's IID_IHIERARCHY_DOCUMENT protocol, so when a page item is deleted from the document, this observer will be notified. This is needed because we want to be notified Before the page item is about to be deleted so this implementation can have a chance to delete the instances of persistent list items associated with the said page item, otherwise if we wait until SelectionAttributeChanged of my CSB gets called, it's too late; The page item will have been deleted from the hierarchy, and all of instances of persistent list items will be left dangling somewhere in memory (= boss leaks)! This observer gets attached with the ISubject of kDocBoss when a document is opened or created, through the use of a open/new document responder, and this observer is detached when a document is closed, through the use of a close document responder.

See Also
PstLstDocResponder

Constructor & Destructor Documentation

Binds the C implementation class onto its ImplementationID making the C code callable by the application * PstLstDocObserver::PstLstDocObserver (IPMUnknownboss)

Constructor.

Parameters
bossIN interface ptr from boss object on which this interface is aggregated.
PstLstDocObserver::~PstLstDocObserver ()
virtual

Destructor.

Member Function Documentation

void PstLstDocObserver::AttachDocument (IDocumentiDocument)
protected

Attaches this observer to a document.

Parameters
iDocumentIN The document to which we want to attach.
void PstLstDocObserver::AutoAttach (void )
virtual

Called by the application to allow the observer to attach to the subjects to be observed (kDocBoss)

Reimplemented from CObserver.

void PstLstDocObserver::AutoDetach (void )
virtual

Called by the application to allow the observer to detach from the subjects being observed.

Reimplemented from CObserver.

void PstLstDocObserver::DetachDocument (IDocumentiDocument)
protected

Detaches this observer from a document.

Parameters
iDocumentIN The document from which we want to detach.
void PstLstDocObserver::HandlePageItemDeleted (void * changedBy)
protected

The selected page items are about to be deleted, call IPstLstSuite's function to delete its associated IPstLstData objects. It is called when we get the pre-notification of deletion of page items.

Parameters
changedByIN points to additional data about the change.
See Also
PstLstDocObserver::Update
void PstLstDocObserver::Update (const ClassIDtheChange,
ISubjecttheSubject,
const PMIIDprotocol,
void * changedBy 
)
virtual

Update is called for all registered observers, and is the method through which changes are broadcast. In this case, the only things we are interested in are if the drop down list selection has changed and if a page item is deleted from the document.

Parameters
theChangeIN specifies the class ID of the change to the subject. Frequently this is a command ID.
theSubjectIN points to the ISubject interface for the subject that has changed.
protocolIN specifies the ID of the changed interface on the subject boss.
changedByIN points to additional data about the change. Often this pointer indicates the class ID of the command that has caused the change.

Implements IObserver.