Revision: 7873
http://svn.sourceforge.net/foray/?rev=7873&view=rev
Author: victormote
Date: 2006-09-03 14:21:31 -0700 (Sun, 03 Sep 2006)
Log Message:
-----------
More cleanup of page generation logic.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageMasterResolver.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RepeatablePMReference.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SinglePageMasterReference.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SubSequenceSpecifier.java
Removed Paths:
-------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageMasterReference.java
Deleted: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageMasterReference.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageMasterReference.java 2006-09-03 21:06:28 UTC (rev 7872)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageMasterReference.java 2006-09-03 21:21:31 UTC (rev 7873)
@@ -1,45 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/* $Id$ */
-
-package org.foray.fotree.fo.obj;
-
-import org.foray.fotree.FObj;
-import org.foray.fotree.PropertyList;
-
-
-/**
- * Abstract base class for PageMasterReference classes.
- * Provides implementation for handling the master-reference attribute and
- * containment within a PageSequenceMaster
- */
-public abstract class PageMasterReference extends FObj
- implements SubSequenceSpecifier {
-
- public PageMasterReference(final FObj parent,
- final PropertyList propertyList, final String systemId,
- final int line, final int column) {
- super(parent, propertyList, systemId, line, column);
- }
-
-}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageMasterResolver.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageMasterResolver.java 2006-09-03 21:06:28 UTC (rev 7872)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageMasterResolver.java 2006-09-03 21:21:31 UTC (rev 7873)
@@ -42,7 +42,7 @@
private int currentSubSequenceNumber;
/** Current SubSequenceSpecifier. */
- private SubSequenceSpecifier currentSubSequence;
+ private SubSequenceWrapper currentSubSequence;
public PageMasterResolver(final PageSequence pageSequence,
final int lastPageNumber) {
@@ -84,7 +84,7 @@
oddPage, firstPage, blankPage);
boolean canRecover = true;
while (pageMasterName == null) {
- final SubSequenceSpecifier nextSubSequence = getNextSubSequence(
+ final SubSequenceWrapper nextSubSequence = getNextSubSequence(
psm);
firstPage = true;
if (nextSubSequence == null) {
@@ -97,7 +97,6 @@
"subsequences exhausted in " + "page-sequence-master '"
+ psm.traitMasterName()
+ "', use previous subsequence");
- currentSubSequence.reset();
canRecover = false;
} else {
currentSubSequence = nextSubSequence;
@@ -116,15 +115,64 @@
return pageMaster;
}
- protected SubSequenceSpecifier getNextSubSequence(
+ protected SubSequenceWrapper getNextSubSequence(
final PageSequenceMaster psm) {
currentSubSequenceNumber++;
if (currentSubSequenceNumber >= 0
&& currentSubSequenceNumber < psm.getChildCount()) {
- return (SubSequenceSpecifier) psm.getChildAt(
- currentSubSequenceNumber);
+ final SubSequenceSpecifier specifier = (SubSequenceSpecifier)
+ psm.getChildAt(currentSubSequenceNumber);
+ return makeWrapper(specifier);
}
return null;
}
+ private SubSequenceWrapper makeWrapper(
+ final SubSequenceSpecifier specifier) {
+ if (specifier instanceof SinglePageMasterReference) {
+ return new SinglePageMRWrapper((SinglePageMasterReference)
+ specifier);
+ }
+ return null;
+ }
+
+/******************************************************************************/
+
+ /**
+ * Private inner abstract superclass for all sub-sequence specifier
+ * wrappers.
+ */
+ private abstract class SubSequenceWrapper {
+ abstract String getNextPageMasterName(boolean isOddPage,
+ boolean isFirstPage, boolean isEmptyPage)
+ throws FOTreeException;
+
+ }
+
+/******************************************************************************/
+
+ /**
+ * Private inner class wrapping a {@link SinglePageMasterReference}
+ * instance.
+ */
+ private class SinglePageMRWrapper extends SubSequenceWrapper {
+
+ private SinglePageMasterReference wrapped;
+ private boolean isDone = false;
+
+ SinglePageMRWrapper(final SinglePageMasterReference wrapped) {
+ this.wrapped = wrapped;
+ }
+
+ public String getNextPageMasterName(final boolean isOddPage,
+ final boolean isFirstPage, final boolean isEmptyPage) {
+ if (! this.isDone) {
+ this.isDone = true;
+ return wrapped.traitMasterName();
+ }
+ return null;
+ }
+
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RepeatablePMReference.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RepeatablePMReference.java 2006-09-03 21:06:28 UTC (rev 7872)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RepeatablePMReference.java 2006-09-03 21:21:31 UTC (rev 7873)
@@ -40,7 +40,7 @@
/**
* A "repeatable-page-master-reference" object in XSL-FO.
*/
-public class RepeatablePMReference extends PageMasterReference
+public class RepeatablePMReference extends FObj
implements SubSequenceSpecifier {
/* TODO: This state information should probably be stored in
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SinglePageMasterReference.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SinglePageMasterReference.java 2006-09-03 21:06:28 UTC (rev 7872)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SinglePageMasterReference.java 2006-09-03 21:21:31 UTC (rev 7873)
@@ -39,13 +39,9 @@
/**
* A "single-page-master-reference" object in XSl-FO.
*/
-public class SinglePageMasterReference extends PageMasterReference {
+public class SinglePageMasterReference extends FObj
+ implements SubSequenceSpecifier {
- /* TODO: This state information should probably be stored in
- * PageSequenceMaster, with a unique value for each occurrence used within
- * each PageSequence. */
- private boolean isDone = false;
-
public SinglePageMasterReference(final FObj parent,
final PropertyList propertyList, final String systemId,
final int line, final int column) {
@@ -107,19 +103,6 @@
return "single-page-master-reference";
}
- public String getNextPageMasterName(final boolean isOddPage,
- final boolean isFirstPage, final boolean isEmptyPage) {
- if (! this.isDone) {
- this.isDone = true;
- return traitMasterName();
- }
- return null;
- }
-
- public void reset() {
- this.isDone = false;
- }
-
public Namespace getNamespace() {
return this.getFOTreeBuilder().getFONamespace();
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SubSequenceSpecifier.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SubSequenceSpecifier.java 2006-09-03 21:06:28 UTC (rev 7872)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SubSequenceSpecifier.java 2006-09-03 21:21:31 UTC (rev 7873)
@@ -24,8 +24,6 @@
package org.foray.fotree.fo.obj;
-import org.axsl.foR.FOTreeException;
-
import java.util.Set;
/**
@@ -34,20 +32,7 @@
*/
public interface SubSequenceSpecifier {
- String getNextPageMasterName(boolean isOddPage, boolean isFirstPage,
- boolean isEmptyPage) throws FOTreeException;
-
/**
- * Called before a new page sequence is rendered so subsequences can reset
- * any state they keep during the formatting process.
- */
- /* TODO: This method should be removed. Any state information should be
- * tracked by the PageSequenceMaster, with unique values for each
- * PageSequence. At the very least it needs to be renamed to avoid confusion
- * with the method of the same signature in FONode. */
- void reset();
-
- /**
* Returns the page-master instances that are included in this template.
* @return The page-master instances that can be generated from this
* template.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|