![]() | InDesign SDK 20.5 |
#include <IBaseVisitor.h>

Public Member Functions | |
| virtual bool16 | InitVisitor (IDataBase *theDB, IBaseHandler *theHandler, bool16 bFinishChildren=kFalse)=0 |
| virtual IBaseHandler * | GetHandler (void) const =0 |
| virtual bool16 | GetFinishChildren (void) const =0 |
| virtual bool16 | VisitChildren (IVisitorHelper *pVisitable)=0 |
| virtual bool16 | VisitSpread (IVisitorHelper *pVisitable)=0 |
| virtual bool16 | VisitSpreadLayer (IVisitorHelper *pVisitable)=0 |
| virtual bool16 | VisitInlineItem (IVisitorHelper *pVisitable)=0 |
| virtual bool16 | VisitSplineItem (IVisitorHelper *pVisitable)=0 |
| virtual bool16 | VisitMultiColumnFrameItem (IVisitorHelper *pVisitable)=0 |
| virtual bool16 | VisitFrameItem (IVisitorHelper *pVisitable)=0 |
| virtual bool16 | VisitGroupItem (IVisitorHelper *pVisitable)=0 |
| virtual bool16 | VisitGuideItem (IVisitorHelper *pVisitable)=0 |
| virtual bool16 | VisitPage (IVisitorHelper *pVisitable)=0 |
| virtual bool16 | VisitImageItem (IVisitorHelper *pVisitable)=0 |
| virtual bool16 | VisitHTMLItem (IVisitorHelper *pVisitable)=0 |
| virtual bool16 | VisitEPSTextItem (IVisitorHelper *pVisitable)=0 |
| virtual bool16 | VisitEPSItem (IVisitorHelper *pVisitable)=0 |
| virtual bool16 | VisitPICTItem (IVisitorHelper *pVisitable)=0 |
| virtual bool16 | VisitWMFItem (IVisitorHelper *pVisitable)=0 |
| virtual bool16 | VisitPDFItem (IVisitorHelper *pVisitable)=0 |
| virtual bool16 | VisitTOPItem (IVisitorHelper *pVisitable)=0 |
| virtual bool16 | VisitOwnedItem (IVisitorHelper *pVisitable)=0 |
| virtual bool16 | VisitWaxAnchoredElementItem (IVisitorHelper *pVisitable)=0 |
| virtual bool16 | VisitParcelItem (IVisitorHelper *pVisitable)=0 |
| virtual bool16 | VisitUnknownItem (IVisitorHelper *pVisitable)=0 |
Public Member Functions inherited from IPMUnknown | |
| virtual IPMUnknown * | QueryInterface (PMIID interfaceID) const =0 |
| virtual void | AddRef () const =0 |
| virtual void | Release () const =0 |
An interface class used in conjunction with IBaseHandler and IVisitorHelper, IBaseVisitor
accomplishes a traversal (or visitation) of an arbitrary structure of connected
nodes -- typically (but not limited to) pageitems on a spread. As the visitor traverses the
structure, it uses each node's IVisitorHelper::Accept() routine to invoke the appropriate method
in the IBaseHandler to accomplish whatever task is required. A depth-first traversal of the node
structure is performed in the visitation scheme.
Using a separate handler is an extension of the visitor design pattern presented
in Gamma, et al, and allows the visitor scheme to be problem-independent. That is, a generic
visitor scheme for traversal can be married with any number of handler bosses, each doing a
specific task or solving a particular problem during the traversal. An example of the use
of the visitor/handler scheme in InDesign is hit-testing.
NOTE: Third-party-created pageitems that are not derived from built-in InDesign page item bosses must contain
an IVisitorHelper interface on the page item boss in order for hit-testing to be supported for the item.
Also, since VisitXXX routines aren't defined for these pageitems in IBaseVisitor,
these should be provided by custom implementations that are added-in to the kBaseVisitorBoss.
InDesign's visitor capability can be extended to support new types of nodes by creating an interface,
say IMyNodeVisitor, and adding it in to kBaseVisitorBoss. It would contain a VisitMyNode routine, as
follows:
<pre>
bool16 MyNodeVisitorImpl::VisitMyNode(IVisitorHelper* pVisitable)
{
bool16 bDone = kFalse;
Get the current handler by asking the base visitor InterfacePtr<IBaseVisitor> baseVisitor(this, UseDefaultIID()); if (baseVisitor) { InterfacePtr<IBaseHandler> theHandler(baseVisitor->GetHandler(), IID_IBASEHANDLER); if (theHandler) { Invoke the handler's HandleMyNode, which is added-in to the handler boss InterfacePtr<IMyNodeHandler> myHandler(theHandler, UseDefaultIID()); if (myHandler) bDone = myHandler->HandleMyNode(pVisitable, this); } } return bDone; }
A custom IMyNodeVisitor may implement an alternative child traversal scheme by providing its own version of VisitChildren. The built-in IBaseVisitor::VisitChildren() implementation is as follows:
bool16 BaseVisitorImpl::VisitChildren(IVisitorHelper* pVisitable)
{
bool16 bDone = kFalse;
fTheHandler and fFinishChildren were cached when InitVisitor was called
if (pVisitable)
{
int32 childCount = pVisitable->CollectChildren(fTheHandler);
for (int32 i = childCount-1; i >= 0 && (fFinishChildren || !bDone); i--)
{
InterfacePtr<IVisitorHelper> aChild(pVisitable->QueryChild(i));
if (aChild)
{
bDone |= aChild->Accept(this);
}
}
}
return bDone;
}
| pure virtual |
Get the bFinishChildren flag
| pure virtual |
Get the handler used in this visitation
| pure virtual |
Initialize the visitor with the database, the handler to use for acting on each node visited, and a flag dictating whether all children of a node should be visited if one returns kTrue.
| theDB | IN IDataBase pointer for database being traversed |
| theHandler | IN IBaseHandler pointer for handler to use for node actions |
| bFinishChildren | IN kFalse if VisitChildren should return immediately after a child returns kTrue from visitation, kTrue if all children should be visited regardless of return value |
| pure virtual |
Visit the children of the node referenced by pVisitable. The base class implementation knows how to use IHierarchy to traverse nodes.
| pVisitable | IN IVisitorHelper pointer for item whose children are to be visited |
| pure virtual |
Visit an ISpread item
| pVisitable | IN IVisitorHelper pointer for item whose children are to be visited |
| pure virtual |
Visit an EPS text item
| pVisitable | IN IVisitorHelper pointer for item whose children are to be visited |
| pure virtual |
Visit a text frame (a child of multicolumn frame item)
| pVisitable | IN IVisitorHelper pointer for item whose children are to be visited |
| pure virtual |
Visit a group item
| pVisitable | IN IVisitorHelper pointer for item whose children are to be visited |
| pure virtual |
Visit a guide item
| pVisitable | IN IVisitorHelper pointer for item whose children are to be visited |
| pure virtual |
Visit an embedded HTML Page Item
| pVisitable | IN IVisitorHelper pointer for item whose children are to be visited |
| pure virtual |
Visit an image
| pVisitable | IN IVisitorHelper pointer for item whose children are to be visited |
| pure virtual |
Visit an inline pageitem
| pVisitable | IN IVisitorHelper pointer for item whose children are to be visited |
| pure virtual |
Visit a multicolumn frame item
| pVisitable | IN IVisitorHelper pointer for item whose children are to be visited |
| pure virtual |
Visit an owned item – that is, owned by a text frame
| pVisitable | IN IVisitorHelper pointer for item whose children are to be visited |
| pure virtual |
Visit a page
| pVisitable | IN IVisitorHelper pointer for item whose children are to be visited |
| pure virtual |
Visit a parcel – not really a pageitem (such as a line of text or a table cell)
| pVisitable | IN IVisitorHelper pointer for item whose children are to be visited |
| pure virtual |
Visit a PDF item
| pVisitable | IN IVisitorHelper pointer for item whose children are to be visited |
| pure virtual |
Visit a PICT item
| pVisitable | IN IVisitorHelper pointer for item whose children are to be visited |
| pure virtual |
Visit a spline, or CGraphicFrameShape item
| pVisitable | IN IVisitorHelper pointer for item whose children are to be visited |
| pure virtual |
Visit an ISpread item
| pVisitable | IN IVisitorHelper pointer for item whose children are to be visited |
| pure virtual |
Visit a spread layer item
| pVisitable | IN IVisitorHelper pointer for item whose children are to be visited |
| pure virtual |
Visit a Text on a Path item
| pVisitable | IN IVisitorHelper pointer for item whose children are to be visited |
| pure virtual |
Visit an item of unknown type (provides generic handling)
| pVisitable | IN IVisitorHelper pointer for item whose children are to be visited |
| pure virtual |
Visit an IWaxAnchoredElement, such as an anchored graphic
| pVisitable | IN IVisitorHelper pointer for item whose children are to be visited |
| pure virtual |
Visit Windows metafile item
| pVisitable | IN IVisitorHelper pointer for item whose children are to be visited |