field_3_outline_style_level = in.readByte();
} else {
int field_2_name_length = in.readShort();
-
+
if(in.remaining() < 1) {
// Some files from Crystal Reports lack the is16BitUnicode byte
// the remaining fields, which is naughty
// guess this is OK if the string length is zero
field_4_name = "";
} else {
-
+
field_3_stringHasMultibyte = in.readByte() != 0x00;
if (field_3_stringHasMultibyte) {
field_4_name = StringUtil.readUnicodeLE(in, field_2_name_length);
/**
* get the actual index of the style extended format record
- * @see #getXFIndex()
+ * @see #getXFIndex()
* @return index of the xf record
*/
public int getXFIndex() {
return field_4_name;
}
+ @Override
public String toString() {
StringBuffer sb = new StringBuffer();
return sb.toString();
}
-
+
+ @Override
protected int getDataSize() {
if (isBuiltin()) {
return 4; // short, byte, byte
}
- return 2 // short xf index
- + 3 // str len + flag
+ return 2 // short xf index
+ + 3 // str len + flag
+ field_4_name.length() * (field_3_stringHasMultibyte ? 2 : 1);
}
+ @Override
public void serialize(LittleEndianOutput out) {
out.writeShort(field_1_xf_index);
if (isBuiltin()) {
}
}
+ @Override
public short getSid() {
return sid;
}
*
* @param part - The package part that holds xml data represenring this sheet.
* @param rel - the relationship of the given package part
- * @see #read(POIXMLFactory, java.util.Map)
+ * @see #read(POIXMLFactory, java.util.Map)
*/
public POIXMLDocumentPart(PackagePart part, PackageRelationship rel){
this.packagePart = part;
/**
* When you open something like a theme, call this to
* re-base the XML Document onto the core child of the
- * current core document
+ * current core document
*/
protected final void rebase(OPCPackage pkg) throws InvalidFormatException {
PackageRelationshipCollection cores =
* {@link POIXMLDocumentPart} to the {@link PackagePart} of the target
* {@link POIXMLDocumentPart} with a {@link PackageRelationship#getId()}
* matching the given parameter value.
- *
+ *
* @param id
* The relation id to look for
* @return the target part of the relation, or null, if none exists
* {@link PackageRelationship}, that sources from the {@link PackagePart} of
* this {@link POIXMLDocumentPart} to the {@link PackagePart} of the given
* parameter value.
- *
+ *
* @param part
* The {@link POIXMLDocumentPart} for which the according
* relation-id shall be found.
/**
* Remove the relation to the specified part in this package and remove the
* part, if it is no longer needed and flag is set to true.
- *
+ *
* @param part
* The related part, to which the relation shall be removed.
* @param removeUnusedParts
* @param noRelation if true, then no relationship is added.
* @return the created child POIXMLDocumentPart
*/
- protected final POIXMLDocumentPart createRelationship(POIXMLRelation descriptor, POIXMLFactory factory, int idx, boolean noRelation){
+ @SuppressWarnings("null")
+ protected final POIXMLDocumentPart createRelationship(POIXMLRelation descriptor, POIXMLFactory factory, int idx, boolean noRelation){
try {
PackagePartName ppName = PackagingURIHelper.createPartName(descriptor.getFileName(idx));
PackageRelationship rel = null;
}
}
}
-
+
/**
* Get the PackagePart that is the target of a relationship from this Part.
*
==================================================================== */\r
package org.apache.poi;\r
\r
-import java.io.*;\r
+import java.io.ByteArrayOutputStream;\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.FileNotFoundException;\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
\r
/**\r
* Centralises logic for finding/opening sample files\r
_is = is;\r
}\r
\r
- public int read() throws IOException {\r
+ @Override\r
+ public int read() throws IOException {\r
return _is.read();\r
}\r
- public int read(byte[] b, int off, int len) throws IOException {\r
+ @Override\r
+ public int read(byte[] b, int off, int len) throws IOException {\r
return _is.read(b, off, len);\r
}\r
- public boolean markSupported() {\r
+ @Override\r
+ public boolean markSupported() {\r
return false;\r
}\r
- public void close() throws IOException {\r
+ @Override\r
+ public void close() throws IOException {\r
_is.close();\r
}\r
}\r
public void testRemoveCell() {
Workbook workbook = _testDataProvider.createWorkbook();
- Sheet sheet = workbook.createSheet();
- Row row = sheet.createRow(0);
-
- assertEquals(0, row.getPhysicalNumberOfCells());
- assertEquals(-1, row.getLastCellNum());
- assertEquals(-1, row.getFirstCellNum());
-
- row.createCell(1);
- assertEquals(2, row.getLastCellNum());
- assertEquals(1, row.getFirstCellNum());
- assertEquals(1, row.getPhysicalNumberOfCells());
- row.createCell(3);
- assertEquals(4, row.getLastCellNum());
- assertEquals(1, row.getFirstCellNum());
- assertEquals(2, row.getPhysicalNumberOfCells());
- row.removeCell(row.getCell(3));
- assertEquals(2, row.getLastCellNum());
- assertEquals(1, row.getFirstCellNum());
- assertEquals(1, row.getPhysicalNumberOfCells());
- row.removeCell(row.getCell(1));
- assertEquals(-1, row.getLastCellNum());
- assertEquals(-1, row.getFirstCellNum());
- assertEquals(0, row.getPhysicalNumberOfCells());
+ {
+ Sheet sheet = workbook.createSheet();
+ Row row = sheet.createRow(0);
+
+ assertEquals(0, row.getPhysicalNumberOfCells());
+ assertEquals(-1, row.getLastCellNum());
+ assertEquals(-1, row.getFirstCellNum());
+
+ row.createCell(1);
+ assertEquals(2, row.getLastCellNum());
+ assertEquals(1, row.getFirstCellNum());
+ assertEquals(1, row.getPhysicalNumberOfCells());
+ row.createCell(3);
+ assertEquals(4, row.getLastCellNum());
+ assertEquals(1, row.getFirstCellNum());
+ assertEquals(2, row.getPhysicalNumberOfCells());
+ row.removeCell(row.getCell(3));
+ assertEquals(2, row.getLastCellNum());
+ assertEquals(1, row.getFirstCellNum());
+ assertEquals(1, row.getPhysicalNumberOfCells());
+ row.removeCell(row.getCell(1));
+ assertEquals(-1, row.getLastCellNum());
+ assertEquals(-1, row.getFirstCellNum());
+ assertEquals(0, row.getPhysicalNumberOfCells());
+ }
workbook = _testDataProvider.writeOutAndReadBack(workbook);
- sheet = workbook.getSheetAt(0);
- row = sheet.getRow(0);
- assertEquals(-1, row.getLastCellNum());
- assertEquals(-1, row.getFirstCellNum());
- assertEquals(0, row.getPhysicalNumberOfCells());
+
+ {
+ Sheet sheet = workbook.getSheetAt(0);
+ Row row = sheet.getRow(0);
+ assertEquals(-1, row.getLastCellNum());
+ assertEquals(-1, row.getFirstCellNum());
+ assertEquals(0, row.getPhysicalNumberOfCells());
+ }
}
public void baseTestRowBounds(int maxRowNum) {
assertTrue(cell2 == it.next());
assertEquals(Cell.CELL_TYPE_STRING, cell5.getCellType());
}
-
+
public void testRowStyle() {
Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet("test");
Row row1 = sheet.createRow(0);
Row row2 = sheet.createRow(1);
-
+
// Won't be styled currently
assertEquals(false, row1.isFormatted());
assertEquals(false, row2.isFormatted());
assertEquals(null, row1.getRowStyle());
assertEquals(null, row2.getRowStyle());
-
+
// Style one
CellStyle style = workbook.createCellStyle();
style.setDataFormat((short)4);
row2.setRowStyle(style);
-
+
// Check
assertEquals(false, row1.isFormatted());
assertEquals(true, row2.isFormatted());
assertEquals(null, row1.getRowStyle());
assertEquals(style, row2.getRowStyle());
-
+
// Save, load and re-check
workbook = _testDataProvider.writeOutAndReadBack(workbook);
sheet = workbook.getSheetAt(0);
row1 = sheet.getRow(0);
row2 = sheet.getRow(1);
style = workbook.getCellStyleAt(style.getIndex());
-
+
assertEquals(false, row1.isFormatted());
assertEquals(true, row2.isFormatted());
assertEquals(null, row1.getRowStyle());