This repository was archived by the owner on Jul 31, 2022. It is now read-only.
forked from uxal/officegen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgendocx.js
More file actions
845 lines (721 loc) · 52.7 KB
/
gendocx.js
File metadata and controls
845 lines (721 loc) · 52.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
//
// officegen: All the code to generate DOCX files.
//
// Please refer to README.md for this module's documentations.
//
// NOTE:
// - Before changing this code please refer to the hacking the code section on README.md.
//
// Copyright (c) 2013 Ziv Barber;
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// 'Software'), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
/**
* Basicgen plugin to create docx files (Microsoft World).
*/
var baseobj = require("./basicgen.js");
var msdoc = require("./msofficegen.js");
var docxP = require('./docx-p.js');
var docxTable = require('./docxtable.js');
var xmlBuilder = require('xmlbuilder');
var path = require('path');
var docplugman = require('./docplug');
// Officegen docx plugins:
var plugHeadfoot = require('./docxplg-headfoot');
// BMK_DOCX_PLUG:
if (!String.prototype.encodeHTML) {
String.prototype.encodeHTML = function () {
return this.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"');
};
}
/**
* Extend officegen object with DOCX support.
* <br /><br />
*
* This method extending the given officegen object to create DOCX document.
*
* @param[in] genobj The object to extend.
* @param[in] new_type The type of object to create.
* @param[in] options The object's options.
* @param[in] gen_private Access to the internals of this object.
* @param[in] type_info Additional information about this type.
* @constructor
* @name makeDocx
*/
function makeDocx(genobj, new_type, options, gen_private, type_info) {
/**
* Prepare the default data.
* @param {object} docpluginman Access to the document plugins manager.
*/
function setDefaultDocValues(docpluginman) {
var pptxData = docpluginman.getDataStorage();
// Please put any setting that API can override here:
}
/**
* Prepare everything to generate a docx zip.
*/
function cbPrepareDocxToGenerate() {
// Tell all the features (plugins) that we are about to generate a new document zip:
gen_private.features.type.docx.emitEvent('beforeGen', genobj);
// Allow some plugins to do more stuff after all the plugins added their data:
gen_private.features.type.docx.emitEvent('beforeGenFinal', genobj);
}
/**
* ???.
*
* @param[in] data Ignored by this callback function.
* @return Text string.
*/
function cbMakeDocxFontsTable(data) {
return gen_private.plugs.type.msoffice.cbMakeMsOfficeBasicXml(data) + '<w:fonts xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:font w:name="Calibri"><w:panose1 w:val="020F0502020204030204"/><w:charset w:val="00"/><w:family w:val="swiss"/><w:pitch w:val="variable"/><w:sig w:usb0="A00002EF" w:usb1="4000207B" w:usb2="00000000" w:usb3="00000000" w:csb0="0000009F" w:csb1="00000000"/></w:font><w:font w:name="Arial"><w:panose1 w:val="020B0604020202020204"/><w:charset w:val="00"/><w:family w:val="swiss"/><w:pitch w:val="variable"/><w:sig w:usb0="20002A87" w:usb1="80000000" w:usb2="00000008" w:usb3="00000000" w:csb0="000001FF" w:csb1="00000000"/></w:font><w:font w:name="Times New Roman"><w:panose1 w:val="02020603050405020304"/><w:charset w:val="00"/><w:family w:val="roman"/><w:pitch w:val="variable"/><w:sig w:usb0="20002A87" w:usb1="80000000" w:usb2="00000008" w:usb3="00000000" w:csb0="000001FF" w:csb1="00000000"/></w:font><w:font w:name="Cambria"><w:panose1 w:val="02040503050406030204"/><w:charset w:val="00"/><w:family w:val="roman"/><w:pitch w:val="variable"/><w:sig w:usb0="A00002EF" w:usb1="4000004B" w:usb2="00000000" w:usb3="00000000" w:csb0="0000009F" w:csb1="00000000"/></w:font></w:fonts>';
}
/**
* ???.
*
* @param[in] data Ignored by this callback function.
* @return Text string.
*/
function cbMakeDocxSettings(data) {
return gen_private.plugs.type.msoffice.cbMakeMsOfficeBasicXml(data) + '<w:settings xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:sl="http://schemas.openxmlformats.org/schemaLibrary/2006/main"><w:zoom w:percent="120"/><w:defaultTabStop w:val="720"/><w:characterSpacingControl w:val="doNotCompress"/><w:compat/><w:rsids><w:rsidRoot w:val="00A94AF2"/><w:rsid w:val="00A02F19"/><w:rsid w:val="00A94AF2"/></w:rsids><m:mathPr><m:mathFont m:val="Cambria Math"/><m:brkBin m:val="before"/><m:brkBinSub m:val="--"/><m:smallFrac m:val="off"/><m:dispDef/><m:lMargin m:val="0"/><m:rMargin m:val="0"/><m:defJc m:val="centerGroup"/><m:wrapIndent m:val="1440"/><m:intLim m:val="subSup"/><m:naryLim m:val="undOvr"/></m:mathPr><w:themeFontLang w:val="en-US" w:bidi="en-US"/><w:clrSchemeMapping w:bg1="light1" w:t1="dark1" w:bg2="light2" w:t2="dark2" w:accent1="accent1" w:accent2="accent2" w:accent3="accent3" w:accent4="accent4" w:accent5="accent5" w:accent6="accent6" w:hyperlink="hyperlink" w:followedHyperlink="followedHyperlink"/><w:shapeDefaults><o:shapedefaults v:ext="edit" spidmax="2050"/><o:shapelayout v:ext="edit"><o:idmap v:ext="edit" data="1"/></o:shapelayout></w:shapeDefaults><w:decimalSymbol w:val="."/><w:listSeparator w:val=","/></w:settings>';
}
// NJC - added to support bullets
function cbMakeDocxNumbers(data) {
return gen_private.plugs.type.msoffice.cbMakeMsOfficeBasicXml(data) + '<w:numbering xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mo="http://schemas.microsoft.com/office/mac/office/2008/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="urn:schemas-microsoft-com:mac:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 w15 wp14"><w:abstractNum w:abstractNumId="0"><w:nsid w:val="709F643A"/><w:multiLevelType w:val="hybridMultilevel"/><w:tmpl w:val="B8B464D0"/><w:lvl w:ilvl="0" w:tplc="04090001"><w:start w:val="1"/><w:numFmt w:val="bullet"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="720" w:hanging="360"/></w:pPr><w:rPr><w:rFonts w:ascii="Symbol" w:hAnsi="Symbol" w:hint="default"/></w:rPr></w:lvl><w:lvl w:ilvl="1" w:tplc="04090003" w:tentative="1"><w:start w:val="1"/><w:numFmt w:val="bullet"/><w:lvlText w:val="o"/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="1440" w:hanging="360"/></w:pPr><w:rPr><w:rFonts w:ascii="Courier New" w:hAnsi="Courier New" w:cs="Courier New" w:hint="default"/></w:rPr></w:lvl><w:lvl w:ilvl="2" w:tplc="04090005" w:tentative="1"><w:start w:val="1"/><w:numFmt w:val="bullet"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="2160" w:hanging="360"/></w:pPr><w:rPr><w:rFonts w:ascii="Wingdings" w:hAnsi="Wingdings" w:hint="default"/></w:rPr></w:lvl><w:lvl w:ilvl="3" w:tplc="04090001" w:tentative="1"><w:start w:val="1"/><w:numFmt w:val="bullet"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="2880" w:hanging="360"/></w:pPr><w:rPr><w:rFonts w:ascii="Symbol" w:hAnsi="Symbol" w:hint="default"/></w:rPr></w:lvl><w:lvl w:ilvl="4" w:tplc="04090003" w:tentative="1"><w:start w:val="1"/><w:numFmt w:val="bullet"/><w:lvlText w:val="o"/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="3600" w:hanging="360"/></w:pPr><w:rPr><w:rFonts w:ascii="Courier New" w:hAnsi="Courier New" w:cs="Courier New" w:hint="default"/></w:rPr></w:lvl><w:lvl w:ilvl="5" w:tplc="04090005" w:tentative="1"><w:start w:val="1"/><w:numFmt w:val="bullet"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="4320" w:hanging="360"/></w:pPr><w:rPr><w:rFonts w:ascii="Wingdings" w:hAnsi="Wingdings" w:hint="default"/></w:rPr></w:lvl><w:lvl w:ilvl="6" w:tplc="04090001" w:tentative="1"><w:start w:val="1"/><w:numFmt w:val="bullet"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="5040" w:hanging="360"/></w:pPr><w:rPr><w:rFonts w:ascii="Symbol" w:hAnsi="Symbol" w:hint="default"/></w:rPr></w:lvl><w:lvl w:ilvl="7" w:tplc="04090003" w:tentative="1"><w:start w:val="1"/><w:numFmt w:val="bullet"/><w:lvlText w:val="o"/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="5760" w:hanging="360"/></w:pPr><w:rPr><w:rFonts w:ascii="Courier New" w:hAnsi="Courier New" w:cs="Courier New" w:hint="default"/></w:rPr></w:lvl><w:lvl w:ilvl="8" w:tplc="04090005" w:tentative="1"><w:start w:val="1"/><w:numFmt w:val="bullet"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="6480" w:hanging="360"/></w:pPr><w:rPr><w:rFonts w:ascii="Wingdings" w:hAnsi="Wingdings" w:hint="default"/></w:rPr></w:lvl></w:abstractNum><w:num w:numId="1"><w:abstractNumId w:val="0"/></w:num></w:numbering>';
}
/**
* ???.
*
* @param[in] data Ignored by this callback function.
* @return Text string.
*/
function cbMakeDocxWeb(data) {
return gen_private.plugs.type.msoffice.cbMakeMsOfficeBasicXml(data) + '<w:webSettings xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:optimizeForBrowser/></w:webSettings>';
}
/**
* ???.
*
* @param[in] data Ignored by this callback function.
* @return Text string.
*/
function cbMakeDocxStyles(data) {
return gen_private.plugs.type.msoffice.cbMakeMsOfficeBasicXml(data) + '<w:styles xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:docDefaults><w:rPrDefault><w:rPr><w:rFonts w:asciiTheme="minorHAnsi" w:eastAsiaTheme="minorHAnsi" w:hAnsiTheme="minorHAnsi" w:cstheme="minorBidi"/><w:sz w:val="22"/><w:szCs w:val="22"/><w:lang w:val="en-US" w:eastAsia="en-US" w:bidi="en-US"/></w:rPr></w:rPrDefault><w:pPrDefault><w:pPr><w:spacing w:after="200" w:line="276" w:lineRule="auto"/></w:pPr></w:pPrDefault></w:docDefaults><w:latentStyles w:defLockedState="0" w:defUIPriority="99" w:defSemiHidden="1" w:defUnhideWhenUsed="1" w:defQFormat="0" w:count="267"><w:lsdException w:name="Normal" w:semiHidden="0" w:uiPriority="0" w:unhideWhenUsed="0" w:qFormat="1"/><w:lsdException w:name="heading 1" w:semiHidden="0" w:uiPriority="9" w:unhideWhenUsed="0" w:qFormat="1"/><w:lsdException w:name="heading 2" w:uiPriority="9" w:qFormat="1"/><w:lsdException w:name="heading 3" w:uiPriority="9" w:qFormat="1"/><w:lsdException w:name="heading 4" w:uiPriority="9" w:qFormat="1"/><w:lsdException w:name="heading 5" w:uiPriority="9" w:qFormat="1"/><w:lsdException w:name="heading 6" w:uiPriority="9" w:qFormat="1"/><w:lsdException w:name="heading 7" w:uiPriority="9" w:qFormat="1"/><w:lsdException w:name="heading 8" w:uiPriority="9" w:qFormat="1"/><w:lsdException w:name="heading 9" w:uiPriority="9" w:qFormat="1"/><w:lsdException w:name="toc 1" w:uiPriority="39"/><w:lsdException w:name="toc 2" w:uiPriority="39"/><w:lsdException w:name="toc 3" w:uiPriority="39"/><w:lsdException w:name="toc 4" w:uiPriority="39"/><w:lsdException w:name="toc 5" w:uiPriority="39"/><w:lsdException w:name="toc 6" w:uiPriority="39"/><w:lsdException w:name="toc 7" w:uiPriority="39"/><w:lsdException w:name="toc 8" w:uiPriority="39"/><w:lsdException w:name="toc 9" w:uiPriority="39"/><w:lsdException w:name="caption" w:uiPriority="35" w:qFormat="1"/><w:lsdException w:name="Title" w:semiHidden="0" w:uiPriority="10" w:unhideWhenUsed="0" w:qFormat="1"/><w:lsdException w:name="Default Paragraph Font" w:uiPriority="1"/><w:lsdException w:name="Subtitle" w:semiHidden="0" w:uiPriority="11" w:unhideWhenUsed="0" w:qFormat="1"/><w:lsdException w:name="Strong" w:semiHidden="0" w:uiPriority="22" w:unhideWhenUsed="0" w:qFormat="1"/><w:lsdException w:name="Emphasis" w:semiHidden="0" w:uiPriority="20" w:unhideWhenUsed="0" w:qFormat="1"/><w:lsdException w:name="Table Grid" w:semiHidden="0" w:uiPriority="59" w:unhideWhenUsed="0"/><w:lsdException w:name="Placeholder Text" w:unhideWhenUsed="0"/><w:lsdException w:name="No Spacing" w:semiHidden="0" w:uiPriority="1" w:unhideWhenUsed="0" w:qFormat="1"/><w:lsdException w:name="Light Shading" w:semiHidden="0" w:uiPriority="60" w:unhideWhenUsed="0"/><w:lsdException w:name="Light List" w:semiHidden="0" w:uiPriority="61" w:unhideWhenUsed="0"/><w:lsdException w:name="Light Grid" w:semiHidden="0" w:uiPriority="62" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Shading 1" w:semiHidden="0" w:uiPriority="63" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Shading 2" w:semiHidden="0" w:uiPriority="64" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium List 1" w:semiHidden="0" w:uiPriority="65" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium List 2" w:semiHidden="0" w:uiPriority="66" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Grid 1" w:semiHidden="0" w:uiPriority="67" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Grid 2" w:semiHidden="0" w:uiPriority="68" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Grid 3" w:semiHidden="0" w:uiPriority="69" w:unhideWhenUsed="0"/><w:lsdException w:name="Dark List" w:semiHidden="0" w:uiPriority="70" w:unhideWhenUsed="0"/><w:lsdException w:name="Colorful Shading" w:semiHidden="0" w:uiPriority="71" w:unhideWhenUsed="0"/><w:lsdException w:name="Colorful List" w:semiHidden="0" w:uiPriority="72" w:unhideWhenUsed="0"/><w:lsdException w:name="Colorful Grid" w:semiHidden="0" w:uiPriority="73" w:unhideWhenUsed="0"/><w:lsdException w:name="Light Shading Accent 1" w:semiHidden="0" w:uiPriority="60" w:unhideWhenUsed="0"/><w:lsdException w:name="Light List Accent 1" w:semiHidden="0" w:uiPriority="61" w:unhideWhenUsed="0"/><w:lsdException w:name="Light Grid Accent 1" w:semiHidden="0" w:uiPriority="62" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Shading 1 Accent 1" w:semiHidden="0" w:uiPriority="63" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Shading 2 Accent 1" w:semiHidden="0" w:uiPriority="64" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium List 1 Accent 1" w:semiHidden="0" w:uiPriority="65" w:unhideWhenUsed="0"/><w:lsdException w:name="Revision" w:unhideWhenUsed="0"/><w:lsdException w:name="List Paragraph" w:semiHidden="0" w:uiPriority="34" w:unhideWhenUsed="0" w:qFormat="1"/><w:lsdException w:name="Quote" w:semiHidden="0" w:uiPriority="29" w:unhideWhenUsed="0" w:qFormat="1"/><w:lsdException w:name="Intense Quote" w:semiHidden="0" w:uiPriority="30" w:unhideWhenUsed="0" w:qFormat="1"/><w:lsdException w:name="Medium List 2 Accent 1" w:semiHidden="0" w:uiPriority="66" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Grid 1 Accent 1" w:semiHidden="0" w:uiPriority="67" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Grid 2 Accent 1" w:semiHidden="0" w:uiPriority="68" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Grid 3 Accent 1" w:semiHidden="0" w:uiPriority="69" w:unhideWhenUsed="0"/><w:lsdException w:name="Dark List Accent 1" w:semiHidden="0" w:uiPriority="70" w:unhideWhenUsed="0"/><w:lsdException w:name="Colorful Shading Accent 1" w:semiHidden="0" w:uiPriority="71" w:unhideWhenUsed="0"/><w:lsdException w:name="Colorful List Accent 1" w:semiHidden="0" w:uiPriority="72" w:unhideWhenUsed="0"/><w:lsdException w:name="Colorful Grid Accent 1" w:semiHidden="0" w:uiPriority="73" w:unhideWhenUsed="0"/><w:lsdException w:name="Light Shading Accent 2" w:semiHidden="0" w:uiPriority="60" w:unhideWhenUsed="0"/><w:lsdException w:name="Light List Accent 2" w:semiHidden="0" w:uiPriority="61" w:unhideWhenUsed="0"/><w:lsdException w:name="Light Grid Accent 2" w:semiHidden="0" w:uiPriority="62" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Shading 1 Accent 2" w:semiHidden="0" w:uiPriority="63" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Shading 2 Accent 2" w:semiHidden="0" w:uiPriority="64" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium List 1 Accent 2" w:semiHidden="0" w:uiPriority="65" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium List 2 Accent 2" w:semiHidden="0" w:uiPriority="66" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Grid 1 Accent 2" w:semiHidden="0" w:uiPriority="67" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Grid 2 Accent 2" w:semiHidden="0" w:uiPriority="68" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Grid 3 Accent 2" w:semiHidden="0" w:uiPriority="69" w:unhideWhenUsed="0"/><w:lsdException w:name="Dark List Accent 2" w:semiHidden="0" w:uiPriority="70" w:unhideWhenUsed="0"/><w:lsdException w:name="Colorful Shading Accent 2" w:semiHidden="0" w:uiPriority="71" w:unhideWhenUsed="0"/><w:lsdException w:name="Colorful List Accent 2" w:semiHidden="0" w:uiPriority="72" w:unhideWhenUsed="0"/><w:lsdException w:name="Colorful Grid Accent 2" w:semiHidden="0" w:uiPriority="73" w:unhideWhenUsed="0"/><w:lsdException w:name="Light Shading Accent 3" w:semiHidden="0" w:uiPriority="60" w:unhideWhenUsed="0"/><w:lsdException w:name="Light List Accent 3" w:semiHidden="0" w:uiPriority="61" w:unhideWhenUsed="0"/><w:lsdException w:name="Light Grid Accent 3" w:semiHidden="0" w:uiPriority="62" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Shading 1 Accent 3" w:semiHidden="0" w:uiPriority="63" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Shading 2 Accent 3" w:semiHidden="0" w:uiPriority="64" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium List 1 Accent 3" w:semiHidden="0" w:uiPriority="65" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium List 2 Accent 3" w:semiHidden="0" w:uiPriority="66" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Grid 1 Accent 3" w:semiHidden="0" w:uiPriority="67" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Grid 2 Accent 3" w:semiHidden="0" w:uiPriority="68" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Grid 3 Accent 3" w:semiHidden="0" w:uiPriority="69" w:unhideWhenUsed="0"/><w:lsdException w:name="Dark List Accent 3" w:semiHidden="0" w:uiPriority="70" w:unhideWhenUsed="0"/><w:lsdException w:name="Colorful Shading Accent 3" w:semiHidden="0" w:uiPriority="71" w:unhideWhenUsed="0"/><w:lsdException w:name="Colorful List Accent 3" w:semiHidden="0" w:uiPriority="72" w:unhideWhenUsed="0"/><w:lsdException w:name="Colorful Grid Accent 3" w:semiHidden="0" w:uiPriority="73" w:unhideWhenUsed="0"/><w:lsdException w:name="Light Shading Accent 4" w:semiHidden="0" w:uiPriority="60" w:unhideWhenUsed="0"/><w:lsdException w:name="Light List Accent 4" w:semiHidden="0" w:uiPriority="61" w:unhideWhenUsed="0"/><w:lsdException w:name="Light Grid Accent 4" w:semiHidden="0" w:uiPriority="62" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Shading 1 Accent 4" w:semiHidden="0" w:uiPriority="63" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Shading 2 Accent 4" w:semiHidden="0" w:uiPriority="64" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium List 1 Accent 4" w:semiHidden="0" w:uiPriority="65" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium List 2 Accent 4" w:semiHidden="0" w:uiPriority="66" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Grid 1 Accent 4" w:semiHidden="0" w:uiPriority="67" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Grid 2 Accent 4" w:semiHidden="0" w:uiPriority="68" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Grid 3 Accent 4" w:semiHidden="0" w:uiPriority="69" w:unhideWhenUsed="0"/><w:lsdException w:name="Dark List Accent 4" w:semiHidden="0" w:uiPriority="70" w:unhideWhenUsed="0"/><w:lsdException w:name="Colorful Shading Accent 4" w:semiHidden="0" w:uiPriority="71" w:unhideWhenUsed="0"/><w:lsdException w:name="Colorful List Accent 4" w:semiHidden="0" w:uiPriority="72" w:unhideWhenUsed="0"/><w:lsdException w:name="Colorful Grid Accent 4" w:semiHidden="0" w:uiPriority="73" w:unhideWhenUsed="0"/><w:lsdException w:name="Light Shading Accent 5" w:semiHidden="0" w:uiPriority="60" w:unhideWhenUsed="0"/><w:lsdException w:name="Light List Accent 5" w:semiHidden="0" w:uiPriority="61" w:unhideWhenUsed="0"/><w:lsdException w:name="Light Grid Accent 5" w:semiHidden="0" w:uiPriority="62" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Shading 1 Accent 5" w:semiHidden="0" w:uiPriority="63" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Shading 2 Accent 5" w:semiHidden="0" w:uiPriority="64" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium List 1 Accent 5" w:semiHidden="0" w:uiPriority="65" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium List 2 Accent 5" w:semiHidden="0" w:uiPriority="66" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Grid 1 Accent 5" w:semiHidden="0" w:uiPriority="67" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Grid 2 Accent 5" w:semiHidden="0" w:uiPriority="68" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Grid 3 Accent 5" w:semiHidden="0" w:uiPriority="69" w:unhideWhenUsed="0"/><w:lsdException w:name="Dark List Accent 5" w:semiHidden="0" w:uiPriority="70" w:unhideWhenUsed="0"/><w:lsdException w:name="Colorful Shading Accent 5" w:semiHidden="0" w:uiPriority="71" w:unhideWhenUsed="0"/><w:lsdException w:name="Colorful List Accent 5" w:semiHidden="0" w:uiPriority="72" w:unhideWhenUsed="0"/><w:lsdException w:name="Colorful Grid Accent 5" w:semiHidden="0" w:uiPriority="73" w:unhideWhenUsed="0"/><w:lsdException w:name="Light Shading Accent 6" w:semiHidden="0" w:uiPriority="60" w:unhideWhenUsed="0"/><w:lsdException w:name="Light List Accent 6" w:semiHidden="0" w:uiPriority="61" w:unhideWhenUsed="0"/><w:lsdException w:name="Light Grid Accent 6" w:semiHidden="0" w:uiPriority="62" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Shading 1 Accent 6" w:semiHidden="0" w:uiPriority="63" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Shading 2 Accent 6" w:semiHidden="0" w:uiPriority="64" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium List 1 Accent 6" w:semiHidden="0" w:uiPriority="65" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium List 2 Accent 6" w:semiHidden="0" w:uiPriority="66" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Grid 1 Accent 6" w:semiHidden="0" w:uiPriority="67" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Grid 2 Accent 6" w:semiHidden="0" w:uiPriority="68" w:unhideWhenUsed="0"/><w:lsdException w:name="Medium Grid 3 Accent 6" w:semiHidden="0" w:uiPriority="69" w:unhideWhenUsed="0"/><w:lsdException w:name="Dark List Accent 6" w:semiHidden="0" w:uiPriority="70" w:unhideWhenUsed="0"/><w:lsdException w:name="Colorful Shading Accent 6" w:semiHidden="0" w:uiPriority="71" w:unhideWhenUsed="0"/><w:lsdException w:name="Colorful List Accent 6" w:semiHidden="0" w:uiPriority="72" w:unhideWhenUsed="0"/><w:lsdException w:name="Colorful Grid Accent 6" w:semiHidden="0" w:uiPriority="73" w:unhideWhenUsed="0"/><w:lsdException w:name="Subtle Emphasis" w:semiHidden="0" w:uiPriority="19" w:unhideWhenUsed="0" w:qFormat="1"/><w:lsdException w:name="Intense Emphasis" w:semiHidden="0" w:uiPriority="21" w:unhideWhenUsed="0" w:qFormat="1"/><w:lsdException w:name="Subtle Reference" w:semiHidden="0" w:uiPriority="31" w:unhideWhenUsed="0" w:qFormat="1"/><w:lsdException w:name="Intense Reference" w:semiHidden="0" w:uiPriority="32" w:unhideWhenUsed="0" w:qFormat="1"/><w:lsdException w:name="Book Title" w:semiHidden="0" w:uiPriority="33" w:unhideWhenUsed="0" w:qFormat="1"/><w:lsdException w:name="Bibliography" w:uiPriority="37"/><w:lsdException w:name="TOC Heading" w:uiPriority="39" w:qFormat="1"/></w:latentStyles><w:style w:type="paragraph" w:default="1" w:styleId="Normal"><w:name w:val="Normal"/><w:qFormat/><w:rsid w:val="00A02F19"/></w:style><w:style w:type="character" w:default="1" w:styleId="DefaultParagraphFont"><w:name w:val="Default Paragraph Font"/><w:uiPriority w:val="1"/><w:semiHidden/><w:unhideWhenUsed/></w:style><w:style w:type="table" w:default="1" w:styleId="TableNormal"><w:name w:val="Normal Table"/><w:uiPriority w:val="99"/><w:semiHidden/><w:unhideWhenUsed/><w:qFormat/><w:tblPr><w:tblInd w:w="0" w:type="dxa"/><w:tblCellMar><w:top w:w="0" w:type="dxa"/><w:left w:w="108" w:type="dxa"/><w:bottom w:w="0" w:type="dxa"/><w:right w:w="108" w:type="dxa"/></w:tblCellMar></w:tblPr></w:style><w:style w:type="numbering" w:default="1" w:styleId="NoList"><w:name w:val="No List"/><w:uiPriority w:val="99"/><w:semiHidden/><w:unhideWhenUsed/></w:style></w:styles>';
}
/**
* ???.
*
* @param[in] data Ignored by this callback function.
* @return Text string.
*/
function cbMakeDocxApp(data) {
var userName = genobj.options.author || genobj.options.creator || 'officegen';
var outString = gen_private.plugs.type.msoffice.cbMakeMsOfficeBasicXml(data) + '<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"><Template>Normal.dotm</Template><TotalTime>1</TotalTime><Pages>1</Pages><Words>0</Words><Characters>0</Characters><Application>Microsoft Office Word</Application><DocSecurity>0</DocSecurity><Lines>1</Lines><Paragraphs>1</Paragraphs><ScaleCrop>false</ScaleCrop><Company>' + userName + '</Company><LinksUpToDate>false</LinksUpToDate><CharactersWithSpaces>0</CharactersWithSpaces><SharedDoc>false</SharedDoc><HyperlinksChanged>false</HyperlinksChanged><AppVersion>12.0000</AppVersion></Properties>';
return outString;
}
/**
* Create the document's itself resource.
*
* @param[in] data Ignored by this callback function.
* @return Text string.
*/
function cbMakeDocxDocument(data) {
data.docStartExtra = data.docStartExtra || '';
data.docEndExtra = data.docEndExtra || '';
var outString = gen_private.plugs.type.msoffice.cbMakeMsOfficeBasicXml(data) + '<w:' + data.docType + ' xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml">' + data.docStartExtra;
var objs_list = data.data;
var bookmarkId = 0;
// In case of an empty document - just place an empty paragraph:
if (!objs_list.length) {
outString += '<w:p w:rsidR="009F2180" w:rsidRDefault="009F2180">';
if (data.pStyleDef) {
outString += '<w:pPr><w:pStyle w:val="' + data.pStyleDef + '"/></w:pPr>';
} // Endif.
outString += '</w:p>';
} // Endif.
// Work on all the stored paragraphs inside this document:
for (var i = 0, total_size = objs_list.length; i < total_size; i++) {
if (objs_list[i] && objs_list[i].type === 'table') {
var table_obj = docxTable.getTable(objs_list[i].data, objs_list[i].options, gen_private);
var table_xml = xmlBuilder.create(table_obj, { version: '1.0', encoding: 'UTF-8', standalone: true }).toString({ pretty: true, indent: ' ', newline: '\n' });
outString += table_xml;
continue;
}
outString += '<w:p w:rsidR="00A77427" w:rsidRDefault="007F1D13">';
var pPrData = '';
if (objs_list[i].options) {
if (objs_list[i].options.align) {
switch (objs_list[i].options.align) {
case 'center':
pPrData += '<w:jc w:val="center"/>';
break;
case 'right':
pPrData += '<w:jc w:val="right"/>';
break;
case 'justify':
pPrData += '<w:jc w:val="both"/>';
break;
} // End of switch.
} // Endif.
if (objs_list[i].options.list_type) {
pPrData += '<w:pStyle w:val="ListParagraph"/><w:numPr><w:ilvl w:val="0"/><w:numId w:val="' + objs_list[i].options.list_type + '"/></w:numPr>';
} // Endif.
if (objs_list[i].options.backline) {
pPrData += '<w:pPr><w:shd w:val="solid" w:color="' + objs_list[i].options.backline + '" w:fill="auto"/></w:pPr>';
} // Endif.
} // Endif.
// Some resource types have default style in case that there's no style settings:
if (!pPrData && data.pStyleDef) {
pPrData = '<w:pStyle w:val="' + data.pStyleDef + '"/>';
} // Endif.
if (pPrData) {
outString += '<w:pPr>' + pPrData + '</w:pPr>';
} // Endif.
// Work on all the objects in the document:
for (var j = 0, total_size_j = objs_list[i].data.length; j < total_size_j; j++) {
if (objs_list[i].data[j]) {
var rExtra = '';
var tExtra = '';
var rPrData = '';
var colorCode;
var valType;
var sizeVal;
var hyperlinkOn = false;
if (options.language) {
rPrData += '<w:lang w:val="' + options.language + '"/>';
}
if (objs_list[i].data[j].options) {
if (objs_list[i].data[j].options.color) {
rPrData += '<w:color w:val="' + objs_list[i].data[j].options.color + '"/>';
} // Endif.
if (objs_list[i].data[j].options.back) {
colorCode = objs_list[i].data[j].options.shdColor || 'auto';
valType = objs_list[i].data[j].options.shdType || 'clear';
rPrData += '<w:shd w:val="' + valType + '" w:color="' + colorCode + '" w:fill="' + objs_list[i].data[j].options.back + '"/>';
} // Endif.
if (objs_list[i].data[j].options.highlight) {
valType = 'yellow';
if (typeof objs_list[i].data[j].options.highlight === 'string') {
valType = objs_list[i].data[j].options.highlight;
} // Endif.
rPrData += '<w:highlight w:val="' + valType + '"/>';
} // Endif.
if (objs_list[i].data[j].options.bold) {
rPrData += '<w:b/><w:bCs/>';
} // Endif.
if (objs_list[i].data[j].options.italic) {
rPrData += '<w:i/><w:iCs/>';
} // Endif.
if (objs_list[i].data[j].options.underline) {
valType = 'single';
if (typeof objs_list[i].data[j].options.underline === 'string') {
valType = objs_list[i].data[j].options.underline;
} // Endif.
rPrData += '<w:u w:val="' + valType + '"/>';
} // Endif.
if (objs_list[i].data[j].options.font_face) {
rPrData += '<w:rFonts w:ascii="' + objs_list[i].data[j].options.font_face + '" w:eastAsia="' + objs_list[i].data[j].options.font_face + '" w:hAnsi="' + objs_list[i].data[j].options.font_face + '" w:cs="' + objs_list[i].data[j].options.font_face + '"/>';
} // Endif.
if (objs_list[i].data[j].options.font_size) {
var fontSizeInHalfPoints = 2 * objs_list[i].data[j].options.font_size;
rPrData += '<w:sz w:val="' + fontSizeInHalfPoints + '"/><w:szCs w:val="' + fontSizeInHalfPoints + '"/>';
} // Endif.
if (objs_list[i].data[j].options.border) {
colorCode = 'auto';
valType = 'single';
sizeVal = 4;
if (typeof objs_list[i].data[j].options.borderColor === 'string') {
colorCode = objs_list[i].data[j].options.borderColor;
} // Endif.
if (typeof objs_list[i].data[j].options.border === 'string') {
valType = objs_list[i].data[j].options.border;
} // Endif.
if (typeof objs_list[i].data[j].options.borderSize === 'number' && objs_list[i].data[j].options.borderSize && objs_list[i].data[j].options.borderSize === objs_list[i].data[j].options.borderSize) {
sizeVal = objs_list[i].data[j].options.borderSize;
} // Endif.
rPrData += '<w:bdr w:val="' + valType + '" w:sz="' + sizeVal + '" w:space="0" w:color="' + colorCode + '"/>';
} // Endif.
// Hyperlink support:
if (objs_list[i].data[j].options.hyperlink) {
outString += '<w:hyperlink w:anchor="' + objs_list[i].data[j].options.hyperlink + '">';
hyperlinkOn = true;
if (!rPrData) {
rPrData = '<w:rStyle w:val="Hyperlink"/>';
} // Endif.
} // Endif.
} // Endif.
// Field support:
if (objs_list[i].data[j].fieldObj) {
outString += '<w:fldSimple w:instr="' + objs_list[i].data[j].fieldObj + '">';
} // Endif.
if (objs_list[i].data[j].text) {
if ((objs_list[i].data[j].text[0] == ' ') || (objs_list[i].data[j].text[objs_list[i].data[j].text.length - 1] == ' ')) {
tExtra += ' xml:space="preserve"';
} // Endif.
if (objs_list[i].data[j].link_rel_id) {
outString += '<w:hyperlink r:id="rId' + objs_list[i].data[j].link_rel_id + '">';
}
outString += '<w:r' + rExtra + '>';
if (rPrData) {
outString += '<w:rPr>' + rPrData + '</w:rPr>';
} // Endif.
outString += '<w:t' + tExtra + '>' + objs_list[i].data[j].text.encodeHTML() + '</w:t></w:r>';
if (objs_list[i].data[j].link_rel_id) {
outString += '</w:hyperlink>';
}
} else if (objs_list[i].data[j].specialField) {
outString += '<w:r><w:fldChar w:fldCharType="begin"/></w:r>';
outString += '<w:r><w:instrText xml:space="preserve">' + objs_list[i].data[j].specialField + '</w:instrText></w:r>';
outString += '<w:r><w:fldChar w:fldCharType="separate"/></w:r>';
outString += '<w:r>';
if (rPrData) {
outString += '<w:rPr>' + rPrData + '</w:rPr>';
} // Endif.
outString += '<w:t>1</w:t>';
outString += '</w:r>';
outString += '<w:r><w:fldChar w:fldCharType="end"/></w:r>';
} else if (objs_list[i].data[j].page_break) {
outString += '<w:r><w:br w:type="page"/></w:r>';
} else if (objs_list[i].data[j].line_break) {
outString += '<w:r><w:br/></w:r>';
} else if (objs_list[i].data[j].horizontal_line) {
outString += '<w:r><w:pict><v:rect style="width:0;height:.75pt" o:hralign="center" o:hrstd="t" o:hr="t" fillcolor="#e0e0e0" stroked="f"/></w:pict></w:r>';
} else if (objs_list[i].data[j].line) {
outString += '<w:r>';
outString += '<w:rPr>' + rPrData + '</w:rPr>';
outString += '<w:pict>';
outString += '<v:shape id="_x0000_s1026" o:connectortype="straight" strokecolor="#' + objs_list[i].data[j].options.color + '" style="position:absolute;margin-left:' + objs_list[i].data[j].options.marginLeft + 'pt;margin-top:' + objs_list[i].data[j].options.marginTop + 'pt;width:' + objs_list[i].data[j].options.width + 'pt;height:0;z-index:251659263;mso-position-horizontal:absolute;mso-position-horizontal-relative:page;mso-position-vertical:absolute;mso-position-vertical-relative:page" type="#_x0000_t32">';
outString += '<w10:wrap anchorx="page" anchory="page"/>';
outString += '</v:shape>';
outString += '</w:pict>';
outString += '</w:r>';
// Bookmark start support:
} else if (objs_list[i].data[j].bookmark_start) {
outString += '<w:bookmarkStart w:id="' + bookmarkId + '" w:name="' + objs_list[i].data[j].bookmark_start + '"/>';
// Bookmark end support:
} else if (objs_list[i].data[j].bookmark_end) {
outString += '<w:bookmarkEnd w:id="' + bookmarkId + '"/>';
bookmarkId++;
} else if (objs_list[i].data[j].textbox_start) {
var filled = '';
if (objs_list[i].data[j].opts.transparent) {
filled = 'filled="f"';
}
var style = 'position:absolute;margin-left:' + objs_list[i].data[j].opts.marginLeft + 'pt;margin-top:' + objs_list[i].data[j].opts.marginTop + 'pt;width:' + objs_list[i].data[j].opts.width + 'pt;height:' + objs_list[i].data[j].opts.height + 'pt;z-index:251659263'
outString += '<w:pict>';
outString += '<v:shapetype coordsize="21600,21600" id="_x0000_t202" o:spt="202" path="m,l,21600r21600,l21600,xe">';
outString += '<v:stroke joinstyle="miter"/>';
outString += '<v:path gradientshapeok="t" o:connecttype="rect"/>';
outString += '</v:shapetype>';
outString += '<v:shape ' + filled + ' id="_x0000_s1026" stroked="f" style="' + style + '" type="#_x0000_t202">';
outString += '<v:textbox>';
outString += '<w:txbxContent>';
outString += '<w:p w:rsidR="0026655B" w:rsidRDefault="0026655B">';
if (objs_list[i].data[j].opts.lineHeight || objs_list[i].data[j].opts.lineRule) {
outString += '<w:pPr>';
outString += '<w:spacing w:line="' + objs_list[i].data[j].opts.lineHeight + '" w:lineRule="' + objs_list[i].data[j].opts.lineRule + '"/>';
outString += '</w:pPr>';
}
} else if (objs_list[i].data[j].textbox_end) {
outString += '</w:p>';
outString += '</w:txbxContent>';
outString += '</v:textbox>';
outString += '</v:shape>';
outString += '</w:pict>';
} else if (objs_list[i].data[j].image) {
outString += '<w:r' + rExtra + '>';
rPrData += '<w:noProof/>';
if (rPrData) {
outString += '<w:rPr>' + rPrData + '</w:rPr>';
} // Endif.
//914400L / 96DPI
var pixelToEmu = 9525;
var absolutePosition = objs_list[i].data[j].options.x >= 0 && objs_list[i].data[j].options.y >= 0;
outString += '<w:drawing>';
if (absolutePosition) {
outString += '<wp:anchor distT="10000" distB="0" distL="0" distR="0" simplePos="1" relativeHeight="251658239" behindDoc="0" locked="0" layoutInCell="1" allowOverlap="1">';
outString += '<wp:simplePos x="' + objs_list[i].data[j].options.x * pixelToEmu + '" y="' + objs_list[i].data[j].options.y * pixelToEmu + '" />';
outString += '<wp:positionH relativeFrom="page">';
outString += '<wp:posOffset>' + (objs_list[i].data[j].options.x * pixelToEmu) + '</wp:posOffset>';
outString += '</wp:positionH>';
outString += '<wp:positionV relativeFrom="page">';
outString += '<wp:posOffset>' + (objs_list[i].data[j].options.y * pixelToEmu) + '</wp:posOffset>';
outString += '</wp:positionV>';
} else {
outString += '<wp:inline distT="0" distB="0" distL="0" distR="0">';
}
outString += '<wp:extent cx="' + (objs_list[i].data[j].options.cx * pixelToEmu) + '" cy="' + (objs_list[i].data[j].options.cy * pixelToEmu) + '"/>';
outString += '<wp:effectExtent l="19050" t="0" r="9525" b="0"/>';
if (absolutePosition) {
outString += '<wp:wrapNone />';
}
outString += '<wp:docPr id="' + (objs_list[i].data[j].image_id + 1) + '" name="Picture ' + objs_list[i].data[j].image_id + '" descr="Picture ' + objs_list[i].data[j].image_id + '">';
if (objs_list[i].data[j].link_rel_id) {
outString += '<a:hlinkClick xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" r:id="rId' + objs_list[i].data[j].link_rel_id + '"/>';
}
outString += '</wp:docPr>';
outString += '<wp:cNvGraphicFramePr>';
outString += '<a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1"/>';
outString += '</wp:cNvGraphicFramePr>';
outString += '<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">';
outString += '<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">';
outString += '<pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">';
outString += '<pic:nvPicPr>';
outString += '<pic:cNvPr id="0" name="Picture ' + objs_list[i].data[j].image_id + '"/>';
outString += '<pic:cNvPicPr/>';
outString += '</pic:nvPicPr>';
outString += '<pic:blipFill>';
outString += '<a:blip r:embed="rId' + objs_list[i].data[j].rel_id + '" cstate="print"/>';
outString += '<a:stretch>';
outString += '<a:fillRect/>';
outString += '</a:stretch>';
outString += '</pic:blipFill>';
outString += '<pic:spPr>';
outString += '<a:xfrm>';
outString += '<a:off x="0" y="0"/>';
outString += '<a:ext cx="' + (objs_list[i].data[j].options.cx * pixelToEmu) + '" cy="' + (objs_list[i].data[j].options.cy * pixelToEmu) + '"/>';
outString += '</a:xfrm>';
outString += '<a:prstGeom prst="rect">';
outString += '<a:avLst/>';
outString += '</a:prstGeom>';
outString += '</pic:spPr>';
outString += '</pic:pic>';
outString += '</a:graphicData>';
outString += '</a:graphic>';
if (absolutePosition) {
outString += '</wp:anchor>';
} else {
outString += '</wp:inline>';
}
outString += '</w:drawing>';
outString += '</w:r>';
} // Endif.
// Field support:
if (objs_list[i].data[j].fieldObj) {
outString += '</w:fldSimple>';
} // Endif.
if (hyperlinkOn) {
outString += '</w:hyperlink>';
} // Endif.
} // Endif.
} // Endif.
outString += '</w:p>';
} // End of for loop.
if (data.docType === 'document') {
outString += '<w:p w:rsidR="00A02F19" w:rsidRDefault="00A02F19"/>';
var defaultOptions = {
pageSize: {
width: 12240, //8.5 inch
height: 15840 //11 inch
},
pageMargins: {
top: 1440,
right: 1800,
bottom: 1440,
left: 1800,
}
}
if (options.pageMargins) {
defaultOptions.pageMargins.top = options.pageMargins.top || defaultOptions.pageMargins.top;
defaultOptions.pageMargins.right = options.pageMargins.right || defaultOptions.pageMargins.right;
defaultOptions.pageMargins.bottom = options.pageMargins.bottom || defaultOptions.pageMargins.bottom;
defaultOptions.pageMargins.left = options.pageMargins.left || defaultOptions.pageMargins.left;
}
if (options.pageSize !== undefined) {
var pageSizeFactor = 566.93;
if (options.pageSize.toLowerCase() === "a4") {
defaultOptions.pageSize.width = Math.floor(pageSizeFactor * 21);
defaultOptions.pageSize.height = Math.floor(pageSizeFactor * 29.7);
}
//TODO: add other page sizes
}
// Landscape orientation support:
if (options.orientation && options.orientation === 'landscape') {
outString +=
'<w:sectPr w:rsidR="00A02F19" w:rsidSect="00897086">' +
(docxData.secPrExtra ? docxData.secPrExtra : '') +
'<w:pgSz w:w="' + defaultOptions.pageSize.height + '" w:h="' + defaultOptions.pageSize.width + '" w:orient="landscape"/>' +
'<w:pgMar w:top="' + defaultOptions.pageMargins.top + '" w:right="' + defaultOptions.pageMargins.right + '" ' +
'w:bottom="' + defaultOptions.pageMargins.bottom + '" w:left="' + defaultOptions.pageMargins.left + '" w:header="720" w:footer="720" w:gutter="0"/>' +
'<w:cols w:space="720"/>' +
'<w:docGrid w:linePitch="360"/>' +
'</w:sectPr>';
} else {
outString +=
'<w:sectPr w:rsidR="00A02F19" w:rsidSect="00A02F19">' +
(docxData.secPrExtra ? docxData.secPrExtra : '') +
'<w:pgSz w:w="' + defaultOptions.pageSize.width + '" w:h="' + defaultOptions.pageSize.height + '"/>' +
'<w:pgMar w:top="' + defaultOptions.pageMargins.top + '" w:right="' + defaultOptions.pageMargins.right + '" ' +
'w:bottom="' + defaultOptions.pageMargins.bottom + '" w:left="' + defaultOptions.pageMargins.left + '" w:header="720" w:footer="720" w:gutter="0"/>' +
'<w:cols w:space="720"/>' +
'<w:docGrid w:linePitch="360"/>' +
'</w:sectPr>';
} // Endif.
} // Endif.
outString += data.docEndExtra + '</w:' + data.docType + '>';
return outString;
}
// Save it so if some plugin need to generate document style resource then it can use it:
genobj.cbMakeDocxDocument = cbMakeDocxDocument;
// Prepare genobj for MS-Office:
msdoc.makemsdoc(genobj, new_type, options, gen_private, type_info);
gen_private.plugs.type.msoffice.makeOfficeGenerator('word', 'document', {});
genobj.on('clearData', function () {
genobj.data.length = 0;
});
genobj.on('beforeGen', cbPrepareDocxToGenerate);
// Add the document's properties:
gen_private.plugs.type.msoffice.addInfoType('dc:title', '', 'title', 'setDocTitle');
gen_private.plugs.type.msoffice.addInfoType('dc:subject', '', 'subject', 'setDocSubject');
gen_private.plugs.type.msoffice.addInfoType('cp:keywords', '', 'keywords', 'setDocKeywords');
gen_private.plugs.type.msoffice.addInfoType('dc:description', '', 'description', 'setDescription');
gen_private.plugs.type.msoffice.addInfoType('cp:category', '', 'category', 'setDocCategory');
gen_private.plugs.type.msoffice.addInfoType('cp:contentStatus', '', 'status', 'setDocStatus');
// Create the plugins manager:
var plugsmanObj = new docplugman(genobj, gen_private, 'docx', setDefaultDocValues);
// We'll register now any officegen internal plugin that we want to always use for Word based documents:
plugsmanObj.plugsList.push(new plugHeadfoot(plugsmanObj));
// BMK_DOCX_PLUG:
// Dynamic loading of additional plugins requested by the user:
if (options.extraPlugs && typeof options.extraPlugs === 'object' && options.extraPlugs.forEach) {
options.extraPlugs.forEach(function (value) {
var newPlug;
if (value) {
if (typeof value === 'function') {
// You already loaded the plugin:
newPlug = value;
} else if (typeof value === 'string') {
// We need to load the plugin:
newPlug = require('./' + value);
} // Endif.
} // Endif.
plugsmanObj.plugsList.push(new newPlug(plugsmanObj));
});
} // Endif.
// Access to our data:
var docxData = plugsmanObj.getDataStorage();
gen_private.type.msoffice.files_list.push(
{
name: '/word/settings.xml',
type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml',
clear: 'type'
},
{
name: '/word/fontTable.xml',
type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml',
clear: 'type'
},
{
name: '/word/webSettings.xml',
type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml',
clear: 'type'
},
{
name: '/word/styles.xml',
type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml',
clear: 'type'
},
{
name: '/word/document.xml',
type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml',
clear: 'type'
},
{ // NJC - 20161231 - added to support bullets
name: '/word/numbering.xml',
type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml',
clear: 'type'
}
);
gen_private.type.msoffice.rels_app.push(
{
type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles',
target: 'styles.xml',
clear: 'type'
},
{
type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings',
target: 'settings.xml',
clear: 'type'
},
{
type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings',
target: 'webSettings.xml',
clear: 'type'
},
{
type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable',
target: 'fontTable.xml',
clear: 'type'
},
{
type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
target: 'theme/theme1.xml',
clear: 'type'
},
{ // NJC - 20161231 - added to support bullets
type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering',
target: 'numbering.xml',
clear: 'type'
}
);
genobj.data = []; // All the data will be placed here.
gen_private.plugs.intAddAnyResourceToParse('docProps\\app.xml', 'buffer', null, cbMakeDocxApp, true);
gen_private.plugs.intAddAnyResourceToParse('word\\fontTable.xml', 'buffer', null, cbMakeDocxFontsTable, true);
gen_private.plugs.intAddAnyResourceToParse('word\\settings.xml', 'buffer', null, cbMakeDocxSettings, true);
gen_private.plugs.intAddAnyResourceToParse('word\\webSettings.xml', 'buffer', null, cbMakeDocxWeb, true);
gen_private.plugs.intAddAnyResourceToParse('word\\styles.xml', 'buffer', null, cbMakeDocxStyles, true);
gen_private.plugs.intAddAnyResourceToParse('word\\document.xml', 'buffer', { docType: 'document', docStartExtra: '<w:body>', docEndExtra: '</w:body>', data: genobj.data }, cbMakeDocxDocument, true);
gen_private.plugs.intAddAnyResourceToParse('word\\numbering.xml', 'buffer', null, cbMakeDocxNumbers, true); // added to support bullets
gen_private.plugs.intAddAnyResourceToParse('word\\_rels\\document.xml.rels', 'buffer', gen_private.type.msoffice.rels_app, gen_private.plugs.type.msoffice.cbMakeRels, true);
// ----- API for Word documents: -----
/**
* Create a new paragraph.
*
* @param {string} options Default options for all the objects inside this paragraph.
*/
genobj.createP = function (options) {
// Create a new instance of the paragraph object:
return new docxP(genobj, gen_private, 'docx', genobj.data, {}, options);
};
/**
* ???.
*
* @param {object} options ???.
*/
genobj.createListOfDots = function (options) {
var newP = genobj.createP(options);
newP.options.list_type = '1';
return newP;
};
/**
* Create a list of numbers based paragraph.
*
* @param {object} options ???.
*/
genobj.createListOfNumbers = function (options) {
var newP = genobj.createP(options);
newP.options.list_type = '2';
return newP;
};
/**
* Add a page break.
* <br /><br />
*
* This method add a page break to the current Word document.
*/
genobj.putPageBreak = function () {
var newP = {};
newP.data = [{ 'page_break': true }];
genobj.data[genobj.data.length] = newP;
return newP;
};
/**
* Add a page break.
* <br /><br />
*
* This method add a page break to the current Word document.
*/
genobj.addPageBreak = function () {
var newP = {};
newP.data = [{ 'page_break': true }];
genobj.data[genobj.data.length] = newP;
return newP;
};
/**
* Create a table.
* <br /><br />
*
* This method add a table to the current word document.
*
* @param {object} data ???.
* @param {object} options ???.
*/
genobj.createTable = function (data, options) {
var newP = genobj.createP(options);
newP.data = data;
newP.type = 'table';
return newP;
};
/**
* Create Json.
* <br /><br />
*
* @param {object} data ???.
* @param {object} newP ???.
*/
genobj.createJson = function (data, newP) {
newP = newP || genobj.createP(data.lopt || {});
switch (data.type) {
case "text":
newP.addText(data.val, data.opt);
break;
case "linebreak":
newP.addLineBreak();
break;
case "horizontalline":
newP.addHorizontalLine();
break;
case "image":
// Improved by peizhuang in Aug 2016 (added data.opt):
// data.imagetype been added by Ziv Barber in Aug 2016.
newP.addImage(data.path, data.opt || {}, data.imagetype);
break;
case "pagebreak":
newP = genobj.putPageBreak();
break;
case "table":
newP = genobj.createTable(data.val, data.opt);
break;
case "numlist":
newP = genobj.createListOfDots();
break;
case "dotlist":
newP = genobj.createListOfDots();
break;
}
return newP;
};
/**
* Create a document by json data.
* <br /><br />
*
* @param {array} dataArray ???.
*/
genobj.createByJson = function (dataArray) {
var newP = {};
dataArray = [].concat(dataArray || []);
dataArray.forEach(function (data) {
if (Array.isArray(data)) {
newP = genobj.createP(data.shift() || {});
data.forEach(function (d) {
newP = genobj.createJson(d, newP);
});
} else {
newP = genobj.createJson(data);
}
});
return newP;
};
// Tell all the features (plugins) to add extra API:
gen_private.features.type.docx.emitEvent('makeDocApi', genobj);
return this;
}
baseobj.plugins.registerDocType('docx', makeDocx, {}, baseobj.docType.TEXT, "Microsoft Word Document");