Repository navigation
fix(docx): bookmark a layer stack's column, so a page reference to it is a field - #967
Merged
Merged
Conversation
… is a field A layer stack written as columns writes each layer's content into its column's cell without dispatching the layer as a block, so a section's or container's anchor there got no bookmark: a link to it named a bookmark the file did not hold, and a page reference to it was written as a fixed number. writeLayerColumns now puts the anchor's bookmark round what each layer writes, from its first paragraph to its last, as writePlacedNode does for a block in the flow. A block of the layer written in an earlier layer's stand-in is recorded by writeInPlaceOf and opens the bookmark there. A column that writes no paragraph is named as such a block is, and a page reference to it stays its number. Measured in Word 16 (fields updated) and LibreOffice 24.2: a reference to a column on page 2 read 2 before and after a page was put in ahead of it, and the link went nowhere; now both read 3 there and the link lands on the column's page. The template corpus declares no anchors and is unchanged.
writeInPlaceOf recorded what a block wrote in a stand-in once the block was written, so a stack inside it that writes in its own stand-ins was recorded first, and the column's bookmark opened at that stack's subtitle instead of where the block starts. The block's place in the record is now taken before it is written, which keeps the record in the file's order. The recipe's limit on an anchor whose first block moved now names a container inside the later layer: the layer's own anchor, where the stack is written as columns, is marked from the moved block.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A layer stack whose layers stand side by side — a two-column CV, a sidebar beside a body — is written to Word as a one-row table, each layer's content in its column's cell (
writeLayerColumns). The layer itself is never written as a block, so its anchor got no bookmark:linkTo, a table of contents' entry) named a bookmark the file did not hold;Measured in Word 16 (fields updated, as F9 on the whole text) and LibreOffice 24.2, on an anchored column on page 2 and on the same file with a page put in ahead of it, so a live field must move to 3: both editors read 2 in both files and carried no link, for every column shape tried.
What changed
writeLayerColumnsputs the anchor's bookmark round what each layer writes, through the samebookmarkArounda section or container in the flow uses: from the first paragraph it writes — a table's first cell where it opens with one — to the end of its last. A later layer of a column is marked from its own first paragraph, the paragraph closing a table above included where it writes its first line there.DocxLayerColumns.Moveswrites in the strip above it — is written before the rest of its layer.writeInPlaceOfnow records what each such block writes (WrittenInAStandIn), taking its place in the record before it is written, so a stack inside the block that writes in its own stand-ins is recorded after it, in the file's order. The layer's bookmark opens at that block. Only what earlier layers wrote counts: a stack inside the layer writing in its own stand-ins is inside what the layer writes.writtenByis the piece ofwritePlacedNodethat collects what a block wrote in the body or the cell being filled, now used bywritePlacedNode, the column writer andwriteInPlaceOf;markOrName, its marking tail, is shared by the first two. The column drops a blank-anchor check that could never apply.settleThePageReferencesalready names each field after the bookmark its anchor was written under, and a link already names the bookmark by its anchor.nameTheBlocksNoBookmarkMarks), in its own column note where it has one, and a page reference to it stays its number, as before.Measured
Each case on page 2 of a 400×500pt page, then the same DOCX with a page put in at its start (the stored field still reads 2). Each cell: what the reference reads in the file as written / in the shifted one, and where the link goes.
Verification
DocxLayerColumnBookmarkTest(16 tests):PAGEREF left \hreading 2); so does a table of contents' entry;a.whose first paragraph is anchoredagetsa_2, and the reference reads that;1as text with its note, and the column is named — in its own column note where it has one.DocxPageReferenceTest(a reference to a column is a field),DocxCarriedWithoutReportTest(no note for an anchored column), the node and value ledgers.2.5-dev: all 67 byte-identical; report notes 1491 → 1491.clean verifyof the reactor as CI runs it → BUILD SUCCESS (render-docx 2272, qa 1835); the four knowledge checks and core javadoc (0 warnings) pass; examples 93.Lane: shared-engine (render-docx semantic DOCX backend), no public API change.