1 /* This file is part of the KDE project
2    Copyright 2005,2007 Stefan Nikolaus <stefan.nikolaus@kdemail.net>
3 
4    This library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Library General Public
6    License as published by the Free Software Foundation; either
7    version 2 of the License, or (at your option) any later version.
8 
9    This library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Library General Public License for more details.
13 
14    You should have received a copy of the GNU Library General Public License
15    along with this library; see the file COPYING.LIB.  If not, write to
16    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17    Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef CALLIGRA_SHEETS_MERGE_COMMAND
21 #define CALLIGRA_SHEETS_MERGE_COMMAND
22 
23 #include "AbstractRegionCommand.h"
24 
25 namespace Calligra
26 {
27 namespace Sheets
28 {
29 
30 class Selection;
31 
32 /**
33  * \class MergeCommand
34  * \ingroup Commands
35  * \brief Merges and splits the cells of a cell region.
36  */
37 class MergeCommand : public AbstractRegionCommand
38 {
39 public:
40     explicit MergeCommand(KUndo2Command *parent = 0);
41     ~MergeCommand() override;
42 
43     bool preProcessing() override;
44 
setReverse(bool reverse)45     void setReverse(bool reverse) override {
46         m_merge = !reverse;
47     }
setHorizontalMerge(bool state)48     void setHorizontalMerge(bool state) {
49         m_mergeHorizontal = state;
50     }
setVerticalMerge(bool state)51     void setVerticalMerge(bool state) {
52         m_mergeVertical = state;
53     }
54 
setSelection(Selection * selection)55     void setSelection(Selection *selection) {
56         m_selection = selection;
57     }
58 protected:
59     bool process(Element*) override;
60 
61     bool postProcessing() override;
62 
63     KUndo2MagicString name() const;
64 
65     bool m_merge;
66 private:
67     bool m_mergeHorizontal : 1;
68     bool m_mergeVertical   : 1;
69     AbstractRegionCommand* m_unmerger; // to restore old merging
70     Selection *m_selection;
71 };
72 
73 } // namespace Sheets
74 } // namespace Calligra
75 
76 #endif // CALLIGRA_SHEETS_MERGE_COMMAND
77