cui/source/tabpages/autocdlg.cxx | 4 ++-- include/svl/itemset.hxx | 8 +++----- sfx2/source/dialog/dinfdlg.cxx | 2 +- sfx2/source/doc/docfile.cxx | 34 +++++++++++++++++----------------- sfx2/source/doc/guisaveas.cxx | 4 ++-- sfx2/source/doc/objstor.cxx | 10 +++++----- sfx2/source/view/viewfrm.cxx | 8 ++++---- svx/source/dialog/cuicharmap.cxx | 4 ++-- sw/source/ui/misc/insfnote.cxx | 4 ++-- sw/source/uibase/app/docsh2.cxx | 2 +- 10 files changed, 39 insertions(+), 41 deletions(-)
New commits: commit d3cb2e7e2425639185731cb72a591d0618a1cbbc Author: Mike Kaganski <[email protected]> AuthorDate: Wed Nov 26 13:22:18 2025 +0100 Commit: Mike Kaganski <[email protected]> CommitDate: Thu Nov 27 19:21:29 2025 +0100 Let SfxItemSet::GetItem taking TypedWhichId use static_cast Only use the dynamic_cast in assertion. Change-Id: Idbb2800bf4fdba74118b13f5948bc1e26b482c49 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194636 Reviewed-by: Mike Kaganski <[email protected]> Tested-by: Jenkins diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx index 0aedaf104993..49fc4fcd2fd9 100644 --- a/include/svl/itemset.hxx +++ b/include/svl/itemset.hxx @@ -160,10 +160,8 @@ public: template<class T> const T* GetItem(sal_uInt16 nWhich, bool bSearchInParent = true) const { const SfxPoolItem* pItem = GetItem(nWhich, bSearchInParent); - const T* pCastedItem = dynamic_cast<const T*>(pItem); - - assert(!pItem || pCastedItem); // if it exists, must have the correct type - return pCastedItem; + assert(!pItem || dynamic_cast<const T*>(pItem)); // if it exists, must have the correct type + return static_cast<const T*>(pItem); } template<class T> const T* GetItem( TypedWhichId<T> nWhich, bool bSearchInParent = true ) const { commit 503ff1b86925e58ada2d969cf229de68350e46b2 Author: Mike Kaganski <[email protected]> AuthorDate: Wed Nov 26 12:46:46 2025 +0100 Commit: Mike Kaganski <[email protected]> CommitDate: Thu Nov 27 19:21:17 2025 +0100 Drop explicit template parameter where deducible Namely, from SfxItemSet::GetItem variant taking TypedWhichId. Change-Id: I0b5b6ffb052b1a874afe184fc8a7624105e60d17 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194624 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index a64a4239f03a..52700eba495d 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -656,7 +656,7 @@ Reference < XContent > SfxMedium::GetContent() const css::uno::Reference< css::ucb::XProgressHandler > xProgress; rtl::Reference<::ucbhelper::CommandEnvironment> pCommandEnv = new ::ucbhelper::CommandEnvironment( new comphelper::SimpleFileAccessInteraction( xIH ), xProgress ); - const SfxUnoAnyItem* pItem = SfxItemSet::GetItem<SfxUnoAnyItem>(pImpl->m_pSet.get(), SID_CONTENT, false); + const SfxUnoAnyItem* pItem = SfxItemSet::GetItem(pImpl->m_pSet.get(), SID_CONTENT, false); if ( pItem ) pItem->GetValue() >>= xContent; @@ -1483,7 +1483,7 @@ SfxMedium::LockFileResult SfxMedium::LockOrigFileOnDemand(bool bLoading, bool bN { // the error should be set in case it is storing process // or the document has been opened for editing explicitly - const SfxBoolItem* pReadOnlyItem = SfxItemSet::GetItem<SfxBoolItem>(pImpl->m_pSet.get(), SID_DOC_READONLY, false); + const SfxBoolItem* pReadOnlyItem = SfxItemSet::GetItem(pImpl->m_pSet.get(), SID_DOC_READONLY, false); if ( !bLoading || (pReadOnlyItem && !pReadOnlyItem->GetValue()) ) SetError(ERRCODE_IO_ACCESSDENIED); @@ -1733,7 +1733,7 @@ SfxMedium::LockFileResult SfxMedium::LockOrigFileOnDemand(bool bLoading, bool bN { // the error should be set in case it is storing process // or the document has been opened for editing explicitly - const SfxBoolItem* pReadOnlyItem = SfxItemSet::GetItem<SfxBoolItem>(pImpl->m_pSet.get(), SID_DOC_READONLY, false); + const SfxBoolItem* pReadOnlyItem = SfxItemSet::GetItem(pImpl->m_pSet.get(), SID_DOC_READONLY, false); if ( !bLoading || (pReadOnlyItem && !pReadOnlyItem->GetValue()) ) SetError(ERRCODE_IO_ACCESSDENIED); @@ -1938,7 +1938,7 @@ uno::Reference < embed::XStorage > SfxMedium::GetStorage( bool bCreateTempFile ) GetVersionList(); } - const SfxInt16Item* pVersion = SfxItemSet::GetItem<SfxInt16Item>(pImpl->m_pSet.get(), SID_VERSION, false); + const SfxInt16Item* pVersion = SfxItemSet::GetItem(pImpl->m_pSet.get(), SID_VERSION, false); bool bResetStorage = false; if ( pVersion && pVersion->GetValue() ) @@ -2474,7 +2474,7 @@ void SfxMedium::Transfer_Impl() if (pImpl->m_aLogicName.startsWith("private:stream")) { // TODO/LATER: support storing to SID_STREAM - const SfxUnoAnyItem* pOutStreamItem = SfxItemSet::GetItem<SfxUnoAnyItem>(pImpl->m_pSet.get(), SID_OUTPUTSTREAM, false); + const SfxUnoAnyItem* pOutStreamItem = SfxItemSet::GetItem(pImpl->m_pSet.get(), SID_OUTPUTSTREAM, false); if( pOutStreamItem && ( pOutStreamItem->GetValue() >>= rOutStream ) ) { if ( pImpl->xStorage.is() ) @@ -2922,7 +2922,7 @@ void SfxMedium::GetLockingStream_Impl() || pImpl->m_xLockingStream.is() ) return; - const SfxUnoAnyItem* pWriteStreamItem = SfxItemSet::GetItem<SfxUnoAnyItem>(pImpl->m_pSet.get(), SID_STREAM, false); + const SfxUnoAnyItem* pWriteStreamItem = SfxItemSet::GetItem(pImpl->m_pSet.get(), SID_STREAM, false); if ( pWriteStreamItem ) pWriteStreamItem->GetValue() >>= pImpl->m_xLockingStream; @@ -2965,8 +2965,8 @@ void SfxMedium::GetMedium_Impl() Reference< css::task::XInteractionHandler > xInteractionHandler = GetInteractionHandler(); //TODO/MBA: need support for SID_STREAM - const SfxUnoAnyItem* pWriteStreamItem = SfxItemSet::GetItem<SfxUnoAnyItem>(pImpl->m_pSet.get(), SID_STREAM, false); - const SfxUnoAnyItem* pInStreamItem = SfxItemSet::GetItem<SfxUnoAnyItem>(pImpl->m_pSet.get(), SID_INPUTSTREAM, false); + const SfxUnoAnyItem* pWriteStreamItem = SfxItemSet::GetItem(pImpl->m_pSet.get(), SID_STREAM, false); + const SfxUnoAnyItem* pInStreamItem = SfxItemSet::GetItem(pImpl->m_pSet.get(), SID_INPUTSTREAM, false); if ( pWriteStreamItem ) { pWriteStreamItem->GetValue() >>= pImpl->xStream; @@ -3143,7 +3143,7 @@ void SfxMedium::Init_Impl() // TODO/LATER: handle lifetime of storages pImpl->bDisposeStorage = false; - const SfxStringItem* pSalvageItem = SfxItemSet::GetItem<SfxStringItem>(pImpl->m_pSet.get(), SID_DOC_SALVAGE, false); + const SfxStringItem* pSalvageItem = SfxItemSet::GetItem(pImpl->m_pSet.get(), SID_DOC_SALVAGE, false); if ( pSalvageItem && pSalvageItem->GetValue().isEmpty() ) { pSalvageItem = nullptr; @@ -3198,7 +3198,7 @@ void SfxMedium::Init_Impl() // in case output stream is by mistake here // clear the reference - const SfxUnoAnyItem* pOutStreamItem = SfxItemSet::GetItem<SfxUnoAnyItem>(pImpl->m_pSet.get(), SID_OUTPUTSTREAM, false); + const SfxUnoAnyItem* pOutStreamItem = SfxItemSet::GetItem(pImpl->m_pSet.get(), SID_OUTPUTSTREAM, false); if( pOutStreamItem && ( !( pOutStreamItem->GetValue() >>= rOutStream ) || !pImpl->m_aLogicName.startsWith("private:stream")) ) @@ -3210,7 +3210,7 @@ void SfxMedium::Init_Impl() if (!pImpl->m_aLogicName.isEmpty()) { // if the logic name is set it should be set in MediaDescriptor as well - const SfxStringItem* pFileNameItem = SfxItemSet::GetItem<SfxStringItem>(pImpl->m_pSet.get(), SID_FILE_NAME, false); + const SfxStringItem* pFileNameItem = SfxItemSet::GetItem(pImpl->m_pSet.get(), SID_FILE_NAME, false); if ( !pFileNameItem ) { // let the ItemSet be created if necessary @@ -3260,7 +3260,7 @@ SfxMedium::GetInteractionHandler( bool bGetAlways ) if ( pImpl->m_pSet ) { css::uno::Reference< css::task::XInteractionHandler > xHandler; - const SfxUnoAnyItem* pHandler = SfxItemSet::GetItem<SfxUnoAnyItem>(pImpl->m_pSet.get(), SID_INTERACTIONHANDLER, false); + const SfxUnoAnyItem* pHandler = SfxItemSet::GetItem(pImpl->m_pSet.get(), SID_INTERACTIONHANDLER, false); if ( pHandler && (pHandler->GetValue() >>= xHandler) && xHandler.is() ) return xHandler; } @@ -3652,7 +3652,7 @@ SfxMedium::SfxMedium( const uno::Sequence<beans::PropertyValue>& aArgs ) : pImpl->m_pFilter = pImpl->m_pCustomFilter; } - const SfxStringItem* pSalvageItem = SfxItemSet::GetItem<SfxStringItem>(pImpl->m_pSet.get(), SID_DOC_SALVAGE, false); + const SfxStringItem* pSalvageItem = SfxItemSet::GetItem(pImpl->m_pSet.get(), SID_DOC_SALVAGE, false); if( pSalvageItem ) { // QUESTION: there is some treatment of Salvage in Init_Impl; align! @@ -3661,7 +3661,7 @@ SfxMedium::SfxMedium( const uno::Sequence<beans::PropertyValue>& aArgs ) : // if a URL is provided in SalvageItem that means that the FileName refers to a temporary file // that must be copied here - const SfxStringItem* pFileNameItem = SfxItemSet::GetItem<SfxStringItem>(pImpl->m_pSet.get(), SID_FILE_NAME, false); + const SfxStringItem* pFileNameItem = SfxItemSet::GetItem(pImpl->m_pSet.get(), SID_FILE_NAME, false); if (!pFileNameItem) throw uno::RuntimeException(); OUString aNewTempFileURL = SfxMedium::CreateTempCopyWithExt( pFileNameItem->GetValue() ); if ( !aNewTempFileURL.isEmpty() ) @@ -3678,11 +3678,11 @@ SfxMedium::SfxMedium( const uno::Sequence<beans::PropertyValue>& aArgs ) : } } - const SfxBoolItem* pReadOnlyItem = SfxItemSet::GetItem<SfxBoolItem>(pImpl->m_pSet.get(), SID_DOC_READONLY, false); + const SfxBoolItem* pReadOnlyItem = SfxItemSet::GetItem(pImpl->m_pSet.get(), SID_DOC_READONLY, false); if ( pReadOnlyItem && pReadOnlyItem->GetValue() ) pImpl->m_bOriginallyLoadedReadOnly = true; - const SfxStringItem* pFileNameItem = SfxItemSet::GetItem<SfxStringItem>(pImpl->m_pSet.get(), SID_FILE_NAME, false); + const SfxStringItem* pFileNameItem = SfxItemSet::GetItem(pImpl->m_pSet.get(), SID_FILE_NAME, false); if (!pFileNameItem) throw uno::RuntimeException(); pImpl->m_aLogicName = pFileNameItem->GetValue(); pImpl->m_nStorOpenMode = pImpl->m_bOriginallyLoadedReadOnly @@ -4774,7 +4774,7 @@ OUString SfxMedium::SwitchDocumentToTempFile() // remove the readonly state bool bWasReadonly = false; pImpl->m_nStorOpenMode = SFX_STREAM_READWRITE; - const SfxBoolItem* pReadOnlyItem = SfxItemSet::GetItem<SfxBoolItem>(pImpl->m_pSet.get(), SID_DOC_READONLY, false); + const SfxBoolItem* pReadOnlyItem = SfxItemSet::GetItem(pImpl->m_pSet.get(), SID_DOC_READONLY, false); if ( pReadOnlyItem && pReadOnlyItem->GetValue() ) bWasReadonly = true; GetItemSet().ClearItem( SID_DOC_READONLY ); diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index fe75d6ee0deb..64977270d5b4 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -1813,7 +1813,7 @@ bool SfxObjectShell::SaveTo_Impl bool const bPasswdProvided(aEncryptionData.getLength() != 0); pFilter = rMedium.GetFilter(); - const SfxStringItem *pVersionItem = !rMedium.IsInCheckIn()? SfxItemSet::GetItem<SfxStringItem>(pSet, SID_DOCINFO_COMMENTS, false): nullptr; + const SfxStringItem *pVersionItem = !rMedium.IsInCheckIn()? SfxItemSet::GetItem(pSet, SID_DOCINFO_COMMENTS, false): nullptr; OUString aTmpVersionURL; if ( bOk ) @@ -1893,7 +1893,7 @@ bool SfxObjectShell::SaveTo_Impl if ( bOk && pVersionItem && !rMedium.IsInCheckIn() ) { // store a version also - const SfxStringItem *pAuthorItem = SfxItemSet::GetItem<SfxStringItem>(pSet, SID_DOCINFO_AUTHOR, false); + const SfxStringItem *pAuthorItem = SfxItemSet::GetItem(pSet, SID_DOCINFO_AUTHOR, false); // version comment util::RevisionTag aInfo; diff --git a/svx/source/dialog/cuicharmap.cxx b/svx/source/dialog/cuicharmap.cxx index e7597eb2305d..a21d0f7f0659 100644 --- a/svx/source/dialog/cuicharmap.cxx +++ b/svx/source/dialog/cuicharmap.cxx @@ -96,8 +96,8 @@ SvxCharacterMap::SvxCharacterMap(weld::Widget* pParent, const SfxItemSet* pSet, if ( pDisableItem && pDisableItem->GetValue() ) DisableFontSelection(); - const SvxFontItem* pFontItem = SfxItemSet::GetItem<SvxFontItem>(pSet, SID_ATTR_CHAR_FONT, false); - const SfxStringItem* pFontNameItem = SfxItemSet::GetItem<SfxStringItem>(pSet, SID_FONT_NAME, false); + const SvxFontItem* pFontItem = SfxItemSet::GetItem(pSet, SID_ATTR_CHAR_FONT, false); + const SfxStringItem* pFontNameItem = SfxItemSet::GetItem(pSet, SID_FONT_NAME, false); if ( pFontItem ) { vcl::Font aTmpFont( pFontItem->GetFamilyName(), pFontItem->GetStyleName(), GetCharFont().GetFontSize() ); diff --git a/sw/source/ui/misc/insfnote.cxx b/sw/source/ui/misc/insfnote.cxx index f4fe8367aeb6..243cb0fd6615 100644 --- a/sw/source/ui/misc/insfnote.cxx +++ b/sw/source/ui/misc/insfnote.cxx @@ -107,8 +107,8 @@ IMPL_LINK_NOARG(SwInsFootNoteDlg, NumberExtCharHdl, weld::Button&, void) { if (nResult == RET_OK) { - const SfxStringItem* pItem = SfxItemSet::GetItem<SfxStringItem>(pDlg->GetOutputItemSet(), SID_CHARMAP, false); - const SvxFontItem* pFontItem = SfxItemSet::GetItem<SvxFontItem>(pDlg->GetOutputItemSet(), SID_ATTR_CHAR_FONT, false); + const SfxStringItem* pItem = SfxItemSet::GetItem(pDlg->GetOutputItemSet(), SID_CHARMAP, false); + const SvxFontItem* pFontItem = SfxItemSet::GetItem(pDlg->GetOutputItemSet(), SID_ATTR_CHAR_FONT, false); if ( pItem ) { m_xNumberCharEdit->set_text(pItem->GetValue()); commit 8082c9bd075b7a49e4f150792a34c72d8ab5d13f Author: Mike Kaganski <[email protected]> AuthorDate: Wed Nov 26 12:58:01 2025 +0100 Commit: Mike Kaganski <[email protected]> CommitDate: Thu Nov 27 19:21:08 2025 +0100 Don't use static SfxItemSet::GetItem, where set is known to be non-null Just use the non-static overload, which is more concise. Change-Id: I52f3b8aa7880d3e4bc82d8095d6d2a6932fd79e1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194627 Reviewed-by: Mike Kaganski <[email protected]> Tested-by: Jenkins diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx index ebfd0dece4e8..5d611d90506b 100644 --- a/cui/source/tabpages/autocdlg.cxx +++ b/cui/source/tabpages/autocdlg.cxx @@ -68,11 +68,11 @@ OfaAutoCorrDlg::OfaAutoCorrDlg(weld::Window* pParent, const SfxItemSet* _pSet ) if ( _pSet ) { - const SfxBoolItem* pItem = SfxItemSet::GetItem<SfxBoolItem>(_pSet, SID_AUTO_CORRECT_DLG, false); + const SfxBoolItem* pItem = _pSet->GetItem<SfxBoolItem>(SID_AUTO_CORRECT_DLG, false); if ( pItem && pItem->GetValue() ) bShowSWOptions = true; - const SfxBoolItem* pItem2 = SfxItemSet::GetItem<SfxBoolItem>(_pSet, SID_OPEN_SMARTTAGOPTIONS, false); + const SfxBoolItem* pItem2 = _pSet->GetItem<SfxBoolItem>(SID_OPEN_SMARTTAGOPTIONS, false); if ( pItem2 && pItem2->GetValue() ) bOpenSmartTagOptions = true; } diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index dd8a1f6becce..cd5ebf6cb4f8 100644 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -775,7 +775,7 @@ void SfxDocumentDescPage::Reset(const SfxItemSet *rSet) m_xTypeEd->save_value(); m_xCommentEd->save_value(); - const SfxBoolItem* pROItem = SfxItemSet::GetItem<SfxBoolItem>(rSet, SID_DOC_READONLY, false); + const SfxBoolItem* pROItem = rSet->GetItem(SID_DOC_READONLY, false); if (pROItem && pROItem->GetValue()) { m_xTitleEd->set_editable(false); diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index 2ad7c2ad1b97..9580778b3456 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -1124,11 +1124,11 @@ 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, SID_RECOMMENDREADONLY, false); + const SfxBoolItem* pRecommendReadOnly = pDialogParams->GetItem(SID_RECOMMENDREADONLY, false); m_bRecommendReadOnly = ( pRecommendReadOnly && pRecommendReadOnly->GetValue() ); pDialogParams->ClearItem( SID_RECOMMENDREADONLY ); - const SfxBoolItem* pSignWithDefaultKey = SfxItemSet::GetItem<SfxBoolItem>(&*pDialogParams, SID_GPGSIGN, false); + const SfxBoolItem* pSignWithDefaultKey = pDialogParams->GetItem(SID_GPGSIGN, false); m_bSignWithDefaultSignature = (pSignWithDefaultKey && pSignWithDefaultKey->GetValue()); pDialogParams->ClearItem( SID_GPGSIGN ); diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 9bc7e7b78f33..fe75d6ee0deb 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -196,7 +196,7 @@ bool GetEncryptionData_Impl( const SfxItemSet* pSet, uno::Sequence< beans::Named bool bResult = false; if ( pSet ) { - const SfxUnoAnyItem* pEncryptionDataItem = SfxItemSet::GetItem<SfxUnoAnyItem>(pSet, SID_ENCRYPTIONDATA, false); + const SfxUnoAnyItem* pEncryptionDataItem = pSet->GetItem(SID_ENCRYPTIONDATA, false); if ( pEncryptionDataItem ) { pEncryptionDataItem->GetValue() >>= o_rEncryptionData; @@ -204,7 +204,7 @@ bool GetEncryptionData_Impl( const SfxItemSet* pSet, uno::Sequence< beans::Named } else { - const SfxStringItem* pPasswordItem = SfxItemSet::GetItem<SfxStringItem>(pSet, SID_PASSWORD, false); + const SfxStringItem* pPasswordItem = pSet->GetItem(SID_PASSWORD, false); if ( pPasswordItem ) { o_rEncryptionData = ::comphelper::OStorageHelper::CreatePackageEncryptionData( pPasswordItem->GetValue() ); @@ -3053,7 +3053,7 @@ bool SfxObjectShell::DoSave_Impl( const SfxItemSet* pArgs ) // an interaction handler here can acquire only in case of GUI Saving // and should be removed after the saving is done css::uno::Reference< XInteractionHandler > xInteract; - const SfxUnoAnyItem* pxInteractionItem = SfxItemSet::GetItem<SfxUnoAnyItem>(pArgs, SID_INTERACTIONHANDLER, false); + const SfxUnoAnyItem* pxInteractionItem = pArgs->GetItem(SID_INTERACTIONHANDLER, false); if ( pxInteractionItem && ( pxInteractionItem->GetValue() >>= xInteract ) && xInteract.is() ) pMediumTmp->GetItemSet().Put( SfxUnoAnyItem( SID_INTERACTIONHANDLER, Any( xInteract ) ) ); diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 4c04104763f0..26acd5662fe8 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -742,7 +742,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) // If a salvaged file is present, do not enclose the OrigURL // again, since the Template is invalid after reload. - const SfxStringItem* pSalvageItem = SfxItemSet::GetItem<SfxStringItem>(&*pNewSet, SID_DOC_SALVAGE, false); + const SfxStringItem* pSalvageItem = pNewSet->GetItem(SID_DOC_SALVAGE, false); if( pSalvageItem ) { pNewSet->ClearItem( SID_DOC_SALVAGE ); @@ -765,9 +765,9 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) if ( pSilentItem && pSilentItem->GetValue() ) pNewSet->Put( SfxBoolItem( SID_SILENT, true ) ); - const SfxUnoAnyItem* pInteractionItem = SfxItemSet::GetItem<SfxUnoAnyItem>(&*pNewSet, SID_INTERACTIONHANDLER, false); - const SfxUInt16Item* pMacroExecItem = SfxItemSet::GetItem<SfxUInt16Item>(&*pNewSet, SID_MACROEXECMODE, false); - const SfxUInt16Item* pDocTemplateItem = SfxItemSet::GetItem<SfxUInt16Item>(&*pNewSet, SID_UPDATEDOCMODE, false); + const SfxUnoAnyItem* pInteractionItem = pNewSet->GetItem(SID_INTERACTIONHANDLER, false); + const SfxUInt16Item* pMacroExecItem = pNewSet->GetItem(SID_MACROEXECMODE, false); + const SfxUInt16Item* pDocTemplateItem = pNewSet->GetItem(SID_UPDATEDOCMODE, false); if (!pInteractionItem) { diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx index ebba72f85e51..abe519490947 100644 --- a/sw/source/uibase/app/docsh2.cxx +++ b/sw/source/uibase/app/docsh2.cxx @@ -925,7 +925,7 @@ void SwDocShell::Execute(SfxRequest& rReq) if( pArgs && SfxItemState::SET == pArgs->GetItemState( nWhich, false, &pItem ) ) { aFileName = static_cast<const SfxStringItem*>(pItem)->GetValue(); - const SfxStringItem* pTemplItem = SfxItemSet::GetItem<SfxStringItem>(pArgs, SID_TEMPLATE_NAME, false); + const SfxStringItem* pTemplItem = pArgs->GetItem(SID_TEMPLATE_NAME, false); if ( pTemplItem ) aTemplateName = pTemplItem->GetValue(); } commit e871a7d5a65a4a5c983b65cf95b7ff7fd68d7170 Author: Mike Kaganski <[email protected]> AuthorDate: Wed Nov 26 11:10:30 2025 +0100 Commit: Mike Kaganski <[email protected]> CommitDate: Thu Nov 27 19:20:55 2025 +0100 Drop default arguments from the templatized overload These defaults don't provide any advantages over the base overload, which works just fine in case when there's no ppItem argument. The ppItem argument is the only sensible reason to use the templatized overload. Change-Id: Ic17fe1da7a3c02f9e7ebbe725060fcf129bc9f24 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194616 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx index 09e305ee88e8..0aedaf104993 100644 --- a/include/svl/itemset.hxx +++ b/include/svl/itemset.hxx @@ -191,7 +191,7 @@ public: return GetItemState_ForWhichID(SfxItemState::UNKNOWN, nWhich, bSrchInParent, ppItem); } - template <class T> SfxItemState GetItemState(TypedWhichId<T> nWhich, bool bSrchInParent = true, const T **ppItem = nullptr ) const + template <class T> SfxItemState GetItemState(TypedWhichId<T> nWhich, bool bSrchInParent, const T **ppItem) const { return GetItemState(sal_uInt16(nWhich), bSrchInParent, reinterpret_cast<SfxPoolItem const**>(ppItem)); }
