compilerplugins/clang/useuniqueptr.cxx | 3 +++ sw/source/filter/html/htmlatr.cxx | 14 +++++++------- sw/source/filter/html/htmlflywriter.cxx | 5 ++--- sw/source/filter/html/wrthtml.cxx | 15 ++++++--------- sw/source/filter/html/wrthtml.hxx | 6 +++--- sw/source/filter/xml/xmlexp.cxx | 1 + sw/source/filter/xml/xmlexp.hxx | 6 +++--- sw/source/filter/xml/xmliteme.cxx | 12 ++++++------ sw/source/filter/xml/xmltble.cxx | 9 +++------ 9 files changed, 34 insertions(+), 37 deletions(-)
New commits: commit 94e3568d3d1aa399d13c53f53a699c49da3e929c Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Jul 23 09:35:43 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Jul 24 08:33:07 2018 +0200 loplugin:useuniqueptr in SwXMLExport Change-Id: Id0354b73b0ff14b6a168b672f25483c07988494e Reviewed-on: https://gerrit.libreoffice.org/57864 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx index 8a7da0693df1..1f86cd989b28 100644 --- a/sw/source/filter/xml/xmlexp.cxx +++ b/sw/source/filter/xml/xmlexp.cxx @@ -51,6 +51,7 @@ #include <unotext.hxx> #include "xmltexte.hxx" #include "xmlexp.hxx" +#include "xmlexpit.hxx" #include <sfx2/viewsh.hxx> #include <comphelper/processfactory.hxx> #include <docary.hxx> diff --git a/sw/source/filter/xml/xmlexp.hxx b/sw/source/filter/xml/xmlexp.hxx index 211f50840da6..22e6a42368a7 100644 --- a/sw/source/filter/xml/xmlexp.hxx +++ b/sw/source/filter/xml/xmlexp.hxx @@ -47,9 +47,9 @@ typedef std::vector< SwXMLTableLines_Impl* > SwXMLTableLinesCache_Impl; class SwXMLExport : public SvXMLExport { - SvXMLUnitConverter* m_pTwipUnitConverter; - SvXMLExportItemMapper* m_pTableItemMapper; - SwXMLTableLinesCache_Impl* m_pTableLines; + std::unique_ptr<SvXMLUnitConverter> m_pTwipUnitConverter; + std::unique_ptr<SvXMLExportItemMapper> m_pTableItemMapper; + std::unique_ptr<SwXMLTableLinesCache_Impl> m_pTableLines; SvXMLItemMapEntriesRef m_xTableItemMap; SvXMLItemMapEntriesRef m_xTableRowItemMap; diff --git a/sw/source/filter/xml/xmliteme.cxx b/sw/source/filter/xml/xmliteme.cxx index 60eaedd1f562..7ba4db9501d2 100644 --- a/sw/source/filter/xml/xmliteme.cxx +++ b/sw/source/filter/xml/xmliteme.cxx @@ -207,25 +207,25 @@ inline void SwXMLTableItemMapper_Impl::SetAbsWidth( sal_uInt32 nAbs ) void SwXMLExport::InitItemExport() { - m_pTwipUnitConverter = new SvXMLUnitConverter(getComponentContext(), - util::MeasureUnit::TWIP, GetMM100UnitConverter().GetXMLMeasureUnit()); + m_pTwipUnitConverter.reset(new SvXMLUnitConverter(getComponentContext(), + util::MeasureUnit::TWIP, GetMM100UnitConverter().GetXMLMeasureUnit())); m_xTableItemMap = new SvXMLItemMapEntries( aXMLTableItemMap ); m_xTableRowItemMap = new SvXMLItemMapEntries( aXMLTableRowItemMap ); m_xTableCellItemMap = new SvXMLItemMapEntries( aXMLTableCellItemMap ); - m_pTableItemMapper = new SwXMLTableItemMapper_Impl( m_xTableItemMap, *this ); + m_pTableItemMapper.reset(new SwXMLTableItemMapper_Impl( m_xTableItemMap, *this )); } void SwXMLExport::FinitItemExport() { - delete m_pTableItemMapper; - delete m_pTwipUnitConverter; + m_pTableItemMapper.reset(); + m_pTwipUnitConverter.reset(); } void SwXMLExport::ExportTableFormat( const SwFrameFormat& rFormat, sal_uInt32 nAbsWidth ) { - static_cast<SwXMLTableItemMapper_Impl *>(m_pTableItemMapper) + static_cast<SwXMLTableItemMapper_Impl *>(m_pTableItemMapper.get()) ->SetAbsWidth( nAbsWidth ); ExportFormat( rFormat, XML_TABLE ); } diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx index 4077ce852723..9dbc82d0e92a 100644 --- a/sw/source/filter/xml/xmltble.cxx +++ b/sw/source/filter/xml/xmltble.cxx @@ -569,7 +569,7 @@ void SwXMLExport::ExportTableLinesAutoStyles( const SwTableLines& rLines, // pass 1: calculate columns SwXMLTableLines_Impl *pLines = new SwXMLTableLines_Impl( rLines ); if( !m_pTableLines ) - m_pTableLines = new SwXMLTableLinesCache_Impl; + m_pTableLines.reset(new SwXMLTableLinesCache_Impl); m_pTableLines->push_back( pLines ); @@ -995,10 +995,7 @@ void SwXMLExport::ExportTableLines( const SwTableLines& rLines, m_pTableLines->erase( it ); if( m_pTableLines->empty() ) - { - delete m_pTableLines ; - m_pTableLines = nullptr; - } + m_pTableLines.reset(); // pass 2: export columns const SwXMLTableColumns_Impl& rCols = pLines->GetColumns(); @@ -1201,7 +1198,7 @@ void SwXMLExport::DeleteTableLines() for (SwXMLTableLines_Impl* p : *m_pTableLines) delete p; m_pTableLines->clear(); - delete m_pTableLines; + m_pTableLines.reset(); } } commit dba5dccfc5606ed6c6c888524460c9546143aaef Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Jul 23 09:24:24 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Jul 24 08:32:56 2018 +0200 loplugin:useuniqueptr in SwHTMLWriter Change-Id: I67f3dd615e798f8ac865b57332f6153530d81929 Reviewed-on: https://gerrit.libreoffice.org/57863 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/compilerplugins/clang/useuniqueptr.cxx b/compilerplugins/clang/useuniqueptr.cxx index 4d5b7fc0733a..c7f6d7a2444c 100644 --- a/compilerplugins/clang/useuniqueptr.cxx +++ b/compilerplugins/clang/useuniqueptr.cxx @@ -104,6 +104,9 @@ public: // SaveLine::pBox, pNext if (fn == SRCDIR "/sw/source/core/undo/untbl.cxx") return; + // RedlineInfo::pNextRedline + if (fn == SRCDIR "/sw/source/filter/xml/XMLRedlineImportHelper.cxx") + return; TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); } diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx index e69dac37946f..e5a8b05e993b 100644 --- a/sw/source/filter/html/htmlatr.cxx +++ b/sw/source/filter/html/htmlatr.cxx @@ -1079,7 +1079,7 @@ class HTMLEndPosLst SwDoc *pDoc; // the current document SwDoc* pTemplate; // the HTML template (or 0) - const Color* pDfltColor;// the default foreground colors + boost::optional<Color> xDfltColor;// the default foreground colors std::set<OUString>& rScriptTextStyles; sal_uLong nHTMLMode; @@ -1123,7 +1123,7 @@ class HTMLEndPosLst public: - HTMLEndPosLst( SwDoc *pDoc, SwDoc* pTemplate, const Color* pDfltColor, + HTMLEndPosLst( SwDoc *pDoc, SwDoc* pTemplate, boost::optional<Color> xDfltColor, bool bOutStyles, sal_uLong nHTMLMode, const OUString& rText, std::set<OUString>& rStyles ); ~HTMLEndPosLst(); @@ -1570,12 +1570,12 @@ const SwHTMLFormatInfo *HTMLEndPosLst::GetFormatInfo( const SwFormat& rFormat, } HTMLEndPosLst::HTMLEndPosLst( SwDoc *pD, SwDoc* pTempl, - const Color* pDfltCol, bool bStyles, + boost::optional<Color> xDfltCol, bool bStyles, sal_uLong nMode, const OUString& rText, std::set<OUString>& rStyles ): pDoc( pD ), pTemplate( pTempl ), - pDfltColor( pDfltCol ), + xDfltColor( xDfltCol ), rScriptTextStyles( rStyles ), nHTMLMode( nMode ), bOutStyles( bStyles ) @@ -1681,8 +1681,8 @@ void HTMLEndPosLst::InsertNoScript( const SfxPoolItem& rItem, Color aColor( static_cast<const SvxColorItem&>(rItem).GetValue() ); if( COL_AUTO == aColor ) aColor = COL_BLACK; - bSet = !bParaAttrs || !pDfltColor || - !pDfltColor->IsRGBEqual( aColor ); + bSet = !bParaAttrs || !xDfltColor || + !xDfltColor->IsRGBEqual( aColor ); } break; @@ -2259,7 +2259,7 @@ Writer& OutHTML_SwTextNode( Writer& rWrt, const SwContentNode& rNode ) // are there any hard attributes that must be written as tags? aFullText += rStr; HTMLEndPosLst aEndPosLst( rWrt.m_pDoc, rHTMLWrt.m_xTemplate.get(), - rHTMLWrt.m_pDfltColor, rHTMLWrt.m_bCfgOutStyles, + rHTMLWrt.m_xDfltColor, rHTMLWrt.m_bCfgOutStyles, rHTMLWrt.GetHTMLMode(), aFullText, rHTMLWrt.m_aScriptTextStyles ); if( aFormatInfo.pItemSet ) diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx index 79b111405704..5d13d8854556 100644 --- a/sw/source/filter/html/htmlflywriter.cxx +++ b/sw/source/filter/html/htmlflywriter.cxx @@ -345,7 +345,7 @@ void SwHTMLWriter::CollectFlyFrames() } if( !m_pHTMLPosFlyFrames ) - m_pHTMLPosFlyFrames = new SwHTMLPosFlyFrames; + m_pHTMLPosFlyFrames.reset(new SwHTMLPosFlyFrames); SwHTMLPosFlyFrame *pNew = new SwHTMLPosFlyFrame(**aIter, pSdrObj, nMode); m_pHTMLPosFlyFrames->insert( pNew ); @@ -385,8 +385,7 @@ bool SwHTMLWriter::OutFlyFrame( sal_uLong nNdIdx, sal_Int32 nContentIdx, HtmlPos i--; if( m_pHTMLPosFlyFrames->empty() ) { - delete m_pHTMLPosFlyFrames; - m_pHTMLPosFlyFrames = nullptr; + m_pHTMLPosFlyFrames.reset(); bRestart = true; // not really, only exit the loop } diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx index b2f90146fa7c..2f8dde26a3bd 100644 --- a/sw/source/filter/html/wrthtml.cxx +++ b/sw/source/filter/html/wrthtml.cxx @@ -97,7 +97,6 @@ SwHTMLWriter::SwHTMLWriter( const OUString& rBaseURL ) , m_eCSS1Unit(FUNIT_NONE) , m_pFootEndNotes(nullptr) , mxFormComps() - , m_pDfltColor(nullptr) , m_pStartNdIdx(nullptr) , m_pCurrPageDesc(nullptr) , m_pFormatFootnote(nullptr) @@ -324,7 +323,7 @@ ErrCode SwHTMLWriter::WriteStream() ::StartProgress( STR_STATSTR_W4WWRITE, 0, m_pDoc->GetNodes().Count(), m_pDoc->GetDocShell()); - m_pDfltColor = nullptr; + m_xDfltColor.reset(); m_pFootEndNotes = nullptr; m_pFormatFootnote = nullptr; m_bOutTable = m_bOutHeader = m_bOutFooter = m_bOutFlyFrame = false; @@ -487,8 +486,7 @@ ErrCode SwHTMLWriter::WriteStream() if( m_pHTMLPosFlyFrames ) { m_pHTMLPosFlyFrames->DeleteAndDestroyAll(); - delete m_pHTMLPosFlyFrames; - m_pHTMLPosFlyFrames = nullptr; + m_pHTMLPosFlyFrames.reset(); } m_aHTMLControls.DeleteAndDestroyAll(); @@ -513,8 +511,7 @@ ErrCode SwHTMLWriter::WriteStream() m_aScriptParaStyles.clear(); m_aScriptTextStyles.clear(); - delete m_pDfltColor; - m_pDfltColor = nullptr; + m_xDfltColor.reset(); delete m_pStartNdIdx; m_pStartNdIdx = nullptr; @@ -928,7 +925,7 @@ static void OutBodyColor( const sal_Char* pTag, const SwFormat *pFormat, aColor = COL_BLACK; HTMLOutFuncs::Out_Color( rHWrt.Strm(), aColor ); if( RES_POOLCOLL_STANDARD==pFormat->GetPoolFormatId() ) - rHWrt.m_pDfltColor = new Color( aColor ); + rHWrt.m_xDfltColor = aColor; } } @@ -1523,7 +1520,7 @@ HTMLSaveData::HTMLSaveData(SwHTMLWriter& rWriter, sal_uLong nStt, // Only then also the numbering information of the next paragraph will be valid. if( bSaveNum ) { - pOldNumRuleInfo = new SwHTMLNumRuleInfo( rWrt.GetNumInfo() ); + pOldNumRuleInfo.reset( new SwHTMLNumRuleInfo( rWrt.GetNumInfo() ) ); pOldNextNumRuleInfo = rWrt.ReleaseNextNumInfo(); } else @@ -1558,7 +1555,7 @@ HTMLSaveData::~HTMLSaveData() if( pOldNumRuleInfo ) { rWrt.GetNumInfo().Set( *pOldNumRuleInfo ); - delete pOldNumRuleInfo; + pOldNumRuleInfo.reset(); rWrt.SetNextNumInfo( std::move(pOldNextNumRuleInfo) ); } else diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx index 68495b7f15ad..ff58b49b901a 100644 --- a/sw/source/filter/html/wrthtml.hxx +++ b/sw/source/filter/html/wrthtml.hxx @@ -257,7 +257,7 @@ class IDocumentStylePoolAccess; class SW_DLLPUBLIC SwHTMLWriter : public Writer { - SwHTMLPosFlyFrames *m_pHTMLPosFlyFrames; + std::unique_ptr<SwHTMLPosFlyFrames> m_pHTMLPosFlyFrames; std::unique_ptr<SwHTMLNumRuleInfo> m_pNumRuleInfo;// current numbering std::unique_ptr<SwHTMLNumRuleInfo> m_pNextNumRuleInfo; sal_uInt32 m_nHTMLMode; // description of export configuration @@ -296,7 +296,7 @@ public: css::uno::Reference<css::container::XIndexContainer> mxFormComps; // current form rtl::Reference<SwDoc> m_xTemplate; // HTML template - Color *m_pDfltColor; // default colour + boost::optional<Color> m_xDfltColor; // default colour SwNodeIndex *m_pStartNdIdx; // index of first paragraph const SwPageDesc *m_pCurrPageDesc;// current page style const SwFormatFootnote *m_pFormatFootnote; @@ -621,7 +621,7 @@ struct HTMLSaveData { SwHTMLWriter& rWrt; SwPaM* pOldPam, *pOldEnd; - SwHTMLNumRuleInfo *pOldNumRuleInfo; // Owner = this + std::unique_ptr<SwHTMLNumRuleInfo> pOldNumRuleInfo; // Owner = this std::unique_ptr<SwHTMLNumRuleInfo> pOldNextNumRuleInfo; sal_uInt16 nOldDefListLvl; SvxFrameDirection nOldDirection; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits