5 Feb 2023

QR code improvement – LibreOffice EasyHack

A QR code is a type of 2D barcode that is useful for encoding data, such as a URL, contact information and many other data types. One can scan the code via applications on mobile phones to capture a URL or import contact information.

For example, the code below encodes the address of the LibreOffice website:

Encoding LibreOffice website URL with QR code

Encoding LibreOffice website’s URL in a QR code

Generating QR Codes in LibreOffice

In LibreOffice, it is possible to create different barcodes, either 1D or 2D, via extensions, or LibreOffice’s internal functionality.

QR code dialog

QR code dialog

For QR codes, it is possible to use the internal functionality via Insert > OLE Object > QR and Barcode:

The implementation in LibreOffice is using ZXing QR code library:

If you take a look at the source code in cui/source/dialogs/QrCodeGenDialog.cxx, there is ConvertToSVGFormat() function which creates the SVG output. In the recent versions of ZXing library (we use v1.4 right now), there is a function that does that, ZXing::ToSVG(). The task here is to replace the our function with the one from ZXing library.

Handling Different Library Versions

Unfortunately, only recent versions of ZXing provide ZXing::ToSVG() functions. It is not available in 1.3, but is added in 1.4. Looking into the packaging of the library in different distributions, it becomes obvious that this package version is not available yet in many distributions:

Therefore, a solution should check the ZXing library version, and use the new function if the library version is >= 1.4. In other words, limiting the change to where the new version of the library is present is necessary. This is possible using compiler conditionals. It is important where one configures the LibreOffice compilation to use system provided ZXing library, using --with-system-zxing while invoking autogen.sh.

Final Notes

EasyHacks are good starting points for someone who wants to get started in LibreOffice development. This specific issue for improving QR code is filed as tdf#153328 in TDF’s Bugzilla. To understand how to get started with LibreOffice development, you can refer to our getting involved page in the TDF Wiki, or our video tutorial for getting started with LibreOffice development.

28 Jan 2023

VCL example applications and tools

You may already know that LibreOffice uses its internal GUI toolkit, named VCL (Visual Class Library). This library is responsible for creating the GUI widgets for LibreOffice, providing abstraction from the operating system including the basic rendering. To see more details, you can read its documentation page:

VCL has the nice feature of being able to work with different GUI libraries on different platforms. For example, if you are on Linux, you can use X11, Gtk3/4, Qt, or KDE back-ends for the VCL applications like LibreOffice. You can easily switch between them by using the environment variable SAL_USE_VCLPLUGIN. For example, you can use the old style X11 GUI in this way:

SAL_USE_VCLPLUGIN=gen instdir/program/soffice

Or, by passing it to the LibreOffice program itself:

instdir/program/soffice -env:SAL_USE_VCLPLUGIN=gen

In addition, there are other GUI backends, or plugins which are as follows:

UI Plugin UI Backend
qt5 Qt 5
qt6 Qt 6
kf5 KDE KF5
gtk3 GTK 3
gtk4 GTK 4
gtk3_kde5 GTK 3 KDE 5
win Windows UI (Windows only)
osx macOS X UI (macOS only)

You can read more about the related environment variables here:

The code for the library is available in the vcl/ folder inside core source code. Also, beside the main source code and tests, there is a folder named workbench. Inside this folder, you can find several standalone VCL applications:

VCL Applications and Workbenches

vcldemo: This is a showcase of some of the VCL rendering abilities including the lines, shapes, internationalized text, pictures and more! You can see run this demo by invoking this command, after you could be able to build LibreOffice:

./bin/run vcldemo
vcldemo vcl application


minvcl: This is possibly one of the smallest example application that can be created with VCL. Basically, It creates a window and draws a simple text inside it. Likewise, you can run it by invoking:

./bin/run minvcl
minvcl vcl application


Image Tools

icontest: This bitmap image testing is used by some of the developers to test VCL bitmap rendering capabilities. It can be invoked this way:

./bin/run icontest <image>

mtfdemo: This is a small application for displaying and dumping the structure of EMF/EMF+/WMF files, which is a vector image format from Microsoft. This is previously discussed in another blog post here:

Similarly, it can be run in this way:

./bin/run mtfdemo <emf|wmf image>

Font Tools

listfonts: This utility lists the current list of fonts installed in the system, and the features of each font. To display the information on the screen, you can invoke it this way:

./bin/run listfonts --

listglyphs: This utility lists the current glyphs in a font that is already installed on the system. You should provide the font name to it, in this way:

./bin/run listglyphs FreeMono --

VCL Fuzzers and Platform Specific Tools

Beyond the above applications and tools, there are many other platform specific tools that are not available on each and every platform. Also, there are many fuzzers ans testing tools that are helpful for fuzz-testing the library. You can find the complete list of executables using this command:

ls vcl/Executable_*.mk

As can be seen in the output, many of them are fuzzers. To use the fuzzers, first you have to setup the oss-fuzz via ./bin/oss-fuzz-setup.sh script. Then, you may be able to build the fuzzers using ./bin/oss-fuzz-build.sh script. Make sure that you have $OUT, $SRC and $WORK environment variables to set the fuzzer build environment. Be ready for several tarballs and archives downloads at first. You will need curl and svn to continue.

Final Notes

These tools and small applications and their source code are good for testing and getting to understand the VCL library better. As a suggestion, you can start from the minvcl.cxx to understand how to create a GUI application that can work across various platforms with different GUI toolkits. Hopefully, I will discuss the source code of some of these examples in the later blog posts.

13 Jan 2023

String types in LibreOffice C/C++ code – part 1

Strings are very important types of data that are using in LibreOffice. Firstly, they are useful for storing textual data, and is essentially a sequence of characters. As LibreOffice has many modules that depend on various libraries and languages, there are different string types in LibreOffice. Here, we discuss some of them. (more…)

3 Jan 2023

Happy new year 2023!

Happy new year 2023! I wish a great year for you, and the global LibreOffice community.

Here I breifely discuss the year 2022 around the development blog, and the outlook for 2023.

In 2022, I wrote 22 posts around LibreOffice development in this blog. (Some of them are drafts which are not yet published). I hope that my published posts were useful for you to undertsand LibreOffice code better, and to get involved in LibreOffice core development.

At The Document Foundation (TDF), our aim is to improve LibreOffice, the leading free/open source office software that you and many other people around the world use. Our work is community-driven, and we need your help.

Happy new year to the LibreOffice community

Happy new year to the LibreOffice community

These are some the topics I want to discuss in 2023:

  1. Various data types in LibreOffice
  2. LibreOffice build system (gbuild)
  3. New EasyHacks
  4. Fixing crashes
  5. Creating user interfaces with VCL
  6. LibreOffice core development guide
  7. SDK development guide

I will be happy if you provide feedback to me in a comment here, or via email. You can email me using hossein AT libreoffice DOT org.

As you may know, I provide mentoring to those who want to start LibreOffice development. You can contact me if you need help via the above email address.

Have a great time!

21 Dec 2022

UNO Data types in code and API

alsVarious data types are used in LibreOffice code and also in LibreOffice API. Here we discuss some of these data types, which are important when you are working with LibreOffice code and API. (more…)

3 Dec 2022

gbuild: LibreOffice build system – part 1

LibreOffice uses a build system called gbuild which uses GNU Make. Migrating from the old build system to gbuild started in the OpenOffice days, but the migration took a while and a lot of effort, finishing around LibreOffice 4.1. (more…)

17 Nov 2022

Formatting the code in your patch for LibreOffice

Do you want to submit a patch to LibreOffice Gerrit, and you’re wondering if your code will be accepted or not? Other than providing a good solution to resolve a problem (fix a bug, implement a feature or enhancement), you should care about the code conventions, and in particular, code formatting. Suitable code formatting for LibreOffice is what we discuss here. (more…)

3 Nov 2022

Crash fixes, part 2: abort

One category of the bugs that we see in computer programs including LibreOffice is the unexpected crashes. You’re working with the application, and it is suddenly closed! In the previous part, I have discussed crashes that are caused by segmentation fault. In this article, I discuss the crashes from invoking abort() function. Please note that not an abort is not always a bad thing, or a bug. (more…)

24 Oct 2022

Crashes that you can fix! – EasyHack

As discussed in the “crash fixes for LibreOffice, part 1: segfaults“, bugs that lead to crash in LibreOffice or other native applications can have different causes, and therefore need completely different fixes. Some of these bugs are hard to fix: you have to change the behavior of the application in order to avoid crashes. (more…)

6 Sep 2022

Crash fixes, part 1: segfaults

One of the bugs that we see in computer programs including LibreOffice is the crash. You’re working with the application, and the program is suddenly closed! Here we discuss the usual causes for these crashes, and how to fix some of them. (more…)