The class provides methods to ensure the internal representation of InDesign® objects.
The class provides methods to ensure the internal representation of InDesign® objects.
static ItemRef alloc(ItemRef org = 0)
Reserve memory capacity for an InDesign® object. The created ItemRef is thereby not yet connected with an InDesign® object. With alloc created ItemRefs these must be deleted again using item::release.
Name | Type | Default | Description |
Return | ItemRef | New created empty reference to an InDesign® object | |
org | ItemRef | 0 | original 0 : create a new empty object otherwise : make a copy of org Only the reference values are duplicated, not the refered objects itself! |
ItemRef frameRef = item::alloc ();
static ItemRef assign(ItemRef dest, ItemRef src)
Copy on ItemRef to another. The value of src is copied into dest Only the reference values are duplicated, not the refered objects itself!
Name | Type | Default | Description |
Return | ItemRef | dest or 0 on error | |
dest | ItemRef | - | destination |
src | ItemRef | - | original |
static int define(
ItemRef dest,
ItemRef srcDB,
int UID,
int checkIfExists = 1)
Define a reference to a document object.
The function dosn't check whether the object exists. Use exists and get_class to check the reference!
Name | Type | Default | Description |
Return | int | 0 or ErrorCode. | |
dest | ItemRef | - | destination reference |
srcDB | ItemRef | - | Defined reference into the document (gFrame for instance). |
uid | int | - | New object id |
checkIfExists | int | 1 | Before defing the item, check whether an object with given UID exists. 1 : Yes, please check 0 : No, define anyway |
Check a range of document UIDs.
int main () { int i; ItemRef ref = item::alloc ();
for (i = 200; i < 301; i++) { item::define (ref, gFrame, i); wlog ("", "# UID %d : %d, 0x%X'\n", i, item::exists (ref), item::get_class (ref)); }
return 0; }
The UID 0 always points to a document. The examples creates an ItemRef to the document of the current frame an shows the documents name.
int main () { ItemRef docRef = item::alloc (); char docName [4000];
item::define (docRef, gFrame, 0); document::name (docName, docRef); showmessage (docName);
return 0; }
static int release(ItemRef itm)
The reserved memory of an object reference is again released. The target object of the reference remains unaffected by this action.
Name | Type | Default | Description |
itm | ItemRef | - | Reference to be released |
ItemRef frameRef = item::alloc (); : item::release (frameRef);
static int fitframe(
ItemRef ref,
int refPoint = 0,
float* width = 0,
float* height = 0)
Fit the frame, in which a reference is displayed, to its contents. In the optional parameters width and height, the new size of the frame can be requested.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
ref | ItemRef | - | Reference to a document frame |
refPoint | int | kRefPointTopLeft | Which corner of the origin frame should be pinned when scaling? Please note,
that text frames are changed only in their height and that inline frames are always held at the bottom right corner. kRefPointTopLeft kRefPointTopCenter kRefPointTopRight kRefPointLeftCenter kRefPointCenter kRefPointRightCenter kRefPointBottomLeft kRefPointBottomCenter kRefPointBottomRight To fit frames to the contained image, use the frame::fit_image function with method 3. |
width | float* | 0 | New width of the frame, Return value |
height | float* | 0 | New height of the frame, Return value |
ItemRef frame = item::alloc (); document::find_frame (frame, 1, 1, 3, 4);
if (!item::defined (frame)) { item::release (frame); showmessage ("Frame not found"); return 1; } item::fitframe (frame); item::release (frame);
static int defined(ItemRef ref)
Does the reference indicate a valid object?
ItemRefs can point to different objects like frames, tables, documents, ... . A call to defined only anwsers the question, whether the reference points to any object. You can not be sure, that is object is a frame, or a doc, or something else. Anyway, for the most reasons, htis information is enough. To check, whether the ref is a valid frame, table, ... , use one of the corresponding is_valid methods.
Name | Type | Default | Description |
Return | int | != 0 the object is defined, == 0 no object | |
ref | ItemRef | - | Reference to a document frame |
ItemRef frame = item::alloc (); document::find_frame (frame, 1, 1, 3, 4);
if (!frame::is_valid (frame)) { item::release (frame); showmessage ("Frame not found"); return 1; } item::fitframe (frame); item::release (frame);
static int getint(ItemRef ref)
Get the reference as integer. This values are unique in one document.
Name | Type | Default | Description |
Return | int | Value of the referenz | |
ref | ItemRef | - | documet reference |
static int exists(ItemRef ref)
Does the reference indicate an existing object?
ItemRefs can point to different objects like frames, tables, documents, ... . A call to defined only anwsers the question, whether the reference points to any object. You can not be sure, that is object is a frame, or a doc, or something else. Anyway, for the most reasons, htis information is enough. To check, whether the ref is a valid frame, table, ... , use one of the corresponding is_valid methods.
Name | Type | Default | Description |
Return | int | 0 : No 1 : Yes, the object exists |
|
ref | ItemRef | - | reference |
Check a range of document UIDs.
int main () { int i; ItemRef ref = item::alloc ();
for (i = 200; i < 301; i++) { item::define (ref, gFrame, i); wlog ("", "# UID %d : %d, 0x%X'\n", i, item::exists (ref), item::get_class (ref)); }
return 0; }
static int get_class(ItemRef ref)
Get the class of an existing document object. Here's a small collection of IDs and their names.
ClassID | Name | 0x10001 kBookBoss 0x1354C kBookmarkBoss 0x13501 kHyperlinkBoss 0xb603 kTableItemBoss 0xb608 kTableModelBoss
0xe01 | kDocBoss |
0x501 | kSpreadBoss |
0x50f | kPageBoss |
0x1401 | kMasterPagesBoss |
0x302 | kDocumentLayerBoss |
0x301 | kSpreadLayerBoss |
0x201 | kTextStoryBoss |
0x2c0f | kPageItemBoss |
0x263 | kMultiColumnItemBoss |
0x227 | kFrameItemBoss |
0x2c10 | kDrawablePageItemBoss |
0x6201 | kSplineItemBoss - the frames of the document. |
0x1701 | kImageBaseItem |
0x1702 | kImageItem |
0x2501 | kPlacedPDFItemBoss |
0x660b | kEPSTextItemBoss |
0x6611 | kDisplayListPageItemBoss |
0x6601 | kEPSItem |
0x6602 | kPICTItem |
0x6603 | kWMFItem |
0x660f | kDCSItemBoss |
0x401 | kGroupItemBoss - InDesign® groups |
0xb320 | kTOPSplineItemBoss - text on path |
0x3301 | kGuideItemBoss |
0x262 | kInlineBoss - inline frames |
0xb318 | kTOPFrameItemBoss |
0x10001 | kBookBoss |
0x1354C | kBookmarkBoss |
0x13501 | kHyperlinkBoss |
0xb603 | kTableItemBoss |
0xb608 | kTableModelBoss |
0x8c42 | kImportLinkBoss - Images |
0x8c44 | kBidirectionalLinkBoss - Linked text objects (InCopy) |
0x145D8 | kMultiStateObjectItemBoss - Multi state objects |
0x1450C | kPushButtonItemBoss - Pushbuttons |
0x14509 | kFormFieldContentItemBoss |
0x1450A | kFormFieldItemBoss |
0x1450B | kAppearanceFormItemBoss |
0x1450D | kCheckBoxItemBoss |
0x1450E | kRadioButtonItemBoss |
0x1450F | kTextFieldItemBoss |
0x14510 | kListBoxFieldItemBoss |
0x14511 | kComboBoxItemBoss |
0x14512 | kSignatureFieldItemBoss |
Name | Type | Default | Description |
Return | int | Class ID of existing object or 0 | |
ref | ItemRef | - | reference |
Check a range of document UIDs.
int main () { int i; ItemRef ref = item::alloc ();
for (i = 200; i < 301; i++) { item::define (ref, gFrame, i); wlog ("", "# UID %d : %d, 0x%X'\n", i, item::exists (ref), item::get_class (ref)); }
return 0; }
Alphabetic index HTML hierarchy of classes or Java