1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 from uitest
.framework
import UITestCase
8 import org
.libreoffice
.unotest
11 from uitest
.uihelper
.common
import get_state_as_dict
12 from libreoffice
.calc
.document
import get_sheet_from_doc
13 from libreoffice
.calc
.conditional_format
import get_conditional_format_from_sheet
14 from uitest
.debug
import sleep
15 from libreoffice
.calc
.document
import get_cell_by_position
16 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
17 #Bug: Paste Special Link Checkbox fails to insert cell references when the source cell is blank
18 def get_url_for_data_file(file_name
):
19 return pathlib
.Path(org
.libreoffice
.unotest
.makeCopyFromTDOC(file_name
)).as_uri()
21 class tdf57274(UITestCase
):
23 def test_tdf57274_tdf116385_row_only(self
):
24 calc_doc
= self
.ui_test
.load_file(get_url_for_data_file("tdf57274.ods"))
25 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
26 gridwin
= xCalcDoc
.getChild("grid_window")
27 document
= self
.ui_test
.get_component()
29 #* Source Cells, range B6..E6
30 gridwin
.executeAction("SELECT", mkPropertyValues({"RANGE": "B6:E6"}))
31 self
.xUITest
.executeCommand(".uno:Copy")
32 gridwin
.executeAction("SELECT", mkPropertyValues({"CELL": "B11"}))
33 self
.ui_test
.execute_dialog_through_command(".uno:PasteSpecial")
34 xDialog
= self
.xUITest
.getTopFocusWindow()
35 #We paste here using Paste Special with 'Link' Checkbox activated
36 xLink
= xDialog
.getChild("link")
37 xLink
.executeAction("CLICK", tuple())
38 xOkBtn
= xDialog
.getChild("ok")
39 # self.ui_test.close_dialog_through_button(xOkBtn)
40 def handle_confirm_dlg(dialog
):
41 xOKBtn
= dialog
.getChild("yes")
42 self
.ui_test
.close_dialog_through_button(xOKBtn
)
44 self
.ui_test
.execute_blocking_action(xOkBtn
.executeAction
, args
=('CLICK', ()),
45 dialog_handler
=handle_confirm_dlg
)
46 #we would expect a reference to cell E6 here and a zero being displayed, but the cell is also simply blank.
47 self
.assertEqual(get_cell_by_position(document
, 0, 4, 10).getValue(), 0)
48 self
.assertEqual(get_cell_by_position(document
, 0, 4, 10).getFormula(), "=$Sheet1.$E$6")
49 self
.ui_test
.close_doc()
51 # vim: set shiftwidth=4 softtabstop=4 expandtab: