* method will include such rows and thus the returned value might be higher
* than expected!
*
- * @return last row contained n this sheet (0-based)
+ * @return last row contained on this sheet (0-based)
*/
int getLastRowNum();
* Get the visibility state for a given column
*
* @param columnIndex - the column to get (0-based)
- * @param hidden - the visiblity state of the column
+ * @param hidden - the visibility state of the column
*/
void setColumnHidden(int columnIndex, boolean hidden);
* <p>
* 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
* </p>
*
* @param columnIndex - the column to set (0-based)
* evaluation in POI is not possible.
* </p>
*
- * To force recalcuation of formulas in the entire workbook
+ * To force recalculation of formulas in the entire workbook
* use {@link Workbook#setForceFormulaRecalculation(boolean)} instead.
*
* @param value true if the application will perform a full recalculation of
* <p>
* If both colSplit and rowSplit are zero then the existing freeze pane is removed
* </p>
- * @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
* <p>
* If both colSplit and rowSplit are zero then the existing freeze pane is removed
* </p>
- * @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.
* Breaks occur above the specified row and left of the specified column inclusive.
*
* For example, <code>sheet.setColumnBreak(2);</code> breaks the sheet into two parts
- * with columns A,B,C in the first and D,E,... in the second. Simuilar, <code>sheet.setRowBreak(2);</code>
+ * with columns A,B,C in the first and D,E,... in the second. Similar, <code>sheet.setRowBreak(2);</code>
* 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.
*
* Breaks occur above the specified row and left of the specified column inclusive.
*
* For example, <code>sheet.setColumnBreak(2);</code> breaks the sheet into two parts
- * with columns A,B,C in the first and D,E,... in the second. Simuilar, <code>sheet.setRowBreak(2);</code>
+ * with columns A,B,C in the first and D,E,... in the second. Similar, <code>sheet.setRowBreak(2);</code>
* 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.
*
* 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 <code>LittleEndianByteArrayInputStream</code>
+ * that uses <code>buf</code> as its
+ * buffer array. The initial value of <code>pos</code>
+ * is <code>offset</code> and the initial value
+ * of <code>count</code> is the minimum of <code>offset+length</code>
+ * and <code>buf.length</code>.
+ * 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 <code>LittleEndianByteArrayInputStream</code>
+ * that uses <code>buf</code> as its
+ * buffer array. The initial value of <code>pos</code>
+ * is <code>offset</code> and the initial value
+ * of <code>count</code> is the minimum of <code>offset+buf.length</code>
+ * and <code>buf.length</code>.
+ * 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 <code>LittleEndianByteArrayInputStream</code>
+ * so that it uses <code>buf</code> as its
+ * buffer array.
+ * The buffer array is not copied.
+ * The initial value of <code>pos</code>
+ * is <code>0</code> and the initial value
+ * of <code>count</code> is the length of
+ * <code>buf</code>.
+ *
+ * @param buf the input buffer.
+ */
public LittleEndianByteArrayInputStream(byte[] buf) {
- this(buf, 0);
+ super(buf);
}
protected void checkPosition(int i) {
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;
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);
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);
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;
}
* 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 {
@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;
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"));
+ }
+ }
}