Working example of a c++ application using LibreOffice UNO API to create and edit calc files

, ,

I’m making a multiplatform application in c++ (Linux, Windows) and in this application I need to create some LibreOffice Calc files to report its results. I was working with the UNO library and nothing that I code work. The code compiles but always at runtime throws an exception error, mostly regarding to null interfaces. After read and try numerous alternatives I think that I’m in the wrong path, so I ask for help. I want to make clear that I don’t need an UNO AddOn written in c++. In the program I just going to check if there is a functional installation of LibreOffice and if it is true then make reports in Calc files. But nothing to be used inside LibreOffice to extent its functionality. I can use UNO or another library. UNO library mostly have help documentation relative to AddOns in Java and Python but not much in c++ or another use cases of UNO.

mostly have help documentation… in Java and Python

Yes, because it isn’t as easy to make mistakes in those languages that may result in errors such as null interfaces! I have gotten some C++ UNO code to work but try to avoid it if there is an easier way.

It looks like the best example to start from is DocumentLoader at LibreOffice 6.4 SDK - Examples. To determine particularly how to work with Calc, use MRI and keep www.pitonyak.org/oo.php close as a reference. Searching online for examples in Java can sometimes be helpful for C++ because they show the specific interfaces required.

In case you find it helpful, here is some C++ UNO code I wrote recently based on listing 5.49 of Andrew’s Macro Document: https://stackoverflow.com/a/62781467/5100564