tdf#122607 sw: restore CalcLayout() call in getRendererCount()
Effectively revert commit 1ecca673b40fedc53db125e332b087d1c120a254.
There are some documents that aren't formatted correctly.
Change-Id: I4b0cf6313c249a0ed916c2630cd5194d809bfb48
diff --git a/sw/qa/extras/layout/data/tdf122607_leerzeile.odt b/sw/qa/extras/layout/data/tdf122607_leerzeile.odt
new file mode 100644
index 0000000..9819a22
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf122607_leerzeile.odt
Binary files differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index c17adf1..f627227 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -2738,6 +2738,54 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf122607)
"Portion", "Fax:");
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf122607_regression)
{
discardDumpedLayout();
if (mxComponent.is())
mxComponent->dispose();
auto const pName("tdf122607_leerzeile.odt");
OUString const url(m_directories.getURLFromSrc(DATA_DIRECTORY)
+ OUString::createFromAscii(pName));
// note: must set Hidden property, so that SfxFrameViewWindow_Impl::Resize()
// does *not* forward initial VCL Window Resize and thereby triggers a
// layout which does not happen on soffice --convert-to pdf.
std::vector<beans::PropertyValue> aFilterOptions = {
{ beans::PropertyValue("Hidden", -1, uno::Any(true), beans::PropertyState_DIRECT_VALUE) },
};
std::cout << pName << ":\n";
// inline the loading because currently properties can't be passed...
mxComponent = loadFromDesktop(url, "com.sun.star.text.TextDocument",
comphelper::containerToSequence(aFilterOptions));
CPPUNIT_ASSERT(mxComponent.is());
uno::Sequence<beans::PropertyValue> props(comphelper::InitPropertySequence({
{ "FilterName", uno::Any(OUString("writer_pdf_Export")) },
}));
utl::TempFile aTempFile;
uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
xStorable->storeToURL(aTempFile.GetURL(), props);
xmlDocPtr pXmlDoc = parseLayoutDump();
// somehow these 2 rows overlapped in the PDF unless CalcLayout() runs
assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[1]/infos/bounds", "mbFixSize",
"false");
assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[1]/infos/bounds", "top", "2977");
assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[1]/infos/bounds", "height", "241");
assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[2]/infos/bounds", "mbFixSize",
"true");
// this was 3034, causing the overlap
assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[2]/infos/bounds", "top", "3218");
assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/tab[1]/row[2]/infos/bounds", "height", "164");
aTempFile.EnableKillingFile();
}
CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testBtlrCell)
{
SwDoc* pDoc = createDoc("btlr-cell.odt");
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 4a5dcee..5b95045 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -2614,9 +2614,10 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
// should be set for printing as well ...
pViewShell->SetPDFExportOption( true );
// tdf#122607 Re-layout the doc. Calling CalcLayout here is not enough, as it depends
// on the currently visible area which is 0 when doing headless conversion.
pViewShell->Reformat();
// there is some redundancy between those two function calls, but right now
// there is no time to sort this out.
//TODO: check what exactly needs to be done and make just one function for that
pViewShell->CalcLayout();
pViewShell->CalcPagesForPrint( pViewShell->GetPageCount() );