Skip to content

Commit

Permalink
Supports BreakBefore.SHEET, added to dotify.api v4.3.0 (closes #54)
Browse files Browse the repository at this point in the history
  • Loading branch information
bertfrees authored and Joel Håkansson committed Jul 2, 2018
1 parent e3b91b8 commit 36ee65a
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ repositories {

dependencies {
compileOnly 'org.osgi:org.osgi.service.component.annotations:1.3.0'
compile "org.daisy.dotify:dotify.api:4.2.0"
compile "org.daisy.dotify:dotify.api:4.3.0"
compile "org.daisy.dotify:dotify.common:4.1.0"
compile 'org.daisy.streamline:streamline-api:1.2.0'
compile (group: 'org.daisy.libs', name: 'saxon-he', version: '9.5.1.5') {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ repositoryRevision=N/A
repositoryURL=https://github.com/brailleapps/dotify.formatter.impl
repositorySCM=scm:git:https://github.com/brailleapps/dotify.formatter.impl.git
moduleName=org.daisy.dotify.formatter
version=4.3.1-SNAPSHOT
version=4.4.0-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -403,4 +403,9 @@ public void testVolumeBreakingBetweenWords() throws LayoutEngineException, IOExc
null
);
}
@Test
public void testBreakBeforeSheet() throws LayoutEngineException, IOException, PagedMediaWriterConfigurationException {
testPEF("resource-files/dp2/break-before-sheet-input.obfl",
"resource-files/dp2/break-before-sheet-expected.pef", false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<pef xmlns="http://www.daisy.org/ns/2008/pef" version="2008-1">
<head>
<meta>
<dc:title xmlns:dc="http://purl.org/dc/elements/1.1/">break-before-sheet</dc:title>
<dc:description xmlns:dc="http://purl.org/dc/elements/1.1/">Tests break-before="sheet".</dc:description>
<dc:format xmlns:dc="http://purl.org/dc/elements/1.1/">application/x-pef+xml</dc:format>
</meta>
</head>
<body>
<volume cols="10" rows="10" rowgap="0" duplex="true">
<section>
<page>
<row>⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀</row>
<row>⠛⠛⠛</row>
</page>
<page>
<row>⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀</row>
</page>
<page>
<row>⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀</row>
<row>⠤⠤⠤</row>
</page>
</section>
</volume>
</body>
</pef>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<obfl xmlns="http://www.daisy.org/ns/2011/obfl" version="2011-1" xml:lang="und" hyphenate="false">
<meta>
<dc:title xmlns:dc="http://purl.org/dc/elements/1.1/">break-before-sheet</dc:title>
<dc:description xmlns:dc="http://purl.org/dc/elements/1.1/">Tests break-before="sheet".</dc:description>
</meta>
<layout-master name="a" duplex="true" page-width="10" page-height="10">
<default-template>
<header>
<field>
<string value=""/>
</field>
<field>
<string value=""/>
</field>
</header>
<footer/>
</default-template>
</layout-master>
<sequence master="a">
<block>⠛⠛⠛</block>
<block break-before="sheet">⠤⠤⠤</block>
</sequence>
</obfl>
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class PageSequenceBuilder2 {
private int keepNextSheets;
private int pageCount = 0;
private int dataGroupsIndex;
private boolean nextEmpty = false;

//From view, temporary
private final int fromIndex;
Expand Down Expand Up @@ -116,6 +117,7 @@ public PageSequenceBuilder2(PageSequenceBuilder2 template) {
this.data = RowGroupDataSource.copyUnlessNull(template.data);
this.keepNextSheets = template.keepNextSheets;
this.pageCount = template.pageCount;
this.nextEmpty = template.nextEmpty;
this.fromIndex = template.fromIndex;
this.toIndex = template.toIndex;
}
Expand Down Expand Up @@ -180,6 +182,10 @@ public PageImpl nextPage(int pageNumberOffset, boolean hyphenateLastLine, Option
private PageImpl nextPageInner(int pageNumberOffset, boolean hyphenateLastLine, Optional<TransitionContent> transitionContent) throws PaginatorException, RestartPaginationException // pagination must be restarted in PageStructBuilder.paginateInner
{
PageImpl current = newPage(pageNumberOffset);
if (nextEmpty) {
nextEmpty = false;
return current;
}
while (dataGroupsIndex<dataGroups.size() || (data!=null && !data.isEmpty())) {
if ((data==null || data.isEmpty()) && dataGroupsIndex<dataGroups.size()) {
//pick up next group
Expand Down Expand Up @@ -310,8 +316,16 @@ private PageImpl nextPageInner(int pageNumberOffset, boolean hyphenateLastLine,
if (hasPageAreaCollection() && current.pageAreaSpaceNeeded() > master.getPageArea().getMaxHeight()) {
reassignCollection();
}
if (!data.isEmpty() || (current!=null && dataGroupsIndex<dataGroups.size() && dataGroups.get(dataGroupsIndex).getBreakBefore()!=BreakBefore.AUTO)) {
if (!data.isEmpty()) {
return current;
} else if (current!=null && dataGroupsIndex<dataGroups.size()) {
BreakBefore nextStart = dataGroups.get(dataGroupsIndex).getBreakBefore();
if (nextStart!=BreakBefore.AUTO) {
if (nextStart == BreakBefore.SHEET && master.duplex() && pageCount%2==1) {
nextEmpty = true;
}
return current;
}
}
}
}
Expand Down

0 comments on commit 36ee65a

Please sign in to comment.