I am trying to add a bulleted list on an OutlinerShape of a XDrawPage for
an impress document and am having some troubles. I have read in several
places that you need to set the NumberingType of the NumberingRules
property, but I am not sure whether I am doing this correctly. I have tried
this with a TextShape as well to no avail. Here is a code snippet:
public static void createPowerPointPresentation(){
PropertyValue[] loadProps = new PropertyValue[1];
loadProps[0] = new PropertyValue();
loadProps[0].Name = "Silent";
loadProps[0].Value = new Boolean(true);
try {
XComponent document = jComponentLoader.loadComponentFromURL(
"private:factory/simpress", "_blank", 0, loadProps);
XDrawPagesSupplier xDrawPagesSupplier =
(XDrawPagesSupplier)UnoRuntime.queryInterface(
XDrawPagesSupplier.class, document);
XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages();
Object newPage = xDrawPages.getByIndex(0);
XDrawPage xNewPage =
(XDrawPage)UnoRuntime.queryInterface(XDrawPage.class, newPage);
XMultiServiceFactory factory = (XMultiServiceFactory)UnoRuntime
.queryInterface(XMultiServiceFactory.class, document);
Object bullets =
factory.createInstance("com.sun.star.presentation.OutlinerShape");
XShape xBullets =
(XShape)UnoRuntime.queryInterface(XShape.class, bullets);
XIndexAccess xNum = (XIndexAccess)
UnoRuntime.queryInterface(XIndexAccess.class,
factory.createInstance("com.sun.star.text.NumberingRules"));
XIndexReplace xReplace = (XIndexReplace)
UnoRuntime.queryInterface(
XIndexReplace.class, xNum);
PropertyValue[] aProps = (PropertyValue []) xNum.getByIndex(0);
for (int j = 0 ; j < aProps.length ; ++j) {
if (aProps[j].Name.equals ("NumberingType")) {
aProps[j].Value = new Short(NumberingType.ROMAN_UPPER);
xReplace.replaceByIndex (0, aProps);
break;
}
}
XText xText2 = (XText)UnoRuntime.queryInterface(XText.class,
xBullets);
XPropertySet xPropertySet =
(XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, xText2);
xPropertySet.setPropertyValue("NumberingRules", xNum);
xNewPage.add(xBullets);
xText2.setString("bullet1\nbullet2");
Object title =
factory.createInstance("com.sun.star.presentation.TitleTextShape");
XShape xTitle = (XShape)UnoRuntime.queryInterface(XShape.class,
title);
XText xText = (XText)UnoRuntime.queryInterface(XText.class,
xTitle);
xNewPage.add(xTitle);
xText.setString("testing");
Util.convert(document, jContext, "C:\\tmp\\qq.ppt", "MS
PowerPoint 97");
document.dispose();
} catch (Exception ex) {
jL.warning("Problem occurred creation PowerPoint Presentation");
ex.printStackTrace();
}
}