Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / pasteSpecial / tdf62267.py
blob608875db49e2822c5f6580c2f38f5b219526e060
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_state_as_dict, get_url_for_data_file
11 from libreoffice.uno.propertyvalue import mkPropertyValues
12 from libreoffice.calc.paste_special import reset_default_values
14 #Bug 62267 - Conditional formatting lost after paste special of text, numbers and dates.
15 #If you have a cell with conditional formatting and you use paste special only inserting only text,
16 #numbers and dates the formatting is lost. Undo do not recover the conditional formatting.
18 class tdf62267(UITestCase):
20 def test_tdf62267(self):
21 with self.ui_test.load_file(get_url_for_data_file("tdf62267.ods")):
22 xCalcDoc = self.xUITest.getTopFocusWindow()
23 gridwin = xCalcDoc.getChild("grid_window")
25 #* Copy A1, then paste special to C1;
26 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
27 self.xUITest.executeCommand(".uno:Copy")
28 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"}))
29 with self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") as xDialog:
30 reset_default_values(self, xDialog)
31 pass
33 #--> Cell formatting should stay as before
34 with self.ui_test.execute_dialog_through_command(".uno:ConditionalFormatManagerDialog", close_button="cancel") as xCondFormatMgr:
37 # check that we have exactly 1 conditional format
38 xList = xCondFormatMgr.getChild("CONTAINER")
39 list_state = get_state_as_dict(xList)
40 self.assertEqual(list_state['Children'], '1')
42 xTreeEntry = xList.getChild('0')
43 self.assertEqual(get_state_as_dict(xTreeEntry)["Text"], "A1\tCell value = 1")
46 # vim: set shiftwidth=4 softtabstop=4 expandtab: