
Adobe Acrobat SDK
Working with Host Function Tables
Developing Plug-ins and Applications
Replacing HFT methods 175
When an HFT entry is replaced, the entry’s linked list is updated so that the newly-added implementation
is at the head of the linked list. Previous implementations, if any, follow in order, as shown in the following
diagram.
To replace an HFT method, perform the following tasks:
●
Invoke the
ASCallbackCreateReplacement
macro to create the callback pointer.
●
Invoke the
REPLACE
macro to replace the desired method and pass the following arguments:
●
The
HFT
object in which the method is replaced.
●
The entry in the HFT to replace. Append SEL to the method's name. For example, to replace the
AVAppCanQuit
method, specify
AVAppCanQuitSEL
.
●
The address of the replacement method.
The following example shows how to replace the
AVAppCanQuit
method with a custom method named
MyAvAppCanQuit
. The
MyAVAppCanQuit
method’s arguments and return value are identical to those of
the
AVAppCanQuit
method. Replaceable methods must be replaced with methods that have the same
arguments and return type.
The first statement in the following code example initializes a global pointer named
gMyAVAppCanQuitPtr
to your replacement method. You can use this pointer to invoke the original
method. For example, you can invoke your replacement method to exhibit custom functionality and then
invoke the original method. To invoke the original method, use the
CALL_REPLACED_PROC
macro and
pass the pointer to your replacement method. For more information about this macro, see the
Acrobat and
PDF Library API Reference
.
Example 16.6
Replacing an HFT method
void* gMyAVAppCanQuitPtr = NULL;
/*
** A function that informs the application whether it’s OK to quit.
** When quitting, only allow exit when all docs are closed.
*/
ACCB1 ASBool ACCB2 MyAVAppCanQuit (void)
{
if (AVAppGetNumDocs () == 0)
return true;
else
return false;