Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Impoving LibreOffice Android Viewer -- A Google Summer of Code Project
LibreOffice is a modern Free & Open Source Office suite, one of the largest open source projects, and used by millions of users worldwide. LibreOffice works nicely on Android these days, but there are still many things to improve and fix. My work during this project is focused on adding new features to LibreOffice Android Viewer and solving most annoying bugs for it.
Then main tool I used is Android Studio, the official IDE from Google for developing Android apps. The programming language is primarily Java, some XML, and some C++. The version control tool I used is git and code review through Gerrit.
*Main tasks*
1. Presentation mode
I export the presentation as a SVG file and then show it in a WebView. The SVG support of WebView is strongly related to Android version of the running device. Pre-KitKat Android doesn't have this support because the default WebView engine is not chrome yet. So, I did an alert dialog for pre-KitKat Android phones and copy the link to system clipboard. Then the user can go to Chrome or Firefox and load the file manually.
2. Calc UI
Header info can be retrieved with a LOKit call and the JNI functions are already implemented before I started. The challenge here is how to add headers to Calc UI. I decided to add 2 independent Views left and top and only show them when user opens Calc files. The drawing of headers is achieved by CanvasElement. Basically, whenever there is a refresh on the headers, we draw the headers on the left and top views one by one. The result turned out to be quite neat and quick. The tricky part involves calculating the size of the headers in pixels and also adapt them when the user pans and zooms. The zooming is problematic just like in LOOL, in which the retrieved header info doesn't match what's showing on the main GL view. So, we decided to fix the zoom to 1x and DPI to 96 to work around. Someone who knows LO very well should tackle this issue.
After the headers started to work, I implemented selecting cells and rows/columns. They are implemented differently, since cells are on the main GL view and rows/columns are supposed to relate to the top and left header views. The selection involves emitting calls to LOKit and listening to callbacks from LOKit. A lot of details should be considered. Luckily, now they work pretty nicely.
After the selection worked, I went on and implemented address bar and formula bar, which was quite simple.
Finally, I implemented insert/delete/hide/show/adjust width/height, which were straightforward but required a lot of care and caution.
3. Ability to load password-protected documents
Android Viewer was not able to load password protected documents because the proper JNI functions didn't exist. I tried to implement this functionality and found out that in Android Viewer actually only the LO Document instance is implemented. However, in order to provide password, we need to implement the LO Office instance which takes the password. So, I implemented the messageRetrieved and the bindMessageCallback and so on, for LO Office instance as Android JNI. And of course password related JNI functions came afterwards. This task was pretty challenging since I never did C++ programming before. I had to learn by mimicking other parts of the code, which worked well.
*Full list of features added*
1. Ability to load password-protected documents:
2. Auto-updated page number information in text documents:
3. Interactive spreadsheet UI with row/column headers:;
4. Header related functions e.g. insert/delete/hide/show/optimal width or height in spreadsheet UI:
5. Address and formula bars in spreadsheet UI:
6. Presentation Mode in slideshow documents:
7. Developer Mode for sending UNO commands in the app without debugging tool:
8. Ability for user to double tap to zoom in and out:
9. Ability to insert pictures from taking photos, choosing local images, downloading cloud images (Google photos, Dropbox, etc.) with an option to compress the image or not:
*Full list of bugs solved and other patches*
1. Top part unreachable with soft keyboard open:
2. Fix typo: inticator -> indicator:
3. Fix typo: 'forgeround' in multiple files:
4. Restrict zoom to page width:
5. Android Viewer doesn't focus on the word you search:
6. Android Viewer does not show page count:
7. Android Viewer does not switch edit mode to view:
8. Disable 'parts' in text documents:
9. Fix appbar invisible on lower version:
10. Fix behavior of double tap zoom in and out:
11. Update zoom constraints with device rotate:
12. Fix windowSoftInputMode:
13. Fix “Even internal links are treated as hyperlinks”:
14. Correct typo of class name:
15. Fix crash after save dialog:
16. Correct LOK Enums:
17. Add LOKit Enums to
18. appbar invisible on lower version:
19. Clean up util func with Calc dev:
20. Calc cannot zoom due DPI fixed to 96 (work in progress):
*Related links*
1. Proposal page:
2. My code patches:
3. Beta app to test:
4. LibreOffice homepage:
5. TDF homepage:
6. Ideas page for LibreOffice Android Viewer:
7. LibreOffice 6.0 release notes with my contributions:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.