4 from org
.libreoffice
.unotest
import pyuno
, mkPropertyValue
, makeCopyFromTDOC
7 class InsertRemoveCells(unittest
.TestCase
):
11 cls
.xContext
= pyuno
.getComponentContext()
12 pyuno
.private_initTestEnvironment()
14 def test_fdo74824_load(self
):
18 smgr
= ctxt
.ServiceManager
19 desktop
= smgr
.createInstanceWithContext('com.sun.star.frame.Desktop', ctxt
)
20 load_props
= tuple(mkPropertyValue(k
, v
) for (k
, v
) in (
24 tdoc_path
= makeCopyFromTDOC('fdo74824.ods')
25 url
= pathlib
.Path(tdoc_path
).as_uri()
26 doc
= desktop
.loadComponentFromURL(url
, "_blank", 0, load_props
)
28 sheet
= doc
.Sheets
.Sheet1
29 area
= sheet
.getCellRangeByName('A2:B4')
30 addr
= area
.getRangeAddress()
32 # 2 = intended to shift cells right, but I don't know where to find
33 # the ENUM to put in its place. Corrections welcome.
34 sheet
.insertCells(addr
, 2)
36 # basically, the insertCells call is the test: it should not crash
37 # LibreOffice. However, for completeness, we should test the cell
41 (0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3),
42 (3, 1), (4, 0), (4, 2), (5, 0), (5, 2), (5, 3),
45 (2, 0, '=(1+GDR)^-D1', '1.000', 1.0),
46 (4, 1, '=(1+GDR)^-F2', '0.125', 0.125),
47 (4, 3, '=SUM(C1:C2)', '1.000', 1.0),
50 (2, 2, '2010', 2010.0),
53 (3, 2, '2012', 2012.0),
57 for col
, row
in empty_cells
:
59 self
.assertEqual('EMPTY', cell
.Type
.value
)
61 for col
, row
, f
, s
, val
in formula_cells
:
63 self
.assertEqual('FORMULA', cell
.Type
.value
)
64 self
.assertEqual(f
, cell
.getFormula())
65 self
.assertEqual(s
, cell
.String
)
66 self
.assertEqual(val
, cell
.Value
)
68 for col
, row
, s
, val
in value_cells
:
70 self
.assertEqual(s
, cell
.String
)
71 self
.assertEqual(val
, cell
.Value
)
76 if __name__
== '__main__':