<!-- Don't forget to update status.xml too! -->
<release version="3.5-beta6" date="2008-??-??">
+ <action dev="POI-DEVELOPERS" type="add">46660 - added Workbook getHidden() and setHidden(boolean)</action>
<action dev="POI-DEVELOPERS" type="fix">46693 - Fixed bugs serialization bugs in records: CHARTFORMAT, SHTPROPS, SXVD and SXVDEX</action>
<action dev="POI-DEVELOPERS" type="fix">46627 - Fixed offset of added images if Pictures stream contains pictures with zero length</action>
</release>
<!-- Don't forget to update changes.xml too! -->
<changes>
<release version="3.5-beta6" date="2008-??-??">
+ <action dev="POI-DEVELOPERS" type="add">46660 - added Workbook getHidden() and setHidden(boolean)</action>
<action dev="POI-DEVELOPERS" type="fix">46693 - Fixed bugs serialization bugs in records: CHARTFORMAT, SHTPROPS, SXVD and SXVDEX</action>
<action dev="POI-DEVELOPERS" type="fix">46627 - Fixed offset of added images if Pictures stream contains pictures with zero length</action>
</release>
}
/**
- * get the sheet name
- * @param sheetIx Number
- * @return Sheet name
+ * @return Sheet name for the specified index
*/
- public String getSheetName(int sheetIx)
- {
- validateSheetIndex(sheetIx);
- return workbook.getSheetName(sheetIx);
+ public String getSheetName(int sheetIndex) {
+ validateSheetIndex(sheetIndex);
+ return workbook.getSheetName(sheetIndex);
}
- /**
- * Check whether a sheet is hidden.
- * Note that a sheet could instead be
- * set to be very hidden, which is different
- * ({@link #isSheetVeryHidden(int)})
- * @param sheetIx Number
- * @return True if sheet is hidden
- */
+ public boolean isHidden() {
+ return workbook.getWindowOne().getHidden();
+ }
+
+ public void setHidden(boolean hiddenFlag) {
+ workbook.getWindowOne().setHidden(hiddenFlag);
+ }
+
public boolean isSheetHidden(int sheetIx) {
validateSheetIndex(sheetIx);
return workbook.isSheetHidden(sheetIx);
}
- /**
- * Check whether a sheet is very hidden.
- * This is different from the normal
- * hidden status
- * ({@link #isSheetHidden(int)})
- * @param sheetIx Number
- * @return True if sheet is very hidden
- */
+
public boolean isSheetVeryHidden(int sheetIx) {
validateSheetIndex(sheetIx);
return workbook.isSheetVeryHidden(sheetIx);
}
- /**
- * Hide or unhide a sheet
- *
- * @param sheetIx The sheet index
- * @param hidden True to mark the sheet as hidden, false otherwise
- */
+
public void setSheetHidden(int sheetIx, boolean hidden) {
validateSheetIndex(sheetIx);
workbook.setSheetHidden(sheetIx, hidden);
}
- /**
- * Hide or unhide a sheet.
- * 0 = not hidden
- * 1 = hidden
- * 2 = very hidden.
- *
- * @param sheetIx The sheet number
- * @param hidden 0 for not hidden, 1 for hidden, 2 for very hidden
- */
+
public void setSheetHidden(int sheetIx, int hidden) {
validateSheetIndex(sheetIx);
workbook.setSheetHidden(sheetIx, hidden);
}
- /*
- * get the sheet's index
- * @param name sheet name
- * @return sheet index or -1 if it was not found.
- */
-
/** Returns the index of the sheet by his name
* @param name the sheet name
* @return index of the sheet (0 based)
*/
- public int getSheetIndex(String name)
- {
- int retval = workbook.getSheetIndex(name);
-
- return retval;
+ public int getSheetIndex(String name){
+ return workbook.getSheetIndex(name);
}
/** Returns the index of the given sheet
* @param sheet the sheet to look up
* @return index of the sheet (0 based). <tt>-1</tt> if not found
*/
- public int getSheetIndex(org.apache.poi.ss.usermodel.Sheet sheet)
- {
+ public int getSheetIndex(org.apache.poi.ss.usermodel.Sheet sheet) {
for(int i=0; i<_sheets.size(); i++) {
if(_sheets.get(i) == sheet) {
return i;
}
/**
-<<<<<<< .working
* Returns the external sheet index of the sheet
* with the given internal index, creating one
* if needed.
*/
CreationHelper getCreationHelper();
+ /**
+ * @return <code>false</code> if this workbook is not visible in the GUI
+ */
+ boolean isHidden();
+
+ /**
+ * @param hiddenFlag pass <code>false</code> to make the workbook visible in the GUI
+ */
+ void setHidden(boolean hiddenFlag);
+
/**
* Check whether a sheet is hidden.
* <p>
* ({@link #isSheetVeryHidden(int)})
* </p>
* @param sheetIx Number
- * @return True if sheet is hidden
+ * @return <code>true</code> if sheet is hidden
*/
- boolean isSheetHidden(int sheetIx) ;
+ boolean isSheetHidden(int sheetIx);
/**
* Check whether a sheet is very hidden.
* @param hidden 0 for not hidden, 1 for hidden, 2 for very hidden
*/
void setSheetHidden(int sheetIx, int hidden);
-
}
* blank cells when fetching from a row.
* See {@link org.apache.poi.ss.usermodel.Row.MissingCellPolicy}
*/
- private MissingCellPolicy missingCellPolicy = Row.RETURN_NULL_AND_BLANK;
+ private MissingCellPolicy _missingCellPolicy = Row.RETURN_NULL_AND_BLANK;
/**
* array of pictures for this workbook
if(pictures == null) {
//In OOXML pictures are referred to in sheets,
//dive into sheet's relations, select drawings and their images
- pictures = new ArrayList();
+ pictures = new ArrayList<XSSFPictureData>();
for(XSSFSheet sh : sheets){
for(POIXMLDocumentPart dr : sh.getRelations()){
if(dr instanceof XSSFDrawing){
* {@link MissingCellPolicy}
*/
public MissingCellPolicy getMissingCellPolicy() {
- return missingCellPolicy;
+ return _missingCellPolicy;
}
/**
* Sets the policy on what to do when
* {@link MissingCellPolicy}
*/
public void setMissingCellPolicy(MissingCellPolicy missingCellPolicy) {
- this.missingCellPolicy = missingCellPolicy;
+ _missingCellPolicy = missingCellPolicy;
}
/**
XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
xmlOptions.setSaveSyntheticDocumentElement(new QName(CTWorkbook.type.getName().getNamespaceURI(), "workbook"));
- Map map = new HashMap();
+ Map<String, String> map = new HashMap<String, String>();
map.put(STRelationshipId.type.getName().getNamespaceURI(), "r");
xmlOptions.setSaveSuggestedPrefixes(map);
}
return embedds;
}
+
+ public boolean isHidden() {
+ throw new RuntimeException("Not implemented yet");
+ }
+
+ public void setHidden(boolean hiddenFlag) {
+ throw new RuntimeException("Not implemented yet");
+ }
- /**
- * Check whether a sheet is hidden.
- * Note that a sheet could instead be set to be very hidden, which is different
- * ({@link #isSheetVeryHidden(int)})
- * @param sheetIx Number
- * @return True if sheet is hidden
- * @throws IllegalArgumentException if sheetIx is invalid
- */
public boolean isSheetHidden(int sheetIx) {
validateSheetIndex(sheetIx);
CTSheet ctSheet = sheets.get(sheetIx).sheet;
return ctSheet.getState() == STSheetState.HIDDEN;
}
- /**
- * Check whether a sheet is very hidden.
- * This is different from the normal hidden status ({@link #isSheetHidden(int)})
- * @param sheetIx Number
- * @return True if sheet is very hidden
- * @throws IllegalArgumentException if sheetIx is invalid
- */
public boolean isSheetVeryHidden(int sheetIx) {
validateSheetIndex(sheetIx);
CTSheet ctSheet = sheets.get(sheetIx).sheet;
return ctSheet.getState() == STSheetState.VERY_HIDDEN;
}
- /**
- * Hide or unhide a sheet
- *
- * @param sheetIx The sheet index
- * @param hidden True to mark the sheet as hidden, false otherwise
- * @throws IllegalArgumentException if sheetIx is invalid
- */
public void setSheetHidden(int sheetIx, boolean hidden) {
validateSheetIndex(sheetIx);
CTSheet ctSheet = sheets.get(sheetIx).sheet;
ctSheet.setState(hidden ? STSheetState.HIDDEN : STSheetState.VISIBLE);
}
- /**
- * Hide or unhide a sheet.
- * <pre>
- * 0 = not hidden
- * 1 = hidden
- * 2 = very hidden.
- * </pre>
- *
- * @param sheetIx The sheet number
- * @param hidden 0 for not hidden, 1 for hidden, 2 for very hidden
- * @throws IllegalArgumentException if sheetIx is invalid
- */
public void setSheetHidden(int sheetIx, int hidden) {
validateSheetIndex(sheetIx);
CTSheet ctSheet = sheets.get(sheetIx).sheet;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.RecordBase;
import org.apache.poi.hssf.record.RecordFormatException;
+import org.apache.poi.hssf.record.WindowOneRecord;
import org.apache.poi.hssf.record.formula.Area3DPtg;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.TempFile;
fail("WindowOneRecord in Workbook is probably not initialized");
}
}
+
+ /**
+ * Tests for {@link HSSFWorkbook#isHidden()} etc
+ */
+ public void testHidden() {
+ HSSFWorkbook wb = new HSSFWorkbook();
+
+ WindowOneRecord w1 = wb.getWorkbook().getWindowOne();
+
+ assertEquals(false, wb.isHidden());
+ assertEquals(false, w1.getHidden());
+
+ wb.setHidden(true);
+ assertEquals(true, wb.isHidden());
+ assertEquals(true, w1.getHidden());
+
+ wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
+ w1 = wb.getWorkbook().getWindowOne();
+
+ wb.setHidden(true);
+ assertEquals(true, wb.isHidden());
+ assertEquals(true, w1.getHidden());
+
+ wb.setHidden(false);
+ assertEquals(false, wb.isHidden());
+ assertEquals(false, w1.getHidden());
+ }
public void testSheetSelection() {
HSSFWorkbook b = new HSSFWorkbook();