LibreOffice Module sc (master) 1
colorscale.cxx
Go to the documentation of this file.
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#include <memory>
11#include <colorscale.hxx>
12#include <document.hxx>
13#include <formulacell.hxx>
14#include <fillinfo.hxx>
15#include <bitmaps.hlst>
16#include <tokenarray.hxx>
17#include <refupdatecontext.hxx>
18#include <refdata.hxx>
19#include <editeng/fhgtitem.hxx>
20#include <scitems.hxx>
21
22#include <formula/token.hxx>
23#include <vcl/bitmapex.hxx>
24
25#include <algorithm>
26#include <cassert>
27
29 mbDirty(false),
30 mrDoc(pCell->GetDocument())
31{
32 startListening( pCell->GetCode(), pCell->aPos );
33}
34
36 mbDirty(false),
37 mrDoc(rDoc)
38{
39}
40
42 mbDirty(false),
43 mrDoc(rDoc)
44{
45 startListening(rRange);
46}
47
49{
50 if (!pArr || mrDoc.IsClipOrUndo())
51 return;
52
53 for ( auto t: pArr->References() )
54 {
55 switch (t->GetType())
56 {
58 {
59 ScAddress aCell = t->GetSingleRef()->toAbs(mrDoc, rRange.aStart);
60 ScAddress aCell2 = t->GetSingleRef()->toAbs(mrDoc, rRange.aEnd);
61 ScRange aRange(aCell, aCell2);
62 if (aRange.IsValid())
63 mrDoc.StartListeningArea(aRange, false, this);
64 }
65 break;
67 {
68 const ScSingleRefData& rRef1 = *t->GetSingleRef();
69 const ScSingleRefData& rRef2 = *t->GetSingleRef2();
70 ScAddress aCell1 = rRef1.toAbs(mrDoc, rRange.aStart);
71 ScAddress aCell2 = rRef2.toAbs(mrDoc, rRange.aStart);
72 ScAddress aCell3 = rRef1.toAbs(mrDoc, rRange.aEnd);
73 ScAddress aCell4 = rRef2.toAbs(mrDoc, rRange.aEnd);
74 ScRange aRange1(aCell1, aCell3);
75 ScRange aRange2(aCell2, aCell4);
76 aRange1.ExtendTo(aRange2);
77 if (aRange1.IsValid())
78 {
79 if (t->GetOpCode() == ocColRowNameAuto)
80 { // automagically
81 if ( rRef1.IsColRel() )
82 { // ColName
83 aRange1.aEnd.SetRow(mrDoc.MaxRow());
84 }
85 else
86 { // RowName
87 aRange1.aEnd.SetCol(mrDoc.MaxCol());
88 }
89 }
90 mrDoc.StartListeningArea(aRange1, false, this);
91 }
92 }
93 break;
94 default:
95 ; // nothing
96 }
97 }
98}
99
101{
102 if (mrDoc.IsClipOrUndo())
103 return;
104
105 size_t nLength = rRange.size();
106 for (size_t i = 0; i < nLength; ++i)
107 {
108 const ScRange& aRange = rRange[i];
109 mrDoc.StartListeningArea(aRange, false, this);
110 }
111}
112
113void ScFormulaListener::addTokenArray(const ScTokenArray* pArray, const ScRange& rRange)
114{
115 startListening(pArray, rRange);
116}
117
118void ScFormulaListener::setCallback(const std::function<void()>& aCallback)
119{
120 maCallbackFunction = aCallback;
121}
122
124{
125 if (mrDoc.IsClipOrUndo())
126 return;
127
129}
130
132{
134}
135
137{
138 mbDirty = true;
139
140 if (rHint.GetId() == SfxHintId::Dying)
141 return;
142
145}
146
148{
149 bool bRet = mbDirty;
150 mbDirty = false;
151 return bRet;
152}
153
155 mnVal(0),
156 mpFormat(nullptr),
158{
159}
160
162 mnVal(nVal),
163 mpFormat(nullptr),
164 maColor(rCol),
166{
167}
168
170 mnVal(rEntry.mnVal),
171 mpFormat(rEntry.mpFormat),
172 maColor(rEntry.maColor),
173 meType(rEntry.meType)
174{
175 setListener();
176 if(rEntry.mpCell)
177 {
178 mpCell.reset(new ScFormulaCell(*rEntry.mpCell, rEntry.mpCell->GetDocument(), rEntry.mpCell->aPos, ScCloneFlags::NoMakeAbsExternal));
179 mpCell->StartListeningTo(mpCell->GetDocument());
180 mpListener.reset(new ScFormulaListener(mpCell.get()));
181 }
182}
183
185 mnVal(rEntry.mnVal),
186 mpFormat(rEntry.mpFormat),
187 maColor(rEntry.maColor),
188 meType(rEntry.meType)
189{
190 setListener();
191 if(rEntry.mpCell)
192 {
193 mpCell.reset(new ScFormulaCell(*rEntry.mpCell, *pDoc, rEntry.mpCell->aPos, ScCloneFlags::NoMakeAbsExternal));
194 mpCell->StartListeningTo( *pDoc );
195 mpListener.reset(new ScFormulaListener(mpCell.get()));
196 if (mpFormat)
197 mpListener->setCallback([&]() { mpFormat->DoRepaint();});
198 }
199}
200
202{
203 if(mpCell)
204 mpCell->EndListeningTo(mpCell->GetDocument());
205}
206
207void ScColorScaleEntry::SetFormula( const OUString& rFormula, ScDocument& rDoc, const ScAddress& rAddr, formula::FormulaGrammar::Grammar eGrammar )
208{
209 mpCell.reset(new ScFormulaCell( rDoc, rAddr, rFormula, eGrammar ));
210 mpCell->StartListeningTo( rDoc );
211 mpListener.reset(new ScFormulaListener(mpCell.get()));
212 if (mpFormat)
213 mpListener->setCallback([&]() { mpFormat->DoRepaint();});
214}
215
217{
218 if(mpCell)
219 {
220 return mpCell->GetCode();
221 }
222
223 return nullptr;
224}
225
227{
228 if(mpCell)
229 {
230 return mpCell->GetFormula(eGrammar);
231 }
232
233 return OUString();
234}
235
237{
238 if(mpCell)
239 {
240 mpCell->Interpret();
241 if(mpCell->IsValue())
242 return mpCell->GetValue();
243
244 return std::numeric_limits<double>::max();
245 }
246
247 return mnVal;
248}
249
251{
252 mnVal = nValue;
253 mpCell.reset();
254 setListener();
255}
256
258{
259 if (!mpCell)
260 {
261 setListener();
262 return;
263 }
264
265 mpCell->UpdateReference(rCxt);
266 mpListener.reset(new ScFormulaListener(mpCell.get()));
268}
269
271{
272 if (!mpCell)
273 {
274 setListener();
275 return;
276 }
277
278 mpCell->UpdateInsertTab(rCxt);
279 mpListener.reset(new ScFormulaListener(mpCell.get()));
281}
282
284{
285 if (!mpCell)
286 {
287 setListener();
288 return;
289 }
290
291 mpCell->UpdateDeleteTab(rCxt);
292 mpListener.reset(new ScFormulaListener(mpCell.get()));
294}
295
297{
298 if (!mpCell)
299 {
300 setListener();
301 return;
302 }
303
304 SCTAB nTabNo = rCxt.getNewTab(mpCell->aPos.Tab());
305 mpCell->UpdateMoveTab(rCxt, nTabNo);
306 mpListener.reset(new ScFormulaListener(mpCell.get()));
308}
309
311{
312 maColor = rColor;
313}
314
316{
317 mpFormat = pFormat;
318 setListener();
319 if (mpFormat && mpListener)
320 mpListener->setCallback([&]() { mpFormat->DoRepaint();});
321}
322
324{
325 meType = eType;
327 {
328 mpCell.reset();
329 mpListener.reset();
330 }
331
332 setListener();
333}
334
336{
337 if (!mpFormat)
338 return;
339
343 {
345 mpListener->setCallback([&]() { mpFormat->DoRepaint();});
346 }
347}
348
349void ScColorScaleEntry::SetRepaintCallback(const std::function<void()>& func)
350{
351 mpListener->setCallback(func);
352}
353
355 : ScFormatEntry(pDoc)
356 , mpParent(nullptr)
357{
358}
359
361{
362}
363
365{
366 mpParent = pParent;
367}
368
370 ScColorFormat(pDoc)
371{
372}
373
375 ScColorFormat(pDoc)
376{
377 for(const auto& rxEntry : rFormat)
378 {
379 maColorScales.emplace_back(new ScColorScaleEntry(pDoc, *rxEntry));
380 }
381
382 auto aCache = rFormat.GetCache();
383 SetCache(aCache);
384}
385
387{
388 return new ScColorScaleFormat(pDoc, *this);
389}
390
392{
393}
394
396{
397 for (auto itr = begin(), itrEnd = end(); itr != itrEnd; ++itr)
398 {
399 (*itr)->SetRepaintCallback(pFormat);
400 }
402}
403
405{
407 maColorScales.back()->SetRepaintCallback(mpParent);
408}
409
410bool ScColorScaleFormat::IsEqual(const ScFormatEntry& rOther, bool /*bIgnoreSrcPos*/) const
411{
412 if (GetType() != rOther.GetType())
413 return false;
414
415 const ScColorScaleFormat& r = static_cast<const ScColorScaleFormat&>(rOther);
416
417 for (size_t i = 0; i < maColorScales.size(); ++i)
418 {
419 if (!maColorScales[i]->GetColor().IsRGBEqual(r.maColorScales[i]->GetColor().GetRGBColor())
420 || maColorScales[i]->GetType() != r.maColorScales[i]->GetType()
421 || maColorScales[i]->GetValue() != r.maColorScales[i]->GetValue())
422 return false;
423 }
424
425 return true;
426}
427
429{
430 ScColorScaleEntries::const_iterator itr = maColorScales.begin();
431
432 if((*itr)->GetType() == COLORSCALE_VALUE || (*itr)->GetType() == COLORSCALE_FORMULA)
433 return (*itr)->GetValue();
434 else
435 {
436 return getMinValue();
437 }
438}
439
441{
442 ScColorScaleEntries::const_reverse_iterator itr = maColorScales.rbegin();
443
444 if((*itr)->GetType() == COLORSCALE_VALUE || (*itr)->GetType() == COLORSCALE_FORMULA)
445 return (*itr)->GetValue();
446 else
447 {
448 return getMaxValue();
449 }
450}
451
452void ScColorScaleFormat::calcMinMax(double& rMin, double& rMax) const
453{
454 rMin = GetMinValue();
455 rMax = GetMaxValue();
456}
457
459{
460 return mpParent->GetRange();
461}
462
463std::vector<double> ScColorFormat::GetCache() const
464{
465 std::vector<double> empty;
466 return mpCache ? mpCache->maValues : empty;
467}
468
469void ScColorFormat::SetCache(const std::vector<double>& aValues)
470{
471 mpCache.reset(new ScColorFormatCache);
472 mpCache->maValues = aValues;
473}
474
475std::vector<double>& ScColorFormat::getValues() const
476{
477 if(!mpCache)
478 {
479 mpCache.reset(new ScColorFormatCache);
480 std::vector<double>& rValues = mpCache->maValues;
481
482 size_t n = GetRange().size();
483 const ScRangeList& aRanges = GetRange();
484 for(size_t i = 0; i < n; ++i)
485 {
486 const ScRange & rRange = aRanges[i];
487 SCTAB nTab = rRange.aStart.Tab();
488
489 SCCOL nColStart = rRange.aStart.Col();
490 SCROW nRowStart = rRange.aStart.Row();
491 SCCOL nColEnd = rRange.aEnd.Col();
492 SCROW nRowEnd = rRange.aEnd.Row();
493
494 if(nRowEnd == mpDoc->MaxRow())
495 {
496 bool bShrunk = false;
497 mpDoc->ShrinkToUsedDataArea(bShrunk, nTab, nColStart, nRowStart,
498 nColEnd, nRowEnd, false);
499 }
500 for(SCCOL nCol = nColStart; nCol <= nColEnd; ++nCol)
501 {
502 for(SCROW nRow = nRowStart; nRow <= nRowEnd; ++nRow)
503 {
504 ScAddress aAddr(nCol, nRow, nTab);
505 ScRefCellValue rCell(*mpDoc, aAddr);
506 if(rCell.hasNumeric())
507 {
508 double aVal = rCell.getValue();
509 rValues.push_back(aVal);
510 }
511 }
512 }
513 }
514
515 std::sort(rValues.begin(), rValues.end());
516 }
517
518 return mpCache->maValues;
519}
520
522{
523 std::vector<double>& rValues = getValues();
524 if(rValues.empty())
525 return 0;
526 return rValues[0];
527}
528
530{
531 std::vector<double>& rValues = getValues();
532 if(rValues.empty())
533 return 0;
534 return rValues[rValues.size()-1];
535}
536
538{
539 mpCache.reset();
540}
541
543{
544 mpCache.reset();
545}
546
548{
549 getMinValue();
550 getMaxValue();
551}
552
553namespace {
554
555sal_uInt8 GetColorValue( double nVal, double nVal1, sal_uInt8 nColVal1, double nVal2, sal_uInt8 nColVal2 )
556{
557 if (nVal <= nVal1)
558 return nColVal1;
559
560 if (nVal >= nVal2)
561 return nColVal2;
562
563 sal_uInt8 nColVal = static_cast<int>((nVal - nVal1)/(nVal2-nVal1)*(nColVal2-nColVal1))+nColVal1;
564 return nColVal;
565}
566
567Color CalcColor( double nVal, double nVal1, const Color& rCol1, double nVal2, const Color& rCol2)
568{
569 sal_uInt8 nColRed = GetColorValue(nVal, nVal1, rCol1.GetRed(), nVal2, rCol2.GetRed());
570 sal_uInt8 nColBlue = GetColorValue(nVal, nVal1, rCol1.GetBlue(), nVal2, rCol2.GetBlue());
571 sal_uInt8 nColGreen = GetColorValue(nVal, nVal1, rCol1.GetGreen(), nVal2, rCol2.GetGreen());
572
573 return Color(nColRed, nColGreen, nColBlue);
574}
575
580double GetPercentile( const std::vector<double>& rArray, double fPercentile )
581{
582 assert(!rArray.empty());
583 SAL_WARN_IF(fPercentile < 0, "sc", "negative percentile");
584 if (fPercentile < 0)
585 return rArray.front();
586 assert(fPercentile <= 1);
587 size_t nSize = rArray.size();
588 double fFloor = ::rtl::math::approxFloor(fPercentile * (nSize-1));
589 size_t nIndex = static_cast<size_t>(fFloor);
590 double fDiff = fPercentile * (nSize-1) - fFloor;
591 std::vector<double>::const_iterator iter = rArray.begin() + nIndex;
592 if (fDiff == 0.0)
593 return *iter;
594 else
595 {
596 double fVal = *iter;
597 iter = rArray.begin() + nIndex+1;
598 return fVal + fDiff * (*iter - fVal);
599 }
600}
601
602}
603
604double ScColorScaleFormat::CalcValue(double nMin, double nMax, const ScColorScaleEntries::const_iterator& itr) const
605{
606 switch((*itr)->GetType())
607 {
609 return nMin + (nMax-nMin)*((*itr)->GetValue()/100);
610 case COLORSCALE_MIN:
611 return nMin;
612 case COLORSCALE_MAX:
613 return nMax;
615 {
616 std::vector<double>& rValues = getValues();
617 if(rValues.size() == 1)
618 return rValues[0];
619 else
620 {
621 double fPercentile = (*itr)->GetValue()/100.0;
622 return GetPercentile(rValues, fPercentile);
623 }
624 }
625
626 default:
627 break;
628 }
629
630 return (*itr)->GetValue();
631}
632
633std::optional<Color> ScColorScaleFormat::GetColor( const ScAddress& rAddr ) const
634{
635 ScRefCellValue rCell(*mpDoc, rAddr);
636 if(!rCell.hasNumeric())
637 return std::optional<Color>();
638
639 // now we have for sure a value
640 double nVal = rCell.getValue();
641
642 if (maColorScales.size() < 2)
643 return std::optional<Color>();
644
645 double nMin = std::numeric_limits<double>::max();
646 double nMax = std::numeric_limits<double>::min();
647 calcMinMax(nMin, nMax);
648
649 // this check is for safety
650 if(nMin >= nMax)
651 return std::optional<Color>();
652
653 ScColorScaleEntries::const_iterator itr = begin();
654 double nValMin = CalcValue(nMin, nMax, itr);
655 Color rColMin = (*itr)->GetColor();
656 ++itr;
657 double nValMax = CalcValue(nMin, nMax, itr);
658 Color rColMax = (*itr)->GetColor();
659
660 ++itr;
661 while(itr != end() && nVal > nValMax)
662 {
663 rColMin = rColMax;
664 nValMin = nValMax;
665 rColMax = (*itr)->GetColor();
666 nValMax = CalcValue(nMin, nMax, itr);
667 ++itr;
668 }
669
670 Color aColor = CalcColor(nVal, nValMin, rColMin, nValMax, rColMax);
671
672 return aColor;
673}
674
676{
677 for(ScColorScaleEntries::iterator itr = begin(); itr != end(); ++itr)
678 (*itr)->UpdateReference(rCxt);
679}
680
682{
683 for (ScColorScaleEntries::iterator it = begin(); it != end(); ++it)
684 (*it)->UpdateInsertTab(rCxt);
685}
686
688{
689 for (ScColorScaleEntries::iterator it = begin(); it != end(); ++it)
690 (*it)->UpdateDeleteTab(rCxt);
691}
692
694{
695 for (ScColorScaleEntries::iterator it = begin(); it != end(); ++it)
696 (*it)->UpdateMoveTab(rCxt);
697}
698
700{
701 return Type::Colorscale;
702}
703
704ScColorScaleEntries::iterator ScColorScaleFormat::begin()
705{
706 return maColorScales.begin();
707}
708
709ScColorScaleEntries::const_iterator ScColorScaleFormat::begin() const
710{
711 return maColorScales.begin();
712}
713
714ScColorScaleEntries::iterator ScColorScaleFormat::end()
715{
716 return maColorScales.end();
717}
718
719ScColorScaleEntries::const_iterator ScColorScaleFormat::end() const
720{
721 return maColorScales.end();
722}
723
725{
726 if (maColorScales.size() <= nPos)
727 return nullptr;
728
729 return maColorScales[nPos].get();
730}
731
733{
734 if (maColorScales.size() <= nPos)
735 return nullptr;
736
737 return maColorScales[nPos].get();
738}
739
741{
742 return maColorScales.size();
743}
744
746{
747 if (maColorScales.size() < 2)
748 {
749 // TODO: create 2 valid entries
750 }
751}
752
754 ScColorFormat(pDoc),
755 mpFormatData(new ScDataBarFormatData())
756{
757}
758
760 ScColorFormat(pDoc),
761 mpFormatData(new ScDataBarFormatData(*rFormat.mpFormatData))
762{
763}
764
766{
767 mpFormatData.reset(pData);
768 if (mpParent)
769 {
770 mpFormatData->mpUpperLimit->SetRepaintCallback(mpParent);
771 mpFormatData->mpLowerLimit->SetRepaintCallback(mpParent);
772 }
773}
774
776{
777 return mpFormatData.get();
778}
779
781{
782 return mpFormatData.get();
783}
784
786{
787 return new ScDataBarFormat(pDoc, *this);
788}
789
791{
792 if (mpFormatData)
793 {
794 mpFormatData->mpUpperLimit->SetRepaintCallback(pFormat);
795 mpFormatData->mpLowerLimit->SetRepaintCallback(pFormat);
796 }
798}
799
801{
802 return Type::Databar;
803}
804
805bool ScDataBarFormat::IsEqual(const ScFormatEntry& rOther, bool /*bIgnoreSrcPos*/) const
806{
807 if (GetType() != rOther.GetType())
808 return false;
809
810 const ScDataBarFormat& r = static_cast<const ScDataBarFormat&>(rOther);
811
812 bool bEq = (mpFormatData->maAxisColor.IsRGBEqual(r.mpFormatData->maAxisColor)
813 && mpFormatData->maPositiveColor.IsRGBEqual(r.mpFormatData->maPositiveColor)
814 && mpFormatData->mxNegativeColor == r.mpFormatData->mxNegativeColor
815 && mpFormatData->meAxisPosition == r.mpFormatData->meAxisPosition
816 && mpFormatData->mbGradient == r.mpFormatData->mbGradient
817 && mpFormatData->mbOnlyBar == r.mpFormatData->mbOnlyBar);
818
819 if (mpFormatData->mpUpperLimit->GetType() == r.mpFormatData->mpUpperLimit->GetType()
820 && bEq)
821 {
822 bEq = (mpFormatData->mpUpperLimit->GetColor().IsRGBEqual(
823 r.mpFormatData->mpUpperLimit->GetColor())
824 && mpFormatData->mpUpperLimit->GetValue()
825 == r.mpFormatData->mpUpperLimit->GetValue());
826 }
827
828 if (mpFormatData->mpLowerLimit->GetType() == r.mpFormatData->mpLowerLimit->GetType()
829 && bEq)
830 {
831 bEq = (mpFormatData->mpLowerLimit->GetColor().IsRGBEqual(
832 r.mpFormatData->mpLowerLimit->GetColor())
833 && mpFormatData->mpLowerLimit->GetValue()
834 == r.mpFormatData->mpLowerLimit->GetValue());
835 }
836
837 return bEq;
838}
839
841{
842 mpFormatData->mpUpperLimit->UpdateReference(rCxt);
843 mpFormatData->mpLowerLimit->UpdateReference(rCxt);
844}
845
847{
848 mpFormatData->mpUpperLimit->UpdateInsertTab(rCxt);
849 mpFormatData->mpLowerLimit->UpdateInsertTab(rCxt);
850}
851
853{
854 mpFormatData->mpUpperLimit->UpdateDeleteTab(rCxt);
855 mpFormatData->mpLowerLimit->UpdateDeleteTab(rCxt);
856}
857
859{
860 mpFormatData->mpUpperLimit->UpdateMoveTab(rCxt);
861 mpFormatData->mpLowerLimit->UpdateMoveTab(rCxt);
862}
863
864double ScDataBarFormat::getMin(double nMin, double nMax) const
865{
866 switch(mpFormatData->mpLowerLimit->GetType())
867 {
868 case COLORSCALE_MIN:
869 return nMin;
870
871 case COLORSCALE_AUTO:
872 return std::min<double>(0, nMin);
873
875 return nMin + (nMax-nMin)/100*mpFormatData->mpLowerLimit->GetValue();
876
878 {
879 double fPercentile = mpFormatData->mpLowerLimit->GetValue()/100.0;
880 std::vector<double>& rValues = getValues();
881 return GetPercentile(rValues, fPercentile);
882 }
883
884 default:
885 break;
886 }
887
888 return mpFormatData->mpLowerLimit->GetValue();
889}
890
891double ScDataBarFormat::getMax(double nMin, double nMax) const
892{
893 switch(mpFormatData->mpUpperLimit->GetType())
894 {
895 case COLORSCALE_MAX:
896 return nMax;
897 case COLORSCALE_AUTO:
898 return std::max<double>(0, nMax);
900 return nMin + (nMax-nMin)/100*mpFormatData->mpUpperLimit->GetValue();
902 {
903 double fPercentile = mpFormatData->mpUpperLimit->GetValue()/100.0;
904 std::vector<double>& rValues = getValues();
905 return GetPercentile(rValues, fPercentile);
906 }
907
908 default:
909 break;
910 }
911
912 return mpFormatData->mpUpperLimit->GetValue();
913}
914
915std::unique_ptr<ScDataBarInfo> ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const
916{
917 ScRefCellValue rCell(*mpDoc, rAddr);
918 if(!rCell.hasNumeric())
919 return nullptr;
920
921 // now we have for sure a value
922
923 double nValMin = getMinValue();
924 double nValMax = getMaxValue();
925 double nMin = getMin(nValMin, nValMax);
926 double nMax = getMax(nValMin, nValMax);
927 double nMinLength = mpFormatData->mnMinLength;
928 double nMaxLength = mpFormatData->mnMaxLength;
929
930 double nValue = rCell.getValue();
931
932 std::unique_ptr<ScDataBarInfo> pInfo(new ScDataBarInfo);
933 if(mpFormatData->meAxisPosition == databar::NONE)
934 {
935 if(nValue <= nMin)
936 {
937 pInfo->mnLength = nMinLength;
938 }
939 else if(nValue >= nMax)
940 {
941 pInfo->mnLength = nMaxLength;
942 }
943 else
944 {
945 double nDiff = nMax - nMin;
946 pInfo->mnLength = nMinLength + (nValue - nMin)/nDiff * (nMaxLength-nMinLength);
947 }
948 pInfo->mnZero = 0;
949 }
950 else if (mpFormatData->meAxisPosition == databar::AUTOMATIC)
951 {
952 // if auto is used we may need to adjust it
953 // for the length calculation
954 if (mpFormatData->mpLowerLimit->GetType() == COLORSCALE_AUTO && nMin > 0)
955 nMin = 0;
956 if (mpFormatData->mpUpperLimit->GetType() == COLORSCALE_MAX && nMax < 0)
957 nMax = 0;
958
959 //calculate the zero position first
960 if(nMin < 0)
961 {
962 if(nMax < 0)
963 pInfo->mnZero = 100;
964 else
965 {
966 pInfo->mnZero = -100*nMin/(nMax-nMin);
967 }
968 }
969 else
970 pInfo->mnZero = 0;
971
972 double nMinNonNegative = std::max(0.0, nMin);
973 double nMaxNonPositive = std::min(0.0, nMax);
974 //calculate the length
975 if(nValue < 0 && nMin < 0)
976 {
977 if (nValue < nMin)
978 pInfo->mnLength = -100;
979 else
980 pInfo->mnLength = -100 * (nValue-nMaxNonPositive)/(nMin-nMaxNonPositive);
981 }
982 else
983 {
984 if ( nValue > nMax )
985 pInfo->mnLength = 100;
986 else if (nValue <= nMin)
987 pInfo->mnLength = 0;
988 else
989 pInfo->mnLength = 100 * (nValue-nMinNonNegative)/(nMax-nMinNonNegative);
990 }
991 }
992 else if( mpFormatData->meAxisPosition == databar::MIDDLE)
993 {
994 pInfo->mnZero = 50;
995 double nAbsMax = std::max(std::abs(nMin), std::abs(nMax));
996 if (nValue < 0 && nMin < 0)
997 {
998 if (nValue < nMin)
999 pInfo->mnLength = nMaxLength * (nMin/nAbsMax);
1000 else
1001 pInfo->mnLength = nMaxLength * (nValue/nAbsMax);
1002 }
1003 else
1004 {
1005 if (nValue > nMax)
1006 pInfo->mnLength = nMaxLength * (nMax/nAbsMax);
1007 else
1008 pInfo->mnLength = nMaxLength * (std::max(nValue, nMin)/nAbsMax);
1009 }
1010 }
1011 else
1012 assert(false);
1013
1014 // set color
1015 if(mpFormatData->mbNeg && nValue < 0)
1016 {
1017 if(mpFormatData->mxNegativeColor)
1018 {
1019 pInfo->maColor = *mpFormatData->mxNegativeColor;
1020 }
1021 else
1022 {
1023 // default negative color is red
1024 pInfo->maColor = COL_LIGHTRED;
1025 }
1026
1027 }
1028 else
1029 pInfo->maColor = mpFormatData->maPositiveColor;
1030
1031 pInfo->mbGradient = mpFormatData->mbGradient;
1032 pInfo->mbShowValue = !mpFormatData->mbOnlyBar;
1033 pInfo->maAxisColor = mpFormatData->maAxisColor;
1034
1035 return pInfo;
1036}
1037
1039{
1040 if (!mpFormatData->mpLowerLimit)
1041 {
1042 // TODO: implement
1043 }
1044 if (!mpFormatData->mpUpperLimit)
1045 {
1046 // TODO: implement
1047 }
1048}
1049
1051 : eIconSetType(rOther.eIconSetType)
1052 , mbShowValue(rOther.mbShowValue)
1053 , mbReverse(rOther.mbReverse)
1054 , mbCustom(rOther.mbCustom)
1055 , maCustomVector(rOther.maCustomVector)
1056{
1057 m_Entries.reserve(rOther.m_Entries.size());
1058 for (auto const& it : rOther.m_Entries)
1059 {
1060 m_Entries.emplace_back(new ScColorScaleEntry(*it));
1061 }
1062}
1063
1065 ScColorFormat(pDoc),
1066 mpFormatData(new ScIconSetFormatData)
1067{
1068}
1069
1071 ScColorFormat(pDoc),
1072 mpFormatData(new ScIconSetFormatData(*rFormat.mpFormatData))
1073{
1074}
1075
1077{
1078 return new ScIconSetFormat(pDoc, *this);
1079}
1080
1082{
1083 for(iterator itr = begin(); itr != end(); ++itr)
1084 {
1085 (*itr)->SetRepaintCallback(pFormat);
1086 }
1087 ScColorFormat::SetParent(pFormat);
1088}
1089
1091{
1092 mpFormatData.reset( pFormatData );
1094}
1095
1097{
1098 return mpFormatData.get();
1099}
1100
1102{
1103 return mpFormatData.get();
1104}
1105
1106std::unique_ptr<ScIconSetInfo> ScIconSetFormat::GetIconSetInfo(const ScAddress& rAddr) const
1107{
1108 ScRefCellValue rCell(*mpDoc, rAddr);
1109 if(!rCell.hasNumeric())
1110 return nullptr;
1111
1112 // now we have for sure a value
1113 double nVal = rCell.getValue();
1114
1115 if (mpFormatData->m_Entries.size() < 2)
1116 return nullptr;
1117
1118 double nMin = GetMinValue();
1119 double nMax = GetMaxValue();
1120
1121 sal_Int32 nIndex = 0;
1122 const_iterator itr = begin();
1123 ++itr;
1124 double nValMax = CalcValue(nMin, nMax, itr);
1125
1126 ++itr;
1127 while(itr != end() && nVal >= nValMax)
1128 {
1129 ++nIndex;
1130 nValMax = CalcValue(nMin, nMax, itr);
1131 ++itr;
1132 }
1133
1134 if(nVal >= nValMax)
1135 ++nIndex;
1136
1137 std::unique_ptr<ScIconSetInfo> pInfo(new ScIconSetInfo);
1138
1139 const SfxPoolItem& rPoolItem = mpDoc->GetPattern(rAddr)->GetItem(ATTR_FONT_HEIGHT);
1140 tools::Long aFontHeight = static_cast<const SvxFontHeightItem&>(rPoolItem).GetHeight();
1141 pInfo->mnHeight = aFontHeight;
1142
1143 if(mpFormatData->mbReverse)
1144 {
1145 sal_Int32 nMaxIndex = mpFormatData->m_Entries.size() - 1;
1146 nIndex = nMaxIndex - nIndex;
1147 }
1148
1149 if (mpFormatData->mbCustom && sal_Int32(mpFormatData->maCustomVector.size()) > nIndex)
1150 {
1151 ScIconSetType eCustomType = mpFormatData->maCustomVector[nIndex].first;
1152 sal_Int32 nCustomIndex = mpFormatData->maCustomVector[nIndex].second;
1153 if (nCustomIndex == -1)
1154 {
1155 return nullptr;
1156 }
1157
1158 pInfo->eIconSetType = eCustomType;
1159 pInfo->nIconIndex = nCustomIndex;
1160 }
1161 else
1162 {
1163 pInfo->nIconIndex = nIndex;
1164 pInfo->eIconSetType = mpFormatData->eIconSetType;
1165 }
1166
1167 pInfo->mbShowValue = mpFormatData->mbShowValue;
1168 return pInfo;
1169}
1170
1172{
1173 return Type::Iconset;
1174}
1175
1177{
1178 for(iterator itr = begin(); itr != end(); ++itr)
1179 {
1180 (*itr)->UpdateReference(rCxt);
1181 }
1182}
1183
1185{
1186 for(iterator itr = begin(); itr != end(); ++itr)
1187 {
1188 (*itr)->UpdateInsertTab(rCxt);
1189 }
1190}
1191
1193{
1194 for(iterator itr = begin(); itr != end(); ++itr)
1195 {
1196 (*itr)->UpdateDeleteTab(rCxt);
1197 }
1198}
1199
1201{
1202 for(iterator itr = begin(); itr != end(); ++itr)
1203 {
1204 (*itr)->UpdateMoveTab(rCxt);
1205 }
1206}
1207
1209{
1210 return mpFormatData->m_Entries.begin();
1211}
1212
1214{
1215 return mpFormatData->m_Entries.begin();
1216}
1217
1219{
1220 return mpFormatData->m_Entries.end();
1221}
1222
1224{
1225 return mpFormatData->m_Entries.end();
1226}
1227
1229{
1230 const_iterator itr = begin();
1231
1232 if ((*itr)->GetType() == COLORSCALE_VALUE || (*itr)->GetType() == COLORSCALE_FORMULA)
1233 return (*itr)->GetValue();
1234 else
1235 {
1236 return getMinValue();
1237 }
1238}
1239
1241{
1242 auto const itr = mpFormatData->m_Entries.rbegin();
1243
1244 if ((*itr)->GetType() == COLORSCALE_VALUE || (*itr)->GetType() == COLORSCALE_FORMULA)
1245 return (*itr)->GetValue();
1246 else
1247 {
1248 return getMaxValue();
1249 }
1250}
1251
1252double ScIconSetFormat::CalcValue(double nMin, double nMax, const ScIconSetFormat::const_iterator& itr) const
1253{
1254 switch ((*itr)->GetType())
1255 {
1256 case COLORSCALE_PERCENT:
1257 return nMin + (nMax-nMin)*((*itr)->GetValue()/100);
1258 case COLORSCALE_MIN:
1259 return nMin;
1260 case COLORSCALE_MAX:
1261 return nMax;
1263 {
1264 std::vector<double>& rValues = getValues();
1265 if(rValues.size() == 1)
1266 return rValues[0];
1267 else
1268 {
1269 double fPercentile = (*itr)->GetValue()/100.0;
1270 return GetPercentile(rValues, fPercentile);
1271 }
1272 }
1273
1274 default:
1275 break;
1276 }
1277
1278 return (*itr)->GetValue();
1279}
1280
1282 { "3Arrows", IconSet_3Arrows, 3 },
1283 { "3ArrowsGray", IconSet_3ArrowsGray, 3 },
1284 { "3Flags", IconSet_3Flags, 3 },
1285 { "3TrafficLights1", IconSet_3TrafficLights1, 3 },
1286 { "3TrafficLights2", IconSet_3TrafficLights2, 3 },
1287 { "3Signs", IconSet_3Signs, 3 },
1288 { "3Symbols", IconSet_3Symbols, 3 },
1289 { "3Symbols2", IconSet_3Symbols2, 3 },
1290 { "3Smilies", IconSet_3Smilies, 3 },
1291 { "3ColorSmilies", IconSet_3ColorSmilies, 3 },
1292 { "3Stars", IconSet_3Stars, 3 },
1293 { "3Triangles", IconSet_3Triangles, 3 },
1294 { "4Arrows", IconSet_4Arrows, 4 },
1295 { "4ArrowsGray", IconSet_4ArrowsGray, 4 },
1296 { "4RedToBlack", IconSet_4RedToBlack, 4 },
1297 { "4Rating", IconSet_4Rating, 4 },
1298 { "4TrafficLights", IconSet_4TrafficLights, 4 },
1299 { "5Arrows", IconSet_5Arrows, 5 },
1300 { "5ArrowsGray", IconSet_5ArrowsGray, 5 },
1301 { "5Rating", IconSet_5Ratings, 5 },
1302 { "5Quarters", IconSet_5Quarters, 5 },
1303 { "5Boxes", IconSet_5Boxes, 5 },
1304 { nullptr, IconSet_3Arrows, 0 }
1305};
1306
1308{
1309 return mpFormatData->m_Entries.size();
1310}
1311
1312
1313namespace {
1314
1315constexpr rtl::OUStringConstExpr a3TrafficLights1[] = {
1316 BMP_ICON_SET_CIRCLES1_RED, BMP_ICON_SET_CIRCLES1_YELLOW, BMP_ICON_SET_CIRCLES1_GREEN
1317};
1318
1319constexpr rtl::OUStringConstExpr a3TrafficLights2[] = {
1320 BMP_ICON_SET_TRAFFICLIGHTS_RED, BMP_ICON_SET_TRAFFICLIGHTS_YELLOW, BMP_ICON_SET_TRAFFICLIGHTS_GREEN
1321};
1322
1323constexpr rtl::OUStringConstExpr a3Arrows[] = {
1324 BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SAME, BMP_ICON_SET_COLORARROWS_UP
1325};
1326
1327constexpr rtl::OUStringConstExpr a3ArrowsGray[] = {
1328 BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SAME, BMP_ICON_SET_GRAYARROWS_UP
1329};
1330
1331constexpr rtl::OUStringConstExpr a3Flags[] = {
1332 BMP_ICON_SET_FLAGS_RED, BMP_ICON_SET_FLAGS_YELLOW, BMP_ICON_SET_FLAGS_GREEN
1333};
1334
1335constexpr rtl::OUStringConstExpr a3Smilies[] = {
1336 BMP_ICON_SET_POSITIVE_YELLOW_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_NEGATIVE_YELLOW_SMILIE
1337};
1338
1339constexpr rtl::OUStringConstExpr a3ColorSmilies[] = {
1340 BMP_ICON_SET_POSITIVE_GREEN_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_NEGATIVE_RED_SMILIE
1341};
1342
1343constexpr rtl::OUStringConstExpr a3Stars[] = {
1344 BMP_ICON_SET_STARS_EMPTY, BMP_ICON_SET_STARS_HALF, BMP_ICON_SET_STARS_FULL
1345};
1346
1347constexpr rtl::OUStringConstExpr a3Triangles[] = {
1348 BMP_ICON_SET_TRIANGLES_DOWN, BMP_ICON_SET_TRIANGLES_SAME, BMP_ICON_SET_TRIANGLES_UP
1349};
1350
1351constexpr rtl::OUStringConstExpr a4Arrows[] = {
1352 BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP, BMP_ICON_SET_COLORARROWS_UP
1353};
1354
1355constexpr rtl::OUStringConstExpr a4ArrowsGray[] = {
1356 BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP, BMP_ICON_SET_GRAYARROWS_UP
1357};
1358
1359constexpr rtl::OUStringConstExpr a5Arrows[] = {
1360 BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN,
1361 BMP_ICON_SET_COLORARROWS_SAME, BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP, BMP_ICON_SET_COLORARROWS_UP
1362};
1363
1364constexpr rtl::OUStringConstExpr a5ArrowsGray[] = {
1365 BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN,
1366 BMP_ICON_SET_GRAYARROWS_SAME, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP, BMP_ICON_SET_GRAYARROWS_UP
1367};
1368
1369constexpr rtl::OUStringConstExpr a4TrafficLights[] = {
1370 BMP_ICON_SET_CIRCLES1_GRAY, BMP_ICON_SET_CIRCLES1_RED,
1371 BMP_ICON_SET_CIRCLES1_YELLOW, BMP_ICON_SET_CIRCLES1_GREEN
1372};
1373
1374constexpr rtl::OUStringConstExpr a5Quarters[] = {
1375 BMP_ICON_SET_PIES_EMPTY, BMP_ICON_SET_PIES_ONE_QUARTER, BMP_ICON_SET_PIES_HALF,
1376 BMP_ICON_SET_PIES_THREE_QUARTER, BMP_ICON_SET_PIES_FULL,
1377};
1378
1379constexpr rtl::OUStringConstExpr a5Boxes[] = {
1380 BMP_ICON_SET_SQUARES_EMPTY, BMP_ICON_SET_SQUARES_ONE_QUARTER,
1381 BMP_ICON_SET_SQUARES_HALF, BMP_ICON_SET_SQUARES_THREE_QUARTER,
1382 BMP_ICON_SET_SQUARES_FULL
1383};
1384
1385constexpr rtl::OUStringConstExpr a3Symbols1[] = {
1386 BMP_ICON_SET_SYMBOLS1_CROSS, BMP_ICON_SET_SYMBOLS1_EXCLAMATION_MARK, BMP_ICON_SET_SYMBOLS1_CHECK
1387};
1388
1389constexpr rtl::OUStringConstExpr a3Signs[] = {
1390 BMP_ICON_SET_SHAPES_DIAMOND, BMP_ICON_SET_SHAPES_TRIANGLE, BMP_ICON_SET_SHAPES_CIRCLE
1391};
1392
1393constexpr rtl::OUStringConstExpr a4RedToBlack[] = {
1394 BMP_ICON_SET_CIRCLES2_DARK_GRAY, BMP_ICON_SET_CIRCLES2_LIGHT_GRAY,
1395 BMP_ICON_SET_CIRCLES2_LIGHT_RED, BMP_ICON_SET_CIRCLES2_DARK_RED
1396};
1397
1398constexpr rtl::OUStringConstExpr a4Ratings[] = {
1399 BMP_ICON_SET_BARS_ONE_QUARTER, BMP_ICON_SET_BARS_HALF,
1400 BMP_ICON_SET_BARS_THREE_QUARTER, BMP_ICON_SET_BARS_FULL
1401};
1402
1403constexpr rtl::OUStringConstExpr a5Ratings[] = {
1404 BMP_ICON_SET_BARS_EMPTY, BMP_ICON_SET_BARS_ONE_QUARTER, BMP_ICON_SET_BARS_HALF,
1405 BMP_ICON_SET_BARS_THREE_QUARTER, BMP_ICON_SET_BARS_FULL
1406};
1407
1408struct ScIconSetBitmapMap {
1410 const rtl::OUStringConstExpr* pBitmaps;
1411};
1412
1413const ScIconSetBitmapMap aBitmapMap[] = {
1414 { IconSet_3Arrows, a3Arrows },
1415 { IconSet_3ArrowsGray, a3ArrowsGray },
1416 { IconSet_3Flags, a3Flags },
1417 { IconSet_3Signs, a3Signs },
1418 { IconSet_3Symbols, a3Symbols1 },
1419 { IconSet_3Symbols2, a3Symbols1 },
1420 { IconSet_3TrafficLights1, a3TrafficLights1 },
1421 { IconSet_3TrafficLights2, a3TrafficLights2 },
1422 { IconSet_3Smilies, a3Smilies },
1423 { IconSet_3ColorSmilies, a3ColorSmilies },
1424 { IconSet_3Triangles, a3Triangles },
1425 { IconSet_3Stars, a3Stars },
1426 { IconSet_4Arrows, a4Arrows },
1427 { IconSet_4ArrowsGray, a4ArrowsGray },
1428 { IconSet_4Rating, a4Ratings },
1429 { IconSet_4RedToBlack, a4RedToBlack },
1430 { IconSet_4TrafficLights, a4TrafficLights },
1431 { IconSet_5Arrows, a5Arrows },
1432 { IconSet_5ArrowsGray, a5ArrowsGray },
1433 { IconSet_5Quarters, a5Quarters },
1434 { IconSet_5Ratings, a5Ratings },
1435 { IconSet_5Boxes, a5Boxes }
1436};
1437
1438const ScIconSetMap* findIconSetType(ScIconSetType eType)
1439{
1441 for (; pMap->pName; ++pMap)
1442 {
1443 if (pMap->eType == eType)
1444 return pMap;
1445 }
1446
1447 return nullptr;
1448}
1449
1450}
1451
1453{
1454 const ScIconSetMap* pMap = findIconSetType(eType);
1455 if (pMap)
1456 return pMap->pName;
1457
1458 return "";
1459}
1460
1462{
1463 const ScIconSetMap* pMap = findIconSetType(eType);
1464 if (pMap)
1465 return pMap->nElements;
1466
1467 return 0;
1468}
1469
1470OUString ScIconSetFormat::getIconName(ScIconSetType const eType, sal_Int32 const nIndex)
1471{
1472 OUString sBitmap;
1473
1474 for(const ScIconSetBitmapMap & i : aBitmapMap)
1475 {
1476 if(i.eType == eType)
1477 {
1478 sBitmap = *(i.pBitmaps + nIndex);
1479 break;
1480 }
1481 }
1482
1483 assert(!sBitmap.isEmpty());
1484
1485 return sBitmap;
1486}
1487
1489 ScIconSetType const eType, sal_Int32 const nIndex)
1490{
1491 OUString sBitmap(ScIconSetFormat::getIconName(eType, nIndex));
1492
1493 std::map<OUString, BitmapEx>::iterator itr = rIconSetBitmapMap.find(sBitmap);
1494 if (itr != rIconSetBitmapMap.end())
1495 return itr->second;
1496
1497 BitmapEx aBitmap(sBitmap);
1498 std::pair<OUString, BitmapEx> aPair(sBitmap, aBitmap);
1499 std::pair<std::map<OUString, BitmapEx>::iterator, bool> itrNew = rIconSetBitmapMap.insert(aPair);
1500 assert(itrNew.second);
1501
1502 return itrNew.first->second;
1503}
1504
1506{
1507 ScIconSetType eType = mpFormatData->eIconSetType;
1508 for (const ScIconSetMap & i : g_IconSetMap)
1509 {
1510 if (i.eType == eType)
1511 {
1512 // size_t nElements = aIconSetMap[i].nElements;
1513 // TODO: implement
1514 break;
1515 }
1516 }
1517}
1518
1519/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
basegfx::BColor maColor
XPropertyListType t
sal_uInt8 GetBlue() const
sal_uInt8 GetRed() const
sal_uInt8 GetGreen() const
SCTAB Tab() const
Definition: address.hxx:283
void SetCol(SCCOL nColP)
Definition: address.hxx:291
SCROW Row() const
Definition: address.hxx:274
void SetRow(SCROW nRowP)
Definition: address.hxx:287
SCCOL Col() const
Definition: address.hxx:279
const ScRangeList & GetRange() const
Definition: colorscale.cxx:458
double getMinValue() const
Definition: colorscale.cxx:521
virtual void endRendering() override
Definition: colorscale.cxx:542
virtual void SetParent(ScConditionalFormat *pParent) override
Definition: colorscale.cxx:364
void SetCache(const std::vector< double > &aValues)
Definition: colorscale.cxx:469
ScColorFormat(ScDocument *pDoc)
Definition: colorscale.cxx:354
double getMaxValue() const
Definition: colorscale.cxx:529
virtual void updateValues() override
Definition: colorscale.cxx:547
virtual ~ScColorFormat() override
Definition: colorscale.cxx:360
ScConditionalFormat * mpParent
Definition: colorscale.hxx:242
virtual void startRendering() override
Definition: colorscale.cxx:537
std::vector< double > & getValues() const
Definition: colorscale.cxx:475
std::vector< double > GetCache() const
Definition: colorscale.cxx:463
std::unique_ptr< ScColorFormatCache > mpCache
Definition: colorscale.hxx:250
void UpdateInsertTab(const sc::RefUpdateInsertTabContext &rCxt)
Definition: colorscale.cxx:270
double GetValue() const
Definition: colorscale.cxx:236
const ScTokenArray * GetFormula() const
Definition: colorscale.cxx:216
void SetType(ScColorScaleEntryType eType)
Definition: colorscale.cxx:323
std::unique_ptr< ScFormulaListener > mpListener
Definition: colorscale.hxx:47
void SetRepaintCallback(ScConditionalFormat *pParent)
Definition: colorscale.cxx:315
ScColorScaleEntryType meType
Definition: colorscale.hxx:50
void SetFormula(const OUString &rFormula, ScDocument &rDoc, const ScAddress &rAddr, formula::FormulaGrammar::Grammar eGrammar=formula::FormulaGrammar::GRAM_DEFAULT)
Definition: colorscale.cxx:207
void UpdateMoveTab(const sc::RefUpdateMoveTabContext &rCxt)
Definition: colorscale.cxx:296
void UpdateReference(const sc::RefUpdateContext &rCxt)
Definition: colorscale.cxx:257
void SetValue(double nValue)
Definition: colorscale.cxx:250
void UpdateDeleteTab(const sc::RefUpdateDeleteTabContext &rCxt)
Definition: colorscale.cxx:283
void SetColor(const Color &)
Definition: colorscale.cxx:310
std::unique_ptr< ScFormulaCell > mpCell
Definition: colorscale.hxx:46
ScConditionalFormat * mpFormat
Definition: colorscale.hxx:48
~ScColorScaleEntry() COVERITY_NOEXCEPT_FALSE
Definition: colorscale.cxx:201
virtual Type GetType() const override
Definition: colorscale.cxx:699
void AddEntry(ScColorScaleEntry *pEntry)
Definition: colorscale.cxx:404
double GetMinValue() const
Definition: colorscale.cxx:428
double GetMaxValue() const
Definition: colorscale.cxx:440
virtual void UpdateDeleteTab(sc::RefUpdateDeleteTabContext &rCxt) override
Definition: colorscale.cxx:687
virtual ~ScColorScaleFormat() override
Definition: colorscale.cxx:391
virtual void UpdateInsertTab(sc::RefUpdateInsertTabContext &rCxt) override
Definition: colorscale.cxx:681
ScColorScaleEntries::iterator begin()
Definition: colorscale.cxx:704
double CalcValue(double nMin, double nMax, const ScColorScaleEntries::const_iterator &rItr) const
Definition: colorscale.cxx:604
ScColorScaleEntry * GetEntry(size_t nPos)
Definition: colorscale.cxx:724
virtual ScColorFormat * Clone(ScDocument *pDoc) const override
Definition: colorscale.cxx:386
void calcMinMax(double &nMin, double &nMax) const
Definition: colorscale.cxx:452
ScColorScaleEntries::iterator end()
Definition: colorscale.cxx:714
ScColorScaleEntries maColorScales
Definition: colorscale.hxx:258
size_t size() const
Definition: colorscale.cxx:740
virtual void UpdateReference(sc::RefUpdateContext &rCxt) override
Definition: colorscale.cxx:675
bool IsEqual(const ScFormatEntry &r, bool bIgnoreSrcPos) const override
Definition: colorscale.cxx:410
std::optional< Color > GetColor(const ScAddress &rAddr) const
Definition: colorscale.cxx:633
virtual void UpdateMoveTab(sc::RefUpdateMoveTabContext &rCxt) override
Definition: colorscale.cxx:693
virtual void SetParent(ScConditionalFormat *pParent) override
Definition: colorscale.cxx:395
ScColorScaleFormat(ScDocument *pDoc)
Definition: colorscale.cxx:369
void EnsureSize()
Makes sure that the maColorScales contain at least 2 entries.
Definition: colorscale.cxx:745
const ScRangeList & GetRange() const
Definition: conditio.hxx:559
ScDocument * GetDocument()
Definition: conditio.cxx:1791
std::unique_ptr< ScDataBarInfo > GetDataBarInfo(const ScAddress &rAddr) const
Definition: colorscale.cxx:915
virtual void UpdateReference(sc::RefUpdateContext &rCxt) override
Definition: colorscale.cxx:840
void EnsureSize()
Makes sure that the mpFormatData does not contain valid entries.
bool IsEqual(const ScFormatEntry &r, bool bIgnoreSrcPos) const override
Definition: colorscale.cxx:805
virtual void UpdateInsertTab(sc::RefUpdateInsertTabContext &rCxt) override
Definition: colorscale.cxx:846
virtual Type GetType() const override
Definition: colorscale.cxx:800
virtual void UpdateMoveTab(sc::RefUpdateMoveTabContext &rCxt) override
Definition: colorscale.cxx:858
void SetDataBarData(ScDataBarFormatData *pData)
Definition: colorscale.cxx:765
virtual void SetParent(ScConditionalFormat *pParent) override
Definition: colorscale.cxx:790
double getMin(double nMin, double nMax) const
Definition: colorscale.cxx:864
virtual ScColorFormat * Clone(ScDocument *pDoc) const override
Definition: colorscale.cxx:785
virtual void UpdateDeleteTab(sc::RefUpdateDeleteTabContext &rCxt) override
Definition: colorscale.cxx:852
std::unique_ptr< ScDataBarFormatData > mpFormatData
Definition: colorscale.hxx:335
ScDataBarFormat(ScDocument *pDoc)
Definition: colorscale.cxx:753
double getMax(double nMin, double nMax) const
Definition: colorscale.cxx:891
const ScDataBarFormatData * GetDataBarData() const
Definition: colorscale.cxx:780
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:892
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:893
bool ShrinkToUsedDataArea(bool &o_bShrunk, SCTAB nTab, SCCOL &rStartCol, SCROW &rStartRow, SCCOL &rEndCol, SCROW &rEndRow, bool bColumnsOnly, bool bStickyTopRow=false, bool bStickyLeftCol=false, ScDataAreaExtras *pDataAreaExtras=nullptr) const
Shrink a range to only include used data area.
Definition: document.cxx:1072
void StartListeningArea(const ScRange &rRange, bool bGroupListening, SvtListener *pListener)
Definition: documen7.cxx:35
bool IsClipOrUndo() const
Definition: document.hxx:1591
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4813
virtual Type GetType() const =0
ScDocument * mpDoc
Definition: conditio.hxx:256
ScTokenArray * GetCode()
ScAddress aPos
ScDocument & mrDoc
Definition: conditio.hxx:185
void Notify(const SfxHint &rHint) override
Definition: colorscale.cxx:136
std::function< void()> maCallbackFunction
Definition: conditio.hxx:186
bool NeedsRepaint() const
Definition: colorscale.cxx:147
void addTokenArray(const ScTokenArray *pTokens, const ScRange &rRange)
Definition: colorscale.cxx:113
virtual ~ScFormulaListener() override
Definition: colorscale.cxx:131
void startListening(const ScTokenArray *pTokens, const ScRange &rPos)
Definition: colorscale.cxx:48
void setCallback(const std::function< void()> &aCallbackFunction)
Definition: colorscale.cxx:118
ScFormulaListener(ScFormulaCell *pCell)
Definition: colorscale.cxx:28
void EnsureSize()
Makes sure that the mpFormatData does not contain valid entries.
std::unique_ptr< ScIconSetFormatData > mpFormatData
Definition: colorscale.hxx:415
size_t size() const
virtual Type GetType() const override
virtual void UpdateInsertTab(sc::RefUpdateInsertTabContext &rCxt) override
ScIconSetFormatData::Entries_t::iterator iterator
Definition: colorscale.hxx:393
double GetMinValue() const
static const ScIconSetMap g_IconSetMap[]
Definition: colorscale.hxx:387
static sal_Int32 getIconSetElements(ScIconSetType eType)
iterator begin()
double GetMaxValue() const
ScIconSetFormatData::Entries_t::const_iterator const_iterator
Definition: colorscale.hxx:394
virtual ScColorFormat * Clone(ScDocument *pDoc) const override
static OUString getIconName(ScIconSetType eType, sal_Int32 nIndex)
std::unique_ptr< ScIconSetInfo > GetIconSetInfo(const ScAddress &rAddr) const
void SetIconSetData(ScIconSetFormatData *pData)
virtual void UpdateReference(sc::RefUpdateContext &rCxt) override
iterator end()
ScIconSetFormat(ScDocument *pDoc)
static const char * getIconSetName(ScIconSetType eType)
virtual void SetParent(ScConditionalFormat *pParent) override
const ScIconSetFormatData * GetIconSetData() const
static BitmapEx & getBitmap(sc::IconSetBitmapMap &rBitmapMap, ScIconSetType eType, sal_Int32 nIndex)
virtual void UpdateMoveTab(sc::RefUpdateMoveTabContext &rCxt) override
double CalcValue(double nMin, double nMax, const ScIconSetFormat::const_iterator &itr) const
virtual void UpdateDeleteTab(sc::RefUpdateDeleteTabContext &rCxt) override
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
Definition: patattr.hxx:72
size_t size() const
Definition: rangelst.hxx:89
ScAddress aEnd
Definition: address.hxx:498
void ExtendTo(const ScRange &rRange)
Definition: address.cxx:1562
bool IsValid() const
Definition: address.hxx:544
ScAddress aStart
Definition: address.hxx:497
SfxHintId GetId() const
void EndListeningAll()
FormulaTokenArrayReferencesRange References() const
constexpr ::Color COL_LIGHTRED(0xFF, 0x00, 0x00)
ScIconSetType
Definition: colorscale.hxx:189
@ IconSet_3Arrows
Definition: colorscale.hxx:190
@ IconSet_3TrafficLights1
Definition: colorscale.hxx:193
@ IconSet_4Arrows
Definition: colorscale.hxx:202
@ IconSet_3Symbols2
Definition: colorscale.hxx:197
@ IconSet_3ArrowsGray
Definition: colorscale.hxx:191
@ IconSet_3Symbols
Definition: colorscale.hxx:196
@ IconSet_3Triangles
Definition: colorscale.hxx:200
@ IconSet_4TrafficLights
Definition: colorscale.hxx:206
@ IconSet_5Arrows
Definition: colorscale.hxx:207
@ IconSet_4Rating
Definition: colorscale.hxx:205
@ IconSet_3ColorSmilies
Definition: colorscale.hxx:201
@ IconSet_3Signs
Definition: colorscale.hxx:195
@ IconSet_5Quarters
Definition: colorscale.hxx:210
@ IconSet_5Boxes
Definition: colorscale.hxx:211
@ IconSet_5ArrowsGray
Definition: colorscale.hxx:208
@ IconSet_3TrafficLights2
Definition: colorscale.hxx:194
@ IconSet_4ArrowsGray
Definition: colorscale.hxx:203
@ IconSet_5Ratings
Definition: colorscale.hxx:209
@ IconSet_3Smilies
Definition: colorscale.hxx:198
@ IconSet_4RedToBlack
Definition: colorscale.hxx:204
@ IconSet_3Flags
Definition: colorscale.hxx:192
@ IconSet_3Stars
Definition: colorscale.hxx:199
ScColorScaleEntryType
Definition: colorscale.hxx:32
@ COLORSCALE_MAX
Definition: colorscale.hxx:35
@ COLORSCALE_VALUE
Definition: colorscale.hxx:37
@ COLORSCALE_FORMULA
Definition: colorscale.hxx:39
@ COLORSCALE_PERCENT
Definition: colorscale.hxx:38
@ COLORSCALE_PERCENTILE
Definition: colorscale.hxx:36
@ COLORSCALE_AUTO
Definition: colorscale.hxx:33
@ COLORSCALE_MIN
Definition: colorscale.hxx:34
RegionData_Impl * mpParent
DocumentType eType
sal_Int16 nValue
@ NoMakeAbsExternal
If set, absolute refs will not transformed to external references.
sal_Int32 nIndex
sal_Int64 n
sal_uInt16 nPos
#define SAL_WARN_IF(condition, area, stream)
std::unique_ptr< sal_Int32[]> pData
int i
std::map< OUString, BitmapEx > IconSetBitmapMap
Definition: document.hxx:217
long Long
ocColRowNameAuto
constexpr TypedWhichId< SvxFontHeightItem > ATTR_FONT_HEIGHT(101)
ScIconSetFormatData(ScIconSetType eType=IconSet_3Arrows)
Definition: colorscale.hxx:353
ScIconSetType eType
Definition: colorscale.hxx:216
const char * pName
Definition: colorscale.hxx:215
sal_Int32 nElements
Definition: colorscale.hxx:217
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:108
bool hasNumeric() const
Definition: cellvalue.cxx:619
double getValue()
Definition: cellvalue.cxx:629
Single reference (one address) into the sheet.
Definition: refdata.hxx:30
ScAddress toAbs(const ScSheetLimits &rLimits, const ScAddress &rPos) const
Definition: refdata.cxx:193
bool IsColRel() const
Definition: refdata.hxx:65
Context for reference update during shifting, moving or copying of cell ranges.
SCTAB getNewTab(SCTAB nOldTab) const
unsigned char sal_uInt8
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17
RedlineType meType
sal_Int32 nLength