How do I generate an OpenOffice Draw document?
Asked Answered
M

2

8

I want to create a flowchart in OpenOffice Draw.

Since there's a lot of steps to show (and may change in future) but I can extract the data, I want to automate the creation with the following steps:

  • Create a new ODG document with specified page settings.
  • Insert flow chart shapes with specified properties.
  • Connect those things with arrows.
  • Ideally, auto-organise things into sensible positions.

I don't want to spend hours reading about some "UNO" thing - I just want code examples that I can adapt as required.

Not bothered if the example code uses the OO API, or just modify XML files inside a zipped template - so long as it lets me do the above things easily enough.

I'm doing this with Railo (CFML), but I can also work with Java, or convert snippets from other readable languages.

Any suggestions how to go about this?


Update:
I've started playing with the XML route - I saved an empty file, and a file with a single object, and compared the two (treating as zips) to see the difference, then repeated a few times with different changes to help understand what's going on.

I have some very basic (and incomplete) code which can create shapes and connect them, which can be seen here: http://gist.github.com/634306

It's very crude, but I can probably work out a way to use what I've got now to produce what I need - but I'm still hoping that someone can point me towards a better way of doing this - particularly since I'll need to figure out some way of positioning the shapes appropriately, which wont be trivial.

I've created a distinct question for this fourth point:
How do I auto-layout boxes on a flowchart?

Update 2:
From that other question, I have discovered GraphViz which can visualise graphs from data - and I've created a 'digraph' from my data - so all I need is a way to convert the output of GraphViz into something which OpenOffice Draw can accept. The obvious thought there would be SVG, but it seems OpenOffice hasn't implemented SVG properly yet, so I need to come up with another plan.

Mcmichael answered 18/10, 2010 at 17:36 Comment(4)
What are your inputs ? Just a connected graph in some database or something ? What do you really need the output to be ? Just a .png or a real OO Draw file ?Hypocycloid
Basically, yeah - it's a bunch of Jira statuses and their transitions (which link to other statuses), which I've got as a CFML/JSON data structure. (No db access, I converted from the HTML.)Mcmichael
Output-wise, I'll need to do more work in OO Draw afterwards (to add extra information and probably fix positions), so PNG wouldn't be great, but any vector format I can import is fine.Mcmichael
OO Draw imports EPS format, which is one of the outputs for GraphViz. Just tested it out, and it appears to import the EPS files correctly and in vector format.Tunicate
M
1

You could try api.openoffice.org. Let me know how that worked out for you.

Mace answered 27/5, 2011 at 10:29 Comment(0)
I
0

You can checkout my post about how to create an OO Spreadsheet. The example is .NET but should be easily portable to Java. I haven't done it before but I would assume that you can replace writer8 with draw8 to access the OpenOffice Draw engine instead of the spreadsheet engine. If you have successfully created a Spreadsheet that way, then you can checkout the API about how to add Shapes and Figures.

Isopiestic answered 29/6, 2011 at 18:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.