How do I access a cell's VertJustify in Java?

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.

Hello ksten, Google doesn’t recognize the difference between com.sun.star.text.CellProperties and com.sun.star.table.CellProperties

VertJustify is for Calc cells, you have a text table cell. As pointed out by the creator of Xray in this post, you can alter the justfication inside a text table cell by using an ordinary paragraph style, e.g. :

cellCursor.ParaAdjust = com.sun.star.style.ParagraphAdjust.CENTER

That’s for horizontal centering. I need vertical centering.

yes, you can lookup the available properties here, then you see the property “ParaVertAlignment” , then you could type this:

cellCursor.ParaVertAlignment = com.sun.star.text.ParagraphVertAlign.CENTER