diff --git a/integrationtest/org/daisy/dotify/formatter/test/resource-files/page/page-number3-expected.pef b/integrationtest/org/daisy/dotify/formatter/test/resource-files/page/page-number3-expected.pef index d0d8a9cc..b230c1a3 100644 --- a/integrationtest/org/daisy/dotify/formatter/test/resource-files/page/page-number3-expected.pef +++ b/integrationtest/org/daisy/dotify/formatter/test/resource-files/page/page-number3-expected.pef @@ -112,36 +112,18 @@ ⠼⠁⠋ ⠤⠼⠉⠠⠋⠤⠤ - -
⠼⠁⠛ -⠏⠕⠎⠞⠀⠉⠕⠝⠤ -⠞⠑⠝⠞ - -
- - -
- -⠼⠁⠓ -⠏⠗⠑⠀⠉⠕⠝⠤ -⠞⠑⠝⠞ - -
-
- -⠼⠁⠊ ⠤⠼⠉⠠⠛⠤⠤ -⠼⠃⠚ +⠼⠁⠓ ⠤⠼⠉⠠⠓⠤⠤
-⠼⠃⠁ +⠼⠁⠊ ⠏⠕⠎⠞⠀⠉⠕⠝⠤ ⠞⠑⠝⠞ diff --git a/integrationtest/org/daisy/dotify/formatter/test/resource-files/volume-break/volume-breaks-advanced3-expected.pef b/integrationtest/org/daisy/dotify/formatter/test/resource-files/volume-break/volume-breaks-advanced3-expected.pef index d28d9424..9dc24bef 100644 --- a/integrationtest/org/daisy/dotify/formatter/test/resource-files/volume-break/volume-breaks-advanced3-expected.pef +++ b/integrationtest/org/daisy/dotify/formatter/test/resource-files/volume-break/volume-breaks-advanced3-expected.pef @@ -80,28 +80,28 @@ ⠤⠤⠀⠤⠤⠀⠤⠤ ⠤⠤⠀⠤⠤⠀⠤⠤ ⠤⠤⠀⠤⠤⠀⠤⠤ -⠿⠿⠿ +⠿⠤⠀⠤⠤⠀⠤⠤ +⠤⠤⠀⠤⠤⠀⠤⠤ -
-
- -
-⠿⠤⠀⠤⠤⠀⠤⠤ ⠤⠤⠀⠤⠤⠀⠤⠤ ⠤⠤⠀⠤⠤⠀⠤⠤ ⠤⠤⠀⠤⠤⠀⠤⠤ ⠤⠤⠀⠤⠤⠀⠤⠤ +⠿⠤⠀⠤⠤⠀⠤⠤ ⠤⠤⠀⠤⠤⠀⠤⠤ -⠿⠤⠀⠤⠤⠀⠤⠤ -⠤⠤⠀⠤⠤⠀⠤⠤ ⠤⠤⠀⠤⠤⠀⠤⠤ ⠤⠤⠀⠤⠤⠀⠤⠤ ⠤⠤⠀⠤⠤⠀⠤⠤ ⠤⠤⠀⠤⠤⠀⠤⠤ +⠿⠿⠿ +
+
+ +
⠿⠤⠀⠤⠤⠀⠤⠤ ⠤⠤⠀⠤⠤⠀⠤⠤ diff --git a/src/org/daisy/dotify/formatter/impl/page/PageSequenceBuilder2.java b/src/org/daisy/dotify/formatter/impl/page/PageSequenceBuilder2.java index c3f8b77d..15d4aeab 100644 --- a/src/org/daisy/dotify/formatter/impl/page/PageSequenceBuilder2.java +++ b/src/org/daisy/dotify/formatter/impl/page/PageSequenceBuilder2.java @@ -268,11 +268,13 @@ public PageImpl nextPage(int pageNumberOffset, private PageImpl nextPageInner(int pageNumberOffset, boolean hyphenateLastLine, Optional transitionContent, boolean wasSplitInSequence, boolean isFirst) throws PaginatorException, RestartPaginationException // pagination must be restarted in PageStructBuilder.paginateInner { PageImpl current = newPage(pageNumberOffset); - if (pcbl!=null) { + if (pcbl!=null // Store a mapping from the BlockLineLocation of the last line of the page before the // previous page to the BlockLineLocation of the last line of the previous page. This // info is used (in the next iteration) in SheetDataSource to obtain info about the // verso page of a sheet when we are on a recto page of that sheet. + && transitionContent.isPresent() && transitionContent.get().getType()==TransitionContent.Type.INTERRUPT) { + blockContext.getRefs().setNextPageDetailsInSequence(pcbl, current.getDetails()); } if (nextEmpty) { @@ -477,7 +479,9 @@ private PageImpl nextPageInner(int pageNumberOffset, boolean hyphenateLastLine, // Determine whether there is a block boundary on the page, with enough space // available after this point for sequence-interrupted and any-interrupted. boolean hasBlockBoundary = blockBoundary.isPresent()?blockBoundary.get():res.getHead().stream().filter(r->r.isLastRowGroupInBlock()).findFirst().isPresent(); - bc.getRefs().keepTransitionProperties(current.getDetails().getPageLocation(), new TransitionProperties(current.getAvoidVolumeBreakAfter(), hasBlockBoundary)); + if (transitionContent.isPresent() && transitionContent.get().getType()==TransitionContent.Type.INTERRUPT) { + bc.getRefs().keepTransitionProperties(current.getDetails().getPageLocation(), new TransitionProperties(current.getAvoidVolumeBreakAfter(), hasBlockBoundary)); + } } // Discard collapsed margins, but retain their properties (identifiers, markers, // keep-with-next-sheets, keep-with-previous-sheets). diff --git a/src/org/daisy/dotify/formatter/impl/sheet/EvenSizeVolumeSplitter.java b/src/org/daisy/dotify/formatter/impl/sheet/EvenSizeVolumeSplitter.java index 55d869a4..6ab59059 100644 --- a/src/org/daisy/dotify/formatter/impl/sheet/EvenSizeVolumeSplitter.java +++ b/src/org/daisy/dotify/formatter/impl/sheet/EvenSizeVolumeSplitter.java @@ -32,6 +32,8 @@ class EvenSizeVolumeSplitter implements VolumeSplitter { // number of volumes to add on top of the number of volumes strictly needed to accommodate the // total number of sheets int volumeOffset = 0; + int initialSheets; // initial number of sheets; assuming that this is the number of sheets + // required to fit everything into one volume, without the overhead /* * This map keeps track of which split suggestions resulted in a successful split. We @@ -55,6 +57,7 @@ class EvenSizeVolumeSplitter implements VolumeSplitter { public void updateSheetCount(int sheets, int remainingSheets) { if (sdc == null) { sdc = new EvenSizeVolumeSplitterCalculator(sheets, splitterMax, volumeOffset); + initialSheets = sheets; } else { boolean sheetsFitInVolumes = remainingSheets == 0; EvenSizeVolumeSplitterCalculator prvSdc = sdc; @@ -75,12 +78,22 @@ public void updateSheetCount(int sheets, int remainingSheets) { inc *= .75; volumeInc = (int)Math.floor(inc); } + + // estimate of extra overhead per added volume + double overheadPerVolumeEstimate = (sheets - initialSheets) * 1.0 / prvSdc.getVolumeCount(); + int extraOverheadSheets = (int)Math.floor( + overheadPerVolumeEstimate * (volumeInc + esc.getVolumeCount() - prvSdc.getVolumeCount())); + sheets += extraOverheadSheets; + if (volumeInc > 0) { volumeOffset += volumeInc; sdc = new EvenSizeVolumeSplitterCalculator(sheets, splitterMax, volumeOffset); } else { // Try with adjusted number of sheets + if (extraOverheadSheets > 0) { + esc = new EvenSizeVolumeSplitterCalculator(sheets, splitterMax, volumeOffset); + } if (!previouslyTried.containsKey(esc) || previouslyTried.get(esc)) { sdc = esc; } else {