Because I find this module very easy to use and, once known, very effective, I love working with Draw. In my opinion, this module would be better known, more developed, more worked. But it's already very good! And I also love doing macros with what the API offers us. This is extremely powerful, especially if you have fun drawing things with external data sources such as Calc or even Writer.
However, I was working recently to set up a shape (a textbox with a barcode font) and I wanted to convert it to a polygon, for, in a second time, keep only the bars and delete the numbers. This is possible in Draw by menus (Modify - Convert - To Polygon). But no matter since I looked in the API, both in Bernard Marcelly's text and Andrew Pitonyak's text, I did not find it. In this case, we necessarily turn to the dispatcher. It causes the macro recording, which produces very ugly code, that we arrange a little. And it often works very well.
But, save code with the dispatcher is a luxury that you can afford only with Calc or Writer. The other modules of the suite are excluded.
This is an old French forum thread that is almost ten years old. And I remembered it without the least concern as he impressed me at the time. The solution was found by Alain de la Chaume. It was not a matter of "converting a shape into a polygon", but just showing or hide the page preview pane.
I translate here Alain's explanations:
Alain de La Chaume wrote:I was inspired by a macro recorded with Writer to understand what arguments to pass and how to pass them.
I chose the Show / Hide Navigator action (from the View menu) which returns this code to me:
I just have to find the keyword that should replace Navigator...Code: Select all
sub showHideNavig rem ---------------------------------------------------------------------- rem define variables dim document as object dim dispatcher as object rem ---------------------------------------------------------------------- rem get access to the document document = ThisComponent.CurrentController.Frame dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") rem ---------------------------------------------------------------------- dim args1(0) as new com.sun.star.beans.PropertyValue args1(0).Name = "Navigator" args1(0).Value = false dispatcher.executeDispatch(document, ".uno:Navigator", "", 0, args1()) rem ---------------------------------------------------------------------- dim args2(0) as new com.sun.star.beans.PropertyValue args2(0).Name = "Navigator" args2(0).Value = true dispatcher.executeDispatch(document, ".uno:Navigator", "", 0, args2()) end sub
To force OpenOffice/LibreOffice to generate a config menu file in my personal environment, I added a menu item in View, of the Draw module of course.
Then I went to consult the config file: menubar.xml
in the root: 'myPersoDirectory'/.config/libreoffice/4/user/config/soffice.cfg/modules/sdraw/menubar/
who told me everything on the subject, by a simple reading of the disposition of lines.
Uh ... yes, it's true that without digging a little, a lot, even passionately ...Code: Select all
<menu:menuitem menu:id=".uno:LeftPaneDraw"/>
It's not cooked at all!
So; ten years later, this research method is still valid and I was able to convert my textShape into polygons in Draw.
Code: Select all
myText = monDocumentDraw.createInstance("com.sun.star.drawing.TextShape")
' Bla - bla - bla &c.
' Conversion into polygons and dissociation of objects with the dispatcher.
myDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
myDrawDocument.currentController.select(myText) ' Visible selection.
myDispatcher.executeDispatch(myDrawDocument.currentController.Frame, ".uno:ChangePolygon", "", 0, array())
myDispatcher.executeDispatch(myDrawDocument.currentController.Frame, ".uno:Dismantle" , "", 0, array())