Kaydet (Commit) 4dba9820 authored tarafından Caolán McNamara's avatar Caolán McNamara

rework tdf#113647 solution to be safe

rather than passing the pointer around, tragic use of uno apis means monstrous
awt::Window thingy has to be passed around and still smuggled through the
dispatch arguments to get through the eye of the XDispatch::dispatch needle

Change-Id: I353f8a3b0bb698bb58f75576e49efd701f3db8bf
Reviewed-on: https://gerrit.libreoffice.org/44585Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 4c9349ae
...@@ -124,11 +124,12 @@ public: ...@@ -124,11 +124,12 @@ public:
sal_uInt16 nModi = 0, sal_uInt16 nModi = 0,
const SfxPoolItem **pInternalArgs = nullptr); const SfxPoolItem **pInternalArgs = nullptr);
const SfxPoolItem* Execute( sal_uInt16 nSlot, const SfxPoolItem* Execute(sal_uInt16 nSlot,
SfxCallMode nCall, SfxCallMode nCall,
SfxItemSet const * pArgs, SfxItemSet const * pArgs,
SfxItemSet const * pInternalArgs, SfxItemSet const * pInternalArgs,
sal_uInt16 nModi); sal_uInt16 nModi,
vcl::Window* pDialogParent = nullptr);
const SfxPoolItem* ExecuteList( sal_uInt16 nSlot, const SfxPoolItem* ExecuteList( sal_uInt16 nSlot,
SfxCallMode nCall, SfxCallMode nCall,
......
...@@ -41,6 +41,11 @@ class SfxViewFrame; ...@@ -41,6 +41,11 @@ class SfxViewFrame;
struct SfxRequest_Impl; struct SfxRequest_Impl;
enum class SfxCallMode : sal_uInt16; enum class SfxCallMode : sal_uInt16;
namespace vcl
{
class Window;
}
class SFX2_DLLPUBLIC SfxRequest: public SfxHint class SFX2_DLLPUBLIC SfxRequest: public SfxHint
{ {
friend struct SfxRequest_Impl; friend struct SfxRequest_Impl;
...@@ -61,7 +66,7 @@ public: ...@@ -61,7 +66,7 @@ public:
SfxRequest( sal_uInt16 nSlot, SfxCallMode nCallMode, SfxItemPool &rPool ); SfxRequest( sal_uInt16 nSlot, SfxCallMode nCallMode, SfxItemPool &rPool );
SfxRequest( const SfxSlot* pSlot, const css::uno::Sequence < css::beans::PropertyValue >& rArgs, SfxRequest( const SfxSlot* pSlot, const css::uno::Sequence < css::beans::PropertyValue >& rArgs,
SfxCallMode nCallMode, SfxItemPool &rPool ); SfxCallMode nCallMode, SfxItemPool &rPool );
SfxRequest( sal_uInt16 nSlot, SfxCallMode nCallMode, const SfxAllItemSet& rSfxArgs ); SfxRequest(sal_uInt16 nSlot, SfxCallMode nCallMode, const SfxAllItemSet& rSfxArgs, vcl::Window* pDialogParent = nullptr);
SfxRequest( sal_uInt16 nSlot, SfxCallMode nCallMode, const SfxAllItemSet& rSfxArgs, const SfxAllItemSet& rSfxInternalArgs ); SfxRequest( sal_uInt16 nSlot, SfxCallMode nCallMode, const SfxAllItemSet& rSfxArgs, const SfxAllItemSet& rSfxInternalArgs );
SfxRequest( const SfxRequest& rOrig ); SfxRequest( const SfxRequest& rOrig );
virtual ~SfxRequest() override; virtual ~SfxRequest() override;
...@@ -90,6 +95,10 @@ public: ...@@ -90,6 +95,10 @@ public:
return nullptr; return nullptr;
} }
/** Return the window that should be used as the parent for any dialogs this request creates
*/
vcl::Window* GetDialogParent() const;
void ReleaseArgs(); void ReleaseArgs();
void SetReturnValue(const SfxPoolItem &); void SetReturnValue(const SfxPoolItem &);
const SfxPoolItem* GetReturnValue() const; const SfxPoolItem* GetReturnValue() const;
......
...@@ -940,7 +940,7 @@ const SfxSlot* SfxDispatcher::GetSlot( const OUString& rCommand ) ...@@ -940,7 +940,7 @@ const SfxSlot* SfxDispatcher::GetSlot( const OUString& rCommand )
} }
const SfxPoolItem* SfxDispatcher::Execute(sal_uInt16 nSlot, SfxCallMode nCall, const SfxPoolItem* SfxDispatcher::Execute(sal_uInt16 nSlot, SfxCallMode nCall,
SfxItemSet const * pArgs, SfxItemSet const * pInternalArgs, sal_uInt16 nModi) SfxItemSet const * pArgs, SfxItemSet const * pInternalArgs, sal_uInt16 nModi, vcl::Window* pDialogParent)
{ {
if ( IsLocked() ) if ( IsLocked() )
return nullptr; return nullptr;
...@@ -959,7 +959,7 @@ const SfxPoolItem* SfxDispatcher::Execute(sal_uInt16 nSlot, SfxCallMode nCall, ...@@ -959,7 +959,7 @@ const SfxPoolItem* SfxDispatcher::Execute(sal_uInt16 nSlot, SfxCallMode nCall,
pArg = aIter.NextItem() ) pArg = aIter.NextItem() )
MappedPut_Impl( aSet, *pArg ); MappedPut_Impl( aSet, *pArg );
} }
SfxRequest aReq( nSlot, nCall, aSet ); SfxRequest aReq(nSlot, nCall, aSet, pDialogParent);
if (pInternalArgs) if (pInternalArgs)
aReq.SetInternalArgs_Impl( *pInternalArgs ); aReq.SetInternalArgs_Impl( *pInternalArgs );
aReq.SetModifier( nModi ); aReq.SetModifier( nModi );
......
...@@ -67,6 +67,7 @@ struct SfxRequest_Impl: public SfxListener ...@@ -67,6 +67,7 @@ struct SfxRequest_Impl: public SfxListener
bool bAllowRecording; bool bAllowRecording;
std::unique_ptr<SfxAllItemSet> std::unique_ptr<SfxAllItemSet>
pInternalArgs; pInternalArgs;
VclPtr<vcl::Window> xDialogParent;
SfxViewFrame* pViewFrame; SfxViewFrame* pViewFrame;
css::uno::Reference< css::frame::XDispatchRecorder > xRecorder; css::uno::Reference< css::frame::XDispatchRecorder > xRecorder;
...@@ -246,7 +247,8 @@ SfxRequest::SfxRequest ...@@ -246,7 +247,8 @@ SfxRequest::SfxRequest
( (
sal_uInt16 nSlotId, sal_uInt16 nSlotId,
SfxCallMode nMode, SfxCallMode nMode,
const SfxAllItemSet& rSfxArgs const SfxAllItemSet& rSfxArgs,
vcl::Window* pDialogParent
) )
// creates a SfxRequest with arguments // creates a SfxRequest with arguments
...@@ -262,6 +264,7 @@ SfxRequest::SfxRequest ...@@ -262,6 +264,7 @@ SfxRequest::SfxRequest
pImpl->pShell = nullptr; pImpl->pShell = nullptr;
pImpl->pSlot = nullptr; pImpl->pSlot = nullptr;
pImpl->nCallMode = nMode; pImpl->nCallMode = nMode;
pImpl->xDialogParent = pDialogParent;
} }
...@@ -741,4 +744,9 @@ void SfxRequest::ReleaseArgs() ...@@ -741,4 +744,9 @@ void SfxRequest::ReleaseArgs()
pImpl->pInternalArgs.reset(); pImpl->pInternalArgs.reset();
} }
vcl::Window* SfxRequest::GetDialogParent() const
{
return pImpl->xDialogParent;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <svtools/javainteractionhandler.hxx> #include <svtools/javainteractionhandler.hxx>
#include <svl/itempool.hxx> #include <svl/itempool.hxx>
#include <tools/urlobj.hxx> #include <tools/urlobj.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <com/sun/star/awt/FontDescriptor.hpp> #include <com/sun/star/awt/FontDescriptor.hpp>
#include <com/sun/star/util/URLTransformer.hpp> #include <com/sun/star/util/URLTransformer.hpp>
#include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/util/XURLTransformer.hpp>
...@@ -639,6 +640,8 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, ...@@ -639,6 +640,8 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const css::util::URL& aURL,
SfxCallMode nCall = SfxCallMode::RECORD; SfxCallMode nCall = SfxCallMode::RECORD;
sal_Int32 nMarkArg = -1; sal_Int32 nMarkArg = -1;
VclPtr<vcl::Window> xDialogParent;
// Filter arguments which shouldn't be part of the sequence property value // Filter arguments which shouldn't be part of the sequence property value
sal_uInt16 nModifier(0); sal_uInt16 nModifier(0);
std::vector< css::beans::PropertyValue > aAddArgs; std::vector< css::beans::PropertyValue > aAddArgs;
...@@ -651,6 +654,12 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, ...@@ -651,6 +654,12 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const css::util::URL& aURL,
if( rProp.Value >>= bTemp ) if( rProp.Value >>= bTemp )
nCall = bTemp ? SfxCallMode::SYNCHRON : SfxCallMode::ASYNCHRON; nCall = bTemp ? SfxCallMode::SYNCHRON : SfxCallMode::ASYNCHRON;
} }
else if( rProp.Name == "DialogParent" )
{
Reference<css::awt::XWindow> xWindow;
if (rProp.Value >>= xWindow)
xDialogParent = VCLUnoHelper::GetWindow(xWindow);
}
else if( rProp.Name == "Bookmark" ) else if( rProp.Name == "Bookmark" )
{ {
nMarkArg = n; nMarkArg = n;
...@@ -735,7 +744,7 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, ...@@ -735,7 +744,7 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const css::util::URL& aURL,
if (xSet->Count()) if (xSet->Count())
{ {
// execute with arguments - call directly // execute with arguments - call directly
pItem = pDispatcher->Execute(GetId(), nCall, xSet.get(), &aInternalSet, nModifier); pItem = pDispatcher->Execute(GetId(), nCall, xSet.get(), &aInternalSet, nModifier, xDialogParent);
if ( pItem != nullptr ) if ( pItem != nullptr )
{ {
if (const SfxBoolItem* pBoolItem = dynamic_cast<const SfxBoolItem*>(pItem)) if (const SfxBoolItem* pBoolItem = dynamic_cast<const SfxBoolItem*>(pItem))
...@@ -772,10 +781,10 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, ...@@ -772,10 +781,10 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const css::util::URL& aURL,
TransformParameters( GetId(), lNewArgs, aSet ); TransformParameters( GetId(), lNewArgs, aSet );
if ( aSet.Count() ) if ( aSet.Count() )
pItem = pDispatcher->Execute( GetId(), nCall, &aSet, &aInternalSet, nModifier ); pItem = pDispatcher->Execute(GetId(), nCall, &aSet, &aInternalSet, nModifier, xDialogParent);
else else
// SfxRequests take empty sets as argument sets, GetArgs() returning non-zero! // SfxRequests take empty sets as argument sets, GetArgs() returning non-zero!
pItem = pDispatcher->Execute( GetId(), nCall, nullptr, &aInternalSet, nModifier ); pItem = pDispatcher->Execute(GetId(), nCall, nullptr, &aInternalSet, nModifier, xDialogParent);
// no bindings, no invalidate ( usually done in SfxDispatcher::Call_Impl()! ) // no bindings, no invalidate ( usually done in SfxDispatcher::Call_Impl()! )
if (SfxApplication* pApp = SfxApplication::Get()) if (SfxApplication* pApp = SfxApplication::Get())
......
...@@ -5880,7 +5880,7 @@ SvxOrphansItem Orphan SID_ATTR_PARA_ORPHANS ...@@ -5880,7 +5880,7 @@ SvxOrphansItem Orphan SID_ATTR_PARA_ORPHANS
SfxVoidItem OutlineBullet SID_OUTLINE_BULLET SfxVoidItem OutlineBullet SID_OUTLINE_BULLET
(SfxStringItem Page FN_PARAM_1,SfxStringItem ParentWindow FN_PARAM_2) (SfxStringItem Page FN_PARAM_1)
[ [
AutoUpdate = FALSE, AutoUpdate = FALSE,
FastCall = FALSE, FastCall = FALSE,
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <i18nlangtag/mslangid.hxx> #include <i18nlangtag/mslangid.hxx>
#include <svtools/popupwindowcontroller.hxx> #include <svtools/popupwindowcontroller.hxx>
#include <svtools/toolbarmenu.hxx> #include <svtools/toolbarmenu.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <svx/strings.hrc> #include <svx/strings.hrc>
#include <svx/dialmgr.hxx> #include <svx/dialmgr.hxx>
#include <svx/numvset.hxx> #include <svx/numvset.hxx>
...@@ -181,7 +182,7 @@ void NumberingPopup::VSSelectHdl(void const * pControl) ...@@ -181,7 +182,7 @@ void NumberingPopup::VSSelectHdl(void const * pControl)
else if ( getSelectedEntryId() == 1 ) else if ( getSelectedEntryId() == 1 )
{ {
auto aArgs( comphelper::InitPropertySequence( { { "Page", css::uno::makeAny( OUString("customize") ) }, auto aArgs( comphelper::InitPropertySequence( { { "Page", css::uno::makeAny( OUString("customize") ) },
{ "ParentWindow", css::uno::makeAny( OUString::number(reinterpret_cast<sal_uInt64>(GetParent())) ) } } ) ); { "DialogParent", css::uno::makeAny(VCLUnoHelper::GetInterface(GetParent())) } } ) );
mrController.dispatchCommand( ".uno:OutlineBullet", aArgs ); mrController.dispatchCommand( ".uno:OutlineBullet", aArgs );
} }
} }
......
...@@ -183,13 +183,10 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq) ...@@ -183,13 +183,10 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq)
pDocSh->PutItem(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(pDocSh))); pDocSh->PutItem(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(pDocSh)));
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
vcl::Window *pParent = GetView().GetWindow();
const SfxStringItem* pParentItem = rReq.GetArg<SfxStringItem>(FN_PARAM_2);
if (pParentItem)
pParent = reinterpret_cast<vcl::Window*>(pParentItem->GetValue().toUInt64());
assert(pFact && "Dialog creation failed!"); assert(pFact && "Dialog creation failed!");
vcl::Window *pParent = rReq.GetDialogParent();
if (!pParent)
pParent = GetView().GetWindow();
ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSvxNumBulletTabDialog(pParent, &aSet, GetShell())); ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSvxNumBulletTabDialog(pParent, &aSet, GetShell()));
assert(pDlg && "Dialog creation failed!"); assert(pDlg && "Dialog creation failed!");
const SfxStringItem* pPageItem = rReq.GetArg<SfxStringItem>(FN_PARAM_1); const SfxStringItem* pPageItem = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
......
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