odf.js 6.2.1 → 6.4.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 +191 -17
- package/dist/{cascade-BDkyOmoo.d.cts → cascade-BpMwrjkB.d.cts} +1 -1
- package/dist/{cascade-CaVinmvp.d.ts → cascade-PDS3hgrP.d.ts} +1 -1
- package/dist/{codec-B72LApRl.d.cts → codec-CFdlbFLJ.d.cts} +21 -13
- package/dist/{codec-rbZGlr37.d.ts → codec-DTAgph2r.d.ts} +21 -13
- package/dist/codec.d.cts +1 -1
- package/dist/codec.d.ts +1 -1
- package/dist/{embedded-UQQNFd5U.js → embedded-BnavfkP-.js} +4 -5
- package/dist/{embedded-BsO-SvtW.cjs → embedded-Bxyss_ck.cjs} +15 -4
- package/dist/index.cjs +53 -1
- package/dist/index.d.cts +24 -16
- package/dist/index.d.ts +24 -16
- package/dist/index.js +19 -11
- package/dist/list-7FO0SDqZ.d.ts +32 -0
- package/dist/list-BorrTJBY.d.cts +32 -0
- package/dist/metadata-BUzwE_-u.d.ts +10 -0
- package/dist/metadata-CYXgXL_h.d.cts +10 -0
- package/dist/{ns-C14w-Zhf.d.cts → ns-DrleaIZQ.d.cts} +3 -1
- package/dist/{ns-CTyKJZeF.d.ts → ns-E0TfX9tZ.d.ts} +3 -1
- package/dist/ooo1/ns.cjs +9 -0
- package/dist/ooo1/ns.d.cts +2 -2
- package/dist/ooo1/ns.d.ts +2 -2
- package/dist/ooo1/ns.js +8 -1
- package/dist/ooo1/properties.cjs +30 -0
- package/dist/ooo1/properties.d.cts +6 -2
- package/dist/ooo1/properties.d.ts +6 -2
- package/dist/ooo1/properties.js +30 -1
- package/dist/ooo1/read.cjs +1 -1
- package/dist/ooo1/read.d.cts +1 -1
- package/dist/ooo1/read.d.ts +1 -1
- package/dist/ooo1/read.js +1 -1
- package/dist/ooo1/transform.cjs +290 -0
- package/dist/ooo1/transform.d.cts +2 -2
- package/dist/ooo1/transform.d.ts +2 -2
- package/dist/ooo1/transform.js +293 -4
- package/dist/ooo1/write.cjs +40 -0
- package/dist/ooo1/write.d.cts +2 -0
- package/dist/ooo1/write.d.ts +2 -0
- package/dist/ooo1/write.js +32 -0
- package/dist/package-io/scaffold.cjs +65 -0
- package/dist/package-io/scaffold.d.cts +2 -0
- package/dist/package-io/scaffold.d.ts +2 -0
- package/dist/package-io/scaffold.js +62 -0
- package/dist/paragraph-Bf6Iq5wC.d.cts +28 -0
- package/dist/paragraph-DtC86tft.d.ts +28 -0
- package/dist/{path-CK0dIPgx.d.cts → path-8HQS-J7y.d.cts} +3 -1
- package/dist/{path-CK0dIPgx.d.ts → path-8HQS-J7y.d.ts} +3 -1
- package/dist/{read-Bo1GBjSE.d.ts → read-A3CJkqVM.d.ts} +3 -1
- package/dist/{read-RFqq4ckj.d.cts → read-BgnLFuSi.d.cts} +1 -1
- package/dist/{read-3yy5EFV_.d.ts → read-CqaZ01kU.d.ts} +1 -1
- package/dist/{read-tpfiT_n4.d.cts → read-fphkvCpR.d.cts} +3 -1
- package/dist/{registry-Dajfxsbz.d.ts → registry-C_16-N6i.d.ts} +2 -0
- package/dist/{registry-B-ZkdQv1.d.cts → registry-PoQIRgbY.d.cts} +2 -0
- package/dist/scaffold-44EIMGll.d.cts +8 -0
- package/dist/scaffold-ehGsIpZ5.d.ts +8 -0
- package/dist/{shapes-QkOsc-WT.d.ts → shapes-B6Ms7ibr.d.ts} +1 -1
- package/dist/{shapes-BCjeY90t.d.cts → shapes-CbBc9t0y.d.cts} +1 -1
- package/dist/styles/properties.cjs +1 -1
- package/dist/styles/properties.js +2 -2
- package/dist/styles/registry.cjs +9 -6
- package/dist/styles/registry.d.cts +1 -1
- package/dist/styles/registry.d.ts +1 -1
- package/dist/styles/registry.js +9 -6
- package/dist/table-CECMtPxZ.d.cts +20 -0
- package/dist/table-XuniPr2I.d.ts +20 -0
- package/dist/text-B8350HA2.d.ts +17 -0
- package/dist/text-pmlTqzgi.d.cts +17 -0
- package/dist/{transform-SDysw9wx.d.cts → transform-DFCPKX7e.d.cts} +2 -1
- package/dist/{transform-DRr76JEu.d.ts → transform-DPliWQuD.d.ts} +2 -1
- package/dist/typed/draw/embedded.cjs +1 -1
- package/dist/typed/draw/embedded.js +1 -1
- package/dist/typed/draw/shapes.cjs +7 -2
- package/dist/typed/draw/shapes.d.cts +1 -1
- package/dist/typed/draw/shapes.d.ts +1 -1
- package/dist/typed/draw/shapes.js +7 -2
- package/dist/typed/draw/write-shapes.cjs +210 -0
- package/dist/typed/draw/write-shapes.d.cts +2 -0
- package/dist/typed/draw/write-shapes.d.ts +2 -0
- package/dist/typed/draw/write-shapes.js +203 -0
- package/dist/typed/draw/write-vectors.cjs +132 -0
- package/dist/typed/draw/write-vectors.d.cts +2 -0
- package/dist/typed/draw/write-vectors.d.ts +2 -0
- package/dist/typed/draw/write-vectors.js +129 -0
- package/dist/typed/odb/form.cjs +1 -1
- package/dist/typed/odb/form.js +1 -1
- package/dist/typed/odg/write.cjs +80 -0
- package/dist/typed/odg/write.d.cts +2 -0
- package/dist/typed/odg/write.d.ts +2 -0
- package/dist/typed/odg/write.js +77 -0
- package/dist/typed/odp/write.cjs +108 -0
- package/dist/typed/odp/write.d.cts +2 -0
- package/dist/typed/odp/write.d.ts +2 -0
- package/dist/typed/odp/write.js +105 -0
- package/dist/typed/ods/read.cjs +3 -1
- package/dist/typed/ods/read.d.cts +2 -2
- package/dist/typed/ods/read.d.ts +2 -2
- package/dist/typed/ods/read.js +2 -2
- package/dist/typed/ods/write.cjs +578 -0
- package/dist/typed/ods/write.d.cts +2 -0
- package/dist/typed/ods/write.d.ts +2 -0
- package/dist/typed/ods/write.js +575 -0
- package/dist/typed/odt/read.cjs +1 -1
- package/dist/typed/odt/read.js +1 -1
- package/dist/typed/odt/write.cjs +278 -0
- package/dist/typed/odt/write.d.cts +2 -0
- package/dist/typed/odt/write.d.ts +2 -0
- package/dist/typed/odt/write.js +275 -0
- package/dist/typed/shared/canonicalise.cjs +126 -0
- package/dist/typed/shared/canonicalise.d.cts +10 -0
- package/dist/typed/shared/canonicalise.d.ts +10 -0
- package/dist/typed/shared/canonicalise.js +120 -0
- package/dist/typed/shared/cascade.d.cts +1 -1
- package/dist/typed/shared/cascade.d.ts +1 -1
- package/dist/typed/shared/list.cjs +81 -0
- package/dist/typed/shared/list.d.cts +2 -2
- package/dist/typed/shared/list.d.ts +2 -2
- package/dist/typed/shared/list.js +75 -1
- package/dist/typed/shared/metadata.cjs +41 -0
- package/dist/typed/shared/metadata.d.cts +2 -2
- package/dist/typed/shared/metadata.d.ts +2 -2
- package/dist/typed/shared/metadata.js +41 -2
- package/dist/typed/shared/paragraph.cjs +118 -2
- package/dist/typed/shared/paragraph.d.cts +2 -2
- package/dist/typed/shared/paragraph.d.ts +2 -2
- package/dist/typed/shared/paragraph.js +117 -5
- package/dist/typed/shared/path.cjs +19 -0
- package/dist/typed/shared/path.d.cts +2 -2
- package/dist/typed/shared/path.d.ts +2 -2
- package/dist/typed/shared/path.js +18 -1
- package/dist/typed/shared/table.cjs +84 -0
- package/dist/typed/shared/table.d.cts +2 -2
- package/dist/typed/shared/table.d.ts +2 -2
- package/dist/typed/shared/table.js +84 -4
- package/dist/typed/shared/text.cjs +60 -0
- package/dist/typed/shared/text.d.cts +2 -2
- package/dist/typed/shared/text.d.ts +2 -2
- package/dist/typed/shared/text.js +60 -2
- package/dist/typed/shared/units.cjs +16 -1
- package/dist/typed/shared/units.d.cts +2 -2
- package/dist/typed/shared/units.d.ts +2 -2
- package/dist/typed/shared/units.js +16 -2
- package/dist/{units-BQSNkTQZ.d.cts → units-DdyaQolR.d.cts} +2 -1
- package/dist/{units-BQSNkTQZ.d.ts → units-DdyaQolR.d.ts} +2 -1
- package/dist/write-4kMi-asu.d.ts +14 -0
- package/dist/write-BZXpT8F6.d.cts +17 -0
- package/dist/write-BhG3t3fJ.d.cts +14 -0
- package/dist/write-BuLQmwLD.d.cts +14 -0
- package/dist/write-C2c4xBXs.d.cts +14 -0
- package/dist/write-CPATqG4v.d.cts +14 -0
- package/dist/write-CfTE2jY8.d.ts +14 -0
- package/dist/write-DttX1rTC.d.ts +14 -0
- package/dist/write-JERychL3.d.ts +14 -0
- package/dist/write-SKnCTU4C.d.ts +17 -0
- package/dist/write-shapes-Co7BrmMZ.d.ts +36 -0
- package/dist/write-shapes-D4piGKf4.d.cts +36 -0
- package/dist/write-vectors-B-RVHAKI.d.cts +11 -0
- package/dist/write-vectors-CYjZoVBW.d.ts +11 -0
- package/package.json +2 -2
- package/dist/list-DwTyo_B2.d.cts +0 -13
- package/dist/list-X_GJY7P3.d.ts +0 -13
- package/dist/metadata-01SgHkRR.d.cts +0 -7
- package/dist/metadata-D1SOBTh8.d.ts +0 -7
- package/dist/paragraph-ByTzS8Li.d.ts +0 -18
- package/dist/paragraph-CVULactG.d.cts +0 -18
- package/dist/table-CYvFMlP6.d.cts +0 -14
- package/dist/table-DclDgC5h.d.ts +0 -14
- package/dist/text-Bn3C7lnm.d.ts +0 -10
- package/dist/text-CDUCcwje.d.cts +0 -10
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { l as XmlElement } from "./node-B6JX5CRX.js";
|
|
1
2
|
import { r as Package } from "./package-otZYrxiO.js";
|
|
2
3
|
import { n as StyleProperties } from "./properties-CJyykyc_.js";
|
|
3
4
|
//#region src/styles/registry.d.ts
|
|
@@ -8,6 +9,7 @@ interface InternRequest {
|
|
|
8
9
|
properties: StyleProperties;
|
|
9
10
|
family: StyleFamily;
|
|
10
11
|
parentStyleName?: string;
|
|
12
|
+
propertyElements?: readonly XmlElement[];
|
|
11
13
|
}
|
|
12
14
|
interface OtherPartRef {
|
|
13
15
|
pkg: Package;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { l as XmlElement } from "./node-B6JX5CRX.cjs";
|
|
1
2
|
import { r as Package } from "./package-DMk9fuTI.cjs";
|
|
2
3
|
import { n as StyleProperties } from "./properties-CiIoNu2h.cjs";
|
|
3
4
|
//#region src/styles/registry.d.ts
|
|
@@ -8,6 +9,7 @@ interface InternRequest {
|
|
|
8
9
|
properties: StyleProperties;
|
|
9
10
|
family: StyleFamily;
|
|
10
11
|
parentStyleName?: string;
|
|
12
|
+
propertyElements?: readonly XmlElement[];
|
|
11
13
|
}
|
|
12
14
|
interface OtherPartRef {
|
|
13
15
|
pkg: Package;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { l as XmlElement } from "./node-B6JX5CRX.cjs";
|
|
2
|
+
import { r as Package } from "./package-DMk9fuTI.cjs";
|
|
3
|
+
//#region src/package-io/scaffold.d.ts
|
|
4
|
+
declare const DEFAULT_ODF_VERSION = "1.3";
|
|
5
|
+
declare function createOdfPackage(mediaType: string, bodyElement: XmlElement, version?: string): Package;
|
|
6
|
+
declare function odfPartContainer(pkg: Package, partPath: string, containerTag: string): XmlElement;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { createOdfPackage as n, odfPartContainer as r, DEFAULT_ODF_VERSION as t };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { l as XmlElement } from "./node-B6JX5CRX.js";
|
|
2
|
+
import { r as Package } from "./package-otZYrxiO.js";
|
|
3
|
+
//#region src/package-io/scaffold.d.ts
|
|
4
|
+
declare const DEFAULT_ODF_VERSION = "1.3";
|
|
5
|
+
declare function createOdfPackage(mediaType: string, bodyElement: XmlElement, version?: string): Package;
|
|
6
|
+
declare function odfPartContainer(pkg: Package, partPath: string, containerTag: string): XmlElement;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { createOdfPackage as n, odfPartContainer as r, DEFAULT_ODF_VERSION as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { d as XmlNode, l as XmlElement } from "./node-B6JX5CRX.js";
|
|
2
2
|
import { r as Package } from "./package-otZYrxiO.js";
|
|
3
|
-
import {
|
|
3
|
+
import { i as OdfListIdState } from "./list-7FO0SDqZ.js";
|
|
4
4
|
import { r as OdfTransformFunction } from "./transform-BFNc16LQ.js";
|
|
5
5
|
import { Box, ContentImageBlock, ContentShape, ContentVector } from "document-schema.js";
|
|
6
6
|
//#region src/typed/draw/shapes.d.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { d as XmlNode, l as XmlElement } from "./node-B6JX5CRX.cjs";
|
|
2
2
|
import { r as Package } from "./package-DMk9fuTI.cjs";
|
|
3
|
-
import {
|
|
3
|
+
import { i as OdfListIdState } from "./list-BorrTJBY.cjs";
|
|
4
4
|
import { r as OdfTransformFunction } from "./transform-M1gbHp4j.cjs";
|
|
5
5
|
import { Box, ContentImageBlock, ContentShape, ContentVector } from "document-schema.js";
|
|
6
6
|
//#region src/typed/draw/shapes.d.ts
|
|
@@ -110,7 +110,7 @@ function parseTextProperties(element) {
|
|
|
110
110
|
if (strike === "unknown") hasUnknown = true;
|
|
111
111
|
else if (strike !== void 0) properties.strike = strike;
|
|
112
112
|
const fontFamily = attrs.get(ATTR.fontFamily);
|
|
113
|
-
if (fontFamily !== void 0) properties.fontFamily = fontFamily;
|
|
113
|
+
if (fontFamily !== void 0) properties.fontFamily = require_xml_entities.decodeXmlText(fontFamily);
|
|
114
114
|
const fontSize = attrs.get(ATTR.fontSize);
|
|
115
115
|
if (fontSize !== void 0) {
|
|
116
116
|
const pt = require_typed_shared_units.parseOdfLength(fontSize);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { encodeXmlText } from "../xml/entities.js";
|
|
1
|
+
import { decodeXmlText, encodeXmlText } from "../xml/entities.js";
|
|
2
2
|
import { formatOdfLength, parseOdfLength } from "../typed/shared/units.js";
|
|
3
3
|
import { formatOdfColor, parseOdfColor } from "../typed/shared/color.js";
|
|
4
4
|
import { z } from "zod";
|
|
@@ -109,7 +109,7 @@ function parseTextProperties(element) {
|
|
|
109
109
|
if (strike === "unknown") hasUnknown = true;
|
|
110
110
|
else if (strike !== void 0) properties.strike = strike;
|
|
111
111
|
const fontFamily = attrs.get(ATTR.fontFamily);
|
|
112
|
-
if (fontFamily !== void 0) properties.fontFamily = fontFamily;
|
|
112
|
+
if (fontFamily !== void 0) properties.fontFamily = decodeXmlText(fontFamily);
|
|
113
113
|
const fontSize = attrs.get(ATTR.fontSize);
|
|
114
114
|
if (fontSize !== void 0) {
|
|
115
115
|
const pt = parseOdfLength(fontSize);
|
package/dist/styles/registry.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_xml_build = require("../xml/build.cjs");
|
|
2
3
|
const require_xml_fragment = require("../xml/fragment.cjs");
|
|
3
4
|
const require_xml_entities = require("../xml/entities.cjs");
|
|
4
5
|
const require_styles_properties = require("./properties.cjs");
|
|
@@ -87,13 +88,15 @@ function reserveStyleNames(container, reserved) {
|
|
|
87
88
|
}
|
|
88
89
|
const FINGERPRINT_SEPARATOR = "\0";
|
|
89
90
|
const NO_PARENT_SENTINEL = "";
|
|
90
|
-
function computeFingerprint(family, properties, parentStyleName) {
|
|
91
|
+
function computeFingerprint(family, properties, parentStyleName, propertyElements) {
|
|
91
92
|
const parentComponent = parentStyleName ?? NO_PARENT_SENTINEL;
|
|
92
|
-
|
|
93
|
+
const components = [
|
|
93
94
|
family,
|
|
94
95
|
require_styles_serialize.canonicalPropertiesString(properties),
|
|
95
96
|
parentComponent
|
|
96
|
-
]
|
|
97
|
+
];
|
|
98
|
+
if (propertyElements !== void 0 && propertyElements.length > 0) components.push(require_xml_build.buildXml([...propertyElements]));
|
|
99
|
+
return components.join(FINGERPRINT_SEPARATOR);
|
|
97
100
|
}
|
|
98
101
|
var StyleRegistry = class StyleRegistry {
|
|
99
102
|
automaticStyles;
|
|
@@ -134,7 +137,7 @@ var StyleRegistry = class StyleRegistry {
|
|
|
134
137
|
const parsed = require_styles_properties.parseStyleElementProperties(child);
|
|
135
138
|
if (!parsed.hasUnknown) {
|
|
136
139
|
const parentStyleName = attrValue(child, "style:parent-style-name");
|
|
137
|
-
const fingerprint = computeFingerprint(family, parsed.properties, parentStyleName);
|
|
140
|
+
const fingerprint = computeFingerprint(family, parsed.properties, parentStyleName, void 0);
|
|
138
141
|
if (!registry.fingerprintToName.has(fingerprint)) {
|
|
139
142
|
registry.fingerprintToName.set(fingerprint, name);
|
|
140
143
|
registry.nameToFingerprint.set(name, fingerprint);
|
|
@@ -157,7 +160,7 @@ var StyleRegistry = class StyleRegistry {
|
|
|
157
160
|
return registry;
|
|
158
161
|
}
|
|
159
162
|
fingerprint(request) {
|
|
160
|
-
return computeFingerprint(request.family, request.properties, request.parentStyleName);
|
|
163
|
+
return computeFingerprint(request.family, request.properties, request.parentStyleName, request.propertyElements);
|
|
161
164
|
}
|
|
162
165
|
intern(request) {
|
|
163
166
|
const fingerprint = this.fingerprint(request);
|
|
@@ -169,7 +172,7 @@ var StyleRegistry = class StyleRegistry {
|
|
|
169
172
|
"style:family": request.family
|
|
170
173
|
};
|
|
171
174
|
if (request.parentStyleName !== void 0) attributes["style:parent-style-name"] = require_xml_entities.encodeXmlText(request.parentStyleName);
|
|
172
|
-
const styleElement = require_xml_fragment.el("style:style", attributes, require_styles_serialize.buildStylePropertyElements(request.properties));
|
|
175
|
+
const styleElement = require_xml_fragment.el("style:style", attributes, [...require_styles_serialize.buildStylePropertyElements(request.properties), ...request.propertyElements ?? []]);
|
|
173
176
|
this.automaticStyles.children.push(styleElement);
|
|
174
177
|
this.knownStyles.set(name, styleElement);
|
|
175
178
|
this.reservedByFamily[request.family].add(name);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as StyleRegistry, i as StyleFamily, n as OtherPartRef, o as StyleRegistryOptions, r as STYLE_FAMILIES, s as isStyleFamily, t as InternRequest } from "../registry-
|
|
1
|
+
import { a as StyleRegistry, i as StyleFamily, n as OtherPartRef, o as StyleRegistryOptions, r as STYLE_FAMILIES, s as isStyleFamily, t as InternRequest } from "../registry-PoQIRgbY.cjs";
|
|
2
2
|
export { InternRequest, OtherPartRef, STYLE_FAMILIES, StyleFamily, StyleRegistry, StyleRegistryOptions, isStyleFamily };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as StyleRegistry, i as StyleFamily, n as OtherPartRef, o as StyleRegistryOptions, r as STYLE_FAMILIES, s as isStyleFamily, t as InternRequest } from "../registry-
|
|
1
|
+
import { a as StyleRegistry, i as StyleFamily, n as OtherPartRef, o as StyleRegistryOptions, r as STYLE_FAMILIES, s as isStyleFamily, t as InternRequest } from "../registry-C_16-N6i.js";
|
|
2
2
|
export { InternRequest, OtherPartRef, STYLE_FAMILIES, StyleFamily, StyleRegistry, StyleRegistryOptions, isStyleFamily };
|
package/dist/styles/registry.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { buildXml } from "../xml/build.js";
|
|
1
2
|
import { el } from "../xml/fragment.js";
|
|
2
3
|
import { encodeXmlText } from "../xml/entities.js";
|
|
3
4
|
import { parseStyleElementProperties } from "./properties.js";
|
|
@@ -86,13 +87,15 @@ function reserveStyleNames(container, reserved) {
|
|
|
86
87
|
}
|
|
87
88
|
const FINGERPRINT_SEPARATOR = "\0";
|
|
88
89
|
const NO_PARENT_SENTINEL = "";
|
|
89
|
-
function computeFingerprint(family, properties, parentStyleName) {
|
|
90
|
+
function computeFingerprint(family, properties, parentStyleName, propertyElements) {
|
|
90
91
|
const parentComponent = parentStyleName ?? NO_PARENT_SENTINEL;
|
|
91
|
-
|
|
92
|
+
const components = [
|
|
92
93
|
family,
|
|
93
94
|
canonicalPropertiesString(properties),
|
|
94
95
|
parentComponent
|
|
95
|
-
]
|
|
96
|
+
];
|
|
97
|
+
if (propertyElements !== void 0 && propertyElements.length > 0) components.push(buildXml([...propertyElements]));
|
|
98
|
+
return components.join(FINGERPRINT_SEPARATOR);
|
|
96
99
|
}
|
|
97
100
|
var StyleRegistry = class StyleRegistry {
|
|
98
101
|
automaticStyles;
|
|
@@ -133,7 +136,7 @@ var StyleRegistry = class StyleRegistry {
|
|
|
133
136
|
const parsed = parseStyleElementProperties(child);
|
|
134
137
|
if (!parsed.hasUnknown) {
|
|
135
138
|
const parentStyleName = attrValue(child, "style:parent-style-name");
|
|
136
|
-
const fingerprint = computeFingerprint(family, parsed.properties, parentStyleName);
|
|
139
|
+
const fingerprint = computeFingerprint(family, parsed.properties, parentStyleName, void 0);
|
|
137
140
|
if (!registry.fingerprintToName.has(fingerprint)) {
|
|
138
141
|
registry.fingerprintToName.set(fingerprint, name);
|
|
139
142
|
registry.nameToFingerprint.set(name, fingerprint);
|
|
@@ -156,7 +159,7 @@ var StyleRegistry = class StyleRegistry {
|
|
|
156
159
|
return registry;
|
|
157
160
|
}
|
|
158
161
|
fingerprint(request) {
|
|
159
|
-
return computeFingerprint(request.family, request.properties, request.parentStyleName);
|
|
162
|
+
return computeFingerprint(request.family, request.properties, request.parentStyleName, request.propertyElements);
|
|
160
163
|
}
|
|
161
164
|
intern(request) {
|
|
162
165
|
const fingerprint = this.fingerprint(request);
|
|
@@ -168,7 +171,7 @@ var StyleRegistry = class StyleRegistry {
|
|
|
168
171
|
"style:family": request.family
|
|
169
172
|
};
|
|
170
173
|
if (request.parentStyleName !== void 0) attributes["style:parent-style-name"] = encodeXmlText(request.parentStyleName);
|
|
171
|
-
const styleElement = el("style:style", attributes, buildStylePropertyElements(request.properties));
|
|
174
|
+
const styleElement = el("style:style", attributes, [...buildStylePropertyElements(request.properties), ...request.propertyElements ?? []]);
|
|
172
175
|
this.automaticStyles.children.push(styleElement);
|
|
173
176
|
this.knownStyles.set(name, styleElement);
|
|
174
177
|
this.reservedByFamily[request.family].add(name);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { l as XmlElement } from "./node-B6JX5CRX.cjs";
|
|
2
|
+
import { r as Package } from "./package-DMk9fuTI.cjs";
|
|
3
|
+
import { a as StyleRegistry } from "./registry-PoQIRgbY.cjs";
|
|
4
|
+
import { Alignment, Color, ContentBorder, ContentCellBorders, ContentTable } from "document-schema.js";
|
|
5
|
+
//#region src/typed/shared/table.d.ts
|
|
6
|
+
type BorderEdgeKey = "left" | "right" | "top" | "bottom";
|
|
7
|
+
declare const BORDER_EDGE_KEYS: readonly BorderEdgeKey[];
|
|
8
|
+
declare const BORDER_EDGE_ATTRS: Readonly<Record<BorderEdgeKey, string>>;
|
|
9
|
+
interface CellStyleDecoration {
|
|
10
|
+
background?: Color;
|
|
11
|
+
borders?: ContentCellBorders;
|
|
12
|
+
alignment?: Alignment;
|
|
13
|
+
verticalAlignment?: "top" | "middle" | "bottom";
|
|
14
|
+
}
|
|
15
|
+
declare function readCellStyleDecoration(elements: readonly XmlElement[]): CellStyleDecoration;
|
|
16
|
+
declare function formatBorderEdge(border: ContentBorder): string;
|
|
17
|
+
declare function writeOdfTable(table: ContentTable, registry: StyleRegistry, tableName: string): XmlElement;
|
|
18
|
+
declare function readOdfTable(tableElement: XmlElement, pkg: Package): ContentTable;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { formatBorderEdge as a, writeOdfTable as c, CellStyleDecoration as i, BORDER_EDGE_KEYS as n, readCellStyleDecoration as o, BorderEdgeKey as r, readOdfTable as s, BORDER_EDGE_ATTRS as t };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { l as XmlElement } from "./node-B6JX5CRX.js";
|
|
2
|
+
import { r as Package } from "./package-otZYrxiO.js";
|
|
3
|
+
import { a as StyleRegistry } from "./registry-C_16-N6i.js";
|
|
4
|
+
import { Alignment, Color, ContentBorder, ContentCellBorders, ContentTable } from "document-schema.js";
|
|
5
|
+
//#region src/typed/shared/table.d.ts
|
|
6
|
+
type BorderEdgeKey = "left" | "right" | "top" | "bottom";
|
|
7
|
+
declare const BORDER_EDGE_KEYS: readonly BorderEdgeKey[];
|
|
8
|
+
declare const BORDER_EDGE_ATTRS: Readonly<Record<BorderEdgeKey, string>>;
|
|
9
|
+
interface CellStyleDecoration {
|
|
10
|
+
background?: Color;
|
|
11
|
+
borders?: ContentCellBorders;
|
|
12
|
+
alignment?: Alignment;
|
|
13
|
+
verticalAlignment?: "top" | "middle" | "bottom";
|
|
14
|
+
}
|
|
15
|
+
declare function readCellStyleDecoration(elements: readonly XmlElement[]): CellStyleDecoration;
|
|
16
|
+
declare function formatBorderEdge(border: ContentBorder): string;
|
|
17
|
+
declare function writeOdfTable(table: ContentTable, registry: StyleRegistry, tableName: string): XmlElement;
|
|
18
|
+
declare function readOdfTable(tableElement: XmlElement, pkg: Package): ContentTable;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { formatBorderEdge as a, writeOdfTable as c, CellStyleDecoration as i, BORDER_EDGE_KEYS as n, readCellStyleDecoration as o, BorderEdgeKey as r, readOdfTable as s, BORDER_EDGE_ATTRS as t };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { d as XmlNode, l as XmlElement } from "./node-B6JX5CRX.js";
|
|
2
|
+
//#region src/typed/shared/text.d.ts
|
|
3
|
+
declare const ODF_FIELD_TAGS: ReadonlySet<string>;
|
|
4
|
+
declare function isOdfFieldElement(element: XmlElement): boolean;
|
|
5
|
+
declare function getOdfSpaceCount(element: XmlElement): number;
|
|
6
|
+
declare function measureOdfNodeLength(node: XmlNode): number;
|
|
7
|
+
declare function sumOdfNodeLength(nodes: readonly XmlNode[]): number;
|
|
8
|
+
declare function decodeOdfText(container: XmlElement): string;
|
|
9
|
+
type OdfTextSegmentKind = "text" | "space" | "tab" | "lineBreak";
|
|
10
|
+
interface OdfTextSegment {
|
|
11
|
+
readonly kind: OdfTextSegmentKind;
|
|
12
|
+
readonly text: string;
|
|
13
|
+
}
|
|
14
|
+
declare function segmentOdfText(text: string, protectLeading: boolean, protectTrailing: boolean): OdfTextSegment[];
|
|
15
|
+
declare function buildOdfInlineNodes(segments: readonly OdfTextSegment[]): XmlNode[];
|
|
16
|
+
//#endregion
|
|
17
|
+
export { decodeOdfText as a, measureOdfNodeLength as c, buildOdfInlineNodes as i, segmentOdfText as l, OdfTextSegment as n, getOdfSpaceCount as o, OdfTextSegmentKind as r, isOdfFieldElement as s, ODF_FIELD_TAGS as t, sumOdfNodeLength as u };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { d as XmlNode, l as XmlElement } from "./node-B6JX5CRX.cjs";
|
|
2
|
+
//#region src/typed/shared/text.d.ts
|
|
3
|
+
declare const ODF_FIELD_TAGS: ReadonlySet<string>;
|
|
4
|
+
declare function isOdfFieldElement(element: XmlElement): boolean;
|
|
5
|
+
declare function getOdfSpaceCount(element: XmlElement): number;
|
|
6
|
+
declare function measureOdfNodeLength(node: XmlNode): number;
|
|
7
|
+
declare function sumOdfNodeLength(nodes: readonly XmlNode[]): number;
|
|
8
|
+
declare function decodeOdfText(container: XmlElement): string;
|
|
9
|
+
type OdfTextSegmentKind = "text" | "space" | "tab" | "lineBreak";
|
|
10
|
+
interface OdfTextSegment {
|
|
11
|
+
readonly kind: OdfTextSegmentKind;
|
|
12
|
+
readonly text: string;
|
|
13
|
+
}
|
|
14
|
+
declare function segmentOdfText(text: string, protectLeading: boolean, protectTrailing: boolean): OdfTextSegment[];
|
|
15
|
+
declare function buildOdfInlineNodes(segments: readonly OdfTextSegment[]): XmlNode[];
|
|
16
|
+
//#endregion
|
|
17
|
+
export { decodeOdfText as a, measureOdfNodeLength as c, buildOdfInlineNodes as i, segmentOdfText as l, OdfTextSegment as n, getOdfSpaceCount as o, OdfTextSegmentKind as r, isOdfFieldElement as s, ODF_FIELD_TAGS as t, sumOdfNodeLength as u };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { r as Package } from "./package-DMk9fuTI.cjs";
|
|
2
2
|
//#region src/ooo1/transform.d.ts
|
|
3
3
|
declare function transformOoo1Package(pkg: Package): Package;
|
|
4
|
+
declare function transformToOoo1Package(pkg: Package): Package;
|
|
4
5
|
//#endregion
|
|
5
|
-
export { transformOoo1Package as t };
|
|
6
|
+
export { transformToOoo1Package as n, transformOoo1Package as t };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { r as Package } from "./package-otZYrxiO.js";
|
|
2
2
|
//#region src/ooo1/transform.d.ts
|
|
3
3
|
declare function transformOoo1Package(pkg: Package): Package;
|
|
4
|
+
declare function transformToOoo1Package(pkg: Package): Package;
|
|
4
5
|
//#endregion
|
|
5
|
-
export { transformOoo1Package as t };
|
|
6
|
+
export { transformToOoo1Package as n, transformOoo1Package as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_embedded = require("../../embedded-
|
|
2
|
+
const require_embedded = require("../../embedded-Bxyss_ck.cjs");
|
|
3
3
|
exports.readDrawObjectReference = require_embedded.readDrawObjectReference;
|
|
4
4
|
exports.readEmbeddedObjectDocument = require_embedded.readEmbeddedObjectDocument;
|
|
5
5
|
exports.readOdfChartContent = require_embedded.readOdfChartContent;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as readEmbeddedObjectDocument, r as readOdfChartContent, t as readDrawObjectReference } from "../../embedded-
|
|
1
|
+
import { n as readEmbeddedObjectDocument, r as readOdfChartContent, t as readDrawObjectReference } from "../../embedded-BnavfkP-.js";
|
|
2
2
|
export { readDrawObjectReference, readEmbeddedObjectDocument, readOdfChartContent };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_util_base64 = require("../../util/base64.cjs");
|
|
3
3
|
const require_image_sniff = require("../../image/sniff.cjs");
|
|
4
|
+
const require_xml_entities = require("../../xml/entities.cjs");
|
|
4
5
|
const require_typed_shared_units = require("../shared/units.cjs");
|
|
5
6
|
const require_typed_shared_color = require("../shared/color.cjs");
|
|
6
7
|
const require_xml_query = require("../../xml/query.cjs");
|
|
@@ -40,6 +41,10 @@ function readFrameInsets(frame, pkg) {
|
|
|
40
41
|
}
|
|
41
42
|
return insets;
|
|
42
43
|
}
|
|
44
|
+
function readDrawName(element) {
|
|
45
|
+
const raw = require_xml_query.attrValue(element, "draw:name");
|
|
46
|
+
return raw === void 0 ? void 0 : require_xml_entities.decodeXmlText(raw);
|
|
47
|
+
}
|
|
43
48
|
function readFrameAltText(frame) {
|
|
44
49
|
const title = require_xml_query.childrenWithTag(frame, "svg:title")[0];
|
|
45
50
|
const decodedTitle = title === void 0 ? void 0 : require_typed_shared_text.decodeOdfText(title);
|
|
@@ -97,7 +102,7 @@ function readDrawFrame(frame, groupFunctions, pkg, listIdState = { next: 1 }, fl
|
|
|
97
102
|
if (ownGeometry === void 0) return;
|
|
98
103
|
const geometry = require_typed_shared_transform.composeOdfGroupTransform(groupFunctions, ownGeometry);
|
|
99
104
|
return {
|
|
100
|
-
name:
|
|
105
|
+
name: readDrawName(frame),
|
|
101
106
|
frame: geometry.frame,
|
|
102
107
|
rotationDeg: geometry.rotationDeg,
|
|
103
108
|
...readFrameInsets(frame, pkg),
|
|
@@ -287,7 +292,7 @@ function readCustomShapeAsTextShape(element, groupFunctions, pkg) {
|
|
|
287
292
|
const geometry = require_typed_shared_transform.composeOdfGroupTransform(groupFunctions, ownGeometry);
|
|
288
293
|
const enhancedGeometry = require_xml_query.childrenWithTag(element, "draw:enhanced-geometry")[0];
|
|
289
294
|
return {
|
|
290
|
-
name:
|
|
295
|
+
name: readDrawName(element),
|
|
291
296
|
frame: geometry.frame,
|
|
292
297
|
rotationDeg: geometry.rotationDeg,
|
|
293
298
|
...readFrameInsets(element, pkg),
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as walkDrawShapes, i as readDrawPageContent, n as readDrawFrame, r as readDrawImageBlock, t as DrawPageContent } from "../../shapes-
|
|
1
|
+
import { a as walkDrawShapes, i as readDrawPageContent, n as readDrawFrame, r as readDrawImageBlock, t as DrawPageContent } from "../../shapes-CbBc9t0y.cjs";
|
|
2
2
|
export { DrawPageContent, readDrawFrame, readDrawImageBlock, readDrawPageContent, walkDrawShapes };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as walkDrawShapes, i as readDrawPageContent, n as readDrawFrame, r as readDrawImageBlock, t as DrawPageContent } from "../../shapes-
|
|
1
|
+
import { a as walkDrawShapes, i as readDrawPageContent, n as readDrawFrame, r as readDrawImageBlock, t as DrawPageContent } from "../../shapes-B6Ms7ibr.js";
|
|
2
2
|
export { DrawPageContent, readDrawFrame, readDrawImageBlock, readDrawPageContent, walkDrawShapes };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { base64ToBytes } from "../../util/base64.js";
|
|
2
2
|
import { sniffImageFormat } from "../../image/sniff.js";
|
|
3
|
+
import { decodeXmlText } from "../../xml/entities.js";
|
|
3
4
|
import { parseOdfLength } from "../shared/units.js";
|
|
4
5
|
import { parseOdfColor } from "../shared/color.js";
|
|
5
6
|
import { attrValue, childrenWithTag, elementsWithTag } from "../../xml/query.js";
|
|
@@ -39,6 +40,10 @@ function readFrameInsets(frame, pkg) {
|
|
|
39
40
|
}
|
|
40
41
|
return insets;
|
|
41
42
|
}
|
|
43
|
+
function readDrawName(element) {
|
|
44
|
+
const raw = attrValue(element, "draw:name");
|
|
45
|
+
return raw === void 0 ? void 0 : decodeXmlText(raw);
|
|
46
|
+
}
|
|
42
47
|
function readFrameAltText(frame) {
|
|
43
48
|
const title = childrenWithTag(frame, "svg:title")[0];
|
|
44
49
|
const decodedTitle = title === void 0 ? void 0 : decodeOdfText(title);
|
|
@@ -96,7 +101,7 @@ function readDrawFrame(frame, groupFunctions, pkg, listIdState = { next: 1 }, fl
|
|
|
96
101
|
if (ownGeometry === void 0) return;
|
|
97
102
|
const geometry = composeOdfGroupTransform(groupFunctions, ownGeometry);
|
|
98
103
|
return {
|
|
99
|
-
name:
|
|
104
|
+
name: readDrawName(frame),
|
|
100
105
|
frame: geometry.frame,
|
|
101
106
|
rotationDeg: geometry.rotationDeg,
|
|
102
107
|
...readFrameInsets(frame, pkg),
|
|
@@ -286,7 +291,7 @@ function readCustomShapeAsTextShape(element, groupFunctions, pkg) {
|
|
|
286
291
|
const geometry = composeOdfGroupTransform(groupFunctions, ownGeometry);
|
|
287
292
|
const enhancedGeometry = childrenWithTag(element, "draw:enhanced-geometry")[0];
|
|
288
293
|
return {
|
|
289
|
-
name:
|
|
294
|
+
name: readDrawName(element),
|
|
290
295
|
frame: geometry.frame,
|
|
291
296
|
rotationDeg: geometry.rotationDeg,
|
|
292
297
|
...readFrameInsets(element, pkg),
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_xml_fragment = require("../../xml/fragment.cjs");
|
|
3
|
+
const require_xml_entities = require("../../xml/entities.cjs");
|
|
4
|
+
const require_typed_shared_units = require("../shared/units.cjs");
|
|
5
|
+
const require_typed_shared_list = require("../shared/list.cjs");
|
|
6
|
+
const require_typed_shared_paragraph = require("../shared/paragraph.cjs");
|
|
7
|
+
const require_typed_shared_table = require("../shared/table.cjs");
|
|
8
|
+
const require_typed_shared_canonicalise = require("../shared/canonicalise.cjs");
|
|
9
|
+
//#region src/typed/draw/write-shapes.ts
|
|
10
|
+
function unsupportedShapeContent(what) {
|
|
11
|
+
return /* @__PURE__ */ new Error(`writeDrawFrame: a shape carries ${what}, which this writer does not write yet -- refusing rather than producing a document that silently lost it. See ExaDev/documents.js for the tracked follow-up covering the fidelity constructs.`);
|
|
12
|
+
}
|
|
13
|
+
function planShapeContent(blocks, listState) {
|
|
14
|
+
require_typed_shared_list.closeListPlan(listState);
|
|
15
|
+
if (blocks.length === 1) {
|
|
16
|
+
const only = blocks[0];
|
|
17
|
+
if (only.kind === "table") return {
|
|
18
|
+
kind: "table",
|
|
19
|
+
table: only
|
|
20
|
+
};
|
|
21
|
+
if (only.kind === "image") return {
|
|
22
|
+
kind: "image",
|
|
23
|
+
image: only
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const paragraphs = [];
|
|
27
|
+
for (const block of blocks) {
|
|
28
|
+
if (block.kind === "table") throw unsupportedShapeContent("a table alongside other content (a draw:frame's own content is exactly one of table:table/draw:text-box/draw:image, never a mix)");
|
|
29
|
+
if (block.kind === "image") throw unsupportedShapeContent("an image alongside other content (same reason)");
|
|
30
|
+
if (block.kind === "pageBreak") throw unsupportedShapeContent("a page break (no ODF spelling inside a shape's own text)");
|
|
31
|
+
if (block.kind === "embeddedObject") throw unsupportedShapeContent("an embedded object");
|
|
32
|
+
if (block.kind === "constructStart" || block.kind === "constructEnd") throw unsupportedShapeContent("a construct boundary marker");
|
|
33
|
+
if (block.constructs !== void 0 && block.constructs.length > 0) throw unsupportedShapeContent("a run-level construct extent (a field, bookmark, note, annotation, or tracked change)");
|
|
34
|
+
if (block.headingLevel !== void 0) throw unsupportedShapeContent("a heading (a shape's own draw:text-box has no text:h reading path)");
|
|
35
|
+
const canonicalId = require_typed_shared_list.planListMembership(block.list, listState);
|
|
36
|
+
paragraphs.push(canonicalId === void 0 ? {
|
|
37
|
+
...block,
|
|
38
|
+
list: void 0
|
|
39
|
+
} : {
|
|
40
|
+
...block,
|
|
41
|
+
list: {
|
|
42
|
+
numId: canonicalId,
|
|
43
|
+
level: block.list.level
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
kind: "text",
|
|
49
|
+
paragraphs
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function createDrawShapeWriteState(pkg, registry, contentAutomaticStyles) {
|
|
53
|
+
return {
|
|
54
|
+
pkg,
|
|
55
|
+
registry,
|
|
56
|
+
contentAutomaticStyles,
|
|
57
|
+
nextImage: 1,
|
|
58
|
+
nextTable: 1,
|
|
59
|
+
nextListStyle: 1,
|
|
60
|
+
listStyleByKind: /* @__PURE__ */ new Map()
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function listStyleNameFor(kind, state) {
|
|
64
|
+
const existing = state.listStyleByKind.get(kind);
|
|
65
|
+
if (existing !== void 0) return existing;
|
|
66
|
+
const name = `SL${state.nextListStyle}`;
|
|
67
|
+
state.nextListStyle += 1;
|
|
68
|
+
state.listStyleByKind.set(kind, name);
|
|
69
|
+
state.contentAutomaticStyles.children.push(require_typed_shared_list.buildOdfListStyle(name, kind));
|
|
70
|
+
return name;
|
|
71
|
+
}
|
|
72
|
+
function frameGeometryAttrs(frame, rotationDeg) {
|
|
73
|
+
if (rotationDeg === void 0 || rotationDeg === 0) return {
|
|
74
|
+
"svg:x": require_typed_shared_units.formatOdfLength(frame.xPt),
|
|
75
|
+
"svg:y": require_typed_shared_units.formatOdfLength(frame.yPt),
|
|
76
|
+
"svg:width": require_typed_shared_units.formatOdfLength(frame.widthPt),
|
|
77
|
+
"svg:height": require_typed_shared_units.formatOdfLength(frame.heightPt)
|
|
78
|
+
};
|
|
79
|
+
const angleRad = -rotationDeg * Math.PI / 180;
|
|
80
|
+
const cos = Math.cos(angleRad);
|
|
81
|
+
const sin = Math.sin(angleRad);
|
|
82
|
+
const halfWidthPt = frame.widthPt / 2;
|
|
83
|
+
const halfHeightPt = frame.heightPt / 2;
|
|
84
|
+
const txPt = frame.xPt + halfWidthPt - halfWidthPt * cos - halfHeightPt * sin;
|
|
85
|
+
const tyPt = frame.yPt + halfHeightPt - halfHeightPt * cos + halfWidthPt * sin;
|
|
86
|
+
return {
|
|
87
|
+
"svg:width": require_typed_shared_units.formatOdfLength(frame.widthPt),
|
|
88
|
+
"svg:height": require_typed_shared_units.formatOdfLength(frame.heightPt),
|
|
89
|
+
"draw:transform": `rotate(${require_typed_shared_units.formatOdfNumber(angleRad)}) translate(${require_typed_shared_units.formatOdfLength(txPt)} ${require_typed_shared_units.formatOdfLength(tyPt)})`
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function shapeGraphicStyleName(shape, state) {
|
|
93
|
+
const properties = {
|
|
94
|
+
"draw:fill": "none",
|
|
95
|
+
"draw:stroke": "none"
|
|
96
|
+
};
|
|
97
|
+
if (shape.insetLeftPt !== 0 || shape.insetTopPt !== 0 || shape.insetRightPt !== 0 || shape.insetBottomPt !== 0) {
|
|
98
|
+
properties["fo:padding-left"] = require_typed_shared_units.formatOdfLength(shape.insetLeftPt);
|
|
99
|
+
properties["fo:padding-top"] = require_typed_shared_units.formatOdfLength(shape.insetTopPt);
|
|
100
|
+
properties["fo:padding-right"] = require_typed_shared_units.formatOdfLength(shape.insetRightPt);
|
|
101
|
+
properties["fo:padding-bottom"] = require_typed_shared_units.formatOdfLength(shape.insetBottomPt);
|
|
102
|
+
}
|
|
103
|
+
return state.registry.intern({
|
|
104
|
+
properties: {},
|
|
105
|
+
family: "graphic",
|
|
106
|
+
propertyElements: [require_xml_fragment.el("style:graphic-properties", properties)]
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function writeShapeTextBox(paragraphs, state) {
|
|
110
|
+
const out = [];
|
|
111
|
+
let openList;
|
|
112
|
+
const closeList = () => {
|
|
113
|
+
if (openList === void 0) return;
|
|
114
|
+
const kind = require_typed_shared_list.listKindOf(openList.numId);
|
|
115
|
+
const built = require_typed_shared_list.writeOdfList(openList.entries, kind === void 0 ? void 0 : listStyleNameFor(kind, state));
|
|
116
|
+
openList.element.attributes = built.attributes;
|
|
117
|
+
openList.element.children = built.children;
|
|
118
|
+
openList = void 0;
|
|
119
|
+
};
|
|
120
|
+
for (const paragraph of paragraphs) {
|
|
121
|
+
const element = require_typed_shared_paragraph.writeOdfParagraph(paragraph, state.registry);
|
|
122
|
+
const membership = paragraph.list;
|
|
123
|
+
if (membership?.numId === void 0) {
|
|
124
|
+
closeList();
|
|
125
|
+
out.push(element);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (openList !== void 0 && openList.numId !== membership.numId) closeList();
|
|
129
|
+
if (openList === void 0) {
|
|
130
|
+
const listElement = require_xml_fragment.el("text:list");
|
|
131
|
+
openList = {
|
|
132
|
+
numId: membership.numId,
|
|
133
|
+
entries: [],
|
|
134
|
+
element: listElement
|
|
135
|
+
};
|
|
136
|
+
out.push(listElement);
|
|
137
|
+
}
|
|
138
|
+
openList.entries.push({
|
|
139
|
+
level: membership.level,
|
|
140
|
+
element
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
closeList();
|
|
144
|
+
return require_xml_fragment.el("draw:text-box", {}, out);
|
|
145
|
+
}
|
|
146
|
+
const PICTURES_DIRECTORY = "Pictures";
|
|
147
|
+
function writeShapeImage(image, state) {
|
|
148
|
+
const extension = image.format === "png" ? "png" : "jpg";
|
|
149
|
+
const path = `${PICTURES_DIRECTORY}/image${state.nextImage}.${extension}`;
|
|
150
|
+
state.nextImage += 1;
|
|
151
|
+
state.pkg.parts[path] = {
|
|
152
|
+
kind: "binary",
|
|
153
|
+
base64: image.base64
|
|
154
|
+
};
|
|
155
|
+
const children = [require_xml_fragment.el("draw:image", {
|
|
156
|
+
"xlink:href": require_xml_entities.encodeXmlText(path),
|
|
157
|
+
"xlink:type": "simple",
|
|
158
|
+
"xlink:show": "embed",
|
|
159
|
+
"xlink:actuate": "onLoad"
|
|
160
|
+
})];
|
|
161
|
+
if (image.altText !== void 0) children.push(require_xml_fragment.el("svg:title", {}, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(image.altText))]));
|
|
162
|
+
return children;
|
|
163
|
+
}
|
|
164
|
+
function odfZIndexOf(paintOrder) {
|
|
165
|
+
if (paintOrder === void 0 || !Number.isSafeInteger(paintOrder) || paintOrder < 0) return;
|
|
166
|
+
return paintOrder;
|
|
167
|
+
}
|
|
168
|
+
function writeDrawFrame(shape, listState, state, documentIndex) {
|
|
169
|
+
const zIndex = odfZIndexOf(shape.paintOrder) ?? documentIndex;
|
|
170
|
+
const attributes = {
|
|
171
|
+
"draw:z-index": String(zIndex),
|
|
172
|
+
...frameGeometryAttrs(shape.frame, shape.rotationDeg)
|
|
173
|
+
};
|
|
174
|
+
if (shape.name !== void 0) attributes["draw:name"] = require_xml_entities.encodeXmlText(shape.name);
|
|
175
|
+
attributes["draw:style-name"] = require_xml_entities.encodeXmlText(shapeGraphicStyleName(shape, state));
|
|
176
|
+
const content = planShapeContent(shape.blocks, listState);
|
|
177
|
+
const children = content.kind === "table" ? [require_typed_shared_table.writeOdfTable(content.table, state.registry, `DrawTable${state.nextTable++}`)] : content.kind === "image" ? writeShapeImage(content.image, state) : [writeShapeTextBox(content.paragraphs, state)];
|
|
178
|
+
return require_xml_fragment.el("draw:frame", attributes, children);
|
|
179
|
+
}
|
|
180
|
+
function canonicalDrawShape(shape, documentIndex, listState) {
|
|
181
|
+
const content = planShapeContent(shape.blocks, listState);
|
|
182
|
+
const blocks = content.kind === "table" ? [require_typed_shared_canonicalise.canonicalTable(content.table)] : content.kind === "image" ? [{
|
|
183
|
+
...require_typed_shared_canonicalise.canonicalImage(content.image),
|
|
184
|
+
widthPt: shape.frame.widthPt,
|
|
185
|
+
heightPt: shape.frame.heightPt
|
|
186
|
+
}] : content.paragraphs.map((paragraph) => require_typed_shared_canonicalise.canonicalParagraph(paragraph, paragraph.list?.numId));
|
|
187
|
+
const canonical = {
|
|
188
|
+
frame: shape.frame,
|
|
189
|
+
insetLeftPt: shape.insetLeftPt,
|
|
190
|
+
insetTopPt: shape.insetTopPt,
|
|
191
|
+
insetRightPt: shape.insetRightPt,
|
|
192
|
+
insetBottomPt: shape.insetBottomPt,
|
|
193
|
+
paintOrder: odfZIndexOf(shape.paintOrder) ?? documentIndex,
|
|
194
|
+
blocks
|
|
195
|
+
};
|
|
196
|
+
if (shape.name !== void 0) canonical.name = shape.name;
|
|
197
|
+
if (shape.rotationDeg !== void 0 && shape.rotationDeg !== 0) canonical.rotationDeg = shape.rotationDeg;
|
|
198
|
+
return canonical;
|
|
199
|
+
}
|
|
200
|
+
function writeDrawShapes(shapes, listState, state) {
|
|
201
|
+
return shapes.map((shape, index) => writeDrawFrame(shape, listState, state, index));
|
|
202
|
+
}
|
|
203
|
+
//#endregion
|
|
204
|
+
exports.canonicalDrawShape = canonicalDrawShape;
|
|
205
|
+
exports.createDrawShapeWriteState = createDrawShapeWriteState;
|
|
206
|
+
exports.frameGeometryAttrs = frameGeometryAttrs;
|
|
207
|
+
exports.odfZIndexOf = odfZIndexOf;
|
|
208
|
+
exports.planShapeContent = planShapeContent;
|
|
209
|
+
exports.writeDrawFrame = writeDrawFrame;
|
|
210
|
+
exports.writeDrawShapes = writeDrawShapes;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as frameGeometryAttrs, c as writeDrawFrame, i as createDrawShapeWriteState, l as writeDrawShapes, n as ShapeContentPlan, o as odfZIndexOf, r as canonicalDrawShape, s as planShapeContent, t as DrawShapeWriteState } from "../../write-shapes-D4piGKf4.cjs";
|
|
2
|
+
export { DrawShapeWriteState, ShapeContentPlan, canonicalDrawShape, createDrawShapeWriteState, frameGeometryAttrs, odfZIndexOf, planShapeContent, writeDrawFrame, writeDrawShapes };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as frameGeometryAttrs, c as writeDrawFrame, i as createDrawShapeWriteState, l as writeDrawShapes, n as ShapeContentPlan, o as odfZIndexOf, r as canonicalDrawShape, s as planShapeContent, t as DrawShapeWriteState } from "../../write-shapes-Co7BrmMZ.js";
|
|
2
|
+
export { DrawShapeWriteState, ShapeContentPlan, canonicalDrawShape, createDrawShapeWriteState, frameGeometryAttrs, odfZIndexOf, planShapeContent, writeDrawFrame, writeDrawShapes };
|