Hi support,
Please take a look on the following code.
Document doc = new Document("C:\Temp\headings.dot");
DocumentBuilder docBuilder = new DocumentBuilder(doc);
for (Style style: doc.getStyles())
{
System.out.println(style.getName());
}
Style styleH1 = doc.getStyles().get("Heading 1");
Style styleComment = doc.getStyles().get("Comment text");
Style styleQuote = doc.getStyles().get("Quote");
docBuilder.writeln();
docBuilder.getParagraphFormat().setStyle(styleH1);
docBuilder.write("A");
docBuilder.writeln();
docBuilder.getParagraphFormat().setStyle(styleComment);
docBuilder.write("B");
docBuilder.writeln();
docBuilder.getParagraphFormat().setStyle(styleQuote);
docBuilder.write("C");
doc.save("C:\Temp\docSpecialStyle.doc");
The styles names found in the stylesheet are :
CharacterStyle
Default Paragraph Font
Heading 1
Heading 1 Char
Heading 2
Heading 2 Char
Heading 3
Heading 3 Char
Heading 4
Heading 4 Char
LinkedStyle
LinkedStyle Char
ListStyle
No List
Normal
ParagraphStyle
Table Normal
TableStyle
Even if “Comment text” style is not on this list, it exists in the stylesheet and I am able to apply it. But I get a null pointer exception for the “Quote” style, even if this style exists in the stylesheet also.
Another question is why the styles name list does not include all the styles that are present in the stylesheet.
Please advice,
Milan