include/svl/poolitem.hxx | 2 +- sw/source/filter/ww8/docxattributeoutput.cxx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
New commits: commit 4ef4af0a2c15ff4b0a80ca8db0b816389943e8b8 Author: Mike Kaganski <[email protected]> AuthorDate: Mon Nov 24 10:14:04 2025 +0100 Commit: Mike Kaganski <[email protected]> CommitDate: Mon Nov 24 20:18:16 2025 +0100 Use StaticWhichCast instead of static_cast It feels safer in CloneSetWhich; previously, there was no way to make sure that the passed TypedWhichId makes sense. Change-Id: I1df520282f5407a69a095d959d107f6b78621f75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194422 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx index fbe4b6a62336..96e94dca698e 100644 --- a/include/svl/poolitem.hxx +++ b/include/svl/poolitem.hxx @@ -750,7 +750,7 @@ public: std::unique_ptr<SfxPoolItem> CloneSetWhich( sal_uInt16 nNewWhich ) const; template<class T> std::unique_ptr<T> CloneSetWhich( TypedWhichId<T> nId ) const { - return std::unique_ptr<T>(static_cast<T*>(CloneSetWhich(sal_uInt16(nId)).release())); + return std::unique_ptr<T>(&CloneSetWhich(sal_uInt16(nId)).release()->StaticWhichCast(nId)); } sal_uInt32 GetRefCount() const { return m_nRefCount; } commit a9d0ce7ffe4d9a9c4c7e0a5814a87fe7c094152d Author: Mike Kaganski <[email protected]> AuthorDate: Mon Nov 24 11:08:20 2025 +0100 Commit: Mike Kaganski <[email protected]> CommitDate: Mon Nov 24 20:18:09 2025 +0100 Use StaticWhichCast instead of static_cast StaticWhichCast gives useful diagnostics in debug builds, in case the type is wrong. Change-Id: I29394ede9ee635d10951802237b633ef59784e1d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194431 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 1ceb0053ad58..9212969bc3c1 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -5221,13 +5221,13 @@ void DocxAttributeOutput::OutputDefaultItem(const SfxPoolItem& rHt) bMustWrite = !rHt.StaticWhichCast(RES_PARATR_NUMRULE).GetValue().isEmpty(); break; case RES_PARATR_SCRIPTSPACE: - bMustWrite = !static_cast< const SfxBoolItem& >(rHt).GetValue(); + bMustWrite = !rHt.StaticWhichCast(RES_PARATR_SCRIPTSPACE).GetValue(); break; case RES_PARATR_HANGINGPUNCTUATION: - bMustWrite = !static_cast< const SfxBoolItem& >(rHt).GetValue(); + bMustWrite = !rHt.StaticWhichCast(RES_PARATR_HANGINGPUNCTUATION).GetValue(); break; case RES_PARATR_FORBIDDEN_RULES: - bMustWrite = !static_cast< const SfxBoolItem& >(rHt).GetValue(); + bMustWrite = !rHt.StaticWhichCast(RES_PARATR_FORBIDDEN_RULES).GetValue(); break; case RES_PARATR_VERTALIGN: bMustWrite = rHt.StaticWhichCast(RES_PARATR_VERTALIGN).GetValue() != SvxParaVertAlignItem::Align::Automatic;
