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.

PageNumber.java 5.8KB

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