Kaydet (Commit) b3394345 authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen Kaydeden (comit) Björn Michaelsen

UNO redline: uno SvtListener instead of SwClient

Change-Id: Ic580df179c6aa1dedc866cf0882c124d5b13fcb3
Reviewed-on: https://gerrit.libreoffice.org/68360
Tested-by: Jenkins
Reviewed-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@libreoffice.org>
üst 861e3220
......@@ -19,6 +19,7 @@
#ifndef INCLUDED_SW_INC_UNOREDLINE_HXX
#define INCLUDED_SW_INC_UNOREDLINE_HXX
#include <svl/listener.hxx>
#include "unotext.hxx"
#include "ndindex.hxx"
......@@ -59,16 +60,12 @@ public:
virtual sal_Bool SAL_CALL hasElements( ) override;
};
typedef
cppu::WeakImplHelper
<
css::container::XEnumerationAccess
>
SwXRedlineBaseClass;
class SwXRedline :
public SwXRedlineBaseClass,
public SwXText,
public SwClient
typedef cppu::WeakImplHelper<css::container::XEnumerationAccess> SwXRedlineBaseClass;
class SwXRedline
: public SwXRedlineBaseClass
, public SwXText
, public SvtListener
{
SwDoc* pDoc;
SwRangeRedline* pRedline;
......@@ -105,10 +102,19 @@ public:
virtual sal_Bool SAL_CALL hasElements( ) override;
const SwRangeRedline* GetRedline() const {return pRedline;}
protected:
//SwClient
virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override;
virtual void Notify( const SfxHint& ) override;
};
namespace sw
{
struct SW_DLLPUBLIC FindRedlineHint final: SfxHint
{
const SwRangeRedline& m_rRedline;
SwXRedline** m_ppXRedline;
FindRedlineHint(const SwRangeRedline& rRedline, SwXRedline** ppXRedline) : m_rRedline(rRedline), m_ppXRedline(ppXRedline) {}
};
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -348,7 +348,7 @@ SwXRedline::SwXRedline(SwRangeRedline& rRedline, SwDoc& rDoc) :
pDoc(&rDoc),
pRedline(&rRedline)
{
pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
StartListening(pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->GetNotifier());
}
SwXRedline::~SwXRedline()
......@@ -491,13 +491,15 @@ void SwXRedline::removeVetoableChangeListener(
{
}
void SwXRedline::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
void SwXRedline::Notify( const SfxHint& rHint )
{
ClientModify(this, pOld, pNew);
if(!GetRegisteredIn())
{
if(rHint.GetId() == SfxHintId::Dying)
{
pDoc = nullptr;
pRedline = nullptr;
} else if(auto pHint = dynamic_cast<const sw::FindRedlineHint*>(&rHint)) {
if(!*pHint->m_ppXRedline && &pHint->m_rRedline == GetRedline())
*pHint->m_ppXRedline = this;
}
}
......
......@@ -105,20 +105,12 @@ uno::Sequence< OUString > SwXRedlines::getSupportedServiceNames()
return uno::Sequence< OUString >();
}
beans::XPropertySet* SwXRedlines::GetObject( SwRangeRedline& rRedline, SwDoc& rDoc )
{
SwPageDesc* pStdDesc = rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD);
SwIterator<SwXRedline,SwPageDesc> aIter(*pStdDesc);
SwXRedline* pxRedline = aIter.First();
while(pxRedline)
{
if(pxRedline->GetRedline() == &rRedline)
break;
pxRedline = aIter.Next();
}
if( !pxRedline )
pxRedline = new SwXRedline(rRedline, rDoc);
return pxRedline;
beans::XPropertySet* SwXRedlines::GetObject( SwRangeRedline& rRedline, SwDoc& rDoc )
{
SwXRedline* pXRedline(nullptr);
sw::FindRedlineHint aHint(rRedline, &pXRedline);
rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->GetNotifier().Broadcast(aHint);
return pXRedline ? pXRedline : new SwXRedline(rRedline, rDoc);
}
SwXRedlineEnumeration::SwXRedlineEnumeration(SwDoc& rDoc) :
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment