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 <sal/config.h>
11 #include <cppunit/TestFixture.h>
12 #include <cppunit/extensions/HelperMacros.h>
13 #include <cppunit/TestAssert.h>
14 #include <cppunit/plugin/TestPlugIn.h>
16 #include <markdata.hxx>
17 #include <sheetlimits.hxx>
18 #if defined __GNUC__ && !defined __clang__
19 #pragma GCC diagnostic push
20 #pragma GCC diagnostic ignored "-Wsubobject-linkage"
21 // automatically suppressed in the main .cxx, but not in this included one
23 #include "../../source/core/data/segmenttree.cxx"
24 #if defined __GNUC__ && !defined __clang__
25 #pragma GCC diagnostic push
32 struct MarkTestData
// To represent a single rectangle part of a multiselection
37 // Cumulative Test data follows
38 std::vector
<ScAddress
> aInsideAddresses
;
39 std::vector
<ScAddress
> aOutsideAddresses
;
41 std::vector
<SCCOL
> aColumnsWithFullMarks
;
42 std::vector
<SCCOL
> aColumnsWithoutFullMarks
;
44 std::vector
<SCROW
> aRowsWithFullMarks
;
45 std::vector
<SCROW
> aRowsWithoutFullMarks
;
47 std::vector
<ScRange
> aRangesWithFullMarks
;
48 std::vector
<ScRange
> aRangesWithoutFullMarks
;
50 // To test ScMarkData::GetNextMarked()
51 // Encoding : EndRow is the next marked row in the column = StartCol after StartRow.
52 // EndCol = 0 means search up, 1 means to search down
53 std::vector
<ScRange
> aNextMarked
;
55 std::vector
<SCCOL
> aColumnsWithAtLeastOneMark
;
56 std::vector
<SCCOL
> aColumnsWithoutAnyMarks
;
60 struct MarkArrayTestData
63 std::vector
<std::pair
<SCROW
,SCROW
>> aMarkedRowSegs
;
66 struct MultiMarkTestData
68 std::vector
<MarkTestData
> aMarks
;
69 ScRange aSelectionCover
;
70 ScRangeList aLeftEnvelope
;
71 ScRangeList aRightEnvelope
;
72 ScRangeList aTopEnvelope
;
73 ScRangeList aBottomEnvelope
;
74 std::vector
<MarkArrayTestData
> aMarkArrays
;
76 // To test ScMultiSel::HasOneMark()
77 // Encoding : StartCol is the column to test, StartRow is the beginning of the one mark,
78 // EndRow is the end of the one mark, EndCol is not used
79 std::vector
<ScRange
> aColsWithOneMark
;
80 std::vector
<SCCOL
> aColsWithoutOneMark
;
82 // To test ScMultiSel::IsAllMarked()
83 // Encoding StartCol is the column to be queried, [StartRow,EndRow] is the range to test.
84 std::vector
<ScRange
> aColsAllMarked
;
85 std::vector
<ScRange
> aColsNotAllMarked
;
87 // To test ScMultiSel::HasEqualRowsMarked()
88 std::vector
<std::pair
<SCCOL
,SCCOL
>> aColsWithEqualMarksList
;
89 std::vector
<std::pair
<SCCOL
,SCCOL
>> aColsWithUnequalMarksList
;
94 class Test
: public CppUnit::TestFixture
97 void testSimpleMark( const ScRange
& rRange
, const ScRange
& rSelectionCover
,
98 const ScRangeList
& rLeftEnvelope
, const ScRangeList
& rRightEnvelope
,
99 const ScRangeList
& rTopEnvelope
, const ScRangeList
& rBottomEnvelope
,
100 const ScSheetLimits
& rLimits
);
101 void testSimpleMark_Simple();
102 void testSimpleMark_Column();
103 void testSimpleMark_Row();
105 void testMultiMark( const MultiMarkTestData
& rData
);
106 void testMultiMark_FourRanges();
107 void testMultiMark_NegativeMarking();
109 void testInsertTabBeforeSelected();
110 void testInsertTabAfterSelected();
111 void testDeleteTabBeforeSelected();
112 void testDeleteTabAfterSelected();
114 void testScMarkArraySearch();
116 void testIsAllMarked();
118 CPPUNIT_TEST_SUITE(Test
);
119 CPPUNIT_TEST(testSimpleMark_Simple
);
120 CPPUNIT_TEST(testSimpleMark_Column
);
121 CPPUNIT_TEST(testSimpleMark_Row
);
122 CPPUNIT_TEST(testMultiMark_FourRanges
);
123 CPPUNIT_TEST(testMultiMark_NegativeMarking
);
124 CPPUNIT_TEST(testInsertTabBeforeSelected
);
125 CPPUNIT_TEST(testInsertTabAfterSelected
);
126 CPPUNIT_TEST(testDeleteTabBeforeSelected
);
127 CPPUNIT_TEST(testDeleteTabAfterSelected
);
128 CPPUNIT_TEST(testScMarkArraySearch
);
129 CPPUNIT_TEST(testIsAllMarked
);
130 CPPUNIT_TEST_SUITE_END();
133 void testScMarkArraySearch_check(const ScMarkArray
& ar
, SCROW nRow
, bool expectStatus
, SCSIZE nIndexExpect
);
136 static void lcl_GetSortedRanges( const ScRangeList
& rRangeList
, ScRangeList
& rRangeListOut
)
138 rRangeListOut
.RemoveAll();
139 std::vector
<ScRange
> aRanges
;
140 size_t nSize
= rRangeList
.size();
141 aRanges
.reserve( nSize
);
142 for ( size_t nIdx
= 0; nIdx
< nSize
; ++nIdx
)
143 aRanges
.push_back( rRangeList
[nIdx
] );
144 std::sort( aRanges
.begin(), aRanges
.end() );
145 for ( size_t nIdx
= 0; nIdx
< nSize
; ++nIdx
)
146 rRangeListOut
.push_back( aRanges
[nIdx
] );
149 void Test::testSimpleMark( const ScRange
& rRange
, const ScRange
& rSelectionCover
,
150 const ScRangeList
& rLeftEnvelope
, const ScRangeList
& rRightEnvelope
,
151 const ScRangeList
& rTopEnvelope
, const ScRangeList
& rBottomEnvelope
,
152 const ScSheetLimits
& rLimits
)
154 ScMarkData
aMark(rLimits
);
155 CPPUNIT_ASSERT( !aMark
.IsMarked() );
156 CPPUNIT_ASSERT( !aMark
.IsMultiMarked() );
158 aMark
.SetMarkArea( rRange
);
159 CPPUNIT_ASSERT( aMark
.IsMarked() );
160 CPPUNIT_ASSERT( !aMark
.IsMultiMarked() );
162 CPPUNIT_ASSERT_EQUAL( rRange
, aMark
.GetMarkArea() );
164 SCROW nMidRow
= ( rRange
.aStart
.Row() + rRange
.aEnd
.Row() ) / 2;
165 SCCOL nMidCol
= ( rRange
.aStart
.Col() + rRange
.aEnd
.Col() ) / 2;
166 SCROW nOutRow1
= rRange
.aEnd
.Row() + 1;
167 SCCOL nOutCol1
= rRange
.aEnd
.Col() + 1;
168 SCROW nOutRow2
= rRange
.aStart
.Row() - 1;
169 SCCOL nOutCol2
= rRange
.aStart
.Col() - 1;
171 CPPUNIT_ASSERT( aMark
.IsCellMarked( nMidCol
, nMidRow
) );
172 if ( ValidCol( nOutCol1
, rLimits
.MaxCol() ) && ValidRow( nOutRow1
, rLimits
.MaxRow() ) )
173 CPPUNIT_ASSERT( !aMark
.IsCellMarked( nOutCol1
, nOutRow1
) );
175 if ( ValidCol( nOutCol2
, rLimits
.MaxCol() ) && ValidRow( nOutRow2
, rLimits
.MaxRow() ) )
176 CPPUNIT_ASSERT( !aMark
.IsCellMarked( nOutCol2
, nOutRow2
) );
178 if ( ValidRow( nOutRow1
, rLimits
.MaxRow() ) )
179 CPPUNIT_ASSERT( !aMark
.IsCellMarked( nMidCol
, nOutRow1
) );
181 if ( ValidCol( nOutCol1
, rLimits
.MaxCol() ) )
182 CPPUNIT_ASSERT( !aMark
.IsCellMarked( nOutCol1
, nMidRow
) );
184 if ( ValidRow( nOutRow2
, rLimits
.MaxRow() ) )
185 CPPUNIT_ASSERT( !aMark
.IsCellMarked( nMidCol
, nOutRow2
) );
187 if ( ValidCol( nOutCol2
, rLimits
.MaxCol() ) )
188 CPPUNIT_ASSERT( !aMark
.IsCellMarked( nOutCol2
, nMidRow
) );
190 if ( rRange
.aStart
.Row() == 0 && rRange
.aEnd
.Row() == rLimits
.MaxRow() )
191 CPPUNIT_ASSERT( aMark
.IsColumnMarked( nMidCol
) );
193 CPPUNIT_ASSERT( !aMark
.IsColumnMarked( nMidCol
) );
194 if ( rRange
.aStart
.Col() == 0 && rRange
.aEnd
.Col() == rLimits
.MaxCol() )
195 CPPUNIT_ASSERT( aMark
.IsRowMarked( nMidRow
) );
197 CPPUNIT_ASSERT( !aMark
.IsRowMarked( nMidRow
) );
199 ScRange aSelectionCoverOutput
;
200 aMark
.GetSelectionCover( aSelectionCoverOutput
);
201 CPPUNIT_ASSERT_EQUAL( rSelectionCover
, aSelectionCoverOutput
);
202 CPPUNIT_ASSERT_EQUAL( rLeftEnvelope
, aMark
.GetLeftEnvelope() );
203 CPPUNIT_ASSERT_EQUAL( rRightEnvelope
, aMark
.GetRightEnvelope() );
204 CPPUNIT_ASSERT_EQUAL( rTopEnvelope
, aMark
.GetTopEnvelope() );
205 CPPUNIT_ASSERT_EQUAL( rBottomEnvelope
, aMark
.GetBottomEnvelope() );
208 void Test::testSimpleMark_Simple()
210 ScSheetLimits
limits( ScSheetLimits::CreateDefault());
211 testSimpleMark( ScRange( 10, 15, 0, 20, 30, 0 ), // Simple range
212 ScRange( 9, 14, 0, 21, 31, 0 ), // Cover
213 ScRangeList( ScRange( 9, 15, 0, 9, 30, 0 ) ), // Left envelope
214 ScRangeList( ScRange( 21, 15, 0, 21, 30, 0 ) ), // Right envelope
215 ScRangeList( ScRange( 10, 14, 0, 20, 14, 0 ) ), // Top envelope
216 ScRangeList( ScRange( 10, 31, 0, 20, 31, 0 ) ), // Bottom envelope
220 void Test::testSimpleMark_Column()
222 ScSheetLimits
limits( ScSheetLimits::CreateDefault());
223 // Column 10, rows from 15 to 30
224 testSimpleMark( ScRange( 10, 15, 0, 10, 30, 0 ), // Simple range
225 ScRange( 9, 14, 0, 11, 31, 0 ), // Cover
226 ScRangeList( ScRange( 9, 15, 0, 9, 30, 0 ) ), // Left envelope
227 ScRangeList( ScRange( 11, 15, 0, 11, 30, 0 ) ), // Right envelope
228 ScRangeList( ScRange( 10, 14, 0, 10, 14, 0 ) ), // Top envelope
229 ScRangeList( ScRange( 10, 31, 0, 10, 31, 0 ) ), // Bottom envelope
233 testSimpleMark( ScRange( 10, 0, 0, 10, limits
.MaxRow(), 0 ), // Simple range
234 ScRange( 9, 0, 0, 11, limits
.MaxRow(), 0 ), // Cover
235 ScRangeList( ScRange( 9, 0, 0, 9, limits
.MaxRow(), 0 ) ), // Left envelope
236 ScRangeList( ScRange( 11, 0, 0, 11, limits
.MaxRow(), 0 ) ), // Right envelope
237 ScRangeList(), // Top envelope
238 ScRangeList(), // Bottom envelope
242 void Test::testSimpleMark_Row()
244 ScSheetLimits
limits( ScSheetLimits::CreateDefault());
245 // Row 15, cols from 10 to 20
246 testSimpleMark( ScRange( 10, 15, 0, 20, 15, 0 ), // Simple range
247 ScRange( 9, 14, 0, 21, 16, 0 ), // Cover
248 ScRangeList( ScRange( 9, 15, 0, 9, 15, 0 ) ), // Left envelope
249 ScRangeList( ScRange( 21, 15, 0, 21, 15, 0 ) ), // Right envelope
250 ScRangeList( ScRange( 10, 14, 0, 20, 14, 0 ) ), // Top envelope
251 ScRangeList( ScRange( 10, 16, 0, 20, 16, 0 ) ), // Bottom envelope
255 testSimpleMark( ScRange( 0, 15, 0, limits
.MaxCol(), 15, 0 ), // Simple range
256 ScRange( 0, 14, 0, limits
.MaxCol(), 16, 0 ), // Cover
257 ScRangeList(), // Left envelope
258 ScRangeList(), // Right envelope
259 ScRangeList( ScRange( 0, 14, 0, limits
.MaxCol(), 14, 0 ) ), // Top envelope
260 ScRangeList( ScRange( 0, 16, 0, limits
.MaxCol(), 16, 0 ) ), // Bottom envelope
264 void Test::testMultiMark( const MultiMarkTestData
& rMarksData
)
266 ScSheetLimits
limits( ScSheetLimits::CreateDefault());
267 ScMarkData
aMark(limits
);
268 ScMultiSel
aMultiSel(limits
);
269 CPPUNIT_ASSERT( !aMark
.IsMarked() );
270 CPPUNIT_ASSERT( !aMark
.IsMultiMarked() );
271 CPPUNIT_ASSERT_EQUAL( SCCOL(0), aMultiSel
.GetMultiSelectionCount() );
272 CPPUNIT_ASSERT( !aMultiSel
.HasAnyMarks() );
274 for ( const auto& rAreaTestData
: rMarksData
.aMarks
)
276 aMultiSel
.SetMarkArea( rAreaTestData
.aRange
.aStart
.Col(), rAreaTestData
.aRange
.aEnd
.Col(),
277 rAreaTestData
.aRange
.aStart
.Row(), rAreaTestData
.aRange
.aEnd
.Row(),
278 rAreaTestData
.bMark
);
279 aMark
.SetMultiMarkArea( rAreaTestData
.aRange
, rAreaTestData
.bMark
);
280 CPPUNIT_ASSERT( aMark
.IsMultiMarked() );
282 for ( const auto& rMarkedAddress
: rAreaTestData
.aInsideAddresses
)
284 CPPUNIT_ASSERT( aMultiSel
.GetMark( rMarkedAddress
.Col(), rMarkedAddress
.Row() ) );
285 CPPUNIT_ASSERT( aMark
.IsCellMarked( rMarkedAddress
.Col(), rMarkedAddress
.Row() ) );
288 for ( const auto& rUnMarkedAddress
: rAreaTestData
.aOutsideAddresses
)
290 CPPUNIT_ASSERT( !aMark
.IsCellMarked( rUnMarkedAddress
.Col(), rUnMarkedAddress
.Row() ) );
291 CPPUNIT_ASSERT( !aMark
.IsCellMarked( rUnMarkedAddress
.Col(), rUnMarkedAddress
.Row() ) );
294 for ( const auto& rCol
: rAreaTestData
.aColumnsWithFullMarks
)
296 CPPUNIT_ASSERT( aMark
.IsColumnMarked( rCol
) );
297 CPPUNIT_ASSERT( aMultiSel
.IsAllMarked( rCol
, 0, limits
.MaxRow() ) );
300 for ( const auto& rCol
: rAreaTestData
.aColumnsWithoutFullMarks
)
302 CPPUNIT_ASSERT( !aMark
.IsColumnMarked( rCol
) );
303 CPPUNIT_ASSERT( !aMultiSel
.IsAllMarked( rCol
, 0, limits
.MaxRow() ) );
306 for ( const auto& rRow
: rAreaTestData
.aRowsWithFullMarks
)
308 CPPUNIT_ASSERT( aMark
.IsRowMarked( rRow
) );
309 CPPUNIT_ASSERT( aMultiSel
.IsRowMarked( rRow
) );
312 for ( const auto& rRow
: rAreaTestData
.aRowsWithoutFullMarks
)
314 CPPUNIT_ASSERT( !aMark
.IsRowMarked( rRow
) );
315 CPPUNIT_ASSERT( !aMultiSel
.IsRowMarked( rRow
) );
318 for ( const auto& rRange
: rAreaTestData
.aRangesWithFullMarks
)
320 CPPUNIT_ASSERT( aMark
.IsAllMarked( rRange
) );
321 SCROW nRow1
= rRange
.aStart
.Row(), nRow2
= rRange
.aEnd
.Row();
322 SCCOL nCol1
= rRange
.aStart
.Col(), nCol2
= rRange
.aEnd
.Col();
323 for ( SCCOL nColIter
= nCol1
; nColIter
<= nCol2
; ++nColIter
)
324 CPPUNIT_ASSERT( aMultiSel
.IsAllMarked( nColIter
, nRow1
, nRow2
) );
327 for ( const auto& rRange
: rAreaTestData
.aRangesWithoutFullMarks
)
328 CPPUNIT_ASSERT( !aMark
.IsAllMarked( rRange
) );
330 for ( const auto& rRange
: rAreaTestData
.aNextMarked
)
332 SCROW nNextRow1
= aMark
.GetNextMarked( rRange
.aStart
.Col(), rRange
.aStart
.Row(), !static_cast<bool>(rRange
.aEnd
.Col()) );
333 CPPUNIT_ASSERT_EQUAL( rRange
.aEnd
.Row(), nNextRow1
);
334 SCROW nNextRow2
= aMultiSel
.GetNextMarked( rRange
.aStart
.Col(), rRange
.aStart
.Row(), !static_cast<bool>(rRange
.aEnd
.Col()) );
335 CPPUNIT_ASSERT_EQUAL( rRange
.aEnd
.Row(), nNextRow2
);
338 for ( const auto& rCol
: rAreaTestData
.aColumnsWithAtLeastOneMark
)
340 CPPUNIT_ASSERT( aMark
.HasMultiMarks( rCol
) );
341 CPPUNIT_ASSERT( aMultiSel
.HasMarks( rCol
) );
344 for ( const auto& rCol
: rAreaTestData
.aColumnsWithoutAnyMarks
)
346 CPPUNIT_ASSERT( !aMark
.HasMultiMarks( rCol
) );
347 CPPUNIT_ASSERT( !aMultiSel
.HasMarks( rCol
) );
352 ScRange aSelectionCoverOutput
;
353 aMark
.GetSelectionCover( aSelectionCoverOutput
);
354 CPPUNIT_ASSERT_EQUAL( rMarksData
.aSelectionCover
, aSelectionCoverOutput
);
356 ScRangeList aRangesExpected
, aRangesActual
;
357 lcl_GetSortedRanges( rMarksData
.aLeftEnvelope
, aRangesExpected
);
358 lcl_GetSortedRanges( aMark
.GetLeftEnvelope(), aRangesActual
);
359 CPPUNIT_ASSERT_EQUAL( aRangesExpected
, aRangesActual
);
360 lcl_GetSortedRanges( rMarksData
.aRightEnvelope
, aRangesExpected
);
361 lcl_GetSortedRanges( aMark
.GetRightEnvelope(), aRangesActual
);
362 CPPUNIT_ASSERT_EQUAL( aRangesExpected
, aRangesActual
);
363 lcl_GetSortedRanges( rMarksData
.aTopEnvelope
, aRangesExpected
);
364 lcl_GetSortedRanges( aMark
.GetTopEnvelope(), aRangesActual
);
365 CPPUNIT_ASSERT_EQUAL( aRangesExpected
, aRangesActual
);
366 lcl_GetSortedRanges( rMarksData
.aBottomEnvelope
, aRangesExpected
);
367 lcl_GetSortedRanges( aMark
.GetBottomEnvelope(), aRangesActual
);
368 CPPUNIT_ASSERT_EQUAL( aRangesExpected
, aRangesActual
);
370 for ( const auto& rMarkArrayTestData
: rMarksData
.aMarkArrays
)
372 ScMarkArray
aArray( aMark
.GetMarkArray( rMarkArrayTestData
.nCol
) );
373 std::vector
<std::pair
<SCROW
, SCROW
>> aMarkedRowSegs
;
374 ScMarkArrayIter
aIter( &aArray
);
376 while ( aIter
.Next( nStart
, nEnd
) )
377 aMarkedRowSegs
.emplace_back( nStart
, nEnd
);
379 CPPUNIT_ASSERT_EQUAL( rMarkArrayTestData
.aMarkedRowSegs
.size(), aMarkedRowSegs
.size() );
381 for ( const auto& rPair
: rMarkArrayTestData
.aMarkedRowSegs
)
383 CPPUNIT_ASSERT_EQUAL( rPair
.first
, aMarkedRowSegs
[nIdx
].first
);
384 CPPUNIT_ASSERT_EQUAL( rPair
.second
, aMarkedRowSegs
[nIdx
].second
);
389 for ( const auto& rColWithOneMark
: rMarksData
.aColsWithOneMark
)
391 SCROW nRow1
= -1, nRow2
= -1;
392 CPPUNIT_ASSERT( aMultiSel
.HasOneMark( rColWithOneMark
.aStart
.Col(), nRow1
, nRow2
) );
393 CPPUNIT_ASSERT_EQUAL( rColWithOneMark
.aStart
.Row(), nRow1
);
394 CPPUNIT_ASSERT_EQUAL( rColWithOneMark
.aEnd
.Row(), nRow2
);
398 SCROW nRow1
= -1, nRow2
= -1;
399 for ( const SCCOL
& rCol
: rMarksData
.aColsWithoutOneMark
)
400 CPPUNIT_ASSERT( !aMultiSel
.HasOneMark( rCol
, nRow1
, nRow2
) );
403 for ( const auto& rColAllMarked
: rMarksData
.aColsAllMarked
)
404 CPPUNIT_ASSERT( aMultiSel
.IsAllMarked( rColAllMarked
.aStart
.Col(),
405 rColAllMarked
.aStart
.Row(),
406 rColAllMarked
.aEnd
.Row() ) );
408 for ( const auto& rColNotAllMarked
: rMarksData
.aColsNotAllMarked
)
409 CPPUNIT_ASSERT( !aMultiSel
.IsAllMarked( rColNotAllMarked
.aStart
.Col(),
410 rColNotAllMarked
.aStart
.Row(),
411 rColNotAllMarked
.aEnd
.Row() ) );
413 for ( const auto& rColsWithEqualMarks
: rMarksData
.aColsWithEqualMarksList
)
414 CPPUNIT_ASSERT( aMultiSel
.HasEqualRowsMarked( rColsWithEqualMarks
.first
, rColsWithEqualMarks
.second
) );
416 for ( const auto& rColsWithUnequalMarks
: rMarksData
.aColsWithUnequalMarksList
)
417 CPPUNIT_ASSERT( !aMultiSel
.HasEqualRowsMarked( rColsWithUnequalMarks
.first
, rColsWithUnequalMarks
.second
) );
420 CPPUNIT_ASSERT_EQUAL( SCCOL(0), aMultiSel
.GetMultiSelectionCount() );
421 CPPUNIT_ASSERT( !aMultiSel
.HasAnyMarks() );
424 void Test::testMultiMark_FourRanges()
426 ScSheetLimits
limits( ScSheetLimits::CreateDefault());
427 MultiMarkTestData aData
;
428 MarkTestData aSingle1
;
430 // Create rectangle ( 10, 5, 20, 10 )
431 aSingle1
.aRange
= ScRange( 10, 5, 0, 20, 10, 0 );
432 aSingle1
.bMark
= true;
434 aSingle1
.aInsideAddresses
.emplace_back( 15, 6, 0 );
435 aSingle1
.aInsideAddresses
.emplace_back( 10, 5, 0 );
436 aSingle1
.aInsideAddresses
.emplace_back( 20, 5, 0 );
437 aSingle1
.aInsideAddresses
.emplace_back( 10, 10, 0 );
438 aSingle1
.aInsideAddresses
.emplace_back( 20, 10, 0 );
440 aSingle1
.aOutsideAddresses
.emplace_back( 15, 4, 0 );
441 aSingle1
.aOutsideAddresses
.emplace_back( 15, 11, 0 );
442 aSingle1
.aOutsideAddresses
.emplace_back( 9, 6, 0 );
443 aSingle1
.aOutsideAddresses
.emplace_back( 21, 6, 0 );
444 aSingle1
.aOutsideAddresses
.emplace_back( 26, 10, 0 );
446 aSingle1
.aColumnsWithoutFullMarks
.push_back( 16 );
447 aSingle1
.aColumnsWithoutFullMarks
.push_back( 21 );
449 aSingle1
.aRowsWithoutFullMarks
.push_back( 7 );
450 aSingle1
.aRowsWithoutFullMarks
.push_back( 11 );
452 aSingle1
.aRangesWithFullMarks
.emplace_back( 10, 5, 0, 20, 10, 0 );
453 aSingle1
.aRangesWithFullMarks
.emplace_back( 11, 6, 0, 19, 8, 0 );
455 aSingle1
.aRangesWithoutFullMarks
.emplace_back( 9, 4, 0, 21, 11, 0 );
456 aSingle1
.aRangesWithoutFullMarks
.emplace_back( 25, 7, 0, 30, 15, 0 );
458 aSingle1
.aNextMarked
.emplace_back( 15, 1, 0, 1, 5, 0 ); // Search down
459 aSingle1
.aNextMarked
.emplace_back( 15, 15, 0, 0, 10, 0 ); // Search up
461 aSingle1
.aNextMarked
.emplace_back( 15, 15, 0, 1, limits
.GetMaxRowCount(), 0 ); // Search down fail
462 aSingle1
.aNextMarked
.emplace_back( 15, 4, 0, 0, -1, 0 ); // Search up fail
464 aSingle1
.aColumnsWithAtLeastOneMark
.push_back( 10 );
465 aSingle1
.aColumnsWithAtLeastOneMark
.push_back( 15 );
466 aSingle1
.aColumnsWithAtLeastOneMark
.push_back( 20 );
468 aSingle1
.aColumnsWithoutAnyMarks
.push_back( 21 );
469 aSingle1
.aColumnsWithoutAnyMarks
.push_back( 9 );
471 // Create rectangle ( 25, 7, 30, 15 )
472 MarkTestData aSingle2
;
473 aSingle2
.aRange
= ScRange( 25, 7, 0, 30, 15, 0 );
474 aSingle2
.bMark
= true;
476 aSingle2
.aInsideAddresses
= aSingle1
.aInsideAddresses
;
477 aSingle2
.aInsideAddresses
.emplace_back( 27, 10, 0 );
478 aSingle2
.aInsideAddresses
.emplace_back( 25, 7, 0 );
479 aSingle2
.aInsideAddresses
.emplace_back( 30, 7, 0 );
480 aSingle2
.aInsideAddresses
.emplace_back( 25, 15, 0 );
481 aSingle2
.aInsideAddresses
.emplace_back( 30, 15, 0 );
483 aSingle2
.aOutsideAddresses
.emplace_back( 15, 4, 0 );
484 aSingle2
.aOutsideAddresses
.emplace_back( 15, 11, 0 );
485 aSingle2
.aOutsideAddresses
.emplace_back( 9, 6, 0 );
486 aSingle2
.aOutsideAddresses
.emplace_back( 21, 6, 0 );
487 aSingle2
.aOutsideAddresses
.emplace_back( 26, 6, 0 );
488 aSingle2
.aOutsideAddresses
.emplace_back( 26, 16, 0 );
489 aSingle2
.aOutsideAddresses
.emplace_back( 24, 8, 0 );
490 aSingle2
.aOutsideAddresses
.emplace_back( 31, 11, 0 );
492 aSingle2
.aColumnsWithoutFullMarks
= aSingle1
.aColumnsWithoutAnyMarks
;
494 aSingle2
.aRowsWithoutFullMarks
= aSingle1
.aRowsWithoutFullMarks
;
496 aSingle2
.aRangesWithFullMarks
= aSingle1
.aRangesWithFullMarks
;
497 aSingle2
.aRangesWithFullMarks
.emplace_back( 25, 7, 0, 30, 15, 0 );
498 aSingle2
.aRangesWithFullMarks
.emplace_back( 26, 8, 0, 29, 14, 0 );
500 aSingle2
.aRangesWithoutFullMarks
.emplace_back( 9, 4, 0, 21, 11, 0 );
501 aSingle2
.aRangesWithoutFullMarks
.emplace_back( 24, 6, 0, 31, 16, 0 );
502 aSingle2
.aRangesWithoutFullMarks
.emplace_back( 10, 5, 0, 30, 15, 0 );
504 aSingle2
.aNextMarked
.emplace_back( 27, 16, 0, 0, 15, 0 ); // up ok
505 aSingle2
.aNextMarked
.emplace_back( 27, 4, 0, 1, 7, 0 ); // down ok
506 aSingle2
.aNextMarked
.emplace_back( 27, 4, 0, 0, -1, 0 ); // up fail
507 aSingle2
.aNextMarked
.emplace_back( 27, 16, 0, 1, limits
.GetMaxRowCount(), 0 ); // down fail
509 aSingle2
.aColumnsWithAtLeastOneMark
= aSingle1
.aColumnsWithAtLeastOneMark
;
510 aSingle2
.aColumnsWithAtLeastOneMark
.push_back( 25 );
511 aSingle2
.aColumnsWithAtLeastOneMark
.push_back( 27 );
512 aSingle2
.aColumnsWithAtLeastOneMark
.push_back( 30 );
514 aSingle2
.aColumnsWithoutAnyMarks
.push_back( 9 );
515 aSingle2
.aColumnsWithoutAnyMarks
.push_back( 21 );
516 aSingle2
.aColumnsWithoutAnyMarks
.push_back( 24 );
517 aSingle2
.aColumnsWithoutAnyMarks
.push_back( 31 );
520 MarkTestData aSingle3
;
522 aSingle3
.aRange
= ScRange( 0, 20, 0, limits
.MaxCol(), 20, 0 );
523 aSingle3
.bMark
= true;
525 aSingle3
.aInsideAddresses
= aSingle2
.aInsideAddresses
;
526 aSingle3
.aInsideAddresses
.emplace_back( 5, 20, 0 );
527 aSingle3
.aInsideAddresses
.emplace_back( 100, 20, 0 );
529 aSingle3
.aOutsideAddresses
.emplace_back( 0, 21, 0 );
530 aSingle3
.aOutsideAddresses
.emplace_back( 27, 19, 0 );
532 aSingle3
.aColumnsWithoutFullMarks
= aSingle2
.aColumnsWithoutAnyMarks
;
534 aSingle3
.aRowsWithFullMarks
.push_back( 20 );
536 aSingle3
.aRangesWithFullMarks
= aSingle2
.aRangesWithFullMarks
;
537 aSingle3
.aRangesWithFullMarks
.emplace_back( 0, 20, 0, limits
.MaxCol(), 20, 0 );
538 aSingle3
.aRangesWithFullMarks
.emplace_back( 15, 20, 0, 55, 20, 0 );
540 aSingle3
.aNextMarked
.emplace_back( 15, 16, 0, 0, 10, 0 ); // up ok
541 aSingle3
.aNextMarked
.emplace_back( 15, 16, 0, 1, 20, 0 ); // down ok
542 aSingle3
.aNextMarked
.emplace_back( 22, 15, 0, 0, -1, 0 ); // up fail
543 aSingle3
.aNextMarked
.emplace_back( 22, 25, 0, 1, limits
.GetMaxRowCount(), 0 ); // down fail
545 aSingle3
.aColumnsWithAtLeastOneMark
= aSingle2
.aColumnsWithAtLeastOneMark
;
546 aSingle3
.aColumnsWithAtLeastOneMark
.push_back( 39 );
549 MarkTestData aSingle4
;
551 aSingle4
.aRange
= ScRange( 35, 0, 0, 35, limits
.MaxRow(), 0 );
552 aSingle4
.bMark
= true;
554 aSingle4
.aInsideAddresses
= aSingle3
.aInsideAddresses
;
555 aSingle4
.aInsideAddresses
.emplace_back( 35, 10, 0 );
556 aSingle4
.aInsideAddresses
.emplace_back( 35, 25, 0 );
558 aSingle4
.aOutsideAddresses
.emplace_back( 33, 10, 0 );
559 aSingle4
.aOutsideAddresses
.emplace_back( 39, 10, 0 );
560 aSingle4
.aOutsideAddresses
.emplace_back( 33, 25, 0 );
561 aSingle4
.aOutsideAddresses
.emplace_back( 39, 25, 0 );
563 aSingle4
.aColumnsWithFullMarks
.push_back( 35 );
565 aSingle4
.aRowsWithFullMarks
.push_back( 20 );
567 aSingle4
.aRangesWithFullMarks
= aSingle3
.aRangesWithFullMarks
;
568 aSingle4
.aRangesWithFullMarks
.emplace_back( 35, 0, 0, 35, limits
.MaxRow(), 0 );
569 aSingle4
.aRangesWithFullMarks
.emplace_back( 35, 10, 0, 35, 25, 0 );
571 // Add the rectangle data to aData
572 aData
.aMarks
.push_back( aSingle1
);
573 aData
.aMarks
.push_back( aSingle2
);
574 aData
.aMarks
.push_back( aSingle3
);
575 aData
.aMarks
.push_back( aSingle4
);
577 aData
.aSelectionCover
= ScRange( 0, 0, 0, limits
.MaxCol(), limits
.MaxRow(), 0 );
578 aData
.aLeftEnvelope
.push_back( ScRange( 9, 5, 0, 9, 10, 0 ) );
579 aData
.aLeftEnvelope
.push_back( ScRange( 24, 7, 0, 24, 15, 0 ) );
580 aData
.aLeftEnvelope
.push_back( ScRange( 34, 0, 0, 34, 19, 0 ) );
581 aData
.aLeftEnvelope
.push_back( ScRange( 34, 21, 0, 34, limits
.MaxRow(), 0 ) );
583 aData
.aRightEnvelope
.push_back( ScRange( 21, 5, 0, 21, 10, 0 ) );
584 aData
.aRightEnvelope
.push_back( ScRange( 31, 7, 0, 31, 15, 0 ) );
585 aData
.aRightEnvelope
.push_back( ScRange( 36, 0, 0, 36, 19, 0 ) );
586 aData
.aRightEnvelope
.push_back( ScRange( 36, 21, 0, 36, limits
.MaxRow(), 0 ) );
588 aData
.aTopEnvelope
.push_back( ScRange( 10, 4, 0, 20, 4, 0 ) );
589 aData
.aTopEnvelope
.push_back( ScRange( 25, 6, 0, 30, 6, 0 ) );
590 aData
.aTopEnvelope
.push_back( ScRange( 0, 19, 0, 34, 19, 0 ) );
591 aData
.aTopEnvelope
.push_back( ScRange( 36, 19, 0, limits
.MaxCol(), 19, 0 ) );
593 aData
.aBottomEnvelope
.push_back( ScRange( 10, 11, 0, 20, 11, 0 ) );
594 aData
.aBottomEnvelope
.push_back( ScRange( 25, 16, 0, 30, 16, 0 ) );
595 aData
.aBottomEnvelope
.push_back( ScRange( 0, 21, 0, 34, 21, 0 ) );
596 aData
.aBottomEnvelope
.push_back( ScRange( 36, 21, 0, limits
.MaxCol(), 21, 0 ) );
598 MarkArrayTestData aMarkArrayTestData1
;
599 aMarkArrayTestData1
.nCol
= 5;
600 aMarkArrayTestData1
.aMarkedRowSegs
.emplace_back( 20, 20 );
602 MarkArrayTestData aMarkArrayTestData2
;
603 aMarkArrayTestData2
.nCol
= 15;
604 aMarkArrayTestData2
.aMarkedRowSegs
.emplace_back( 5, 10 );
605 aMarkArrayTestData2
.aMarkedRowSegs
.emplace_back( 20, 20 );
607 MarkArrayTestData aMarkArrayTestData3
;
608 aMarkArrayTestData3
.nCol
= 22;
609 aMarkArrayTestData3
.aMarkedRowSegs
.emplace_back( 20, 20 );
611 MarkArrayTestData aMarkArrayTestData4
;
612 aMarkArrayTestData4
.nCol
= 27;
613 aMarkArrayTestData4
.aMarkedRowSegs
.emplace_back( 7, 15 );
614 aMarkArrayTestData4
.aMarkedRowSegs
.emplace_back( 20, 20 );
616 MarkArrayTestData aMarkArrayTestData5
;
617 aMarkArrayTestData5
.nCol
= 33;
618 aMarkArrayTestData5
.aMarkedRowSegs
.emplace_back( 20, 20 );
620 MarkArrayTestData aMarkArrayTestData6
;
621 aMarkArrayTestData6
.nCol
= 35;
622 aMarkArrayTestData6
.aMarkedRowSegs
.emplace_back( 0, limits
.MaxRow() );
624 MarkArrayTestData aMarkArrayTestData7
;
625 aMarkArrayTestData7
.nCol
= 40;
626 aMarkArrayTestData7
.aMarkedRowSegs
.emplace_back( 20, 20 );
628 aData
.aMarkArrays
.push_back( aMarkArrayTestData1
);
629 aData
.aMarkArrays
.push_back( aMarkArrayTestData2
);
630 aData
.aMarkArrays
.push_back( aMarkArrayTestData3
);
631 aData
.aMarkArrays
.push_back( aMarkArrayTestData4
);
632 aData
.aMarkArrays
.push_back( aMarkArrayTestData5
);
633 aData
.aMarkArrays
.push_back( aMarkArrayTestData6
);
634 aData
.aMarkArrays
.push_back( aMarkArrayTestData7
);
636 aData
.aColsWithOneMark
.emplace_back( 5, 20, 0, 0, 20, 0 );
637 aData
.aColsWithOneMark
.emplace_back( 22, 20, 0, 0, 20, 0 );
638 aData
.aColsWithOneMark
.emplace_back( 32, 20, 0, 0, 20, 0 );
639 aData
.aColsWithOneMark
.emplace_back( 35, 0, 0, 0, limits
.MaxRow(), 0 );
640 aData
.aColsWithOneMark
.emplace_back( 50, 20, 0, 0, 20, 0 );
642 aData
.aColsWithoutOneMark
.push_back( 10 );
643 aData
.aColsWithoutOneMark
.push_back( 15 );
644 aData
.aColsWithoutOneMark
.push_back( 20 );
645 aData
.aColsWithoutOneMark
.push_back( 25 );
646 aData
.aColsWithoutOneMark
.push_back( 30 );
648 aData
.aColsAllMarked
.emplace_back( 10, 5, 0, 0, 10, 0 );
649 aData
.aColsAllMarked
.emplace_back( 15, 5, 0, 0, 10, 0 );
650 aData
.aColsAllMarked
.emplace_back( 5, 20, 0, 0, 20, 0 );
651 aData
.aColsAllMarked
.emplace_back( 10, 20, 0, 0, 20, 0 );
652 aData
.aColsAllMarked
.emplace_back( 25, 7, 0, 0, 15, 0 );
653 aData
.aColsAllMarked
.emplace_back( 30, 7, 0, 0, 15, 0 );
654 aData
.aColsAllMarked
.emplace_back( 35, 0, 0, 0, limits
.MaxRow(), 0 );
655 aData
.aColsAllMarked
.emplace_back( 100, 20, 0, 0, 20, 0 );
657 aData
.aColsNotAllMarked
.emplace_back( 5, 5, 0, 0, 25, 0 );
658 aData
.aColsNotAllMarked
.emplace_back( 15, 5, 0, 0, 25, 0 );
659 aData
.aColsNotAllMarked
.emplace_back( 22, 15, 0, 0, 25, 0 );
660 aData
.aColsNotAllMarked
.emplace_back( 27, 7, 0, 0, 20, 0 );
661 aData
.aColsNotAllMarked
.emplace_back( 100, 19, 0, 0, 21, 0 );
663 aData
.aColsWithEqualMarksList
.emplace_back( 0, 9 );
664 aData
.aColsWithEqualMarksList
.emplace_back( 10, 20 );
665 aData
.aColsWithEqualMarksList
.emplace_back( 21, 24 );
666 aData
.aColsWithEqualMarksList
.emplace_back( 25, 30 );
667 aData
.aColsWithEqualMarksList
.emplace_back( 31, 34 );
668 aData
.aColsWithEqualMarksList
.emplace_back( 36, 100 );
669 aData
.aColsWithEqualMarksList
.emplace_back( 0, 22 );
670 aData
.aColsWithEqualMarksList
.emplace_back( 0, 34 );
672 aData
.aColsWithUnequalMarksList
.emplace_back( 0, 10 );
673 aData
.aColsWithUnequalMarksList
.emplace_back( 0, 20 );
674 aData
.aColsWithUnequalMarksList
.emplace_back( 10, 21 );
675 aData
.aColsWithUnequalMarksList
.emplace_back( 20, 25 );
676 aData
.aColsWithUnequalMarksList
.emplace_back( 20, 30 );
677 aData
.aColsWithUnequalMarksList
.emplace_back( 24, 30 );
678 aData
.aColsWithUnequalMarksList
.emplace_back( 30, 31 );
679 aData
.aColsWithUnequalMarksList
.emplace_back( 30, 34 );
680 aData
.aColsWithUnequalMarksList
.emplace_back( 30, 35 );
681 aData
.aColsWithUnequalMarksList
.emplace_back( 35, 100 );
683 testMultiMark( aData
);
686 void Test::testMultiMark_NegativeMarking()
688 ScSheetLimits
limits( ScSheetLimits::CreateDefault());
689 MultiMarkTestData aData
;
691 // Create full row = 5
692 MarkTestData aSingle1
;
693 aSingle1
.aRange
= ScRange( 0, 5, 0, limits
.MaxCol(), 5, 0 );
694 aSingle1
.bMark
= true;
696 // Create rectangle ( 10, 8, 25, 20 )
697 MarkTestData aSingle2
;
698 aSingle2
.aRange
= ScRange( 10, 8, 0, 25, 20, 0 );
699 aSingle2
.bMark
= true;
701 // Create full row = 12
702 MarkTestData aSingle3
;
703 aSingle3
.aRange
= ScRange( 0, 12, 0, limits
.MaxCol(), 12, 0 );
704 aSingle3
.bMark
= true;
706 // Create deselection rectangle ( 17, 5, 20, 5 )
707 MarkTestData aSingle4
;
708 aSingle4
.aRange
= ScRange( 17, 5, 0, 20, 5, 0 );
709 aSingle4
.bMark
= false;
711 aSingle4
.aInsideAddresses
.emplace_back( 6, 5, 0 );
712 aSingle4
.aInsideAddresses
.emplace_back( 30, 5, 0 );
713 aSingle4
.aInsideAddresses
.emplace_back( 6, 12, 0 );
714 aSingle4
.aInsideAddresses
.emplace_back( 30, 12, 0 );
715 aSingle4
.aInsideAddresses
.emplace_back( 13, 14, 0 );
716 aSingle4
.aInsideAddresses
.emplace_back( 16, 12, 0 );
718 aSingle4
.aOutsideAddresses
.emplace_back( 5, 2, 0 );
719 aSingle4
.aOutsideAddresses
.emplace_back( 18, 5, 0 );
720 aSingle4
.aOutsideAddresses
.emplace_back( 17, 5, 0 );
721 aSingle4
.aOutsideAddresses
.emplace_back( 20, 5, 0 );
722 aSingle4
.aOutsideAddresses
.emplace_back( 18, 7, 0 );
723 aSingle4
.aOutsideAddresses
.emplace_back( 5, 10, 0 );
724 aSingle4
.aOutsideAddresses
.emplace_back( 30, 10, 0 );
725 aSingle4
.aOutsideAddresses
.emplace_back( 5, 14, 0 );
726 aSingle4
.aOutsideAddresses
.emplace_back( 30, 14, 0 );
727 aSingle4
.aOutsideAddresses
.emplace_back( 18, 25, 0 );
729 aSingle4
.aRowsWithFullMarks
.push_back( 12 );
731 aSingle4
.aRowsWithoutFullMarks
.push_back( 5 );
733 aSingle4
.aRangesWithFullMarks
.emplace_back( 5, 5, 0, 16, 5, 0 );
734 aSingle4
.aRangesWithFullMarks
.emplace_back( 21, 5, 0, 30, 5, 0 );
735 aSingle4
.aRangesWithFullMarks
.emplace_back( 5, 12, 0, 9, 12, 0 );
736 aSingle4
.aRangesWithFullMarks
.emplace_back( 26, 12, 0, 30, 12, 0 );
737 aSingle4
.aRangesWithFullMarks
.emplace_back( 10, 8, 0, 25, 20, 0 );
739 aSingle4
.aRangesWithoutFullMarks
.emplace_back( 10, 5, 0, 25, 5, 0 );
741 aSingle4
.aNextMarked
.emplace_back( 18, 7, 0, 0, -1, 0 ); // up fail
742 aSingle4
.aNextMarked
.emplace_back( 18, 4, 0, 1, 8, 0 ); // down ok
744 // Create deselection rectangle ( 15, 10, 18, 14 )
745 MarkTestData aSingle5
;
746 aSingle5
.aRange
= ScRange( 15, 10, 0, 18, 14, 0 );
747 aSingle5
.bMark
= false;
749 aSingle5
.aInsideAddresses
.emplace_back( 6, 5, 0 );
750 aSingle5
.aInsideAddresses
.emplace_back( 30, 5, 0 );
751 aSingle5
.aInsideAddresses
.emplace_back( 6, 12, 0 );
752 aSingle5
.aInsideAddresses
.emplace_back( 30, 12, 0 );
753 aSingle5
.aInsideAddresses
.emplace_back( 13, 14, 0 );
755 aSingle5
.aOutsideAddresses
= aSingle4
.aOutsideAddresses
;
756 aSingle5
.aOutsideAddresses
.emplace_back( 17, 12, 0 );
757 aSingle5
.aOutsideAddresses
.emplace_back( 15, 10, 0 );
758 aSingle5
.aOutsideAddresses
.emplace_back( 18, 10, 0 );
759 aSingle5
.aOutsideAddresses
.emplace_back( 15, 14, 0 );
760 aSingle5
.aOutsideAddresses
.emplace_back( 18, 14, 0 );
762 aSingle5
.aRowsWithoutFullMarks
.push_back( 12 );
763 aSingle5
.aRowsWithoutFullMarks
.push_back( 5 );
765 aSingle5
.aRangesWithoutFullMarks
.emplace_back( 10, 8, 0, 25, 20, 0 );
767 aSingle5
.aNextMarked
= aSingle4
.aNextMarked
;
768 aSingle5
.aNextMarked
.emplace_back( 17, 12, 0, 0, 9, 0 ); // up ok
769 aSingle5
.aNextMarked
.emplace_back( 17, 12, 0, 1, 15, 0 ); // down ok
771 // Add the rectangle data to aData
772 aData
.aMarks
.push_back( aSingle1
);
773 aData
.aMarks
.push_back( aSingle2
);
774 aData
.aMarks
.push_back( aSingle3
);
775 aData
.aMarks
.push_back( aSingle4
);
776 aData
.aMarks
.push_back( aSingle5
);
778 aData
.aSelectionCover
= ScRange( 0, 4, 0, limits
.MaxCol(), 21, 0 );
779 aData
.aLeftEnvelope
.push_back( ScRange( 9, 8, 0, 9, 11, 0 ) );
780 aData
.aLeftEnvelope
.push_back( ScRange( 9, 13, 0, 9, 20, 0 ) );
781 aData
.aLeftEnvelope
.push_back( ScRange( 18, 10, 0, 18, 14, 0 ) );
782 aData
.aLeftEnvelope
.push_back( ScRange( 20, 5, 0, 20, 5, 0 ) );
784 aData
.aRightEnvelope
.push_back( ScRange( 17, 5, 0, 17, 5, 0 ) );
785 aData
.aRightEnvelope
.push_back( ScRange( 15, 10, 0, 15, 14, 0 ) );
786 aData
.aRightEnvelope
.push_back( ScRange( 26, 8, 0, 26, 11, 0 ) );
787 aData
.aRightEnvelope
.push_back( ScRange( 26, 13, 0, 26, 20, 0 ) );
789 aData
.aTopEnvelope
.push_back( ScRange( 0, 4, 0, 16, 4, 0 ) );
790 aData
.aTopEnvelope
.push_back( ScRange( 21, 4, 0, limits
.MaxCol(), 4, 0 ) );
791 aData
.aTopEnvelope
.push_back( ScRange( 10, 7, 0, 25, 7, 0 ) );
792 aData
.aTopEnvelope
.push_back( ScRange( 0, 11, 0, 9, 11, 0 ) );
793 aData
.aTopEnvelope
.push_back( ScRange( 26, 11, 0, limits
.MaxCol(), 11, 0 ) );
794 aData
.aTopEnvelope
.push_back( ScRange( 15, 14, 0, 18, 14, 0 ) );
796 aData
.aBottomEnvelope
.push_back( ScRange( 0, 6, 0, 16, 6, 0 ) );
797 aData
.aBottomEnvelope
.push_back( ScRange( 21, 6, 0, limits
.MaxCol(), 6, 0 ) );
798 aData
.aBottomEnvelope
.push_back( ScRange( 15, 10, 0, 18, 10, 0 ) );
799 aData
.aBottomEnvelope
.push_back( ScRange( 0, 13, 0, 9, 13, 0 ) );
800 aData
.aBottomEnvelope
.push_back( ScRange( 26, 13, 0, limits
.MaxCol(), 13, 0 ) );
801 aData
.aBottomEnvelope
.push_back( ScRange( 10, 21, 0, 25, 21, 0 ) );
803 aData
.aColsWithOneMark
.emplace_back( 19, 8, 0, 0, 20, 0 );
804 aData
.aColsWithOneMark
.emplace_back( 20, 8, 0, 0, 20, 0 );
806 aData
.aColsWithoutOneMark
.push_back( 5 );
807 aData
.aColsWithoutOneMark
.push_back( 10 );
808 aData
.aColsWithoutOneMark
.push_back( 12 );
809 aData
.aColsWithoutOneMark
.push_back( 16 );
810 aData
.aColsWithoutOneMark
.push_back( 17 );
811 aData
.aColsWithoutOneMark
.push_back( 24 );
812 aData
.aColsWithoutOneMark
.push_back( 100 );
814 aData
.aColsAllMarked
.emplace_back( 10, 8, 0, 0, 20, 0 );
815 aData
.aColsAllMarked
.emplace_back( 17, 8, 0, 0, 9, 0 );
816 aData
.aColsAllMarked
.emplace_back( 20, 8, 0, 0, 20, 0 );
817 aData
.aColsAllMarked
.emplace_back( 100, 5, 0, 0, 5, 0 );
818 aData
.aColsAllMarked
.emplace_back( 100, 12, 0, 0, 12, 0 );
820 aData
.aColsNotAllMarked
.emplace_back( 5, 5, 0, 0, 12, 0 );
821 aData
.aColsNotAllMarked
.emplace_back( 10, 5, 0, 0, 20, 0 );
822 aData
.aColsNotAllMarked
.emplace_back( 15, 8, 0, 0, 20, 0 );
823 aData
.aColsNotAllMarked
.emplace_back( 18, 8, 0, 0, 20, 0 );
824 aData
.aColsNotAllMarked
.emplace_back( 25, 5, 0, 0, 20, 0 );
826 aData
.aColsWithEqualMarksList
.emplace_back( 0, 9 );
827 aData
.aColsWithEqualMarksList
.emplace_back( 10, 14 );
828 aData
.aColsWithEqualMarksList
.emplace_back( 15, 16 );
829 aData
.aColsWithEqualMarksList
.emplace_back( 17, 18 );
830 aData
.aColsWithEqualMarksList
.emplace_back( 19, 20 );
831 aData
.aColsWithEqualMarksList
.emplace_back( 21, 25 );
832 aData
.aColsWithEqualMarksList
.emplace_back( 26, 100 );
833 aData
.aColsWithEqualMarksList
.emplace_back( 0, 100 );
835 aData
.aColsWithUnequalMarksList
.emplace_back( 0, 10 );
836 aData
.aColsWithUnequalMarksList
.emplace_back( 10, 15 );
837 aData
.aColsWithUnequalMarksList
.emplace_back( 15, 17 );
838 aData
.aColsWithUnequalMarksList
.emplace_back( 17, 19 );
839 aData
.aColsWithUnequalMarksList
.emplace_back( 19, 21 );
840 aData
.aColsWithUnequalMarksList
.emplace_back( 21, 26 );
842 testMultiMark( aData
);
845 void Test::testInsertTabBeforeSelected()
847 ScMarkData
aMark(ScSheetLimits::CreateDefault());
848 aMark
.SelectOneTable(0);
850 CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark
.GetSelectCount());
851 CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark
.GetFirstSelected());
854 void Test::testInsertTabAfterSelected()
856 ScMarkData
aMark(ScSheetLimits::CreateDefault());
857 aMark
.SelectOneTable(0);
859 CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark
.GetSelectCount());
860 CPPUNIT_ASSERT_EQUAL(SCTAB(0), aMark
.GetFirstSelected());
863 void Test::testDeleteTabBeforeSelected()
865 ScMarkData
aMark(ScSheetLimits::CreateDefault());
866 aMark
.SelectOneTable(1);
868 CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark
.GetSelectCount());
869 CPPUNIT_ASSERT_EQUAL(SCTAB(0), aMark
.GetFirstSelected());
872 void Test::testDeleteTabAfterSelected()
874 ScMarkData
aMark(ScSheetLimits::CreateDefault());
875 aMark
.SelectOneTable(0);
877 CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark
.GetSelectCount());
878 CPPUNIT_ASSERT_EQUAL(SCTAB(0), aMark
.GetFirstSelected());
881 void Test::testScMarkArraySearch_check(const ScMarkArray
& ar
, SCROW nRow
, bool expectStatus
, SCSIZE nIndexExpect
)
884 bool status
= ar
.Search(nRow
, nIndex
);
885 CPPUNIT_ASSERT_EQUAL(expectStatus
, status
);
886 CPPUNIT_ASSERT_EQUAL(nIndexExpect
, nIndex
);
889 void Test::testScMarkArraySearch()
891 ScSheetLimits
limits( ScSheetLimits::CreateDefault());
894 ScMarkArray
ar(limits
);
895 testScMarkArraySearch_check(ar
, -1, true, 0);
896 testScMarkArraySearch_check(ar
, 100, true, 0);
901 ScMarkArray
ar(limits
);
902 ar
.SetMarkArea(10, 20, true);
906 testScMarkArraySearch_check(ar
, -100, true, 0);
907 testScMarkArraySearch_check(ar
, -1, true, 0);
909 testScMarkArraySearch_check(ar
, 0, true, 0);
910 testScMarkArraySearch_check(ar
, 5, true, 0);
911 testScMarkArraySearch_check(ar
, 9, true, 0);
912 testScMarkArraySearch_check(ar
, 10, true, 1);
913 testScMarkArraySearch_check(ar
, 11, true, 1);
914 testScMarkArraySearch_check(ar
, 19, true, 1);
915 testScMarkArraySearch_check(ar
, 20, true, 1);
916 testScMarkArraySearch_check(ar
, 21, true, 2);
917 testScMarkArraySearch_check(ar
, 22, true, 2);
922 ScMarkArray
ar(limits
);
923 ar
.SetMarkArea(10, 20, true);
924 ar
.SetMarkArea(21, 30, true);
925 ar
.SetMarkArea(50, 100, true);
927 // 0-9,10-30,31-49,50-100,101+
929 testScMarkArraySearch_check(ar
, -100, true, 0);
930 testScMarkArraySearch_check(ar
, -1, true, 0);
932 testScMarkArraySearch_check(ar
, 5, true, 0);
933 testScMarkArraySearch_check(ar
, 15, true, 1);
934 testScMarkArraySearch_check(ar
, 25, true, 1);
935 testScMarkArraySearch_check(ar
, 35, true, 2);
936 testScMarkArraySearch_check(ar
, 55, true, 3);
937 testScMarkArraySearch_check(ar
, 20, true, 1);
938 testScMarkArraySearch_check(ar
, 21, true, 1);
941 // three single-row ranges
943 ScMarkArray
ar(limits
);
944 ar
.SetMarkArea(4, 4, true);
945 ar
.SetMarkArea(6, 6, true);
946 ar
.SetMarkArea(8, 8, true);
948 testScMarkArraySearch_check(ar
, -100, true, 0);
949 testScMarkArraySearch_check(ar
, -1, true, 0);
951 testScMarkArraySearch_check(ar
, 3, true, 0);
952 testScMarkArraySearch_check(ar
, 4, true, 1);
953 testScMarkArraySearch_check(ar
, 5, true, 2);
954 testScMarkArraySearch_check(ar
, 6, true, 3);
955 testScMarkArraySearch_check(ar
, 7, true, 4);
956 testScMarkArraySearch_check(ar
, 8, true, 5);
957 testScMarkArraySearch_check(ar
, 9, true, 6);
958 testScMarkArraySearch_check(ar
, 10, true, 6);
963 ScMarkArray
ar(limits
);
964 ar
.SetMarkArea(10, limits
.MaxRow(), true);
968 testScMarkArraySearch_check(ar
, -100, true, 0);
969 testScMarkArraySearch_check(ar
, -1, true, 0);
971 testScMarkArraySearch_check(ar
, 0, true, 0);
972 testScMarkArraySearch_check(ar
, 5, true, 0);
973 testScMarkArraySearch_check(ar
, 9, true, 0);
974 testScMarkArraySearch_check(ar
, 10, true, 1);
975 testScMarkArraySearch_check(ar
, 11, true, 1);
976 testScMarkArraySearch_check(ar
, 12, true, 1);
977 testScMarkArraySearch_check(ar
, 200, true, 1);
978 testScMarkArraySearch_check(ar
, limits
.MaxRow(), true, 1);
982 void Test::testIsAllMarked()
984 ScSheetLimits
limits( ScSheetLimits::CreateDefault());
985 ScMarkData
mark(limits
);
986 ScRange
range1( ScAddress( 5, 10, 0 ), ScAddress( 15, 20, 0 ));
987 ScRange
range2( ScAddress( 2, 2, 0 ), ScAddress( 25, 30, 0 ));
988 CPPUNIT_ASSERT( !mark
.IsAllMarked( range1
));
989 CPPUNIT_ASSERT( !mark
.IsAllMarked( range2
));
991 CPPUNIT_ASSERT( !mark
.IsAllMarked( range1
));
992 CPPUNIT_ASSERT( !mark
.IsAllMarked( range2
));
995 mark
.SetMarkArea( range1
);
996 CPPUNIT_ASSERT( mark
.IsAllMarked( range1
));
997 CPPUNIT_ASSERT( !mark
.IsAllMarked( range2
));
999 CPPUNIT_ASSERT( mark
.IsAllMarked( range1
));
1000 CPPUNIT_ASSERT( !mark
.IsAllMarked( range2
));
1003 mark
.SetMarkArea( range2
);
1004 CPPUNIT_ASSERT( mark
.IsAllMarked( range1
));
1005 CPPUNIT_ASSERT( mark
.IsAllMarked( range2
));
1007 CPPUNIT_ASSERT( mark
.IsAllMarked( range1
));
1008 CPPUNIT_ASSERT( mark
.IsAllMarked( range2
));
1011 CPPUNIT_TEST_SUITE_REGISTRATION(Test
);
1013 CPPUNIT_PLUGIN_IMPLEMENT();
1015 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */