summaryrefslogtreecommitdiff
path: root/sc/source/ui/drawfunc/chartsh.cxx
diff options
context:
space:
mode:
authorTomaž Vajngerl <quikee@gmail.com>2012-10-08 07:43:59 +0200
committerTomaž Vajngerl <quikee@gmail.com>2012-10-08 07:46:55 +0200
commitcbb0babb679338ddc9910bbdb2676128d0c236f7 (patch)
treed056f57ae394e63ae569675578fec6166a99c5bf /sc/source/ui/drawfunc/chartsh.cxx
parentfa30508fd3b2224e76e1ac7c150df9040518e7aa (diff)
fdo#30944 Add popup menu function to charts to export them as a graphic
Add popup menu function "Export as Graphic" to charts to export the chart as a graphic. Currently it works only with raster formats like PNG and JPG but not with vector formats like SVG. Change-Id: Ieeda21ff971f2ad31bab2248e8b509883b5cbcd0
Diffstat (limited to 'sc/source/ui/drawfunc/chartsh.cxx')
-rw-r--r--sc/source/ui/drawfunc/chartsh.cxx55
1 files changed, 48 insertions, 7 deletions
diff --git a/sc/source/ui/drawfunc/chartsh.cxx b/sc/source/ui/drawfunc/chartsh.cxx
index 414063394aeb..251fa5d5b044 100644
--- a/sc/source/ui/drawfunc/chartsh.cxx
+++ b/sc/source/ui/drawfunc/chartsh.cxx
@@ -17,8 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <editeng/eeitem.hxx>
-#include <svx/fontwork.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/graphichelper.hxx>
+
#include <svl/srchitem.hxx>
#include <sfx2/app.hxx>
#include <sfx2/objface.hxx>
@@ -34,15 +36,13 @@
#include "docpool.hxx"
#include "drawview.hxx"
#include "scresid.hxx"
-#include <svx/svdobj.hxx>
#define ScChartShell
#include "scslots.hxx"
-
SFX_IMPL_INTERFACE(ScChartShell, ScDrawShell, ScResId(SCSTR_CHARTSHELL) )
{
- SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD | SFX_VISIBILITY_SERVER,
ScResId(RID_DRAW_OBJECTBAR) );
SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_CHART) );
}
@@ -52,14 +52,55 @@ TYPEINIT1( ScChartShell, ScDrawShell );
ScChartShell::ScChartShell(ScViewData* pData) :
ScDrawShell(pData)
{
- SetHelpId(HID_SCSHELL_CHARTSH);
- SetName(rtl::OUString("ChartObject"));
+ SetHelpId( HID_SCSHELL_CHARTSH );
+ SetName( OUString("ChartObject") );
}
ScChartShell::~ScChartShell()
{
}
+void ScChartShell::GetExportAsGraphicState( 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( SdrOle2Obj ) )
+ bEnable = true;
+ }
+
+ if( !bEnable )
+ rSet.DisableItem( SID_EXPORT_AS_GRAPHIC );
+}
+
+void ScChartShell::ExecuteExportAsGraphic( SfxRequest& )
+{
+ ScDrawView* pView = GetViewData()->GetScDrawView();
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+
+ if( rMarkList.GetMarkCount() == 1 )
+ {
+ SdrObject* pObject = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+
+ if( pObject && pObject->ISA( SdrOle2Obj ) )
+ {
+ SdrOle2Obj* aOle2Object = ((SdrOle2Obj*) pObject)->Clone();
+ aOle2Object->NbcResize(Point(), Fraction(1,1), Fraction(1,1));
+ Graphic* pGraphic = aOle2Object->GetGraphic();
+ if( pGraphic != NULL )
+ {
+ String sGrfNm, sFilterNm;
+ GraphicHelper::ExportGraphic( *pGraphic, String("") );
+ }
+ }
+ }
+
+ Invalidate();
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */