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);
106 for (
size_t i = 0;
i < nLength; ++
i)
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;
528 Color CalcColor(
double nVal,
double nVal1,
const Color& rCol1,
double nVal2,
const Color& rCol2)
534 return Color(nColRed, nColGreen, nColBlue);
541 double GetPercentile(
const std::vector<double>& rArray,
double fPercentile )
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;
552 iter = rArray.begin() + nIndex+1;
553 return fVal + fDiff * (*iter - fVal);
561 switch((*itr)->GetType())
564 return nMin + (nMax-nMin)*((*itr)->GetValue()/100);
571 std::vector<double>& rValues =
getValues();
572 if(rValues.size() == 1)
576 double fPercentile = (*itr)->GetValue()/100.0;
577 return GetPercentile(rValues, fPercentile);
585 return (*itr)->GetValue();
592 return std::optional<Color>();
598 return std::optional<Color>();
600 double nMin = std::numeric_limits<double>::max();
601 double nMax = std::numeric_limits<double>::min();
606 return std::optional<Color>();
608 ScColorScaleEntries::const_iterator itr =
begin();
609 double nValMin =
CalcValue(nMin, nMax, itr);
610 Color rColMin = (*itr)->GetColor();
612 double nValMax =
CalcValue(nMin, nMax, itr);
613 Color rColMax = (*itr)->GetColor();
616 while(itr !=
end() && nVal > nValMax)
620 rColMax = (*itr)->GetColor();
625 Color aColor = CalcColor(nVal, nValMin, rColMin, nValMax, rColMax);
632 for(ScColorScaleEntries::iterator itr =
begin(); itr !=
end(); ++itr)
633 (*itr)->UpdateReference(rCxt);
638 for (ScColorScaleEntries::iterator it =
begin(); it !=
end(); ++it)
639 (*it)->UpdateInsertTab(rCxt);
644 for (ScColorScaleEntries::iterator it =
begin(); it !=
end(); ++it)
645 (*it)->UpdateDeleteTab(rCxt);
650 for (ScColorScaleEntries::iterator it =
begin(); it !=
end(); ++it)
651 (*it)->UpdateMoveTab(rCxt);
749 mpFormatData->mpUpperLimit->SetRepaintCallback(pFormat);
750 mpFormatData->mpLowerLimit->SetRepaintCallback(pFormat);
792 return std::min<double>(0, nMin);
795 return nMin + (nMax-nMin)/100*
mpFormatData->mpLowerLimit->GetValue();
799 double fPercentile =
mpFormatData->mpLowerLimit->GetValue()/100.0;
800 std::vector<double>& rValues =
getValues();
801 return GetPercentile(rValues, fPercentile);
818 return std::max<double>(0, nMax);
820 return nMin + (nMax-nMin)/100*
mpFormatData->mpUpperLimit->GetValue();
823 double fPercentile =
mpFormatData->mpUpperLimit->GetValue()/100.0;
824 std::vector<double>& rValues =
getValues();
825 return GetPercentile(rValues, fPercentile);
845 double nMin =
getMin(nValMin, nValMax);
846 double nMax =
getMax(nValMin, nValMax);
857 pInfo->mnLength = nMinLength;
859 else if(nValue >= nMax)
861 pInfo->mnLength = nMaxLength;
865 double nDiff = nMax - nMin;
866 pInfo->mnLength = nMinLength + (nValue - nMin)/nDiff * (nMaxLength-nMinLength);
886 pInfo->mnZero = -100*nMin/(nMax-nMin);
892 double nMinNonNegative = std::max(0.0, nMin);
893 double nMaxNonPositive = std::min(0.0, nMax);
895 if(nValue < 0 && nMin < 0)
898 pInfo->mnLength = -100;
900 pInfo->mnLength = -100 * (nValue-nMaxNonPositive)/(nMin-nMaxNonPositive);
905 pInfo->mnLength = 100;
906 else if (nValue <= nMin)
909 pInfo->mnLength = 100 * (nValue-nMinNonNegative)/(nMax-nMinNonNegative);
915 double nAbsMax = std::max(std::abs(nMin), std::abs(nMax));
916 if (nValue < 0 && nMin < 0)
919 pInfo->mnLength = nMaxLength * (nMin/nAbsMax);
921 pInfo->mnLength = nMaxLength * (nValue/nAbsMax);
926 pInfo->mnLength = nMaxLength * (nMax/nAbsMax);
928 pInfo->mnLength = nMaxLength * (std::max(nValue, nMin)/nAbsMax);
971 : eIconSetType(rOther.eIconSetType)
972 , mbShowValue(rOther.mbShowValue)
974 , mbCustom(rOther.mbCustom)
975 , maCustomVector(rOther.maCustomVector)
1005 (*itr)->SetRepaintCallback(pFormat);
1041 sal_Int32 nIndex = 0;
1044 double nValMax =
CalcValue(nMin, nMax, itr);
1047 while(itr !=
end() && nVal >= nValMax)
1061 pInfo->mnHeight = aFontHeight;
1065 sal_Int32 nMaxIndex =
mpFormatData->m_Entries.size() - 1;
1066 nIndex = nMaxIndex - nIndex;
1072 sal_Int32 nCustomIndex =
mpFormatData->maCustomVector[nIndex].second;
1073 if (nCustomIndex == -1)
1078 pInfo->eIconSetType = eCustomType;
1079 pInfo->nIconIndex = nCustomIndex;
1083 pInfo->nIconIndex = nIndex;
1100 (*itr)->UpdateReference(rCxt);
1108 (*itr)->UpdateInsertTab(rCxt);
1116 (*itr)->UpdateDeleteTab(rCxt);
1124 (*itr)->UpdateMoveTab(rCxt);
1153 return (*itr)->GetValue();
1165 return (*itr)->GetValue();
1174 switch ((*itr)->GetType())
1177 return nMin + (nMax-nMin)*((*itr)->GetValue()/100);
1184 std::vector<double>& rValues =
getValues();
1185 if(rValues.size() == 1)
1189 double fPercentile = (*itr)->GetValue()/100.0;
1190 return GetPercentile(rValues, fPercentile);
1198 return (*itr)->GetValue();
1235 constexpr rtl::OUStringConstExpr a3TrafficLights1[] = {
1236 BMP_ICON_SET_CIRCLES1_RED, BMP_ICON_SET_CIRCLES1_YELLOW, BMP_ICON_SET_CIRCLES1_GREEN
1239 constexpr rtl::OUStringConstExpr a3TrafficLights2[] = {
1240 BMP_ICON_SET_TRAFFICLIGHTS_RED, BMP_ICON_SET_TRAFFICLIGHTS_YELLOW, BMP_ICON_SET_TRAFFICLIGHTS_GREEN
1243 constexpr rtl::OUStringConstExpr a3Arrows[] = {
1244 BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SAME, BMP_ICON_SET_COLORARROWS_UP
1247 constexpr rtl::OUStringConstExpr a3ArrowsGray[] = {
1248 BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SAME, BMP_ICON_SET_GRAYARROWS_UP
1251 constexpr rtl::OUStringConstExpr a3Flags[] = {
1252 BMP_ICON_SET_FLAGS_RED, BMP_ICON_SET_FLAGS_YELLOW, BMP_ICON_SET_FLAGS_GREEN
1255 constexpr rtl::OUStringConstExpr a3Smilies[] = {
1256 BMP_ICON_SET_POSITIVE_YELLOW_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_NEGATIVE_YELLOW_SMILIE
1259 constexpr rtl::OUStringConstExpr a3ColorSmilies[] = {
1260 BMP_ICON_SET_POSITIVE_GREEN_SMILIE, BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE, BMP_ICON_SET_NEGATIVE_RED_SMILIE
1263 constexpr rtl::OUStringConstExpr a3Stars[] = {
1264 BMP_ICON_SET_STARS_EMPTY, BMP_ICON_SET_STARS_HALF, BMP_ICON_SET_STARS_FULL
1267 constexpr rtl::OUStringConstExpr a3Triangles[] = {
1268 BMP_ICON_SET_TRIANGLES_DOWN, BMP_ICON_SET_TRIANGLES_SAME, BMP_ICON_SET_TRIANGLES_UP
1271 constexpr rtl::OUStringConstExpr a4Arrows[] = {
1272 BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP, BMP_ICON_SET_COLORARROWS_UP
1275 constexpr rtl::OUStringConstExpr a4ArrowsGray[] = {
1276 BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP, BMP_ICON_SET_GRAYARROWS_UP
1279 constexpr rtl::OUStringConstExpr a5Arrows[] = {
1280 BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN,
1281 BMP_ICON_SET_COLORARROWS_SAME, BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP, BMP_ICON_SET_COLORARROWS_UP
1284 constexpr rtl::OUStringConstExpr a5ArrowsGray[] = {
1285 BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN,
1286 BMP_ICON_SET_GRAYARROWS_SAME, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP, BMP_ICON_SET_GRAYARROWS_UP
1289 constexpr rtl::OUStringConstExpr a4TrafficLights[] = {
1290 BMP_ICON_SET_CIRCLES1_GRAY, BMP_ICON_SET_CIRCLES1_RED,
1291 BMP_ICON_SET_CIRCLES1_YELLOW, BMP_ICON_SET_CIRCLES1_GREEN
1294 constexpr rtl::OUStringConstExpr a5Quarters[] = {
1295 BMP_ICON_SET_PIES_EMPTY, BMP_ICON_SET_PIES_ONE_QUARTER, BMP_ICON_SET_PIES_HALF,
1296 BMP_ICON_SET_PIES_THREE_QUARTER, BMP_ICON_SET_PIES_FULL,
1299 constexpr rtl::OUStringConstExpr a5Boxes[] = {
1300 BMP_ICON_SET_SQUARES_EMPTY, BMP_ICON_SET_SQUARES_ONE_QUARTER,
1301 BMP_ICON_SET_SQUARES_HALF, BMP_ICON_SET_SQUARES_THREE_QUARTER,
1302 BMP_ICON_SET_SQUARES_FULL
1305 constexpr rtl::OUStringConstExpr a3Symbols1[] = {
1306 BMP_ICON_SET_SYMBOLS1_CROSS, BMP_ICON_SET_SYMBOLS1_EXCLAMATION_MARK, BMP_ICON_SET_SYMBOLS1_CHECK
1309 constexpr rtl::OUStringConstExpr a3Signs[] = {
1310 BMP_ICON_SET_SHAPES_DIAMOND, BMP_ICON_SET_SHAPES_TRIANGLE, BMP_ICON_SET_SHAPES_CIRCLE
1313 constexpr rtl::OUStringConstExpr a4RedToBlack[] = {
1314 BMP_ICON_SET_CIRCLES2_DARK_GRAY, BMP_ICON_SET_CIRCLES2_LIGHT_GRAY,
1315 BMP_ICON_SET_CIRCLES2_LIGHT_RED, BMP_ICON_SET_CIRCLES2_DARK_RED
1318 constexpr rtl::OUStringConstExpr a4Ratings[] = {
1319 BMP_ICON_SET_BARS_ONE_QUARTER, BMP_ICON_SET_BARS_HALF,
1320 BMP_ICON_SET_BARS_THREE_QUARTER, BMP_ICON_SET_BARS_FULL
1323 constexpr rtl::OUStringConstExpr a5Ratings[] = {
1324 BMP_ICON_SET_BARS_EMPTY, BMP_ICON_SET_BARS_ONE_QUARTER, BMP_ICON_SET_BARS_HALF,
1325 BMP_ICON_SET_BARS_THREE_QUARTER, BMP_ICON_SET_BARS_FULL
1328 struct ScIconSetBitmapMap {
1330 const rtl::OUStringConstExpr* pBitmaps;
1333 const ScIconSetBitmapMap aBitmapMap[] = {
1361 for (; pMap->
pName; ++pMap)
1363 if (pMap->
eType == eType)
1394 for(
const ScIconSetBitmapMap &
i : aBitmapMap)
1396 if(
i.eType == eType)
1398 sBitmap = *(
i.pBitmaps + nIndex);
1403 assert(!sBitmap.isEmpty());
1413 std::map<OUString, BitmapEx>::iterator itr = rIconSetBitmapMap.find(sBitmap);
1414 if (itr != rIconSetBitmapMap.end())
1418 std::pair<OUString, BitmapEx> aPair(sBitmap, aBitmap);
1419 std::pair<std::map<OUString, BitmapEx>::iterator,
bool> itrNew = rIconSetBitmapMap.insert(aPair);
1420 assert(itrNew.second);
1422 return itrNew.first->second;
1430 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.
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
std::unique_ptr< ScFormulaListener > mpListener
void SetColor(const Color &)
std::map< OUString, BitmapEx > IconSetBitmapMap
sal_uInt8 GetBlue() const
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_LIGHTRED
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.
const SfxPoolItem & GetItem(sal_uInt16 nWhichP) const
SC_DLLPUBLIC SCCOL MaxCol() const
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)
constexpr TypedWhichId< SvxFontHeightItem > ATTR_FONT_HEIGHT(101)
bool m_bDetectedRangeSegmentation false