[Libreoffice-commits] core.git: Branch 'private/moggi/conditional-format-api' - 4 commits - offapi/com sc/inc sc/source
Markus Mohrhard
markus.mohrhard at collabora.co.uk
Sun Mar 29 17:04:14 PDT 2015
offapi/com/sun/star/sheet/ConditionEntryType.idl | 8
sc/inc/colorscale.hxx | 2
sc/source/core/data/colorscale.cxx | 8
sc/source/ui/inc/condformatuno.hxx | 58 ++++++
sc/source/ui/unoobj/condformatuno.cxx | 196 ++++++++++++++++++++++-
5 files changed, 260 insertions(+), 12 deletions(-)
New commits:
commit c0b663063c38bea1e3cd60d2583813d78c0c02b7
Author: Markus Mohrhard <markus.mohrhard at 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 7200a2a..fd56c05 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_CALL sal_Int32 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_CALL sal_Int32 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_CALL sal_Int32 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 5f45cb8efe6d34e47720582e0844e930d9d13dec
Author: Markus Mohrhard <markus.mohrhard at 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 013d74bbe49b0bed7d0c8d39a84c37aa66dff177
Author: Markus Mohrhard <markus.mohrhard at 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 20c89ae3d5f28642fff654d33244ddcf237b22cf
Author: Markus Mohrhard <markus.mohrhard at 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 3e29911..4b8c56d 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -267,6 +267,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 9c4d7ce..bc45cb7 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 7088bd3..7200a2a 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()),
More information about the Libreoffice-commits
mailing list