The panel is used to show text and image alternatives for placeholders and products. The screenshot shows an image, a text and a snippet:
The buttons in the first column can be used to set new placeholder contents. The placeholders are not linked to a new object and then reloaded, as is usually the case, but the contents are written directly to the document. In addition, you can drag and drop items directly into frames and into the text. See the tooltips of the panel for more information.
If templates are inserted into texts, the frames are grouped beforehand and then inserted into the text as one inline. If the Alt key is held down when inserting templates into texts, the frames are inserted as individual inliness and the sequence defined in the Template Behavior panel is used.
For inserting images, the settings of the popup menus Image Position and Scale Method in the upper right corner of the paeln are used. If you hold down the Alt key while ,inserting the general import options of InDesign® (layers, clipping paths, color spaces, ...) are requested before inserting images.
Note that placeholders changed in this way are normally out of sync with the contents of the database and changes will be lost when the placeholders are updated.
Use button to toggle bettween large and small lines in the panel.
The search methods are defined in the previewstatements database table resp. in the previewstatements.xml file and appear in the order defined there in search popup at the top left of the panel . Search methods can be classified according to the following criteria:
The classification of the search method is defined in the needsselection attribute of the PreviewStatements (see following table). For placeholder- and product-dependent search statements, the condition attribute (see below) is used before the search to check whether the search can be executed at all. The necessary current placeholder and product values are defined in the corresponding search parameters.
The previewstatements table/file must have the following attributes:
Attribute | Type | Description |
id | int | Unique ID of entry |
classid | int | The field is intended for possible extensions. Currently, only the Previews and Alternatives panel is supported:
6 |
name | string | Name of the search method in the search popup at the top left of the panel. The displayed names can be localized depending on the language. Here you can find information about the field labels.
Only entries whose objectstatementid > 0 are included in the popup. |
sequencenr | int | Specify the order of entries in the search popup. The values do not specify the position, but used to determine the order. |
isdefault | int | The first search method with a value > 0 is selected in the search popup after login automatically. |
needsselection | int |
Classification of the instruction. The classification is displayed below the popup with the available searches.
|
condition | string | Search Condition. The search will only be executed if the condition is met. Conditions are only evaluated in placeholder and product dependent searches (needsselection = 1|2). |
statement | string | In XML Offline and database connections the statement returns the IDs of the found results (ID, ID2, ID2, StringID), see here. The contents of the found results are then determined in a second call defined in objectstatementid.
In SOAP and PubServer connections the complete result including ID is expected, see here. |
objectstatementid | int | In XML Offline and database connections the statement returns the IDs of the found results only. In the objectstatementid attribute, you specify the ID of another PreviewStatement, which is then used to determine the contents of the individual results.
In SOAP and PubServer connections, always set the value to 0. Entries with a value < 0 are included in the popup, but do not perform a search and can therefore be used as delimiters in the search popup. To do this, set the name attribute to the value "-" at the same time. |
hasButtonState [optional] | int | Does the statement return the status of the load button of the list items? More about this see here. |
hasLinkScript [optional] | int | Does the statement contain a specification for the ID of a link script? More about this see here. |
Here is an example of a valid definition in XML. The entry inserts a line separator in the search popup. To do this, the name is set to "-". For the entry to be included in the popup at all, the objectstatementid must also be set. Since nothing is to be loaded, here a -1.
<previewstatements> <previewstatement> <id>50</id> <name>-</name> <classid>6</classid> <needsselection>0</needsselection> <condition></condition> <statement></statement> <objectstatementid>-1</objectstatementid> <sequencenr>50</sequencenr> <isdefault>0</isdefault> <hasButtonState>0</hasButtonState> <hasLinkScript>0</hasLinkScript> </previewstatement> </previewstatements>
Searches for XML and database connections are executed in two steps :
Search statements for PubServer and SOAP connections are executed in one step, which fetches IDs and values to be displayed at the same time.
Additional conditions can be used to restrict the list of results to the search field specifications.
This statement is executed only for XML and database connections. For SOAP and PubServer connections see here. The statement must return the following values :
Type | Description |
int, int, int, string | ID of the entry.
The ID usually corresponds to a valid ID of an object of the specified class with which a placeholder can be relinked in the document. Bei Snippets ist es die ID des Templates, das eingesetzt werden soll. Ist nichts anderes angegeben, wird dabei als Datenquelle pageitems.data verwendet. Wollen Sie eine andere Datenquelle verwenden, müssen Sie das im Statement der einzelnen Einträge angeben (siehe hier). For snippets, it is the ID of the snippet to be used. If nothing else is specified, pageitems.data is used as the data source. If you want to use another data source, you have to specify this in the statement (see here for more information). |
int | ClassID of the entry. As a rule, enter a 3 here (for the Product Pool). |
int, int, int, int | Free key values. These values can be accessed with <key1>, .., <key4> when loading the entries using the objectstatementid statement. |
string | Free key value. These valu can be accessed with <stringkey1> when loading the entries using the objectstatementid statement. |
Use Alt-click in the search popup to edit the search entries.
Here is a valid XML statement for loading the IDs. For better readability, the quotation marks, > and < are not XML-encoded here. So if you paste the statement text directly into an XML file, you must XML-encode these characters.
"$FLOWERS" select id, 0, 0, "", <!-- ID --> 3, <!-- class --> 0, 0, 0, 0, <!-- <key1>, ... --> "" <!-- <stringkey> --> node flowers.flower where id > 0
Here is a valid SQL statement for loading the IDs. All entries of a table named comet_snippets_2 should be shown in the list.
select id, 0, 0, '', 3, 0, 0, 0, 0, '', 1, 1 from comet_snippets_2 where id > 0
[XML and database connections] The list entries are loaded one by one using the results of the first search statement. The command must contain a ? value, which is replaced by the respective ID (i.e. the first column of the parent search statement). If more values of the list IDs are needed, this can be done using the usual tags <ID2>, ... , see here. Additionally, the values <key1>, .., <key4> and <stringkey> defined in the list search can be queried.
[PubServer- and SOAP connections] The list entries are loaded including their IDs in one call. The call therefore does not contain a '?' value with which the list ID must be referenced.
The value of the (yellow marked) result columns Path determines the type of the entry:
Please note that the result columns must be complete except for the last two columns. Missing entries can be filled with 0 or "".
Name | Type | Description | ||
• For SOAP connections only | ||||
ID | int | ID of the preview entry consisting of ID, ID2, ID3 and StringID | ||
ID2 | int | |||
ID3 | int | |||
StringID | string | |||
• Image Entry Details | ||||
ImageName | string | Entry name
For image entries with URL only : If empty and the URL ends with a ////-separated specification of a Web Image Display Name, then this display name is used as the name. |
||
Path | string | Non-empty paths create an image or a snippet. The following values are supported:
Attention : Despite all efforts, it may happen that URLs cannot be resolved. Non-resolvable URLs are not subject of the WERK II support! Please feel free to contact our support in these cases, but please understand that we treat enhancements in this area as (chargeable) feature requests.
Empty : Text entry. The information about the image entry (up to the green line) is ignored (but must be present!). |
||
Format | string | Image format or "" | Missing information we try to read directly from the image data. Please understand that we can only support common image formats like JPEG, PNG, GIF etc. here. | |
Width | string | Image width in px or 0 | 1 | ||
Height | string | Image height in px or 0 | 1 | ||
Resolution | string | Image resolution in dpi or 0 | ||
Color Depth | string | Image color depth in bits per pixel or 0 | ||
ButtonState | int | State of Load Button. If the attribute hasButtonState = 1 is set for the statement, the button status is expected here :
If hasButtonState is not defined or 0, the buttons are visible and enabled. |
||
LinkScript | int | Action to execute after Inserting. If the attribute hasLinkScript = 1 is set for the statement, the specification contains the ID of the action to be performed for the target frame/text after the record is inserted into the document. | ||
• Text/Snippet Entry Details. The columns are mandatory even for image entries! | ||||
Text Entry (Path == "") | Snippet (Path == "snippet@...") | Image | ||
TextName | string | Name of text entry | Second line of the second text column.
For backward compatibility reasons, the order of the fields here is unfortunately a bit confusing. |
ignored |
TextInfo1 | string | Description of the entry | Third line of the second text column | ignored |
TextInfo2 | string | ignored | First line of the second text column | ignored |
TextContent | string | Text content. The specification may contain TaggedText. For the panel display, the tags are filtered out and only the plain text is shown. | Snippet description, second line of the first text column | Image placement, see here. |
SnippetTable | string [optional] | ignored | Load snippet from custom source : Name and attribute of the table from which a snippet should be loaded (e.g. "comet_snippets_2", "data"). If the information is missing, snippets will be loaded from pageitems.data. See here for Custom data sources. | ignored |
SnippetAttr | string [optional] | ignored | ignored |
For images, information about positioning, clipping path, etc. can be given in the Content result column. The specifications correspond to the information also given in image placeholders with the only difference that clipping paths must always be identified by their index and not by their name. The information must be given in the following format (and separated without commas) :
Type | Description | Default |
int | Image Position | 5 |
double | Image size | 0.0 |
int | Index of clipping path (see frame::image) | -2 |
int | Clipping parameters | 4 |
int | Clip to frame | 0 |
double | Tolerance | 0.0 |
double | Minimum path size | 0.0 |
double | Inset | 0.0 |
int | Index of Alpha channel (see frame::image) | -2 |
String | Name of Alpha channel (see frame::image) | "" |
If only default values are used, the information may also be missing. Valid positioning info would therefore be:
The snippets described here are different from the Comet 4 Snippets introduced with Comet 4.0.5. A description of the Comet snippets can be found here.
Here are some examples of Snippet definitions:
Data Pool | Example | Description |
XML | snippet@ | Use the entry from pageitems.xml with the ID of the entry |
snippet@'pageitems.xml' select preview.src node pageitems.pageitem where id = <ID> | Load the file path | |
SQL | snippet@ | Use file blob with line id from pageitems |
snippet@select preview from pageitems where id = <ID> | Use file blob | |
SOAP | snippet@ | Use the entry from pageitems.xml with the ID of the entry |
snippet@pageitems/preview/<ID>.gif | Use a FileID. The file is loaded with getBinaryFile. Be sure to specify an empty string ('') before the statement when using call or other SOAP statements. | |
snippet@'pageitems.xml' select preview.src node pageitems.pageitem where id = <ID> | ||
snippet@'' call ... |
The last two columns SnippetTable and SnippetAttr of the instructions for loading the preview entries are optional and are only evaluated for Snippet entries. In this case they contain the description where to search for the snippets. If they are missing, "pageitems" and "data" are used automatically.
The columns indicate the subfolder in the XML data folder where the snippets are located. In this subfolder snippets are located as files under their ID. The following formats are supported : INDD, INDS, IDMS.The format can be specified in the second subfolder as a number and separated by commas (1 INDD, 2 INDS, 3 IDMS). If the format is missing, INDDs are expected.
"snippets", "data" lädt für die Snippet-ID 4 die Datei:
xml-ordner/snippets/data/4.indd
Snippets in InDesign®-Snippet format IDMS : "snippets", "data, 3" loads the following file:
xml-ordner/snippets/data/4.idms
The columns specify the table and attribute (in that order) where the snippets are stored. The table must also have the int attribute format. This attribute defines the format of the data in the BLOB (1 INDD, 2 INDS, 3 IDMS).
"snippets", "data" executes the following statement to load the snippet:
select data, format from snippets where id = 4;
The ID of the snippet plus a file extension are used as the SOAP ID. The two columns are prepended to this SOAP ID. Here too, as with XML, a comma-separated format specification may be made in the second parameter (1 INDD, 2 INDS, 3 IDMS). The format specification does not become part of the SOAP ID.
"snippets", "data" loads the following file for the snippet ID 4
snippets/data/4.indd
"snippets", "data, 3" loads the following file for the snippet ID 4
snippets/data/4.idms
Here is an XML statement for each preview type. In all three examples the columns ButtonState and LinkScript are not included, so in the definition of the statements in PreviewStatements the attributes hasButtonState and hasLinkScript must both be set to the value 0!
For better readability, the quotation marks here are not XML-encoded. So if you paste the statement text directly into an XML file, you still need to encode these characters in an XML-compliant way.
"pageitems.xml"
select
"Image Name",
"$DESKTOP/Bilder/orange.jpg",
"Image Format",
400, 300, 360, 8,
<!-- Omit ButtonState and LinkScript -->
"",
"",
"",
""
node pageitems.pageitem where id = ?
If you enter empty data in the columns Format and ImageInfo1-4, the corresponding image information will be calculated automatically internally:
"pageitems.xml"
select
"Image Name",
"$DESKTOP/Bilder/orange.jpg",
"",
0 0 0 0,
<!-- Omit ButtonState and LinkScript -->
"",
"",
"",
""
node pageitems.pageitem where id = ?
"pageitems.xml"
select
"Image Name",
"snippet@",
"",
0, 0, 0, 0,
<!-- Omit ButtonState and LinkScript -->
"",
"Column 1",
"Column 2",
"Text Content"
node pageitems.pageitem where id = ?
"pageitems.xml"
select
"Text Name",
"",
"",
0, 0, 0, 0,
<!-- Omit ButtonState and LinkScript -->
"",
"Column 1",
"",
"%!TT<cSsize:24.0>Text Content"
node pageitems.pageitem where id = ?
The status of the load button in the individual lines of the list can be defined when loading the list entries. If nothing else is specified, the buttons are visible and active. Here is how to restrict the availability of the buttons :
[Since Version 3.1 R 1730, 5. Feb. 2010] List entries can also be loaded using a script. In this case, the statement attrubiute simply contains a script.
For script entries, no further preview statements are needed to fill the individual list entries. You fill the list entries directly in the script. For the entry to appear in the search popup, the objectstatementid must be set to a value not equal to 0 in addition.
The following table specifies the global variables defined in these scripts:Name | Type | Description |
gProducts | IDTypeList | Result List of previews to be shown |
gButtonState | int* | Status of the preview loading button (since Comet 3.1 R2178, 22. Okt. 2010)
Attention : If you set *gButtonState = -1, the value kPreviewButtonState must be defined in each product. Conversely : If you want to set the values in each product individually, you must include the following line into your script: *gButtonState = -1; |
gLinkScript | int* | ID of the action to be performed after inserting the entry (text or image), see here.
If you enter a value >= 0 it will be used for all entries of the list gProducts. Otherwise set the value with product::set and the slot kPreviewLinkScript. Attention : If you set *gLinkScript = -1, the value kPreviewLinkScript must be defined in each product. Conversely : If you want to set the values in each product individually,you must include the following line into your script: *gLinkScript = -1; |
gSearchField1, gSearchField2 | char*, char* | [Since v3.3 R2660, 26. Sept. 2011] Current values of the two search fields. Unlike normal Preview statements (that execute a select statement), the contents of the search fields are not automatically extended by '%' here. |
The entries that should appear in the list are inserted into the global product list gProducts of the script. Be sure to create the individual entries with kGlobalStack. All specifications in the entries are treated like in the normal lists. So you create e.g. text entries by setting the path specification to empty (""). For a description of the defined values for previews, see product::set.
Here's an example:
#include "internal/types.h" #include "internal/text.h" #include "internal/products.h" int create_preview ( int i1, int i2, int i3, char * s1, char * name, char * path, char * fmt, int w, int h, int res, int depth, char * descr, char * info1, char * info2, char * info3, int clid, int del) { Product p = 0; p = product::alloc (kGlobalStack); product::set (p, kID, i1); product::set (p, kID2, i2); product::set (p, kID3, i3); product::set (p, kStringID, s1); product::set (p, kPreviewName, name); product::set (p, kPreviewPath, path); product::set (p, kPreviewFormat, fmt); product::set (p, kPreviewWidth, w); product::set (p, kPreviewHeight, h); product::set (p, kPreviewResolution, res); product::set (p, kPreviewBitDepth, depth); product::set (p, kPreviewTextName, descr); product::set (p, kPreviewInfo1, info1); product::set (p, kPreviewInfo2, info2); product::set (p, kPreviewText, info3); product::set (p, kPreviewClassID, clid); product::set (p, kPreviewToDelete, del); productlist::append (gProducts, p); return 0; } int main () { Product p; create_preview ( 2, 0, 0, "", "Qualitätsarbeit", "$DESKTOP/12.idml", "", // Format leer! 0, 0, 0, 0, "Bild1", "info-1", "info-2", "info-3", 0, 0); create_preview ( 3, 0, 0, "", "Tantarantana", "$DESKTOP/Bilder/tantarantana.jpg", "JPG", 100, 200, 72, 8, "Bild1", "info-1", "info-2", "info-3", 0, 0); create_preview ( 14, 0, 0, "", "Ein Text", "", "", // Pfad leer! 0, 0, 0, 0, "Textname", "Info1", "info2", "Und das ist der Text : <0x00FC>äöü", 0, 0); create_preview ( 17, 0, 0, "", "Kho Payam", "snippet@", "JPG", 700, 800, 75, 64, "Bild4", "info-10", "info-11", "info-12", 0, 0); return 0; }
Placeholder and product-dependent searches ask whether the search should be carried out at all before the search is triggered. To do that, the condition specification is checked before. This string must contain a valid boolean condition and is checked locally, i.e. it must not contain any database instructions.
Here is a valid condition to test whether a placeholder is selected in the document and whether this placeholder is a product. You can find out more about the permitted tags here.
<selection.placeholder> > 0 and <selection.class> = 3
The search methods can use all global standard tags. Local tags like <page> are undefined.
The following additional tags are defined for the placeholder-dependent searches (needsselection == 1). The tags each contain the values of the first placeholder found in the document. Unless otherwise specified, the tags can be used in all statements for loading the List IDs, the List Entries and testing the search conditions.
Name | Type | Description |
<selection.ID> | int | ID of the first placeholder selected in the document. |
<selection.ID2> | ||
<selection.ID3> | ||
<selection.stringID> | string | |
<selection.placeholder> | int | Placeholder ID of the first placeholder selected in the document |
<selection.class> | int | ClassID of the first placeholder selected in the document. |
<selection.text> | string | Text of the current document selection (shortened to max. 4000 characters). If the text selection is not active, the string is empty. |
<selection.tagtext> | string | |
<selection.tagpath> | string | Image path of the currently selected placeholder frame. If no placeholder frame is selected or no image is defined, the string is empty. |
Only defined when loading the the List Entries (objectstatementid = 0) | ||
<ID> | int | ID, which was determined when the List IDs were loaded. |
<ID2> | ||
<ID3> | ||
<StringID> | string | |
<key1> | int | Values from the associated statement for loading the List IDs |
<key2> | ||
<key3> | ||
<key4> | ||
<stringkey> | string |
The following additional tags are defined for the product-dependent searches (needsselection == 2). The tags each contain the values of the first entry selected in the Product Pool panel. Unless otherwise specified, the tags can be used in all statements for loading the List IDs, the List Entries and testing the search conditions.
Tag | Type | Description | ||||
<product.id> | int |
ID of the first selected entry in the Product Pool panel. |
||||
<product.id2> | int | |||||
<product.id3> | int | |||||
<product.stringid> | string | |||||
<product.pageitemid> | int | Which tepmplate should be used to load the first selected entry in the Product Pool panel? | ||||
<product.docid> | int | Information for the Grid based product build-up of Comet 3.0. The information is supported by Comet 4.0 but is no longer used. | ||||
<product.masterpage> | string | |||||
<product.grid> | string | |||||
<product.gridid> | int | |||||
<product.element> | string | |||||
<product.elementid> | int | |||||
<product.needsrequest> | int | |||||
<product.defined> | int | |||||
<product.level> | stringlist::getint | Absolute treeview depth in the product tree | ||||
<product.substatement> | string | For entries with sub-elements, the instruction for loading the sub-elements. Otherwise empty. | ||||
<product.classid> | stringlist::getint | Class ID of the first selected entry in the Product Pool panel. | ||||
<product.row1> | stringlist::gettext | Text of the first/second text column of the first selected entry of the Product Pool panel. | ||||
<product.row2> | stringlist::gettext | |||||
<product.pre_ruleid> | int | ID and parameters of the rules for preparing and post-processing the first selected entry in the Product Pool panel. These parameters are no longer relevant in Comet 4 applications. | ||||
<product.pre_ruleparams> | string | |||||
<product.post_ruleid> | int | |||||
<product.post_ruleparams> | string | |||||
<product.adparams> | string | |||||
<product.snippet_attr> | string | Name of the database/XML attribute in which the snippet is stored. | ||||
<product.buttonstate> | int | See above under gButtonState | ||||
<product.linkscript> | string>int | See above under gLinkScript |
[Since v4.3 R35700] All tags defined for the search conditions can also be used directly in scripts. To do this, write the tags directly (including the brackets) in your script. The tags are then automatically replaced by their values before execution.
In the example, <product.id> is automatically replaced by the ID of the first selected product (or 0) before execution.
if (<product.id> == 120)
{
...
}
Please take care, the automatic replacement of tags does not work, of course, if you use the text of a tag, e.g. <product.id>, in a different meaning, e.g. as text output!
In versions prior to v4.3 R35700, these tags are not defined in scripts. However, you can easily determine the relevant information using the corresponding cScript/Python functions. Placeholder-relevant information, for example, can be obtained using the functions textmodel::selection and placeholder::(s)get_value.
Determine the product ID plid of the first selected placeholder in the document.
ItemRef frame = item::alloc (); ItemList frames = itemlist::alloc (); int s, e; int plid = 0; char sid [5000]; textmodel::selection (&s, &e, frame, frames); if (s < 0) frame = itemlist::get (frames, frame, 0); plid = placeholder::get_value (frame, "ID", s); item::release (frame); itemlist::release (frames);
Product-relevant information you can obtain using the functions stringlist::alloc (3, kSelected) or productlist::get ("selected").
Determine the ID plid of the first selected entry of the Product Pool panel.
#include "internal/panels.h" StringList sl = stringlist::alloc (kPanelProducts, kSelected); int plid = 0; if (stringlist::length (sl) > 0) { plid = stringlist::getint (sl, 0, "ID"); }
[ab v3.3 R2660, 26. Sept. 2011] Die Ergebnisliste kann mit zwei Suchfeldern eingschränkt werden. Auf die Inhalte der Suchfelder kann wie folgt zugegriffen werden :
Anweisungstyp | Beschreibung |
select, xmlquery, SOAP-Call |
<SearchField1>, <SearchField2> Die Tags werden jeweils durch den aktuellen Inhalt der Suchfelder plus '%' ersetzt. Sollen die Suchkriterien Strings ersetzen, müssen die Tags ebenfalls in gültige Anführungszeichen gesetzt werden. <SearchField1_nopercent>, <SearchField2_nopercent> Diese Tags werden mit dem aktuellen Inhalt der Suchfelder ohne '%' ersetzt. Sollen die Suchkriterien Strings ersetzen, müssen die Tags ebenfalls in gültige Anführungszeichen gesetzt werden. |
cScript |
char * gSearchField1, gSearchField2; Die beiden Variablen sind mit den aktuellen Inhalten der Suchfelder gefüllt. Es wird kein '%' an den Inhalt angefügt. |
The search fields can be labeled according to the statement. For this purpose, you can add the names of the search fields separated by ## to the name of the entry in the definitions of the preview statements. The individual name parts are translated individually.
Here is an XML definition of a preview statement with custom names for the search fields:
<id>1004</id>
<name>Einige Templates (Script)##Namensanfang##ID kleiner</name>
<classid>6</classid>
<needsselection>0</needsselection>
<condition></condition>
<statement>...</statement>
<sequencenr>0</sequencenr>
<domain></domain>
<isdefault>0</isdefault>
</previewstatement>
The entries of the list can react to double clicks. The action to be performed is defined as follows:
Here are some examples of valid panel statements with which the double-click ID can be defined.
select 900+<depth> from dual; "datafiles.xml" -- beliebige XML-Datei select 900+<depth> select id%3 from ... where ID = ? select id%3 from ... where ID = <ID> -- Die ?en sind optional
And here is a simple double-click script
int main () { showmessage ("Zeile %d, ID = %d", gClicked+1, gRecordID); return 1; }
After insertion into the document, the new data can be post-processed with the so-called Link Script. For example, you can reset the object ID of the target placeholder in this script.
The link script is shown also in the help text of the entries.
How to define a link script for an entry of the Preview panle.
The following global variables are defined in the link scripts:
Name | Typ | Beschreibung |
gRecordID | int |
ID of the preview entry that triggered the script. |
gRecordID2 | ||
gRecordID3 | ||
gRecordStringID | string | |
gRecordStringID1 | ||
gRecordStringID2 | ||
gRecordStringID3 | ||
gImageAlign | int | Setting image position and scaling in the Previews palette |
gImageSize | float | Currently always 0.0 |
gInsertedFrames | ItemList |
Snippets can insert new frames into the document. The list contains the newly inserted frames. If no frames were inserted, this list is 0. Frames can also be inserted as inline frames. Note the restrictions that apply to inline frames. For example, you must not move these frames to a new page or layer. |
gSnippetStart | int |
Current insertion position and length for text replacements. If the contents of text placeholders are replaced by simple text entries, these specifications are identical to gStart and gLen. However, when text snippets are inserted, the placeholder is removed, gStart is then 0 and gLen is the length of the entire text. So that you know the current text positions anyway, there are gSnippetStart and gSnippetLen. If snippet frames are inserted in the document (and not as inlines in the text), the variables have the following values : |
gSnippetLen |
The scripts for text, image and snippet differ a little in the basic structure. Here is an example for each case.
A text was inserted (not by a snippet). The ID of the preview entry should then be used as the object ID. For demonstration purposes, another text is added to the new text.
Attention : In general, of course, this is not quite correct. The IDs of the preview list are normally not valid object IDs. In this case you could have used the Product Pool.
int main () { placeholder::link ( gFrame, 3, gRecordID, gRecordID2, gRecordID2, gStart, gLen, gRecordStringID); textmodel::append ("AAA"); return 0; }
An image has been replaced. Enlarge it to fill the frame and center it.
int main () { frame::fit_image (gFrame, 1); frame::fit_image (gFrame, 5, 5); return 0; }
A snippet has been inserted. If text was replaced (also by inline frames), a marker is inserted behind the new text. If page frames were inserted, they get a random (but same) color.
int main () { if (gSnippetLen >= 0) { textmodel::insert ("by action 905", gSnippetStart+gSnippetLen); } else if (gInsertedFrames) { itemlist::apply ( frame::color_rgb, gInsertedFrames, 0, random (255), random (255), random (255), -1, -1); } return 0; }
[Since v4.0.5 R8410]
Comet 4 sSnippets are InDesign®-compatible versions of built-up products. They can be inserted anywhere in documents. Comet4 snippets can be uniquely assigned in the combination of the following three specifications:
Comet snippets cannot go across multiple pages. Therefore, when saving snippets, only products that do not have continuations are saved. To create and delete Comet snippets, use the +, -, x buttons of the Previews panel or the script commands productlist::create_snippets and productlist::remove_snippets.
While building up products, you can decide whether products should be rebuilt in each case or whether a Comet4 snippet should be used. When inserting snippets, no placeholder data is loaded and no further layout rules are executed.
In the popup menu of search methods there are two methods for showing the available Comet snippets:
The menus are only available if the current data connection supports Comet snippets (See here for more).
The menus are always added to the end of the search methods.
Use the checkbox Document selection/Customize product selection to suppress the automatic reloading of the snippets.
Note: The snippets described here are not identical to the Comet snippets described above.
Here is a validSQL statement for loading the preview IDs for showing all entries of comet_snippets_2.
select id, 0, 0, '', 3, 0, 0, 0, 0, '', 1, 1 from comet_snippets_2 where id > 0
Matching the second example of list loading, here is the instruction for loading the snippet entries. The snippets are not loaded from the default pageitems table, nor do the IDs come from this table. To ensure that the correct data file is used when inserting a snippet into a document, the table (comet_snippets_2) and attribute (data) of the data source must be specified here.
select name, "snippet@select preview from comet_snippets_2 where id = <ID>", "" , CONVERT (rightPos-leftPos, UNSIGNED), CONVERT (bottomPos-topPos, UNSIGNED), 0, 0, 2, // hasButtonState der Listensuche auf 1 setzen! 0, // hasLinkState der Listensuche auf 1 setzen! "Info1", "Info2","info3" , "Snippetbeschr", "comet_snippets_2", "data" from comet_snippets_2 where id = <ID>
The table comet_snippets_2 must be defined at least as follows (mySQL) :
create table snippets
(
ID int(10),
name varchar (4000),
data longblob,
preview longblob,
format int(10),
leftPos float(10,4),
topPos float(10,4),
rightPos float(10,4),
bottomPos float(10,4)
);
And here is an example script how the comet_snippets_2 table could be filled.
#include "internal/types.h" int main () { Query qu = sql::query (sql::dbconnection ()); long id = 0; char path [2000]; ItemList frames = itemlist::selected (); Image img = 0; float l, t, r, b; // create content strcpy (path, "$DESKTOP/aaa"); itemlist::create_snippet (frames, path, 1); itemlist::bbox (frames, &l, &t, &r, &b); img = image::snapshot_frames (frames, 100); // next free comet_snippet id query::send (qu, "select max(id) from comet_snippets_2"); query::output (qu, kInt, &id); query::exec (qu); while (query::fetch (qu)) {} id = id + 1; // create the new entry query::send (qu, "insert into comet_snippets_2 (ID, active, leftPos, topPos, rightPos, bottomPos) values (?, 3, ?, ?, ?, ?)"); query::input (qu, kInt, id); query::input (qu, kFloat, l); query::input (qu, kFloat, t); query::input (qu, kFloat, r); query::input (qu, kFloat, b); query::exec (qu); // store snippet strcat (path, ".idms"); query::send (qu, "update comet_snippets_2 set data = ?, preview = ?, format = 3 where ID = ?"); query::input (qu, kBinfile, path, kCopyLocalFile, "PICT"); query::input (qu, kImage, img); query::input (qu, kInt, id); query::exec (qu); // clean up query::close (qu); image::release (img); itemlist::release (frames); file::remove (path); return 0; }
If image files are to be displayed for which no preview exists, the program tries to generate a preview matching the disired size. The generation of the preview can take some time, so generated previews are cached on your hard disk. If the image file changes, the preview is updated automatically. The previews are saved in the preferences of the user:
The files and folders in this storage can be deleted but not modified. Using the buttons they can also be deleted from the panel.
The preview files contain, although their ending suggests that, no valid images of the respective image format and can not be opened with other programs. The format of these files is as follows (the actual image data and the previews begin only at the last entry in the format description):
Datatype | Value | Description |
int | flen | Length of the following string with the specification of the file format |
flen chars | File Format | |
int | Image width in pixels | |
int | Image height in pixels | |
int | Image resolution in dpi | |
int | Color depth (1, 2, 4, 8, 24) | |
int | blen | Size of the preview in bytes |
int | Preview width in pixels | |
int | Preview height in pixels | |
int | Bits per image line (for the color depth of the preview) | |
int | 1 | Internal image format |
int | 24 | Internally used color depth |
blen chars | Preview |