odf.js 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -3
- package/dist/index.cjs +3 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -2
- package/dist/typed/draw/embedded.cjs +42 -0
- package/dist/typed/draw/embedded.d.cts +13 -0
- package/dist/typed/draw/embedded.d.ts +13 -0
- package/dist/typed/draw/embedded.js +41 -0
- package/dist/typed/draw/shapes.cjs +15 -3
- package/dist/typed/draw/shapes.js +15 -3
- package/dist/typed/odb/form.cjs +1 -1
- package/dist/typed/odb/form.js +1 -1
- package/dist/typed/odb/report.cjs +1 -1
- package/dist/typed/odb/report.js +1 -1
- package/dist/typed/ods/read.cjs +90 -4
- package/dist/typed/ods/read.js +91 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ This package is under active development. What's built and shipped:
|
|
|
51
51
|
- **Namespaces, media types, mimetype, manifest** (`src/ns.ts`, `src/media-type.ts`, `src/mimetype.ts`, `src/manifest.ts`) — full read *and* write, including `META-INF/manifest.xml`'s exhaustive per-part enumeration and the mimetype part's mandatory first-entry/stored/uncompressed byte layout, verified against real LibreOffice-produced output.
|
|
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
|
-
- **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.
|
|
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, plus cell- and page-anchored `draw:frame` images and embedded ODF sub-documents) each resolve a `Package` into `document-schema.js`'s own `ContentSection`/`ContentSlide`/`ContentDrawPage`/`ContentSheet` shapes.
|
|
55
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
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.
|
|
@@ -126,7 +126,7 @@ Layered from a lossless core outward, mirroring `ooxml.js`'s own structure:
|
|
|
126
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.
|
|
127
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).
|
|
128
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).
|
|
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).
|
|
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 (`shapes.ts`), plus `embedded.ts`'s `readDrawObjectReference`, the `draw:object` embedded-sub-document counterpart `readOds` resolves a sheet's anchored OLE objects through; **`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).
|
|
130
130
|
|
|
131
131
|
## Why no `ooxml.js` dependency
|
|
132
132
|
|
|
@@ -149,8 +149,11 @@ See the top of this README — the short version: `ooxml.js`'s branding and sign
|
|
|
149
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
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
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).
|
|
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). The original test coverage for `svg:fill-rule` only ever exercised a single-loop `svg:d`, which cannot actually distinguish the two rules — there is nothing for `evenodd`'s alternating parity to differ from `nonzero`'s winding count with only one contour. `shapes.test.ts` now also covers a genuine two-subpath "letter O" donut shape (an outer square and an inner square hole, both wound in the same rotational direction), the real-world case the attribute exists for: `nonzero` would fill the hole solid (winding number 2, still non-zero) while `evenodd` correctly punches it (parity toggles to 0 inside), and the test confirms both subpaths, their `closed` flags, and the inner subpath's scaled points are read correctly alongside `fillRule` itself.
|
|
153
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
|
+
- **`readOds` now reads drawings anchored to a sheet, populating `ContentSheet.images` (previously hardcoded `[]`) and `ContentSheet.embeddedObjects` (previously never set), through the same `typed/draw/shapes.ts` primitives `readOdp`/`readOdg` already use.** ODF has exactly two spreadsheet anchoring conventions, both confirmed against real LibreOffice 26.2 output (`src/typed/ods/fixtures/sheet-anchors.ods`, built via a Java UNO client and never hand-edited): a **cell-anchored** `draw:frame` is a *direct child of the `table:table-cell` it is anchored to*, with `svg:x`/`svg:y` measured from **that cell's own top-left corner**; a **page-anchored** one sits in a `table:shapes` element (a child of `table:table` preceding its column definitions) with absolute sheet coordinates. The anchor cell reference is not read from any attribute at all — ODF cells have none (see the cursor gotchas above) — it is the same running `TableCursor` position `ContentSheetCell.row`/`column` already come from; a page-anchored image is reported against cell `(0, 0)`, whose own top-left *is* the sheet origin, so its absolute offsets carry through exactly rather than being approximated. A `draw:g` group is walked through, composing its own `draw:transform` via `readDrawFrame`'s existing `groupFunctions` parameter. What a sheet cannot carry is anything `ContentSheetSchema` has nowhere to put — a floating text box or table frame (no `shapes` array), a bare vector primitive (no `vectors` array), and an embedded formula or chart object (`ContentEmbeddedObject.document` is a required `ContentDocument`, whose union has no MathML- or chart-shaped variant) — each skipped rather than mapped onto an approximation of a different kind.
|
|
155
|
+
- **`readDrawObjectReference` (`typed/draw/embedded.ts`) is the new shared `draw:object` counterpart to `shapes.ts`'s existing `draw:image` handling**, resolving a frame's embedded-object reference into the sub-`Package` it names (via `subDocumentPackage`) plus the `ContentEmbeddedObjectKind` that sub-document actually is, read from its own `office:body` content child rather than from the manifest's declared media type — one signal, so the reported kind and the reader that produced the content agree by construction. It deliberately stops short of calling `readOdt`/`readOds`/`readOdp`/`readOdg` itself: doing so would import `readOds`, which imports this module. A real embedded-object frame also carries a `draw:image` preview of its own object (an `ObjectReplacements/` GDI metafile), so `draw:object` must be checked *before* a frame's image content — the same ordering, for the same reason, that `readDrawFrameContent` already applies to a table frame's preview image.
|
|
156
|
+
- **A `draw:frame`'s alternative text (`svg:title`, falling back to `svg:desc`) is now read into `ContentImageBlock.altText` for every format**, not just spreadsheets. Both are plain-text *child elements* of `draw:frame` itself, not attributes — confirmed against real LibreOffice output, where a Calc image's UNO `Title`/`Description` properties round-trip as `<svg:title>`/`<svg:desc>` siblings of the frame's own `draw:image`.
|
|
154
157
|
- **`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
158
|
- **`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
159
|
- **`.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.
|
package/dist/index.cjs
CHANGED
|
@@ -34,6 +34,8 @@ const require_typed_shared_transform = require("./typed/shared/transform.cjs");
|
|
|
34
34
|
const require_typed_shared_masterpage = require("./typed/shared/masterpage.cjs");
|
|
35
35
|
const require_typed_shared_path = require("./typed/shared/path.cjs");
|
|
36
36
|
const require_typed_draw_shapes = require("./typed/draw/shapes.cjs");
|
|
37
|
+
const require_typed_odb_subdocument = require("./typed/odb/subdocument.cjs");
|
|
38
|
+
const require_typed_draw_embedded = require("./typed/draw/embedded.cjs");
|
|
37
39
|
const require_typed_odp_read = require("./typed/odp/read.cjs");
|
|
38
40
|
const require_typed_odt_read = require("./typed/odt/read.cjs");
|
|
39
41
|
const require_typed_odg_read = require("./typed/odg/read.cjs");
|
|
@@ -41,7 +43,6 @@ const require_typed_ods_read = require("./typed/ods/read.cjs");
|
|
|
41
43
|
const require_typed_formula_read = require("./typed/formula/read.cjs");
|
|
42
44
|
const require_typed_odm_read = require("./typed/odm/read.cjs");
|
|
43
45
|
const require_typed_odb_read = require("./typed/odb/read.cjs");
|
|
44
|
-
const require_typed_odb_subdocument = require("./typed/odb/subdocument.cjs");
|
|
45
46
|
const require_typed_odb_form = require("./typed/odb/form.cjs");
|
|
46
47
|
const require_typed_odb_report = require("./typed/odb/report.cjs");
|
|
47
48
|
let document_schema_js = require("document-schema.js");
|
|
@@ -130,6 +131,7 @@ exports.parseTextProperties = require_styles_properties.parseTextProperties;
|
|
|
130
131
|
exports.parseXml = require_xml_parse.parseXml;
|
|
131
132
|
exports.rawSubpathFromPoints = require_typed_shared_path.rawSubpathFromPoints;
|
|
132
133
|
exports.readDrawFrame = require_typed_draw_shapes.readDrawFrame;
|
|
134
|
+
exports.readDrawObjectReference = require_typed_draw_embedded.readDrawObjectReference;
|
|
133
135
|
exports.readDrawPageContent = require_typed_draw_shapes.readDrawPageContent;
|
|
134
136
|
exports.readManifest = require_manifest.readManifest;
|
|
135
137
|
exports.readMimetype = require_mimetype.readMimetype;
|
package/dist/index.d.cts
CHANGED
|
@@ -33,6 +33,7 @@ import { OdfPoint, OdfShapeGeometry, OdfTransformFunction, applyOdfTransform, co
|
|
|
33
33
|
import { resolveDrawPageSize, resolvePageLayoutProperties } from "./typed/shared/masterpage.cjs";
|
|
34
34
|
import { OdfRawPoint, OdfRawSegment, OdfRawSubpath, OdfViewBox, buildOdfSubpaths, parseOdfPathData, parseOdfPointsList, parseOdfViewBox, rawSubpathFromPoints, scaleOdfRawPoint } from "./typed/shared/path.cjs";
|
|
35
35
|
import { DrawPageContent, readDrawFrame, readDrawPageContent, walkDrawShapes } from "./typed/draw/shapes.cjs";
|
|
36
|
+
import { EmbeddedDocumentKind, EmbeddedDrawObject, readDrawObjectReference } from "./typed/draw/embedded.cjs";
|
|
36
37
|
import { OdpDocument, readOdp } from "./typed/odp/read.cjs";
|
|
37
38
|
import { OdtDocument, readOdt } from "./typed/odt/read.cjs";
|
|
38
39
|
import { OdgDocument, readOdg } from "./typed/odg/read.cjs";
|
|
@@ -43,4 +44,4 @@ import { OdbComponentInfo, OdbConnectionInfo, OdbInventory, OdbQueryInfo, readOd
|
|
|
43
44
|
import { SubDocumentPackageOptions, subDocumentPackage } from "./typed/odb/subdocument.cjs";
|
|
44
45
|
import { OdbForm, OdbFormControl, OdbFormDefinition, readOdbForm } from "./typed/odb/form.cjs";
|
|
45
46
|
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 };
|
|
47
|
+
export { type Alignment, AlignmentSchema, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type BuildManifestOptions, type CascadeDiagnostic, type DrawPageContent, type EmbeddedDocumentKind, type EmbeddedDrawObject, 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, readDrawObjectReference, 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
|
@@ -33,6 +33,7 @@ import { OdfPoint, OdfShapeGeometry, OdfTransformFunction, applyOdfTransform, co
|
|
|
33
33
|
import { resolveDrawPageSize, resolvePageLayoutProperties } from "./typed/shared/masterpage.js";
|
|
34
34
|
import { OdfRawPoint, OdfRawSegment, OdfRawSubpath, OdfViewBox, buildOdfSubpaths, parseOdfPathData, parseOdfPointsList, parseOdfViewBox, rawSubpathFromPoints, scaleOdfRawPoint } from "./typed/shared/path.js";
|
|
35
35
|
import { DrawPageContent, readDrawFrame, readDrawPageContent, walkDrawShapes } from "./typed/draw/shapes.js";
|
|
36
|
+
import { EmbeddedDocumentKind, EmbeddedDrawObject, readDrawObjectReference } from "./typed/draw/embedded.js";
|
|
36
37
|
import { OdpDocument, readOdp } from "./typed/odp/read.js";
|
|
37
38
|
import { OdtDocument, readOdt } from "./typed/odt/read.js";
|
|
38
39
|
import { OdgDocument, readOdg } from "./typed/odg/read.js";
|
|
@@ -43,4 +44,4 @@ import { OdbComponentInfo, OdbConnectionInfo, OdbInventory, OdbQueryInfo, readOd
|
|
|
43
44
|
import { SubDocumentPackageOptions, subDocumentPackage } from "./typed/odb/subdocument.js";
|
|
44
45
|
import { OdbForm, OdbFormControl, OdbFormDefinition, readOdbForm } from "./typed/odb/form.js";
|
|
45
46
|
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 };
|
|
47
|
+
export { type Alignment, AlignmentSchema, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type BuildManifestOptions, type CascadeDiagnostic, type DrawPageContent, type EmbeddedDocumentKind, type EmbeddedDrawObject, 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, readDrawObjectReference, 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
|
@@ -33,6 +33,8 @@ import { applyOdfTransform, composeOdfGroupTransform, netRotationDeg, parseOdfTr
|
|
|
33
33
|
import { resolveDrawPageSize, resolvePageLayoutProperties } from "./typed/shared/masterpage.js";
|
|
34
34
|
import { buildOdfSubpaths, parseOdfPathData, parseOdfPointsList, parseOdfViewBox, rawSubpathFromPoints, scaleOdfRawPoint } from "./typed/shared/path.js";
|
|
35
35
|
import { readDrawFrame, readDrawPageContent, walkDrawShapes } from "./typed/draw/shapes.js";
|
|
36
|
+
import { subDocumentPackage } from "./typed/odb/subdocument.js";
|
|
37
|
+
import { readDrawObjectReference } from "./typed/draw/embedded.js";
|
|
36
38
|
import { readOdp } from "./typed/odp/read.js";
|
|
37
39
|
import { readOdt } from "./typed/odt/read.js";
|
|
38
40
|
import { readOdg } from "./typed/odg/read.js";
|
|
@@ -40,7 +42,6 @@ import { readOds } from "./typed/ods/read.js";
|
|
|
40
42
|
import { readOdfFormula, readOdfFormulaDocument } from "./typed/formula/read.js";
|
|
41
43
|
import { readOdm } from "./typed/odm/read.js";
|
|
42
44
|
import { readOdbInventory, resolveOdbComponent } from "./typed/odb/read.js";
|
|
43
|
-
import { subDocumentPackage } from "./typed/odb/subdocument.js";
|
|
44
45
|
import { readOdbForm } from "./typed/odb/form.js";
|
|
45
46
|
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 };
|
|
47
|
+
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, readDrawObjectReference, 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 };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_xml_query = require("../../xml/query.cjs");
|
|
3
|
+
const require_typed_odb_subdocument = require("../odb/subdocument.cjs");
|
|
4
|
+
//#region src/typed/draw/embedded.ts
|
|
5
|
+
const CONTENT_PART = "content.xml";
|
|
6
|
+
function embeddedKindFor(bodyChildTag) {
|
|
7
|
+
switch (bodyChildTag) {
|
|
8
|
+
case "office:text": return "wordprocessing";
|
|
9
|
+
case "office:spreadsheet": return "spreadsheet";
|
|
10
|
+
case "office:presentation": return "presentation";
|
|
11
|
+
case "office:drawing": return "drawing";
|
|
12
|
+
default: return;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function normaliseObjectHref(raw) {
|
|
16
|
+
const withoutPrefix = raw.startsWith("./") ? raw.slice(2) : raw;
|
|
17
|
+
const trimmed = withoutPrefix.endsWith("/") ? withoutPrefix.slice(0, -1) : withoutPrefix;
|
|
18
|
+
if (trimmed.length === 0 || trimmed.startsWith("..") || trimmed.startsWith("/") || trimmed.includes("://")) return;
|
|
19
|
+
return trimmed;
|
|
20
|
+
}
|
|
21
|
+
function readDrawObjectReference(frame, pkg) {
|
|
22
|
+
const object = require_xml_query.childrenWithTag(frame, "draw:object")[0];
|
|
23
|
+
if (object === void 0) return;
|
|
24
|
+
const rawHref = require_xml_query.attrValue(object, "xlink:href");
|
|
25
|
+
const href = rawHref === void 0 ? void 0 : normaliseObjectHref(rawHref);
|
|
26
|
+
if (href === void 0) return;
|
|
27
|
+
const subPackage = require_typed_odb_subdocument.subDocumentPackage(pkg, href, { allowMissingContent: true });
|
|
28
|
+
const contentPart = subPackage.parts[CONTENT_PART];
|
|
29
|
+
if (contentPart?.kind !== "xml") return;
|
|
30
|
+
const root = require_xml_query.rootElement(contentPart.nodes);
|
|
31
|
+
const body = root === void 0 ? void 0 : require_xml_query.findChildElement(root.children, "office:body");
|
|
32
|
+
const bodyChild = body === void 0 ? void 0 : require_xml_query.rootElement(body.children);
|
|
33
|
+
const objectKind = bodyChild === void 0 ? void 0 : embeddedKindFor(bodyChild.tag);
|
|
34
|
+
if (objectKind === void 0) return;
|
|
35
|
+
return {
|
|
36
|
+
objectKind,
|
|
37
|
+
package: subPackage,
|
|
38
|
+
href
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
exports.readDrawObjectReference = readDrawObjectReference;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { l as XmlElement } from "../../node-CkBWRjNR.cjs";
|
|
2
|
+
import { Package } from "../../model/package.cjs";
|
|
3
|
+
import { ContentEmbeddedObjectKind } from "document-schema.js";
|
|
4
|
+
//#region src/typed/draw/embedded.d.ts
|
|
5
|
+
type EmbeddedDocumentKind = Extract<ContentEmbeddedObjectKind, 'wordprocessing' | 'presentation' | 'spreadsheet' | 'drawing'>;
|
|
6
|
+
interface EmbeddedDrawObject {
|
|
7
|
+
objectKind: EmbeddedDocumentKind;
|
|
8
|
+
package: Package;
|
|
9
|
+
href: string;
|
|
10
|
+
}
|
|
11
|
+
declare function readDrawObjectReference(frame: XmlElement, pkg: Package): EmbeddedDrawObject | undefined;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { EmbeddedDocumentKind, EmbeddedDrawObject, readDrawObjectReference };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { l as XmlElement } from "../../node-CkBWRjNR.js";
|
|
2
|
+
import { Package } from "../../model/package.js";
|
|
3
|
+
import { ContentEmbeddedObjectKind } from "document-schema.js";
|
|
4
|
+
//#region src/typed/draw/embedded.d.ts
|
|
5
|
+
type EmbeddedDocumentKind = Extract<ContentEmbeddedObjectKind, 'wordprocessing' | 'presentation' | 'spreadsheet' | 'drawing'>;
|
|
6
|
+
interface EmbeddedDrawObject {
|
|
7
|
+
objectKind: EmbeddedDocumentKind;
|
|
8
|
+
package: Package;
|
|
9
|
+
href: string;
|
|
10
|
+
}
|
|
11
|
+
declare function readDrawObjectReference(frame: XmlElement, pkg: Package): EmbeddedDrawObject | undefined;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { EmbeddedDocumentKind, EmbeddedDrawObject, readDrawObjectReference };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { attrValue, childrenWithTag, findChildElement, rootElement } from "../../xml/query.js";
|
|
2
|
+
import { subDocumentPackage } from "../odb/subdocument.js";
|
|
3
|
+
//#region src/typed/draw/embedded.ts
|
|
4
|
+
const CONTENT_PART = "content.xml";
|
|
5
|
+
function embeddedKindFor(bodyChildTag) {
|
|
6
|
+
switch (bodyChildTag) {
|
|
7
|
+
case "office:text": return "wordprocessing";
|
|
8
|
+
case "office:spreadsheet": return "spreadsheet";
|
|
9
|
+
case "office:presentation": return "presentation";
|
|
10
|
+
case "office:drawing": return "drawing";
|
|
11
|
+
default: return;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function normaliseObjectHref(raw) {
|
|
15
|
+
const withoutPrefix = raw.startsWith("./") ? raw.slice(2) : raw;
|
|
16
|
+
const trimmed = withoutPrefix.endsWith("/") ? withoutPrefix.slice(0, -1) : withoutPrefix;
|
|
17
|
+
if (trimmed.length === 0 || trimmed.startsWith("..") || trimmed.startsWith("/") || trimmed.includes("://")) return;
|
|
18
|
+
return trimmed;
|
|
19
|
+
}
|
|
20
|
+
function readDrawObjectReference(frame, pkg) {
|
|
21
|
+
const object = childrenWithTag(frame, "draw:object")[0];
|
|
22
|
+
if (object === void 0) return;
|
|
23
|
+
const rawHref = attrValue(object, "xlink:href");
|
|
24
|
+
const href = rawHref === void 0 ? void 0 : normaliseObjectHref(rawHref);
|
|
25
|
+
if (href === void 0) return;
|
|
26
|
+
const subPackage = subDocumentPackage(pkg, href, { allowMissingContent: true });
|
|
27
|
+
const contentPart = subPackage.parts[CONTENT_PART];
|
|
28
|
+
if (contentPart?.kind !== "xml") return;
|
|
29
|
+
const root = rootElement(contentPart.nodes);
|
|
30
|
+
const body = root === void 0 ? void 0 : findChildElement(root.children, "office:body");
|
|
31
|
+
const bodyChild = body === void 0 ? void 0 : rootElement(body.children);
|
|
32
|
+
const objectKind = bodyChild === void 0 ? void 0 : embeddedKindFor(bodyChild.tag);
|
|
33
|
+
if (objectKind === void 0) return;
|
|
34
|
+
return {
|
|
35
|
+
objectKind,
|
|
36
|
+
package: subPackage,
|
|
37
|
+
href
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { readDrawObjectReference };
|
|
@@ -4,6 +4,7 @@ const require_image_sniff = require("../../image/sniff.cjs");
|
|
|
4
4
|
const require_typed_shared_units = require("../shared/units.cjs");
|
|
5
5
|
const require_typed_shared_color = require("../shared/color.cjs");
|
|
6
6
|
const require_xml_query = require("../../xml/query.cjs");
|
|
7
|
+
const require_typed_shared_text = require("../shared/text.cjs");
|
|
7
8
|
const require_typed_shared_geometry = require("../shared/geometry.cjs");
|
|
8
9
|
const require_typed_shared_cascade = require("../shared/cascade.cjs");
|
|
9
10
|
const require_typed_shared_paragraph = require("../shared/paragraph.cjs");
|
|
@@ -37,20 +38,31 @@ function readFrameInsets(frame, pkg) {
|
|
|
37
38
|
}
|
|
38
39
|
return insets;
|
|
39
40
|
}
|
|
40
|
-
function
|
|
41
|
+
function readFrameAltText(frame) {
|
|
42
|
+
const title = require_xml_query.childrenWithTag(frame, "svg:title")[0];
|
|
43
|
+
const decodedTitle = title === void 0 ? void 0 : require_typed_shared_text.decodeOdfText(title);
|
|
44
|
+
if (decodedTitle !== void 0 && decodedTitle.length > 0) return decodedTitle;
|
|
45
|
+
const description = require_xml_query.childrenWithTag(frame, "svg:desc")[0];
|
|
46
|
+
const decodedDescription = description === void 0 ? void 0 : require_typed_shared_text.decodeOdfText(description);
|
|
47
|
+
return decodedDescription !== void 0 && decodedDescription.length > 0 ? decodedDescription : void 0;
|
|
48
|
+
}
|
|
49
|
+
function readDrawImageBlock(image, frame, frameBox, pkg) {
|
|
41
50
|
const href = require_xml_query.attrValue(image, "xlink:href");
|
|
42
51
|
const part = href === void 0 ? void 0 : pkg.parts[href];
|
|
43
52
|
if (part?.kind !== "binary") return;
|
|
44
53
|
const bytes = require_util_base64.base64ToBytes(part.base64);
|
|
45
54
|
const format = require_image_sniff.sniffImageFormat(bytes);
|
|
46
55
|
if (format === void 0) return;
|
|
47
|
-
|
|
56
|
+
const block = {
|
|
48
57
|
kind: "image",
|
|
49
58
|
format,
|
|
50
59
|
base64: part.base64,
|
|
51
60
|
widthPt: frameBox.widthPt,
|
|
52
61
|
heightPt: frameBox.heightPt
|
|
53
62
|
};
|
|
63
|
+
const altText = readFrameAltText(frame);
|
|
64
|
+
if (altText !== void 0) block.altText = altText;
|
|
65
|
+
return block;
|
|
54
66
|
}
|
|
55
67
|
function readDrawFrameContent(frame, frameBox, pkg) {
|
|
56
68
|
const table = require_xml_query.childrenWithTag(frame, "table:table")[0];
|
|
@@ -59,7 +71,7 @@ function readDrawFrameContent(frame, frameBox, pkg) {
|
|
|
59
71
|
if (textBox !== void 0) return require_xml_query.elementsWithTag(textBox.children, "text:p").map((p) => require_typed_shared_paragraph.readOdfParagraph(p, pkg));
|
|
60
72
|
const image = require_xml_query.childrenWithTag(frame, "draw:image")[0];
|
|
61
73
|
if (image !== void 0) {
|
|
62
|
-
const block = readDrawImageBlock(image, frameBox, pkg);
|
|
74
|
+
const block = readDrawImageBlock(image, frame, frameBox, pkg);
|
|
63
75
|
return block === void 0 ? [] : [block];
|
|
64
76
|
}
|
|
65
77
|
return [];
|
|
@@ -3,6 +3,7 @@ import { sniffImageFormat } from "../../image/sniff.js";
|
|
|
3
3
|
import { parseOdfLength } from "../shared/units.js";
|
|
4
4
|
import { parseOdfColor } from "../shared/color.js";
|
|
5
5
|
import { attrValue, childrenWithTag, elementsWithTag } from "../../xml/query.js";
|
|
6
|
+
import { decodeOdfText } from "../shared/text.js";
|
|
6
7
|
import { parseLinePoints } from "../shared/geometry.js";
|
|
7
8
|
import { resolveStyleElementChain } from "../shared/cascade.js";
|
|
8
9
|
import { readOdfParagraph } from "../shared/paragraph.js";
|
|
@@ -36,20 +37,31 @@ function readFrameInsets(frame, pkg) {
|
|
|
36
37
|
}
|
|
37
38
|
return insets;
|
|
38
39
|
}
|
|
39
|
-
function
|
|
40
|
+
function readFrameAltText(frame) {
|
|
41
|
+
const title = childrenWithTag(frame, "svg:title")[0];
|
|
42
|
+
const decodedTitle = title === void 0 ? void 0 : decodeOdfText(title);
|
|
43
|
+
if (decodedTitle !== void 0 && decodedTitle.length > 0) return decodedTitle;
|
|
44
|
+
const description = childrenWithTag(frame, "svg:desc")[0];
|
|
45
|
+
const decodedDescription = description === void 0 ? void 0 : decodeOdfText(description);
|
|
46
|
+
return decodedDescription !== void 0 && decodedDescription.length > 0 ? decodedDescription : void 0;
|
|
47
|
+
}
|
|
48
|
+
function readDrawImageBlock(image, frame, frameBox, pkg) {
|
|
40
49
|
const href = attrValue(image, "xlink:href");
|
|
41
50
|
const part = href === void 0 ? void 0 : pkg.parts[href];
|
|
42
51
|
if (part?.kind !== "binary") return;
|
|
43
52
|
const bytes = base64ToBytes(part.base64);
|
|
44
53
|
const format = sniffImageFormat(bytes);
|
|
45
54
|
if (format === void 0) return;
|
|
46
|
-
|
|
55
|
+
const block = {
|
|
47
56
|
kind: "image",
|
|
48
57
|
format,
|
|
49
58
|
base64: part.base64,
|
|
50
59
|
widthPt: frameBox.widthPt,
|
|
51
60
|
heightPt: frameBox.heightPt
|
|
52
61
|
};
|
|
62
|
+
const altText = readFrameAltText(frame);
|
|
63
|
+
if (altText !== void 0) block.altText = altText;
|
|
64
|
+
return block;
|
|
53
65
|
}
|
|
54
66
|
function readDrawFrameContent(frame, frameBox, pkg) {
|
|
55
67
|
const table = childrenWithTag(frame, "table:table")[0];
|
|
@@ -58,7 +70,7 @@ function readDrawFrameContent(frame, frameBox, pkg) {
|
|
|
58
70
|
if (textBox !== void 0) return elementsWithTag(textBox.children, "text:p").map((p) => readOdfParagraph(p, pkg));
|
|
59
71
|
const image = childrenWithTag(frame, "draw:image")[0];
|
|
60
72
|
if (image !== void 0) {
|
|
61
|
-
const block = readDrawImageBlock(image, frameBox, pkg);
|
|
73
|
+
const block = readDrawImageBlock(image, frame, frameBox, pkg);
|
|
62
74
|
return block === void 0 ? [] : [block];
|
|
63
75
|
}
|
|
64
76
|
return [];
|
package/dist/typed/odb/form.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_xml_entities = require("../../xml/entities.cjs");
|
|
3
3
|
const require_xml_query = require("../../xml/query.cjs");
|
|
4
|
+
const require_typed_odb_subdocument = require("./subdocument.cjs");
|
|
4
5
|
const require_typed_odt_read = require("../odt/read.cjs");
|
|
5
6
|
const require_typed_odb_read = require("./read.cjs");
|
|
6
|
-
const require_typed_odb_subdocument = require("./subdocument.cjs");
|
|
7
7
|
//#region src/typed/odb/form.ts
|
|
8
8
|
const CONTENT_PART = "content.xml";
|
|
9
9
|
const FORM_ELEMENT_TAG = "form:form";
|
package/dist/typed/odb/form.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { decodeXmlText } from "../../xml/entities.js";
|
|
2
2
|
import { attrValue, findChildElement, rootElement } from "../../xml/query.js";
|
|
3
|
+
import { subDocumentPackage } from "./subdocument.js";
|
|
3
4
|
import { readOdt } from "../odt/read.js";
|
|
4
5
|
import { resolveOdbComponent } from "./read.js";
|
|
5
|
-
import { subDocumentPackage } from "./subdocument.js";
|
|
6
6
|
//#region src/typed/odb/form.ts
|
|
7
7
|
const CONTENT_PART = "content.xml";
|
|
8
8
|
const FORM_ELEMENT_TAG = "form:form";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_xml_entities = require("../../xml/entities.cjs");
|
|
3
3
|
const require_xml_query = require("../../xml/query.cjs");
|
|
4
|
-
const require_typed_odb_read = require("./read.cjs");
|
|
5
4
|
const require_typed_odb_subdocument = require("./subdocument.cjs");
|
|
5
|
+
const require_typed_odb_read = require("./read.cjs");
|
|
6
6
|
//#region src/typed/odb/report.ts
|
|
7
7
|
const CONTENT_PART = "content.xml";
|
|
8
8
|
const GROUP_TAG = "rpt:group";
|
package/dist/typed/odb/report.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { decodeXmlText } from "../../xml/entities.js";
|
|
2
2
|
import { attrValue, findChildElement, rootElement } from "../../xml/query.js";
|
|
3
|
-
import { resolveOdbComponent } from "./read.js";
|
|
4
3
|
import { subDocumentPackage } from "./subdocument.js";
|
|
4
|
+
import { resolveOdbComponent } from "./read.js";
|
|
5
5
|
//#region src/typed/odb/report.ts
|
|
6
6
|
const CONTENT_PART = "content.xml";
|
|
7
7
|
const GROUP_TAG = "rpt:group";
|
package/dist/typed/ods/read.cjs
CHANGED
|
@@ -7,7 +7,13 @@ const require_typed_shared_cascade = require("../shared/cascade.cjs");
|
|
|
7
7
|
const require_typed_shared_metadata = require("../shared/metadata.cjs");
|
|
8
8
|
const require_typed_shared_paragraph = require("../shared/paragraph.cjs");
|
|
9
9
|
const require_typed_shared_table = require("../shared/table.cjs");
|
|
10
|
+
const require_typed_shared_transform = require("../shared/transform.cjs");
|
|
10
11
|
const require_typed_shared_masterpage = require("../shared/masterpage.cjs");
|
|
12
|
+
const require_typed_draw_shapes = require("../draw/shapes.cjs");
|
|
13
|
+
const require_typed_draw_embedded = require("../draw/embedded.cjs");
|
|
14
|
+
const require_typed_odp_read = require("../odp/read.cjs");
|
|
15
|
+
const require_typed_odt_read = require("../odt/read.cjs");
|
|
16
|
+
const require_typed_odg_read = require("../odg/read.cjs");
|
|
11
17
|
let document_schema_js = require("document-schema.js");
|
|
12
18
|
//#region src/typed/ods/read.ts
|
|
13
19
|
const CONTENT_PART = "content.xml";
|
|
@@ -156,10 +162,84 @@ function parseNonNegativeInteger(value) {
|
|
|
156
162
|
const parsed = Number.parseInt(value, 10);
|
|
157
163
|
return Number.isInteger(parsed) && parsed >= 0 ? parsed : void 0;
|
|
158
164
|
}
|
|
165
|
+
function readEmbeddedObjectDocument(reference) {
|
|
166
|
+
switch (reference.objectKind) {
|
|
167
|
+
case "wordprocessing": {
|
|
168
|
+
const { metadata, sections } = require_typed_odt_read.readOdt(reference.package);
|
|
169
|
+
return {
|
|
170
|
+
kind: "wordprocessing",
|
|
171
|
+
formatVersion: document_schema_js.CONTENT_FORMAT_VERSION,
|
|
172
|
+
metadata,
|
|
173
|
+
sections
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
case "presentation": {
|
|
177
|
+
const { metadata, slides } = require_typed_odp_read.readOdp(reference.package);
|
|
178
|
+
return {
|
|
179
|
+
kind: "presentation",
|
|
180
|
+
formatVersion: document_schema_js.CONTENT_FORMAT_VERSION,
|
|
181
|
+
metadata,
|
|
182
|
+
slides
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
case "drawing": {
|
|
186
|
+
const { metadata, pages } = require_typed_odg_read.readOdg(reference.package);
|
|
187
|
+
return {
|
|
188
|
+
kind: "drawing",
|
|
189
|
+
formatVersion: document_schema_js.CONTENT_FORMAT_VERSION,
|
|
190
|
+
metadata,
|
|
191
|
+
pages
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
case "spreadsheet": {
|
|
195
|
+
const { metadata, sheets } = readOds(reference.package);
|
|
196
|
+
return {
|
|
197
|
+
kind: "spreadsheet",
|
|
198
|
+
formatVersion: document_schema_js.CONTENT_FORMAT_VERSION,
|
|
199
|
+
metadata,
|
|
200
|
+
sheets
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
function collectAnchoredFrame(frameElement, groupFunctions, pkg, anchorRow, anchorColumn, images, embeddedObjects) {
|
|
206
|
+
const shape = require_typed_draw_shapes.readDrawFrame(frameElement, groupFunctions, pkg);
|
|
207
|
+
if (shape === void 0) return;
|
|
208
|
+
const reference = require_typed_draw_embedded.readDrawObjectReference(frameElement, pkg);
|
|
209
|
+
if (reference !== void 0) {
|
|
210
|
+
embeddedObjects.push({
|
|
211
|
+
objectKind: reference.objectKind,
|
|
212
|
+
document: readEmbeddedObjectDocument(reference),
|
|
213
|
+
frame: shape.frame
|
|
214
|
+
});
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
for (const block of shape.blocks) if (block.kind === "image") images.push({
|
|
218
|
+
...block,
|
|
219
|
+
anchorRow,
|
|
220
|
+
anchorColumn,
|
|
221
|
+
offsetXPt: shape.frame.xPt,
|
|
222
|
+
offsetYPt: shape.frame.yPt
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
function collectAnchoredFrames(children, groupFunctions, pkg, anchorRow, anchorColumn, images, embeddedObjects) {
|
|
226
|
+
for (const child of children) {
|
|
227
|
+
if (child.type !== "element") continue;
|
|
228
|
+
if (child.tag === "draw:frame") collectAnchoredFrame(child, groupFunctions, pkg, anchorRow, anchorColumn, images, embeddedObjects);
|
|
229
|
+
else if (child.tag === "draw:g") {
|
|
230
|
+
const ownValue = require_xml_query.attrValue(child, "draw:transform");
|
|
231
|
+
const ownFunctions = ownValue === void 0 ? [] : require_typed_shared_transform.parseOdfTransform(ownValue);
|
|
232
|
+
const nested = ownFunctions.length === 0 ? groupFunctions : [...ownFunctions, ...groupFunctions];
|
|
233
|
+
collectAnchoredFrames(child.children, nested, pkg, anchorRow, anchorColumn, images, embeddedObjects);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
159
237
|
function readTable(tableElement, pkg) {
|
|
160
238
|
const columns = [];
|
|
161
239
|
const rows = [];
|
|
162
240
|
const cells = [];
|
|
241
|
+
const images = [];
|
|
242
|
+
const embeddedObjects = [];
|
|
163
243
|
const manualBreakRows = [];
|
|
164
244
|
const manualBreakColumns = [];
|
|
165
245
|
let repeatColumns;
|
|
@@ -184,6 +264,7 @@ function readTable(tableElement, pkg) {
|
|
|
184
264
|
const columnIndex = cursor.columnIndex;
|
|
185
265
|
const rowIndex = cursor.rowIndex;
|
|
186
266
|
cursor.nextCell(readRepeatCount(child, "table:number-columns-repeated"));
|
|
267
|
+
collectAnchoredFrames(child.children, [], pkg, rowIndex, columnIndex, images, embeddedObjects);
|
|
187
268
|
const formula = require_xml_query.attrValue(child, "table:formula");
|
|
188
269
|
const { runs, displayText } = readCellText(child, pkg);
|
|
189
270
|
if (!(require_xml_query.attrValue(child, "office:value-type") !== void 0) && formula === void 0 && displayText.length === 0) continue;
|
|
@@ -225,7 +306,8 @@ function readTable(tableElement, pkg) {
|
|
|
225
306
|
}
|
|
226
307
|
for (const child of tableElement.children) {
|
|
227
308
|
if (child.type !== "element") continue;
|
|
228
|
-
if (child.tag === "table:
|
|
309
|
+
if (child.tag === "table:shapes") collectAnchoredFrames(child.children, [], pkg, 0, 0, images, embeddedObjects);
|
|
310
|
+
else if (child.tag === "table:table-column") processColumn(child);
|
|
229
311
|
else if (child.tag === "table:table-header-columns") {
|
|
230
312
|
const startIndex = columnCursor;
|
|
231
313
|
for (const headerChild of child.children) if (headerChild.type === "element" && headerChild.tag === "table:table-column") processColumn(headerChild);
|
|
@@ -247,6 +329,8 @@ function readTable(tableElement, pkg) {
|
|
|
247
329
|
columns,
|
|
248
330
|
rows,
|
|
249
331
|
cells,
|
|
332
|
+
images,
|
|
333
|
+
embeddedObjects,
|
|
250
334
|
repeatColumns,
|
|
251
335
|
repeatRows,
|
|
252
336
|
manualBreakRows,
|
|
@@ -296,15 +380,17 @@ function readPrintSettings(tableElement, pkg, repeatColumns, repeatRows, manualB
|
|
|
296
380
|
function readSheet(tableElement, pkg) {
|
|
297
381
|
const name = require_xml_query.attrValue(tableElement, "table:name");
|
|
298
382
|
if (name === void 0) return;
|
|
299
|
-
const { columns, rows, cells, repeatColumns, repeatRows, manualBreakRows, manualBreakColumns } = readTable(tableElement, pkg);
|
|
300
|
-
|
|
383
|
+
const { columns, rows, cells, images, embeddedObjects, repeatColumns, repeatRows, manualBreakRows, manualBreakColumns } = readTable(tableElement, pkg);
|
|
384
|
+
const sheet = {
|
|
301
385
|
name,
|
|
302
386
|
cells,
|
|
303
387
|
columns,
|
|
304
388
|
rows,
|
|
305
|
-
images
|
|
389
|
+
images,
|
|
306
390
|
printSettings: readPrintSettings(tableElement, pkg, repeatColumns, repeatRows, manualBreakRows, manualBreakColumns)
|
|
307
391
|
};
|
|
392
|
+
if (embeddedObjects.length > 0) sheet.embeddedObjects = embeddedObjects;
|
|
393
|
+
return sheet;
|
|
308
394
|
}
|
|
309
395
|
function readOds(pkg) {
|
|
310
396
|
const contentPart = pkg.parts[CONTENT_PART];
|
package/dist/typed/ods/read.js
CHANGED
|
@@ -6,8 +6,14 @@ import { findStyleElement, resolveStyleElementChain } from "../shared/cascade.js
|
|
|
6
6
|
import { readOdfMetadata } from "../shared/metadata.js";
|
|
7
7
|
import { readOdfParagraph } from "../shared/paragraph.js";
|
|
8
8
|
import { readCellStyleDecoration } from "../shared/table.js";
|
|
9
|
+
import { parseOdfTransform } from "../shared/transform.js";
|
|
9
10
|
import { resolvePageLayoutProperties } from "../shared/masterpage.js";
|
|
10
|
-
import {
|
|
11
|
+
import { readDrawFrame } from "../draw/shapes.js";
|
|
12
|
+
import { readDrawObjectReference } from "../draw/embedded.js";
|
|
13
|
+
import { readOdp } from "../odp/read.js";
|
|
14
|
+
import { readOdt } from "../odt/read.js";
|
|
15
|
+
import { readOdg } from "../odg/read.js";
|
|
16
|
+
import { CONTENT_FORMAT_VERSION, PAGE_SIZE_A4 } from "document-schema.js";
|
|
11
17
|
//#region src/typed/ods/read.ts
|
|
12
18
|
const CONTENT_PART = "content.xml";
|
|
13
19
|
function parseKnownOdfLength(value) {
|
|
@@ -155,10 +161,84 @@ function parseNonNegativeInteger(value) {
|
|
|
155
161
|
const parsed = Number.parseInt(value, 10);
|
|
156
162
|
return Number.isInteger(parsed) && parsed >= 0 ? parsed : void 0;
|
|
157
163
|
}
|
|
164
|
+
function readEmbeddedObjectDocument(reference) {
|
|
165
|
+
switch (reference.objectKind) {
|
|
166
|
+
case "wordprocessing": {
|
|
167
|
+
const { metadata, sections } = readOdt(reference.package);
|
|
168
|
+
return {
|
|
169
|
+
kind: "wordprocessing",
|
|
170
|
+
formatVersion: CONTENT_FORMAT_VERSION,
|
|
171
|
+
metadata,
|
|
172
|
+
sections
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
case "presentation": {
|
|
176
|
+
const { metadata, slides } = readOdp(reference.package);
|
|
177
|
+
return {
|
|
178
|
+
kind: "presentation",
|
|
179
|
+
formatVersion: CONTENT_FORMAT_VERSION,
|
|
180
|
+
metadata,
|
|
181
|
+
slides
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
case "drawing": {
|
|
185
|
+
const { metadata, pages } = readOdg(reference.package);
|
|
186
|
+
return {
|
|
187
|
+
kind: "drawing",
|
|
188
|
+
formatVersion: CONTENT_FORMAT_VERSION,
|
|
189
|
+
metadata,
|
|
190
|
+
pages
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
case "spreadsheet": {
|
|
194
|
+
const { metadata, sheets } = readOds(reference.package);
|
|
195
|
+
return {
|
|
196
|
+
kind: "spreadsheet",
|
|
197
|
+
formatVersion: CONTENT_FORMAT_VERSION,
|
|
198
|
+
metadata,
|
|
199
|
+
sheets
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function collectAnchoredFrame(frameElement, groupFunctions, pkg, anchorRow, anchorColumn, images, embeddedObjects) {
|
|
205
|
+
const shape = readDrawFrame(frameElement, groupFunctions, pkg);
|
|
206
|
+
if (shape === void 0) return;
|
|
207
|
+
const reference = readDrawObjectReference(frameElement, pkg);
|
|
208
|
+
if (reference !== void 0) {
|
|
209
|
+
embeddedObjects.push({
|
|
210
|
+
objectKind: reference.objectKind,
|
|
211
|
+
document: readEmbeddedObjectDocument(reference),
|
|
212
|
+
frame: shape.frame
|
|
213
|
+
});
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
for (const block of shape.blocks) if (block.kind === "image") images.push({
|
|
217
|
+
...block,
|
|
218
|
+
anchorRow,
|
|
219
|
+
anchorColumn,
|
|
220
|
+
offsetXPt: shape.frame.xPt,
|
|
221
|
+
offsetYPt: shape.frame.yPt
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
function collectAnchoredFrames(children, groupFunctions, pkg, anchorRow, anchorColumn, images, embeddedObjects) {
|
|
225
|
+
for (const child of children) {
|
|
226
|
+
if (child.type !== "element") continue;
|
|
227
|
+
if (child.tag === "draw:frame") collectAnchoredFrame(child, groupFunctions, pkg, anchorRow, anchorColumn, images, embeddedObjects);
|
|
228
|
+
else if (child.tag === "draw:g") {
|
|
229
|
+
const ownValue = attrValue(child, "draw:transform");
|
|
230
|
+
const ownFunctions = ownValue === void 0 ? [] : parseOdfTransform(ownValue);
|
|
231
|
+
const nested = ownFunctions.length === 0 ? groupFunctions : [...ownFunctions, ...groupFunctions];
|
|
232
|
+
collectAnchoredFrames(child.children, nested, pkg, anchorRow, anchorColumn, images, embeddedObjects);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
158
236
|
function readTable(tableElement, pkg) {
|
|
159
237
|
const columns = [];
|
|
160
238
|
const rows = [];
|
|
161
239
|
const cells = [];
|
|
240
|
+
const images = [];
|
|
241
|
+
const embeddedObjects = [];
|
|
162
242
|
const manualBreakRows = [];
|
|
163
243
|
const manualBreakColumns = [];
|
|
164
244
|
let repeatColumns;
|
|
@@ -183,6 +263,7 @@ function readTable(tableElement, pkg) {
|
|
|
183
263
|
const columnIndex = cursor.columnIndex;
|
|
184
264
|
const rowIndex = cursor.rowIndex;
|
|
185
265
|
cursor.nextCell(readRepeatCount(child, "table:number-columns-repeated"));
|
|
266
|
+
collectAnchoredFrames(child.children, [], pkg, rowIndex, columnIndex, images, embeddedObjects);
|
|
186
267
|
const formula = attrValue(child, "table:formula");
|
|
187
268
|
const { runs, displayText } = readCellText(child, pkg);
|
|
188
269
|
if (!(attrValue(child, "office:value-type") !== void 0) && formula === void 0 && displayText.length === 0) continue;
|
|
@@ -224,7 +305,8 @@ function readTable(tableElement, pkg) {
|
|
|
224
305
|
}
|
|
225
306
|
for (const child of tableElement.children) {
|
|
226
307
|
if (child.type !== "element") continue;
|
|
227
|
-
if (child.tag === "table:
|
|
308
|
+
if (child.tag === "table:shapes") collectAnchoredFrames(child.children, [], pkg, 0, 0, images, embeddedObjects);
|
|
309
|
+
else if (child.tag === "table:table-column") processColumn(child);
|
|
228
310
|
else if (child.tag === "table:table-header-columns") {
|
|
229
311
|
const startIndex = columnCursor;
|
|
230
312
|
for (const headerChild of child.children) if (headerChild.type === "element" && headerChild.tag === "table:table-column") processColumn(headerChild);
|
|
@@ -246,6 +328,8 @@ function readTable(tableElement, pkg) {
|
|
|
246
328
|
columns,
|
|
247
329
|
rows,
|
|
248
330
|
cells,
|
|
331
|
+
images,
|
|
332
|
+
embeddedObjects,
|
|
249
333
|
repeatColumns,
|
|
250
334
|
repeatRows,
|
|
251
335
|
manualBreakRows,
|
|
@@ -295,15 +379,17 @@ function readPrintSettings(tableElement, pkg, repeatColumns, repeatRows, manualB
|
|
|
295
379
|
function readSheet(tableElement, pkg) {
|
|
296
380
|
const name = attrValue(tableElement, "table:name");
|
|
297
381
|
if (name === void 0) return;
|
|
298
|
-
const { columns, rows, cells, repeatColumns, repeatRows, manualBreakRows, manualBreakColumns } = readTable(tableElement, pkg);
|
|
299
|
-
|
|
382
|
+
const { columns, rows, cells, images, embeddedObjects, repeatColumns, repeatRows, manualBreakRows, manualBreakColumns } = readTable(tableElement, pkg);
|
|
383
|
+
const sheet = {
|
|
300
384
|
name,
|
|
301
385
|
cells,
|
|
302
386
|
columns,
|
|
303
387
|
rows,
|
|
304
|
-
images
|
|
388
|
+
images,
|
|
305
389
|
printSettings: readPrintSettings(tableElement, pkg, repeatColumns, repeatRows, manualBreakRows, manualBreakColumns)
|
|
306
390
|
};
|
|
391
|
+
if (embeddedObjects.length > 0) sheet.embeddedObjects = embeddedObjects;
|
|
392
|
+
return sheet;
|
|
307
393
|
}
|
|
308
394
|
function readOds(pkg) {
|
|
309
395
|
const contentPart = pkg.parts[CONTENT_PART];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "odf.js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Type-safe, lossless round-trip conversion between OpenDocument Format packages (odt, ods, odp) and JSON, hand-written and dependency-minimal, built on Zod 4 codecs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|