1 /* This file is part of the KDE project
2    Copyright 2005-2006 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 // Local
21 #include "PrecisionCommand.h"
22 
23 #include <KLocalizedString>
24 
25 #include "Cell.h"
26 #include "CellStorage.h"
27 #include "Sheet.h"
28 #include "Style.h"
29 
30 using namespace Calligra::Sheets;
31 
PrecisionCommand()32 PrecisionCommand::PrecisionCommand()
33         : AbstractRegionCommand()
34 {
35     setText(kundo2_i18n("Increase Precision"));
36 }
37 
mainProcessing()38 bool PrecisionCommand::mainProcessing()
39 {
40     Style style;
41     if (!m_reverse) {
42         // increase the precision
43         style.setPrecision(1);
44     } else { // m_reverse
45         // decrease the precision
46         style.setPrecision(-1);
47     }
48     m_sheet->cellStorage()->setStyle(*this, style);
49     return true;
50 }
51 
postProcessing()52 bool PrecisionCommand::postProcessing()
53 {
54     return true;
55 }
56 
setReverse(bool reverse)57 void PrecisionCommand::setReverse(bool reverse)
58 {
59     AbstractRegionCommand::setReverse(reverse);
60     if (!m_reverse)
61         setText(kundo2_i18n("Increase Precision"));
62     else
63         setText(kundo2_i18n("Decrease Precision"));
64 }
65