StanB123 created ODFTOOLKIT-394:
-----------------------------------
Summary: Paragraph styles cannot be set
Key: ODFTOOLKIT-394
URL: https://issues.apache.org/jira/browse/ODFTOOLKIT-394
Project: ODF Toolkit
Issue Type: Bug
Components: simple api
Affects Versions: 0.6.1-incubating
Reporter: StanB123
Priority: Minor
The setStyleName method on the Paragraph class in the SimpleAPI doesn't appear
to do anything. In my case I have been trying to set a style that was
preconfigured in a template. I have just checked, and a style that was set in
code appears to do the same.
Here's a short snippet.
{code}
public static void main(String[] args) throws Exception {
TextDocument odt = TextDocument.loadDocument("template.ott");
OdfOfficeStyles s = odt.getOrCreateDocumentStyles();
OdfStyle veryRed = s.newStyle("Very_red", OdfStyleFamily.Paragraph);
veryRed.setProperty(OdfParagraphProperties.BackgroundColor, "#ff0000");
// Create a paragraph
Paragraph p1 = odt.addParagraph("Blah.");
// I think these two lines are supposed to be equivalent, however,
// when you comment out the first one, the style is lost.
p1.getOdfElement().setStyleName("Very_red");
p1.setStyleName("Very_red");
// Save the file
odt.save("result.odt");
}
{/code}
I looked into how to fix this, and I think it might be as simple as changing a
few lines in Paragraph's constructor. But I don't really feel comfortable doing
it seeing as I have only been using this library for a few days.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)