Using UNO API for java
Michael Stahl
mstahl at redhat.com
Mon Apr 29 03:18:58 PDT 2013
On 29/04/13 05:55, adrivero wrote:
>
> Using UNO API for java and charge a template that contains a table ....
>
> I try to copy that table on the next page (I need copy also property ) to
> create a new .... and I find as
[...]
your code should locate the source table, and i assume your question is
how to copy that?
hmmm.... that doesn't appear to be entirely obvious....
so there is a XTextCopy interface [1]... which is apparently implemented
in SwXText so it should be available at both the Writer body text and
cell objects... but this interface does not allow to specify a position
at which the copy should be inserted, it is always inserted at the end,
which is a serious shortcoming.
i guess it would be possible to copy a table to the end of a document
like so:
1. read out the properties of the table and store them
2. iterate over all cells and:
a) store the position at the end of the document
b) use XTextCopy to insert the cell content at the end of the
document
c) store the cell properties somewhere
3. use XTextConvert [2] to convert the bunch of paragraphs that were
inserted in step 2 into a table using the stored positions and cell
properties
... but that appears annoyingly complicated and you can only insert at
the end.
seems much easier to do the copying via the clipboard... this article
[3] looks very interesting, it's even possible to do an "internal"
copy/paste via API that doesn't even mess up the system clipboard.
regards,
michael
[1]
http://api.libreoffice.org/docs/common/ref/com/sun/star/text/XTextCopy.html
[2]
http://api.libreoffice.org/docs/common/ref/com/sun/star/text/XTextConvert.html
[3]
http://blog.oio.de/2010/10/27/copy-and-paste-without-clipboard-using-openoffice-org-api/
More information about the LibreOffice
mailing list