File indexing completed on 2024-05-19 16:08:03
0001 /* This file is part of the KDE project 0002 Copyright 2005-2006 Stefan Nikolaus <stefan.nikolaus@kdemail.net> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef CALLIGRA_SHEETS_STYLE_COMMAND 0021 #define CALLIGRA_SHEETS_STYLE_COMMAND 0022 0023 #include <QPair> 0024 #include <QPen> 0025 0026 #include "AbstractRegionCommand.h" 0027 #include "Style.h" 0028 0029 namespace Calligra 0030 { 0031 namespace Sheets 0032 { 0033 class Style; 0034 0035 /** 0036 * \class StyleCommand 0037 * \ingroup Commands 0038 * \brief Manipulates the style of a cell region. 0039 */ 0040 class StyleCommand : public AbstractRegionCommand 0041 { 0042 public: 0043 explicit StyleCommand(KUndo2Command *parent = 0); 0044 ~StyleCommand() override; 0045 0046 // SetSelectionFontWorker 0047 // SetSelectionSizeWorker 0048 void setFontFamily(const QString& font) { 0049 m_style->setFontFamily(font); 0050 } 0051 void setFontSize(int size) { 0052 m_style->setFontSize(size); 0053 } 0054 void setFontBold(bool bold) { 0055 m_style->setFontBold(bold); 0056 } 0057 void setFontItalic(uint italic) { 0058 m_style->setFontItalic(italic); 0059 } 0060 void setFontStrike(uint strike) { 0061 m_style->setFontStrikeOut(strike); 0062 } 0063 void setFontUnderline(uint underline) { 0064 m_style->setFontUnderline(underline); 0065 } 0066 // SetSelectionAngleWorker 0067 void setAngle(int angle) { 0068 m_style->setAngle(angle); 0069 } 0070 // SetSelectionTextColorWorker 0071 void setFontColor(const QColor& textColor) { 0072 m_style->setFontColor(textColor); 0073 } 0074 // SetSelectionBgColorWorker 0075 void setBackgroundColor(const QColor& bgColor) { 0076 m_style->setBackgroundColor(bgColor); 0077 } 0078 // SetSelectionBorderAllWorker 0079 void setTopBorderPen(const QPen& pen) { 0080 m_style->setTopBorderPen(pen); 0081 } 0082 void setBottomBorderPen(const QPen& pen) { 0083 m_style->setBottomBorderPen(pen); 0084 } 0085 void setLeftBorderPen(const QPen& pen) { 0086 m_style->setLeftBorderPen(pen); 0087 } 0088 void setRightBorderPen(const QPen& pen) { 0089 m_style->setRightBorderPen(pen); 0090 } 0091 void setHorizontalPen(const QPen& pen) { 0092 m_horizontalPen = pen; m_horizontalPenChanged = true; 0093 } 0094 void setVerticalPen(const QPen& pen) { 0095 m_verticalPen = pen; m_verticalPenChanged = true; 0096 } 0097 void setFallDiagonalPen(const QPen& pen) { 0098 m_style->setFallDiagonalPen(pen); 0099 } 0100 void setGoUpDiagonalPen(const QPen& pen) { 0101 m_style->setGoUpDiagonalPen(pen); 0102 } 0103 // SetSelectionAlignWorker 0104 void setHorizontalAlignment(Style::HAlign align) { 0105 m_style->setHAlign(align); 0106 } 0107 // SetSelectionAlignWorker 0108 void setVerticalAlignment(Style::VAlign align) { 0109 m_style->setVAlign(align); 0110 } 0111 0112 void setBackgroundBrush(const QBrush& brush) { 0113 m_style->setBackgroundBrush(brush); 0114 } 0115 void setIndentation(double indent) { 0116 m_style->setIndentation(indent); 0117 } 0118 void setMultiRow(bool multiRow) { 0119 m_style->setWrapText(multiRow); 0120 } 0121 void setVerticalText(bool verticalText) { 0122 m_style->setVerticalText(verticalText); 0123 } 0124 void setShrinkToFit(bool shrink) { 0125 m_style->setShrinkToFit(shrink); 0126 } 0127 void setDontPrintText(bool dontPrintText) { 0128 m_style->setDontPrintText(dontPrintText); 0129 } 0130 void setNotProtected(bool notProtected) { 0131 m_style->setNotProtected(notProtected); 0132 } 0133 void setHideAll(bool hideAll) { 0134 m_style->setHideAll(hideAll); 0135 } 0136 void setHideFormula(bool hideFormula) { 0137 m_style->setHideFormula(hideFormula); 0138 } 0139 void setPrefix(const QString& prefix) { 0140 m_style->setPrefix(prefix); 0141 } 0142 void setPostfix(const QString& postfix) { 0143 m_style->setPostfix(postfix); 0144 } 0145 void setPrecision(int precision) { 0146 m_style->setPrecision(precision); 0147 } 0148 void setFloatFormat(Style::FloatFormat floatFormat) { 0149 m_style->setFloatFormat(floatFormat); 0150 } 0151 void setFloatColor(Style::FloatColor floatColor) { 0152 m_style->setFloatColor(floatColor); 0153 } 0154 void setFormatType(Format::Type formatType) { 0155 m_style->setFormatType(formatType); 0156 } 0157 void setCurrency(const Currency& currency) { 0158 m_style->setCurrency(currency); 0159 } 0160 void setParentName(const QString& name) { 0161 m_style->setParentName(name); 0162 } 0163 void setDefault() { 0164 m_style->setDefault(); 0165 } 0166 void setCustomFormat(const QString &format) { 0167 m_style->setCustomFormat(format); 0168 } 0169 0170 protected: 0171 bool process(Element*) override; 0172 0173 bool preProcessing() override; 0174 bool mainProcessing() override; 0175 bool postProcessing() override; 0176 0177 private: 0178 QPen m_horizontalPen; 0179 QPen m_verticalPen; 0180 bool m_horizontalPenChanged; 0181 bool m_verticalPenChanged; 0182 0183 Style* m_style; 0184 QList< QPair<QRectF, SharedSubStyle> > m_undoData; 0185 }; 0186 0187 } // namespace Sheets 0188 } // namespace Calligra 0189 0190 #endif // CALLIGRA_SHEETS_STYLE_COMMAND