summaryrefslogtreecommitdiff
path: root/sc/source/core
diff options
context:
space:
mode:
authorAttila Szűcs <szucs.attila3@nisz.hu>2021-01-27 17:43:43 +0100
committerLászló Németh <nemeth@numbertext.org>2021-02-09 16:37:51 +0100
commit2bf3e0d00e3bccb5b250642ee0d3fdbe6cae8ecc (patch)
treed789235fb774e6109276b657e836b8c9dc9d710e /sc/source/core
parent0f89ce31eda36a05d295504a521b27907b798490 (diff)
tdf#104502 sc: skip hidden columns at printing pages
Page calculation counted the hidden columns, resulted printing blank pages by accident. Extend GetPrintArea() and GetTableArea() to count pages without the hidden columns, too. Co-authored-by: Tibor Nagy (NISZ) Change-Id: I4817965a675e059cdc8f81ca3bb6e128af874f2f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110028 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sc/source/core')
-rw-r--r--sc/source/core/data/documen2.cxx4
-rw-r--r--sc/source/core/data/document.cxx4
-rw-r--r--sc/source/core/data/table1.cxx47
3 files changed, 38 insertions, 17 deletions
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 56e4fac4d711..e49694224fd6 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -571,11 +571,11 @@ const svl::SharedStringPool& ScDocument::GetSharedStringPool() const
}
bool ScDocument::GetPrintArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow,
- bool bNotes ) const
+ bool bNotes, bool bCalcHiddens) const
{
if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
{
- bool bAny = maTabs[nTab]->GetPrintArea( rEndCol, rEndRow, bNotes );
+ bool bAny = maTabs[nTab]->GetPrintArea( rEndCol, rEndRow, bNotes, bCalcHiddens);
if (mpDrawLayer)
{
ScRange aDrawRange(0,0,nTab, MaxCol(),MaxRow(),nTab);
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 48282126b0fc..ba9cee894875 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1016,11 +1016,11 @@ bool ScDocument::GetCellArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const
return false;
}
-bool ScDocument::GetTableArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const
+bool ScDocument::GetTableArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow, bool bCalcHiddens) const
{
if (ValidTab(nTab) && nTab < static_cast<SCTAB> (maTabs.size()))
if (maTabs[nTab])
- return maTabs[nTab]->GetTableArea( rEndCol, rEndRow );
+ return maTabs[nTab]->GetTableArea( rEndCol, rEndRow, bCalcHiddens);
rEndCol = 0;
rEndRow = 0;
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 0e35edf44d05..0665e90a4542 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -249,6 +249,8 @@ ScTable::ScTable( ScDocument& rDoc, SCTAB nNewTab, const OUString& rNewName,
mpFilteredRows(new ScFlatBoolRowSegments(rDoc.MaxRow())),
nTableAreaX( 0 ),
nTableAreaY( 0 ),
+ nTableAreaVisibleX( 0 ),
+ nTableAreaVisibleY( 0 ),
nTab( nNewTab ),
rDocument( rDoc ),
pSortCollator( nullptr ),
@@ -541,22 +543,35 @@ bool ScTable::GetCellArea( SCCOL& rEndCol, SCROW& rEndRow ) const
return bFound;
}
-bool ScTable::GetTableArea( SCCOL& rEndCol, SCROW& rEndRow ) const
+bool ScTable::GetTableArea( SCCOL& rEndCol, SCROW& rEndRow, bool bCalcHiddens) const
{
bool bRet = true; //TODO: remember?
- if (!bTableAreaValid)
+ if (bCalcHiddens)
{
- bRet = GetPrintArea(nTableAreaX, nTableAreaY, true);
- bTableAreaValid = true;
+ if (!bTableAreaValid)
+ {
+ bRet = GetPrintArea(nTableAreaX, nTableAreaY, true, bCalcHiddens);
+ bTableAreaValid = true;
+ }
+ rEndCol = nTableAreaX;
+ rEndRow = nTableAreaY;
+ }
+ else
+ {
+ if (!bTableAreaVisibleValid)
+ {
+ bRet = GetPrintArea(nTableAreaVisibleX, nTableAreaVisibleY, true, bCalcHiddens);
+ bTableAreaVisibleValid = true;
+ }
+ rEndCol = nTableAreaVisibleX;
+ rEndRow = nTableAreaVisibleY;
}
- rEndCol = nTableAreaX;
- rEndRow = nTableAreaY;
return bRet;
}
const SCCOL SC_COLUMNS_STOP = 30;
-bool ScTable::GetPrintArea( SCCOL& rEndCol, SCROW& rEndRow, bool bNotes ) const
+bool ScTable::GetPrintArea( SCCOL& rEndCol, SCROW& rEndRow, bool bNotes, bool bCalcHiddens ) const
{
bool bFound = false;
SCCOL nMaxX = 0;
@@ -564,6 +579,8 @@ bool ScTable::GetPrintArea( SCCOL& rEndCol, SCROW& rEndRow, bool bNotes ) const
SCCOL i;
for (i=0; i<aCol.size(); i++) // Test data
+ {
+ if (bCalcHiddens || !rDocument.ColHidden(i, nTab))
{
if (!aCol[i].IsEmptyData())
{
@@ -589,18 +606,22 @@ bool ScTable::GetPrintArea( SCCOL& rEndCol, SCROW& rEndRow, bool bNotes ) const
}
}
}
+ }
SCCOL nMaxDataX = nMaxX;
for (i=0; i<aCol.size(); i++) // Test attribute
{
- SCROW nLastRow;
- if (aCol[i].GetLastVisibleAttr( nLastRow ))
+ if (bCalcHiddens || !rDocument.ColHidden(i, nTab))
{
- bFound = true;
- nMaxX = i;
- if (nLastRow > nMaxY)
- nMaxY = nLastRow;
+ SCROW nLastRow;
+ if (aCol[i].GetLastVisibleAttr( nLastRow ))
+ {
+ bFound = true;
+ nMaxX = i;
+ if (nLastRow > nMaxY)
+ nMaxY = nLastRow;
+ }
}
}