Bug 59056 - [Patch] Render individual slideshow shapes
Summary: [Patch] Render individual slideshow shapes
Alias: None
Product: POI
Classification: Unclassified
Component: SL Common (show other bugs)
Version: 3.14-dev
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Keywords: PatchAvailable
Depends on:
Reported: 2016-02-23 21:26 UTC by holgerbrandl
Modified: 2016-03-01 00:41 UTC (History)
0 users

Patch for drawing single shapes (9.27 KB, text/x-diff)
2016-02-26 21:43 UTC, Andreas Beeker

Note You need to log in before you can comment on or make changes to this bug.
Description holgerbrandl 2016-02-23 21:26:06 UTC
org.apache.poi.hslf.usermodel.HSLFShape#draw is no longer implemented, which makes it impossible to render individual shapes.

In poi v3.12 it was still possible to render indidual Shapes (e.g. for text because org.apache.poi.hslf.model.TextShape#draw was overriding the placeholder org.apache.poi.hslf.model.Shape#draw and provided rendering logic). However in 3.13 and later org.apache.poi.hslf.usermodel.HSLFShape#draw is not overridden anywhere but also does not provide any rendering logic.

To avoid any confusion: Rending of complete slides still works via org.apache.poi.hslf.usermodel.HSLFSlide#draw the regression is only affecting individual shape rendering with Graphics2D.
Comment 1 Andreas Beeker 2016-02-23 22:52:47 UTC
Please elaborate a bit more your use-case - best would be some kind of example where the rendering is to be inserted.

How would you change org.apache.poi.sl.draw.DrawTextShape to suit your needs?

The background for this change is, the common sl change, which refactors the rendering code from X/HSLF to a separate package hierarchy. You can even provide your own org.apache.poi.sl.draw.DrawFactory to provide custom rendering.

Please be aware X/HSLF still has scratchpad state, so api breaks aren't a regression.
My goal is to keep the common sl interfaces (org.apache.poi.sl.*) downward compatible, but this isn't necessarily true for the X/HSLF implementation classes - usually the HSLF api will be migrated towards XSLF.
Comment 2 holgerbrandl 2016-02-25 21:57:17 UTC
My usecase is http://opencards.info/ where I need to partially render slides. To do so I was using in the past the following code https://github.com/holgerbrandl/opencards/blob/8fe5ac6ec4af1603352f1a2a935657fb09371971/src/info/opencards/pptintegration/PPTSlideRenderPanel.java#L65

Since with v3.13 the method org.apache.poi.hslf.usermodel.HSLFShape#draw is not implemented by any of the subclasses, so rendering of individual slides does not work anymore. 

With v3.12 and earlier I was using org.apache.poi.hslf.model.Shape#draw which itself was also not doing anything but it was overridden by

Thanks to your answer I discovered the workaround of doing 
instead of the previous approach of  

See here https://github.com/holgerbrandl/opencards/blob/poi_3.13/src/info/opencards/pptintegration/PPTSlideRenderPanel.java#L91

Still, org.apache.poi.hslf.usermodel.HSLFShape#draw should imho either simply implement this workaround or be removed from the api (since it's non-functional at the moment).
Comment 3 Andreas Beeker 2016-02-26 21:43:19 UTC
You are right, I've missed that draw method.

What do you think about the patch?
Comment 4 Andreas Beeker 2016-02-26 21:43:22 UTC
Created attachment 33601 [details]
Patch for drawing single shapes
Comment 5 holgerbrandl 2016-02-29 07:44:56 UTC
Patch looks very good to me. Thanks!
Comment 6 Andreas Beeker 2016-03-01 00:41:40 UTC
added via r1732974