From c98714481006753bd1add759440b5c9a2e875b14 Mon Sep 17 00:00:00 2001 From: Chris Bowditch Date: Tue, 19 Apr 2011 13:49:40 +0000 Subject: [PATCH] Bugzilla #51010: Bookmarks create useless lines in RTF Patch submitted by Max Aster git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1095086 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java | 16 ++++++++++++++-- status.xml | 3 +++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java index 7a9245dd5..0cbd1f686 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java @@ -437,10 +437,16 @@ public class RtfTextrun extends RtfContainer { //get last RtfParagraphBreak, which is not followed by any visible child RtfParagraphBreak lastParagraphBreak = null; if (bLast) { + RtfElement aBefore = null; for (Iterator it = getChildren().iterator(); it.hasNext();) { final RtfElement e = (RtfElement)it.next(); if (e instanceof RtfParagraphBreak) { - lastParagraphBreak = (RtfParagraphBreak)e; + //If the element before was a paragraph break or a bookmark + //they will be hidden and are therefore not considered as visible + if (!(aBefore instanceof RtfParagraphBreak) + && !(aBefore instanceof RtfBookmark)) { + lastParagraphBreak = (RtfParagraphBreak)e; + } } else { if (!(e instanceof RtfOpenGroupMark) && !(e instanceof RtfCloseGroupMark) @@ -448,6 +454,7 @@ public class RtfTextrun extends RtfContainer { lastParagraphBreak = null; } } + aBefore = e; } } @@ -460,6 +467,7 @@ public class RtfTextrun extends RtfContainer { //write all children boolean bPrevPar = false; + boolean bBookmark = false; boolean bFirst = true; for (Iterator it = getChildren().iterator(); it.hasNext();) { final RtfElement e = (RtfElement)it.next(); @@ -484,7 +492,8 @@ public class RtfTextrun extends RtfContainer { && (bPrevPar || bFirst || (bSuppressLastPar && bLast && lastParagraphBreak != null - && e == lastParagraphBreak)); + && e == lastParagraphBreak) + || bBookmark); if (!bHide) { newLine(); @@ -497,6 +506,8 @@ public class RtfTextrun extends RtfContainer { if (e instanceof RtfParagraphBreak) { bPrevPar = true; + } else if (e instanceof RtfBookmark) { + bBookmark = true; } else if (e instanceof RtfCloseGroupMark) { //do nothing } else if (e instanceof RtfOpenGroupMark) { @@ -504,6 +515,7 @@ public class RtfTextrun extends RtfContainer { } else { bPrevPar = bPrevPar && e.isEmpty(); bFirst = bFirst && e.isEmpty(); + bBookmark = false; } } //for (Iterator it = ...) diff --git a/status.xml b/status.xml index 12aade2fc..23dedd018 100644 --- a/status.xml +++ b/status.xml @@ -59,6 +59,9 @@ documents. Example: the fix of marks layering will be such a case when it's done. --> + + Bugzilla 51010: Bookmarks create useless lines in RTF + Bugzilla 51008: page-number-citation-last does not work in RTF -- 2.39.5