From janetmason@example.net Sun Oct 04 10:01:27 2009 Return-Path: <janetmason@example.net> Delivered-To: janetmason@example.net Received: (qmail 59188 invoked from network); 4 Oct 2009 10:01:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 4 Oct 2009 10:01:26 -0000 Received: (qmail 18593 invoked by uid 500); 4 Oct 2009 10:01:26 -0000 Delivered-To: janetmason@example.net Received: (qmail 18557 invoked by uid 500); 4 Oct 2009 10:01:26 -0000 Mailing-List: contact janetmason@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:janetmason@example.net> List-Unsubscribe: <mailto:janetmason@example.net> List-Post: <mailto:janetmason@example.net> List-Id: <commits.poi.apache.org> Reply-To: janetmason@example.net Delivered-To: mailing list janetmason@example.net Received: (qmail 18542 invoked by uid 99); 4 Oct 2009 10:01:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Oct 2009 10:01:26 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Oct 2009 10:01:14 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 45C81238889D; Sun, 4 Oct 2009 10:00:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r821496 - in /poi/trunk/src: examples/src/org/apache/poi/xssf/usermodel/examples/WorkbookProperties.java ooxml/java/org/apache/poi/POIXMLProperties.java ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java Date: Sun, 04 Oct 2009 10:00:53 -0000 To: janetmason@example.net From: janetmason@example.net X-Mailer: svnmailer-1.0.8 Message-Id: <janetmason@example.net> X-Virus-Checked: Checked by ClamAV on apache.org Author: yegor Date: Sun Oct 4 10:00:52 2009 New Revision: 821496 URL: http://svn.apache.org/viewvc?rev=821496&view=rev Log: improved API for OOXML custom properties Modified: poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkbookProperties.java poi/trunk/src/ooxml/java/org/apache/poi/POIXMLProperties.java poi/trunk/src/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java Modified: poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkbookProperties.java URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkbookProperties.java?rev=821496&r1=821495&r2=821496&view=diff ============================================================================== --- poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkbookProperties.java (original) +++ poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkbookProperties.java Sun Oct 4 10:00:52 2009 @@ -47,24 +47,15 @@ ext.getUnderlyingProperties().setTemplate("XSSF"); /** - * Custom properties enable users to define custom metadata properties - * through a set of well-defined data types. For example, a custom - * OLE Editor property of type string can be defined as follows: - * - * <property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="Editor"> - * <vt:lpwstr>John Smith</vt:lpwstr> - * </property> + * Custom properties enable users to define custom metadata properties. */ POIXMLProperties.CustomProperties cust = props.getCustomProperties(); - org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperty - property = cust.getUnderlyingProperties().addNewProperty(); + cust.addProperty("Author", "John Smith"); + cust.addProperty("Year", 2009); + cust.addProperty("Price", 45.50); + cust.addProperty("Available", true); - property.setFmtid("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"); - property.setPid(2); - property.setName("Editor"); - property.setLpwstr("John Smith"); - FileOutputStream out = new FileOutputStream("workbook.xlsx"); workbook.write(out); out.close(); Modified: poi/trunk/src/ooxml/java/org/apache/poi/POIXMLProperties.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/POIXMLProperties.java?rev=821496&r1=821495&r2=821496&view=diff ============================================================================== --- poi/trunk/src/ooxml/java/org/apache/poi/POIXMLProperties.java (original) +++ poi/trunk/src/ooxml/java/org/apache/poi/POIXMLProperties.java Sun Oct 4 10:00:52 2009 @@ -34,6 +34,7 @@ import org.apache.poi.openxml4j.util.Nullable; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlOptions; +import org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperty; /** * Wrapper around the two different kinds of OOXML properties @@ -150,8 +151,14 @@ out.close(); } if(custPart != null){ + XmlOptions xmlOptions = new XmlOptions(POIXMLDocumentPart.DEFAULT_XML_OPTIONS); + + Map<String, String> map = new HashMap<String, String>(); + map.put("http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes", "vt"); + xmlOptions.setSaveSuggestedPrefixes(map); + OutputStream out = custPart.getOutputStream(); - cust.props.save(out, POIXMLDocumentPart.DEFAULT_XML_OPTIONS); + cust.props.save(out, xmlOptions); out.close(); } } @@ -271,10 +278,16 @@ } /** - * Custom document properties + * Custom document properties */ public class CustomProperties { - private org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument props; + /** + * Each custom property element contains an fmtid attribute + * with the same GUID value ({D5CDD505-2E9C-101B-9397-08002B2CF9AE}). + */ + public static final String FORMAT_ID = "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"; + + private org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument props; private CustomProperties(org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument props) { this.props = props; } @@ -282,5 +295,91 @@ public org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperties getUnderlyingProperties() { return props.getProperties(); } - } + + /** + * Add a new property + * + * @param name the property name + * @throws IllegalArgumentException if a property with this name already exists + */ + private CTProperty add(String name) { + if(contains(name)) { + throw new IllegalArgumentException("A property with this name " + + "already exists in the custom properties"); + } + + CTProperty p = props.getProperties().addNewProperty(); + int pid = nextPid(); + p.setPid(pid); + p.setFmtid(FORMAT_ID); + p.setName(name); + return p; + } + + /** + * Add a new string property + * + * @throws IllegalArgumentException if a property with this name already exists + */ + public void addProperty(String name, String value){ + CTProperty p = add(name); + p.setLpwstr(value); + } + + /** + * Add a new double property + * + * @throws IllegalArgumentException if a property with this name already exists + */ + public void addProperty(String name, double value){ + CTProperty p = add(name); + p.setR8(value); + } + + /** + * Add a new integer property + * + * @throws IllegalArgumentException if a property with this name already exists + */ + public void addProperty(String name, int value){ + CTProperty p = add(name); + p.setI4(value); + } + + /** + * Add a new boolean property + * + * @throws IllegalArgumentException if a property with this name already exists + */ + public void addProperty(String name, boolean value){ + CTProperty p = add(name); + p.setBool(value); + } + + /** + * Generate next id that uniquely relates a custom property + * + * @return next property id starting with 2 + */ + protected int nextPid(){ + int propid = 1; + for(CTProperty p : props.getProperties().getPropertyArray()){ + if(p.getPid() > propid) propid = p.getPid(); + } + return propid + 1; + } + + /** + * Check if a property with this name already exists in the collection of custom properties + * + * @param name the name to check + * @return whether a property with the given name exists in the custom properties + */ + public boolean contains(String name){ + for(CTProperty p : props.getProperties().getPropertyArray()){ + if(p.getName().equals(name)) return true; + } + return false; + } + } } Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java?rev=821496&r1=821495&r2=821496&view=diff ============================================================================== --- poi/trunk/src/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java (original) +++ poi/trunk/src/ooxml/testcases/org/apache/poi/TestPOIXMLProperties.java Sun Oct 4 10:00:52 2009 @@ -27,6 +27,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xwpf.XWPFTestDataSamples; import org.apache.poi.xwpf.usermodel.XWPFDocument; +import org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperties; /** * Test setting extended and custom OOXML properties @@ -85,69 +86,57 @@ } - public void testWorkbookCustomProperties() { - XSSFWorkbook workbook = new XSSFWorkbook(); - POIXMLProperties props = workbook.getProperties(); - assertNotNull(props); - - org.apache.poi.POIXMLProperties.CustomProperties properties = - props.getCustomProperties(); - - org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperties - ctProps = properties.getUnderlyingProperties(); - - - org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperty - property = ctProps.addNewProperty(); - - - String fmtid = - "{A1A1A1A1A1A1A1A1-A1A1A1A1-A1A1A1A1-A1A1A1A1-A1A1A1A1A1A1A1A1}"; - int pId = 1; - String name = "testProperty"; - String stringValue = "testValue"; - - - property.setFmtid(fmtid); - property.setPid(pId); - property.setName(name); - property.setBstr(stringValue); - - - property = null; - ctProps = null; - properties = null; - props = null; - - XSSFWorkbook newWorkbook = - XSSFTestDataSamples.writeOutAndReadBack(workbook); - - assertTrue(workbook != newWorkbook); - - - POIXMLProperties newProps = newWorkbook.getProperties(); - assertNotNull(newProps); - org.apache.poi.POIXMLProperties.CustomProperties newProperties = - newProps.getCustomProperties(); - - org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperties - newCtProps = newProperties.getUnderlyingProperties(); - - assertEquals(1, newCtProps.getPropertyArray().length); - - - org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperty - newpProperty = newCtProps.getPropertyArray()[0]; - - assertEquals(fmtid, newpProperty.getFmtid()); - assertEquals(pId, newpProperty.getPid()); - assertEquals(name, newpProperty.getName()); - assertEquals(stringValue, newpProperty.getBstr()); - - - } + /** + * Test usermodel API for setting custom properties + */ + public void testCustomProperties() { + POIXMLDocument wb = new XSSFWorkbook(); + + POIXMLProperties.CustomProperties customProps = wb.getProperties().getCustomProperties(); + customProps.addProperty("test-1", "string val"); + customProps.addProperty("test-2", 1974); + customProps.addProperty("test-3", 36.6); + //adding a duplicate + try { + customProps.addProperty("test-3", 36.6); + fail("expected exception"); + } catch(IllegalArgumentException e){ + assertEquals("A property with this name already exists in the custom properties", e.getMessage()); + } + customProps.addProperty("test-4", true); + + wb = XSSFTestDataSamples.writeOutAndReadBack((XSSFWorkbook)wb); + org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperties ctProps = + wb.getProperties().getCustomProperties().getUnderlyingProperties(); + assertEquals(4, ctProps.sizeOfPropertyArray()); + org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperty p; + + p = ctProps.getPropertyArray(0); + assertEquals("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}", p.getFmtid()); + assertEquals("test-1", p.getName()); + assertEquals("string val", p.getLpwstr()); + assertEquals(2, p.getPid()); + + p = ctProps.getPropertyArray(1); + assertEquals("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}", p.getFmtid()); + assertEquals("test-2", p.getName()); + assertEquals(1974, p.getI4()); + assertEquals(3, p.getPid()); + + p = ctProps.getPropertyArray(2); + assertEquals("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}", p.getFmtid()); + assertEquals("test-3", p.getName()); + assertEquals(36.6, p.getR8()); + assertEquals(4, p.getPid()); + + p = ctProps.getPropertyArray(3); + assertEquals("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}", p.getFmtid()); + assertEquals("test-4", p.getName()); + assertEquals(true, p.getBool()); + assertEquals(5, p.getPid()); + } - public void testDocumentProperties() { + public void testDocumentProperties() { String category = _coreProperties.getCategory(); assertEquals("test", category); String contentStatus = "Draft"; --------------------------------------------------------------------- To unsubscribe, e-mail: janetmason@example.net For additional commands, e-mail: janetmason@example.net From janetmason@example.net Sun Oct 04 10:09:12 2009 Return-Path: <janetmason@example.net> Delivered-To: janetmason@example.net Received: (qmail 59884 invoked from network); 4 Oct 2009 10:09:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 4 Oct 2009 10:09:12 -0000 Received: (qmail 19778 invoked by uid 500); 4 Oct 2009 10:09:12 -0000 Delivered-To: janetmason@example.net Received: (qmail 19747 invoked by uid 500); 4 Oct 2009 10:09:12 -0000 Mailing-List: contact janetmason@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:janetmason@example.net> List-Unsubscribe: <mailto:janetmason@example.net> List-Post: <mailto:janetmason@example.net> List-Id: <commits.poi.apache.org> Reply-To: janetmason@example.net Delivered-To: mailing list janetmason@example.net Received: (qmail 19738 invoked by uid 99); 4 Oct 2009 10:09:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Oct 2009 10:09:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Oct 2009 10:09:09 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 18AC92388865; Sun, 4 Oct 2009 10:08:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r821497 - in /poi/trunk: src/documentation/content/xdocs/ src/ooxml/java/org/apache/poi/xssf/usermodel/ src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ src/ooxml/testcases/org/apache/poi/xssf/usermodel/ test-data/spreadsheet/ Date: Sun, 04 Oct 2009 10:08:47 -0000 To: janetmason@example.net From: janetmason@example.net X-Mailer: svnmailer-1.0.8 Message-Id: <janetmason@example.net> X-Virus-Checked: Checked by ClamAV on apache.org Author: yegor Date: Sun Oct 4 10:08:47 2009 New Revision: 821497 URL: http://svn.apache.org/viewvc?rev=821497&view=rev Log: fixed ColumnHelper to correctly handle columns included in a column span Added: poi/trunk/test-data/spreadsheet/47804.xlsx (with props) poi/trunk/test-data/spreadsheet/47862.xlsx (with props) Modified: poi/trunk/src/documentation/content/xdocs/status.xml poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.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=821497&r1=821496&r2=821497&view=diff ============================================================================== --- poi/trunk/src/documentation/content/xdocs/status.xml (original) +++ poi/trunk/src/documentation/content/xdocs/status.xml Sun Oct 4 10:08:47 2009 @@ -33,6 +33,9 @@ <changes> <release version="3.6-beta1" date="2009-??-??"> + <action dev="POI-DEVELOPERS" type="add">47839 - improved API for OOXML custom properties</action> + <action dev="POI-DEVELOPERS" type="fix">47862 - fixed XSSFSheet.setColumnWidth to handle columns included in a column span</action> + <action dev="POI-DEVELOPERS" type="fix">47804 - fixed XSSFSheet.setColumnHidden to handle columns included in a column span</action> <action dev="POI-DEVELOPERS" type="fix">47889 - fixed XSSFCell.getStringCellValue() to properly handle cached formula results</action> </release> <release version="3.5-FINAL" date="2009-09-28"> Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=821497&r1=821496&r2=821497&view=diff ============================================================================== --- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (original) +++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Sun Oct 4 10:08:47 2009 @@ -1086,7 +1086,8 @@ * @return hidden - <code>false</code> if the column is visible */ public boolean isColumnHidden(int columnIndex) { - return columnHelper.getColumn(columnIndex, false).getHidden(); + CTCol col = columnHelper.getColumn(columnIndex, false); + return col != null && col.getHidden(); } /** Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java?rev=821497&r1=821496&r2=821497&view=diff ============================================================================== --- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java (original) +++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java Sun Oct 4 10:08:47 2009 @@ -72,7 +72,7 @@ worksheet.setColsArray(0, newCols); } - public void sortColumns(CTCols newCols) { + public static void sortColumns(CTCols newCols) { CTCol[] colArray = newCols.getColArray(); Arrays.sort(colArray, new CTColComparator()); newCols.setColArray(colArray); @@ -235,17 +235,17 @@ col.setBestFit(bestFit); } public void setCustomWidth(long index, boolean bestFit) { - CTCol col = getOrCreateColumn1Based(index+1, false); + CTCol col = getOrCreateColumn1Based(index+1, true); col.setCustomWidth(bestFit); } public void setColWidth(long index, double width) { - CTCol col = getOrCreateColumn1Based(index+1, false); + CTCol col = getOrCreateColumn1Based(index+1, true); col.setWidth(width); } public void setColHidden(long index, boolean hidden) { - CTCol col = getOrCreateColumn1Based(index+1, false); + CTCol col = getOrCreateColumn1Based(index+1, true); col.setHidden(hidden); } Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java?rev=821497&r1=821496&r2=821497&view=diff ============================================================================== --- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java (original) +++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java Sun Oct 4 10:08:47 2009 @@ -717,4 +717,130 @@ assertEquals(33.0, col.getWidth(), 0.0); assertTrue(col.getCustomWidth()); } + + /** + * Setting width of a column included in a column span + */ + public void test47862() { + XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("47862.xlsx"); + XSSFSheet sheet = wb.getSheetAt(0); + CTCols cols = sheet.getCTWorksheet().getColsArray(0); + //<cols> + // <col min="1" max="5" width="15.77734375" customWidth="1"/> + //</cols> + + //a span of columns [1,5] + assertEquals(1, cols.sizeOfColArray()); + CTCol col = cols.getColArray(0); + assertEquals(1, col.getMin()); + assertEquals(5, col.getMax()); + double swidth = 15.77734375; //width of columns in the span + assertEquals(swidth, col.getWidth()); + + for (int i = 0; i < 5; i++) { + assertEquals((int)(swidth*256), sheet.getColumnWidth(i)); + } + + int[] cw = new int[]{10, 15, 20, 25, 30}; + for (int i = 0; i < 5; i++) { + sheet.setColumnWidth(i, cw[i]*256); + } + + //the check below failed prior to fix of Bug #47862 + ColumnHelper.sortColumns(cols); + //<cols> + // <col min="1" max="1" customWidth="true" width="10.0" /> + // <col min="2" max="2" customWidth="true" width="15.0" /> + // <col min="3" max="3" customWidth="true" width="20.0" /> + // <col min="4" max="4" customWidth="true" width="25.0" /> + // <col min="5" max="5" customWidth="true" width="30.0" /> + //</cols> + + //now the span is splitted into 5 individual columns + assertEquals(5, cols.sizeOfColArray()); + for (int i = 0; i < 5; i++) { + assertEquals(cw[i]*256, sheet.getColumnWidth(i)); + assertEquals((double)cw[i], cols.getColArray(i).getWidth()); + } + + //serialize and check again + wb = getTestDataProvider().writeOutAndReadBack(wb); + sheet = wb.getSheetAt(0); + cols = sheet.getCTWorksheet().getColsArray(0); + assertEquals(5, cols.sizeOfColArray()); + for (int i = 0; i < 5; i++) { + assertEquals(cw[i]*256, sheet.getColumnWidth(i)); + assertEquals((double)cw[i], cols.getColArray(i).getWidth()); + } + } + + /** + * Hiding a column included in a column span + */ + public void test47804() { + XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("47804.xlsx"); + XSSFSheet sheet = wb.getSheetAt(0); + CTCols cols = sheet.getCTWorksheet().getColsArray(0); + assertEquals(2, cols.sizeOfColArray()); + CTCol col; + //<cols> + // <col min="2" max="4" width="12" customWidth="1"/> + // <col min="7" max="7" width="10.85546875" customWidth="1"/> + //</cols> + + //a span of columns [2,4] + col = cols.getColArray(0); + assertEquals(2, col.getMin()); + assertEquals(4, col.getMax()); + //individual column + col = cols.getColArray(1); + assertEquals(7, col.getMin()); + assertEquals(7, col.getMax()); + + sheet.setColumnHidden(2, true); // Column C + sheet.setColumnHidden(6, true); // Column G + + assertTrue(sheet.isColumnHidden(2)); + assertTrue(sheet.isColumnHidden(6)); + + //other columns but C and G are not hidden + assertFalse(sheet.isColumnHidden(1)); + assertFalse(sheet.isColumnHidden(3)); + assertFalse(sheet.isColumnHidden(4)); + assertFalse(sheet.isColumnHidden(5)); + + //the check below failed prior to fix of Bug #47804 + ColumnHelper.sortColumns(cols); + //the span is now splitted into three parts + //<cols> + // <col min="2" max="2" customWidth="true" width="12.0" /> + // <col min="3" max="3" customWidth="true" width="12.0" hidden="true"/> + // <col min="4" max="4" customWidth="true" width="12.0"/> + // <col min="7" max="7" customWidth="true" width="10.85546875" hidden="true"/> + //</cols> + + assertEquals(4, cols.sizeOfColArray()); + col = cols.getColArray(0); + assertEquals(2, col.getMin()); + assertEquals(2, col.getMax()); + col = cols.getColArray(1); + assertEquals(3, col.getMin()); + assertEquals(3, col.getMax()); + col = cols.getColArray(2); + assertEquals(4, col.getMin()); + assertEquals(4, col.getMax()); + col = cols.getColArray(3); + assertEquals(7, col.getMin()); + assertEquals(7, col.getMax()); + + //serialize and check again + wb = getTestDataProvider().writeOutAndReadBack(wb); + sheet = wb.getSheetAt(0); + assertTrue(sheet.isColumnHidden(2)); + assertTrue(sheet.isColumnHidden(6)); + assertFalse(sheet.isColumnHidden(1)); + assertFalse(sheet.isColumnHidden(3)); + assertFalse(sheet.isColumnHidden(4)); + assertFalse(sheet.isColumnHidden(5)); + } } Added: poi/trunk/test-data/spreadsheet/47804.xlsx URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/47804.xlsx?rev=821497&view=auto ============================================================================== Binary file - no diff available. Propchange: poi/trunk/test-data/spreadsheet/47804.xlsx ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: poi/trunk/test-data/spreadsheet/47862.xlsx URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/47862.xlsx?rev=821497&view=auto ============================================================================== Binary file - no diff available. Propchange: poi/trunk/test-data/spreadsheet/47862.xlsx ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream --------------------------------------------------------------------- To unsubscribe, e-mail: janetmason@example.net For additional commands, e-mail: janetmason@example.net From janetmason@example.net Sun Oct 04 10:26:18 2009 Return-Path: <janetmason@example.net> Delivered-To: janetmason@example.net Received: (qmail 61588 invoked from network); 4 Oct 2009 10:26:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 4 Oct 2009 10:26:18 -0000 Received: (qmail 28644 invoked by uid 500); 4 Oct 2009 10:26:18 -0000 Delivered-To: janetmason@example.net Received: (qmail 28610 invoked by uid 500); 4 Oct 2009 10:26:18 -0000 Mailing-List: contact janetmason@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:janetmason@example.net> List-Unsubscribe: <mailto:janetmason@example.net> List-Post: <mailto:janetmason@example.net> List-Id: <commits.poi.apache.org> Reply-To: janetmason@example.net Delivered-To: mailing list janetmason@example.net Received: (qmail 28601 invoked by uid 99); 4 Oct 2009 10:26:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Oct 2009 10:26:18 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Oct 2009 10:26:15 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2DD9F238888F; Sun, 4 Oct 2009 10:25:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r821500 - in /poi/trunk: ./ src/documentation/content/xdocs/ src/scratchpad/examples/src/org/apache/poi/hsmf/ src/scratchpad/examples/src/org/apache/poi/hsmf/examples/ Date: Sun, 04 Oct 2009 10:25:54 -0000 To: janetmason@example.net From: janetmason@example.net X-Mailer: svnmailer-1.0.8 Message-Id: <janetmason@example.net> X-Virus-Checked: Checked by ClamAV on apache.org Author: yegor Date: Sun Oct 4 10:25:53 2009 New Revision: 821500 URL: http://svn.apache.org/viewvc?rev=821500&view=rev Log: added Ant target to compile scratchpad examples, added example HSMF application that converts a .msg file to text and extracts attachments, see Bugzilla 47922 Added: poi/trunk/src/scratchpad/examples/src/org/apache/poi/hsmf/ poi/trunk/src/scratchpad/examples/src/org/apache/poi/hsmf/examples/ poi/trunk/src/scratchpad/examples/src/org/apache/poi/hsmf/examples/Msg2txt.java Modified: poi/trunk/build.xml poi/trunk/src/documentation/content/xdocs/status.xml Modified: poi/trunk/build.xml URL: http://svn.apache.org/viewvc/poi/trunk/build.xml?rev=821500&r1=821499&r2=821500&view=diff ============================================================================== --- poi/trunk/build.xml (original) +++ poi/trunk/build.xml Sun Oct 4 10:25:53 2009 @@ -27,6 +27,7 @@ Modified by: Rainer Klute janetmason@example.net + Bruno Girin janetmason@example.net This build was tested with ant 1.6.2 although it will probably work with other versions. The following jar files should be available on the @@ -110,6 +111,10 @@ <property name="examples.src" location="src/examples/src"/> <property name="examples.output.dir" location="build/examples-classes"/> + <!-- Scratchpad Examples: --> + <property name="scratchpad.examples.src" location="src/scratchpad/examples/src"/> + <property name="scratchpad.examples.output.dir" location="build/scratchpad-examples-classes"/> + <!-- OOXML support: --> <property name="ooxml.src" location="src/ooxml/java"/> <property name="ooxml.src.test" location="src/ooxml/testcases"/> @@ -273,6 +278,7 @@ <mkdir dir="${scratchpad.output.dir}"/> <mkdir dir="${contrib.output.dir}"/> <mkdir dir="${examples.output.dir}"/> + <mkdir dir="${scratchpad.examples.output.dir}"/> <mkdir dir="${ooxml.output.dir}"/> <mkdir dir="${main.output.test.dir}"/> <mkdir dir="${contrib.output.test.dir}"/> @@ -423,8 +429,8 @@ </target> <target name="compile" depends="init, compile-main, - compile-scratchpad, compile-contrib, compile-examples" - description="Compiles the POI main classes, scratchpad, contrib, and examples"/> + compile-scratchpad, compile-contrib, compile-examples, compile-scratchpad-examples" + description="Compiles the POI main classes, scratchpad, contrib, examples, and scratchpad examples"/> <target name="compile-main"> <copy todir="${main.output.dir}"> @@ -508,6 +514,19 @@ </javac> </target> + <target name="compile-scratchpad-examples" depends="init,compile-ooxml"> + <javac target="${jdk.version.class}" source="${jdk.version.source}" + failonerror="true" destdir="${scratchpad.examples.output.dir}" debug="on" fork="yes" + srcdir="${scratchpad.examples.src}"> + <classpath> + <path refid="examples.classpath"/> + <path refid="ooxml.classpath"/> + <pathelement path="${ooxml.output.dir}"/> + <pathelement location="${junit.jar1.dir}"/> + </classpath> + </javac> + </target> + <target name="compile-ooxml" depends="init, compile-main, compile-scratchpad"> <javac target="1.5" source="1.5" destdir="${ooxml.output.dir}" debug="on" srcdir="${ooxml.src}"> Modified: poi/trunk/src/documentation/content/xdocs/status.xml URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=821500&r1=821499&r2=821500&view=diff ============================================================================== --- poi/trunk/src/documentation/content/xdocs/status.xml (original) +++ poi/trunk/src/documentation/content/xdocs/status.xml Sun Oct 4 10:25:53 2009 @@ -33,6 +33,8 @@ <changes> <release version="3.6-beta1" date="2009-??-??"> + <action dev="POI-DEVELOPERS" type="add">47922 - added example HSMF application that converts a .msg file to text and extracts attachments</action> + <action dev="POI-DEVELOPERS" type="add">47903 - added Ant target to compile scratchpad examples</action> <action dev="POI-DEVELOPERS" type="add">47839 - improved API for OOXML custom properties</action> <action dev="POI-DEVELOPERS" type="fix">47862 - fixed XSSFSheet.setColumnWidth to handle columns included in a column span</action> <action dev="POI-DEVELOPERS" type="fix">47804 - fixed XSSFSheet.setColumnHidden to handle columns included in a column span</action> Added: poi/trunk/src/scratchpad/examples/src/org/apache/poi/hsmf/examples/Msg2txt.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/examples/src/org/apache/poi/hsmf/examples/Msg2txt.java?rev=821500&view=auto ============================================================================== --- poi/trunk/src/scratchpad/examples/src/org/apache/poi/hsmf/examples/Msg2txt.java (added) +++ poi/trunk/src/scratchpad/examples/src/org/apache/poi/hsmf/examples/Msg2txt.java Sun Oct 4 10:25:53 2009 @@ -0,0 +1,185 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +package org.apache.poi.hsmf.examples; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.util.Iterator; +import java.util.Map; + +import org.apache.poi.hsmf.MAPIMessage; +import org.apache.poi.hsmf.exceptions.ChunkNotFoundException; + +/** + * Reads one or several Outlook MSG files and for each of them creates + * a text file from available chunks and a directory that contains + * attachments. + * + * @author Bruno Girin + * + */ +public class Msg2txt { + + /** + * The stem used to create file names for the text file and the directory + * that contains the attachments. + */ + private String fileNameStem; + + /** + * The Outlook MSG file being processed. + */ + private MAPIMessage msg; + + public Msg2txt(String fileName) throws IOException { + fileNameStem = fileName; + if(fileNameStem.endsWith(".msg") || fileNameStem.endsWith(".MSG")) { + fileNameStem = fileNameStem.substring(0, fileNameStem.length() - 4); + } + msg = new MAPIMessage(fileName); + } + + /** + * Processes the message. + * + * @throws IOException if an exception occurs while writing the message out + */ + public void processMessage() throws IOException { + String txtFileName = fileNameStem + ".txt"; + String attDirName = fileNameStem + "-att"; + PrintWriter txtOut = null; + try { + txtOut = new PrintWriter(txtFileName); + try { + String displayFrom = msg.getDisplayFrom(); + txtOut.println("From: "+displayFrom); + } catch (ChunkNotFoundException e) { + // ignore + } + try { + String displayTo = msg.getDisplayTo(); + txtOut.println("To: "+displayTo); + } catch (ChunkNotFoundException e) { + // ignore + } + try { + String displayCC = msg.getDisplayCC(); + txtOut.println("CC: "+displayCC); + } catch (ChunkNotFoundException e) { + // ignore + } + try { + String displayBCC = msg.getDisplayBCC(); + txtOut.println("BCC: "+displayBCC); + } catch (ChunkNotFoundException e) { + // ignore + } + try { + String subject = msg.getSubject(); + txtOut.println("Subject: "+subject); + } catch (ChunkNotFoundException e) { + // ignore + } + try { + String body = msg.getTextBody(); + txtOut.println(body); + } catch (ChunkNotFoundException e) { + System.err.println("No message body"); + } + Map attachmentMap = msg.getAttachmentFiles(); + if(attachmentMap.size() > 0) { + File d = new File(attDirName); + if(d.mkdir()) { + for( + Iterator ii = attachmentMap.entrySet().iterator(); + ii.hasNext(); + ) { + Map.Entry entry = (Map.Entry)ii.next(); + processAttachment(d, entry.getKey().toString(), + (ByteArrayInputStream)entry.getValue()); + } + } else { + System.err.println("Can't create directory "+attDirName); + } + } + } finally { + if(txtOut != null) { + txtOut.close(); + } + } + } + + /** + * Processes a single attachment: reads it from the Outlook MSG file and + * writes it to disk as an individual file. + * + * @param dir the directory in which to write the attachment file + * @param fileName the name of the attachment file + * @param fileIn the input stream that contains the attachment's data + * @throws IOException when any of the file operations fails + */ + public void processAttachment(File dir, String fileName, + ByteArrayInputStream fileIn) throws IOException { + File f = new File(dir, fileName); + OutputStream fileOut = null; + try { + fileOut = new FileOutputStream(f); + byte[] buffer = new byte[2048]; + int bNum = fileIn.read(buffer); + while(bNum > 0) { + fileOut.write(buffer); + bNum = fileIn.read(buffer); + } + } finally { + try { + if(fileIn != null) { + fileIn.close(); + } + } finally { + if(fileOut != null) { + fileOut.close(); + } + } + } + } + + /** + * Processes the list of arguments as a list of names of Outlook MSG files. + * + * @param args the list of MSG files to process + */ + public static void main(String[] args) { + if(args.length <= 0) { + System.err.println("No files names provided"); + } else { + for(int i = 0; i < args.length; i++) { + try { + Msg2txt processor = new Msg2txt(args[i]); + processor.processMessage(); + } catch (IOException e) { + System.err.println("Could not process "+args[i]+": "+e); + } + } + } + } + +} --------------------------------------------------------------------- To unsubscribe, e-mail: janetmason@example.net For additional commands, e-mail: janetmason@example.net From janetmason@example.net Sun Oct 04 16:02:03 2009 Return-Path: <janetmason@example.net> Delivered-To: janetmason@example.net Received: (qmail 6992 invoked from network); 4 Oct 2009 16:02:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 4 Oct 2009 16:02:03 -0000 Received: (qmail 357 invoked by uid 500); 4 Oct 2009 16:02:03 -0000 Delivered-To: janetmason@example.net Received: (qmail 320 invoked by uid 500); 4 Oct 2009 16:02:03 -0000 Mailing-List: contact janetmason@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:janetmason@example.net> List-Unsubscribe: <mailto:janetmason@example.net> List-Post: <mailto:janetmason@example.net> List-Id: <commits.poi.apache.org> Reply-To: janetmason@example.net Delivered-To: mailing list janetmason@example.net Received: (qmail 311 invoked by uid 99); 4 Oct 2009 16:02:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Oct 2009 16:02:03 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Oct 2009 16:01:50 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id C5ADF23888D7; Sun, 4 Oct 2009 16:01:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r821551 - in /poi/trunk/src/ooxml: java/org/apache/poi/extractor/ java/org/apache/poi/openxml4j/opc/ java/org/apache/poi/xssf/extractor/ java/org/apache/poi/xssf/usermodel/ java/org/apache/poi/xwpf/model/ java/org/apache/poi/xwpf/usermodel/... Date: Sun, 04 Oct 2009 16:01:29 -0000 To: janetmason@example.net From: janetmason@example.net X-Mailer: svnmailer-1.0.8 Message-Id: <janetmason@example.net> X-Virus-Checked: Checked by ClamAV on apache.org Author: yegor Date: Sun Oct 4 16:01:29 2009 New Revision: 821551 URL: http://svn.apache.org/viewvc?rev=821551&view=rev Log: reduced the number of compiler warnings generated by JDK 1.6.13 with -Xlint Modified: poi/trunk/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/Package.java poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFactory.java poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java poi/trunk/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFactory.java poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePartName.java Modified: poi/trunk/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java?rev=821551&r1=821550&r2=821551&view=diff ============================================================================== --- poi/trunk/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java (original) +++ poi/trunk/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java Sun Oct 4 16:01:29 2009 @@ -152,7 +152,7 @@ */ public static POITextExtractor[] getEmbededDocsTextExtractors(POIOLE2TextExtractor ext) throws IOException { // Find all the embeded directories - ArrayList dirs = new ArrayList(); + ArrayList<Entry> dirs = new ArrayList<Entry>(); POIFSFileSystem fs = ext.getFileSystem(); if(fs == null) { throw new IllegalStateException("The extractor didn't know which POIFS it came from!"); Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/Package.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/Package.java?rev=821551&r1=821550&r2=821551&view=diff ============================================================================== --- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/Package.java (original) +++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/Package.java Sun Oct 4 16:01:29 2009 @@ -37,6 +37,7 @@ * @author Julien Chable, CDubet * */ +@Deprecated public abstract class Package extends OPCPackage { /** @@ -48,7 +49,8 @@ /** * @deprecated use {@link OPCPackage} */ - protected Package(PackageAccess access) { + @Deprecated + protected Package(PackageAccess access) { super(access); } @@ -56,6 +58,7 @@ /** * @deprecated use {@link OPCPackage#open(String)} */ + @Deprecated public static Package open(String path) throws InvalidFormatException { return open(path, defaultPackageAccess); } @@ -63,6 +66,7 @@ /** * @deprecated use {@link OPCPackage#open(String,PackageAccess)} */ + @Deprecated public static Package open(String path, PackageAccess access) throws InvalidFormatException { if (path == null || "".equals(path.trim()) @@ -80,6 +84,7 @@ /** * @deprecated use {@link OPCPackage#open(InputStream)} */ + @Deprecated public static Package open(InputStream in) throws InvalidFormatException, IOException { Package pack = new ZipPackage(in, PackageAccess.READ); @@ -92,6 +97,7 @@ /** * @deprecated use {@link OPCPackage#openOrCreate(java.io.File)} */ + @Deprecated public static Package openOrCreate(File file) throws InvalidFormatException { Package retPackage = null; if (file.exists()) { @@ -105,6 +111,7 @@ /** * @deprecated use {@link OPCPackage#create(String)} */ + @Deprecated public static Package create(String path) { return create(new File(path)); } @@ -112,6 +119,7 @@ /** * @deprecated use {@link OPCPackage#create(File)} */ + @Deprecated public static Package create(File file) { if (file == null || (file.exists() && file.isDirectory())) throw new IllegalArgumentException("file"); @@ -133,6 +141,7 @@ /** * @deprecated use {@link OPCPackage#create(OutputStream)} */ + @Deprecated public static Package create(OutputStream output) { Package pkg = null; pkg = new ZipPackage(); Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java?rev=821551&r1=821550&r2=821551&view=diff ============================================================================== --- poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java (original) +++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java Sun Oct 4 16:01:29 2009 @@ -297,7 +297,7 @@ case XSSFCell.CELL_TYPE_STRING: value = cell.getStringCellValue(); break; case XSSFCell.CELL_TYPE_BOOLEAN: value += cell.getBooleanCellValue(); break; - case XSSFCell.CELL_TYPE_ERROR: value = cell.getErrorCellString(); + case XSSFCell.CELL_TYPE_ERROR: value = cell.getErrorCellString(); break; case XSSFCell.CELL_TYPE_FORMULA: value = cell.getStringCellValue(); break; case XSSFCell.CELL_TYPE_NUMERIC: value += cell.getRawValue(); break; default: ; Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java?rev=821551&r1=821550&r2=821551&view=diff ============================================================================== --- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java (original) +++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java Sun Oct 4 16:01:29 2009 @@ -97,7 +97,7 @@ xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"> */ if(isNew) xmlOptions.setSaveSyntheticDocumentElement(new QName(CTDrawing.type.getName().getNamespaceURI(), "wsDr", "xdr")); - Map map = new HashMap(); + Map<String, String> map = new HashMap<String, String>(); map.put("http://schemas.openxmlformats.org/drawingml/2006/main", "a"); map.put(STRelationshipId.type.getName().getNamespaceURI(), "r"); xmlOptions.setSaveSuggestedPrefixes(map); Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFactory.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFactory.java?rev=821551&r1=821550&r2=821551&view=diff ============================================================================== --- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFactory.java (original) +++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFactory.java Sun Oct 4 16:01:29 2009 @@ -54,7 +54,7 @@ } try { - Class cls = descriptor.getRelationClass(); + Class<? extends POIXMLDocumentPart> cls = descriptor.getRelationClass(); Constructor<? extends POIXMLDocumentPart> constructor = cls.getDeclaredConstructor(PackagePart.class, PackageRelationship.class); return constructor.newInstance(part, rel); } catch (Exception e){ @@ -64,7 +64,7 @@ public POIXMLDocumentPart newDocumentPart(POIXMLRelation descriptor){ try { - Class cls = descriptor.getRelationClass(); + Class<? extends POIXMLDocumentPart> cls = descriptor.getRelationClass(); Constructor<? extends POIXMLDocumentPart> constructor = cls.getDeclaredConstructor(); return constructor.newInstance(); } catch (Exception e){ Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java?rev=821551&r1=821550&r2=821551&view=diff ============================================================================== --- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java (original) +++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java Sun Oct 4 16:01:29 2009 @@ -55,9 +55,10 @@ * @param stabilityClassifier used to optimise caching performance. Pass <code>null</code> * for the (conservative) assumption that any cell may have its definition changed after * evaluation begins. - * @deprecated (Sep 2009) (reduce overloading) use {@link #create(HSSFWorkbook, IStabilityClassifier, UDFFinder)} + * @deprecated (Sep 2009) (reduce overloading) use {@link #create(XSSFWorkbook, org.apache.poi.ss.formula.IStabilityClassifier, org.apache.poi.hssf.record.formula.udf.UDFFinder)} */ - public XSSFFormulaEvaluator(XSSFWorkbook workbook, IStabilityClassifier stabilityClassifier) { + @Deprecated + public XSSFFormulaEvaluator(XSSFWorkbook workbook, IStabilityClassifier stabilityClassifier) { _bookEvaluator = new WorkbookEvaluator(XSSFEvaluationWorkbook.create(workbook), stabilityClassifier, null); } private XSSFFormulaEvaluator(XSSFWorkbook workbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder) { Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=821551&r1=821550&r2=821551&view=diff ============================================================================== --- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (original) +++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Sun Oct 4 16:01:29 2009 @@ -2326,7 +2326,7 @@ XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTWorksheet.type.getName().getNamespaceURI(), "worksheet")); - Map map = new HashMap(); + Map<String, String> map = new HashMap<String, String>(); map.put(STRelationshipId.type.getName().getNamespaceURI(), "r"); xmlOptions.setSaveSuggestedPrefixes(map); Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java?rev=821551&r1=821550&r2=821551&view=diff ============================================================================== --- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java (original) +++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java Sun Oct 4 16:01:29 2009 @@ -263,7 +263,7 @@ private XmlOptions commit(XWPFHeaderFooter wrapper) { XmlOptions xmlOptions = new XmlOptions(wrapper.DEFAULT_XML_OPTIONS); - Map map = new HashMap(); + Map<String, String> map = new HashMap<String, String>(); map.put("http://schemas.openxmlformats.org/officeDocument/2006/math", "m"); map.put("urn:schemas-microsoft-com:office:office", "o"); map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r"); Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java?rev=821551&r1=821550&r2=821551&view=diff ============================================================================== --- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java (original) +++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java Sun Oct 4 16:01:29 2009 @@ -326,7 +326,7 @@ XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTDocument1.type.getName().getNamespaceURI(), "document")); - Map map = new HashMap(); + Map<String, String> map = new HashMap<String, String>(); map.put("http://schemas.openxmlformats.org/officeDocument/2006/math", "m"); map.put("urn:schemas-microsoft-com:office:office", "o"); map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r"); Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFactory.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFactory.java?rev=821551&r1=821550&r2=821551&view=diff ============================================================================== --- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFactory.java (original) +++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFactory.java Sun Oct 4 16:01:29 2009 @@ -53,7 +53,7 @@ } try { - Class cls = descriptor.getRelationClass(); + Class<? extends POIXMLDocumentPart> cls = descriptor.getRelationClass(); Constructor<? extends POIXMLDocumentPart> constructor = cls.getDeclaredConstructor(PackagePart.class, PackageRelationship.class); return constructor.newInstance(part, rel); } catch (Exception e){ @@ -63,7 +63,7 @@ public POIXMLDocumentPart newDocumentPart(POIXMLRelation descriptor){ try { - Class cls = descriptor.getRelationClass(); + Class<? extends POIXMLDocumentPart> cls = descriptor.getRelationClass(); Constructor<? extends POIXMLDocumentPart> constructor = cls.getDeclaredConstructor(); return constructor.newInstance(); } catch (Exception e){ Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePartName.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePartName.java?rev=821551&r1=821550&r2=821551&view=diff ============================================================================== --- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePartName.java (original) +++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCCompliancePartName.java Sun Oct 4 16:01:29 2009 @@ -91,7 +91,7 @@ try { uri = new URI(s); } catch (URISyntaxException e) { - assertTrue(s == "[Content_Types].xml"); + assertTrue(s.equals("[Content_Types].xml")); continue; } assertFalse("This part name SHOULD NOT be valid: " + s, --------------------------------------------------------------------- To unsubscribe, e-mail: janetmason@example.net For additional commands, e-mail: janetmason@example.net From janetmason@example.net Thu Oct 08 22:30:14 2009 Return-Path: <janetmason@example.net> Delivered-To: janetmason@example.net Received: (qmail 39941 invoked from network); 8 Oct 2009 22:30:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 8 Oct 2009 22:30:14 -0000 Received: (qmail 97864 invoked by uid 500); 8 Oct 2009 22:30:14 -0000 Delivered-To: janetmason@example.net Received: (qmail 97828 invoked by uid 500); 8 Oct 2009 22:30:14 -0000 Mailing-List: contact janetmason@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:janetmason@example.net> List-Unsubscribe: <mailto:janetmason@example.net> List-Post: <mailto:janetmason@example.net> List-Id: <commits.poi.apache.org> Reply-To: janetmason@example.net Delivered-To: mailing list janetmason@example.net Received: (qmail 97815 invoked by uid 99); 8 Oct 2009 22:30:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Oct 2009 22:30:13 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Oct 2009 22:30:08 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 84B8F238897D; Thu, 8 Oct 2009 22:29:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r823348 [4/4] - in /poi/trunk/src: contrib/src/org/apache/poi/hssf/contrib/view/ contrib/src/org/apache/poi/ss/usermodel/contrib/ examples/src/org/apache/poi/hpsf/examples/ java/org/apache/poi/ddf/ java/org/apache/poi/hpsf/ java/org/apache/... Date: Thu, 08 Oct 2009 22:29:43 -0000 To: janetmason@example.net From: janetmason@example.net X-Mailer: svnmailer-1.0.8 Message-Id: <janetmason@example.net> X-Virus-Checked: Checked by ClamAV on apache.org Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/function/ExcelFileFormatDocFunctionExtractor.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/function/ExcelFileFormatDocFunctionExtractor.java?rev=823348&r1=823347&r2=823348&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/function/ExcelFileFormatDocFunctionExtractor.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/function/ExcelFileFormatDocFunctionExtractor.java Thu Oct 8 22:29:41 2009 @@ -56,7 +56,7 @@ * the file 'functionMetadata.txt'. There are more than 300 built-in functions in Excel and the * intention of this class is to make it easier to maintain the metadata, by extracting it from * a reliable source. - * + * * @author Josh Micich */ public final class ExcelFileFormatDocFunctionExtractor { @@ -65,10 +65,10 @@ /** * For simplicity, the output file is strictly simple ASCII. - * This method detects any unexpected characters. + * This method detects any unexpected characters. */ /* package */ static boolean isSimpleAscii(char c) { - + if (c>=0x21 && c<=0x7E) { // everything from '!' to '~' (includes letters, digits, punctuation return true; @@ -83,8 +83,8 @@ } return false; } - - + + private static final class FunctionData { // special characters from the ooo document private static final int CHAR_ELLIPSIS_8230 = 8230; @@ -148,7 +148,7 @@ return b ? "x" : ""; } } - + private static final class FunctionDataCollector { private final Map _allFunctionsByIndex; @@ -156,7 +156,7 @@ private final Set _groupFunctionIndexes; private final Set _groupFunctionNames; private final PrintStream _ps; - + public FunctionDataCollector(PrintStream ps) { _ps = ps; _allFunctionsByIndex = new HashMap(); @@ -168,19 +168,19 @@ public void addFuntion(int funcIx, boolean hasFootnote, String funcName, int minParams, int maxParams, String returnClass, String paramClasses, String volatileFlagStr) { boolean isVolatile = volatileFlagStr.length() > 0; - - Integer funcIxKey = new Integer(funcIx); + + Integer funcIxKey = Integer.valueOf(funcIx); if(!_groupFunctionIndexes.add(funcIxKey)) { throw new RuntimeException("Duplicate function index (" + funcIx + ")"); } if(!_groupFunctionNames.add(funcName)) { throw new RuntimeException("Duplicate function name '" + funcName + "'"); } - + checkRedefinedFunction(hasFootnote, funcName, funcIxKey); - FunctionData fd = new FunctionData(funcIx, hasFootnote, funcName, + FunctionData fd = new FunctionData(funcIx, hasFootnote, funcName, minParams, maxParams, returnClass, paramClasses, isVolatile); - + _allFunctionsByIndex.put(funcIxKey, fd); _allFunctionsByName.put(funcName, fd); } @@ -195,7 +195,7 @@ fdPrev = (FunctionData) _allFunctionsByIndex.get(funcIxKey); if(fdPrev != null) { if(!fdPrev.hasFootnote() || !hasNote) { - throw new RuntimeException("changing function [" + throw new RuntimeException("changing function [" + funcIxKey + "] definition without foot-note"); } _allFunctionsByName.remove(fdPrev.getName()); @@ -204,10 +204,10 @@ fdPrev = (FunctionData) _allFunctionsByName.get(funcName); if(fdPrev != null) { if(!fdPrev.hasFootnote() || !hasNote) { - throw new RuntimeException("changing function '" + throw new RuntimeException("changing function '" + funcName + "' definition without foot-note"); } - _allFunctionsByIndex.remove(new Integer(fdPrev.getIndex())); + _allFunctionsByIndex.remove(Integer.valueOf(fdPrev.getIndex())); } } @@ -217,7 +217,7 @@ _groupFunctionIndexes.clear(); _groupFunctionNames.clear(); Arrays.sort(keys); - + _ps.println("# " + headingText); for (int i = 0; i < keys.length; i++) { FunctionData fd = (FunctionData) _allFunctionsByIndex.get(keys[i]); @@ -225,25 +225,25 @@ } } } - + /** - * To avoid drag-in - parse XML using only JDK. + * To avoid drag-in - parse XML using only JDK. */ private static class EFFDocHandler implements ContentHandler { private static final String[] HEADING_PATH_NAMES = { - "office:document-content", "office:body", "office:text", "text:h", + "office:document-content", "office:body", "office:text", "text:h", }; private static final String[] TABLE_BASE_PATH_NAMES = { - "office:document-content", "office:body", "office:text", "table:table", + "office:document-content", "office:body", "office:text", "table:table", }; private static final String[] TABLE_ROW_RELPATH_NAMES = { - "table:table-row", + "table:table-row", }; private static final String[] TABLE_CELL_RELPATH_NAMES = { - "table:table-row", "table:table-cell", "text:p", + "table:table-row", "table:table-cell", "text:p", }; // after May 2008 there was one more style applied to the footnotes - private static final String[] NOTE_REF_RELPATH_NAMES_OLD = { + private static final String[] NOTE_REF_RELPATH_NAMES_OLD = { "table:table-row", "table:table-cell", "text:p", "text:span", "text:note-ref", }; private static final String[] NOTE_REF_RELPATH_NAMES = { @@ -255,7 +255,7 @@ /** <code>true</code> only when parsing the target tables */ private boolean _isInsideTable; - private final List _rowData; + private final List _rowData; private final StringBuffer _textNodeBuffer; private final List _rowNoteFlags; private boolean _cellHasNote; @@ -304,7 +304,7 @@ if(matchesPath(0, HEADING_PATH_NAMES)) { _lastHeadingText = _textNodeBuffer.toString().trim(); _textNodeBuffer.setLength(0); - } + } if(_isInsideTable) { if(matchesTargetPath()) { _fdc.endTableGroup(_lastHeadingText); @@ -350,7 +350,7 @@ String returnClass = cellData[i + 4]; String paramClasses = cellData[i + 5]; String volatileFlagStr = cellData[i + 6]; - + _fdc.addFuntion(funcIx, hasFootnote, funcName, minParams, maxParams, returnClass, paramClasses, volatileFlagStr); } private static int parseInt(String valStr) { @@ -412,7 +412,7 @@ private static void extractFunctionData(FunctionDataCollector fdc, InputStream is) { XMLReader xr; - + try { // First up, try the default one xr = XMLReaderFactory.createXMLReader(); @@ -460,7 +460,7 @@ public void write(byte[] b, int off, int len) throws IOException { for (int i = 0; i < len; i++) { checkByte(b[i + off]); - + } _os.write(b, off, len); } @@ -483,7 +483,7 @@ } catch(UnsupportedEncodingException e) { throw new RuntimeException(e); } - + outputLicenseHeader(ps); Class genClass = ExcelFileFormatDocFunctionExtractor.class; ps.println("# Created by (" + genClass.getName() + ")"); @@ -504,7 +504,7 @@ throw new RuntimeException(e); } ps.close(); - + String canonicalOutputFileName; try { canonicalOutputFileName = outFile.getCanonicalPath(); @@ -554,7 +554,7 @@ InputStream is = new FileInputStream(f); while(true) { int bytesRead = is.read(buf); - if(bytesRead<1) { + if(bytesRead<1) { break; } m.update(buf, 0, bytesRead); @@ -563,7 +563,7 @@ } catch (IOException e) { throw new RuntimeException(e); } - + return "0x" + new BigInteger(1, m.digest()).toString(16); } @@ -585,7 +585,7 @@ OutputStream os = new FileOutputStream(result); while(true) { int bytesRead = is.read(buf); - if(bytesRead<1) { + if(bytesRead<1) { break; } os.write(buf, 0, bytesRead); @@ -609,7 +609,7 @@ processFile(effDocFile, outFile); return; } - + File tempEFFDocFile = downloadSourceFile(); processFile(tempEFFDocFile, outFile); tempEFFDocFile.delete(); Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/StreamUtility.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/StreamUtility.java?rev=823348&r1=823347&r2=823348&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/StreamUtility.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/StreamUtility.java Thu Oct 8 22:29:41 2009 @@ -6,7 +6,7 @@ (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -23,24 +23,24 @@ import java.util.List; /** - * Utility class to help test code verify that generated files do not differ from proof copies in + * Utility class to help test code verify that generated files do not differ from proof copies in * any significant detail. Normally this task would be simple except for the presence of artifacts - * in the file that change every time it is generated. Usually these volatile artifacts are + * in the file that change every time it is generated. Usually these volatile artifacts are * time-stamps, user names, or other machine dependent parameters. - * + * * @author Josh Micich */ public final class StreamUtility { /** * Compares two streams with expected differences in specified regions. The streams are - * expected to be of equal length and comparison is always byte for byte. That is - - * differences can only involve exchanging each individual byte for another single byte.<br> - * Both input streams are closed. - * - * @param allowableDifferenceRegions array of integer pairs: (offset, length). + * expected to be of equal length and comparison is always byte for byte. That is - + * differences can only involve exchanging each individual byte for another single byte.<br> + * Both input streams are closed. + * + * @param allowableDifferenceRegions array of integer pairs: (offset, length). * Any differences encountered in these regions of the streams will be ignored - * @return <code>null</code> if streams are identical, else the + * @return <code>null</code> if streams are identical, else the * byte indexes of differing data. If streams were different lengths, * the returned indexes will be -1 and the length of the shorter stream */ @@ -51,36 +51,36 @@ } boolean success = false; int[] result; - try { - result = diffInternal(isA, isB, allowableDifferenceRegions); - success = true; - } catch (IOException e) { - throw new RuntimeException(e); - } finally { - close(isA, success); - close(isB, success); - } - return result; + try { + result = diffInternal(isA, isB, allowableDifferenceRegions); + success = true; + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + close(isA, success); + close(isB, success); + } + return result; } /** * @param success <code>false</code> if the outer method is throwing an exception. */ - private static void close(InputStream is, boolean success) { - try { - is.close(); - } catch (IOException e) { - if(success) { - // this is a new error. ok to throw - throw new RuntimeException(e); - } - // else don't subvert original exception. just print stack trace for this one - e.printStackTrace(); - } - } + private static void close(InputStream is, boolean success) { + try { + is.close(); + } catch (IOException e) { + if(success) { + // this is a new error. ok to throw + throw new RuntimeException(e); + } + // else don't subvert original exception. just print stack trace for this one + e.printStackTrace(); + } + } - private static int[] diffInternal(InputStream isA, InputStream isB, int[] allowableDifferenceRegions) - throws IOException { + private static int[] diffInternal(InputStream isA, InputStream isB, int[] allowableDifferenceRegions) + throws IOException { int offset = 0; List temp = new ArrayList(); while (true) { @@ -97,11 +97,11 @@ return new int[] { -1, offset, }; } if (b != b2 && !isIgnoredRegion(allowableDifferenceRegions, offset)) { - temp.add(new Integer(offset)); + temp.add(Integer.valueOf(offset)); } offset++; } - } + } private static boolean isIgnoredRegion(int[] allowableDifferenceRegions, int offset) { for (int i = 0; i < allowableDifferenceRegions.length; i+=2) { @@ -121,7 +121,7 @@ } Integer[] boxInts = new Integer[nItems]; temp.toArray(boxInts); - + int[] result = new int[nItems]; for (int i = 0; i < result.length; i++) { result[i] = boxInts[i].intValue(); Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestDataFormat.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestDataFormat.java?rev=823348&r1=823347&r2=823348&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestDataFormat.java (original) +++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestDataFormat.java Thu Oct 8 22:29:41 2009 @@ -40,7 +40,7 @@ Map<Integer, String> formats = BuiltinFormats.getBuiltinFormats(); for (int idx : formats.keySet()) { - String fmt = formats.get(new Integer(idx)); + String fmt = formats.get(Integer.valueOf(idx)); assertEquals(idx, df.getFormat(fmt)); } Modified: poi/trunk/src/testcases/org/apache/poi/util/LocalTestNode.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/util/LocalTestNode.java?rev=823348&r1=823347&r2=823348&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/util/LocalTestNode.java (original) +++ poi/trunk/src/testcases/org/apache/poi/util/LocalTestNode.java Thu Oct 8 22:29:41 2009 @@ -15,7 +15,6 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - package org.apache.poi.util; @@ -33,7 +32,7 @@ LocalTestNode(final int key) { - _key = new Integer(key); + _key = Integer.valueOf(key); _value = String.valueOf(key); } @@ -118,7 +117,6 @@ /** * @return hash code */ - public int hashCode() { return getKey().hashCode() ^ getValue().hashCode(); Modified: poi/trunk/src/testcases/org/apache/poi/util/TestArrayUtil.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/util/TestArrayUtil.java?rev=823348&r1=823347&r2=823348&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/util/TestArrayUtil.java (original) +++ poi/trunk/src/testcases/org/apache/poi/util/TestArrayUtil.java Thu Oct 8 22:29:41 2009 @@ -15,261 +15,264 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - + package org.apache.poi.util; -import junit.framework.*; +import junit.framework.TestCase; /** * Unit test for ArrayUtil * * @author Nick Burch */ -public class TestArrayUtil extends TestCase -{ +public class TestArrayUtil extends TestCase { /** * Test to ensure that our own arraycopy behaves as it should do */ public void testarraycopy() { byte[] bytes = new byte[] { 0x01, 0x02, 0x03, 0x04 }; - + // Test copy whole thing byte[] dest = new byte[4]; ArrayUtil.arraycopy(bytes, 0, dest, 0, 4); - + assertEquals(dest.length, bytes.length); for(int i=0; i<dest.length; i++) { assertEquals(bytes[i], dest[i]); } - + // ToDo - test exceptions are as expected } - - + + /** - * Helper for testArrayMoveWithin + * Helper for testArrayMoveWithin */ - private Integer[] getIntsList() { + private Integer[] getIntsList() { return new Integer[] { - new Integer(0), - new Integer(1), - new Integer(2), - new Integer(3), - new Integer(4), - new Integer(5), - new Integer(6), - new Integer(7), - new Integer(8), - new Integer(9) + Integer.valueOf(0), + Integer.valueOf(1), + Integer.valueOf(2), + Integer.valueOf(3), + Integer.valueOf(4), + Integer.valueOf(5), + Integer.valueOf(6), + Integer.valueOf(7), + Integer.valueOf(8), + Integer.valueOf(9) }; } + + private static void assertEquals(int exp, Integer act) { + assertEquals(exp, act.intValue()); + } /** * Test to ensure that arrayMoveWithin works as expected */ public void testArrayMoveWithin() { Integer[] ints = getIntsList(); - - assertEquals(new Integer(0), ints[0]); - assertEquals(new Integer(1), ints[1]); - assertEquals(new Integer(2), ints[2]); - assertEquals(new Integer(3), ints[3]); - assertEquals(new Integer(4), ints[4]); - assertEquals(new Integer(5), ints[5]); - assertEquals(new Integer(6), ints[6]); - assertEquals(new Integer(7), ints[7]); - assertEquals(new Integer(8), ints[8]); - assertEquals(new Integer(9), ints[9]); - - + + assertEquals(0, ints[0]); + assertEquals(1, ints[1]); + assertEquals(2, ints[2]); + assertEquals(3, ints[3]); + assertEquals(4, ints[4]); + assertEquals(5, ints[5]); + assertEquals(6, ints[6]); + assertEquals(7, ints[7]); + assertEquals(8, ints[8]); + assertEquals(9, ints[9]); + + // // Moving to a later point in the array // - + // Shift 1 back ints = getIntsList(); ArrayUtil.arrayMoveWithin(ints, 4, 8, 1); - assertEquals(new Integer(0), ints[0]); - assertEquals(new Integer(1), ints[1]); - assertEquals(new Integer(2), ints[2]); - assertEquals(new Integer(3), ints[3]); - assertEquals(new Integer(5), ints[4]); - assertEquals(new Integer(6), ints[5]); - assertEquals(new Integer(7), ints[6]); - assertEquals(new Integer(8), ints[7]); - assertEquals(new Integer(4), ints[8]); - assertEquals(new Integer(9), ints[9]); - + assertEquals(0, ints[0]); + assertEquals(1, ints[1]); + assertEquals(2, ints[2]); + assertEquals(3, ints[3]); + assertEquals(5, ints[4]); + assertEquals(6, ints[5]); + assertEquals(7, ints[6]); + assertEquals(8, ints[7]); + assertEquals(4, ints[8]); + assertEquals(9, ints[9]); + // Shift front 1 back ints = getIntsList(); ArrayUtil.arrayMoveWithin(ints, 0, 7, 1); - assertEquals(new Integer(1), ints[0]); - assertEquals(new Integer(2), ints[1]); - assertEquals(new Integer(3), ints[2]); - assertEquals(new Integer(4), ints[3]); - assertEquals(new Integer(5), ints[4]); - assertEquals(new Integer(6), ints[5]); - assertEquals(new Integer(7), ints[6]); - assertEquals(new Integer(0), ints[7]); - assertEquals(new Integer(8), ints[8]); - assertEquals(new Integer(9), ints[9]); - + assertEquals(1, ints[0]); + assertEquals(2, ints[1]); + assertEquals(3, ints[2]); + assertEquals(4, ints[3]); + assertEquals(5, ints[4]); + assertEquals(6, ints[5]); + assertEquals(7, ints[6]); + assertEquals(0, ints[7]); + assertEquals(8, ints[8]); + assertEquals(9, ints[9]); + // Shift 1 to end ints = getIntsList(); ArrayUtil.arrayMoveWithin(ints, 4, 9, 1); - assertEquals(new Integer(0), ints[0]); - assertEquals(new Integer(1), ints[1]); - assertEquals(new Integer(2), ints[2]); - assertEquals(new Integer(3), ints[3]); - assertEquals(new Integer(5), ints[4]); - assertEquals(new Integer(6), ints[5]); - assertEquals(new Integer(7), ints[6]); - assertEquals(new Integer(8), ints[7]); - assertEquals(new Integer(9), ints[8]); - assertEquals(new Integer(4), ints[9]); + assertEquals(0, ints[0]); + assertEquals(1, ints[1]); + assertEquals(2, ints[2]); + assertEquals(3, ints[3]); + assertEquals(5, ints[4]); + assertEquals(6, ints[5]); + assertEquals(7, ints[6]); + assertEquals(8, ints[7]); + assertEquals(9, ints[8]); + assertEquals(4, ints[9]); + - // // Moving to an earlier point in the array // - + // Shift 1 forward ints = getIntsList(); ArrayUtil.arrayMoveWithin(ints, 8, 3, 1); - assertEquals(new Integer(0), ints[0]); - assertEquals(new Integer(1), ints[1]); - assertEquals(new Integer(2), ints[2]); - assertEquals(new Integer(8), ints[3]); - assertEquals(new Integer(3), ints[4]); - assertEquals(new Integer(4), ints[5]); - assertEquals(new Integer(5), ints[6]); - assertEquals(new Integer(6), ints[7]); - assertEquals(new Integer(7), ints[8]); - assertEquals(new Integer(9), ints[9]); - + assertEquals(0, ints[0]); + assertEquals(1, ints[1]); + assertEquals(2, ints[2]); + assertEquals(8, ints[3]); + assertEquals(3, ints[4]); + assertEquals(4, ints[5]); + assertEquals(5, ints[6]); + assertEquals(6, ints[7]); + assertEquals(7, ints[8]); + assertEquals(9, ints[9]); + // Shift end 1 forward ints = getIntsList(); ArrayUtil.arrayMoveWithin(ints, 9, 2, 1); - assertEquals(new Integer(0), ints[0]); - assertEquals(new Integer(1), ints[1]); - assertEquals(new Integer(9), ints[2]); - assertEquals(new Integer(2), ints[3]); - assertEquals(new Integer(3), ints[4]); - assertEquals(new Integer(4), ints[5]); - assertEquals(new Integer(5), ints[6]); - assertEquals(new Integer(6), ints[7]); - assertEquals(new Integer(7), ints[8]); - assertEquals(new Integer(8), ints[9]); - + assertEquals(0, ints[0]); + assertEquals(1, ints[1]); + assertEquals(9, ints[2]); + assertEquals(2, ints[3]); + assertEquals(3, ints[4]); + assertEquals(4, ints[5]); + assertEquals(5, ints[6]); + assertEquals(6, ints[7]); + assertEquals(7, ints[8]); + assertEquals(8, ints[9]); + // Shift 1 to front ints = getIntsList(); ArrayUtil.arrayMoveWithin(ints, 5, 0, 1); - assertEquals(new Integer(5), ints[0]); - assertEquals(new Integer(0), ints[1]); - assertEquals(new Integer(1), ints[2]); - assertEquals(new Integer(2), ints[3]); - assertEquals(new Integer(3), ints[4]); - assertEquals(new Integer(4), ints[5]); - assertEquals(new Integer(6), ints[6]); - assertEquals(new Integer(7), ints[7]); - assertEquals(new Integer(8), ints[8]); - assertEquals(new Integer(9), ints[9]); + assertEquals(5, ints[0]); + assertEquals(0, ints[1]); + assertEquals(1, ints[2]); + assertEquals(2, ints[3]); + assertEquals(3, ints[4]); + assertEquals(4, ints[5]); + assertEquals(6, ints[6]); + assertEquals(7, ints[7]); + assertEquals(8, ints[8]); + assertEquals(9, ints[9]); + - // // Moving many to a later point in the array // - + // Shift 3 back ints = getIntsList(); ArrayUtil.arrayMoveWithin(ints, 2, 6, 3); - assertEquals(new Integer(0), ints[0]); - assertEquals(new Integer(1), ints[1]); - assertEquals(new Integer(5), ints[2]); - assertEquals(new Integer(6), ints[3]); - assertEquals(new Integer(7), ints[4]); - assertEquals(new Integer(8), ints[5]); - assertEquals(new Integer(2), ints[6]); - assertEquals(new Integer(3), ints[7]); - assertEquals(new Integer(4), ints[8]); - assertEquals(new Integer(9), ints[9]); - + assertEquals(0, ints[0]); + assertEquals(1, ints[1]); + assertEquals(5, ints[2]); + assertEquals(6, ints[3]); + assertEquals(7, ints[4]); + assertEquals(8, ints[5]); + assertEquals(2, ints[6]); + assertEquals(3, ints[7]); + assertEquals(4, ints[8]); + assertEquals(9, ints[9]); + // Shift 3 to back ints = getIntsList(); ArrayUtil.arrayMoveWithin(ints, 2, 7, 3); - assertEquals(new Integer(0), ints[0]); - assertEquals(new Integer(1), ints[1]); - assertEquals(new Integer(5), ints[2]); - assertEquals(new Integer(6), ints[3]); - assertEquals(new Integer(7), ints[4]); - assertEquals(new Integer(8), ints[5]); - assertEquals(new Integer(9), ints[6]); - assertEquals(new Integer(2), ints[7]); - assertEquals(new Integer(3), ints[8]); - assertEquals(new Integer(4), ints[9]); - + assertEquals(0, ints[0]); + assertEquals(1, ints[1]); + assertEquals(5, ints[2]); + assertEquals(6, ints[3]); + assertEquals(7, ints[4]); + assertEquals(8, ints[5]); + assertEquals(9, ints[6]); + assertEquals(2, ints[7]); + assertEquals(3, ints[8]); + assertEquals(4, ints[9]); + // Shift from 3 front ints = getIntsList(); ArrayUtil.arrayMoveWithin(ints, 0, 5, 3); - assertEquals(new Integer(3), ints[0]); - assertEquals(new Integer(4), ints[1]); - assertEquals(new Integer(5), ints[2]); - assertEquals(new Integer(6), ints[3]); - assertEquals(new Integer(7), ints[4]); - assertEquals(new Integer(0), ints[5]); - assertEquals(new Integer(1), ints[6]); - assertEquals(new Integer(2), ints[7]); - assertEquals(new Integer(8), ints[8]); - assertEquals(new Integer(9), ints[9]); - - + assertEquals(3, ints[0]); + assertEquals(4, ints[1]); + assertEquals(5, ints[2]); + assertEquals(6, ints[3]); + assertEquals(7, ints[4]); + assertEquals(0, ints[5]); + assertEquals(1, ints[6]); + assertEquals(2, ints[7]); + assertEquals(8, ints[8]); + assertEquals(9, ints[9]); + + // // Moving many to an earlier point in the array // - + // Shift 3 forward ints = getIntsList(); ArrayUtil.arrayMoveWithin(ints, 6, 2, 3); - assertEquals(new Integer(0), ints[0]); - assertEquals(new Integer(1), ints[1]); - assertEquals(new Integer(6), ints[2]); - assertEquals(new Integer(7), ints[3]); - assertEquals(new Integer(8), ints[4]); - assertEquals(new Integer(2), ints[5]); - assertEquals(new Integer(3), ints[6]); - assertEquals(new Integer(4), ints[7]); - assertEquals(new Integer(5), ints[8]); - assertEquals(new Integer(9), ints[9]); - + assertEquals(0, ints[0]); + assertEquals(1, ints[1]); + assertEquals(6, ints[2]); + assertEquals(7, ints[3]); + assertEquals(8, ints[4]); + assertEquals(2, ints[5]); + assertEquals(3, ints[6]); + assertEquals(4, ints[7]); + assertEquals(5, ints[8]); + assertEquals(9, ints[9]); + // Shift 3 to front ints = getIntsList(); ArrayUtil.arrayMoveWithin(ints, 6, 0, 3); - assertEquals(new Integer(6), ints[0]); - assertEquals(new Integer(7), ints[1]); - assertEquals(new Integer(8), ints[2]); - assertEquals(new Integer(0), ints[3]); - assertEquals(new Integer(1), ints[4]); - assertEquals(new Integer(2), ints[5]); - assertEquals(new Integer(3), ints[6]); - assertEquals(new Integer(4), ints[7]); - assertEquals(new Integer(5), ints[8]); - assertEquals(new Integer(9), ints[9]); - + assertEquals(6, ints[0]); + assertEquals(7, ints[1]); + assertEquals(8, ints[2]); + assertEquals(0, ints[3]); + assertEquals(1, ints[4]); + assertEquals(2, ints[5]); + assertEquals(3, ints[6]); + assertEquals(4, ints[7]); + assertEquals(5, ints[8]); + assertEquals(9, ints[9]); + // Shift from 3 back ints = getIntsList(); ArrayUtil.arrayMoveWithin(ints, 7, 3, 3); - assertEquals(new Integer(0), ints[0]); - assertEquals(new Integer(1), ints[1]); - assertEquals(new Integer(2), ints[2]); - assertEquals(new Integer(7), ints[3]); - assertEquals(new Integer(8), ints[4]); - assertEquals(new Integer(9), ints[5]); - assertEquals(new Integer(3), ints[6]); - assertEquals(new Integer(4), ints[7]); - assertEquals(new Integer(5), ints[8]); - assertEquals(new Integer(6), ints[9]); - - + assertEquals(0, ints[0]); + assertEquals(1, ints[1]); + assertEquals(2, ints[2]); + assertEquals(7, ints[3]); + assertEquals(8, ints[4]); + assertEquals(9, ints[5]); + assertEquals(3, ints[6]); + assertEquals(4, ints[7]); + assertEquals(5, ints[8]); + assertEquals(6, ints[9]); + + // Check can't shift more than we have try { ints = getIntsList(); @@ -278,7 +281,7 @@ } catch(IllegalArgumentException e) { // Good, we don't have 5 from 7 onwards } - + // Check can't shift where would overshoot try { ints = getIntsList(); @@ -289,4 +292,3 @@ } } } - Modified: poi/trunk/src/testcases/org/apache/poi/util/TestBinaryTree.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/util/TestBinaryTree.java?rev=823348&r1=823347&r2=823348&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/util/TestBinaryTree.java (original) +++ poi/trunk/src/testcases/org/apache/poi/util/TestBinaryTree.java Thu Oct 8 22:29:41 2009 @@ -120,7 +120,7 @@ m.put(nodes[ k ].getKey(), nodes[ k ]); assertTrue(m.containsKey(nodes[ k ].getKey())); } - assertTrue(!m.containsKey(new Integer(-1))); + assertTrue(!m.containsKey(Integer.valueOf(-1))); try { m.containsKey("foo"); @@ -179,7 +179,7 @@ m.put(nodes[
{'source': 'Apache Software Foundation Public Mail Archives'}