summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-11-09 20:43:09 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-11-10 16:40:05 +0100
commit4dba9820cf44718121a38b3f89eb8caa244d7321 (patch)
tree70bd1e02f89742f70b1a542042dd57cacdfc2c4d
parent4c9349aef26499b9d80a4d6354680b688a95fb0b (diff)
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/44585 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--include/sfx2/dispatch.hxx11
-rw-r--r--include/sfx2/request.hxx11
-rw-r--r--sfx2/source/control/dispatch.cxx4
-rw-r--r--sfx2/source/control/request.cxx10
-rw-r--r--sfx2/source/control/unoctitm.cxx15
-rw-r--r--svx/sdi/svx.sdi2
-rw-r--r--svx/source/tbxctrls/bulletsnumbering.cxx3
-rw-r--r--sw/source/uibase/shells/txtnum.cxx9
8 files changed, 45 insertions, 20 deletions
diff --git a/include/sfx2/dispatch.hxx b/include/sfx2/dispatch.hxx
index 2c41b9ae98bb..e8ad3783c9f8 100644
--- a/include/sfx2/dispatch.hxx
+++ b/include/sfx2/dispatch.hxx
@@ -124,11 +124,12 @@ public:
sal_uInt16 nModi = 0,
const SfxPoolItem **pInternalArgs = nullptr);
- const SfxPoolItem* Execute( sal_uInt16 nSlot,
- SfxCallMode nCall,
- SfxItemSet const * pArgs,
- SfxItemSet const * pInternalArgs,
- sal_uInt16 nModi);
+ const SfxPoolItem* Execute(sal_uInt16 nSlot,
+ SfxCallMode nCall,
+ SfxItemSet const * pArgs,
+ SfxItemSet const * pInternalArgs,
+ sal_uInt16 nModi,
+ vcl::Window* pDialogParent = nullptr);
const SfxPoolItem* ExecuteList( sal_uInt16 nSlot,
SfxCallMode nCall,
diff --git a/include/sfx2/request.hxx b/include/sfx2/request.hxx
index 86a9630b0f03..72d98071007f 100644
--- a/include/sfx2/request.hxx
+++ b/include/sfx2/request.hxx
@@ -41,6 +41,11 @@ class SfxViewFrame;
struct SfxRequest_Impl;
enum class SfxCallMode : sal_uInt16;
+namespace vcl
+{
+ class Window;
+}
+
class SFX2_DLLPUBLIC SfxRequest: public SfxHint
{
friend struct SfxRequest_Impl;
@@ -61,7 +66,7 @@ public:
SfxRequest( sal_uInt16 nSlot, SfxCallMode nCallMode, SfxItemPool &rPool );
SfxRequest( const SfxSlot* pSlot, const css::uno::Sequence < css::beans::PropertyValue >& rArgs,
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( const SfxRequest& rOrig );
virtual ~SfxRequest() override;
@@ -90,6 +95,10 @@ public:
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 SetReturnValue(const SfxPoolItem &);
const SfxPoolItem* GetReturnValue() const;
diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index 20f4de86914e..b4606a7401ca 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -940,7 +940,7 @@ const SfxSlot* SfxDispatcher::GetSlot( const OUString& rCommand )
}
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() )
return nullptr;
@@ -959,7 +959,7 @@ const SfxPoolItem* SfxDispatcher::Execute(sal_uInt16 nSlot, SfxCallMode nCall,
pArg = aIter.NextItem() )
MappedPut_Impl( aSet, *pArg );
}
- SfxRequest aReq( nSlot, nCall, aSet );
+ SfxRequest aReq(nSlot, nCall, aSet, pDialogParent);
if (pInternalArgs)
aReq.SetInternalArgs_Impl( *pInternalArgs );
aReq.SetModifier( nModi );
diff --git a/sfx2/source/control/request.cxx b/sfx2/source/control/request.cxx
index 572af7ed108d..2bd37d439613 100644
--- a/sfx2/source/control/request.cxx
+++ b/sfx2/source/control/request.cxx
@@ -67,6 +67,7 @@ struct SfxRequest_Impl: public SfxListener
bool bAllowRecording;
std::unique_ptr<SfxAllItemSet>
pInternalArgs;
+ VclPtr<vcl::Window> xDialogParent;
SfxViewFrame* pViewFrame;
css::uno::Reference< css::frame::XDispatchRecorder > xRecorder;
@@ -246,7 +247,8 @@ SfxRequest::SfxRequest
(
sal_uInt16 nSlotId,
SfxCallMode nMode,
- const SfxAllItemSet& rSfxArgs
+ const SfxAllItemSet& rSfxArgs,
+ vcl::Window* pDialogParent
)
// creates a SfxRequest with arguments
@@ -262,6 +264,7 @@ SfxRequest::SfxRequest
pImpl->pShell = nullptr;
pImpl->pSlot = nullptr;
pImpl->nCallMode = nMode;
+ pImpl->xDialogParent = pDialogParent;
}
@@ -741,4 +744,9 @@ void SfxRequest::ReleaseArgs()
pImpl->pInternalArgs.reset();
}
+vcl::Window* SfxRequest::GetDialogParent() const
+{
+ return pImpl->xDialogParent;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index 2dcbb0b7113c..115cc0eebd16 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -30,6 +30,7 @@
#include <svtools/javainteractionhandler.hxx>
#include <svl/itempool.hxx>
#include <tools/urlobj.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
#include <com/sun/star/awt/FontDescriptor.hpp>
#include <com/sun/star/util/URLTransformer.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
@@ -639,6 +640,8 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const css::util::URL& aURL,
SfxCallMode nCall = SfxCallMode::RECORD;
sal_Int32 nMarkArg = -1;
+ VclPtr<vcl::Window> xDialogParent;
+
// Filter arguments which shouldn't be part of the sequence property value
sal_uInt16 nModifier(0);
std::vector< css::beans::PropertyValue > aAddArgs;
@@ -651,6 +654,12 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const css::util::URL& aURL,
if( rProp.Value >>= bTemp )
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" )
{
nMarkArg = n;
@@ -735,7 +744,7 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const css::util::URL& aURL,
if (xSet->Count())
{
// 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 (const SfxBoolItem* pBoolItem = dynamic_cast<const SfxBoolItem*>(pItem))
@@ -772,10 +781,10 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const css::util::URL& aURL,
TransformParameters( GetId(), lNewArgs, aSet );
if ( aSet.Count() )
- pItem = pDispatcher->Execute( GetId(), nCall, &aSet, &aInternalSet, nModifier );
+ pItem = pDispatcher->Execute(GetId(), nCall, &aSet, &aInternalSet, nModifier, xDialogParent);
else
// 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()! )
if (SfxApplication* pApp = SfxApplication::Get())
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index 4737b1333dfe..3d684944a963 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -5880,7 +5880,7 @@ SvxOrphansItem Orphan SID_ATTR_PARA_ORPHANS
SfxVoidItem OutlineBullet SID_OUTLINE_BULLET
-(SfxStringItem Page FN_PARAM_1,SfxStringItem ParentWindow FN_PARAM_2)
+(SfxStringItem Page FN_PARAM_1)
[
AutoUpdate = FALSE,
FastCall = FALSE,
diff --git a/svx/source/tbxctrls/bulletsnumbering.cxx b/svx/source/tbxctrls/bulletsnumbering.cxx
index 42714fae2bbb..8180d18977e3 100644
--- a/svx/source/tbxctrls/bulletsnumbering.cxx
+++ b/svx/source/tbxctrls/bulletsnumbering.cxx
@@ -14,6 +14,7 @@
#include <i18nlangtag/mslangid.hxx>
#include <svtools/popupwindowcontroller.hxx>
#include <svtools/toolbarmenu.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
#include <svx/strings.hrc>
#include <svx/dialmgr.hxx>
#include <svx/numvset.hxx>
@@ -181,7 +182,7 @@ void NumberingPopup::VSSelectHdl(void const * pControl)
else if ( getSelectedEntryId() == 1 )
{
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 );
}
}
diff --git a/sw/source/uibase/shells/txtnum.cxx b/sw/source/uibase/shells/txtnum.cxx
index 9fd26cfe69a0..c89fae5043e9 100644
--- a/sw/source/uibase/shells/txtnum.cxx
+++ b/sw/source/uibase/shells/txtnum.cxx
@@ -183,13 +183,10 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq)
pDocSh->PutItem(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(pDocSh)));
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!");
+ vcl::Window *pParent = rReq.GetDialogParent();
+ if (!pParent)
+ pParent = GetView().GetWindow();
ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSvxNumBulletTabDialog(pParent, &aSet, GetShell()));
assert(pDlg && "Dialog creation failed!");
const SfxStringItem* pPageItem = rReq.GetArg<SfxStringItem>(FN_PARAM_1);