summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Jung <phil.jung@free.fr>2015-05-02 00:22:25 +0200
committerJan Holesovsky <kendy@collabora.com>2015-05-05 10:03:59 +0000
commitb1df1ac809fd6de972a6ed4f638a1ac8d29ba40d (patch)
tree0cdb28e2b5af146dfb84f2a936d8da84e4fe4624
parent80a38d299133823e93ec5c29e8fe5c51771940d5 (diff)
tdf#34555 add to scalc: crop, change img, save img, edit with ext tools
Adds Save graphic, Change Picture, Edit with external tool, Crop (by handles) to scalc. Proposal of new Format menu and image context menu organisation. This is part of a serie of 4 patches that adds Save graphic, Change Picture, Edit with external tool, Crop (by handles) in all products (scalc, sdraw, simpress, swriter). Main menus, toolbars and contextual menus are updated accordingly. Change-Id: I7f5cf2d1eb3870245684eadf5909fe590d56bf42 Reviewed-on: https://gerrit.libreoffice.org/15589 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jan Holesovsky <kendy@collabora.com>
-rw-r--r--officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu28
-rw-r--r--sc/inc/sc.hrc1
-rw-r--r--sc/sdi/graphsh.sdi19
-rw-r--r--sc/source/ui/drawfunc/graphsh.cxx129
-rw-r--r--sc/source/ui/drawfunc/objdraw.src23
-rw-r--r--sc/source/ui/inc/graphsh.hxx9
-rw-r--r--sc/uiconfig/scalc/menubar/menubar.xml13
-rw-r--r--sc/uiconfig/scalc/toolbar/graphicobjectbar.xml1
8 files changed, 218 insertions, 5 deletions
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
index 103bc0206583..433c7236753b 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
@@ -1914,9 +1914,9 @@
<value xml:lang="en-US">Pri~nt Ranges</value>
</prop>
</node>
- <node oor:name=".uno:DrawGraphicMenu" oor:op="replace">
+ <node oor:name=".uno:FormatObjectMenu" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
- <value xml:lang="en-US">Graph~ic</value>
+ <value xml:lang="en-US">O~bject</value>
</prop>
</node>
<node oor:name=".uno:ToggleFormula" oor:op="replace">
@@ -1994,6 +1994,30 @@
<value xml:lang="en-US">Paste Only Value</value>
</prop>
</node>
+ <node oor:name=".uno:CompressGraphic" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="en-US">Co~mpress Image...</value>
+ </prop>
+ <prop oor:name="Properties" oor:type="xs:int">
+ <value>1</value>
+ </prop>
+ </node>
+ <node oor:name=".uno:SaveGraphic" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="en-US">Save Image...</value>
+ </prop>
+ <prop oor:name="Properties" oor:type="xs:int">
+ <value>1</value>
+ </prop>
+ </node>
+ <node oor:name=".uno:ChangePicture" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="en-US">~Change Image...</value>
+ </prop>
+ <prop oor:name="Properties" oor:type="xs:int">
+ <value>1</value>
+ </prop>
+ </node>
</node>
</node>
</oor:component-data>
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index 242d8e8deee3..174db9b8625e 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -724,6 +724,7 @@
#define RID_FUNCTION_CATEGORIES (SC_RESOURCE_START+62)
#define RID_MN_INSERT_FIELDS (SC_RESOURCE_START+63)
#define RID_STATISTICS_DLGS (SC_RESOURCE_START+64)
+#define RID_IMAGE_SUBMENU (SC_RESOURCE_START+65)
#define STR_START (SC_RESOURCE_START+100)
#define STR_ROWHEIGHT (STR_START)
diff --git a/sc/sdi/graphsh.sdi b/sc/sdi/graphsh.sdi
index 2329ede9c575..6b2f4bcc4b69 100644
--- a/sc/sdi/graphsh.sdi
+++ b/sc/sdi/graphsh.sdi
@@ -146,6 +146,25 @@ interface GraphSelection
ExecMethod = ExecuteCompressGraphic;
StateMethod = GetCompressGraphicState;
]
+
+ SID_OBJECT_CROP
+ [
+ ExecMethod = ExecuteCropGraphic ;
+ StateMethod = GetCropGraphicState ;
+ ]
+
+ SID_SAVE_GRAPHIC
+ [
+ ExecMethod = ExecuteSaveGraphic;
+ StateMethod = GetSaveGraphicState ;
+ ]
+
+ SID_CHANGE_PICTURE
+ [
+ ExecMethod = ExecuteChangePicture ;
+ StateMethod = GetChangePictureState ;
+ ]
+
}
diff --git a/sc/source/ui/drawfunc/graphsh.cxx b/sc/source/ui/drawfunc/graphsh.cxx
index f8c2be9ca17b..94742a0a177c 100644
--- a/sc/source/ui/drawfunc/graphsh.cxx
+++ b/sc/source/ui/drawfunc/graphsh.cxx
@@ -21,11 +21,13 @@
#include <sfx2/objface.hxx>
#include <sfx2/request.hxx>
#include <sfx2/sidebar/EnumContext.hxx>
+#include <sfx2/opengrf.hxx>
#include <svl/whiter.hxx>
#include <svx/svdograf.hxx>
#include <svx/grfflt.hxx>
#include <svx/grafctrl.hxx>
#include <svx/compressgraphicdialog.hxx>
+#include <svx/graphichelper.hxx>
#include <vcl/msgbox.hxx>
#include "graphsh.hxx"
@@ -34,6 +36,7 @@
#include "drawview.hxx"
#include "scresid.hxx"
#include <svx/extedit.hxx>
+#include "tabvwsh.hxx"
#define ScGraphicShell
#include "scslots.hxx"
@@ -216,4 +219,130 @@ void ScGraphicShell::ExecuteCompressGraphic( SfxRequest& )
Invalidate();
}
+void ScGraphicShell::GetCropGraphicState( SfxItemSet& rSet )
+{
+ ScDrawView* pView = GetViewData()->GetScDrawView();
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ bool bEnable = false;
+ if( rMarkList.GetMarkCount() == 1 )
+ {
+ SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+
+ if( pObj && pObj->ISA( SdrGrafObj ) && ( static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GRAPHIC_BITMAP ) )
+ bEnable = true;
+ }
+
+ if( !bEnable )
+ rSet.DisableItem( SID_OBJECT_CROP );
+}
+
+void ScGraphicShell::ExecuteCropGraphic( SfxRequest& )
+{
+ ScDrawView* pView = GetViewData()->GetScDrawView();
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+
+ if( rMarkList.GetMarkCount() == 1 )
+ {
+ SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+
+ if( pObj && pObj->ISA( SdrGrafObj ) && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GRAPHIC_BITMAP )
+ {
+ pView->SetEditMode(SDREDITMODE_EDIT);
+ pView->SetDragMode(SDRDRAG_CROP);
+ }
+ }
+
+ Invalidate();
+}
+
+void ScGraphicShell::ExecuteSaveGraphic(SfxRequest& /*rReq*/)
+{
+ ScDrawView* pView = GetViewData()->GetScDrawView();
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ if( rMarkList.GetMarkCount() == 1 )
+ {
+ SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+ if( pObj && pObj->ISA( SdrGrafObj ) && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GRAPHIC_BITMAP )
+ {
+ GraphicObject aGraphicObject( static_cast<SdrGrafObj*>( pObj )->GetGraphicObject() );
+ {
+ GraphicHelper::ExportGraphic( aGraphicObject.GetGraphic(), "" );
+ }
+ }
+ }
+
+ Invalidate();
+}
+
+void ScGraphicShell::GetSaveGraphicState(SfxItemSet &rSet)
+{
+ ScDrawView* pView = GetViewData()->GetScDrawView();
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ bool bEnable = false;
+ if( rMarkList.GetMarkCount() == 1 )
+ {
+ SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+
+ if( pObj && pObj->ISA( SdrGrafObj ) && ( static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GRAPHIC_BITMAP ) )
+ bEnable = true;
+ }
+
+ if( !bEnable )
+ rSet.DisableItem( SID_SAVE_GRAPHIC );
+}
+
+void ScGraphicShell::ExecuteChangePicture(SfxRequest& /*rReq*/)
+{
+ ScDrawView* pView = GetViewData()->GetScDrawView();
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+
+ if( rMarkList.GetMarkCount() == 1 )
+ {
+ SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+
+ if( pObj && pObj->ISA( SdrGrafObj ) && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GRAPHIC_BITMAP )
+ {
+ SdrGrafObj* pGraphicObj = static_cast<SdrGrafObj*>(pObj);
+ SvxOpenGraphicDialog aDlg(ScResId(STR_INSERTGRAPHIC));
+
+ if( aDlg.Execute() == GRFILTER_OK )
+ {
+ Graphic aGraphic;
+ int nError = aDlg.GetGraphic(aGraphic);
+ if( nError == GRFILTER_OK )
+ {
+ SdrGrafObj* pNewObject = pGraphicObj->Clone();
+ pNewObject->SetGraphic( aGraphic );
+ SdrPageView* pPageView = pView->GetSdrPageView();
+ OUString aUndoString = pView->GetDescriptionOfMarkedObjects() + " Change";
+ pView->BegUndo( aUndoString );
+ pView->ReplaceObjectAtView( pObj, *pPageView, pNewObject );
+ pView->EndUndo();
+ }
+ }
+ }
+ }
+
+ Invalidate();
+}
+
+void ScGraphicShell::GetChangePictureState(SfxItemSet &rSet)
+{
+ ScDrawView* pView = GetViewData()->GetScDrawView();
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ bool bEnable = false;
+ if( rMarkList.GetMarkCount() == 1 )
+ {
+ SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+
+ if( pObj && pObj->ISA( SdrGrafObj ) && ( static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GRAPHIC_BITMAP ) )
+ bEnable = true;
+ }
+
+ if( !bEnable )
+ rSet.DisableItem( SID_CHANGE_PICTURE );
+}
+
+
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/objdraw.src b/sc/source/ui/drawfunc/objdraw.src
index b8cbe4033cf9..7989e2743717 100644
--- a/sc/source/ui/drawfunc/objdraw.src
+++ b/sc/source/ui/drawfunc/objdraw.src
@@ -358,8 +358,27 @@ Menu RID_POPUP_GRAPHIC
MN_EDITLNK
MN_DELLNK
MenuItem { ITEM_OPEN_HYPERLINK };
- MenuItem { ITEM_COMPRESS_GRAPHIC };
- MenuItem { ITEM_EXTERNAL_EDIT };
+
+ MenuItem { Separator = TRUE ; };
+
+ MenuItem {
+ Identifier = RID_IMAGE_SUBMENU ;
+ Text [ en-US ] = "Image" ;
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem { ITEM_CHANGE_PICTURE };
+ MenuItem { ITEM_SAVE_GRAPHIC };
+ MenuItem { ITEM_COMPRESS_GRAPHIC };
+ MenuItem { ITEM_EXTERNAL_EDIT };
+
+ MenuItem { Separator = TRUE ; };
+
+ MenuItem { ITEM_OBJECT_CROP };
+ };
+ };
+ };
};
};
diff --git a/sc/source/ui/inc/graphsh.hxx b/sc/source/ui/inc/graphsh.hxx
index 59bd4a4f4047..531451411e98 100644
--- a/sc/source/ui/inc/graphsh.hxx
+++ b/sc/source/ui/inc/graphsh.hxx
@@ -57,6 +57,15 @@ public:
void ExecuteCompressGraphic(SfxRequest& rReq);
void GetCompressGraphicState(SfxItemSet &rSet);
+
+ void ExecuteCropGraphic(SfxRequest& rReq);
+ void GetCropGraphicState(SfxItemSet &rSet);
+
+ void ExecuteSaveGraphic(SfxRequest& rReq);
+ void GetSaveGraphicState(SfxItemSet &rSet);
+
+ void ExecuteChangePicture(SfxRequest& rReq);
+ void GetChangePictureState(SfxItemSet &rSet);
};
#endif
diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml
index 5a83aec8a74c..46d3da4dcf7a 100644
--- a/sc/uiconfig/scalc/menubar/menubar.xml
+++ b/sc/uiconfig/scalc/menubar/menubar.xml
@@ -377,7 +377,7 @@
<menu:menuitem menu:id=".uno:LeaveGroup"/>
</menu:menupopup>
</menu:menu>
- <menu:menu menu:id=".uno:DrawGraphicMenu">
+ <menu:menu menu:id=".uno:FormatObjectMenu">
<menu:menupopup>
<menu:menuitem menu:id=".uno:TransformDialog"/>
<menu:menuitem menu:id=".uno:FormatLine"/>
@@ -387,6 +387,17 @@
<menu:menuitem menu:id=".uno:ToggleObjectBezierMode"/>
</menu:menupopup>
</menu:menu>
+ <menu:menu menu:id=".uno:FormatImageMenu">
+ <menu:menupopup>
+ <menu:menuitem menu:id=".uno:Crop"/>
+ <menu:menuseparator/>
+ <menu:menuitem menu:id=".uno:ExternalEdit"/>
+ <menu:menuitem menu:id=".uno:ChangePicture"/>
+ <menu:menuitem menu:id=".uno:CompressGraphic"/>
+ <menu:menuseparator/>
+ <menu:menuitem menu:id=".uno:SaveGraphic"/>
+ </menu:menupopup>
+ </menu:menu>
<menu:menuitem menu:id=".uno:ControlProperties"/>
<menu:menuitem menu:id=".uno:FormProperties"/>
</menu:menupopup>
diff --git a/sc/uiconfig/scalc/toolbar/graphicobjectbar.xml b/sc/uiconfig/scalc/toolbar/graphicobjectbar.xml
index 0c9439cfe379..5b17ac9c9d2f 100644
--- a/sc/uiconfig/scalc/toolbar/graphicobjectbar.xml
+++ b/sc/uiconfig/scalc/toolbar/graphicobjectbar.xml
@@ -30,6 +30,7 @@
<toolbar:toolbaritem xlink:href=".uno:FormatArea"/>
<toolbar:toolbaritem xlink:href=".uno:FillShadow"/>
<toolbar:toolbarseparator/>
+ <toolbar:toolbaritem xlink:href=".uno:Crop"/>
<toolbar:toolbaritem xlink:href=".uno:GrafAttrCrop"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:ToggleAnchorType"/>