Kaydet (Commit) 21e92879 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

add color scale entries

Change-Id: If88822765b5ec738f3204a4ef7c76c3d529e6be2
üst 2773e6ff
...@@ -281,6 +281,8 @@ public: ...@@ -281,6 +281,8 @@ public:
iterator end(); iterator end();
const_iterator end() const; const_iterator end() const;
ScColorScaleEntry* GetEntry(size_t nPos);
size_t size() const; size_t size() const;
}; };
......
...@@ -671,6 +671,14 @@ ScColorScaleFormat::const_iterator ScColorScaleFormat::end() const ...@@ -671,6 +671,14 @@ ScColorScaleFormat::const_iterator ScColorScaleFormat::end() const
return maColorScales.end(); return maColorScales.end();
} }
ScColorScaleEntry* ScColorScaleFormat::GetEntry(size_t nPos)
{
if (maColorScales.size() <= nPos)
return NULL;
return &maColorScales[nPos];
}
size_t ScColorScaleFormat::size() const size_t ScColorScaleFormat::size() const
{ {
return maColorScales.size(); return maColorScales.size();
......
...@@ -297,6 +297,38 @@ private: ...@@ -297,6 +297,38 @@ private:
const ScColorScaleFormat* mpFormat; 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> class ScDataBarFormatObj : public cppu::WeakImplHelper1<com::sun::star::beans::XPropertySet>
{ {
public: public:
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <com/sun/star/sheet/DataBarAxis.hpp> #include <com/sun/star/sheet/DataBarAxis.hpp>
#include <com/sun/star/sheet/ConditionFormatOperator.hpp> #include <com/sun/star/sheet/ConditionFormatOperator.hpp>
#include <com/sun/star/sheet/DataBarEntryType.hpp> #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/IconSetFormatEntry.hpp>
namespace { namespace {
...@@ -121,6 +122,22 @@ const SfxItemPropertyMapEntry* getColorScalePropSet() ...@@ -121,6 +122,22 @@ const SfxItemPropertyMapEntry* getColorScalePropSet()
return aColorScalePropertyMap_Impl; 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 enum DataBarProperties
{ {
AxisPosition, AxisPosition,
...@@ -823,6 +840,14 @@ uno::Any SAL_CALL ScColorScaleFormatObj::getPropertyValue( const OUString& aProp ...@@ -823,6 +840,14 @@ uno::Any SAL_CALL ScColorScaleFormatObj::getPropertyValue( const OUString& aProp
switch(pEntry->nWID) switch(pEntry->nWID)
{ {
case ColorScaleEntries: 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; break;
default: default:
SAL_WARN("sc", "unknown property"); SAL_WARN("sc", "unknown property");
...@@ -863,6 +888,102 @@ void SAL_CALL ScColorScaleFormatObj::removeVetoableChangeListener( const OUStrin ...@@ -863,6 +888,102 @@ void SAL_CALL ScColorScaleFormatObj::removeVetoableChangeListener( const OUStrin
SAL_WARN("sc", "not implemented"); 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, ScDataBarFormatObj::ScDataBarFormatObj(rtl::Reference<ScCondFormatObj> xParent,
const ScDataBarFormat* pFormat): const ScDataBarFormat* pFormat):
mpDocShell(xParent->getDocShell()), mpDocShell(xParent->getDocShell()),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment