Delete specific XSLFTextParagraph in XSLFShape

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Delete specific XSLFTextParagraph in XSLFShape

Chau362
I am using XSLF to populate a given PowerPoint document (template) with
values from a Hashmap. Inside the PowerPoint I have one slide with
predefined textShapes. Every textShape has one or more textParagraphs. In
order to fill the template with my own values, I loop over the textShape and
textParagraphs and search for a placeholder in the form "< keyword >"
(without spaces). Whenever I find a placeholer, I want to insert new
paragraphs in form of a bullet point after the position of the placeholder.
However if I try to insert a new paragraph at a specific position they only
appear at the end of the textShape. I use the placeholder to collect the
necessary information about the formatting (fontColor, fontSize, fontFamily
etc.)

The placeholder should not be in the final presentation slide, which is why
I tried to replace/delete it. However whenever I try to replace or remove
the placeholder the presentation still looks the same. So basically my
questions are:

1. How can I remove a specified textParagraph from a textShape?

2. Is it possible to create a textParagraph at a specified position in a
textShape?

I tried

((XSLFTextShape) correctShape).getTextParagraphs().remove(paragraphNumber);

to remove and

((XSLFTextShape) correctShape).getTextParagraphs().add(paragraphNumber,
newParagraph);

to insert, but neither worked.


Thanks in advance!






--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Delete specific XSLFTextParagraph in XSLFShape

pj.fanning
https://github.com/apache/poi/blob/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java
has an addNewTextParagraph method. There doesn't appear to be a remove
paragraph method.

You might be able to remove a paragraph by calling the `public
Iterator<XSLFTextParagraph> iterator()` and removing the paragraph you want
to remove from the iterator.



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Delete specific XSLFTextParagraph in XSLFShape

Chau362
pj.fanning wrote
> https://github.com/apache/poi/blob/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java
> has an addNewTextParagraph method. There doesn't appear to be a remove
> paragraph method.
>
> You might be able to remove a paragraph by calling the `public
> Iterator
> <XSLFTextParagraph>
>  iterator()` and removing the paragraph you want
> to remove from the iterator.

I tried it but apparently it doesn't have any influence on the final
outputted presentation either. Do you have any other ideas to remove an
existing XSLFTextParagraph inside a shape?

I would be fine if I could at least replace the existing content, as it is
used to aggregate the necessary formatting options, for the following text.




--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]