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

Mail merge embedding in LibreOffice Writer

Miklos V
January 30, 2016
170

Mail merge embedding in LibreOffice Writer

FOSDEM 2016, , Brussels

Miklos V

January 30, 2016
Tweet

Transcript

  1. Mail merge embedding
    in LibreOffice Writer
    By Miklos Vajna
    Software Engineer at Collabora Productivity
    2016-01-30
    @CollaboraOffice www.CollaboraOffice.com

    View full-size slide

  2. 2 / 19
    FOSDEM 2016, Brussels | Miklos Vajna
    About Miklos

    From Hungary

    More blurb: http://vmiklos.hu/

    Google Summer of Code 2010/2011

    Rewrite of the Writer RTF import/export

    Writer developer since Feb 2012

    Contractor at Collabora since Sept 2013

    View full-size slide

  3. Embedding a mail merge
    data source definition

    View full-size slide

  4. 4 / 19
    FOSDEM 2016, Brussels | Miklos Vajna
    Embedded objects

    Cross-platform for native data models

    Windows-only: OLE

    Bitmap (replacement image) + native data

    In Writer: text embedded object

    Part of the document body (anchored, etc.)

    View full-size slide

  5. 5 / 19
    FOSDEM 2016, Brussels | Miklos Vajna
    Mail merge
    data source definition

    Typical use-case:

    Real data source

    Base document (wrapper): data source
    definition

    Global inside LibreOffice

    Mail merge uses a data source from this list

    View full-size slide

  6. 6 / 19
    FOSDEM 2016, Brussels | Miklos Vajna
    Results #1

    Save your document template

    Tools → Mail Merge Wizard

    Select Address list → e.g. a .ods file

    Edit document

    View full-size slide

  7. 7 / 19
    FOSDEM 2016, Brussels | Miklos Vajna
    Results #2

    Insert mail merge fields

    Return to the wizard

    View full-size slide

  8. 8 / 19
    FOSDEM 2016, Brussels | Miklos Vajna
    Results #3

    Save merged document

    Save as single document

    Click on save document

    Close the merged result, no need to save

    View full-size slide

  9. 9 / 19
    FOSDEM 2016, Brussels | Miklos Vajna
    Results #4

    Embedded data source is registered

    Close the mail template

    Data source definition disappears

    View full-size slide

  10. 10 / 19
    FOSDEM 2016, Brussels | Miklos Vajna
    Results #5

    Open the mail template

    Embedded data source definition is
    registered again

    View full-size slide

  11. How is this
    implemented?

    View full-size slide

  12. 12 / 19
    FOSDEM 2016, Brussels | Miklos Vajna
    Embedding a Base document

    dbaccess::ODatabaseDocument

    Does not inherit from SfxBaseModel

    dbaccess::ODatabaseContext is the
    global manager

    No SwOLENode, just
    OCommonEmbeddedObject

    SwDBManager's
    StoreEmbeddedDataSource() is the
    implementation

    View full-size slide

  13. 13 / 19
    FOSDEM 2016, Brussels | Miklos Vajna
    ODF filter

    Newly handled parameters:

    TargetStorage

    StreamRelPath

    BaseURI

    dbaxml::ODBFilter is the importer

    dbaxml::ODBExport is the export

    loadFromStorage() not implemented,
    storeToStorage() needed fixing

    View full-size slide

  14. 14 / 19
    FOSDEM 2016, Brussels | Miklos Vajna
    Embedding
    without a text embedded object
    ● ODatabaseContext owns the doc model
    ● In ODF, settings.xml refers the storage of
    the XML streams
    ● It gets registered on load
    ● It gets removed on close

    View full-size slide

  15. 15 / 19
    FOSDEM 2016, Brussels | Miklos Vajna
    Mail merge wizard

    SwDBManager's
    LoadAndRegisterDataSource() does the
    creation

    The Writer document has to be saved, so
    it has a storage

    The embedded model then can be a sub-
    storage

    View full-size slide

  16. 16 / 19
    FOSDEM 2016, Brussels | Miklos Vajna
    Address book wizard

    Another user interface to create data
    source definitions

    Code in extensions/source/abpilot/

    View full-size slide

  17. 17 / 19
    FOSDEM 2016, Brussels | Miklos Vajna
    Relative references, testing

    Feature: relative references

    So .odt and .ods can travel together

    But ../ would refer to the non-embedded
    parent model

    Have to support even ../../

    If the parent doc moves → need to re-
    save the embedded doc

    SwUiWriterTest's
    testEmbeddedDataSource()

    View full-size slide

  18. 18 / 19
    FOSDEM 2016, Brussels | Miklos Vajna
    Thanks

    Collabora is an open source consulting
    company

    What we do and share with the community
    has to be paid by someone

    LHM sponsored this work

    View full-size slide

  19. 19 / 19
    FOSDEM 2016, Brussels | Miklos Vajna
    Summary
    ● Mail merge embedding allows mail merge
    with just two (ODT and e.g. ODS) documents
    ● Available in LibreOffice 5.1
    ● Improves experience for those who migrate from
    Microsoft Office
    ● One more long-standing problem solved
    ● Thanks for listening! :-)
    ● Slides: http://vmiklos.hu/odp

    View full-size slide