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 #ifndef CALLIGRA_SHEETS_STYLE_COMMAND
21 #define CALLIGRA_SHEETS_STYLE_COMMAND
22 
23 #include <QPair>
24 #include <QPen>
25 
26 #include "AbstractRegionCommand.h"
27 #include "Style.h"
28 
29 namespace Calligra
30 {
31 namespace Sheets
32 {
33 class Style;
34 
35 /**
36  * \class StyleCommand
37  * \ingroup Commands
38  * \brief Manipulates the style of a cell region.
39  */
40 class StyleCommand : public AbstractRegionCommand
41 {
42 public:
43     explicit StyleCommand(KUndo2Command *parent = 0);
44     ~StyleCommand() override;
45 
46     // SetSelectionFontWorker
47     // SetSelectionSizeWorker
setFontFamily(const QString & font)48     void setFontFamily(const QString& font) {
49         m_style->setFontFamily(font);
50     }
setFontSize(int size)51     void setFontSize(int size) {
52         m_style->setFontSize(size);
53     }
setFontBold(bool bold)54     void setFontBold(bool bold) {
55         m_style->setFontBold(bold);
56     }
setFontItalic(uint italic)57     void setFontItalic(uint italic) {
58         m_style->setFontItalic(italic);
59     }
setFontStrike(uint strike)60     void setFontStrike(uint strike) {
61         m_style->setFontStrikeOut(strike);
62     }
setFontUnderline(uint underline)63     void setFontUnderline(uint underline) {
64         m_style->setFontUnderline(underline);
65     }
66     // SetSelectionAngleWorker
setAngle(int angle)67     void setAngle(int angle) {
68         m_style->setAngle(angle);
69     }
70     // SetSelectionTextColorWorker
setFontColor(const QColor & textColor)71     void setFontColor(const QColor& textColor) {
72         m_style->setFontColor(textColor);
73     }
74     // SetSelectionBgColorWorker
setBackgroundColor(const QColor & bgColor)75     void setBackgroundColor(const QColor& bgColor) {
76         m_style->setBackgroundColor(bgColor);
77     }
78     // SetSelectionBorderAllWorker
setTopBorderPen(const QPen & pen)79     void setTopBorderPen(const QPen& pen) {
80         m_style->setTopBorderPen(pen);
81     }
setBottomBorderPen(const QPen & pen)82     void setBottomBorderPen(const QPen& pen) {
83         m_style->setBottomBorderPen(pen);
84     }
setLeftBorderPen(const QPen & pen)85     void setLeftBorderPen(const QPen& pen) {
86         m_style->setLeftBorderPen(pen);
87     }
setRightBorderPen(const QPen & pen)88     void setRightBorderPen(const QPen& pen) {
89         m_style->setRightBorderPen(pen);
90     }
setHorizontalPen(const QPen & pen)91     void setHorizontalPen(const QPen& pen) {
92         m_horizontalPen = pen; m_horizontalPenChanged = true;
93     }
setVerticalPen(const QPen & pen)94     void setVerticalPen(const QPen& pen) {
95         m_verticalPen = pen; m_verticalPenChanged = true;
96     }
setFallDiagonalPen(const QPen & pen)97     void setFallDiagonalPen(const QPen& pen) {
98         m_style->setFallDiagonalPen(pen);
99     }
setGoUpDiagonalPen(const QPen & pen)100     void setGoUpDiagonalPen(const QPen& pen) {
101         m_style->setGoUpDiagonalPen(pen);
102     }
103     // SetSelectionAlignWorker
setHorizontalAlignment(Style::HAlign align)104     void setHorizontalAlignment(Style::HAlign align) {
105         m_style->setHAlign(align);
106     }
107     // SetSelectionAlignWorker
setVerticalAlignment(Style::VAlign align)108     void setVerticalAlignment(Style::VAlign align) {
109         m_style->setVAlign(align);
110     }
111 
setBackgroundBrush(const QBrush & brush)112     void setBackgroundBrush(const QBrush& brush) {
113         m_style->setBackgroundBrush(brush);
114     }
setIndentation(double indent)115     void setIndentation(double indent) {
116         m_style->setIndentation(indent);
117     }
setMultiRow(bool multiRow)118     void setMultiRow(bool multiRow) {
119         m_style->setWrapText(multiRow);
120     }
setVerticalText(bool verticalText)121     void setVerticalText(bool verticalText) {
122         m_style->setVerticalText(verticalText);
123     }
setShrinkToFit(bool shrink)124     void setShrinkToFit(bool shrink) {
125         m_style->setShrinkToFit(shrink);
126     }
setDontPrintText(bool dontPrintText)127     void setDontPrintText(bool dontPrintText) {
128         m_style->setDontPrintText(dontPrintText);
129     }
setNotProtected(bool notProtected)130     void setNotProtected(bool notProtected) {
131         m_style->setNotProtected(notProtected);
132     }
setHideAll(bool hideAll)133     void setHideAll(bool hideAll) {
134         m_style->setHideAll(hideAll);
135     }
setHideFormula(bool hideFormula)136     void setHideFormula(bool hideFormula) {
137         m_style->setHideFormula(hideFormula);
138     }
setPrefix(const QString & prefix)139     void setPrefix(const QString& prefix) {
140         m_style->setPrefix(prefix);
141     }
setPostfix(const QString & postfix)142     void setPostfix(const QString& postfix) {
143         m_style->setPostfix(postfix);
144     }
setPrecision(int precision)145     void setPrecision(int precision) {
146         m_style->setPrecision(precision);
147     }
setFloatFormat(Style::FloatFormat floatFormat)148     void setFloatFormat(Style::FloatFormat floatFormat) {
149         m_style->setFloatFormat(floatFormat);
150     }
setFloatColor(Style::FloatColor floatColor)151     void setFloatColor(Style::FloatColor floatColor) {
152         m_style->setFloatColor(floatColor);
153     }
setFormatType(Format::Type formatType)154     void setFormatType(Format::Type formatType) {
155         m_style->setFormatType(formatType);
156     }
setCurrency(const Currency & currency)157     void setCurrency(const Currency& currency) {
158         m_style->setCurrency(currency);
159     }
setParentName(const QString & name)160     void setParentName(const QString& name) {
161         m_style->setParentName(name);
162     }
setDefault()163     void setDefault() {
164         m_style->setDefault();
165     }
setCustomFormat(const QString & format)166     void setCustomFormat(const QString &format) {
167         m_style->setCustomFormat(format);
168     }
169 
170 protected:
171     bool process(Element*) override;
172 
173     bool preProcessing() override;
174     bool mainProcessing() override;
175     bool postProcessing() override;
176 
177 private:
178     QPen m_horizontalPen;
179     QPen m_verticalPen;
180     bool m_horizontalPenChanged;
181     bool m_verticalPenChanged;
182 
183     Style* m_style;
184     QList< QPair<QRectF, SharedSubStyle> > m_undoData;
185 };
186 
187 } // namespace Sheets
188 } // namespace Calligra
189 
190 #endif // CALLIGRA_SHEETS_STYLE_COMMAND
191