Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * Version: MPL 1.1 / GPLv3+ / LGPLv3+
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License or as specified alternatively below. You may obtain a copy of
8 : * the License at http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * Major Contributor(s):
16 : * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
17 : *
18 : * All Rights Reserved.
19 : *
20 : * For minor contributions see the git repository.
21 : *
22 : * Alternatively, the contents of this file may be used under the terms of
23 : * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
24 : * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
25 : * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
26 : * instead of those above.
27 : */
28 :
29 : #include <test/sheet/xcellrangedata.hxx>
30 : #include <com/sun/star/sheet/XCellRangeData.hpp>
31 :
32 : #include "cppunit/extensions/HelperMacros.h"
33 :
34 : using namespace com::sun::star::uno;
35 :
36 : namespace apitest {
37 :
38 : namespace {
39 :
40 0 : void setValues(uno::Sequence< uno::Sequence < Any > >& rColRow, double nOffset)
41 : {
42 0 : for (sal_Int32 i = 0; i < 4; ++i)
43 : {
44 0 : rColRow[i].realloc(4);
45 0 : for (sal_Int32 j = 0; j < 4; ++j)
46 : {
47 0 : Any& aAny = rColRow[i][j];
48 0 : double nValue = i + j + nOffset;
49 0 : aAny <<= nValue;
50 : }
51 : }
52 0 : }
53 :
54 : }
55 :
56 0 : void XCellRangeData::testSetDataArray()
57 : {
58 0 : uno::Reference< sheet::XCellRangeData > xCellRangeData( getXCellRangeData(), UNO_QUERY_THROW);
59 :
60 0 : uno::Sequence< uno::Sequence < Any > > aColRow;
61 0 : aColRow.realloc(4);
62 0 : setValues(aColRow, 1);
63 0 : xCellRangeData->setDataArray(aColRow);
64 : // need to check here for correct values
65 :
66 : // set old values
67 0 : setValues(aColRow, 0);
68 0 : xCellRangeData->setDataArray(aColRow);
69 0 : }
70 :
71 0 : void XCellRangeData::testGetDataArray()
72 : {
73 0 : uno::Reference< sheet::XCellRangeData > xCellRangeData( getXCellRangeData(), UNO_QUERY_THROW);
74 0 : uno::Sequence< uno::Sequence < Any > > aColRow = xCellRangeData->getDataArray();
75 0 : for ( sal_Int32 i = 0; i < aColRow.getLength(); ++i)
76 : {
77 0 : for ( sal_Int32 j = 0; j < aColRow[i].getLength(); ++j)
78 : {
79 0 : Any& aAny = aColRow[i][j];
80 0 : double nValue = 0.0;
81 0 : CPPUNIT_ASSERT( aAny >>= nValue);
82 0 : CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast<double>(i+j), nValue, 0.000001);
83 : }
84 0 : }
85 0 : }
86 :
87 0 : }
88 :
89 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|