[Libreoffice-commits] core.git: include/sfx2 sfx2/source svx/source sw/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue May 12 14:11:22 UTC 2020


 include/sfx2/linkmgr.hxx            |    9 ++++-----
 sfx2/source/appl/linkmgr2.cxx       |    8 ++++++--
 svx/source/svdraw/svdograf.cxx      |    9 +--------
 sw/source/core/docnode/swbaslnk.cxx |   10 ++--------
 4 files changed, 13 insertions(+), 23 deletions(-)

New commits:
commit 19edcfe36b32b15f86cba1eead7932b610e70ce7
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon May 11 17:17:26 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue May 12 16:10:37 2020 +0200

    always use the LinkManager's persist as the known referer
    
    Change-Id: Ibb1bd9138993adbd8391b524c0cd654ba523cad2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94006
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/sfx2/linkmgr.hxx b/include/sfx2/linkmgr.hxx
index 4940a0a18625..deb9f00c0797 100644
--- a/include/sfx2/linkmgr.hxx
+++ b/include/sfx2/linkmgr.hxx
@@ -155,11 +155,10 @@ public:
 
     // if the mimetype says graphic/bitmap/gdimetafile then get the
     // graphic from the Any. Return says no errors
-    static bool GetGraphicFromAny(const OUString& rMimeType,
-                                  const css::uno::Any & rValue,
-                                  const OUString& rReferer,
-                                  Graphic& rGrf,
-                                  weld::Window* pParentWin);
+    bool GetGraphicFromAny(const OUString& rMimeType,
+                           const css::uno::Any & rValue,
+                           Graphic& rGrf,
+                           weld::Window* pParentWin);
 
 private:
                 LinkManager( const LinkManager& ) = delete;
diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx
index 4c5af8b85cda..8245f6da66ec 100644
--- a/sfx2/source/appl/linkmgr2.cxx
+++ b/sfx2/source/appl/linkmgr2.cxx
@@ -508,7 +508,6 @@ SotClipboardFormatId LinkManager::RegisterStatusInfoId()
 
 bool LinkManager::GetGraphicFromAny(const OUString& rMimeType,
                                     const css::uno::Any & rValue,
-                                    const OUString& rReferer,
                                     Graphic& rGraphic,
                                     weld::Window* pParentWin)
 {
@@ -519,8 +518,13 @@ bool LinkManager::GetGraphicFromAny(const OUString& rMimeType,
 
     if (rValue.has<OUString>())
     {
+        OUString sReferer;
+        SfxObjectShell* sh = GetPersist();
+        if (sh && sh->HasName())
+            sReferer = sh->GetMedium()->GetName();
+
         OUString sURL = rValue.get<OUString>();
-        if (!SvtSecurityOptions().isUntrustedReferer(rReferer))
+        if (!SvtSecurityOptions().isUntrustedReferer(sReferer))
             rGraphic = vcl::graphic::loadFromURL(sURL, pParentWin);
         if (rGraphic.IsNone())
             rGraphic.SetDefaultType();
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index b0a13593845c..3f836d4123cd 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -19,9 +19,7 @@
 
 #include <unotools/streamwrap.hxx>
 
-#include <sfx2/docfile.hxx>
 #include <sfx2/lnkbase.hxx>
-#include <sfx2/objsh.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <tools/helpers.hxx>
 #include <tools/stream.hxx>
@@ -92,13 +90,8 @@ SdrGraphicLink::SdrGraphicLink(SdrGrafObj& rObj)
     {
         sfx2::LinkManager::GetDisplayNames( this, nullptr, &rGrafObj.aFileName, nullptr, &rGrafObj.aFilterName );
 
-        OUString sReferer(rGrafObj.aReferer);
-        SfxObjectShell * sh = pLinkManager->GetPersist();
-        if (sh != nullptr && sh->HasName())
-            sReferer = sh->GetMedium()->GetName();
-
         Graphic aGraphic;
-        if (sfx2::LinkManager::GetGraphicFromAny(rMimeType, rValue, sReferer, aGraphic, nullptr))
+        if (pLinkManager->GetGraphicFromAny(rMimeType, rValue, aGraphic, nullptr))
         {
             rGrafObj.ImpSetLinkedGraphic(aGraphic);
         }
diff --git a/sw/source/core/docnode/swbaslnk.cxx b/sw/source/core/docnode/swbaslnk.cxx
index 404356efb381..8b7832937ead 100644
--- a/sw/source/core/docnode/swbaslnk.cxx
+++ b/sw/source/core/docnode/swbaslnk.cxx
@@ -32,6 +32,7 @@
 #include <frmatr.hxx>
 #include <frmfmt.hxx>
 #include <doc.hxx>
+#include <DocumentLinksAdministrationManager.hxx>
 #include <IDocumentLayoutAccess.hxx>
 #include <pam.hxx>
 #include <swtable.hxx>
@@ -134,17 +135,10 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
 
         Graphic aGrf;
 
-        OUString sReferer;
-        SfxObjectShell * sh = pDoc->GetPersist();
-        if (sh != nullptr && sh->HasName())
-        {
-            sReferer = sh->GetMedium()->GetName();
-        }
-
         // tdf#124698 if any auth dialog is needed, find what the parent window should be
         weld::Window* pDlgParent = GetFrameWeld(pDoc);
 
-        if( sfx2::LinkManager::GetGraphicFromAny(rMimeType, rValue, sReferer, aGrf, pDlgParent) &&
+        if (pDoc->getIDocumentLinksAdministration().GetLinkManager().GetGraphicFromAny(rMimeType, rValue, aGrf, pDlgParent) &&
             ( GraphicType::Default != aGrf.GetType() ||
               GraphicType::Default != rGrfObj.GetType() ) )
         {


More information about the Libreoffice-commits mailing list