}
}
- 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;
}
}
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;
}