You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ad...@apache.org on 2005/12/29 22:09:20 UTC
svn commit: r359890 - in /xmlgraphics/fop/trunk:
src/documentation/content/xdocs/ src/java/org/apache/fop/fo/
src/java/org/apache/fop/fo/properties/ test/fotree/testcases/
Author: adelmelle
Date: Thu Dec 29 13:09:07 2005
New Revision: 359890
URL: http://svn.apache.org/viewcvs?rev=359890&view=rev
Log:
1) Added support for the page-break-* shorthands
2) Minor tweak: added validity check for reference-orientation
Added:
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/PageBreakShorthandParser.java (with props)
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/ReferenceOrientationMaker.java (with props)
xmlgraphics/fop/trunk/test/fotree/testcases/page-break_shorthand-expansion.fo (with props)
Modified:
xmlgraphics/fop/trunk/src/documentation/content/xdocs/compliance.ihtml
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java
Modified: xmlgraphics/fop/trunk/src/documentation/content/xdocs/compliance.ihtml
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/documentation/content/xdocs/compliance.ihtml?rev=359890&r1=359889&r2=359890&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/documentation/content/xdocs/compliance.ihtml (original)
+++ xmlgraphics/fop/trunk/src/documentation/content/xdocs/compliance.ihtml Thu Dec 29 13:09:07 2005
@@ -6673,8 +6673,8 @@
<td class="no">
no
</td>
- <td class="no">
- no
+ <td class="yes">
+ yes
</td>
<td align="center">
@@ -6693,8 +6693,8 @@
<td class="no">
no
</td>
- <td class="no">
- no
+ <td class="yes">
+ yes
</td>
<td align="center">
@@ -6713,8 +6713,8 @@
<td class="no">
no
</td>
- <td class="no">
- no
+ <td class="yes">
+ yes
</td>
<td align="center">
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java?rev=359890&r1=359889&r2=359890&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java Thu Dec 29 13:09:07 2005
@@ -45,10 +45,12 @@
import org.apache.fop.fo.properties.LineHeightPropertyMaker;
import org.apache.fop.fo.properties.ListProperty;
import org.apache.fop.fo.properties.NumberProperty;
+import org.apache.fop.fo.properties.PageBreakShorthandParser;
import org.apache.fop.fo.properties.PageDimensionMaker;
import org.apache.fop.fo.properties.PositionShorthandParser;
import org.apache.fop.fo.properties.Property;
import org.apache.fop.fo.properties.PropertyMaker;
+import org.apache.fop.fo.properties.ReferenceOrientationMaker;
import org.apache.fop.fo.properties.SpaceProperty;
import org.apache.fop.fo.properties.SpacePropertyMaker;
import org.apache.fop.fo.properties.SpacingPropertyMaker;
@@ -1877,11 +1879,13 @@
// break-after
m = new EnumProperty.Maker(PR_BREAK_AFTER);
m.useGeneric(genericBreak);
+ m.addShorthand(s_generics[PR_PAGE_BREAK_AFTER]);
addPropertyMaker("break-after", m);
// break-before
m = new EnumProperty.Maker(PR_BREAK_BEFORE);
m.useGeneric(genericBreak);
+ m.addShorthand(s_generics[PR_PAGE_BREAK_BEFORE]);
addPropertyMaker("break-before", m);
// keep-together
@@ -1889,6 +1893,7 @@
m.useGeneric(genericKeep);
m.setInherited(false);
m.setDefault("auto");
+ m.addShorthand(s_generics[PR_PAGE_BREAK_INSIDE]);
addPropertyMaker("keep-together", m);
// keep-with-next
@@ -1896,6 +1901,7 @@
m.useGeneric(genericKeep);
m.setInherited(false);
m.setDefault("auto");
+ m.addShorthand(s_generics[PR_PAGE_BREAK_AFTER]);
addPropertyMaker("keep-with-next", m);
// keep-with-previous
@@ -1903,6 +1909,7 @@
m.useGeneric(genericKeep);
m.setInherited(false);
m.setDefault("auto");
+ m.addShorthand(s_generics[PR_PAGE_BREAK_BEFORE]);
addPropertyMaker("keep-with-previous", m);
// orphans
@@ -1939,7 +1946,7 @@
addPropertyMaker("overflow", m);
// reference-orientation
- m = new NumberProperty.Maker(PR_REFERENCE_ORIENTATION);
+ m = new ReferenceOrientationMaker(PR_REFERENCE_ORIENTATION);
m.setInherited(true);
m.setDefault("0");
addPropertyMaker("reference-orientation", m);
@@ -2686,21 +2693,36 @@
addPropertyMaker("padding", m);
// page-break-after
- m = new ToBeImplementedProperty.Maker(PR_PAGE_BREAK_AFTER);
+ m = new EnumProperty.Maker(PR_PAGE_BREAK_AFTER);
m.setInherited(false);
+ m.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO"));
+ m.addEnum("always", getEnumProperty(EN_ALWAYS, "ALWAYS"));
+ m.addEnum("avoid", getEnumProperty(EN_AVOID, "AVOID"));
+ m.addEnum("left", getEnumProperty(EN_LEFT, "LEFT"));
+ m.addEnum("right", getEnumProperty(EN_RIGHT, "RIGHT"));
m.setDefault("auto");
+ m.setDatatypeParser(new PageBreakShorthandParser());
addPropertyMaker("page-break-after", m);
// page-break-before
- m = new ToBeImplementedProperty.Maker(PR_PAGE_BREAK_BEFORE);
+ m = new EnumProperty.Maker(PR_PAGE_BREAK_BEFORE);
m.setInherited(false);
+ m.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO"));
+ m.addEnum("always", getEnumProperty(EN_ALWAYS, "ALWAYS"));
+ m.addEnum("avoid", getEnumProperty(EN_AVOID, "AVOID"));
+ m.addEnum("left", getEnumProperty(EN_LEFT, "LEFT"));
+ m.addEnum("right", getEnumProperty(EN_RIGHT, "RIGHT"));
m.setDefault("auto");
+ m.setDatatypeParser(new PageBreakShorthandParser());
addPropertyMaker("page-break-before", m);
// page-break-inside
- m = new ToBeImplementedProperty.Maker(PR_PAGE_BREAK_INSIDE);
+ m = new EnumProperty.Maker(PR_PAGE_BREAK_INSIDE);
m.setInherited(true);
+ m.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO"));
+ m.addEnum("avoid", getEnumProperty(EN_AVOID, "AVOID"));
m.setDefault("auto");
+ m.setDatatypeParser(new PageBreakShorthandParser());
addPropertyMaker("page-break-inside", m);
// pause
Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/PageBreakShorthandParser.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/PageBreakShorthandParser.java?rev=359890&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/PageBreakShorthandParser.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/PageBreakShorthandParser.java Thu Dec 29 13:09:07 2005
@@ -0,0 +1,65 @@
+/*
+ * 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$ */
+
+package org.apache.fop.fo.properties;
+
+import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.expr.PropertyException;
+
+/**
+ * Shorthand parser for page-break-before, page-break-after and page-break-inside.
+ * Used to set the corresponding keep-* and break-* properties.
+ */
+public class PageBreakShorthandParser implements ShorthandParser {
+
+ /**
+ * @see org.apache.fop.fo.properties.ShorthandParser#getValueForProperty()
+ */
+ public Property getValueForProperty(int propId,
+ Property property,
+ PropertyMaker maker,
+ PropertyList propertyList)
+ throws PropertyException {
+
+ if (propId == Constants.PR_KEEP_WITH_PREVIOUS
+ || propId == Constants.PR_KEEP_WITH_NEXT
+ || propId == Constants.PR_KEEP_TOGETHER) {
+ if (property.getEnum() == Constants.EN_AVOID) {
+ return new EnumProperty(Constants.EN_ALWAYS, "ALWAYS");
+ } else {
+ return new EnumProperty(Constants.EN_AUTO, "AUTO");
+ }
+ } else if (propId == Constants.PR_BREAK_BEFORE
+ || propId == Constants.PR_BREAK_AFTER) {
+ switch (property.getEnum()) {
+ case Constants.EN_ALWAYS:
+ return new EnumProperty(Constants.EN_PAGE, "PAGE");
+ case Constants.EN_LEFT:
+ return new EnumProperty(Constants.EN_EVEN_PAGE, "EVEN-PAGE");
+ case Constants.EN_RIGHT:
+ return new EnumProperty(Constants.EN_ODD_PAGE, "ODD-PAGE");
+ case Constants.EN_AVOID:
+ default:
+ return new EnumProperty(Constants.EN_AUTO, "AUTO");
+ }
+ }
+ return null;
+ }
+
+}
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/PageBreakShorthandParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/PageBreakShorthandParser.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/ReferenceOrientationMaker.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/ReferenceOrientationMaker.java?rev=359890&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/ReferenceOrientationMaker.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/ReferenceOrientationMaker.java Thu Dec 29 13:09:07 2005
@@ -0,0 +1,62 @@
+/*
+ * 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$ */
+
+package org.apache.fop.fo.properties;
+
+import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.properties.NumberProperty.Maker;
+
+/**
+ * Custom Maker adding validity check for reference-orientation
+ */
+public class ReferenceOrientationMaker extends Maker {
+
+ /**
+ * Constructor
+ * @param propId the Constant Id for the property to be made
+ * @see org.apache.fop.fo.properties.PropertyMaker#PropertyMaker(propId)
+ */
+ public ReferenceOrientationMaker(int propId) {
+ super(propId);
+ }
+
+ /**
+ * Check the value of the reference-orientation property.
+ *
+ * @see org.apache.fop.fo.properties.PropertyMaker#get(int, PropertyList, boolean, boolean)
+ */
+ public Property get(int subpropId, PropertyList propertyList,
+ boolean tryInherit, boolean tryDefault)
+ throws PropertyException {
+
+ Property p = super.get(0, propertyList, tryInherit, tryDefault);
+ int ro = 0;
+ if (p != null) {
+ ro = p.getNumeric().getValue();
+ }
+ if ((Math.abs(ro) % 90) == 0 && (Math.abs(ro) / 90) <= 3) {
+ return p;
+ } else {
+ throw new PropertyException("Illegal property value: "
+ + "reference-orientation=\"" + ro + "\" "
+ + "on " + propertyList.getFObj().getName());
+ }
+ }
+
+}
\ No newline at end of file
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/ReferenceOrientationMaker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/ReferenceOrientationMaker.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/test/fotree/testcases/page-break_shorthand-expansion.fo
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/fotree/testcases/page-break_shorthand-expansion.fo?rev=359890&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/fotree/testcases/page-break_shorthand-expansion.fo (added)
+++ xmlgraphics/fop/trunk/test/fotree/testcases/page-break_shorthand-expansion.fo Thu Dec 29 13:09:07 2005
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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$ -->
+ <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:test="http://xmlgraphics.apache.org/fop/test">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="normal" page-width="5in" page-height="5in">
+ <fo:region-body/>
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+ <fo:page-sequence master-reference="normal">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block page-break-before="avoid">
+ <test:assert property="break-before" expected="AUTO" />
+ <test:assert property="keep-with-previous" expected="ALWAYS" />
+ Block 1: testing page-break-before="avoid"
+ </fo:block>
+ <fo:block page-break-before="always">
+ <test:assert property="break-before" expected="PAGE" />
+ <test:assert property="keep-with-previous" expected="AUTO" />
+ Block 2: testing page-break-before="always"
+ </fo:block>
+ <fo:block page-break-before="left">
+ <test:assert property="break-before" expected="EVEN-PAGE" />
+ <test:assert property="keep-with-previous" expected="AUTO" />
+ Block 3: testing page-break-before="left"
+ </fo:block>
+ <fo:block page-break-before="right">
+ <test:assert property="break-before" expected="ODD-PAGE" />
+ <test:assert property="keep-with-previous" expected="AUTO" />
+ Block 4: testing page-break-before="right"
+ </fo:block>
+ <fo:block page-break-after="avoid">
+ <test:assert property="break-after" expected="AUTO" />
+ <test:assert property="keep-with-next" expected="ALWAYS" />
+ Block 5: testing page-break-after="avoid"
+ </fo:block>
+ <fo:block page-break-after="always">
+ <test:assert property="break-after" expected="PAGE" />
+ <test:assert property="keep-with-next" expected="AUTO" />
+ Block 6: testing page-break-after="always"
+ </fo:block>
+ <fo:block page-break-after="left">
+ <test:assert property="break-after" expected="EVEN-PAGE" />
+ <test:assert property="keep-with-next" expected="AUTO" />
+ Block 7: testing page-break-after="left"
+ </fo:block>
+ <fo:block page-break-after="right">
+ <test:assert property="break-after" expected="ODD-PAGE" />
+ <test:assert property="keep-with-next" expected="AUTO" />
+ Block 8: testing page-break-after="right"
+ </fo:block>
+ <fo:block page-break-inside="avoid">
+ <test:assert property="keep-together" expected="ALWAYS" />
+ Block 9: testing page-break-inside="avoid"
+ </fo:block>
+ <fo:block page-break-before="left" page-break-inside="avoid"
+ page-break-after="right">
+ <test:assert property="break-before" expected="EVEN-PAGE" />
+ <test:assert property="keep-with-previous" expected="AUTO" />
+ <test:assert property="break-after" expected="ODD-PAGE" />
+ <test:assert property="keep-with-next" expected="AUTO" />
+ <test:assert property="keep-together" expected="ALWAYS" />
+ Block 10: testing page-break-before="left", page-break-inside="avoid"
+ and page-break-after="right"
+ </fo:block>
+ </fo:flow>
+ </fo:page-sequence>
+ </fo:root>
+
Propchange: xmlgraphics/fop/trunk/test/fotree/testcases/page-break_shorthand-expansion.fo
------------------------------------------------------------------------------
svn:keywords = Id
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org