[Bug 60234] Regression: XSSFWorkBook#() throws unexpected exception in 3.15 for invalid input

2016-10-10 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=60234

Javen O'Neal  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |WONTFIX

-- 
You are receiving this mail because:
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



[Bug 60234] Regression: XSSFWorkBook#() throws unexpected exception in 3.15 for invalid input

2016-10-10 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=60234

--- Comment #2 from Nick Burch  ---
NotOfficeXmlFileException extends from UnsupportedFileFormatException, which is
in the core POI jar and has been around for a while. The fix to give a more
helpful exception brings the OOXML code more in line with the behaviour of the
other formats

I'd suggest you change your code to catch
org.apache.poi.UnsupportedFileFormatException as your primary "is this a
supported file" exception

-- 
You are receiving this mail because:
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



[Bug 57184] Missing Formula support for External References

2016-10-10 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=57184

--- Comment #1 from IgnacioHR  ---
https://bz.apache.org/bugzilla/show_bug.cgi?id=60219

Patch contains implementation of requirement:

 * It should be possible to create HSSF formulas which refer to a new external
workbook, with the link table being set up for it (failing, commented out unit
test available)

-- 
You are receiving this mail because:
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



[Bug 60235] New: Intersection arguments to worksheet function in FormulaEvaluator

2016-10-10 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=60235

Bug ID: 60235
   Summary: Intersection arguments to worksheet function in
FormulaEvaluator
   Product: POI
   Version: 3.15-FINAL
  Hardware: PC
Status: NEW
  Severity: normal
  Priority: P2
 Component: XSSF
  Assignee: dev@poi.apache.org
  Reporter: as...@pnash.me.uk

XSSF sheet with worksheet function whose arguments are overlapping intersecting
ranges, for example =SUM(B3:C3 C3:C4), generates a FormulaParseException from
the following code (stack trace below).

FileInputStream fileIn = new FileInputStream(new File("intersect.xlsx"));
Workbook wb = WorkbookFactory.create(fileIn);
fileIn.close();

FormulaEvaluator eval = wb.getCreationHelper().createFormulaEvaluator();
eval.evaluateAll();

Speculation: A Possible Fix: In FormulaParser, in Arguments() method, replace
call to temp.add(comparisonExpression()); with
temp.add(intersectionExpression()); instead. This appears to fix it for me!

---

Exception in thread "main" org.apache.poi.ss.formula.FormulaParseException:
Parse error near char 10 'C' in specified formula 'SUM(B3:C3 C3:C4)'. Expected
',' or ')'
at org.apache.poi.ss.formula.FormulaParser.expected(FormulaParser.java:262)
at
org.apache.poi.ss.formula.FormulaParser.Arguments(FormulaParser.java:1444)
at
org.apache.poi.ss.formula.FormulaParser.function(FormulaParser.java:1316)
at
org.apache.poi.ss.formula.FormulaParser.parseNonRange(FormulaParser.java:884)
at
org.apache.poi.ss.formula.FormulaParser.parseRangeable(FormulaParser.java:575)
at
org.apache.poi.ss.formula.FormulaParser.parseRangeExpression(FormulaParser.java:311)
at
org.apache.poi.ss.formula.FormulaParser.parseSimpleFactor(FormulaParser.java:1509)
at
org.apache.poi.ss.formula.FormulaParser.percentFactor(FormulaParser.java:1467)
at
org.apache.poi.ss.formula.FormulaParser.powerFactor(FormulaParser.java:1454)
at org.apache.poi.ss.formula.FormulaParser.Term(FormulaParser.java:1827)
at
org.apache.poi.ss.formula.FormulaParser.additiveExpression(FormulaParser.java:1955)
at
org.apache.poi.ss.formula.FormulaParser.concatExpression(FormulaParser.java:1939)
at
org.apache.poi.ss.formula.FormulaParser.comparisonExpression(FormulaParser.java:1896)
at
org.apache.poi.ss.formula.FormulaParser.intersectionExpression(FormulaParser.java:1869)
at
org.apache.poi.ss.formula.FormulaParser.unionExpression(FormulaParser.java:1849)
at org.apache.poi.ss.formula.FormulaParser.parse(FormulaParser.java:1997)
at org.apache.poi.ss.formula.FormulaParser.parse(FormulaParser.java:170)
at
org.apache.poi.xssf.usermodel.XSSFEvaluationWorkbook.getFormulaTokens(XSSFEvaluationWorkbook.java:85)
at
org.apache.poi.ss.formula.WorkbookEvaluator.evaluateAny(WorkbookEvaluator.java:315)
at
org.apache.poi.ss.formula.WorkbookEvaluator.evaluate(WorkbookEvaluator.java:259)
at
org.apache.poi.xssf.usermodel.BaseXSSFFormulaEvaluator.evaluateFormulaCellValue(BaseXSSFFormulaEvaluator.java:65)
at
org.apache.poi.ss.formula.BaseFormulaEvaluator.evaluateFormulaCellEnum(BaseFormulaEvaluator.java:193)
at
org.apache.poi.ss.formula.BaseFormulaEvaluator.evaluateAllFormulaCells(BaseFormulaEvaluator.java:268)
at
org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator.evaluateAll(XSSFFormulaEvaluator.java:92)
at poi.POIDemo.main(POIDemo.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

-- 
You are receiving this mail because:
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



[Bug 60234] Regression: XSSFWorkBook#() throws unexpected exception in 3.15 for invalid input

2016-10-10 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=60234

--- Comment #1 from Andreas Kohn  ---
Work-around: For now I've changed the catch to catch all RuntimeExceptions, but
that's obviously not very nice.

-- 
You are receiving this mail because:
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



[Bug 60234] New: Regression: XSSFWorkBook#() throws unexpected exception in 3.15 for invalid input

2016-10-10 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=60234

Bug ID: 60234
   Summary: Regression: XSSFWorkBook#() throws unexpected
exception in 3.15 for invalid input
   Product: POI
   Version: 3.15-FINAL
  Hardware: PC
OS: Linux
Status: NEW
  Severity: normal
  Priority: P2
 Component: XSSF
  Assignee: dev@poi.apache.org
  Reporter: andreas.k...@gmail.com

We have a piece of code that essentially does this:

try {
  new XSSFWorkbook(new ByteArrayInputStream("garbage".getBytes());
} catch (POIXMLException e) {
  // Ok, guess it wasn't OOXML, so try something else.
  // ...
}

This worked fine in 3.14 and before. After I updated to 3.15 it fails, because
we're now seeing a
'org.apache.poi.openxml4j.exceptions.NotOfficeXmlFileException' instead:

org.apache.poi.openxml4j.exceptions.NotOfficeXmlFileException: No valid entries
or contents found, this is not a valid OOXML (Office Open XML) file
at
org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:290)
at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:774)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:344)
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:37)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:285)
at ...

-- 
You are receiving this mail because:
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



[Bug 60219] [PATCH] FormulaParser can't parse external references when sheet name is quoted

2016-10-10 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=60219

IgnacioHR  changed:

   What|Removed |Added

  Attachment #34342|0   |1
is obsolete||

--- Comment #6 from IgnacioHR  ---
Created attachment 34354
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=34354=edit
Full patch, passes conf suite

-- 
You are receiving this mail because:
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



[Bug 60216] [PATCH] Patch for Comment documentation

2016-10-10 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=60216

IgnacioHR  changed:

   What|Removed |Added

  Attachment #34332|0   |1
is obsolete||

--- Comment #2 from IgnacioHR  ---
Created attachment 34353
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=34353=edit
Full patch - passes conf suite

-- 
You are receiving this mail because:
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



[Bug 60219] [PATCH] FormulaParser can't parse external references when sheet name is quoted

2016-10-10 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=60219

--- Comment #5 from IgnacioHR  ---
I'm sorry to be so active at this time.

o.a.p.hssf.usermodel.TestHSSFFormulaEvaluator.java#testXRefs suggest me that
the preferred option is (2) (the external workbook must be added to the
linkTable before the setFormula is called)

This means the code o.a.p.hssf.usermodel.TestBugs#bug45970 MUST always fail and
the current situation (the test pass without a fail) pass because the
resolution of the formula reference contains a bug and the external workbook is
recognised as a worksheet of the current workbook.

In order to fix code in bug45970. The changes should be like this:

---
// Link our new workbook
wb1.linkExternalWorkbook("$http://gagravarr.org/FormulaRefs2.xls;, new String[]
{"Sheet1"});

// Change 4  
row.getCell(1).setCellFormula("'[$http://gagravarr.org/FormulaRefs2.xls]Sheet1'!B2");
row.getCell(1).setCellValue(123.0);

// Link our new workbook
wb1.linkExternalWorkbook("$http://example.com/FormulaRefs.xls;, new String[]
{"Sheet1"});

// Add 5
row = s.createRow(5);
row.createCell(1, CellType.FORMULA);
  
row.getCell(1).setCellFormula("'[$http://example.com/FormulaRefs.xls]Sheet1'!B1");
row.getCell(1).setCellValue(234.0);
---

Note I'm adding the external workbook to the current workbook prior to set a
formula that uses cells in that workbook.

The current implementation of linkExternalWorkbook requires the external
workbook to be instantiated as a Workbook object. In order to support
referencing external workbooks that are now already instantiated a new method
linkExternalWorkbook(String name, String sheetNames[]) is required.

The attached new patch contains all required changes and passes complete
conformance suite.

The changes include:

added linkExternalWorkbook(String name, String sheetNames[]) to 
src/java/org/apache/poi/ss/usermodel/Workbook.java and added implementation of
derived classes. Note XSSF... does not implements external workbooks at all.

TestBugs now can uncomment two final tests (that pass OK) to check the external
references.

-- 
You are receiving this mail because:
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



[Bug 57342] Writing very large file via SXSSF leads to corrupt file

2016-10-10 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=57342

--- Comment #19 from Javen O'Neal  ---
Patches are greatly appreciated. Appreciate your help on this.

-- 
You are receiving this mail because:
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



[Bug 57342] Writing very large file via SXSSF leads to corrupt file

2016-10-10 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=57342

--- Comment #18 from Ramesh  ---
Dear All,

Any workaround to this issue? We are also facing the same issue with similar
approach. Appreciate your help on this.

Thanks
Ramesh

-- 
You are receiving this mail because:
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



[Bug 60230] Roundtrip test that encrypts XSSFWorkbook and then decrypts it fails with latest code

2016-10-10 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=60230

--- Comment #6 from Andreas Beeker  ---
I need to have another look an, as it came to my mind, that depending on the
padding there might be more than  bytes in the result, which would
be chopped off ... which is not such a good idea for block-based ciphers

The implementation of ChunkedCipherIn/OutputStream is a bit tricky in that
regard, as it handles stream-based (XOR/RC4) and block-based (AES/...)
encryption modes.

-- 
You are receiving this mail because:
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



[Bug 60153] [PATCH] Use ZipEntrySource in SXSSF module

2016-10-10 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=60153

--- Comment #11 from PJ Fanning  ---
Hi Javen,
I can look at putting together some doc and related sample code.
Could take a few days.

-- 
You are receiving this mail because:
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



[Bug 60219] [PATCH] FormulaParser can't parse external references when sheet name is quoted

2016-10-10 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=60219

--- Comment #4 from IgnacioHR  ---
OK, I've dig into the problem of TestBugs#bug45970 and this is what I see.

on line 1852 of o.a.p.hssf.usermodel.TestBugs.java there is the following:

row.getCell(1).setCellFormula("'[$http://gagravarr.org/FormulaRefs2.xls]Sheet1'!B2");

During setCellFormula operation, the referenced external workbook is not in the
LinkTable as you can see in the following stack trace:

LinkTable.getExternalSheetIndex(String, String, String) line: 443
InternalWorkbook.getExternalSheetIndex(String, String, String) line: 2012
HSSFEvaluationWorkbook.getSheetExtIx(SheetIdentifier) line: 300
HSSFEvaluationWorkbook.get3DReferencePtg(CellReference, SheetIdentifier) line:
94
FormulaParser.createAreaRefParseNode(SheetIdentifier,
FormulaParser$SimpleRangePart, FormulaParser$SimpleRangePart) line: 957
FormulaParser.parseRangeable() line: 568
FormulaParser.parseRangeExpression() line: 311
FormulaParser.parseSimpleFactor() line: 1516
FormulaParser.percentFactor() line: 1474
FormulaParser.powerFactor() line: 1461
FormulaParser.Term() line: 1834
FormulaParser.additiveExpression() line: 1962
FormulaParser.concatExpression() line: 1946
FormulaParser.comparisonExpression() line: 1903
FormulaParser.intersectionExpression() line: 1876
FormulaParser.unionExpression() line: 1856
FormulaParser.parse() line: 2004
FormulaParser.parse(String, FormulaParsingWorkbook, FormulaType, int, int)
line: 170
FormulaParser.parse(String, FormulaParsingWorkbook, FormulaType, int) line: 190 
HSSFFormulaParser.parse(String, HSSFWorkbook, FormulaType, int) line: 108
HSSFCell.setCellFormula(String) line: 622
TestBugs.bug45970() line: 1852


LinkTable.getExternalSheetIndex(String, String, String) line: 443 returns -1
because and on line 445 of o.a.p.hssf.model.LinkTable.java a RuntimeException
is raised.

There are three options:
1) Modify LinkTable to automatically add a new external reference to the link
table rather that raise an exception (this way looks easy for POI users)
2) Modify test case 45970 to add an external workbook reference before setting
the formula
3) Other, such as define a policy for unreferenced external workbooks and
either raise an error or create the reference automatically.

Going for (2) seems obvious and the simplest way to fix this problem, but makes
live more difficult to developers
Going for (1) seems possible in a short period of time, but might break
existing test cases (I'm not 100% sure about this)
Going for (3) seems to be the right position in a long term. But requires more
work

Any preference?

-- 
You are receiving this mail because:
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



[Bug 60219] [PATCH] FormulaParser can't parse external references when sheet name is quoted

2016-10-10 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=60219

--- Comment #3 from IgnacioHR  ---
Hi,

Sorry, I don't understand this part of the comment:

"Unfortunately, this patch cannot be committed yet because it breaks
o.a.p.hssf.usermodel.TestBugs#bug45970."

row.getCell(1).setCellFormula("'[$http://gagravarr.org/FormulaRefs2.xls]Sheet1'!B2");

The error message generated is right cause the Excel sheet referenced in the
URL does not exists. So maybe there is a bug in the output of test case
o.a.p.hssf.usermodel.TestBugs#bug45970 because it MUST raise that exception

-- 
You are receiving this mail because:
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



[Bug 60217] Word document with a single table gets corrupted after load/save with no changes

2016-10-10 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=60217

--- Comment #6 from Kostiantyn Miklevskyi 
 ---
Created attachment 34351
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=34351=edit
LibreOffice 5.2.2.2 original file and corrupted file side-to-side

Downloaded latest stable LibreOffice version 5.2.2.2 and it indeed doesn't
complain about the corruption but, so I opened original document and a
corrupted one to show the difference.

-- 
You are receiving this mail because:
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



[Bug 60217] Word document with a single table gets corrupted after load/save with no changes

2016-10-10 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=60217

--- Comment #5 from Kostiantyn Miklevskyi 
 ---
Created attachment 34350
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=34350=edit
Screenshot of Word error message when opening a corrupted file

-- 
You are receiving this mail because:
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



[Bug 60217] Word document with a single table gets corrupted after load/save with no changes

2016-10-10 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=60217

--- Comment #4 from Kostiantyn Miklevskyi 
 ---
>Javen O'Neal 2016-10-08 22:16:16 UTC
>Can you check if Word reports that the attached file is corrupted?

Yes. The same error message that Word reported previously.
Attaching a screenshot.

-- 
You are receiving this mail because:
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



[Bug 60217] Word document with a single table gets corrupted after load/save with no changes

2016-10-10 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=60217

Kostiantyn Miklevskyi  changed:

   What|Removed |Added

 Status|NEEDINFO|NEW

--- Comment #3 from Kostiantyn Miklevskyi 
 ---
>Mark Murphy 2016-10-07 19:23:58 UTC
>Can POI read the document after load/save?

No, it throws an exception.
Should've provided this info in initial report as I actually tried it.

Here's a code:

final POIDocument doc = new
HWPFDocument(SaveToAnotherDocumentBug.class.getClassLoader().getResourceAsStream(DOCUMENT_NAME));
final File copy = new File(CORRUPTED_PREFIX + "-" + DOCUMENT_NAME);
doc.write(copy);
doc.close();

new HWPFDocument(new FileInputStream(copy));

And it throws with this stacktrace:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:
-1845343745
at org.apache.poi.util.LittleEndian.getUByte(LittleEndian.java:274)
at
org.apache.poi.hwpf.model.FormattedDiskPage.(FormattedDiskPage.java:61)
at
org.apache.poi.hwpf.model.PAPFormattedDiskPage.(PAPFormattedDiskPage.java:85)
at org.apache.poi.hwpf.model.PAPBinTable.(PAPBinTable.java:75)
at org.apache.poi.hwpf.HWPFDocument.(HWPFDocument.java:226)
at org.apache.poi.hwpf.HWPFDocument.(HWPFDocument.java:157)
at org.apache.poi.hwpf.HWPFDocument.(HWPFDocument.java:145)
at com.cosi.SaveToAnotherDocumentBug.main(SaveToAnotherDocumentBug.java:20)

-- 
You are receiving this mail because:
You are the assignee for the bug.

-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org