12 #include <document.hxx>
15 #include <bitmaps.hlst>
16 #include <tokenarray.hxx>
25 #include <string_view>
29 mrDoc(pCell->GetDocument())
73 ScRange aRange1(aCell1, aCell3);
74 ScRange aRange2(aCell2, aCell4);
105 for (
size_t i = 0;
i < nLength; ++
i)
139 if (rHint.
GetId() == SfxHintId::Dying)
170 mpFormat(rEntry.mpFormat),
186 mpFormat(rEntry.mpFormat),
194 mpCell->StartListeningTo( *pDoc );
210 mpCell->StartListeningTo( rDoc );
231 mpCell->GetFormula(aFormula, eGrammar);
243 return mpCell->GetValue();
245 return std::numeric_limits<double>::max();
266 mpCell->UpdateReference(rCxt);
279 mpCell->UpdateInsertTab(rCxt);
292 mpCell->UpdateDeleteTab(rCxt);
306 mpCell->UpdateMoveTab(rCxt, nTabNo);
378 for(
const auto& rxEntry : rFormat)
395 for (
auto itr =
begin(), itrEnd =
end(); itr != itrEnd; ++itr)
397 (*itr)->SetRepaintCallback(pFormat);
410 ScColorScaleEntries::const_iterator itr =
maColorScales.begin();
413 return (*itr)->GetValue();
422 ScColorScaleEntries::const_reverse_iterator itr =
maColorScales.rbegin();
425 return (*itr)->GetValue();
448 std::vector<double>& rValues =
mpCache->maValues;
452 for(
size_t i = 0;
i < n; ++
i)
454 const ScRange & rRange = aRanges[
i];
464 bool bShrunk =
false;
466 nColEnd, nRowEnd,
false);
468 for(
SCCOL nCol = nColStart; nCol <= nColEnd; ++nCol)
470 for(
SCROW nRow = nRowStart; nRow <= nRowEnd; ++nRow)
477 rValues.push_back(aVal);
483 std::sort(rValues.begin(), rValues.end());
491 std::vector<double>& rValues =
getValues();
499 std::vector<double>& rValues =
getValues();
502 return rValues[rValues.size()-1];
525 sal_uInt8 nColVal =
static_cast<int>((nVal - nVal1)/(nVal2-nVal1)*(nColVal2-nColVal1))+nColVal1;
529 Color CalcColor(
double nVal,
double nVal1,
const Color& rCol1,
double nVal2,
const Color& rCol2)
535 return Color(nColRed, nColGreen, nColBlue);
542 double GetPercentile(
const std::vector<double>& rArray,
double fPercentile )
544 size_t nSize = rArray.size();
545 size_t nIndex =
static_cast<size_t>(::rtl::math::approxFloor( fPercentile * (nSize-1)));
546 double fDiff = fPercentile * (nSize-1) - ::rtl::math::approxFloor( fPercentile * (nSize-1));
547 std::vector<double>::const_iterator iter = rArray.begin() + nIndex;
553 iter = rArray.begin() + nIndex+1;
554 return fVal + fDiff * (*iter - fVal);
562 switch((*itr)->GetType())
565 return nMin + (nMax-nMin)*((*itr)->GetValue()/100);
572 std::vector<double>& rValues =
getValues();
573 if(rValues.size() == 1)
577 double fPercentile = (*itr)->GetValue()/100.0;
578 return GetPercentile(rValues, fPercentile);
586 return (*itr)->GetValue();
593 return std::optional<Color>();
599 return std::optional<Color>();
601 double nMin = std::numeric_limits<double>::max();
602 double nMax = std::numeric_limits<double>::min();
607 return std::optional<Color>();
609 ScColorScaleEntries::const_iterator itr =
begin();
610 double nValMin =
CalcValue(nMin, nMax, itr);
611 Color rColMin = (*itr)->GetColor();
613 double nValMax =
CalcValue(nMin, nMax, itr);
614 Color rColMax = (*itr)->GetColor();
617 while(itr !=
end() && nVal > nValMax)
621 rColMax = (*itr)->GetColor();
626 Color aColor = CalcColor(nVal, nValMin, rColMin, nValMax, rColMax);
633 for(ScColorScaleEntries::iterator itr =
begin(); itr !=
end(); ++itr)
634 (*itr)->UpdateReference(rCxt);
639 for (ScColorScaleEntries::iterator it =
begin(); it !=
end(); ++it)
640 (*it)->UpdateInsertTab(rCxt);
645 for (ScColorScaleEntries::iterator it =
begin(); it !=
end(); ++it)
646 (*it)->UpdateDeleteTab(rCxt);
651 for (ScColorScaleEntries::iterator it =
begin(); it !=
end(); ++it)
652 (*it)->UpdateMoveTab(rCxt);
750 mpFormatData->mpUpperLimit->SetRepaintCallback(pFormat);
751 mpFormatData->mpLowerLimit->SetRepaintCallback(pFormat);
793 return std::min<double>(0, nMin);
796 return nMin + (nMax-nMin)/100*
mpFormatData->mpLowerLimit->GetValue();
800 double fPercentile =
mpFormatData->mpLowerLimit->GetValue()/100.0;
801 std::vector<double>& rValues =
getValues();
802 return GetPercentile(rValues, fPercentile);
819 return std::max<double>(0, nMax);
821 return nMin + (nMax-nMin)/100*
mpFormatData->mpUpperLimit->GetValue();
824 double fPercentile =
mpFormatData->mpUpperLimit->GetValue()/100.0;
825 std::vector<double>& rValues =
getValues();
826 return GetPercentile(rValues, fPercentile);
846 double nMin =
getMin(nValMin, nValMax);
847 double nMax =
getMax(nValMin, nValMax);
858 pInfo->mnLength = nMinLength;
860 else if(nValue >= nMax)
862 pInfo->mnLength = nMaxLength;
866 double nDiff = nMax - nMin;
867 pInfo->mnLength = nMinLength + (nValue - nMin)/nDiff * (nMaxLength-nMinLength);
887 pInfo->mnZero = -100*nMin/(nMax-nMin);
893 double nMinNonNegative = std::max(0.0, nMin);
894 double nMaxNonPositive = std::min(0.0, nMax);
896 if(nValue < 0 && nMin < 0)
899 pInfo->mnLength = -100;
901 pInfo->mnLength = -100 * (nValue-nMaxNonPositive)/(nMin-nMaxNonPositive);
906 pInfo->mnLength = 100;
907 else if (nValue <= nMin)
910 pInfo->mnLength = 100 * (nValue-nMinNonNegative)/(nMax-nMinNonNegative);
916 double nAbsMax = std::max(std::abs(nMin), std::abs(nMax));
917 if (nValue < 0 && nMin < 0)
920 pInfo->mnLength = nMaxLength * (nMin/nAbsMax);
922 pInfo->mnLength = nMaxLength * (nValue/nAbsMax);
927 pInfo->mnLength = nMaxLength * (nMax/nAbsMax);
929 pInfo->mnLength = nMaxLength * (std::max(nValue, nMin)/nAbsMax);
972 : eIconSetType(rOther.eIconSetType)
973 , mbShowValue(rOther.mbShowValue)
975 , mbCustom(rOther.mbCustom)
976 , maCustomVector(rOther.maCustomVector)
1006 (*itr)->SetRepaintCallback(pFormat);
1042 sal_Int32 nIndex = 0;
1045 double nValMax =
CalcValue(nMin, nMax, itr);
1048 while(itr !=
end() && nVal >= nValMax)
1062 sal_Int32 nMaxIndex =
mpFormatData->m_Entries.size() - 1;
1063 nIndex = nMaxIndex - nIndex;
1069 sal_Int32 nCustomIndex =
mpFormatData->maCustomVector[nIndex].second;
1070 if (nCustomIndex == -1)
1075 pInfo->eIconSetType = eCustomType;
1076 pInfo->nIconIndex = nCustomIndex;
1080 pInfo->nIconIndex = nIndex;
1097 (*itr)->UpdateReference(rCxt);
1105 (*itr)->UpdateInsertTab(rCxt);
1113 (*itr)->UpdateDeleteTab(rCxt);
1121 (*itr)->UpdateMoveTab(rCxt);
1150 return (*itr)->GetValue();
1162 return (*itr)->GetValue();
1171 switch ((*itr)->GetType())
1174 return nMin + (nMax-nMin)*((*itr)->GetValue()/100);
1181 std::vector<double>& rValues =
getValues();
1182 if(rValues.size() == 1)
1186 double fPercentile = (*itr)->GetValue()/100.0;
1187 return GetPercentile(rValues, fPercentile);
1195 return (*itr)->GetValue();
1232 const std::u16string_view a3TrafficLights1[] = {
1233 u"" BMP_ICON_SET_CIRCLES1_RED,
u"" BMP_ICON_SET_CIRCLES1_YELLOW,
u"" BMP_ICON_SET_CIRCLES1_GREEN
1236 const std::u16string_view a3TrafficLights2[] = {
1237 u"" BMP_ICON_SET_TRAFFICLIGHTS_RED,
u"" BMP_ICON_SET_TRAFFICLIGHTS_YELLOW,
u"" BMP_ICON_SET_TRAFFICLIGHTS_GREEN
1240 const std::u16string_view a3Arrows[] = {
1241 u"" BMP_ICON_SET_COLORARROWS_DOWN,
u"" BMP_ICON_SET_COLORARROWS_SAME,
u"" BMP_ICON_SET_COLORARROWS_UP
1244 const std::u16string_view a3ArrowsGray[] = {
1245 u"" BMP_ICON_SET_GRAYARROWS_DOWN,
u"" BMP_ICON_SET_GRAYARROWS_SAME,
u"" BMP_ICON_SET_GRAYARROWS_UP
1248 const std::u16string_view a3Flags[] = {
1249 u"" BMP_ICON_SET_FLAGS_RED,
u"" BMP_ICON_SET_FLAGS_YELLOW,
u"" BMP_ICON_SET_FLAGS_GREEN
1252 const std::u16string_view a3Smilies[] = {
1253 u"" BMP_ICON_SET_POSITIVE_YELLOW_SMILIE,
u"" BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE,
u"" BMP_ICON_SET_NEGATIVE_YELLOW_SMILIE
1256 const std::u16string_view a3ColorSmilies[] = {
1257 u"" BMP_ICON_SET_POSITIVE_GREEN_SMILIE,
u"" BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE,
u"" BMP_ICON_SET_NEGATIVE_RED_SMILIE
1260 const std::u16string_view a3Stars[] = {
1261 u"" BMP_ICON_SET_STARS_EMPTY,
u"" BMP_ICON_SET_STARS_HALF,
u"" BMP_ICON_SET_STARS_FULL
1264 const std::u16string_view a3Triangles[] = {
1265 u"" BMP_ICON_SET_TRIANGLES_DOWN,
u"" BMP_ICON_SET_TRIANGLES_SAME,
u"" BMP_ICON_SET_TRIANGLES_UP
1268 const std::u16string_view a4Arrows[] = {
1269 u"" BMP_ICON_SET_COLORARROWS_DOWN,
u"" BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN,
u"" BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP,
u"" BMP_ICON_SET_COLORARROWS_UP
1272 const std::u16string_view a4ArrowsGray[] = {
1273 u"" BMP_ICON_SET_GRAYARROWS_DOWN,
u"" BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN,
u"" BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP,
u"" BMP_ICON_SET_GRAYARROWS_UP
1276 const std::u16string_view a5Arrows[] = {
1277 u"" BMP_ICON_SET_COLORARROWS_DOWN,
u"" BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN,
1278 u"" BMP_ICON_SET_COLORARROWS_SAME,
u"" BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP,
u"" BMP_ICON_SET_COLORARROWS_UP
1281 const std::u16string_view a5ArrowsGray[] = {
1282 u"" BMP_ICON_SET_GRAYARROWS_DOWN,
u"" BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN,
1283 u"" BMP_ICON_SET_GRAYARROWS_SAME,
u"" BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP,
u"" BMP_ICON_SET_GRAYARROWS_UP
1286 const std::u16string_view a4TrafficLights[] = {
1287 u"" BMP_ICON_SET_CIRCLES1_GRAY,
u"" BMP_ICON_SET_CIRCLES1_RED,
1288 u"" BMP_ICON_SET_CIRCLES1_YELLOW,
u"" BMP_ICON_SET_CIRCLES1_GREEN
1291 const std::u16string_view a5Quarters[] = {
1292 u"" BMP_ICON_SET_PIES_EMPTY,
u"" BMP_ICON_SET_PIES_ONE_QUARTER,
u"" BMP_ICON_SET_PIES_HALF,
1293 u"" BMP_ICON_SET_PIES_THREE_QUARTER,
u"" BMP_ICON_SET_PIES_FULL,
1296 const std::u16string_view a5Boxes[] = {
1297 u"" BMP_ICON_SET_SQUARES_EMPTY,
u"" BMP_ICON_SET_SQUARES_ONE_QUARTER,
1298 u"" BMP_ICON_SET_SQUARES_HALF,
u"" BMP_ICON_SET_SQUARES_THREE_QUARTER,
1299 u"" BMP_ICON_SET_SQUARES_FULL
1302 const std::u16string_view a3Symbols1[] = {
1303 u"" BMP_ICON_SET_SYMBOLS1_CROSS,
u"" BMP_ICON_SET_SYMBOLS1_EXCLAMATION_MARK,
u"" BMP_ICON_SET_SYMBOLS1_CHECK
1306 const std::u16string_view a3Signs[] = {
1307 u"" BMP_ICON_SET_SHAPES_DIAMOND,
u"" BMP_ICON_SET_SHAPES_TRIANGLE,
u"" BMP_ICON_SET_SHAPES_CIRCLE
1310 const std::u16string_view a4RedToBlack[] = {
1311 u"" BMP_ICON_SET_CIRCLES2_DARK_GRAY,
u"" BMP_ICON_SET_CIRCLES2_LIGHT_GRAY,
1312 u"" BMP_ICON_SET_CIRCLES2_LIGHT_RED,
u"" BMP_ICON_SET_CIRCLES2_DARK_RED
1315 const std::u16string_view a4Ratings[] = {
1316 u"" BMP_ICON_SET_BARS_ONE_QUARTER,
u"" BMP_ICON_SET_BARS_HALF,
1317 u"" BMP_ICON_SET_BARS_THREE_QUARTER,
u"" BMP_ICON_SET_BARS_FULL
1320 const std::u16string_view a5Ratings[] = {
1321 u"" BMP_ICON_SET_BARS_EMPTY,
u"" BMP_ICON_SET_BARS_ONE_QUARTER,
u"" BMP_ICON_SET_BARS_HALF,
1322 u"" BMP_ICON_SET_BARS_THREE_QUARTER,
u"" BMP_ICON_SET_BARS_FULL
1325 struct ScIconSetBitmapMap {
1327 const std::u16string_view* pBitmaps;
1330 const ScIconSetBitmapMap aBitmapMap[] = {
1358 for (; pMap->
pName; ++pMap)
1360 if (pMap->
eType == eType)
1391 for(
const ScIconSetBitmapMap &
i : aBitmapMap)
1393 if(
i.eType == eType)
1395 sBitmap = *(
i.pBitmaps + nIndex);
1400 assert(!sBitmap.isEmpty());
1410 std::map<OUString, BitmapEx>::iterator itr = rIconSetBitmapMap.find(sBitmap);
1411 if (itr != rIconSetBitmapMap.end())
1415 std::pair<OUString, BitmapEx> aPair(sBitmap, aBitmap);
1416 std::pair<std::map<OUString, BitmapEx>::iterator,
bool> itrNew = rIconSetBitmapMap.insert(aPair);
1419 return itrNew.first->second;
1427 if (
i.eType == eType)
ScConditionalFormat * mpFormat
void SetRepaintCallback(ScConditionalFormat *pParent)
ScColorScaleEntryType meType
Single reference (one address) into the sheet.
void UpdateInsertTab(const sc::RefUpdateInsertTabContext &rCxt)
ScAddress toAbs(const ScSheetLimits &rLimits, const ScAddress &rPos) const
Context for reference update during shifting, moving or copying of cell ranges.
SC_DLLPUBLIC void ExtendTo(const ScRange &rRange)
std::unique_ptr< ScFormulaCell > mpCell
SCTAB getNewTab(SCTAB nOldTab) const
If set, absolute refs will not transformed to external references.
bool IsClipOrUndo() const
This is very similar to ScCellValue, except that it references the original value instead of copying ...
void SetValue(double nValue)
~ScColorScaleEntry() COVERITY_NOEXCEPT_FALSE
const ScTokenArray * GetFormula() const
SC_DLLPUBLIC SCROW MaxRow() const
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
std::unique_ptr< ScFormulaListener > mpListener
void SetColor(const Color &)
std::map< OUString, BitmapEx > IconSetBitmapMap
sal_uInt8 GetBlue() const
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_LIGHTRED
SC_DLLPUBLIC SCCOL MaxCol() const
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.
void UpdateReference(const sc::RefUpdateContext &rCxt)
void SetFormula(const OUString &rFormula, ScDocument &rDoc, const ScAddress &rAddr, formula::FormulaGrammar::Grammar eGrammar=formula::FormulaGrammar::GRAM_DEFAULT)
RegionData_Impl * mpParent
sal_uInt8 GetGreen() const
void UpdateMoveTab(const sc::RefUpdateMoveTabContext &rCxt)
void UpdateDeleteTab(const sc::RefUpdateDeleteTabContext &rCxt)
void StartListeningArea(const ScRange &rRange, bool bGroupListening, SvtListener *pListener)
void SetType(ScColorScaleEntryType eType)