You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2014/09/17 23:12:38 UTC
svn commit: r1625828 [5/6] - in /poi/branches/xml_signature: ./
src/examples/src/org/apache/poi/xssf/eventusermodel/examples/
src/java/org/apache/poi/hssf/dev/ src/java/org/apache/poi/hssf/record/
src/java/org/apache/poi/hssf/record/aggregates/ src/jav...
Modified: poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java
URL: http://svn.apache.org/viewvc/poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java?rev=1625828&r1=1625827&r2=1625828&view=diff
==============================================================================
--- poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java (original)
+++ poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRichTextString.java Wed Sep 17 21:12:36 2014
@@ -308,22 +308,22 @@ public final class TestXSSFRichTextStrin
str = new XSSFRichTextString("Incorrect\nLine-Breaking");
str.applyFont(0, 8, font);
- t1 = str.getCTRst().getRList().get(0).xgetT();
- t2 = str.getCTRst().getRList().get(1).xgetT();
+ t1 = str.getCTRst().getRArray(0).xgetT();
+ t2 = str.getCTRst().getRArray(1).xgetT();
assertEquals("<xml-fragment>Incorrec</xml-fragment>", t1.xmlText());
assertEquals("<xml-fragment>t\nLine-Breaking</xml-fragment>", t2.xmlText());
str = new XSSFRichTextString("Incorrect\nLine-Breaking");
str.applyFont(0, 9, font);
- t1 = str.getCTRst().getRList().get(0).xgetT();
- t2 = str.getCTRst().getRList().get(1).xgetT();
+ t1 = str.getCTRst().getRArray(0).xgetT();
+ t2 = str.getCTRst().getRArray(1).xgetT();
assertEquals("<xml-fragment>Incorrect</xml-fragment>", t1.xmlText());
assertEquals("<xml-fragment xml:space=\"preserve\">\nLine-Breaking</xml-fragment>", t2.xmlText());
str = new XSSFRichTextString("Incorrect\n Line-Breaking");
str.applyFont(0, 9, font);
- t1 = str.getCTRst().getRList().get(0).xgetT();
- t2 = str.getCTRst().getRList().get(1).xgetT();
+ t1 = str.getCTRst().getRArray(0).xgetT();
+ t2 = str.getCTRst().getRArray(1).xgetT();
assertEquals("<xml-fragment>Incorrect</xml-fragment>", t1.xmlText());
assertEquals("<xml-fragment xml:space=\"preserve\">\n Line-Breaking</xml-fragment>", t2.xmlText());
@@ -333,15 +333,15 @@ public final class TestXSSFRichTextStrin
assertEquals("<xml-fragment xml:space=\"preserve\">Tab\tseparated\n</xml-fragment>", t1.xmlText());
str.applyFont(0, 3, font);
- t1 = str.getCTRst().getRList().get(0).xgetT();
- t2 = str.getCTRst().getRList().get(1).xgetT();
+ t1 = str.getCTRst().getRArray(0).xgetT();
+ t2 = str.getCTRst().getRArray(1).xgetT();
assertEquals("<xml-fragment>Tab</xml-fragment>", t1.xmlText());
assertEquals("<xml-fragment xml:space=\"preserve\">\tseparated\n</xml-fragment>", t2.xmlText());
str = new XSSFRichTextString("Tab\tseparated\n");
str.applyFont(0, 4, font);
- t1 = str.getCTRst().getRList().get(0).xgetT();
- t2 = str.getCTRst().getRList().get(1).xgetT();
+ t1 = str.getCTRst().getRArray(0).xgetT();
+ t2 = str.getCTRst().getRArray(1).xgetT();
// YK: don't know why, but XmlBeans converts leading tab characters to spaces
//assertEquals("<xml-fragment>Tab\t</xml-fragment>", t1.xmlText());
assertEquals("<xml-fragment xml:space=\"preserve\">separated\n</xml-fragment>", t2.xmlText());
@@ -349,9 +349,9 @@ public final class TestXSSFRichTextStrin
str = new XSSFRichTextString("\n\n\nNew Line\n\n");
str.applyFont(0, 3, font);
str.applyFont(11, 13, font);
- t1 = str.getCTRst().getRList().get(0).xgetT();
- t2 = str.getCTRst().getRList().get(1).xgetT();
- t3 = str.getCTRst().getRList().get(2).xgetT();
+ t1 = str.getCTRst().getRArray(0).xgetT();
+ t2 = str.getCTRst().getRArray(1).xgetT();
+ t3 = str.getCTRst().getRArray(2).xgetT();
// YK: don't know why, but XmlBeans converts leading tab characters to spaces
assertEquals("<xml-fragment xml:space=\"preserve\">\n\n\n</xml-fragment>", t1.xmlText());
assertEquals("<xml-fragment>New Line</xml-fragment>", t2.xmlText());
Modified: poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java?rev=1625828&r1=1625827&r2=1625828&view=diff
==============================================================================
--- poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java (original)
+++ poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java Wed Sep 17 21:12:36 2014
@@ -19,6 +19,8 @@ package org.apache.poi.xssf.usermodel;
import static junit.framework.TestCase.assertNotNull;
import static junit.framework.TestCase.assertTrue;
+import static org.apache.poi.xssf.XSSFTestDataSamples.openSampleWorkbook;
+import static org.apache.poi.xssf.XSSFTestDataSamples.writeOutAndReadBack;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
@@ -26,10 +28,14 @@ import static org.junit.Assert.assertNul
import static org.junit.Assert.assertSame;
import static org.junit.Assert.fail;
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.hssf.record.PasswordRecord;
+import org.apache.poi.poifs.crypt.CryptoFunctions;
+import org.apache.poi.poifs.crypt.HashAlgorithm;
import org.apache.poi.ss.usermodel.AutoFilter;
import org.apache.poi.ss.usermodel.BaseTestSheet;
import org.apache.poi.ss.usermodel.Cell;
@@ -41,7 +47,6 @@ import org.apache.poi.ss.usermodel.Workb
import org.apache.poi.ss.util.AreaReference;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellReference;
-import org.apache.poi.util.HexDump;
import org.apache.poi.xssf.SXSSFITestDataProvider;
import org.apache.poi.xssf.XSSFITestDataProvider;
import org.apache.poi.xssf.XSSFTestDataSamples;
@@ -293,6 +298,7 @@ public final class TestXSSFSheet extends
CellRangeAddress region_1 = CellRangeAddress.valueOf("A1:B2");
CellRangeAddress region_2 = CellRangeAddress.valueOf("C3:D4");
CellRangeAddress region_3 = CellRangeAddress.valueOf("E5:F6");
+ CellRangeAddress region_4 = CellRangeAddress.valueOf("G7:H8");
sheet.addMergedRegion(region_1);
sheet.addMergedRegion(region_2);
sheet.addMergedRegion(region_3);
@@ -306,6 +312,17 @@ public final class TestXSSFSheet extends
assertEquals(0, sheet.getNumMergedRegions());
assertNull(" CTMergeCells should be deleted after removing the last merged " +
"region on the sheet.", sheet.getCTWorksheet().getMergeCells());
+ sheet.addMergedRegion(region_1);
+ sheet.addMergedRegion(region_2);
+ sheet.addMergedRegion(region_3);
+ sheet.addMergedRegion(region_4);
+ // test invalid indexes OOBE
+ Set<Integer> rmIdx = new HashSet<Integer>(Arrays.asList(5,6));
+ sheet.removeMergedRegions(rmIdx);
+ rmIdx = new HashSet<Integer>(Arrays.asList(1,3));
+ sheet.removeMergedRegions(rmIdx);
+ assertEquals("A1:B2", ctWorksheet.getMergeCells().getMergeCellArray(0).getRef());
+ assertEquals("E5:F6", ctWorksheet.getMergeCells().getMergeCellArray(1).getRef());
}
@Test
@@ -335,6 +352,7 @@ public final class TestXSSFSheet extends
@Test
+ @SuppressWarnings("deprecation")
public void groupUngroupColumn() {
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet();
@@ -344,36 +362,36 @@ public final class TestXSSFSheet extends
sheet.groupColumn(10, 11);
CTCols cols = sheet.getCTWorksheet().getColsArray(0);
assertEquals(2, cols.sizeOfColArray());
- List<CTCol> colArray = cols.getColList();
+ CTCol[] colArray = cols.getColArray();
assertNotNull(colArray);
- assertEquals(2 + 1, colArray.get(0).getMin()); // 1 based
- assertEquals(7 + 1, colArray.get(0).getMax()); // 1 based
- assertEquals(1, colArray.get(0).getOutlineLevel());
+ assertEquals(2 + 1, colArray[0].getMin()); // 1 based
+ assertEquals(7 + 1, colArray[0].getMax()); // 1 based
+ assertEquals(1, colArray[0].getOutlineLevel());
//two level
sheet.groupColumn(1, 2);
cols = sheet.getCTWorksheet().getColsArray(0);
assertEquals(4, cols.sizeOfColArray());
- colArray = cols.getColList();
- assertEquals(2, colArray.get(1).getOutlineLevel());
+ colArray = cols.getColArray();
+ assertEquals(2, colArray[1].getOutlineLevel());
//three level
sheet.groupColumn(6, 8);
sheet.groupColumn(2, 3);
cols = sheet.getCTWorksheet().getColsArray(0);
assertEquals(7, cols.sizeOfColArray());
- colArray = cols.getColList();
- assertEquals(3, colArray.get(1).getOutlineLevel());
+ colArray = cols.getColArray();
+ assertEquals(3, colArray[1].getOutlineLevel());
assertEquals(3, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelCol());
sheet.ungroupColumn(8, 10);
- colArray = cols.getColList();
+ colArray = cols.getColArray();
//assertEquals(3, colArray[1].getOutlineLevel());
sheet.ungroupColumn(4, 6);
sheet.ungroupColumn(2, 2);
- colArray = cols.getColList();
- assertEquals(4, colArray.size());
+ colArray = cols.getColArray();
+ assertEquals(4, colArray.length);
assertEquals(2, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelCol());
}
@@ -758,9 +776,8 @@ public final class TestXSSFSheet extends
XSSFSheet xs = sheet;
CTWorksheet cts = xs.getCTWorksheet();
- List<CTCols> cols_s = cts.getColsList();
- assertEquals(1, cols_s.size());
- CTCols cols = cols_s.get(0);
+ assertEquals(1, cts.sizeOfColsArray());
+ CTCols cols = cts.getColsArray(0);
assertEquals(1, cols.sizeOfColArray());
CTCol col = cols.getColArray(0);
@@ -773,9 +790,8 @@ public final class TestXSSFSheet extends
// Now set another
sheet.setColumnWidth(3, 33 * 256);
- cols_s = cts.getColsList();
- assertEquals(1, cols_s.size());
- cols = cols_s.get(0);
+ assertEquals(1, cts.sizeOfColsArray());
+ cols = cts.getColsArray(0);
assertEquals(2, cols.sizeOfColArray());
col = cols.getColArray(0);
@@ -960,6 +976,7 @@ public final class TestXSSFSheet extends
* but CTRows are kept in ascending order
*/
@Test
+ @SuppressWarnings("deprecation")
public void createRow() {
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet();
@@ -983,27 +1000,27 @@ public final class TestXSSFSheet extends
row3.createCell(5);
- List<CTRow> xrow = sheetData.getRowList();
- assertEquals(3, xrow.size());
+ CTRow[] xrow = sheetData.getRowArray();
+ assertEquals(3, xrow.length);
//rows are sorted: {0, 1, 2}
- assertEquals(4, xrow.get(0).sizeOfCArray());
- assertEquals(1, xrow.get(0).getR());
- assertTrue(xrow.get(0).equals(row3.getCTRow()));
-
- assertEquals(3, xrow.get(1).sizeOfCArray());
- assertEquals(2, xrow.get(1).getR());
- assertTrue(xrow.get(1).equals(row2.getCTRow()));
-
- assertEquals(2, xrow.get(2).sizeOfCArray());
- assertEquals(3, xrow.get(2).getR());
- assertTrue(xrow.get(2).equals(row1.getCTRow()));
-
- List<CTCell> xcell = xrow.get(0).getCList();
- assertEquals("D1", xcell.get(0).getR());
- assertEquals("A1", xcell.get(1).getR());
- assertEquals("C1", xcell.get(2).getR());
- assertEquals("F1", xcell.get(3).getR());
+ assertEquals(4, xrow[0].sizeOfCArray());
+ assertEquals(1, xrow[0].getR());
+ assertTrue(xrow[0].equals(row3.getCTRow()));
+
+ assertEquals(3, xrow[1].sizeOfCArray());
+ assertEquals(2, xrow[1].getR());
+ assertTrue(xrow[1].equals(row2.getCTRow()));
+
+ assertEquals(2, xrow[2].sizeOfCArray());
+ assertEquals(3, xrow[2].getR());
+ assertTrue(xrow[2].equals(row1.getCTRow()));
+
+ CTCell[] xcell = xrow[0].getCArray();
+ assertEquals("D1", xcell[0].getR());
+ assertEquals("A1", xcell[1].getR());
+ assertEquals("C1", xcell[2].getR());
+ assertEquals("F1", xcell[3].getR());
//re-creating a row does NOT add extra data to the parent
row2 = sheet.createRow(1);
@@ -1015,25 +1032,25 @@ public final class TestXSSFSheet extends
workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
sheet = workbook.getSheetAt(0);
wsh = sheet.getCTWorksheet();
- xrow = sheetData.getRowList();
- assertEquals(3, xrow.size());
+ xrow = sheetData.getRowArray();
+ assertEquals(3, xrow.length);
//rows are sorted: {0, 1, 2}
- assertEquals(4, xrow.get(0).sizeOfCArray());
- assertEquals(1, xrow.get(0).getR());
+ assertEquals(4, xrow[0].sizeOfCArray());
+ assertEquals(1, xrow[0].getR());
//cells are now sorted
- xcell = xrow.get(0).getCList();
- assertEquals("A1", xcell.get(0).getR());
- assertEquals("C1", xcell.get(1).getR());
- assertEquals("D1", xcell.get(2).getR());
- assertEquals("F1", xcell.get(3).getR());
+ xcell = xrow[0].getCArray();
+ assertEquals("A1", xcell[0].getR());
+ assertEquals("C1", xcell[1].getR());
+ assertEquals("D1", xcell[2].getR());
+ assertEquals("F1", xcell[3].getR());
- assertEquals(0, xrow.get(1).sizeOfCArray());
- assertEquals(2, xrow.get(1).getR());
+ assertEquals(0, xrow[1].sizeOfCArray());
+ assertEquals(2, xrow[1].getR());
- assertEquals(2, xrow.get(2).sizeOfCArray());
- assertEquals(3, xrow.get(2).getR());
+ assertEquals(2, xrow[2].sizeOfCArray());
+ assertEquals(3, xrow[2].getR());
}
@@ -1068,13 +1085,27 @@ public final class TestXSSFSheet extends
assertTrue("sheet protection should be on", pr.isSetSheet());
assertTrue("object protection should be on", pr.isSetObjects());
assertTrue("scenario protection should be on", pr.isSetScenarios());
- String hash = String.valueOf(HexDump.shortToHex(PasswordRecord.hashPassword(password))).substring(2);
- assertEquals("well known value for top secret hash should be "+ hash, hash, pr.xgetPassword().getStringValue());
+ int hashVal = CryptoFunctions.createXorVerifier1(password);
+ int actualVal = Integer.parseInt(pr.xgetPassword().getStringValue(),16);
+ assertEquals("well known value for top secret hash should match", hashVal, actualVal);
sheet.protectSheet(null);
assertNull("protectSheet(null) should unset CTSheetProtection", sheet.getCTWorksheet().getSheetProtection());
}
+ @Test
+ public void protectSheet_lowlevel_2013() {
+ String password = "test";
+ XSSFWorkbook wb = new XSSFWorkbook();
+ XSSFSheet xs = wb.createSheet();
+ xs.setSheetPassword(password, HashAlgorithm.sha384);
+ wb = writeOutAndReadBack(wb);
+ assertTrue(wb.getSheetAt(0).validateSheetPassword(password));
+
+ wb = openSampleWorkbook("workbookProtection-sheet_password-2013.xlsx");
+ assertTrue(wb.getSheetAt(0).validateSheetPassword("pwd"));
+ }
+
@Test
public void bug49966() {
Modified: poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java
URL: http://svn.apache.org/viewvc/poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java?rev=1625828&r1=1625827&r2=1625828&view=diff
==============================================================================
--- poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java (original)
+++ poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java Wed Sep 17 21:12:36 2014
@@ -25,9 +25,11 @@ import org.apache.poi.ss.usermodel.Comme
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellUtil;
import org.apache.poi.xssf.XSSFITestDataProvider;
import org.apache.poi.xssf.XSSFTestDataSamples;
+import org.junit.Test;
/**
* @author Yegor Kozlov
@@ -187,4 +189,14 @@ public final class TestXSSFSheetShiftRow
assertEquals("Amdocs", comment.getAuthor());
assertEquals("Amdocs:\ntest\n", comment.getString().getString());
}
+
+ @Test
+ public void testBug55280() {
+ Workbook w = new XSSFWorkbook();
+ Sheet s = w.createSheet();
+ for (int row = 0; row < 5000; ++row)
+ s.addMergedRegion(new CellRangeAddress(row, row, 0, 3));
+
+ s.shiftRows(0, 4999, 1); // takes a long time...
+ }
}
Modified: poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java
URL: http://svn.apache.org/viewvc/poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java?rev=1625828&r1=1625827&r2=1625828&view=diff
==============================================================================
--- poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java (original)
+++ poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java Wed Sep 17 21:12:36 2014
@@ -17,13 +17,8 @@
package org.apache.poi.xssf.usermodel;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.apache.poi.xssf.streaming.SXSSFWorkbook;
-import org.apache.poi.util.TempFile;
-import org.junit.Test;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTable;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTableColumn;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FileInputStream;
@@ -32,8 +27,13 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.util.TempFile;
+import org.apache.poi.xssf.XSSFTestDataSamples;
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
+import org.junit.Test;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTable;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTableColumn;
public final class TestXSSFTable {
@@ -41,6 +41,7 @@ public final class TestXSSFTable {
}
@Test
+ @SuppressWarnings("deprecation")
public void bug56274() throws IOException {
// read sample file
XSSFWorkbook inputWorkbook = XSSFTestDataSamples.openSampleWorkbook("56274.xlsx");
@@ -60,13 +61,13 @@ public final class TestXSSFTable {
// re-read the saved file and make sure headers in the xml are in the original order
inputWorkbook = new org.apache.poi.xssf.usermodel.XSSFWorkbook(new FileInputStream(outputFile));
CTTable ctTable = inputWorkbook.getSheetAt(0).getTables().get(0).getCTTable();
- List<CTTableColumn> ctTableColumnList = ctTable.getTableColumns().getTableColumnList();
+ CTTableColumn[] ctTableColumnArray = ctTable.getTableColumns().getTableColumnArray();
assertEquals("number of headers in xml table should match number of header cells in worksheet",
- headers.size(), ctTableColumnList.size());
+ headers.size(), ctTableColumnArray.length);
for (int i = 0; i < headers.size(); i++) {
assertEquals("header name in xml table should match number of header cells in worksheet",
- headers.get(i), ctTableColumnList.get(i).getName());
+ headers.get(i), ctTableColumnArray[i].getName());
}
assertTrue(outputFile.delete());
}
Modified: poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java?rev=1625828&r1=1625827&r2=1625828&view=diff
==============================================================================
--- poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java (original)
+++ poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java Wed Sep 17 21:12:36 2014
@@ -704,7 +704,7 @@ public final class TestXSSFWorkbook exte
CTPivotCache pivotCache = wb.addPivotCache("0");
//Ensures that pivotCaches is initiated
assertTrue(ctWb.isSetPivotCaches());
- assertSame(pivotCache, ctWb.getPivotCaches().getPivotCacheList().get(0));
+ assertSame(pivotCache, ctWb.getPivotCaches().getPivotCacheArray(0));
assertEquals("0", pivotCache.getId());
}
Modified: poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java
URL: http://svn.apache.org/viewvc/poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java?rev=1625828&r1=1625827&r2=1625828&view=diff
==============================================================================
--- poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java (original)
+++ poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java Wed Sep 17 21:12:36 2014
@@ -31,34 +31,34 @@ import junit.framework.TestCase;
public class TestXSSFCellFill extends TestCase {
-
- public void testGetFillBackgroundColor() {
- CTFill ctFill = CTFill.Factory.newInstance();
- XSSFCellFill cellFill = new XSSFCellFill(ctFill);
- CTPatternFill ctPatternFill = ctFill.addNewPatternFill();
- CTColor bgColor = ctPatternFill.addNewBgColor();
- assertNotNull(cellFill.getFillBackgroundColor());
- bgColor.setIndexed(2);
- assertEquals(2, cellFill.getFillBackgroundColor().getIndexed());
- }
-
- public void testGetFillForegroundColor() {
- CTFill ctFill = CTFill.Factory.newInstance();
- XSSFCellFill cellFill = new XSSFCellFill(ctFill);
- CTPatternFill ctPatternFill = ctFill.addNewPatternFill();
- CTColor fgColor = ctPatternFill.addNewFgColor();
- assertNotNull(cellFill.getFillForegroundColor());
- fgColor.setIndexed(8);
- assertEquals(8, cellFill.getFillForegroundColor().getIndexed());
- }
-
- public void testGetSetPatternType() {
- CTFill ctFill = CTFill.Factory.newInstance();
- XSSFCellFill cellFill = new XSSFCellFill(ctFill);
- CTPatternFill ctPatternFill = ctFill.addNewPatternFill();
- ctPatternFill.setPatternType(STPatternType.SOLID);
- //assertEquals(FillPatternType.SOLID_FOREGROUND.ordinal(), cellFill.getPatternType().ordinal());
- }
+
+ public void testGetFillBackgroundColor() {
+ CTFill ctFill = CTFill.Factory.newInstance();
+ XSSFCellFill cellFill = new XSSFCellFill(ctFill);
+ CTPatternFill ctPatternFill = ctFill.addNewPatternFill();
+ CTColor bgColor = ctPatternFill.addNewBgColor();
+ assertNotNull(cellFill.getFillBackgroundColor());
+ bgColor.setIndexed(2);
+ assertEquals(2, cellFill.getFillBackgroundColor().getIndexed());
+ }
+
+ public void testGetFillForegroundColor() {
+ CTFill ctFill = CTFill.Factory.newInstance();
+ XSSFCellFill cellFill = new XSSFCellFill(ctFill);
+ CTPatternFill ctPatternFill = ctFill.addNewPatternFill();
+ CTColor fgColor = ctPatternFill.addNewFgColor();
+ assertNotNull(cellFill.getFillForegroundColor());
+ fgColor.setIndexed(8);
+ assertEquals(8, cellFill.getFillForegroundColor().getIndexed());
+ }
+
+ public void testGetSetPatternType() {
+ CTFill ctFill = CTFill.Factory.newInstance();
+ XSSFCellFill cellFill = new XSSFCellFill(ctFill);
+ CTPatternFill ctPatternFill = ctFill.addNewPatternFill();
+ ctPatternFill.setPatternType(STPatternType.SOLID);
+ //assertEquals(FillPatternType.SOLID_FOREGROUND.ordinal(), cellFill.getPatternType().ordinal());
+ }
public void testGetNotModifies() {
CTFill ctFill = CTFill.Factory.newInstance();
@@ -75,11 +75,16 @@ public class TestXSSFCellFill extends Te
XSSFColor foregroundColor = cellWithThemeColor.getCellStyle().getFillForegroundXSSFColor();
byte[] rgb = foregroundColor.getRgb();
byte[] rgbWithTint = foregroundColor.getRgbWithTint();
- assertEquals(rgb[0],-18);
- assertEquals(rgb[1],-20);
- assertEquals(rgb[2],-31);
- assertEquals(rgbWithTint[0],-12);
- assertEquals(rgbWithTint[1],-13);
- assertEquals(rgbWithTint[2],-20);
+ // Dk2
+ assertEquals(rgb[0],31);
+ assertEquals(rgb[1],73);
+ assertEquals(rgb[2],125);
+ // Dk2, lighter 40% (tint is about 0.39998)
+ // 31 * (1.0 - 0.39998) + (255 - 255 * (1.0 - 0.39998)) = 120.59552 => 120 (byte)
+ // 73 * (1.0 - 0.39998) + (255 - 255 * (1.0 - 0.39998)) = 145.79636 => -111 (byte)
+ // 125 * (1.0 - 0.39998) + (255 - 255 * (1.0 - 0.39998)) = 176.99740 => -80 (byte)
+ assertEquals(rgbWithTint[0],120);
+ assertEquals(rgbWithTint[1],-111);
+ assertEquals(rgbWithTint[2],-80);
}
}
Modified: poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/helpers/TestColumnHelper.java
URL: http://svn.apache.org/viewvc/poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/helpers/TestColumnHelper.java?rev=1625828&r1=1625827&r2=1625828&view=diff
==============================================================================
--- poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/helpers/TestColumnHelper.java (original)
+++ poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/usermodel/helpers/TestColumnHelper.java Wed Sep 17 21:12:36 2014
@@ -186,7 +186,7 @@ public final class TestColumnHelper exte
helper.addCleanColIntoCols(cols1, col9);
// TODO - assert something interesting
- assertEquals(12, cols1.getColList().size());
+ assertEquals(12, cols1.sizeOfColArray());
assertEquals(1, cols1.getColArray(0).getMin());
assertEquals(16750, cols1.getColArray(11).getMax());
}
Modified: poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/util/TestCTColComparator.java
URL: http://svn.apache.org/viewvc/poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/util/TestCTColComparator.java?rev=1625828&r1=1625827&r2=1625828&view=diff
==============================================================================
--- poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/util/TestCTColComparator.java (original)
+++ poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xssf/util/TestCTColComparator.java Wed Sep 17 21:12:36 2014
@@ -27,39 +27,37 @@ import org.openxmlformats.schemas.spread
public final class TestCTColComparator extends TestCase {
public void testCompare() {
- CTColComparator comparator = new CTColComparator();
CTCol o1 = CTCol.Factory.newInstance();
o1.setMin(1);
o1.setMax(10);
CTCol o2 = CTCol.Factory.newInstance();
o2.setMin(11);
o2.setMax(12);
- assertEquals(-1, comparator.compare(o1, o2));
+ assertEquals(-1, CTColComparator.BY_MIN_MAX.compare(o1, o2));
CTCol o3 = CTCol.Factory.newInstance();
o3.setMin(5);
o3.setMax(8);
CTCol o4 = CTCol.Factory.newInstance();
o4.setMin(5);
o4.setMax(80);
- assertEquals(-1, comparator.compare(o3, o4));
+ assertEquals(-1, CTColComparator.BY_MIN_MAX.compare(o3, o4));
}
public void testArraysSort() {
- CTColComparator comparator = new CTColComparator();
CTCol o1 = CTCol.Factory.newInstance();
o1.setMin(1);
o1.setMax(10);
CTCol o2 = CTCol.Factory.newInstance();
o2.setMin(11);
o2.setMax(12);
- assertEquals(-1, comparator.compare(o1, o2));
+ assertEquals(-1, CTColComparator.BY_MIN_MAX.compare(o1, o2));
CTCol o3 = CTCol.Factory.newInstance();
o3.setMin(5);
o3.setMax(80);
CTCol o4 = CTCol.Factory.newInstance();
o4.setMin(5);
o4.setMax(8);
- assertEquals(1, comparator.compare(o3, o4));
+ assertEquals(1, CTColComparator.BY_MIN_MAX.compare(o3, o4));
CTCol[] cols = new CTCol[4];
cols[0] = o1;
cols[1] = o2;
@@ -67,7 +65,7 @@ public final class TestCTColComparator e
cols[3] = o4;
assertEquals(80, cols[2].getMax());
assertEquals(8, cols[3].getMax());
- Arrays.sort(cols, comparator);
+ Arrays.sort(cols, CTColComparator.BY_MIN_MAX);
assertEquals(12, cols[3].getMax());
assertEquals(8, cols[1].getMax());
assertEquals(80, cols[2].getMax());
Modified: poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java
URL: http://svn.apache.org/viewvc/poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java?rev=1625828&r1=1625827&r2=1625828&view=diff
==============================================================================
--- poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java (original)
+++ poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java Wed Sep 17 21:12:36 2014
@@ -19,6 +19,7 @@ package org.apache.poi.xwpf.usermodel;
import java.io.IOException;
import java.io.OutputStream;
+import java.util.Arrays;
import java.util.List;
import junit.framework.TestCase;
@@ -32,7 +33,6 @@ import org.apache.poi.openxml4j.opc.Pack
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.openxml4j.opc.PackagingURIHelper;
import org.apache.poi.openxml4j.opc.TargetMode;
-import org.apache.poi.util.ArrayUtil;
import org.apache.poi.xwpf.XWPFTestDataSamples;
import org.apache.xmlbeans.XmlCursor;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
@@ -234,7 +234,7 @@ public final class TestXWPFDocument exte
OutputStream os = newImagePart.getOutputStream();
os.write(nature1);
os.close();
- XWPFHeader xwpfHeader = doc.getHeaderList().get(0);
+ XWPFHeader xwpfHeader = doc.getHeaderArray(0);
PackageRelationship relationship = xwpfHeader.getPackagePart().addRelationship(partName, TargetMode.INTERNAL, jpgRelation.getRelation());
XWPFPictureData newPicData = new XWPFPictureData(newImagePart,relationship);
/* new part is now ready to rumble */
@@ -307,7 +307,7 @@ public final class TestXWPFDocument exte
String id1 = doc.addPictureData(newPic, Document.PICTURE_TYPE_JPEG);
assertEquals(2,doc.getAllPackagePictures().size());
/* copy data, to avoid instance-equality */
- byte[] newPicCopy = ArrayUtil.copyOf(newPic, newPic.length);
+ byte[] newPicCopy = Arrays.copyOf(newPic, newPic.length);
String id2 = doc.addPictureData(newPicCopy, Document.PICTURE_TYPE_JPEG);
assertEquals(id1,id2);
doc.getPackage().revert();
@@ -317,13 +317,13 @@ public final class TestXWPFDocument exte
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("issue_51265_2.docx");
assertEquals(1,doc.getAllPictures().size());
assertEquals(1,doc.getAllPackagePictures().size());
- assertEquals(1,doc.getHeaderList().get(0).getAllPictures().size());
+ assertEquals(1,doc.getHeaderArray(0).getAllPictures().size());
doc.getPackage().revert();
}
public void testPictureHandlingComplex() throws IOException, InvalidFormatException {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("issue_51265_3.docx");
- XWPFHeader xwpfHeader = doc.getHeaderList().get(0);
+ XWPFHeader xwpfHeader = doc.getHeaderArray(0);
assertEquals(3,doc.getAllPictures().size());
assertEquals(3,xwpfHeader.getAllPictures().size());
Modified: poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java
URL: http://svn.apache.org/viewvc/poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java?rev=1625828&r1=1625827&r2=1625828&view=diff
==============================================================================
--- poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java (original)
+++ poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java Wed Sep 17 21:12:36 2014
@@ -24,6 +24,9 @@ import java.util.List;
import junit.framework.TestCase;
import org.apache.poi.xwpf.XWPFTestDataSamples;
+import org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture;
+import org.openxmlformats.schemas.drawingml.x2006.picture.PicDocument;
+import org.openxmlformats.schemas.drawingml.x2006.picture.impl.PicDocumentImpl;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBookmark;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTInd;
@@ -39,9 +42,6 @@ import org.openxmlformats.schemas.wordpr
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STLineSpacingRule;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTextAlignment;
-import org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture;
-import org.openxmlformats.schemas.drawingml.x2006.picture.PicDocument;
-import org.openxmlformats.schemas.drawingml.x2006.picture.impl.PicDocumentImpl;
/**
* Tests for XWPF Paragraphs
@@ -62,7 +62,7 @@ public final class TestXWPFParagraph ext
assertEquals(1, ps.size());
XWPFParagraph p = ps.get(0);
- assertEquals(5, p.getCTP().getRList().size());
+ assertEquals(5, p.getCTP().sizeOfRArray());
assertEquals("First header column!\tMid header\tRight header!", p
.getText());
}
@@ -234,6 +234,7 @@ public final class TestXWPFParagraph ext
assertEquals(STOnOff.TRUE, ppr.getPageBreakBefore().getVal());
}
+ @SuppressWarnings("deprecation")
public void testBookmarks() throws IOException {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("bookmarks.docx");
XWPFParagraph paragraph = doc.getParagraphs().get(0);
@@ -242,7 +243,7 @@ public final class TestXWPFParagraph ext
assertEquals(0, paragraph.getCTP().sizeOfBookmarkEndArray());
CTBookmark ctBookmark = paragraph.getCTP().getBookmarkStartArray(0);
assertEquals("poi", ctBookmark.getName());
- for(CTBookmark bookmark : paragraph.getCTP().getBookmarkStartList()) {
+ for(CTBookmark bookmark : paragraph.getCTP().getBookmarkStartArray()) {
assertEquals("poi", bookmark.getName());
}
}
Modified: poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFRun.java
URL: http://svn.apache.org/viewvc/poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFRun.java?rev=1625828&r1=1625827&r2=1625828&view=diff
==============================================================================
--- poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFRun.java (original)
+++ poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFRun.java Wed Sep 17 21:12:36 2014
@@ -180,7 +180,7 @@ public class TestXWPFRun extends TestCas
run.addCarriageReturn();
run.setText("T2");
run.addCarriageReturn();
- assertEquals(3, run.getCTR().getCrList().size());
+ assertEquals(3, run.getCTR().sizeOfCrArray());
assertEquals("T1\n\nT2\n", run.toString());
}
@@ -200,8 +200,8 @@ public class TestXWPFRun extends TestCas
run.setText("T2");
run.addTab();
run.setText("T3");
- assertEquals(1, run.getCTR().getCrList().size());
- assertEquals(1, run.getCTR().getTabList().size());
+ assertEquals(1, run.getCTR().sizeOfCrArray());
+ assertEquals(1, run.getCTR().sizeOfTabArray());
assertEquals("T1\nT2\tT3", run.toString());
}
Modified: poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFStyles.java
URL: http://svn.apache.org/viewvc/poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFStyles.java?rev=1625828&r1=1625827&r2=1625828&view=diff
==============================================================================
--- poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFStyles.java (original)
+++ poi/branches/xml_signature/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFStyles.java Wed Sep 17 21:12:36 2014
@@ -116,6 +116,6 @@ public class TestXWPFStyles extends Test
ex.setName("ex1");
XWPFLatentStyles ls = new XWPFLatentStyles(latentStyles);
assertEquals(true, ls.isLatentStyle("ex1"));
-
+ assertEquals(false, ls.isLatentStyle("notex1"));
}
}
Modified: poi/branches/xml_signature/src/scratchpad/src/org/apache/poi/hwpf/model/NilPICFAndBinData.java
URL: http://svn.apache.org/viewvc/poi/branches/xml_signature/src/scratchpad/src/org/apache/poi/hwpf/model/NilPICFAndBinData.java?rev=1625828&r1=1625827&r2=1625828&view=diff
==============================================================================
--- poi/branches/xml_signature/src/scratchpad/src/org/apache/poi/hwpf/model/NilPICFAndBinData.java (original)
+++ poi/branches/xml_signature/src/scratchpad/src/org/apache/poi/hwpf/model/NilPICFAndBinData.java Wed Sep 17 21:12:36 2014
@@ -16,11 +16,12 @@
==================================================================== */
package org.apache.poi.hwpf.model;
-import org.apache.poi.util.ArrayUtil;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
+import java.util.Arrays;
+
public class NilPICFAndBinData
{
@@ -52,8 +53,8 @@ public class NilPICFAndBinData
// skip the 62 ignored bytes
int binaryLength = lcb - cbHeader;
- this._binData = ArrayUtil.copyOfRange( data, offset + cbHeader,
- offset + cbHeader + binaryLength );
+ this._binData = Arrays.copyOfRange(data, offset + cbHeader,
+ offset + cbHeader + binaryLength);
}
public byte[] getBinData()
Modified: poi/branches/xml_signature/src/scratchpad/src/org/apache/poi/hwpf/model/PlfLfo.java
URL: http://svn.apache.org/viewvc/poi/branches/xml_signature/src/scratchpad/src/org/apache/poi/hwpf/model/PlfLfo.java?rev=1625828&r1=1625827&r2=1625828&view=diff
==============================================================================
--- poi/branches/xml_signature/src/scratchpad/src/org/apache/poi/hwpf/model/PlfLfo.java (original)
+++ poi/branches/xml_signature/src/scratchpad/src/org/apache/poi/hwpf/model/PlfLfo.java Wed Sep 17 21:12:36 2014
@@ -23,7 +23,6 @@ import java.util.Arrays;
import java.util.NoSuchElementException;
import org.apache.poi.hwpf.model.io.HWPFOutputStream;
-import org.apache.poi.util.ArrayUtil;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
@@ -118,10 +117,10 @@ public class PlfLfo
{
final int newLfoMac = _lfoMac + 1;
- _rgLfo = ArrayUtil.copyOf( _rgLfo, new LFO[newLfoMac] );
+ _rgLfo = Arrays.copyOf(_rgLfo, newLfoMac);
_rgLfo[_lfoMac + 1] = lfo;
- _rgLfoData = ArrayUtil.copyOf( _rgLfoData, new LFOData[_lfoMac + 1] );
+ _rgLfoData = Arrays.copyOf(_rgLfoData, newLfoMac);
_rgLfoData[_lfoMac + 1] = lfoData;
this._lfoMac = newLfoMac;
Modified: poi/branches/xml_signature/src/scratchpad/src/org/apache/poi/hwpf/model/Sttb.java
URL: http://svn.apache.org/viewvc/poi/branches/xml_signature/src/scratchpad/src/org/apache/poi/hwpf/model/Sttb.java?rev=1625828&r1=1625827&r2=1625828&view=diff
==============================================================================
--- poi/branches/xml_signature/src/scratchpad/src/org/apache/poi/hwpf/model/Sttb.java (original)
+++ poi/branches/xml_signature/src/scratchpad/src/org/apache/poi/hwpf/model/Sttb.java Wed Sep 17 21:12:36 2014
@@ -16,10 +16,11 @@
==================================================================== */
package org.apache.poi.hwpf.model;
-import org.apache.poi.util.ArrayUtil;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.StringUtil;
+import java.util.Arrays;
+
/**
* The STTB is a string table that is made up of a header that is followed by an
* array of elements. The cData value specifies the number of elements that are
@@ -64,7 +65,7 @@ public class Sttb
{
this._cDataLength = cDataLength;
- this._data = ArrayUtil.copyOf( data, new String[data.length] );
+ this._data = Arrays.copyOf(data, data.length);
this._cbExtra = 0;
this._extraData = null;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org