offapi/com/sun/star/sheet/IconSetFormatEntry.idl | 13 sc/qa/extras/new_cond_format.cxx | 112 +++++ sc/qa/extras/testdocuments/new_cond_format_api.ods |binary sc/source/ui/inc/condformatuno.hxx | 68 +++ sc/source/ui/unoobj/condformatuno.cxx | 399 +++++++++++++++++++-- 5 files changed, 561 insertions(+), 31 deletions(-)
New commits: commit a3adf88205df89c7fafac8a434956e0495fd90d4 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 ca89b93acff683b7fb2f8212a6a303d43e7552f8 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 c0d30df0ef942e34c84a941757f11d59c52a4875 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 48bc1ae1ede126aecee3f817515380e6c8a25a8d 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 a4f6928..7088bd3 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 707fc3ad62f70e8ed5a8b83c1faa2b0ba7484e2d 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 6333775..a4f6928 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 22b3d0c25128953714a832bd9f9016768a195570 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 2f5adf45526ae1dc918731f9eb768023f5b4a9d9 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 d43719e42eb0931c2d859937859096155f537657 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 d3615d310314998364054aa7c1a5f03944d1877c 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 75e0f2ec5ef4b119cabe749dd394937153c70323 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 0e9ac286b45a21b2214365a154abcbf0d1cff93c 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 04acec2..6333775 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() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits