poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Darius Miliauskas <dariui.miliaus...@gmail.com>
Subject appendText method does not work for HSLFTextBox
Date Thu, 22 Oct 2015 14:48:51 GMT
Dear users,

as Java documentation claims HSLFTextBox class inherits the methods from
the class
org.apache.poi.hslf.usermodel.HSLFTextShape
(
https://poi.apache.org/apidocs/org/apache/poi/hslf/usermodel/HSLFTextBox.html),
including the methods such as setText and appendText. The methods
themselves are described at the documentation:
https://poi.apache.org/apidocs/org/apache/poi/hslf/usermodel/HSLFTextShape.html

Anyway, I tried to applied these methods with the text, and setText works
fine, however, appendText gives the error.

My code sample was pretty simple:


SlideShow ppt = new SlideShow();

backgroundToBlack(ppt);

for (String text : texts) {

// adding the empty slide

Slide s0 = ppt.createSlide();

Slide s = ppt.createSlide();

*TextBox title = s.addTitle();*

RichTextRun rt = title.getTextRun().getRichTextRuns()[0];

rt.setFontColor(Color.white);

rt.setFontName("Arial");

rt.setFontSize(44);


Rectangle anchorInTheSlide = new java.awt.Rectangle(5, 5, 710, 125);

title.setAnchor(anchorInTheSlide);


// italic text

if (text.contains("<i>")) {

String[] texts0 = text.split("<i>");

// texts0.length;

*title.setText("");*

TextRun run = title.getTextRun();

//run.setText("");

for (String text0 : texts0) {

if (text0.contains("</i>")) {

text0 = text0.replace("</i>", "");

                                                *title.appendText(text0);*

rt.setItalic(true);

} else {

                                                rt.setItalic(false);

                                                *title.appendText(text0);*

}

}

System.out.println(run.getText());

} else {

title.setText(text);

}

}


Ačiū,

Darius Miliauskas

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message