Kaydet (Commit) 3dce04a7 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

add uno object for iconset entries

Change-Id: I3eed6b39a72369063e160e2be7a27fed53a0234a
üst dd45f089
...@@ -441,6 +441,32 @@ private: ...@@ -441,6 +441,32 @@ private:
const ScIconSetFormat* mpFormat; 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 #endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -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/IconSetFormatEntry.hpp>
namespace { namespace {
...@@ -229,6 +230,21 @@ const IconSetTypeApiMap aIconSetApiMap[] = ...@@ -229,6 +230,21 @@ const IconSetTypeApiMap aIconSetApiMap[] =
{ IconSet_5Quarters, sheet::IconSetType::ICONSET_5QUARTERS }, { 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): ScCondFormatsObj::ScCondFormatsObj(ScDocShell* pDocShell, SCTAB nTab):
...@@ -1266,6 +1282,15 @@ void SAL_CALL ScIconSetFormatObj::setPropertyValue( ...@@ -1266,6 +1282,15 @@ void SAL_CALL ScIconSetFormatObj::setPropertyValue(
} }
break; break;
case IconSetEntries: case IconSetEntries:
{
uno::Sequence<uno::Reference<sheet::XIconSetEntry> > aEntries;
if (aValue >>= aEntries)
{
}
else
throw lang::IllegalArgumentException();
}
break; break;
default: default:
break; break;
...@@ -1308,11 +1333,13 @@ uno::Any SAL_CALL ScIconSetFormatObj::getPropertyValue( const OUString& aPropert ...@@ -1308,11 +1333,13 @@ uno::Any SAL_CALL ScIconSetFormatObj::getPropertyValue( const OUString& aPropert
break; break;
case IconSetEntries: case IconSetEntries:
{ {
uno::Sequence< sheet::XIconSetEntry > aEntries(getCoreObject()->size()); uno::Sequence<uno::Reference<sheet::XIconSetEntry> > aEntries(getCoreObject()->size());
for (auto it = getCoreObject()->begin(), itEnd = getCoreObject()->end(); it != itEnd; ++it) 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; break;
default: default:
...@@ -1353,4 +1380,86 @@ void SAL_CALL ScIconSetFormatObj::removeVetoableChangeListener( const OUString&, ...@@ -1353,4 +1380,86 @@ void SAL_CALL ScIconSetFormatObj::removeVetoableChangeListener( const OUString&,
SAL_WARN("sc", "not implemented"); 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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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