Bug 45780

Summary: area references are not updated on shiftRows
Product: POI Reporter: Antti Koskimäki <antti.koskimaki>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Attachments: Patch for shiftRows to update area references too

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.