sc/inc/document.hxx                |    2 ++
 sc/inc/table.hxx                   |    1 +
 sc/source/core/data/document.cxx   |    7 +++++++
 sc/source/core/data/table1.cxx     |    9 +++++++++
 sc/source/filter/html/htmlexp2.cxx |    4 +---
 5 files changed, 20 insertions(+), 3 deletions(-)

New commits:
commit 79ea331bbd91def54bb8a31ba2acd671fbf4422d
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Thu Apr 21 21:56:32 2022 +0200
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Fri Apr 22 07:44:07 2022 +0200

    fix checking whether a block of cells is empty
    
    The GetEmptyLinesInBlock() call has unclear semantics and it appears
    that it has an off-by-one error. Use a simple clear function
    for the check.
    
    Change-Id: I45d9b73428aedababc1ad93c202daa1de945b5bf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133303
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index d24f4f170239..5e5af3a31fa6 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1532,6 +1532,8 @@ public:
     void                        ExtendPrintArea( OutputDevice* pDev, SCTAB 
nTab,
                                                  SCCOL nStartCol, SCROW 
nStartRow,
                                                  SCCOL& rEndCol, SCROW nEndRow 
) const;
+    SC_DLLPUBLIC bool           IsEmptyBlock(SCCOL nStartCol, SCROW nStartRow,
+                                             SCCOL nEndCol, SCROW nEndRow, 
SCTAB nTab) const;
     SC_DLLPUBLIC SCSIZE         GetEmptyLinesInBlock( SCCOL nStartCol, SCROW 
nStartRow, SCTAB nStartTab,
                                                       SCCOL nEndCol, SCROW 
nEndRow, SCTAB nEndTab,
                                                       ScDirection eDir );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index ba8ed9e328d8..ec78bfa598c5 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -619,6 +619,7 @@ public:
     SCROW       GetLastDataRow( SCCOL nCol1, SCCOL nCol2, SCROW nLastRow,
                                 ScDataAreaExtras* pDataAreaExtras = nullptr ) 
const;
 
+    bool        IsEmptyBlock(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, 
SCROW nEndRow) const;
     SCSIZE      GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow,
                                         SCCOL nEndCol, SCROW nEndRow, 
ScDirection eDir ) const;
 
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index b0b9242a1a63..c8e951e7b909 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -6142,6 +6142,13 @@ ScStyleSheetPool* ScDocument::GetStyleSheetPool() const
     return mxPoolHelper->GetStylePool();
 }
 
+bool ScDocument::IsEmptyBlock(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, 
SCROW nEndRow, SCTAB nTab) const
+{
+    if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && 
maTabs[nTab])
+        return maTabs[nTab]->IsEmptyBlock(nStartCol, nStartRow, nEndCol, 
nEndRow);
+    return true;
+}
+
 SCSIZE ScDocument::GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow, 
SCTAB nStartTab,
                             SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, 
ScDirection eDir )
 {
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index e864bd23974f..16b90b3b7c62 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1175,6 +1175,15 @@ SCROW ScTable::GetLastDataRow( SCCOL nCol1, SCCOL nCol2, 
SCROW nLastRow, ScDataA
     return nNewLastRow;
 }
 
+bool ScTable::IsEmptyBlock( SCCOL nStartCol, SCROW nStartRow,
+                            SCCOL nEndCol, SCROW nEndRow ) const
+{
+    for( SCCOL col : GetAllocatedColumnsRange( nStartCol, nEndCol ))
+        if( !aCol[col].IsEmptyBlock( nStartRow, nEndRow ))
+            return false;
+    return true;
+}
+
 SCSIZE ScTable::GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow,
                                         SCCOL nEndCol, SCROW nEndRow, 
ScDirection eDir ) const
 {
diff --git a/sc/source/filter/html/htmlexp2.cxx 
b/sc/source/filter/html/htmlexp2.cxx
index 7d3c7f75b213..bc969f89fc80 100644
--- a/sc/source/filter/html/htmlexp2.cxx
+++ b/sc/source/filter/html/htmlexp2.cxx
@@ -89,9 +89,7 @@ void ScHTMLExport::FillGraphList( const SdrPage* pPage, SCTAB 
nTab,
             SCCOL nCol2 = aR.aEnd.Col();
             SCROW nRow2 = aR.aEnd.Row();
             // All cells empty under object?
-            bool bInCell = (pDoc->GetEmptyLinesInBlock(
-                nCol1, nRow1, nTab, nCol2, nRow2, nTab, DIR_TOP )
-                == static_cast< SCSIZE >( nRow2 - nRow1 ));    // rows-1 !
+            bool bInCell = pDoc->IsEmptyBlock( nCol1, nRow1, nCol2, nRow2, 
nTab );
             if ( bInCell )
             {   // Spacing in spanning cell
                 tools::Rectangle aCellRect = pDoc->GetMMRect(

Reply via email to