summaryrefslogtreecommitdiffstats
path: root/sw
diff options
context:
space:
mode:
authorIvan Timofeev <timofeev.i.s@gmail.com>2011-11-16 15:47:51 +0400
committerIvan Timofeev <timofeev.i.s@gmail.com>2011-11-18 16:26:18 +0400
commitce888a74614aa83e17a34e557f416acb262419a1 (patch)
treee1c646064a48c2055d94ba4fade370ee4bd7e70b /sw
parentfix UI updating in the print dialog (diff)
downloadcore-ce888a74614aa83e17a34e557f416acb262419a1.tar.gz
core-ce888a74614aa83e17a34e557f416acb262419a1.zip
fix fdo#42178: crash when printing from Page Preview
Diffstat (limited to 'sw')
-rw-r--r--sw/source/ui/inc/pview.hxx1
-rw-r--r--sw/source/ui/uno/unotxdoc.cxx16
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 );
}