From 3588a48a82d37f940595570758bc1d1179d18b84 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 10 Nov 2017 12:48:21 +0200 Subject: TypedWhichId use a strong-typedef template to give which IDs a type, which we can carry around to do a (a) little bit more convenience when Get()'ing them and (b) a little bit of enforcement of which PoolItem subclass each ID uses Fix a bug in casting EE_PARA_BULLETSTATE to the wrong subclass in AccessibleEditableTextPara::_correctValues Change-Id: I015ce8b3b0f6d21308af182afa3caf122c877a5b Reviewed-on: https://gerrit.libreoffice.org/44587 Tested-by: Jenkins Reviewed-by: Noel Grandin --- chart2/source/controller/dialogs/res_DataLabel.cxx | 2 +- chart2/source/controller/dialogs/tp_AxisLabel.cxx | 2 +- .../controller/dialogs/tp_LegendPosition.cxx | 2 +- .../source/controller/dialogs/tp_TitleRotation.cxx | 2 +- .../CharacterPropertyItemConverter.cxx | 8 +-- .../controller/itemsetwrapper/SchWhichPairs.hxx | 2 +- chart2/source/view/main/ChartView.cxx | 2 +- chart2/source/view/main/DrawModelWrapper.cxx | 2 +- editeng/inc/editdoc.hxx | 5 ++ .../accessibility/AccessibleEditableTextPara.cxx | 5 +- editeng/source/editeng/editdbg.cxx | 14 ++--- editeng/source/editeng/editdoc.cxx | 4 +- editeng/source/editeng/editeng.cxx | 2 +- editeng/source/editeng/edtspell.cxx | 6 +-- editeng/source/editeng/eerdll.cxx | 22 ++++---- editeng/source/editeng/eertfpar.cxx | 2 +- editeng/source/editeng/impedit.cxx | 4 +- editeng/source/editeng/impedit.hxx | 5 ++ editeng/source/editeng/impedit2.cxx | 4 +- editeng/source/editeng/impedit3.cxx | 11 ++-- editeng/source/editeng/impedit4.cxx | 8 +-- editeng/source/outliner/outliner.cxx | 20 +++---- editeng/source/outliner/outlvw.cxx | 12 ++--- editeng/source/uno/unotext.cxx | 12 ++--- editeng/source/xml/xmltxtexp.cxx | 6 +-- filter/source/msfilter/msdffimp.cxx | 6 +-- filter/source/msfilter/svdfppt.cxx | 20 +++---- forms/source/richtext/rtattributehandler.cxx | 2 +- include/editeng/editeng.hxx | 6 +++ include/editeng/eeitem.hxx | 31 +++++++---- include/editeng/unotext.hxx | 20 +++---- include/svl/itempool.hxx | 17 ++++++ include/svl/itemset.hxx | 26 +++++++++ include/svl/poolitem.hxx | 9 ++++ include/svl/typedwhich.hxx | 61 ++++++++++++++++++++++ include/svx/svdobj.hxx | 6 +++ sc/source/core/data/column2.cxx | 2 +- sc/source/core/data/drwlayer.cxx | 4 +- sc/source/core/data/patattr.cxx | 8 +-- sc/source/ui/app/inputwin.cxx | 2 +- sc/source/ui/drawfunc/drawsh2.cxx | 2 +- sc/source/ui/drawfunc/drawsh5.cxx | 4 +- sc/source/ui/drawfunc/drtxtob.cxx | 11 ++-- sc/source/ui/drawfunc/drtxtob2.cxx | 8 +-- sc/source/ui/drawfunc/futext.cxx | 2 +- sc/source/ui/view/output2.cxx | 4 +- sc/source/ui/view/printfun.cxx | 2 +- sd/qa/unit/export-tests-ooxml1.cxx | 8 +-- sd/qa/unit/import-tests.cxx | 6 +-- sd/source/core/drawdoc.cxx | 2 +- sd/source/core/drawdoc4.cxx | 16 +++--- sd/source/core/sdpage.cxx | 10 ++-- sd/source/core/stlpool.cxx | 13 +++-- sd/source/core/stlsheet.cxx | 4 +- sd/source/ui/dlg/dlgolbul.cxx | 4 +- sd/source/ui/func/fuolbull.cxx | 6 +-- sd/source/ui/func/fupage.cxx | 4 +- sd/source/ui/func/fuparagr.cxx | 2 +- sd/source/ui/func/futempl.cxx | 2 +- sd/source/ui/func/futext.cxx | 6 +-- sd/source/ui/view/drtxtob.cxx | 6 +-- sd/source/ui/view/drtxtob1.cxx | 14 ++--- sd/source/ui/view/drviews2.cxx | 8 +-- sd/source/ui/view/drviews3.cxx | 26 ++++----- sd/source/ui/view/drviewsf.cxx | 4 +- sd/source/ui/view/outlview.cxx | 2 +- sd/source/ui/view/viewshel.cxx | 6 +-- .../customshapes/EnhancedCustomShapeFontWork.cxx | 2 +- svx/source/svdraw/svdattr.cxx | 12 ++--- svx/source/unodraw/unomod.cxx | 2 +- sw/source/uibase/shells/annotsh.cxx | 10 ++-- sw/source/uibase/shells/drwtxtex.cxx | 12 ++--- sw/source/uibase/uiview/viewdraw.cxx | 9 ++-- 73 files changed, 376 insertions(+), 237 deletions(-) create mode 100644 include/svl/typedwhich.hxx diff --git a/chart2/source/controller/dialogs/res_DataLabel.cxx b/chart2/source/controller/dialogs/res_DataLabel.cxx index 73d8598a6dd2..abfffe1b6355 100644 --- a/chart2/source/controller/dialogs/res_DataLabel.cxx +++ b/chart2/source/controller/dialogs/res_DataLabel.cxx @@ -306,7 +306,7 @@ bool DataLabelResources::FillItemSet( SfxItemSet* rOutAttrs ) const } if( m_pLB_TextDirection->GetSelectedEntryCount() > 0 ) - rOutAttrs->Put( SvxFrameDirectionItem( m_pLB_TextDirection->GetSelectEntryValue(), EE_PARA_WRITINGDIR ) ); + rOutAttrs->Put( SvxFrameDirectionItem( m_pLB_TextDirection->GetSelectEntryValue(), EE_PARA_WRITINGDIR.Which() ) ); if( m_pDC_Dial->IsVisible() ) { diff --git a/chart2/source/controller/dialogs/tp_AxisLabel.cxx b/chart2/source/controller/dialogs/tp_AxisLabel.cxx index 3df8869364be..7fdeb8ffea7d 100644 --- a/chart2/source/controller/dialogs/tp_AxisLabel.cxx +++ b/chart2/source/controller/dialogs/tp_AxisLabel.cxx @@ -149,7 +149,7 @@ bool SchAxisLabelTabPage::FillItemSet( SfxItemSet* rOutAttrs ) rOutAttrs->Put( SfxBoolItem( SCHATTR_AXIS_SHOWDESCR, m_pCbShowDescription->IsChecked() ) ); if( m_pLbTextDirection->GetSelectedEntryCount() > 0 ) - rOutAttrs->Put( SvxFrameDirectionItem( m_pLbTextDirection->GetSelectEntryValue(), EE_PARA_WRITINGDIR ) ); + rOutAttrs->Put( SvxFrameDirectionItem( m_pLbTextDirection->GetSelectEntryValue(), EE_PARA_WRITINGDIR.Which() ) ); return true; } diff --git a/chart2/source/controller/dialogs/tp_LegendPosition.cxx b/chart2/source/controller/dialogs/tp_LegendPosition.cxx index 554235d17343..8c0e7310081d 100644 --- a/chart2/source/controller/dialogs/tp_LegendPosition.cxx +++ b/chart2/source/controller/dialogs/tp_LegendPosition.cxx @@ -63,7 +63,7 @@ bool SchLegendPosTabPage::FillItemSet(SfxItemSet* rOutAttrs) m_aLegendPositionResources.writeToItemSet(*rOutAttrs); if( m_pLbTextDirection->GetSelectedEntryCount() > 0 ) - rOutAttrs->Put( SvxFrameDirectionItem( m_pLbTextDirection->GetSelectEntryValue(), EE_PARA_WRITINGDIR ) ); + rOutAttrs->Put( SvxFrameDirectionItem( m_pLbTextDirection->GetSelectEntryValue(), EE_PARA_WRITINGDIR.Which() ) ); return true; } diff --git a/chart2/source/controller/dialogs/tp_TitleRotation.cxx b/chart2/source/controller/dialogs/tp_TitleRotation.cxx index ae304b22d24e..05537d931c8a 100644 --- a/chart2/source/controller/dialogs/tp_TitleRotation.cxx +++ b/chart2/source/controller/dialogs/tp_TitleRotation.cxx @@ -96,7 +96,7 @@ bool SchAlignmentTabPage::FillItemSet(SfxItemSet* rOutAttrs) rOutAttrs->Put( SfxInt32Item( SCHATTR_TEXT_DEGREES, nDegrees ) ); SvxFrameDirection aDirection( m_pLbTextDirection->GetSelectEntryValue() ); - rOutAttrs->Put( SvxFrameDirectionItem( aDirection, EE_PARA_WRITINGDIR ) ); + rOutAttrs->Put( SvxFrameDirectionItem( aDirection, EE_PARA_WRITINGDIR.Which() ) ); return true; } diff --git a/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx b/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx index 062b4b173b3e..7810f28e4b3c 100644 --- a/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx @@ -56,9 +56,9 @@ ItemPropertyMapType & lcl_GetCharacterPropertyPropertyMap() {EE_CHAR_OUTLINE, {"CharContoured", 0}}, {EE_CHAR_EMPHASISMARK, {"CharEmphasis", 0}}, - {EE_PARA_WRITINGDIR, {"WritingMode", 0}}, + {EE_PARA_WRITINGDIR.Which(), {"WritingMode", 0}}, - {EE_PARA_ASIANCJKSPACING, {"ParaIsCharacterDistance", 0}}}; + {EE_PARA_ASIANCJKSPACING.Which(), {"ParaIsCharacterDistance", 0}}}; return aCharacterPropertyMap; } @@ -296,8 +296,8 @@ void CharacterPropertyItemConverter::FillSpecialItem( } break; - case EE_PARA_FORBIDDENRULES: - case EE_PARA_HANGINGPUNCTUATION: + case EE_PARA_FORBIDDENRULES.Which(): + case EE_PARA_HANGINGPUNCTUATION.Which(): rOutItemSet.DisableItem( nWhichId ); break; } diff --git a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx index b8c85f61c046..3c3d4fd2a1a1 100644 --- a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx +++ b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx @@ -82,7 +82,7 @@ const sal_uInt16 nDataLabelWhichPairs[] = SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, /* 10585 - 10585 svx/svxids.hrc */ SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, /* 11432 svx/svxids.hrc */ SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, - EE_PARA_WRITINGDIR,EE_PARA_WRITINGDIR, + EE_PARA_WRITINGDIR.Which(),EE_PARA_WRITINGDIR.Which(), 0 }; diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 49f1670e9f37..7dc5a3d8e99a 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -1538,7 +1538,7 @@ void lcl_setDefaultWritingMode( const std::shared_ptr< DrawModelWrapper >& pDraw if( nWritingMode != -1 && nWritingMode != text::WritingMode2::PAGE ) { if( pDrawModelWrapper.get() ) - pDrawModelWrapper->GetItemPool().SetPoolDefaultItem(SvxFrameDirectionItem(static_cast(nWritingMode), EE_PARA_WRITINGDIR) ); + pDrawModelWrapper->GetItemPool().SetPoolDefaultItem(SvxFrameDirectionItem(static_cast(nWritingMode), EE_PARA_WRITINGDIR.Which()) ); } } catch( const uno::Exception& ex ) diff --git a/chart2/source/view/main/DrawModelWrapper.cxx b/chart2/source/view/main/DrawModelWrapper.cxx index ab87a0769172..100517b08de1 100644 --- a/chart2/source/view/main/DrawModelWrapper.cxx +++ b/chart2/source/view/main/DrawModelWrapper.cxx @@ -63,7 +63,7 @@ DrawModelWrapper::DrawModelWrapper() SfxItemPool* pMasterPool = &GetItemPool(); pMasterPool->SetDefaultMetric(MapUnit::Map100thMM); - pMasterPool->SetPoolDefaultItem(SfxBoolItem(EE_PARA_HYPHENATE, true) ); + pMasterPool->SetPoolDefaultItem(SfxBoolItem(EE_PARA_HYPHENATE.Which(), true) ); pMasterPool->SetPoolDefaultItem(makeSvx3DPercentDiagonalItem (5)); SfxItemPool* pPool = pMasterPool; diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx index 541ccca8b424..542b6d319982 100644 --- a/editeng/inc/editdoc.hxx +++ b/editeng/inc/editdoc.hxx @@ -174,6 +174,11 @@ public: void SetStyleSheet( SfxStyleSheet* pS ); const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const; + template + const T& GetItem( TypedWhichId nWhich ) const + { + return static_cast(GetItem(nWhich.Which())); + } bool HasItem( sal_uInt16 nWhich ) const; }; diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx index 33f884d7bc62..2348709303b1 100644 --- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx +++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx @@ -52,6 +52,7 @@ #include #include #include +#include // Project-local header @@ -1534,7 +1535,7 @@ namespace accessibility // NumberingLevel if (rRes.Name == "NumberingLevel") { - const SvxNumBulletItem& rNumBullet = static_cast(rCacheTF.GetParaAttribs(GetParagraphIndex()).Get(EE_PARA_NUMBULLET)); + const SvxNumBulletItem& rNumBullet = rCacheTF.GetParaAttribs(GetParagraphIndex()).Get(EE_PARA_NUMBULLET); if(rNumBullet.GetNumRule()->GetLevelCount()==0) { rRes.Value <<= (sal_Int16)-1; @@ -1559,7 +1560,7 @@ namespace accessibility if (rRes.Name == "NumberingRules") { SfxItemSet aAttribs = rCacheTF.GetParaAttribs(GetParagraphIndex()); - bool bVis = static_cast(aAttribs.Get( EE_PARA_BULLETSTATE )).GetValue() != 0; + bool bVis = aAttribs.Get( EE_PARA_BULLETSTATE ).GetValue(); if(bVis) { rRes.Value <<= (sal_Int16)-1; diff --git a/editeng/source/editeng/editdbg.cxx b/editeng/source/editeng/editdbg.cxx index c93477eb7309..40eaab64d1bb 100644 --- a/editeng/source/editeng/editdbg.cxx +++ b/editeng/source/editeng/editdbg.cxx @@ -64,12 +64,12 @@ OString DbgOutItem(const SfxItemPool& rPool, const SfxPoolItem& rItem) OStringBuffer aDebStr; switch ( rItem.Which() ) { - case EE_PARA_WRITINGDIR: + case EE_PARA_WRITINGDIR.Which(): aDebStr.append("WritingDir="); aDebStr.append(static_cast(static_cast(rItem).GetValue())); break; - case EE_PARA_OUTLLRSPACE: - case EE_PARA_LRSPACE: + case EE_PARA_OUTLLRSPACE.Which(): + case EE_PARA_LRSPACE.Which(): aDebStr.append("FI="); aDebStr.append(static_cast(static_cast(rItem).GetTextFirstLineOfst())); aDebStr.append(", LI="); @@ -77,7 +77,7 @@ OString DbgOutItem(const SfxItemPool& rPool, const SfxPoolItem& rItem) aDebStr.append(", RI="); aDebStr.append(static_cast(static_cast(rItem).GetRight())); break; - case EE_PARA_NUMBULLET: + case EE_PARA_NUMBULLET.Which(): aDebStr.append("NumItem "); for ( sal_uInt16 nLevel = 0; nLevel < 3; nLevel++ ) { @@ -106,15 +106,15 @@ OString DbgOutItem(const SfxItemPool& rPool, const SfxPoolItem& rItem) } } break; - case EE_PARA_BULLETSTATE: + case EE_PARA_BULLETSTATE.Which(): aDebStr.append("ShowBullet="); aDebStr.append(static_cast(static_cast(rItem).GetValue())); break; - case EE_PARA_HYPHENATE: + case EE_PARA_HYPHENATE.Which(): aDebStr.append("Hyphenate="); aDebStr.append(static_cast(static_cast(rItem).GetValue())); break; - case EE_PARA_OUTLLEVEL: + case EE_PARA_OUTLLEVEL.Which(): aDebStr.append("Level="); aDebStr.append(static_cast(static_cast(rItem).GetValue())); break; diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 8db5de5780d8..56219c85196e 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -825,7 +825,7 @@ void ConvertItem( SfxPoolItem& rPoolItem, MapUnit eSourceUnit, MapUnit eDestUnit switch ( rPoolItem.Which() ) { - case EE_PARA_LRSPACE: + case EE_PARA_LRSPACE.Which(): { assert(dynamic_cast(&rPoolItem) != nullptr); SvxLRSpaceItem& rItem = static_cast(rPoolItem); @@ -2271,7 +2271,7 @@ EditPaM EditDoc::InsertParaBreak( EditPaM aPaM, bool bKeepEndingAttribs ) ContentAttribs aContentAttribs( aPaM.GetNode()->GetContentAttribs() ); // for a new paragraph we like to have the bullet/numbering visible by default - aContentAttribs.GetItems().Put( SfxBoolItem( EE_PARA_BULLETSTATE, true) ); + aContentAttribs.GetItems().Put( SfxBoolItem( EE_PARA_BULLETSTATE.Which(), true) ); // ContentNode constructor copies also the paragraph attributes ContentNode* pNode = new ContentNode( aStr, aContentAttribs ); diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index bb09af238d99..db6c7710dc38 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -1126,7 +1126,7 @@ bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditView, v sal_Int32 nPara = pImpEditEngine->GetEditDoc().GetPos( pNode ); - SfxBoolItem aBulletState( static_cast( pImpEditEngine->GetParaAttrib( nPara, EE_PARA_BULLETSTATE ) ) ); + SfxBoolItem aBulletState( pImpEditEngine->GetParaAttrib( nPara, EE_PARA_BULLETSTATE ) ); bool bBulletIsVisible = aBulletState.GetValue(); // just toggling EE_PARA_BULLETSTATE should be fine for both cases... diff --git a/editeng/source/editeng/edtspell.cxx b/editeng/source/editeng/edtspell.cxx index a27ae110a04e..e123b64c2bec 100644 --- a/editeng/source/editeng/edtspell.cxx +++ b/editeng/source/editeng/edtspell.cxx @@ -648,14 +648,12 @@ OUString const* EdtAutoCorrDoc::GetPrevPara(bool const) sal_Int32 nPos = rNodes.GetPos( pCurNode ); // Special case: Bullet => Paragraph start => simply return NULL... - const SfxBoolItem& rBulletState = static_cast( - mpEditEngine->GetParaAttrib( nPos, EE_PARA_BULLETSTATE )); + const SfxBoolItem& rBulletState = mpEditEngine->GetParaAttrib( nPos, EE_PARA_BULLETSTATE ); bool bBullet = rBulletState.GetValue(); if ( !bBullet && (mpEditEngine->GetControlWord() & EEControlBits::OUTLINER) ) { // The Outliner has still a Bullet at Level 0. - const SfxInt16Item& rLevel = static_cast( - mpEditEngine->GetParaAttrib( nPos, EE_PARA_OUTLLEVEL )); + const SfxInt16Item& rLevel = mpEditEngine->GetParaAttrib( nPos, EE_PARA_OUTLLEVEL ); if ( rLevel.GetValue() == 0 ) bBullet = true; } diff --git a/editeng/source/editeng/eerdll.cxx b/editeng/source/editeng/eerdll.cxx index a7f74bf2701f..80a6bed5723e 100644 --- a/editeng/source/editeng/eerdll.cxx +++ b/editeng/source/editeng/eerdll.cxx @@ -94,18 +94,18 @@ DefItems::DefItems() // Paragraph attributes: SvxNumRule aDefaultNumRule( SvxNumRuleFlags::NONE, 0, false ); - rDefItems[0] = new SvxFrameDirectionItem( SvxFrameDirection::Horizontal_LR_TB, EE_PARA_WRITINGDIR ); + rDefItems[0] = new SvxFrameDirectionItem( SvxFrameDirection::Horizontal_LR_TB, EE_PARA_WRITINGDIR.Which() ); rDefItems[1] = new SvXMLAttrContainerItem( EE_PARA_XMLATTRIBS ); - rDefItems[2] = new SvxHangingPunctuationItem(false, EE_PARA_HANGINGPUNCTUATION); - rDefItems[3] = new SvxForbiddenRuleItem(true, EE_PARA_FORBIDDENRULES); - rDefItems[4] = new SvxScriptSpaceItem( true, EE_PARA_ASIANCJKSPACING ); - rDefItems[5] = new SvxNumBulletItem( aDefaultNumRule, EE_PARA_NUMBULLET ); - rDefItems[6] = new SfxBoolItem( EE_PARA_HYPHENATE, false ); - rDefItems[7] = new SfxBoolItem( EE_PARA_BULLETSTATE, true ); - rDefItems[8] = new SvxLRSpaceItem( EE_PARA_OUTLLRSPACE ); - rDefItems[9] = new SfxInt16Item( EE_PARA_OUTLLEVEL, -1 ); - rDefItems[10] = new SvxBulletItem( EE_PARA_BULLET ); - rDefItems[11] = new SvxLRSpaceItem( EE_PARA_LRSPACE ); + rDefItems[2] = new SvxHangingPunctuationItem(false, EE_PARA_HANGINGPUNCTUATION.Which()); + rDefItems[3] = new SvxForbiddenRuleItem(true, EE_PARA_FORBIDDENRULES.Which()); + rDefItems[4] = new SvxScriptSpaceItem( true, EE_PARA_ASIANCJKSPACING.Which() ); + rDefItems[5] = new SvxNumBulletItem( aDefaultNumRule, EE_PARA_NUMBULLET.Which() ); + rDefItems[6] = new SfxBoolItem( EE_PARA_HYPHENATE.Which(), false ); + rDefItems[7] = new SfxBoolItem( EE_PARA_BULLETSTATE.Which(), true ); + rDefItems[8] = new SvxLRSpaceItem( EE_PARA_OUTLLRSPACE.Which() ); + rDefItems[9] = new SfxInt16Item( EE_PARA_OUTLLEVEL.Which(), -1 ); + rDefItems[10] = new SvxBulletItem( EE_PARA_BULLET.Which() ); + rDefItems[11] = new SvxLRSpaceItem( EE_PARA_LRSPACE.Which() ); rDefItems[12] = new SvxULSpaceItem( EE_PARA_ULSPACE ); rDefItems[13] = new SvxLineSpacingItem( 0, EE_PARA_SBL ); rDefItems[14] = new SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST ); diff --git a/editeng/source/editeng/eertfpar.cxx b/editeng/source/editeng/eertfpar.cxx index 428e76cc5e32..5f81f3709c2f 100644 --- a/editeng/source/editeng/eertfpar.cxx +++ b/editeng/source/editeng/eertfpar.cxx @@ -433,7 +433,7 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet ) for ( sal_Int32 n = nStartNode; n <= nEndNode; n++ ) { ContentNode* pNode = mpEditEngine->GetEditDoc().GetObject( n ); - pNode->GetContentAttribs().GetItems().Put( SfxInt16Item( EE_PARA_OUTLLEVEL, nOutlLevel ) ); + pNode->GetContentAttribs().GetItems().Put( SfxInt16Item( EE_PARA_OUTLLEVEL.Which(), nOutlLevel ) ); } } } diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx index 1cadc38a7539..6a89f6f360f0 100644 --- a/editeng/source/editeng/impedit.cxx +++ b/editeng/source/editeng/impedit.cxx @@ -1876,10 +1876,10 @@ void ImpEditView::dragGestureRecognized(const css::datatransfer::dnd::DragGestur pDragAndDropInfo->bOutlinerMode = true; EditPaM aStartPaM( pEditEngine->GetEditDoc().GetObject( nPara ), 0 ); EditPaM aEndPaM( aStartPaM ); - const SfxInt16Item& rLevel = static_cast(pEditEngine->GetParaAttrib( nPara, EE_PARA_OUTLLEVEL )); + const SfxInt16Item& rLevel = pEditEngine->GetParaAttrib( nPara, EE_PARA_OUTLLEVEL ); for ( sal_Int32 n = nPara +1; n < pEditEngine->GetEditDoc().Count(); n++ ) { - const SfxInt16Item& rL = static_cast( pEditEngine->GetParaAttrib( n, EE_PARA_OUTLLEVEL ) ); + const SfxInt16Item& rL = pEditEngine->GetParaAttrib( n, EE_PARA_OUTLLEVEL ); if ( rL.GetValue() > rLevel.GetValue() ) { aEndPaM.SetNode( pEditEngine->GetEditDoc().GetObject( n ) ); diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 3f1e0f3f0b05..56e27e67b5b4 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -852,6 +852,11 @@ public: bool HasParaAttrib( sal_Int32 nPara, sal_uInt16 nWhich ) const; const SfxPoolItem& GetParaAttrib( sal_Int32 nPara, sal_uInt16 nWhich ) const; + template + const T& GetParaAttrib( sal_Int32 nPara, TypedWhichId nWhich ) const + { + return static_cast(GetParaAttrib(nPara, nWhich.Which())); + } tools::Rectangle PaMtoEditCursor( EditPaM aPaM, GetCursorFlags nFlags = GetCursorFlags::NONE ); tools::Rectangle GetEditCursor( ParaPortion* pPortion, sal_Int32 nIndex, GetCursorFlags nFlags = GetCursorFlags::NONE ); diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 1cb3649e89b1..a8571b69a200 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -1972,7 +1972,7 @@ bool ImpEditEngine::IsRightToLeft( sal_Int32 nPara ) const if ( !IsVertical() ) { bR2L = GetDefaultHorizontalTextDirection() == EE_HTEXTDIR_R2L; - pFrameDirItem = &static_cast(GetParaAttrib( nPara, EE_PARA_WRITINGDIR )); + pFrameDirItem = &GetParaAttrib( nPara, EE_PARA_WRITINGDIR ); if ( pFrameDirItem->GetValue() == SvxFrameDirection::Environment ) { // #103045# if DefaultHorizontalTextDirection is set, use that value, otherwise pool default. @@ -1983,7 +1983,7 @@ bool ImpEditEngine::IsRightToLeft( sal_Int32 nPara ) const else { // Use pool default - pFrameDirItem = &static_cast(const_cast(this)->GetEmptyItemSet().Get( EE_PARA_WRITINGDIR )); + pFrameDirItem = &const_cast(this)->GetEmptyItemSet().Get( EE_PARA_WRITINGDIR ); } } } diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index 6d153502585f..dece17fbb7a9 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include "impedit.hxx" #include #include @@ -54,6 +55,7 @@ #include #include +#include #include #include @@ -638,13 +640,13 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) bool bRightToLeftPara = IsRightToLeft( nPara ); SvxAdjust eJustification = GetJustification( nPara ); - bool bHyphenatePara = static_cast(pNode->GetContentAttribs().GetItem( EE_PARA_HYPHENATE )).GetValue(); + bool bHyphenatePara = pNode->GetContentAttribs().GetItem( EE_PARA_HYPHENATE ).GetValue(); sal_Int32 nSpaceBefore = 0; sal_Int32 nMinLabelWidth = 0; sal_Int32 nSpaceBeforeAndMinLabelWidth = GetSpaceBeforeAndMinLabelWidth( pNode, &nSpaceBefore, &nMinLabelWidth ); const SvxLRSpaceItem& rLRItem = GetLRSpaceItem( pNode ); const SvxLineSpacingItem& rLSItem = static_cast( pNode->GetContentAttribs().GetItem( EE_PARA_SBL ) ); - const bool bScriptSpace = static_cast(pNode->GetContentAttribs().GetItem( EE_PARA_ASIANCJKSPACING )).GetValue(); + const bool bScriptSpace = pNode->GetContentAttribs().GetItem( EE_PARA_ASIANCJKSPACING ).GetValue(); const short nInvalidDiff = pParaPortion->GetInvalidDiff(); const sal_Int32 nInvalidStart = pParaPortion->GetInvalidPosStart(); @@ -3080,8 +3082,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, tools::Rectangle aClipRect, Po GetEditEnginePtr()->PaintingFirstLine( n, aParaStart, aTmpPos.Y(), aOrigin, nOrientation, pOutDev ); // Remember whether a bullet was painted. - const SfxBoolItem& rBulletState = static_cast( - pEditEngine->GetParaAttrib(n, EE_PARA_BULLETSTATE)); + const SfxBoolItem& rBulletState = pEditEngine->GetParaAttrib(n, EE_PARA_BULLETSTATE); bPaintBullet = rBulletState.GetValue(); } @@ -4329,7 +4330,7 @@ sal_Int32 ImpEditEngine::GetSpaceBeforeAndMinLabelWidth( const SvxLRSpaceItem& ImpEditEngine::GetLRSpaceItem( ContentNode* pNode ) { - return static_cast(pNode->GetContentAttribs().GetItem( aStatus.IsOutliner() ? EE_PARA_OUTLLRSPACE : EE_PARA_LRSPACE )); + return pNode->GetContentAttribs().GetItem( aStatus.IsOutliner() ? EE_PARA_OUTLLRSPACE : EE_PARA_LRSPACE ); } // select a representative text language for the digit type according to the diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index 6b82c0b658d6..1019cc0b84fc 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -673,7 +673,7 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, sal_uInt16 nWhich = rItem.Which(); switch ( nWhich ) { - case EE_PARA_WRITINGDIR: + case EE_PARA_WRITINGDIR.Which(): { const SvxFrameDirectionItem& rWritingMode = static_cast(rItem); if ( rWritingMode.GetValue() == SvxFrameDirection::Horizontal_RL_TB ) @@ -682,7 +682,7 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, rOutput.WriteCharPtr( "\\ltrpar" ); } break; - case EE_PARA_OUTLLEVEL: + case EE_PARA_OUTLLEVEL.Which(): { sal_Int32 nLevel = static_cast(rItem).GetValue(); if( nLevel >= 0 ) @@ -692,8 +692,8 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, } } break; - case EE_PARA_OUTLLRSPACE: - case EE_PARA_LRSPACE: + case EE_PARA_OUTLLRSPACE.Which(): + case EE_PARA_LRSPACE.Which(): { rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_FI ); sal_Int32 nTxtFirst = static_cast(rItem).GetTextFirstLineOfst(); diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index e4455865396d..6ef469e64c3e 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -132,7 +132,7 @@ void Outliner::ParagraphInserted( sal_Int32 nPara ) { pPara->nFlags = ParaFlag::SETBULLETTEXT; pPara->bVisible = true; - const SfxInt16Item& rLevel = static_cast( pEditEngine->GetParaAttrib( nPara, EE_PARA_OUTLLEVEL ) ); + const SfxInt16Item& rLevel = pEditEngine->GetParaAttrib( nPara, EE_PARA_OUTLLEVEL ); pPara->SetDepth( rLevel.GetValue() ); } } @@ -550,7 +550,7 @@ bool Outliner::ImpConvertEdtToOut( sal_Int32 nPara ) pEditEngine->QuickDelete( aDelSel ); } - const SfxInt16Item& rLevel = static_cast( pEditEngine->GetParaAttrib( nPara, EE_PARA_OUTLLEVEL ) ); + const SfxInt16Item& rLevel = pEditEngine->GetParaAttrib( nPara, EE_PARA_OUTLLEVEL ); sal_Int16 nOutlLevel = rLevel.GetValue(); ImplCheckDepth( nOutlLevel ); @@ -726,7 +726,7 @@ void Outliner::ImplInitDepth( sal_Int32 nPara, sal_Int16 nDepth, bool bCreateUnd bool bUndo = bCreateUndo && IsUndoEnabled(); SfxItemSet aAttrs( pEditEngine->GetParaAttribs( nPara ) ); - aAttrs.Put( SfxInt16Item( EE_PARA_OUTLLEVEL, nDepth ) ); + aAttrs.Put( SfxInt16Item( EE_PARA_OUTLLEVEL.Which(), nDepth ) ); pEditEngine->SetParaAttribs( nPara, aAttrs ); ImplCheckNumBulletItem( nPara ); ImplCalcBulletText( nPara, false, false ); @@ -871,7 +871,7 @@ void Outliner::PaintBullet( sal_Int32 nPara, const Point& rStartPos, bool bDrawBullet = false; if (pEditEngine) { - const SfxBoolItem& rBulletState = static_cast( pEditEngine->GetParaAttrib( nPara, EE_PARA_BULLETSTATE ) ); + const SfxBoolItem& rBulletState = pEditEngine->GetParaAttrib( nPara, EE_PARA_BULLETSTATE ); bDrawBullet = rBulletState.GetValue(); } @@ -1107,7 +1107,7 @@ ErrCode Outliner::Read( SvStream& rInput, const OUString& rBaseURL, sal_uInt16 e if ( eFormat == EE_FORMAT_BIN ) { const SfxItemSet& rAttrs = pEditEngine->GetParaAttribs( n ); - const SfxInt16Item& rLevel = static_cast( rAttrs.Get( EE_PARA_OUTLLEVEL )); + const SfxInt16Item& rLevel = rAttrs.Get( EE_PARA_OUTLLEVEL ); sal_Int16 nDepth = rLevel.GetValue(); ImplInitDepth( n, nDepth, false ); } @@ -1197,7 +1197,7 @@ void Outliner::ImpTextPasted( sal_Int32 nStartPara, sal_Int32 nCount ) const SfxItemSet& rAttrs = pEditEngine->GetParaAttribs( nStartPara ); if ( rAttrs.GetItemState( EE_PARA_OUTLLEVEL ) == SfxItemState::SET ) { - const SfxInt16Item& rLevel = static_cast( rAttrs.Get( EE_PARA_OUTLLEVEL ) ); + const SfxInt16Item& rLevel = rAttrs.Get( EE_PARA_OUTLLEVEL ); nDepth = rLevel.GetValue(); } if ( nDepth != GetDepth( nStartPara ) ) @@ -1402,7 +1402,7 @@ const SvxNumberFormat* Outliner::GetNumberFormat( sal_Int32 nPara ) const if( nDepth >= 0 ) { - const SvxNumBulletItem& rNumBullet = static_cast( pEditEngine->GetParaAttrib( nPara, EE_PARA_NUMBULLET ) ); + const SvxNumBulletItem& rNumBullet = pEditEngine->GetParaAttrib( nPara, EE_PARA_NUMBULLET ); if ( rNumBullet.GetNumRule()->GetLevelCount() > nDepth ) pFmt = rNumBullet.GetNumRule()->Get( nDepth ); } @@ -1486,7 +1486,7 @@ void Outliner::ParaAttribsChanged( sal_Int32 nPara ) return; // tdf#100734: force update of bullet pPara->Invalidate(); - const SfxInt16Item& rLevel = static_cast( pEditEngine->GetParaAttrib( nPara, EE_PARA_OUTLLEVEL ) ); + const SfxInt16Item& rLevel = pEditEngine->GetParaAttrib( nPara, EE_PARA_OUTLLEVEL ); if (pPara->GetDepth() == rLevel.GetValue()) return; pPara->SetDepth(rLevel.GetValue()); @@ -1530,7 +1530,7 @@ tools::Rectangle Outliner::ImpCalcBulletArea( sal_Int32 nPara, bool bAdjust, boo // the ODF attribute text:space-before which holds the spacing to add to the left of the label const short nSpaceBefore = pFmt->GetAbsLSpace() + pFmt->GetFirstLineOffset(); - const SvxLRSpaceItem& rLR = static_cast( pEditEngine->GetParaAttrib( nPara, bOutlineMode ? EE_PARA_OUTLLRSPACE : EE_PARA_LRSPACE ) ); + const SvxLRSpaceItem& rLR = pEditEngine->GetParaAttrib( nPara, bOutlineMode ? EE_PARA_OUTLLRSPACE : EE_PARA_LRSPACE ); aTopLeft.X() = rLR.GetTextLeft() + rLR.GetTextFirstLineOfst() + nSpaceBefore; long nBulletWidth = std::max( (long) -rLR.GetTextFirstLineOfst(), (long) ((-pFmt->GetFirstLineOffset()) + pFmt->GetCharTextDistance()) ); @@ -1824,7 +1824,7 @@ sal_uInt16 Outliner::ImplGetNumbering( sal_Int32 nPara, const SvxNumberFormat* p pParaFmt = pFmt; } - const SfxBoolItem& rBulletState = static_cast( pEditEngine->GetParaAttrib( nPara, EE_PARA_BULLETSTATE ) ); + const SfxBoolItem& rBulletState = pEditEngine->GetParaAttrib( nPara, EE_PARA_BULLETSTATE ); if( rBulletState.GetValue() ) nNumber += 1; diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx index e9e8c4e02036..a83110ee3876 100644 --- a/editeng/source/outliner/outlvw.cxx +++ b/editeng/source/outliner/outlvw.cxx @@ -878,7 +878,7 @@ void OutlinerView::ToggleBullets() { SfxItemSet aAttrs( pOwner->GetParaAttribs( nPara ) ); SvxNumRule aNewNumRule( *pDefaultBulletNumRule ); - aAttrs.Put( SvxNumBulletItem( aNewNumRule, EE_PARA_NUMBULLET ) ); + aAttrs.Put( SvxNumBulletItem( aNewNumRule, EE_PARA_NUMBULLET.Which() ) ); pOwner->SetParaAttribs( nPara, aAttrs ); } } @@ -1013,7 +1013,7 @@ void OutlinerView::ApplyBulletsNumbering( const SfxItemSet& rAttrs = pOwner->GetParaAttribs(nPara); SfxItemSet aAttrs(rAttrs); - aAttrs.Put(SfxBoolItem(EE_PARA_BULLETSTATE, true)); + aAttrs.Put(SfxBoolItem(EE_PARA_BULLETSTATE.Which(), true)); // apply new numbering rule if ( pNewNumRule ) @@ -1083,7 +1083,7 @@ void OutlinerView::ApplyBulletsNumbering( } } - aAttrs.Put(SvxNumBulletItem(aNewRule, EE_PARA_NUMBULLET)); + aAttrs.Put(SvxNumBulletItem(aNewRule, EE_PARA_NUMBULLET.Which())); } } pOwner->SetParaAttribs(nPara, aAttrs); @@ -1132,10 +1132,10 @@ void OutlinerView::SwitchOffBulletsNumbering( pOwner->SetDepth( pPara, -1 ); const SfxItemSet& rAttrs = pOwner->GetParaAttribs( nPara ); - if (rAttrs.GetItemState( EE_PARA_BULLETSTATE ) == SfxItemState::SET) + if (rAttrs.GetItemState( EE_PARA_BULLETSTATE.Which() ) == SfxItemState::SET) { SfxItemSet aAttrs(rAttrs); - aAttrs.ClearItem( EE_PARA_BULLETSTATE ); + aAttrs.ClearItem( EE_PARA_BULLETSTATE.Which() ); pOwner->SetParaAttribs( nPara, aAttrs ); } } @@ -1391,7 +1391,7 @@ void OutlinerView::Read( SvStream& rInput, EETextFormat eFormat, SvKeyValueItera if ( eFormat == EE_FORMAT_BIN ) { const SfxItemSet& rAttrs = pOwner->GetParaAttribs( n ); - const SfxInt16Item& rLevel = static_cast( rAttrs.Get( EE_PARA_OUTLLEVEL ) ); + const SfxInt16Item& rLevel = rAttrs.Get( EE_PARA_OUTLLEVEL ); sal_uInt16 nDepth = rLevel.GetValue(); pOwner->ImplInitDepth( n, nDepth, false ); } diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx index d5c0a32d8b06..eb745a27f4c9 100644 --- a/editeng/source/uno/unotext.cxx +++ b/editeng/source/uno/unotext.cxx @@ -506,7 +506,7 @@ bool SvxUnoTextRangeBase::SetPropertyValueHelper( const SfxItemPropertySimpleEnt } break; - case EE_PARA_NUMBULLET: + case EE_PARA_NUMBULLET.Which(): { uno::Reference< container::XIndexReplace > xRule; return !aValue.hasValue() || ((aValue >>= xRule) && !xRule.is()); @@ -557,12 +557,12 @@ bool SvxUnoTextRangeBase::SetPropertyValueHelper( const SfxItemPropertySimpleEnt } } break; - case EE_PARA_BULLETSTATE: + case EE_PARA_BULLETSTATE.Which(): { bool bBullet = true; if( aValue >>= bBullet ) { - SfxBoolItem aItem( EE_PARA_BULLETSTATE, bBullet ); + SfxBoolItem aItem( EE_PARA_BULLETSTATE.Which(), bBullet ); rNewSet.Put(aItem); return true; } @@ -678,13 +678,13 @@ bool SvxUnoTextRangeBase::GetPropertyValueHelper( SfxItemSet const & rSet, cons } break; - case EE_PARA_NUMBULLET: + case EE_PARA_NUMBULLET.Which(): { SfxItemState eState = rSet.GetItemState( EE_PARA_NUMBULLET ); if( eState != SfxItemState::SET && eState != SfxItemState::DEFAULT) throw uno::RuntimeException(); - const SvxNumBulletItem* pBulletItem = rSet.GetItem( EE_PARA_NUMBULLET ); + const SvxNumBulletItem* pBulletItem = rSet.GetItem( EE_PARA_NUMBULLET ); if( pBulletItem == nullptr ) throw uno::RuntimeException(); @@ -719,7 +719,7 @@ bool SvxUnoTextRangeBase::GetPropertyValueHelper( SfxItemSet const & rSet, cons } break; - case EE_PARA_BULLETSTATE: + case EE_PARA_BULLETSTATE.Which(): { bool bState = false; SfxItemState eState = rSet.GetItemState( EE_PARA_BULLETSTATE ); diff --git a/editeng/source/xml/xmltxtexp.cxx b/editeng/source/xml/xmltxtexp.cxx index 1ada3a700339..b3ffd98b675b 100644 --- a/editeng/source/xml/xmltxtexp.cxx +++ b/editeng/source/xml/xmltxtexp.cxx @@ -281,9 +281,9 @@ SvxXMLTextExportComponent::SvxXMLTextExportComponent( { SVX_UNOEDIT_CHAR_PROPERTIES, SVX_UNOEDIT_FONT_PROPERTIES, - { OUString(UNO_NAME_NUMBERING_RULES), EE_PARA_NUMBULLET, cppu::UnoType::get(), 0, 0 }, - { OUString(UNO_NAME_NUMBERING), EE_PARA_BULLETSTATE,cppu::UnoType::get(), 0, 0 }, - { OUString(UNO_NAME_NUMBERING_LEVEL), EE_PARA_OUTLLEVEL, ::cppu::UnoType::get(), 0, 0 }, + { OUString(UNO_NAME_NUMBERING_RULES), EE_PARA_NUMBULLET.Which(), cppu::UnoType::get(), 0, 0 }, + { OUString(UNO_NAME_NUMBERING), EE_PARA_BULLETSTATE.Which(),cppu::UnoType::get(), 0, 0 }, + { OUString(UNO_NAME_NUMBERING_LEVEL), EE_PARA_OUTLLEVEL.Which(), ::cppu::UnoType::get(), 0, 0 }, SVX_UNOEDIT_PARA_PROPERTIES, { OUString(), 0, css::uno::Type(), 0, 0 } }; diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index 25be4f0f04f6..63f152418418 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -1532,7 +1532,7 @@ void DffPropertyReader::ApplyCustomShapeTextAttributes( SfxItemSet& rSet ) const break; } } - rSet.Put( SvxFrameDirectionItem( bVerticalText ? SvxFrameDirection::Vertical_RL_TB : SvxFrameDirection::Horizontal_LR_TB, EE_PARA_WRITINGDIR ) ); + rSet.Put( SvxFrameDirectionItem( bVerticalText ? SvxFrameDirection::Vertical_RL_TB : SvxFrameDirection::Horizontal_LR_TB, EE_PARA_WRITINGDIR.Which() ) ); rSet.Put( SdrTextVertAdjustItem( eTVA ) ); rSet.Put( SdrTextHorzAdjustItem( eTHA ) ); @@ -3661,7 +3661,7 @@ void SvxMSDffManager::ReadObjText( const OUString& rText, SdrObject* pObj ) SfxItemSet aParagraphAttribs( rOutliner.GetEmptyItemSet() ); if ( !aSelection.nStartPos ) - aParagraphAttribs.Put( SfxBoolItem( EE_PARA_BULLETSTATE, false ) ); + aParagraphAttribs.Put( SfxBoolItem( EE_PARA_BULLETSTATE.Which(), false ) ); aSelection.nStartPos = 0; rOutliner.QuickSetAttribs( aParagraphAttribs, aSelection ); nParaIndex++; @@ -4469,7 +4469,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r if ( bIsRTL ) { SfxItemSet aSet2( rOutliner.GetParaAttribs( i ) ); - aSet2.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_RL_TB, EE_PARA_WRITINGDIR ) ); + aSet2.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_RL_TB, EE_PARA_WRITINGDIR.Which() ) ); rOutliner.SetParaAttribs( i, aSet2 ); bCreateNewParaObject = true; } diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx index 0ba7d259d7a5..78ee76593663 100644 --- a/filter/source/msfilter/svdfppt.cxx +++ b/filter/source/msfilter/svdfppt.cxx @@ -1090,7 +1090,7 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi bAutoGrowHeight = bFitShapeToText; } } - pTObj->SetMergedItem( SvxFrameDirectionItem( bVerticalText ? SvxFrameDirection::Vertical_RL_TB : SvxFrameDirection::Horizontal_LR_TB, EE_PARA_WRITINGDIR ) ); + pTObj->SetMergedItem( SvxFrameDirectionItem( bVerticalText ? SvxFrameDirection::Vertical_RL_TB : SvxFrameDirection::Horizontal_LR_TB, EE_PARA_WRITINGDIR.Which() ) ); //Autofit text only if there is no auto grow height and width //See fdo#41245 @@ -2329,11 +2329,11 @@ SdrObject* SdrPowerPointImport::ApplyTextObj( PPTTextObj* pTextObj, SdrTextObj* sal_uInt32 nIsBullet2 = 0; //, nInstance = nDestinationInstance != 0xffffffff ? nDestinationInstance : pTextObj->GetInstance(); pPara->GetAttrib( PPT_ParaAttr_BulletOn, nIsBullet2, nDestinationInstance ); if ( !nIsBullet2 ) - aParagraphAttribs.Put( SfxBoolItem( EE_PARA_BULLETSTATE, false ) ); + aParagraphAttribs.Put( SfxBoolItem( EE_PARA_BULLETSTATE.Which(), false ) ); if ( !aSelection.nStartPos ) // in PPT empty paragraphs never gets a bullet { - aParagraphAttribs.Put( SfxBoolItem( EE_PARA_BULLETSTATE, false ) ); + aParagraphAttribs.Put( SfxBoolItem( EE_PARA_BULLETSTATE.Which(), false ) ); } aSelection.nStartPos = 0; rOutliner.QuickSetAttribs( aParagraphAttribs, aSelection ); @@ -4396,7 +4396,7 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd aRule.SetLevel( 0, aNumberFormat ); } } - mpNumBulletItem[ i ] = new SvxNumBulletItem( aRule, EE_PARA_NUMBULLET ); + mpNumBulletItem[ i ] = new SvxNumBulletItem( aRule, EE_PARA_NUMBULLET.Which() ); } } @@ -6231,7 +6231,7 @@ void PPTParagraphObj::ApplyTo( SfxItemSet& rSet, boost::optional< sal_Int16 >& GetAttrib(PPT_ParaAttr_BulletOfs, _nBulletOfs, nDestinationInstance); if ( !nIsBullet2 ) { - SvxLRSpaceItem aLRSpaceItem( EE_PARA_LRSPACE ); + SvxLRSpaceItem aLRSpaceItem( EE_PARA_LRSPACE.Which() ); sal_uInt16 nAbsLSpace = (sal_uInt16)( ( _nTextOfs * 2540 ) / 576 ); sal_uInt16 nFirstLineOffset = nAbsLSpace - (sal_uInt16)( ( _nBulletOfs * 2540 ) / 576 ); aLRSpaceItem.SetLeft( nAbsLSpace ); @@ -6240,7 +6240,7 @@ void PPTParagraphObj::ApplyTo( SfxItemSet& rSet, boost::optional< sal_Int16 >& } else { - SvxLRSpaceItem aLRSpaceItem( EE_PARA_LRSPACE ); + SvxLRSpaceItem aLRSpaceItem( EE_PARA_LRSPACE.Which() ); aLRSpaceItem.SetLeft( 0 ); aLRSpaceItem.SetTextFirstLineOfstValue( 0 ); rSet.Put( aLRSpaceItem ); @@ -6255,12 +6255,12 @@ void PPTParagraphObj::ApplyTo( SfxItemSet& rSet, boost::optional< sal_Int16 >& } if ( GetAttrib( PPT_ParaAttr_AsianLB_1, nVal, nDestinationInstance ) ) - rSet.Put(SvxForbiddenRuleItem(nVal != 0, EE_PARA_FORBIDDENRULES)); + rSet.Put(SvxForbiddenRuleItem(nVal != 0, EE_PARA_FORBIDDENRULES.Which())); if ( GetAttrib( PPT_ParaAttr_AsianLB_3, nVal, nDestinationInstance ) ) - rSet.Put(SvxHangingPunctuationItem(nVal != 0, EE_PARA_HANGINGPUNCTUATION)); + rSet.Put(SvxHangingPunctuationItem(nVal != 0, EE_PARA_HANGINGPUNCTUATION.Which())); if ( GetAttrib( PPT_ParaAttr_BiDi, nVal, nDestinationInstance ) ) - rSet.Put( SvxFrameDirectionItem( nVal == 1 ? SvxFrameDirection::Horizontal_RL_TB : SvxFrameDirection::Horizontal_LR_TB, EE_PARA_WRITINGDIR ) ); + rSet.Put( SvxFrameDirectionItem( nVal == 1 ? SvxFrameDirection::Horizontal_RL_TB : SvxFrameDirection::Horizontal_LR_TB, EE_PARA_WRITINGDIR.Which() ) ); // LineSpacing PPTPortionObj* pPortion = First(); @@ -7406,7 +7406,7 @@ void ApplyCellAttributes( const SdrObject* pObj, Reference< XCell > const & xCel //set textHorizontalAdjust and TextWritingMode attr const sal_Int32 eHA(static_cast(pObj->GetMergedItem(SDRATTR_TEXT_HORZADJUST)).GetValue()); - const SvxFrameDirection eDirection = static_cast(pObj->GetMergedItem(EE_PARA_WRITINGDIR)).GetValue(); + const SvxFrameDirection eDirection = pObj->GetMergedItem(EE_PARA_WRITINGDIR).GetValue(); xPropSet->setPropertyValue( "TextHorizontalAdjust" , Any( eHA ) ); if ( eDirection == SvxFrameDirection::Vertical_RL_TB ) {//vertical writing diff --git a/forms/source/richtext/rtattributehandler.cxx b/forms/source/richtext/rtattributehandler.cxx index 84d3464e571c..6ea84eab3ebd 100644 --- a/forms/source/richtext/rtattributehandler.cxx +++ b/forms/source/richtext/rtattributehandler.cxx @@ -369,7 +369,7 @@ namespace frm } ParagraphDirectionHandler::ParagraphDirectionHandler( AttributeId _nAttributeId ) - :AttributeHandler( _nAttributeId, EE_PARA_WRITINGDIR ) + :AttributeHandler( _nAttributeId, EE_PARA_WRITINGDIR.Which() ) ,m_eParagraphDirection( SvxFrameDirection::Horizontal_LR_TB ) ,m_eDefaultAdjustment( SvxAdjust::Right ) ,m_eOppositeDefaultAdjustment( SvxAdjust::Left ) diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx index e7b33cfd5345..4f0be32b9dee 100644 --- a/include/editeng/editeng.hxx +++ b/include/editeng/editeng.hxx @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -319,6 +320,11 @@ public: bool HasParaAttrib( sal_Int32 nPara, sal_uInt16 nWhich ) const; const SfxPoolItem& GetParaAttrib( sal_Int32 nPara, sal_uInt16 nWhich ); + template + const T& GetParaAttrib( sal_Int32 nPara, TypedWhichId nWhich ) + { + return static_cast(GetParaAttrib(nPara, nWhich.Which())); + } vcl::Font GetStandardFont( sal_Int32 nPara ); SvxFont GetStandardSvxFont( sal_Int32 nPara ); diff --git a/include/editeng/eeitem.hxx b/include/editeng/eeitem.hxx index 19393957e6bf..afc0eb8cd715 100644 --- a/include/editeng/eeitem.hxx +++ b/include/editeng/eeitem.hxx @@ -21,6 +21,15 @@ #define INCLUDED_EDITENG_EEITEM_HXX #include +#include + +class SvxForbiddenRuleItem; +class SvxFrameDirectionItem; +class SvxHangingPunctuationItem; +class SfxBoolItem; +class SfxInt16Item; +class SvxLRSpaceItem; +class SvxScriptSpaceItem; /* * NOTE: Changes in this file will probably require @@ -32,18 +41,18 @@ // Paragraph attributes: #define EE_PARA_START (EE_ITEMS_START+0) -#define EE_PARA_WRITINGDIR (EE_ITEMS_START+0) +#define EE_PARA_WRITINGDIR TypedWhichId(EE_ITEMS_START+0) #define EE_PARA_XMLATTRIBS (EE_ITEMS_START+1) -#define EE_PARA_HANGINGPUNCTUATION (EE_ITEMS_START+2) -#define EE_PARA_FORBIDDENRULES (EE_ITEMS_START+3) -#define EE_PARA_ASIANCJKSPACING (EE_ITEMS_START+4) -#define EE_PARA_NUMBULLET (EE_ITEMS_START+5) -#define EE_PARA_HYPHENATE (EE_ITEMS_START+6) -#define EE_PARA_BULLETSTATE (EE_ITEMS_START+7) -#define EE_PARA_OUTLLRSPACE (EE_ITEMS_START+8) -#define EE_PARA_OUTLLEVEL (EE_ITEMS_START+9) -#define EE_PARA_BULLET (EE_ITEMS_START+10) -#define EE_PARA_LRSPACE (EE_ITEMS_START+11) +#define EE_PARA_HANGINGPUNCTUATION TypedWhichId(EE_ITEMS_START+2) +#define EE_PARA_FORBIDDENRULES TypedWhichId(EE_ITEMS_START+3) +#define EE_PARA_ASIANCJKSPACING TypedWhichId(EE_ITEMS_START+4) +#define EE_PARA_NUMBULLET TypedWhichId(EE_ITEMS_START+5) +#define EE_PARA_HYPHENATE TypedWhichId(EE_ITEMS_START+6) +#define EE_PARA_BULLETSTATE TypedWhichId(EE_ITEMS_START+7) +#define EE_PARA_OUTLLRSPACE TypedWhichId(EE_ITEMS_START+8) +#define EE_PARA_OUTLLEVEL TypedWhichId(EE_ITEMS_START+9) +#define EE_PARA_BULLET TypedWhichId(EE_ITEMS_START+10) +#define EE_PARA_LRSPACE TypedWhichId(EE_ITEMS_START+11) #define EE_PARA_ULSPACE (EE_ITEMS_START+12) #define EE_PARA_SBL (EE_ITEMS_START+13) #define EE_PARA_JUST (EE_ITEMS_START+14) diff --git a/include/editeng/unotext.hxx b/include/editeng/unotext.hxx index d2d29a8b0078..d55a5da31123 100644 --- a/include/editeng/unotext.hxx +++ b/include/editeng/unotext.hxx @@ -70,8 +70,8 @@ class SvxItemPropertySet; #define WID_PARAISNUMBERINGRESTART OWN_ATTR_VALUE_START+4 #define SVX_UNOEDIT_NUMBERING_PROPERTIE \ - {OUString(UNO_NAME_NUMBERING_RULES), EE_PARA_NUMBULLET, cppu::UnoType::get(), 0, 0 }, \ - {OUString(UNO_NAME_NUMBERING), EE_PARA_BULLETSTATE,cppu::UnoType::get(), 0, 0 } + {OUString(UNO_NAME_NUMBERING_RULES), EE_PARA_NUMBULLET.Which(), cppu::UnoType::get(), 0, 0 }, \ + {OUString(UNO_NAME_NUMBERING), EE_PARA_BULLETSTATE.Which(),cppu::UnoType::get(), 0, 0 } #define SVX_UNOEDIT_OUTLINER_PROPERTIES \ SVX_UNOEDIT_NUMBERING_PROPERTIE, \ @@ -138,18 +138,18 @@ class SvxItemPropertySet; #define SVX_UNOEDIT_PARA_PROPERTIES \ {OUString(UNO_NAME_EDIT_PARA_ADJUST), EE_PARA_JUST, ::cppu::UnoType::get(), 0, MID_PARA_ADJUST }, \ {OUString(UNO_NAME_EDIT_PARA_BMARGIN), EE_PARA_ULSPACE, ::cppu::UnoType::get(), 0, MID_LO_MARGIN|SFX_METRIC_ITEM }, \ - {OUString(UNO_NAME_EDIT_PARA_IS_HYPHEN), EE_PARA_HYPHENATE, cppu::UnoType::get(), 0, 0 }, \ + {OUString(UNO_NAME_EDIT_PARA_IS_HYPHEN), EE_PARA_HYPHENATE.Which(), ::cppu::UnoType::get(), 0, 0 }, \ {OUString(UNO_NAME_EDIT_PARA_LASTLINEADJ), EE_PARA_JUST, ::cppu::UnoType::get(), 0, MID_LAST_LINE_ADJUST }, \ - {OUString(UNO_NAME_EDIT_PARA_LMARGIN), EE_PARA_LRSPACE, ::cppu::UnoType::get(), 0, MID_TXT_LMARGIN|SFX_METRIC_ITEM }, \ + {OUString(UNO_NAME_EDIT_PARA_LMARGIN), EE_PARA_LRSPACE.Which(), ::cppu::UnoType::get(), 0, MID_TXT_LMARGIN|SFX_METRIC_ITEM }, \ {OUString(UNO_NAME_EDIT_PARA_LINESPACING), EE_PARA_SBL, cppu::UnoType::get(), 0, CONVERT_TWIPS}, \ - {OUString(UNO_NAME_EDIT_PARA_RMARGIN), EE_PARA_LRSPACE, ::cppu::UnoType::get(), 0, MID_R_MARGIN|SFX_METRIC_ITEM }, \ + {OUString(UNO_NAME_EDIT_PARA_RMARGIN), EE_PARA_LRSPACE.Which(), ::cppu::UnoType::get(), 0, MID_R_MARGIN|SFX_METRIC_ITEM }, \ {OUString(UNO_NAME_EDIT_PARA_TAPSTOPS), EE_PARA_TABS, cppu::UnoType>::get(), 0, 0 }, \ {OUString(UNO_NAME_EDIT_PARA_TMARGIN), EE_PARA_ULSPACE, ::cppu::UnoType::get(), 0, MID_UP_MARGIN|SFX_METRIC_ITEM },\ - {OUString(UNO_NAME_EDIT_PARA_FIRST_LINE_INDENT), EE_PARA_LRSPACE, ::cppu::UnoType::get(), 0, MID_FIRST_LINE_INDENT|SFX_METRIC_ITEM}, \ - {OUString(UNO_NAME_EDIT_PARA_IS_HANGING_PUNCTUATION),EE_PARA_HANGINGPUNCTUATION, cppu::UnoType::get(), 0 ,0 }, \ - {OUString(UNO_NAME_EDIT_PARA_IS_CHARACTER_DISTANCE), EE_PARA_ASIANCJKSPACING, cppu::UnoType::get(), 0 ,0 }, \ - {OUString(UNO_NAME_EDIT_PARA_IS_FORBIDDEN_RULES), EE_PARA_FORBIDDENRULES, cppu::UnoType::get(), 0 ,0 },\ - {OUString("WritingMode"), EE_PARA_WRITINGDIR, ::cppu::UnoType::get(), 0, 0 } + {OUString(UNO_NAME_EDIT_PARA_FIRST_LINE_INDENT), EE_PARA_LRSPACE.Which(), ::cppu::UnoType::get(), 0, MID_FIRST_LINE_INDENT|SFX_METRIC_ITEM}, \ + {OUString(UNO_NAME_EDIT_PARA_IS_HANGING_PUNCTUATION),EE_PARA_HANGINGPUNCTUATION.Which(), cppu::UnoType::get(), 0 ,0 }, \ + {OUString(UNO_NAME_EDIT_PARA_IS_CHARACTER_DISTANCE), EE_PARA_ASIANCJKSPACING.Which(), cppu::UnoType::get(), 0 ,0 }, \ + {OUString(UNO_NAME_EDIT_PARA_IS_FORBIDDEN_RULES), EE_PARA_FORBIDDENRULES.Which(), cppu::UnoType::get(), 0 ,0 },\ + {OUString("WritingMode"), EE_PARA_WRITINGDIR.Which(), ::cppu::UnoType::get(), 0, 0 } class SvxEditSource; class SvxTextForwarder; diff --git a/include/svl/itempool.hxx b/include/svl/itempool.hxx index 0cd5bfc13342..22ea12cf4e24 100644 --- a/include/svl/itempool.hxx +++ b/include/svl/itempool.hxx @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -101,7 +102,11 @@ public: SfxBroadcaster& BC(); void SetPoolDefaultItem( const SfxPoolItem& ); + const SfxPoolItem* GetPoolDefaultItem( sal_uInt16 nWhich ) const; + template const T* GetPoolDefaultItem( TypedWhichId nWhich ) const + { return static_cast(GetPoolDefaultItem(nWhich.Which())); } + void ResetPoolDefaultItem( sal_uInt16 nWhich ); void SetDefaults(std::vector* pDefaults); @@ -147,11 +152,21 @@ public: virtual const SfxPoolItem& Put( const SfxPoolItem&, sal_uInt16 nWhich = 0 ); void Remove( const SfxPoolItem& ); + const SfxPoolItem& GetDefaultItem( sal_uInt16 nWhich ) const; + template const T& GetDefaultItem( TypedWhichId nWhich ) const + { return static_cast(GetDefaultItem(nWhich.Which())); } bool CheckItemInPool(const SfxPoolItem *) const; + const SfxPoolItem * GetItem2(sal_uInt16 nWhich, sal_uInt32 nSurrogate) const; + template const T* GetItem2( TypedWhichId nWhich, sal_uInt32 nSurrogate ) const + { return dynamic_cast(GetItem2(nWhich.Which(), nSurrogate)); } + const SfxPoolItem * GetItem2Default(sal_uInt16 nWhich) const; + template const T* GetItem2Default( TypedWhichId nWhich ) const + { return static_cast(GetItem2Default(nWhich.Which())); } + sal_uInt32 GetItemCount2(sal_uInt16 nWhich) const; sal_uInt16 GetFirstWhich() const; @@ -169,6 +184,8 @@ public: { return IsItemPoolable( rItem.Which() ); } void SetItemInfos( const SfxItemInfo *pInfos ); sal_uInt16 GetWhich( sal_uInt16 nSlot, bool bDeep = true ) const; + template sal_uInt16 GetWhich( TypedWhichId nSlot, bool bDeep = true ) const + { return GetWhich(nSlot.Which(), bDeep); } sal_uInt16 GetSlotId( sal_uInt16 nWhich ) const; sal_uInt16 GetTrueWhich( sal_uInt16 nSlot, bool bDeep = true ) const; sal_uInt16 GetTrueSlotId( sal_uInt16 nWhich ) const; diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx index 89c6149f44a2..3254263c38ab 100644 --- a/include/svl/itemset.hxx +++ b/include/svl/itemset.hxx @@ -28,6 +28,7 @@ #include #include +#include class SfxItemPool; class SfxPoolItem; @@ -131,6 +132,11 @@ public: sal_uInt16 TotalCount() const; const SfxPoolItem& Get( sal_uInt16 nWhich, bool bSrchInParent = true ) const; + template + const T& Get( TypedWhichId nWhich, bool bSrchInParent = true ) const + { + return static_cast(Get(nWhich.Which(), bSrchInParent)); + } /** This method eases accessing single Items in the SfxItemSet. @@ -149,6 +155,15 @@ public: assert(!pItem || pCastedItem); // if it exists, must have the correct type return pCastedItem; } + template const T* GetItem( TypedWhichId nWhich, bool bSearchInParent = true ) const + { + const SfxPoolItem* pItem = GetItem(nWhich.Which(), bSearchInParent); + const T* pCastedItem = dynamic_cast(pItem); + + assert(!pItem || pCastedItem); // if it exists, must have the correct type + return pCastedItem; + } + /// Templatized static version of GetItem() to directly return the correct type if the SfxItemSet is available. template static const T* GetItem(const SfxItemSet* pItemSet, sal_uInt16 nWhich, bool bSearchInParent = true) @@ -166,12 +181,23 @@ public: SfxItemState GetItemState( sal_uInt16 nWhich, bool bSrchInParent = true, const SfxPoolItem **ppItem = nullptr ) const; + template + SfxItemState GetItemState( TypedWhichId nWhich, + bool bSrchInParent = true, + const SfxPoolItem **ppItem = nullptr ) const + { return GetItemState(nWhich.Which(), bSrchInParent, ppItem); } bool HasItem(sal_uInt16 nWhich, const SfxPoolItem** ppItem = nullptr) const; void DisableItem(sal_uInt16 nWhich); + template void DisableItem( TypedWhichId nWhich ) + { DisableItem(nWhich.Which()); } void InvalidateItem( sal_uInt16 nWhich ); + template void InvalidateItem( TypedWhichId nWhich ) + { InvalidateItem(nWhich.Which()); } sal_uInt16 ClearItem( sal_uInt16 nWhich = 0); + template sal_uInt16 ClearItem( TypedWhichId nWhich ) + { return ClearItem(nWhich.Which()); } void ClearInvalidItems(); void InvalidateAllItems(); // HACK(via nWhich = 0) ??? diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx index 7f9540c166a2..2d5a6f567c0b 100644 --- a/include/svl/poolitem.hxx +++ b/include/svl/poolitem.hxx @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -149,6 +150,10 @@ public: assert(m_nRefCount==0); m_nWhich = nId; } + template void SetWhich( TypedWhichId nId ) + { + SetWhich(nId.Which()); + } sal_uInt16 Which() const { return m_nWhich; } virtual bool operator==( const SfxPoolItem& ) const = 0; bool operator!=( const SfxPoolItem& rItem ) const @@ -173,6 +178,10 @@ public: virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const = 0; // clone and call SetWhich SfxPoolItem* CloneSetWhich( sal_uInt16 nNewWhich ) const; + template T* CloneSetWhich( TypedWhichId nId ) const + { + return static_cast(CloneSetWhich(nId.Which())); + } sal_uInt32 GetRefCount() const { return m_nRefCount; } SfxItemKind GetKind() const { return m_nKind; } diff --git a/include/svl/typedwhich.hxx b/include/svl/typedwhich.hxx new file mode 100644 index 000000000000..43318cc52303 --- /dev/null +++ b/include/svl/typedwhich.hxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVL_TYPEDWHICH_HXX +#define INCLUDED_SVL_TYPEDWHICH_HXX + +#include +#include + +/** + * A very thin wrapper around the sal_uInt16 WhichId whose purpose is mostly to carry type information, + * so that we Put() and Get() the right subclasses of SfxPoolItem for each WhichId. + */ +template class TypedWhichId final +{ +public: + constexpr TypedWhichId(sal_uInt16 nWhich) + : mnWhich(nWhich) + { + } + constexpr sal_uInt16 Which() const { return mnWhich; } + //constexpr operator sal_uInt16() const { return mnWhich; } +private: + sal_uInt16 const mnWhich; +}; + +template constexpr bool operator==(sal_uInt16 lhs, TypedWhichId const& rhs) +{ + return lhs == rhs.Which(); +} +template constexpr bool operator!=(sal_uInt16 lhs, TypedWhichId const& rhs) +{ + return lhs != rhs.Which(); +} +template constexpr bool operator==(TypedWhichId const& lhs, sal_uInt16 rhs) +{ + return lhs.Which() == rhs; +} +template constexpr bool operator!=(TypedWhichId const& lhs, sal_uInt16 rhs) +{ + return lhs.Which() != rhs; +} + +#endif // INCLUDED_SVL_TYPEDWHICH_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx index cd6953312565..af4f7ec72e21 100644 --- a/include/svx/svdobj.hxx +++ b/include/svx/svdobj.hxx @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -581,6 +582,11 @@ public: void ClearMergedItem(const sal_uInt16 nWhich = 0); void SetMergedItemSet(const SfxItemSet& rSet, bool bClearAllItems = false); const SfxPoolItem& GetMergedItem(const sal_uInt16 nWhich) const; + template + const T& GetMergedItem( TypedWhichId nWhich ) const + { + return static_cast(GetMergedItem(nWhich.Which())); + } // syntactical sugar for ItemSet accesses void SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, bool bClearAllItems = false); diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 562137f53d1e..0fa0f3d1358b 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -391,7 +391,7 @@ long ScColumn::GetNeededSize( // no longer needed, are set with the text (is faster) // pEngine->SetDefaults( pSet ); - if ( static_cast(pSet->Get(EE_PARA_HYPHENATE)).GetValue() ) { + if ( pSet->Get(EE_PARA_HYPHENATE).GetValue() ) { css::uno::Reference xXHyphenator( LinguMgr::GetHyphenator() ); pEngine->SetHyphenator( xXHyphenator ); diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx index 103093b1741f..b0e709b67dfa 100644 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -265,7 +265,7 @@ ScDrawLayer::ScDrawLayer( ScDocument* pDocument, const OUString& rName ) : SetScaleUnit(MapUnit::Map100thMM); SfxItemPool& rPool = GetItemPool(); rPool.SetDefaultMetric(MapUnit::Map100thMM); - SvxFrameDirectionItem aModeItem( SvxFrameDirection::Environment, EE_PARA_WRITINGDIR ); + SvxFrameDirectionItem aModeItem( SvxFrameDirection::Environment, EE_PARA_WRITINGDIR.Which() ); rPool.SetPoolDefaultItem( aModeItem ); // #i33700# @@ -278,7 +278,7 @@ ScDrawLayer::ScDrawLayer( ScDocument* pDocument, const OUString& rName ) : if (MsLangId::isKorean(eOfficeLanguage) || eOfficeLanguage == LANGUAGE_JAPANESE) { // secondary is edit engine pool - rPool.GetSecondaryPool()->SetPoolDefaultItem( SvxScriptSpaceItem( false, EE_PARA_ASIANCJKSPACING ) ); + rPool.GetSecondaryPool()->SetPoolDefaultItem( SvxScriptSpaceItem( false, EE_PARA_ASIANCJKSPACING.Which() ) ); } rPool.FreezeIdRanges(); // the pool is also used directly diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index 8238ea0b18e2..b5fe55473f73 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -763,21 +763,21 @@ void ScPatternAttr::FillToEditItemSet( SfxItemSet& rEditSet, const SfxItemSet& r rEditSet.Put( SvxPostureItem ( eCtlItalic, EE_CHAR_ITALIC_CTL ) ); rEditSet.Put( SvxContourItem ( bOutline, EE_CHAR_OUTLINE ) ); rEditSet.Put( SvxShadowedItem ( bShadow, EE_CHAR_SHADOW ) ); - rEditSet.Put( SvxForbiddenRuleItem(bForbidden, EE_PARA_FORBIDDENRULES) ); + rEditSet.Put( SvxForbiddenRuleItem(bForbidden, EE_PARA_FORBIDDENRULES.Which()) ); rEditSet.Put( SvxEmphasisMarkItem( eEmphasis, EE_CHAR_EMPHASISMARK ) ); rEditSet.Put( SvxCharReliefItem( eRelief, EE_CHAR_RELIEF ) ); rEditSet.Put( SvxLanguageItem ( eLang, EE_CHAR_LANGUAGE ) ); rEditSet.Put( SvxLanguageItem ( eCjkLang, EE_CHAR_LANGUAGE_CJK ) ); rEditSet.Put( SvxLanguageItem ( eCtlLang, EE_CHAR_LANGUAGE_CTL ) ); - rEditSet.Put( SfxBoolItem ( EE_PARA_HYPHENATE, bHyphenate ) ); - rEditSet.Put( SvxFrameDirectionItem( eDirection, EE_PARA_WRITINGDIR ) ); + rEditSet.Put( SfxBoolItem ( EE_PARA_HYPHENATE.Which(), bHyphenate ) ); + rEditSet.Put( SvxFrameDirectionItem( eDirection, EE_PARA_WRITINGDIR.Which() ) ); // Script spacing is always off. // The cell attribute isn't used here as long as there is no UI to set it // (don't evaluate attributes that can't be changed). // If a locale-dependent default is needed, it has to go into the cell // style, like the fonts. - rEditSet.Put( SvxScriptSpaceItem( false, EE_PARA_ASIANCJKSPACING ) ); + rEditSet.Put( SvxScriptSpaceItem( false, EE_PARA_ASIANCJKSPACING.Which() ) ); } void ScPatternAttr::FillEditItemSet( SfxItemSet* pEditSet, const SfxItemSet* pCondSet ) const diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index bd5293e9b1c3..71524d74dc9d 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -1203,7 +1203,7 @@ void ScTextWnd::InitEditEngine() EditEngine::SetFontInfoInItemSet( *pSet, aTextFont ); lcl_ExtendEditFontAttribs( *pSet ); // turn off script spacing to match DrawText output - pSet->Put( SvxScriptSpaceItem( false, EE_PARA_ASIANCJKSPACING ) ); + pSet->Put( SvxScriptSpaceItem( false, EE_PARA_ASIANCJKSPACING.Which() ) ); if ( bIsRTL ) lcl_ModifyRTLDefaults( *pSet ); mpEditEngine->SetDefaults( pSet ); diff --git a/sc/source/ui/drawfunc/drawsh2.cxx b/sc/source/ui/drawfunc/drawsh2.cxx index b07d67947910..099ed3d3aee1 100644 --- a/sc/source/ui/drawfunc/drawsh2.cxx +++ b/sc/source/ui/drawfunc/drawsh2.cxx @@ -266,7 +266,7 @@ void ScDrawShell::GetDrawFuncState( SfxItemSet& rSet ) // disable functions pView->GetAttributes( aAttrs ); if( aAttrs.GetItemState( EE_PARA_HYPHENATE ) >= SfxItemState::DEFAULT ) { - bool bValue = static_cast( aAttrs.Get( EE_PARA_HYPHENATE ) ).GetValue(); + bool bValue = aAttrs.Get( EE_PARA_HYPHENATE ).GetValue(); rSet.Put( SfxBoolItem( SID_ENABLE_HYPHENATION, bValue ) ); } } diff --git a/sc/source/ui/drawfunc/drawsh5.cxx b/sc/source/ui/drawfunc/drawsh5.cxx index 95122e1c9e0d..a6e7e99db274 100644 --- a/sc/source/ui/drawfunc/drawsh5.cxx +++ b/sc/source/ui/drawfunc/drawsh5.cxx @@ -450,9 +450,9 @@ void ScDrawShell::ExecDrawFunc( SfxRequest& rReq ) const SfxBoolItem* pItem = rReq.GetArg(SID_ENABLE_HYPHENATION); if( pItem ) { - SfxItemSet aSet( GetPool(), svl::Items{} ); + SfxItemSet aSet( GetPool(), svl::Items{} ); bool bValue = pItem->GetValue(); - aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) ); + aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE.Which(), bValue ) ); pView->SetAttributes( aSet ); } rReq.Done(); diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx index 3a8c3bdc14a0..f9a66daf5e88 100644 --- a/sc/source/ui/drawfunc/drtxtob.cxx +++ b/sc/source/ui/drawfunc/drtxtob.cxx @@ -439,7 +439,7 @@ void ScDrawTextObjectBar::GetState( SfxItemSet& rSet ) pView->GetAttributes( aAttrs ); if( aAttrs.GetItemState( EE_PARA_HYPHENATE ) >= SfxItemState::DEFAULT ) { - bool bValue = static_cast( aAttrs.Get( EE_PARA_HYPHENATE ) ).GetValue(); + bool bValue = aAttrs.Get( EE_PARA_HYPHENATE ).GetValue(); rSet.Put( SfxBoolItem( SID_ENABLE_HYPHENATION, bValue ) ); } } @@ -924,8 +924,8 @@ void ScDrawTextObjectBar::ExecuteAttr( SfxRequest &rReq ) sal_uInt16 nId = SID_ATTR_PARA_LRSPACE; const SvxLRSpaceItem& rItem = static_cast( pArgs->Get( nId )); - SfxItemSet aAttr( GetPool(), svl::Items{} ); - nId = EE_PARA_LRSPACE; + SfxItemSet aAttr( GetPool(), svl::Items{} ); + nId = EE_PARA_LRSPACE.Which(); SvxLRSpaceItem aLRSpaceItem( rItem.GetLeft(), rItem.GetRight(), rItem.GetTextLeft(), rItem.GetTextFirstLineOfst(), nId ); @@ -1040,7 +1040,7 @@ void ScDrawTextObjectBar::GetAttrState( SfxItemSet& rDestSet ) rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_RIGHT, eAdj == SvxAdjust::Right ) ); rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_JUSTIFIED, eAdj == SvxAdjust::Block ) ); - SvxLRSpaceItem aLR = static_cast(aAttrSet.Get( EE_PARA_LRSPACE )); + SvxLRSpaceItem aLR = aAttrSet.Get( EE_PARA_LRSPACE ); aLR.SetWhich(SID_ATTR_PARA_LRSPACE); rDestSet.Put(aLR); Invalidate( SID_ATTR_PARA_LRSPACE ); @@ -1168,8 +1168,7 @@ void ScDrawTextObjectBar::GetAttrState( SfxItemSet& rDestSet ) } else { - SvxFrameDirection eAttrDir = static_cast( - aAttrSet.Get( EE_PARA_WRITINGDIR )).GetValue(); + SvxFrameDirection eAttrDir = aAttrSet.Get( EE_PARA_WRITINGDIR ).GetValue(); if ( eAttrDir == SvxFrameDirection::Environment ) { // get "environment" direction from page style diff --git a/sc/source/ui/drawfunc/drtxtob2.cxx b/sc/source/ui/drawfunc/drtxtob2.cxx index 28050513064b..bc0e8f35bff0 100644 --- a/sc/source/ui/drawfunc/drtxtob2.cxx +++ b/sc/source/ui/drawfunc/drtxtob2.cxx @@ -107,9 +107,9 @@ void ScDrawTextObjectBar::ExecuteGlobal( SfxRequest &rReq ) const SfxBoolItem* pItem = rReq.GetArg(SID_ENABLE_HYPHENATION); if( pItem ) { - SfxItemSet aSet( GetPool(), svl::Items{} ); + SfxItemSet aSet( GetPool(), svl::Items{} ); bool bValue = pItem->GetValue(); - aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) ); + aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE.Which(), bValue ) ); pView->SetAttributes( aSet ); } rReq.Done(); @@ -163,12 +163,12 @@ void ScDrawTextObjectBar::ExecuteExtra( SfxRequest &rReq ) case SID_ATTR_PARA_RIGHT_TO_LEFT: { SfxItemSet aAttr( pView->GetModel()->GetItemPool(), - svl::Items{} ); bool bLeft = ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT ); aAttr.Put( SvxFrameDirectionItem( bLeft ? SvxFrameDirection::Horizontal_LR_TB : SvxFrameDirection::Horizontal_RL_TB, - EE_PARA_WRITINGDIR ) ); + EE_PARA_WRITINGDIR.Which() ) ); aAttr.Put( SvxAdjustItem( bLeft ? SvxAdjust::Left : SvxAdjust::Right, EE_PARA_JUST ) ); diff --git a/sc/source/ui/drawfunc/futext.cxx b/sc/source/ui/drawfunc/futext.cxx index bf3e1bbebd09..f95b6465e07d 100644 --- a/sc/source/ui/drawfunc/futext.cxx +++ b/sc/source/ui/drawfunc/futext.cxx @@ -95,7 +95,7 @@ static void lcl_InvalidateAttribs( SfxBindings& rBindings ) static void lcl_UpdateHyphenator( Outliner& rOutliner, const SdrObject* pObj ) { // use hyphenator only if hyphenation attribute is set - if ( pObj && static_cast(pObj->GetMergedItem(EE_PARA_HYPHENATE)).GetValue() ) { + if ( pObj && pObj->GetMergedItem(EE_PARA_HYPHENATE).GetValue() ) { css::uno::Reference xHyphenator( LinguMgr::GetHyphenator() ); rOutliner.SetHyphenator( xHyphenator ); } diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 0a27abb7ccf2..c344f751c10e 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -2442,7 +2442,7 @@ void ScOutputData::DrawEditParam::setPatternToEngine(bool bUseStyleColor) nControl &= ~EEControlBits::ONECHARPERLINE; mpEngine->SetControlWord( nControl ); - if ( !mbHyphenatorSet && static_cast(pSet->Get(EE_PARA_HYPHENATE)).GetValue() ) + if ( !mbHyphenatorSet && pSet->Get(EE_PARA_HYPHENATE).GetValue() ) { // set hyphenator the first time it is needed css::uno::Reference xXHyphenator( LinguMgr::GetHyphenator() ); @@ -4798,7 +4798,7 @@ void ScOutputData::DrawRotated(bool bPixelToLogic) nControl &= ~EEControlBits::ONECHARPERLINE; pEngine->SetControlWord( nControl ); - if ( !bHyphenatorSet && static_cast(pSet->Get(EE_PARA_HYPHENATE)).GetValue() ) + if ( !bHyphenatorSet && pSet->Get(EE_PARA_HYPHENATE).GetValue() ) { // set hyphenator the first time it is needed css::uno::Reference xXHyphenator( LinguMgr::GetHyphenator() ); diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx index 12236ffdac7f..772a60df0df4 100644 --- a/sc/source/ui/view/printfun.cxx +++ b/sc/source/ui/view/printfun.cxx @@ -1703,7 +1703,7 @@ void ScPrintFunc::MakeEditEngine() //! there's no way to set the background for note pages pEditDefaults->ClearItem( EE_CHAR_COLOR ); if (ScGlobal::IsSystemRTL()) - pEditDefaults->Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_RL_TB, EE_PARA_WRITINGDIR ) ); + pEditDefaults->Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_RL_TB, EE_PARA_WRITINGDIR.Which() ) ); } pEditEngine->SetData( aFieldData ); // Set page count etc. diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx index 1ffcdf3cc8ea..0ad825d57700 100644 --- a/sd/qa/unit/export-tests-ooxml1.cxx +++ b/sd/qa/unit/export-tests-ooxml1.cxx @@ -293,7 +293,7 @@ void SdOOXMLExportTest1::testN828390_5() SdrTextObj *pTxtObj = dynamic_cast( pObj ); CPPUNIT_ASSERT( pTxtObj ); const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject(); - const SvxNumBulletItem *pNumFmt = dynamic_cast(aEdit.GetPool()->GetItem2(EE_PARA_NUMBULLET, 5)); + const SvxNumBulletItem *pNumFmt = aEdit.GetPool()->GetItem2(EE_PARA_NUMBULLET, 5); CPPUNIT_ASSERT( pNumFmt ); CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's relative size is wrong!", pNumFmt->GetNumRule()->GetLevel(1).GetBulletRelSize(), sal_uInt16(75) ); // != 25 } @@ -535,7 +535,7 @@ void SdOOXMLExportTest1::testBulletStartNumber() SdrTextObj *pTxtObj = dynamic_cast( pPage->GetObj(0) ); CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr); const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject(); - const SvxNumBulletItem *pNumFmt = dynamic_cast(aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET)); + const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET); CPPUNIT_ASSERT(pNumFmt); CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's start number is wrong!", sal_Int16(pNumFmt->GetNumRule()->GetLevel(0).GetStart()), sal_Int16(3) ); xDocShRef->DoClose(); @@ -613,7 +613,7 @@ void SdOOXMLExportTest1::testBulletColor() CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr); const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject(); - const SvxNumBulletItem *pNumFmt = dynamic_cast(aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET)); + const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET); CPPUNIT_ASSERT(pNumFmt); CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's color is wrong!", sal_uInt32(0xff0000),pNumFmt->GetNumRule()->GetLevel(0).GetBulletColor().GetColor()); @@ -659,7 +659,7 @@ void SdOOXMLExportTest1::testBulletMarginAndIndentation() CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr); const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject(); - const SvxNumBulletItem *pNumFmt = dynamic_cast(aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET)); + const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET); CPPUNIT_ASSERT(pNumFmt); CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's left margin is wrong!", sal_uInt32(1000),sal_uInt32(pNumFmt->GetNumRule()->GetLevel(0).GetAbsLSpace()) ); // left margin is 0.79 cm diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 875c110584a6..d80981457188 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -1218,7 +1218,7 @@ void SdImportTest::testBulletSuffix() SdrTextObj *pTxtObj = dynamic_cast( pPage->GetObj(0) ); CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr); const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject(); - const SvxNumBulletItem *pNumFmt = dynamic_cast(aEdit.GetParaAttribs(1).GetItem(EE_PARA_NUMBULLET)); + const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(1).GetItem(EE_PARA_NUMBULLET); CPPUNIT_ASSERT(pNumFmt); CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's suffix is wrong!", pNumFmt->GetNumRule()->GetLevel(0).GetSuffix(), OUString() ); xDocShRef->DoClose(); @@ -1755,7 +1755,7 @@ void SdImportTest::testTdf103477() CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr ); const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject(); - const SvxNumBulletItem *pNumFmt = dynamic_cast( aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET) ); + const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET); CPPUNIT_ASSERT(pNumFmt); CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's color is wrong!", sal_uInt32(0x000000), pNumFmt->GetNumRule()->GetLevel(1).GetBulletColor().GetColor()); @@ -2216,7 +2216,7 @@ void SdImportTest::testTdf108925() CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj != nullptr); const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject(); - const SvxNumBulletItem *pNumFmt = dynamic_cast(aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET)); + const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET); CPPUNIT_ASSERT(pNumFmt); CPPUNIT_ASSERT_EQUAL(pNumFmt->GetNumRule()->GetLevel(0).GetBulletRelSize(), sal_uInt16(25)); diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx index ff30462fc3c9..c6ad5a56fba5 100644 --- a/sd/source/core/drawdoc.cxx +++ b/sd/source/core/drawdoc.cxx @@ -241,7 +241,7 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh) // for korean and japanese languages we have a different default for apply spacing between asian, latin and ctl text if (MsLangId::isKorean(eRealCTLLanguage) || (LANGUAGE_JAPANESE == eRealCTLLanguage)) { - GetPool().GetSecondaryPool()->SetPoolDefaultItem( SvxScriptSpaceItem( false, EE_PARA_ASIANCJKSPACING ) ); + GetPool().GetSecondaryPool()->SetPoolDefaultItem( SvxScriptSpaceItem( false, EE_PARA_ASIANCJKSPACING.Which() ) ); } // Set DefTab and SpellOptions for the SD module diff --git a/sd/source/core/drawdoc4.cxx b/sd/source/core/drawdoc4.cxx index 4fc6bba2d5d7..3c12d11e64c8 100644 --- a/sd/source/core/drawdoc4.cxx +++ b/sd/source/core/drawdoc4.cxx @@ -218,7 +218,7 @@ void SdDrawDocument::CreateLayoutTemplates() rISet.Put(SvxColorItem(Color(COL_AUTO), EE_CHAR_COLOR )); // Paragraph attributes (Edit Engine) - rISet.Put(SvxLRSpaceItem(EE_PARA_LRSPACE)); + rISet.Put(SvxLRSpaceItem(EE_PARA_LRSPACE.Which())); rISet.Put(SvxULSpaceItem(EE_PARA_ULSPACE)); rISet.Put( makeSdrTextLeftDistItem( 250 ) ); // sj: (i33745) using text frame distances seems to be a better default @@ -233,7 +233,7 @@ void SdDrawDocument::CreateLayoutTemplates() // Bullet // BulletItem and BulletFont for title and outline - SvxBulletItem aBulletItem(EE_PARA_BULLET); + SvxBulletItem aBulletItem(EE_PARA_BULLET.Which()); // Identical in all layers aBulletItem.SetStyle(SvxBulletStyle::BULLET); aBulletItem.SetStart(1); @@ -352,7 +352,7 @@ void SdDrawDocument::CreateLayoutTemplates() pISet->Put(XLineStyleItem(drawing::LineStyle_NONE)); pISet->Put(XFillStyleItem(drawing::FillStyle_NONE)); - SvxLRSpaceItem aLRSpaceItem( EE_PARA_LRSPACE ); + SvxLRSpaceItem aLRSpaceItem( EE_PARA_LRSPACE.Which() ); aLRSpaceItem.SetTextFirstLineOfst(600); // Indentation of first line: 6mm; right: 0 pISet->Put(aLRSpaceItem); @@ -411,7 +411,7 @@ void SdDrawDocument::CreateLayoutTemplates() pISet->Put(SvxFontHeightItem(1270, 100, EE_CHAR_FONTHEIGHT )); // 36 pt - SvxLRSpaceItem aLRSpItem( 200, 200, 0, 0, EE_PARA_LRSPACE); + SvxLRSpaceItem aLRSpItem( 200, 200, 0, 0, EE_PARA_LRSPACE.Which()); pISet->Put( aLRSpItem ); // Indentation of first line: 0 mm; left and right: 2 mm pISet->Put(SvxULSpaceItem(100, 100, EE_PARA_ULSPACE )); // Paragraph margin above/below: 1 mm @@ -578,7 +578,7 @@ void SdDrawDocument::CreateDefaultCellStyles() rISet.Put(SvxColorItem(Color(COL_AUTO), EE_CHAR_COLOR )); // Paragraph attributes (Edit Engine) - rISet.Put(SvxLRSpaceItem(EE_PARA_LRSPACE)); + rISet.Put(SvxLRSpaceItem(EE_PARA_LRSPACE.Which())); rISet.Put(SvxULSpaceItem(EE_PARA_ULSPACE)); rISet.Put( makeSdrTextLeftDistItem( 250 ) ); @@ -1188,7 +1188,7 @@ void SdDrawDocument::RenameLayoutTemplate(const OUString& rOldLayoutName, const void SdDrawDocument::SetTextDefaults() const { // BulletItem and BulletFont for Title and Outline - SvxBulletItem aBulletItem(EE_PARA_BULLET); + SvxBulletItem aBulletItem(EE_PARA_BULLET.Which()); vcl::Font aBulletFont( SdStyleSheetPool::GetBulletFont() ); aBulletFont.SetFontSize(Size(0,846)); // 24 pt aBulletItem.SetFont(aBulletFont); @@ -1221,7 +1221,7 @@ void SdDrawDocument::SetTextDefaults() const aNumRule.SetLevel( i, aNumberFormat ); } - SvxNumBulletItem aNumBulletItem( aNumRule, EE_PARA_NUMBULLET ); + SvxNumBulletItem aNumBulletItem( aNumRule, EE_PARA_NUMBULLET.Which() ); pItemPool->SetPoolDefaultItem( aNumBulletItem ); } @@ -1262,7 +1262,7 @@ void SdDrawDocument::SetDefaultWritingMode(css::text::WritingMode eMode ) return; } - SvxFrameDirectionItem aModeItem( nVal, EE_PARA_WRITINGDIR ); + SvxFrameDirectionItem aModeItem( nVal, EE_PARA_WRITINGDIR.Which() ); pItemPool->SetPoolDefaultItem( aModeItem ); SvxAdjustItem aAdjust( SvxAdjust::Left, EE_PARA_JUST ); diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx index 6d7358947ca6..7870627411c5 100644 --- a/sd/source/core/sdpage.cxx +++ b/sd/source/core/sdpage.cxx @@ -2022,8 +2022,8 @@ void SdPage::ScaleObjects(const Size& rNewPageSize, const ::tools::Rectangle& rN // of the BulletItems if (aTempSet.GetItemState(EE_PARA_BULLET) == SfxItemState::DEFAULT) { - SvxBulletItem aOldBulItem(static_cast( pOutlineSheet->GetItemSet().Get(EE_PARA_BULLET) )); - const SvxBulletItem& rNewBulItem = static_cast( aTempSet.Get(EE_PARA_BULLET) ); + SvxBulletItem aOldBulItem( pOutlineSheet->GetItemSet().Get(EE_PARA_BULLET) ); + const SvxBulletItem& rNewBulItem = aTempSet.Get(EE_PARA_BULLET); aOldBulItem.CopyValidProperties(rNewBulItem); aTempSet.Put(aOldBulItem); } @@ -2149,7 +2149,7 @@ SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourceObj, P } // Remove LRSpace item - SfxItemSet aSet(pModel->GetPool(), svl::Items{} ); + SfxItemSet aSet(pModel->GetPool(), svl::Items{} ); aSet.Put(pNewObj->GetMergedItemSet()); @@ -2187,11 +2187,11 @@ SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourceObj, P pNewObj->SetEmptyPresObj(false); // reset left indent - SfxItemSet aSet(pModel->GetPool(), svl::Items{} ); + SfxItemSet aSet(pModel->GetPool(), svl::Items{} ); aSet.Put(pNewObj->GetMergedItemSet()); - const SvxLRSpaceItem& rLRItem = static_cast( aSet.Get(EE_PARA_LRSPACE) ); + const SvxLRSpaceItem& rLRItem = aSet.Get(EE_PARA_LRSPACE); SvxLRSpaceItem aNewLRItem(rLRItem); aNewLRItem.SetTextLeft(0); aSet.Put(aNewLRItem); diff --git a/sd/source/core/stlpool.cxx b/sd/source/core/stlpool.cxx index 9e40da77990e..df43cb8c0535 100644 --- a/sd/source/core/stlpool.cxx +++ b/sd/source/core/stlpool.cxx @@ -210,7 +210,7 @@ void SdStyleSheetPool::CreateLayoutStyleSheets(const OUString& rLayoutName, bool OUString aName(STR_LAYOUT_OUTLINE); OUString aHelpFile; - SvxLRSpaceItem aSvxLRSpaceItem( EE_PARA_LRSPACE ); + SvxLRSpaceItem aSvxLRSpaceItem( EE_PARA_LRSPACE.Which() ); SvxULSpaceItem aSvxULSpaceItem( EE_PARA_ULSPACE ); for( sal_Int32 nLevel = 1; nLevel < 10; nLevel++) @@ -459,7 +459,7 @@ void SdStyleSheetPool::CreateLayoutStyleSheets(const OUString& rLayoutName, bool rNotesSet.Put( SvxCharReliefItem(FontRelief::NONE, EE_CHAR_RELIEF) ); rNotesSet.Put( SvxColorItem( Color(COL_AUTO), EE_CHAR_COLOR ) ); rNotesSet.Put( SvxBackgroundColorItem( Color(COL_AUTO), EE_CHAR_BKGCOLOR ) ); - rNotesSet.Put( SvxLRSpaceItem( 0, 0, 600, -600, EE_PARA_LRSPACE ) ); + rNotesSet.Put( SvxLRSpaceItem( 0, 0, 600, -600, EE_PARA_LRSPACE.Which() ) ); // #i16874# enable kerning by default but only for new documents rNotesSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) ); @@ -1106,7 +1106,7 @@ void SdStyleSheetPool::PutNumBulletItem( SfxStyleSheetBase* pSheet, aNumRule.SetLevel( i, aNumberFormat ); } - rSet.Put( SvxNumBulletItem( aNumRule, EE_PARA_NUMBULLET ) ); + rSet.Put( SvxNumBulletItem( aNumRule, EE_PARA_NUMBULLET.Which() ) ); static_cast(pSheet)->Broadcast(SfxHint( SfxHintId::DataChanged ) ); } break; @@ -1117,8 +1117,7 @@ void SdStyleSheetPool::PutNumBulletItem( SfxStyleSheetBase* pSheet, { // Subtitle template SvxNumBulletItem const*const pItem( - static_cast( - rSet.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET))); + rSet.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET)); SvxNumRule *const pDefaultRule = (pItem) ? pItem->GetNumRule() : nullptr; DBG_ASSERT( pDefaultRule, "Where is my default template? [CL]" ); @@ -1139,7 +1138,7 @@ void SdStyleSheetPool::PutNumBulletItem( SfxStyleSheetBase* pSheet, aNumRule.SetLevel(i, aFrmt); } - rSet.Put( SvxNumBulletItem( aNumRule, EE_PARA_NUMBULLET ) ); + rSet.Put( SvxNumBulletItem( aNumRule, EE_PARA_NUMBULLET.Which() ) ); static_cast(pSheet)->Broadcast(SfxHint( SfxHintId::DataChanged ) ); } } @@ -1164,7 +1163,7 @@ void SdStyleSheetPool::PutNumBulletItem( SfxStyleSheetBase* pSheet, aNumRule.SetLevel( i, aNumberFormat ); } - rSet.Put( SvxNumBulletItem( aNumRule, EE_PARA_NUMBULLET ) ); + rSet.Put( SvxNumBulletItem( aNumRule, EE_PARA_NUMBULLET.Which() ) ); static_cast(pSheet)->Broadcast(SfxHint( SfxHintId::DataChanged ) ); } break; diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx index da1e75fa0d4e..edd71b9be94e 100644 --- a/sd/source/core/stlsheet.cxx +++ b/sd/source/core/stlsheet.cxx @@ -534,7 +534,7 @@ void SdStyleSheet::AdjustToFontHeight(SfxItemSet& rSet, bool bOnlyMissingItems) if (rSet.GetItemState(EE_PARA_BULLET) != SfxItemState::SET || !bOnlyMissingItems) { - const SvxBulletItem& rBItem = static_cast(pCurSet->Get(EE_PARA_BULLET)); + const SvxBulletItem& rBItem = pCurSet->Get(EE_PARA_BULLET); double fBulletFraction = double(rBItem.GetWidth()) / nOldHeight; SvxBulletItem aNewBItem(rBItem); aNewBItem.SetWidth((sal_uInt32)(fBulletFraction * nNewHeight)); @@ -543,7 +543,7 @@ void SdStyleSheet::AdjustToFontHeight(SfxItemSet& rSet, bool bOnlyMissingItems) if (rSet.GetItemState(EE_PARA_LRSPACE) != SfxItemState::SET || !bOnlyMissingItems) { - const SvxLRSpaceItem& rLRItem = static_cast(pCurSet->Get(EE_PARA_LRSPACE)); + const SvxLRSpaceItem& rLRItem = pCurSet->Get(EE_PARA_LRSPACE); double fIndentFraction = double(rLRItem.GetTextLeft()) / nOldHeight; SvxLRSpaceItem aNewLRItem(rLRItem); aNewLRItem.SetTextLeft(fIndentFraction * nNewHeight); diff --git a/sd/source/ui/dlg/dlgolbul.cxx b/sd/source/ui/dlg/dlgolbul.cxx index 6764fa73595c..0f1fe5824910 100644 --- a/sd/source/ui/dlg/dlgolbul.cxx +++ b/sd/source/ui/dlg/dlgolbul.cxx @@ -103,7 +103,7 @@ OutlineBulletDlg::OutlineBulletDlg( } if( pItem == nullptr ) - pItem = static_cast( aInputSet.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET) ); + pItem = aInputSet.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET); DBG_ASSERT( pItem, "No EE_PARA_NUMBULLET in Pool! [CL]" ); @@ -120,7 +120,7 @@ OutlineBulletDlg::OutlineBulletDlg( SvxNumRule aNewRule( *pRule ); aNewRule.SetFeatureFlag( SvxNumRuleFlags::NO_NUMBERS ); - SvxNumBulletItem aNewItem( aNewRule, EE_PARA_NUMBULLET ); + SvxNumBulletItem aNewItem( aNewRule, EE_PARA_NUMBULLET.Which() ); aInputSet.Put(aNewItem); } } diff --git a/sd/source/ui/func/fuolbull.cxx b/sd/source/ui/func/fuolbull.cxx index f8be75ef3643..4565e0b5e81f 100644 --- a/sd/source/ui/func/fuolbull.cxx +++ b/sd/source/ui/func/fuolbull.cxx @@ -335,7 +335,7 @@ const SfxPoolItem* FuOutlineBullet::GetNumBulletItem(SfxItemSet& aNewAttr, sal_u } if( pItem == nullptr ) - pItem = static_cast( aNewAttr.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET) ); + pItem = aNewAttr.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET); //DBG_ASSERT( pItem, "No EE_PARA_NUMBULLET in the Pool!" ); @@ -344,14 +344,14 @@ const SfxPoolItem* FuOutlineBullet::GetNumBulletItem(SfxItemSet& aNewAttr, sal_u if(bTitle && aNewAttr.GetItemState(EE_PARA_NUMBULLET) == SfxItemState::SET ) { - const SvxNumBulletItem* pBulletItem = static_cast( aNewAttr.GetItem(EE_PARA_NUMBULLET) ); + const SvxNumBulletItem* pBulletItem = aNewAttr.GetItem(EE_PARA_NUMBULLET); SvxNumRule* pLclRule = pBulletItem->GetNumRule(); if(pLclRule) { SvxNumRule aNewRule( *pLclRule ); aNewRule.SetFeatureFlag( SvxNumRuleFlags::NO_NUMBERS ); - SvxNumBulletItem aNewItem( aNewRule, EE_PARA_NUMBULLET ); + SvxNumBulletItem aNewItem( aNewRule, EE_PARA_NUMBULLET.Which() ); aNewAttr.Put(aNewItem); } } diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx index fa14378f2da0..059ff5e61102 100644 --- a/sd/source/ui/func/fupage.cxx +++ b/sd/source/ui/func/fupage.cxx @@ -218,7 +218,7 @@ const SfxItemSet* FuPage::ExecuteDialog( vcl::Window* pParent ) {SID_ATTR_BORDER_SHADOW, SID_ATTR_BORDER_SHADOW}, {XATTR_FILL_FIRST, XATTR_FILL_LAST}, {SID_ATTR_PAGE_COLOR,SID_ATTR_PAGE_FILLSTYLE}, - {EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR}}); + {EE_PARA_WRITINGDIR.Which(), EE_PARA_WRITINGDIR.Which()}}); // Retrieve additional data for dialog @@ -229,7 +229,7 @@ const SfxItemSet* FuPage::ExecuteDialog( vcl::Window* pParent ) aNewAttr.Put( SvxFrameDirectionItem( mpDoc->GetDefaultWritingMode() == css::text::WritingMode_RL_TB ? SvxFrameDirection::Horizontal_RL_TB : SvxFrameDirection::Horizontal_LR_TB, - EE_PARA_WRITINGDIR ) ); + EE_PARA_WRITINGDIR.Which() ) ); // Retrieve page-data for dialog diff --git a/sd/source/ui/func/fuparagr.cxx b/sd/source/ui/func/fuparagr.cxx index 9600f35f89c7..36af7fa013b7 100644 --- a/sd/source/ui/func/fuparagr.cxx +++ b/sd/source/ui/func/fuparagr.cxx @@ -77,7 +77,7 @@ void FuParagraph::DoExecute( SfxRequest& rReq ) aNewAttr.Put( aEditAttr ); // left border is offset - const long nOff = static_cast(aNewAttr.Get( EE_PARA_LRSPACE ) ).GetTextLeft(); + const long nOff = aNewAttr.Get( EE_PARA_LRSPACE ).GetTextLeft(); // conversion since TabulatorTabPage always uses Twips! SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff ); aNewAttr.Put( aOff ); diff --git a/sd/source/ui/func/futempl.cxx b/sd/source/ui/func/futempl.cxx index ff7eaa096ea8..191cd65c362f 100644 --- a/sd/source/ui/func/futempl.cxx +++ b/sd/source/ui/func/futempl.cxx @@ -420,7 +420,7 @@ void FuTemplate::DoExecute( SfxRequest& rReq ) if(pFirstStyleSheet) { - pFirstStyleSheet->GetItemSet().Put( SvxNumBulletItem( aRule, EE_PARA_NUMBULLET )); + pFirstStyleSheet->GetItemSet().Put( SvxNumBulletItem( aRule, EE_PARA_NUMBULLET.Which() )); SdStyleSheet* pRealSheet = static_cast(pFirstStyleSheet)->GetRealStyleSheet(); pRealSheet->Broadcast(SfxHint(SfxHintId::DataChanged)); } diff --git a/sd/source/ui/func/futext.cxx b/sd/source/ui/func/futext.cxx index 2b4ca65526cb..3e3143f20dd6 100644 --- a/sd/source/ui/func/futext.cxx +++ b/sd/source/ui/func/futext.cxx @@ -843,8 +843,7 @@ bool FuText::MouseButtonUp(const MouseEvent& rMEvt) // one of the default set items from ImpSetAttributesForNewTextObject // needs to be adapted to non-block mode. const SfxItemSet& rSet = mpView->GetDefaultAttr(); - SvxFrameDirection eDirection = static_cast( - rSet.Get(EE_PARA_WRITINGDIR)).GetValue(); + SvxFrameDirection eDirection = rSet.Get(EE_PARA_WRITINGDIR).GetValue(); if(SvxFrameDirection::Horizontal_RL_TB == eDirection || SvxFrameDirection::Vertical_RL_TB == eDirection) { @@ -864,8 +863,7 @@ bool FuText::MouseButtonUp(const MouseEvent& rMEvt) // Look in the object defaults if left-to-right is wanted. If // yes, set text anchoring to right to let the box grow to left. const SfxItemSet& rSet = mpView->GetDefaultAttr(); - SvxFrameDirection eDirection = - static_cast(rSet.Get(EE_PARA_WRITINGDIR)).GetValue(); + SvxFrameDirection eDirection = rSet.Get(EE_PARA_WRITINGDIR).GetValue(); if(SvxFrameDirection::Horizontal_RL_TB == eDirection) { diff --git a/sd/source/ui/view/drtxtob.cxx b/sd/source/ui/view/drtxtob.cxx index f28c5f10b82a..cfbe431edc98 100644 --- a/sd/source/ui/view/drtxtob.cxx +++ b/sd/source/ui/view/drtxtob.cxx @@ -477,7 +477,7 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet ) } // paragraph justification - SvxLRSpaceItem aLR = static_cast( aAttrSet.Get( EE_PARA_LRSPACE ) ); + SvxLRSpaceItem aLR = aAttrSet.Get( EE_PARA_LRSPACE ); rSet.Put(aLR); SvxAdjust eAdj = static_cast( aAttrSet.Get( EE_PARA_JUST ) ).GetAdjust(); switch( eAdj ) @@ -513,7 +513,7 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet ) } else { - switch( static_cast( aAttrSet.Get( EE_PARA_WRITINGDIR ) ).GetValue() ) + switch( aAttrSet.Get( EE_PARA_WRITINGDIR ).GetValue() ) { case SvxFrameDirection::Vertical_LR_TB: case SvxFrameDirection::Vertical_RL_TB: @@ -554,7 +554,7 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet ) } } - SvxLRSpaceItem aLRSpace = static_cast( aAttrSet.Get( EE_PARA_LRSPACE ) ); + SvxLRSpaceItem aLRSpace = aAttrSet.Get( EE_PARA_LRSPACE ); aLRSpace.SetWhich(SID_ATTR_PARA_LRSPACE); rSet.Put(aLRSpace); Invalidate(SID_ATTR_PARA_LRSPACE); diff --git a/sd/source/ui/view/drtxtob1.cxx b/sd/source/ui/view/drtxtob1.cxx index 80296e5b2d4e..6e539965659e 100644 --- a/sd/source/ui/view/drtxtob1.cxx +++ b/sd/source/ui/view/drtxtob1.cxx @@ -266,7 +266,7 @@ void TextObjectBar::Execute( SfxRequest &rReq ) SvxLRSpaceItem aLRSpace = static_cast(pArgs->Get( GetPool().GetWhich(SID_ATTR_PARA_LRSPACE))); - SfxItemSet aEditAttr( GetPool(), svl::Items{} ); + SfxItemSet aEditAttr( GetPool(), svl::Items{} ); aLRSpace.SetWhich( EE_PARA_LRSPACE ); aEditAttr.Put( aLRSpace ); @@ -278,11 +278,11 @@ void TextObjectBar::Execute( SfxRequest &rReq ) case SID_HANGING_INDENT: { - SfxItemSet aLRSpaceSet( GetPool(), svl::Items{} ); + SfxItemSet aLRSpaceSet( GetPool(), svl::Items{} ); mpView->GetAttributes( aLRSpaceSet ); - SvxLRSpaceItem aParaMargin( static_cast( aLRSpaceSet.Get( EE_PARA_LRSPACE ) ) ); + SvxLRSpaceItem aParaMargin( aLRSpaceSet.Get( EE_PARA_LRSPACE ) ); - SvxLRSpaceItem aNewMargin( EE_PARA_LRSPACE ); + SvxLRSpaceItem aNewMargin( EE_PARA_LRSPACE.Which() ); aNewMargin.SetTextLeft( aParaMargin.GetTextLeft() + aParaMargin.GetTextFirstLineOfst() ); aNewMargin.SetRight( aParaMargin.GetRight() ); aNewMargin.SetTextFirstLineOfst( ( aParaMargin.GetTextFirstLineOfst() ) * (-1) ); @@ -394,7 +394,7 @@ void TextObjectBar::Execute( SfxRequest &rReq ) aNewRule.SetLevel(nLevel, aFmt); } - pFirstStyleSheet->GetItemSet().Put(SvxNumBulletItem(aNewRule, EE_PARA_NUMBULLET)); + pFirstStyleSheet->GetItemSet().Put(SvxNumBulletItem(aNewRule, EE_PARA_NUMBULLET.Which())); SdStyleSheet::BroadcastSdStyleSheetChange(pFirstStyleSheet, PO_OUTLINE_1, pSSPool); } @@ -601,13 +601,13 @@ void TextObjectBar::Execute( SfxRequest &rReq ) if( bLeftToRight ) { - aNewAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_LR_TB, EE_PARA_WRITINGDIR ) ); + aNewAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_LR_TB, EE_PARA_WRITINGDIR.Which() ) ); if( nAdjust == SvxAdjust::Right ) aNewAttr.Put( SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST ) ); } else { - aNewAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_RL_TB, EE_PARA_WRITINGDIR ) ); + aNewAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_RL_TB, EE_PARA_WRITINGDIR.Which() ) ); if( nAdjust == SvxAdjust::Left ) aNewAttr.Put( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) ); } diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 6e327c690ae1..b98e4acddda6 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -669,16 +669,16 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) if( pItem ) { - SfxItemSet aSet( GetPool(), svl::Items{} ); + SfxItemSet aSet( GetPool(), svl::Items{} ); bool bValue = pItem->GetValue(); - aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) ); + aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE.Which(), bValue ) ); mpDrawView->SetAttributes( aSet ); } else // only for testing purpose { OSL_FAIL(" no value for hyphenation!"); - SfxItemSet aSet( GetPool(), svl::Items{} ); - aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, true ) ); + SfxItemSet aSet( GetPool(), svl::Items{} ); + aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE.Which(), true ) ); mpDrawView->SetAttributes( aSet ); } rReq.Done(); diff --git a/sd/source/ui/view/drviews3.cxx b/sd/source/ui/view/drviews3.cxx index 5c35827aff84..b2e9d1c2330d 100644 --- a/sd/source/ui/view/drviews3.cxx +++ b/sd/source/ui/view/drviews3.cxx @@ -742,7 +742,7 @@ void DrawViewShell::ExecRuler(SfxRequest& rReq) SvxLRSpaceItem aLRSpace = static_cast(pArgs->Get( GetPool().GetWhich(SID_ATTR_PARA_LRSPACE))); - SfxItemSet aEditAttr( GetPool(), svl::Items{} ); + SfxItemSet aEditAttr( GetPool(), svl::Items{} ); aLRSpace.SetWhich( EE_PARA_LRSPACE ); aEditAttr.Put( aLRSpace ); @@ -760,9 +760,9 @@ void DrawViewShell::ExecRuler(SfxRequest& rReq) static const sal_uInt16 aWhichTable[]= { - EE_PARA_OUTLLEVEL, EE_PARA_OUTLLEVEL, - EE_PARA_LRSPACE, EE_PARA_LRSPACE, - EE_PARA_NUMBULLET, EE_PARA_NUMBULLET, + EE_PARA_OUTLLEVEL.Which(), EE_PARA_OUTLLEVEL.Which(), + EE_PARA_LRSPACE.Which(), EE_PARA_LRSPACE.Which(), + EE_PARA_NUMBULLET.Which(), EE_PARA_NUMBULLET.Which(), 0, 0 }; @@ -770,14 +770,14 @@ void DrawViewShell::ExecRuler(SfxRequest& rReq) aWhichTable ); mpDrawView->GetAttributes( aEditAttr ); - nId = EE_PARA_LRSPACE; + nId = EE_PARA_LRSPACE.Which(); SvxLRSpaceItem aLRSpaceItem( rItem.GetLeft(), rItem.GetRight(), rItem.GetTextLeft(), rItem.GetTextFirstLineOfst(), nId ); - const sal_Int16 nOutlineLevel = static_cast(aEditAttr.Get( EE_PARA_OUTLLEVEL )).GetValue(); - const SvxLRSpaceItem& rOrigLRSpaceItem = static_cast( aEditAttr.Get( EE_PARA_LRSPACE )); - const SvxNumBulletItem& rNumBulletItem = static_cast( aEditAttr.Get( EE_PARA_NUMBULLET ) ); + const sal_Int16 nOutlineLevel = aEditAttr.Get( EE_PARA_OUTLLEVEL ).GetValue(); + const SvxLRSpaceItem& rOrigLRSpaceItem = aEditAttr.Get( EE_PARA_LRSPACE ); + const SvxNumBulletItem& rNumBulletItem = aEditAttr.Get( EE_PARA_NUMBULLET ); if( nOutlineLevel != -1 && rNumBulletItem.GetNumRule() && rNumBulletItem.GetNumRule()->GetLevelCount() > nOutlineLevel ) @@ -832,7 +832,7 @@ void DrawViewShell::ExecRuler(SfxRequest& rReq) // only put lrSpace item SfxItemSet aEditAttrReduced( GetDoc()->GetPool(), - svl::Items{} ); + svl::Items{} ); aEditAttrReduced.Put( aLRSpaceItem ); mpDrawView->SetAttributes( aEditAttrReduced ); @@ -901,13 +901,13 @@ void DrawViewShell::GetRulerState(SfxItemSet& rSet) const SvxTabStopItem& rItem = static_cast( aEditAttr.Get( EE_PARA_TABS ) ); rSet.Put( rItem ); - const SvxLRSpaceItem& rLRSpaceItem = static_cast( aEditAttr.Get( EE_PARA_LRSPACE ) ); + const SvxLRSpaceItem& rLRSpaceItem = aEditAttr.Get( EE_PARA_LRSPACE ); SvxLRSpaceItem aLRSpaceItem( rLRSpaceItem.GetLeft(), rLRSpaceItem.GetRight(), rLRSpaceItem.GetTextLeft(), rLRSpaceItem.GetTextFirstLineOfst(), SID_ATTR_PARA_LRSPACE ); - const sal_Int16 nOutlineLevel = static_cast( aEditAttr.Get( EE_PARA_OUTLLEVEL )).GetValue(); - const SvxNumBulletItem& rNumBulletItem = static_cast( aEditAttr.Get( EE_PARA_NUMBULLET ) ); + const sal_Int16 nOutlineLevel = aEditAttr.Get( EE_PARA_OUTLLEVEL ).GetValue(); + const SvxNumBulletItem& rNumBulletItem = aEditAttr.Get( EE_PARA_NUMBULLET ); if( nOutlineLevel != -1 && rNumBulletItem.GetNumRule() && rNumBulletItem.GetNumRule()->GetLevelCount() > nOutlineLevel ) @@ -956,7 +956,7 @@ void DrawViewShell::GetRulerState(SfxItemSet& rSet) if( aEditAttr.GetItemState( EE_PARA_WRITINGDIR ) >= SfxItemState::DEFAULT ) { - const SvxFrameDirectionItem& rItem = static_cast( aEditAttr.Get( EE_PARA_WRITINGDIR ) ); + const SvxFrameDirectionItem& rItem = aEditAttr.Get( EE_PARA_WRITINGDIR ); rSet.Put(SfxBoolItem(SID_RULER_TEXT_RIGHT_TO_LEFT, rItem.GetValue() == SvxFrameDirection::Horizontal_RL_TB)); } } diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx index 218312476031..ab5f07bd21b3 100644 --- a/sd/source/ui/view/drviewsf.cxx +++ b/sd/source/ui/view/drviewsf.cxx @@ -355,7 +355,7 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet ) { SfxItemSet aAttrs( GetDoc()->GetPool() ); mpDrawView->GetAttributes( aAttrs ); - SvxLRSpaceItem aLRSpace = static_cast( aAttrs.Get( EE_PARA_LRSPACE ) ); + SvxLRSpaceItem aLRSpace = aAttrs.Get( EE_PARA_LRSPACE ); aLRSpace.SetWhich(SID_ATTR_PARA_LRSPACE); rSet.Put(aLRSpace); bAttr = true; @@ -426,7 +426,7 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet ) mpDrawView->GetAttributes( aAttrs ); if( aAttrs.GetItemState( EE_PARA_HYPHENATE ) >= SfxItemState::DEFAULT ) { - bool bValue = static_cast( aAttrs.Get( EE_PARA_HYPHENATE ) ).GetValue(); + bool bValue = aAttrs.Get( EE_PARA_HYPHENATE ).GetValue(); rSet.Put( SfxBoolItem( SID_HYPHENATION, bValue ) ); } } diff --git a/sd/source/ui/view/outlview.cxx b/sd/source/ui/view/outlview.cxx index 67d509d913c7..97c74ad2a011 100644 --- a/sd/source/ui/view/outlview.cxx +++ b/sd/source/ui/view/outlview.cxx @@ -86,7 +86,7 @@ OutlineView::OutlineView( DrawDocShell& rDocSh, vcl::Window* pWindow, OutlineVie , mbFirstPaint(true) , mpProgress(nullptr) , maDocColor( COL_WHITE ) -, maLRSpaceItem( 0, 0, 2000, 0, EE_PARA_OUTLLRSPACE ) +, maLRSpaceItem( 0, 0, 2000, 0, EE_PARA_OUTLLRSPACE.Which() ) { bool bInitOutliner = false; diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx index b89d56ba7de7..e46103b4c40a 100644 --- a/sd/source/ui/view/viewshel.cxx +++ b/sd/source/ui/view/viewshel.cxx @@ -937,21 +937,21 @@ const SfxPoolItem* ViewShell::GetNumBulletItem(SfxItemSet& aNewAttr, sal_uInt16& } if( pItem == nullptr ) - pItem = static_cast( aNewAttr.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET) ); + pItem = aNewAttr.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET); std::unique_ptr pNewItem(pItem->CloneSetWhich(EE_PARA_NUMBULLET)); aNewAttr.Put(*pNewItem); if(bTitle && aNewAttr.GetItemState(EE_PARA_NUMBULLET) == SfxItemState::SET ) { - const SvxNumBulletItem* pBulletItem = static_cast(aNewAttr.GetItem(EE_PARA_NUMBULLET)); + const SvxNumBulletItem* pBulletItem = aNewAttr.GetItem(EE_PARA_NUMBULLET); SvxNumRule* pRule = pBulletItem->GetNumRule(); if(pRule) { SvxNumRule aNewRule( *pRule ); aNewRule.SetFeatureFlag( SvxNumRuleFlags::NO_NUMBERS ); - SvxNumBulletItem aNewItem( aNewRule, EE_PARA_NUMBULLET ); + SvxNumBulletItem aNewItem( aNewRule, EE_PARA_NUMBULLET.Which() ); aNewAttr.Put(aNewItem); } } diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx index 3b0238e8705d..a3c09c83038d 100644 --- a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx @@ -118,7 +118,7 @@ static bool InitializeFontWorkData( const SdrObject* pCustomShape, const sal_uIn aParagraphData.aString = rTextObj.GetText( j ); const SfxItemSet& rParaSet = rTextObj.GetParaAttribs( j ); // retrieving some paragraph attributes - aParagraphData.nFrameDirection = static_cast(rParaSet.Get( EE_PARA_WRITINGDIR )).GetValue(); + aParagraphData.nFrameDirection = rParaSet.Get( EE_PARA_WRITINGDIR ).GetValue(); aTextArea.vParagraphs.push_back( aParagraphData ); } rFWData.vTextAreas.push_back( aTextArea ); diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx index 1bde1afca7f0..4d6bddb01fbc 100644 --- a/svx/source/svdraw/svdattr.cxx +++ b/svx/source/svdraw/svdattr.cxx @@ -565,12 +565,12 @@ void SdrItemPool::TakeItemName(sal_uInt16 nWhich, OUString& rItemName) case SDRATTR_GRAFMODE : pResId = SIP_SA_GRAFMODE;break; case SDRATTR_GRAFCROP : pResId = SIP_SA_GRAFCROP;break; - case EE_PARA_HYPHENATE : pResId = SIP_EE_PARA_HYPHENATE;break; - case EE_PARA_BULLETSTATE: pResId = SIP_EE_PARA_BULLETSTATE;break; - case EE_PARA_OUTLLRSPACE: pResId = SIP_EE_PARA_OUTLLRSPACE;break; - case EE_PARA_OUTLLEVEL : pResId = SIP_EE_PARA_OUTLLEVEL;break; - case EE_PARA_BULLET : pResId = SIP_EE_PARA_BULLET;break; - case EE_PARA_LRSPACE : pResId = SIP_EE_PARA_LRSPACE;break; + case EE_PARA_HYPHENATE.Which() : pResId = SIP_EE_PARA_HYPHENATE;break; + case EE_PARA_BULLETSTATE.Which(): pResId = SIP_EE_PARA_BULLETSTATE;break; + case EE_PARA_OUTLLRSPACE.Which(): pResId = SIP_EE_PARA_OUTLLRSPACE;break; + case EE_PARA_OUTLLEVEL.Which() : pResId = SIP_EE_PARA_OUTLLEVEL;break; + case EE_PARA_BULLET.Which() : pResId = SIP_EE_PARA_BULLET;break; + case EE_PARA_LRSPACE.Which() : pResId = SIP_EE_PARA_LRSPACE;break; case EE_PARA_ULSPACE : pResId = SIP_EE_PARA_ULSPACE;break; case EE_PARA_SBL : pResId = SIP_EE_PARA_SBL;break; case EE_PARA_JUST : pResId = SIP_EE_PARA_JUST;break; diff --git a/svx/source/unodraw/unomod.cxx b/svx/source/unodraw/unomod.cxx index 8aeb91bf8dcb..93f86755bdda 100644 --- a/svx/source/unodraw/unomod.cxx +++ b/svx/source/unodraw/unomod.cxx @@ -692,7 +692,7 @@ css::uno::Reference< css::container::XIndexReplace > SvxCreateNumRule( SdrModel* const SvxNumRule* pDefaultRule = nullptr; if( pModel ) { - const SvxNumBulletItem* pItem = static_cast( pModel->GetItemPool().GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET) ); + const SvxNumBulletItem* pItem = pModel->GetItemPool().GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET); if( pItem ) { pDefaultRule = pItem->GetNumRule(); diff --git a/sw/source/uibase/shells/annotsh.cxx b/sw/source/uibase/shells/annotsh.cxx index 8e94dd42375d..e65dd89523ac 100644 --- a/sw/source/uibase/shells/annotsh.cxx +++ b/sw/source/uibase/shells/annotsh.cxx @@ -575,7 +575,7 @@ void SwAnnotationShell::Exec( SfxRequest &rReq ) SfxItemSet aAttr( *aNewAttr.GetPool(), svl::Items< - EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR, + EE_PARA_WRITINGDIR.Which(), EE_PARA_WRITINGDIR.Which(), EE_PARA_JUST, EE_PARA_JUST>{}); SvxAdjust nAdjust = SvxAdjust::Left; @@ -584,13 +584,13 @@ void SwAnnotationShell::Exec( SfxRequest &rReq ) if( bLeftToRight ) { - aAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_LR_TB, EE_PARA_WRITINGDIR ) ); + aAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_LR_TB, EE_PARA_WRITINGDIR.Which() ) ); if( nAdjust == SvxAdjust::Right ) aAttr.Put( SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST ) ); } else { - aAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_RL_TB, EE_PARA_WRITINGDIR ) ); + aAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_RL_TB, EE_PARA_WRITINGDIR.Which() ) ); if( nAdjust == SvxAdjust::Left ) aAttr.Put( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) ); } @@ -646,7 +646,7 @@ void SwAnnotationShell::GetState(SfxItemSet& rSet) SfxItemState eState = aEditAttr.GetItemState( EE_PARA_LRSPACE ); if( eState >= SfxItemState::DEFAULT ) { - SvxLRSpaceItem aLR = static_cast( aEditAttr.Get( EE_PARA_LRSPACE ) ); + SvxLRSpaceItem aLR = aEditAttr.Get( EE_PARA_LRSPACE ); aLR.SetWhich(nSlotId); rSet.Put(aLR); } @@ -826,7 +826,7 @@ void SwAnnotationShell::GetState(SfxItemSet& rSet) else { bool bFlag = false; - switch( static_cast( aEditAttr.Get( EE_PARA_WRITINGDIR ) ).GetValue() ) + switch( aEditAttr.Get( EE_PARA_WRITINGDIR ).GetValue() ) { case SvxFrameDirection::Horizontal_LR_TB: { diff --git a/sw/source/uibase/shells/drwtxtex.cxx b/sw/source/uibase/shells/drwtxtex.cxx index e92724c00f00..4c11e1cecb62 100644 --- a/sw/source/uibase/shells/drwtxtex.cxx +++ b/sw/source/uibase/shells/drwtxtex.cxx @@ -224,7 +224,7 @@ void SwDrawTextShell::Execute( SfxRequest &rReq ) SfxItemState eState = aEditAttr.GetItemState( EE_PARA_LRSPACE ); if( eState >= SfxItemState::DEFAULT ) { - SvxLRSpaceItem aParaMargin = static_cast( aEditAttr.Get( EE_PARA_LRSPACE ) ); + SvxLRSpaceItem aParaMargin = aEditAttr.Get( EE_PARA_LRSPACE ); aParaMargin.SetWhich( EE_PARA_LRSPACE ); short int nFirstLineOffset = aParaMargin.GetTextFirstLineOfst(); aParaMargin.SetTextLeft( aParaMargin.GetTextLeft() + nFirstLineOffset ); @@ -536,7 +536,7 @@ void SwDrawTextShell::Execute( SfxRequest &rReq ) SfxItemSet aAttr( *aNewAttr.GetPool(), svl::Items< - EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR, + EE_PARA_WRITINGDIR.Which(), EE_PARA_WRITINGDIR.Which(), EE_PARA_JUST, EE_PARA_JUST>{}); SvxAdjust nAdjust = SvxAdjust::Left; @@ -545,13 +545,13 @@ void SwDrawTextShell::Execute( SfxRequest &rReq ) if( bLeftToRight ) { - aAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_LR_TB, EE_PARA_WRITINGDIR ) ); + aAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_LR_TB, EE_PARA_WRITINGDIR.Which() ) ); if( nAdjust == SvxAdjust::Right ) aAttr.Put( SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST ) ); } else { - aAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_RL_TB, EE_PARA_WRITINGDIR ) ); + aAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_RL_TB, EE_PARA_WRITINGDIR.Which() ) ); if( nAdjust == SvxAdjust::Left ) aAttr.Put( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) ); } @@ -667,7 +667,7 @@ ASK_ADJUST: SfxItemState eState = aEditAttr.GetItemState(EE_PARA_LRSPACE); if( eState >= SfxItemState::DEFAULT ) { - SvxLRSpaceItem aLR = static_cast( aEditAttr.Get( EE_PARA_LRSPACE ) ); + SvxLRSpaceItem aLR = aEditAttr.Get( EE_PARA_LRSPACE ); aLR.SetWhich(SID_ATTR_PARA_LRSPACE); rSet.Put(aLR); } @@ -836,7 +836,7 @@ ASK_ESCAPE: } else { - switch( static_cast( aEditAttr.Get( EE_PARA_WRITINGDIR ) ).GetValue() ) + switch( aEditAttr.Get( EE_PARA_WRITINGDIR ).GetValue() ) { case SvxFrameDirection::Horizontal_LR_TB: bFlag = nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT; diff --git a/sw/source/uibase/uiview/viewdraw.cxx b/sw/source/uibase/uiview/viewdraw.cxx index 04cc5e8d57f2..b06dc59965bf 100644 --- a/sw/source/uibase/uiview/viewdraw.cxx +++ b/sw/source/uibase/uiview/viewdraw.cxx @@ -752,11 +752,10 @@ bool SwView::IsDrawTextHyphenate() bool bHyphenate = false; SfxItemSet aNewAttr( pSdrView->GetModel()->GetItemPool(), - svl::Items{} ); + svl::Items{} ); if( pSdrView->GetAttributes( aNewAttr ) && aNewAttr.GetItemState( EE_PARA_HYPHENATE ) >= SfxItemState::DEFAULT ) - bHyphenate = static_cast(aNewAttr.Get( EE_PARA_HYPHENATE )). - GetValue(); + bHyphenate = aNewAttr.Get( EE_PARA_HYPHENATE ).GetValue(); return bHyphenate; } @@ -766,8 +765,8 @@ void SwView::HyphenateDrawText() SdrView *pSdrView = m_pWrtShell->GetDrawView(); bool bHyphenate = IsDrawTextHyphenate(); - SfxItemSet aSet( GetPool(), svl::Items{} ); - aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, !bHyphenate ) ); + SfxItemSet aSet( GetPool(), svl::Items{} ); + aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE.Which(), !bHyphenate ) ); pSdrView->SetAttributes( aSet ); GetViewFrame()->GetBindings().Invalidate(FN_HYPHENATE_OPT_DLG); } -- cgit