diff options
-rw-r--r-- | sc/source/ui/inc/condformatuno.hxx | 26 | ||||
-rw-r--r-- | sc/source/ui/unoobj/condformatuno.cxx | 115 |
2 files changed, 138 insertions, 3 deletions
diff --git a/sc/source/ui/inc/condformatuno.hxx b/sc/source/ui/inc/condformatuno.hxx index a4f6928413c6..7088bd394c5c 100644 --- a/sc/source/ui/inc/condformatuno.hxx +++ b/sc/source/ui/inc/condformatuno.hxx @@ -441,6 +441,32 @@ private: const ScIconSetFormat* mpFormat; }; +class ScIconSetEntryObj : public cppu::WeakImplHelper1<com::sun::star::sheet::XIconSetEntry> +{ +public: + ScIconSetEntryObj(rtl::Reference<ScIconSetFormatObj> xParent, size_t nPos); + + virtual ~ScIconSetEntryObj(); + + virtual sal_Int32 SAL_CALL getType() + throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual void SAL_CALL setType(sal_Int32 nType) + throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual OUString SAL_CALL getFormula() + throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual void SAL_CALL setFormula(const OUString& rString) + throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + +private: + ScColorScaleEntry* getCoreObject(); + + rtl::Reference<ScIconSetFormatObj> mxParent; + size_t mnPos; +}; + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx index a78c5627720d..6bbbe2e2385c 100644 --- a/sc/source/ui/unoobj/condformatuno.cxx +++ b/sc/source/ui/unoobj/condformatuno.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/sheet/DataBarAxis.hpp> #include <com/sun/star/sheet/ConditionFormatOperator.hpp> #include <com/sun/star/sheet/DataBarEntryType.hpp> +#include <com/sun/star/sheet/IconSetFormatEntry.hpp> namespace { @@ -229,6 +230,21 @@ const IconSetTypeApiMap aIconSetApiMap[] = { IconSet_5Quarters, sheet::IconSetType::ICONSET_5QUARTERS }, }; +struct IconSetEntryTypeApiMap +{ + ScColorScaleEntryType eType; + sal_Int32 nApiType; +}; + +IconSetEntryTypeApiMap aIconSetEntryTypeMap[] = +{ + { COLORSCALE_MIN, sheet::IconSetFormatEntry::ICONSET_MIN }, + { COLORSCALE_VALUE, sheet::IconSetFormatEntry::ICONSET_VALUE }, + { COLORSCALE_FORMULA, sheet::IconSetFormatEntry::ICONSET_FORMULA }, + { COLORSCALE_PERCENT, sheet::IconSetFormatEntry::ICONSET_PERCENT }, + { COLORSCALE_PERCENTILE, sheet::IconSetFormatEntry::ICONSET_PERCENTILE } +}; + } ScCondFormatsObj::ScCondFormatsObj(ScDocShell* pDocShell, SCTAB nTab): @@ -1266,6 +1282,15 @@ void SAL_CALL ScIconSetFormatObj::setPropertyValue( } break; case IconSetEntries: + { + uno::Sequence<uno::Reference<sheet::XIconSetEntry> > aEntries; + if (aValue >>= aEntries) + { + + } + else + throw lang::IllegalArgumentException(); + } break; default: break; @@ -1308,11 +1333,13 @@ uno::Any SAL_CALL ScIconSetFormatObj::getPropertyValue( const OUString& aPropert break; case IconSetEntries: { - uno::Sequence< sheet::XIconSetEntry > aEntries(getCoreObject()->size()); - for (auto it = getCoreObject()->begin(), itEnd = getCoreObject()->end(); it != itEnd; ++it) + uno::Sequence<uno::Reference<sheet::XIconSetEntry> > aEntries(getCoreObject()->size()); + size_t i = 0; + for (auto it = getCoreObject()->begin(), itEnd = getCoreObject()->end(); it != itEnd; ++it, ++i) { - //aEntries.operator[] = ; + aEntries[i] = new ScIconSetEntryObj(this, i); } + aAny <<= aEntries; } break; default: @@ -1353,4 +1380,86 @@ void SAL_CALL ScIconSetFormatObj::removeVetoableChangeListener( const OUString&, SAL_WARN("sc", "not implemented"); } +ScIconSetEntryObj::ScIconSetEntryObj(rtl::Reference<ScIconSetFormatObj> xParent, + size_t nPos): + mxParent(xParent), + mnPos(nPos) +{ +} + +ScIconSetEntryObj::~ScIconSetEntryObj() +{ +} + +ScColorScaleEntry* ScIconSetEntryObj::getCoreObject() +{ + ScIconSetFormat* pFormat = mxParent->getCoreObject(); + if (pFormat->GetIconSetData()->maEntries.size() <= mnPos) + throw lang::IllegalArgumentException(); + + return &pFormat->GetIconSetData()->maEntries[mnPos]; +} + +sal_Int32 ScIconSetEntryObj::getType() + throw(uno::RuntimeException, std::exception) +{ + ScColorScaleEntry* pEntry = getCoreObject(); + for (size_t i = 0; i < SAL_N_ELEMENTS(aIconSetEntryTypeMap); ++i) + { + if (aIconSetEntryTypeMap[i].eType == pEntry->GetType()) + { + return aIconSetEntryTypeMap[i].nApiType; + } + } + + throw lang::IllegalArgumentException(); +} + +void ScIconSetEntryObj::setType(sal_Int32 nType) + throw(uno::RuntimeException, std::exception) +{ + ScColorScaleEntry* pEntry = getCoreObject(); + for (size_t i = 0; i < SAL_N_ELEMENTS(aIconSetEntryTypeMap); ++i) + { + if (aIconSetEntryTypeMap[i].nApiType == nType) + { + pEntry->SetType(aIconSetEntryTypeMap[i].eType); + return; + } + } + throw lang::IllegalArgumentException(); +} + +OUString ScIconSetEntryObj::getFormula() + throw(uno::RuntimeException, std::exception) +{ + ScColorScaleEntry* pEntry = getCoreObject(); + switch (pEntry->GetType()) + { + case COLORSCALE_FORMULA: + // TODO: Implement + break; + default: + return OUString::number(pEntry->GetValue()); + } + + return OUString(); +} + +void ScIconSetEntryObj::setFormula(const OUString& rFormula) + throw(uno::RuntimeException, std::exception) +{ + ScColorScaleEntry* pEntry = getCoreObject(); + switch (pEntry->GetType()) + { + case COLORSCALE_FORMULA: + // TODO: Implement + // pEntry->SetFormula(rFormula); + break; + default: + pEntry->SetValue(rFormula.toDouble()); + break; + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |