[Libreoffice-commits] core.git: sw/source
Caolán McNamara
caolanm at redhat.com
Fri Oct 6 12:03:55 UTC 2017
sw/source/filter/ww8/ww8par.cxx | 25 +++++++++++++++----------
sw/source/filter/ww8/ww8par.hxx | 6 +++---
sw/source/filter/ww8/ww8par3.cxx | 17 ++++++++---------
sw/source/filter/ww8/ww8par6.cxx | 18 +++++++++---------
4 files changed, 35 insertions(+), 31 deletions(-)
New commits:
commit a0f5b389df14129dfe89269fbf3c6cbeefb92c2e
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Oct 6 11:20:18 2017 +0100
ofz#3564 Direct-leak
Change-Id: I4d816c91874f059becb3f7fdc6007618ac43e88a
Reviewed-on: https://gerrit.libreoffice.org/43194
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index d84440531c43..ad8c23f0312f 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -3972,7 +3972,7 @@ bool SwWW8ImplReader::ReadText(WW8_CP nStartCp, WW8_CP nTextLen, ManTypes nType)
m_bWasParaEnd = false;
m_nAktColl = 0;
- m_pAktItemSet = nullptr;
+ m_xAktItemSet.reset();
m_nCharFormat = -1;
m_bSpec = false;
m_bPgSecBreak = false;
@@ -4093,22 +4093,21 @@ bool SwWW8ImplReader::ReadText(WW8_CP nStartCp, WW8_CP nTextLen, ManTypes nType)
const SwFormatCharFormat *pSwFormatCharFormat = nullptr;
- if(m_pAktItemSet)
- pSwFormatCharFormat = &(ItemGet<SwFormatCharFormat>(*m_pAktItemSet, RES_TXTATR_CHARFMT));
+ if (m_xAktItemSet)
+ pSwFormatCharFormat = &(ItemGet<SwFormatCharFormat>(*m_xAktItemSet, RES_TXTATR_CHARFMT));
- if(pSwFormatCharFormat)
+ if (pSwFormatCharFormat)
pFormat = pSwFormatCharFormat->GetCharFormat();
- if(m_pAktItemSet && !pFormat)
+ if (m_xAktItemSet && !pFormat)
{
OUString sPrefix = "WW8Dropcap" + OUString::number(m_nDropCap++);
pNewSwCharFormat = m_rDoc.MakeCharFormat(sPrefix, m_rDoc.GetDfltCharFormat());
- m_pAktItemSet->ClearItem(RES_CHRATR_ESCAPEMENT);
- pNewSwCharFormat->SetFormatAttr( *m_pAktItemSet );
+ m_xAktItemSet->ClearItem(RES_CHRATR_ESCAPEMENT);
+ pNewSwCharFormat->SetFormatAttr(*m_xAktItemSet);
}
- delete m_pAktItemSet;
- m_pAktItemSet = nullptr;
+ m_xAktItemSet.reset();
m_bDropCap=false;
}
@@ -4189,7 +4188,6 @@ SwWW8ImplReader::SwWW8ImplReader(sal_uInt8 nVersionPara, SotStorage* pStorage,
, m_aTextNodesHavingFirstLineOfstSet()
, m_aTextNodesHavingLeftIndentSet()
, m_pAktColl(nullptr)
- , m_pAktItemSet(nullptr)
, m_pDfltTextFormatColl(nullptr)
, m_pStandardFormatColl(nullptr)
, m_pTableDesc(nullptr)
@@ -6557,4 +6555,11 @@ SdrObjUserData* SwMacroInfo::Clone( SdrObject* /*pObj*/ ) const
return new SwMacroInfo( *this );
}
+std::unique_ptr<SfxItemSet> SwWW8ImplReader::SetAktItemSet(SfxItemSet* pItemSet)
+{
+ std::unique_ptr<SfxItemSet> xRet(std::move(m_xAktItemSet));
+ m_xAktItemSet.reset(pItemSet);
+ return xRet;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index cfb3ed81ad89..ba333b218dfe 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1221,7 +1221,7 @@ private:
std::unique_ptr<WW8RStyle> m_xStyles; // pointer to the style reading class
SwFormat* m_pAktColl; // collection to be created now
// ( always 0 outside of a Style-Def )
- SfxItemSet* m_pAktItemSet;// character attributes to be read in now
+ std::unique_ptr<SfxItemSet> m_xAktItemSet;// character attributes to be read in now
// (always 0 outside of the WW8ListManager Ctor)
std::vector<SwWW8StyInf> m_vColl;
const SwTextFormatColl* m_pDfltTextFormatColl; // Default
@@ -1481,7 +1481,7 @@ private:
SwFrameFormat const *pFlyFormat, WW8_FSPA const *pF);
bool IsDropCap();
- bool IsListOrDropcap() { return (!m_pAktItemSet || m_bDropCap); };
+ bool IsListOrDropcap() { return (!m_xAktItemSet || m_bDropCap); };
//Apo == Absolutely Positioned Object, MSWord's old-style frames
WW8FlyPara *ConstructApo(const ApoTestResults &rApo,
@@ -1873,7 +1873,7 @@ public: // really private, but can only be done public
SwDoc& GetDoc() const { return m_rDoc; }
sal_uInt16 GetNAktColl() const { return m_nAktColl; }
void SetNAktColl( sal_uInt16 nColl ) { m_nAktColl = nColl; }
- void SetAktItemSet( SfxItemSet* pItemSet ) { m_pAktItemSet = pItemSet; }
+ std::unique_ptr<SfxItemSet> SetAktItemSet(SfxItemSet* pItemSet);
sal_uInt16 StyleUsingLFO( sal_uInt16 nLFOIndex ) const ;
const SwFormat* GetStyleWithOrgWWName( OUString const & rName ) const ;
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index 8e51cb748ae5..0cb10ddecc7a 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -673,7 +673,7 @@ bool WW8ListManager::ReadLVL(SwNumFormat& rNumFormat, std::unique_ptr<SfxItemSet
rpItemSet.reset(new SfxItemSet( rDoc.GetAttrPool(), svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_END - 1>{}));
// Set Reader-ItemSet-Pointer to the newly created set
- rReader.SetAktItemSet(rpItemSet.get());
+ rReader.SetAktItemSet(rpItemSet.release());
// Set Reader-Style to Style of this Level
sal_uInt16 nOldColl = rReader.GetNAktColl();
sal_uInt16 nNewColl = nLevelStyle;
@@ -697,7 +697,7 @@ bool WW8ListManager::ReadLVL(SwNumFormat& rNumFormat, std::unique_ptr<SfxItemSet
}
// Reset Reader-ItemSet-Pointer and Reader-Style
- rReader.SetAktItemSet( nullptr );
+ rpItemSet = rReader.SetAktItemSet(nullptr);
rReader.SetNAktColl( nOldColl );
rReader.SetToggleAttrFlags(nOldFlags1);
rReader.SetToggleBiDiAttrFlags(nOldFlags2);
@@ -1844,13 +1844,13 @@ void SwWW8ImplReader::RegisterNumFormatOnTextNode(sal_uInt16 nActLFO,
if (bApplyListLevelIndentDirectlyAtPara)
{
- SfxItemSet aListIndent(m_rDoc.GetAttrPool(), svl::Items<RES_LR_SPACE,
- RES_LR_SPACE>{});
+ std::unique_ptr<SfxItemSet> xListIndent(new SfxItemSet(m_rDoc.GetAttrPool(), svl::Items<RES_LR_SPACE,
+ RES_LR_SPACE>{}));
const SvxLRSpaceItem *pItem = static_cast<const SvxLRSpaceItem*>(
GetFormatAttr(RES_LR_SPACE));
OSL_ENSURE(pItem, "impossible");
if (pItem)
- aListIndent.Put(*pItem);
+ xListIndent->Put(*pItem);
/*
Take the original paragraph sprms attached to this list level
@@ -1859,8 +1859,7 @@ void SwWW8ImplReader::RegisterNumFormatOnTextNode(sal_uInt16 nActLFO,
*/
if (short nLen = static_cast< short >(aParaSprms.size()))
{
- SfxItemSet* pOldAktItemSet = m_pAktItemSet;
- SetAktItemSet(&aListIndent);
+ std::unique_ptr<SfxItemSet> xOldAktItemSet(SetAktItemSet(xListIndent.release()));
sal_uInt8* pSprms1 = &aParaSprms[0];
while (0 < nLen)
@@ -1870,10 +1869,10 @@ void SwWW8ImplReader::RegisterNumFormatOnTextNode(sal_uInt16 nActLFO,
pSprms1 += nL1;
}
- SetAktItemSet(pOldAktItemSet);
+ xListIndent = SetAktItemSet(xOldAktItemSet.release());
}
- if (const SvxLRSpaceItem *pLR = aListIndent.GetItem<SvxLRSpaceItem>(RES_LR_SPACE))
+ if (const SvxLRSpaceItem *pLR = xListIndent->GetItem<SvxLRSpaceItem>(RES_LR_SPACE))
{
m_xCtrlStck->NewAttr(*m_pPaM->GetPoint(), *pLR);
m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_LR_SPACE);
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index c8207b87ad4f..7a9fdf0c4676 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -2352,7 +2352,7 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo, const WW8_TablePos *p
if (IsDropCap())
{
m_bDropCap = true;
- m_pAktItemSet = new SfxItemSet( m_rDoc.GetAttrPool(), svl::Items<RES_CHRATR_BEGIN, RES_PARATR_END - 1>{} );
+ m_xAktItemSet.reset(new SfxItemSet(m_rDoc.GetAttrPool(), svl::Items<RES_CHRATR_BEGIN, RES_PARATR_END - 1>{}));
return false;
}
@@ -2640,9 +2640,9 @@ void SwWW8ImplReader::NewAttr( const SfxPoolItem& rAttr,
OSL_ENSURE(rAttr.Which() != RES_FLTR_REDLINE, "redline in style!");
m_pAktColl->SetFormatAttr(rAttr);
}
- else if (m_pAktItemSet)
+ else if (m_xAktItemSet)
{
- m_pAktItemSet->Put(rAttr);
+ m_xAktItemSet->Put(rAttr);
}
else if (rAttr.Which() == RES_FLTR_REDLINE)
{
@@ -2676,9 +2676,9 @@ const SfxPoolItem* SwWW8ImplReader::GetFormatAttr( sal_uInt16 nWhich )
const SfxPoolItem* pRet = nullptr;
if (m_pAktColl)
pRet = &(m_pAktColl->GetFormatAttr(nWhich));
- else if (m_pAktItemSet)
+ else if (m_xAktItemSet)
{
- pRet = m_pAktItemSet->GetItem(nWhich);
+ pRet = m_xAktItemSet->GetItem(nWhich);
if (!pRet)
pRet = m_pStandardFormatColl ? &(m_pStandardFormatColl->GetFormatAttr(nWhich)) : nullptr;
if (!pRet)
@@ -3496,16 +3496,16 @@ void SwWW8ImplReader::Read_UnderlineColor(sal_uInt16, const sal_uInt8* pData, sh
}
}
}
- else if ( m_pAktItemSet )
+ else if (m_xAktItemSet)
{
- if ( SfxItemState::SET == m_pAktItemSet->GetItemState( RES_CHRATR_UNDERLINE, false ) )
+ if ( SfxItemState::SET == m_xAktItemSet->GetItemState( RES_CHRATR_UNDERLINE, false ) )
{
SvxUnderlineItem *pUnderline
- = static_cast<SvxUnderlineItem *>(m_pAktItemSet->Get( RES_CHRATR_UNDERLINE, false ) .Clone());
+ = static_cast<SvxUnderlineItem*>(m_xAktItemSet->Get(RES_CHRATR_UNDERLINE, false).Clone());
if (pUnderline && nLen >= 4)
{
pUnderline->SetColor( Color( msfilter::util::BGRToRGB(SVBT32ToUInt32(pData)) ) );
- m_pAktItemSet->Put( *pUnderline );
+ m_xAktItemSet->Put( *pUnderline );
delete pUnderline;
}
}
More information about the Libreoffice-commits
mailing list