I need to get notified when any master spread is selected from InDesign or pages are inserted/deleted from any master spread.
For this, I have implemented a custom observer derived from CObserver.
In AutoAttach(), the code is as follows,
InterfacePtr<IWorkspace> docWorkspace(doc->GetDocWorkSpace(), UseDefaultIID());
if( !docWorkspace )
InterfacePtr<ISubject> docSubject(docWorkspace, UseDefaultIID());
if( !docSubject )
docSubject->AttachObserver(this, IID_ISPREADLIST, IID_IABCDOCOBSERVER);
docSubject->AttachObserver(this, IID_ICURRENTSPREAD, IID_IABCDOCOBSERVER);
docSubject->AttachObserver(this, IID_IMASTERSPREADLIST, IID_IABCDOCOBSERVER);
docSubject->AttachObserver(this, IID_IPAGEPREFERENCES, IID_IABCDOCOBSERVER);
I have observed these protocols but still don't get any notification when any spread is selected (set to active spread) or pages are added in any master spread.
Please let me know which interface should be observed to get notified for the same? Am I correct in checking the document workspace as subject?
Please help me out. Thanks in advance.
Even if the method AutoAttach exists, it doesn't imply it will call automatically. You should call AutoAttach yourself.
You need also e.g. a responder service (maybe Startup/Shutdown) from where you will call all AutoAttach methods of your observers.
It is better to AddIn your IID_IABCDOCOBSERVER to existing boss-class (kWorkspaceBoss or kDocumentBoss).
Thanks for replying Suraba.
I have already created my custom observer, IID_IABCDOCOBSERVER and added it in my dialog's class. I'm calling its Auto-attach whenever my plugin is opened. I'm already using this for observing GridPreferences, PagePreferences etc. This works fine for them.
Now I have to observe the change in active spread & still looking for the solution.
Suppose there are 3 master spreads on any document, ABC-1, ABC-2, ABC-3.
ABC-1 is the currently active spread. Now, if I select ABC-2 from InDesign, I want to get its notificaiton. Plz help me out.
I need to clarify what kind of event you're interested in.
1. When you click once on page/spead widget in the Pages panel and only widget becomes selected. The layout window remains unchanged. OR
2. When you doubleclick on page/spread widget the selected master spread appears in the layout window.
In the first case you work with Pages panel.
Have a look to file PageTransitionsPanelObserver.cpp from SDK.
In the second case you work with Layout window.