stylefactory.h
1/* This file is part of the KDE project
2 Copyright (C) 2003 Percy Leonhardt
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 STYLEFACTORY_H
22#define STYLEFACTORY_H
23
24#include <tqptrlist.h>
25#include <tqstring.h>
26
27#include <tqdom.h>
28
29class StyleFactory;
30
31class StrokeDashStyle
32{
33public:
34 StrokeDashStyle( int style );
35 ~StrokeDashStyle() {};
36
37 void toXML( TQDomDocument & doc, TQDomElement & e ) const;
38 TQString name() const { return m_name; };
39
40private:
41 StrokeDashStyle() {};
42
43 TQString m_name, m_style, m_dots1, m_dots2, m_dots1_length, m_dots2_length,
44 m_distance;
45};
46
47class GradientStyle
48{
49public:
50 GradientStyle( TQDomElement & gradient, int index );
51 ~GradientStyle() {};
52
53 void toXML( TQDomDocument & doc, TQDomElement & e ) const;
54 TQString name() const { return m_name; };
55
56private:
57 GradientStyle() {};
58
59 TQString m_name, m_style, m_cx, m_cy, m_start_color, m_end_color,
60 m_start_intensity, m_end_intensity, m_angle, m_border;
61};
62
63class MarkerStyle
64{
65public:
66 MarkerStyle( int style );
67 ~MarkerStyle() {};
68
69 void toXML( TQDomDocument & doc, TQDomElement & e ) const;
70 TQString name() const { return m_name; };
71
72private:
73 MarkerStyle() {};
74
75 TQString m_name, m_viewBox, m_d;
76};
77
78class HatchStyle
79{
80public:
81 HatchStyle( int style, TQString & color );
82 ~HatchStyle() {};
83
84 void toXML( TQDomDocument & doc, TQDomElement & e ) const;
85 TQString name() const { return m_name; };
86
87private:
88 HatchStyle() {};
89
90 TQString m_name, m_style, m_color, m_distance, m_rotation;
91};
92
93class FillImageStyle
94{
95public:
96 FillImageStyle( TQString & name );
97 ~FillImageStyle() {};
98
99 void toXML( TQDomDocument & doc, TQDomElement & e ) const;
100
101private:
102 FillImageStyle() {};
103
104 TQString m_name, m_href, m_type, m_show, m_actuate;
105};
106
107class PageMasterStyle
108{
109public:
110 PageMasterStyle( TQDomElement & e, const uint index );
111 ~PageMasterStyle() {};
112
113 void toXML( TQDomDocument & doc, TQDomElement & e ) const;
114 bool operator==( const PageMasterStyle & pageMasterStyle ) const;
115 TQString name() const { return m_name; };
116 TQString style() const { return m_style; };
117
118private:
119 PageMasterStyle() {};
120
121 TQString m_name, m_page_width, m_page_height, m_orientation, m_style;
122 TQString m_margin_top, m_margin_bottom, m_margin_left, m_margin_right;
123};
124
125class PageStyle
126{
127public:
128 PageStyle( StyleFactory * styleFactory, TQDomElement & e, const uint index );
129 ~PageStyle() {};
130
131 void toXML( TQDomDocument & doc, TQDomElement & e ) const;
132 bool operator==( const PageStyle & pageStyle ) const;
133 TQString name() const { return m_name; };
134
135private:
136 PageStyle() {};
137
138 TQString m_name, m_bg_visible, m_bg_objects_visible, m_fill, m_fill_color,
139 m_fill_image_name, m_fill_image_width, m_fill_image_height,
140 m_fill_image_ref_point, m_fill_gradient_name, m_repeat, m_page_effect,
141 m_page_duration;
142};
143
144class TextStyle
145{
146public:
147 TextStyle( TQDomElement & e, const uint index );
148 ~TextStyle() {};
149
150 void toXML( TQDomDocument & doc, TQDomElement & e ) const;
151 bool operator==( const TextStyle & textStyle ) const;
152 TQString name() const { return m_name; };
153
154private:
155 TextStyle() {};
156
157 TQString m_name, m_font_size, m_font_family, m_font_family_generic,
158 m_color, m_font_pitch, m_font_style, m_font_weight, m_text_shadow,
159 m_text_underline, m_text_underline_color, m_text_crossing_out;
160};
161
162class GraphicStyle
163{
164public:
165 GraphicStyle( StyleFactory * styleFactory, TQDomElement & e, const uint index );
166 GraphicStyle( const char * name,
167 const char * stroke, const char * stroke_color,
168 const char * stroke_width, const char * shadow,
169 const char * shadow_offset_x, const char * shadow_offset_y,
170 const char * shadow_color, const char * margin_left,
171 const char * margin_right, const char * margin_top,
172 const char * margin_bottom, const char * color,
173 const char * text_outline, const char * text_crossing_out,
174 const char * font_family, const char * font_size,
175 const char * font_style, const char * text_shadow,
176 const char * text_underline, const char * font_weight,
177 const char * line_height, const char * text_align,
178 const char * fill, const char * fill_color,
179 const char * enable_numbering );
180 ~GraphicStyle() {};
181
182 void toXML( TQDomDocument & doc, TQDomElement & e ) const;
183 bool operator==( const GraphicStyle & graphicStyle ) const;
184 TQString name() const { return m_name; };
185
186private:
187 GraphicStyle() {};
188
189 TQString m_name, m_stroke, m_stroke_color, m_stroke_width, m_shadow,
190 m_shadow_offset_x, m_shadow_offset_y, m_shadow_color, m_margin_left,
191 m_margin_right, m_margin_top, m_margin_bottom, m_color, m_text_outline,
192 m_text_crossing_out, m_font_family, m_font_size, m_font_style,
193 m_text_shadow, m_text_underline, m_font_weight, m_line_height,
194 m_text_align, m_fill, m_fill_color, m_enable_numbering, m_stroke_dash,
195 m_fill_hatch_name, m_marker_start, m_marker_start_width,
196 m_marker_end, m_marker_end_width, m_fill_gradient_name, m_transparency, m_textAlignment,
197 m_textMarginLeft, m_textMarginBottom, m_textMarginTop, m_textMarginRight;
198};
199
200class ParagraphStyle
201{
202public:
203 ParagraphStyle( TQDomElement & e, const uint index );
204 ~ParagraphStyle() {};
205
206 void toXML( TQDomDocument & doc, TQDomElement & e ) const;
207 bool operator==( const ParagraphStyle & paragraphStyle ) const;
208 TQString name() const { return m_name; };
209
210private:
211 ParagraphStyle() {};
212 TQString parseBorder( TQDomElement e );
213
214 TQString m_name, m_margin_left, m_margin_right, m_text_indent, m_text_align,
215 m_enable_numbering, m_text_shadow, m_margin_top, m_margin_bottom,
216 m_border_left, m_border_right, m_border_top, m_border_bottom,
217 m_line_height, m_line_height_at_least, m_line_spacing;
218};
219
220class ListStyle
221{
222public:
223 ListStyle( TQDomElement & e, const uint index );
224 ~ListStyle() {};
225
226 void toXML( TQDomDocument & doc, TQDomElement & e ) const;
227 bool operator==( const ListStyle & listStyle ) const;
228 TQString name() const { return m_name; };
229
230private:
231 ListStyle() {};
232
233 typedef enum {
234 LLS_NUMBER,
235 LLS_BULLET
236 } list_level_style_t;
237
238 float m_min_label_width;
239 list_level_style_t m_listLevelStyle;
240 TQString m_name, m_num_suffix, m_num_format, m_bullet_char, m_color,
241 m_font_size, m_font_family;
242};
243
244class StyleFactory
245{
246public:
247 StyleFactory();
248 ~StyleFactory();
249
250 void addOfficeStyles( TQDomDocument & doc, TQDomElement & styles );
251 void addOfficeMaster( TQDomDocument & doc, TQDomElement & master );
252 void addOfficeAutomatic( TQDomDocument & doc, TQDomElement & automatic );
253 void addAutomaticStyles( TQDomDocument & doc, TQDomElement & autoStyles );
254
255 TQString createStrokeDashStyle( int style );
256 TQString createGradientStyle( TQDomElement & gradient );
257 TQString createMarkerStyle( int style );
258 TQString createHatchStyle( int style, TQString & color );
259 TQString createListStyle( TQDomElement & e );
260 TQString createPageStyle( TQDomElement & e );
261 TQString createTextStyle( TQDomElement & e );
262 TQString createGraphicStyle( TQDomElement & e );
263 TQString createParagraphStyle( TQDomElement & e );
264 TQString createPageMasterStyle( TQDomElement & e );
265
266 static TQString toCM( const TQString & point );
267
268private:
269 TQPtrList<StrokeDashStyle> m_strokeDashStyles;
270 TQPtrList<GradientStyle> m_gradientStyles;
271 TQPtrList<HatchStyle> m_hatchStyles;
272 TQPtrList<MarkerStyle> m_markerStyles;
273 TQPtrList<FillImageStyle> m_fillImageStyles;
274 TQPtrList<ListStyle> m_listStyles;
275 TQPtrList<PageStyle> m_pageStyles;
276 TQPtrList<TextStyle> m_textStyles;
277 TQPtrList<GraphicStyle> m_graphicStyles;
278 TQPtrList<ParagraphStyle> m_paragraphStyles;
279 TQPtrList<PageMasterStyle> m_pageMasterStyles;
280};
281
282#endif