summaryrefslogtreecommitdiff
path: root/sw/qa/extras
diff options
context:
space:
mode:
authorJim Raykowski <raykowj@gmail.com>2024-04-14 14:49:48 -0800
committerJim Raykowski <raykowj@gmail.com>2024-04-20 18:14:00 +0200
commitca66965507494d0c5e07bfe81334749bc08af409 (patch)
tree20f61358b4a8b218af55fdb76b21eb497285b68d /sw/qa/extras
parent57f4581e326453ebed8fe688ade924804aae46dd (diff)
tdf#146190 Fix move to next drawing object using the tab key
after double click on a drawing obect in the Navigator doesn't move to the next/previous drawing object when there is a number rule at the current current cursor position and the current cursor position is at the start of a paragraph. This patch reworks the SwWrtShell::GotoDrawingObject function so the document cursor position gets moved to the position of the drawing object when the object is selected. Another way to get expected results is to leave the GotoDrawingObject function as is and move: else if (rSh.GetSelectionType() & (SelectionType::Graphic | SelectionType::Frame | SelectionType::Ole | SelectionType::DrawObject | SelectionType::DbForm)) above the: else if( rSh.GetNumRuleAtCurrCursorPos() && rSh.IsSttOfPara() && !rSh.HasReadonlySel() ) in the SwEditWin::KeyInput function case KEY_TAB: block. SwWrtShell::GotoDrawingObject is made SW_DLLPUBIC by this patch to able to be used by the included unit test. Change-Id: I047b416ae94a9284d304798924e0c5f2be526f85 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166089 Tested-by: Jenkins Reviewed-by: Jim Raykowski <raykowj@gmail.com>
Diffstat (limited to 'sw/qa/extras')
-rw-r--r--sw/qa/extras/uiwriter/data/tdf146190.odtbin0 -> 18070 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter9.cxx38
2 files changed, 38 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data/tdf146190.odt b/sw/qa/extras/uiwriter/data/tdf146190.odt
new file mode 100644
index 000000000000..b686cb174bc9
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf146190.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter9.cxx b/sw/qa/extras/uiwriter/uiwriter9.cxx
index f46d43e537b6..93d608a69247 100644
--- a/sw/qa/extras/uiwriter/uiwriter9.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter9.cxx
@@ -47,6 +47,9 @@
#include <fmtinfmt.hxx>
#include <rootfrm.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdmark.hxx>
+
namespace
{
class SwUiWriterTest9 : public SwModelTestBase
@@ -555,6 +558,41 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf158375_ole_object_disable)
comphelper::LibreOfficeKit::setActive(false);
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf146190)
+{
+ // Given a document with a number rule at the start of a paragraph and two drawing objects:
+ createSwDoc("tdf146190.odt");
+ SwXTextDocument* pXTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ SwDocShell* pDocShell = pXTextDocument->GetDocShell();
+ SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+
+ const SdrMarkList& rMrkList = pWrtShell->GetDrawView()->GetMarkedObjectList();
+
+ // Assert the current cursor position has a number rule and is at the start of a paragraph:
+ pWrtShell->SttEndDoc(/*bStt=*/true);
+ CPPUNIT_ASSERT(pWrtShell->GetNumRuleAtCurrCursorPos());
+ CPPUNIT_ASSERT(pWrtShell->IsSttOfPara());
+
+ // Then go to "Shape 1" drawing object using the GotoDrawingObject function:
+ pWrtShell->GotoDrawingObject(u"Shape 1");
+ CPPUNIT_ASSERT_EQUAL(OUString("Shape 1"), rMrkList.GetMark(0)->GetMarkedSdrObj()->GetName());
+
+ // Move to the next drawing object by Tab key press:
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB);
+ Scheduler::ProcessEventsToIdle();
+ // Without the fix in place, this test would have failed with:
+ // equality assertion failed
+ // - Expected: Shape 2
+ // - Actual : Shape 1
+ // i.e. Tab did not move to the next drawing object
+ CPPUNIT_ASSERT_EQUAL(OUString("Shape 2"), rMrkList.GetMark(0)->GetMarkedSdrObj()->GetName());
+
+ // Tab key press should now select 'Shape 1':
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB);
+ Scheduler::ProcessEventsToIdle();
+ CPPUNIT_ASSERT_EQUAL(OUString("Shape 1"), rMrkList.GetMark(0)->GetMarkedSdrObj()->GetName());
+}
+
} // end of anonymous namespace
CPPUNIT_PLUGIN_IMPLEMENT();