Kaydet (Commit) 8efb69e2 authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen Kaydeden (comit) Björn Michaelsen

move base check for bibliography to sfx2

- 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/1207Reviewed-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@canonical.com>
Tested-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@canonical.com>
üst 847455f9
......@@ -32,7 +32,6 @@
#include <com/sun/star/util/XURLTransformer.hpp>
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
#include <com/sun/star/sdbc/XRowSet.hpp>
#include <com/sun/star/sdbc/DriverManager.hpp>
#include <com/sun/star/sdb/CommandType.hpp>
#include <com/sun/star/frame/XFrameLoader.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
......@@ -44,7 +43,6 @@
#include <com/sun/star/form/XLoadListener.hpp>
#include <com/sun/star/frame/XLayoutManager.hpp>
#include <com/sun/star/uno/XAggregation.hpp>
#include <org/freedesktop/PackageKit/SyncDbusSessionHelper.hpp>
#include <toolkit/awt/vclxwindow.hxx>
#include <vcl/window.hxx>
#include <vcl/edit.hxx>
......@@ -233,53 +231,10 @@ void BibliographyLoader::cancel(void) throw (::com::sun::star::uno::RuntimeExcep
//!
}
// -----------------------------------------------------------------------
namespace
{
// 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(
"extensions.bibliography",
"assuming Base to be missing; caught " << e.Message);
return false;
}
}
}
void BibliographyLoader::load(const Reference< XFrame > & rFrame, const rtl::OUString& rURL,
const Sequence< PropertyValue >& rArgs,
const Reference< XLoadEventListener > & rListener) throw (::com::sun::star::uno::RuntimeException)
{
// lp#527938, debian#602953, fdo#33266, i#105408
// make sure we actually can instanciate services from base first
if(!lcl_isBaseAvailable())
{
try
{
using namespace org::freedesktop::PackageKit;
Reference< XSyncDbusSessionHelper > xSyncDbusSessionHelper(SyncDbusSessionHelper::create(comphelper::getProcessComponentContext()));
Sequence< ::rtl::OUString > vPackages(1);
vPackages[0] = "libreoffice-base";
::rtl::OUString sInteraction;
xSyncDbusSessionHelper->InstallPackageNames(0, vPackages, sInteraction);
// FIXME: notify user to restart here
}
catch (Exception & e)
{
SAL_INFO(
"extensions.bibliography",
"trying to install LibreOffice Base, caught " << e.Message);
}
return;
}
SolarMutexGuard aGuard;
......
......@@ -36,6 +36,8 @@
#include <com/sun/star/system/SystemShellExecute.hpp>
#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
#include <com/sun/star/system/SystemShellExecuteException.hpp>
#include <com/sun/star/sdbc/DriverManager.hpp>
#include <org/freedesktop/PackageKit/SyncDbusSessionHelper.hpp>
#include <com/sun/star/frame/XComponentLoader.hpp>
......@@ -45,6 +47,7 @@
#include <svtools/addresstemplate.hxx>
#include <svtools/miscopt.hxx>
#include <svtools/restartdialog.hxx>
#include <svl/visitem.hxx>
#include <unotools/intlwrapper.hxx>
......@@ -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;
}
}
......
......@@ -26,9 +26,12 @@ enum RestartReason {
RESTART_REASON_JAVA,
// "For the selected Java runtime environment to work properly,
// %PRODUCTNAME must be restarted."
RESTART_REASON_PDF_AS_STANDARD_JOB_FORMAT
RESTART_REASON_PDF_AS_STANDARD_JOB_FORMAT,
// For the modified default print job format to take effect,
// %PRODUCTNAME must be restarted.
RESTART_REASON_BIBLIOGRAPHY_INSTALL
// "For the bibliography to work properly,
// %PRODUCTNAME must be restarted."
};
SVT_DLLPUBLIC void executeRestartDialog(
......
......@@ -37,6 +37,9 @@ public:
case svtools::RESTART_REASON_PDF_AS_STANDARD_JOB_FORMAT:
get(reason_, "reason_pdf");
break;
case svtools::RESTART_REASON_BIBLIOGRAPHY_INSTALL:
get(reason_, "reason_bibliography_install");
break;
default:
assert(false); // this cannot happen
}
......
......@@ -90,6 +90,20 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="reason_bibliography_install">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="label" translatable="yes">For the bibliography to work properly, %PRODUCTNAME must be restarted.</property>
<property name="wrap">True</property>
<property name="max_width_chars">50</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label">
<property name="visible">True</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment