File indexing completed on 2025-02-16 13:49:57
0001 0002 /* 0003 ** Header file for inclusion with words_xml2latex.c 0004 ** 0005 ** Copyright (C) 2002 Robert JACOLIN 0006 ** 0007 ** This library is free software; you can redistribute it and/or 0008 ** modify it under the terms of the GNU Library General Public 0009 ** License as published by the Free Software Foundation; either 0010 ** version 2 of the License, or (at your option) any later version. 0011 ** 0012 ** This library is distributed in the hope that it will be useful, 0013 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 ** Library General Public License for more details. 0016 ** 0017 ** To receive a copy of the GNU Library General Public License, write to the 0018 ** Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0019 * Boston, MA 02110-1301, USA. 0020 ** 0021 */ 0022 0023 #ifndef __CALLIGRA_SHEETS_LATEX_FORMAT_H__ 0024 #define __CALLIGRA_SHEETS_LATEX_FORMAT_H__ 0025 0026 #include <QTextStream> 0027 #include <QString> 0028 #include <QColor> 0029 #include "xmlparser.h" 0030 #include "pen.h" 0031 0032 /***********************************************************************/ 0033 /* Class: Format */ 0034 /***********************************************************************/ 0035 0036 class Column; 0037 class Row; 0038 0039 /** 0040 * This class describe a cell, row or column format. 0041 */ 0042 class Format: public XmlParser 0043 { 0044 long _align; 0045 long _alignY; 0046 QColor _bgColor; 0047 long _multirow; 0048 bool _verticalText; 0049 double _angle; 0050 QColor _brushColor; 0051 int _brushStyle; 0052 int _indent; 0053 bool _dontprinttext; 0054 0055 /* pen */ 0056 double _penWidth; 0057 int _penStyle; 0058 QColor _penColor; 0059 0060 /* font */ 0061 int _size; 0062 QString _family; 0063 int _weight; 0064 0065 /* borders */ 0066 Pen *_bottomBorder; 0067 Pen *_topBorder; 0068 Pen *_leftBorder; 0069 Pen *_rightBorder; 0070 0071 /* */ 0072 bool _isValidFormat; 0073 0074 public: 0075 /** 0076 * Constructors 0077 * 0078 * Creates a new instance of Format. 0079 * 0080 * @param Para the parent class of the format. 0081 */ 0082 Format(); 0083 0084 /* 0085 * Destructor 0086 * 0087 * Nothing to do 0088 */ 0089 ~Format() override; 0090 0091 /** 0092 * getters 0093 */ 0094 long getMultirow() const { 0095 return _multirow; 0096 } 0097 long getAlign() const { 0098 return _align; 0099 } 0100 long getAlignY() const { 0101 return _alignY; 0102 } 0103 QColor getBgColor() const { 0104 return _bgColor; 0105 } 0106 bool getVerticalText() const { 0107 return _verticalText; 0108 } 0109 double getAngle() const { 0110 return _angle; 0111 } 0112 QColor getBrushColor() const { 0113 return _brushColor; 0114 } 0115 int getBrushStyle() const { 0116 return _brushStyle; 0117 } 0118 int getIndent() const { 0119 return _indent; 0120 } 0121 bool getDontPrintText() const { 0122 return _dontprinttext; 0123 } 0124 0125 bool hasBorder() const { 0126 return (hasTopBorder() || hasBottomBorder() || hasLeftBorder() || hasRightBorder()); 0127 } 0128 bool hasTopBorder() const; 0129 //Pen* getTopBorder() const { return _topBorder; } 0130 bool hasBottomBorder() const; 0131 //Pen* getBottomBorder() const { return _bottomBorder; } 0132 bool hasLeftBorder() const; 0133 //Pen* getLeftBorder() const { return _leftBorder; } 0134 bool hasRightBorder() const; 0135 //Pen* getRightBorder() const { return _rightBorder; } 0136 0137 /* pen */ 0138 double getPenWidth() const { 0139 return _penWidth; 0140 } 0141 int getPenStyle() const { 0142 return _penStyle; 0143 } 0144 QColor getPenColor() const { 0145 return _penColor; 0146 } 0147 0148 /* font */ 0149 int getFontSize() const { 0150 return _size; 0151 } 0152 QString getFontFamily() const { 0153 return _family; 0154 } 0155 int getFontWeight() const { 0156 return _weight; 0157 } 0158 bool isValidFormat() const { 0159 return _isValidFormat; 0160 } 0161 0162 /** 0163 * setters 0164 */ 0165 void setAlign(long a) { 0166 _align = a; 0167 } 0168 void setAlignY(long a) { 0169 _alignY = a; 0170 } 0171 void setBgColor(QColor b) { 0172 _bgColor = b; 0173 } 0174 void setMultirow(long mr) { 0175 _multirow = mr; 0176 } 0177 void setVerticalText(bool vt) { 0178 _verticalText = vt; 0179 } 0180 void setAngle(double a) { 0181 _angle = a; 0182 } 0183 void setBrushColor(QString bc) { 0184 _brushColor.setNamedColor(bc); 0185 } 0186 void setBrushStyle(int bs) { 0187 _brushStyle = bs; 0188 } 0189 void setIndent(int indent) { 0190 _indent = indent; 0191 } 0192 void setDontPrintText(bool dpt) { 0193 _dontprinttext = dpt; 0194 } 0195 0196 /* pen */ 0197 void setPenWidth(double pw) { 0198 _penWidth = pw; 0199 } 0200 void setPenStyle(int ps) { 0201 _penStyle = ps; 0202 } 0203 void setPenColor(QString pc) { 0204 _penColor.setNamedColor(pc); 0205 } 0206 0207 /* font */ 0208 void setFontSize(int s) { 0209 _size = s; 0210 } 0211 void setFontFamily(QString f) { 0212 _family = f; 0213 } 0214 void setFontWeight(int w) { 0215 _weight = w; 0216 } 0217 0218 /** 0219 * Helpful functions 0220 */ 0221 0222 /** 0223 * Get information from a markup tree (only param of a format). 0224 */ 0225 virtual void analyze(const QDomNode); 0226 virtual void analyzePen(const QDomNode); 0227 virtual void analyzeFont(const QDomNode); 0228 0229 /** 0230 * Generate the cell format inherited from the row or the column format or 0231 * use its own format. 0232 * 0233 * @param out The output stream. 0234 * @param col The column of this cell. 0235 * @param row The row of this cell. 0236 */ 0237 void generate(QTextStream& out, Column* col = nullptr, Row* row = nullptr); 0238 0239 /** 0240 * Generate the text cell format (color and font). 0241 */ 0242 void generateTextFormat(QTextStream& out, QString text); 0243 0244 /** 0245 * Generate the color format for a column or a row. 0246 * 0247 * The command can be either columncolor or rowcolor. 0248 * 0249 * @param out The output stream 0250 */ 0251 void generateColor(QTextStream& out); 0252 }; 0253 0254 #endif /* __CALLIGRA_SHEETS_LATEX_FORMAT_H__ */