Due to Popular Demand - SVG Import! - OpenOffice.org...Why XSLT Won't Work Out • ODF & SVG are...
Transcript of Due to Popular Demand - SVG Import! - OpenOffice.org...Why XSLT Won't Work Out • ODF & SVG are...
![Page 1: Due to Popular Demand - SVG Import! - OpenOffice.org...Why XSLT Won't Work Out • ODF & SVG are mutually incompatible: –transformation not possible by mapping xml entities –instead,](https://reader034.fdocuments.us/reader034/viewer/2022043002/5f7d630ed2c46204323ca608/html5/thumbnails/1.jpg)
Due to Popular Demand - SVG Import!A long story in 45 minutes
Fridrich Strba & Thorsten BehrensNovell, Inc.
![Page 2: Due to Popular Demand - SVG Import! - OpenOffice.org...Why XSLT Won't Work Out • ODF & SVG are mutually incompatible: –transformation not possible by mapping xml entities –instead,](https://reader034.fdocuments.us/reader034/viewer/2022043002/5f7d630ed2c46204323ca608/html5/thumbnails/2.jpg)
Why SVG Import?
• users desperately want it in OOo – missing SVG import is one of the highestvoted issues
• and then some:– the most prevalent format for vector cliparts
– the most prevalent vector graphics exchange format
– an Open Standard and> native format for one of the best vector drawing apps out there – Inkscape
– a subset of SVG is even copied in ODF for the drawing shapes
![Page 3: Due to Popular Demand - SVG Import! - OpenOffice.org...Why XSLT Won't Work Out • ODF & SVG are mutually incompatible: –transformation not possible by mapping xml entities –instead,](https://reader034.fdocuments.us/reader034/viewer/2022043002/5f7d630ed2c46204323ca608/html5/thumbnails/3.jpg)
The History
• In the beginning, there was void SVG support
• Then came about Issue 2497
• Followed by WindLi's XSLT implementation
• And Bernhard Haumacher's excellent Batikbased import extension
• The final wisdom is in Issue 49991
• Not to forget the piece presented here: the builtin component
![Page 4: Due to Popular Demand - SVG Import! - OpenOffice.org...Why XSLT Won't Work Out • ODF & SVG are mutually incompatible: –transformation not possible by mapping xml entities –instead,](https://reader034.fdocuments.us/reader034/viewer/2022043002/5f7d630ed2c46204323ca608/html5/thumbnails/4.jpg)
Why XSLT Won't Work Out
• ODF & SVG are mutually incompatible:– transformation not possible by mapping xml entities
– instead, graphical entities need to be mapped, sometimes with intimate knowledge of pixel & geometry
➢ though ODF reuses a subset of SVG, semantics & expressiveness is different enough to make xmlbased conversions fail
![Page 5: Due to Popular Demand - SVG Import! - OpenOffice.org...Why XSLT Won't Work Out • ODF & SVG are mutually incompatible: –transformation not possible by mapping xml entities –instead,](https://reader034.fdocuments.us/reader034/viewer/2022043002/5f7d630ed2c46204323ca608/html5/thumbnails/5.jpg)
What Did We Do?
• Took generic SAX DOM parser
• Twopass DOM tree visiting:– First pass collects style information, serializes styles to ODF
& annotates elements with style names
– Second pass maps SVG shapes to ODF shapes, possibly emulating via polygons
• No need for custom xml parser, very quick results
• Easy to extend over time, no crosscutting changes necessary
![Page 6: Due to Popular Demand - SVG Import! - OpenOffice.org...Why XSLT Won't Work Out • ODF & SVG are mutually incompatible: –transformation not possible by mapping xml entities –instead,](https://reader034.fdocuments.us/reader034/viewer/2022043002/5f7d630ed2c46204323ca608/html5/thumbnails/6.jpg)
Architecture
Cliparts from: http://openclipart.org/people/skadge/skadge_SVG_widgets_for_diagrams.svg
<svg/>
xml::dom::XDocument
<office:drawing/>
writeShapes()
annotateStyles()
<office:styles/>
![Page 7: Due to Popular Demand - SVG Import! - OpenOffice.org...Why XSLT Won't Work Out • ODF & SVG are mutually incompatible: –transformation not possible by mapping xml entities –instead,](https://reader034.fdocuments.us/reader034/viewer/2022043002/5f7d630ed2c46204323ca608/html5/thumbnails/7.jpg)
DEMO: ODF Import
![Page 8: Due to Popular Demand - SVG Import! - OpenOffice.org...Why XSLT Won't Work Out • ODF & SVG are mutually incompatible: –transformation not possible by mapping xml entities –instead,](https://reader034.fdocuments.us/reader034/viewer/2022043002/5f7d630ed2c46204323ca608/html5/thumbnails/8.jpg)
Why ODF Import is Suboptimal
• Inevitable information loss:– Inferior gradients
– Inferior fill rules
– Inferior line stroking & dashing
– Inferior line end markers
– Grouping much less expressive
– No 'template' shapes
– No clipping
– No filters
• i.e. all nonrepresentable features need to be emulated via custom rendering
![Page 9: Due to Popular Demand - SVG Import! - OpenOffice.org...Why XSLT Won't Work Out • ODF & SVG are mutually incompatible: –transformation not possible by mapping xml entities –instead,](https://reader034.fdocuments.us/reader034/viewer/2022043002/5f7d630ed2c46204323ca608/html5/thumbnails/9.jpg)
SVG Graphic Import
The “Insert>Picture” variant
• most code shared with ODF import
• Adding render commands to a metafile, instead of streaming ODF
• Yields an atomic, noneditable image like PNG or EMF
![Page 10: Due to Popular Demand - SVG Import! - OpenOffice.org...Why XSLT Won't Work Out • ODF & SVG are mutually incompatible: –transformation not possible by mapping xml entities –instead,](https://reader034.fdocuments.us/reader034/viewer/2022043002/5f7d630ed2c46204323ca608/html5/thumbnails/10.jpg)
Architecture
Cliparts from: http://openclipart.org/people/skadge/skadge_SVG_widgets_for_diagrams.svg
<svg/>
xml::dom::XDocument annotateStyles()
class GDIMetaFile;
renderMtf()
![Page 11: Due to Popular Demand - SVG Import! - OpenOffice.org...Why XSLT Won't Work Out • ODF & SVG are mutually incompatible: –transformation not possible by mapping xml entities –instead,](https://reader034.fdocuments.us/reader034/viewer/2022043002/5f7d630ed2c46204323ca608/html5/thumbnails/11.jpg)
DEMO: Graphics Import
![Page 12: Due to Popular Demand - SVG Import! - OpenOffice.org...Why XSLT Won't Work Out • ODF & SVG are mutually incompatible: –transformation not possible by mapping xml entities –instead,](https://reader034.fdocuments.us/reader034/viewer/2022043002/5f7d630ed2c46204323ca608/html5/thumbnails/12.jpg)
What's Wrong With Graphic Import?
• Duplicates effort – librsvg is there & works like a charm
• Problem is, OOo does not easily lend itself to custom graphic renderers
– Historically, all OOo graphic filters convert to either> Bitmap, or
> StarView Metafile (comparable to WMF)
– There are two notable exception to the rule:> EPS tunneling for PostScript printers
> Rodo's EMF+ import, rendered via Xcanvas
• Hacking librsvg to pseudorender to StarView Metafile is a waste – too little expressiveness
![Page 13: Due to Popular Demand - SVG Import! - OpenOffice.org...Why XSLT Won't Work Out • ODF & SVG are mutually incompatible: –transformation not possible by mapping xml entities –instead,](https://reader034.fdocuments.us/reader034/viewer/2022043002/5f7d630ed2c46204323ca608/html5/thumbnails/13.jpg)
Planned Graphic Import Improvements
• better gradient & text support for the ODF import
• use librsvg to render directly:– either with the cairo backend
– or via rendering::XCanvas
• get Sun to accept it under nonSCA conditions
![Page 14: Due to Popular Demand - SVG Import! - OpenOffice.org...Why XSLT Won't Work Out • ODF & SVG are mutually incompatible: –transformation not possible by mapping xml entities –instead,](https://reader034.fdocuments.us/reader034/viewer/2022043002/5f7d630ed2c46204323ca608/html5/thumbnails/14.jpg)
Roadmap
• Improve SVG to ODF mapping on demand
• bin SVG to SVM mapping midterm, and replace with librsvg binding
– if possible, provide a generic render plugin mechanism for other vector formats:
> WMF/EMF (join forces with Abiword/libwmf)
> EMF+
> SVG (librsvg)
> EPS/PDF (gs/poppler)
> SVM (extract own code to lib)
> PICT (extract own code to lib)
• Longterm, decouple all graphic filters from core OOo
![Page 15: Due to Popular Demand - SVG Import! - OpenOffice.org...Why XSLT Won't Work Out • ODF & SVG are mutually incompatible: –transformation not possible by mapping xml entities –instead,](https://reader034.fdocuments.us/reader034/viewer/2022043002/5f7d630ed2c46204323ca608/html5/thumbnails/15.jpg)
Q & A