editeng/source/items/textitem.cxx | 52 ++++++++++++----------------------- include/editeng/escapementitem.hxx | 9 +----- sc/source/filter/rtf/eeimpars.cxx | 2 - sc/source/ui/drawfunc/drtxtob.cxx | 6 ++-- sc/source/ui/view/editsh.cxx | 6 ++-- sd/source/ui/view/drtxtob.cxx | 2 - sd/source/ui/view/drtxtob1.cxx | 8 ++--- sd/source/ui/view/drviews2.cxx | 4 +- sd/source/ui/view/drviewsf.cxx | 2 - sw/source/filter/html/htmlatr.cxx | 5 +-- sw/source/uibase/shells/annotsh.cxx | 4 +- sw/source/uibase/shells/drwtxtex.cxx | 4 +- 12 files changed, 41 insertions(+), 63 deletions(-)
New commits: commit c5bdbaf6586e38fda377885d69f3fb980ef1f420 Author: Mike Kaganski <[email protected]> AuthorDate: Mon Jun 9 08:04:39 2025 +0200 Commit: Mike Kaganski <[email protected]> CommitDate: Mon Jun 9 12:47:39 2025 +0200 SvxEscapementItem does not need to be an SfxEnumItemInterface Change-Id: Ie194e42c4f4eef22df6cd290cf9ed2d228e2006a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186278 Reviewed-by: Mike Kaganski <[email protected]> Tested-by: Jenkins diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx index 56923526cff1..e74187788407 100644 --- a/editeng/source/items/textitem.cxx +++ b/editeng/source/items/textitem.cxx @@ -1904,7 +1904,7 @@ bool SvxCaseMapItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) // class SvxEscapementItem ----------------------------------------------- SvxEscapementItem::SvxEscapementItem( const sal_uInt16 nId ) : - SfxEnumItemInterface( nId ), + SfxPoolItem( nId ), nEsc ( 0 ), nProp ( 100 ) @@ -1914,7 +1914,7 @@ SvxEscapementItem::SvxEscapementItem( const sal_uInt16 nId ) : SvxEscapementItem::SvxEscapementItem( const SvxEscapement eEscape, const sal_uInt16 nId ) : - SfxEnumItemInterface( nId ), + SfxPoolItem( nId ), nProp( 100 ) { SetEscapement( eEscape ); @@ -1926,7 +1926,7 @@ SvxEscapementItem::SvxEscapementItem( const SvxEscapement eEscape, SvxEscapementItem::SvxEscapementItem( const short _nEsc, const sal_uInt8 _nProp, const sal_uInt16 nId ) : - SfxEnumItemInterface( nId ), + SfxPoolItem( nId ), nEsc ( _nEsc ), nProp ( _nProp ) { @@ -1945,12 +1945,6 @@ SvxEscapementItem* SvxEscapementItem::Clone( SfxItemPool * ) const return new SvxEscapementItem( *this ); } -sal_uInt16 SvxEscapementItem::GetValueCount() const -{ - return sal_uInt16(SvxEscapement::End); // SvxEscapement::Subscript + 1 -} - - bool SvxEscapementItem::GetPresentation ( SfxItemPresentation /*ePres*/, @@ -1959,7 +1953,17 @@ bool SvxEscapementItem::GetPresentation OUString& rText, const IntlWrapper& /*rIntl*/ ) const { - rText = GetValueTextByPos( GetEnumValue() ); + static constexpr TranslateId RID_SVXITEMS_ESCAPEMENT[] = + { + RID_SVXITEMS_ESCAPEMENT_OFF, + RID_SVXITEMS_ESCAPEMENT_SUPER, + RID_SVXITEMS_ESCAPEMENT_SUB + }; + + SvxEscapement pos = GetEscapement(); + static_assert(std::size(RID_SVXITEMS_ESCAPEMENT) == size_t(SvxEscapement::End), "must match"); + assert(pos < SvxEscapement::End && "enum overflow!"); + rText = EditResId(RID_SVXITEMS_ESCAPEMENT[static_cast<size_t>(pos)]); if ( nEsc != 0 ) { @@ -1971,33 +1975,13 @@ bool SvxEscapementItem::GetPresentation return true; } -OUString SvxEscapementItem::GetValueTextByPos( sal_uInt16 nPos ) -{ - static TranslateId RID_SVXITEMS_ESCAPEMENT[] = - { - RID_SVXITEMS_ESCAPEMENT_OFF, - RID_SVXITEMS_ESCAPEMENT_SUPER, - RID_SVXITEMS_ESCAPEMENT_SUB - }; - - static_assert(std::size(RID_SVXITEMS_ESCAPEMENT) == size_t(SvxEscapement::End), "must match"); - assert(nPos < sal_uInt16(SvxEscapement::End) && "enum overflow!"); - return EditResId(RID_SVXITEMS_ESCAPEMENT[nPos]); -} - -sal_uInt16 SvxEscapementItem::GetEnumValue() const +SvxEscapement SvxEscapementItem::GetEscapement() const { if ( nEsc < 0 ) - return sal_uInt16(SvxEscapement::Subscript); + return SvxEscapement::Subscript; else if ( nEsc > 0 ) - return sal_uInt16(SvxEscapement::Superscript); - return sal_uInt16(SvxEscapement::Off); -} - - -void SvxEscapementItem::SetEnumValue( sal_uInt16 nVal ) -{ - SetEscapement( static_cast<SvxEscapement>(nVal) ); + return SvxEscapement::Superscript; + return SvxEscapement::Off; } bool SvxEscapementItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const diff --git a/include/editeng/escapementitem.hxx b/include/editeng/escapementitem.hxx index 94db1972673c..ea3ca106db3f 100644 --- a/include/editeng/escapementitem.hxx +++ b/include/editeng/escapementitem.hxx @@ -37,7 +37,7 @@ This item describes the writing position. */ -class EDITENG_DLLPUBLIC SvxEscapementItem final : public SfxEnumItemInterface +class EDITENG_DLLPUBLIC SvxEscapementItem final : public SfxPoolItem { short nEsc; sal_uInt8 nProp; @@ -80,18 +80,13 @@ public: nEsc = DFLT_ESC_AUTO_SUB; } } - SvxEscapement GetEscapement() const { return static_cast< SvxEscapement >( GetEnumValue() ); } + SvxEscapement GetEscapement() const; short GetEsc() const { return nEsc; } void SetEsc(short nNewEsc) { ASSERT_CHANGE_REFCOUNTED_ITEM; nEsc = nNewEsc; } sal_uInt8 GetProportionalHeight() const { return nProp; } void SetProportionalHeight(sal_uInt8 n) { ASSERT_CHANGE_REFCOUNTED_ITEM; nProp = n; } - - virtual sal_uInt16 GetValueCount() const override; - static OUString GetValueTextByPos( sal_uInt16 nPos ); - virtual sal_uInt16 GetEnumValue() const override; - virtual void SetEnumValue( sal_uInt16 nNewVal ) override; }; #endif diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx index f2f50c276beb..1e75f6ec5ddf 100644 --- a/sc/source/filter/rtf/eeimpars.cxx +++ b/sc/source/filter/rtf/eeimpars.cxx @@ -189,7 +189,7 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNu { if ( nId == EE_CHAR_ESCAPEMENT ) // Super-/Subscript always via EE { - if ( static_cast<SvxEscapement>(static_cast<const SvxEscapementItem*>(pItem)->GetEnumValue()) + if ( pItem->StaticWhichCast(EE_CHAR_ESCAPEMENT).GetEscapement() != SvxEscapement::Off ) bSimple = false; } diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx index ba159f9c40f2..57442c400e8a 100644 --- a/sc/source/ui/drawfunc/drtxtob.cxx +++ b/sc/source/ui/drawfunc/drtxtob.cxx @@ -722,7 +722,7 @@ void ScDrawTextObjectBar::ExecuteAttr( SfxRequest &rReq ) case SID_SET_SUPER_SCRIPT: { SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); - SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue()); + SvxEscapement eEsc = aEditAttr.Get(EE_CHAR_ESCAPEMENT).GetEscapement(); if( eEsc == SvxEscapement::Superscript ) aItem.SetEscapement( SvxEscapement::Off ); @@ -735,7 +735,7 @@ void ScDrawTextObjectBar::ExecuteAttr( SfxRequest &rReq ) case SID_SET_SUB_SCRIPT: { SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); - SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue()); + SvxEscapement eEsc = aEditAttr.Get(EE_CHAR_ESCAPEMENT).GetEscapement(); if( eEsc == SvxEscapement::Subscript ) aItem.SetEscapement( SvxEscapement::Off ); @@ -1132,7 +1132,7 @@ void ScDrawTextObjectBar::GetAttrState( SfxItemSet& rDestSet ) } // super-/subscript - SvxEscapement eEsc = static_cast<SvxEscapement>(aAttrSet.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue()); + SvxEscapement eEsc = aAttrSet.Get(EE_CHAR_ESCAPEMENT).GetEscapement(); rDestSet.Put(SfxBoolItem(SID_SET_SUPER_SCRIPT, eEsc == SvxEscapement::Superscript)); rDestSet.Put(SfxBoolItem(SID_SET_SUB_SCRIPT, eEsc == SvxEscapement::Subscript)); diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx index d7356d74b7b3..8fe4e3b0aae1 100644 --- a/sc/source/ui/view/editsh.cxx +++ b/sc/source/ui/view/editsh.cxx @@ -1172,7 +1172,7 @@ void ScEditShell::ExecuteAttr(SfxRequest& rReq) case SID_SET_SUPER_SCRIPT: { - SvxEscapement eOld = static_cast<SvxEscapement>(pEditView->GetAttribs().Get(EE_CHAR_ESCAPEMENT).GetEnumValue()); + SvxEscapement eOld = pEditView->GetAttribs().Get(EE_CHAR_ESCAPEMENT).GetEscapement(); SvxEscapement eNew = (eOld == SvxEscapement::Superscript) ? SvxEscapement::Off : SvxEscapement::Superscript; aSet.Put( SvxEscapementItem( eNew, EE_CHAR_ESCAPEMENT ) ); @@ -1181,7 +1181,7 @@ void ScEditShell::ExecuteAttr(SfxRequest& rReq) break; case SID_SET_SUB_SCRIPT: { - SvxEscapement eOld = static_cast<SvxEscapement>(pEditView->GetAttribs().Get(EE_CHAR_ESCAPEMENT).GetEnumValue()); + SvxEscapement eOld = pEditView->GetAttribs().Get(EE_CHAR_ESCAPEMENT).GetEscapement(); SvxEscapement eNew = (eOld == SvxEscapement::Subscript) ? SvxEscapement::Off : SvxEscapement::Subscript; aSet.Put( SvxEscapementItem( eNew, EE_CHAR_ESCAPEMENT ) ); @@ -1285,7 +1285,7 @@ void ScEditShell::GetAttrState(SfxItemSet &rSet) if ( pHdl && pHdl->IsFormulaMode() ) rSet.ClearItem( EE_CHAR_WEIGHT ); // Highlighted brace not here - SvxEscapement eEsc = static_cast<SvxEscapement>(aAttribs.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue()); + SvxEscapement eEsc = aAttribs.Get(EE_CHAR_ESCAPEMENT).GetEscapement(); rSet.Put(SfxBoolItem(SID_SET_SUPER_SCRIPT, eEsc == SvxEscapement::Superscript)); rSet.Put(SfxBoolItem(SID_SET_SUB_SCRIPT, eEsc == SvxEscapement::Subscript)); rViewData.GetBindings().Invalidate( SID_SET_SUPER_SCRIPT ); diff --git a/sd/source/ui/view/drtxtob.cxx b/sd/source/ui/view/drtxtob.cxx index de14496da243..a746a5d7ad0b 100644 --- a/sd/source/ui/view/drtxtob.cxx +++ b/sd/source/ui/view/drtxtob.cxx @@ -676,7 +676,7 @@ void TextObjectBar::GetAttrStateImpl(ViewShell& rViewShell, ::sd::View* pView, S } // justification (superscript, subscript) is also needed in outline-mode - SvxEscapement eEsc = static_cast<SvxEscapement>(aAttrSet.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue()); + SvxEscapement eEsc = aAttrSet.Get(EE_CHAR_ESCAPEMENT).GetEscapement(); rSet.Put(SfxBoolItem(SID_SET_SUPER_SCRIPT, eEsc == SvxEscapement::Superscript)); rSet.Put(SfxBoolItem(SID_SET_SUB_SCRIPT, eEsc == SvxEscapement::Subscript)); diff --git a/sd/source/ui/view/drtxtob1.cxx b/sd/source/ui/view/drtxtob1.cxx index 1fb33ca059a0..eddd320be984 100644 --- a/sd/source/ui/view/drtxtob1.cxx +++ b/sd/source/ui/view/drtxtob1.cxx @@ -633,7 +633,7 @@ SET_ADJUST: case SID_SET_SUPER_SCRIPT: { SvxEscapementItem aItem( EE_CHAR_ESCAPEMENT ); - SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue()); + SvxEscapement eEsc = aEditAttr.Get(EE_CHAR_ESCAPEMENT).GetEscapement(); if( eEsc == SvxEscapement::Superscript ) aItem.SetEscapement( SvxEscapement::Off ); @@ -645,7 +645,7 @@ SET_ADJUST: case SID_SET_SUB_SCRIPT: { SvxEscapementItem aItem( EE_CHAR_ESCAPEMENT ); - SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue()); + SvxEscapement eEsc = aEditAttr.Get(EE_CHAR_ESCAPEMENT).GetEscapement(); if( eEsc == SvxEscapement::Subscript ) aItem.SetEscapement( SvxEscapement::Off ); @@ -780,7 +780,7 @@ SET_ADJUST: else if(nSlot == SID_SET_SUPER_SCRIPT ) { SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); - SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue()); + SvxEscapement eEsc = aEditAttr.Get(EE_CHAR_ESCAPEMENT).GetEscapement(); if( eEsc == SvxEscapement::Superscript ) aItem.SetEscapement( SvxEscapement::Off ); @@ -793,7 +793,7 @@ SET_ADJUST: else if( nSlot == SID_SET_SUB_SCRIPT ) { SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); - SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue()); + SvxEscapement eEsc = aEditAttr.Get(EE_CHAR_ESCAPEMENT).GetEscapement(); if( eEsc == SvxEscapement::Subscript ) aItem.SetEscapement( SvxEscapement::Off ); diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index a24c5aa049e7..c709ffdb4733 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -4483,7 +4483,7 @@ void DrawViewShell::ExecChar( SfxRequest &rReq ) case SID_SET_SUB_SCRIPT: { SvxEscapementItem aItem( EE_CHAR_ESCAPEMENT ); - SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue()); + SvxEscapement eEsc = aEditAttr.Get(EE_CHAR_ESCAPEMENT).GetEscapement(); if( eEsc == SvxEscapement::Subscript ) aItem.SetEscapement( SvxEscapement::Off ); else @@ -4494,7 +4494,7 @@ void DrawViewShell::ExecChar( SfxRequest &rReq ) case SID_SET_SUPER_SCRIPT: { SvxEscapementItem aItem( EE_CHAR_ESCAPEMENT ); - SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue()); + SvxEscapement eEsc = aEditAttr.Get(EE_CHAR_ESCAPEMENT).GetEscapement(); if( eEsc == SvxEscapement::Superscript ) aItem.SetEscapement( SvxEscapement::Off ); else diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx index 917a21e14ece..02b929aad44f 100644 --- a/sd/source/ui/view/drviewsf.cxx +++ b/sd/source/ui/view/drviewsf.cxx @@ -778,7 +778,7 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet ) rSet.InvalidateItem(SID_ATTR_PARA_ULSPACE); } - SvxEscapement eEsc = static_cast<SvxEscapement>(pSet->Get( EE_CHAR_ESCAPEMENT ).GetEnumValue()); + SvxEscapement eEsc = pSet->Get(EE_CHAR_ESCAPEMENT).GetEscapement(); rSet.Put(SfxBoolItem(SID_SET_SUPER_SCRIPT, eEsc == SvxEscapement::Superscript)); rSet.Put(SfxBoolItem(SID_SET_SUB_SCRIPT, eEsc == SvxEscapement::Subscript)); diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx index 3a15d00a8c3a..c16fd612d092 100644 --- a/sw/source/filter/html/htmlatr.cxx +++ b/sw/source/filter/html/htmlatr.cxx @@ -1270,7 +1270,7 @@ HTMLOnOffState HTMLEndPosLst::GetHTMLItemState( const SfxPoolItem& rItem ) break; case RES_CHRATR_ESCAPEMENT: - switch( static_cast<SvxEscapement>(rItem.StaticWhichCast(RES_CHRATR_ESCAPEMENT).GetEnumValue()) ) + switch (rItem.StaticWhichCast(RES_CHRATR_ESCAPEMENT).GetEscapement()) { case SvxEscapement::Superscript: case SvxEscapement::Subscript: @@ -2938,8 +2938,7 @@ static SwHTMLWriter& OutHTML_SvxEscapement( SwHTMLWriter& rWrt, const SfxPoolIte if( rWrt.m_bOutOpts ) return rWrt; - const SvxEscapement eEscape = - static_cast<SvxEscapement>(static_cast<const SvxEscapementItem&>(rHt).GetEnumValue()); + const SvxEscapement eEscape = static_cast<const SvxEscapementItem&>(rHt).GetEscapement(); OString aTag; switch( eEscape ) { diff --git a/sw/source/uibase/shells/annotsh.cxx b/sw/source/uibase/shells/annotsh.cxx index 4ffcc3081dee..a43123c58d50 100644 --- a/sw/source/uibase/shells/annotsh.cxx +++ b/sw/source/uibase/shells/annotsh.cxx @@ -374,7 +374,7 @@ void SwAnnotationShell::Exec( SfxRequest &rReq ) case FN_SET_SUPER_SCRIPT: { SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); - SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue()); + SvxEscapement eEsc = aEditAttr.Get(EE_CHAR_ESCAPEMENT).GetEscapement(); if( eEsc == SvxEscapement::Superscript ) aItem.SetEscapement( SvxEscapement::Off ); @@ -386,7 +386,7 @@ void SwAnnotationShell::Exec( SfxRequest &rReq ) case FN_SET_SUB_SCRIPT: { SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); - SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue()); + SvxEscapement eEsc = aEditAttr.Get(EE_CHAR_ESCAPEMENT).GetEscapement(); if( eEsc == SvxEscapement::Subscript ) aItem.SetEscapement( SvxEscapement::Off ); diff --git a/sw/source/uibase/shells/drwtxtex.cxx b/sw/source/uibase/shells/drwtxtex.cxx index a27ad1d1d1c1..faba17cd3b8e 100644 --- a/sw/source/uibase/shells/drwtxtex.cxx +++ b/sw/source/uibase/shells/drwtxtex.cxx @@ -336,7 +336,7 @@ void SwDrawTextShell::Execute( SfxRequest &rReq ) case FN_SET_SUPER_SCRIPT: { SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); - SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue()); + SvxEscapement eEsc = aEditAttr.Get(EE_CHAR_ESCAPEMENT).GetEscapement(); if( eEsc == SvxEscapement::Superscript ) aItem.SetEscapement( SvxEscapement::Off ); @@ -348,7 +348,7 @@ void SwDrawTextShell::Execute( SfxRequest &rReq ) case FN_SET_SUB_SCRIPT: { SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); - SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue()); + SvxEscapement eEsc = aEditAttr.Get(EE_CHAR_ESCAPEMENT).GetEscapement(); if( eEsc == SvxEscapement::Subscript ) aItem.SetEscapement( SvxEscapement::Off );
