Tag: cws_src680_custommeta
User: mst     
Date: 2008-02-04 15:26:48+0000
Modified:
   dba/dbaccess/source/core/misc/propertybag.cxx
   dba/dbaccess/source/core/misc/propertybag.hxx

Log:
 - dbaccess/source/core/misc/propertybag.{hxx,cxx}:
   + OPropertyBag implements interface XModifyBroadcaster
   + OPropertyBag implements IEventNotificationHook

File Changes:

Directory: /dba/dbaccess/source/core/misc/
==========================================

File [changed]: propertybag.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/misc/propertybag.cxx?r1=1.8&r2=1.8.4.1
Delta lines:  +75 -4
--------------------
--- propertybag.cxx     2008-01-30 08:36:43+0000        1.8
+++ propertybag.cxx     2008-02-04 15:26:45+0000        1.8.4.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: propertybag.cxx,v $
  *
- *  $Revision: 1.8 $
+ *  $Revision: 1.8.4.1 $
  *
- *  last change: $Author: rt $ $Date: 2008/01/30 08:36:43 $
+ *  last change: $Author: mst $ $Date: 2008/02/04 15:26:45 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -66,15 +66,20 @@
     using namespace ::com::sun::star::uno;
     using namespace ::com::sun::star::lang;
     using namespace ::com::sun::star::beans;
+    using namespace ::com::sun::star::util;
 
        //====================================================================
        //= OPropertyBag
        //====================================================================
     //--------------------------------------------------------------------
     OPropertyBag::OPropertyBag( const Reference< XComponentContext >& 
_rxContext )
-        :OPropertyBag_PBase( GetBroadcastHelper() )
+        :OPropertyBag_PBase( GetBroadcastHelper(), this )
+        ,::cppu::IEventNotificationHook()
         ,m_aContext( _rxContext )
         ,m_bAutoAddProperties( false )
+        ,m_NotifyListeners(m_aMutex)
+        ,m_isModified(false)
+
     {
     }
 
@@ -145,6 +150,68 @@
     }
 
     //--------------------------------------------------------------------
+    void OPropertyBag::fireEvents(
+            sal_Int32 * /*pnHandles*/,
+            sal_Int32 nCount,
+            sal_Bool bVetoable,
+            bool bIgnoreRuntimeExceptionsWhileFiring)
+    {
+        if (nCount && !bVetoable) {
+            setModifiedImpl(sal_True, bIgnoreRuntimeExceptionsWhileFiring);
+        }
+    }
+
+    void OPropertyBag::setModifiedImpl(::sal_Bool bModified,
+            bool bIgnoreRuntimeExceptionsWhileFiring)
+    {
+        ::osl::MutexGuard aGuard( m_aMutex );
+        m_isModified = bModified;
+        if (bModified) {
+            try {
+                Reference<XInterface> xThis(*this);
+                EventObject event(xThis);
+                m_NotifyListeners.notifyEach(
+                    &XModifyListener::modified, event);
+            } catch (RuntimeException &) {
+                if (!bIgnoreRuntimeExceptionsWhileFiring) {
+                    throw;
+                }
+            } catch (Exception & e) {
+                // ignore
+                DBG_UNHANDLED_EXCEPTION();
+            }
+        }
+    }
+
+    //--------------------------------------------------------------------
+    ::sal_Bool SAL_CALL OPropertyBag::isModified()
+        throw (RuntimeException)
+    {
+        ::osl::MutexGuard aGuard( m_aMutex );
+        return m_isModified;
+    }
+
+    void SAL_CALL OPropertyBag::setModified( ::sal_Bool bModified )
+        throw (PropertyVetoException, RuntimeException)
+    {
+        setModifiedImpl(bModified, false);
+    }
+
+    void SAL_CALL OPropertyBag::addModifyListener(
+        const Reference< XModifyListener > & xListener)
+        throw (RuntimeException)
+    {
+        m_NotifyListeners.addInterface(xListener);
+    }
+
+    void SAL_CALL OPropertyBag::removeModifyListener(
+        const Reference< XModifyListener > & xListener)
+        throw (RuntimeException)
+    {
+        m_NotifyListeners.removeInterface(xListener);
+    }
+
+    //--------------------------------------------------------------------
     Reference< XPropertySetInfo > SAL_CALL OPropertyBag::getPropertySetInfo(  
) throw(RuntimeException)
     {
         return createPropertySetInfo( getInfoHelper() );
@@ -221,6 +288,8 @@
 
         // our property info is dirty
         m_pArrayHelper.reset();
+
+        setModified(sal_True);
     }
 
     //--------------------------------------------------------------------
@@ -232,6 +301,8 @@
 
         // our property info is dirty
         m_pArrayHelper.reset();
+
+        setModified(sal_True);
     }
 
     //--------------------------------------------------------------------

File [changed]: propertybag.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/misc/propertybag.hxx?r1=1.6&r2=1.6.4.1
Delta lines:  +40 -5
--------------------
--- propertybag.hxx     2008-01-30 08:36:56+0000        1.6
+++ propertybag.hxx     2008-02-04 15:26:45+0000        1.6.4.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: propertybag.hxx,v $
  *
- *  $Revision: 1.6 $
+ *  $Revision: 1.6.4.1 $
  *
- *  last change: $Author: rt $ $Date: 2008/01/30 08:36:56 $
+ *  last change: $Author: mst $ $Date: 2008/02/04 15:26:45 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -40,13 +40,14 @@
 #include <com/sun/star/lang/XInitialization.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/util/XModifyBroadcaster.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/beans/XPropertyContainer.hpp>
 #include <com/sun/star/beans/XPropertyAccess.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
 /** === end UNO includes === **/
 
-#include <cppuhelper/implbase4.hxx>
+#include <cppuhelper/implbase5.hxx>
 #include <comphelper/propstate.hxx>
 #include <comphelper/broadcasthelper.hxx>
 #include <comphelper/propertybag.hxx>
@@ -82,8 +83,9 @@
     //====================================================================
        //= OPropertyBag
        //====================================================================
-    typedef ::cppu::WeakAggImplHelper4  <   
::com::sun::star::beans::XPropertyContainer
+    typedef ::cppu::WeakAggImplHelper5  <   
::com::sun::star::beans::XPropertyContainer
                                         ,   
::com::sun::star::beans::XPropertyAccess
+                                        ,   
::com::sun::star::util::XModifyBroadcaster
                                         ,   
::com::sun::star::lang::XServiceInfo
                                         ,   
::com::sun::star::lang::XInitialization
                                         >   OPropertyBag_Base;
@@ -92,6 +94,7 @@
     class OPropertyBag  :public ::comphelper::OMutexAndBroadcastHelper  // 
must be before OPropertyBag_PBase
                         ,public OPropertyBag_PBase
                         ,public OPropertyBag_Base
+                        ,public ::cppu::IEventNotificationHook
        {
     private:
         ::comphelper::ComponentContext
@@ -107,6 +110,11 @@
         /// should we automatically add properties which are tried to set, if 
they don't exist previously?
         bool            m_bAutoAddProperties;
 
+        /// for notification
+        ::cppu::OInterfaceContainerHelper m_NotifyListeners;
+        /// modify flag
+        bool            m_isModified;
+
     public:
         OPropertyBag( const ::com::sun::star::uno::Reference< 
::com::sun::star::uno::XComponentContext >& _rxContext );
 
@@ -130,6 +138,23 @@
         virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& 
ServiceName ) throw (::com::sun::star::uno::RuntimeException);
         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL 
getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);
 
+        // XModifiable:
+        virtual ::sal_Bool SAL_CALL isModified(  )
+            throw (::com::sun::star::uno::RuntimeException);
+        virtual void SAL_CALL setModified( ::sal_Bool bModified )
+            throw (::com::sun::star::beans::PropertyVetoException,
+                    ::com::sun::star::uno::RuntimeException);
+
+        // XModifyBroadcaster
+        virtual void SAL_CALL addModifyListener(
+            const ::com::sun::star::uno::Reference<
+                    ::com::sun::star::util::XModifyListener > & xListener)
+            throw (::com::sun::star::uno::RuntimeException);
+        virtual void SAL_CALL removeModifyListener(
+            const ::com::sun::star::uno::Reference<
+                    ::com::sun::star::util::XModifyListener > & xListener)
+            throw (::com::sun::star::uno::RuntimeException);
+
         // XPropertyContainer
         virtual void SAL_CALL addProperty( const ::rtl::OUString& Name, 
::sal_Int16 Attributes, const ::com::sun::star::uno::Any& DefaultValue ) throw 
(::com::sun::star::beans::PropertyExistException, 
::com::sun::star::beans::IllegalTypeException, 
::com::sun::star::lang::IllegalArgumentException, 
::com::sun::star::uno::RuntimeException);
         virtual void SAL_CALL removeProperty( const ::rtl::OUString& Name ) 
throw (::com::sun::star::beans::UnknownPropertyException, 
::com::sun::star::beans::NotRemoveableException, 
::com::sun::star::uno::RuntimeException);
@@ -154,6 +179,16 @@
         virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 
nHandle, const ::com::sun::star::uno::Any& rValue ) throw 
(::com::sun::star::uno::Exception);
         virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
 
+        // IEventNotificationHook
+        virtual void fireEvents(
+            sal_Int32 * pnHandles,
+            sal_Int32 nCount,
+            sal_Bool bVetoable,
+            bool bIgnoreRuntimeExceptionsWhileFiring);
+
+        void SAL_CALL setModifiedImpl( ::sal_Bool bModified,
+            bool bIgnoreRuntimeExceptionsWhileFiring);
+
     private:
         /** finds a free property handle
             @precond




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to