/**
* @param parentContext the context to be used for all percentages other than lengthBase
- * @param lengthBase the particular percentage length base for which this context provides a value
+ * @param lengthBase the particular percentage length base for which this context provides
+ * a value
* @param lengthBaseValue the value to be returned for requests to the given lengthBase
*/
public SimplePercentBaseContext(PercentBaseContext parentContext,
--- /dev/null
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id: SimplePercentBaseContext.java 279656 2005-09-08 22:06:48Z pietsch $ */
+
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.FObj;
+
+/**
+ * This base context is used during validation when the actual base values are still unknown
+ * but should still already be checked. The actual value returned is not so important in this
+ * case. But it's important that zero and non-zero values can be distinguished.
+ * <p>
+ * Example: A table with collapsing border model has no padding. The Table FO should be able
+ * to check if non-zero values (even percentages) have been specified.
+ */
+public final class ValidationPercentBaseContext implements PercentBaseContext {
+
+ /**
+ * Main constructor.
+ */
+ private ValidationPercentBaseContext() {
+ }
+
+ /**
+ * Returns the value for the given lengthBase.
+ * @see org.apache.fop.datatypes.PercentBaseContext#getBaseLength(int, FObj)
+ */
+ public int getBaseLength(int lengthBase, FObj fobj) {
+ //Simply return a dummy value which produces a non-zero value when a non-zero percentage
+ //was specified.
+ return 100000;
+ }
+
+ private static PercentBaseContext pseudoContextForValidation = null;
+
+ /** @return a base context for validation purposes. See class description. */
+ public static PercentBaseContext getPseudoContextForValidationPurposes() {
+ if (pseudoContextForValidation == null) {
+ pseudoContextForValidation = new ValidationPercentBaseContext();
+ }
+ return pseudoContextForValidation;
+ }
+
+}
* @param problem text to display that indicates the problem
*/
protected void attributeWarning(String problem) {
- log.warn(errorText(locator) + getName() + ", " + problem);
+ log.warn(warningText(locator) + getName() + ", " + problem);
}
/**
* @param loc org.xml.sax.Locator object
* @return String the formatted text
*/
- protected static String getLocatorString(Locator loc) {
+ public static String getLocatorString(Locator loc) {
if (loc == null) {
return "Unknown location";
} else {
import org.xml.sax.Locator;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.datatypes.ValidationPercentBaseContext;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.StaticPropertyList;
colPList.setWritingMode();
defaultColumn.bind(colPList);
- /*if (borderCollapse != EN_SEPARATE && commonBorderPaddingBackground.hasPadding()) {
- //See "17.6.2 The collapsing border model" in CSS2
- getLogger().warn("Table may not have padding when using the collapsing "
- + "border model. Padding will be ignored.");
- }*/
if (borderCollapse != EN_SEPARATE) {
- getLogger().warn("The collapsing border model on an fo:table "
+ attributeWarning("The collapsing border model on an fo:table "
+ "is currently not supported by FOP");
}
if (tableLayout == EN_AUTO) {
- getLogger().warn("table-layout=\"auto\" is currently not supported by FOP");
+ attributeWarning("table-layout=\"auto\" is currently not supported by FOP");
+ }
+ if (!isSeparateBorderModel() && getCommonBorderPaddingBackground().hasPadding(
+ ValidationPercentBaseContext.getPseudoContextForValidationPurposes())) {
+ //See "17.6.2 The collapsing border model" in CSS2
+ attributeWarning("In collapsing border model a table does not have padding"
+ + " (see http://www.w3.org/TR/REC-CSS2/tables.html#collapsing-borders)"
+ + ", but a non-zero value for padding was found. The padding will be ignored.");
}
}
import org.apache.fop.apps.FOPException;
import org.apache.fop.datatypes.Numeric;
+import org.apache.fop.datatypes.ValidationPercentBaseContext;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
/**
* Superclass for table-related FOs
- *
*/
-
public abstract class TableFObj extends FObj {
private Numeric borderAfterPrecedence;
if (getNameId() != FO_TABLE && getNameId() != FO_TABLE_CELL
&& getTable().isSeparateBorderModel()
&& getCommonBorderPaddingBackground().hasBorderInfo()) {
- getLogger().warn("Borders on " + getName()
- + " non-applicable for table with border-collapse=\"separate\"");
+ attributeWarning("In the separate border model (border-collapse=\"separate\")"
+ + ", borders cannot be specified on a " + getName()
+ + ", but a non-zero value for border was found. The border will be ignored. ");
+ }
+ if (getNameId() != FO_TABLE //Separate check for fo:table in Table.java
+ && getNameId() != FO_TABLE_CELL
+ && getCommonBorderPaddingBackground().hasPadding(
+ ValidationPercentBaseContext.getPseudoContextForValidationPurposes())) {
+ attributeWarning(getName() + " does not have padding"
+ + " (see the property list for " + getName() + " in XSL 1.0)"
+ + ", but a non-zero value for padding was found. The padding will be ignored.");
}
}