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
384{
385 return new ScColorScaleFormat(pDoc, *this);
386}
387
389{
390}
391
393{
394 for (auto itr = begin(), itrEnd = end(); itr != itrEnd; ++itr)
395 {
396 (*itr)->SetRepaintCallback(pFormat);
397 }
399}
400
402{
404 maColorScales.back()->SetRepaintCallback(mpParent);
405}
406
408{
409 ScColorScaleEntries::const_iterator itr = maColorScales.begin();
410
411 if((*itr)->GetType() == COLORSCALE_VALUE || (*itr)->GetType() == COLORSCALE_FORMULA)
412 return (*itr)->GetValue();
413 else
414 {
415 return getMinValue();
416 }
417}
418
420{
421 ScColorScaleEntries::const_reverse_iterator itr = maColorScales.rbegin();
422
423 if((*itr)->GetType() == COLORSCALE_VALUE || (*itr)->GetType() == COLORSCALE_FORMULA)
424 return (*itr)->GetValue();
425 else
426 {
427 return getMaxValue();
428 }
429}
430
431void ScColorScaleFormat::calcMinMax(double& rMin, double& rMax) const
432{
433 rMin = GetMinValue();
434 rMax = GetMaxValue();
435}
436
438{
439 return mpParent->GetRange();
440}
441
442std::vector<double>& ScColorFormat::getValues() const
443{
444 if(!mpCache)
445 {
446 mpCache.reset(new ScColorFormatCache);
447 std::vector<double>& rValues = mpCache->maValues;
448
449 size_t n = GetRange().size();
450 const ScRangeList& aRanges = GetRange();
451 for(size_t i = 0; i < n; ++i)
452 {
453 const ScRange & rRange = aRanges[i];
454 SCTAB nTab = rRange.aStart.Tab();
455
456 SCCOL nColStart = rRange.aStart.Col();
457 SCROW nRowStart = rRange.aStart.Row();
458 SCCOL nColEnd = rRange.aEnd.Col();
459 SCROW nRowEnd = rRange.aEnd.Row();
460
461 if(nRowEnd == mpDoc->MaxRow())
462 {
463 bool bShrunk = false;
464 mpDoc->ShrinkToUsedDataArea(bShrunk, nTab, nColStart, nRowStart,
465 nColEnd, nRowEnd, false);
466 }
467 for(SCCOL nCol = nColStart; nCol <= nColEnd; ++nCol)
468 {
469 for(SCROW nRow = nRowStart; nRow <= nRowEnd; ++nRow)
470 {
471 ScAddress aAddr(nCol, nRow, nTab);
472 ScRefCellValue rCell(*mpDoc, aAddr);
473 if(rCell.hasNumeric())
474 {
475 double aVal = rCell.getValue();
476 rValues.push_back(aVal);
477 }
478 }
479 }
480 }
481
482 std::sort(rValues.begin(), rValues.end());
483 }
484
485 return mpCache->maValues;
486}
487
489{
490 std::vector<double>& rValues = getValues();
491 if(rValues.empty())
492 return 0;
493 return rValues[0];
494}
495
497{
498 std::vector<double>& rValues = getValues();
499 if(rValues.empty())
500 return 0;
501 return rValues[rValues.size()-1];
502}
503
505{
506 mpCache.reset();
507}
508
510{
511 mpCache.reset();
512}
513
514namespace {
515
516sal_uInt8 GetColorValue( double nVal, double nVal1, sal_uInt8 nColVal1, double nVal2, sal_uInt8 nColVal2 )
517{
518 if (nVal <= nVal1)
519 return nColVal1;
520
521 if (nVal >= nVal2)
522 return nColVal2;
523
524 sal_uInt8 nColVal = static_cast<int>((nVal - nVal1)/(nVal2-nVal1)*(nColVal2-nColVal1))+nColVal1;
525 return nColVal;
526}
527
528Color CalcColor( double nVal, double nVal1, const Color& rCol1, double nVal2, const Color& rCol2)
529{
530 sal_uInt8 nColRed = GetColorValue(nVal, nVal1, rCol1.GetRed(), nVal2, rCol2.GetRed());
531 sal_uInt8 nColBlue = GetColorValue(nVal, nVal1, rCol1.GetBlue(), nVal2, rCol2.GetBlue());
532 sal_uInt8 nColGreen = GetColorValue(nVal, nVal1, rCol1.GetGreen(), nVal2, rCol2.GetGreen());
533
534 return Color(nColRed, nColGreen, nColBlue);
535}
536
541double GetPercentile( const std::vector<double>& rArray, double fPercentile )
542{
543 assert(!rArray.empty());
544 SAL_WARN_IF(fPercentile < 0, "sc", "negative percentile");
545 if (fPercentile < 0)
546 return rArray.front();
547 assert(fPercentile <= 1);
548 size_t nSize = rArray.size();
549 double fFloor = ::rtl::math::approxFloor(fPercentile * (nSize-1));
550 size_t nIndex = static_cast<size_t>(fFloor);
551 double fDiff = fPercentile * (nSize-1) - fFloor;
552 std::vector<double>::const_iterator iter = rArray.begin() + nIndex;
553 if (fDiff == 0.0)
554 return *iter;
555 else
556 {
557 double fVal = *iter;
558 iter = rArray.begin() + nIndex+1;
559 return fVal + fDiff * (*iter - fVal);
560 }
561}
562
563}
564
565double ScColorScaleFormat::CalcValue(double nMin, double nMax, const ScColorScaleEntries::const_iterator& itr) const
566{
567 switch((*itr)->GetType())
568 {
570 return nMin + (nMax-nMin)*((*itr)->GetValue()/100);
571 case COLORSCALE_MIN:
572 return nMin;
573 case COLORSCALE_MAX:
574 return nMax;
576 {
577 std::vector<double>& rValues = getValues();
578 if(rValues.size() == 1)
579 return rValues[0];
580 else
581 {
582 double fPercentile = (*itr)->GetValue()/100.0;
583 return GetPercentile(rValues, fPercentile);
584 }
585 }
586
587 default:
588 break;
589 }
590
591 return (*itr)->GetValue();
592}
593
594std::optional<Color> ScColorScaleFormat::GetColor( const ScAddress& rAddr ) const
595{
596 ScRefCellValue rCell(*mpDoc, rAddr);
597 if(!rCell.hasNumeric())
598 return std::optional<Color>();
599
600 // now we have for sure a value
601 double nVal = rCell.getValue();
602
603 if (maColorScales.size() < 2)
604 return std::optional<Color>();
605
606 double nMin = std::numeric_limits<double>::max();
607 double nMax = std::numeric_limits<double>::min();
608 calcMinMax(nMin, nMax);
609
610 // this check is for safety
611 if(nMin >= nMax)
612 return std::optional<Color>();
613
614 ScColorScaleEntries::const_iterator itr = begin();
615 double nValMin = CalcValue(nMin, nMax, itr);
616 Color rColMin = (*itr)->GetColor();
617 ++itr;
618 double nValMax = CalcValue(nMin, nMax, itr);
619 Color rColMax = (*itr)->GetColor();
620
621 ++itr;
622 while(itr != end() && nVal > nValMax)
623 {
624 rColMin = rColMax;
625 nValMin = nValMax;
626 rColMax = (*itr)->GetColor();
627 nValMax = CalcValue(nMin, nMax, itr);
628 ++itr;
629 }
630
631 Color aColor = CalcColor(nVal, nValMin, rColMin, nValMax, rColMax);
632
633 return aColor;
634}
635
637{
638 for(ScColorScaleEntries::iterator itr = begin(); itr != end(); ++itr)
639 (*itr)->UpdateReference(rCxt);
640}
641
643{
644 for (ScColorScaleEntries::iterator it = begin(); it != end(); ++it)
645 (*it)->UpdateInsertTab(rCxt);
646}
647
649{
650 for (ScColorScaleEntries::iterator it = begin(); it != end(); ++it)
651 (*it)->UpdateDeleteTab(rCxt);
652}
653
655{
656 for (ScColorScaleEntries::iterator it = begin(); it != end(); ++it)
657 (*it)->UpdateMoveTab(rCxt);
658}
659
661{
662 return Type::Colorscale;
663}
664
665ScColorScaleEntries::iterator ScColorScaleFormat::begin()
666{
667 return maColorScales.begin();
668}
669
670ScColorScaleEntries::const_iterator ScColorScaleFormat::begin() const
671{
672 return maColorScales.begin();
673}
674
675ScColorScaleEntries::iterator ScColorScaleFormat::end()
676{
677 return maColorScales.end();
678}
679
680ScColorScaleEntries::const_iterator ScColorScaleFormat::end() const
681{
682 return maColorScales.end();
683}
684
686{
687 if (maColorScales.size() <= nPos)
688 return nullptr;
689
690 return maColorScales[nPos].get();
691}
692
694{
695 if (maColorScales.size() <= nPos)
696 return nullptr;
697
698 return maColorScales[nPos].get();
699}
700
702{
703 return maColorScales.size();
704}
705
707{
708 if (maColorScales.size() < 2)
709 {
710 // TODO: create 2 valid entries
711 }
712}
713
715 ScColorFormat(pDoc),
716 mpFormatData(new ScDataBarFormatData())
717{
718}
719
721 ScColorFormat(pDoc),
722 mpFormatData(new ScDataBarFormatData(*rFormat.mpFormatData))
723{
724}
725
727{
728 mpFormatData.reset(pData);
729 if (mpParent)
730 {
731 mpFormatData->mpUpperLimit->SetRepaintCallback(mpParent);
732 mpFormatData->mpLowerLimit->SetRepaintCallback(mpParent);
733 }
734}
735
737{
738 return mpFormatData.get();
739}
740
742{
743 return mpFormatData.get();
744}
745
747{
748 return new ScDataBarFormat(pDoc, *this);
749}
750
752{
753 if (mpFormatData)
754 {
755 mpFormatData->mpUpperLimit->SetRepaintCallback(pFormat);
756 mpFormatData->mpLowerLimit->SetRepaintCallback(pFormat);
757 }
759}
760
762{
763 return Type::Databar;
764}
765
767{
768 mpFormatData->mpUpperLimit->UpdateReference(rCxt);
769 mpFormatData->mpLowerLimit->UpdateReference(rCxt);
770}
771
773{
774 mpFormatData->mpUpperLimit->UpdateInsertTab(rCxt);
775 mpFormatData->mpLowerLimit->UpdateInsertTab(rCxt);
776}
777
779{
780 mpFormatData->mpUpperLimit->UpdateDeleteTab(rCxt);
781 mpFormatData->mpLowerLimit->UpdateDeleteTab(rCxt);
782}
783
785{
786 mpFormatData->mpUpperLimit->UpdateMoveTab(rCxt);
787 mpFormatData->mpLowerLimit->UpdateMoveTab(rCxt);
788}
789
790double ScDataBarFormat::getMin(double nMin, double nMax) const
791{
792 switch(mpFormatData->mpLowerLimit->GetType())
793 {
794 case COLORSCALE_MIN:
795 return nMin;
796
797 case COLORSCALE_AUTO:
798 return std::min<double>(0, nMin);
799
801 return nMin + (nMax-nMin)/100*mpFormatData->mpLowerLimit->GetValue();
802
804 {
805 double fPercentile = mpFormatData->mpLowerLimit->GetValue()/100.0;
806 std::vector<double>& rValues = getValues();
807 return GetPercentile(rValues, fPercentile);
808 }
809
810 default:
811 break;
812 }
813
814 return mpFormatData->mpLowerLimit->GetValue();
815}
816
817double ScDataBarFormat::getMax(double nMin, double nMax) const
818{
819 switch(mpFormatData->mpUpperLimit->GetType())
820 {
821 case COLORSCALE_MAX:
822 return nMax;
823 case COLORSCALE_AUTO:
824 return std::max<double>(0, nMax);
826 return nMin + (nMax-nMin)/100*mpFormatData->mpUpperLimit->GetValue();
828 {
829 double fPercentile = mpFormatData->mpUpperLimit->GetValue()/100.0;
830 std::vector<double>& rValues = getValues();
831 return GetPercentile(rValues, fPercentile);
832 }
833
834 default:
835 break;
836 }
837
838 return mpFormatData->mpUpperLimit->GetValue();
839}
840
841std::unique_ptr<ScDataBarInfo> ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const
842{
843 ScRefCellValue rCell(*mpDoc, rAddr);
844 if(!rCell.hasNumeric())
845 return nullptr;
846
847 // now we have for sure a value
848
849 double nValMin = getMinValue();
850 double nValMax = getMaxValue();
851 double nMin = getMin(nValMin, nValMax);
852 double nMax = getMax(nValMin, nValMax);
853 double nMinLength = mpFormatData->mnMinLength;
854 double nMaxLength = mpFormatData->mnMaxLength;
855
856 double nValue = rCell.getValue();
857
858 std::unique_ptr<ScDataBarInfo> pInfo(new ScDataBarInfo);
859 if(mpFormatData->meAxisPosition == databar::NONE)
860 {
861 if(nValue <= nMin)
862 {
863 pInfo->mnLength = nMinLength;
864 }
865 else if(nValue >= nMax)
866 {
867 pInfo->mnLength = nMaxLength;
868 }
869 else
870 {
871 double nDiff = nMax - nMin;
872 pInfo->mnLength = nMinLength + (nValue - nMin)/nDiff * (nMaxLength-nMinLength);
873 }
874 pInfo->mnZero = 0;
875 }
876 else if (mpFormatData->meAxisPosition == databar::AUTOMATIC)
877 {
878 // if auto is used we may need to adjust it
879 // for the length calculation
880 if (mpFormatData->mpLowerLimit->GetType() == COLORSCALE_AUTO && nMin > 0)
881 nMin = 0;
882 if (mpFormatData->mpUpperLimit->GetType() == COLORSCALE_MAX && nMax < 0)
883 nMax = 0;
884
885 //calculate the zero position first
886 if(nMin < 0)
887 {
888 if(nMax < 0)
889 pInfo->mnZero = 100;
890 else
891 {
892 pInfo->mnZero = -100*nMin/(nMax-nMin);
893 }
894 }
895 else
896 pInfo->mnZero = 0;
897
898 double nMinNonNegative = std::max(0.0, nMin);
899 double nMaxNonPositive = std::min(0.0, nMax);
900 //calculate the length
901 if(nValue < 0 && nMin < 0)
902 {
903 if (nValue < nMin)
904 pInfo->mnLength = -100;
905 else
906 pInfo->mnLength = -100 * (nValue-nMaxNonPositive)/(nMin-nMaxNonPositive);
907 }
908 else
909 {
910 if ( nValue > nMax )
911 pInfo->mnLength = 100;
912 else if (nValue <= nMin)
913 pInfo->mnLength = 0;
914 else
915 pInfo->mnLength = 100 * (nValue-nMinNonNegative)/(nMax-nMinNonNegative);
916 }
917 }
918 else if( mpFormatData->meAxisPosition == databar::MIDDLE)
919 {
920 pInfo->mnZero = 50;
921 double nAbsMax = std::max(std::abs(nMin), std::abs(nMax));
922 if (nValue < 0 && nMin < 0)
923 {
924 if (nValue < nMin)
925 pInfo->mnLength = nMaxLength * (nMin/nAbsMax);
926 else
927 pInfo->mnLength = nMaxLength * (nValue/nAbsMax);
928 }
929 else
930 {
931 if (nValue > nMax)
932 pInfo->mnLength = nMaxLength * (nMax/nAbsMax);
933 else
934 pInfo->mnLength = nMaxLength * (std::max(nValue, nMin)/nAbsMax);
935 }
936 }
937 else
938 assert(false);
939
940 // set color
941 if(mpFormatData->mbNeg && nValue < 0)
942 {
943 if(mpFormatData->mxNegativeColor)
944 {
945 pInfo->maColor = *mpFormatData->mxNegativeColor;
946 }
947 else
948 {
949 // default negative color is red
950 pInfo->maColor = COL_LIGHTRED;
951 }
952
953 }
954 else
955 pInfo->maColor = mpFormatData->maPositiveColor;
956
957 pInfo->mbGradient = mpFormatData->mbGradient;
958 pInfo->mbShowValue = !mpFormatData->mbOnlyBar;
959 pInfo->maAxisColor = mpFormatData->maAxisColor;
960
961 return pInfo;
962}
963
965{
966 if (!mpFormatData->mpLowerLimit)
967 {
968 // TODO: implement
969 }
970 if (!mpFormatData->mpUpperLimit)
971 {
972 // TODO: implement
973 }
974}
975
977 : eIconSetType(rOther.eIconSetType)
978 , mbShowValue(rOther.mbShowValue)
979 , mbReverse(rOther.mbReverse)
980 , mbCustom(rOther.mbCustom)
981 , maCustomVector(rOther.maCustomVector)
982{
983 m_Entries.reserve(rOther.m_Entries.size());
984 for (auto const& it : rOther.m_Entries)
985 {
986 m_Entries.emplace_back(new ScColorScaleEntry(*it));
987 }
988}
989
991 ScColorFormat(pDoc),
992 mpFormatData(new ScIconSetFormatData)
993{
994}
995
997 ScColorFormat(pDoc),
998 mpFormatData(new ScIconSetFormatData(*rFormat.mpFormatData))
999{
1000}
1001
1003{
1004 return new ScIconSetFormat(pDoc, *this);
1005}
1006
1008{
1009 for(iterator itr = begin(); itr != end(); ++itr)
1010 {
1011 (*itr)->SetRepaintCallback(pFormat);
1012 }
1013 ScColorFormat::SetParent(pFormat);
1014}
1015
1017{
1018 mpFormatData.reset( pFormatData );
1020}
1021
1023{
1024 return mpFormatData.get();
1025}
1026
1028{
1029 return mpFormatData.get();
1030}
1031
1032std::unique_ptr<ScIconSetInfo> ScIconSetFormat::GetIconSetInfo(const ScAddress& rAddr) const
1033{
1034 ScRefCellValue rCell(*mpDoc, rAddr);
1035 if(!rCell.hasNumeric())
1036 return nullptr;
1037
1038 // now we have for sure a value
1039 double nVal = rCell.getValue();
1040
1041 if (mpFormatData->m_Entries.size() < 2)
1042 return nullptr;
1043
1044 double nMin = GetMinValue();
1045 double nMax = GetMaxValue();
1046
1047 sal_Int32 nIndex = 0;
1048 const_iterator itr = begin();
1049 ++itr;
1050 double nValMax = CalcValue(nMin, nMax, itr);
1051
1052 ++itr;
1053 while(itr != end() && nVal >= nValMax)
1054 {
1055 ++nIndex;
1056 nValMax = CalcValue(nMin, nMax, itr);
1057 ++itr;
1058 }
1059
1060 if(nVal >= nValMax)
1061 ++nIndex;
1062
1063 std::unique_ptr<ScIconSetInfo> pInfo(new ScIconSetInfo);
1064
1065 const SfxPoolItem& rPoolItem = mpDoc->GetPattern(rAddr)->GetItem(ATTR_FONT_HEIGHT);
1066 tools::Long aFontHeight = static_cast<const SvxFontHeightItem&>(rPoolItem).GetHeight();
1067 pInfo->mnHeight = aFontHeight;
1068
1069 if(mpFormatData->mbReverse)
1070 {
1071 sal_Int32 nMaxIndex = mpFormatData->m_Entries.size() - 1;
1072 nIndex = nMaxIndex - nIndex;
1073 }
1074
1075 if (mpFormatData->mbCustom && sal_Int32(mpFormatData->maCustomVector.size()) > nIndex)
1076 {
1077 ScIconSetType eCustomType = mpFormatData->maCustomVector[nIndex].first;
1078 sal_Int32 nCustomIndex = mpFormatData->maCustomVector[nIndex].second;
1079 if (nCustomIndex == -1)
1080 {
1081 return nullptr;
1082 }
1083
1084 pInfo->eIconSetType = eCustomType;
1085 pInfo->nIconIndex = nCustomIndex;
1086 }
1087 else
1088 {
1089 pInfo->nIconIndex = nIndex;
1090 pInfo->eIconSetType = mpFormatData->eIconSetType;
1091 }
1092
1093 pInfo->mbShowValue = mpFormatData->mbShowValue;
1094 return pInfo;
1095}
1096
1098{
1099 return Type::Iconset;
1100}
1101
1103{
1104 for(iterator itr = begin(); itr != end(); ++itr)
1105 {
1106 (*itr)->UpdateReference(rCxt);
1107 }
1108}
1109
1111{
1112 for(iterator itr = begin(); itr != end(); ++itr)
1113 {
1114 (*itr)->UpdateInsertTab(rCxt);
1115 }
1116}
1117
1119{
1120 for(iterator itr = begin(); itr != end(); ++itr)
1121 {
1122 (*itr)->UpdateDeleteTab(rCxt);
1123 }
1124}
1125
1127{
1128 for(iterator itr = begin(); itr != end(); ++itr)
1129 {
1130 (*itr)->UpdateMoveTab(rCxt);
1131 }
1132}
1133
1135{
1136 return mpFormatData->m_Entries.begin();
1137}
1138
1140{
1141 return mpFormatData->m_Entries.begin();
1142}
1143
1145{
1146 return mpFormatData->m_Entries.end();
1147}
1148
1150{
1151 return mpFormatData->m_Entries.end();
1152}
1153
1155{
1156 const_iterator itr = begin();
1157
1158 if ((*itr)->GetType() == COLORSCALE_VALUE || (*itr)->GetType() == COLORSCALE_FORMULA)
1159 return (*itr)->GetValue();
1160 else
1161 {
1162 return getMinValue();
1163 }
1164}
1165
1167{
1168 auto const itr = mpFormatData->m_Entries.rbegin();
1169
1170 if ((*itr)->GetType() == COLORSCALE_VALUE || (*itr)->GetType() == COLORSCALE_FORMULA)
1171 return (*itr)->GetValue();
1172 else
1173 {
1174 return getMaxValue();
1175 }
1176}
1177
1178double ScIconSetFormat::CalcValue(double nMin, double nMax, const ScIconSetFormat::const_iterator& itr) const
1179{
1180 switch ((*itr)->GetType())
1181 {
1182 case COLORSCALE_PERCENT:
1183 return nMin + (nMax-nMin)*((*itr)->GetValue()/100);
1184 case COLORSCALE_MIN:
1185 return nMin;
1186 case COLORSCALE_MAX:
1187 return nMax;
1189 {
1190 std::vector<double>& rValues = getValues();
1191 if(rValues.size() == 1)
1192 return rValues[0];
1193 else
1194 {
1195 double fPercentile = (*itr)->GetValue()/100.0;
1196 return GetPercentile(rValues, fPercentile);
1197 }
1198 }
1199
1200 default:
1201 break;
1202 }
1203
1204 return (*itr)->GetValue();
1205}
1206
1208 { "3Arrows", IconSet_3Arrows, 3 },
1209 { "3ArrowsGray", IconSet_3ArrowsGray, 3 },
1210 { "3Flags", IconSet_3Flags, 3 },
1211 { "3TrafficLights1", IconSet_3TrafficLights1, 3 },
1212 { "3TrafficLights2", IconSet_3TrafficLights2, 3 },
1213 { "3Signs", IconSet_3Signs, 3 },
1214 { "3Symbols", IconSet_3Symbols, 3 },
1215 { "3Symbols2", IconSet_3Symbols2, 3 },
1216 { "3Smilies", IconSet_3Smilies, 3 },
1217 { "3ColorSmilies", IconSet_3ColorSmilies, 3 },
1218 { "3Stars", IconSet_3Stars, 3 },
1219 { "3Triangles", IconSet_3Triangles, 3 },
1220 { "4Arrows", IconSet_4Arrows, 4 },
1221 { "4ArrowsGray", IconSet_4ArrowsGray, 4 },
1222 { "4RedToBlack", IconSet_4RedToBlack, 4 },
1223 { "4Rating", IconSet_4Rating, 4 },
1224 { "4TrafficLights", IconSet_4TrafficLights, 4 },
1225 { "5Arrows", IconSet_5Arrows, 5 },
1226 { "5ArrowsGray", IconSet_5ArrowsGray, 5 },
1227 { "5Rating", IconSet_5Ratings, 5 },
1228 { "5Quarters", IconSet_5Quarters, 5 },
1229 { "5Boxes", IconSet_5Boxes, 5 },
1230 { nullptr, IconSet_3Arrows, 0 }
1231};
1232
1234{
1235 return mpFormatData->m_Entries.size();
1236}
1237
1238
1239namespace {
1240
1241constexpr rtl::OUStringConstExpr a3TrafficLights1[] = {
1242 BMP_ICON_SET_CIRCLES1_RED, BMP_ICON_SET_CIRCLES1_YELLOW, BMP_ICON_SET_CIRCLES1_GREEN
1243};
1244
1245constexpr rtl::OUStringConstExpr a3TrafficLights2[] = {
1246 BMP_ICON_SET_TRAFFICLIGHTS_RED, BMP_ICON_SET_TRAFFICLIGHTS_YELLOW, BMP_ICON_SET_TRAFFICLIGHTS_GREEN
1247};
1248
1249constexpr rtl::OUStringConstExpr a3Arrows[] = {
1250 BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SAME, BMP_ICON_SET_COLORARROWS_UP
1251};
1252
1253constexpr rtl::OUStringConstExpr a3ArrowsGray[] = {
1254 BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SAME, BMP_ICON_SET_GRAYARROWS_UP
1255};
1256
1257constexpr rtl::OUStringConstExpr a3Flags[] = {
1258 BMP_ICON_SET_FLAGS_RED, BMP_ICON_SET_FLAGS_YELLOW, BMP_ICON_SET_FLAGS_GREEN
1259};
1260
1261constexpr rtl::OUStringConstExpr a3Smilies[] = {
1262 BMP_ICON_SET_POSITIVE_YELLOW_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_NEGATIVE_YELLOW_SMILIE
1263};
1264
1265constexpr rtl::OUStringConstExpr a3ColorSmilies[] = {
1266 BMP_ICON_SET_POSITIVE_GREEN_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_NEGATIVE_RED_SMILIE
1267};
1268
1269constexpr rtl::OUStringConstExpr a3Stars[] = {
1270 BMP_ICON_SET_STARS_EMPTY, BMP_ICON_SET_STARS_HALF, BMP_ICON_SET_STARS_FULL
1271};
1272
1273constexpr rtl::OUStringConstExpr a3Triangles[] = {
1274 BMP_ICON_SET_TRIANGLES_DOWN, BMP_ICON_SET_TRIANGLES_SAME, BMP_ICON_SET_TRIANGLES_UP
1275};
1276
1277constexpr rtl::OUStringConstExpr a4Arrows[] = {
1278 BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP, BMP_ICON_SET_COLORARROWS_UP
1279};
1280
1281constexpr rtl::OUStringConstExpr a4ArrowsGray[] = {
1282 BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP, BMP_ICON_SET_GRAYARROWS_UP
1283};
1284
1285constexpr rtl::OUStringConstExpr a5Arrows[] = {
1286 BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN,
1287 BMP_ICON_SET_COLORARROWS_SAME, BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP, BMP_ICON_SET_COLORARROWS_UP
1288};
1289
1290constexpr rtl::OUStringConstExpr a5ArrowsGray[] = {
1291 BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN,
1292 BMP_ICON_SET_GRAYARROWS_SAME, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP, BMP_ICON_SET_GRAYARROWS_UP
1293};
1294
1295constexpr rtl::OUStringConstExpr a4TrafficLights[] = {
1296 BMP_ICON_SET_CIRCLES1_GRAY, BMP_ICON_SET_CIRCLES1_RED,
1297 BMP_ICON_SET_CIRCLES1_YELLOW, BMP_ICON_SET_CIRCLES1_GREEN
1298};
1299
1300constexpr rtl::OUStringConstExpr a5Quarters[] = {
1301 BMP_ICON_SET_PIES_EMPTY, BMP_ICON_SET_PIES_ONE_QUARTER, BMP_ICON_SET_PIES_HALF,
1302 BMP_ICON_SET_PIES_THREE_QUARTER, BMP_ICON_SET_PIES_FULL,
1303};
1304
1305constexpr rtl::OUStringConstExpr a5Boxes[] = {
1306 BMP_ICON_SET_SQUARES_EMPTY, BMP_ICON_SET_SQUARES_ONE_QUARTER,
1307 BMP_ICON_SET_SQUARES_HALF, BMP_ICON_SET_SQUARES_THREE_QUARTER,
1308 BMP_ICON_SET_SQUARES_FULL
1309};
1310
1311constexpr rtl::OUStringConstExpr a3Symbols1[] = {
1312 BMP_ICON_SET_SYMBOLS1_CROSS, BMP_ICON_SET_SYMBOLS1_EXCLAMATION_MARK, BMP_ICON_SET_SYMBOLS1_CHECK
1313};
1314
1315constexpr rtl::OUStringConstExpr a3Signs[] = {
1316 BMP_ICON_SET_SHAPES_DIAMOND, BMP_ICON_SET_SHAPES_TRIANGLE, BMP_ICON_SET_SHAPES_CIRCLE
1317};
1318
1319constexpr rtl::OUStringConstExpr a4RedToBlack[] = {
1320 BMP_ICON_SET_CIRCLES2_DARK_GRAY, BMP_ICON_SET_CIRCLES2_LIGHT_GRAY,
1321 BMP_ICON_SET_CIRCLES2_LIGHT_RED, BMP_ICON_SET_CIRCLES2_DARK_RED
1322};
1323
1324constexpr rtl::OUStringConstExpr a4Ratings[] = {
1325 BMP_ICON_SET_BARS_ONE_QUARTER, BMP_ICON_SET_BARS_HALF,
1326 BMP_ICON_SET_BARS_THREE_QUARTER, BMP_ICON_SET_BARS_FULL
1327};
1328
1329constexpr rtl::OUStringConstExpr a5Ratings[] = {
1330 BMP_ICON_SET_BARS_EMPTY, BMP_ICON_SET_BARS_ONE_QUARTER, BMP_ICON_SET_BARS_HALF,
1331 BMP_ICON_SET_BARS_THREE_QUARTER, BMP_ICON_SET_BARS_FULL
1332};
1333
1334struct ScIconSetBitmapMap {
1336 const rtl::OUStringConstExpr* pBitmaps;
1337};
1338
1339const ScIconSetBitmapMap aBitmapMap[] = {
1340 { IconSet_3Arrows, a3Arrows },
1341 { IconSet_3ArrowsGray, a3ArrowsGray },
1342 { IconSet_3Flags, a3Flags },
1343 { IconSet_3Signs, a3Signs },
1344 { IconSet_3Symbols, a3Symbols1 },
1345 { IconSet_3Symbols2, a3Symbols1 },
1346 { IconSet_3TrafficLights1, a3TrafficLights1 },
1347 { IconSet_3TrafficLights2, a3TrafficLights2 },
1348 { IconSet_3Smilies, a3Smilies },
1349 { IconSet_3ColorSmilies, a3ColorSmilies },
1350 { IconSet_3Triangles, a3Triangles },
1351 { IconSet_3Stars, a3Stars },
1352 { IconSet_4Arrows, a4Arrows },
1353 { IconSet_4ArrowsGray, a4ArrowsGray },
1354 { IconSet_4Rating, a4Ratings },
1355 { IconSet_4RedToBlack, a4RedToBlack },
1356 { IconSet_4TrafficLights, a4TrafficLights },
1357 { IconSet_5Arrows, a5Arrows },
1358 { IconSet_5ArrowsGray, a5ArrowsGray },
1359 { IconSet_5Quarters, a5Quarters },
1360 { IconSet_5Ratings, a5Ratings },
1361 { IconSet_5Boxes, a5Boxes }
1362};
1363
1364const ScIconSetMap* findIconSetType(ScIconSetType eType)
1365{
1367 for (; pMap->pName; ++pMap)
1368 {
1369 if (pMap->eType == eType)
1370 return pMap;
1371 }
1372
1373 return nullptr;
1374}
1375
1376}
1377
1379{
1380 const ScIconSetMap* pMap = findIconSetType(eType);
1381 if (pMap)
1382 return pMap->pName;
1383
1384 return "";
1385}
1386
1388{
1389 const ScIconSetMap* pMap = findIconSetType(eType);
1390 if (pMap)
1391 return pMap->nElements;
1392
1393 return 0;
1394}
1395
1396OUString ScIconSetFormat::getIconName(ScIconSetType const eType, sal_Int32 const nIndex)
1397{
1398 OUString sBitmap;
1399
1400 for(const ScIconSetBitmapMap & i : aBitmapMap)
1401 {
1402 if(i.eType == eType)
1403 {
1404 sBitmap = *(i.pBitmaps + nIndex);
1405 break;
1406 }
1407 }
1408
1409 assert(!sBitmap.isEmpty());
1410
1411 return sBitmap;
1412}
1413
1415 ScIconSetType const eType, sal_Int32 const nIndex)
1416{
1417 OUString sBitmap(ScIconSetFormat::getIconName(eType, nIndex));
1418
1419 std::map<OUString, BitmapEx>::iterator itr = rIconSetBitmapMap.find(sBitmap);
1420 if (itr != rIconSetBitmapMap.end())
1421 return itr->second;
1422
1423 BitmapEx aBitmap(sBitmap);
1424 std::pair<OUString, BitmapEx> aPair(sBitmap, aBitmap);
1425 std::pair<std::map<OUString, BitmapEx>::iterator, bool> itrNew = rIconSetBitmapMap.insert(aPair);
1426 assert(itrNew.second);
1427
1428 return itrNew.first->second;
1429}
1430
1432{
1433 ScIconSetType eType = mpFormatData->eIconSetType;
1434 for (const ScIconSetMap & i : g_IconSetMap)
1435 {
1436 if (i.eType == eType)
1437 {
1438 // size_t nElements = aIconSetMap[i].nElements;
1439 // TODO: implement
1440 break;
1441 }
1442 }
1443}
1444
1445/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
basegfx::BColor maColor
bool mbReverse
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:437
double getMinValue() const
Definition: colorscale.cxx:488
virtual void endRendering() override
Definition: colorscale.cxx:509
virtual void SetParent(ScConditionalFormat *pParent) override
Definition: colorscale.cxx:364
ScColorFormat(ScDocument *pDoc)
Definition: colorscale.cxx:354
double getMaxValue() const
Definition: colorscale.cxx:496
virtual ~ScColorFormat() override
Definition: colorscale.cxx:360
ScConditionalFormat * mpParent
Definition: colorscale.hxx:239
virtual void startRendering() override
Definition: colorscale.cxx:504
std::vector< double > & getValues() const
Definition: colorscale.cxx:442
std::unique_ptr< ScColorFormatCache > mpCache
Definition: colorscale.hxx:247
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:660
void AddEntry(ScColorScaleEntry *pEntry)
Definition: colorscale.cxx:401
double GetMinValue() const
Definition: colorscale.cxx:407
double GetMaxValue() const
Definition: colorscale.cxx:419
virtual void UpdateDeleteTab(sc::RefUpdateDeleteTabContext &rCxt) override
Definition: colorscale.cxx:648
virtual ~ScColorScaleFormat() override
Definition: colorscale.cxx:388
virtual void UpdateInsertTab(sc::RefUpdateInsertTabContext &rCxt) override
Definition: colorscale.cxx:642
ScColorScaleEntries::iterator begin()
Definition: colorscale.cxx:665
double CalcValue(double nMin, double nMax, const ScColorScaleEntries::const_iterator &rItr) const
Definition: colorscale.cxx:565
ScColorScaleEntry * GetEntry(size_t nPos)
Definition: colorscale.cxx:685
virtual ScColorFormat * Clone(ScDocument *pDoc) const override
Definition: colorscale.cxx:383
void calcMinMax(double &nMin, double &nMax) const
Definition: colorscale.cxx:431
ScColorScaleEntries::iterator end()
Definition: colorscale.cxx:675
ScColorScaleEntries maColorScales
Definition: colorscale.hxx:255
size_t size() const
Definition: colorscale.cxx:701
virtual void UpdateReference(sc::RefUpdateContext &rCxt) override
Definition: colorscale.cxx:636
std::optional< Color > GetColor(const ScAddress &rAddr) const
Definition: colorscale.cxx:594
virtual void UpdateMoveTab(sc::RefUpdateMoveTabContext &rCxt) override
Definition: colorscale.cxx:654
virtual void SetParent(ScConditionalFormat *pParent) override
Definition: colorscale.cxx:392
ScColorScaleFormat(ScDocument *pDoc)
Definition: colorscale.cxx:369
void EnsureSize()
Makes sure that the maColorScales contain at least 2 entries.
Definition: colorscale.cxx:706
const ScRangeList & GetRange() const
Definition: conditio.hxx:558
ScDocument * GetDocument()
Definition: conditio.cxx:1780
std::unique_ptr< ScDataBarInfo > GetDataBarInfo(const ScAddress &rAddr) const
Definition: colorscale.cxx:841
virtual void UpdateReference(sc::RefUpdateContext &rCxt) override
Definition: colorscale.cxx:766
void EnsureSize()
Makes sure that the mpFormatData does not contain valid entries.
Definition: colorscale.cxx:964
virtual void UpdateInsertTab(sc::RefUpdateInsertTabContext &rCxt) override
Definition: colorscale.cxx:772
virtual Type GetType() const override
Definition: colorscale.cxx:761
virtual void UpdateMoveTab(sc::RefUpdateMoveTabContext &rCxt) override
Definition: colorscale.cxx:784
void SetDataBarData(ScDataBarFormatData *pData)
Definition: colorscale.cxx:726
virtual void SetParent(ScConditionalFormat *pParent) override
Definition: colorscale.cxx:751
double getMin(double nMin, double nMax) const
Definition: colorscale.cxx:790
virtual ScColorFormat * Clone(ScDocument *pDoc) const override
Definition: colorscale.cxx:746
virtual void UpdateDeleteTab(sc::RefUpdateDeleteTabContext &rCxt) override
Definition: colorscale.cxx:778
std::unique_ptr< ScDataBarFormatData > mpFormatData
Definition: colorscale.hxx:328
ScDataBarFormat(ScDocument *pDoc)
Definition: colorscale.cxx:714
double getMax(double nMin, double nMax) const
Definition: colorscale.cxx:817
const ScDataBarFormatData * GetDataBarData() const
Definition: colorscale.cxx:741
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:891
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:892
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:1074
void StartListeningArea(const ScRange &rRange, bool bGroupListening, SvtListener *pListener)
Definition: documen7.cxx:35
bool IsClipOrUndo() const
Definition: document.hxx:1590
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4812
ScDocument * mpDoc
Definition: conditio.hxx:255
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:408
size_t size() const
virtual Type GetType() const override
virtual void UpdateInsertTab(sc::RefUpdateInsertTabContext &rCxt) override
ScIconSetFormatData::Entries_t::iterator iterator
Definition: colorscale.hxx:386
double GetMinValue() const
static const ScIconSetMap g_IconSetMap[]
Definition: colorscale.hxx:380
static sal_Int32 getIconSetElements(ScIconSetType eType)
iterator begin()
double GetMaxValue() const
ScIconSetFormatData::Entries_t::const_iterator const_iterator
Definition: colorscale.hxx:387
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)
Definition: colorscale.cxx:990
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:216
long Long
ocColRowNameAuto
constexpr TypedWhichId< SvxFontHeightItem > ATTR_FONT_HEIGHT(101)
ScIconSetFormatData(ScIconSetType eType=IconSet_3Arrows)
Definition: colorscale.hxx:346
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