2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2011-03-31 10:05:04 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2011-03-31 10:05:04 +02:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2011-03-31 10:05:04 +02:00
|
|
|
* This file incorporates work covered by the following license notice:
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2011-03-31 10:05:04 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2013-11-05 02:17:53 +01:00
|
|
|
#ifndef INCLUDED_SW_INC_CALBCK_HXX
|
|
|
|
#define INCLUDED_SW_INC_CALBCK_HXX
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
#include <tools/rtti.hxx>
|
2004-08-23 07:28:17 +00:00
|
|
|
#include "swdllapi.h"
|
2010-12-21 19:33:34 +01:00
|
|
|
#include <boost/noncopyable.hpp>
|
2015-03-13 02:57:07 +01:00
|
|
|
#include <ring.hxx>
|
2015-03-13 14:51:53 +01:00
|
|
|
#include <hintids.hxx>
|
|
|
|
#include <hints.hxx>
|
2004-08-23 07:28:17 +00:00
|
|
|
|
2015-03-13 14:57:08 +01:00
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
class SwModify;
|
|
|
|
class SwClientIter;
|
|
|
|
class SfxPoolItem;
|
2010-12-21 19:33:34 +01:00
|
|
|
class SfxHint;
|
2010-12-17 09:02:23 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
SwModify and SwClient cooperate in propagating attribute changes.
|
|
|
|
If an attribute changes, the change is notified to all dependent
|
|
|
|
formats and other interested objects, e.g. Nodes. The clients will detect
|
|
|
|
if the change affects them. It could be that the changed attribute is
|
|
|
|
overruled in the receiving object so that its change does not become
|
|
|
|
effective or that the receiver is not interested in the particular attribute
|
|
|
|
in general (though probably in other attributes of the SwModify object they
|
|
|
|
are registered in).
|
|
|
|
As SwModify objects are derived from SwClient, they can create a chain of SwClient
|
|
|
|
objects where changes can get propagated through.
|
|
|
|
Each SwClient can be registered at only one SwModify object, while each SwModify
|
|
|
|
object is connected to a list of SwClient objects. If an object derived from SwClient
|
|
|
|
wants to get notifications from more than one SwModify object, it must create additional
|
|
|
|
SwClient objects. The SwDepend class allows to handle their notifications in the same
|
|
|
|
notification callback as it forwards the Modify() calls it receives to a "master"
|
|
|
|
SwClient implementation.
|
|
|
|
The SwClientIter class allows to iterate over the SwClient objects registered at an
|
|
|
|
SwModify. For historical reasons its ability to use TypeInfo to restrict this iteration
|
|
|
|
to objects of a particular type created a lot of code that misuses SwClient-SwModify
|
|
|
|
relationships that basically should be used only for Modify() callbacks.
|
|
|
|
This is still subject to refactoring.
|
|
|
|
Until this gets resolved, new SwClientIter base code should be reduced to the absolute
|
|
|
|
minimum and it also should be wrapped by SwIterator templates that prevent that the
|
|
|
|
code gets polluted by pointer casts (see switerator.hxx).
|
|
|
|
*/
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2015-03-10 00:57:49 +01:00
|
|
|
class SwModify;
|
|
|
|
class SwClient;
|
|
|
|
class SwClientIter;
|
|
|
|
namespace sw
|
|
|
|
{
|
|
|
|
/// refactoring out the some of the more sane SwClient functionality
|
|
|
|
class SW_DLLPUBLIC WriterListener : ::boost::noncopyable
|
|
|
|
{
|
|
|
|
friend class ::SwModify;
|
|
|
|
friend class ::SwClient;
|
|
|
|
friend class ::SwClientIter;
|
|
|
|
private:
|
|
|
|
WriterListener* m_pLeft;
|
|
|
|
WriterListener* m_pRight; ///< double-linked list of other clients
|
|
|
|
protected:
|
|
|
|
WriterListener()
|
|
|
|
: m_pLeft(nullptr), m_pRight(nullptr)
|
|
|
|
{}
|
|
|
|
virtual ~WriterListener() {};
|
|
|
|
// callbacks received from SwModify (friend class - so these methods can be private)
|
|
|
|
// should be called only from SwModify the client is registered in
|
|
|
|
// mba: IMHO these methods should be pure virtual
|
|
|
|
virtual void Modify(const SfxPoolItem*, const SfxPoolItem*) {};
|
|
|
|
virtual void SwClientNotify( const SwModify&, const SfxHint&) {};
|
|
|
|
public:
|
|
|
|
bool IsLast() const { return !m_pLeft && !m_pRight; }
|
|
|
|
};
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
// SwClient
|
2015-03-10 00:57:49 +01:00
|
|
|
class SW_DLLPUBLIC SwClient : ::sw::WriterListener
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2010-12-17 09:02:23 +01:00
|
|
|
// avoids making the details of the linked list and the callback method public
|
2000-09-18 16:15:01 +00:00
|
|
|
friend class SwModify;
|
|
|
|
friend class SwClientIter;
|
|
|
|
|
2012-07-22 11:29:48 +03:00
|
|
|
SwModify *pRegisteredIn; ///< event source
|
2010-11-15 23:37:49 +01:00
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
protected:
|
2004-08-23 07:28:17 +00:00
|
|
|
// single argument ctors shall be explicit.
|
2015-03-13 13:23:40 +01:00
|
|
|
inline explicit SwClient( SwModify* pToRegisterIn );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
// write access to pRegisteredIn shall be granted only to the object itself (protected access)
|
|
|
|
SwModify* GetRegisteredInNonConst() const { return pRegisteredIn; }
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
public:
|
2010-12-17 09:02:23 +01:00
|
|
|
|
2015-03-10 00:57:49 +01:00
|
|
|
SwClient() : pRegisteredIn(nullptr) {}
|
2000-09-18 16:15:01 +00:00
|
|
|
virtual ~SwClient();
|
2015-03-13 13:23:40 +01:00
|
|
|
virtual void Modify( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue )
|
|
|
|
{ CheckRegistration( pOldValue, pNewValue ); }
|
2004-08-23 07:28:17 +00:00
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
// in case an SwModify object is destroyed that itself is registered in another SwModify,
|
|
|
|
// its SwClient objects can decide to get registered to the latter instead by calling this method
|
|
|
|
void CheckRegistration( const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue );
|
|
|
|
|
|
|
|
// controlled access to Modify method
|
|
|
|
// mba: this is still considered a hack and it should be fixed; the name makes grep-ing easier
|
2015-03-10 00:57:49 +01:00
|
|
|
void ModifyNotification( const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue ) { this->Modify ( pOldValue, pNewValue ); }
|
2015-03-13 13:23:40 +01:00
|
|
|
void SwClientNotifyCall( const SwModify& rModify, const SfxHint& rHint ) { SwClientNotify( rModify, rHint ); }
|
2010-12-17 09:02:23 +01:00
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
const SwModify* GetRegisteredIn() const { return pRegisteredIn; }
|
2014-09-18 15:10:54 +02:00
|
|
|
SwModify* GetRegisteredIn() { return pRegisteredIn; }
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
// needed for class SwClientIter
|
2000-09-18 16:15:01 +00:00
|
|
|
TYPEINFO();
|
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
// get information about attribute
|
2015-03-13 13:23:40 +01:00
|
|
|
virtual bool GetInfo( SfxPoolItem& ) const { return true; }
|
2000-09-18 16:15:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// SwModify
|
|
|
|
|
2010-11-15 23:37:49 +01:00
|
|
|
// class has a doubly linked list for dependencies
|
2004-08-23 07:28:17 +00:00
|
|
|
class SW_DLLPUBLIC SwModify: public SwClient
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2015-03-10 00:57:49 +01:00
|
|
|
sw::WriterListener* pRoot; // the start of the linked list of clients
|
2012-11-21 07:34:08 +09:00
|
|
|
bool bModifyLocked : 1; // don't broadcast changes now
|
2014-04-25 14:00:35 +02:00
|
|
|
bool bLockClientList : 1; // may be set when this instance notifies its clients
|
|
|
|
bool bInDocDTOR : 1; // workaround for problems when a lot of objects are destroyed
|
|
|
|
bool bInCache : 1;
|
|
|
|
bool bInSwFntCache : 1;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
// mba: IMHO this method should be pure virtual
|
2015-03-13 13:44:40 +01:00
|
|
|
virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE
|
|
|
|
{ NotifyClients( pOld, pNew ); };
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
public:
|
2015-03-13 13:44:40 +01:00
|
|
|
SwModify()
|
|
|
|
: SwClient(nullptr), pRoot(nullptr), bModifyLocked(false), bLockClientList(false), bInDocDTOR(false), bInCache(false), bInSwFntCache(false)
|
|
|
|
{}
|
2010-12-17 09:02:23 +01:00
|
|
|
|
|
|
|
// broadcasting: send notifications to all clients
|
|
|
|
void NotifyClients( const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue );
|
|
|
|
|
|
|
|
// the same, but without setting bModifyLocked or checking for any of the flags
|
|
|
|
// mba: it would be interesting to know why this is necessary
|
|
|
|
// also allows to limit callback to certain type (HACK)
|
2015-03-13 14:30:10 +01:00
|
|
|
inline void ModifyBroadcast( const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue, TypeId nType = TYPE(SwClient) );
|
2010-12-17 09:02:23 +01:00
|
|
|
|
2010-12-21 19:33:34 +01:00
|
|
|
// a more universal broadcasting mechanism
|
2015-03-13 14:30:10 +01:00
|
|
|
inline void CallSwClientNotify( const SfxHint& rHint ) const;
|
2004-08-23 07:28:17 +00:00
|
|
|
|
|
|
|
// single argument ctors shall be explicit.
|
2015-03-13 13:44:40 +01:00
|
|
|
explicit SwModify( SwModify* pToRegisterIn )
|
|
|
|
: SwClient(pToRegisterIn), pRoot(nullptr), bModifyLocked(false), bLockClientList(false), bInDocDTOR(false), bInCache(false), bInSwFntCache(false)
|
|
|
|
{}
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
virtual ~SwModify();
|
2004-08-23 07:28:17 +00:00
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
void Add(SwClient *pDepend);
|
2010-12-17 09:02:23 +01:00
|
|
|
SwClient* Remove(SwClient *pDepend);
|
2015-03-10 00:57:49 +01:00
|
|
|
const SwClient* GetDepends() const { return static_cast<SwClient*>(pRoot); }
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
// get information about attribute
|
2014-03-27 18:12:18 +01:00
|
|
|
virtual bool GetInfo( SfxPoolItem& ) const SAL_OVERRIDE;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2012-11-21 07:34:08 +09:00
|
|
|
void LockModify() { bModifyLocked = true; }
|
|
|
|
void UnlockModify() { bModifyLocked = false; }
|
2014-04-25 14:00:35 +02:00
|
|
|
void SetInCache( bool bNew ) { bInCache = bNew; }
|
|
|
|
void SetInSwFntCache( bool bNew ) { bInSwFntCache = bNew; }
|
|
|
|
void SetInDocDTOR() { bInDocDTOR = true; }
|
2012-11-21 07:34:08 +09:00
|
|
|
bool IsModifyLocked() const { return bModifyLocked; }
|
2014-04-25 14:00:35 +02:00
|
|
|
bool IsInDocDTOR() const { return bInDocDTOR; }
|
|
|
|
bool IsInCache() const { return bInCache; }
|
|
|
|
bool IsInSwFntCache() const { return bInSwFntCache; }
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void CheckCaching( const sal_uInt16 nWhich );
|
2010-12-17 09:02:23 +01:00
|
|
|
bool IsLastDepend() { return pRoot && pRoot->IsLast(); }
|
2000-09-18 16:15:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// SwDepend
|
|
|
|
|
|
|
|
/*
|
2010-12-17 09:02:23 +01:00
|
|
|
* Helper class for objects that need to depend on more than one SwClient
|
2000-09-18 16:15:01 +00:00
|
|
|
*/
|
2015-03-13 14:58:03 +01:00
|
|
|
class SW_DLLPUBLIC SwDepend SAL_FINAL : public SwClient
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2015-03-13 14:58:03 +01:00
|
|
|
SwClient *m_pToTell;
|
2004-08-23 07:28:17 +00:00
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
public:
|
2015-03-13 14:58:03 +01:00
|
|
|
SwDepend() : m_pToTell(nullptr) {}
|
|
|
|
SwDepend(SwClient *pTellHim, SwModify *pDepend) : SwClient(pDepend), m_pToTell(pTellHim) {}
|
2004-08-23 07:28:17 +00:00
|
|
|
|
2015-03-13 14:58:03 +01:00
|
|
|
SwClient* GetToTell() { return m_pToTell; }
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2012-07-22 11:29:48 +03:00
|
|
|
/** get Client information */
|
2015-03-13 14:51:53 +01:00
|
|
|
virtual bool GetInfo( SfxPoolItem& rInfo) const SAL_OVERRIDE
|
2015-03-13 14:58:03 +01:00
|
|
|
{ return m_pToTell ? m_pToTell->GetInfo( rInfo ) : true; }
|
2010-12-17 09:02:23 +01:00
|
|
|
protected:
|
2015-03-13 14:51:53 +01:00
|
|
|
virtual void Modify( const SfxPoolItem* pOldValue, const SfxPoolItem *pNewValue ) SAL_OVERRIDE
|
|
|
|
{
|
|
|
|
if( pNewValue && pNewValue->Which() == RES_OBJECTDYING )
|
|
|
|
CheckRegistration(pOldValue,pNewValue);
|
2015-03-13 14:58:03 +01:00
|
|
|
else if( m_pToTell )
|
|
|
|
m_pToTell->ModifyNotification(pOldValue, pNewValue);
|
2015-03-13 14:51:53 +01:00
|
|
|
}
|
|
|
|
virtual void SwClientNotify( const SwModify& rModify, const SfxHint& rHint ) SAL_OVERRIDE
|
2015-03-13 14:58:03 +01:00
|
|
|
{ if(m_pToTell) m_pToTell->SwClientNotifyCall(rModify, rHint); }
|
2000-09-18 16:15:01 +00:00
|
|
|
};
|
|
|
|
|
2015-03-13 14:58:03 +01:00
|
|
|
class SwClientIter SAL_FINAL : public sw::Ring<SwClientIter>
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2012-07-22 11:29:48 +03:00
|
|
|
friend SwClient* SwModify::Remove(SwClient *); ///< for pointer adjustments
|
|
|
|
friend void SwModify::Add(SwClient *pDepend); ///< for pointer adjustments
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2015-03-13 12:59:46 +01:00
|
|
|
const SwModify& m_rRoot;
|
2006-02-09 13:53:27 +00:00
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
// the current object in an iteration
|
2015-03-13 12:59:46 +01:00
|
|
|
SwClient* m_pCurrent;
|
2006-02-09 13:53:27 +00:00
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
// in case the current object is already removed, the next object in the list
|
|
|
|
// is marked down to become the current object in the next step
|
|
|
|
// this is necessary because iteration requires access to members of the current object
|
2015-03-13 12:59:46 +01:00
|
|
|
SwClient* m_pPosition;
|
2006-02-09 13:53:27 +00:00
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
// iterator can be limited to return only SwClient objects of a certain type
|
2015-03-13 12:59:46 +01:00
|
|
|
TypeId m_aSearchType;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2015-03-13 12:59:46 +01:00
|
|
|
static SW_DLLPUBLIC SwClientIter* our_pClientIters;
|
2015-03-13 12:36:12 +01:00
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
public:
|
2015-03-13 12:36:12 +01:00
|
|
|
SwClientIter( const SwModify& rModify )
|
2015-03-13 12:59:46 +01:00
|
|
|
: m_rRoot(rModify)
|
|
|
|
, m_aSearchType(nullptr)
|
2015-03-13 12:36:12 +01:00
|
|
|
{
|
2015-03-13 12:59:46 +01:00
|
|
|
MoveTo(our_pClientIters);
|
|
|
|
our_pClientIters = this;
|
|
|
|
m_pCurrent = m_pPosition = const_cast<SwClient*>(m_rRoot.GetDepends());
|
2015-03-13 12:36:12 +01:00
|
|
|
}
|
|
|
|
~SwClientIter()
|
|
|
|
{
|
2015-03-13 12:59:46 +01:00
|
|
|
assert(our_pClientIters);
|
|
|
|
if(our_pClientIters == this)
|
|
|
|
our_pClientIters = unique() ? nullptr : GetNextInRing();
|
2015-03-13 12:36:12 +01:00
|
|
|
MoveTo(nullptr);
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2015-03-13 12:59:46 +01:00
|
|
|
const SwModify& GetModify() const { return m_rRoot; }
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2015-03-13 12:36:12 +01:00
|
|
|
SwClient* operator++()
|
|
|
|
{
|
2015-03-13 12:59:46 +01:00
|
|
|
if( m_pPosition == m_pCurrent )
|
|
|
|
m_pPosition = static_cast<SwClient*>(m_pPosition->m_pRight);
|
|
|
|
return m_pCurrent = m_pPosition;
|
2015-03-13 12:36:12 +01:00
|
|
|
}
|
|
|
|
SwClient* GoStart()
|
|
|
|
{
|
2015-03-13 12:59:46 +01:00
|
|
|
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;
|
2015-03-13 12:36:12 +01:00
|
|
|
}
|
|
|
|
SwClient* GoEnd()
|
|
|
|
{
|
2015-03-13 12:59:46 +01:00
|
|
|
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;
|
2015-03-13 12:36:12 +01:00
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2015-03-13 13:46:59 +01:00
|
|
|
// returns the current SwClient object, if its still a listener
|
|
|
|
// otherwise it returns the next SwClient that still is
|
2000-09-18 16:15:01 +00:00
|
|
|
SwClient* operator()() const
|
2015-03-13 13:46:59 +01:00
|
|
|
{ return m_pPosition; }
|
2015-03-13 14:14:09 +01:00
|
|
|
// returns the current SwClient object, wether it is still a client or not
|
|
|
|
SwClient& operator*() const
|
|
|
|
{ return *m_pCurrent; }
|
|
|
|
// returns the current SwClient object, wether it is still a client or not
|
|
|
|
SwClient* operator->() const
|
|
|
|
{ return m_pCurrent; }
|
|
|
|
explicit operator bool() const
|
|
|
|
{ return m_pCurrent!=nullptr; }
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
// return "true" if an object was removed from a client chain in iteration
|
|
|
|
// adding objects to a client chain in iteration is forbidden
|
|
|
|
// SwModify::Add() asserts this
|
2015-03-13 12:59:46 +01:00
|
|
|
bool IsChanged() const { return m_pPosition != m_pCurrent; }
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2015-03-13 12:36:12 +01:00
|
|
|
SwClient* First( TypeId nType )
|
|
|
|
{
|
2015-03-13 12:59:46 +01:00
|
|
|
m_aSearchType = nType;
|
2015-03-13 12:36:12 +01:00
|
|
|
GoStart();
|
2015-03-13 12:59:46 +01:00
|
|
|
if(!m_pPosition)
|
2015-03-13 12:36:12 +01:00
|
|
|
return nullptr;
|
2015-03-13 12:59:46 +01:00
|
|
|
m_pCurrent = nullptr;
|
2015-03-13 12:36:12 +01:00
|
|
|
return Next();
|
|
|
|
}
|
|
|
|
SwClient* Last( TypeId nType )
|
|
|
|
{
|
2015-03-13 12:59:46 +01:00
|
|
|
m_aSearchType = nType;
|
2015-03-13 12:36:12 +01:00
|
|
|
GoEnd();
|
2015-03-13 12:59:46 +01:00
|
|
|
if(!m_pPosition)
|
2015-03-13 12:36:12 +01:00
|
|
|
return nullptr;
|
2015-03-13 12:59:46 +01:00
|
|
|
if( m_pPosition->IsA( m_aSearchType ) )
|
|
|
|
return m_pPosition;
|
2015-03-13 12:36:12 +01:00
|
|
|
return Previous();
|
|
|
|
}
|
|
|
|
SwClient* Next()
|
|
|
|
{
|
2015-03-13 12:59:46 +01:00
|
|
|
if( m_pPosition == m_pCurrent )
|
|
|
|
m_pPosition = static_cast<SwClient*>(m_pPosition->m_pRight);
|
|
|
|
while(m_pPosition && !m_pPosition->IsA( m_aSearchType ) )
|
|
|
|
m_pPosition = static_cast<SwClient*>(m_pPosition->m_pRight);
|
|
|
|
return m_pCurrent = m_pPosition;
|
2015-03-13 12:36:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SwClient* Previous()
|
|
|
|
{
|
2015-03-13 12:59:46 +01:00
|
|
|
m_pPosition = static_cast<SwClient*>(m_pPosition->m_pLeft);
|
|
|
|
while(m_pPosition && !m_pPosition->IsA( m_aSearchType ) )
|
|
|
|
m_pPosition = static_cast<SwClient*>(m_pPosition->m_pLeft);
|
|
|
|
return m_pCurrent = m_pPosition;
|
2015-03-13 12:36:12 +01:00
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
};
|
|
|
|
|
2015-03-13 13:23:40 +01:00
|
|
|
SwClient::SwClient( SwModify* pToRegisterIn )
|
|
|
|
: pRegisteredIn( nullptr )
|
|
|
|
{
|
|
|
|
if(pToRegisterIn)
|
|
|
|
pToRegisterIn->Add(this);
|
|
|
|
}
|
2015-03-13 14:30:10 +01:00
|
|
|
|
|
|
|
void SwModify::ModifyBroadcast( const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue, TypeId nType)
|
|
|
|
{
|
|
|
|
SwClientIter aIter(*this);
|
|
|
|
for(aIter.First(nType); aIter; aIter.Next())
|
|
|
|
aIter->Modify( pOldValue, pNewValue );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwModify::CallSwClientNotify( const SfxHint& rHint ) const
|
|
|
|
{
|
|
|
|
for(SwClientIter aIter(*this); aIter; ++aIter)
|
|
|
|
aIter->SwClientNotify( *this, rHint );
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
#endif
|
2010-10-14 08:30:41 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|