diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2019-07-02 00:01:01 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-07-03 09:18:41 +0200 |
commit | e6c7a018a0cfee395ce2886d41c908a2447ef5cc (patch) | |
tree | 724d0f4e4b62ea2cd91480ee10690585dbafa7a8 /svx | |
parent | c7f633d80f9ef5db60ad7218adf08a5914438e80 (diff) |
tdf#126180: EndTextEdit on all views before delete/cut slide
This also reworks the fixes tdf#125824 and tdf#111522 to use EndTextEdit
instead of blocking the undoing
Change-Id: I73c2289a9d950465f020f684e9e736148380f5c5
Reviewed-on: https://gerrit.libreoffice.org/74989
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/svdraw/svddrgmt.cxx | 3 | ||||
-rw-r--r-- | svx/source/svdraw/svdedtv.cxx | 13 | ||||
-rw-r--r-- | svx/source/svdraw/svdedtv1.cxx | 42 | ||||
-rw-r--r-- | svx/source/svdraw/svdedxv.cxx | 3 |
4 files changed, 40 insertions, 21 deletions
diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx index f41a7991ccec..400cab8f936b 100644 --- a/svx/source/svdraw/svddrgmt.cxx +++ b/svx/source/svdraw/svddrgmt.cxx @@ -1366,10 +1366,11 @@ bool SdrDragObjOwn::EndSdrDrag(bool /*bCopy*/) { std::unique_ptr<SdrUndoAction> pUndo; std::unique_ptr<SdrUndoAction> pUndo2; - const bool bUndo = getSdrDragView().IsUndoEnabled() && getSdrDragView().CanDoSdrUndo(); + const bool bUndo = getSdrDragView().IsUndoEnabled(); if( bUndo ) { + getSdrDragView().EndTextEditAllViews(); if(!getSdrDragView().IsInsObjPoint() && pObj->IsInserted() ) { if (DragStat().IsEndDragChangesAttributes()) diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx index e424276da087..d83910a86746 100644 --- a/svx/source/svdraw/svdedtv.cxx +++ b/svx/source/svdraw/svdedtv.cxx @@ -973,8 +973,11 @@ bool SdrEditView::InsertObjectAtView(SdrObject* pObj, SdrPageView& rPV, SdrInser if (!pObj->IsInserted()) { rPV.GetObjList()->InsertObject(pObj, SAL_MAX_SIZE); } - if( IsUndoEnabled() && CanDoSdrUndo()) + if( IsUndoEnabled()) + { + EndTextEditAllViews(); AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj)); + } if (!(nOptions & SdrInsertFlags::DONTMARK)) { if (!(nOptions & SdrInsertFlags::ADDMARK)) UnmarkAllObj(); @@ -1029,20 +1032,18 @@ bool SdrEditView::IsUndoEnabled() const return mpModel->IsUndoEnabled(); } -bool SdrEditView::CanDoSdrUndo() const +void SdrEditView::EndTextEditAllViews() const { size_t nViews = mpModel->GetListenerCount(); for (size_t nView = 0; nView < nViews; ++nView) { - SdrEditView* pView = dynamic_cast<SdrEditView*>(mpModel->GetListener(nView)); + SdrObjEditView* pView = dynamic_cast<SdrObjEditView*>(mpModel->GetListener(nView)); if (!pView) continue; if (pView->IsTextEdit()) - return false; + pView->SdrEndTextEdit(); } - - return true; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx index 47e05a0ad5e4..44c4b2fe5201 100644 --- a/svx/source/svdraw/svdedtv1.cxx +++ b/svx/source/svdraw/svdedtv1.cxx @@ -88,9 +88,12 @@ void SdrEditView::SetMarkedObjRect(const tools::Rectangle& rRect) long w1=rRect.Right()-x1; long h1=rRect.Bottom()-y1; - const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); + const bool bUndo = IsUndoEnabled(); if( bUndo ) + { + EndTextEditAllViews(); BegUndo(ImpGetDescriptionString(STR_EditPosSize)); + } for (size_t nm=0; nm<nCount; ++nm) { @@ -175,10 +178,11 @@ void SdrEditView::AddUndoActions( std::vector< std::unique_ptr<SdrUndoAction> > void SdrEditView::MoveMarkedObj(const Size& rSiz, bool bCopy) { - const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); + const bool bUndo = IsUndoEnabled(); if( bUndo ) { + EndTextEditAllViews(); OUString aStr(SvxResId(STR_EditMove)); if (bCopy) aStr += SvxResId(STR_EditWithCopy); @@ -208,9 +212,10 @@ void SdrEditView::MoveMarkedObj(const Size& rSiz, bool bCopy) void SdrEditView::ResizeMarkedObj(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bCopy) { - const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); + const bool bUndo = IsUndoEnabled(); if( bUndo ) { + EndTextEditAllViews(); OUString aStr {ImpGetDescriptionString(STR_EditResize)}; if (bCopy) aStr+=SvxResId(STR_EditWithCopy); @@ -242,9 +247,10 @@ void SdrEditView::ResizeMultMarkedObj(const Point& rRef, const bool bWdh, const bool bHgt) { - const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); + const bool bUndo = IsUndoEnabled(); if( bUndo ) { + EndTextEditAllViews(); BegUndo(ImpGetDescriptionString(STR_EditResize)); } @@ -302,9 +308,10 @@ long SdrEditView::GetMarkedObjRotate() const void SdrEditView::RotateMarkedObj(const Point& rRef, long nAngle, bool bCopy) { - const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); + const bool bUndo = IsUndoEnabled(); if( bUndo ) { + EndTextEditAllViews(); OUString aStr {ImpGetDescriptionString(STR_EditRotate)}; if (bCopy) aStr+=SvxResId(STR_EditWithCopy); BegUndo(aStr); @@ -357,10 +364,11 @@ void SdrEditView::RotateMarkedObj(const Point& rRef, long nAngle, bool bCopy) void SdrEditView::MirrorMarkedObj(const Point& rRef1, const Point& rRef2, bool bCopy) { - const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); + const bool bUndo = IsUndoEnabled(); if( bUndo ) { + EndTextEditAllViews(); OUString aStr; Point aDif(rRef2-rRef1); if (aDif.X()==0) @@ -456,10 +464,11 @@ long SdrEditView::GetMarkedObjShear() const void SdrEditView::ShearMarkedObj(const Point& rRef, long nAngle, bool bVShear, bool bCopy) { - const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); + const bool bUndo = IsUndoEnabled(); if( bUndo ) { + EndTextEditAllViews(); OUString aStr {ImpGetDescriptionString(STR_EditShear)}; if (bCopy) aStr+=SvxResId(STR_EditWithCopy); @@ -569,12 +578,13 @@ void SdrEditView::CrookMarkedObj(const Point& rRef, const Point& rRad, SdrCrookM bool bVertical, bool bNoContortion, bool bCopy) { tools::Rectangle aMarkRect(GetMarkedObjRect()); - const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); + const bool bUndo = IsUndoEnabled(); bool bRotate=bNoContortion && eMode==SdrCrookMode::Rotate && IsRotateAllowed(); if( bUndo ) { + EndTextEditAllViews(); OUString aStr {ImpGetDescriptionString(bNoContortion ? STR_EditCrook : STR_EditCrookContortion)}; if (bCopy) aStr+=SvxResId(STR_EditWithCopy); @@ -644,10 +654,11 @@ void SdrEditView::ImpDistortObj(SdrObject* pO, const tools::Rectangle& rRef, con void SdrEditView::DistortMarkedObj(const tools::Rectangle& rRef, const XPolygon& rDistortedRect, bool bNoContortion, bool bCopy) { - const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); + const bool bUndo = IsUndoEnabled(); if( bUndo ) { + EndTextEditAllViews(); OUString aStr {ImpGetDescriptionString(STR_EditDistort)}; if (bCopy) aStr+=SvxResId(STR_EditWithCopy); @@ -753,7 +764,9 @@ void SdrEditView::SetNotPersistAttrToMarked(const SfxItemSet& rAttr) ShearMarkedObj(aAllSnapRect.Center(),nAngle,true); } - const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + EndTextEditAllViews(); // TODO: check if WhichRange is necessary. const size_t nMarkCount=GetMarkedObjectCount(); @@ -1001,9 +1014,10 @@ void SdrEditView::SetAttrToMarked(const SfxItemSet& rAttr, bool bReplaceAll) nWhich = aIter.NextWhich(); } - const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); + const bool bUndo = IsUndoEnabled(); if( bUndo ) { + EndTextEditAllViews(); BegUndo(ImpGetDescriptionString(STR_EditSetAttributes)); } @@ -1179,10 +1193,11 @@ void SdrEditView::SetStyleSheetToMarked(SfxStyleSheet* pStyleSheet, bool bDontRe { if (AreObjectsMarked()) { - const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); + const bool bUndo = IsUndoEnabled(); if( bUndo ) { + EndTextEditAllViews(); OUString aStr; if (pStyleSheet!=nullptr) aStr = ImpGetDescriptionString(STR_EditSetStylesheet); @@ -1741,9 +1756,10 @@ void SdrEditView::AlignMarkedObjects(SdrHorAlign eHor, SdrVertAlign eVert) if (!GetMarkedObjectCount()) return; - const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); + const bool bUndo = IsUndoEnabled(); if( bUndo ) { + EndTextEditAllViews(); OUString aStr(GetDescriptionOfMarkedObjects()); if (eHor==SdrHorAlign::NONE) { diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index 5163f943e8bb..d37f7db235ee 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -1475,9 +1475,10 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(bool bDontDeleteReally) pTEOutliner->SetBeginPasteOrDropHdl(Link<PasteOrDropInfos*,void>()); pTEOutliner->SetEndPasteOrDropHdl(Link<PasteOrDropInfos*,void>()); - const bool bUndo = IsUndoEnabled() && CanDoSdrUndo(); + const bool bUndo = IsUndoEnabled(); if( bUndo ) { + EndTextEditAllViews(); OUString aObjName(pTEObj->TakeObjNameSingul()); BegUndo(SvxResId(STR_UndoObjSetText),aObjName); } |