license. The content of this ma nual is furnished for information al us e onl y, is subject to change without noti c e, and should not be construed as a
commitment by Adobe Systems Incorporated. Adobe Systems Incorporated assumes no responsibility or liability for any errors or inaccuracies that
may appear in this book.
Except as permitted by such license, no part of this publication ma y be reproduced, stored in a retrieval system, or transmitted, in any form or by
any means, electronic, mechanical, recording, or othe rw ise , without the prior written permission of A dobe Systems Incorporated.
Please remember that existing artwork or images that you ma y w a nt t o inc lu de in your project may be protected un der copyright law. The
unauthorized incorpora ti on of suc h m at er ia l in to your ne w w ork could be a violation of the right s of the cop yright owner. Please be sure to obtain
any permission required from the copyright owner.
Any references to company names in sample templates are for demonstration purposes only and are not intended to refer to any actual organization.
Adobe, the Adobe logo, Ac robat, Acrobat Reader, Adobe Typ e Ma na ge r, ATM, D ispl a y PostSc ri pt, Dist il ler, Exchange, Frame, FrameM aker,
FrameViewer, InstantView, and PostScript are trademarks of Adobe Systems Incorporated.
Apple, Power Book, QuickT ime, Mac int osh a nd Power Maci ntos h are tradem arks of A pple Com puter , Inc. , re giste red in the Un ited Stat es and othe r
countries. Fo coltone is a re gistered trademark of Gordon Phil lips Limite d. ImageStr eam Graphic s Filters and ImageStream are registered trademarks
of Inso Corporation. Microsoft, MS-DOS, Windows, and Windows NT are either reg is tered trademarks or trademarks of Micro s of t Corporation in
the United States and/or other countries. Quadralay and WebWorks are registered trademarks of Quadralay Corporation. PANTONE, PANTONE
MATCHING SYSTEM, PANTONE Process Color System, and POCE are trademar ks of Pantone, Inc. Proximity and Linguibase are
registered trad emar ks of P ro ximit y Techn olo gy I nc. A Me rri am-We bs ter is a re gi ste red trad emar k of Mer ria m- Webst er Inc . Su n is a trad emar k or
registered trademark of Sun Microsystems, Inc. in the United States and other countries. TRUMATCH is a registered trademark of Trumatch Inc.
Unix is a registered trademark and X Window System is a trademark of The Open Group. Verity and TOPIC are registered trademarks of Verity,
Inc. All other trademarks are property of their respective owners.
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE
SOFTWARE. APPLE DOES NOT WARRANT, GUARANTEE, OR MAKE ANY REPRESENTA-TIONS REGARDING THE USE OR THE
RESULTS OF THE USE OF THE APPLE S OFTWARE IN TERM S OF ITS COR RECTNESS, ACC URACY, RELI ABILITY, CU RRENTNESS,
OR OTHERWISE. THE ENTIRE RISK AS TO THE RESULTS AND PERFORMANCE OF THE APPLE SOFTWARE IS ASSUMED BY YOU.
THE EXCLUSION OF IMPLIED WARRANTIES IS NOT PERMITTED BY SOME STATES. THE ABOVE EXCLUSION MAY NOT APPLY
TO YOU.
IN NO EVENT WILL APPLE, ITS DIRECTORS, OFFICERS, EMPLOYEES, OR AGENTS BE LIABLE TO YOU FOR ANY
CONSEQUENTIAL, INCIDENTAL, OR INDIRECT DAMAGES (INCLUDING DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS
INTERRUPTION, LOSS OF BUSINESS INFORMATION, AND THE LIKE) ARISING OUT OF THE USE OR INABILITY TO USE THE
APPLE SOFTWARE EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME STATES DO
NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE
LIMITATIONS MAY NOT APPLY TO YOU.
Adobe Systems Incorporated, 345 Park Ave nue, San Jose, California 95110, USA
Notice to U.S. gov ernment end users. Th e s o ft w are and documentat ion are “commerci al items,” as that te rm is defined at 48 C.F.R . §2. 101,
consisting of “commercial computer software” and “commercial computer software documentation,” as such terms are used in 48 C.F.R. §12.212
or 48 C.F.R. §227.7202, as applicabl e. Consistent with 48 C.F.R. §12.212 or 48 C.F.R. §§227.7202-1 through 227.72 02-4, as applicable, the
commercial computer softwa re and commercial computer soft w ar e do cumentation are being licensed to U.S. government end users (A) only as
commercial items and (B) with onl y th ose rights as are granted to all other end users pursuant to the terms and conditions set forth in the Adobe
standard commercial agreement for this software. Unpublishe d rights reserved under the copyrig ht laws of t he United States.
The Frame Developer’s Kit (FDK) provides tools for developers to enhance the
functionality of FrameMaker
aspects of FrameMaker that are useful for developers. It also discusses the FDK
documentation.
The principal parts of the FDK are:
● Frame Application Program Interface
● Frame Development Environment
● Frame Structure Import/Export Application Program Interface (Structure Import/Export
The following sections describe these parts and discuss how you can use them.
Frame API
The Frame API allows you to write C language programs, called FDK clients, that can take
control of a FrameMaker product session and communicate interactively with the user. With
the API, a client can do nea rly ev er ything an in teracti v e user ca n do and more. The API gi v es a
client direct access to the text and graphic objects in documents. The API includes a set of
header files, libraries, and makefiles for each supported platform. Here are some examples of
the types of clients you can create with the API:
● Grammar checkers
API)
. This chapter provides an overview of the FDK and other
(API)
(FDE)
● Bibliography utilities
● Voice control utilities
● Document reporting utilities
● Version control systems for documents
● Table utilities, such as sorting and totali ng
● Database publishing packages
● Interfaces to document management systems
● Filters to exchange files between other desktop publishing applications and FrameMaker
FDK Programmer’ s Guideix
Using Frame Deve loper Tools
FDE
The Frame Development Environment (FDE) helps you make your client portable to all
platforms supported by FrameMaker. It provides platform-independent alternatives to
platform-specific I/O, string, and memory allocation schemes. It also provides a variety of
utility functions, such as Maker Interchange Format (MIF) writing functions. Frame
encourages you to use the FDE to develop all your clients. The FDE includes header files and
libraries for each supported platform.
Structure Import/Export API
The Structure Import/Expo rt API al lows you to write client s that co ntrol the import of markup
documents into FrameMaker, and control the export of FrameMaker documents to markup
(XML or SGML).
Other FrameMaker features for developers
MIF
fmbatch
FrameMaker provides other advanced features that are useful for developers. You do not need
the FDK to use these features.
Maker Interch ange Form at (MIF) is an easi ly parsed ASCII format that de scribes a docum ent’ s
text, graphics, formatting, and layout. FrameMaker can save a document or a book to a MIF
file, and convert a MIF file back to a document or book, without losing any information.
You can write applications or sc ripts that convert a MIF file to the format of another desktop
publishing package, or convert other formats to MIF.
Here are some examples of things you can use MIF for:
● Sharing files with earlier releases of Fr ameMaker products
● Converting database files into Frame documents
● Filtering word processor documents into Frame documents
You can find documentation for MIF in the online manuals folder for your FrameMaker
installation.
The fmbatch utility is shipped with UNIX versions of FrameMaker. It allows you to open,
print, reformat, and save FrameMaker product files without displaying them. You can use
fmbatch directly at a UNIX graphics workstation or in a remote shell from a nongraphics
terminal. The fmbatch utili ty pro vides interac tiv e a nd batch mode s. When you use it in ba tch
xFDK Programmer’s Guide
mode, you can execute operations on multiple files automatically. For example, you can use
fmbatch for:
● Printing books or documents from a remote location
● Printing multiple books or docume nts automati cally
● Updating multiple books or documents automatically
● Converting multiple books or documents to MIF
For more information on the fmbatch utility, see the FrameMaker product user
documentation for UNIX platforms.
Choosing the right Frame tools
There are often several tools or combinations of tools that you can use to solve a given
problem. In particular, you can use the API to perform many of the tasks that MIF and
fmbatch perform. The tool or combination of tools you should use depends on your needs.
Generally, MIF and fmbatch are more useful for one-time solutions to small problems,
whereas the API is more useful for full-scale applications or applications where interaction
with the user is required.
Using Frame Developer Tools
The following table summarizes the advantages and limitations of each Frame tool.
Frame tool
or featureAdvantagesLimitations
Frame APIFast, interactive, and portable; easy to provide a user
interface for your applications
MIFCan be used by text-processing utilities or UNIX shell
script. It can also be used to provide “backwards”
compatibility allowing files to be opened in earlier releases
of the product.
Third party MIF creators do not need to write complete
MIF. FrameMaker will always write out complete MIF.
fmbatch
Doesn’t require C pr ogramming ; can be used remotely fr om
a nongraphics terminal
FDK documentation
FDK documentation assumes that you have a thorough knowledge of FrameMaker. For
background information on FrameMaker, see your user documentation.
Must be compiled
Files must be saved as
MIF; not interactive
Only provides simple
functions; only
available on UNIX
platforms
FDK documentation includes the following manuals.
FDK Programmer’ s Guidexi
Using Frame Deve loper Tools
FDK Platform Guide
The FDK Platform Guide is printed in several versions, each describing how to install the
FDK on a specific platform. It provides the pathnames of sample programs and describes
platform-specific differences in using the FDK.
FDK Programmer’s Guide
The FDK Programmer’s Guide describes how to use the FDK to create clients for
FrameMaker. To get the most from this manual, you should be familiar with the C
programming language and event-driven programming.
The FDK Programmer’s Guide is divided into thre e parts:
● Part I, Frame Application Program Interface (API), provides instruct ions for creating API
clients.
● Part II, Frame Product Architecture, provides a conceptual overview of how the API
represents sessions, books, and documents.
● Part III, Frame Development Environment (FDE), provides instructions for making filters
and API clients platform-independent.
FDK Programmer’s Reference
The FDK Programmer’s Guide, which you are reading now, provides FDK reference
information, such as error codes and data structure, function, and property descriptions.
Structure Import/Export API Programmer’s Guide
The Structure Import/Export API Programmer’s Guide provides instructions and reference
information for using the Structure Import/Export API.
Naming conventions
To help you identify the structures, constants, and functions defined by the FDK, this manual
and the FDK adhere to the following naming conventions:
TypeNaming conventionExample
API error codesBegin with FE_
API functionsBegin with F_Api
API scriptable function
property names
Begin with FS_
FE_NotPgf
F_ApiGetInt()
FS_NewDoc
FDE functionsBegin with F_
F_StrNew()
xiiFDK Programmer’s Guide
Using Frame Developer Tools
TypeNaming conventionExample
Flags used by API functionsBegin with FF_ and all let t e r s
Initialization constantsBegin with FA_Init
Notification constantsBegin with FA_Note
Object property namesBegin with FP_
Object typesBegin with FO_
Property value constantsBegin with FV_
TypedefsEnd with T
This manual uses the term API graphic object to refer to objects (such as FO_Polygon and FO_TextFr ame objects ) th at t he API uses to represent the gr aphi c obj ec ts (such as polygons
and text frames) that appear on a page.
Style conventions
FDK manuals distinguish between you, the developer, and the user, the person for whom you
write clients.
FF_UFF_VAR
are uppercase
FA_Init_First
FA_Note_PreFileType
FP_Fill
FO_Doc
FV_Doc_Type_MIF
MetricT
FDK manuals may use the term FrameMaker product t o re fe r to the FrameMaker software, as
opposed to the software you write to work with the FrameMaker product.
Structured program interface
FrameMaker 7.0 and later ships with two program interfaces—Structured FrameMaker and
FrameMaker. The structured program interface presents menus, icons, and commands for
working with structured documents. The FDK includes some functions that only work on
structured documents. For example, setting an element range makes no sense in a document
that doesn’t contain any structure elements. Further, you can specify that an FDK client
requires the Structured FrameMaker program interface. For example, assume you specify
Structured FrameMak er when you re gi ster your cl ient. I f a use r has you r cli ent ins tall ed, b ut i s
running the FrameMaker program interface (not structured), then his installation of
FrameMaker will not initialize your client when it starts up. (In earlier versions you could
specify which FrameMaker products would initialize your client; FrameMaker,
FrameMaker+SGML, or FrameViewer.)
The FDK Programmer’s Refer e nce indicates tho se FDK functions th at apply only to structured
FrameMaker documents, as follows:
FDK Programmer’ s Guidexiii
Using Frame Deve loper Tools
Structured
In this example the word Structured appears to the left of the function name, indicating that
this function applies only to the content of a structured document. If you register a client to
work with the FrameMaker program interface, you should be sure that your client doesn’t use
any functions identified as Structured, otherwise your client may exhibit unpredictable
behavior.
Pathnames
Code examples in this manual use UNIX pathnames. For example:
If you are using the FDK on the Macintosh or on Windows, change the code to use the
filepath naming conventions for those platforms. F or e x ampl e, on Macintosh, change t he cod e
above to code like the following:
The FDK provides functions for converting platform-specific filepaths. For more information,
see “Making I/O portable with channels” on page 377 of the FDK Programmer’s Guide.
F_ApiGetAttributeDefs()
Typographic conventions
This manual uses different fonts to represent different types of information.
● What you type is shown in
text like this.
● Function names, property names, structure names, returned values, constants, filter names,
program names, pathnames, and filenames are also shown in
text like this.
● Placeholders (such as those representing names of files and directories) are shown in
text like this.
For example, this represents the name of your working directory:
/Mydir
● Omitted code in source code examples is indicated with ellipses.
For example, the el lipsi s in the foll o wi ng code indic ates th at some of th e code necess ary to
create a complete program is omitted:
. . .
F_ApiAlert((StringT)"Hello w orld.", FF_ALERT_CONT INUE_NOTE);
xivFDK Progra mmer’s Guide
PartI
Frame Application Program Interface
(API)
FDK Programmer’ s Guide1
2FDK Programmer’s Guide
Introduction to the Frame API
1
This chapter provides an overview of how the API works and how to create an FDK client. It
also provides a simple example—a client that you can create and run right away.
The API enables you to create a client that takes control of a FrameMaker product session.
With the API, a client can do almost anything an interactive user can do. It can create, save,
and print documents; add and del ete te xt and gra phics; an d perform man y other formatti ng and
document-management tasks. It can also interact with the user by responding to user actions,
displaying dialog boxes, and creating menus.
How the API works
The API represents e v eryth ing in a Fr ameMaker pr oduct ses sion as an object.1 Each object has
a type, a constant that indicates the type of thing it represents. For example, an object’s type
can be FO_Doc (if it represents a document), FO_Rectangle (if it represents a graphic
rectangle), or FO_Pgf (if it represents a paragraph).
FrameMaker products assign an identifier (ID) to each object in a session. You use this ID to
identify an object when you call API functions.
An object’s characteristics are called properties. Each type of object has a particular set of
properties or a property list. For example, an FO_Rectangle object’s property list includes
properties named FP _Width and FP_Height, which represent its height and width. An
FO_Pgf object’s property list includes properties named FP_LeftIndent and
FP_Leadin g, which represent its left indent and its leading. Each property has a predetermined data typ e, such as IntT (int e ger, Boolean, or ordinal), StringT (string), or
F_ObjHand leT (object ID).
Each of an indi vid ual obj ect’s properties has a value. This value descri bes th e prope rty f or that
particular object. For example, suppose a document contains a smoothed rectangle that is 20
points wide and 10 points high. The Frame API represents the rectangle as an
FO_Rectan gle object with the following properties and values.
TABLE 1.1
PropertyData TypeValue
FP_WidthMetricT20 * 65536
FP_HeightMetricT10 * 65536
FP_RectangleIsSmoothedIntTTrue
a
1. Frame API objects should not be confused with the graphic object s that you create with the Tools palette, object elements in
structured documents, or the objects of object-oriented programming langua ges.
FDK Programmer’ s Guide3
Introduction to the Frame API
1
ABLE 1.1
T
PropertyData TypeValue
FP_FrameParentF_ObjHandleT
a.
MetricT values are 32-bit integers that represent measurements in points. The 16
most significant bits represent the digits before the decimal. The 16 least significant
bits represent the digits after the decimal. A point is 65536 (1 << 16) in
units. For more information on MetricT, see ‘ ‘Metr icT values’’ on page 675 of the
FDK Programmer’s Reference.
ID of the frame containing the
rectangle
MetricT
FO_Rectan gle objects actually have many more properties than are shown in the table
above. For a complete list of Frame API objects and properties, see Chapter 3, “Object
Reference” in the FDK Programmer’s Reference.
How clients can change FrameMaker documents, books, and sessions
A client can change FrameMaker documents, books, and sessions by:
● Creating and destroying objects
The API provides functions to create and destroy objects.
● Changing object properties
The API provides functions to get and set object properties.
● Programmatically executing FrameMaker product commands, such as Open, Print, Save,
and Clear All Change Bars
How clients communica te with the user
A client can communicate with the user by:
● Creating menus and menu items
● Displaying dialog boxes
The API allows a client to respond to user actions by:
● Notifying the client when the user initiates certain events, such as Open, Save, or Quit
● Passing a message to the client when the user clicks a hypertext marker that contains a
message apiclient hypertext command
How clients work with FrameMaker
Clients us e different mechanisms to work with FrameMaker on the different platforms the
FDK supports. On the Macintosh, clients are dynamic ally loa ded modules. On Windows, they
are dynamic link libraries (DLLs), or they can be executable programs that use COM to
communicate with a FrameMak er session. On UNIX platf orms, they c an be either dynamic ally
4FDK Programmer’s Guide
linked code or separate processes that use the RPC mechanism to communicate with the
FrameMaker product. A client does not need to be aware of the low-level details of integrating
with FrameMaker, because the API provides high-level functions that are the same on all
platforms.
When the user starts FrameMaker it sends an initi alization call to each registered client.
Clients can take control immediately, or they can request the FrameMaker product to notify
them of specific events and wait for t hose events to occu r.
Special types of clients
In addition to conventional clients that take control of a FrameMaker product session in
response to user actions, the API allows you to create th ree special ty pes of clients: document
reports, filters, and take-control clients.
Document reports
Introduction to the Frame API
1
Filters
A document report is a client that provides detailed information about a document. The user
can start a document report by choosing Utilities>Document Reports from the File menu, and
then choosing the report from the Document Reports dialog box. The FDK includes a sample
document report, named wordcnt, which counts the number of words in a document. For
more inform ation on sample programs provided with the FDK, see the FDK Platform Guide
for the platform you’re using.
A filter is a client that converts FrameMaker product files to or from other file formats.
An import filter is a filter that the FrameMaker product calls when the user attempts to open a
non-Frame file and chooses a filter in the Unknown File Type dialog box. The import filter
reads the file and c onverts it to a FrameMaker product documen t or book . The FDK include s a
sample import filter, named mmlimport, that converts MML files to FrameMaker product
documents.
An export fi lter is a filter that the FrameMaker product calls when the user attempts to save a
FrameMaker product document or book in a particular format by choosing the format in the
Save dialog box or by specifying a filename with a particular extension. The export filter
writes information in the document or book to a file with a different format.
A file-to-file filter is a fil ter that the FrameMaker pr oduct can ca ll to both impo rt or e xport f iles
of different formats. A single file-to-file filter client can actually consist of more than one
filter. For example, the same client could filter CGM to FrameVector and FrameVector to
CGM. The way you register the client’s different filters determines which filter to invoke for
import and export. Another advanage of these filters is they can filter from an external file to
an external file. For e xample, y ou could f ilt er from CGM to TIFF, and the TIFF file can r emain
an external file th at is imported into the document by reference.
FDK Programmer’ s Guide5
Introduction to the Frame API
1
Take-control clients
A take-control client is a client that takes control of a FrameMaker product session
immediately after the FrameMaker product starts. The UNIX implementation of the FDK
allows users to specify a take-control client in the FrameMaker product command line. Takecontrol clients are useful for conducting batch operations in which little or no user interaction
is needed.
Portability
The API’s design makes it easy to create portable clients. In most cases, you only need to
recompile your cli ent to run it on a diff er ent platform. To ensure that your client is completely
portable, use the FDE with the API. You should replace platform-specific I/O, str i ng, and
memory functions in your client with the al terna ti v es th e FDE pro vide s. For more infor mat ion
on the FDE, see Part III, Frame Development Environment (FDE).
The FDE and the API provide alternatives to the C language’s fundamental data types. For
example, the F DE and the AP I substitute IntT for a 32-bit int and UCharT for
unsigned char. The API uses other types for specific purposes. For example, it uses
F_ObjHand leT for object IDs. For a list of API data typ es, see Chapter 4 , “Data Types and
Structures Reference,” in the FDK Programmer’s Reference.
Due to platform limitations Asynchronous clients (clients that run outside of the FrameMaker
process space) are not portable on all platforms. For specific information on Asynchronous
clients se e the FDK Platform guide for the platform in question.
Running clients with different FrameMaker product interfaces
FrameMaker ships with t wo product interfaces, Structured FrameMaker and FrameMaker. A
client can only use functionality that is available in the product interface that is active for the
currently running FrameMaker process . For example, if a client is running on the unstructured
FrameMaker product interface , it can’t create or mani pulate struct ural elements ( FO_Element
objects). On the other hand, all functions in the FDK are available to a client running on the
Structured FrameMaker product interface.
To determine if a function is available in a particular product interface, see Chapter 2, “FDK
Function Reference,” in the FDK Programmer’s Reference. For an example of how to
programmatically determine which product interface is running, see ‘‘F_ApiGetString()’’ on
page 158 of the FDK Programmer’s Reference.
Creating and running a client
To create and run a client, follow these general steps:
6FDK Programmer’s Guide
Introduction to the Frame API
1. Write an init ialization fu nction.
Most clients need to define an F_ApiInitialize() callback function. When the
FrameMaker product starts, it calls your client’s F_ApiInitialize() function. Normally,
you will want to include code in F_ApiInitialize() to set up your client’s menus and
request notification for particular events.
For more information on creating an F_ApiInitialize() callback, see Chapter 2, “API
Client Initialization”.
2. Set up the client’s user interface.
Your client probably needs to inte ract wi th the use r. To res pond to use r acti ons, you can def ine
the following ca llback functions in your client:
● F_ApiNotify() to respond to the user initiating FrameMaker product operations, such
as Open an d Save
● F_ApiCommand() to respond to the user choosing menu items created by your client
● F_ApiMessage() to respond to the user clicking hypertext markers that contain the
message apiclient command
1
● F_ApiDialogEvent() to respond to the user manip ulati ng items in a dialo g box creat ed
by your client
You can also display notices and prompt the user for inpu t by usi ng API dial og box funct i ons,
such as F_ApiAlert() and F_ApiPromptString().
For more information on setting up your client’s user interface, see Chapter 3, “Creating Your
Client’s User Interface”.
3. Add code to programmatically execute FrameMaker product commands.
Your client probably needs to execute some FrameMaker product commands, such as Open,
Print, or Close. To execute these commands programmatically, use API functions, such as
F_ApiSimpleOpen(), F_ApiSilentPrintDoc(), or F_ApiClose().
For more informati on on u si ng API fu nct io ns to execute FrameMak e r pr oduc t commands, see
Chapter 4, “Executing Commands with API Functions”.
4. Add code to get and set object properties.
To get or set an object property, use the F_ApiGetPropertyType() or
F_ApiSetPropertyType() function that corresponds to the type of property you want to
get or set. For example, to get or set an IntT property, use F_ApiGetInt() or
F_ApiSetI nt(). To get or set a StringT property, use F_ApiGetString() or
F_ApiSetS tring( ).
For more information on changing object properties, see Chapter 5, “Getting and Setting
Properties”.
5. Add code to create objects.
FDK Programmer’ s Guide7
Introduction to the Frame API
1
T o creat e objects, use the F_ApiNewObjectType() function t hat correspond s to the kind of
object that you want to create. For example, to create a new anchored frame, use
F_ApiNewAnchoredObject().
For more information on creating objects, see Chapter 8, “Creating and Deleting API
Objects”.
6. Compile your client.
The API function declarations are cont ained in the fapi.h header. Be sure to include this
header in your client code. Include C library header files before the fapi.h header.
The FDK comes with sample makefiles or project files for each supported platform. To
compile your client, use your platform’s make or build utility. For more information on using
FDK makefiles or project files on a specific platform, see the FDK Platform Guide for that
platform.
7. Register your client with the FrameMaker product.
The FrameMaker product needs to know about your client to initialize it. To let the
FrameMaker product know about your client, you must make some changes to the
environment under which the client runs.
● On UNIX platforms, when you start FrameMaker it looks for a text-only file named
fminit/UILanguage/APIArea/apiclients, where
UILanguage is the user interface
language (such as usenglish for US English). It looks in the directory from which it
was started, in your home directory, and in $FMHOME. To register your client, create an
fminit/UILanguage/APIArea/apiclients file in your home directory or the
directory from which you intend to start the FrameMaker product. Add the following lines
to the file:
<APIclient
<Name
<Directory
<CommandLine $FAPIDIR
>
client_name>
clientdir>
/executab le_name>
The path clientdir specifies the full path of the directory containing your client’s executable
file and other resources,
reference your client, and
FDK sets the environment variable $FAPIDIR to
● On Macintosh computers, copy or mov e your client t o the FrameMaker p roduct’ s Modules
client_name is the name that FrameMaker and other clients use to
executab le_name is the name of your clien t’s executable f il e. The
clientdir.
folder.
● On Windows platforms, add the followin g lines to the [APIClients] section of the
maker.ini file:
ClientName=ClientType, description, path, mode
ClientName
client.
TextImport.
is the name that the FrameMak er product and other client s use to r eference your
ClientType specifies your client type: for example, Standard, DocReport, or
description is a string describing your client. path is the pathname of your
8FDK Programmer’s Guide
client’s DLL.mode determine s wha t p rodu ct interfaces your cl ie nt supports—can be one of
all, maker, or structured.
You can also register a Windows client by setting values in the DLL’s VERSIONINFO
resource, then copying or moving the DLL in the PrameMaker product’s Plugins folder.
For information on registering your client o n a specific platform, see the FDK Plat form Guide
for that platform.
A simple example
The followin g client adds a menu wit h three items to t he FrameMak er pro duct menu bar when
the FrameMaker product starts. The first menu item closes the active document; the second
item sets the fill pattern of a selected graphic object; the third item adds a body page to the
active document. Following the code is a line-by-line description of how it works.
1. #include "fapi.h"
2. #define CloseDoc 1
3. #define SetFill 2
4. #define AddPage 3
5.
6.
VoidT F_ApiInitialize(initia lization)
7. IntT initialization; /* Code for initializ ation type */
These lines includ e heade r f iles a nd def ine t he consta nts for the cli ent’s menu items. All clients
must include the fapi.h header. To e nsure your cl ient is portable, include fapi.h before
any other header files.
Lines 6.–25.
These line s define the F_ApiInitialize() callback function. When the user starts the
FrameMaker product, it calls F_ApiInitialize().
The call to F_ApiGetNamedObject() gets the ID of the FrameMaker product menu bar
(!MakerMainMenu). The call to F_ApiDefineAndAddMenu() creates a menu named API
on the menu bar. The calls to F_ApiDefineAndAddCommand() add menu items to the API
menu and define keyboard shortcuts for the items.
Lines 26.–56.
These line s define the F_ApiCommand() callback function. When the user chooses a menu
item, the FrameMaker product calls this callback with command set to the menu item number
(in this example, CloseDoc, SetFill , or AddPage).
Lines 31.–34.
These lines get the ID of the document to change. To use most API functions, you need to
specify an ID. This e xample get s the ID of th e document tha t has input focus, that is, the active
document.
In each FrameMaker product session there is only one active document at a time. The session
object (FO_Session) has a property named FP_ActiveDoc that specifies its ID. To retrieve
10FDK Programmer’s Guide
Introduction to the Frame API
the active document’s ID from the FO_Session object, you use F_ApiGetId() to query
the FO_Session object’s FP_ActiveDoc property. The syntax for F_ApiGetId() is:
F_ObjHandleT F_ApiGetId(pare ntId, /* Object’s par ent */
objId, /* Object whose prop erty you want to quer y */
property );/* Constant speci fying property to que ry */
The parentId parameter specifies the ID of the object’s parent—the session, book, or
document that contains the object. No other object contains the FO_Session object, so
parentId is set to 0. The ID of the FO_Session object (there can only be one) is always
FV_Sessio nId, so objId is set to FV_SessionId.
Lines 37.–40.
These lines close the active document when the user chooses Close Doc from the API menu.
The FF_CLOSE _MODIFIED flag instruct s the API t o clos e the do cument without war ning the
user, even if the document has unsaved changes.
Lines 41.–51.
These lines set the f i ll patt ern of a se lect ed object to blac k when the user choo ses Set Fi ll fro m
the API menu. To set the selected object’s fill pattern, the client needs the object’s ID. To get
the ID, the cl ient uses F_ApiGetId() to query the document property,
FP_FirstSelectedGraphicInDoc. If no object is selected, F_ApiGetId() returns 0.
1
The F_ApiAlert() call displays an alert that tells the user to select an object. The constant,
FF_ALERT_CONTINUE_WARN, specifies the type of al ert—an ale rt with a Continue button.
To set the object’s fill pattern, the client mu st set its FP_Fill property. FP_Fill is an
IntT property, so the client must use F_ApiSetInt() to s et it. The syntax for
F_ApiSetI nt() is:
VoidT F_ApiSetInt(parentId,/ * Object’s parent */
objId, /* Object whose prope rty you want to set * /
property, /* Constant specif ying property to set */
value);/* Value to which to set the property */
FP_Fill can have any value between 0 and 15. The API-defi ned constant,
FV_FILL_B LACK, specifies 0 (black).
Lines 52.–54.
These lines add a body page t o the docu me nt whe n th e user chooses Add a Page fr om the API
menu. A body page object is a series object. To create a series object, you use
F_ApiNewSeriesObject(). The sy ntax for F_ApiNewSeriesObject() is:
objectType, /* Constant spec ifying new object typ e */
prevObjectId); /* Object for new object to follow */
The parentId parameter specif ies t he ID of the ob ject t hat is to cont ain the new object. The
new page shoul d appear in the acti v e document, so parentId is set to docId. The API uses
FO_BodyPa ge objects to represent body pages, so objectType is set to FO_BodyPage.
Specifying 0 for prevObjectId puts the new page at the beginning of the document. For
more information on creating different types of objects, see “Creating objects” on page 143.
FDK Programmer’ s Guide11
Introduction to the Frame API
1
Compiling and running the example client
The source code for the example client and a makefile or project file are provided in the
samples/m yapi dire ctory of your FDK inst allati on. F or th e locati on of the fi les, see the FDK
Platform Guide for your platform. To compile the client, use your platform’s make or build
utility.
To run the example client, you must first register it as required by your platform’s
implementation of the API:
● If you are wor king on a UNIX platfo rm with US English as the us er inte rface language, and
the pathname of your compiled client is /usr/fdk/samples/ch1/fa.myapi, you can
register it by creating a text-only file named
~/fminit/usenglish/APIArea/apiclients with the following lines in it:
For more information on how to register clients, see the FDK Platform Guide.
After you have registered the example client, start the FrameMaker product and open a
document. The API menu should appear to the right of the FrameMaker product menus.
12FDK Programmer’s Guide
API Client Initialization
2
This chapter describes how to start interaction between your client and FrameMaker.
Responding to the FrameMaker product’s initialization call
When the FrameMaker product starts, it attempts to start all the clients registered with it,1
except document reports and filters. The FrameMaker product attempts to start each client by
calling its F_ApiInitialize() callback function.
Your client should define F_ApiInitialize() as follows:
Usually, you want your client to do something immediately after the user starts the
FrameMaker product. For example, you may want to add menus to the menu bar or request
notification for certain events. To do this, you call API functions from the
F_ApiInitialize() function. For information on creating menus and requesting
notification, see Chapter 3 , “Creating Your Client’s User Interface.”
Suppose you want your cl ien t t o di splay a dialog box after th e FrameMaker product is st ar ted.
To do this, you could use the following F_ApiInitialize() function:
F_ApiAlert("Client has start ed.", FF_ALERT_CONTIN UE_NOTE);
}
. . .
A flag that indicates the type of initialization (see “Initialization
types” on page 14)
1. For information on registerin g yo ur cl ie nt with the Fra meMaker product, see the FDK Platform Guide for your platform.
FDK Programmer’ s Guide13
API Client Initialization
2
Initialization types
The following table summarizes the different types of initializations and the
initializ ation constants FrameMaker can pass to your client’s F_ApiInitialize()
callback.
TABLE 2.2
Type of
initialization
FrameMaker starts
with no special options
FrameMaker starts
with take-control
client
Document report
chosen from
Document Reports
dialog box
Notification, menu
choice, or hypertext
command for a client
that has bailed out
When F_ApiInitialize
is calledInitialization constant
After starting
After starting
After all clients have finished
processing the
FA_Init_First
FA_Init_First
FA_Init_TakeControl
FA_Init_First
initialization
After report is chosen
When the menu item is chosen,
the hypertext command is
clicked, or the notification
should be issued
FA_Init_DocReport
FA_Init_Subsequent
Clients that receive
initialization
All except document
reports and filters
All except document
reports and filters
All clients set up as takecontrol clients
The chosen document
report
Clients that hav e bai l ed
out and are waiting for an
event, menu choice, or
hypertext command to
occur
First initializa tion
When the user starts the FrameMaker product, the product calls the F_ApiInitialize()
function of each registered client (unless it’s a document report or filter) with
initializ ation set to FA_Init_First.
Take-control initialization
The FDK allows you to set up clients to receive a special initialization called a take-control or
FA_Init_TakeControl initialization. The FrameMaker product issues the
FA_Init_TakeControl in itiali zatio n after it has issued th e FA_Init_First initialization
and all clients have returned control. This initialization is useful if you want your client to
conduct some batch processing after other clients have initialized, but before the interactive
user has control.
14FDK Programmer’s Guide
On UNIX platforms, the FrameMaker pr oduct issues the FA_Init_TakeControl
initialization to only one client. The user speci fies this client by starting the FrameMaker
product with the -apiclient client_name option (where client_name is the
registered name of the client).
On Windows and Macintosh platforms, the FrameMaker product can issue the
FA_Init_TakeControl initialization to several clients. To set up a client to receive
FA_Init_TakeControl initializations on Windows, set the client’s type to TakeControl
in the FrameMak er product .ini file. To set up a client to receive FA_Init_TakeControl
initializations on the Macinto sh, set the flags fie ld of the clien t’ s fdat resource to in clude
ApiClientFlagCanTakeControl. For more information on setting up clients to receive
take-control initializations, see the FDK Platform Guide for your platform.
Document report initialization
When the FrameMaker product is started, it does not attempt to initialize API clients that are
registered as do cument re ports . It ini tial izes a document report only when the user ch ooses t he
document report from the Document Reports dialog box. When this occurs, the FrameMaker
product calls the document report’s F_ApiInitialize() callback with
initializ ation set to FA_Init_DocReport.
API Client Initialization
2
To appear in the Document Reports dialog box, a docu me nt r epo rt mu st b e registered with the
FrameMaker product as a document report. For information on registering document reports,
see the FDK Platform Guide for your platform.
Filter initialization
If your client is registered as a filter, you should not define an F_ApiInitialize()
function for it. When the user opens or saves a file and selects your filter, the FrameMaker
product notifies your client by calling your client’s F_ApiNotify() callback. For more
information on F_ApiNotify() and notification, see “Responding to user-initiated events
or FrameMaker product operations” on page 34.
To receive notific ati on, your filter must be r e gistered as a fi lt er. For information on registering
filters, see the FDK Platform Guide for your platform.
Initialization after a client has bailed out
If your API client is waiting for an event and not performing any other processing, it can call
F_ApiBail Out(). This exits your client’s process and frees all the system resources that it
uses. If an event that your client is waiting for occurs, the FrameMaker product restarts your
client by calling its F_ApiInitialize() function with initialization set to
FA_Init_Subsequent.
A document report should always bail out after it completes processing, because the API
initializes it each time the user chooses it from the Document Reports dia log box. A filter
should always bail out after it filters a file, because the API initializes it each time a filterable
file is opened, imported, or saved.
FDK Programmer’ s Guide15
API Client Initialization
2
For more information on F_Ap iBailO ut(), see ‘‘F_ApiBailOut()’’ on page 48 of the FDK
Programmer’s Reference.
Disabling the API
The user can disable all API clients before starting the FrameMaker product. On UNIX
platforms, the user can disable all clients by specifying -noapi in a resou rce file or when
starting the FrameMak er produc t from the command li ne. On W i ndo ws platfor ms, the user can
disable all clients by changing the API=On setting in the maker.ini file to API=Off. On
the Macintosh, the user can disable clients by dragging them from the FrameMaker product
Modules folder. For more information on disabling individual clients, see the FDK Platform Guide for your platform.
IMPORTANT: Many FrameMaker features are implemented via API clients. If you disable
the API then you also disable these features. Such features include XML and
SGML import and export, Save As HTML, and Word Count.
16FDK Programmer’s Guide
Loading...
+ 452 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.