I’m trying to use a macro to copy text to the clipboard from LO Base and then paste the text into Firefox.
The code below only works once. The second time I try only a few characters get pasted and then shortly after LO crashes.
Is there a bug in LO or is something wrong with my code?
I’m running under Ubuntu 18 and LO 6.0.7.3
Any help would be appreciated.
Here is the code:
GLOBAL sGlobalText as STRING
SUB CopyClipboardTitle(event as OBJECT)
rem this routine is called when a button on the Base form is pressed to copy the text to the clipboard
DIM oTR as OBJECT
DIM oClip as OBJECT
rem this function makes the string and stores it in a global variable
sGlobalText = FunctionToBuildString()
oClip = createUnoService("com.sun.star.datatransfer.clipboard.SystemClipboard")
oTR = createUnoListener("TR_","com.sun.star.datatransfer.XTransferable")
oClip.setContents(oTR,null)
END SUB
FUNCTION TR_getTransferData(aFlavor as com.sun.star.datatransfer.DataFlavor) as Any
IF (aFlavor.MimeType = "text/plain;charset=utf-16") THEN
rem sGlobalText is a global variable and has already been set
TR_getTransferData = sGlobalText
ENDIF
END FUNCTION
FUNCTION TR_getTransferDataFlavors() as Any
DIM aF as NEW com.sun.star.datatransfer.DataFlavor
aF.MimeType = "text/plain;charset=utf-16"
aF.HumanPresentableName = "Unicode-Text"
TR_getTransferDataFlavors = Array(aF)
END FUNCTION
FUNCTION TR_isDataFlavorSupported(aFlavor as com.sun.star.datatransfer.DataFlavor) as BOOLEAN
TR_isDataFlavorSupported = (aFlavor.MimeType = "text/plain;charset=utf-16")
END FUNCTION