sc/qa/extras/new_cond_format.cxx | 62 +++++++++++++++++++-- sc/qa/extras/testdocuments/new_cond_format_api.ods |binary sc/source/ui/unoobj/condformatuno.cxx | 21 ++++++- 3 files changed, 78 insertions(+), 5 deletions(-)
New commits: commit bcb470224969420a9c7d5a7c4fbe52852209a6da 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 720813d776eb1ed33b76d84c9399639062d005ab 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 24b158fc554cf150d6418d8f8362e51acf468acc 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 aa35e3a50e6412346b0e761df03c89d84767997c 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: _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits