Fix for Bug#28328
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353773 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5748dfe392
commit
f3df5ee67f
@ -100,6 +100,7 @@ public class Workbook implements Model
|
|||||||
private boolean uses1904datewindowing = false; // whether 1904 date windowing is being used
|
private boolean uses1904datewindowing = false; // whether 1904 date windowing is being used
|
||||||
private DrawingManager2 drawingManager;
|
private DrawingManager2 drawingManager;
|
||||||
private List escherBSERecords = new ArrayList(); // EscherBSERecord
|
private List escherBSERecords = new ArrayList(); // EscherBSERecord
|
||||||
|
private WindowOneRecord windowOne;
|
||||||
|
|
||||||
private static POILogger log = POILogFactory.getLogger(Workbook.class);
|
private static POILogger log = POILogFactory.getLogger(Workbook.class);
|
||||||
|
|
||||||
@ -215,6 +216,10 @@ public class Workbook implements Model
|
|||||||
if (log.check( POILogger.DEBUG ))
|
if (log.check( POILogger.DEBUG ))
|
||||||
log.log(DEBUG, "found palette record at " + k);
|
log.log(DEBUG, "found palette record at " + k);
|
||||||
retval.records.setPalettepos( k );
|
retval.records.setPalettepos( k );
|
||||||
|
case WindowOneRecord.sid:
|
||||||
|
if (log.check( POILogger.DEBUG ))
|
||||||
|
log.log(DEBUG, "found WindowOneRecord at " + k);
|
||||||
|
retval.windowOne = (WindowOneRecord) rec;
|
||||||
default :
|
default :
|
||||||
}
|
}
|
||||||
records.add(rec);
|
records.add(rec);
|
||||||
@ -226,6 +231,10 @@ public class Workbook implements Model
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
retval.records.setRecords(records);
|
retval.records.setRecords(records);
|
||||||
|
|
||||||
|
if (retval.windowOne == null) {
|
||||||
|
retval.windowOne = (WindowOneRecord) retval.createWindowOne();
|
||||||
|
}
|
||||||
if (log.check( POILogger.DEBUG ))
|
if (log.check( POILogger.DEBUG ))
|
||||||
log.log(DEBUG, "exit create workbook from existing file function");
|
log.log(DEBUG, "exit create workbook from existing file function");
|
||||||
return retval;
|
return retval;
|
||||||
@ -259,7 +268,8 @@ public class Workbook implements Model
|
|||||||
records.add( retval.createPassword() );
|
records.add( retval.createPassword() );
|
||||||
records.add( retval.createProtectionRev4() );
|
records.add( retval.createProtectionRev4() );
|
||||||
records.add( retval.createPasswordRev4() );
|
records.add( retval.createPasswordRev4() );
|
||||||
records.add( retval.createWindowOne() );
|
retval.windowOne = (WindowOneRecord) retval.createWindowOne();
|
||||||
|
records.add( retval.windowOne );
|
||||||
records.add( retval.createBackup() );
|
records.add( retval.createBackup() );
|
||||||
retval.records.setBackuppos( records.size() - 1 );
|
retval.records.setBackuppos( records.size() - 1 );
|
||||||
records.add( retval.createHideObj() );
|
records.add( retval.createHideObj() );
|
||||||
@ -2164,7 +2174,11 @@ public class Workbook implements Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WindowOneRecord getWindowOne() {
|
||||||
|
return windowOne;
|
||||||
|
}
|
||||||
|
|
||||||
public int addBSERecord(EscherBSERecord e)
|
public int addBSERecord(EscherBSERecord e)
|
||||||
{
|
{
|
||||||
createDrawingGroup();
|
createDrawingGroup();
|
||||||
|
@ -251,6 +251,48 @@ public class HSSFWorkbook
|
|||||||
public void setSheetOrder(String sheetname, int pos ) {
|
public void setSheetOrder(String sheetname, int pos ) {
|
||||||
workbook.setSheetOrder(sheetname, pos);
|
workbook.setSheetOrder(sheetname, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets the tab whose data is actually seen when the sheet is opened.
|
||||||
|
* This may be different from the "selected sheet" since excel seems to
|
||||||
|
* allow you to show the data of one sheet when another is seen "selected"
|
||||||
|
* in the tabs (at the bottom).
|
||||||
|
* @see org.apache.poi.hssf.usermodel.HSSFSheet#setSelected(boolean)
|
||||||
|
* @param index
|
||||||
|
*/
|
||||||
|
public void setSelectedTab(short index) {
|
||||||
|
workbook.getWindowOne().setSelectedTab(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets the tab whose data is actually seen when the sheet is opened.
|
||||||
|
* This may be different from the "selected sheet" since excel seems to
|
||||||
|
* allow you to show the data of one sheet when another is seen "selected"
|
||||||
|
* in the tabs (at the bottom).
|
||||||
|
* @see org.apache.poi.hssf.usermodel.HSSFSheet#setSelected(boolean)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public short getSelectedTab() {
|
||||||
|
return workbook.getWindowOne().getSelectedTab();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets the first tab that is displayed in the list of tabs
|
||||||
|
* in excel.
|
||||||
|
* @param index
|
||||||
|
*/
|
||||||
|
public void setDisplayedTab(short index) {
|
||||||
|
workbook.getWindowOne().setDisplayedTab(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets the first tab that is displayed in the list of tabs
|
||||||
|
* in excel.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public short getDisplayedTab() {
|
||||||
|
return workbook.getWindowOne().getDisplayedTab();
|
||||||
|
}
|
||||||
|
|
||||||
public final static byte ENCODING_COMPRESSED_UNICODE = 0;
|
public final static byte ENCODING_COMPRESSED_UNICODE = 0;
|
||||||
public final static byte ENCODING_UTF_16 = 1;
|
public final static byte ENCODING_UTF_16 = 1;
|
||||||
|
@ -64,4 +64,24 @@ public class TestHSSFWorkbook extends TestCase
|
|||||||
c.createSheet("Sheet4");
|
c.createSheet("Sheet4");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testWindowOneDefaults() {
|
||||||
|
HSSFWorkbook b = new HSSFWorkbook( );
|
||||||
|
try {
|
||||||
|
assertEquals(b.getSelectedTab(), 0);
|
||||||
|
assertEquals(b.getDisplayedTab(), 0);
|
||||||
|
} catch (NullPointerException npe) {
|
||||||
|
fail("WindowOneRecord in Workbook is probably not initialized");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSheetSelection() {
|
||||||
|
HSSFWorkbook b = new HSSFWorkbook();
|
||||||
|
b.createSheet("Sheet One");
|
||||||
|
HSSFSheet s = b.createSheet("Sheet Two");
|
||||||
|
b.setSelectedTab((short) 1);
|
||||||
|
b.setDisplayedTab((short) 1);
|
||||||
|
assertEquals(b.getSelectedTab(), 1);
|
||||||
|
assertEquals(b.getDisplayedTab(), 1);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user