1 /* This file is part of the KDE project 2 Copyright (C) 2003 Norbert Andres <nandres@web.de> 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 21 #ifndef OPENCALCSTYLEEXPORT_H 22 #define OPENCALCSTYLEEXPORT_H 23 24 #include "sheets/Global.h" 25 #include "sheets/Style.h" 26 27 #include <QColor> 28 #include <QFont> 29 #include <QPen> 30 #include <QString> 31 #include <QList> 32 33 namespace Calligra 34 { 35 namespace Sheets 36 { 37 class Cell; 38 } 39 } 40 41 class QDomDocument; 42 class QDomElement; 43 44 class Style 45 { 46 public: 47 enum breakBefore { none, automatic, page }; 48 Style()49 Style() : breakB(none), size(0.0) {} 50 51 QString name; 52 uint breakB; 53 double size; 54 }; 55 56 class SheetStyle 57 { 58 public: SheetStyle()59 SheetStyle() : visible(true) {} 60 copyData(SheetStyle const & ts)61 void copyData(SheetStyle const & ts) { 62 visible = ts.visible; 63 } 64 static bool isEqual(SheetStyle const * const t1, SheetStyle const & t2); 65 66 QString name; 67 bool visible; 68 }; 69 70 class NumberStyle 71 { 72 public: NumberStyle()73 NumberStyle() {} 74 75 enum NumberType { Boolean, Date, Number, Percentage, Time }; 76 copyData(NumberStyle const & ts)77 void copyData(NumberStyle const & ts) { 78 type = ts.type; 79 } 80 static bool isEqual(NumberStyle const * const t1, NumberStyle const & t2); 81 82 QString name; 83 84 NumberType type; 85 QString pattern; 86 }; 87 88 class CellStyle 89 { 90 public: 91 CellStyle(); 92 93 void copyData(CellStyle const & ts); 94 static bool isEqual(CellStyle const * const t1, CellStyle const & t2); 95 96 // all except the number style 97 static void loadData(CellStyle & cs, const Calligra::Sheets::Cell& cell); 98 99 QString name; 100 101 QFont font; 102 QString numberStyle; 103 QColor color; 104 QColor bgColor; 105 double indent; 106 bool wrap; 107 bool vertical; 108 int angle; 109 bool print; 110 QPen left; 111 QPen right; 112 QPen top; 113 QPen bottom; 114 bool hideAll; 115 bool hideFormula; 116 bool notProtected; 117 118 Calligra::Sheets::Style::HAlign alignX; 119 Calligra::Sheets::Style::VAlign alignY; 120 }; 121 122 class ColumnStyle : public Style 123 { 124 public: ColumnStyle()125 ColumnStyle() : Style() {} 126 127 void copyData(ColumnStyle const & cs); 128 static bool isEqual(ColumnStyle const * const c1, ColumnStyle const & c2); 129 }; 130 131 class RowStyle : public Style 132 { 133 public: RowStyle()134 RowStyle() : Style() {} 135 136 void copyData(RowStyle const & cs); 137 static bool isEqual(RowStyle const * const c1, RowStyle const & c2); 138 }; 139 140 class OpenCalcStyles 141 { 142 public: 143 OpenCalcStyles(); 144 ~OpenCalcStyles(); 145 146 void writeStyles(QDomDocument & doc, QDomElement & autoStyles); 147 void writeFontDecl(QDomDocument & doc, QDomElement & content); 148 149 void addFont(QFont const & font, bool def = false); 150 151 QString cellStyle(CellStyle const & cs); 152 QString columnStyle(ColumnStyle const & cs); 153 QString numberStyle(NumberStyle const & ns); 154 QString rowStyle(RowStyle const & rs); 155 QString sheetStyle(SheetStyle const & ts); 156 157 private: 158 QList<CellStyle*> m_cellStyles; 159 QList<ColumnStyle*> m_columnStyles; 160 QList<NumberStyle*> m_numberStyles; 161 QList<RowStyle*> m_rowStyles; 162 QList<SheetStyle*> m_sheetStyles; 163 QList<QFont*> m_fontList; 164 165 QFont m_defaultFont; 166 167 void addCellStyles(QDomDocument & doc, QDomElement & autoStyles); 168 void addColumnStyles(QDomDocument & doc, QDomElement & autoStyles); 169 void addNumberStyles(QDomDocument & doc, QDomElement & autoStyles); 170 void addRowStyles(QDomDocument & doc, QDomElement & autoStyles); 171 void addSheetStyles(QDomDocument & doc, QDomElement & autoStyles); 172 }; 173 174 175 176 #endif 177