Skip to content

Instantly share code, notes, and snippets.

@hmeeks-dot
Last active February 3, 2024 04:03
Show Gist options
  • Save hmeeks-dot/0a04bd685d4d18f755b727e231b27b96 to your computer and use it in GitHub Desktop.
Save hmeeks-dot/0a04bd685d4d18f755b727e231b27b96 to your computer and use it in GitHub Desktop.
GSoC 2022 - Final Report - Hannah Meeks

Google Summer of Code 2022 - Final Report

Organisation: Libre Office

Project Title: VBA Macros - Tests and missing APIs

Overview

My task was to write macros tests in VBA and to identify areas in the code to fix in order to improve interoperability between Libre Office Writer and Microsoft Word. I wrote tests on find and replace, paragraph format, document range, tables etc.(see below) as well as writing some code framework to run my tests.

Results

At the start of the project I wrote a test for Value2 and focused on resolving mutex issues from the bonding period/ my first hack. I wrote tests for find and replace and when testing discovered that new find objects kept being created - there were issues around this, I tried anchoring the find object to the selection object which had the same problem, fixed this by making find global. I then made a test framework and changed the filing method to make it easier to add docm files. Looking at the document object I fixed errors to do with setting the range around text, I also looked at font and colour mapping resolving problems due to this. I then looked at the table object spending some time trying to add style properties to writer but this was too hard - I couldn't find a table-styles UNO-interface. I added padding properties to table in order to pass some of my VBA tests, and added unit conversions to application and global.

Overall I wrote lots of macros tests which was the main aim of the project and found lots of bugs/areas to fix so my Summer was a success! I also really enjoyed looking into the core and fixing some of these problems. Lots of my tests are still broken in LO so need fixing, for example I found that there seem to be problems with new lines being created in Word that are not created in Writer - looking at tests testSelection and testSentences.

Test Documents Added

  • testFind.docm
  • testDocumentRange.docm
  • testFontColor.docm
  • testSentences.docm
  • testWords.docm
  • testParagraphFormat.docm
  • testTables.docm
  • testShapeWrapFormat.docm
  • testSelection.docm

My Changes - VBA

https://gerrit.libreoffice.org/c/core/+/133645 https://gerrit.libreoffice.org/c/core/+/136943 https://gerrit.libreoffice.org/c/core/+/136630 https://gerrit.libreoffice.org/c/core/+/136944 https://gerrit.libreoffice.org/c/core/+/137004 https://gerrit.libreoffice.org/c/core/+/137006 https://gerrit.libreoffice.org/c/core/+/137204 https://gerrit.libreoffice.org/c/core/+/137032 https://gerrit.libreoffice.org/c/core/+/137105 https://gerrit.libreoffice.org/c/core/+/137109 https://gerrit.libreoffice.org/c/core/+/137202 https://gerrit.libreoffice.org/c/core/+/137262 https://gerrit.libreoffice.org/c/core/+/137383 https://gerrit.libreoffice.org/c/core/+/137630 https://gerrit.libreoffice.org/c/core/+/137787 https://gerrit.libreoffice.org/c/core/+/137851 https://gerrit.libreoffice.org/c/core/+/137856 https://gerrit.libreoffice.org/c/core/+/137852 https://gerrit.libreoffice.org/c/core/+/137897

Useful Stuff I learnt

One of the most useful things I learnt was printf debugging. I couldn't get the debugger to work and had problems with this, in the end adding a few lines of code to vlc/source/dialog helped me to display message-box contents. I also learnt that adding Option Explicit at the top of a macro test doc is hugely helpful for updating casing of function names. Annoyingly VBA function names do not automatically update but this allows them to in a change of case, which can save considerable time!

Future Improvements

So much stuff left to do here there is just massive scope...

More Generally:

  • Some of my tests are commented out in the document or in macros-tests.cxx - these still don't work in LO due to bugs - they need fixing and more testing.
  • There are VBA tests missing for lots of areas - hard to name them all! - would recommend recording macros in word and then spotting differences in writer when run to find good areas to test with lots of bugs to fix in the most used areas.
  • I found that some areas were hard to fix/implement because there seemd to be no core code supporting some areas - e.g. table styles, casing in find and replace (a capital is replaced with a capital in word) etc. so these would probably take more significant time to fix.

Specifically next steps could be:

  • Looking at tables - there seems to be lots of problems when multiple tables are put into the same document.
  • Adding the paragraphs object to writer - this should be do-able as lots of the table referencing is already there so this can probably be applied to paragraphs.

Conclusion & Thanks

It was such a fun and interesting experience to work on such a massive project, thank you to the whole of the Libre Office community and especially to my mentors: Tomaž Vajngerl and Thorsten Behrens. Also thanks to Google for letting me spend my summer coding, I plan to contribute much more in the future!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment