summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorSascha Ballach <sab@openoffice.org>2002-09-26 07:52:20 +0000
committerSascha Ballach <sab@openoffice.org>2002-09-26 07:52:20 +0000
commitf34ad1954a71b239ab54a901407318d26e444da7 (patch)
tree87f0bcda14ab5f8cccc15a81e12f91a4a35183d4 /sc
parent7d2c0508e6aef92dda5a1a44d07926c0ea7a012e (diff)
#103377#,#103378#; add support of XRefreshable
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/fielduno.hxx50
-rw-r--r--sc/source/ui/unoobj/fielduno.cxx164
2 files changed, 203 insertions, 11 deletions
diff --git a/sc/inc/fielduno.hxx b/sc/inc/fielduno.hxx
index fda3f49bfdbd..c47567a89a04 100644
--- a/sc/inc/fielduno.hxx
+++ b/sc/inc/fielduno.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: fielduno.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: hr $ $Date: 2001-10-23 11:14:49 $
+ * last change: $Author: sab $ $Date: 2002-09-26 08:52:02 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -100,14 +100,19 @@
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
#include <com/sun/star/beans/XPropertySet.hpp>
#endif
+#ifndef _COM_SUN_STAR_UTIL_XREFRESHABLE_HPP_
+#include <com/sun/star/util/XRefreshable.hpp>
+#endif
#ifndef _CPPUHELPER_COMPONENT_HXX_
#include <cppuhelper/component.hxx>
#endif
-#ifndef _CPPUHELPER_IMPLBASE4_HXX_
-#include <cppuhelper/implbase4.hxx>
+#ifndef _CPPUHELPER_IMPLBASE5_HXX_
+#include <cppuhelper/implbase5.hxx>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
#endif
-
class SvxEditSource;
class SvxFieldItem;
@@ -119,10 +124,11 @@ class ScHeaderFooterContentObj;
//------------------------------------------------------------------
-class ScCellFieldsObj : public cppu::WeakImplHelper4<
+class ScCellFieldsObj : public cppu::WeakImplHelper5<
com::sun::star::container::XEnumerationAccess,
com::sun::star::container::XIndexAccess,
com::sun::star::container::XContainer,
+ com::sun::star::util::XRefreshable,
com::sun::star::lang::XServiceInfo >,
public SfxListener
{
@@ -130,6 +136,10 @@ private:
ScDocShell* pDocShell;
ScAddress aCellPos;
SvxEditSource* pEditSource;
+ /// List of refresh listeners.
+ cppu::OInterfaceContainerHelper* mpRefreshListeners;
+ /// mutex to lock the InterfaceContainerHelper
+ osl::Mutex aMutex;
ScCellFieldObj* GetObjectByIndex_Impl(INT32 Index) const;
@@ -163,6 +173,16 @@ public:
::com::sun::star::container::XContainerListener >& xListener )
throw(::com::sun::star::uno::RuntimeException);
+ // XRefreshable
+ virtual void SAL_CALL refresh( )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addRefreshListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::util::XRefreshListener >& l )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeRefreshListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::util::XRefreshListener >& l )
+ throw (::com::sun::star::uno::RuntimeException);
+
// XServiceInfo
virtual ::rtl::OUString SAL_CALL getImplementationName()
throw(::com::sun::star::uno::RuntimeException);
@@ -304,10 +324,11 @@ public:
//------------------------------------------------------------------
-class ScHeaderFieldsObj : public cppu::WeakImplHelper4<
+class ScHeaderFieldsObj : public cppu::WeakImplHelper5<
com::sun::star::container::XEnumerationAccess,
com::sun::star::container::XIndexAccess,
com::sun::star::container::XContainer,
+ com::sun::star::util::XRefreshable,
com::sun::star::lang::XServiceInfo >
{
private:
@@ -316,6 +337,11 @@ private:
UINT16 nType;
SvxEditSource* pEditSource;
+ /// List of refresh listeners.
+ cppu::OInterfaceContainerHelper* mpRefreshListeners;
+ /// mutex to lock the InterfaceContainerHelper
+ osl::Mutex aMutex;
+
ScHeaderFieldObj* GetObjectByIndex_Impl(INT32 Index) const;
public:
@@ -347,6 +373,16 @@ public:
::com::sun::star::container::XContainerListener >& xListener )
throw(::com::sun::star::uno::RuntimeException);
+ // XRefreshable
+ virtual void SAL_CALL refresh( )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addRefreshListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::util::XRefreshListener >& l )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeRefreshListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::util::XRefreshListener >& l )
+ throw (::com::sun::star::uno::RuntimeException);
+
// XServiceInfo
virtual ::rtl::OUString SAL_CALL getImplementationName()
throw(::com::sun::star::uno::RuntimeException);
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index adf83d77c0fa..ac37a032e995 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: fielduno.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: sab $ $Date: 2002-09-11 09:52:12 $
+ * last change: $Author: sab $ $Date: 2002-09-26 08:52:20 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -278,7 +278,8 @@ SvxFieldData* ScUnoEditEngine::FindByPos(USHORT nPar, xub_StrLen nPos, TypeId aT
ScCellFieldsObj::ScCellFieldsObj(ScDocShell* pDocSh, const ScAddress& rPos) :
pDocShell( pDocSh ),
- aCellPos( rPos )
+ aCellPos( rPos ),
+ mpRefreshListeners( NULL )
{
pDocShell->GetDocument()->AddUnoObject(*this);
@@ -291,6 +292,20 @@ ScCellFieldsObj::~ScCellFieldsObj()
pDocShell->GetDocument()->RemoveUnoObject(*this);
delete pEditSource;
+
+ // increment refcount to prevent double call off dtor
+ osl_incrementInterlockedCount( &m_refCount );
+
+ if (mpRefreshListeners)
+ {
+ lang::EventObject aEvent;
+ aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+ if (mpRefreshListeners)
+ {
+ mpRefreshListeners->disposeAndClear(aEvent);
+ DELETEZ( mpRefreshListeners );
+ }
+ }
}
void ScCellFieldsObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
@@ -386,6 +401,69 @@ void SAL_CALL ScCellFieldsObj::removeContainerListener(
DBG_ERROR("not implemented");
}
+// XRefreshable
+void SAL_CALL ScCellFieldsObj::refresh( )
+ throw (uno::RuntimeException)
+{
+ if (mpRefreshListeners)
+ {
+ // Call all listeners.
+ uno::Sequence< uno::Reference< uno::XInterface > > aListeners = mpRefreshListeners->getElements();
+ sal_uInt32 nLength(aListeners.getLength());
+ if (nLength)
+ {
+ const uno::Reference< uno::XInterface >* pInterfaces = aListeners.getConstArray();
+ if (pInterfaces)
+ {
+ lang::EventObject aEvent;
+ aEvent.Source = uno::Reference< util::XRefreshable >(const_cast<ScCellFieldsObj*>(this));
+ sal_uInt32 i(0);
+ while (i < nLength)
+ {
+ try
+ {
+ while(i < nLength)
+ {
+ static_cast< util::XRefreshListener* >(pInterfaces->get())->refreshed(aEvent);
+ ++pInterfaces;
+ ++i;
+ }
+ }
+ catch(uno::RuntimeException&)
+ {
+// DBG_ERROR("a object is gone without to remove from Broadcaster");
+ ++pInterfaces;
+ ++i;
+ }
+ }
+ }
+ }
+ }
+}
+
+void SAL_CALL ScCellFieldsObj::addRefreshListener( const uno::Reference< util::XRefreshListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ if (xListener.is())
+ {
+ ScUnoGuard aGuard;
+ if (!mpRefreshListeners)
+ mpRefreshListeners = new cppu::OInterfaceContainerHelper(aMutex);
+ mpRefreshListeners->addInterface(xListener);
+ }
+}
+
+void SAL_CALL ScCellFieldsObj::removeRefreshListener( const uno::Reference<util::XRefreshListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ if (xListener.is())
+ {
+ ScUnoGuard aGuard;
+ if (mpRefreshListeners)
+ mpRefreshListeners->removeInterface(xListener);
+ }
+}
+
//------------------------------------------------------------------------
// Default-ctor wird fuer SMART_REFLECTION_IMPLEMENTATION gebraucht
@@ -832,7 +910,8 @@ uno::Sequence<rtl::OUString> SAL_CALL ScCellFieldObj::getSupportedServiceNames()
ScHeaderFieldsObj::ScHeaderFieldsObj(ScHeaderFooterContentObj* pContent, USHORT nP, USHORT nT) :
pContentObj( pContent ),
nPart( nP ),
- nType( nT )
+ nType( nT ),
+ mpRefreshListeners( NULL )
{
DBG_ASSERT( pContentObj, "ScHeaderFieldsObj ohne Objekt?" );
@@ -851,6 +930,20 @@ ScHeaderFieldsObj::~ScHeaderFieldsObj()
if (pContentObj)
pContentObj->release();
+
+ // increment refcount to prevent double call off dtor
+ osl_incrementInterlockedCount( &m_refCount );
+
+ if (mpRefreshListeners)
+ {
+ lang::EventObject aEvent;
+ aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+ if (mpRefreshListeners)
+ {
+ mpRefreshListeners->disposeAndClear(aEvent);
+ DELETEZ( mpRefreshListeners );
+ }
+ }
}
// XIndexAccess (via XTextFields)
@@ -966,6 +1059,69 @@ void SAL_CALL ScHeaderFieldsObj::removeContainerListener(
DBG_ERROR("not implemented");
}
+// XRefreshable
+void SAL_CALL ScHeaderFieldsObj::refresh( )
+ throw (uno::RuntimeException)
+{
+ if (mpRefreshListeners)
+ {
+ // Call all listeners.
+ uno::Sequence< uno::Reference< uno::XInterface > > aListeners = mpRefreshListeners->getElements();
+ sal_uInt32 nLength(aListeners.getLength());
+ if (nLength)
+ {
+ const uno::Reference< uno::XInterface >* pInterfaces = aListeners.getConstArray();
+ if (pInterfaces)
+ {
+ lang::EventObject aEvent;
+ aEvent.Source = uno::Reference< util::XRefreshable >(const_cast<ScHeaderFieldsObj*>(this));
+ sal_uInt32 i(0);
+ while (i < nLength)
+ {
+ try
+ {
+ while(i < nLength)
+ {
+ static_cast< util::XRefreshListener* >(pInterfaces->get())->refreshed(aEvent);
+ ++pInterfaces;
+ ++i;
+ }
+ }
+ catch(uno::RuntimeException&)
+ {
+// DBG_ERROR("a object is gone without to remove from Broadcaster");
+ ++pInterfaces;
+ ++i;
+ }
+ }
+ }
+ }
+ }
+}
+
+void SAL_CALL ScHeaderFieldsObj::addRefreshListener( const uno::Reference< util::XRefreshListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ if (xListener.is())
+ {
+ ScUnoGuard aGuard;
+ if (!mpRefreshListeners)
+ mpRefreshListeners = new cppu::OInterfaceContainerHelper(aMutex);
+ mpRefreshListeners->addInterface(xListener);
+ }
+}
+
+void SAL_CALL ScHeaderFieldsObj::removeRefreshListener( const uno::Reference<util::XRefreshListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ if (xListener.is())
+ {
+ ScUnoGuard aGuard;
+ if (mpRefreshListeners)
+ mpRefreshListeners->removeInterface(xListener);
+ }
+}
+
//------------------------------------------------------------------------
SvxFileFormat lcl_UnoToSvxFileFormat( sal_Int16 nUnoValue )