tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / pyuno / qa / pytests / insertremovecells.py
blob2583fdb134c12f314a3735398269ababc79281e4
1 import pathlib
2 import unittest
4 from org.libreoffice.unotest import pyuno, mkPropertyValue, makeCopyFromTDOC
7 class InsertRemoveCells(unittest.TestCase):
9 @classmethod
10 def setUpClass(cls):
11 cls.xContext = pyuno.getComponentContext()
12 pyuno.private_initTestEnvironment()
14 def test_fdo74824_load(self):
15 ctxt = self.xContext
16 assert(ctxt)
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 (
21 ('Hidden', True),
22 ('ReadOnly', False)
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
38 # contents as well.
40 empty_cells = (
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),
44 formula_cells = (
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),
49 value_cells = (
50 (2, 2, '2010', 2010.0),
51 (2, 3, '7', 7.0),
52 (3, 0, '0', 0),
53 (3, 2, '2012', 2012.0),
54 (3, 3, '6', 6.0),
55 (5, 1, '1', 1.0),
57 for col, row in empty_cells:
58 cell = sheet[row,col]
59 self.assertEqual('EMPTY', cell.Type.value)
61 for col, row, f, s, val in formula_cells:
62 cell = sheet[row,col]
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:
69 cell = sheet[row,col]
70 self.assertEqual(s, cell.String)
71 self.assertEqual(val, cell.Value)
73 doc.close(True)
76 if __name__ == '__main__':
77 unittest.main()