summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-08-20 12:56:12 +0200
committerMichael Stahl <mstahl@redhat.com>2014-08-20 16:40:17 +0200
commite54015d06f103e3ce9edc899f0d839ead88add8a (patch)
tree0950a1c4f53a7d65011b772f3960b307ac186643
parenteee8b6eed6145f695d532aa62c33e3a0c44cba86 (diff)
i#107771: sw: make SwXFootnote a client of its format poolitem
In other words, stop registering at SwDoc's "UnoCallBack". Change-Id: Ie73c707b0f43559cc78717c0879d5e9a9335a7ac
-rw-r--r--sw/inc/fmtftn.hxx8
-rw-r--r--sw/inc/hintids.hxx1
-rw-r--r--sw/source/core/attr/calbck.cxx4
-rw-r--r--sw/source/core/doc/docftn.cxx3
-rw-r--r--sw/source/core/docnode/nodes.cxx4
-rw-r--r--sw/source/core/inc/unofootnote.hxx4
-rw-r--r--sw/source/core/txtnode/atrftn.cxx19
-rw-r--r--sw/source/core/txtnode/thints.cxx2
-rw-r--r--sw/source/core/unocore/unocoll.cxx5
-rw-r--r--sw/source/core/unocore/unocrsrhelper.cxx3
-rw-r--r--sw/source/core/unocore/unoftn.cxx29
-rw-r--r--sw/source/core/unocore/unoobj2.cxx3
12 files changed, 43 insertions, 42 deletions
diff --git a/sw/inc/fmtftn.hxx b/sw/inc/fmtftn.hxx
index 038b68231158..fdfaee578d4e 100644
--- a/sw/inc/fmtftn.hxx
+++ b/sw/inc/fmtftn.hxx
@@ -21,14 +21,18 @@
#include <rtl/ustring.hxx>
#include <svl/poolitem.hxx>
+
#include "swdllapi.h"
+#include <calbck.hxx>
class SwDoc;
class SwTxtFtn;
// ATT_FTN
-class SW_DLLPUBLIC SwFmtFtn: public SfxPoolItem
+class SW_DLLPUBLIC SwFmtFtn
+ : public SfxPoolItem
+ , public SwModify
{
friend class SwTxtFtn;
SwTxtFtn* m_pTxtAttr; ///< My TextAttribute.
@@ -48,6 +52,8 @@ public:
virtual bool operator==( const SfxPoolItem& ) const SAL_OVERRIDE;
virtual SfxPoolItem* Clone( SfxItemPool* pPool = 0 ) const SAL_OVERRIDE;
+ void InvalidateFootnote();
+
OUString GetNumStr() const { return m_aNumber; }
sal_uInt16 GetNumber() const { return m_nNumber; }
bool IsEndNote() const { return m_bEndNote;}
diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx
index 3c5db6b159da..687727679506 100644
--- a/sw/inc/hintids.hxx
+++ b/sw/inc/hintids.hxx
@@ -329,7 +329,6 @@ RES_MSG_BEGIN = RES_FMT_END,
RES_SECTION_RESETHIDDENFLAG,
RES_FINDNEARESTNODE,
RES_CONTENT_VISIBLE,
- RES_FOOTNOTE_DELETED,
RES_GRAPHIC_SWAPIN,
RES_NAME_CHANGED,
RES_TITLE_CHANGED,
diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx
index 75d46e5e9307..44d54c483f6e 100644
--- a/sw/source/core/attr/calbck.cxx
+++ b/sw/source/core/attr/calbck.cxx
@@ -173,10 +173,6 @@ void SwModify::NotifyClients( const SfxPoolItem* pOldValue, const SfxPoolItem* p
bLockClientList = ((SwPtrMsgPoolItem*)pOldValue)->pObject != this;
break;
- case RES_FOOTNOTE_DELETED:
- bLockClientList = false;
- break;
-
default:
bLockClientList = true;
}
diff --git a/sw/source/core/doc/docftn.cxx b/sw/source/core/doc/docftn.cxx
index 258a336beee8..8814552e3041 100644
--- a/sw/source/core/doc/docftn.cxx
+++ b/sw/source/core/doc/docftn.cxx
@@ -437,8 +437,7 @@ bool SwDoc::SetCurFtn( const SwPaM& rPam, const OUString& rNumStr,
bTypeChgd = true;
pTxtFtn->CheckCondColl();
//#i11339# dispose UNO wrapper when a footnote is changed to an endnote or vice versa
- SwPtrMsgPoolItem aMsgHint( RES_FOOTNOTE_DELETED, (void*)&pTxtFtn->GetAttr() );
- GetUnoCallBack()->ModifyNotification( &aMsgHint, &aMsgHint );
+ const_cast<SwFmtFtn&>(rFtn).InvalidateFootnote();
}
}
}
diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index 19e7190deb10..b65429686cf9 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -40,6 +40,7 @@
#include <txtatr.hxx>
#include <tox.hxx>
#include <fmtrfmrk.hxx>
+#include <fmtftn.hxx>
#include <docsh.hxx>
#include <svl/smplhint.hxx>
@@ -296,7 +297,8 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, sal_uLong nSz,
break;
case RES_TXTATR_FTN:
- nDelMsg = RES_FOOTNOTE_DELETED;
+ static_cast<SwFmtFtn&>(pAttr->GetAttr())
+ .InvalidateFootnote();
break;
case RES_TXTATR_TOXMARK:
diff --git a/sw/source/core/inc/unofootnote.hxx b/sw/source/core/inc/unofootnote.hxx
index bc8d40bb6ffe..2a7643b31c62 100644
--- a/sw/source/core/inc/unofootnote.hxx
+++ b/sw/source/core/inc/unofootnote.hxx
@@ -66,14 +66,14 @@ protected:
virtual ~SwXFootnote();
- SwXFootnote(SwDoc & rDoc, const SwFmtFtn & rFmt);
+ SwXFootnote(SwDoc & rDoc, SwFmtFtn & rFmt);
public:
SwXFootnote(const bool bEndnote);
static SwXFootnote *
- CreateXFootnote(SwDoc & rDoc, SwFmtFtn const& rFootnoteFmt);
+ CreateXFootnote(SwDoc & rDoc, SwFmtFtn & rFootnoteFmt);
/// may return 0
static SwXFootnote *
GetXFootnote(SwModify const& rUnoCB, SwFmtFtn const& rFootnoteFmt);
diff --git a/sw/source/core/txtnode/atrftn.cxx b/sw/source/core/txtnode/atrftn.cxx
index f7f2aa555860..9ada9dfbb567 100644
--- a/sw/source/core/txtnode/atrftn.cxx
+++ b/sw/source/core/txtnode/atrftn.cxx
@@ -17,12 +17,13 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <fmtftn.hxx>
+
#include <doc.hxx>
#include <DocumentContentOperationsManager.hxx>
#include <IDocumentStylePoolAccess.hxx>
#include <cntfrm.hxx>
#include <pagefrm.hxx>
-#include <fmtftn.hxx>
#include <txtftn.hxx>
#include <ftnidx.hxx>
#include <ftninfo.hxx>
@@ -115,10 +116,11 @@ namespace {
}
SwFmtFtn::SwFmtFtn( bool bEndNote )
- : SfxPoolItem( RES_TXTATR_FTN ),
- m_pTxtAttr( 0 ),
- m_nNumber( 0 ),
- m_bEndNote( bEndNote )
+ : SfxPoolItem( RES_TXTATR_FTN )
+ , SwModify(0)
+ , m_pTxtAttr(0)
+ , m_nNumber(0)
+ , m_bEndNote(bEndNote)
{
}
@@ -139,6 +141,13 @@ SfxPoolItem* SwFmtFtn::Clone( SfxItemPool* ) const
return pNew;
}
+void SwFmtFtn::InvalidateFootnote()
+{
+ SwPtrMsgPoolItem const item(RES_REMOVE_UNO_OBJECT,
+ &static_cast<SwModify&>(*this)); // cast to base class (void*)
+ NotifyClients(&item, &item);
+}
+
void SwFmtFtn::SetEndNote( bool b )
{
if ( b != m_bEndNote )
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index 4d84c9110d22..2ca92bab52fc 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -1133,7 +1133,7 @@ void SwTxtNode::DestroyAttr( SwTxtAttr* pAttr )
case RES_TXTATR_FTN:
((SwTxtFtn*)pAttr)->SetStartNode( 0 );
- nDelMsg = RES_FOOTNOTE_DELETED;
+ static_cast<SwFmtFtn&>(pAttr->GetAttr()).InvalidateFootnote();
break;
case RES_TXTATR_FIELD:
diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx
index 4f3a825330b3..36fd4bae86d2 100644
--- a/sw/source/core/unocore/unocoll.cxx
+++ b/sw/source/core/unocore/unocoll.cxx
@@ -1835,7 +1835,8 @@ uno::Any SwXFootnotes::getByIndex(sal_Int32 nIndex)
if(nCount == nIndex)
{
- xRef = SwXFootnote::CreateXFootnote(*GetDoc(), rFtn);
+ xRef = SwXFootnote::CreateXFootnote(*GetDoc(),
+ const_cast<SwFmtFtn&>(rFtn));
aRet <<= xRef;
break;
}
@@ -1864,7 +1865,7 @@ sal_Bool SwXFootnotes::hasElements(void) throw( uno::RuntimeException, std::exce
Reference<XFootnote> SwXFootnotes::GetObject( SwDoc& rDoc, const SwFmtFtn& rFmt )
{
- return SwXFootnote::CreateXFootnote(rDoc, rFmt);
+ return SwXFootnote::CreateXFootnote(rDoc, const_cast<SwFmtFtn&>(rFmt));
}
OUString SwXReferenceMarks::getImplementationName(void) throw( RuntimeException, std::exception )
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx
index a80c496589bd..6ea70b4a9dc8 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -607,7 +607,8 @@ bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry
if( pAny )
{
const uno::Reference< text::XFootnote > xFootnote =
- SwXFootnote::CreateXFootnote(*rPam.GetDoc(), rFtn);
+ SwXFootnote::CreateXFootnote(*rPam.GetDoc(),
+ const_cast<SwFmtFtn&>(rFtn));
*pAny <<= xFootnote;
}
}
diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx
index 1aab582abc8a..158e7292f699 100644
--- a/sw/source/core/unocore/unoftn.cxx
+++ b/sw/source/core/unocore/unoftn.cxx
@@ -57,9 +57,9 @@ public:
OUString m_sLabel;
Impl( SwXFootnote & rThis,
- SwDoc *const pDoc, SwFmtFtn const*const pFootnote,
+ SwFmtFtn *const pFootnote,
const bool bIsEndnote)
- : SwClient((pDoc) ? pDoc->GetUnoCallBack() : 0)
+ : SwClient(pFootnote)
, m_rThis(rThis)
, m_bIsEndnote(bIsEndnote)
, m_EventListeners(m_Mutex)
@@ -108,30 +108,17 @@ void SwXFootnote::Impl::Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew)
{
Invalidate();
}
- else if (pOld)
- {
- switch (pOld->Which())
- {
- case RES_FOOTNOTE_DELETED:
- if (static_cast<const void*>(m_pFmtFtn) ==
- static_cast<const SwPtrMsgPoolItem *>(pOld)->pObject)
- {
- Invalidate();
- }
- break;
- }
- }
}
SwXFootnote::SwXFootnote(const bool bEndnote)
: SwXText(0, CURSOR_FOOTNOTE)
- , m_pImpl( new SwXFootnote::Impl(*this, 0, 0, bEndnote) )
+ , m_pImpl( new SwXFootnote::Impl(*this, 0, bEndnote) )
{
}
-SwXFootnote::SwXFootnote(SwDoc & rDoc, const SwFmtFtn& rFmt)
+SwXFootnote::SwXFootnote(SwDoc & rDoc, SwFmtFtn & rFmt)
: SwXText(& rDoc, CURSOR_FOOTNOTE)
- , m_pImpl( new SwXFootnote::Impl(*this, &rDoc, &rFmt, rFmt.IsEndNote()) )
+ , m_pImpl( new SwXFootnote::Impl(*this, &rFmt, rFmt.IsEndNote()) )
{
}
@@ -152,10 +139,10 @@ SwXFootnote::GetXFootnote(
}
SwXFootnote *
-SwXFootnote::CreateXFootnote(SwDoc & rDoc, SwFmtFtn const& rFootnoteFmt)
+SwXFootnote::CreateXFootnote(SwDoc & rDoc, SwFmtFtn & rFootnoteFmt)
{
SwXFootnote *const pXFootnote(
- GetXFootnote(*rDoc.GetUnoCallBack(), rFootnoteFmt));
+ GetXFootnote(rFootnoteFmt, rFootnoteFmt));
return (pXFootnote)
? pXFootnote
: new SwXFootnote(rDoc, rFootnoteFmt);
@@ -335,7 +322,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
{
const SwFmtFtn& rFtn = pTxtAttr->GetFtn();
m_pImpl->m_pFmtFtn = &rFtn;
- pNewDoc->GetUnoCallBack()->Add(m_pImpl.get());
+ const_cast<SwFmtFtn*>(m_pImpl->m_pFmtFtn)->Add(m_pImpl.get());
// force creation of sequence id - is used for references
if (pNewDoc->IsInReading())
{
diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx
index f23768031ba2..e1b4615a3379 100644
--- a/sw/source/core/unocore/unoobj2.cxx
+++ b/sw/source/core/unocore/unoobj2.cxx
@@ -1238,7 +1238,8 @@ CreateParentXText(SwDoc & rDoc, const SwPosition& rPos)
if (pSttNode == pTxtFtn->GetStartNode()->GetNode().
FindSttNodeByType(SwFootnoteStartNode))
{
- xParentText = SwXFootnote::CreateXFootnote(rDoc, rFtn);
+ xParentText = SwXFootnote::CreateXFootnote(rDoc,
+ const_cast<SwFmtFtn&>(rFtn));
break;
}
}