From 5f2010ed8436e6da90a996efbf070f34e485efd6 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Thu, 1 Aug 2013 23:18:13 +0200 Subject: fdo#67639 Rotate crop area when the image is rotated. Change-Id: Ifdd0080f278b67b815f15c71523497de59e615bd Reviewed-on: https://gerrit.libreoffice.org/5235 Reviewed-by: Miklos Vajna Tested-by: Miklos Vajna --- sw/source/ui/shells/grfsh.cxx | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/sw/source/ui/shells/grfsh.cxx b/sw/source/ui/shells/grfsh.cxx index 33108c062559..911d1e202c1e 100644 --- a/sw/source/ui/shells/grfsh.cxx +++ b/sw/source/ui/shells/grfsh.cxx @@ -764,11 +764,33 @@ void SwGrfShell::ExecuteRotation(SfxRequest &rReq) aTransform.rotate(aRotation); rShell.ReRead(aEmptyStr, aEmptyStr, (const Graphic*) &aGraphic); - SwFlyFrmAttrMgr aManager( false, &rShell, rShell.IsFrmSelected() ? FRMMGR_TYPE_NONE : FRMMGR_TYPE_GRF); + SwFlyFrmAttrMgr aManager(false, &rShell, rShell.IsFrmSelected() ? FRMMGR_TYPE_NONE : FRMMGR_TYPE_GRF); Size aSize(aManager.GetSize().Height(), aManager.GetSize().Width()); aManager.SetSize(aSize); aManager.UpdateFlyFrm(); + SfxItemSet aSet( rShell.GetAttrPool(), RES_GRFATR_CROPGRF, RES_GRFATR_CROPGRF ); + rShell.GetCurAttr( aSet ); + SwCropGrf aCrop( (const SwCropGrf&) aSet.Get(RES_GRFATR_CROPGRF) ); + Rectangle aCropRectangle(aCrop.GetLeft(), aCrop.GetTop(), aCrop.GetRight(), aCrop.GetBottom()); + + if (rReq.GetSlot() == SID_ROTATE_GRAPHIC_LEFT) + { + aCrop.SetLeft( aCropRectangle.Top() ); + aCrop.SetTop( aCropRectangle.Right() ); + aCrop.SetRight( aCropRectangle.Bottom() ); + aCrop.SetBottom( aCropRectangle.Left() ); + } + else if (rReq.GetSlot() == SID_ROTATE_GRAPHIC_RIGHT) + { + aCrop.SetLeft( aCropRectangle.Bottom() ); + aCrop.SetTop( aCropRectangle.Left() ); + aCrop.SetRight( aCropRectangle.Top() ); + aCrop.SetBottom( aCropRectangle.Right() ); + } + + rShell.SetAttr(aCrop); + rShell.EndUndo(UNDO_END); rShell.EndAllAction(); } -- cgit v1.2.3