List of products.
You will find a general example for the use of productlist here.
List of products. The list may be ascertained either using the current product research and its selections or build up using the script. List of the current product research can be expanded.
static ProductList alloc()
Create a new empty list. The list may be again deleted using release.
More information about product lists and products in lists can be found here.
Name | Type | Default | Description |
Return | ProductList | pointer to a new empty list |
static ProductList get(char* statement)
Create a new list from the entries of the Product Pool panel.
A second version of the function with two parameters fetches the n-th product of a given list.
Name | Type | Default | Description |
Return | ProductList | New allocted list of products | |
statement | String or char* | - | Instructions to fill the list, see here. |
static void clear(ProductList pl, int delete_items = 1)
Clear list.
More information about product lists and products in lists can be found here.
Name | Type | Default | Description |
pl | ProductList | - | pointer to a valid product list |
delete_items | int | - | Are the list elements likewise to be deleted from the memory? 1 - Delete objects 0 - do not delete |
static void release(ProductList pl, int delete_items = 1)
Delete a list again from the active store.
More information about product lists and products in lists can be found here.
Name | Type | Default | Description |
pl | ProductList | - | pointer to a valid product list |
delete_items | int | 1 | Are the list elements likewise to be deleted from the memory? 1 - Delete objects 0 - do not delete |
static int length(ProductList pl)
Current length of the list
Name | Type | Default | Description |
Return | int | Number of list elements | |
pl | ProductList | - | pointer to a valid product list |
static Product get(ProductList pl, int nth)
Name | Type | Default | Description |
Return | Product | found object. In case of error the call returns 0. | |
pl | ProductList | - | Pointer to a valid product list |
nth | int | - | 0-based list index |
static int get_pos(
ProductList pl,
Product p,
int setPos = 0)
Define the index which has an object in the list.
Name | Type | Default | Description |
Return | int | 0-based list position of the object. If the object is not found, the call returns -1. | |
pl | ProductList | - | Pointer to a valid product list |
p | Product | - | Pointer to a valid product |
setPos | int | 0 | Set the current list position to this product? 0 : no 1 : yes |
static Product get_nth(
ProductList pl,
int n,
int setPos = 0)
Get the nth product of a given product list.
Name | Type | Default | Description |
Return | Product | product found at the given 0-based list index 0 : list empty or index out of range |
|
pl | ProductList | - | Pointer to a valid product list |
n | int | - | 0-based index |
setPos | int | 0 | Set the current list position to this index? 0 : no 1 : yes |
static int append(
ProductList pl,
Product p,
int allowDoubles = 1)
Insert an object to the list.
More information about product lists and products in lists can be found here.
Name | Type | Default | Description |
Return | int | 1 - The object could be inserted (and will be automatically deleted with clear (1)) 0 - Objects not inserted (and must then be deleted) |
|
pl | ProductList | - | pointer to a valid product list |
p | Product | - | pointer to a valid product |
allowDoubles | int | 1 | Are entries with the same IDs permitted in the list? 0 - If the list already contains an entry with the ID of p, p will not be inserted in the list. 1 - The entry will be inserted without checking the ID. |
static int insert(
ProductList pl,
Product p,
int index,
int allowDoubles = 1)
Insert an object in the list.
More information about product lists and products in lists can be found here.
Name | Type | Default | Description |
Return | int | 1 - The object could be inserted (and will be automatically deleted with clear/release (li, 1)) 0 - Objects not inserted (and must then be deleted) |
|
pl | ProductList | - | pointer to a valid product list |
p | Product | - | pointer to a valid product |
ix | int | - | Insert in front of this position. The position is 0-based. To append an object to the list, use append or the Index -1. |
allowDoubles | int | 1 | Are entries with the same IDs permitted in the list? 0 - If the list already contains an entry with the ID of p, p will not be inserted in the list. 1 - The entry will be inserted without checking the ID. |
static Product remove_pos(ProductList pl, int index)
Remove an object from the list. The object at the defined list position will be removed from the list. The product itself is not automatically deleted upon removal from the list.
More information about product lists and products in lists can be found here.
Name | Type | Default | Description |
Return | Product | The removed object 0 - no object is to be removed from the list |
|
pl | ProductList | - | pointer to a valid product list |
ix | int | - | 0-based list index |
static Product remove(ProductList pl, Product p)
Delete an object from the list. The object will be removed from the list. The product itself is not automatically deleted upon removal from the list.
More information about product lists and products in lists can be found here.
Name | Type | Default | Description |
Return | Product | The removed object 0 - the object was not found in the list |
|
pl | ProductList | - | pointer to a valid product list |
p | Product | - | pointer to a valid product |
static Product first(ProductList pl)
Get the first object of the list and define the current list pointer at the list start.
Name | Type | Default | Description |
Return | Product | First object in the list 0 - Empty list |
|
pl | ProductList | - | Pointer to a valid product list |
static Product next(ProductList pl)
Move the current list pointer toe position onwards and get the next object of the list. The call is dependent on either first or last and some prev calls.
Name | Type | Default | Description |
Return | Product | Next object of the list 0 - List end not reached |
|
pl | ProductList | - | Pointer to a valid product list |
static Product prev(ProductList pl)
Move the current list pointer toe position onwards and get the next object of the list. The call is dependent on either first or last and some next calls.
Name | Type | Default | Description |
Return | Product | Next object of the list 0 - List start reached |
|
pl | ProductList | - | Pointer to a valid product list |
static Product last(ProductList pl)
Get the last object of the list and define the current list pointer at the list end.
Name | Type | Default | Description |
Return | Product | Last object of the list 0 - List empty |
|
pl | ProductList | - | Pointer to a valid product list |
static int build(
char* statement = "watched",
int flags = 0,
char* errmess = 0,
ItemRef baseFrame = 0,
int removeFrame = 0,
int pageNum = -1,
char* layerName = "",
char* defaultMasterpage = "",
int gridID = 0,
int pageitemID = 0,
int anchor = 0,
float left = 0.0,
float top = 0.0,
float right = 0.0,
float bottom = 0.0,
int purgeSequence = 0,
char* sequName = "",
int preScript = kNoRule)
Product build. Like document::build_products.
static int build_list(
ProductList pl,
int flags = 0,
char* errmess = 0,
ItemRef baseFrame = 0,
int removeFrame = 0,
int pageNum = -1,
char* layerName = "",
char* defaultMasterpage = "",
int gridID = 0,
int pageitemID = 0,
int anchor = 0,
float left = 0.0,
float top = 0.0,
float right = 0.0,
float bottom = 0.0,
int purgeSequence = 0,
char* sequName = "",
int preScript = kNoRule)
Product build. Like document::build_products, but the first argument is a ProductList. No prescript is executed. You may prepare your products inside the script instead. Multiple products removed from the list by default.
This statement is prefered to use in a faceless InDesign® Server environment. In all other situations use the (faster) statement document::build_products please. The only exceptions are if you fill the productlist inside the script or if you want to make some special changes inside the resulting list from productlist::get.
Build a small amount of products.
#include "internal/products.h"
int gGridID = 12;
int append_product (ProductList li, int id1, int id2, int id3, int pi) { Product p;
if (!li) return 1;
p = product::alloc (); product::set (p, kID, id1); product::set (p, kID2, id2); product::set (p, kID3, id3); product::set (p, kPageitemid, pi);
productlist::append (li, p, 1);
return 0; }
int main () { ProductList li = productlist::alloc ();
append_product (li, 100, 10, 0, 2); append_product (li, 300, 10, 0, 2); append_product (li, 400, 10, 0, 12); append_product (li, 500, 10, 0, 2);
productlist::build_list ( li, kUseDefaultGrid, 0, 0, 0, -1, "", "", gGridID);
productlist::clear (li, 1);
return 0; }
static ProductList load(
int sourceType,
void* dsn,
int format,
char* statement = "",
List values = 0 )
Load a list of products from a file (XML or CSV), a database connection or an XMLTree.
Name | Type | Default | Description |
Return | ProductList | Newly allocated list of products or 0 in case of some errors | |
sourceType | int | Type of data source - kXML |
XML-file - kCSV CSV file - kDB database or SOAP connection - kXMLTree XMLTree |
dsn | void * | depending on sourceType - kXML |
complete path to XML file - kCSV complete path to CSV file - kDB database or SOAP connection - kXMLTree XMLTree |
format | int | kStandardSet | Data format : Describes the expected result columns: - kStandardSet : ID,ID2,ID3,StringID - kExtendedSet : ID,ID2,ID3,StringID,Pageitemid - kCustomSet self defined set. In this case, parameter values must contain a list of expected results (see product::get) |
statement | String or char* | "" | Statement to select data (depends on the sourceType and format) - kXML, kXMLTree: optionally if XML structure is like shown in example 1 or 2. - kCSV: ignored - kDB: required |
List | values | 0 | List of expected result rows (see product::get). The list entries and their datatypes must match the statements result rows. |
XML standard set
// // <productlist> // <product> // <ID/> // <ID2/> // <ID3/> // <StringID/> // </product> // </productlist> // ProducList pl = productlist::load (kXML, "/Export/catalogue_data/2007_05.xml");
XML extented set
// // <productlist> // <product> // <ID/> // <ID2/> // <ID3/> // <StringID/> // <Pageitemid/> // </product> // </productlist> // ProducList pl = productlist::load (kXML, "/Export/catalogue_data/2007_05.xml");
Load from xml structure (e.g. for validating parameters passed as an XML String)
XMLTree tree; ProductList pl;
tree = xmlquery::parse ("<productlist><product><ID/><ID2/><ID3/><StringID/></product></productlist>"); pl = productlist::load(kXMLTree, tree);
SQL with own result set
ProductList pl; int dbc = datapool::get_dbc (); // DBC oder SOAP // Create a list of expected return values List values = list::alloc ();
list::insert (values, kID); list::insert (values, kID2);
pl = productlist::load(kDB, dbc, kCustomSet, "SELECT ID,ID2 FROM product", values);
// product lists loaded like shown above can be used like this: productlist::build_list (pl, kUseDefaultGrid, 0, 0, 0, 1, "produktlayer", "A-Mustervorlage", 1, 0, 0);
static int seek(ProductList pl, int pos)
Set internal list iterator to position pos
Name | Type | Default | Description |
Return | int 1 if successful, 0 otherwise | ||
pl ProductList - Pointer to a valid product list | |||
pos int - position |
static int establish(
ProductList pl,
ItemRef dref = 0,
int pageNum = -1,
char* layer = "",
int pageTemplate = 0,
int pageItem = 0,
int flags = 0,
int preScript = 0,
int singleSequences = 0,
char* sequName = 0,
char* errMess = 0,
char* ignoreLayers = 0,
int snippetMatchFlag = 0,
char* snippetContext = 0,
int snippetFilterFunc = 0,
...)
Product building using page templates.
Buildig products by using page templates. In the Tutorial PageBuilding you will find more information about page template based product build-ups. Here is a flowchart of the product build-up:
Label{Flussdiagramm}Here is a flowchart of the product build:
Descriptions:
Next Item Get the next element of the input list. The list can contain products and page templates (kProductType = 4).
Is Prrduct The product list can contain both products and page templates. Page templates are marked by kProductType = 4 and create a new page in the document. If the page templates has parent pages defined the first parent page found in the document will be applied to the new page.
Fix Template If the template of the current product has page-specific subtemplates, the subtemplate matching the current page type is determined. When creating continuations, the matching subtemplate of the continuations is used automatically.
Fix Page Element Search for the next available (free) page element on the page.
In 1:N elements, it is first checked whether the element has enough space for another product. If this is not the case, the the products built up in the element are justified horizontally and vertically according to the settings of the element.If a new page element has to be determined, a check is made starting behind the current (or at the first) page element of the page template, whether already existing document frames overlap the element. The first element without frame overlaps is used to build the product. If no free page element is found, a new page is inserted, linked to the current page template and the first element of the new page is used.
Create New Page Each page template in the input list automatically creates a new page. If the page template requires a special (left or right) page, an empty page is inserted first if necessary (e.g. if the build-up is on a left page and a page template requires a new left page, then an additional right page is inserted).
Set PageTemplate New created pages are linked to the current page template. If the page template contains information about parent pages, the first parent page found in the document will be applied to the new pages.
Page Created Was a new page created in the last action? In the vast majority of cases, only one page can be created at a time. Only if the input list contains a page template that requires an exact page type (left, right), the necessary blank page is additionally created in double-page documents (e.g. if the build-up is on a left page and a page template requires a new left page, then an empty right page is additionally inserted).
Check Page Type Check if the current document page has the page type required by the page template. If the page template requires a left (or right) page, a blank page is inserted first if necessary (e.g. if the build-up is on a left page and a page template requires a new left page, then an additional blank right page is inserted).
Exec Pageitem Script Sometimes the product template depends on the location in the document. For example, the first product on a page should always be displayed differently from the subsequent products. At this point of the build-up the target position of the product in the document is now clear and the template can be calculated. Information about the script type can be found here.
Check Element Size Before Check whether the template fits into the calculated element. The saved size information of the template is used for the check. The actual frames of the template are not used. If the template has an expected minimum size, the minimum size is used instead of the template size. Only the geometric size is tested, other criteria do not play a role in the test. To check other criteria, use the Build-Support script with the situation kCheckSizeBefore (= 1).
Build-Support Call your Build-Support script with the given situation. The following situations are supported:
1 kCheckSizeBefore 2 kCheckSizeAfter 3 kBeforeCreateContinue 4 kAfterCreateContinue 5 kProductPlaced 6 kUnsolvableOversets 7 kBeforeLoad // since v4.2 R32572, UNUSED 8 kProductPlacedAndFitted // since v4.3 R35000 // Not included in the image! // Is executed directly before 'Prepare Oversets' 20 kAfterBuild 21 kProductFinished
Exec PreRule The script was used in the Comet3 Grid Layout for page and slot changes. It is still called in the Comet4 product build-up, but has only historical significance. A description of the defined variables can be found here.
Exec PostRule The script was used in the Comet3 Grid Layout for postprocessing of the prpduct. It is still called in the Comet4 product build-up, but has only historical significance. A description of the defined variables can be found here.
Check Element Size After The product template is now linked and loaded. All its appropriate layout rules have been executed. Does the product still fit in its originally assigned location? The bounding box of the current document frames of the product or its current continuation is used for the check. Only the geometric size is tested, other criteria do not play a role in the check. To check other criteria, use your Build-Support script> with the situation kCheckSizeAfter (= 2).
Move Frames (to Element) Move the frames of the product (or its continuation) to the upper left corner of the current location. For 1:N elements, this place can also be inside the element.
Remove Frames from Grid If the product frames were built up as part of a 1:N element, they are now also removed from the internal 'accounting' of the element grid. (The element grid is used for the later row and column alignments of the element).
Next Page Element Jump to the next page element. The order of the page elements is determined by the sequence number of the elements. When the last page element is reached, a new page is automatically created and linked to the page template specified as continuation.
Prepare Oversets Frames with overset, for which a continuation is defined, are brought to their maximum possible height limited by the page element. If the overset is thereby resolved, the frame is then adjusted to its content again to its content.
Frames With Overset Is there now at least one frame with continuation that still has text overset even in its maximum height limited by the page element?
Oversets Smaller than before Did enlarging the frames with continuation reduce the overset?
Recursive Continue Call The product needs a continuation. For this purpose, the product build-up is called internally again. At the end of this call, frames with the same key are automatically linked together in a text frames chain.
Continue Call Is the main template of the product or a continuation inserted?
Is Textflow Is the product built as a text flow?
Prrduct Exists ... ? Does the product already exist in the document?
Create Textframe There is no unique template frame available for building up the product as a text flow. Therefore, the page element itself is used as the frame for the text. The prerequisite is that the page template exists as a document in the data pool (and not just its XML description). If the corresponding page element is not a text frame, the frame is automatically converted to a text frame. Otherwise the frame is taken over with all its text frame properties.
Any existing text in the frame is removed and replaced by the product text. In the Template Behavior palette, you can specify whether the individual frames of the template should be included in the text flow as inlines or whether their text content should be inserted. You can find more information here.
Insert Template Inserting the template into the document. Templates are always inserted at the page position (0, 0), i.e. at the top left, and only moved later. The reason for this is that with larger templates, parts of the template can otherwise fall off the pasteboard which may cause serious errors in InDesignInDesign®.
To avoid errors in the later determination of the text obersets, all text wraps of other frames are also temporarily removed at this point in the product build-up.
Note: The deactivated text wraps are automatically reactivated when the product is moved to its final target position later. At this point, the text oversets (with the now valid text wraps) are also re-determined. In order not to make the description of the product build-up more complex, these steps are not shown in the flowchart.
Link Placeholders Link the placeholders of all newly inserted frames and texts to the ID of the current product.
Load Placeholders Load the contents of all placeholders of all newly inserted frames and texts.
Build Repeating Elements Build-up the repeating elements. Information about the repeating elements can be found here.
Execute the given Layout Rules for all inserted frames. Height changes to frames with continuations are automatically undone.
This is a Reorganisation This branch of the product build-upo is visited only during reorganizations. The main template of the product is moved to its newly calculated position in the document. Continuations of the product are deleted and created again.
Not Enough Space No page element is found that is large enough for the product (or its continuation).
Prrduct Finished The product has been successfully inserted and built. The build process now continues with the next product (or page template).
Name | Type | Default | Description |
Return | int | 0 or ErrorCode. If parameter errmess is given and allocated, it contains an error description too. | |
pl | ProductList | - | products to build |
dref | ItemRef | - | destination document 0 : Current front document |
int | pageNum | - | start page 0 : Current page on front document Using InDesign® Server or comet_pdf the current front page is undefined! |
layer | String or char* | - | layer name "" : Current front layer |
int | pageTemplate | - | Initial page template to use for building Page breaks are achieved by inserting products with kProductType = 4 (page template) into the product list. Here you will find an example. |
int | pageItem | 0 | template to use for building product(s), see (kPreferDefaultPageItem for more information |
int | flags | 0 | Customize building. kPreferDefaultPageItem . Use pageItem for all products. Otherwise pageItem is used only for products with no pageitem given. kSkipEmptyTemplates : Skip products with no template defined. (available since Comet 3.2 R2187) kShowProgress show progressbar kCheckIfNotExists : Check whether a product already exists in the document and suppress inserting if so. kAutoDetectType : While inserting templates as text we have two possibilities : Insert a frame as inline or insert the frames (text) content. With kAutoDetectType set, the following is done : Insert the text content if the frame is a text frame and inserted the frame as an inline otherwise. kSuppressAlerts Suppress alerts while building products. Some alerts like 'Object will leave the paste board' are too deep inside InDesign® and cannot suppressed! kIgnoreErrors Ignore errors and continue. This may generate gaps in page elements. Reorganizing the document again will fill this gaps. kPreferExistingPages If document pages are already linked against page templates, prefer this page templates instead of the the page template given in pageTemplate. If the last page is reached, the normal page templates successor rules are used. kPreferProductPT Since v3.3 R2731 Products may contain a page template. Product page templates are shown (delimited by an @) behind the products template in the product pool. The page template is given by the panelstatements in the column gridID. Every page template will create a page break. Products without a page template will use the standard page template as given above. ATTENTION : This version of Comet does NOT support page breaks to specific page type (left, right pages)! kLoadMasterItems Seit v3.3 R3051 Override and link all parent page frames linked with placeholders after successfully building all products. In this case, we walk through all pages of the document. The document will remember, wether the flag is set or not : If the flag is set, all subsequent reorganizations will walk through the parent pages items too. Overriden parent items always lie above the non-overridden items and may cover these frame. If necessary, frames that are to be in the foreground must be provided with an empty placeholder and arranged accordingly. kSuppressLoad Since v4.1.8 R30123 Suppress loading placeholders and building repeating elements. |
preScript | int | kNoRule | ID of the preparation script. The script is executed in that the list of the products to be imported is determined
and can then be used to process the product list. For more see product::set, product::clone,
productlist and on chapter Script support. kNoRule - No script is executed Otherwise : ID of script, see here for more information. |
singleSequences | int | 0 | ignored |
sequName | String or char* | "" | ignored |
errmess | String or char* | 0 | If the variable identifies an allocated string (e.g. of type char[256]), an error message can be received here. |
ignoreLayers, ... | String or char* | 0 | since Comet 3.2 Any number of layer names. New products are allowed to intersect objects on this layers. "invisibles" : All invisibles layers "except name" : All but this "behind name" : Alle All behind this "background" : Background layer 0 or "" : no more layers given otherwise : Name of layer. Ignored, if it is the active front layer of the document. If snippet parameter should be used, the list of ignoreLayers must be terminated by a '0'. Therefore, for no ignoreLayers, therefore a single '0' must be written. |
snippetMatchFlags | int | kSnippetsNever | since v4.1.6 R26609 Should Comet Snippets be used? Flags can be added, e.g. kSnippetMatchesProduct + kSnippetMatchesTemplate kSnippetsNever : No, don't use snippets kSnippetMatchesProduct : Yes, if products match kSnippetMatchesTemplate : Yes, if templates match kSnippetMatchesDocument : Yes, if documents match kSnippetMatchesLayer : Yes, if layers match kSnippetMatchesContext : Yes, if the contexts match kSnippetFallbackToTemplate : if the snippet doesn't fit the page element, use original template instead. kSnippetCreate : create non existing snippets on the fly |
snippetContext | String oder char* | 0 | since v4.1.6 R26609 arbitrary string to identify a snippet's "context". This will be used for snippet search and for new snippets created during building. |
snippetFilterFunc | int | 0 | since v4.1.6 R26609 Pointer to a function, which is executed before snippet creation to check, whether a snippet should be created for a product or not. The function must be defined in the same script (or be included from a script library) and follow this signature: int (*snippetFilterFunc)(Product p). See prefs::snippet_filter for an example |
#include "internal/products.h" #include "internal/types.h"
int main () { ProductList pl = productlist::get ("selected"); int result;
result = productlist::establish ( pl, 0, // front document -1, // current page "", // front layer 2, // page template 0, // default template kShowProgress, // flags, (showprogress) 0, // pre script 0, // no single sequences "", // sequence name not used 0 // errmess ); if (result == 0) wlog ("", "# Establishing %d products done\n", productlist::length (pl)); else wlog ("", "# Establishing %d products returned error %d\n", productlist::length (pl), result);
return 0; }
static int grid_build(
ItemRef docRef,
PlanningList plannings,
int flags,
char* buildMessage)
Build a list of plannings according page, coordinates and dimension configured in grid planning.
Name | Type | Default | Description |
Return | int | 0 or error code. | |
docRef | ItemRef | - | document 0 : current document |
plannings | PlanningList | - | list of planning objects |
flags | int | - | control flags. Basically, all flags supported by productlist::establish are allowed, mainly useful in this context: 0 : ignore grid size. This also implies: ignore existing page content kCheckGridElementSize : respect grid size |
buildMessage | char * | 0 | buffer for build messages |
static int trace_build(
ItemRef docRef,
int pg,
char* fileName)
Add an image to the build trace. The statement is a *NOP* if the build trace is not activated. To activate the build trace, use the ProductPool flyout menu Produktpool -> Misc -> Build Trace
Name | Type | Default | Description |
Return | int | 0 or ErrorCode. | |
docRef | ItemRef | - | Document 0 : Current document |
pg | int | - | 1-based page to create an image from |
fileName | String or char* | - | File name of image. The file name is added to an automatic counter number. In addition, a message is written to the log: # Trace image created : '$CACHE/BuildTrace/NN_p1_fileName.png' |
static ProductList get_established(
ItemRef docRef = 0,
int startPage = 1,
ItemRef behindRef = 0)
Create a new list of the products built in a document and the page templates used for building these products. The result is the same list the panel Products of document shows. if you insert new objects in this list, create them using kListOwner, see product::alloc for more information. More information about product lists and products in lists can be found here.
Name | Type | Default | Description |
Return | ProductList | pointer to the new list | |
docRef | ItemRef | 0 | Document 0 : current document |
startPage | int | 1 | start collecting at the given page (1-based) |
behindFrame | ItemRef | 0 | Start collecting behind this frame. If given, the start page is ignored. |
Write all established products of the current document page to the logfile.
#include "internal/products.h"
int main () { ProductList pl; Product p; ItemList li = itemlist::alloc (); ItemRef f1 = item::alloc (); int pg1 = page::get (gFrame); int pg = -1;
pl = productlist::get_established (0, pg1, 0); p = productlist::first (pl);
if (!p) { wlog ("", "No products found!\n"); return 0; } if (product::get (p, kProductType) != 4) { wlog ("", "No page template found!\n"); return 0; }
wlog ("", "Products found on page %d\n", pg1); for (p = productlist::next (pl); p; p = productlist::next (pl)) { if (product::get (p, kProductType) != 0) break; // no a built product product::get_itemlist (p, kProductOriginals, li); if (itemlist::length (li) == 0) break; if (page::get (itemlist::get (li, f1, 0)) != pg1) break; // next page
wlog ("", "[%d, %d %d %s] : used template %d\n", product::get (p, kID), product::get (p, kID2), product::get (p, kID3), product::gets (p, kStringID), product::get (p, kPageitemid)); }
return 0; }
static int reorganize(
ItemRef docRef = 0,
ProductList plist = 0,
ItemRef firstFrame = 0,
int thisPageOnly = 0,
int flags = 1,
char* errmess = 0,
int* failedIndex = 0,
Product* firstEntry = 0)
Reorganization of a document. If th given product list is empty or 0, the document is scanned to get the current document products.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
docRef | ItemRef | 0 | Document 0 : current document |
plist | ProductList | 0 | List of products. You may get such a list by a call to get_established. 0 : Scan the list of products directly from the document at runtime |
firstFrame | ItemRef | 0 | Start reorganization at the Comet group of this frame. 0 : Reorganize whole document |
thisPageOnly | int | 0 | Reorganize only this page 0 : Ignore. Reorganize complete document (starting after firstFrame if given). Otherwise : 1-based page index. In this case firstFrame and plist are ignored. -2 : Clean up only the page where either the first frame of the first product of plist or (if plist is empty) the frame firstFrame is located. If both data are empty, the first page of the document is reorganized. This conforms to the menu "Reorganize page" or (if used with flag kFillPage) the menu "Fill and reorganize page". |
flags | int | kShowProgress | Used flags kShowProgress show progressbar kReloadAll suppress copying contents between frames with same frame labels and same groups on template changes kSuppressAlerts Suppress alerts while building products. Some alerts like 'Object will leave the paste board' are too deep inside InDesign® and cannot suppressed! kIgnoreErrors Ignore errors and continue. This may generate gaps in page elements. Reorganizing the document again will fill this gaps. kPreferExistingPages If document pages are already linked against page templates, prefer this page templates instead of the the page template given in pageTemplate. If the last page is reached, the normal page templates successor rules are used. kLoadMasterItems Seit v3.3 R3051 Override and link all parent page frames linked with placeholders after successfully building all products. In this case, we walk through all pages of the document. If the last products are built using this flag, the option has no effect : Parent page items are overridden/loaded if the flag is set or not. Overriden parent items always lie above the non-overridden items and may cover these frame. If necessary, frames that are to be in the foreground must be provided with an empty placeholder and arranged accordingly. kFillPage since v3.4 R5115 and in case of thisPageOnly > 0 : Fill page before reorganizing. kCropPage since v3.4 R5115 and in case of thisPageOnly > 0 : Insert product-building page breaks around the reorganized page. |
errmess | String or char* | 0 | 0 or allocated string to get error messages (if the variable type is char*, please allocate at least 4000 bytes). |
failedIndex | int* | 0 | Index in plist of th first failed product. |
firstEntry | Product | 0 | Reorganize from the given entry to the end of the list plist 0 : Ignore Otherwise : Valid list entry in plist. The specifications for firstFrame and thisPageOnly are ignored in this case. |
static int get_default_pageitem()
Retreive the current default template selected in the Product pool panel. If the panel is closed, the function will return 0.
Name | Type | Default | Description |
Return | int | ID of default template or 0. |
static int sort(LinkList lli, int cmpFunc)
Sort a list of products.
The compare function cmpFunc must be defined in the script and must be of the following type:
int yourCmpFunction (Product a, Product b)
The function is used by the sorter to check whether two list objects are well placed in the list. At calling time a stands before b. If you want to change the objects positions, return 1 otherwise 0.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
lli | ProductList | - | Valid ProductList. |
cmpFunc | int yourCmpFunction (Product a, Product b) | - | Compare function.The function is used by the sorter to check whether
two list objects are well placed in the list. At calling time a stands before b.
If you want to change the objects positions, return 1 otherwise 0. Do not use script global variables inside the function! |
Get all selected entries of the product pool panel and sort them by different ways. Resuts are written to the log.
#include "internal/text.h" #include "internal/types.h" #include "internal/products.h"
int w_pli (ProductList pli, char * trailer) { Product p;
wlog ("", "%s\n", trailer); for (p = productlist::first (pli); p; p = productlist::next (pli)) { wlog ("", "[%d %d %d, '%s'] (Template %d): '%s'\n", product::get (p, kID), product::get (p, kID2), product::get (p, kID3), product::get (p, kStringID), product::get (p, kPageitemid), product::gets (p, kRow1)); } wlog ("", "\n"); }
int byName_asc (Product a, Product b) { char s1 [8000]; char s2 [8000];
strcpy (s1, product::gets (a, kRow1)); strcpy (s2, product::gets (b, kRow1));
if (strcmp (s1, s2) > 0) return 1;
else return 0; }
int byName_desc (Product a, Product b) { char s1 [8000]; char s2 [8000];
strcpy (s1, product::gets (a, kRow1)); strcpy (s2, product::gets (b, kRow1));
if (strcmp (s1, s2) < 0) return 1;
else return 0; }
int byTemplate_asc (Product a, Product b) { if (product::get (a, kPageitemid) > product::get (b, kPageitemid)) return 1;
else return 0; }
int byID_asc (Product a, Product b) { if (product::get (a, kID) > product::get (b, kID)) return 1;
else return 0; }
int main () { ProductList pli = productlist::get ("selected");
w_pli (pli, "Original");
productlist::sort (pli, byName_asc); w_pli (pli, "By name (ascent)");
productlist::sort (pli, byName_desc); w_pli (pli, "By name (descent)");
productlist::sort (pli, byTemplate_asc); w_pli (pli, "By template (ascent)");
productlist::sort (pli, byID_asc); w_pli (pli, "By id1 (ascent)");
return 0; }
static int update_findstatements(
int reloadFindStatements,
int popupSelection,
int reloadProducts)
Update the search methods popup on the Products panel.
Name | Type | Default | Description |
Return | 0 or ErrorCode | ||
reloadFindStatements | int | 0 | Reload popup entries? 0 : no 1 : yes |
popupSelection | int | -1 | Select this popup entry (0-based with delimiter lines counted) -1 : Do not change selection (if possible) >= number of menu entries : Select last item |
reloadProducts | int | 0 | Reload products? 0 : no 1 : yes |
static int create_snippets(
ItemRef docRef = 0,
int page = 0,
int snippetMatchFlags = 0,
char* snippetContext = 0,
char* snippetLayer = 0,
int snippetFilterFunc = 0)
Create Comet-Snippets from the Comet groups of a given document. Existing snippets matching the same criteria are overwritten. This means: the more specific match criteria are defined, the less snippets are affected by updates. If no matching snippet can be found, new snippet entries are created.
Comet-Snippets are only created from products without continuing frames!
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
docRef | ItemRef | 0 | Document to create snippets from 0 : current front document |
page | int | 0 | Wich pages? 0 : all pages > 0 : only this page -1 : Comet groups of selected frames |
snippetMatchFlags | int | kSnippetsNever | since v4.1.6 R26609 Should Comet Snippets be used? Flags can be added, e.g. kSnippetMatchesProduct + kSnippetMatchesTemplate Set to -1 to show the snippet match criteria dialog. kSnippetsNever : No, don't use snippets kSnippetMatchesProduct : Yes, if products match kSnippetMatchesTemplate : Yes, if templates match kSnippetMatchesDocument : Yes, if documents match kSnippetMatchesLayer : Yes, if layers match kSnippetMatchesContext : Yes, if the contexts match |
snippetContext | String oder char* | 0 | since v4.1.6 R26609 arbitrary string to identify a snippet's "context". This will be used for snippet search and for new snippets created during building. |
snippetLayer | String oder char* | 0 | since v4.1.6 R26609 if provided, also snippets layer also checked against this. |
snippetFilterFunc | int | 0 | since v4.1.6 R26609 Pointer to a function, which is executed before snippet creation to check, whether a snippet should be created for a product or not. The function must be defined in the same script (or be included from a script library) and follow this signature: int (*snippetFilterFunc)(Product p). See prefs::snippet_filter for an example. |
static int remove_snippets(char* key, ItemRef docRef)
Remove Comet-Snippets.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
Snippets eines Dokumentes löschen | |||
key | String or char* | - | "DOC" |
value | ItemRef | - | Remove all snippets of a given document 0 : current front document |
Dokumentauswahl | |||
key | String or char* | - | "DOCID" or "DOCPATH" |
value | String or char* | - | key == "DOCID" : Document-ID of Pubserver key == "DOCPATH" : Complete path of document |
Produkt-ID | |||
key | String or char* | - | "RECORDID" |
id1 | int | - | record ID of snippet(s) to remove |
id2 | int | - | record ID2 of snippet(s) to remove |
id3 | int | - | record ID3 of snippet(s) to remove |
sid | String or char* | - | record string ID of snippet(s) to remove |
static char* to_xml(ProductList list, char* rootElementName = "products")
Generate a XML structure of a ProductList object.
If you think about using this function, you might be interested in further information about cscript / java interaction. Related information can be found here.
Name | Type | Default | Description |
Return | char * | xml string or 0 on errors. The result string is valid until the next time a to_xml function is called and must not be changed or released. | |
list | ProductList | - object | |
rootElementName | String or char* | products | name of the root element |
static ProductList from_xml(char* xml)
Create a ProductList object from an xml structure.
There are two formats in which product lists can be transferred:
This format contains all the data that the products of a Product Pool know (cf. here). The format is used in the PubServer environment and the XML description is expected as string input of this function.
If you think about using this function, you might be interested in further information about cscript / java interaction. Related information can be found here.
<products xsi:type="cscript-products" xmlns:xsi="http:www.w3.org/2001/XMLSchema-instance" xmlns:xs="http:www.w3.org/2001/XMLSchema"> <product> <classId>0</classId> <column1/> <column2/> <docId>0</docId> <gridElementId>0</gridElementId> <gridElementName/> <gridId>0</gridId> <gridName/> <gridElmentId>0</gridElmentId> <pageTemplateElementId>0</pageTemplateElementId> <pageTemplateId>0</pageTemplateId> <forceDelete>false</forceDelete> <id>1</id> <id2>0</id2> <id3>0</id3> <stringId/> <masterPage/> <pageItemId>0</pageItemId> <preRuleId>0</preRuleId> <postRuleId>0</postRuleId> <documentPosition>-1</documentPosition> <toDelete>0</toDelete> <start>-1</start> <end>-1</end> <type>4</type> <tagId1>0</tagId1> <tagId2>0</tagId2> <pageType>1</pageType> <preRuleParams/> <postRuleParams/> <adParams/> <snippetAttribute/> </product> <product> <classId>0</classId> <column1/> <column2/> <docId>0</docId> <gridElementId>0</gridElementId> <gridElementName/> <gridId>0</gridId> <gridName/> <gridElmentId>0</gridElmentId> <pageTemplateElementId>0</pageTemplateElementId> <pageTemplateId>0</pageTemplateId> <forceDelete>false</forceDelete> <id>1</id> <id2>0</id2> <id3>0</id3> <stringId/> <masterPage/> <pageItemId>1</pageItemId> <preRuleId>0</preRuleId> <postRuleId>0</postRuleId> <documentPosition>-1</documentPosition> <toDelete>0</toDelete> <start>-1</start> <end>-1</end> <type>0</type> <tagId1>0</tagId1> <tagId2>0</tagId2> <pageType>-1</pageType> <preRuleParams/> <postRuleParams/> <adParams/> <snippetAttribute/> </product> </products>
This format contains all the information necessary for a product buildup and reorganizations. The format can be read only via input files. The path is specified after a leading file: in the xml parameter of the function. You can get valid items.xmls e.g. by using the Save button of the panel Products of Document from a document with previously built products.
<?xml version="1.0" encoding="utf-8"?> <items version="4.2" pluginRevision="33067" ref="document" documentID="" spreadID="" pageID="" groupID="" elementID="" importFlags="0x0" documentPath="" documentName="" isMissingPlugIns="0" isConverted="0" isModified="1" isReadOnly="0"> <item> <ID>1</ID> <ID2>0</ID2> <ID3>0</ID3> <stringID/> <pageitemID>0</pageitemID> <type>pagetemplate</type> <pageType>1</pageType> <layout_layers/> <document-position>-1</document-position> <groupID>0</groupID> <classID>3</classID> <status>normal</status> <elementID>0</elementID> <preruleID>0</preruleID> <preruleParams/> <postruleID>0</postruleID> <postruleParams/> <keepWithNext>0</keepWithNext> </item> <item> <ID>1</ID> <ID2>0</ID2> <ID3>0</ID3> <stringID/> <pageitemID>1</pageitemID> <type>product</type> <pageType>-1</pageType> <layout_layers/> <document-position>-1</document-position> <groupID>0</groupID> <classID>3</classID> <status>normal</status> <elementID>0</elementID> <preruleID>0</preruleID> <preruleParams/> <postruleID>0</postruleID> <postruleParams/> <keepWithNext>0</keepWithNext> </item> <items>
Name | Type | Default | Description |
Return | ProductList | object of type ProductList. This list must be released using productlist::release. | |
xml | String or char* | - | Valid XML string of an products.xml XML "file://..." [since v4.2 R33100, not supported by Illustrator] Specification of a path to an items.xml XML file. Please note that the syntax of an items.xml is different from a products.xml. The following path specifications are supported:
|
static int add_all(
ProductList target,
ProductList src,
int deleteFromSource)
Append all elements from list src to list target. If deleteFromSource is non-zero, all elements are removed from source list. (but not deleted)
Name | Type | Default | Description |
Return | int | 0 oder Fehlercode. | |
target | ProductList | - | target list |
src | ProductList | - | source list |
deleteFromSource | 0 | delete elements from source |
static int is_in_build(int* pageTemplateID = 0, int* elementSeq = 0)
Is the currently executing script in a product build up or not?
Name | Type | Default | Description |
Return | int | 0 : No, there is no product build active 1 : Yes |
|
pageTemplateID | int* | 0 | If return value is 1 : ID of the currently used page template |
elementSeq | int* | 0 | If return value is 1 : Sequence number of the currently used page element. |
static int get_build_trace(
int* on = 0,
int* showNails = 0,
int* showUIDs = 0,
int* showEdges = 0,
float* resolution = 0)
Get the current values used for build tracings.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
on | int* | 0 | Build tracing activated? 0 : ignore otherwise : The variable will contain the current state (0 off, 1 on) on successful return |
showNails | int* | 0 | Show nails and magnets in build traces? 0 : ignore otherwise : The variable will contain the current state (0 no, 1 yes) on successful return |
showUIDs | int* | 0 | Show frame UIDs in build traces? 0 : ignore otherwise : The variable will contain the current state (0 no, 1 yes) on successful return |
showEdges | int* | 0 | Show frame edges in build traces? 0 : ignore otherwise : The variable will contain the current state (0 no, 1 yes) on successful return |
resolution | float* | 0 | Resolution of build trace images 0 : ignore otherwise : The variable will contain the current resolution on successful return |
static int set_build_trace(
int on = -2,
int showNails = -2,
int showUIDs = -2,
int showEdges = -2,
float resolution = 0.0)
(De)activate build tracing. Build tracing is deactivated after InDesign® restarts automatically!
Build tracing may cause extremely slower building processes. Images are created in the folder $CACHE/BuildTrace. Don't forget to trash this folder from time to time.
Name | Type | Default | Description |
Return | int | 0 or ErrorCode | |
on | int | -2 | Activate build tracing? -2 : Leave untouched -1 : Toggle 0 : Off >0 : On |
showNails | int | 0 | Show nails and magnets? -2 : Leave untouched -1 : Toggle 0 : No >0 : Yes |
showUIDs | int | 0 | Show frame UIDs? -2 : Leave untouched -1 : Toggle 0 : No >0 : Yes |
showEdges | int | 0 | Show frame edges? -2 : Leave untouched -1 : Toggle 0 : No >0 : Yes |
resolution | float | 0 | Resolution of snapshots 0.0 : Leave untouched otherwise : Snapshot resolution in px/pt. Values are delimited in the range [20.0 - 600.0]. |
Here's a simple Javascript building some products of the Comic Showcase.
var gOptions = app.comet.ping () + ";-1;"; var myPath = "/Users/paul/Desktop/aaa.indd";
var gScriptID = 2006; var gScript = "gray">"\ \ #include \"internal/types.h\"\ #include \"internal/text.h\"\ #include \"internal/products.h\"\ \ int main() \ {\ productlist::set_build_trace (1, 1, 1, 0, 56.7);\ return 0;\ }\ ";
app.comet.setEnvironment ("/DATA/CometEnvironment", 2, ""); // XMLData with connections.xml app.comet.use ("demo", "", "", false, ""); // Entry in connections.xml
app.comet.documentOpen (myPath, true, gOptions);
app.comet.eval (gScript, '', '');
var gItemsXML ="gray">"\ <item><ID>1</ID><ID2>0</ID2><ID3>0</ID3><stringID>109007</stringID><pageitemID>1</pageitemID></item>\ <item><ID>1</ID><ID2>0</ID2><ID3>0</ID3><stringID>116507</stringID><pageitemID>1</pageitemID></item>\ <item><ID>1</ID><ID2>0</ID2><ID3>0</ID3><stringID>105507</stringID><pageitemID>1</pageitemID></item>\ <item><ID>1</ID><ID2>0</ID2><ID3>0</ID3><stringID>110007</stringID><pageitemID>1</pageitemID></item>\ </items>" ;
app.comet.build (myPath, // document path Scope.SPREAD, // Scope.SPREAD | Scope.PAGE 0, // spread or page index gItemsXML, // items xml 0.0, 0.0, // x / y gOptions);
app.comet.documentSave (myPath, gOptions); app.comet.documentClose (myPath, gOptions);
#include "internal/products.h"
int main () { ProductList li; Product p; int i;
li = productlist::get ("watched [id3 = 1 or id3=6]"); if (!li) { showmessage ("no products"); return 0; }
showmessage ("-- %d --", productlist::length (li)); for ( p = productlist::first (li); p; p = productlist::next (li)) { showmessage ("%d : %s (template %d)", product::get (p, kID), product::gets (p, kRow1), product::get (p, kPageitemid)); }
return 0; }
Alphabetic index HTML hierarchy of classes or Java