title subject keywords comments properties writer document Vincenzo Giuliano

How can I read the writer document properties (File -> Properties ->) in Java code?

You have need to XPropertySet belong to XDocumentInfo interface

import {%see com.sun.star.text.XTextDocument}; import {%see com.sun.star.document.XDocumentInfoSupplier}; import {%see com.sun.star.document.XDocumentInfo}; import {%see com.sun.star.beans.XPropertySet}; import {%see com.sun.star.beans.XPropertySetInfo}; import {%see com.sun.star.beans.Property}; import {%see com.sun.star.lang.XComponent}; public Property[] getDocumentProperties(XComponent xComponent) { {%seeshort com.sun.star.text.XTextDocument} xtd = ({%seeshort com.sun.star.text.XTextDocument})UnoRuntime.queryInterface({%seeshort com.sun.star.text.XTextDocument}.class,xComponent); {%seeshort com.sun.star.document.XDocumentInfoSupplier} xdis = ({%seeshort com.sun.star.document.XDocumentInfoSupplier})UnoRuntime.queryInterface({%seeshort com.sun.star.document.XDocumentInfoSupplier}.class,xtd); {%seeshort com.sun.star.document.XDocumentInfo} xdi = xdis.getDocumentInfo(); {%seeshort com.sun.star.beans.XPropertySet} xps = ({%seeshort com.sun.star.beans.XPropertySet})UnoRuntime.queryInterface({%seeshort com.sun.star.beans.XPropertySet}.class,xdi); {%seeshort com.sun.star.beans.XPropertySetInfo} xpsi = xps.getPropertySetInfo(); {%seeshort com.sun.star.beans.Property}[] props = xpsi.getProperties(); /*The properties are within props */ return props; }
Initial version