Exploring the LibreOffice code base

http://www.flickr.com/photos/marine_corps/9717971226/sizes/z/in/photostream/

Opening LibreOffice’s source code for the first time, the amount of code that a new developer has to sift through can be intimidating and off-putting. So, here are some useful locations within the LibreOffice source directory structure that should help get you started.

General layout

LibreOffice consists of over a hundred interdependent modules, each contained within a subdirectory of the LibreOffice root directory. Please note that all paths hereafter are relative to this directory, unless otherwise specified. The layout of a module tends to follow a general pattern, with at least the following places of interest:

moduledir/README
Usually contains useful information about the module purpose and contents. A list of all modules and the first line of their README can be found at docs.libreoffice.org.
moduledir/*.mk
gbuild makefiles for various build possibilities.
moduledir/source/
Source code (usually C++). There is often some sort of division of code into submodules.

Headers

Headers may be found in several places, depending on the minimum required scope of the interface defined.

include/
Inter-module headers.
moduledir/inc/
Intra-module headers.
moduledir/source/submoduledir/inc/
Headers required only by a submodule.

Headers may also occasionally be found alongside their .cxx implementations.

UI

For modules where a GUI is relevent, there are two main possibilities. Work on converting the user interface specifications from the older, inflexible legacy format (.src/.hrc) to the xml-based Glade/Gtk3 format (.ui) is currently underway throughout the codebase.

moduledir/uiconfig/
New, Glade-style .ui files.
moduledir/source/ui/
Older .src files.

Build system

There’s an informative slide deck from the 2013 LibreOffice conference in Milan that discusses state of the LibreOffice build system. While you will find a brief overview below, this presentation goes into far more detail if that is what’s required.

solenv/
Contains many important parts of the build system.
solenv/gbuild
gbuild implementation.
solenv/bin ; solenv/bin/modules/
Perl build and packaging tools.
scp2/
Configuration of packinging and installation.

Once LibreOffice has been built using ./autogen.sh followed by make, a complete runnable installation can be found in:

instdir/program/

There, soffice.bin and soffice can be found. The former is the main LibreOffice binary. On the first run, it creates the user profile and exits and can then be executed again as normal. To avoid this, the wrapper soffice should be used for running LibreOffice for testing purposes. When running LibreOffice via a debugger, soffice.bin should be used directly.

Main components

LibreOffice Writer

Due to LibreOffice’s history as a product of Sun’s StarDivision, the main application component paths contain hints toward this legacy. The Writer module, for example, is contained within the directory sw/ (StarWriter).

sw/
Main Writer module.
starmath/
The mathematical formula editor.
swext/
Shipped Writer extensions.

LibreOffice Calc

sc/
Main Calc code.
chart2/
Implementation of charts for Calc.

LibreOffice Draw (and LibreOffice Impress)

sd/
Draw and Impress share a module and quite a bit of code here.
sdext/
Extensions for Draw and Impress.

LibreOffice Impress only

slideshow/
Slideshow engine for Impress.

Graphics modules

svx/
Contains graphics helper code shared by several major modules, but especially Draw and Impress.
drawinglayer/
Provides an API for drawing objects.

Documents

sfx2/
Contains the framework used by sw, sc and sd to dispatch actions to the document shells. This module includes document load and save handling, which invokes the correct import and export filters, respectively.
writerfilter/
Writer .rtf import filter and part of the .docx import filter.
writerperfect/
A family of Writer import filters including WordPerfect, Microsoft Publisher and Microsft Visio file format import filters.
oox/
Suppport for parsing Microsoft’s OOXML format (.docx, .xlsx, etc.)

Hopefully you’ll now have an idea of where to get started if you want to tackle a bug or feature in LibreOffice. For more help and resources, see my LibreOffice Development Howto or, if you want professional support, don’t hesitate to contact us.

Share on Google+Tweet about this on TwitterShare on LinkedInShare on FacebookFlattr the authorBuffer this pageShare on RedditDigg thisPin on PinterestShare on StumbleUponShare on TumblrEmail this to someone

Eilidh McAdam is a programmer from Scotland who works on open source project LibreOffice. She also enjoys coding for fun, reading, music and writing. Eilidh got involved with the open source community through the Google Summer of Code program several years ago (libvisio – reading .vsd files produced by Microsoft Visio and importing them into LibreOffice Draw). Eilidh enjoys learning new languages and paradigms. You can contact Eilidh and her team for professional consulting on our contact page.

Posted in Blog, Development, LibreOffice Tagged with: ,
One comment on “Exploring the LibreOffice code base
  1. Rohan Kumar says:

    Thanks a lot, it was extremely helpful. It is much more helpful as compared to the module diagram that is present on the libre wiki website

Leave a Reply

Your email address will not be published. Required fields are marked *

*