summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-07-23 09:24:24 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-07-24 08:32:56 +0200
commitdba5dccfc5606ed6c6c888524460c9546143aaef (patch)
treed882efce0801e2f202bced80884a53582f3bd9cc
parent0b7fe7b2ceff8056b619b994fc765eb827f29bf3 (diff)
loplugin:useuniqueptr in SwHTMLWriter
Change-Id: I67f3dd615e798f8ac865b57332f6153530d81929 Reviewed-on: https://gerrit.libreoffice.org/57863 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--compilerplugins/clang/useuniqueptr.cxx3
-rw-r--r--sw/source/filter/html/htmlatr.cxx14
-rw-r--r--sw/source/filter/html/htmlflywriter.cxx5
-rw-r--r--sw/source/filter/html/wrthtml.cxx15
-rw-r--r--sw/source/filter/html/wrthtml.hxx6
5 files changed, 21 insertions, 22 deletions
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;