7

I'm trying to set the background fill color for a pptx file using the Apache POI XSLF library. My code looks like this:

XSLFSlideMaster defaultMaster = ppt.getSlideMasters().get(0);
XSLFSlideLayout layout = defaultMaster.getLayout(SlideLayout.BLANK);
XSLFBackground background = layout.getBackground();
background.setFillColor(Color.BLACK);

which results in

Exception in thread "main" java.lang.IllegalStateException: CTShapeProperties was not found.
at org.apache.poi.xslf.usermodel.XSLFShape.getSpPr(XSLFShape.java:240)
at org.apache.poi.xslf.usermodel.XSLFSimpleShape.setFillColor(XSLFSimpleShape.java:549)

I've tried calling this on SlideMaster's background, the layout's background, and the slide's background and all result in the same error.

Kaptain
  • 115
  • 1
  • 2
  • 7

1 Answers1

1

This was fixed in POI 3.15-beta2 via #59702.

The "problem" with the OOXml properties or the POI implementation or the xmlbeans schemas is, that similar attributes like colors are stored below different schema types and the old code didn't cover that parent nodes. The patch introduced delegates to wrap those differences and the XSLF usermodel methods can be now more uniform.

kiwiwings
  • 3,386
  • 1
  • 21
  • 57
  • thanks kiwings.. Is there any way to make it in older version (3.9) ?because higher version doesn't have some backward compatibility – Jekin Kalariya Feb 11 '17 at 14:49
  • I 'm not backporting any patches... so I could imagine, that it is possible to implement it based on 3.9. As I'm always puzzled why so many projects stay on 3.9 - instead of 3.10 which was the last jdk 1.5 release - what compatibility problems do you face? ... please be detailed, as this really bugs me – kiwiwings Feb 11 '17 at 16:50
  • @kiwiwings: Have a look at this for example: http://stackoverflow.com/questions/35097640/add-image-into-a-word-docx-document-header-using-poi-xwpf/35103749#35103749. This had worked until apache poi 3.13. Since 3.14, at least until 3.15 final, it works not more. Reason: POI will not save the blip reference for images in header paragraphs anymore. – Axel Richter Feb 12 '17 at 09:31