]> source.dussan.org Git - poi.git/commitdiff
#65653 - HSLF FillType for texture and background color fills ignored
authorAndreas Beeker <kiwiwings@apache.org>
Sun, 24 Oct 2021 22:07:59 +0000 (22:07 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Sun, 24 Oct 2021 22:07:59 +0000 (22:07 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894538 13f79535-47bb-0310-9956-ffa450edef68

poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFFill.java
poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestBugs.java
poi/src/test/java9/module-info.class

index 50ddf9cdf21d97c2399e73ae2f08b511ecf59cb2..219cd05c594cac6b2bcc7fa3eb0a9f0143e87e05 100644 (file)
@@ -254,6 +254,8 @@ public final class HSLFFill {
         // need to handle (not only) the type (radial,rectangular,linear),
         // the direction, e.g. top right, and bounds (e.g. for rectangular boxes)
         switch (fillType) {
+            case FILL_BACKGROUND:
+                return DrawPaint.createSolidPaint(getBackgroundColor());
             case FILL_SOLID:
                 return DrawPaint.createSolidPaint(getForegroundColor());
             case FILL_SHADE_SHAPE:
@@ -264,6 +266,7 @@ public final class HSLFFill {
             case FILL_SHADE:
             case FILL_SHADE_SCALE:
                 return getGradientPaint(GradientType.linear);
+            case FILL_TEXTURE:
             case FILL_PICTURE:
                 return getTexturePaint();
             default:
index a2b0df9bf700a68d37b67293b049256719ff32d6..1cd5be3cf60645ed1fe3db0b470a8d539be42d17 100644 (file)
@@ -109,6 +109,25 @@ public final class TestBugs {
         }
     }
 
+    @Test
+    void fillTypesPaintMapping_65653() throws IOException {
+        try (HSLFSlideShow ppt = open("41246-2.ppt")) {
+            HSLFAutoShape as = (HSLFAutoShape) ppt.getSlides().get(15).getShapes().get(0);
+            HSLFFill f = as.getFill();
+            assertEquals(HSLFFill.FILL_TEXTURE, f.getFillType());
+            PaintStyle p = f.getFillStyle().getPaint();
+            assertTrue(p instanceof PaintStyle.TexturePaint);
+        }
+        try (HSLFSlideShow ppt = open("backgrounds.ppt")) {
+            HSLFAutoShape as = (HSLFAutoShape) ppt.getSlides().get(1).getShapes().get(0);
+            HSLFFill f = as.getFill();
+            assertEquals(HSLFFill.FILL_BACKGROUND, f.getFillType());
+            PaintStyle p = as.getFillStyle().getPaint();
+            assertTrue(p instanceof SolidPaint);
+            assertEquals(Color.WHITE, ((SolidPaint)p).getSolidColor().getColor());
+        }
+    }
+
     /**
      * First fix from Bug 42474: NPE in RichTextRun.isBold()
      * when the RichTextRun comes from a Notes model object
index 028b943d0ae7577c19f08d4b20ce352134f4f685..438e778ab515b0d480b1fb79ccaffeeafa4e55c6 100644 (file)
Binary files a/poi/src/test/java9/module-info.class and b/poi/src/test/java9/module-info.class differ