Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
23fd991f
Kaydet (Commit)
23fd991f
authored
Mar 09, 2015
tarafından
Bjoern Michaelsen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
separate the sane from the less sane in SwClient
Change-Id: Ie641019e0de26fc73ffb51b825fef2cc072adc6e
üst
3b4a7845
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
48 deletions
+61
-48
calbck.hxx
sw/inc/calbck.hxx
+34
-17
calbck.cxx
sw/source/core/attr/calbck.cxx
+27
-31
No files found.
sw/inc/calbck.hxx
Dosyayı görüntüle @
23fd991f
...
...
@@ -56,23 +56,43 @@ class SfxHint;
code gets polluted by pointer casts (see switerator.hxx).
*/
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
;
}
};
}
// SwClient
class
SW_DLLPUBLIC
SwClient
:
::
boost
::
noncopyable
class
SW_DLLPUBLIC
SwClient
:
::
sw
::
WriterListener
{
// avoids making the details of the linked list and the callback method public
friend
class
SwModify
;
friend
class
SwClientIter
;
SwClient
*
pLeft
,
*
pRight
;
///< double-linked list of other clients
SwModify
*
pRegisteredIn
;
///< event source
// 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
*
pOld
,
const
SfxPoolItem
*
pNew
);
virtual
void
SwClientNotify
(
const
SwModify
&
rModify
,
const
SfxHint
&
rHint
);
protected
:
// single argument ctors shall be explicit.
explicit
SwClient
(
SwModify
*
pToRegisterIn
);
...
...
@@ -82,8 +102,9 @@ protected:
public
:
inline
SwClient
();
SwClient
()
:
pRegisteredIn
(
nullptr
)
{}
virtual
~
SwClient
();
virtual
void
Modify
(
const
SfxPoolItem
*
pOld
,
const
SfxPoolItem
*
pNew
);
// 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
...
...
@@ -91,12 +112,11 @@ public:
// controlled access to Modify method
// mba: this is still considered a hack and it should be fixed; the name makes grep-ing easier
void
ModifyNotification
(
const
SfxPoolItem
*
pOldValue
,
const
SfxPoolItem
*
pNewValue
)
{
Modify
(
pOldValue
,
pNewValue
);
}
void
ModifyNotification
(
const
SfxPoolItem
*
pOldValue
,
const
SfxPoolItem
*
pNewValue
)
{
this
->
Modify
(
pOldValue
,
pNewValue
);
}
void
SwClientNotifyCall
(
const
SwModify
&
rModify
,
const
SfxHint
&
rHint
)
{
SwClientNotify
(
rModify
,
rHint
);
}
const
SwModify
*
GetRegisteredIn
()
const
{
return
pRegisteredIn
;
}
SwModify
*
GetRegisteredIn
()
{
return
pRegisteredIn
;
}
bool
IsLast
()
const
{
return
!
pLeft
&&
!
pRight
;
}
// needed for class SwClientIter
TYPEINFO
();
...
...
@@ -105,16 +125,13 @@ public:
virtual
bool
GetInfo
(
SfxPoolItem
&
)
const
;
};
inline
SwClient
::
SwClient
()
:
pLeft
(
0
),
pRight
(
0
),
pRegisteredIn
(
0
)
{}
// SwModify
// class has a doubly linked list for dependencies
class
SW_DLLPUBLIC
SwModify
:
public
SwClient
{
SwClient
*
pRoot
;
// the start of the linked list of clients
sw
::
WriterListener
*
pRoot
;
// the start of the linked list of clients
bool
bModifyLocked
:
1
;
// don't broadcast changes now
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
...
...
@@ -144,7 +161,7 @@ public:
void
Add
(
SwClient
*
pDepend
);
SwClient
*
Remove
(
SwClient
*
pDepend
);
const
SwClient
*
GetDepends
()
const
{
return
pRoot
;
}
const
SwClient
*
GetDepends
()
const
{
return
static_cast
<
SwClient
*>
(
pRoot
)
;
}
// get information about attribute
virtual
bool
GetInfo
(
SfxPoolItem
&
)
const
SAL_OVERRIDE
;
...
...
sw/source/core/attr/calbck.cxx
Dosyayı görüntüle @
23fd991f
...
...
@@ -28,7 +28,7 @@ static SwClientIter* pClientIters = nullptr;
TYPEINIT0
(
SwClient
);
SwClient
::
SwClient
(
SwModify
*
pToRegisterIn
)
:
p
Left
(
nullptr
),
pRight
(
nullptr
),
p
RegisteredIn
(
nullptr
)
:
pRegisteredIn
(
nullptr
)
{
if
(
pToRegisterIn
)
// connect to SwModify
...
...
@@ -63,10 +63,6 @@ void SwClient::Modify( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValu
CheckRegistration
(
pOldValue
,
pNewValue
);
}
void
SwClient
::
SwClientNotify
(
const
SwModify
&
,
const
SfxHint
&
)
{
}
SwClient
::~
SwClient
()
{
OSL_ENSURE
(
!
pRegisteredIn
||
pRegisteredIn
->
GetDepends
(),
"SwModify still known, but Client already disconnected!"
);
...
...
@@ -135,7 +131,7 @@ SwModify::~SwModify()
// remove all clients that have not done themselves
// mba: possibly a hotfix for forgotten base class calls?!
while
(
pRoot
)
pRoot
->
CheckRegistration
(
&
aDyObject
,
&
aDyObject
);
static_cast
<
SwClient
*>
(
pRoot
)
->
CheckRegistration
(
&
aDyObject
,
&
aDyObject
);
}
}
}
...
...
@@ -225,17 +221,17 @@ void SwModify::Add( SwClient* pDepend )
{
// first client added
pRoot
=
pDepend
;
pRoot
->
pLeft
=
nullptr
;
pRoot
->
pRight
=
nullptr
;
pRoot
->
m_
pLeft
=
nullptr
;
pRoot
->
m_
pRight
=
nullptr
;
}
else
{
// append client
pDepend
->
pRight
=
pRoot
->
pRight
;
pRoot
->
pRight
=
pDepend
;
pDepend
->
pLeft
=
pRoot
;
if
(
pDepend
->
pRight
)
pDepend
->
pRight
->
pLeft
=
pDepend
;
pDepend
->
m_pRight
=
pRoot
->
m_
pRight
;
pRoot
->
m_
pRight
=
pDepend
;
pDepend
->
m_
pLeft
=
pRoot
;
if
(
pDepend
->
m_
pRight
)
pDepend
->
m_pRight
->
m_
pLeft
=
pDepend
;
}
// connect client to me
...
...
@@ -252,15 +248,15 @@ SwClient* SwModify::Remove( SwClient* pDepend )
{
// SwClient is my listener
// remove it from my list
SwClient
*
pR
=
pDepend
->
pRight
;
SwClient
*
pL
=
pDepend
->
pLeft
;
::
sw
::
WriterListener
*
pR
=
pDepend
->
m_
pRight
;
::
sw
::
WriterListener
*
pL
=
pDepend
->
m_
pLeft
;
if
(
pRoot
==
pDepend
)
pRoot
=
pL
?
pL
:
pR
;
if
(
pL
)
pL
->
pRight
=
pR
;
pL
->
m_
pRight
=
pR
;
if
(
pR
)
pR
->
pLeft
=
pL
;
pR
->
m_
pLeft
=
pL
;
// update ClientIters
SwClientIter
*
pTmp
=
pClientIters
;
...
...
@@ -270,13 +266,13 @@ SwClient* SwModify::Remove( SwClient* pDepend )
{
// if object being removed is the current or next object in an
// iterator, advance this iterator
pTmp
->
pDelNext
=
pR
;
pTmp
->
pDelNext
=
static_cast
<
SwClient
*>
(
pR
)
;
}
pTmp
=
pTmp
->
pNxtIter
;
}
pDepend
->
pLeft
=
nullptr
;
pDepend
->
pRight
=
nullptr
;
pDepend
->
m_
pLeft
=
nullptr
;
pDepend
->
m_
pRight
=
nullptr
;
}
else
{
...
...
@@ -412,7 +408,7 @@ SwClient* SwClientIter::operator++()
{
if
(
pDelNext
==
pAct
)
{
pAct
=
pAct
->
pRight
;
pAct
=
static_cast
<
SwClient
*>
(
pAct
->
m_pRight
)
;
pDelNext
=
pAct
;
}
else
...
...
@@ -425,8 +421,8 @@ SwClient* SwClientIter::GoStart()
pAct
=
const_cast
<
SwClient
*>
(
rRoot
.
GetDepends
());
if
(
pAct
)
{
while
(
pAct
->
pLeft
)
pAct
=
pAct
->
pLeft
;
while
(
pAct
->
m_
pLeft
)
pAct
=
static_cast
<
SwClient
*>
(
pAct
->
m_pLeft
)
;
}
pDelNext
=
pAct
;
return
pAct
;
...
...
@@ -439,8 +435,8 @@ SwClient* SwClientIter::GoEnd()
pAct
=
const_cast
<
SwClient
*>
(
rRoot
.
GetDepends
());
if
(
pAct
)
{
while
(
pAct
->
pRight
)
pAct
=
pAct
->
pRight
;
while
(
pAct
->
m_
pRight
)
pAct
=
static_cast
<
SwClient
*>
(
pAct
->
m_pRight
)
;
}
pDelNext
=
pAct
;
return
pAct
;
...
...
@@ -457,7 +453,7 @@ SwClient* SwClientIter::First( TypeId nType )
if
(
pDelNext
==
pAct
)
{
pAct
=
pAct
->
pRight
;
pAct
=
static_cast
<
SwClient
*>
(
pAct
->
m_pRight
)
;
pDelNext
=
pAct
;
}
else
...
...
@@ -476,9 +472,9 @@ SwClient* SwClientIter::Last( TypeId nType )
break
;
if
(
pDelNext
==
pAct
)
pAct
=
pAct
->
pLeft
;
pAct
=
static_cast
<
SwClient
*>
(
pAct
->
m_pLeft
)
;
else
pAct
=
pDelNext
->
pLeft
;
pAct
=
static_cast
<
SwClient
*>
(
pDelNext
->
m_pLeft
)
;
pDelNext
=
pAct
;
}
while
(
pAct
);
return
pAct
;
...
...
@@ -489,7 +485,7 @@ SwClient* SwClientIter::Next()
do
{
if
(
pDelNext
==
pAct
)
{
pAct
=
pAct
->
pRight
;
pAct
=
static_cast
<
SwClient
*>
(
pAct
->
m_pRight
)
;
pDelNext
=
pAct
;
}
else
...
...
@@ -505,9 +501,9 @@ SwClient* SwClientIter::Previous()
{
do
{
if
(
pDelNext
==
pAct
)
pAct
=
pAct
->
pLeft
;
pAct
=
static_cast
<
SwClient
*>
(
pAct
->
m_pLeft
)
;
else
pAct
=
pDelNext
->
pLeft
;
pAct
=
static_cast
<
SwClient
*>
(
pDelNext
->
m_pLeft
)
;
pDelNext
=
pAct
;
if
(
pAct
&&
pAct
->
IsA
(
aSrchId
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment