SonarCloud's analysis of main at b4da59f0c lists 23 closures such as `|v| v.as_slice()` that hand their argument straight to one method. This passes the method itself: `Vec::as_slice`, `str::to_ascii_lowercase`, `f64::total_cmp` and the like, all forms the repo already uses elsewhere. Behaviour is unchanged.
Five stay. The four in crates/proof/src/es/mod.rs sit in code that #4191 replaces, and its replacement already uses `PoisonError::into_inner`. In crates/engine/src/io/safe_save.rs the path would be `<dyn std::error::Error + Send + Sync>::is::<Guided>`, which reads worse than `|inner| inner.is::<Guided>()`.
crates/metafile/src/lib.rs: re-export both TextLayout (#1915) and crop_window.
ROADMAP.md, docs/layout-parity.md: main's status lines kept; the PR's log rows added.
With 0.1% the whole source of a 4000 pt frame spanned up to 4,000,000 pt,
past the ±1,000,000 pt limit Picture::place uses to leave out items far
off the page, so a metafile cropped that narrow lost what the crop shows.
At 0.5% it spans at most 800,000 pt (CodeRabbit on #3247).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A crop that kept under 5% of a picture's axis was widened to 5%, so a
header bar cropped to 2.7% of a page-sized WMF came out half as tall and
the text box over it fell below it. The rasteriser, the PDF writer and
the metafile placement now share wordcraft_metafile::crop_window, which
keeps down to 0.1% of an axis and keeps junk crops finite.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Metafile: WMF handle table finds its lowest free slot without scanning (#1463)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
* Metafile: map shape ops in place and decode only the clipped part of a DIB (#1463)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
* ROADMAP: progress log row for the metafile reader (#1463)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
* Metafile: write cropped DIB pixels through as_chunks_mut (#1463)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: Brandon Thomas <echelon@gmail.com>
Word plays a WMF into the picture's box the way a GDI player does: the
placeable header's bounds are only the first window, mapped onto a
viewport of the picture's size, and the file's own SETWINDOWORG and
SETWINDOWEXT records replace that window. WordCraft mapped the header's
bounds through the file's final mapping instead, which broke three
pictures in docxide-pdf's fixtures:
- bulgarian_farmland_allocation_order: the coat of arms draws in a
window centred on the origin, nowhere near the header's bounds, so
the lion was blown up into a solid black box.
- ukrainian_municipal_heating_resolution: a portrait window replaced
the landscape bounds, so the emblem was drawn at a fifth of its size.
- A plain WMF in anisotropic mode that sets a window but no viewport
kept the 1 x 1 default viewport and shrank to a point; its first
window is now its target.
Files that set their own viewport, or use the fixed-scale map modes,
are read as before.
SETROP2 is now read too: with R2_NOP, shapes and paths draw nothing
(the coat of arms first draws its bounding rectangle that way, which
showed as an outline). The mode is saved and restored with the DC.
Co-authored-by: Naxvog <4963183+naxvog@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Brandon Thomas <echelon@gmail.com>
Windows metafiles (WMF, EMF), common for logos, crests and diagrams in
older documents, couldn't be decoded and showed as grey boxes, on screen
and in PDF.
The new crate wordcraft-metafile (layer 1) reads them from the public
[MS-WMF] and [MS-EMF] specifications into paths and bitmaps, and places
them in a picture's box; render and pdf paint the result as vectors.
It covers the drawing records Office pictures use (lines, polygons,
curves, rectangles, ellipses, arcs, path brackets), pens and brushes,
the mapping modes and world transforms, and bitmaps in DIB form with the
usual raster operations. Input is treated as hostile: every read is
bounded, and a byte budget caps what one picture may allocate.
Not yet: text records (ExtTextOut) and EMF+ records are skipped, so a
metafile whose content is mostly text shows only its lines and fills.
docxide-pdf bench (365 documents, vs main + #135): the twelve documents
with WMF/EMF pictures show them; the pictures are a small part of their
pages, so the scores move little (Jaccard passes 208 -> 209, five
documents up to 3 SSIM points better, none worse).
Co-authored-by: Oliver Zieschang <4963183+naxvog@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>