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 5.8KB

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