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 je...@apache.org on 2007/12/20 20:19:22 UTC

svn commit: r606004 - in /xmlgraphics/fop/trunk: ./ src/java/org/apache/fop/fo/ src/java/org/apache/fop/layoutmgr/inline/ test/layoutengine/standard-testcases/

Author: jeremias
Date: Thu Dec 20 11:19:19 2007
New Revision: 606004

URL: http://svn.apache.org/viewvc?rev=606004&view=rev
Log:
Added support for scale-down-to-fit and scale-up-to-fit.

Added:
    xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/external-graphic_content-height_content-width_2.xml   (with props)
Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/Constants.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java
    xmlgraphics/fop/trunk/status.xml

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/Constants.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/Constants.java?rev=606004&r1=606003&r2=606004&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/Constants.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/Constants.java Thu Dec 20 11:19:19 2007
@@ -1087,6 +1087,12 @@
     int EN_SMALL_CAPTION = 184;
     /** Enumeration constant -- font shorthand */
     int EN_STATUS_BAR = 185;
+    /** Enumeration constant -- for page-position, XSL 1.1 */
+    int EN_ONLY = 186; 
+    /** Enumeration constant -- for instream-foreign-object and external-graphic, XSL 1.1 */
+    int EN_SCALE_DOWN_TO_FIT = 187; 
+    /** Enumeration constant -- for instream-foreign-object and external-graphic, XSL 1.1 */
+    int EN_SCALE_UP_TO_FIT = 188; 
     /** Number of enumeration constants defined */
-    int ENUM_COUNT = 185;
+    int ENUM_COUNT = 188;
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java?rev=606004&r1=606003&r2=606004&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 20 11:19:19 2007
@@ -25,13 +25,13 @@
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.datatypes.LengthBase;
 import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.flow.table.TableFObj.ColumnNumberPropertyMaker;
 import org.apache.fop.fo.properties.BackgroundPositionShorthandParser;
 import org.apache.fop.fo.properties.BorderSpacingShorthandParser;
 import org.apache.fop.fo.properties.BorderWidthPropertyMaker;
 import org.apache.fop.fo.properties.BoxPropShorthandParser;
 import org.apache.fop.fo.properties.CharacterProperty;
 import org.apache.fop.fo.properties.ColorProperty;
-import org.apache.fop.fo.flow.table.TableFObj.ColumnNumberPropertyMaker;
 import org.apache.fop.fo.properties.CondLengthProperty;
 import org.apache.fop.fo.properties.CorrespondingPropertyMaker;
 import org.apache.fop.fo.properties.DimensionPropertyMaker;
@@ -1353,6 +1353,8 @@
         l.setInherited(false);
         l.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO"));
         l.addEnum("scale-to-fit", getEnumProperty(EN_SCALE_TO_FIT, "SCALE_TO_FIT"));
+        l.addEnum("scale-down-to-fit", getEnumProperty(EN_SCALE_DOWN_TO_FIT, "SCALE_DOWN_TO_FIT"));
+        l.addEnum("scale-up-to-fit", getEnumProperty(EN_SCALE_UP_TO_FIT, "SCALE_UP_TO_FIT"));
         l.setDefault("auto");
         l.setPercentBase(LengthBase.IMAGE_INTRINSIC_HEIGHT);
         addPropertyMaker("content-height", l);
@@ -1362,6 +1364,8 @@
         l.setInherited(false);
         l.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO"));
         l.addEnum("scale-to-fit", getEnumProperty(EN_SCALE_TO_FIT, "SCALE_TO_FIT"));
+        l.addEnum("scale-down-to-fit", getEnumProperty(EN_SCALE_DOWN_TO_FIT, "SCALE_DOWN_TO_FIT"));
+        l.addEnum("scale-up-to-fit", getEnumProperty(EN_SCALE_UP_TO_FIT, "SCALE_UP_TO_FIT"));
         l.setDefault("auto");
         l.setPercentBase(LengthBase.IMAGE_INTRINSIC_WIDTH);
         addPropertyMaker("content-width", l);
@@ -2223,6 +2227,7 @@
         m.addEnum("last", getEnumProperty(EN_LAST, "LAST"));
         m.addEnum("rest", getEnumProperty(EN_REST, "REST"));
         m.addEnum("any", getEnumProperty(EN_ANY, "ANY"));
+        m.addEnum("only", getEnumProperty(EN_ONLY, "ONLY")); //XSL 1.1
         m.setDefault("any");
         addPropertyMaker("page-position", m);
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java?rev=606004&r1=606003&r2=606004&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java Thu Dec 20 11:19:19 2007
@@ -104,21 +104,45 @@
         int cheight = -1;
         len = fobj.getContentWidth();
         if (len.getEnum() != EN_AUTO) {
-            if (len.getEnum() == EN_SCALE_TO_FIT) {
+            switch (len.getEnum()) {
+            case EN_SCALE_TO_FIT:
                 if (ipd != -1) {
                     cwidth = ipd;
                 }
-            } else {
+                break;
+            case EN_SCALE_DOWN_TO_FIT:
+                if (ipd != -1 && fobj.getIntrinsicWidth() > ipd) {
+                    cwidth = ipd;
+                }
+                break;
+            case EN_SCALE_UP_TO_FIT:
+                if (ipd != -1 && fobj.getIntrinsicWidth() < ipd) {
+                    cwidth = ipd;
+                }
+                break;
+            default:
                 cwidth = len.getValue(this);
             }
         }
         len = fobj.getContentHeight();
         if (len.getEnum() != EN_AUTO) {
-            if (len.getEnum() == EN_SCALE_TO_FIT) {
+            switch (len.getEnum()) {
+            case EN_SCALE_TO_FIT:
                 if (bpd != -1) {
                     cheight = bpd;
                 }
-            } else {
+                break;
+            case EN_SCALE_DOWN_TO_FIT:
+                if (bpd != -1 && fobj.getIntrinsicHeight() > bpd) {
+                    cheight = bpd;
+                }
+                break;
+            case EN_SCALE_UP_TO_FIT:
+                if (bpd != -1 && fobj.getIntrinsicHeight() < bpd) {
+                    cheight = bpd;
+                }
+                break;
+            default:
                 cheight = len.getValue(this);
             }
         }

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=606004&r1=606003&r2=606004&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Thu Dec 20 11:19:19 2007
@@ -28,6 +28,9 @@
 
   <changes>
     <release version="FOP Trunk">
+      <action context="Code" dev="JM" type="add">
+        Added support for scale-down-to-fit and scale-up-to-fit (introduced in XSL 1.1).
+      </action>
       <action context="Code" dev="VH" type="fix" fixes-bug="43633">
         Bugfix: content of a row with zero height overriding the previous row
       </action>

Added: xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/external-graphic_content-height_content-width_2.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/external-graphic_content-height_content-width_2.xml?rev=606004&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/external-graphic_content-height_content-width_2.xml (added)
+++ xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/external-graphic_content-height_content-width_2.xml Thu Dec 20 11:19:19 2007
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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$ -->
+<testcase>
+  <info>
+    <p>
+      This test checks external-graphics with content-width
+      (values: scale-to-fit, scale-down-to-fit and scale-up-to-fit)
+    </p>
+  </info>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+      <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" font-size="0" line-height="1">
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block>
+            <fo:external-graphic id="img1" src="../../resources/images/bgimg72dpi.jpg"/>
+          </fo:block>
+          <fo:block>
+            <fo:external-graphic id="img2" src="../../resources/images/bgimg72dpi.jpg"
+              inline-progression-dimension="250pt" block-progression-dimension="250pt"
+              content-height="scale-to-fit" content-width="scale-to-fit"/>
+          </fo:block>
+          <fo:block>
+            <fo:external-graphic id="img3" src="../../resources/images/bgimg72dpi.jpg"
+              inline-progression-dimension="250pt" block-progression-dimension="250pt"
+              content-height="scale-down-to-fit" content-width="scale-down-to-fit"/>
+          </fo:block>
+          <fo:block>
+            <fo:external-graphic id="img4" src="../../resources/images/bgimg72dpi.jpg"
+              inline-progression-dimension="250pt" block-progression-dimension="250pt"
+              content-height="scale-up-to-fit" content-width="scale-up-to-fit"/>
+          </fo:block>
+          <fo:block>
+            <fo:external-graphic id="img5" src="../../resources/images/bgimg300dpi.jpg"
+              inline-progression-dimension="250pt" block-progression-dimension="250pt"
+              content-height="scale-down-to-fit" content-width="scale-down-to-fit"/>
+          </fo:block>
+          <fo:block>
+            <fo:external-graphic id="img6" src="../../resources/images/bgimg300dpi.jpg"
+              inline-progression-dimension="250pt" block-progression-dimension="250pt"
+              content-height="scale-up-to-fit" content-width="scale-up-to-fit"/>
+          </fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <eval expected="192000" xpath="//image[@prod-id='img1']/../@ipd"/>
+    <eval expected="192000" xpath="//image[@prod-id='img1']/../@bpd"/>
+    <eval expected="0 0 192000 192000" xpath="//image[@prod-id='img1']/../@pos"/>
+    
+    <eval expected="250000" xpath="//image[@prod-id='img2']/../@ipd"/>
+    <eval expected="250000" xpath="//image[@prod-id='img2']/../@bpd"/>
+    <eval expected="0 0 250000 250000" xpath="//image[@prod-id='img2']/../@pos"/>
+    
+    <eval expected="250000" xpath="//image[@prod-id='img3']/../@ipd"/>
+    <eval expected="250000" xpath="//image[@prod-id='img3']/../@bpd"/>
+    <eval expected="0 0 192000 192000" xpath="//image[@prod-id='img3']/../@pos"/>
+    
+    <eval expected="250000" xpath="//image[@prod-id='img4']/../@ipd"/>
+    <eval expected="250000" xpath="//image[@prod-id='img4']/../@bpd"/>
+    <eval expected="0 0 250000 250000" xpath="//image[@prod-id='img4']/../@pos"/>
+
+    <eval expected="250000" xpath="//image[@prod-id='img5']/../@ipd"/>
+    <eval expected="250000" xpath="//image[@prod-id='img5']/../@bpd"/>
+    <eval expected="0 0 46080 46080" xpath="//image[@prod-id='img5']/../@pos"/>
+    
+    <eval expected="250000" xpath="//image[@prod-id='img6']/../@ipd"/>
+    <eval expected="250000" xpath="//image[@prod-id='img6']/../@bpd"/>
+    <eval expected="0 0 250000 250000" xpath="//image[@prod-id='img6']/../@pos"/>
+  </checks>
+</testcase>

Propchange: xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/external-graphic_content-height_content-width_2.xml
------------------------------------------------------------------------------
    svn:keywords = Id



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org