Commit Graph
38 Commits
Author SHA1 Message Date
Dylan M. Taylor d9e56e3f7c Merge pull request #1290 from vangel76/feat/docx-chart-axis-series
DOCX charts keep axis and series formatting
2026-11-15 18:30:37 -05:00
vangel76andClaude Sonnet 5.5 b4463c6203 docx charts: outline unfilled bars, honour no-fill areas, keep source-linked label formats
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-15 13:30:44 +01:00
vangel76andClaude Sonnet 5.5 8761999c9b docx charts: automatic marker colour, data label positions, horizontal axis titles
Word draws markers without their own fill in the automatic palette colour of the
series index, not the explicit line colour. Line and scatter data labels sit to
the right of the point unless c:dLblPos says t, b, l, r or ctr. A vertical-axis
title with rot="0" stays horizontal, wrapped into a strip of at most a quarter of
the chart width, instead of being forced to -90 degrees.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-15 01:19:18 +01:00
vangel76andClaude Sonnet 5.5 396402940c docx charts: marker symbols and sizes, data label formats, upward axis titles
A chart file carried three things that were read but not drawn like Word:
- c:marker/c:symbol was ignored (every marker was a circle): squares, diamonds,
  triangles, x, plus, star, dash and dot are drawn now, in the series' c:size;
  unknown names fall back to a circle, sizes are clamped to 2..72 points.
- c:dLbls/c:numFmt (not linked to the source) now formats the data labels, on
  the series or on the chart type; over-long codes are ignored.
- The vertical axis title is turned -90 degrees (reading upwards) as Word does,
  or 90 when the file's bodyPr rot says so. It was always +90.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-15 01:06:12 +01:00
batistalucasv 80ed9665e7 craft-docx: preserve w:numberingChange without active list and raise w:original bound 2026-11-14 15:25:54 -03:00
vangel76andClaude Sonnet 5.5 0edccaf1bc docx: category gridlines follow line and area points when the axis crosses mid
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 18:59:56 +01:00
vangel76andClaude Sonnet 5.5 40d27e4ede docx: bar category labels start after the axis title strip
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 18:59:56 +01:00
vangel76andClaude Sonnet 5.5 e1cd8b5e01 docx: no_fill wins over a stored series colour
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 18:58:38 +01:00
vangel76andClaude Sonnet 5.5 4d8273712e docx: count chart axis format characters like the model
The reader counted UTF-8 bytes against 255 while the model keeps 128 characters,
so a CJK axis format was written and then dropped on reading. Use MAX_FMT.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 18:58:38 +01:00
Dylan M. Taylor 7ad4765ee5 Merge pull request #1325 from storytold/codex/docx-level-presence
docx: retain explicitly defined numbering levels
2026-11-14 11:48:48 -05:00
Dylan M. Taylor 874c94f2b1 Merge pull request #1311 from pakiat/fix/field-results-complex-script
craft-docx: a field's Thai result takes the complex-script formatting only where Word does
2026-11-14 11:43:58 -05:00
Dylan M. Taylor 5c8e1b0d82 docx: retain explicit numbering level presence 2026-11-14 15:10:43 +00:00
Naxvog 5f67d91eee craft-docx: a file with no default table style gives its tables no cell margins
Port of storytold/wordcraft#3821, whose reader code moved here with storytold/wordcraft#6603. Word's 0.08" cell margin comes from the Normal Table default table style; without a default table style a table that sets no margins (and whose style sets none) has zero margins. The zeros are kept as the table's own, also for the old properties of a tblPrChange, so they survive saving. w:default="on" now marks a default style too.
2026-11-14 15:27:22 +01:00
Dylan M. Taylor 8097ede0ff Resolve DOCX migration conflict with current main 2026-11-14 13:29:23 +00:00
Dylan M. Taylor 6d19bb44f3 fix(docx): preserve Normal inference compatibility 2026-11-14 13:25:25 +00:00
Dylan M. Taylor 31f4185fa5 test(docx): preserve explicit Normal-off serialization 2026-11-14 13:25:25 +00:00
Dylan M. Taylor 90d20fd39f fix(docx): keep default Normal for fresh documents 2026-11-14 13:25:25 +00:00
Dylan M. Taylor 00fdde1f06 docx: retain explicit nondefault Normal on write 2026-11-14 13:25:25 +00:00
Dylan M. Taylor a94c1a386a Respect on-valued default paragraph styles 2026-11-14 13:25:25 +00:00
Dylan M. Taylor 15740f3083 fix(docx): mark declared Normal as the default 2026-11-14 13:25:13 +00:00
pakiatandClaude Opus 5.5 9a5a35334a craft-docx: a field's Thai result takes the complex-script formatting only where Word does
Measured in Word for Windows: Thai text as a field's result follows the rule ordinary text does. mark_runs_as_word_draws_them counts the result of a field kept as one object as the text of its run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 11:52:27 +00:00
Dylan M. Taylor 4baa7d81ca fix(docx): ignore overrides without a list level 2026-11-14 10:57:01 +00:00
Dylan M. Taylor 7ac384839d fix(docx): ignore malformed list levels 2026-11-14 10:45:23 +00:00
pakiatandClaude Opus 5.5 24907cbd7a craft-wordmodel: mark runs as Word draws them in the model, for every reader
StyleSheet::mark_runs_as_word_draws_them moves from the DOCX reader into the model, unchanged, so the .doc reader can apply the same rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 10:41:38 +00:00
vangel76andClaude Sonnet 5.5 b6a2df0c1d docx: chart axis and series formatting
Add the series formatting (fill, line, markers, smooth, labels, number
format) and the category/value axis formatting (title, bounds, number
format, gridlines, tick labels, axis line) to the chart model, and read
and write them in the DOCX chart part. GraphicItem::Text gets an angle
for the rotated vertical axis title. With none of the new fields set the
chart part is written as before.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 11:27:03 +01:00
pakiatandClaude Opus 5.5 0e83ef6d51 craft-docx: Thai text outside a complex-script run takes the run's own font and size, as in Word
Moved from the DOCX part of storytold/wordcraft#6244. Runs are marked with what Word counts as complex script (the run, its paragraph style chain, its table style and the run defaults, not a character style). StyleSheet::table_cells_chr works out a table's cell run formatting once; ResolvedChar gains cs_off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 09:33:37 +00:00
Dylan M. Taylor 506610767b Merge pull request #1266 from storytold/codex/docx-measure-clamp
docx: clamp large measurements in f64
2026-11-14 02:21:06 -05:00
Dylan M. Taylor f5ccaba5d3 Merge pull request #1265 from storytold/codex/docx-notes-fallback
docx: read conventional footnote and endnote parts
2026-11-14 02:20:44 -05:00
Dylan M. Taylor 9ea7a82027 fix(docx,wordmodel): preserve style revisions, lnNumType countBy guard, and deterministic Paragraph Debug 2026-11-14 06:11:36 +00:00
Dylan M. Taylor d2fd4fb09e Clamp OOXML measurements before f32 conversion 2026-11-14 04:54:11 +00:00
Dylan M. Taylor 0559e4214e Read conventional footnote and endnote parts 2026-11-14 04:48:57 +00:00
Dylan M. Taylor 7f59e8f3f5 fix(docx): preserve case-insensitive main part fallback 2026-11-14 03:04:54 +00:00
Dylan M. Taylor fbbebecf27 Preserve conventional Word part fallback 2026-11-14 02:28:04 +00:00
Dylan M. Taylor de7640a006 feat(xml): preserve strict end-tag parsing as an option 2026-11-13 21:11:56 -05:00
Dylan M. Taylor 09c1ecc2a0 craft-docx: custom geometry through craft-drawingml (arcs and guides read) (#1056)
* Add craft-wordmodel: WordCraft's document model without its editing code

WordCraft's crates/doc (wordcraft-doc, at 07f97737) moved as it is, so the DOCX,
RTF, ODT and other text-format crates can read into and write from one model.
Module paths, type names and serde attributes are unchanged: an app that
re-exports the crate keeps its native file format.

Left in the app: range editing (edit.rs), IME text and equation editing. Not
model, and already in craft-libs: code pages (craft-rtf), the ZIP entry-count
check (craft-opc), the compound-file guard (craft-cfb). The paragraph walks
moved to walk.rs and the unit helpers of wordcraft-geom to geom.rs.

* craft-wordmodel: math_tree, the arguments of an equation node and a walk over its runs

The DOCX reader and writer walk an equation's runs. The walk and the child
accessors it uses were in WordCraft's equation editor (math_edit.rs), which
stays in the app; they are structure, not editing.

* craft-wordmodel: keep the document operations (edit.rs) with the model

The DOCX and RTF readers use them: alternative-format chunks are merged into
a document with adopt_blocks, and a reader formats ranges with format_range
and inserts objects. They operate on the document, not on a view, so they
belong beside it. The tests that drove them come back with them; the
paragraph walks stay in walk.rs and edit re-exports them.

base64 0.23, as WordCraft and craft-offcrypto use.

* craft-docx: WordCraft's crates/docx as it is at wordcraft 07f97737

The source, unchanged, so the next commit shows only what the move changes.
This commit does not build on its own (it still names wordcraft-doc and
wordcraft-geom, and is not a workspace member yet).

* craft-docx: on craft-wordmodel, craft-opc, craft-xml and craft-offcrypto

- The package (zip reading, part names, relationships, content types,
  zip writing) is craft-opc's; the module keeps WordCraft's bookkeeping
  (passthrough keys, the embedded-part manifest) and its own Rel/Rels shape.
- Parts are parsed with craft-xml's canonical names (the Strict drawing
  names and mc:Choice/@Requires through its hooks), then given the tree
  shape the reader was written against.
- Encryption and Restrict Editing hashes are craft-offcrypto's; this crate
  maps its errors and the w:documentProtection attributes.
- wordcraft-doc is craft-wordmodel; wordcraft-geom's helpers are its geom.

Tests that covered what now lives in craft-opc and craft-offcrypto are left to
those crates; the DIFAT regression is craft-cfb's. Test-only zip use follows
zip 9's fallible names. The attribute-cap test times the read only.

* craft-docx: DrawingML colours through craft-drawingml

Preset colours and the colour transforms of a:srgbClr, a:schemeClr and the
other colour elements are craft-drawingml's (craft_drawingml::color::preset,
ColorTransform, apply); opacity stays here, in percent.

craft-drawingml's preset table takes WordCraft's names (19 more, and the
dk/lt/grey spellings) and is case-insensitive, as WordCraft's was.

Two behaviours change, both to what craft-drawingml and LibreOffice do:
- a:tint and a:shade mix in linear light, not in sRGB bytes (a 50% shade of
  64 128 192 is 44 92 140, not 32 64 96); two tests are updated;
- the transforms WordCraft ignored (hueMod, hueOff, satOff, comp, inv, gray,
  redMod, greenMod, blueMod) are applied.

* craft-drawingml: test the preset names in any case and their dk/lt spellings

* craft-docx: custom geometry (a:custGeom) read by craft-drawingml

read_cust_geom evaluates the shape's guides and turns arcs into Bézier
curves; this crate flattens its paths into the model's freeform as before.
Arcs were drawn straight to their end and points named by guides were lost;
a test covers both.
2026-11-11 21:36:33 -05:00
Dylan M. Taylor f3fe9de956 craft-docx: DrawingML colours through craft-drawingml; its preset table takes WordCraft's names (#1049)
* Add craft-wordmodel: WordCraft's document model without its editing code

WordCraft's crates/doc (wordcraft-doc, at 07f97737) moved as it is, so the DOCX,
RTF, ODT and other text-format crates can read into and write from one model.
Module paths, type names and serde attributes are unchanged: an app that
re-exports the crate keeps its native file format.

Left in the app: range editing (edit.rs), IME text and equation editing. Not
model, and already in craft-libs: code pages (craft-rtf), the ZIP entry-count
check (craft-opc), the compound-file guard (craft-cfb). The paragraph walks
moved to walk.rs and the unit helpers of wordcraft-geom to geom.rs.

* craft-wordmodel: math_tree, the arguments of an equation node and a walk over its runs

The DOCX reader and writer walk an equation's runs. The walk and the child
accessors it uses were in WordCraft's equation editor (math_edit.rs), which
stays in the app; they are structure, not editing.

* craft-wordmodel: keep the document operations (edit.rs) with the model

The DOCX and RTF readers use them: alternative-format chunks are merged into
a document with adopt_blocks, and a reader formats ranges with format_range
and inserts objects. They operate on the document, not on a view, so they
belong beside it. The tests that drove them come back with them; the
paragraph walks stay in walk.rs and edit re-exports them.

base64 0.23, as WordCraft and craft-offcrypto use.

* craft-docx: WordCraft's crates/docx as it is at wordcraft 07f97737

The source, unchanged, so the next commit shows only what the move changes.
This commit does not build on its own (it still names wordcraft-doc and
wordcraft-geom, and is not a workspace member yet).

* craft-docx: on craft-wordmodel, craft-opc, craft-xml and craft-offcrypto

- The package (zip reading, part names, relationships, content types,
  zip writing) is craft-opc's; the module keeps WordCraft's bookkeeping
  (passthrough keys, the embedded-part manifest) and its own Rel/Rels shape.
- Parts are parsed with craft-xml's canonical names (the Strict drawing
  names and mc:Choice/@Requires through its hooks), then given the tree
  shape the reader was written against.
- Encryption and Restrict Editing hashes are craft-offcrypto's; this crate
  maps its errors and the w:documentProtection attributes.
- wordcraft-doc is craft-wordmodel; wordcraft-geom's helpers are its geom.

Tests that covered what now lives in craft-opc and craft-offcrypto are left to
those crates; the DIFAT regression is craft-cfb's. Test-only zip use follows
zip 9's fallible names. The attribute-cap test times the read only.

* craft-docx: DrawingML colours through craft-drawingml

Preset colours and the colour transforms of a:srgbClr, a:schemeClr and the
other colour elements are craft-drawingml's (craft_drawingml::color::preset,
ColorTransform, apply); opacity stays here, in percent.

craft-drawingml's preset table takes WordCraft's names (19 more, and the
dk/lt/grey spellings) and is case-insensitive, as WordCraft's was.

Two behaviours change, both to what craft-drawingml and LibreOffice do:
- a:tint and a:shade mix in linear light, not in sRGB bytes (a 50% shade of
  64 128 192 is 44 92 140, not 32 64 96); two tests are updated;
- the transforms WordCraft ignored (hueMod, hueOff, satOff, comp, inv, gray,
  redMod, greenMod, blueMod) are applied.

* craft-drawingml: test the preset names in any case and their dk/lt spellings
2026-11-11 21:33:23 -05:00
Dylan M. Taylorandshuff57 865671e1fd craft-docx: equations through craft_math::omml (#1035)
* Add craft-wordmodel: WordCraft's document model without its editing code

WordCraft's crates/doc (wordcraft-doc, at 07f97737) moved as it is, so the DOCX,
RTF, ODT and other text-format crates can read into and write from one model.
Module paths, type names and serde attributes are unchanged: an app that
re-exports the crate keeps its native file format.

Left in the app: range editing (edit.rs), IME text and equation editing. Not
model, and already in craft-libs: code pages (craft-rtf), the ZIP entry-count
check (craft-opc), the compound-file guard (craft-cfb). The paragraph walks
moved to walk.rs and the unit helpers of wordcraft-geom to geom.rs.

* craft-wordmodel: math_tree, the arguments of an equation node and a walk over its runs

The DOCX reader and writer walk an equation's runs. The walk and the child
accessors it uses were in WordCraft's equation editor (math_edit.rs), which
stays in the app; they are structure, not editing.

* craft-wordmodel: keep the document operations (edit.rs) with the model

The DOCX and RTF readers use them: alternative-format chunks are merged into
a document with adopt_blocks, and a reader formats ranges with format_range
and inserts objects. They operate on the document, not on a view, so they
belong beside it. The tests that drove them come back with them; the
paragraph walks stay in walk.rs and edit re-exports them.

base64 0.23, as WordCraft and craft-offcrypto use.

* craft-docx: WordCraft's crates/docx as it is at wordcraft 07f97737

The source, unchanged, so the next commit shows only what the move changes.
This commit does not build on its own (it still names wordcraft-doc and
wordcraft-geom, and is not a workspace member yet).

* Add craft-math: the equation tree with OMML, MathML, LaTeX and UnicodeMath

The math tree, LaTeX, linear-format, symbol and tree-walk modules come
from craft-wordmodel (storytold/craft-libs#963, WordCraft's crates/doc at
07f97737) unchanged, with the run colour (Rgb) and the symbol-font tables
they use. MathML is WordCraft's crates/formats/src/mathml.rs and OMML is
WordCraft's crates/docx/src/read/math.rs and write/math.rs (06c2ae6f /
07f97737), moved onto craft-xml. The HTML-specific MathML tests stay in
WordCraft; the rest moved with the code.

mathml::parse and omml::parse/read_str/write_str are new: string entry
points for callers that have no tree of their own.

* craft-math: read MathLive's and other spellings of LaTeX math commands

\abs{...} (an absolute value), \lvert \rvert \lVert \rVert, \nparallel,
\backprime, \infinity, \cross, \differentialD, \exponentialE and
\imaginaryI (MathLive's d, upright e and i), \emph, \textsf, \hbox,
\mathnormal and \underleftarrow / \underrightarrow /
\underleftrightarrow were unknown and read as literal text. They are read
as equaSHion's typed-input parser reads them (storytold/craft-libs#29).

* craft-math: equaSHion's equation corpus as test data

corpus/equations.tsv, corpus/latex.tsv and the OMML samples of
storytold/craft-libs#29 (7a6ef6b9), unmodified.

* craft-math: corpus round trips, GridCraft's OMML cases, entry points and limits tested; README

The corpus equations go through OMML, MathML and LaTeX and back; the OMML
samples are written back as kept and from the tree. GridCraft's OMML to
LaTeX test cases (crates/xlsx/src/omml.rs) give LaTeX that reads back the
same through the tree. omml::parse and read_str are tested against other
prefixes, the strict namespace, kept OMML, junk, the element cap and deep
nesting.

* craft-docx: on craft-wordmodel, craft-opc, craft-xml and craft-offcrypto

- The package (zip reading, part names, relationships, content types,
  zip writing) is craft-opc's; the module keeps WordCraft's bookkeeping
  (passthrough keys, the embedded-part manifest) and its own Rel/Rels shape.
- Parts are parsed with craft-xml's canonical names (the Strict drawing
  names and mc:Choice/@Requires through its hooks), then given the tree
  shape the reader was written against.
- Encryption and Restrict Editing hashes are craft-offcrypto's; this crate
  maps its errors and the w:documentProtection attributes.
- wordcraft-doc is craft-wordmodel; wordcraft-geom's helpers are its geom.

Tests that covered what now lives in craft-opc and craft-offcrypto are left to
those crates; the DIFAT regression is craft-cfb's. Test-only zip use follows
zip 9's fallible names. The attribute-cap test times the read only.

* craft-wordmodel: the math modules, symbol_fonts and Rgb are craft-math's

math, math_latex, math_linear, math_symbols, math_tree and symbol_fonts are
re-exported from craft-math at the paths they had, and props::Rgb is
craft-math's Rgb (TextColor stays), so the serde forms and the app's imports
do not change. Their tests are in craft-math.

* craft-docx: equations (OMML) are read and written by craft_math::omml

read/math.rs and write/math.rs keep their functions as adapters: the reader's
tree is handed to craft-math as a craft-xml tree, and the writer's output is
written into this crate's writer. Their tests are in craft-math.

---------

Co-authored-by: shuff57 <62350898+shuff57@users.noreply.github.com>
2026-11-11 21:32:31 -05:00
Dylan M. Taylor e3e31693c7 Add craft-docx: WordCraft's DOCX reader and writer on craft-wordmodel, craft-opc and craft-xml (#1015)
* Add craft-wordmodel: WordCraft's document model without its editing code

WordCraft's crates/doc (wordcraft-doc, at 07f97737) moved as it is, so the DOCX,
RTF, ODT and other text-format crates can read into and write from one model.
Module paths, type names and serde attributes are unchanged: an app that
re-exports the crate keeps its native file format.

Left in the app: range editing (edit.rs), IME text and equation editing. Not
model, and already in craft-libs: code pages (craft-rtf), the ZIP entry-count
check (craft-opc), the compound-file guard (craft-cfb). The paragraph walks
moved to walk.rs and the unit helpers of wordcraft-geom to geom.rs.

* craft-wordmodel: math_tree, the arguments of an equation node and a walk over its runs

The DOCX reader and writer walk an equation's runs. The walk and the child
accessors it uses were in WordCraft's equation editor (math_edit.rs), which
stays in the app; they are structure, not editing.

* craft-wordmodel: keep the document operations (edit.rs) with the model

The DOCX and RTF readers use them: alternative-format chunks are merged into
a document with adopt_blocks, and a reader formats ranges with format_range
and inserts objects. They operate on the document, not on a view, so they
belong beside it. The tests that drove them come back with them; the
paragraph walks stay in walk.rs and edit re-exports them.

base64 0.23, as WordCraft and craft-offcrypto use.

* craft-docx: WordCraft's crates/docx as it is at wordcraft 07f97737

The source, unchanged, so the next commit shows only what the move changes.
This commit does not build on its own (it still names wordcraft-doc and
wordcraft-geom, and is not a workspace member yet).

* craft-docx: on craft-wordmodel, craft-opc, craft-xml and craft-offcrypto

- The package (zip reading, part names, relationships, content types,
  zip writing) is craft-opc's; the module keeps WordCraft's bookkeeping
  (passthrough keys, the embedded-part manifest) and its own Rel/Rels shape.
- Parts are parsed with craft-xml's canonical names (the Strict drawing
  names and mc:Choice/@Requires through its hooks), then given the tree
  shape the reader was written against.
- Encryption and Restrict Editing hashes are craft-offcrypto's; this crate
  maps its errors and the w:documentProtection attributes.
- wordcraft-doc is craft-wordmodel; wordcraft-geom's helpers are its geom.

Tests that covered what now lives in craft-opc and craft-offcrypto are left to
those crates; the DIFAT regression is craft-cfb's. Test-only zip use follows
zip 9's fallible names. The attribute-cap test times the read only.
2026-11-11 20:31:40 -05:00