001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: /* $Id: PageNumber.java 554094 2007-07-07 00:04:25Z adelmelle $ */
019:
020: package org.apache.fop.fo.flow;
021:
022: import java.awt.Color;
023:
024: import org.xml.sax.Locator;
025:
026: import org.apache.fop.apps.FOPException;
027: import org.apache.fop.datatypes.Length;
028: import org.apache.fop.fo.Constants;
029: import org.apache.fop.fo.FONode;
030: import org.apache.fop.fo.FObj;
031: import org.apache.fop.fo.PropertyList;
032: import org.apache.fop.fo.ValidationException;
033: import org.apache.fop.fo.properties.CommonAccessibility;
034: import org.apache.fop.fo.properties.CommonAural;
035: import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
036: import org.apache.fop.fo.properties.CommonFont;
037: import org.apache.fop.fo.properties.CommonMarginInline;
038: import org.apache.fop.fo.properties.CommonRelativePosition;
039: import org.apache.fop.fo.properties.CommonTextDecoration;
040: import org.apache.fop.fo.properties.KeepProperty;
041: import org.apache.fop.fo.properties.SpaceProperty;
042:
043: /**
044: * Class modelling the fo:page-number object.
045: */
046: public class PageNumber extends FObj {
047: // The value of properties relevant for fo:page-number.
048: private CommonBorderPaddingBackground commonBorderPaddingBackground;
049: private CommonFont commonFont;
050: private Length alignmentAdjust;
051: private int alignmentBaseline;
052: private Length baselineShift;
053: private int dominantBaseline;
054: // private ToBeImplementedProperty letterSpacing;
055: private SpaceProperty lineHeight;
056: /** Holds the text decoration values. May be null */
057: private CommonTextDecoration textDecoration;
058: // private ToBeImplementedProperty textShadow;
059: // Unused but valid items, commented out for performance:
060: // private CommonAccessibility commonAccessibility;
061: // private CommonAural commonAural;
062: // private CommonMarginInline commonMarginInline;
063: // private CommonRelativePosition commonRelativePosition;
064: // private KeepProperty keepWithNext;
065: // private KeepProperty keepWithPrevious;
066: // private int scoreSpaces;
067: // private Length textAltitude;
068: // private Length textDepth;
069: // private int textTransform;
070: // private int visibility;
071: // private SpaceProperty wordSpacing;
072: // private int wrapOption;
073: // End of property values
074:
075: // Properties which are not explicitely listed but are still applicable
076: private Color color;
077:
078: /**
079: * @param parent FONode that is the parent of this object
080: */
081: public PageNumber(FONode parent) {
082: super (parent);
083: }
084:
085: /**
086: * @see org.apache.fop.fo.FObj#bind(PropertyList)
087: */
088: public void bind(PropertyList pList) throws FOPException {
089: super .bind(pList);
090: commonBorderPaddingBackground = pList
091: .getBorderPaddingBackgroundProps();
092: commonFont = pList.getFontProps();
093: alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength();
094: alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum();
095: baselineShift = pList.get(PR_BASELINE_SHIFT).getLength();
096: dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum();
097: // letterSpacing = pList.get(PR_LETTER_SPACING);
098: lineHeight = pList.get(PR_LINE_HEIGHT).getSpace();
099: textDecoration = pList.getTextDecorationProps();
100: // textShadow = pList.get(PR_TEXT_SHADOW);
101:
102: // implicit properties
103: color = pList.get(Constants.PR_COLOR).getColor(getUserAgent());
104: }
105:
106: /**
107: * @see org.apache.fop.fo.FONode#startOfNode
108: */
109: protected void startOfNode() throws FOPException {
110: super .startOfNode();
111: getFOEventHandler().startPageNumber(this );
112: }
113:
114: /**
115: * @see org.apache.fop.fo.FONode#endOfNode
116: */
117: protected void endOfNode() throws FOPException {
118: getFOEventHandler().endPageNumber(this );
119: }
120:
121: /**
122: * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
123: * XSL Content Model: empty
124: */
125: protected void validateChildNode(Locator loc, String nsURI,
126: String localName) throws ValidationException {
127: invalidChildError(loc, nsURI, localName);
128: }
129:
130: /** @return the Common Font Properties. */
131: public CommonFont getCommonFont() {
132: return commonFont;
133: }
134:
135: /** @return the "color" property. */
136: public Color getColor() {
137: return color;
138: }
139:
140: /** @return the Common Border, Padding, and Background Properties. */
141: public CommonBorderPaddingBackground getCommonBorderPaddingBackground() {
142: return commonBorderPaddingBackground;
143: }
144:
145: /** @return the "text-decoration" property. */
146: public CommonTextDecoration getTextDecoration() {
147: return textDecoration;
148: }
149:
150: /**
151: * @return the "alignment-adjust" property
152: */
153: public Length getAlignmentAdjust() {
154: return alignmentAdjust;
155: }
156:
157: /**
158: * @return the "alignment-baseline" property
159: */
160: public int getAlignmentBaseline() {
161: return alignmentBaseline;
162: }
163:
164: /**
165: * @return the "baseline-shift" property
166: */
167: public Length getBaselineShift() {
168: return baselineShift;
169: }
170:
171: /**
172: * @return the "dominant-baseline" property
173: */
174: public int getDominantBaseline() {
175: return dominantBaseline;
176: }
177:
178: /**
179: * @return the "line-height" property
180: */
181: public SpaceProperty getLineHeight() {
182: return lineHeight;
183: }
184:
185: /** @see org.apache.fop.fo.FONode#getLocalName() */
186: public String getLocalName() {
187: return "page-number";
188: }
189:
190: /** @see org.apache.fop.fo.FObj#getNameId() */
191: public int getNameId() {
192: return FO_PAGE_NUMBER;
193: }
194: }
|