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

UNO Styles: uno SvtListener instead of SwClient

Change-Id: I173f8e2e74d4892f259fb62b623cad87523bc990
Reviewed-on: https://gerrit.libreoffice.org/66334
Tested-by: Jenkins
Reviewed-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@libreoffice.org>
üst 14087d3e
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#ifndef INCLUDED_SW_INC_UNOSTYLE_HXX #ifndef INCLUDED_SW_INC_UNOSTYLE_HXX
#define INCLUDED_SW_INC_UNOSTYLE_HXX #define INCLUDED_SW_INC_UNOSTYLE_HXX
#include <svl/listener.hxx>
#include <svl/style.hxx> #include <svl/style.hxx>
#include "unocoll.hxx" #include "unocoll.hxx"
#include "tblafmt.hxx" #include "tblafmt.hxx"
...@@ -131,14 +132,11 @@ public: ...@@ -131,14 +132,11 @@ public:
}; };
// access to a family of automatic styles (character or paragraph or ...) // access to a family of automatic styles (character or paragraph or ...)
class SwXAutoStyleFamily : public cppu::WeakImplHelper< css::style::XAutoStyleFamily >, class SwXAutoStyleFamily : public cppu::WeakImplHelper< css::style::XAutoStyleFamily >, public SvtListener
public SwClient
{ {
SwDocShell *m_pDocShell; SwDocShell *m_pDocShell;
IStyleAccess::SwAutoStyleFamily const m_eFamily; IStyleAccess::SwAutoStyleFamily const m_eFamily;
protected:
virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override;
public: public:
SwXAutoStyleFamily(SwDocShell* pDocShell, IStyleAccess::SwAutoStyleFamily eFamily); SwXAutoStyleFamily(SwDocShell* pDocShell, IStyleAccess::SwAutoStyleFamily eFamily);
...@@ -154,10 +152,10 @@ public: ...@@ -154,10 +152,10 @@ public:
virtual css::uno::Type SAL_CALL getElementType( ) override; virtual css::uno::Type SAL_CALL getElementType( ) override;
virtual sal_Bool SAL_CALL hasElements( ) override; virtual sal_Bool SAL_CALL hasElements( ) override;
virtual void Notify( const SfxHint&) override;
}; };
class SwXAutoStylesEnumerator : public cppu::WeakImplHelper< css::container::XEnumeration >, class SwXAutoStylesEnumerator : public cppu::WeakImplHelper< css::container::XEnumeration >, public SvtListener
public SwClient
{ {
std::unique_ptr<SwAutoStylesEnumImpl> m_pImpl; std::unique_ptr<SwAutoStylesEnumImpl> m_pImpl;
public: public:
...@@ -167,8 +165,8 @@ public: ...@@ -167,8 +165,8 @@ public:
//XEnumeration //XEnumeration
virtual sal_Bool SAL_CALL hasMoreElements( ) override; virtual sal_Bool SAL_CALL hasMoreElements( ) override;
virtual css::uno::Any SAL_CALL nextElement( ) override; virtual css::uno::Any SAL_CALL nextElement( ) override;
protected:
virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; virtual void Notify( const SfxHint&) override;
}; };
// an automatic style // an automatic style
...@@ -178,7 +176,7 @@ class SwXAutoStyle : public cppu::WeakImplHelper ...@@ -178,7 +176,7 @@ class SwXAutoStyle : public cppu::WeakImplHelper
css::beans::XPropertyState, css::beans::XPropertyState,
css::style::XAutoStyle css::style::XAutoStyle
>, >,
public SwClient public SvtListener
{ {
private: private:
std::shared_ptr<SfxItemSet> mpSet; std::shared_ptr<SfxItemSet> mpSet;
...@@ -224,8 +222,8 @@ public: ...@@ -224,8 +222,8 @@ public:
// Special // Special
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getProperties() override; virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getProperties() override;
protected:
virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; virtual void Notify( const SfxHint& ) override;
}; };
......
...@@ -3474,17 +3474,16 @@ SwXAutoStyleFamily::SwXAutoStyleFamily(SwDocShell* pDocSh, IStyleAccess::SwAutoS ...@@ -3474,17 +3474,16 @@ SwXAutoStyleFamily::SwXAutoStyleFamily(SwDocShell* pDocSh, IStyleAccess::SwAutoS
m_pDocShell( pDocSh ), m_eFamily(nFamily) m_pDocShell( pDocSh ), m_eFamily(nFamily)
{ {
// Register ourselves as a listener to the document (via the page descriptor) // Register ourselves as a listener to the document (via the page descriptor)
pDocSh->GetDoc()->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); StartListening(pDocSh->GetDoc()->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->GetNotifier());
} }
SwXAutoStyleFamily::~SwXAutoStyleFamily() SwXAutoStyleFamily::~SwXAutoStyleFamily()
{ {
} }
void SwXAutoStyleFamily::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) void SwXAutoStyleFamily::Notify(const SfxHint& rHint)
{ {
ClientModify(this, pOld, pNew); if(rHint.GetId() == SfxHintId::Dying)
if(!GetRegisteredIn())
m_pDocShell = nullptr; m_pDocShell = nullptr;
} }
...@@ -3772,20 +3771,17 @@ SwXAutoStylesEnumerator::SwXAutoStylesEnumerator( SwDoc* pDoc, IStyleAccess::SwA ...@@ -3772,20 +3771,17 @@ SwXAutoStylesEnumerator::SwXAutoStylesEnumerator( SwDoc* pDoc, IStyleAccess::SwA
: m_pImpl( new SwAutoStylesEnumImpl( pDoc, eFam ) ) : m_pImpl( new SwAutoStylesEnumImpl( pDoc, eFam ) )
{ {
// Register ourselves as a listener to the document (via the page descriptor) // Register ourselves as a listener to the document (via the page descriptor)
pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); StartListening(pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->GetNotifier());
} }
SwXAutoStylesEnumerator::~SwXAutoStylesEnumerator() SwXAutoStylesEnumerator::~SwXAutoStylesEnumerator()
{ {
} }
void SwXAutoStylesEnumerator::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) void SwXAutoStylesEnumerator::Notify( const SfxHint& rHint)
{ {
ClientModify(this, pOld, pNew); if(rHint.GetId() == SfxHintId::Dying)
if(!GetRegisteredIn())
{
m_pImpl.reset(); m_pImpl.reset();
}
} }
sal_Bool SwXAutoStylesEnumerator::hasMoreElements( ) sal_Bool SwXAutoStylesEnumerator::hasMoreElements( )
...@@ -3826,20 +3822,17 @@ SwXAutoStyle::SwXAutoStyle( ...@@ -3826,20 +3822,17 @@ SwXAutoStyle::SwXAutoStyle(
mrDoc(*pDoc) mrDoc(*pDoc)
{ {
// Register ourselves as a listener to the document (via the page descriptor) // Register ourselves as a listener to the document (via the page descriptor)
mrDoc.getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); //StartListening(mrDoc.getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->GetNotifier());
} }
SwXAutoStyle::~SwXAutoStyle() SwXAutoStyle::~SwXAutoStyle()
{ {
} }
void SwXAutoStyle::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) void SwXAutoStyle::Notify(const SfxHint& rHint)
{ {
ClientModify(this, pOld, pNew); if(rHint.GetId() == SfxHintId::Dying)
if(!GetRegisteredIn())
{
mpSet.reset(); mpSet.reset();
}
} }
uno::Reference< beans::XPropertySetInfo > SwXAutoStyle::getPropertySetInfo( ) uno::Reference< beans::XPropertySetInfo > SwXAutoStyle::getPropertySetInfo( )
......
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