office-viewer 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/esm/OpenXML.d.ts +21 -0
- package/esm/OpenXML.js +60 -0
- package/esm/Word.d.ts +208 -0
- package/esm/Word.js +370 -0
- package/esm/index.d.ts +6 -0
- package/esm/index.js +6 -0
- package/esm/node_modules/tslib/tslib.es6.js +120 -0
- package/esm/openxml/ContentType.d.ts +12 -0
- package/esm/openxml/ContentType.js +15 -0
- package/esm/openxml/Style.d.ts +41 -0
- package/esm/openxml/Style.js +156 -0
- package/esm/openxml/Theme.d.ts +26 -0
- package/esm/openxml/Theme.js +69 -0
- package/esm/openxml/Types.d.ts +2512 -0
- package/esm/openxml/Types.js +1003 -0
- package/esm/openxml/word/Background.d.ts +11 -0
- package/esm/openxml/word/Body.d.ts +18 -0
- package/esm/openxml/word/Body.js +67 -0
- package/esm/openxml/word/Bookmark.d.ts +6 -0
- package/esm/openxml/word/Bookmark.js +18 -0
- package/esm/openxml/word/Border.d.ts +10 -0
- package/esm/openxml/word/Break.d.ts +13 -0
- package/esm/openxml/word/Break.js +19 -0
- package/esm/openxml/word/CustomXml.d.ts +8 -0
- package/esm/openxml/word/FldSimple.d.ts +7 -0
- package/esm/openxml/word/FldSimple.js +15 -0
- package/esm/openxml/word/FrameProperties.d.ts +18 -0
- package/esm/openxml/word/Hyperlink.d.ts +13 -0
- package/esm/openxml/word/Hyperlink.js +53 -0
- package/esm/openxml/word/Indent.d.ts +8 -0
- package/esm/openxml/word/InlineText.d.ts +14 -0
- package/esm/openxml/word/InlineText.js +62 -0
- package/esm/openxml/word/InstrText.d.ts +4 -0
- package/esm/openxml/word/InstrText.js +8 -0
- package/esm/openxml/word/Paragraph.d.ts +34 -0
- package/esm/openxml/word/Paragraph.js +133 -0
- package/esm/openxml/word/Pict.d.ts +6 -0
- package/esm/openxml/word/Pict.js +19 -0
- package/esm/openxml/word/Ruby.d.ts +20 -0
- package/esm/openxml/word/Ruby.js +87 -0
- package/esm/openxml/word/Run.d.ts +31 -0
- package/esm/openxml/word/Run.js +98 -0
- package/esm/openxml/word/Section.d.ts +38 -0
- package/esm/openxml/word/Section.js +59 -0
- package/esm/openxml/word/Shading.d.ts +9 -0
- package/esm/openxml/word/SmartTag.d.ts +8 -0
- package/esm/openxml/word/SmartTag.js +18 -0
- package/esm/openxml/word/Spacing.d.ts +9 -0
- package/esm/openxml/word/Sym.d.ts +8 -0
- package/esm/openxml/word/Sym.js +16 -0
- package/esm/openxml/word/Tab.d.ts +8 -0
- package/esm/openxml/word/Tab.js +17 -0
- package/esm/openxml/word/Table.d.ts +49 -0
- package/esm/openxml/word/Table.js +248 -0
- package/esm/openxml/word/VerticalAlign.d.ts +6 -0
- package/esm/openxml/word/WDocument.d.ts +13 -0
- package/esm/openxml/word/WDocument.js +58 -0
- package/esm/openxml/word/drawing/Blip.d.ts +6 -0
- package/esm/openxml/word/drawing/Blip.js +17 -0
- package/esm/openxml/word/drawing/BlipFill.d.ts +9 -0
- package/esm/openxml/word/drawing/BlipFill.js +20 -0
- package/esm/openxml/word/drawing/Drawing.d.ts +6 -0
- package/esm/openxml/word/drawing/Drawing.js +15 -0
- package/esm/openxml/word/drawing/Pic.d.ts +8 -0
- package/esm/openxml/word/drawing/Pic.js +16 -0
- package/esm/openxml/word/drawing/ShapeProperties.d.ts +9 -0
- package/esm/openxml/word/drawing/ShapeProperties.js +20 -0
- package/esm/openxml/word/drawing/Transform.d.ts +17 -0
- package/esm/openxml/word/drawing/Transform.js +30 -0
- package/esm/openxml/word/numbering/AbstractNum.d.ts +13 -0
- package/esm/openxml/word/numbering/AbstractNum.js +42 -0
- package/esm/openxml/word/numbering/Lvl.d.ts +16 -0
- package/esm/openxml/word/numbering/Lvl.js +62 -0
- package/esm/openxml/word/numbering/Num.d.ts +10 -0
- package/esm/openxml/word/numbering/Num.js +46 -0
- package/esm/openxml/word/numbering/NumberProperties.d.ts +6 -0
- package/esm/openxml/word/numbering/NumberProperties.js +21 -0
- package/esm/openxml/word/numbering/Numbering.d.ts +9 -0
- package/esm/openxml/word/numbering/Numbering.js +50 -0
- package/esm/openxml/word/properties/Properties.d.ts +12 -0
- package/esm/openxml/word/table/Tc.d.ts +46 -0
- package/esm/openxml/word/table/Tc.js +234 -0
- package/esm/openxml/word/table/Tr.d.ts +18 -0
- package/esm/openxml/word/table/Tr.js +106 -0
- package/esm/package/PackageParser.d.ts +26 -0
- package/esm/package/XMLPackageParser.d.ts +31 -0
- package/esm/package/ZipPackageParser.d.ts +29 -0
- package/esm/package/ZipPackageParser.js +70 -0
- package/esm/parse/jcToTextAlign.d.ts +5 -0
- package/esm/parse/jcToTextAlign.js +21 -0
- package/esm/parse/parseBorder.d.ts +13 -0
- package/esm/parse/parseBorder.js +78 -0
- package/esm/parse/parseColor.d.ts +22 -0
- package/esm/parse/parseColor.js +131 -0
- package/esm/parse/parseFont.d.ts +7 -0
- package/esm/parse/parseFont.js +54 -0
- package/esm/parse/parseInd.d.ts +5 -0
- package/esm/parse/parseInd.js +27 -0
- package/esm/parse/parsePr.d.ts +8 -0
- package/esm/parse/parsePr.js +325 -0
- package/esm/parse/parseRelationship.d.ts +12 -0
- package/esm/parse/parseRelationship.js +40 -0
- package/esm/parse/parseSize.d.ts +27 -0
- package/esm/parse/parseSize.js +38 -0
- package/esm/parse/parseSpacing.d.ts +7 -0
- package/esm/parse/parseSpacing.js +43 -0
- package/esm/parse/parseTextDirection.d.ts +2 -0
- package/esm/parse/parseTextDirection.js +25 -0
- package/esm/parse/parseTrHeight.d.ts +2 -0
- package/esm/parse/parseTrHeight.js +17 -0
- package/esm/render/renderBody.d.ts +6 -0
- package/esm/render/renderBody.js +53 -0
- package/esm/render/renderBookmark.d.ts +6 -0
- package/esm/render/renderBookmark.js +17 -0
- package/esm/render/renderBr.d.ts +7 -0
- package/esm/render/renderBr.js +13 -0
- package/esm/render/renderDocument.d.ts +7 -0
- package/esm/render/renderDocument.js +14 -0
- package/esm/render/renderDrawing.d.ts +8 -0
- package/esm/render/renderDrawing.js +38 -0
- package/esm/render/renderHyperLink.d.ts +7 -0
- package/esm/render/renderHyperLink.js +41 -0
- package/esm/render/renderInlineText.d.ts +6 -0
- package/esm/render/renderInlineText.js +39 -0
- package/esm/render/renderInstrText.d.ts +8 -0
- package/esm/render/renderInstrText.js +40 -0
- package/esm/render/renderNumbering.d.ts +7 -0
- package/esm/render/renderNumbering.js +161 -0
- package/esm/render/renderParagraph.d.ts +7 -0
- package/esm/render/renderParagraph.js +78 -0
- package/esm/render/renderPict.d.ts +6 -0
- package/esm/render/renderPict.js +19 -0
- package/esm/render/renderRuby.d.ts +6 -0
- package/esm/render/renderRuby.js +53 -0
- package/esm/render/renderRun.d.ts +14 -0
- package/esm/render/renderRun.js +116 -0
- package/esm/render/renderSection.d.ts +6 -0
- package/esm/render/renderSection.js +36 -0
- package/esm/render/renderStyle.d.ts +13 -0
- package/esm/render/renderStyle.js +194 -0
- package/esm/render/renderSym.d.ts +3 -0
- package/esm/render/renderSym.js +10 -0
- package/esm/render/renderTab.d.ts +7 -0
- package/esm/render/renderTab.js +19 -0
- package/esm/render/renderTable.d.ts +6 -0
- package/esm/render/renderTable.js +186 -0
- package/esm/render/setElementStyle.d.ts +6 -0
- package/esm/render/setElementStyle.js +21 -0
- package/esm/util/autoSpace.d.ts +5 -0
- package/esm/util/autoSpace.js +33 -0
- package/esm/util/blob.d.ts +9 -0
- package/esm/util/blob.js +39 -0
- package/esm/util/dom.d.ts +36 -0
- package/esm/util/dom.js +63 -0
- package/esm/util/mergeRun.d.ts +17 -0
- package/esm/util/mergeRun.js +134 -0
- package/esm/util/xml.d.ts +8 -0
- package/esm/util/xml.js +12 -0
- package/lib/OpenXML.d.ts +21 -0
- package/lib/OpenXML.js +69 -0
- package/lib/Word.d.ts +208 -0
- package/lib/Word.js +374 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +10 -0
- package/lib/node_modules/tslib/tslib.es6.js +129 -0
- package/lib/openxml/ContentType.d.ts +12 -0
- package/lib/openxml/ContentType.js +19 -0
- package/lib/openxml/Style.d.ts +41 -0
- package/lib/openxml/Style.js +160 -0
- package/lib/openxml/Theme.d.ts +26 -0
- package/lib/openxml/Theme.js +73 -0
- package/lib/openxml/Types.d.ts +2512 -0
- package/lib/openxml/Types.js +1005 -0
- package/lib/openxml/word/Background.d.ts +11 -0
- package/lib/openxml/word/Body.d.ts +18 -0
- package/lib/openxml/word/Body.js +71 -0
- package/lib/openxml/word/Bookmark.d.ts +6 -0
- package/lib/openxml/word/Bookmark.js +22 -0
- package/lib/openxml/word/Border.d.ts +10 -0
- package/lib/openxml/word/Break.d.ts +13 -0
- package/lib/openxml/word/Break.js +23 -0
- package/lib/openxml/word/CustomXml.d.ts +8 -0
- package/lib/openxml/word/FldSimple.d.ts +7 -0
- package/lib/openxml/word/FldSimple.js +19 -0
- package/lib/openxml/word/FrameProperties.d.ts +18 -0
- package/lib/openxml/word/Hyperlink.d.ts +13 -0
- package/lib/openxml/word/Hyperlink.js +57 -0
- package/lib/openxml/word/Indent.d.ts +8 -0
- package/lib/openxml/word/InlineText.d.ts +14 -0
- package/lib/openxml/word/InlineText.js +66 -0
- package/lib/openxml/word/InstrText.d.ts +4 -0
- package/lib/openxml/word/InstrText.js +12 -0
- package/lib/openxml/word/Paragraph.d.ts +34 -0
- package/lib/openxml/word/Paragraph.js +137 -0
- package/lib/openxml/word/Pict.d.ts +6 -0
- package/lib/openxml/word/Pict.js +23 -0
- package/lib/openxml/word/Ruby.d.ts +20 -0
- package/lib/openxml/word/Ruby.js +91 -0
- package/lib/openxml/word/Run.d.ts +31 -0
- package/lib/openxml/word/Run.js +103 -0
- package/lib/openxml/word/Section.d.ts +38 -0
- package/lib/openxml/word/Section.js +63 -0
- package/lib/openxml/word/Shading.d.ts +9 -0
- package/lib/openxml/word/SmartTag.d.ts +8 -0
- package/lib/openxml/word/SmartTag.js +22 -0
- package/lib/openxml/word/Spacing.d.ts +9 -0
- package/lib/openxml/word/Sym.d.ts +8 -0
- package/lib/openxml/word/Sym.js +20 -0
- package/lib/openxml/word/Tab.d.ts +8 -0
- package/lib/openxml/word/Tab.js +21 -0
- package/lib/openxml/word/Table.d.ts +49 -0
- package/lib/openxml/word/Table.js +252 -0
- package/lib/openxml/word/VerticalAlign.d.ts +6 -0
- package/lib/openxml/word/WDocument.d.ts +13 -0
- package/lib/openxml/word/WDocument.js +62 -0
- package/lib/openxml/word/drawing/Blip.d.ts +6 -0
- package/lib/openxml/word/drawing/Blip.js +21 -0
- package/lib/openxml/word/drawing/BlipFill.d.ts +9 -0
- package/lib/openxml/word/drawing/BlipFill.js +24 -0
- package/lib/openxml/word/drawing/Drawing.d.ts +6 -0
- package/lib/openxml/word/drawing/Drawing.js +19 -0
- package/lib/openxml/word/drawing/Pic.d.ts +8 -0
- package/lib/openxml/word/drawing/Pic.js +20 -0
- package/lib/openxml/word/drawing/ShapeProperties.d.ts +9 -0
- package/lib/openxml/word/drawing/ShapeProperties.js +24 -0
- package/lib/openxml/word/drawing/Transform.d.ts +17 -0
- package/lib/openxml/word/drawing/Transform.js +34 -0
- package/lib/openxml/word/numbering/AbstractNum.d.ts +13 -0
- package/lib/openxml/word/numbering/AbstractNum.js +46 -0
- package/lib/openxml/word/numbering/Lvl.d.ts +16 -0
- package/lib/openxml/word/numbering/Lvl.js +66 -0
- package/lib/openxml/word/numbering/Num.d.ts +10 -0
- package/lib/openxml/word/numbering/Num.js +50 -0
- package/lib/openxml/word/numbering/NumberProperties.d.ts +6 -0
- package/lib/openxml/word/numbering/NumberProperties.js +25 -0
- package/lib/openxml/word/numbering/Numbering.d.ts +9 -0
- package/lib/openxml/word/numbering/Numbering.js +54 -0
- package/lib/openxml/word/properties/Properties.d.ts +12 -0
- package/lib/openxml/word/table/Tc.d.ts +46 -0
- package/lib/openxml/word/table/Tc.js +242 -0
- package/lib/openxml/word/table/Tr.d.ts +18 -0
- package/lib/openxml/word/table/Tr.js +110 -0
- package/lib/package/PackageParser.d.ts +26 -0
- package/lib/package/XMLPackageParser.d.ts +31 -0
- package/lib/package/ZipPackageParser.d.ts +29 -0
- package/lib/package/ZipPackageParser.js +74 -0
- package/lib/parse/jcToTextAlign.d.ts +5 -0
- package/lib/parse/jcToTextAlign.js +25 -0
- package/lib/parse/parseBorder.d.ts +13 -0
- package/lib/parse/parseBorder.js +83 -0
- package/lib/parse/parseColor.d.ts +22 -0
- package/lib/parse/parseColor.js +137 -0
- package/lib/parse/parseFont.d.ts +7 -0
- package/lib/parse/parseFont.js +58 -0
- package/lib/parse/parseInd.d.ts +5 -0
- package/lib/parse/parseInd.js +31 -0
- package/lib/parse/parsePr.d.ts +8 -0
- package/lib/parse/parsePr.js +329 -0
- package/lib/parse/parseRelationship.d.ts +12 -0
- package/lib/parse/parseRelationship.js +45 -0
- package/lib/parse/parseSize.d.ts +27 -0
- package/lib/parse/parseSize.js +44 -0
- package/lib/parse/parseSpacing.d.ts +7 -0
- package/lib/parse/parseSpacing.js +47 -0
- package/lib/parse/parseTextDirection.d.ts +2 -0
- package/lib/parse/parseTextDirection.js +29 -0
- package/lib/parse/parseTrHeight.d.ts +2 -0
- package/lib/parse/parseTrHeight.js +21 -0
- package/lib/render/renderBody.d.ts +6 -0
- package/lib/render/renderBody.js +57 -0
- package/lib/render/renderBookmark.d.ts +6 -0
- package/lib/render/renderBookmark.js +21 -0
- package/lib/render/renderBr.d.ts +7 -0
- package/lib/render/renderBr.js +17 -0
- package/lib/render/renderDocument.d.ts +7 -0
- package/lib/render/renderDocument.js +18 -0
- package/lib/render/renderDrawing.d.ts +8 -0
- package/lib/render/renderDrawing.js +42 -0
- package/lib/render/renderHyperLink.d.ts +7 -0
- package/lib/render/renderHyperLink.js +45 -0
- package/lib/render/renderInlineText.d.ts +6 -0
- package/lib/render/renderInlineText.js +43 -0
- package/lib/render/renderInstrText.d.ts +8 -0
- package/lib/render/renderInstrText.js +44 -0
- package/lib/render/renderNumbering.d.ts +7 -0
- package/lib/render/renderNumbering.js +165 -0
- package/lib/render/renderParagraph.d.ts +7 -0
- package/lib/render/renderParagraph.js +82 -0
- package/lib/render/renderPict.d.ts +6 -0
- package/lib/render/renderPict.js +23 -0
- package/lib/render/renderRuby.d.ts +6 -0
- package/lib/render/renderRuby.js +57 -0
- package/lib/render/renderRun.d.ts +14 -0
- package/lib/render/renderRun.js +121 -0
- package/lib/render/renderSection.d.ts +6 -0
- package/lib/render/renderSection.js +40 -0
- package/lib/render/renderStyle.d.ts +13 -0
- package/lib/render/renderStyle.js +199 -0
- package/lib/render/renderSym.d.ts +3 -0
- package/lib/render/renderSym.js +14 -0
- package/lib/render/renderTab.d.ts +7 -0
- package/lib/render/renderTab.js +23 -0
- package/lib/render/renderTable.d.ts +6 -0
- package/lib/render/renderTable.js +190 -0
- package/lib/render/setElementStyle.d.ts +6 -0
- package/lib/render/setElementStyle.js +25 -0
- package/lib/util/autoSpace.d.ts +5 -0
- package/lib/util/autoSpace.js +37 -0
- package/lib/util/blob.d.ts +9 -0
- package/lib/util/blob.js +44 -0
- package/lib/util/dom.d.ts +36 -0
- package/lib/util/dom.js +72 -0
- package/lib/util/mergeRun.d.ts +17 -0
- package/lib/util/mergeRun.js +140 -0
- package/lib/util/xml.d.ts +8 -0
- package/lib/util/xml.js +16 -0
- package/package.json +91 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { __values } from '../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { getValNumber, getVal, getValHex, getAttrBoolean } from '../../OpenXML.js';
|
|
3
|
+
import { parseBorders } from '../../parse/parseBorder.js';
|
|
4
|
+
import { parseShdColor } from '../../parse/parseColor.js';
|
|
5
|
+
import { parseSize } from '../../parse/parseSize.js';
|
|
6
|
+
import { ST_TblLayoutType } from '../Types.js';
|
|
7
|
+
import { parseTblCellSpacing, parseCellMargin, parseInsideBorders, parseTblWidth } from './table/Tc.js';
|
|
8
|
+
import { Tr } from './table/Tr.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* http://officeopenxml.com/WPtable.php
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* 表格的 jc 需要使用 float 来实现
|
|
15
|
+
* http://officeopenxml.com/WPtableAlignment.php
|
|
16
|
+
*/
|
|
17
|
+
function parseTblJc(element, cssStyle) {
|
|
18
|
+
var val = getVal(element);
|
|
19
|
+
switch (val) {
|
|
20
|
+
case 'left':
|
|
21
|
+
case 'start':
|
|
22
|
+
// TODO: 会导致前面的文字掉下去,感觉还是不能支持这个功能
|
|
23
|
+
// cssStyle['float'] = 'left';
|
|
24
|
+
break;
|
|
25
|
+
case 'right':
|
|
26
|
+
case 'end':
|
|
27
|
+
cssStyle['float'] = 'right';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 这个其实分左右,但目前只支持左,右可能是阿拉伯语?
|
|
32
|
+
* http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/tblInd_2.html
|
|
33
|
+
*/
|
|
34
|
+
function parseTblInd(element, style) {
|
|
35
|
+
var width = parseTblWidth(element);
|
|
36
|
+
if (width) {
|
|
37
|
+
style['margin-left'] = width;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function parseTblW(element, style) {
|
|
41
|
+
var width = parseTblWidth(element);
|
|
42
|
+
if (width) {
|
|
43
|
+
style['width'] = width;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* http://officeopenxml.com/WPtableLayout.php
|
|
48
|
+
*/
|
|
49
|
+
function parseTblLayout(element, style) {
|
|
50
|
+
var type = element.getAttribute('w:type');
|
|
51
|
+
if (type === ST_TblLayoutType.fixed) {
|
|
52
|
+
style['table-layout'] = 'fixed';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function parseTblGrid(element) {
|
|
56
|
+
var e_1, _a;
|
|
57
|
+
var gridCol = [];
|
|
58
|
+
var gridColElements = element.getElementsByTagName('w:gridCol');
|
|
59
|
+
try {
|
|
60
|
+
for (var gridColElements_1 = __values(gridColElements), gridColElements_1_1 = gridColElements_1.next(); !gridColElements_1_1.done; gridColElements_1_1 = gridColElements_1.next()) {
|
|
61
|
+
var gridColElement = gridColElements_1_1.value;
|
|
62
|
+
var w = parseSize(gridColElement, 'w:w');
|
|
63
|
+
gridCol.push({ w: w });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
67
|
+
finally {
|
|
68
|
+
try {
|
|
69
|
+
if (gridColElements_1_1 && !gridColElements_1_1.done && (_a = gridColElements_1.return)) _a.call(gridColElements_1);
|
|
70
|
+
}
|
|
71
|
+
finally { if (e_1) throw e_1.error; }
|
|
72
|
+
}
|
|
73
|
+
return gridCol;
|
|
74
|
+
}
|
|
75
|
+
// http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/ST_TblStyleOverrideType.html
|
|
76
|
+
// val 是旧的格式
|
|
77
|
+
function parseTblLook(child) {
|
|
78
|
+
var tblLook = {};
|
|
79
|
+
var tblLookVal = getValHex(child);
|
|
80
|
+
if (getAttrBoolean(child, 'firstRow', false) || tblLookVal & 0x0020) {
|
|
81
|
+
tblLook['firstRow'] = true;
|
|
82
|
+
}
|
|
83
|
+
if (getAttrBoolean(child, 'lastRow', false) || tblLookVal & 0x0040) {
|
|
84
|
+
tblLook['lastRow'] = true;
|
|
85
|
+
}
|
|
86
|
+
if (getAttrBoolean(child, 'firstColumn', false) || tblLookVal & 0x0080) {
|
|
87
|
+
tblLook['firstColumn'] = true;
|
|
88
|
+
}
|
|
89
|
+
if (getAttrBoolean(child, 'lastColumn', false) || tblLookVal & 0x0100) {
|
|
90
|
+
tblLook['lastColumn'] = true;
|
|
91
|
+
}
|
|
92
|
+
if (getAttrBoolean(child, 'noHBand', false) || tblLookVal & 0x0200) {
|
|
93
|
+
tblLook['noHBand'] = true;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
tblLook['noHBand'] = false;
|
|
97
|
+
}
|
|
98
|
+
if (getAttrBoolean(child, 'noVBand', false) || tblLookVal & 0x0400) {
|
|
99
|
+
tblLook['noVBand'] = true;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
tblLook['noVBand'] = false;
|
|
103
|
+
}
|
|
104
|
+
return tblLook;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/tblpPr.html
|
|
108
|
+
* 只支持部分
|
|
109
|
+
*/
|
|
110
|
+
function parsetTlpPr(word, child, style) {
|
|
111
|
+
// 如果设置 padding 会导致绝对定位不准确,所以一旦设置就不支持
|
|
112
|
+
if (typeof word.renderOptions.padding === 'undefined') {
|
|
113
|
+
var tplpX = parseSize(child, 'w:tblpX');
|
|
114
|
+
var tplpY = parseSize(child, 'w:tblpY');
|
|
115
|
+
style.position = 'absolute';
|
|
116
|
+
style.top = tplpY;
|
|
117
|
+
style.left = tplpX;
|
|
118
|
+
}
|
|
119
|
+
// 之前想用 float 来实现,但是会导致文字掉下去
|
|
120
|
+
// const topFromText = parseSize(child, 'w:topFromText');
|
|
121
|
+
// const bottomFromText = parseSize(child, 'w:bottomFromText');
|
|
122
|
+
// const rightFromText = parseSize(child, 'w:rightFromText');
|
|
123
|
+
// const leftFromText = parseSize(child, 'w:leftFromText');
|
|
124
|
+
// style['float'] = 'left';
|
|
125
|
+
// style['margin-bottom'] = addSize(style['margin-bottom'], bottomFromText);
|
|
126
|
+
// style['margin-left'] = addSize(style['margin-left'], leftFromText);
|
|
127
|
+
// style['margin-right'] = addSize(style['margin-right'], rightFromText);
|
|
128
|
+
// style['margin-top'] = addSize(style['margin-top'], topFromText);
|
|
129
|
+
}
|
|
130
|
+
var Table = /** @class */ (function () {
|
|
131
|
+
function Table() {
|
|
132
|
+
this.properties = {};
|
|
133
|
+
this.tblGrid = [];
|
|
134
|
+
this.trs = [];
|
|
135
|
+
}
|
|
136
|
+
Table.parseTablePr = function (word, element) {
|
|
137
|
+
var e_2, _a;
|
|
138
|
+
var properties = {};
|
|
139
|
+
var tableStyle = {};
|
|
140
|
+
var tcStyle = {};
|
|
141
|
+
properties.tblLook = {};
|
|
142
|
+
properties.cssStyle = tableStyle;
|
|
143
|
+
properties.tcCSSStyle = tcStyle;
|
|
144
|
+
try {
|
|
145
|
+
for (var _b = __values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
146
|
+
var child = _c.value;
|
|
147
|
+
var tagName = child.tagName;
|
|
148
|
+
switch (tagName) {
|
|
149
|
+
case 'w:tblBorders':
|
|
150
|
+
parseBorders(word, child, tableStyle);
|
|
151
|
+
properties.insideBorder = parseInsideBorders(word, child);
|
|
152
|
+
break;
|
|
153
|
+
case 'w:tcBorders':
|
|
154
|
+
parseBorders(word, child, tableStyle);
|
|
155
|
+
break;
|
|
156
|
+
case 'w:tblInd':
|
|
157
|
+
parseTblInd(child, tableStyle);
|
|
158
|
+
break;
|
|
159
|
+
case 'w:jc':
|
|
160
|
+
parseTblJc(child, tableStyle);
|
|
161
|
+
break;
|
|
162
|
+
case 'w:tblCellMar':
|
|
163
|
+
case 'w:tcMar':
|
|
164
|
+
// http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/tblCellMar_1.html
|
|
165
|
+
parseCellMargin(child, tcStyle);
|
|
166
|
+
break;
|
|
167
|
+
case 'w:tblStyle':
|
|
168
|
+
properties.pStyle = getVal(child);
|
|
169
|
+
break;
|
|
170
|
+
case 'w:tblW':
|
|
171
|
+
parseTblW(child, tableStyle);
|
|
172
|
+
break;
|
|
173
|
+
case 'w:shd':
|
|
174
|
+
// http://officeopenxml.com/WPtableShading.php
|
|
175
|
+
tableStyle['background-color'] = parseShdColor(word, child);
|
|
176
|
+
break;
|
|
177
|
+
case 'w:tblCaption':
|
|
178
|
+
properties.tblCaption = getVal(child);
|
|
179
|
+
break;
|
|
180
|
+
case 'w:tblCellSpacing':
|
|
181
|
+
parseTblCellSpacing(child, tableStyle);
|
|
182
|
+
break;
|
|
183
|
+
case 'w:tblLayout':
|
|
184
|
+
parseTblLayout(child, tableStyle);
|
|
185
|
+
break;
|
|
186
|
+
case 'w:tblLook':
|
|
187
|
+
properties.tblLook = parseTblLook(child);
|
|
188
|
+
break;
|
|
189
|
+
case 'w:tblStyleRowBandSize':
|
|
190
|
+
properties.rowBandSize = getValNumber(child);
|
|
191
|
+
break;
|
|
192
|
+
case 'w:tblStyleColBandSize':
|
|
193
|
+
properties.colBandSize = getValNumber(child);
|
|
194
|
+
break;
|
|
195
|
+
case 'w:tblpPr':
|
|
196
|
+
parsetTlpPr(word, child, tableStyle);
|
|
197
|
+
break;
|
|
198
|
+
default:
|
|
199
|
+
console.warn('parseTableProperties unknown tag', tagName, child);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
204
|
+
finally {
|
|
205
|
+
try {
|
|
206
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
207
|
+
}
|
|
208
|
+
finally { if (e_2) throw e_2.error; }
|
|
209
|
+
}
|
|
210
|
+
return properties;
|
|
211
|
+
};
|
|
212
|
+
Table.fromXML = function (word, element) {
|
|
213
|
+
var e_3, _a;
|
|
214
|
+
var table = new Table();
|
|
215
|
+
// 用于计算列的跨行,这里记下前面的跨行情况
|
|
216
|
+
var rowSpanMap = {};
|
|
217
|
+
try {
|
|
218
|
+
for (var _b = __values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
219
|
+
var child = _c.value;
|
|
220
|
+
var tagName = child.tagName;
|
|
221
|
+
switch (tagName) {
|
|
222
|
+
case 'w:tblPr':
|
|
223
|
+
table.properties = Table.parseTablePr(word, child);
|
|
224
|
+
break;
|
|
225
|
+
case 'w:tr':
|
|
226
|
+
table.trs.push(Tr.fromXML(word, child, rowSpanMap));
|
|
227
|
+
break;
|
|
228
|
+
case 'w:tblGrid':
|
|
229
|
+
table.tblGrid = parseTblGrid(child);
|
|
230
|
+
break;
|
|
231
|
+
default:
|
|
232
|
+
console.warn('Table.fromXML unknown tag', tagName, child);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
237
|
+
finally {
|
|
238
|
+
try {
|
|
239
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
240
|
+
}
|
|
241
|
+
finally { if (e_3) throw e_3.error; }
|
|
242
|
+
}
|
|
243
|
+
return table;
|
|
244
|
+
};
|
|
245
|
+
return Table;
|
|
246
|
+
}());
|
|
247
|
+
|
|
248
|
+
export { Table };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Document 解析及类型定义
|
|
3
|
+
* http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/document.html
|
|
4
|
+
* http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/Main%20Document%20Story.html
|
|
5
|
+
*/
|
|
6
|
+
import Word from '../../Word';
|
|
7
|
+
import { DocumentBackground } from './Background';
|
|
8
|
+
import { Body } from './Body';
|
|
9
|
+
export declare class WDocument {
|
|
10
|
+
body: Body;
|
|
11
|
+
documentBackground?: DocumentBackground;
|
|
12
|
+
static fromXML(word: Word, element: Document): WDocument;
|
|
13
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { __values } from '../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { parseColorAttr } from '../../parse/parseColor.js';
|
|
3
|
+
import { Body } from './Body.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Document 解析及类型定义
|
|
7
|
+
* http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/document.html
|
|
8
|
+
* http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/Main%20Document%20Story.html
|
|
9
|
+
*/
|
|
10
|
+
var WDocument = /** @class */ (function () {
|
|
11
|
+
function WDocument() {
|
|
12
|
+
}
|
|
13
|
+
WDocument.fromXML = function (word, element) {
|
|
14
|
+
var e_1, _a;
|
|
15
|
+
var doc = new WDocument();
|
|
16
|
+
var body = element.querySelector('body');
|
|
17
|
+
if (body) {
|
|
18
|
+
doc.body = Body.fromXML(word, body);
|
|
19
|
+
}
|
|
20
|
+
var background = element.querySelector('background');
|
|
21
|
+
if (background) {
|
|
22
|
+
var documentBackground = {};
|
|
23
|
+
try {
|
|
24
|
+
for (var _b = __values(background.attributes), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
25
|
+
var attr = _c.value;
|
|
26
|
+
var name_1 = attr.name;
|
|
27
|
+
switch (name_1) {
|
|
28
|
+
case 'w:color':
|
|
29
|
+
documentBackground.color = parseColorAttr(word, background, 'w:color');
|
|
30
|
+
break;
|
|
31
|
+
case 'w:themeColor':
|
|
32
|
+
documentBackground.themeColor = parseColorAttr(word, background, 'w:themeColor');
|
|
33
|
+
break;
|
|
34
|
+
case 'w:themeShade':
|
|
35
|
+
documentBackground.themeShade = parseColorAttr(word, background, 'w:themeShade');
|
|
36
|
+
break;
|
|
37
|
+
case 'w:themeTint':
|
|
38
|
+
documentBackground.themeTint = parseColorAttr(word, background, 'w:themeTint');
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
46
|
+
finally {
|
|
47
|
+
try {
|
|
48
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
49
|
+
}
|
|
50
|
+
finally { if (e_1) throw e_1.error; }
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return doc;
|
|
54
|
+
};
|
|
55
|
+
return WDocument;
|
|
56
|
+
}());
|
|
57
|
+
|
|
58
|
+
export { WDocument };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var Blip = /** @class */ (function () {
|
|
2
|
+
function Blip() {
|
|
3
|
+
}
|
|
4
|
+
Blip.fromXML = function (word, element) {
|
|
5
|
+
var blip = new Blip();
|
|
6
|
+
// 目前值支持 embed 这一种
|
|
7
|
+
var embedId = element.getAttribute('r:embed') || '';
|
|
8
|
+
var rel = word.getRelationship(embedId);
|
|
9
|
+
if (rel) {
|
|
10
|
+
blip.embled = rel;
|
|
11
|
+
}
|
|
12
|
+
return blip;
|
|
13
|
+
};
|
|
14
|
+
return Blip;
|
|
15
|
+
}());
|
|
16
|
+
|
|
17
|
+
export { Blip };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* http://webapp.docx4java.org/OnlineDemo/ecma376/DrawingML/blipFill_2.html
|
|
3
|
+
*/
|
|
4
|
+
import Word from '../../../Word';
|
|
5
|
+
import { Blip } from './Blip';
|
|
6
|
+
export declare class BlipFill {
|
|
7
|
+
blip?: Blip;
|
|
8
|
+
static fromXML(word: Word, element?: Element | null): BlipFill;
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Blip } from './Blip.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* http://webapp.docx4java.org/OnlineDemo/ecma376/DrawingML/blipFill_2.html
|
|
5
|
+
*/
|
|
6
|
+
var BlipFill = /** @class */ (function () {
|
|
7
|
+
function BlipFill() {
|
|
8
|
+
}
|
|
9
|
+
BlipFill.fromXML = function (word, element) {
|
|
10
|
+
var blipFill = new BlipFill();
|
|
11
|
+
var blip = element === null || element === void 0 ? void 0 : element.querySelector('blip');
|
|
12
|
+
if (blip) {
|
|
13
|
+
blipFill.blip = Blip.fromXML(word, blip);
|
|
14
|
+
}
|
|
15
|
+
return blipFill;
|
|
16
|
+
};
|
|
17
|
+
return BlipFill;
|
|
18
|
+
}());
|
|
19
|
+
|
|
20
|
+
export { BlipFill };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Pic } from './Pic.js';
|
|
2
|
+
|
|
3
|
+
var Drawing = /** @class */ (function () {
|
|
4
|
+
function Drawing() {
|
|
5
|
+
}
|
|
6
|
+
Drawing.fromXML = function (word, element) {
|
|
7
|
+
var drawing = new Drawing();
|
|
8
|
+
var pic = element.querySelector('pic');
|
|
9
|
+
drawing.pic = Pic.fromXML(word, pic);
|
|
10
|
+
return drawing;
|
|
11
|
+
};
|
|
12
|
+
return Drawing;
|
|
13
|
+
}());
|
|
14
|
+
|
|
15
|
+
export { Drawing };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BlipFill } from './BlipFill.js';
|
|
2
|
+
import { ShapePr } from './ShapeProperties.js';
|
|
3
|
+
|
|
4
|
+
var Pic = /** @class */ (function () {
|
|
5
|
+
function Pic() {
|
|
6
|
+
}
|
|
7
|
+
Pic.fromXML = function (word, element) {
|
|
8
|
+
var pic = new Pic();
|
|
9
|
+
pic.blipFill = BlipFill.fromXML(word, element === null || element === void 0 ? void 0 : element.querySelector('blipFill'));
|
|
10
|
+
pic.spPr = ShapePr.fromXML(word, element === null || element === void 0 ? void 0 : element.querySelector('spPr'));
|
|
11
|
+
return pic;
|
|
12
|
+
};
|
|
13
|
+
return Pic;
|
|
14
|
+
}());
|
|
15
|
+
|
|
16
|
+
export { Pic };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* http://webapp.docx4java.org/OnlineDemo/ecma376/DrawingML/spPr_2.html
|
|
3
|
+
*/
|
|
4
|
+
import Word from '../../../Word';
|
|
5
|
+
import { Transform } from './Transform';
|
|
6
|
+
export declare class ShapePr {
|
|
7
|
+
xfrm?: Transform;
|
|
8
|
+
static fromXML(word: Word, element?: Element | null): ShapePr;
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Transform } from './Transform.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* http://webapp.docx4java.org/OnlineDemo/ecma376/DrawingML/spPr_2.html
|
|
5
|
+
*/
|
|
6
|
+
var ShapePr = /** @class */ (function () {
|
|
7
|
+
function ShapePr() {
|
|
8
|
+
}
|
|
9
|
+
ShapePr.fromXML = function (word, element) {
|
|
10
|
+
var shapePr = new ShapePr();
|
|
11
|
+
var xfrm = element === null || element === void 0 ? void 0 : element.querySelector('xfrm');
|
|
12
|
+
if (xfrm) {
|
|
13
|
+
shapePr.xfrm = Transform.fromXML(word, xfrm);
|
|
14
|
+
}
|
|
15
|
+
return shapePr;
|
|
16
|
+
};
|
|
17
|
+
return ShapePr;
|
|
18
|
+
}());
|
|
19
|
+
|
|
20
|
+
export { ShapePr };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* http://webapp.docx4java.org/OnlineDemo/ecma376/DrawingML/xfrm_2.html
|
|
3
|
+
*/
|
|
4
|
+
import Word from '../../../Word';
|
|
5
|
+
export interface Off {
|
|
6
|
+
x: string;
|
|
7
|
+
y: string;
|
|
8
|
+
}
|
|
9
|
+
export interface Ext {
|
|
10
|
+
cx: string;
|
|
11
|
+
cy: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class Transform {
|
|
14
|
+
off?: Off;
|
|
15
|
+
ext?: Ext;
|
|
16
|
+
static fromXML(word: Word, element: Element): Transform;
|
|
17
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { parseSize, LengthUsage } from '../../../parse/parseSize.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* http://webapp.docx4java.org/OnlineDemo/ecma376/DrawingML/xfrm_2.html
|
|
5
|
+
*/
|
|
6
|
+
var Transform = /** @class */ (function () {
|
|
7
|
+
function Transform() {
|
|
8
|
+
}
|
|
9
|
+
Transform.fromXML = function (word, element) {
|
|
10
|
+
var transform = new Transform();
|
|
11
|
+
var off = element.querySelector('off');
|
|
12
|
+
if (off) {
|
|
13
|
+
transform.off = {
|
|
14
|
+
x: parseSize(off, 'x', LengthUsage.Emu),
|
|
15
|
+
y: parseSize(off, 'y', LengthUsage.Emu)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
var ext = element.querySelector('ext');
|
|
19
|
+
if (ext) {
|
|
20
|
+
transform.ext = {
|
|
21
|
+
cx: parseSize(ext, 'cx', LengthUsage.Emu),
|
|
22
|
+
cy: parseSize(ext, 'cy', LengthUsage.Emu)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return transform;
|
|
26
|
+
};
|
|
27
|
+
return Transform;
|
|
28
|
+
}());
|
|
29
|
+
|
|
30
|
+
export { Transform };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* lvl 的解析,只支持部分
|
|
3
|
+
* http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/abstractNum.html
|
|
4
|
+
*/
|
|
5
|
+
import { ST_MultiLevelType } from '../../Types';
|
|
6
|
+
import { Lvl } from './Lvl';
|
|
7
|
+
import Word from '../../../Word';
|
|
8
|
+
export declare class AbstractNum {
|
|
9
|
+
abstractNumId: string;
|
|
10
|
+
multiLevelType?: ST_MultiLevelType;
|
|
11
|
+
lvls: Record<string, Lvl>;
|
|
12
|
+
static fromXML(word: Word, element: Element): AbstractNum;
|
|
13
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { __values } from '../../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { Lvl } from './Lvl.js';
|
|
3
|
+
import { getVal } from '../../../OpenXML.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* lvl 的解析,只支持部分
|
|
7
|
+
* http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/abstractNum.html
|
|
8
|
+
*/
|
|
9
|
+
var AbstractNum = /** @class */ (function () {
|
|
10
|
+
function AbstractNum() {
|
|
11
|
+
this.lvls = {};
|
|
12
|
+
}
|
|
13
|
+
AbstractNum.fromXML = function (word, element) {
|
|
14
|
+
var e_1, _a;
|
|
15
|
+
var abstractNum = new AbstractNum();
|
|
16
|
+
abstractNum.abstractNumId = element.getAttribute('w:abstractNumId') || '';
|
|
17
|
+
abstractNum.multiLevelType = element.getAttribute('w:multiLevelType');
|
|
18
|
+
var lvls = element.getElementsByTagName('w:lvl');
|
|
19
|
+
try {
|
|
20
|
+
for (var lvls_1 = __values(lvls), lvls_1_1 = lvls_1.next(); !lvls_1_1.done; lvls_1_1 = lvls_1.next()) {
|
|
21
|
+
var child = lvls_1_1.value;
|
|
22
|
+
var lvlId = child.getAttribute('w:ilvl') || '';
|
|
23
|
+
abstractNum.lvls[lvlId] = Lvl.fromXML(word, child);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
27
|
+
finally {
|
|
28
|
+
try {
|
|
29
|
+
if (lvls_1_1 && !lvls_1_1.done && (_a = lvls_1.return)) _a.call(lvls_1);
|
|
30
|
+
}
|
|
31
|
+
finally { if (e_1) throw e_1.error; }
|
|
32
|
+
}
|
|
33
|
+
var multiLevelType = element.querySelector('multiLevelType');
|
|
34
|
+
if (multiLevelType) {
|
|
35
|
+
abstractNum.multiLevelType = getVal(multiLevelType);
|
|
36
|
+
}
|
|
37
|
+
return abstractNum;
|
|
38
|
+
};
|
|
39
|
+
return AbstractNum;
|
|
40
|
+
}());
|
|
41
|
+
|
|
42
|
+
export { AbstractNum };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RunPr } from './../Run';
|
|
2
|
+
import { ST_Jc, ST_LevelSuffix, ST_NumberFormat } from '../../Types';
|
|
3
|
+
import { ParagraphPr } from '../Paragraph';
|
|
4
|
+
import Word from '../../../Word';
|
|
5
|
+
export declare class Lvl {
|
|
6
|
+
ilvl: string;
|
|
7
|
+
start: number;
|
|
8
|
+
numFmt: ST_NumberFormat;
|
|
9
|
+
lvlText: string;
|
|
10
|
+
isLgl: boolean;
|
|
11
|
+
lvlJc: ST_Jc;
|
|
12
|
+
suff: ST_LevelSuffix;
|
|
13
|
+
pPr?: ParagraphPr;
|
|
14
|
+
rPr?: RunPr;
|
|
15
|
+
static fromXML(word: Word, element: Element): Lvl;
|
|
16
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { __values } from '../../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { Run } from '../Run.js';
|
|
3
|
+
import { getValBoolean, getVal, getValNumber } from '../../../OpenXML.js';
|
|
4
|
+
import { ST_Jc, ST_LevelSuffix } from '../../Types.js';
|
|
5
|
+
import { Paragraph } from '../Paragraph.js';
|
|
6
|
+
|
|
7
|
+
var Lvl = /** @class */ (function () {
|
|
8
|
+
function Lvl() {
|
|
9
|
+
this.start = 1;
|
|
10
|
+
this.lvlText = '%1.';
|
|
11
|
+
this.isLgl = false;
|
|
12
|
+
this.lvlJc = ST_Jc.start;
|
|
13
|
+
this.suff = ST_LevelSuffix.space;
|
|
14
|
+
}
|
|
15
|
+
Lvl.fromXML = function (word, element) {
|
|
16
|
+
var e_1, _a;
|
|
17
|
+
var lvl = new Lvl();
|
|
18
|
+
lvl.ilvl = element.getAttribute('w:ilvl');
|
|
19
|
+
try {
|
|
20
|
+
for (var _b = __values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
21
|
+
var child = _c.value;
|
|
22
|
+
var tagName = child.tagName;
|
|
23
|
+
switch (tagName) {
|
|
24
|
+
case 'w:start':
|
|
25
|
+
lvl.start = getValNumber(child);
|
|
26
|
+
break;
|
|
27
|
+
case 'w:numFmt':
|
|
28
|
+
lvl.numFmt = getVal(child);
|
|
29
|
+
break;
|
|
30
|
+
case 'w:lvlText':
|
|
31
|
+
lvl.lvlText = getVal(child);
|
|
32
|
+
break;
|
|
33
|
+
case 'w:lvlJc':
|
|
34
|
+
lvl.lvlJc = getVal(child);
|
|
35
|
+
break;
|
|
36
|
+
case 'w:pPr':
|
|
37
|
+
lvl.pPr = Paragraph.parseParagraphPr(word, child);
|
|
38
|
+
break;
|
|
39
|
+
case 'w:rPr':
|
|
40
|
+
lvl.rPr = Run.parseRunPr(word, child);
|
|
41
|
+
break;
|
|
42
|
+
case 'w:isLgl':
|
|
43
|
+
lvl.isLgl = getValBoolean(child);
|
|
44
|
+
break;
|
|
45
|
+
default:
|
|
46
|
+
console.warn("Lvl: Unknown tag ", tagName, child);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
51
|
+
finally {
|
|
52
|
+
try {
|
|
53
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
54
|
+
}
|
|
55
|
+
finally { if (e_1) throw e_1.error; }
|
|
56
|
+
}
|
|
57
|
+
return lvl;
|
|
58
|
+
};
|
|
59
|
+
return Lvl;
|
|
60
|
+
}());
|
|
61
|
+
|
|
62
|
+
export { Lvl };
|