Bug 55516 - createDrawingPatriarch does not take drawingml.chartshapes+xml into account for calculation of drawingNumber
Summary: createDrawingPatriarch does not take drawingml.chartshapes+xml into account f...
Status: RESOLVED DUPLICATE of bug 60255
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.9-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-03 06:30 UTC by mmuehlan
Modified: 2016-10-15 17:11 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mmuehlan 2013-09-03 06:30:19 UTC
I have an Excel containing multiple drawings.

/xl/drawings/drawing1.xml=Name: /xl/drawings/drawing1.xml - Content Type: application/vnd.openxmlformats-officedocument.drawing+xml
/xl/drawings/drawing2.xml=Name: /xl/drawings/drawing2.xml - Content Type: application/vnd.openxmlformats-officedocument.drawing+xml
/xl/drawings/drawing3.xml=Name: /xl/drawings/drawing3.xml - Content Type: application/vnd.openxmlformats-officedocument.drawing+xml
/xl/drawings/drawing4.xml=Name: /xl/drawings/drawing4.xml - Content Type: application/vnd.openxmlformats-officedocument.drawing+xml
/xl/drawings/drawing5.xml=Name: /xl/drawings/drawing5.xml - Content Type: application/vnd.openxmlformats-officedocument.drawing+xml
/xl/drawings/drawing6.xml=Name: /xl/drawings/drawing6.xml - Content Type: application/vnd.openxmlformats-officedocument.drawing+xml
/xl/drawings/drawing7.xml=Name: /xl/drawings/drawing7.xml - Content Type: application/vnd.openxmlformats-officedocument.drawing+xml
/xl/drawings/drawing8.xml=Name: /xl/drawings/drawing8.xml - Content Type: application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml

A Workbook gets created from this file.

		Drawing drawing = sheet.createDrawingPatriarch();
Throws an Exception:
Exception in thread "main" org.apache.poi.openxml4j.exceptions.PartAlreadyExistsException: A part with the name '/xl/drawings/drawing8.xml' already exists : Packages shall not contain equivalent part names and package implementers shall neither create nor recognize packages with equivalent part names. [M1.12]

Having analyzed this issue by looking into the sources, there are the following findings:
1. XSSFRelation does not contain the ...drawingml.chartshapes+xml
2. Excel apparently has a unique numbering across (at least) drawing+xml and drawingml.chartshapes+xml Content types
3. My Suggestion would be to add the new Content type and modify the XSSFSheet createDrawingPatriarch() to:
  int drawingNumber = 
   getPackagePart().getPackage().getPartsByContentType(XSSFRelation.DRAWINGS.getContentType()).size()
   getPackagePart().getPackage().getPartsByContentType(XSSFRelation.***NEW CONSTANT FOR drawingml***.getContentType()).size()
 + 1;

This Problem occurs in 3.9 and in the latest 3.10 beta download.
Comment 1 Nick Burch 2014-07-31 16:17:12 UTC
Any chance you could create a very small test excel file, with the mixture of drawing types, and then a short junit test case which triggers this bug?

We can then use those to test a fix, verify it is fixed, and ensure it stays fixed into the future!
Comment 2 Dominik Stadler 2015-09-13 12:49:57 UTC
No response since a long time, hard to fix without a file that allows to reproduce the problem, therefore I am closing this as WONTFIX for now, please reopen if you still see this problem and can provide more information, especially a sample file and related unit-test code.
Comment 3 Zero 2016-10-15 12:35:29 UTC
fixed in https://svn.apache.org/viewvc?view=rev&rev=1764863 by Nick Burch
Comment 4 Zero 2016-10-15 12:41:34 UTC
same my problem at https://bz.apache.org/bugzilla/show_bug.cgi?id=60255
Comment 5 Javen O'Neal 2016-10-15 17:11:59 UTC

*** This bug has been marked as a duplicate of bug 60255 ***