The class provides methods to ensure the internal representation of InDesign® objects.

Version :
09.11.2021, 08:27 Uhr

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 ();

org since version 1.3.4 (P/R 74)

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

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

Version 1.3.4 (P/R 74)

priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

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 error code.
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; }

v3.3 R2489, 06.06.2011 Parameter checkIfExists since v4.1.6 R26001, 1. Oct 2019

priint:comet InDesign® Plug-Ins, comet_pdf

defined, exists, get_class

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);	


priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

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.

Unlike in frame::resize et. al. the left top reference point is named by kRefPointTopLeftNew here. To get the default fitting behavior, use kRefPointDefault.

Name Type Default Description
Return int   error code oder 0
ref ItemRef - Reference to a document frame
refPoint int kRefPointTopLeft kRefPointDefault
kRefPointTopLeftNew
kRefPointTopCenter
kRefPointTopRight
kRefPointLeftCenter
kRefPointCenter
kRefPointRightCenter
kRefPointBottomLeft
kRefPointBottomCenter
kRefPointBottomRight
 
width float* 0 New width of the frame, Return value
height float* 0 New height of the frame, Return value

#include "internal/types.h"
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);


priint:comet InDesign® Plug-Ins, comet_pdf

frame::fit
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);


priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

frame::is_valid, table::is_valid, bookmark::is_valid, document::is_valid, hyerlink::is_valid

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

Version 1.4 R334 (13. April 2007)

priint:comet InDesign® Plug-Ins, comet_pdf

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; }

v3.3 R2489, 06.06.2011

priint:comet InDesign® Plug-Ins, comet_pdf

static int get_class(ItemRef ref)

Get the class of an existing document object. Here's a small collection of IDs and their names.

0x10001 kBookBoss 0x1354C kBookmarkBoss 0x13501 kHyperlinkBoss 0xb603 kTableItemBoss 0xb608 kTableModelBoss

ClassID Name
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; }

v3.3 R2489, 06.06.2011

priint:comet InDesign® Plug-Ins, comet_pdf

This class has no child classes.

Author
Paul Seidel
Version
09.11.2021, 08:27 Uhr
Since
Plugin Version 1.0.10
See Also
frame
itemlist

Alphabetic index HTML hierarchy of classes or Java