tdf#93315 sc: Only 84 empty row show in the Print Preview

Change in Calc behaviour, dropping the 84 line limit.
This way, if all rows or columns are bordered, only up to the last
cell containing data is displayed in the Print Preview. In other
cases, all bordered cells are visible.

Change-Id: I7d874a093d76d5ed92b1b63b645b97582d52629e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153256
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack@redhat.com>
This commit is contained in:
Czeber László Ádám
2023-07-25 00:32:30 +02:00
committed by Eike Rathke
parent 851f0dc7cd
commit 87ca7d2f14
4 changed files with 46 additions and 28 deletions
+1 -1
View File
@@ -203,7 +203,7 @@ public:
bool IsEmpty() const;
bool GetFirstVisibleAttr( SCROW& rFirstRow ) const;
bool GetLastVisibleAttr( SCROW& rLastRow, SCROW nLastData ) const;
bool GetLastVisibleAttr( SCROW& rLastRow, SCROW nLastData, bool bSkipEmpty ) const;
bool HasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const;
bool IsVisibleEqual( const ScAttrArray& rOther,
SCROW nStartRow, SCROW nEndRow ) const;
+3 -3
View File
@@ -313,7 +313,7 @@ public:
bool HasSelectionMatrixFragment(const ScMarkData& rMark, const ScRangeList& rRangeList) const;
bool GetFirstVisibleAttr( SCROW& rFirstRow ) const;
bool GetLastVisibleAttr( SCROW& rLastRow ) const;
bool GetLastVisibleAttr( SCROW& rLastRow, bool bSkipEmpty ) const;
bool HasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const;
bool IsVisibleAttrEqual( const ScColumn& rCol, SCROW nStartRow, SCROW nEndRow ) const;
@@ -890,11 +890,11 @@ inline bool ScColumn::GetFirstVisibleAttr( SCROW& rFirstRow ) const
return pAttrArray->GetFirstVisibleAttr( rFirstRow );
}
inline bool ScColumn::GetLastVisibleAttr( SCROW& rLastRow ) const
inline bool ScColumn::GetLastVisibleAttr( SCROW& rLastRow, bool bSkipEmpty ) const
{
// row of last cell is needed
SCROW nLastData = GetLastDataPos(); // always including notes, 0 if none
return pAttrArray->GetLastVisibleAttr( rLastRow, nLastData );
return pAttrArray->GetLastVisibleAttr( rLastRow, nLastData, bSkipEmpty );
}
inline bool ScColumn::HasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const
+33 -21
View File
@@ -1942,7 +1942,7 @@ bool ScAttrArray::GetFirstVisibleAttr( SCROW& rFirstRow ) const
const SCROW SC_VISATTR_STOP = 84;
bool ScAttrArray::GetLastVisibleAttr( SCROW& rLastRow, SCROW nLastData ) const
bool ScAttrArray::GetLastVisibleAttr( SCROW& rLastRow, SCROW nLastData, bool bSkipEmpty ) const
{
if ( mvData.empty() )
{
@@ -1971,31 +1971,43 @@ bool ScAttrArray::GetLastVisibleAttr( SCROW& rLastRow, SCROW nLastData ) const
rLastRow = nLastData;
return false;
}
// Find a run below last data row.
// tdf#93315: If "Suppress output of empty pages" in Calc Options is not checked, show empty
// (containing only empty data cells) page in the document
bool bFound = false;
Search( nLastData, nPos );
while ( nPos < mvData.size() )
if (bSkipEmpty)
{
// find range of visually equal formats
SCSIZE nEndPos = nPos;
while ( nEndPos < mvData.size()-1 &&
mvData[nEndPos].pPattern->IsVisibleEqual( *mvData[nEndPos+1].pPattern))
++nEndPos;
SCROW nAttrStartRow = ( nPos > 0 ) ? ( mvData[nPos-1].nEndRow + 1 ) : 0;
if ( nAttrStartRow <= nLastData )
nAttrStartRow = nLastData + 1;
SCROW nAttrSize = mvData[nEndPos].nEndRow + 1 - nAttrStartRow;
if ( nAttrSize >= SC_VISATTR_STOP )
break; // while, ignore this range and below
else if ( mvData[nEndPos].pPattern->IsVisible() )
Search( nLastData, nPos );
while ( nPos < mvData.size() )
{
rLastRow = mvData[nEndPos].nEndRow;
bFound = true;
// find range of visually equal formats
SCSIZE nEndPos = nPos;
while ( nEndPos < mvData.size()-1 &&
mvData[nEndPos].pPattern->IsVisibleEqual(*mvData[nEndPos+1].pPattern))
++nEndPos;
SCROW nAttrStartRow = ( nPos > 0 ) ? ( mvData[nPos-1].nEndRow + 1) : 0;
if ( nAttrStartRow <= nLastData )
nAttrStartRow = nLastData + 1;
SCROW nAttrSize = mvData[nEndPos].nEndRow + 1 - nAttrStartRow;
if ( nAttrSize >= SC_VISATTR_STOP )
break; // while, ignore this range and below
else if ( mvData[nEndPos].pPattern->IsVisible() )
{
rLastRow = mvData[nEndPos].nEndRow;
bFound = true;
}
nPos = nEndPos + 1;
}
nPos = nEndPos + 1;
}
else
{
if ((nPos > 0 && mvData[nPos-1].pPattern->IsVisible())
|| (nPos > 1 && !mvData[nPos-1].pPattern->IsVisibleEqual(*mvData[nPos-2].pPattern)))
{
rLastRow = mvData[nPos-1].nEndRow;
return true;
}
rLastRow = nLastData;
}
return bFound;
}
+9 -3
View File
@@ -37,6 +37,8 @@
#include <markdata.hxx>
#include <progress.hxx>
#include <prnsave.hxx>
#include <printopt.hxx>
#include <scmod.hxx>
#include <tabprotection.hxx>
#include <sheetevents.hxx>
#include <segmenttree.hxx>
@@ -610,6 +612,8 @@ bool ScTable::GetPrintArea( SCCOL& rEndCol, SCROW& rEndRow, bool bNotes, bool bC
SCROW nMaxY = 0;
SCCOL i;
bool bSkipEmpty = SC_MOD()->GetPrintOptions().GetSkipEmpty();
for (i=0; i<aCol.size(); i++) // Test data
{
if (bCalcHiddens || !rDocument.ColHidden(i, nTab))
@@ -661,7 +665,7 @@ bool ScTable::GetPrintArea( SCCOL& rEndCol, SCROW& rEndRow, bool bNotes, bool bC
if (bCalcHiddens || !rDocument.ColHidden(i, nTab))
{
SCROW nLastRow;
if (aCol[i].GetLastVisibleAttr( nLastRow ))
if (aCol[i].GetLastVisibleAttr( nLastRow, bSkipEmpty ))
{
bFound = true;
nMaxX = i;
@@ -697,7 +701,7 @@ bool ScTable::GetPrintArea( SCCOL& rEndCol, SCROW& rEndRow, bool bNotes, bool bC
// also don't include default-formatted columns before that
SCROW nDummyRow;
while ( nMaxX > nMaxDataX && !aCol[nMaxX].GetLastVisibleAttr( nDummyRow ) )
while ( nMaxX > nMaxDataX && !aCol[nMaxX].GetLastVisibleAttr( nDummyRow, bSkipEmpty ) )
--nMaxX;
break;
}
@@ -762,10 +766,12 @@ bool ScTable::GetPrintAreaVer( SCCOL nStartCol, SCCOL nEndCol,
SCROW nMaxY = 0;
SCCOL i;
bool bSkipEmpty = SC_MOD()->GetPrintOptions().GetSkipEmpty();
for (i=nStartCol; i<=nEndCol && i < aCol.size(); i++) // Test attribute
{
SCROW nLastRow;
if (aCol[i].GetLastVisibleAttr( nLastRow ))
if (aCol[i].GetLastVisibleAttr( nLastRow, bSkipEmpty ))
{
bFound = true;
if (nLastRow > nMaxY)