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 2013/10/28 14:57:04 UTC

[Bug 55714] New: Background image ignored on slide copy

https://issues.apache.org/bugzilla/show_bug.cgi?id=55714

            Bug ID: 55714
           Summary: Background image ignored on slide copy
           Product: POI
           Version: 3.10-dev
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSLF
          Assignee: dev@poi.apache.org
          Reporter: benjamin.gam@gmail.com

Created attachment 30982
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=30982&action=edit
Input file with a background image

Hi and thank you for this great library. I'm using 3.10-beta2

I try to copy some slides from a presentation to a new blank presentation, like
this :

XMLSlideShow srcPptx = null;
try (InputStream is = Resources.getResource("test.pptx").openStream()) {
    srcPptx = new XMLSlideShow(is);
}

int slideIndex = 0;
for (XSLFSlide srcSlide : srcPptx.getSlides()) {
    XMLSlideShow newPptx = new XMLSlideShow();

    // Add slide
    XSLFSlide newSlide = newPptx.createSlide();
    XSLFSlideLayout srcSlideLayout = srcSlide.getSlideLayout();
    XSLFSlideMaster srcSlideMaster = srcSlide.getSlideMaster();
    XSLFSlideLayout newSlideLayout = newSlide.getSlideLayout();
    XSLFSlideMaster newSlideMaster = newSlide.getSlideMaster();
    newSlideLayout.importContent(srcSlideLayout);
    newSlideMaster.importContent(srcSlideMaster); 
    newSlide.importContent(srcSlide);

    // Write the new presentation
    try (OutputStream os = new FileOutputStream("slide-" + (slideIndex++) +
".pptx")) {
        newPptx.write(os);
    }
}

It seems to work great, except that background images are not copied.
I join you an input .pptx to reproduce.

Tell me if you need more details.

-- 
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 55714] Background image ignored on slide copy

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55714

--- Comment #6 from Benjamin Gamard <be...@gmail.com> ---
It seems that there is no way to add a new slide master or slide layout in POI
for the moment, and the copy process keeps overlapping old ones.
So I am stuck here now.

-- 
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 55714] Background image ignored on slide copy

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55714

--- Comment #7 from Nick Burch <ap...@gagravarr.org> ---
(In reply to Benjamin Gamard from comment #6)
> It seems that there is no way to add a new slide master or slide layout in
> POI for the moment, and the copy process keeps overlapping old ones.
> So I am stuck here now.

It might not be that much extra work to implement new slide master and/or
layout support for XSLF, so that might be the way to go!

(There may be some IDs that need fixing up, and you'll need to identify the
smallest valid new master/layout for when creating the new one)

-- 
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 55714] Background image ignored on slide copy

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55714

--- Comment #5 from Benjamin Gamard <be...@gmail.com> ---
I was on the right path, however it does not seem to work if the background is
carried by the slide master. Do you have any idea about it? Thanks.

-- 
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 55714] Background image ignored on slide copy

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55714

Nick Burch <ap...@gagravarr.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO
                 OS|                            |All

--- Comment #1 from Nick Burch <ap...@gagravarr.org> ---
PPTX files are a zip of XML files.

Are you able to unzip the resulting file, and diff the slide and layout xml to
see what's different between the slides that include the background and those
who lost it?

-- 
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 55714] Background image ignored on slide copy

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55714

--- Comment #4 from Nick Burch <ap...@gagravarr.org> ---
Looks promising!

Any chance you could write a short junit unit test that shows the problem? We
can use that to test your proposed fix, as well as to ensure it stays fixed
into the future!

-- 
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 55714] Background image ignored on slide copy

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55714

Benjamin Gamard <be...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

-- 
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 55714] Background image ignored on slide copy

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55714

--- Comment #3 from Benjamin Gamard <be...@gmail.com> ---
After further debugging, I think I have found where the problem is.

in XSLFSlide.importContent (line 228), we have :
XSLFBackground bgShape = getBackground();

instead of :
XSLFBackground bgShape = src.getBackground();

It seems to import correctly the background in the new pptx, but it's not
enough. The <p:bgPr> is not copied (as I said in my previous comment). If I
copy it manually like that :
newSlide.getXmlObject().getCSld().setBg(srcSlide.getXmlObject().getCSld().getBg());

The background works.

-- 
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 55714] Background image ignored on slide copy

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55714

--- Comment #2 from Benjamin Gamard <be...@gmail.com> ---
(In reply to Nick Burch from comment #1)
> PPTX files are a zip of XML files.
> 
> Are you able to unzip the resulting file, and diff the slide and layout xml
> to see what's different between the slides that include the background and
> those who lost it?

Yes, here it is.

The source pptx slide contains at the beginning :

...
<p:cSld>
<p:bg>
  <p:bgPr>
    <a:blipFill dpi="0" rotWithShape="1">
      <a:blip r:embed="rId2" cstate="print">
        <a:lum />
      </a:blip>
      <a:srcRect />
      <a:stretch>
        <a:fillRect />
      </a:stretch>
    </a:blipFill>
    <a:effectLst />
  </p:bgPr>
</p:bg>
<p:spTree>
...

And the resulting pptx does not contains the <p:bg> tag :

...
<p:cSld>
<p:spTree>
...

I tried to debug into the copy process, and it seems that it never pass in the
XSLFBackground.copy method (but it does for all the other shapes).

-- 
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