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();
665 while(itr !=
end() && (nVal > nValMax || bEqual))
668 nValMin = !bEqual ? nValMax : nValMax - 1;
669 rColMax = (*itr)->GetColor();
674 Color aColor = CalcColor(nVal, nValMin, rColMin, nValMax, rColMax);
681 for(ScColorScaleEntries::iterator itr =
begin(); itr !=
end(); ++itr)
682 (*itr)->UpdateReference(rCxt);
687 for (ScColorScaleEntries::iterator it =
begin(); it !=
end(); ++it)
688 (*it)->UpdateInsertTab(rCxt);
693 for (ScColorScaleEntries::iterator it =
begin(); it !=
end(); ++it)
694 (*it)->UpdateDeleteTab(rCxt);
699 for (ScColorScaleEntries::iterator it =
begin(); it !=
end(); ++it)
700 (*it)->UpdateMoveTab(rCxt);
798 mpFormatData->mpUpperLimit->SetRepaintCallback(pFormat);
799 mpFormatData->mpLowerLimit->SetRepaintCallback(pFormat);
826 bEq = (
mpFormatData->mpUpperLimit->GetColor().IsRGBEqual(
835 bEq = (
mpFormatData->mpLowerLimit->GetColor().IsRGBEqual(
876 return std::min<double>(0, nMin);
879 return nMin + (nMax-nMin)/100*
mpFormatData->mpLowerLimit->GetValue();
883 double fPercentile =
mpFormatData->mpLowerLimit->GetValue()/100.0;
884 std::vector<double>& rValues =
getValues();
885 return GetPercentile(rValues, fPercentile);
902 return std::max<double>(0, nMax);
904 return nMin + (nMax-nMin)/100*
mpFormatData->mpUpperLimit->GetValue();
907 double fPercentile =
mpFormatData->mpUpperLimit->GetValue()/100.0;
908 std::vector<double>& rValues =
getValues();
909 return GetPercentile(rValues, fPercentile);
929 double nMin =
getMin(nValMin, nValMax);
930 double nMax =
getMax(nValMin, nValMax);
941 pInfo->mnLength = nMinLength;
945 pInfo->mnLength = nMaxLength;
949 double nDiff = nMax - nMin;
950 pInfo->mnLength = nMinLength + (
nValue - nMin)/nDiff * (nMaxLength-nMinLength);
970 pInfo->mnZero = -100*nMin/(nMax-nMin);
976 double nMinNonNegative = std::max(0.0, nMin);
977 double nMaxNonPositive = std::min(0.0, nMax);
979 if(
nValue < 0 && nMin < 0)
982 pInfo->mnLength = -100;
984 pInfo->mnLength = -100 * (
nValue-nMaxNonPositive)/(nMin-nMaxNonPositive);
989 pInfo->mnLength = 100;
993 pInfo->mnLength = 100 * (
nValue-nMinNonNegative)/(nMax-nMinNonNegative);
999 double nAbsMax = std::max(std::abs(nMin), std::abs(nMax));
1000 if (
nValue < 0 && nMin < 0)
1003 pInfo->mnLength = nMaxLength * (nMin/nAbsMax);
1005 pInfo->mnLength = nMaxLength * (
nValue/nAbsMax);
1010 pInfo->mnLength = nMaxLength * (nMax/nAbsMax);
1012 pInfo->mnLength = nMaxLength * (std::max(
nValue, nMin)/nAbsMax);
1055 : eIconSetType(rOther.eIconSetType)
1056 , mbShowValue(rOther.mbShowValue)
1057 , mbReverse(rOther.mbReverse)
1058 , mbCustom(rOther.mbCustom)
1059 , maCustomVector(rOther.maCustomVector)
1089 (*itr)->SetRepaintCallback(pFormat);
1128 double nValMax =
CalcValue(nMin, nMax, itr);
1131 while(itr !=
end() && nVal >= nValMax)
1145 pInfo->mnHeight = aFontHeight;
1149 sal_Int32 nMaxIndex =
mpFormatData->m_Entries.size() - 1;
1157 if (nCustomIndex == -1)
1162 pInfo->eIconSetType = eCustomType;
1163 pInfo->nIconIndex = nCustomIndex;
1167 pInfo->nIconIndex =
nIndex;
1184 (*itr)->UpdateReference(rCxt);
1192 (*itr)->UpdateInsertTab(rCxt);
1200 (*itr)->UpdateDeleteTab(rCxt);
1208 (*itr)->UpdateMoveTab(rCxt);
1237 return (*itr)->GetValue();
1249 return (*itr)->GetValue();
1258 switch ((*itr)->GetType())
1261 return nMin + (nMax-nMin)*((*itr)->GetValue()/100);
1268 std::vector<double>& rValues =
getValues();
1269 if(rValues.size() == 1)
1273 double fPercentile = (*itr)->GetValue()/100.0;
1274 return GetPercentile(rValues, fPercentile);
1282 return (*itr)->GetValue();
1319constexpr rtl::OUStringConstExpr a3TrafficLights1[] = {
1320 BMP_ICON_SET_CIRCLES1_RED, BMP_ICON_SET_CIRCLES1_YELLOW, BMP_ICON_SET_CIRCLES1_GREEN
1323constexpr rtl::OUStringConstExpr a3TrafficLights2[] = {
1324 BMP_ICON_SET_TRAFFICLIGHTS_RED, BMP_ICON_SET_TRAFFICLIGHTS_YELLOW, BMP_ICON_SET_TRAFFICLIGHTS_GREEN
1327constexpr rtl::OUStringConstExpr a3Arrows[] = {
1328 BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SAME, BMP_ICON_SET_COLORARROWS_UP
1331constexpr rtl::OUStringConstExpr a3ArrowsGray[] = {
1332 BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SAME, BMP_ICON_SET_GRAYARROWS_UP
1335constexpr rtl::OUStringConstExpr a3Flags[] = {
1336 BMP_ICON_SET_FLAGS_RED, BMP_ICON_SET_FLAGS_YELLOW, BMP_ICON_SET_FLAGS_GREEN
1339constexpr rtl::OUStringConstExpr a3Smilies[] = {
1340 BMP_ICON_SET_POSITIVE_YELLOW_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_NEGATIVE_YELLOW_SMILIE
1343constexpr rtl::OUStringConstExpr a3ColorSmilies[] = {
1344 BMP_ICON_SET_POSITIVE_GREEN_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_NEGATIVE_RED_SMILIE
1347constexpr rtl::OUStringConstExpr a3Stars[] = {
1348 BMP_ICON_SET_STARS_EMPTY, BMP_ICON_SET_STARS_HALF, BMP_ICON_SET_STARS_FULL
1351constexpr rtl::OUStringConstExpr a3Triangles[] = {
1352 BMP_ICON_SET_TRIANGLES_DOWN, BMP_ICON_SET_TRIANGLES_SAME, BMP_ICON_SET_TRIANGLES_UP
1355constexpr rtl::OUStringConstExpr a4Arrows[] = {
1356 BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP, BMP_ICON_SET_COLORARROWS_UP
1359constexpr rtl::OUStringConstExpr a4ArrowsGray[] = {
1360 BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP, BMP_ICON_SET_GRAYARROWS_UP
1363constexpr rtl::OUStringConstExpr a5Arrows[] = {
1364 BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN,
1365 BMP_ICON_SET_COLORARROWS_SAME, BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP, BMP_ICON_SET_COLORARROWS_UP
1368constexpr rtl::OUStringConstExpr a5ArrowsGray[] = {
1369 BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN,
1370 BMP_ICON_SET_GRAYARROWS_SAME, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP, BMP_ICON_SET_GRAYARROWS_UP
1373constexpr rtl::OUStringConstExpr a4TrafficLights[] = {
1374 BMP_ICON_SET_CIRCLES1_GRAY, BMP_ICON_SET_CIRCLES1_RED,
1375 BMP_ICON_SET_CIRCLES1_YELLOW, BMP_ICON_SET_CIRCLES1_GREEN
1378constexpr rtl::OUStringConstExpr a5Quarters[] = {
1379 BMP_ICON_SET_PIES_EMPTY, BMP_ICON_SET_PIES_ONE_QUARTER, BMP_ICON_SET_PIES_HALF,
1380 BMP_ICON_SET_PIES_THREE_QUARTER, BMP_ICON_SET_PIES_FULL,
1383constexpr rtl::OUStringConstExpr a5Boxes[] = {
1384 BMP_ICON_SET_SQUARES_EMPTY, BMP_ICON_SET_SQUARES_ONE_QUARTER,
1385 BMP_ICON_SET_SQUARES_HALF, BMP_ICON_SET_SQUARES_THREE_QUARTER,
1386 BMP_ICON_SET_SQUARES_FULL
1389constexpr rtl::OUStringConstExpr a3Symbols1[] = {
1390 BMP_ICON_SET_SYMBOLS1_CROSS, BMP_ICON_SET_SYMBOLS1_EXCLAMATION_MARK, BMP_ICON_SET_SYMBOLS1_CHECK
1393constexpr rtl::OUStringConstExpr a3Signs[] = {
1394 BMP_ICON_SET_SHAPES_DIAMOND, BMP_ICON_SET_SHAPES_TRIANGLE, BMP_ICON_SET_SHAPES_CIRCLE
1397constexpr rtl::OUStringConstExpr a4RedToBlack[] = {
1398 BMP_ICON_SET_CIRCLES2_DARK_GRAY, BMP_ICON_SET_CIRCLES2_LIGHT_GRAY,
1399 BMP_ICON_SET_CIRCLES2_LIGHT_RED, BMP_ICON_SET_CIRCLES2_DARK_RED
1402constexpr rtl::OUStringConstExpr a4Ratings[] = {
1403 BMP_ICON_SET_BARS_ONE_QUARTER, BMP_ICON_SET_BARS_HALF,
1404 BMP_ICON_SET_BARS_THREE_QUARTER, BMP_ICON_SET_BARS_FULL
1407constexpr rtl::OUStringConstExpr a5Ratings[] = {
1408 BMP_ICON_SET_BARS_EMPTY, BMP_ICON_SET_BARS_ONE_QUARTER, BMP_ICON_SET_BARS_HALF,
1409 BMP_ICON_SET_BARS_THREE_QUARTER, BMP_ICON_SET_BARS_FULL
1412struct ScIconSetBitmapMap {
1414 const rtl::OUStringConstExpr* pBitmaps;
1417const ScIconSetBitmapMap aBitmapMap[] = {
1445 for (; pMap->
pName; ++pMap)
1447 if (pMap->
eType == eType)
1478 for(
const ScIconSetBitmapMap &
i : aBitmapMap)
1482 sBitmap = *(
i.pBitmaps +
nIndex);
1487 assert(!sBitmap.isEmpty());
1497 std::map<OUString, BitmapEx>::iterator itr = rIconSetBitmapMap.find(sBitmap);
1498 if (itr != rIconSetBitmapMap.end())
1502 std::pair<OUString, BitmapEx> aPair(sBitmap, aBitmap);
1503 std::pair<std::map<OUString, BitmapEx>::iterator,
bool> itrNew = rIconSetBitmapMap.insert(aPair);
1504 assert(itrNew.second);
1506 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