27#include <sfx2/sfxsids.hrc>
28#include <com/sun/star/lang/NoSupportException.hpp>
29#include <com/sun/star/lang/NotInitializedException.hpp>
40 using ::com::sun::star::uno::Reference;
41 using ::com::sun::star::uno::XInterface;
42 using ::com::sun::star::uno::Sequence;
43 using ::com::sun::star::document::XUndoAction;
44 using ::com::sun::star::lang::NotInitializedException;
45 using ::com::sun::star::document::XUndoManagerListener;
46 using ::com::sun::star::document::XUndoManager;
47 using ::com::sun::star::lang::NoSupportException;
48 using ::com::sun::star::frame::XModel;
73 virtual Reference< XUndoManager >
getThis()
override;
89 if ( pObjectShell !=
nullptr )
92 throw NotInitializedException( OUString(), i_baseModel );
100 ENSURE_OR_THROW(
pUndoManager !=
nullptr,
"DocumentUndoManager_Impl::getImplUndoManager: no access to the doc's UndoManager implementation!" );
102#if OSL_DEBUG_LEVEL > 0
107 "DocumentUndoManager_Impl::getImplUndoManager: the UndoManager changed meanwhile - what about our listener?" );
116 return static_cast< XUndoManager*
>( &
rAntiImpl );
125 ENSURE_OR_THROW( pDocShell !=
nullptr,
"lcl_invalidateUndo: no access to the doc shell!" );
149 virtual ~SolarMutexFacade() {}
151 virtual void acquire()
override
156 virtual void release()
override
168 explicit UndoManagerGuard( DocumentUndoManager& i_undoManager )
173 virtual ~UndoManagerGuard()
177 UndoManagerGuard(
const UndoManagerGuard&) =
delete;
178 UndoManagerGuard& operator=(
const UndoManagerGuard&) =
delete;
180 virtual void clear()
override
185 virtual ::framework::IMutex& getGuardedMutex()
override
221 return m_pImpl->getImplUndoManager().IsInListAction();
227 OWeakObject::acquire();
235 OWeakObject::release();
242 UndoManagerGuard aGuard( *
this );
243 m_pImpl->aUndoHelper.enterUndoContext( i_title, aGuard );
245 m_pImpl->invalidateXDo_nolck();
252 UndoManagerGuard aGuard( *
this );
253 m_pImpl->aUndoHelper.enterHiddenUndoContext( aGuard );
255 m_pImpl->invalidateXDo_nolck();
262 UndoManagerGuard aGuard( *
this );
263 m_pImpl->aUndoHelper.leaveUndoContext( aGuard );
265 m_pImpl->invalidateXDo_nolck();
272 UndoManagerGuard aGuard( *
this );
273 m_pImpl->aUndoHelper.addUndoAction( i_action, aGuard );
275 m_pImpl->invalidateXDo_nolck();
282 UndoManagerGuard aGuard( *
this );
283 m_pImpl->aUndoHelper.undo( aGuard );
285 m_pImpl->invalidateXDo_nolck();
292 UndoManagerGuard aGuard( *
this );
293 m_pImpl->aUndoHelper.redo( aGuard );
295 m_pImpl->invalidateXDo_nolck();
301 UndoManagerGuard aGuard( *
this );
302 return m_pImpl->aUndoHelper.isUndoPossible();
308 UndoManagerGuard aGuard( *
this );
309 return m_pImpl->aUndoHelper.isRedoPossible();
315 UndoManagerGuard aGuard( *
this );
316 return m_pImpl->aUndoHelper.getCurrentUndoActionTitle();
322 UndoManagerGuard aGuard( *
this );
323 return m_pImpl->aUndoHelper.getCurrentRedoActionTitle();
329 UndoManagerGuard aGuard( *
this );
330 return m_pImpl->aUndoHelper.getAllUndoActionTitles();
336 UndoManagerGuard aGuard( *
this );
337 return m_pImpl->aUndoHelper.getAllRedoActionTitles();
344 UndoManagerGuard aGuard( *
this );
345 m_pImpl->aUndoHelper.clear( aGuard );
347 m_pImpl->invalidateXDo_nolck();
354 UndoManagerGuard aGuard( *
this );
355 m_pImpl->aUndoHelper.clearRedo( aGuard );
357 m_pImpl->invalidateXDo_nolck();
364 UndoManagerGuard aGuard( *
this );
365 m_pImpl->aUndoHelper.reset( aGuard );
367 m_pImpl->invalidateXDo_nolck();
373 UndoManagerGuard aGuard( *
this );
380 UndoManagerGuard aGuard( *
this );
387 UndoManagerGuard aGuard( *
this );
388 return m_pImpl->aUndoHelper.isLocked();
394 UndoManagerGuard aGuard( *
this );
395 return m_pImpl->aUndoHelper.addUndoManagerListener( i_listener );
401 UndoManagerGuard aGuard( *
this );
402 return m_pImpl->aUndoHelper.removeUndoManagerListener( i_listener );
408 UndoManagerGuard aGuard( *
this );
415 throw NoSupportException( OUString(),
m_pImpl->getThis() );
static comphelper::SolarMutex & GetSolarMutex()
SfxObjectShell * GetObjectShell() const
void Invalidate(sal_uInt16 nId)
base class for sub components of an SfxBaseModel, which share their ref count and lifetime with the S...
const SfxBaseModel & getBaseModel() const
virtual SfxUndoManager * GetUndoManager()
Each Subclass of SfxShell can have a <SfxUndoManager>.
SfxBindings & GetBindings()
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetNext(const SfxViewFrame &rPrev, const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
sal_uInt32 release(bool bUnlockAll=false)
void acquire(sal_uInt32 nLockCount=1)
virtual sal_Bool SAL_CALL isUndoPossible() override
virtual void SAL_CALL redo() override
virtual void SAL_CALL clear() override
virtual css::uno::Sequence< OUString > SAL_CALL getAllRedoActionTitles() override
virtual void SAL_CALL undo() override
virtual OUString SAL_CALL getCurrentUndoActionTitle() override
virtual void SAL_CALL enterHiddenUndoContext() override
virtual void SAL_CALL clearRedo() override
virtual void SAL_CALL setParent(const css::uno::Reference< css::uno::XInterface > &Parent) override
virtual void SAL_CALL addUndoManagerListener(const css::uno::Reference< css::document::XUndoManagerListener > &i_listener) override
virtual void SAL_CALL release() noexcept override
virtual void SAL_CALL leaveUndoContext() override
virtual void SAL_CALL enterUndoContext(const OUString &i_title) override
bool isInContext() const
determines whether we have an open Undo context.
std::unique_ptr< DocumentUndoManager_Impl > m_pImpl
virtual OUString SAL_CALL getCurrentRedoActionTitle() override
virtual void SAL_CALL unlock() override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent() override
virtual void SAL_CALL removeUndoManagerListener(const css::uno::Reference< css::document::XUndoManagerListener > &i_listener) override
DocumentUndoManager(SfxBaseModel &i_document)
virtual void SAL_CALL reset() override
virtual sal_Bool SAL_CALL isRedoPossible() override
virtual void SAL_CALL lock() override
virtual css::uno::Sequence< OUString > SAL_CALL getAllUndoActionTitles() override
virtual ~DocumentUndoManager() override
virtual void SAL_CALL addUndoAction(const css::uno::Reference< css::document::XUndoAction > &i_action) override
virtual void SAL_CALL acquire() noexcept override
virtual sal_Bool SAL_CALL isLocked() override
#define ENSURE_OR_THROW(c, m)
#define ENSURE_OR_RETURN_VOID(c, m)
SolarMutexFacade m_solarMutexFacade
::framework::UndoManagerHelper aUndoHelper
virtual SfxUndoManager & getImplUndoManager() override
virtual Reference< XUndoManager > getThis() override
SfxUndoManager * pUndoManager
static SfxUndoManager * impl_retrieveUndoManager(SfxBaseModel &i_baseModel)
DocumentUndoManager & rAntiImpl
virtual ~DocumentUndoManager_Impl()
DocumentUndoManager_Impl(DocumentUndoManager &i_antiImpl)
void invalidateXDo_nolck()