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: InlineContainer.java 554094 2007-07-07 00:04:25Z adelmelle $ */
019:
020: package org.apache.fop.fo.flow;
021:
022: import org.xml.sax.Locator;
023:
024: import org.apache.fop.apps.FOPException;
025: import org.apache.fop.datatypes.Length;
026: import org.apache.fop.datatypes.Numeric;
027: import org.apache.fop.fo.FONode;
028: import org.apache.fop.fo.FObj;
029: import org.apache.fop.fo.PropertyList;
030: import org.apache.fop.fo.ValidationException;
031: import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
032: import org.apache.fop.fo.properties.CommonMarginInline;
033: import org.apache.fop.fo.properties.CommonRelativePosition;
034: import org.apache.fop.fo.properties.KeepProperty;
035: import org.apache.fop.fo.properties.LengthRangeProperty;
036: import org.apache.fop.fo.properties.SpaceProperty;
037:
038: /**
039: * Class modelling the fo:inline-container object.
040: */
041: public class InlineContainer extends FObj {
042:
043: // The value of properties relevant for fo:inline-container.
044: private Length alignmentAdjust;
045: private int alignmentBaseline;
046: private Length baselineShift;
047: // private ToBeImplementedProperty clip;
048: private int dominantBaseline;
049: private SpaceProperty lineHeight;
050: // Unused but valid items, commented out for performance:
051: // private CommonBorderPaddingBackground commonBorderPaddingBackground;
052: // private CommonMarginInline commonMarginInline;
053: // private CommonRelativePosition commonRelativePosition;
054: // private LengthRangeProperty blockProgressionDimension;
055: // private int displayAlign;
056: // private Length height;
057: // private LengthRangeProperty inlineProgressionDimension;
058: // private KeepProperty keepTogether;
059: // private KeepProperty keepWithNext;
060: // private KeepProperty keepWithPrevious;
061: // private int overflow;
062: // private Numeric referenceOrientation;
063: // private Length width;
064: // private int writingMode;
065: // End of property values
066:
067: /** used for FO validation */
068: private boolean blockItemFound = false;
069:
070: /**
071: * @param parent FONode that is the parent of this object
072: */
073: public InlineContainer(FONode parent) {
074: super (parent);
075: }
076:
077: /**
078: * @see org.apache.fop.fo.FObj#bind(PropertyList)
079: */
080: public void bind(PropertyList pList) throws FOPException {
081: super .bind(pList);
082: alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength();
083: alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum();
084: baselineShift = pList.get(PR_BASELINE_SHIFT).getLength();
085: // clip = pList.get(PR_CLIP);
086: dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum();
087: lineHeight = pList.get(PR_LINE_HEIGHT).getSpace();
088: }
089:
090: /**
091: * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
092: * XSL Content Model: marker* (%block;)+
093: */
094: protected void validateChildNode(Locator loc, String nsURI,
095: String localName) throws ValidationException {
096: if (FO_URI.equals(nsURI) && localName.equals("marker")) {
097: if (blockItemFound) {
098: nodesOutOfOrderError(loc, "fo:marker", "(%block;)");
099: }
100: } else if (!isBlockItem(nsURI, localName)) {
101: invalidChildError(loc, nsURI, localName);
102: } else {
103: blockItemFound = true;
104: }
105: }
106:
107: /**
108: * @see org.apache.fop.fo.FONode#endOfNode
109: */
110: protected void endOfNode() throws FOPException {
111: if (!blockItemFound) {
112: missingChildElementError("marker* (%block;)+");
113: }
114: }
115:
116: /**
117: * @return the "alignment-adjust" property
118: */
119: public Length getAlignmentAdjust() {
120: return alignmentAdjust;
121: }
122:
123: /**
124: * @return the "alignment-baseline" property
125: */
126: public int getAlignmentBaseline() {
127: return alignmentBaseline;
128: }
129:
130: /**
131: * @return the "baseline-shift" property
132: */
133: public Length getBaselineShift() {
134: return baselineShift;
135: }
136:
137: /**
138: * @return the "dominant-baseline" property
139: */
140: public int getDominantBaseline() {
141: return dominantBaseline;
142: }
143:
144: /**
145: * @return the "line-height" property.
146: */
147: public SpaceProperty getLineHeight() {
148: return lineHeight;
149: }
150:
151: /** @see org.apache.fop.fo.FONode#getLocalName() */
152: public String getLocalName() {
153: return "inline-container";
154: }
155:
156: /**
157: * @see org.apache.fop.fo.FObj#getNameId()
158: */
159: public int getNameId() {
160: return FO_INLINE_CONTAINER;
161: }
162:
163: }
|