Image handling rework for LibreOffice – Collabora’s tender results

Donations to The Document Foundation are used for many purposes, such as organising events, maintaining our infrastructure, and paying a small team to handle QA, marketing, documentation and other tasks. But donations are also used to fund tenders, whereby companies and individuals improve LibreOffice in specific areas and share knowledge with the community.

One such tender was posted in May 2017: “improve image handling in LibreOffice (#201705-01)“. When images are used in LibreOffice documents, the software manages them in a “life-cycle” which includes importing, displaying, modifying, exporting and more. To save memory – especially with large documents – images that are not currently on screen are sometimes moved out of memory and saved onto disk in a technique known as “swapping” or “paging”. The goal of the tender was to improve LibreOffice in these areas, making it more efficient at handling images and modernising the code base.

Collabora was selected to implement the tender; the work is now complete, and it will benefit all users in the upcoming LibreOffice 6.1 (due to be released in early August). Here are some technical notes about what was improved in the source code of LibreOffice, and what was achieved.

Problems with the image life-cycle

Currently, when an image is read from a document, a GraphicObject is created for the image and handled over to the GraphicManager which manages the life-cycle. When this happens we usually get back the string based unique ID of the GraphicObject with which we can always get access the image by creating a new GraphicObject with the unique ID (GraphicManager will look for the image with that unique ID).

Usually the unique ID is the one that is passed on between layers in LibreOffice (for example, from the ODF filter when loaded, to the model, where it is manipulated and then to the OOXML filter when saving) but the unique ID itself is just a “reference” to the image and by itself it doesn’t have any control over when the image can safely be removed and when not. It could happen that in a certain situation we would still have the unique ID referenced somewhere in the model, but the image would already be removed. This is dangerous and needs to be changed.

Usually for this kind of object we use a reference counting technique, where we pass an object around that holds a reference to the object resource. When the object is created, the reference count is increased; when destroyed, the reference count is decreased; when the reference count reaches zero, the resource object is destroyed.

The solution for the life-cycle

So instead of passing around a unique ID, the idea is to use the usual reference counting technique, which is normally used in this situation. The GraphicObject is mainly a wrapper around Graphic (which then holds a pixel-based image, or animated image, or possibly a vector image), and in addition it keeps additional attributes (gamma, crop, transparency etc.). It also has the implementation of swapping-in and out.

On the other hand, Graphic is properly reference-counted already (Graphic objects are reference counting the private ImpGraphic) so the solution to the life-cycle problem is that instead of GraphicObject unique ID, we would just pass along the Graphic object instead, or XGraphic, XBitmap which are just UNO wrappers around Graphic. Potentially we could also pass along the GraphicObject or XGraphicObject (UNO wrapper for the GraphicObject) when we would need to take into account the graphic attributes too. This should make the life-cycle much more manageable.

GraphicObject refactoring

GraphicObject and the implementation of XGraphicObject (UnoGraphicObject) and XGraphic (UnoGraphic) were located in module svtools, which is hierarchically above vcl. This is problematic when creating new instances like in Graphic.GetXGraphic method, which needs to bend backward to make it even work (ugly hack by sending the pointer value as URL string to GraphicProvider). The solution to this is to move all GraphicObject related things to vcl, which surprisingly didn’t cause a lot problem and once done, it looks like a much more “natural” place.

Managing memory used by images

Previously, the memory managing was done on the level of GraphicObjects, where a GraphicManager and Graphic-Cache were responsible to create new instances from uniqueID and manage the memory usage that GraphicObject take. Here’s the hierarchy before refactoring:

This is not possible anymore as we don’t operate with uniqueIDs anymore, but always use Graphic and XGraphic objects (in UNO), so we need to manage the creation of Graphic object or more precisely – ImpGraphic (Graphic objects are just reference-counted objects of ImpGraphic).

So to make this possible GraphicManager and GraphicCache need to be decoupled and removed from GraphicObject and a new manager needs to be introduced between Graphic and ImpGraphic, where the manager controls the creation and accounts for the memory usage:

Graphic swapping and swapping strategy

The new swapping strategy is relatively simple – if a lot of memory is needed by graphic objects in a certain time, we let it use it and don’t try to over-aggressively try to free it. In the past this cased swap-out and swap-in cycle that made the application completely unusable. In the future, external hints when a certain Graphic object can be swapped out may be added, so we can perform swapping more effectively. There are also several other ideas which will increase performance and reduce memory usage that can be implemented now with the new hierarchy where most all of the swapping is contained inside the Graphic itself, but all of this is currently out of the scope of this work.

In conclusion

Thanks to Collabora and Tomaž Vajngerl for their work on this. Although the details are highly technical, the end result is a faster and more robust office suite. If you’re an end user of LibreOffice and your documents include lots of images, you will be able to enjoy the benefits of this work in future releases, starting with LibreOffice 6.1.

Simplicity and flexibility: choose the right LibreOffice interface for you

With free and open source software, you get back control – over your software, your data, and your computer as a whole. And in the LibreOffice community, we strive to create the best user experience, but we also recognise that different users have different requirements.

To this end, LibreOffice includes three main user interface designs, accessible via View > Toolbar Layout in the menu. Let’s go through them…

The first layout, Default, is what you see when you first install LibreOffice:

It’s a familiar layout with two toolbars containing various buttons. (Note that you can customise and add buttons to the toolbars if desired.)

Then there is the single mode, which opts for simplicity and minimalism, giving you more screen space to really focus on your content:

And finally, the third option is the sidebar, which uses horizontal space to provide buttons and options for your work:

So LibreOffice gives you the freedom and flexibility to choose the right interface for you. But we’re not finished yet! Our design community is working on the Notebookbar, another (optional) user interface:

It’s still experimental, but you can try it out and help us to improve it, so that we can polish it up and include it in future releases! Join our design community to provide feedback – and thank you!

Posting stickers for the Month of LibreOffice – don’t forget to claims yours!

Currently we’re posting out the sticker packs for the Month of LibreOffice. Did you contribute to the project in May 2018, and your name (or username) is on this page?

If so, and you haven’t contacted us yet, email mike.saunders@documentfoundation.org with your name (or username) from the wiki page, along with your postal address, and we’ll send you a bunch of stickers for your laptop, PC and other devices!

(Note: we will only use your postal address to send the stickers. No data will be transferred to third parties, and your address will be deleted as soon as the stickers are posted.)

LibreOffice interview: Andreas Kainz talks about new icons and the Notebookbar

Andreas Kainz

LibreOffice’s design community works on improving the user interface of the software. Today we talk to Andreas Kainz, who has created new icon themes and made improvements to the Notebookbar, an experimental and alternative user interface layout that will become an option in future releases…

Tell us a bit about yourself!

I live in Vienna, Austria. I have a KDE and LibreOffice-related blog, and a new one only for LibreOffice things, because I started by contributing to KDE, but in the last few years have been doing more and more with LibreOffice.

What have you been working on recently?

Here are some of the changes:

  • New default table styles for LibreOffice 6.0:

  • New area fill gradients for LibreOffice 6.1

And then, in terms of icons:

  • Colibre icon theme (for LibreOffice 6.1). Here’s what it looks like, with the Notebookbar activated:

All icon themes are available in PNG and SVG formats, under a GPL conforming licence, and I also maintain all three icon themes (Elementary, Colibre and Breeze – see below).

Regarding the Notebookbar, I have worked on the groupedbar full and compact, and the tabbedbar full and compact. I think that the Notebookbar is a great (optional) addition to the default toolbars and the sidebar.

(If you’re using LibreOffice 6.0 or 5.4, you can try the Notebookbar by following these steps. Please note that it’s still an experimental feature, though, and not ready for production use! But we’d like to hear your feedback.)

How much time do you spend contributing to LibreOffice?

I contribute in my spare time, between 23:00 – 01:00, when my daughter and wife are sleeping. Since 2014 I have submited 412 commits and 893,810 addition to LibreOffice core, which mean that I’m in second place in terms of additions (see the stats here – my username is DarkknightAK).

How did you get involved with LibreOffice?

I’m the maintainer of the Breeze icons for KDE, and in 2014 the LibreOffice community asked if the Breeze icons could be available for LibreOffice. Four months later, 2,500 breeze icons had been drawn and Breeze become default in LibreOffice 5 for KDE, Unity, macOS and LibreOffice Online. Here’s what Breeze looks like:

What was your initial experience of contributing to LibreOffice like?

LibreOffice is a friendly and structured project. With Gerrit and Jenkins it’s easy to have a good review process, when you’d like to submit a patch.

What does LibreOffice need most right now?

Contributors are always welcome. It would be awesome to have some goals where a team of developers AND designers work on them.

What tools do you use?

Inkscape and Kate.

Anything else you want to mention?

If you like my work, read my blog posts, join the LibreOffice design IRC channel (#libreoffice-design) or become a Patreon.

A big thanks to Andreas for his great work. As mentioned, LibreOffice users can try out the Notebookbar today, and give feedback to our design community, so that we can improve it further and make it available as a standard (optional) feature in the future!

Month of LibreOffice, May 2018: A look at the numbers

Last week, the Month of LibreOffice, May 2018 came to a close – and 336 stickers were awarded! You can read more about the results here, and today we’ll take a closer look at the numbers.

But first, we want to say a special thanks to the following people who took part during May, but weren’t in the lists during last year’s Months of LibreOffice. Welcome to the project (or welcome back if you’ve been away for a while), and a huge thanks for all your help:

Abhyudaya Sharma, Anass Ahmed, Andrew Watson, Angelos Skembris, Angermuller Hubert, Anil Kumar Shrestha, Anton Shevtsov, arindam, baffclan, Balint Fodor, bblack4jc, bertrandgajac, Brian Barker, carnish, cesar.rickinho, Charles Valente, ChenyHsu, Christian Preuß, DaeHyun Sung, Dan Lewis, Daniel Silva, David, david.vantyghem@free.fr, daviding, Denis J Navas, Derek Keats, Ding Duck, Dipesh Kumar, Drew, Drew Jensen, ebot, Eddie, eglejasu, Ekansh Jha, Elizabeth Contreras, Emersson Augusto Suarez Ortiz, EricBright, Fito, ge60, geraldg@libreoffice.org, Gerhard Weydt, gho87, Girvin Herr, himajin100000, hjek, Hrbrgr, Hussam Al-Tayeb, Ilhan Yesil, impreza233, Jean-Francois Nifenecker, Jihui Choi, jimrussell98116@gmail.com, Joachim Jacob, Joao Farias, Johannes Kingma, jomali, Jonathan Fisher, Juan C. Sanz, Kacper Kasper, Keith Curtis, kiloran, konsultor, Lamamane, Lant, Laurent BP, Leo442, Liberty Belle, Lorenzo Chiola, Luca Daghino, Luis, Luuk, merzouk.ouchene, Nikola, nobody_special, oldgoatroper, oleg.tolmatcev@gmail.com, OSS-user, PaulaO, Pheeble, Philip Jackson, Prajwol Lamichhane, Pratit Raj Giri, Regis Perdreau, Remy Gauthier, Rene Engelhard, René Leyva, Ricardo Berlasso, rir, Robert Großkopf, Roy Reese, Rraj_Gautam, Salim Habchi, scott092707@aol.com, Selim Ozcan, Sergio bh, serval2412, slimane.amiri, sludge7051-x, SteenRønnow, subedimonika, sukho, surbun@hotmail.com, Sveinn í Felli, Séamas Ó Brógáin, Takeshi Abe, Thomas Woltjer, Tim Lloyd, toki, Tom Davies, Tomáš Chvátal, Ujwal, ve3oat, Virgil Arrington, Xoristzatziki, Yauhen Kharuzhy, Ysabeau, zahra a, Zdeněk Crhonek, _dave, निराजन पन्त, सन्जोग सिग्देल

We hope you had fun in the Month of LibreOffice, and look forward to your future contributions! Oh, and if you haven’t seen it yet, here’s a video just for you:

Please confirm that you want to play a YouTube video. By accepting, you will be accessing content from YouTube, a service provided by an external third party.

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.

Where do the numbers come from?

If you look at the wiki page listing the stickers that were awarded, you can see that they are split into several categories. We use various tools and data sources to gather the names (and usernames), but if we’ve missed someone, let us know! Here’s a bit more background on the various sub-projects:

  • Contributing code patches: – For this, we use our Gerrit installation. Note that we are tracking contributions from community members in the Month of LibreOffice, but throughout May there were many more code patches from various people working for LibreOffice-related companies, as you can see here.
  • Helping to report and confirm bugs: – Our QA community was really well supported in May, so thanks a lot to everyone who reported and/or confirmed bugs! Of course, you can submit a bug report at any time, as described on the wiki.
  • Helping with translations: – LibreOffice is available in over 100 languages, helping to break down digital divides. We want to express our massive appreciation for all the hard work done by people around the globe, who use our translation tools to make LibreOffice a truly universal suite.
  • Answering questions from users: – This covers Ask LibreOffice and the users mailing list. Our community does a great job there, helping users with their questions. If you want to help the LibreOffice project but don’t have much spare time, answering a few questions here and there makes a big difference, as the answers can be useful in the future too!
  • Updating documentation: – LibreOffice’s documentation comprises the built-in help and the user guides, so another hearty thanks to those who gave time to keep them up-to-date. It really makes a difference to the overall quality of the software we all use.
  • Marketing, and spreading the word on Twitter: – We don’t have to add much here! Marketing is essential to spread the word about LibreOffice and grow our community, so it’s great to see people active on social media, telling the world about free software and open standards.

So that was the Month of LibreOffice, May 2018! We’ll be running another one later in the year, with another chance to get a cool sticker bag. Of course, you can help our project and community at any time, and make LibreOffice better for millions of people around the world. Thank you!

Month of LibreOffice, May 2018: The results!

At the start of May, we kicked off a new Month of LibreOffice, celebrating contributions all across the project. Well, May has come to a close now, so how many people got stickers throughout the month? Check it out…

Great work, everyone! This is higher than the previous three Months of LibreOffice (in November 2016, and May and November 2017), which reflects our growing and thriving community. Click the number to see the full details, showing usernames of the contributors helping out in various parts of the project.

Now, if you see your name (or username) on that page, we want to send you a cool sticker pack! Email mike.saunders@documentfoundation.org with your name (or username) from the wiki page, along with your postal address, and we’ll send you these:

(Note: we will only use your postal address to send the stickers. No data will be transferred to third parties, and your address will be deleted as soon as the stickers are posted.)

If you contributed to the LibreOffice project in May but your name (or username) isn’t on the list, let us know! Send us an email stating what you did and with your address, and we’ll make sure you get a sticker too!

And here’s a special thanks to everyone who took part:

Please confirm that you want to play a YouTube video. By accepting, you will be accessing content from YouTube, a service provided by an external third party.

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.

The hundreds of contributions during May have helped to make LibreOffice even better – but we’re not done yet! There are still many ways you can get involved, join our friendly community and have fun – see this page to get started. Thanks again!