Kaydet (Commit) 0b8777dc authored tarafından Markus Mohrhard's avatar Markus Mohrhard

integrate ScConditionalFormat UNO object correctly

Change-Id: I8da8d954dc7bcdf0a8c2f78eeb6b2403eb75d9e3
üst 11b0bbcb
...@@ -21,8 +21,10 @@ ...@@ -21,8 +21,10 @@
#include <com/sun/star/sheet/XIconSetEntry.hpp> #include <com/sun/star/sheet/XIconSetEntry.hpp>
#include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase1.hxx>
#include <cppuhelper/implbase2.hxx>
#include <svl/itemprop.hxx> #include <svl/itemprop.hxx>
#include <svl/lstner.hxx> #include <svl/lstner.hxx>
#include <rtl/ref.hxx>
class ScDocument; class ScDocument;
class ScDocShell; class ScDocShell;
...@@ -75,18 +77,18 @@ public: ...@@ -75,18 +77,18 @@ public:
throw(::com::sun::star::uno::RuntimeException, throw(::com::sun::star::uno::RuntimeException,
std::exception) SAL_OVERRIDE; std::exception) SAL_OVERRIDE;
private:
ScConditionalFormatList* getCoreObject(); ScConditionalFormatList* getCoreObject();
private:
SCTAB mnTab; SCTAB mnTab;
ScDocShell* mpDocShell; ScDocShell* mpDocShell;
}; };
class ScCondFormatObj : public com::sun::star::sheet::XConditionalFormat, class ScCondFormatObj : public cppu::WeakImplHelper2<com::sun::star::sheet::XConditionalFormat,
public com::sun::star::beans::XPropertySet, com::sun::star::beans::XPropertySet>
public cppu::OWeakObject
{ {
public: public:
ScCondFormatObj(ScDocument* pDoc, ScConditionalFormat* pList); ScCondFormatObj(ScDocShell* pDocShell, rtl::Reference<ScCondFormatsObj> xCondFormats, sal_Int32 nKey);
virtual ~ScCondFormatObj(); virtual ~ScCondFormatObj();
...@@ -101,6 +103,24 @@ public: ...@@ -101,6 +103,24 @@ public:
throw(::com::sun::star::uno::RuntimeException, throw(::com::sun::star::uno::RuntimeException,
std::exception) SAL_OVERRIDE; std::exception) SAL_OVERRIDE;
// XIndexAccess
virtual uno::Type SAL_CALL getElementType()
throw(::com::sun::star::uno::RuntimeException,
std::exception) SAL_OVERRIDE;
virtual sal_Bool SAL_CALL hasElements()
throw(::com::sun::star::uno::RuntimeException,
std::exception) SAL_OVERRIDE;
virtual sal_Int32 SAL_CALL getCount()
throw(::com::sun::star::uno::RuntimeException,
std::exception) SAL_OVERRIDE;
virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex)
throw(::com::sun::star::uno::RuntimeException,
std::exception) SAL_OVERRIDE;
// XPropertySet // XPropertySet
virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
SAL_CALL getPropertySetInfo() SAL_CALL getPropertySetInfo()
...@@ -142,9 +162,13 @@ public: ...@@ -142,9 +162,13 @@ public:
::com::sun::star::lang::WrappedTargetException, ::com::sun::star::lang::WrappedTargetException,
::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
ScConditionalFormat* getCoreObject();
private: private:
ScConditionalFormat* mpFormat; rtl::Reference<ScCondFormatsObj> mxCondFormatList;
ScDocShell* mpDocShell;
SfxItemPropertySet maPropSet; SfxItemPropertySet maPropSet;
sal_Int32 mnKey;
}; };
class ScConditionEntryObj : public com::sun::star::beans::XPropertySet, class ScConditionEntryObj : public com::sun::star::beans::XPropertySet,
......
...@@ -235,7 +235,17 @@ void ScCondFormatsObj::removeByID(const sal_Int32 nID) ...@@ -235,7 +235,17 @@ void ScCondFormatsObj::removeByID(const sal_Int32 nID)
uno::Sequence<uno::Reference<sheet::XConditionalFormat> > ScCondFormatsObj::getConditionalFormats() uno::Sequence<uno::Reference<sheet::XConditionalFormat> > ScCondFormatsObj::getConditionalFormats()
throw(uno::RuntimeException, std::exception) throw(uno::RuntimeException, std::exception)
{ {
return uno::Sequence<uno::Reference<sheet::XConditionalFormat> >(); SolarMutexGuard aGuard;
ScConditionalFormatList* pFormatList = getCoreObject();;
size_t n = pFormatList->size();
uno::Sequence<uno::Reference<sheet::XConditionalFormat> > aCondFormats(n);
sal_Int32 i = 0;
for (ScConditionalFormatList::const_iterator itr = pFormatList->begin(); itr != pFormatList->end(); ++itr, ++i) {
uno::Reference<sheet::XConditionalFormat> xCondFormat(new ScCondFormatObj(mpDocShell, this, itr->GetKey()));
aCondFormats[i] = xCondFormat;
}
return aCondFormats;
} }
sal_Int32 ScCondFormatsObj::getLength() sal_Int32 ScCondFormatsObj::getLength()
...@@ -258,9 +268,12 @@ ScConditionalFormatList* ScCondFormatsObj::getCoreObject() ...@@ -258,9 +268,12 @@ ScConditionalFormatList* ScCondFormatsObj::getCoreObject()
return pList; return pList;
} }
ScCondFormatObj::ScCondFormatObj(ScDocument* /*pDoc*/, ScConditionalFormat* pFormat): ScCondFormatObj::ScCondFormatObj(ScDocShell* pDocShell, rtl::Reference<ScCondFormatsObj> xCondFormats,
mpFormat(pFormat), sal_Int32 nKey):
maPropSet(getCondFormatPropset()) mxCondFormatList(xCondFormats),
mpDocShell(pDocShell),
maPropSet(getCondFormatPropset()),
mnKey(nKey)
{ {
} }
...@@ -268,6 +281,16 @@ ScCondFormatObj::~ScCondFormatObj() ...@@ -268,6 +281,16 @@ ScCondFormatObj::~ScCondFormatObj()
{ {
} }
ScConditionalFormat* ScCondFormatObj::getCoreObject()
{
ScConditionalFormatList* pList = mxCondFormatList->getCoreObject();
ScConditionalFormat* pFormat = pList->GetFormat(mnKey);
if (!pFormat)
throw uno::RuntimeException();
return pFormat;
}
void ScCondFormatObj::addEntry(const uno::Reference<sheet::XConditionEntry>& /*xEntry*/) void ScCondFormatObj::addEntry(const uno::Reference<sheet::XConditionEntry>& /*xEntry*/)
throw(uno::RuntimeException, std::exception) throw(uno::RuntimeException, std::exception)
{ {
...@@ -278,6 +301,36 @@ void ScCondFormatObj::removeByIndex(const sal_Int32 /*nIndex*/) ...@@ -278,6 +301,36 @@ void ScCondFormatObj::removeByIndex(const sal_Int32 /*nIndex*/)
{ {
} }
uno::Type ScCondFormatObj::getElementType()
throw(uno::RuntimeException, std::exception)
{
return cppu::UnoType<sheet::XConditionEntry>::get();
}
sal_Bool ScCondFormatObj::hasElements()
throw(uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
ScConditionalFormat* pFormat = getCoreObject();
return !pFormat->IsEmpty();
}
sal_Int32 ScCondFormatObj::getCount()
throw(uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
ScConditionalFormat* pFormat = getCoreObject();
return pFormat->size();
}
uno::Any ScCondFormatObj::getByIndex(sal_Int32 /*nIndex*/)
throw(uno::RuntimeException, std::exception)
{
uno::Any aAny;
return aAny;
}
uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCondFormatObj::getPropertySetInfo() uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCondFormatObj::getPropertySetInfo()
throw(uno::RuntimeException, std::exception) throw(uno::RuntimeException, std::exception)
{ {
...@@ -327,14 +380,13 @@ uno::Any SAL_CALL ScCondFormatObj::getPropertyValue( const OUString& aPropertyNa ...@@ -327,14 +380,13 @@ uno::Any SAL_CALL ScCondFormatObj::getPropertyValue( const OUString& aPropertyNa
switch(pEntry->nWID) switch(pEntry->nWID)
{ {
case ID: case ID:
aAny <<= sal_Int32(mpFormat->GetKey()); aAny <<= sal_Int32(getCoreObject()->GetKey());
break; break;
case CondFormat_Range: case CondFormat_Range:
{ {
const ScRangeList& rRange = mpFormat->GetRange(); const ScRangeList& rRange = getCoreObject()->GetRange();
ScDocShell* pShell = static_cast<ScDocShell*>(mpFormat->GetDocument()->GetDocumentShell());
uno::Reference<sheet::XSheetCellRanges> xRange; uno::Reference<sheet::XSheetCellRanges> xRange;
xRange.set(new ScCellRangesObj(pShell, rRange)); xRange.set(new ScCellRangesObj(mpDocShell, rRange));
} }
break; break;
default: default:
......
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