16#include <document.hxx>
20#include <compiler.hxx>
21#include <tokenarray.hxx>
29#include <rtl/ustring.hxx>
32#include <com/sun/star/sheet/DataBarAxis.hpp>
33#include <com/sun/star/sheet/IconSetType.hpp>
34#include <com/sun/star/sheet/ConditionFormatOperator.hpp>
35#include <com/sun/star/sheet/DataBarEntryType.hpp>
36#include <com/sun/star/sheet/ColorScaleEntryType.hpp>
37#include <com/sun/star/sheet/IconSetFormatEntry.hpp>
38#include <com/sun/star/sheet/ConditionEntryType.hpp>
39#include <com/sun/star/sheet/DateType.hpp>
43enum CondFormatProperties
56 return aCondFormatPropertyMap_Impl;
59enum ConditionEntryProperties
76 return aConditionEntryPropertyMap_Impl;
79struct ConditionEntryApiMap
85ConditionEntryApiMap
const aConditionEntryMap[] =
115enum ColorScaleProperties
126 return aColorScalePropertyMap_Impl;
129struct ColorScaleEntryTypeApiMap
135ColorScaleEntryTypeApiMap
const aColorScaleEntryTypeMap[] =
145enum DataBarProperties
163 {
u"AxisPosition", AxisPosition,
cppu::UnoType<
decltype(sheet::DataBarAxis::AXIS_AUTOMATIC)>::get(), 0, 0 },
174 return aDataBarPropertyMap_Impl;
177struct DataBarAxisApiMap
183DataBarAxisApiMap
const aDataBarAxisMap[] =
190struct DataBarEntryTypeApiMap
196DataBarEntryTypeApiMap
const aDataBarEntryTypeMap[] =
207enum IconSetProperties
219 {
u"Icons", Icons,
cppu::UnoType<
decltype(sheet::IconSetType::ICONSET_3SYMBOLS)>::get(), 0, 0 },
224 return aIconSetPropertyMap_Impl;
227struct IconSetTypeApiMap
233const IconSetTypeApiMap aIconSetApiMap[] =
256struct IconSetEntryTypeApiMap
262IconSetEntryTypeApiMap
const aIconSetEntryTypeMap[] =
284 return aCondDatePropertyMap_Impl;
293DateTypeApiMap
const aDateTypeApiMap[] =
314 mpDocShell(pDocShell)
327 if ( rHint.
GetId() == SfxHintId::Dying )
337 throw lang::IllegalArgumentException();
340 throw lang::IllegalArgumentException();
342 const uno::Sequence<table::CellRangeAddress> aRanges =
343 xRanges->getRangeAddresses();
346 for (
const auto& rRange : aRanges)
350 aCoreRange.
Join(aRange);
353 if (aCoreRange.
empty())
354 throw lang::IllegalArgumentException();
356 SCTAB nTab = aCoreRange[0].aStart.Tab();
359 pNewFormat->SetRange(aCoreRange);
367 pFormatList->
erase(nID);
374 size_t n = pFormatList->
size();
375 uno::Sequence<uno::Reference<sheet::XConditionalFormat> > aCondFormats(
n);
376 std::transform(pFormatList->
begin(), pFormatList->
end(), aCondFormats.getArray(),
377 [
this](
const auto& rFormat)
378 { return uno::Reference(new ScCondFormatObj(mpDocShell, this, rFormat->GetKey())); });
387 return pFormatList->
size();
393 throw uno::RuntimeException();
397 throw uno::RuntimeException();
404uno::Reference<beans::XPropertySet> createConditionEntry(
const ScFormatEntry* pEntry,
433 return uno::Reference<beans::XPropertySet>();
440 mxCondFormatList(
std::move(xCondFormats)),
441 mpDocShell(pDocShell),
442 maPropSet(getCondFormatPropset()),
456 throw uno::RuntimeException();
470 if (
nPos > sal_Int32(pFormat->
size()))
471 throw lang::IllegalArgumentException();
497 SAL_WARN(
"sc",
"unknown conditional format type");
498 throw lang::IllegalArgumentException();
508 throw lang::IllegalArgumentException();
530 return pFormat->
size();
537 throw lang::IllegalArgumentException();
540 uno::Reference<beans::XPropertySet> xCondEntry =
541 createConditionEntry(pEntry,
this);
548 static uno::Reference<beans::XPropertySetInfo> aRef(
554 const OUString& aPropertyName,
const uno::Any& aValue )
561 throw beans::UnknownPropertyException(aPropertyName);
566 throw lang::IllegalArgumentException();
568 case CondFormat_Range:
570 uno::Reference<sheet::XSheetCellRanges> xRange;
571 if (aValue >>= xRange)
574 const uno::Sequence<table::CellRangeAddress> aRanges =
575 xRange->getRangeAddresses();
577 for (
const auto& rRange : aRanges)
581 aTargetRange.
Join(aRange);
599 throw beans::UnknownPropertyException(aPropertyName);
607 case CondFormat_Range:
610 uno::Reference<sheet::XSheetCellRanges> xRange;
611 xRange.set(
new ScCellRangesObj(
mpDocShell, rRange));
622 const uno::Reference<beans::XPropertyChangeListener>& )
628 const uno::Reference<beans::XPropertyChangeListener>& )
634 const uno::Reference<beans::XVetoableChangeListener>&)
640 const uno::Reference<beans::XVetoableChangeListener>&)
649 for(
size_t i = 0, n= pFormat->
size(); i < n; ++i)
663 maPropSet(getConditionEntryrPropSet()),
675 if (isObjectStillAlive(pFormat,
mpFormat))
678 throw lang::IllegalArgumentException();
688 static uno::Reference<beans::XPropertySetInfo> aRef(
694 const OUString& aPropertyName,
const uno::Any& aValue )
701 throw beans::UnknownPropertyException(aPropertyName);
708 if ((aValue >>= aStyleName) && !aStyleName.isEmpty())
715 if ((aValue >>= aFormula) && !aFormula.isEmpty())
719 std::unique_ptr<ScTokenArray> pArr(aComp.
CompileString(aFormula));
727 if ((aValue >>= aFormula) && !aFormula.isEmpty())
731 std::unique_ptr<ScTokenArray> pArr(aComp.
CompileString(aFormula));
741 for (ConditionEntryApiMap
const & rEntry : aConditionEntryMap)
743 if (rEntry.nApiMode == nVal)
753 SAL_WARN(
"sc",
"unsupported property");
764 throw beans::UnknownPropertyException(aPropertyName);
789 for (ConditionEntryApiMap
const & rEntry : aConditionEntryMap)
791 if (rEntry.eMode ==
eMode)
793 aAny <<= rEntry.nApiMode;
800 SAL_WARN(
"sc",
"unsupported property");
806 const uno::Reference<beans::XPropertyChangeListener>& )
812 const uno::Reference<beans::XPropertyChangeListener>& )
818 const uno::Reference<beans::XVetoableChangeListener>&)
824 const uno::Reference<beans::XVetoableChangeListener>&)
832 maPropSet(getColorScalePropSet()),
844 if (isObjectStillAlive(pFormat,
mpFormat))
847 throw lang::IllegalArgumentException();
857 static uno::Reference<beans::XPropertySetInfo> aRef(
864void setColorScaleEntry(
ScColorScaleEntry* pEntry, uno::Reference<sheet::XColorScaleEntry>
const & xEntry)
867 sal_Int32 nApiType = xEntry->getType();
869 for (ColorScaleEntryTypeApiMap
const & rEntry : aColorScaleEntryTypeMap)
871 if (rEntry.nApiType == nApiType)
873 eType = rEntry.eType;
880 throw lang::IllegalArgumentException();
883 pEntry->
SetColor(
Color(ColorTransparency, xEntry->getColor()));
891 double nVal = xEntry->getFormula().toDouble();
901 const OUString& aPropertyName,
const uno::Any& aValue )
908 throw beans::UnknownPropertyException(aPropertyName);
912 case ColorScaleEntries:
914 uno::Sequence<uno::Reference<sheet::XColorScaleEntry> >
aEntries;
916 throw lang::IllegalArgumentException();
919 throw lang::IllegalArgumentException();
923 for (
size_t i = 0;
i <
n; ++
i)
942 throw beans::UnknownPropertyException(aPropertyName);
948 case ColorScaleEntries:
951 auto aEntriesRange = asNonConstRange(
aEntries);
967 const uno::Reference<beans::XPropertyChangeListener>& )
973 const uno::Reference<beans::XPropertyChangeListener>& )
979 const uno::Reference<beans::XVetoableChangeListener>&)
985 const uno::Reference<beans::XVetoableChangeListener>&)
1005 throw lang::IllegalArgumentException();
1013 return sal_Int32(aColor);
1024 for (ColorScaleEntryTypeApiMap
const & rEntry : aColorScaleEntryTypeMap)
1026 if (rEntry.eType == pEntry->
GetType())
1028 return rEntry.nApiType;
1032 throw lang::IllegalArgumentException();
1038 for (ColorScaleEntryTypeApiMap
const & rEntry : aColorScaleEntryTypeMap)
1040 if (rEntry.nApiType ==
nType)
1042 pEntry->
SetType(rEntry.eType);
1046 throw lang::IllegalArgumentException();
1058 return OUString::number(pEntry->
GetValue());
1074 pEntry->
SetValue(rFormula.toDouble());
1083 maPropSet(getDataBarPropSet()),
1095 if (isObjectStillAlive(pFormat,
mpFormat))
1098 throw lang::IllegalArgumentException();
1109 static uno::Reference<beans::XPropertySetInfo> aRef(
1116void setDataBarEntry(
ScColorScaleEntry* pEntry, uno::Reference<sheet::XDataBarEntry>
const & xEntry)
1119 sal_Int32 nApiType = xEntry->getType();
1120 bool bFound =
false;
1121 for (DataBarEntryTypeApiMap
const & rEntry : aDataBarEntryTypeMap)
1123 if (rEntry.nApiType == nApiType)
1125 eType = rEntry.eType;
1132 throw lang::IllegalArgumentException();
1142 double nVal = xEntry->getFormula().toDouble();
1152 const OUString& aPropertyName,
const uno::Any& aValue )
1159 throw beans::UnknownPropertyException(aPropertyName);
1161 switch(pEntry->
nWID)
1166 if (aValue >>= nVal)
1168 for (DataBarAxisApiMap
const & rEntry : aDataBarAxisMap)
1170 if (rEntry.nApiPos == nVal)
1182 bool bUseGradient =
true;
1183 if (aValue >>= bUseGradient)
1189 case UseNegativeColor:
1191 bool bUseNegativeColor =
false;
1192 if (aValue >>= bUseNegativeColor)
1195 if (bUseNegativeColor && !
getCoreObject()->GetDataBarData()->mxNegativeColor)
1202 case DataBar_ShowValue:
1204 bool bShowValue =
true;
1205 if (aValue >>= bShowValue)
1214 if (aValue >>= nColor)
1223 if (aValue >>= nAxisColor)
1232 if (!(aValue >>= nNegativeColor) || !
getCoreObject()->GetDataBarData()->mbNeg)
1233 throw lang::IllegalArgumentException();
1239 case DataBarEntries:
1241 uno::Sequence<uno::Reference<sheet::XDataBarEntry> >
aEntries;
1243 throw lang::IllegalArgumentException();
1246 throw lang::IllegalArgumentException();
1248 setDataBarEntry(
getCoreObject()->GetDataBarData()->mpLowerLimit.get(),
1250 setDataBarEntry(
getCoreObject()->GetDataBarData()->mpUpperLimit.get(),
1259 throw lang::IllegalArgumentException();
1268 throw lang::IllegalArgumentException();
1283 throw beans::UnknownPropertyException(aPropertyName);
1286 switch(pEntry->
nWID)
1291 sal_Int32 nApiPos = sheet::DataBarAxis::AXIS_NONE;
1292 for (DataBarAxisApiMap
const & rEntry : aDataBarAxisMap)
1294 if (rEntry.ePos ==
ePos)
1296 nApiPos = rEntry.nApiPos;
1308 case UseNegativeColor:
1313 case DataBar_ShowValue:
1336 case DataBarEntries:
1338 uno::Sequence<uno::Reference<sheet::XDataBarEntry> >
aEntries
1351 const uno::Reference<beans::XPropertyChangeListener>& )
1357 const uno::Reference<beans::XPropertyChangeListener>& )
1363 const uno::Reference<beans::XVetoableChangeListener>&)
1369 const uno::Reference<beans::XVetoableChangeListener>&)
1400 for (DataBarEntryTypeApiMap
const & rEntry : aDataBarEntryTypeMap)
1402 if (rEntry.eType == pEntry->
GetType())
1404 return rEntry.nApiType;
1408 throw lang::IllegalArgumentException();
1414 for (DataBarEntryTypeApiMap
const & rEntry : aDataBarEntryTypeMap)
1416 if (rEntry.nApiType ==
nType)
1418 pEntry->
SetType(rEntry.eType);
1422 throw lang::IllegalArgumentException();
1434 return OUString::number(pEntry->
GetValue());
1450 pEntry->
SetValue(rFormula.toDouble());
1459 maPropSet(getIconSetPropSet()),
1471 if (isObjectStillAlive(pFormat,
mpFormat))
1474 throw lang::IllegalArgumentException();
1485 static uno::Reference<beans::XPropertySetInfo> aRef(
1492void setIconSetEntry(
ScIconSetFormat* pFormat, uno::Reference<sheet::XIconSetEntry>
const & xEntry,
size_t nPos)
1496 sal_Int32 nApiType = xEntry->getType();
1497 bool bFound =
false;
1498 for (IconSetEntryTypeApiMap
const & rEntry : aIconSetEntryTypeMap)
1500 if (rEntry.nApiType == nApiType)
1502 eType = rEntry.eType;
1509 throw lang::IllegalArgumentException();
1519 double nVal = xEntry->getFormula().toDouble();
1529 const OUString& aPropertyName,
const uno::Any& aValue )
1536 throw beans::UnknownPropertyException(aPropertyName);
1538 switch(pEntry->
nWID)
1542 bool bShowValue =
true;
1543 aValue >>= bShowValue;
1549 bool bReverse =
false;
1550 aValue >>= bReverse;
1556 sal_Int32 nApiType = -1;
1557 aValue >>= nApiType;
1559 bool bFound =
false;
1560 for (
const IconSetTypeApiMap & rEntry : aIconSetApiMap)
1562 if (rEntry.nApiType == nApiType)
1564 eType = rEntry.eType;
1572 throw lang::IllegalArgumentException();
1579 case IconSetEntries:
1581 uno::Sequence<uno::Reference<sheet::XIconSetEntry> >
aEntries;
1583 throw lang::IllegalArgumentException();
1607 throw beans::UnknownPropertyException(aPropertyName);
1611 switch(pEntry->
nWID)
1622 for (
const IconSetTypeApiMap & rEntry : aIconSetApiMap)
1624 if (rEntry.eType ==
eType)
1626 aAny <<= rEntry.nApiType;
1632 case IconSetEntries:
1635 uno::Sequence<uno::Reference<sheet::XIconSetEntry> >
aEntries(nSize);
1636 auto aEntriesRange = asNonConstRange(
aEntries);
1637 for (
size_t i = 0;
i < nSize; ++
i)
1645 SAL_WARN(
"sc",
"unknown property");
1651 const uno::Reference<beans::XPropertyChangeListener>& )
1657 const uno::Reference<beans::XPropertyChangeListener>& )
1663 const uno::Reference<beans::XVetoableChangeListener>&)
1669 const uno::Reference<beans::XVetoableChangeListener>&)
1689 throw lang::IllegalArgumentException();
1699 return sheet::IconSetFormatEntry::ICONSET_MIN;
1701 for (IconSetEntryTypeApiMap
const & rEntry : aIconSetEntryTypeMap)
1703 if (rEntry.eType == pEntry->
GetType())
1705 return rEntry.nApiType;
1709 throw lang::IllegalArgumentException();
1719 for (IconSetEntryTypeApiMap
const & rEntry : aIconSetEntryTypeMap)
1721 if (rEntry.nApiType ==
nType)
1723 pEntry->
SetType(rEntry.eType);
1727 throw lang::IllegalArgumentException();
1739 return OUString::number(pEntry->
GetValue());
1755 pEntry->
SetValue(rFormula.toDouble());
1763 maPropSet(getCondDatePropSet()),
1775 if (isObjectStillAlive(pFormat,
mpFormat))
1778 throw lang::IllegalArgumentException();
1789 static uno::Reference<beans::XPropertySetInfo> aRef(
1795 const OUString& aPropertyName,
const uno::Any& aValue )
1802 throw beans::UnknownPropertyException(aPropertyName);
1804 switch(pEntry->
nWID)
1806 case Date_StyleName:
1808 OUString aStyleName;
1809 if (!(aValue >>= aStyleName))
1810 throw lang::IllegalArgumentException();
1818 sal_Int32 nApiType = -1;
1819 if (!(aValue >>= nApiType))
1820 throw lang::IllegalArgumentException();
1822 for (DateTypeApiMap
const & rEntry : aDateTypeApiMap)
1824 if (rEntry.nApiType == nApiType)
1844 throw beans::UnknownPropertyException(aPropertyName);
1848 switch(pEntry->
nWID)
1850 case Date_StyleName:
1853 aAny <<= aStyleName;
1859 for (DateTypeApiMap
const & rEntry : aDateTypeApiMap)
1861 if (rEntry.eType ==
eType)
1863 aAny <<= rEntry.nApiType;
1870 SAL_WARN(
"sc",
"unknown property");
1876 const uno::Reference<beans::XPropertyChangeListener>& )
1882 const uno::Reference<beans::XPropertyChangeListener>& )
1888 const uno::Reference<beans::XVetoableChangeListener>&)
1894 const uno::Reference<beans::XVetoableChangeListener>&)
css::chart::ChartAxisLabelPosition ePos
unotools::WeakReference< AnimationNode > mxParent
virtual sal_Int32 SAL_CALL getType() override
ScColorScaleEntry * getCoreObject()
virtual ~ScColorScaleEntryObj() override
virtual OUString SAL_CALL getFormula() override
virtual void SAL_CALL setColor(sal_Int32 aColor) override
virtual void SAL_CALL setType(sal_Int32 nType) override
virtual sal_Int32 SAL_CALL getColor() override
ScColorScaleEntryObj(rtl::Reference< ScColorScaleFormatObj > xParent, size_t nPos)
rtl::Reference< ScColorScaleFormatObj > mxParent
virtual void SAL_CALL setFormula(const OUString &rString) override
void SetType(ScColorScaleEntryType eType)
ScColorScaleEntryType GetType() const
const Color & GetColor() const
void SetValue(double nValue)
void SetColor(const Color &)
void SetGrammar(const formula::FormulaGrammar::Grammar eGrammar)
std::unique_ptr< ScTokenArray > CompileString(const OUString &rFormula)
Tokenize formula expression string into an array of tokens.
void SetDateType(condformat::ScCondFormatDateType eType)
void SetStyleName(const OUString &rStyleName)
condformat::ScCondFormatDateType GetDateType() const
const OUString & GetStyleName() const
const OUString & GetStyle() const
void UpdateStyleName(const OUString &rNew)
virtual sal_Int32 SAL_CALL getType() override
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual ~ScConditionEntryObj() override
ScConditionEntryObj(rtl::Reference< ScCondFormatObj > const &xParent, const ScCondFormatEntry *pFormat)
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
SfxItemPropertySet maPropSet
ScCondFormatEntry * getCoreObject()
const ScCondFormatEntry * mpFormat
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
rtl::Reference< ScCondFormatObj > mxParent
void SetFormula1(const ScTokenArray &rArray)
ScConditionMode GetOperation() const
const ScAddress & GetSrcPos() const
void SetFormula2(const ScTokenArray &rArray)
OUString GetExpression(const ScAddress &rCursor, sal_uInt16 nPos, sal_uInt32 nNumFmt=0, const formula::FormulaGrammar::Grammar eGrammar=formula::FormulaGrammar::GRAM_DEFAULT) const
void SetOperation(ScConditionMode eMode)
virtual sal_Int32 SAL_CALL getType() override
virtual OUString SAL_CALL getFormula() override
virtual ~ScDataBarEntryObj() override
ScColorScaleEntry * getCoreObject()
virtual void SAL_CALL setType(sal_Int32 nType) override
ScDataBarEntryObj(rtl::Reference< ScDataBarFormatObj > xParent, size_t nPos)
virtual void SAL_CALL setFormula(const OUString &rString) override
rtl::Reference< ScDataBarFormatObj > mxParent
const ScDocument & GetDocument() const
void AddUnoObject(SfxListener &rObject)
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
SC_DLLPUBLIC ScConditionalFormatList * GetCondFormList(SCTAB nTab) const
void RemoveUnoObject(SfxListener &rObject)
SC_DLLPUBLIC sal_uLong AddCondFormat(std::unique_ptr< ScConditionalFormat > pNew, SCTAB nTab)
virtual Type GetType() const =0
ScColorScaleEntry * getCoreObject()
rtl::Reference< ScIconSetFormatObj > mxParent
virtual sal_Int32 SAL_CALL getType() override
ScIconSetEntryObj(rtl::Reference< ScIconSetFormatObj > xParent, size_t nPos)
virtual void SAL_CALL setType(sal_Int32 nType) override
virtual void SAL_CALL setFormula(const OUString &rString) override
virtual ~ScIconSetEntryObj() override
virtual OUString SAL_CALL getFormula() override
ScAddress GetTopLeftCorner() const
void Join(const ScRange &, bool bIsInList=false)
static void FillScRange(ScRange &rScRange, const css::table::CellRangeAddress &rApiRange)
const SfxItemPropertyMapEntry * getByName(std::u16string_view rName) const
const SfxItemPropertyMap & getPropertyMap() const
css::uno::Type const & get()
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
@ IconSet_3TrafficLights1
@ IconSet_3TrafficLights2
ScXMLEditAttributeMap::Entry const aEntries[]
#define SAL_WARN(area, stream)
std::unique_ptr< sal_Int32[]> pData
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
ScDocShell * getDocShell(const css::uno::Reference< css::frame::XModel > &xModel)