Search code examples
pythoncsvdifflibreoffice

Access to LibreOffice's Compare Documents using python


I have two .csv files that I want to use LibreOffice's compare documents tool (Edit>Compare Document) with.

These csv files are made after the run of a long and involved script, and it would be nice to be able to have the compare process to be automatic as well, with the result being a window of LibreOffice open with the changes as if I selected compare manually. I want the specific LibreOffice gui (which I believe does a great job highlighting differences) not just a diff.

Looking online, it seems like there is nice but limited set of python wrappers for libre office (pyoo).

However, despite related questions, I couldn't see any way of gaining access to the compare functionality through this or any other library. Is the Compare Documents functionality available at the python level, the UNO API level, or simply not available at all?


Solution

  • Use the dispatcher:

    Dispatcher.executeDispatch(
        (XDispatchProvider)Frame, ".uno:CompareDocuments", "", 0, propertyValueFile);
    

    A complete Java example is at https://forum.openoffice.org/en/forum/viewtopic.php?f=44&t=2795.