[Libreoffice-commits] .: sc/inc sc/sdi sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sun Oct 7 22:49:33 PDT 2012


 sc/inc/sc.hrc                     |    4 ++
 sc/sdi/chartsh.sdi                |   11 ++++++-
 sc/sdi/scalc.sdi                  |   34 ++++++++++++++++++++---
 sc/source/ui/drawfunc/chartsh.cxx |   55 +++++++++++++++++++++++++++++++++-----
 sc/source/ui/drawfunc/objdraw.src |    6 ++++
 sc/source/ui/inc/chartsh.hxx      |    3 +-
 6 files changed, 98 insertions(+), 15 deletions(-)

New commits:
commit cbb0babb679338ddc9910bbdb2676128d0c236f7
Author: Tomaž Vajngerl <quikee at gmail.com>
Date:   Mon Oct 8 07:43:59 2012 +0200

    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

diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index e47ee57..efec7ab 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -529,6 +529,9 @@
 #define SID_NEW_SLOTS           (SID_KEYFUNC_END)
 
 #define SID_NEW_TABLENAME       (SID_NEW_SLOTS+1)
+
+#define SID_EXPORT_AS_GRAPHIC   (SID_NEW_SLOTS+2)
+
 #define FID_MERGE_TOGGLE        (SID_NEW_SLOTS+10)
 #define SID_ATTR_ROWHEADERS     (SID_NEW_SLOTS+11)
 #define SID_ATTR_COLHEADERS     (SID_NEW_SLOTS+12)
@@ -1126,4 +1129,3 @@
 #define RID_SCPAGE_DEFAULTS         (SC_OOO_BUILD_START + 10)
 
 #endif
-
diff --git a/sc/sdi/chartsh.sdi b/sc/sdi/chartsh.sdi
index c050a7c..ce00043 100644
--- a/sc/sdi/chartsh.sdi
+++ b/sc/sdi/chartsh.sdi
@@ -16,7 +16,16 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
- // ===========================================================================
+interface ChartSelection
+{
+    SID_EXPORT_AS_GRAPHIC
+    [
+        ExecMethod = ExecuteExportAsGraphic;
+        StateMethod = GetExportAsGraphicState;
+    ]
+}
+
 shell ScChartShell : ScDrawShell
 {
+    import ChartSelection;
 }
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
index 5b9cda6..14fb8cc 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -24,7 +24,7 @@
  * for a copy of the LGPLv3 License.
  *
  ************************************************************************/
-//--------------------------------------------------------------------------
+
 SfxVoidItem AcceptChanges FID_CHG_ACCEPT
 ()
 [
@@ -2919,10 +2919,10 @@ SfxVoidItem SolverDialog SID_OPENDLG_OPTSOLVER
     Synchron;
 
     /* config: */
-	AccelConfig = FALSE,
-	MenuConfig = FALSE,
-	StatusBarConfig = FALSE,
-	ToolBoxConfig = FALSE,
+    AccelConfig = FALSE,
+    MenuConfig = FALSE,
+    StatusBarConfig = FALSE,
+    ToolBoxConfig = FALSE,
     GroupId = GID_OPTIONS;
 ]
 
@@ -8342,3 +8342,27 @@ SfxVoidItem EnterString SID_ENTER_STRING
     ToolBoxConfig = FALSE,
     GroupId = GID_INTERN;
 ]
+
+SfxVoidItem ExportAsGraphic SID_EXPORT_AS_GRAPHIC
+()
+[
+    /* flags: */
+    AutoUpdate = FALSE,
+    Cachable = Cachable,
+    FastCall = FALSE,
+    HasCoreId = FALSE,
+    HasDialog = FALSE,
+    ReadOnlyDoc = TRUE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+    Synchron;
+
+    /* config: */
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    StatusBarConfig = FALSE,
+    ToolBoxConfig = TRUE,
+    GroupId = GID_CHART;
+]
diff --git a/sc/source/ui/drawfunc/chartsh.cxx b/sc/source/ui/drawfunc/chartsh.cxx
index 4140633..251fa5d 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: */
diff --git a/sc/source/ui/drawfunc/objdraw.src b/sc/source/ui/drawfunc/objdraw.src
index a2ed29e..3263ec3 100644
--- a/sc/source/ui/drawfunc/objdraw.src
+++ b/sc/source/ui/drawfunc/objdraw.src
@@ -619,6 +619,12 @@ Menu RID_POPUP_CHART
         MenuItem { Separator = TRUE ; };
          //------------------------------
         ITEM_GROUP_MENU
+        MenuItem
+        {
+            Identifier = SID_EXPORT_AS_GRAPHIC ;
+            Command = ".uno:ExportAsGraphic" ;
+            Text [ en-US ] = "Export as graphic.." ;
+        };
     };
 };
 
diff --git a/sc/source/ui/inc/chartsh.hxx b/sc/source/ui/inc/chartsh.hxx
index 9de99ea..3e2eddf 100644
--- a/sc/source/ui/inc/chartsh.hxx
+++ b/sc/source/ui/inc/chartsh.hxx
@@ -23,7 +23,6 @@
 #include <sfx2/shell.hxx>
 #include "shellids.hxx"
 #include <sfx2/module.hxx>
-#include <svx/svdmark.hxx>
 
 class ScViewData;
 
@@ -39,6 +38,8 @@ public:
                 ScChartShell(ScViewData* pData);
     virtual     ~ScChartShell();
 
+    void    ExecuteExportAsGraphic(SfxRequest& rReq);
+    void    GetExportAsGraphicState(SfxItemSet &rSet);
 };
 
 #endif


More information about the Libreoffice-commits mailing list