From: Dominik Stadler
* Please note, that this method works correctly only for workbooks
* with the default font size (Arial 10pt for .xls and Calibri 11pt for .xlsx).
- * If the default font is changed the column width can be streched
+ * If the default font is changed the column width can be stretched
*
* If both colSplit and rowSplit are zero then the existing freeze pane is removed *
- * @param colSplit Horizonatal position of split. + * @param colSplit Horizontal position of split. * @param rowSplit Vertical position of split. * @param leftmostColumn Left column visible in right pane. * @param topRow Top row visible in bottom pane @@ -731,14 +731,14 @@ public interface Sheet extends Iterable* If both colSplit and rowSplit are zero then the existing freeze pane is removed *
- * @param colSplit Horizonatal position of split. + * @param colSplit Horizontal position of split. * @param rowSplit Vertical position of split. */ void createFreezePane(int colSplit, int rowSplit); /** * Creates a split pane. Any existing freezepane or split pane is overwritten. - * @param xSplitPos Horizonatal position of split (in 1/20th of a point). + * @param xSplitPos Horizontal position of split (in 1/20th of a point). * @param ySplitPos Vertical position of split (in 1/20th of a point). * @param topRow Top row visible in bottom pane * @param leftmostColumn Left column visible in right pane. @@ -804,7 +804,7 @@ public interface Sheet extends Iterablesheet.setColumnBreak(2);
breaks the sheet into two parts
- * with columns A,B,C in the first and D,E,... in the second. Simuilar, sheet.setRowBreak(2);
+ * with columns A,B,C in the first and D,E,... in the second. Similar, sheet.setRowBreak(2);
* breaks the sheet into two parts with first three rows (rownum=1...3) in the first part
* and rows starting with rownum=4 in the second.
*
@@ -842,7 +842,7 @@ public interface Sheet extends Iterablesheet.setColumnBreak(2);
breaks the sheet into two parts
- * with columns A,B,C in the first and D,E,... in the second. Simuilar, sheet.setRowBreak(2);
+ * with columns A,B,C in the first and D,E,... in the second. Similar, sheet.setRowBreak(2);
* breaks the sheet into two parts with first three rows (rownum=1...3) in the first part
* and rows starting with rownum=4 in the second.
*
diff --git a/src/java/org/apache/poi/util/LittleEndianByteArrayInputStream.java b/src/java/org/apache/poi/util/LittleEndianByteArrayInputStream.java
index fcb44f653e..0a28333e25 100644
--- a/src/java/org/apache/poi/util/LittleEndianByteArrayInputStream.java
+++ b/src/java/org/apache/poi/util/LittleEndianByteArrayInputStream.java
@@ -23,16 +23,55 @@ import java.io.ByteArrayInputStream;
* Adapts a plain byte array to {@link LittleEndianInput}
*/
public class LittleEndianByteArrayInputStream extends ByteArrayInputStream implements LittleEndianInput {
- public LittleEndianByteArrayInputStream(byte[] buf, int startOffset, int maxReadLen) { // NOSONAR
- super(buf, startOffset, maxReadLen);
+ /**
+ * Creates LittleEndianByteArrayInputStream
+ * that uses buf
as its
+ * buffer array. The initial value of pos
+ * is offset
and the initial value
+ * of count
is the minimum of offset+length
+ * and buf.length
.
+ * The buffer array is not copied. The buffer's mark is
+ * set to the specified offset.
+ *
+ * @param buf the input buffer.
+ * @param offset the offset in the buffer of the first byte to read.
+ * @param length the maximum number of bytes to read from the buffer.
+ */
+ public LittleEndianByteArrayInputStream(byte[] buf, int offset, int length) { // NOSONAR
+ super(buf, offset, length);
}
-
- public LittleEndianByteArrayInputStream(byte[] buf, int startOffset) {
- this(buf, startOffset, buf.length - startOffset);
+
+ /**
+ * Creates LittleEndianByteArrayInputStream
+ * that uses buf
as its
+ * buffer array. The initial value of pos
+ * is offset
and the initial value
+ * of count
is the minimum of offset+buf.length
+ * and buf.length
.
+ * The buffer array is not copied. The buffer's mark is
+ * set to the specified offset.
+ *
+ * @param buf the input buffer.
+ * @param offset the offset in the buffer of the first byte to read.
+ */
+ public LittleEndianByteArrayInputStream(byte[] buf, int offset) {
+ this(buf, offset, buf.length - offset);
}
-
+
+ /**
+ * Creates a LittleEndianByteArrayInputStream
+ * so that it uses buf
as its
+ * buffer array.
+ * The buffer array is not copied.
+ * The initial value of pos
+ * is 0
and the initial value
+ * of count
is the length of
+ * buf
.
+ *
+ * @param buf the input buffer.
+ */
public LittleEndianByteArrayInputStream(byte[] buf) {
- this(buf, 0);
+ super(buf);
}
protected void checkPosition(int i) {
diff --git a/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java b/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java
index 68799fdca5..9f49886563 100644
--- a/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java
+++ b/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java
@@ -18,8 +18,6 @@ package org.apache.poi.xwpf.model;
import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.POIXMLDocumentPart.RelationPart;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFFactory;
import org.apache.poi.xwpf.usermodel.XWPFFooter;
@@ -187,8 +185,7 @@ public class XWPFHeaderFooterPolicy {
XWPFFactory.getInstance(), i);
wrapper.setXWPFDocument(doc);
- String pStyle = "Header";
- CTHdrFtr hdr = buildHdr(type, pStyle, wrapper, pars);
+ CTHdrFtr hdr = buildHdr(type, wrapper, pars);
wrapper.setHeaderFooter(hdr);
hdrDoc.setHdr(hdr);
assignHeader(wrapper, type);
@@ -224,8 +221,7 @@ public class XWPFHeaderFooterPolicy {
XWPFFactory.getInstance(), i);
wrapper.setXWPFDocument(doc);
- String pStyle = "Footer";
- CTHdrFtr ftr = buildFtr(type, pStyle, wrapper, pars);
+ CTHdrFtr ftr = buildFtr(type, wrapper, pars);
wrapper.setHeaderFooter(ftr);
ftrDoc.setFtr(ftr);
assignFooter(wrapper, type);
@@ -245,16 +241,16 @@ public class XWPFHeaderFooterPolicy {
return i;
}
- private CTHdrFtr buildFtr(Enum type, String pStyle, XWPFHeaderFooter wrapper, XWPFParagraph[] pars) {
+ private CTHdrFtr buildFtr(Enum type, XWPFHeaderFooter wrapper, XWPFParagraph[] pars) {
//CTHdrFtr ftr = buildHdrFtr(pStyle, pars); // MB 24 May 2010
- CTHdrFtr ftr = buildHdrFtr(pStyle, pars, wrapper); // MB 24 May 2010
+ CTHdrFtr ftr = buildHdrFtr(pars, wrapper); // MB 24 May 2010
setFooterReference(type, wrapper);
return ftr;
}
- private CTHdrFtr buildHdr(Enum type, String pStyle, XWPFHeaderFooter wrapper, XWPFParagraph[] pars) {
+ private CTHdrFtr buildHdr(Enum type, XWPFHeaderFooter wrapper, XWPFParagraph[] pars) {
//CTHdrFtr hdr = buildHdrFtr(pStyle, pars); // MB 24 May 2010
- CTHdrFtr hdr = buildHdrFtr(pStyle, pars, wrapper); // MB 24 May 2010
+ CTHdrFtr hdr = buildHdrFtr(pars, wrapper); // MB 24 May 2010
setHeaderReference(type, wrapper);
return hdr;
}
@@ -271,11 +267,11 @@ public class XWPFHeaderFooterPolicy {
* that had previoulsy been instantiated in the createHeader(int, XWPFParagraph[]) or
* createFooter(int, XWPFParagraph[]) methods.
*/
- private CTHdrFtr buildHdrFtr(String pStyle, XWPFParagraph[] paragraphs, XWPFHeaderFooter wrapper) {
+ private CTHdrFtr buildHdrFtr(XWPFParagraph[] paragraphs, XWPFHeaderFooter wrapper) {
CTHdrFtr ftr = wrapper._getHdrFtr();
if (paragraphs != null) {
for (int i = 0; i < paragraphs.length; i++) {
- CTP p = ftr.addNewP();
+ /*CTP p =*/ ftr.addNewP();
ftr.setPArray(i, paragraphs[i].getCTP());
}
// } else {
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java
index 2d0aec1671..bb9a9a6a45 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java
@@ -110,18 +110,18 @@ public final class TestSXSSFBugs extends BaseTestBugzillaIssues {
@Test
public void bug61648() throws Exception {
// works as expected
- writeWorkbook(new XSSFWorkbook(), "/tmp/61648.xlsx", XSSFITestDataProvider.instance);
+ writeWorkbook(new XSSFWorkbook(), XSSFITestDataProvider.instance);
// does not work
try {
- writeWorkbook(new SXSSFWorkbook(), "/tmp/61648s.xlsx", SXSSFITestDataProvider.instance);
+ writeWorkbook(new SXSSFWorkbook(), SXSSFITestDataProvider.instance);
fail("Should catch exception here");
} catch (RuntimeException e) {
// this is not implemented yet
}
}
- void writeWorkbook(Workbook wb, String filename, ITestDataProvider testDataProvider) throws IOException {
+ void writeWorkbook(Workbook wb, ITestDataProvider testDataProvider) throws IOException {
Sheet sheet = wb.createSheet("array formula test");
int rowIndex = 0;
diff --git a/src/testcases/org/apache/poi/util/TestLittleEndianStreams.java b/src/testcases/org/apache/poi/util/TestLittleEndianStreams.java
index 1b327669ae..32373c2be7 100644
--- a/src/testcases/org/apache/poi/util/TestLittleEndianStreams.java
+++ b/src/testcases/org/apache/poi/util/TestLittleEndianStreams.java
@@ -97,4 +97,30 @@ public final class TestLittleEndianStreams extends TestCase {
assertTrue(e.getMessage().contains("Buffer overrun"));
}
}
+
+ public void testBufferOverrunStartOffset() {
+ byte[] srcBuf = HexRead.readFromString("99 88 77 88 99");
+ LittleEndianInput lei = new LittleEndianByteArrayInputStream(srcBuf, 2);
+
+ // only one byte left, so this should fail
+ try {
+ lei.readFully(new byte[4]);
+ fail("Should catch exception here");
+ } catch (RuntimeException e) {
+ assertTrue(e.getMessage().contains("Buffer overrun"));
+ }
+ }
+
+ public void testBufferOverrunStartOffset2() {
+ byte[] srcBuf = HexRead.readFromString("99 88 77 88 99");
+ LittleEndianInput lei = new LittleEndianByteArrayInputStream(srcBuf, 2, 2);
+
+ // only one byte left, so this should fail
+ try {
+ lei.readFully(new byte[4]);
+ fail("Should catch exception here");
+ } catch (RuntimeException e) {
+ assertTrue(e.getMessage().contains("Buffer overrun"));
+ }
+ }
}