odf.js 1.12.0 → 1.13.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 +39 -0
- package/dist/codec.cjs +28 -0
- package/dist/codec.d.cts +72 -0
- package/dist/codec.d.ts +72 -0
- package/dist/codec.js +24 -0
- package/dist/image/sniff.cjs +28 -0
- package/dist/image/sniff.d.cts +5 -0
- package/dist/image/sniff.d.ts +5 -0
- package/dist/image/sniff.js +27 -0
- package/dist/index.cjs +156 -3242
- package/dist/index.d.cts +42 -679
- package/dist/index.d.ts +42 -679
- package/dist/index.js +42 -3129
- package/dist/manifest.cjs +252 -0
- package/dist/manifest.d.cts +41 -0
- package/dist/manifest.d.ts +41 -0
- package/dist/manifest.js +242 -0
- package/dist/media-type.cjs +27 -0
- package/dist/media-type.d.cts +20 -0
- package/dist/media-type.d.ts +20 -0
- package/dist/media-type.js +25 -0
- package/dist/mimetype.cjs +19 -0
- package/dist/mimetype.d.cts +7 -0
- package/dist/mimetype.d.ts +7 -0
- package/dist/mimetype.js +16 -0
- package/dist/model/node.cjs +67 -0
- package/dist/model/node.d.cts +2 -0
- package/dist/model/node.d.ts +2 -0
- package/dist/model/node.js +58 -0
- package/dist/model/package.cjs +19 -0
- package/dist/model/package.d.cts +114 -0
- package/dist/model/package.d.ts +114 -0
- package/dist/model/package.js +15 -0
- package/dist/node-CkBWRjNR.d.cts +83 -0
- package/dist/node-CkBWRjNR.d.ts +83 -0
- package/dist/ns.cjs +37 -0
- package/dist/ns.d.cts +32 -0
- package/dist/ns.d.ts +32 -0
- package/dist/ns.js +35 -0
- package/dist/package-io/read.cjs +35 -0
- package/dist/package-io/read.d.cts +5 -0
- package/dist/package-io/read.d.ts +5 -0
- package/dist/package-io/read.js +34 -0
- package/dist/package-io/write.cjs +36 -0
- package/dist/package-io/write.d.cts +7 -0
- package/dist/package-io/write.d.ts +7 -0
- package/dist/package-io/write.js +33 -0
- package/dist/styles/properties.cjs +286 -0
- package/dist/styles/properties.d.cts +45 -0
- package/dist/styles/properties.d.ts +45 -0
- package/dist/styles/properties.js +277 -0
- package/dist/styles/registry.cjs +212 -0
- package/dist/styles/registry.d.cts +37 -0
- package/dist/styles/registry.d.ts +37 -0
- package/dist/styles/registry.js +209 -0
- package/dist/styles/serialize.cjs +23 -0
- package/dist/styles/serialize.d.cts +7 -0
- package/dist/styles/serialize.d.ts +7 -0
- package/dist/styles/serialize.js +21 -0
- package/dist/styles/span.cjs +114 -0
- package/dist/styles/span.d.cts +5 -0
- package/dist/styles/span.d.ts +5 -0
- package/dist/styles/span.js +113 -0
- package/dist/typed/draw/shapes.cjs +314 -0
- package/dist/typed/draw/shapes.d.cts +14 -0
- package/dist/typed/draw/shapes.d.ts +14 -0
- package/dist/typed/draw/shapes.js +311 -0
- package/dist/typed/formula/read.cjs +48 -0
- package/dist/typed/formula/read.d.cts +12 -0
- package/dist/typed/formula/read.d.ts +12 -0
- package/dist/typed/formula/read.js +47 -0
- package/dist/typed/odb/read.cjs +112 -0
- package/dist/typed/odb/read.d.cts +17 -0
- package/dist/typed/odb/read.d.ts +17 -0
- package/dist/typed/odb/read.js +111 -0
- package/dist/typed/odg/read.cjs +30 -0
- package/dist/typed/odg/read.d.cts +10 -0
- package/dist/typed/odg/read.d.ts +10 -0
- package/dist/typed/odg/read.js +29 -0
- package/dist/typed/odm/read.cjs +37 -0
- package/dist/typed/odm/read.d.cts +15 -0
- package/dist/typed/odm/read.d.ts +15 -0
- package/dist/typed/odm/read.js +36 -0
- package/dist/typed/odp/read.cjs +39 -0
- package/dist/typed/odp/read.d.cts +10 -0
- package/dist/typed/odp/read.d.ts +10 -0
- package/dist/typed/odp/read.js +38 -0
- package/dist/typed/ods/read.cjs +318 -0
- package/dist/typed/ods/read.d.cts +10 -0
- package/dist/typed/ods/read.d.ts +10 -0
- package/dist/typed/ods/read.js +317 -0
- package/dist/typed/odt/read.cjs +112 -0
- package/dist/typed/odt/read.d.cts +10 -0
- package/dist/typed/odt/read.d.ts +10 -0
- package/dist/typed/odt/read.js +111 -0
- package/dist/typed/shared/a1.cjs +68 -0
- package/dist/typed/shared/a1.d.cts +18 -0
- package/dist/typed/shared/a1.d.ts +18 -0
- package/dist/typed/shared/a1.js +63 -0
- package/dist/typed/shared/cascade.cjs +102 -0
- package/dist/typed/shared/cascade.d.cts +22 -0
- package/dist/typed/shared/cascade.d.ts +22 -0
- package/dist/typed/shared/cascade.js +99 -0
- package/dist/typed/shared/color.cjs +14 -0
- package/dist/typed/shared/color.d.cts +6 -0
- package/dist/typed/shared/color.d.ts +6 -0
- package/dist/typed/shared/color.js +12 -0
- package/dist/typed/shared/geometry.cjs +79 -0
- package/dist/typed/shared/geometry.d.cts +12 -0
- package/dist/typed/shared/geometry.d.ts +12 -0
- package/dist/typed/shared/geometry.js +75 -0
- package/dist/typed/shared/masterpage.cjs +39 -0
- package/dist/typed/shared/masterpage.d.cts +8 -0
- package/dist/typed/shared/masterpage.d.ts +8 -0
- package/dist/typed/shared/masterpage.js +37 -0
- package/dist/typed/shared/metadata.cjs +42 -0
- package/dist/typed/shared/metadata.d.cts +7 -0
- package/dist/typed/shared/metadata.d.ts +7 -0
- package/dist/typed/shared/metadata.js +40 -0
- package/dist/typed/shared/paragraph.cjs +57 -0
- package/dist/typed/shared/paragraph.d.cts +7 -0
- package/dist/typed/shared/paragraph.d.ts +7 -0
- package/dist/typed/shared/paragraph.js +56 -0
- package/dist/typed/shared/path.cjs +261 -0
- package/dist/typed/shared/path.d.cts +34 -0
- package/dist/typed/shared/path.d.ts +34 -0
- package/dist/typed/shared/path.js +255 -0
- package/dist/typed/shared/style.cjs +8 -0
- package/dist/typed/shared/style.d.cts +2 -0
- package/dist/typed/shared/style.d.ts +2 -0
- package/dist/typed/shared/style.js +2 -0
- package/dist/typed/shared/table.cjs +84 -0
- package/dist/typed/shared/table.d.cts +7 -0
- package/dist/typed/shared/table.d.ts +7 -0
- package/dist/typed/shared/table.js +83 -0
- package/dist/typed/shared/text.cjs +43 -0
- package/dist/typed/shared/text.d.cts +8 -0
- package/dist/typed/shared/text.d.ts +8 -0
- package/dist/typed/shared/text.js +39 -0
- package/dist/typed/shared/transform.cjs +112 -0
- package/dist/typed/shared/transform.d.cts +26 -0
- package/dist/typed/shared/transform.d.ts +26 -0
- package/dist/typed/shared/transform.js +107 -0
- package/dist/typed/shared/units.cjs +35 -0
- package/dist/typed/shared/units.d.cts +2 -0
- package/dist/typed/shared/units.d.ts +2 -0
- package/dist/typed/shared/units.js +33 -0
- package/dist/units-7pCiECuP.d.cts +6 -0
- package/dist/units-7pCiECuP.d.ts +6 -0
- package/dist/util/base64.cjs +48 -0
- package/dist/util/base64.d.cts +5 -0
- package/dist/util/base64.d.ts +5 -0
- package/dist/util/base64.js +46 -0
- package/dist/xml/build.cjs +46 -0
- package/dist/xml/build.d.cts +5 -0
- package/dist/xml/build.d.ts +5 -0
- package/dist/xml/build.js +46 -0
- package/dist/xml/entities.cjs +19 -0
- package/dist/xml/entities.d.cts +5 -0
- package/dist/xml/entities.d.ts +5 -0
- package/dist/xml/entities.js +17 -0
- package/dist/xml/fragment.cjs +22 -0
- package/dist/xml/fragment.d.cts +6 -0
- package/dist/xml/fragment.d.ts +6 -0
- package/dist/xml/fragment.js +20 -0
- package/dist/xml/parse.cjs +88 -0
- package/dist/xml/parse.d.cts +5 -0
- package/dist/xml/parse.d.ts +5 -0
- package/dist/xml/parse.js +88 -0
- package/dist/xml/query.cjs +33 -0
- package/dist/xml/query.d.cts +9 -0
- package/dist/xml/query.d.ts +9 -0
- package/dist/xml/query.js +28 -0
- package/dist/zip.cjs +15 -0
- package/dist/zip.d.cts +9 -0
- package/dist/zip.d.ts +9 -0
- package/dist/zip.js +13 -0
- package/package.json +9 -1
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_util_base64 = require("../../util/base64.cjs");
|
|
3
|
+
const require_image_sniff = require("../../image/sniff.cjs");
|
|
4
|
+
const require_typed_shared_units = require("../shared/units.cjs");
|
|
5
|
+
const require_typed_shared_color = require("../shared/color.cjs");
|
|
6
|
+
const require_xml_query = require("../../xml/query.cjs");
|
|
7
|
+
const require_typed_shared_geometry = require("../shared/geometry.cjs");
|
|
8
|
+
const require_typed_shared_cascade = require("../shared/cascade.cjs");
|
|
9
|
+
const require_typed_shared_paragraph = require("../shared/paragraph.cjs");
|
|
10
|
+
const require_typed_shared_table = require("../shared/table.cjs");
|
|
11
|
+
const require_typed_shared_transform = require("../shared/transform.cjs");
|
|
12
|
+
const require_typed_shared_path = require("../shared/path.cjs");
|
|
13
|
+
//#region src/typed/draw/shapes.ts
|
|
14
|
+
const ZERO_INSETS = {
|
|
15
|
+
insetLeftPt: 0,
|
|
16
|
+
insetTopPt: 0,
|
|
17
|
+
insetRightPt: 0,
|
|
18
|
+
insetBottomPt: 0
|
|
19
|
+
};
|
|
20
|
+
function readPaddingPt(props, attrName) {
|
|
21
|
+
const value = require_xml_query.attrValue(props, attrName);
|
|
22
|
+
return value === void 0 ? void 0 : require_typed_shared_units.parseOdfLength(value);
|
|
23
|
+
}
|
|
24
|
+
function readFrameInsets(frame, pkg) {
|
|
25
|
+
const styleName = require_xml_query.attrValue(frame, "draw:style-name");
|
|
26
|
+
const { elements } = require_typed_shared_cascade.resolveStyleElementChain(styleName, "graphic", pkg);
|
|
27
|
+
let insets = ZERO_INSETS;
|
|
28
|
+
for (const element of elements) {
|
|
29
|
+
const props = require_xml_query.childrenWithTag(element, "style:graphic-properties")[0];
|
|
30
|
+
if (props === void 0) continue;
|
|
31
|
+
insets = {
|
|
32
|
+
insetLeftPt: readPaddingPt(props, "fo:padding-left") ?? insets.insetLeftPt,
|
|
33
|
+
insetTopPt: readPaddingPt(props, "fo:padding-top") ?? insets.insetTopPt,
|
|
34
|
+
insetRightPt: readPaddingPt(props, "fo:padding-right") ?? insets.insetRightPt,
|
|
35
|
+
insetBottomPt: readPaddingPt(props, "fo:padding-bottom") ?? insets.insetBottomPt
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return insets;
|
|
39
|
+
}
|
|
40
|
+
function readDrawImageBlock(image, frameBox, pkg) {
|
|
41
|
+
const href = require_xml_query.attrValue(image, "xlink:href");
|
|
42
|
+
const part = href === void 0 ? void 0 : pkg.parts[href];
|
|
43
|
+
if (part?.kind !== "binary") return;
|
|
44
|
+
const bytes = require_util_base64.base64ToBytes(part.base64);
|
|
45
|
+
const format = require_image_sniff.sniffImageFormat(bytes);
|
|
46
|
+
if (format === void 0) return;
|
|
47
|
+
return {
|
|
48
|
+
kind: "image",
|
|
49
|
+
format,
|
|
50
|
+
base64: part.base64,
|
|
51
|
+
widthPt: frameBox.widthPt,
|
|
52
|
+
heightPt: frameBox.heightPt
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function readDrawFrameContent(frame, frameBox, pkg) {
|
|
56
|
+
const table = require_xml_query.childrenWithTag(frame, "table:table")[0];
|
|
57
|
+
if (table !== void 0) return [require_typed_shared_table.readOdfTable(table, pkg)];
|
|
58
|
+
const textBox = require_xml_query.childrenWithTag(frame, "draw:text-box")[0];
|
|
59
|
+
if (textBox !== void 0) return require_xml_query.elementsWithTag(textBox.children, "text:p").map((p) => require_typed_shared_paragraph.readOdfParagraph(p, pkg));
|
|
60
|
+
const image = require_xml_query.childrenWithTag(frame, "draw:image")[0];
|
|
61
|
+
if (image !== void 0) {
|
|
62
|
+
const block = readDrawImageBlock(image, frameBox, pkg);
|
|
63
|
+
return block === void 0 ? [] : [block];
|
|
64
|
+
}
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
function readDrawFrame(frame, groupFunctions, pkg) {
|
|
68
|
+
const ownGeometry = require_typed_shared_transform.resolveOdfShapeGeometry(frame);
|
|
69
|
+
if (ownGeometry === void 0) return;
|
|
70
|
+
const geometry = require_typed_shared_transform.composeOdfGroupTransform(groupFunctions, ownGeometry);
|
|
71
|
+
return {
|
|
72
|
+
name: require_xml_query.attrValue(frame, "draw:name"),
|
|
73
|
+
frame: geometry.frame,
|
|
74
|
+
rotationDeg: geometry.rotationDeg,
|
|
75
|
+
...readFrameInsets(frame, pkg),
|
|
76
|
+
blocks: readDrawFrameContent(frame, geometry.frame, pkg)
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function readOwnTransformFunctions(element) {
|
|
80
|
+
const value = require_xml_query.attrValue(element, "draw:transform");
|
|
81
|
+
return value === void 0 ? [] : require_typed_shared_transform.parseOdfTransform(value);
|
|
82
|
+
}
|
|
83
|
+
function walkDrawShapes(children, groupFunctions, pkg, out) {
|
|
84
|
+
for (const node of children) {
|
|
85
|
+
if (node.type !== "element") continue;
|
|
86
|
+
if (node.tag === "draw:frame") {
|
|
87
|
+
const shape = readDrawFrame(node, groupFunctions, pkg);
|
|
88
|
+
if (shape !== void 0) out.push(shape);
|
|
89
|
+
} else if (node.tag === "draw:g") {
|
|
90
|
+
const ownFunctions = readOwnTransformFunctions(node);
|
|
91
|
+
const nested = ownFunctions.length === 0 ? groupFunctions : [...ownFunctions, ...groupFunctions];
|
|
92
|
+
walkDrawShapes(node.children, nested, pkg, out);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function readOdfFillAndStroke(element, pkg) {
|
|
97
|
+
const styleName = require_xml_query.attrValue(element, "draw:style-name");
|
|
98
|
+
const { elements } = require_typed_shared_cascade.resolveStyleElementChain(styleName, "graphic", pkg);
|
|
99
|
+
let fill;
|
|
100
|
+
let stroke;
|
|
101
|
+
for (const styleElement of elements) {
|
|
102
|
+
const props = require_xml_query.childrenWithTag(styleElement, "style:graphic-properties")[0];
|
|
103
|
+
if (props === void 0) continue;
|
|
104
|
+
if (require_xml_query.attrValue(props, "draw:fill") === "none") fill = void 0;
|
|
105
|
+
else {
|
|
106
|
+
const fillColorValue = require_xml_query.attrValue(props, "draw:fill-color");
|
|
107
|
+
const parsedFill = fillColorValue === void 0 ? void 0 : require_typed_shared_color.parseOdfColor(fillColorValue);
|
|
108
|
+
if (parsedFill !== void 0) fill = parsedFill;
|
|
109
|
+
}
|
|
110
|
+
if (require_xml_query.attrValue(props, "draw:stroke") === "none") stroke = void 0;
|
|
111
|
+
else {
|
|
112
|
+
const strokeColorValue = require_xml_query.attrValue(props, "svg:stroke-color");
|
|
113
|
+
const strokeWidthValue = require_xml_query.attrValue(props, "svg:stroke-width");
|
|
114
|
+
const strokeColor = strokeColorValue === void 0 ? void 0 : require_typed_shared_color.parseOdfColor(strokeColorValue);
|
|
115
|
+
const strokeWidthPt = strokeWidthValue === void 0 ? void 0 : require_typed_shared_units.parseOdfLength(strokeWidthValue);
|
|
116
|
+
if (strokeColor !== void 0 && strokeWidthPt !== void 0 && strokeWidthPt > 0) stroke = {
|
|
117
|
+
color: strokeColor,
|
|
118
|
+
widthPt: strokeWidthPt
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
fill,
|
|
124
|
+
stroke
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function resolveVectorFrame(element, groupFunctions) {
|
|
128
|
+
const geometry = require_typed_shared_transform.resolveOdfShapeGeometry(element);
|
|
129
|
+
if (geometry === void 0) return;
|
|
130
|
+
return require_typed_shared_transform.composeOdfGroupTransform(groupFunctions, geometry).frame;
|
|
131
|
+
}
|
|
132
|
+
function readDrawRectVector(element, groupFunctions, pkg) {
|
|
133
|
+
const frame = resolveVectorFrame(element, groupFunctions);
|
|
134
|
+
if (frame === void 0) return;
|
|
135
|
+
const { fill, stroke } = readOdfFillAndStroke(element, pkg);
|
|
136
|
+
return {
|
|
137
|
+
kind: "rect",
|
|
138
|
+
frame,
|
|
139
|
+
fill,
|
|
140
|
+
stroke
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function readDrawEllipseVector(element, groupFunctions, pkg) {
|
|
144
|
+
const frame = resolveVectorFrame(element, groupFunctions);
|
|
145
|
+
if (frame === void 0) return;
|
|
146
|
+
const { fill, stroke } = readOdfFillAndStroke(element, pkg);
|
|
147
|
+
return {
|
|
148
|
+
kind: "ellipse",
|
|
149
|
+
frame,
|
|
150
|
+
fill,
|
|
151
|
+
stroke
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function readDrawLineVector(element, groupFunctions, pkg) {
|
|
155
|
+
const raw = require_typed_shared_geometry.parseLinePoints(element);
|
|
156
|
+
if (raw === void 0) return;
|
|
157
|
+
const from = groupFunctions.length === 0 ? raw.from : require_typed_shared_transform.applyOdfTransform(groupFunctions, raw.from);
|
|
158
|
+
const to = groupFunctions.length === 0 ? raw.to : require_typed_shared_transform.applyOdfTransform(groupFunctions, raw.to);
|
|
159
|
+
const { stroke } = readOdfFillAndStroke(element, pkg);
|
|
160
|
+
if (stroke === void 0) return;
|
|
161
|
+
return {
|
|
162
|
+
kind: "line",
|
|
163
|
+
from,
|
|
164
|
+
to,
|
|
165
|
+
stroke
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function readDrawPathVector(element, groupFunctions, pkg) {
|
|
169
|
+
const frame = resolveVectorFrame(element, groupFunctions);
|
|
170
|
+
if (frame === void 0) return;
|
|
171
|
+
const viewBoxValue = require_xml_query.attrValue(element, "svg:viewBox");
|
|
172
|
+
const viewBox = viewBoxValue === void 0 ? void 0 : require_typed_shared_path.parseOdfViewBox(viewBoxValue);
|
|
173
|
+
if (viewBox === void 0) return;
|
|
174
|
+
let rawSubpaths;
|
|
175
|
+
if (element.tag === "draw:path") {
|
|
176
|
+
const d = require_xml_query.attrValue(element, "svg:d");
|
|
177
|
+
rawSubpaths = d === void 0 ? [] : require_typed_shared_path.parseOdfPathData(d);
|
|
178
|
+
} else {
|
|
179
|
+
const pointsValue = require_xml_query.attrValue(element, "draw:points");
|
|
180
|
+
const points = pointsValue === void 0 ? [] : require_typed_shared_path.parseOdfPointsList(pointsValue);
|
|
181
|
+
const subpath = require_typed_shared_path.rawSubpathFromPoints(points, element.tag === "draw:polygon");
|
|
182
|
+
rawSubpaths = subpath === void 0 ? [] : [subpath];
|
|
183
|
+
}
|
|
184
|
+
if (rawSubpaths.length === 0) return;
|
|
185
|
+
const subpaths = require_typed_shared_path.buildOdfSubpaths(rawSubpaths, viewBox, frame);
|
|
186
|
+
const { fill, stroke } = readOdfFillAndStroke(element, pkg);
|
|
187
|
+
return {
|
|
188
|
+
kind: "path",
|
|
189
|
+
frame,
|
|
190
|
+
subpaths,
|
|
191
|
+
fill,
|
|
192
|
+
stroke
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
const RECOGNIZED_CUSTOM_SHAPE_PRESETS = /* @__PURE__ */ new Set([
|
|
196
|
+
"rectangle",
|
|
197
|
+
"round-rectangle",
|
|
198
|
+
"ellipse"
|
|
199
|
+
]);
|
|
200
|
+
function readCustomShapeVector(element, groupFunctions, pkg) {
|
|
201
|
+
const geometryElement = require_xml_query.childrenWithTag(element, "draw:enhanced-geometry")[0];
|
|
202
|
+
const type = geometryElement === void 0 ? void 0 : require_xml_query.attrValue(geometryElement, "draw:type");
|
|
203
|
+
if (type === void 0 || !RECOGNIZED_CUSTOM_SHAPE_PRESETS.has(type)) return;
|
|
204
|
+
const frame = resolveVectorFrame(element, groupFunctions);
|
|
205
|
+
if (frame === void 0) return;
|
|
206
|
+
const { fill, stroke } = readOdfFillAndStroke(element, pkg);
|
|
207
|
+
return {
|
|
208
|
+
kind: type === "ellipse" ? "ellipse" : "rect",
|
|
209
|
+
frame,
|
|
210
|
+
fill,
|
|
211
|
+
stroke
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
function readCustomShapeAsTextShape(element, groupFunctions, pkg) {
|
|
215
|
+
const paragraphs = require_xml_query.elementsWithTag(element.children, "text:p").map((p) => require_typed_shared_paragraph.readOdfParagraph(p, pkg));
|
|
216
|
+
if (!paragraphs.some((paragraph) => paragraph.runs.some((run) => run.text.length > 0))) return;
|
|
217
|
+
const ownGeometry = require_typed_shared_transform.resolveOdfShapeGeometry(element);
|
|
218
|
+
if (ownGeometry === void 0) return;
|
|
219
|
+
const geometry = require_typed_shared_transform.composeOdfGroupTransform(groupFunctions, ownGeometry);
|
|
220
|
+
return {
|
|
221
|
+
name: require_xml_query.attrValue(element, "draw:name"),
|
|
222
|
+
frame: geometry.frame,
|
|
223
|
+
rotationDeg: geometry.rotationDeg,
|
|
224
|
+
...readFrameInsets(element, pkg),
|
|
225
|
+
blocks: paragraphs
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
function nextDocumentIndex(state) {
|
|
229
|
+
const value = state.next;
|
|
230
|
+
state.next += 1;
|
|
231
|
+
return value;
|
|
232
|
+
}
|
|
233
|
+
function paintOrderKey(element, state) {
|
|
234
|
+
const documentIndex = nextDocumentIndex(state);
|
|
235
|
+
const raw = require_xml_query.attrValue(element, "draw:z-index");
|
|
236
|
+
if (raw === void 0) return documentIndex;
|
|
237
|
+
const parsed = Number.parseInt(raw, 10);
|
|
238
|
+
return Number.isInteger(parsed) && parsed >= 0 ? parsed : documentIndex;
|
|
239
|
+
}
|
|
240
|
+
function byPaintOrder(items) {
|
|
241
|
+
return items.slice().sort((a, b) => a.zIndex - b.zIndex).map((item) => item.value);
|
|
242
|
+
}
|
|
243
|
+
function walkDrawPageContent(children, groupFunctions, pkg, indexState, shapesOut, vectorsOut) {
|
|
244
|
+
for (const node of children) {
|
|
245
|
+
if (node.type !== "element") continue;
|
|
246
|
+
if (node.tag === "draw:frame") {
|
|
247
|
+
const zIndex = paintOrderKey(node, indexState);
|
|
248
|
+
const shape = readDrawFrame(node, groupFunctions, pkg);
|
|
249
|
+
if (shape !== void 0) shapesOut.push({
|
|
250
|
+
value: shape,
|
|
251
|
+
zIndex
|
|
252
|
+
});
|
|
253
|
+
} else if (node.tag === "draw:g") {
|
|
254
|
+
const ownFunctions = readOwnTransformFunctions(node);
|
|
255
|
+
const nested = ownFunctions.length === 0 ? groupFunctions : [...ownFunctions, ...groupFunctions];
|
|
256
|
+
walkDrawPageContent(node.children, nested, pkg, indexState, shapesOut, vectorsOut);
|
|
257
|
+
} else if (node.tag === "draw:rect") {
|
|
258
|
+
const zIndex = paintOrderKey(node, indexState);
|
|
259
|
+
const vector = readDrawRectVector(node, groupFunctions, pkg);
|
|
260
|
+
if (vector !== void 0) vectorsOut.push({
|
|
261
|
+
value: vector,
|
|
262
|
+
zIndex
|
|
263
|
+
});
|
|
264
|
+
} else if (node.tag === "draw:ellipse" || node.tag === "draw:circle") {
|
|
265
|
+
const zIndex = paintOrderKey(node, indexState);
|
|
266
|
+
const vector = readDrawEllipseVector(node, groupFunctions, pkg);
|
|
267
|
+
if (vector !== void 0) vectorsOut.push({
|
|
268
|
+
value: vector,
|
|
269
|
+
zIndex
|
|
270
|
+
});
|
|
271
|
+
} else if (node.tag === "draw:line") {
|
|
272
|
+
const zIndex = paintOrderKey(node, indexState);
|
|
273
|
+
const vector = readDrawLineVector(node, groupFunctions, pkg);
|
|
274
|
+
if (vector !== void 0) vectorsOut.push({
|
|
275
|
+
value: vector,
|
|
276
|
+
zIndex
|
|
277
|
+
});
|
|
278
|
+
} else if (node.tag === "draw:path" || node.tag === "draw:polygon" || node.tag === "draw:polyline") {
|
|
279
|
+
const zIndex = paintOrderKey(node, indexState);
|
|
280
|
+
const vector = readDrawPathVector(node, groupFunctions, pkg);
|
|
281
|
+
if (vector !== void 0) vectorsOut.push({
|
|
282
|
+
value: vector,
|
|
283
|
+
zIndex
|
|
284
|
+
});
|
|
285
|
+
} else if (node.tag === "draw:custom-shape") {
|
|
286
|
+
const zIndex = paintOrderKey(node, indexState);
|
|
287
|
+
const vector = readCustomShapeVector(node, groupFunctions, pkg);
|
|
288
|
+
if (vector !== void 0) vectorsOut.push({
|
|
289
|
+
value: vector,
|
|
290
|
+
zIndex
|
|
291
|
+
});
|
|
292
|
+
else {
|
|
293
|
+
const shape = readCustomShapeAsTextShape(node, groupFunctions, pkg);
|
|
294
|
+
if (shape !== void 0) shapesOut.push({
|
|
295
|
+
value: shape,
|
|
296
|
+
zIndex
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
function readDrawPageContent(children, pkg) {
|
|
303
|
+
const shapesOut = [];
|
|
304
|
+
const vectorsOut = [];
|
|
305
|
+
walkDrawPageContent(children, [], pkg, { next: 0 }, shapesOut, vectorsOut);
|
|
306
|
+
return {
|
|
307
|
+
shapes: byPaintOrder(shapesOut),
|
|
308
|
+
vectors: byPaintOrder(vectorsOut)
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
//#endregion
|
|
312
|
+
exports.readDrawFrame = readDrawFrame;
|
|
313
|
+
exports.readDrawPageContent = readDrawPageContent;
|
|
314
|
+
exports.walkDrawShapes = walkDrawShapes;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { d as XmlNode, l as XmlElement } from "../../node-CkBWRjNR.cjs";
|
|
2
|
+
import { Package } from "../../model/package.cjs";
|
|
3
|
+
import { OdfTransformFunction } from "../shared/transform.cjs";
|
|
4
|
+
import { ContentShape, ContentVector } from "document-schema.js";
|
|
5
|
+
//#region src/typed/draw/shapes.d.ts
|
|
6
|
+
declare function readDrawFrame(frame: XmlElement, groupFunctions: readonly OdfTransformFunction[], pkg: Package): ContentShape | undefined;
|
|
7
|
+
declare function walkDrawShapes(children: readonly XmlNode[], groupFunctions: readonly OdfTransformFunction[], pkg: Package, out: ContentShape[]): void;
|
|
8
|
+
interface DrawPageContent {
|
|
9
|
+
readonly shapes: ContentShape[];
|
|
10
|
+
readonly vectors: ContentVector[];
|
|
11
|
+
}
|
|
12
|
+
declare function readDrawPageContent(children: readonly XmlNode[], pkg: Package): DrawPageContent;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { DrawPageContent, readDrawFrame, readDrawPageContent, walkDrawShapes };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { d as XmlNode, l as XmlElement } from "../../node-CkBWRjNR.js";
|
|
2
|
+
import { Package } from "../../model/package.js";
|
|
3
|
+
import { OdfTransformFunction } from "../shared/transform.js";
|
|
4
|
+
import { ContentShape, ContentVector } from "document-schema.js";
|
|
5
|
+
//#region src/typed/draw/shapes.d.ts
|
|
6
|
+
declare function readDrawFrame(frame: XmlElement, groupFunctions: readonly OdfTransformFunction[], pkg: Package): ContentShape | undefined;
|
|
7
|
+
declare function walkDrawShapes(children: readonly XmlNode[], groupFunctions: readonly OdfTransformFunction[], pkg: Package, out: ContentShape[]): void;
|
|
8
|
+
interface DrawPageContent {
|
|
9
|
+
readonly shapes: ContentShape[];
|
|
10
|
+
readonly vectors: ContentVector[];
|
|
11
|
+
}
|
|
12
|
+
declare function readDrawPageContent(children: readonly XmlNode[], pkg: Package): DrawPageContent;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { DrawPageContent, readDrawFrame, readDrawPageContent, walkDrawShapes };
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { base64ToBytes } from "../../util/base64.js";
|
|
2
|
+
import { sniffImageFormat } from "../../image/sniff.js";
|
|
3
|
+
import { parseOdfLength } from "../shared/units.js";
|
|
4
|
+
import { parseOdfColor } from "../shared/color.js";
|
|
5
|
+
import { attrValue, childrenWithTag, elementsWithTag } from "../../xml/query.js";
|
|
6
|
+
import { parseLinePoints } from "../shared/geometry.js";
|
|
7
|
+
import { resolveStyleElementChain } from "../shared/cascade.js";
|
|
8
|
+
import { readOdfParagraph } from "../shared/paragraph.js";
|
|
9
|
+
import { readOdfTable } from "../shared/table.js";
|
|
10
|
+
import { applyOdfTransform, composeOdfGroupTransform, parseOdfTransform, resolveOdfShapeGeometry } from "../shared/transform.js";
|
|
11
|
+
import { buildOdfSubpaths, parseOdfPathData, parseOdfPointsList, parseOdfViewBox, rawSubpathFromPoints } from "../shared/path.js";
|
|
12
|
+
//#region src/typed/draw/shapes.ts
|
|
13
|
+
const ZERO_INSETS = {
|
|
14
|
+
insetLeftPt: 0,
|
|
15
|
+
insetTopPt: 0,
|
|
16
|
+
insetRightPt: 0,
|
|
17
|
+
insetBottomPt: 0
|
|
18
|
+
};
|
|
19
|
+
function readPaddingPt(props, attrName) {
|
|
20
|
+
const value = attrValue(props, attrName);
|
|
21
|
+
return value === void 0 ? void 0 : parseOdfLength(value);
|
|
22
|
+
}
|
|
23
|
+
function readFrameInsets(frame, pkg) {
|
|
24
|
+
const styleName = attrValue(frame, "draw:style-name");
|
|
25
|
+
const { elements } = resolveStyleElementChain(styleName, "graphic", pkg);
|
|
26
|
+
let insets = ZERO_INSETS;
|
|
27
|
+
for (const element of elements) {
|
|
28
|
+
const props = childrenWithTag(element, "style:graphic-properties")[0];
|
|
29
|
+
if (props === void 0) continue;
|
|
30
|
+
insets = {
|
|
31
|
+
insetLeftPt: readPaddingPt(props, "fo:padding-left") ?? insets.insetLeftPt,
|
|
32
|
+
insetTopPt: readPaddingPt(props, "fo:padding-top") ?? insets.insetTopPt,
|
|
33
|
+
insetRightPt: readPaddingPt(props, "fo:padding-right") ?? insets.insetRightPt,
|
|
34
|
+
insetBottomPt: readPaddingPt(props, "fo:padding-bottom") ?? insets.insetBottomPt
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return insets;
|
|
38
|
+
}
|
|
39
|
+
function readDrawImageBlock(image, frameBox, pkg) {
|
|
40
|
+
const href = attrValue(image, "xlink:href");
|
|
41
|
+
const part = href === void 0 ? void 0 : pkg.parts[href];
|
|
42
|
+
if (part?.kind !== "binary") return;
|
|
43
|
+
const bytes = base64ToBytes(part.base64);
|
|
44
|
+
const format = sniffImageFormat(bytes);
|
|
45
|
+
if (format === void 0) return;
|
|
46
|
+
return {
|
|
47
|
+
kind: "image",
|
|
48
|
+
format,
|
|
49
|
+
base64: part.base64,
|
|
50
|
+
widthPt: frameBox.widthPt,
|
|
51
|
+
heightPt: frameBox.heightPt
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function readDrawFrameContent(frame, frameBox, pkg) {
|
|
55
|
+
const table = childrenWithTag(frame, "table:table")[0];
|
|
56
|
+
if (table !== void 0) return [readOdfTable(table, pkg)];
|
|
57
|
+
const textBox = childrenWithTag(frame, "draw:text-box")[0];
|
|
58
|
+
if (textBox !== void 0) return elementsWithTag(textBox.children, "text:p").map((p) => readOdfParagraph(p, pkg));
|
|
59
|
+
const image = childrenWithTag(frame, "draw:image")[0];
|
|
60
|
+
if (image !== void 0) {
|
|
61
|
+
const block = readDrawImageBlock(image, frameBox, pkg);
|
|
62
|
+
return block === void 0 ? [] : [block];
|
|
63
|
+
}
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
function readDrawFrame(frame, groupFunctions, pkg) {
|
|
67
|
+
const ownGeometry = resolveOdfShapeGeometry(frame);
|
|
68
|
+
if (ownGeometry === void 0) return;
|
|
69
|
+
const geometry = composeOdfGroupTransform(groupFunctions, ownGeometry);
|
|
70
|
+
return {
|
|
71
|
+
name: attrValue(frame, "draw:name"),
|
|
72
|
+
frame: geometry.frame,
|
|
73
|
+
rotationDeg: geometry.rotationDeg,
|
|
74
|
+
...readFrameInsets(frame, pkg),
|
|
75
|
+
blocks: readDrawFrameContent(frame, geometry.frame, pkg)
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function readOwnTransformFunctions(element) {
|
|
79
|
+
const value = attrValue(element, "draw:transform");
|
|
80
|
+
return value === void 0 ? [] : parseOdfTransform(value);
|
|
81
|
+
}
|
|
82
|
+
function walkDrawShapes(children, groupFunctions, pkg, out) {
|
|
83
|
+
for (const node of children) {
|
|
84
|
+
if (node.type !== "element") continue;
|
|
85
|
+
if (node.tag === "draw:frame") {
|
|
86
|
+
const shape = readDrawFrame(node, groupFunctions, pkg);
|
|
87
|
+
if (shape !== void 0) out.push(shape);
|
|
88
|
+
} else if (node.tag === "draw:g") {
|
|
89
|
+
const ownFunctions = readOwnTransformFunctions(node);
|
|
90
|
+
const nested = ownFunctions.length === 0 ? groupFunctions : [...ownFunctions, ...groupFunctions];
|
|
91
|
+
walkDrawShapes(node.children, nested, pkg, out);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function readOdfFillAndStroke(element, pkg) {
|
|
96
|
+
const styleName = attrValue(element, "draw:style-name");
|
|
97
|
+
const { elements } = resolveStyleElementChain(styleName, "graphic", pkg);
|
|
98
|
+
let fill;
|
|
99
|
+
let stroke;
|
|
100
|
+
for (const styleElement of elements) {
|
|
101
|
+
const props = childrenWithTag(styleElement, "style:graphic-properties")[0];
|
|
102
|
+
if (props === void 0) continue;
|
|
103
|
+
if (attrValue(props, "draw:fill") === "none") fill = void 0;
|
|
104
|
+
else {
|
|
105
|
+
const fillColorValue = attrValue(props, "draw:fill-color");
|
|
106
|
+
const parsedFill = fillColorValue === void 0 ? void 0 : parseOdfColor(fillColorValue);
|
|
107
|
+
if (parsedFill !== void 0) fill = parsedFill;
|
|
108
|
+
}
|
|
109
|
+
if (attrValue(props, "draw:stroke") === "none") stroke = void 0;
|
|
110
|
+
else {
|
|
111
|
+
const strokeColorValue = attrValue(props, "svg:stroke-color");
|
|
112
|
+
const strokeWidthValue = attrValue(props, "svg:stroke-width");
|
|
113
|
+
const strokeColor = strokeColorValue === void 0 ? void 0 : parseOdfColor(strokeColorValue);
|
|
114
|
+
const strokeWidthPt = strokeWidthValue === void 0 ? void 0 : parseOdfLength(strokeWidthValue);
|
|
115
|
+
if (strokeColor !== void 0 && strokeWidthPt !== void 0 && strokeWidthPt > 0) stroke = {
|
|
116
|
+
color: strokeColor,
|
|
117
|
+
widthPt: strokeWidthPt
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
fill,
|
|
123
|
+
stroke
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function resolveVectorFrame(element, groupFunctions) {
|
|
127
|
+
const geometry = resolveOdfShapeGeometry(element);
|
|
128
|
+
if (geometry === void 0) return;
|
|
129
|
+
return composeOdfGroupTransform(groupFunctions, geometry).frame;
|
|
130
|
+
}
|
|
131
|
+
function readDrawRectVector(element, groupFunctions, pkg) {
|
|
132
|
+
const frame = resolveVectorFrame(element, groupFunctions);
|
|
133
|
+
if (frame === void 0) return;
|
|
134
|
+
const { fill, stroke } = readOdfFillAndStroke(element, pkg);
|
|
135
|
+
return {
|
|
136
|
+
kind: "rect",
|
|
137
|
+
frame,
|
|
138
|
+
fill,
|
|
139
|
+
stroke
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function readDrawEllipseVector(element, groupFunctions, pkg) {
|
|
143
|
+
const frame = resolveVectorFrame(element, groupFunctions);
|
|
144
|
+
if (frame === void 0) return;
|
|
145
|
+
const { fill, stroke } = readOdfFillAndStroke(element, pkg);
|
|
146
|
+
return {
|
|
147
|
+
kind: "ellipse",
|
|
148
|
+
frame,
|
|
149
|
+
fill,
|
|
150
|
+
stroke
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function readDrawLineVector(element, groupFunctions, pkg) {
|
|
154
|
+
const raw = parseLinePoints(element);
|
|
155
|
+
if (raw === void 0) return;
|
|
156
|
+
const from = groupFunctions.length === 0 ? raw.from : applyOdfTransform(groupFunctions, raw.from);
|
|
157
|
+
const to = groupFunctions.length === 0 ? raw.to : applyOdfTransform(groupFunctions, raw.to);
|
|
158
|
+
const { stroke } = readOdfFillAndStroke(element, pkg);
|
|
159
|
+
if (stroke === void 0) return;
|
|
160
|
+
return {
|
|
161
|
+
kind: "line",
|
|
162
|
+
from,
|
|
163
|
+
to,
|
|
164
|
+
stroke
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function readDrawPathVector(element, groupFunctions, pkg) {
|
|
168
|
+
const frame = resolveVectorFrame(element, groupFunctions);
|
|
169
|
+
if (frame === void 0) return;
|
|
170
|
+
const viewBoxValue = attrValue(element, "svg:viewBox");
|
|
171
|
+
const viewBox = viewBoxValue === void 0 ? void 0 : parseOdfViewBox(viewBoxValue);
|
|
172
|
+
if (viewBox === void 0) return;
|
|
173
|
+
let rawSubpaths;
|
|
174
|
+
if (element.tag === "draw:path") {
|
|
175
|
+
const d = attrValue(element, "svg:d");
|
|
176
|
+
rawSubpaths = d === void 0 ? [] : parseOdfPathData(d);
|
|
177
|
+
} else {
|
|
178
|
+
const pointsValue = attrValue(element, "draw:points");
|
|
179
|
+
const points = pointsValue === void 0 ? [] : parseOdfPointsList(pointsValue);
|
|
180
|
+
const subpath = rawSubpathFromPoints(points, element.tag === "draw:polygon");
|
|
181
|
+
rawSubpaths = subpath === void 0 ? [] : [subpath];
|
|
182
|
+
}
|
|
183
|
+
if (rawSubpaths.length === 0) return;
|
|
184
|
+
const subpaths = buildOdfSubpaths(rawSubpaths, viewBox, frame);
|
|
185
|
+
const { fill, stroke } = readOdfFillAndStroke(element, pkg);
|
|
186
|
+
return {
|
|
187
|
+
kind: "path",
|
|
188
|
+
frame,
|
|
189
|
+
subpaths,
|
|
190
|
+
fill,
|
|
191
|
+
stroke
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
const RECOGNIZED_CUSTOM_SHAPE_PRESETS = /* @__PURE__ */ new Set([
|
|
195
|
+
"rectangle",
|
|
196
|
+
"round-rectangle",
|
|
197
|
+
"ellipse"
|
|
198
|
+
]);
|
|
199
|
+
function readCustomShapeVector(element, groupFunctions, pkg) {
|
|
200
|
+
const geometryElement = childrenWithTag(element, "draw:enhanced-geometry")[0];
|
|
201
|
+
const type = geometryElement === void 0 ? void 0 : attrValue(geometryElement, "draw:type");
|
|
202
|
+
if (type === void 0 || !RECOGNIZED_CUSTOM_SHAPE_PRESETS.has(type)) return;
|
|
203
|
+
const frame = resolveVectorFrame(element, groupFunctions);
|
|
204
|
+
if (frame === void 0) return;
|
|
205
|
+
const { fill, stroke } = readOdfFillAndStroke(element, pkg);
|
|
206
|
+
return {
|
|
207
|
+
kind: type === "ellipse" ? "ellipse" : "rect",
|
|
208
|
+
frame,
|
|
209
|
+
fill,
|
|
210
|
+
stroke
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function readCustomShapeAsTextShape(element, groupFunctions, pkg) {
|
|
214
|
+
const paragraphs = elementsWithTag(element.children, "text:p").map((p) => readOdfParagraph(p, pkg));
|
|
215
|
+
if (!paragraphs.some((paragraph) => paragraph.runs.some((run) => run.text.length > 0))) return;
|
|
216
|
+
const ownGeometry = resolveOdfShapeGeometry(element);
|
|
217
|
+
if (ownGeometry === void 0) return;
|
|
218
|
+
const geometry = composeOdfGroupTransform(groupFunctions, ownGeometry);
|
|
219
|
+
return {
|
|
220
|
+
name: attrValue(element, "draw:name"),
|
|
221
|
+
frame: geometry.frame,
|
|
222
|
+
rotationDeg: geometry.rotationDeg,
|
|
223
|
+
...readFrameInsets(element, pkg),
|
|
224
|
+
blocks: paragraphs
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
function nextDocumentIndex(state) {
|
|
228
|
+
const value = state.next;
|
|
229
|
+
state.next += 1;
|
|
230
|
+
return value;
|
|
231
|
+
}
|
|
232
|
+
function paintOrderKey(element, state) {
|
|
233
|
+
const documentIndex = nextDocumentIndex(state);
|
|
234
|
+
const raw = attrValue(element, "draw:z-index");
|
|
235
|
+
if (raw === void 0) return documentIndex;
|
|
236
|
+
const parsed = Number.parseInt(raw, 10);
|
|
237
|
+
return Number.isInteger(parsed) && parsed >= 0 ? parsed : documentIndex;
|
|
238
|
+
}
|
|
239
|
+
function byPaintOrder(items) {
|
|
240
|
+
return items.slice().sort((a, b) => a.zIndex - b.zIndex).map((item) => item.value);
|
|
241
|
+
}
|
|
242
|
+
function walkDrawPageContent(children, groupFunctions, pkg, indexState, shapesOut, vectorsOut) {
|
|
243
|
+
for (const node of children) {
|
|
244
|
+
if (node.type !== "element") continue;
|
|
245
|
+
if (node.tag === "draw:frame") {
|
|
246
|
+
const zIndex = paintOrderKey(node, indexState);
|
|
247
|
+
const shape = readDrawFrame(node, groupFunctions, pkg);
|
|
248
|
+
if (shape !== void 0) shapesOut.push({
|
|
249
|
+
value: shape,
|
|
250
|
+
zIndex
|
|
251
|
+
});
|
|
252
|
+
} else if (node.tag === "draw:g") {
|
|
253
|
+
const ownFunctions = readOwnTransformFunctions(node);
|
|
254
|
+
const nested = ownFunctions.length === 0 ? groupFunctions : [...ownFunctions, ...groupFunctions];
|
|
255
|
+
walkDrawPageContent(node.children, nested, pkg, indexState, shapesOut, vectorsOut);
|
|
256
|
+
} else if (node.tag === "draw:rect") {
|
|
257
|
+
const zIndex = paintOrderKey(node, indexState);
|
|
258
|
+
const vector = readDrawRectVector(node, groupFunctions, pkg);
|
|
259
|
+
if (vector !== void 0) vectorsOut.push({
|
|
260
|
+
value: vector,
|
|
261
|
+
zIndex
|
|
262
|
+
});
|
|
263
|
+
} else if (node.tag === "draw:ellipse" || node.tag === "draw:circle") {
|
|
264
|
+
const zIndex = paintOrderKey(node, indexState);
|
|
265
|
+
const vector = readDrawEllipseVector(node, groupFunctions, pkg);
|
|
266
|
+
if (vector !== void 0) vectorsOut.push({
|
|
267
|
+
value: vector,
|
|
268
|
+
zIndex
|
|
269
|
+
});
|
|
270
|
+
} else if (node.tag === "draw:line") {
|
|
271
|
+
const zIndex = paintOrderKey(node, indexState);
|
|
272
|
+
const vector = readDrawLineVector(node, groupFunctions, pkg);
|
|
273
|
+
if (vector !== void 0) vectorsOut.push({
|
|
274
|
+
value: vector,
|
|
275
|
+
zIndex
|
|
276
|
+
});
|
|
277
|
+
} else if (node.tag === "draw:path" || node.tag === "draw:polygon" || node.tag === "draw:polyline") {
|
|
278
|
+
const zIndex = paintOrderKey(node, indexState);
|
|
279
|
+
const vector = readDrawPathVector(node, groupFunctions, pkg);
|
|
280
|
+
if (vector !== void 0) vectorsOut.push({
|
|
281
|
+
value: vector,
|
|
282
|
+
zIndex
|
|
283
|
+
});
|
|
284
|
+
} else if (node.tag === "draw:custom-shape") {
|
|
285
|
+
const zIndex = paintOrderKey(node, indexState);
|
|
286
|
+
const vector = readCustomShapeVector(node, groupFunctions, pkg);
|
|
287
|
+
if (vector !== void 0) vectorsOut.push({
|
|
288
|
+
value: vector,
|
|
289
|
+
zIndex
|
|
290
|
+
});
|
|
291
|
+
else {
|
|
292
|
+
const shape = readCustomShapeAsTextShape(node, groupFunctions, pkg);
|
|
293
|
+
if (shape !== void 0) shapesOut.push({
|
|
294
|
+
value: shape,
|
|
295
|
+
zIndex
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
function readDrawPageContent(children, pkg) {
|
|
302
|
+
const shapesOut = [];
|
|
303
|
+
const vectorsOut = [];
|
|
304
|
+
walkDrawPageContent(children, [], pkg, { next: 0 }, shapesOut, vectorsOut);
|
|
305
|
+
return {
|
|
306
|
+
shapes: byPaintOrder(shapesOut),
|
|
307
|
+
vectors: byPaintOrder(vectorsOut)
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
//#endregion
|
|
311
|
+
export { readDrawFrame, readDrawPageContent, walkDrawShapes };
|