[Libreoffice-commits] core.git: 3 commits - sw/inc sw/source
Bjoern Michaelsen
bjoern.michaelsen at canonical.com
Mon Mar 16 15:37:37 PDT 2015
sw/inc/calbck.hxx | 40 +++++++++++++++++-----------------------
sw/inc/switerator.hxx | 2 --
sw/source/core/attr/calbck.cxx | 31 +++++++++----------------------
3 files changed, 26 insertions(+), 47 deletions(-)
New commits:
commit e3167924fd28c8b854f23139dbf49f53e6282ef7
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Mar 15 04:50:32 2015 +0100
make SwClientIter::GoStart/GoEnd private
Change-Id: I0c0f84d110e8ea4f84404a8ca17d0c982c9200c4
diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx
index 7fc2e6d..2141653 100644
--- a/sw/inc/calbck.hxx
+++ b/sw/inc/calbck.hxx
@@ -243,10 +243,8 @@ protected:
class SwClientIter SAL_FINAL : public sw::Ring<SwClientIter>
{
- friend SwClient* SwModify::Remove(SwClient*); ///< for pointer adjustments
- friend void SwModify::Add(SwClient*); ///< for pointer adjustments
+ friend class SwModify;
template<typename E, typename S> friend class SwIterator; ///< for typed interation
- friend void SwModify::ModifyBroadcast( const SfxPoolItem*, const SfxPoolItem*, TypeId); ///< for typed iteration
const SwModify& m_rRoot;
@@ -259,6 +257,22 @@ class SwClientIter SAL_FINAL : public sw::Ring<SwClientIter>
SwClient* m_pPosition;
SwClient* GetLeftOfPos() { return static_cast<SwClient*>(m_pPosition->m_pLeft); }
SwClient* GetRighOfPos() { return static_cast<SwClient*>(m_pPosition->m_pRight); }
+ SwClient* GoStart()
+ {
+ if((m_pPosition = const_cast<SwClient*>(m_rRoot.GetDepends())))
+ while( m_pPosition->m_pLeft )
+ m_pPosition = static_cast<SwClient*>(m_pPosition->m_pLeft);
+ return m_pCurrent = m_pPosition;
+ }
+ SwClient* GoEnd()
+ {
+ if(!m_pPosition)
+ m_pPosition = const_cast<SwClient*>(m_rRoot.GetDepends());
+ if(m_pPosition)
+ while( m_pPosition->m_pRight )
+ m_pPosition = static_cast<SwClient*>(m_pPosition->m_pRight);
+ return m_pCurrent = m_pPosition;
+ }
static SW_DLLPUBLIC SwClientIter* our_pClientIters;
@@ -286,22 +300,6 @@ public:
m_pPosition = static_cast<SwClient*>(m_pPosition->m_pRight);
return m_pCurrent = m_pPosition;
}
- SwClient* GoStart()
- {
- if((m_pPosition = const_cast<SwClient*>(m_rRoot.GetDepends())))
- while( m_pPosition->m_pLeft )
- m_pPosition = static_cast<SwClient*>(m_pPosition->m_pLeft);
- return m_pCurrent = m_pPosition;
- }
- SwClient* GoEnd()
- {
- if(!m_pPosition)
- m_pPosition = const_cast<SwClient*>(m_rRoot.GetDepends());
- if(m_pPosition)
- while( m_pPosition->m_pRight )
- m_pPosition = static_cast<SwClient*>(m_pPosition->m_pRight);
- return m_pCurrent = m_pPosition;
- }
// returns the current SwClient object, wether it is still a client or not
SwClient& operator*() const
commit a21948bddfefa8554fb2d468616ec1bfda128e9d
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Mar 15 04:49:36 2015 +0100
refactor iteration
Change-Id: Ifc2e190fa54e2e1e8992ae7e4e3ff15465b6db3d
diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx
index 636ee94..0ea5389 100644
--- a/sw/source/core/attr/calbck.cxx
+++ b/sw/source/core/attr/calbck.cxx
@@ -75,12 +75,8 @@ SwModify::~SwModify()
// forget me so that they don't try to get removed from my list
// later when they also get destroyed
SwClientIter aIter( *this );
- SwClient* p = aIter.GoStart();
- while ( p )
- {
- p->pRegisteredIn = nullptr;
- p = ++aIter;
- }
+ for(aIter.GoStart(); aIter; ++aIter)
+ aIter->pRegisteredIn = nullptr;
}
else
{
@@ -136,22 +132,13 @@ void SwModify::NotifyClients( const SfxPoolItem* pOldValue, const SfxPoolItem* p
bool SwModify::GetInfo( SfxPoolItem& rInfo ) const
{
- bool bRet = true; // means: continue with next
-
- if( pRoot )
- {
- SwClientIter aIter( *(SwModify*)this );
-
- SwClient* pLast = aIter.GoStart();
- if( pLast )
- {
- while( ( bRet = pLast->GetInfo( rInfo ) ) &&
- nullptr != ( pLast = ++aIter ) )
- ;
- }
- }
-
- return bRet;
+ if(!pRoot)
+ return true;
+ SwClientIter aIter( *const_cast<SwModify*>(this) );
+ for(aIter.GoStart(); aIter; ++aIter)
+ if(!aIter->GetInfo( rInfo ))
+ return false;
+ return true;
}
void SwModify::Add( SwClient* pDepend )
commit 3b4e5fd012be12478fed5c55f53cfd9cc4747a0e
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Mar 15 02:45:08 2015 +0100
get rid of SearchType
- lets hope nobody counts on ModifyBroadcast having persistent
sideeffects
Change-Id: Ie85feb71732c4a81fba22db8cf62ec7fe30d0cfa
diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx
index 4c76fe9..7fc2e6d 100644
--- a/sw/inc/calbck.hxx
+++ b/sw/inc/calbck.hxx
@@ -260,15 +260,11 @@ class SwClientIter SAL_FINAL : public sw::Ring<SwClientIter>
SwClient* GetLeftOfPos() { return static_cast<SwClient*>(m_pPosition->m_pLeft); }
SwClient* GetRighOfPos() { return static_cast<SwClient*>(m_pPosition->m_pRight); }
- // iterator can be limited to return only SwClient objects of a certain type
- TypeId m_aSearchType;
-
static SW_DLLPUBLIC SwClientIter* our_pClientIters;
public:
SwClientIter( const SwModify& rModify )
: m_rRoot(rModify)
- , m_aSearchType(nullptr)
{
MoveTo(our_pClientIters);
our_pClientIters = this;
diff --git a/sw/inc/switerator.hxx b/sw/inc/switerator.hxx
index 499c6e18..693393e 100644
--- a/sw/inc/switerator.hxx
+++ b/sw/inc/switerator.hxx
@@ -30,7 +30,6 @@ public:
SwIterator( const TSource& rSrc ) : aClientIter(rSrc) { assert(TElementType::IsOf( TYPE(SwClient) )); }
TElementType* First()
{
- aClientIter.m_aSearchType = TYPE(TElementType);
aClientIter.GoStart();
if(!aClientIter.m_pPosition)
return nullptr;
@@ -39,7 +38,6 @@ public:
}
TElementType* Last()
{
- aClientIter.m_aSearchType = TYPE(TElementType);
aClientIter.GoEnd();
if(!aClientIter.m_pPosition)
return nullptr;
More information about the Libreoffice-commits
mailing list