1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
10 #include <test/sheet/xcellrangedata.hxx>
12 #include <com/sun/star/sheet/XCellRangeData.hpp>
13 #include <com/sun/star/uno/Any.hxx>
14 #include <com/sun/star/uno/Reference.hxx>
15 #include <com/sun/star/uno/RuntimeException.hpp>
16 #include <com/sun/star/uno/Sequence.hxx>
18 #include <cppunit/TestAssert.h>
21 using namespace css::uno
;
27 void setValues(uno::Sequence
< uno::Sequence
< Any
> >& rColRow
, double nOffset
)
29 for (sal_Int32 i
= 0; i
< 4; ++i
)
31 rColRow
[i
].realloc(4);
32 for (sal_Int32 j
= 0; j
< 4; ++j
)
34 Any
& aAny
= rColRow
[i
][j
];
35 double nValue
= i
+ j
+ nOffset
;
43 void XCellRangeData::testSetDataArray()
45 uno::Reference
< sheet::XCellRangeData
> xCellRangeData( getXCellRangeData(), UNO_QUERY_THROW
);
47 uno::Sequence
< uno::Sequence
< Any
> > aColRow
;
49 setValues(aColRow
, 1);
50 xCellRangeData
->setDataArray(aColRow
);
52 for ( sal_Int32 i
= 0; i
< aColRow
.getLength(); ++i
)
54 for ( sal_Int32 j
= 0; j
< aColRow
[i
].getLength(); ++j
)
56 Any
& aAny
= aColRow
[i
][j
];
58 CPPUNIT_ASSERT( aAny
>>= nValue
);
59 CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast<double>(i
+j
+1), nValue
, 0.000001);
64 setValues(aColRow
, 0);
65 xCellRangeData
->setDataArray(aColRow
);
68 void XCellRangeData::testGetDataArray()
70 uno::Reference
< sheet::XCellRangeData
> xCellRangeData( getXCellRangeData(), UNO_QUERY_THROW
);
71 uno::Sequence
< uno::Sequence
< Any
> > aColRow
= xCellRangeData
->getDataArray();
72 CPPUNIT_ASSERT(aColRow
.hasElements());
75 void XCellRangeData::testGetDataArrayOnTableSheet()
77 uno::Reference
< sheet::XCellRangeData
> xCellRangeData( getXCellRangeData(), UNO_QUERY_THROW
);
78 CPPUNIT_ASSERT_THROW_MESSAGE("No RuntimeException thrown", xCellRangeData
->getDataArray(),
79 css::uno::RuntimeException
);
82 void XCellRangeData::testSetDataArrayOnTableSheet()
84 uno::Reference
< sheet::XCellRangeData
> xCellRangeData( getXCellRangeData(), UNO_QUERY_THROW
);
86 uno::Sequence
< uno::Sequence
< Any
> > aColRow
;
88 setValues(aColRow
, 1);
89 CPPUNIT_ASSERT_THROW_MESSAGE("No RuntimeException thrown", xCellRangeData
->setDataArray(aColRow
),
90 css::uno::RuntimeException
);
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */