summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-03-01 19:14:03 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-03-02 08:31:22 +0100
commit24bcd1692cd9689f2586beebb5e4215d02fe8196 (patch)
tree017ce96ae7dab93bd22da1be00e9c4cce2e64e07 /sw
parent919b923e9fe59bd83d954a53c21635317fea0de7 (diff)
remove writerhelper::ItemGet
the TypedWhichId template methods on SwFormat supercede this Change-Id: I7444dc1eb85fccfc9d60da4f1502ea2e2ceccdc1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130805 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx10
-rw-r--r--sw/source/filter/ww8/writerhelper.cxx2
-rw-r--r--sw/source/filter/ww8/writerhelper.hxx26
-rw-r--r--sw/source/filter/ww8/writerwordglue.cxx3
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx10
-rw-r--r--sw/source/filter/ww8/wrtw8sty.cxx4
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx6
-rw-r--r--sw/source/filter/ww8/ww8par.cxx4
-rw-r--r--sw/source/filter/ww8/ww8par2.cxx2
-rw-r--r--sw/source/filter/ww8/ww8par3.cxx6
-rw-r--r--sw/source/filter/ww8/ww8par5.cxx6
-rw-r--r--sw/source/filter/ww8/ww8par6.cxx12
12 files changed, 31 insertions, 60 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 9bb849bce6aa..f5b270f1f580 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3324,12 +3324,12 @@ void DocxAttributeOutput::StartRuby( const SwTextNode& rNode, sal_Int32 nPos, co
{
const SwCharFormat* pFormat = rRuby.GetTextRuby()->GetCharFormat();
sal_uInt16 nScript = g_pBreakIt->GetBreakIter()->getScriptType(rRuby.GetText(), 0);
- sal_uInt16 nWhichFont = (nScript == i18n::ScriptType::LATIN) ? RES_CHRATR_FONT : RES_CHRATR_CJK_FONT;
- sal_uInt16 nWhichFontSize = (nScript == i18n::ScriptType::LATIN) ? RES_CHRATR_FONTSIZE : RES_CHRATR_CJK_FONTSIZE;
+ TypedWhichId<SvxFontItem> nWhichFont = (nScript == i18n::ScriptType::LATIN) ? RES_CHRATR_FONT : RES_CHRATR_CJK_FONT;
+ TypedWhichId<SvxFontHeightItem> nWhichFontSize = (nScript == i18n::ScriptType::LATIN) ? RES_CHRATR_FONTSIZE : RES_CHRATR_CJK_FONTSIZE;
- CharFont(ItemGet<SvxFontItem>(*pFormat, nWhichFont));
- CharFontSize(ItemGet<SvxFontHeightItem>(*pFormat, nWhichFontSize));
- CharFontSize(ItemGet<SvxFontHeightItem>(*pFormat, RES_CHRATR_CTL_FONTSIZE));
+ CharFont(pFormat->GetFormatAttr(nWhichFont));
+ CharFontSize(pFormat->GetFormatAttr(nWhichFontSize));
+ CharFontSize(pFormat->GetFormatAttr(RES_CHRATR_CTL_FONTSIZE));
}
EndRunProperties( nullptr );
diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx
index 740274453dfb..6c62af767ab0 100644
--- a/sw/source/filter/ww8/writerhelper.cxx
+++ b/sw/source/filter/ww8/writerhelper.cxx
@@ -589,7 +589,7 @@ namespace sw
const SwFrameFormat* pApply = rTable.GetFrameFormat();
OSL_ENSURE(pApply, "impossible");
if (pApply)
- pBreak = &(ItemGet<SvxFormatBreakItem>(*pApply, RES_BREAK));
+ pBreak = &pApply->GetFormatAttr(RES_BREAK);
}
else if (const SwContentNode *pNd = rNd.GetContentNode())
pBreak = &pNd->GetAttr(RES_BREAK);
diff --git a/sw/source/filter/ww8/writerhelper.hxx b/sw/source/filter/ww8/writerhelper.hxx
index 65d5c2501bc4..e07c6759d9c6 100644
--- a/sw/source/filter/ww8/writerhelper.hxx
+++ b/sw/source/filter/ww8/writerhelper.hxx
@@ -248,32 +248,6 @@ namespace sw
return dynamic_cast<const T *>(pItem);
}
- /** Extract a SfxPoolItem derived property from a SwFormat
-
- 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 rFormat
- The SwFormat 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
- */
- template<class T> const T & ItemGet(const SwFormat &rFormat,
- sal_uInt16 eType)
- {
- return item_cast<T>(rFormat.GetFormatAttr(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 5474148b5c5d..b2eb03e4a53a 100644
--- a/sw/source/filter/ww8/writerwordglue.cxx
+++ b/sw/source/filter/ww8/writerwordglue.cxx
@@ -70,8 +70,7 @@ namespace myImplHelpers
const SwFormatFrameSize& rSz = rFormat.GetFrameSize();
const SwHeaderAndFooterEatSpacingItem &rSpacingCtrl =
- sw::util::ItemGet<SwHeaderAndFooterEatSpacingItem>
- (rFormat, RES_HEADER_FOOTER_EAT_SPACING);
+ rFormat.GetFormatAttr(RES_HEADER_FOOTER_EAT_SPACING);
if (rSpacingCtrl.GetValue())
nDist += rSz.GetHeight();
else
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 394203367dc4..ff9304815f78 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -405,8 +405,8 @@ void SwWW8AttrIter::OutAttr(sal_Int32 nSwPos, bool bWriteCombChars)
*/
TypedWhichId<SvxFontItem> nFontId = GetWhichOfScript( RES_CHRATR_FONT, GetScript() );
- const SvxFontItem &rParentFont = ItemGet<SvxFontItem>(
- static_cast<const SwTextFormatColl&>(rNd.GetAnyFormatColl()), nFontId);
+ const SvxFontItem &rParentFont =
+ static_cast<const SwTextFormatColl&>(rNd.GetAnyFormatColl()).GetFormatAttr(nFontId);
const SvxFontItem *pFont = &rParentFont;
const SfxPoolItem *pGrabBag = nullptr;
@@ -3629,11 +3629,11 @@ WW8Ruby::WW8Ruby(const SwTextNode& rNode, const SwFormatRuby& rRuby, const MSWor
if (pFormat)
{
const auto& rFont
- = ItemGet<SvxFontItem>(*pFormat, GetWhichOfScript(RES_CHRATR_FONT, nRubyScript));
+ = pFormat->GetFormatAttr( GetWhichOfScript(RES_CHRATR_FONT, nRubyScript) );
m_sFontFamily = rFont.GetFamilyName();
- const auto& rHeight = ItemGet<SvxFontHeightItem>(
- *pFormat, GetWhichOfScript(RES_CHRATR_FONTSIZE, nRubyScript));
+ const auto& rHeight =
+ pFormat->GetFormatAttr( GetWhichOfScript(RES_CHRATR_FONTSIZE, nRubyScript) );
m_nRubyHeight = rHeight.GetHeight();
}
else
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index f91375da04bb..d613c00af5a2 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -1679,9 +1679,9 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
// at the child ONLY change column structure according to Sect-Attr.
const SvxLRSpaceItem &rSectionLR =
- ItemGet<SvxLRSpaceItem>( *(rSepInfo.pSectionFormat), RES_LR_SPACE );
+ rSepInfo.pSectionFormat->GetFormatAttr( RES_LR_SPACE );
const SvxLRSpaceItem &rPageLR =
- ItemGet<SvxLRSpaceItem>( *pPdFormat, RES_LR_SPACE );
+ pPdFormat->GetFormatAttr( RES_LR_SPACE );
SvxLRSpaceItem aResultLR( rPageLR.GetLeft() +
rSectionLR.GetLeft(), rPageLR.GetRight() +
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 531194cdf981..fcadda82f7c8 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -4037,8 +4037,7 @@ sal_uInt32 AttributeOutputBase::GridCharacterPitch( const SwTextGridItem& rGrid
if (pSwFormat != nullptr)
{
- nPageCharSize = ItemGet<SvxFontHeightItem>
- (*pSwFormat, RES_CHRATR_FONTSIZE).GetHeight();
+ nPageCharSize = pSwFormat->GetFormatAttr(RES_CHRATR_FONTSIZE).GetHeight();
}
sal_uInt16 nPitch = rGrid.IsSquaredMode() ? rGrid.GetBaseHeight() :
rGrid.GetBaseWidth( );
@@ -4953,8 +4952,7 @@ void WW8AttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust )
}
else if (auto pC = dynamic_cast<const SwTextFormatColl*>(m_rWW8Export.m_pOutFormatNode))
{
- const SvxFrameDirectionItem &rItem =
- ItemGet<SvxFrameDirectionItem>(*pC, RES_FRAMEDIR);
+ const SvxFrameDirectionItem &rItem = pC->GetFormatAttr(RES_FRAMEDIR);
nDirection = rItem.GetValue();
}
if ( ( nDirection == SvxFrameDirection::Horizontal_RL_TB ) ||
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 350275a340c2..3b787d257fb4 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1765,8 +1765,8 @@ void SwWW8ImplReader::Read_Tab(sal_uInt16 , const sal_uInt8* pData, short nLen)
if (!m_pCurrentColl) // not importing into a style
{
SvxTabStopItem aOrig = pSty ?
- ItemGet<SvxTabStopItem>(*pSty, RES_PARATR_TABSTOP) :
- DefaultItemGet<SvxTabStopItem>(m_rDoc, RES_PARATR_TABSTOP);
+ pSty->GetFormatAttr(RES_PARATR_TABSTOP) :
+ DefaultItemGet<SvxTabStopItem>(m_rDoc, RES_PARATR_TABSTOP);
NewAttr(aOrig);
}
}
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index b7ce97387f59..e47f11913548 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -3316,7 +3316,7 @@ void WW8TabDesc::AdjustNewBand()
SetTabBorders(pBox, j);
- SvxBoxItem aCurrentBox(sw::util::ItemGet<SvxBoxItem>(*(pBox->GetFrameFormat()), RES_BOX));
+ SvxBoxItem aCurrentBox(pBox->GetFrameFormat()->GetFormatAttr(RES_BOX));
pBox->GetFrameFormat()->SetFormatAttr(aCurrentBox);
SetTabVertAlign(pBox, j);
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index f59962580e2b..0d1c634d9839 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -1699,7 +1699,7 @@ void UseListIndent(SwWW8StyInf &rStyle, const SwNumFormat &rFormat)
{
const auto nAbsLSpace = rFormat.GetAbsLSpace();
const tools::Long nListFirstLineIndent = GetListFirstLineIndent(rFormat);
- SvxLRSpaceItem aLR(ItemGet<SvxLRSpaceItem>(*rStyle.m_pFormat, RES_LR_SPACE));
+ SvxLRSpaceItem aLR(rStyle.m_pFormat->GetFormatAttr(RES_LR_SPACE));
aLR.SetTextLeft(nAbsLSpace);
aLR.SetTextFirstLineOffset(writer_cast<short>(nListFirstLineIndent));
rStyle.m_pFormat->SetFormatAttr(aLR);
@@ -1712,7 +1712,7 @@ void SetStyleIndent(SwWW8StyInf &rStyle, const SwNumFormat &rFormat)
if ( rFormat.GetPositionAndSpaceMode() != SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) // #i86652#
return;
- SvxLRSpaceItem aLR(ItemGet<SvxLRSpaceItem>(*rStyle.m_pFormat, RES_LR_SPACE));
+ SvxLRSpaceItem aLR(rStyle.m_pFormat->GetFormatAttr(RES_LR_SPACE));
if (rStyle.m_bListRelevantIndentSet)
{
@@ -1769,7 +1769,7 @@ void SwWW8ImplReader::RegisterNumFormatOnStyle(sal_uInt16 nStyle)
return;
//Save old pre-list modified indent, which are the word indent values
- rStyleInf.maWordLR.reset(ItemGet<SvxLRSpaceItem>(*rStyleInf.m_pFormat, RES_LR_SPACE).Clone());
+ rStyleInf.maWordLR.reset(rStyleInf.m_pFormat->GetFormatAttr(RES_LR_SPACE).Clone());
// Phase 2: refresh StyleDef after reading all Lists
if (rStyleInf.m_nLFOIndex >= USHRT_MAX || rStyleInf.m_nListLevel >= WW8ListManager::nMaxLevel)
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index 8bc9dbb75dbf..a7075b66e949 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -2768,11 +2768,11 @@ void SwWW8ImplReader::Read_SubF_Ruby( WW8ReadFieldParams& rReadParam)
for(const auto& rpCharFormat : m_aRubyCharFormats)
{
const SvxFontHeightItem &rFH =
- ItemGet<SvxFontHeightItem>(*rpCharFormat,
- GetWhichOfScript(RES_CHRATR_FONTSIZE,nScript));
+ rpCharFormat->GetFormatAttr(
+ GetWhichOfScript(RES_CHRATR_FONTSIZE,nScript));
if (rFH.GetHeight() == nFontSize*10)
{
- const SvxFontItem &rF = ItemGet<SvxFontItem>(*rpCharFormat,
+ const SvxFontItem &rF = rpCharFormat->GetFormatAttr(
GetWhichOfScript(RES_CHRATR_FONT,nScript));
if (rF.GetFamilyName() == sFontName)
{
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 32028c0eebb3..7f47d529656d 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -219,12 +219,12 @@ void SwWW8ImplReader::SetDocumentGrid(SwFrameFormat &rFormat, const wwSection &r
rFormat.SetFormatAttr(SvxFrameDirectionItem(rSection.meDir, RES_FRAMEDIR));
SwTwips nTextareaHeight = rFormat.GetFrameSize().GetHeight();
- const SvxULSpaceItem &rUL = ItemGet<SvxULSpaceItem>(rFormat, RES_UL_SPACE);
+ const SvxULSpaceItem &rUL = rFormat.GetFormatAttr(RES_UL_SPACE);
nTextareaHeight -= rUL.GetUpper();
nTextareaHeight -= rUL.GetLower();
SwTwips nTextareaWidth = rFormat.GetFrameSize().GetWidth();
- const SvxLRSpaceItem &rLR = ItemGet<SvxLRSpaceItem>(rFormat, RES_LR_SPACE);
+ const SvxLRSpaceItem &rLR = rFormat.GetFormatAttr(RES_LR_SPACE);
nTextareaWidth -= rLR.GetLeft();
nTextareaWidth -= rLR.GetRight();
@@ -276,8 +276,9 @@ void SwWW8ImplReader::SetDocumentGrid(SwFrameFormat &rFormat, const wwSection &r
if (m_vColl[nI].m_bValid && m_vColl[nI].m_pFormat &&
m_vColl[nI].IsWW8BuiltInDefaultStyle())
{
- nCharWidth = ItemGet<SvxFontHeightItem>(*(m_vColl[nI].m_pFormat),
- RES_CHRATR_CJK_FONTSIZE).GetHeight();
+ const SvxFontHeightItem& rFontHeightItem =
+ m_vColl[nI].m_pFormat->GetFormatAttr(RES_CHRATR_CJK_FONTSIZE);
+ nCharWidth = rFontHeightItem.GetHeight();
break;
}
}
@@ -4311,8 +4312,7 @@ void SwWW8ImplReader::Read_LR( sal_uInt16 nId, const sal_uInt8* pData, short nLe
if (aIsZeroed.pSprm && aIsZeroed.nRemainingData >= 1 && *aIsZeroed.pSprm == 0)
{
const SvxLRSpaceItem &rLR =
- ItemGet<SvxLRSpaceItem>(*(m_vColl[m_nCurrentColl].m_pFormat),
- RES_LR_SPACE);
+ m_vColl[m_nCurrentColl].m_pFormat->GetFormatAttr(RES_LR_SPACE);
nPara = nPara - rLR.GetTextFirstLineOffset();
}
}