Repository navigation
fix(docx): ask a zone's page predicate of the layout's own pages - #918
Merged
Merged
Conversation
Word paginates for itself, so a page zone's appliesTo predicate is asked over sample pages, a document of six pages or of the layout's own count where that is more, and sorted into Word's first, even and other pages. A shorter layout's pages were asked as pages of that six-page document, while the page asks each of its pages as one of as many as the layout ran to. A predicate that reads the total then answered otherwise for the export than for the page. On a one-page document a footer for one-page documents only (page.total() == 1) was not written, with nothing said, and one for longer documents only (page.total() > 1) was written on the one page, which the page draws none of. Measured in Word and LibreOffice on Windows, both showed the second and not the first. DocxPageClasses still asks the six-page sample, which decides whether the predicate follows Word's kinds at all. A layout of fewer than six pages is now asked as well, as a document of its own, each page as the page asks it; those answers decide the kinds of page the layout has, and the sample's the rest. Both editors then show the first footer on the one page, 19.92 and 19.96pt from its foot where the page sets it 19.95, and the second on none; on two pages a footer for two-page documents only is on both and one for more than two pages on neither. A document of six pages or more, and an export with no layout, is asked as before.
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
Word paginates for itself, so a page zone's
appliesTopredicate is asked over sample pages andsorted into Word's first, even and other pages (
DocxPageClasses). The sample is a document of sixpages, or of the layout's own page count where that is more. Every sample page was asked as one
of that document, so a shorter layout's pages too were asked as pages of a six-page document. The
page asks each of its pages as one of as many as the layout ran to (
DocumentPageZones.apply).A predicate that reads the total therefore answered one way for the export and another for the
page.
Measured in Word and LibreOffice on Windows, on a one-page document:
page -> page.total() == 1page -> page.total() > 1The first footer was skipped, with nothing in the report. The second got only the "not measured" note.
What changed
DocxPageClasses.of:all: the last page, the third;
paginated(number, pageCount);and reported, as a sample that does so is;
Consequences:
total() == 1sorts to the first page (the title page's footer);total() > 1sorts to the pages after the first;isFirst() && !isLast()sorts to none;total() == 2sorts to the first and even pages;total() > 2sorts to the later odd pages, which a two-page document has none of.Asking the layout's pages and the pages past them in one pass, each of its own total, puts two
documents into one kind:
total() > 2on two pages answered no for page 2 and yes for page 4.So the layout is asked as a sample of its own.
Docs:
Verification
total() == 1: the footer is on the one page, 19.92 and 19.96pt from its foot (the page: 19.95);total() > 1: on none;total() == 2: on both, 19.92 and 19.96pt (the page: 19.95), with no zone note;total() > 2: on neither;total() > 1: where the page draws it, as before../mvnw -B -ntp test -f render-docx/pom.xml:DocxPageClassesTest, 1 new test:total() == 1,total() > 1,isFirst() && !isLast();total() == 1,total() == 2,total() > 2;total() == 3(every kind),total() > 3(none);total() == 4 && number() == 2: unsorted;total() == 8.DocxPageZoneKindsTest, 4 new tests: the one-page and two-page footers above, read fromthe exported parts. The
total() > 2footer is the later odd pages' footer, with differenteven and odd pages stated.
./mvnw -B -ntp clean verify: BUILD SUCCESS (core 821, render-docx 1775, examples 93, qa 1820).The knowledge pack's
--checkpasses. Two test assertions, a Javadoc line and docs wording wereadded after it;
./mvnw -B -ntp test -f render-docx/pom.xmlre-run after them: 1775, BUILDSUCCESS.
Lane: render-docx (semantic backend). DOCX output can change only in a document with a zone
whose predicate reads the page total (
total(),isLast()) on fewer than six pages. The titlepage a section states, and the different even and odd pages a document states, then reach that
section's and the document's other zones and bands, as they do for any zone filed so.