Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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.datatypes.Numeric;
  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. import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
  28. import org.apache.fop.fo.properties.CommonMarginInline;
  29. import org.apache.fop.fo.properties.KeepProperty;
  30. import org.apache.fop.fo.properties.LengthRangeProperty;
  31. import org.apache.fop.fo.properties.SpaceProperty;
  32. import org.apache.fop.traits.Direction;
  33. import org.apache.fop.traits.WritingMode;
  34. import org.apache.fop.traits.WritingModeTraits;
  35. public class InlineContainer extends FObj {
  36. private LengthRangeProperty inlineProgressionDimension;
  37. private LengthRangeProperty blockProgressionDimension;
  38. private int overflow;
  39. private CommonBorderPaddingBackground commonBorderPaddingBackground;
  40. private CommonMarginInline commonMarginInline;
  41. private Numeric referenceOrientation;
  42. private int displayAlign;
  43. private KeepProperty keepTogether;
  44. private KeepProperty keepWithNext;
  45. private KeepProperty keepWithPrevious;
  46. private SpaceProperty lineHeight;
  47. private Length alignmentAdjust;
  48. private int alignmentBaseline;
  49. private Length baselineShift;
  50. private int dominantBaseline;
  51. private WritingModeTraits writingModeTraits;
  52. /** used for FO validation */
  53. private boolean blockItemFound;
  54. /**
  55. * Creates a new instance.
  56. *
  57. * @param parent the parent of this inline-container
  58. */
  59. public InlineContainer(FONode parent) {
  60. super(parent);
  61. }
  62. @Override
  63. public void bind(PropertyList pList) throws FOPException {
  64. super.bind(pList);
  65. alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength();
  66. alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum();
  67. baselineShift = pList.get(PR_BASELINE_SHIFT).getLength();
  68. blockProgressionDimension = pList.get(PR_BLOCK_PROGRESSION_DIMENSION).getLengthRange();
  69. commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps();
  70. commonMarginInline = pList.getMarginInlineProps();
  71. displayAlign = pList.get(PR_DISPLAY_ALIGN).getEnum();
  72. dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum();
  73. inlineProgressionDimension = pList.get(PR_INLINE_PROGRESSION_DIMENSION).getLengthRange();
  74. keepTogether = pList.get(PR_KEEP_TOGETHER).getKeep();
  75. keepWithNext = pList.get(PR_KEEP_WITH_NEXT).getKeep();
  76. keepWithPrevious = pList.get(PR_KEEP_WITH_PREVIOUS).getKeep();
  77. lineHeight = pList.get(PR_LINE_HEIGHT).getSpace();
  78. overflow = pList.get(PR_OVERFLOW).getEnum();
  79. referenceOrientation = pList.get(PR_REFERENCE_ORIENTATION).getNumeric();
  80. writingModeTraits = new WritingModeTraits(
  81. WritingMode.valueOf(pList.get(PR_WRITING_MODE).getEnum()),
  82. pList.getExplicit(PR_WRITING_MODE) != null);
  83. }
  84. /**
  85. * {@inheritDoc}
  86. * <br>XSL Content Model: marker* (%block;)+
  87. */
  88. @Override
  89. protected void validateChildNode(Locator loc, String nsURI, String localName)
  90. throws ValidationException {
  91. if (FO_URI.equals(nsURI)) {
  92. if (localName.equals("marker")) {
  93. if (blockItemFound) {
  94. nodesOutOfOrderError(loc, "fo:marker", "(%block;)+");
  95. }
  96. } else if (!isBlockItem(nsURI, localName)) {
  97. invalidChildError(loc, nsURI, localName);
  98. } else {
  99. blockItemFound = true;
  100. }
  101. }
  102. }
  103. @Override
  104. public void endOfNode() throws FOPException {
  105. if (!blockItemFound) {
  106. missingChildElementError("marker* (%block;)+");
  107. }
  108. }
  109. /** {@inheritDoc} */
  110. public String getLocalName() {
  111. return "inline-container";
  112. }
  113. /**
  114. * {@inheritDoc}
  115. * @return {@link org.apache.fop.fo.Constants#FO_INLINE_CONTAINER}
  116. */
  117. public int getNameId() {
  118. return FO_INLINE_CONTAINER;
  119. }
  120. public LengthRangeProperty getInlineProgressionDimension() {
  121. return inlineProgressionDimension;
  122. }
  123. public LengthRangeProperty getBlockProgressionDimension() {
  124. return blockProgressionDimension;
  125. }
  126. public int getOverflow() {
  127. return overflow;
  128. }
  129. public CommonBorderPaddingBackground getCommonBorderPaddingBackground() {
  130. return this.commonBorderPaddingBackground;
  131. }
  132. public CommonMarginInline getCommonMarginInline() {
  133. return this.commonMarginInline;
  134. }
  135. public int getReferenceOrientation() {
  136. return referenceOrientation.getValue();
  137. }
  138. public int getDisplayAlign() {
  139. return this.displayAlign;
  140. }
  141. public KeepProperty getKeepWithPrevious() {
  142. return keepWithPrevious;
  143. }
  144. public KeepProperty getKeepTogether() {
  145. return keepTogether;
  146. }
  147. public KeepProperty getKeepWithNext() {
  148. return keepWithNext;
  149. }
  150. public SpaceProperty getLineHeight() {
  151. return lineHeight;
  152. }
  153. public Length getAlignmentAdjust() {
  154. return alignmentAdjust;
  155. }
  156. public int getAlignmentBaseline() {
  157. return alignmentBaseline;
  158. }
  159. public Length getBaselineShift() {
  160. return baselineShift;
  161. }
  162. public int getDominantBaseline() {
  163. return dominantBaseline;
  164. }
  165. public WritingMode getWritingMode() {
  166. return writingModeTraits.getWritingMode();
  167. }
  168. /**
  169. * Obtain writing mode explicit indicator.
  170. * @return the writing mode explicit indicator
  171. */
  172. public boolean getExplicitWritingMode() {
  173. return writingModeTraits.getExplicitWritingMode();
  174. }
  175. public Direction getInlineProgressionDirection() {
  176. return writingModeTraits.getInlineProgressionDirection();
  177. }
  178. public Direction getBlockProgressionDirection() {
  179. return writingModeTraits.getBlockProgressionDirection();
  180. }
  181. public Direction getColumnProgressionDirection() {
  182. return writingModeTraits.getColumnProgressionDirection();
  183. }
  184. public Direction getRowProgressionDirection() {
  185. return writingModeTraits.getRowProgressionDirection();
  186. }
  187. public Direction getShiftDirection() {
  188. return writingModeTraits.getShiftDirection();
  189. }
  190. @Override
  191. public boolean isDelimitedTextRangeBoundary(int boundary) {
  192. return false;
  193. }
  194. @Override
  195. public boolean generatesReferenceAreas() {
  196. return true;
  197. }
  198. @Override
  199. protected boolean isBidiBoundary(boolean propagate) {
  200. return getExplicitWritingMode();
  201. }
  202. }