Basic macro: how to flip horizontally an object?

I would like to create a macro in Impress that flips horizontally or vertically the object which is currently selected.

I have searched for that in the API, in particular in this document (in French):

but I could not find anything relevant.

I have tried:

ThisComponent.CurrentSelection(0).MirroredX = True

but this does not work.

Could somebody help me?

Thanks in advance.

@FrédéricParrenin, Would you help me with a small favor? I am collecting data about how many karma is
needed for which activities in this site. Could you hover the mouse pointer over the karma points (next to your user name at the top) and share here the content it display? It will say “Currently, you can:…”. Thanks in advance.

My first tip: install one of the object inspection tools (XrayTool, MRI). Then you will able to list the properties an methods of the programmig objects.

Here is my sample file. I just studied these API functions with the helps of the XrayTool. I never used these properties before.


And here is a recorded macro (uses the Dispatcher).

dim document   as object
dim dispatcher as object
	document   = ThisComponent.CurrentController.Frame
	dispatcher = createUnoService("")
	dispatcher.executeDispatch(document, ".uno:FlipHorizontal", "", 0, Array())
	rem dispatcher.executeDispatch(document, ".uno:FlipVertical", "", 0, Array())

It will flip the other type of shapes too. But is not work with multiselection.

There is also the LibreOffice reference API:

LibreOffice: Namespace List

There are MirroredX() and MirroredY() methods, but when I try:

ThisComponent.CurrentSelection(0).MirroredY = True

I get an error message that the MirroredY property or method does not exist.

Please upload your ODF type sample file here. Then we will see: what type of graphical objects did you meant. (We will examine it with an object inspection tool.)
What is the “CurrentSelection”? Do you selected more than one objects? Or is it a Group of objects?
Do you use any object ispection tool?

So my basic macro is the following:

Sub TriangleIsocele(xx as Integer, yy as Integer, LL as Integer, HH as Integer)
Dim oSize as New
Dim oPosition As New
Dim Coordinates(2) As New
oObject = ThisComponent.createInstance("")
coordinates(0).x = xx*100
coordinates(0).y = (yy+HH)*100
coordinates(1).x = (xx+LL)*100
coordinates(1).y = (yy+HH)*100
coordinates(2).x = (xx+LL/2)*100
coordinates(2).y = yy*100
oObject.PolyPolygon = Array(Coordinates())
End Sub

Sub test()
call TriangleIsocele(10, 10, 100, 50)
ThisComponent.CurrentSelection(0).MirroredY = True
end Sub

So in this case it is one single drawing object.
I did not manage to use an inspection tool.

“I did not manage to use an inspection tool.”

See my answer and my comments in this thread:

I could not installed X-ray, is it compatible with LO7?
I did install MRI, but did not find attribute related to geometric operations.
But I am not sure to use the tool correctly.

The XrayTool 6.0 works fine in my LibreOffice 7.0.0 x64 portable (winPenPack) version on Windows10x64Prof.

I could eventually install XrayTool on LO7.
XrayTool and MRI seem to provide similar information.
However, I do not see where to get an horizontal of vertical flip transformation of a polygon shape from XrayTool. I see RotageAngle and ShearAngle, but nothing mirror- or flip-related.

See my sample file in my answer. There is not any “Mirror” nor “Flip” command or method for the polygons. You must calculate the coordinates of the transponed points of the polygons to flip them.

Yes, it was my conclusion also that there is no Flip or Mirror command. For the polygon, I can do the transformation manually, but I wanted a generic tool which works for any shape. Maybe I will post a bug report on bugzilla.

“but I wanted a generic tool which works for any shape.”

Then you need modify my macro routines. (See my sample file in my Answer above.) Embed more other methods to flip the other type of shapes - with same subroutine.

Or you can record a macro (in the Writer App) to flip the objects. It not work wit multiselection. See the code in my Answer above.

Thanks @Zizi64.
Your recorded macro using the dispatcher works, actually even for multiselection.