odf.js 5.2.0 → 5.3.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 +3 -1
- package/dist/{cascade-rhqUQrUa.d.ts → cascade-BZ7zqXhL.d.ts} +2 -2
- package/dist/{cascade-BmvsXcAz.d.cts → cascade-DWQfTwaM.d.cts} +2 -2
- package/dist/{codec-BoPvy83Y.d.cts → codec-LgpdP32n.d.cts} +13 -13
- package/dist/{codec-BQB05qN1.d.ts → codec-sFSMk-if.d.ts} +13 -13
- package/dist/codec.d.cts +1 -1
- package/dist/codec.d.ts +1 -1
- package/dist/{constructs-CJpDDQV0.d.ts → constructs-B1yajQJB.d.ts} +8 -1
- package/dist/{constructs-Dy_DMFs3.d.cts → constructs-BSC_5kfU.d.cts} +8 -1
- package/dist/{embedded-BBJoUl86.js → embedded-BSSdoKcK.js} +151 -24
- package/dist/{embedded-CLuwn306.d.ts → embedded-ClsebpWi.d.ts} +1 -1
- package/dist/{embedded-FMIPM1fw.cjs → embedded-DbLrCGPi.cjs} +148 -21
- package/dist/{embedded-ztNK8w6V.d.cts → embedded-rKOsAsjg.d.cts} +1 -1
- package/dist/{form-D3H5H2NL.d.ts → form-CsOrcORr.d.ts} +2 -2
- package/dist/{form-BGCT81ss.d.cts → form-D8wh-xhJ.d.cts} +2 -2
- package/dist/{forms-cIjw-Jf-.d.cts → forms-BydLKkI0.d.cts} +1 -1
- package/dist/{forms-D1-0spCe.d.ts → forms-iwRSwhOn.d.ts} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +15 -15
- package/dist/index.d.ts +15 -15
- package/dist/index.js +1 -1
- package/dist/{masterpage-XJ2v2khe.d.cts → masterpage-Bt6gxuoL.d.cts} +2 -1
- package/dist/{masterpage-C1McDhMv.d.ts → masterpage-By_F05W4.d.ts} +2 -1
- package/dist/{paragraph-6hzAZpmi.d.ts → paragraph-BE71DZ0t.d.ts} +4 -3
- package/dist/{paragraph-BBmSl_sK.d.cts → paragraph-CuEMXbDg.d.cts} +4 -3
- package/dist/{properties-BF_Fv6B3.d.cts → properties-C-JKQZUD.d.cts} +2 -0
- package/dist/{properties-DjAIdPry.d.ts → properties-Rral02h1.d.ts} +2 -0
- package/dist/read-24g5eZw6.d.ts +25 -0
- package/dist/{read-lc0t0UHK.d.ts → read-BLoaDxr_.d.ts} +2 -1
- package/dist/{read-B4238IGr.d.cts → read-C3Ei_MYc.d.cts} +2 -1
- package/dist/{read-CTfeWaWq.d.cts → read-CDSmR3qt.d.cts} +2 -1
- package/dist/{read-CdvX2qnz.d.ts → read-DJqvINGW.d.ts} +2 -1
- package/dist/{read-Db_GZ0ZH.d.ts → read-DfEHXwgn.d.ts} +2 -1
- package/dist/{read-DOYWO6BM.d.cts → read-IOYq80AA.d.cts} +2 -1
- package/dist/read-rwDsgR0d.d.cts +25 -0
- package/dist/{registry-CaJpWDke.d.cts → registry-CphRYjDD.d.cts} +1 -1
- package/dist/{registry-BVeEpUMI.d.ts → registry-D5RGBteE.d.ts} +1 -1
- package/dist/{serialize-DvaE_t5D.d.ts → serialize-B-lq0LiG.d.ts} +1 -1
- package/dist/{serialize-9xvti0FF.d.cts → serialize-D1fti8C5.d.cts} +1 -1
- package/dist/styles/properties.cjs +25 -3
- package/dist/styles/properties.d.cts +1 -1
- package/dist/styles/properties.d.ts +1 -1
- package/dist/styles/properties.js +25 -3
- package/dist/styles/registry.d.cts +1 -1
- package/dist/styles/registry.d.ts +1 -1
- package/dist/styles/serialize.d.cts +1 -1
- package/dist/styles/serialize.d.ts +1 -1
- package/dist/typed/draw/embedded.cjs +1 -1
- package/dist/typed/draw/embedded.d.cts +1 -1
- package/dist/typed/draw/embedded.d.ts +1 -1
- package/dist/typed/draw/embedded.js +1 -1
- package/dist/typed/draw/shapes.cjs +4 -1
- package/dist/typed/draw/shapes.js +4 -1
- package/dist/typed/odb/form.cjs +1 -1
- package/dist/typed/odb/form.d.cts +1 -1
- package/dist/typed/odb/form.d.ts +1 -1
- package/dist/typed/odb/form.js +1 -1
- package/dist/typed/odg/read.cjs +14 -4
- package/dist/typed/odg/read.d.cts +1 -1
- package/dist/typed/odg/read.d.ts +1 -1
- package/dist/typed/odg/read.js +14 -4
- package/dist/typed/odp/read.cjs +51 -4
- package/dist/typed/odp/read.d.cts +1 -1
- package/dist/typed/odp/read.d.ts +1 -1
- package/dist/typed/odp/read.js +52 -5
- package/dist/typed/ods/read.cjs +1 -1
- package/dist/typed/ods/read.d.cts +1 -1
- package/dist/typed/ods/read.d.ts +1 -1
- package/dist/typed/ods/read.js +1 -1
- package/dist/typed/odt/read.cjs +1 -1
- package/dist/typed/odt/read.d.cts +2 -2
- package/dist/typed/odt/read.d.ts +2 -2
- package/dist/typed/odt/read.js +1 -1
- package/dist/typed/shared/cascade.d.cts +1 -1
- package/dist/typed/shared/cascade.d.ts +1 -1
- package/dist/typed/shared/constructs.cjs +73 -0
- package/dist/typed/shared/constructs.d.cts +2 -2
- package/dist/typed/shared/constructs.d.ts +2 -2
- package/dist/typed/shared/constructs.js +67 -1
- package/dist/typed/shared/forms.d.cts +1 -1
- package/dist/typed/shared/forms.d.ts +1 -1
- package/dist/typed/shared/masterpage.cjs +7 -0
- package/dist/typed/shared/masterpage.d.cts +2 -2
- package/dist/typed/shared/masterpage.d.ts +2 -2
- package/dist/typed/shared/masterpage.js +7 -1
- package/dist/typed/shared/paragraph.cjs +17 -6
- package/dist/typed/shared/paragraph.d.cts +2 -2
- package/dist/typed/shared/paragraph.d.ts +2 -2
- package/dist/typed/shared/paragraph.js +18 -8
- package/package.json +2 -2
- package/dist/read-Cs1ktkWB.d.cts +0 -15
- package/dist/read-DHuiGh_y.d.ts +0 -15
package/README.md
CHANGED
|
@@ -237,7 +237,7 @@ Layered from a lossless core outward, mirroring `ooxml.js`:
|
|
|
237
237
|
|
|
238
238
|
## Fidelity constructs
|
|
239
239
|
|
|
240
|
-
`readOdt` reads ODF's fidelity constructs into `document-schema.js`'s harmonised construct vocabulary — the semantic channel of the family's two-channel fidelity model (the quarantined residue channel is the other half).
|
|
240
|
+
`readOdt` reads ODF's fidelity constructs into `document-schema.js`'s harmonised construct vocabulary — the semantic channel of the family's two-channel fidelity model (the quarantined residue channel is the other half). Two residue rows carry genuine producer fixtures (`conditional-format.ods`, `transitions.odp` — real LibreOffice output, generated through the same UNO calls the Calc/Impress UIs use); every other fixture below the unit suites is programmatic, built to the OASIS element grammar, with real-producer verification outstanding.
|
|
241
241
|
|
|
242
242
|
- **Fields** — every inline field element (the simple set, the variable/user-field/sequence instance families, the database displays) reads as ordinary runs carrying its cached text plus a run-level field extent on the paragraph, instruction being the serialised element and `cachedResult` its own text content. Field master declarations (`text:*-decls`) read into the package-root definitions table, keyed per family.
|
|
243
243
|
- **Bookmarks and tracked changes** — paired marker halves at run scope pair inside one paragraph; halves at paragraph edges pair across blocks into `constructStart`/`constructEnd` markers. Change markers resolve their `text:change-id` against the `text:changed-region` definitions (either id spelling, `xml:id` today and ODF 1.0's `text:id`), carrying author and date as provenance.
|
|
@@ -246,6 +246,8 @@ Layered from a lossless core outward, mirroring `ooxml.js`:
|
|
|
246
246
|
- **Forms** — `office:forms` in an ordinary text document reads as point content controls in pre-order through the same form-tree walker the `.odb` reader uses; `form:properties` bags quarantine into residue.
|
|
247
247
|
- **Anchored frames** — a `draw:frame` in text flow lifts to blocks after its paragraph: images, text-box content, and embedded objects (formula, drawing, presentation, chart, spreadsheet), each dispatched through `typed/draw/embedded.ts`'s shared `readEmbeddedObjectDocument` — the central kind→reader table that lets a Writer document read an embedded Calc sheet (and a Calc sheet an embedded Writer document) without any format reader importing a sibling reader.
|
|
248
248
|
- **Style-side tenants** — `number:*` data styles and `office:font-face-decls` read into the definitions table from both parts; a paragraph style's unmodellable properties quarantine as per-node residue.
|
|
249
|
+
- **Master pages and page-break styles** — every `style:master-page` reads as part of a whole-page inventory: a paragraph style's `style:paragraph-properties/@style:master-page-name` switch opens a new `ContentSection` at that paragraph carrying the named master page's own geometry (`breakType: 'nextPage'` — ODF defines the switch as forcing a page break), and each master page's `style:header`/`style:footer` variants (default, `-left`, `-first`) read as real block flow on `OdtDocument.headerFooterParts`, with `sectionMasterPages` naming positionally which master page each section came from. Explicit page breaks ride the shared cascade: `fo:break-before`/`fo:break-after="page"` resolve onto the paragraph's `pageBreakBefore`/`pageBreakAfter` flags (`auto` to an explicit false; `column`/`even-page`/`odd-page` quarantine as residue through the unknown-properties path, since the boolean cannot hold their extra meaning).
|
|
250
|
+
- **The quarantined residue rows** — inline no-analogue constructs (`text:ruby`, `text:meta`, a heading's `text:is-list-header` flag) quarantine on their own paragraph beside the style-chain unknowns; document-level tenants nothing else owns (`xforms:model`, DDE connection declarations and `text:dde-source` links, vendor-extension elements) quarantine at the package tier on `OdtDocument.source`; `table:calculation-settings` and vendor-extension elements (Calc writes its `calcext:conditional-formats` inside each `table:table`) do the same on `OdsDocument.source`; an odp slide's presentation extras — the transition attributes off the slide's own drawing-page style, where every ODF schema version and real Impress output put them (the legacy `presentation:transition-*`/`presentation:duration` spelling and the ODF 1.2 `smil:type`/`-subtype`/`-direction`/`-fadeColor` one), plus `presentation:sound` and `anim:` trees — and every format's unmapped shape kinds (`dr3d:scene`, `draw:connector`, `draw:measure`, applet/plugin/floating-frame) quarantine on their own slide/page; an unrecognised `draw:custom-shape` preset's whole `draw:enhanced-geometry` quarantines in the text shape it degrades to; and every non-content XML part (`settings.xml`, `META-INF/manifest.rdf`, `Configurations2/…`) quarantines at the package tier keyed by its part path — never an embedded sub-document's own `Object N/` parts, which the semantic channel already carries whole.
|
|
249
251
|
|
|
250
252
|
Every read-side construct has no write-side counterpart because this package's typed layer is read-only — the honest asymmetry of a reader with no content writer; the lossless `encodePackage` layer remains the byte-fidelity tier.
|
|
251
253
|
- **An embedded Math object in a spreadsheet cell reads as `objectKind: 'formula'`** — its `content.xml` root *is* the MathML root, so `readDrawObjectReference` falls back to `findMathRoot` and dispatches to `readOdfFormulaContent`.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { l as XmlElement } from "./node-CkBWRjNR.js";
|
|
2
2
|
import { r as Package } from "./package-BUojjTXf.js";
|
|
3
|
-
import { n as StyleProperties } from "./properties-
|
|
4
|
-
import { i as StyleFamily } from "./registry-
|
|
3
|
+
import { n as StyleProperties } from "./properties-Rral02h1.js";
|
|
4
|
+
import { i as StyleFamily } from "./registry-D5RGBteE.js";
|
|
5
5
|
//#region src/typed/shared/cascade.d.ts
|
|
6
6
|
interface CascadeDiagnostic {
|
|
7
7
|
severity: 'warning';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { l as XmlElement } from "./node-CkBWRjNR.cjs";
|
|
2
2
|
import { r as Package } from "./package-L24lkba-.cjs";
|
|
3
|
-
import { n as StyleProperties } from "./properties-
|
|
4
|
-
import { i as StyleFamily } from "./registry-
|
|
3
|
+
import { n as StyleProperties } from "./properties-C-JKQZUD.cjs";
|
|
4
|
+
import { i as StyleFamily } from "./registry-CphRYjDD.cjs";
|
|
5
5
|
//#region src/typed/shared/cascade.d.ts
|
|
6
6
|
interface CascadeDiagnostic {
|
|
7
7
|
severity: 'warning';
|
|
@@ -7,34 +7,34 @@ import "./build-XSm3I8LT.cjs";
|
|
|
7
7
|
import "./mimetype-CPNMj04s.cjs";
|
|
8
8
|
import "./fragment-B1og_8uA.cjs";
|
|
9
9
|
import "./manifest-BALwu2JR.cjs";
|
|
10
|
-
import "./properties-
|
|
11
|
-
import "./serialize-
|
|
12
|
-
import "./registry-
|
|
10
|
+
import "./properties-C-JKQZUD.cjs";
|
|
11
|
+
import "./serialize-D1fti8C5.cjs";
|
|
12
|
+
import "./registry-CphRYjDD.cjs";
|
|
13
13
|
import "./span-BtmvlqZH.cjs";
|
|
14
14
|
import "./query-P-Y5DK0-.cjs";
|
|
15
15
|
import "./color-CqXjt_to.cjs";
|
|
16
16
|
import "./geometry-lKWJ_ifA.cjs";
|
|
17
17
|
import "./text-BAi1tapc.cjs";
|
|
18
|
-
import "./cascade-
|
|
18
|
+
import "./cascade-DWQfTwaM.cjs";
|
|
19
19
|
import "./metadata-1j1zm9Cx.cjs";
|
|
20
20
|
import "./list-KZeXA0mR.cjs";
|
|
21
|
-
import "./paragraph-
|
|
21
|
+
import "./paragraph-CuEMXbDg.cjs";
|
|
22
22
|
import "./table-BH_Q2n_N.cjs";
|
|
23
23
|
import "./transform-DKEjydnm.cjs";
|
|
24
|
-
import "./masterpage-
|
|
24
|
+
import "./masterpage-Bt6gxuoL.cjs";
|
|
25
25
|
import "./path-DE7wkIcz.cjs";
|
|
26
26
|
import "./shapes-8o3NjBLU.cjs";
|
|
27
|
-
import "./embedded-
|
|
28
|
-
import "./read-
|
|
29
|
-
import "./read-
|
|
30
|
-
import "./read-
|
|
31
|
-
import "./read-
|
|
27
|
+
import "./embedded-rKOsAsjg.cjs";
|
|
28
|
+
import "./read-CDSmR3qt.cjs";
|
|
29
|
+
import "./read-rwDsgR0d.cjs";
|
|
30
|
+
import "./read-IOYq80AA.cjs";
|
|
31
|
+
import "./read-C3Ei_MYc.cjs";
|
|
32
32
|
import "./read-DUCm1nUv.cjs";
|
|
33
33
|
import "./read-ydLJ8bid.cjs";
|
|
34
34
|
import "./read-BV2an1ok.cjs";
|
|
35
35
|
import "./subdocument-yY8ASE4N.cjs";
|
|
36
|
-
import "./forms-
|
|
37
|
-
import "./form-
|
|
36
|
+
import "./forms-BydLKkI0.cjs";
|
|
37
|
+
import "./form-D8wh-xhJ.cjs";
|
|
38
38
|
import "./report-D6WNYaVn.cjs";
|
|
39
39
|
import { z } from "zod";
|
|
40
40
|
import { Alignment as Alignment$1, AlignmentSchema, DocumentPackage as DocumentPackage$1 } from "document-schema.js";
|
|
@@ -7,34 +7,34 @@ import "./build-Z1KRkSEB.js";
|
|
|
7
7
|
import "./mimetype-BfkwTeaW.js";
|
|
8
8
|
import "./fragment-B1ZV7T5Z.js";
|
|
9
9
|
import "./manifest-CP1sqyGU.js";
|
|
10
|
-
import "./properties-
|
|
11
|
-
import "./serialize-
|
|
12
|
-
import "./registry-
|
|
10
|
+
import "./properties-Rral02h1.js";
|
|
11
|
+
import "./serialize-B-lq0LiG.js";
|
|
12
|
+
import "./registry-D5RGBteE.js";
|
|
13
13
|
import "./span-KXroEGuH.js";
|
|
14
14
|
import "./query-sECN-7vU.js";
|
|
15
15
|
import "./color-CqXjt_to.js";
|
|
16
16
|
import "./geometry-DnhkIhAM.js";
|
|
17
17
|
import "./text-gJ5R0q3u.js";
|
|
18
|
-
import "./cascade-
|
|
18
|
+
import "./cascade-BZ7zqXhL.js";
|
|
19
19
|
import "./metadata-BXpjrAS-.js";
|
|
20
20
|
import "./list-Qeuawtew.js";
|
|
21
|
-
import "./paragraph-
|
|
21
|
+
import "./paragraph-BE71DZ0t.js";
|
|
22
22
|
import "./table-ByOoGcq_.js";
|
|
23
23
|
import "./transform-C7GrZZdR.js";
|
|
24
|
-
import "./masterpage-
|
|
24
|
+
import "./masterpage-By_F05W4.js";
|
|
25
25
|
import "./path-DE7wkIcz.js";
|
|
26
26
|
import "./shapes-CCB8ydqD.js";
|
|
27
|
-
import "./embedded-
|
|
28
|
-
import "./read-
|
|
29
|
-
import "./read-
|
|
30
|
-
import "./read-
|
|
31
|
-
import "./read-
|
|
27
|
+
import "./embedded-ClsebpWi.js";
|
|
28
|
+
import "./read-DfEHXwgn.js";
|
|
29
|
+
import "./read-24g5eZw6.js";
|
|
30
|
+
import "./read-BLoaDxr_.js";
|
|
31
|
+
import "./read-DJqvINGW.js";
|
|
32
32
|
import "./read-BnN7u9Y2.js";
|
|
33
33
|
import "./read-DYYxbvfo.js";
|
|
34
34
|
import "./read-CvjbdgH3.js";
|
|
35
35
|
import "./subdocument-BwW3FZC_.js";
|
|
36
|
-
import "./forms-
|
|
37
|
-
import "./form-
|
|
36
|
+
import "./forms-iwRSwhOn.js";
|
|
37
|
+
import "./form-CsOrcORr.js";
|
|
38
38
|
import "./report-DbslT2OR.js";
|
|
39
39
|
import { z } from "zod";
|
|
40
40
|
import { Alignment as Alignment$1, AlignmentSchema as AlignmentSchema$1, DocumentPackage as DocumentPackage$1 } from "document-schema.js";
|
package/dist/codec.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as xmlCodec, n as encodePackage, r as packageCodec, t as decodePackage } from "./codec-
|
|
1
|
+
import { i as xmlCodec, n as encodePackage, r as packageCodec, t as decodePackage } from "./codec-LgpdP32n.cjs";
|
|
2
2
|
export { decodePackage, encodePackage, packageCodec, xmlCodec };
|
package/dist/codec.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as xmlCodec, n as encodePackage, r as packageCodec, t as decodePackage } from "./codec-
|
|
1
|
+
import { i as xmlCodec, n as encodePackage, r as packageCodec, t as decodePackage } from "./codec-sFSMk-if.js";
|
|
2
2
|
export { decodePackage, encodePackage, packageCodec, xmlCodec };
|
|
@@ -6,6 +6,13 @@ declare function odfFieldDescriptor(element: XmlElement): FieldDescriptor;
|
|
|
6
6
|
declare function odfBookmarkAnchorDescriptor(name: string): AnchorDescriptor;
|
|
7
7
|
type OdfResidueFormat = 'odt' | 'ods' | 'odp' | 'odg' | 'odm' | 'odb' | 'odf';
|
|
8
8
|
declare function odfResidue(format: OdfResidueFormat, ...elements: XmlElement[]): SourceResidue;
|
|
9
|
+
declare function isOdfExtensionElement(element: XmlElement): boolean;
|
|
10
|
+
declare const ODF_UNMAPPED_SHAPE_TAGS: ReadonlySet<string>;
|
|
11
|
+
declare function collectOdfUnmappedShapeResidue(children: readonly XmlNode[], out: XmlElement[]): void;
|
|
12
|
+
declare function odfAttributeElement(element: XmlElement, ...attributeNames: readonly string[]): XmlElement;
|
|
13
|
+
declare function addOdfPackageResidue(out: Record<string, SourceResidue>, key: string, format: OdfResidueFormat, ...elements: XmlElement[]): void;
|
|
14
|
+
declare const ODF_CONSUMED_PART_PATHS: ReadonlySet<string>;
|
|
15
|
+
declare function collectOdfNonContentPartResidue(pkg: Package, format: OdfResidueFormat, out: Record<string, SourceResidue>): void;
|
|
9
16
|
declare function odfDivisionDescriptor(sectionElement: XmlElement, pkg: Package): DivisionDescriptor;
|
|
10
17
|
declare const ODF_INDEX_WRAPPER_TAGS: ReadonlySet<string>;
|
|
11
18
|
declare function isOdfIndexWrapper(element: XmlElement): boolean;
|
|
@@ -60,4 +67,4 @@ declare function collectOdfDataStyleDefinitions(nodes: readonly XmlNode[], out:
|
|
|
60
67
|
declare function collectOdfFontFaceDefinitions(nodes: readonly XmlNode[], out: Record<string, DefinitionEntry>): void;
|
|
61
68
|
declare function collectOdfNamedExpressions(nodes: readonly XmlNode[], out: Record<string, DefinitionEntry>): void;
|
|
62
69
|
//#endregion
|
|
63
|
-
export { pairOdfMarkerHalves as C,
|
|
70
|
+
export { pairOdfMarkerHalves as A, odfBookmarkAnchorDescriptor as C, odfIndexControlDescriptor as D, odfFieldDescriptor as E, odfMarkerHalfEventIndex as O, odfAttributeElement as S, odfDivisionDescriptor as T, collectOdfUnmappedShapeResidue as _, OdfDefinitionsSink as a, isOdfExtensionElement as b, OdfMarkerKind as c, collectOdfDataStyleDefinitions as d, collectOdfFieldMasterDefinitions as f, collectOdfProvenanceRegions as g, collectOdfNonContentPartResidue as h, OdfConstructExtent as i, resolveOdfMarkerEvents as j, odfResidue as k, OdfResidueFormat as l, collectOdfNamedExpressions as m, ODF_INDEX_WRAPPER_TAGS as n, OdfMarkerEvent as o, collectOdfFontFaceDefinitions as p, ODF_UNMAPPED_SHAPE_TAGS as r, OdfMarkerHalf as s, ODF_CONSUMED_PART_PATHS as t, addOdfPackageResidue as u, insertOdfConstructMarkers as v, odfChangedRegionId as w, isOdfIndexWrapper as x, isOdfBlockScopedHalf as y };
|
|
@@ -6,6 +6,13 @@ declare function odfFieldDescriptor(element: XmlElement): FieldDescriptor;
|
|
|
6
6
|
declare function odfBookmarkAnchorDescriptor(name: string): AnchorDescriptor;
|
|
7
7
|
type OdfResidueFormat = 'odt' | 'ods' | 'odp' | 'odg' | 'odm' | 'odb' | 'odf';
|
|
8
8
|
declare function odfResidue(format: OdfResidueFormat, ...elements: XmlElement[]): SourceResidue;
|
|
9
|
+
declare function isOdfExtensionElement(element: XmlElement): boolean;
|
|
10
|
+
declare const ODF_UNMAPPED_SHAPE_TAGS: ReadonlySet<string>;
|
|
11
|
+
declare function collectOdfUnmappedShapeResidue(children: readonly XmlNode[], out: XmlElement[]): void;
|
|
12
|
+
declare function odfAttributeElement(element: XmlElement, ...attributeNames: readonly string[]): XmlElement;
|
|
13
|
+
declare function addOdfPackageResidue(out: Record<string, SourceResidue>, key: string, format: OdfResidueFormat, ...elements: XmlElement[]): void;
|
|
14
|
+
declare const ODF_CONSUMED_PART_PATHS: ReadonlySet<string>;
|
|
15
|
+
declare function collectOdfNonContentPartResidue(pkg: Package, format: OdfResidueFormat, out: Record<string, SourceResidue>): void;
|
|
9
16
|
declare function odfDivisionDescriptor(sectionElement: XmlElement, pkg: Package): DivisionDescriptor;
|
|
10
17
|
declare const ODF_INDEX_WRAPPER_TAGS: ReadonlySet<string>;
|
|
11
18
|
declare function isOdfIndexWrapper(element: XmlElement): boolean;
|
|
@@ -60,4 +67,4 @@ declare function collectOdfDataStyleDefinitions(nodes: readonly XmlNode[], out:
|
|
|
60
67
|
declare function collectOdfFontFaceDefinitions(nodes: readonly XmlNode[], out: Record<string, DefinitionEntry>): void;
|
|
61
68
|
declare function collectOdfNamedExpressions(nodes: readonly XmlNode[], out: Record<string, DefinitionEntry>): void;
|
|
62
69
|
//#endregion
|
|
63
|
-
export { pairOdfMarkerHalves as C,
|
|
70
|
+
export { pairOdfMarkerHalves as A, odfBookmarkAnchorDescriptor as C, odfIndexControlDescriptor as D, odfFieldDescriptor as E, odfMarkerHalfEventIndex as O, odfAttributeElement as S, odfDivisionDescriptor as T, collectOdfUnmappedShapeResidue as _, OdfDefinitionsSink as a, isOdfExtensionElement as b, OdfMarkerKind as c, collectOdfDataStyleDefinitions as d, collectOdfFieldMasterDefinitions as f, collectOdfProvenanceRegions as g, collectOdfNonContentPartResidue as h, OdfConstructExtent as i, resolveOdfMarkerEvents as j, odfResidue as k, OdfResidueFormat as l, collectOdfNamedExpressions as m, ODF_INDEX_WRAPPER_TAGS as n, OdfMarkerEvent as o, collectOdfFontFaceDefinitions as p, ODF_UNMAPPED_SHAPE_TAGS as r, OdfMarkerHalf as s, ODF_CONSUMED_PART_PATHS as t, addOdfPackageResidue as u, insertOdfConstructMarkers as v, odfChangedRegionId as w, isOdfIndexWrapper as x, isOdfBlockScopedHalf as y };
|
|
@@ -5,11 +5,11 @@ import { parseMargins, parsePageSize } from "./typed/shared/geometry.js";
|
|
|
5
5
|
import { findStyleElement, resolveStyleElementChain } from "./typed/shared/cascade.js";
|
|
6
6
|
import { readOdfMetadata } from "./typed/shared/metadata.js";
|
|
7
7
|
import { mintOdfListNumId, readOdfListParagraphs } from "./typed/shared/list.js";
|
|
8
|
-
import { collectOdfDataStyleDefinitions, collectOdfFieldMasterDefinitions, collectOdfFontFaceDefinitions, collectOdfNamedExpressions, collectOdfProvenanceRegions, insertOdfConstructMarkers, isOdfIndexWrapper, odfDivisionDescriptor, odfIndexControlDescriptor, odfMarkerHalfEventIndex, odfResidue, resolveOdfMarkerEvents } from "./typed/shared/constructs.js";
|
|
9
|
-
import { readOdfParagraph } from "./typed/shared/paragraph.js";
|
|
8
|
+
import { addOdfPackageResidue, collectOdfDataStyleDefinitions, collectOdfFieldMasterDefinitions, collectOdfFontFaceDefinitions, collectOdfNamedExpressions, collectOdfNonContentPartResidue, collectOdfProvenanceRegions, insertOdfConstructMarkers, isOdfExtensionElement, isOdfIndexWrapper, odfDivisionDescriptor, odfIndexControlDescriptor, odfMarkerHalfEventIndex, odfResidue, resolveOdfMarkerEvents } from "./typed/shared/constructs.js";
|
|
9
|
+
import { readOdfConstructBodyBlocks, readOdfParagraph } from "./typed/shared/paragraph.js";
|
|
10
10
|
import { readCellStyleDecoration, readOdfTable } from "./typed/shared/table.js";
|
|
11
11
|
import { parseOdfTransform } from "./typed/shared/transform.js";
|
|
12
|
-
import { resolvePageLayoutProperties } from "./typed/shared/masterpage.js";
|
|
12
|
+
import { readOdfMasterPageElements, resolvePageLayoutProperties } from "./typed/shared/masterpage.js";
|
|
13
13
|
import { readDrawFrame } from "./typed/draw/shapes.js";
|
|
14
14
|
import { findMathRoot, readOdfFormulaContent } from "./typed/formula/read.js";
|
|
15
15
|
import { subDocumentPackage } from "./typed/odb/subdocument.js";
|
|
@@ -363,6 +363,9 @@ function readSheet(tableElement, pkg) {
|
|
|
363
363
|
if (embeddedObjects.length > 0) sheet.embeddedObjects = embeddedObjects;
|
|
364
364
|
return sheet;
|
|
365
365
|
}
|
|
366
|
+
function collectOdsExtensionElementResidue(children, source) {
|
|
367
|
+
for (const child of children) if (child.type === "element" && isOdfExtensionElement(child)) addOdfPackageResidue(source, child.tag, "ods", child);
|
|
368
|
+
}
|
|
366
369
|
function readOdsContent(pkg) {
|
|
367
370
|
const contentPart = pkg.parts[CONTENT_PART$2];
|
|
368
371
|
const root = contentPart?.kind === "xml" ? rootElement(contentPart.nodes) : void 0;
|
|
@@ -375,28 +378,62 @@ function readOdsContent(pkg) {
|
|
|
375
378
|
if (sheet !== void 0) sheets.push(sheet);
|
|
376
379
|
}
|
|
377
380
|
const definitions = {};
|
|
378
|
-
|
|
381
|
+
const source = {};
|
|
382
|
+
if (spreadsheet !== void 0) {
|
|
383
|
+
collectOdfNamedExpressions(spreadsheet.children, definitions);
|
|
384
|
+
addOdfPackageResidue(source, "calculation-settings", "ods", ...childrenWithTag(spreadsheet, "table:calculation-settings"));
|
|
385
|
+
collectOdsExtensionElementResidue(spreadsheet.children, source);
|
|
386
|
+
for (const table of tables) collectOdsExtensionElementResidue(table.children, source);
|
|
387
|
+
}
|
|
388
|
+
collectOdfNonContentPartResidue(pkg, "ods", source);
|
|
379
389
|
return {
|
|
380
390
|
metadata: readOdfMetadata(pkg),
|
|
381
391
|
sheets,
|
|
382
|
-
...Object.keys(definitions).length > 0 ? { definitions } : {}
|
|
392
|
+
...Object.keys(definitions).length > 0 ? { definitions } : {},
|
|
393
|
+
...Object.keys(source).length > 0 ? { source } : {}
|
|
383
394
|
};
|
|
384
395
|
}
|
|
385
396
|
function readOds(pkg) {
|
|
386
|
-
const { metadata, sheets, definitions } = readOdsContent(pkg);
|
|
397
|
+
const { metadata, sheets, definitions, source } = readOdsContent(pkg);
|
|
387
398
|
const assembled = assemblePackage({
|
|
388
399
|
kind: "spreadsheet",
|
|
389
400
|
metadata,
|
|
390
401
|
sheets
|
|
391
402
|
});
|
|
392
403
|
if (definitions !== void 0) assembled.definitions = definitions;
|
|
404
|
+
if (source !== void 0) assembled.source = source;
|
|
393
405
|
return assembled;
|
|
394
406
|
}
|
|
395
407
|
//#endregion
|
|
396
408
|
//#region src/typed/odt/read.ts
|
|
409
|
+
const ODT_HEADER_FOOTER_TAGS = /* @__PURE__ */ new Map([
|
|
410
|
+
["style:header", {
|
|
411
|
+
kind: "header",
|
|
412
|
+
variant: "default"
|
|
413
|
+
}],
|
|
414
|
+
["style:header-left", {
|
|
415
|
+
kind: "header",
|
|
416
|
+
variant: "left"
|
|
417
|
+
}],
|
|
418
|
+
["style:header-first", {
|
|
419
|
+
kind: "header",
|
|
420
|
+
variant: "first"
|
|
421
|
+
}],
|
|
422
|
+
["style:footer", {
|
|
423
|
+
kind: "footer",
|
|
424
|
+
variant: "default"
|
|
425
|
+
}],
|
|
426
|
+
["style:footer-left", {
|
|
427
|
+
kind: "footer",
|
|
428
|
+
variant: "left"
|
|
429
|
+
}],
|
|
430
|
+
["style:footer-first", {
|
|
431
|
+
kind: "footer",
|
|
432
|
+
variant: "first"
|
|
433
|
+
}]
|
|
434
|
+
]);
|
|
397
435
|
const CONTENT_PART$1 = "content.xml";
|
|
398
|
-
const
|
|
399
|
-
const AUTOMATIC_STYLE_PARTS = [CONTENT_PART$1, STYLES_PART];
|
|
436
|
+
const AUTOMATIC_STYLE_PARTS = [CONTENT_PART$1, "styles.xml"];
|
|
400
437
|
function readOutlineLevel(headingElement) {
|
|
401
438
|
const raw = attrValue(headingElement, "text:outline-level");
|
|
402
439
|
if (raw === void 0) return 1;
|
|
@@ -411,6 +448,18 @@ function readParagraphOrHeading(element, paragraph) {
|
|
|
411
448
|
}
|
|
412
449
|
return paragraph;
|
|
413
450
|
}
|
|
451
|
+
function resolveParagraphMasterPageName(element, pkg, state) {
|
|
452
|
+
const styleName = attrValue(element, "text:style-name");
|
|
453
|
+
if (state.masterPageByStyleName.has(styleName)) return state.masterPageByStyleName.get(styleName);
|
|
454
|
+
let resolved;
|
|
455
|
+
for (const style of resolveStyleElementChain(styleName, "paragraph", pkg).elements) {
|
|
456
|
+
const properties = findChildElement(style.children, "style:paragraph-properties");
|
|
457
|
+
const name = properties === void 0 ? void 0 : attrValue(properties, "style:master-page-name");
|
|
458
|
+
if (name !== void 0) resolved = name;
|
|
459
|
+
}
|
|
460
|
+
state.masterPageByStyleName.set(styleName, resolved);
|
|
461
|
+
return resolved;
|
|
462
|
+
}
|
|
414
463
|
function readAnchoredFrameSources(paragraphElement, pkg, state) {
|
|
415
464
|
if (!state.liftFrames) return [];
|
|
416
465
|
const sources = [];
|
|
@@ -464,6 +513,13 @@ function readBlocks(nodes, pkg, state, baseIndex = 0) {
|
|
|
464
513
|
const emitParagraphs = (reads) => {
|
|
465
514
|
let cursor = baseIndex + blocks.length;
|
|
466
515
|
for (const read of reads) {
|
|
516
|
+
if (read.masterPageName !== void 0 && read.masterPageName !== state.masterPage) {
|
|
517
|
+
state.sectionSplits.push({
|
|
518
|
+
index: cursor,
|
|
519
|
+
masterPage: read.masterPageName
|
|
520
|
+
});
|
|
521
|
+
state.masterPage = read.masterPageName;
|
|
522
|
+
}
|
|
467
523
|
const lifted = read.liftedSources.flatMap((source) => source.blocks);
|
|
468
524
|
for (const half of read.halves) {
|
|
469
525
|
const eventIndex = odfMarkerHalfEventIndex(half, read.element, cursor, liftedBlocksBeforeHalf(read, half.element));
|
|
@@ -495,7 +551,8 @@ function readBlocks(nodes, pkg, state, baseIndex = 0) {
|
|
|
495
551
|
format: "odt"
|
|
496
552
|
})),
|
|
497
553
|
halves,
|
|
498
|
-
liftedSources: readAnchoredFrameSources(element, pkg, state)
|
|
554
|
+
liftedSources: readAnchoredFrameSources(element, pkg, state),
|
|
555
|
+
masterPageName: resolveParagraphMasterPageName(element, pkg, state)
|
|
499
556
|
};
|
|
500
557
|
};
|
|
501
558
|
for (const node of nodes) {
|
|
@@ -524,6 +581,7 @@ function readBlocks(nodes, pkg, state, baseIndex = 0) {
|
|
|
524
581
|
order,
|
|
525
582
|
descriptor: odfDivisionDescriptor(node, pkg)
|
|
526
583
|
});
|
|
584
|
+
addOdfPackageResidue(state.packageResidue, "dde-links", "odt", ...childrenWithTag(node, "text:dde-source"));
|
|
527
585
|
} else if (isOdfIndexWrapper(node)) {
|
|
528
586
|
const startIndex = baseIndex + blocks.length;
|
|
529
587
|
const order = state.order++;
|
|
@@ -536,7 +594,11 @@ function readBlocks(nodes, pkg, state, baseIndex = 0) {
|
|
|
536
594
|
descriptor: odfIndexControlDescriptor(node)
|
|
537
595
|
});
|
|
538
596
|
} else if (node.tag === "text:index-title") blocks.push(...readBlocks(node.children, pkg, state, baseIndex + blocks.length));
|
|
539
|
-
else if (node.tag === "office:forms")
|
|
597
|
+
else if (node.tag === "office:forms") {
|
|
598
|
+
blocks.push(...readOdfFormControlConstructs(node, "odt"));
|
|
599
|
+
addOdfPackageResidue(state.packageResidue, "xforms", "odt", ...childrenWithTag(node, "xforms:model"));
|
|
600
|
+
} else if (node.tag === "text:dde-connection-decls") addOdfPackageResidue(state.packageResidue, "dde-connections", "odt", ...childrenWithTag(node, "text:dde-connection-decl"));
|
|
601
|
+
else if (isOdfExtensionElement(node)) addOdfPackageResidue(state.packageResidue, node.tag, "odt", node);
|
|
540
602
|
}
|
|
541
603
|
return blocks;
|
|
542
604
|
}
|
|
@@ -564,12 +626,8 @@ function findPageLayoutElement(pkg, pageLayoutName) {
|
|
|
564
626
|
if (found !== void 0) return found;
|
|
565
627
|
}
|
|
566
628
|
}
|
|
567
|
-
function
|
|
568
|
-
const
|
|
569
|
-
const stylesRoot = stylesPart?.kind === "xml" ? rootElement(stylesPart.nodes) : void 0;
|
|
570
|
-
const masterStyles = stylesRoot === void 0 ? void 0 : findChildElement(stylesRoot.children, "office:master-styles");
|
|
571
|
-
const masterPage = masterStyles === void 0 ? void 0 : findChildElement(masterStyles.children, "style:master-page");
|
|
572
|
-
const layout = findPageLayoutElement(pkg, masterPage === void 0 ? void 0 : attrValue(masterPage, "style:page-layout-name"));
|
|
629
|
+
function resolveMasterPageGeometry(pkg, masterPage) {
|
|
630
|
+
const layout = findPageLayoutElement(pkg, attrValue(masterPage, "style:page-layout-name"));
|
|
573
631
|
const properties = layout === void 0 ? void 0 : findChildElement(layout.children, "style:page-layout-properties");
|
|
574
632
|
const pageSize = properties === void 0 ? void 0 : parsePageSize(properties);
|
|
575
633
|
const margins = properties === void 0 ? void 0 : parseMargins(properties);
|
|
@@ -578,6 +636,40 @@ function readFirstMasterPageGeometry(pkg) {
|
|
|
578
636
|
margins: margins ?? DEFAULT_MARGINS
|
|
579
637
|
};
|
|
580
638
|
}
|
|
639
|
+
function splitOdtSections(walked, extents, splits, initialMasterPage, geometryByMasterPage) {
|
|
640
|
+
let initial = initialMasterPage;
|
|
641
|
+
let boundaries = splits;
|
|
642
|
+
const firstSplit = splits[0];
|
|
643
|
+
if (firstSplit?.index === 0) {
|
|
644
|
+
initial = firstSplit.masterPage;
|
|
645
|
+
boundaries = splits.slice(1);
|
|
646
|
+
}
|
|
647
|
+
const sections = [];
|
|
648
|
+
const masterPages = [];
|
|
649
|
+
for (let segment = 0; segment <= boundaries.length; segment += 1) {
|
|
650
|
+
const start = segment === 0 ? 0 : boundaries[segment - 1].index;
|
|
651
|
+
const end = segment === boundaries.length ? walked.length : boundaries[segment].index;
|
|
652
|
+
const masterPage = segment === 0 ? initial : boundaries[segment - 1].masterPage;
|
|
653
|
+
const geometry = masterPage === void 0 ? void 0 : geometryByMasterPage.get(masterPage);
|
|
654
|
+
const segmentExtents = extents.filter((extent) => extent.startIndex >= start && extent.endIndex <= end).map((extent) => ({
|
|
655
|
+
...extent,
|
|
656
|
+
startIndex: extent.startIndex - start,
|
|
657
|
+
endIndex: extent.endIndex - start
|
|
658
|
+
}));
|
|
659
|
+
const blocks = insertOdfConstructMarkers(walked.slice(start, end), segmentExtents);
|
|
660
|
+
sections.push({
|
|
661
|
+
pageSize: geometry?.pageSize ?? PAGE_SIZE_A4,
|
|
662
|
+
margins: geometry?.margins ?? DEFAULT_MARGINS,
|
|
663
|
+
blocks,
|
|
664
|
+
...segment > 0 ? { breakType: "nextPage" } : {}
|
|
665
|
+
});
|
|
666
|
+
masterPages.push(masterPage);
|
|
667
|
+
}
|
|
668
|
+
return {
|
|
669
|
+
sections,
|
|
670
|
+
masterPages
|
|
671
|
+
};
|
|
672
|
+
}
|
|
581
673
|
function readOdtContent(pkg, options = {}) {
|
|
582
674
|
const contentPart = pkg.parts[CONTENT_PART$1];
|
|
583
675
|
if (contentPart?.kind !== "xml") throw new Error(`readOdtContent: package has no ${CONTENT_PART$1} part`);
|
|
@@ -586,7 +678,13 @@ function readOdtContent(pkg, options = {}) {
|
|
|
586
678
|
const textElement = body === void 0 ? void 0 : findChildElement(body.children, "office:text");
|
|
587
679
|
if (textElement === void 0) throw new Error(`readOdtContent: ${CONTENT_PART$1} has no office:body/office:text element`);
|
|
588
680
|
const metadata = readOdfMetadata(pkg);
|
|
589
|
-
const
|
|
681
|
+
const masterPageElements = readOdfMasterPageElements(pkg);
|
|
682
|
+
const geometryByMasterPage = /* @__PURE__ */ new Map();
|
|
683
|
+
for (const masterPage of masterPageElements) {
|
|
684
|
+
const name = attrValue(masterPage, "style:name");
|
|
685
|
+
if (name !== void 0) geometryByMasterPage.set(name, resolveMasterPageGeometry(pkg, masterPage));
|
|
686
|
+
}
|
|
687
|
+
const firstMasterPageName = masterPageElements.map((masterPage) => attrValue(masterPage, "style:name")).find((name) => name !== void 0);
|
|
590
688
|
const provenanceRegions = /* @__PURE__ */ new Map();
|
|
591
689
|
collectOdfProvenanceRegions(textElement.children, provenanceRegions);
|
|
592
690
|
const definitions = {
|
|
@@ -608,6 +706,10 @@ function readOdtContent(pkg, options = {}) {
|
|
|
608
706
|
wrapperExtents: [],
|
|
609
707
|
markerEvents: [],
|
|
610
708
|
liftFrames: options.frames !== "none",
|
|
709
|
+
sectionSplits: [],
|
|
710
|
+
masterPageByStyleName: /* @__PURE__ */ new Map(),
|
|
711
|
+
packageResidue: {},
|
|
712
|
+
masterPage: firstMasterPageName,
|
|
611
713
|
order: 0
|
|
612
714
|
};
|
|
613
715
|
const walked = readBlocks(textElement.children, pkg, state);
|
|
@@ -622,24 +724,49 @@ function readOdtContent(pkg, options = {}) {
|
|
|
622
724
|
descriptor
|
|
623
725
|
});
|
|
624
726
|
}
|
|
727
|
+
const { sections, masterPages } = splitOdtSections(walked, extents, state.sectionSplits, firstMasterPageName, geometryByMasterPage);
|
|
728
|
+
const headerFooterParts = [];
|
|
729
|
+
for (const masterPage of masterPageElements) {
|
|
730
|
+
const masterPageName = attrValue(masterPage, "style:name");
|
|
731
|
+
if (masterPageName === void 0) continue;
|
|
732
|
+
for (const child of masterPage.children) {
|
|
733
|
+
if (child.type !== "element") continue;
|
|
734
|
+
const slot = ODT_HEADER_FOOTER_TAGS.get(child.tag);
|
|
735
|
+
if (slot === void 0 || attrValue(child, "style:display") === "false") continue;
|
|
736
|
+
const blocks = readOdfConstructBodyBlocks(child, pkg, {
|
|
737
|
+
provenanceRegions,
|
|
738
|
+
definitions,
|
|
739
|
+
listIdState: state.listIdState,
|
|
740
|
+
format: "odt"
|
|
741
|
+
}, state.listIdState);
|
|
742
|
+
if (blocks.length > 0) headerFooterParts.push({
|
|
743
|
+
masterPage: masterPageName,
|
|
744
|
+
kind: slot.kind,
|
|
745
|
+
variant: slot.variant,
|
|
746
|
+
blocks
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
const packageResidue = { ...state.packageResidue };
|
|
751
|
+
collectOdfNonContentPartResidue(pkg, "odt", packageResidue);
|
|
625
752
|
return {
|
|
626
753
|
metadata,
|
|
627
|
-
sections
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
}
|
|
632
|
-
...Object.keys(definitions.entries).length > 0 ? { definitions: definitions.entries } : {}
|
|
754
|
+
sections,
|
|
755
|
+
...Object.keys(definitions.entries).length > 0 ? { definitions: definitions.entries } : {},
|
|
756
|
+
...headerFooterParts.length > 0 ? { headerFooterParts } : {},
|
|
757
|
+
...masterPageElements.length > 0 ? { sectionMasterPages: masterPages } : {},
|
|
758
|
+
...Object.keys(packageResidue).length > 0 ? { source: packageResidue } : {}
|
|
633
759
|
};
|
|
634
760
|
}
|
|
635
761
|
function readOdt(pkg, options = {}) {
|
|
636
|
-
const { metadata, sections, definitions } = readOdtContent(pkg, options);
|
|
762
|
+
const { metadata, sections, definitions, source } = readOdtContent(pkg, options);
|
|
637
763
|
const assembled = assemblePackage({
|
|
638
764
|
kind: "wordprocessing",
|
|
639
765
|
metadata,
|
|
640
766
|
sections
|
|
641
767
|
});
|
|
642
768
|
if (definitions !== void 0) assembled.definitions = definitions;
|
|
769
|
+
if (source !== void 0) assembled.source = source;
|
|
643
770
|
return assembled;
|
|
644
771
|
}
|
|
645
772
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { l as XmlElement } from "./node-CkBWRjNR.js";
|
|
2
2
|
import { r as Package } from "./package-BUojjTXf.js";
|
|
3
|
-
import {
|
|
3
|
+
import { l as OdfResidueFormat } from "./constructs-B1yajQJB.js";
|
|
4
4
|
import { Box, ContentDocument, ContentEmbeddedObjectKind, SourceResidue } from "document-schema.js";
|
|
5
5
|
//#region src/typed/draw/embedded.d.ts
|
|
6
6
|
type EmbeddedDocumentKind = ContentEmbeddedObjectKind;
|