Kaydet (Commit) bb01d7bc authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski

tdf#97505 Account empty pages for print preview

Commit 1296f9dc was just a workaround
to fix the crash, while I couldn't find a way to get the layout from
the print preview, as all shells seemed empty. Took me a while to
realize the SwViewShell also has a layout, which is available, so we
can account for the empty pages correctly.

Change-Id: Icf0e9fdc0c1eeb6cadc48482595482545fd553e7
üst 5abe0ab1
......@@ -189,30 +189,35 @@ static SwPrintUIOptions * lcl_GetPrintUIOptions(
// Get current page number
sal_uInt16 nCurrentPage = 1;
SwWrtShell* pSh = pDocShell->GetWrtShell();
const SwWrtShell* pSh = pDocShell->GetWrtShell();
const SwRootFrame *pFrame = nullptr;
if (pSh)
{
SwPaM* pShellCursor = pSh->GetCursor();
nCurrentPage = pShellCursor->GetPageNum();
pFrame = pSh->GetLayout();
}
else if (!bSwSrcView)
{
const SwPagePreview* pPreview = dynamic_cast< const SwPagePreview* >(pView);
OSL_ENSURE(pPreview, "Unexpected type of the view shell");
if (pPreview)
{
nCurrentPage = pPreview->GetSelectedPage();
pFrame = pPreview->GetViewShell()->GetLayout();
}
}
// If blanks are skipped, account for them in initial page range value
if (pSh && !rPrintData.IsPrintEmptyPages())
if (pFrame && !rPrintData.IsPrintEmptyPages())
{
sal_uInt16 nMax = nCurrentPage;
SwPageFrame *pPage = dynamic_cast<SwPageFrame*>(pSh->GetLayout()->Lower());
const SwPageFrame *pPage = dynamic_cast<const SwPageFrame*>(pFrame->Lower());
for ( ; nMax-- > 0; )
{
if (pPage->Frame().Height() == 0)
nCurrentPage--;
pPage = static_cast<SwPageFrame*>(pPage->GetNext());
pPage = static_cast<const SwPageFrame*>(pPage->GetNext());
}
}
return new SwPrintUIOptions( nCurrentPage, bWebDoc, bSwSrcView, bHasSelection, bHasPostIts, rPrintData );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment