summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-10-07 16:48:46 +0200
committerTomaž Vajngerl <quikee@gmail.com>2021-10-22 22:02:00 +0200
commit2d95b3846eac367d2baadc194ab258dc31e7bd33 (patch)
tree18438367545335e3a284dfdf30eab840e9a28e51 /svx
parent1042ffc16be570f42abc4d68dcb2f6deeb290f52 (diff)
svx: Don't end text edit mode for all views
This allows multiple views to not disturb each other editing inside a impress document. With the ending of text edit for all views still enabled, one view can cancel other views text editing just by moving or resizing a unrelated shape in the document. To make this possible we also need a view-local undo manager for the text edit mode, which is independent of the document undo manager. When the text edit mode ends, all the changes will be added as one change to the document undo stack. This prevents any conflicts in the undo stack that could be made when 2 views are editing the same document at the same time. This also adds the test for the new use case and changes the existing tests to reflect the change. Change-Id: I04edb4f91d7e111a490c946f7121cbca75f818d7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123220 Tested-by: Tomaž Vajngerl <quikee@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit c175c1dc19d0edc8ca66e39f0b4b8af04e3d6c87) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123951
Diffstat (limited to 'svx')
-rw-r--r--svx/source/svdraw/svddrgmt.cxx2
-rw-r--r--svx/source/svdraw/svdedtv.cxx12
-rw-r--r--svx/source/svdraw/svdedtv1.cxx24
-rw-r--r--svx/source/svdraw/svdedxv.cxx17
4 files changed, 36 insertions, 19 deletions
diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx
index 6f6ac53a11fa..ee6dae66d985 100644
--- a/svx/source/svdraw/svddrgmt.cxx
+++ b/svx/source/svdraw/svddrgmt.cxx
@@ -1352,7 +1352,7 @@ bool SdrDragObjOwn::EndSdrDrag(bool /*bCopy*/)
if( bUndo )
{
- getSdrDragView().EndTextEditAllViews();
+ getSdrDragView().EndTextEditCurrentView();
if(!getSdrDragView().IsInsObjPoint() && pObj->IsInserted() )
{
if (DragStat().IsEndDragChangesAttributes())
diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx
index 2fd71bee4092..6f2be8bf54f4 100644
--- a/svx/source/svdraw/svdedtv.cxx
+++ b/svx/source/svdraw/svdedtv.cxx
@@ -998,7 +998,7 @@ bool SdrEditView::InsertObjectAtView(SdrObject* pObj, SdrPageView& rPV, SdrInser
}
if( IsUndoEnabled())
{
- EndTextEditAllViews();
+ EndTextEditCurrentView();
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj));
}
@@ -1069,4 +1069,14 @@ void SdrEditView::EndTextEditAllViews() const
}
}
+void SdrEditView::EndTextEditCurrentView()
+{
+ if (IsTextEdit())
+ {
+ SdrView* pSdrView = dynamic_cast<SdrView*>(this);
+ if (pSdrView)
+ pSdrView->SdrEndTextEdit();
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx
index 50a903b0a4b5..d785af007144 100644
--- a/svx/source/svdraw/svdedtv1.cxx
+++ b/svx/source/svdraw/svdedtv1.cxx
@@ -94,7 +94,7 @@ void SdrEditView::SetMarkedObjRect(const tools::Rectangle& rRect)
const bool bUndo = IsUndoEnabled();
if( bUndo )
{
- EndTextEditAllViews();
+ EndTextEditCurrentView();
BegUndo(ImpGetDescriptionString(STR_EditPosSize));
}
@@ -185,7 +185,7 @@ void SdrEditView::MoveMarkedObj(const Size& rSiz, bool bCopy)
if( bUndo )
{
- EndTextEditAllViews();
+ EndTextEditCurrentView();
OUString aStr(SvxResId(STR_EditMove));
if (bCopy)
aStr += SvxResId(STR_EditWithCopy);
@@ -218,7 +218,7 @@ void SdrEditView::ResizeMarkedObj(const Point& rRef, const Fraction& xFact, cons
const bool bUndo = IsUndoEnabled();
if( bUndo )
{
- EndTextEditAllViews();
+ EndTextEditCurrentView();
OUString aStr {ImpGetDescriptionString(STR_EditResize)};
if (bCopy)
aStr+=SvxResId(STR_EditWithCopy);
@@ -253,7 +253,7 @@ void SdrEditView::ResizeMultMarkedObj(const Point& rRef,
const bool bUndo = IsUndoEnabled();
if( bUndo )
{
- EndTextEditAllViews();
+ EndTextEditCurrentView();
BegUndo(ImpGetDescriptionString(STR_EditResize));
}
@@ -300,7 +300,7 @@ void SdrEditView::RotateMarkedObj(const Point& rRef, tools::Long nAngle, bool bC
const bool bUndo = IsUndoEnabled();
if( bUndo )
{
- EndTextEditAllViews();
+ EndTextEditCurrentView();
OUString aStr {ImpGetDescriptionString(STR_EditRotate)};
if (bCopy) aStr+=SvxResId(STR_EditWithCopy);
BegUndo(aStr);
@@ -357,7 +357,7 @@ void SdrEditView::MirrorMarkedObj(const Point& rRef1, const Point& rRef2, bool b
if( bUndo )
{
- EndTextEditAllViews();
+ EndTextEditCurrentView();
OUString aStr;
Point aDif(rRef2-rRef1);
if (aDif.X()==0)
@@ -457,7 +457,7 @@ void SdrEditView::ShearMarkedObj(const Point& rRef, tools::Long nAngle, bool bVS
if( bUndo )
{
- EndTextEditAllViews();
+ EndTextEditCurrentView();
OUString aStr {ImpGetDescriptionString(STR_EditShear)};
if (bCopy)
aStr+=SvxResId(STR_EditWithCopy);
@@ -573,7 +573,7 @@ void SdrEditView::CrookMarkedObj(const Point& rRef, const Point& rRad, SdrCrookM
if( bUndo )
{
- EndTextEditAllViews();
+ EndTextEditCurrentView();
OUString aStr {ImpGetDescriptionString(bNoContortion ? STR_EditCrook : STR_EditCrookContortion)};
if (bCopy)
aStr+=SvxResId(STR_EditWithCopy);
@@ -647,7 +647,7 @@ void SdrEditView::DistortMarkedObj(const tools::Rectangle& rRef, const XPolygon&
if( bUndo )
{
- EndTextEditAllViews();
+ EndTextEditCurrentView();
OUString aStr {ImpGetDescriptionString(STR_EditDistort)};
if (bCopy)
aStr+=SvxResId(STR_EditWithCopy);
@@ -1097,7 +1097,7 @@ void SdrEditView::SetAttrToMarked(const SfxItemSet& rAttr, bool bReplaceAll)
const bool bUndo = IsUndoEnabled();
if( bUndo )
{
- EndTextEditAllViews();
+ EndTextEditCurrentView();
BegUndo(ImpGetDescriptionString(STR_EditSetAttributes));
}
@@ -1276,7 +1276,7 @@ void SdrEditView::SetStyleSheetToMarked(SfxStyleSheet* pStyleSheet, bool bDontRe
if( bUndo )
{
- EndTextEditAllViews();
+ EndTextEditCurrentView();
OUString aStr;
if (pStyleSheet!=nullptr)
aStr = ImpGetDescriptionString(STR_EditSetStylesheet);
@@ -1843,7 +1843,7 @@ void SdrEditView::AlignMarkedObjects(SdrHorAlign eHor, SdrVertAlign eVert)
const bool bUndo = IsUndoEnabled();
if( bUndo )
{
- EndTextEditAllViews();
+ EndTextEditCurrentView();
OUString aStr(GetDescriptionOfMarkedObjects());
if (eHor==SdrHorAlign::NONE)
{
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 65aadab57145..a4d43f97b8c6 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -1057,10 +1057,11 @@ IMPL_LINK(SdrObjEditView, ImpOutlinerCalcFieldValueHdl, EditFieldInfo*, pFI, voi
IMPL_LINK_NOARG(SdrObjEditView, EndTextEditHdl, SdrUndoManager*, void) { SdrEndTextEdit(); }
-SdrUndoManager* SdrObjEditView::getSdrUndoManagerForEnhancedTextEdit() const
+// Default implementation - null UndoManager
+std::unique_ptr<SdrUndoManager> SdrObjEditView::createLocalTextUndoManager()
{
- // default returns registered UndoManager
- return GetModel() ? dynamic_cast<SdrUndoManager*>(GetModel()->GetSdrUndoManager()) : nullptr;
+ SAL_WARN("svx", "SdrObjEditView::createLocalTextUndoManager needs to be overridden");
+ return std::unique_ptr<SdrUndoManager>();
}
bool SdrObjEditView::SdrBeginTextEdit(SdrObject* pObj_, SdrPageView* pPV, vcl::Window* pWin,
@@ -1357,7 +1358,11 @@ bool SdrObjEditView::SdrBeginTextEdit(SdrObject* pObj_, SdrPageView* pPV, vcl::W
if (GetModel() && IsUndoEnabled()
&& !GetModel()->GetDisableTextEditUsesCommonUndoManager())
{
- SdrUndoManager* pSdrUndoManager = getSdrUndoManagerForEnhancedTextEdit();
+ SdrUndoManager* pSdrUndoManager = nullptr;
+ mpLocalTextEditUndoManager = createLocalTextUndoManager();
+
+ if (mpLocalTextEditUndoManager)
+ pSdrUndoManager = mpLocalTextEditUndoManager.get();
if (pSdrUndoManager)
{
@@ -1431,7 +1436,7 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(bool bDontDeleteReally)
if (pOriginal)
{
// check if we got back our document undo manager
- SdrUndoManager* pSdrUndoManager = getSdrUndoManagerForEnhancedTextEdit();
+ SdrUndoManager* pSdrUndoManager = mpLocalTextEditUndoManager.get();
if (pSdrUndoManager && dynamic_cast<SdrUndoManager*>(pOriginal) == pSdrUndoManager)
{
@@ -1464,6 +1469,8 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(bool bDontDeleteReally)
"expected document UndoManager (!)");
delete pOriginal;
}
+
+ mpLocalTextEditUndoManager.reset();
}
}
else