diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-05-02 13:00:30 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-05-02 13:58:07 +0200 |
commit | be48eb2e82a3d8891ee84145567e2b89884f1fd6 (patch) | |
tree | 17e123be98ce578c3ff10c31a275141dfe2e3afa | |
parent | f66edd357c4572fd69d42c2330f922ec2beaa415 (diff) |
return std::unique_ptr from SdrMakeOutliner
and some of its callers
Change-Id: I121a7810e3e35e76da4ffe5fc5405a7bf86cb66d
Reviewed-on: https://gerrit.libreoffice.org/53728
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | include/svx/svdetc.hxx | 2 | ||||
-rw-r--r-- | include/svx/svdmodel.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/futext.cxx | 14 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/futext2.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/inc/futext.hxx | 2 | ||||
-rw-r--r-- | sd/source/ui/func/fuexpand.cxx | 7 | ||||
-rw-r--r-- | sd/source/ui/func/futext.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/view/sdview.cxx | 2 | ||||
-rw-r--r-- | svx/source/inc/svdoutlinercache.hxx | 2 | ||||
-rw-r--r-- | svx/source/sdr/properties/textproperties.cxx | 3 | ||||
-rw-r--r-- | svx/source/svdraw/svdedxv.cxx | 2 | ||||
-rw-r--r-- | svx/source/svdraw/svdetc.cxx | 4 | ||||
-rw-r--r-- | svx/source/svdraw/svdmodel.cxx | 8 | ||||
-rw-r--r-- | svx/source/svdraw/svdoutlinercache.cxx | 10 | ||||
-rw-r--r-- | svx/source/table/tablecontroller.cxx | 4 | ||||
-rw-r--r-- | svx/source/unodraw/unoshtxt.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewdraw.cxx | 6 |
17 files changed, 39 insertions, 39 deletions
diff --git a/include/svx/svdetc.hxx b/include/svx/svdetc.hxx index c39e77b7d174..abd5c886ef2b 100644 --- a/include/svx/svdetc.hxx +++ b/include/svx/svdetc.hxx @@ -55,7 +55,7 @@ namespace com { namespace sun { namespace star { namespace lang { * The resulting default font height, however, stays the same (the logical * font height is converted). */ -SVX_DLLPUBLIC SdrOutliner* SdrMakeOutliner(OutlinerMode nOutlinerMode, SdrModel& rMod); +SVX_DLLPUBLIC std::unique_ptr<SdrOutliner> SdrMakeOutliner(OutlinerMode nOutlinerMode, SdrModel& rMod); /** * Global default settings for the DrawingEngine. diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx index cd49212c3584..0b7b5ab5cc40 100644 --- a/include/svx/svdmodel.hxx +++ b/include/svx/svdmodel.hxx @@ -543,7 +543,7 @@ public: void ReformatAllTextObjects(); - SdrOutliner* createOutliner( OutlinerMode nOutlinerMode ); + std::unique_ptr<SdrOutliner> createOutliner( OutlinerMode nOutlinerMode ); void disposeOutliner( SdrOutliner* pOutliner ); bool IsWriter() const { return !bMyPool; } diff --git a/sc/source/ui/drawfunc/futext.cxx b/sc/source/ui/drawfunc/futext.cxx index 7914c87a7313..0152ba0084af 100644 --- a/sc/source/ui/drawfunc/futext.cxx +++ b/sc/source/ui/drawfunc/futext.cxx @@ -184,7 +184,7 @@ bool FuText::MouseButtonDown(const MouseEvent& rMEvt) nullptr; if (pObj) { - SdrOutliner* pO = MakeOutliner(); + std::unique_ptr<SdrOutliner> pO = MakeOutliner(); lcl_UpdateHyphenator( *pO, pObj ); // vertical flag: @@ -197,10 +197,11 @@ bool FuText::MouseButtonDown(const MouseEvent& rMEvt) pO->SetVertical( bVertical ); //!?? the default values are not correct when result is without outliner ???!? - if ( pView->SdrBeginTextEdit(pObj, pPV, pWindow, true, pO) ) + auto pUndoManager = &pO->GetUndoManager(); + if ( pView->SdrBeginTextEdit(pObj, pPV, pWindow, true, pO.release()) ) { // subscribe EditEngine-UndoManager - pViewShell->SetDrawTextUndo( &pO->GetUndoManager() ); + pViewShell->SetDrawTextUndo( pUndoManager ); OutlinerView* pOLV = pView->GetTextEditOutlinerView(); if ( pOLV->MouseButtonDown(rMEvt) ) @@ -578,7 +579,7 @@ void FuText::SetInEditMode(SdrObject* pObj, const Point* pMousePixel, if ( pObj->HasTextEdit() ) { - SdrOutliner* pO = MakeOutliner(); + std::unique_ptr<SdrOutliner> pO = MakeOutliner(); lcl_UpdateHyphenator( *pO, pObj ); // vertical flag: @@ -592,7 +593,8 @@ void FuText::SetInEditMode(SdrObject* pObj, const Point* pMousePixel, pO->SetVertical( bVertical ); //!?? without returned Outliner the defaults are not correct ???!? - if ( pView->SdrBeginTextEdit(pObj, pPV, pWindow, true, pO) ) + auto pUndoManager = &pO->GetUndoManager(); + if ( pView->SdrBeginTextEdit(pObj, pPV, pWindow, true, pO.release()) ) { // Toggle out of paste mode if we are in it, otherwise // pressing return in this object will instead go to the @@ -601,7 +603,7 @@ void FuText::SetInEditMode(SdrObject* pObj, const Point* pMousePixel, pViewShell->UpdateCopySourceOverlay(); // EditEngine-UndoManager anmelden - pViewShell->SetDrawTextUndo( &pO->GetUndoManager() ); + pViewShell->SetDrawTextUndo( pUndoManager ); pView->SetEditMode(); diff --git a/sc/source/ui/drawfunc/futext2.cxx b/sc/source/ui/drawfunc/futext2.cxx index 22f6325a7114..e986099cce7a 100644 --- a/sc/source/ui/drawfunc/futext2.cxx +++ b/sc/source/ui/drawfunc/futext2.cxx @@ -24,10 +24,10 @@ #include <futext.hxx> #include <tabvwsh.hxx> -SdrOutliner* FuText::MakeOutliner() +std::unique_ptr<SdrOutliner> FuText::MakeOutliner() { ScViewData& rViewData = pViewShell->GetViewData(); - SdrOutliner* pOutl = SdrMakeOutliner(OutlinerMode::OutlineObject, *pDrDoc); + std::unique_ptr<SdrOutliner> pOutl = SdrMakeOutliner(OutlinerMode::OutlineObject, *pDrDoc); rViewData.UpdateOutlinerFlags(*pOutl); diff --git a/sc/source/ui/inc/futext.hxx b/sc/source/ui/inc/futext.hxx index 0403dc944004..215da2dbe80c 100644 --- a/sc/source/ui/inc/futext.hxx +++ b/sc/source/ui/inc/futext.hxx @@ -53,7 +53,7 @@ public: virtual SdrObject* CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override; private: - SdrOutliner* MakeOutliner(); + std::unique_ptr<SdrOutliner> MakeOutliner(); }; #endif diff --git a/sd/source/ui/func/fuexpand.cxx b/sd/source/ui/func/fuexpand.cxx index b5fc2916e36d..c0b54ec139b4 100644 --- a/sd/source/ui/func/fuexpand.cxx +++ b/sd/source/ui/func/fuexpand.cxx @@ -190,7 +190,7 @@ void FuExpandPage::DoExecute( SfxRequest& ) if( pOutlinerParaObject->GetDepth(0) != -1 ) { - SdrOutliner* pTempOutl = SdrMakeOutliner(OutlinerMode::TitleObject, *mpDoc); + std::unique_ptr<SdrOutliner> pTempOutl = SdrMakeOutliner(OutlinerMode::TitleObject, *mpDoc); pTempOutl->SetText( *pOutlinerParaObject ); @@ -199,7 +199,6 @@ void FuExpandPage::DoExecute( SfxRequest& ) pTempOutl->SetDepth( pTempOutl->GetParagraph( 0 ), -1 ); pOutlinerParaObject = pTempOutl->CreateParaObject(); - delete pTempOutl; } pTextObj->SetOutlinerParaObject(pOutlinerParaObject); @@ -218,7 +217,7 @@ void FuExpandPage::DoExecute( SfxRequest& ) // create structuring text objects OutlinerParaObject* pOPO = pOutl->CreateParaObject(++nParaPos, nChildCount); - SdrOutliner* pTempOutl = SdrMakeOutliner(OutlinerMode::OutlineObject, *mpDoc); + std::unique_ptr<SdrOutliner> pTempOutl = SdrMakeOutliner(OutlinerMode::OutlineObject, *mpDoc); pTempOutl->SetText( *pOPO ); sal_Int32 nParaCount2 = pTempOutl->GetParagraphCount(); @@ -232,7 +231,7 @@ void FuExpandPage::DoExecute( SfxRequest& ) delete pOPO; pOPO = pTempOutl->CreateParaObject(); - delete pTempOutl; + pTempOutl.reset(); pOutlineObj->SetOutlinerParaObject( pOPO ); pOutlineObj->SetEmptyPresObj(false); diff --git a/sd/source/ui/func/futext.cxx b/sd/source/ui/func/futext.cxx index b6d81901f870..3d50a81139e9 100644 --- a/sd/source/ui/func/futext.cxx +++ b/sd/source/ui/func/futext.cxx @@ -1055,7 +1055,7 @@ void FuText::SetInEditMode(const MouseEvent& rMEvt, bool bQuickDrag) nSdrObjKind == OBJ_OUTLINETEXT || !mxTextObj->IsEmptyPresObj() ) ) { // create new outliner (owned by SdrObjEditView) - SdrOutliner* pOutl = SdrMakeOutliner(OutlinerMode::OutlineObject, *mpDoc); + std::unique_ptr<SdrOutliner> pOutl = SdrMakeOutliner(OutlinerMode::OutlineObject, *mpDoc); if (bEmptyOutliner) mpView->SdrEndTextEdit(true); @@ -1076,7 +1076,7 @@ void FuText::SetInEditMode(const MouseEvent& rMEvt, bool bQuickDrag) pTextObj->setActiveText( pTextObj->CheckTextHit(aPnt ) ); } - if (mpView->SdrBeginTextEdit(pTextObj, pPV, mpWindow, true, pOutl) && mxTextObj->GetObjInventor() == SdrInventor::Default) + if (mpView->SdrBeginTextEdit(pTextObj, pPV, mpWindow, true, pOutl.release()) && mxTextObj->GetObjInventor() == SdrInventor::Default) { //tdf#102293 flush overlay before going on to pass clicks down to //the outline view which will want to paint selections diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx index 7bff93080e61..3409123b788b 100644 --- a/sd/source/ui/view/sdview.cxx +++ b/sd/source/ui/view/sdview.cxx @@ -659,7 +659,7 @@ bool View::SdrBeginTextEdit( EventMultiplexerEventId::BeginTextEdit, static_cast<void*>(pObj) ); if( pOutl==nullptr && pObj ) - pOutl = SdrMakeOutliner(OutlinerMode::TextObject, pObj->getSdrModelFromSdrObject()); + pOutl = SdrMakeOutliner(OutlinerMode::TextObject, pObj->getSdrModelFromSdrObject()).release(); // make draw&impress specific initialisations if( pOutl ) diff --git a/svx/source/inc/svdoutlinercache.hxx b/svx/source/inc/svdoutlinercache.hxx index 30f5c6699e11..9eba3da602c9 100644 --- a/svx/source/inc/svdoutlinercache.hxx +++ b/svx/source/inc/svdoutlinercache.hxx @@ -41,7 +41,7 @@ public: SdrOutlinerCache( SdrModel* pModel ); ~SdrOutlinerCache(); - SdrOutliner* createOutliner( OutlinerMode nOutlinerMode ); + std::unique_ptr<SdrOutliner> createOutliner( OutlinerMode nOutlinerMode ); void disposeOutliner( SdrOutliner* pOutliner ); std::vector< SdrOutliner* > GetActiveOutliners() const; }; diff --git a/svx/source/sdr/properties/textproperties.cxx b/svx/source/sdr/properties/textproperties.cxx index aac5e1b59a2d..503872cb4ba6 100644 --- a/svx/source/sdr/properties/textproperties.cxx +++ b/svx/source/sdr/properties/textproperties.cxx @@ -397,7 +397,7 @@ namespace sdr if(!rObj.IsTextEditActive() && !rObj.IsLinkedText()) { - Outliner* pOutliner = SdrMakeOutliner(OutlinerMode::OutlineObject, rObj.getSdrModelFromSdrObject()); + std::unique_ptr<Outliner> pOutliner = SdrMakeOutliner(OutlinerMode::OutlineObject, rObj.getSdrModelFromSdrObject()); const svx::ITextProvider& rTextProvider(getTextProvider()); sal_Int32 nText = rTextProvider.getTextCount(); while (nText--) @@ -525,7 +525,6 @@ namespace sdr pOutliner->Clear(); } - delete pOutliner; } } diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index 21e1f10d43f7..211537d4c411 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -1091,7 +1091,7 @@ bool SdrObjEditView::SdrBeginTextEdit( mxTextEditObj.reset( pObj ); pTextEditOutliner=pGivenOutliner; if (pTextEditOutliner==nullptr) - pTextEditOutliner = SdrMakeOutliner( OutlinerMode::TextObject, mxTextEditObj->getSdrModelFromSdrObject() ); + pTextEditOutliner = SdrMakeOutliner( OutlinerMode::TextObject, mxTextEditObj->getSdrModelFromSdrObject() ).release(); { SvtAccessibilityOptions aOptions; diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx index 3633bfbba696..fb8aab8a82ec 100644 --- a/svx/source/svdraw/svdetc.cxx +++ b/svx/source/svdraw/svdetc.cxx @@ -331,10 +331,10 @@ bool GetDraftFillColor(const SfxItemSet& rSet, Color& rCol) return bRetval; } -SdrOutliner* SdrMakeOutliner(OutlinerMode nOutlinerMode, SdrModel& rModel) +std::unique_ptr<SdrOutliner> SdrMakeOutliner(OutlinerMode nOutlinerMode, SdrModel& rModel) { SfxItemPool* pPool = &rModel.GetItemPool(); - SdrOutliner* pOutl = new SdrOutliner( pPool, nOutlinerMode ); + std::unique_ptr<SdrOutliner> pOutl(new SdrOutliner( pPool, nOutlinerMode )); pOutl->SetEditTextObjectPool( pPool ); pOutl->SetStyleSheetPool( static_cast<SfxStyleSheetPool*>(rModel.GetStyleSheetPool())); pOutl->SetDefTab(rModel.GetDefaultTabulator()); diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx index ccb3e52d3416..47fdc5fa4e92 100644 --- a/svx/source/svdraw/svdmodel.cxx +++ b/svx/source/svdraw/svdmodel.cxx @@ -198,15 +198,15 @@ void SdrModel::ImpCtor(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* _pEmbe // can't create DrawOutliner OnDemand, because I can't get the Pool, // then (only from 302 onwards!) - pDrawOutliner.reset(SdrMakeOutliner(OutlinerMode::TextObject, *this)); + pDrawOutliner = SdrMakeOutliner(OutlinerMode::TextObject, *this); ImpSetOutlinerDefaults(pDrawOutliner.get(), true); - pHitTestOutliner.reset(SdrMakeOutliner(OutlinerMode::TextObject, *this)); + pHitTestOutliner = SdrMakeOutliner(OutlinerMode::TextObject, *this); ImpSetOutlinerDefaults(pHitTestOutliner.get(), true); /* Start Text Chaining related code */ // Initialize Chaining Outliner - pChainingOutliner.reset(SdrMakeOutliner( OutlinerMode::TextObject, *this )); + pChainingOutliner = SdrMakeOutliner( OutlinerMode::TextObject, *this ); ImpSetOutlinerDefaults(pChainingOutliner.get(), true); // Make a TextChain @@ -1861,7 +1861,7 @@ void SdrModel::ReformatAllTextObjects() ImpReformatAllTextObjects(); } -SdrOutliner* SdrModel::createOutliner( OutlinerMode nOutlinerMode ) +std::unique_ptr<SdrOutliner> SdrModel::createOutliner( OutlinerMode nOutlinerMode ) { if( !mpOutlinerCache ) mpOutlinerCache.reset(new SdrOutlinerCache(this)); diff --git a/svx/source/svdraw/svdoutlinercache.cxx b/svx/source/svdraw/svdoutlinercache.cxx index 419837070d4f..fe66e5f0a42f 100644 --- a/svx/source/svdraw/svdoutlinercache.cxx +++ b/svx/source/svdraw/svdoutlinercache.cxx @@ -30,18 +30,18 @@ SdrOutlinerCache::SdrOutlinerCache( SdrModel* pModel ) { } -SdrOutliner* SdrOutlinerCache::createOutliner( OutlinerMode nOutlinerMode ) +std::unique_ptr<SdrOutliner> SdrOutlinerCache::createOutliner( OutlinerMode nOutlinerMode ) { - SdrOutliner* pOutliner = nullptr; + std::unique_ptr<SdrOutliner> pOutliner; if( (OutlinerMode::OutlineObject == nOutlinerMode) && !maModeOutline.empty() ) { - pOutliner = maModeOutline.back().release(); + pOutliner = std::move(maModeOutline.back()); maModeOutline.pop_back(); } else if( (OutlinerMode::TextObject == nOutlinerMode) && !maModeText.empty() ) { - pOutliner = maModeText.back().release(); + pOutliner = std::move(maModeText.back()); maModeText.pop_back(); } else @@ -49,7 +49,7 @@ SdrOutliner* SdrOutlinerCache::createOutliner( OutlinerMode nOutlinerMode ) pOutliner = SdrMakeOutliner(nOutlinerMode, *mpModel); Outliner& aDrawOutliner = mpModel->GetDrawOutliner(); pOutliner->SetCalcFieldValueHdl( aDrawOutliner.GetCalcFieldValueHdl() ); - maActiveOutliners.insert(pOutliner); + maActiveOutliners.insert(pOutliner.get()); } return pOutliner; diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx index 0e2b612c85e4..ecdd0a233be5 100644 --- a/svx/source/table/tablecontroller.cxx +++ b/svx/source/table/tablecontroller.cxx @@ -1907,12 +1907,12 @@ void SvxTableController::EditCell(const CellPos& rPos, vcl::Window* pWindow, Tbl // create new outliner, owner will be the SdrObjEditView SdrModel& rModel(rTableObj.getSdrModelFromSdrObject()); - SdrOutliner* pOutl(SdrMakeOutliner(OutlinerMode::OutlineObject, rModel)); + std::unique_ptr<SdrOutliner> pOutl(SdrMakeOutliner(OutlinerMode::OutlineObject, rModel)); if (pOutl && rTableObj.IsVerticalWriting()) pOutl->SetVertical( true ); - if (mrView.SdrBeginTextEdit(&rTableObj, pPV, pWindow, true, pOutl)) + if (mrView.SdrBeginTextEdit(&rTableObj, pPV, pWindow, true, pOutl.release())) { maCursorLastPos = maCursorFirstPos = rPos; diff --git a/svx/source/unodraw/unoshtxt.cxx b/svx/source/unodraw/unoshtxt.cxx index 9fdefcbb5791..779d7c066e8e 100644 --- a/svx/source/unodraw/unoshtxt.cxx +++ b/svx/source/unodraw/unoshtxt.cxx @@ -516,7 +516,7 @@ SvxTextForwarder* SvxTextEditSourceImpl::GetBackgroundTextForwarder() if( pTextObj && pTextObj->IsTextFrame() && pTextObj->GetTextKind() == OBJ_OUTLINETEXT ) nOutlMode = OutlinerMode::OutlineObject; - mpOutliner = mpModel->createOutliner( nOutlMode ); + mpOutliner = mpModel->createOutliner( nOutlMode ).release(); // Do the setup after outliner creation, would be useless otherwise if( HasView() ) diff --git a/sw/source/uibase/uiview/viewdraw.cxx b/sw/source/uibase/uiview/viewdraw.cxx index b80b3008be62..208ce460db6b 100644 --- a/sw/source/uibase/uiview/viewdraw.cxx +++ b/sw/source/uibase/uiview/viewdraw.cxx @@ -503,7 +503,7 @@ bool SwView::BeginTextEdit(SdrObject* pObj, SdrPageView* pPV, vcl::Window* pWin, { SwWrtShell *pSh = &GetWrtShell(); SdrView *pSdrView = pSh->GetDrawView(); - SdrOutliner* pOutliner = ::SdrMakeOutliner(OutlinerMode::TextObject, *pSdrView->GetModel()); + std::unique_ptr<SdrOutliner> pOutliner = ::SdrMakeOutliner(OutlinerMode::TextObject, *pSdrView->GetModel()); uno::Reference< linguistic2::XSpellChecker1 > xSpell( ::GetSpellChecker() ); if (pOutliner) { @@ -511,7 +511,7 @@ bool SwView::BeginTextEdit(SdrObject* pObj, SdrPageView* pPV, vcl::Window* pWin, pOutliner->SetSpeller(xSpell); uno::Reference<linguistic2::XHyphenator> xHyphenator( ::GetHyphenator() ); pOutliner->SetHyphenator( xHyphenator ); - pSh->SetCalcFieldValueHdl(pOutliner); + pSh->SetCalcFieldValueHdl(pOutliner.get()); EEControlBits nCntrl = pOutliner->GetControlWord(); nCntrl |= EEControlBits::ALLOWBIGOBJS; @@ -562,7 +562,7 @@ bool SwView::BeginTextEdit(SdrObject* pObj, SdrPageView* pPV, vcl::Window* pWin, // set in each case, thus it will be correct for all objects static_cast<SdrTextObj*>(pToBeActivated)->SetTextEditOffset(aNewTextEditOffset); - bool bRet(pSdrView->SdrBeginTextEdit( pToBeActivated, pPV, pWin, true, pOutliner, nullptr, false, false, false )); + bool bRet(pSdrView->SdrBeginTextEdit( pToBeActivated, pPV, pWin, true, pOutliner.release(), nullptr, false, false, false )); // #i7672# // Since SdrBeginTextEdit actually creates the OutlinerView and thus also |