diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-05-10 15:47:53 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-05-11 09:09:52 +0200 |
commit | f8d29fea9915a5fe66e4ba24cbd3b248929b51b7 (patch) | |
tree | 04e56aaf1432bf00cb67f5f02d8b9f7d631ef9ed /svx/source/svdraw | |
parent | 08b79ade4f2e2fa98487696591123f71a7521dff (diff) |
handle empty tools::Rectangle in svx
Change-Id: I45e26c9cdc00ae6d3bc56534d612b83b5ac26074
Reviewed-on: https://gerrit.libreoffice.org/72125
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx/source/svdraw')
-rw-r--r-- | svx/source/svdraw/svdogrp.cxx | 27 | ||||
-rw-r--r-- | svx/source/svdraw/svdopath.cxx | 8 |
2 files changed, 26 insertions, 9 deletions
diff --git a/svx/source/svdraw/svdogrp.cxx b/svx/source/svdraw/svdogrp.cxx index 61bca73c9a37..c50ba9524908 100644 --- a/svx/source/svdraw/svdogrp.cxx +++ b/svx/source/svdraw/svdogrp.cxx @@ -501,17 +501,26 @@ void SdrObjGroup::SetSnapRect(const tools::Rectangle& rRect) { tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect(); tools::Rectangle aOld(GetSnapRect()); - long nMulX=rRect.Right()-rRect.Left(); - long nDivX=aOld.Right()-aOld.Left(); - long nMulY=rRect.Bottom()-rRect.Top(); - long nDivY=aOld.Bottom()-aOld.Top(); - if (nDivX==0) { nMulX=1; nDivX=1; } - if (nDivY==0) { nMulY=1; nDivY=1; } - if (nMulX!=nDivX || nMulY!=nDivY) { - Fraction aX(nMulX,nDivX); - Fraction aY(nMulY,nDivY); + if (aOld.IsEmpty()) + { + Fraction aX(1,1); + Fraction aY(1,1); Resize(aOld.TopLeft(),aX,aY); } + else + { + long nMulX=rRect.Right()-rRect.Left(); + long nDivX=aOld.Right()-aOld.Left(); + long nMulY=rRect.Bottom()-rRect.Top(); + long nDivY=aOld.Bottom()-aOld.Top(); + if (nDivX==0) { nMulX=1; nDivX=1; } + if (nDivY==0) { nMulY=1; nDivY=1; } + if (nMulX!=nDivX || nMulY!=nDivY) { + Fraction aX(nMulX,nDivX); + Fraction aY(nMulY,nDivY); + Resize(aOld.TopLeft(),aX,aY); + } + } if (rRect.Left()!=aOld.Left() || rRect.Top()!=aOld.Top()) { Move(Size(rRect.Left()-aOld.Left(),rRect.Top()-aOld.Top())); } diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx index 4c3d0f2040b9..12a7b2c1af39 100644 --- a/svx/source/svdraw/svdopath.cxx +++ b/svx/source/svdraw/svdopath.cxx @@ -2362,6 +2362,14 @@ void SdrPathObj::RecalcSnapRect() void SdrPathObj::NbcSetSnapRect(const tools::Rectangle& rRect) { tools::Rectangle aOld(GetSnapRect()); + if (aOld.IsEmpty()) + { + Fraction aX(1,1); + Fraction aY(1,1); + NbcResize(aOld.TopLeft(), aX, aY); + NbcMove(Size(rRect.Left() - aOld.Left(), rRect.Top() - aOld.Top())); + return; + } // Take empty into account when calculating scale factors long nMulX = rRect.IsWidthEmpty() ? 0 : rRect.Right() - rRect.Left(); |