From 4b230fa142f599f9580a630f7bbdcd3ae095569f Mon Sep 17 00:00:00 2001 From: Andreas Beeker Date: Sun, 24 Oct 2021 22:07:59 +0000 Subject: [PATCH] #65653 - HSLF FillType for texture and background color fills ignored git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894538 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/hslf/usermodel/HSLFFill.java | 3 +++ .../apache/poi/hslf/usermodel/TestBugs.java | 19 ++++++++++++++++++ poi/src/test/java9/module-info.class | Bin 4145 -> 4198 bytes 3 files changed, 22 insertions(+) diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFFill.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFFill.java index 50ddf9cdf2..219cd05c59 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFFill.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFFill.java @@ -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: diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestBugs.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestBugs.java index a2b0df9bf7..1cd5be3cf6 100644 --- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestBugs.java +++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestBugs.java @@ -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 diff --git a/poi/src/test/java9/module-info.class b/poi/src/test/java9/module-info.class index 028b943d0ae7577c19f08d4b20ce352134f4f685..438e778ab515b0d480b1fb79ccaffeeafa4e55c6 100644 GIT binary patch literal 4198 zcmai1X`9qU5UxgGT}4L4TQW)SOm;I#OfoZ!=ZdI!-}i-h zE8aIB`~m(bAFC>vnd~I9?8CnAcDlN|y58#Q=HLI${R04d;9MU}6ELUhSv5!Pu-#El z!0e(|3rsa+J4(R9RF^hp)C~bMN7%XmeF7GHL0L0=!>lOH_iXwtz$^i?$W$vCAx<%~ ze?Z%*?JB@r0qausrdO?cZm5}_<0vz-@$Z2G%ongc*T_<40Tv3F*BVzfqRQ?9EEX`g z=o>+(2JNV*q5{atQ#f9^Y`bL*d0-6P*`=XF{RLQt1KG{Qpa3gcUn~`lN1k7RRRR`_ zS>syG4Qsyd1(C7}um+uQRiu@gkt)?Jt0|zbU+c$z`wFmLz!LI*tmfJgqHjkkz!2F2 zX6(`S(!!e(|0bK@7K~~rVT*wIIDsBVRmX@*xHz6P^-YhXAmNfYsM#*P7ODW%Q;vj7 z1#Fo-XEMHHq>p-Tgv;-UMNQ9V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