diff options
Diffstat (limited to 'sw/source/ui/shells/grfsh.cxx')
-rw-r--r-- | sw/source/ui/shells/grfsh.cxx | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/sw/source/ui/shells/grfsh.cxx b/sw/source/ui/shells/grfsh.cxx index bfee25b84501..f29eb7486221 100644 --- a/sw/source/ui/shells/grfsh.cxx +++ b/sw/source/ui/shells/grfsh.cxx @@ -41,6 +41,7 @@ #include <svx/sdgmoitm.hxx> #include <editeng/brushitem.hxx> #include <svx/grfflt.hxx> +#include <svx/compressgraphicdialog.hxx> #include <svx/tbxcolor.hxx> #include <fmturl.hxx> #include <view.hxx> @@ -115,6 +116,50 @@ void SwGrfShell::Execute(SfxRequest &rReq) } } break; + case SID_COMPRESS_GRAPHIC: + { + const Graphic* pGraphic = rSh.GetGraphic(); + if( pGraphic ) + { + Size aSize ( + TWIP_TO_MM100(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Width()), + TWIP_TO_MM100(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Height())); + + SfxItemSet aSet( rSh.GetAttrPool(), RES_GRFATR_CROPGRF, RES_GRFATR_CROPGRF ); + rSh.GetCurAttr( aSet ); + SwCropGrf aCrop( (const SwCropGrf&) aSet.Get(RES_GRFATR_CROPGRF) ); + + Rectangle aCropRectangle( + TWIP_TO_MM100(aCrop.GetLeft()), + TWIP_TO_MM100(aCrop.GetTop()), + TWIP_TO_MM100(aCrop.GetRight()), + TWIP_TO_MM100(aCrop.GetBottom()) ); + + Graphic aGraphic = Graphic( *pGraphic ); + + CompressGraphicsDialog aDialog( GetView().GetWindow(), aGraphic, aSize, aCropRectangle, GetView().GetViewFrame()->GetBindings() ); + if( aDialog.Execute() == RET_OK ) + { + rSh.StartAllAction(); + rSh.StartUndo(UNDO_START); + Rectangle aScaledCropedRectangle = aDialog.GetScaledCropRectangle(); + + aCrop.SetLeft( MM100_TO_TWIP( aScaledCropedRectangle.Left() )); + aCrop.SetTop( MM100_TO_TWIP( aScaledCropedRectangle.Top() )); + aCrop.SetRight( MM100_TO_TWIP( aScaledCropedRectangle.Right() )); + aCrop.SetBottom( MM100_TO_TWIP( aScaledCropedRectangle.Bottom() )); + + Graphic aCompressedGraphic( aDialog.GetCompressedGraphic() ); + rSh.ReRead(aEmptyStr, aEmptyStr, (const Graphic*) &aCompressedGraphic); + + rSh.SetAttr(aCrop); + + rSh.EndUndo(UNDO_END); + rSh.EndAllAction(); + } + } + } + break; case SID_EXTERNAL_EDIT: { /* When the graphic is selected to be opened via some external tool |