
Adobe Acrobat SDK
Working with Acrobat Extended APIs
Developing Plug-ins and Applications
Creating an agent class 227
Each Cos object has a simple Cos type and attributes, in the scheme of the document as a whole each
object serves a particular purpose. The PDF object type assigned to each object represents that object's
role in the PDF document.
Some PDF object types represent higher-level, conceptually-familiar objects like
PT_PAGE
(which
indicates that the object is a page in the document), while others (like
PT_AADICTIONARY
) are a bit more
obscure, particularly to those who are not familiar with the PDF document format. PDF object types are
represented using the enumerated type
PDFObjType
, which is defined in ConsObTp.h. A good way to see
all of the various PDF object types that the consultant can identify is to look at the constants defined in
that file.
Some object types (in particular many simpler objects such as strings and numbers) are not assigned a
particular type. The consultant can identify those objects that are of most use to you. If the consultant
cannot identify a specific object, it assigns the identity of
PT_UNKNOWN
to the object. Just because the
consultant assigns this value to an object does not mean the object is foreign or invalid (although it can
potentially mean that), it may simply mean that the object type is not particularly significant in the realm
of the PDF document format, and thus the consultant does not know about it.
To allow for greater agent flexibility, the consultant understands PDF object type subclasses and
superclasses. Certain PDF object types are members of more generic classes of PDF object type. Agents
can often make use of this information, so the consultant assigns object types that are actually arrays of
types.
The consultant assigns to an object the most specific classification as well as the more generic classes of
which the object is a member. Agent structures include a field called
WantSubclasses
that indicates
whether or not the agent wants to be called for all the interesting objects’ subclasses as well as their
directly interesting types.
For example, the
PT_ANNOTATION
object type has a number of more specific subclasses such as
PT_LINKANNOTATION
,
PT_LINEANNOTATION
, and so on. If an agent requests only objects of type
PT_ANNOTATION
, and its
WantSubclasses
member is
false
, it may not be called back for very many
objects. If the
WantSubclasses
member is
true
, then the consultant will invoke the agent back for
objects of all specific types of annotations as well as those classified only as
PT_ANNOTATION
. This also
means that when an agent retrieves the type of an object, it must specify which type it wants. The types in
the array that is the classification of the object always go from the most specific (at index 0) to the least
specific (the last index in the array).
Creating an agent class
A minimal
Agent
class needs only to define the functions defined as virtual in the
ConsultantAgentObject
class declared in ConsExpt.h. The following example shows this definition.
Example 20.4
Creating an agent class
#include "ConsExpt.h"
class DumpAllObjectsAgent : public ConsultantAgentObj
{
protected:
//Data members
FILE* m_DumpFile;
const static PDFObjType s_hAgentObjects[ ];
const static ASUns32 s_iNumAgentObjects;
public: