diff options
author | László Németh <nemeth@numbertext.org> | 2024-06-05 01:39:48 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2024-06-05 10:04:58 +0200 |
commit | 3e0650fb166cac116a43f6ce5d03bd69830e37b8 (patch) | |
tree | b1922d5980cf579d2360839dc4a53d891e3e0ef2 /sw/qa/extras/uiwriter/uiwriter6.cxx | |
parent | e03d54c2652049a1315fcddcb6a8e881a0ca65cb (diff) |
tdf#157533 sw: fix cursor position deselecting formula in table
Fix lost cursor by deselecting formula object anchored as
character as single content of table cells. In this case, the
cursor was positioned inside the frame of the formula,
disappeared in a flash.
Fix also bad cursor position by deselecting formula object
anchored as character at beginning of text lines in table
content.
Follow-up to commit 014e5f559a9acf319af24c721dbe6b0bc3bc5882
"tdf#161360 sw: fix cursor position deselecting image in table".
Change-Id: Ia1a96359f473071c4cead580322aa9c1af1d3f24
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168416
Reviewed-by: László Németh <nemeth@numbertext.org>
Tested-by: Jenkins
Diffstat (limited to 'sw/qa/extras/uiwriter/uiwriter6.cxx')
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter6.cxx | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx b/sw/qa/extras/uiwriter/uiwriter6.cxx index a9dc5530dab6..9cbe0a0311ec 100644 --- a/sw/qa/extras/uiwriter/uiwriter6.cxx +++ b/sw/qa/extras/uiwriter/uiwriter6.cxx @@ -41,6 +41,7 @@ #include <com/sun/star/text/XTextTable.hpp> #include <com/sun/star/text/XTextViewCursorSupplier.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> #include <o3tl/cppunittraitshelper.hxx> #include <swdtflvr.hxx> #include <comphelper/propertysequence.hxx> @@ -1745,6 +1746,61 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf161360) CPPUNIT_ASSERT_EQUAL(SelectionType::Text, eType2); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf157533) +{ + // load a table with objects positioned at beginning of text lines + createSwDoc("tdf157533.fodt"); + SwDoc* pDoc = getSwDoc(); + CPPUNIT_ASSERT(pDoc); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + CPPUNIT_ASSERT(pWrtShell); + auto pShell = pDoc->GetDocShell()->GetFEShell(); + CPPUNIT_ASSERT(pShell); + + auto xModel = mxComponent.queryThrow<frame::XModel>(); + uno::Reference<drawing::XShape> xShape(getShapeByName(u"Objet2")); + uno::Reference<view::XSelectionSupplier> xCtrl(xModel->getCurrentController(), uno::UNO_QUERY); + xCtrl->select(uno::Any(xShape)); + + dispatchCommand(mxComponent, ".uno:Escape", {}); + + // Then make sure that the cursor in the table: + SelectionType eType2 = pWrtShell->GetSelectionType(); + // This was false (only SelectionType::Text) + bool bCursorInTable = eType2 == (SelectionType::Text | SelectionType::Table); + CPPUNIT_ASSERT(bCursorInTable); + + SwTextNode* pTextNode = pWrtShell->GetCursor()->GetPointNode().GetTextNode(); + // This was false (not in the same paragraph and cell) + CPPUNIT_ASSERT(pTextNode->GetText().indexOf("and the second formula") > -1); + + uno::Reference<drawing::XShape> xShape2(getShapeByName(u"Objet11")); + xCtrl->select(uno::Any(xShape2)); + + dispatchCommand(mxComponent, ".uno:Escape", {}); + + SwTextNode* pTextNode2 = pWrtShell->GetCursor()->GetPointNode().GetTextNode(); + // This was false (lost text cursor inside the frame of the formula) + CPPUNIT_ASSERT(pTextNode2->GetTableBox()); + SwTableNode* pTableNode = pWrtShell->GetCursor()->GetPointNode().FindTableNode(); + SwTable& rTable = pTableNode->GetTable(); + // cursor in the same cell + bool bSameBox = pTextNode2->GetTableBox() == rTable.GetTableBox("A1"); + CPPUNIT_ASSERT(bSameBox); + + uno::Reference<drawing::XShape> xShape3(getShapeByName(u"Objet10")); + xCtrl->select(uno::Any(xShape3)); + + dispatchCommand(mxComponent, ".uno:Escape", {}); + + SwTextNode* pTextNode3 = pWrtShell->GetCursor()->GetPointNode().GetTextNode(); + // This was false (lost text cursor inside the frame of the formula) + CPPUNIT_ASSERT(pTextNode3->GetTableBox()); + // cursor in the same cell + bSameBox = pTextNode3->GetTableBox() == rTable.GetTableBox("B1"); + CPPUNIT_ASSERT(bSameBox); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf115132) { createSwDoc(); |