poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r744253 - in /poi/trunk/src: documentation/content/xdocs/ java/org/apache/poi/hssf/usermodel/ ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/ ooxml/java/org/apache/poi/xssf/usermodel/ testcases/org/apache/poi/hssf/usermodel/
Date Fri, 13 Feb 2009 21:46:45 GMT
Author: josh
Date: Fri Feb 13 21:46:44 2009
New Revision: 744253

URL: http://svn.apache.org/viewvc?rev=744253&view=rev
Log:
Bugzilla 46660 - added 'hidden' property to Workbook

Modified:
    poi/trunk/src/documentation/content/xdocs/changes.xml
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
    poi/trunk/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java

Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=744253&r1=744252&r2=744253&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Fri Feb 13 21:46:44 2009
@@ -37,6 +37,7 @@
 
 		<!-- 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>

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=744253&r1=744252&r2=744253&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Fri Feb 13 21:46:44 2009
@@ -34,6 +34,7 @@
 	<!-- 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>

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java?rev=744253&r1=744252&r2=744253&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java Fri Feb 13 21:46:44
2009
@@ -537,88 +537,55 @@
     }
 
     /**
-     * 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;
@@ -628,7 +595,6 @@
     }
 
     /**
-<<<<<<< .working
      * Returns the external sheet index of the sheet
      *  with the given internal index, creating one
      *  if needed.

Modified: poi/trunk/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java?rev=744253&r1=744252&r2=744253&view=diff
==============================================================================
--- poi/trunk/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java (original)
+++ poi/trunk/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java Fri Feb
13 21:46:44 2009
@@ -412,15 +412,25 @@
     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>
      * Note that a sheet could instead be set to be very hidden, which is different
      *  ({@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.
@@ -452,5 +462,4 @@
      * @param hidden 0 for not hidden, 1 for hidden, 2 for very hidden
      */
     void setSheetHidden(int sheetIx, int hidden);
-    
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java?rev=744253&r1=744252&r2=744253&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java Fri Feb 13 21:46:44
2009
@@ -129,7 +129,7 @@
      *  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
@@ -514,7 +514,7 @@
         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){
@@ -788,7 +788,7 @@
      *  {@link MissingCellPolicy}
      */
     public MissingCellPolicy getMissingCellPolicy() {
-        return missingCellPolicy;
+        return _missingCellPolicy;
     }
     /**
      * Sets the policy on what to do when
@@ -798,7 +798,7 @@
      *  {@link MissingCellPolicy}
      */
     public void setMissingCellPolicy(MissingCellPolicy missingCellPolicy) {
-        this.missingCellPolicy = missingCellPolicy;
+        _missingCellPolicy = missingCellPolicy;
     }
 
     /**
@@ -1077,7 +1077,7 @@
 
         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);
 
@@ -1208,59 +1208,33 @@
         }
         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;

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java?rev=744253&r1=744252&r2=744253&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java Fri Feb 13
21:46:44 2009
@@ -32,6 +32,7 @@
 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;
@@ -118,6 +119,33 @@
             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();



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message