summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sfx2/linkmgr.hxx3
-rw-r--r--include/unotools/ucbstreamhelper.hxx8
-rw-r--r--include/vcl/GraphicLoader.hxx7
-rw-r--r--sfx2/source/appl/linkmgr2.cxx5
-rw-r--r--svx/source/svdraw/svdograf.cxx2
-rw-r--r--sw/Library_sw.mk1
-rw-r--r--sw/source/core/doc/DocumentLinksAdministrationManager.cxx8
-rw-r--r--sw/source/core/docnode/swbaslnk.cxx6
-rw-r--r--sw/source/core/inc/dialoghelp.hxx30
-rw-r--r--sw/source/core/view/dialoghelp.cxx48
-rw-r--r--unotools/source/ucbhelper/ucbstreamhelper.cxx10
-rw-r--r--vcl/source/graphic/GraphicLoader.cxx7
12 files changed, 113 insertions, 22 deletions
diff --git a/include/sfx2/linkmgr.hxx b/include/sfx2/linkmgr.hxx
index 2646d2d61cdd..7f3bf021eeed 100644
--- a/include/sfx2/linkmgr.hxx
+++ b/include/sfx2/linkmgr.hxx
@@ -158,7 +158,8 @@ public:
static bool GetGraphicFromAny(const OUString& rMimeType,
const css::uno::Any & rValue,
const OUString& rReferer,
- Graphic& rGrf);
+ Graphic& rGrf,
+ weld::Window* pParentWin);
private:
LinkManager( const LinkManager& ) = delete;
diff --git a/include/unotools/ucbstreamhelper.hxx b/include/unotools/ucbstreamhelper.hxx
index fd0a8cd13bad..0d7d867d21f6 100644
--- a/include/unotools/ucbstreamhelper.hxx
+++ b/include/unotools/ucbstreamhelper.hxx
@@ -19,6 +19,8 @@
#ifndef INCLUDED_UNOTOOLS_UCBSTREAMHELPER_HXX
#define INCLUDED_UNOTOOLS_UCBSTREAMHELPER_HXX
+#include <com/sun/star/awt/XWindow.hpp>
+
#include <unotools/unotoolsdllapi.h>
#include <tools/stream.hxx>
@@ -45,9 +47,9 @@ namespace utl
class UNOTOOLS_DLLPUBLIC UcbStreamHelper
{
public:
- static std::unique_ptr<SvStream> CreateStream( const OUString& rFileName, StreamMode eOpenMode );
- static std::unique_ptr<SvStream> CreateStream( const OUString& rFileName, StreamMode eOpenMode,
- bool bFileExists );
+ static std::unique_ptr<SvStream> CreateStream(const OUString& rFileName, StreamMode eOpenMode, css::uno::Reference<css::awt::XWindow> xParentWin = nullptr);
+ static std::unique_ptr<SvStream> CreateStream(const OUString& rFileName, StreamMode eOpenMode,
+ bool bFileExists, css::uno::Reference<css::awt::XWindow> xParentWin = nullptr);
static std::unique_ptr<SvStream> CreateStream( const css::uno::Reference < css::io::XInputStream >& xStream );
static std::unique_ptr<SvStream> CreateStream( const css::uno::Reference < css::io::XStream >& xStream );
static std::unique_ptr<SvStream> CreateStream( const css::uno::Reference < css::io::XInputStream >& xStream, bool bCloseStream );
diff --git a/include/vcl/GraphicLoader.hxx b/include/vcl/GraphicLoader.hxx
index 9b96ec13b8a2..5cca83a99d94 100644
--- a/include/vcl/GraphicLoader.hxx
+++ b/include/vcl/GraphicLoader.hxx
@@ -12,11 +12,16 @@
#include <vcl/graph.hxx>
+namespace weld
+{
+class Window;
+}
+
namespace vcl
{
namespace graphic
{
-Graphic VCL_DLLPUBLIC loadFromURL(OUString const& rURL);
+Graphic VCL_DLLPUBLIC loadFromURL(OUString const& rURL, weld::Window* pParentWin = nullptr);
}
} // end vcl::graphic
diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx
index 459ded0e88b3..965417572ba5 100644
--- a/sfx2/source/appl/linkmgr2.cxx
+++ b/sfx2/source/appl/linkmgr2.cxx
@@ -502,7 +502,8 @@ SotClipboardFormatId LinkManager::RegisterStatusInfoId()
bool LinkManager::GetGraphicFromAny(const OUString& rMimeType,
const css::uno::Any & rValue,
const OUString& rReferer,
- Graphic& rGraphic )
+ Graphic& rGraphic,
+ weld::Window* pParentWin)
{
bool bRet = false;
@@ -513,7 +514,7 @@ bool LinkManager::GetGraphicFromAny(const OUString& rMimeType,
{
OUString sURL = rValue.get<OUString>();
if (!SvtSecurityOptions().isUntrustedReferer(rReferer))
- rGraphic = vcl::graphic::loadFromURL(sURL);
+ rGraphic = vcl::graphic::loadFromURL(sURL, pParentWin);
if (!rGraphic)
rGraphic.SetDefaultType();
rGraphic.setOriginURL(sURL);
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index c8eb04b37d3a..73601570b4a8 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -103,7 +103,7 @@ SdrGraphicLink::SdrGraphicLink(SdrGrafObj& rObj)
sfx2::LinkManager::GetDisplayNames( this, nullptr, &rGrafObj.aFileName, nullptr, &rGrafObj.aFilterName );
Graphic aGraphic;
- if (sfx2::LinkManager::GetGraphicFromAny(rMimeType, rValue, getReferer(), aGraphic))
+ if (sfx2::LinkManager::GetGraphicFromAny(rMimeType, rValue, getReferer(), aGraphic, nullptr))
{
rGrafObj.ImpSetLinkedGraphic(aGraphic);
}
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 1cd8d8cb1613..9f92d20e643f 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -489,6 +489,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
sw/source/core/unocore/unotbl \
sw/source/core/unocore/unotext \
sw/source/core/unocore/unotextmarkup \
+ sw/source/core/view/dialoghelp \
sw/source/core/view/pagepreviewlayout \
sw/source/core/view/printdata \
sw/source/core/view/vdraw \
diff --git a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
index 018ca3e0e6a6..65f0319936bd 100644
--- a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
+++ b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
@@ -29,6 +29,7 @@
#include <sfx2/linkmgr.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/frame.hxx>
+#include <dialoghelp.hxx>
#include <linkenum.hxx>
#include <com/sun/star/document/UpdateDocMode.hpp>
#include <swtypes.hxx>
@@ -237,11 +238,8 @@ void DocumentLinksAdministrationManager::UpdateLinks()
{
rEmbeddedObjectContainer.setUserAllowsLinkUpdate(true);
- SfxMedium* pMedium = m_rDoc.GetDocShell()->GetMedium();
- SfxFrame* pFrame = pMedium ? pMedium->GetLoadTargetFrame() : nullptr;
- weld::Window* pDlgParent = pFrame ? pFrame->GetWindow().GetFrameWeld() : nullptr;
-
- GetLinkManager().UpdateAllLinks( bAskUpdate, false, pDlgParent );
+ weld::Window* pDlgParent = GetFrameWeld(m_rDoc.GetDocShell());
+ GetLinkManager().UpdateAllLinks(bAskUpdate, false, pDlgParent);
}
else
{
diff --git a/sw/source/core/docnode/swbaslnk.cxx b/sw/source/core/docnode/swbaslnk.cxx
index 7d0edf5fedf0..8957ac4a8a69 100644
--- a/sw/source/core/docnode/swbaslnk.cxx
+++ b/sw/source/core/docnode/swbaslnk.cxx
@@ -53,6 +53,7 @@
#include <cntfrm.hxx>
#include <htmltbl.hxx>
#include <calbck.hxx>
+#include <dialoghelp.hxx>
#include <memory>
using namespace com::sun::star;
@@ -149,7 +150,10 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
sReferer = sh->GetMedium()->GetName();
}
- if( sfx2::LinkManager::GetGraphicFromAny(rMimeType, rValue, sReferer, aGrf) &&
+ // 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) &&
( GraphicType::Default != aGrf.GetType() ||
GraphicType::Default != rGrfObj.GetType() ) )
{
diff --git a/sw/source/core/inc/dialoghelp.hxx b/sw/source/core/inc/dialoghelp.hxx
new file mode 100644
index 000000000000..ce9c0721055f
--- /dev/null
+++ b/sw/source/core/inc/dialoghelp.hxx
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SW_SOURCE_CORE_INC_DIALOGHELP_HXX
+#define INCLUDED_SW_SOURCE_CORE_INC_DIALOGHELP_HXX
+
+class SwDoc;
+class SwDocShell;
+class SfxFrame;
+class SfxMedium;
+
+namespace weld
+{
+class Window;
+}
+
+weld::Window* GetFrameWeld(SfxFrame* pFrame);
+weld::Window* GetFrameWeld(SfxMedium* pMedium);
+weld::Window* GetFrameWeld(SwDocShell* pDocSh);
+weld::Window* GetFrameWeld(SwDoc* pDoc);
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sw/source/core/view/dialoghelp.cxx b/sw/source/core/view/dialoghelp.cxx
new file mode 100644
index 000000000000..0ee765845b29
--- /dev/null
+++ b/sw/source/core/view/dialoghelp.cxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <sfx2/docfile.hxx>
+#include <sfx2/frame.hxx>
+#include <vcl/weld.hxx>
+#include <vcl/window.hxx>
+
+#include <dialoghelp.hxx>
+#include <doc.hxx>
+#include <docsh.hxx>
+#include <view.hxx>
+
+weld::Window* GetFrameWeld(SfxFrame* pFrame)
+{
+ return pFrame ? pFrame->GetWindow().GetFrameWeld() : nullptr;
+}
+
+weld::Window* GetFrameWeld(SfxMedium* pMedium)
+{
+ return GetFrameWeld(pMedium ? pMedium->GetLoadTargetFrame() : nullptr);
+}
+
+weld::Window* GetFrameWeld(SwDocShell* pDocShell)
+{
+ if (!pDocShell)
+ return nullptr;
+ weld::Window* pRet = GetFrameWeld(pDocShell->GetMedium());
+ if (!pRet)
+ {
+ if (SwView* pView = pDocShell->GetView())
+ pRet = pView->GetFrameWeld();
+ }
+ return pRet;
+}
+
+weld::Window* GetFrameWeld(SwDoc* pDoc)
+{
+ return GetFrameWeld(pDoc ? pDoc->GetDocShell() : nullptr);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/unotools/source/ucbhelper/ucbstreamhelper.cxx b/unotools/source/ucbhelper/ucbstreamhelper.cxx
index 94d884564146..33c6529b6a56 100644
--- a/unotools/source/ucbhelper/ucbstreamhelper.cxx
+++ b/unotools/source/ucbhelper/ucbstreamhelper.cxx
@@ -138,24 +138,24 @@ static std::unique_ptr<SvStream> lcl_CreateStream( const OUString& rFileName, St
return pStream;
}
-std::unique_ptr<SvStream> UcbStreamHelper::CreateStream( const OUString& rFileName, StreamMode eOpenMode )
+std::unique_ptr<SvStream> UcbStreamHelper::CreateStream(const OUString& rFileName, StreamMode eOpenMode, css::uno::Reference<css::awt::XWindow> xParentWin)
{
// related tdf#99312
// create a specialized interaction handler to manages Web certificates and Web credentials when needed
Reference< XInteractionHandler > xIH(
- css::task::InteractionHandler::createWithParent( comphelper::getProcessComponentContext(), nullptr ) );
+ css::task::InteractionHandler::createWithParent(comphelper::getProcessComponentContext(), xParentWin));
Reference<XInteractionHandler> xIHScoped(new comphelper::SimpleFileAccessInteraction(xIH));
return lcl_CreateStream( rFileName, eOpenMode, xIHScoped, true /* bEnsureFileExists */ );
}
-std::unique_ptr<SvStream> UcbStreamHelper::CreateStream( const OUString& rFileName, StreamMode eOpenMode,
- bool bFileExists )
+std::unique_ptr<SvStream> UcbStreamHelper::CreateStream(const OUString& rFileName, StreamMode eOpenMode,
+ bool bFileExists, css::uno::Reference<css::awt::XWindow> xParentWin)
{
// related tdf#99312
// create a specialized interaction handler to manages Web certificates and Web credentials when needed
Reference< XInteractionHandler > xIH(
- css::task::InteractionHandler::createWithParent( comphelper::getProcessComponentContext(), nullptr ) );
+ css::task::InteractionHandler::createWithParent(comphelper::getProcessComponentContext(), xParentWin));
Reference<XInteractionHandler> xIHScoped(new comphelper::SimpleFileAccessInteraction(xIH));
return lcl_CreateStream( rFileName, eOpenMode, xIHScoped,!bFileExists );
}
diff --git a/vcl/source/graphic/GraphicLoader.cxx b/vcl/source/graphic/GraphicLoader.cxx
index 770cb2158fba..8343b513942a 100644
--- a/vcl/source/graphic/GraphicLoader.cxx
+++ b/vcl/source/graphic/GraphicLoader.cxx
@@ -12,6 +12,7 @@
#include <unotools/ucbstreamhelper.hxx>
#include <vcl/graphicfilter.hxx>
+#include <vcl/weld.hxx>
#include <vcl/wmf.hxx>
using namespace css;
@@ -20,12 +21,12 @@ namespace vcl
{
namespace graphic
{
-Graphic loadFromURL(OUString const& rURL)
+Graphic loadFromURL(OUString const& rURL, weld::Window* pParentWin)
{
Graphic aGraphic;
- std::unique_ptr<SvStream> pInputStream
- = utl::UcbStreamHelper::CreateStream(rURL, StreamMode::READ);
+ std::unique_ptr<SvStream> pInputStream = utl::UcbStreamHelper::CreateStream(
+ rURL, StreamMode::READ, pParentWin ? pParentWin->GetXWindow() : nullptr);
if (pInputStream)
{