From db3860062ebf4109f48139c2556ff4041aff5d6e Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 14 Jul 2017 14:36:52 +0200 Subject: extend loplugin useuniqueptr to OUString pointers Change-Id: Ieb5bab3895e1edaff497c4a1a88303ccac097edc Reviewed-on: https://gerrit.libreoffice.org/39948 Tested-by: Jenkins Reviewed-by: Noel Grandin --- .../officeinstallationdirectories.cxx | 6 +- .../officeinstallationdirectories.hxx | 5 +- compilerplugins/clang/useuniqueptr.cxx | 6 +- idlc/inc/astexpression.hxx | 3 +- idlc/source/astexpression.cxx | 1 - .../source/spellcheck/spell/sspellimp.cxx | 6 +- .../source/spellcheck/spell/sspellimp.hxx | 2 +- sc/inc/chartarr.hxx | 4 +- sc/source/core/tool/chartarr.cxx | 6 +- sc/source/filter/html/htmlpars.cxx | 10 +-- sc/source/filter/inc/eeparser.hxx | 12 ++-- sc/source/filter/xml/XMLStylesImportHelper.cxx | 37 ++++------ sc/source/filter/xml/XMLStylesImportHelper.hxx | 12 ++-- svgio/inc/svgnode.hxx | 9 +-- svgio/source/svgreader/svgnode.cxx | 12 ++-- svl/source/numbers/zforfind.cxx | 40 +++++------ svl/source/numbers/zforfind.hxx | 17 ++--- sw/source/core/doc/DocumentRedlineManager.cxx | 9 +-- sw/source/core/inc/DocumentRedlineManager.hxx | 3 +- sw/source/core/inc/UndoDelete.hxx | 3 +- sw/source/core/inc/UndoInsert.hxx | 9 +-- sw/source/core/undo/undel.cxx | 12 ++-- sw/source/core/undo/unins.cxx | 36 ++++------ sw/source/uibase/inc/toxmgr.hxx | 80 +++++++++------------- .../ucp/webdav-neon/UCBDeadPropertyValue.cxx | 14 ++-- vcl/inc/window.h | 9 ++- vcl/source/window/accessibility.cxx | 8 +-- vcl/source/window/window.cxx | 1 - vcl/source/window/winproc.cxx | 8 +-- xmloff/inc/MultiPropertySetHelper.hxx | 2 +- xmloff/source/style/MultiPropertySetHelper.cxx | 4 +- xmlscript/source/xml_helper/xml_impctx.cxx | 14 +--- 32 files changed, 170 insertions(+), 230 deletions(-) diff --git a/comphelper/source/officeinstdir/officeinstallationdirectories.cxx b/comphelper/source/officeinstdir/officeinstallationdirectories.cxx index 48295a494841..63d88868add6 100644 --- a/comphelper/source/officeinstdir/officeinstallationdirectories.cxx +++ b/comphelper/source/officeinstdir/officeinstallationdirectories.cxx @@ -89,8 +89,6 @@ OfficeInstallationDirectories::OfficeInstallationDirectories( // virtual OfficeInstallationDirectories::~OfficeInstallationDirectories() { - delete m_pOfficeBrandDir; - delete m_pUserDir; } @@ -216,8 +214,8 @@ void OfficeInstallationDirectories::initDirs() osl::MutexGuard aGuard( m_aMutex ); if ( m_pOfficeBrandDir == nullptr ) { - m_pOfficeBrandDir = new OUString; - m_pUserDir = new OUString; + m_pOfficeBrandDir.reset( new OUString ); + m_pUserDir.reset( new OUString ); uno::Reference< util::XMacroExpander > xExpander = util::theMacroExpander::get(m_xCtx); diff --git a/comphelper/source/officeinstdir/officeinstallationdirectories.hxx b/comphelper/source/officeinstdir/officeinstallationdirectories.hxx index b1b235622a73..4437951b7dec 100644 --- a/comphelper/source/officeinstdir/officeinstallationdirectories.hxx +++ b/comphelper/source/officeinstdir/officeinstallationdirectories.hxx @@ -26,6 +26,7 @@ #include #include #include +#include namespace comphelper { @@ -71,8 +72,8 @@ private: OUString m_aOfficeBrandDirMacro; OUString m_aUserDirMacro; css::uno::Reference< css::uno::XComponentContext > m_xCtx; - OUString * m_pOfficeBrandDir; - OUString * m_pUserDir; + std::unique_ptr m_pOfficeBrandDir; + std::unique_ptr m_pUserDir; }; } // namespace comphelper diff --git a/compilerplugins/clang/useuniqueptr.cxx b/compilerplugins/clang/useuniqueptr.cxx index dc1371f00b4a..977404ab2ae6 100644 --- a/compilerplugins/clang/useuniqueptr.cxx +++ b/compilerplugins/clang/useuniqueptr.cxx @@ -14,6 +14,7 @@ #include #include #include "plugin.hxx" +#include "check.hxx" /** Find destructors that only contain a single call to delete of a field. In which @@ -221,7 +222,10 @@ void UseUniquePtr::CheckForDeleteOfPOD(const CompoundStmt* compoundStmt) auto pointerType = dyn_cast(fieldDecl->getType()->getUnqualifiedDesugaredType()); QualType elementType = pointerType->getPointeeType(); - if (!elementType.isPODType(compiler.getASTContext())) + auto tc = loplugin::TypeCheck(elementType); + if (!elementType.isPODType(compiler.getASTContext()) + && !tc.Class("OUString").Namespace("rtl").GlobalNamespace() + && !tc.Class("OString").Namespace("rtl").GlobalNamespace()) continue; StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(fieldDecl->getLocStart())); diff --git a/idlc/inc/astexpression.hxx b/idlc/inc/astexpression.hxx index e9e92600bad8..d978f321fb0f 100644 --- a/idlc/inc/astexpression.hxx +++ b/idlc/inc/astexpression.hxx @@ -131,7 +131,8 @@ private: AstExpression* m_subExpr2; std::unique_ptr m_exprValue; - OString* m_pSymbolicName; + std::unique_ptr + m_pSymbolicName; }; #endif // INCLUDED_IDLC_INC_ASTEXPRESSION_HXX diff --git a/idlc/source/astexpression.cxx b/idlc/source/astexpression.cxx index 8ec1f63b49df..c2da1ae717ea 100644 --- a/idlc/source/astexpression.cxx +++ b/idlc/source/astexpression.cxx @@ -125,7 +125,6 @@ AstExpression::~AstExpression() { delete m_subExpr1; delete m_subExpr2; - delete m_pSymbolicName; } /* diff --git a/lingucomponent/source/spellcheck/spell/sspellimp.cxx b/lingucomponent/source/spellcheck/spell/sspellimp.cxx index 97b5c48a1676..e541a5ef314e 100644 --- a/lingucomponent/source/spellcheck/spell/sspellimp.cxx +++ b/lingucomponent/source/spellcheck/spell/sspellimp.cxx @@ -89,7 +89,6 @@ SpellChecker::~SpellChecker() delete[] m_aDicts; } delete[] m_aDLocs; - delete[] m_aDNames; if (m_pPropHelper) { m_pPropHelper->RemoveAsPropListener(); @@ -201,7 +200,7 @@ Sequence< Locale > SAL_CALL SpellChecker::getLocales() m_aDicts = new Hunspell* [m_nNumDict]; m_aDEncs.reset( new rtl_TextEncoding [m_nNumDict] ); m_aDLocs = new Locale [m_nNumDict]; - m_aDNames = new OUString [m_nNumDict]; + m_aDNames.reset( new OUString [m_nNumDict] ); k = 0; for (aDictIt = aDics.begin(); aDictIt != aDics.end(); ++aDictIt) { @@ -242,8 +241,7 @@ Sequence< Locale > SAL_CALL SpellChecker::getLocales() m_aDEncs.reset(); delete[] m_aDLocs; m_aDLocs = nullptr; - delete[] m_aDNames; - m_aDNames = nullptr; + m_aDNames.reset(); m_aSuppLocales.realloc(0); } } diff --git a/lingucomponent/source/spellcheck/spell/sspellimp.hxx b/lingucomponent/source/spellcheck/spell/sspellimp.hxx index 3a61900e8c15..285ab715ad0a 100644 --- a/lingucomponent/source/spellcheck/spell/sspellimp.hxx +++ b/lingucomponent/source/spellcheck/spell/sspellimp.hxx @@ -58,7 +58,7 @@ class SpellChecker : Hunspell ** m_aDicts; std::unique_ptr m_aDEncs; Locale * m_aDLocs; - OUString * m_aDNames; + std::unique_ptr m_aDNames; sal_Int32 m_nNumDict; ::comphelper::OInterfaceContainerHelper2 m_aEvtListeners; diff --git a/sc/inc/chartarr.hxx b/sc/inc/chartarr.hxx index 57feca6d91a1..57013e9b0034 100644 --- a/sc/inc/chartarr.hxx +++ b/sc/inc/chartarr.hxx @@ -37,8 +37,8 @@ class ScMemChart SCROW nRowCnt; SCCOL nColCnt; std::unique_ptr pData; - OUString* pColText; - OUString* pRowText; + std::unique_ptr pColText; + std::unique_ptr pRowText; ScMemChart(const ScMemChart& rMemChart) = delete; diff --git a/sc/source/core/tool/chartarr.cxx b/sc/source/core/tool/chartarr.cxx index ef89cbeb0710..6ce768b69543 100644 --- a/sc/source/core/tool/chartarr.cxx +++ b/sc/source/core/tool/chartarr.cxx @@ -47,14 +47,12 @@ ScMemChart::ScMemChart(SCCOL nCols, SCROW nRows) memset( pData.get(), 0.0, nColCnt * nRowCnt ); - pColText = new OUString[nColCnt]; - pRowText = new OUString[nRowCnt]; + pColText.reset( new OUString[nColCnt] ); + pRowText.reset( new OUString[nRowCnt] ); } ScMemChart::~ScMemChart() { - delete[] pRowText; - delete[] pColText; } ScChartArray::ScChartArray( ScDocument* pDoc, SCTAB nTab, diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx index 99769779ffb9..11795a5ff086 100644 --- a/sc/source/filter/html/htmlpars.cxx +++ b/sc/source/filter/html/htmlpars.cxx @@ -1012,12 +1012,12 @@ void ScHTMLLayoutParser::TableDataOn( HtmlImportInfo* pInfo ) break; case HtmlOptionId::SDVAL: { - pActEntry->pValStr = new OUString( rOption.GetString() ); + pActEntry->pValStr.reset( new OUString( rOption.GetString() ) ); } break; case HtmlOptionId::SDNUM: { - pActEntry->pNumStr = new OUString( rOption.GetString() ); + pActEntry->pNumStr.reset( new OUString( rOption.GetString() ) ); } break; default: break; @@ -1453,7 +1453,7 @@ void ScHTMLLayoutParser::AnchorOn( HtmlImportInfo* pInfo ) for (const auto & rOption : rOptions) { if( rOption.GetToken() == HtmlOptionId::NAME ) - pActEntry->pName = new OUString(rOption.GetString()); + pActEntry->pName.reset( new OUString(rOption.GetString()) ); } } @@ -2160,8 +2160,8 @@ void ScHTMLTable::DataOn( const HtmlImportInfo& rInfo ) ProcessFormatOptions( *mxDataItemSet, rInfo ); CreateNewEntry( rInfo ); - mxCurrEntry->pValStr = pValStr.release(); - mxCurrEntry->pNumStr = pNumStr.release(); + mxCurrEntry->pValStr.reset( pValStr.release() ); + mxCurrEntry->pNumStr.reset( pNumStr.release() ); } else CreateNewEntry( rInfo ); diff --git a/sc/source/filter/inc/eeparser.hxx b/sc/source/filter/inc/eeparser.hxx index 280446e076b7..9ecf023f59f9 100644 --- a/sc/source/filter/inc/eeparser.hxx +++ b/sc/source/filter/inc/eeparser.hxx @@ -51,9 +51,12 @@ struct ScEEParseEntry { SfxItemSet aItemSet; ESelection aSel; // Selection in EditEngine - OUString* pValStr; // HTML possibly SDVAL string - OUString* pNumStr; // HTML possibly SDNUM string - OUString* pName; // HTML possibly anchor/RangeName + std::unique_ptr + pValStr; // HTML possibly SDVAL string + std::unique_ptr + pNumStr; // HTML possibly SDNUM string + std::unique_ptr + pName; // HTML possibly anchor/RangeName OUString aAltText; // HTML IMG ALT Text std::vector< std::unique_ptr > maImageList; // graphics in this cell SCCOL nCol; // relative to the beginning of the parse @@ -85,9 +88,6 @@ struct ScEEParseEntry ~ScEEParseEntry() { - delete pValStr; - delete pNumStr; - delete pName; maImageList.clear(); } }; diff --git a/sc/source/filter/xml/XMLStylesImportHelper.cxx b/sc/source/filter/xml/XMLStylesImportHelper.cxx index a1f1b08eff6e..28142107b0d1 100644 --- a/sc/source/filter/xml/XMLStylesImportHelper.cxx +++ b/sc/source/filter/xml/XMLStylesImportHelper.cxx @@ -250,21 +250,13 @@ ScMyStylesImportHelper::ScMyStylesImportHelper(ScXMLImport& rTempImport) ScMyStylesImportHelper::~ScMyStylesImportHelper() { - delete pPrevStyleName; - delete pPrevCurrency; - delete pStyleName; - delete pCurrency; } void ScMyStylesImportHelper::ResetAttributes() { - delete pPrevStyleName; - delete pPrevCurrency; - pPrevStyleName = pStyleName; - pPrevCurrency = pCurrency; + pPrevStyleName.reset( pStyleName.release() ); + pPrevCurrency.reset( pCurrency.release() ); nPrevCellType = nCellType; - pStyleName = nullptr; - pCurrency = nullptr; nCellType = 0; } @@ -311,8 +303,7 @@ void ScMyStylesImportHelper::AddDefaultRange(const ScRange& rRange) ScRange aRange(rRange); aRange.aStart.SetCol(nStartCol); aRange.aEnd.SetCol(i - 1); - delete pPrevStyleName; - pPrevStyleName = new OUString(aPrevItr->sStyleName); + pPrevStyleName.reset( new OUString(aPrevItr->sStyleName) ); AddSingleRange(aRange); nStartCol = i; aPrevItr = aColDefaultStyles[i]; @@ -322,8 +313,7 @@ void ScMyStylesImportHelper::AddDefaultRange(const ScRange& rRange) { ScRange aRange(rRange); aRange.aStart.SetCol(nStartCol); - delete pPrevStyleName; - pPrevStyleName = new OUString(aPrevItr->sStyleName); + pPrevStyleName.reset( new OUString(aPrevItr->sStyleName) ); AddSingleRange(aRange); } else @@ -338,21 +328,20 @@ void ScMyStylesImportHelper::AddDefaultRange(const ScRange& rRange) } else { - delete pPrevStyleName; - pPrevStyleName = new OUString(aRowDefaultStyle->sStyleName); + pPrevStyleName.reset( new OUString(aRowDefaultStyle->sStyleName) ); AddSingleRange(rRange); } } void ScMyStylesImportHelper::AddSingleRange(const ScRange& rRange) { - ScMyStylesSet::iterator aItr(GetIterator(pPrevStyleName)); + ScMyStylesSet::iterator aItr(GetIterator(pPrevStyleName.get())); if (aItr != aCellStyles.end()) { if (nPrevCellType != util::NumberFormat::CURRENCY) aItr->xRanges->AddRange(rRange, nPrevCellType); else - aItr->xRanges->AddCurrencyRange(rRange, pPrevCurrency); + aItr->xRanges->AddCurrencyRange(rRange, pPrevCurrency.get()); } } @@ -383,11 +372,9 @@ void ScMyStylesImportHelper::SetRowStyle(const OUString& sStyleName) void ScMyStylesImportHelper::SetAttributes(OUString* pStyleNameP, OUString* pCurrencyP, const sal_Int16 nCellTypeP) { - delete this->pStyleName; - delete this->pCurrency; - this->pStyleName = pStyleNameP; - this->pCurrency = pCurrencyP; - this->nCellType = nCellTypeP; + pStyleName.reset( pStyleNameP ); + pCurrency.reset( pCurrencyP ); + nCellType = nCellTypeP; } void ScMyStylesImportHelper::AddRange(const ScRange& rRange) @@ -396,8 +383,8 @@ void ScMyStylesImportHelper::AddRange(const ScRange& rRange) { bool bAddRange(false); if (nCellType == nPrevCellType && - IsEqual(pStyleName, pPrevStyleName) && - IsEqual(pCurrency, pPrevCurrency)) + IsEqual(pStyleName.get(), pPrevStyleName.get()) && + IsEqual(pCurrency.get(), pPrevCurrency.get())) { if (rRange.aStart.Row() == aPrevRange.aStart.Row()) { diff --git a/sc/source/filter/xml/XMLStylesImportHelper.hxx b/sc/source/filter/xml/XMLStylesImportHelper.hxx index 7907726d27b4..a9eadfaeef90 100644 --- a/sc/source/filter/xml/XMLStylesImportHelper.hxx +++ b/sc/source/filter/xml/XMLStylesImportHelper.hxx @@ -128,10 +128,14 @@ class ScMyStylesImportHelper std::vector aColDefaultStyles; ScMyStylesSet::iterator aRowDefaultStyle; ScXMLImport& rImport; - OUString* pStyleName; - OUString* pPrevStyleName; - OUString* pCurrency; - OUString* pPrevCurrency; + std::unique_ptr + pStyleName; + std::unique_ptr + pPrevStyleName; + std::unique_ptr + pCurrency; + std::unique_ptr + pPrevCurrency; ScRange aPrevRange; sal_Int16 nCellType; sal_Int16 nPrevCellType; diff --git a/svgio/inc/svgnode.hxx b/svgio/inc/svgnode.hxx index 2d2c95bf2cc1..0633e0aae390 100644 --- a/svgio/inc/svgnode.hxx +++ b/svgio/inc/svgnode.hxx @@ -25,6 +25,7 @@ #include #include #include +#include #include // predefines @@ -94,10 +95,10 @@ namespace svgio SvgNodeVector maChildren; /// Id svan value - OUString* mpId; + std::unique_ptr mpId; /// Class svan value - OUString* mpClass; + std::unique_ptr mpClass; /// XmlSpace value XmlSpace maXmlSpace; @@ -163,11 +164,11 @@ namespace svgio double getCurrentXHeight() const; /// Id access - const OUString* getId() const { return mpId; } + const OUString* getId() const { return mpId.get(); } void setId(const OUString* pfId); /// Class access - const OUString* getClass() const { return mpClass; } + const OUString* getClass() const { return mpClass.get(); } void setClass(const OUString* pfClass); /// XmlSpace access diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx index de546314956c..160774ad35e4 100644 --- a/svgio/source/svgreader/svgnode.cxx +++ b/svgio/source/svgreader/svgnode.cxx @@ -296,8 +296,6 @@ namespace svgio maChildren.pop_back(); } - delete mpId; - delete mpClass; delete mpLocalCssStyle; } @@ -643,13 +641,12 @@ namespace svgio if(mpId) { mrDocument.removeSvgNodeFromMapper(*mpId); - delete mpId; - mpId = nullptr; + mpId.reset(); } if(pfId) { - mpId = new OUString(*pfId); + mpId.reset( new OUString(*pfId) ); mrDocument.addSvgNodeToMapper(*mpId, *this); } } @@ -659,13 +656,12 @@ namespace svgio if(mpClass) { mrDocument.removeSvgNodeFromMapper(*mpClass); - delete mpClass; - mpClass = nullptr; + mpClass.reset(); } if(pfClass) { - mpClass = new OUString(*pfClass); + mpClass.reset( new OUString(*pfClass) ); mrDocument.addSvgNodeToMapper(*mpClass, *this); } } diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx index ddf0f9983f80..f2d6a25b8828 100644 --- a/svl/source/numbers/zforfind.cxx +++ b/svl/source/numbers/zforfind.cxx @@ -95,14 +95,6 @@ ImpSvNumberInputScan::~ImpSvNumberInputScan() { Reset(); delete pNullDate; - delete [] pUpperMonthText; - delete [] pUpperAbbrevMonthText; - delete [] pUpperGenitiveMonthText; - delete [] pUpperGenitiveAbbrevMonthText; - delete [] pUpperPartitiveMonthText; - delete [] pUpperPartitiveAbbrevMonthText; - delete [] pUpperDayText; - delete [] pUpperAbbrevDayText; } @@ -3380,25 +3372,25 @@ void ImpSvNumberInputScan::InitText() const CharClass* pChrCls = pFormatter->GetCharClass(); const CalendarWrapper* pCal = pFormatter->GetCalendar(); - delete [] pUpperMonthText; - delete [] pUpperAbbrevMonthText; + pUpperMonthText.reset(); + pUpperAbbrevMonthText.reset(); css::uno::Sequence< css::i18n::CalendarItem2 > xElems = pCal->getMonths(); nElems = xElems.getLength(); - pUpperMonthText = new OUString[nElems]; - pUpperAbbrevMonthText = new OUString[nElems]; + pUpperMonthText.reset( new OUString[nElems] ); + pUpperAbbrevMonthText.reset( new OUString[nElems] ); for ( j = 0; j < nElems; j++ ) { pUpperMonthText[j] = pChrCls->uppercase( xElems[j].FullName ); pUpperAbbrevMonthText[j] = pChrCls->uppercase( xElems[j].AbbrevName ); } - delete [] pUpperGenitiveMonthText; - delete [] pUpperGenitiveAbbrevMonthText; + pUpperGenitiveMonthText.reset(); + pUpperGenitiveAbbrevMonthText.reset(); xElems = pCal->getGenitiveMonths(); bScanGenitiveMonths = (nElems != xElems.getLength()); nElems = xElems.getLength(); - pUpperGenitiveMonthText = new OUString[nElems]; - pUpperGenitiveAbbrevMonthText = new OUString[nElems]; + pUpperGenitiveMonthText.reset( new OUString[nElems] ); + pUpperGenitiveAbbrevMonthText.reset( new OUString[nElems] ); for ( j = 0; j < nElems; j++ ) { pUpperGenitiveMonthText[j] = pChrCls->uppercase( xElems[j].FullName ); @@ -3411,13 +3403,13 @@ void ImpSvNumberInputScan::InitText() } } - delete [] pUpperPartitiveMonthText; - delete [] pUpperPartitiveAbbrevMonthText; + pUpperPartitiveMonthText.reset(); + pUpperPartitiveAbbrevMonthText.reset(); xElems = pCal->getPartitiveMonths(); bScanPartitiveMonths = (nElems != xElems.getLength()); nElems = xElems.getLength(); - pUpperPartitiveMonthText = new OUString[nElems]; - pUpperPartitiveAbbrevMonthText = new OUString[nElems]; + pUpperPartitiveMonthText.reset( new OUString[nElems] ); + pUpperPartitiveAbbrevMonthText.reset( new OUString[nElems] ); for ( j = 0; j < nElems; j++ ) { pUpperPartitiveMonthText[j] = pChrCls->uppercase( xElems[j].FullName ); @@ -3430,12 +3422,12 @@ void ImpSvNumberInputScan::InitText() } } - delete [] pUpperDayText; - delete [] pUpperAbbrevDayText; + pUpperDayText.reset(); + pUpperAbbrevDayText.reset(); xElems = pCal->getDays(); nElems = xElems.getLength(); - pUpperDayText = new OUString[nElems]; - pUpperAbbrevDayText = new OUString[nElems]; + pUpperDayText.reset( new OUString[nElems] ); + pUpperAbbrevDayText.reset( new OUString[nElems] ); for ( j = 0; j < nElems; j++ ) { pUpperDayText[j] = pChrCls->uppercase( xElems[j].FullName ); diff --git a/svl/source/numbers/zforfind.hxx b/svl/source/numbers/zforfind.hxx index 6f95d4c6e6b3..9c4c50044816 100644 --- a/svl/source/numbers/zforfind.hxx +++ b/svl/source/numbers/zforfind.hxx @@ -22,6 +22,7 @@ #include #include +#include class Date; class SvNumberformat; @@ -74,14 +75,14 @@ public: private: SvNumberFormatter* pFormatter; - OUString* pUpperMonthText; //* Array of month names, uppercase - OUString* pUpperAbbrevMonthText; //* Array of month names, abbreviated, uppercase - OUString* pUpperGenitiveMonthText; //* Array of genitive month names, uppercase - OUString* pUpperGenitiveAbbrevMonthText; //* Array of genitive month names, abbreviated, uppercase - OUString* pUpperPartitiveMonthText; //* Array of partitive month names, uppercase - OUString* pUpperPartitiveAbbrevMonthText; //* Array of partitive month names, abbreviated, uppercase - OUString* pUpperDayText; //* Array of day of week names, uppercase - OUString* pUpperAbbrevDayText; //* Array of day of week names, abbreviated, uppercase + std::unique_ptr pUpperMonthText; //* Array of month names, uppercase + std::unique_ptr pUpperAbbrevMonthText; //* Array of month names, abbreviated, uppercase + std::unique_ptr pUpperGenitiveMonthText; //* Array of genitive month names, uppercase + std::unique_ptr pUpperGenitiveAbbrevMonthText; //* Array of genitive month names, abbreviated, uppercase + std::unique_ptr pUpperPartitiveMonthText; //* Array of partitive month names, uppercase + std::unique_ptr pUpperPartitiveAbbrevMonthText;//* Array of partitive month names, abbreviated, uppercase + std::unique_ptr pUpperDayText; //* Array of day of week names, uppercase + std::unique_ptr pUpperAbbrevDayText; //* Array of day of week names, abbreviated, uppercase OUString aUpperCurrSymbol; //* Currency symbol, uppercase bool bTextInitialized; //* Whether days and months are initialized bool bScanGenitiveMonths; //* Whether to scan an input for genitive months diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index d4f117ebc66b..601a57db22fe 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -2659,15 +2659,11 @@ void DocumentRedlineManager::SetAutoFormatRedlineComment( const OUString* pText, m_rDoc.SetAutoFormatRedline( nullptr != pText ); if( pText ) { - if( !mpAutoFormatRedlnComment ) - mpAutoFormatRedlnComment = new OUString( *pText ); - else - *mpAutoFormatRedlnComment = *pText; + mpAutoFormatRedlnComment.reset( new OUString( *pText ) ); } else { - delete mpAutoFormatRedlnComment; - mpAutoFormatRedlnComment = nullptr; + mpAutoFormatRedlnComment.reset(); } mnAutoFormatRedlnCommentNo = nSeqNo; @@ -2697,7 +2693,6 @@ DocumentRedlineManager::~DocumentRedlineManager() { delete mpRedlineTable; mpRedlineTable = nullptr; delete mpExtraRedlineTable; mpExtraRedlineTable = nullptr; - delete mpAutoFormatRedlnComment; mpAutoFormatRedlnComment = nullptr; } } diff --git a/sw/source/core/inc/DocumentRedlineManager.hxx b/sw/source/core/inc/DocumentRedlineManager.hxx index 2a5c1cd24d1f..eeea5f23ace9 100644 --- a/sw/source/core/inc/DocumentRedlineManager.hxx +++ b/sw/source/core/inc/DocumentRedlineManager.hxx @@ -21,6 +21,7 @@ #define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTREDLINEMANAGER_HXX #include +#include class SwDoc; @@ -131,7 +132,7 @@ private: RedlineFlags meRedlineFlags; //< Current Redline Mode. SwRedlineTable *mpRedlineTable; //< List of all Ranged Redlines. SwExtraRedlineTable *mpExtraRedlineTable; //< List of all Extra Redlines. - OUString *mpAutoFormatRedlnComment; //< Comment for Redlines inserted via AutoFormat. + std::unique_ptr mpAutoFormatRedlnComment; //< Comment for Redlines inserted via AutoFormat. bool mbIsRedlineMove; //< true: Redlines are moved into to / out of the section. bool mbReadlineChecked; //< true: if the query was already shown sal_uInt16 mnAutoFormatRedlnCommentNo; /**< SeqNo for conjoining of AutoFormat-Redlines. diff --git a/sw/source/core/inc/UndoDelete.hxx b/sw/source/core/inc/UndoDelete.hxx index 2a0c9fc5ffef..a29993610cd2 100644 --- a/sw/source/core/inc/UndoDelete.hxx +++ b/sw/source/core/inc/UndoDelete.hxx @@ -23,6 +23,7 @@ #include #include #include +#include class SwRedlineSaveDatas; class SwTextNode; @@ -37,7 +38,7 @@ class SwUndoDelete , private SwUndoSaveContent { SwNodeIndex* m_pMvStt; // Position of Nodes in UndoNodes-Array - OUString *m_pSttStr, *m_pEndStr; + std::unique_ptr m_pSttStr, m_pEndStr; SwRedlineSaveDatas* m_pRedlSaveData; std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoStart; std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoEnd; diff --git a/sw/source/core/inc/UndoInsert.hxx b/sw/source/core/inc/UndoInsert.hxx index 9af50eb0efdb..7ee2266e8508 100644 --- a/sw/source/core/inc/UndoInsert.hxx +++ b/sw/source/core/inc/UndoInsert.hxx @@ -41,7 +41,8 @@ class SwUndoInsert: public SwUndo, private SwUndoSaveContent { /// start of Content in UndoNodes for Redo std::unique_ptr m_pUndoNodeIndex; - OUString *pText, *pUndoText; + OUString *pText; + std::unique_ptr pUndoText; SwRedlineData* pRedlData; sal_uLong nNode; sal_Int32 nContent, nLen; @@ -135,9 +136,9 @@ private: class SwUndoReRead : public SwUndo { - Graphic *pGrf; - OUString *pNm; - OUString *pFltr; + std::unique_ptr pGrf; + std::unique_ptr pNm; + std::unique_ptr pFltr; sal_uLong nPos; MirrorGraph nMirr; diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index 94a86342db6d..dcde4a7fc246 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -384,7 +384,7 @@ bool SwUndoDelete::SaveContent( const SwPosition* pStt, const SwPosition* pEnd, // delete now also the text (all attribute changes are added to // UNDO history) - m_pSttStr = new OUString( pSttTextNd->GetText().copy(nSttContent, nLen)); + m_pSttStr.reset( new OUString( pSttTextNd->GetText().copy(nSttContent, nLen)) ); pSttTextNd->EraseText( pStt->nContent, nLen ); if( pSttTextNd->GetpSwpHints() ) pSttTextNd->GetpSwpHints()->DeRegister(); @@ -419,8 +419,8 @@ bool SwUndoDelete::SaveContent( const SwPosition* pStt, const SwPosition* pEnd, // delete now also the text (all attribute changes are added to // UNDO history) - m_pEndStr = new OUString( pEndTextNd->GetText().copy( 0, - pEnd->nContent.GetIndex() )); + m_pEndStr.reset( new OUString( pEndTextNd->GetText().copy( 0, + pEnd->nContent.GetIndex() )) ); pEndTextNd->EraseText( aEndIdx, pEnd->nContent.GetIndex() ); if( pEndTextNd->GetpSwpHints() ) pEndTextNd->GetpSwpHints()->DeRegister(); @@ -518,8 +518,6 @@ bool SwUndoDelete::CanGrouping( SwDoc* pDoc, const SwPaM& rDelPam ) SwUndoDelete::~SwUndoDelete() { - delete m_pSttStr; - delete m_pEndStr; if( m_pMvStt ) // Delete also the selection from UndoNodes array { // Insert saves content in IconSection @@ -706,9 +704,9 @@ SwRewriter SwUndoDelete::GetRewriter() const { OUString * pStr = nullptr; if (m_pSttStr != nullptr) - pStr = m_pSttStr; + pStr = m_pSttStr.get(); else if (m_pEndStr != nullptr) - pStr = m_pEndStr; + pStr = m_pEndStr.get(); if (pStr != nullptr) { diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx index f6ff3e80ee4b..c9d311a3d782 100644 --- a/sw/source/core/undo/unins.cxx +++ b/sw/source/core/undo/unins.cxx @@ -101,7 +101,7 @@ void SwUndoInsert::Init(const SwNodeIndex & rNd) SetRedlineFlags( pDoc->getIDocumentRedlineAccess().GetRedlineFlags() ); } - pUndoText = GetTextFromDoc(); + pUndoText.reset( GetTextFromDoc() ); bCacheComment = false; } @@ -203,7 +203,6 @@ SwUndoInsert::~SwUndoInsert() else // the inserted text delete pText; delete pRedlData; - delete pUndoText; } void SwUndoInsert::UndoImpl(::sw::UndoRedoContext & rContext) @@ -290,7 +289,7 @@ void SwUndoInsert::UndoImpl(::sw::UndoRedoContext & rContext) pPam->GetPoint()->nNode.GetNode().GetContentNode(), nCnt ); } - DELETEZ(pUndoText); + pUndoText.reset(); } void SwUndoInsert::RedoImpl(::sw::UndoRedoContext & rContext) @@ -373,7 +372,7 @@ void SwUndoInsert::RedoImpl(::sw::UndoRedoContext & rContext) } } - pUndoText = GetTextFromDoc(); + pUndoText.reset( GetTextFromDoc() ); } void SwUndoInsert::RepeatImpl(::sw::RepeatContext & rContext) @@ -462,7 +461,7 @@ SwRewriter SwUndoInsert::GetRewriter() const if (pText) pStr = pText; else if (pUndoText) - pStr = pUndoText; + pStr = pUndoText.get(); if (pStr) { @@ -796,9 +795,6 @@ SwUndoReRead::SwUndoReRead( const SwPaM& rPam, const SwGrfNode& rGrfNd ) SwUndoReRead::~SwUndoReRead() { - delete pGrf; - delete pNm; - delete pFltr; } void SwUndoReRead::SetAndSave(::sw::UndoRedoContext & rContext) @@ -810,9 +806,9 @@ void SwUndoReRead::SetAndSave(::sw::UndoRedoContext & rContext) return ; // cache the old values - Graphic* pOldGrf = pGrf; - OUString* pOldNm = pNm; - OUString* pOldFltr = pFltr; + std::unique_ptr pOldGrf( pGrf ? new Graphic(*pGrf) : nullptr); + std::unique_ptr pOldNm( pNm ? new OUString(*pNm) : nullptr); + std::unique_ptr pOldFltr( pFltr ? new OUString(*pFltr) : nullptr); MirrorGraph nOldMirr = nMirr; // since all of them are cleared/modified by SaveGraphicData: SaveGraphicData( *pGrfNd ); @@ -820,13 +816,10 @@ void SwUndoReRead::SetAndSave(::sw::UndoRedoContext & rContext) if( pOldNm ) { pGrfNd->ReRead( *pOldNm, pFltr ? *pFltr : OUString() ); - delete pOldNm; - delete pOldFltr; } else { - pGrfNd->ReRead( OUString(), OUString(), pOldGrf ); - delete pOldGrf; + pGrfNd->ReRead( OUString(), OUString(), pOldGrf.get() ); } if( MirrorGraph::Dont != nOldMirr ) @@ -849,15 +842,16 @@ void SwUndoReRead::SaveGraphicData( const SwGrfNode& rGrfNd ) { if( rGrfNd.IsGrfLink() ) { - pNm = new OUString; - pFltr = new OUString; - rGrfNd.GetFileFilterNms( pNm, pFltr ); - pGrf = nullptr; + pNm.reset( new OUString ); + pFltr.reset( new OUString ); + rGrfNd.GetFileFilterNms( pNm.get(), pFltr.get() ); + pGrf.reset(); } else { - pGrf = new Graphic( rGrfNd.GetGrf(true) ); - pNm = pFltr = nullptr; + pGrf.reset( new Graphic( rGrfNd.GetGrf(true) ) ); + pNm.reset(); + pFltr.reset(); } nMirr = rGrfNd.GetSwAttrSet().GetMirrorGrf().GetValue(); } diff --git a/sw/source/uibase/inc/toxmgr.hxx b/sw/source/uibase/inc/toxmgr.hxx index 65dd2e5ebe48..b15972d3cf55 100644 --- a/sw/source/uibase/inc/toxmgr.hxx +++ b/sw/source/uibase/inc/toxmgr.hxx @@ -23,6 +23,7 @@ #include "swdllapi.h" #include "tox.hxx" #include +#include class SwWrtShell; class SwForm; @@ -36,9 +37,12 @@ class SW_DLLPUBLIC SwTOXDescription OUString m_sSequenceName; OUString m_sMainEntryCharStyle; OUString m_sAutoMarkURL; - OUString* m_pTitle; - OUString* m_pTOUName; - SwForm* m_pForm; + std::unique_ptr + m_pTitle; + std::unique_ptr + m_pTOUName; + std::unique_ptr + m_pForm; SwTOXElement m_nContent; SwTOIOptions m_nIndexOptions; SwTOOElements m_nOLEOptions; @@ -84,12 +88,6 @@ public: m_bIsAuthSequence(false), m_bSortByDocument(true) {} - ~SwTOXDescription() - { - delete m_pTitle; - delete m_pForm; - delete m_pTOUName; - } TOXTypes GetTOXType() const { return m_eTOXType;} @@ -101,14 +99,14 @@ public: const OUString& GetAutoMarkURL() const { return m_sAutoMarkURL;} void SetAutoMarkURL(const OUString& rSet) {m_sAutoMarkURL = rSet;} - void SetTitle(const OUString& pSet) {delete m_pTitle; m_pTitle = new OUString(pSet);} - const OUString* GetTitle() const {return m_pTitle; } + void SetTitle(const OUString& pSet) { m_pTitle.reset( new OUString(pSet) );} + const OUString* GetTitle() const {return m_pTitle.get(); } - void SetTOUName(const OUString& pSet) {delete m_pTOUName; m_pTOUName = new OUString(pSet);} - const OUString* GetTOUName() const {return m_pTOUName; } + void SetTOUName(const OUString& pSet) { m_pTOUName.reset( new OUString(pSet) );} + const OUString* GetTOUName() const {return m_pTOUName.get(); } - void SetForm(const SwForm& rSet) {delete m_pForm; m_pForm = new SwForm(rSet);} - const SwForm* GetForm() const {return m_pForm;} + void SetForm(const SwForm& rSet) { m_pForm.reset( new SwForm(rSet) );} + const SwForm* GetForm() const {return m_pForm.get();} void SetContentOptions(SwTOXElement nSet) { m_nContent = nSet;} SwTOXElement GetContentOptions() const { return m_nContent;} @@ -176,14 +174,14 @@ class SwTOXMarkDescription int nLevel; bool bMainEntry; - OUString* pPrimKey; - OUString* pSecKey; - OUString* pAltStr; - OUString* pTOUName; + std::unique_ptr pPrimKey; + std::unique_ptr pSecKey; + std::unique_ptr pAltStr; + std::unique_ptr pTOUName; - OUString* pPhoneticReadingOfAltStr; - OUString* pPhoneticReadingOfPrimKey; - OUString* pPhoneticReadingOfSecKey; + std::unique_ptr pPhoneticReadingOfAltStr; + std::unique_ptr pPhoneticReadingOfPrimKey; + std::unique_ptr pPhoneticReadingOfSecKey; SwTOXMarkDescription(SwTOXMarkDescription&) = delete; SwTOXMarkDescription & operator= (SwTOXMarkDescription&) = delete; @@ -203,16 +201,6 @@ public: pPhoneticReadingOfSecKey(nullptr) { } - ~SwTOXMarkDescription() - { - delete pPrimKey; - delete pSecKey; - delete pAltStr; - delete pTOUName; - delete pPhoneticReadingOfAltStr; - delete pPhoneticReadingOfPrimKey; - delete pPhoneticReadingOfSecKey; - } TOXTypes GetTOXType()const {return eTOXType;} @@ -223,32 +211,32 @@ public: bool IsMainEntry() const {return bMainEntry;} void SetPrimKey(const OUString& rSet) - {delete pPrimKey; pPrimKey = new OUString(rSet);} - const OUString* GetPrimKey() const {return pPrimKey;} + { pPrimKey.reset( new OUString(rSet) );} + const OUString* GetPrimKey() const {return pPrimKey.get();} void SetSecKey(const OUString& rSet) - {delete pSecKey; pSecKey = new OUString(rSet);} - const OUString* GetSecKey() const { return pSecKey; } + { pSecKey.reset( new OUString(rSet) );} + const OUString* GetSecKey() const { return pSecKey.get(); } void SetAltStr(const OUString& rSet) - {delete pAltStr; pAltStr = new OUString(rSet);} - const OUString* GetAltStr() const { return pAltStr; } + { pAltStr.reset( new OUString(rSet) );} + const OUString* GetAltStr() const { return pAltStr.get(); } void SetTOUName(const OUString& rSet) - {delete pTOUName; pTOUName = new OUString(rSet);} - const OUString* GetTOUName() const {return pTOUName;} + { pTOUName.reset( new OUString(rSet) );} + const OUString* GetTOUName() const {return pTOUName.get();} void SetPhoneticReadingOfAltStr(const OUString& rSet) - {delete pPhoneticReadingOfAltStr; pPhoneticReadingOfAltStr = new OUString(rSet);} - const OUString* GetPhoneticReadingOfAltStr() const { return pPhoneticReadingOfAltStr; } + { pPhoneticReadingOfAltStr.reset( new OUString(rSet) );} + const OUString* GetPhoneticReadingOfAltStr() const { return pPhoneticReadingOfAltStr.get(); } void SetPhoneticReadingOfPrimKey(const OUString& rSet) - {delete pPhoneticReadingOfPrimKey; pPhoneticReadingOfPrimKey = new OUString(rSet);} - const OUString* GetPhoneticReadingOfPrimKey() const { return pPhoneticReadingOfPrimKey; } + { pPhoneticReadingOfPrimKey.reset( new OUString(rSet) );} + const OUString* GetPhoneticReadingOfPrimKey() const { return pPhoneticReadingOfPrimKey.get(); } void SetPhoneticReadingOfSecKey(const OUString& rSet) - {delete pPhoneticReadingOfSecKey; pPhoneticReadingOfSecKey = new OUString(rSet);} - const OUString* GetPhoneticReadingOfSecKey() const { return pPhoneticReadingOfSecKey; } + { pPhoneticReadingOfSecKey.reset( new OUString(rSet) );} + const OUString* GetPhoneticReadingOfSecKey() const { return pPhoneticReadingOfSecKey.get(); } }; class SW_DLLPUBLIC SwTOXMgr diff --git a/ucb/source/ucp/webdav-neon/UCBDeadPropertyValue.cxx b/ucb/source/ucp/webdav-neon/UCBDeadPropertyValue.cxx index 85e6ab1794c5..29891c3afddb 100644 --- a/ucb/source/ucp/webdav-neon/UCBDeadPropertyValue.cxx +++ b/ucb/source/ucp/webdav-neon/UCBDeadPropertyValue.cxx @@ -31,6 +31,7 @@ #include #include #include "UCBDeadPropertyValue.hxx" +#include using namespace webdav_ucp; using namespace com::sun::star; @@ -38,11 +39,10 @@ using namespace com::sun::star; struct UCBDeadPropertyValueParseContext { - OUString * pType; - OUString * pValue; + std::unique_ptr pType; + std::unique_ptr pValue; - UCBDeadPropertyValueParseContext() : pType( nullptr ), pValue( nullptr ) {} - ~UCBDeadPropertyValueParseContext() { delete pType; delete pValue; } + UCBDeadPropertyValueParseContext() {} }; static const char aTypeString[] = "string"; @@ -110,16 +110,14 @@ extern "C" int UCBDeadPropertyValue_chardata_callback( assert( !pCtx->pType && "UCBDeadPropertyValue_endelement_callback - " "Type already set!" ); - pCtx->pType - = new OUString( buf, len, RTL_TEXTENCODING_ASCII_US ); + pCtx->pType.reset( new OUString( buf, len, RTL_TEXTENCODING_ASCII_US ) ); break; case STATE_VALUE: assert( !pCtx->pValue && "UCBDeadPropertyValue_endelement_callback - " "Value already set!" ); - pCtx->pValue - = new OUString( buf, len, RTL_TEXTENCODING_ASCII_US ); + pCtx->pValue.reset( new OUString( buf, len, RTL_TEXTENCODING_ASCII_US ) ); break; } return 0; // zero to continue, non-zero to abort parsing diff --git a/vcl/inc/window.h b/vcl/inc/window.h index b305aa865515..d5c58195f7ae 100644 --- a/vcl/inc/window.h +++ b/vcl/inc/window.h @@ -84,7 +84,8 @@ bool ImplWindowFrameProc( vcl::Window* pInst, SalEvent nEvent, const void* pEven struct ImplWinData { - OUString* mpExtOldText; + std::unique_ptr + mpExtOldText; std::unique_ptr mpExtOldAttrAry; tools::Rectangle* mpCursorRect; @@ -164,8 +165,10 @@ struct ImplFrameData struct ImplAccessibleInfos { sal_uInt16 nAccessibleRole; - OUString* pAccessibleName; - OUString* pAccessibleDescription; + std::unique_ptr + pAccessibleName; + std::unique_ptr + pAccessibleDescription; VclPtr pLabeledByWindow; VclPtr pLabelForWindow; VclPtr pMemberOfWindow; diff --git a/vcl/source/window/accessibility.cxx b/vcl/source/window/accessibility.cxx index cee8929a905a..74561cda7dc2 100644 --- a/vcl/source/window/accessibility.cxx +++ b/vcl/source/window/accessibility.cxx @@ -107,8 +107,6 @@ ImplAccessibleInfos::ImplAccessibleInfos() ImplAccessibleInfos::~ImplAccessibleInfos() { - delete pAccessibleName; - delete pAccessibleDescription; } namespace vcl { @@ -422,8 +420,7 @@ void Window::SetAccessibleName( const OUString& rName ) OUString oldName = GetAccessibleName(); - delete mpWindowImpl->mpAccessibleInfos->pAccessibleName; - mpWindowImpl->mpAccessibleInfos->pAccessibleName = new OUString( rName ); + mpWindowImpl->mpAccessibleInfos->pAccessibleName.reset( new OUString( rName ) ); CallEventListeners( VclEventId::WindowFrameTitleChanged, &oldName ); } @@ -504,8 +501,7 @@ void Window::SetAccessibleDescription( const OUString& rDescription ) mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos; SAL_WARN_IF( mpWindowImpl->mpAccessibleInfos->pAccessibleDescription, "vcl", "AccessibleDescription already set!" ); - delete mpWindowImpl->mpAccessibleInfos->pAccessibleDescription; - mpWindowImpl->mpAccessibleInfos->pAccessibleDescription = new OUString( rDescription ); + mpWindowImpl->mpAccessibleInfos->pAccessibleDescription.reset( new OUString( rDescription ) ); } OUString Window::GetAccessibleDescription() const diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index cdcffdace4f8..6e35ebac9815 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -765,7 +765,6 @@ ImplWinData::ImplWinData() : ImplWinData::~ImplWinData() { - delete mpExtOldText; delete mpCursorRect; delete[] mpCompositionCharRects; delete mpFocusRect; diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx index e7621bb58a40..4f5e11a6df21 100644 --- a/vcl/source/window/winproc.cxx +++ b/vcl/source/window/winproc.cxx @@ -1139,7 +1139,7 @@ static bool ImplHandleExtTextInput( vcl::Window* pWindow, if ( !pChild->ImplGetWindowImpl()->mbExtTextInput ) { pChild->ImplGetWindowImpl()->mbExtTextInput = true; - pWinData->mpExtOldText = new OUString; + pWinData->mpExtOldText.reset( new OUString ); pWinData->mpExtOldAttrAry.reset(); pSVData->maWinData.mpExtTextInputWin = pChild; ImplCallCommand( pChild, CommandEventId::StartExtTextInput ); @@ -1206,11 +1206,7 @@ static bool ImplHandleEndExtTextInput() pChild->ImplGetWindowImpl()->mbExtTextInput = false; pSVData->maWinData.mpExtTextInputWin = nullptr; ImplWinData* pWinData = pChild->ImplGetWinData(); - if ( pWinData->mpExtOldText ) - { - delete pWinData->mpExtOldText; - pWinData->mpExtOldText = nullptr; - } + pWinData->mpExtOldText.reset(); pWinData->mpExtOldAttrAry.reset(); bRet = !ImplCallCommand( pChild, CommandEventId::EndExtTextInput ); } diff --git a/xmloff/inc/MultiPropertySetHelper.hxx b/xmloff/inc/MultiPropertySetHelper.hxx index 7218c89a9617..8b77b8d0623e 100644 --- a/xmloff/inc/MultiPropertySetHelper.hxx +++ b/xmloff/inc/MultiPropertySetHelper.hxx @@ -55,7 +55,7 @@ namespace com { namespace sun { namespace star { class MultiPropertySetHelper { /// names of all properties - OUString* pPropertyNames; + std::unique_ptr pPropertyNames; /// length of pPropertyNames array sal_Int16 nLength; diff --git a/xmloff/source/style/MultiPropertySetHelper.cxx b/xmloff/source/style/MultiPropertySetHelper.cxx index 498491199c8a..0fe5099192bb 100644 --- a/xmloff/source/style/MultiPropertySetHelper.cxx +++ b/xmloff/source/style/MultiPropertySetHelper.cxx @@ -46,7 +46,7 @@ MultiPropertySetHelper::MultiPropertySetHelper( nLength++; // allocate array and create strings - pPropertyNames = new OUString[nLength]; + pPropertyNames.reset( new OUString[nLength] ); for( sal_Int16 i = 0; i < nLength; i++ ) pPropertyNames[i] = OUString::createFromAscii( pNames[i] ); } @@ -55,8 +55,6 @@ MultiPropertySetHelper::MultiPropertySetHelper( MultiPropertySetHelper::~MultiPropertySetHelper() { pValues = nullptr; // memory 'owned' by aValues - - delete[] pPropertyNames; } diff --git a/xmlscript/source/xml_helper/xml_impctx.cxx b/xmlscript/source/xml_helper/xml_impctx.cxx index 6b7288de37c5..5c461c29a64f 100644 --- a/xmlscript/source/xml_helper/xml_impctx.cxx +++ b/xmlscript/source/xml_helper/xml_impctx.cxx @@ -304,9 +304,9 @@ class ExtendedAttributes : { sal_Int32 m_nAttributes; std::unique_ptr m_pUids; - OUString * m_pLocalNames; - OUString * m_pQNames; - OUString * m_pValues; + std::unique_ptr m_pLocalNames; + std::unique_ptr m_pQNames; + std::unique_ptr m_pValues; public: inline ExtendedAttributes( @@ -314,7 +314,6 @@ public: sal_Int32 * pUids, OUString * pLocalNames, OUString * pQNames, Reference< xml::sax::XAttributeList > const & xAttributeList ); - virtual ~ExtendedAttributes() throw () override; // XAttributes virtual sal_Int32 SAL_CALL getLength() override; @@ -353,13 +352,6 @@ inline ExtendedAttributes::ExtendedAttributes( } } -ExtendedAttributes::~ExtendedAttributes() throw () -{ - delete [] m_pLocalNames; - delete [] m_pQNames; - delete [] m_pValues; -} - // XServiceInfo OUString DocumentHandlerImpl::getImplementationName() -- cgit