0

I want – as the title says – extract programmatically a shape from a Draw document through the api interface. Beside I want to import such a shape into a document as well.

I saw some predefined shapes in XML form and the document is stored as XML structure as well. Is there a known way to anybody out there to allow the storage and load of one shape?

What is this good for?

I want to, for example, enable the programmatic deletion of objects. But to enable the undo/redo functionalities I need to “store” the deleted shape. Beyond that this would allow me to add user-defined objects programmatically, e.g. arrow heads, UML structures or unicorns.

Thanks in advance for any ideas,

J

P.S.: I work with LibreOffice Version: 5.2.1.2 . Access the interface through C# (so java and C++ would do it as well) but any ideas are welcome.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Jens Bornschein
  • 163
  • 2
  • 11

1 Answers1

1

I'm not entirely sure what you are trying to do, but here are some ideas:

Instead of deleting an XShape, you could use the dispatcher to Cut it. That will store it in the clipboard, so if it needs to be added back then the dispatcher can Paste it, as long as no other copy or cut was performed.

To create a shape, see the example at https://wiki.openoffice.org/wiki/Documentation/DevGuide/Drawings/Shapes. This code will look different depending on what kind of shape it is. It sounds like you are asking for one code listing that will programmatically create any type of shape, but I do not think it is that easy.

Instead of using the UNO API, you could programmatically modify the XML files, which may make it easier to store and work with any shape. Be sure to use an XML parsing library, not just regular expressions.

Jim K
  • 12,824
  • 2
  • 22
  • 51
  • Very interesting idea to use the dispatcher. Maybe it is possible to serialize the clipboard element and store it as a binary stream. I will try this and give you feedback. Nice idea. – Jens Bornschein Oct 18 '16 at 12:11