Tender to implement C++ accessibility tests (#202110-01)

The Document Foundation (TDF) is the charitable entity behind the world’s leading free/libre open source (FLOSS) office suite LibreOffice.

We are looking for an individual or company to implement C++ accessibility tests.

The work has to be developed on LibreOffice master, so that it will be released in the next major version.

The current accessibility tests are rather incomplete and hard to maintain. Additionally, they are written in Java.

The scope of this tender is to convert them into in-process cppunit-based tests and create a solid foundation in both code as well as documentation to facilitate extending the coverage both as part of this tender as well as for follow-up contributions. TDF aims to prepare a good infrastructure and documentation, so that adding further tests is much simpler in the future, even for new kinds of widgets, up to a point where they could be implemented as part of our EasyHacks. The implementation therefore has to be solid and thorough to support future test cases easily.

We recommend the following steps to approach the tender deliverable:

  • assessing the technical requirements (both using the existing tests to convert, plus the various requirements of a11y in general)
  • assessing the current status
  • designing and creating the new required interfaces, or adapting or augmenting existing ones
  • creating helpers to ease writing tests
  • writing some tests to both serve as examples and proof of concept (at least a couple for each key aspect of testing, but exercising the infrastructure to validate it is key to having something that has a chance of withstanding the test of time)
  • extensive documentation on all those, plus how to write tests and such
  • peer review

Therefore, this tender should provide the infrastructure to:

  • Test the interfaces (AT-SPI, UIA, MSAA, etc.) allowing accessibility tools (ATs) such as e.g. screen readers, magnifier glasses, etc. to access the information required to perform their tasks. This requires testing the LibreOffice implementation of the AT interfaces themselves to catch issues at the outer edge. It is crucial because even if all is well working inside LibreOffice itself, but the information is not properly sent to the platform, it still won’t work for users. Also, it probably has to be done for each platform separately (Desktop Linux (AT-SPI2), Windows (UIA, MSAA), macOS etc.) as their APIs are different, even if often similar, and have separate modules in LibreOffice.
  • Test that there is enough information sent through those interfaces and that it is accurate and usable. This could rely on internal unified interfaces to fetch information and interact with the UI, but there still is a fair bit of diversity on what needs to be tested.
  • Test that functionalities are usable with different type of input (e.g. work with the keyboard, as it’s the most common offender). Also this could rely on internal unified interfaces to fetch information and interact with the UI, but there still is a fair bit of diversity on what needs to be tested.

A key item of the deliverables for this tender is the extensive documentation (in addition to the source-code documentation) that will allow to both maintain the converted tests as well as create additional tests. The documentation shall include (but is not limited to) common pitfalls with accessibility related tests (like timeouts/waiting for events/deal with load dependent/parallelism differences) and how to deal with them. The documentation could walk the developer through the process behind the creation of newly created tests, showcasing both the obvious and not-so-obvious hurdles with that specific tests/a11y related tests in general and how they were dealt with. Aiming for an extendable framework, this likely requires creating new interfaces for missing functionality for reuse in tests.

We expect bidders to provide information on both the code and the non-code parts of this tender, e.g. methodology, structure and technical aspects. The Document Foundation will publish this under a free and open source license and make it available to the general public.

Required skills

  • Extensive knowledge of C++
  • Experience working on the LibreOffice source code

Other skills

  • English (conversationally fluent in order to coordinate and plan with members of TDF)

We use free, libre and open source (FLOSS) software for development wherever possible, and the resulting work must be licensed under the Mozilla Public License v2.0.

TDF welcomes applications from all suitably qualified persons regardless of their race, sex, disability, religion/belief, sexual orientation or age.

Bidders will get a preference for including a partner or independent developer who has not been involved in a successful tender before.

As always, TDF will give some preference to individuals who have previously shown a commitment to TDF, including but not limited to certified developers and/or members of TDF. Not being a member, or never having contributed before, does not exclude any applicants from consideration.

The task offered is a project-based one-off, with no immediate plans to a mid- or long-term contractual relationship. It is offered on a freelance, project basis. Individuals and companies applying can be located anywhere in the world.

When budgeting, we anticipated that this project (all items combined) to take in the region of 30 days of work. Should bidders’ assessment result in a significantly different number, please reach out to us before sending your bid, so we can clarify upfront.

TDF is looking forward to receiving your applications for one or more of the aforementioned tasks, your financial expectations and the earliest date of your availability, via e-mail to a committee at tender20211001@documentfoundation.org no later than November 26, 2021.

Applicants who have not received feedback by December 23, 2021 should consider that their application, after careful review, was not accepted.

All bidders are invited to ask their questions on this tender until November 19, 2021. Questions and answers will be made public in a collected and anonymized form.

Youth Hacking 4 Freedom – from the Free Software Foundation Europe


(Graphic by Lisa Schmidt, CC-BY-SA 4.0 or later)

The Free Software Foundation Europe is starting a new competition:

Are you up to hacking on a software project of your choice? Do you want to meet like-minded people of your age from around Europe? What about getting the chance to receive one of our cash awards and to travel to Brussels to meet the other winners and great people from the Free Software movement? Then join the YH4F competition! The only conditions for you to join are that you are 14-18 years old and you live in Europe. Start by registering before Sunday, 31 October 2021.

There’ll be an online event on Sunday, 10 October at 17:00 CET – see the Youth Hacking 4 Freedom page for more info, and details on registering.

And there’s more: Thorsten Behrens from The Document Foundation’s Board of Directors is on the jury. So, if you fill the requirements listed above and want to get hacking on a project, join in!

Check out the new LibreOffice Development Blog!

Here on The Document Foundation’s blog, we post about general news and activities in the LibreOffice world. But now we have a dedicated development blog, set up by Hossein Nourikhah, who recently joined us as a Developer Community Architect.

Click here to view the first post

Hossein and others will post more updates in the coming weeks and months, helping new developers to get started with the LibreOffice codebase, and providing other insights.

Also check out our other blogs: Design and QA

Interviewing Hypra’s Jean-Philippe Mengual about software accessibility

Accessibility is a key factor for the inclusiveness of digital transformation, but only a few people are really competent in the topic. To learn more about accessibility, we interviewed Hypra’s co-founder, Jean-Philippe Mengual.

Q1. Jean-Philippe, can you tell us about the birth of Hypra?

A1. In 2008 I met Corentin at the Sciences Po higher-learning school in Aix-en-Provence. Through our friendship and the time we spent together studying, he realized how much IT can bring to visually impaired people, but also realized the current limitations.

Together, we understood the revolution it represents: digital technology may erase some inequalities, when one knows how to use it of course. We studied how digital technology can bring equality between visually impaired and sighted people, and then we realized that other people may also benefit from this phenomenon.

We were looking for a solution to this challenge, and we decided to create a computer that was accessible to all, easy to use, adaptable and accompanied by an empowering training.

That is how Hypra was born.

Q2. How challenging is it to work full-time to improve accessibility, and to help seniors and people with disabilities to leverage the opportunities offered by IT?

A2. It is a challenge indeed, and most of us are actually split between several jobs and specialties: psychology, sociology, teaching, but also hacking a distro, patching code, debugging, testing, talking with many communities. The most difficult is to experience regressions and needing of “race” after the accessibility regression to ensure a good end-user experience. And either the upstream project is reactive with our bug reports and/or patches, or it is not, so it may become disappointing.

However, working with people who, because of age or disabilities, are reluctant to use a computer, has allowed us to come to the conclusion that anyone can learn to use a computer fully autonomously, no matter your situation their age, as long as they are well supported at the beginning.

When we see such people progress and succeed, we realize that all of our work is worthwhile.

Q3. How far is free and open source software from offering true accessibility?

A3. Since I started with FOSS in the 2000s, I have seen a lot of real improvements. I, for one, am now able to only use free open source software in my daily activities, with a nice graphical interface.

However, I think reaching actual feature parity would allow users to be fully autonomous with FOSS. At the top of my mind, all features regarding speech synthesis (text to speech) and voice recognition (speech to text) are not quite up to what is achievable with proprietary software. It is the same for OCR (optical character recognition).

Another important dimension is the durability of software environments. Indeed, some programs that used to be perfectly accessible may cease to be so, from one day to another. This may be because some crucial contributors have abandoned that particular project, or it may be due to an update in which accessibility has been put on the back burner.

Q4. Hypra provides hardware solutions both for seniors and for people with disabilities. Can you tell us about these products, and about the software?

A4. We rely on Debian GNU/Linux for our products. We chose it because of its stability and careful update pace, which allows us to guarantee optimal use for our customers including our own layer of customizations in good conditions.

We mainly use free and open source software on our computers. To enable individual support, we provide Mumble, VNC to take control of the system remotely, and we use SSH for maintenance.

Regarding the tools for our visually impaired customers, we have chosen the Orca screen reader and Compiz for visual filters, rely on the MATE desktop (great for its full flexibility from a user point of view). Alongside with the computers, we provide scanners which, together with the screen reader, turn your laptop into a reading machine.

Generally speaking, the fact we produce only free code and use mainly free software enables us to sell, for a standard price, hardware with a high service level.

Q5. Hypra is working with enterprises to integrate people with disabilities in business environments. How difficult is this task?

A5. It’s important to know that the first task when adapting a workstation is to reassure both the user and their company. They have to be reassured that the equipment is compatible with the work environment already in place and that we’ll be there to support them.

In fact, the highest challenge is the diversity of the infrastructures: many solutions, more and more remote, few free software in the workstation (which is not always accessible, by the way, under Windows). It depends on the size of the organization and the flexibility possible in respect with the IT teams and the security needs of the company. The good news comes when the clients are web interfaces, even if some improvements are needed to make everything accessible. But a web interface is potentially easier to make accessible than software, because it is governed by standards, while software is based on various toolkits, not always compatible with any accessibility solution – in particular remotely.

Q6. What kind of integration have you done with LibreOffice?

A6. We only use vanilla LibreOffice versions. We’re generally very happy with these, except for certain aspects such as the stability of certain versions or occasional accessibility regressions in LibreOffice.

As far as Orca users are concerned, we’ve chosen to use an older LibreOffice build, version 4.2, as it gives us full satisfaction – which also applies to all low vision software.

However, we have noticed that accessibility is becoming more and more present in LibreOffice’s development in the recent years; we’re speculating that from version 8.x onwards we’ll hopefully be able to migrate all users to a more recent version.

On our end, we plan to systematize regression testing of the master branch in order to get more actively involved in the development process. This will also allow us to alert contributors immediately if a specific proposed change affects accessibility.

We also want to provide use cases to the community, so that each of its members can concretely test what a user with specific needs expects from the program in their daily use.

Fixing an Interoperability Bug in LibreOffice: Missing Lines from DOCX (part 3/3)

By Hossein Nourikah, Developer Community Architect at The Document Foundation

In LibreOffice, interoperability is considered a very important aspect of the software. Today, LibreOffice can load and save various file formats from many different office applications from different companies across the world. But, bugs are inevitable parts of every software: there are situations where the application does not behave as it should, and a developer should take action and fix it, so that it will behave as it is expected by the user.

What if you encounter a bug in LibreOffice, and how does a developer fix the problem? In these series of articles, we discuss the steps needed to fix a bug. In the end, we will provide a test and make sure that the same problem does not happen in the future, again.

The article is presented in three parts:

  1. Understanding the Bugs and QA
  2. Developing a Bug Fix
  3. Writing the Tests and Finishing the Task

This is the third part.

3. Writing the Tests and Finishing the Task

So, if you have read the two previous parts on “Fixing an Interoperability Bug: Missing Lines in Save and Load” (part 1, part 2), this is the third and last part of these series. In this part, we discuss how to write a test, submit the patch to the Gerrit and try to get it incorporated into the LibreOffice code.

3.1. Writing a Test for the Regression

In order to make sure that this regression will not happen again, we should create test for every bug that is fixed. If we don’t do this, there is a big chance that this bug will occur again and again.

But how to start writing a test? The answer is that there are ~3000 tests available in sw/qa/extras/ folder, and there is a tiny document sw/qa/extras/README that describes them. These tests can be a basis for writing a new test. For example, test for tdf#91687 consist of these lines:

DECLARE_WW8EXPORT_TEST(testTdf91687, "tdf91687.doc")
{ // Exported Watermarks were resized
 uno::Reference xWatermark = getShape(1);
 CPPUNIT_ASSERT_EQUAL(sal_Int32(5172), xWatermark->getSize().Height);
 CPPUNIT_ASSERT_EQUAL(sal_Int32(18105), xWatermark->getSize().Width);
}

It uses a macro DECLARE_WW8EXPORT_TEST too, that checks some properties of the document after loading it, and then again after saving and reloading it. If some property is erroneously changed, the test will fail, and you will get noticed.
As you can see, the name of the test, and the name of the test document in which here is .doc file, come from the bug number.

The test for this regression should check for the position and size of the shapes, so there are similarities between the our desired test and the test above. But how can we find the properties of the elements of the document? The answer is the new UNO object inspection tool for the LibreOffice:

https://blog.documentfoundation.org/blog/2021/03/02/update-on-tender-for-a-built-in-uno-object-inspection-tool-in-libreoffice/

As can be seen in figure 1, the size for Shape7 which is the first vertical line, is visible on the right.

In previous versions, tools called XRAY or MRI were used for object inspection.

Figure 1. UNO object inspection tool for the LibreOffice

The completed test comes below. It takes Shape7, Shape8 and Shape9 which are the three vertical lines, and ensures that they have the same size in the first load, and after save and reload. Without the fix, some of these test fail, which are size checking for the first and last vertical lines. Their size was reduced to ~0, so it is justifiable that previously they were erroneously disappearing after save and reload. The test passes after applying the fix.

DECLARE_WW8EXPORT_TEST(testTdf123321, "shapes-line-ellipse.doc")
{
 // These are the 3 lines in which 1st and 3rd one were
 // disappearing before
 uno::Reference<drawing::XShape> l1 = getShape(7);
 uno::Reference<drawing::XShape> l2 = getShape(8);
 uno::Reference<drawing::XShape> l3 = getShape(9);
 // first line (smallest)
 // Fails without the fix: Expected: 423, Actual: 2
 CPPUNIT_ASSERT_EQUAL(sal_Int32(423), l1->getSize().Height);
 // Fails without the fix: Expected: 0, Actual: 2
 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), l1->getSize().Width);
 CPPUNIT_ASSERT_EQUAL(sal_Int32(7908), l1->getPosition().X);
 CPPUNIT_ASSERT_EQUAL(sal_Int32(37), l1->getPosition().Y);
 // second line (larger)
 CPPUNIT_ASSERT_EQUAL(sal_Int32(2542), l2->getSize().Height);
 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), l2->getSize().Width);
 CPPUNIT_ASSERT_EQUAL(sal_Int32(7916), l2->getPosition().X);
 CPPUNIT_ASSERT_EQUAL(sal_Int32(289), l2->getPosition().Y);
 // third line (largest)
 // Fails without the fix: Expected: 7027, Actual: 2
 CPPUNIT_ASSERT_EQUAL(sal_Int32(7027), l3->getSize().Height);
 // Fails without the fix: Expected: 0, Actual: 2
 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), l3->getSize().Width);
 CPPUNIT_ASSERT_EQUAL(sal_Int32(7911), l3->getPosition().X);
 CPPUNIT_ASSERT_EQUAL(sal_Int32(231), l3->getPosition().Y);
}

As you can see, not all the tests fail without the fix, but they are in place to protect the correct load and save of the shapes in the future.

3.2. Cleaning up and Submitting the Changes

After we finished the fix, we commit the changes, and submit it to the LibreOffice Gerrit.

$ git add include/svx/svdopath.hxx svx/source/svdraw/svdopath.cxx sw/qa/extras/ww8export/data/shapes-line-ellipse.doc sw/qa/extras/ww8export/ww8export2.cxx

$git commit

Let’s see our latest commit:

$ git show --name-only

Author: Hossein <hossein@libreoffice.org>
Date:   Mon Jul 19 13:03:42 2021 +0200

    tdf#123321 Fix DOC/DOCX export bug which made some lines disappear
    
    * Fix the wrong calculation of SdrPathObj (line) extent while exporting
      to .doc and .docx formats. This resolves tdf#123321 which cause some
      lines to disappear after save and reload. This fix does not break
      tdf#91687
    * added tests to make sure this does not happen again, based on the
      .doc file provided in Bugzilla
    * Loading the bad exported file in MS Word is OK, but it does not work
      in LibreOffice, and some of the lines will be hidden. This needs
      additional work.
    
    The regression came from d72e0cadceb0b43928a9b4f18d75c9d5d30afdda
    
    Change-Id: Ic5a7af4d29df741204c50590728542e674ee9f91

include/svx/svdopath.hxx
svx/source/svdraw/svdopath.cxx
sw/qa/extras/ww8export/data/shapes-line-ellipse.doc
sw/qa/extras/ww8export/ww8export2.cxx

The actual commit information is lengthy, but for making it shorter, we only listed the name of the changed or new files. Then, we submit the patch:

$ ./logerrit submit master

This is with the assumption that we have successfully configured Gerrit before. One should set up Gerrit before doing this. A step-by-step manual is presented in The Document Foundation Wiki.

https://wiki.documentfoundation.org/Development/gerrit/setup

3.3 Getting the Submission Merged

Every submission to the Gerrit is reviewed by one or more developers, and is possibly gets merged into to the code after the submitter has done all the requested fixes and improvement. This is done by the decision one of the people with commit access. Commit access is granted to the developers who had a good record of contributions and are trusted to change the code base directly.

So, the code is reviewed in the Gerrit:

https://gerrit.libreoffice.org/c/core/+/119116

Every submitted code is built automatically by Jenkins in a process called CI (continues integration). If the build is successful, you will get a     Verified +1     from Jenkins.

If, for any reason, one of the builds for several platforms that is tested fails, you will get     Verified -1     from Jenkins. Then, you will have to fix the problem and re-submit again. Please note that there are situations that some tests fail because of the Jenkins problem itself. If that is the case, you should ask people in the #libreoffice-dev irc channel to invoke a resume for you, or try rebasing to initiate a rebuild.

The original submission (patch set 1) lacked the tests, so a test was requested. After doing the improvements, including a change in the title and uploading seven patch sets in total, it was given the   Code Review +2   from the reviewer. Here, Miklos Vajna from Collabora has done the reviews and merging.

Then, the proposed changes eventually got merged into the code by the reviewer with appropriate access. After that, everyone can pull the changes from Git:

https://git.libreoffice.org/core/+/bda4d7a7c3fcc259e023f568606be5dcba818db9

3.4 Marking the Bug as Fixed

After the commit is done, the journey ends with marking the bug as fixed. Looking at the other possible registrations of the symptoms at TDF Bugzilla, it turns out that another bug can be considered a duplicate of this one:

Bug 127296 – FILESAVE: DOC Rotated line loses rotation when saved

https://bugs.documentfoundation.org/show_bug.cgi?id=127296

It is reported in 2019-09-02, and it is newer than the one we have fixed. So, we can mark tdf#127296 as a duplicate of this one. After that, we can safely change the status of tdf#123321 to “RESOLVED FIXED”, and we’re done!

3.5 Want to Get Involved?

If you want to get involved in Libreoffice development, you can help in fixing the bugs. Looking at the statistics from TDF’s Bugzilla, we see that there is a total of ~12k open bugs, in which ~1.3k of them are regressions. Among them, around 1.1k are bibisected. They are more suitable for getting into, because the root of the problem is known to some extent.

You can go through the same process that was discussed in the series of articles here to fix the bugs and submit your patch, and if you had any questions, #libreoffice-dev is a good place to ask. Also, it is suggested that you join the LibreOffice development mailing list. See the instructions here.


Hossein Nourikhah is the Developer Community Architect at the The Document Foundation (TDF), the non-profit behind LibreOffice. If you need assistance getting started with LibreOffice development, you can get in touch with him:

E-Mail: hossein@libreoffice.org

IRC: hossein in the IRC channel #libreoffice-dev on the Libera.Chat network connect via webchat

Fixing an Interoperability Bug in LibreOffice: Missing Lines from DOCX (part 2/3)

By Hossein Nourikah, Developer Community Architect at The Document Foundation

In LibreOffice, interoperability is considered a very important aspect of the software. Today LibreOffice can load and save various file formats from many different Office applications from different companies across the world. But, bugs are inevitable parts of every software: There are situations where the application does not behave as it should, and a developer should take action and fix it, so that it will behave as it is expected by the user.

What if you encounter a bug in LibreOffice, and how a developer fixes the problem? In these series of articles, we discuss the steps needed to fix a bug. In the end, we will provide a test and make sure that the same problem does not happen in the future, again.

The article is presented in three parts:

  1. Understanding the Bugs and QA
  2. Developing a Bug Fix
  3. Writing the Tests and Finishing the Task

This is the second part.


2. Developing a Bug Fix

So, if you have read the previous part of “Fixing an Interoperability Bug: Missing Lines in Save and Load” (part 1), this is the sequel. Here we try to develop a solution for the problem with our knowledge of C++.

The first thing we need is to build the LibreOffice core. Depending on the platform, you can find the instructions in the TDF wiki.

See the instructions for building LibreOffice on:

2.1. Finding the Responsible Change

So, now we know that through this commit, these files were changed. One (or possibly all) of the changes is responsible for the regression. So we try to find a minimize set of changes that lead to the problem. We can use --name-only option from git:

$ git show d72e0cadceb0b43928a9b4f18d75c9d5d30afdda --name-only

So, the changed files are:

  1. filter/source/msfilter/escherex.cxx
  2. filter/source/msfilter/msdffimp.cxx
  3. include/svx/msdffdef.hxx
  4. sw/qa/extras/ww8export/data/tdf91687.doc
  5. sw/qa/extras/ww8export/ww8export2.cxx
  6. sw/source/filter/ww8/wrtw8esh.cxx

Sometimes we have to go back to this specific commit using git checkout command to be able to work on the exact commit before the one that created the bug. But, most of the time, reverting the specific commit is easier, and the build will be much faster. Also, building older versions of LibeOffice is tricky. We can instead invoke this command:

$ git revert d72e0cadceb0b43928a9b4f18d75c9d5d30afdda

Now we should try to resolve the possible conflicts, then build the code and make sure the problem has gone away! Then we can try to re-introduce one or more changes to achieve a minimal set of changes that reproduces the problem.

We can start at the file level to find the relevant files to work on. Files 4 and 5 are related to the tests, so they should have no impact. File 1 and 2 seem to be related, as both are from filter/source/msfilter folder, file 3 is also related to these two files. After leaving out all the files, we see that changes from 6 (sw/source/filter/ww8/wrtw8esh.cxx) is enough to reproduce the problem. So, we have few lines of code changes in front of us:

@@ -756,7 +756,12 @@ void PlcDrawObj::WritePlc( WW8Export& rWrt ) const
                OSL_ENSURE(pObj, "Where is the SDR-Object?");
                if (pObj)
                {
-                   aRect = pObj->GetSnapRect();
+                   aRect = pObj->GetLogicRect();
+
+                    // We have to export original size with padding
+                    const SfxItemSet& rSet = pObj->GetMergedItemSet();
+                    const SdrMetricItem* pItem = static_cast(rSet.GetItem(SDRATTR_TEXT_UPPERDIST));
+                    aRect.SetSize(Size(aRect.GetWidth(), aRect.GetHeight() + pItem->GetValue()));
                }
            }

If we work further on this piece of code, we will find that the change from pObj->GetSnapRect() to pObj->GetLogicRect() is the source of regression: Good catch!

2.2. Creating a Fix

As described in the previous section, going back to pObj->GetSnapRect() fixes the problem, but wait! Isn’t that change supposed to fix a problem?

(GOOD)

(BAD)

Figure 1: Wrong increase of watermark size
after save and reload

If we go back to git master using:

git reset --hard HEAD^1

and then only change pObj->GetSnapRect() to pObj->GetSnapRect(), this test fails with the change. Try:

$ make CPPUNIT_TEST_NAME="testTdf91687" -sr CppunitTest_sw_ww8export2

If we take a look at the tdf#91687 in the Bugzilla, we see the example sw/qa/extras/ww8export/data/tdf91687.doc that contains a watermark (Figure 1) that gets bigger by save and reload! Looking more carefully to the changes, it becomes clear that rotation is important here. If we change the watermark example in order to set rotation to zero, nothing happens.

This is not limited to watermarks: Saving and re-loading any custom shape leads to such a wrong increase in size. On the other hand, this does not have any effect on the lines, rotated or not.

2.3. Fixing the Side Effects

In order to fix the undesired side effects, we should make a difference between the lines and the complex shapes. So, what is the difference? If we look closely to the code, we find out that pObj object is from SdrObj class, which is abstract DrawObject. The documentation for this class can be found here:
https://docs.libreoffice.org/svx/html/classSdrObject.html

Figure 2. Class hierarchy for SdrObject

So, objects from different SdrObject subclasses are sent here, and appropriate GetSnapRect() or GetLogicRect() is called. But which method? According to the runtime polymorphism, this is determined at runtime. So without debugging, nothing becomes clear.

By setting a break-point at this modified line and stepping into the GetLogicRect() function, it becomes clear that two types of object are created for the shapes:

  • pObj is SdrObjCustomShape (x4): representing 4 ellipeses
  • pObj is SdrPathObj (x5): representing 5 lines

So, the trick would be creating a GetLogicRect() method for SdrPathObj and make it invoke GetSnapRect(). In this way, lines and custom shapes are treated differently.

We declare GetLogicRect() in include/svx/svdopath.hxx:

virtual const tools::Rectangle& GetLogicRect() const override;

and add its implementation in svx/source/svdraw/svdopath.cxx:

const tools::Rectangle &SdrPathObj::GetLogicRect() const
{
    return GetSnapRect();
}

Then we rebuild the LibreOffice by invoking make, and then start the LibreOffice from instdir/program/soffice. After loading, saving, and re-loading the example DOCX file, we see that this fix actually works!

In the third part, we are going to talk about the steps needed to get our changes merged into the LibreOffice Code. If you want to get involved in LibreOffice development, it is suggested that you join the LibreOffice development mailing list. See the instructions here.


Hossein Nourikhah is the Developer Community Architect at the The Document Foundation (TDF), the non-profit behind LibreOffice. If you need assistance getting started with LibreOffice development, you can get in touch with him:

E-Mail: hossein@libreoffice.org

IRC: hossein in the IRC channel #libreoffice-dev on the Libera.Chat network connect via webchat