summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-10-22 09:32:39 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-10-22 12:54:08 +0200
commite5e0cc68f70d35e1849aeaf21c0ce68afd6a1f59 (patch)
treeb4bce95d15819feb2c38e183c3ccdcbab76db60c /sw
parentfd56d5fd409c832886bf42a020322e69b6a35d9e (diff)
pvs-studio: V794 The assignment operator should be protected
Change-Id: Ia443a0e61a091d877c8da26bf7d45bf4261f8669 Reviewed-on: https://gerrit.libreoffice.org/62166 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/layout/atrfrm.cxx44
-rw-r--r--sw/source/core/txtnode/swfont.cxx59
2 files changed, 56 insertions, 47 deletions
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index d3af82b5315a..d7b894c092c0 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -827,19 +827,22 @@ SwFormatCol::~SwFormatCol() {}
SwFormatCol& SwFormatCol::operator=( const SwFormatCol& rCpy )
{
- m_eLineStyle = rCpy.m_eLineStyle;
- m_nLineWidth = rCpy.m_nLineWidth;
- m_aLineColor = rCpy.m_aLineColor;
- m_nLineHeight = rCpy.GetLineHeight();
- m_eAdj = rCpy.GetLineAdj();
- m_nWidth = rCpy.GetWishWidth();
- m_aWidthAdjustValue = rCpy.m_aWidthAdjustValue;
- m_bOrtho = rCpy.IsOrtho();
-
- m_aColumns.clear();
- for ( sal_uInt16 i = 0; i < rCpy.GetNumCols(); ++i )
+ if (this != &rCpy)
{
- m_aColumns.emplace_back(rCpy.GetColumns()[i] );
+ m_eLineStyle = rCpy.m_eLineStyle;
+ m_nLineWidth = rCpy.m_nLineWidth;
+ m_aLineColor = rCpy.m_aLineColor;
+ m_nLineHeight = rCpy.GetLineHeight();
+ m_eAdj = rCpy.GetLineAdj();
+ m_nWidth = rCpy.GetWishWidth();
+ m_aWidthAdjustValue = rCpy.m_aWidthAdjustValue;
+ m_bOrtho = rCpy.IsOrtho();
+
+ m_aColumns.clear();
+ for ( sal_uInt16 i = 0; i < rCpy.GetNumCols(); ++i )
+ {
+ m_aColumns.emplace_back(rCpy.GetColumns()[i] );
+ }
}
return *this;
}
@@ -1537,14 +1540,17 @@ void SwFormatAnchor::SetAnchor( const SwPosition *pPos )
SwFormatAnchor& SwFormatAnchor::operator=(const SwFormatAnchor& rAnchor)
{
- m_eAnchorId = rAnchor.GetAnchorId();
- m_nPageNumber = rAnchor.GetPageNum();
- // OD 2004-05-05 #i28701# - get always new increased order number
- m_nOrder = ++m_nOrderCounter;
+ if (this != &rAnchor)
+ {
+ m_eAnchorId = rAnchor.GetAnchorId();
+ m_nPageNumber = rAnchor.GetPageNum();
+ // OD 2004-05-05 #i28701# - get always new increased order number
+ m_nOrder = ++m_nOrderCounter;
- m_pContentAnchor.reset( (rAnchor.GetContentAnchor())
- ? new SwPosition(*(rAnchor.GetContentAnchor()))
- : nullptr );
+ m_pContentAnchor.reset( (rAnchor.GetContentAnchor())
+ ? new SwPosition(*(rAnchor.GetContentAnchor()))
+ : nullptr );
+ }
return *this;
}
diff --git a/sw/source/core/txtnode/swfont.cxx b/sw/source/core/txtnode/swfont.cxx
index fad6b64db17e..8683e97e82e0 100644
--- a/sw/source/core/txtnode/swfont.cxx
+++ b/sw/source/core/txtnode/swfont.cxx
@@ -889,34 +889,37 @@ SwFont::~SwFont()
SwFont& SwFont::operator=( const SwFont &rFont )
{
- m_aSub[SwFontScript::Latin] = rFont.m_aSub[SwFontScript::Latin];
- m_aSub[SwFontScript::CJK] = rFont.m_aSub[SwFontScript::CJK];
- m_aSub[SwFontScript::CTL] = rFont.m_aSub[SwFontScript::CTL];
- m_nActual = rFont.m_nActual;
- m_pBackColor.reset( rFont.m_pBackColor ? new Color( *rFont.m_pBackColor ) : nullptr );
- m_aHighlightColor = rFont.m_aHighlightColor;
- m_aTopBorder = rFont.m_aTopBorder;
- m_aBottomBorder = rFont.m_aBottomBorder;
- m_aRightBorder = rFont.m_aRightBorder;
- m_aLeftBorder = rFont.m_aLeftBorder;
- m_nTopBorderDist = rFont.m_nTopBorderDist;
- m_nBottomBorderDist = rFont.m_nBottomBorderDist;
- m_nRightBorderDist = rFont.m_nRightBorderDist;
- m_nLeftBorderDist = rFont.m_nLeftBorderDist;
- m_aShadowColor = rFont.m_aShadowColor;
- m_nShadowWidth = rFont.m_nShadowWidth;
- m_aShadowLocation = rFont.m_aShadowLocation;
- m_aUnderColor = rFont.GetUnderColor();
- m_aOverColor = rFont.GetOverColor();
- m_nToxCount = 0;
- m_nRefCount = 0;
- m_nMetaCount = 0;
- m_nInputFieldCount = 0;
- m_bFontChg = rFont.m_bFontChg;
- m_bOrgChg = rFont.m_bOrgChg;
- m_bPaintBlank = rFont.m_bPaintBlank;
- m_bGreyWave = rFont.m_bGreyWave;
- m_bBlink = rFont.m_bBlink;
+ if (this != &rFont)
+ {
+ m_aSub[SwFontScript::Latin] = rFont.m_aSub[SwFontScript::Latin];
+ m_aSub[SwFontScript::CJK] = rFont.m_aSub[SwFontScript::CJK];
+ m_aSub[SwFontScript::CTL] = rFont.m_aSub[SwFontScript::CTL];
+ m_nActual = rFont.m_nActual;
+ m_pBackColor.reset( rFont.m_pBackColor ? new Color( *rFont.m_pBackColor ) : nullptr );
+ m_aHighlightColor = rFont.m_aHighlightColor;
+ m_aTopBorder = rFont.m_aTopBorder;
+ m_aBottomBorder = rFont.m_aBottomBorder;
+ m_aRightBorder = rFont.m_aRightBorder;
+ m_aLeftBorder = rFont.m_aLeftBorder;
+ m_nTopBorderDist = rFont.m_nTopBorderDist;
+ m_nBottomBorderDist = rFont.m_nBottomBorderDist;
+ m_nRightBorderDist = rFont.m_nRightBorderDist;
+ m_nLeftBorderDist = rFont.m_nLeftBorderDist;
+ m_aShadowColor = rFont.m_aShadowColor;
+ m_nShadowWidth = rFont.m_nShadowWidth;
+ m_aShadowLocation = rFont.m_aShadowLocation;
+ m_aUnderColor = rFont.GetUnderColor();
+ m_aOverColor = rFont.GetOverColor();
+ m_nToxCount = 0;
+ m_nRefCount = 0;
+ m_nMetaCount = 0;
+ m_nInputFieldCount = 0;
+ m_bFontChg = rFont.m_bFontChg;
+ m_bOrgChg = rFont.m_bOrgChg;
+ m_bPaintBlank = rFont.m_bPaintBlank;
+ m_bGreyWave = rFont.m_bGreyWave;
+ m_bBlink = rFont.m_bBlink;
+ }
return *this;
}