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.

AbstractPageNumberCitation.java 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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 java.awt.Color;
  20. import org.xml.sax.Attributes;
  21. import org.xml.sax.Locator;
  22. import org.apache.fop.accessibility.StructureTreeElement;
  23. import org.apache.fop.apps.FOPException;
  24. import org.apache.fop.datatypes.Length;
  25. import org.apache.fop.fo.Constants;
  26. import org.apache.fop.fo.FONode;
  27. import org.apache.fop.fo.FObj;
  28. import org.apache.fop.fo.PropertyList;
  29. import org.apache.fop.fo.ValidationException;
  30. import org.apache.fop.fo.properties.CommonAccessibility;
  31. import org.apache.fop.fo.properties.CommonAccessibilityHolder;
  32. import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
  33. import org.apache.fop.fo.properties.CommonFont;
  34. import org.apache.fop.fo.properties.CommonTextDecoration;
  35. import org.apache.fop.fo.properties.SpaceProperty;
  36. import org.apache.fop.fo.properties.StructureTreeElementHolder;
  37. /**
  38. * Common base class for the <a href="http://www.w3.org/TR/xsl/#fo_page-number-citation">
  39. * <code>fo:page-number-citation</code></a> and
  40. * <a href="http://www.w3.org/TR/xsl/#fo_page-number-citation-last">
  41. * <code>fo:page-number-citation-last</code></a> objects.
  42. */
  43. public abstract class AbstractPageNumberCitation extends FObj
  44. implements StructureTreeElementHolder, CommonAccessibilityHolder {
  45. // The value of properties relevant for fo:page-number-citation(-last).
  46. private CommonAccessibility commonAccessibility;
  47. private CommonBorderPaddingBackground commonBorderPaddingBackground;
  48. private CommonFont commonFont;
  49. private Length alignmentAdjust;
  50. private int alignmentBaseline;
  51. private Length baselineShift;
  52. private int dominantBaseline;
  53. private StructureTreeElement structureTreeElement;
  54. // private ToBeImplementedProperty letterSpacing;
  55. private SpaceProperty lineHeight;
  56. private String refId;
  57. /** Holds the text decoration values. May be null */
  58. private CommonTextDecoration textDecoration;
  59. // private ToBeImplementedProperty textShadow;
  60. // Unused but valid items, commented out for performance:
  61. // private CommonAural commonAural;
  62. // private CommonMarginInline commonMarginInline;
  63. // private CommonRelativePosition commonRelativePosition;
  64. // private KeepProperty keepWithNext;
  65. // private KeepProperty keepWithPrevious;
  66. // private int scoreSpaces;
  67. // private Length textAltitude;
  68. // private Length textDepth;
  69. // private int textTransform;
  70. // private int visibility;
  71. // private SpaceProperty wordSpacing;
  72. // private int wrapOption;
  73. // End of property values
  74. // Properties which are not explicitely listed but are still applicable
  75. private Color color;
  76. /**
  77. * Base constructor
  78. *
  79. * @param parent {@link FONode} that is the parent of this object
  80. */
  81. public AbstractPageNumberCitation(FONode parent) {
  82. super(parent);
  83. }
  84. /** {@inheritDoc} */
  85. public void bind(PropertyList pList) throws FOPException {
  86. super.bind(pList);
  87. commonAccessibility = CommonAccessibility.getInstance(pList);
  88. commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps();
  89. commonFont = pList.getFontProps();
  90. alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength();
  91. alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum();
  92. baselineShift = pList.get(PR_BASELINE_SHIFT).getLength();
  93. dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum();
  94. // letterSpacing = pList.get(PR_LETTER_SPACING);
  95. lineHeight = pList.get(PR_LINE_HEIGHT).getSpace();
  96. refId = pList.get(PR_REF_ID).getString();
  97. textDecoration = pList.getTextDecorationProps();
  98. // textShadow = pList.get(PR_TEXT_SHADOW);
  99. // implicit properties
  100. color = pList.get(Constants.PR_COLOR).getColor(getUserAgent());
  101. }
  102. /** {@inheritDoc} */
  103. public void processNode
  104. (String elementName, Locator locator, Attributes attlist, PropertyList pList)
  105. throws FOPException {
  106. super.processNode(elementName, locator, attlist, pList);
  107. if (!inMarker() && (refId == null || "".equals(refId))) {
  108. missingPropertyError("ref-id");
  109. }
  110. }
  111. /**
  112. * {@inheritDoc}
  113. * <br>XSL Content Model: empty
  114. */
  115. protected void validateChildNode(Locator loc, String nsURI, String localName)
  116. throws ValidationException {
  117. if (FO_URI.equals(nsURI)) {
  118. invalidChildError(loc, nsURI, localName);
  119. }
  120. }
  121. public CommonAccessibility getCommonAccessibility() {
  122. return commonAccessibility;
  123. }
  124. /** @return the {@link CommonFont} */
  125. public CommonFont getCommonFont() {
  126. return commonFont;
  127. }
  128. /** @return the "color" property. */
  129. public Color getColor() {
  130. return color;
  131. }
  132. /** @return the "text-decoration" property. */
  133. public CommonTextDecoration getTextDecoration() {
  134. return textDecoration;
  135. }
  136. @Override
  137. public void setStructureTreeElement(StructureTreeElement structureTreeElement) {
  138. this.structureTreeElement = structureTreeElement;
  139. }
  140. /** {@inheritDoc} */
  141. public StructureTreeElement getStructureTreeElement() {
  142. return structureTreeElement;
  143. }
  144. /** @return the "alignment-adjust" property */
  145. public Length getAlignmentAdjust() {
  146. return alignmentAdjust;
  147. }
  148. /** @return the "alignment-baseline" property */
  149. public int getAlignmentBaseline() {
  150. return alignmentBaseline;
  151. }
  152. /** @return the "baseline-shift" property */
  153. public Length getBaselineShift() {
  154. return baselineShift;
  155. }
  156. /** @return the "dominant-baseline" property */
  157. public int getDominantBaseline() {
  158. return dominantBaseline;
  159. }
  160. /** @return the {@link CommonBorderPaddingBackground} */
  161. public CommonBorderPaddingBackground getCommonBorderPaddingBackground() {
  162. return commonBorderPaddingBackground;
  163. }
  164. /** @return the "line-height" property */
  165. public SpaceProperty getLineHeight() {
  166. return lineHeight;
  167. }
  168. /** @return the "ref-id" property. */
  169. public String getRefId() {
  170. return refId;
  171. }
  172. }