Bug 60072 - Sheet shiftRows doesn't trigger charts position updating
Summary: Sheet shiftRows doesn't trigger charts position updating
Status: NEEDINFO
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.13-FINAL
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-31 12:12 UTC by Lapo Cioni
Modified: 2016-09-10 05:22 UTC (History)
0 users



Attachments
Proposed patch (933 bytes, application/gzip)
2016-08-31 12:12 UTC, Lapo Cioni
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lapo Cioni 2016-08-31 12:12:38 UTC
Created attachment 34187 [details]
Proposed patch

Hi all, 
it seems that adding rows on a sheet (using Sheet.shiftRows) does not trigger any update in charts anchors.
Our proposal is to shift any chart anchor referring a cell above the start row of the shifted area.
I've attached a patch that includes a new method in XSSFSheet, called from within the shiftRows method.
Comment 1 Javen O'Neal 2016-08-31 15:41:03 UTC
Thanks for the patch! I'll review it and apply it once 3.15 is released and the trunk is unfrozen.

Does your patch also update chart data series address ranges? See bug 59306. It would be nice to have these two fixed at the same time.
Comment 2 Lapo Cioni 2016-09-01 16:50:45 UTC
(In reply to Javen O'Neal from comment #1)
> Thanks for the patch! I'll review it and apply it once 3.15 is released and
> the trunk is unfrozen.
> 
> Does your patch also update chart data series address ranges? See bug 59306.
> It would be nice to have these two fixed at the same time.

Unfortunately no.
I've only made some failed attempts to solve the issue related to bug 59306.
Comment 3 Javen O'Neal 2016-09-10 05:17:32 UTC
Could you move the drawing (chart, picture, object, etc) shifting into the XSSFRowShifter or RowShifter class?

Would you be willing to write a unit test for this class to prevent regressions on this feature in future releases? There is a class called TestXSSFSheetShiftRows or BaseTestSheetShiftRows that would be a good place for this test. This also proves to others that the behavior works as described.

Thanks!
Comment 4 Javen O'Neal 2016-09-10 05:22:13 UTC
You can use test-data/spreadsheet/WithChart.xlsx and WithDrawing.xlsx for unit tests or make your own test spreadsheet (or even better, write a unit test starting with a new XSSFWorkbook(), add the chart and/or drawing to the workbook, shift the rows, and verify that the chart and drawing were shifted the correct number of rows.

https://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/