[Libreoffice-commits] core.git: forms/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon May 11 14:57:34 UTC 2020


 forms/source/component/clickableimage.cxx |   90 ++++++++++++++++--------------
 forms/source/component/clickableimage.hxx |    5 +
 2 files changed, 51 insertions(+), 44 deletions(-)

New commits:
commit 318d5bf2a3d70300268c778074919fa908a0dcee
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon May 11 13:44:44 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon May 11 16:56:52 2020 +0200

    factor out finding the matching SfxObjectShell
    
    Change-Id: I8d73e55e8fe836f495a44a0e24ac085f15bfcf4b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93965
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/forms/source/component/clickableimage.cxx b/forms/source/component/clickableimage.cxx
index e606ea2f549e..a78b1908fc65 100644
--- a/forms/source/component/clickableimage.cxx
+++ b/forms/source/component/clickableimage.cxx
@@ -684,6 +684,52 @@ namespace frm
         }
     }
 
+    SfxObjectShell* OClickableImageBaseModel::GetObjectShell()
+    {
+        // Find the XModel to get to the Object shell or at least the
+        // Referer.
+        // There's only a Model if we load HTML documents and the URL is
+        // changed in a document that is already loaded. There's no way
+        // we can get to the Model during loading.
+        Reference< XModel >  xModel;
+        css::uno::Reference<css::uno::XInterface>  xIfc( *this );
+        while( !xModel.is() && xIfc.is() )
+        {
+            Reference<XChild>  xChild( xIfc, UNO_QUERY );
+            xIfc = xChild->getParent();
+            xModel.set(xIfc, css::uno::UNO_QUERY);
+        }
+
+        // Search for the Object shell by iterating over all Object shells
+        // and comparing their XModel to ours.
+        // As an optimization, we try the current Object shell first.
+        SfxObjectShell *pObjSh = nullptr;
+
+        if( xModel.is() )
+        {
+            SfxObjectShell *pTestObjSh = SfxObjectShell::Current();
+            if( pTestObjSh )
+            {
+                Reference< XModel >  xTestModel = pTestObjSh->GetModel();
+                if( xTestModel == xModel )
+                    pObjSh = pTestObjSh;
+            }
+            if( !pObjSh )
+            {
+                pTestObjSh = SfxObjectShell::GetFirst();
+                while( !pObjSh && pTestObjSh )
+                {
+                    Reference< XModel > xTestModel = pTestObjSh->GetModel();
+                    if( xTestModel == xModel )
+                        pObjSh = pTestObjSh;
+                    else
+                        pTestObjSh = SfxObjectShell::GetNext( *pTestObjSh );
+                }
+            }
+        }
+
+        return pObjSh;
+    }
 
     void OClickableImageBaseModel::SetURL( const OUString& rURL )
     {
@@ -701,50 +747,10 @@ namespace frm
             return;
 
         if (!rURL.isEmpty() && !::svt::GraphicAccess::isSupportedURL( rURL ) )
-       {
+        {
             m_pMedium.reset(new SfxMedium(rURL, StreamMode::STD_READ));
 
-            // Find the XModel to get to the Object shell or at least the
-            // Referer.
-            // There's only a Model if we load HTML documents and the URL is
-            // changed in a document that is already loaded. There's no way
-            // we can get to the Model during loading.
-            Reference< XModel >  xModel;
-            css::uno::Reference<css::uno::XInterface>  xIfc( *this );
-            while( !xModel.is() && xIfc.is() )
-            {
-                Reference<XChild>  xChild( xIfc, UNO_QUERY );
-                xIfc = xChild->getParent();
-                xModel.set(xIfc, css::uno::UNO_QUERY);
-            }
-
-            // Search for the Object shell by iterating over all Object shells
-            // and comparing their XModel to ours.
-            // As an optimization, we try the current Object shell first.
-            SfxObjectShell *pObjSh = nullptr;
-
-            if( xModel.is() )
-            {
-                SfxObjectShell *pTestObjSh = SfxObjectShell::Current();
-                if( pTestObjSh )
-                {
-                    Reference< XModel >  xTestModel = pTestObjSh->GetModel();
-                    if( xTestModel == xModel )
-                        pObjSh = pTestObjSh;
-                }
-                if( !pObjSh )
-                {
-                    pTestObjSh = SfxObjectShell::GetFirst();
-                    while( !pObjSh && pTestObjSh )
-                    {
-                        Reference< XModel > xTestModel = pTestObjSh->GetModel();
-                        if( xTestModel == xModel )
-                            pObjSh = pTestObjSh;
-                        else
-                            pTestObjSh = SfxObjectShell::GetNext( *pTestObjSh );
-                    }
-                }
-            }
+            SfxObjectShell *pObjSh = GetObjectShell();
 
     #ifdef USE_REGISTER_TRANSFER
             if( pObjSh )
diff --git a/forms/source/component/clickableimage.hxx b/forms/source/component/clickableimage.hxx
index d4a5065e0383..ad823c4209ac 100644
--- a/forms/source/component/clickableimage.hxx
+++ b/forms/source/component/clickableimage.hxx
@@ -35,9 +35,8 @@
 #include <com/sun/star/graphic/XGraphicObject.hpp>
 #include <cppuhelper/implbase3.hxx>
 
-
 class SfxMedium;
-
+class SfxObjectShell;
 
 namespace frm
 {
@@ -148,6 +147,8 @@ namespace frm
         // to be called from within the cloning-ctor of your derived class
         void implInitializeImageURL( );
 
+        SfxObjectShell* GetObjectShell();
+
         DECL_LINK( OnImageImportDone, ::Graphic*, void );
     };
 


More information about the Libreoffice-commits mailing list