Saturday, March 28, 2015

MS Word compatible text highlighting in LibreOffice 5.0

LibreOffice has an old compatibility issue (inherited from OpenOffice) with Microsoft Office related to text highlighting (character background). During document exchange between the two office suites text highlighting is changed on an unexpected way. The root of the problem is that LibreOffice (LO) and Microsoft Office (MSO) has a different design for character backgrounds and so it's ambiguous how to save LO character background to MSO file formats (ambiguous both to users and to developers). Now this issue is solved by allowing the users to specify the behavior of LO export.

Design differences

Microsoft Word has a two-character-background concept. One attribute is called shading which lives on more levels of the document model: table cells, paragraphs and characters. With it we can add any background color to the selected object and we also can use it in a theme. The other one is called highlighting which offers a more limited color selection and is used on the analogy of highlighter pen to call attention to a portion of the document.

LibreOffice Writer, in the other hand, supports only one kind of character background which is called also as highlighting. This character background is closer to Word shading attribute, since it has a wider color selection and it's also a specialization of the general background attribute on the same way as shading in Word. An other similarity is that automatic font color interacts with character background in Writer and with shading in Word on a way to make text always visible (e.g. when background is dark then text color becomes white, when the background is light then text color changes to black). Word highlighting doesn't have this kind of behavior.

About Microsoft Word's concept

After I decided to fix this issue the first questions were: How useful is this two-character-background concept of Microsoft Office? Is this something which LibreOffice should support?
I've got the answer: It's not something that LibreOffice needs.

First of all I can't see a real difference between the usage of shading and highlighting in Word. I mean both have the purpose to make some parts of the text more visible (highlight them). Highlighting can be also used for reviewing a document (mark parts of a document temporarily), but both office suits have a Comments feature which includes an integrated highlighting function, which can be more useful for this purpose.

Additonally this concept also leads to misunderstandings among the users. At the first sight it can't be decided whether a highlighted text portion in a document is formatted actually with highlighting or with shading. This becomes worse because of that the highlighting feature is more accessible in some versions of Word and so it is more known by the users as shading which can make users confused when they get a document with character shading. As I see this was the main issue also in case of LibreOffice, because it exported character background as shading to MSO formats and so some of the users were not able to remove this shading in Word by using "Highlight" toolbar button.

Summary, as I see the two-character-background concept does not have a real benefit and also causes problems on the user side so it's not worth to have.

Export as highlighting or as shading

The second question was: How to export LO character background to MSO formats to make the users happy? MSO shading is closer to LO character background in behavior but at the same time highlighting is more accessible in Word and on Writer's user interface character background is called as highlighting. So both attribute can be a good candidate for export.

That's why it seemed the best to have an option to choose between shading and highlighting. I added this option at Tools -> Options -> Load/Save -> Microsoft Office, with which user can specify the behavior of the export. The default became highlighting mainly because in LO character background is called highlighting and so users can expect they will get highlighting in their MSO document and not shading.

New Microsoft Office compatibility option

Import of Microsoft Word documents

So far I wrote only about the export of LO character background. The next question is how shading and highlighting are imported from MSO documents and how they saved back. I solved this on the way that both attributes are preserved by import so a Word document will have the same appearance in Writer. If this document is saved without modification, then shading and highlighting will be saved back unchanged.

The difference compared to Word becomes visible by editing. It doesn't matter whether a character background was shading or highlighting in the original document it can be edited by Highlighting toolbar button in Writer. From that point - after a specific text range's background is edited inside LibreOffice - MSO shading and highlighting markers will be removed and will be replaced with LO specific character background. So MSO attributes are preserved until the corresponding text range is edited by LibreOffice.

Summary

In the next LibreOffice release users will be able to customize their office suite on one more way by specifying how to export character background to Microsoft Word file formats. I think this is the best we can do here because of the design differences. Well, let's see what users say.

Choice is good, but most "regular" users won't know (nor care) about the difference between how the two programs handle a color "underlay," to use a neutral term. For the user, the question is: Will your changes—coupled with whatever the default setting is delivered in 5.0—result in a transparent experience that correctly puts the right color behind the text, whether the document goes from LO to MSO or vice versa ... or if it goes back and forth several times, as is often the case?

Great work!!! I think this bug has been a big barrier for LO adoption for a lot of users. Now we can easily work in LO, "highlight" some text, save as .docx and send to some collegue which uses word. Simply fantastic. If I am right this will not work if the text will be saved in .odp, right?

This scenario should work also with .odt format. At least LO saves highlighting to this file format too. It depends on MSO Word, whether it is imported and how it is imported (highlighting or shading). I don't know how good is MSO's ODF support.