[FOray-commit] SF.net SVN: foray: [9672] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2007-05-31 18:29:09
|
Revision: 9672
http://svn.sourceforge.net/foray/?rev=9672&view=rev
Author: victormote
Date: 2007-05-31 11:29:11 -0700 (Thu, 31 May 2007)
Log Message:
-----------
1. Fix bug in block layout logic, returning with the wrong status.
2. Add test file and test for this bug.
Modified Paths:
--------------
trunk/foray/foray-app/src/javatest/org/foray/app/area/AbstractAreaTreeTest.java
trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java
trunk/foray/foray-pioneer/src/java/org/foray/pioneer/BlockPL.java
trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FOTextPL.java
Added Paths:
-----------
trunk/foray/resource/test/fo/block-002.fo
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/area/AbstractAreaTreeTest.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/area/AbstractAreaTreeTest.java 2007-05-30 21:23:35 UTC (rev 9671)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/area/AbstractAreaTreeTest.java 2007-05-31 18:29:11 UTC (rev 9672)
@@ -46,15 +46,13 @@
public abstract class AbstractAreaTreeTest extends TestCase {
/**
- * Returns the first page item in a given area tree.
- * @param areaTree The area tree whose first page is needed.
- * @return The first page in <code>areaTree</code>
+ * Returns the first normal-flow reference area in a given area tree.
+ * @param areaTree The area tree being tested.
+ * @return The first normal-flow reference area in <code>areaTree</code>.
*/
protected NormalFlowRA getFirstNormalFlowArea(final AreaTree areaTree) {
- OrderedTreeNode node = areaTree.getChildAt(0);
- assertTrue(node instanceof PageCollection);
- final PageCollection pageCollection = (PageCollection) node;
- node = pageCollection.getChildAt(0);
+ final PageCollection pageCollection = getFirstPageCollection(areaTree);
+ OrderedTreeNode node = pageCollection.getChildAt(0);
assertTrue(node instanceof PageRA);
final PageRA firstPage = (PageRA) node;
final RegionRABody regionBody = firstPage.getRegionBody();
@@ -68,4 +66,16 @@
return nfa;
}
+ /**
+ * Returns the first page collection in a given area tree.
+ * @param areaTree The area tree being tested.
+ * @return The first page collection in <code>areaTree</code>.
+ */
+ protected PageCollection getFirstPageCollection(final AreaTree areaTree) {
+ final OrderedTreeNode node = areaTree.getChildAt(0);
+ assertTrue(node instanceof PageCollection);
+ final PageCollection pageCollection = (PageCollection) node;
+ return pageCollection;
+ }
+
}
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java 2007-05-30 21:23:35 UTC (rev 9671)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java 2007-05-31 18:29:11 UTC (rev 9672)
@@ -32,6 +32,7 @@
import org.foray.area.LineArea;
import org.foray.area.NormalBlockArea;
import org.foray.area.NormalFlowRA;
+import org.foray.area.PageCollection;
import org.foray.core.FOrayException;
import org.axsl.common.OrderedTreeNode;
@@ -138,4 +139,18 @@
assertEquals(12000, lineArea.crBPD());
}
+ /**
+ * Test of fo/block-002.fo.
+ * @throws FOrayException For errors creating the FO Tree or Area Tree.
+ */
+ public void testBlock002() throws FOrayException {
+ final AreaTreeCreator creator = AreaTreeCreator.getInstance();
+ final AreaTree areaTree = creator.buildAreaTree(
+ "fo/block-002.fo");
+ final PageCollection pageCollection = this.getFirstPageCollection(
+ areaTree);
+ final int numPages = pageCollection.getChildCount();
+ assertEquals(2, numPages);
+ }
+
}
Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/BlockPL.java
===================================================================
--- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/BlockPL.java 2007-05-30 21:23:35 UTC (rev 9671)
+++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/BlockPL.java 2007-05-31 18:29:11 UTC (rev 9672)
@@ -167,6 +167,7 @@
return Status.AREA_FULL_SOME;
}
anythingLaidOut = true;
+ return status;
}
anythingLaidOut = true;
}
Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FOTextPL.java
===================================================================
--- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FOTextPL.java 2007-05-30 21:23:35 UTC (rev 9671)
+++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FOTextPL.java 2007-05-31 18:29:11 UTC (rev 9672)
@@ -95,7 +95,9 @@
if (la == null) {
return start;
}
- return addTextItemToLine(la, lineText, start, end, graftingPoint);
+ final int progress = addTextItemToLine(la, lineText, start, end,
+ graftingPoint);
+ return progress;
}
/**
Added: trunk/foray/resource/test/fo/block-002.fo
===================================================================
--- trunk/foray/resource/test/fo/block-002.fo (rev 0)
+++ trunk/foray/resource/test/fo/block-002.fo 2007-05-31 18:29:11 UTC (rev 9672)
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+This fo file is on a short (4 inches high) page, and contains one block with
+content that spills onto a second page. Its purpose is to test whether all of
+the content finds its way into the Area Tree.
+-->
+
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+
+<fo:layout-master-set>
+ <fo:simple-page-master
+ master-name="simple"
+ page-height="4in"
+ margin-top="1in"
+ margin-bottom="1in"
+ margin-left="1in"
+ margin-right="1in">
+ <fo:region-body/>
+ </fo:simple-page-master>
+</fo:layout-master-set>
+
+<fo:page-sequence master-reference="simple">
+<fo:flow flow-name="xsl-region-body">
+
+
+<fo:block>
+This document is on a short (4 inches high) page, and contains one block.
+The content of that one block is intended to spill onto a second page, the
+purpose being to test whether all of the content ends up in the output
+document.
+This is test sentence 1. This is test sentence 2. This is test sentence 3.
+This is test sentence 4. This is test sentence 5. This is test sentence 6.
+This is test sentence 7. This is test sentence 8. This is test sentence 9.
+This is test sentence 10. This is test sentence 11. This is test sentence 12.
+This is test sentence 13. This is test sentence 14. This is test sentence 15.
+This is test sentence 16. This is test sentence 17. This is test sentence 18.
+This is test sentence 19. This is test sentence 20. This is test sentence 21.
+This is test sentence 22. This is test sentence 23. This is test sentence 24.
+This is test sentence 25. This is test sentence 26. This is test sentence 27.
+This is test sentence 28. This is test sentence 29. This is test sentence 30.
+This is test sentence 31. This is test sentence 32. This is test sentence 33.
+This is test sentence 34. This is test sentence 35. This is test sentence 36.
+This is test sentence 37. This is test sentence 38. This is test sentence 39.
+This is test sentence 40. This is test sentence 41. This is test sentence 42.
+This is test sentence 43. This is test sentence 44. This is test sentence 45.
+This is test sentence 46. This is test sentence 47. This is test sentence 48.
+This is test sentence 49. This is test sentence 50. This is test sentence 51.
+This is test sentence 52. This is test sentence 53. This is test sentence 54.
+</fo:block>
+
+
+</fo:flow>
+</fo:page-sequence>
+</fo:root>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|