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 
48 void ScFormulaListener::startListening(const ScTokenArray* pArr, const ScRange& rRange)
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 
113 void ScFormulaListener::addTokenArray(const ScTokenArray* pArray, const ScRange& rRange)
114 {
115  startListening(pArray, rRange);
116 }
117 
118 void ScFormulaListener::setCallback(const std::function<void()>& aCallback)
119 {
120  maCallbackFunction = aCallback;
121 }
122 
124 {
125  if (mrDoc.IsClipOrUndo())
126  return;
127 
128  EndListeningAll();
129 }
130 
132 {
133  stopListening();
134 }
135 
137 {
138  mbDirty = true;
139 
140  if (rHint.GetId() == SfxHintId::Dying)
141  return;
142 
143  if (maCallbackFunction)
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),
165  meType(eType)
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, rEntry.mpCell->GetDocument(), 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 
201 ScColorScaleEntry::~ScColorScaleEntry() COVERITY_NOEXCEPT_FALSE
202 {
203  if(mpCell)
204  mpCell->EndListeningTo(mpCell->GetDocument());
205 }
206 
207 void 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 
250 void ScColorScaleEntry::SetValue(double nValue)
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;
326  if(eType != COLORSCALE_FORMULA)
327  {
328  mpCell.reset();
329  mpListener.reset();
330  }
331 
332  setListener();
333 }
334 
336 {
337  if (!mpFormat)
338  return;
339 
342  || meType == COLORSCALE_AUTO)
343  {
345  mpListener->setCallback([&]() { mpFormat->DoRepaint();});
346  }
347 }
348 
349 void 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  }
398  ScColorFormat::SetParent(pFormat);
399 }
400 
402 {
403  maColorScales.push_back(std::unique_ptr<ScColorScaleEntry, o3tl::default_delete<ScColorScaleEntry>>(pEntry));
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 
431 void ScColorScaleFormat::calcMinMax(double& rMin, double& rMax) const
432 {
433  rMin = GetMinValue();
434  rMax = GetMaxValue();
435 }
436 
438 {
439  return mpParent->GetRange();
440 }
441 
442 std::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 
514 namespace {
515 
516 sal_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 
528 Color 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 
541 double GetPercentile( const std::vector<double>& rArray, double fPercentile )
542 {
543  size_t nSize = rArray.size();
544  size_t nIndex = static_cast<size_t>(::rtl::math::approxFloor( fPercentile * (nSize-1)));
545  double fDiff = fPercentile * (nSize-1) - ::rtl::math::approxFloor( fPercentile * (nSize-1));
546  std::vector<double>::const_iterator iter = rArray.begin() + nIndex;
547  if (fDiff == 0.0)
548  return *iter;
549  else
550  {
551  double fVal = *iter;
552  iter = rArray.begin() + nIndex+1;
553  return fVal + fDiff * (*iter - fVal);
554  }
555 }
556 
557 }
558 
559 double ScColorScaleFormat::CalcValue(double nMin, double nMax, const ScColorScaleEntries::const_iterator& itr) const
560 {
561  switch((*itr)->GetType())
562  {
563  case COLORSCALE_PERCENT:
564  return nMin + (nMax-nMin)*((*itr)->GetValue()/100);
565  case COLORSCALE_MIN:
566  return nMin;
567  case COLORSCALE_MAX:
568  return nMax;
570  {
571  std::vector<double>& rValues = getValues();
572  if(rValues.size() == 1)
573  return rValues[0];
574  else
575  {
576  double fPercentile = (*itr)->GetValue()/100.0;
577  return GetPercentile(rValues, fPercentile);
578  }
579  }
580 
581  default:
582  break;
583  }
584 
585  return (*itr)->GetValue();
586 }
587 
588 std::optional<Color> ScColorScaleFormat::GetColor( const ScAddress& rAddr ) const
589 {
590  ScRefCellValue rCell(*mpDoc, rAddr);
591  if(!rCell.hasNumeric())
592  return std::optional<Color>();
593 
594  // now we have for sure a value
595  double nVal = rCell.getValue();
596 
597  if (maColorScales.size() < 2)
598  return std::optional<Color>();
599 
600  double nMin = std::numeric_limits<double>::max();
601  double nMax = std::numeric_limits<double>::min();
602  calcMinMax(nMin, nMax);
603 
604  // this check is for safety
605  if(nMin >= nMax)
606  return std::optional<Color>();
607 
608  ScColorScaleEntries::const_iterator itr = begin();
609  double nValMin = CalcValue(nMin, nMax, itr);
610  Color rColMin = (*itr)->GetColor();
611  ++itr;
612  double nValMax = CalcValue(nMin, nMax, itr);
613  Color rColMax = (*itr)->GetColor();
614 
615  ++itr;
616  while(itr != end() && nVal > nValMax)
617  {
618  rColMin = rColMax;
619  nValMin = nValMax;
620  rColMax = (*itr)->GetColor();
621  nValMax = CalcValue(nMin, nMax, itr);
622  ++itr;
623  }
624 
625  Color aColor = CalcColor(nVal, nValMin, rColMin, nValMax, rColMax);
626 
627  return aColor;
628 }
629 
631 {
632  for(ScColorScaleEntries::iterator itr = begin(); itr != end(); ++itr)
633  (*itr)->UpdateReference(rCxt);
634 }
635 
637 {
638  for (ScColorScaleEntries::iterator it = begin(); it != end(); ++it)
639  (*it)->UpdateInsertTab(rCxt);
640 }
641 
643 {
644  for (ScColorScaleEntries::iterator it = begin(); it != end(); ++it)
645  (*it)->UpdateDeleteTab(rCxt);
646 }
647 
649 {
650  for (ScColorScaleEntries::iterator it = begin(); it != end(); ++it)
651  (*it)->UpdateMoveTab(rCxt);
652 }
653 
655 {
656  return Type::Colorscale;
657 }
658 
659 ScColorScaleEntries::iterator ScColorScaleFormat::begin()
660 {
661  return maColorScales.begin();
662 }
663 
664 ScColorScaleEntries::const_iterator ScColorScaleFormat::begin() const
665 {
666  return maColorScales.begin();
667 }
668 
669 ScColorScaleEntries::iterator ScColorScaleFormat::end()
670 {
671  return maColorScales.end();
672 }
673 
674 ScColorScaleEntries::const_iterator ScColorScaleFormat::end() const
675 {
676  return maColorScales.end();
677 }
678 
680 {
681  if (maColorScales.size() <= nPos)
682  return nullptr;
683 
684  return maColorScales[nPos].get();
685 }
686 
688 {
689  if (maColorScales.size() <= nPos)
690  return nullptr;
691 
692  return maColorScales[nPos].get();
693 }
694 
696 {
697  return maColorScales.size();
698 }
699 
701 {
702  if (maColorScales.size() < 2)
703  {
704  // TODO: create 2 valid entries
705  }
706 }
707 
709  ScColorFormat(pDoc),
710  mpFormatData(new ScDataBarFormatData())
711 {
712 }
713 
715  ScColorFormat(pDoc),
716  mpFormatData(new ScDataBarFormatData(*rFormat.mpFormatData))
717 {
718 }
719 
721 {
722  mpFormatData.reset(pData);
723  if (mpParent)
724  {
725  mpFormatData->mpUpperLimit->SetRepaintCallback(mpParent);
726  mpFormatData->mpLowerLimit->SetRepaintCallback(mpParent);
727  }
728 }
729 
731 {
732  return mpFormatData.get();
733 }
734 
736 {
737  return mpFormatData.get();
738 }
739 
741 {
742  return new ScDataBarFormat(pDoc, *this);
743 }
744 
746 {
747  if (mpFormatData)
748  {
749  mpFormatData->mpUpperLimit->SetRepaintCallback(pFormat);
750  mpFormatData->mpLowerLimit->SetRepaintCallback(pFormat);
751  }
752  ScColorFormat::SetParent(pFormat);
753 }
754 
756 {
757  return Type::Databar;
758 }
759 
761 {
762  mpFormatData->mpUpperLimit->UpdateReference(rCxt);
763  mpFormatData->mpLowerLimit->UpdateReference(rCxt);
764 }
765 
767 {
768  mpFormatData->mpUpperLimit->UpdateInsertTab(rCxt);
769  mpFormatData->mpLowerLimit->UpdateInsertTab(rCxt);
770 }
771 
773 {
774  mpFormatData->mpUpperLimit->UpdateDeleteTab(rCxt);
775  mpFormatData->mpLowerLimit->UpdateDeleteTab(rCxt);
776 }
777 
779 {
780  mpFormatData->mpUpperLimit->UpdateMoveTab(rCxt);
781  mpFormatData->mpLowerLimit->UpdateMoveTab(rCxt);
782 }
783 
784 double ScDataBarFormat::getMin(double nMin, double nMax) const
785 {
786  switch(mpFormatData->mpLowerLimit->GetType())
787  {
788  case COLORSCALE_MIN:
789  return nMin;
790 
791  case COLORSCALE_AUTO:
792  return std::min<double>(0, nMin);
793 
794  case COLORSCALE_PERCENT:
795  return nMin + (nMax-nMin)/100*mpFormatData->mpLowerLimit->GetValue();
796 
798  {
799  double fPercentile = mpFormatData->mpLowerLimit->GetValue()/100.0;
800  std::vector<double>& rValues = getValues();
801  return GetPercentile(rValues, fPercentile);
802  }
803 
804  default:
805  break;
806  }
807 
808  return mpFormatData->mpLowerLimit->GetValue();
809 }
810 
811 double ScDataBarFormat::getMax(double nMin, double nMax) const
812 {
813  switch(mpFormatData->mpUpperLimit->GetType())
814  {
815  case COLORSCALE_MAX:
816  return nMax;
817  case COLORSCALE_AUTO:
818  return std::max<double>(0, nMax);
819  case COLORSCALE_PERCENT:
820  return nMin + (nMax-nMin)/100*mpFormatData->mpUpperLimit->GetValue();
822  {
823  double fPercentile = mpFormatData->mpUpperLimit->GetValue()/100.0;
824  std::vector<double>& rValues = getValues();
825  return GetPercentile(rValues, fPercentile);
826  }
827 
828  default:
829  break;
830  }
831 
832  return mpFormatData->mpUpperLimit->GetValue();
833 }
834 
835 std::unique_ptr<ScDataBarInfo> ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const
836 {
837  ScRefCellValue rCell(*mpDoc, rAddr);
838  if(!rCell.hasNumeric())
839  return nullptr;
840 
841  // now we have for sure a value
842 
843  double nValMin = getMinValue();
844  double nValMax = getMaxValue();
845  double nMin = getMin(nValMin, nValMax);
846  double nMax = getMax(nValMin, nValMax);
847  double nMinLength = mpFormatData->mnMinLength;
848  double nMaxLength = mpFormatData->mnMaxLength;
849 
850  double nValue = rCell.getValue();
851 
852  std::unique_ptr<ScDataBarInfo> pInfo(new ScDataBarInfo);
853  if(mpFormatData->meAxisPosition == databar::NONE)
854  {
855  if(nValue <= nMin)
856  {
857  pInfo->mnLength = nMinLength;
858  }
859  else if(nValue >= nMax)
860  {
861  pInfo->mnLength = nMaxLength;
862  }
863  else
864  {
865  double nDiff = nMax - nMin;
866  pInfo->mnLength = nMinLength + (nValue - nMin)/nDiff * (nMaxLength-nMinLength);
867  }
868  pInfo->mnZero = 0;
869  }
870  else if (mpFormatData->meAxisPosition == databar::AUTOMATIC)
871  {
872  // if auto is used we may need to adjust it
873  // for the length calculation
874  if (mpFormatData->mpLowerLimit->GetType() == COLORSCALE_AUTO && nMin > 0)
875  nMin = 0;
876  if (mpFormatData->mpUpperLimit->GetType() == COLORSCALE_MAX && nMax < 0)
877  nMax = 0;
878 
879  //calculate the zero position first
880  if(nMin < 0)
881  {
882  if(nMax < 0)
883  pInfo->mnZero = 100;
884  else
885  {
886  pInfo->mnZero = -100*nMin/(nMax-nMin);
887  }
888  }
889  else
890  pInfo->mnZero = 0;
891 
892  double nMinNonNegative = std::max(0.0, nMin);
893  double nMaxNonPositive = std::min(0.0, nMax);
894  //calculate the length
895  if(nValue < 0 && nMin < 0)
896  {
897  if (nValue < nMin)
898  pInfo->mnLength = -100;
899  else
900  pInfo->mnLength = -100 * (nValue-nMaxNonPositive)/(nMin-nMaxNonPositive);
901  }
902  else
903  {
904  if ( nValue > nMax )
905  pInfo->mnLength = 100;
906  else if (nValue <= nMin)
907  pInfo->mnLength = 0;
908  else
909  pInfo->mnLength = 100 * (nValue-nMinNonNegative)/(nMax-nMinNonNegative);
910  }
911  }
912  else if( mpFormatData->meAxisPosition == databar::MIDDLE)
913  {
914  pInfo->mnZero = 50;
915  double nAbsMax = std::max(std::abs(nMin), std::abs(nMax));
916  if (nValue < 0 && nMin < 0)
917  {
918  if (nValue < nMin)
919  pInfo->mnLength = nMaxLength * (nMin/nAbsMax);
920  else
921  pInfo->mnLength = nMaxLength * (nValue/nAbsMax);
922  }
923  else
924  {
925  if (nValue > nMax)
926  pInfo->mnLength = nMaxLength * (nMax/nAbsMax);
927  else
928  pInfo->mnLength = nMaxLength * (std::max(nValue, nMin)/nAbsMax);
929  }
930  }
931  else
932  assert(false);
933 
934  // set color
935  if(mpFormatData->mbNeg && nValue < 0)
936  {
937  if(mpFormatData->mxNegativeColor)
938  {
939  pInfo->maColor = *mpFormatData->mxNegativeColor;
940  }
941  else
942  {
943  // default negative color is red
944  pInfo->maColor = COL_LIGHTRED;
945  }
946 
947  }
948  else
949  pInfo->maColor = mpFormatData->maPositiveColor;
950 
951  pInfo->mbGradient = mpFormatData->mbGradient;
952  pInfo->mbShowValue = !mpFormatData->mbOnlyBar;
953  pInfo->maAxisColor = mpFormatData->maAxisColor;
954 
955  return pInfo;
956 }
957 
959 {
960  if (!mpFormatData->mpLowerLimit)
961  {
962  // TODO: implement
963  }
964  if (!mpFormatData->mpUpperLimit)
965  {
966  // TODO: implement
967  }
968 }
969 
971  : eIconSetType(rOther.eIconSetType)
972  , mbShowValue(rOther.mbShowValue)
973  , mbReverse(rOther.mbReverse)
974  , mbCustom(rOther.mbCustom)
975  , maCustomVector(rOther.maCustomVector)
976 {
977  m_Entries.reserve(rOther.m_Entries.size());
978  for (auto const& it : rOther.m_Entries)
979  {
980  m_Entries.emplace_back(new ScColorScaleEntry(*it));
981  }
982 }
983 
985  ScColorFormat(pDoc),
986  mpFormatData(new ScIconSetFormatData)
987 {
988 }
989 
991  ScColorFormat(pDoc),
992  mpFormatData(new ScIconSetFormatData(*rFormat.mpFormatData))
993 {
994 }
995 
997 {
998  return new ScIconSetFormat(pDoc, *this);
999 }
1000 
1002 {
1003  for(iterator itr = begin(); itr != end(); ++itr)
1004  {
1005  (*itr)->SetRepaintCallback(pFormat);
1006  }
1007  ScColorFormat::SetParent(pFormat);
1008 }
1009 
1011 {
1012  mpFormatData.reset( pFormatData );
1014 }
1015 
1017 {
1018  return mpFormatData.get();
1019 }
1020 
1022 {
1023  return mpFormatData.get();
1024 }
1025 
1026 std::unique_ptr<ScIconSetInfo> ScIconSetFormat::GetIconSetInfo(const ScAddress& rAddr) const
1027 {
1028  ScRefCellValue rCell(*mpDoc, rAddr);
1029  if(!rCell.hasNumeric())
1030  return nullptr;
1031 
1032  // now we have for sure a value
1033  double nVal = rCell.getValue();
1034 
1035  if (mpFormatData->m_Entries.size() < 2)
1036  return nullptr;
1037 
1038  double nMin = GetMinValue();
1039  double nMax = GetMaxValue();
1040 
1041  sal_Int32 nIndex = 0;
1042  const_iterator itr = begin();
1043  ++itr;
1044  double nValMax = CalcValue(nMin, nMax, itr);
1045 
1046  ++itr;
1047  while(itr != end() && nVal >= nValMax)
1048  {
1049  ++nIndex;
1050  nValMax = CalcValue(nMin, nMax, itr);
1051  ++itr;
1052  }
1053 
1054  if(nVal >= nValMax)
1055  ++nIndex;
1056 
1057  std::unique_ptr<ScIconSetInfo> pInfo(new ScIconSetInfo);
1058 
1059  const SfxPoolItem& rPoolItem = mpDoc->GetPattern(rAddr)->GetItem(ATTR_FONT_HEIGHT);
1060  tools::Long aFontHeight = static_cast<const SvxFontHeightItem&>(rPoolItem).GetHeight();
1061  pInfo->mnHeight = aFontHeight;
1062 
1063  if(mpFormatData->mbReverse)
1064  {
1065  sal_Int32 nMaxIndex = mpFormatData->m_Entries.size() - 1;
1066  nIndex = nMaxIndex - nIndex;
1067  }
1068 
1069  if (mpFormatData->mbCustom && sal_Int32(mpFormatData->maCustomVector.size()) > nIndex)
1070  {
1071  ScIconSetType eCustomType = mpFormatData->maCustomVector[nIndex].first;
1072  sal_Int32 nCustomIndex = mpFormatData->maCustomVector[nIndex].second;
1073  if (nCustomIndex == -1)
1074  {
1075  return nullptr;
1076  }
1077 
1078  pInfo->eIconSetType = eCustomType;
1079  pInfo->nIconIndex = nCustomIndex;
1080  }
1081  else
1082  {
1083  pInfo->nIconIndex = nIndex;
1084  pInfo->eIconSetType = mpFormatData->eIconSetType;
1085  }
1086 
1087  pInfo->mbShowValue = mpFormatData->mbShowValue;
1088  return pInfo;
1089 }
1090 
1092 {
1093  return Type::Iconset;
1094 }
1095 
1097 {
1098  for(iterator itr = begin(); itr != end(); ++itr)
1099  {
1100  (*itr)->UpdateReference(rCxt);
1101  }
1102 }
1103 
1105 {
1106  for(iterator itr = begin(); itr != end(); ++itr)
1107  {
1108  (*itr)->UpdateInsertTab(rCxt);
1109  }
1110 }
1111 
1113 {
1114  for(iterator itr = begin(); itr != end(); ++itr)
1115  {
1116  (*itr)->UpdateDeleteTab(rCxt);
1117  }
1118 }
1119 
1121 {
1122  for(iterator itr = begin(); itr != end(); ++itr)
1123  {
1124  (*itr)->UpdateMoveTab(rCxt);
1125  }
1126 }
1127 
1129 {
1130  return mpFormatData->m_Entries.begin();
1131 }
1132 
1134 {
1135  return mpFormatData->m_Entries.begin();
1136 }
1137 
1139 {
1140  return mpFormatData->m_Entries.end();
1141 }
1142 
1144 {
1145  return mpFormatData->m_Entries.end();
1146 }
1147 
1149 {
1150  const_iterator itr = begin();
1151 
1152  if ((*itr)->GetType() == COLORSCALE_VALUE || (*itr)->GetType() == COLORSCALE_FORMULA)
1153  return (*itr)->GetValue();
1154  else
1155  {
1156  return getMinValue();
1157  }
1158 }
1159 
1161 {
1162  auto const itr = mpFormatData->m_Entries.rbegin();
1163 
1164  if ((*itr)->GetType() == COLORSCALE_VALUE || (*itr)->GetType() == COLORSCALE_FORMULA)
1165  return (*itr)->GetValue();
1166  else
1167  {
1168  return getMaxValue();
1169  }
1170 }
1171 
1172 double ScIconSetFormat::CalcValue(double nMin, double nMax, const ScIconSetFormat::const_iterator& itr) const
1173 {
1174  switch ((*itr)->GetType())
1175  {
1176  case COLORSCALE_PERCENT:
1177  return nMin + (nMax-nMin)*((*itr)->GetValue()/100);
1178  case COLORSCALE_MIN:
1179  return nMin;
1180  case COLORSCALE_MAX:
1181  return nMax;
1182  case COLORSCALE_PERCENTILE:
1183  {
1184  std::vector<double>& rValues = getValues();
1185  if(rValues.size() == 1)
1186  return rValues[0];
1187  else
1188  {
1189  double fPercentile = (*itr)->GetValue()/100.0;
1190  return GetPercentile(rValues, fPercentile);
1191  }
1192  }
1193 
1194  default:
1195  break;
1196  }
1197 
1198  return (*itr)->GetValue();
1199 }
1200 
1202  { "3Arrows", IconSet_3Arrows, 3 },
1203  { "3ArrowsGray", IconSet_3ArrowsGray, 3 },
1204  { "3Flags", IconSet_3Flags, 3 },
1205  { "3TrafficLights1", IconSet_3TrafficLights1, 3 },
1206  { "3TrafficLights2", IconSet_3TrafficLights2, 3 },
1207  { "3Signs", IconSet_3Signs, 3 },
1208  { "3Symbols", IconSet_3Symbols, 3 },
1209  { "3Symbols2", IconSet_3Symbols2, 3 },
1210  { "3Smilies", IconSet_3Smilies, 3 },
1211  { "3ColorSmilies", IconSet_3ColorSmilies, 3 },
1212  { "3Stars", IconSet_3Stars, 3 },
1213  { "3Triangles", IconSet_3Triangles, 3 },
1214  { "4Arrows", IconSet_4Arrows, 4 },
1215  { "4ArrowsGray", IconSet_4ArrowsGray, 4 },
1216  { "4RedToBlack", IconSet_4RedToBlack, 4 },
1217  { "4Rating", IconSet_4Rating, 4 },
1218  { "4TrafficLights", IconSet_4TrafficLights, 4 },
1219  { "5Arrows", IconSet_5Arrows, 5 },
1220  { "5ArrowsGray", IconSet_5ArrowsGray, 5 },
1221  { "5Rating", IconSet_5Ratings, 5 },
1222  { "5Quarters", IconSet_5Quarters, 5 },
1223  { "5Boxes", IconSet_5Boxes, 5 },
1224  { nullptr, IconSet_3Arrows, 0 }
1225 };
1226 
1228 {
1229  return mpFormatData->m_Entries.size();
1230 }
1231 
1232 
1233 namespace {
1234 
1235 constexpr rtl::OUStringConstExpr a3TrafficLights1[] = {
1236  BMP_ICON_SET_CIRCLES1_RED, BMP_ICON_SET_CIRCLES1_YELLOW, BMP_ICON_SET_CIRCLES1_GREEN
1237 };
1238 
1239 constexpr rtl::OUStringConstExpr a3TrafficLights2[] = {
1240  BMP_ICON_SET_TRAFFICLIGHTS_RED, BMP_ICON_SET_TRAFFICLIGHTS_YELLOW, BMP_ICON_SET_TRAFFICLIGHTS_GREEN
1241 };
1242 
1243 constexpr rtl::OUStringConstExpr a3Arrows[] = {
1244  BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SAME, BMP_ICON_SET_COLORARROWS_UP
1245 };
1246 
1247 constexpr rtl::OUStringConstExpr a3ArrowsGray[] = {
1248  BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SAME, BMP_ICON_SET_GRAYARROWS_UP
1249 };
1250 
1251 constexpr rtl::OUStringConstExpr a3Flags[] = {
1252  BMP_ICON_SET_FLAGS_RED, BMP_ICON_SET_FLAGS_YELLOW, BMP_ICON_SET_FLAGS_GREEN
1253 };
1254 
1255 constexpr rtl::OUStringConstExpr a3Smilies[] = {
1256  BMP_ICON_SET_POSITIVE_YELLOW_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_NEGATIVE_YELLOW_SMILIE
1257 };
1258 
1259 constexpr rtl::OUStringConstExpr a3ColorSmilies[] = {
1260  BMP_ICON_SET_POSITIVE_GREEN_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_NEGATIVE_RED_SMILIE
1261 };
1262 
1263 constexpr rtl::OUStringConstExpr a3Stars[] = {
1264  BMP_ICON_SET_STARS_EMPTY, BMP_ICON_SET_STARS_HALF, BMP_ICON_SET_STARS_FULL
1265 };
1266 
1267 constexpr rtl::OUStringConstExpr a3Triangles[] = {
1268  BMP_ICON_SET_TRIANGLES_DOWN, BMP_ICON_SET_TRIANGLES_SAME, BMP_ICON_SET_TRIANGLES_UP
1269 };
1270 
1271 constexpr rtl::OUStringConstExpr a4Arrows[] = {
1272  BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP, BMP_ICON_SET_COLORARROWS_UP
1273 };
1274 
1275 constexpr rtl::OUStringConstExpr a4ArrowsGray[] = {
1276  BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP, BMP_ICON_SET_GRAYARROWS_UP
1277 };
1278 
1279 constexpr rtl::OUStringConstExpr a5Arrows[] = {
1280  BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN,
1281  BMP_ICON_SET_COLORARROWS_SAME, BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP, BMP_ICON_SET_COLORARROWS_UP
1282 };
1283 
1284 constexpr rtl::OUStringConstExpr a5ArrowsGray[] = {
1285  BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN,
1286  BMP_ICON_SET_GRAYARROWS_SAME, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP, BMP_ICON_SET_GRAYARROWS_UP
1287 };
1288 
1289 constexpr rtl::OUStringConstExpr a4TrafficLights[] = {
1290  BMP_ICON_SET_CIRCLES1_GRAY, BMP_ICON_SET_CIRCLES1_RED,
1291  BMP_ICON_SET_CIRCLES1_YELLOW, BMP_ICON_SET_CIRCLES1_GREEN
1292 };
1293 
1294 constexpr rtl::OUStringConstExpr a5Quarters[] = {
1295  BMP_ICON_SET_PIES_EMPTY, BMP_ICON_SET_PIES_ONE_QUARTER, BMP_ICON_SET_PIES_HALF,
1296  BMP_ICON_SET_PIES_THREE_QUARTER, BMP_ICON_SET_PIES_FULL,
1297 };
1298 
1299 constexpr rtl::OUStringConstExpr a5Boxes[] = {
1300  BMP_ICON_SET_SQUARES_EMPTY, BMP_ICON_SET_SQUARES_ONE_QUARTER,
1301  BMP_ICON_SET_SQUARES_HALF, BMP_ICON_SET_SQUARES_THREE_QUARTER,
1302  BMP_ICON_SET_SQUARES_FULL
1303 };
1304 
1305 constexpr rtl::OUStringConstExpr a3Symbols1[] = {
1306  BMP_ICON_SET_SYMBOLS1_CROSS, BMP_ICON_SET_SYMBOLS1_EXCLAMATION_MARK, BMP_ICON_SET_SYMBOLS1_CHECK
1307 };
1308 
1309 constexpr rtl::OUStringConstExpr a3Signs[] = {
1310  BMP_ICON_SET_SHAPES_DIAMOND, BMP_ICON_SET_SHAPES_TRIANGLE, BMP_ICON_SET_SHAPES_CIRCLE
1311 };
1312 
1313 constexpr rtl::OUStringConstExpr a4RedToBlack[] = {
1314  BMP_ICON_SET_CIRCLES2_DARK_GRAY, BMP_ICON_SET_CIRCLES2_LIGHT_GRAY,
1315  BMP_ICON_SET_CIRCLES2_LIGHT_RED, BMP_ICON_SET_CIRCLES2_DARK_RED
1316 };
1317 
1318 constexpr rtl::OUStringConstExpr a4Ratings[] = {
1319  BMP_ICON_SET_BARS_ONE_QUARTER, BMP_ICON_SET_BARS_HALF,
1320  BMP_ICON_SET_BARS_THREE_QUARTER, BMP_ICON_SET_BARS_FULL
1321 };
1322 
1323 constexpr rtl::OUStringConstExpr a5Ratings[] = {
1324  BMP_ICON_SET_BARS_EMPTY, BMP_ICON_SET_BARS_ONE_QUARTER, BMP_ICON_SET_BARS_HALF,
1325  BMP_ICON_SET_BARS_THREE_QUARTER, BMP_ICON_SET_BARS_FULL
1326 };
1327 
1328 struct ScIconSetBitmapMap {
1330  const rtl::OUStringConstExpr* pBitmaps;
1331 };
1332 
1333 const ScIconSetBitmapMap aBitmapMap[] = {
1334  { IconSet_3Arrows, a3Arrows },
1335  { IconSet_3ArrowsGray, a3ArrowsGray },
1336  { IconSet_3Flags, a3Flags },
1337  { IconSet_3Signs, a3Signs },
1338  { IconSet_3Symbols, a3Symbols1 },
1339  { IconSet_3Symbols2, a3Symbols1 },
1340  { IconSet_3TrafficLights1, a3TrafficLights1 },
1341  { IconSet_3TrafficLights2, a3TrafficLights2 },
1342  { IconSet_3Smilies, a3Smilies },
1343  { IconSet_3ColorSmilies, a3ColorSmilies },
1344  { IconSet_3Triangles, a3Triangles },
1345  { IconSet_3Stars, a3Stars },
1346  { IconSet_4Arrows, a4Arrows },
1347  { IconSet_4ArrowsGray, a4ArrowsGray },
1348  { IconSet_4Rating, a4Ratings },
1349  { IconSet_4RedToBlack, a4RedToBlack },
1350  { IconSet_4TrafficLights, a4TrafficLights },
1351  { IconSet_5Arrows, a5Arrows },
1352  { IconSet_5ArrowsGray, a5ArrowsGray },
1353  { IconSet_5Quarters, a5Quarters },
1354  { IconSet_5Ratings, a5Ratings },
1355  { IconSet_5Boxes, a5Boxes }
1356 };
1357 
1358 const ScIconSetMap* findIconSetType(ScIconSetType eType)
1359 {
1361  for (; pMap->pName; ++pMap)
1362  {
1363  if (pMap->eType == eType)
1364  return pMap;
1365  }
1366 
1367  return nullptr;
1368 }
1369 
1370 }
1371 
1373 {
1374  const ScIconSetMap* pMap = findIconSetType(eType);
1375  if (pMap)
1376  return pMap->pName;
1377 
1378  return "";
1379 }
1380 
1382 {
1383  const ScIconSetMap* pMap = findIconSetType(eType);
1384  if (pMap)
1385  return pMap->nElements;
1386 
1387  return 0;
1388 }
1389 
1390 OUString ScIconSetFormat::getIconName(ScIconSetType const eType, sal_Int32 const nIndex)
1391 {
1392  OUString sBitmap;
1393 
1394  for(const ScIconSetBitmapMap & i : aBitmapMap)
1395  {
1396  if(i.eType == eType)
1397  {
1398  sBitmap = *(i.pBitmaps + nIndex);
1399  break;
1400  }
1401  }
1402 
1403  assert(!sBitmap.isEmpty());
1404 
1405  return sBitmap;
1406 }
1407 
1409  ScIconSetType const eType, sal_Int32 const nIndex)
1410 {
1411  OUString sBitmap(ScIconSetFormat::getIconName(eType, nIndex));
1412 
1413  std::map<OUString, BitmapEx>::iterator itr = rIconSetBitmapMap.find(sBitmap);
1414  if (itr != rIconSetBitmapMap.end())
1415  return itr->second;
1416 
1417  BitmapEx aBitmap(sBitmap);
1418  std::pair<OUString, BitmapEx> aPair(sBitmap, aBitmap);
1419  std::pair<std::map<OUString, BitmapEx>::iterator, bool> itrNew = rIconSetBitmapMap.insert(aPair);
1420  assert(itrNew.second);
1421 
1422  return itrNew.first->second;
1423 }
1424 
1426 {
1427  ScIconSetType eType = mpFormatData->eIconSetType;
1428  for (const ScIconSetMap & i : g_IconSetMap)
1429  {
1430  if (i.eType == eType)
1431  {
1432  // size_t nElements = aIconSetMap[i].nElements;
1433  // TODO: implement
1434  break;
1435  }
1436  }
1437 }
1438 
1439 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
size_t size() const
Definition: colorscale.cxx:695
ScConditionalFormat * mpFormat
Definition: colorscale.hxx:48
virtual void UpdateReference(sc::RefUpdateContext &rCxt) override
Definition: colorscale.cxx:760
void SetRepaintCallback(ScConditionalFormat *pParent)
Definition: colorscale.cxx:315
sal_Int32 nIndex
ScAddress aStart
Definition: address.hxx:497
iterator end()
sal_uInt8 GetRed() const
virtual void UpdateReference(sc::RefUpdateContext &rCxt) override
ScIconSetFormatData::Entries_t::iterator iterator
Definition: colorscale.hxx:386
virtual void UpdateMoveTab(sc::RefUpdateMoveTabContext &rCxt) override
Definition: colorscale.cxx:778
ScColorScaleEntryType meType
Definition: colorscale.hxx:50
virtual ScColorFormat * Clone(ScDocument *pDoc) const override
Definition: colorscale.cxx:996
SCROW Row() const
Definition: address.hxx:274
ScFormulaListener(ScFormulaCell *pCell)
Definition: colorscale.cxx:28
virtual void SetParent(ScConditionalFormat *pParent) override
Definition: colorscale.cxx:745
ScColorScaleEntry * GetEntry(size_t nPos)
Definition: colorscale.cxx:679
Single reference (one address) into the sheet.
Definition: refdata.hxx:29
void UpdateInsertTab(const sc::RefUpdateInsertTabContext &rCxt)
Definition: colorscale.cxx:270
ScAddress toAbs(const ScSheetLimits &rLimits, const ScAddress &rPos) const
Definition: refdata.cxx:193
double getMin(double nMin, double nMax) const
Definition: colorscale.cxx:784
ScTokenArray * GetCode()
long Long
Context for reference update during shifting, moving or copying of cell ranges.
void ExtendTo(const ScRange &rRange)
Definition: address.cxx:1562
std::unique_ptr< ScFormulaCell > mpCell
Definition: colorscale.hxx:46
ScColorScaleFormat(ScDocument *pDoc)
Definition: colorscale.cxx:369
sal_Int64 n
virtual void UpdateInsertTab(sc::RefUpdateInsertTabContext &rCxt) override
Definition: colorscale.cxx:766
virtual ~ScColorScaleFormat() override
Definition: colorscale.cxx:388
static BitmapEx & getBitmap(sc::IconSetBitmapMap &rBitmapMap, ScIconSetType eType, sal_Int32 nIndex)
SCTAB getNewTab(SCTAB nOldTab) const
If set, absolute refs will not transformed to external references.
double getMaxValue() const
Definition: colorscale.cxx:496
bool IsClipOrUndo() const
Definition: document.hxx:1587
ScAddress aEnd
Definition: address.hxx:498
basegfx::BColor maColor
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:103
void SetValue(double nValue)
Definition: colorscale.cxx:250
static const ScIconSetMap g_IconSetMap[]
Definition: colorscale.hxx:380
bool NeedsRepaint() const
Definition: colorscale.cxx:147
std::function< void()> maCallbackFunction
Definition: conditio.hxx:186
double GetMinValue() const
SfxHintId GetId() const
static sal_Int32 getIconSetElements(ScIconSetType eType)
~ScColorScaleEntry() COVERITY_NOEXCEPT_FALSE
Definition: colorscale.cxx:201
const ScTokenArray * GetFormula() const
Definition: colorscale.cxx:216
static const char * getIconSetName(ScIconSetType eType)
const ScRangeList & GetRange() const
Definition: conditio.hxx:558
virtual Type GetType() const override
Definition: colorscale.cxx:755
void EnsureSize()
Makes sure that the mpFormatData does not contain valid entries.
Definition: colorscale.cxx:958
double CalcValue(double nMin, double nMax, const ScIconSetFormat::const_iterator &itr) const
void setCallback(const std::function< void()> &aCallbackFunction)
Definition: colorscale.cxx:118
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:891
std::optional< Color > GetColor(const ScAddress &rAddr) const
Definition: colorscale.cxx:588
double getMax(double nMin, double nMax) const
Definition: colorscale.cxx:811
std::unique_ptr< ScFormulaListener > mpListener
Definition: colorscale.hxx:47
void SetColor(const Color &)
Definition: colorscale.cxx:310
std::unique_ptr< ScColorFormatCache > mpCache
Definition: colorscale.hxx:247
std::vector< double > & getValues() const
Definition: colorscale.cxx:442
virtual void SetParent(ScConditionalFormat *pParent) override
Definition: colorscale.cxx:392
iterator begin()
virtual void UpdateReference(sc::RefUpdateContext &rCxt) override
Definition: colorscale.cxx:630
std::unique_ptr< ScDataBarInfo > GetDataBarInfo(const ScAddress &rAddr) const
Definition: colorscale.cxx:835
std::map< OUString, BitmapEx > IconSetBitmapMap
Definition: document.hxx:216
SCTAB Tab() const
Definition: address.hxx:283
void SetRow(SCROW nRowP)
Definition: address.hxx:287
bool IsColRel() const
Definition: refdata.hxx:65
ScAddress aPos
sal_uInt8 GetBlue() const
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4799
void SetCol(SCCOL nColP)
Definition: address.hxx:291
void Notify(const SfxHint &rHint) override
Definition: colorscale.cxx:136
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_LIGHTRED
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:1066
double GetMinValue() const
Definition: colorscale.cxx:407
double CalcValue(double nMin, double nMax, const ScColorScaleEntries::const_iterator &rItr) const
Definition: colorscale.cxx:559
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
Definition: patattr.hxx:72
DocumentType eType
ScColorScaleEntries::iterator end()
Definition: colorscale.cxx:669
const ScRangeList & GetRange() const
Definition: colorscale.cxx:437
void EndListeningAll()
virtual void UpdateDeleteTab(sc::RefUpdateDeleteTabContext &rCxt) override
Definition: colorscale.cxx:642
ScColorScaleEntryType
Definition: colorscale.hxx:31
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:890
void UpdateReference(const sc::RefUpdateContext &rCxt)
Definition: colorscale.cxx:257
ocColRowNameAuto
int i
void addTokenArray(const ScTokenArray *pTokens, const ScRange &rRange)
Definition: colorscale.cxx:113
void AddEntry(ScColorScaleEntry *pEntry)
Definition: colorscale.cxx:401
void calcMinMax(double &nMin, double &nMax) const
Definition: colorscale.cxx:431
sal_Int16 SCCOL
Definition: types.hxx:21
virtual void UpdateDeleteTab(sc::RefUpdateDeleteTabContext &rCxt) override
Definition: colorscale.cxx:772
std::unique_ptr< ScDataBarFormatData > mpFormatData
Definition: colorscale.hxx:328
virtual ~ScColorFormat() override
Definition: colorscale.cxx:360
size_t size() const
Definition: rangelst.hxx:89
virtual void UpdateInsertTab(sc::RefUpdateInsertTabContext &rCxt) override
Definition: colorscale.cxx:636
const ScIconSetFormatData * GetIconSetData() const
virtual void SetParent(ScConditionalFormat *pParent) override
Definition: colorscale.cxx:364
static OUString getIconName(ScIconSetType eType, sal_Int32 nIndex)
virtual ScColorFormat * Clone(ScDocument *pDoc) const override
Definition: colorscale.cxx:383
ScIconSetType eType
Definition: colorscale.hxx:216
ScIconSetFormatData::Entries_t::const_iterator const_iterator
Definition: colorscale.hxx:387
bool hasNumeric() const
Definition: cellvalue.cxx:622
virtual Type GetType() const override
Definition: colorscale.cxx:654
ScIconSetFormatData(ScIconSetType eType=IconSet_3Arrows)
Definition: colorscale.hxx:346
void SetFormula(const OUString &rFormula, ScDocument &rDoc, const ScAddress &rAddr, formula::FormulaGrammar::Grammar eGrammar=formula::FormulaGrammar::GRAM_DEFAULT)
Definition: colorscale.cxx:207
bool IsValid() const
Definition: address.hxx:544
virtual Type GetType() const override
ScColorFormat(ScDocument *pDoc)
Definition: colorscale.cxx:354
SCCOL Col() const
Definition: address.hxx:279
XPropertyListType t
virtual void SetParent(ScConditionalFormat *pParent) override
RegionData_Impl * mpParent
virtual void UpdateMoveTab(sc::RefUpdateMoveTabContext &rCxt) override
Definition: colorscale.cxx:648
sal_uInt8 GetGreen() const
ScDocument & mrDoc
Definition: conditio.hxx:185
virtual void UpdateMoveTab(sc::RefUpdateMoveTabContext &rCxt) override
size_t size() const
sal_Int32 SCROW
Definition: types.hxx:17
ScColorScaleEntries::iterator begin()
Definition: colorscale.cxx:659
void UpdateMoveTab(const sc::RefUpdateMoveTabContext &rCxt)
Definition: colorscale.cxx:296
unsigned char sal_uInt8
void SetIconSetData(ScIconSetFormatData *pData)
ScDataBarFormat(ScDocument *pDoc)
Definition: colorscale.cxx:708
void EnsureSize()
Makes sure that the maColorScales contain at least 2 entries.
Definition: colorscale.cxx:700
double getValue()
Definition: cellvalue.cxx:632
const char * pName
Definition: colorscale.hxx:215
ScDocument * mpDoc
Definition: conditio.hxx:255
const ScDataBarFormatData * GetDataBarData() const
Definition: colorscale.cxx:735
ScIconSetType
Definition: colorscale.hxx:188
void UpdateDeleteTab(const sc::RefUpdateDeleteTabContext &rCxt)
Definition: colorscale.cxx:283
ScColorScaleEntries maColorScales
Definition: colorscale.hxx:255
virtual void startRendering() override
Definition: colorscale.cxx:504
std::unique_ptr< ScIconSetInfo > GetIconSetInfo(const ScAddress &rAddr) const
void StartListeningArea(const ScRange &rRange, bool bGroupListening, SvtListener *pListener)
Definition: documen7.cxx:35
void SetType(ScColorScaleEntryType eType)
Definition: colorscale.cxx:323
sal_Int32 nLength
double getMinValue() const
Definition: colorscale.cxx:488
bool mbReverse
virtual void UpdateInsertTab(sc::RefUpdateInsertTabContext &rCxt) override
virtual ~ScFormulaListener() override
Definition: colorscale.cxx:131
virtual ScColorFormat * Clone(ScDocument *pDoc) const override
Definition: colorscale.cxx:740
double GetMaxValue() const
double GetMaxValue() const
Definition: colorscale.cxx:419
ScIconSetFormat(ScDocument *pDoc)
Definition: colorscale.cxx:984
constexpr TypedWhichId< SvxFontHeightItem > ATTR_FONT_HEIGHT(101)
ScConditionalFormat * mpParent
Definition: colorscale.hxx:239
RedlineType meType
virtual void endRendering() override
Definition: colorscale.cxx:509
double GetValue() const
Definition: colorscale.cxx:236
void SetDataBarData(ScDataBarFormatData *pData)
Definition: colorscale.cxx:720
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int32 nElements
Definition: colorscale.hxx:217
FormulaTokenArrayReferencesRange References() const
sal_Int16 nValue
virtual void UpdateDeleteTab(sc::RefUpdateDeleteTabContext &rCxt) override
bool m_bDetectedRangeSegmentation false
std::unique_ptr< ScIconSetFormatData > mpFormatData
Definition: colorscale.hxx:408
void startListening(const ScTokenArray *pTokens, const ScRange &rPos)
Definition: colorscale.cxx:48
ScDocument * GetDocument()
Definition: conditio.cxx:1776
void EnsureSize()
Makes sure that the mpFormatData does not contain valid entries.