Background:
I want to paste (like [CTRL+V]) anything (preferably image, shape) at the position I click or hover with the mouse (when using a key to activate). I don't know how to get the position on the document (X, Y) I clicked.
(Apache OpenOffice, SDraw-Document, OpenOffice BASIC Macro)
What I need:
- Hint/Tip how to get the location from the mouse-click / mouse-position on the document. (Which class, listener, component I need)
Notes:
Something like a com.sun.star.awt.XMouseClickHandler
would be perfect, if the given oEvent
gave me the X+Y of the document, where I clicked.
(Maybe you know how to "activate" PopupTrigger
? (com.sun.star.awt.MouseEvent
))
My code so far:
I tried using the mentioned XMouseClickHandler
to get X+Y.
Sadly, X+Y refer to the relative position of the window and not the actual position a shape or text would have on the document.
Execution: My Sub Main
is executed via a Menu-Button at the top.
Then clicking anywhere will output (via MsgBox) the coordinates of that click.
Only Problem: Coordinates are relative to the corner of the window, not the corner of the document.
Global gListener As Object
Sub Main
gListener = CreateUnoListener("Listener_","com.sun.star.awt.XMouseClickHandler")
ThisComponent.CurrentController.addMouseClickHandler(gListener)
End Sub
Sub Listener_mousePressed(oMouseEvent) As Boolean
ThisComponent.CurrentController.removeMouseClickHandler(gListener)
Msg = "Position: "
Msg = Msg & oMouseEvent.X & "/" & oMouseEvent.Y
MsgBox(Msg)
REM :: I want something like:
REM :: Msg = "Position: " & oMouseEvent.PositionOnDocument.X
REM :: Msg = Msg & "/" & oMouseEvent.PositionOnDocument.Y
REM :: MsgBox(Msg)
End Sub
My references:
All my information come from the official references/docs so far, since all my searches did not find anything helpful.
- Class-List: http://api.libreoffice.org/docs/idl/ref/annotated.html Here you can see docs for the used classes (com.sun.star.awt.XMouseClickHandler, com.sun.star.awt.MouseEvent)
- Infos about listener: https://help.libreoffice.org/3.6/Basic/CreateUnoListener_Function_Runtime
Thanks in advance.