Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / unit / ucalc_sparkline.cxx
blobd058d16f0248445c07c942144e90706a6e9458f7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #include "helper/qahelper.hxx"
11 #include <docsh.hxx>
12 #include <tabvwsh.hxx>
13 #include <cliputil.hxx>
14 #include <docfunc.hxx>
15 #include <undomanager.hxx>
17 #include <Sparkline.hxx>
18 #include <SparklineGroup.hxx>
19 #include <SparklineList.hxx>
20 #include <SparklineAttributes.hxx>
21 #include <ThemeColorChanger.hxx>
22 #include <docmodel/theme/Theme.hxx>
23 #include <svx/svdpage.hxx>
25 using namespace css;
27 /** Test operation for sparklines, sparkline groups and attributes */
28 class SparklineTest : public ScUcalcTestBase
32 namespace
34 void insertTestData(ScDocument& rDoc)
36 rDoc.SetValue(0, 0, 0, 4);
37 rDoc.SetValue(0, 1, 0, -2);
38 rDoc.SetValue(0, 2, 0, 1);
39 rDoc.SetValue(0, 3, 0, -3);
40 rDoc.SetValue(0, 4, 0, 5);
41 rDoc.SetValue(0, 5, 0, 3);
44 sc::Sparkline* createTestSparkline(ScDocument& rDoc)
46 auto pSparklineGroup = std::make_shared<sc::SparklineGroup>();
48 sc::Sparkline* pSparkline = rDoc.CreateSparkline(ScAddress(0, 6, 0), pSparklineGroup);
49 if (!pSparkline)
50 return nullptr;
52 insertTestData(rDoc);
54 ScRangeList aList;
55 aList.push_back(ScRange(0, 0, 0, 0, 5, 0));
56 pSparkline->setInputRange(aList);
58 return pSparkline;
61 } // end anonymous namespace
63 CPPUNIT_TEST_FIXTURE(SparklineTest, testAddSparkline)
65 m_pDoc->InsertTab(0, "Test");
67 auto pSparkline = createTestSparkline(*m_pDoc);
68 CPPUNIT_ASSERT(pSparkline);
70 auto pGetSparkline = m_pDoc->GetSparkline(ScAddress(0, 6, 0));
71 CPPUNIT_ASSERT(pGetSparkline);
73 CPPUNIT_ASSERT_EQUAL(pGetSparkline.get(), pSparkline);
75 sc::SparklineList* pList = m_pDoc->GetSparklineList(SCTAB(0));
76 CPPUNIT_ASSERT(pList);
78 CPPUNIT_ASSERT_EQUAL(size_t(1), pList->getSparklineGroups().size());
80 auto const& aSparklineVector = pList->getSparklinesFor(pGetSparkline->getSparklineGroup());
81 CPPUNIT_ASSERT_EQUAL(size_t(1), aSparklineVector.size());
82 CPPUNIT_ASSERT_EQUAL(aSparklineVector[0].get(), pSparkline);
84 m_pDoc->DeleteTab(0);
87 CPPUNIT_TEST_FIXTURE(SparklineTest, testClearContentSprkline)
89 m_pDoc->InsertTab(0, "Test");
91 auto pSparkline = createTestSparkline(*m_pDoc);
92 CPPUNIT_ASSERT(pSparkline);
94 clearRange(m_pDoc, ScRange(0, 6, 0, 0, 6, 0));
96 auto pGetSparkline = m_pDoc->GetSparkline(ScAddress(0, 6, 0));
97 CPPUNIT_ASSERT(!pGetSparkline);
99 m_pDoc->DeleteTab(0);
102 CPPUNIT_TEST_FIXTURE(SparklineTest, testCopyPasteSparkline)
104 m_pDoc->InsertTab(0, "Test");
106 auto* pCreatedSparkline = createTestSparkline(*m_pDoc);
107 CPPUNIT_ASSERT(pCreatedSparkline);
109 ScRange aSourceRange(0, 6, 0, 0, 6, 0);
110 auto pSparkline = m_pDoc->GetSparkline(aSourceRange.aStart);
111 auto const& pOriginalGroup = pSparkline->getSparklineGroup();
113 CPPUNIT_ASSERT(pSparkline);
114 CPPUNIT_ASSERT_EQUAL(SCCOL(0), pSparkline->getColumn());
115 CPPUNIT_ASSERT_EQUAL(SCROW(6), pSparkline->getRow());
117 // CopyToClip / CopyFromClip with a aClipDoc
119 ScDocument aClipDoc(SCDOCMODE_CLIP);
120 copyToClip(m_pDoc, aSourceRange, &aClipDoc);
122 auto pClipSparkline = aClipDoc.GetSparkline(aSourceRange.aStart);
123 CPPUNIT_ASSERT(pClipSparkline);
125 ScRange aPasteRange(0, 7, 0, 0, 7, 0);
127 ScMarkData aMark(m_pDoc->GetSheetLimits());
128 aMark.SetMarkArea(aPasteRange);
129 m_pDoc->CopyFromClip(aPasteRange, aMark, InsertDeleteFlags::ALL, nullptr, &aClipDoc);
131 auto pSparklineCopy = m_pDoc->GetSparkline(aPasteRange.aStart);
132 CPPUNIT_ASSERT(pSparklineCopy);
134 CPPUNIT_ASSERT_EQUAL(SCCOL(0), pSparklineCopy->getColumn());
135 CPPUNIT_ASSERT_EQUAL(SCROW(7), pSparklineCopy->getRow());
137 auto const& pCopyGroup = pSparklineCopy->getSparklineGroup();
139 CPPUNIT_ASSERT_EQUAL(pOriginalGroup->getID(), pCopyGroup->getID());
140 CPPUNIT_ASSERT_EQUAL(pOriginalGroup.get(), pCopyGroup.get());
143 // Copy / Paste with a Clim_pDoc
145 // Copy
146 ScDocument aClipDoc(SCDOCMODE_CLIP);
147 copyToClip(m_pDoc, aSourceRange, &aClipDoc);
149 // Paste
150 ScRange aPasteRange(0, 8, 0, 0, 8, 0);
152 pasteFromClip(m_pDoc, aPasteRange, &aClipDoc);
154 auto pSparklineCopy = m_pDoc->GetSparkline(aPasteRange.aStart);
155 CPPUNIT_ASSERT(pSparklineCopy);
157 CPPUNIT_ASSERT_EQUAL(SCCOL(0), pSparklineCopy->getColumn());
158 CPPUNIT_ASSERT_EQUAL(SCROW(8), pSparklineCopy->getRow());
160 auto const& pCopyGroup = pSparklineCopy->getSparklineGroup();
162 CPPUNIT_ASSERT_EQUAL(pOriginalGroup->getID(), pCopyGroup->getID());
163 CPPUNIT_ASSERT_EQUAL(pOriginalGroup.get(), pCopyGroup.get());
166 m_pDoc->DeleteTab(0);
169 CPPUNIT_TEST_FIXTURE(SparklineTest, testCutPasteSparkline)
171 m_pDoc->InsertTab(0, "Test");
173 auto* pCreatedSparkline = createTestSparkline(*m_pDoc);
174 CPPUNIT_ASSERT(pCreatedSparkline);
176 ScRange aSourceRange(0, 6, 0, 0, 6, 0);
177 auto pSparkline = m_pDoc->GetSparkline(aSourceRange.aStart);
179 CPPUNIT_ASSERT(pSparkline);
180 CPPUNIT_ASSERT_EQUAL(SCCOL(0), pSparkline->getColumn());
181 CPPUNIT_ASSERT_EQUAL(SCROW(6), pSparkline->getRow());
183 // Cut
184 ScDocument aClipDoc(SCDOCMODE_CLIP);
185 cutToClip(*m_xDocShell, aSourceRange, &aClipDoc, false);
187 // Paste
188 ScRange aPasteRange(0, 7, 0, 0, 7, 0);
189 pasteFromClip(m_pDoc, aPasteRange, &aClipDoc);
191 // Check
192 auto pSparklineCopy = m_pDoc->GetSparkline(aPasteRange.aStart);
193 CPPUNIT_ASSERT(pSparklineCopy);
195 CPPUNIT_ASSERT_EQUAL(SCCOL(0), pSparklineCopy->getColumn());
196 CPPUNIT_ASSERT_EQUAL(SCROW(7), pSparklineCopy->getRow());
198 m_pDoc->DeleteTab(0);
201 CPPUNIT_TEST_FIXTURE(SparklineTest, testUndoRedoInsertSparkline)
203 m_pDoc->InsertTab(0, "Test");
205 auto& rDocFunc = m_xDocShell->GetDocFunc();
207 // insert test data - A1:A6
208 insertTestData(*m_pDoc);
210 // Sparkline range
211 ScRange aRange(0, 6, 0, 0, 6, 0);
213 // Check Sparkline at cell A7 doesn't exists
214 auto pSparkline = m_pDoc->GetSparkline(aRange.aStart);
215 CPPUNIT_ASSERT(!pSparkline);
217 auto pSparklineGroup = std::make_shared<sc::SparklineGroup>();
218 rDocFunc.InsertSparklines(ScRange(0, 0, 0, 0, 5, 0), aRange, pSparklineGroup);
220 // Check Sparkline at cell A7 exists
221 pSparkline = m_pDoc->GetSparkline(aRange.aStart);
222 CPPUNIT_ASSERT(pSparkline);
223 CPPUNIT_ASSERT_EQUAL(SCCOL(0), pSparkline->getColumn());
224 CPPUNIT_ASSERT_EQUAL(SCROW(6), pSparkline->getRow());
226 // Undo
227 m_pDoc->GetUndoManager()->Undo();
229 // Check Sparkline at cell A7 doesn't exists
230 pSparkline = m_pDoc->GetSparkline(aRange.aStart);
231 CPPUNIT_ASSERT(!pSparkline);
233 // Redo
234 m_pDoc->GetUndoManager()->Redo();
236 // Check Sparkline at cell A7 exists
237 pSparkline = m_pDoc->GetSparkline(aRange.aStart);
238 CPPUNIT_ASSERT(pSparkline);
239 CPPUNIT_ASSERT_EQUAL(SCCOL(0), pSparkline->getColumn());
240 CPPUNIT_ASSERT_EQUAL(SCROW(6), pSparkline->getRow());
242 m_pDoc->DeleteTab(0);
245 CPPUNIT_TEST_FIXTURE(SparklineTest, testUndoRedoDeleteSparkline)
247 m_pDoc->InsertTab(0, "Test");
249 auto& rDocFunc = m_xDocShell->GetDocFunc();
251 // Try to delete sparkline that doesn't exist - returns false
252 CPPUNIT_ASSERT(!rDocFunc.DeleteSparkline(ScAddress(0, 6, 0)));
254 // insert test data - A1:A6
255 insertTestData(*m_pDoc);
257 // Sparkline range
258 ScRange aRange(0, 6, 0, 0, 6, 0);
260 // Check Sparkline at cell A7 doesn't exists
261 auto pSparkline = m_pDoc->GetSparkline(aRange.aStart);
262 CPPUNIT_ASSERT(!pSparkline);
264 auto pSparklineGroup = std::make_shared<sc::SparklineGroup>();
265 CPPUNIT_ASSERT(rDocFunc.InsertSparklines(ScRange(0, 0, 0, 0, 5, 0), aRange, pSparklineGroup));
267 // Check Sparkline at cell A7 exists
268 pSparkline = m_pDoc->GetSparkline(aRange.aStart);
269 CPPUNIT_ASSERT(pSparkline);
270 CPPUNIT_ASSERT_EQUAL(SCCOL(0), pSparkline->getColumn());
271 CPPUNIT_ASSERT_EQUAL(SCROW(6), pSparkline->getRow());
273 // Delete Sparkline
274 CPPUNIT_ASSERT(rDocFunc.DeleteSparkline(ScAddress(0, 6, 0)));
276 // Check Sparkline at cell A7 doesn't exists
277 pSparkline = m_pDoc->GetSparkline(aRange.aStart);
278 CPPUNIT_ASSERT(!pSparkline);
280 // Undo
281 m_pDoc->GetUndoManager()->Undo();
283 // Check Sparkline at cell A7 exists
284 pSparkline = m_pDoc->GetSparkline(aRange.aStart);
285 CPPUNIT_ASSERT(pSparkline);
286 CPPUNIT_ASSERT_EQUAL(SCCOL(0), pSparkline->getColumn());
287 CPPUNIT_ASSERT_EQUAL(SCROW(6), pSparkline->getRow());
289 // Redo
290 m_pDoc->GetUndoManager()->Redo();
292 // Check Sparkline at cell A7 doesn't exists
293 pSparkline = m_pDoc->GetSparkline(aRange.aStart);
294 CPPUNIT_ASSERT(!pSparkline);
296 CPPUNIT_ASSERT(!m_pDoc->HasSparkline(aRange.aStart));
298 m_pDoc->DeleteTab(0);
301 CPPUNIT_TEST_FIXTURE(SparklineTest, testUndoRedoDeleteSparklineGroup)
303 m_pDoc->InsertTab(0, "Test");
305 auto& rDocFunc = m_xDocShell->GetDocFunc();
307 // insert test data - A1:A6
308 insertTestData(*m_pDoc);
310 // Sparkline range
311 ScRange aDataRange(0, 0, 0, 3, 5, 0); //A1:D6
312 ScRange aRange(0, 6, 0, 3, 6, 0); // A7:D7
314 auto pSparklineGroup = std::make_shared<sc::SparklineGroup>();
315 CPPUNIT_ASSERT(rDocFunc.InsertSparklines(aDataRange, aRange, pSparklineGroup));
317 // Check Sparklines
318 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(0, 6, 0))); // A7
319 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(1, 6, 0)));
320 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(2, 6, 0)));
321 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(3, 6, 0))); // D7
323 // Delete Sparkline
324 CPPUNIT_ASSERT(rDocFunc.DeleteSparklineGroup(pSparklineGroup, SCTAB(0)));
326 // Check Sparklines
327 CPPUNIT_ASSERT_EQUAL(false, m_pDoc->HasSparkline(ScAddress(0, 6, 0))); // A7
328 CPPUNIT_ASSERT_EQUAL(false, m_pDoc->HasSparkline(ScAddress(1, 6, 0)));
329 CPPUNIT_ASSERT_EQUAL(false, m_pDoc->HasSparkline(ScAddress(2, 6, 0)));
330 CPPUNIT_ASSERT_EQUAL(false, m_pDoc->HasSparkline(ScAddress(3, 6, 0))); // D7
332 // Undo
333 m_pDoc->GetUndoManager()->Undo();
335 // Check Sparklines
336 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(0, 6, 0))); // A7
337 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(1, 6, 0)));
338 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(2, 6, 0)));
339 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(3, 6, 0))); // D7
341 // Check if the sparkline has the input range set
342 auto const& pSparkline = m_pDoc->GetSparkline(ScAddress(3, 6, 0));
343 ScRangeList rRangeList = pSparkline->getInputRange();
344 CPPUNIT_ASSERT_EQUAL(size_t(1), rRangeList.size());
345 CPPUNIT_ASSERT_EQUAL(ScRange(3, 0, 0, 3, 5, 0), rRangeList[0]);
347 // Redo
348 m_pDoc->GetUndoManager()->Redo();
350 // Check Sparklines
351 CPPUNIT_ASSERT_EQUAL(false, m_pDoc->HasSparkline(ScAddress(0, 6, 0))); // A7
352 CPPUNIT_ASSERT_EQUAL(false, m_pDoc->HasSparkline(ScAddress(1, 6, 0)));
353 CPPUNIT_ASSERT_EQUAL(false, m_pDoc->HasSparkline(ScAddress(2, 6, 0)));
354 CPPUNIT_ASSERT_EQUAL(false, m_pDoc->HasSparkline(ScAddress(3, 6, 0))); // D7
356 m_pDoc->DeleteTab(0);
359 CPPUNIT_TEST_FIXTURE(SparklineTest, testUndoRedoClearContentForSparkline)
361 m_pDoc->InsertTab(0, "Test");
363 auto& rDocFunc = m_xDocShell->GetDocFunc();
365 // Try to delete sparkline that doesn't exist - returns false
366 CPPUNIT_ASSERT(!rDocFunc.DeleteSparkline(ScAddress(0, 6, 0)));
368 // insert test data - A1:A6
369 insertTestData(*m_pDoc);
371 // Sparkline range
372 ScRange aDataRange(0, 0, 0, 3, 5, 0); //A1:D6
373 ScRange aRange(0, 6, 0, 3, 6, 0); // A7:D7
375 // Check Sparklines - none should exist
377 CPPUNIT_ASSERT(!m_pDoc->HasSparkline(ScAddress(0, 6, 0)));
378 CPPUNIT_ASSERT(!m_pDoc->HasSparkline(ScAddress(1, 6, 0)));
379 CPPUNIT_ASSERT(!m_pDoc->HasSparkline(ScAddress(2, 6, 0)));
380 CPPUNIT_ASSERT(!m_pDoc->HasSparkline(ScAddress(3, 6, 0)));
383 auto pSparklineGroup = std::make_shared<sc::SparklineGroup>();
384 CPPUNIT_ASSERT(rDocFunc.InsertSparklines(aDataRange, aRange, pSparklineGroup));
386 // Check Sparklines
388 CPPUNIT_ASSERT(m_pDoc->HasSparkline(ScAddress(0, 6, 0)));
389 CPPUNIT_ASSERT(m_pDoc->HasSparkline(ScAddress(1, 6, 0)));
390 CPPUNIT_ASSERT(m_pDoc->HasSparkline(ScAddress(2, 6, 0)));
391 // D7 exists
392 CPPUNIT_ASSERT(m_pDoc->HasSparkline(ScAddress(3, 6, 0)));
394 // Check D7
395 auto pSparkline = m_pDoc->GetSparkline(ScAddress(3, 6, 0));
396 CPPUNIT_ASSERT_EQUAL(SCCOL(3), pSparkline->getColumn());
397 CPPUNIT_ASSERT_EQUAL(SCROW(6), pSparkline->getRow());
399 // Check collections
400 auto* pSparklineList = m_pDoc->GetSparklineList(SCTAB(0));
401 auto pSparklineGroups = pSparklineList->getSparklineGroups();
402 CPPUNIT_ASSERT_EQUAL(size_t(1), pSparklineGroups.size());
404 auto pSparklines = pSparklineList->getSparklinesFor(pSparklineGroups[0]);
405 CPPUNIT_ASSERT_EQUAL(size_t(4), pSparklines.size());
408 // Clear content of cell D7 - including sparkline
410 ScMarkData aMark(m_pDoc->GetSheetLimits());
411 aMark.SetMarkArea(ScAddress(3, 6, 0));
412 rDocFunc.DeleteContents(aMark, InsertDeleteFlags::CONTENTS, true, true);
415 // Check Sparklines
417 CPPUNIT_ASSERT(m_pDoc->HasSparkline(ScAddress(1, 6, 0)));
418 CPPUNIT_ASSERT(m_pDoc->HasSparkline(ScAddress(1, 6, 0)));
419 CPPUNIT_ASSERT(m_pDoc->HasSparkline(ScAddress(2, 6, 0)));
420 // D7 is gone
421 CPPUNIT_ASSERT(!m_pDoc->HasSparkline(ScAddress(3, 6, 0)));
423 // Check collections
424 auto* pSparklineList = m_pDoc->GetSparklineList(SCTAB(0));
425 auto pSparklineGroups = pSparklineList->getSparklineGroups();
426 CPPUNIT_ASSERT_EQUAL(size_t(1), pSparklineGroups.size());
428 auto pSparklines = pSparklineList->getSparklinesFor(pSparklineGroups[0]);
429 CPPUNIT_ASSERT_EQUAL(size_t(3), pSparklines.size());
432 // Undo
433 m_pDoc->GetUndoManager()->Undo();
435 // Check Sparkline
437 CPPUNIT_ASSERT(m_pDoc->HasSparkline(ScAddress(0, 6, 0)));
438 CPPUNIT_ASSERT(m_pDoc->HasSparkline(ScAddress(1, 6, 0)));
439 CPPUNIT_ASSERT(m_pDoc->HasSparkline(ScAddress(2, 6, 0)));
440 // D7 exists - again
441 CPPUNIT_ASSERT(m_pDoc->HasSparkline(ScAddress(3, 6, 0)));
443 // Check D7
444 auto pSparkline = m_pDoc->GetSparkline(ScAddress(3, 6, 0));
445 CPPUNIT_ASSERT_EQUAL(SCCOL(3), pSparkline->getColumn());
446 CPPUNIT_ASSERT_EQUAL(SCROW(6), pSparkline->getRow());
448 auto* pSparklineList = m_pDoc->GetSparklineList(SCTAB(0));
449 auto pSparklineGroups = pSparklineList->getSparklineGroups();
450 CPPUNIT_ASSERT_EQUAL(size_t(1), pSparklineGroups.size());
452 auto pSparklines = pSparklineList->getSparklinesFor(pSparklineGroups[0]);
453 CPPUNIT_ASSERT_EQUAL(size_t(4), pSparklines.size());
456 // Redo
457 m_pDoc->GetUndoManager()->Redo();
459 // Check Sparklines
461 CPPUNIT_ASSERT(m_pDoc->HasSparkline(ScAddress(1, 6, 0)));
462 CPPUNIT_ASSERT(m_pDoc->HasSparkline(ScAddress(1, 6, 0)));
463 CPPUNIT_ASSERT(m_pDoc->HasSparkline(ScAddress(2, 6, 0)));
464 // D7 is gone - again
465 CPPUNIT_ASSERT(!m_pDoc->HasSparkline(ScAddress(3, 6, 0)));
467 // Check collections
468 auto* pSparklineList = m_pDoc->GetSparklineList(SCTAB(0));
469 auto pSparklineGroups = pSparklineList->getSparklineGroups();
470 CPPUNIT_ASSERT_EQUAL(size_t(1), pSparklineGroups.size());
472 auto pSparklines = pSparklineList->getSparklinesFor(pSparklineGroups[0]);
473 CPPUNIT_ASSERT_EQUAL(size_t(3), pSparklines.size());
475 m_pDoc->DeleteTab(0);
478 CPPUNIT_TEST_FIXTURE(SparklineTest, testUndoRedoEditSparklineGroup)
480 m_pDoc->InsertTab(0, "Test");
482 auto& rDocFunc = m_xDocShell->GetDocFunc();
484 auto pSparklineGroup = std::make_shared<sc::SparklineGroup>();
486 sc::SparklineAttributes& rAttibutes = pSparklineGroup->getAttributes();
487 rAttibutes.setType(sc::SparklineType::Column);
488 rAttibutes.setColorSeries(model::ComplexColor::createRGB(COL_YELLOW));
489 rAttibutes.setColorAxis(model::ComplexColor::createRGB(COL_GREEN));
492 m_pDoc->CreateSparkline(ScAddress(0, 6, 0), pSparklineGroup);
494 sc::SparklineAttributes aNewAttributes;
495 aNewAttributes.setType(sc::SparklineType::Stacked);
496 aNewAttributes.setColorSeries(model::ComplexColor::createRGB(COL_BLACK));
497 aNewAttributes.setColorAxis(model::ComplexColor::createRGB(COL_BLUE));
499 sc::SparklineAttributes aInitialAttibutes(pSparklineGroup->getAttributes());
501 CPPUNIT_ASSERT(aNewAttributes != aInitialAttibutes);
503 CPPUNIT_ASSERT_EQUAL(true, aInitialAttibutes == pSparklineGroup->getAttributes());
504 CPPUNIT_ASSERT_EQUAL(false, aNewAttributes == pSparklineGroup->getAttributes());
506 CPPUNIT_ASSERT_EQUAL(sc::SparklineType::Column, pSparklineGroup->getAttributes().getType());
507 CPPUNIT_ASSERT_EQUAL(COL_YELLOW,
508 pSparklineGroup->getAttributes().getColorSeries().getFinalColor());
509 CPPUNIT_ASSERT_EQUAL(COL_GREEN,
510 pSparklineGroup->getAttributes().getColorAxis().getFinalColor());
512 rDocFunc.ChangeSparklineGroupAttributes(pSparklineGroup, aNewAttributes);
514 CPPUNIT_ASSERT_EQUAL(false, aInitialAttibutes == pSparklineGroup->getAttributes());
515 CPPUNIT_ASSERT_EQUAL(true, aNewAttributes == pSparklineGroup->getAttributes());
517 CPPUNIT_ASSERT_EQUAL(sc::SparklineType::Stacked, pSparklineGroup->getAttributes().getType());
518 CPPUNIT_ASSERT_EQUAL(COL_BLACK,
519 pSparklineGroup->getAttributes().getColorSeries().getFinalColor());
520 CPPUNIT_ASSERT_EQUAL(COL_BLUE, pSparklineGroup->getAttributes().getColorAxis().getFinalColor());
522 m_pDoc->GetUndoManager()->Undo();
524 CPPUNIT_ASSERT_EQUAL(true, aInitialAttibutes == pSparklineGroup->getAttributes());
525 CPPUNIT_ASSERT_EQUAL(false, aNewAttributes == pSparklineGroup->getAttributes());
527 CPPUNIT_ASSERT_EQUAL(sc::SparklineType::Column, pSparklineGroup->getAttributes().getType());
528 CPPUNIT_ASSERT_EQUAL(COL_YELLOW,
529 pSparklineGroup->getAttributes().getColorSeries().getFinalColor());
530 CPPUNIT_ASSERT_EQUAL(COL_GREEN,
531 pSparklineGroup->getAttributes().getColorAxis().getFinalColor());
533 m_pDoc->GetUndoManager()->Redo();
535 CPPUNIT_ASSERT_EQUAL(false, aInitialAttibutes == pSparklineGroup->getAttributes());
536 CPPUNIT_ASSERT_EQUAL(true, aNewAttributes == pSparklineGroup->getAttributes());
538 CPPUNIT_ASSERT_EQUAL(sc::SparklineType::Stacked, pSparklineGroup->getAttributes().getType());
539 CPPUNIT_ASSERT_EQUAL(COL_BLACK,
540 pSparklineGroup->getAttributes().getColorSeries().getFinalColor());
541 CPPUNIT_ASSERT_EQUAL(COL_BLUE, pSparklineGroup->getAttributes().getColorAxis().getFinalColor());
543 m_pDoc->DeleteTab(0);
546 CPPUNIT_TEST_FIXTURE(SparklineTest, testUndoRedoUngroupSparklines)
548 m_pDoc->InsertTab(0, "Test");
550 auto& rDocFunc = m_xDocShell->GetDocFunc();
552 // insert test data - A1:A6
553 insertTestData(*m_pDoc);
555 // Sparkline range
556 ScRange aDataRange(0, 0, 0, 3, 5, 0); //A1:D6
557 ScRange aRange(0, 6, 0, 3, 6, 0); // A7:D7
559 auto pSparklineGroup = std::make_shared<sc::SparklineGroup>();
560 CPPUNIT_ASSERT(rDocFunc.InsertSparklines(aDataRange, aRange, pSparklineGroup));
562 // Check Sparklines
564 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(0, 6, 0))); // A7
565 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(1, 6, 0)));
566 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(2, 6, 0)));
567 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(3, 6, 0))); // D7
569 auto pGroup1 = m_pDoc->GetSparkline(ScAddress(0, 6, 0))->getSparklineGroup();
570 auto pGroup2 = m_pDoc->GetSparkline(ScAddress(1, 6, 0))->getSparklineGroup();
571 auto pGroup3 = m_pDoc->GetSparkline(ScAddress(2, 6, 0))->getSparklineGroup();
572 auto pGroup4 = m_pDoc->GetSparkline(ScAddress(3, 6, 0))->getSparklineGroup();
574 CPPUNIT_ASSERT_EQUAL(pGroup1, pGroup2);
575 CPPUNIT_ASSERT_EQUAL(pGroup1, pGroup3);
576 CPPUNIT_ASSERT_EQUAL(pGroup1, pGroup4);
577 CPPUNIT_ASSERT_EQUAL(pGroup3, pGroup4);
580 CPPUNIT_ASSERT(rDocFunc.UngroupSparklines(ScRange(2, 6, 0, 3, 6, 0)));
582 // Check Sparklines
584 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(0, 6, 0))); // A7
585 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(1, 6, 0)));
586 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(2, 6, 0)));
587 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(3, 6, 0))); // D7
589 auto pGroup1 = m_pDoc->GetSparkline(ScAddress(0, 6, 0))->getSparklineGroup();
590 auto pGroup2 = m_pDoc->GetSparkline(ScAddress(1, 6, 0))->getSparklineGroup();
591 auto pGroup3 = m_pDoc->GetSparkline(ScAddress(2, 6, 0))->getSparklineGroup();
592 auto pGroup4 = m_pDoc->GetSparkline(ScAddress(3, 6, 0))->getSparklineGroup();
594 CPPUNIT_ASSERT_EQUAL(pGroup1, pGroup2);
595 CPPUNIT_ASSERT(pGroup1 != pGroup3);
596 CPPUNIT_ASSERT(pGroup1 != pGroup4);
597 CPPUNIT_ASSERT(pGroup3 != pGroup4);
600 // Undo
601 m_pDoc->GetUndoManager()->Undo();
603 // Check Sparklines
605 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(0, 6, 0))); // A7
606 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(1, 6, 0)));
607 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(2, 6, 0)));
608 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(3, 6, 0))); // D7
610 auto pGroup1 = m_pDoc->GetSparkline(ScAddress(0, 6, 0))->getSparklineGroup();
611 auto pGroup2 = m_pDoc->GetSparkline(ScAddress(1, 6, 0))->getSparklineGroup();
612 auto pGroup3 = m_pDoc->GetSparkline(ScAddress(2, 6, 0))->getSparklineGroup();
613 auto pGroup4 = m_pDoc->GetSparkline(ScAddress(3, 6, 0))->getSparklineGroup();
615 CPPUNIT_ASSERT_EQUAL(pGroup1, pGroup2);
616 CPPUNIT_ASSERT_EQUAL(pGroup1, pGroup3);
617 CPPUNIT_ASSERT_EQUAL(pGroup1, pGroup4);
618 CPPUNIT_ASSERT_EQUAL(pGroup3, pGroup4);
621 // Redo
622 m_pDoc->GetUndoManager()->Redo();
624 // Check Sparklines
626 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(0, 6, 0))); // A7
627 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(1, 6, 0)));
628 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(2, 6, 0)));
629 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(3, 6, 0))); // D7
631 auto pGroup1 = m_pDoc->GetSparkline(ScAddress(0, 6, 0))->getSparklineGroup();
632 auto pGroup2 = m_pDoc->GetSparkline(ScAddress(1, 6, 0))->getSparklineGroup();
633 auto pGroup3 = m_pDoc->GetSparkline(ScAddress(2, 6, 0))->getSparklineGroup();
634 auto pGroup4 = m_pDoc->GetSparkline(ScAddress(3, 6, 0))->getSparklineGroup();
636 CPPUNIT_ASSERT_EQUAL(pGroup1, pGroup2);
637 CPPUNIT_ASSERT(pGroup1 != pGroup3);
638 CPPUNIT_ASSERT(pGroup1 != pGroup4);
639 CPPUNIT_ASSERT(pGroup3 != pGroup4);
641 m_pDoc->DeleteTab(0);
644 CPPUNIT_TEST_FIXTURE(SparklineTest, testUndoRedoGroupSparklines)
646 m_pDoc->InsertTab(0, "Test");
648 auto& rDocFunc = m_xDocShell->GetDocFunc();
650 // insert test data - A1:A6
651 insertTestData(*m_pDoc);
653 // Sparkline range
654 ScRange aDataRange(0, 0, 0, 3, 5, 0); //A1:D6
655 ScRange aRange(0, 6, 0, 3, 6, 0); // A7:D7
657 auto pSparklineGroup = std::make_shared<sc::SparklineGroup>();
658 CPPUNIT_ASSERT(rDocFunc.InsertSparklines(aDataRange, aRange, pSparklineGroup));
660 // Check Sparklines
662 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(0, 6, 0))); // A7
663 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(1, 6, 0)));
664 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(2, 6, 0)));
665 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(3, 6, 0))); // D7
667 auto pGroup1 = m_pDoc->GetSparkline(ScAddress(0, 6, 0))->getSparklineGroup();
668 auto pGroup2 = m_pDoc->GetSparkline(ScAddress(1, 6, 0))->getSparklineGroup();
669 auto pGroup3 = m_pDoc->GetSparkline(ScAddress(2, 6, 0))->getSparklineGroup();
670 auto pGroup4 = m_pDoc->GetSparkline(ScAddress(3, 6, 0))->getSparklineGroup();
672 CPPUNIT_ASSERT_EQUAL(pGroup1, pGroup2);
673 CPPUNIT_ASSERT_EQUAL(pGroup1, pGroup3);
674 CPPUNIT_ASSERT_EQUAL(pGroup1, pGroup4);
675 CPPUNIT_ASSERT_EQUAL(pGroup3, pGroup4);
678 CPPUNIT_ASSERT(rDocFunc.UngroupSparklines(ScRange(2, 6, 0, 3, 6, 0)));
680 // Check Sparklines
682 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(0, 6, 0))); // A7
683 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(1, 6, 0)));
684 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(2, 6, 0)));
685 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(3, 6, 0))); // D7
687 auto pGroup1 = m_pDoc->GetSparkline(ScAddress(0, 6, 0))->getSparklineGroup();
688 auto pGroup2 = m_pDoc->GetSparkline(ScAddress(1, 6, 0))->getSparklineGroup();
689 auto pGroup3 = m_pDoc->GetSparkline(ScAddress(2, 6, 0))->getSparklineGroup();
690 auto pGroup4 = m_pDoc->GetSparkline(ScAddress(3, 6, 0))->getSparklineGroup();
692 CPPUNIT_ASSERT_EQUAL(pGroup1, pGroup2);
693 CPPUNIT_ASSERT(pGroup1 != pGroup3);
694 CPPUNIT_ASSERT(pGroup1 != pGroup4);
695 CPPUNIT_ASSERT(pGroup3 != pGroup4);
699 auto pGroup = m_pDoc->GetSparkline(ScAddress(3, 6, 0))->getSparklineGroup();
700 CPPUNIT_ASSERT(rDocFunc.GroupSparklines(ScRange(1, 6, 0, 3, 6, 0), pGroup));
703 // Check Sparklines
705 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(0, 6, 0))); // A7
706 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(1, 6, 0)));
707 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(2, 6, 0)));
708 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(3, 6, 0))); // D7
710 auto pGroup1 = m_pDoc->GetSparkline(ScAddress(0, 6, 0))->getSparklineGroup();
711 auto pGroup2 = m_pDoc->GetSparkline(ScAddress(1, 6, 0))->getSparklineGroup();
712 auto pGroup3 = m_pDoc->GetSparkline(ScAddress(2, 6, 0))->getSparklineGroup();
713 auto pGroup4 = m_pDoc->GetSparkline(ScAddress(3, 6, 0))->getSparklineGroup();
715 CPPUNIT_ASSERT(pGroup1 != pGroup2);
716 CPPUNIT_ASSERT(pGroup1 != pGroup3);
717 CPPUNIT_ASSERT(pGroup1 != pGroup4);
718 CPPUNIT_ASSERT_EQUAL(pGroup2, pGroup3);
719 CPPUNIT_ASSERT_EQUAL(pGroup2, pGroup4);
720 CPPUNIT_ASSERT_EQUAL(pGroup3, pGroup4);
723 // Undo
724 m_pDoc->GetUndoManager()->Undo();
726 // Check Sparklines
728 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(0, 6, 0))); // A7
729 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(1, 6, 0)));
730 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(2, 6, 0)));
731 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(3, 6, 0))); // D7
733 auto pGroup1 = m_pDoc->GetSparkline(ScAddress(0, 6, 0))->getSparklineGroup();
734 auto pGroup2 = m_pDoc->GetSparkline(ScAddress(1, 6, 0))->getSparklineGroup();
735 auto pGroup3 = m_pDoc->GetSparkline(ScAddress(2, 6, 0))->getSparklineGroup();
736 auto pGroup4 = m_pDoc->GetSparkline(ScAddress(3, 6, 0))->getSparklineGroup();
738 CPPUNIT_ASSERT_EQUAL(pGroup1, pGroup2);
739 CPPUNIT_ASSERT(pGroup1 != pGroup3);
740 CPPUNIT_ASSERT(pGroup1 != pGroup4);
741 CPPUNIT_ASSERT(pGroup3 != pGroup4);
744 // Redo
745 m_pDoc->GetUndoManager()->Redo();
747 // Check Sparklines
749 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(0, 6, 0))); // A7
750 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(1, 6, 0)));
751 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(2, 6, 0)));
752 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(3, 6, 0))); // D7
754 auto pGroup1 = m_pDoc->GetSparkline(ScAddress(0, 6, 0))->getSparklineGroup();
755 auto pGroup2 = m_pDoc->GetSparkline(ScAddress(1, 6, 0))->getSparklineGroup();
756 auto pGroup3 = m_pDoc->GetSparkline(ScAddress(2, 6, 0))->getSparklineGroup();
757 auto pGroup4 = m_pDoc->GetSparkline(ScAddress(3, 6, 0))->getSparklineGroup();
759 CPPUNIT_ASSERT(pGroup1 != pGroup2);
760 CPPUNIT_ASSERT(pGroup1 != pGroup3);
761 CPPUNIT_ASSERT(pGroup1 != pGroup4);
762 CPPUNIT_ASSERT_EQUAL(pGroup2, pGroup3);
763 CPPUNIT_ASSERT_EQUAL(pGroup2, pGroup4);
764 CPPUNIT_ASSERT_EQUAL(pGroup3, pGroup4);
766 m_pDoc->DeleteTab(0);
769 CPPUNIT_TEST_FIXTURE(SparklineTest, testUndoRedoEditSparkline)
771 m_pDoc->InsertTab(0, "Test");
773 auto& rDocFunc = m_xDocShell->GetDocFunc();
775 // Try to delete sparkline that doesn't exist - returns false
776 CPPUNIT_ASSERT(!rDocFunc.DeleteSparkline(ScAddress(0, 6, 0)));
778 // insert test data - A1:A6
779 insertTestData(*m_pDoc);
781 // Sparkline range
782 ScAddress aAddress(0, 6, 0);
783 ScRange aRange(aAddress);
785 // Check Sparkline at cell A7 doesn't exists
786 auto pSparkline = m_pDoc->GetSparkline(aAddress);
787 CPPUNIT_ASSERT(!pSparkline);
789 auto pSparklineGroup = std::make_shared<sc::SparklineGroup>();
790 CPPUNIT_ASSERT(rDocFunc.InsertSparklines(ScRange(0, 0, 0, 0, 5, 0), aRange, pSparklineGroup));
792 // Check Sparkline at cell A7
793 pSparkline = m_pDoc->GetSparkline(aAddress);
794 CPPUNIT_ASSERT(pSparkline);
795 CPPUNIT_ASSERT_EQUAL(size_t(1), pSparkline->getInputRange().size());
796 CPPUNIT_ASSERT_EQUAL(ScRange(0, 0, 0, 0, 5, 0), pSparkline->getInputRange()[0]);
798 // Change Sparkline
799 CPPUNIT_ASSERT(
800 rDocFunc.ChangeSparkline(pSparkline, SCTAB(0), ScRangeList(ScRange(0, 1, 0, 0, 4, 0))));
802 pSparkline = m_pDoc->GetSparkline(aAddress);
803 CPPUNIT_ASSERT(pSparkline);
804 CPPUNIT_ASSERT_EQUAL(size_t(1), pSparkline->getInputRange().size());
805 CPPUNIT_ASSERT_EQUAL(ScRange(0, 1, 0, 0, 4, 0), pSparkline->getInputRange()[0]);
807 // Undo
808 m_pDoc->GetUndoManager()->Undo();
810 pSparkline = m_pDoc->GetSparkline(aAddress);
811 CPPUNIT_ASSERT(pSparkline);
812 CPPUNIT_ASSERT_EQUAL(size_t(1), pSparkline->getInputRange().size());
813 CPPUNIT_ASSERT_EQUAL(ScRange(0, 0, 0, 0, 5, 0), pSparkline->getInputRange()[0]);
815 // Redo
816 m_pDoc->GetUndoManager()->Redo();
818 pSparkline = m_pDoc->GetSparkline(aAddress);
819 CPPUNIT_ASSERT(pSparkline);
820 CPPUNIT_ASSERT_EQUAL(size_t(1), pSparkline->getInputRange().size());
821 CPPUNIT_ASSERT_EQUAL(ScRange(0, 1, 0, 0, 4, 0), pSparkline->getInputRange()[0]);
823 m_pDoc->DeleteTab(0);
826 CPPUNIT_TEST_FIXTURE(SparklineTest, testSparklineList)
828 m_pDoc->InsertTab(0, "Test");
830 auto pSparklineGroup = std::make_shared<sc::SparklineGroup>();
832 m_pDoc->CreateSparkline(ScAddress(0, 6, 0), pSparklineGroup);
835 auto* pSparklineList = m_pDoc->GetSparklineList(SCTAB(0));
836 auto pSparklineGroups = pSparklineList->getSparklineGroups();
837 CPPUNIT_ASSERT_EQUAL(size_t(1), pSparklineGroups.size());
839 auto pSparklines = pSparklineList->getSparklinesFor(pSparklineGroups[0]);
840 CPPUNIT_ASSERT_EQUAL(size_t(1), pSparklines.size());
842 m_pDoc->CreateSparkline(ScAddress(1, 6, 0), pSparklineGroup);
843 m_pDoc->CreateSparkline(ScAddress(2, 6, 0), pSparklineGroup);
846 auto* pSparklineList = m_pDoc->GetSparklineList(SCTAB(0));
847 auto pSparklineGroups = pSparklineList->getSparklineGroups();
848 CPPUNIT_ASSERT_EQUAL(size_t(1), pSparklineGroups.size());
850 auto pSparklines = pSparklineList->getSparklinesFor(pSparklineGroups[0]);
851 CPPUNIT_ASSERT_EQUAL(size_t(3), pSparklines.size());
855 auto pSparklineGroup2 = std::make_shared<sc::SparklineGroup>();
856 m_pDoc->CreateSparkline(ScAddress(3, 6, 0), pSparklineGroup2);
858 auto* pSparklineList = m_pDoc->GetSparklineList(SCTAB(0));
860 auto pSparklineGroups = pSparklineList->getSparklineGroups();
861 CPPUNIT_ASSERT_EQUAL(size_t(2), pSparklineGroups.size());
863 auto pSparklines2 = pSparklineList->getSparklinesFor(pSparklineGroup2);
864 CPPUNIT_ASSERT_EQUAL(size_t(1), pSparklines2.size());
867 m_pDoc->DeleteSparkline(ScAddress(3, 6, 0));
870 auto* pSparklineList = m_pDoc->GetSparklineList(SCTAB(0));
872 auto pSparklineGroups = pSparklineList->getSparklineGroups();
873 CPPUNIT_ASSERT_EQUAL(size_t(1), pSparklineGroups.size());
875 auto pSparklines = pSparklineList->getSparklinesFor(pSparklineGroups[0]);
876 CPPUNIT_ASSERT_EQUAL(size_t(3), pSparklines.size());
880 CPPUNIT_TEST_FIXTURE(SparklineTest, testSparklineThemeColorChange)
882 m_pDoc->InitDrawLayer();
883 m_pDoc->InsertTab(0, "Test");
885 // insert test data - A1:A6
886 insertTestData(*m_pDoc);
888 auto& rDocFunc = m_xDocShell->GetDocFunc();
890 ScDrawLayer* pDrawLayer = m_pDoc->GetDrawLayer();
891 CPPUNIT_ASSERT(pDrawLayer);
892 auto const& pTheme = pDrawLayer->getTheme();
893 CPPUNIT_ASSERT(pTheme);
895 // Sparkline range
896 ScRange aDataRange(0, 0, 0, 3, 5, 0); //A1:D6
897 ScRange aRange(0, 6, 0, 3, 6, 0); // A7:D7
900 auto pSparklineGroup = std::make_shared<sc::SparklineGroup>();
901 sc::SparklineAttributes& rAttibutes = pSparklineGroup->getAttributes();
903 model::ComplexColor aSeriesComplexColor;
904 aSeriesComplexColor.setThemeColor(model::ThemeColorType::Accent3);
905 aSeriesComplexColor.setFinalColor(pTheme->getColorSet()->resolveColor(aSeriesComplexColor));
906 rAttibutes.setColorSeries(aSeriesComplexColor);
908 model::ComplexColor aAxisComplexColor;
909 aAxisComplexColor.setThemeColor(model::ThemeColorType::Accent1);
910 aAxisComplexColor.setFinalColor(pTheme->getColorSet()->resolveColor(aAxisComplexColor));
911 rAttibutes.setColorAxis(aAxisComplexColor);
913 CPPUNIT_ASSERT(rDocFunc.InsertSparklines(aDataRange, aRange, pSparklineGroup));
917 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(0, 6, 0))); // A7
918 auto pGroup = m_pDoc->GetSparkline(ScAddress(0, 6, 0))->getSparklineGroup();
919 CPPUNIT_ASSERT(pGroup);
920 sc::SparklineAttributes& rAttibutes = pGroup->getAttributes();
921 CPPUNIT_ASSERT_EQUAL(Color(0xa33e03), rAttibutes.getColorSeries().getFinalColor());
922 CPPUNIT_ASSERT_EQUAL(Color(0x18a303), rAttibutes.getColorAxis().getFinalColor());
926 auto pColorSet = std::make_shared<model::ColorSet>("TestColorScheme");
927 pColorSet->add(model::ThemeColorType::Dark1, 0x000000);
928 pColorSet->add(model::ThemeColorType::Light1, 0x111111);
929 pColorSet->add(model::ThemeColorType::Dark2, 0x222222);
930 pColorSet->add(model::ThemeColorType::Light2, 0x333333);
931 pColorSet->add(model::ThemeColorType::Accent1, 0x444444);
932 pColorSet->add(model::ThemeColorType::Accent2, 0x555555);
933 pColorSet->add(model::ThemeColorType::Accent3, 0x666666);
934 pColorSet->add(model::ThemeColorType::Accent4, 0x777777);
935 pColorSet->add(model::ThemeColorType::Accent5, 0x888888);
936 pColorSet->add(model::ThemeColorType::Accent6, 0x999999);
937 pColorSet->add(model::ThemeColorType::Hyperlink, 0xaaaaaa);
938 pColorSet->add(model::ThemeColorType::FollowedHyperlink, 0xbbbbbb);
940 sc::ThemeColorChanger aChanger(*m_xDocShell);
941 aChanger.apply(pColorSet);
945 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(0, 6, 0))); // A7
946 auto pGroup = m_pDoc->GetSparkline(ScAddress(0, 6, 0))->getSparklineGroup();
947 CPPUNIT_ASSERT(pGroup);
948 sc::SparklineAttributes& rAttibutes = pGroup->getAttributes();
949 CPPUNIT_ASSERT_EQUAL(Color(0x666666), rAttibutes.getColorSeries().getFinalColor());
950 CPPUNIT_ASSERT_EQUAL(Color(0x444444), rAttibutes.getColorAxis().getFinalColor());
953 m_pDoc->GetUndoManager()->Undo();
956 CPPUNIT_ASSERT_EQUAL(true, m_pDoc->HasSparkline(ScAddress(0, 6, 0))); // A7
957 auto pGroup = m_pDoc->GetSparkline(ScAddress(0, 6, 0))->getSparklineGroup();
958 CPPUNIT_ASSERT(pGroup);
959 sc::SparklineAttributes& rAttibutes = pGroup->getAttributes();
960 CPPUNIT_ASSERT_EQUAL(Color(0xa33e03), rAttibutes.getColorSeries().getFinalColor());
961 CPPUNIT_ASSERT_EQUAL(Color(0x18a303), rAttibutes.getColorAxis().getFinalColor());
965 CPPUNIT_PLUGIN_IMPLEMENT();
967 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */