diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-04-12 12:07:22 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-04-23 15:11:30 +0200 |
commit | ab401b59209ae6bd0d050558063800409278e8c8 (patch) | |
tree | fd27687df3845060d00a674d019fc0cd426396db | |
parent | b929fd7a369630fa70a74eec3040761cea58b660 (diff) |
Resolves: tdf#124698 bubble down parent for modal dialog
Change-Id: If03c6ff8043bb39f2efdf4cde19d8277886bf36f
Reviewed-on: https://gerrit.libreoffice.org/70677
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | include/sfx2/linkmgr.hxx | 3 | ||||
-rw-r--r-- | include/unotools/ucbstreamhelper.hxx | 8 | ||||
-rw-r--r-- | include/vcl/GraphicLoader.hxx | 7 | ||||
-rw-r--r-- | sfx2/source/appl/linkmgr2.cxx | 5 | ||||
-rw-r--r-- | svx/source/svdraw/svdograf.cxx | 2 | ||||
-rw-r--r-- | sw/Library_sw.mk | 1 | ||||
-rw-r--r-- | sw/source/core/doc/DocumentLinksAdministrationManager.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/docnode/swbaslnk.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/inc/dialoghelp.hxx | 30 | ||||
-rw-r--r-- | sw/source/core/view/dialoghelp.cxx | 48 | ||||
-rw-r--r-- | unotools/source/ucbhelper/ucbstreamhelper.cxx | 16 | ||||
-rw-r--r-- | vcl/source/graphic/GraphicLoader.cxx | 7 |
12 files changed, 115 insertions, 26 deletions
diff --git a/include/sfx2/linkmgr.hxx b/include/sfx2/linkmgr.hxx index 128dd47e4462..02ba1a91875b 100644 --- a/include/sfx2/linkmgr.hxx +++ b/include/sfx2/linkmgr.hxx @@ -159,7 +159,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 05c817ab7855..be6ad47b0a38 100644 --- a/sfx2/source/appl/linkmgr2.cxx +++ b/sfx2/source/appl/linkmgr2.cxx @@ -501,7 +501,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; @@ -512,7 +513,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 c0cebde414b5..38e57ac81694 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 446600957649..f69c69adc337 100644 --- a/sw/Library_sw.mk +++ b/sw/Library_sw.mk @@ -488,6 +488,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 577db70611ff..56dd981d9a48 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> @@ -239,11 +240,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 27f30ba05d9f..ff20ad997a72 100644 --- a/sw/source/core/docnode/swbaslnk.cxx +++ b/sw/source/core/docnode/swbaslnk.cxx @@ -52,6 +52,7 @@ #include <cntfrm.hxx> #include <htmltbl.hxx> #include <calbck.hxx> +#include <dialoghelp.hxx> #include <memory> using namespace com::sun::star; @@ -148,7 +149,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 4cb749306149..33c6529b6a56 100644 --- a/unotools/source/ucbhelper/ucbstreamhelper.cxx +++ b/unotools/source/ucbhelper/ucbstreamhelper.cxx @@ -138,27 +138,25 @@ 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 ) ); - Reference < XInteractionHandler > xIHScoped( static_cast< XInteractionHandler *> ( - new comphelper::SimpleFileAccessInteraction( xIH ) ) ); + 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 ) ); - Reference < XInteractionHandler > xIHScoped( static_cast< XInteractionHandler *> ( - new comphelper::SimpleFileAccessInteraction( xIH ) ) ); + 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) { |