Fai la tua domanda

ksten's profile - attività

2018-12-20 06:12:36 +0200 received badge  Domande famose (source)
2018-10-17 14:21:17 +0200 ha accettato una risposta Detecting when the page changes

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?

2018-06-09 00:28:38 +0200 received badge  Domande famose (source)
2018-06-09 00:28:38 +0200 received badge  Domanda notevole (source)
2018-04-06 12:46:57 +0200 received badge  Domanda gettonata (source)
2018-04-06 12:46:57 +0200 received badge  Domanda notevole (source)
2018-03-20 01:49:26 +0200 received badge  Domanda notevole (source)
2017-06-11 02:43:56 +0200 received badge  Domanda notevole (source)
2017-06-01 04:07:14 +0200 received badge  Entusiasta
2017-05-30 13:10:42 +0200 ha commentato una risposta Why does my table of contents start on the next page?

Yup, it's checked.

2017-05-30 07:25:53 +0200 received badge  Domanda gettonata (source)
2017-05-30 06:35:01 +0200 ha commentato una risposta Why does my table of contents start on the next page?

Insert is unchecked in both cases.

2017-05-30 01:57:52 +0200 ha posto una domanda Why does my table of contents start on the next page?

Why does my table of contents start on the next page? When I insert a table of contents into my document, it shows "Tabl

2017-05-27 16:31:26 +0200 received badge  Domanda gettonata (source)
2017-05-25 16:51:40 +0200 received badge  Domanda gettonata (source)
2017-05-22 18:26:57 +0200 ha posto una domanda Why does setting a frame's relative width not work?

Why does setting a frame's relative width not work? I'm generating a frame like so: XTextFrame frame = UnoRuntime.q

2017-05-22 18:23:39 +0200 ha posto una domanda Why does my frame not center vertically?

Why does my frame not center vertically? I'm generating a frame like so: XTextFrame frame = UnoRuntime.queryInterf

2017-05-22 18:11:55 +0200 received badge  Sostenitore (source)
2017-05-22 18:11:53 +0200 ha accettato una risposta 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.

2017-05-22 18:11:53 +0200 received badge  Studioso (source)
2017-05-22 07:28:54 +0200 ha commentato una risposta How do I access a cell's VertJustify in Java?

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

2017-05-22 07:14:32 +0200 received badge  Autodidatta (source)
2017-05-22 07:14:32 +0200 received badge  Insegnante (source)
2017-05-22 07:14:19 +0200 received badge  Studente (source)
2017-05-22 05:35:22 +0200 ha modificato una risposta Detecting when the page changes

I found it: XModel model = UnoRuntime.queryInterface(XModel.class, document); XController controller = model.ge

2017-05-22 05:34:22 +0200 ha risposto a una domanda Detecting when the page changes

I found it: XModel model = UnoRuntime.queryInterface(XModel.class, document); XController controller = model.ge

2017-05-22 05:29:42 +0200 ha posto una domanda How do I access a cell's VertJustify in Java?

How do I access a cell's VertJustify in Java? When I search for this on Google, it gives examples in the macro language

2017-05-15 16:10:17 +0200 received badge  Domanda gettonata (source)
2017-05-15 00:39:08 +0200 ha posto una domanda Detecting when the page changes

Detecting when the page changes I'm using the Java SDK interface to build a writer (text) document. As part of the proce