Path of current document in [Libre|Open]Office

dubbaluga picture dubbaluga · Sep 15, 2012 · Viewed 12.8k times · Source

How can I determine the path of the currently open document in an OpenOffice or LibreOffice document? I want to forward the path to an external application.

More specifically I want to launch an external player from impress with a video file in full-screen mode:

Shell("/usr/bin/mplayer", 2, """ -fs"" some-file-in-same-dir-as-document.mp4")

For the last parameter I would need the path to the currently opened document in order to append it. Not specifying the path results in referring to the current path (as given by the CurDir() function) which is something different.

Is there actually a good reference for LibreOffice Macros? The only relatively good (but hard to search) document I have found is "OpenOffice Macros Explained" by Andrew Pitonyak.

Answer

dubbaluga picture dubbaluga · Dec 14, 2012

In the meantime I have found a feasible solution. Look here:

Sub RunSomeMovie
    GlobalScope.BasicLibraries.loadLibrary("Tools")
    Shell("/usr/bin/mplayer -fs ", 2, "" & Tools.Strings.DirectoryNameoutofPath(ThisComponent.getURL(),"/") & "/media/somemovie.mp4")
End Sub