*
* @author Andreas Br�ker
*/
public IPageStyle getPageStyle() throws TextException {
if (document == null || !(document instanceof ITextDocument))
throw new TextException("Text style not available");
try {
XPropertySet xPropertySet = (XPropertySet) UnoRuntime
.queryInterface(XPropertySet.class, xTextRange);
String pageStyleName = xPropertySet.getPropertyValue(
"PageStyleName").toString();
XStyleFamiliesSupplier xStyleFamiliesSupplier = (XStyleFamiliesSupplier) UnoRuntime
.queryInterface(XStyleFamiliesSupplier.class,
((ITextDocument) document).getXTextDocument());
XNameAccess xNameAccess = xStyleFamiliesSupplier.getStyleFamilies();
Any any = (Any) xNameAccess.getByName("PageStyles");
XNameContainer xNameContainer = (XNameContainer) any.getObject();
any = (Any) xNameContainer.getByName(pageStyleName);
XStyle style = (XStyle) any.getObject();
return new PageStyle(style);
} catch (Exception exception) {
TextException textException = new TextException(exception
.getMessage());
textException.initCause(exception);
throw textException;
}
}