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: ListBlock.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.fo.FONode;
027: import org.apache.fop.fo.FObj;
028: import org.apache.fop.fo.PropertyList;
029: import org.apache.fop.fo.ValidationException;
030: import org.apache.fop.fo.properties.CommonAccessibility;
031: import org.apache.fop.fo.properties.CommonAural;
032: import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
033: import org.apache.fop.fo.properties.CommonMarginBlock;
034: import org.apache.fop.fo.properties.CommonRelativePosition;
035: import org.apache.fop.fo.properties.KeepProperty;
036:
037: /**
038: * Class modelling the fo:list-block object.
039: */
040: public class ListBlock extends FObj {
041: // The value of properties relevant for fo:list-block.
042: private CommonBorderPaddingBackground commonBorderPaddingBackground;
043: private CommonMarginBlock commonMarginBlock;
044: private int breakAfter;
045: private int breakBefore;
046: private KeepProperty keepTogether;
047: private KeepProperty keepWithNext;
048: private KeepProperty keepWithPrevious;
049: // Unused but valid items, commented out for performance:
050: // private CommonAccessibility commonAccessibility;
051: // private CommonAural commonAural;
052: // private CommonRelativePosition commonRelativePosition;
053: // private int intrusionDisplace;
054: // private Length provisionalDistanceBetweenStarts;
055: // private Length provisionalLabelSeparation;
056: // End of property values
057:
058: /** extension properties */
059: private Length widowContentLimit;
060: private Length orphanContentLimit;
061:
062: // used for child node validation
063: private boolean hasListItem = false;
064:
065: /**
066: * @param parent FONode that is the parent of this object
067: */
068: public ListBlock(FONode parent) {
069: super (parent);
070: }
071:
072: /**
073: * @see org.apache.fop.fo.FObj#bind(PropertyList)
074: */
075: public void bind(PropertyList pList) throws FOPException {
076: super .bind(pList);
077: commonBorderPaddingBackground = pList
078: .getBorderPaddingBackgroundProps();
079: commonMarginBlock = pList.getMarginBlockProps();
080: breakAfter = pList.get(PR_BREAK_AFTER).getEnum();
081: breakBefore = pList.get(PR_BREAK_BEFORE).getEnum();
082: keepTogether = pList.get(PR_KEEP_TOGETHER).getKeep();
083: keepWithNext = pList.get(PR_KEEP_WITH_NEXT).getKeep();
084: keepWithPrevious = pList.get(PR_KEEP_WITH_PREVIOUS).getKeep();
085: //Bind extension properties
086: widowContentLimit = pList.get(PR_X_WIDOW_CONTENT_LIMIT)
087: .getLength();
088: orphanContentLimit = pList.get(PR_X_ORPHAN_CONTENT_LIMIT)
089: .getLength();
090: }
091:
092: /**
093: * @see org.apache.fop.fo.FONode#startOfNode
094: */
095: protected void startOfNode() throws FOPException {
096: super .startOfNode();
097: getFOEventHandler().startList(this );
098: }
099:
100: /**
101: * Make sure content model satisfied, if so then tell the
102: * FOEventHandler that we are at the end of the flow.
103: * @see org.apache.fop.fo.FONode#endOfNode
104: */
105: protected void endOfNode() throws FOPException {
106: if (!hasListItem) {
107: missingChildElementError("marker* (list-item)+");
108: }
109: getFOEventHandler().endList(this );
110: }
111:
112: /**
113: * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
114: * XSL Content Model: marker* (list-item)+
115: */
116: protected void validateChildNode(Locator loc, String nsURI,
117: String localName) throws ValidationException {
118: if (FO_URI.equals(nsURI) && localName.equals("marker")) {
119: if (hasListItem) {
120: nodesOutOfOrderError(loc, "fo:marker", "fo:list-item");
121: }
122: } else if (FO_URI.equals(nsURI)
123: && localName.equals("list-item")) {
124: hasListItem = true;
125: } else {
126: invalidChildError(loc, nsURI, localName);
127: }
128: }
129:
130: /**
131: * @return the Common Margin Properties-Block.
132: */
133: public CommonMarginBlock getCommonMarginBlock() {
134: return commonMarginBlock;
135: }
136:
137: /**
138: * @return the Common Border, Padding, and Background Properties.
139: */
140: public CommonBorderPaddingBackground getCommonBorderPaddingBackground() {
141: return commonBorderPaddingBackground;
142: }
143:
144: /**
145: * @return the "break-after" property.
146: */
147: public int getBreakAfter() {
148: return breakAfter;
149: }
150:
151: /**
152: * @return the "break-before" property.
153: */
154: public int getBreakBefore() {
155: return breakBefore;
156: }
157:
158: /** @return the "keep-with-next" property. */
159: public KeepProperty getKeepWithNext() {
160: return keepWithNext;
161: }
162:
163: /** @return the "keep-with-previous" property. */
164: public KeepProperty getKeepWithPrevious() {
165: return keepWithPrevious;
166: }
167:
168: /** @return the "keep-together" property. */
169: public KeepProperty getKeepTogether() {
170: return keepTogether;
171: }
172:
173: /** @return the "fox:widow-content-limit" extension property */
174: public Length getWidowContentLimit() {
175: return widowContentLimit;
176: }
177:
178: /** @return the "fox:orphan-content-limit" extension property */
179: public Length getOrphanContentLimit() {
180: return orphanContentLimit;
181: }
182:
183: /** @see org.apache.fop.fo.FONode#getLocalName() */
184: public String getLocalName() {
185: return "list-block";
186: }
187:
188: /** @see org.apache.fop.fo.FObj#getNameId() */
189: public int getNameId() {
190: return FO_LIST_BLOCK;
191: }
192: }
|