Line data Source code
1 : /*
2 : * This file is part of the LibreOffice project.
3 : *
4 : * This Source Code Form is subject to the terms of the Mozilla Public
5 : * License, v. 2.0. If a copy of the MPL was not distributed with this
6 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 : *
8 : * This file incorporates work covered by the following license notice:
9 : *
10 : * Licensed to the Apache Software Foundation (ASF) under one or more
11 : * contributor license agreements. See the NOTICE file distributed
12 : * with this work for additional information regarding copyright
13 : * ownership. The ASF licenses this file to you under the Apache
14 : * License, Version 2.0 (the "License"); you may not use this file
15 : * except in compliance with the License. You may obtain a copy of
16 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
17 : */
18 : #ifndef _SDR_UNDOMANAGER_HXX
19 : #define _SDR_UNDOMANAGER_HXX
20 :
21 : #include "svx/svxdllapi.h"
22 : #include <sal/types.h>
23 : #include <editeng/editund2.hxx>
24 : #include <tools/link.hxx>
25 :
26 : //////////////////////////////////////////////////////////////////////////////
27 :
28 : class SVX_DLLPUBLIC SdrUndoManager : public EditUndoManager
29 : {
30 : private:
31 : using EditUndoManager::Undo;
32 : using EditUndoManager::Redo;
33 :
34 : Link maEndTextEditHdl;
35 : SfxUndoAction* mpLastUndoActionBeforeTextEdit;
36 : bool mbEndTextEditTriggeredFromUndo;
37 :
38 : protected:
39 : // call to check for TextEdit active
40 : bool isTextEditActive() const;
41 :
42 : public:
43 : SdrUndoManager(sal_uInt16 nMaxUndoActionCount = 20);
44 : virtual ~SdrUndoManager();
45 :
46 : /// react depending on edit mode and if no more undo is possible
47 : virtual bool Undo();
48 : virtual bool Redo();
49 :
50 : // Call for the view which starts the interactive text edit. Use link to
51 : // activate (start text edit) and empty link to reset (end text edit). On
52 : // reset all text edit actions will be removed from this undo manager to
53 : // restore the state before activation
54 : void SetEndTextEditHdl(const Link& rLink);
55 :
56 : // check from outside if we are inside a callback for ending text edit. This
57 : // is needed to detect inside end text edit if it is a regular one or triggered
58 : // by a last undo during text edit
59 0 : bool isEndTextEditTriggeredFromUndo() { return mbEndTextEditTriggeredFromUndo; }
60 : };
61 :
62 : //////////////////////////////////////////////////////////////////////////////
63 :
64 : #endif //_SDR_UNDOMANAGER_HXX
65 : // eof
|