Kaydet (Commit) fd665508 authored tarafından Samuel Mehrbrodt's avatar Samuel Mehrbrodt

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/26947Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
üst 28a03248
...@@ -99,14 +99,17 @@ FuInsertGraphic::FuInsertGraphic ( ...@@ -99,14 +99,17 @@ FuInsertGraphic::FuInsertGraphic (
::sd::Window* pWin, ::sd::Window* pWin,
::sd::View* pView, ::sd::View* pView,
SdDrawDocument* pDoc, SdDrawDocument* pDoc,
SfxRequest& rReq) SfxRequest& rReq,
: FuPoor(pViewSh, pWin, pView, pDoc, 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); xFunc->DoExecute(rReq);
return xFunc; return xFunc;
} }
...@@ -154,14 +157,14 @@ void FuInsertGraphic::DoExecute( SfxRequest& rReq ) ...@@ -154,14 +157,14 @@ void FuInsertGraphic::DoExecute( SfxRequest& rReq )
if( mpViewShell && dynamic_cast< DrawViewShell *>( mpViewShell ) != nullptr) if( mpViewShell && dynamic_cast< DrawViewShell *>( mpViewShell ) != nullptr)
{ {
sal_Int8 nAction = DND_ACTION_COPY; sal_Int8 nAction = DND_ACTION_COPY;
SdrObject* pPickObj; SdrObject* pPickObj = mpView->GetEmptyPresentationObject( PRESOBJ_GRAPHIC );
bool bSelectionReplaced(false); bool bSelectionReplaced(false);
if( ( pPickObj = mpView->GetSelectedSingleObject( mpView->GetPage() ) ) || ( pPickObj = mpView->GetEmptyPresentationObject( PRESOBJ_GRAPHIC ) ) ) if( pPickObj )
{ {
nAction = DND_ACTION_LINK; nAction = DND_ACTION_LINK;
} }
else if(1 == mpView->GetMarkedObjectCount()) else if(mbReplaceExistingImage && mpView->GetMarkedObjectCount() == 1)
{ {
pPickObj = mpView->GetMarkedObjectByIndex(0); pPickObj = mpView->GetMarkedObjectByIndex(0);
nAction = DND_ACTION_MOVE; nAction = DND_ACTION_MOVE;
......
...@@ -30,7 +30,9 @@ class FuInsertGraphic ...@@ -30,7 +30,9 @@ class FuInsertGraphic
{ {
public: 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; virtual void DoExecute( SfxRequest& rReq ) override;
private: private:
...@@ -40,7 +42,10 @@ private: ...@@ -40,7 +42,10 @@ private:
::sd::Window* pWin, ::sd::Window* pWin,
::sd::View* pView, ::sd::View* pView,
SdDrawDocument* pDoc, SdDrawDocument* pDoc,
SfxRequest& rReq); SfxRequest& rReq,
bool replaceExistingImage);
bool mbReplaceExistingImage;
}; };
/************************************************************************/ /************************************************************************/
......
...@@ -1084,7 +1084,8 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) ...@@ -1084,7 +1084,8 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
case SID_CHANGE_PICTURE: case SID_CHANGE_PICTURE:
case SID_INSERT_GRAPHIC: 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(); Cancel();
rReq.Ignore (); rReq.Ignore ();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment