LibreOffice Module framework (master) 1
undomanagerhelper.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#ifndef INCLUDED_FRAMEWORK_UNDOMANAGERHELPER_HXX
21#define INCLUDED_FRAMEWORK_UNDOMANAGERHELPER_HXX
22
23#include <framework/fwkdllapi.h>
24#include <com/sun/star/uno/Sequence.hxx>
25#include <com/sun/star/uno/Reference.hxx>
26
27#include <memory>
28
29namespace com::sun::star::document { class XUndoAction; }
30namespace com::sun::star::document { class XUndoManager; }
31namespace com::sun::star::document { class XUndoManagerListener; }
32namespace com::sun::star::util { class XModifyListener; }
33namespace framework { class IMutex; }
34
35class SfxUndoManager;
36
37
38namespace framework
39{
40
41
42 //= IMutexGuard
43
45 {
46 public:
49 virtual void clear() = 0;
50
55 virtual IMutex& getGuardedMutex() = 0;
56
57 protected:
59 };
60
61
62 //= IUndoManagerImplementation
63
65 {
66 public:
76
79 virtual css::uno::Reference< css::document::XUndoManager >
80 getThis() = 0;
81
82 protected:
84 };
85
86
87 //= UndoManagerHelper
88
89 class UndoManagerHelper_Impl;
114 {
115 public:
116 UndoManagerHelper( IUndoManagerImplementation& i_undoManagerImpl );
118
119 // life time control
120 void disposing();
121
122 // XUndoManager equivalents
123 void enterUndoContext( const OUString& i_title, IMutexGuard& i_instanceLock );
124 void enterHiddenUndoContext( IMutexGuard& i_instanceLock );
125 void leaveUndoContext( IMutexGuard& i_instanceLock );
126 void addUndoAction( const css::uno::Reference< css::document::XUndoAction >& i_action, IMutexGuard& i_instanceLock );
127 void undo( IMutexGuard& i_instanceLock );
128 void redo( IMutexGuard& i_instanceLock );
129 bool isUndoPossible() const;
130 bool isRedoPossible() const;
131 OUString getCurrentUndoActionTitle() const;
132 OUString getCurrentRedoActionTitle() const;
133 css::uno::Sequence< OUString >
134 getAllUndoActionTitles() const;
135 css::uno::Sequence< OUString >
136 getAllRedoActionTitles() const;
137 void clear( IMutexGuard& i_instanceLock );
138 void clearRedo( IMutexGuard& i_instanceLock );
139 void reset( IMutexGuard& i_instanceLock );
140 void addUndoManagerListener( const css::uno::Reference< css::document::XUndoManagerListener >& i_listener );
141 void removeUndoManagerListener( const css::uno::Reference< css::document::XUndoManagerListener >& i_listener );
142
143 // XLockable, base of XUndoManager, equivalents
144 void lock();
145 void unlock();
146 bool isLocked();
147
148 // XModifyBroadcaster equivalents
149 void addModifyListener( const css::uno::Reference< css::util::XModifyListener >& i_listener );
150 void removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& i_listener );
151
152 private:
153 std::unique_ptr< UndoManagerHelper_Impl > m_xImpl;
154 };
155
156
157} // namespace framework
158
159
160#endif // INCLUDED_FRAMEWORK_UNDOMANAGERHELPER_HXX
161
162/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void clear()=0
clears the lock.
virtual IMutex & getGuardedMutex()=0
returns the mutex guarded by the instance.
Interface to support different mutex implementations in a generic way.
Definition: imutex.hxx:29
virtual css::uno::Reference< css::document::XUndoManager > getThis()=0
provides access to a UNO interface for the XUndoManager implementation.
virtual SfxUndoManager & getImplUndoManager()=0
returns the SfxUndoManager interface to the actual Undo stack
helper class for implementing an XUndoManager
std::unique_ptr< UndoManagerHelper_Impl > m_xImpl
#define FWK_DLLPUBLIC
Definition: fwkdllapi.h:19
std::shared_ptr< osl::Mutex > const & lock()
#define SAL_NO_VTABLE