[Libreoffice-commits] core.git: sw/source
Jan-Marek Glogowski
glogow at fbihome.de
Tue Feb 2 18:02:25 UTC 2016
sw/source/uibase/uno/unotxdoc.cxx | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
New commits:
commit bb01d7bc50e59eb30c0826a000ede52b93074f75
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date: Tue Feb 2 18:38:09 2016 +0100
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
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index c42bcca..9c64773 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 );
More information about the Libreoffice-commits
mailing list