13 #include <document.hxx>
17 #include <compiler.hxx>
18 #include <tokenarray.hxx>
25 #include <rtl/ustring.hxx>
28 #include <com/sun/star/sheet/DataBarAxis.hpp>
29 #include <com/sun/star/sheet/IconSetType.hpp>
30 #include <com/sun/star/sheet/ConditionFormatOperator.hpp>
31 #include <com/sun/star/sheet/DataBarEntryType.hpp>
32 #include <com/sun/star/sheet/ColorScaleEntryType.hpp>
33 #include <com/sun/star/sheet/IconSetFormatEntry.hpp>
34 #include <com/sun/star/sheet/ConditionEntryType.hpp>
35 #include <com/sun/star/sheet/DateType.hpp>
51 {
u"", 0, css::uno::Type(), 0, 0}
53 return aCondFormatPropertyMap_Impl;
72 {
u"", 0, css::uno::Type(), 0, 0}
74 return aConditionEntryPropertyMap_Impl;
77 struct ConditionEntryApiMap
83 ConditionEntryApiMap
const aConditionEntryMap[] =
123 {
u"", 0, css::uno::Type(), 0, 0}
125 return aColorScalePropertyMap_Impl;
128 struct ColorScaleEntryTypeApiMap
134 ColorScaleEntryTypeApiMap
const aColorScaleEntryTypeMap[] =
172 {
u"", 0, css::uno::Type(), 0, 0}
174 return aDataBarPropertyMap_Impl;
177 struct DataBarAxisApiMap
183 DataBarAxisApiMap
const aDataBarAxisMap[] =
190 struct DataBarEntryTypeApiMap
196 DataBarEntryTypeApiMap
const aDataBarEntryTypeMap[] =
223 {
u"", 0, css::uno::Type(), 0, 0}
225 return aIconSetPropertyMap_Impl;
228 struct IconSetTypeApiMap
234 const IconSetTypeApiMap aIconSetApiMap[] =
257 struct IconSetEntryTypeApiMap
263 IconSetEntryTypeApiMap
const aIconSetEntryTypeMap[] =
284 {
u"", 0, css::uno::Type(), 0, 0}
286 return aCondDatePropertyMap_Impl;
289 struct DateTypeApiMap
295 DateTypeApiMap
const aDateTypeApiMap[] =
316 mpDocShell(pDocShell)
329 if ( rHint.
GetId() == SfxHintId::Dying )
339 throw lang::IllegalArgumentException();
342 throw lang::IllegalArgumentException();
344 const uno::Sequence<table::CellRangeAddress> aRanges =
345 xRanges->getRangeAddresses();
348 for (
const auto& rRange : aRanges)
352 aCoreRange.
Join(aRange);
355 if (aCoreRange.
empty())
356 throw lang::IllegalArgumentException();
358 SCTAB nTab = aCoreRange[0].aStart.Tab();
361 pNewFormat->SetRange(aCoreRange);
369 pFormatList->
erase(nID);
376 size_t n = pFormatList->
size();
377 uno::Sequence<uno::Reference<sheet::XConditionalFormat> > aCondFormats(n);
379 for (
const auto& rFormat : *pFormatList)
382 aCondFormats[i] = xCondFormat;
393 return pFormatList->
size();
399 throw uno::RuntimeException();
403 throw uno::RuntimeException();
410 uno::Reference<beans::XPropertySet> createConditionEntry(
const ScFormatEntry* pEntry,
418 static_cast<const ScCondFormatEntry*>(pEntry));
422 static_cast<const ScColorScaleFormat*>(pEntry));
426 static_cast<const ScDataBarFormat*>(pEntry));
430 static_cast<const ScIconSetFormat*>(pEntry));
434 static_cast<const ScCondDateFormatEntry*>(pEntry));
439 return uno::Reference<beans::XPropertySet>();
446 mxCondFormatList(xCondFormats),
447 mpDocShell(pDocShell),
448 maPropSet(getCondFormatPropset()),
462 throw uno::RuntimeException();
476 if (nPos > sal_Int32(pFormat->
size()))
477 throw lang::IllegalArgumentException();
503 SAL_WARN(
"sc",
"unknown conditional format type");
504 throw lang::IllegalArgumentException();
514 throw lang::IllegalArgumentException();
536 return pFormat->
size();
543 throw lang::IllegalArgumentException();
546 uno::Reference<beans::XPropertySet> xCondEntry =
547 createConditionEntry(pEntry,
this);
554 static uno::Reference<beans::XPropertySetInfo> aRef(
560 const OUString& aPropertyName,
const uno::Any& aValue )
567 throw beans::UnknownPropertyException(aPropertyName);
572 throw lang::IllegalArgumentException();
574 case CondFormat_Range:
576 uno::Reference<sheet::XSheetCellRanges> xRange;
577 if (aValue >>= xRange)
580 const uno::Sequence<table::CellRangeAddress> aRanges =
581 xRange->getRangeAddresses();
583 for (
const auto& rRange : aRanges)
587 aTargetRange.
Join(aRange);
605 throw beans::UnknownPropertyException(aPropertyName);
613 case CondFormat_Range:
616 uno::Reference<sheet::XSheetCellRanges> xRange;
628 const uno::Reference<beans::XPropertyChangeListener>& )
634 const uno::Reference<beans::XPropertyChangeListener>& )
640 const uno::Reference<beans::XVetoableChangeListener>&)
646 const uno::Reference<beans::XVetoableChangeListener>&)
655 for(
size_t i = 0, n= pFormat->
size();
i <
n; ++
i)
669 maPropSet(getConditionEntryrPropSet()),
681 if (isObjectStillAlive(pFormat,
mpFormat))
684 throw lang::IllegalArgumentException();
694 static uno::Reference<beans::XPropertySetInfo> aRef(
700 const OUString& aPropertyName,
const uno::Any& aValue )
707 throw beans::UnknownPropertyException(aPropertyName);
714 if ((aValue >>= aStyleName) && !aStyleName.isEmpty())
721 if ((aValue >>= aFormula) && !aFormula.isEmpty())
725 std::unique_ptr<ScTokenArray> pArr(aComp.CompileString(aFormula));
733 if ((aValue >>= aFormula) && !aFormula.isEmpty())
737 std::unique_ptr<ScTokenArray> pArr(aComp.CompileString(aFormula));
747 for (ConditionEntryApiMap
const & rEntry : aConditionEntryMap)
749 if (rEntry.nApiMode == nVal)
759 SAL_WARN(
"sc",
"unsupported property");
770 throw beans::UnknownPropertyException(aPropertyName);
795 for (ConditionEntryApiMap
const & rEntry : aConditionEntryMap)
797 if (rEntry.eMode == eMode)
799 aAny <<= rEntry.nApiMode;
806 SAL_WARN(
"sc",
"unsupported property");
812 const uno::Reference<beans::XPropertyChangeListener>& )
818 const uno::Reference<beans::XPropertyChangeListener>& )
824 const uno::Reference<beans::XVetoableChangeListener>&)
830 const uno::Reference<beans::XVetoableChangeListener>&)
838 maPropSet(getColorScalePropSet()),
850 if (isObjectStillAlive(pFormat,
mpFormat))
853 throw lang::IllegalArgumentException();
863 static uno::Reference<beans::XPropertySetInfo> aRef(
870 void setColorScaleEntry(
ScColorScaleEntry* pEntry, uno::Reference<sheet::XColorScaleEntry>
const & xEntry)
873 sal_Int32 nApiType = xEntry->getType();
875 for (ColorScaleEntryTypeApiMap
const & rEntry : aColorScaleEntryTypeMap)
877 if (rEntry.nApiType == nApiType)
879 eType = rEntry.eType;
886 throw lang::IllegalArgumentException();
897 double nVal = xEntry->getFormula().toDouble();
907 const OUString& aPropertyName,
const uno::Any& aValue )
914 throw beans::UnknownPropertyException(aPropertyName);
918 case ColorScaleEntries:
920 uno::Sequence<uno::Reference<sheet::XColorScaleEntry> >
aEntries;
921 if (!(aValue >>= aEntries))
922 throw lang::IllegalArgumentException();
924 if (aEntries.getLength() < 2)
925 throw lang::IllegalArgumentException();
928 size_t n = size_t(aEntries.getLength());
929 for (
size_t i = 0;
i < n; ++
i)
948 throw beans::UnknownPropertyException(aPropertyName);
954 case ColorScaleEntries:
972 const uno::Reference<beans::XPropertyChangeListener>& )
978 const uno::Reference<beans::XPropertyChangeListener>& )
984 const uno::Reference<beans::XVetoableChangeListener>&)
990 const uno::Reference<beans::XVetoableChangeListener>&)
1010 throw lang::IllegalArgumentException();
1018 return sal_Int32(aColor);
1029 for (ColorScaleEntryTypeApiMap
const & rEntry : aColorScaleEntryTypeMap)
1031 if (rEntry.eType == pEntry->
GetType())
1033 return rEntry.nApiType;
1037 throw lang::IllegalArgumentException();
1043 for (ColorScaleEntryTypeApiMap
const & rEntry : aColorScaleEntryTypeMap)
1045 if (rEntry.nApiType == nType)
1047 pEntry->
SetType(rEntry.eType);
1051 throw lang::IllegalArgumentException();
1063 return OUString::number(pEntry->
GetValue());
1079 pEntry->
SetValue(rFormula.toDouble());
1088 maPropSet(getDataBarPropSet()),
1100 if (isObjectStillAlive(pFormat,
mpFormat))
1103 throw lang::IllegalArgumentException();
1114 static uno::Reference<beans::XPropertySetInfo> aRef(
1121 void setDataBarEntry(
ScColorScaleEntry* pEntry, uno::Reference<sheet::XDataBarEntry>
const & xEntry)
1124 sal_Int32 nApiType = xEntry->getType();
1125 bool bFound =
false;
1126 for (DataBarEntryTypeApiMap
const & rEntry : aDataBarEntryTypeMap)
1128 if (rEntry.nApiType == nApiType)
1130 eType = rEntry.eType;
1137 throw lang::IllegalArgumentException();
1147 double nVal = xEntry->getFormula().toDouble();
1157 const OUString& aPropertyName,
const uno::Any& aValue )
1164 throw beans::UnknownPropertyException(aPropertyName);
1166 switch(pEntry->
nWID)
1171 if (aValue >>= nVal)
1173 for (DataBarAxisApiMap
const & rEntry : aDataBarAxisMap)
1175 if (rEntry.nApiPos == nVal)
1187 bool bUseGradient =
true;
1188 if (aValue >>= bUseGradient)
1194 case UseNegativeColor:
1196 bool bUseNegativeColor =
false;
1197 if (aValue >>= bUseNegativeColor)
1200 if (bUseNegativeColor && !
getCoreObject()->GetDataBarData()->mxNegativeColor)
1207 case DataBar_ShowValue:
1209 bool bShowValue =
true;
1210 if (aValue >>= bShowValue)
1219 if (aValue >>= nColor)
1228 if (aValue >>= nAxisColor)
1237 if (!(aValue >>= nNegativeColor) || !
getCoreObject()->GetDataBarData()->mbNeg)
1238 throw lang::IllegalArgumentException();
1244 case DataBarEntries:
1246 uno::Sequence<uno::Reference<sheet::XDataBarEntry> >
aEntries;
1247 if (!(aValue >>= aEntries))
1248 throw lang::IllegalArgumentException();
1250 if (aEntries.getLength() != 2)
1251 throw lang::IllegalArgumentException();
1253 setDataBarEntry(
getCoreObject()->GetDataBarData()->mpLowerLimit.get(),
1255 setDataBarEntry(
getCoreObject()->GetDataBarData()->mpUpperLimit.get(),
1263 if (!(aValue >>= nLength) || nLength >= 100 || nLength < 0)
1264 throw lang::IllegalArgumentException();
1272 if (!(aValue >>= nLength) || nLength > 100 || nLength <= 0)
1273 throw lang::IllegalArgumentException();
1288 throw beans::UnknownPropertyException(aPropertyName);
1291 switch(pEntry->
nWID)
1296 sal_Int32 nApiPos = sheet::DataBarAxis::AXIS_NONE;
1297 for (DataBarAxisApiMap
const & rEntry : aDataBarAxisMap)
1299 if (rEntry.ePos == ePos)
1301 nApiPos = rEntry.nApiPos;
1313 case UseNegativeColor:
1318 case DataBar_ShowValue:
1341 case DataBarEntries:
1343 uno::Sequence<uno::Reference<sheet::XDataBarEntry> >
aEntries(2);
1354 const uno::Reference<beans::XPropertyChangeListener>& )
1360 const uno::Reference<beans::XPropertyChangeListener>& )
1366 const uno::Reference<beans::XVetoableChangeListener>&)
1372 const uno::Reference<beans::XVetoableChangeListener>&)
1403 for (DataBarEntryTypeApiMap
const & rEntry : aDataBarEntryTypeMap)
1405 if (rEntry.eType == pEntry->
GetType())
1407 return rEntry.nApiType;
1411 throw lang::IllegalArgumentException();
1417 for (DataBarEntryTypeApiMap
const & rEntry : aDataBarEntryTypeMap)
1419 if (rEntry.nApiType == nType)
1421 pEntry->
SetType(rEntry.eType);
1425 throw lang::IllegalArgumentException();
1437 return OUString::number(pEntry->
GetValue());
1453 pEntry->
SetValue(rFormula.toDouble());
1462 maPropSet(getIconSetPropSet()),
1474 if (isObjectStillAlive(pFormat,
mpFormat))
1477 throw lang::IllegalArgumentException();
1488 static uno::Reference<beans::XPropertySetInfo> aRef(
1495 void setIconSetEntry(
ScIconSetFormat* pFormat, uno::Reference<sheet::XIconSetEntry>
const & xEntry,
size_t nPos)
1499 sal_Int32 nApiType = xEntry->getType();
1500 bool bFound =
false;
1501 for (IconSetEntryTypeApiMap
const & rEntry : aIconSetEntryTypeMap)
1503 if (rEntry.nApiType == nApiType)
1505 eType = rEntry.eType;
1512 throw lang::IllegalArgumentException();
1522 double nVal = xEntry->getFormula().toDouble();
1532 const OUString& aPropertyName,
const uno::Any& aValue )
1539 throw beans::UnknownPropertyException(aPropertyName);
1541 switch(pEntry->
nWID)
1545 bool bShowValue =
true;
1546 aValue >>= bShowValue;
1552 bool bReverse =
false;
1553 aValue >>= bReverse;
1559 sal_Int32 nApiType = -1;
1560 aValue >>= nApiType;
1562 bool bFound =
false;
1563 for (
const IconSetTypeApiMap & rEntry : aIconSetApiMap)
1565 if (rEntry.nApiType == nApiType)
1567 eType = rEntry.eType;
1575 throw lang::IllegalArgumentException();
1582 case IconSetEntries:
1584 uno::Sequence<uno::Reference<sheet::XIconSetEntry> >
aEntries;
1585 if (!(aValue >>= aEntries))
1586 throw lang::IllegalArgumentException();
1590 sal_Int32
nLength = aEntries.getLength();
1610 throw beans::UnknownPropertyException(aPropertyName);
1614 switch(pEntry->
nWID)
1625 for (
const IconSetTypeApiMap & rEntry : aIconSetApiMap)
1627 if (rEntry.eType == eType)
1629 aAny <<= rEntry.nApiType;
1635 case IconSetEntries:
1638 uno::Sequence<uno::Reference<sheet::XIconSetEntry> >
aEntries(nSize);
1639 for (
size_t i = 0;
i < nSize; ++
i)
1647 SAL_WARN(
"sc",
"unknown property");
1653 const uno::Reference<beans::XPropertyChangeListener>& )
1659 const uno::Reference<beans::XPropertyChangeListener>& )
1665 const uno::Reference<beans::XVetoableChangeListener>&)
1671 const uno::Reference<beans::XVetoableChangeListener>&)
1691 throw lang::IllegalArgumentException();
1701 return sheet::IconSetFormatEntry::ICONSET_MIN;
1703 for (IconSetEntryTypeApiMap
const & rEntry : aIconSetEntryTypeMap)
1705 if (rEntry.eType == pEntry->
GetType())
1707 return rEntry.nApiType;
1711 throw lang::IllegalArgumentException();
1721 for (IconSetEntryTypeApiMap
const & rEntry : aIconSetEntryTypeMap)
1723 if (rEntry.nApiType == nType)
1725 pEntry->
SetType(rEntry.eType);
1729 throw lang::IllegalArgumentException();
1741 return OUString::number(pEntry->
GetValue());
1757 pEntry->
SetValue(rFormula.toDouble());
1765 maPropSet(getCondDatePropSet()),
1777 if (isObjectStillAlive(pFormat,
mpFormat))
1780 throw lang::IllegalArgumentException();
1791 static uno::Reference<beans::XPropertySetInfo> aRef(
1797 const OUString& aPropertyName,
const uno::Any& aValue )
1804 throw beans::UnknownPropertyException(aPropertyName);
1806 switch(pEntry->
nWID)
1808 case Date_StyleName:
1810 OUString aStyleName;
1811 if (!(aValue >>= aStyleName))
1812 throw lang::IllegalArgumentException();
1820 sal_Int32 nApiType = -1;
1821 if (!(aValue >>= nApiType))
1822 throw lang::IllegalArgumentException();
1824 for (DateTypeApiMap
const & rEntry : aDateTypeApiMap)
1826 if (rEntry.nApiType == nApiType)
1846 throw beans::UnknownPropertyException(aPropertyName);
1850 switch(pEntry->
nWID)
1852 case Date_StyleName:
1855 aAny <<= aStyleName;
1861 for (DateTypeApiMap
const & rEntry : aDateTypeApiMap)
1863 if (rEntry.eType == eType)
1865 aAny <<= rEntry.nApiType;
1872 SAL_WARN(
"sc",
"unknown property");
1878 const uno::Reference<beans::XPropertyChangeListener>& )
1884 const uno::Reference<beans::XPropertyChangeListener>& )
1890 const uno::Reference<beans::XVetoableChangeListener>&)
1896 const uno::Reference<beans::XVetoableChangeListener>&)
void SetOperation(ScConditionMode eMode)
virtual void SAL_CALL setFormula(const OUString &rString) override
const SfxItemPropertySimpleEntry * getByName(std::u16string_view rName) const
ScIconSetEntryObj(rtl::Reference< ScIconSetFormatObj > const &xParent, size_t nPos)
ScDataBarEntryObj(rtl::Reference< ScDataBarFormatObj > const &xParent, size_t nPos)
void SetGrammar(const formula::FormulaGrammar::Grammar eGrammar)
rtl::Reference< ScColorScaleFormatObj > mxParent
std::unique_ptr< ContentProperties > pData
const ScCondFormatEntry * mpFormat
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
virtual ~ScDataBarEntryObj() override
ScCondFormatEntry * getCoreObject()
void SetFormula1(const ScTokenArray &rArray)
WeakReference< XInterface > mxParent
ScColorScaleEntry * getCoreObject()
const OUString & GetStyle() const
condformat::ScCondFormatDateType GetDateType() const
SC_DLLPUBLIC sal_uLong AddCondFormat(std::unique_ptr< ScConditionalFormat > pNew, SCTAB nTab)
void SetValue(double nValue)
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
ScConditionEntryObj(rtl::Reference< ScCondFormatObj > const &xParent, const ScCondFormatEntry *pFormat)
ScConditionMode GetOperation() const
css::chart::ChartAxisLabelPosition ePos
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
ScColorScaleEntryObj(rtl::Reference< ScColorScaleFormatObj > const &xParent, size_t nPos)
constexpr::Color COL_AUTO(0xFF, 0xFF, 0xFF, 0xFF)
SC_DLLPUBLIC ScConditionalFormatList * GetCondFormList(SCTAB nTab) const
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
virtual ~ScIconSetEntryObj() override
void SetColor(const Color &)
ScColorScaleEntryType GetType() const
ScColorScaleEntry * getCoreObject()
ScAddress GetTopLeftCorner() const
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
ScDocShell * getDocShell(const css::uno::Reference< css::frame::XModel > &xModel)
const Color & GetColor() const
OUString GetExpression(const ScAddress &rCursor, sal_uInt16 nPos, sal_uInt32 nNumFmt=0, const formula::FormulaGrammar::Grammar eGrammar=formula::FormulaGrammar::GRAM_DEFAULT) const
SfxItemPropertySet maPropSet
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
rtl::Reference< ScCondFormatObj > mxParent
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
virtual void SAL_CALL setColor(sal_Int32 aColor) override
const SfxItemPropertyMap & getPropertyMap() const
virtual sal_Int32 SAL_CALL getColor() override
virtual sal_Int32 SAL_CALL getType() override
css::uno::Type const & get()
void SetFormula2(const ScTokenArray &rArray)
void UpdateStyleName(const OUString &rNew)
const ScAddress & GetSrcPos() const
virtual void SAL_CALL setFormula(const OUString &rString) override
void AddUnoObject(SfxListener &rObject)
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
virtual sal_Int32 SAL_CALL getType() override
virtual ~ScConditionEntryObj() override
rtl::Reference< ScIconSetFormatObj > mxParent
void Join(const ScRange &, bool bIsInList=false)
virtual OUString SAL_CALL getFormula() override
const OUString & GetStyleName() const
virtual void SAL_CALL setType(sal_Int32 nType) override
virtual void SAL_CALL setFormula(const OUString &rString) override
void RemoveUnoObject(SfxListener &rObject)
void SetDateType(condformat::ScCondFormatDateType eType)
virtual OUString SAL_CALL getFormula() override
const ScDocument & GetDocument() const
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual void SAL_CALL setType(sal_Int32 nType) override
virtual Type GetType() const =0
ScXMLEditAttributeMap::Entry const aEntries[]
ScColorScaleEntry * getCoreObject()
virtual ~ScColorScaleEntryObj() override
#define SAL_WARN(area, stream)
void SetType(ScColorScaleEntryType eType)
virtual void SAL_CALL setType(sal_Int32 nType) override
static void FillScRange(ScRange &rScRange, const css::table::CellRangeAddress &rApiRange)
virtual OUString SAL_CALL getFormula() override
virtual sal_Int32 SAL_CALL getType() override
virtual sal_Int32 SAL_CALL getType() override
void SetStyleName(const OUString &rStyleName)
rtl::Reference< ScDataBarFormatObj > mxParent