diff options
author | Adrian Cumiskey <acumiskey@apache.org> | 2007-10-26 18:17:00 +0000 |
---|---|---|
committer | Adrian Cumiskey <acumiskey@apache.org> | 2007-10-26 18:17:00 +0000 |
commit | 00988a93d33e694bd6caf478bcff7daf92c4ba49 (patch) | |
tree | d637fa22adcdd96daeb2817eba5b0fa573476901 | |
parent | fb9e4e279d5f83eeabbd2fa69b1a342ab66429b8 (diff) | |
download | xmlgraphics-fop-00988a93d33e694bd6caf478bcff7daf92c4ba49.tar.gz xmlgraphics-fop-00988a93d33e694bd6caf478bcff7daf92c4ba49.zip |
Applying [PATCH] 43587 - Multiple ps:comment-? within fo:declarations causes ClassCastException
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@588733 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/java/org/apache/fop/render/ps/PSRenderer.java | 12 | ||||
-rw-r--r-- | test/layoutengine/standard-testcases/ps-extension_2.xml | 28 |
2 files changed, 27 insertions, 13 deletions
diff --git a/src/java/org/apache/fop/render/ps/PSRenderer.java b/src/java/org/apache/fop/render/ps/PSRenderer.java index 9e224a9b2..3befb0738 100644 --- a/src/java/org/apache/fop/render/ps/PSRenderer.java +++ b/src/java/org/apache/fop/render/ps/PSRenderer.java @@ -830,6 +830,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer implements ImageAda PSExtensionAttachment comment = (PSExtensionAttachment)iter.next(); gen.commentln("%" + comment.getContent()); } + footerComments.clear(); } gen.writeDSCComment(DSCConstants.PAGES, new Integer(this.currentPageNumber)); gen.getResourceTracker().writeResources(false, gen); @@ -840,7 +841,12 @@ public class PSRenderer extends AbstractPathOrientedRenderer implements ImageAda IOUtils.closeQuietly(gen.getOutputStream()); rewritePostScriptFile(); } - this.pageDeviceDictionary.clear(); + if (footerComments != null) { + headerComments.clear(); + } + if (pageDeviceDictionary != null) { + pageDeviceDictionary.clear(); + } } /** @@ -910,12 +916,12 @@ public class PSRenderer extends AbstractPathOrientedRenderer implements ImageAda } } else if (attachment instanceof PSCommentBefore) { if (headerComments == null) { - headerComments = new java.util.TreeSet(); + headerComments = new java.util.ArrayList(); } headerComments.add(attachment); } else if (attachment instanceof PSCommentAfter) { if (footerComments == null) { - footerComments = new java.util.TreeSet(); + footerComments = new java.util.ArrayList(); } footerComments.add(attachment); } diff --git a/test/layoutengine/standard-testcases/ps-extension_2.xml b/test/layoutengine/standard-testcases/ps-extension_2.xml index 846a96db5..036c19fd6 100644 --- a/test/layoutengine/standard-testcases/ps-extension_2.xml +++ b/test/layoutengine/standard-testcases/ps-extension_2.xml @@ -34,8 +34,10 @@ </fo:simple-page-master>
<fo:simple-page-master master-name="A4a" page-height="29.7cm" page-width="21cm" margin-top="1cm" margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
<ps:ps-setpagedevice name="upper tray"><![CDATA[ << /MediaPosition 1 >> ]]></ps:ps-setpagedevice>
- <ps:ps-comment-before>A4a before page</ps:ps-comment-before>
- <ps:ps-comment-after>A4a after page</ps:ps-comment-after>
+ <ps:ps-comment-before>A4a before page 1</ps:ps-comment-before>
+ <ps:ps-comment-after>A4a after page 1</ps:ps-comment-after>
+ <ps:ps-comment-before>A4a before page 2</ps:ps-comment-before>
+ <ps:ps-comment-after>A4a after page 2</ps:ps-comment-after>
<fo:region-body background-color="orange"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="complex">
@@ -46,8 +48,10 @@ </fo:layout-master-set>
<fo:declarations>
<ps:ps-setpagedevice name="autofeed"><![CDATA[ << /ManualFeed false >> ]]></ps:ps-setpagedevice>
- <ps:ps-comment-before>header comment</ps:ps-comment-before>
- <ps:ps-comment-after>footer comment</ps:ps-comment-after>
+ <ps:ps-comment-before>header comment 1</ps:ps-comment-before>
+ <ps:ps-comment-after>footer comment 1</ps:ps-comment-after>
+ <ps:ps-comment-before>header comment 2</ps:ps-comment-before>
+ <ps:ps-comment-after>footer comment 2</ps:ps-comment-after>
</fo:declarations>
<fo:page-sequence master-reference="complex">
<fo:flow flow-name="xsl-region-body">
@@ -64,20 +68,24 @@ <eval expected="2" xpath="count(/areaTree/child::*)"/>
<eval expected="1" xpath="count(/areaTree/child::pageSequence)"/>
<eval expected="1" xpath="count(/areaTree/child::extension-attachments)"/>
- <eval expected="3" xpath="count(/areaTree/child::extension-attachments/child::*)"/>
+ <eval expected="5" xpath="count(/areaTree/child::extension-attachments/child::*)"/>
<eval expected="autofeed" xpath="/areaTree/extension-attachments/child::*[1]/@name"/>
- <eval expected="header comment" xpath="/areaTree/extension-attachments/child::*[2]/text()"/>
- <eval expected="footer comment" xpath="/areaTree/extension-attachments/child::*[3]/text()"/>
+ <eval expected="header comment 1" xpath="/areaTree/extension-attachments/child::*[2]/text()"/>
+ <eval expected="footer comment 1" xpath="/areaTree/extension-attachments/child::*[3]/text()"/>
+ <eval expected="header comment 2" xpath="/areaTree/extension-attachments/child::*[4]/text()"/>
+ <eval expected="footer comment 2" xpath="/areaTree/extension-attachments/child::*[5]/text()"/>
<eval expected="3" xpath="count(/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4' and @nr=1]/page/extension-attachments/child::*)"/>
<eval expected="lower tray" xpath="/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4' and @nr=1]/page/extension-attachments/child::*[1]/@name"/>
<eval expected="A4 before page" xpath="/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4' and @nr=1]/page/extension-attachments/child::*[2]"/>
<eval expected="A4 after page" xpath="/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4' and @nr=1]/page/extension-attachments/child::*[3]"/>
- <eval expected="3" xpath="count(/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4a' and @nr=2]/page/extension-attachments/child::*)"/>
+ <eval expected="5" xpath="count(/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4a' and @nr=2]/page/extension-attachments/child::*)"/>
<eval expected="upper tray" xpath="/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4a' and @nr=2]/page/extension-attachments/child::*[1]/@name"/>
- <eval expected="A4a before page" xpath="/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4a' and @nr=2]/page/extension-attachments/child::*[2]"/>
- <eval expected="A4a after page" xpath="/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4a' and @nr=2]/page/extension-attachments/child::*[3]"/>
+ <eval expected="A4a before page 1" xpath="/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4a' and @nr=2]/page/extension-attachments/child::*[2]"/>
+ <eval expected="A4a after page 1" xpath="/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4a' and @nr=2]/page/extension-attachments/child::*[3]"/>
+ <eval expected="A4a before page 2" xpath="/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4a' and @nr=2]/page/extension-attachments/child::*[4]"/>
+ <eval expected="A4a after page 2" xpath="/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4a' and @nr=2]/page/extension-attachments/child::*[5]"/>
<eval expected="3" xpath="count(/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4' and @nr=3]/page/extension-attachments/child::*)"/>
<eval expected="lower tray" xpath="/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4' and @nr=3]/page/extension-attachments/child::*[1]/@name"/>
|