00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <stdlib.h>
00023
00024 #include <kdebug.h>
00025
00026 #include "fileheader.h"
00027 #include "textformat.h"
00028
00029
00030
00031
00032 int TextFormat::getColorBlue () const
00033 {
00034 if(_textcolor!= 0)
00035 return _textcolor->blue();
00036 else
00037 return 0;
00038 }
00039
00040 int TextFormat::getColorGreen() const
00041 {
00042 if(_textcolor!= 0)
00043 return _textcolor->green();
00044 else
00045 return 0;
00046 }
00047
00048 int TextFormat::getColorRed () const
00049 {
00050 if(_textcolor!= 0)
00051 return _textcolor->red();
00052 else
00053 return 0;
00054 }
00055
00056
00057
00058
00059 int TextFormat::getBkColorBlue () const
00060 {
00061 if(_backcolor!= 0)
00062 return _backcolor->blue();
00063 else
00064 return 0;
00065 }
00066
00067 int TextFormat::getBkColorGreen() const
00068 {
00069 if(_backcolor!= 0)
00070 return _backcolor->green();
00071 else
00072 return 0;
00073 }
00074
00075 int TextFormat::getBkColorRed () const
00076 {
00077 if(_backcolor!= 0)
00078 return _backcolor->red();
00079 else
00080 return 0;
00081 }
00082
00083
00084
00085
00086 void TextFormat::setColor (const int r, const int g, const int b)
00087 {
00088 if(_textcolor == 0)
00089 _textcolor = new QColor(r, g, b);
00090 else
00091 _textcolor->setRgb(r, g, b);
00092 }
00093
00094
00095
00096
00097 void TextFormat::setBkColor (const int r, const int g, const int b)
00098 {
00099 if(_backcolor == 0)
00100 _backcolor = new QColor(r, g, b);
00101 else
00102 _backcolor->setRgb(r, g, b);
00103 }
00104
00105
00106
00107
00108
00109
00110 void TextFormat::analyseFormat(const QDomNode balise)
00111 {
00112
00113
00114
00115 analyseParam(balise);
00116 kdDebug(30522) << "ANALYSE A FORMAT" << endl;
00117
00118
00119 if(isChild(balise, "FONT"))
00120 analyseFont(getChild(balise, "FONT"));
00121 if(isChild(balise, "ITALIC"))
00122 analyseItalic(getChild(balise, "ITALIC"));
00123 if(isChild(balise, "UNDERLINE"))
00124 analyseUnderlined(getChild(balise, "UNDERLINE"));
00125 if(isChild(balise, "WEIGHT"))
00126 analyseWeight(getChild(balise, "WEIGHT"));
00127 if(isChild(balise, "VERTALIGN"))
00128 analyseAlign(getChild(balise, "VERTALIGN"));
00129 if(isChild(balise, "STRIKEOUT"))
00130 analyseStrikeout(getChild(balise, "STRIKEOUT"));
00131 if(isChild(balise, "COLOR"))
00132 analyseColor(getChild(balise, "COLOR"));
00133 if(isChild(balise, "SIZE"))
00134 analyseSize(getChild(balise, "SIZE"));
00135 if(isChild(balise, "TEXTBACKGROUNDCOLOR"))
00136 analyseBackgroundColor(getChild(balise, "TEXTBACKGROUNDCOLOR"));
00137
00138 kdDebug(30522) << "END OF A FORMAT" << endl;
00139 }
00140
00141 void TextFormat::analyseBackgroundColor(const QDomNode balise)
00142 {
00143
00144 int red = 0,
00145 blue = 0,
00146 green = 0;
00147
00148 red = getAttr(balise, "red").toInt();
00149 green = getAttr(balise, "green").toInt();
00150 blue = getAttr(balise, "blue").toInt();
00151
00152 if(!(red == 255 && green == 255 && blue == 255))
00153 {
00154 kdDebug(30522) << "bk color = " << red << "," << green << "," << blue << endl;
00155
00156 setBkColor(red, green, blue);
00157 FileHeader::instance()->useColor();
00158 }
00159 }
00160
00161
00162
00163
00164
00165
00166 void TextFormat::analyseParam(const QDomNode balise)
00167 {
00168
00169
00170
00171
00172
00173 Format::analyse(balise);
00174 }
00175
00176
00177
00178
00179
00180
00181 void TextFormat::analyseFont(const QDomNode balise)
00182 {
00183
00184 setPolice(getAttr(balise, "name"));
00185 }
00186
00187
00188
00189
00190
00191
00192 void TextFormat::analyseItalic(const QDomNode balise)
00193 {
00194
00195 setItalic(getAttr(balise, "value").toInt());
00196 }
00197
00198
00199
00200
00201
00202
00203 void TextFormat::analyseUnderlined(const QDomNode balise)
00204 {
00205
00206
00207 setUnderlined(getAttr(balise, "value"));
00208 if(isUnderlined())
00209 FileHeader::instance()->useUnderline();
00210 kdDebug(30522) << "Underlined ? " << isUnderlined() << endl;
00211 }
00212
00213
00214
00215
00216
00217
00218 void TextFormat::analyseStrikeout(const QDomNode balise)
00219 {
00220
00221 setStrikeout(getAttr(balise, "value").toInt());
00222 if(isStrikeout())
00223 FileHeader::instance()->useUnderline();
00224 kdDebug(30522) << "Strikeout ? " << isUnderlined() << endl;
00225 }
00226
00227
00228
00229
00230
00231
00232 void TextFormat::analyseWeight(const QDomNode balise)
00233 {
00234
00235 setWeight(getAttr(balise, "value").toInt());
00236 kdDebug(30522) << "Weight = " << getWeight() << endl;
00237 }
00238
00239
00240
00241
00242
00243
00244 void TextFormat::analyseAlign(const QDomNode balise)
00245 {
00246
00247
00248 setAlign(getAttr(balise, "value").toInt());
00249 }
00250
00251
00252
00253
00254
00255
00256 void TextFormat::analyseColor(const QDomNode balise)
00257 {
00258
00259 int red = 0,
00260 blue = 0,
00261 green = 0;
00262
00263 red = getAttr(balise, "red").toInt();
00264 green = getAttr(balise, "green").toInt();
00265 blue = getAttr(balise, "blue").toInt();
00266
00267 if(!(red == 0 && green == 0 && blue == 0))
00268 {
00269
00270 kdDebug(30522) << "color = " << red << "," << green << "," << blue << endl;
00271 setColor(red, green, blue);
00272 FileHeader::instance()->useColor();
00273 }
00274 }
00275
00276
00277
00278
00279
00280
00281 void TextFormat::analyseSize(const QDomNode balise)
00282 {
00283
00284 setSize(getAttr(balise, "value").toInt());
00285 kdDebug(30522) << "font size : " << getSize() << endl;
00286 }