]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Added check for both page-height and page-width set to indefinite; use fallback ...
authorAndreas L. Delmelle <adelmelle@apache.org>
Sat, 24 Sep 2005 23:55:41 +0000 (23:55 +0000)
committerAndreas L. Delmelle <adelmelle@apache.org>
Sat, 24 Sep 2005 23:55:41 +0000 (23:55 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@291351 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/fo/properties/PageDimensionMaker.java
test/fotree/testcases/page-dimension_both_indefinite.fo [new file with mode: 0644]

index cf50fc41f6bb04ae8f3901a771515d6e3b4e0198..47183e38f9f2ed4f4d3c0cfcadd23688fba29d6b 100644 (file)
@@ -51,20 +51,48 @@ public class PageDimensionMaker extends LengthProperty.Maker {
             throws PropertyException {
         
         Property p = super.get(0, propertyList, tryInherit, tryDefault);    
+        FObj fo = propertyList.getFObj();
+        String fallbackValue = (propId == Constants.PR_PAGE_HEIGHT)
+        ? fo.getFOEventHandler().getUserAgent().getPageHeight()
+            : fo.getFOEventHandler().getUserAgent().getPageWidth();
         
-        //TODO: add check for both height and width being specified as indefinite
-        //      and use the fallback value (= set to "auto")
+        if (p.getEnum() == Constants.EN_INDEFINITE) {
+            int otherId = (propId == Constants.PR_PAGE_HEIGHT) 
+                ? Constants.PR_PAGE_WIDTH : Constants.PR_PAGE_HEIGHT;
+            int writingMode = propertyList.get(Constants.PR_WRITING_MODE).getEnum();
+            int refOrientation = propertyList.get(Constants.PR_REFERENCE_ORIENTATION)
+                        .getNumeric().getValue();
+            if (propertyList.getExplicit(otherId) != null
+                    && propertyList.getExplicit(otherId).getEnum() == Constants.EN_INDEFINITE) {
+                //both set to "indefinite":
+                //determine which one of the two defines the dimension
+                //in block-progression-direction, and set the other to 
+                //"auto"
+                if ((writingMode != Constants.EN_TB_RL
+                        && (refOrientation == 0 
+                                || refOrientation == 180
+                                || refOrientation == -180))
+                     || (writingMode == Constants.EN_TB_RL
+                             && (refOrientation == 90
+                                     || refOrientation == 270
+                                     || refOrientation == -270))) {
+                    //set page-width to "auto" = use the fallback from FOUserAgent
+                    if (propId == Constants.PR_PAGE_WIDTH) {
+                        return make(propertyList, fallbackValue, fo);
+                    }
+                } else {
+                    //set page-height to "auto" = use fallback from FOUserAgent
+                    if (propId == Constants.PR_PAGE_HEIGHT) {
+                        return make(propertyList, fallbackValue, fo);
+                    }
+                }
+            }
+        }
         
         if (p.isAuto()) {
-            FObj fo = propertyList.getFObj();
-            
-            String fallbackValue = (propId == Constants.PR_PAGE_HEIGHT)
-                ? fo.getFOEventHandler().getUserAgent().getPageHeight()
-                    : fo.getFOEventHandler().getUserAgent().getPageWidth();
             return make(propertyList, fallbackValue, fo);
         }
         
         return p;
-    }
-    
+    }    
 }
diff --git a/test/fotree/testcases/page-dimension_both_indefinite.fo b/test/fotree/testcases/page-dimension_both_indefinite.fo
new file mode 100644 (file)
index 0000000..7a10263
--- /dev/null
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+  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="lr-tb-0"
+          page-width="indefinite" page-height="indefinite"
+          writing-mode="lr-tb"
+          margin="20pt">
+      <!-- page-width should properly fall back to 8.26 * 72000 -->
+      <test:assert property="page-width" expected="594720mpt" />
+      <fo:region-body />
+    </fo:simple-page-master>
+    <fo:simple-page-master master-name="lr-tb-90" 
+          page-width="indefinite" page-height="indefinite"
+          writing-mode="lr-tb" reference-orientation="90"
+          margin="20pt">
+      <!-- page-height should properly fall back to 11 * 72000 -->
+      <test:assert property="page-height" expected="792000mpt" />
+      <fo:region-body />
+    </fo:simple-page-master>
+    <fo:simple-page-master master-name="tb-rl-0"
+          page-width="indefinite" page-height="indefinite"
+          writing-mode="tb-rl" reference-orientation="0"
+          margin="20pt">
+      <!-- page-height should properly fall back to 11 * 72000 -->
+      <test:assert property="page-height" expected="792000mpt" />
+      <fo:region-body />
+    </fo:simple-page-master>
+    <fo:simple-page-master master-name="tb-rl-90"
+          page-width="indefinite" page-height="indefinite"
+          writing-mode="tb-rl" reference-orientation="90"
+          margin="20pt">
+      <!-- page-width should properly fall back to 8.26 * 72000 -->
+      <test:assert property="page-width" expected="594720mpt" />
+      <fo:region-body />
+    </fo:simple-page-master>
+  </fo:layout-master-set>
+  <fo:page-sequence master-reference="lr-tb-0">
+    <fo:flow flow-name="xsl-region-body">
+      <fo:block>Testing page-height and page-width both "indefinite"</fo:block>
+    </fo:flow>
+  </fo:page-sequence>
+  <fo:page-sequence master-reference="lr-tb-90">
+    <fo:flow flow-name="xsl-region-body">
+      <fo:block>Testing page-height and page-width both "indefinite"</fo:block>
+    </fo:flow>
+  </fo:page-sequence>
+  <fo:page-sequence master-reference="tb-rl-0">
+    <fo:flow flow-name="xsl-region-body">
+      <fo:block>Testing page-height and page-width both "indefinite"</fo:block>
+    </fo:flow>
+  </fo:page-sequence>
+  <fo:page-sequence master-reference="tb-rl-90">
+    <fo:flow flow-name="xsl-region-body">
+      <fo:block>Testing page-height and page-width both "indefinite"</fo:block>
+    </fo:flow>
+  </fo:page-sequence>
+</fo:root>