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.

AbstractListItemPart.java 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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.Locator;
  20. import org.apache.fop.apps.FOPException;
  21. import org.apache.fop.fo.FONode;
  22. import org.apache.fop.fo.FObj;
  23. import org.apache.fop.fo.PropertyList;
  24. import org.apache.fop.fo.ValidationException;
  25. import org.apache.fop.fo.properties.CommonAccessibility;
  26. import org.apache.fop.fo.properties.CommonAccessibilityHolder;
  27. import org.apache.fop.fo.properties.KeepProperty;
  28. /**
  29. * Common superclass for <a href="http://www.w3.org/TR/xsl/#fo_list-item-label">
  30. * <code>fo:list-item-label</code></a> and <a href="http://www.w3.org/TR/xsl/#fo_list-item-body">
  31. * <code>fo:list-item-body</code></a>.
  32. */
  33. public abstract class AbstractListItemPart extends FObj implements CommonAccessibilityHolder {
  34. private CommonAccessibility commonAccessibility;
  35. private KeepProperty keepTogether;
  36. // Valid properties, commented out for performance:
  37. // private CommonAccessibility commonAccessibility;
  38. // End of property values
  39. /** used for FO validation */
  40. private boolean blockItemFound;
  41. /**
  42. * Base constructor
  43. *
  44. * @param parent {@link FONode} that is the parent of this object
  45. */
  46. public AbstractListItemPart(FONode parent) {
  47. super(parent);
  48. }
  49. /** {@inheritDoc} */
  50. public void bind(PropertyList pList) throws FOPException {
  51. super.bind(pList);
  52. commonAccessibility = CommonAccessibility.getInstance(pList);
  53. keepTogether = pList.get(PR_KEEP_TOGETHER).getKeep();
  54. }
  55. /**
  56. * {@inheritDoc}
  57. * <br>XSL Content Model: marker* (%block;)+
  58. */
  59. protected void validateChildNode(Locator loc, String nsURI, String localName)
  60. throws ValidationException {
  61. if (FO_URI.equals(nsURI)) {
  62. if (localName.equals("marker")) {
  63. if (blockItemFound) {
  64. nodesOutOfOrderError(loc, "fo:marker", "(%block;)");
  65. }
  66. } else if (!isBlockItem(nsURI, localName)) {
  67. invalidChildError(loc, nsURI, localName);
  68. } else {
  69. blockItemFound = true;
  70. }
  71. }
  72. }
  73. /** {@inheritDoc} */
  74. public void endOfNode() throws FOPException {
  75. if (!this.blockItemFound) {
  76. String contentModel = "marker* (%block;)+";
  77. getFOValidationEventProducer().missingChildElement(this, getName(),
  78. contentModel, true, getLocator());
  79. }
  80. }
  81. /** {@inheritDoc} */
  82. public CommonAccessibility getCommonAccessibility() {
  83. return commonAccessibility;
  84. }
  85. /** @return the "keep-together" property. */
  86. public KeepProperty getKeepTogether() {
  87. return keepTogether;
  88. }
  89. }