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/03/07 08:27:44 UTC

[Bug 65934] New: removed textparagraphs remain visible in slideshow

https://bz.apache.org/bugzilla/show_bug.cgi?id=65934

            Bug ID: 65934
           Summary: removed textparagraphs remain visible in slideshow
           Product: POI
           Version: 5.2.0-FINAL
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSLF
          Assignee: dev@poi.apache.org
          Reporter: bugzilla-apache@outlook.com
  Target Milestone: ---

When a textparagraph is deleted, programmatically it seems as if the deletion
has been applied. However, the textparagraph is still visible in the slide of
the slideshow. (The same problem occurs with textruns, cf. another filed bug.)

Steps to reproduce:

  @Test
  void removeTextParagraph() throws IOException {
    final XMLSlideShow ppt = new XMLSlideShow();

    final XSLFSlide slide = ppt.createSlide();;

    final XSLFTextBox textBox = slide.createTextBox();
    textBox.setAnchor(new Rectangle(0, 0, 100, 100));

    textBox.getTextParagraphs().get(0).getTextRuns().get(0).setText("lorem");
    textBox.addNewTextParagraph().addNewTextRun().setText("ipsum");
    textBox.addNewTextParagraph().addNewTextRun().setText("dolor");

    assertEquals(3, textBox.getTextParagraphs().size());
    assertEquals("lorem\nipsum\ndolor", textBox.getText());
    assertEquals("lorem", textBox.getTextParagraphs().get(0).getText());
    assertEquals("ipsum", textBox.getTextParagraphs().get(1).getText());
    assertEquals("dolor", textBox.getTextParagraphs().get(2).getText());

    textBox.getTextParagraphs().remove(textBox.getTextParagraphs().get(1));

    assertEquals(2, textBox.getTextParagraphs().size());
    assertEquals("lorem\ndolor", textBox.getText());
    assertEquals("lorem", textBox.getTextParagraphs().get(0).getText());
    assertEquals("dolor", textBox.getTextParagraphs().get(1).getText());

    String filepath = System.getProperty("java.io.tmpdir") + "tmp.pptx";

    FileOutputStream fos = new FileOutputStream(filepath);
    ppt.write(fos);

    fos.close();

    System.out.println("file written to " + filepath);
  }

see also:

https://user.poi.apache.narkive.com/S6TaNfG4/delete-specific-xslftextparagraph-in-xslfshape

-- 
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 65934] removed textparagraphs remain visible in slideshow

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

--- Comment #1 from PJ Fanning <fa...@yahoo.com> ---
I added r1898668 - would you be in a position to test this? The problem is that
textBox.getTextParagraphs().remove(...) does not remove the underlying XMLBeans
data (CTTextParagraph class).

If you want to work around the issue without my change, you can get the
CTTextBody for the XSLFTextBox using textBox.getTextBody().getXmlObject(). You
can then iterate over the 'p' array to find the right CTTextParagraph to
remove.

-- 
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 65934] removed textparagraphs remain visible in slideshow

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

bugzilla-apache@outlook.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All
                 CC|                            |bugzilla-apache@outlook.com

-- 
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 65934] removed textparagraphs remain visible in slideshow

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

--- Comment #2 from bugzilla-apache@outlook.com ---
I was able to verify that the change works.

The above test initially failed with an UnsupportedOperationException. Great
idea to change the list of textparagraphs to Collections.unmodifiableList. :-)

After replacing the line

  textBox.getTextParagraphs().remove(textBox.getTextParagraphs().get(1));

with

  textBox.removeTextParagraph(textBox.getTextParagraphs().get(1));

the test passed again and the slide finally looks as expected.

Thanks for fixing the issue!

-- 
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 65934] removed textparagraphs remain visible in slideshow

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

PJ Fanning <fa...@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

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