aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java')
-rw-r--r--src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java106
1 files changed, 39 insertions, 67 deletions
diff --git a/src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java b/src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java
index dcaf01180..a85ddd43a 100644
--- a/src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java
+++ b/src/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java
@@ -43,9 +43,9 @@ public class ConditionalPageMasterReference extends FObj {
validateParent(parent);
- setPagePosition(this.properties.get("page-position").getEnum());
- setOddOrEven(this.properties.get("odd-or-even").getEnum());
- setBlankOrNotBlank(this.properties.get("blank-or-not-blank").getEnum());
+ this.pagePosition = this.properties.get("page-position").getEnum();
+ this.oddOrEven = this.properties.get("odd-or-even").getEnum();
+ this.blankOrNotBlank = this.properties.get("blank-or-not-blank").getEnum();
}
protected void setMasterName(String masterName) {
@@ -64,77 +64,49 @@ public class ConditionalPageMasterReference extends FObj {
* checks the page number and emptyness to determine if this
* matches.
*/
- protected boolean isValid(int currentPageNumber, boolean thisIsFirstPage,
+ protected boolean isValid(boolean isOddPage, boolean isFirstPage,
boolean isEmptyPage) {
// page-position
- boolean okOnPagePosition = true; // default is 'any'
- switch (getPagePosition()) {
- case PagePosition.FIRST:
- if (!thisIsFirstPage)
- okOnPagePosition = false;
- break;
- case PagePosition.LAST:
- // how the hell do you know at this point?
- getLogger().warn("LAST PagePosition NYI");
- okOnPagePosition = true;
- break;
- case PagePosition.REST:
- if (thisIsFirstPage)
- okOnPagePosition = false;
- break;
- case PagePosition.ANY:
- okOnPagePosition = true;
+ if( isFirstPage ) {
+ if (pagePosition==PagePosition.REST) {
+ return false;
+ } else if (pagePosition==PagePosition.LAST) {
+ // how the hell do you know at this point?
+ getLogger().debug("LAST PagePosition NYI");
+ return false;
+ }
+ } else {
+ if (pagePosition==PagePosition.FIRST) {
+ return false;
+ } else if (pagePosition==PagePosition.LAST) {
+ // how the hell do you know at this point?
+ getLogger().debug("LAST PagePosition NYI");
+ // potentially valid, don't return
+ }
}
- // odd or even
- boolean okOnOddOrEven = true; // default is 'any'
- int ooe = getOddOrEven();
- boolean isOddPage = ((currentPageNumber % 2) == 1) ? true : false;
- if ((OddOrEven.ODD == ooe) &&!isOddPage) {
- okOnOddOrEven = false;
- }
- if ((OddOrEven.EVEN == ooe) && isOddPage) {
- okOnOddOrEven = false;
+ // odd-or-even
+ if (isOddPage) {
+ if (oddOrEven==OddOrEven.EVEN) {
+ return false;
+ }
+ } else {
+ if (oddOrEven==OddOrEven.ODD) {
+ return false;
+ }
}
- // experimental check for blank-or-not-blank
-
- boolean okOnBlankOrNotBlank = true; // default is 'any'
-
- int bnb = getBlankOrNotBlank();
-
- if ((BlankOrNotBlank.BLANK == bnb) &&!isEmptyPage) {
- okOnBlankOrNotBlank = false;
- } else if ((BlankOrNotBlank.NOT_BLANK == bnb) && isEmptyPage) {
- okOnBlankOrNotBlank = false;
+ // blank-or-not-blank
+ if (isEmptyPage) {
+ if (blankOrNotBlank==BlankOrNotBlank.NOT_BLANK) {
+ return false;
+ }
+ } else {
+ if (blankOrNotBlank==BlankOrNotBlank.BLANK) {
+ return false;
+ }
}
-
- return (okOnOddOrEven && okOnPagePosition && okOnBlankOrNotBlank);
-
- }
-
- protected void setPagePosition(int pagePosition) {
- this.pagePosition = pagePosition;
- }
-
- protected int getPagePosition() {
- return this.pagePosition;
- }
-
- protected void setOddOrEven(int oddOrEven) {
- this.oddOrEven = oddOrEven;
- }
-
- protected int getOddOrEven() {
- return this.oddOrEven;
- }
-
- protected void setBlankOrNotBlank(int blankOrNotBlank) {
- this.blankOrNotBlank = blankOrNotBlank;
- }
-
- protected int getBlankOrNotBlank() {
- return this.blankOrNotBlank;
+ return true;
}
/**