My attempt for automation all process. Libre 7.6.4.1 Win10
Sub EditText
dim oDoc as object, oShape as object, oCur as object
oDoc=ThisComponent
for each oShape in oDoc.DrawPage 'get the shape by the name
if oShape.Name="myShape" then
rem select text in text box via textCursor
oCur=oShape.createTextCursor
oDoc.CurrentController.Select(oCur)
wait 10
uno(oDoc, "SelectAll")
wait 10
uno(oDoc, "Copy")
wait 10
exit for
end if
next
rem remove Text Box
with oShape
.ChainName=""
.TextBox=False
.TextBoxContent=Nothing
end with
rem Paste to Shape
oDoc.CurrentController.Select(oShape)
keyPress(oDoc) 'F2
wait 500 'sometimes lesser value doesn't want to Paste copied text
uno(oDoc, "Paste")
End Sub
Sub uno(oDoc as object, s$, optional arr())
on local error goto bug
if isMissing(arr) then arr=array()
s=".uno:" & s
createUnoService("com.sun.star.frame.DispatchHelper").executeDispatch(oDoc.CurrentController.Frame, s, "", 0, arr)
exit sub
bug:
bug(Erl, Err, Error, "uno")
End Sub
rem key pressing
Sub keyPress(oDoc as object) 'simulate F2/Enter press in oDoc
rem !!! this can cause the triggering of window elements.
dim oKeyEvent as new com.sun.star.awt.KeyEvent
oKeyEvent.Modifiers=0
oKeyEvent.KeyCode=com.sun.star.awt.Key.F2 'or .RETURN
'oKeyEvent.KeyChar=chr(13) 'can use for .RETURN
simulate_KeyPress(oKeyEvent, oDoc)
End Sub
Sub simulate_KeyPress(oKeyEvent as com.sun.star.awt.KeyEvent, oDoc as object)
if NOT isNull(oKeyEvent) then
dim oWindow as object, oToolkit as object
oWindow=oDoc.CurrentController.Frame.ContainerWindow
oKeyEvent.Source=oWindow
oToolkit=oWindow.Toolkit
with oToolkit
.keyPress(oKeyEvent)
.keyRelease(oKeyEvent)
end with
end if
End Sub