File indexing completed on 2025-01-12 13:05:55
0001 /* This file is part of the KDE project 0002 Copyright (C) 2003 Norbert Andres <nandres@web.de> 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 0021 #ifndef OPENCALCSTYLEEXPORT_H 0022 #define OPENCALCSTYLEEXPORT_H 0023 0024 #include "sheets/Global.h" 0025 #include "sheets/Style.h" 0026 0027 #include <QColor> 0028 #include <QFont> 0029 #include <QPen> 0030 #include <QString> 0031 #include <QList> 0032 0033 namespace Calligra 0034 { 0035 namespace Sheets 0036 { 0037 class Cell; 0038 } 0039 } 0040 0041 class QDomDocument; 0042 class QDomElement; 0043 0044 class Style 0045 { 0046 public: 0047 enum breakBefore { none, automatic, page }; 0048 0049 Style() : breakB(none), size(0.0) {} 0050 0051 QString name; 0052 uint breakB; 0053 double size; 0054 }; 0055 0056 class SheetStyle 0057 { 0058 public: 0059 SheetStyle() : visible(true) {} 0060 0061 void copyData(SheetStyle const & ts) { 0062 visible = ts.visible; 0063 } 0064 static bool isEqual(SheetStyle const * const t1, SheetStyle const & t2); 0065 0066 QString name; 0067 bool visible; 0068 }; 0069 0070 class NumberStyle 0071 { 0072 public: 0073 NumberStyle() {} 0074 0075 enum NumberType { Boolean, Date, Number, Percentage, Time }; 0076 0077 void copyData(NumberStyle const & ts) { 0078 type = ts.type; 0079 } 0080 static bool isEqual(NumberStyle const * const t1, NumberStyle const & t2); 0081 0082 QString name; 0083 0084 NumberType type; 0085 QString pattern; 0086 }; 0087 0088 class CellStyle 0089 { 0090 public: 0091 CellStyle(); 0092 0093 void copyData(CellStyle const & ts); 0094 static bool isEqual(CellStyle const * const t1, CellStyle const & t2); 0095 0096 // all except the number style 0097 static void loadData(CellStyle & cs, const Calligra::Sheets::Cell& cell); 0098 0099 QString name; 0100 0101 QFont font; 0102 QString numberStyle; 0103 QColor color; 0104 QColor bgColor; 0105 double indent; 0106 bool wrap; 0107 bool vertical; 0108 int angle; 0109 bool print; 0110 QPen left; 0111 QPen right; 0112 QPen top; 0113 QPen bottom; 0114 bool hideAll; 0115 bool hideFormula; 0116 bool notProtected; 0117 0118 Calligra::Sheets::Style::HAlign alignX; 0119 Calligra::Sheets::Style::VAlign alignY; 0120 }; 0121 0122 class ColumnStyle : public Style 0123 { 0124 public: 0125 ColumnStyle() : Style() {} 0126 0127 void copyData(ColumnStyle const & cs); 0128 static bool isEqual(ColumnStyle const * const c1, ColumnStyle const & c2); 0129 }; 0130 0131 class RowStyle : public Style 0132 { 0133 public: 0134 RowStyle() : Style() {} 0135 0136 void copyData(RowStyle const & cs); 0137 static bool isEqual(RowStyle const * const c1, RowStyle const & c2); 0138 }; 0139 0140 class OpenCalcStyles 0141 { 0142 public: 0143 OpenCalcStyles(); 0144 ~OpenCalcStyles(); 0145 0146 void writeStyles(QDomDocument & doc, QDomElement & autoStyles); 0147 void writeFontDecl(QDomDocument & doc, QDomElement & content); 0148 0149 void addFont(QFont const & font, bool def = false); 0150 0151 QString cellStyle(CellStyle const & cs); 0152 QString columnStyle(ColumnStyle const & cs); 0153 QString numberStyle(NumberStyle const & ns); 0154 QString rowStyle(RowStyle const & rs); 0155 QString sheetStyle(SheetStyle const & ts); 0156 0157 private: 0158 QList<CellStyle*> m_cellStyles; 0159 QList<ColumnStyle*> m_columnStyles; 0160 QList<NumberStyle*> m_numberStyles; 0161 QList<RowStyle*> m_rowStyles; 0162 QList<SheetStyle*> m_sheetStyles; 0163 QList<QFont*> m_fontList; 0164 0165 QFont m_defaultFont; 0166 0167 void addCellStyles(QDomDocument & doc, QDomElement & autoStyles); 0168 void addColumnStyles(QDomDocument & doc, QDomElement & autoStyles); 0169 void addNumberStyles(QDomDocument & doc, QDomElement & autoStyles); 0170 void addRowStyles(QDomDocument & doc, QDomElement & autoStyles); 0171 void addSheetStyles(QDomDocument & doc, QDomElement & autoStyles); 0172 }; 0173 0174 0175 0176 #endif