diff options
author | Baole Fang <baole.fang@gmail.com> | 2023-05-28 10:28:24 -0400 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-06-02 20:02:39 +0200 |
commit | 0450c7177f61ba5be15f7b4175b9fb5e89f850ae (patch) | |
tree | cdc4743400bd5e23a61095bb4a19fab6acf05297 | |
parent | 17339a6e1f090972781af94e96f6a39408e49c88 (diff) |
tdf#132026: Fix selection in text cell
Change-Id: Ic2bf869efa198cba83d1b781b419c3a9e0e606f3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152356
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | sc/qa/uitest/calc_tests8/tdf132026.py | 44 | ||||
-rw-r--r-- | sc/qa/uitest/data/tdf132026.ods | bin | 0 -> 10130 bytes | |||
-rw-r--r-- | sc/source/ui/view/tabvwsha.cxx | 12 |
3 files changed, 53 insertions, 3 deletions
diff --git a/sc/qa/uitest/calc_tests8/tdf132026.py b/sc/qa/uitest/calc_tests8/tdf132026.py new file mode 100644 index 000000000000..abd3a86e720b --- /dev/null +++ b/sc/qa/uitest/calc_tests8/tdf132026.py @@ -0,0 +1,44 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf132026(UITestCase): + + def test_tdf132026(self): + with self.ui_test.load_file(get_url_for_data_file("tdf132026.ods")) as calc_doc: + MainWindow = self.xUITest.getTopFocusWindow() + grid_window = MainWindow.getChild("grid_window") + + chars=["=","+","-"] + directions=["UP","DOWN","LEFT","RIGHT"] + + # format general, should select cell + for c in chars: + sign=-1 if c=="-" else 1 + for i,direction in enumerate(directions): + grid_window.executeAction("SELECT", mkPropertyValues({"CELL": "B2"})) + grid_window.executeAction("TYPE", mkPropertyValues({"TEXT": c})) + grid_window.executeAction("TYPE", mkPropertyValues({"KEYCODE": direction})) + grid_window.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 1).getString(), str(sign*(i+1))) + + # format text, shouldn't select cell + for c in chars: + for direction in directions: + grid_window.executeAction("SELECT", mkPropertyValues({"CELL": "E2"})) + grid_window.executeAction("TYPE", mkPropertyValues({"TEXT": c})) + grid_window.executeAction("TYPE", mkPropertyValues({"KEYCODE": direction})) + grid_window.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 1).getString(), c) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/data/tdf132026.ods b/sc/qa/uitest/data/tdf132026.ods Binary files differnew file mode 100644 index 000000000000..03c6c654fdc5 --- /dev/null +++ b/sc/qa/uitest/data/tdf132026.ods diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx index 4021f1937f91..f1305672a096 100644 --- a/sc/source/ui/view/tabvwsha.cxx +++ b/sc/source/ui/view/tabvwsha.cxx @@ -640,13 +640,19 @@ bool ScTabViewShell::IsRefInputMode() const ScInputHandler* pHdl = pScMod->GetInputHdl(); if ( pHdl ) { + const ScViewData& rViewData = GetViewData(); + ScDocument& rDoc = rViewData.GetDocument(); + const ScAddress aPos( rViewData.GetCurPos() ); + const sal_uInt32 nIndex = rDoc.GetAttr(aPos, ATTR_VALUE_FORMAT )->GetValue(); + const SvNumFormatType nType = rDoc.GetFormatTable()->GetType(nIndex); + if (nType == SvNumFormatType::TEXT) + { + return false; + } OUString aString = pHdl->GetEditString(); if ( !pHdl->GetSelIsRef() && aString.getLength() > 1 && ( aString[0] == '+' || aString[0] == '-' ) ) { - const ScViewData& rViewData = GetViewData(); - ScDocument& rDoc = rViewData.GetDocument(); - const ScAddress aPos( rViewData.GetCurPos() ); ScCompiler aComp( rDoc, aPos, rDoc.GetGrammar() ); aComp.SetCloseBrackets( false ); std::unique_ptr<ScTokenArray> pArr(aComp.CompileString(aString)); |