diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-05-29 09:58:42 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-05-29 11:02:45 +0100 |
commit | c24272c7972e0cbb51e7f104e356973ecb03c352 (patch) | |
tree | c8e3c0dd30daabae61adbdf9e70e70a1fc8b551c /sfx2/source/inc | |
parent | a65b6a4626d85880a4f39bda177473df91cf5369 (diff) |
the dubious SfxModelSubComponent and friends aren't used outside sfx2
so move out of the globals headers and drop their public visibility
markup
Change-Id: Ie0a852c962a9d05488022397e83152d1c73cfa29
Diffstat (limited to 'sfx2/source/inc')
-rw-r--r-- | sfx2/source/inc/docundomanager.hxx | 74 |
1 files changed, 73 insertions, 1 deletions
diff --git a/sfx2/source/inc/docundomanager.hxx b/sfx2/source/inc/docundomanager.hxx index 044d0fb7ca9d..f970bed57d71 100644 --- a/sfx2/source/inc/docundomanager.hxx +++ b/sfx2/source/inc/docundomanager.hxx @@ -29,12 +29,84 @@ #include <boost/scoped_ptr.hpp> #include <boost/noncopyable.hpp> +/** base class for sub components of an SfxBaseModel, which share their ref count and lifetime with the SfxBaseModel +*/ +class SfxModelSubComponent +{ +public: + /** checks whether the instance is alive, i.e. properly initialized, and not yet disposed + */ + void MethodEntryCheck() + { + m_rModel.MethodEntryCheck( true ); + } -namespace sfx2 + // called when the SfxBaseModel which the component is superordinate of is being disposed + virtual void disposing(); + +protected: + SfxModelSubComponent( SfxBaseModel& i_model ) + :m_rModel( i_model ) + { + } + virtual ~SfxModelSubComponent(); + + void acquireModel() { m_rModel.acquire(); } + void releaseModel() { m_rModel.release(); } + + bool isDisposed() const { return m_rModel.IsDisposed(); } + +protected: + const SfxBaseModel& getBaseModel() const { return m_rModel; } + SfxBaseModel& getBaseModel() { return m_rModel; } + + ::osl::Mutex& getMutex() { return m_rModel.getMutex(); } + +private: + SfxBaseModel& m_rModel; +}; + +class SfxModelGuard { +public: + enum AllowedModelState + { + // not yet initialized + E_INITIALIZING, + // fully alive, i.e. initialized, and not yet disposed + E_FULLY_ALIVE + }; + SfxModelGuard( SfxBaseModel& i_rModel, const AllowedModelState i_eState = E_FULLY_ALIVE ) + : m_aGuard() + { + i_rModel.MethodEntryCheck( i_eState != E_INITIALIZING ); + } + SfxModelGuard( SfxModelSubComponent& i_rSubComponent ) + :m_aGuard() + { + i_rSubComponent.MethodEntryCheck(); + } + ~SfxModelGuard() + { + } + void reset() + { + m_aGuard.reset(); + } + void clear() + { + m_aGuard.clear(); + } + +private: + SolarMutexResettableGuard m_aGuard; +}; + +namespace sfx2 +{ //= DocumentUndoManager typedef ::cppu::WeakImplHelper1 <css::document::XUndoManager> DocumentUndoManager_Base; |