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.
[Solved] Copy writer editing document
[Solved] Copy writer editing document
Last edited by robleyd on Sat Jul 24, 2021 5:02 am, edited 2 times in total.
Reason: Add green tick
Reason: Add green tick
OpenOffice 3.1 on Windows 10
Re: Copy writer editing document
Is this what you're after:
https://www.openoffice.org/api/docs/com ... plier.html
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)
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
[Solved] Copy writer editing document
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/
===============================
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());
OpenOffice 3.1 on Windows 10