summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2016-02-02 18:38:09 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2016-02-02 18:38:09 +0100
commitbb01d7bc50e59eb30c0826a000ede52b93074f75 (patch)
tree710b4eaf8ebb4ce30f1331c51769e2b717c193e0 /sw
parent5abe0ab18a10a3cb13485ce3ba9433bd82b32221 (diff)
tdf#97505 Account empty pages for print preview
Commit 1296f9dc9e502abd8422dfeee1ac7747a82aee17 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
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx13
1 files changed, 9 insertions, 4 deletions
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index c42bcca0a0c5..9c647734b36e 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -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 );