def StartLibreOffice(filename):
    if sys.platform == 'win32':
        filename = "".join(["file:", urllib.pathname2url(os.path.abspath(filename.encode("utf-8")))])
        # print filename
        try:
            StarDesktop, objServiceManager, core_reflection = getOOoContext()
            StarDesktop.LoadComponentFromURL(filename, "_blank", 0, MakePropertyValues(objServiceManager, [
                ["ReadOnly", False],
                ["Hidden", False]]))
        except Exception as e:
            print("Exception ouverture LibreOffice", e)
            dlg = wx.MessageDialog(None, "Impossible d'ouvrir le document\n%r" % e, "Erreur", wx.OK|wx.ICON_WARNING)
            dlg.ShowModal()
            dlg.Destroy()
    else:
        paths = []
        if sys.platform == "darwin":
            paths.append("/Applications/LibreOffice.app/Contents/MacOS/soffice")
            paths.append("/Applications/OpenOffice.app/Contents/MacOS/soffice")
        else:
            paths.append("/usr/bin/libreoffice")
            paths.append("ooffice")
        for path in paths:
            try:
                print(path, filename)
                subprocess.Popen([path, filename])
                return
            except Exception as e:
                print(e)
                pass
        dlg = wx.MessageDialog(None, "Impossible de lancer OpenOffice / LibreOffice", 'Erreur', wx.OK|wx.ICON_WARNING)
        dlg.ShowModal()
        dlg.Destroy()