You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SinglePageMasterReference.java 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * $Id$
  3. * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
  4. * For details on use and redistribution please refer to the
  5. * LICENSE file included with these sources.
  6. */
  7. package org.apache.fop.fo.pagination;
  8. import org.apache.fop.fo.*;
  9. import org.apache.fop.apps.FOPException;
  10. /**
  11. * Class modeling the fo:single-page-master-reference object.
  12. *
  13. * @see <a href="@XSLFO-STD@#fo_single-page-master-reference"
  14. target="_xslfostd">@XSLFO-STDID@
  15. * &para;6.4.8</a>
  16. */
  17. public class SinglePageMasterReference extends PageMasterReference {
  18. public static class Maker extends FObj.Maker {
  19. public FObj make(FObj parent,
  20. PropertyList propertyList) throws FOPException {
  21. return new SinglePageMasterReference(parent, propertyList);
  22. }
  23. }
  24. public static FObj.Maker maker() {
  25. return new SinglePageMasterReference.Maker();
  26. }
  27. private static final int FIRST = 0;
  28. private static final int DONE = 1;
  29. private int state;
  30. public SinglePageMasterReference(FObj parent, PropertyList propertyList)
  31. throws FOPException {
  32. super(parent, propertyList);
  33. if (getProperty("master-reference") != null) {
  34. this.masterName = getProperty("master-reference").getString();
  35. if (parent.getName().equals("fo:page-sequence-master")) {
  36. PageSequenceMaster pageSequenceMaster = (PageSequenceMaster)parent;
  37. pageSequenceMaster.addSubsequenceSpecifier(this);
  38. } else {
  39. throw new FOPException("A fo:single-page-master-reference must be child of fo:page-sequence-master, not "
  40. + parent.getName());
  41. }
  42. } else {
  43. log.warn("A fo:single-page-master-reference does not have a master-reference and so is being ignored");
  44. }
  45. this.state = FIRST;
  46. }
  47. public String getName() {
  48. return "fo:single-page-master-reference";
  49. }
  50. public String getNextPageMasterName(boolean isOddPage,
  51. boolean isFirstPage,
  52. boolean isEmptyPage) {
  53. if (this.state == FIRST) {
  54. this.state = DONE;
  55. return getMasterName();
  56. } else {
  57. return null;
  58. }
  59. }
  60. public void reset() {
  61. this.state = FIRST;
  62. }
  63. }