tdf#64703 sc: fix regression of printing page breaks
After hidden rows or rows hidden by Autofilter,
printing removed the page breaks between the visible
rows, too. Now Calc supports WYSWYG: it prints all the
visible page breaks, which includes the page breaks
between the visible rows, and page breaks between the
hidden rows (multiple page breaks of a hidden row
sequence converted to a single page break).
This was a regression since LO 3.6, introducing
Autofilter with multichoice.
Co-authored-by: Tibor Nagy (NISZ)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118984
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
(cherry picked from commit 8b2a2de2481843502f0566e773ed11532520bc70)
Check nNextPageBreak for ScRowBreakIterator::NOT_FOUND, tdf#64703 follow-up
Ifa0fd1b53da70018d8d14abd4f8ba347908d5ea9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119732
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
Change-Id: I87858d36fc62b8a5952cfd5bc39dbe90f1452ac0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119620
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sc/qa/extras/scpdfexport.cxx b/sc/qa/extras/scpdfexport.cxx
index b98ee77..e066208 100644
--- a/sc/qa/extras/scpdfexport.cxx
+++ b/sc/qa/extras/scpdfexport.cxx
@@ -65,11 +65,13 @@ public:
void testExportRange_Tdf120161();
void testExportFitToPage_Tdf103516();
void testUnoCommands_Tdf120161();
void testTdf64703_hiddenPageBreak();
CPPUNIT_TEST_SUITE(ScPDFExportTest);
CPPUNIT_TEST(testExportRange_Tdf120161);
CPPUNIT_TEST(testExportFitToPage_Tdf103516);
CPPUNIT_TEST(testUnoCommands_Tdf120161);
CPPUNIT_TEST(testTdf64703_hiddenPageBreak);
CPPUNIT_TEST_SUITE_END();
};
@@ -438,6 +440,23 @@ void ScPDFExportTest::testUnoCommands_Tdf120161()
}
}
void ScPDFExportTest::testTdf64703_hiddenPageBreak()
{
mxComponent = loadFromDesktop(m_directories.getURLFromSrc(DATA_DIRECTORY)
+ "tdf64703_hiddenPageBreak.ods",
"com.sun.star.sheet.SpreadsheetDocument");
uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
// A1:A11: 4-page export
{
ScRange range1(0, 0, 0, 0, 10, 0);
std::shared_ptr<utl::TempFile> pPDFFile = exportToPDF(xModel, range1);
bool bFound = false;
CPPUNIT_ASSERT(hasTextInPdf(pPDFFile, "/Count 4>>", bFound));
CPPUNIT_ASSERT_EQUAL(true, bFound);
}
}
CPPUNIT_TEST_SUITE_REGISTRATION(ScPDFExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/qa/extras/testdocuments/tdf64703_hiddenPageBreak.ods b/sc/qa/extras/testdocuments/tdf64703_hiddenPageBreak.ods
new file mode 100644
index 0000000..87f1109
--- /dev/null
+++ b/sc/qa/extras/testdocuments/tdf64703_hiddenPageBreak.ods
Binary files differ
diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx
index 950fa94..782af0a 100644
--- a/sc/source/ui/view/printfun.cxx
+++ b/sc/source/ui/view/printfun.cxx
@@ -3197,8 +3197,11 @@ void PrintPageRanges::calculate(ScDocument& rDoc,
nLastVisibleRow = nLastRow;
}
else
// skip all hidden rows.
nRow = nLastRow;
{
// Skip all hidden rows until next pagebreak.
nRow = ((nNextPageBreak == ScRowBreakIterator::NOT_FOUND) ? nLastRow :
std::min(nLastRow, nNextPageBreak - 1));
}
}
if (!bVisRow)