Repository navigation
fix(layout): draw a table whose every row is a header (#488) - #649
Merged
Merged
Conversation
The repeatable header is the leading run of header rows only when a row that is not a header follows it. With none, the run covered every row, the fit loop never started and Layout gave up on any area, so Save threw "too tall" for a table that was never too tall. Such a table now lays out and draws as its own body, split between rows like any other, each row still tagged TH.
Review round on the all-header table change: a multi-page trailing-header case, the Layout outcome and the exception-type changes named in the CHANGELOG, exact messages on the no-column refusals, Draw before Layout asserted to draw nothing, and the touched comments wrapped to 100 columns.
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.
Closes #488
What changed
The repeatable header is the leading run of header rows only when a row that is not a header follows
it. A table whose rows are all headers has no header to repeat, so
TableRendererlays out and drawsits rows as the body: each once, in order, split between rows like any other table. Each row is
still tagged
THwith/Scope /Column, becauseRow.IsHeaderdecides that.The change is in
TableRenderer.FindHeaderRowIndices, which returns an empty list when the runcovers every row.
LayoutandDrawboth read that list, so they agree by construction. Before, therun covered every row,
dataStartRowequalled the row count, the fit loop never ran andLayoutreturned
Nothingon any area, soSavethrew the "too tall"InvalidOperationException.XML docs rewritten to say so:
TableRenderer(summary, remarks, constructor remarks, theDrawIndexOutOfRangeExceptioncondition),Row.IsHeader,TableElement(class remarks,AddRow,AddHeaderRow),Cell.RowSpan. The save-timeInvalidOperationExceptiontags for "every row is aheader" are removed because that case no longer throws.
LayoutGen.RowHeaderShapenow includes bothrows as headers, and its comment no longer excludes the shape.
Deliberate output and behaviour changes
TableRenderer.LayoutreturnsFullorPartialfor an all-header table, where 2.3.3 returnedNothingon every area. A caller's renderer that composesTableRendererand skipsNothingnowdraws the table.
BorderColor(NaN) or tableMargins(NaN) threw the "too tall"InvalidOperationExceptionon2.3.3. It now throws the canvas's
ArgumentException, the same as any table with data rows. Onerule for all three; each is pinned in a test with the exact type.
TableRenderer.Drawcalled beforeLayouton a table with no repeatable header (no header row,or every row a header) draws nothing; a table with leading header rows and a row after them
still throws
IndexOutOfRangeException. Documented onDrawas a rule.2.3.3 against this build
Probe: 300x600 page, 10 pt margins, one Helvetica 10 pt cell per row. Both assemblies printed:
VellumPdf.Layout.dll 2.3.3+1c61fa6...(2.3.3) and2.3.3+b95d435...(this build).The content of HHH, and of 1, 2, 3 and 29 header rows, equals the content of the same rows as data
rows byte for byte (
AllHeaderRows_untagged_drawTheContentOfTheSameRowsAsDataRows).Tests
tests/VellumPdf.Layout.Tests/TableAllHeaderRowsTests.cs, value-level: exact shown strings, baselines(576 for the first row, 20 pt apart), per-page contents of 30 and 61 header rows (page 1 holds
r0..r28, page 2 holds r29 alone), a footer run (
1/2,2/2; the footer leaves room for 28 rows, so page 1 holds r0..r27 and page 2 holds r28 and r29), aRowSpangroupkept whole across the break, a group taller than the page still refused, HDD / HDH controls, no rows
still refused for no columns, start row past the end still
Nothing, tagged HHH (3TR, 3TH,3
/Scope /Column, 0TD), a header run followed by 30 data rows and a trailing header row across two pages (page 2 is r0, r29, r30, r31), the exact no-columns message for no rows,HandHHHwithout cells, the save throwing for a start row past the end, the exception type for each of the NaN and +Infinity background, NaNBorderColorand NaN margin, and theDraw-before-Layoutbehaviour (HDD throws, HHH and DDD draw nothing, asserted on the page content).Oracles:
pdftotexton the 30-row file (every row once and in order, page break after r28); qpdf12.4.2
--checkand veraPDF 1.30.4ua1on tagged HHH in embedded DejaVu Sans, each after assertingthe fixture holds three
/S /TH.PropertyTests.ValidDocument_rendersWithoutThrowingandValidDocument_placesNothingOutsideThePagepass with the widened generator.Release,
REQUIRE_ORACLES=1,REQUIRE_VERAPDF=1, after merging origin/main:VellumPdf.Layout.Tests1,184 passed, 0 failed, 2 skipped (Linux-only pipe tests) on net10.0 and on net11.0. Release solution
build 0 warnings;
dotnet format --verify-no-changes,eng/clean-room-check.ps1andgenerate-roadmap.py --checkexit 0.Mutations (each run in a detached worktree, Release, oracles required; rebuilt DLLs checked)
FindHeaderRowIndicesreturns the run for an all-header table (the old behaviour)TableAllHeaderRowsTests(every all-header test except the refusal and start-row ones, and both tests of a leading header run),Draw_beforeLayout_...(HHH),PropertyTests.ValidDocument_rendersWithoutThrowing,ValidDocument_placesNothingOutsideThePagerows.Count == 1 ? [] : indices)fitOnePage(HH),(HHH), both pagination tests, the footer test, the span test, the tagged tests, the oracle tests, the content-equality cases for 2, 3 and 29 rows,Draw_beforeLayout_...(HHH), both property testsif (!rows[i].IsHeader) return rows[^1].IsHeader ? [] : indices;(a table whose last row is a header has no repeatable header)HeaderRunWithATrailingHeaderRow_stillRepeats_acrossPages, and nothing else; the property tests pass. The test is the only guard against this mutant.Not done
PdfUA1table of 40 rows with a 2-rowRowSpanat row 28 fails veraPDF clause 7.2 test 42,on tables of data rows and of header rows alike and on 2.3.3 too (Layout: a covered row's own cell is never drawn when an earlier column is span-occupied #487, Layout: a span covering a whole row emits a table whose rows differ in width #489). This change makes no
PDF/UA claim for that shape.
RowSpangroup across pages is unchanged; a group taller than the page is still refused.q/Qis added: the table renderer writes none.