-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
builder.CreateFile("docx"); | ||
var odoc = Api.GetDocument(); | ||
let arr_def_styles = ["Normal", | ||
"No Spacing", | ||
"Heading 1", | ||
"Heading 2", | ||
"Heading 3", | ||
"Heading 4", | ||
"Heading 5", | ||
"Heading 6", | ||
"Heading 7", | ||
"Heading 8", | ||
"Heading 9", | ||
"Title", | ||
"Subtitle", | ||
"Quote", | ||
"Intense Quote", | ||
"List Paragraph", | ||
"Caption", | ||
"Header", | ||
"Footer", | ||
"Footnote text", | ||
"Endnote text"] | ||
var result_json = {} | ||
arr_def_styles.forEach(el => { | ||
let st = odoc.GetStyle(el); | ||
let json = st.ToJSON() | ||
result_json[el] = json; | ||
}); | ||
GlobalVariable["JSON"] = JSON.stringify(result_json); | ||
builder.CloseFile(); | ||
|
||
//////////////////////// | ||
|
||
builder.CreateFile("docx"); | ||
var json = GlobalVariable["JSON"] | ||
var obj_json = JSON.parse(json) | ||
var odoc = Api.GetDocument(); | ||
for(let k in obj_json){ | ||
let st = Api.FromJSON(obj_json[k]); | ||
let opar = Api.CreateParagraph(); | ||
opar.AddText(st.GetName()) | ||
opar.SetStyle(st); | ||
odoc.Push(opar) | ||
} | ||
let opar = Api.CreateParagraph(); | ||
opar.AddText(json); | ||
odoc.Push(opar) | ||
builder.SaveFile("docx", "StyleToJSON.docx"); | ||
builder.CloseFile(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
# module for doc builder static data | ||
module DocBuilderStaticData | ||
# Default style list in the CDE | ||
DEFAULT_STYLES = [ | ||
'Normal', | ||
'No Spacing', | ||
'Heading 1', | ||
'Heading 2', | ||
'Heading 3', | ||
'Heading 4', | ||
'Heading 5', | ||
'Heading 6', | ||
'Heading 7', | ||
'Heading 8', | ||
'Heading 9', | ||
'Title', | ||
'Subtitle', | ||
'Quote', | ||
'Intense Quote', | ||
'List Paragraph', | ||
'Caption', | ||
'Header', | ||
'Footer', | ||
'Footnote text', | ||
'Endnote text' | ||
].freeze | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters