Hi Now we have replaced tools/list with std::list in ScAddInListener, here we used a list, as there is adding, removing, and searching on this list, and no clear way to sort the elements. The patch comes in three files: 0001 Replacing deprecated data types from solar.h 0002 Cleaning up the spacings 0003 Replacing tools/list with std::list and a non-related 4th file: 0004 Removing unnecessary include of tools/string in funcdesc.hxx
The patches compile fine, but we couldn't really test them in the running scalc, as it was impossible for us, to get scalc to use the ScAddInListener (although it seems to be used in the unit tests without failing). Best Regards Sören Möller
From f1fe93b0b5a2edd1e6da8b1629c5d16651e6bb02 Mon Sep 17 00:00:00 2001 From: Thies Pierdola <thiespierd...@gmail.com> Date: Sat, 29 Jan 2011 17:39:34 +0100 Subject: [PATCH] Replaced deprecated types with sal types --- sc/source/core/inc/addinlis.hxx | 2 +- sc/source/core/tool/addinlis.cxx | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sc/source/core/inc/addinlis.hxx b/sc/source/core/inc/addinlis.hxx index d3cb130..9c8b471 100644 --- a/sc/source/core/inc/addinlis.hxx +++ b/sc/source/core/inc/addinlis.hxx @@ -72,7 +72,7 @@ public: com::sun::star::sheet::XVolatileResult> xVR ); static void RemoveDocument( ScDocument* pDocument ); - BOOL HasDocument( ScDocument* pDoc ) const { return pDocs->Seek_Entry( pDoc ); } + bool HasDocument( ScDocument* pDoc ) const { return pDocs->Seek_Entry( pDoc ); } void AddDocument( ScDocument* pDoc ) { pDocs->Insert( pDoc ); } const com::sun::star::uno::Any& GetResult() const { return aResult; } diff --git a/sc/source/core/tool/addinlis.cxx b/sc/source/core/tool/addinlis.cxx index 71b3d72..81fdd80 100644 --- a/sc/source/core/tool/addinlis.cxx +++ b/sc/source/core/tool/addinlis.cxx @@ -84,8 +84,8 @@ ScAddInListener* ScAddInListener::Get( uno::Reference<sheet::XVolatileResult> xV { sheet::XVolatileResult* pComp = xVR.get(); - ULONG nCount = aAllListeners.Count(); - for (ULONG nPos=0; nPos<nCount; nPos++) + sal_uInt32 nCount = aAllListeners.Count(); + for (sal_uInt32 nPos=0; nPos<nCount; nPos++) { ScAddInListener* pLst = (ScAddInListener*)aAllListeners.GetObject(nPos); if ( pComp == (sheet::XVolatileResult*)pLst->xVolRes.get() ) @@ -97,14 +97,14 @@ ScAddInListener* ScAddInListener::Get( uno::Reference<sheet::XVolatileResult> xV //! move to some container object? void ScAddInListener::RemoveDocument( ScDocument* pDocumentP ) { - ULONG nPos = aAllListeners.Count(); + sal_uInt32 nPos = aAllListeners.Count(); while (nPos) { // loop backwards because elements are removed --nPos; ScAddInListener* pLst = (ScAddInListener*)aAllListeners.GetObject(nPos); ScAddInDocs* p = pLst->pDocs; - USHORT nFoundPos; + sal_uInt16 nFoundPos; if ( p->Seek_Entry( pDocumentP, &nFoundPos ) ) { p->Remove( nFoundPos ); @@ -140,8 +140,8 @@ void SAL_CALL ScAddInListener::modified( const ::com::sun::star::sheet::ResultEv Broadcast( ScHint( SC_HINT_DATACHANGED, ScAddress(), NULL ) ); const ScDocument** ppDoc = (const ScDocument**) pDocs->GetData(); - USHORT nCount = pDocs->Count(); - for ( USHORT j=0; j<nCount; j++, ppDoc++ ) + sal_uInt16 nCount = pDocs->Count(); + for ( sal_uInt16 j=0; j<nCount; j++, ppDoc++ ) { ScDocument* pDoc = (ScDocument*)*ppDoc; pDoc->TrackFormulas(); -- 1.7.0.4
From 8876c079f754211c2ba5ab8fa959c1d3056eceff Mon Sep 17 00:00:00 2001 From: Thies Pierdola <thiespierd...@gmail.com> Date: Sat, 29 Jan 2011 16:17:15 +0100 Subject: [PATCH 2/3] Cleaned up spacings --- sc/source/core/inc/addinlis.hxx | 70 +++++++++++++++++++------------------- sc/source/core/tool/addinlis.cxx | 42 +++++++---------------- 2 files changed, 48 insertions(+), 64 deletions(-) diff --git a/sc/source/core/inc/addinlis.hxx b/sc/source/core/inc/addinlis.hxx index 9c8b471..ace8d49 100644 --- a/sc/source/core/inc/addinlis.hxx +++ b/sc/source/core/inc/addinlis.hxx @@ -29,18 +29,15 @@ #ifndef SC_ADDINLIS_HXX #define SC_ADDINLIS_HXX -#include "adiasync.hxx" // for ScAddInDocs PtrArr +#include "adiasync.hxx" // for ScAddInDocs PtrArr #include <tools/list.hxx> #include <com/sun/star/sheet/XResultListener.hpp> #include <com/sun/star/sheet/XVolatileResult.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <cppuhelper/implbase2.hxx> - - class ScDocument; - class ScAddInListener : public cppu::WeakImplHelper2< com::sun::star::sheet::XResultListener, com::sun::star::lang::XServiceInfo >, @@ -48,53 +45,56 @@ class ScAddInListener : public cppu::WeakImplHelper2< { private: com::sun::star::uno::Reference<com::sun::star::sheet::XVolatileResult> xVolRes; - com::sun::star::uno::Any aResult; - ScAddInDocs* pDocs; // documents where this is used + com::sun::star::uno::Any aResult; + ScAddInDocs* pDocs; // documents where this is used - static List aAllListeners; + static List aAllListeners; - // always allocated via CreateListener - ScAddInListener( - com::sun::star::uno::Reference< - com::sun::star::sheet::XVolatileResult> xVR, - ScDocument* pD ); + // always allocated via CreateListener + ScAddInListener( com::sun::star::uno::Reference<com::sun::star::sheet::XVolatileResult> xVR, + ScDocument* pD ); public: - virtual ~ScAddInListener(); + virtual ~ScAddInListener(); - // create Listener and put it into global list - static ScAddInListener* CreateListener( - com::sun::star::uno::Reference< - com::sun::star::sheet::XVolatileResult> xVR, + // create Listener and put it into global list + static ScAddInListener* CreateListener( + com::sun::star::uno::Reference<com::sun::star::sheet::XVolatileResult> xVR, ScDocument* pDoc ); - static ScAddInListener* Get( com::sun::star::uno::Reference< + static ScAddInListener*Get( com::sun::star::uno::Reference< com::sun::star::sheet::XVolatileResult> xVR ); - static void RemoveDocument( ScDocument* pDocument ); - bool HasDocument( ScDocument* pDoc ) const { return pDocs->Seek_Entry( pDoc ); } - void AddDocument( ScDocument* pDoc ) { pDocs->Insert( pDoc ); } - const com::sun::star::uno::Any& GetResult() const { return aResult; } + static void RemoveDocument( ScDocument* pDocument ); + bool HasDocument( ScDocument* pDoc ) const + { return pDocs->Seek_Entry( pDoc ); } - // XResultListener - virtual void SAL_CALL modified( const ::com::sun::star::sheet::ResultEvent& aEvent ) - throw(::com::sun::star::uno::RuntimeException); + void AddDocument( ScDocument* pDoc ) + { pDocs->Insert( pDoc ); } - // XEventListener - virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) - throw(::com::sun::star::uno::RuntimeException); + const com::sun::star::uno::Any& GetResult() const + { return aResult; } + + // XResultListener + virtual void SAL_CALL modified( const ::com::sun::star::sheet::ResultEvent& aEvent ) + throw(::com::sun::star::uno::RuntimeException); + + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) + throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw(::com::sun::star::uno::RuntimeException); - // XServiceInfo - virtual ::rtl::OUString SAL_CALL getImplementationName( ) - throw(::com::sun::star::uno::RuntimeException); 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); + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); }; - -#endif +#endif // SC_ADDINLIS_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/tool/addinlis.cxx b/sc/source/core/tool/addinlis.cxx index 6ef41e3..b138b72 100644 --- a/sc/source/core/tool/addinlis.cxx +++ b/sc/source/core/tool/addinlis.cxx @@ -29,41 +29,32 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" - - #include <tools/debug.hxx> #include <sfx2/objsh.hxx> #include <vcl/svapp.hxx> - #include "addinlis.hxx" -#include "miscuno.hxx" // SC_IMPL_SERVICE_INFO +#include "miscuno.hxx" // SC_IMPL_SERVICE_INFO #include "document.hxx" #include "brdcst.hxx" #include "sc.hrc" using namespace com::sun::star; -//------------------------------------------------------------------------ - SC_SIMPLE_SERVICE_INFO( ScAddInListener, "ScAddInListener", "stardiv.one.sheet.AddInListener" ) -//------------------------------------------------------------------------ - List ScAddInListener::aAllListeners; -//------------------------------------------------------------------------ - ScAddInListener* ScAddInListener::CreateListener( uno::Reference<sheet::XVolatileResult> xVR, ScDocument* pDoc ) { ScAddInListener* pNew = new ScAddInListener( xVR, pDoc ); - pNew->acquire(); // for aAllListeners + pNew->acquire(); // for aAllListeners aAllListeners.Insert( pNew, LIST_APPEND ); - if ( xVR.is() ) - xVR->addResultListener( pNew ); // after at least 1 ref exists! + if ( xVR.is() ) + xVR->addResultListener( pNew ); // after at least 1 ref exists! return pNew; } @@ -91,16 +82,16 @@ ScAddInListener* ScAddInListener::Get( uno::Reference<sheet::XVolatileResult> xV if ( pComp == (sheet::XVolatileResult*)pLst->xVolRes.get() ) return pLst; } - return NULL; // not found + return NULL; // not found } -//! move to some container object? +//! move to some container object? void ScAddInListener::RemoveDocument( ScDocument* pDocumentP ) { sal_uInt32 nPos = aAllListeners.Count(); while (nPos) { - // loop backwards because elements are removed + // loop backwards because elements are removed --nPos; ScAddInListener* pLst = (ScAddInListener*)aAllListeners.GetObject(nPos); ScAddInDocs* p = pLst->pDocs; @@ -111,31 +102,29 @@ void ScAddInListener::RemoveDocument( ScDocument* pDocumentP ) if ( p->Count() == 0 ) { // this AddIn is no longer used - // dont delete, just remove the ref for the list + // dont delete, just remove the ref for the list aAllListeners.Remove( nPos ); - if ( pLst->xVolRes.is() ) + if ( pLst->xVolRes.is() ) pLst->xVolRes->removeResultListener( pLst ); - pLst->release(); // Ref for aAllListeners - pLst may be deleted here + pLst->release(); // Ref for aAllListeners - pLst may be deleted here } } } } -//------------------------------------------------------------------------ - // XResultListener void SAL_CALL ScAddInListener::modified( const ::com::sun::star::sheet::ResultEvent& aEvent ) throw(::com::sun::star::uno::RuntimeException) { - SolarMutexGuard aGuard; //! or generate a UserEvent + SolarMutexGuard aGuard; //! or generate a UserEvent - aResult = aEvent.Value; // store result + aResult = aEvent.Value; // store result - // notify document of changes + // notify document of changes Broadcast( ScHint( SC_HINT_DATACHANGED, ScAddress(), NULL ) ); @@ -165,9 +154,4 @@ void SAL_CALL ScAddInListener::disposing( const ::com::sun::star::lang::EventObj } } - -//------------------------------------------------------------------------ - - - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- 1.7.0.4
From b78d0af059c487c42a65c3ba2004db72521d4d81 Mon Sep 17 00:00:00 2001 From: Thies Pierdola <thiespierd...@gmail.com> Date: Sat, 29 Jan 2011 17:34:52 +0100 Subject: [PATCH 3/3] Replaced use of tools/list by std::list --- sc/source/core/inc/addinlis.hxx | 3 +- sc/source/core/tool/addinlis.cxx | 42 +++++++++++++++++++------------------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/sc/source/core/inc/addinlis.hxx b/sc/source/core/inc/addinlis.hxx index ace8d49..753998a 100644 --- a/sc/source/core/inc/addinlis.hxx +++ b/sc/source/core/inc/addinlis.hxx @@ -30,7 +30,6 @@ #define SC_ADDINLIS_HXX #include "adiasync.hxx" // for ScAddInDocs PtrArr -#include <tools/list.hxx> #include <com/sun/star/sheet/XResultListener.hpp> #include <com/sun/star/sheet/XVolatileResult.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -48,7 +47,7 @@ private: com::sun::star::uno::Any aResult; ScAddInDocs* pDocs; // documents where this is used - static List aAllListeners; + static ::std::list<ScAddInListener*> aAllListeners; // always allocated via CreateListener ScAddInListener( com::sun::star::uno::Reference<com::sun::star::sheet::XVolatileResult> xVR, diff --git a/sc/source/core/tool/addinlis.cxx b/sc/source/core/tool/addinlis.cxx index b138b72..69a8f52 100644 --- a/sc/source/core/tool/addinlis.cxx +++ b/sc/source/core/tool/addinlis.cxx @@ -29,7 +29,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" -#include <tools/debug.hxx> #include <sfx2/objsh.hxx> #include <vcl/svapp.hxx> @@ -43,7 +42,7 @@ using namespace com::sun::star; SC_SIMPLE_SERVICE_INFO( ScAddInListener, "ScAddInListener", "stardiv.one.sheet.AddInListener" ) -List ScAddInListener::aAllListeners; +::std::list<ScAddInListener*> ScAddInListener::aAllListeners; ScAddInListener* ScAddInListener::CreateListener( uno::Reference<sheet::XVolatileResult> xVR, ScDocument* pDoc ) @@ -51,7 +50,7 @@ ScAddInListener* ScAddInListener::CreateListener( ScAddInListener* pNew = new ScAddInListener( xVR, pDoc ); pNew->acquire(); // for aAllListeners - aAllListeners.Insert( pNew, LIST_APPEND ); + aAllListeners.push_back( pNew ); if ( xVR.is() ) xVR->addResultListener( pNew ); // after at least 1 ref exists! @@ -73,45 +72,46 @@ ScAddInListener::~ScAddInListener() ScAddInListener* ScAddInListener::Get( uno::Reference<sheet::XVolatileResult> xVR ) { + ScAddInListener* pLst = NULL; sheet::XVolatileResult* pComp = xVR.get(); - sal_uInt32 nCount = aAllListeners.Count(); - for (sal_uInt32 nPos=0; nPos<nCount; nPos++) + for(::std::list<ScAddInListener*>::iterator iter = aAllListeners.begin(); iter != aAllListeners.end(); ++iter) { - ScAddInListener* pLst = (ScAddInListener*)aAllListeners.GetObject(nPos); - if ( pComp == (sheet::XVolatileResult*)pLst->xVolRes.get() ) - return pLst; + if ( pComp == (sheet::XVolatileResult*)(*iter)->xVolRes.get() ) + { + pLst = *iter; + break; + } } - return NULL; // not found + return pLst; } //! move to some container object? void ScAddInListener::RemoveDocument( ScDocument* pDocumentP ) { - sal_uInt32 nPos = aAllListeners.Count(); - while (nPos) + ::std::list<ScAddInListener*>::iterator iter = aAllListeners.begin(); + while(iter != aAllListeners.end()) { - // loop backwards because elements are removed - --nPos; - ScAddInListener* pLst = (ScAddInListener*)aAllListeners.GetObject(nPos); - ScAddInDocs* p = pLst->pDocs; + ScAddInDocs* p = (*iter)->pDocs; sal_uInt16 nFoundPos; if ( p->Seek_Entry( pDocumentP, &nFoundPos ) ) { p->Remove( nFoundPos ); if ( p->Count() == 0 ) { - // this AddIn is no longer used - // dont delete, just remove the ref for the list + if ( (*iter)->xVolRes.is() ) + (*iter)->xVolRes->removeResultListener( *iter ); - aAllListeners.Remove( nPos ); + (*iter)->release(); // Ref for aAllListeners - pLst may be deleted here - if ( pLst->xVolRes.is() ) - pLst->xVolRes->removeResultListener( pLst ); + // this AddIn is no longer used + // dont delete, just remove the ref for the list - pLst->release(); // Ref for aAllListeners - pLst may be deleted here + iter = aAllListeners.erase( iter ); + continue; } } + ++iter; } } -- 1.7.0.4
From 2924de36d45a8e885864713ece3dd54a75572a7d Mon Sep 17 00:00:00 2001 From: Thies Pierdola <thiespierd...@gmail.com> Date: Fri, 28 Jan 2011 22:53:30 +0100 Subject: [PATCH] Removed include of tools/string as no longer used --- sc/source/core/data/funcdesc.cxx | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/sc/source/core/data/funcdesc.cxx b/sc/source/core/data/funcdesc.cxx index b3a502c..28e8a5c 100644 --- a/sc/source/core/data/funcdesc.cxx +++ b/sc/source/core/data/funcdesc.cxx @@ -41,7 +41,6 @@ #include <rtl/ustrbuf.hxx> #include <tools/rcid.h> #include <tools/resid.hxx> -#include <tools/string.hxx> #include <unotools/collatorwrapper.hxx> #include <numeric> -- 1.7.0.4
_______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice