summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@libreoffice.org>2018-02-05 01:04:24 +0100
committerBjoern Michaelsen <bjoern.michaelsen@libreoffice.org>2018-02-05 01:04:24 +0100
commit35317520fb9fbd5c530aacff61d78353baebd9d2 (patch)
tree0042efe8bba689c942ce57c6c8aab27f5db27f2f
parent484572952270629b89e8ca0389164514ea5bba61 (diff)
remocve aAnchorCharFormatDep
Change-Id: Ic6a4ebacd14cec920affb922cc5b2853583e5328
-rw-r--r--sw/inc/ftninfo.hxx8
-rw-r--r--sw/source/core/doc/docftn.cxx41
-rw-r--r--sw/source/core/unocore/unosett.cxx24
3 files changed, 33 insertions, 40 deletions
diff --git a/sw/inc/ftninfo.hxx b/sw/inc/ftninfo.hxx
index 9a6982a81893..2552fc34a578 100644
--- a/sw/inc/ftninfo.hxx
+++ b/sw/inc/ftninfo.hxx
@@ -32,8 +32,10 @@ class SwDoc;
class SW_DLLPUBLIC SwEndNoteInfo : public SwClient
{
+ mutable SwMultiDepend aDepends;
+ mutable SwCharFormat* pAnchorFormat;
SwDepend aPageDescDep;
- SwDepend aCharFormatDep, aAnchorCharFormatDep;
+ SwDepend aCharFormatDep;
OUString sPrefix;
OUString sSuffix;
protected:
@@ -57,8 +59,8 @@ public:
SwClient *GetCharFormatDep() const { return const_cast<SwClient*>(static_cast<SwClient const *>(&aCharFormatDep)); }
SwCharFormat* GetAnchorCharFormat(SwDoc &rDoc) const;
- void SetAnchorCharFormat( SwCharFormat* );
- SwClient *GetAnchorCharFormatDep() const { return const_cast<SwClient*>(static_cast<SwClient const *>(&aAnchorCharFormatDep)); }
+ void SetAnchorCharFormat(SwCharFormat*);
+ SwCharFormat* GetCurrentCharFormat(const bool bAnchor) const;
SwEndNoteInfo & operator=(const SwEndNoteInfo&);
bool operator==( const SwEndNoteInfo &rInf ) const;
diff --git a/sw/source/core/doc/docftn.cxx b/sw/source/core/doc/docftn.cxx
index 3ddfcf96c9ee..f074edb04020 100644
--- a/sw/source/core/doc/docftn.cxx
+++ b/sw/source/core/doc/docftn.cxx
@@ -42,7 +42,9 @@ SwEndNoteInfo& SwEndNoteInfo::operator=(const SwEndNoteInfo& rInfo)
StartListeningToSameModifyAs(rInfo);
aPageDescDep.StartListeningToSameModifyAs(rInfo.aPageDescDep);
aCharFormatDep.StartListeningToSameModifyAs(rInfo.aCharFormatDep);
- aAnchorCharFormatDep.StartListeningToSameModifyAs(rInfo.aAnchorCharFormatDep);
+ pAnchorFormat = rInfo.pAnchorFormat;
+ aDepends.EndListeningAll();
+ aDepends.StartListening(pAnchorFormat);
aFormat = rInfo.aFormat;
nFootnoteOffset = rInfo.nFootnoteOffset;
@@ -58,8 +60,7 @@ bool SwEndNoteInfo::operator==( const SwEndNoteInfo& rInfo ) const
rInfo.aPageDescDep.GetRegisteredIn() &&
aCharFormatDep.GetRegisteredIn() ==
rInfo.aCharFormatDep.GetRegisteredIn() &&
- aAnchorCharFormatDep.GetRegisteredIn() ==
- rInfo.aAnchorCharFormatDep.GetRegisteredIn() &&
+ pAnchorFormat == rInfo.pAnchorFormat &&
GetFootnoteTextColl() == rInfo.GetFootnoteTextColl() &&
aFormat.GetNumberingType() == rInfo.aFormat.GetNumberingType() &&
nFootnoteOffset == rInfo.nFootnoteOffset &&
@@ -70,9 +71,10 @@ bool SwEndNoteInfo::operator==( const SwEndNoteInfo& rInfo ) const
SwEndNoteInfo::SwEndNoteInfo(const SwEndNoteInfo& rInfo) :
SwClient( rInfo.GetFootnoteTextColl() ),
+ aDepends(*this),
+ pAnchorFormat(rInfo.pAnchorFormat),
aPageDescDep( this, nullptr ),
aCharFormatDep( this, nullptr ),
- aAnchorCharFormatDep( this, nullptr ),
sPrefix( rInfo.sPrefix ),
sSuffix( rInfo.sSuffix ),
m_bEndNote( true ),
@@ -81,14 +83,15 @@ SwEndNoteInfo::SwEndNoteInfo(const SwEndNoteInfo& rInfo) :
{
aPageDescDep.StartListeningToSameModifyAs(rInfo.aPageDescDep);
aCharFormatDep.StartListeningToSameModifyAs(rInfo.aCharFormatDep);
- aAnchorCharFormatDep.StartListeningToSameModifyAs(rInfo.aAnchorCharFormatDep);
+ aDepends.StartListening(pAnchorFormat);
}
SwEndNoteInfo::SwEndNoteInfo() :
SwClient(nullptr),
+ aDepends(*this),
+ pAnchorFormat(nullptr),
aPageDescDep( this, nullptr ),
aCharFormatDep( this, nullptr ),
- aAnchorCharFormatDep( this, nullptr ),
m_bEndNote( true ),
nFootnoteOffset( 0 )
{
@@ -144,23 +147,31 @@ void SwEndNoteInfo::SetCharFormat( SwCharFormat* pChFormat )
pChFormat->Add( &static_cast<SwClient&>(aCharFormatDep) );
}
-SwCharFormat* SwEndNoteInfo::GetAnchorCharFormat(SwDoc &rDoc) const
+SwCharFormat* SwEndNoteInfo::GetAnchorCharFormat(SwDoc& rDoc) const
{
- if( !aAnchorCharFormatDep.GetRegisteredIn() )
+ if(!pAnchorFormat)
{
- SwCharFormat* pFormat = rDoc.getIDocumentStylePoolAccess().GetCharFormatFromPool( static_cast<sal_uInt16>(
+ pAnchorFormat = rDoc.getIDocumentStylePoolAccess().GetCharFormatFromPool( static_cast<sal_uInt16>(
m_bEndNote ? RES_POOLCHR_ENDNOTE_ANCHOR : RES_POOLCHR_FOOTNOTE_ANCHOR ) );
- pFormat->Add( &const_cast<SwClient&>(static_cast<const SwClient&>(aAnchorCharFormatDep)) );
+ aDepends.StartListening(pAnchorFormat);
}
- return const_cast<SwCharFormat*>(static_cast<const SwCharFormat*>(aAnchorCharFormatDep.GetRegisteredIn()));
+ return pAnchorFormat;
}
-void SwEndNoteInfo::SetAnchorCharFormat( SwCharFormat* pChFormat )
+void SwEndNoteInfo::SetAnchorCharFormat(SwCharFormat* pFormat)
{
- OSL_ENSURE(pChFormat, "no CharFormat?");
- pChFormat->Add( &static_cast<SwClient&>(aAnchorCharFormatDep) );
+ pAnchorFormat = pFormat;
+ aDepends.StartListening(pAnchorFormat);
+}
+
+SwCharFormat* SwEndNoteInfo::GetCurrentCharFormat(const bool bAnchor) const
+{
+ return bAnchor
+ ? pAnchorFormat
+ : const_cast<SwCharFormat*>(static_cast<const SwCharFormat*>(aCharFormatDep.GetRegisteredIn()));
}
+
void SwEndNoteInfo::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
{
const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0 ;
@@ -172,7 +183,7 @@ void SwEndNoteInfo::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
if( aCharFormatDep.GetRegisteredIn() )
pDoc = static_cast<SwFormat*>(aCharFormatDep.GetRegisteredIn())->GetDoc();
else
- pDoc = static_cast<SwFormat*>(aAnchorCharFormatDep.GetRegisteredIn())->GetDoc();
+ pDoc = pAnchorFormat->GetDoc();
SwFootnoteIdxs& rFootnoteIdxs = pDoc->GetFootnoteIdxs();
for( size_t nPos = 0; nPos < rFootnoteIdxs.size(); ++nPos )
{
diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx
index 8841f50de1db..39d78447a6a4 100644
--- a/sw/source/core/unocore/unosett.cxx
+++ b/sw/source/core/unocore/unosett.cxx
@@ -489,17 +489,7 @@ uno::Any SwXFootnoteProperties::getPropertyValue(const OUString& rPropertyName)
case WID_CHARACTER_STYLE:
{
OUString aString;
- const SwCharFormat* pCharFormat = nullptr;
- if( pEntry->nWID == WID_ANCHOR_CHARACTER_STYLE )
- {
- if( rFootnoteInfo.GetAnchorCharFormatDep()->GetRegisteredIn() )
- pCharFormat = rFootnoteInfo.GetAnchorCharFormat(*pDoc);
- }
- else
- {
- if( rFootnoteInfo.GetCharFormatDep()->GetRegisteredIn() )
- pCharFormat = rFootnoteInfo.GetCharFormat(*pDoc);
- }
+ const SwCharFormat* pCharFormat = rFootnoteInfo.GetCurrentCharFormat(pEntry->nWID == WID_ANCHOR_CHARACTER_STYLE);
if( pCharFormat )
{
SwStyleNameMapper::FillProgName(
@@ -712,17 +702,7 @@ uno::Any SwXEndnoteProperties::getPropertyValue(const OUString& rPropertyName)
case WID_CHARACTER_STYLE:
{
OUString aString;
- const SwCharFormat* pCharFormat = nullptr;
- if( pEntry->nWID == WID_ANCHOR_CHARACTER_STYLE )
- {
- if( rEndInfo.GetAnchorCharFormatDep()->GetRegisteredIn() )
- pCharFormat = rEndInfo.GetAnchorCharFormat(*pDoc);
- }
- else
- {
- if( rEndInfo.GetCharFormatDep()->GetRegisteredIn() )
- pCharFormat = rEndInfo.GetCharFormat(*pDoc);
- }
+ const SwCharFormat* pCharFormat = rEndInfo.GetCurrentCharFormat( pEntry->nWID == WID_ANCHOR_CHARACTER_STYLE );
if( pCharFormat )
{
SwStyleNameMapper::FillProgName(