diff options
author | Ivan Timofeev <timofeev.i.s@gmail.com> | 2011-11-16 15:47:51 +0400 |
---|---|---|
committer | Ivan Timofeev <timofeev.i.s@gmail.com> | 2011-11-18 16:26:18 +0400 |
commit | ce888a74614aa83e17a34e557f416acb262419a1 (patch) | |
tree | e1c646064a48c2055d94ba4fade370ee4bd7e70b /sw | |
parent | 639f7b562c0e3304e3b087d86ea2a1134bc0d044 (diff) |
fix fdo#42178: crash when printing from Page Preview
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/ui/inc/pview.hxx | 1 | ||||
-rw-r--r-- | sw/source/ui/uno/unotxdoc.cxx | 16 |
2 files changed, 14 insertions, 3 deletions
diff --git a/sw/source/ui/inc/pview.hxx b/sw/source/ui/inc/pview.hxx index e9902fbfd339..329ba5e567d9 100644 --- a/sw/source/ui/inc/pview.hxx +++ b/sw/source/ui/inc/pview.hxx @@ -273,6 +273,7 @@ public: void ShowVScrollbar(sal_Bool bShow); sal_uInt16 GetPageCount() const { return mnPageCount; } + sal_uInt16 GetSelectedPage() const {return aViewWin.SelectedPage();} sal_Bool HandleWheelCommands( const CommandEvent& ); diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index c849fa7ab961..4a1ef26553f1 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -187,10 +187,20 @@ SwPrintUIOptions * lcl_GetPrintUIOptions( const SwPrintData &rPrintData = pDocShell->GetDoc()->getPrintData(); // Get current page number + sal_uInt16 nCurrentPage = 1; SwWrtShell* pSh = pDocShell->GetWrtShell(); - SwPaM* pShellCrsr = pSh->GetCrsr(); - sal_uInt16 nCurrentPage = pShellCrsr->GetPageNum(sal_True, 0); - + if (pSh) + { + SwPaM* pShellCrsr = pSh->GetCrsr(); + nCurrentPage = pShellCrsr->GetPageNum(sal_True, 0); + } + else + { + const SwPagePreView* pPreView = dynamic_cast< const SwPagePreView* >(pView); + OSL_ENSURE(pPreView, "Unexpected type of the view shell"); + if (pPreView) + nCurrentPage = pPreView->GetSelectedPage(); + } return new SwPrintUIOptions( nCurrentPage, bWebDoc, bSwSrcView, bHasSelection, bHasPostIts, rPrintData ); } |