summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2019-07-02 00:01:01 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-07-15 09:13:07 +0200
commitf160dbfc92b89aff5afc4c87692e52bd50e3f09e (patch)
tree52814c1fac7dee2c7885919ba2c6043d2af72664
parent7ccc93d947ba3333cba6d99a03ed2d0c27b1983a (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> (cherry picked from commit e6c7a018a0cfee395ce2886d41c908a2447ef5cc) Reviewed-on: https://gerrit.libreoffice.org/75027 Reviewed-by: Xisco FaulĂ­ <xiscofauli@libreoffice.org> (cherry picked from commit 1aa93766ee3994af9975e96e8ea60e02078de2d8) Reviewed-on: https://gerrit.libreoffice.org/75031
-rw-r--r--include/svx/svdedtv.hxx5
-rw-r--r--sd/source/ui/slidesorter/controller/SlsSlotManager.cxx2
-rw-r--r--svx/source/svdraw/svddrgmt.cxx3
-rw-r--r--svx/source/svdraw/svdedtv.cxx13
-rw-r--r--svx/source/svdraw/svdedtv1.cxx42
-rw-r--r--svx/source/svdraw/svdedxv.cxx3
6 files changed, 44 insertions, 24 deletions
diff --git a/include/svx/svdedtv.hxx b/include/svx/svdedtv.hxx
index 17fc9af93c76..941aef9ae81c 100644
--- a/include/svx/svdedtv.hxx
+++ b/include/svx/svdedtv.hxx
@@ -187,10 +187,9 @@ public:
bool IsUndoEnabled() const;
/**
- * Checks if this or other views have an active text edit, in which case object undos are not
- * created.
+ * Checks if this or other views have an active text edit, if true, end them.
*/
- bool CanDoSdrUndo() const;
+ void EndTextEditAllViews() const;
std::vector< std::unique_ptr<SdrUndoAction> > CreateConnectorUndo( SdrObject& rO );
void AddUndoActions( std::vector< std::unique_ptr<SdrUndoAction> > );
diff --git a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx
index 0a8f11f58271..1dcf5fc6bdcd 100644
--- a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx
@@ -234,6 +234,7 @@ void SlotManager::FuTemporary (SfxRequest& rRequest)
// (DEL -> accelerator -> SID_CUT).
if (mrSlideSorter.GetModel().GetPageCount() > 1)
{
+ mrSlideSorter.GetView().EndTextEditAllViews();
mrSlideSorter.GetController().GetSelectionManager()->DeleteSelectedPages();
}
@@ -371,6 +372,7 @@ void SlotManager::FuSupport (SfxRequest& rRequest)
case SID_CUT:
case SID_COPY:
case SID_DELETE:
+ mrSlideSorter.GetView().EndTextEditAllViews();
mrSlideSorter.GetController().GetClipboard().HandleSlotCall(rRequest);
break;
diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx
index affd94e14bb6..d6d9a8db0668 100644
--- a/svx/source/svdraw/svddrgmt.cxx
+++ b/svx/source/svdraw/svddrgmt.cxx
@@ -1323,10 +1323,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 e42e90fcedeb..dc84c10bfdc6 100644
--- a/svx/source/svdraw/svdedtv.cxx
+++ b/svx/source/svdraw/svdedtv.cxx
@@ -977,8 +977,11 @@ bool SdrEditView::InsertObjectAtView(SdrObject* pObj, SdrPageView& rPV, SdrInser
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();
@@ -1033,20 +1036,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 43f72e63369f..61322578b444 100644
--- a/svx/source/svdraw/svdedtv1.cxx
+++ b/svx/source/svdraw/svdedtv1.cxx
@@ -85,9 +85,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)
{
@@ -172,10 +175,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);
@@ -205,9 +209,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);
@@ -239,9 +244,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));
}
@@ -299,9 +305,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);
@@ -354,10 +361,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)
@@ -453,10 +461,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);
@@ -566,12 +575,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);
@@ -641,10 +651,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);
@@ -750,7 +761,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();
@@ -998,9 +1011,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));
}
@@ -1176,10 +1190,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);
@@ -1729,9 +1744,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 2af15dba79a3..c7f8b58e2fdf 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -1454,9 +1454,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);
}