1 51 package org.apache.fop.fo.pagination; 52 53 import org.apache.fop.fo.*; 54 import org.apache.fop.apps.FOPException; 55 56 63 public class SinglePageMasterReference extends PageMasterReference { 64 65 public static class Maker extends FObj.Maker { 66 public FObj make(FObj parent, PropertyList propertyList, 67 String systemId, int line, int column) 68 throws FOPException { 69 return new SinglePageMasterReference(parent, propertyList, 70 systemId, line, column); 71 } 72 73 } 74 75 public static FObj.Maker maker() { 76 return new SinglePageMasterReference.Maker(); 77 } 78 79 private static final int FIRST = 0; 80 private static final int DONE = 1; 81 82 private int state; 83 84 public SinglePageMasterReference(FObj parent, PropertyList propertyList, 85 String systemId, int line, int column) 86 throws FOPException { 87 super(parent, propertyList, systemId, line, column); 88 if (getProperty("master-reference") != null) { 89 this.masterName = getProperty("master-reference").getString(); 90 if (parent.getName().equals("fo:page-sequence-master")) { 91 PageSequenceMaster pageSequenceMaster = (PageSequenceMaster)parent; 92 pageSequenceMaster.addSubsequenceSpecifier(this); 93 } else { 94 throw new FOPException("A fo:single-page-master-reference must be child of fo:page-sequence-master, not " 95 + parent.getName(), systemId, line, column); 96 } 97 } else { 98 log.warn("A fo:single-page-master-reference does not have a master-reference and so is being ignored"); 99 } 100 this.state = FIRST; 101 } 102 103 public String getName() { 104 return "fo:single-page-master-reference"; 105 } 106 107 public String getNextPageMasterName(boolean isOddPage, 108 boolean isFirstPage, 109 boolean isEmptyPage) { 110 if (this.state == FIRST) { 111 this.state = DONE; 112 return getMasterName(); 113 } else { 114 return null; 115 } 116 117 } 118 119 public void reset() { 120 this.state = FIRST; 121 } 122 123 } 124 | Popular Tags |