
Hi all,
in the _write() methods for most SPObjects there are some lines of code similar to the following (this example is taken from sp-rect.cpp):
if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); repr = xml_doc->createElement("svg:rect"); }
I have been wondering for quite some time in which situations these are called at all. Just now I discovered that this is the case when saving a file as plain SVG. Are there other circumstances, too? I'm asking because I'd like to know what kind of attributes should be set when building an object like this. For example, when I want to create a 3D box with this piece of code, should I set the "sodipodi:type" attribute or should I leave it out (so that effectively only an ordinary svg:g is created)? I'm inclined towards the latter because otherwise when the file is reopened there are also some other attributes missing (since it was saved as plain SVG) so the box is not shown at all because Inkscape is missing some information necessary to render it correctly. I just wanted to ask if my reasoning is correct or if I'm missing anything.
Generally, it would be interesting to know what kinds of attributes should be saved to plain SVG. Apparently, various Inkscape-specific elements are saved (like LPEs), but they seem to be stripped off some attributes that might be necessary to fully recover them.
I hope everyone is enjoying their Christmas vacations! Don't mind if it therefore takes you a bit longer to reply. ;-)
Thanks and best regards, Max
P.S.: BTW, why is repr == NULL if the above code is called when saving to plain SVG but not in other situations? Just wondering.

On Dec 25, 2007 9:23 PM, Maximilian Albert <Anhalter42@...173...> wrote:
I have been wondering for quite some time in which situations these are called at all. Just now I discovered that this is the case when saving a file as plain SVG.
may be, but I don't know of any
because I'd like to know what kind of attributes should be set when building an object like this. For example, when I want to create a 3D box with this piece of code, should I set the "sodipodi:type" attribute or should I leave it out (so that effectively only an ordinary svg:g is created)?
this code just creates or not the element itself, whether or not to add extension attributes is controlled by another flag, SP_OBJECT_WRITE_EXT
file is reopened there are also some other attributes missing (since it was saved as plain SVG) so the box is not shown at all because Inkscape is missing some information necessary to render it correctly.
No. When saving as plain svg, a 3D box is saved as simply a group of paths. So when opened, it must show as it is, but not be editable as a 3D box.
Generally, it would be interesting to know what kinds of attributes should be saved to plain SVG.
only those in the svg standard
P.S.: BTW, why is repr == NULL if the above code is called when saving to plain SVG but not in other situations? Just wondering.
because to save plain svg, inkscape generates a whole new repr tree, so all elements have to be created anew.
participants (2)
-
bulia byak
-
Maximilian Albert