From 6bf198e44f601009fde252e7d803dae64e639b43 Mon Sep 17 00:00:00 2001 From: Joerg Pietschmann Date: Fri, 19 Jul 2002 00:30:13 +0000 Subject: [PATCH] Fixed marker retrival to a large degree. It works now for arbitrary retrival boundaries as long as the referenced page is still in the renderer queue (could be enforced by forward referencing page number citation) Markers which are immediate children of a flow still don't work. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_20_2-maintain@195009 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/apps/StreamRenderer.java | 77 +++++++++++-------- .../apache/fop/fo/flow/RetrieveMarker.java | 47 +++++------ 2 files changed, 70 insertions(+), 54 deletions(-) diff --git a/src/org/apache/fop/apps/StreamRenderer.java b/src/org/apache/fop/apps/StreamRenderer.java index 6870aeb7c..d56bb932a 100644 --- a/src/org/apache/fop/apps/StreamRenderer.java +++ b/src/org/apache/fop/apps/StreamRenderer.java @@ -318,42 +318,55 @@ public class StreamRenderer { } } - public Page getNextPage(Page current, boolean isWithinPageSequence, - boolean isFirstCall) { - Page nextPage = null; - int pageIndex = 0; - if (isFirstCall) - pageIndex = renderQueue.size(); - else - pageIndex = renderQueue.indexOf(current); - if ((pageIndex + 1) < renderQueue.size()) { - nextPage = ((RenderQueueEntry)renderQueue - .elementAt(pageIndex + 1)).getPage(); - if (isWithinPageSequence - &&!nextPage.getPageSequence().equals(current.getPageSequence())) { - nextPage = null; - } - } - return nextPage; - } + // unused and broken +// public Page getNextPage(Page current, boolean isWithinPageSequence, +// boolean isFirstCall) { +// Page nextPage = null; +// int pageIndex = 0; +// if (isFirstCall) +// pageIndex = renderQueue.size(); +// else +// pageIndex = renderQueue.indexOf(current); +// if ((pageIndex + 1) < renderQueue.size()) { +// nextPage = ((RenderQueueEntry)renderQueue +// .elementAt(pageIndex + 1)).getPage(); +// if (isWithinPageSequence +// &&!nextPage.getPageSequence().equals(current.getPageSequence())) { +// nextPage = null; +// } +// } +// return nextPage; +// } public Page getPreviousPage(Page current, boolean isWithinPageSequence, boolean isFirstCall) { - Page previousPage = null; - int pageIndex = 0; - if (isFirstCall) - pageIndex = renderQueue.size(); - else - pageIndex = renderQueue.indexOf(current); - if ((pageIndex - 1) >= 0) { - previousPage = ((RenderQueueEntry)renderQueue - .elementAt(pageIndex - 1)).getPage(); - PageSequence currentPS = current.getPageSequence(); - PageSequence previousPS = previousPage.getPageSequence(); - if (isWithinPageSequence &&!previousPS.equals(currentPS)) { - previousPage = null; + if (isFirstCall) { + int pageIndex = renderQueue.size(); + if (pageIndex > 0) { + Page previousPage = ((RenderQueueEntry)renderQueue + .elementAt(pageIndex - 1)).getPage(); + PageSequence currentPS = current.getPageSequence(); + PageSequence previousPS = previousPage.getPageSequence(); + if (!isWithinPageSequence || previousPS.equals(currentPS)) { + return previousPage; + } + } + } else { + for (int pageIndex=renderQueue.size()-1;pageIndex>0;pageIndex--) { + Page page = ((RenderQueueEntry)renderQueue + .elementAt(pageIndex)).getPage(); + if (current.equals(page)) { + Page previousPage = ((RenderQueueEntry)renderQueue + .elementAt(pageIndex - 1)).getPage(); + PageSequence currentPS = current.getPageSequence(); + PageSequence previousPS = previousPage.getPageSequence(); + if (!isWithinPageSequence || previousPS.equals(currentPS)) { + return previousPage; + } + return null; + } } } - return previousPage; + return null; } } diff --git a/src/org/apache/fop/fo/flow/RetrieveMarker.java b/src/org/apache/fop/fo/flow/RetrieveMarker.java index 7e2817f7b..bfb7545ec 100644 --- a/src/org/apache/fop/fo/flow/RetrieveMarker.java +++ b/src/org/apache/fop/fo/flow/RetrieveMarker.java @@ -55,32 +55,35 @@ public class RetrieveMarker extends FObjMixed { Marker bestMarker = searchPage(containingPage, true); // if marker not yet found, and 'retrieve-boundary' permits, - // search forward by Page - if ((null == bestMarker) - && (retrieveBoundary != RetrieveBoundary.PAGE)) { - // System.out.println("Null bestMarker and searching..."); - Page currentPage = containingPage; - boolean isFirstCall = true; - while (bestMarker == null) { - Page previousPage = locatePreviousPage(currentPage, - retrieveBoundary, - isFirstCall); - isFirstCall = false; - // System.out.println("Previous page = '" + previousPage + "'"); - bestMarker = searchPage(previousPage, false); - currentPage = previousPage; + // search backward by Page + if (bestMarker == null) { + if (retrieveBoundary != RetrieveBoundary.PAGE) { +// System.out.println("Null bestMarker and searching..."); + Page currentPage = containingPage; + boolean isFirstCall = true; + while (bestMarker == null) { + Page previousPage = locatePreviousPage(currentPage, + retrieveBoundary, + isFirstCall); + isFirstCall = false; + if (previousPage!=null) { + bestMarker = searchPage(previousPage, false); + currentPage = previousPage; + } else { + return new Status(Status.OK); + } + } + } else { + return new Status(Status.OK); } } Status status = new Status(Status.OK); - if (null != bestMarker) { - // System.out.println("Laying out marker '" + bestMarker + "' in area '" + area + "'"); - // the 'markers' referred to in this method are internal; they have - // nothing to do with fo:marker - bestMarker.resetMarker(); - status = bestMarker.layoutMarker(area); - } - + // System.out.println("Laying out marker '" + bestMarker + "' in area '" + area + "'"); + // the 'markers' referred to in this method are internal; they have + // nothing to do with fo:marker + bestMarker.resetMarker(); + status = bestMarker.layoutMarker(area); return status; } -- 2.39.5