3 from os
import getenv
, path
6 from urllib
.parse
import quote
8 from urllib
import quote
10 from org
.libreoffice
.unotest
import pyuno
, mkPropertyValue
12 class InsertRemoveCells(unittest
.TestCase
):
16 cls
.xContext
= pyuno
.getComponentContext()
17 pyuno
.private_initTestEnvironment()
20 # no need for a tearDown(cls) method.
23 def test_fdo74824_load(self
):
27 smgr
= ctxt
.ServiceManager
28 desktop
= smgr
.createInstanceWithContext('com.sun.star.frame.Desktop', ctxt
)
29 loadProps
= tuple(mkPropertyValue(k
, v
) for (k
, v
) in (
33 tdoc_dir
= getenv('TDOC')
34 url
= 'file://' + quote(path
.join(tdoc_dir
, 'fdo74824.ods'))
35 doc
= desktop
.loadComponentFromURL(url
, "_blank", 0, loadProps
)
37 sheet
= doc
.Sheets
.Sheet1
38 area
= sheet
.getCellRangeByName( 'A2:B4' )
39 addr
= area
.getRangeAddress()
41 # 2 = intended to shift cells right, but I don't know where to find
42 # the ENUM to put in it's place. Corrections welcome.
43 sheet
.insertCells( addr
, 2 )
45 # basically, the insertCells call is the test: it should not crash
46 # LibreOffice. However, for completeness, we should test the cell
50 (0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3),
51 (3, 1), (4, 0), (4, 2), (5, 0), (5, 2), (5, 3),
54 (2, 0, '=(1+GDR)^-D1', '1.000', 1.0),
55 (4, 1, '=(1+GDR)^-F2', '0.125', 0.125),
56 (4, 3, '=SUM(C1:C2)', '1.000', 1.0),
59 (2, 2, '2010', 2010.0),
62 (3, 2, '2012', 2012.0),
66 for pos
in empty_cells
:
67 cell
= sheet
.getCellByPosition(*pos
)
68 self
.assertEqual( 'EMPTY', cell
.Type
.value
)
69 for x
, y
, f
, s
, val
in formula_cells
:
70 cell
= sheet
.getCellByPosition(x
, y
)
71 self
.assertEqual( 'FORMULA', cell
.Type
.value
)
72 self
.assertEqual( f
, cell
.getFormula() )
73 self
.assertEqual( s
, cell
.String
)
74 self
.assertEqual( val
, cell
.Value
)
75 for x
, y
, s
, val
in value_cells
:
76 cell
= sheet
.getCellByPosition(x
, y
)
77 self
.assertEqual( s
, cell
.String
)
78 self
.assertEqual( val
, cell
.Value
)
83 if __name__
== '__main__':