[Libreoffice-commits] core.git: extensions/source
Stephan Bergmann
sbergman at redhat.com
Wed Mar 8 16:57:49 UTC 2017
extensions/source/scanner/grid.cxx | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
New commits:
commit ad5432935de1abcb2fbff732d7e2eb2782cc0a6a
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Mar 8 14:43:56 2017 +0100
Clean up uses of integer types
Change-Id: Iaf07f989776c80abd998977e0a2a67f503d0860e
Reviewed-on: https://gerrit.libreoffice.org/34975
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/extensions/source/scanner/grid.cxx b/extensions/source/scanner/grid.cxx
index 4f8c285..f7d08a9 100644
--- a/extensions/source/scanner/grid.cxx
+++ b/extensions/source/scanner/grid.cxx
@@ -29,6 +29,7 @@
#include <vcl/builderfactory.hxx>
#include <algorithm>
+#include <limits>
#include <memory>
class GridWindow : public vcl::Window
@@ -87,8 +88,10 @@ class GridWindow : public vcl::Window
bool m_bCutValues;
// stuff for handles
- std::vector< impHandle > m_aHandles;
- sal_uInt32 m_nDragIndex;
+ using Handles = std::vector<impHandle>;
+ static constexpr auto npos = std::numeric_limits<Handles::size_type>::max();
+ Handles m_aHandles;
+ Handles::size_type m_nDragIndex;
BitmapEx m_aMarkerBitmap;
@@ -151,7 +154,7 @@ GridWindow::GridWindow(vcl::Window* pParent)
, m_BmOffY(0)
, m_bCutValues(false)
, m_aHandles()
- , m_nDragIndex(0xffffffff)
+ , m_nDragIndex(npos)
{
SetMapMode(MapMode(MapUnit::MapPixel));
}
@@ -536,11 +539,11 @@ void GridWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRec
void GridWindow::MouseMove( const MouseEvent& rEvt )
{
- if( rEvt.GetButtons() == MOUSE_LEFT && m_nDragIndex != 0xffffffff )
+ if( rEvt.GetButtons() == MOUSE_LEFT && m_nDragIndex != npos )
{
Point aPoint( rEvt.GetPosPixel() );
- if( m_nDragIndex == 0L || m_nDragIndex == m_aHandles.size() - 1L)
+ if( m_nDragIndex == 0 || m_nDragIndex == m_aHandles.size() - 1L)
{
aPoint.X() = m_aHandles[m_nDragIndex].maPos.X();
}
@@ -571,9 +574,9 @@ void GridWindow::MouseButtonUp( const MouseEvent& rEvt )
{
if( rEvt.GetButtons() == MOUSE_LEFT )
{
- if( m_nDragIndex != 0xffffffff )
+ if( m_nDragIndex != npos )
{
- m_nDragIndex = 0xffffffff;
+ m_nDragIndex = npos;
computeNew();
Invalidate(m_aGridArea);
}
@@ -585,9 +588,9 @@ void GridWindow::MouseButtonUp( const MouseEvent& rEvt )
void GridWindow::MouseButtonDown( const MouseEvent& rEvt )
{
Point aPoint( rEvt.GetPosPixel() );
- sal_uInt32 nMarkerIndex = 0xffffffff;
+ Handles::size_type nMarkerIndex = npos;
- for(sal_uInt32 a(0L); nMarkerIndex == 0xffffffff && a < m_aHandles.size(); a++)
+ for(Handles::size_type a(0L); nMarkerIndex == npos && a < m_aHandles.size(); a++)
{
if(m_aHandles[a].isHit(*this, aPoint))
{
@@ -598,7 +601,7 @@ void GridWindow::MouseButtonDown( const MouseEvent& rEvt )
if( rEvt.GetButtons() == MOUSE_LEFT )
{
// user wants to drag a button
- if( nMarkerIndex != 0xffffffff )
+ if( nMarkerIndex != npos )
{
m_nDragIndex = nMarkerIndex;
}
@@ -606,13 +609,13 @@ void GridWindow::MouseButtonDown( const MouseEvent& rEvt )
else if( rEvt.GetButtons() == MOUSE_RIGHT )
{
// user wants to add/delete a button
- if( nMarkerIndex != 0xffffffff )
+ if( nMarkerIndex != npos )
{
if( nMarkerIndex != 0L && nMarkerIndex != m_aHandles.size() - 1L)
{
// delete marker under mouse
if( m_nDragIndex == nMarkerIndex )
- m_nDragIndex = 0xffffffff;
+ m_nDragIndex = npos;
m_aHandles.erase(m_aHandles.begin() + nMarkerIndex);
}
More information about the Libreoffice-commits
mailing list