Add custom shape into LO Draw via extension

Hello!
I am developing an extension on C++ using UNO API.
And I want to create some custom shapes for my extension. For example, let it be filled circle inside another cricle. I want this shape to behave like a standalone basic shape - it is being drawn via cursor, not just spawned, you can adjust its size and e.t.c. How should I do that?
I found some guides about gallery themes and .fodg formats, but some info looks like outdated.

So, what`s the best way to create a template of a complex custom shape (group of basic shapes) and place it via extension button as any basic LO shape?

I found some guides about gallery themes and .fodg formats, but some info looks like outdated.

You find some general details about custom shapes in
https://wiki.documentfoundation.org/Development/Custom_Shape_Orientation_Guide
Some information about the file format is in book “Custom Shape Tutorial” from
https://documentation.libreoffice.org/en/english-documentation-ii/

You could first create your shape by editing the file format and after that, create such shape by a macro. Of cause you can design you shape directly in a macro as well. I would first do it independent from your extension. For example start with inserting a circle and then change its geometry.

To learn more about custom shapes in the API, insert a custom shape in a document and look at its properties with the Development Tools (menu Tools) or write a minimal macro and look at it in the BASIC IDE. The relevant property is “CustomShapeGeometry”.

Find more hints on Macros - The Document Foundation Wiki

Do you need text in the custom shape in addition?

What is the purpose of your extension? Using C++ is unusual.

1 Like

Just a master’s degree project for my uni. It should be some kind of a graphical modeling tool for LO Draw. I think we will add a bunch of shapes with and without text, and using custom shapes’ user-defined properties we will simulate some processes.
We are using C++ because I am using C++ at my job
Anyway, thanks for providing points for my further LO investigation

MakroIncluded.odp (15.3 KB)
That document contains a BASIC macro to insert a user defined custom shape. It should work similar in C++, but I have never written macros in C++, thus cannot help. It doesn’t look to me as if that is the way for you to go. It might be more appropriate to create the shapes in the UI and by editing the file markup, collect all of them in a Gallery theme and deliver the theme together with all other things in your extension.

1 Like