Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Flat ODF as the Swiss Army Knife

Flat ODF as the Swiss Army Knife

Fridrich Strba

October 11, 2012

More Decks by Fridrich Strba

Other Decks in Technology


  1. Flat ODF as the Swiss Army Knife Fridrich Štrba Software

    Engineer SUSE/Attachmate
  2. What is Flat ODF

  3. 3 “Normal” ODF File • Package OpenDocument File ‒ Chapter

    3.1.3 of ODF 1.2 specifications ‒ Collection of xml files in a ZIP container ‒ <office:document-content> ‒ <office:document-styles> ‒ <office:document-meta> ‒ <office:document-settings> ‒ Images and OLE objects sub-streams in the ZIP container ‒ Referenced by xlink:href attribute
  4. 4 “Flat” ODF file • Single OpenDocument XML Files ‒

    Chapter 3.1.2 of the ODF 1.2 specifications ‒ Contains the whole document ‒ <office:document> root element ‒ office:mimetype and office:version attributes ‒ Images and OLE objects inlined ‒ <office:binary-data>[base64 data]</office:binary-data>
  5. 5 ZIP Storage (1) • Main entry point is the

    Central Directory End located at the end of the ZIP file. ‒ Scanning for it towards the end of the file ‒ Whole file must be present • Pointing at the Central Directory containing entries ‒ For name access, iterate over them ‒ Need to seek back to read the entry • Which contains pointer to Local File Header ‒ Seek to local file-header offset ‒ Need to seek back again ‒ The content of the stream comes after the header
  6. 6 ZIP Storage (2) FILE ENTRY 1 <data> FILE ENTRY

    2 <data> FILE ENTRY 3 <data> FILE ENTRY 4 <data> Local header 1 Local header 2 Local header 3 Local header n Relative offset 2 Relative offset 1 Relative offset 3 Relative offset n File entry 1 File entry 2 File entry 3 n CENTRAL DIRECTORY
  7. Advantages of Flat ODF

  8. 8 No Need for Special tools • No need for

    compression and stream extraction tools ‒ ODF documents can be generated manually ‒ Developer modifying a document ‒ XSLT tools ‒ Programmatic generation of documents ‒ Further processing of documents ‒ Easier parsing of document and extraction of relevant information
  9. 9 Sequential Access to File • Difference with ZIP file

    ‒ No need to know the end of the file to start to parse it • Exchange file-format par excellence ‒ Possibility to communicate document as SAX messages ‒ Communicate XML to an application sequentially ‒ Possibility to stream document over wire ‒ Collaboration protocol? ‒ Communication with CMS systems?
  10. 10 Storing documents in SCM • Package ODF file ‒

    Stored as binary file ‒ Impossibility to see reasonable diff to previous version • Simple XML ODF file ‒ A text file after all ‒ Difference are easily visible between revisions ‒ SCMs are designed to handle text files the best ‒ Example of LibreOffice templates ‒ Stored in git repository
  11. Examples of Flat ODF use

  12. 12 LibreOffice UNO Filter API • XSLT based filters ‒

    com.sun.star.comp.Writer.XMLOasisImporter ‒ pushes to LibreOffice flat ODT ‒ com.sun.star.comp.Calc.XMLOasisExporter ‒ receives from LibreOffice flat ODS • XML based filters ‒ com::sun::star::xml::sax::XDocumentHandler ‒ com.sun.star.document.ImportFilter pushes SAX messages to com::sun::star::xml::sax::XDocumentHandler ‒ com.sun.star.document.ExportFilter is itself a com::sun::star::xml::sax::XDocumentHandler and receives SAX messages from LibreOffice
  13. 13 File importers • Writerperfect ODT generator ‒ Libwpd –

    WordPerfect documents ‒ Generates ODT with embedded WPG files as <office:object> elements in flat ODG ‒ Libwps – Microsoft Works ‒ Generates ODT • Writerperfect ODG generator ‒ Libwpg – WordPerfect graphics ‒ Libvisio – Microsoft Visio diagrams ‒ Libcdr – CorelDraw drawings ‒ Libmspub – Microsoft Publisher publications ‒ Generate ODG documents
  14. Thank you. 14 Single XML OpenDocument representation is an important

    part of the ODF ecosystem
  15. Corporate Headquarters Maxfeldstrasse 5 90409 Nuremberg Germany +49 911 740

    53 0 (Worldwide) www.suse.com Join us on: www.opensuse.org 15
  16. Unpublished Work of SUSE. All Rights Reserved. This work is

    an unpublished work and contains confidential, proprietary and trade secret information of SUSE. Access to this work is restricted to SUSE employees who have a need to know to perform tasks within the scope of their assignments. No part of this work may be practiced, performed, copied, distributed, revised, modified, translated, abridged, condensed, expanded, collected, or adapted without the prior written consent of SUSE. Any use or exploitation of this work without authorization could subject the perpetrator to criminal and civil liability. General Disclaimer This document is not to be construed as a promise by any participating company to develop, deliver, or market a product. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. SUSE makes no representations or warranties with respect to the contents of this document, and specifically disclaims any express or implied warranties of merchantability or fitness for any particular purpose. The development, release, and timing of features or functionality described for SUSE products remains at the sole discretion of SUSE. Further, SUSE reserves the right to revise this document and to make changes to its content, at any time, without obligation to notify any person or entity of such revisions or changes. All SUSE marks referenced in this presentation are trademarks or registered trademarks of Novell, Inc. in the United States and other countries. All third-party trademarks are the property of their respective owners.