poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r1139288 - in /poi/trunk/src: documentation/content/xdocs/ ooxml/java/org/apache/poi/xssf/usermodel/ ooxml/testcases/org/apache/poi/xssf/usermodel/ testcases/org/apache/poi/ss/usermodel/
Date Fri, 24 Jun 2011 13:06:04 GMT
Author: yegor
Date: Fri Jun 24 13:06:04 2011
New Revision: 1139288

URL: http://svn.apache.org/viewvc?rev=1139288&view=rev
Log:
Bug  49564 - Fixed default behaviour of XSSFCellStyle.getLocked()

Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=1139288&r1=1139287&r2=1139288&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Fri Jun 24 13:06:04 2011
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.8-beta4" date="2011-??-??">
+           <action dev="poi-developers" type="fix">49564 - Fixed default behaviour
of XSSFCellStyle.getLocked() </action>
            <action dev="poi-developers" type="fix">48314 - Fixed setting column and
row breaks in XSSF</action>
            <action dev="poi-developers" type="add">51424 - Ignore exceptions in ParagraphSprmUncompressor</action>
            <action dev="poi-developers" type="fix">51415 - Fixed Workbook.createSheet(sheetName)
to truncate names longer than 31 characters</action>

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java?rev=1139288&r1=1139287&r2=1139288&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java Fri Jun 24 13:06:04
2011
@@ -565,7 +565,10 @@ public class XSSFCellStyle implements Ce
      * @return boolean -  whether the cell using this style is hidden
      */
     public boolean getHidden() {
-        return getCellProtection().getHidden();
+        if (!_cellXf.isSetProtection() || !_cellXf.getProtection().isSetHidden()) {
+            return false;
+        }
+        return _cellXf.getProtection().getHidden();
     }
 
     /**
@@ -619,7 +622,10 @@ public class XSSFCellStyle implements Ce
      * @return whether the cell using this style are locked
      */
     public boolean getLocked() {
-        return getCellProtection().getLocked();
+        if (!_cellXf.isSetProtection() || !_cellXf.getProtection().isSetLocked()) {
+            return true;
+        }
+        return _cellXf.getProtection().getLocked();
     }
 
     /**
@@ -1169,7 +1175,10 @@ public class XSSFCellStyle implements Ce
      * @param hidden - whether the cell using this style should be hidden
      */
     public void setHidden(boolean hidden) {
-        getCellProtection().setHidden(hidden);
+        if (!_cellXf.isSetProtection()) {
+             _cellXf.addNewProtection();
+         }
+        _cellXf.getProtection().setHidden(hidden);
     }
 
     /**
@@ -1218,7 +1227,10 @@ public class XSSFCellStyle implements Ce
      * @param locked -  whether the cell using this style should be locked
      */
     public void setLocked(boolean locked) {
-        getCellProtection().setLocked(locked);
+        if (!_cellXf.isSetProtection()) {
+             _cellXf.addNewProtection();
+         }
+        _cellXf.getProtection().setLocked(locked);
     }
 
     /**
@@ -1389,17 +1401,6 @@ public class XSSFCellStyle implements Ce
     }
 
     /**
-     * get a cellProtection from the supplied XML definition
-     * @return CTCellProtection
-     */
-    private CTCellProtection getCellProtection() {
-        if (_cellXf.getProtection() == null) {
-            _cellXf.addNewProtection();
-        }
-        return _cellXf.getProtection();
-    }
-
-    /**
      * get the cellAlignment object to use for manage alignment
      * @return XSSFCellAlignment - cell alignment
      */

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java?rev=1139288&r1=1139287&r2=1139288&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java Fri
Jun 24 13:06:04 2011
@@ -526,15 +526,15 @@ public class TestXSSFCellStyle extends T
 
 	public void testGetSetHidden() {
 		assertFalse(cellStyle.getHidden());
-		cellXf.getProtection().setHidden(true);
+		cellStyle.setHidden(true);
 		assertTrue(cellStyle.getHidden());
 		cellStyle.setHidden(false);
 		assertFalse(cellStyle.getHidden());
 	}
 
 	public void testGetSetLocked() {
-		assertFalse(cellStyle.getLocked());
-		cellXf.getProtection().setLocked(true);
+		assertTrue(cellStyle.getLocked());
+		cellStyle.setLocked(true);
 		assertTrue(cellStyle.getLocked());
 		cellStyle.setLocked(false);
 		assertFalse(cellStyle.getLocked());

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java?rev=1139288&r1=1139287&r2=1139288&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java Fri Jun 24 13:06:04
2011
@@ -544,4 +544,39 @@ public abstract class BaseTestCell exten
         assertEquals(Cell.CELL_TYPE_ERROR, cell2.getCellType());
         assertEquals(ErrorConstants.ERROR_DIV_0, cell2.getErrorCellValue());
     }
+
+    public void testDefaultStyleProperties() {
+        Workbook wb = _testDataProvider.createWorkbook();
+
+        Cell cell = wb.createSheet("Sheet1").createRow(0).createCell(0);
+        CellStyle style = cell.getCellStyle();
+
+        assertTrue(style.getLocked());
+        assertFalse(style.getHidden());
+        assertEquals(0, style.getIndention());
+        assertEquals(0, style.getFontIndex());
+        assertEquals(0, style.getAlignment());
+        assertEquals(0, style.getDataFormat());
+        assertEquals(false, style.getWrapText());
+
+        CellStyle style2 = wb.createCellStyle();
+        assertTrue(style2.getLocked());
+        assertFalse(style2.getHidden());
+        style2.setLocked(false);
+        style2.setHidden(true);
+        assertFalse(style2.getLocked());
+        assertTrue(style2.getHidden());
+
+        wb = _testDataProvider.writeOutAndReadBack(wb);
+        cell = wb.getSheetAt(0).getRow(0).getCell(0);
+        style = cell.getCellStyle();
+        assertFalse(style2.getLocked());
+        assertTrue(style2.getHidden());
+
+        style2.setLocked(true);
+        style2.setHidden(false);
+        assertTrue(style2.getLocked());
+        assertFalse(style2.getHidden());
+    }
+
 }



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


Mime
View raw message