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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Jan 3 18:32:25 PST 2013


 sc/source/filter/xml/xmlcelli.cxx |   21 +++++++++++++++++----
 sc/source/filter/xml/xmlcoli.cxx  |    3 ++-
 sc/source/filter/xml/xmlrowi.cxx  |    8 ++++++++
 sc/source/filter/xml/xmlrowi.hxx  |    2 ++
 4 files changed, 29 insertions(+), 5 deletions(-)

New commits:
commit cf019c9a7baceec3b4dc849d7cba8923c6d2a425
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Jan 4 03:28:32 2013 +0100

    OSL_ENSURE -> SAL_WARN_IF in xmlcelli.cxx
    
    Change-Id: Ia60e07dca17cbc728385c411f67bd3d9041b15ee

diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index fac1191..58919b0 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -1064,7 +1064,7 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos )
     if( cellExists(rCellPos) )
     {
         SetContentValidation( rCellPos );
-        OSL_ENSURE(((nColsRepeated == 1) && (nRepeatedRows == 1)), "repeated cells with formula not possible now");
+        SAL_WARN_IF((nColsRepeated != 1) || (nRepeatedRows != 1), "sc", "repeated cells with formula not possible now");
         rXMLImport.GetStylesImportHelper()->AddCell(rCellPos);
 
         //add matrix
commit 94f7417b038fad6f2a92d1c7c5f8f00c3e64711b
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Jan 4 03:27:01 2013 +0100

    don't overflow SCCOL during repeated cell import, fdo#58539
    
    This is the fix for the third and last crash with gnome#627150
    
    Change-Id: Iaf8611500fdb485017814b35789332c6c89530c0

diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index f3eca23..fac1191 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -167,7 +167,8 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport,
                 nMatrixRows = static_cast<SCROW>(sValue.toInt32());
             break;
             case XML_TOK_TABLE_ROW_CELL_ATTR_REPEATED:
-                nColsRepeated = static_cast<SCCOL>(std::max( sValue.toInt32(), static_cast<sal_Int32>(1) ));
+                nColsRepeated = static_cast<SCCOL>(std::min<sal_Int32>( MAXCOLCOUNT,
+                            std::max( sValue.toInt32(), static_cast<sal_Int32>(1) ) ));
             break;
             case XML_TOK_TABLE_ROW_CELL_ATTR_VALUE_TYPE:
                 nCellType = GetScImport().GetCellType(sValue);
commit 9bcfb6f06bf5a4708b8858469b4118af4222db5a
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Jan 4 03:17:13 2013 +0100

    add some more safety checks for row and column import from ODS
    
    Change-Id: Ic714c65cfe93198c462ba55752223f4e60e5aad9

diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 5a5d73f..f3eca23 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -833,6 +833,12 @@ void ScXMLTableRowCellContext::AddTextAndValueCells( const ScAddress& rCellPos,
     for (SCCOL i = 0; i < nColsRepeated; ++i)
     {
         rCurrentPos.SetCol( rCellPos.Col() + i );
+
+        // it makes no sense to import data after the last supported column
+        // fdo#58539 & gnome#627150
+        if(rCurrentPos.Col() > MAXCOL)
+            break;
+
         if (i > 0)
             rTables.AddColumn(false);
         if (!bIsEmpty)
@@ -840,6 +846,12 @@ void ScXMLTableRowCellContext::AddTextAndValueCells( const ScAddress& rCellPos,
             for (SCROW j = 0; j < nRepeatedRows; ++j)
             {
                 rCurrentPos.SetRow( rCellPos.Row() + j );
+
+                // it makes no sense to import data after last supported row
+                // fdo#58539 & gnome#627150
+                if(rCurrentPos.Row() > MAXROW)
+                    break;
+
                 if( (rCurrentPos.Col() == 0) && (j > 0) )
                 {
                     rTables.AddRow();
diff --git a/sc/source/filter/xml/xmlcoli.cxx b/sc/source/filter/xml/xmlcoli.cxx
index 688300e..ed89294 100644
--- a/sc/source/filter/xml/xmlcoli.cxx
+++ b/sc/source/filter/xml/xmlcoli.cxx
@@ -66,7 +66,8 @@ ScXMLTableColContext::ScXMLTableColContext( ScXMLImport& rImport,
         {
             case XML_TOK_TABLE_COL_ATTR_REPEATED:
                 {
-                    nColCount = sValue.toInt32();
+                    nColCount = std::max<sal_Int32>(sValue.toInt32(), 1);
+                    nColCount = std::min<sal_Int32>(nColCount, MAXCOLCOUNT);
                 }
                 break;
             case XML_TOK_TABLE_COL_ATTR_STYLE_NAME:
diff --git a/sc/source/filter/xml/xmlrowi.cxx b/sc/source/filter/xml/xmlrowi.cxx
index 67d1f23..a4434e1 100644
--- a/sc/source/filter/xml/xmlrowi.cxx
+++ b/sc/source/filter/xml/xmlrowi.cxx
@@ -83,6 +83,7 @@ ScXMLTableRowContext::ScXMLTableRowContext( ScXMLImport& rImport,
             case XML_TOK_TABLE_ROW_ATTR_REPEATED:
             {
                 nRepeatedRows = std::max( sValue.toInt32(), (sal_Int32) 1 );
+                nRepeatedRows = std::min( nRepeatedRows, MAXROWCOUNT );
             }
             break;
             case XML_TOK_TABLE_ROW_ATTR_DEFAULT_CELL_STYLE_NAME:
commit 3e85d9c62c69ee39dd4c6ae7cd556fdf53f5e01d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Jan 4 02:59:23 2013 +0100

    workaround problems with row import, fdo#58539
    
    This fixes another crash with gnome#627150
    
    Change-Id: Ibd259c77f8df04b52c9fee0699e0edd1ad30e94e

diff --git a/sc/source/filter/xml/xmlrowi.cxx b/sc/source/filter/xml/xmlrowi.cxx
index ea58165..67d1f23 100644
--- a/sc/source/filter/xml/xmlrowi.cxx
+++ b/sc/source/filter/xml/xmlrowi.cxx
@@ -97,6 +97,7 @@ ScXMLTableRowContext::ScXMLTableRowContext( ScXMLImport& rImport,
             break;*/
         }
     }
+    mnLastRow = GetScImport().GetTables().GetCurrentRow() + nRepeatedRows;
     GetScImport().GetTables().AddRow();
     GetScImport().GetTables().SetRowStyle(sCellStyleName);
 }
@@ -154,6 +155,12 @@ void ScXMLTableRowContext::EndElement()
     }
     SCTAB nSheet = rXMLImport.GetTables().GetCurrentSheet();
     sal_Int32 nCurrentRow(rXMLImport.GetTables().GetCurrentRow());
+    if(nCurrentRow != mnLastRow)
+    {
+        // this document is most likely invalid in some way
+        SAL_WARN("sc", "we did not generate enough rows in the cell import!!");
+        nCurrentRow = mnLastRow;
+    }
     uno::Reference<sheet::XSpreadsheet> xSheet(rXMLImport.GetTables().GetCurrentXSheet());
     if(xSheet.is())
     {
diff --git a/sc/source/filter/xml/xmlrowi.hxx b/sc/source/filter/xml/xmlrowi.hxx
index a900ff7..02c5255 100644
--- a/sc/source/filter/xml/xmlrowi.hxx
+++ b/sc/source/filter/xml/xmlrowi.hxx
@@ -29,6 +29,8 @@ class ScXMLTableRowContext : public SvXMLImportContext
     rtl::OUString sStyleName;
     rtl::OUString sVisibility;
     sal_Int32 nRepeatedRows;
+    sal_Int32 mnLastRow; // to workaround problems with the cell import, can be removed when the cell
+                        // always adds enough rows
     bool bHasCell;
 
     const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
commit 6e26f941e162da811fcc449f2f6cce083d21100c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Jan 3 23:54:27 2013 +0100

    initialize it irectly in the constructor
    
    Change-Id: If3ad494073d3fb491a0f8e981a28db5bbb917661

diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 398a49c..5a5d73f 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -1002,8 +1002,8 @@ void ScXMLTableRowCellContext::PutFormulaCell( const ScAddress& rCellPos )
     rtl::OUString aText = pOUFormula->first;
     rtl::OUString aFormulaNmsp = pOUFormula->second;
 
-    ::boost::scoped_ptr<ScExternalRefManager::ApiGuard> pExtRefGuard;
-    pExtRefGuard.reset(new ScExternalRefManager::ApiGuard(pDoc));
+    ::boost::scoped_ptr<ScExternalRefManager::ApiGuard> pExtRefGuard (
+            new ScExternalRefManager::ApiGuard(pDoc));
 
 
     if ( !aText.isEmpty() )


More information about the Libreoffice-commits mailing list