odf.js 1.13.1 → 2.0.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 +15 -3
- package/dist/index.cjs +8 -0
- package/dist/index.d.cts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +6 -3
- package/dist/ns.cjs +2 -1
- package/dist/ns.d.cts +1 -0
- package/dist/ns.d.ts +1 -0
- package/dist/ns.js +2 -1
- package/dist/typed/draw/shapes.cjs +71 -27
- package/dist/typed/draw/shapes.d.cts +4 -1
- package/dist/typed/draw/shapes.d.ts +4 -1
- package/dist/typed/draw/shapes.js +71 -27
- package/dist/typed/formula/read.cjs +14 -0
- package/dist/typed/formula/read.d.cts +3 -2
- package/dist/typed/formula/read.d.ts +3 -2
- package/dist/typed/formula/read.js +14 -1
- package/dist/typed/odb/form.cjs +85 -0
- package/dist/typed/odb/form.d.cts +31 -0
- package/dist/typed/odb/form.d.ts +31 -0
- package/dist/typed/odb/form.js +84 -0
- package/dist/typed/odb/read.cjs +60 -23
- package/dist/typed/odb/read.d.cts +15 -4
- package/dist/typed/odb/read.d.ts +15 -4
- package/dist/typed/odb/read.js +60 -24
- package/dist/typed/odb/report.cjs +161 -0
- package/dist/typed/odb/report.d.cts +48 -0
- package/dist/typed/odb/report.d.ts +48 -0
- package/dist/typed/odb/report.js +160 -0
- package/dist/typed/odb/subdocument.cjs +16 -0
- package/dist/typed/odb/subdocument.d.cts +8 -0
- package/dist/typed/odb/subdocument.d.ts +8 -0
- package/dist/typed/odb/subdocument.js +15 -0
- package/dist/typed/ods/read.cjs +9 -1
- package/dist/typed/ods/read.js +10 -2
- package/dist/typed/shared/table.cjs +94 -7
- package/dist/typed/shared/table.d.cts +9 -2
- package/dist/typed/shared/table.d.ts +9 -2
- package/dist/typed/shared/table.js +94 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -52,12 +52,15 @@ This package is under active development. What's built and shipped:
|
|
|
52
52
|
- **Style interning** (`src/styles/`) — `StyleRegistry`: adopts a part's existing automatic styles on construction, finds-or-mints on `intern()`, fingerprints on canonical serialized properties plus parent style name (never `JSON.stringify`), and is collision-checked across all four style containers a document can have.
|
|
53
53
|
- **Shared typed primitives** (`src/typed/shared/`) — ODF length-unit parsing (`cm`/`mm`/`in`/`pt`/`pc`/`px`), A1-style spreadsheet cell-reference computation with repeat-count cursor advancement, colour/geometry/master-page-size parsing into `document-schema.js`'s own types, ODF's `text:s`/`text:tab`/`text:line-break` whitespace-run decoding, the read-side style cascade (`style:default-style` → parent chain → the referenced style — one layer shorter than OOXML's, since ODF has no separate direct-formatting layer on top), the shared `text:p` → `ContentParagraph`/`ContentRun` and `table:table` → `ContentTable` readers (`readOdfParagraph`/`readOdfTable`) every typed reader below builds on, the `draw:transform`/`draw:g` group-flattening geometry resolver, an `svg:d`/`draw:points` vector-path grammar parser, and `meta.xml` reading.
|
|
54
54
|
- **Typed readers** — `readOdt` (wordprocessing), `readOdp` (presentation slides: `draw:frame`/`draw:g` text/image/table content), `readOdg` (drawing pages: every vector primitive — `draw:rect`/`draw:ellipse`/`draw:circle`/`draw:line`/`draw:path`/`draw:polygon`/`draw:polyline`, plus a recognised `draw:custom-shape` preset subset — in real `draw:z-index`-aware paint order), and `readOds` (spreadsheets: geometry- and print-settings-rich, every `office:value-type` variant with its own OpenFormula string) each resolve a `Package` into `document-schema.js`'s own `ContentSection`/`ContentSlide`/`ContentDrawPage`/`ContentSheet` shapes.
|
|
55
|
-
- **`readOdfFormula`** resolves a standalone or embedded `.odf` formula's `content.xml` — bare MathML with no `office:document-content` wrapper, confirmed against real LibreOffice output — into its raw MathML nodes plus, when present, the formula's own native StarMath annotation string.
|
|
55
|
+
- **`readOdfFormula`** resolves a standalone or embedded `.odf` formula's `content.xml` — bare MathML with no `office:document-content` wrapper, confirmed against real LibreOffice output — into its raw MathML nodes plus, when present, the formula's own native StarMath annotation string, in this reader's own bespoke `OdfFormulaDocument` shape. **`readOdfFormulaDocument`** wraps that same result into a real `document-schema.js` `ContentDocument` of kind `'formula'` — `document-schema.js` 2.0.0 added a `MathMlNode`/`ContentFormula` pivot shape for exactly this, a structural mirror of this package's own `XmlNode` that `readOdfFormula`'s real output assigns to with zero cast.
|
|
56
56
|
- **`readOdm`** resolves a `.odm` master document's own `content.xml` into an ordered list of chapter references (`{ name, href, filterName? }`, one per top-level linked `text:section`) without opening the external `.odt` files those references point at. A master document's chapters are genuinely external files by ODF design, not embedded package sub-documents — confirmed against real LibreOffice output, which never caches a chapter's own content inside the master document itself (see `src/typed/odm/read.ts`'s own top-of-file note).
|
|
57
|
-
- **`readOdbInventory`** resolves a `.odb` database front-end package into connection info
|
|
57
|
+
- **`readOdbInventory`** resolves a `.odb` database front-end package into connection info, its table *names*, its query *definitions* (name, real `db:command` SQL text, and `db:escape-processing` when declared), and its forms/reports as `{ name, href }` pairs. Confirmed against real LibreOffice output that `office:database` lives directly in the package's ordinary `content.xml` (no separate `database/connection.xml` part, contrary to the OASIS schema's own chapter layout suggesting one), that queries are declared inline (`db:queries/db:query`, no manifest part of their own), and that a live engine's own tables have no ODF-level manifest listing at all. A form's/report's sub-document directory is named after an opaque *persistent* name (`forms/Obj11`), **not** after the form/report — the user-visible name lives only in `content.xml`'s own `db:forms`/`db:reports` registry, which is where this reader takes both the name and the href from. See `src/typed/odb/read.ts`'s own top-of-file note for the full findings.
|
|
58
|
+
- **`readOdbForm`** and **`readOdbReport`** open one of those sub-documents and extract its *static structure*, executing nothing. A form sub-document is a complete, ordinary ODF text document (`readOdt` reads it unmodified through `subDocumentPackage`, a synthetic sub-`Package` view over the sub-document's own directory) plus an `office:text/office:forms` control tree: per form, its `form:command`/`form:command-type` binding, every control's real element tag, UNO control implementation and `form:data-field` binding, and any genuinely nested sub-form with its own independent binding. A report sub-document uses the `rpt:` Report Builder vocabulary: the `rpt:command`/`rpt:command-type` data binding, the band stack (report header, page header, detail, page footer, report footer), the recursive group tree with each group's own expression/sort/page-break attributes and header/footer bands, every band's bound fields (`field:[COLUMN]`, unwrapped into a real column name) and computed expressions (`rpt:SUM([AMOUNT])`, left verbatim), and the report's own `rpt:function` declarations. Both are grounded in a real, LibreOffice-generated fixture rather than in the schema — which is what caught the two shapes an assumed reading gets wrong: the detail band is nested *inside the innermost group*, not a sibling of the other bands, and a group's key is a formula (`rpt:HASCHANGED("REGION")`), not a bare column name. See `src/typed/odb/form.ts`'s and `src/typed/odb/report.ts`'s own top-of-file notes.
|
|
58
59
|
|
|
59
60
|
Not yet built: live-view editors and the `.odb` database-table-export subsystem. This section will be replaced with real usage examples once those land — see the [Architecture](#architecture) section below for the intended shape, and this repository's own commit history/releases for current progress.
|
|
60
61
|
|
|
62
|
+
A general-purpose SQL query engine for actually rendering a Report against its data — as opposed to reading the report's own static `rpt:command`/band/group definition, which `readOdbReport` already does — has been deliberately **not attempted**, not merely left unstarted. `readOdbInventory` already extracts a query's or report's real `db:command`/`rpt:command` SQL text verbatim, and a rough survey against the one real fixture this package has (`src/typed/odb/fixtures/form-and-report.odb`) suggests the underlying query text itself would often fall inside a plausible bounded SQL subset (single-table `SELECT`/`WHERE`/`ORDER BY`, no `JOIN`s or subqueries) — but that survey is a sample size of one report and should not be read as a real coverage figure. Building even a bounded engine against it means reimplementing a slice of HSQLDB's/Firebird's own query semantics, which is a materially different undertaking from decoding their file formats (already done safely elsewhere in this package's `.odb` support) and raises its own licensing questions that have not yet been reviewed. This is gated on the requesting engineer's own explicit sign-off on that licensing posture, given after reading the relevant engine source — not given yet — before any such engine is built.
|
|
63
|
+
|
|
61
64
|
## Getting started
|
|
62
65
|
|
|
63
66
|
Requires Node.js `>=20` and pnpm `11.6.0` (pinned via `packageManager` in `package.json`).
|
|
@@ -123,7 +126,7 @@ Layered from a lossless core outward, mirroring `ooxml.js`'s own structure:
|
|
|
123
126
|
- **`src/manifest.ts`** — unlike `ooxml.js` (which only ever *reads* OPC relationships, leaving writing to `documents.js`), `odf.js` owns manifest read **and** write, since the manifest is ODF's one mandatory part and its correctness is exhaustive.
|
|
124
127
|
- **`src/styles/`** — `properties.ts` (the property-bag shape + real ODF attribute parsing), `serialize.ts` (canonical, deterministic property-bag → XML attributes), `registry.ts` (`StyleRegistry`, ODF's mandatory style-interning layer, no OOXML equivalent), `span.ts` (character-range wrapping into a formattable `text:span`, correctly splitting `text:s`/`text:tab` elements that straddle a boundary).
|
|
125
128
|
- **`src/typed/shared/`** — the ODF-specific typed primitives every future format reader builds on: `units.ts`, `a1.ts`, `color.ts`/`geometry.ts` (parsing into `document-schema.js`'s own types, never redefining them), `style.ts` (a thin re-export — ODF's style-properties concern is fully covered by `styles/properties.ts` and the cascade below), `text.ts` (whitespace-run decoding), `cascade.ts` (the read-side style-resolution walk), `paragraph.ts`/`table.ts` (`readOdfParagraph`/`readOdfTable`, the shared `text:p` → `ContentParagraph`/`ContentRun` and `table:table` → `ContentTable` readers `readOdt`, `readOds`, and `typed/draw/shapes.ts` all call), `transform.ts` (the `draw:transform`/`draw:g` group-flattening geometry resolver), `masterpage.ts` (master-page → page-layout page-size/print-settings resolution, shared by a `draw:page`'s own size and a spreadsheet's print settings), `path.ts` (an `svg:d`/`draw:points` vector-path grammar parser), `metadata.ts` (`meta.xml` reading).
|
|
126
|
-
- **`src/typed/odt/`, `src/typed/odp/`, `src/typed/odg/`, `src/typed/ods/`** — the built `readOdt`/`readOdp`/`readOdg`/`readOds` readers; **`src/typed/draw/`** — the `draw:frame`/`draw:g`/vector-primitive shape vocabulary `readOdp` and `readOdg` both share; **`src/typed/formula/`, `src/typed/odm/`** — `readOdfFormula` (raw MathML,
|
|
129
|
+
- **`src/typed/odt/`, `src/typed/odp/`, `src/typed/odg/`, `src/typed/ods/`** — the built `readOdt`/`readOdp`/`readOdg`/`readOds` readers; **`src/typed/draw/`** — the `draw:frame`/`draw:g`/vector-primitive shape vocabulary `readOdp` and `readOdg` both share; **`src/typed/formula/`, `src/typed/odm/`** — `readOdfFormula`/`readOdfFormulaDocument` (raw MathML, and the `document-schema.js` `ContentDocument` 'formula'-kind pivot built on top of it) and `readOdm` (a `.odm` master document's own external chapter references — name/href/filter-name per linked `text:section`, never the linked content itself); **`src/typed/odb/`** — `readOdbInventory` (a `.odb` package's own connection info, table/query/form/report registry, never the database engine's own storage), plus `readOdbForm`/`readOdbReport` (static, execution-free structure extraction from a form's or report's own ODF sub-document) and `subDocumentPackage` (the synthetic sub-`Package` view they read those sub-documents through).
|
|
127
130
|
|
|
128
131
|
## Why no `ooxml.js` dependency
|
|
129
132
|
|
|
@@ -144,6 +147,15 @@ See the top of this README — the short version: `ooxml.js`'s branding and sign
|
|
|
144
147
|
- **`meta:keyword` appears once per keyword**, unlike OOXML's single comma-separated `cp:keywords` element.
|
|
145
148
|
- **`table:number-columns-repeated`/`table:number-rows-repeated` must be cursor-advanced, never materialized.** A real spreadsheet has trailing cells/rows with repeat counts over a million; `typed/shared/a1.ts`'s cursor advances in O(1) without allocating that many objects — tested against a real repeat count taken from a genuine LibreOffice template.
|
|
146
149
|
- **ODF cells carry no explicit cell-reference attribute at all** (unlike xlsx's `r="B7"`) — `typed/shared/a1.ts` computes A1-style references from a running column/row cursor as a reader walks cells in document order.
|
|
150
|
+
- **A rotated `draw:rect`/`draw:ellipse`/`draw:path`/`draw:custom-shape` vector primitive now reads its own `rotationDeg`, not just its unrotated bounding frame.** `resolveVectorGeometry` (`typed/draw/shapes.ts`) replaces the old frame-only `resolveVectorFrame`, reusing the exact same `resolveOdfShapeGeometry`/`composeOdfGroupTransform` machinery `draw:frame` already resolved rotation through, including composing an enclosing `draw:g`'s own rotation the same way it already did for a frame. `ContentVectorSchema`'s rect/ellipse/path variants already carried a `rotationDeg` field before this change — it was being discarded on the read side, not missing from the schema.
|
|
151
|
+
- **Every `ContentShape`/`ContentVector` a drawing or presentation reader produces is now stamped with its own resolved `paintOrder`, not merely sorted by it and discarded.** `walkDrawPageContent` (odg) and `walkDrawShapes` (odp) both compute a real z-index per element — an explicit `draw:z-index` when present, otherwise a monotonic document-encounter counter — purely to order their own output arrays; that value is now attached to each produced value via the same single counter threaded across the whole walk. Because `shapes` and `vectors` are stamped from the identical counter, a caller can recover their true relative paint order across the two independently-ordered arrays by comparing `paintOrder` directly — closing the cross-array ordering gap `documents.js`'s own README previously described as unrecoverable, even though `ContentDrawPageSchema` itself still keeps the two arrays with no shared ordering field of its own.
|
|
152
|
+
- **`svg:fill-rule` (`nonzero`/`evenodd`) and `draw:stroke`'s `solid`/`dash` enumeration are now read and mapped onto `ContentVector`'s path-variant `fillRule` and `ContentStroke.style`.** Both mappings are confirmed against the OASIS schema reference rather than only against real-world producer output — `typed/draw/shapes.ts`'s own comment notes that a live-LibreOffice re-verification of `svg:fill-rule` specifically was blocked by the same headless-`soffice`-hang constraint `documents.js`'s own README documents. A genuinely dotted (as opposed to dashed) stroke pattern, and a `"double"` stroke style ODF's own vector-stroke model has no concept of at all, both remain unread — real, permanent boundaries rather than oversights (see that file's own comment for why each).
|
|
153
|
+
- **`readOds` and the shared `readTableCell` (odt/odp table cells) now resolve `fo:background-color`, the `fo:border`/`fo:border-(left|right|top|bottom)` shorthand-and-per-edge-override chain, `style:vertical-align`, and a cell style's own `style:paragraph-properties` `fo:text-align` from the real ODF style cascade**, populating `ContentSheetCell`/`ContentTableCell`'s `background`/`borders` (plus `ContentSheetCell`'s own `alignment`/`verticalAlignment`) rather than leaving them unpopulated. `readCellStyleDecoration` (`typed/shared/table.ts`) is the one fold both callers share: `readOds` resolves it over the full root-to-target `style:parent-style-name` chain (`resolveStyleElementChain`, confirmed against this package's own `kitchen-sink.ods` fixture's real `ce1`..`ce5` → `Default` chain), `readTableCell` over the single style element `findStyleElement` already resolves. An explicit `fo:border-*` override of `"none"`/`"hidden"` genuinely clears an inherited edge rather than merely leaving it unmentioned.
|
|
154
|
+
- **`readOdfFormulaDocument` now wraps a formula's raw MathML into a real `document-schema.js` `ContentDocument` of kind `'formula'`**, alongside (not instead of) this package's own pre-existing bespoke `OdfFormulaDocument` shape from `readOdfFormula`, which is unchanged. `document-schema.js` 2.0.0 added the `MathMlNode`/`ContentFormula` pivot specifically for this — a structural mirror of this package's own `XmlNode` that `readOdfFormula`'s existing return value assigns into with zero cast.
|
|
155
|
+
- **`readOdbInventory`'s `queries` now carry each query's real `db:command` SQL text (plus `db:escape-processing` when declared) instead of only a bare name.** `OdbInventory.queries` is now `OdbQueryInfo[]` (`{ name, command, escapeProcessing? }`), a breaking rename from the previous `string[]` — a query's own `db:command` is already inline in `content.xml`, unlike a form/report/table's real content, which lives in a separate sub-document or database engine this reader never opens, so the "content lives elsewhere, only names are read" rule that correctly applies to those does not hold for a query. `db:command` is entity-decoded before being returned, matching every other typed reader's convention.
|
|
156
|
+
- **`.odb` Form/Report structure extraction is real and working, grounded in a genuine LibreOffice-generated fixture, not blocked.** `readOdbForm`/`readOdbReport` open a form's or report's own sub-document (via `subDocumentPackage`, a synthetic sub-`Package` view over its directory) and extract its complete static structure — command bindings, control trees, nested sub-forms, the band/group hierarchy, bound and computed expressions — executing nothing. See the Architecture section above and `src/typed/odb/form.ts`/`report.ts`'s own top-of-file notes for the two real shapes this fixture caught that an assumed reading would have got wrong. **A SQL/`rpt:` rendering engine to actually execute a query or evaluate a report's own totals against real data is deliberately not attempted**, not merely unstarted — that is a materially different, larger undertaking (reimplementing a slice of HSQLDB's/Firebird's own query semantics) with its own unreviewed licensing question, gated on the requesting engineer's explicit sign-off after reading the relevant engine source. See the bounded-SQL-subset assessment immediately below for exactly how far the *reading* side alone gets you.
|
|
157
|
+
|
|
158
|
+
- **A bounded-SQL-subset assessment for Report rendering exists for exactly one real report, and it should be read that way.** `src/typed/odb/fixtures/form-and-report.odb`'s own "SalesByRegion" report is bound (`rpt:command-type="query"`) to a saved query whose real SQL text is `SELECT "SALES"."REGION", "SALES"."QUARTER", "SALES"."CUSTOMER", "SALES"."AMOUNT" FROM "SALES" WHERE "SALES"."AMOUNT" >= 100 ORDER BY "SALES"."REGION" ASC, "SALES"."QUARTER" ASC, "SALES"."AMOUNT" DESC` — single-table, a simple comparison `WHERE`, a multi-column `ORDER BY`, no `JOIN`, no subquery, and (in the SQL itself) no `GROUP BY` or aggregate function at all. That one query sits entirely inside the bounded subset described above. The fixture's bound form is even simpler: its top-level `form:form` binds directly to the bare table name `SALES` (`form:command-type="table"`), equivalent to an unconditional `SELECT * FROM "SALES"`. On this single data point, 100% of the real `.odb` command bindings seen so far (one query, one table binding, one repeat use of the same query from a nested sub-form) fall inside the bounded subset — but a sample of one report from one fixture says essentially nothing about the real-world distribution of `.odb` files in the wild, and should not be quoted as a coverage percentage beyond "the one file we have." **A more consequential finding sits alongside the SQL text itself: even a fully bounded SQL engine would not be sufficient to render this one report.** The report's own grouping breaks (`rpt:HASCHANGED("REGION")`, `rpt:HASCHANGED("LEFT_QUARTER")`), its prefix-character grouping function (`rpt:LEFT([QUARTER];2)`), and its running per-group/per-report totals (`rpt:SUM([AMOUNT])`) are all evaluated by Report Builder's own `rpt:` formula language over the plain, ungrouped, ordered row stream the SQL query returns — LibreOffice does not express any of that as SQL `GROUP BY`/aggregate syntax at all. Rendering even this one simple report therefore needs a bounded SQL engine *and* a separate `rpt:` formula evaluator (`HASCHANGED`, `LEFT`, `SUM`, and whatever else real reports use) — two genuinely different pieces of engine-semantics reimplementation, not one.
|
|
147
159
|
|
|
148
160
|
## Release and publishing
|
|
149
161
|
|
package/dist/index.cjs
CHANGED
|
@@ -41,6 +41,9 @@ const require_typed_ods_read = require("./typed/ods/read.cjs");
|
|
|
41
41
|
const require_typed_formula_read = require("./typed/formula/read.cjs");
|
|
42
42
|
const require_typed_odm_read = require("./typed/odm/read.cjs");
|
|
43
43
|
const require_typed_odb_read = require("./typed/odb/read.cjs");
|
|
44
|
+
const require_typed_odb_subdocument = require("./typed/odb/subdocument.cjs");
|
|
45
|
+
const require_typed_odb_form = require("./typed/odb/form.cjs");
|
|
46
|
+
const require_typed_odb_report = require("./typed/odb/report.cjs");
|
|
44
47
|
let document_schema_js = require("document-schema.js");
|
|
45
48
|
Object.defineProperty(exports, "AlignmentSchema", {
|
|
46
49
|
enumerable: true,
|
|
@@ -130,8 +133,11 @@ exports.readDrawFrame = require_typed_draw_shapes.readDrawFrame;
|
|
|
130
133
|
exports.readDrawPageContent = require_typed_draw_shapes.readDrawPageContent;
|
|
131
134
|
exports.readManifest = require_manifest.readManifest;
|
|
132
135
|
exports.readMimetype = require_mimetype.readMimetype;
|
|
136
|
+
exports.readOdbForm = require_typed_odb_form.readOdbForm;
|
|
133
137
|
exports.readOdbInventory = require_typed_odb_read.readOdbInventory;
|
|
138
|
+
exports.readOdbReport = require_typed_odb_report.readOdbReport;
|
|
134
139
|
exports.readOdfFormula = require_typed_formula_read.readOdfFormula;
|
|
140
|
+
exports.readOdfFormulaDocument = require_typed_formula_read.readOdfFormulaDocument;
|
|
135
141
|
exports.readOdfMetadata = require_typed_shared_metadata.readOdfMetadata;
|
|
136
142
|
exports.readOdfParagraph = require_typed_shared_paragraph.readOdfParagraph;
|
|
137
143
|
exports.readOdfTable = require_typed_shared_table.readOdfTable;
|
|
@@ -141,6 +147,7 @@ exports.readOdp = require_typed_odp_read.readOdp;
|
|
|
141
147
|
exports.readOds = require_typed_ods_read.readOds;
|
|
142
148
|
exports.readOdt = require_typed_odt_read.readOdt;
|
|
143
149
|
exports.resolveDrawPageSize = require_typed_shared_masterpage.resolveDrawPageSize;
|
|
150
|
+
exports.resolveOdbComponent = require_typed_odb_read.resolveOdbComponent;
|
|
144
151
|
exports.resolveOdfShapeGeometry = require_typed_shared_transform.resolveOdfShapeGeometry;
|
|
145
152
|
exports.resolvePageLayoutProperties = require_typed_shared_masterpage.resolvePageLayoutProperties;
|
|
146
153
|
exports.resolveStyle = require_typed_shared_cascade.resolveStyle;
|
|
@@ -150,6 +157,7 @@ exports.scaleOdfRawPoint = require_typed_shared_path.scaleOdfRawPoint;
|
|
|
150
157
|
exports.serializePackage = require_package_io_write.serializePackage;
|
|
151
158
|
exports.setDocumentMediaType = require_manifest.setDocumentMediaType;
|
|
152
159
|
exports.sniffImageFormat = require_image_sniff.sniffImageFormat;
|
|
160
|
+
exports.subDocumentPackage = require_typed_odb_subdocument.subDocumentPackage;
|
|
153
161
|
exports.sumOdfNodeLength = require_typed_shared_text.sumOdfNodeLength;
|
|
154
162
|
exports.syncManifest = require_manifest.syncManifest;
|
|
155
163
|
exports.textPropertiesToAttributes = require_styles_properties.textPropertiesToAttributes;
|
package/dist/index.d.cts
CHANGED
|
@@ -37,7 +37,10 @@ import { OdpDocument, readOdp } from "./typed/odp/read.cjs";
|
|
|
37
37
|
import { OdtDocument, readOdt } from "./typed/odt/read.cjs";
|
|
38
38
|
import { OdgDocument, readOdg } from "./typed/odg/read.cjs";
|
|
39
39
|
import { OdsDocument, readOds } from "./typed/ods/read.cjs";
|
|
40
|
-
import { OdfFormulaDocument, readOdfFormula } from "./typed/formula/read.cjs";
|
|
40
|
+
import { OdfFormulaDocument, readOdfFormula, readOdfFormulaDocument } from "./typed/formula/read.cjs";
|
|
41
41
|
import { OdmDocument, OdmSection, readOdm } from "./typed/odm/read.cjs";
|
|
42
|
-
import { OdbConnectionInfo, OdbInventory, readOdbInventory } from "./typed/odb/read.cjs";
|
|
43
|
-
|
|
42
|
+
import { OdbComponentInfo, OdbConnectionInfo, OdbInventory, OdbQueryInfo, readOdbInventory, resolveOdbComponent } from "./typed/odb/read.cjs";
|
|
43
|
+
import { SubDocumentPackageOptions, subDocumentPackage } from "./typed/odb/subdocument.cjs";
|
|
44
|
+
import { OdbForm, OdbFormControl, OdbFormDefinition, readOdbForm } from "./typed/odb/form.cjs";
|
|
45
|
+
import { OdbReport, OdbReportBand, OdbReportElement, OdbReportFunction, OdbReportGroup, readOdbReport } from "./typed/odb/report.cjs";
|
|
46
|
+
export { type Alignment, AlignmentSchema, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type BuildManifestOptions, type CascadeDiagnostic, type DrawPageContent, type ImageFormat, type InternRequest, type LengthUnit, MANIFEST_PART, META_PART, MIMETYPE_PART, type Manifest, type ManifestEntry, ManifestEntrySchema, type ManifestProblem, ManifestProblemSchema, ManifestSchema, ODF_MEDIA_TYPES, ODF_NAMESPACES, type OdbComponentInfo, type OdbConnectionInfo, type OdbForm, type OdbFormControl, type OdbFormDefinition, type OdbInventory, type OdbQueryInfo, type OdbReport, type OdbReportBand, type OdbReportElement, type OdbReportFunction, type OdbReportGroup, type OdfExtension, type OdfFormulaDocument, type OdfNamespacePrefix, type OdfPoint, type OdfRawPoint, type OdfRawSegment, type OdfRawSubpath, type OdfShapeGeometry, type OdfTransformFunction, type OdfViewBox, type OdgDocument, type OdmDocument, type OdmSection, type OdpDocument, type OdsDocument, type OdtDocument, type OtherPartRef, type Package, PackageSchema, type ParsedProperties, type Part, PartSchema, STYLE_FAMILIES, type StyleCascadeResult, type StyleElementChainResult, type StyleFamily, type StyleProperties, StylePropertiesSchema, StyleRegistry, type StyleRegistryOptions, type SubDocumentPackageOptions, TableCursor, type XmlCdata, XmlCdataSchema, type XmlComment, XmlCommentSchema, type XmlDeclaration, XmlDeclarationSchema, type XmlElement, XmlElementSchema, type XmlNode, XmlNodeSchema, type XmlPart, XmlPartSchema, type XmlPi, XmlPiSchema, type XmlText, XmlTextSchema, type ZipEntry, applyOdfTransform, attrValue, base64ToBytes, buildManifest, buildOdfSubpaths, buildStylePropertyElements, buildXml, bytesToBase64, canonicalPropertiesString, cellReference, childrenWithTag, columnIndexToLetters, columnLettersToIndex, composeOdfGroupTransform, decodeOdfText, decodePackage, decodeXmlText, el, elementsWithTag, encodePackage, encodeXmlText, ensureSpan, findChildElement, findStyleElement, formatOdfColor, formatOdfLength, formatPercentageMultiplier, formatPt, getOdfSpaceCount, isStyleFamily, isXmlNode, measureOdfNodeLength, mediaTypeForExtension, netRotationDeg, packageCodec, paragraphPropertiesToAttributes, parseBox, parseCellReference, parseOdfLength as parseLength, parseOdfLength, parseLinePoints, parseMargins, parseOdfColor, parseOdfPathData, parseOdfPointsList, parseOdfTransform, parseOdfViewBox, parsePackage, parsePageSize, parseParagraphProperties, parseStyleElementProperties, parseTextProperties, parseXml, rawSubpathFromPoints, readDrawFrame, readDrawPageContent, readManifest, readMimetype, readOdbForm, readOdbInventory, readOdbReport, readOdfFormula, readOdfFormulaDocument, readOdfMetadata, readOdfParagraph, readOdfTable, readOdg, readOdm, readOdp, readOds, readOdt, resolveDrawPageSize, resolveOdbComponent, resolveOdfShapeGeometry, resolvePageLayoutProperties, resolveStyle, resolveStyleElementChain, rootElement, scaleOdfRawPoint, serializePackage, setDocumentMediaType, sniffImageFormat, subDocumentPackage, sumOdfNodeLength, syncManifest, textPropertiesToAttributes, txt, unzipPackage, validateManifest, walkDrawShapes, writeManifest, writeMimetype, xmlCodec, xmlnsAttributes, zipPackage };
|
package/dist/index.d.ts
CHANGED
|
@@ -37,7 +37,10 @@ import { OdpDocument, readOdp } from "./typed/odp/read.js";
|
|
|
37
37
|
import { OdtDocument, readOdt } from "./typed/odt/read.js";
|
|
38
38
|
import { OdgDocument, readOdg } from "./typed/odg/read.js";
|
|
39
39
|
import { OdsDocument, readOds } from "./typed/ods/read.js";
|
|
40
|
-
import { OdfFormulaDocument, readOdfFormula } from "./typed/formula/read.js";
|
|
40
|
+
import { OdfFormulaDocument, readOdfFormula, readOdfFormulaDocument } from "./typed/formula/read.js";
|
|
41
41
|
import { OdmDocument, OdmSection, readOdm } from "./typed/odm/read.js";
|
|
42
|
-
import { OdbConnectionInfo, OdbInventory, readOdbInventory } from "./typed/odb/read.js";
|
|
43
|
-
|
|
42
|
+
import { OdbComponentInfo, OdbConnectionInfo, OdbInventory, OdbQueryInfo, readOdbInventory, resolveOdbComponent } from "./typed/odb/read.js";
|
|
43
|
+
import { SubDocumentPackageOptions, subDocumentPackage } from "./typed/odb/subdocument.js";
|
|
44
|
+
import { OdbForm, OdbFormControl, OdbFormDefinition, readOdbForm } from "./typed/odb/form.js";
|
|
45
|
+
import { OdbReport, OdbReportBand, OdbReportElement, OdbReportFunction, OdbReportGroup, readOdbReport } from "./typed/odb/report.js";
|
|
46
|
+
export { type Alignment, AlignmentSchema, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type BuildManifestOptions, type CascadeDiagnostic, type DrawPageContent, type ImageFormat, type InternRequest, type LengthUnit, MANIFEST_PART, META_PART, MIMETYPE_PART, type Manifest, type ManifestEntry, ManifestEntrySchema, type ManifestProblem, ManifestProblemSchema, ManifestSchema, ODF_MEDIA_TYPES, ODF_NAMESPACES, type OdbComponentInfo, type OdbConnectionInfo, type OdbForm, type OdbFormControl, type OdbFormDefinition, type OdbInventory, type OdbQueryInfo, type OdbReport, type OdbReportBand, type OdbReportElement, type OdbReportFunction, type OdbReportGroup, type OdfExtension, type OdfFormulaDocument, type OdfNamespacePrefix, type OdfPoint, type OdfRawPoint, type OdfRawSegment, type OdfRawSubpath, type OdfShapeGeometry, type OdfTransformFunction, type OdfViewBox, type OdgDocument, type OdmDocument, type OdmSection, type OdpDocument, type OdsDocument, type OdtDocument, type OtherPartRef, type Package, PackageSchema, type ParsedProperties, type Part, PartSchema, STYLE_FAMILIES, type StyleCascadeResult, type StyleElementChainResult, type StyleFamily, type StyleProperties, StylePropertiesSchema, StyleRegistry, type StyleRegistryOptions, type SubDocumentPackageOptions, TableCursor, type XmlCdata, XmlCdataSchema, type XmlComment, XmlCommentSchema, type XmlDeclaration, XmlDeclarationSchema, type XmlElement, XmlElementSchema, type XmlNode, XmlNodeSchema, type XmlPart, XmlPartSchema, type XmlPi, XmlPiSchema, type XmlText, XmlTextSchema, type ZipEntry, applyOdfTransform, attrValue, base64ToBytes, buildManifest, buildOdfSubpaths, buildStylePropertyElements, buildXml, bytesToBase64, canonicalPropertiesString, cellReference, childrenWithTag, columnIndexToLetters, columnLettersToIndex, composeOdfGroupTransform, decodeOdfText, decodePackage, decodeXmlText, el, elementsWithTag, encodePackage, encodeXmlText, ensureSpan, findChildElement, findStyleElement, formatOdfColor, formatOdfLength, formatPercentageMultiplier, formatPt, getOdfSpaceCount, isStyleFamily, isXmlNode, measureOdfNodeLength, mediaTypeForExtension, netRotationDeg, packageCodec, paragraphPropertiesToAttributes, parseBox, parseCellReference, parseOdfLength as parseLength, parseOdfLength, parseLinePoints, parseMargins, parseOdfColor, parseOdfPathData, parseOdfPointsList, parseOdfTransform, parseOdfViewBox, parsePackage, parsePageSize, parseParagraphProperties, parseStyleElementProperties, parseTextProperties, parseXml, rawSubpathFromPoints, readDrawFrame, readDrawPageContent, readManifest, readMimetype, readOdbForm, readOdbInventory, readOdbReport, readOdfFormula, readOdfFormulaDocument, readOdfMetadata, readOdfParagraph, readOdfTable, readOdg, readOdm, readOdp, readOds, readOdt, resolveDrawPageSize, resolveOdbComponent, resolveOdfShapeGeometry, resolvePageLayoutProperties, resolveStyle, resolveStyleElementChain, rootElement, scaleOdfRawPoint, serializePackage, setDocumentMediaType, sniffImageFormat, subDocumentPackage, sumOdfNodeLength, syncManifest, textPropertiesToAttributes, txt, unzipPackage, validateManifest, walkDrawShapes, writeManifest, writeMimetype, xmlCodec, xmlnsAttributes, zipPackage };
|
package/dist/index.js
CHANGED
|
@@ -37,7 +37,10 @@ import { readOdp } from "./typed/odp/read.js";
|
|
|
37
37
|
import { readOdt } from "./typed/odt/read.js";
|
|
38
38
|
import { readOdg } from "./typed/odg/read.js";
|
|
39
39
|
import { readOds } from "./typed/ods/read.js";
|
|
40
|
-
import { readOdfFormula } from "./typed/formula/read.js";
|
|
40
|
+
import { readOdfFormula, readOdfFormulaDocument } from "./typed/formula/read.js";
|
|
41
41
|
import { readOdm } from "./typed/odm/read.js";
|
|
42
|
-
import { readOdbInventory } from "./typed/odb/read.js";
|
|
43
|
-
|
|
42
|
+
import { readOdbInventory, resolveOdbComponent } from "./typed/odb/read.js";
|
|
43
|
+
import { subDocumentPackage } from "./typed/odb/subdocument.js";
|
|
44
|
+
import { readOdbForm } from "./typed/odb/form.js";
|
|
45
|
+
import { readOdbReport } from "./typed/odb/report.js";
|
|
46
|
+
export { AlignmentSchema, AttributeSchema, BinaryPartSchema, MANIFEST_PART, META_PART, MIMETYPE_PART, ManifestEntrySchema, ManifestProblemSchema, ManifestSchema, ODF_MEDIA_TYPES, ODF_NAMESPACES, PackageSchema, PartSchema, STYLE_FAMILIES, StylePropertiesSchema, StyleRegistry, TableCursor, XmlCdataSchema, XmlCommentSchema, XmlDeclarationSchema, XmlElementSchema, XmlNodeSchema, XmlPartSchema, XmlPiSchema, XmlTextSchema, applyOdfTransform, attrValue, base64ToBytes, buildManifest, buildOdfSubpaths, buildStylePropertyElements, buildXml, bytesToBase64, canonicalPropertiesString, cellReference, childrenWithTag, columnIndexToLetters, columnLettersToIndex, composeOdfGroupTransform, decodeOdfText, decodePackage, decodeXmlText, el, elementsWithTag, encodePackage, encodeXmlText, ensureSpan, findChildElement, findStyleElement, formatOdfColor, formatOdfLength, formatPercentageMultiplier, formatPt, getOdfSpaceCount, isStyleFamily, isXmlNode, measureOdfNodeLength, mediaTypeForExtension, netRotationDeg, packageCodec, paragraphPropertiesToAttributes, parseBox, parseCellReference, parseOdfLength as parseLength, parseOdfLength, parseLinePoints, parseMargins, parseOdfColor, parseOdfPathData, parseOdfPointsList, parseOdfTransform, parseOdfViewBox, parsePackage, parsePageSize, parseParagraphProperties, parseStyleElementProperties, parseTextProperties, parseXml, rawSubpathFromPoints, readDrawFrame, readDrawPageContent, readManifest, readMimetype, readOdbForm, readOdbInventory, readOdbReport, readOdfFormula, readOdfFormulaDocument, readOdfMetadata, readOdfParagraph, readOdfTable, readOdg, readOdm, readOdp, readOds, readOdt, resolveDrawPageSize, resolveOdbComponent, resolveOdfShapeGeometry, resolvePageLayoutProperties, resolveStyle, resolveStyleElementChain, rootElement, scaleOdfRawPoint, serializePackage, setDocumentMediaType, sniffImageFormat, subDocumentPackage, sumOdfNodeLength, syncManifest, textPropertiesToAttributes, txt, unzipPackage, validateManifest, walkDrawShapes, writeManifest, writeMimetype, xmlCodec, xmlnsAttributes, zipPackage };
|
package/dist/ns.cjs
CHANGED
|
@@ -25,7 +25,8 @@ const ODF_NAMESPACES = Object.freeze({
|
|
|
25
25
|
xsd: "http://www.w3.org/2001/XMLSchema",
|
|
26
26
|
xsi: "http://www.w3.org/2001/XMLSchema-instance",
|
|
27
27
|
manifest: "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0",
|
|
28
|
-
db: "urn:oasis:names:tc:opendocument:xmlns:database:1.0"
|
|
28
|
+
db: "urn:oasis:names:tc:opendocument:xmlns:database:1.0",
|
|
29
|
+
rpt: "http://openoffice.org/2005/report"
|
|
29
30
|
});
|
|
30
31
|
function xmlnsAttributes(prefixes) {
|
|
31
32
|
const attrs = {};
|
package/dist/ns.d.cts
CHANGED
|
@@ -25,6 +25,7 @@ declare const ODF_NAMESPACES: Readonly<{
|
|
|
25
25
|
xsi: "http://www.w3.org/2001/XMLSchema-instance";
|
|
26
26
|
manifest: "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0";
|
|
27
27
|
db: "urn:oasis:names:tc:opendocument:xmlns:database:1.0";
|
|
28
|
+
rpt: "http://openoffice.org/2005/report";
|
|
28
29
|
}>;
|
|
29
30
|
type OdfNamespacePrefix = keyof typeof ODF_NAMESPACES;
|
|
30
31
|
declare function xmlnsAttributes(prefixes: readonly OdfNamespacePrefix[]): Record<string, string>;
|
package/dist/ns.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ declare const ODF_NAMESPACES: Readonly<{
|
|
|
25
25
|
xsi: "http://www.w3.org/2001/XMLSchema-instance";
|
|
26
26
|
manifest: "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0";
|
|
27
27
|
db: "urn:oasis:names:tc:opendocument:xmlns:database:1.0";
|
|
28
|
+
rpt: "http://openoffice.org/2005/report";
|
|
28
29
|
}>;
|
|
29
30
|
type OdfNamespacePrefix = keyof typeof ODF_NAMESPACES;
|
|
30
31
|
declare function xmlnsAttributes(prefixes: readonly OdfNamespacePrefix[]): Record<string, string>;
|
package/dist/ns.js
CHANGED
|
@@ -24,7 +24,8 @@ const ODF_NAMESPACES = Object.freeze({
|
|
|
24
24
|
xsd: "http://www.w3.org/2001/XMLSchema",
|
|
25
25
|
xsi: "http://www.w3.org/2001/XMLSchema-instance",
|
|
26
26
|
manifest: "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0",
|
|
27
|
-
db: "urn:oasis:names:tc:opendocument:xmlns:database:1.0"
|
|
27
|
+
db: "urn:oasis:names:tc:opendocument:xmlns:database:1.0",
|
|
28
|
+
rpt: "http://openoffice.org/2005/report"
|
|
28
29
|
});
|
|
29
30
|
function xmlnsAttributes(prefixes) {
|
|
30
31
|
const attrs = {};
|
|
@@ -80,16 +80,20 @@ function readOwnTransformFunctions(element) {
|
|
|
80
80
|
const value = require_xml_query.attrValue(element, "draw:transform");
|
|
81
81
|
return value === void 0 ? [] : require_typed_shared_transform.parseOdfTransform(value);
|
|
82
82
|
}
|
|
83
|
-
function walkDrawShapes(children, groupFunctions, pkg, out) {
|
|
83
|
+
function walkDrawShapes(children, groupFunctions, pkg, out, indexState = { next: 0 }) {
|
|
84
84
|
for (const node of children) {
|
|
85
85
|
if (node.type !== "element") continue;
|
|
86
86
|
if (node.tag === "draw:frame") {
|
|
87
|
+
const zIndex = paintOrderKey(node, indexState);
|
|
87
88
|
const shape = readDrawFrame(node, groupFunctions, pkg);
|
|
88
|
-
if (shape !== void 0) out.push(
|
|
89
|
+
if (shape !== void 0) out.push({
|
|
90
|
+
...shape,
|
|
91
|
+
paintOrder: zIndex
|
|
92
|
+
});
|
|
89
93
|
} else if (node.tag === "draw:g") {
|
|
90
94
|
const ownFunctions = readOwnTransformFunctions(node);
|
|
91
95
|
const nested = ownFunctions.length === 0 ? groupFunctions : [...ownFunctions, ...groupFunctions];
|
|
92
|
-
walkDrawShapes(node.children, nested, pkg, out);
|
|
96
|
+
walkDrawShapes(node.children, nested, pkg, out, indexState);
|
|
93
97
|
}
|
|
94
98
|
}
|
|
95
99
|
}
|
|
@@ -97,7 +101,9 @@ function readOdfFillAndStroke(element, pkg) {
|
|
|
97
101
|
const styleName = require_xml_query.attrValue(element, "draw:style-name");
|
|
98
102
|
const { elements } = require_typed_shared_cascade.resolveStyleElementChain(styleName, "graphic", pkg);
|
|
99
103
|
let fill;
|
|
104
|
+
let fillRule;
|
|
100
105
|
let stroke;
|
|
106
|
+
let strokeStyle;
|
|
101
107
|
for (const styleElement of elements) {
|
|
102
108
|
const props = require_xml_query.childrenWithTag(styleElement, "style:graphic-properties")[0];
|
|
103
109
|
if (props === void 0) continue;
|
|
@@ -107,8 +113,15 @@ function readOdfFillAndStroke(element, pkg) {
|
|
|
107
113
|
const parsedFill = fillColorValue === void 0 ? void 0 : require_typed_shared_color.parseOdfColor(fillColorValue);
|
|
108
114
|
if (parsedFill !== void 0) fill = parsedFill;
|
|
109
115
|
}
|
|
110
|
-
|
|
111
|
-
|
|
116
|
+
const fillRuleValue = require_xml_query.attrValue(props, "svg:fill-rule");
|
|
117
|
+
if (fillRuleValue === "nonzero" || fillRuleValue === "evenodd") fillRule = fillRuleValue;
|
|
118
|
+
const strokeMode = require_xml_query.attrValue(props, "draw:stroke");
|
|
119
|
+
if (strokeMode === "none") {
|
|
120
|
+
stroke = void 0;
|
|
121
|
+
strokeStyle = void 0;
|
|
122
|
+
} else {
|
|
123
|
+
if (strokeMode === "dash") strokeStyle = "dashed";
|
|
124
|
+
else if (strokeMode === "solid") strokeStyle = "solid";
|
|
112
125
|
const strokeColorValue = require_xml_query.attrValue(props, "svg:stroke-color");
|
|
113
126
|
const strokeWidthValue = require_xml_query.attrValue(props, "svg:stroke-width");
|
|
114
127
|
const strokeColor = strokeColorValue === void 0 ? void 0 : require_typed_shared_color.parseOdfColor(strokeColorValue);
|
|
@@ -121,32 +134,38 @@ function readOdfFillAndStroke(element, pkg) {
|
|
|
121
134
|
}
|
|
122
135
|
return {
|
|
123
136
|
fill,
|
|
124
|
-
|
|
137
|
+
fillRule,
|
|
138
|
+
stroke: stroke === void 0 || strokeStyle === void 0 ? stroke : {
|
|
139
|
+
...stroke,
|
|
140
|
+
style: strokeStyle
|
|
141
|
+
}
|
|
125
142
|
};
|
|
126
143
|
}
|
|
127
|
-
function
|
|
144
|
+
function resolveVectorGeometry(element, groupFunctions) {
|
|
128
145
|
const geometry = require_typed_shared_transform.resolveOdfShapeGeometry(element);
|
|
129
146
|
if (geometry === void 0) return;
|
|
130
|
-
return require_typed_shared_transform.composeOdfGroupTransform(groupFunctions, geometry)
|
|
147
|
+
return require_typed_shared_transform.composeOdfGroupTransform(groupFunctions, geometry);
|
|
131
148
|
}
|
|
132
149
|
function readDrawRectVector(element, groupFunctions, pkg) {
|
|
133
|
-
const
|
|
134
|
-
if (
|
|
150
|
+
const geometry = resolveVectorGeometry(element, groupFunctions);
|
|
151
|
+
if (geometry === void 0) return;
|
|
135
152
|
const { fill, stroke } = readOdfFillAndStroke(element, pkg);
|
|
136
153
|
return {
|
|
137
154
|
kind: "rect",
|
|
138
|
-
frame,
|
|
155
|
+
frame: geometry.frame,
|
|
156
|
+
rotationDeg: geometry.rotationDeg,
|
|
139
157
|
fill,
|
|
140
158
|
stroke
|
|
141
159
|
};
|
|
142
160
|
}
|
|
143
161
|
function readDrawEllipseVector(element, groupFunctions, pkg) {
|
|
144
|
-
const
|
|
145
|
-
if (
|
|
162
|
+
const geometry = resolveVectorGeometry(element, groupFunctions);
|
|
163
|
+
if (geometry === void 0) return;
|
|
146
164
|
const { fill, stroke } = readOdfFillAndStroke(element, pkg);
|
|
147
165
|
return {
|
|
148
166
|
kind: "ellipse",
|
|
149
|
-
frame,
|
|
167
|
+
frame: geometry.frame,
|
|
168
|
+
rotationDeg: geometry.rotationDeg,
|
|
150
169
|
fill,
|
|
151
170
|
stroke
|
|
152
171
|
};
|
|
@@ -166,8 +185,9 @@ function readDrawLineVector(element, groupFunctions, pkg) {
|
|
|
166
185
|
};
|
|
167
186
|
}
|
|
168
187
|
function readDrawPathVector(element, groupFunctions, pkg) {
|
|
169
|
-
const
|
|
170
|
-
if (
|
|
188
|
+
const geometry = resolveVectorGeometry(element, groupFunctions);
|
|
189
|
+
if (geometry === void 0) return;
|
|
190
|
+
const frame = geometry.frame;
|
|
171
191
|
const viewBoxValue = require_xml_query.attrValue(element, "svg:viewBox");
|
|
172
192
|
const viewBox = viewBoxValue === void 0 ? void 0 : require_typed_shared_path.parseOdfViewBox(viewBoxValue);
|
|
173
193
|
if (viewBox === void 0) return;
|
|
@@ -183,12 +203,14 @@ function readDrawPathVector(element, groupFunctions, pkg) {
|
|
|
183
203
|
}
|
|
184
204
|
if (rawSubpaths.length === 0) return;
|
|
185
205
|
const subpaths = require_typed_shared_path.buildOdfSubpaths(rawSubpaths, viewBox, frame);
|
|
186
|
-
const { fill, stroke } = readOdfFillAndStroke(element, pkg);
|
|
206
|
+
const { fill, fillRule, stroke } = readOdfFillAndStroke(element, pkg);
|
|
187
207
|
return {
|
|
188
208
|
kind: "path",
|
|
189
209
|
frame,
|
|
210
|
+
rotationDeg: geometry.rotationDeg,
|
|
190
211
|
subpaths,
|
|
191
212
|
fill,
|
|
213
|
+
fillRule,
|
|
192
214
|
stroke
|
|
193
215
|
};
|
|
194
216
|
}
|
|
@@ -201,12 +223,13 @@ function readCustomShapeVector(element, groupFunctions, pkg) {
|
|
|
201
223
|
const geometryElement = require_xml_query.childrenWithTag(element, "draw:enhanced-geometry")[0];
|
|
202
224
|
const type = geometryElement === void 0 ? void 0 : require_xml_query.attrValue(geometryElement, "draw:type");
|
|
203
225
|
if (type === void 0 || !RECOGNIZED_CUSTOM_SHAPE_PRESETS.has(type)) return;
|
|
204
|
-
const
|
|
205
|
-
if (
|
|
226
|
+
const geometry = resolveVectorGeometry(element, groupFunctions);
|
|
227
|
+
if (geometry === void 0) return;
|
|
206
228
|
const { fill, stroke } = readOdfFillAndStroke(element, pkg);
|
|
207
229
|
return {
|
|
208
230
|
kind: type === "ellipse" ? "ellipse" : "rect",
|
|
209
|
-
frame,
|
|
231
|
+
frame: geometry.frame,
|
|
232
|
+
rotationDeg: geometry.rotationDeg,
|
|
210
233
|
fill,
|
|
211
234
|
stroke
|
|
212
235
|
};
|
|
@@ -247,7 +270,10 @@ function walkDrawPageContent(children, groupFunctions, pkg, indexState, shapesOu
|
|
|
247
270
|
const zIndex = paintOrderKey(node, indexState);
|
|
248
271
|
const shape = readDrawFrame(node, groupFunctions, pkg);
|
|
249
272
|
if (shape !== void 0) shapesOut.push({
|
|
250
|
-
value:
|
|
273
|
+
value: {
|
|
274
|
+
...shape,
|
|
275
|
+
paintOrder: zIndex
|
|
276
|
+
},
|
|
251
277
|
zIndex
|
|
252
278
|
});
|
|
253
279
|
} else if (node.tag === "draw:g") {
|
|
@@ -258,41 +284,59 @@ function walkDrawPageContent(children, groupFunctions, pkg, indexState, shapesOu
|
|
|
258
284
|
const zIndex = paintOrderKey(node, indexState);
|
|
259
285
|
const vector = readDrawRectVector(node, groupFunctions, pkg);
|
|
260
286
|
if (vector !== void 0) vectorsOut.push({
|
|
261
|
-
value:
|
|
287
|
+
value: {
|
|
288
|
+
...vector,
|
|
289
|
+
paintOrder: zIndex
|
|
290
|
+
},
|
|
262
291
|
zIndex
|
|
263
292
|
});
|
|
264
293
|
} else if (node.tag === "draw:ellipse" || node.tag === "draw:circle") {
|
|
265
294
|
const zIndex = paintOrderKey(node, indexState);
|
|
266
295
|
const vector = readDrawEllipseVector(node, groupFunctions, pkg);
|
|
267
296
|
if (vector !== void 0) vectorsOut.push({
|
|
268
|
-
value:
|
|
297
|
+
value: {
|
|
298
|
+
...vector,
|
|
299
|
+
paintOrder: zIndex
|
|
300
|
+
},
|
|
269
301
|
zIndex
|
|
270
302
|
});
|
|
271
303
|
} else if (node.tag === "draw:line") {
|
|
272
304
|
const zIndex = paintOrderKey(node, indexState);
|
|
273
305
|
const vector = readDrawLineVector(node, groupFunctions, pkg);
|
|
274
306
|
if (vector !== void 0) vectorsOut.push({
|
|
275
|
-
value:
|
|
307
|
+
value: {
|
|
308
|
+
...vector,
|
|
309
|
+
paintOrder: zIndex
|
|
310
|
+
},
|
|
276
311
|
zIndex
|
|
277
312
|
});
|
|
278
313
|
} else if (node.tag === "draw:path" || node.tag === "draw:polygon" || node.tag === "draw:polyline") {
|
|
279
314
|
const zIndex = paintOrderKey(node, indexState);
|
|
280
315
|
const vector = readDrawPathVector(node, groupFunctions, pkg);
|
|
281
316
|
if (vector !== void 0) vectorsOut.push({
|
|
282
|
-
value:
|
|
317
|
+
value: {
|
|
318
|
+
...vector,
|
|
319
|
+
paintOrder: zIndex
|
|
320
|
+
},
|
|
283
321
|
zIndex
|
|
284
322
|
});
|
|
285
323
|
} else if (node.tag === "draw:custom-shape") {
|
|
286
324
|
const zIndex = paintOrderKey(node, indexState);
|
|
287
325
|
const vector = readCustomShapeVector(node, groupFunctions, pkg);
|
|
288
326
|
if (vector !== void 0) vectorsOut.push({
|
|
289
|
-
value:
|
|
327
|
+
value: {
|
|
328
|
+
...vector,
|
|
329
|
+
paintOrder: zIndex
|
|
330
|
+
},
|
|
290
331
|
zIndex
|
|
291
332
|
});
|
|
292
333
|
else {
|
|
293
334
|
const shape = readCustomShapeAsTextShape(node, groupFunctions, pkg);
|
|
294
335
|
if (shape !== void 0) shapesOut.push({
|
|
295
|
-
value:
|
|
336
|
+
value: {
|
|
337
|
+
...shape,
|
|
338
|
+
paintOrder: zIndex
|
|
339
|
+
},
|
|
296
340
|
zIndex
|
|
297
341
|
});
|
|
298
342
|
}
|
|
@@ -4,7 +4,10 @@ import { OdfTransformFunction } from "../shared/transform.cjs";
|
|
|
4
4
|
import { ContentShape, ContentVector } from "document-schema.js";
|
|
5
5
|
//#region src/typed/draw/shapes.d.ts
|
|
6
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;
|
|
7
|
+
declare function walkDrawShapes(children: readonly XmlNode[], groupFunctions: readonly OdfTransformFunction[], pkg: Package, out: ContentShape[], indexState?: DocumentIndexState): void;
|
|
8
|
+
interface DocumentIndexState {
|
|
9
|
+
next: number;
|
|
10
|
+
}
|
|
8
11
|
interface DrawPageContent {
|
|
9
12
|
readonly shapes: ContentShape[];
|
|
10
13
|
readonly vectors: ContentVector[];
|
|
@@ -4,7 +4,10 @@ import { OdfTransformFunction } from "../shared/transform.js";
|
|
|
4
4
|
import { ContentShape, ContentVector } from "document-schema.js";
|
|
5
5
|
//#region src/typed/draw/shapes.d.ts
|
|
6
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;
|
|
7
|
+
declare function walkDrawShapes(children: readonly XmlNode[], groupFunctions: readonly OdfTransformFunction[], pkg: Package, out: ContentShape[], indexState?: DocumentIndexState): void;
|
|
8
|
+
interface DocumentIndexState {
|
|
9
|
+
next: number;
|
|
10
|
+
}
|
|
8
11
|
interface DrawPageContent {
|
|
9
12
|
readonly shapes: ContentShape[];
|
|
10
13
|
readonly vectors: ContentVector[];
|