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 // tdf#155321 for the last percentile value, use always the end of the color scale,
661 // i.e. not the first possible color in the case of repeating values
662 bool bEqual = COLORSCALE_PERCENTILE == (*itr)->GetType() && nVal == nMax && nVal == nValMax;
663
664 ++itr;
665 while(itr != end() && (nVal > nValMax || bEqual))
666 {
667 rColMin = rColMax;
668 nValMin = !bEqual ? nValMax : nValMax - 1;
669 rColMax = (*itr)->GetColor();
670 nValMax = CalcValue(nMin, nMax, itr);
671 ++itr;
672 }
673
674 Color aColor = CalcColor(nVal, nValMin, rColMin, nValMax, rColMax);
675
676 return aColor;
677}
678
680{
681 for(ScColorScaleEntries::iterator itr = begin(); itr != end(); ++itr)
682 (*itr)->UpdateReference(rCxt);
683}
684
686{
687 for (ScColorScaleEntries::iterator it = begin(); it != end(); ++it)
688 (*it)->UpdateInsertTab(rCxt);
689}
690
692{
693 for (ScColorScaleEntries::iterator it = begin(); it != end(); ++it)
694 (*it)->UpdateDeleteTab(rCxt);
695}
696
698{
699 for (ScColorScaleEntries::iterator it = begin(); it != end(); ++it)
700 (*it)->UpdateMoveTab(rCxt);
701}
702
704{
705 return Type::Colorscale;
706}
707
708ScColorScaleEntries::iterator ScColorScaleFormat::begin()
709{
710 return maColorScales.begin();
711}
712
713ScColorScaleEntries::const_iterator ScColorScaleFormat::begin() const
714{
715 return maColorScales.begin();
716}
717
718ScColorScaleEntries::iterator ScColorScaleFormat::end()
719{
720 return maColorScales.end();
721}
722
723ScColorScaleEntries::const_iterator ScColorScaleFormat::end() const
724{
725 return maColorScales.end();
726}
727
729{
730 if (maColorScales.size() <= nPos)
731 return nullptr;
732
733 return maColorScales[nPos].get();
734}
735
737{
738 if (maColorScales.size() <= nPos)
739 return nullptr;
740
741 return maColorScales[nPos].get();
742}
743
745{
746 return maColorScales.size();
747}
748
750{
751 if (maColorScales.size() < 2)
752 {
753 // TODO: create 2 valid entries
754 }
755}
756
758 ScColorFormat(pDoc),
759 mpFormatData(new ScDataBarFormatData())
760{
761}
762
764 ScColorFormat(pDoc),
765 mpFormatData(new ScDataBarFormatData(*rFormat.mpFormatData))
766{
767}
768
770{
771 mpFormatData.reset(pData);
772 if (mpParent)
773 {
774 mpFormatData->mpUpperLimit->SetRepaintCallback(mpParent);
775 mpFormatData->mpLowerLimit->SetRepaintCallback(mpParent);
776 }
777}
778
780{
781 return mpFormatData.get();
782}
783
785{
786 return mpFormatData.get();
787}
788
790{
791 return new ScDataBarFormat(pDoc, *this);
792}
793
795{
796 if (mpFormatData)
797 {
798 mpFormatData->mpUpperLimit->SetRepaintCallback(pFormat);
799 mpFormatData->mpLowerLimit->SetRepaintCallback(pFormat);
800 }
802}
803
805{
806 return Type::Databar;
807}
808
809bool ScDataBarFormat::IsEqual(const ScFormatEntry& rOther, bool /*bIgnoreSrcPos*/) const
810{
811 if (GetType() != rOther.GetType())
812 return false;
813
814 const ScDataBarFormat& r = static_cast<const ScDataBarFormat&>(rOther);
815
816 bool bEq = (mpFormatData->maAxisColor.IsRGBEqual(r.mpFormatData->maAxisColor)
817 && mpFormatData->maPositiveColor.IsRGBEqual(r.mpFormatData->maPositiveColor)
818 && mpFormatData->mxNegativeColor == r.mpFormatData->mxNegativeColor
819 && mpFormatData->meAxisPosition == r.mpFormatData->meAxisPosition
820 && mpFormatData->mbGradient == r.mpFormatData->mbGradient
821 && mpFormatData->mbOnlyBar == r.mpFormatData->mbOnlyBar);
822
823 if (mpFormatData->mpUpperLimit->GetType() == r.mpFormatData->mpUpperLimit->GetType()
824 && bEq)
825 {
826 bEq = (mpFormatData->mpUpperLimit->GetColor().IsRGBEqual(
827 r.mpFormatData->mpUpperLimit->GetColor())
828 && mpFormatData->mpUpperLimit->GetValue()
829 == r.mpFormatData->mpUpperLimit->GetValue());
830 }
831
832 if (mpFormatData->mpLowerLimit->GetType() == r.mpFormatData->mpLowerLimit->GetType()
833 && bEq)
834 {
835 bEq = (mpFormatData->mpLowerLimit->GetColor().IsRGBEqual(
836 r.mpFormatData->mpLowerLimit->GetColor())
837 && mpFormatData->mpLowerLimit->GetValue()
838 == r.mpFormatData->mpLowerLimit->GetValue());
839 }
840
841 return bEq;
842}
843
845{
846 mpFormatData->mpUpperLimit->UpdateReference(rCxt);
847 mpFormatData->mpLowerLimit->UpdateReference(rCxt);
848}
849
851{
852 mpFormatData->mpUpperLimit->UpdateInsertTab(rCxt);
853 mpFormatData->mpLowerLimit->UpdateInsertTab(rCxt);
854}
855
857{
858 mpFormatData->mpUpperLimit->UpdateDeleteTab(rCxt);
859 mpFormatData->mpLowerLimit->UpdateDeleteTab(rCxt);
860}
861
863{
864 mpFormatData->mpUpperLimit->UpdateMoveTab(rCxt);
865 mpFormatData->mpLowerLimit->UpdateMoveTab(rCxt);
866}
867
868double ScDataBarFormat::getMin(double nMin, double nMax) const
869{
870 switch(mpFormatData->mpLowerLimit->GetType())
871 {
872 case COLORSCALE_MIN:
873 return nMin;
874
875 case COLORSCALE_AUTO:
876 return std::min<double>(0, nMin);
877
879 return nMin + (nMax-nMin)/100*mpFormatData->mpLowerLimit->GetValue();
880
882 {
883 double fPercentile = mpFormatData->mpLowerLimit->GetValue()/100.0;
884 std::vector<double>& rValues = getValues();
885 return GetPercentile(rValues, fPercentile);
886 }
887
888 default:
889 break;
890 }
891
892 return mpFormatData->mpLowerLimit->GetValue();
893}
894
895double ScDataBarFormat::getMax(double nMin, double nMax) const
896{
897 switch(mpFormatData->mpUpperLimit->GetType())
898 {
899 case COLORSCALE_MAX:
900 return nMax;
901 case COLORSCALE_AUTO:
902 return std::max<double>(0, nMax);
904 return nMin + (nMax-nMin)/100*mpFormatData->mpUpperLimit->GetValue();
906 {
907 double fPercentile = mpFormatData->mpUpperLimit->GetValue()/100.0;
908 std::vector<double>& rValues = getValues();
909 return GetPercentile(rValues, fPercentile);
910 }
911
912 default:
913 break;
914 }
915
916 return mpFormatData->mpUpperLimit->GetValue();
917}
918
919std::unique_ptr<ScDataBarInfo> ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const
920{
921 ScRefCellValue rCell(*mpDoc, rAddr);
922 if(!rCell.hasNumeric())
923 return nullptr;
924
925 // now we have for sure a value
926
927 double nValMin = getMinValue();
928 double nValMax = getMaxValue();
929 double nMin = getMin(nValMin, nValMax);
930 double nMax = getMax(nValMin, nValMax);
931 double nMinLength = mpFormatData->mnMinLength;
932 double nMaxLength = mpFormatData->mnMaxLength;
933
934 double nValue = rCell.getValue();
935
936 std::unique_ptr<ScDataBarInfo> pInfo(new ScDataBarInfo);
937 if(mpFormatData->meAxisPosition == databar::NONE)
938 {
939 if(nValue <= nMin)
940 {
941 pInfo->mnLength = nMinLength;
942 }
943 else if(nValue >= nMax)
944 {
945 pInfo->mnLength = nMaxLength;
946 }
947 else
948 {
949 double nDiff = nMax - nMin;
950 pInfo->mnLength = nMinLength + (nValue - nMin)/nDiff * (nMaxLength-nMinLength);
951 }
952 pInfo->mnZero = 0;
953 }
954 else if (mpFormatData->meAxisPosition == databar::AUTOMATIC)
955 {
956 // if auto is used we may need to adjust it
957 // for the length calculation
958 if (mpFormatData->mpLowerLimit->GetType() == COLORSCALE_AUTO && nMin > 0)
959 nMin = 0;
960 if (mpFormatData->mpUpperLimit->GetType() == COLORSCALE_MAX && nMax < 0)
961 nMax = 0;
962
963 //calculate the zero position first
964 if(nMin < 0)
965 {
966 if(nMax < 0)
967 pInfo->mnZero = 100;
968 else
969 {
970 pInfo->mnZero = -100*nMin/(nMax-nMin);
971 }
972 }
973 else
974 pInfo->mnZero = 0;
975
976 double nMinNonNegative = std::max(0.0, nMin);
977 double nMaxNonPositive = std::min(0.0, nMax);
978 //calculate the length
979 if(nValue < 0 && nMin < 0)
980 {
981 if (nValue < nMin)
982 pInfo->mnLength = -100;
983 else
984 pInfo->mnLength = -100 * (nValue-nMaxNonPositive)/(nMin-nMaxNonPositive);
985 }
986 else
987 {
988 if ( nValue > nMax )
989 pInfo->mnLength = 100;
990 else if (nValue <= nMin)
991 pInfo->mnLength = 0;
992 else
993 pInfo->mnLength = 100 * (nValue-nMinNonNegative)/(nMax-nMinNonNegative);
994 }
995 }
996 else if( mpFormatData->meAxisPosition == databar::MIDDLE)
997 {
998 pInfo->mnZero = 50;
999 double nAbsMax = std::max(std::abs(nMin), std::abs(nMax));
1000 if (nValue < 0 && nMin < 0)
1001 {
1002 if (nValue < nMin)
1003 pInfo->mnLength = nMaxLength * (nMin/nAbsMax);
1004 else
1005 pInfo->mnLength = nMaxLength * (nValue/nAbsMax);
1006 }
1007 else
1008 {
1009 if (nValue > nMax)
1010 pInfo->mnLength = nMaxLength * (nMax/nAbsMax);
1011 else
1012 pInfo->mnLength = nMaxLength * (std::max(nValue, nMin)/nAbsMax);
1013 }
1014 }
1015 else
1016 assert(false);
1017
1018 // set color
1019 if(mpFormatData->mbNeg && nValue < 0)
1020 {
1021 if(mpFormatData->mxNegativeColor)
1022 {
1023 pInfo->maColor = *mpFormatData->mxNegativeColor;
1024 }
1025 else
1026 {
1027 // default negative color is red
1028 pInfo->maColor = COL_LIGHTRED;
1029 }
1030
1031 }
1032 else
1033 pInfo->maColor = mpFormatData->maPositiveColor;
1034
1035 pInfo->mbGradient = mpFormatData->mbGradient;
1036 pInfo->mbShowValue = !mpFormatData->mbOnlyBar;
1037 pInfo->maAxisColor = mpFormatData->maAxisColor;
1038
1039 return pInfo;
1040}
1041
1043{
1044 if (!mpFormatData->mpLowerLimit)
1045 {
1046 // TODO: implement
1047 }
1048 if (!mpFormatData->mpUpperLimit)
1049 {
1050 // TODO: implement
1051 }
1052}
1053
1055 : eIconSetType(rOther.eIconSetType)
1056 , mbShowValue(rOther.mbShowValue)
1057 , mbReverse(rOther.mbReverse)
1058 , mbCustom(rOther.mbCustom)
1059 , maCustomVector(rOther.maCustomVector)
1060{
1061 m_Entries.reserve(rOther.m_Entries.size());
1062 for (auto const& it : rOther.m_Entries)
1063 {
1064 m_Entries.emplace_back(new ScColorScaleEntry(*it));
1065 }
1066}
1067
1069 ScColorFormat(pDoc),
1070 mpFormatData(new ScIconSetFormatData)
1071{
1072}
1073
1075 ScColorFormat(pDoc),
1076 mpFormatData(new ScIconSetFormatData(*rFormat.mpFormatData))
1077{
1078}
1079
1081{
1082 return new ScIconSetFormat(pDoc, *this);
1083}
1084
1086{
1087 for(iterator itr = begin(); itr != end(); ++itr)
1088 {
1089 (*itr)->SetRepaintCallback(pFormat);
1090 }
1091 ScColorFormat::SetParent(pFormat);
1092}
1093
1095{
1096 mpFormatData.reset( pFormatData );
1098}
1099
1101{
1102 return mpFormatData.get();
1103}
1104
1106{
1107 return mpFormatData.get();
1108}
1109
1110std::unique_ptr<ScIconSetInfo> ScIconSetFormat::GetIconSetInfo(const ScAddress& rAddr) const
1111{
1112 ScRefCellValue rCell(*mpDoc, rAddr);
1113 if(!rCell.hasNumeric())
1114 return nullptr;
1115
1116 // now we have for sure a value
1117 double nVal = rCell.getValue();
1118
1119 if (mpFormatData->m_Entries.size() < 2)
1120 return nullptr;
1121
1122 double nMin = GetMinValue();
1123 double nMax = GetMaxValue();
1124
1125 sal_Int32 nIndex = 0;
1126 const_iterator itr = begin();
1127 ++itr;
1128 double nValMax = CalcValue(nMin, nMax, itr);
1129
1130 ++itr;
1131 while(itr != end() && nVal >= nValMax)
1132 {
1133 ++nIndex;
1134 nValMax = CalcValue(nMin, nMax, itr);
1135 ++itr;
1136 }
1137
1138 if(nVal >= nValMax)
1139 ++nIndex;
1140
1141 std::unique_ptr<ScIconSetInfo> pInfo(new ScIconSetInfo);
1142
1143 const SfxPoolItem& rPoolItem = mpDoc->GetPattern(rAddr)->GetItem(ATTR_FONT_HEIGHT);
1144 tools::Long aFontHeight = static_cast<const SvxFontHeightItem&>(rPoolItem).GetHeight();
1145 pInfo->mnHeight = aFontHeight;
1146
1147 if(mpFormatData->mbReverse)
1148 {
1149 sal_Int32 nMaxIndex = mpFormatData->m_Entries.size() - 1;
1150 nIndex = nMaxIndex - nIndex;
1151 }
1152
1153 if (mpFormatData->mbCustom && sal_Int32(mpFormatData->maCustomVector.size()) > nIndex)
1154 {
1155 ScIconSetType eCustomType = mpFormatData->maCustomVector[nIndex].first;
1156 sal_Int32 nCustomIndex = mpFormatData->maCustomVector[nIndex].second;
1157 if (nCustomIndex == -1)
1158 {
1159 return nullptr;
1160 }
1161
1162 pInfo->eIconSetType = eCustomType;
1163 pInfo->nIconIndex = nCustomIndex;
1164 }
1165 else
1166 {
1167 pInfo->nIconIndex = nIndex;
1168 pInfo->eIconSetType = mpFormatData->eIconSetType;
1169 }
1170
1171 pInfo->mbShowValue = mpFormatData->mbShowValue;
1172 return pInfo;
1173}
1174
1176{
1177 return Type::Iconset;
1178}
1179
1181{
1182 for(iterator itr = begin(); itr != end(); ++itr)
1183 {
1184 (*itr)->UpdateReference(rCxt);
1185 }
1186}
1187
1189{
1190 for(iterator itr = begin(); itr != end(); ++itr)
1191 {
1192 (*itr)->UpdateInsertTab(rCxt);
1193 }
1194}
1195
1197{
1198 for(iterator itr = begin(); itr != end(); ++itr)
1199 {
1200 (*itr)->UpdateDeleteTab(rCxt);
1201 }
1202}
1203
1205{
1206 for(iterator itr = begin(); itr != end(); ++itr)
1207 {
1208 (*itr)->UpdateMoveTab(rCxt);
1209 }
1210}
1211
1213{
1214 return mpFormatData->m_Entries.begin();
1215}
1216
1218{
1219 return mpFormatData->m_Entries.begin();
1220}
1221
1223{
1224 return mpFormatData->m_Entries.end();
1225}
1226
1228{
1229 return mpFormatData->m_Entries.end();
1230}
1231
1233{
1234 const_iterator itr = begin();
1235
1236 if ((*itr)->GetType() == COLORSCALE_VALUE || (*itr)->GetType() == COLORSCALE_FORMULA)
1237 return (*itr)->GetValue();
1238 else
1239 {
1240 return getMinValue();
1241 }
1242}
1243
1245{
1246 auto const itr = mpFormatData->m_Entries.rbegin();
1247
1248 if ((*itr)->GetType() == COLORSCALE_VALUE || (*itr)->GetType() == COLORSCALE_FORMULA)
1249 return (*itr)->GetValue();
1250 else
1251 {
1252 return getMaxValue();
1253 }
1254}
1255
1256double ScIconSetFormat::CalcValue(double nMin, double nMax, const ScIconSetFormat::const_iterator& itr) const
1257{
1258 switch ((*itr)->GetType())
1259 {
1260 case COLORSCALE_PERCENT:
1261 return nMin + (nMax-nMin)*((*itr)->GetValue()/100);
1262 case COLORSCALE_MIN:
1263 return nMin;
1264 case COLORSCALE_MAX:
1265 return nMax;
1267 {
1268 std::vector<double>& rValues = getValues();
1269 if(rValues.size() == 1)
1270 return rValues[0];
1271 else
1272 {
1273 double fPercentile = (*itr)->GetValue()/100.0;
1274 return GetPercentile(rValues, fPercentile);
1275 }
1276 }
1277
1278 default:
1279 break;
1280 }
1281
1282 return (*itr)->GetValue();
1283}
1284
1286 { "3Arrows", IconSet_3Arrows, 3 },
1287 { "3ArrowsGray", IconSet_3ArrowsGray, 3 },
1288 { "3Flags", IconSet_3Flags, 3 },
1289 { "3TrafficLights1", IconSet_3TrafficLights1, 3 },
1290 { "3TrafficLights2", IconSet_3TrafficLights2, 3 },
1291 { "3Signs", IconSet_3Signs, 3 },
1292 { "3Symbols", IconSet_3Symbols, 3 },
1293 { "3Symbols2", IconSet_3Symbols2, 3 },
1294 { "3Smilies", IconSet_3Smilies, 3 },
1295 { "3ColorSmilies", IconSet_3ColorSmilies, 3 },
1296 { "3Stars", IconSet_3Stars, 3 },
1297 { "3Triangles", IconSet_3Triangles, 3 },
1298 { "4Arrows", IconSet_4Arrows, 4 },
1299 { "4ArrowsGray", IconSet_4ArrowsGray, 4 },
1300 { "4RedToBlack", IconSet_4RedToBlack, 4 },
1301 { "4Rating", IconSet_4Rating, 4 },
1302 { "4TrafficLights", IconSet_4TrafficLights, 4 },
1303 { "5Arrows", IconSet_5Arrows, 5 },
1304 { "5ArrowsGray", IconSet_5ArrowsGray, 5 },
1305 { "5Rating", IconSet_5Ratings, 5 },
1306 { "5Quarters", IconSet_5Quarters, 5 },
1307 { "5Boxes", IconSet_5Boxes, 5 },
1308 { nullptr, IconSet_3Arrows, 0 }
1309};
1310
1312{
1313 return mpFormatData->m_Entries.size();
1314}
1315
1316
1317namespace {
1318
1319constexpr rtl::OUStringConstExpr a3TrafficLights1[] = {
1320 BMP_ICON_SET_CIRCLES1_RED, BMP_ICON_SET_CIRCLES1_YELLOW, BMP_ICON_SET_CIRCLES1_GREEN
1321};
1322
1323constexpr rtl::OUStringConstExpr a3TrafficLights2[] = {
1324 BMP_ICON_SET_TRAFFICLIGHTS_RED, BMP_ICON_SET_TRAFFICLIGHTS_YELLOW, BMP_ICON_SET_TRAFFICLIGHTS_GREEN
1325};
1326
1327constexpr rtl::OUStringConstExpr a3Arrows[] = {
1328 BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SAME, BMP_ICON_SET_COLORARROWS_UP
1329};
1330
1331constexpr rtl::OUStringConstExpr a3ArrowsGray[] = {
1332 BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SAME, BMP_ICON_SET_GRAYARROWS_UP
1333};
1334
1335constexpr rtl::OUStringConstExpr a3Flags[] = {
1336 BMP_ICON_SET_FLAGS_RED, BMP_ICON_SET_FLAGS_YELLOW, BMP_ICON_SET_FLAGS_GREEN
1337};
1338
1339constexpr rtl::OUStringConstExpr a3Smilies[] = {
1340 BMP_ICON_SET_POSITIVE_YELLOW_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_NEGATIVE_YELLOW_SMILIE
1341};
1342
1343constexpr rtl::OUStringConstExpr a3ColorSmilies[] = {
1344 BMP_ICON_SET_POSITIVE_GREEN_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_NEGATIVE_RED_SMILIE
1345};
1346
1347constexpr rtl::OUStringConstExpr a3Stars[] = {
1348 BMP_ICON_SET_STARS_EMPTY, BMP_ICON_SET_STARS_HALF, BMP_ICON_SET_STARS_FULL
1349};
1350
1351constexpr rtl::OUStringConstExpr a3Triangles[] = {
1352 BMP_ICON_SET_TRIANGLES_DOWN, BMP_ICON_SET_TRIANGLES_SAME, BMP_ICON_SET_TRIANGLES_UP
1353};
1354
1355constexpr rtl::OUStringConstExpr a4Arrows[] = {
1356 BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP, BMP_ICON_SET_COLORARROWS_UP
1357};
1358
1359constexpr rtl::OUStringConstExpr a4ArrowsGray[] = {
1360 BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP, BMP_ICON_SET_GRAYARROWS_UP
1361};
1362
1363constexpr rtl::OUStringConstExpr a5Arrows[] = {
1364 BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN,
1365 BMP_ICON_SET_COLORARROWS_SAME, BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP, BMP_ICON_SET_COLORARROWS_UP
1366};
1367
1368constexpr rtl::OUStringConstExpr a5ArrowsGray[] = {
1369 BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN,
1370 BMP_ICON_SET_GRAYARROWS_SAME, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP, BMP_ICON_SET_GRAYARROWS_UP
1371};
1372
1373constexpr rtl::OUStringConstExpr a4TrafficLights[] = {
1374 BMP_ICON_SET_CIRCLES1_GRAY, BMP_ICON_SET_CIRCLES1_RED,
1375 BMP_ICON_SET_CIRCLES1_YELLOW, BMP_ICON_SET_CIRCLES1_GREEN
1376};
1377
1378constexpr rtl::OUStringConstExpr a5Quarters[] = {
1379 BMP_ICON_SET_PIES_EMPTY, BMP_ICON_SET_PIES_ONE_QUARTER, BMP_ICON_SET_PIES_HALF,
1380 BMP_ICON_SET_PIES_THREE_QUARTER, BMP_ICON_SET_PIES_FULL,
1381};
1382
1383constexpr rtl::OUStringConstExpr a5Boxes[] = {
1384 BMP_ICON_SET_SQUARES_EMPTY, BMP_ICON_SET_SQUARES_ONE_QUARTER,
1385 BMP_ICON_SET_SQUARES_HALF, BMP_ICON_SET_SQUARES_THREE_QUARTER,
1386 BMP_ICON_SET_SQUARES_FULL
1387};
1388
1389constexpr rtl::OUStringConstExpr a3Symbols1[] = {
1390 BMP_ICON_SET_SYMBOLS1_CROSS, BMP_ICON_SET_SYMBOLS1_EXCLAMATION_MARK, BMP_ICON_SET_SYMBOLS1_CHECK
1391};
1392
1393constexpr rtl::OUStringConstExpr a3Signs[] = {
1394 BMP_ICON_SET_SHAPES_DIAMOND, BMP_ICON_SET_SHAPES_TRIANGLE, BMP_ICON_SET_SHAPES_CIRCLE
1395};
1396
1397constexpr rtl::OUStringConstExpr a4RedToBlack[] = {
1398 BMP_ICON_SET_CIRCLES2_DARK_GRAY, BMP_ICON_SET_CIRCLES2_LIGHT_GRAY,
1399 BMP_ICON_SET_CIRCLES2_LIGHT_RED, BMP_ICON_SET_CIRCLES2_DARK_RED
1400};
1401
1402constexpr rtl::OUStringConstExpr a4Ratings[] = {
1403 BMP_ICON_SET_BARS_ONE_QUARTER, BMP_ICON_SET_BARS_HALF,
1404 BMP_ICON_SET_BARS_THREE_QUARTER, BMP_ICON_SET_BARS_FULL
1405};
1406
1407constexpr rtl::OUStringConstExpr a5Ratings[] = {
1408 BMP_ICON_SET_BARS_EMPTY, BMP_ICON_SET_BARS_ONE_QUARTER, BMP_ICON_SET_BARS_HALF,
1409 BMP_ICON_SET_BARS_THREE_QUARTER, BMP_ICON_SET_BARS_FULL
1410};
1411
1412struct ScIconSetBitmapMap {
1414 const rtl::OUStringConstExpr* pBitmaps;
1415};
1416
1417const ScIconSetBitmapMap aBitmapMap[] = {
1418 { IconSet_3Arrows, a3Arrows },
1419 { IconSet_3ArrowsGray, a3ArrowsGray },
1420 { IconSet_3Flags, a3Flags },
1421 { IconSet_3Signs, a3Signs },
1422 { IconSet_3Symbols, a3Symbols1 },
1423 { IconSet_3Symbols2, a3Symbols1 },
1424 { IconSet_3TrafficLights1, a3TrafficLights1 },
1425 { IconSet_3TrafficLights2, a3TrafficLights2 },
1426 { IconSet_3Smilies, a3Smilies },
1427 { IconSet_3ColorSmilies, a3ColorSmilies },
1428 { IconSet_3Triangles, a3Triangles },
1429 { IconSet_3Stars, a3Stars },
1430 { IconSet_4Arrows, a4Arrows },
1431 { IconSet_4ArrowsGray, a4ArrowsGray },
1432 { IconSet_4Rating, a4Ratings },
1433 { IconSet_4RedToBlack, a4RedToBlack },
1434 { IconSet_4TrafficLights, a4TrafficLights },
1435 { IconSet_5Arrows, a5Arrows },
1436 { IconSet_5ArrowsGray, a5ArrowsGray },
1437 { IconSet_5Quarters, a5Quarters },
1438 { IconSet_5Ratings, a5Ratings },
1439 { IconSet_5Boxes, a5Boxes }
1440};
1441
1442const ScIconSetMap* findIconSetType(ScIconSetType eType)
1443{
1445 for (; pMap->pName; ++pMap)
1446 {
1447 if (pMap->eType == eType)
1448 return pMap;
1449 }
1450
1451 return nullptr;
1452}
1453
1454}
1455
1457{
1458 const ScIconSetMap* pMap = findIconSetType(eType);
1459 if (pMap)
1460 return pMap->pName;
1461
1462 return "";
1463}
1464
1466{
1467 const ScIconSetMap* pMap = findIconSetType(eType);
1468 if (pMap)
1469 return pMap->nElements;
1470
1471 return 0;
1472}
1473
1474OUString ScIconSetFormat::getIconName(ScIconSetType const eType, sal_Int32 const nIndex)
1475{
1476 OUString sBitmap;
1477
1478 for(const ScIconSetBitmapMap & i : aBitmapMap)
1479 {
1480 if(i.eType == eType)
1481 {
1482 sBitmap = *(i.pBitmaps + nIndex);
1483 break;
1484 }
1485 }
1486
1487 assert(!sBitmap.isEmpty());
1488
1489 return sBitmap;
1490}
1491
1493 ScIconSetType const eType, sal_Int32 const nIndex)
1494{
1495 OUString sBitmap(ScIconSetFormat::getIconName(eType, nIndex));
1496
1497 std::map<OUString, BitmapEx>::iterator itr = rIconSetBitmapMap.find(sBitmap);
1498 if (itr != rIconSetBitmapMap.end())
1499 return itr->second;
1500
1501 BitmapEx aBitmap(sBitmap);
1502 std::pair<OUString, BitmapEx> aPair(sBitmap, aBitmap);
1503 std::pair<std::map<OUString, BitmapEx>::iterator, bool> itrNew = rIconSetBitmapMap.insert(aPair);
1504 assert(itrNew.second);
1505
1506 return itrNew.first->second;
1507}
1508
1510{
1511 ScIconSetType eType = mpFormatData->eIconSetType;
1512 for (const ScIconSetMap & i : g_IconSetMap)
1513 {
1514 if (i.eType == eType)
1515 {
1516 // size_t nElements = aIconSetMap[i].nElements;
1517 // TODO: implement
1518 break;
1519 }
1520 }
1521}
1522
1523/* 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:703
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:691
virtual ~ScColorScaleFormat() override
Definition: colorscale.cxx:391
virtual void UpdateInsertTab(sc::RefUpdateInsertTabContext &rCxt) override
Definition: colorscale.cxx:685
ScColorScaleEntries::iterator begin()
Definition: colorscale.cxx:708
double CalcValue(double nMin, double nMax, const ScColorScaleEntries::const_iterator &rItr) const
Definition: colorscale.cxx:604
ScColorScaleEntry * GetEntry(size_t nPos)
Definition: colorscale.cxx:728
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:718
ScColorScaleEntries maColorScales
Definition: colorscale.hxx:258
size_t size() const
Definition: colorscale.cxx:744
virtual void UpdateReference(sc::RefUpdateContext &rCxt) override
Definition: colorscale.cxx:679
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:697
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:749
const ScRangeList & GetRange() const
Definition: conditio.hxx:559
ScDocument * GetDocument()
Definition: conditio.cxx:1793
std::unique_ptr< ScDataBarInfo > GetDataBarInfo(const ScAddress &rAddr) const
Definition: colorscale.cxx:919
virtual void UpdateReference(sc::RefUpdateContext &rCxt) override
Definition: colorscale.cxx:844
void EnsureSize()
Makes sure that the mpFormatData does not contain valid entries.
bool IsEqual(const ScFormatEntry &r, bool bIgnoreSrcPos) const override
Definition: colorscale.cxx:809
virtual void UpdateInsertTab(sc::RefUpdateInsertTabContext &rCxt) override
Definition: colorscale.cxx:850
virtual Type GetType() const override
Definition: colorscale.cxx:804
virtual void UpdateMoveTab(sc::RefUpdateMoveTabContext &rCxt) override
Definition: colorscale.cxx:862
void SetDataBarData(ScDataBarFormatData *pData)
Definition: colorscale.cxx:769
virtual void SetParent(ScConditionalFormat *pParent) override
Definition: colorscale.cxx:794
double getMin(double nMin, double nMax) const
Definition: colorscale.cxx:868
virtual ScColorFormat * Clone(ScDocument *pDoc) const override
Definition: colorscale.cxx:789
virtual void UpdateDeleteTab(sc::RefUpdateDeleteTabContext &rCxt) override
Definition: colorscale.cxx:856
std::unique_ptr< ScDataBarFormatData > mpFormatData
Definition: colorscale.hxx:335
ScDataBarFormat(ScDocument *pDoc)
Definition: colorscale.cxx:757
double getMax(double nMin, double nMax) const
Definition: colorscale.cxx:895
const ScDataBarFormatData * GetDataBarData() const
Definition: colorscale.cxx:784
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:1049
void StartListeningArea(const ScRange &rRange, bool bGroupListening, SvtListener *pListener)
Definition: documen7.cxx:35
bool IsClipOrUndo() const
Definition: document.hxx:1592
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4719
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:73
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