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 rRangeListOut
.insert(rRangeListOut
.end(), rRangeList
.begin(), rRangeList
.end());
140 std::sort(rRangeListOut
.begin(), rRangeListOut
.end());
143 void Test::testSimpleMark( const ScRange
& rRange
, const ScRange
& rSelectionCover
,
144 const ScRangeList
& rLeftEnvelope
, const ScRangeList
& rRightEnvelope
,
145 const ScRangeList
& rTopEnvelope
, const ScRangeList
& rBottomEnvelope
,
146 const ScSheetLimits
& rLimits
)
148 ScMarkData
aMark(rLimits
);
149 CPPUNIT_ASSERT( !aMark
.IsMarked() );
150 CPPUNIT_ASSERT( !aMark
.IsMultiMarked() );
152 aMark
.SetMarkArea( rRange
);
153 CPPUNIT_ASSERT( aMark
.IsMarked() );
154 CPPUNIT_ASSERT( !aMark
.IsMultiMarked() );
156 CPPUNIT_ASSERT_EQUAL( rRange
, aMark
.GetMarkArea() );
158 SCROW nMidRow
= ( rRange
.aStart
.Row() + rRange
.aEnd
.Row() ) / 2;
159 SCCOL nMidCol
= ( rRange
.aStart
.Col() + rRange
.aEnd
.Col() ) / 2;
160 SCROW nOutRow1
= rRange
.aEnd
.Row() + 1;
161 SCCOL nOutCol1
= rRange
.aEnd
.Col() + 1;
162 SCROW nOutRow2
= rRange
.aStart
.Row() - 1;
163 SCCOL nOutCol2
= rRange
.aStart
.Col() - 1;
165 CPPUNIT_ASSERT( aMark
.IsCellMarked( nMidCol
, nMidRow
) );
166 if ( ValidCol( nOutCol1
, rLimits
.MaxCol() ) && ValidRow( nOutRow1
, rLimits
.MaxRow() ) )
167 CPPUNIT_ASSERT( !aMark
.IsCellMarked( nOutCol1
, nOutRow1
) );
169 if ( ValidCol( nOutCol2
, rLimits
.MaxCol() ) && ValidRow( nOutRow2
, rLimits
.MaxRow() ) )
170 CPPUNIT_ASSERT( !aMark
.IsCellMarked( nOutCol2
, nOutRow2
) );
172 if ( ValidRow( nOutRow1
, rLimits
.MaxRow() ) )
173 CPPUNIT_ASSERT( !aMark
.IsCellMarked( nMidCol
, nOutRow1
) );
175 if ( ValidCol( nOutCol1
, rLimits
.MaxCol() ) )
176 CPPUNIT_ASSERT( !aMark
.IsCellMarked( nOutCol1
, nMidRow
) );
178 if ( ValidRow( nOutRow2
, rLimits
.MaxRow() ) )
179 CPPUNIT_ASSERT( !aMark
.IsCellMarked( nMidCol
, nOutRow2
) );
181 if ( ValidCol( nOutCol2
, rLimits
.MaxCol() ) )
182 CPPUNIT_ASSERT( !aMark
.IsCellMarked( nOutCol2
, nMidRow
) );
184 if ( rRange
.aStart
.Row() == 0 && rRange
.aEnd
.Row() == rLimits
.MaxRow() )
185 CPPUNIT_ASSERT( aMark
.IsColumnMarked( nMidCol
) );
187 CPPUNIT_ASSERT( !aMark
.IsColumnMarked( nMidCol
) );
188 if ( rRange
.aStart
.Col() == 0 && rRange
.aEnd
.Col() == rLimits
.MaxCol() )
189 CPPUNIT_ASSERT( aMark
.IsRowMarked( nMidRow
) );
191 CPPUNIT_ASSERT( !aMark
.IsRowMarked( nMidRow
) );
193 ScRange aSelectionCoverOutput
;
194 aMark
.GetSelectionCover( aSelectionCoverOutput
);
195 CPPUNIT_ASSERT_EQUAL( rSelectionCover
, aSelectionCoverOutput
);
196 CPPUNIT_ASSERT_EQUAL( rLeftEnvelope
, aMark
.GetLeftEnvelope() );
197 CPPUNIT_ASSERT_EQUAL( rRightEnvelope
, aMark
.GetRightEnvelope() );
198 CPPUNIT_ASSERT_EQUAL( rTopEnvelope
, aMark
.GetTopEnvelope() );
199 CPPUNIT_ASSERT_EQUAL( rBottomEnvelope
, aMark
.GetBottomEnvelope() );
202 void Test::testSimpleMark_Simple()
204 ScSheetLimits
limits( ScSheetLimits::CreateDefault());
205 testSimpleMark( ScRange( 10, 15, 0, 20, 30, 0 ), // Simple range
206 ScRange( 9, 14, 0, 21, 31, 0 ), // Cover
207 ScRangeList( ScRange( 9, 15, 0, 9, 30, 0 ) ), // Left envelope
208 ScRangeList( ScRange( 21, 15, 0, 21, 30, 0 ) ), // Right envelope
209 ScRangeList( ScRange( 10, 14, 0, 20, 14, 0 ) ), // Top envelope
210 ScRangeList( ScRange( 10, 31, 0, 20, 31, 0 ) ), // Bottom envelope
214 void Test::testSimpleMark_Column()
216 ScSheetLimits
limits( ScSheetLimits::CreateDefault());
217 // Column 10, rows from 15 to 30
218 testSimpleMark( ScRange( 10, 15, 0, 10, 30, 0 ), // Simple range
219 ScRange( 9, 14, 0, 11, 31, 0 ), // Cover
220 ScRangeList( ScRange( 9, 15, 0, 9, 30, 0 ) ), // Left envelope
221 ScRangeList( ScRange( 11, 15, 0, 11, 30, 0 ) ), // Right envelope
222 ScRangeList( ScRange( 10, 14, 0, 10, 14, 0 ) ), // Top envelope
223 ScRangeList( ScRange( 10, 31, 0, 10, 31, 0 ) ), // Bottom envelope
227 testSimpleMark( ScRange( 10, 0, 0, 10, limits
.MaxRow(), 0 ), // Simple range
228 ScRange( 9, 0, 0, 11, limits
.MaxRow(), 0 ), // Cover
229 ScRangeList( ScRange( 9, 0, 0, 9, limits
.MaxRow(), 0 ) ), // Left envelope
230 ScRangeList( ScRange( 11, 0, 0, 11, limits
.MaxRow(), 0 ) ), // Right envelope
231 ScRangeList(), // Top envelope
232 ScRangeList(), // Bottom envelope
236 void Test::testSimpleMark_Row()
238 ScSheetLimits
limits( ScSheetLimits::CreateDefault());
239 // Row 15, cols from 10 to 20
240 testSimpleMark( ScRange( 10, 15, 0, 20, 15, 0 ), // Simple range
241 ScRange( 9, 14, 0, 21, 16, 0 ), // Cover
242 ScRangeList( ScRange( 9, 15, 0, 9, 15, 0 ) ), // Left envelope
243 ScRangeList( ScRange( 21, 15, 0, 21, 15, 0 ) ), // Right envelope
244 ScRangeList( ScRange( 10, 14, 0, 20, 14, 0 ) ), // Top envelope
245 ScRangeList( ScRange( 10, 16, 0, 20, 16, 0 ) ), // Bottom envelope
249 testSimpleMark( ScRange( 0, 15, 0, limits
.MaxCol(), 15, 0 ), // Simple range
250 ScRange( 0, 14, 0, limits
.MaxCol(), 16, 0 ), // Cover
251 ScRangeList(), // Left envelope
252 ScRangeList(), // Right envelope
253 ScRangeList( ScRange( 0, 14, 0, limits
.MaxCol(), 14, 0 ) ), // Top envelope
254 ScRangeList( ScRange( 0, 16, 0, limits
.MaxCol(), 16, 0 ) ), // Bottom envelope
258 void Test::testMultiMark( const MultiMarkTestData
& rMarksData
)
260 ScSheetLimits
limits( ScSheetLimits::CreateDefault());
261 ScMarkData
aMark(limits
);
262 ScMultiSel
aMultiSel(limits
);
263 CPPUNIT_ASSERT( !aMark
.IsMarked() );
264 CPPUNIT_ASSERT( !aMark
.IsMultiMarked() );
265 CPPUNIT_ASSERT_EQUAL( SCCOL(0), aMultiSel
.GetMultiSelectionCount() );
266 CPPUNIT_ASSERT( !aMultiSel
.HasAnyMarks() );
268 for ( const auto& rAreaTestData
: rMarksData
.aMarks
)
270 aMultiSel
.SetMarkArea( rAreaTestData
.aRange
.aStart
.Col(), rAreaTestData
.aRange
.aEnd
.Col(),
271 rAreaTestData
.aRange
.aStart
.Row(), rAreaTestData
.aRange
.aEnd
.Row(),
272 rAreaTestData
.bMark
);
273 aMark
.SetMultiMarkArea( rAreaTestData
.aRange
, rAreaTestData
.bMark
);
274 CPPUNIT_ASSERT( aMark
.IsMultiMarked() );
276 for ( const auto& rMarkedAddress
: rAreaTestData
.aInsideAddresses
)
278 CPPUNIT_ASSERT( aMultiSel
.GetMark( rMarkedAddress
.Col(), rMarkedAddress
.Row() ) );
279 CPPUNIT_ASSERT( aMark
.IsCellMarked( rMarkedAddress
.Col(), rMarkedAddress
.Row() ) );
282 for ( const auto& rUnMarkedAddress
: rAreaTestData
.aOutsideAddresses
)
284 CPPUNIT_ASSERT( !aMark
.IsCellMarked( rUnMarkedAddress
.Col(), rUnMarkedAddress
.Row() ) );
285 CPPUNIT_ASSERT( !aMark
.IsCellMarked( rUnMarkedAddress
.Col(), rUnMarkedAddress
.Row() ) );
288 for ( const auto& rCol
: rAreaTestData
.aColumnsWithFullMarks
)
290 CPPUNIT_ASSERT( aMark
.IsColumnMarked( rCol
) );
291 CPPUNIT_ASSERT( aMultiSel
.IsAllMarked( rCol
, 0, limits
.MaxRow() ) );
294 for ( const auto& rCol
: rAreaTestData
.aColumnsWithoutFullMarks
)
296 CPPUNIT_ASSERT( !aMark
.IsColumnMarked( rCol
) );
297 CPPUNIT_ASSERT( !aMultiSel
.IsAllMarked( rCol
, 0, limits
.MaxRow() ) );
300 for ( const auto& rRow
: rAreaTestData
.aRowsWithFullMarks
)
302 CPPUNIT_ASSERT( aMark
.IsRowMarked( rRow
) );
303 CPPUNIT_ASSERT( aMultiSel
.IsRowMarked( rRow
) );
306 for ( const auto& rRow
: rAreaTestData
.aRowsWithoutFullMarks
)
308 CPPUNIT_ASSERT( !aMark
.IsRowMarked( rRow
) );
309 CPPUNIT_ASSERT( !aMultiSel
.IsRowMarked( rRow
) );
312 for ( const auto& rRange
: rAreaTestData
.aRangesWithFullMarks
)
314 CPPUNIT_ASSERT( aMark
.IsAllMarked( rRange
) );
315 SCROW nRow1
= rRange
.aStart
.Row(), nRow2
= rRange
.aEnd
.Row();
316 SCCOL nCol1
= rRange
.aStart
.Col(), nCol2
= rRange
.aEnd
.Col();
317 for ( SCCOL nColIter
= nCol1
; nColIter
<= nCol2
; ++nColIter
)
318 CPPUNIT_ASSERT( aMultiSel
.IsAllMarked( nColIter
, nRow1
, nRow2
) );
321 for ( const auto& rRange
: rAreaTestData
.aRangesWithoutFullMarks
)
322 CPPUNIT_ASSERT( !aMark
.IsAllMarked( rRange
) );
324 for ( const auto& rRange
: rAreaTestData
.aNextMarked
)
326 SCROW nNextRow1
= aMark
.GetNextMarked( rRange
.aStart
.Col(), rRange
.aStart
.Row(), !static_cast<bool>(rRange
.aEnd
.Col()) );
327 CPPUNIT_ASSERT_EQUAL( rRange
.aEnd
.Row(), nNextRow1
);
328 SCROW nNextRow2
= aMultiSel
.GetNextMarked( rRange
.aStart
.Col(), rRange
.aStart
.Row(), !static_cast<bool>(rRange
.aEnd
.Col()) );
329 CPPUNIT_ASSERT_EQUAL( rRange
.aEnd
.Row(), nNextRow2
);
332 for ( const auto& rCol
: rAreaTestData
.aColumnsWithAtLeastOneMark
)
334 CPPUNIT_ASSERT( aMark
.HasMultiMarks( rCol
) );
335 CPPUNIT_ASSERT( aMultiSel
.HasMarks( rCol
) );
338 for ( const auto& rCol
: rAreaTestData
.aColumnsWithoutAnyMarks
)
340 CPPUNIT_ASSERT( !aMark
.HasMultiMarks( rCol
) );
341 CPPUNIT_ASSERT( !aMultiSel
.HasMarks( rCol
) );
346 ScRange aSelectionCoverOutput
;
347 aMark
.GetSelectionCover( aSelectionCoverOutput
);
348 CPPUNIT_ASSERT_EQUAL( rMarksData
.aSelectionCover
, aSelectionCoverOutput
);
350 ScRangeList aRangesExpected
, aRangesActual
;
351 lcl_GetSortedRanges( rMarksData
.aLeftEnvelope
, aRangesExpected
);
352 lcl_GetSortedRanges( aMark
.GetLeftEnvelope(), aRangesActual
);
353 CPPUNIT_ASSERT_EQUAL( aRangesExpected
, aRangesActual
);
354 lcl_GetSortedRanges( rMarksData
.aRightEnvelope
, aRangesExpected
);
355 lcl_GetSortedRanges( aMark
.GetRightEnvelope(), aRangesActual
);
356 CPPUNIT_ASSERT_EQUAL( aRangesExpected
, aRangesActual
);
357 lcl_GetSortedRanges( rMarksData
.aTopEnvelope
, aRangesExpected
);
358 lcl_GetSortedRanges( aMark
.GetTopEnvelope(), aRangesActual
);
359 CPPUNIT_ASSERT_EQUAL( aRangesExpected
, aRangesActual
);
360 lcl_GetSortedRanges( rMarksData
.aBottomEnvelope
, aRangesExpected
);
361 lcl_GetSortedRanges( aMark
.GetBottomEnvelope(), aRangesActual
);
362 CPPUNIT_ASSERT_EQUAL( aRangesExpected
, aRangesActual
);
364 for ( const auto& rMarkArrayTestData
: rMarksData
.aMarkArrays
)
366 ScMarkArray
aArray( aMark
.GetMarkArray( rMarkArrayTestData
.nCol
) );
367 std::vector
<std::pair
<SCROW
, SCROW
>> aMarkedRowSegs
;
368 ScMarkArrayIter
aIter( &aArray
);
370 while ( aIter
.Next( nStart
, nEnd
) )
371 aMarkedRowSegs
.emplace_back( nStart
, nEnd
);
373 CPPUNIT_ASSERT_EQUAL( rMarkArrayTestData
.aMarkedRowSegs
.size(), aMarkedRowSegs
.size() );
375 for ( const auto& rPair
: rMarkArrayTestData
.aMarkedRowSegs
)
377 CPPUNIT_ASSERT_EQUAL( rPair
.first
, aMarkedRowSegs
[nIdx
].first
);
378 CPPUNIT_ASSERT_EQUAL( rPair
.second
, aMarkedRowSegs
[nIdx
].second
);
383 for ( const auto& rColWithOneMark
: rMarksData
.aColsWithOneMark
)
385 SCROW nRow1
= -1, nRow2
= -1;
386 CPPUNIT_ASSERT( aMultiSel
.HasOneMark( rColWithOneMark
.aStart
.Col(), nRow1
, nRow2
) );
387 CPPUNIT_ASSERT_EQUAL( rColWithOneMark
.aStart
.Row(), nRow1
);
388 CPPUNIT_ASSERT_EQUAL( rColWithOneMark
.aEnd
.Row(), nRow2
);
392 SCROW nRow1
= -1, nRow2
= -1;
393 for ( const SCCOL
& rCol
: rMarksData
.aColsWithoutOneMark
)
394 CPPUNIT_ASSERT( !aMultiSel
.HasOneMark( rCol
, nRow1
, nRow2
) );
397 for ( const auto& rColAllMarked
: rMarksData
.aColsAllMarked
)
398 CPPUNIT_ASSERT( aMultiSel
.IsAllMarked( rColAllMarked
.aStart
.Col(),
399 rColAllMarked
.aStart
.Row(),
400 rColAllMarked
.aEnd
.Row() ) );
402 for ( const auto& rColNotAllMarked
: rMarksData
.aColsNotAllMarked
)
403 CPPUNIT_ASSERT( !aMultiSel
.IsAllMarked( rColNotAllMarked
.aStart
.Col(),
404 rColNotAllMarked
.aStart
.Row(),
405 rColNotAllMarked
.aEnd
.Row() ) );
407 for ( const auto& rColsWithEqualMarks
: rMarksData
.aColsWithEqualMarksList
)
408 CPPUNIT_ASSERT( aMultiSel
.HasEqualRowsMarked( rColsWithEqualMarks
.first
, rColsWithEqualMarks
.second
) );
410 for ( const auto& rColsWithUnequalMarks
: rMarksData
.aColsWithUnequalMarksList
)
411 CPPUNIT_ASSERT( !aMultiSel
.HasEqualRowsMarked( rColsWithUnequalMarks
.first
, rColsWithUnequalMarks
.second
) );
414 CPPUNIT_ASSERT_EQUAL( SCCOL(0), aMultiSel
.GetMultiSelectionCount() );
415 CPPUNIT_ASSERT( !aMultiSel
.HasAnyMarks() );
418 void Test::testMultiMark_FourRanges()
420 ScSheetLimits
limits( ScSheetLimits::CreateDefault());
421 MultiMarkTestData aData
;
422 MarkTestData aSingle1
;
424 // Create rectangle ( 10, 5, 20, 10 )
425 aSingle1
.aRange
= ScRange( 10, 5, 0, 20, 10, 0 );
426 aSingle1
.bMark
= true;
428 aSingle1
.aInsideAddresses
.emplace_back( 15, 6, 0 );
429 aSingle1
.aInsideAddresses
.emplace_back( 10, 5, 0 );
430 aSingle1
.aInsideAddresses
.emplace_back( 20, 5, 0 );
431 aSingle1
.aInsideAddresses
.emplace_back( 10, 10, 0 );
432 aSingle1
.aInsideAddresses
.emplace_back( 20, 10, 0 );
434 aSingle1
.aOutsideAddresses
.emplace_back( 15, 4, 0 );
435 aSingle1
.aOutsideAddresses
.emplace_back( 15, 11, 0 );
436 aSingle1
.aOutsideAddresses
.emplace_back( 9, 6, 0 );
437 aSingle1
.aOutsideAddresses
.emplace_back( 21, 6, 0 );
438 aSingle1
.aOutsideAddresses
.emplace_back( 26, 10, 0 );
440 aSingle1
.aColumnsWithoutFullMarks
.push_back( 16 );
441 aSingle1
.aColumnsWithoutFullMarks
.push_back( 21 );
443 aSingle1
.aRowsWithoutFullMarks
.push_back( 7 );
444 aSingle1
.aRowsWithoutFullMarks
.push_back( 11 );
446 aSingle1
.aRangesWithFullMarks
.emplace_back( 10, 5, 0, 20, 10, 0 );
447 aSingle1
.aRangesWithFullMarks
.emplace_back( 11, 6, 0, 19, 8, 0 );
449 aSingle1
.aRangesWithoutFullMarks
.emplace_back( 9, 4, 0, 21, 11, 0 );
450 aSingle1
.aRangesWithoutFullMarks
.emplace_back( 25, 7, 0, 30, 15, 0 );
452 aSingle1
.aNextMarked
.emplace_back( 15, 1, 0, 1, 5, 0 ); // Search down
453 aSingle1
.aNextMarked
.emplace_back( 15, 15, 0, 0, 10, 0 ); // Search up
455 aSingle1
.aNextMarked
.emplace_back( 15, 15, 0, 1, limits
.GetMaxRowCount(), 0 ); // Search down fail
456 aSingle1
.aNextMarked
.emplace_back( 15, 4, 0, 0, -1, 0 ); // Search up fail
458 aSingle1
.aColumnsWithAtLeastOneMark
.push_back( 10 );
459 aSingle1
.aColumnsWithAtLeastOneMark
.push_back( 15 );
460 aSingle1
.aColumnsWithAtLeastOneMark
.push_back( 20 );
462 aSingle1
.aColumnsWithoutAnyMarks
.push_back( 21 );
463 aSingle1
.aColumnsWithoutAnyMarks
.push_back( 9 );
465 // Create rectangle ( 25, 7, 30, 15 )
466 MarkTestData aSingle2
;
467 aSingle2
.aRange
= ScRange( 25, 7, 0, 30, 15, 0 );
468 aSingle2
.bMark
= true;
470 aSingle2
.aInsideAddresses
= aSingle1
.aInsideAddresses
;
471 aSingle2
.aInsideAddresses
.emplace_back( 27, 10, 0 );
472 aSingle2
.aInsideAddresses
.emplace_back( 25, 7, 0 );
473 aSingle2
.aInsideAddresses
.emplace_back( 30, 7, 0 );
474 aSingle2
.aInsideAddresses
.emplace_back( 25, 15, 0 );
475 aSingle2
.aInsideAddresses
.emplace_back( 30, 15, 0 );
477 aSingle2
.aOutsideAddresses
.emplace_back( 15, 4, 0 );
478 aSingle2
.aOutsideAddresses
.emplace_back( 15, 11, 0 );
479 aSingle2
.aOutsideAddresses
.emplace_back( 9, 6, 0 );
480 aSingle2
.aOutsideAddresses
.emplace_back( 21, 6, 0 );
481 aSingle2
.aOutsideAddresses
.emplace_back( 26, 6, 0 );
482 aSingle2
.aOutsideAddresses
.emplace_back( 26, 16, 0 );
483 aSingle2
.aOutsideAddresses
.emplace_back( 24, 8, 0 );
484 aSingle2
.aOutsideAddresses
.emplace_back( 31, 11, 0 );
486 aSingle2
.aColumnsWithoutFullMarks
= aSingle1
.aColumnsWithoutAnyMarks
;
488 aSingle2
.aRowsWithoutFullMarks
= aSingle1
.aRowsWithoutFullMarks
;
490 aSingle2
.aRangesWithFullMarks
= aSingle1
.aRangesWithFullMarks
;
491 aSingle2
.aRangesWithFullMarks
.emplace_back( 25, 7, 0, 30, 15, 0 );
492 aSingle2
.aRangesWithFullMarks
.emplace_back( 26, 8, 0, 29, 14, 0 );
494 aSingle2
.aRangesWithoutFullMarks
.emplace_back( 9, 4, 0, 21, 11, 0 );
495 aSingle2
.aRangesWithoutFullMarks
.emplace_back( 24, 6, 0, 31, 16, 0 );
496 aSingle2
.aRangesWithoutFullMarks
.emplace_back( 10, 5, 0, 30, 15, 0 );
498 aSingle2
.aNextMarked
.emplace_back( 27, 16, 0, 0, 15, 0 ); // up ok
499 aSingle2
.aNextMarked
.emplace_back( 27, 4, 0, 1, 7, 0 ); // down ok
500 aSingle2
.aNextMarked
.emplace_back( 27, 4, 0, 0, -1, 0 ); // up fail
501 aSingle2
.aNextMarked
.emplace_back( 27, 16, 0, 1, limits
.GetMaxRowCount(), 0 ); // down fail
503 aSingle2
.aColumnsWithAtLeastOneMark
= aSingle1
.aColumnsWithAtLeastOneMark
;
504 aSingle2
.aColumnsWithAtLeastOneMark
.push_back( 25 );
505 aSingle2
.aColumnsWithAtLeastOneMark
.push_back( 27 );
506 aSingle2
.aColumnsWithAtLeastOneMark
.push_back( 30 );
508 aSingle2
.aColumnsWithoutAnyMarks
.push_back( 9 );
509 aSingle2
.aColumnsWithoutAnyMarks
.push_back( 21 );
510 aSingle2
.aColumnsWithoutAnyMarks
.push_back( 24 );
511 aSingle2
.aColumnsWithoutAnyMarks
.push_back( 31 );
514 MarkTestData aSingle3
;
516 aSingle3
.aRange
= ScRange( 0, 20, 0, limits
.MaxCol(), 20, 0 );
517 aSingle3
.bMark
= true;
519 aSingle3
.aInsideAddresses
= aSingle2
.aInsideAddresses
;
520 aSingle3
.aInsideAddresses
.emplace_back( 5, 20, 0 );
521 aSingle3
.aInsideAddresses
.emplace_back( 100, 20, 0 );
523 aSingle3
.aOutsideAddresses
.emplace_back( 0, 21, 0 );
524 aSingle3
.aOutsideAddresses
.emplace_back( 27, 19, 0 );
526 aSingle3
.aColumnsWithoutFullMarks
= aSingle2
.aColumnsWithoutAnyMarks
;
528 aSingle3
.aRowsWithFullMarks
.push_back( 20 );
530 aSingle3
.aRangesWithFullMarks
= aSingle2
.aRangesWithFullMarks
;
531 aSingle3
.aRangesWithFullMarks
.emplace_back( 0, 20, 0, limits
.MaxCol(), 20, 0 );
532 aSingle3
.aRangesWithFullMarks
.emplace_back( 15, 20, 0, 55, 20, 0 );
534 aSingle3
.aNextMarked
.emplace_back( 15, 16, 0, 0, 10, 0 ); // up ok
535 aSingle3
.aNextMarked
.emplace_back( 15, 16, 0, 1, 20, 0 ); // down ok
536 aSingle3
.aNextMarked
.emplace_back( 22, 15, 0, 0, -1, 0 ); // up fail
537 aSingle3
.aNextMarked
.emplace_back( 22, 25, 0, 1, limits
.GetMaxRowCount(), 0 ); // down fail
539 aSingle3
.aColumnsWithAtLeastOneMark
= aSingle2
.aColumnsWithAtLeastOneMark
;
540 aSingle3
.aColumnsWithAtLeastOneMark
.push_back( 39 );
543 MarkTestData aSingle4
;
545 aSingle4
.aRange
= ScRange( 35, 0, 0, 35, limits
.MaxRow(), 0 );
546 aSingle4
.bMark
= true;
548 aSingle4
.aInsideAddresses
= aSingle3
.aInsideAddresses
;
549 aSingle4
.aInsideAddresses
.emplace_back( 35, 10, 0 );
550 aSingle4
.aInsideAddresses
.emplace_back( 35, 25, 0 );
552 aSingle4
.aOutsideAddresses
.emplace_back( 33, 10, 0 );
553 aSingle4
.aOutsideAddresses
.emplace_back( 39, 10, 0 );
554 aSingle4
.aOutsideAddresses
.emplace_back( 33, 25, 0 );
555 aSingle4
.aOutsideAddresses
.emplace_back( 39, 25, 0 );
557 aSingle4
.aColumnsWithFullMarks
.push_back( 35 );
559 aSingle4
.aRowsWithFullMarks
.push_back( 20 );
561 aSingle4
.aRangesWithFullMarks
= aSingle3
.aRangesWithFullMarks
;
562 aSingle4
.aRangesWithFullMarks
.emplace_back( 35, 0, 0, 35, limits
.MaxRow(), 0 );
563 aSingle4
.aRangesWithFullMarks
.emplace_back( 35, 10, 0, 35, 25, 0 );
565 // Add the rectangle data to aData
566 aData
.aMarks
.push_back( aSingle1
);
567 aData
.aMarks
.push_back( aSingle2
);
568 aData
.aMarks
.push_back( aSingle3
);
569 aData
.aMarks
.push_back( aSingle4
);
571 aData
.aSelectionCover
= ScRange( 0, 0, 0, limits
.MaxCol(), limits
.MaxRow(), 0 );
572 aData
.aLeftEnvelope
.push_back( ScRange( 9, 5, 0, 9, 10, 0 ) );
573 aData
.aLeftEnvelope
.push_back( ScRange( 24, 7, 0, 24, 15, 0 ) );
574 aData
.aLeftEnvelope
.push_back( ScRange( 34, 0, 0, 34, 19, 0 ) );
575 aData
.aLeftEnvelope
.push_back( ScRange( 34, 21, 0, 34, limits
.MaxRow(), 0 ) );
577 aData
.aRightEnvelope
.push_back( ScRange( 21, 5, 0, 21, 10, 0 ) );
578 aData
.aRightEnvelope
.push_back( ScRange( 31, 7, 0, 31, 15, 0 ) );
579 aData
.aRightEnvelope
.push_back( ScRange( 36, 0, 0, 36, 19, 0 ) );
580 aData
.aRightEnvelope
.push_back( ScRange( 36, 21, 0, 36, limits
.MaxRow(), 0 ) );
582 aData
.aTopEnvelope
.push_back( ScRange( 10, 4, 0, 20, 4, 0 ) );
583 aData
.aTopEnvelope
.push_back( ScRange( 25, 6, 0, 30, 6, 0 ) );
584 aData
.aTopEnvelope
.push_back( ScRange( 0, 19, 0, 34, 19, 0 ) );
585 aData
.aTopEnvelope
.push_back( ScRange( 36, 19, 0, limits
.MaxCol(), 19, 0 ) );
587 aData
.aBottomEnvelope
.push_back( ScRange( 10, 11, 0, 20, 11, 0 ) );
588 aData
.aBottomEnvelope
.push_back( ScRange( 25, 16, 0, 30, 16, 0 ) );
589 aData
.aBottomEnvelope
.push_back( ScRange( 0, 21, 0, 34, 21, 0 ) );
590 aData
.aBottomEnvelope
.push_back( ScRange( 36, 21, 0, limits
.MaxCol(), 21, 0 ) );
592 MarkArrayTestData aMarkArrayTestData1
;
593 aMarkArrayTestData1
.nCol
= 5;
594 aMarkArrayTestData1
.aMarkedRowSegs
.emplace_back( 20, 20 );
596 MarkArrayTestData aMarkArrayTestData2
;
597 aMarkArrayTestData2
.nCol
= 15;
598 aMarkArrayTestData2
.aMarkedRowSegs
.emplace_back( 5, 10 );
599 aMarkArrayTestData2
.aMarkedRowSegs
.emplace_back( 20, 20 );
601 MarkArrayTestData aMarkArrayTestData3
;
602 aMarkArrayTestData3
.nCol
= 22;
603 aMarkArrayTestData3
.aMarkedRowSegs
.emplace_back( 20, 20 );
605 MarkArrayTestData aMarkArrayTestData4
;
606 aMarkArrayTestData4
.nCol
= 27;
607 aMarkArrayTestData4
.aMarkedRowSegs
.emplace_back( 7, 15 );
608 aMarkArrayTestData4
.aMarkedRowSegs
.emplace_back( 20, 20 );
610 MarkArrayTestData aMarkArrayTestData5
;
611 aMarkArrayTestData5
.nCol
= 33;
612 aMarkArrayTestData5
.aMarkedRowSegs
.emplace_back( 20, 20 );
614 MarkArrayTestData aMarkArrayTestData6
;
615 aMarkArrayTestData6
.nCol
= 35;
616 aMarkArrayTestData6
.aMarkedRowSegs
.emplace_back( 0, limits
.MaxRow() );
618 MarkArrayTestData aMarkArrayTestData7
;
619 aMarkArrayTestData7
.nCol
= 40;
620 aMarkArrayTestData7
.aMarkedRowSegs
.emplace_back( 20, 20 );
622 aData
.aMarkArrays
.push_back( aMarkArrayTestData1
);
623 aData
.aMarkArrays
.push_back( aMarkArrayTestData2
);
624 aData
.aMarkArrays
.push_back( aMarkArrayTestData3
);
625 aData
.aMarkArrays
.push_back( aMarkArrayTestData4
);
626 aData
.aMarkArrays
.push_back( aMarkArrayTestData5
);
627 aData
.aMarkArrays
.push_back( aMarkArrayTestData6
);
628 aData
.aMarkArrays
.push_back( aMarkArrayTestData7
);
630 aData
.aColsWithOneMark
.emplace_back( 5, 20, 0, 0, 20, 0 );
631 aData
.aColsWithOneMark
.emplace_back( 22, 20, 0, 0, 20, 0 );
632 aData
.aColsWithOneMark
.emplace_back( 32, 20, 0, 0, 20, 0 );
633 aData
.aColsWithOneMark
.emplace_back( 35, 0, 0, 0, limits
.MaxRow(), 0 );
634 aData
.aColsWithOneMark
.emplace_back( 50, 20, 0, 0, 20, 0 );
636 aData
.aColsWithoutOneMark
.push_back( 10 );
637 aData
.aColsWithoutOneMark
.push_back( 15 );
638 aData
.aColsWithoutOneMark
.push_back( 20 );
639 aData
.aColsWithoutOneMark
.push_back( 25 );
640 aData
.aColsWithoutOneMark
.push_back( 30 );
642 aData
.aColsAllMarked
.emplace_back( 10, 5, 0, 0, 10, 0 );
643 aData
.aColsAllMarked
.emplace_back( 15, 5, 0, 0, 10, 0 );
644 aData
.aColsAllMarked
.emplace_back( 5, 20, 0, 0, 20, 0 );
645 aData
.aColsAllMarked
.emplace_back( 10, 20, 0, 0, 20, 0 );
646 aData
.aColsAllMarked
.emplace_back( 25, 7, 0, 0, 15, 0 );
647 aData
.aColsAllMarked
.emplace_back( 30, 7, 0, 0, 15, 0 );
648 aData
.aColsAllMarked
.emplace_back( 35, 0, 0, 0, limits
.MaxRow(), 0 );
649 aData
.aColsAllMarked
.emplace_back( 100, 20, 0, 0, 20, 0 );
651 aData
.aColsNotAllMarked
.emplace_back( 5, 5, 0, 0, 25, 0 );
652 aData
.aColsNotAllMarked
.emplace_back( 15, 5, 0, 0, 25, 0 );
653 aData
.aColsNotAllMarked
.emplace_back( 22, 15, 0, 0, 25, 0 );
654 aData
.aColsNotAllMarked
.emplace_back( 27, 7, 0, 0, 20, 0 );
655 aData
.aColsNotAllMarked
.emplace_back( 100, 19, 0, 0, 21, 0 );
657 aData
.aColsWithEqualMarksList
.emplace_back( 0, 9 );
658 aData
.aColsWithEqualMarksList
.emplace_back( 10, 20 );
659 aData
.aColsWithEqualMarksList
.emplace_back( 21, 24 );
660 aData
.aColsWithEqualMarksList
.emplace_back( 25, 30 );
661 aData
.aColsWithEqualMarksList
.emplace_back( 31, 34 );
662 aData
.aColsWithEqualMarksList
.emplace_back( 36, 100 );
663 aData
.aColsWithEqualMarksList
.emplace_back( 0, 22 );
664 aData
.aColsWithEqualMarksList
.emplace_back( 0, 34 );
666 aData
.aColsWithUnequalMarksList
.emplace_back( 0, 10 );
667 aData
.aColsWithUnequalMarksList
.emplace_back( 0, 20 );
668 aData
.aColsWithUnequalMarksList
.emplace_back( 10, 21 );
669 aData
.aColsWithUnequalMarksList
.emplace_back( 20, 25 );
670 aData
.aColsWithUnequalMarksList
.emplace_back( 20, 30 );
671 aData
.aColsWithUnequalMarksList
.emplace_back( 24, 30 );
672 aData
.aColsWithUnequalMarksList
.emplace_back( 30, 31 );
673 aData
.aColsWithUnequalMarksList
.emplace_back( 30, 34 );
674 aData
.aColsWithUnequalMarksList
.emplace_back( 30, 35 );
675 aData
.aColsWithUnequalMarksList
.emplace_back( 35, 100 );
677 testMultiMark( aData
);
680 void Test::testMultiMark_NegativeMarking()
682 ScSheetLimits
limits( ScSheetLimits::CreateDefault());
683 MultiMarkTestData aData
;
685 // Create full row = 5
686 MarkTestData aSingle1
;
687 aSingle1
.aRange
= ScRange( 0, 5, 0, limits
.MaxCol(), 5, 0 );
688 aSingle1
.bMark
= true;
690 // Create rectangle ( 10, 8, 25, 20 )
691 MarkTestData aSingle2
;
692 aSingle2
.aRange
= ScRange( 10, 8, 0, 25, 20, 0 );
693 aSingle2
.bMark
= true;
695 // Create full row = 12
696 MarkTestData aSingle3
;
697 aSingle3
.aRange
= ScRange( 0, 12, 0, limits
.MaxCol(), 12, 0 );
698 aSingle3
.bMark
= true;
700 // Create deselection rectangle ( 17, 5, 20, 5 )
701 MarkTestData aSingle4
;
702 aSingle4
.aRange
= ScRange( 17, 5, 0, 20, 5, 0 );
703 aSingle4
.bMark
= false;
705 aSingle4
.aInsideAddresses
.emplace_back( 6, 5, 0 );
706 aSingle4
.aInsideAddresses
.emplace_back( 30, 5, 0 );
707 aSingle4
.aInsideAddresses
.emplace_back( 6, 12, 0 );
708 aSingle4
.aInsideAddresses
.emplace_back( 30, 12, 0 );
709 aSingle4
.aInsideAddresses
.emplace_back( 13, 14, 0 );
710 aSingle4
.aInsideAddresses
.emplace_back( 16, 12, 0 );
712 aSingle4
.aOutsideAddresses
.emplace_back( 5, 2, 0 );
713 aSingle4
.aOutsideAddresses
.emplace_back( 18, 5, 0 );
714 aSingle4
.aOutsideAddresses
.emplace_back( 17, 5, 0 );
715 aSingle4
.aOutsideAddresses
.emplace_back( 20, 5, 0 );
716 aSingle4
.aOutsideAddresses
.emplace_back( 18, 7, 0 );
717 aSingle4
.aOutsideAddresses
.emplace_back( 5, 10, 0 );
718 aSingle4
.aOutsideAddresses
.emplace_back( 30, 10, 0 );
719 aSingle4
.aOutsideAddresses
.emplace_back( 5, 14, 0 );
720 aSingle4
.aOutsideAddresses
.emplace_back( 30, 14, 0 );
721 aSingle4
.aOutsideAddresses
.emplace_back( 18, 25, 0 );
723 aSingle4
.aRowsWithFullMarks
.push_back( 12 );
725 aSingle4
.aRowsWithoutFullMarks
.push_back( 5 );
727 aSingle4
.aRangesWithFullMarks
.emplace_back( 5, 5, 0, 16, 5, 0 );
728 aSingle4
.aRangesWithFullMarks
.emplace_back( 21, 5, 0, 30, 5, 0 );
729 aSingle4
.aRangesWithFullMarks
.emplace_back( 5, 12, 0, 9, 12, 0 );
730 aSingle4
.aRangesWithFullMarks
.emplace_back( 26, 12, 0, 30, 12, 0 );
731 aSingle4
.aRangesWithFullMarks
.emplace_back( 10, 8, 0, 25, 20, 0 );
733 aSingle4
.aRangesWithoutFullMarks
.emplace_back( 10, 5, 0, 25, 5, 0 );
735 aSingle4
.aNextMarked
.emplace_back( 18, 7, 0, 0, -1, 0 ); // up fail
736 aSingle4
.aNextMarked
.emplace_back( 18, 4, 0, 1, 8, 0 ); // down ok
738 // Create deselection rectangle ( 15, 10, 18, 14 )
739 MarkTestData aSingle5
;
740 aSingle5
.aRange
= ScRange( 15, 10, 0, 18, 14, 0 );
741 aSingle5
.bMark
= false;
743 aSingle5
.aInsideAddresses
.emplace_back( 6, 5, 0 );
744 aSingle5
.aInsideAddresses
.emplace_back( 30, 5, 0 );
745 aSingle5
.aInsideAddresses
.emplace_back( 6, 12, 0 );
746 aSingle5
.aInsideAddresses
.emplace_back( 30, 12, 0 );
747 aSingle5
.aInsideAddresses
.emplace_back( 13, 14, 0 );
749 aSingle5
.aOutsideAddresses
= aSingle4
.aOutsideAddresses
;
750 aSingle5
.aOutsideAddresses
.emplace_back( 17, 12, 0 );
751 aSingle5
.aOutsideAddresses
.emplace_back( 15, 10, 0 );
752 aSingle5
.aOutsideAddresses
.emplace_back( 18, 10, 0 );
753 aSingle5
.aOutsideAddresses
.emplace_back( 15, 14, 0 );
754 aSingle5
.aOutsideAddresses
.emplace_back( 18, 14, 0 );
756 aSingle5
.aRowsWithoutFullMarks
.push_back( 12 );
757 aSingle5
.aRowsWithoutFullMarks
.push_back( 5 );
759 aSingle5
.aRangesWithoutFullMarks
.emplace_back( 10, 8, 0, 25, 20, 0 );
761 aSingle5
.aNextMarked
= aSingle4
.aNextMarked
;
762 aSingle5
.aNextMarked
.emplace_back( 17, 12, 0, 0, 9, 0 ); // up ok
763 aSingle5
.aNextMarked
.emplace_back( 17, 12, 0, 1, 15, 0 ); // down ok
765 // Add the rectangle data to aData
766 aData
.aMarks
.push_back( aSingle1
);
767 aData
.aMarks
.push_back( aSingle2
);
768 aData
.aMarks
.push_back( aSingle3
);
769 aData
.aMarks
.push_back( aSingle4
);
770 aData
.aMarks
.push_back( aSingle5
);
772 aData
.aSelectionCover
= ScRange( 0, 4, 0, limits
.MaxCol(), 21, 0 );
773 aData
.aLeftEnvelope
.push_back( ScRange( 9, 8, 0, 9, 11, 0 ) );
774 aData
.aLeftEnvelope
.push_back( ScRange( 9, 13, 0, 9, 20, 0 ) );
775 aData
.aLeftEnvelope
.push_back( ScRange( 18, 10, 0, 18, 14, 0 ) );
776 aData
.aLeftEnvelope
.push_back( ScRange( 20, 5, 0, 20, 5, 0 ) );
778 aData
.aRightEnvelope
.push_back( ScRange( 17, 5, 0, 17, 5, 0 ) );
779 aData
.aRightEnvelope
.push_back( ScRange( 15, 10, 0, 15, 14, 0 ) );
780 aData
.aRightEnvelope
.push_back( ScRange( 26, 8, 0, 26, 11, 0 ) );
781 aData
.aRightEnvelope
.push_back( ScRange( 26, 13, 0, 26, 20, 0 ) );
783 aData
.aTopEnvelope
.push_back( ScRange( 0, 4, 0, 16, 4, 0 ) );
784 aData
.aTopEnvelope
.push_back( ScRange( 21, 4, 0, limits
.MaxCol(), 4, 0 ) );
785 aData
.aTopEnvelope
.push_back( ScRange( 10, 7, 0, 25, 7, 0 ) );
786 aData
.aTopEnvelope
.push_back( ScRange( 0, 11, 0, 9, 11, 0 ) );
787 aData
.aTopEnvelope
.push_back( ScRange( 26, 11, 0, limits
.MaxCol(), 11, 0 ) );
788 aData
.aTopEnvelope
.push_back( ScRange( 15, 14, 0, 18, 14, 0 ) );
790 aData
.aBottomEnvelope
.push_back( ScRange( 0, 6, 0, 16, 6, 0 ) );
791 aData
.aBottomEnvelope
.push_back( ScRange( 21, 6, 0, limits
.MaxCol(), 6, 0 ) );
792 aData
.aBottomEnvelope
.push_back( ScRange( 15, 10, 0, 18, 10, 0 ) );
793 aData
.aBottomEnvelope
.push_back( ScRange( 0, 13, 0, 9, 13, 0 ) );
794 aData
.aBottomEnvelope
.push_back( ScRange( 26, 13, 0, limits
.MaxCol(), 13, 0 ) );
795 aData
.aBottomEnvelope
.push_back( ScRange( 10, 21, 0, 25, 21, 0 ) );
797 aData
.aColsWithOneMark
.emplace_back( 19, 8, 0, 0, 20, 0 );
798 aData
.aColsWithOneMark
.emplace_back( 20, 8, 0, 0, 20, 0 );
800 aData
.aColsWithoutOneMark
.push_back( 5 );
801 aData
.aColsWithoutOneMark
.push_back( 10 );
802 aData
.aColsWithoutOneMark
.push_back( 12 );
803 aData
.aColsWithoutOneMark
.push_back( 16 );
804 aData
.aColsWithoutOneMark
.push_back( 17 );
805 aData
.aColsWithoutOneMark
.push_back( 24 );
806 aData
.aColsWithoutOneMark
.push_back( 100 );
808 aData
.aColsAllMarked
.emplace_back( 10, 8, 0, 0, 20, 0 );
809 aData
.aColsAllMarked
.emplace_back( 17, 8, 0, 0, 9, 0 );
810 aData
.aColsAllMarked
.emplace_back( 20, 8, 0, 0, 20, 0 );
811 aData
.aColsAllMarked
.emplace_back( 100, 5, 0, 0, 5, 0 );
812 aData
.aColsAllMarked
.emplace_back( 100, 12, 0, 0, 12, 0 );
814 aData
.aColsNotAllMarked
.emplace_back( 5, 5, 0, 0, 12, 0 );
815 aData
.aColsNotAllMarked
.emplace_back( 10, 5, 0, 0, 20, 0 );
816 aData
.aColsNotAllMarked
.emplace_back( 15, 8, 0, 0, 20, 0 );
817 aData
.aColsNotAllMarked
.emplace_back( 18, 8, 0, 0, 20, 0 );
818 aData
.aColsNotAllMarked
.emplace_back( 25, 5, 0, 0, 20, 0 );
820 aData
.aColsWithEqualMarksList
.emplace_back( 0, 9 );
821 aData
.aColsWithEqualMarksList
.emplace_back( 10, 14 );
822 aData
.aColsWithEqualMarksList
.emplace_back( 15, 16 );
823 aData
.aColsWithEqualMarksList
.emplace_back( 17, 18 );
824 aData
.aColsWithEqualMarksList
.emplace_back( 19, 20 );
825 aData
.aColsWithEqualMarksList
.emplace_back( 21, 25 );
826 aData
.aColsWithEqualMarksList
.emplace_back( 26, 100 );
827 aData
.aColsWithEqualMarksList
.emplace_back( 0, 100 );
829 aData
.aColsWithUnequalMarksList
.emplace_back( 0, 10 );
830 aData
.aColsWithUnequalMarksList
.emplace_back( 10, 15 );
831 aData
.aColsWithUnequalMarksList
.emplace_back( 15, 17 );
832 aData
.aColsWithUnequalMarksList
.emplace_back( 17, 19 );
833 aData
.aColsWithUnequalMarksList
.emplace_back( 19, 21 );
834 aData
.aColsWithUnequalMarksList
.emplace_back( 21, 26 );
836 testMultiMark( aData
);
839 void Test::testInsertTabBeforeSelected()
841 ScMarkData
aMark(ScSheetLimits::CreateDefault());
842 aMark
.SelectOneTable(0);
844 CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark
.GetSelectCount());
845 CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark
.GetFirstSelected());
848 void Test::testInsertTabAfterSelected()
850 ScMarkData
aMark(ScSheetLimits::CreateDefault());
851 aMark
.SelectOneTable(0);
853 CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark
.GetSelectCount());
854 CPPUNIT_ASSERT_EQUAL(SCTAB(0), aMark
.GetFirstSelected());
857 void Test::testDeleteTabBeforeSelected()
859 ScMarkData
aMark(ScSheetLimits::CreateDefault());
860 aMark
.SelectOneTable(1);
862 CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark
.GetSelectCount());
863 CPPUNIT_ASSERT_EQUAL(SCTAB(0), aMark
.GetFirstSelected());
866 void Test::testDeleteTabAfterSelected()
868 ScMarkData
aMark(ScSheetLimits::CreateDefault());
869 aMark
.SelectOneTable(0);
871 CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark
.GetSelectCount());
872 CPPUNIT_ASSERT_EQUAL(SCTAB(0), aMark
.GetFirstSelected());
875 void Test::testScMarkArraySearch_check(const ScMarkArray
& ar
, SCROW nRow
, bool expectStatus
, SCSIZE nIndexExpect
)
878 bool status
= ar
.Search(nRow
, nIndex
);
879 CPPUNIT_ASSERT_EQUAL(expectStatus
, status
);
880 CPPUNIT_ASSERT_EQUAL(nIndexExpect
, nIndex
);
883 void Test::testScMarkArraySearch()
885 ScSheetLimits
limits( ScSheetLimits::CreateDefault());
888 ScMarkArray
ar(limits
);
889 testScMarkArraySearch_check(ar
, -1, true, 0);
890 testScMarkArraySearch_check(ar
, 100, true, 0);
895 ScMarkArray
ar(limits
);
896 ar
.SetMarkArea(10, 20, true);
900 testScMarkArraySearch_check(ar
, -100, true, 0);
901 testScMarkArraySearch_check(ar
, -1, true, 0);
903 testScMarkArraySearch_check(ar
, 0, true, 0);
904 testScMarkArraySearch_check(ar
, 5, true, 0);
905 testScMarkArraySearch_check(ar
, 9, true, 0);
906 testScMarkArraySearch_check(ar
, 10, true, 1);
907 testScMarkArraySearch_check(ar
, 11, true, 1);
908 testScMarkArraySearch_check(ar
, 19, true, 1);
909 testScMarkArraySearch_check(ar
, 20, true, 1);
910 testScMarkArraySearch_check(ar
, 21, true, 2);
911 testScMarkArraySearch_check(ar
, 22, true, 2);
916 ScMarkArray
ar(limits
);
917 ar
.SetMarkArea(10, 20, true);
918 ar
.SetMarkArea(21, 30, true);
919 ar
.SetMarkArea(50, 100, true);
921 // 0-9,10-30,31-49,50-100,101+
923 testScMarkArraySearch_check(ar
, -100, true, 0);
924 testScMarkArraySearch_check(ar
, -1, true, 0);
926 testScMarkArraySearch_check(ar
, 5, true, 0);
927 testScMarkArraySearch_check(ar
, 15, true, 1);
928 testScMarkArraySearch_check(ar
, 25, true, 1);
929 testScMarkArraySearch_check(ar
, 35, true, 2);
930 testScMarkArraySearch_check(ar
, 55, true, 3);
931 testScMarkArraySearch_check(ar
, 20, true, 1);
932 testScMarkArraySearch_check(ar
, 21, true, 1);
935 // three single-row ranges
937 ScMarkArray
ar(limits
);
938 ar
.SetMarkArea(4, 4, true);
939 ar
.SetMarkArea(6, 6, true);
940 ar
.SetMarkArea(8, 8, true);
942 testScMarkArraySearch_check(ar
, -100, true, 0);
943 testScMarkArraySearch_check(ar
, -1, true, 0);
945 testScMarkArraySearch_check(ar
, 3, true, 0);
946 testScMarkArraySearch_check(ar
, 4, true, 1);
947 testScMarkArraySearch_check(ar
, 5, true, 2);
948 testScMarkArraySearch_check(ar
, 6, true, 3);
949 testScMarkArraySearch_check(ar
, 7, true, 4);
950 testScMarkArraySearch_check(ar
, 8, true, 5);
951 testScMarkArraySearch_check(ar
, 9, true, 6);
952 testScMarkArraySearch_check(ar
, 10, true, 6);
957 ScMarkArray
ar(limits
);
958 ar
.SetMarkArea(10, limits
.MaxRow(), true);
962 testScMarkArraySearch_check(ar
, -100, true, 0);
963 testScMarkArraySearch_check(ar
, -1, true, 0);
965 testScMarkArraySearch_check(ar
, 0, true, 0);
966 testScMarkArraySearch_check(ar
, 5, true, 0);
967 testScMarkArraySearch_check(ar
, 9, true, 0);
968 testScMarkArraySearch_check(ar
, 10, true, 1);
969 testScMarkArraySearch_check(ar
, 11, true, 1);
970 testScMarkArraySearch_check(ar
, 12, true, 1);
971 testScMarkArraySearch_check(ar
, 200, true, 1);
972 testScMarkArraySearch_check(ar
, limits
.MaxRow(), true, 1);
976 void Test::testIsAllMarked()
978 ScSheetLimits
limits( ScSheetLimits::CreateDefault());
979 ScMarkData
mark(limits
);
980 ScRange
range1( ScAddress( 5, 10, 0 ), ScAddress( 15, 20, 0 ));
981 ScRange
range2( ScAddress( 2, 2, 0 ), ScAddress( 25, 30, 0 ));
982 CPPUNIT_ASSERT( !mark
.IsAllMarked( range1
));
983 CPPUNIT_ASSERT( !mark
.IsAllMarked( range2
));
985 CPPUNIT_ASSERT( !mark
.IsAllMarked( range1
));
986 CPPUNIT_ASSERT( !mark
.IsAllMarked( range2
));
989 mark
.SetMarkArea( range1
);
990 CPPUNIT_ASSERT( mark
.IsAllMarked( range1
));
991 CPPUNIT_ASSERT( !mark
.IsAllMarked( range2
));
993 CPPUNIT_ASSERT( mark
.IsAllMarked( range1
));
994 CPPUNIT_ASSERT( !mark
.IsAllMarked( range2
));
997 mark
.SetMarkArea( range2
);
998 CPPUNIT_ASSERT( mark
.IsAllMarked( range1
));
999 CPPUNIT_ASSERT( mark
.IsAllMarked( range2
));
1001 CPPUNIT_ASSERT( mark
.IsAllMarked( range1
));
1002 CPPUNIT_ASSERT( mark
.IsAllMarked( range2
));
1005 CPPUNIT_TEST_SUITE_REGISTRATION(Test
);
1007 CPPUNIT_PLUGIN_IMPLEMENT();
1009 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */