aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/fo/properties/PageBreakShorthandParser.java
diff options
context:
space:
mode:
authorAndreas L. Delmelle <adelmelle@apache.org>2005-12-29 21:09:07 +0000
committerAndreas L. Delmelle <adelmelle@apache.org>2005-12-29 21:09:07 +0000
commitb4473242b43dc69c0faa175e462c2ccc4cbf922f (patch)
tree62356c8571eef6c2ecda47fb6c831b0b309ced09 /src/java/org/apache/fop/fo/properties/PageBreakShorthandParser.java
parent0027e137a66f10dcab63c82d32e82105f3850a07 (diff)
downloadxmlgraphics-fop-b4473242b43dc69c0faa175e462c2ccc4cbf922f.tar.gz
xmlgraphics-fop-b4473242b43dc69c0faa175e462c2ccc4cbf922f.zip
1) Added support for the page-break-* shorthands
2) Minor tweak: added validity check for reference-orientation git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@359890 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/fo/properties/PageBreakShorthandParser.java')
-rw-r--r--src/java/org/apache/fop/fo/properties/PageBreakShorthandParser.java65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/fo/properties/PageBreakShorthandParser.java b/src/java/org/apache/fop/fo/properties/PageBreakShorthandParser.java
new file mode 100644
index 000000000..f139b2999
--- /dev/null
+++ b/src/java/org/apache/fop/fo/properties/PageBreakShorthandParser.java
@@ -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;
+ }
+
+}