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