opencalcstyleexport.h
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 "kspread_format.h"
25
26#include <tqcolor.h>
27#include <tqfont.h>
28#include <tqptrlist.h>
29#include <tqstring.h>
30
31namespace KSpread
32{
33 class Cell;
34}
35
36class TQDomDocument;
37class TQDomElement;
38
39typedef enum T1 { Boolean, Date, Number, Percentage, Time } NumberType;
40
41class Style
42{
43 public:
44 enum breakBefore { none, automatic, page };
45
46 Style() : breakB( none ), size( 0.0 ) {}
47
48 TQString name;
49 uint breakB;
50 double size;
51};
52
53class SheetStyle
54{
55 public:
56 SheetStyle() : visible( true ) {}
57
58 void copyData( SheetStyle const & ts ) { visible = ts.visible; }
59 static bool isEqual( SheetStyle const * const t1, SheetStyle const & t2 );
60
61 TQString name;
62 bool visible;
63};
64
65class NumberStyle
66{
67 public:
68 NumberStyle() {}
69
70 void copyData( NumberStyle const & ts ) { type = ts.type; }
71 static bool isEqual( NumberStyle const * const t1, NumberStyle const & t2 );
72
73 TQString name;
74
75 NumberType type;
76 TQString pattern;
77};
78
79class CellStyle
80{
81 public:
82 CellStyle();
83
84 void copyData( CellStyle const & ts );
85 static bool isEqual( CellStyle const * const t1, CellStyle const & t2 );
86
87 // all except the number style
88 static void loadData( CellStyle & cs, KSpread::Cell const * const cell );
89
90 TQString name;
91
92 TQFont font;
93 TQString numberStyle;
94 TQColor color;
95 TQColor bgColor;
96 double indent;
97 bool wrap;
98 bool vertical;
99 int angle;
100 bool print;
101 TQPen left;
102 TQPen right;
103 TQPen top;
104 TQPen bottom;
105 bool hideAll;
106 bool hideFormula;
107 bool notProtected;
108
109 KSpread::Format::Align alignX;
110 KSpread::Format::AlignY alignY;
111};
112
113class ColumnStyle : public Style
114{
115 public:
116 ColumnStyle() : Style() {}
117
118 void copyData( ColumnStyle const & cs );
119 static bool isEqual( ColumnStyle const * const c1, ColumnStyle const & c2 );
120};
121
122class RowStyle : public Style
123{
124 public:
125 RowStyle() : Style() {}
126
127 void copyData( RowStyle const & cs );
128 static bool isEqual( RowStyle const * const c1, RowStyle const & c2 );
129};
130
131class OpenCalcStyles
132{
133 public:
134 OpenCalcStyles();
135 ~OpenCalcStyles();
136
137 void writeStyles ( TQDomDocument & doc, TQDomElement & autoStyles );
138 void writeFontDecl( TQDomDocument & doc, TQDomElement & content );
139
140 void addFont( TQFont const & font, bool def = false );
141
142 TQString cellStyle( CellStyle const & cs );
143 TQString columnStyle( ColumnStyle const & cs );
144 TQString numberStyle( NumberStyle const & ns );
145 TQString rowStyle( RowStyle const & rs );
146 TQString sheetStyle( SheetStyle const & ts );
147
148 private:
149 TQPtrList<CellStyle> m_cellStyles;
150 TQPtrList<ColumnStyle> m_columnStyles;
151 TQPtrList<NumberStyle> m_numberStyles;
152 TQPtrList<RowStyle> m_rowStyles;
153 TQPtrList<SheetStyle> m_sheetStyles;
154 TQPtrList<TQFont> m_fontList;
155
156 TQFont m_defaultFont;
157
158 void addCellStyles( TQDomDocument & doc, TQDomElement & autoStyles );
159 void addColumnStyles( TQDomDocument & doc, TQDomElement & autoStyles );
160 void addNumberStyles( TQDomDocument & doc, TQDomElement & autoStyles );
161 void addRowStyles( TQDomDocument & doc, TQDomElement & autoStyles );
162 void addSheetStyles( TQDomDocument & doc, TQDomElement & autoStyles );
163};
164
165
166
167#endif