Hello,
I’ve been using draw to register many systems over a map, and I was wondering if there’s any way to export individual objets + coordinates to an external database (and back).
Did anyone walk this way or can give me some advice?
Just opened the content.xml from a small odg file (renamed to zip) and indeed, I can see many “draw:custom-shape” tags with the required info (coordinates, text, styles…), but I want to avoid messing with dirty custom scripts to do the job: file version control, unzipping, etl, sanity checks, etc.
Thank you
For example?
This is one of the objects:
<draw:custom-shape draw:style-name=“gr2” draw:text-style-name=“P4” draw:layer=“layout” svg:width=“0.384cm” svg:height=“0.232cm” svg:x=“9.311cm” svg:y=“23.703cm”>
<text:p text:style-name=“P3”>
<text:span text:style-name=“T2”>OBJECT1 LINE1
</text:span>
</text:p>
<text:p text:style-name=“P3”>
<text:span text:style-name=“T2”>OBJECT1 LINE1
</text:span>
</text:p>
<text:p text:style-name=“P3”>
<text:span text:style-name=“T2”>DESCRIPTION1
</text:span>
</text:p>
<draw:enhanced-geometry svg:viewBox=“0 0 21600 21600” draw:mirror-horizontal=“false” draw:mirror-vertical=“false” draw:type=“rectangle” draw:enhanced-path=“M 0 0 L 21600 0 21600 21600 0 21600 0 0 Z N”/>
I would need to unzip the .odg file and parse the content.xml (after inspection, everything I need it’s located here). That’s the easy part. Ideally, I would have a copy in a database I should be able to modify and then get the .odg “reforged” again (this is the tricky part). This way Draw would be the viewer and I could easily manipulate the data: forms, positions, texts…
But I think I would lose days just hammering back a file that Draw could load without errors. That’s why I’m asking if someone has made something similar, as all the results I find in google talk about Base instead of Draw :S
Any help is appreciated.
Thank you
Hi, in general, there are two options: manipulate the xml, or use the LO api. Manipulate the xml is pretty safe for extracting the shape properties. For modifying the properties, I would consider it relatively safe if you do not modify the hierachical xml structure, just modify the numbers or texts. If you modify the structure, I would be afraid of an unpredicted change in the LO logic in some later LO version, which could make the modified XML unreadable. So using the LO api definitely I would consider the safer way.
Do all your shapes follow the same template?
I am missing the draw:name attribute …
No, I don’t ask for XML/ODG.
Managing that from the API is trivial.
It weighs an example of the origin/destiny of the data, the database and a file in Draw as it remains.
To tell you how it’s done, with the API.
Oh great, we have an API. Please forgive me, I didn’t know about it. Will check it. Thank you so much.