summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorTomaž Vajngerl <quikee@gmail.com>2012-06-28 00:19:28 +0200
committerTomaž Vajngerl <quikee@gmail.com>2012-06-28 00:27:47 +0200
commit7a3ae89a12b2c11e90d3f0c76293ddb63203bd2a (patch)
tree0882ad037d36e6d2281d22e8dbffbb635ca7c138 /sw
parente18655e47530f1e399cb546a6001fa0aa0f1873c (diff)
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
Diffstat (limited to 'sw')
-rw-r--r--sw/Library_sw.mk1
-rw-r--r--sw/inc/cmdid.h3
-rw-r--r--sw/inc/swcommands.h1
-rw-r--r--sw/sdi/_grfsh.sdi4
-rw-r--r--sw/sdi/swriter.sdi27
-rw-r--r--sw/source/ui/app/mn.src5
-rw-r--r--sw/source/ui/docvw/extedit.cxx149
-rw-r--r--sw/source/ui/inc/extedit.hxx50
-rw-r--r--sw/source/ui/shells/grfsh.cxx30
9 files changed, 26 insertions, 244 deletions
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 1ddc142c108c..dc25ed8acc57 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 ac547f67a226..2262521988ef 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 530e3a6d02c1..69e546c06de6 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 d60dc39d4b36..42d9666a7105 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 bab0c1b7442f..7e9680e58f80 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 deed82e7c615..8b312910a3c0 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 8b70262e2568..000000000000
--- 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 <surenspost@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 d013890a338d..000000000000
--- 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 <surenspost@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 898da61dd449..f47284124ea0 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;