Discussion:
XSLFTextRun definition
giazo
2018-08-04 16:27:11 UTC
Permalink
Hey all,

I'm currently working on a tool that is required, between other things, to
fill some XSLFAutoShapes containing placeholder text with actual text,
inside a pptx file.
I'd like to be able to apply the formatting (font
color/size/bold/italic/underlined) of the placeholder to the actual text
that will replace it.
I'm having partial success: while getting the aforementioned textRun
properties isn't a problem, the XSLFTextRun itself seems to vary: the text
it contains is not the text I expect it to contain.

I am working under the assumption that a XSLFTextRun is a String of chars
which share the same set of formatting properties and doesn't contain any
newlines.
Is there an official definition of what a XSLFTextRun is?

I found a StackOverflow post where someone was replying that XSLFTextRun are
somewhat decided by the office suite that generated the pptx/docx/xslx, but
I can't find it now for the life of me. I got it bookmarked on my machine at
my workplace, but I cannot access it remotely, so I'll be able to retrieve
it only just monday.
In the meanwhile I'd like to start thinking to a different solution, if this
turns out to be true.

Thanks in advance

Giacomo






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

---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@poi.apache.org
For additional commands, e-mail: user-***@poi.apache.org
Andreas Beeker
2018-08-05 19:00:41 UTC
Permalink
Hi Giacomo,
the text it contains is not the text I expect it to contain
If you would provide your expected text + the file, that would lift the mysterious curtain ... :)
Is there an official definition of what a XSLFTextRun is?
The official POI statement is in the code ... just look at the hierarchy of XSLFTextRun +
XSLFTextParagraph constructor. When I've refactored the code a while ago, I've tried to
unify HSLF and XSLF usage, therefore the underlying xml structures aren't always
identical to the usermodel classes. I also wouldn't rule out, that eventually I need to
add further classes to handle CTText* classes differently.
I am working under the assumption that a XSLFTextRun is a String of chars
which share the same set of formatting properties and doesn't contain any
newlines.
XSLFLineBreak extends XSLFTextRun ... so your assumption is partly wrong.
I found a StackOverflow post where someone was replying that XSLFTextRun are
somewhat decided by the office suite that generated the pptx/docx/xslx
The underlying CT* classes are from the drawingml schema, which is used also by XSSF/XWPF,
but XSLFTextRun is specific to XSLF - the counterpart would be XSSFTextRun.
Those classes are currently independently developed - which is a pity, but one could argue,
that XSSF is more stable than XSLF.
I'd like to be able to apply the formatting ... of the placeholder to the actual text
that will replace it.
There are several indirections of the formatting (directly on the XSLFTextRun, inherited by the
slidelayout or the slidemaster, or inherited by the theme) - the easiest would be, if you create
an example file with Powerpoint and then check where your modifications are located
(... in the xmls in the .pptx/.zip)

Sorry to be so unspecific, but your description was also a bit vague ...

Andi

Loading...