Bug 45780 - area references are not updated on shiftRows
Summary: area references are not updated on shiftRows
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2008-09-11 07:57 UTC by Antti Koskimäki
Modified: 2008-09-16 13:38 UTC (History)
0 users

Patch for shiftRows to update area references too (2.26 KB, patch)
2008-09-11 07:57 UTC, Antti Koskimäki
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Koskimäki 2008-09-11 07:57:56 UTC
Created attachment 22556 [details]
Patch for shiftRows to update area references too

HSSFSheet.shiftRows updates single references (A1) but leaves area references (A1:A4) intact. 

Patch fixing this attaced. I simply handled AreaPtg exactly the same way RefPtg was handled.
Comment 1 Josh Micich 2008-09-16 13:38:44 UTC
Fixed in svn r696038.

This fix has added (hopefully complete) support for adjusting area refs due to row shifting.  Formulas are now adjusted in every cell in the workbook (i.e current *and* all other sheets).  However, other (non-cell) formulas such as defined names, data validation and conditional formats are not adjusted yet.

This turned out to be more complex than expected. There are many permutations regarding the exact relation of the moved rows to the area ref in question, for example whether the moved rows initially overlap or end up overlapping the area ref, whether the overlap is complete or partial.  JUnits were updated and added to cover this new functionality.

The Ptg translation logic was moved into a separate class, 'FormulaShifter', to allow for easier testing and enhancement.  This class could be augmented later to provide support for shifting columns, or perhaps any rectangular region.  The Ptg adjusting logic should be easy to re-use for non-cell formulas if someone ever wants to write that patch.