Skip to content

Commit

Permalink
brailleapps#32: Parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulRambags committed Aug 7, 2020
1 parent f4ae2e7 commit da3bb59
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.daisy.dotify.formatter.test;

import org.daisy.dotify.api.engine.LayoutEngineException;
import org.daisy.dotify.api.writer.PagedMediaWriterConfigurationException;
import org.junit.Test;

import java.io.IOException;

/**
* Unit tests for sequence breaks.
* TODO: true -> false
*
* @author Paul Rambags
*/
@SuppressWarnings("javadoc")
public class SequenceBreakTest extends AbstractFormatterEngineTest {

@Test
public void testParsing() throws
LayoutEngineException,
IOException,
PagedMediaWriterConfigurationException {
testPEF(
"resource-files/sequence-break/parsing-input.obfl",
"resource-files/sequence-break/parsing-expected.pef",
true
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<pef version="2008-1" xmlns="http://www.daisy.org/ns/2008/pef">
<head>
<meta xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:format>application/x-pef+xml</dc:format>
<dc:identifier>identifier?</dc:identifier>
<dc:date>2020-08-07</dc:date>
<dc:title>Parsing of sequence breaks test</dc:title>
<dc:description>Tests the parsing of sequence breaks</dc:description>
</meta>
</head>
<body>
<volume cols="10" rows="6" rowgap="0" duplex="false">
<section>
<page>
<row>⠤⠤⠤</row>
</page>
</section>
<section>
<page>
<row>⠤⠤⠤</row>
</page>
</section>
<section>
<page>
<row>⠤⠤⠤</row>
</page>
</section>
<section>
<page>
<row>⠤⠤⠤</row>
</page>
</section>
<section>
<page>
<row>⠤⠤⠤</row>
</page>
</section>
</volume>
<volume cols="10" rows="6" rowgap="0" duplex="false">
<section>
<page>
<row>⠤⠤⠤</row>
</page>
</section>
<section>
<page>
<row>⠤⠤⠤</row>
</page>
</section>
</volume>
</body>
</pef>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<obfl xmlns="http://www.daisy.org/ns/2011/obfl" version="2011-1" xml:lang="en">
<meta xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title>Parsing of sequence breaks test</dc:title>
<dc:description>Tests the parsing of sequence breaks</dc:description>
</meta>
<layout-master name="main" page-width="10" page-height="6" duplex="false">
<default-template>
<header/>
<footer/>
</default-template>
</layout-master>
<table-of-contents name="toc">
<toc-block/>
</table-of-contents>
<volume-template sheets-in-volume-max="5" use-when="(= $volume 1)">
<pre-content>
<dynamic-sequence master="main" break-before="page" break-after="page">
<block>⠤⠤⠤</block>
</dynamic-sequence>
<sequence master="main" break-before="page" break-after="page">
<block>⠤⠤⠤</block>
</sequence>
</pre-content>
<post-content>
<toc-sequence toc="toc" range="document" master="main" break-before="page" break-after="page"/>
</post-content>
</volume-template>
<volume-template sheets-in-volume-max="5" use-when="(> $volume 1)">
<pre-content>
<dynamic-sequence master="main" break-before="sheet" break-after="sheet">
<block>⠤⠤⠤</block>
</dynamic-sequence>
<sequence master="main" break-before="sheet" break-after="sheet">
<block>⠤⠤⠤</block>
</sequence>
</pre-content>
<post-content>
<toc-sequence toc="toc" range="document" master="main" break-before="sheet" break-after="sheet"/>
</post-content>
</volume-template>
<sequence master="main">
<block>⠤⠤⠤</block>
</sequence>
<sequence master="main" break-before="auto" break-after="page">
<block>⠤⠤⠤</block>
</sequence>
<sequence master="main" break-before="page" break-after="sheet">
<block>⠤⠤⠤</block>
</sequence>
<sequence master="main" break-before="sheet" break-after="volume">
<block>⠤⠤⠤</block>
</sequence>
<sequence master="main" break-before="volume" break-after="auto">
<block>⠤⠤⠤</block>
</sequence>
</obfl>
4 changes: 2 additions & 2 deletions src/org/daisy/dotify/formatter/impl/VolumeProvider.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.daisy.dotify.formatter.impl;

import org.daisy.dotify.api.formatter.SequenceProperties.SequenceBreakBefore;
import org.daisy.dotify.api.formatter.SequenceProperties.SequenceBreak;
import org.daisy.dotify.common.splitter.SplitPoint;
import org.daisy.dotify.common.splitter.SplitPointCost;
import org.daisy.dotify.common.splitter.SplitPointDataSource;
Expand Down Expand Up @@ -324,7 +324,7 @@ private Iterable<SheetDataSource> prepareToPaginateWithVolumeGroups(
List<BlockSequence> currentGroup = new ArrayList<>();
volGroups.add(currentGroup);
for (BlockSequence bs : fs) {
if (bs.getSequenceProperties().getBreakBeforeType() == SequenceBreakBefore.VOLUME) {
if (bs.getSequenceProperties().getBreakBeforeType() == SequenceBreak.VOLUME) {
currentGroup = new ArrayList<>();
volGroups.add(currentGroup);
}
Expand Down
6 changes: 5 additions & 1 deletion src/org/daisy/dotify/formatter/impl/obfl/ObflParserImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,11 @@ private void parseSequence(XMLEvent event, XMLEventIterator input, TextPropertie
}
String breakBefore = getAttr(event, "break-before");
if (breakBefore != null) {
builder.breakBefore(SequenceProperties.SequenceBreakBefore.valueOf(breakBefore.toUpperCase()));
builder.breakBefore(SequenceProperties.SequenceBreak.valueOf(breakBefore.toUpperCase()));
}
String breakAfter = getAttr(event, "break-after");
if (breakAfter != null) {
builder.breakAfter(SequenceProperties.SequenceBreak.valueOf(breakAfter.toUpperCase()));
}
String pageNumberCounter = getAttr(event, "page-number-counter");
if (pageNumberCounter != null) {
Expand Down

0 comments on commit da3bb59

Please sign in to comment.