Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / pasteSpecial / tdf57274.py
blob977c063938364129369de2b0d192000c899bc586
1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 from uitest.framework import UITestCase
10 from uitest.uihelper.common import get_url_for_data_file
11 from libreoffice.calc.document import get_cell_by_position
12 from libreoffice.uno.propertyvalue import mkPropertyValues
13 from libreoffice.calc.paste_special import reset_default_values
15 #Bug: Paste Special Link Checkbox fails to insert cell references when the source cell is blank
17 class tdf57274(UITestCase):
19 def test_tdf57274_tdf116385_row_only(self):
20 with self.ui_test.load_file(get_url_for_data_file("tdf57274.ods")) as calc_doc:
21 xCalcDoc = self.xUITest.getTopFocusWindow()
22 gridwin = xCalcDoc.getChild("grid_window")
24 #* Source Cells, range B6..E6
25 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B6:E6"}))
26 self.xUITest.executeCommand(".uno:Copy")
27 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B11"}))
28 with self.ui_test.execute_dialog_through_command(".uno:PasteSpecial", close_button="") as xDialog:
29 reset_default_values(self, xDialog)
30 #We paste here using Paste Special with 'Link' Checkbox activated
31 xLink = xDialog.getChild("link")
32 xLink.executeAction("CLICK", tuple())
34 xOkBtn = xDialog.getChild("ok")
35 with self.ui_test.execute_blocking_action(xOkBtn.executeAction, args=('CLICK', ()), close_button="yes"):
36 pass
38 #we would expect a reference to cell E6 here and a zero being displayed, but the cell is also simply blank.
39 self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 10).getValue(), 0)
40 self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 10).getFormula(), "=$Sheet1.$E$6")
42 # vim: set shiftwidth=4 softtabstop=4 expandtab: