I’m using the Java SDK interface to build a writer (text) document. As part of the process, I want to selectively add headers to the page, but not to the first page of a section.
My first thought was to just check the page count as my code adds paragraphs, and then use the point where page count increases to mark the change of a page. Unfortunately, the data from XDocumentProperties.getDocumentStatistics() seems to be generated at load time and never updated. I tried adding a few pagefuls of stuff, but the PageCount remained at 1 and WordCount remained at 0 when I queried it.
XTextDocument document = createDocumentSomehow();
XDocumentPropertiesSupplier supplier = UnoRuntime.queryInterface(XDocumentPropertiesSupplier.class, document);
XDocumentProperties properties = supplier.getDocumentProperties();
NamedValue[] values = properties.getDocumentStatistics();
... and then fetch "PageCount" from that
Is there a better way to detect a page changing as my code adds to the document?