When I search for this on Google, it gives examples in the macro language like this:
Cell.VertJustify = com.sun.star.table.CellVertJustify.CENTER
However when I try something similar in Java:
XTextDocument document = getDocument();
XMultiServiceFactory serviceFactory = UnoRuntime.queryInterface(XMultiServiceFactory.class, document);
XTextTable table = UnoRuntime.queryInterface(XTextTable.class, serviceFactory.createInstance("com.sun.star.text.TextTable"));
table.initialize(1, 1);
XPropertySet properties = UnoRuntime.queryInterface(XPropertySet.class, table);
properties.setPropertyValue("HoriOrient", HoriOrientation.FULL);
document.getText().insertTextContent(cursor, table, false);
XCell cell = table.getCellByName("A1");
XText cellText = UnoRuntime.queryInterface(XText.class, cell);
XTextCursor cellCursor = cellText.createTextCursor();
cellText.insertString(cellCursor, "This is a test", false);
properties = UnoRuntime.queryInterface(XPropertySet.class, cell);
properties.setPropertyValue("BottomBorderDistance", Units.inchesToHundredthsMm(7));
properties.setPropertyValue("VertJustify", CellVertJustify.CENTER);
It throws an exception: Exception in thread “main” com.sun.star.beans.UnknownPropertyException: VertJustify
What I’m trying to do is center some text both vertically and horizontally on a page in my writer document.