summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2021-03-25 17:21:35 +0100
committerJan Holesovsky <kendy@collabora.com>2021-03-29 14:43:49 +0200
commitec90261c6568476c0eb039d7f2e4af75a535baf2 (patch)
tree4243e1905c2616ef0ca84fade0a262d9fad6b98b /sd
parentf34eac66e64a416739c36aa996c90ea1869b9f0d (diff)
impress: don't exit textbox editing when new slide was added
When new slide is added by other user before currently visible slide then SwitchPage is called and textbox editing is ended. Avoid any focus change when setPart is called just for rendering or SwitchPage is used on previously avtive slide (only slide numer changed). Change-Id: I7fef42b863e0079acc84dadfc3f891548652b48f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113144 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx68
-rw-r--r--sd/source/ui/inc/DrawViewShell.hxx2
-rw-r--r--sd/source/ui/inc/unomodel.hxx2
-rw-r--r--sd/source/ui/unoidl/unomodel.cxx4
-rw-r--r--sd/source/ui/view/drviews1.cxx22
5 files changed, 88 insertions, 10 deletions
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 64e6196ae605..61940c1e8c2a 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -113,6 +113,7 @@ public:
void testCommentChangeImpress();
void testCommentChangeDraw();
void testMultiViewInsertDeletePage();
+ void testMultiViewInsertDeletePage2();
void testDisableUndoRepair();
void testDocumentRepair();
void testLanguageStatus();
@@ -165,6 +166,7 @@ public:
CPPUNIT_TEST(testCommentChangeImpress);
CPPUNIT_TEST(testCommentChangeDraw);
CPPUNIT_TEST(testMultiViewInsertDeletePage);
+ CPPUNIT_TEST(testMultiViewInsertDeletePage2);
CPPUNIT_TEST(testDisableUndoRepair);
CPPUNIT_TEST(testDocumentRepair);
CPPUNIT_TEST(testLanguageStatus);
@@ -1918,6 +1920,72 @@ void SdTiledRenderingTest::testMultiViewInsertDeletePage()
CPPUNIT_ASSERT_EQUAL(4, pXImpressDocument->getPart());
}
+void SdTiledRenderingTest::testMultiViewInsertDeletePage2()
+{
+ // Load the document.
+ SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
+ ViewCallback aView1;
+ int nView1 = SfxLokHelper::getView();
+ uno::Sequence<beans::PropertyValue> aArgs;
+ SdDrawDocument* pDoc = pXImpressDocument->GetDocShell()->GetDoc();
+
+ // Create second view
+ SfxLokHelper::createView();
+ pXImpressDocument->initializeForTiledRendering(aArgs);
+ ViewCallback aView2;
+ int nView2 = SfxLokHelper::getView();
+
+ // the document has 8 slides
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(8), pDoc->GetSdPageCount(PageKind::Standard));
+
+ // 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 slide in 1st view
+ SfxLokHelper::setView(nView1);
+ comphelper::dispatchCommand(".uno:InsertPage", aArgs);
+ Scheduler::ProcessEventsToIdle();
+
+ // See if the current slide number changed in 2nd view too
+ SfxLokHelper::setView(nView2);
+ CPPUNIT_ASSERT_EQUAL(5, pXImpressDocument->getPart());
+
+ // Delete the page in 1st view now
+ SfxLokHelper::setView(nView1);
+ comphelper::dispatchCommand(".uno:DeletePage", aArgs);
+ Scheduler::ProcessEventsToIdle();
+
+ // See if current slide number changed in 2nd view too
+ SfxLokHelper::setView(nView2);
+ CPPUNIT_ASSERT_EQUAL(4, pXImpressDocument->getPart());
+
+ // We must be still in text editing mode and have cursor visible.
+ CPPUNIT_ASSERT(pViewShell->GetView()->IsTextEdit());
+}
+
void SdTiledRenderingTest::testDisableUndoRepair()
{
// Load the document.
diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx
index cd283c76fa57..daa2c36478e2 100644
--- a/sd/source/ui/inc/DrawViewShell.hxx
+++ b/sd/source/ui/inc/DrawViewShell.hxx
@@ -244,7 +244,7 @@ public:
void ResetActualPage();
void ResetActualLayer();
- bool SwitchPage(sal_uInt16 nPage);
+ bool SwitchPage(sal_uInt16 nPage, bool bAllowChangeFocus = true);
bool IsSwitchPageAllowed() const;
/**
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index 08629b074b5b..60dfcb02f8d1 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -232,7 +232,7 @@ public:
long nTileWidth,
long nTileHeight ) override;
virtual Size getDocumentSize() override;
- virtual void setPart( int nPart ) override;
+ virtual void setPart( int nPart, bool bAllowChangeFocus = true ) override;
virtual int getPart() override;
virtual int getParts() override;
virtual OUString getPartName( int nPart ) override;
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 69c2a94dd946..21298e4da4af 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2283,13 +2283,13 @@ OUString SdXImpressDocument::getPartInfo(int nPart)
return aPartInfo;
}
-void SdXImpressDocument::setPart( int nPart )
+void SdXImpressDocument::setPart( int nPart, bool bAllowChangeFocus )
{
DrawViewShell* pViewSh = GetViewShell();
if (!pViewSh)
return;
- pViewSh->SwitchPage( nPart );
+ pViewSh->SwitchPage( nPart, bAllowChangeFocus );
}
int SdXImpressDocument::getParts()
diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx
index 3a370de8b33b..4a055184fb08 100644
--- a/sd/source/ui/view/drviews1.cxx
+++ b/sd/source/ui/view/drviews1.cxx
@@ -651,6 +651,7 @@ void DrawViewShell::ResetActualPage()
return;
sal_uInt16 nCurrentPageId = maTabControl->GetCurPageId();
+ sal_uInt16 nNewPageId = nCurrentPageId;
sal_uInt16 nCurrentPageNum = maTabControl->GetPagePos(nCurrentPageId);
sal_uInt16 nPageCount = (meEditMode == EditMode::Page)?GetDoc()->GetSdPageCount(mePageKind):GetDoc()->GetMasterSdPageCount(mePageKind);
@@ -677,7 +678,8 @@ void DrawViewShell::ResetActualPage()
GetDoc()->SetSelected(pPage, false);
}
- maTabControl->SetCurPageId(maTabControl->GetPageId(nCurrentPageNum));
+ nNewPageId = maTabControl->GetPageId(nCurrentPageNum);
+ maTabControl->SetCurPageId(nNewPageId);
}
else // EditMode::MasterPage
{
@@ -697,12 +699,16 @@ void DrawViewShell::ResetActualPage()
nCurrentPageNum = i;
}
- maTabControl->SetCurPageId(maTabControl->GetPageId(nCurrentPageNum));
+ nNewPageId = maTabControl->GetPageId(nCurrentPageNum);
+ maTabControl->SetCurPageId(nNewPageId);
SwitchPage(nCurrentPageNum);
}
- GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHPAGE,
- SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
+ if (nNewPageId != nCurrentPageId)
+ GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHPAGE,
+ SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
+ else
+ SwitchPage(nCurrentPageNum, false);
}
/**
@@ -817,8 +823,11 @@ bool DrawViewShell::IsVisible(sal_uInt16 nPage)
/**
* Switch to desired page.
* nSelectPage refers to the current EditMode
+ * bAllowChangeFocus set to false when slide is inserted before current page
+ * and we need to only update the current page number,
+ * do not disturb editing in that case
*/
-bool DrawViewShell::SwitchPage(sal_uInt16 nSelectedPage)
+bool DrawViewShell::SwitchPage(sal_uInt16 nSelectedPage, bool bAllowChangeFocus)
{
/** Under some circumstances there are nested calls to SwitchPage() and
may crash the application (activation of form controls when the
@@ -922,7 +931,8 @@ bool DrawViewShell::SwitchPage(sal_uInt16 nSelectedPage)
}
}
- mpDrawView->SdrEndTextEdit();
+ if (bAllowChangeFocus)
+ mpDrawView->SdrEndTextEdit();
mpActualPage = nullptr;