oox/source/drawingml/chart/chartconverter.cxx |   38 ++++++++++----------------
 1 file changed, 16 insertions(+), 22 deletions(-)

New commits:
commit ab88eb539b012c9a54b4b20b4cc564a2bf3cd259
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Wed Aug 1 10:42:16 2018 +0100
Commit:     Michael Stahl <michael.st...@cib.de>
CommitDate: Fri Aug 3 10:45:01 2018 +0200

    forcepoint#59 the "matrix" is always one row in height
    
    so it can be a vector instead, and by using vector::at() instead of
    matrix::at() vector bounds checking is performed, unlike matrix::at()
    which does no checking
    
    Change-Id: Ic767c2dd884bffbf1cdff65c0980b21170612f4d
    Reviewed-on: https://gerrit.libreoffice.org/58397
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@cib.de>

diff --git a/oox/source/drawingml/chart/chartconverter.cxx 
b/oox/source/drawingml/chart/chartconverter.cxx
index 4992758396ac..f86ea8adb760 100644
--- a/oox/source/drawingml/chart/chartconverter.cxx
+++ b/oox/source/drawingml/chart/chartconverter.cxx
@@ -44,7 +44,6 @@ using ::oox::core::XmlFilterBase;
 
 static const sal_Unicode API_TOKEN_ARRAY_OPEN      = '{';
 static const sal_Unicode API_TOKEN_ARRAY_CLOSE     = '}';
-static const sal_Unicode API_TOKEN_ARRAY_ROWSEP    = '|';
 static const sal_Unicode API_TOKEN_ARRAY_COLSEP    = ';';
 
 // Code similar to oox/source/xls/formulabase.cxx
@@ -57,28 +56,23 @@ static OUString lclGenerateApiString( const OUString& 
rString )
     return "\"" + aRetString + "\"";
 }
 
-static OUString lclGenerateApiArray( const Matrix< Any >& rMatrix )
+static OUString lclGenerateApiArray(const std::vector<Any>& rRow)
 {
-    OSL_ENSURE( !rMatrix.empty(), "ChartConverter::lclGenerateApiArray - 
missing matrix values" );
+    OSL_ENSURE( !rRow.empty(), "ChartConverter::lclGenerateApiArray - missing 
matrix values" );
     OUStringBuffer aBuffer;
     aBuffer.append( API_TOKEN_ARRAY_OPEN );
-    for( size_t nRow = 0, nHeight = rMatrix.height(); nRow < nHeight; ++nRow )
+    for (auto aBeg = rRow.begin(), aIt = aBeg, aEnd = rRow.end(); aIt != aEnd; 
++aIt)
     {
-        if( nRow > 0 )
-            aBuffer.append( API_TOKEN_ARRAY_ROWSEP );
-        for( Matrix< Any >::const_iterator aBeg = rMatrix.row_begin( nRow ), 
aIt = aBeg, aEnd = rMatrix.row_end( nRow ); aIt != aEnd; ++aIt )
-        {
-            double fValue = 0.0;
-            OUString aString;
-            if( aIt != aBeg )
-                aBuffer.append( API_TOKEN_ARRAY_COLSEP );
-            if( *aIt >>= fValue )
-                aBuffer.append( fValue );
-            else if( *aIt >>= aString )
-                aBuffer.append( lclGenerateApiString( aString ) );
-            else
-                aBuffer.append( "\"\"" );
-        }
+        double fValue = 0.0;
+        OUString aString;
+        if( aIt != aBeg )
+            aBuffer.append( API_TOKEN_ARRAY_COLSEP );
+        if( *aIt >>= fValue )
+            aBuffer.append( fValue );
+        else if( *aIt >>= aString )
+            aBuffer.append( lclGenerateApiString( aString ) );
+        else
+            aBuffer.append( "\"\"" );
     }
     aBuffer.append( API_TOKEN_ARRAY_CLOSE );
     return aBuffer.makeStringAndClear();
@@ -133,11 +127,11 @@ Reference< XDataSequence > 
ChartConverter::createDataSequence(
         if( !rDataSeq.maData.empty() )
         {
             // create a single-row array from constant source data
-            Matrix< Any > aMatrix( rDataSeq.mnPointCount, 1 );
+            std::vector<Any> aRow(rDataSeq.mnPointCount);
             for (auto const& elem : rDataSeq.maData)
-                *aMatrix.at(elem.first, 0) = elem.second;
+                aRow.at(elem.first) = elem.second;
 
-            aRangeRep = lclGenerateApiArray( aMatrix );
+            aRangeRep = lclGenerateApiArray(aRow);
         }
 
         if( !aRangeRep.isEmpty() ) try
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to