summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2016-07-05 12:05:28 +0000
committerEike Rathke <erack@redhat.com>2016-07-21 17:16:51 +0000
commit7524dd59efc9b685548caf7967b24f7758796078 (patch)
tree294c5a2c6ef4679a5db2689f5b0fa8d46b0fcd5f
parent2152e6bd6960e2cfc719f4274504e842cfdd4bc3 (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/26966 Reviewed-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sd/source/ui/func/fuinsert.cxx17
-rw-r--r--sd/source/ui/inc/fuinsert.hxx9
-rw-r--r--sd/source/ui/view/drviews2.cxx3
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 ();
}