summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorTomaž Vajngerl <quikee@gmail.com>2013-02-24 13:45:47 +0100
committerTomaž Vajngerl <quikee@gmail.com>2013-02-24 13:47:55 +0100
commit44faceac60f9046e4827290a85f790a46ed1e227 (patch)
tree93189b494812d484500ec02d0f4dcf710d2e6afb /sw
parentbd502f4d99a6f1e783d7eaf53e0a4d05f04629c1 (diff)
Add "Compress Graphic Dialog" to Writer.
Change-Id: Icff16a86d217b2648ce588ca2b90abefcd1634d9
Diffstat (limited to 'sw')
-rw-r--r--sw/sdi/_grfsh.sdi7
-rw-r--r--sw/source/ui/app/mn.src1
-rw-r--r--sw/source/ui/shells/grfsh.cxx45
3 files changed, 52 insertions, 1 deletions
diff --git a/sw/sdi/_grfsh.sdi b/sw/sdi/_grfsh.sdi
index 23afadd6f9ce..a76718431409 100644
--- a/sw/sdi/_grfsh.sdi
+++ b/sw/sdi/_grfsh.sdi
@@ -42,13 +42,18 @@ interface BaseTextGraphic
DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR";
]
-
SID_SAVE_GRAPHIC
[
ExecMethod = Execute ;
StateMethod = GetAttrState ;
]
+ SID_COMPRESS_GRAPHIC
+ [
+ ExecMethod = Execute ;
+ StateMethod = GetAttrState ;
+ ]
+
SID_EXTERNAL_EDIT
[
ExecMethod = Execute ;
diff --git a/sw/source/ui/app/mn.src b/sw/source/ui/app/mn.src
index 4dd44253774b..f95371d13902 100644
--- a/sw/source/ui/app/mn.src
+++ b/sw/source/ui/app/mn.src
@@ -1286,6 +1286,7 @@ Menu MN_GRF_POPUPMENU
MN_FRM_CAPTION_ITEM
SEPARATOR;
MenuItem { ITEM_SAVE_GRAPHIC };
+ MenuItem { ITEM_COMPRESS_GRAPHIC };
MenuItem { ITEM_EXTERNAL_EDIT };
SEPARATOR;
MenuItem
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