]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Merged revisions 685573,685785,685879,685885 via svnmerge from
authorAdrian Cumiskey <acumiskey@apache.org>
Thu, 14 Aug 2008 13:37:33 +0000 (13:37 +0000)
committerAdrian Cumiskey <acumiskey@apache.org>
Thu, 14 Aug 2008 13:37:33 +0000 (13:37 +0000)
https://svn.eu.apache.org/repos/asf/xmlgraphics/fop/trunk

........
  r685573 | jeremias | 2008-08-13 15:34:03 +0100 (Wed, 13 Aug 2008) | 1 line

  Fixed border trait parsing for the area tree XML when CMYK or ICC colors were used.
........
  r685785 | jeremias | 2008-08-14 07:32:52 +0100 (Thu, 14 Aug 2008) | 1 line

  Removed three unused classes in the traits package.
........
  r685879 | jeremias | 2008-08-14 14:03:20 +0100 (Thu, 14 Aug 2008) | 2 lines

  Fixed the source for a NullPointerException when the content of an fo:leader with leader-pattern="use-content" collapses to zero width during layout.
........
  r685885 | acumiskey | 2008-08-14 14:25:54 +0100 (Thu, 14 Aug 2008) | 1 line

  Moved static method lightenColor() from PrintRenderer to ColorUtil.  Thats one less Renderer interface dependency to worry about :).
........

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@685891 13f79535-47bb-0310-9956-ffa450edef68

14 files changed:
src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java
src/java/org/apache/fop/render/PrintRenderer.java
src/java/org/apache/fop/render/afp/AFPRenderer.java
src/java/org/apache/fop/render/java2d/Java2DRenderer.java
src/java/org/apache/fop/render/pdf/PDFRenderer.java
src/java/org/apache/fop/render/ps/PSRenderer.java
src/java/org/apache/fop/traits/BlockProps.java [deleted file]
src/java/org/apache/fop/traits/BorderProps.java
src/java/org/apache/fop/traits/InlineProps.java [deleted file]
src/java/org/apache/fop/traits/LayoutProps.java [deleted file]
src/java/org/apache/fop/util/ColorUtil.java
status.xml
test/java/org/apache/fop/traits/BorderPropsTestCase.java
test/layoutengine/standard-testcases/leader_leader-pattern_use-content.xml

index 1e163bef825dbe4e7796d357f9e60a6ebd52291d..f3bbc454a0095bef5c1c563455581241fbb39bb8 100644 (file)
@@ -183,17 +183,23 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager {
             childContext.setAlignmentContext(context.getAlignmentContext());
             contentList = clm.getNextKnuthElements(childContext, 0);
             int width = clm.getStackingSize();
-            Space spacer = null;
-            if (fobj.getLeaderPatternWidth().getValue(this) > width) {
-                spacer = new Space();
-                spacer.setIPD(fobj.getLeaderPatternWidth().getValue(this) - width);
-                width = fobj.getLeaderPatternWidth().getValue(this);
-            }
-            fa.setUnitWidth(width);
-            if (spacer != null) {
-                fa.addChildArea(spacer);
+            if (width != 0) {
+                Space spacer = null;
+                if (fobj.getLeaderPatternWidth().getValue(this) > width) {
+                    spacer = new Space();
+                    spacer.setIPD(fobj.getLeaderPatternWidth().getValue(this) - width);
+                    width = fobj.getLeaderPatternWidth().getValue(this);
+                }
+                fa.setUnitWidth(width);
+                if (spacer != null) {
+                    fa.addChildArea(spacer);
+                }
+                leaderArea = fa;
+            } else {
+                //Content collapsed to nothing, so use a space
+                leaderArea = new Space();
+                leaderArea.setBPD(1);
             }
-            leaderArea = fa;
         }
         TraitSetter.setProducerID(leaderArea, fobj.getId());
         return leaderArea;
index 44b0a211d7c58f10943fa8dc916a11e9449962df..56504ff53855c3cf1edb9eb0c32e958e95e48929 100644 (file)
@@ -20,7 +20,6 @@
 package org.apache.fop.render;
 
 // FOP
-import java.awt.Color;
 import java.awt.geom.Rectangle2D;
 import java.util.List;
 import java.util.Map;
@@ -112,29 +111,6 @@ public abstract class PrintRenderer extends AbstractRenderer {
         return fontInfo.getFontInstance(triplet, size);
     }
 
-    /**
-     * Lightens up a color for groove, ridge, inset and outset border effects.
-     * @param col the color to lighten up
-     * @param factor factor by which to lighten up (negative values darken the color)
-     * @return the modified color
-     */
-    public static Color lightenColor(Color col, float factor) {
-        // TODO: This function converts the color into the sRGB namespace.
-        // This should be avoided if possible.
-        float[] cols = new float[4];
-        cols = col.getRGBComponents(cols);
-        if (factor > 0) {
-            cols[0] += (1.0 - cols[0]) * factor;
-            cols[1] += (1.0 - cols[1]) * factor;
-            cols[2] += (1.0 - cols[2]) * factor;
-        } else {
-            cols[0] -= cols[0] * -factor;
-            cols[1] -= cols[1] * -factor;
-            cols[2] -= cols[2] * -factor;
-        }
-        return new Color(cols[0], cols[1], cols[2], cols[3]);
-    }
-
     /**
      * Creates a RendererContext for an image.
      * @param x the x coordinate (in millipoints)
index 94918f7ec7725bcbe6dd3381a76e41c14f8a8ffb..6d4e8fafd4ff89e60fd00ad6d39a597f9117c1df 100644 (file)
@@ -78,6 +78,7 @@ import org.apache.fop.render.afp.fonts.AFPFont;
 import org.apache.fop.render.afp.fonts.AFPFontCollection;
 import org.apache.fop.render.afp.modca.AFPDataStream;
 import org.apache.fop.render.afp.modca.PageObject;
+import org.apache.fop.util.ColorUtil;
 
 /**
  * This is an implementation of a FOP Renderer that renders areas to AFP.
@@ -502,7 +503,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
 
                 float h3 = height / 3;
                 
-                lineDataInfo.color = lightenColor(col, -colFactor);
+                lineDataInfo.color = ColorUtil.lightenColor(col, -colFactor);
                 lineDataInfo.thickness = Math.round(h3);
                 lineDataInfo.y1 = lineDataInfo.y2 = coords[Y1];
                 afpDataStream.createLine(lineDataInfo);
@@ -511,7 +512,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
                 lineDataInfo.y1 = lineDataInfo.y2 = Math.round(dstPts[Y1] + h3);
                 afpDataStream.createLine(lineDataInfo);
                 
-                lineDataInfo.color = lightenColor(col, colFactor);
+                lineDataInfo.color = ColorUtil.lightenColor(col, colFactor);
                 lineDataInfo.y1 = lineDataInfo.y2
                     = Math.round(dstPts[Y1] + h3 + h3);                
                 afpDataStream.createLine(lineDataInfo);
@@ -524,7 +525,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
                 float w3 = width / 3;
                 float xm1 = dstPts[X1] + (w3 / 2);
 
-                lineDataInfo.color = lightenColor(col, -colFactor);
+                lineDataInfo.color = ColorUtil.lightenColor(col, -colFactor);
                 lineDataInfo.x1 = lineDataInfo.x2 = Math.round(xm1);
                 afpDataStream.createLine(lineDataInfo);
                 
@@ -532,7 +533,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
                 lineDataInfo.x1 = lineDataInfo.x2 = Math.round(xm1 + w3);
                 afpDataStream.createLine(lineDataInfo);
 
-                lineDataInfo.color = lightenColor(col, colFactor);
+                lineDataInfo.color = ColorUtil.lightenColor(col, colFactor);
                 lineDataInfo.x1 = lineDataInfo.x2 = Math.round(xm1 + w3 + w3);
                 afpDataStream.createLine(lineDataInfo);
             }
index 02b809ff7b9ccbfdc3e83c3da519a54840a0a419..1e396c24792b5cd20527f00d6e49205608539bf2 100644 (file)
@@ -77,6 +77,7 @@ import org.apache.fop.render.Graphics2DAdapter;
 import org.apache.fop.render.RendererContext;
 import org.apache.fop.render.pdf.CTMHelper;
 import org.apache.fop.util.CharUtilities;
+import org.apache.fop.util.ColorUtil;
 
 /**
  * The <code>Java2DRenderer</code> class provides the abstract technical
@@ -625,8 +626,8 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem
             case Constants.EN_RIDGE:
                 float colFactor = (style == EN_GROOVE ? 0.4f : -0.4f);
                 if (horz) {
-                    Color uppercol = lightenColor(col, -colFactor);
-                    Color lowercol = lightenColor(col, colFactor);
+                    Color uppercol = ColorUtil.lightenColor(col, -colFactor);
+                    Color lowercol = ColorUtil.lightenColor(col, colFactor);
                     float h3 = h / 3;
                     float ym1 = y1 + (h3 / 2);
                     g2d.setStroke(new BasicStroke(h3));
@@ -637,8 +638,8 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem
                     g2d.setColor(lowercol);
                     g2d.draw(new Line2D.Float(x1, ym1 + h3 + h3, x2, ym1 + h3 + h3));
                 } else {
-                    Color leftcol = lightenColor(col, -colFactor);
-                    Color rightcol = lightenColor(col, colFactor);
+                    Color leftcol = ColorUtil.lightenColor(col, -colFactor);
+                    Color rightcol = ColorUtil.lightenColor(col, colFactor);
                     float w3 = w / 3;
                     float xm1 = x1 + (w3 / 2);
                     g2d.setStroke(new BasicStroke(w3));
@@ -654,13 +655,13 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem
             case Constants.EN_OUTSET:
                 colFactor = (style == EN_OUTSET ? 0.4f : -0.4f);
                 if (horz) {
-                    col = lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
+                    col = ColorUtil.lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
                     g2d.setStroke(new BasicStroke(h));
                     float ym1 = y1 + (h / 2);
                     g2d.setColor(col);
                     g2d.draw(new Line2D.Float(x1, ym1, x2, ym1));
                 } else {
-                    col = lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
+                    col = ColorUtil.lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
                     float xm1 = x1 + (w / 2);
                     g2d.setStroke(new BasicStroke(w));
                     g2d.setColor(col);
@@ -830,7 +831,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem
         case EN_RIDGE:
             float half = area.getRuleThickness() / 2000f;
 
-            state.updateColor(lightenColor(col, 0.6f));
+            state.updateColor(ColorUtil.lightenColor(col, 0.6f));
             moveTo(startx, starty);
             lineTo(endx, starty);
             lineTo(endx, starty + 2 * half);
index 27caf86b4a7025aba1fb811e081fc34774feaaa2..61ed1ff07d9e9fd0dff752e4c228cc78e241a047 100644 (file)
@@ -117,6 +117,7 @@ import org.apache.fop.render.Graphics2DAdapter;
 import org.apache.fop.render.RendererContext;
 import org.apache.fop.util.CharUtilities;
 import org.apache.fop.util.ColorProfileUtil;
+import org.apache.fop.util.ColorUtil;
 
 /**
  * Renderer that renders areas to PDF.
@@ -939,8 +940,8 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
                 float colFactor = (style == EN_GROOVE ? 0.4f : -0.4f);
                 currentStream.add("[] 0 d ");
                 if (horz) {
-                    Color uppercol = lightenColor(col, -colFactor);
-                    Color lowercol = lightenColor(col, colFactor);
+                    Color uppercol = ColorUtil.lightenColor(col, -colFactor);
+                    Color lowercol = ColorUtil.lightenColor(col, colFactor);
                     float h3 = h / 3;
                     currentStream.add(format(h3) + " w\n");
                     float ym1 = y1 + (h3 / 2);
@@ -954,8 +955,8 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
                     currentStream.add(format(x1) + " " + format(ym1 + h3 + h3) + " m "
                                         + format(x2) + " " + format(ym1 + h3 + h3) + " l S\n");
                 } else {
-                    Color leftcol = lightenColor(col, -colFactor);
-                    Color rightcol = lightenColor(col, colFactor);
+                    Color leftcol = ColorUtil.lightenColor(col, -colFactor);
+                    Color rightcol = ColorUtil.lightenColor(col, colFactor);
                     float w3 = w / 3;
                     currentStream.add(format(w3) + " w\n");
                     float xm1 = x1 + (w3 / 2);
@@ -978,14 +979,14 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
                 currentStream.add("[] 0 d ");
                 Color c = col;
                 if (horz) {
-                    c = lightenColor(c, (startOrBefore ? 1 : -1) * colFactor);
+                    c = ColorUtil.lightenColor(c, (startOrBefore ? 1 : -1) * colFactor);
                     currentStream.add(format(h) + " w\n");
                     float ym1 = y1 + (h / 2);
                     setColor(c, false, null);
                     currentStream.add(format(x1) + " " + format(ym1) + " m "
                             + format(x2) + " " + format(ym1) + " l S\n");
                 } else {
-                    c = lightenColor(c, (startOrBefore ? 1 : -1) * colFactor);
+                    c = ColorUtil.lightenColor(c, (startOrBefore ? 1 : -1) * colFactor);
                     currentStream.add(format(w) + " w\n");
                     float xm1 = x1 + (w / 2);
                     setColor(c, false, null);
@@ -1773,7 +1774,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
             case EN_RIDGE:
                 float half = area.getRuleThickness() / 2000f;
 
-                setColor(lightenColor(col, 0.6f), true, null);
+                setColor(ColorUtil.lightenColor(col, 0.6f), true, null);
                 currentStream.add(format(startx) + " " + format(starty) + " m\n");
                 currentStream.add(format(endx) + " " + format(starty) + " l\n");
                 currentStream.add(format(endx) + " " + format(starty + 2 * half) + " l\n");
index 9f8cdc771f9c798a237e0e28526afa00d0e01790..4785ea14fea9c3cf0c26732da305c3f6d8818d09 100644 (file)
@@ -106,6 +106,7 @@ import org.apache.fop.render.ps.extensions.PSExtensionAttachment;
 import org.apache.fop.render.ps.extensions.PSSetPageDevice;
 import org.apache.fop.render.ps.extensions.PSSetupCode;
 import org.apache.fop.util.CharUtilities;
+import org.apache.fop.util.ColorUtil;
 
 /**
  * Renderer that renders to PostScript.
@@ -839,8 +840,8 @@ public class PSRenderer extends AbstractPathOrientedRenderer
                     float colFactor = (style == EN_GROOVE ? 0.4f : -0.4f);
                     gen.useDash(null);
                     if (horz) {
-                        Color uppercol = lightenColor(col, -colFactor);
-                        Color lowercol = lightenColor(col, colFactor);
+                        Color uppercol = ColorUtil.lightenColor(col, -colFactor);
+                        Color lowercol = ColorUtil.lightenColor(col, colFactor);
                         float h3 = h / 3;
                         gen.useLineWidth(h3);
                         float ym1 = y1 + (h3 / 2);
@@ -851,8 +852,8 @@ public class PSRenderer extends AbstractPathOrientedRenderer
                         gen.useColor(lowercol);
                         drawLine(x1, ym1 + h3 + h3, x2, ym1 + h3 + h3);
                     } else {
-                        Color leftcol = lightenColor(col, -colFactor);
-                        Color rightcol = lightenColor(col, colFactor);
+                        Color leftcol = ColorUtil.lightenColor(col, -colFactor);
+                        Color rightcol = ColorUtil.lightenColor(col, colFactor);
                         float w3 = w / 3;
                         gen.useLineWidth(w3);
                         float xm1 = x1 + (w3 / 2);
@@ -869,13 +870,13 @@ public class PSRenderer extends AbstractPathOrientedRenderer
                     colFactor = (style == EN_OUTSET ? 0.4f : -0.4f);
                     gen.useDash(null);
                     if (horz) {
-                        Color c = lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
+                        Color c = ColorUtil.lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
                         gen.useLineWidth(h);
                         float ym1 = y1 + (h / 2);
                         gen.useColor(c);
                         drawLine(x1, ym1, x2, ym1);
                     } else {
-                        Color c = lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
+                        Color c = ColorUtil.lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
                         gen.useLineWidth(w);
                         float xm1 = x1 + (w / 2);
                         gen.useColor(c);
@@ -1570,7 +1571,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
                 case EN_RIDGE:
                     float half = area.getRuleThickness() / 2000f;
 
-                    gen.useColor(lightenColor(col, 0.6f));
+                    gen.useColor(ColorUtil.lightenColor(col, 0.6f));
                     moveTo(startx, starty);
                     lineTo(endx, starty);
                     lineTo(endx, starty + 2 * half);
diff --git a/src/java/org/apache/fop/traits/BlockProps.java b/src/java/org/apache/fop/traits/BlockProps.java
deleted file mode 100644 (file)
index 370a979..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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$ */
-
-package org.apache.fop.traits;
-
-import org.apache.fop.datatypes.Length;
-
-/**
- * Store all block-level layout properties on an FO.
- * Public "structure" allows direct member access.
- */
-public class BlockProps {
-
-    public Length firstIndent; // text-indent
-    public int lastIndent; // last-line-indent
-    public int textAlign;
-    public int textAlignLast;
-    public int lineStackType; // line-stacking-strategy (enum)
-
-}
index 20e3626748a1b76e8efafdcaab8b9b2753c96d43..338743538ae743ad1696eeb09e222f0bd6af16e1 100644 (file)
@@ -21,7 +21,8 @@ package org.apache.fop.traits;
 
 import java.awt.Color;
 import java.io.Serializable;
-import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.fo.Constants;
@@ -162,13 +163,19 @@ public class BorderProps implements Serializable {
     public static BorderProps valueOf(FOUserAgent foUserAgent, String s) {
         if (s.startsWith("(") && s.endsWith(")")) {
             s = s.substring(1, s.length() - 1);
-            StringTokenizer st = new StringTokenizer(s, ",");
-            String style = st.nextToken();
-            String color = st.nextToken();
-            int width = Integer.parseInt(st.nextToken());
+            Pattern pattern = Pattern.compile("([^,\\(]+(?:\\(.*\\))?)");
+            Matcher m = pattern.matcher(s);
+            boolean found;
+            found = m.find();
+            String style = m.group();
+            found = m.find();
+            String color = m.group();
+            found = m.find();
+            int width = Integer.parseInt(m.group());
             int mode = SEPARATE;
-            if (st.hasMoreTokens()) {
-                String ms = st.nextToken();
+            found = m.find();
+            if (found) {
+                String ms = m.group();
                 if ("collapse-inner".equalsIgnoreCase(ms)) {
                     mode = COLLAPSE_INNER;
                 } else if ("collapse-outer".equalsIgnoreCase(ms)) {
diff --git a/src/java/org/apache/fop/traits/InlineProps.java b/src/java/org/apache/fop/traits/InlineProps.java
deleted file mode 100644 (file)
index 06ca255..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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$ */
-
-package org.apache.fop.traits;
-
-/**
- * Store all inline "margin" related properties
- * Public "structure" allows direct member access.
- */
-public class InlineProps {
-
-    public int marginTop;
-    public int marginBottom;
-    public int marginLeft;
-    public int marginRight;
-    public SpaceVal spaceStart;
-    public SpaceVal spaceEnd;
-
-}
diff --git a/src/java/org/apache/fop/traits/LayoutProps.java b/src/java/org/apache/fop/traits/LayoutProps.java
deleted file mode 100644 (file)
index eff218b..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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$ */
-
-package org.apache.fop.traits;
-
-import org.apache.fop.datatypes.KeepValue;
-import org.apache.fop.fo.Constants;
-
-/**
- * Store properties affecting layout: break-before, break-after, keeps, span.
- * for a block level FO.
- * Public "structure" allows direct member access.
- */
-public class LayoutProps {
-
-    public int breakBefore; // enum constant BreakBefore.xxx
-    public int breakAfter; // enum constant BreakAfter.xxx
-    public KeepValue keepWithPrevious;  /*LF*/
-    public KeepValue keepWithNext;      /*LF*/
-    public KeepValue keepTogether;      /*LF*/
-    public int orphans;                 /*LF*/
-    public int widows;                  /*LF*/
-    public int blockProgressionUnit;    /*LF*/
-    public int lineStackingStrategy;    /*LF*/
-    public boolean bIsSpan;
-    public SpaceVal spaceBefore;
-    public SpaceVal spaceAfter;
-
-    private static final int[] BREAK_PRIORITIES =
-        new int[]{ Constants.EN_AUTO, Constants.EN_COLUMN, Constants.EN_PAGE };
-
-
-    public LayoutProps() {
-        breakBefore = breakAfter = Constants.EN_AUTO;
-        bIsSpan = false;
-    }
-
-    //     public static int higherBreak(int brkParent, int brkChild) {
-    // if (brkParent == brkChild) return brkChild;
-    // for (int i=0; i < s_breakPriorities.length; i++) {
-    //     int bp = s_breakPriorities[i];
-    //     if (bp == brkParent) return brkChild;
-    //     else if (bp == brkChild) return brkParent;
-    // }
-    // return brkChild;
-    //     }
-
-    public void combineWithParent(LayoutProps parentLP) {
-        if (parentLP.breakBefore != breakBefore) {
-            for (int i = 0; i < BREAK_PRIORITIES.length; i++) {
-                int bp = BREAK_PRIORITIES[i];
-                if (bp == breakBefore) {
-                    breakBefore = parentLP.breakBefore;
-                    break;
-                } else if (bp == parentLP.breakBefore) {
-                    break;
-                }
-            }
-        }
-        // Parent span always overrides child span
-        bIsSpan = parentLP.bIsSpan;
-    }
-
-    public String toString() {
-        return "LayoutProps:\n" +
-        "breakBefore = " + breakBefore + "; breakAfter = " + breakAfter + "\n" +
-        "spaceBefore = " + ((spaceBefore != null) ? spaceBefore.toString() : "null") + "\n" +
-        "spaceAfter = " + ((spaceAfter != null) ? spaceAfter.toString() : "null") + "\n" +
-        "bIsSpan = " + bIsSpan + "\n";
-    }
-}
-
index b85b0c017e95e76aa7f7de4d506a7e08940d5563..9534bfba3e391e2f8150de961622bae7336e7eba 100644 (file)
@@ -658,4 +658,27 @@ public final class ColorUtil {
         colorMap.put("transparent", new Color(0, 0, 0, 0));
     }
 
+    /**
+     * Lightens up a color for groove, ridge, inset and outset border effects.
+     * @param col the color to lighten up
+     * @param factor factor by which to lighten up (negative values darken the color)
+     * @return the modified color
+     */
+    public static Color lightenColor(Color col, float factor) {
+        // TODO: This function converts the color into the sRGB namespace.
+        // This should be avoided if possible.
+        float[] cols = new float[4];
+        cols = col.getRGBComponents(cols);
+        if (factor > 0) {
+            cols[0] += (1.0 - cols[0]) * factor;
+            cols[1] += (1.0 - cols[1]) * factor;
+            cols[2] += (1.0 - cols[2]) * factor;
+        } else {
+            cols[0] -= cols[0] * -factor;
+            cols[1] -= cols[1] * -factor;
+            cols[2] -= cols[2] * -factor;
+        }
+        return new Color(cols[0], cols[1], cols[2], cols[3]);
+    }
+
 }
index d5ca1ac9fe522e17fa77eb45862d2557869673e2..c134fadc21649006b21e21a88fd434f3fe5030e1 100644 (file)
 
   <changes>
     <release version="FOP Trunk" date="TBD">
+      <action context="Layout" dev="JM" type="fix">
+        Fixed the source for a NullPointerException when the content of an fo:leader with
+        leader-pattern="use-content" collapses to zero width during layout.
+      </action>
+      <action context="Renderers" dev="JM" type="fix">
+        Fixed border trait parsing for the area tree XML when CMYK or ICC colors were used.
+      </action>
       <action context="Renderers" dev="JM" type="fix" fixes-bug="45606" due-to="Pavel Kysilka">
         Fixed generation of "fonttbl" for RTF output to fix loading problem with AbiWord.
       </action>
index 6aea38512b163f1a3038eb3c098c5198d593a0d8..0c08e05af96757d65945b82ddec238f389d799f0 100644 (file)
@@ -24,6 +24,8 @@ import java.awt.Color;
 import junit.framework.TestCase;
 
 import org.apache.fop.fo.Constants;
+import org.apache.fop.util.CMYKColorSpace;
+import org.apache.fop.util.ColorExt;
 import org.apache.fop.util.ColorUtil;
 
 /**
@@ -46,6 +48,11 @@ public class BorderPropsTestCase extends TestCase {
         BorderProps b2 = BorderProps.valueOf(null, ser);
         assertEquals(b1, b2);
 
+        float[] cmyk = new float[] {1.0f, 1.0f, 0.5f, 1.0f};
+        CMYKColorSpace cmykCs = CMYKColorSpace.getInstance();
+        float[] rgb = cmykCs.toRGB(cmyk);
+        col = ColorExt.createFromFoRgbIcc(rgb[0], rgb[1], rgb[2],
+                null, "#CMYK", cmykCs, cmyk);
         b1 = new BorderProps(Constants.EN_INSET, 9999,
                 col, BorderProps.SEPARATE);
         ser = b1.toString();
index c98bd45116aeef826c63ea39abe1bd9b3107cda4..2a5c72c14cb29db530313ddfb7de867601211b7e 100644 (file)
                 </fo:instream-foreign-object></fo:leader>
               Content is svg 20 x 10 which is wider than the leader-length
           </fo:block>
+          <fo:block>
+            <fo:leader leader-length="36pt" leader-pattern="use-content"> </fo:leader>
+            Content is " "
+          </fo:block>
         </fo:flow>
       </fo:page-sequence>
     </fo:root>
     <eval expected="0" xpath="//flow/block[7]/lineArea/inlineparent/inlineparent[1]/@offset"/>
     <eval expected="20000" xpath="//flow/block[7]/lineArea/inlineparent/inlineparent[1]/viewport/@ipd"/>
     <eval expected="-1384" xpath="//flow/block[7]/lineArea/inlineparent/inlineparent[1]/viewport/@offset"/>
+
+    <eval expected="11100" xpath="//flow/block[8]/lineArea/@bpd"/>
+    <eval expected="36000" xpath="//flow/block[8]/lineArea/space[1]/@ipd"/>
+    <eval expected="0" xpath="//flow/block[8]/lineArea/space[1]/@offset"/>
   </checks>
 </testcase>