summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2015-03-16 22:50:18 +0100
committerJan Holesovsky <kendy@collabora.com>2015-04-09 11:39:21 +0200
commit4dfeb9be5c7f4e26c6668d7b639d475a29624717 (patch)
treeda080759ec8aa1d757dbef6ec1e6973039527066
parentadd test for conditional format list size (diff)
downloadcore-4dfeb9be5c7f4e26c6668d7b639d475a29624717.tar.gz
core-4dfeb9be5c7f4e26c6668d7b639d475a29624717.zip
integrate ScConditionalFormat UNO object correctly
Change-Id: I8da8d954dc7bcdf0a8c2f78eeb6b2403eb75d9e3
-rw-r--r--sc/source/ui/inc/condformatuno.hxx36
-rw-r--r--sc/source/ui/unoobj/condformatuno.cxx68
2 files changed, 90 insertions, 14 deletions
diff --git a/sc/source/ui/inc/condformatuno.hxx b/sc/source/ui/inc/condformatuno.hxx
index 254640375983..ec9218cdf46b 100644
--- a/sc/source/ui/inc/condformatuno.hxx
+++ b/sc/source/ui/inc/condformatuno.hxx
@@ -21,8 +21,10 @@
#include <com/sun/star/sheet/XIconSetEntry.hpp>
#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase2.hxx>
#include <svl/itemprop.hxx>
#include <svl/lstner.hxx>
+#include <rtl/ref.hxx>
class ScDocument;
class ScDocShell;
@@ -75,18 +77,18 @@ public:
throw(::com::sun::star::uno::RuntimeException,
std::exception) SAL_OVERRIDE;
-private:
ScConditionalFormatList* getCoreObject();
+
+private:
SCTAB mnTab;
ScDocShell* mpDocShell;
};
-class ScCondFormatObj : public com::sun::star::sheet::XConditionalFormat,
- public com::sun::star::beans::XPropertySet,
- public cppu::OWeakObject
+class ScCondFormatObj : public cppu::WeakImplHelper2<com::sun::star::sheet::XConditionalFormat,
+ com::sun::star::beans::XPropertySet>
{
public:
- ScCondFormatObj(ScDocument* pDoc, ScConditionalFormat* pList);
+ ScCondFormatObj(ScDocShell* pDocShell, rtl::Reference<ScCondFormatsObj> xCondFormats, sal_Int32 nKey);
virtual ~ScCondFormatObj();
@@ -101,6 +103,24 @@ public:
throw(::com::sun::star::uno::RuntimeException,
std::exception) SAL_OVERRIDE;
+ // XIndexAccess
+
+ virtual SAL_CALL uno::Type getElementType()
+ throw(::com::sun::star::uno::RuntimeException,
+ std::exception) SAL_OVERRIDE;
+
+ virtual SAL_CALL sal_Bool hasElements()
+ throw(::com::sun::star::uno::RuntimeException,
+ std::exception) SAL_OVERRIDE;
+
+ virtual SAL_CALL sal_Int32 getCount()
+ throw(::com::sun::star::uno::RuntimeException,
+ std::exception) SAL_OVERRIDE;
+
+ virtual SAL_CALL uno::Any getByIndex(sal_Int32 nIndex)
+ 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()
@@ -142,9 +162,13 @@ public:
::com::sun::star::lang::WrappedTargetException,
::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ ScConditionalFormat* getCoreObject();
+
private:
- ScConditionalFormat* mpFormat;
+ rtl::Reference<ScCondFormatsObj> mxCondFormatList;
+ ScDocShell* mpDocShell;
SfxItemPropertySet maPropSet;
+ sal_Int32 mnKey;
};
class ScConditionEntryObj : public com::sun::star::beans::XPropertySet,
diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx
index faa108c4c649..8ceee90db1b0 100644
--- a/sc/source/ui/unoobj/condformatuno.cxx
+++ b/sc/source/ui/unoobj/condformatuno.cxx
@@ -235,7 +235,17 @@ void ScCondFormatsObj::removeByID(const sal_Int32 nID)
uno::Sequence<uno::Reference<sheet::XConditionalFormat> > ScCondFormatsObj::getConditionalFormats()
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()
@@ -258,9 +268,12 @@ ScConditionalFormatList* ScCondFormatsObj::getCoreObject()
return pList;
}
-ScCondFormatObj::ScCondFormatObj(ScDocument* /*pDoc*/, ScConditionalFormat* pFormat):
- mpFormat(pFormat),
- maPropSet(getCondFormatPropset())
+ScCondFormatObj::ScCondFormatObj(ScDocShell* pDocShell, rtl::Reference<ScCondFormatsObj> xCondFormats,
+ sal_Int32 nKey):
+ mxCondFormatList(xCondFormats),
+ mpDocShell(pDocShell),
+ maPropSet(getCondFormatPropset()),
+ mnKey(nKey)
{
}
@@ -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*/)
throw(uno::RuntimeException, std::exception)
{
@@ -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()
throw(uno::RuntimeException, std::exception)
{
@@ -327,14 +380,13 @@ uno::Any SAL_CALL ScCondFormatObj::getPropertyValue( const OUString& aPropertyNa
switch(pEntry->nWID)
{
case ID:
- aAny <<= sal_Int32(mpFormat->GetKey());
+ aAny <<= sal_Int32(getCoreObject()->GetKey());
break;
case CondFormat_Range:
{
- const ScRangeList& rRange = mpFormat->GetRange();
- ScDocShell* pShell = static_cast<ScDocShell*>(mpFormat->GetDocument()->GetDocumentShell());
+ const ScRangeList& rRange = getCoreObject()->GetRange();
uno::Reference<sheet::XSheetCellRanges> xRange;
- xRange.set(new ScCellRangesObj(pShell, rRange));
+ xRange.set(new ScCellRangesObj(mpDocShell, rRange));
}
break;
default: