diff options
author | Tomaž Vajngerl <quikee@gmail.com> | 2012-10-03 22:27:41 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2012-10-04 07:45:40 +0200 |
commit | 1e6985da53b91fd0f2a3d44cd30dd3a73dcd6919 (patch) | |
tree | b7a2b5573ad406b175ac655d60552cc307bc3f0b /sc/source/ui/drawfunc | |
parent | 7895ebdab0b0ed7d2a9b361d6d5ab02b0e9361d6 (diff) |
Add "Compress Graphic" menu entry for bitmaps to Calc
Change-Id: I591c544f600361b5bc9c59b5627f6cdd9f9b09db
Diffstat (limited to 'sc/source/ui/drawfunc')
-rw-r--r-- | sc/source/ui/drawfunc/graphsh.cxx | 56 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/objdraw.src | 1 |
2 files changed, 55 insertions, 2 deletions
diff --git a/sc/source/ui/drawfunc/graphsh.cxx b/sc/source/ui/drawfunc/graphsh.cxx index f2258e8d9750..8ecbd7d233d4 100644 --- a/sc/source/ui/drawfunc/graphsh.cxx +++ b/sc/source/ui/drawfunc/graphsh.cxx @@ -33,6 +33,8 @@ #include <svx/svdograf.hxx> #include <svx/grfflt.hxx> #include <svx/grafctrl.hxx> +#include <svx/compressgraphicdialog.hxx> +#include <vcl/msgbox.hxx> #include "graphsh.hxx" #include "sc.hrc" @@ -48,11 +50,11 @@ class ScExternalToolEdit : public ExternalToolEdit { - ScDrawView* m_pView; + FmFormView* m_pView; SdrObject* m_pObj; public: - ScExternalToolEdit ( ScDrawView* pView, SdrObject* pObj ) : + ScExternalToolEdit ( FmFormView* pView, SdrObject* pObj ) : m_pView (pView), m_pObj (pObj) {} @@ -204,4 +206,54 @@ void ScGraphicShell::ExecuteExternalEdit( SfxRequest& ) Invalidate(); } + +void ScGraphicShell::GetCompressGraphicState( 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 ) && ( ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP ) ) + bEnable = true; + } + + if( !bEnable ) + rSet.DisableItem( SID_COMPRESS_GRAPHIC ); +} + +void ScGraphicShell::ExecuteCompressGraphic( 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 ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP ) + { + GraphicObject aGraphicObject( ( (SdrGrafObj*) pObj )->GetGraphicObject() ); + CompressGraphicsDialog dialog( GetViewData()->GetDialogParent(), aGraphicObject.GetGraphic(), pObj->GetLogicRect().GetSize(), GetViewData()->GetBindings() ); + if ( dialog.Execute() == RET_OK ) + { + SdrGrafObj* pNewObject = (SdrGrafObj*) pObj->Clone(); + const Graphic aNewGraphic = dialog.GetCompressedGraphic(); + SdrPageView* pPageView = pView->GetSdrPageView(); + pNewObject->SetEmptyPresObj( sal_False ); + pNewObject->SetGraphic( aNewGraphic ); + String aUndoString( pView->GetDescriptionOfMarkedObjects() ); + aUndoString += (sal_Unicode) ' '; + aUndoString += String( "Compress" ); + pView->BegUndo( aUndoString ); + pView->ReplaceObjectAtView( pObj, *pPageView, pNewObject ); + pView->EndUndo(); + } + } + } + + Invalidate(); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/objdraw.src b/sc/source/ui/drawfunc/objdraw.src index 02fc43505b1b..a2ed29eaabca 100644 --- a/sc/source/ui/drawfunc/objdraw.src +++ b/sc/source/ui/drawfunc/objdraw.src @@ -527,6 +527,7 @@ Menu RID_POPUP_GRAPHIC MN_EDITLNK MN_DELLNK MenuItem { ITEM_OPEN_HYPERLINK }; + MenuItem { ITEM_COMPRESS_GRAPHIC }; MenuItem { ITEM_EXTERNAL_EDIT }; }; }; |