Kaydet (Commit) 7a092e25 authored tarafından Caolán McNamara's avatar Caolán McNamara

Resolves: tdf#124698 bubble down parent for modal dialog

Change-Id: If03c6ff8043bb39f2efdf4cde19d8277886bf36f
Reviewed-on: https://gerrit.libreoffice.org/70658
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 1453c2c8
......@@ -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;
......
......@@ -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 );
......
......@@ -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
......
......@@ -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);
......
......@@ -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);
}
......
......@@ -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 \
......
......@@ -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
{
......
......@@ -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() ) )
{
......
/* -*- 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: */
/* -*- 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: */
......@@ -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 );
}
......
......@@ -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)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment