diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-01-14 10:43:10 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-01-15 06:57:58 +0100 |
commit | 11f85d828a16b1beee5c476bd4d8d21c3e450592 (patch) | |
tree | 03adbd6630f76ee2199a33b2e935f75b9dea8198 | |
parent | 9c6cd998aeb7061f38ec1334e160d002008dd66b (diff) |
use unique_ptr in SwWW8ImplReader::ConstructApo
Change-Id: I104168fbbd04f81d500bc9d63d4328aee0a11f24
Reviewed-on: https://gerrit.libreoffice.org/66318
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sw/source/filter/ww8/ww8par.hxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par2.cxx | 14 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par6.cxx | 10 |
3 files changed, 9 insertions, 17 deletions
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx index 4a91dc1da609..33b0a9349141 100644 --- a/sw/source/filter/ww8/ww8par.hxx +++ b/sw/source/filter/ww8/ww8par.hxx @@ -1493,7 +1493,7 @@ private: bool IsListOrDropcap() { return (!m_xCurrentItemSet || m_bDropCap); }; //Apo == Absolutely Positioned Object, MSWord's old-style frames - WW8FlyPara *ConstructApo(const ApoTestResults &rApo, + std::unique_ptr<WW8FlyPara> ConstructApo(const ApoTestResults &rApo, const WW8_TablePos *pTabPos); bool StartApo(const ApoTestResults &rApo, const WW8_TablePos *pTabPos); void StopApo(); diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index 04f896ea268f..f5224bec80a1 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -460,9 +460,7 @@ ApoTestResults SwWW8ImplReader::TestApo(int nCellLevel, bool bTableRowEnd, bool bNowApo = aRet.HasFrame() || pTopLevelTable; if (bNowApo) { - if (WW8FlyPara *pTest = ConstructApo(aRet, pTabPos)) - delete pTest; - else + if (!ConstructApo(aRet, pTabPos)) bNowApo = false; } @@ -2080,10 +2078,7 @@ WW8TabDesc::WW8TabDesc(SwWW8ImplReader* pIoClass, WW8_CP nStartCp) : if (aApo.mbStartApo) { //if there really is a fly here, and not a "null" fly then break. - WW8FlyPara *pNewFly = m_pIo->ConstructApo(aApo, pTabPos); - if (pNewFly) - delete pNewFly; - else + if (m_pIo->ConstructApo(aApo, pTabPos)) break; } @@ -3408,7 +3403,7 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp) // #i33818# - determine absolute position object attributes, // if possible. It's needed for nested tables. - WW8FlyPara* pTableWFlyPara( nullptr ); + std::unique_ptr<WW8FlyPara> pTableWFlyPara; WW8SwFlyPara* pTableSFlyPara( nullptr ); // #i45301# - anchor nested table inside Writer fly frame // only at-character, if absolute position object attributes are available. @@ -3485,7 +3480,7 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp) // if existing, and apply them to the created Writer fly frame. if ( pTableWFlyPara && pTableSFlyPara ) { - WW8FlySet aFlySet( *this, pTableWFlyPara, pTableSFlyPara, false ); + WW8FlySet aFlySet( *this, pTableWFlyPara.get(), pTableSFlyPara, false ); SwFormatAnchor aAnchor( RndStdIds::FLY_AT_CHAR ); aAnchor.SetAnchor( m_xTableDesc->m_pParentPos ); aFlySet.Put( aAnchor ); @@ -3510,7 +3505,6 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp) PopTableDesc(); // #i33818# - delete pTableWFlyPara; delete pTableSFlyPara; return m_xTableDesc != nullptr; diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index a178f5c788d0..2b12c2619a1b 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -2364,14 +2364,13 @@ SwTwips SwWW8ImplReader::MoveOutsideFly(SwFrameFormat *pFlyFormat, return nRetWidth; } -WW8FlyPara *SwWW8ImplReader::ConstructApo(const ApoTestResults &rApo, +std::unique_ptr<WW8FlyPara> SwWW8ImplReader::ConstructApo(const ApoTestResults &rApo, const WW8_TablePos *pTabPos) { - WW8FlyPara *pRet = nullptr; OSL_ENSURE(rApo.HasFrame() || pTabPos, "If no frame found, *MUST* be in a table"); - pRet = new WW8FlyPara(m_bVer67, rApo.mpStyleApo); + std::unique_ptr<WW8FlyPara> pRet(new WW8FlyPara(m_bVer67, rApo.mpStyleApo)); // find APO parameter and test for bGrafApo if (rApo.HasFrame()) @@ -2381,8 +2380,7 @@ WW8FlyPara *SwWW8ImplReader::ConstructApo(const ApoTestResults &rApo, if (pRet->IsEmpty()) { - delete pRet; - pRet = nullptr; + pRet.reset(); } return pRet; } @@ -2418,7 +2416,7 @@ bool SwWW8ImplReader::IsDropCap() bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo, const WW8_TablePos *pTabPos) { - m_xWFlyPara.reset(ConstructApo(rApo, pTabPos)); + m_xWFlyPara = ConstructApo(rApo, pTabPos); if (!m_xWFlyPara) return false; |