diff options
author | Philippe Jung <phil.jung@free.fr> | 2015-05-02 00:22:25 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2015-05-05 10:03:59 +0000 |
commit | b1df1ac809fd6de972a6ed4f638a1ac8d29ba40d (patch) | |
tree | 0cdb28e2b5af146dfb84f2a936d8da84e4fe4624 /sc/source/ui/drawfunc/graphsh.cxx | |
parent | 80a38d299133823e93ec5c29e8fe5c51771940d5 (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>
Diffstat (limited to 'sc/source/ui/drawfunc/graphsh.cxx')
-rw-r--r-- | sc/source/ui/drawfunc/graphsh.cxx | 129 |
1 files changed, 129 insertions, 0 deletions
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: */ |