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: TableAndCaption.java 554094 2007-07-07 00:04:25Z adelmelle $ */
019:
020: package org.apache.fop.fo.flow;
021:
022: // XML
023: import org.xml.sax.Locator;
024:
025: import org.apache.fop.apps.FOPException;
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:table-and-caption property.
039: * @todo needs implementation
040: */
041: public class TableAndCaption extends FObj {
042: // The value of properties relevant for fo:table-and-caption.
043: // Unused but valid items, commented out for performance:
044: // private CommonAccessibility commonAccessibility;
045: // private CommonAural commonAural;
046: // private CommonBorderPaddingBackground commonBorderPaddingBackground;
047: // private CommonMarginBlock commonMarginBlock;
048: // private CommonRelativePosition commonRelativePosition;
049: // private int breakAfter;
050: // private int breakBefore;
051: // private int captionSide;
052: // private int intrusionDisplace;
053: // private KeepProperty keepTogether;
054: // private KeepProperty keepWithNext;
055: // private KeepProperty keepWithPrevious;
056: // private int textAlign;
057: // End of property values
058:
059: static boolean notImplementedWarningGiven = false;
060:
061: /** used for FO validation */
062: private boolean tableCaptionFound = false;
063: private boolean tableFound = false;
064:
065: /**
066: * @param parent FONode that is the parent of this object
067: */
068: public TableAndCaption(FONode parent) {
069: super (parent);
070:
071: if (!notImplementedWarningGiven) {
072: log.warn("fo:table-and-caption is not yet implemented.");
073: notImplementedWarningGiven = true;
074: }
075: }
076:
077: /**
078: * Make sure content model satisfied, if so then tell the
079: * FOEventHandler that we are at the end of the flow.
080: * @see org.apache.fop.fo.FONode#endOfNode
081: */
082: protected void endOfNode() throws FOPException {
083: if (!tableFound) {
084: missingChildElementError("marker* table-caption? table");
085: }
086: }
087:
088: /**
089: * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
090: * XSL Content Model: marker* table-caption? table
091: */
092: protected void validateChildNode(Locator loc, String nsURI,
093: String localName) throws ValidationException {
094:
095: if (FO_URI.equals(nsURI) && localName.equals("marker")) {
096: if (tableCaptionFound) {
097: nodesOutOfOrderError(loc, "fo:marker",
098: "fo:table-caption");
099: } else if (tableFound) {
100: nodesOutOfOrderError(loc, "fo:marker", "fo:table");
101: }
102: } else if (FO_URI.equals(nsURI)
103: && localName.equals("table-caption")) {
104: if (tableCaptionFound) {
105: tooManyNodesError(loc, "fo:table-caption");
106: } else if (tableFound) {
107: nodesOutOfOrderError(loc, "fo:table-caption",
108: "fo:table");
109: } else {
110: tableCaptionFound = true;
111: }
112: } else if (FO_URI.equals(nsURI) && localName.equals("table")) {
113: if (tableFound) {
114: tooManyNodesError(loc, "fo:table");
115: } else {
116: tableFound = true;
117: }
118: } else {
119: invalidChildError(loc, nsURI, localName);
120: }
121: }
122:
123: /** @see org.apache.fop.fo.FONode#getLocalName() */
124: public String getLocalName() {
125: return "table-and-caption";
126: }
127:
128: /**
129: * @see org.apache.fop.fo.FObj#getNameId()
130: */
131: public int getNameId() {
132: return FO_TABLE_AND_CAPTION;
133: }
134: }
|