bin/gbuild-to-ide | 1 offapi/UnoApi_offapi.mk | 16 offapi/com/sun/star/sheet/ConditionEntryType.idl | 8 offapi/com/sun/star/sheet/ConditionFormatEntry.idl | 9 offapi/com/sun/star/sheet/ConditionFormatOperator.idl | 10 offapi/com/sun/star/sheet/ConditionalFormat.idl | 4 offapi/com/sun/star/sheet/DataBar.idl | 8 offapi/com/sun/star/sheet/IconSet.idl | 5 offapi/com/sun/star/sheet/IconSetFormatEntry.idl | 15 offapi/com/sun/star/sheet/XColorScaleEntry.idl | 16 offapi/com/sun/star/sheet/XDataBarEntry.idl | 12 offapi/com/sun/star/sheet/XIconSetEntry.idl | 12 sc/CppunitTest_sc_new_cond_format_api.mk | 109 + sc/Library_sc.mk | 1 sc/Module_sc.mk | 1 sc/inc/colorscale.hxx | 6 sc/inc/conditio.hxx | 2 sc/inc/unonames.hxx | 1 sc/inc/unowids.hxx | 3 sc/qa/extras/new_cond_format.cxx | 307 +++ sc/qa/extras/testdocuments/new_cond_format_api.ods |binary sc/source/core/data/colorscale.cxx | 24 sc/source/core/data/conditio.cxx | 14 sc/source/ui/inc/condformatuno.hxx | 520 +++++ sc/source/ui/unoobj/cellsuno.cxx | 15 sc/source/ui/unoobj/condformatuno.cxx | 1746 ++++++++++++++++++ 26 files changed, 2835 insertions(+), 30 deletions(-)
New commits: commit 64c251f99ba633c96c1e3410e69dfcdcbf44a267 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Mon Mar 30 02:03:14 2015 +0200 let all cond format objects inherit from XConditionEntry Change-Id: I60f156b4a64cc70bd1d19f4bb29c79cc8cff3e94 diff --git a/sc/source/ui/inc/condformatuno.hxx b/sc/source/ui/inc/condformatuno.hxx index 48ab6fe..99e5dec 100644 --- a/sc/source/ui/inc/condformatuno.hxx +++ b/sc/source/ui/inc/condformatuno.hxx @@ -238,7 +238,8 @@ private: const ScCondFormatEntry* mpFormat; }; -class ScColorScaleFormatObj : public cppu::WeakImplHelper1<com::sun::star::beans::XPropertySet> +class ScColorScaleFormatObj : public cppu::WeakImplHelper2<com::sun::star::beans::XPropertySet, + com::sun::star::sheet::XConditionEntry> { public: @@ -247,6 +248,11 @@ public: static ScColorScaleFormatObj* getImplementation(uno::Reference<beans::XPropertySet> xPropSet); + // XConditionEntry + virtual sal_Int32 SAL_CALL getType() + throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + ScColorScaleFormat* getCoreObject(); // XPropertySet @@ -329,7 +335,8 @@ private: size_t mnPos; }; -class ScDataBarFormatObj : public cppu::WeakImplHelper1<com::sun::star::beans::XPropertySet> +class ScDataBarFormatObj : public cppu::WeakImplHelper2<com::sun::star::beans::XPropertySet, + com::sun::star::sheet::XConditionEntry> { public: ScDataBarFormatObj(rtl::Reference<ScCondFormatObj> xParent, @@ -340,7 +347,11 @@ public: ScDataBarFormat* getCoreObject(); - // XPropertySet + // XConditionEntry + virtual sal_Int32 SAL_CALL getType() + throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + // XPropertySet virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; @@ -414,7 +425,8 @@ private: size_t mnPos; }; -class ScIconSetFormatObj : public cppu::WeakImplHelper1<com::sun::star::beans::XPropertySet> +class ScIconSetFormatObj : public cppu::WeakImplHelper2<com::sun::star::beans::XPropertySet, + com::sun::star::sheet::XConditionEntry> { public: ScIconSetFormatObj(rtl::Reference<ScCondFormatObj> xParent, @@ -425,7 +437,11 @@ public: ScIconSetFormat* getCoreObject(); - // XPropertySet + // XConditionEntry + virtual sal_Int32 SAL_CALL getType() + throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + // XPropertySet virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx index b3ff5c9..ba9d496 100644 --- a/sc/source/ui/unoobj/condformatuno.cxx +++ b/sc/source/ui/unoobj/condformatuno.cxx @@ -30,6 +30,7 @@ #include <com/sun/star/sheet/DataBarEntryType.hpp> #include <com/sun/star/sheet/ColorScaleEntryType.hpp> #include <com/sun/star/sheet/IconSetFormatEntry.hpp> +#include <com/sun/star/sheet/ConditionEntryType.hpp> namespace { @@ -613,7 +614,7 @@ ScCondFormatEntry* ScConditionEntryObj::getCoreObject() sal_Int32 ScConditionEntryObj::getType() throw(uno::RuntimeException, std::exception) { - return 0; + return sheet::ConditionEntryType::CONDITION; } uno::Reference<beans::XPropertySetInfo> SAL_CALL ScConditionEntryObj::getPropertySetInfo() @@ -729,7 +730,6 @@ uno::Any SAL_CALL ScConditionEntryObj::getPropertyValue( const OUString& aProper { aAny <<= aConditionEntryMap[i].nApiMode; break; - } } } @@ -794,6 +794,12 @@ ScColorScaleFormat* ScColorScaleFormatObj::getCoreObject() throw lang::IllegalArgumentException(); } +sal_Int32 ScColorScaleFormatObj::getType() + throw(uno::RuntimeException, std::exception) +{ + return sheet::ConditionEntryType::COLORSCALE; +} + uno::Reference<beans::XPropertySetInfo> SAL_CALL ScColorScaleFormatObj::getPropertySetInfo() throw(uno::RuntimeException, std::exception) { @@ -1057,6 +1063,12 @@ ScDataBarFormat* ScDataBarFormatObj::getCoreObject() throw lang::IllegalArgumentException(); } +sal_Int32 ScDataBarFormatObj::getType() + throw(uno::RuntimeException, std::exception) +{ + return sheet::ConditionEntryType::DATABAR; +} + uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDataBarFormatObj::getPropertySetInfo() throw(uno::RuntimeException, std::exception) { @@ -1432,6 +1444,12 @@ ScIconSetFormat* ScIconSetFormatObj::getCoreObject() throw lang::IllegalArgumentException(); } +sal_Int32 ScIconSetFormatObj::getType() + throw(uno::RuntimeException, std::exception) +{ + return sheet::ConditionEntryType::ICONSET; +} + uno::Reference<beans::XPropertySetInfo> SAL_CALL ScIconSetFormatObj::getPropertySetInfo() throw(uno::RuntimeException, std::exception) { commit d21f9f5079c4ca705331dcb298709bc55971bafa Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Mon Mar 30 02:02:39 2015 +0200 fix API values Change-Id: I3a5890d8d46936b264510150ef0fa8ac79feb74d diff --git a/offapi/com/sun/star/sheet/ConditionEntryType.idl b/offapi/com/sun/star/sheet/ConditionEntryType.idl index 151ed52..43148cf 100644 --- a/offapi/com/sun/star/sheet/ConditionEntryType.idl +++ b/offapi/com/sun/star/sheet/ConditionEntryType.idl @@ -16,13 +16,13 @@ constants ConditionEntryType { const long CONDITION = 0; - const long COLORSCALE = 0; + const long COLORSCALE = 1; - const long DATABAR = 0; + const long DATABAR = 2; - const long ICONSET = 0; + const long ICONSET = 3; - const long DATE = 0; + const long DATE = 4; }; commit fc3e8355774a5e7ee524626bc50f2a39d4785c00 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Mon Mar 30 01:55:29 2015 +0200 implement last part for color scales Change-Id: Ieaca45d01b5e631e624016b58ab7964dc880725a diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx index e7295f9..b3ff5c9 100644 --- a/sc/source/ui/unoobj/condformatuno.cxx +++ b/sc/source/ui/unoobj/condformatuno.cxx @@ -802,8 +802,46 @@ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScColorScaleFormatObj::getPrope return aRef; } +namespace { + +void setColorScaleEntry(ScColorScaleEntry* pEntry, uno::Reference<sheet::XColorScaleEntry> xEntry) +{ + ScColorScaleEntryType eType; + sal_Int32 nApiType = xEntry->getType(); + bool bFound = false; + for (size_t i = 0; i < SAL_N_ELEMENTS(aColorScaleEntryTypeMap); ++i) + { + if (aColorScaleEntryTypeMap[i].nApiType == nApiType) + { + eType = aColorScaleEntryTypeMap[i].eType; + bFound = true; + break; + } + } + + if (!bFound) + throw lang::IllegalArgumentException(); + + pEntry->SetType(eType); + pEntry->SetColor(xEntry->getColor()); + switch (eType) + { + case COLORSCALE_FORMULA: + // TODO: Implement + break; + default: + { + double nVal = xEntry->getFormula().toDouble(); + pEntry->SetValue(nVal); + } + break; + } +} + +} + void SAL_CALL ScColorScaleFormatObj::setPropertyValue( - const OUString& aPropertyName, const uno::Any& /*aValue*/ ) + const OUString& aPropertyName, const uno::Any& aValue ) throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception) @@ -818,6 +856,19 @@ void SAL_CALL ScColorScaleFormatObj::setPropertyValue( switch(pEntry->nWID) { case ColorScaleEntries: + { + uno::Sequence<uno::Reference<sheet::XColorScaleEntry> > aEntries; + if (aValue >>= aEntries) + { + size_t n = size_t(aEntries.getLength()); + for (size_t i = 0; i < n; ++i) + { + setColorScaleEntry(getCoreObject()->GetEntry(i), aEntries[i]); + } + } + else + throw lang::IllegalArgumentException(); + } break; default: SAL_WARN("sc", "unknown property"); commit 21e9287987e99b1c9a5b9af7ace1c3f8b3b888dd Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Mon Mar 30 01:47:13 2015 +0200 add color scale entries Change-Id: If88822765b5ec738f3204a4ef7c76c3d529e6be2 diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx index 1b5c4f6..7409706 100644 --- a/sc/inc/colorscale.hxx +++ b/sc/inc/colorscale.hxx @@ -281,6 +281,8 @@ public: iterator end(); const_iterator end() const; + ScColorScaleEntry* GetEntry(size_t nPos); + size_t size() const; }; diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 366f9dc..9f02077 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -671,6 +671,14 @@ ScColorScaleFormat::const_iterator ScColorScaleFormat::end() const return maColorScales.end(); } +ScColorScaleEntry* ScColorScaleFormat::GetEntry(size_t nPos) +{ + if (maColorScales.size() <= nPos) + return NULL; + + return &maColorScales[nPos]; +} + size_t ScColorScaleFormat::size() const { return maColorScales.size(); diff --git a/sc/source/ui/inc/condformatuno.hxx b/sc/source/ui/inc/condformatuno.hxx index 1792058..48ab6fe 100644 --- a/sc/source/ui/inc/condformatuno.hxx +++ b/sc/source/ui/inc/condformatuno.hxx @@ -297,6 +297,38 @@ private: const ScColorScaleFormat* mpFormat; }; +class ScColorScaleEntryObj : public cppu::WeakImplHelper1<com::sun::star::sheet::XColorScaleEntry> +{ +public: + ScColorScaleEntryObj(rtl::Reference<ScColorScaleFormatObj> xParent, size_t nPos); + + virtual ~ScColorScaleEntryObj(); + + virtual com::sun::star::util::Color SAL_CALL getColor() + throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual void SAL_CALL setColor(com::sun::star::util::Color aColor) + throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + 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<ScColorScaleFormatObj> mxParent; + size_t mnPos; +}; + class ScDataBarFormatObj : public cppu::WeakImplHelper1<com::sun::star::beans::XPropertySet> { public: diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx index c0c20f0..e7295f9 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/ColorScaleEntryType.hpp> #include <com/sun/star/sheet/IconSetFormatEntry.hpp> namespace { @@ -121,6 +122,22 @@ const SfxItemPropertyMapEntry* getColorScalePropSet() return aColorScalePropertyMap_Impl; } +struct ColorScaleEntryTypeApiMap +{ + ScColorScaleEntryType eType; + sal_Int32 nApiType; +}; + +ColorScaleEntryTypeApiMap aColorScaleEntryTypeMap[] = +{ + { COLORSCALE_MIN, sheet::ColorScaleEntryType::COLORSCALE_MIN }, + { COLORSCALE_MAX, sheet::ColorScaleEntryType::COLORSCALE_MAX }, + { COLORSCALE_VALUE, sheet::ColorScaleEntryType::COLORSCALE_VALUE }, + { COLORSCALE_FORMULA, sheet::ColorScaleEntryType::COLORSCALE_FORMULA }, + { COLORSCALE_PERCENT, sheet::ColorScaleEntryType::COLORSCALE_PERCENT }, + { COLORSCALE_PERCENTILE, sheet::ColorScaleEntryType::COLORSCALE_PERCENTILE } +}; + enum DataBarProperties { AxisPosition, @@ -823,6 +840,14 @@ uno::Any SAL_CALL ScColorScaleFormatObj::getPropertyValue( const OUString& aProp switch(pEntry->nWID) { case ColorScaleEntries: + { + uno::Sequence<uno::Reference<sheet::XColorScaleEntry> > aEntries(getCoreObject()->size()); + for (size_t i = 0; i < getCoreObject()->size(); ++i) + { + aEntries[i] = new ScColorScaleEntryObj(this, i); + } + aAny <<= aEntries; + } break; default: SAL_WARN("sc", "unknown property"); @@ -863,6 +888,102 @@ void SAL_CALL ScColorScaleFormatObj::removeVetoableChangeListener( const OUStrin SAL_WARN("sc", "not implemented"); } +ScColorScaleEntryObj::ScColorScaleEntryObj(rtl::Reference<ScColorScaleFormatObj> xParent, + size_t nPos): + mxParent(xParent), + mnPos(nPos) +{ +} + +ScColorScaleEntryObj::~ScColorScaleEntryObj() +{ +} + +ScColorScaleEntry* ScColorScaleEntryObj::getCoreObject() +{ + ScColorScaleFormat* pFormat = mxParent->getCoreObject(); + if (pFormat->size() <= mnPos) + throw lang::IllegalArgumentException(); + + return pFormat->GetEntry(mnPos); +} + +util::Color ScColorScaleEntryObj::getColor() + throw(uno::RuntimeException, std::exception) +{ + Color aColor = getCoreObject()->GetColor(); + return aColor.GetColor(); +} + +void ScColorScaleEntryObj::setColor(util::Color aColor) + throw(uno::RuntimeException, std::exception) +{ + getCoreObject()->SetColor(Color(aColor)); +} + +sal_Int32 ScColorScaleEntryObj::getType() + throw(uno::RuntimeException, std::exception) +{ + ScColorScaleEntry* pEntry = getCoreObject(); + for (size_t i = 0; i < SAL_N_ELEMENTS(aColorScaleEntryTypeMap); ++i) + { + if (aColorScaleEntryTypeMap[i].eType == pEntry->GetType()) + { + return aColorScaleEntryTypeMap[i].nApiType; + } + } + + throw lang::IllegalArgumentException(); +} + +void ScColorScaleEntryObj::setType(sal_Int32 nType) + throw(uno::RuntimeException, std::exception) +{ + ScColorScaleEntry* pEntry = getCoreObject(); + for (size_t i = 0; i < SAL_N_ELEMENTS(aColorScaleEntryTypeMap); ++i) + { + if (aColorScaleEntryTypeMap[i].nApiType == nType) + { + pEntry->SetType(aColorScaleEntryTypeMap[i].eType); + return; + } + } + throw lang::IllegalArgumentException(); +} + +OUString ScColorScaleEntryObj::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 ScColorScaleEntryObj::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; + } +} + + ScDataBarFormatObj::ScDataBarFormatObj(rtl::Reference<ScCondFormatObj> xParent, const ScDataBarFormat* pFormat): mpDocShell(xParent->getDocShell()), commit 2773e6ffb57d514e667e8e75cf165a6bfef82dec Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Mon Mar 30 01:27:47 2015 +0200 add last databar part Change-Id: Id86dfa4e6795d0ec6a66850747f95de6b0bd8b98 diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx index 0b81b5a..c0c20f0 100644 --- a/sc/source/ui/unoobj/condformatuno.cxx +++ b/sc/source/ui/unoobj/condformatuno.cxx @@ -894,6 +894,43 @@ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDataBarFormatObj::getProperty return aRef; } +namespace { + +void setDataBarEntry(ScColorScaleEntry* pEntry, uno::Reference<sheet::XDataBarEntry> xEntry) +{ + ScColorScaleEntryType eType; + sal_Int32 nApiType = xEntry->getType(); + bool bFound = false; + for (size_t i = 0; i < SAL_N_ELEMENTS(aDataBarEntryTypeMap); ++i) + { + if (aDataBarEntryTypeMap[i].nApiType == nApiType) + { + eType = aDataBarEntryTypeMap[i].eType; + bFound = true; + break; + } + } + + if (!bFound) + throw lang::IllegalArgumentException(); + + pEntry->SetType(eType); + switch (eType) + { + case COLORSCALE_FORMULA: + // TODO: Implement + break; + default: + { + double nVal = xEntry->getFormula().toDouble(); + pEntry->SetValue(nVal); + } + break; + } +} + +} + void SAL_CALL ScDataBarFormatObj::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue ) throw(beans::UnknownPropertyException, beans::PropertyVetoException, @@ -994,6 +1031,10 @@ void SAL_CALL ScDataBarFormatObj::setPropertyValue( if (aEntries.getLength() != 2) throw lang::IllegalArgumentException(); + setDataBarEntry(getCoreObject()->GetDataBarData()->mpLowerLimit.get(), + aEntries[0]); + setDataBarEntry(getCoreObject()->GetDataBarData()->mpUpperLimit.get(), + aEntries[1]); } else throw lang::IllegalArgumentException(); commit 5762370f7a9b6061e30ea458a4b08d24ff745788 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Mon Mar 30 01:17:44 2015 +0200 implement last missing IconSet piece Change-Id: I97fb3a2e8bc5abb68a07e4daab6492a4ffa5c52a diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx index 10a2e78..0b81b5a 100644 --- a/sc/source/ui/unoobj/condformatuno.cxx +++ b/sc/source/ui/unoobj/condformatuno.cxx @@ -1228,6 +1228,44 @@ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScIconSetFormatObj::getProperty return aRef; } +namespace { + +void setIconSetEntry(ScIconSetFormat* pFormat, uno::Reference<sheet::XIconSetEntry> xEntry, size_t nPos) +{ + ScIconSetFormatData* pData = pFormat->GetIconSetData(); + ScColorScaleEntryType eType; + sal_Int32 nApiType = xEntry->getType(); + bool bFound = false; + for (size_t i = 0; i < SAL_N_ELEMENTS(aIconSetEntryTypeMap); ++i) + { + if (aIconSetEntryTypeMap[i].nApiType == nApiType) + { + eType = aIconSetEntryTypeMap[i].eType; + bFound = true; + break; + } + } + + if (!bFound) + throw lang::IllegalArgumentException(); + + pData->maEntries[nPos].SetType(eType); + switch (eType) + { + case COLORSCALE_FORMULA: + // TODO: Implement + break; + default: + { + double nVal = xEntry->getFormula().toDouble(); + pData->maEntries[nPos].SetValue(nVal); + } + break; + } +} + +} + void SAL_CALL ScIconSetFormatObj::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue ) throw(beans::UnknownPropertyException, beans::PropertyVetoException, @@ -1286,7 +1324,11 @@ void SAL_CALL ScIconSetFormatObj::setPropertyValue( uno::Sequence<uno::Reference<sheet::XIconSetEntry> > aEntries; if (aValue >>= aEntries) { - + sal_Int32 nLength = aEntries.getLength(); + for (size_t i = 0; i < size_t(nLength); ++i) + { + setIconSetEntry(getCoreObject(), aEntries[i], i); + } } else throw lang::IllegalArgumentException(); commit 8b3137c9460aec7873001d5bbdf1b6f29d7646a4 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Mon Mar 30 01:03:37 2015 +0200 first icon set entry always is minimum Change-Id: Iddeced617ec6248601a3636a84abab6c1d4bb015 diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx index 6bbbe2e..10a2e78 100644 --- a/sc/source/ui/unoobj/condformatuno.cxx +++ b/sc/source/ui/unoobj/condformatuno.cxx @@ -1404,6 +1404,10 @@ sal_Int32 ScIconSetEntryObj::getType() throw(uno::RuntimeException, std::exception) { ScColorScaleEntry* pEntry = getCoreObject(); + // the first entry always is minimum + if (mnPos == 0) + return sheet::IconSetFormatEntry::ICONSET_MIN; + for (size_t i = 0; i < SAL_N_ELEMENTS(aIconSetEntryTypeMap); ++i) { if (aIconSetEntryTypeMap[i].eType == pEntry->GetType()) @@ -1418,6 +1422,10 @@ sal_Int32 ScIconSetEntryObj::getType() void ScIconSetEntryObj::setType(sal_Int32 nType) throw(uno::RuntimeException, std::exception) { + // first entry is always MIN + if (mnPos == 0) + return; + ScColorScaleEntry* pEntry = getCoreObject(); for (size_t i = 0; i < SAL_N_ELEMENTS(aIconSetEntryTypeMap); ++i) { commit 3dce04a789f076c73f6fbcfadc86903be114020c Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Mon Mar 30 01:01:04 2015 +0200 add uno object for iconset entries Change-Id: I3eed6b39a72369063e160e2be7a27fed53a0234a diff --git a/sc/source/ui/inc/condformatuno.hxx b/sc/source/ui/inc/condformatuno.hxx index 7188065..1792058 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 a78c562..6bbbe2e 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: */ commit dd45f089b2fc45ece880c4c1ff219a92975a95d5 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Mon Mar 30 01:00:11 2015 +0200 add UNO object for DataBar entries Change-Id: I5e11e62076495f62876654baeebe7dffe6492040 diff --git a/sc/source/ui/inc/condformatuno.hxx b/sc/source/ui/inc/condformatuno.hxx index 497285f..7188065 100644 --- a/sc/source/ui/inc/condformatuno.hxx +++ b/sc/source/ui/inc/condformatuno.hxx @@ -34,6 +34,7 @@ class ScIconSetFormat; class ScDataBarFormat; class ScColorScaleFormat; class ScCondFormatEntry; +class ScColorScaleEntry; using namespace com::sun::star; @@ -355,6 +356,32 @@ private: const ScDataBarFormat* mpFormat; }; +class ScDataBarEntryObj : public cppu::WeakImplHelper1<com::sun::star::sheet::XDataBarEntry> +{ +public: + ScDataBarEntryObj(rtl::Reference<ScDataBarFormatObj> xParent, size_t nPos); + + virtual ~ScDataBarEntryObj(); + + 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<ScDataBarFormatObj> mxParent; + size_t mnPos; +}; + class ScIconSetFormatObj : public cppu::WeakImplHelper1<com::sun::star::beans::XPropertySet> { public: diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx index 88fd41a..a78c562 100644 --- a/sc/source/ui/unoobj/condformatuno.cxx +++ b/sc/source/ui/unoobj/condformatuno.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/sheet/IconSetType.hpp> #include <com/sun/star/sheet/DataBarAxis.hpp> #include <com/sun/star/sheet/ConditionFormatOperator.hpp> +#include <com/sun/star/sheet/DataBarEntryType.hpp> namespace { @@ -161,6 +162,23 @@ DataBarAxisApiMap aDataBarAxisMap[] = { databar::MIDDLE, sheet::DataBarAxis::AXIS_MIDDLE } }; +struct DataBarEntryTypeApiMap +{ + ScColorScaleEntryType eType; + sal_Int32 nApiType; +}; + +DataBarEntryTypeApiMap aDataBarEntryTypeMap[] = +{ + { COLORSCALE_AUTO, sheet::DataBarEntryType::DATABAR_MAX }, + { COLORSCALE_MIN, sheet::DataBarEntryType::DATABAR_MIN }, + { COLORSCALE_MAX, sheet::DataBarEntryType::DATABAR_MAX }, + { COLORSCALE_VALUE, sheet::DataBarEntryType::DATABAR_VALUE }, + { COLORSCALE_FORMULA, sheet::DataBarEntryType::DATABAR_FORMULA }, + { COLORSCALE_PERCENT, sheet::DataBarEntryType::DATABAR_PERCENT }, + { COLORSCALE_PERCENTILE, sheet::DataBarEntryType::DATABAR_PERCENTILE } +}; + enum IconSetProperties { Icons, @@ -954,6 +972,15 @@ void SAL_CALL ScDataBarFormatObj::setPropertyValue( break; case DataBarEntries: { + uno::Sequence<uno::Reference<sheet::XDataBarEntry> > aEntries; + if (aValue >>= aEntries) + { + if (aEntries.getLength() != 2) + throw lang::IllegalArgumentException(); + + } + else + throw lang::IllegalArgumentException(); } break; } @@ -1026,6 +1053,10 @@ uno::Any SAL_CALL ScDataBarFormatObj::getPropertyValue( const OUString& aPropert break; case DataBarEntries: { + uno::Sequence<uno::Reference<sheet::XDataBarEntry> > aEntries(2); + aEntries[0] = new ScDataBarEntryObj(this, 0); + aEntries[1] = new ScDataBarEntryObj(this, 1); + aAny <<= aEntries; } break; } @@ -1064,6 +1095,92 @@ void SAL_CALL ScDataBarFormatObj::removeVetoableChangeListener( const OUString&, SAL_WARN("sc", "not implemented"); } +ScDataBarEntryObj::ScDataBarEntryObj(rtl::Reference<ScDataBarFormatObj> xParent, + size_t nPos): + mxParent(xParent), + mnPos(nPos) +{ +} + +ScDataBarEntryObj::~ScDataBarEntryObj() +{ +} + +ScColorScaleEntry* ScDataBarEntryObj::getCoreObject() +{ + ScDataBarFormat* pFormat = mxParent->getCoreObject(); + ScColorScaleEntry* pEntry; + if (mnPos == 0) + pEntry = pFormat->GetDataBarData()->mpLowerLimit.get(); + else + pEntry = pFormat->GetDataBarData()->mpUpperLimit.get(); + + return pEntry; +} + +sal_Int32 ScDataBarEntryObj::getType() + throw(uno::RuntimeException, std::exception) +{ + ScColorScaleEntry* pEntry = getCoreObject(); + for (size_t i = 0; i < SAL_N_ELEMENTS(aDataBarEntryTypeMap); ++i) + { + if (aDataBarEntryTypeMap[i].eType == pEntry->GetType()) + { + return aDataBarEntryTypeMap[i].nApiType; + } + } + + throw lang::IllegalArgumentException(); +} + +void ScDataBarEntryObj::setType(sal_Int32 nType) + throw(uno::RuntimeException, std::exception) +{ + ScColorScaleEntry* pEntry = getCoreObject(); + for (size_t i = 0; i < SAL_N_ELEMENTS(aDataBarEntryTypeMap); ++i) + { + if (aDataBarEntryTypeMap[i].nApiType == nType) + { + pEntry->SetType(aDataBarEntryTypeMap[i].eType); + return; + } + } + throw lang::IllegalArgumentException(); +} + +OUString ScDataBarEntryObj::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 ScDataBarEntryObj::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; + } +} + + ScIconSetFormatObj::ScIconSetFormatObj(rtl::Reference<ScCondFormatObj> xParent, const ScIconSetFormat* pFormat): mpDocShell(xParent->getDocShell()), commit ad6d79c61702b2301a7deba11ff4be836bae326d Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Mon Mar 30 00:58:43 2015 +0200 add value for first entry Change-Id: Ifc53952ba0aaa8b5e59944e309428bfce4d48ef7 diff --git a/offapi/com/sun/star/sheet/IconSetFormatEntry.idl b/offapi/com/sun/star/sheet/IconSetFormatEntry.idl index 24715e3..652618c 100644 --- a/offapi/com/sun/star/sheet/IconSetFormatEntry.idl +++ b/offapi/com/sun/star/sheet/IconSetFormatEntry.idl @@ -14,13 +14,18 @@ module com { module sun { module star { module sheet { constants IconSetFormatEntry { - const long ICONSET_PERCENTILE = 0; + /** + * Can not be set! Will always be the type of the first entry. + */ + const long ICONSET_MIN = 0; - const long ICONSET_VALUE = 1; + const long ICONSET_PERCENTILE = 1; - const long ICONSET_PERCENT = 2; + const long ICONSET_VALUE = 2; - const long ICONSET_FORMULA = 3; + const long ICONSET_PERCENT = 3; + + const long ICONSET_FORMULA = 4; }; commit b48cd09e419efc012fe4719afafc9a8ddbf875f9 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Sun Mar 29 23:10:51 2015 +0200 work on initial colorscale properties tests Change-Id: Ifc71437b8c7dfd70bf733863713ada4ad605abad diff --git a/sc/qa/extras/new_cond_format.cxx b/sc/qa/extras/new_cond_format.cxx index 3f67d38..c4876e6 100644 --- a/sc/qa/extras/new_cond_format.cxx +++ b/sc/qa/extras/new_cond_format.cxx @@ -38,6 +38,7 @@ public: void testCondFormatProperties(); void testCondFormatXIndex(); void testDataBarProperties(); + void testColorScaleProperties(); CPPUNIT_TEST_SUITE(ScConditionalFormatTest); CPPUNIT_TEST(testRequestCondFormatListFromSheet); @@ -46,6 +47,7 @@ public: CPPUNIT_TEST(testCondFormatProperties); CPPUNIT_TEST(testCondFormatXIndex); CPPUNIT_TEST(testDataBarProperties); + CPPUNIT_TEST(testColorScaleProperties); CPPUNIT_TEST_SUITE_END(); private: @@ -259,6 +261,25 @@ void ScConditionalFormatTest::testDataBarProperties() } } +void ScConditionalFormatTest::testColorScaleProperties() +{ + uno::Reference<sheet::XConditionalFormats> xCondFormatList = + getConditionalFormatList(init(3)); + + uno::Sequence<uno::Reference<sheet::XConditionalFormat> > xCondFormats = + xCondFormatList->getConditionalFormats(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xCondFormats.getLength()); + + uno::Reference<sheet::XConditionalFormat> xCondFormat = xCondFormats[0]; + CPPUNIT_ASSERT(xCondFormat.is()); + + uno::Type aType = xCondFormat->getElementType(); + CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.beans.XPropertySet"), aType.getTypeName()); + + CPPUNIT_ASSERT(xCondFormat->hasElements()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xCondFormat->getCount()); +} + void ScConditionalFormatTest::setUp() { nTest++; diff --git a/sc/qa/extras/testdocuments/new_cond_format_api.ods b/sc/qa/extras/testdocuments/new_cond_format_api.ods index 480ee24..06bb1d7 100644 Binary files a/sc/qa/extras/testdocuments/new_cond_format_api.ods and b/sc/qa/extras/testdocuments/new_cond_format_api.ods differ commit e49808edc46c75ae2bd351ca71f09fb43c3b9051 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Sun Mar 29 23:03:06 2015 +0200 the implementation is available so enable it again Change-Id: Ia5974e57fd4a21897577ff25fb53f48cceb49501 diff --git a/sc/qa/extras/new_cond_format.cxx b/sc/qa/extras/new_cond_format.cxx index 7b76f6e..3f67d38 100644 --- a/sc/qa/extras/new_cond_format.cxx +++ b/sc/qa/extras/new_cond_format.cxx @@ -170,11 +170,9 @@ void ScConditionalFormatTest::testCondFormatXIndex() CPPUNIT_ASSERT(xCondFormat->hasElements()); CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xCondFormat->getCount()); - /* - * missing implementation + uno::Any aAny = xCondFormat->getByIndex(0); CPPUNIT_ASSERT(aAny.hasValue()); - */ } namespace { commit 76115b29524be1214e29613aa31cc433f5ba7c75 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Sun Mar 29 23:01:28 2015 +0200 start work on data property tests Change-Id: I1f1722aa3566555816df19e68aa7eaa97e7a13d9 diff --git a/sc/qa/extras/new_cond_format.cxx b/sc/qa/extras/new_cond_format.cxx index 0bd96d4..7b76f6e 100644 --- a/sc/qa/extras/new_cond_format.cxx +++ b/sc/qa/extras/new_cond_format.cxx @@ -14,6 +14,7 @@ #include <com/sun/star/sheet/XSpreadsheetDocument.hpp> #include <com/sun/star/sheet/XSpreadsheet.hpp> #include <com/sun/star/table/CellAddress.hpp> +#include <com/sun/star/sheet/DataBarAxis.hpp> #include <unonames.hxx> using namespace css; @@ -36,6 +37,7 @@ public: void testCondFormatListFormats(); void testCondFormatProperties(); void testCondFormatXIndex(); + void testDataBarProperties(); CPPUNIT_TEST_SUITE(ScConditionalFormatTest); CPPUNIT_TEST(testRequestCondFormatListFromSheet); @@ -43,6 +45,7 @@ public: CPPUNIT_TEST(testCondFormatListFormats); CPPUNIT_TEST(testCondFormatProperties); CPPUNIT_TEST(testCondFormatXIndex); + CPPUNIT_TEST(testDataBarProperties); CPPUNIT_TEST_SUITE_END(); private: @@ -174,6 +177,90 @@ void ScConditionalFormatTest::testCondFormatXIndex() */ } +namespace { + +void testAxisPosition(uno::Reference<beans::XPropertySet> xPropSet, sal_Int32 ePos) +{ + sal_Int32 eAxisPos; + uno::Any aAny = xPropSet->getPropertyValue("AxisPosition"); + CPPUNIT_ASSERT(aAny >>= eAxisPos); + CPPUNIT_ASSERT_EQUAL(ePos, eAxisPos); +} + +void testShowValue(uno::Reference<beans::XPropertySet> xPropSet, bool bShowVal) +{ + bool bShow; + uno::Any aAny = xPropSet->getPropertyValue("ShowValue"); + CPPUNIT_ASSERT(aAny >>= bShow); + CPPUNIT_ASSERT_EQUAL(bShowVal, bShow); +} + +void testUseGradient(uno::Reference<beans::XPropertySet> xPropSet, bool bUseGradient) +{ + bool bGradient; + uno::Any aAny = xPropSet->getPropertyValue("UseGradient"); + CPPUNIT_ASSERT(aAny >>= bGradient); + CPPUNIT_ASSERT_EQUAL(bUseGradient, bGradient); +} + +void testPositiveColor(uno::Reference<beans::XPropertySet> xPropSet, Color aColor) +{ + sal_Int32 nColor; + uno::Any aAny = xPropSet->getPropertyValue("Color"); + CPPUNIT_ASSERT(aAny >>= nColor); + CPPUNIT_ASSERT_EQUAL(aColor.GetColor(), sal_uInt32(nColor)); +} + +void testNegativeColor(uno::Reference<beans::XPropertySet> xPropSet, Color aColor) +{ + sal_Int32 nColor; + uno::Any aAny = xPropSet->getPropertyValue("NegativeColor"); + CPPUNIT_ASSERT(aAny >>= nColor); + CPPUNIT_ASSERT_EQUAL(aColor.GetColor(), sal_uInt32(nColor)); +} + +void testAxisColor(uno::Reference<beans::XPropertySet> xPropSet, Color aColor) +{ + sal_Int32 nColor; + uno::Any aAny = xPropSet->getPropertyValue("AxisColor"); + CPPUNIT_ASSERT(aAny >>= nColor); + CPPUNIT_ASSERT_EQUAL(aColor.GetColor(), sal_uInt32(nColor)); +} + +} + +void ScConditionalFormatTest::testDataBarProperties() +{ + uno::Reference<sheet::XConditionalFormats> xCondFormatList = + getConditionalFormatList(init(2)); + + uno::Sequence<uno::Reference<sheet::XConditionalFormat> > xCondFormats = + xCondFormatList->getConditionalFormats(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xCondFormats.getLength()); + + uno::Reference<sheet::XConditionalFormat> xCondFormat = xCondFormats[0]; + CPPUNIT_ASSERT(xCondFormat.is()); + + uno::Type aType = xCondFormat->getElementType(); + CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.beans.XPropertySet"), aType.getTypeName()); + + CPPUNIT_ASSERT(xCondFormat->hasElements()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xCondFormat->getCount()); + + uno::Reference<beans::XPropertySet> xPropSet; + { + uno::Any aAny = xCondFormat->getByIndex(0); + CPPUNIT_ASSERT(aAny.hasValue()); + CPPUNIT_ASSERT(aAny >>= xPropSet); + testAxisPosition(xPropSet, sheet::DataBarAxis::AXIS_AUTOMATIC); + testShowValue(xPropSet, true); + testUseGradient(xPropSet, true); + testPositiveColor(xPropSet, COL_LIGHTBLUE); + testNegativeColor(xPropSet, COL_LIGHTRED); + testAxisColor(xPropSet, COL_BLACK); + } +} + void ScConditionalFormatTest::setUp() { nTest++; diff --git a/sc/qa/extras/testdocuments/new_cond_format_api.ods b/sc/qa/extras/testdocuments/new_cond_format_api.ods index 3660f45..480ee24 100644 Binary files a/sc/qa/extras/testdocuments/new_cond_format_api.ods and b/sc/qa/extras/testdocuments/new_cond_format_api.ods differ commit af56ed1ca1e4d37bdef0875757bdee050c35cfef Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Sun Mar 29 23:01:10 2015 +0200 fix condition Change-Id: If8ad2361d6c0d838c39f8625f129fc326efd2cd4 diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx index 1a5af16..88fd41a 100644 --- a/sc/source/ui/unoobj/condformatuno.cxx +++ b/sc/source/ui/unoobj/condformatuno.cxx @@ -398,7 +398,7 @@ uno::Any ScCondFormatObj::getByIndex(sal_Int32 nIndex) throw(uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - if (getCoreObject()->size() >= size_t(nIndex)) + if (getCoreObject()->size() <= size_t(nIndex)) throw lang::IllegalArgumentException(); const ScFormatEntry* pEntry = getCoreObject()->GetEntry(nIndex); commit e21e3b26646e9642d3e72269c44cbe3b781f9782 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Sun Mar 29 19:54:09 2015 +0200 correct lifecycle handling for more objects Change-Id: I456019c298c73bc872b49b55b628af1e0233be73 diff --git a/sc/source/ui/inc/condformatuno.hxx b/sc/source/ui/inc/condformatuno.hxx index a7140e7..497285f 100644 --- a/sc/source/ui/inc/condformatuno.hxx +++ b/sc/source/ui/inc/condformatuno.hxx @@ -177,7 +177,8 @@ class ScConditionEntryObj : public cppu::WeakImplHelper2<com::sun::star::beans:: { public: - ScConditionEntryObj(rtl::Reference<ScCondFormatObj> xParent); + ScConditionEntryObj(rtl::Reference<ScCondFormatObj> xParent, + const ScCondFormatEntry* pFormat); virtual ~ScConditionEntryObj(); static ScConditionEntryObj* getImplementation(uno::Reference<sheet::XConditionEntry> xCondition); @@ -233,13 +234,14 @@ private: ScDocShell* mpDocShell; rtl::Reference<ScCondFormatObj> mxParent; SfxItemPropertySet maPropSet; + const ScCondFormatEntry* mpFormat; }; class ScColorScaleFormatObj : public cppu::WeakImplHelper1<com::sun::star::beans::XPropertySet> { public: - ScColorScaleFormatObj(rtl::Reference<ScCondFormatObj> xParent); + ScColorScaleFormatObj(rtl::Reference<ScCondFormatObj> xParent, const ScColorScaleFormat* pFormat); virtual ~ScColorScaleFormatObj(); static ScColorScaleFormatObj* getImplementation(uno::Reference<beans::XPropertySet> xPropSet); @@ -291,12 +293,14 @@ private: ScDocShell* mpDocShell; rtl::Reference<ScCondFormatObj> mxParent; SfxItemPropertySet maPropSet; + const ScColorScaleFormat* mpFormat; }; class ScDataBarFormatObj : public cppu::WeakImplHelper1<com::sun::star::beans::XPropertySet> { public: - ScDataBarFormatObj(rtl::Reference<ScCondFormatObj> xParent); + ScDataBarFormatObj(rtl::Reference<ScCondFormatObj> xParent, + const ScDataBarFormat* pFormat); virtual ~ScDataBarFormatObj(); static ScDataBarFormatObj* getImplementation(uno::Reference<beans::XPropertySet> xPropSet); @@ -348,12 +352,14 @@ private: ScDocShell* mpDocShell; rtl::Reference<ScCondFormatObj> mxParent; SfxItemPropertySet maPropSet; + const ScDataBarFormat* mpFormat; }; class ScIconSetFormatObj : public cppu::WeakImplHelper1<com::sun::star::beans::XPropertySet> { public: - ScIconSetFormatObj(rtl::Reference<ScCondFormatObj> xParent); + ScIconSetFormatObj(rtl::Reference<ScCondFormatObj> xParent, + const ScIconSetFormat* pFormat); virtual ~ScIconSetFormatObj(); static ScIconSetFormatObj* getImplementation(uno::Reference<beans::XPropertySet> xPropSet); @@ -405,6 +411,7 @@ private: ScDocShell* mpDocShell; rtl::Reference<ScCondFormatObj> mxParent; SfxItemPropertySet maPropSet; + const ScIconSetFormat* mpFormat; }; #endif diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx index aee40f7..1a5af16 100644 --- a/sc/source/ui/unoobj/condformatuno.cxx +++ b/sc/source/ui/unoobj/condformatuno.cxx @@ -303,16 +303,20 @@ uno::Reference<beans::XPropertySet> createConditionEntry(const ScFormatEntry* pE switch (pEntry->GetType()) { case condformat::CONDITION: - return new ScConditionEntryObj(xParent); + return new ScConditionEntryObj(xParent, + static_cast<const ScCondFormatEntry*>(pEntry)); break; case condformat::COLORSCALE: - return new ScColorScaleFormatObj(xParent); + return new ScColorScaleFormatObj(xParent, + static_cast<const ScColorScaleFormat*>(pEntry)); break; case condformat::DATABAR: - return new ScDataBarFormatObj(xParent); + return new ScDataBarFormatObj(xParent, + static_cast<const ScDataBarFormat*>(pEntry)); break; case condformat::ICONSET: - return new ScIconSetFormatObj(xParent); + return new ScIconSetFormatObj(xParent, + static_cast<const ScIconSetFormat*>(pEntry)); break; case condformat::DATE: break; @@ -519,10 +523,26 @@ void SAL_CALL ScCondFormatObj::removeVetoableChangeListener( const OUString&, SAL_WARN("sc", "not implemented"); } -ScConditionEntryObj::ScConditionEntryObj(rtl::Reference<ScCondFormatObj> xParent): +namespace { + +bool isObjectStillAlive(ScConditionalFormat* pFormat, const ScFormatEntry* pEntry) +{ + for(size_t i = 0, n= pFormat->size(); i < n; ++i) + { + if (pFormat->GetEntry(i) == pEntry) + return true; + } + return false; +} + +} + +ScConditionEntryObj::ScConditionEntryObj(rtl::Reference<ScCondFormatObj> xParent, + const ScCondFormatEntry* pFormat): mpDocShell(xParent->getDocShell()), mxParent(xParent), - maPropSet(getConditionEntryrPropSet()) + maPropSet(getConditionEntryrPropSet()), + mpFormat(pFormat) { } @@ -532,7 +552,11 @@ ScConditionEntryObj::~ScConditionEntryObj() ScCondFormatEntry* ScConditionEntryObj::getCoreObject() { - return NULL; + ScConditionalFormat* pFormat = mxParent->getCoreObject(); + if (isObjectStillAlive(pFormat, mpFormat)) + return const_cast<ScCondFormatEntry*>(mpFormat); + + throw lang::IllegalArgumentException(); } sal_Int32 ScConditionEntryObj::getType() @@ -697,10 +721,12 @@ void SAL_CALL ScConditionEntryObj::removeVetoableChangeListener( const OUString& SAL_WARN("sc", "not implemented"); } -ScColorScaleFormatObj::ScColorScaleFormatObj(rtl::Reference<ScCondFormatObj> xParent): +ScColorScaleFormatObj::ScColorScaleFormatObj(rtl::Reference<ScCondFormatObj> xParent, + const ScColorScaleFormat* pFormat): mpDocShell(xParent->getDocShell()), mxParent(xParent), - maPropSet(getColorScalePropSet()) + maPropSet(getColorScalePropSet()), + mpFormat(pFormat) { } @@ -710,7 +736,11 @@ ScColorScaleFormatObj::~ScColorScaleFormatObj() ScColorScaleFormat* ScColorScaleFormatObj::getCoreObject() { - return NULL; + ScConditionalFormat* pFormat = mxParent->getCoreObject(); + if (isObjectStillAlive(pFormat, mpFormat)) + return const_cast<ScColorScaleFormat*>(mpFormat); + + throw lang::IllegalArgumentException(); } uno::Reference<beans::XPropertySetInfo> SAL_CALL ScColorScaleFormatObj::getPropertySetInfo() @@ -799,10 +829,12 @@ void SAL_CALL ScColorScaleFormatObj::removeVetoableChangeListener( const OUStrin SAL_WARN("sc", "not implemented"); } -ScDataBarFormatObj::ScDataBarFormatObj(rtl::Reference<ScCondFormatObj> xParent): +ScDataBarFormatObj::ScDataBarFormatObj(rtl::Reference<ScCondFormatObj> xParent, + const ScDataBarFormat* pFormat): mpDocShell(xParent->getDocShell()), mxParent(xParent), - maPropSet(getDataBarPropSet()) + maPropSet(getDataBarPropSet()), + mpFormat(pFormat) { } @@ -812,7 +844,11 @@ ScDataBarFormatObj::~ScDataBarFormatObj() ScDataBarFormat* ScDataBarFormatObj::getCoreObject() { - return NULL; + ScConditionalFormat* pFormat = mxParent->getCoreObject(); + if (isObjectStillAlive(pFormat, mpFormat)) + return const_cast<ScDataBarFormat*>(mpFormat); + + throw lang::IllegalArgumentException(); } uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDataBarFormatObj::getPropertySetInfo() @@ -1028,10 +1064,12 @@ void SAL_CALL ScDataBarFormatObj::removeVetoableChangeListener( const OUString&, SAL_WARN("sc", "not implemented"); } -ScIconSetFormatObj::ScIconSetFormatObj(rtl::Reference<ScCondFormatObj> xParent): +ScIconSetFormatObj::ScIconSetFormatObj(rtl::Reference<ScCondFormatObj> xParent, + const ScIconSetFormat* pFormat): mpDocShell(xParent->getDocShell()), mxParent(xParent), - maPropSet(getIconSetPropSet()) + maPropSet(getIconSetPropSet()), + mpFormat(pFormat) { } @@ -1041,7 +1079,11 @@ ScIconSetFormatObj::~ScIconSetFormatObj() ScIconSetFormat* ScIconSetFormatObj::getCoreObject() { - return NULL; + ScConditionalFormat* pFormat = mxParent->getCoreObject(); + if (isObjectStillAlive(pFormat, mpFormat)) + return const_cast<ScIconSetFormat*>(mpFormat); + + throw lang::IllegalArgumentException(); } uno::Reference<beans::XPropertySetInfo> SAL_CALL ScIconSetFormatObj::getPropertySetInfo() commit 97054f533f8c7153545a1c08dae12ca92f069122 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Fri Mar 27 04:13:52 2015 +0100 implement one more method Change-Id: Ie18be81fa664df88af605674968e302c59f7dc98 diff --git a/sc/source/ui/inc/condformatuno.hxx b/sc/source/ui/inc/condformatuno.hxx index d5c1865..a7140e7 100644 --- a/sc/source/ui/inc/condformatuno.hxx +++ b/sc/source/ui/inc/condformatuno.hxx @@ -93,6 +93,7 @@ public: virtual ~ScCondFormatObj(); static ScCondFormatObj* getImplementation( uno::Reference<sheet::XConditionalFormat> XCondFormat); + ScDocShell* getDocShell(); // XConditionalFormat virtual void SAL_CALL addEntry(const uno::Reference<sheet::XConditionEntry>& xEntry) @@ -176,7 +177,7 @@ class ScConditionEntryObj : public cppu::WeakImplHelper2<com::sun::star::beans:: { public: - ScConditionEntryObj(); + ScConditionEntryObj(rtl::Reference<ScCondFormatObj> xParent); virtual ~ScConditionEntryObj(); static ScConditionEntryObj* getImplementation(uno::Reference<sheet::XConditionEntry> xCondition); @@ -238,7 +239,7 @@ class ScColorScaleFormatObj : public cppu::WeakImplHelper1<com::sun::star::beans { public: - ScColorScaleFormatObj(); + ScColorScaleFormatObj(rtl::Reference<ScCondFormatObj> xParent); virtual ~ScColorScaleFormatObj(); static ScColorScaleFormatObj* getImplementation(uno::Reference<beans::XPropertySet> xPropSet); @@ -295,7 +296,7 @@ private: class ScDataBarFormatObj : public cppu::WeakImplHelper1<com::sun::star::beans::XPropertySet> { public: - ScDataBarFormatObj(); + ScDataBarFormatObj(rtl::Reference<ScCondFormatObj> xParent); virtual ~ScDataBarFormatObj(); static ScDataBarFormatObj* getImplementation(uno::Reference<beans::XPropertySet> xPropSet); @@ -352,7 +353,7 @@ private: class ScIconSetFormatObj : public cppu::WeakImplHelper1<com::sun::star::beans::XPropertySet> { public: - ScIconSetFormatObj(); + ScIconSetFormatObj(rtl::Reference<ScCondFormatObj> xParent); virtual ~ScIconSetFormatObj(); static ScIconSetFormatObj* getImplementation(uno::Reference<beans::XPropertySet> xPropSet); diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx index fcf32b5..aee40f7 100644 --- a/sc/source/ui/unoobj/condformatuno.cxx +++ b/sc/source/ui/unoobj/condformatuno.cxx @@ -295,6 +295,35 @@ ScConditionalFormatList* ScCondFormatsObj::getCoreObject() return pList; } +namespace { + +uno::Reference<beans::XPropertySet> createConditionEntry(const ScFormatEntry* pEntry, + rtl::Reference<ScCondFormatObj> xParent) +{ + switch (pEntry->GetType()) + { + case condformat::CONDITION: + return new ScConditionEntryObj(xParent); + break; + case condformat::COLORSCALE: + return new ScColorScaleFormatObj(xParent); + break; + case condformat::DATABAR: + return new ScDataBarFormatObj(xParent); + break; + case condformat::ICONSET: + return new ScIconSetFormatObj(xParent); + break; + case condformat::DATE: + break; + default: + break; + } + return uno::Reference<beans::XPropertySet>(); +} + +} + ScCondFormatObj::ScCondFormatObj(ScDocShell* pDocShell, rtl::Reference<ScCondFormatsObj> xCondFormats, sal_Int32 nKey): mxCondFormatList(xCondFormats), @@ -318,6 +347,11 @@ ScConditionalFormat* ScCondFormatObj::getCoreObject() return pFormat; } +ScDocShell* ScCondFormatObj::getDocShell() +{ + return mpDocShell; +} + void ScCondFormatObj::addEntry(const uno::Reference<sheet::XConditionEntry>& /*xEntry*/) throw(uno::RuntimeException, std::exception) { @@ -356,10 +390,18 @@ sal_Int32 ScCondFormatObj::getCount() return pFormat->size(); } -uno::Any ScCondFormatObj::getByIndex(sal_Int32 /*nIndex*/) +uno::Any ScCondFormatObj::getByIndex(sal_Int32 nIndex) throw(uno::RuntimeException, std::exception) { + SolarMutexGuard aGuard; + if (getCoreObject()->size() >= size_t(nIndex)) + throw lang::IllegalArgumentException(); + + const ScFormatEntry* pEntry = getCoreObject()->GetEntry(nIndex); + uno::Reference<beans::XPropertySet> xCondEntry = + createConditionEntry(pEntry, this); uno::Any aAny; + aAny <<= xCondEntry; return aAny; } @@ -477,7 +519,9 @@ void SAL_CALL ScCondFormatObj::removeVetoableChangeListener( const OUString&, SAL_WARN("sc", "not implemented"); } -ScConditionEntryObj::ScConditionEntryObj(): +ScConditionEntryObj::ScConditionEntryObj(rtl::Reference<ScCondFormatObj> xParent): + mpDocShell(xParent->getDocShell()), + mxParent(xParent), maPropSet(getConditionEntryrPropSet()) { } @@ -653,7 +697,9 @@ void SAL_CALL ScConditionEntryObj::removeVetoableChangeListener( const OUString& SAL_WARN("sc", "not implemented"); } -ScColorScaleFormatObj::ScColorScaleFormatObj(): +ScColorScaleFormatObj::ScColorScaleFormatObj(rtl::Reference<ScCondFormatObj> xParent): + mpDocShell(xParent->getDocShell()), + mxParent(xParent), maPropSet(getColorScalePropSet()) { } @@ -753,7 +799,9 @@ void SAL_CALL ScColorScaleFormatObj::removeVetoableChangeListener( const OUStrin SAL_WARN("sc", "not implemented"); } -ScDataBarFormatObj::ScDataBarFormatObj(): +ScDataBarFormatObj::ScDataBarFormatObj(rtl::Reference<ScCondFormatObj> xParent): + mpDocShell(xParent->getDocShell()), + mxParent(xParent), maPropSet(getDataBarPropSet()) { } @@ -980,7 +1028,9 @@ void SAL_CALL ScDataBarFormatObj::removeVetoableChangeListener( const OUString&, SAL_WARN("sc", "not implemented"); } -ScIconSetFormatObj::ScIconSetFormatObj(): +ScIconSetFormatObj::ScIconSetFormatObj(rtl::Reference<ScCondFormatObj> xParent): + mpDocShell(xParent->getDocShell()), + mxParent(xParent), maPropSet(getIconSetPropSet()) { } commit 35ea7ffe7549eb8a5f2539bc37ac5041a8d80c72 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Fri Mar 27 04:12:53 2015 +0100 fix return type Change-Id: I581a8a0c7348a9752611b378e883ef20172d16e0 diff --git a/sc/qa/extras/new_cond_format.cxx b/sc/qa/extras/new_cond_format.cxx index e648edc..0bd96d4 100644 --- a/sc/qa/extras/new_cond_format.cxx +++ b/sc/qa/extras/new_cond_format.cxx @@ -163,7 +163,7 @@ void ScConditionalFormatTest::testCondFormatXIndex() CPPUNIT_ASSERT(xCondFormat.is()); uno::Type aType = xCondFormat->getElementType(); - CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.sheet.XConditionEntry"), aType.getTypeName()); + CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.beans.XPropertySet"), aType.getTypeName()); CPPUNIT_ASSERT(xCondFormat->hasElements()); CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xCondFormat->getCount()); diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx index a21fc7e..fcf32b5 100644 --- a/sc/source/ui/unoobj/condformatuno.cxx +++ b/sc/source/ui/unoobj/condformatuno.cxx @@ -336,7 +336,7 @@ void ScCondFormatObj::removeByIndex(const sal_Int32 nIndex) uno::Type ScCondFormatObj::getElementType() throw(uno::RuntimeException, std::exception) { - return cppu::UnoType<sheet::XConditionEntry>::get(); + return cppu::UnoType<beans::XPropertySet>::get(); } sal_Bool ScCondFormatObj::hasElements() commit 4a9ba96520bdd6f8d40a9e92ef11b481f0d408dc Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Fri Mar 27 04:11:53 2015 +0100 implement one more method Change-Id: I3483b2004c0afb8bea651d9eec35d1cbf9aff2a1 diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx index 425e09e..fc039c0 100644 --- a/sc/inc/conditio.hxx +++ b/sc/inc/conditio.hxx @@ -392,6 +392,7 @@ public: ScConditionalFormat* Clone(ScDocument* pNewDoc = NULL) const; void AddEntry( ScFormatEntry* pNew ); + void RemoveEntry(size_t nIndex); void SetRange( const ScRangeList& rRanges ); const ScRangeList& GetRange() const { return maRanges; } // don't use the same name as for the const version diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index b39d4d0..3036999 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -1853,6 +1853,15 @@ void ScConditionalFormat::AddEntry( ScFormatEntry* pNew ) pNew->SetParent(this); } +void ScConditionalFormat::RemoveEntry(size_t n) +{ + if (n < maEntries.size()) + { + maEntries.erase(maEntries.begin() + n); + DoRepaint(NULL); + } +} + bool ScConditionalFormat::IsEmpty() const { return maEntries.empty(); diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx index 9a3876b..a21fc7e 100644 --- a/sc/source/ui/unoobj/condformatuno.cxx +++ b/sc/source/ui/unoobj/condformatuno.cxx @@ -323,9 +323,14 @@ void ScCondFormatObj::addEntry(const uno::Reference<sheet::XConditionEntry>& /*x { } -void ScCondFormatObj::removeByIndex(const sal_Int32 /*nIndex*/) +void ScCondFormatObj::removeByIndex(const sal_Int32 nIndex) throw(uno::RuntimeException, std::exception) { + SolarMutexGuard aGuard; + if (getCoreObject()->size() >= size_t(nIndex)) + throw lang::IllegalArgumentException(); + + getCoreObject()->RemoveEntry(nIndex); } uno::Type ScCondFormatObj::getElementType() commit c40a4290193e6e16f92e3b90b76ef709db41cb9d Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Fri Mar 27 03:24:35 2015 +0100 implement some more properties for databars Change-Id: Ib6c7f4f316ff49d433c8810ef9a7bbfe64c0576d diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx index 9aad855..9a3876b 100644 --- a/sc/source/ui/unoobj/condformatuno.cxx +++ b/sc/source/ui/unoobj/condformatuno.cxx @@ -788,6 +788,19 @@ void SAL_CALL ScDataBarFormatObj::setPropertyValue( { case AxisPosition: { + sal_Int32 nVal; + if (aValue >>= nVal) + { + for (size_t i = 0; i < SAL_N_ELEMENTS(aDataBarAxisMap); ++i) + { + if (aDataBarAxisMap[i].nApiPos == nVal) + { + getCoreObject()->GetDataBarData()->meAxisPosition = + aDataBarAxisMap[i].ePos; + break; + } + } + } } break; case UseGradient: @@ -1038,6 +1051,10 @@ void SAL_CALL ScIconSetFormatObj::setPropertyValue( getCoreObject()->GetIconSetData()->eIconSetType = eType; } break; + case IconSetEntries: + break; + default: + break; } } commit 2f266f2dd20e5e2a05504ea68d5a8d224429d511 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Thu Mar 26 23:16:27 2015 +0100 fix getPropertyValue/setPropertyValue for ScCondFormatEntry UNO object Change-Id: Id1a3cc62288c6c618c8b86caaa69a96eb541d06f diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx index 57dd2d9..425e09e 100644 --- a/sc/inc/conditio.hxx +++ b/sc/inc/conditio.hxx @@ -209,6 +209,7 @@ public: bool IsCellValid( ScRefCellValue& rCell, const ScAddress& rPos ) const; ScConditionMode GetOperation() const { return eOp; } + void SetOperation(ScConditionMode eMode); bool IsIgnoreBlank() const { return ( nOptions & SC_COND_NOBLANKS ) == 0; } void SetIgnoreBlank(bool bSet); ScAddress GetSrcPos() const { return aSrcPos; } diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 3da67a4..b39d4d0 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -322,6 +322,11 @@ ScConditionEntry::~ScConditionEntry() delete pFormula2; } +void ScConditionEntry::SetOperation(ScConditionMode eMode) +{ + eOp = eMode; +} + void ScConditionEntry::Compile( const OUString& rExpr1, const OUString& rExpr2, const OUString& rExprNmsp1, const OUString& rExprNmsp2, FormulaGrammar::Grammar eGrammar1, FormulaGrammar::Grammar eGrammar2, bool bTextToReal ) diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx index 81e32f7..9aad855 100644 --- a/sc/source/ui/unoobj/condformatuno.cxx +++ b/sc/source/ui/unoobj/condformatuno.cxx @@ -14,6 +14,8 @@ #include "colorscale.hxx" #include "docsh.hxx" #include "miscuno.hxx" +#include "compiler.hxx" +#include "tokenarray.hxx" #include "cellsuno.hxx" #include "convuno.hxx" @@ -72,11 +74,35 @@ struct ConditionEntryApiMap sal_Int32 nApiMode; }; -/* ConditionEntryApiMap aConditionEntryMap[] = { + {SC_COND_EQUAL, sheet::ConditionFormatOperator::EQUAL}, + {SC_COND_LESS, sheet::ConditionFormatOperator::LESS}, + {SC_COND_GREATER, sheet::ConditionFormatOperator::GREATER}, + {SC_COND_EQLESS, sheet::ConditionFormatOperator::LESS_EQUAL}, + {SC_COND_EQGREATER, sheet::ConditionFormatOperator::GREATER_EQUAL}, + {SC_COND_NOTEQUAL, sheet::ConditionFormatOperator::NOT_EQUAL}, + {SC_COND_BETWEEN, sheet::ConditionFormatOperator::BETWEEN}, + {SC_COND_NOTBETWEEN, sheet::ConditionFormatOperator::NOT_BETWEEN}, + {SC_COND_DUPLICATE, sheet::ConditionFormatOperator::DUPLICATE}, + {SC_COND_NOTDUPLICATE, sheet::ConditionFormatOperator::UNIQUE}, + {SC_COND_DIRECT, sheet::ConditionFormatOperator::EXPRESSION}, + {SC_COND_TOP10, sheet::ConditionFormatOperator::TOP_N_ELEMENTS}, + {SC_COND_BOTTOM10, sheet::ConditionFormatOperator::BOTTOM_N_ELEMENTS}, + {SC_COND_TOP_PERCENT, sheet::ConditionFormatOperator::TOP_N_PERCENT}, + {SC_COND_BOTTOM_PERCENT, sheet::ConditionFormatOperator::BOTTOM_N_PERCENT}, + {SC_COND_ABOVE_AVERAGE, sheet::ConditionFormatOperator::ABOVE_AVERAGE}, + {SC_COND_BELOW_AVERAGE, sheet::ConditionFormatOperator::BELOW_AVERAGE}, + {SC_COND_ABOVE_EQUAL_AVERAGE, sheet::ConditionFormatOperator::ABOVE_EQUAL_AVERAGE}, + {SC_COND_BELOW_EQUAL_AVERAGE, sheet::ConditionFormatOperator::BELOW_EQUAL_AVERAGE}, + {SC_COND_ERROR, sheet::ConditionFormatOperator::ERROR}, + {SC_COND_NOERROR, sheet::ConditionFormatOperator::NO_ERROR}, + {SC_COND_BEGINS_WITH, sheet::ConditionFormatOperator::BEGINS_WITH}, + {SC_COND_ENDS_WITH, sheet::ConditionFormatOperator::ENDS_WITH}, + {SC_COND_CONTAINS_TEXT, sheet::ConditionFormatOperator::CONTAINS}, + {SC_COND_NOT_CONTAINS_TEXT, sheet::ConditionFormatOperator::NOT_CONTAINS}, + {SC_COND_NONE, sheet::ConditionFormatOperator::EQUAL}, }; -*/ enum ColorScaleProperties { @@ -475,7 +501,7 @@ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScConditionEntryObj::getPropert } void SAL_CALL ScConditionEntryObj::setPropertyValue( - const OUString& aPropertyName, const uno::Any& /*aValue*/ ) + const OUString& aPropertyName, const uno::Any& aValue ) throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception) @@ -490,12 +516,49 @@ void SAL_CALL ScConditionEntryObj::setPropertyValue( switch(pEntry->nWID) { case StyleName: + { + OUString aStyleName; + if ((aValue >>= aStyleName) && !aStyleName.isEmpty()) + getCoreObject()->UpdateStyleName(aStyleName); + } break; case Formula1: + { + OUString aFormula; + if ((aValue >>= aFormula) && !aFormula.isEmpty()) + { + ScCompiler aComp(&mpDocShell->GetDocument(), getCoreObject()->GetSrcPos()); + boost::scoped_ptr<ScTokenArray> pArr(aComp.CompileString(aFormula)); + getCoreObject()->SetFormula1(*pArr); + } + } break; case Formula2: + { + OUString aFormula; + if ((aValue >>= aFormula) && !aFormula.isEmpty()) + { + ScCompiler aComp(&mpDocShell->GetDocument(), getCoreObject()->GetSrcPos()); + boost::scoped_ptr<ScTokenArray> pArr(aComp.CompileString(aFormula)); + getCoreObject()->SetFormula2(*pArr); + } + } break; case Operator: + { + sal_Int32 nVal; + if (aValue >>= nVal) + { + for (size_t i = 0; i < SAL_N_ELEMENTS(aConditionEntryMap); ++i) + { + if (aConditionEntryMap[i].nApiMode == nVal) + { + getCoreObject()->SetOperation(aConditionEntryMap[i].eMode); + break; + } + } + } + } break; default: SAL_WARN("sc", "unsupported property"); @@ -517,25 +580,34 @@ uno::Any SAL_CALL ScConditionEntryObj::getPropertyValue( const OUString& aProper switch(pEntry->nWID) { case StyleName: - aAny <<= pFormat->GetStyle(); + aAny <<= getCoreObject()->GetStyle(); break; case Formula1: { - ScAddress aCursor = pFormat->GetSrcPos(); - OUString aFormula = pFormat->GetExpression(aCursor, 0); + ScAddress aCursor = getCoreObject()->GetSrcPos(); + OUString aFormula = getCoreObject()->GetExpression(aCursor, 0); aAny <<= aFormula; } break; case Formula2: { - ScAddress aCursor = pFormat->GetSrcPos(); - OUString aFormula = pFormat->GetExpression(aCursor, 1); + ScAddress aCursor = getCoreObject()->GetSrcPos(); + OUString aFormula = getCoreObject()->GetExpression(aCursor, 1); aAny <<= aFormula; } break; case Operator: { + ScConditionMode eMode = getCoreObject()->GetOperation(); + for (size_t i = 0; i < SAL_N_ELEMENTS(aConditionEntryMap); ++i) + { + if (aConditionEntryMap[i].eMode == eMode) + { + aAny <<= aConditionEntryMap[i].nApiMode; + break; + } + } } break; default: commit b1df39726f28b356a3f77e17d83809dd13dabcb6 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Thu Mar 26 23:14:29 2015 +0100 more work for fixing lifecycle Change-Id: Ieba2eef93777f616bda6a46fe206b773c09ab2a0 diff --git a/sc/source/ui/inc/condformatuno.hxx b/sc/source/ui/inc/condformatuno.hxx index e23ff42..d5c1865 100644 --- a/sc/source/ui/inc/condformatuno.hxx +++ b/sc/source/ui/inc/condformatuno.hxx @@ -32,7 +32,7 @@ class ScConditionalFormatList; class ScConditionalFormat; class ScIconSetFormat; class ScDataBarFormat; -class ScColorScale; +class ScColorScaleFormat; class ScCondFormatEntry; using namespace com::sun::star; @@ -181,6 +181,8 @@ public: static ScConditionEntryObj* getImplementation(uno::Reference<sheet::XConditionEntry> xCondition); + ScCondFormatEntry* getCoreObject(); + // XConditionEntry virtual sal_Int32 SAL_CALL getType() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; @@ -227,8 +229,9 @@ public: ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; private: + ScDocShell* mpDocShell; + rtl::Reference<ScCondFormatObj> mxParent; SfxItemPropertySet maPropSet; - ScCondFormatEntry* pFormat; }; class ScColorScaleFormatObj : public cppu::WeakImplHelper1<com::sun::star::beans::XPropertySet> @@ -240,6 +243,8 @@ public: static ScColorScaleFormatObj* getImplementation(uno::Reference<beans::XPropertySet> xPropSet); + ScColorScaleFormat* getCoreObject(); + // XPropertySet virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() @@ -282,7 +287,8 @@ public: ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; private: - ScColorScale* pColorScale; + ScDocShell* mpDocShell; + rtl::Reference<ScCondFormatObj> mxParent; SfxItemPropertySet maPropSet; }; @@ -294,6 +300,8 @@ public: static ScDataBarFormatObj* getImplementation(uno::Reference<beans::XPropertySet> xPropSet); + ScDataBarFormat* getCoreObject(); + // XPropertySet virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() @@ -336,7 +344,8 @@ public: ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; private: - ScDataBarFormat* mpDataBar; + ScDocShell* mpDocShell; + rtl::Reference<ScCondFormatObj> mxParent; SfxItemPropertySet maPropSet; }; @@ -348,6 +357,8 @@ public: static ScIconSetFormatObj* getImplementation(uno::Reference<beans::XPropertySet> xPropSet); + ScIconSetFormat* getCoreObject(); + // XPropertySet virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() @@ -390,8 +401,8 @@ public: ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; private: - - ScIconSetFormat* mpIconSet; + ScDocShell* mpDocShell; + rtl::Reference<ScCondFormatObj> mxParent; SfxItemPropertySet maPropSet; }; diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx index 7113129..81e32f7 100644 --- a/sc/source/ui/unoobj/condformatuno.cxx +++ b/sc/source/ui/unoobj/condformatuno.cxx @@ -455,6 +455,11 @@ ScConditionEntryObj::~ScConditionEntryObj() { } +ScCondFormatEntry* ScConditionEntryObj::getCoreObject() +{ + return NULL; +} + sal_Int32 ScConditionEntryObj::getType() throw(uno::RuntimeException, std::exception) { @@ -580,6 +585,11 @@ ScColorScaleFormatObj::~ScColorScaleFormatObj() { } +ScColorScaleFormat* ScColorScaleFormatObj::getCoreObject() +{ + return NULL; +} + uno::Reference<beans::XPropertySetInfo> SAL_CALL ScColorScaleFormatObj::getPropertySetInfo() throw(uno::RuntimeException, std::exception) { @@ -675,6 +685,11 @@ ScDataBarFormatObj::~ScDataBarFormatObj() { } +ScDataBarFormat* ScDataBarFormatObj::getCoreObject() +{ + return NULL; +} + uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDataBarFormatObj::getPropertySetInfo() throw(uno::RuntimeException, std::exception) { @@ -708,7 +723,7 @@ void SAL_CALL ScDataBarFormatObj::setPropertyValue( bool bUseGradient = true; if (aValue >>= bUseGradient) { - mpDataBar->GetDataBarData()->mbGradient = bUseGradient; + getCoreObject()->GetDataBarData()->mbGradient = bUseGradient; } } break; @@ -717,10 +732,10 @@ void SAL_CALL ScDataBarFormatObj::setPropertyValue( bool bUseNegativeColor = false; if (aValue >>= bUseNegativeColor) { - mpDataBar->GetDataBarData()->mbNeg = bUseNegativeColor; - if (bUseNegativeColor && !mpDataBar->GetDataBarData()->mpNegativeColor) + getCoreObject()->GetDataBarData()->mbNeg = bUseNegativeColor; + if (bUseNegativeColor && !getCoreObject()->GetDataBarData()->mpNegativeColor) { - mpDataBar->GetDataBarData()->mpNegativeColor.reset(new Color(COL_AUTO)); + getCoreObject()->GetDataBarData()->mpNegativeColor.reset(new Color(COL_AUTO)); } } } @@ -730,7 +745,7 @@ void SAL_CALL ScDataBarFormatObj::setPropertyValue( bool bShowValue = true; if (aValue >>= bShowValue) { - mpDataBar->GetDataBarData()->mbOnlyBar = !bShowValue; + getCoreObject()->GetDataBarData()->mbOnlyBar = !bShowValue; } } break; @@ -739,7 +754,7 @@ void SAL_CALL ScDataBarFormatObj::setPropertyValue( sal_Int32 nColor = COL_AUTO; if (aValue >>= nColor) { - mpDataBar->GetDataBarData()->maPositiveColor.SetColor(nColor); + getCoreObject()->GetDataBarData()->maPositiveColor.SetColor(nColor); } } break; @@ -748,16 +763,16 @@ void SAL_CALL ScDataBarFormatObj::setPropertyValue( sal_Int32 nAxisColor = COL_AUTO; if (aValue >>= nAxisColor) { - mpDataBar->GetDataBarData()->maAxisColor.SetColor(nAxisColor); + getCoreObject()->GetDataBarData()->maAxisColor.SetColor(nAxisColor); } } break; case NegativeColor: { sal_Int32 nNegativeColor = COL_AUTO; - if ((aValue >>= nNegativeColor) && mpDataBar->GetDataBarData()->mbNeg) + if ((aValue >>= nNegativeColor) && getCoreObject()->GetDataBarData()->mbNeg) { - mpDataBar->GetDataBarData()->mpNegativeColor->SetColor(nNegativeColor); + getCoreObject()->GetDataBarData()->mpNegativeColor->SetColor(nNegativeColor); } else throw lang::IllegalArgumentException(); @@ -786,7 +801,7 @@ uno::Any SAL_CALL ScDataBarFormatObj::getPropertyValue( const OUString& aPropert { case AxisPosition: { - databar::ScAxisPosition ePos = mpDataBar->GetDataBarData()->meAxisPosition; + databar::ScAxisPosition ePos = getCoreObject()->GetDataBarData()->meAxisPosition; sal_Int32 nApiPos = sheet::DataBarAxis::AXIS_NONE; for (size_t i = 0; i < SAL_N_ELEMENTS(aDataBarAxisMap); ++i) { @@ -801,36 +816,36 @@ uno::Any SAL_CALL ScDataBarFormatObj::getPropertyValue( const OUString& aPropert break; case UseGradient: { - aAny <<= mpDataBar->GetDataBarData()->mbGradient; + aAny <<= getCoreObject()->GetDataBarData()->mbGradient; } break; case UseNegativeColor: { - aAny <<= mpDataBar->GetDataBarData()->mbNeg; + aAny <<= getCoreObject()->GetDataBarData()->mbNeg; } break; case DataBar_ShowValue: { - aAny <<= !mpDataBar->GetDataBarData()->mbOnlyBar; + aAny <<= !getCoreObject()->GetDataBarData()->mbOnlyBar; } break; case DataBar_Color: { - sal_Int32 nColor = mpDataBar->GetDataBarData()->maPositiveColor.GetColor(); + sal_Int32 nColor = getCoreObject()->GetDataBarData()->maPositiveColor.GetColor(); aAny <<= nColor; } break; case AxisColor: { - sal_Int32 nAxisColor = mpDataBar->GetDataBarData()->maAxisColor.GetColor(); + sal_Int32 nAxisColor = getCoreObject()->GetDataBarData()->maAxisColor.GetColor(); aAny <<= nAxisColor; } break; case NegativeColor: { - if (mpDataBar->GetDataBarData()->mbNeg && mpDataBar->GetDataBarData()->mpNegativeColor) + if (getCoreObject()->GetDataBarData()->mbNeg && getCoreObject()->GetDataBarData()->mpNegativeColor) { - sal_Int32 nNegativeColor = mpDataBar->GetDataBarData() ->mpNegativeColor->GetColor(); + sal_Int32 nNegativeColor = getCoreObject()->GetDataBarData()->mpNegativeColor->GetColor(); aAny <<= nNegativeColor; } } @@ -884,6 +899,11 @@ ScIconSetFormatObj::~ScIconSetFormatObj() { } +ScIconSetFormat* ScIconSetFormatObj::getCoreObject() +{ + return NULL; +} + uno::Reference<beans::XPropertySetInfo> SAL_CALL ScIconSetFormatObj::getPropertySetInfo() throw(uno::RuntimeException, std::exception) { @@ -912,14 +932,14 @@ void SAL_CALL ScIconSetFormatObj::setPropertyValue( { bool bShowValue = true; aValue >>= bShowValue; - mpIconSet->GetIconSetData()->mbShowValue = bShowValue; + getCoreObject()->GetIconSetData()->mbShowValue = bShowValue; } break; case Reverse: { bool bReverse = false; aValue >>= bReverse; - mpIconSet->GetIconSetData()->mbReverse = bReverse; + getCoreObject()->GetIconSetData()->mbReverse = bReverse; } break; case Icons: @@ -943,7 +963,7 @@ void SAL_CALL ScIconSetFormatObj::setPropertyValue( throw lang::IllegalArgumentException(); } - mpIconSet->GetIconSetData()->eIconSetType = eType; + getCoreObject()->GetIconSetData()->eIconSetType = eType; } break; } @@ -965,14 +985,14 @@ uno::Any SAL_CALL ScIconSetFormatObj::getPropertyValue( const OUString& aPropert switch(pEntry->nWID) { case ShowValue: - aAny <<= mpIconSet->GetIconSetData()->mbShowValue; + aAny <<= getCoreObject()->GetIconSetData()->mbShowValue; break; case Reverse: - aAny <<= mpIconSet->GetIconSetData()->mbReverse; + aAny <<= getCoreObject()->GetIconSetData()->mbReverse; break; case Icons: { - ScIconSetType eType = mpIconSet->GetIconSetData()->eIconSetType; + ScIconSetType eType = getCoreObject()->GetIconSetData()->eIconSetType; for (size_t i = 0; i < SAL_N_ELEMENTS(aIconSetApiMap); ++i) { if (aIconSetApiMap[i].eType == eType) @@ -985,8 +1005,8 @@ uno::Any SAL_CALL ScIconSetFormatObj::getPropertyValue( const OUString& aPropert break; case IconSetEntries: { - uno::Sequence< sheet::XIconSetEntry > aEntries(mpIconSet->size()); - for (auto it = mpIconSet->begin(), itEnd = mpIconSet->end(); it != itEnd; ++it) + uno::Sequence< sheet::XIconSetEntry > aEntries(getCoreObject()->size()); + for (auto it = getCoreObject()->begin(), itEnd = getCoreObject()->end(); it != itEnd; ++it) { //aEntries.operator[] = ; } commit a017e073f033f669de79bb7fc7dc1268ff236dd8 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Thu Mar 26 23:12:10 2015 +0100 add missing enum values Change-Id: I3234fb21e3f62068e39b6667e9c77e857536ade4 diff --git a/offapi/com/sun/star/sheet/ConditionFormatOperator.idl b/offapi/com/sun/star/sheet/ConditionFormatOperator.idl index 187fde36..68ac0e2 100644 --- a/offapi/com/sun/star/sheet/ConditionFormatOperator.idl +++ b/offapi/com/sun/star/sheet/ConditionFormatOperator.idl @@ -54,11 +54,15 @@ constants ConditionFormatOperator const long NO_ERROR = 19; - const long CONTAINS = 20; + const long BEGINS_WITH = 20; - const long NOT_CONTAINS = 21; + const long ENDS_WITH = 21; - const long EXPRESSION = 22; + const long CONTAINS = 22; + + const long NOT_CONTAINS = 23; + + const long EXPRESSION = 24; }; commit 31cf3baa7985cc98339a83ecd22aa7fe5fbc7916 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Tue Mar 17 08:34:05 2015 +0100 let all new conditional formatting objects use WeakImplHelper Change-Id: I3b7bfb0104fb4b41c2c84d00723934faa8de5be9 diff --git a/sc/source/ui/inc/condformatuno.hxx b/sc/source/ui/inc/condformatuno.hxx index 12b7f2f..e23ff42 100644 --- a/sc/source/ui/inc/condformatuno.hxx +++ b/sc/source/ui/inc/condformatuno.hxx @@ -171,9 +171,8 @@ private: sal_Int32 mnKey; }; -class ScConditionEntryObj : public com::sun::star::beans::XPropertySet, - public com::sun::star::sheet::XConditionEntry, - public cppu::OWeakObject +class ScConditionEntryObj : public cppu::WeakImplHelper2<com::sun::star::beans::XPropertySet, + com::sun::star::sheet::XConditionEntry> { public: @@ -232,8 +231,7 @@ private: ScCondFormatEntry* pFormat; }; -class ScColorScaleFormatObj : public com::sun::star::beans::XPropertySet, - public cppu::OWeakObject +class ScColorScaleFormatObj : public cppu::WeakImplHelper1<com::sun::star::beans::XPropertySet> { public: @@ -288,8 +286,7 @@ private: SfxItemPropertySet maPropSet; }; -class ScDataBarFormatObj : public com::sun::star::beans::XPropertySet, - public cppu::OWeakObject +class ScDataBarFormatObj : public cppu::WeakImplHelper1<com::sun::star::beans::XPropertySet> { public: ScDataBarFormatObj(); @@ -343,8 +340,7 @@ private: SfxItemPropertySet maPropSet; }; -class ScIconSetFormatObj : public com::sun::star::beans::XPropertySet, - public cppu::OWeakObject +class ScIconSetFormatObj : public cppu::WeakImplHelper1<com::sun::star::beans::XPropertySet> { public: ScIconSetFormatObj(); commit f2462b220562dc961f0858073389ed9ef3bbf571 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Tue Mar 17 08:28:20 2015 +0100 add XIndex interface tests for ScCondFormatObj Change-Id: I55604485183057f476c636abc4d43bc9fc58711a diff --git a/sc/qa/extras/new_cond_format.cxx b/sc/qa/extras/new_cond_format.cxx index 88bccdd..e648edc 100644 --- a/sc/qa/extras/new_cond_format.cxx +++ b/sc/qa/extras/new_cond_format.cxx @@ -20,7 +20,7 @@ using namespace css; namespace sc_apitest { -#define NUMBER_OF_TESTS 4 +#define NUMBER_OF_TESTS 5 class ScConditionalFormatTest : public CalcUnoApiTest { @@ -35,12 +35,14 @@ public: void testCondFormatListProperties(); void testCondFormatListFormats(); void testCondFormatProperties(); + void testCondFormatXIndex(); CPPUNIT_TEST_SUITE(ScConditionalFormatTest); CPPUNIT_TEST(testRequestCondFormatListFromSheet); CPPUNIT_TEST(testCondFormatListProperties); CPPUNIT_TEST(testCondFormatListFormats); CPPUNIT_TEST(testCondFormatProperties); + CPPUNIT_TEST(testCondFormatXIndex); CPPUNIT_TEST_SUITE_END(); private: @@ -148,6 +150,30 @@ void ScConditionalFormatTest::testCondFormatProperties() CPPUNIT_ASSERT_EQUAL(sal_Int32(16), aRange.EndRow); } +void ScConditionalFormatTest::testCondFormatXIndex() +{ + uno::Reference<sheet::XConditionalFormats> xCondFormatList = + getConditionalFormatList(init(1)); + + uno::Sequence<uno::Reference<sheet::XConditionalFormat> > xCondFormats = + xCondFormatList->getConditionalFormats(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xCondFormats.getLength()); + + uno::Reference<sheet::XConditionalFormat> xCondFormat = xCondFormats[0]; + CPPUNIT_ASSERT(xCondFormat.is()); + + uno::Type aType = xCondFormat->getElementType(); + CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.sheet.XConditionEntry"), aType.getTypeName()); + + CPPUNIT_ASSERT(xCondFormat->hasElements()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xCondFormat->getCount()); + /* + * missing implementation + uno::Any aAny = xCondFormat->getByIndex(0); + CPPUNIT_ASSERT(aAny.hasValue()); + */ +} + void ScConditionalFormatTest::setUp() { nTest++; commit 0b1c4b8a0a5fb0b61cf044a2d54ba797fec69d9b Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Tue Mar 17 08:17:53 2015 +0100 add test for XPropertySet for ScCondFormatObj Change-Id: I1786a8b1bf871ccefd73efe3e0515bc3a7dda709 diff --git a/sc/qa/extras/new_cond_format.cxx b/sc/qa/extras/new_cond_format.cxx index ea17e10..88bccdd 100644 --- a/sc/qa/extras/new_cond_format.cxx +++ b/sc/qa/extras/new_cond_format.cxx @@ -20,7 +20,7 @@ using namespace css; namespace sc_apitest { -#define NUMBER_OF_TESTS 2 +#define NUMBER_OF_TESTS 4 class ScConditionalFormatTest : public CalcUnoApiTest { @@ -34,11 +34,13 @@ public: void testRequestCondFormatListFromSheet(); void testCondFormatListProperties(); void testCondFormatListFormats(); + void testCondFormatProperties(); CPPUNIT_TEST_SUITE(ScConditionalFormatTest); CPPUNIT_TEST(testRequestCondFormatListFromSheet); CPPUNIT_TEST(testCondFormatListProperties); CPPUNIT_TEST(testCondFormatListFormats); + CPPUNIT_TEST(testCondFormatProperties); CPPUNIT_TEST_SUITE_END(); private: @@ -120,6 +122,32 @@ void ScConditionalFormatTest::testCondFormatListFormats() } } +void ScConditionalFormatTest::testCondFormatProperties() +{ + uno::Reference<sheet::XConditionalFormats> xCondFormatList = + getConditionalFormatList(init(1)); + + uno::Sequence<uno::Reference<sheet::XConditionalFormat> > xCondFormats = + xCondFormatList->getConditionalFormats(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xCondFormats.getLength()); + + uno::Reference<sheet::XConditionalFormat> xCondFormat = xCondFormats[0]; + CPPUNIT_ASSERT(xCondFormat.is()); + uno::Reference<beans::XPropertySet> xPropSet(xCondFormat, uno::UNO_QUERY_THROW); + uno::Any aAny = xPropSet->getPropertyValue("Range"); + uno::Reference<sheet::XSheetCellRanges> xCellRanges; + CPPUNIT_ASSERT(aAny >>= xCellRanges); + CPPUNIT_ASSERT(xCellRanges.is()); + uno::Sequence<table::CellRangeAddress> aRanges = xCellRanges->getRangeAddresses(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aRanges.getLength()); + table::CellRangeAddress aRange = aRanges[0]; + CPPUNIT_ASSERT_EQUAL(sal_Int16(1), aRange.Sheet); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aRange.StartColumn); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), aRange.StartRow); + CPPUNIT_ASSERT_EQUAL(sal_Int32(7), aRange.EndColumn); + CPPUNIT_ASSERT_EQUAL(sal_Int32(16), aRange.EndRow); +} + void ScConditionalFormatTest::setUp() { nTest++; diff --git a/sc/qa/extras/testdocuments/new_cond_format_api.ods b/sc/qa/extras/testdocuments/new_cond_format_api.ods index 8208fea..3660f45 100644 Binary files a/sc/qa/extras/testdocuments/new_cond_format_api.ods and b/sc/qa/extras/testdocuments/new_cond_format_api.ods differ commit c75c0cd7eea3b6c626ab3c981b717a92cbf1d8f8 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Tue Mar 17 07:56:58 2015 +0100 prepare test code for next tests Change-Id: I38cfba16e3187a9d80b51258c85f06a829a8a76c diff --git a/sc/qa/extras/new_cond_format.cxx b/sc/qa/extras/new_cond_format.cxx index cd4826c..ea17e10 100644 --- a/sc/qa/extras/new_cond_format.cxx +++ b/sc/qa/extras/new_cond_format.cxx @@ -30,7 +30,7 @@ public: virtual void setUp() SAL_OVERRIDE; virtual void tearDown() SAL_OVERRIDE; - uno::Reference< uno::XInterface > init(); + uno::Reference< uno::XInterface > init(sal_Int32 nIndex = 0); void testRequestCondFormatListFromSheet(); void testCondFormatListProperties(); void testCondFormatListFormats(); @@ -54,7 +54,7 @@ ScConditionalFormatTest::ScConditionalFormatTest() { } -uno::Reference< uno::XInterface > ScConditionalFormatTest::init() +uno::Reference< uno::XInterface > ScConditionalFormatTest::init(sal_Int32 nIndex) { if(!mxComponent.is()) { @@ -68,7 +68,7 @@ uno::Reference< uno::XInterface > ScConditionalFormatTest::init() // get the first sheet uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, uno::UNO_QUERY_THROW); uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), uno::UNO_QUERY_THROW); - uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(nIndex), uno::UNO_QUERY_THROW); return xSheet; } commit f104581dd1c3daf8e0ccd5c027259f12792cd26e Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Tue Mar 17 07:56:20 2015 +0100 fix a few places around range for conditional format API Change-Id: I544314004e32465248a1ec228dddcf84052d7d2d diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx index 8ceee90..7113129 100644 --- a/sc/source/ui/unoobj/condformatuno.cxx +++ b/sc/source/ui/unoobj/condformatuno.cxx @@ -16,6 +16,7 @@ #include "miscuno.hxx" #include "cellsuno.hxx" +#include "convuno.hxx" #include <vcl/svapp.hxx> #include <rtl/ustring.hxx> @@ -341,7 +342,7 @@ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCondFormatObj::getPropertySet } void SAL_CALL ScCondFormatObj::setPropertyValue( - const OUString& aPropertyName, const uno::Any& /*aValue*/ ) + const OUString& aPropertyName, const uno::Any& aValue ) throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception) @@ -359,6 +360,23 @@ void SAL_CALL ScCondFormatObj::setPropertyValue( throw lang::IllegalArgumentException(); break; case CondFormat_Range: + { + uno::Reference<sheet::XSheetCellRanges> xRange; + if (aValue >>= xRange) + { + ScConditionalFormat* pFormat = getCoreObject(); + uno::Sequence<table::CellRangeAddress> aRanges = + xRange->getRangeAddresses(); + ScRangeList aTargetRange; + for (size_t i = 0, n = aRanges.getLength(); i < n; ++i) + { + ScRange aRange; + ScUnoConversion::FillScRange(aRange, aRanges[i]); + aTargetRange.Join(aRange); + } + pFormat->SetRange(aTargetRange); + } + } break; default: SAL_WARN("sc", "unknown property"); @@ -387,6 +405,7 @@ uno::Any SAL_CALL ScCondFormatObj::getPropertyValue( const OUString& aPropertyNa const ScRangeList& rRange = getCoreObject()->GetRange(); uno::Reference<sheet::XSheetCellRanges> xRange; xRange.set(new ScCellRangesObj(mpDocShell, rRange)); + aAny <<= xRange; } break; default: commit 8a5482912b5091ede68b823e4e29cfb2f74c6315 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Mon Mar 16 23:14:08 2015 +0100 add test for one of the ScCondFormatsObj methods Change-Id: I05fc54a2153fd90d03d2575bdd9bde30a54d71c1 diff --git a/sc/qa/extras/new_cond_format.cxx b/sc/qa/extras/new_cond_format.cxx index 3200998..cd4826c 100644 --- a/sc/qa/extras/new_cond_format.cxx +++ b/sc/qa/extras/new_cond_format.cxx @@ -33,10 +33,12 @@ public: uno::Reference< uno::XInterface > init(); void testRequestCondFormatListFromSheet(); void testCondFormatListProperties(); + void testCondFormatListFormats(); CPPUNIT_TEST_SUITE(ScConditionalFormatTest); CPPUNIT_TEST(testRequestCondFormatListFromSheet); CPPUNIT_TEST(testCondFormatListProperties); + CPPUNIT_TEST(testCondFormatListFormats); CPPUNIT_TEST_SUITE_END(); private: @@ -104,6 +106,20 @@ void ScConditionalFormatTest::testCondFormatListProperties() CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xCondFormat->getLength()); } +void ScConditionalFormatTest::testCondFormatListFormats() +{ + uno::Reference<sheet::XConditionalFormats> xCondFormatList = + getConditionalFormatList(init()); + + uno::Sequence<uno::Reference<sheet::XConditionalFormat> > xCondFormats = + xCondFormatList->getConditionalFormats(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xCondFormats.getLength()); + for (sal_Int32 i = 0, n = xCondFormats.getLength(); i < n; ++i) + { + CPPUNIT_ASSERT(xCondFormats[i].is()); + } +} + void ScConditionalFormatTest::setUp() { nTest++; commit 0b8777dc19bb86fb196f45183cdc9fa8f764add3 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Mon Mar 16 22:50:18 2015 +0100 integrate ScConditionalFormat UNO object correctly Change-Id: I8da8d954dc7bcdf0a8c2f78eeb6b2403eb75d9e3 diff --git a/sc/source/ui/inc/condformatuno.hxx b/sc/source/ui/inc/condformatuno.hxx index eacdd21..12b7f2f 100644 --- a/sc/source/ui/inc/condformatuno.hxx +++ b/sc/source/ui/inc/condformatuno.hxx @@ -21,8 +21,10 @@ #include <com/sun/star/sheet/XIconSetEntry.hpp> #include <cppuhelper/implbase1.hxx> +#include <cppuhelper/implbase2.hxx> #include <svl/itemprop.hxx> #include <svl/lstner.hxx> +#include <rtl/ref.hxx> class ScDocument; class ScDocShell; @@ -75,18 +77,18 @@ public: throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; -private: ScConditionalFormatList* getCoreObject(); + +private: SCTAB mnTab; ScDocShell* mpDocShell; }; -class ScCondFormatObj : public com::sun::star::sheet::XConditionalFormat, - public com::sun::star::beans::XPropertySet, - public cppu::OWeakObject +class ScCondFormatObj : public cppu::WeakImplHelper2<com::sun::star::sheet::XConditionalFormat, + com::sun::star::beans::XPropertySet> { public: - ScCondFormatObj(ScDocument* pDoc, ScConditionalFormat* pList); + ScCondFormatObj(ScDocShell* pDocShell, rtl::Reference<ScCondFormatsObj> xCondFormats, sal_Int32 nKey); virtual ~ScCondFormatObj(); @@ -101,6 +103,24 @@ public: throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + // XIndexAccess + + virtual uno::Type SAL_CALL getElementType() + throw(::com::sun::star::uno::RuntimeException, + std::exception) SAL_OVERRIDE; + + virtual sal_Bool SAL_CALL hasElements() + throw(::com::sun::star::uno::RuntimeException, + std::exception) SAL_OVERRIDE; + + virtual sal_Int32 SAL_CALL getCount() + throw(::com::sun::star::uno::RuntimeException, + std::exception) SAL_OVERRIDE; + + virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) + throw(::com::sun::star::uno::RuntimeException, + std::exception) SAL_OVERRIDE; + // XPropertySet virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() @@ -142,9 +162,13 @@ public: ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + ScConditionalFormat* getCoreObject(); + private: - ScConditionalFormat* mpFormat; + rtl::Reference<ScCondFormatsObj> mxCondFormatList; + ScDocShell* mpDocShell; SfxItemPropertySet maPropSet; + sal_Int32 mnKey; }; class ScConditionEntryObj : public com::sun::star::beans::XPropertySet, diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx index faa108c..8ceee90 100644 ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits