[Libreoffice-commits] core.git: 6 commits - offapi/com sc/qa sc/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Thu Apr 2 08:31:55 PDT 2015
offapi/com/sun/star/sheet/DataBar.idl | 14 ++
sc/qa/extras/new_cond_format.cxx | 171 ++++++++++++++++++++++++++++++++++
sc/source/ui/unoobj/condformatuno.cxx | 29 +++++
3 files changed, 212 insertions(+), 2 deletions(-)
New commits:
commit 3aac11a1233f679ea813fee8b8de134553d7db60
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Apr 2 17:29:08 2015 +0200
test color scale entries
Change-Id: I95b8a415e6dea108ac1401447e3c645e8a7b75ef
diff --git a/sc/qa/extras/new_cond_format.cxx b/sc/qa/extras/new_cond_format.cxx
index b7798f2..375b23a 100644
--- a/sc/qa/extras/new_cond_format.cxx
+++ b/sc/qa/extras/new_cond_format.cxx
@@ -17,6 +17,8 @@
#include <com/sun/star/sheet/DataBarAxis.hpp>
#include <com/sun/star/sheet/XDataBarEntry.hpp>
#include <com/sun/star/sheet/DataBarEntryType.hpp>
+#include <com/sun/star/sheet/ColorScaleEntryType.hpp>
+#include <com/sun/star/sheet/XColorScaleEntry.hpp>
#include <unonames.hxx>
using namespace css;
@@ -359,6 +361,51 @@ void ScConditionalFormatTest::testDataBarProperties()
}
}
+namespace {
+
+void testColorScaleEntry(uno::Reference<sheet::XColorScaleEntry> xEntry,
+ sal_Int32 nType, const OUString& rString, sal_uInt32 nColor)
+{
+ CPPUNIT_ASSERT_EQUAL(nType, xEntry->getType());
+ CPPUNIT_ASSERT_EQUAL(nColor, sal_uInt32(xEntry->getColor()));
+ switch (nType)
+ {
+ case sheet::ColorScaleEntryType::COLORSCALE_VALUE:
+ case sheet::ColorScaleEntryType::COLORSCALE_PERCENT:
+ case sheet::ColorScaleEntryType::COLORSCALE_PERCENTILE:
+ // case sheet::ColorScaleEntryType::COLORSCALE_FORMULA:
+ {
+ CPPUNIT_ASSERT_EQUAL(rString, xEntry->getFormula());
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void testColorScaleEntries(uno::Reference<beans::XPropertySet> xPropSet, sal_Int32 nEntries,
+ sal_Int32 nMinType, const OUString& rMinString, sal_uInt32 nMinColor,
+ sal_Int32 nMediumType, const OUString& rMediumString, sal_uInt32 nMediumColor,
+ sal_Int32 nMaxType, const OUString& rMaxString, sal_uInt32 nMaxColor)
+{
+ uno::Any aAny = xPropSet->getPropertyValue("ColorScaleEntries");
+ CPPUNIT_ASSERT(aAny.hasValue());
+ uno::Sequence<uno::Reference<sheet::XColorScaleEntry> > aEntries;
+ CPPUNIT_ASSERT(aAny >>= aEntries);
+
+ CPPUNIT_ASSERT_EQUAL(nEntries, aEntries.getLength());
+ testColorScaleEntry(aEntries[0], nMinType, rMinString, nMinColor);
+ size_t nMaxEntry = 1;
+ if (nEntries == 3)
+ {
+ nMaxEntry = 2;
+ testColorScaleEntry(aEntries[1], nMediumType, rMediumString, nMediumColor);
+ }
+ testColorScaleEntry(aEntries[nMaxEntry], nMaxType, rMaxString, nMaxColor);
+}
+
+}
+
void ScConditionalFormatTest::testColorScaleProperties()
{
uno::Reference<sheet::XConditionalFormats> xCondFormatList =
@@ -376,6 +423,32 @@ void ScConditionalFormatTest::testColorScaleProperties()
CPPUNIT_ASSERT(xCondFormat->hasElements());
CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xCondFormat->getCount());
+
+ uno::Reference<beans::XPropertySet> xPropSet;
+ {
+ uno::Any aAny = xCondFormat->getByIndex(0);
+ CPPUNIT_ASSERT(aAny.hasValue());
+ CPPUNIT_ASSERT(aAny >>= xPropSet);
+ testColorScaleEntries(xPropSet, 3, sheet::ColorScaleEntryType::COLORSCALE_MIN, "", sal_uInt32(16777113),
+ sheet::ColorScaleEntryType::COLORSCALE_PERCENTILE, "50", sal_uInt32(16737792),
+ sheet::ColorScaleEntryType::COLORSCALE_MAX, "", sal_uInt32(16724787));
+ }
+ {
+ uno::Any aAny = xCondFormat->getByIndex(1);
+ CPPUNIT_ASSERT(aAny.hasValue());
+ CPPUNIT_ASSERT(aAny >>= xPropSet);
+ testColorScaleEntries(xPropSet, 3, sheet::ColorScaleEntryType::COLORSCALE_VALUE, "0", sal_uInt32(16711680),
+ sheet::ColorScaleEntryType::COLORSCALE_PERCENTILE, "50", sal_uInt32(10092390),
+ sheet::ColorScaleEntryType::COLORSCALE_PERCENT, "90", sal_uInt32(255));
+ }
+ {
+ uno::Any aAny = xCondFormat->getByIndex(2);
+ CPPUNIT_ASSERT(aAny.hasValue());
+ CPPUNIT_ASSERT(aAny >>= xPropSet);
+ testColorScaleEntries(xPropSet, 2, sheet::ColorScaleEntryType::COLORSCALE_FORMULA, "=A1", COL_WHITE,
+ sheet::ColorScaleEntryType::COLORSCALE_PERCENTILE, "not used", sal_uInt32(1),
+ sheet::ColorScaleEntryType::COLORSCALE_VALUE, "10", COL_BLACK);
+ }
}
void ScConditionalFormatTest::setUp()
commit 60e48509fa4a200d96887eb4137c6b3b2788b608
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Thu Apr 2 16:53:58 2015 +0200
add test for remaining databar properties
Change-Id: I7188af55ebc48838ea236d482e8809a43a99ba9d
diff --git a/sc/qa/extras/new_cond_format.cxx b/sc/qa/extras/new_cond_format.cxx
index e067080..b7798f2 100644
--- a/sc/qa/extras/new_cond_format.cxx
+++ b/sc/qa/extras/new_cond_format.cxx
@@ -302,6 +302,61 @@ void ScConditionalFormatTest::testDataBarProperties()
testDataBarEntries(xPropSet, "", sheet::DataBarEntryType::DATABAR_AUTO,
"", sheet::DataBarEntryType::DATABAR_MAX);
}
+ {
+ uno::Any aAny = xCondFormat->getByIndex(1);
+ 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);
+ testDataBarEntries(xPropSet, "", sheet::DataBarEntryType::DATABAR_MIN,
+ "90", sheet::DataBarEntryType::DATABAR_PERCENTILE);
+ }
+ {
+ uno::Any aAny = xCondFormat->getByIndex(2);
+ 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);
+ testDataBarEntries(xPropSet, "2", sheet::DataBarEntryType::DATABAR_VALUE,
+ "80", sheet::DataBarEntryType::DATABAR_PERCENT);
+ }
+ {
+ uno::Any aAny = xCondFormat->getByIndex(3);
+ 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);
+ /*
+ * TODO: implement FORMULA
+ testDataBarEntries(xPropSet, "=A1", sheet::DataBarEntryType::DATABAR_FORMULA,
+ "", sheet::DataBarEntryType::DATABAR_AUTO);
+ */
+ }
+ {
+ uno::Any aAny = xCondFormat->getByIndex(4);
+ CPPUNIT_ASSERT(aAny.hasValue());
+ CPPUNIT_ASSERT(aAny >>= xPropSet);
+ testAxisPosition(xPropSet, sheet::DataBarAxis::AXIS_MIDDLE);
+ testShowValue(xPropSet, true);
+ testUseGradient(xPropSet, false);
+ testPositiveColor(xPropSet, sal_uInt32(10092390));
+ testNegativeColor(xPropSet, sal_uInt32(52428));
+ testAxisColor(xPropSet, sal_uInt32(16777113));
+ testDataBarEntries(xPropSet, "", sheet::DataBarEntryType::DATABAR_AUTO,
+ "", sheet::DataBarEntryType::DATABAR_AUTO);
+ }
}
void ScConditionalFormatTest::testColorScaleProperties()
commit ae7cfa6a9bef89bbe0f7d827925b606a3f59adef
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Thu Apr 2 15:58:51 2015 +0200
add a test for databar entries
Change-Id: I38c025481d3135a708668cad00816f22cdd66cc8
diff --git a/sc/qa/extras/new_cond_format.cxx b/sc/qa/extras/new_cond_format.cxx
index edefc1f..e067080 100644
--- a/sc/qa/extras/new_cond_format.cxx
+++ b/sc/qa/extras/new_cond_format.cxx
@@ -15,6 +15,8 @@
#include <com/sun/star/sheet/XSpreadsheet.hpp>
#include <com/sun/star/table/CellAddress.hpp>
#include <com/sun/star/sheet/DataBarAxis.hpp>
+#include <com/sun/star/sheet/XDataBarEntry.hpp>
+#include <com/sun/star/sheet/DataBarEntryType.hpp>
#include <unonames.hxx>
using namespace css;
@@ -227,6 +229,45 @@ void testAxisColor(uno::Reference<beans::XPropertySet> xPropSet, Color aColor)
CPPUNIT_ASSERT_EQUAL(aColor.GetColor(), sal_uInt32(nColor));
}
+void testDataBarEntryValue(uno::Reference<sheet::XDataBarEntry> xEntry,
+ const OUString& rExpectedValue, sal_Int32 nType)
+{
+ switch (nType)
+ {
+ case sheet::DataBarEntryType::DATABAR_VALUE:
+ case sheet::DataBarEntryType::DATABAR_PERCENT:
+ case sheet::DataBarEntryType::DATABAR_PERCENTILE:
+ case sheet::DataBarEntryType::DATABAR_FORMULA:
+ {
+ OUString aString = xEntry->getFormula();
+ CPPUNIT_ASSERT_EQUAL(rExpectedValue, aString);
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void testDataBarEntries(uno::Reference<beans::XPropertySet> xPropSet,
+ const OUString& rExpectedMinString, sal_Int32 nExpectedMinType,
+ const OUString& rExpectedMaxString, sal_Int32 nExpectedMaxType)
+{
+ uno::Any aAny = xPropSet->getPropertyValue("DataBarEntries");
+ uno::Sequence<uno::Reference<sheet::XDataBarEntry> > aEntries;
+ CPPUNIT_ASSERT(aAny >>= aEntries);
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aEntries.getLength());
+
+ sal_Int32 nMinType = aEntries[0]->getType();
+ CPPUNIT_ASSERT_EQUAL(nExpectedMinType, nMinType);
+
+ sal_Int32 nMaxType = aEntries[1]->getType();
+ CPPUNIT_ASSERT_EQUAL(nExpectedMaxType, nMaxType);
+
+ testDataBarEntryValue(aEntries[0], rExpectedMinString, nMinType);
+ testDataBarEntryValue(aEntries[1], rExpectedMaxString, nMaxType);
+}
+
}
void ScConditionalFormatTest::testDataBarProperties()
@@ -258,6 +299,8 @@ void ScConditionalFormatTest::testDataBarProperties()
testPositiveColor(xPropSet, COL_LIGHTBLUE);
testNegativeColor(xPropSet, COL_LIGHTRED);
testAxisColor(xPropSet, COL_BLACK);
+ testDataBarEntries(xPropSet, "", sheet::DataBarEntryType::DATABAR_AUTO,
+ "", sheet::DataBarEntryType::DATABAR_MAX);
}
}
commit b44acb8c559a98ffcee28e995f696055e022a7f5
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Thu Apr 2 15:58:24 2015 +0200
fix error in databar entry type api map
Change-Id: Ibf81edf40f1b8a591b48aa77314104e511f0ff49
diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx
index a12c32a..ad79b20 100644
--- a/sc/source/ui/unoobj/condformatuno.cxx
+++ b/sc/source/ui/unoobj/condformatuno.cxx
@@ -194,7 +194,7 @@ struct DataBarEntryTypeApiMap
DataBarEntryTypeApiMap aDataBarEntryTypeMap[] =
{
- { COLORSCALE_AUTO, sheet::DataBarEntryType::DATABAR_MAX },
+ { COLORSCALE_AUTO, sheet::DataBarEntryType::DATABAR_AUTO },
{ COLORSCALE_MIN, sheet::DataBarEntryType::DATABAR_MIN },
{ COLORSCALE_MAX, sheet::DataBarEntryType::DATABAR_MAX },
{ COLORSCALE_VALUE, sheet::DataBarEntryType::DATABAR_VALUE },
commit 2560c5222c811a3975fdccfd8a4f423e52a15e10
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Thu Apr 2 15:31:04 2015 +0200
add properties for new databar properties
Change-Id: Icc65283a1e60ea61af917432e3fb577e7b0370a7
diff --git a/offapi/com/sun/star/sheet/DataBar.idl b/offapi/com/sun/star/sheet/DataBar.idl
index 9045a67..3803dba 100644
--- a/offapi/com/sun/star/sheet/DataBar.idl
+++ b/offapi/com/sun/star/sheet/DataBar.idl
@@ -39,6 +39,20 @@ service DataBar
[property, optional] com::sun::star::util::Color NegativeColor;
[property] sequence<XDataBarEntry> DataBarEntries;
+
+ /**
+ * Mimimum databar length in percent of cell width.
+ *
+ * Allowed values are [0, 100) but smaller than MaximumLength.
+ */
+ [property] double MinimumLength;
+
+ /**
+ * Maximum databar length in percent of cell width.
+ *
+ * Allowed values are (0, 1000) but larger than MinimumLength.
+ */
+ [property] double MaximumLength;
};
diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx
index 745ea47..a12c32a 100644
--- a/sc/source/ui/unoobj/condformatuno.cxx
+++ b/sc/source/ui/unoobj/condformatuno.cxx
@@ -149,7 +149,9 @@ enum DataBarProperties
DataBar_Color,
AxisColor,
NegativeColor,
- DataBarEntries
+ DataBarEntries,
+ MinimumLength,
+ MaximumLength
};
const SfxItemPropertyMapEntry* getDataBarPropSet()
@@ -164,6 +166,8 @@ const SfxItemPropertyMapEntry* getDataBarPropSet()
{OUString("AxisColor"), AxisColor, cppu::UnoType<sal_Int32>::get(), 0, 0},
{OUString("NegativeColor"), NegativeColor, cppu::UnoType<sal_Int32>::get(), 0, 0},
{OUString("DataBarEntries"), DataBarEntries, cppu::UnoType<uno::Sequence< sheet::XDataBarEntry >>::get(), 0, 0 },
+ {OUString("MinimumLength"), MinimumLength, cppu::UnoType<double>::get(), 0, 0 },
+ {OUString("MaximumLength"), MaximumLength, cppu::UnoType<double>::get(), 0, 0 },
{OUString(), 0, css::uno::Type(), 0, 0}
};
return aDataBarPropertyMap_Impl;
@@ -1267,6 +1271,26 @@ void SAL_CALL ScDataBarFormatObj::setPropertyValue(
throw lang::IllegalArgumentException();
}
break;
+ case MinimumLength:
+ {
+ double nLength = 0;
+ if ((aValue >>= nLength) && nLength < 100 && nLength >= 0)
+ {
+ getCoreObject()->GetDataBarData()->mnMinLength = nLength;
+ }
+ else throw lang::IllegalArgumentException();
+ }
+ break;
+ case MaximumLength:
+ {
+ double nLength = 0;
+ if ((aValue >>= nLength) && nLength <= 100 && nLength > 0)
+ {
+ getCoreObject()->GetDataBarData()->mnMaxLength = nLength;
+ }
+ else throw lang::IllegalArgumentException();
+ }
+ break;
}
}
commit 68cec355eb75f1a03dabc5ccb29c97d281de3f32
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Mon Mar 30 13:04:32 2015 +0200
forgot the property definition
Change-Id: I60b28152068fa9d5fee9dff0509eb4a3721ce0ca
diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx
index 68f49ea..745ea47 100644
--- a/sc/source/ui/unoobj/condformatuno.cxx
+++ b/sc/source/ui/unoobj/condformatuno.cxx
@@ -275,6 +275,7 @@ const SfxItemPropertyMapEntry* getCondDatePropSet()
static const SfxItemPropertyMapEntry aCondDatePropertyMap_Impl[] =
{
{OUString("StyleName"), StyleName, cppu::UnoType<OUString>::get(), 0, 0},
+ {OUString("DateType"), Icons, getCppuType(&sheet::DateType::TODAY), 0, 0 },
{OUString(), 0, css::uno::Type(), 0, 0}
};
return aCondDatePropertyMap_Impl;
More information about the Libreoffice-commits
mailing list