diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-08-28 16:45:00 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-08-28 21:35:32 +0200 |
commit | 1877c2edd4af4f8a415f5324358da72493075201 (patch) | |
tree | d1b724a6ce5431f3bbf8d72ab05140e6b22c193b | |
parent | loplugin:implicitboolconversion (diff) | |
download | core-1877c2edd4af4f8a415f5324358da72493075201.tar.gz core-1877c2edd4af4f8a415f5324358da72493075201.zip |
ofz#3189 Direct-leak
Change-Id: I5702fe12c9c56794983536caecfb7d05f26f9b8b
Reviewed-on: https://gerrit.libreoffice.org/41649
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sw/source/filter/ww8/ww8graf.cxx | 44 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8graf2.cxx | 22 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 22 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par.hxx | 10 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par3.cxx | 12 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par4.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par6.cxx | 2 |
7 files changed, 52 insertions, 64 deletions
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index e9796306d1af..4b7a47f307dc 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -1428,7 +1428,7 @@ void SwWW8ImplReader::ReadGrafLayer1( WW8PLCFspecial* pPF, long nGrafAnchorCp ) SfxAllItemSet aSet( m_pDrawModel->GetItemPool() ); if (SdrObject *pObject = ReadGrafPrimitive(nLeft, aSet)) { - m_pWWZOrder->InsertDrawingObject(pObject, SVBT16ToShort(aDo.dhgt)); + m_xWWZOrder->InsertDrawingObject(pObject, SVBT16ToShort(aDo.dhgt)); tools::Rectangle aRect(pObject->GetSnapRect()); @@ -2482,8 +2482,8 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( long nGrafAnchorCp ) return nullptr; } - if (!m_pMSDffManager->GetModel()) - m_pMSDffManager->SetModel(m_pDrawModel, 1440); + if (!m_xMSDffManager->GetModel()) + m_xMSDffManager->SetModel(m_pDrawModel, 1440); tools::Rectangle aRect(pF->nXaLeft, pF->nYaTop, pF->nXaRight, pF->nYaBottom); SvxMSDffImportData aData( aRect ); @@ -2497,7 +2497,7 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( long nGrafAnchorCp ) m_rDoc.SetDocShell(nullptr); // #i20540# Persist guard SdrObject* pObject = nullptr; - bool bOk = (m_pMSDffManager->GetShape(pF->nSpId, pObject, aData) && pObject); + bool bOk = (m_xMSDffManager->GetShape(pF->nSpId, pObject, aData) && pObject); m_rDoc.SetDocShell(pPersist); // #i20540# Persist guard @@ -2703,12 +2703,12 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( long nGrafAnchorCp ) { /* Need to make sure that the correct layer ordering is applied. */ // pass information, if object is in page header|footer to method. - m_pWWZOrder->InsertEscherObject( pObject, pF->nSpId, + m_xWWZOrder->InsertEscherObject( pObject, pF->nSpId, m_bIsHeader || m_bIsFooter ); } else { - m_pWWZOrder->InsertTextLayerObject(pObject); + m_xWWZOrder->InsertTextLayerObject(pObject); } pRetFrameFormat = m_rDoc.getIDocumentContentOperations().InsertDrawObj(*m_pPaM, *pObject, aFlySet ); @@ -2817,7 +2817,7 @@ SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SdrObject* pTrueObject, if (pSdrTextObj != pNewObj) { // Replace object in the Z-Order-List - m_pMSDffManager->ExchangeInShapeOrder(pSdrTextObj, 0, pNewObj); + m_xMSDffManager->ExchangeInShapeOrder(pSdrTextObj, 0, pNewObj); // now delete object SdrObject::Free( pRecord->pObj ); // and save the new object. @@ -2827,7 +2827,7 @@ SwFrameFormat* SwWW8ImplReader::MungeTextIntoDrawBox(SdrObject* pTrueObject, else { // remove the object from Z-Order list - m_pMSDffManager->RemoveFromShapeOrder( pSdrTextObj ); + m_xMSDffManager->RemoveFromShapeOrder( pSdrTextObj ); // take the object from the drawing page if( pSdrTextObj->GetPage() ) m_pDrawPg->RemoveObject( pSdrTextObj->GetOrdNum() ); @@ -2894,7 +2894,7 @@ SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(SdrObject* &rpObject, rpOurNewObject = CreateContactObject(pRetFrameFormat); // remove old object from the Z-Order list - m_pMSDffManager->RemoveFromShapeOrder( rpObject ); + m_xMSDffManager->RemoveFromShapeOrder( rpObject ); // and delete the object SdrObject::Free( rpObject ); @@ -2915,7 +2915,7 @@ SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(SdrObject* &rpObject, contact object, while a raw rpOutNewObject stored here becomes deleted and useless. */ - m_pMSDffManager->StoreShapeOrder(pF->nSpId, + m_xMSDffManager->StoreShapeOrder(pF->nSpId, (((sal_uLong)pRecord->aTextId.nTxBxS) << 16) + pRecord->aTextId.nSequence, nullptr, pRetFrameFormat); @@ -2924,7 +2924,7 @@ SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(SdrObject* &rpObject, if (!rpOurNewObject->IsInserted()) { // pass information, if object is in page header|footer to method. - m_pWWZOrder->InsertEscherObject( rpOurNewObject, pF->nSpId, + m_xWWZOrder->InsertEscherObject( rpOurNewObject, pF->nSpId, m_bIsHeader || m_bIsFooter ); } } @@ -2939,7 +2939,7 @@ SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(SdrObject* &rpObject, SwNodeIndex aStart(m_pPaM->GetPoint()->nNode); - m_pWWZOrder->InsideEscher(pF->nSpId); + m_xWWZOrder->InsideEscher(pF->nSpId); // read in the text m_bTxbxFlySection = true; @@ -2947,7 +2947,7 @@ SwFlyFrameFormat* SwWW8ImplReader::ConvertDrawTextToFly(SdrObject* &rpObject, MAN_MAINTEXT == m_xPlcxMan->GetManType() ? MAN_TXBX : MAN_TXBX_HDFT); - m_pWWZOrder->OutsideEscher(); + m_xWWZOrder->OutsideEscher(); MoveOutsideFly(pRetFrameFormat, aSave.GetStartPos(),!bJoined); @@ -3055,7 +3055,7 @@ SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables( SdrObject* &rpObj rpOurNewObject = CreateContactObject(pRetFrameFormat); // remove old object from Z-Order-List - m_pMSDffManager->RemoveFromShapeOrder( rpObject ); + m_xMSDffManager->RemoveFromShapeOrder( rpObject ); // remove from Drawing-Page if( rpObject->GetPage() ) m_pDrawPg->RemoveObject( rpObject->GetOrdNum() ); @@ -3070,14 +3070,14 @@ SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables( SdrObject* &rpObj if (rpOurNewObject) { if (!m_bHdFtFootnoteEdn) - m_pMSDffManager->StoreShapeOrder(pF->nSpId, 0, rpOurNewObject ); + m_xMSDffManager->StoreShapeOrder(pF->nSpId, 0, rpOurNewObject ); // The Contact-Object MUST be set in the Draw-Page, so that in // SwWW8ImplReader::LoadDoc1() the Z-Order can be defined !!! if (!rpOurNewObject->IsInserted()) { // pass information, if object is in page header|footer to method. - m_pWWZOrder->InsertEscherObject( rpOurNewObject, pF->nSpId, + m_xWWZOrder->InsertEscherObject( rpOurNewObject, pF->nSpId, m_bIsHeader || m_bIsFooter ); } } @@ -3093,23 +3093,23 @@ void SwWW8ImplReader::GrafikCtor() // For SVDraw and VCControls and Escher OSL_ENSURE(m_pDrawModel, "Cannot create DrawModel"); m_pDrawPg = m_pDrawModel->GetPage(0); - m_pMSDffManager = new SwMSDffManager(*this, m_bSkipImages); - m_pMSDffManager->SetModel(m_pDrawModel, 1440); + m_xMSDffManager.reset(new SwMSDffManager(*this, m_bSkipImages)); + m_xMSDffManager->SetModel(m_pDrawModel, 1440); /* Now the dff manager always needs a controls converter as well, but a control converter may still exist without a dffmanager. */ - m_pFormImpl = new SwMSConvertControls(m_pDocShell, m_pPaM); + m_xFormImpl.reset(new SwMSConvertControls(m_pDocShell, m_pPaM)); - m_pWWZOrder = new wwZOrderer(sw::util::SetLayer(m_rDoc), m_pDrawPg, - m_pMSDffManager->GetShapeOrders()); + m_xWWZOrder.reset(new wwZOrderer(sw::util::SetLayer(m_rDoc), m_pDrawPg, + m_xMSDffManager->GetShapeOrders())); } } void SwWW8ImplReader::GrafikDtor() { DELETEZ(m_pDrawEditEngine); // maybe created by graphic - DELETEZ(m_pWWZOrder); // same + m_xWWZOrder.reset(); // same } void SwWW8FltAnchorStack::AddAnchor(const SwPosition& rPos, SwFrameFormat *pFormat) diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx index 0f13748e5b0b..df199a69f87a 100644 --- a/sw/source/filter/ww8/ww8graf2.cxx +++ b/sw/source/filter/ww8/ww8graf2.cxx @@ -530,8 +530,8 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj, SdrObject* pObject = nullptr; WW8PicDesc aPD( aPic ); - if (!m_pMSDffManager) - m_pMSDffManager = new SwMSDffManager(*this, m_bSkipImages); + if (!m_xMSDffManager) + m_xMSDffManager.reset(new SwMSDffManager(*this, m_bSkipImages)); /* ##835## * Disable use of main stream as fallback stream for inline direct * blips as it is known that they are directly after the record @@ -539,9 +539,9 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj, * incorrect fallback graphic being found if other escher graphics * have been inserted in the document */ - m_pMSDffManager->DisableFallbackStream(); - if( !m_pMSDffManager->GetModel() ) - m_pMSDffManager->SetModel(m_pDrawModel, 1440); + m_xMSDffManager->DisableFallbackStream(); + if (!m_xMSDffManager->GetModel()) + m_xMSDffManager->SetModel(m_pDrawModel, 1440); if (0x66 == aPic.MFP.mm) { @@ -554,7 +554,7 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj, tools::Rectangle aChildRect; tools::Rectangle aClientRect( 0,0, aPD.nWidth, aPD.nHeight); SvxMSDffImportData aData( aClientRect ); - pObject = m_pMSDffManager->ImportObj(*m_pDataStream, &aData, aClientRect, aChildRect ); + pObject = m_xMSDffManager->ImportObj(*m_pDataStream, &aData, aClientRect, aChildRect ); if (pObject) { // for the frame @@ -701,7 +701,7 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj, { if (pOurNewObject != pObject) { - m_pMSDffManager->ExchangeInShapeOrder( pObject, 0, + m_xMSDffManager->ExchangeInShapeOrder( pObject, 0, pOurNewObject ); // delete and destroy old SdrGrafObj from page @@ -711,16 +711,16 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj, } } else - m_pMSDffManager->RemoveFromShapeOrder( pObject ); + m_xMSDffManager->RemoveFromShapeOrder( pObject ); } else - m_pMSDffManager->RemoveFromShapeOrder( pObject ); + m_xMSDffManager->RemoveFromShapeOrder( pObject ); // also delete this from the page if not grouped if (pTextObj && !bTextObjWasGrouped && pTextObj->GetPage()) m_pDrawPg->RemoveObject( pTextObj->GetOrdNum() ); } - m_pMSDffManager->EnableFallbackStream(); + m_xMSDffManager->EnableFallbackStream(); } else if (aPic.lcb >= 58) pRet = ImportGraf1(aPic, m_pDataStream, m_nPicLocFc); @@ -730,7 +730,7 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj, if (pRet) { SdrObject* pOurNewObject = CreateContactObject(pRet); - m_pWWZOrder->InsertTextLayerObject(pOurNewObject); + m_xWWZOrder->InsertTextLayerObject(pOurNewObject); } return AddAutoAnchor(pRet); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index d48b6678024f..1d68e88d301f 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -511,10 +511,10 @@ SdrObject* SwMSDffManager::ImportOLE( sal_uInt32 nOLEId, if( GetOLEStorageName( nOLEId, sStorageName, xSrcStg, xDstStg )) { tools::SvRef<SotStorage> xSrc = xSrcStg->OpenSotStorage( sStorageName ); - OSL_ENSURE(rReader.m_pFormImpl, "No Form Implementation!"); + OSL_ENSURE(rReader.m_xFormImpl.get(), "No Form Implementation!"); css::uno::Reference< css::drawing::XShape > xShape; if ( (!(rReader.m_bIsHeader || rReader.m_bIsFooter)) && - rReader.m_pFormImpl->ReadOCXStream(xSrc,&xShape,true)) + rReader.m_xFormImpl->ReadOCXStream(xSrc,&xShape,true)) { pRet = GetSdrObjectFromXShape(xShape); } @@ -4125,7 +4125,6 @@ SwWW8ImplReader::SwWW8ImplReader(sal_uInt8 nVersionPara, SotStorage* pStorage, , m_aGrfNameGenerator(bNewDoc, OUString('G')) , m_aParaStyleMapper(rD) , m_aCharStyleMapper(rD) - , m_pFormImpl(nullptr) , m_pFlyFormatOfJustInsertedGraphic(nullptr) , m_pFormatOfJustInsertedApo(nullptr) , m_pPreviousNumPaM(nullptr) @@ -4141,9 +4140,7 @@ SwWW8ImplReader::SwWW8ImplReader(sal_uInt8 nVersionPara, SotStorage* pStorage, , m_pDrawModel(nullptr) , m_pDrawPg(nullptr) , m_pDrawEditEngine(nullptr) - , m_pWWZOrder(nullptr) , m_pNumFieldType(nullptr) - , m_pMSDffManager(nullptr) , m_pAtnNames(nullptr) , m_sBaseURL(rBaseURL) , m_nIniFlags(0) @@ -4255,12 +4252,12 @@ void wwSectionManager::SetSegmentToPageDesc(const wwSection &rSection, if(mrReader.m_xWDop->fUseBackGroundInAllmodes) // #i56806# Make sure mrReader is initialized mrReader.GrafikCtor(); - if (mrReader.m_xWDop->fUseBackGroundInAllmodes && mrReader.m_pMSDffManager) + if (mrReader.m_xWDop->fUseBackGroundInAllmodes && mrReader.m_xMSDffManager) { tools::Rectangle aRect(0, 0, 100, 100); // A dummy, we don't care about the size SvxMSDffImportData aData(aRect); SdrObject* pObject = nullptr; - if (mrReader.m_pMSDffManager->GetShape(0x401, pObject, aData) && !aData.empty()) + if (mrReader.m_xMSDffManager->GetShape(0x401, pObject, aData) && !aData.empty()) { // Only handle shape if it is a background shape if (((*aData.begin())->nFlags & 0x400) != 0) @@ -5167,18 +5164,18 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss) m_xProgress->Update(m_nProgress); // Update - if (m_pDrawPg && m_pMSDffManager && m_pMSDffManager->GetShapeOrders()) + if (m_pDrawPg && m_xMSDffManager && m_xMSDffManager->GetShapeOrders()) { // Helper array to chain the inserted frames (instead of SdrTextObj) SvxMSDffShapeTxBxSort aTxBxSort; // Ensure correct z-order of read Escher objects - sal_uInt16 nShapeCount = m_pMSDffManager->GetShapeOrders()->size(); + sal_uInt16 nShapeCount = m_xMSDffManager->GetShapeOrders()->size(); for (sal_uInt16 nShapeNum=0; nShapeNum < nShapeCount; nShapeNum++) { SvxMSDffShapeOrder *pOrder = - (*m_pMSDffManager->GetShapeOrders())[nShapeNum].get(); + (*m_xMSDffManager->GetShapeOrders())[nShapeNum].get(); // Insert Pointer into new Sort array if (pOrder->nTxBxComp && pOrder->pFly) aTxBxSort.insert(pOrder); @@ -5243,10 +5240,9 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss) m_xStyles.reset(); - if( m_pFormImpl ) - DeleteFormImpl(); + m_xFormImpl.reset(); GrafikDtor(); - DELETEZ( m_pMSDffManager ); + m_xMSDffManager.reset(); m_xHdFt.reset(); m_xSBase.reset(); m_xWDop.reset(); diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx index 5e9036d611ae..a0d54fcdbbfd 100644 --- a/sw/source/filter/ww8/ww8par.hxx +++ b/sw/source/filter/ww8/ww8par.hxx @@ -38,6 +38,7 @@ #include "ww8struc.hxx" #include "ww8scan.hxx" #include "ww8glsy.hxx" +#include "ww8graf.hxx" #include "wrtww8.hxx" #include <msfilter.hxx> #include <xmloff/odffields.hxx> @@ -103,7 +104,6 @@ class SwAttrSet; class GDIMetaFile; struct ESelection; class SfxItemSet; -class wwZOrderer; class OutlinerParaObject; namespace com{namespace sun {namespace star{ @@ -1189,7 +1189,7 @@ private: */ std::unique_ptr<ImportProgress> m_xProgress; - SwMSConvertControls *m_pFormImpl; // implementation of control + std::unique_ptr<SwMSConvertControls> m_xFormImpl; // implementation of control SwFlyFrameFormat* m_pFlyFormatOfJustInsertedGraphic; SwFrameFormat* m_pFormatOfJustInsertedApo; @@ -1242,11 +1242,11 @@ private: SdrModel* m_pDrawModel; SdrPage* m_pDrawPg; EditEngine* m_pDrawEditEngine; - wwZOrderer *m_pWWZOrder; + std::unique_ptr<wwZOrderer> m_xWWZOrder; SwFieldType* m_pNumFieldType; // for number circle - SwMSDffManager* m_pMSDffManager; + std::unique_ptr<SwMSDffManager> m_xMSDffManager; std::vector<OUString>* m_pAtnNames; @@ -1862,8 +1862,6 @@ public: // really private, but can only be done public eF_ResT Read_F_Shape(WW8FieldDesc* pF, OUString& rStr); eF_ResT Read_F_HTMLControl( WW8FieldDesc* pF, OUString& rStr); - void DeleteFormImpl(); - short ImportSprm(const sal_uInt8* pPos, sal_Int32 nMemLen, sal_uInt16 nId = 0); bool SearchRowEnd(WW8PLCFx_Cp_FKP* pPap,WW8_CP &rStartCp, int nLevel) const; diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx index 222b858cc602..44168c8bb66f 100644 --- a/sw/source/filter/ww8/ww8par3.cxx +++ b/sw/source/filter/ww8/ww8par3.cxx @@ -161,8 +161,8 @@ eF_ResT SwWW8ImplReader::Read_F_FormCheckBox( WW8FieldDesc* pF, OUString& rStr ) { WW8FormulaCheckBox aFormula(*this); - if (!m_pFormImpl) - m_pFormImpl = new SwMSConvertControls(m_pDocShell, m_pPaM); + if (!m_xFormImpl) + m_xFormImpl.reset(new SwMSConvertControls(m_pDocShell, m_pPaM)); if (rStr[pF->nLCode-1]==0x01) ImportFormulaControl(aFormula,pF->nSCode+pF->nLCode-1, WW8_CT_CHECKBOX); @@ -171,7 +171,7 @@ eF_ResT SwWW8ImplReader::Read_F_FormCheckBox( WW8FieldDesc* pF, OUString& rStr ) if (!bUseEnhFields) { - m_pFormImpl->InsertFormula(aFormula); + m_xFormImpl->InsertFormula(aFormula); return eF_ResT::OK; } @@ -297,12 +297,6 @@ eF_ResT SwWW8ImplReader::Read_F_HTMLControl(WW8FieldDesc*, OUString&) return eF_ResT::TEXT; } -void SwWW8ImplReader::DeleteFormImpl() -{ - delete m_pFormImpl; - m_pFormImpl = nullptr; -} - // Helper declarations // Style Id's for each level diff --git a/sw/source/filter/ww8/ww8par4.cxx b/sw/source/filter/ww8/ww8par4.cxx index 43b57c16ec5b..15ac1c90e9fb 100644 --- a/sw/source/filter/ww8/ww8par4.cxx +++ b/sw/source/filter/ww8/ww8par4.cxx @@ -394,8 +394,8 @@ SdrObject* SwWW8ImplReader::ImportOleBase( Graphic& rGraph, { //Can't put them in headers/footers :-( uno::Reference< drawing::XShape > xRef; - OSL_ENSURE(m_pFormImpl, "Impossible"); - if (m_pFormImpl && m_pFormImpl->ReadOCXStream(xSrc1, &xRef)) + OSL_ENSURE(m_xFormImpl.get(), "Impossible"); + if (m_xFormImpl && m_xFormImpl->ReadOCXStream(xSrc1, &xRef)) { pRet = GetSdrObjectFromXShape(xRef); OSL_ENSURE(pRet, "Impossible"); diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index d3b6709e7443..ee031c7b9a68 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -2385,7 +2385,7 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo, const WW8_TablePos *p GrafikCtor(); SdrObject* pOurNewObject = CreateContactObject(m_xSFlyPara->pFlyFormat); - m_pWWZOrder->InsertTextLayerObject(pOurNewObject); + m_xWWZOrder->InsertTextLayerObject(pOurNewObject); } if (RndStdIds::FLY_AS_CHAR != m_xSFlyPara->eAnchor && m_xSFlyPara->pFlyFormat) |