12#include <document.hxx>
15#include <bitmaps.hlst>
16#include <tokenarray.hxx>
30 mrDoc(pCell->GetDocument())
74 ScRange aRange1(aCell1, aCell3);
75 ScRange aRange2(aCell2, aCell4);
140 if (rHint.
GetId() == SfxHintId::Dying)
171 mpFormat(rEntry.mpFormat),
186 mpFormat(rEntry.mpFormat),
194 mpCell->StartListeningTo( *pDoc );
210 mpCell->StartListeningTo( rDoc );
230 return mpCell->GetFormula(eGrammar);
242 return mpCell->GetValue();
244 return std::numeric_limits<double>::max();
265 mpCell->UpdateReference(rCxt);
278 mpCell->UpdateInsertTab(rCxt);
291 mpCell->UpdateDeleteTab(rCxt);
305 mpCell->UpdateMoveTab(rCxt, nTabNo);
377 for(
const auto& rxEntry : rFormat)
397 for (
auto itr =
begin(), itrEnd =
end(); itr != itrEnd; ++itr)
399 (*itr)->SetRepaintCallback(pFormat);
430 ScColorScaleEntries::const_iterator itr =
maColorScales.begin();
433 return (*itr)->GetValue();
442 ScColorScaleEntries::const_reverse_iterator itr =
maColorScales.rbegin();
445 return (*itr)->GetValue();
465 std::vector<double> empty;
480 std::vector<double>& rValues =
mpCache->maValues;
484 for(
size_t i = 0;
i <
n; ++
i)
486 const ScRange & rRange = aRanges[
i];
496 bool bShrunk =
false;
498 nColEnd, nRowEnd,
false);
500 for(
SCCOL nCol = nColStart; nCol <= nColEnd; ++nCol)
502 for(
SCROW nRow = nRowStart; nRow <= nRowEnd; ++nRow)
509 rValues.push_back(aVal);
515 std::sort(rValues.begin(), rValues.end());
523 std::vector<double>& rValues =
getValues();
531 std::vector<double>& rValues =
getValues();
534 return rValues[rValues.size()-1];
563 sal_uInt8 nColVal =
static_cast<int>((nVal - nVal1)/(nVal2-nVal1)*(nColVal2-nColVal1))+nColVal1;
567Color CalcColor(
double nVal,
double nVal1,
const Color& rCol1,
double nVal2,
const Color& rCol2)
573 return Color(nColRed, nColGreen, nColBlue);
580double GetPercentile(
const std::vector<double>& rArray,
double fPercentile )
582 assert(!rArray.empty());
583 SAL_WARN_IF(fPercentile < 0,
"sc",
"negative percentile");
585 return rArray.front();
586 assert(fPercentile <= 1);
587 size_t nSize = rArray.size();
588 double fFloor = ::rtl::math::approxFloor(fPercentile * (nSize-1));
589 size_t nIndex =
static_cast<size_t>(fFloor);
590 double fDiff = fPercentile * (nSize-1) - fFloor;
591 std::vector<double>::const_iterator iter = rArray.begin() +
nIndex;
597 iter = rArray.begin() +
nIndex+1;
598 return fVal + fDiff * (*iter - fVal);
606 switch((*itr)->GetType())
609 return nMin + (nMax-nMin)*((*itr)->GetValue()/100);
616 std::vector<double>& rValues =
getValues();
617 if(rValues.size() == 1)
621 double fPercentile = (*itr)->GetValue()/100.0;
622 return GetPercentile(rValues, fPercentile);
630 return (*itr)->GetValue();
637 return std::optional<Color>();
643 return std::optional<Color>();
645 double nMin = std::numeric_limits<double>::max();
646 double nMax = std::numeric_limits<double>::min();
651 return std::optional<Color>();
653 ScColorScaleEntries::const_iterator itr =
begin();
654 double nValMin =
CalcValue(nMin, nMax, itr);
655 Color rColMin = (*itr)->GetColor();
657 double nValMax =
CalcValue(nMin, nMax, itr);
658 Color rColMax = (*itr)->GetColor();
661 while(itr !=
end() && nVal > nValMax)
665 rColMax = (*itr)->GetColor();
670 Color aColor = CalcColor(nVal, nValMin, rColMin, nValMax, rColMax);
677 for(ScColorScaleEntries::iterator itr =
begin(); itr !=
end(); ++itr)
678 (*itr)->UpdateReference(rCxt);
683 for (ScColorScaleEntries::iterator it =
begin(); it !=
end(); ++it)
684 (*it)->UpdateInsertTab(rCxt);
689 for (ScColorScaleEntries::iterator it =
begin(); it !=
end(); ++it)
690 (*it)->UpdateDeleteTab(rCxt);
695 for (ScColorScaleEntries::iterator it =
begin(); it !=
end(); ++it)
696 (*it)->UpdateMoveTab(rCxt);
794 mpFormatData->mpUpperLimit->SetRepaintCallback(pFormat);
795 mpFormatData->mpLowerLimit->SetRepaintCallback(pFormat);
822 bEq = (
mpFormatData->mpUpperLimit->GetColor().IsRGBEqual(
831 bEq = (
mpFormatData->mpLowerLimit->GetColor().IsRGBEqual(
872 return std::min<double>(0, nMin);
875 return nMin + (nMax-nMin)/100*
mpFormatData->mpLowerLimit->GetValue();
879 double fPercentile =
mpFormatData->mpLowerLimit->GetValue()/100.0;
880 std::vector<double>& rValues =
getValues();
881 return GetPercentile(rValues, fPercentile);
898 return std::max<double>(0, nMax);
900 return nMin + (nMax-nMin)/100*
mpFormatData->mpUpperLimit->GetValue();
903 double fPercentile =
mpFormatData->mpUpperLimit->GetValue()/100.0;
904 std::vector<double>& rValues =
getValues();
905 return GetPercentile(rValues, fPercentile);
925 double nMin =
getMin(nValMin, nValMax);
926 double nMax =
getMax(nValMin, nValMax);
937 pInfo->mnLength = nMinLength;
941 pInfo->mnLength = nMaxLength;
945 double nDiff = nMax - nMin;
946 pInfo->mnLength = nMinLength + (
nValue - nMin)/nDiff * (nMaxLength-nMinLength);
966 pInfo->mnZero = -100*nMin/(nMax-nMin);
972 double nMinNonNegative = std::max(0.0, nMin);
973 double nMaxNonPositive = std::min(0.0, nMax);
975 if(
nValue < 0 && nMin < 0)
978 pInfo->mnLength = -100;
980 pInfo->mnLength = -100 * (
nValue-nMaxNonPositive)/(nMin-nMaxNonPositive);
985 pInfo->mnLength = 100;
989 pInfo->mnLength = 100 * (
nValue-nMinNonNegative)/(nMax-nMinNonNegative);
995 double nAbsMax = std::max(std::abs(nMin), std::abs(nMax));
996 if (
nValue < 0 && nMin < 0)
999 pInfo->mnLength = nMaxLength * (nMin/nAbsMax);
1001 pInfo->mnLength = nMaxLength * (
nValue/nAbsMax);
1006 pInfo->mnLength = nMaxLength * (nMax/nAbsMax);
1008 pInfo->mnLength = nMaxLength * (std::max(
nValue, nMin)/nAbsMax);
1051 : eIconSetType(rOther.eIconSetType)
1052 , mbShowValue(rOther.mbShowValue)
1053 , mbReverse(rOther.mbReverse)
1054 , mbCustom(rOther.mbCustom)
1055 , maCustomVector(rOther.maCustomVector)
1085 (*itr)->SetRepaintCallback(pFormat);
1124 double nValMax =
CalcValue(nMin, nMax, itr);
1127 while(itr !=
end() && nVal >= nValMax)
1141 pInfo->mnHeight = aFontHeight;
1145 sal_Int32 nMaxIndex =
mpFormatData->m_Entries.size() - 1;
1153 if (nCustomIndex == -1)
1158 pInfo->eIconSetType = eCustomType;
1159 pInfo->nIconIndex = nCustomIndex;
1163 pInfo->nIconIndex =
nIndex;
1180 (*itr)->UpdateReference(rCxt);
1188 (*itr)->UpdateInsertTab(rCxt);
1196 (*itr)->UpdateDeleteTab(rCxt);
1204 (*itr)->UpdateMoveTab(rCxt);
1233 return (*itr)->GetValue();
1245 return (*itr)->GetValue();
1254 switch ((*itr)->GetType())
1257 return nMin + (nMax-nMin)*((*itr)->GetValue()/100);
1264 std::vector<double>& rValues =
getValues();
1265 if(rValues.size() == 1)
1269 double fPercentile = (*itr)->GetValue()/100.0;
1270 return GetPercentile(rValues, fPercentile);
1278 return (*itr)->GetValue();
1315constexpr rtl::OUStringConstExpr a3TrafficLights1[] = {
1316 BMP_ICON_SET_CIRCLES1_RED, BMP_ICON_SET_CIRCLES1_YELLOW, BMP_ICON_SET_CIRCLES1_GREEN
1319constexpr rtl::OUStringConstExpr a3TrafficLights2[] = {
1320 BMP_ICON_SET_TRAFFICLIGHTS_RED, BMP_ICON_SET_TRAFFICLIGHTS_YELLOW, BMP_ICON_SET_TRAFFICLIGHTS_GREEN
1323constexpr rtl::OUStringConstExpr a3Arrows[] = {
1324 BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SAME, BMP_ICON_SET_COLORARROWS_UP
1327constexpr rtl::OUStringConstExpr a3ArrowsGray[] = {
1328 BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SAME, BMP_ICON_SET_GRAYARROWS_UP
1331constexpr rtl::OUStringConstExpr a3Flags[] = {
1332 BMP_ICON_SET_FLAGS_RED, BMP_ICON_SET_FLAGS_YELLOW, BMP_ICON_SET_FLAGS_GREEN
1335constexpr rtl::OUStringConstExpr a3Smilies[] = {
1336 BMP_ICON_SET_POSITIVE_YELLOW_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_NEGATIVE_YELLOW_SMILIE
1339constexpr rtl::OUStringConstExpr a3ColorSmilies[] = {
1340 BMP_ICON_SET_POSITIVE_GREEN_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_NEGATIVE_RED_SMILIE
1343constexpr rtl::OUStringConstExpr a3Stars[] = {
1344 BMP_ICON_SET_STARS_EMPTY, BMP_ICON_SET_STARS_HALF, BMP_ICON_SET_STARS_FULL
1347constexpr rtl::OUStringConstExpr a3Triangles[] = {
1348 BMP_ICON_SET_TRIANGLES_DOWN, BMP_ICON_SET_TRIANGLES_SAME, BMP_ICON_SET_TRIANGLES_UP
1351constexpr rtl::OUStringConstExpr a4Arrows[] = {
1352 BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP, BMP_ICON_SET_COLORARROWS_UP
1355constexpr rtl::OUStringConstExpr a4ArrowsGray[] = {
1356 BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP, BMP_ICON_SET_GRAYARROWS_UP
1359constexpr rtl::OUStringConstExpr a5Arrows[] = {
1360 BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN,
1361 BMP_ICON_SET_COLORARROWS_SAME, BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP, BMP_ICON_SET_COLORARROWS_UP
1364constexpr rtl::OUStringConstExpr a5ArrowsGray[] = {
1365 BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN,
1366 BMP_ICON_SET_GRAYARROWS_SAME, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP, BMP_ICON_SET_GRAYARROWS_UP
1369constexpr rtl::OUStringConstExpr a4TrafficLights[] = {
1370 BMP_ICON_SET_CIRCLES1_GRAY, BMP_ICON_SET_CIRCLES1_RED,
1371 BMP_ICON_SET_CIRCLES1_YELLOW, BMP_ICON_SET_CIRCLES1_GREEN
1374constexpr rtl::OUStringConstExpr a5Quarters[] = {
1375 BMP_ICON_SET_PIES_EMPTY, BMP_ICON_SET_PIES_ONE_QUARTER, BMP_ICON_SET_PIES_HALF,
1376 BMP_ICON_SET_PIES_THREE_QUARTER, BMP_ICON_SET_PIES_FULL,
1379constexpr rtl::OUStringConstExpr a5Boxes[] = {
1380 BMP_ICON_SET_SQUARES_EMPTY, BMP_ICON_SET_SQUARES_ONE_QUARTER,
1381 BMP_ICON_SET_SQUARES_HALF, BMP_ICON_SET_SQUARES_THREE_QUARTER,
1382 BMP_ICON_SET_SQUARES_FULL
1385constexpr rtl::OUStringConstExpr a3Symbols1[] = {
1386 BMP_ICON_SET_SYMBOLS1_CROSS, BMP_ICON_SET_SYMBOLS1_EXCLAMATION_MARK, BMP_ICON_SET_SYMBOLS1_CHECK
1389constexpr rtl::OUStringConstExpr a3Signs[] = {
1390 BMP_ICON_SET_SHAPES_DIAMOND, BMP_ICON_SET_SHAPES_TRIANGLE, BMP_ICON_SET_SHAPES_CIRCLE
1393constexpr rtl::OUStringConstExpr a4RedToBlack[] = {
1394 BMP_ICON_SET_CIRCLES2_DARK_GRAY, BMP_ICON_SET_CIRCLES2_LIGHT_GRAY,
1395 BMP_ICON_SET_CIRCLES2_LIGHT_RED, BMP_ICON_SET_CIRCLES2_DARK_RED
1398constexpr rtl::OUStringConstExpr a4Ratings[] = {
1399 BMP_ICON_SET_BARS_ONE_QUARTER, BMP_ICON_SET_BARS_HALF,
1400 BMP_ICON_SET_BARS_THREE_QUARTER, BMP_ICON_SET_BARS_FULL
1403constexpr rtl::OUStringConstExpr a5Ratings[] = {
1404 BMP_ICON_SET_BARS_EMPTY, BMP_ICON_SET_BARS_ONE_QUARTER, BMP_ICON_SET_BARS_HALF,
1405 BMP_ICON_SET_BARS_THREE_QUARTER, BMP_ICON_SET_BARS_FULL
1408struct ScIconSetBitmapMap {
1410 const rtl::OUStringConstExpr* pBitmaps;
1413const ScIconSetBitmapMap aBitmapMap[] = {
1441 for (; pMap->
pName; ++pMap)
1443 if (pMap->
eType == eType)
1474 for(
const ScIconSetBitmapMap &
i : aBitmapMap)
1478 sBitmap = *(
i.pBitmaps +
nIndex);
1483 assert(!sBitmap.isEmpty());
1493 std::map<OUString, BitmapEx>::iterator itr = rIconSetBitmapMap.find(sBitmap);
1494 if (itr != rIconSetBitmapMap.end())
1498 std::pair<OUString, BitmapEx> aPair(sBitmap, aBitmap);
1499 std::pair<std::map<OUString, BitmapEx>::iterator,
bool> itrNew = rIconSetBitmapMap.insert(aPair);
1500 assert(itrNew.second);
1502 return itrNew.first->second;
sal_uInt8 GetBlue() const
sal_uInt8 GetGreen() const
void UpdateInsertTab(const sc::RefUpdateInsertTabContext &rCxt)
const ScTokenArray * GetFormula() const
void SetType(ScColorScaleEntryType eType)
std::unique_ptr< ScFormulaListener > mpListener
void SetRepaintCallback(ScConditionalFormat *pParent)
ScColorScaleEntryType meType
void SetFormula(const OUString &rFormula, ScDocument &rDoc, const ScAddress &rAddr, formula::FormulaGrammar::Grammar eGrammar=formula::FormulaGrammar::GRAM_DEFAULT)
void UpdateMoveTab(const sc::RefUpdateMoveTabContext &rCxt)
void UpdateReference(const sc::RefUpdateContext &rCxt)
void SetValue(double nValue)
void UpdateDeleteTab(const sc::RefUpdateDeleteTabContext &rCxt)
void SetColor(const Color &)
std::unique_ptr< ScFormulaCell > mpCell
ScConditionalFormat * mpFormat
~ScColorScaleEntry() COVERITY_NOEXCEPT_FALSE
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC SCROW MaxRow() const
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.
void StartListeningArea(const ScRange &rRange, bool bGroupListening, SvtListener *pListener)
bool IsClipOrUndo() const
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
virtual Type GetType() const =0
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
void ExtendTo(const ScRange &rRange)
constexpr ::Color COL_LIGHTRED(0xFF, 0x00, 0x00)
@ IconSet_3TrafficLights1
@ IconSet_3TrafficLights2
RegionData_Impl * mpParent
@ NoMakeAbsExternal
If set, absolute refs will not transformed to external references.
#define SAL_WARN_IF(condition, area, stream)
std::unique_ptr< sal_Int32[]> pData
std::map< OUString, BitmapEx > IconSetBitmapMap
constexpr TypedWhichId< SvxFontHeightItem > ATTR_FONT_HEIGHT(101)
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Single reference (one address) into the sheet.
ScAddress toAbs(const ScSheetLimits &rLimits, const ScAddress &rPos) const
Context for reference update during shifting, moving or copying of cell ranges.
SCTAB getNewTab(SCTAB nOldTab) const