summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-07-01 10:29:22 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-07-01 15:00:16 +0200
commit5021a10f75870e7fa8f34e58512fd7c027debc68 (patch)
tree0c1d2e4d67a564ed09f206e79259ee41b500def4 /sfx2
parent5c23560ba39fe17c75cafe3d495af743238e4d67 (diff)
sfx2::FileDialogHelper allocate SfxItemSet on stack
and pass around the explicit sub-type, instead of doing static_cast in various places Change-Id: I28ba8fd6f5c9e2a1ffbf5ec091bcf0ebdd1d18b1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118210 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/appl/appopen.cxx4
-rw-r--r--sfx2/source/dialog/filedlghelper.cxx18
-rw-r--r--sfx2/source/dialog/filedlgimpl.hxx2
-rw-r--r--sfx2/source/doc/guisaveas.cxx6
4 files changed, 15 insertions, 15 deletions
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx
index 08431c29eaaa..f26b88a1b06c 100644
--- a/sfx2/source/appl/appopen.cxx
+++ b/sfx2/source/appl/appopen.cxx
@@ -608,7 +608,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
// get FileName from dialog
std::vector<OUString> aURLList;
OUString aFilter;
- std::unique_ptr<SfxItemSet> pSet;
+ std::optional<SfxAllItemSet> pSet;
OUString aPath;
const SfxStringItem* pFolderNameItem = rReq.GetArg<SfxStringItem>(SID_PATH);
if ( pFolderNameItem )
@@ -662,7 +662,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
return;
}
- rReq.SetArgs( *static_cast<SfxAllItemSet*>(pSet.get()) );
+ rReq.SetArgs( *pSet );
if ( !aFilter.isEmpty() )
rReq.AppendItem( SfxStringItem( SID_FILTER_NAME, aFilter ) );
rReq.AppendItem( SfxStringItem( SID_TARGETNAME, "_default" ) );
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index 939863816142..c388b909a3a4 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -1395,7 +1395,7 @@ void FileDialogHelper_Impl::implGetAndCacheFiles(const uno::Reference< XInterfac
}
ErrCode FileDialogHelper_Impl::execute( std::vector<OUString>& rpURLList,
- std::unique_ptr<SfxItemSet>& rpSet,
+ std::optional<SfxAllItemSet>& rpSet,
OUString& rFilter )
{
// rFilter is a pure output parameter, it shouldn't be used for anything else
@@ -1411,15 +1411,15 @@ ErrCode FileDialogHelper_Impl::execute( std::vector<OUString>& rpURLList,
// check password checkbox if the document had password before
if( mbHasPassword )
{
- const SfxBoolItem* pPassItem = SfxItemSet::GetItem<SfxBoolItem>(rpSet.get(), SID_PASSWORDINTERACTION, false);
+ const SfxBoolItem* pPassItem = SfxItemSet::GetItem<SfxBoolItem>(&*rpSet, SID_PASSWORDINTERACTION, false);
mbPwdCheckBoxState = ( pPassItem != nullptr && pPassItem->GetValue() );
// in case the document has password to modify, the dialog should be shown
- const SfxUnoAnyItem* pPassToModifyItem = SfxItemSet::GetItem<SfxUnoAnyItem>(rpSet.get(), SID_MODIFYPASSWORDINFO, false);
+ const SfxUnoAnyItem* pPassToModifyItem = SfxItemSet::GetItem<SfxUnoAnyItem>(&*rpSet, SID_MODIFYPASSWORDINFO, false);
mbPwdCheckBoxState |= ( pPassToModifyItem && pPassToModifyItem->GetValue().hasValue() );
}
- const SfxBoolItem* pSelectItem = SfxItemSet::GetItem<SfxBoolItem>(rpSet.get(), SID_SELECTION, false);
+ const SfxBoolItem* pSelectItem = SfxItemSet::GetItem<SfxBoolItem>(&*rpSet, SID_SELECTION, false);
if ( pSelectItem )
mbSelection = pSelectItem->GetValue();
else
@@ -1455,7 +1455,7 @@ ErrCode FileDialogHelper_Impl::execute( std::vector<OUString>& rpURLList,
{
// create an itemset if there is no
if( !rpSet )
- rpSet.reset(new SfxAllItemSet( SfxGetpApp()->GetPool() ));
+ rpSet.emplace( SfxGetpApp()->GetPool() );
// the item should remain only if it was set by the dialog
rpSet->ClearItem( SID_SELECTION );
@@ -1531,7 +1531,7 @@ ErrCode FileDialogHelper_Impl::execute( std::vector<OUString>& rpURLList,
{
// ask for a password
OUString aDocName(rpURLList[0]);
- ErrCode errCode = RequestPassword(pCurrentFilter, aDocName, rpSet.get(), GetFrameInterface());
+ ErrCode errCode = RequestPassword(pCurrentFilter, aDocName, &*rpSet, GetFrameInterface());
if (errCode != ERRCODE_NONE)
return errCode;
}
@@ -2383,7 +2383,7 @@ IMPL_LINK_NOARG(FileDialogHelper, ExecuteSystemFilePicker, void*, void)
// rDirPath has to be a directory
ErrCode FileDialogHelper::Execute( std::vector<OUString>& rpURLList,
- std::unique_ptr<SfxItemSet>& rpSet,
+ std::optional<SfxAllItemSet>& rpSet,
OUString& rFilter,
const OUString& rDirPath )
{
@@ -2397,7 +2397,7 @@ ErrCode FileDialogHelper::Execute()
return mpImpl->execute();
}
-ErrCode FileDialogHelper::Execute( std::unique_ptr<SfxItemSet>& rpSet,
+ErrCode FileDialogHelper::Execute( std::optional<SfxAllItemSet>& rpSet,
OUString& rFilter )
{
ErrCode nRet;
@@ -2645,7 +2645,7 @@ ErrCode FileOpenDialog_Impl( weld::Window* pParent,
FileDialogFlags nFlags,
std::vector<OUString>& rpURLList,
OUString& rFilter,
- std::unique_ptr<SfxItemSet>& rpSet,
+ std::optional<SfxAllItemSet>& rpSet,
const OUString* pPath,
sal_Int16 nDialog,
const OUString& rStandardDir,
diff --git a/sfx2/source/dialog/filedlgimpl.hxx b/sfx2/source/dialog/filedlgimpl.hxx
index e5e02e209748..f8a75f049f76 100644
--- a/sfx2/source/dialog/filedlgimpl.hxx
+++ b/sfx2/source/dialog/filedlgimpl.hxx
@@ -176,7 +176,7 @@ namespace sfx2
virtual ~FileDialogHelper_Impl() override;
ErrCode execute( std::vector<OUString>& rpURLList,
- std::unique_ptr<SfxItemSet>& rpSet,
+ std::optional<SfxAllItemSet>& rpSet,
OUString& rFilter );
ErrCode execute();
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index e2a2209e7b38..84a4edd83b42 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -966,10 +966,10 @@ bool ModelData_Impl::OutputFileDialog( sal_Int16 nStoreMode,
// generate SidSet from MediaDescriptor and provide it into FileDialog
// than merge changed SidSet back
- std::unique_ptr<SfxItemSet> pDialogParams(new SfxAllItemSet( SfxGetpApp()->GetPool() ));
+ std::optional<SfxAllItemSet> pDialogParams( SfxGetpApp()->GetPool() );
TransformParameters( nSlotID,
GetMediaDescr().getAsConstPropertyValueList(),
- static_cast<SfxAllItemSet&>(*pDialogParams) );
+ *pDialogParams );
const SfxPoolItem* pItem = nullptr;
if ( bPreselectPassword && pDialogParams->GetItemState( SID_ENCRYPTIONDATA, true, &pItem ) != SfxItemState::SET )
@@ -990,7 +990,7 @@ bool ModelData_Impl::OutputFileDialog( sal_Int16 nStoreMode,
// the following two arguments can not be converted in MediaDescriptor,
// so they should be removed from the ItemSet after retrieving
- const SfxBoolItem* pRecommendReadOnly = SfxItemSet::GetItem<SfxBoolItem>(pDialogParams.get(), SID_RECOMMENDREADONLY, false);
+ const SfxBoolItem* pRecommendReadOnly = SfxItemSet::GetItem<SfxBoolItem>(&*pDialogParams, SID_RECOMMENDREADONLY, false);
m_bRecommendReadOnly = ( pRecommendReadOnly && pRecommendReadOnly->GetValue() );
pDialogParams->ClearItem( SID_RECOMMENDREADONLY );