diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-07-05 12:05:28 +0000 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-07-05 19:58:48 +0000 |
commit | fd6655080e181de4b78e31f13fe8ba35de8edfe5 (patch) | |
tree | b132314cd39e107b818f057cda33c07e6e9f2e47 /sd | |
parent | 28a03248b1d1649e157b788e43dfe8326f165379 (diff) |
tdf#73742 Don't replace existing image when inserting one
If we want to replace an image, we have an entry in the context menu for that.
Change-Id: I7a5326fecb72896c0709c9272769b8d51e4a5ca2
Reviewed-on: https://gerrit.libreoffice.org/26947
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/func/fuinsert.cxx | 17 | ||||
-rw-r--r-- | sd/source/ui/inc/fuinsert.hxx | 9 | ||||
-rw-r--r-- | sd/source/ui/view/drviews2.cxx | 3 |
3 files changed, 19 insertions, 10 deletions
diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx index d63bcc0e649f..cbf79344334e 100644 --- a/sd/source/ui/func/fuinsert.cxx +++ b/sd/source/ui/func/fuinsert.cxx @@ -99,14 +99,17 @@ FuInsertGraphic::FuInsertGraphic ( ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, - SfxRequest& rReq) - : FuPoor(pViewSh, pWin, pView, pDoc, rReq) + SfxRequest& rReq, + bool replaceExistingImage) + : FuPoor(pViewSh, pWin, pView, pDoc, rReq), + mbReplaceExistingImage(replaceExistingImage) { } -rtl::Reference<FuPoor> FuInsertGraphic::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq ) +rtl::Reference<FuPoor> FuInsertGraphic::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, + SdDrawDocument* pDoc, SfxRequest& rReq, bool replaceExistingImage ) { - rtl::Reference<FuPoor> xFunc( new FuInsertGraphic( pViewSh, pWin, pView, pDoc, rReq ) ); + rtl::Reference<FuPoor> xFunc( new FuInsertGraphic( pViewSh, pWin, pView, pDoc, rReq, replaceExistingImage ) ); xFunc->DoExecute(rReq); return xFunc; } @@ -154,14 +157,14 @@ void FuInsertGraphic::DoExecute( SfxRequest& rReq ) if( mpViewShell && dynamic_cast< DrawViewShell *>( mpViewShell ) != nullptr) { sal_Int8 nAction = DND_ACTION_COPY; - SdrObject* pPickObj; + SdrObject* pPickObj = mpView->GetEmptyPresentationObject( PRESOBJ_GRAPHIC ); bool bSelectionReplaced(false); - if( ( pPickObj = mpView->GetSelectedSingleObject( mpView->GetPage() ) ) || ( pPickObj = mpView->GetEmptyPresentationObject( PRESOBJ_GRAPHIC ) ) ) + if( pPickObj ) { nAction = DND_ACTION_LINK; } - else if(1 == mpView->GetMarkedObjectCount()) + else if(mbReplaceExistingImage && mpView->GetMarkedObjectCount() == 1) { pPickObj = mpView->GetMarkedObjectByIndex(0); nAction = DND_ACTION_MOVE; diff --git a/sd/source/ui/inc/fuinsert.hxx b/sd/source/ui/inc/fuinsert.hxx index 74e251a138c8..2a946e8e2e18 100644 --- a/sd/source/ui/inc/fuinsert.hxx +++ b/sd/source/ui/inc/fuinsert.hxx @@ -30,7 +30,9 @@ class FuInsertGraphic { public: - static rtl::Reference<FuPoor> Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq ); + static rtl::Reference<FuPoor> Create( ViewShell* pViewSh, ::sd::Window* pWin, + ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, + bool replaceExistingImage); virtual void DoExecute( SfxRequest& rReq ) override; private: @@ -40,7 +42,10 @@ private: ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, - SfxRequest& rReq); + SfxRequest& rReq, + bool replaceExistingImage); + + bool mbReplaceExistingImage; }; /************************************************************************/ diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index bec691d69132..829ee91607be 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -1084,7 +1084,8 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) case SID_CHANGE_PICTURE: case SID_INSERT_GRAPHIC: { - SetCurrentFunction( FuInsertGraphic::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); + SetCurrentFunction( FuInsertGraphic::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq, + nSId == SID_CHANGE_PICTURE ) ); Cancel(); rReq.Ignore (); } |