ASF Bugzilla – Attachment 22637 Details for
Bug 45894
patch XSSFWorkbook
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
XSSFWorkbook allows duplicate sheet names
20080925XSSFWorkbook.diff (text/plain), 3.04 KB, created by
Gisella Bronzetti
on 2008-09-25 08:46:47 UTC
(
hide
)
Description:
XSSFWorkbook allows duplicate sheet names
Filename:
MIME Type:
Creator:
Gisella Bronzetti
Created:
2008-09-25 08:46:47 UTC
Size:
3.04 KB
patch
obsolete
>Index: src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java >=================================================================== >--- src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java (revision 698947) >+++ src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java (working copy) >@@ -242,7 +242,7 @@ > public void testFindFont(){ > //get dafault font and check against default value > XSSFWorkbook workbook = new XSSFWorkbook(); >- Font fontFind=workbook.findFont(Font.BOLDWEIGHT_NORMAL, IndexedColors.BLACK.getIndex(), (short)11, "Calibri", false, false, Font.SS_NONE, Font.U_NONE); >+ Font fontFind=workbook.findFont(Font.BOLDWEIGHT_NORMAL, Font.COLOR_NORMAL, (short)11, "Calibri", false, false, Font.SS_NONE, Font.U_NONE); > assertNotNull(fontFind); > > //get default font, then change 2 values and check against different values (height changes) >@@ -251,8 +251,9 @@ > font.setUnderline(Font.U_DOUBLE); > StylesSource styleSource=new StylesTable(); > long index=styleSource.putFont(font); >+ System.out.println("index="+index); > workbook.setStylesSource(styleSource); >- fontFind=workbook.findFont(Font.BOLDWEIGHT_BOLD, IndexedColors.BLACK.getIndex(), (short)15, "Calibri", false, false, Font.SS_NONE, Font.U_DOUBLE); >+ fontFind=workbook.findFont(Font.BOLDWEIGHT_BOLD, Font.COLOR_NORMAL, (short)15, "Calibri", false, false, Font.SS_NONE, Font.U_DOUBLE); > assertNull(fontFind); > } > >@@ -290,7 +291,6 @@ > assertNotNull(fontAt); > } > >- > public void testGetNumberOfFonts(){ > XSSFWorkbook wb = new XSSFWorkbook(); > >Index: src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java >=================================================================== >--- src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (revision 698947) >+++ src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (working copy) >@@ -287,6 +287,8 @@ > } > > public XSSFSheet createSheet(String sheetname) { >+ if (doesContainsSheetName( sheetname, sheets.size() )) >+ throw new IllegalArgumentException( "The workbook already contains a sheet of this name" ); > return createSheet(sheetname, XSSFSheet.newSheetInstance()); > } > >@@ -588,6 +590,8 @@ > } > > public void setSheetName(int sheet, String name) { >+ if (doesContainsSheetName(name, sheet )) >+ throw new IllegalArgumentException( "The workbook already contains a sheet of this name" ); > this.workbook.getSheets().getSheetArray(sheet).setName(name); > } > >@@ -765,4 +769,14 @@ > public CreationHelper getCreationHelper() { > return new XSSFCreationHelper(this); > } >+ >+ public boolean doesContainsSheetName( String name, int excludeSheetIdx ){ >+ CTSheet[] ctSheetArray=workbook.getSheets().getSheetArray(); >+ for ( int i = 0; i < ctSheetArray.length; i++ ) { >+ if (excludeSheetIdx != i && name.equalsIgnoreCase(ctSheetArray[i].getName())) >+ return true; >+ } >+ return false; >+ } >+ > }
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 45894
: 22637