sw/source/filter/ww8/writerhelper.hxx   |   28 ----------------------------
 sw/source/filter/ww8/writerwordglue.cxx |    3 +--
 sw/source/filter/ww8/wrtw8esh.cxx       |    2 +-
 sw/source/filter/ww8/wrtw8nds.cxx       |   13 ++++++-------
 sw/source/filter/ww8/ww8atr.cxx         |   12 +++++-------
 sw/source/filter/ww8/ww8graf.cxx        |    2 +-
 sw/source/filter/ww8/ww8par.cxx         |    2 +-
 sw/source/filter/ww8/ww8par6.cxx        |   10 +++++-----
 8 files changed, 20 insertions(+), 52 deletions(-)

New commits:
commit aa01aa03b73ddeeae1f98730b21ec77338af5f9e
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Mar 1 18:57:56 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Mar 2 07:46:07 2022 +0100

    remove writerhelper::ItemGet
    
    the TypedWhichId template methods on SfxItemSet supercede this
    
    Change-Id: I9c6240657a7c98fad93399f9ce17c370acd125c2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130803
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/filter/ww8/writerhelper.hxx 
b/sw/source/filter/ww8/writerhelper.hxx
index 91b881eaf57c..29e9a8e6b495 100644
--- a/sw/source/filter/ww8/writerhelper.hxx
+++ b/sw/source/filter/ww8/writerhelper.hxx
@@ -302,34 +302,6 @@ namespace sw
             return item_cast<T>(rFormat.GetFormatAttr(eType));
         }
 
-        /** Extract a SfxPoolItem derived property from a SfxItemSet
-
-            Writer's attributes are retrieved by passing a numeric identifier
-            and receiving a SfxPoolItem reference which must then typically be
-            cast back to its original type which is both tedious and verbose.
-
-            ItemGet uses item_cast () on the retrieved reference to test that 
the
-            retrieved property is of the type that the developer thinks it is.
-
-            @param rSet
-            The SfxItemSet to retrieve the property from
-
-            @param eType
-            The numeric identifier of the property to be retrieved
-
-            @tplparam T
-            A SfxPoolItem derived class of the retrieved property
-
-            @exception std::bad_cast Thrown if the property was not a T
-
-            @return The T requested
-        */
-        template<class T> const T & ItemGet(const SfxItemSet &rSet,
-            sal_uInt16 eType)
-        {
-            return item_cast<T>(rSet.Get(eType));
-        }
-
         /** Extract a default SfxPoolItem derived property from a SfxItemPool
 
             Writer's attributes are retrieved by passing a numeric identifier
diff --git a/sw/source/filter/ww8/writerwordglue.cxx 
b/sw/source/filter/ww8/writerwordglue.cxx
index 3d4a06e5cce3..fda1043db476 100644
--- a/sw/source/filter/ww8/writerwordglue.cxx
+++ b/sw/source/filter/ww8/writerwordglue.cxx
@@ -404,8 +404,7 @@ namespace sw
             {
                 dyaHdrTop = dyaHdrBottom = 0;
             }
-            const SvxULSpaceItem &rUL =
-                ItemGet<SvxULSpaceItem>(rPage, RES_UL_SPACE);
+            const SvxULSpaceItem &rUL = rPage.Get(RES_UL_SPACE);
             dyaHdrTop += rUL.GetUpper();
             dyaHdrBottom += rUL.GetLower();
 
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx 
b/sw/source/filter/ww8/wrtw8esh.cxx
index 7927d230a553..6ce80301125c 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -1032,7 +1032,7 @@ void MSWord_SdrAttrIter::NextPara( sal_Int32 nPar )
 
     SfxItemSet aSet( pEditObj->GetParaAttribs( nPara ));
     pEditPool = aSet.GetPool();
-    eNdChrSet = ItemGet<SvxFontItem>(aSet,EE_CHAR_FONTINFO).GetCharSet();
+    eNdChrSet = aSet.Get(EE_CHAR_FONTINFO).GetCharSet();
 
     assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
     nScript = g_pBreakIt->GetBreakIter()->getScriptType( 
pEditObj->GetText(nPara), 0);
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx 
b/sw/source/filter/ww8/wrtw8nds.cxx
index 36d80ebb427d..bf0d049b1d6a 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -403,7 +403,7 @@ void SwWW8AttrIter::OutAttr(sal_Int32 nSwPos, bool 
bWriteCombChars)
      script, the idea is that the font that is actually in use to render this
      range of text ends up in pFont
     */
-    sal_uInt16 nFontId = GetWhichOfScript( RES_CHRATR_FONT, GetScript() );
+    TypedWhichId<SvxFontItem> nFontId = GetWhichOfScript( RES_CHRATR_FONT, 
GetScript() );
 
     const SvxFontItem &rParentFont = ItemGet<SvxFontItem>(
         static_cast<const SwTextFormatColl&>(rNd.GetAnyFormatColl()), nFontId);
@@ -418,7 +418,7 @@ void SwWW8AttrIter::OutAttr(sal_Int32 nSwPos, bool 
bWriteCombChars)
         // only copy hard attributes - bDeep = false
         aExportSet.Set(rNd.GetSwAttrSet(), false/*bDeep*/);
         // get the current font item. Use rNd.GetSwAttrSet instead of 
aExportSet:
-        const SvxFontItem &rNdFont = ItemGet<SvxFontItem>(rNd.GetSwAttrSet(), 
nFontId);
+        const SvxFontItem &rNdFont = rNd.GetSwAttrSet().Get(nFontId);
         pFont = &rNdFont;
         aExportSet.ClearItem(nFontId);
     }
@@ -2807,7 +2807,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
 
                 if ( !bCheckSectionBreak )
                 {
-                    auto rBreak = 
ItemGet<SvxFormatBreakItem>(rNode.GetSwAttrSet(), RES_BREAK);
+                    const SvxFormatBreakItem& rBreak = 
rNode.GetSwAttrSet().Get(RES_BREAK);
                     if ( rBreak.GetBreak() == SvxBreak::PageAfter )
                     {
                         if ( pNextNode && pNextNode->FindPageDesc() != 
pNextSplitParaPageDesc )
@@ -2898,7 +2898,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
                 if( !oTmpSet )
                     oTmpSet.emplace( rNode.GetSwAttrSet() );
 
-                SvxLRSpaceItem aLR(ItemGet<SvxLRSpaceItem>(*oTmpSet, 
RES_LR_SPACE));
+                SvxLRSpaceItem aLR(oTmpSet->Get(RES_LR_SPACE));
                 // #i86652#
                 if ( pFormat->GetPositionAndSpaceMode() ==
                                         
SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
@@ -2952,8 +2952,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
                     oTmpSet->Put(aLR);
 
                     //#i21847#
-                    SvxTabStopItem aItem(
-                        ItemGet<SvxTabStopItem>(*oTmpSet, RES_PARATR_TABSTOP));
+                    SvxTabStopItem aItem(oTmpSet->Get(RES_PARATR_TABSTOP));
                     SvxTabStop aTabStop(pFormat->GetAbsLSpace());
                     aItem.Insert(aTabStop);
                     oTmpSet->Put(aItem);
@@ -3059,7 +3058,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
                  SfxItemState::SET != 
rNode.GetpSwAttrSet()->GetItemState(RES_BREAK, false) )
             {
                 const SvxFormatBreakItem& rBreakAtParaStyle
-                    = ItemGet<SvxFormatBreakItem>(rNode.GetSwAttrSet(), 
RES_BREAK);
+                    = rNode.GetSwAttrSet().Get(RES_BREAK);
                 if (rBreakAtParaStyle.GetBreak() == SvxBreak::PageAfter)
                 {
                     if ( !oTmpSet )
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 243add5dc339..f90d04a765a3 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -657,7 +657,7 @@ sal_uLong MSWordExportBase::GetSectionLineNo( const 
SfxItemSet* pSet, const SwNo
     const SwFormatLineNumber* pNItem = nullptr;
     if ( pSet )
     {
-        pNItem = &( ItemGet<SwFormatLineNumber>( *pSet, RES_LINENUMBER ) );
+        pNItem = & pSet->Get( RES_LINENUMBER );
     }
     else if ( const SwContentNode *pNd = rNd.GetContentNode() )
     {
@@ -849,8 +849,7 @@ void MSWordExportBase::OutputFormat( const SwFormat& 
rFormat, bool bPapFormat, b
                      rNFormat.GetAbsLSpace() )
                 {
                     SfxItemSet aSet( rFormat.GetAttrSet() );
-                    SvxLRSpaceItem aLR(
-                        ItemGet<SvxLRSpaceItem>(aSet, RES_LR_SPACE));
+                    SvxLRSpaceItem aLR(aSet.Get(RES_LR_SPACE));
 
                     aLR.SetTextLeft( aLR.GetTextLeft() + 
rNFormat.GetAbsLSpace() );
                     aLR.SetTextFirstLineOffset( 
GetWordFirstLineOffset(rNFormat));
@@ -872,8 +871,7 @@ void MSWordExportBase::OutputFormat( const SwFormat& 
rFormat, bool bPapFormat, b
                 if ( m_bStyDef && DisallowInheritingOutlineNumbering(rFormat) )
                 {
                     SfxItemSet aSet( rFormat.GetAttrSet() );
-                    const SvxLRSpaceItem& aLR(
-                        ItemGet<SvxLRSpaceItem>(aSet, RES_LR_SPACE));
+                    const SvxLRSpaceItem& aLR = aSet.Get(RES_LR_SPACE);
                     aSet.Put( aLR );
                     OutputItemSet( aSet, bPapFormat, bChpFormat,
                         css::i18n::ScriptType::LATIN, m_bExportModeRTF);
@@ -5321,7 +5319,7 @@ void WW8AttributeOutput::ParaTabStop( const 
SvxTabStopItem& rTabStops )
         tools::Long nParentLeft = 0;
         if ( bTabsRelativeToIndex )
         {
-            const SvxLRSpaceItem &rStyleLR = ItemGet<SvxLRSpaceItem>( 
pParentStyle->GetAttrSet(), RES_LR_SPACE );
+            const SvxLRSpaceItem &rStyleLR = pParentStyle->GetAttrSet().Get( 
RES_LR_SPACE );
             nParentLeft = rStyleLR.GetTextLeft();
         }
 
@@ -5344,7 +5342,7 @@ void WW8AttributeOutput::ParaTabStop( const 
SvxTabStopItem& rTabStops )
         tools::Long nStyleLeft = 0;
         if ( bTabsRelativeToIndex )
         {
-            const SvxLRSpaceItem &rStyleLR = 
ItemGet<SvxLRSpaceItem>(*m_rWW8Export.m_pStyAttr, RES_LR_SPACE);
+            const SvxLRSpaceItem &rStyleLR = 
m_rWW8Export.m_pStyAttr->Get(RES_LR_SPACE);
             nStyleLeft = rStyleLR.GetTextLeft();
         }
 
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index 3cb0aebf6bc8..2c7a11452d2f 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -1742,7 +1742,7 @@ void SwWW8ImplReader::MatchSdrItemsIntoFlySet( SdrObject 
const * pSdrObj,
 
     // now calculate the borders and build the box: The unit is needed for the
     // frame SIZE!
-    SvxBoxItem aBox(sw::util::ItemGet<SvxBoxItem>(rFlySet, RES_BOX));
+    SvxBoxItem aBox(rFlySet.Get(RES_BOX));
     // dashed or solid becomes solid
     // WW-default: 0.75 pt = 15 twips
     sal_Int32 nLineThick = 15, nOutside=0;
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 5bcf33eba878..350275a340c2 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4145,7 +4145,7 @@ bool SwWW8ImplReader::ReadText(WW8_CP nStartCp, WW8_CP 
nTextLen, ManTypes nType)
             const SwFormatCharFormat *pSwFormatCharFormat = nullptr;
 
             if (m_xCurrentItemSet)
-                pSwFormatCharFormat = 
&(ItemGet<SwFormatCharFormat>(*m_xCurrentItemSet, RES_TXTATR_CHARFMT));
+                pSwFormatCharFormat = 
&(m_xCurrentItemSet->Get(RES_TXTATR_CHARFMT));
 
             if (pSwFormatCharFormat)
                 pFormat = pSwFormatCharFormat->GetCharFormat();
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 9473fca42e45..6d4938a8557f 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -562,9 +562,9 @@ void SwWW8ImplReader::SetPageBorder(SwFrameFormat &rFormat, 
const wwSection &rSe
     SfxItemSet aSet(rFormat.GetAttrSet());
     short aSizeArray[5]={0};
     SetFlyBordersShadow(aSet, rSection.brc, &aSizeArray[0]);
-    SvxLRSpaceItem aLR(ItemGet<SvxLRSpaceItem>(aSet, RES_LR_SPACE));
-    SvxULSpaceItem aUL(ItemGet<SvxULSpaceItem>(aSet, RES_UL_SPACE));
-    SvxBoxItem aBox(ItemGet<SvxBoxItem>(aSet, RES_BOX));
+    SvxLRSpaceItem aLR(aSet.Get(RES_LR_SPACE));
+    SvxULSpaceItem aUL(aSet.Get(RES_UL_SPACE));
+    SvxBoxItem aBox(aSet.Get(RES_BOX));
     bool bFromEdge = rSection.maSep.pgbOffsetFrom == 1;
 
     aLR.SetLeft(SetBorderDistance(bFromEdge, aBox, SvxBoxItemLine::LEFT, 
aLR.GetLeft()));
@@ -2740,7 +2740,7 @@ void SwWW8ImplReader::StopApo()
             using namespace sw::util;
             SfxItemSet aFlySet( m_xSFlyPara->GetFlyFormat()->GetAttrSet() );
 
-            SwFormatFrameSize aSize(ItemGet<SwFormatFrameSize>(aFlySet, 
RES_FRM_SIZE));
+            SwFormatFrameSize aSize(aFlySet.Get(RES_FRM_SIZE));
 
             aFlySet.ClearItem(RES_FRM_SIZE);
 
@@ -2750,7 +2750,7 @@ void SwWW8ImplReader::StopApo()
                     m_xSFlyPara->nWidth);
             }
 
-            nNewWidth = ItemGet<SwFormatFrameSize>(aFlySet, 
RES_FRM_SIZE).GetWidth();
+            nNewWidth = aFlySet.Get(RES_FRM_SIZE).GetWidth();
 
             aSize.SetWidth(nNewWidth);
             aSize.SetWidthSizeType(SwFrameSize::Variable);

Reply via email to