* Layout: balanced columns keep a continued paragraph's last lines together from Word 2013's layout
When the columns of a section's last page are balanced before a continuous
break, Word (compatibility mode 15) does not leave one line of a paragraph
alone in a column: the last two or three lines of a paragraph that began on the
page before, and a two- or three-line paragraph that begins the page, stay in
the first column that can hold them. settled_end only guarded a paragraph's
start, and skipped even that at the top of a column, so the balancing tries
split such lines one per column and the section came out a line short.
In mode 15, while balancing, widow/orphan control also applies at the top of a
column, a one-line fragment of a continued paragraph with more after it moves
on whole, and lines it moved go to the next column instead of overflowing.
Mode 14 and unbalanced flow are unchanged. Part of #6821 fix, measured in Word
with synthetic documents (see layout::tests::balanced_tail).
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* Layout: balanced columns also keep kept paragraphs whole, and the lines are pinned beside notes and floats (#6821)
Measured in Word for Windows (synthetic documents, exact 14 pt lines, two and
three columns, compatibility mode 15): a paragraph with keep lines together, or
keep with next and the paragraph after it, stays whole in the first balanced
column; the tails and short paragraphs behave as before beside a footnote and a
square-wrapped picture; a section that starts and ends on one page, and plain
page flow with a footnote, widow control on and off, already matched.
keep_together now also applies at the top of a column while balancing in mode 15.
The move-on after widow/orphan control is taken only when that control, not a row
beside a floating object, moved the lines back (review of the first commit).
Tests added for notes, floats, a mid-page section, keep lines/next, unbalanced
columns and mode 14.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* Layout: balanced columns fall back to the old layout when the strict rules cannot fit, and keep paragraphs ask again at a column top (#6821)
Second review: pass(full) can now fail (a page whose columns are a couple of
lines high), so balance_columns lays the page out once more without the strict
rules of Word 2013's layout (PageBuilder::relaxed, kept across the snapshot
restore) instead of leaving a spilled pass. A paragraph moved to a column top
by the lines before it asks keep lines / keep with next again there, and keeps
going on to a column that holds it. Tests: the columns' left edges come from the
first page, a page too short for the rules keeps every line, docs reworded.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* Layout tests: classify columns by the declared column edges
The balanced-tail test helper took column edges from observed caret positions, so an empty middle column could be mistaken for the last one. The edges now come from the section geometry and keep every declared column.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* Layout: release floats when balancing moves their anchors (#6821)
Use the same overflow decision for line emission and for retaining late floats. Cover the strict widow control case and qualify the balancing evidence.
---------
Co-authored-by: vangel76 <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Co-authored-by: Martin Ball <[email protected]>
* Layout: a header at compatibility mode 14 or lower keeps its text beside its own floats
In Word, a header in a document of Word 2010's layout or older does not move its
text below or beside the header's own floating objects. A top and bottom object
only makes the header taller when it starts above the end of the text. From mode
15 the text goes below the object, which WordCraft already did in every mode.
Part of #6805. Not built or run yet.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* Layout: header floats at mode 14: measured wraps only, tests read the header, distances
Only top and bottom and square objects stop wrapping the header's text at
compatibility mode 14 and lower (Tight and Through were not measured). The
distance below a top and bottom object counts, as in Word. The tests read the
header's own items, add the distance, space-after and multi-paragraph cases, and
the measured numbers are in the test file's header. The layout_box change moves
into three small helpers.
Part of #6805.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* Layout: header floats at mode 11 measured in Word, test and notes say so
The legacy header path applies below compatibility mode 15, so mode 11 (.doc files)
takes it too. Measured in Word on synthetic .doc files: mode 11 keeps the header text
beside its own top and bottom object like modes 12 and 14. Add a test for it and drop
"mode 11 not measured" from the test header, ROADMAP and layout-parity notes.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* docs: narrow header float coverage
Refs #6805
* docs: specify header contour compatibility
Refs #6805
---------
Co-authored-by: vangel76 <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Co-authored-by: Martin Ball <[email protected]>
Word breaks a line between two hyphens in a row, so a ruled line made of
hyphens after a gap first fills the line and continues on the next. UAX #14
(LB21) keeps the hyphens together, so the whole row moved to the next line
and the paragraph got one line more than in Word. Add the break after U+002D
when another U+002D follows, next to the existing breaks before a digit and
before a slash and a letter. Non-breaking hyphens and minus signs stay
unbreakable.
Co-authored-by: vangel76 <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Co-authored-by: Martin Ball <[email protected]>
Co-authored-by: Martin Ball <[email protected]>
* Layout: a paragraph of only a page break moves when it doesn't fit
* Apply cargo fmt
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* docs: name the deferred double-spacing case in the break-only paragraph entry
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
---------
Co-authored-by: Dominik Strebel <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Co-authored-by: Martin Ball <[email protected]>
Co-authored-by: vangel76 <[email protected]>
Co-authored-by: Martin Ball <[email protected]>
* Tables: split the paragraph that starts a cell's part of a page where its lines fall
A row split across pages whose cell continued with a paragraph of two or three
lines, of which only the first (or two) fit, kept nothing on the page: the
orphan/widow rule moved the paragraph on whole, but it already started the page.
The row was then placed whole and ran off the bottom. Word splits such a paragraph
where the lines fall (a lone first line stays; three lines with room for two split
two and one; a continuation's lone line stays). A paragraph below other content of
its cell, and a row starting below other content of a page, keep the rule.
Part of #6823 (phase 1: not built or run yet).
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* Tables: a can't split row taller than a page splits at the page's end; more Word-measured cases
A can't split row (not an exact one) taller than a page now moves to a new page when it starts
below text and splits where the page ends, as Word does, instead of running off the page. The
tests now cover nested tables, a repeated header row, text lines, rows with several paragraphs and
the exact configurations measured in Word. The earlier note that Word keeps two and one below
other content was a misreading of a run without compatibility mode 15 and is removed.
Part of #6823 (phase 1: not built or run yet).
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* Tables: review fixes for the split-row work
The new test module defines its own lay helper; only text in the flow decides which paragraph
starts a cell's part of a page, so a floating picture above it no longer keeps the old orphan
rule; a can't split row only splits when it is taller than the room; a stale test comment is
updated; tests for a floating picture and a row that fits a page.
Part of #6823.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* Tables: a test for a floating picture above the first paragraph; rustfmt
Floats are placed with the first piece of their paragraph, so the test puts the picture on the
table's first page. Without the in-flow-only rule it fails.
Part of #6823.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* 6823: Document split-row limits
* 6823: Clarify widow control in split rows
---------
Co-authored-by: vangel76 <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Co-authored-by: Martin Ball <[email protected]>
* Layout: Keep with next on a section's last paragraph no longer adds an empty page
A paragraph that closes a section whose next section starts on a new page (next page, odd or
even) has nothing on its page to keep with. Keep with next still added the next section's first
line to the room it needed, so a closing paragraph that fitted at the bottom of a full page was
moved to the next page, leaving a page holding only it. Word ignores Keep with next there. The
chain lookahead stops at the closing paragraph too. Before a continuous section the old
behaviour stays (not measured in Word).
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* Layout: exact-geometry tests for keep with next at a section end (#6834)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* Layout: format, and say odd/even breaks are by analogy (#6834)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
---------
Co-authored-by: vangel76 <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Co-authored-by: Martin Ball <[email protected]>
Fixes#4030
On a small screen (an 11-inch 1366x768 panel) the system can report a very large display scale. The Auto interface size followed it blindly, so the window and ribbon came out far bigger than the screen and File > Options, where the size is set, could not be reached.
What this changes:
- Auto interface size is now capped so a window of at least 900x460 points still fits the screen (about 152% on 1366x768). Scales that already fit (for example 1920x1080 at 100-150%, or 1366x768 at up to 150%) are unchanged. If the screen size is unknown there is no cap.
- A size chosen in File > Options is still taken as is. If a large size pushes the options out of reach, Ctrl+Shift+0 (Cmd+Shift+0 on Mac) returns to Auto from anywhere. Ctrl+Alt+0 is not used because it is AltGr+0 on some layouts and would type a character.
- `ui.interfaceSize` and the "Auto (n%)" label in Options report the capped value. The cap is never saved to `ui.json`.
- Tests: the cap for several screen sizes, the shortcut, AltGr+0 still typing, and the reported percent. Docs: ui-parity, control-protocol, ROADMAP progress log.
Not covered:
- The root cause of the oversized scale (X11 DPI detection) is handled by #721 and #3240. This change is separate and works with or without them.
- A manually chosen large size can still push controls off screen, but there is now a way back.
- Not tested on a real 1366x768 screen.
`cargo xtask ci` passed locally on the pushed code; GitHub CI has not run yet.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
* **New Features**
* Auto interface sizing now scales down on smaller displays to keep a window of at least 900×460 points within the screen. Sizes selected in Options remain uncapped, and the minimum Auto scale is 100%.
* Press Ctrl+Shift+0 (⌘⇧0 on Mac) to restore Auto sizing. When Auto sizing is capped, the displayed zoom percentage reflects the screen-fit limit; the cap does not change the saved size.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
A text box inside a group (Word's cards made of a coloured bar and a text
box) could not be edited: every click selected the whole group, and typing
then replaced the group with the typed text. Layout now keeps each group's
text box areas on the group's object, and hit testing treats them like a
text box on its own: inside is the box's text, the border and the group's
other members still grab the group (#6027).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
In a multi-column section every line number was drawn left of the page
margin, so the second column's numbers sat on top of the first column's.
Each column now has its numbers left of its own edge, as in Word.
Word in other languages saves the built-in "line number" style under a
localised id (German: Zeilennummer); the numbers now find it by its
built-in name when there is no LineNumber id, so its formatting applies.
Fixes#6018.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
[MS-DOC] 2.3.3 ends every non-empty header/footer story with a guard paragraph
mark that is not part of the story. It was read as an empty paragraph, which
added a line under every header and footer and pushed the first body line down
when the header reached past the top margin (#5922).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every style-definition change sits at the same collapsed anchor at the
start of the document, so Accept or Reject there resolved all of them,
across authors, and so did any caret put at the document start. Next and
Previous Change now remember which style change they selected (style id
and revision, for that document and selection), step between style
changes that share the anchor, and Accept/Reject resolve that revision
alone. A caret placed there any other way resolves no style change;
Accept/Reject All and a whole-body selection still resolve them all.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Pin that FILENAME and FILENAME \p in a header show the new name and path after Save As, that a Word-style FILENAME \* MERGEFORMAT field drops its cached name, and that Rename is picked up by Update Field. No production code changes.
Refs #3796
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
* docbin: a field's cached result keeps its formatting per run, not per character (#5477)
The result was a Vec<(char, CharProps)>: 365 bytes per character, 1.44 GB
at peak for a 4 MB file with one field. It is now a String plus a run
list that gains an entry only when the formatting changes (25 MB peak
for the same file). Output is unchanged.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* docbin: show the objects when the field-result test fails
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* docbin: resolve character formatting per run, not per character (#5478)
The text loop looked up the piece four or five times and the CHPX once
(a backward scan over up to 101 FKP entries) for every character, and
cloned the memoised 368-byte CharProps each time. Now the walk keeps the
piece span and the CHPX run of the previous character and reuses them
while the next character is inside, and hands the memoised properties
to the paragraph builder by reference: they are cloned when a run
starts and not compared while the resolved formatting is unchanged.
Output is identical, also on corrupt pages (a run's FC range is
bounded by the smallest later start).
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* docbin: tests for run ranges across bins, empty pieces and a whole read
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
---------
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
The test asked the global font database for a fallback face before any
layout call, so the pinned fonts could no longer be installed.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Keep upstream's split of layout_para and install the pinned fonts at its
start. Refit the main tests added since (#4250 widow and footnote length,
#4720 chart fallback font) to the pinned test fonts. Merge the two
wordcraft-layout dev-dependency tables.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The hinting test took whatever default font the machine resolved, so its grey-pixel threshold
depended on the system. It now sets Source Sans 3 at 12 pt (4.7 percent fewer grey pixels).
The footnote test's note length was chosen against system fonts and is now the one that fits
the pinned test fonts, which every layout call now installs.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
layout, layout_para, layout_equation and mark_text_width call test_fonts() first in test
builds, so the shared lay helper and everything that goes through them is covered. Tests and
helpers that look up fonts directly (the Times New Roman substitute test, the Symbol bullet
test, the Arabic/Myanmar/Thai face probes and the nbsp fixture) call it themselves. Audited by
running every layout test in its own process with a temporary guard that panicked on any
global font access before the pinned fonts were installed.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The CSV fallback is now only for an absent values field. A null values argument is rejected
before anything is inserted. Null cells inside a valid row still work. Engine and MCP
regressions check that the document and the undo history stay unchanged.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
layout, layout_para, layout_equation and mark_text_width call test_fonts() first in test
builds, so the shared lay helper and everything that goes through them is covered. Tests and
helpers that look up fonts directly (the Times New Roman substitute test, the Symbol bullet
test, the Arabic/Myanmar/Thai face probes and the nbsp fixture) call it themselves. Audited by
running every layout test in its own process with a temporary guard that panicked on any
global font access before the pinned fonts were installed.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
With the fixed test fonts the paragraph with a widow needs fewer repeats
than the search range started at.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The footnote text length and the paragraph-length search range in these two
tests were chosen against system fonts; with the fixed test fonts the page
breaks fall elsewhere.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* docbin: a field's cached result keeps its formatting per run, not per character (#5477)
The result was a Vec<(char, CharProps)>: 365 bytes per character, 1.44 GB
at peak for a 4 MB file with one field. It is now a String plus a run
list that gains an entry only when the formatting changes (25 MB peak
for the same file). Output is unchanged.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* docbin: show the objects when the field-result test fails
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
---------
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
* docbin: cap paragraph and cell marks, keep the table context only for table marks (#5476)
The walk budget counts characters, not paragraphs, so a file made of
paragraph marks grew memory about 2,000 times faster than its size
(4 MB of marks: 9.4 s, 8.4 GB peak). Marks now draw on one document-wide
cap (2,000,000, all stories together); past it the read returns
DocbinError::Limit. A ParaOut no longer embeds the 296-byte RowInfo of a
table mark: it is an optional box, present only for table marks.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* docbin: say what the paragraph cap bounds; name the budget test for what it checks
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* docbin: refuse an exhausted paragraph budget before assembling a story (review point)
CodeRabbit pointed out that the header, footnote, endnote and text box walks
assembled their partial paragraph lists before the budget check, a transient
memory peak. They now share story_blocks, which checks first.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* docbin: test that the paragraph cap is shared by the body and a footnote (review nitpick)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* docbin test: review fixes (assert empty pairs, comment wording)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
---------
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
* Content controls: a press on the drop-down list button no longer moves the caret (#5389)
The list button hangs over whatever follows the control. The canvas put the
caret under the pointer first, which left the control, and the list closed in
the frame it opened. A press on the button now skips the caret move.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* Content controls: only a press that began on the list button skips the caret move (#5389)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* Content controls: a press and release in one frame, and a table tool, no longer hit the button guard (review points)
CodeRabbit pointed out that egui clears press_origin when a press and its
release arrive in the same frame, so the caret still moved off the control and
closed the list; the press is now also read from the frame's events. It also
pointed out that the guard ran before the table pen, so a stroke could not
start over the button; the guard is skipped while a table tool is on.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* Content controls: feed the same-frame press and release as one frame in the test
Harness::event runs one frame per event, so the earlier version of the test did
not exercise the single-frame case.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
---------
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
metafile_size() parsed the whole metafile, decoding every bitmap and building every path, to
read two numbers at picture insert and replace. A new wordcraft_metafile::size reads the frame
from the EMF header or the placeable WMF header, and falls back to the full parse for every
other file (plain WMF, an EMF without a usable frame, a file with no records), so it returns
what parse would. For an EMF with one 8000x5000 1 bpp bitmap the size now costs well under a
microsecond instead of about 280 ms.
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
decode_clip matched the bit depth, bounds-checked and (for 16 and 32 bpp) divided per channel
for every pixel. The depth, palette and masks are now turned into a row decoder once per
bitmap: a 256-entry colour table for 1/4/8 bpp, plain channel swaps for 24 bpp and default
32 bpp, and precomputed shifts and scale tables for masked 16/32 bpp. Output is byte for byte
the same; the old per-pixel code stays in the tests as the reference.
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
decode_clip only capped width x height at 40 MP. A 32 x 1,250,000 pixel 1 bpp bitmap (about
5 MB in the file) was decoded to 160 MB of RGBA and kept, then dropped by Item::take_pixels
because its side is over MAX_BITMAP_SIDE, while counting against the parse's 256 MB budget.
decode_clip now returns None when the clipped width or height is over the cap, so crops of a
large bitmap that fit still decode.
Co-authored-by: Claude Sonnet 5.5 <[email protected]>