tdf#155630 De-duplicate code
Found the duplicated code by PMD analyser. Change-Id: I5c9858cca37c65fdedca109fa0f26be2baaf87a3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210482 Tested-by: Jenkins Reviewed-by: Hossein <hossein@libreoffice.org>
This commit is contained in:
@@ -39,6 +39,7 @@ class SwDoCapitals; // DoCapitals
|
||||
class SwScriptInfo; // GetTextSize_
|
||||
class SwViewShell;
|
||||
class IDocumentSettingAccess;
|
||||
class SvxBoxItem;
|
||||
enum class SvxShadowItemSide;
|
||||
|
||||
const sal_Unicode CH_BLANK = ' '; // ' ' blank spaces
|
||||
@@ -354,6 +355,8 @@ public:
|
||||
void Invalidate()
|
||||
{ m_bFontChg = m_bOrgChg = true; }
|
||||
|
||||
void SetBorder(const SvxBoxItem* pBoxItem);
|
||||
void ClearBorders();
|
||||
void SetTopBorder( const editeng::SvxBorderLine* pTopBorder );
|
||||
void SetBottomBorder( const editeng::SvxBorderLine* pBottomBorder );
|
||||
void SetRightBorder( const editeng::SvxBorderLine* pRightBorder );
|
||||
@@ -378,6 +381,10 @@ public:
|
||||
void SetBottomBorderDist( const sal_uInt16 nBottomDist );
|
||||
void SetRightBorderDist( const sal_uInt16 nRightDist );
|
||||
void SetLeftBorderDist( const sal_uInt16 nLeftDist );
|
||||
void SetBorderDist(const sal_uInt16 nTopDist,
|
||||
const sal_uInt16 nBottomDist,
|
||||
const sal_uInt16 nRightDist,
|
||||
const sal_uInt16 nLeftDist);
|
||||
|
||||
sal_uInt16 GetTopBorderDist() const { return m_nTopBorderDist; }
|
||||
sal_uInt16 GetBottomBorderDist() const { return m_nBottomBorderDist; }
|
||||
@@ -908,6 +915,14 @@ inline void SwFont::SetLeftBorderDist( const sal_uInt16 nLeftDist )
|
||||
m_aSub[SwFontScript::Latin].m_nFontCacheId = m_aSub[SwFontScript::CJK].m_nFontCacheId = m_aSub[SwFontScript::CTL].m_nFontCacheId = nullptr;
|
||||
}
|
||||
|
||||
inline void SwFont::SetBorderDist(const sal_uInt16 nTopDist, const sal_uInt16 nBottomDist, const sal_uInt16 nRightDist, const sal_uInt16 nLeftDist)
|
||||
{
|
||||
SetTopBorderDist(nTopDist);
|
||||
SetBottomBorderDist(nBottomDist);
|
||||
SetRightBorderDist(nRightDist);
|
||||
SetLeftBorderDist(nLeftDist);
|
||||
}
|
||||
|
||||
inline sal_uInt16 SwFont::GetTopBorderSpace() const
|
||||
{
|
||||
sal_uInt16 nRet = 0;
|
||||
|
||||
@@ -71,6 +71,23 @@ void SwFont::SetBackColor( std::optional<Color> xNewColor )
|
||||
m_aSub[SwFontScript::Latin].m_nFontCacheId = m_aSub[SwFontScript::CJK].m_nFontCacheId = m_aSub[SwFontScript::CTL].m_nFontCacheId = nullptr;
|
||||
}
|
||||
|
||||
void SwFont::SetBorder(const SvxBoxItem* pBoxItem)
|
||||
{
|
||||
if(!pBoxItem) return;
|
||||
SetTopBorder(pBoxItem->GetTop());
|
||||
SetBottomBorder(pBoxItem->GetBottom());
|
||||
SetRightBorder(pBoxItem->GetRight());
|
||||
SetLeftBorder(pBoxItem->GetLeft());
|
||||
}
|
||||
|
||||
void SwFont::ClearBorders()
|
||||
{
|
||||
SetTopBorder(nullptr);
|
||||
SetBottomBorder(nullptr);
|
||||
SetRightBorder(nullptr);
|
||||
SetLeftBorder(nullptr);
|
||||
}
|
||||
|
||||
void SwFont::SetTopBorder( const editeng::SvxBorderLine* pTopBorder )
|
||||
{
|
||||
if( pTopBorder )
|
||||
@@ -648,14 +665,11 @@ void SwFont::SetDiffFnt( const SfxItemSet *pAttrSet,
|
||||
SetHighlightColor(pItem->GetColor());
|
||||
if( const SvxBoxItem* pBoxItem = pAttrSet->GetItemIfSet( RES_CHRATR_BOX ) )
|
||||
{
|
||||
SetTopBorder(pBoxItem->GetTop());
|
||||
SetBottomBorder(pBoxItem->GetBottom());
|
||||
SetRightBorder(pBoxItem->GetRight());
|
||||
SetLeftBorder(pBoxItem->GetLeft());
|
||||
SetTopBorderDist(pBoxItem->GetDistance(SvxBoxItemLine::TOP));
|
||||
SetBottomBorderDist(pBoxItem->GetDistance(SvxBoxItemLine::BOTTOM));
|
||||
SetRightBorderDist(pBoxItem->GetDistance(SvxBoxItemLine::RIGHT));
|
||||
SetLeftBorderDist(pBoxItem->GetDistance(SvxBoxItemLine::LEFT));
|
||||
SetBorder(pBoxItem);
|
||||
SetBorderDist(pBoxItem->GetDistance(SvxBoxItemLine::TOP),
|
||||
pBoxItem->GetDistance(SvxBoxItemLine::BOTTOM),
|
||||
pBoxItem->GetDistance(SvxBoxItemLine::RIGHT),
|
||||
pBoxItem->GetDistance(SvxBoxItemLine::LEFT));
|
||||
}
|
||||
if( const SvxShadowItem* pShadowItem = pAttrSet->GetItemIfSet( RES_CHRATR_SHADOW ) )
|
||||
{
|
||||
@@ -818,25 +832,16 @@ SwFont::SwFont( const SwAttrSet* pAttrSet,
|
||||
SetHighlightColor(COL_TRANSPARENT);
|
||||
if( const SvxBoxItem* pBoxItem = pAttrSet->GetItemIfSet( RES_CHRATR_BOX ) )
|
||||
{
|
||||
SetTopBorder(pBoxItem->GetTop());
|
||||
SetBottomBorder(pBoxItem->GetBottom());
|
||||
SetRightBorder(pBoxItem->GetRight());
|
||||
SetLeftBorder(pBoxItem->GetLeft());
|
||||
SetTopBorderDist(pBoxItem->GetDistance(SvxBoxItemLine::TOP));
|
||||
SetBottomBorderDist(pBoxItem->GetDistance(SvxBoxItemLine::BOTTOM));
|
||||
SetRightBorderDist(pBoxItem->GetDistance(SvxBoxItemLine::RIGHT));
|
||||
SetLeftBorderDist(pBoxItem->GetDistance(SvxBoxItemLine::LEFT));
|
||||
SetBorder(pBoxItem);
|
||||
SetBorderDist(pBoxItem->GetDistance(SvxBoxItemLine::TOP),
|
||||
pBoxItem->GetDistance(SvxBoxItemLine::BOTTOM),
|
||||
pBoxItem->GetDistance(SvxBoxItemLine::RIGHT),
|
||||
pBoxItem->GetDistance(SvxBoxItemLine::LEFT));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetTopBorder(nullptr);
|
||||
SetBottomBorder(nullptr);
|
||||
SetRightBorder(nullptr);
|
||||
SetLeftBorder(nullptr);
|
||||
SetTopBorderDist(0);
|
||||
SetBottomBorderDist(0);
|
||||
SetRightBorderDist(0);
|
||||
SetLeftBorderDist(0);
|
||||
ClearBorders();
|
||||
SetBorderDist(0,0,0,0);
|
||||
}
|
||||
|
||||
if( const SvxShadowItem* pShadowItem = pAttrSet->GetItemIfSet( RES_CHRATR_SHADOW ) )
|
||||
|
||||
Reference in New Issue
Block a user