From 77eac365c179e1a1cad3e0d8ebe3fe5bafa65720 Mon Sep 17 00:00:00 2001 From: Takeshi Abe Date: Wed, 14 Dec 2016 07:08:16 +0900 Subject: tdf#91767 Read SfxItemSet before disposing its AbstractSvxZoomDialog Change-Id: I5dc6a1b1fa42a4fd76af398c2fb56461574900ee Reviewed-on: https://gerrit.libreoffice.org/31980 Tested-by: Jenkins Reviewed-by: Takeshi Abe --- starmath/inc/view.hxx | 3 ++ starmath/source/view.cxx | 74 ++++++++++++++++++++++++++---------------------- 2 files changed, 43 insertions(+), 34 deletions(-) (limited to 'starmath') diff --git a/starmath/inc/view.hxx b/starmath/inc/view.hxx index a1a3b4964f13..840b6d27428d 100644 --- a/starmath/inc/view.hxx +++ b/starmath/inc/view.hxx @@ -319,6 +319,9 @@ public: bInsertIntoEditWindow = bEditWindowHadFocusLast; } bool IsInlineEditEnabled() const; + +private: + void ZoomByItemSet(const SfxItemSet *pSet); }; #endif diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index 4486a89bbd27..df0edfcf7ba3 100644 --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -1730,7 +1730,11 @@ void SmViewShell::Execute(SfxRequest& rReq) if ( !GetViewFrame()->GetFrame().IsInPlace() ) { const SfxItemSet *pSet = rReq.GetArgs(); - if ( !pSet ) + if ( pSet ) + { + ZoomByItemSet(pSet); + } + else { SfxItemSet aSet( SmDocShell::GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM); aSet.Put( SvxZoomItem( SvxZoomType::PERCENT, aGraphic->GetZoom())); @@ -1741,39 +1745,7 @@ void SmViewShell::Execute(SfxRequest& rReq) assert(xDlg); xDlg->SetLimits( MINZOOM, MAXZOOM ); if (xDlg->Execute() != RET_CANCEL) - pSet = xDlg->GetOutputItemSet(); - } - } - if ( pSet ) - { - const SvxZoomItem &rZoom = static_cast(pSet->Get(SID_ATTR_ZOOM)); - switch( rZoom.GetType() ) - { - case SvxZoomType::PERCENT: - aGraphic->SetZoom(sal::static_int_cast(rZoom.GetValue ())); - break; - - case SvxZoomType::OPTIMAL: - aGraphic->ZoomToFitInWindow(); - break; - - case SvxZoomType::PAGEWIDTH: - case SvxZoomType::WHOLEPAGE: - { - const MapMode aMap( MapUnit::Map100thMM ); - SfxPrinter *pPrinter = GetPrinter( true ); - Point aPoint; - Rectangle OutputRect(aPoint, pPrinter->GetOutputSize()); - Size OutputSize(pPrinter->LogicToPixel(Size(OutputRect.GetWidth(), - OutputRect.GetHeight()), aMap)); - Size GraphicSize(pPrinter->LogicToPixel(GetDoc()->GetSize(), aMap)); - sal_uInt16 nZ = sal::static_int_cast(std::min(long(Fraction(OutputSize.Width() * 100L, GraphicSize.Width())), - long(Fraction(OutputSize.Height() * 100L, GraphicSize.Height())))); - aGraphic->SetZoom (nZ); - break; - } - default: - break; + ZoomByItemSet(xDlg->GetOutputItemSet()); } } } @@ -2057,4 +2029,38 @@ bool SmViewShell::IsInlineEditEnabled() const return pImpl->aOpts.IsExperimentalMode(); } +void SmViewShell::ZoomByItemSet(const SfxItemSet *pSet) +{ + assert(pSet); + const SvxZoomItem &rZoom = static_cast(pSet->Get(SID_ATTR_ZOOM)); + switch( rZoom.GetType() ) + { + case SvxZoomType::PERCENT: + aGraphic->SetZoom(sal::static_int_cast(rZoom.GetValue ())); + break; + + case SvxZoomType::OPTIMAL: + aGraphic->ZoomToFitInWindow(); + break; + + case SvxZoomType::PAGEWIDTH: + case SvxZoomType::WHOLEPAGE: + { + const MapMode aMap( MapUnit::Map100thMM ); + SfxPrinter *pPrinter = GetPrinter( true ); + Point aPoint; + Rectangle OutputRect(aPoint, pPrinter->GetOutputSize()); + Size OutputSize(pPrinter->LogicToPixel(Size(OutputRect.GetWidth(), + OutputRect.GetHeight()), aMap)); + Size GraphicSize(pPrinter->LogicToPixel(GetDoc()->GetSize(), aMap)); + sal_uInt16 nZ = sal::static_int_cast(std::min(long(Fraction(OutputSize.Width() * 100L, GraphicSize.Width())), + long(Fraction(OutputSize.Height() * 100L, GraphicSize.Height())))); + aGraphic->SetZoom (nZ); + break; + } + default: + break; + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit