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.
Die Suchmethoden werden in der Datenbanktabelle previewstatements und/oder in der Datei previewstatements.xml definiert und erscheinen in der dort festgelegten Reihenfolge oben links im Suchpopup der Palette. Suchmethoden können nach folgenden Kriterien klassifiziert werden
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 executed at all before triggering the search itself. For this purpose, the Condition result column is checked. The string must contain a valid boolean condition. The condition is checked locally, so it must not contain any database statements.
Here is a valid condition. The condition tests whether a placeholder is selected in the document and whether this placeholder is a product. You can learn more about the allowed tags here.
<selection.placeholder> > 0 and <selection.class> = 3
In the statements of the search methods you can access global values of the environment using usual tags. Note, however, that you can only access values that are globally defined, but, for example, the value of <page> is undefined of course here.
In addition to these values, a number of local values are defined that allow you to learn more about the current situation. The following table describes the tags. The tags can be used in all statements for loading the list IDs, list entries and testing the search condition, unless otherwise specified.
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 | Text of the currently selected placeholder in the document (shortend to max. 4000 characters). If no placeholder is selected, the string is empty. |
<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. |
<product.KEY> with KEY defined in the Table of Product Keys, e.g. <product.id> or <product.level> | See Table of Product Keys | Keword of the first selected product of the Product Pool |
Only defined when loading the list entries (objectstatementid = 0) | ||
<ID> | int | ID while loading the list entries |
<ID2> | ||
<ID3> | ||
<StringID> | string | |
<key1> | int | Values from the associated statement for loading the list IDs |
<key2> | ||
<key3> | ||
<key4> | ||
<stringkey> | string |
In scripts, of course, these tags are not defined. However, you can easily determine the corresponding information :
Placeholder relevant info
ItemRef frame = item::alloc (); int s, e; int ID = 0; char sid [5000]; textmodel::selection (&s, &e, frame); if (s >= 0) { plid= placeholder::get_value (frame, "ID", s); strcpy (sid, placeholder::sget_value (frame, "StringID", s)); }
Product relevant info
StringList sl = stringlist::alloc (3, kSelected); char row1 [5000]; int tid = 0; if (stringlist::length (sl) > 0) { tid= stringlist::getint (sl, 0, "PageitemID"); stringlist::gettext (sl, 0, "Num", row1); }
The stringlist::gettext and stringlist::getint functions used for the product-relevant information use different identifiers for the respective info. The following table shows the "translations":
Tag | Function | Parameter attribute in stringlist::get~ |
id | stringlist::getint |
ID |
id2 | stringlist::getint | ID2 |
id3 | stringlist::getint | ID3 |
stringid | stringlist::gettext | StringID |
pageitemid | stringlist::getint | PageitemID |
docid | stringlist::getint | DocID |
masterpage | stringlist::gettext | Masterpage |
grid | stringlist::gettext | Grid |
gridid | stringlist::getint | GridID |
element | stringlist::gettext | GridElement |
elementid | stringlist::getint | GridElementID |
needsrequest | n/a | |
defined | n/a | |
level | stringlist::getint | Depth |
substatement | stringlist::getint | StatementID |
classid | stringlist::getint | ClassID |
row1 | stringlist::gettext | Num |
row2 | stringlist::gettext | Name |
pre_ruleid | n/a | |
pre_ruleparams | n/a | |
post_ruleid | n/a | |
post_ruleparams | n/a | |
adparams | n/a | |
snippet_attr | n/a | |
preview_buttonstate | siehe oben unter gButtonState | |
preview_linkscript | siehe oben unter gLinkScript |
[Dince v3.3 R2660, 26. Sept. 2011] The result list can be restricted with two search fields. The contents of the search fields can be accessed as follows :
Statement Type | Description |
select, xmlquery, SOAP-Call |
<SearchField1>, <SearchField2> The tags are replaced by the current content of the search fields plus '%'. If the search criteria are to replace strings, the tags must also be enclosed in valid quotation marks. <SearchField1_nopercent>, <SearchField2_nopercent> These tags are replaced with the current content of the search fields without '%'. If the search criteria are to replace strings, the tags must also be enclosed in valid quotation marks. |
cScript |
char * gSearchField1, gSearchField2; The two variables are filled with the current contents of the search fields. No '%' is added to the content. |
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 |