[Libreoffice-commits] core.git: 3 commits - include/vcl vcl/inc vcl/source
Noel Grandin
noel.grandin at collabora.co.uk
Tue Apr 24 06:23:04 UTC 2018
include/vcl/vclmedit.hxx | 8 ++++----
vcl/inc/printdlg.hxx | 2 +-
vcl/source/edit/textdat2.hxx | 18 +++++++++---------
vcl/source/edit/textdata.cxx | 28 ++++++++++++----------------
vcl/source/edit/texteng.cxx | 18 +++++++++---------
vcl/source/edit/vclmedit.cxx | 12 +++++-------
vcl/source/window/printdlg.cxx | 5 ++---
7 files changed, 42 insertions(+), 49 deletions(-)
New commits:
commit 27bc42d77a71118b9e7cf11132ea4e47d42b676c
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Mon Apr 23 10:18:31 2018 +0200
loplugin:useuniqueptr in TextWindow
Change-Id: I66c966f79d56be5dfc1422fa3de52d9bf4411ff2
Reviewed-on: https://gerrit.libreoffice.org/53348
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/vcl/vclmedit.hxx b/include/vcl/vclmedit.hxx
index 6b4b0b8fcebb..eaffca059a0d 100644
--- a/include/vcl/vclmedit.hxx
+++ b/include/vcl/vclmedit.hxx
@@ -36,8 +36,8 @@ class TextWindow : public vcl::Window
{
private:
VclPtr<Edit> mxParent;
- ExtTextEngine* mpExtTextEngine;
- TextView* mpExtTextView;
+ std::unique_ptr<ExtTextEngine> mpExtTextEngine;
+ std::unique_ptr<TextView> mpExtTextView;
bool mbInMBDown;
bool mbFocusSelectionHide;
@@ -50,8 +50,8 @@ public:
virtual ~TextWindow() override;
virtual void dispose() override;
- ExtTextEngine* GetTextEngine() const { return mpExtTextEngine; }
- TextView* GetTextView() const { return mpExtTextView; }
+ ExtTextEngine* GetTextEngine() const { return mpExtTextEngine.get(); }
+ TextView* GetTextView() const { return mpExtTextView.get(); }
virtual void MouseMove( const MouseEvent& rMEvt ) override;
virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
diff --git a/vcl/source/edit/vclmedit.cxx b/vcl/source/edit/vclmedit.cxx
index 32a2b209696e..18a48eddb933 100644
--- a/vcl/source/edit/vclmedit.cxx
+++ b/vcl/source/edit/vclmedit.cxx
@@ -672,13 +672,13 @@ TextWindow::TextWindow(Edit* pParent)
SetPointer( Pointer( PointerStyle::Text ) );
- mpExtTextEngine = new ExtTextEngine;
+ mpExtTextEngine.reset(new ExtTextEngine);
mpExtTextEngine->SetMaxTextLen(EDIT_NOLIMIT);
if( pParent->GetStyle() & WB_BORDER )
mpExtTextEngine->SetLeftMargin( 2 );
mpExtTextEngine->SetLocale( GetSettings().GetLanguageTag().getLocale() );
- mpExtTextView = new TextView( mpExtTextEngine, this );
- mpExtTextEngine->InsertView( mpExtTextView );
+ mpExtTextView.reset(new TextView( mpExtTextEngine.get(), this ));
+ mpExtTextEngine->InsertView( mpExtTextView.get() );
mpExtTextEngine->EnableUndo( true );
mpExtTextView->ShowCursor();
@@ -695,10 +695,8 @@ TextWindow::~TextWindow()
void TextWindow::dispose()
{
mxParent.clear();
- delete mpExtTextView;
- mpExtTextView = nullptr;
- delete mpExtTextEngine;
- mpExtTextEngine = nullptr;
+ mpExtTextView.reset();
+ mpExtTextEngine.reset();
Window::dispose();
}
commit 148b84160667ed3ec74c8767f6e62567479488f9
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Mon Apr 23 09:51:55 2018 +0200
loplugin:useuniqueptr in TETextPortionList
Change-Id: Ia4ba670cc524a0103dbab0880931279bafd0925e
Reviewed-on: https://gerrit.libreoffice.org/53347
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/vcl/source/edit/textdat2.hxx b/vcl/source/edit/textdat2.hxx
index 27b110b6e322..29589aadcffd 100644
--- a/vcl/source/edit/textdat2.hxx
+++ b/vcl/source/edit/textdat2.hxx
@@ -72,7 +72,7 @@ public:
class TETextPortionList
{
private:
- std::vector<TETextPortion*> maPortions;
+ std::vector<std::unique_ptr<TETextPortion>> maPortions;
public:
static constexpr auto npos = std::numeric_limits<std::size_t>::max();
@@ -81,16 +81,16 @@ public:
~TETextPortionList();
TETextPortion* operator[]( std::size_t nPos );
- std::vector<TETextPortion*>::iterator begin();
- std::vector<TETextPortion*>::const_iterator begin() const;
- std::vector<TETextPortion*>::iterator end();
- std::vector<TETextPortion*>::const_iterator end() const;
+ std::vector<std::unique_ptr<TETextPortion>>::iterator begin();
+ std::vector<std::unique_ptr<TETextPortion>>::const_iterator begin() const;
+ std::vector<std::unique_ptr<TETextPortion>>::iterator end();
+ std::vector<std::unique_ptr<TETextPortion>>::const_iterator end() const;
bool empty() const;
std::size_t size() const;
- std::vector<TETextPortion*>::iterator erase( const std::vector<TETextPortion*>::iterator& aIter );
- std::vector<TETextPortion*>::iterator insert( const std::vector<TETextPortion*>::iterator& aIter,
- TETextPortion* pTP );
- void push_back( TETextPortion* pTP );
+ std::vector<std::unique_ptr<TETextPortion>>::iterator erase( const std::vector<std::unique_ptr<TETextPortion>>::iterator& aIter );
+ std::vector<std::unique_ptr<TETextPortion>>::iterator insert( const std::vector<std::unique_ptr<TETextPortion>>::iterator& aIter,
+ std::unique_ptr<TETextPortion> pTP );
+ void push_back( std::unique_ptr<TETextPortion> pTP );
void Reset();
std::size_t FindPortion( sal_Int32 nCharPos, sal_Int32& rPortionStart, bool bPreferStartingPortion = false );
diff --git a/vcl/source/edit/textdata.cxx b/vcl/source/edit/textdata.cxx
index bc8302174cab..6f048175b5f2 100644
--- a/vcl/source/edit/textdata.cxx
+++ b/vcl/source/edit/textdata.cxx
@@ -60,25 +60,25 @@ TETextPortionList::~TETextPortionList()
TETextPortion* TETextPortionList::operator[]( std::size_t nPos )
{
- return maPortions[ nPos ];
+ return maPortions[ nPos ].get();
}
-std::vector<TETextPortion*>::iterator TETextPortionList::begin()
+std::vector<std::unique_ptr<TETextPortion>>::iterator TETextPortionList::begin()
{
return maPortions.begin();
}
-std::vector<TETextPortion*>::const_iterator TETextPortionList::begin() const
+std::vector<std::unique_ptr<TETextPortion>>::const_iterator TETextPortionList::begin() const
{
return maPortions.begin();
}
-std::vector<TETextPortion*>::iterator TETextPortionList::end()
+std::vector<std::unique_ptr<TETextPortion>>::iterator TETextPortionList::end()
{
return maPortions.end();
}
-std::vector<TETextPortion*>::const_iterator TETextPortionList::end() const
+std::vector<std::unique_ptr<TETextPortion>>::const_iterator TETextPortionList::end() const
{
return maPortions.end();
}
@@ -93,34 +93,30 @@ std::size_t TETextPortionList::size() const
return maPortions.size();
}
-std::vector<TETextPortion*>::iterator TETextPortionList::erase( const std::vector<TETextPortion*>::iterator& aIter )
+std::vector<std::unique_ptr<TETextPortion>>::iterator TETextPortionList::erase( const std::vector<std::unique_ptr<TETextPortion>>::iterator& aIter )
{
return maPortions.erase( aIter );
}
-std::vector<TETextPortion*>::iterator TETextPortionList::insert( const std::vector<TETextPortion*>::iterator& aIter,
- TETextPortion* pTP )
+std::vector<std::unique_ptr<TETextPortion>>::iterator TETextPortionList::insert( const std::vector<std::unique_ptr<TETextPortion>>::iterator& aIter,
+ std::unique_ptr<TETextPortion> pTP )
{
- return maPortions.insert( aIter, pTP );
+ return maPortions.insert( aIter, std::move(pTP) );
}
-void TETextPortionList::push_back( TETextPortion* pTP )
+void TETextPortionList::push_back( std::unique_ptr<TETextPortion> pTP )
{
- maPortions.push_back( pTP );
+ maPortions.push_back( std::move(pTP) );
}
void TETextPortionList::Reset()
{
- for ( auto pTP : maPortions )
- delete pTP;
maPortions.clear();
}
void TETextPortionList::DeleteFromPortion( std::size_t nDelFrom )
{
SAL_WARN_IF( ( nDelFrom >= maPortions.size() ) && ( (nDelFrom != 0) || (maPortions.size() != 0) ), "vcl", "DeleteFromPortion: Out of range" );
- for ( auto it = maPortions.begin() + nDelFrom; it != maPortions.end(); ++it )
- delete *it;
maPortions.erase( maPortions.begin() + nDelFrom, maPortions.end() );
}
@@ -130,7 +126,7 @@ std::size_t TETextPortionList::FindPortion( sal_Int32 nCharPos, sal_Int32& nPort
sal_Int32 nTmpPos = 0;
for ( std::size_t nPortion = 0; nPortion < maPortions.size(); nPortion++ )
{
- TETextPortion* pPortion = maPortions[ nPortion ];
+ TETextPortion* pPortion = maPortions[ nPortion ].get();
nTmpPos += pPortion->GetLen();
if ( nTmpPos >= nCharPos )
{
diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx
index e382a514ee4c..0884040c94b1 100644
--- a/vcl/source/edit/texteng.cxx
+++ b/vcl/source/edit/texteng.cxx
@@ -1612,9 +1612,9 @@ void TextEngine::CreateAndInsertEmptyLine( sal_uInt32 nPara )
bool bLineBreak = !pNode->GetText().isEmpty();
- TETextPortion* pDummyPortion = new TETextPortion( 0 );
+ std::unique_ptr<TETextPortion> pDummyPortion(new TETextPortion( 0 ));
pDummyPortion->GetWidth() = 0;
- pTEParaPortion->GetTextPortions().push_back( pDummyPortion );
+ pTEParaPortion->GetTextPortions().push_back( std::move(pDummyPortion) );
if ( bLineBreak )
{
@@ -1704,8 +1704,8 @@ std::size_t TextEngine::SplitTextPortion( sal_uInt32 nPara, sal_Int32 nPos )
const sal_Int32 nOverlapp = nTmpPos - nPos;
pTextPortion->GetLen() -= nOverlapp;
- TETextPortion* pNewPortion = new TETextPortion( nOverlapp );
- pTEParaPortion->GetTextPortions().insert( pTEParaPortion->GetTextPortions().begin() + nSplitPortion + 1, pNewPortion );
+ std::unique_ptr<TETextPortion> pNewPortion( new TETextPortion( nOverlapp ) );
+ pTEParaPortion->GetTextPortions().insert( pTEParaPortion->GetTextPortions().begin() + nSplitPortion + 1, std::move(pNewPortion) );
pTextPortion->GetWidth() = CalcTextWidth( nPara, nPos-pTextPortion->GetLen(), pTextPortion->GetLen() );
return nSplitPortion;
@@ -1797,8 +1797,8 @@ void TextEngine::CreateTextPortions( sal_uInt32 nPara, sal_Int32 nStartPos )
std::set<sal_Int32>::iterator nextIt = aPositionsIt;
for ( ++nextIt; nextIt != aPositions.end(); ++aPositionsIt, ++nextIt )
{
- TETextPortion* pNew = new TETextPortion( *nextIt - *aPositionsIt );
- pTEParaPortion->GetTextPortions().push_back( pNew );
+ std::unique_ptr<TETextPortion> pNew( new TETextPortion( *nextIt - *aPositionsIt ) );
+ pTEParaPortion->GetTextPortions().push_back( std::move(pNew) );
}
}
OSL_ENSURE(pTEParaPortion->GetTextPortions().size(), "CreateTextPortions: No Portions?!");
@@ -1835,8 +1835,8 @@ void TextEngine::RecalcTextPortion( sal_uInt32 nPara, sal_Int32 nStartPos, sal_I
}
else
{
- TETextPortion* pNewPortion = new TETextPortion( nNewChars );
- pTEParaPortion->GetTextPortions().insert( pTEParaPortion->GetTextPortions().begin() + nNewPortionPos, pNewPortion );
+ std::unique_ptr<TETextPortion> pNewPortion(new TETextPortion( nNewChars ));
+ pTEParaPortion->GetTextPortions().insert( pTEParaPortion->GetTextPortions().begin() + nNewPortionPos, std::move(pNewPortion) );
}
}
else
@@ -2112,7 +2112,7 @@ bool TextEngine::CreateLines( sal_uInt32 nPara )
{
// check if deleting across Portion border
sal_Int32 nPos = 0;
- for ( const auto pTP : pTEParaPortion->GetTextPortions() )
+ for ( const auto & pTP : pTEParaPortion->GetTextPortions() )
{
// there must be no Start/End in the deleted region
nPos += pTP->GetLen();
commit 447d4e1366cf176c6ff2c6eebf3cf8a65745a7dc
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Mon Apr 23 09:46:14 2018 +0200
loplugin:useuniqueptr in PrintDialog
Change-Id: Ia40e48b2e57624bb59bc0dcc0927bf673581081d
Reviewed-on: https://gerrit.libreoffice.org/53346
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx
index f8c799e7ff97..b16d91cad1f6 100644
--- a/vcl/inc/printdlg.hxx
+++ b/vcl/inc/printdlg.hxx
@@ -168,7 +168,7 @@ namespace vcl
void storeToSettings();
};
- VclBuilder* mpCustomOptionsUIBuilder;
+ std::unique_ptr<VclBuilder> mpCustomOptionsUIBuilder;
std::shared_ptr<PrinterController> maPController;
VclPtr<TabControl> mpTabCtrl;
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index a7ef48c01e83..084763fa934b 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -798,7 +798,7 @@ PrintDialog::~PrintDialog()
void PrintDialog::dispose()
{
- delete mpCustomOptionsUIBuilder;
+ mpCustomOptionsUIBuilder.reset();
mpTabCtrl.clear();
mpPreviewWindow.clear();
mpPageEdit.clear();
@@ -908,8 +908,7 @@ void PrintDialog::setupOptionalUI()
vcl::Window *pCustom = get<vcl::Window>("customcontents");
- delete mpCustomOptionsUIBuilder;
- mpCustomOptionsUIBuilder = new VclBuilder(pCustom, getUIRootDir(), sOptionsUIFile);
+ mpCustomOptionsUIBuilder.reset(new VclBuilder(pCustom, getUIRootDir(), sOptionsUIFile));
vcl::Window *pWindow = mpCustomOptionsUIBuilder->get_widget_root();
pWindow->Show();
continue;
More information about the Libreoffice-commits
mailing list