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.

InlineContainer.java 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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.datatypes.Length;
  22. import org.apache.fop.fo.FONode;
  23. import org.apache.fop.fo.FObj;
  24. import org.apache.fop.fo.PropertyList;
  25. import org.apache.fop.fo.ValidationException;
  26. import org.apache.fop.fo.properties.SpaceProperty;
  27. /**
  28. * Class modelling the fo:inline-container object.
  29. */
  30. public class InlineContainer extends FObj {
  31. // The value of properties relevant for fo:inline-container.
  32. private Length alignmentAdjust;
  33. private int alignmentBaseline;
  34. private Length baselineShift;
  35. // private ToBeImplementedProperty clip;
  36. private int dominantBaseline;
  37. private SpaceProperty lineHeight;
  38. // Unused but valid items, commented out for performance:
  39. // private CommonBorderPaddingBackground commonBorderPaddingBackground;
  40. // private CommonMarginInline commonMarginInline;
  41. // private CommonRelativePosition commonRelativePosition;
  42. // private LengthRangeProperty blockProgressionDimension;
  43. // private int displayAlign;
  44. // private Length height;
  45. // private LengthRangeProperty inlineProgressionDimension;
  46. // private KeepProperty keepTogether;
  47. // private KeepProperty keepWithNext;
  48. // private KeepProperty keepWithPrevious;
  49. // private int overflow;
  50. // private Numeric referenceOrientation;
  51. // private Length width;
  52. // private int writingMode;
  53. // End of property values
  54. /** used for FO validation */
  55. private boolean blockItemFound = false;
  56. /**
  57. * @param parent FONode that is the parent of this object
  58. */
  59. public InlineContainer(FONode parent) {
  60. super(parent);
  61. }
  62. /**
  63. * {@inheritDoc}
  64. */
  65. public void bind(PropertyList pList) throws FOPException {
  66. super.bind(pList);
  67. alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength();
  68. alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum();
  69. baselineShift = pList.get(PR_BASELINE_SHIFT).getLength();
  70. // clip = pList.get(PR_CLIP);
  71. dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum();
  72. lineHeight = pList.get(PR_LINE_HEIGHT).getSpace();
  73. }
  74. /**
  75. * {@inheritDoc}
  76. * XSL Content Model: marker* (%block;)+
  77. */
  78. protected void validateChildNode(Locator loc, String nsURI, String localName)
  79. throws ValidationException {
  80. if (FO_URI.equals(nsURI)) {
  81. if (localName.equals("marker")) {
  82. if (blockItemFound) {
  83. nodesOutOfOrderError(loc, "fo:marker", "(%block;)");
  84. }
  85. } else if (!isBlockItem(nsURI, localName)) {
  86. invalidChildError(loc, nsURI, localName);
  87. } else {
  88. blockItemFound = true;
  89. }
  90. }
  91. }
  92. /**
  93. * {@inheritDoc}
  94. */
  95. protected void endOfNode() throws FOPException {
  96. if (!blockItemFound) {
  97. missingChildElementError("marker* (%block;)+");
  98. }
  99. }
  100. /**
  101. * @return the "alignment-adjust" property
  102. */
  103. public Length getAlignmentAdjust() {
  104. return alignmentAdjust;
  105. }
  106. /**
  107. * @return the "alignment-baseline" property
  108. */
  109. public int getAlignmentBaseline() {
  110. return alignmentBaseline;
  111. }
  112. /**
  113. * @return the "baseline-shift" property
  114. */
  115. public Length getBaselineShift() {
  116. return baselineShift;
  117. }
  118. /**
  119. * @return the "dominant-baseline" property
  120. */
  121. public int getDominantBaseline() {
  122. return dominantBaseline;
  123. }
  124. /**
  125. * @return the "line-height" property.
  126. */
  127. public SpaceProperty getLineHeight() {
  128. return lineHeight;
  129. }
  130. /** {@inheritDoc} */
  131. public String getLocalName() {
  132. return "inline-container";
  133. }
  134. /**
  135. * {@inheritDoc}
  136. */
  137. public int getNameId() {
  138. return FO_INLINE_CONTAINER;
  139. }
  140. }