Kaydet (Commit) a0f5b389 authored tarafından Caolán McNamara's avatar Caolán McNamara

ofz#3564 Direct-leak

Change-Id: I4d816c91874f059becb3f7fdc6007618ac43e88a
Reviewed-on: https://gerrit.libreoffice.org/43194Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 63d845dc
......@@ -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: */
......@@ -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 ;
......
......@@ -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);
......
......@@ -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;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment