You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2016/03/14 17:13:27 UTC

[Bug 59180] New: XSSFGraphicFrame hides anchor from XSSFShape

https://bz.apache.org/bugzilla/show_bug.cgi?id=59180

            Bug ID: 59180
           Summary: XSSFGraphicFrame hides anchor from XSSFShape
           Product: POI
           Version: 3.14-FINAL
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: tony.benbrahim@gmail.com

Created attachment 33674
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=33674&action=edit
inspection of anchor field

XSSFGraphicFrame incorrectly declares its own anchor field, hiding the anchor
property from XSSFShape. The achor property from XSSFShape has the anchor
value, the one from XSSFGraphicFrame is always null.


Workaround:
I was working with the graphic frame for a chart. I was able to get the anchor
through the chart parent:

final XSSFDrawing parent = (XSSFDrawing) chart.getParent();
final CTTwoCellAnchor twoCellAnchorArray =
parent.getCTDrawing().getTwoCellAnchorArray(0);
        final XSSFClientAnchor xssfClientAnchor = new XSSFClientAnchor((int)
twoCellAnchorArray.getFrom().getColOff(),
                (int) twoCellAnchorArray.getFrom().getRowOff(), (int)
twoCellAnchorArray.getTo().getColOff(),
                (int) twoCellAnchorArray.getTo().getRowOff(),
twoCellAnchorArray.getFrom().getCol(),
                twoCellAnchorArray.getFrom().getRow(),
twoCellAnchorArray.getTo().getCol(),
twoCellAnchorArray.getTo().getRow());

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59180] XSSFGraphicFrame hides anchor from XSSFShape

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59180

Tony BenBrahim <to...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from Tony BenBrahim <to...@gmail.com> ---
Workaround above did not work in one case of three (wrong parent returned by
chart.getParent().

I ended up using this (ugly but works)

if (shape instanceof XSSFGraphicFrame) {
    try {
    final Field anchorField = XSSFShape.class.getDeclaredField("anchor");
    anchorField.setAccessible(true);
    final XSSFClientAnchor anchor = (XSSFClientAnchor) anchorField.get(shape);
        renderGraphicsFrame...
    } catch (NoSuchFieldException | SecurityException | IllegalAccessException
|
 IllegalArgumentException e) {
    LOG.info("unable to extract anchor for chart", e);
   }

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 59180] XSSFGraphicFrame hides anchor from XSSFShape

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59180

--- Comment #2 from Dominik Stadler <do...@gmx.at> ---
One thing that makes it a bit more complex to fix this is that 
XSSFGraphicFrame uses an XSSFClientAnchor, but XSSFShape the superclass
XSSFAnchor. XSSFClientAnchor seems to hold a bit more information, so I am not
sure how this can be combined without causing compatibility problems and
missing functionality. 

The best way I can think of is to rename the field/getters/setters in 
XSSFGraphicFrame to get/setClientAnchor() to have both available for now,
however this still could cause some compatibility errors for other users of 
XSSFGraphicFrame.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org