diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-07-05 12:05:28 +0000 |
---|---|---|
committer | Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> | 2016-07-28 21:53:35 +0000 |
commit | 6033d910aa7a6ac7f9ce477d59df6c4766128a59 (patch) | |
tree | 890284c9ed0c37bafa6b7bf94c70650c79fd20b7 | |
parent | 0f3e3f4f0c0cb83d9289d8719982ff740406ceae (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>
(cherry picked from commit fd6655080e181de4b78e31f13fe8ba35de8edfe5)
Reviewed-on: https://gerrit.libreoffice.org/27114
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Tested-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-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 63410aae10e1..a26a6b12213f 100644 --- a/sd/source/ui/func/fuinsert.cxx +++ b/sd/source/ui/func/fuinsert.cxx @@ -98,14 +98,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; } @@ -153,14 +156,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 6a88b01d88c3..8d4ebec6f2b3 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -1114,7 +1114,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 (); } |