summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/svx/svdedtv.hxx6
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx51
-rw-r--r--svx/source/svdraw/svdedtv.cxx21
3 files changed, 74 insertions, 4 deletions
diff --git a/include/svx/svdedtv.hxx b/include/svx/svdedtv.hxx
index 4351ccee2764..51da6124ed88 100644
--- a/include/svx/svdedtv.hxx
+++ b/include/svx/svdedtv.hxx
@@ -186,6 +186,12 @@ public:
bool IsUndoEnabled() const;
/**
+ * Checks if this or other views have an active text edit, in which case object undos are not
+ * created.
+ */
+ bool CanDoSdrUndo() const;
+
+ /**
* Checks if this or other views have an active text edit, if true, end them.
*/
void EndTextEditAllViews() const;
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 61940c1e8c2a..161aed640277 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -114,6 +114,7 @@ public:
void testCommentChangeDraw();
void testMultiViewInsertDeletePage();
void testMultiViewInsertDeletePage2();
+ void testEditingTextBoxAndInsertShapeInterrupt();
void testDisableUndoRepair();
void testDocumentRepair();
void testLanguageStatus();
@@ -167,6 +168,7 @@ public:
CPPUNIT_TEST(testCommentChangeDraw);
CPPUNIT_TEST(testMultiViewInsertDeletePage);
CPPUNIT_TEST(testMultiViewInsertDeletePage2);
+ CPPUNIT_TEST(testEditingTextBoxAndInsertShapeInterrupt);
CPPUNIT_TEST(testDisableUndoRepair);
CPPUNIT_TEST(testDocumentRepair);
CPPUNIT_TEST(testLanguageStatus);
@@ -1986,6 +1988,55 @@ void SdTiledRenderingTest::testMultiViewInsertDeletePage2()
CPPUNIT_ASSERT(pViewShell->GetView()->IsTextEdit());
}
+void SdTiledRenderingTest::testEditingTextBoxAndInsertShapeInterrupt()
+{
+ // Load the document.
+ SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
+ ViewCallback aView1;
+ int nView1 = SfxLokHelper::getView();
+ uno::Sequence<beans::PropertyValue> aArgs;
+
+ // Create second view
+ SfxLokHelper::createView();
+ pXImpressDocument->initializeForTiledRendering(aArgs);
+ ViewCallback aView2;
+ int nView2 = SfxLokHelper::getView();
+
+ // Switch to 5th page in 2nd view
+ pXImpressDocument->setPart(4);
+
+ // Begin text edit on the only object on the slide.
+ sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+ SdPage* pActualPage = pViewShell->GetActualPage();
+ SdrObject* pObject1 = pActualPage->GetObj(0);
+ CPPUNIT_ASSERT(pObject1 != nullptr);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(OBJ_TITLETEXT), pObject1->GetObjIdentifier());
+ SdrTextObj* pTextObject = static_cast<SdrTextObj*>(pObject1);
+
+ // Double-click outside the text to enter edit mode.
+ const ::tools::Rectangle aRect = pTextObject->GetCurrentBoundRect();
+ const auto cornerX = convertMm100ToTwip(aRect.getX() + (aRect.getWidth() / 4));
+ const auto cornerY = convertMm100ToTwip(aRect.getY() + (aRect.getHeight() / 4));
+ pXImpressDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
+ cornerX, cornerY,
+ 2, MOUSE_LEFT, 0);
+ pXImpressDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP,
+ cornerX, cornerY,
+ 2, MOUSE_LEFT, 0);
+ Scheduler::ProcessEventsToIdle();
+
+ // We must be in text editing mode and have cursor visible.
+ CPPUNIT_ASSERT(pViewShell->GetView()->IsTextEdit());
+
+ // Insert shape in 1st view
+ SfxLokHelper::setView(nView1);
+ comphelper::dispatchCommand(".uno:BasicShapes.rectangle", aArgs);
+
+ // We must be still in text editing mode and have cursor visible.
+ SfxLokHelper::setView(nView2);
+ CPPUNIT_ASSERT(pViewShell->GetView()->IsTextEdit());
+}
+
void SdTiledRenderingTest::testDisableUndoRepair()
{
// Load the document.
diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx
index b301d19312d2..b48174ad8b57 100644
--- a/svx/source/svdraw/svdedtv.cxx
+++ b/svx/source/svdraw/svdedtv.cxx
@@ -973,11 +973,8 @@ bool SdrEditView::InsertObjectAtView(SdrObject* pObj, SdrPageView& rPV, SdrInser
if (!pObj->IsInserted()) {
rPV.GetObjList()->InsertObject(pObj, SAL_MAX_SIZE);
}
- if( IsUndoEnabled())
- {
- EndTextEditAllViews();
+ if( IsUndoEnabled() && CanDoSdrUndo())
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj));
- }
if (!(nOptions & SdrInsertFlags::DONTMARK)) {
if (!(nOptions & SdrInsertFlags::ADDMARK)) UnmarkAllObj();
@@ -1032,6 +1029,22 @@ bool SdrEditView::IsUndoEnabled() const
return mpModel->IsUndoEnabled();
}
+bool SdrEditView::CanDoSdrUndo() const
+{
+ size_t nViews = mpModel->GetListenerCount();
+ for (size_t nView = 0; nView < nViews; ++nView)
+ {
+ SdrEditView* pView = dynamic_cast<SdrEditView*>(mpModel->GetListener(nView));
+ if (!pView)
+ continue;
+
+ if (pView->IsTextEdit())
+ return false;
+ }
+
+ return true;
+}
+
void SdrEditView::EndTextEditAllViews() const
{
size_t nViews = mpModel->GetListenerCount();