sc/qa/extras/scpdfexport.cxx               |   39 ++++++++++++++++++++++++++--
 sc/qa/extras/testdocuments/23000_rows.fods |   40 +++++++++++++++++++++++++++++
 sc/source/ui/view/printfun.cxx             |    2 -
 3 files changed, 77 insertions(+), 4 deletions(-)

New commits:
commit eabe86fb8f57457978bc224b9bc942239a3d25c9
Author:     Mike Kaganski <[email protected]>
AuthorDate: Sun Mar 8 12:08:50 2026 +0500
Commit:     Xisco Fauli <[email protected]>
CommitDate: Mon Mar 9 15:26:18 2026 +0100

    tdf#156893: in ScPrintFunc::DrawToDev, row count is not a hint
    
    Before this, the function created at most 1024 rows in ScTableInfo,
    which is OK for notmal pages, but is limiting whole sheet export.
    
    Change-Id: Ie1663147476f56e879673a7532ec9ae8bb28ac68
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201204
    Reviewed-by: Mike Kaganski <[email protected]>
    Tested-by: Jenkins
    (cherry picked from commit 015861bbf45e5cf901fec9c8394b3046ce27514c)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201276
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/sc/qa/extras/scpdfexport.cxx b/sc/qa/extras/scpdfexport.cxx
index 6ef9267e4ee5..67107aa88726 100644
--- a/sc/qa/extras/scpdfexport.cxx
+++ b/sc/qa/extras/scpdfexport.cxx
@@ -18,6 +18,7 @@
 #include <com/sun/star/table/XCellRange.hpp>
 #include <com/sun/star/view/XSelectionSupplier.hpp>
 #include <comphelper/propertysequence.hxx>
+#include <comphelper/sequence.hxx>
 #include <unotools/tempfile.hxx>
 #include <docsh.hxx>
 #include <editutil.hxx>
@@ -46,7 +47,8 @@ public:
 
     // helpers
 private:
-    void exportToPDF(const uno::Reference<frame::XModel>& xModel, const 
ScRange& range);
+    void exportToPDF(const uno::Reference<frame::XModel>& xModel, const 
ScRange& range,
+                     const std::initializer_list<css::beans::PropertyValue>& 
params = {});
 
     void exportToPDFWithUnoCommands(const OUString& rRange);
 
@@ -73,6 +75,7 @@ public:
     void testTdf84012();
     void testTdf78897();
     void testForcepoint97();
+    void testTdf156893();
 
     CPPUNIT_TEST_SUITE(ScPDFExportTest);
     CPPUNIT_TEST(testPopupRectangleSize_Tdf162955);
@@ -91,6 +94,7 @@ public:
     CPPUNIT_TEST(testTdf84012);
     CPPUNIT_TEST(testTdf78897);
     CPPUNIT_TEST(testForcepoint97);
+    CPPUNIT_TEST(testTdf156893);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -135,7 +139,8 @@ bool ScPDFExportTest::hasTextInPdf(const char* sText, bool& 
bFound)
     return (nRead == nFileSize);
 }
 
-void ScPDFExportTest::exportToPDF(const uno::Reference<frame::XModel>& xModel, 
const ScRange& range)
+void ScPDFExportTest::exportToPDF(const uno::Reference<frame::XModel>& xModel, 
const ScRange& range,
+                                  const 
std::initializer_list<css::beans::PropertyValue>& params)
 {
     // get XSpreadsheet
     uno::Reference<sheet::XSpreadsheetDocument> xDoc(xModel, 
uno::UNO_QUERY_THROW);
@@ -168,7 +173,8 @@ void ScPDFExportTest::exportToPDF(const 
uno::Reference<frame::XModel>& xModel, c
 
     // init set of params for storeToURL() call
     css::uno::Sequence<css::beans::PropertyValue> seqArguments{
-        comphelper::makePropertyValue(u"FilterData"_ustr, aFilterData),
+        comphelper::makePropertyValue(u"FilterData"_ustr,
+                                      comphelper::concatSequences(aFilterData, 
params)),
         comphelper::makePropertyValue(u"FilterName"_ustr, 
u"calc_pdf_Export"_ustr),
         comphelper::makePropertyValue(u"URL"_ustr, maTempFile.GetURL())
     };
@@ -916,6 +922,33 @@ void ScPDFExportTest::testForcepoint97()
     exportToPDF(xModel, range1);
 }
 
+void ScPDFExportTest::testTdf156893()
+{
+    // Given a spreadsheet with a large number of rows, the whole-sheet export 
to PDF should export
+    // all rows.
+    loadFromFile(u"23000_rows.fods");
+    uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+
+    // A1:A23000
+    ScRange range(0, 0, 0, 0, 22999, 0);
+    exportToPDF(xModel, range, { 
comphelper::makePropertyValue(u"SinglePageSheets"_ustr, true) });
+
+    // Parse the export result
+    auto pPdfDocument = parsePDFExport();
+    CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
+
+    // Get the first page
+    auto pPdfPage = pPdfDocument->openPage(0);
+    CPPUNIT_ASSERT(pPdfPage);
+
+    // Without the fix, this failed with
+    // - Expected: 23000
+    // - Actual  : 1022
+    CPPUNIT_ASSERT_EQUAL(23000, pPdfPage->getObjectCount());
+    CPPUNIT_ASSERT_EQUAL(u"Last row"_ustr,
+                         
pPdfPage->getObject(22999)->getText(pPdfPage->getTextPage()));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScPDFExportTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sc/qa/extras/testdocuments/23000_rows.fods 
b/sc/qa/extras/testdocuments/23000_rows.fods
new file mode 100644
index 000000000000..f3ab0017f9eb
--- /dev/null
+++ b/sc/qa/extras/testdocuments/23000_rows.fods
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
office:version="1.4" 
office:mimetype="application/vnd.oasis.opendocument.spreadsheet">
+ <office:font-face-decls>
+  <style:font-face style:name="Liberation Sans" 
svg:font-family="&apos;Liberation Sans&apos;" style:font-family-generic="swiss" 
style:font-pitch="variable"/>
+ </office:font-face-decls>
+ <office:styles>
+  <style:default-style style:family="table-cell">
+   <style:text-properties style:font-name="Liberation Sans" 
fo:font-size="10pt" fo:language="en" fo:country="US"/>
+  </style:default-style>
+  <style:style style:name="Default" style:family="table-cell"/>
+ </office:styles>
+ <office:automatic-styles>
+  <style:style style:name="co1" style:family="table-column">
+   <style:table-column-properties style:column-width="25mm"/>
+  </style:style>
+  <style:style style:name="ro1" style:family="table-row">
+   <style:table-row-properties style:row-height="4.5mm" fo:break-before="auto" 
style:use-optimal-row-height="true"/>
+  </style:style>
+  <style:style style:name="ce1" style:family="table-cell" 
style:parent-style-name="Default">
+   <style:paragraph-properties fo:text-align="end"/>
+  </style:style>
+ </office:automatic-styles>
+ <office:body>
+  <office:spreadsheet>
+   <table:table table:name="Sheet1">
+    <table:table-column table:style-name="co1" 
table:default-cell-style-name="Default"/>
+    <table:table-row table:style-name="ro1">
+     <table:table-cell table:style-name="ce1" office:value-type="string" 
office:string-value="First row"/>
+    </table:table-row>
+    <table:table-row table:style-name="ro1" table:number-rows-repeated="22998">
+     <table:table-cell table:style-name="ce1" office:value-type="string" 
office:string-value="row"/>
+    </table:table-row>
+    <table:table-row table:style-name="ro1">
+     <table:table-cell table:style-name="ce1" office:value-type="string" 
office:string-value="Last row"/>
+    </table:table-row>
+   </table:table>
+  </office:spreadsheet>
+ </office:body>
+</office:document>
\ No newline at end of file
diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx
index 8f54b3718772..90e4fda9d30e 100644
--- a/sc/source/ui/view/printfun.cxx
+++ b/sc/source/ui/view/printfun.cxx
@@ -526,7 +526,7 @@ void ScPrintFunc::DrawToDev(ScDocument& rDoc, OutputDevice* 
pDev, double /* nPri
 
     //  Assemble data
 
-    ScTableInfo aTabInfo(nY1, nY2, true);
+    ScTableInfo aTabInfo(nY1, nY2, false);
     rDoc.FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nTab,
                    nScaleX, nScaleY, false, bFormula );
     lcl_HidePrint( aTabInfo, nX1, nX2 );

Reply via email to