[Libreoffice-commits] .: 2 commits - sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Jan 3 08:46:59 PST 2013


 sc/source/core/data/documen4.cxx  |   32 ++++++++++----------------------
 sc/source/filter/xml/xmlcelli.cxx |    4 ++--
 2 files changed, 12 insertions(+), 24 deletions(-)

New commits:
commit 5bc348ae930b57f546238a8d24efebdd0972753c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Jan 3 17:46:18 2013 +0100

    make sure the column index is valid, fdo#58539
    
    This is the first part of the fix for gnome#627150
    
    Change-Id: I02cd8c553dd6b9a026c0ea38d77c6831fef6498e

diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 7e064ae..b3bb256 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -119,6 +119,8 @@ void ScDocument::InsertMatrixFormula(SCCOL nCol1, SCROW nRow1,
 {
     PutInOrder(nCol1, nCol2);
     PutInOrder(nRow1, nRow2);
+    nCol2 = std::min<SCCOL>(nCol2, MAXCOL);
+    nRow2 = std::min<SCROW>(nRow2, MAXROW);
     if (!rMark.GetSelectCount())
     {
         SAL_WARN("sc", "ScDocument::InsertMatrixFormula Keine Tabelle markiert");
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 957cb67..398a49c 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -1063,8 +1063,8 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos )
                 //value/text of each matrix cell later
                 rXMLImport.GetTables().AddMatrixRange(
                         rCellPos.Col(), rCellPos.Row(),
-                        rCellPos.Col() + nMatrixCols - 1,
-                        rCellPos.Row() + nMatrixRows - 1,
+                        std::min<SCCOL>(rCellPos.Col() + nMatrixCols - 1, MAXCOL),
+                        std::min<SCROW>(rCellPos.Row() + nMatrixRows - 1, MAXROW),
                         pOUFormula->first, pOUFormula->second, eGrammar);
 
                 //set the value/text of the first matrix position (top-left).
commit 95dbe79206b107a987914f8f97f26ca79da5dd2b
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Jan 3 15:16:57 2013 +0100

    simplify this code a little bit
    
    and restore some of the old optimizations
    
    Change-Id: I1b42ed135bd3f8dfb663740a1bd2dbfa1216a388

diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index cc3b181..7e064ae 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -119,29 +119,14 @@ void ScDocument::InsertMatrixFormula(SCCOL nCol1, SCROW nRow1,
 {
     PutInOrder(nCol1, nCol2);
     PutInOrder(nRow1, nRow2);
-    SCTAB i, nTab1;
-    SCCOL j;
-    SCROW k;
-    i = 0;
-    bool bStop = false;
-    SCTAB nMax = static_cast<SCTAB>(maTabs.size());
-    ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
-    for (; itr != itrEnd && *itr < nMax; ++itr)
+    if (!rMark.GetSelectCount())
     {
-        if (maTabs[i])
-        {
-            i = *itr;
-            bStop = true;
-            break;
-        }
-    }
-    nTab1 = i;
-    if (!bStop)
-    {
-        OSL_FAIL("ScDocument::InsertMatrixFormula Keine Tabelle markiert");
+        SAL_WARN("sc", "ScDocument::InsertMatrixFormula Keine Tabelle markiert");
         return;
     }
 
+    SCTAB nTab1 = *rMark.begin();
+
     ScFormulaCell* pCell;
     ScAddress aPos( nCol1, nRow1, nTab1 );
     if (pArr)
@@ -149,7 +134,8 @@ void ScDocument::InsertMatrixFormula(SCCOL nCol1, SCROW nRow1,
     else
         pCell = new ScFormulaCell( this, aPos, rFormula, eGram, MM_FORMULA );
     pCell->SetMatColsRows( nCol2 - nCol1 + 1, nRow2 - nRow1 + 1, bDirtyFlag );
-    itr = rMark.begin();
+    ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
+    SCTAB nMax = static_cast<SCTAB>(maTabs.size());
     for (; itr != itrEnd && *itr < nMax; ++itr)
     {
         if (maTabs[*itr])
@@ -186,9 +172,9 @@ void ScDocument::InsertMatrixFormula(SCCOL nCol1, SCROW nRow1,
                 aRefData.nRelTab = *itr - nTab1;
                 t->GetSingleRef() = aRefData;
             }
-            for (j = nCol1; j <= nCol2; j++)
+            for (SCCOL j = nCol1; j <= nCol2; j++)
             {
-                for (k = nRow1; k <= nRow2; k++)
+                for (SCROW k = nRow1; k <= nRow2; k++)
                 {
                     if (j != nCol1 || k != nRow1)       // nicht in der ersten Zelle
                     {


More information about the Libreoffice-commits mailing list