Commit Graph
70 Commits
Author SHA1 Message Date
Dylan M. Taylor 8672aff3d8 Merge pull request #1991 from storytold/fix/plot-range-contains
unbreak the Workspace gate: the xlsx fixture Result and the docx range-contains lint
2026-11-17 03:17:42 -05:00
FredApps cc22854ea4 Preserve ODF lookahead and stacking normalization together 2026-11-17 04:59:07 +01:00
FredApps 0dbd888f3c Integrate page background preservation with stacking normalization 2026-11-17 04:12:46 +01:00
Dylan M. Taylor b4d17d3943 docx: preserve horizontal axis-title rotation guard semantics 2026-11-16 22:03:46 -05:00
Dylan M. Taylor 1901b2fac6 docx: satisfy clippy's range-contains lint in the chart title guard
main's gate fails here for every pull request: `!(r < 1.0 || r > 359.0)` is
exactly what `manual_range_contains` rejects. Express the same range as
`(1.0..=359.0).contains(&r)`.
2026-11-16 21:54:47 -05:00
midasmatterhorn 93598bc018 craft-docx: documentProtection without w:enforcement is enforced, as in Word, and survives a save (#1750) 2026-11-16 21:31:25 -05:00
Hamza Naveed 76fc04feee craft-docx: relate the bibliography store from the main part, not the package (#1835) 2026-11-16 21:30:40 -05:00
Joseph Anglada b1d3abc55e DOCX: the parts of a package that cannot be read are listed on the document (#1902) 2026-11-16 21:30:17 -05:00
Joseph Anglada 38e5614b9c SmartArt: an item's opacity is read, written and drawn (#1906) 2026-11-16 21:30:04 -05:00
keithcsqueensu 738bf6fafe docx: write a font table naming the fonts a document uses (#1948) 2026-11-16 21:29:43 -05:00
FredApps 1612dd35b9 Integrate current drawing readers and preserve retained OLE stacking 2026-11-17 03:11:41 +01:00
Dylan M. Taylor 4992583846 Merge pull request #1898 from StDenis1980/tinta/upstream-application-name
docx: set_application_name for apps that embed the writer
2026-11-16 19:16:04 -05:00
Dylan M. Taylor 68cc642520 Merge pull request #1791 from vangel76/feat/6820-chartex-placeholder
Office 2016 charts with a text-only fallback keep their size instead of collapsing the pages
2026-11-16 16:12:25 -05:00
Dylan M. Taylor 09cae32c45 Merge pull request #1776 from vangel76/fix/gutter-at-top
The "gutter at top" page setting in Word files is now read and saved
2026-11-16 16:11:33 -05:00
Dylan M. Taylor 443a2b05ff docx: preserve partial table margins in current and tracked properties (#1924) 2026-11-16 15:51:23 -05:00
FredApps c2068fc90b fix(import): normalize maximum drawing stacking orders without replay 2026-11-16 18:54:38 +01:00
FredApps d60d1b0a45 Merge pull request #1868 from tsw2k/fix/docx-frame-shape
craft-docx: a frame preset shape is a border with a hole
2026-11-16 16:24:26 +01:00
FredApps dd3015c678 wordmodel: keep the kashida length of a justified paragraph (#1875)
* wordmodel: keep the kashida length of a justified paragraph

ST_Jc lowKashida, mediumKashida and highKashida were all read as
Align::Justify, so the length was lost. ParaProps and ResolvedPara now
keep it; a direct both/justify cancels an inherited length. The DOCX
reader and writer round-trip the three values.

* docx: keep a style's kashida length when writing justify

w:jc encodes alignment and kashida together. A paragraph or style
with Align::Justify and kashida unset still inherits a length from
the style chain; writing "both" would read back as Some(Kashida::None)
and cancel it. Use the resolved length in that case.
2026-11-16 10:23:22 -05:00
FredApps 8ee8316213 Merge pull request #1652 from D13GOOOO/docx-locked-canvas
craft-docx: read a DrawingML locked canvas as a group of its members (wordcraft#5060)
2026-11-16 16:12:08 +01:00
FredApps c5f217e765 craft-docx: a shape's VML fallback takes its anchor's relativeHeight
Main's VML fallback (#1864) read the writer's z counter after the anchor was written. That counter now only counts objects without a stored order, so a stored order's fallback got the wrong z-index. The anchor's relativeHeight is now kept in anchor_z for the fallback, and the wps_fallback tests expect the written relativeHeight (one less than Float::z).
2026-11-16 16:10:03 +01:00
FredApps bb965ed3c9 Merge remote-tracking branch 'origin/main' into t1729 2026-11-16 16:09:39 +01:00
StDenis1980andClaude Opus 5.5 0b0e5accd5 docx: set_application_name for apps that embed the writer
An app that ships the writer under its own name names itself in docProps/app.xml
(<Application>); "WordCraft" until set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 14:37:37 +01:00
Dylan M. TaylorandAndy Ching 046a7229af fix(docx): integrate VML fallbacks without breaking linked text-box stories (#1864)
* craft-docx: write Word 2010 shapes inside mc:AlternateContent with a VML fallback

A shape was written as a bare `wps:wsp` in `w:drawing`. Word 2007, and
Word 2000-2003 with the Office Compatibility Pack, don't know `wps` and
refuse the whole file. Word writes such shapes in `mc:AlternateContent`.

`write_shape` now guards the drawing with `mc:Choice Requires="wps"` and,
for rectangles, text boxes, rounded rectangles and ellipses, adds an
`mc:Fallback` with the shape as VML: size, position, z-order, wrapping,
fill, outline and the text box's text (copied from the choice's output,
so the story isn't written twice). Other kinds get no fallback; an old
reader skips that shape and still opens the file.

Refs storytold/wordcraft#6849

* craft-docx: guard a shape only when it gets a VML fallback; keep more in the fallback

A shape guarded by `mc:AlternateContent` with no fallback is skipped by
a reader that doesn't know `wps`, and dropped on that reader's next save:
worse than refusing the file. Such shapes are written bare again; only
shapes with a VML form are guarded.

The VML fallback also keeps the shape's own stacking order (a floating
object in its text box moved `self.z` on), its wrap distances, its hidden
flag and its text box's text direction.

* craft-docx: keep behind-text shapes' order in the VML fallback

A behind-text shape's fallback `z-index` was the negated `z`, which
reverses the order of overlapping behind-text shapes. It is now `z`
shifted below zero within signed 32-bit range, so a higher `z` still
stacks higher; other shapes' `z-index` is capped at `i32::MAX`.

* fix(docx): preserve linked text boxes without an incomplete VML fallback

---------

Co-authored-by: Andy Ching <53651198+andyching168@users.noreply.github.com>
2026-11-16 08:16:40 -05:00
tsw2k 8b876291a1 craft-docx: a frame preset shape is a border with a hole
Moves the format part of storytold/wordcraft#6162 into craft-wordmodel,
craft-docx, craft-flow and craft-odf, where WordCraft's DOCX and ODT I/O now
live (#778).

A DrawingML `prstGeom frame` (a letterhead's page border) was read as a
rectangle, so its fill covered the whole page behind the text. It is now
ShapeKind::Frame, its border width read from `adj1` (capped, as a rounded
rectangle's corner is) and written back as the same preset.
connector::frame_width gives the border in points. Formats with no frame
shape (ODT and the other flow formats) get the freeform it draws: its
outline and, wound the other way, its hole, so the hole stays empty under
either fill rule.
2026-11-16 11:46:35 +00:00
Diego Guerini ce8ab5cc6d craft-docx: a locked canvas's paragraph falls back on its level's alignment and the list style's defaults; bold or italic set off stays off 2026-11-16 08:52:44 +01:00
Andy Ching 5033f10bf2 craft-docx: keep behind-text shapes' order in the VML fallback
A behind-text shape's fallback `z-index` was the negated `z`, which
reverses the order of overlapping behind-text shapes. It is now `z`
shifted below zero within signed 32-bit range, so a higher `z` still
stacks higher; other shapes' `z-index` is capped at `i32::MAX`.
2026-11-16 15:51:31 +08:00
Andy Ching 489f3cbc12 craft-docx: guard a shape only when it gets a VML fallback; keep more in the fallback
A shape guarded by `mc:AlternateContent` with no fallback is skipped by
a reader that doesn't know `wps`, and dropped on that reader's next save:
worse than refusing the file. Such shapes are written bare again; only
shapes with a VML form are guarded.

The VML fallback also keeps the shape's own stacking order (a floating
object in its text box moved `self.z` on), its wrap distances, its hidden
flag and its text box's text direction.
2026-11-16 15:32:11 +08:00
Andy Ching 741192a57c craft-docx: write Word 2010 shapes inside mc:AlternateContent with a VML fallback
A shape was written as a bare `wps:wsp` in `w:drawing`. Word 2007, and
Word 2000-2003 with the Office Compatibility Pack, don't know `wps` and
refuse the whole file. Word writes such shapes in `mc:AlternateContent`.

`write_shape` now guards the drawing with `mc:Choice Requires="wps"` and,
for rectangles, text boxes, rounded rectangles and ellipses, adds an
`mc:Fallback` with the shape as VML: size, position, z-order, wrapping,
fill, outline and the text box's text (copied from the choice's output,
so the story isn't written twice). Other kinds get no fallback; an old
reader skips that shape and still opens the file.

Refs storytold/wordcraft#6849
2026-11-16 15:15:06 +08:00
vangel76andClaude Sonnet 5.5 5e3632533f DOCX: read the placeholder chart title from its text, leave the frame unfilled
Take the title of an Office 2016 chart from its rich text (all runs) or its text data, and draw the placeholder frame without a fill so it does not become a white box on a coloured page. The run-fallback test is a guard and says so.

Part of storytold/wordcraft#6820

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 02:18:25 +01:00
vangel76andClaude Sonnet 5.5 e76bf4bad4 DOCX: an Office 2016 chart with a text-only fallback keeps its size as a placeholder
read_chartex_alternate built the chart object only from a picture fallback. With a fallback
that holds only text (for example "Chart not available."), it returned None and the reader
used the fallback words, so the chart's 432 x 252 pt frame was never reserved and the pages
collapsed.

Now such a chart becomes a Chart graphic of the choice's wp:extent, drawn as the same kind of
placeholder unsupported classic charts get (frame, title, chart type), with the choice and
fallback kept so saving writes them back unchanged. A fallback that holds runs or paragraphs
is still read as before, because the writer puts the fallback inside the object's own run.

The frame reading at the top of read_drawing moves into drawing_frame so both paths share it.

Part of storytold/wordcraft#6820

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 02:04:08 +01:00
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 1ea162df26 DOCX: make the gutter-at-top tests check the order and False/FALSE
The merge unit test compared Options, and its generated part had no
w:mirrorMargins, so the order check proved nothing; put the element in
and look the positions up. Add the False and FALSE spellings to the
value test.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 00:17:26 +01:00
vangel76andClaude Sonnet 5.5 fc808abd49 DOCX: read and write the "gutter at top" setting (w:gutterAtTop)
The reader ignored w:gutterAtTop in settings.xml (it was only carried
through on save), so an app using the model could not tell that Word adds
the gutter to the top margin instead of the left one. Add
Settings::gutter_at_top (document-wide, off by default), read it with the
shared on/off helper, write it after w:mirrorMargins and before
w:attachedTemplate, and make the settings merge treat it as a modelled
child so turning it off removes it.

Tests: round trip and default off, every on/off spelling, merge into a
settings part from another writer (keep, remove, insert in schema order).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 00:12:22 +01:00
Diego Guerini 5f453efa9a craft-docx: a relativeHeight of 0 stays the lowest stacking order
Float::z kept relativeHeight as read, so a file's 0, the lowest order a
file can give, read as 0, "none", which stacks above every object. z is
now one more than the file's (as ODF's draw:z-index is read), and
Float::stack gives the stacking key. The writer writes stored orders one
less, numbers objects made in the app above every stored one, and
numbers the stored ones again from Word's first order when u32::MAX
leaves no room above them. Document::stacking_orders counts every story
saved with the document, the glossary's building blocks included.

Moved from storytold/wordcraft#2655 (wordcraft#2638), whose DOCX reader
and writer now live here.
2026-11-15 20:10:47 +01:00
Diego Guerini 6fde933469 craft-docx: read a DrawingML locked canvas as a group of its members
Word 2007 writes shapes, pictures and WordArt in a drawing as an
lc:lockedCanvas (ECMA-376 Part 1 20.3.2.1) in compatibility mode. Only
its first picture was read; its shapes and their text were dropped. The
canvas is now rewritten as the wpg group the reader already handles,
its DrawingML text as text-box paragraphs with their run formatting.

Moved from storytold/wordcraft#5067 (wordcraft#5060), whose DOCX reader
now lives here.
2026-11-15 18:01:57 +01: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 90d20fd39f fix(docx): keep default Normal for fresh documents 2026-11-14 13:25:25 +00:00