[Libreoffice-commits] core.git: Branch 'feature/cib_contract57' - 2 commits - framework/source offapi/com

Samuel Mehrbrodt Samuel.Mehrbrodt at cib.de
Tue Sep 20 07:24:07 UTC 2016


 framework/source/dispatch/closedispatcher.cxx          |   28 ++++++++++++-----
 framework/source/services/desktop.cxx                  |   13 ++++---
 offapi/com/sun/star/frame/TerminationVetoException.idl |    4 ++
 3 files changed, 31 insertions(+), 14 deletions(-)

New commits:
commit de2533cdcdce5a065cc10444c63dce81d1d5029e
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date:   Mon Sep 19 17:05:36 2016 +0200

    tdf#102288 TerminationVetoException should only prevent termination
    
    When using a TerminationVetoException, all windows should be closed,
    but the process should be kept running.
    
    Change-Id: I71b0b57b6035a36f0325c8dea3cd38309408f176

diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx
index 24b9761..9090f83 100644
--- a/framework/source/services/desktop.cxx
+++ b/framework/source/services/desktop.cxx
@@ -219,9 +219,14 @@ sal_Bool SAL_CALL Desktop::terminate()
 
     aReadLock.clear();
 
-    // Ask normal terminate listener. They could stop terminate without closing any open document.
+    // try to close all open frames.
+    // Allow using of any UI ... because Desktop.terminate() was designed as UI functionality in the past.
+    bool bAllowUI      = true;
+    bool bFramesClosed = impl_closeFrames(bAllowUI);
+
+    // Ask normal terminate listener. They could stop terminating the process.
     Desktop::TTerminateListenerList lCalledTerminationListener;
-    bool                      bVeto = false;
+    bool bVeto = false;
     impl_sendQueryTerminationEvent(lCalledTerminationListener, bVeto);
     if ( bVeto )
     {
@@ -229,10 +234,6 @@ sal_Bool SAL_CALL Desktop::terminate()
         return sal_False;
     }
 
-    // try to close all open frames.
-    // Allow using of any UI ... because Desktop.terminate() was designed as UI functionality in the past.
-    bool bAllowUI      = true;
-    bool bFramesClosed = impl_closeFrames(bAllowUI);
     if ( ! bFramesClosed )
     {
         impl_sendCancelTerminationEvent(lCalledTerminationListener);
diff --git a/offapi/com/sun/star/frame/TerminationVetoException.idl b/offapi/com/sun/star/frame/TerminationVetoException.idl
index 99f58d5..135c9c1 100644
--- a/offapi/com/sun/star/frame/TerminationVetoException.idl
+++ b/offapi/com/sun/star/frame/TerminationVetoException.idl
@@ -33,6 +33,10 @@
     After his own operation will be finished, he MUST try to terminate the
     office again. Any other veto listener can intercept that again or office
     will die really.
+
+    Since LibreOffice 5.3:
+    Throwing this exception will only prevent *termination*.
+    Exiting LibreOffice will close all the windows, but the process will keep running.
     </p>
 
     @see XDesktop::terminate()
commit 057f9de9edeac31b2492fb52dc4cdd89d0e3ae0e
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date:   Mon Sep 19 13:08:23 2016 +0200

    tdf#102274 Closing LibreOffice should not kill active UNO connections
    
    When closing the last window, check whether there are active UNO connections.
    If that's the case, just close the window, don't terminate the application
    so that the connected application keeps working.
    
    This doesn't affect the behavior of "File->Exit LibreOffice". In that case,
    the application still gets terminated and existing connections are closed.
    
    Change-Id: If2d22d51c9b566be8abd51969f35c80896ed4767

diff --git a/framework/source/dispatch/closedispatcher.cxx b/framework/source/dispatch/closedispatcher.cxx
index 9bfd558..14537bd 100644
--- a/framework/source/dispatch/closedispatcher.cxx
+++ b/framework/source/dispatch/closedispatcher.cxx
@@ -23,6 +23,8 @@
 #include <services.h>
 #include <general.h>
 
+#include <com/sun/star/bridge/BridgeFactory.hpp>
+#include <com/sun/star/bridge/XBridgeFactory2.hpp>
 #include <com/sun/star/frame/Desktop.hpp>
 #include <com/sun/star/frame/XController.hpp>
 #include <com/sun/star/frame/CommandGroup.hpp>
@@ -278,6 +280,12 @@ IMPL_LINK_NOARG(CloseDispatcher, impl_asyncCallback)
     bool bCloseFrame           = false;
     bool bEstablishBackingMode = false;
     bool bTerminateApp         = false;
+    bool bHasActiveConnections = false;
+
+    css::uno::Reference<css::bridge::XBridgeFactory2> bridgeFac( css::bridge::BridgeFactory::create(xContext) );
+    const css::uno::Sequence< css::uno::Reference<css::bridge::XBridge> >seqBridges = bridgeFac->getExistingBridges();
+    bHasActiveConnections = seqBridges.getLength() > 0;
+
 
     // Analyze the environment a first time.
     // If we found some special cases, we can
@@ -302,13 +310,15 @@ IMPL_LINK_NOARG(CloseDispatcher, impl_asyncCallback)
     else if (aCheck1.m_bReferenceIsHelp)
         bCloseFrame = true;
 
-    // c) If we are already in "backing mode", we have to terminate
-    //    the application, if this special frame is closed.
-    //    It doesn't matter, how many other frames (can be the help or hidden frames only)
-    //    are open then.
-    //    => terminate the application!
-    else if (aCheck1.m_bReferenceIsBacking)
-        bTerminateApp = true;
+    // c) If we are already in "backing mode", we terminate the application, if no active UNO connections are found.
+    //    If there is an active UNO connection, we only close the frame and leave the application alive.
+    //    It doesn't matter, how many other frames (can be the help or hidden frames only) are open then.
+    else if (aCheck1.m_bReferenceIsBacking) {
+        if (bHasActiveConnections)
+            bCloseFrame = true;
+        else
+            bTerminateApp = true;
+    }
 
     // d) Otherwhise we have to: close all views to the same document, close the
     //    document inside our own frame and decide then again, what has to be done!
@@ -344,7 +354,9 @@ IMPL_LINK_NOARG(CloseDispatcher, impl_asyncCallback)
             //     application or establish the backing mode now.
             //     And that depends from the dispatched URL ...
             {
-                if (eOperation == E_CLOSE_FRAME)
+                if (bHasActiveConnections)
+                    bCloseFrame = true;
+                else if (eOperation == E_CLOSE_FRAME)
                     bTerminateApp = true;
                 else if( SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::EModule::STARTMODULE) )
                     bEstablishBackingMode = true;


More information about the Libreoffice-commits mailing list