sc/sdi/graphsh.sdi                |   18 ++--
 sc/source/ui/drawfunc/graphsh.cxx |   66 ++++++++++++++
 sc/source/ui/drawfunc/objdraw.src |    4 
 sc/source/ui/inc/graphsh.hxx      |    3 
 svx/Library_svxcore.mk            |    1 
 svx/Package_inc.mk                |    3 
 svx/inc/globlmn_tmpl.hrc          |    5 +
 svx/inc/svx/extedit.hxx           |   54 ++++++++++++
 svx/inc/svx/svxids.hrc            |    4 
 svx/sdi/svx.sdi                   |   25 +++++
 svx/source/core/extedit.cxx       |  170 ++++++++++++++++++++++++++++++++++++++
 sw/Library_sw.mk                  |    1 
 sw/inc/cmdid.h                    |    3 
 sw/inc/swcommands.h               |    1 
 sw/sdi/_grfsh.sdi                 |    4 
 sw/sdi/swriter.sdi                |   27 ------
 sw/source/ui/app/mn.src           |    5 -
 sw/source/ui/docvw/extedit.cxx    |  149 ---------------------------------
 sw/source/ui/inc/extedit.hxx      |   50 -----------
 sw/source/ui/shells/grfsh.cxx     |   30 +++++-
 20 files changed, 367 insertions(+), 256 deletions(-)

New commits:
commit 7a3ae89a12b2c11e90d3f0c76293ddb63203bd2a
Author: Tomaž Vajngerl <qui...@gmail.com>
Date:   Thu Jun 28 00:19:28 2012 +0200

    Enable menu option "Edit witn External Tool.." for Calc.
    
    Currently it was only possible to use "Exit with External Tool.."
    menu option in Writer. Now it is also possible to use this in
    Calc and in future Draw and Impress. Code has been refactored and
    extacted out of "sw" into "svx", so other components can use it.
    
    Currently there is no cleanup of temporary images after processing
    was done, and also pinging for changes are still active even when
    editing in external tool is done. This behavior will be changed
    in the future.
    
    Change-Id: I09969d44dfddbf9183b30ff3fffa2d201c7ae40f

diff --git a/sc/sdi/graphsh.sdi b/sc/sdi/graphsh.sdi
index cbf2583..6eb051b 100644
--- a/sc/sdi/graphsh.sdi
+++ b/sc/sdi/graphsh.sdi
@@ -128,11 +128,18 @@ interface GraphSelection
         ExecMethod = Execute;
         StateMethod = GetAttrState;
     ]
-        SID_COLOR_SETTINGS
-        [
-                ExecMethod = Execute;
-                StateMethod = GetAttrState;
-        ]
+
+    SID_COLOR_SETTINGS
+    [
+        ExecMethod = Execute;
+        StateMethod = GetAttrState;
+    ]
+
+    SID_EXTERNAL_EDIT
+    [
+        ExecMethod = ExecuteExternalEdit;
+        StateMethod = GetExternalEditState;
+    ]
 }
 
  // ===========================================================================
@@ -140,4 +147,3 @@ shell ScGraphicShell : ScDrawShell
 {
     import GraphSelection;
 }
-
diff --git a/sc/source/ui/drawfunc/graphsh.cxx 
b/sc/source/ui/drawfunc/graphsh.cxx
index 751fc41..ff4d43d 100644
--- a/sc/source/ui/drawfunc/graphsh.cxx
+++ b/sc/source/ui/drawfunc/graphsh.cxx
@@ -39,12 +39,40 @@
 #include "viewdata.hxx"
 #include "drawview.hxx"
 #include "scresid.hxx"
+#include <svx/extedit.hxx>
 
 #define ScGraphicShell
 #include "scslots.hxx"
 
 #define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
 
+class ScExternalToolEdit : public ExternalToolEdit
+{
+    ScDrawView* m_pView;
+    SdrObject*  m_pObj;
+
+public:
+    ScExternalToolEdit ( ScDrawView* pView, SdrObject* pObj ) :
+        m_pView   (pView),
+        m_pObj (pObj)
+    {}
+
+    virtual void Update( Graphic& aGraphic )
+    {
+        SdrPageView* pPageView = m_pView->GetSdrPageView();
+        if( pPageView )
+        {
+            SdrGrafObj* pNewObj = (SdrGrafObj*) m_pObj->Clone();
+            String      aStr( m_pView->GetDescriptionOfMarkedObjects() );
+            aStr.Append( sal_Unicode(' ') );
+            aStr.Append( String( "External Edit" ) );
+            m_pView->BegUndo( aStr );
+            pNewObj->SetGraphicObject( aGraphic );
+            m_pView->ReplaceObjectAtView( m_pObj, *pPageView, pNewObj );
+            m_pView->EndUndo();
+        }
+    }
+};
 
 SFX_IMPL_INTERFACE(ScGraphicShell, ScDrawShell, ScResId(SCSTR_GRAPHICSHELL) )
 {
@@ -140,4 +168,42 @@ void ScGraphicShell::ExecuteFilter( SfxRequest& rReq )
     Invalidate();
 }
 
+void ScGraphicShell::GetExternalEditState( SfxItemSet& rSet )
+{
+    ScDrawView* pView = GetViewData()->GetScDrawView();
+    const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+    bool bEnable = false;
+    printf("ZO!\n");
+    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_EXTERNAL_EDIT );
+}
+
+void ScGraphicShell::ExecuteExternalEdit( SfxRequest& rReq )
+{
+    ScDrawView* pView = GetViewData()->GetScDrawView();
+    const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+    printf("YO!\n");
+
+    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() );
+            ScExternalToolEdit* aExternalToolEdit = new ScExternalToolEdit( 
pView, pObj );
+            aExternalToolEdit->Edit( &aGraphicObject );
+        }
+    }
+
+    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 5df0c5f..02fc435 100644
--- a/sc/source/ui/drawfunc/objdraw.src
+++ b/sc/source/ui/drawfunc/objdraw.src
@@ -404,7 +404,7 @@ String RID_POPUP_DRAW
     Text [ en-US ] = "Pop-up menu for drawing objects" ;
 };
  //
- //     Popup-Menue fuer (allgemeine) Zeichenobjekte
+ //     Pop-up menu for drawing objects
  //
 Menu RID_POPUP_DRAW
 {
@@ -527,6 +527,7 @@ Menu RID_POPUP_GRAPHIC
         MN_EDITLNK
         MN_DELLNK
         MenuItem { ITEM_OPEN_HYPERLINK };
+        MenuItem { ITEM_EXTERNAL_EDIT };
     };
 };
 
@@ -657,4 +658,3 @@ Menu RID_POPUP_DRAWTEXT
         };
     };
 };
-
diff --git a/sc/source/ui/inc/graphsh.hxx b/sc/source/ui/inc/graphsh.hxx
index 7e7c5fa..3c700c7 100644
--- a/sc/source/ui/inc/graphsh.hxx
+++ b/sc/source/ui/inc/graphsh.hxx
@@ -44,6 +44,9 @@ public:
 
     void    ExecuteFilter(SfxRequest& rReq);
     void    GetFilterState(SfxItemSet &rSet);
+
+    void    ExecuteExternalEdit(SfxRequest& rReq);
+    void    GetExternalEditState(SfxItemSet &rSet);
 };
 
 #endif
diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk
index beda9bd..8361ec1 100644
--- a/svx/Library_svxcore.mk
+++ b/svx/Library_svxcore.mk
@@ -92,6 +92,7 @@ $(eval $(call gb_Library_use_external,svxcore,icuuc))
 
 $(eval $(call gb_Library_add_exception_objects,svxcore,\
     svx/source/core/coreservices \
+    svx/source/core/extedit \
     svx/source/customshapes/EnhancedCustomShape2d \
     svx/source/customshapes/EnhancedCustomShapeGeometry \
     svx/source/customshapes/EnhancedCustomShapeTypeNames \
diff --git a/svx/Package_inc.mk b/svx/Package_inc.mk
index df90d0f..b6888d1 100644
--- a/svx/Package_inc.mk
+++ b/svx/Package_inc.mk
@@ -2,7 +2,7 @@
 #*************************************************************************
 #
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-# 
+#
 # Copyright 2000, 2011 Oracle and/or its affiliates.
 #
 # OpenOffice.org - a multi-platform office productivity suite
@@ -553,5 +553,6 @@ $(eval $(call 
gb_Package_add_file,svx_inc,inc/svx/svxdllapi.h,svx/svxdllapi.h))
 $(eval $(call 
gb_Package_add_file,svx_inc,inc/svx/colrctrl.hxx,svx/colrctrl.hxx))
 $(eval $(call gb_Package_add_file,svx_inc,inc/svx/fmdpage.hxx,svx/fmdpage.hxx))
 $(eval $(call 
gb_Package_add_file,svx_inc,inc/svx/sxmtpitm.hxx,svx/sxmtpitm.hxx))
+$(eval $(call gb_Package_add_file,svx_inc,inc/svx/extedit.hxx,svx/extedit.hxx))
 
 # vim: set noet sw=4 ts=4:
diff --git a/svx/inc/globlmn_tmpl.hrc b/svx/inc/globlmn_tmpl.hrc
index f6b8f73..e85bd91 100644
--- a/svx/inc/globlmn_tmpl.hrc
+++ b/svx/inc/globlmn_tmpl.hrc
@@ -257,6 +257,11 @@
     Command = ".uno:ImageMapDialog" ; \
     Text [ en-US ] = "ImageMap" ; \
 
+#define ITEM_EXTERNAL_EDIT \
+    Identifier = SID_EXTERNAL_EDIT ; \
+    Command = ".uno:ExternalEdit" ; \
+    Text [ en-US ] = "Edit with External Tool..." ; \
+
 #define ITEM_VIEW_ATTR_ZOOM \
     Identifier = SID_ATTR_ZOOM ; \
     Command = ".uno:Zoom" ; \
diff --git a/svx/inc/svx/extedit.hxx b/svx/inc/svx/extedit.hxx
new file mode 100644
index 0000000..b286ad8
--- /dev/null
+++ b/svx/inc/svx/extedit.hxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       [ Surendran Mahendran <surensp...@gmail.com>]
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+#ifndef _EXTEDIT_HXX
+#define _EXTEDIT_HXX
+
+#include <osl/file.hxx>
+#include <osl/process.h>
+#include <vcl/graph.hxx>
+#include <svtools/grfmgr.hxx>
+#include <vcl/timer.hxx>
+#include "svx/svxdllapi.h"
+
+class SVX_DLLPUBLIC ExternalToolEdit
+{
+public:
+    GraphicObject* m_pGraphicObject;
+    rtl::OUString m_aFileName;
+
+    ExternalToolEdit();
+    virtual ~ExternalToolEdit();
+
+    virtual void Update( Graphic& aGraphic ) = 0;
+    void Edit( GraphicObject *pGraphic );
+
+
+    DECL_LINK( StartListeningEvent, void *pEvent );
+
+    static void threadWorker( void *pThreadData );
+    static void HandleCloseEvent( ExternalToolEdit* pData );
+};
+
+
+#endif
diff --git a/svx/inc/svx/svxids.hrc b/svx/inc/svx/svxids.hrc
index fca5831..918d44d 100644
--- a/svx/inc/svx/svxids.hrc
+++ b/svx/inc/svx/svxids.hrc
@@ -955,9 +955,10 @@
 #define SID_INSERT_FORM_SPIN                            (SID_SVX_START+1110)
 #define SID_INSERT_FORM_VSCROLL                         (SID_SVX_START+1111)
 #define SID_INSERT_FORM_HSCROLL                         (SID_SVX_START+1112)
+#define SID_EXTERNAL_EDIT                               (SID_SVX_START+1113)
 
 // IMPORTANT NOTE: adjust SID_SVX_FIRSTFREE, when adding new slot id
-#define SID_SVX_FIRSTFREE                               
(SID_INSERT_FORM_HSCROLL + 1)
+#define SID_SVX_FIRSTFREE                               (SID_EXTERNAL_EDIT + 1)
 
 // --------------------------------------------------------------------------
 // Overflow check for slot IDs
@@ -970,4 +971,3 @@
 #endif // #ifndef _SVX_SVXIDS_HRC
 
 // ******************************************************************* EOF
-
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index 5e19175..8b168c8 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -5948,6 +5948,30 @@ SfxBoolItem ImageMapExecute SID_IMAP_EXEC
     GroupId = GID_EDIT;
 ]
 
+SfxVoidItem ExternalEdit SID_EXTERNAL_EDIT
+
+[
+    /* 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_GRAPHIC;
+]
+
 //--------------------------------------------------------------------------
 SfxBoolItem Init3D SID_3D_INIT
 
@@ -15323,4 +15347,3 @@ SfxVoidItem PrepareMailExport SID_MAIL_PREPAREEXPORT
     ToolBoxConfig = FALSE,
     GroupId = GID_EXPLORER;
 ]
-
diff --git a/svx/source/core/extedit.cxx b/svx/source/core/extedit.cxx
new file mode 100644
index 0000000..eddb16a
--- /dev/null
+++ b/svx/source/core/extedit.cxx
@@ -0,0 +1,170 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       [ Surendran Mahendran <surensp...@gmail.com>]
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <svx/extedit.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <osl/file.hxx>
+#include <osl/thread.hxx>
+#include <osl/process.h>
+#include <osl/time.h>
+#include <svtools/filter.hxx>
+#include <svtools/filechangedchecker.hxx>
+#include <svx/xoutbmp.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/cvtgrf.hxx>
+
+#include "com/sun/star/system/XSystemShellExecute.hpp"
+#include "com/sun/star/system/SystemShellExecuteFlags.hpp"
+#include <comphelper/processfactory.hxx>
+
+#include <boost/bind.hpp>
+
+using namespace ::com::sun::star;
+ExternalToolEdit::ExternalToolEdit()
+{}
+
+ExternalToolEdit::~ExternalToolEdit()
+{}
+
+void ExternalToolEdit::HandleCloseEvent(ExternalToolEdit* pData)
+{
+    Graphic newGraphic;
+
+    //import the temp file image stream into the newGraphic
+    SvStream* pStream = utl::UcbStreamHelper::CreateStream(pData->m_aFileName, 
STREAM_READ);
+    if(pStream)
+    {
+        GraphicConverter::Import(*pStream, newGraphic);
+
+        // Now update the Graphic in the shell by re-reading from the 
newGraphic
+        // TODO: Make this action Undoable !
+        //rSh->ReRead(aEmptyStr, aEmptyStr, (const Graphic*) &newGraphic);
+        pData->Update( newGraphic );
+
+        delete(pStream);
+    }
+}
+
+IMPL_LINK (ExternalToolEdit, StartListeningEvent, void*, pEvent)
+{
+    //Start an event listener implemented via VCL timeout
+    ExternalToolEdit* pData = ( ExternalToolEdit* )pEvent;
+    String aURL( pData->m_aFileName );
+
+    new FileChangedChecker(
+        pData->m_aFileName,
+        ::boost::bind(&HandleCloseEvent, pData));
+
+    return 0;
+}
+
+void ExternalToolEdit::threadWorker(void* pThreadData)
+{
+    ExternalToolEdit* pData = (ExternalToolEdit*) pThreadData;
+
+    // Make an asynchronous call to listen to the event of temporary image file
+    // getting changed
+    Application::PostUserEvent( LINK( NULL, ExternalToolEdit, 
StartListeningEvent ), pThreadData);
+
+    uno::Reference< com::sun::star::system::XSystemShellExecute > 
xSystemShellExecute(
+            ::comphelper::getProcessServiceFactory()->createInstance(
+                DEFINE_CONST_UNICODE("com.sun.star.system.SystemShellExecute") 
), uno::UNO_QUERY_THROW );
+    xSystemShellExecute->execute( pData->m_aFileName, rtl::OUString(),  
com::sun::star::system::SystemShellExecuteFlags::URIS_ONLY );
+}
+
+
+void GetPreferedExtension( String &rExt, const Graphic &rGrf )
+{
+    // then propose the "best" filter using the native-info, if applicable
+    const sal_Char* pExt = "png";
+    switch( const_cast<Graphic&>(rGrf).GetLink().GetType() )
+    {
+        case GFX_LINK_TYPE_NATIVE_GIF:
+            pExt = "gif";
+            break;
+        case GFX_LINK_TYPE_NATIVE_TIF:
+            pExt = "tif";
+            break;
+        case GFX_LINK_TYPE_NATIVE_WMF:
+            pExt = "wmf";
+            break;
+        case GFX_LINK_TYPE_NATIVE_MET:
+            pExt = "met";
+            break;
+        case GFX_LINK_TYPE_NATIVE_PCT:
+            pExt = "pct";
+            break;
+        case GFX_LINK_TYPE_NATIVE_JPG:
+            pExt = "jpg";
+            break;
+        default:
+            break;
+    }
+    rExt.AssignAscii( pExt );
+}
+
+void ExternalToolEdit::Edit( GraphicObject* pGraphicObject )
+{
+    //Get the graphic from the GraphicObject
+    m_pGraphicObject = pGraphicObject;
+    const Graphic aGraphic = pGraphicObject->GetGraphic();
+
+    //get the Preferred File Extension for this graphic
+    String fExtension;
+    GetPreferedExtension(fExtension, aGraphic);
+
+    //Create the temp File
+    rtl::OUString tempFileBase, tempFileName;
+    oslFileHandle pHandle;
+    osl::FileBase::createTempFile(0, &pHandle, &tempFileBase);
+
+    // Move it to a file name with image extension properly set
+    tempFileName = tempFileBase + rtl::OUString(String('.')) + 
rtl::OUString(fExtension);
+    osl::File::move(tempFileBase, tempFileName);
+
+    //Write Graphic to the Temp File
+    GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter();
+    sal_uInt16 nFilter(rGraphicFilter.GetExportFormatNumber(fExtension));
+    String aFilter(rGraphicFilter.GetExportFormatShortName(nFilter));
+    String sPath(tempFileName);
+
+    // Write the Graphic to the file now
+    XOutBitmap::WriteGraphic(aGraphic, sPath, aFilter, 
XOUTBMP_USE_NATIVE_IF_POSSIBLE|XOUTBMP_DONT_EXPAND_FILENAME);
+
+    // There is a possiblity that sPath extnesion might have been changed if 
the
+    // provided extension is not writable
+    tempFileName = rtl::OUString(sPath);
+
+    //Create a thread
+    rtl_uString* aFileName = new rtl_uString();
+    rtl_uString_newFromAscii(
+        &aFileName,
+        rtl::OUStringToOString(tempFileName, RTL_TEXTENCODING_UTF8).getStr());
+    m_aFileName = aFileName;
+    // Create the data that is needed by the thread later
+    osl_createThread(ExternalToolEdit::threadWorker, this);
+}
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 1ddc142..dc25ed8 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -585,7 +585,6 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
     sw/source/ui/docvw/edtwin \
     sw/source/ui/docvw/edtwin2 \
     sw/source/ui/docvw/edtwin3 \
-    sw/source/ui/docvw/extedit \
     sw/source/ui/docvw/frmsidebarwincontainer \
     sw/source/ui/docvw/romenu \
     sw/source/ui/docvw/srcedtw \
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index ac547f6..2262521 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -853,14 +853,11 @@ included in c-context files, so c++ style stuff will 
cause problems.
 #define FN_UNO_TABLE_NAME                   (FN_EXTRA2 + 111)
 #define FN_UNO_META                         (FN_EXTRA2 + 112)
 #define FN_UNO_NESTED_TEXT_CONTENT          (FN_EXTRA2 + 113)
-/* Edit Graphic with External Tool */
-#define FN_EXTERNAL_EDIT                    (FN_EXTRA2 + 114)
 
 /* Navigation buttons */
 #define FN_NAVIGATION_BACK                  (FN_EXTRA2 + 115)
 #define FN_NAVIGATION_FORWARD               (FN_EXTRA2 + 116)
 
-
 // #i972: bool items to be passed to SwFrmPage for evaluation
 #define FN_OLE_IS_MATH                      (FN_EXTRA2 + 114)
 #define FN_MATH_BASELINE_ALIGNMENT          (FN_EXTRA2 + 115)
diff --git a/sw/inc/swcommands.h b/sw/inc/swcommands.h
index 530e3a6..69e546c 100644
--- a/sw/inc/swcommands.h
+++ b/sw/inc/swcommands.h
@@ -48,7 +48,6 @@
 #define CMD_FN_FORMAT_FRAME_DLG                     ".uno:FrameDialog"
 #define CMD_FN_FORMAT_GRAFIC_DLG                    ".uno:GraphicDialog"
 #define CMD_FN_SAVE_GRAPHIC                         ".uno:SaveGraphic"
-#define CMD_FN_EXTERNAL_EDIT                        ".uno:ExternalEdit"
 #define CMD_FN_NUM_BULLET_UP                        ".uno:IncrementLevel"
 #define CMD_FN_EDIT_IDX_ENTRY_DLG                   ".uno:IndexEntryDialog"
 #define CMD_FN_INSERT_FLD_AUTHOR                    ".uno:InsertAuthorField"
diff --git a/sw/sdi/_grfsh.sdi b/sw/sdi/_grfsh.sdi
index d60dc39..42d9666 100644
--- a/sw/sdi/_grfsh.sdi
+++ b/sw/sdi/_grfsh.sdi
@@ -58,11 +58,12 @@ interface BaseTextGraphic
         StateMethod = GetAttrState ;
     ]
 
-    FN_EXTERNAL_EDIT
+    SID_EXTERNAL_EDIT
     [
         ExecMethod = Execute ;
         StateMethod = GetAttrState ;
     ]
+
     SID_INSERT_GRAPHIC // zeigt auf FN_FORMAT_GRAFIC_DLG
     [
         ExecMethod = Execute ;
@@ -218,4 +219,3 @@ interface BaseTextGraphic
         ]
 
 }
-
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index bab0c1b..7e9680e 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -3462,33 +3462,6 @@ SfxVoidItem SaveGraphic FN_SAVE_GRAPHIC
     GroupId = GID_GRAPHIC;
 ]
 
-//------------------------------------------------------------------------
-SfxVoidItem ExternalEdit FN_EXTERNAL_EDIT
-()
-[
-    /* 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_GRAPHIC;
-]
-//------------------------------------------------------------------------
-
-
 //--------------------------------------------------------------------------
 SfxVoidItem Grow FN_GROW_FONT_SIZE
 ()
diff --git a/sw/source/ui/app/mn.src b/sw/source/ui/app/mn.src
index deed82e..8b31291 100644
--- a/sw/source/ui/app/mn.src
+++ b/sw/source/ui/app/mn.src
@@ -1290,9 +1290,7 @@ Menu MN_GRF_POPUPMENU
         SEPARATOR;
         MenuItem
         {
-            Identifier = FN_EXTERNAL_EDIT ;
-            HelpID = CMD_FN_EXTERNAL_EDIT ;
-            Text [ en-US ] = "Edit with External Tool...";
+           ITEM_EXTERNAL_EDIT
         };
         SEPARATOR;
         MenuItem
@@ -1462,4 +1460,3 @@ Menu MN_TEXT_POPUPMENU
     BASE_TEXT_POPUPMENU_BEGIN
     BASE_TEXT_POPUPMENU_NOWEB
     BASE_TEXT_POPUPMENU_END
-
diff --git a/sw/source/ui/docvw/extedit.cxx b/sw/source/ui/docvw/extedit.cxx
deleted file mode 100644
index 8b70262..0000000
--- a/sw/source/ui/docvw/extedit.cxx
+++ /dev/null
@@ -1,149 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Initial Developer of the Original Code is
- *       [ Surendran Mahendran <surensp...@gmail.com>]
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-
-#include <extedit.hxx>
-#include <view.hxx>
-#include <sfx2/viewfrm.hxx>
-#include <sfx2/bindings.hxx>
-#include <wrtsh.hxx>
-#include <osl/file.hxx>
-#include <osl/thread.hxx>
-#include <osl/process.h>
-#include <osl/time.h>
-#include <svtools/filter.hxx>
-#include <svtools/filechangedchecker.hxx>
-#include <svx/xoutbmp.hxx>
-#include <unotools/ucbstreamhelper.hxx>
-#include <vcl/svapp.hxx>
-#include <vcl/graph.hxx>
-#include <vcl/cvtgrf.hxx>
-#include <basesh.hxx>
-#include "romenu.hxx"
-#include "com/sun/star/system/XSystemShellExecute.hpp"
-#include "com/sun/star/system/SystemShellExecuteFlags.hpp"
-#include <comphelper/processfactory.hxx>
-
-#include <boost/bind.hpp>
-
-using namespace ::com::sun::star;
-
-void HandleCloseEvent(const String& rURL, SwWrtShell *rSh)
-{
-    //create a new Graphic
-    Graphic newGraphic;
-
-    //import the temp file image stream into the newGraphic
-    SvStream*  pStream = utl::UcbStreamHelper::CreateStream(rURL, STREAM_READ);
-    if(pStream)
-    {
-        GraphicConverter::Import(*pStream, newGraphic);
-
-        // Now update the Graphic in the shell by re-reading from the 
newGraphic
-        // TODO: Make this action Undoable !
-        rSh->ReRead(aEmptyStr, aEmptyStr, (const Graphic*) &newGraphic);
-
-        delete(pStream);
-    }
-}
-
-IMPL_LINK (ExternalProcessClass_Impl, StartListeningEvent, void*, pEvent)
-{
-    //Start an event listener implemented via VCL timeout
-    Data *pData = ( Data* )pEvent;
-    String aURL( pData->fileName );
-
-    new FileChangedChecker(
-        pData->fileName,
-        ::boost::bind(&HandleCloseEvent,aURL,pData->rSh));
-
-    return 0;
-}
-
-void pWorker(void *pThreadData)
-{
-    Data *pData = (Data*)(pThreadData);
-    rtl_uString *aFileName = new rtl_uString();
-    rtl_uString_newFromAscii (
-            &aFileName, rtl::OUStringToOString(
-                pData->fileName, RTL_TEXTENCODING_UTF8).getStr());
-
-    // Make an asynchronous call to listen to the event of temporary image file
-    // getting changed
-    Application::PostUserEvent(
-            LINK(NULL, ExternalProcessClass_Impl, StartListeningEvent), 
pThreadData);
-
-    uno::Reference< com::sun::star::system::XSystemShellExecute > 
xSystemShellExecute(
-            ::comphelper::getProcessServiceFactory()->createInstance(
-                DEFINE_CONST_UNICODE("com.sun.star.system.SystemShellExecute") 
), uno::UNO_QUERY_THROW );
-    xSystemShellExecute->execute( pData->fileName, rtl::OUString(),  
com::sun::star::system::SystemShellExecuteFlags::URIS_ONLY );
-}
-
-void EditWithExternalTool(GraphicObject *pGraphicObject, SwWrtShell *rSh)
-{
-    //Get the graphic from the GraphicObject
-    const Graphic pGraphic = pGraphicObject->GetGraphic();
-
-    //get the Preferred File Extension for this graphic
-    String fExt;
-    GetPreferedExtension(fExt, pGraphic);
-
-    //Create the temp File
-    rtl::OUString tempFileBase, tempFileName;
-    oslFileHandle pHandle;
-    osl::FileBase::createTempFile(0, &pHandle, &tempFileBase);
-
-    // Move it to a file name with image extension properly set
-    tempFileName = tempFileBase + rtl::OUString(String('.')) +
-        rtl::OUString(fExt);
-    osl::File::move(tempFileBase, tempFileName);
-
-    //Write Graphic to the Temp File
-    GraphicFilter& rGF = GraphicFilter::GetGraphicFilter();
-    sal_uInt16 nFilter(rGF.GetExportFormatNumber(fExt));
-    String aFilter(rGF.GetExportFormatShortName(nFilter));
-    String sPath(tempFileName);
-
-    // Write the Graphic to the file now
-    XOutBitmap::WriteGraphic(pGraphic, sPath, aFilter,
-            XOUTBMP_USE_NATIVE_IF_POSSIBLE|XOUTBMP_DONT_EXPAND_FILENAME);
-
-    // There is a possiblity that sPath extnesion might have been changed if 
the
-    // provided extension is not writable
-    tempFileName = rtl::OUString(sPath);
-
-    //Create a thread
-    rtl_uString *fileName = new rtl_uString();
-    rtl_uString_newFromAscii(
-            &fileName, rtl::OUStringToOString(tempFileName,
-                RTL_TEXTENCODING_UTF8).getStr());
-
-    // Create the data that is needed by the thread later
-    Data *pThreadData = new Data();
-    pThreadData->pGraphicObject = pGraphicObject;
-    pThreadData->fileName = fileName;
-    pThreadData->rSh = rSh ;
-
-    osl_createThread(pWorker, pThreadData);
-
-}
diff --git a/sw/source/ui/inc/extedit.hxx b/sw/source/ui/inc/extedit.hxx
deleted file mode 100644
index d013890..0000000
--- a/sw/source/ui/inc/extedit.hxx
+++ /dev/null
@@ -1,50 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Initial Developer of the Original Code is
- *       [ Surendran Mahendran <surensp...@gmail.com>]
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-#ifndef _EXTEDIT_HXX
-#define _EXTEDIT_HXX
-
-#include <osl/file.hxx>
-#include <osl/process.h>
-#include <vcl/graph.hxx>
-#include <svtools/grfmgr.hxx>
-#include <wrtsh.hxx>
-#include <vcl/timer.hxx>
-
-struct Data
-{
-    GraphicObject *pGraphicObject;
-    rtl::OUString fileName;
-    SwWrtShell *rSh ;
-};
-
-class ExternalProcessClass_Impl
-{
-    public:
-        DECL_LINK( CloseEvent, void *pEvent );
-        DECL_LINK( StartListeningEvent, void *pEvent );
-};
-
-void EditWithExternalTool(GraphicObject *pGraphic, SwWrtShell *rSh);
-
-#endif
diff --git a/sw/source/ui/shells/grfsh.cxx b/sw/source/ui/shells/grfsh.cxx
index 898da61..f472841 100644
--- a/sw/source/ui/shells/grfsh.cxx
+++ b/sw/source/ui/shells/grfsh.cxx
@@ -70,7 +70,7 @@
 #include <swwait.hxx>
 #include <shells.hrc>
 #include <popup.hrc>
-#include <extedit.hxx>
+#include <svx/extedit.hxx>
 #define SwGrfShell
 #include <sfx2/msg.hxx>
 #include "swslots.hxx"
@@ -79,6 +79,21 @@
 
 #define TOOLBOX_NAME    ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 
"colorbar" ) )
 
+class SwExternalToolEdit : public ExternalToolEdit
+{
+    SwWrtShell*  m_pShell;
+
+public:
+    SwExternalToolEdit ( SwWrtShell* pShell ) :
+        m_pShell  (pShell)
+    {}
+
+    virtual void Update( Graphic& aGraphic )
+    {
+        m_pShell->ReRead(aEmptyStr, aEmptyStr, (const Graphic*) &aGraphic);
+    }
+};
+
 SFX_IMPL_INTERFACE(SwGrfShell, SwBaseShell, SW_RES(STR_SHELLNAME_GRAPHIC))
 {
     SFX_POPUPMENU_REGISTRATION(SW_RES(MN_GRF_POPUPMENU));
@@ -108,7 +123,7 @@ void SwGrfShell::Execute(SfxRequest &rReq)
             }
         }
         break;
-        case FN_EXTERNAL_EDIT:
+        case SID_EXTERNAL_EDIT:
         {
             /* When the graphic is selected to be opened via some external tool
              * for advanced editing
@@ -116,7 +131,8 @@ void SwGrfShell::Execute(SfxRequest &rReq)
             GraphicObject *pGraphicObject = (GraphicObject *) 
rSh.GetGraphicObj();
             if(0 != pGraphicObject)
             {
-                EditWithExternalTool(pGraphicObject, &rSh);
+                SwExternalToolEdit* externalToolEdit = new SwExternalToolEdit( 
&rSh );
+                externalToolEdit->Edit ( pGraphicObject );
             }
         }
         break;
@@ -541,10 +557,10 @@ void SwGrfShell::GetAttrState(SfxItemSet &rSet)
             if( rSh.GetGraphicType() == GRAPHIC_NONE )
                 bDisable = sal_True;
         break;
-        /*
-         * If the Graphic is None type it should be externally editable
-         */
-        case FN_EXTERNAL_EDIT:
+        case SID_EXTERNAL_EDIT:
+            /*
+             * If the Graphic is None type it should be externally editable
+             */
             if( rSh.GetGraphicType() == GRAPHIC_NONE )
                 bDisable = sal_True;
         break;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to