]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fixed marker retrival to a large degree. It works
authorJoerg Pietschmann <pietsch@apache.org>
Fri, 19 Jul 2002 00:30:13 +0000 (00:30 +0000)
committerJoerg Pietschmann <pietsch@apache.org>
Fri, 19 Jul 2002 00:30:13 +0000 (00:30 +0000)
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
src/org/apache/fop/fo/flow/RetrieveMarker.java

index 6870aeb7c52c37e39a246dee3abb0409ee0e7f8e..d56bb932a41da1afaebedae833cccd276f7644c1 100644 (file)
@@ -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;
     }
 }
index 7e2817f7b6077ddcface66c4f4668ee0b58fe855..bfb7545ecb0d155dc0be4bb3dab0ba0a0812f605 100644 (file)
@@ -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;
     }