summaryrefslogtreecommitdiff
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
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>
-rw-r--r--basic/source/sbx/sbxvar.cxx19
-rw-r--r--cppuhelper/source/unourl.cxx18
-rw-r--r--editeng/source/items/frmitems.cxx22
-rw-r--r--editeng/source/items/numitem.cxx23
-rw-r--r--filter/source/graphicfilter/icgm/bundles.cxx43
-rw-r--r--include/canvas/vclwrapper.hxx20
-rw-r--r--sc/source/core/data/dpobject.cxx44
-rw-r--r--sc/source/core/data/global2.cxx33
-rw-r--r--sc/source/core/data/sheetevents.cxx13
-rw-r--r--sc/source/core/tool/dbdata.cxx86
-rw-r--r--sc/source/core/tool/queryparam.cxx26
-rw-r--r--sc/source/ui/app/inputhdl.cxx18
-rw-r--r--sc/source/ui/undo/undostyl.cxx10
-rw-r--r--sd/source/ui/app/optsitem.cxx13
-rw-r--r--shell/source/win32/shlxthandler/ooofilt/propspec.cxx11
-rw-r--r--svl/source/items/macitem.cxx7
-rw-r--r--svl/source/passwordcontainer/passwordcontainer.hxx12
-rw-r--r--svtools/source/misc/imap.cxx44
-rw-r--r--svx/source/form/dataaccessdescriptor.cxx3
-rw-r--r--svx/source/svdraw/svdlayer.cxx15
-rw-r--r--svx/source/svdraw/svdmark.cxx27
-rw-r--r--svx/source/xoutdev/xexch.cxx14
-rw-r--r--sw/source/core/layout/atrfrm.cxx44
-rw-r--r--sw/source/core/txtnode/swfont.cxx59
-rw-r--r--vcl/source/gdi/animate.cxx22
-rw-r--r--vcl/source/gdi/regionband.cxx34
26 files changed, 374 insertions, 306 deletions
diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx
index 3759da581907..ec67be889e3a 100644
--- a/basic/source/sbx/sbxvar.cxx
+++ b/basic/source/sbx/sbxvar.cxx
@@ -333,17 +333,20 @@ sal_uInt16 SbxVariable::MakeHashCode( const OUString& rName )
SbxVariable& SbxVariable::operator=( const SbxVariable& r )
{
- SbxValue::operator=( r );
- mpImpl.reset();
- if( r.mpImpl != nullptr )
+ if (this != &r)
{
- mpImpl.reset( new SbxVariableImpl( *r.mpImpl ) );
-#if HAVE_FEATURE_SCRIPTING
- if( mpImpl->m_xComListener.is() )
+ SbxValue::operator=( r );
+ mpImpl.reset();
+ if( r.mpImpl != nullptr )
{
- registerComListenerVariableForBasic( this, mpImpl->m_pComListenerParentBasic );
- }
+ mpImpl.reset( new SbxVariableImpl( *r.mpImpl ) );
+#if HAVE_FEATURE_SCRIPTING
+ if( mpImpl->m_xComListener.is() )
+ {
+ registerComListenerVariableForBasic( this, mpImpl->m_pComListenerParentBasic );
+ }
#endif
+ }
}
return *this;
}
diff --git a/cppuhelper/source/unourl.cxx b/cppuhelper/source/unourl.cxx
index 22250e5568eb..f131a81f68a6 100644
--- a/cppuhelper/source/unourl.cxx
+++ b/cppuhelper/source/unourl.cxx
@@ -140,9 +140,12 @@ UnoUrlDescriptor::~UnoUrlDescriptor()
UnoUrlDescriptor & UnoUrlDescriptor::operator =(UnoUrlDescriptor const & rOther)
{
- std::unique_ptr<Impl> newImpl(rOther.m_pImpl->clone());
- delete m_pImpl;
- m_pImpl = newImpl.release();
+ if (this != &rOther)
+ {
+ std::unique_ptr<Impl> newImpl(rOther.m_pImpl->clone());
+ delete m_pImpl;
+ m_pImpl = newImpl.release();
+ }
return *this;
}
@@ -237,9 +240,12 @@ UnoUrl::~UnoUrl()
UnoUrl & UnoUrl::operator =(UnoUrl const & rOther)
{
- std::unique_ptr<Impl> newImpl(rOther.m_pImpl->clone());
- delete m_pImpl;
- m_pImpl = newImpl.release();
+ if (this != &rOther)
+ {
+ std::unique_ptr<Impl> newImpl(rOther.m_pImpl->clone());
+ delete m_pImpl;
+ m_pImpl = newImpl.release();
+ }
return *this;
}
diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx
index 910de8dcd434..976084b13b3c 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -2262,26 +2262,26 @@ SvxBoxInfoItem::SvxBoxInfoItem( const SvxBoxInfoItem& rCpy ) :
{
}
-
SvxBoxInfoItem::~SvxBoxInfoItem()
{
}
-
SvxBoxInfoItem &SvxBoxInfoItem::operator=( const SvxBoxInfoItem& rCpy )
{
- pHori.reset( rCpy.GetHori() ? new SvxBorderLine( *rCpy.GetHori() ) : nullptr );
- pVert.reset( rCpy.GetVert() ? new SvxBorderLine( *rCpy.GetVert() ) : nullptr );
- mbEnableHor = rCpy.mbEnableHor;
- mbEnableVer = rCpy.mbEnableVer;
- bDist = rCpy.IsDist();
- bMinDist = rCpy.IsMinDist();
- nValidFlags = rCpy.nValidFlags;
- nDefDist = rCpy.GetDefDist();
+ if (this != &rCpy)
+ {
+ pHori.reset( rCpy.GetHori() ? new SvxBorderLine( *rCpy.GetHori() ) : nullptr );
+ pVert.reset( rCpy.GetVert() ? new SvxBorderLine( *rCpy.GetVert() ) : nullptr );
+ mbEnableHor = rCpy.mbEnableHor;
+ mbEnableVer = rCpy.mbEnableVer;
+ bDist = rCpy.IsDist();
+ bMinDist = rCpy.IsMinDist();
+ nValidFlags = rCpy.nValidFlags;
+ nDefDist = rCpy.GetDefDist();
+ }
return *this;
}
-
bool SvxBoxInfoItem::operator==( const SfxPoolItem& rAttr ) const
{
assert(SfxPoolItem::operator==(rAttr));
diff --git a/editeng/source/items/numitem.cxx b/editeng/source/items/numitem.cxx
index b674d2685246..d96fa16b0901 100644
--- a/editeng/source/items/numitem.cxx
+++ b/editeng/source/items/numitem.cxx
@@ -718,17 +718,20 @@ SvxNumRule::~SvxNumRule()
SvxNumRule& SvxNumRule::operator=( const SvxNumRule& rCopy )
{
- nLevelCount = rCopy.nLevelCount;
- nFeatureFlags = rCopy.nFeatureFlags;
- bContinuousNumbering = rCopy.bContinuousNumbering;
- eNumberingType = rCopy.eNumberingType;
- for(sal_uInt16 i = 0; i < SVX_MAX_NUM; i++)
+ if (this != &rCopy)
{
- if(rCopy.aFmts[i])
- aFmts[i].reset( new SvxNumberFormat(*rCopy.aFmts[i]) );
- else
- aFmts[i].reset();
- aFmtsSet[i] = rCopy.aFmtsSet[i];
+ nLevelCount = rCopy.nLevelCount;
+ nFeatureFlags = rCopy.nFeatureFlags;
+ bContinuousNumbering = rCopy.bContinuousNumbering;
+ eNumberingType = rCopy.eNumberingType;
+ for(sal_uInt16 i = 0; i < SVX_MAX_NUM; i++)
+ {
+ if(rCopy.aFmts[i])
+ aFmts[i].reset( new SvxNumberFormat(*rCopy.aFmts[i]) );
+ else
+ aFmts[i].reset();
+ aFmtsSet[i] = rCopy.aFmtsSet[i];
+ }
}
return *this;
}
diff --git a/filter/source/graphicfilter/icgm/bundles.cxx b/filter/source/graphicfilter/icgm/bundles.cxx
index 8cce817c3800..c1b6277c88c1 100644
--- a/filter/source/graphicfilter/icgm/bundles.cxx
+++ b/filter/source/graphicfilter/icgm/bundles.cxx
@@ -51,36 +51,37 @@ CGMFList::~CGMFList()
ImplDeleteList();
}
-
CGMFList& CGMFList::operator=( const CGMFList& rSource )
{
- ImplDeleteList();
- nFontsAvailable = rSource.nFontsAvailable;
- nFontNameCount = rSource.nFontNameCount;
- nCharSetCount = rSource.nCharSetCount;
- for (auto const & pPtr : rSource.aFontEntryList)
+ if (this != &rSource)
{
- std::unique_ptr<FontEntry> pCFontEntry(new FontEntry);
- if ( pPtr->pFontName )
+ ImplDeleteList();
+ nFontsAvailable = rSource.nFontsAvailable;
+ nFontNameCount = rSource.nFontNameCount;
+ nCharSetCount = rSource.nCharSetCount;
+ for (auto const & pPtr : rSource.aFontEntryList)
{
- sal_uInt32 nSize = strlen( reinterpret_cast<char*>(pPtr->pFontName.get()) ) + 1;
- pCFontEntry->pFontName.reset( new sal_Int8[ nSize ] );
- memcpy( pCFontEntry->pFontName.get(), pPtr->pFontName.get(), nSize );
+ std::unique_ptr<FontEntry> pCFontEntry(new FontEntry);
+ if ( pPtr->pFontName )
+ {
+ sal_uInt32 nSize = strlen( reinterpret_cast<char*>(pPtr->pFontName.get()) ) + 1;
+ pCFontEntry->pFontName.reset( new sal_Int8[ nSize ] );
+ memcpy( pCFontEntry->pFontName.get(), pPtr->pFontName.get(), nSize );
+ }
+ if ( pPtr->pCharSetValue )
+ {
+ sal_uInt32 nSize = strlen( reinterpret_cast<char*>(pPtr->pCharSetValue.get()) ) + 1;
+ pCFontEntry->pCharSetValue.reset( new sal_Int8[ nSize ] );
+ memcpy( pCFontEntry->pCharSetValue.get(), pPtr->pCharSetValue.get(), nSize );
+ }
+ pCFontEntry->eCharSetType = pPtr->eCharSetType;
+ pCFontEntry->nFontType = pPtr->nFontType;
+ aFontEntryList.push_back( std::move(pCFontEntry) );
}
- if ( pPtr->pCharSetValue )
- {
- sal_uInt32 nSize = strlen( reinterpret_cast<char*>(pPtr->pCharSetValue.get()) ) + 1;
- pCFontEntry->pCharSetValue.reset( new sal_Int8[ nSize ] );
- memcpy( pCFontEntry->pCharSetValue.get(), pPtr->pCharSetValue.get(), nSize );
- }
- pCFontEntry->eCharSetType = pPtr->eCharSetType;
- pCFontEntry->nFontType = pPtr->nFontType;
- aFontEntryList.push_back( std::move(pCFontEntry) );
}
return *this;
}
-
FontEntry* CGMFList::GetFontEntry( sal_uInt32 nIndex )
{
sal_uInt32 nInd = nIndex;
diff --git a/include/canvas/vclwrapper.hxx b/include/canvas/vclwrapper.hxx
index 77cf8b705e11..0a80cb282986 100644
--- a/include/canvas/vclwrapper.hxx
+++ b/include/canvas/vclwrapper.hxx
@@ -95,17 +95,19 @@ namespace canvas
// assignment to wrappee
VCLObject& operator=( const VCLObject& rhs )
{
- if( mpWrappee )
+ if (this != &rhs)
{
- if( rhs.mpWrappee )
- *mpWrappee = *rhs.mpWrappee;
+ if( mpWrappee )
+ {
+ if( rhs.mpWrappee )
+ *mpWrappee = *rhs.mpWrappee;
+ }
+ else
+ {
+ if( rhs.mpWrappee )
+ mpWrappee = new Wrappee( *rhs.mpWrappee );
+ }
}
- else
- {
- if( rhs.mpWrappee )
- mpWrappee = new Wrappee( *rhs.mpWrappee );
- }
-
return *this;
}
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 8d10bb32f9c6..a891b0938259 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -348,27 +348,29 @@ ScDPObject::~ScDPObject()
ScDPObject& ScDPObject::operator= (const ScDPObject& r)
{
- Clear();
-
- pDoc = r.pDoc;
- aTableName = r.aTableName;
- aTableTag = r.aTableTag;
- aOutRange = r.aOutRange;
- nHeaderRows = r.nHeaderRows;
- mbHeaderLayout = r.mbHeaderLayout;
- bAllowMove = false;
- bSettingsChanged = false;
- mbEnableGetPivotData = r.mbEnableGetPivotData;
-
- if (r.pSaveData)
- pSaveData.reset( new ScDPSaveData(*r.pSaveData) );
- if (r.pSheetDesc)
- pSheetDesc.reset( new ScSheetSourceDesc(*r.pSheetDesc) );
- if (r.pImpDesc)
- pImpDesc.reset( new ScImportSourceDesc(*r.pImpDesc) );
- if (r.pServDesc)
- pServDesc.reset( new ScDPServiceDesc(*r.pServDesc) );
-
+ if (this != &r)
+ {
+ Clear();
+
+ pDoc = r.pDoc;
+ aTableName = r.aTableName;
+ aTableTag = r.aTableTag;
+ aOutRange = r.aOutRange;
+ nHeaderRows = r.nHeaderRows;
+ mbHeaderLayout = r.mbHeaderLayout;
+ bAllowMove = false;
+ bSettingsChanged = false;
+ mbEnableGetPivotData = r.mbEnableGetPivotData;
+
+ if (r.pSaveData)
+ pSaveData.reset( new ScDPSaveData(*r.pSaveData) );
+ if (r.pSheetDesc)
+ pSheetDesc.reset( new ScSheetSourceDesc(*r.pSheetDesc) );
+ if (r.pImpDesc)
+ pImpDesc.reset( new ScImportSourceDesc(*r.pImpDesc) );
+ if (r.pServDesc)
+ pServDesc.reset( new ScDPServiceDesc(*r.pServDesc) );
+ }
return *this;
}
diff --git a/sc/source/core/data/global2.cxx b/sc/source/core/data/global2.cxx
index b89daafb5881..c35fce66b8e9 100644
--- a/sc/source/core/data/global2.cxx
+++ b/sc/source/core/data/global2.cxx
@@ -139,23 +139,26 @@ void ScConsolidateParam::Clear()
ScConsolidateParam& ScConsolidateParam::operator=( const ScConsolidateParam& r )
{
- nCol = r.nCol;
- nRow = r.nRow;
- nTab = r.nTab;
- bByCol = r.bByCol;
- bByRow = r.bByRow;
- bReferenceData = r.bReferenceData;
- eFunction = r.eFunction;
- nDataAreaCount = r.nDataAreaCount;
- if ( r.nDataAreaCount > 0 )
+ if (this != &r)
{
- nDataAreaCount = r.nDataAreaCount;
- pDataAreas.reset( new ScArea[nDataAreaCount] );
- for ( sal_uInt16 i=0; i<nDataAreaCount; i++ )
- pDataAreas[i] = r.pDataAreas[i];
+ nCol = r.nCol;
+ nRow = r.nRow;
+ nTab = r.nTab;
+ bByCol = r.bByCol;
+ bByRow = r.bByRow;
+ bReferenceData = r.bReferenceData;
+ eFunction = r.eFunction;
+ nDataAreaCount = r.nDataAreaCount;
+ if ( r.nDataAreaCount > 0 )
+ {
+ nDataAreaCount = r.nDataAreaCount;
+ pDataAreas.reset( new ScArea[nDataAreaCount] );
+ for ( sal_uInt16 i=0; i<nDataAreaCount; i++ )
+ pDataAreas[i] = r.pDataAreas[i];
+ }
+ else
+ pDataAreas.reset();
}
- else
- pDataAreas.reset();
return *this;
}
diff --git a/sc/source/core/data/sheetevents.cxx b/sc/source/core/data/sheetevents.cxx
index f885d6cac530..82853cc27793 100644
--- a/sc/source/core/data/sheetevents.cxx
+++ b/sc/source/core/data/sheetevents.cxx
@@ -83,12 +83,15 @@ ScSheetEvents::ScSheetEvents(const ScSheetEvents& rOther)
ScSheetEvents& ScSheetEvents::operator=(const ScSheetEvents& rOther)
{
- Clear();
- if (rOther.mpScriptNames)
+ if (this != &rOther)
{
- mpScriptNames.reset( new boost::optional<OUString>[COUNT] );
- for (sal_Int32 nEvent=0; nEvent<COUNT; ++nEvent)
- mpScriptNames[nEvent] = rOther.mpScriptNames[nEvent];
+ Clear();
+ if (rOther.mpScriptNames)
+ {
+ mpScriptNames.reset( new boost::optional<OUString>[COUNT] );
+ for (sal_Int32 nEvent=0; nEvent<COUNT; ++nEvent)
+ mpScriptNames[nEvent] = rOther.mpScriptNames[nEvent];
+ }
}
return *this;
}
diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index 17533332d90b..92d6cee222ff 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -158,51 +158,53 @@ ScDBData::ScDBData( const OUString& rName, const ScDBData& rData ) :
ScDBData& ScDBData::operator= (const ScDBData& rData)
{
- // Don't modify the name. The name is not mutable as it is used as a key
- // in the container to keep the db ranges sorted by the name.
-
- bool bHeaderRangeDiffers = (nTable != rData.nTable || nStartCol != rData.nStartCol ||
- nEndCol != rData.nEndCol || nStartRow != rData.nStartRow);
- bool bNeedsListening = ((bHasHeader && bHeaderRangeDiffers) || (!bHasHeader && rData.bHasHeader));
- if (bHasHeader && (!rData.bHasHeader || bHeaderRangeDiffers))
+ if (this != &rData)
{
- EndTableColumnNamesListener();
- }
- ScRefreshTimer::operator=( rData );
- mpSortParam.reset(new ScSortParam(*rData.mpSortParam));
- mpQueryParam.reset(new ScQueryParam(*rData.mpQueryParam));
- mpSubTotal.reset(new ScSubTotalParam(*rData.mpSubTotal));
- mpImportParam.reset(new ScImportParam(*rData.mpImportParam));
- // Keep mpContainer.
- nTable = rData.nTable;
- nStartCol = rData.nStartCol;
- nStartRow = rData.nStartRow;
- nEndCol = rData.nEndCol;
- nEndRow = rData.nEndRow;
- bByRow = rData.bByRow;
- bHasHeader = rData.bHasHeader;
- bHasTotals = rData.bHasTotals;
- bDoSize = rData.bDoSize;
- bKeepFmt = rData.bKeepFmt;
- bStripData = rData.bStripData;
- bIsAdvanced = rData.bIsAdvanced;
- aAdvSource = rData.aAdvSource;
- bDBSelection = rData.bDBSelection;
- nIndex = rData.nIndex;
- bAutoFilter = rData.bAutoFilter;
- nFilteredRowCount = rData.nFilteredRowCount;
-
- if (bHeaderRangeDiffers)
- InvalidateTableColumnNames( true);
- else
- {
- maTableColumnNames = rData.maTableColumnNames;
- mbTableColumnNamesDirty = rData.mbTableColumnNamesDirty;
- }
+ // Don't modify the name. The name is not mutable as it is used as a key
+ // in the container to keep the db ranges sorted by the name.
- if (bNeedsListening)
- StartTableColumnNamesListener();
+ bool bHeaderRangeDiffers = (nTable != rData.nTable || nStartCol != rData.nStartCol ||
+ nEndCol != rData.nEndCol || nStartRow != rData.nStartRow);
+ bool bNeedsListening = ((bHasHeader && bHeaderRangeDiffers) || (!bHasHeader && rData.bHasHeader));
+ if (bHasHeader && (!rData.bHasHeader || bHeaderRangeDiffers))
+ {
+ EndTableColumnNamesListener();
+ }
+ ScRefreshTimer::operator=( rData );
+ mpSortParam.reset(new ScSortParam(*rData.mpSortParam));
+ mpQueryParam.reset(new ScQueryParam(*rData.mpQueryParam));
+ mpSubTotal.reset(new ScSubTotalParam(*rData.mpSubTotal));
+ mpImportParam.reset(new ScImportParam(*rData.mpImportParam));
+ // Keep mpContainer.
+ nTable = rData.nTable;
+ nStartCol = rData.nStartCol;
+ nStartRow = rData.nStartRow;
+ nEndCol = rData.nEndCol;
+ nEndRow = rData.nEndRow;
+ bByRow = rData.bByRow;
+ bHasHeader = rData.bHasHeader;
+ bHasTotals = rData.bHasTotals;
+ bDoSize = rData.bDoSize;
+ bKeepFmt = rData.bKeepFmt;
+ bStripData = rData.bStripData;
+ bIsAdvanced = rData.bIsAdvanced;
+ aAdvSource = rData.aAdvSource;
+ bDBSelection = rData.bDBSelection;
+ nIndex = rData.nIndex;
+ bAutoFilter = rData.bAutoFilter;
+ nFilteredRowCount = rData.nFilteredRowCount;
+
+ if (bHeaderRangeDiffers)
+ InvalidateTableColumnNames( true);
+ else
+ {
+ maTableColumnNames = rData.maTableColumnNames;
+ mbTableColumnNamesDirty = rData.mbTableColumnNamesDirty;
+ }
+ if (bNeedsListening)
+ StartTableColumnNamesListener();
+ }
return *this;
}
diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx
index 17d05c5e8914..3beff5d31e76 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -89,20 +89,22 @@ ScQueryParamBase::ScQueryParamBase(const ScQueryParamBase& r) :
ScQueryParamBase& ScQueryParamBase::operator=(const ScQueryParamBase& r)
{
- eSearchType = r.eSearchType;
- bHasHeader = r.bHasHeader;
- bByRow = r.bByRow;
- bInplace = r.bInplace;
- bCaseSens = r.bCaseSens;
- bDuplicate = r.bDuplicate;
- mbRangeLookup = r.mbRangeLookup;
-
- m_Entries.clear();
- for (auto const& it : r.m_Entries)
+ if (this != &r)
{
- m_Entries.push_back(o3tl::make_unique<ScQueryEntry>(*it));
+ eSearchType = r.eSearchType;
+ bHasHeader = r.bHasHeader;
+ bByRow = r.bByRow;
+ bInplace = r.bInplace;
+ bCaseSens = r.bCaseSens;
+ bDuplicate = r.bDuplicate;
+ mbRangeLookup = r.mbRangeLookup;
+
+ m_Entries.clear();
+ for (auto const& it : r.m_Entries)
+ {
+ m_Entries.push_back(o3tl::make_unique<ScQueryEntry>(*it));
+ }
}
-
return *this;
}
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 34e4cd1732bb..ce7f9c301d9e 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -4067,14 +4067,16 @@ bool ScInputHdlState::operator==( const ScInputHdlState& r ) const
ScInputHdlState& ScInputHdlState::operator=( const ScInputHdlState& r )
{
- aCursorPos = r.aCursorPos;
- aStartPos = r.aStartPos;
- aEndPos = r.aEndPos;
- aString = r.aString;
- pEditData.reset();
- if (r.pEditData)
- pEditData = r.pEditData->Clone();
-
+ if (this != &r)
+ {
+ aCursorPos = r.aCursorPos;
+ aStartPos = r.aStartPos;
+ aEndPos = r.aEndPos;
+ aString = r.aString;
+ pEditData.reset();
+ if (r.pEditData)
+ pEditData = r.pEditData->Clone();
+ }
return *this;
}
diff --git a/sc/source/ui/undo/undostyl.cxx b/sc/source/ui/undo/undostyl.cxx
index 9d1363faba60..62b19d45c6ce 100644
--- a/sc/source/ui/undo/undostyl.cxx
+++ b/sc/source/ui/undo/undostyl.cxx
@@ -46,10 +46,12 @@ ScStyleSaveData::ScStyleSaveData( const ScStyleSaveData& rOther ) :
ScStyleSaveData& ScStyleSaveData::operator=( const ScStyleSaveData& rOther )
{
- aName = rOther.aName;
- aParent = rOther.aParent;
- xItems.reset(rOther.xItems ? new SfxItemSet(*rOther.xItems) : nullptr);
-
+ if (this != &rOther)
+ {
+ aName = rOther.aName;
+ aParent = rOther.aParent;
+ xItems.reset(rOther.xItems ? new SfxItemSet(*rOther.xItems) : nullptr);
+ }
return *this;
}
diff --git a/sd/source/ui/app/optsitem.cxx b/sd/source/ui/app/optsitem.cxx
index f2c2414fdb46..1bded3fdac06 100644
--- a/sd/source/ui/app/optsitem.cxx
+++ b/sd/source/ui/app/optsitem.cxx
@@ -89,11 +89,14 @@ SdOptionsGeneric::SdOptionsGeneric(SdOptionsGeneric const & rSource)
SdOptionsGeneric& SdOptionsGeneric::operator=(SdOptionsGeneric const & rSource)
{
- maSubTree = rSource.maSubTree;
- mpCfgItem.reset(rSource.mpCfgItem ? new SdOptionsItem(*rSource.mpCfgItem) : nullptr );
- mbImpress = rSource.mbImpress;
- mbInit = rSource.mbInit;
- mbEnableModify = rSource.mbEnableModify;
+ if (this != &rSource)
+ {
+ maSubTree = rSource.maSubTree;
+ mpCfgItem.reset(rSource.mpCfgItem ? new SdOptionsItem(*rSource.mpCfgItem) : nullptr );
+ mbImpress = rSource.mbImpress;
+ mbInit = rSource.mbInit;
+ mbEnableModify = rSource.mbEnableModify;
+ }
return *this;
}
diff --git a/shell/source/win32/shlxthandler/ooofilt/propspec.cxx b/shell/source/win32/shlxthandler/ooofilt/propspec.cxx
index ed44bb8b22b9..f96d363d6542 100644
--- a/shell/source/win32/shlxthandler/ooofilt/propspec.cxx
+++ b/shell/source/win32/shlxthandler/ooofilt/propspec.cxx
@@ -111,12 +111,16 @@ CFullPropSpec::CFullPropSpec( CFullPropSpec const & src ) :
CFullPropSpec & CFullPropSpec::operator=( CFullPropSpec const & Property )
{
- // Clean up.
- this->CFullPropSpec::~CFullPropSpec();
+ if (this != &Property)
+ {
+ // Clean up.
+ this->CFullPropSpec::~CFullPropSpec();
- ::new (this) CFullPropSpec( Property );
+ ::new (this) CFullPropSpec( Property );
+ }
return *this;
}
+
CFullPropSpec::~CFullPropSpec()
{
if ( _psProperty.ulKind == PRSPEC_LPWSTR &&
@@ -125,6 +129,7 @@ CFullPropSpec::~CFullPropSpec()
CoTaskMemFree( _psProperty.lpwstr );
}
}
+
void CFullPropSpec::SetProperty( PROPID pidProperty )
{
if ( _psProperty.ulKind == PRSPEC_LPWSTR &&
diff --git a/svl/source/items/macitem.cxx b/svl/source/items/macitem.cxx
index b8e56d9f0ed4..f18a575bf2df 100644
--- a/svl/source/items/macitem.cxx
+++ b/svl/source/items/macitem.cxx
@@ -68,8 +68,11 @@ SvxMacro& SvxMacro::operator=( const SvxMacro& rBase )
SvxMacroTableDtor& SvxMacroTableDtor::operator=( const SvxMacroTableDtor& rTbl )
{
- aSvxMacroTable.clear();
- aSvxMacroTable.insert(rTbl.aSvxMacroTable.begin(), rTbl.aSvxMacroTable.end());
+ if (this != &rTbl)
+ {
+ aSvxMacroTable.clear();
+ aSvxMacroTable.insert(rTbl.aSvxMacroTable.begin(), rTbl.aSvxMacroTable.end());
+ }
return *this;
}
diff --git a/svl/source/passwordcontainer/passwordcontainer.hxx b/svl/source/passwordcontainer/passwordcontainer.hxx
index 3da1e606d4d1..ad62ac0c91bd 100644
--- a/svl/source/passwordcontainer/passwordcontainer.hxx
+++ b/svl/source/passwordcontainer/passwordcontainer.hxx
@@ -96,12 +96,14 @@ public:
NamePassRecord& operator=( const NamePassRecord& aRecord )
{
- m_aName = aRecord.m_aName;
-
- m_aMemPass.clear();
- m_aPersPass.clear();
- InitArrays( aRecord.m_bHasMemPass, aRecord.m_aMemPass, aRecord.m_bHasPersPass, aRecord.m_aPersPass );
+ if (this != &aRecord)
+ {
+ m_aName = aRecord.m_aName;
+ m_aMemPass.clear();
+ m_aPersPass.clear();
+ InitArrays( aRecord.m_bHasMemPass, aRecord.m_aMemPass, aRecord.m_bHasPersPass, aRecord.m_aPersPass );
+ }
return *this;
}
diff --git a/svtools/source/misc/imap.cxx b/svtools/source/misc/imap.cxx
index 4e23ef612173..0a2739f7eb4c 100644
--- a/svtools/source/misc/imap.cxx
+++ b/svtools/source/misc/imap.cxx
@@ -624,35 +624,37 @@ void ImageMap::ClearImageMap()
ImageMap& ImageMap::operator=( const ImageMap& rImageMap )
{
- size_t nCount = rImageMap.GetIMapObjectCount();
-
- ClearImageMap();
-
- for ( size_t i = 0; i < nCount; i++ )
+ if (this != &rImageMap)
{
- IMapObject* pCopyObj = rImageMap.GetIMapObject( i );
+ size_t nCount = rImageMap.GetIMapObjectCount();
- switch( pCopyObj->GetType() )
+ ClearImageMap();
+
+ for ( size_t i = 0; i < nCount; i++ )
{
- case IMAP_OBJ_RECTANGLE:
- maList.emplace_back( new IMapRectangleObject( *static_cast<IMapRectangleObject*>(pCopyObj) ) );
- break;
+ IMapObject* pCopyObj = rImageMap.GetIMapObject( i );
- case IMAP_OBJ_CIRCLE:
- maList.emplace_back( new IMapCircleObject( *static_cast<IMapCircleObject*>(pCopyObj) ) );
- break;
+ switch( pCopyObj->GetType() )
+ {
+ case IMAP_OBJ_RECTANGLE:
+ maList.emplace_back( new IMapRectangleObject( *static_cast<IMapRectangleObject*>(pCopyObj) ) );
+ break;
- case IMAP_OBJ_POLYGON:
- maList.emplace_back( new IMapPolygonObject( *static_cast<IMapPolygonObject*>(pCopyObj) ) );
- break;
+ case IMAP_OBJ_CIRCLE:
+ maList.emplace_back( new IMapCircleObject( *static_cast<IMapCircleObject*>(pCopyObj) ) );
+ break;
- default:
- break;
- }
- }
+ case IMAP_OBJ_POLYGON:
+ maList.emplace_back( new IMapPolygonObject( *static_cast<IMapPolygonObject*>(pCopyObj) ) );
+ break;
- aName = rImageMap.aName;
+ default:
+ break;
+ }
+ }
+ aName = rImageMap.aName;
+ }
return *this;
}
diff --git a/svx/source/form/dataaccessdescriptor.cxx b/svx/source/form/dataaccessdescriptor.cxx
index dcc0a3175a7c..f2b6a1b5711a 100644
--- a/svx/source/form/dataaccessdescriptor.cxx
+++ b/svx/source/form/dataaccessdescriptor.cxx
@@ -273,7 +273,8 @@ namespace svx
ODataAccessDescriptor& ODataAccessDescriptor::operator=(const ODataAccessDescriptor& _rSource)
{
- m_pImpl.reset(new ODADescriptorImpl(*_rSource.m_pImpl));
+ if (this != &_rSource)
+ m_pImpl.reset(new ODADescriptorImpl(*_rSource.m_pImpl));
return *this;
}
diff --git a/svx/source/svdraw/svdlayer.cxx b/svx/source/svdraw/svdlayer.cxx
index b941c72cdc8b..8c9c15852a7d 100644
--- a/svx/source/svdraw/svdlayer.cxx
+++ b/svx/source/svdraw/svdlayer.cxx
@@ -136,12 +136,15 @@ void SdrLayerAdmin::ClearLayers()
SdrLayerAdmin& SdrLayerAdmin::operator=(const SdrLayerAdmin& rSrcLayerAdmin)
{
- maLayers.clear();
- pParent=rSrcLayerAdmin.pParent;
- sal_uInt16 i;
- sal_uInt16 nCount=rSrcLayerAdmin.GetLayerCount();
- for (i=0; i<nCount; i++) {
- maLayers.emplace_back(new SdrLayer(*rSrcLayerAdmin.GetLayer(i)));
+ if (this != &rSrcLayerAdmin)
+ {
+ maLayers.clear();
+ pParent=rSrcLayerAdmin.pParent;
+ sal_uInt16 i;
+ sal_uInt16 nCount=rSrcLayerAdmin.GetLayerCount();
+ for (i=0; i<nCount; i++) {
+ maLayers.emplace_back(new SdrLayer(*rSrcLayerAdmin.GetLayer(i)));
+ }
}
return *this;
}
diff --git a/svx/source/svdraw/svdmark.cxx b/svx/source/svdraw/svdmark.cxx
index 08277af19f76..5c2760f495d8 100644
--- a/svx/source/svdraw/svdmark.cxx
+++ b/svx/source/svdraw/svdmark.cxx
@@ -217,20 +217,23 @@ void SdrMarkList::Clear()
SdrMarkList& SdrMarkList::operator=(const SdrMarkList& rLst)
{
- Clear();
-
- for(size_t i = 0; i < rLst.GetMarkCount(); ++i)
+ if (this != &rLst)
{
- SdrMark* pMark = rLst.GetMark(i);
- maList.emplace_back(new SdrMark(*pMark));
- }
+ Clear();
+
+ for(size_t i = 0; i < rLst.GetMarkCount(); ++i)
+ {
+ SdrMark* pMark = rLst.GetMark(i);
+ maList.emplace_back(new SdrMark(*pMark));
+ }
- maMarkName = rLst.maMarkName;
- mbNameOk = rLst.mbNameOk;
- maPointName = rLst.maPointName;
- mbPointNameOk = rLst.mbPointNameOk;
- maGluePointName = rLst.maGluePointName;
- mbSorted = rLst.mbSorted;
+ maMarkName = rLst.maMarkName;
+ mbNameOk = rLst.mbNameOk;
+ maPointName = rLst.maPointName;
+ mbPointNameOk = rLst.mbPointNameOk;
+ maGluePointName = rLst.maGluePointName;
+ mbSorted = rLst.mbSorted;
+ }
return *this;
}
diff --git a/svx/source/xoutdev/xexch.cxx b/svx/source/xoutdev/xexch.cxx
index d0ead7dfa21a..00f9fefbf96c 100644
--- a/svx/source/xoutdev/xexch.cxx
+++ b/svx/source/xoutdev/xexch.cxx
@@ -120,14 +120,16 @@ SvStream& ReadXFillExchangeData( SvStream& rIStm, XFillExchangeData& rData )
XFillExchangeData& XFillExchangeData::operator=( const XFillExchangeData& rData )
{
- if( rData.pXFillAttrSetItem )
- pXFillAttrSetItem.reset( static_cast<XFillAttrSetItem*>( rData.pXFillAttrSetItem->Clone( pPool = rData.pXFillAttrSetItem->GetItemSet().GetPool() ) ) );
- else
+ if (this != &rData)
{
- pPool = nullptr;
- pXFillAttrSetItem.reset();
+ if( rData.pXFillAttrSetItem )
+ pXFillAttrSetItem.reset( static_cast<XFillAttrSetItem*>( rData.pXFillAttrSetItem->Clone( pPool = rData.pXFillAttrSetItem->GetItemSet().GetPool() ) ) );
+ else
+ {
+ pPool = nullptr;
+ pXFillAttrSetItem.reset();
+ }
}
-
return *this;
}
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;
}
diff --git a/vcl/source/gdi/animate.cxx b/vcl/source/gdi/animate.cxx
index 22519fa5b810..7e3cb72ac9cf 100644
--- a/vcl/source/gdi/animate.cxx
+++ b/vcl/source/gdi/animate.cxx
@@ -96,18 +96,20 @@ Animation::~Animation()
Animation& Animation::operator=( const Animation& rAnimation )
{
- Clear();
-
- for(auto const & i : rAnimation.maList)
- maList.emplace_back( new AnimationBitmap( *i ) );
+ if (this != &rAnimation)
+ {
+ Clear();
- maGlobalSize = rAnimation.maGlobalSize;
- maBitmapEx = rAnimation.maBitmapEx;
- mnLoopCount = rAnimation.mnLoopCount;
- mnPos = rAnimation.mnPos;
- mbLoopTerminated = rAnimation.mbLoopTerminated;
- mnLoops = mbLoopTerminated ? 0 : mnLoopCount;
+ for(auto const & i : rAnimation.maList)
+ maList.emplace_back( new AnimationBitmap( *i ) );
+ maGlobalSize = rAnimation.maGlobalSize;
+ maBitmapEx = rAnimation.maBitmapEx;
+ mnLoopCount = rAnimation.mnLoopCount;
+ mnPos = rAnimation.mnPos;
+ mbLoopTerminated = rAnimation.mbLoopTerminated;
+ mnLoops = mbLoopTerminated ? 0 : mnLoopCount;
+ }
return *this;
}
diff --git a/vcl/source/gdi/regionband.cxx b/vcl/source/gdi/regionband.cxx
index 50f0cecd6616..4cfee2a8d503 100644
--- a/vcl/source/gdi/regionband.cxx
+++ b/vcl/source/gdi/regionband.cxx
@@ -38,27 +38,29 @@ RegionBand::RegionBand(const RegionBand& rRef)
RegionBand& RegionBand::operator=(const RegionBand& rRef)
{
- ImplRegionBand* pPrevBand = nullptr;
- ImplRegionBand* pBand = rRef.mpFirstBand;
-
- while(pBand)
+ if (this != &rRef)
{
- ImplRegionBand* pNewBand = new ImplRegionBand(*pBand);
+ ImplRegionBand* pPrevBand = nullptr;
+ ImplRegionBand* pBand = rRef.mpFirstBand;
- // first element? -> set as first into the list
- if(pBand == rRef.mpFirstBand)
- {
- mpFirstBand = pNewBand;
- }
- else
+ while(pBand)
{
- pPrevBand->mpNextBand = pNewBand;
- }
+ ImplRegionBand* pNewBand = new ImplRegionBand(*pBand);
- pPrevBand = pNewBand;
- pBand = pBand->mpNextBand;
- }
+ // first element? -> set as first into the list
+ if(pBand == rRef.mpFirstBand)
+ {
+ mpFirstBand = pNewBand;
+ }
+ else
+ {
+ pPrevBand->mpNextBand = pNewBand;
+ }
+ pPrevBand = pNewBand;
+ pBand = pBand->mpNextBand;
+ }
+ }
return *this;
}