You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2022/09/29 06:46:17 UTC
[Bug 66284] New: Apache POI - Merge deck with different slide layouts
https://bz.apache.org/bugzilla/show_bug.cgi?id=66284
Bug ID: 66284
Summary: Apache POI - Merge deck with different slide layouts
Product: POI
Version: unspecified
Hardware: PC
Status: NEW
Severity: critical
Priority: P2
Component: XSLF
Assignee: dev@poi.apache.org
Reporter: jatish.khanna@gmail.com
Target Milestone: ---
On Using option targetDeck.createSlide(srcSlide.getSlideLayout), the apache POI
throws error while writing (mergedDeck.write(outStream)) to a deck -
Rule M2.4 exception : Part '/_rels/.rels' not found - this error should NEVER
happen!\nCheck that your code is closing the open resources in the correct
order prior to filing a bug report.\nIf you can provide the triggering file,
then please raise a bug at
https://bz.apache.org/bugzilla/enter_bug.cgi?product=POI and attach the file
that triggers it, thanks!
The probable reason for the above -
When slides are created using PackagePart with the same name in this case
(SlideLayout from different decks having different), on cleanup it will throw
an exception. Find below the trace-
org.apache.poi.openxml4j.opc.internal.ContentTypeManager.getContentType(ContentTypeManager.java:353)
at
org.apache.poi.openxml4j.opc.internal.ContentTypeManager.removeContentType(ContentTypeManager.java:262)
at org.apache.poi.openxml4j.opc.OPCPackage.removePart(OPCPackage.java:998) at
org.apache.poi.openxml4j.opc.PackagePart.getOutputStream(PackagePart.java:526)
at org.apache.poi.xslf.usermodel.XSLFSheet.commit(XSLFSheet.java:412) at
org.apache.poi.ooxml.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:467) at
org.apache.poi.ooxml.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:472) at
org.apache.poi.ooxml.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:472) at
org.apache.poi.ooxml.POIXMLDocument.write(POIXMLDocument.java:221)
More details:
https://stackoverflow.com/questions/73727277/apache-poi-merge-multiple-decks-to-single-deck
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 66284] Apache POI - Merge deck with different slide layouts
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66284
--- Comment #6 from J Khanna <ja...@gmail.com> ---
I've already shared most of things, I'm not sure what else you are looking for?
Only change in my codebase is source of input stream. Otherwise the simplest
possible Java code is available on the reference URL. We can do a google meet
if required
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 66284] Apache POI - Merge deck with different slide layouts
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66284
--- Comment #7 from J Khanna <ja...@gmail.com> ---
Please use the reference project -
https://github.com/Jatish-Khanna/apache-poi-example.git
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 66284] Apache POI - Merge deck with different slide layouts
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66284
J Khanna <ja...@gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|5.3.x-dev |5.2.2-FINAL
--- Comment #9 from J Khanna <ja...@gmail.com> ---
I've already reverse engineered and tried multiple approaches including the
suggested one. Please check the stackoverflow post for additional details.
- POI doesn't offer extension
- when trying to create a slide from layout, it overrides instead of adding a
new layout
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 66284] Apache POI - Merge deck with different slide layouts
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66284
--- Comment #5 from PJ Fanning <fa...@yahoo.com> ---
Fair enough if you don't want to right a test. I don't want to write one for
you. Maybe someone else will.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 66284] Apache POI - Merge deck with different slide layouts
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66284
--- Comment #2 from J Khanna <ja...@gmail.com> ---
Use case: create a single deck by merging all the slides from different decks
Source decks has different slide layouts, sizes.
To load decks source decks, and merge them I'm using Apache POI 5.2.3.
0) create an empty target deck
1) load decks from input stream
2) iterate over slides on the deck
4) create new slide in the target deck using the layout (each slide can have
different layout), contents of the source deck
5) repeat step#1 until all the source decks have been imported to target deck
as new slides
6) export the merged deck to file
Each step has inbuilt functions provided by Apache POI which have been
mentioned in stackoverflow as well.
Finally, while exporting the target deck using write operation of class:
XMLSlideShow, it throws mentioned exception.
Note: this exception is only logged if we use slide layouts of the source
slides to create target.
Code for each step has been mentioned in stackoverflow otherwise I can post
it here
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 66284] Apache POI - Merge deck with different slide layouts
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66284
PJ Fanning <fa...@yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |NEEDINFO
--- Comment #3 from PJ Fanning <fa...@yahoo.com> ---
That is not what I asked for. I asked for all the code in a runnable form.
There is a likely reason that noone has commented or answered on your
stackoverflow question: you have not provided a reproducible example.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 66284] Apache POI - Merge deck with different slide layouts
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66284
J Khanna <ja...@gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|unspecified |5.3.x-dev
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 66284] Apache POI - Merge deck with different slide layouts
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66284
--- Comment #1 from PJ Fanning <fa...@yahoo.com> ---
Can you provide a full test case? Including a couple of random lines of the
code is not enough. This issue and the stackoverflow question are far from
clear.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 66284] Apache POI - Merge deck with different slide layouts
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66284
J Khanna <ja...@gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jatish.khanna@gmail.com
URL| |https://stackoverflow.com/q
| |uestions/73727277/apache-po
| |i-merge-multiple-decks-to-s
| |ingle-deck
Keywords| |APIBug
OS| |All
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 66284] Apache POI - Merge deck with different slide layouts
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66284
J Khanna <ja...@gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEEDINFO |NEW
--- Comment #4 from J Khanna <ja...@gmail.com> ---
https://www.tutorialspoint.com/apache_poi_ppt/apache_poi_ppt_merging.htm
The code is similar to the mentioned reference.
for(XSLFSlide srcSlide : src.getSlides()) {
//merging the contents
ppt.createSlide().importContent(srcSlide);
}
This requires improvement. If you would see the bottom of the reference, would
only find content but source layouts
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 66284] Apache POI - Merge deck with different slide layouts
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66284
--- Comment #10 from J Khanna <ja...@gmail.com> ---
Do you need any other information to solve the bug?
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 66284] Apache POI - Merge deck with different slide layouts
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66284
--- Comment #8 from PJ Fanning <fa...@yahoo.com> ---
I don't have much time to spend on POI right now. One thing to try yourself is
to try out the `importContent` methods on XSLFSlide, XSLFSlideLayout and
XSLFSlideMaster. These are the methods used in our tests when copying slides
and/or their layouts to other slideshows.
One of the POI unit tests does this.
XSLFSlide srcSlide = srcPptx.getSlides().get(0);
XSLFSlide newSlide = newPptx.createSlide();
XSLFSlideLayout srcSlideLayout = srcSlide.getSlideLayout();
XSLFSlideLayout newSlideLayout = newSlide.getSlideLayout();
newSlideLayout.importContent(srcSlideLayout);
XSLFSlideMaster srcSlideMaster = srcSlide.getSlideMaster();
XSLFSlideMaster newSlideMaster = newSlide.getSlideMaster();
newSlideMaster.importContent(srcSlideMaster);
newSlide.importContent(srcSlide);
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org