Hi there,
I have fixed https://bugs.freedesktop.org/show_bug.cgi?id=42178 :-) ,
but I think an additional review will not be superfluous, since I am
still a newbie.
The fact is SwDocShell::GetWrtShell() always returns 0 in page
preview. And Writer dies due to that in "lcl_GetPrintUIOptions"
function (sw/source/ui/uno/unotxdoc.cxx).
The second patch makes testing of the first one easier. :-) Because,
when you press "Cancel" in a print dialog, then make changes to a doc
and open a print dialog again, you currently will not see any effect.
Options will not be updated. The patch fixes this.
If someone will approve the patches, I will push them.
Thanks,
Ivan
From bc7d667dccb8505516614daa5fb7da7996967617 Mon Sep 17 00:00:00 2001
From: Ivan Timofeev <timofeev.i.s@gmail.com>
Date: Wed, 16 Nov 2011 15:47:51 +0400
Subject: [PATCH 1/2] fix fdo#42178: crash when printing from Page Preview
---
sw/source/ui/inc/pview.hxx | 1 +
sw/source/ui/uno/unotxdoc.cxx | 15 ++++++++++++---
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/sw/source/ui/inc/pview.hxx b/sw/source/ui/inc/pview.hxx
index e9902fb..329ba5e 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 c849fa7..f4d2935 100644
--- a/sw/source/ui/uno/unotxdoc.cxx
+++ b/sw/source/ui/uno/unotxdoc.cxx
@@ -187,10 +187,19 @@ 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);
+ if (pPreView)
+ nCurrentPage = pPreView->GetSelectedPage();
+ }
return new SwPrintUIOptions( nCurrentPage, bWebDoc, bSwSrcView, bHasSelection, bHasPostIts,
rPrintData );
}
--
1.7.7.2
From e312651c459495c9604206a611a36462b12db654 Mon Sep 17 00:00:00 2001
From: Ivan Timofeev <timofeev.i.s@gmail.com>
Date: Wed, 16 Nov 2011 17:01:37 +0400
Subject: [PATCH 2/2] always refresh print ui options, not only after printing
---
sw/source/ui/uno/unotxdoc.cxx | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx
index f4d2935..4b545b4 100644
--- a/sw/source/ui/uno/unotxdoc.cxx
+++ b/sw/source/ui/uno/unotxdoc.cxx
@@ -2661,6 +2661,12 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer(
// otherwise be provided here!
// if( ! m_pRenderData )
// m_pRenderData = new SwRenderData;
+
+ if (nRenderer == 0)
+ {
+ delete m_pPrintUIOptions;
+ m_pPrintUIOptions = 0;
+ }
if (!m_pPrintUIOptions)
m_pPrintUIOptions = lcl_GetPrintUIOptions( pDocShell, pView );
m_pPrintUIOptions->processProperties( rxOptions );
--
1.7.7.2
Context
- [Libreoffice] [PATCH] Fix for fdo#42178 · Ivan Timofeev
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.