framework/inc/dispatch/dispatchprovider.hxx   |    2 ++
 framework/inc/dispatch/interceptionhelper.hxx |    2 ++
 framework/source/services/frame.cxx           |   11 +++++++++++
 3 files changed, 15 insertions(+)

New commits:
commit de1e46fcda2b8b805891baeec09228b5846ed34a
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Mon Dec 12 16:10:05 2022 +0100
Commit:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
CommitDate: Thu Dec 15 19:45:35 2022 +0000

    tdf#151376 framework: fix calling in-document macros with reused frames
    
    The bugdoc has a macro in it, and after closing the document -> start
    center -> opening it again, you could no longer trigger the macro by
    clicking on the URL field in the Calc cell.
    
    The problem is that we cache protocol handler instances since
    3f768cddd28a2f04eb1ffa30bed4474deb6fbfc4 (framework: avoid re-creating
    protocol handler instances all the time, 2022-05-02) in frames, but we
    failed to invalidate this cache when the component of the frame changes.
    
    Fix the problem by clearing the cache in XFrameImpl::setComponent(),
    which gets called in this somewhat rare case when a frame gets reused to
    host a different component.
    
    [ No testcase, I'm not sure how to close a document without disposing
    its XFrame from code. ]
    
    (cherry picked from commit 4bcf6d9c905e7b5558ee8d9f7f616ce61eadb8f8)
    
    Change-Id: I73ee83ec017f476803010cbf9e514315fc797371
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144036
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    (cherry picked from commit 961a322ec0a754b0c372a32de81a8e4c5f2190ea)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144177
    Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>

diff --git a/framework/inc/dispatch/dispatchprovider.hxx 
b/framework/inc/dispatch/dispatchprovider.hxx
index 3b544807337c..c6656948ebee 100644
--- a/framework/inc/dispatch/dispatchprovider.hxx
+++ b/framework/inc/dispatch/dispatchprovider.hxx
@@ -88,6 +88,8 @@ class DispatchProvider final : public ::cppu::WeakImplHelper< 
css::frame::XDispa
                                                                                
                                    sal_Int32                                   
          nSearchFlags     ) override;
         virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch 
> > SAL_CALL queryDispatches( const css::uno::Sequence< 
css::frame::DispatchDescriptor >& lDescriptions    ) override;
 
+        void ClearProtocolHandlers() { m_aProtocolHandlers.clear(); }
+
     /* helper */
     private:
         // Let him protected! So nobody can use us as base ...
diff --git a/framework/inc/dispatch/interceptionhelper.hxx 
b/framework/inc/dispatch/interceptionhelper.hxx
index a1a4cfc0b3e1..fda3a81dd949 100644
--- a/framework/inc/dispatch/interceptionhelper.hxx
+++ b/framework/inc/dispatch/interceptionhelper.hxx
@@ -248,6 +248,8 @@ class InterceptionHelper final : public  
::cppu::WeakImplHelper<
          */
         virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) 
override;
 
+        css::uno::Reference<css::frame::XDispatchProvider> GetSlave() const { 
return m_xSlave; }
+
 }; // class InterceptionHelper
 
 } // namespace framework
diff --git a/framework/source/services/frame.cxx 
b/framework/source/services/frame.cxx
index d722b5e0b98d..5fc6309aa450 100644
--- a/framework/source/services/frame.cxx
+++ b/framework/source/services/frame.cxx
@@ -1475,6 +1475,17 @@ sal_Bool SAL_CALL XFrameImpl::setComponent(const 
css::uno::Reference< css::awt::
         {
             SolarMutexGuard aWriteLock;
             m_xController = nullptr;
+
+            auto pInterceptionHelper = 
dynamic_cast<InterceptionHelper*>(m_xDispatchHelper.get());
+            if (pInterceptionHelper)
+            {
+                css::uno::Reference<css::frame::XDispatchProvider> 
xDispatchProvider = pInterceptionHelper->GetSlave();
+                auto pDispatchProvider = 
dynamic_cast<DispatchProvider*>(xDispatchProvider.get());
+                if (pDispatchProvider)
+                {
+                    pDispatchProvider->ClearProtocolHandlers();
+                }
+            }
         }
         /* } SAFE */
 

Reply via email to