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.

RetrieveMarker.java 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.fo.flow;
  19. import org.xml.sax.Attributes;
  20. import org.xml.sax.Locator;
  21. import org.apache.fop.apps.FOPException;
  22. import org.apache.fop.fo.FONode;
  23. import org.apache.fop.fo.PropertyList;
  24. /**
  25. * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_retrieve-marker">
  26. * <code>fo:retrieve-marker</code></a> formatting object.
  27. * This will create a layout manager that will retrieve
  28. * a marker based on the information.
  29. */
  30. public class RetrieveMarker extends AbstractRetrieveMarker {
  31. /**
  32. * Create a new RetrieveMarker instance that is a
  33. * child of the given {@link FONode}.
  34. *
  35. * @param parent the parent {@link FONode}
  36. */
  37. public RetrieveMarker(FONode parent) {
  38. super(parent);
  39. }
  40. /**
  41. * {@inheritDoc}
  42. * <i>NOTE: An <code>fo:retrieve-marker</code> is only permitted as a descendant
  43. * of an <code>fo:static-content</code>.</i>
  44. */
  45. public void processNode(String elementName,
  46. Locator locator,
  47. Attributes attlist,
  48. PropertyList pList)
  49. throws FOPException {
  50. if (findAncestor(FO_STATIC_CONTENT) < 0) {
  51. invalidChildError(locator, getParent().getName(), FO_URI, getLocalName(),
  52. "rule.retrieveMarkerDescendantOfStaticContent");
  53. } else {
  54. super.processNode(elementName, locator, attlist, pList);
  55. }
  56. }
  57. /** {@inheritDoc} */
  58. public void bind(PropertyList pList) throws FOPException {
  59. super.bind(pList);
  60. setPosition(pList.get(PR_RETRIEVE_POSITION).getEnum());
  61. setPositionLabel((String) pList.get(PR_RETRIEVE_POSITION).getObject());
  62. setBoundary(pList.get(PR_RETRIEVE_BOUNDARY).getEnum());
  63. setBoundaryLabel((String) pList.get(PR_RETRIEVE_BOUNDARY).getObject());
  64. }
  65. @Override
  66. public void startOfNode() throws FOPException {
  67. super.startOfNode();
  68. getFOEventHandler().startRetrieveMarker(this);
  69. }
  70. @Override
  71. public void endOfNode() throws FOPException {
  72. super.endOfNode();
  73. getFOEventHandler().endRetrieveMarker(this);
  74. }
  75. /**
  76. * Return the value for the <code>retrieve-position</code>
  77. * property
  78. * @return the value for retrieve-position-within-table; one of
  79. * {@link org.apache.fop.fo.Constants#EN_FSWP},
  80. * {@link org.apache.fop.fo.Constants#EN_FIC},
  81. * {@link org.apache.fop.fo.Constants#EN_LSWP},
  82. * {@link org.apache.fop.fo.Constants#EN_LEWP}.
  83. */
  84. public int getRetrievePosition() {
  85. return getPosition();
  86. }
  87. /**
  88. * Return the value for the <code>retrieve-boundary</code>
  89. * property
  90. * @return the value for retrieve-boundary; one of
  91. * {@link org.apache.fop.fo.Constants#EN_PAGE},
  92. * {@link org.apache.fop.fo.Constants#EN_PAGE_SEQUENCE},
  93. * {@link org.apache.fop.fo.Constants#EN_DOCUMENT}.
  94. */
  95. public int getRetrieveBoundary() {
  96. return getBoundary();
  97. }
  98. /** {@inheritDoc} */
  99. public String getLocalName() {
  100. return "retrieve-marker";
  101. }
  102. /**
  103. * {@inheritDoc}
  104. * @return {@link org.apache.fop.fo.Constants#FO_RETRIEVE_MARKER}
  105. */
  106. public int getNameId() {
  107. return FO_RETRIEVE_MARKER;
  108. }
  109. @Override
  110. protected void restoreFOEventHandlerState() {
  111. getFOEventHandler().restoreState(this);
  112. }
  113. }