Mail merge embedding in LibreOffice Writer By Miklos Vajna Software Engineer at Collabora Productivity 2016-01-30 @CollaboraOffice www.CollaboraOffice.com
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 FOSDEM 2016, Brussels | Miklos Vajna 2 / 19
Embedding a mail merge data source definition
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.) FOSDEM 2016, Brussels | Miklos Vajna 4 / 19
Mail merge data source defjnition ● Typical use-case: ● Real data source ● Base document (wrapper): data source definition ● Global inside LibreOffice ● Mail merge uses a data source from this list FOSDEM 2016, Brussels | Miklos Vajna 5 / 19
Results #1 ● Save your document template ● Tools → Mail Merge Wizard ● Select Address list → e.g. a .ods file ● Edit document FOSDEM 2016, Brussels | Miklos Vajna 6 / 19
Results #2 ● Insert mail merge fields ● Return to the wizard FOSDEM 2016, Brussels | Miklos Vajna 7 / 19
Results #3 ● Save merged document ● Save as single document ● Click on save document ● Close the merged result, no need to save FOSDEM 2016, Brussels | Miklos Vajna 8 / 19
Results #4 ● Embedded data source is registered ● Close the mail template ● Data source definition disappears FOSDEM 2016, Brussels | Miklos Vajna 9 / 19
Results #5 ● Open the mail template ● Embedded data source definition is registered again FOSDEM 2016, Brussels | Miklos Vajna 10 / 19
How is this implemented?
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 FOSDEM 2016, Brussels | Miklos Vajna 12 / 19
ODF fjlter ● Newly handled parameters: ● TargetStorage ● StreamRelPath ● BaseURI ● dbaxml::ODBFilter is the importer ● dbaxml::ODBExport is the export ● loadFromStorage() not implemented, storeToStorage() needed fixing FOSDEM 2016, Brussels | Miklos Vajna 13 / 19
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 FOSDEM 2016, Brussels | Miklos Vajna 14 / 19
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 FOSDEM 2016, Brussels | Miklos Vajna 15 / 19
Address book wizard ● Another user interface to create data source definitions ● Code in extensions/source/abpilot/ FOSDEM 2016, Brussels | Miklos Vajna 16 / 19
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() FOSDEM 2016, Brussels | Miklos Vajna 17 / 19
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 FOSDEM 2016, Brussels | Miklos Vajna 18 / 19
Summary ● Mail merge embedding allows mail merge with just two (ODT and e.g. ODS) documents ● Available in LibreOffjce 5.1 ● Improves experience for those who migrate from Microsoft Offjce ● One more long-standing problem solved ● Thanks for listening! :-) ● Slides: http://vmiklos.hu/odp FOSDEM 2016, Brussels | Miklos Vajna 19 / 19
Recommend
More recommend