import filters for vector graphic formats in libreoffice: the reverse- and straight engineering fun
DESCRIPTION
The talk aims at presenting the recent graphic import filters additions to LibreOffice. It will show the feature coverage and the way we developed them. The method allowed us to do quite substantial progress in short time. The APIs used will be also presented briefly.TRANSCRIPT
LGM 2012 - LibreOffice Graphic Import filters
LibreOffice import filters for vector graphic formatsThe fun of reverse- and straight engineering
Fridrich Štrba – [email protected] Document FoundationSoftware Engineer, SUSE
2LGM 2012 - LibreOffice Graphic Import filters
Who Am I?
Software Engineer in SUSE LibreOffice Team
Diverse background
FLOSS enthusiast
Working in free time on various projects
3LGM 2012 - LibreOffice Graphic Import filters
Agenda
Vector graphic import filters resulting from the work of LibreOffice community
How we did itFramework usedMissing file-format documentationCollaboration patternsIncremental reverse-engineering
4LGM 2012 - LibreOffice Graphic Import filters
Why do we handle legacy file-formats?
5LGM 2012 - LibreOffice Graphic Import filters
Legacy formats out there
ODF is the future of the humanityNevertheless, humanity does not know about it as of now
Other de facto standardsSome people use other Office Suites and graphic applications :(
Hard-disks full of bad teenage poetry and indecent drawings in funny formats
LibreOffice offers the freedom to read that pile of …
6LGM 2012 - LibreOffice Graphic Import filters
Pure intellectual exercise
Allows to program for LibreOffice without having to understand its internals
Pretty stand-alone functionality communicating with LibreOffice over well defined interfaces …… almost
Happy users will reward youYou will be the hero of the people who can now read their documents...… and they will get on your nerves listing features that are not converted.
7LGM 2012 - LibreOffice Graphic Import filters
Import filters available to all resulting from the work of LibreOffice community
8LGM 2012 - LibreOffice Graphic Import filters
Vector graphics import filters based on libwpg
WordPerfect Graphics import filter and libwpgStarted by Marc Oude-Kotte and yours faithfulGoogle Summer of Code by Ariya Hidayat in 2006
MS Visio import filter and libvisio
Google Summer of Code by Eilidh McAdam in 2011Guest appearance of re-lab's Valek Filippov
Corel Draw import filter and libcdrWork in progress (kind of) started basically at the end of 2011Will be in LibreOffice 3.6Check http://dev-builds.libreoffice.org for preview fun
9LGM 2012 - LibreOffice Graphic Import filters
Future directions
I prefer to speak about future when it becomes a featureToo many projects with declarations of intentions and nothing at the arrivalCode speaks louder then press releases
Google Summer of Code 2012An attempt at MS Publisher file-format
Valek's personal pet file-formatMacromedia Freehand
Trying to crowd-source the development
10LGM 2012 - LibreOffice Graphic Import filters
How we did it?
11LGM 2012 - LibreOffice Graphic Import filters
Minimize the count of reinvented wheels
Reuse, embrace and extendODF as interchange format
Way import filters communicate with LibreOfficelibwpg's application programming interface
Reusing OdgGenerator class implementing this interface
Speedy developmentNo need to write any boilerplate code
LibreOffice import filter itself about 100 LOCThe core written as a standalone library
Faster testing
12LGM 2012 - LibreOffice Graphic Import filters
Graphic Document Representation
namespace libwpg{ class WPGPaintInterface
{ public: virtual ~WPGPaintInterface () {} virtual void startGraphics (const ::WPXPropertyList &propList) = 0; virtual void endGraphics () = 0; virtual void setStyle (const ::WPXPropertyList &propList, const ::WPXPropertyListVector &gradient) = 0; virtual void startLayer (const ::WPXPropertyList &propList) = 0; virtual void endLayer () = 0; virtual void startEmbeddedGraphics (const ::WPXPropertyList &propList) = 0; virtual void endEmbeddedGraphics () = 0; virtual void drawRectangle (const ::WPXPropertyList& propList) = 0; virtual void drawEllipse (const ::WPXPropertyList& propList) = 0; virtual void drawPolygon (const ::WPXPropertyListVector &vertices) = 0; virtual void drawPolyline (const ::WPXPropertyListVector &vertices) = 0; virtual void drawPath (const ::WPXPropertyListVector &path) = 0; virtual void drawGraphicObject (const ::WPXPropertyList &propList, const ::WPXBinaryData &binaryData) = 0; virtual void startTextObject (const ::WPXPropertyList &propList, const ::WPXPropertyListVector &path) = 0; virtual void endTextObject () = 0; virtual void startTextLine (const ::WPXPropertyList &propList) = 0; virtual void endTextLine () = 0; virtual void startTextSpan (const ::WPXPropertyList &propList) = 0; virtual void endTextSpan () = 0; virtual void insertText (const ::WPXString &str) = 0; };
} // namespace libwpg
13LGM 2012 - LibreOffice Graphic Import filters
Key Classes
OdgGenerator.?xxImplementation of libwpg::WPGPaintInterface
OdfDocumentHandler.hxxAbstract SAX interface to receive ODF documentCode that serializes the SAX calls into file (flat ODF and zip-based ODF)
*SVGGenerator.?xxEach library has an internal SVG Generator (suboptimal)New libwpg will make the SVG Generator part of the public API
14LGM 2012 - LibreOffice Graphic Import filters
Advantages
Generating ODF is not trivialSettingsStylesAutomatic stylesContent
Provide a linear interfaceReuse instead of copying the existing ODF generatorsDeveloper does not waste time designing interfaceSpeeds up development by focusing on the essentials
15LGM 2012 - LibreOffice Graphic Import filters
File-format documentation
Almost noneFor libvisio
Marginally useful user and developer documentation of MSDNPossibility to save using the VDX (xml) file-formatBasically XML dump of the binary (the same concepts)
For libcdrDocument explaining a bit the CMX exchange format (similar concepts)
Reverse engineeringBased on re-lab's work
oletoy
16LGM 2012 - LibreOffice Graphic Import filters
Development method
Focus on getting “some” result earlyFirst embedded raster images
Libreoffice is able to render them without further processing
Next graphic primitives“Everything is just a path”
Develop tools along the implementationIntrospection tool improved constantly
Driven by the need of the implementationReflecting growing understanding of file-formatDon't solve problems that don't exist
17LGM 2012 - LibreOffice Graphic Import filters
The team
Valentin Filippov Fridrich Štrba Eilidh McAdam
18LGM 2012 - LibreOffice Graphic Import filters
Development method II
Design the software as you go
Some code is better then an abstract designPossibility to find and fix real bugsLittle communication overhead
Communication by code in gitLearning by doing mistakes and fixing
Release soon, release oftenA release every 2-3 weeksGood to have intermediary targets
19LGM 2012 - LibreOffice Graphic Import filters
Extending the file-format coverage
Incremental reverse-engineeringNobody reinvents a wheel completely
Two subsequent versions of the same file-format will have some common DNA
Try to parse lower or higher version using the existing parserFix issues as they appearImportance of a small number of reference documents covering many featuresImportance of having a working parser for other versions
Experience makes differenceDifferent ways of encoding the same informationDifferent ways of structuring
20LGM 2012 - LibreOffice Graphic Import filters
All text and image content in this document is licensed under the Creative Commons Attribution-Share Alike 3.0 License (unless otherwise specified). "LibreOffice" and "The Document Foundation" are registered trademarks. Their respective logos and icons are subject to international copyright laws. The use of these therefore is subject to the trademark policy.
Q&A and Stoning session