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.

Float.java 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. // XML
  20. import org.xml.sax.Attributes;
  21. import org.xml.sax.Locator;
  22. import org.apache.fop.apps.FOPException;
  23. import org.apache.fop.fo.FONode;
  24. import org.apache.fop.fo.FObj;
  25. import org.apache.fop.fo.PropertyList;
  26. import org.apache.fop.fo.ValidationException;
  27. /**
  28. * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_float">
  29. * <code>fo:float</code></a> object.
  30. */
  31. public class Float extends FObj {
  32. // The value of properties relevant for fo:float (commented out for performance.
  33. private int foFloat;
  34. private int clear;
  35. // End of property values
  36. private boolean inWhiteSpace;
  37. private boolean disabled;
  38. /**
  39. * Base constructor
  40. *
  41. * @param parent the parent {@link FONode}
  42. */
  43. public Float(FONode parent) {
  44. super(parent);
  45. }
  46. /** {@inheritDoc} */
  47. public void bind(PropertyList pList) throws FOPException {
  48. super.bind(pList);
  49. foFloat = pList.get(PR_FLOAT).getEnum();
  50. clear = pList.get(PR_CLEAR).getEnum();
  51. }
  52. /**
  53. * {@inheritDoc}
  54. * <br>XSL Content Model: (%block;)+
  55. */
  56. protected void validateChildNode(Locator loc, String nsURI, String localName)
  57. throws ValidationException {
  58. if (FO_URI.equals(nsURI)) {
  59. if (!isBlockItem(nsURI, localName)) {
  60. invalidChildError(loc, nsURI, localName);
  61. }
  62. }
  63. }
  64. /** {@inheritDoc} */
  65. public void endOfNode() throws FOPException {
  66. if (firstChild == null) {
  67. missingChildElementError("(%block;)+");
  68. }
  69. }
  70. /** {@inheritDoc} */
  71. public String getLocalName() {
  72. return "float";
  73. }
  74. /**
  75. * {@inheritDoc}
  76. * @return {@link org.apache.fop.fo.Constants#FO_FLOAT}
  77. */
  78. public int getNameId() {
  79. return FO_FLOAT;
  80. }
  81. public int getFloat() {
  82. return foFloat;
  83. }
  84. public void setInWhiteSpace(boolean iws) {
  85. inWhiteSpace = iws;
  86. }
  87. public boolean getInWhiteSpace() {
  88. return inWhiteSpace;
  89. }
  90. public void processNode(String elementName, Locator locator, Attributes attlist, PropertyList pList)
  91. throws FOPException {
  92. if (findAncestor(FO_TABLE) > 0) {
  93. disabled = true;
  94. getFOValidationEventProducer().unimplementedFeature(this, "fo:table", getName(), getLocator());
  95. } else {
  96. super.processNode(elementName, locator, attlist, pList);
  97. }
  98. }
  99. public boolean isDisabled() {
  100. return disabled;
  101. }
  102. }