Skip to content

Commit

Permalink
Merge pull request #14 from RolandDreger/ui
Browse files Browse the repository at this point in the history
Graphical user interface
  • Loading branch information
RolandDreger authored Sep 11, 2022
2 parents 98f7b8c + e31eaa4 commit 7075d2b
Show file tree
Hide file tree
Showing 3 changed files with 694 additions and 9 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ For special cases you can hook into the import with JavaScript, e.g. to create y
|Option|Property|Type|Default|Description|
|---|---|---|---|---|
|Logging|isLogged|Boolean|false|Logging of info messages, e.g. which objects are created in InDesign in the course of the import. Warning messages will always be output.|
|Dialog|isDialogShown|Boolean|false|Whether dialog is displayed or not. (Not implemented yet.)|
|Dialog|isDialogShown|Boolean|true|Whether dialog is displayed or not. With `false` the dialog can be displayed by pressing and holding the **Shift** key when opening the document (click on the **Open** button).|

# Document Settings

Expand Down Expand Up @@ -196,8 +196,9 @@ Hyperlinks are automatically named by InDesign and not renamed by the script. Th

|Option|Property|Type|Default|Description|
|---|---|---|---|---|
|Mark|isMarkec|Boolean|false|Insert hyperlink as plain text and mark with condition.|
|Mark|isMarked|Boolean|false|Insert hyperlink as plain text and mark with condition.|
|Create|isCreated|Boolean|true|Insert as InDesign hyperlink.|
|Ignore|isIgnored|Boolean|false|Ignore hyperlinks. Text content is imported as it is.|
|Character Style|characterStyleName|String|Hyperlink|Character style applied to the hyperlink text.|
|Add Character Style|isCharacterStyleAdded|Boolean|false| Add a character style to hyperlink text.|

Expand All @@ -211,6 +212,7 @@ Please check after the import if these correspond to your needs. Otherwise deact
|---|---|---|---|---|
|Mark|isMarked|Boolean|false|Insert cross-reference as plain text and mark with condition.|
|Create|isCreated|Boolean|true|Insert as InDesign cross-reference.|
|Ignore|isIgnored|Boolean|false|Ignore cross-references. Text content is imported as it is.|
|Character Style|characterStyleName|String|Cross_Reference|Character style applied to the cross-reference text.|
|Add Character Style|isCharacterStyleAdded|Boolean|false|Add a character style to cross-reference text.|

Expand All @@ -219,7 +221,7 @@ Please check after the import if these correspond to your needs. Otherwise deact
|Option|Property|Type|Default|Description|
|---|---|---|---|---|
|Create|isCreated|Boolean|false|Insert as InDesign bookmark.|
|Marker|marker|String||Marker as a prefix of the content to identify bookmarks to be included. Example: Marker `#`, Bookmark in Word `#My_bookmark_name`. So Word bookmarks with prefix `#` will be transferred to InDesgin bookmarks.|
|Marker|marker|String||Marker as a prefix of the content to identify bookmarks to be included. Example: Marker `#`, Bookmark in Word `#My_bookmark_name`. So Word bookmarks with prefix `#` will be transferred to InDesign bookmarks.|

# Track Changes

Expand Down
210 changes: 205 additions & 5 deletions importDocx.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
+ Author: Roland Dreger
+ Date: January 24, 2022
+ Last modified: July 7, 2022
+ Last modified: September 11, 2022
+ Descriptions
Expand All @@ -29,10 +29,10 @@

var _global = {
"projectName":"Import_Docx",
"version":"0.3.1",
"version":"0.4.0",
"mode":"release", /* Type: String. Value: "debug" or "release" */
"isLogged":false,
"isDialogShown":false,
"isDialogShown":true,
"log":[]
};

Expand Down Expand Up @@ -119,7 +119,8 @@ _global["setups"] = {
"characterStyleName":"Hyperlink",
"isCharacterStyleAdded":false,
"isMarked":false,
"isCreated":true
"isCreated":true,
"isIgnored":false
},
"crossReference":{
"tag":"cross-reference",
Expand All @@ -133,7 +134,8 @@ _global["setups"] = {
"isAnchorHidden":true,
"isCharacterStyleAdded":true,
"isMarked":false,
"isCreated":true
"isCreated":true,
"isIgnored":false
},
"bookmark":{
"tag":"bookmark",
Expand Down Expand Up @@ -372,6 +374,14 @@ function __runMainSequence(_doScriptParameterArray) {
return false;
}

/* Show import dialog */
if(_global["isDialogShown"] || (ScriptUI && ScriptUI.environment && ScriptUI.environment.keyboardState && ScriptUI.environment.keyboardState.shiftKey)) {
_setupObj = __showImportDialog(_setupObj);
if(!_setupObj) {
return false;
}
}

/* Get package data */
var _unpackObj = __getPackageData(_docxFile);
if(!_unpackObj) {
Expand Down Expand Up @@ -1634,6 +1644,11 @@ function __handleHyperlinks(_doc, _wordXMLElement, _setupObj) {
const COLOR_ARRAY = _setupObj["hyperlink"]["color"];
const IS_HYPERLINK_MARKED = _setupObj["hyperlink"]["isMarked"];
const IS_HYPERLINK_CREATED = _setupObj["hyperlink"]["isCreated"];
const IS_HYPERLINK_IGNORED = _setupObj["hyperlink"]["isIgnored"];

if(IS_HYPERLINK_IGNORED) {
return true;
}

var _hyperlinkXMLElementArray = _wordXMLElement.evaluateXPathExpression("//" + HYPERLINK_TAG_NAME);
if(_hyperlinkXMLElementArray.length === 0) {
Expand Down Expand Up @@ -1816,6 +1831,11 @@ function __handleCrossReferences(_doc, _wordXMLElement, _setupObj) {
const COLOR_ARRAY = _setupObj["crossReference"]["color"];
const IS_CROSS_REFERENCE_MARKED = _setupObj["crossReference"]["isMarked"];
const IS_CROSS_REFERENCE_CREATED = _setupObj["crossReference"]["isCreated"];
const IS_CROSS_REFERENCE_IGNORED = _setupObj["crossReference"]["isIgnored"];

if(IS_CROSS_REFERENCE_IGNORED) {
return true;
}

var _crossRefXMLElementArray = _wordXMLElement.evaluateXPathExpression("//" + CROSS_REFERENCE_TAG_NAME);
if(_crossRefXMLElementArray.length === 0) {
Expand Down Expand Up @@ -3744,4 +3764,184 @@ function __defLocalizeStrings() {
en: "Bookmarks",
de: "Lesezeichen"
};

_global.importDialogTitle = {
en: "Microsoft Word Import Options",
de: "Microsoft Word Importoptionen"
};

_global.okButtonLabel = {
en: "OK",
de: "OK"
};

_global.cancelButtonLabel = {
en: "Cancel",
de: "Abbrechen"
};

_global.documentLabel = {
en: "Document",
de: "Dokument"
};

_global.defaultParagraphStyleLabel = {
en: "Default paragraph style",
de: "Standard-Absatzformat"
};

_global.isAutoflowingLabel = {
en: "Automatic flow",
de: "Automatischer Textfluss"
};

_global.isUntaggedLabel = {
en: "Remove Tags",
de: "Tags entfernen"
};

_global.stylePanelLabel = {
en: "Styles",
de: "Formate"
};

_global.styleModeGroupLabel = {
en: "Character Styles",
de: "Zeichenformate"
};

_global.extendedStyleModeRadiobutton = {
en: "Extended Mode",
de: "Erweiterter Modus"
};

_global.minimizedStyleModeRadiobutton = {
en: "Minimized Mode",
de: "Reduzierter Modus"
};

_global.breaksLabel = {
en: "Breaks",
de: "Umbrüche"
};

_global.pageBreakLabel = {
en: "Page break",
de: "Seitenumbruch"
};

_global.columnBreakLabel = {
en: "Column break",
de: "Spaltenumbruch"
};

_global.forcedLineLabel = {
en: "Forced line break",
de: "Erzwungener Zeilenumbruch"
};

_global.sectionLabel = {
en: "Section break",
de: "Abschnittsumbruch"
};

_global.commentsLabel = {
en: "Comments",
de: "Kommentare"
};

_global.removeLabel = {
en: "Remove",
de: "Entfernen"
};

_global.markLabel = {
en: "Mark",
de: "Markieren"
};

_global.ignoreLabel = {
en: "Ignore",
de: "Ignorieren"
};

_global.createLabel = {
en: "Create",
de: "Erstellen"
};

_global.placeLabel = {
en: "Place",
de: "Platzieren"
};

_global.indexmarksLabel = {
en: "Index marks",
de: "Indexmarken"
};

_global.hyperlinksLabel = {
en: "Hyperlinks",
de: "Hyperlinks"
};

_global.crossReferencesLabel = {
en: "Cross-references",
de: "Querverweise"
};

_global.bookmarksPanelLabel = {
en: "Bookmarks",
de: "Lesezeichen"
};

_global.bookmarkMarkerLabel = {
en: "Marker",
de: "Marker"
};

_global.trackChangesLabel = {
en: "Track changes",
de: "Änderungsverfolgung"
};

_global.footnotesLabel = {
en: "Footnotes",
de: "Fußnoten"
};

_global.endnotesLabel = {
en: "Endnotes",
de: "Endnoten"
};

_global.imagesPanelLabel = {
en: "Images",
de: "Bilder"
};

_global.imageWidthLabel = {
en: "Width (mm)",
de: "Breite (mm)"
};

_global.imageHeightLabel = {
en: "Height (mm)",
de: "Höhe (mm)"
};

_global.textboxesPanelLabel = {
en: "Textboxes",
de: "Textfelder"
};

_global.textboxWidthLabel = {
en: "Width (mm)",
de: "Breite (mm)"
};

_global.textboxHeightLabel = {
en: "Height (mm)",
de: "Höhe (mm)"
};
} /* END function __defLocalizeStrings */
Loading

0 comments on commit 7075d2b

Please sign in to comment.