summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorTomaž Vajngerl <quikee@gmail.com>2012-10-03 22:27:41 +0200
committerTomaž Vajngerl <quikee@gmail.com>2012-10-04 07:45:40 +0200
commit1e6985da53b91fd0f2a3d44cd30dd3a73dcd6919 (patch)
treeb7a2b5573ad406b175ac655d60552cc307bc3f0b /sc
parent7895ebdab0b0ed7d2a9b361d6d5ab02b0e9361d6 (diff)
Add "Compress Graphic" menu entry for bitmaps to Calc
Change-Id: I591c544f600361b5bc9c59b5627f6cdd9f9b09db
Diffstat (limited to 'sc')
-rw-r--r--sc/sdi/graphsh.sdi6
-rw-r--r--sc/source/ui/drawfunc/graphsh.cxx56
-rw-r--r--sc/source/ui/drawfunc/objdraw.src1
-rw-r--r--sc/source/ui/inc/graphsh.hxx3
4 files changed, 64 insertions, 2 deletions
diff --git a/sc/sdi/graphsh.sdi b/sc/sdi/graphsh.sdi
index 6eb051bc5eaf..6c9ae7a0d440 100644
--- a/sc/sdi/graphsh.sdi
+++ b/sc/sdi/graphsh.sdi
@@ -140,6 +140,12 @@ interface GraphSelection
ExecMethod = ExecuteExternalEdit;
StateMethod = GetExternalEditState;
]
+
+ SID_COMPRESS_GRAPHIC
+ [
+ ExecMethod = ExecuteCompressGraphic;
+ StateMethod = GetCompressGraphicState;
+ ]
}
// ===========================================================================
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 };
};
};
diff --git a/sc/source/ui/inc/graphsh.hxx b/sc/source/ui/inc/graphsh.hxx
index 3c700c73ad12..31d2d35bcffe 100644
--- a/sc/source/ui/inc/graphsh.hxx
+++ b/sc/source/ui/inc/graphsh.hxx
@@ -47,6 +47,9 @@ public:
void ExecuteExternalEdit(SfxRequest& rReq);
void GetExternalEditState(SfxItemSet &rSet);
+
+ void ExecuteCompressGraphic(SfxRequest& rReq);
+ void GetCompressGraphicState(SfxItemSet &rSet);
};
#endif