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 
20 #include <formula/token.hxx>
21 #include <vcl/bitmapex.hxx>
22 
23 #include <algorithm>
24 #include <cassert>
25 
27  mbDirty(false),
28  mpDoc(pCell->GetDocument())
29 {
30  startListening( pCell->GetCode(), pCell->aPos );
31 }
32 
34  mbDirty(false),
35  mpDoc(pDoc)
36 {
37 }
38 
40  mbDirty(false),
41  mpDoc(pDoc)
42 {
43  startListening(rRange);
44 }
45 
46 void ScFormulaListener::startListening(const ScTokenArray* pArr, const ScRange& rRange)
47 {
48  if (!pArr || mpDoc->IsClipOrUndo())
49  return;
50 
51  for ( auto t: pArr->References() )
52  {
53  switch (t->GetType())
54  {
56  {
57  ScAddress aCell = t->GetSingleRef()->toAbs(mpDoc, rRange.aStart);
58  ScAddress aCell2 = t->GetSingleRef()->toAbs(mpDoc, rRange.aEnd);
59  ScRange aRange(aCell, aCell2);
60  if (aRange.IsValid())
61  mpDoc->StartListeningArea(aRange, false, this);
62  }
63  break;
65  {
66  const ScSingleRefData& rRef1 = *t->GetSingleRef();
67  const ScSingleRefData& rRef2 = *t->GetSingleRef2();
68  ScAddress aCell1 = rRef1.toAbs(mpDoc, rRange.aStart);
69  ScAddress aCell2 = rRef2.toAbs(mpDoc, rRange.aStart);
70  ScAddress aCell3 = rRef1.toAbs(mpDoc, rRange.aEnd);
71  ScAddress aCell4 = rRef2.toAbs(mpDoc, rRange.aEnd);
72  ScRange aRange1(aCell1, aCell3);
73  ScRange aRange2(aCell2, aCell4);
74  aRange1.ExtendTo(aRange2);
75  if (aRange1.IsValid())
76  {
77  if (t->GetOpCode() == ocColRowNameAuto)
78  { // automagically
79  if ( rRef1.IsColRel() )
80  { // ColName
81  aRange1.aEnd.SetRow(mpDoc->MaxRow());
82  }
83  else
84  { // RowName
85  aRange1.aEnd.SetCol(mpDoc->MaxCol());
86  }
87  }
88  mpDoc->StartListeningArea(aRange1, false, this);
89  }
90  }
91  break;
92  default:
93  ; // nothing
94  }
95  }
96 }
97 
99 {
100  if (mpDoc->IsClipOrUndo())
101  return;
102 
103  size_t nLength = rRange.size();
104  for (size_t i = 0; i < nLength; ++i)
105  {
106  const ScRange& aRange = rRange[i];
107  mpDoc->StartListeningArea(aRange, false, this);
108  }
109 }
110 
111 void ScFormulaListener::addTokenArray(const ScTokenArray* pArray, const ScRange& rRange)
112 {
113  startListening(pArray, rRange);
114 }
115 
116 void ScFormulaListener::setCallback(const std::function<void()>& aCallback)
117 {
118  maCallbackFunction = aCallback;
119 }
120 
122 {
123  if (mpDoc->IsClipOrUndo())
124  return;
125 
126  EndListeningAll();
127 }
128 
130 {
131  stopListening();
132 }
133 
135 {
136  mbDirty = true;
137 
138  if (rHint.GetId() == SfxHintId::Dying)
139  return;
140 
141  if (maCallbackFunction)
143 }
144 
146 {
147  bool bRet = mbDirty;
148  mbDirty = false;
149  return bRet;
150 }
151 
153  mnVal(0),
154  mpFormat(nullptr),
156 {
157 }
158 
160  mnVal(nVal),
161  mpFormat(nullptr),
162  maColor(rCol),
163  meType(eType)
164 {
165 }
166 
168  mnVal(rEntry.mnVal),
169  mpFormat(rEntry.mpFormat),
170  maColor(rEntry.maColor),
171  meType(rEntry.meType)
172 {
173  setListener();
174  if(rEntry.mpCell)
175  {
176  mpCell.reset(new ScFormulaCell(*rEntry.mpCell, *rEntry.mpCell->GetDocument(), rEntry.mpCell->aPos, ScCloneFlags::NoMakeAbsExternal));
177  mpCell->StartListeningTo( mpCell->GetDocument() );
178  mpListener.reset(new ScFormulaListener(mpCell.get()));
179  }
180 }
181 
183  mnVal(rEntry.mnVal),
184  mpCell(),
185  mpFormat(rEntry.mpFormat),
186  maColor(rEntry.maColor),
187  meType(rEntry.meType)
188 {
189  setListener();
190  if(rEntry.mpCell)
191  {
192  mpCell.reset(new ScFormulaCell(*rEntry.mpCell, *rEntry.mpCell->GetDocument(), rEntry.mpCell->aPos, ScCloneFlags::NoMakeAbsExternal));
193  mpCell->StartListeningTo( pDoc );
194  mpListener.reset(new ScFormulaListener(mpCell.get()));
195  if (mpFormat)
196  mpListener->setCallback([&]() { mpFormat->DoRepaint();});
197  }
198 }
199 
200 ScColorScaleEntry::~ScColorScaleEntry() COVERITY_NOEXCEPT_FALSE
201 {
202  if(mpCell)
203  mpCell->EndListeningTo(mpCell->GetDocument());
204 }
205 
206 void ScColorScaleEntry::SetFormula( const OUString& rFormula, ScDocument* pDoc, const ScAddress& rAddr, formula::FormulaGrammar::Grammar eGrammar )
207 {
208  mpCell.reset(new ScFormulaCell( pDoc, rAddr, rFormula, eGrammar ));
209  mpCell->StartListeningTo( pDoc );
210  mpListener.reset(new ScFormulaListener(mpCell.get()));
211  if (mpFormat)
212  mpListener->setCallback([&]() { mpFormat->DoRepaint();});
213 }
214 
216 {
217  if(mpCell)
218  {
219  return mpCell->GetCode();
220  }
221 
222  return nullptr;
223 }
224 
226 {
227  OUString aFormula;
228  if(mpCell)
229  {
230  mpCell->GetFormula(aFormula, eGrammar);
231  }
232 
233  return aFormula;
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 == 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->mpNegativeColor)
938  {
939  pInfo->maColor = *mpFormatData->mpNegativeColor;
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  if(mpFormatData->mbReverse)
1060  {
1061  sal_Int32 nMaxIndex = mpFormatData->m_Entries.size() - 1;
1062  nIndex = nMaxIndex - nIndex;
1063  }
1064 
1065  if (mpFormatData->mbCustom && sal_Int32(mpFormatData->maCustomVector.size()) > nIndex)
1066  {
1067  ScIconSetType eCustomType = mpFormatData->maCustomVector[nIndex].first;
1068  sal_Int32 nCustomIndex = mpFormatData->maCustomVector[nIndex].second;
1069  if (nCustomIndex == -1)
1070  {
1071  return nullptr;
1072  }
1073 
1074  pInfo->eIconSetType = eCustomType;
1075  pInfo->nIconIndex = nCustomIndex;
1076  }
1077  else
1078  {
1079  pInfo->nIconIndex = nIndex;
1080  pInfo->eIconSetType = mpFormatData->eIconSetType;
1081  }
1082 
1083  pInfo->mbShowValue = mpFormatData->mbShowValue;
1084  return pInfo;
1085 }
1086 
1088 {
1089  return Type::Iconset;
1090 }
1091 
1093 {
1094  for(iterator itr = begin(); itr != end(); ++itr)
1095  {
1096  (*itr)->UpdateReference(rCxt);
1097  }
1098 }
1099 
1101 {
1102  for(iterator itr = begin(); itr != end(); ++itr)
1103  {
1104  (*itr)->UpdateInsertTab(rCxt);
1105  }
1106 }
1107 
1109 {
1110  for(iterator itr = begin(); itr != end(); ++itr)
1111  {
1112  (*itr)->UpdateDeleteTab(rCxt);
1113  }
1114 }
1115 
1117 {
1118  for(iterator itr = begin(); itr != end(); ++itr)
1119  {
1120  (*itr)->UpdateMoveTab(rCxt);
1121  }
1122 }
1123 
1125 {
1126  return mpFormatData->m_Entries.begin();
1127 }
1128 
1130 {
1131  return mpFormatData->m_Entries.begin();
1132 }
1133 
1135 {
1136  return mpFormatData->m_Entries.end();
1137 }
1138 
1140 {
1141  return mpFormatData->m_Entries.end();
1142 }
1143 
1145 {
1146  const_iterator itr = begin();
1147 
1148  if ((*itr)->GetType() == COLORSCALE_VALUE || (*itr)->GetType() == COLORSCALE_FORMULA)
1149  return (*itr)->GetValue();
1150  else
1151  {
1152  return getMinValue();
1153  }
1154 }
1155 
1157 {
1158  auto const itr = mpFormatData->m_Entries.rbegin();
1159 
1160  if ((*itr)->GetType() == COLORSCALE_VALUE || (*itr)->GetType() == COLORSCALE_FORMULA)
1161  return (*itr)->GetValue();
1162  else
1163  {
1164  return getMaxValue();
1165  }
1166 }
1167 
1168 double ScIconSetFormat::CalcValue(double nMin, double nMax, const ScIconSetFormat::const_iterator& itr) const
1169 {
1170  switch ((*itr)->GetType())
1171  {
1172  case COLORSCALE_PERCENT:
1173  return nMin + (nMax-nMin)*((*itr)->GetValue()/100);
1174  case COLORSCALE_MIN:
1175  return nMin;
1176  case COLORSCALE_MAX:
1177  return nMax;
1178  case COLORSCALE_PERCENTILE:
1179  {
1180  std::vector<double>& rValues = getValues();
1181  if(rValues.size() == 1)
1182  return rValues[0];
1183  else
1184  {
1185  double fPercentile = (*itr)->GetValue()/100.0;
1186  return GetPercentile(rValues, fPercentile);
1187  }
1188  }
1189 
1190  default:
1191  break;
1192  }
1193 
1194  return (*itr)->GetValue();
1195 }
1196 
1198  { "3Arrows", IconSet_3Arrows, 3 },
1199  { "3ArrowsGray", IconSet_3ArrowsGray, 3 },
1200  { "3Flags", IconSet_3Flags, 3 },
1201  { "3TrafficLights1", IconSet_3TrafficLights1, 3 },
1202  { "3TrafficLights2", IconSet_3TrafficLights2, 3 },
1203  { "3Signs", IconSet_3Signs, 3 },
1204  { "3Symbols", IconSet_3Symbols, 3 },
1205  { "3Symbols2", IconSet_3Symbols2, 3 },
1206  { "3Smilies", IconSet_3Smilies, 3 },
1207  { "3ColorSmilies", IconSet_3ColorSmilies, 3 },
1208  { "3Stars", IconSet_3Stars, 3 },
1209  { "3Triangles", IconSet_3Triangles, 3 },
1210  { "4Arrows", IconSet_4Arrows, 4 },
1211  { "4ArrowsGray", IconSet_4ArrowsGray, 4 },
1212  { "4RedToBlack", IconSet_4RedToBlack, 4 },
1213  { "4Rating", IconSet_4Rating, 4 },
1214  { "4TrafficLights", IconSet_4TrafficLights, 4 },
1215  { "5Arrows", IconSet_5Arrows, 5 },
1216  { "5ArrowsGray", IconSet_5ArrowsGray, 5 },
1217  { "5Rating", IconSet_5Ratings, 5 },
1218  { "5Quarters", IconSet_5Quarters, 5 },
1219  { "5Boxes", IconSet_5Boxes, 5 },
1220  { nullptr, IconSet_3Arrows, 0 }
1221 };
1222 
1224 {
1225  return mpFormatData->m_Entries.size();
1226 }
1227 
1228 
1229 namespace {
1230 
1231 const OUStringLiteral a3TrafficLights1[] = {
1232  BMP_ICON_SET_CIRCLES1_RED, BMP_ICON_SET_CIRCLES1_YELLOW, BMP_ICON_SET_CIRCLES1_GREEN
1233 };
1234 
1235 const OUStringLiteral a3TrafficLights2[] = {
1236  BMP_ICON_SET_TRAFFICLIGHTS_RED, BMP_ICON_SET_TRAFFICLIGHTS_YELLOW, BMP_ICON_SET_TRAFFICLIGHTS_GREEN
1237 };
1238 
1239 const OUStringLiteral a3Arrows[] = {
1240  BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SAME, BMP_ICON_SET_COLORARROWS_UP
1241 };
1242 
1243 const OUStringLiteral a3ArrowsGray[] = {
1244  BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SAME, BMP_ICON_SET_GRAYARROWS_UP
1245 };
1246 
1247 const OUStringLiteral a3Flags[] = {
1248  BMP_ICON_SET_FLAGS_RED, BMP_ICON_SET_FLAGS_YELLOW, BMP_ICON_SET_FLAGS_GREEN
1249 };
1250 
1251 const OUStringLiteral a3Smilies[] = {
1252  BMP_ICON_SET_POSITIVE_YELLOW_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_NEGATIVE_YELLOW_SMILIE
1253 };
1254 
1255 const OUStringLiteral a3ColorSmilies[] = {
1256  BMP_ICON_SET_POSITIVE_GREEN_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_NEGATIVE_RED_SMILIE
1257 };
1258 
1259 const OUStringLiteral a3Stars[] = {
1260  BMP_ICON_SET_STARS_EMPTY, BMP_ICON_SET_STARS_HALF, BMP_ICON_SET_STARS_FULL
1261 };
1262 
1263 const OUStringLiteral a3Triangles[] = {
1264  BMP_ICON_SET_TRIANGLES_DOWN, BMP_ICON_SET_TRIANGLES_SAME, BMP_ICON_SET_TRIANGLES_UP
1265 };
1266 
1267 const OUStringLiteral a4Arrows[] = {
1268  BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP, BMP_ICON_SET_COLORARROWS_UP
1269 };
1270 
1271 const OUStringLiteral a4ArrowsGray[] = {
1272  BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP, BMP_ICON_SET_GRAYARROWS_UP
1273 };
1274 
1275 const OUStringLiteral a5Arrows[] = {
1276  BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN,
1277  BMP_ICON_SET_COLORARROWS_SAME, BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP, BMP_ICON_SET_COLORARROWS_UP
1278 };
1279 
1280 const OUStringLiteral a5ArrowsGray[] = {
1281  BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN,
1282  BMP_ICON_SET_GRAYARROWS_SAME, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP, BMP_ICON_SET_GRAYARROWS_UP
1283 };
1284 
1285 const OUStringLiteral a4TrafficLights[] = {
1286  BMP_ICON_SET_CIRCLES1_GRAY, BMP_ICON_SET_CIRCLES1_RED,
1287  BMP_ICON_SET_CIRCLES1_YELLOW, BMP_ICON_SET_CIRCLES1_GREEN
1288 };
1289 
1290 const OUStringLiteral a5Quarters[] = {
1291  BMP_ICON_SET_PIES_EMPTY, BMP_ICON_SET_PIES_ONE_QUARTER, BMP_ICON_SET_PIES_HALF,
1292  BMP_ICON_SET_PIES_THREE_QUARTER, BMP_ICON_SET_PIES_FULL,
1293 };
1294 
1295 const OUStringLiteral a5Boxes[] = {
1296  BMP_ICON_SET_SQUARES_EMPTY, BMP_ICON_SET_SQUARES_ONE_QUARTER,
1297  BMP_ICON_SET_SQUARES_HALF, BMP_ICON_SET_SQUARES_THREE_QUARTER,
1298  BMP_ICON_SET_SQUARES_FULL
1299 };
1300 
1301 const OUStringLiteral a3Symbols1[] = {
1302  BMP_ICON_SET_SYMBOLS1_CROSS, BMP_ICON_SET_SYMBOLS1_EXCLAMATION_MARK, BMP_ICON_SET_SYMBOLS1_CHECK
1303 };
1304 
1305 const OUStringLiteral a3Signs[] = {
1306  BMP_ICON_SET_SHAPES_DIAMOND, BMP_ICON_SET_SHAPES_TRIANGLE, BMP_ICON_SET_SHAPES_CIRCLE
1307 };
1308 
1309 const OUStringLiteral a4RedToBlack[] = {
1310  BMP_ICON_SET_CIRCLES2_DARK_GRAY, BMP_ICON_SET_CIRCLES2_LIGHT_GRAY,
1311  BMP_ICON_SET_CIRCLES2_LIGHT_RED, BMP_ICON_SET_CIRCLES2_DARK_RED
1312 };
1313 
1314 const OUStringLiteral a4Ratings[] = {
1315  BMP_ICON_SET_BARS_ONE_QUARTER, BMP_ICON_SET_BARS_HALF,
1316  BMP_ICON_SET_BARS_THREE_QUARTER, BMP_ICON_SET_BARS_FULL
1317 };
1318 
1319 const OUStringLiteral a5Ratings[] = {
1320  BMP_ICON_SET_BARS_EMPTY, BMP_ICON_SET_BARS_ONE_QUARTER, BMP_ICON_SET_BARS_HALF,
1321  BMP_ICON_SET_BARS_THREE_QUARTER, BMP_ICON_SET_BARS_FULL
1322 };
1323 
1324 struct ScIconSetBitmapMap {
1326  const OUStringLiteral* pBitmaps;
1327 };
1328 
1329 const ScIconSetBitmapMap aBitmapMap[] = {
1330  { IconSet_3Arrows, a3Arrows },
1331  { IconSet_3ArrowsGray, a3ArrowsGray },
1332  { IconSet_3Flags, a3Flags },
1333  { IconSet_3Signs, a3Signs },
1334  { IconSet_3Symbols, a3Symbols1 },
1335  { IconSet_3Symbols2, a3Symbols1 },
1336  { IconSet_3TrafficLights1, a3TrafficLights1 },
1337  { IconSet_3TrafficLights2, a3TrafficLights2 },
1338  { IconSet_3Smilies, a3Smilies },
1339  { IconSet_3ColorSmilies, a3ColorSmilies },
1340  { IconSet_3Triangles, a3Triangles },
1341  { IconSet_3Stars, a3Stars },
1342  { IconSet_4Arrows, a4Arrows },
1343  { IconSet_4ArrowsGray, a4ArrowsGray },
1344  { IconSet_4Rating, a4Ratings },
1345  { IconSet_4RedToBlack, a4RedToBlack },
1346  { IconSet_4TrafficLights, a4TrafficLights },
1347  { IconSet_5Arrows, a5Arrows },
1348  { IconSet_5ArrowsGray, a5ArrowsGray },
1349  { IconSet_5Quarters, a5Quarters },
1350  { IconSet_5Ratings, a5Ratings },
1351  { IconSet_5Boxes, a5Boxes }
1352 };
1353 
1354 const ScIconSetMap* findIconSetType(ScIconSetType eType)
1355 {
1357  for (; pMap->pName; ++pMap)
1358  {
1359  if (pMap->eType == eType)
1360  return pMap;
1361  }
1362 
1363  return nullptr;
1364 }
1365 
1366 }
1367 
1369 {
1370  const ScIconSetMap* pMap = findIconSetType(eType);
1371  if (pMap)
1372  return pMap->pName;
1373 
1374  return "";
1375 }
1376 
1378 {
1379  const ScIconSetMap* pMap = findIconSetType(eType);
1380  if (pMap)
1381  return pMap->nElements;
1382 
1383  return 0;
1384 }
1385 
1386 OUString ScIconSetFormat::getIconName(ScIconSetType const eType, sal_Int32 const nIndex)
1387 {
1388  OUString sBitmap;
1389 
1390  for(const ScIconSetBitmapMap & i : aBitmapMap)
1391  {
1392  if(i.eType == eType)
1393  {
1394  sBitmap = *(i.pBitmaps + nIndex);
1395  break;
1396  }
1397  }
1398 
1399  assert(!sBitmap.isEmpty());
1400 
1401  return sBitmap;
1402 }
1403 
1405  ScIconSetType const eType, sal_Int32 const nIndex)
1406 {
1407  OUString sBitmap(ScIconSetFormat::getIconName(eType, nIndex));
1408 
1409  std::map<OUString, BitmapEx>::iterator itr = rIconSetBitmapMap.find(sBitmap);
1410  if (itr != rIconSetBitmapMap.end())
1411  return itr->second;
1412 
1413  BitmapEx aBitmap(sBitmap);
1414  std::pair<OUString, BitmapEx> aPair(sBitmap, aBitmap);
1415  std::pair<std::map<OUString, BitmapEx>::iterator, bool> itrNew = rIconSetBitmapMap.insert(aPair);
1416  assert(itrNew.second);
1417 
1418  return itrNew.first->second;
1419 }
1420 
1422 {
1423  ScIconSetType eType = mpFormatData->eIconSetType;
1424  for (const ScIconSetMap & i : g_IconSetMap)
1425  {
1426  if (i.eType == eType)
1427  {
1428  // size_t nElements = aIconSetMap[i].nElements;
1429  // TODO: implement
1430  break;
1431  }
1432  }
1433 }
1434 
1435 /* 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:500
iterator end()
sal_uInt8 GetRed() const
virtual void UpdateReference(sc::RefUpdateContext &rCxt) override
ScIconSetFormatData::Entries_t::iterator iterator
Definition: colorscale.hxx:387
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:262
ScFormulaListener(ScFormulaCell *pCell)
Definition: colorscale.cxx:26
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:30
void UpdateInsertTab(const sc::RefUpdateInsertTabContext &rCxt)
Definition: colorscale.cxx:270
double getMin(double nMin, double nMax) const
Definition: colorscale.cxx:784
ScTokenArray * GetCode()
Context for reference update during shifting, moving or copying of cell ranges.
SC_DLLPUBLIC void ExtendTo(const ScRange &rRange)
Definition: address.cxx:1599
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:1531
ScAddress aEnd
Definition: address.hxx:501
constexpr::Color COL_LIGHTRED(0xFF, 0x00, 0x00)
basegfx::BColor maColor
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:104
void SetValue(double nValue)
Definition: colorscale.cxx:250
static const ScIconSetMap g_IconSetMap[]
Definition: colorscale.hxx:381
bool NeedsRepaint() const
Definition: colorscale.cxx:145
std::function< void()> maCallbackFunction
Definition: conditio.hxx:188
double GetMinValue() const
SfxHintId GetId() const
static sal_Int32 getIconSetElements(ScIconSetType eType)
~ScColorScaleEntry() COVERITY_NOEXCEPT_FALSE
Definition: colorscale.cxx:200
const ScTokenArray * GetFormula() const
Definition: colorscale.cxx:215
static const char * getIconSetName(ScIconSetType eType)
const ScRangeList & GetRange() const
Definition: conditio.hxx:560
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:116
void SetFormula(const OUString &rFormula, ScDocument *pDoc, const ScAddress &rAddr, formula::FormulaGrammar::Grammar eGrammar=formula::FormulaGrammar::GRAM_DEFAULT)
Definition: colorscale.cxx:206
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:876
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
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:248
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
ScFormulaCell * mpCell
const SCROW MAXROW
Definition: address.hxx:69
std::unique_ptr< ScDataBarInfo > GetDataBarInfo(const ScAddress &rAddr) const
Definition: colorscale.cxx:835
ScDocument * mpDoc
Definition: conditio.hxx:187
std::map< OUString, BitmapEx > IconSetBitmapMap
Definition: document.hxx:207
SCTAB Tab() const
Definition: address.hxx:271
void SetRow(SCROW nRowP)
Definition: address.hxx:275
bool IsColRel() const
Definition: refdata.hxx:66
ScAddress aPos
sal_uInt8 GetBlue() const
void SetCol(SCCOL nColP)
Definition: address.hxx:279
void Notify(const SfxHint &rHint) override
Definition: colorscale.cxx:134
double GetMinValue() const
Definition: colorscale.cxx:407
double CalcValue(double nMin, double nMax, const ScColorScaleEntries::const_iterator &rItr) const
Definition: colorscale.cxx:559
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:875
bool ShrinkToUsedDataArea(bool &o_bShrunk, SCTAB nTab, SCCOL &rStartCol, SCROW &rStartRow, SCCOL &rEndCol, SCROW &rEndRow, bool bColumnsOnly, bool bStickyTopRow=false, bool bStickyLeftCol=false, bool bConsiderCellNotes=false, bool bConsiderCellDrawObjects=false) const
Shrink a range to only include used data area.
Definition: document.cxx:1070
void UpdateReference(const sc::RefUpdateContext &rCxt)
Definition: colorscale.cxx:257
ocColRowNameAuto
int i
void addTokenArray(const ScTokenArray *pTokens, const ScRange &rRange)
Definition: colorscale.cxx:111
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:22
virtual void UpdateDeleteTab(sc::RefUpdateDeleteTabContext &rCxt) override
Definition: colorscale.cxx:772
std::unique_ptr< ScDataBarFormatData > mpFormatData
Definition: colorscale.hxx:329
virtual ~ScColorFormat() override
Definition: colorscale.cxx:360
size_t size() const
Definition: rangelst.hxx:90
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:217
ScIconSetFormatData::Entries_t::const_iterator const_iterator
Definition: colorscale.hxx:388
bool hasNumeric() const
Definition: cellvalue.cxx:622
virtual Type GetType() const override
Definition: colorscale.cxx:654
ScIconSetFormatData(ScIconSetType eType=IconSet_3Arrows)
Definition: colorscale.hxx:347
bool IsValid() const
Definition: address.hxx:547
virtual Type GetType() const override
ScColorFormat(ScDocument *pDoc)
Definition: colorscale.cxx:354
SCCOL Col() const
Definition: address.hxx:267
XPropertyListType t
virtual void SetParent(ScConditionalFormat *pParent) override
RegionData_Impl * mpParent
ScAddress toAbs(ScSheetLimits &rLimits, const ScAddress &rPos) const
Definition: refdata.cxx:193
virtual void UpdateMoveTab(sc::RefUpdateMoveTabContext &rCxt) override
Definition: colorscale.cxx:648
sal_uInt8 GetGreen() const
virtual void UpdateMoveTab(sc::RefUpdateMoveTabContext &rCxt) override
size_t size() const
sal_Int32 SCROW
Definition: types.hxx:18
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:216
ScDocument * mpDoc
Definition: conditio.hxx:257
const ScDataBarFormatData * GetDataBarData() const
Definition: colorscale.cxx:735
ScIconSetType
Definition: colorscale.hxx:189
void UpdateDeleteTab(const sc::RefUpdateDeleteTabContext &rCxt)
Definition: colorscale.cxx:283
ScColorScaleEntries maColorScales
Definition: colorscale.hxx:256
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:129
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
ScConditionalFormat * mpParent
Definition: colorscale.hxx:240
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:23
sal_Int32 nElements
Definition: colorscale.hxx:218
FormulaTokenArrayReferencesRange References() const
sal_Int16 nValue
virtual void UpdateDeleteTab(sc::RefUpdateDeleteTabContext &rCxt) override
std::unique_ptr< ScIconSetFormatData > mpFormatData
Definition: colorscale.hxx:409
void startListening(const ScTokenArray *pTokens, const ScRange &rPos)
Definition: colorscale.cxx:46
ScDocument * GetDocument()
Definition: conditio.cxx:1772
void EnsureSize()
Makes sure that the mpFormatData does not contain valid entries.