summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorPhilipp Lohmann <Philipp.Lohmann@Sun.COM>2009-10-29 14:01:21 +0100
committerPhilipp Lohmann <Philipp.Lohmann@Sun.COM>2009-10-29 14:01:21 +0100
commit80ccdb417dd3eeb6f70d8c39eb6448185adec94c (patch)
tree18c705e2bd96689a51427d571ce79f3ddf1c64c2 /vcl
parent069ce0d6e5cc9994af9b6470c2cf02057db84d0f (diff)
#i106341# catch division by zero in exotic case
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/window/printdlg.cxx20
1 files changed, 16 insertions, 4 deletions
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index 66cac6f83a5d..1e1a9006c405 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -83,15 +83,22 @@ void PrintDialog::PrintPreviewWindow::Resize()
aNewSize.Height() -= 2;
Size aScaledSize;
double fScale = 1.0;
- if( maOrigSize.Width() > maOrigSize.Height() )
+
+ // #i106435# catch corner case of Size(0,0)
+ Size aOrigSize( maOrigSize );
+ if( aOrigSize.Width() < 1 )
+ aOrigSize.Width() = aNewSize.Width();
+ if( aOrigSize.Height() < 1 )
+ aOrigSize.Height() = aNewSize.Height();
+ if( aOrigSize.Width() > aOrigSize.Height() )
{
- aScaledSize = Size( aNewSize.Width(), aNewSize.Width() * maOrigSize.Height() / maOrigSize.Width() );
+ aScaledSize = Size( aNewSize.Width(), aNewSize.Width() * aOrigSize.Height() / aOrigSize.Width() );
if( aScaledSize.Height() > aNewSize.Height() )
fScale = double(aNewSize.Height())/double(aScaledSize.Height());
}
else
{
- aScaledSize = Size( aNewSize.Height() * maOrigSize.Width() / maOrigSize.Height(), aNewSize.Height() );
+ aScaledSize = Size( aNewSize.Height() * aOrigSize.Width() / aOrigSize.Height(), aNewSize.Height() );
if( aScaledSize.Width() > aNewSize.Width() )
fScale = double(aNewSize.Width())/double(aScaledSize.Width());
}
@@ -125,7 +132,12 @@ void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& )
(aSize.Height() - aPreviewSize.Height()) / 2 );
const Size aLogicSize( maPageVDev.PixelToLogic( aPreviewSize, MapMode( MAP_100TH_MM ) ) );
- double fScale = double(aLogicSize.Width())/double(maOrigSize.Width());
+ Size aOrigSize( maOrigSize );
+ if( aOrigSize.Width() < 1 )
+ aOrigSize.Width() = aLogicSize.Width();
+ if( aOrigSize.Height() < 1 )
+ aOrigSize.Height() = aLogicSize.Height();
+ double fScale = double(aLogicSize.Width())/double(aOrigSize.Width());
maPageVDev.Erase();