tdf#84953 Only resize proportionally when dragging on a corner

Change-Id: Iec4eda867216575e058fa673788d9345da05c872
Reviewed-on: https://gerrit.libreoffice.org/23291
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
This commit is contained in:
Samuel Mehrbrodt
2016-03-15 19:43:36 +01:00
parent eca17faebd
commit e41d23abb0
3 changed files with 28 additions and 14 deletions

View File

@@ -297,9 +297,15 @@ bool FuPoor::doConstructOrthogonal() const
if (rMarkList.GetMarkCount() == 1) if (rMarkList.GetMarkCount() == 1)
{ {
sal_uInt16 aObjIdentifier = rMarkList.GetMark(0)->GetMarkedSdrObj()->GetObjIdentifier(); sal_uInt16 aObjIdentifier = rMarkList.GetMark(0)->GetMarkedSdrObj()->GetObjIdentifier();
return aObjIdentifier == OBJ_GRAF || bool bIsMediaSelected = aObjIdentifier == OBJ_GRAF ||
aObjIdentifier == OBJ_MEDIA || aObjIdentifier == OBJ_MEDIA ||
aObjIdentifier == OBJ_OLE2; aObjIdentifier == OBJ_OLE2;
SdrHdl* pHdl = pView->PickHandle(aMDPos);
// Resize proportionally when media is selected and the user drags on a corner
if (pHdl)
return bIsMediaSelected && pHdl->IsCornerHdl();
return bIsMediaSelected;
} }
} }
else if (aSfxRequest.GetSlot() == SID_DRAW_XPOLYGON || aSfxRequest.GetSlot() == SID_DRAW_XPOLYGON_NOFILL) else if (aSfxRequest.GetSlot() == SID_DRAW_XPOLYGON || aSfxRequest.GetSlot() == SID_DRAW_XPOLYGON_NOFILL)

View File

@@ -1124,23 +1124,26 @@ bool FuPoor::cancel()
bool FuPoor::doConstructOrthogonal() const bool FuPoor::doConstructOrthogonal() const
{ {
// Check whether a media object is selected // Check whether a media object is selected
bool bIsMediaSelected = false; bool bResizeKeepRatio = false;
// tdf#89758 Avoid interactive crop preview from being proportionally scaled by default. // tdf#89758 Avoid interactive crop preview from being proportionally scaled by default.
if (mpView->AreObjectsMarked() && mpView->GetDragMode() != SDRDRAG_CROP) if (mpView->AreObjectsMarked() && mpView->GetDragMode() != SDRDRAG_CROP)
{ {
const SdrMarkList& rMarkList = mpView->GetMarkedObjectList(); const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
if (rMarkList.GetMarkCount() == 1) if (rMarkList.GetMarkCount() == 1)
{ {
SdrMark* pMark = rMarkList.GetMark(0); sal_uInt16 aObjIdentifier = rMarkList.GetMark(0)->GetMarkedSdrObj()->GetObjIdentifier();
sal_uInt16 aObjIdentifier = pMark->GetMarkedSdrObj()->GetObjIdentifier(); bResizeKeepRatio = aObjIdentifier == OBJ_GRAF ||
bIsMediaSelected = aObjIdentifier == OBJ_GRAF ||
aObjIdentifier == OBJ_MEDIA || aObjIdentifier == OBJ_MEDIA ||
aObjIdentifier == OBJ_OLE2; aObjIdentifier == OBJ_OLE2;
} }
} }
SdrHdl* pHdl = mpView->PickHandle(aMDPos);
// Resize proportionally when media is selected and the user drags on a corner
if (pHdl)
bResizeKeepRatio = bResizeKeepRatio && pHdl->IsCornerHdl();
return ( return (
bIsMediaSelected || bResizeKeepRatio ||
SID_DRAW_XLINE == nSlotId || SID_DRAW_XLINE == nSlotId ||
SID_DRAW_CIRCLEARC == nSlotId || SID_DRAW_CIRCLEARC == nSlotId ||
SID_DRAW_SQUARE == nSlotId || SID_DRAW_SQUARE == nSlotId ||

View File

@@ -4079,29 +4079,34 @@ void SwEditWin::MouseMove(const MouseEvent& _rMEvt)
if( bIsDocReadOnly ) if( bIsDocReadOnly )
break; break;
bool bIsMediaSelected = rSh.GetSelectionType() & nsSelectionType::SEL_GRF || bool bResizeKeepRatio = rSh.GetSelectionType() & nsSelectionType::SEL_GRF ||
rSh.GetSelectionType() & nsSelectionType::SEL_MEDIA || rSh.GetSelectionType() & nsSelectionType::SEL_MEDIA ||
rSh.GetSelectionType() & nsSelectionType::SEL_OLE; rSh.GetSelectionType() & nsSelectionType::SEL_OLE;
bool bisResize = g_eSdrMoveHdl != HDL_MOVE; bool bisResize = g_eSdrMoveHdl != HDL_MOVE;
// Resize proportionally when media is selected and the user drags on a corner
const Point aSttPt(PixelToLogic(m_aStartPos));
SdrHdl* pHdl = pSdrView->PickHandle(aSttPt);
if (pHdl)
bResizeKeepRatio = bResizeKeepRatio && pHdl->IsCornerHdl();
if (pSdrView) if (pSdrView)
{ {
if (pSdrView->GetDragMode() == SDRDRAG_CROP) if (pSdrView->GetDragMode() == SDRDRAG_CROP)
bisResize = false; bisResize = false;
if (rMEvt.IsShift()) if (rMEvt.IsShift())
{ {
pSdrView->SetAngleSnapEnabled(!bIsMediaSelected); pSdrView->SetAngleSnapEnabled(!bResizeKeepRatio);
if (bisResize) if (bisResize)
pSdrView->SetOrtho(!bIsMediaSelected); pSdrView->SetOrtho(!bResizeKeepRatio);
else else
pSdrView->SetOrtho(true); pSdrView->SetOrtho(true);
} }
else else
{ {
pSdrView->SetAngleSnapEnabled(bIsMediaSelected); pSdrView->SetAngleSnapEnabled(bResizeKeepRatio);
if (bisResize) if (bisResize)
pSdrView->SetOrtho(bIsMediaSelected); pSdrView->SetOrtho(bResizeKeepRatio);
else else
pSdrView->SetOrtho(false); pSdrView->SetOrtho(false);
} }