[Libreoffice-commits] core.git: officecfg/registry sc/inc sc/sdi sc/source sc/uiconfig

Philippe Jung phil.jung at free.fr
Tue May 5 03:04:23 PDT 2015


 officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu |   28 ++
 sc/inc/sc.hrc                                                     |    1 
 sc/sdi/graphsh.sdi                                                |   19 +
 sc/source/ui/drawfunc/graphsh.cxx                                 |  129 ++++++++++
 sc/source/ui/drawfunc/objdraw.src                                 |   23 +
 sc/source/ui/inc/graphsh.hxx                                      |    9 
 sc/uiconfig/scalc/menubar/menubar.xml                             |   13 -
 sc/uiconfig/scalc/toolbar/graphicobjectbar.xml                    |    1 
 8 files changed, 218 insertions(+), 5 deletions(-)

New commits:
commit b1df1ac809fd6de972a6ed4f638a1ac8d29ba40d
Author: Philippe Jung <phil.jung at free.fr>
Date:   Sat May 2 00:22:25 2015 +0200

    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 at libreoffice.org>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
index 103bc02..433c723 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
@@ -1914,9 +1914,9 @@
           <value xml:lang="en-US">Pri~nt Ranges</value>
         </prop>
       </node>
-      <node oor:name=".uno:DrawGraphicMenu" oor:op="replace">
+      <node oor:name=".uno:FormatObjectMenu" oor:op="replace">
         <prop oor:name="Label" oor:type="xs:string">
-          <value xml:lang="en-US">Graph~ic</value>
+          <value xml:lang="en-US">O~bject</value>
         </prop>
       </node>
       <node oor:name=".uno:ToggleFormula" oor:op="replace">
@@ -1994,6 +1994,30 @@
           <value xml:lang="en-US">Paste Only Value</value>
         </prop>
       </node>
+      <node oor:name=".uno:CompressGraphic" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Co~mpress Image...</value>
+        </prop>
+        <prop oor:name="Properties" oor:type="xs:int">
+            <value>1</value>
+        </prop>
+      </node>
+      <node oor:name=".uno:SaveGraphic" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Save Image...</value>
+        </prop>
+        <prop oor:name="Properties" oor:type="xs:int">
+            <value>1</value>
+        </prop>
+      </node>
+      <node oor:name=".uno:ChangePicture" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">~Change Image...</value>
+        </prop>
+        <prop oor:name="Properties" oor:type="xs:int">
+            <value>1</value>
+        </prop>
+      </node>
     </node>
   </node>
 </oor:component-data>
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index 242d8e8..174db9b 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -724,6 +724,7 @@
 #define RID_FUNCTION_CATEGORIES (SC_RESOURCE_START+62)
 #define RID_MN_INSERT_FIELDS    (SC_RESOURCE_START+63)
 #define RID_STATISTICS_DLGS     (SC_RESOURCE_START+64)
+#define RID_IMAGE_SUBMENU       (SC_RESOURCE_START+65)
 
 #define STR_START               (SC_RESOURCE_START+100)
 #define STR_ROWHEIGHT           (STR_START)
diff --git a/sc/sdi/graphsh.sdi b/sc/sdi/graphsh.sdi
index 2329ede..6b2f4bc 100644
--- a/sc/sdi/graphsh.sdi
+++ b/sc/sdi/graphsh.sdi
@@ -146,6 +146,25 @@ interface GraphSelection
         ExecMethod = ExecuteCompressGraphic;
         StateMethod = GetCompressGraphicState;
     ]
+
+    SID_OBJECT_CROP
+    [
+        ExecMethod = ExecuteCropGraphic ;
+        StateMethod = GetCropGraphicState ;
+    ]
+
+    SID_SAVE_GRAPHIC
+    [
+        ExecMethod = ExecuteSaveGraphic;
+        StateMethod = GetSaveGraphicState ;
+    ]
+
+    SID_CHANGE_PICTURE
+    [
+        ExecMethod = ExecuteChangePicture ;
+        StateMethod = GetChangePictureState ;
+    ]
+
 }
 
 
diff --git a/sc/source/ui/drawfunc/graphsh.cxx b/sc/source/ui/drawfunc/graphsh.cxx
index f8c2be9..94742a0 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: */
diff --git a/sc/source/ui/drawfunc/objdraw.src b/sc/source/ui/drawfunc/objdraw.src
index b8cbe40..7989e27 100644
--- a/sc/source/ui/drawfunc/objdraw.src
+++ b/sc/source/ui/drawfunc/objdraw.src
@@ -358,8 +358,27 @@ Menu RID_POPUP_GRAPHIC
         MN_EDITLNK
         MN_DELLNK
         MenuItem { ITEM_OPEN_HYPERLINK };
-        MenuItem { ITEM_COMPRESS_GRAPHIC };
-        MenuItem { ITEM_EXTERNAL_EDIT };
+
+        MenuItem { Separator = TRUE ; };
+
+        MenuItem {
+            Identifier = RID_IMAGE_SUBMENU ;
+            Text [ en-US ] = "Image" ;
+            SubMenu = Menu
+            {
+                ItemList =
+                {
+                    MenuItem { ITEM_CHANGE_PICTURE };
+                    MenuItem { ITEM_SAVE_GRAPHIC };
+                    MenuItem { ITEM_COMPRESS_GRAPHIC };
+                    MenuItem { ITEM_EXTERNAL_EDIT };
+
+                    MenuItem { Separator = TRUE ; };
+
+                    MenuItem { ITEM_OBJECT_CROP };
+                };
+            };
+        };
     };
 };
 
diff --git a/sc/source/ui/inc/graphsh.hxx b/sc/source/ui/inc/graphsh.hxx
index 59bd4a4..5314514 100644
--- a/sc/source/ui/inc/graphsh.hxx
+++ b/sc/source/ui/inc/graphsh.hxx
@@ -57,6 +57,15 @@ public:
 
     void    ExecuteCompressGraphic(SfxRequest& rReq);
     void    GetCompressGraphicState(SfxItemSet &rSet);
+
+    void    ExecuteCropGraphic(SfxRequest& rReq);
+    void    GetCropGraphicState(SfxItemSet &rSet);
+
+    void    ExecuteSaveGraphic(SfxRequest& rReq);
+    void    GetSaveGraphicState(SfxItemSet &rSet);
+
+    void    ExecuteChangePicture(SfxRequest& rReq);
+    void    GetChangePictureState(SfxItemSet &rSet);
 };
 
 #endif
diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml
index 5a83aec..46d3da4 100644
--- a/sc/uiconfig/scalc/menubar/menubar.xml
+++ b/sc/uiconfig/scalc/menubar/menubar.xml
@@ -377,7 +377,7 @@
                     <menu:menuitem menu:id=".uno:LeaveGroup"/>
                 </menu:menupopup>
             </menu:menu>
-            <menu:menu menu:id=".uno:DrawGraphicMenu">
+            <menu:menu menu:id=".uno:FormatObjectMenu">
                 <menu:menupopup>
                     <menu:menuitem menu:id=".uno:TransformDialog"/>
                     <menu:menuitem menu:id=".uno:FormatLine"/>
@@ -387,6 +387,17 @@
                     <menu:menuitem menu:id=".uno:ToggleObjectBezierMode"/>
                 </menu:menupopup>
             </menu:menu>
+            <menu:menu menu:id=".uno:FormatImageMenu">
+                <menu:menupopup>
+                    <menu:menuitem menu:id=".uno:Crop"/>
+                    <menu:menuseparator/>
+                    <menu:menuitem menu:id=".uno:ExternalEdit"/>
+                    <menu:menuitem menu:id=".uno:ChangePicture"/>
+                    <menu:menuitem menu:id=".uno:CompressGraphic"/>
+                    <menu:menuseparator/>
+                    <menu:menuitem menu:id=".uno:SaveGraphic"/>
+                </menu:menupopup>
+            </menu:menu>
             <menu:menuitem menu:id=".uno:ControlProperties"/>
             <menu:menuitem menu:id=".uno:FormProperties"/>
         </menu:menupopup>
diff --git a/sc/uiconfig/scalc/toolbar/graphicobjectbar.xml b/sc/uiconfig/scalc/toolbar/graphicobjectbar.xml
index 0c9439c..5b17ac9 100644
--- a/sc/uiconfig/scalc/toolbar/graphicobjectbar.xml
+++ b/sc/uiconfig/scalc/toolbar/graphicobjectbar.xml
@@ -30,6 +30,7 @@
  <toolbar:toolbaritem xlink:href=".uno:FormatArea"/>
  <toolbar:toolbaritem xlink:href=".uno:FillShadow"/>
  <toolbar:toolbarseparator/>
+ <toolbar:toolbaritem xlink:href=".uno:Crop"/>
  <toolbar:toolbaritem xlink:href=".uno:GrafAttrCrop"/>
  <toolbar:toolbarseparator/>
  <toolbar:toolbaritem xlink:href=".uno:ToggleAnchorType"/>


More information about the Libreoffice-commits mailing list