sc/qa/unit/uicalc/uicalc.cxx   |   39 +++++++++++++++++++++++++++++++++++++++
 sc/source/ui/inc/tabvwsh.hxx   |    1 +
 sc/source/ui/view/tabvwsha.cxx |    8 ++++++++
 3 files changed, 48 insertions(+)

New commits:
commit cdca06306e0d4ae2d9874bc7bbd0290d100d54cc
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Tue Jul 18 15:21:02 2023 -0400
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Tue Aug 8 16:44:39 2023 +0200

    tdf#155799: sc: qa: add unit test "testKeyboardMergeRef"
    
    Signed-off-by: Henry Castro <hcas...@collabora.com>
    Change-Id: I4d80ad5d9e5fe2c131f9397ec59c6c16ef92c094
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154601
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 9a795f4a5bde..2d1378c92c30 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -2060,6 +2060,45 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf141440)
     CPPUNIT_ASSERT_EQUAL(OUString("Note in A1"), pDoc->GetNote(ScAddress(0, 0, 
0))->GetText());
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testKeyboardMergeRef)
+{
+    createScDoc();
+    ScDocShell* pDocSh = getScDocShell();
+    ScModelObj* pModelObj = 
comphelper::getFromUnoTunnel<ScModelObj>(mxComponent);
+    ScTabViewShell* pViewShell = pDocSh->GetBestViewShell(false);
+    CPPUNIT_ASSERT(pViewShell);
+
+    goToCell("A1:A5");
+    dispatchCommand(mxComponent, ".uno:ToggleMergeCells", {});
+    goToCell("A6:A10");
+    dispatchCommand(mxComponent, ".uno:ToggleMergeCells", {});
+
+    goToCell("B1");
+    typeString(u"=");
+
+    goToCell("A1");
+
+    pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_DOWN | KEY_SHIFT);
+    pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_DOWN | KEY_SHIFT);
+    Scheduler::ProcessEventsToIdle();
+    CPPUNIT_ASSERT(pViewShell->IsRefInputMode());
+    {
+        const OUString* pInput = pViewShell->GetEditString();
+        CPPUNIT_ASSERT(pInput);
+        CPPUNIT_ASSERT_EQUAL(OUString("=A1:A10"), *pInput);
+    }
+
+    pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_UP | KEY_SHIFT);
+    pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_UP | KEY_SHIFT);
+    Scheduler::ProcessEventsToIdle();
+    CPPUNIT_ASSERT(pViewShell->IsRefInputMode());
+    {
+        const OUString* pInput = pViewShell->GetEditString();
+        CPPUNIT_ASSERT(pInput);
+        CPPUNIT_ASSERT_EQUAL(OUString("=A1:A5"), *pInput);
+    }
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 3273d44baaf0679a19527e953809b9d61d8e2201
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Tue Jul 18 15:18:41 2023 -0400
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Tue Aug 8 16:44:31 2023 +0200

    tdf#155799: sc: add getter function "GetEditString"
    
    Useful for QA test queries.
    ..
    
    Signed-off-by: Henry Castro <hcas...@collabora.com>
    Change-Id: Ibd3c902405f478032447b10286a788cd0769c855
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154600
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index 06e9f31e19cb..3c80dbc1995d 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -236,6 +236,7 @@ public:
 
     const ScInputHandler* GetInputHandler() const { return 
mpInputHandler.get(); }
     ScInputHandler* GetInputHandler() { return mpInputHandler.get(); }
+    const OUString* GetEditString() const;
     void            UpdateInputHandler( bool bForce = false, bool bStopEditing 
= true );
     void            UpdateInputHandlerCellAdjust( SvxCellHorJustify eJust );
     bool            TabKeyInput(const KeyEvent& rKEvt);
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index c07a070e08ef..dd73c21a5076 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -631,6 +631,14 @@ void ScTabViewShell::ExecuteCellFormatDlg(SfxRequest& 
rReq, const OUString &rNam
     });
 }
 
+const OUString* ScTabViewShell::GetEditString() const
+{
+    if (mpInputHandler)
+        return &mpInputHandler->GetEditString();
+
+    return nullptr;
+}
+
 bool ScTabViewShell::IsRefInputMode() const
 {
     ScModule* pScMod = SC_MOD();

Reply via email to