* export: write RTF through craft-rtf's full writer, from the word model
The pages are mapped onto a craft_wordmodel::Document (as_word.rs, the
mapping the DOCX export will share), and craft_rtf::doc::export writes
it. Over the small writer this keeps, in RTF:
- pictures, inline (the engine no longer leaves them out for RTF);
- each page's size, as a section per page (blank pages kept);
- Heading 1 and 2 styles;
- the title;
- hard line breaks inside a paragraph or cell (storytold/pdfcraft#4723).
It also fixes two bugs: \cellx was the absolute page x, so every column
edge sat one left margin too far right, and tables that touched became
one (NIST CSF 2.0 came out with 28 tables instead of 68).
craft-rtf, craft-wordmodel, craft-docx and craft-mime are pinned together
at one craft-libs commit: doc::export takes its own revision's Document.
* export: pin craft-libs main with push_text, the header-row fix and the RTF generator name
craft-rtf, craft-wordmodel, craft-docx and craft-mime move to craft-libs
b8eaa8e2, which has storytold/craft-libs#1946, #1947 and #1950. The
mapping appends through Paragraph::push_text/push_object, tables keep
the default look, and the RTF names PdfCraft as its generator.
* export: write Word through craft-docx, from the shared word model
as_docx.rs no longer writes WordprocessingML itself: as_word::word_doc
maps the pages onto a craft_wordmodel::Document and craft_docx::write
writes it. The decisions stay the same: a page with rotated text or
overlapping text keeps its layout as positioned text boxes and pictures
(watermark-sized text behind, pictures over it, other text on top), the
other pages flow, each page is a section of its own size, a shared page
colour is the document's, the PDF's language goes in the slot Word keeps
for its script, and the media limits are unchanged.
Over the hand-written package this gains:
- a VML fallback for every text box, so Word 2007 opens positioned pages;
- rotated text as a turned text box Word draws as a line;
- the body font named (Arial), with a font table saying it is a sans;
- PdfCraft as the application in docProps/app.xml;
- a picture drawn many times stored once.
The tests that matched XML read the package back through craft-docx.
* parity: the Word export through craft-docx, checked in Word 16, Word 2007 and LibreOffice
* chore: update Cargo.lock after rebasing #7592
---------
Co-authored-by: kiwi4boy <kiwi4boy@gmail.com>
* fix(xfdf): bound field text, look up names, guard tab cells, protect fields
XFDF import built every full field name from its parent's with no total; it
is held to 64 MiB of names and values. FDF field arrays charge each decoded
value before keeping it instead of after decoding all of them. merge_csv,
XFDF field export and apply_values looked names up by linear scan per field;
they use maps, keeping first-match behaviour. Tab-delimited export guards
formula-like cells with a leading ' as CSV does, and import takes it off.
A same-name comment import no longer replaces a widget whose subtype is a
reference or whose /FT is inherited from its parent, existing annotations
are borrowed instead of deep-copied per import, and an imported redaction
mark's /Rect is grown to hold its /QuadPoints so nothing is removed outside
its review outline.
* address review: follow /Parent 64 levels in is_field
Use the merged craft-libs #1467 commit for craft-rtf and its codepage dependency, leaving other shared pins unchanged. Flush pending breaks before a second break and at end of input so blank and omitted-image pages retain every boundary. Add semantic readback coverage for those cases.
* chore: cut over image, png, tiff, and zune-jpeg to craft-image-codecs
* chore: cut over xfa XML parsing from roxmltree to craft-xml
* chore: cut over export DOCX and PPTX packaging to craft-opc and craft-xml
* style: cargo fmt
* fix(optimize): a destination name given by reference is copied once however many dictionaries name it
* fix(optimize): aliases of one destination-name object are copied once
* fix(flatpak): allow release checks and self-update helpers
* test: keep Flatpak permission parsing within strict Clippy rules
* chore: bump version to 0.21.1 for the Flatpak update fix
* fix(redact): remove a stroked path by the box its stroke paints
Path redaction tested a path's construction box against the marks. A
horizontal or vertical stroke has a zero-area box, which overlaps
nothing, so its drawing commands stayed beneath the overlay; a wide
stroke whose points lie beside a mark but whose ink reaches into it
stayed too.
The interpreter now tracks the line width, miter limit and join style
(`w`, `M`, `j`, and `LW`, `ML`, `LJ` through `gs`) and, for a stroking
operator, grows the box by half the width (at least one unit), times
the miter limit when the path has mitred joins, scaled by the CTM's
largest stretch, before the hit test. The bound is conservative: a
stroke near a mark may now go where before it stayed.
* address review: pad hairlines by half a unit, rectangles for their corners, square caps by sqrt 2
* review: test a kept clip against the path as constructed
* address review: a line state set between a path and its stroke no longer lets the stroke skip the redaction test
* address review: line-state operators read the operand before the operator
* fix(forms,xfa): find every password field before a save skips scrubbing it
The quick Password-flag check in pdfcraft-forms stopped silently at its
depth limit, and visited the tree in an order where a field the full
field walk reaches could be cut off on a long branch first. It now
answers true (read every field) whenever it cannot look as far as the
field walk, and also walks below fields adopted from page widgets.
XFA password classification walked AcroForm fields only 32 levels deep,
shallower than editing and dataset synchronization, and read the
datasets packet of an XFA array without the prefixes its preamble
declares, so a typed password could stay in the saved datasets. It now
walks as deep as the field walk, refuses to clear (and so to save) when
the tree is deeper than it can check, and reads the packet the way the
datasets writer does.
* address review: check every page widget's /Parent chain for the password flag
* address review: password scan follows the parents of nameless /Fields entries; field-walk completeness checked before the datasets packet is read
* address review: the field walk's completeness is decided after every root; the subtree scan starts at the last dictionary of the parent chain
* address review: a skipped visit does not replace the reach a field was classified with
* fix(edit,a11y): font aliases share the metrics built for their font
Text extraction and heading extraction built and kept font metrics per resource name, so
many names for one font object each held a copy of its Unicode and width tables.
* fmt
* address review: font metrics are cached by the object at the end of the reference chain
* fix(engine): run the renderer redaction check on redactions applied inside a batch
* Resolve redaction marks by page object and measure the edited document
The renderer check looked marks up by the page index they had when they
were drawn, so a MovePages later in the same batch pointed them at another
page's text, and it measured glyphs with page geometry from before the edit.
Each mark now carries the page object it was placed on, and the geometry is
read back from the document as the batch wrote it.
* review: skip marks whose page the batch deleted
* review: group marks by page once and refuse an ambiguous page tree
* address review: refuse a batch that deletes a marked page while adding pages
* merge main, keep both
* address review: a batch that applies redactions and then copies a page is refused
* fix(js): bound array text, month parsing, name registration and list work
- strings() (field value and colour setters, resetForm) copied every array
entry into its own String with no total: one long string listed a million
times was copied a million times. The copies together are now held to the
run's MAX_PAYLOAD byte budget.
- FormCalc parse_date copied and lowercased the rest of the text for every
month token of the picture, quadratic in both; it reads at most the longest
month name now.
- XFA global registration checked each child name against a Vec of every
name defined so far, quadratic in a wide form; it is a HashSet.
- FormCalc gather charged one step for a whole collection and list_push
charged nothing for a duplicate it dropped, so .all on same-named siblings
did quadratic work for one step a pair; every node visited costs a step.
- add_instance reserved only the new root's SOM before copying a subtree;
the copy's nodes, names and SOMs are charged to the byte budget first.
* address review: gather charges each call; check an array entry's length before copying it
* Hold an array entry to its widest escaped size before copying it
The pre-copy check compared the payload budget against a JS string's UTF-16
length, which is shorter than the escaped UTF-8 form it is copied to: a
string of quotes or non-ASCII text could allocate up to six times the
budget before the post-check rejected it.
The check now uses the widest escaped width, so the copy cannot exceed the
budget it is checked against.
* review: measure an array entry's escaped width before refusing it
* address review: count an array entry's escaped width without copying it
* address review: charge retained field text and colours to a run-wide budget
* fmt
* fmt
* merge main, keep both
* fix(render): charge field, tooltip, layer, bookmark and blank-comment text against shared allowances
* address review: charge comment text once, keep JS and field-action flags past the budgets
* review: count an unlisted field's actions through its whole subtree
* review: mark multi-select values the allowance dropped
* review: count only real actions, walk each field once, keep name selections
* address review: revisit shared field descendants from shallower paths, charge value separators, check every widget for actions
* merge main, keep both