summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-03-06 20:47:17 +0100
committerTomaž Vajngerl <quikee@gmail.com>2020-03-06 23:23:00 +0100
commit5699f1e0cb782003a1bb7ff3823b0b1c41819a07 (patch)
tree525e029fc862e9e9f67d732b28c75adccf11f1e2 /svx
parent54c6fcff19fdf9e9074bdf7b7a3f68ec398c51df (diff)
basegfx: B2DTuple replace operator[] with "get" and Axis2D enum
opertaor[] was used for index access of of x and y variables where 0 is x and 1 is y - similar like access to an array with 2 elements. This comes in handy when you write generic code where the algorithm is the same for x and y, but using index access operator doesn't look clean and is potentially dangerous. We know we only have 2 options (o and 1), but an index access allows for more. A solution to this is to have a normal "get" method, with an enum as parameter (Axis2D), which can only have values X or Y. Change-Id: I3f98d0149214808a336f25599350a78436236827 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90133 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/table/tablehandles.cxx10
1 files changed, 5 insertions, 5 deletions
diff --git a/svx/source/table/tablehandles.cxx b/svx/source/table/tablehandles.cxx
index daaf45c8832c..2760755421c1 100644
--- a/svx/source/table/tablehandles.cxx
+++ b/svx/source/table/tablehandles.cxx
@@ -116,17 +116,17 @@ void TableEdgeHdl::getPolyPolygon(basegfx::B2DPolyPolygon& rVisible, basegfx::B2
if( pDrag )
{
- int n = mbHorizontal ? 1 : 0;
- aOffset[n] = aOffset[n] + GetValidDragOffset( *pDrag );
+ basegfx::Axis2D eDragAxis = mbHorizontal ? basegfx::Axis2D::Y : basegfx::Axis2D::X;
+ aOffset.set(eDragAxis, aOffset.get(eDragAxis) + GetValidDragOffset( *pDrag ));
}
basegfx::B2DPoint aStart(aOffset), aEnd(aOffset);
- int nPos = mbHorizontal ? 0 : 1;
+ basegfx::Axis2D eAxis = mbHorizontal ? basegfx::Axis2D::X : basegfx::Axis2D::Y;
for( const TableEdge& aEdge : maEdges )
{
- aStart[nPos] = aOffset[nPos] + aEdge.mnStart;
- aEnd[nPos] = aOffset[nPos] + aEdge.mnEnd;
+ aStart.set(eAxis, aOffset.get(eAxis) + aEdge.mnStart);
+ aEnd.set(eAxis, aOffset.get(eAxis) + aEdge.mnEnd);
basegfx::B2DPolygon aPolygon;
aPolygon.append( aStart );