1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_SC_QA_UNIT_UCALC_HXX
#define INCLUDED_SC_QA_UNIT_UCALC_HXX
#include "helper/qahelper.hxx"
#include "document.hxx"
struct TestImpl;
class ScUndoPaste;
/**
* Temporarily set formula grammar.
*/
class FormulaGrammarSwitch
{
ScDocument* mpDoc;
formula::FormulaGrammar::Grammar meOldGrammar;
public:
FormulaGrammarSwitch(ScDocument* pDoc, formula::FormulaGrammar::Grammar eGrammar);
~FormulaGrammarSwitch();
};
class Test : public test::BootstrapFixture
{
public:
struct RangeNameDef
{
const char* mpName;
const char* mpExpr;
sal_uInt16 mnIndex;
};
static ScDocShell* findLoadedDocShellByName(const OUString& rName);
static bool insertRangeNames(ScDocument* pDoc, ScRangeName* pNames, const RangeNameDef* p, const RangeNameDef* pEnd);
static void printRange(ScDocument* pDoc, const ScRange& rRange, const char* pCaption);
static void clearRange(ScDocument* pDoc, const ScRange& rRange);
static void clearSheet(ScDocument* pDoc, SCTAB nTab);
static void copyToClip(ScDocument* pSrcDoc, const ScRange& rRange, ScDocument* pClipDoc);
static void pasteFromClip(ScDocument* pDestDoc, const ScRange& rDestRange, ScDocument* pClipDoc);
static ScUndoPaste* createUndoPaste(ScDocShell& rDocSh, const ScRange& rRange, ScDocument* pUndoDoc);
/**
* Enable or disable expand reference options which controls how
* references in formula are expanded when inserting rows or columns.
*/
static void setExpandRefs(bool bExpand);
static void setCalcAsShown(ScDocument* pDoc, bool bCalcAsShown);
template<size_t _Size>
static ScRange insertRangeData(ScDocument* pDoc, const ScAddress& rPos, const char* aData[][_Size], size_t nRowCount)
{
ScRange aRange(rPos);
aRange.aEnd.SetCol(rPos.Col()+_Size-1);
aRange.aEnd.SetRow(rPos.Row()+nRowCount-1);
clearRange(pDoc, aRange);
for (size_t i = 0; i < _Size; ++i)
{
for (size_t j = 0; j < nRowCount; ++j)
{
if (!aData[j][i])
continue;
SCCOL nCol = i + rPos.Col();
SCROW nRow = j + rPos.Row();
pDoc->SetString(nCol, nRow, rPos.Tab(), OUString(aData[j][i], strlen(aData[j][i]), RTL_TEXTENCODING_UTF8));
}
}
printRange(pDoc, aRange, "Range data content");
return aRange;
}
Test();
virtual ~Test();
ScDocShell& getDocShell();
virtual void setUp() SAL_OVERRIDE;
virtual void tearDown() SAL_OVERRIDE;
/**
* Basic performance regression test. Pick some actions that *should* take
* only a fraction of a second to complete, and make sure they stay that
* way. We set the threshold to 1 second for each action which should be
* large enough to accommodate slower machines or machines with high load.
*/
void testPerf();
void testCollator();
void testSharedStringPool();
void testSharedStringPoolUndoDoc();
void testRangeList();
void testMarkData();
void testInput();
void testDocStatistics();
/**
* The 'data entries' data is a list of strings used for suggestions as
* the user types in new cell value.
*/
void testDataEntries();
/**
* Selection function is responsible for displaying quick calculation
* results in the status bar.
*/
void testSelectionFunction();
void testFormulaCreateStringFromTokens();
void testFormulaParseReference();
void testFetchVectorRefArray();
void testFormulaHashAndTag();
void testFormulaTokenEquality();
void testFormulaRefData();
void testFormulaCompiler();
void testFormulaCompilerJumpReordering();
void testFormulaRefUpdate();
void testFormulaRefUpdateRange();
void testFormulaRefUpdateSheets();
void testFormulaRefUpdateInsertRows();
void testFormulaRefUpdateInsertColumns();
void testFormulaRefUpdateMove();
void testFormulaRefUpdateMoveUndo();
void testFormulaRefUpdateMoveToSheet();
void testFormulaRefUpdateDeleteContent();
void testFormulaRefUpdateNamedExpression();
void testFormulaRefUpdateNamedExpressionMove();
void testFormulaRefUpdateNamedExpressionExpandRef();
void testFormulaRefUpdateValidity();
void testMultipleOperations();
void testFuncCOLUMN();
void testFuncCOUNT();
void testFuncROW();
void testFuncSUM();
void testFuncPRODUCT();
void testFuncSUMPRODUCT();
void testFuncMIN();
void testFuncN();
void testFuncCOUNTIF();
void testFuncNUMBERVALUE();
void testFuncLEN();
void testFuncLOOKUP();
void testFuncVLOOKUP();
void testFuncMATCH();
void testFuncCELL();
void testFuncDATEDIF();
void testFuncINDIRECT();
void testFuncIF();
void testFuncCHOOSE();
void testFuncIFERROR();
void testFuncSHEET();
void testFuncNOW();
void testFuncGETPIVOTDATA();
void testFuncGETPIVOTDATALeafAccess();
void testExternalRef();
void testExternalRefFunctions();
void testCopyToDocument();
void testHorizontalIterator();
void testValueIterator();
/**
* Basic test for formula dependency tracking.
*/
void testFormulaDepTracking();
/**
* Another test for formula dependency tracking, inspired by fdo#56278.
*/
void testFormulaDepTracking2();
void testFormulaDepTrackingDeleteRow();
void testFormulaMatrixResultUpdate();
/**
* More direct test for cell broadcaster management, used to track formula
* dependencies.
*/
void testCellBroadcaster();
void testFuncParam();
void testNamedRange();
void testInsertNameList();
void testCSV();
void testMatrix();
void testEnterMixedMatrix();
void testMatrixEditable();
/**
* Basic test for pivot tables.
*/
void testPivotTable();
/**
* Test against unwanted automatic format detection on field names and
* field members in pivot tables.
*/
void testPivotTableLabels();
/**
* Make sure that we set cells displaying date values numeric cells,
* rather than text cells. Grouping by date or number functionality
* depends on this.
*/
void testPivotTableDateLabels();
/**
* Test for pivot table's filtering functionality by page fields.
*/
void testPivotTableFilters();
/**
* Test for pivot table's named source range.
*/
void testPivotTableNamedSource();
/**
* Test for pivot table cache. Each dimension in the pivot cache stores
* only unique values that are sorted in ascending order.
*/
void testPivotTableCache();
/**
* Test for pivot table containing data fields that reference the same
* source field but different functions.
*/
void testPivotTableDuplicateDataFields();
void testPivotTableNormalGrouping();
void testPivotTableNumberGrouping();
void testPivotTableDateGrouping();
void testPivotTableEmptyRows();
void testPivotTableTextNumber();
/**
* Test for checking that pivot table treats strings in a case insensitive
* manner.
*/
void testPivotTableCaseInsensitiveStrings();
/**
* Test for pivot table's handling of double-precision numbers that are
* very close together.
*/
void testPivotTableNumStability();
/**
* Test for pivot table that include field with various non-default field
* refrences.
*/
void testPivotTableFieldReference();
/**
* Test pivot table functionality performed via ScDBDocFunc.
*/
void testPivotTableDocFunc();
void testCellCopy();
void testSheetCopy();
void testSheetMove();
void testDataArea();
void testAutofilter();
void testCopyPaste();
void testCopyPasteAsLink();
void testCopyPasteTranspose();
void testCopyPasteMultiRange();
void testCopyPasteSkipEmpty();
void testCopyPasteSkipEmpty2();
void testCopyPasteSkipEmptyConditionalFormatting();
void testCutPasteRefUndo();
void testMoveRefBetweenSheets();
void testUndoCut();
void testMoveBlock();
void testCopyPasteRelativeFormula();
void testMergedCells();
void testUpdateReference();
void testSearchCells();
void testSharedFormulas();
void testSharedFormulasRefUpdate();
void testSharedFormulasRefUpdateMove();
void testSharedFormulasRefUpdateMove2();
void testSharedFormulasRefUpdateRange();
void testSharedFormulasRefUpdateExternal();
void testSharedFormulasInsertRow();
void testSharedFormulasDeleteRows();
void testSharedFormulasDeleteColumns();
void testSharedFormulasRefUpdateMoveSheets();
void testSharedFormulasRefUpdateCopySheets();
void testSharedFormulasRefUpdateDeleteSheets();
void testSharedFormulasCopyPaste();
void testSharedFormulaInsertColumn();
void testSharedFormulaMoveBlock();
void testSharedFormulaUpdateOnNamedRangeChange();
void testSharedFormulaUpdateOnDBChange();
void testFormulaPosition();
void testMixData();
/**
* Make sure the sheet streams are invalidated properly.
*/
void testStreamValid();
/**
* Test built-in cell functions to make sure their categories and order
* are correct.
*/
void testFunctionLists();
void testGraphicsInGroup();
void testGraphicsOnSheetMove();
/**
* Test toggling relative/absolute flag of cell and cell range references.
* This corresponds with hitting Shift-F4 while the cursor is on a formula
* cell.
*/
void testToggleRefFlag();
/**
* Test to make sure correct precedent / dependent cells are obtained when
* preparing to jump to them.
*/
void testJumpToPrecedentsDependents();
void testSetBackgroundColor();
void testRenameTable();
void testAutoFill();
void testCopyPasteFormulas();
void testCopyPasteFormulasExternalDoc();
void testFindAreaPosVertical();
void testFindAreaPosColRight();
void testSort();
void testSortHorizontal();
void testSortSingleRow();
void testSortWithFormulaRefs();
void testSortWithStrings();
void testSortInFormulaGroup();
void testSortWithCellFormats();
void testSortRefUpdate();
void testSortRefUpdate2();
void testSortRefUpdate3();
void testSortRefUpdate4();
void testSortRefUpdate5();
void testSortOutOfPlaceResult();
void testSortPartialFormulaGroup();
void testShiftCells();
void testNoteBasic();
void testNoteDeleteRow();
void testNoteDeleteCol();
void testNoteLifeCycle();
void testNoteCopyPaste();
void testAreasWithNotes();
void testAnchoredRotatedShape();
void testCellTextWidth();
void testEditTextIterator();
void testCondFormatINSDEL();
void testCondFormatInsertRow();
void testCondFormatInsertCol();
void testCondFormatInsertDeleteSheets();
void testCondCopyPaste();
void testCondCopyPasteSingleCell(); //e.g. fdo#82503
void testCopySheetCondFormat();
void testIconSet();
void testImportStream();
void testDeleteContents();
void testTransliterateText();
void testColumnFindEditCells();
CPPUNIT_TEST_SUITE(Test);
#if CALC_TEST_PERF
CPPUNIT_TEST(testPerf);
#endif
CPPUNIT_TEST(testCollator);
CPPUNIT_TEST(testSharedStringPool);
CPPUNIT_TEST(testSharedStringPoolUndoDoc);
CPPUNIT_TEST(testRangeList);
CPPUNIT_TEST(testMarkData);
CPPUNIT_TEST(testInput);
CPPUNIT_TEST(testDocStatistics);
CPPUNIT_TEST(testDataEntries);
CPPUNIT_TEST(testSelectionFunction);
CPPUNIT_TEST(testFormulaCreateStringFromTokens);
CPPUNIT_TEST(testFormulaParseReference);
CPPUNIT_TEST(testFetchVectorRefArray);
CPPUNIT_TEST(testFormulaHashAndTag);
CPPUNIT_TEST(testFormulaTokenEquality);
CPPUNIT_TEST(testFormulaRefData);
CPPUNIT_TEST(testFormulaCompiler);
CPPUNIT_TEST(testFormulaCompilerJumpReordering);
CPPUNIT_TEST(testFormulaRefUpdate);
CPPUNIT_TEST(testFormulaRefUpdateRange);
CPPUNIT_TEST(testFormulaRefUpdateSheets);
CPPUNIT_TEST(testFormulaRefUpdateInsertRows);
CPPUNIT_TEST(testFormulaRefUpdateInsertColumns);
CPPUNIT_TEST(testFormulaRefUpdateMove);
CPPUNIT_TEST(testFormulaRefUpdateMoveUndo);
CPPUNIT_TEST(testFormulaRefUpdateMoveToSheet);
CPPUNIT_TEST(testFormulaRefUpdateDeleteContent);
CPPUNIT_TEST(testFormulaRefUpdateNamedExpression);
CPPUNIT_TEST(testFormulaRefUpdateNamedExpressionMove);
CPPUNIT_TEST(testFormulaRefUpdateNamedExpressionExpandRef);
CPPUNIT_TEST(testFormulaRefUpdateValidity);
CPPUNIT_TEST(testMultipleOperations);
CPPUNIT_TEST(testFuncCOLUMN);
CPPUNIT_TEST(testFuncCOUNT);
CPPUNIT_TEST(testFuncROW);
CPPUNIT_TEST(testFuncSUM);
CPPUNIT_TEST(testFuncPRODUCT);
CPPUNIT_TEST(testFuncSUMPRODUCT);
CPPUNIT_TEST(testFuncMIN);
CPPUNIT_TEST(testFuncN);
CPPUNIT_TEST(testFuncCOUNTIF);
CPPUNIT_TEST(testFuncNUMBERVALUE);
CPPUNIT_TEST(testFuncLEN);
CPPUNIT_TEST(testFuncLOOKUP);
CPPUNIT_TEST(testFuncVLOOKUP);
CPPUNIT_TEST(testFuncMATCH);
CPPUNIT_TEST(testFuncCELL);
CPPUNIT_TEST(testFuncDATEDIF);
CPPUNIT_TEST(testFuncINDIRECT);
CPPUNIT_TEST(testFuncIF);
CPPUNIT_TEST(testFuncCHOOSE);
CPPUNIT_TEST(testFuncIFERROR);
CPPUNIT_TEST(testFuncGETPIVOTDATA);
CPPUNIT_TEST(testFuncGETPIVOTDATALeafAccess);
CPPUNIT_TEST(testExternalRef);
CPPUNIT_TEST(testExternalRefFunctions);
CPPUNIT_TEST(testCopyToDocument);
CPPUNIT_TEST(testFuncSHEET);
CPPUNIT_TEST(testFuncNOW);
CPPUNIT_TEST(testHorizontalIterator);
CPPUNIT_TEST(testValueIterator);
CPPUNIT_TEST(testFormulaDepTracking);
CPPUNIT_TEST(testFormulaDepTracking2);
CPPUNIT_TEST(testFormulaDepTrackingDeleteRow);
CPPUNIT_TEST(testFormulaMatrixResultUpdate);
CPPUNIT_TEST(testCellBroadcaster);
CPPUNIT_TEST(testFuncParam);
CPPUNIT_TEST(testNamedRange);
CPPUNIT_TEST(testInsertNameList);
CPPUNIT_TEST(testCSV);
CPPUNIT_TEST(testMatrix);
CPPUNIT_TEST(testEnterMixedMatrix);
CPPUNIT_TEST(testMatrixEditable);
CPPUNIT_TEST(testPivotTable);
CPPUNIT_TEST(testPivotTableLabels);
CPPUNIT_TEST(testPivotTableDateLabels);
CPPUNIT_TEST(testPivotTableFilters);
CPPUNIT_TEST(testPivotTableNamedSource);
CPPUNIT_TEST(testPivotTableCache);
CPPUNIT_TEST(testPivotTableDuplicateDataFields);
CPPUNIT_TEST(testPivotTableNormalGrouping);
CPPUNIT_TEST(testPivotTableNumberGrouping);
CPPUNIT_TEST(testPivotTableDateGrouping);
CPPUNIT_TEST(testPivotTableEmptyRows);
CPPUNIT_TEST(testPivotTableTextNumber);
CPPUNIT_TEST(testPivotTableCaseInsensitiveStrings);
CPPUNIT_TEST(testPivotTableNumStability);
CPPUNIT_TEST(testPivotTableFieldReference);
CPPUNIT_TEST(testPivotTableDocFunc);
CPPUNIT_TEST(testCellCopy);
CPPUNIT_TEST(testSheetCopy);
CPPUNIT_TEST(testSheetMove);
CPPUNIT_TEST(testDataArea);
CPPUNIT_TEST(testGraphicsInGroup);
CPPUNIT_TEST(testGraphicsOnSheetMove);
CPPUNIT_TEST(testStreamValid);
CPPUNIT_TEST(testFunctionLists);
CPPUNIT_TEST(testToggleRefFlag);
CPPUNIT_TEST(testAutofilter);
CPPUNIT_TEST(testCopyPaste);
CPPUNIT_TEST(testCopyPasteAsLink);
CPPUNIT_TEST(testCopyPasteTranspose);
CPPUNIT_TEST(testCopyPasteMultiRange);
CPPUNIT_TEST(testCopyPasteSkipEmpty);
CPPUNIT_TEST(testCopyPasteSkipEmpty2);
//CPPUNIT_TEST(testCopyPasteSkipEmptyConditionalFormatting);
CPPUNIT_TEST(testCutPasteRefUndo);
CPPUNIT_TEST(testMoveRefBetweenSheets);
CPPUNIT_TEST(testUndoCut);
CPPUNIT_TEST(testMoveBlock);
CPPUNIT_TEST(testCopyPasteRelativeFormula);
CPPUNIT_TEST(testMergedCells);
CPPUNIT_TEST(testUpdateReference);
CPPUNIT_TEST(testSearchCells);
CPPUNIT_TEST(testSharedFormulas);
CPPUNIT_TEST(testSharedFormulasRefUpdate);
CPPUNIT_TEST(testSharedFormulasRefUpdateMove);
CPPUNIT_TEST(testSharedFormulasRefUpdateMove2);
CPPUNIT_TEST(testSharedFormulasRefUpdateRange);
CPPUNIT_TEST(testSharedFormulasRefUpdateExternal);
CPPUNIT_TEST(testSharedFormulasInsertRow);
CPPUNIT_TEST(testSharedFormulasDeleteRows);
CPPUNIT_TEST(testSharedFormulasDeleteColumns);
CPPUNIT_TEST(testSharedFormulasRefUpdateMoveSheets);
CPPUNIT_TEST(testSharedFormulasRefUpdateCopySheets);
CPPUNIT_TEST(testSharedFormulasRefUpdateDeleteSheets);
CPPUNIT_TEST(testSharedFormulasCopyPaste);
CPPUNIT_TEST(testSharedFormulaInsertColumn);
CPPUNIT_TEST(testSharedFormulaUpdateOnNamedRangeChange);
CPPUNIT_TEST(testSharedFormulaUpdateOnDBChange);
CPPUNIT_TEST(testFormulaPosition);
CPPUNIT_TEST(testMixData);
CPPUNIT_TEST(testJumpToPrecedentsDependents);
CPPUNIT_TEST(testSetBackgroundColor);
CPPUNIT_TEST(testRenameTable);
CPPUNIT_TEST(testAutoFill);
CPPUNIT_TEST(testCopyPasteFormulas);
CPPUNIT_TEST(testCopyPasteFormulasExternalDoc);
CPPUNIT_TEST(testFindAreaPosVertical);
CPPUNIT_TEST(testFindAreaPosColRight);
CPPUNIT_TEST(testSort);
CPPUNIT_TEST(testSortHorizontal);
CPPUNIT_TEST(testSortSingleRow);
CPPUNIT_TEST(testSortWithFormulaRefs);
CPPUNIT_TEST(testSortWithStrings);
CPPUNIT_TEST(testSortInFormulaGroup);
CPPUNIT_TEST(testSortWithCellFormats);
CPPUNIT_TEST(testSortRefUpdate);
CPPUNIT_TEST(testSortRefUpdate2);
CPPUNIT_TEST(testSortRefUpdate3);
CPPUNIT_TEST(testSortRefUpdate4);
CPPUNIT_TEST(testSortRefUpdate5);
CPPUNIT_TEST(testSortOutOfPlaceResult);
CPPUNIT_TEST(testSortPartialFormulaGroup);
CPPUNIT_TEST(testShiftCells);
CPPUNIT_TEST(testNoteBasic);
CPPUNIT_TEST(testNoteDeleteRow);
CPPUNIT_TEST(testNoteDeleteCol);
CPPUNIT_TEST(testNoteLifeCycle);
CPPUNIT_TEST(testNoteCopyPaste);
CPPUNIT_TEST(testAreasWithNotes);
CPPUNIT_TEST(testAnchoredRotatedShape);
CPPUNIT_TEST(testCellTextWidth);
CPPUNIT_TEST(testEditTextIterator);
CPPUNIT_TEST(testCondFormatINSDEL);
CPPUNIT_TEST(testCondFormatInsertRow);
CPPUNIT_TEST(testCondFormatInsertCol);
CPPUNIT_TEST(testCondFormatInsertDeleteSheets);
CPPUNIT_TEST(testCondCopyPaste);
CPPUNIT_TEST(testCondCopyPasteSingleCell);
CPPUNIT_TEST(testCopySheetCondFormat);
CPPUNIT_TEST(testIconSet);
CPPUNIT_TEST(testImportStream);
CPPUNIT_TEST(testDeleteContents);
CPPUNIT_TEST(testTransliterateText);
CPPUNIT_TEST(testColumnFindEditCells);
CPPUNIT_TEST_SUITE_END();
private:
TestImpl* m_pImpl;
ScDocument *m_pDoc;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|