summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-05-12 09:02:07 +0200
committerLuboš Luňák <l.lunak@collabora.com>2022-05-12 16:39:06 +0200
commit818eeaa3ae7146190c71b7e8901bd7f67aa672b8 (patch)
treece90f3e2289125ea9e54c7c31b50f6af43cf3d83
parent1e990a5ab399a1bb15d4002ca30f13611ba6edbc (diff)
IsEmptyBlock() -> IsEmptyData()
It's unclear what "block" is supposed to mean, as that may mean "cells with no value", but a cell also may have a note, or since recently apparently also a sparkline. To make it even more confusing, there is IsBlockEmpty(), which may explicitly take bIgnoreNotes set to true, in which case it presumably should check only data, but then the recent sparklines addition still counts sparklines even in that case, which is presumably a mistake. Rename the data-only function to make it clear, and remove the extra argument from the empty-in-all-ways function. Change-Id: I8e3f75407d243b733d61640e2f54954762601ab1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134217 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--sc/inc/column.hxx2
-rw-r--r--sc/inc/document.hxx7
-rw-r--r--sc/inc/table.hxx5
-rw-r--r--sc/qa/unit/ucalc.cxx6
-rw-r--r--sc/source/core/data/column2.cxx2
-rw-r--r--sc/source/core/data/document.cxx8
-rw-r--r--sc/source/core/data/table1.cxx28
-rw-r--r--sc/source/core/data/table2.cxx6
-rw-r--r--sc/source/filter/html/htmlexp2.cxx2
-rw-r--r--sc/source/ui/docshell/docfunc.cxx6
-rw-r--r--sc/source/ui/view/tabview3.cxx2
-rw-r--r--sc/source/ui/view/viewfun2.cxx2
12 files changed, 38 insertions, 38 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index feba105169e6..01dc4e8611fa 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -285,7 +285,7 @@ public:
bool IsEmptyAttr() const;
// data only:
- bool IsEmptyBlock(SCROW nStartRow, SCROW nEndRow) const;
+ bool IsEmptyData(SCROW nStartRow, SCROW nEndRow) const;
SCSIZE GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirection eDir ) const;
bool HasDataAt( SCROW nRow, ScDataAreaExtras* pDataAreaExtras = nullptr ) const;
bool HasDataAt( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow,
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 7f32bb7bc6bd..0a483cfeb9a1 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1334,8 +1334,9 @@ public:
SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bDeleteCaptions = true );
void RemoveMerge( SCCOL nCol, SCROW nRow, SCTAB nTab );
+ // This also includes e.g. notes. Use IsEmptyData() for cell data only.
bool IsBlockEmpty( SCCOL nStartCol, SCROW nStartRow,
- SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bIgnoreNotes = false ) const;
+ SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ) const;
bool IsPrintEmpty( SCCOL nStartCol, SCROW nStartRow,
SCCOL nEndCol, SCROW nEndRow, SCTAB nTab,
bool bLeftIsEmpty = false,
@@ -1541,8 +1542,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 bool IsEmptyData(SCCOL nStartCol, SCROW nStartRow,
+ SCCOL nEndCol, SCROW nEndRow, SCTAB nTab) const;
// I think this returns the number of empty cells starting from the given direction.
SC_DLLPUBLIC SCSIZE GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab,
SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab,
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 290dfcf74f3d..e89dbd34dbc8 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -411,7 +411,8 @@ public:
bool bNoMatrixAtAll = false ) const;
bool HasSelectionMatrixFragment( const ScMarkData& rMark ) const;
- bool IsBlockEmpty( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bIgnoreNotes ) const;
+ // This also includes e.g. notes. Use IsEmptyData() for cell data only.
+ bool IsBlockEmpty( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const;
bool SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString& rString,
const ScSetStringParam * pParam = nullptr );
@@ -621,7 +622,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;
+ bool IsEmptyData(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/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 1019cf44a879..9f8fad755ea1 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5008,10 +5008,8 @@ void Test::testNoteDeleteRow()
CPPUNIT_ASSERT_MESSAGE("there should be a note", m_pDoc->HasNote(1, 1, 0));
// test with IsBlockEmpty
- bool bIgnoreNotes = true;
- CPPUNIT_ASSERT_MESSAGE("The Block should be detected as empty (no Notes)", m_pDoc->IsBlockEmpty(0, 0, 100, 100, 0, bIgnoreNotes));
- bIgnoreNotes = false;
- CPPUNIT_ASSERT_MESSAGE("The Block should NOT be detected as empty", !m_pDoc->IsBlockEmpty(0, 0, 100, 100, 0, bIgnoreNotes));
+ CPPUNIT_ASSERT_MESSAGE("The Block should be detected as empty (no Notes)", m_pDoc->IsEmptyData(0, 0, 100, 100, 0));
+ CPPUNIT_ASSERT_MESSAGE("The Block should NOT be detected as empty", !m_pDoc->IsBlockEmpty(0, 0, 100, 100, 0));
m_pDoc->DeleteRow(0, 0, m_pDoc->MaxCol(), 0, 1, 1);
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index f933497b4a75..9d93bc6fd032 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1293,7 +1293,7 @@ bool ScColumn::HasVisibleDataAt(SCROW nRow) const
return it->type != sc::element_type_empty;
}
-bool ScColumn::IsEmptyBlock(SCROW nStartRow, SCROW nEndRow) const
+bool ScColumn::IsEmptyData(SCROW nStartRow, SCROW nEndRow) const
{
std::pair<sc::CellStoreType::const_iterator,size_t> aPos = maCells.position(nStartRow);
sc::CellStoreType::const_iterator it = aPos.first;
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index de398e96a13f..8791c3afe1bd 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -5389,11 +5389,11 @@ void ScDocument::GetBorderLines( SCCOL nCol, SCROW nRow, SCTAB nTab,
}
bool ScDocument::IsBlockEmpty(SCCOL nStartCol, SCROW nStartRow,
- SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bIgnoreNotes ) const
+ SCCOL nEndCol, SCROW nEndRow, SCTAB nTab) const
{
if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()))
if (maTabs[nTab])
- return maTabs[nTab]->IsBlockEmpty( nStartCol, nStartRow, nEndCol, nEndRow, bIgnoreNotes );
+ return maTabs[nTab]->IsBlockEmpty( nStartCol, nStartRow, nEndCol, nEndRow );
OSL_FAIL("wrong table number");
return false;
@@ -6163,10 +6163,10 @@ ScStyleSheetPool* ScDocument::GetStyleSheetPool() const
return mxPoolHelper->GetStylePool();
}
-bool ScDocument::IsEmptyBlock(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab) const
+bool ScDocument::IsEmptyData(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 maTabs[nTab]->IsEmptyData(nStartCol, nStartRow, nEndCol, nEndRow);
return true;
}
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 9119aa076e1a..a423b2b4774c 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -720,7 +720,7 @@ bool ScTable::GetPrintAreaHor( SCROW nStartRow, SCROW nEndRow,
for (i=0; i<aCol.size(); i++) // test the data
{
- if (!aCol[i].IsEmptyBlock( nStartRow, nEndRow )) //TODO: bNotes ??????
+ if (!aCol[i].IsEmptyData( nStartRow, nEndRow )) //TODO: bNotes ??????
{
bFound = true;
if (i > nMaxX)
@@ -906,7 +906,7 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, S
if (nEnd<rDocument.MaxRow()) ++nEnd;
if (rEndCol < (aCol.size()-1))
- if (!aCol[rEndCol+1].IsEmptyBlock(nStart,nEnd))
+ if (!aCol[rEndCol+1].IsEmptyData(nStart,nEnd))
{
assert( int( blockPos.size()) == rEndCol + 1 );
++rEndCol;
@@ -917,7 +917,7 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, S
}
if (rStartCol > 0)
- if (!aCol[rStartCol-1].IsEmptyBlock(nStart,nEnd))
+ if (!aCol[rStartCol-1].IsEmptyData(nStart,nEnd))
{
--rStartCol;
bChanged = true;
@@ -960,11 +960,11 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, S
if ( !bIncludeOld && !bOnlyDown )
{
if ( !bLeft )
- while ( rStartCol < rEndCol && rStartCol < (aCol.size()-1) && aCol[rStartCol].IsEmptyBlock(rStartRow,rEndRow) )
+ while ( rStartCol < rEndCol && rStartCol < (aCol.size()-1) && aCol[rStartCol].IsEmptyData(rStartRow,rEndRow) )
++rStartCol;
if ( !bRight )
- while ( rEndCol > 0 && rStartCol < rEndCol && aCol[rEndCol].IsEmptyBlock(rStartRow,rEndRow) )
+ while ( rEndCol > 0 && rStartCol < rEndCol && aCol[rEndCol].IsEmptyData(rStartRow,rEndRow) )
--rEndCol;
if ( !bTop && rStartRow < rDocument.MaxRow() && rStartRow < rEndRow )
@@ -1067,7 +1067,7 @@ bool ScTable::ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rS
while (rStartCol < rEndCol)
{
- if (aCol[rEndCol].IsEmptyBlock( rStartRow, rEndRow))
+ if (aCol[rEndCol].IsEmptyData( rStartRow, rEndRow))
{
if (pDataAreaExtras && pDataAreaExtras->mnEndCol < rEndCol)
{
@@ -1093,7 +1093,7 @@ bool ScTable::ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rS
{
while (rStartCol < rEndCol)
{
- if (aCol[rStartCol].IsEmptyBlock( rStartRow, rEndRow))
+ if (aCol[rStartCol].IsEmptyData( rStartRow, rEndRow))
{
if (pDataAreaExtras && pDataAreaExtras->mnStartCol > rStartCol)
{
@@ -1152,7 +1152,7 @@ bool ScTable::ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rS
}
return rStartCol != rEndCol || (bColumnsOnly ?
- !aCol[rStartCol].IsEmptyBlock( rStartRow, rEndRow) :
+ !aCol[rStartCol].IsEmptyData( rStartRow, rEndRow) :
(rStartRow != rEndRow ||
aCol[rStartCol].HasDataAt( rStartRow, pDataAreaExtras)));
}
@@ -1175,11 +1175,11 @@ SCROW ScTable::GetLastDataRow( SCCOL nCol1, SCCOL nCol2, SCROW nLastRow, ScDataA
return nNewLastRow;
}
-bool ScTable::IsEmptyBlock( SCCOL nStartCol, SCROW nStartRow,
+bool ScTable::IsEmptyData( SCCOL nStartCol, SCROW nStartRow,
SCCOL nEndCol, SCROW nEndRow ) const
{
for( SCCOL col : GetAllocatedColumnsRange( nStartCol, nEndCol ))
- if( !aCol[col].IsEmptyBlock( nStartRow, nEndRow ))
+ if( !aCol[col].IsEmptyData( nStartRow, nEndRow ))
return false;
return true;
}
@@ -1211,7 +1211,7 @@ SCSIZE ScTable::GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow,
{
nCol = nEndCol;
while ((nCol >= nStartCol) &&
- aCol[nCol].IsEmptyBlock(nStartRow, nEndRow))
+ aCol[nCol].IsEmptyData(nStartRow, nEndRow))
{
nCount++;
nCol--;
@@ -1221,7 +1221,7 @@ SCSIZE ScTable::GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow,
else
{
nCol = nStartCol;
- while ((nCol <= nEndCol) && aCol[nCol].IsEmptyBlock(nStartRow, nEndRow))
+ while ((nCol <= nEndCol) && aCol[nCol].IsEmptyData(nStartRow, nEndRow))
{
nCount++;
nCol++;
@@ -1254,10 +1254,10 @@ void ScTable::LimitChartArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol
rStartCol = std::min<SCCOL>( rStartCol, aCol.size()-1 );
rEndCol = std::min<SCCOL>( rEndCol, aCol.size()-1 );
- while ( rStartCol<rEndCol && aCol[rStartCol].IsEmptyBlock(rStartRow,rEndRow) )
+ while ( rStartCol<rEndCol && aCol[rStartCol].IsEmptyData(rStartRow,rEndRow) )
++rStartCol;
- while ( rStartCol<rEndCol && aCol[rEndCol].IsEmptyBlock(rStartRow,rEndRow) )
+ while ( rStartCol<rEndCol && aCol[rEndCol].IsEmptyData(rStartRow,rEndRow) )
--rEndCol;
while ( rStartRow<rEndRow && IsEmptyLine(rStartRow, rStartCol, rEndCol) )
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 8670ae56e7a6..8d442dd2bd00 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -2340,7 +2340,7 @@ void ScTable::SetMergedCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2
ApplyFlags(nCol1+1, nRow1+1, nCol2, nRow2, ScMF::Hor | ScMF::Ver);
}
-bool ScTable::IsBlockEmpty( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bIgnoreNotes ) const
+bool ScTable::IsBlockEmpty( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const
{
if (!(ValidCol(nCol1) && ValidCol(nCol2)))
{
@@ -2351,12 +2351,12 @@ bool ScTable::IsBlockEmpty( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
bool bEmpty = true;
for (SCCOL i=nCol1; i<=nCol2 && bEmpty; i++)
{
- bEmpty = aCol[i].IsEmptyBlock( nRow1, nRow2 );
+ bEmpty = aCol[i].IsEmptyData( nRow1, nRow2 );
if (bEmpty)
{
bEmpty = aCol[i].IsSparklinesEmptyBlock(nRow1, nRow2);
}
- if (!bIgnoreNotes && bEmpty)
+ if (bEmpty)
{
bEmpty = aCol[i].IsNotesEmptyBlock(nRow1, nRow2);
}
diff --git a/sc/source/filter/html/htmlexp2.cxx b/sc/source/filter/html/htmlexp2.cxx
index bc969f89fc80..475fea96c8f8 100644
--- a/sc/source/filter/html/htmlexp2.cxx
+++ b/sc/source/filter/html/htmlexp2.cxx
@@ -89,7 +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->IsEmptyBlock( nCol1, nRow1, nCol2, nRow2, nTab );
+ bool bInCell = pDoc->IsEmptyData( nCol1, nRow1, nCol2, nRow2, nTab );
if ( bInCell )
{ // Spacing in spanning cell
tools::Rectangle aCellRect = pDoc->GetMMRect(
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 1619fa781047..3e80b6ce5a6e 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -4976,9 +4976,9 @@ bool ScDocFunc::MergeCells( const ScCellMergeOption& rOption, bool bContents, bo
for (const SCTAB nTab : rOption.maTabs)
{
bool bIsBlockEmpty = ( nStartRow == nEndRow )
- ? rDoc.IsBlockEmpty( nStartCol+1,nStartRow, nEndCol,nEndRow, nTab, true )
- : rDoc.IsBlockEmpty( nStartCol,nStartRow+1, nStartCol,nEndRow, nTab, true ) &&
- rDoc.IsBlockEmpty( nStartCol+1,nStartRow, nEndCol,nEndRow, nTab, true );
+ ? rDoc.IsEmptyData( nStartCol+1,nStartRow, nEndCol,nEndRow, nTab )
+ : rDoc.IsEmptyData( nStartCol,nStartRow+1, nStartCol,nEndRow, nTab ) &&
+ rDoc.IsEmptyData( nStartCol+1,nStartRow, nEndCol,nEndRow, nTab );
bool bNeedContents = bContents && !bIsBlockEmpty;
bool bNeedEmpty = bEmptyMergedCells && !bIsBlockEmpty && !bNeedContents; // if DoMergeContents then cells are emptied
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index 97f80622fa23..5c706bab5f11 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -2413,7 +2413,7 @@ void ScTabView::PaintArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCRO
bool bMarkClipped = aViewData.GetOptions().GetOption( VOPT_CLIPMARKS );
if (bMarkClipped)
{
- // ScColumn::IsEmptyBlock has to be optimized for this
+ // ScColumn::IsEmptyData has to be optimized for this
// (switch to Search() )
//!if ( nCol1 > 0 && !aViewData.GetDocument()->IsBlockEmpty(
//! 0, nRow1, nCol1-1, nRow2.
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 648af012aaeb..dd1c48f73164 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -1824,7 +1824,7 @@ void ScViewFunc::FillCrossDblClick()
bDataFound = (rDoc.HasData( nMovX, nStartY, nTab) && rDoc.HasData( nMovX, nStartY + 1, nTab));
}
- if (!(bDataFound && rDoc.IsBlockEmpty( nStartX, nEndY + 1, nEndX, nEndY + 1, nTab, true)))
+ if (!(bDataFound && rDoc.IsEmptyData( nStartX, nEndY + 1, nEndX, nEndY + 1, nTab )))
return;
// Get end of data left or right.