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)
394 for (
auto itr =
begin(), itrEnd =
end(); itr != itrEnd; ++itr)
396 (*itr)->SetRepaintCallback(pFormat);
409 ScColorScaleEntries::const_iterator itr =
maColorScales.begin();
412 return (*itr)->GetValue();
421 ScColorScaleEntries::const_reverse_iterator itr =
maColorScales.rbegin();
424 return (*itr)->GetValue();
447 std::vector<double>& rValues =
mpCache->maValues;
451 for(
size_t i = 0;
i <
n; ++
i)
453 const ScRange & rRange = aRanges[
i];
463 bool bShrunk =
false;
465 nColEnd, nRowEnd,
false);
467 for(
SCCOL nCol = nColStart; nCol <= nColEnd; ++nCol)
469 for(
SCROW nRow = nRowStart; nRow <= nRowEnd; ++nRow)
476 rValues.push_back(aVal);
482 std::sort(rValues.begin(), rValues.end());
490 std::vector<double>& rValues =
getValues();
498 std::vector<double>& rValues =
getValues();
501 return rValues[rValues.size()-1];
524 sal_uInt8 nColVal =
static_cast<int>((nVal - nVal1)/(nVal2-nVal1)*(nColVal2-nColVal1))+nColVal1;
528Color CalcColor(
double nVal,
double nVal1,
const Color& rCol1,
double nVal2,
const Color& rCol2)
534 return Color(nColRed, nColGreen, nColBlue);
541double GetPercentile(
const std::vector<double>& rArray,
double fPercentile )
543 assert(!rArray.empty());
544 SAL_WARN_IF(fPercentile < 0,
"sc",
"negative percentile");
546 return rArray.front();
547 assert(fPercentile <= 1);
548 size_t nSize = rArray.size();
549 double fFloor = ::rtl::math::approxFloor(fPercentile * (nSize-1));
550 size_t nIndex =
static_cast<size_t>(fFloor);
551 double fDiff = fPercentile * (nSize-1) - fFloor;
552 std::vector<double>::const_iterator iter = rArray.begin() +
nIndex;
558 iter = rArray.begin() +
nIndex+1;
559 return fVal + fDiff * (*iter - fVal);
567 switch((*itr)->GetType())
570 return nMin + (nMax-nMin)*((*itr)->GetValue()/100);
577 std::vector<double>& rValues =
getValues();
578 if(rValues.size() == 1)
582 double fPercentile = (*itr)->GetValue()/100.0;
583 return GetPercentile(rValues, fPercentile);
591 return (*itr)->GetValue();
598 return std::optional<Color>();
604 return std::optional<Color>();
606 double nMin = std::numeric_limits<double>::max();
607 double nMax = std::numeric_limits<double>::min();
612 return std::optional<Color>();
614 ScColorScaleEntries::const_iterator itr =
begin();
615 double nValMin =
CalcValue(nMin, nMax, itr);
616 Color rColMin = (*itr)->GetColor();
618 double nValMax =
CalcValue(nMin, nMax, itr);
619 Color rColMax = (*itr)->GetColor();
622 while(itr !=
end() && nVal > nValMax)
626 rColMax = (*itr)->GetColor();
631 Color aColor = CalcColor(nVal, nValMin, rColMin, nValMax, rColMax);
638 for(ScColorScaleEntries::iterator itr =
begin(); itr !=
end(); ++itr)
639 (*itr)->UpdateReference(rCxt);
644 for (ScColorScaleEntries::iterator it =
begin(); it !=
end(); ++it)
645 (*it)->UpdateInsertTab(rCxt);
650 for (ScColorScaleEntries::iterator it =
begin(); it !=
end(); ++it)
651 (*it)->UpdateDeleteTab(rCxt);
656 for (ScColorScaleEntries::iterator it =
begin(); it !=
end(); ++it)
657 (*it)->UpdateMoveTab(rCxt);
755 mpFormatData->mpUpperLimit->SetRepaintCallback(pFormat);
756 mpFormatData->mpLowerLimit->SetRepaintCallback(pFormat);
798 return std::min<double>(0, nMin);
801 return nMin + (nMax-nMin)/100*
mpFormatData->mpLowerLimit->GetValue();
805 double fPercentile =
mpFormatData->mpLowerLimit->GetValue()/100.0;
806 std::vector<double>& rValues =
getValues();
807 return GetPercentile(rValues, fPercentile);
824 return std::max<double>(0, nMax);
826 return nMin + (nMax-nMin)/100*
mpFormatData->mpUpperLimit->GetValue();
829 double fPercentile =
mpFormatData->mpUpperLimit->GetValue()/100.0;
830 std::vector<double>& rValues =
getValues();
831 return GetPercentile(rValues, fPercentile);
851 double nMin =
getMin(nValMin, nValMax);
852 double nMax =
getMax(nValMin, nValMax);
863 pInfo->mnLength = nMinLength;
867 pInfo->mnLength = nMaxLength;
871 double nDiff = nMax - nMin;
872 pInfo->mnLength = nMinLength + (
nValue - nMin)/nDiff * (nMaxLength-nMinLength);
892 pInfo->mnZero = -100*nMin/(nMax-nMin);
898 double nMinNonNegative = std::max(0.0, nMin);
899 double nMaxNonPositive = std::min(0.0, nMax);
901 if(
nValue < 0 && nMin < 0)
904 pInfo->mnLength = -100;
906 pInfo->mnLength = -100 * (
nValue-nMaxNonPositive)/(nMin-nMaxNonPositive);
911 pInfo->mnLength = 100;
915 pInfo->mnLength = 100 * (
nValue-nMinNonNegative)/(nMax-nMinNonNegative);
921 double nAbsMax = std::max(std::abs(nMin), std::abs(nMax));
922 if (
nValue < 0 && nMin < 0)
925 pInfo->mnLength = nMaxLength * (nMin/nAbsMax);
927 pInfo->mnLength = nMaxLength * (
nValue/nAbsMax);
932 pInfo->mnLength = nMaxLength * (nMax/nAbsMax);
934 pInfo->mnLength = nMaxLength * (std::max(
nValue, nMin)/nAbsMax);
977 : eIconSetType(rOther.eIconSetType)
978 , mbShowValue(rOther.mbShowValue)
979 , mbReverse(rOther.mbReverse)
980 , mbCustom(rOther.mbCustom)
981 , maCustomVector(rOther.maCustomVector)
1011 (*itr)->SetRepaintCallback(pFormat);
1050 double nValMax =
CalcValue(nMin, nMax, itr);
1053 while(itr !=
end() && nVal >= nValMax)
1067 pInfo->mnHeight = aFontHeight;
1071 sal_Int32 nMaxIndex =
mpFormatData->m_Entries.size() - 1;
1079 if (nCustomIndex == -1)
1084 pInfo->eIconSetType = eCustomType;
1085 pInfo->nIconIndex = nCustomIndex;
1089 pInfo->nIconIndex =
nIndex;
1106 (*itr)->UpdateReference(rCxt);
1114 (*itr)->UpdateInsertTab(rCxt);
1122 (*itr)->UpdateDeleteTab(rCxt);
1130 (*itr)->UpdateMoveTab(rCxt);
1159 return (*itr)->GetValue();
1171 return (*itr)->GetValue();
1180 switch ((*itr)->GetType())
1183 return nMin + (nMax-nMin)*((*itr)->GetValue()/100);
1190 std::vector<double>& rValues =
getValues();
1191 if(rValues.size() == 1)
1195 double fPercentile = (*itr)->GetValue()/100.0;
1196 return GetPercentile(rValues, fPercentile);
1204 return (*itr)->GetValue();
1241constexpr rtl::OUStringConstExpr a3TrafficLights1[] = {
1242 BMP_ICON_SET_CIRCLES1_RED, BMP_ICON_SET_CIRCLES1_YELLOW, BMP_ICON_SET_CIRCLES1_GREEN
1245constexpr rtl::OUStringConstExpr a3TrafficLights2[] = {
1246 BMP_ICON_SET_TRAFFICLIGHTS_RED, BMP_ICON_SET_TRAFFICLIGHTS_YELLOW, BMP_ICON_SET_TRAFFICLIGHTS_GREEN
1249constexpr rtl::OUStringConstExpr a3Arrows[] = {
1250 BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SAME, BMP_ICON_SET_COLORARROWS_UP
1253constexpr rtl::OUStringConstExpr a3ArrowsGray[] = {
1254 BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SAME, BMP_ICON_SET_GRAYARROWS_UP
1257constexpr rtl::OUStringConstExpr a3Flags[] = {
1258 BMP_ICON_SET_FLAGS_RED, BMP_ICON_SET_FLAGS_YELLOW, BMP_ICON_SET_FLAGS_GREEN
1261constexpr rtl::OUStringConstExpr a3Smilies[] = {
1262 BMP_ICON_SET_POSITIVE_YELLOW_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_NEGATIVE_YELLOW_SMILIE
1265constexpr rtl::OUStringConstExpr a3ColorSmilies[] = {
1266 BMP_ICON_SET_POSITIVE_GREEN_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_NEGATIVE_RED_SMILIE
1269constexpr rtl::OUStringConstExpr a3Stars[] = {
1270 BMP_ICON_SET_STARS_EMPTY, BMP_ICON_SET_STARS_HALF, BMP_ICON_SET_STARS_FULL
1273constexpr rtl::OUStringConstExpr a3Triangles[] = {
1274 BMP_ICON_SET_TRIANGLES_DOWN, BMP_ICON_SET_TRIANGLES_SAME, BMP_ICON_SET_TRIANGLES_UP
1277constexpr rtl::OUStringConstExpr a4Arrows[] = {
1278 BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP, BMP_ICON_SET_COLORARROWS_UP
1281constexpr rtl::OUStringConstExpr a4ArrowsGray[] = {
1282 BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP, BMP_ICON_SET_GRAYARROWS_UP
1285constexpr rtl::OUStringConstExpr a5Arrows[] = {
1286 BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN,
1287 BMP_ICON_SET_COLORARROWS_SAME, BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP, BMP_ICON_SET_COLORARROWS_UP
1290constexpr rtl::OUStringConstExpr a5ArrowsGray[] = {
1291 BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN,
1292 BMP_ICON_SET_GRAYARROWS_SAME, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP, BMP_ICON_SET_GRAYARROWS_UP
1295constexpr rtl::OUStringConstExpr a4TrafficLights[] = {
1296 BMP_ICON_SET_CIRCLES1_GRAY, BMP_ICON_SET_CIRCLES1_RED,
1297 BMP_ICON_SET_CIRCLES1_YELLOW, BMP_ICON_SET_CIRCLES1_GREEN
1300constexpr rtl::OUStringConstExpr a5Quarters[] = {
1301 BMP_ICON_SET_PIES_EMPTY, BMP_ICON_SET_PIES_ONE_QUARTER, BMP_ICON_SET_PIES_HALF,
1302 BMP_ICON_SET_PIES_THREE_QUARTER, BMP_ICON_SET_PIES_FULL,
1305constexpr rtl::OUStringConstExpr a5Boxes[] = {
1306 BMP_ICON_SET_SQUARES_EMPTY, BMP_ICON_SET_SQUARES_ONE_QUARTER,
1307 BMP_ICON_SET_SQUARES_HALF, BMP_ICON_SET_SQUARES_THREE_QUARTER,
1308 BMP_ICON_SET_SQUARES_FULL
1311constexpr rtl::OUStringConstExpr a3Symbols1[] = {
1312 BMP_ICON_SET_SYMBOLS1_CROSS, BMP_ICON_SET_SYMBOLS1_EXCLAMATION_MARK, BMP_ICON_SET_SYMBOLS1_CHECK
1315constexpr rtl::OUStringConstExpr a3Signs[] = {
1316 BMP_ICON_SET_SHAPES_DIAMOND, BMP_ICON_SET_SHAPES_TRIANGLE, BMP_ICON_SET_SHAPES_CIRCLE
1319constexpr rtl::OUStringConstExpr a4RedToBlack[] = {
1320 BMP_ICON_SET_CIRCLES2_DARK_GRAY, BMP_ICON_SET_CIRCLES2_LIGHT_GRAY,
1321 BMP_ICON_SET_CIRCLES2_LIGHT_RED, BMP_ICON_SET_CIRCLES2_DARK_RED
1324constexpr rtl::OUStringConstExpr a4Ratings[] = {
1325 BMP_ICON_SET_BARS_ONE_QUARTER, BMP_ICON_SET_BARS_HALF,
1326 BMP_ICON_SET_BARS_THREE_QUARTER, BMP_ICON_SET_BARS_FULL
1329constexpr rtl::OUStringConstExpr a5Ratings[] = {
1330 BMP_ICON_SET_BARS_EMPTY, BMP_ICON_SET_BARS_ONE_QUARTER, BMP_ICON_SET_BARS_HALF,
1331 BMP_ICON_SET_BARS_THREE_QUARTER, BMP_ICON_SET_BARS_FULL
1334struct ScIconSetBitmapMap {
1336 const rtl::OUStringConstExpr* pBitmaps;
1339const ScIconSetBitmapMap aBitmapMap[] = {
1367 for (; pMap->
pName; ++pMap)
1369 if (pMap->
eType == eType)
1400 for(
const ScIconSetBitmapMap &
i : aBitmapMap)
1404 sBitmap = *(
i.pBitmaps +
nIndex);
1409 assert(!sBitmap.isEmpty());
1419 std::map<OUString, BitmapEx>::iterator itr = rIconSetBitmapMap.find(sBitmap);
1420 if (itr != rIconSetBitmapMap.end())
1424 std::pair<OUString, BitmapEx> aPair(sBitmap, aBitmap);
1425 std::pair<std::map<OUString, BitmapEx>::iterator,
bool> itrNew = rIconSetBitmapMap.insert(aPair);
1426 assert(itrNew.second);
1428 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
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