From fe1322f8d009e45ef598ec9a8a3af8b8f738eb55 Mon Sep 17 00:00:00 2001 From: Matteo Casalin Date: Sun, 17 Feb 2019 23:56:43 +0100 Subject: Simplify ShapeAnchor::importVmlAnchor Change-Id: Ibee7914a0c5027b4679163e6a5108f646ad66546 Reviewed-on: https://gerrit.libreoffice.org/68122 Tested-by: Jenkins Reviewed-by: Matteo Casalin --- sc/source/filter/oox/drawingbase.cxx | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/sc/source/filter/oox/drawingbase.cxx b/sc/source/filter/oox/drawingbase.cxx index d3ea89df7b4e..d1c670d00537 100644 --- a/sc/source/filter/oox/drawingbase.cxx +++ b/sc/source/filter/oox/drawingbase.cxx @@ -152,23 +152,27 @@ void ShapeAnchor::importVmlAnchor( const OUString& rAnchor ) meAnchorType = ANCHOR_VML; meCellAnchorType = CellAnchorType::Pixel; - ::std::vector< OUString > aTokens; - sal_Int32 nIndex = 0; - while( nIndex >= 0 ) - aTokens.push_back( rAnchor.getToken( 0, ',', nIndex ).trim() ); + sal_Int32 nValues[8]; + sal_Int32 nI{ 0 }; - OSL_ENSURE( aTokens.size() >= 8, "ShapeAnchor::importVmlAnchor - missing anchor tokens" ); - if( aTokens.size() >= 8 ) + for(sal_Int32 nIndex{ 0 }; nIndex>=0;) { - maFrom.mnCol = aTokens[ 0 ].toInt32(); - maFrom.mnColOffset = aTokens[ 1 ].toInt32(); - maFrom.mnRow = aTokens[ 2 ].toInt32(); - maFrom.mnRowOffset = aTokens[ 3 ].toInt32(); - maTo.mnCol = aTokens[ 4 ].toInt32(); - maTo.mnColOffset = aTokens[ 5 ].toInt32(); - maTo.mnRow = aTokens[ 6 ].toInt32(); - maTo.mnRowOffset = aTokens[ 7 ].toInt32(); + nValues[nI] = rAnchor.getToken( 0, ',', nIndex ).toInt32(); + if (++nI==8) + { + maFrom.mnCol = nValues[0]; + maFrom.mnColOffset = nValues[1]; + maFrom.mnRow = nValues[2]; + maFrom.mnRowOffset = nValues[3]; + maTo.mnCol = nValues[4]; + maTo.mnColOffset = nValues[5]; + maTo.mnRow = nValues[6]; + maTo.mnRowOffset = nValues[7]; + return; + } } + + OSL_FAIL("ShapeAnchor::importVmlAnchor - missing anchor tokens" ); } bool ShapeAnchor::isAnchorValid() const -- cgit