summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2017-12-11 22:28:32 +0900
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-12-12 07:56:40 +0100
commitde37c379847afcef8ddf3f03f84cca1b61104851 (patch)
treeb2add14a4d8c1628d9de7cddaabb51ffef9ae1d6 /svtools
parentd905c783e7f20ea1f18600252cd92c02ea7f91f7 (diff)
svtools: Simplify BrowserDataWin with std::unique_ptr
Change-Id: Ib63b60c1f5326cfc1b163164ae5a783ea8ba1919 Reviewed-on: https://gerrit.libreoffice.org/46256 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/brwbox/brwbox2.cxx15
-rw-r--r--svtools/source/brwbox/datwin.cxx18
-rw-r--r--svtools/source/brwbox/datwin.hxx5
3 files changed, 15 insertions, 23 deletions
diff --git a/svtools/source/brwbox/brwbox2.cxx b/svtools/source/brwbox/brwbox2.cxx
index f1030cd9ec31..8ff0f3e860e5 100644
--- a/svtools/source/brwbox/brwbox2.cxx
+++ b/svtools/source/brwbox/brwbox2.cxx
@@ -27,6 +27,7 @@
#include <tools/multisel.hxx>
#include <tools/fract.hxx>
#include <algorithm>
+#include <memory>
using namespace ::com::sun::star::datatransfer;
@@ -234,7 +235,7 @@ void BrowseBox::ToggleSelection()
bNotToggleSel = true;
// accumulate areas of rows to highlight
- RectangleList aHighlightList;
+ std::vector<tools::Rectangle> aHighlightList;
long nLastRowInRect = 0; // for the CFront
// don't highlight handle column
@@ -257,20 +258,18 @@ void BrowseBox::ToggleSelection()
Point( nOfsX, (nRow-nTopRow)*GetDataRowHeight() ),
Size( pDataWin->GetSizePixel().Width(), GetDataRowHeight() ) );
if ( aHighlightList.size() && nLastRowInRect == ( nRow - 1 ) )
- aHighlightList[ 0 ]->Union( aAddRect );
+ aHighlightList[ 0 ].Union( aAddRect );
else
- aHighlightList.insert( aHighlightList.begin(), new tools::Rectangle( aAddRect ) );
+ aHighlightList.emplace( aHighlightList.begin(), aAddRect );
nLastRowInRect = nRow;
}
// unhighlight the old selection (if any)
- for ( size_t i = aHighlightList.size(); i > 0; )
+ while ( !aHighlightList.empty() )
{
- tools::Rectangle *pRect = aHighlightList[ --i ];
- pDataWin->Invalidate( *pRect );
- delete pRect;
+ pDataWin->Invalidate( aHighlightList.back() );
+ aHighlightList.pop_back();
}
- aHighlightList.clear();
// unhighlight old column selection (if any)
for ( long nColId = pColSel ? pColSel->FirstSelected() : BROWSER_ENDOFSELECTION;
diff --git a/svtools/source/brwbox/datwin.cxx b/svtools/source/brwbox/datwin.cxx
index 2378e91ed4f5..69d6501a24da 100644
--- a/svtools/source/brwbox/datwin.cxx
+++ b/svtools/source/brwbox/datwin.cxx
@@ -214,8 +214,6 @@ void BrowserDataWin::dispose()
{
bInDtor = true;
- for (tools::Rectangle* i : aInvalidRegion)
- delete i;
aInvalidRegion.clear();
pHeaderBar.clear();
pEventWin.clear();
@@ -283,7 +281,7 @@ void BrowserDataWin::Paint(vcl::RenderContext& rRenderContext, const tools::Rect
{
if (bInPaint)
{
- aInvalidRegion.push_back(new tools::Rectangle(rRect));
+ aInvalidRegion.emplace_back(rRect);
return;
}
bInPaint = true;
@@ -293,7 +291,7 @@ void BrowserDataWin::Paint(vcl::RenderContext& rRenderContext, const tools::Rect
}
else
{
- aInvalidRegion.push_back(new tools::Rectangle(rRect));
+ aInvalidRegion.emplace_back(rRect);
}
}
@@ -637,10 +635,8 @@ void BrowserDataWin::SetUpdateMode( bool bMode )
void BrowserDataWin::DoOutstandingInvalidations()
{
- for (tools::Rectangle* i : aInvalidRegion) {
- Control::Invalidate( *i );
- delete i;
- }
+ for (auto& rRect : aInvalidRegion)
+ Control::Invalidate( rRect );
aInvalidRegion.clear();
}
@@ -649,10 +645,8 @@ void BrowserDataWin::Invalidate( InvalidateFlags nFlags )
{
if ( !GetUpdateMode() )
{
- for (tools::Rectangle* i : aInvalidRegion)
- delete i;
aInvalidRegion.clear();
- aInvalidRegion.push_back( new tools::Rectangle( Point( 0, 0 ), GetOutputSizePixel() ) );
+ aInvalidRegion.emplace_back( Point( 0, 0 ), GetOutputSizePixel() );
}
else
Window::Invalidate( nFlags );
@@ -662,7 +656,7 @@ void BrowserDataWin::Invalidate( InvalidateFlags nFlags )
void BrowserDataWin::Invalidate( const tools::Rectangle& rRect, InvalidateFlags nFlags )
{
if ( !GetUpdateMode() )
- aInvalidRegion.push_back( new tools::Rectangle( rRect ) );
+ aInvalidRegion.emplace_back( rRect );
else
Window::Invalidate( rRect, nFlags );
}
diff --git a/svtools/source/brwbox/datwin.hxx b/svtools/source/brwbox/datwin.hxx
index 81366e31548e..ab8ba930d193 100644
--- a/svtools/source/brwbox/datwin.hxx
+++ b/svtools/source/brwbox/datwin.hxx
@@ -25,13 +25,12 @@
#include <vcl/timer.hxx>
#include <vcl/image.hxx>
#include <svtools/transfer.hxx>
+#include <memory>
#include <vector>
#define MIN_COLUMNWIDTH 2
-typedef ::std::vector< tools::Rectangle* > RectangleList;
-
class ButtonFrame
{
@@ -101,7 +100,7 @@ public:
OUString aRealRowCount; // to show in VScrollBar
- RectangleList aInvalidRegion; // invalidated Rectangles during !UpdateMode
+ std::vector<tools::Rectangle> aInvalidRegion; // invalidated Rectangles during !UpdateMode
bool bInPaint; // TRUE while in Paint
bool bInCommand; // TRUE while in Command
bool bNoScrollBack; // only scroll forward