diff options
author | Tomaž Vajngerl <quikee@gmail.com> | 2012-06-28 00:19:28 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2012-06-28 00:27:47 +0200 |
commit | 7a3ae89a12b2c11e90d3f0c76293ddb63203bd2a (patch) | |
tree | 0882ad037d36e6d2281d22e8dbffbb635ca7c138 /sc/source/ui/drawfunc/graphsh.cxx | |
parent | e18655e47530f1e399cb546a6001fa0aa0f1873c (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 'sc/source/ui/drawfunc/graphsh.cxx')
-rw-r--r-- | sc/source/ui/drawfunc/graphsh.cxx | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/sc/source/ui/drawfunc/graphsh.cxx b/sc/source/ui/drawfunc/graphsh.cxx index 751fc41cab63..ff4d43d72dae 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: */ |