From 8efb69e260ecbcde5ee67ab41ed7a9630783c29a Mon Sep 17 00:00:00 2001 From: Bjoern Michaelsen Date: Fri, 30 Nov 2012 19:37:07 +0100 Subject: move base check for bibliography to sfx2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - in the libbiblio component the frame is already created, and a frame that is loading is vetoing a terminate - thus move check to sfx2 - use the fancy svtools::RestartDialog Change-Id: I500aaeac44d52969575f50f6b79d0c07a08c977e Reviewed-on: https://gerrit.libreoffice.org/1207 Reviewed-by: Björn Michaelsen Tested-by: Björn Michaelsen --- sfx2/source/appl/appserv.cxx | 70 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 6 deletions(-) (limited to 'sfx2/source') diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index b85612bff2b4..57029cf49164 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -36,6 +36,8 @@ #include #include #include +#include +#include #include @@ -45,6 +47,7 @@ #include #include +#include #include #include @@ -130,6 +133,66 @@ using namespace ::com::sun::star::system; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::document; +namespace +{ + struct BaseInstallerPhoenix : osl::Thread + { + BaseInstallerPhoenix() {}; + virtual void run() + { + try + { + using namespace org::freedesktop::PackageKit; + using namespace svtools; + Reference< XSyncDbusSessionHelper > xSyncDbusSessionHelper(SyncDbusSessionHelper::create(comphelper::getProcessComponentContext())); + Sequence< ::rtl::OUString > vPackages(1); + vPackages[0] = "libreoffice-base"; + ::rtl::OUString sInteraction; + xSyncDbusSessionHelper->InstallPackageNames(0, vPackages, sInteraction); + // Ill be back (hopefully)! + executeRestartDialog(comphelper::getProcessComponentContext(), NULL, RESTART_REASON_BIBLIOGRAPHY_INSTALL); + } + catch (Exception & e) + { + SAL_INFO( + "sfx2.bibliography", + "trying to install LibreOffice Base, caught " << e.Message); + } + } + }; + // lp#527938, debian#602953, fdo#33266, i#105408 + static bool lcl_isBaseAvailable() + { + try + { + // if we get com::sun::star::sdbc::DriverManager, libsdbc2 is there + // and the bibliography is assumed to work + return com::sun::star::sdbc::DriverManager::create(comphelper::getProcessComponentContext()).is(); + } + catch (Exception & e) + { + SAL_INFO( + "sfx2.bibliography", + "assuming Base to be missing; caught " << e.Message); + return false; + } + } + static void lcl_tryLoadBibliography() + { + // lp#527938, debian#602953, fdo#33266, i#105408 + // make sure we actually can instanciate services from base first + //if(!lcl_isBaseAvailable()) + { + BaseInstallerPhoenix *pBaseInstallerPhoenix = new BaseInstallerPhoenix(); + pBaseInstallerPhoenix->create(); + return; + } + SfxStringItem aURL(SID_FILE_NAME, rtl::OUString(".component:Bibliography/View1")); + SfxStringItem aRef(SID_REFERER, rtl::OUString("private:user")); + SfxStringItem aTarget(SID_TARGETNAME, rtl::OUString("_blank")); + SfxViewFrame::Current()->GetDispatcher()->Execute( SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, &aURL, &aRef, &aTarget, 0L); + } +} /// Find the correct location of the document (LICENSE.odt, etc.), and return /// it in rURL if found. static sal_Bool checkURL( const char *pName, const char *pExt, rtl::OUString &rURL ) @@ -1408,12 +1471,7 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) break; case SID_COMP_BIBLIOGRAPHY: - { - SfxStringItem aURL(SID_FILE_NAME, rtl::OUString(".component:Bibliography/View1")); - SfxStringItem aRef(SID_REFERER, rtl::OUString("private:user")); - SfxStringItem aTarget(SID_TARGETNAME, rtl::OUString("_blank")); - SfxViewFrame::Current()->GetDispatcher()->Execute( SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, &aURL, &aRef, &aTarget, 0L); - } + lcl_tryLoadBibliography(); break; } } -- cgit