summaryrefslogtreecommitdiffstats
path: root/sfx2
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2016-03-30 17:55:05 +0200
committerMichael Stahl <mstahl@redhat.com>2016-03-31 11:19:23 +0000
commit51d7f466df85f679f54e4e690f8b5e602192eb7b (patch)
tree94a72abb002879ef4dca830ad652415521b8bdd5 /sfx2
parentFix Windows part of 97858ca008fd8cf405e52795c8db415ef6c5afb3 (diff)
downloadcore-51d7f466df85f679f54e4e690f8b5e602192eb7b.tar.gz
core-51d7f466df85f679f54e4e690f8b5e602192eb7b.zip
sfx2: make SfxDispatcher::Execute() less variadic ...
... and less overloaded; C++11 initializer_list should make undefined behavior as fixed in ba0a866b83f016fd460320e7d057dd107e019f19 less likely. Change-Id: I15cc0804451b6a4fcbfaa623f9a30db222207865 Reviewed-on: https://gerrit.libreoffice.org/23666 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/appl/appdde.cxx5
-rw-r--r--sfx2/source/appl/appopen.cxx10
-rw-r--r--sfx2/source/appl/appserv.cxx8
-rw-r--r--sfx2/source/control/dispatch.cxx25
-rw-r--r--sfx2/source/dialog/basedlgs.cxx8
-rw-r--r--sfx2/source/dialog/dockwin.cxx5
-rw-r--r--sfx2/source/dialog/recfloat.cxx6
-rw-r--r--sfx2/source/dialog/templdlg.cxx2
-rw-r--r--sfx2/source/dialog/titledockwin.cxx5
-rw-r--r--sfx2/source/dialog/versdlg.cxx12
-rw-r--r--sfx2/source/doc/objserv.cxx6
-rw-r--r--sfx2/source/view/viewfrm.cxx3
-rw-r--r--sfx2/source/view/viewsh.cxx4
13 files changed, 54 insertions, 45 deletions
diff --git a/sfx2/source/appl/appdde.cxx b/sfx2/source/appl/appdde.cxx
index ad9e9d49abc5..4685749f473e 100644
--- a/sfx2/source/appl/appdde.cxx
+++ b/sfx2/source/appl/appdde.cxx
@@ -149,10 +149,9 @@ bool ImplDdeService::MakeTopic( const OUString& rNm )
SfxBoolItem aSilent(SID_SILENT, sal_True);
SfxDispatcher* pDispatcher = SfxGetpApp()->GetDispatcher_Impl();
- const SfxPoolItem* pRet = pDispatcher->Execute( SID_OPENDOC,
+ const SfxPoolItem* pRet = pDispatcher->ExecuteList(SID_OPENDOC,
SfxCallMode::SYNCHRON,
- &aName, &aNewView,
- &aSilent, 0L );
+ { &aName, &aNewView, &aSilent });
if( pRet && dynamic_cast< const SfxViewFrameItem *>( pRet ) != nullptr &&
((SfxViewFrameItem*)pRet)->GetFrame() &&
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx
index 07a1deef8619..9500ceb5af3c 100644
--- a/sfx2/source/appl/appopen.cxx
+++ b/sfx2/source/appl/appopen.cxx
@@ -314,7 +314,9 @@ sal_uIntPtr SfxApplication::LoadTemplate( SfxObjectShellLock& xDoc, const OUStri
SfxStringItem aReferer( SID_REFERER, OUString("private:user") );
SfxStringItem aFlags( SID_OPTIONS, OUString("T") );
SfxBoolItem aHidden( SID_HIDDEN, true );
- const SfxPoolItem *pRet = GetDispatcher_Impl()->Execute( SID_OPENDOC, SfxCallMode::SYNCHRON, &aName, &aHidden, &aReferer, &aFlags, 0L );
+ const SfxPoolItem *pRet = GetDispatcher_Impl()->ExecuteList(
+ SID_OPENDOC, SfxCallMode::SYNCHRON,
+ { &aName, &aHidden, &aReferer, &aFlags } );
const SfxObjectItem *pObj = dynamic_cast<const SfxObjectItem*>( pRet );
if ( pObj )
xDoc = dynamic_cast<SfxObjectShell*>( pObj->GetShell() );
@@ -520,12 +522,14 @@ void SfxApplication::NewDocExec_Impl( SfxRequest& rReq )
SfxStringItem aName( SID_FILE_NAME, aObj.GetMainURL( INetURLObject::NO_DECODE ) );
SfxStringItem aTemplName( SID_TEMPLATE_NAME, aTemplateName );
SfxStringItem aTemplRegionName( SID_TEMPLATE_REGIONNAME, aTemplateRegion );
- pRet = GetDispatcher_Impl()->Execute( SID_OPENDOC, eMode, &aName, &aTarget, &aReferer, &aTemplName, &aTemplRegionName, 0L );
+ pRet = GetDispatcher_Impl()->ExecuteList(SID_OPENDOC, eMode,
+ {&aName, &aTarget, &aReferer, &aTemplName, &aTemplRegionName});
}
else
{
SfxStringItem aName( SID_FILE_NAME, "private:factory" );
- pRet = GetDispatcher_Impl()->Execute( SID_OPENDOC, eMode, &aName, &aTarget, &aReferer, 0L );
+ pRet = GetDispatcher_Impl()->ExecuteList(SID_OPENDOC, eMode,
+ { &aName, &aTarget, &aReferer } );
}
if ( pRet )
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx
index f467783104ce..822a851b6a84 100644
--- a/sfx2/source/appl/appserv.cxx
+++ b/sfx2/source/appl/appserv.cxx
@@ -185,7 +185,8 @@ namespace
SfxStringItem aURL(SID_FILE_NAME, OUString(".component:Bibliography/View1"));
SfxStringItem aRef(SID_REFERER, OUString("private:user"));
SfxStringItem aTarget(SID_TARGETNAME, OUString("_blank"));
- SfxViewFrame::Current()->GetDispatcher()->Execute( SID_OPENDOC, SfxCallMode::ASYNCHRON, &aURL, &aRef, &aTarget, 0L);
+ SfxViewFrame::Current()->GetDispatcher()->ExecuteList(SID_OPENDOC,
+ SfxCallMode::ASYNCHRON, { &aURL, &aRef, &aTarget });
}
catch (const Exception & e)
{
@@ -299,7 +300,8 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
SfxStringItem aNameItem( SID_FILE_NAME, OUString("vnd.sun.star.cmd:logout") );
SfxStringItem aReferer( SID_REFERER, "private/user" );
- pAppData_Impl->pAppDispat->Execute( SID_OPENDOC, SfxCallMode::SLOT, &aNameItem, &aReferer, 0L );
+ pAppData_Impl->pAppDispat->ExecuteList(SID_OPENDOC,
+ SfxCallMode::SLOT, { &aNameItem, &aReferer });
return;
}
@@ -625,7 +627,7 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
break;
}
- pCurrentShell->GetDispatcher()->Execute(SID_ATTR_ZOOM, SfxCallMode::ASYNCHRON, &aZoom, 0L);
+ pCurrentShell->GetDispatcher()->ExecuteList(SID_ATTR_ZOOM, SfxCallMode::ASYNCHRON, { &aZoom });
break;
}
diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index f0d4327bd64e..dc710dd886d5 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -1017,8 +1017,7 @@ const SfxPoolItem* SfxDispatcher::Execute(sal_uInt16 nSlot, SfxCallMode eCall,
@param nSlot the Id of the executing function
@param eCall SfxCallMode::SYNCRHON, ..._ASYNCHRON or ..._SLOT
- @param pArg1 First parameter
- @param ... Zero terminated list of parameters
+ @param args list of SfxPoolItem arguments
@return Pointer to the SfxPoolItem valid to the next run
though the Message-Loop, which contains the return
@@ -1030,13 +1029,13 @@ const SfxPoolItem* SfxDispatcher::Execute(sal_uInt16 nSlot, SfxCallMode eCall,
[Example]
pDispatcher->Execute( SID_OPENDOCUMENT, SfxCallMode::SYNCHRON,
- &SfxStringItem( SID_FILE_NAME, "\\tmp\\temp.sdd" ),
- &SfxStringItem( SID_FILTER_NAME, "StarDraw Presentation" ),
- &SfxBoolItem( SID_DOC_READONLY, sal_False ),
- 0L );
+ { &SfxStringItem( SID_FILE_NAME, "\\tmp\\temp.sdd" ),
+ &SfxStringItem( SID_FILTER_NAME, "StarDraw Presentation" ),
+ &SfxBoolItem( SID_DOC_READONLY, sal_False ),
+ });
*/
-const SfxPoolItem* SfxDispatcher::Execute(sal_uInt16 nSlot, SfxCallMode eCall,
- const SfxPoolItem* pArg1, ...)
+const SfxPoolItem* SfxDispatcher::ExecuteList(sal_uInt16 nSlot, SfxCallMode eCall,
+ std::initializer_list<SfxPoolItem const*> args)
{
if ( IsLocked(nSlot) )
return nullptr;
@@ -1048,13 +1047,11 @@ const SfxPoolItem* SfxDispatcher::Execute(sal_uInt16 nSlot, SfxCallMode eCall,
{
SfxAllItemSet aSet( pShell->GetPool() );
- va_list pVarArgs;
- va_start( pVarArgs, pArg1 );
- for ( const SfxPoolItem *pArg = pArg1;
- pArg;
- pArg = va_arg( pVarArgs, const SfxPoolItem* ) )
+ for (const SfxPoolItem *pArg : args)
+ {
+ assert(pArg);
MappedPut_Impl( aSet, *pArg );
- va_end(pVarArgs);
+ }
SfxRequest aReq( nSlot, eCall, aSet );
_Execute( *pShell, *pSlot, aReq, eCall );
diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index 851eb5430938..84dff54daeb5 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -385,9 +385,9 @@ bool SfxModelessDialog::Close()
{
// Execute with Parameters, since Toggle is ignored by some ChildWindows.
SfxBoolItem aValue( pImp->pMgr->GetType(), false);
- pBindings->GetDispatcher_Impl()->Execute(
+ pBindings->GetDispatcher_Impl()->ExecuteList(
pImp->pMgr->GetType(),
- SfxCallMode::RECORD|SfxCallMode::SYNCHRON, &aValue, 0L );
+ SfxCallMode::RECORD|SfxCallMode::SYNCHRON, { &aValue } );
return true;
}
@@ -498,9 +498,9 @@ bool SfxFloatingWindow::Close()
{
// Execute with Parameters, since Toggle is ignored by some ChildWindows.
SfxBoolItem aValue( pImp->pMgr->GetType(), false);
- pBindings->GetDispatcher_Impl()->Execute(
+ pBindings->GetDispatcher_Impl()->ExecuteList(
pImp->pMgr->GetType(),
- SfxCallMode::RECORD|SfxCallMode::SYNCHRON, &aValue, 0L );
+ SfxCallMode::RECORD|SfxCallMode::SYNCHRON, { &aValue });
return true;
}
diff --git a/sfx2/source/dialog/dockwin.cxx b/sfx2/source/dialog/dockwin.cxx
index 28011c99ab32..caf0c64b0203 100644
--- a/sfx2/source/dialog/dockwin.cxx
+++ b/sfx2/source/dialog/dockwin.cxx
@@ -1661,8 +1661,9 @@ bool SfxDockingWindow::Close()
return true;
SfxBoolItem aValue( pMgr->GetType(), false);
- pBindings->GetDispatcher_Impl()->Execute(
- pMgr->GetType(), SfxCallMode::RECORD | SfxCallMode::ASYNCHRON, &aValue, 0L );
+ pBindings->GetDispatcher_Impl()->ExecuteList(
+ pMgr->GetType(), SfxCallMode::RECORD | SfxCallMode::ASYNCHRON,
+ { &aValue });
return true;
}
diff --git a/sfx2/source/dialog/recfloat.cxx b/sfx2/source/dialog/recfloat.cxx
index 0cb4a836985f..780fb404c037 100644
--- a/sfx2/source/dialog/recfloat.cxx
+++ b/sfx2/source/dialog/recfloat.cxx
@@ -141,7 +141,8 @@ SfxRecordingFloatWrapper_Impl::~SfxRecordingFloatWrapper_Impl()
SfxBoolItem aItem( FN_PARAM_1, true );
css::uno::Reference< css::frame::XDispatchRecorder > xRecorder = pBindings->GetRecorder();
if ( xRecorder.is() )
- pBindings->GetDispatcher()->Execute( SID_STOP_RECORDING, SfxCallMode::SYNCHRON, &aItem, 0L );
+ pBindings->GetDispatcher()->ExecuteList(SID_STOP_RECORDING,
+ SfxCallMode::SYNCHRON, { &aItem });
}
bool SfxRecordingFloatWrapper_Impl::QueryClose()
@@ -193,7 +194,8 @@ SfxRecordingFloat_Impl::SfxRecordingFloat_Impl(
// start recording
SfxBoolItem aItem( SID_RECORDMACRO, true );
- GetBindings().GetDispatcher()->Execute( SID_RECORDMACRO, SfxCallMode::SYNCHRON, &aItem, 0L );
+ GetBindings().GetDispatcher()->ExecuteList(SID_RECORDMACRO,
+ SfxCallMode::SYNCHRON, { &aItem });
}
SfxRecordingFloat_Impl::~SfxRecordingFloat_Impl()
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index e0f10e91a612..86af63d112c3 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -1701,7 +1701,7 @@ void SfxCommonTemplateDialog_Impl::FamilySelect(sal_uInt16 nEntry)
nActFamily = nEntry;
SfxDispatcher* pDispat = pBindings->GetDispatcher_Impl();
SfxUInt16Item aItem( SID_STYLE_FAMILY, nEntry );
- pDispat->Execute( SID_STYLE_FAMILY, SfxCallMode::SYNCHRON, &aItem, 0L );
+ pDispat->ExecuteList(SID_STYLE_FAMILY, SfxCallMode::SYNCHRON, { &aItem });
pBindings->Invalidate( SID_STYLE_FAMILY );
pBindings->Update( SID_STYLE_FAMILY );
UpdateFamily_Impl();
diff --git a/sfx2/source/dialog/titledockwin.cxx b/sfx2/source/dialog/titledockwin.cxx
index 154e40697730..cfe9d7331158 100644
--- a/sfx2/source/dialog/titledockwin.cxx
+++ b/sfx2/source/dialog/titledockwin.cxx
@@ -236,11 +236,10 @@ namespace sfx2
EndTracking();
const sal_uInt16 nChildWindowId( GetChildWindow_Impl()->GetType() );
const SfxBoolItem aVisibility( nChildWindowId, false );
- GetBindings().GetDispatcher()->Execute(
+ GetBindings().GetDispatcher()->ExecuteList(
nChildWindowId,
SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
- &aVisibility,
- nullptr
+ { &aVisibility }
);
}
}
diff --git a/sfx2/source/dialog/versdlg.cxx b/sfx2/source/dialog/versdlg.cxx
index 02029f6486f6..ab2572c52eb4 100644
--- a/sfx2/source/dialog/versdlg.cxx
+++ b/sfx2/source/dialog/versdlg.cxx
@@ -359,12 +359,16 @@ void SfxVersionDialog::Open_Impl()
{
// there is a password, it should be used during the opening
SfxUnoAnyItem aEncryptionDataItem( SID_ENCRYPTIONDATA, uno::makeAny( aEncryptionData ) );
- pViewFrame->GetDispatcher()->Execute(
- SID_OPENDOC, SfxCallMode::ASYNCHRON, &aFile, &aItem, &aTarget, &aReferer, &aEncryptionDataItem, 0L );
+ pViewFrame->GetDispatcher()->ExecuteList(
+ SID_OPENDOC, SfxCallMode::ASYNCHRON,
+ { &aFile, &aItem, &aTarget, &aReferer, &aEncryptionDataItem });
}
else
- pViewFrame->GetDispatcher()->Execute(
- SID_OPENDOC, SfxCallMode::ASYNCHRON, &aFile, &aItem, &aTarget, &aReferer, 0L );
+ {
+ pViewFrame->GetDispatcher()->ExecuteList(
+ SID_OPENDOC, SfxCallMode::ASYNCHRON,
+ { &aFile, &aItem, &aTarget, &aReferer });
+ }
Close();
}
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 92ba81e4f522..de663cfb0b11 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -1255,9 +1255,9 @@ void SfxObjectShell::ExecView_Impl(SfxRequest &rReq)
{
SfxStringItem aName( SID_FILE_NAME, aFileName );
SfxBoolItem aCreateView( SID_OPEN_NEW_VIEW, true );
- SfxGetpApp()->GetAppDispatcher_Impl()->Execute(
- SID_OPENDOC, SfxCallMode::ASYNCHRON, &aName,
- &aCreateView, 0L);
+ SfxGetpApp()->GetAppDispatcher_Impl()->ExecuteList(
+ SID_OPENDOC, SfxCallMode::ASYNCHRON,
+ { &aName, &aCreateView });
}
}
}
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 3c803a9a1a7e..6d1672c73c50 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -2660,7 +2660,8 @@ void SfxViewFrame::AddDispatchMacroToBasic_Impl( const OUString& sMacro )
if ( pDispat )
{
SfxMacroInfoItem aInfoItem( SID_BASICIDE_ARG_MACROINFO, pBasMgr, aLibName, aModuleName, OUString(), OUString() );
- pDispat->Execute( SID_BASICIDE_UPDATEMODULESOURCE, SfxCallMode::SYNCHRON, &aInfoItem, 0L );
+ pDispat->ExecuteList(SID_BASICIDE_UPDATEMODULESOURCE,
+ SfxCallMode::SYNCHRON, { &aInfoItem });
}
}
}
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 11cf17ed7317..d1aa7548d4c0 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1758,10 +1758,10 @@ bool SfxViewShell::IsShowView_Impl() const
void SfxViewShell::JumpToMark( const OUString& rMark )
{
SfxStringItem aMarkItem( SID_JUMPTOMARK, rMark );
- GetViewFrame()->GetDispatcher()->Execute(
+ GetViewFrame()->GetDispatcher()->ExecuteList(
SID_JUMPTOMARK,
SfxCallMode::SYNCHRON|SfxCallMode::RECORD,
- &aMarkItem, 0L );
+ { &aMarkItem });
}
void SfxViewShell::SetController( SfxBaseController* pController )