sw/source/uibase/inc/concustomshape.hxx | 1 + sw/source/uibase/inc/drawbase.hxx | 1 + sw/source/uibase/ribbar/concustomshape.cxx | 16 ++++++++++++++++ sw/source/uibase/ribbar/drawbase.cxx | 24 ++++++++++++++++++++++-- 4 files changed, 40 insertions(+), 2 deletions(-)
New commits: commit 3aa5aa83039b04f1412185e49cad9e3b694d49ca Author: AshSinc <ashleighsinclai...@gmail.com> AuthorDate: Fri May 20 12:54:53 2022 +0100 Commit: Heiko Tietze <heiko.tie...@documentfoundation.org> CommitDate: Mon May 23 15:09:35 2022 +0200 tdf#149141 - Writer - Added default object creation when drag size too low Patch in case consistency is required for suggested Draw/Impress change here : https://gerrit.libreoffice.org/c/core/+/134499 Change-Id: If4f51109633338620cfe836695214df20c3ec577 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134682 Tested-by: Jenkins Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org> diff --git a/sw/source/uibase/inc/concustomshape.hxx b/sw/source/uibase/inc/concustomshape.hxx index 1ebb77cdd68e..cc2358ceeefc 100644 --- a/sw/source/uibase/inc/concustomshape.hxx +++ b/sw/source/uibase/inc/concustomshape.hxx @@ -47,6 +47,7 @@ class ConstCustomShape final : public SwDrawBase static OUString GetShapeTypeFromRequest( SfxRequest const & rReq ); virtual void CreateDefaultObject() override; + virtual void CreateDefaultObjectAtPosWithSize(Point aPos, Size aSize) override; // #i33136# virtual bool doConstructOrthogonal() const override; diff --git a/sw/source/uibase/inc/drawbase.hxx b/sw/source/uibase/inc/drawbase.hxx index 6aeb4455a3a1..ccc045ced313 100644 --- a/sw/source/uibase/inc/drawbase.hxx +++ b/sw/source/uibase/inc/drawbase.hxx @@ -63,6 +63,7 @@ public: virtual void Deactivate(); // deactivate function virtual void CreateDefaultObject(); + virtual void CreateDefaultObjectAtPosWithSize(Point aPos, Size aSize); // #i33136# virtual bool doConstructOrthogonal() const; diff --git a/sw/source/uibase/ribbar/concustomshape.cxx b/sw/source/uibase/ribbar/concustomshape.cxx index e830a447a374..56030fc42d35 100644 --- a/sw/source/uibase/ribbar/concustomshape.cxx +++ b/sw/source/uibase/ribbar/concustomshape.cxx @@ -171,6 +171,22 @@ void ConstCustomShape::CreateDefaultObject() } } +void ConstCustomShape::CreateDefaultObjectAtPosWithSize(Point aPos, Size aSize) +{ + SwDrawBase::CreateDefaultObjectAtPosWithSize(aPos, aSize); + SdrView *pSdrView = m_pSh->GetDrawView(); + if ( pSdrView ) + { + const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); + if ( rMarkList.GetMarkCount() == 1 ) + { + SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + if ( dynamic_cast< const SdrObjCustomShape *>( pObj ) ) + SetAttributes( pObj ); + } + } +} + // #i33136# bool ConstCustomShape::doConstructOrthogonal() const { diff --git a/sw/source/uibase/ribbar/drawbase.cxx b/sw/source/uibase/ribbar/drawbase.cxx index b88c964aa7f2..36a00853da90 100644 --- a/sw/source/uibase/ribbar/drawbase.cxx +++ b/sw/source/uibase/ribbar/drawbase.cxx @@ -254,7 +254,7 @@ bool SwDrawBase::MouseButtonUp(const MouseEvent& rMEvt) SdrObjKind::PathFill == nDrawMode || SdrObjKind::FreehandLine == nDrawMode || SdrObjKind::FreehandFill == nDrawMode; - if(rMEvt.IsRight() || (aPnt == m_aStartPos && !bMultiPoint)) + if(rMEvt.IsRight()) { m_pSh->BreakCreate(); m_pView->LeaveDrawCreate(); @@ -269,7 +269,12 @@ bool SwDrawBase::MouseButtonUp(const MouseEvent& rMEvt) m_pSh->StartUndo(SwUndoId::INSERT, &aRewriter); } - m_pSh->EndCreate(SdrCreateCmd::ForceEnd); + bool didCreate = m_pSh->EndCreate(SdrCreateCmd::ForceEnd); + if(!didCreate && !bMultiPoint) + { + CreateDefaultObjectAtPosWithSize(aPnt, Size(1000, 1000)); + } + if (SdrObjKind::NONE == nDrawMode) // Text border inserted { uno::Reference< frame::XDispatchRecorder > xRecorder = @@ -523,6 +528,21 @@ void SwDrawBase::CreateDefaultObject() m_pSh->CreateDefaultShape(m_pWin->GetSdrDrawMode(), aRect, m_nSlotId); } +void SwDrawBase::CreateDefaultObjectAtPosWithSize(Point aPos, Size aSize) +{ + aPos.AdjustX(-sal_Int32(aSize.getWidth() / 2)); + aPos.AdjustY(-sal_Int32(aSize.getHeight() / 2)); + + SdrView* sdrView = m_pView->GetDrawView(); + SdrPageView *pPV = sdrView->GetSdrPageView(); + + if(sdrView->IsSnapEnabled()) + aPos = sdrView->GetSnapPos(aPos, pPV); + + ::tools::Rectangle aNewObjectRectangle(aPos, aSize); + m_pSh->CreateDefaultShape(m_pWin->GetSdrDrawMode(), aNewObjectRectangle, m_nSlotId); +} + Point SwDrawBase::GetDefaultCenterPos() const { Size aDocSz(m_pSh->GetDocSize());