ASF Bugzilla – Attachment 29034 Details for
Bug 50083
Workbook.setSheetOrder does not fixup record list
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
patch.txt (text/plain), 2.31 KB, created by
Rémy LeBeau
on 2012-07-05 13:26:47 UTC
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Rémy LeBeau
Created:
2012-07-05 13:26:47 UTC
Size:
2.31 KB
patch
obsolete
>Index: src/java/org/apache/poi/hssf/model/InternalWorkbook.java >=================================================================== >--- src/java/org/apache/poi/hssf/model/InternalWorkbook.java (revision 1357535) >+++ src/java/org/apache/poi/hssf/model/InternalWorkbook.java (working copy) >@@ -624,9 +624,16 @@ > */ > > public void setSheetOrder(String sheetname, int pos ) { >- int sheetNumber = getSheetIndex(sheetname); >- //remove the sheet that needs to be reordered and place it in the spot we want >- boundsheets.add(pos, boundsheets.remove(sheetNumber)); >+ int sheetNumber = getSheetIndex(sheetname); >+ //remove the sheet that needs to be reordered and place it in the spot we want >+ boundsheets.add(pos, boundsheets.remove(sheetNumber)); >+ //reorder records list as well >+ int baseIndx = records.getBspos() - (boundsheets.size() - 1); >+ int recIndx = baseIndx + sheetNumber; >+ int recNewIndx = baseIndx + pos; >+ Record rec = records.get(recIndx); >+ records.remove(recIndx); >+ records.add(recNewIndx, rec); > } > > /** >Index: src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java >=================================================================== >--- src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (revision 1357535) >+++ src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (working copy) >@@ -2238,4 +2238,26 @@ > // make sure we are still readable > writeOutAndReadBack(workbook); > } >+ >+ /** >+ * Test case for bug #50083. >+ * If bug is present, test case throws an IllegalArgumentException >+ * on workbook serialization. >+ */ >+ public void test50083() { >+ HSSFWorkbook workbook = new HSSFWorkbook(); >+ Sheet sheet0 = workbook.createSheet("Sheet_00"); >+ >+ Sheet sheet1 = workbook.createSheet("Sheet_1"); >+ >+ //Breaks propper sheet order here. >+ workbook.setSheetOrder(sheet1.getSheetName(), 0); >+ >+ //Deletes wrong sheet record due to the wrong reordering above. >+ workbook.removeSheetAt(0); >+ >+ //Exception gets thrown here because of incorrect data is supplied >+ //when calculating output buffer size on workbook serialization. >+ writeOutAndReadBack(workbook); >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 50083
:
27231
|
28685
|
29024
| 29034