diff options
author | AshSinc <ashleighsinclair86@gmail.com> | 2022-05-18 23:04:20 +0100 |
---|---|---|
committer | Heiko Tietze <heiko.tietze@documentfoundation.org> | 2022-05-23 15:12:04 +0200 |
commit | 9e7597a1cc92e06d61acf87a8c560de3b4fdabf8 (patch) | |
tree | b219e34a34e4727869c54bfcfe8fd3d9b2fd0570 | |
parent | 3aa5aa83039b04f1412185e49cad9e3b694d49ca (diff) |
tdf#149141 - Added default object creation when drag size too low
Change-Id: Ibbc0fab14c0bcb18a979d6364b04c236c8c5e29e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134499
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
-rw-r--r-- | sd/source/ui/func/fucon3d.cxx | 26 | ||||
-rw-r--r-- | sd/source/ui/func/fuconcs.cxx | 18 | ||||
-rw-r--r-- | sd/source/ui/func/fuconrec.cxx | 18 |
3 files changed, 59 insertions, 3 deletions
diff --git a/sd/source/ui/func/fucon3d.cxx b/sd/source/ui/func/fucon3d.cxx index 111f7b141282..fb844548fafc 100644 --- a/sd/source/ui/func/fucon3d.cxx +++ b/sd/source/ui/func/fucon3d.cxx @@ -357,10 +357,30 @@ bool FuConstruct3dObject::MouseButtonUp(const MouseEvent& rMEvt) if ( mpView->IsCreateObj() && rMEvt.IsLeft() ) { - mpView->EndCreateObj(SdrCreateCmd::ForceEnd); - bReturn = true; - } + if( mpView->EndCreateObj( SdrCreateCmd::ForceEnd ) ) + { + bReturn = true; + } + else + { + //Drag was too small to create object, so insert default object at click pos + Point aClickPos(mpWindow->PixelToLogic(rMEvt.GetPosPixel())); + sal_uInt32 nDefaultObjectSize(1000); + sal_Int32 nCenterOffset(-sal_Int32(nDefaultObjectSize / 2)); + aClickPos.AdjustX(nCenterOffset); + aClickPos.AdjustY(nCenterOffset); + + SdrPageView *pPV = mpView->GetSdrPageView(); + if(mpView->IsSnapEnabled()) + aClickPos = mpView->GetSnapPos(aClickPos, pPV); + + ::tools::Rectangle aNewObjectRectangle(aClickPos, Size(nDefaultObjectSize, nDefaultObjectSize)); + SdrObjectUniquePtr pObjDefault = CreateDefaultObject(nSlotId, aNewObjectRectangle); + + bReturn = mpView->InsertObjectAtView(pObjDefault.release(), *pPV); + } + } bReturn = FuConstruct::MouseButtonUp(rMEvt) || bReturn; if (!bPermanent) diff --git a/sd/source/ui/func/fuconcs.cxx b/sd/source/ui/func/fuconcs.cxx index 964366f4522d..806960dd254a 100644 --- a/sd/source/ui/func/fuconcs.cxx +++ b/sd/source/ui/func/fuconcs.cxx @@ -124,6 +124,24 @@ bool FuConstructCustomShape::MouseButtonUp(const MouseEvent& rMEvt) { bReturn = true; } + else + { + //Drag was too small to create object, so insert default object at click pos + Point aClickPos(mpWindow->PixelToLogic(rMEvt.GetPosPixel())); + sal_uInt32 nDefaultObjectSize(1000); + sal_Int32 nCenterOffset(-sal_Int32(nDefaultObjectSize / 2)); + aClickPos.AdjustX(nCenterOffset); + aClickPos.AdjustY(nCenterOffset); + + SdrPageView *pPV = mpView->GetSdrPageView(); + if(mpView->IsSnapEnabled()) + aClickPos = mpView->GetSnapPos(aClickPos, pPV); + + ::tools::Rectangle aNewObjectRectangle(aClickPos, Size(nDefaultObjectSize, nDefaultObjectSize)); + SdrObjectUniquePtr pObjDefault = CreateDefaultObject(nSlotId, aNewObjectRectangle); + + bReturn = mpView->InsertObjectAtView(pObjDefault.release(), *pPV); + } } bReturn = FuConstruct::MouseButtonUp (rMEvt) || bReturn; diff --git a/sd/source/ui/func/fuconrec.cxx b/sd/source/ui/func/fuconrec.cxx index 605a330bdf63..d93ef2849468 100644 --- a/sd/source/ui/func/fuconrec.cxx +++ b/sd/source/ui/func/fuconrec.cxx @@ -314,6 +314,24 @@ bool FuConstructRectangle::MouseButtonUp(const MouseEvent& rMEvt) bReturn = true; } + else + { + //Drag was too small to create object, so insert default object at click pos + Point aClickPos(mpWindow->PixelToLogic(rMEvt.GetPosPixel())); + sal_uInt32 nDefaultObjectSize(1500); + sal_Int32 nCenterOffset(-sal_Int32(nDefaultObjectSize / 2)); + aClickPos.AdjustX(nCenterOffset); + aClickPos.AdjustY(nCenterOffset); + + SdrPageView *pPV = mpView->GetSdrPageView(); + if(mpView->IsSnapEnabled()) + aClickPos = mpView->GetSnapPos(aClickPos, pPV); + + ::tools::Rectangle aNewObjectRectangle(aClickPos, Size(nDefaultObjectSize, nDefaultObjectSize)); + SdrObjectUniquePtr pObjDefault = CreateDefaultObject(nSlotId, aNewObjectRectangle); + + bReturn = mpView->InsertObjectAtView(pObjDefault.release(), *pPV); + } } bReturn = FuConstruct::MouseButtonUp (rMEvt) || bReturn; |