Page 1 of 1
[Solved] Copy writer editing document
Posted: Fri Jul 23, 2021 2:12 am
by HCL
How to copy(or duplicate) a writer document?
I want to copy a editing writer document.
I found a way to use "XDocumentInsertable.insertDocumentFromURL".
But it just copy saved document.
It mean that this method can't copy editing document that are not saved.
Re: Copy writer editing document
Posted: Fri Jul 23, 2021 9:33 am
by JeJe
Is this what you're after:
https://www.openoffice.org/api/docs/com ... plier.html
Code: Select all
'copy the selection to a variable
trans= thiscomponent.currentcontroller.getTransferable
'insert the copied selection
thiscomponent.currentcontroller.setTransferable(trans)
[Solved] Copy writer editing document
Posted: Sat Jul 24, 2021 3:37 am
by HCL
Thank you for your reply.
I could do I wanted by your advice.
And
https://blog.oio.de/2010/10/27/copy-and ... e-org-api/
===============================
Code: Select all
XTextDocument xdoc1; // Source to be copied
XTextDocument xdoc2; // Target to copy
XTransferableSupplier sup1 = UnoRuntime.queryInterface(XTransferableSupplier.class, xdoc1.getCurrentController());
XTransferableSupplier sup2 = UnoRuntime.queryInterface(XTransferableSupplier.class, xdoc2.getCurrentController());
// Select target texts to be copied
XSelectionSupplier xSelectionSupplier = UnoRuntime.queryInterface(XSelectionSupplier.class, xdoc1.getCurrentController());
xSelectionSupplier.select(xdoc1.getText());
sup2.insertTransferable(sup1.getTransferable());