[Libreoffice-commits] .: extensions/source sfx2/source svtools/inc svtools/source svtools/uiconfig

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Dec 3 05:35:14 PST 2012


 extensions/source/bibliography/bibload.cxx |   45 ------------------
 sfx2/source/appl/appserv.cxx               |   70 ++++++++++++++++++++++++++---
 svtools/inc/svtools/restartdialog.hxx      |    5 +-
 svtools/source/dialogs/restartdialog.cxx   |    3 +
 svtools/uiconfig/ui/restartdialog.ui       |   14 +++++
 5 files changed, 85 insertions(+), 52 deletions(-)

New commits:
commit 8efb69e260ecbcde5ee67ab41ed7a9630783c29a
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Fri Nov 30 19:37:07 2012 +0100

    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/1207
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>
    Tested-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>

diff --git a/extensions/source/bibliography/bibload.cxx b/extensions/source/bibliography/bibload.cxx
index 2436791..537010e 100644
--- a/extensions/source/bibliography/bibload.cxx
+++ b/extensions/source/bibliography/bibload.cxx
@@ -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;
     
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx
index b85612b..57029cf 100644
--- a/sfx2/source/appl/appserv.cxx
+++ b/sfx2/source/appl/appserv.cxx
@@ -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;
     }
 }
diff --git a/svtools/inc/svtools/restartdialog.hxx b/svtools/inc/svtools/restartdialog.hxx
index 91ff4ea..63a4e8e 100644
--- a/svtools/inc/svtools/restartdialog.hxx
+++ b/svtools/inc/svtools/restartdialog.hxx
@@ -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(
diff --git a/svtools/source/dialogs/restartdialog.cxx b/svtools/source/dialogs/restartdialog.cxx
index faf05df..e5d64de 100644
--- a/svtools/source/dialogs/restartdialog.cxx
+++ b/svtools/source/dialogs/restartdialog.cxx
@@ -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
         }
diff --git a/svtools/uiconfig/ui/restartdialog.ui b/svtools/uiconfig/ui/restartdialog.ui
index 856dee6..f31af2e 100644
--- a/svtools/uiconfig/ui/restartdialog.ui
+++ b/svtools/uiconfig/ui/restartdialog.ui
@@ -91,6 +91,20 @@
               </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>
                 <property name="can_focus">False</property>


More information about the Libreoffice-commits mailing list