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>
This commit is contained in:
Philippe Jung 2015-05-02 00:22:25 +02:00 committed by Jan Holesovsky
parent 80a38d2991
commit b1df1ac809
8 changed files with 218 additions and 5 deletions

View file

@ -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>

View file

@ -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)

View file

@ -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 ;
]
}

View file

@ -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: */

View file

@ -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 };
};
};
};
};
};

View file

@ -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

View file

@ -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>

View file

@ -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"/>