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/unoapi_test.hxx>
12 #include <svx/framelinkarray.hxx>
13 #include <svx/framelink.hxx>
15 using namespace com::sun::star
;
17 class FrameLinkArrayTest
: public UnoApiTest
21 : UnoApiTest(u
"svx/qa/unit/data/"_ustr
)
26 CPPUNIT_TEST_FIXTURE(FrameLinkArrayTest
, testSingleCell
)
28 svx::frame::Array stArr
;
29 stArr
.Initialize(10, 10);
31 stArr
.SetCellStyleLeft(/*col*/ 2, /*row*/ 4,
32 svx::frame::Style
{ 1.0, 1.0, 1.0, SvxBorderLineStyle::ENGRAVED
, 1.0 });
33 stArr
.SetCellStyleRight(/*col*/ 2, /*row*/ 4,
34 svx::frame::Style
{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DOTTED
, 1.0 });
35 stArr
.SetCellStyleTop(/*col*/ 2, /*row*/ 4,
36 svx::frame::Style
{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DASHED
, 1.0 });
37 stArr
.SetCellStyleBottom(/*col*/ 2, /*row*/ 4,
38 svx::frame::Style
{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DOUBLE
, 1.0 });
40 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::ENGRAVED
, stArr
.GetCellStyleLeft(2, 4).Type());
41 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOTTED
, stArr
.GetCellStyleRight(2, 4).Type());
42 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DASHED
, stArr
.GetCellStyleTop(2, 4).Type());
43 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOUBLE
, stArr
.GetCellStyleBottom(2, 4).Type());
46 CPPUNIT_TEST_FIXTURE(FrameLinkArrayTest
, testSingleCellRtl
)
48 svx::frame::Array stArr
;
49 stArr
.Initialize(10, 10);
51 stArr
.SetCellStyleLeft(/*col*/ 2, /*row*/ 4,
52 svx::frame::Style
{ 1.0, 1.0, 1.0, SvxBorderLineStyle::ENGRAVED
, 1.0 });
53 stArr
.SetCellStyleRight(/*col*/ 2, /*row*/ 4,
54 svx::frame::Style
{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DOTTED
, 1.0 });
55 stArr
.SetCellStyleTop(/*col*/ 2, /*row*/ 4,
56 svx::frame::Style
{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DASHED
, 1.0 });
57 stArr
.SetCellStyleBottom(/*col*/ 2, /*row*/ 4,
58 svx::frame::Style
{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DOUBLE
, 1.0 });
62 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleLeft(2, 4).Type());
63 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleRight(2, 4).Type());
64 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleTop(2, 4).Type());
65 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleBottom(2, 4).Type());
67 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOTTED
, stArr
.GetCellStyleLeft(7, 4).Type());
68 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::ENGRAVED
, stArr
.GetCellStyleRight(7, 4).Type());
69 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DASHED
, stArr
.GetCellStyleTop(7, 4).Type());
70 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOUBLE
, stArr
.GetCellStyleBottom(7, 4).Type());
73 CPPUNIT_TEST_FIXTURE(FrameLinkArrayTest
, testMergedCell
)
75 svx::frame::Array stArr
;
76 stArr
.Initialize(10, 10);
78 stArr
.SetCellStyleLeft(/*col*/ 2, /*row*/ 4,
79 svx::frame::Style
{ 1.0, 1.0, 1.0, SvxBorderLineStyle::ENGRAVED
, 1.0 });
80 stArr
.SetCellStyleRight(/*col*/ 2, /*row*/ 4,
81 svx::frame::Style
{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DOTTED
, 1.0 });
82 stArr
.SetCellStyleTop(/*col*/ 2, /*row*/ 4,
83 svx::frame::Style
{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DASHED
, 1.0 });
84 stArr
.SetCellStyleBottom(/*col*/ 2, /*row*/ 4,
85 svx::frame::Style
{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DOUBLE
, 1.0 });
86 stArr
.SetMergedRange(/*first col*/ 2, /*first row*/ 4, /*last col*/ 4, /*last row*/ 6);
88 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::ENGRAVED
, stArr
.GetCellStyleLeft(2, 4).Type());
89 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleRight(2, 4).Type());
90 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DASHED
, stArr
.GetCellStyleTop(2, 4).Type());
91 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleBottom(2, 4).Type());
93 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleLeft(3, 4).Type());
94 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleRight(3, 4).Type());
95 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DASHED
, stArr
.GetCellStyleTop(3, 4).Type());
96 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleBottom(3, 4).Type());
98 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleLeft(4, 4).Type());
99 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOTTED
, stArr
.GetCellStyleRight(4, 4).Type());
100 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DASHED
, stArr
.GetCellStyleTop(4, 4).Type());
101 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleBottom(4, 4).Type());
103 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::ENGRAVED
, stArr
.GetCellStyleLeft(2, 5).Type());
104 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleRight(2, 5).Type());
105 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleTop(2, 5).Type());
106 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleBottom(2, 5).Type());
108 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleLeft(3, 5).Type());
109 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleRight(3, 5).Type());
110 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleTop(3, 5).Type());
111 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleBottom(3, 5).Type());
113 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleLeft(4, 5).Type());
114 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOTTED
, stArr
.GetCellStyleRight(4, 5).Type());
115 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleTop(4, 5).Type());
116 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleBottom(4, 5).Type());
118 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::ENGRAVED
, stArr
.GetCellStyleLeft(2, 6).Type());
119 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleRight(2, 6).Type());
120 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleTop(2, 6).Type());
121 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOUBLE
, stArr
.GetCellStyleBottom(2, 6).Type());
123 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleLeft(3, 6).Type());
124 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleRight(3, 6).Type());
125 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleTop(3, 6).Type());
126 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOUBLE
, stArr
.GetCellStyleBottom(3, 6).Type());
128 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleLeft(4, 6).Type());
129 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOTTED
, stArr
.GetCellStyleRight(4, 6).Type());
130 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleTop(4, 6).Type());
131 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOUBLE
, stArr
.GetCellStyleBottom(4, 6).Type());
134 CPPUNIT_TEST_FIXTURE(FrameLinkArrayTest
, testMergedCellRtl
)
136 svx::frame::Array stArr
;
137 stArr
.Initialize(10, 10);
139 stArr
.SetCellStyleLeft(/*col*/ 2, /*row*/ 4,
140 svx::frame::Style
{ 1.0, 1.0, 1.0, SvxBorderLineStyle::ENGRAVED
, 1.0 });
141 stArr
.SetCellStyleRight(/*col*/ 2, /*row*/ 4,
142 svx::frame::Style
{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DOTTED
, 1.0 });
143 stArr
.SetCellStyleTop(/*col*/ 2, /*row*/ 4,
144 svx::frame::Style
{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DASHED
, 1.0 });
145 stArr
.SetCellStyleBottom(/*col*/ 2, /*row*/ 4,
146 svx::frame::Style
{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DOUBLE
, 1.0 });
147 stArr
.SetMergedRange(/*first col*/ 2, /*first row*/ 4, /*last col*/ 4, /*last row*/ 6);
150 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOTTED
, stArr
.GetCellStyleLeft(5, 4).Type());
151 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleRight(5, 4).Type());
152 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DASHED
, stArr
.GetCellStyleTop(5, 4).Type());
153 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleBottom(5, 4).Type());
155 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleLeft(6, 4).Type());
156 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleRight(6, 4).Type());
157 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DASHED
, stArr
.GetCellStyleTop(6, 4).Type());
158 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleBottom(6, 4).Type());
160 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleLeft(7, 4).Type());
161 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::ENGRAVED
, stArr
.GetCellStyleRight(7, 4).Type());
162 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DASHED
, stArr
.GetCellStyleTop(7, 4).Type());
163 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleBottom(7, 4).Type());
165 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOTTED
, stArr
.GetCellStyleLeft(5, 5).Type());
166 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleRight(5, 5).Type());
167 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleTop(5, 5).Type());
168 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleBottom(5, 5).Type());
170 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleLeft(6, 5).Type());
171 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleRight(6, 5).Type());
172 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleTop(6, 5).Type());
173 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleBottom(6, 5).Type());
175 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleLeft(7, 5).Type());
176 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::ENGRAVED
, stArr
.GetCellStyleRight(7, 5).Type());
177 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleTop(7, 5).Type());
178 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleBottom(7, 5).Type());
180 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOTTED
, stArr
.GetCellStyleLeft(5, 6).Type());
181 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleRight(5, 6).Type());
182 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleTop(5, 6).Type());
183 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOUBLE
, stArr
.GetCellStyleBottom(5, 6).Type());
185 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleLeft(6, 6).Type());
186 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleRight(6, 6).Type());
187 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleTop(6, 6).Type());
188 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOUBLE
, stArr
.GetCellStyleBottom(6, 6).Type());
190 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleLeft(7, 6).Type());
191 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::ENGRAVED
, stArr
.GetCellStyleRight(7, 6).Type());
192 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID
, stArr
.GetCellStyleTop(7, 6).Type());
193 CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOUBLE
, stArr
.GetCellStyleBottom(7, 6).Type());
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */