LibreOffice: Code Structure By Miklos Vajna Senior Software - - PowerPoint PPT Presentation

libreoffice code structure
SMART_READER_LITE
LIVE PREVIEW

LibreOffice: Code Structure By Miklos Vajna Senior Software - - PowerPoint PPT Presentation

LibreOffice: Code Structure By Miklos Vajna Senior Software Engineer at Collabora Productivity 2017-10-11 @CollaboraOffice www.CollaboraOffice.com About Miklos From Hungary More blurb: http://vmiklos.hu/ Google Summer of Code


slide-1
SLIDE 1

LibreOffice: Code Structure

By Miklos Vajna

Senior Software Engineer at Collabora Productivity 2017-10-11 @CollaboraOffice www.CollaboraOffice.com

slide-2
SLIDE 2

2 / 30 LibreOffice Conference 2017, Rome | 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 2012
  • Contractor at Collabora since 2013
slide-3
SLIDE 3

3 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

Thanks

  • This is an updated version of Michael

Meeks’ talk from last year

slide-4
SLIDE 4

4 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

Overview

  • Code-base overview
  • Internal core modules, internal leaf
  • Ignoring externals
  • Building / packaging: gnumake, scp2
  • Code organisation, git bits
  • Keep in mind: this is a 20 years old code-base
  • The quality is much better than you would expect after

knowing its age

  • Things continue to improve over time
slide-5
SLIDE 5

Module overview lowest level

slide-6
SLIDE 6

6 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

Internal non-leaf modules: UNO modules

  • Module = toplevel dir
  • m

a k e d u m p s

  • d

e p s

  • p

n g

  • Each module has a README
  • e.g. sal/README
  • sal: at the bottom
  • The system abstraction layer
  • tools is an obsolete internal (more or

less) duplication of this

  • salhelper: wrapper code around sal,

also part of the URE

slide-7
SLIDE 7

7 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

What is the Uno Runtime Environment (URE)?

URE

  • We’ll come to UNO in detail a bit later,

but for now:

  • Uno Runtime Environment
  • See also JRE, Java Runtime Env.
  • Belongs to the idea that UNO would be

reused somewhere else

  • Provides an API/ABI-stable abstraction

layer for the suite

  • Allows writing C++ extensions
  • Modify carefully:
  • Should not change the ABI
  • ABI control via C .map fjles
slide-8
SLIDE 8

8 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

UNO modules

  • store: legacy .rdb format
  • registry: UNO type regisistry
  • unoidl: a .idl fjle compiler
  • cppu: C++ UNO
  • Implements basic UNO types and

infrastructure for C++, e.g. WeakImplHelper

  • xmlreader: very simple XML pull parser
  • cppuhelper: boostraps UNO,

createInstance() implementation leaves here

slide-9
SLIDE 9

9 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

More related modules

  • ucbhelper: Universal Content

Broker, a Virtual File System abstraction

  • i18nlangtag: handles BCP47, a

powerful way to represent languages/locales

  • jvmfwk: glue layer between Java

and UNO

  • comphelper: lots of good C++

stuff, intentionally not part of the URE

slide-10
SLIDE 10

Module overview middle level

slide-11
SLIDE 11

11 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

Internal related modules

  • basegfx: algorithms and

graphic types for basic graphics

  • tools: more basic types
  • SvStream: internal stream type

– Equivalent of UCB / sal fjle

pieces

  • Color: e.g. COL_RED
  • INetURLObject: URL handling
  • SolarMutex (the big LO lock)
  • Polygon / Polypolygon
  • Date / time classes
slide-12
SLIDE 12

12 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

Unit testing modules

  • cppunit: all of our C++ tests are

CppUnit tests (external module)

  • unotest: bootstraps UNO, so

components can be tested

  • types, services, confjguration is

available

  • test: non-UNO part of test setup:

VCL, UCB, etc.

  • CppUnit_*.mk fjles in the

modules

slide-13
SLIDE 13

13 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

Other non-graphical modules

  • i18nutil: C++ wrapper around

low-level UNO interfaces

  • unotools:
  • XStream

SvStream conversion ↔

  • boost::gettext wrapper
  • sot: OLE2 binary storage

implementation

  • svl: non-graphical parts, which

were in svx/sfx2 earlier

  • SfxItemSet: an id-any map
  • undo/redo
  • crypto pieces
slide-14
SLIDE 14

14 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

Graphical / toolkit modules

  • vcl: Visual Class Libraries, the

LibreOffjce graphical toolkit

  • toolkit: UNO API wrapper around vcl
  • canvas: rendering UNO API that

supports alpha and anti-aliasing, used by slideshow

  • DirectX, Cairo and VCL backends
  • cppcanvas: wrapper around the UNO

API

  • emfjo, svgio: drawinglayer-based

EMF/SVG import

slide-15
SLIDE 15

15 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

Non-graphical modules

  • basic: StarBasic interpreter
  • xmlscript: Basic dialog

loader/serializer

  • connectvity: database

drivers

  • pgsql, mysql, address books,

jdbc, odbc, Calc/Writer

  • sax: libxml2 wrapper,

provides the fast parser (a SAX API)

slide-16
SLIDE 16

16 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

Graphical modules

  • svtools:
  • Tree / list VCL widgets
  • Table widget
  • Dialog helpers (e.g. closing

listener)

  • Accessibility helpers (e.g.

accessible ruler)

  • confjgmgr wrappers
  • Printing options
  • Image map handling
  • Wizard framework
slide-17
SLIDE 17

Module overview Upper level

slide-18
SLIDE 18

18 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

Document / frame modules

  • framework: docking,

toolbars, menus, status bar, sidebars, task panes

  • sfx2: core of the app
  • SfxMedium: load / save

logic

  • Object / view

management

  • Dialog helpers: tab pages
  • Document meta-data

dialogs

  • Template management
  • Shared style code
slide-19
SLIDE 19

19 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

Other document modules

  • formula: shared code

between sc and reportdesign

  • avmedia: video playing
  • linguistic: spellchecker,

hyphenating

  • xmlsecurity:

ODF/OOXML/PDF signing

  • vbahelper: code on top of

basic for MSO VBA interop

slide-20
SLIDE 20

20 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

Load / save (fjlter) logic

  • package: ZIP fjle handling
  • xmloff: shared ODF fjlter

code

  • fjlter: fjlter confjguration
  • Also: fmat ODF, shared

binary MSO support, etc.

  • oox: shared OOXML

support:

  • VML, drawingML
slide-21
SLIDE 21

21 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

Applications

  • desktop: StarDesktop
  • main() lives here
  • sd: StarDraw (Draw,

Impress)

  • drawings,

presentations

  • sw: StarWriter
  • Word processor
  • sc: StarCalc
  • Spreadsheet
slide-22
SLIDE 22

22 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

This is a simplifjed picture

  • These all were non-leaf nodes
  • This is a linking dependency graph
  • UNO is a great dependency breaking tool
  • Modules still missed:
  • cui: Common User Interface, common dialogs
  • chart2: charting support
  • slideshow: the piece that renders your Impress slideshow
  • solenv: build infrastructure
slide-23
SLIDE 23

Building, packaging

slide-24
SLIDE 24

24 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

Build: confjgure and compile

  • autoconf / confjgure – pretty standard
  • autogen.sh – a wrapper around autotools
  • Builds & runs the confjgure script
  • Keep your parameters in autogen.input
  • Builds:

– confjg_host.mk from confjg_host.mk.in, contains all

the environment variables

– confjg_host/*.h, C++ headers

slide-25
SLIDE 25

25 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

Android and Online build

  • Android
  • Inside core.git, confjgure with --with-

distro=LibreOffjceAndroid

  • See android/README
  • Resulting .apk fjle under android/.
  • Online
  • Uses autotools, in separate online.git
  • Link to core.git: --with-lo-path
slide-26
SLIDE 26

26 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

Build: gnumake

  • Gnumake is used in creative ways
  • Code is in solenv/gbuild/
  • Each module has its own Makefjle

– You can build each independently after a full build – All rules are built by $(call Function,…) magic, we don’t use

any of the build-in rules

– If something is compiled, we have an explicit rule for it

somewhere, you can fjnd it

  • Following the rules is expensive due to non-

named function parameters ($(1), $(7))

slide-27
SLIDE 27

27 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

Build: output

  • We build an installation set in instdir/
  • instdir/program
  • Contains something you can run in-place
  • make && instdir/program/soffjce – it works
  • workdir/
  • Object fjles, build intermediates here
  • Generated headers
  • Unpacked external source code
  • So make clean can just remove instdir/workdir
slide-28
SLIDE 28

28 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

Build-related modules

  • Postprocess
  • Packimages

– Using solenv/bin/pack_images.py – build icon theme .zip and

sort it by access pattern

  • CustomTarget_registry.mk

– Builds confjguration fjles from offjcecfg/.

  • Rdb_services.mk

– Builds services.rdb fjle .component fjles

  • Offjcecfg/
  • Home of all defaults / offjce confjguration / settings
slide-29
SLIDE 29

29 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

Internal module organization

  • include/
  • All global includes live in include/<module>/
  • e.g. sfx2/inc/ – these are includes local to a module
  • sfx2/source/ – source code for the module
  • uiconfjg/ – UI descriptions (dialogs, toolbars, menus)
  • sdi/ – descriptions of slots / actions (UNO commands)
  • qa/ – unit tests, test fjle data, etc.
  • Lots of things moved over time:
  • git log -u --follow is your friend
slide-30
SLIDE 30

30 / 30 LibreOffice Conference 2017, Rome | Miklos Vajna

Summary

  • This was very high-level
  • Intentionally, so you can get the big picture
  • Hopefully still useful
  • We have a lot of modules
  • You can safely not know about the majority of

them.

  • Slides: https://vmiklos.hu/odp