Revision: 7877
http://svn.sourceforge.net/foray/?rev=7877&view=rev
Author: victormote
Date: 2006-09-03 16:26:25 -0700 (Sun, 03 Sep 2006)
Log Message:
-----------
Extract methods to clean up doc on page selection.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/ConditionalPageMasterReference.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageMasterResolver.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/ConditionalPageMasterReference.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/ConditionalPageMasterReference.java 2006-09-03 22:26:23 UTC (rev 7876)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/ConditionalPageMasterReference.java 2006-09-03 23:26:25 UTC (rev 7877)
@@ -109,30 +109,68 @@
return (RepeatablePMAlternatives) this.parentFO();
}
- protected boolean isValid(final boolean isOddPage,
- final boolean isFirstPage, final boolean isEmptyPage) {
+ /**
+ * Indicates whether this instance matches a specific set of constraints.
+ * @param isOddPage True if the
+ * @param isFirstPage Set to true to return a true value if this instance's
+ * page-position is "first".
+ * @param isEmptyPage
+ * @return True iff this instance matches the "position" criteria.
+ * Note that if both <tt>isFirstPage</tt> and <tt>isLasttPage</tt> are
+ * specified, this instance's ability to satisfy <em>either</em> of the
+ * criteria allows it to return true.
+ * @see "XSL-FO Standard 1.0, Section 6.4.11."
+ */
+ protected boolean matchesCriteria(final boolean isFirstPage,
+ final boolean isLastPage, final boolean isOddPage,
+ final boolean isEmptyPage) {
+ if (! matchesPositionCriteria(isFirstPage, isLastPage)) {
+ return false;
+ }
+ if (! matchesParityCriteria(isOddPage)) {
+ return false;
+ }
+ if (! matchesContentCriteria(isEmptyPage)) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Indicates whether this instance matches the "position" criteria.
+ * @param isFirstPage Set to true to return a true value if this instance's
+ * page-position is "first".
+ * @param isLastPage Set to true to return a true value if this instance's
+ * page-position is "last".
+ * @return True iff this instance matches the "position" criteria.
+ * Note that if both <tt>isFirstPage</tt> and <tt>isLasttPage</tt> are
+ * specified, this instance's ability to satisfy <em>either</em> of the
+ * criteria allows it to return true.
+ * @see "XSL-FO Standard 1.0, Section 6.4.11."
+ */
+ public boolean matchesPositionCriteria(final boolean isFirstPage,
+ final boolean isLastPage) {
final int pagePosition = traitPagePosition();
- if (isFirstPage) {
- if (pagePosition == Constants.FOVAL_REST) {
- return false;
- } else if (pagePosition == Constants.FOVAL_LAST) {
- // how the hell do you know at this point?
- logWarning(getFullName() + ": "
- + "page-position='last' is not yet implemented (NYI)");
- return false;
- }
- } else {
- if (pagePosition == Constants.FOVAL_FIRST) {
- return false;
- } else if (pagePosition == Constants.FOVAL_LAST) {
- // how the hell do you know at this point?
- logWarning(getFullName() + ": "
- + "page-position='last' is not yet implemented (NYI)");
- // potentially valid, don't return
- }
+ if (pagePosition == Constants.FOVAL_ANY) {
+ return true;
}
+ if (pagePosition == Constants.FOVAL_FIRST
+ && isFirstPage) {
+ return true;
+ }
+ if (pagePosition == Constants.FOVAL_LAST
+ && isLastPage) {
+ return true;
+ }
+ if (pagePosition == Constants.FOVAL_REST
+ && !isFirstPage
+ && !isLastPage) {
+ return true;
+ }
+ return false;
+ }
- // odd-or-even
+ public boolean matchesParityCriteria(final boolean isOddPage) {
if (isOddPage) {
if (traitOddOrEven() == Constants.FOVAL_EVEN) {
return false;
@@ -142,8 +180,10 @@
return false;
}
}
+ return true;
+ }
- // blank-or-not-blank
+ public boolean matchesContentCriteria(final boolean isEmptyPage) {
if (isEmptyPage) {
if (traitBlankOrNotBlank() == Constants.FOVAL_NOT_BLANK) {
return false;
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 22:26:23 UTC (rev 7876)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageMasterResolver.java 2006-09-03 23:26:25 UTC (rev 7877)
@@ -237,7 +237,8 @@
for (int i = 0; i < wrapped.getChildCount(); i++) {
final ConditionalPageMasterReference cpmr =
(ConditionalPageMasterReference) wrapped.getChildAt(i);
- if (cpmr.isValid(isOddPage, isFirstPage, isEmptyPage)) {
+ if (cpmr.matchesCriteria(isFirstPage, false, isOddPage,
+ isEmptyPage)) {
return cpmr.traitMasterReference();
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|