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: PageNumberCitation.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-citation object.
045: * This inline fo is replaced with the text for a page number.
046: * The page number used is the page that contains the start of the
047: * block referenced with the ref-id attribute.
048: */
049: public class PageNumberCitation extends FObj {
050: // The value of properties relevant for fo:page-number-citation.
051: private CommonBorderPaddingBackground commonBorderPaddingBackground;
052: private CommonFont commonFont;
053: private Length alignmentAdjust;
054: private int alignmentBaseline;
055: private Length baselineShift;
056: private int dominantBaseline;
057: // private ToBeImplementedProperty letterSpacing;
058: private SpaceProperty lineHeight;
059: private String refId;
060: /** Holds the text decoration values. May be null */
061: private CommonTextDecoration textDecoration;
062: // private ToBeImplementedProperty textShadow;
063: // Unused but valid items, commented out for performance:
064: // private CommonAccessibility commonAccessibility;
065: // private CommonAural commonAural;
066: // private CommonMarginInline commonMarginInline;
067: // private CommonRelativePosition commonRelativePosition;
068: // private KeepProperty keepWithNext;
069: // private KeepProperty keepWithPrevious;
070: // private int scoreSpaces;
071: // private Length textAltitude;
072: // private Length textDepth;
073: // private int textTransform;
074: // private int visibility;
075: // private SpaceProperty wordSpacing;
076: // private int wrapOption;
077: // End of property values
078:
079: // Properties which are not explicitely listed but are still applicable
080: private Color color;
081:
082: /**
083: * @param parent FONode that is the parent of this object
084: */
085: public PageNumberCitation(FONode parent) {
086: super (parent);
087: }
088:
089: /**
090: * @see org.apache.fop.fo.FObj#bind(PropertyList)
091: */
092: public void bind(PropertyList pList) throws FOPException {
093: super .bind(pList);
094: commonBorderPaddingBackground = pList
095: .getBorderPaddingBackgroundProps();
096: commonFont = pList.getFontProps();
097: alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength();
098: alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum();
099: baselineShift = pList.get(PR_BASELINE_SHIFT).getLength();
100: dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum();
101: // letterSpacing = pList.get(PR_LETTER_SPACING);
102: lineHeight = pList.get(PR_LINE_HEIGHT).getSpace();
103: refId = pList.get(PR_REF_ID).getString();
104: textDecoration = pList.getTextDecorationProps();
105: // textShadow = pList.get(PR_TEXT_SHADOW);
106:
107: // implicit properties
108: color = pList.get(Constants.PR_COLOR).getColor(getUserAgent());
109: }
110:
111: /**
112: * @see org.apache.fop.fo.FONode#startOfNode
113: */
114: protected void startOfNode() throws FOPException {
115: super .startOfNode();
116: if (refId.equals("")) {
117: missingPropertyError("ref-id");
118: }
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 "text-decoration" property. */
141: public CommonTextDecoration getTextDecoration() {
142: return textDecoration;
143: }
144:
145: /**
146: * @return the "alignment-adjust" property
147: */
148: public Length getAlignmentAdjust() {
149: return alignmentAdjust;
150: }
151:
152: /**
153: * @return the "alignment-baseline" property
154: */
155: public int getAlignmentBaseline() {
156: return alignmentBaseline;
157: }
158:
159: /**
160: * @return the "baseline-shift" property
161: */
162: public Length getBaselineShift() {
163: return baselineShift;
164: }
165:
166: /**
167: * @return the "dominant-baseline" property
168: */
169: public int getDominantBaseline() {
170: return dominantBaseline;
171: }
172:
173: /** @return the Common Border, Padding, and Background Properties. */
174: public CommonBorderPaddingBackground getCommonBorderPaddingBackground() {
175: return commonBorderPaddingBackground;
176: }
177:
178: /**
179: * @return the "line-height" property
180: */
181: public SpaceProperty getLineHeight() {
182: return lineHeight;
183: }
184:
185: /** @return the "ref-id" property. */
186: public String getRefId() {
187: return refId;
188: }
189:
190: /** @see org.apache.fop.fo.FONode#getLocalName() */
191: public String getLocalName() {
192: return "page-number-citation";
193: }
194:
195: /** @see org.apache.fop.fo.FObj#getNameId() */
196: public int getNameId() {
197: return FO_PAGE_NUMBER_CITATION;
198: }
199: }
|