00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "qstylesheet.h"
00039
00040 #include "qrichtext_p.h"
00041 #include "qcleanuphandler.h"
00042
00043 #include <stdio.h>
00044
00045 using namespace Qt3;
00046
00047 namespace Qt3 {
00048
00049 class QStyleSheetItemData
00050 {
00051 public:
00052 QStyleSheetItem::DisplayMode disp;
00053 int fontitalic;
00054 int fontunderline;
00055 int fontstrikeout;
00056 int fontweight;
00057 int fontsize;
00058 int fontsizelog;
00059 int fontsizestep;
00060 int lineSpacing;
00061 QString fontfamily;
00062 QStyleSheetItem *parentstyle;
00063 QString stylename;
00064 int ncolumns;
00065 QColor col;
00066 bool anchor;
00067 int align;
00068 QStyleSheetItem::VerticalAlignment valign;
00069 int margin[5];
00070 QStyleSheetItem::ListStyle list;
00071 QStyleSheetItem::WhiteSpaceMode whitespacemode;
00072 QString contxt;
00073 bool selfnest;
00074 QStyleSheet* sheet;
00075 };
00076
00077 }
00078
00149 QStyleSheetItem::QStyleSheetItem( QStyleSheet* parent, const QString& name )
00150 {
00151 d = new QStyleSheetItemData;
00152 d->stylename = name.lower();
00153 d->sheet = parent;
00154 init();
00155 if (parent)
00156 parent->insert( this );
00157 }
00158
00163 QStyleSheetItem::QStyleSheetItem( const QStyleSheetItem & other )
00164 {
00165 d = new QStyleSheetItemData;
00166 *d = *other.d;
00167 }
00168
00169
00174 QStyleSheetItem::~QStyleSheetItem()
00175 {
00176 delete d;
00177 }
00178
00179
00180
00184 QStyleSheet* QStyleSheetItem::styleSheet()
00185 {
00186 return d->sheet;
00187 }
00188
00194 const QStyleSheet* QStyleSheetItem::styleSheet() const
00195 {
00196 return d->sheet;
00197 }
00198
00203 void QStyleSheetItem::init()
00204 {
00205 d->disp = DisplayInline;
00206
00207 d->fontitalic = Undefined;
00208 d->fontunderline = Undefined;
00209 d->fontstrikeout = Undefined;
00210 d->fontweight = Undefined;
00211 d->fontsize = Undefined;
00212 d->fontsizelog = Undefined;
00213 d->fontsizestep = 0;
00214 d->ncolumns = Undefined;
00215 d->col = QColor();
00216 d->anchor = FALSE;
00217 d->align = Undefined;
00218 d->valign = VAlignBaseline;
00219 d->margin[0] = Undefined;
00220 d->margin[1] = Undefined;
00221 d->margin[2] = Undefined;
00222 d->margin[3] = Undefined;
00223 d->margin[4] = Undefined;
00224 d->list = (ListStyle) Undefined;
00225 d->whitespacemode = (WhiteSpaceMode) Undefined;
00226 d->selfnest = TRUE;
00227 d->lineSpacing = Undefined;
00228 }
00229
00233 QString QStyleSheetItem::name() const
00234 {
00235 return d->stylename;
00236 }
00237
00244 QStyleSheetItem::DisplayMode QStyleSheetItem::displayMode() const
00245 {
00246 return d->disp;
00247 }
00248
00271 void QStyleSheetItem::setDisplayMode(DisplayMode m)
00272 {
00273 d->disp=m;
00274 }
00275
00276
00284 int QStyleSheetItem::alignment() const
00285 {
00286 return d->align;
00287 }
00288
00297 void QStyleSheetItem::setAlignment( int f )
00298 {
00299 d->align = f;
00300 }
00301
00302
00309 QStyleSheetItem::VerticalAlignment QStyleSheetItem::verticalAlignment() const
00310 {
00311 return d->valign;
00312 }
00313
00339 void QStyleSheetItem::setVerticalAlignment( VerticalAlignment valign )
00340 {
00341 d->valign = valign;
00342 }
00343
00344
00351 bool QStyleSheetItem::fontItalic() const
00352 {
00353 return d->fontitalic > 0;
00354 }
00355
00362 void QStyleSheetItem::setFontItalic(bool italic)
00363 {
00364 d->fontitalic = italic?1:0;
00365 }
00366
00374 bool QStyleSheetItem::definesFontItalic() const
00375 {
00376 return d->fontitalic != Undefined;
00377 }
00378
00385 bool QStyleSheetItem::fontUnderline() const
00386 {
00387 return d->fontunderline > 0;
00388 }
00389
00396 void QStyleSheetItem::setFontUnderline(bool underline)
00397 {
00398 d->fontunderline = underline?1:0;
00399 }
00400
00408 bool QStyleSheetItem::definesFontUnderline() const
00409 {
00410 return d->fontunderline != Undefined;
00411 }
00412
00413
00420 bool QStyleSheetItem::fontStrikeOut() const
00421 {
00422 return d->fontstrikeout > 0;
00423 }
00424
00431 void QStyleSheetItem::setFontStrikeOut(bool strikeOut)
00432 {
00433 d->fontstrikeout = strikeOut?1:0;
00434 }
00435
00443 bool QStyleSheetItem::definesFontStrikeOut() const
00444 {
00445 return d->fontstrikeout != Undefined;
00446 }
00447
00448
00455 int QStyleSheetItem::fontWeight() const
00456 {
00457 return d->fontweight;
00458 }
00459
00466 void QStyleSheetItem::setFontWeight(int w)
00467 {
00468 d->fontweight = w;
00469 }
00470
00477 int QStyleSheetItem::logicalFontSize() const
00478 {
00479 return d->fontsizelog;
00480 }
00481
00482
00489 void QStyleSheetItem::setLogicalFontSize(int s)
00490 {
00491 d->fontsizelog = s;
00492 }
00493
00502 int QStyleSheetItem::logicalFontSizeStep() const
00503 {
00504 return d->fontsizestep;
00505 }
00506
00512 void QStyleSheetItem::setLogicalFontSizeStep( int s )
00513 {
00514 d->fontsizestep = s;
00515 }
00516
00517
00518
00524 void QStyleSheetItem::setFontSize(int s)
00525 {
00526 d->fontsize = s;
00527 }
00528
00535 int QStyleSheetItem::fontSize() const
00536 {
00537 return d->fontsize;
00538 }
00539
00540
00547 QString QStyleSheetItem::fontFamily() const
00548 {
00549 return d->fontfamily;
00550 }
00551
00557 void QStyleSheetItem::setFontFamily( const QString& fam)
00558 {
00559 d->fontfamily = fam;
00560 }
00561
00562
00569 int QStyleSheetItem::numberOfColumns() const
00570 {
00571 return d->ncolumns;
00572 }
00573
00574
00584 void QStyleSheetItem::setNumberOfColumns(int ncols)
00585 {
00586 if (ncols > 0)
00587 d->ncolumns = ncols;
00588 }
00589
00590
00597 QColor QStyleSheetItem::color() const
00598 {
00599 return d->col;
00600 }
00601
00607 void QStyleSheetItem::setColor( const QColor &c)
00608 {
00609 d->col = c;
00610 }
00611
00617 bool QStyleSheetItem::isAnchor() const
00618 {
00619 return d->anchor;
00620 }
00621
00629 void QStyleSheetItem::setAnchor(bool anc)
00630 {
00631 d->anchor = anc;
00632 }
00633
00634
00640 QStyleSheetItem::WhiteSpaceMode QStyleSheetItem::whiteSpaceMode() const
00641 {
00642 return d->whitespacemode;
00643 }
00644
00650 void QStyleSheetItem::setWhiteSpaceMode(WhiteSpaceMode m)
00651 {
00652 d->whitespacemode = m;
00653 }
00654
00655
00665 int QStyleSheetItem::margin(Margin m) const
00666 {
00667 return d->margin[m];
00668 }
00669
00670
00680 void QStyleSheetItem::setMargin(Margin m, int v)
00681 {
00682 if (m == MarginAll ) {
00683 d->margin[0] = v;
00684 d->margin[1] = v;
00685 d->margin[2] = v;
00686 d->margin[3] = v;
00687 d->margin[4] = v;
00688 } else if (m == MarginVertical ) {
00689 d->margin[MarginTop] = v;
00690 d->margin[MarginBottom] = v;
00691 } else if (m == MarginHorizontal ) {
00692 d->margin[MarginLeft] = v;
00693 d->margin[MarginRight] = v;
00694 } else {
00695 d->margin[m] = v;
00696 }
00697 }
00698
00699
00705 QStyleSheetItem::ListStyle QStyleSheetItem::listStyle() const
00706 {
00707 return d->list;
00708 }
00709
00732 void QStyleSheetItem::setListStyle(ListStyle s)
00733 {
00734 d->list=s;
00735 }
00736
00737
00746 QString QStyleSheetItem::contexts() const
00747 {
00748 return d->contxt;
00749 }
00750
00758 void QStyleSheetItem::setContexts( const QString& c)
00759 {
00760 d->contxt = QChar(' ') + c + QChar(' ');
00761 }
00762
00769 bool QStyleSheetItem::allowedInContext( const QStyleSheetItem* s) const
00770 {
00771 if ( d->contxt.isEmpty() )
00772 return TRUE;
00773 return d->contxt.find( QChar(' ')+s->name()+QChar(' ')) != -1;
00774 }
00775
00776
00783 bool QStyleSheetItem::selfNesting() const
00784 {
00785 return d->selfnest;
00786 }
00787
00797 void QStyleSheetItem::setSelfNesting( bool nesting )
00798 {
00799 d->selfnest = nesting;
00800 }
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812 void QStyleSheetItem::setLineSpacing( int ls )
00813 {
00814 d->lineSpacing = ls;
00815 }
00816
00823 int QStyleSheetItem::lineSpacing() const
00824 {
00825 return d->lineSpacing;
00826 }
00827
00828
00829
00830
00831
00832
00833
00834
00835
01054 QStyleSheet::QStyleSheet( QObject *parent, const char *name )
01055 : QObject( parent, name )
01056 {
01057 init();
01058 }
01059
01064 QStyleSheet::~QStyleSheet()
01065 {
01066 }
01067
01072 void QStyleSheet::init()
01073 {
01074 styles.setAutoDelete( TRUE );
01075
01076 nullstyle = new QStyleSheetItem( this,
01077 QString::fromLatin1("") );
01078
01079 QStyleSheetItem* style;
01080
01081 style = new QStyleSheetItem( this, "qml" );
01082 style->setDisplayMode( QStyleSheetItem::DisplayBlock );
01083
01084 style = new QStyleSheetItem( this, QString::fromLatin1("qt") );
01085 style->setDisplayMode( QStyleSheetItem::DisplayBlock );
01086
01087 style = new QStyleSheetItem( this, QString::fromLatin1("a") );
01088 style->setAnchor( TRUE );
01089
01090 style = new QStyleSheetItem( this, QString::fromLatin1("em") );
01091 style->setFontItalic( TRUE );
01092
01093 style = new QStyleSheetItem( this, QString::fromLatin1("i") );
01094 style->setFontItalic( TRUE );
01095
01096 style = new QStyleSheetItem( this, QString::fromLatin1("big") );
01097 style->setLogicalFontSizeStep( 1 );
01098 style = new QStyleSheetItem( this, QString::fromLatin1("large") );
01099 style->setLogicalFontSizeStep( 1 );
01100
01101 style = new QStyleSheetItem( this, QString::fromLatin1("small") );
01102 style->setLogicalFontSizeStep( -1 );
01103
01104 style = new QStyleSheetItem( this, QString::fromLatin1("strong") );
01105 style->setFontWeight( QFont::Bold);
01106
01107 style = new QStyleSheetItem( this, QString::fromLatin1("b") );
01108 style->setFontWeight( QFont::Bold);
01109
01110 style = new QStyleSheetItem( this, QString::fromLatin1("h1") );
01111 style->setFontWeight( QFont::Bold);
01112 style->setLogicalFontSize(6);
01113 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
01114 style-> setMargin(QStyleSheetItem::MarginTop, 18);
01115 style-> setMargin(QStyleSheetItem::MarginBottom, 12);
01116
01117 style = new QStyleSheetItem( this, QString::fromLatin1("h2") );
01118 style->setFontWeight( QFont::Bold);
01119 style->setLogicalFontSize(5);
01120 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
01121 style-> setMargin(QStyleSheetItem::MarginTop, 16);
01122 style-> setMargin(QStyleSheetItem::MarginBottom, 12);
01123
01124 style = new QStyleSheetItem( this, QString::fromLatin1("h3") );
01125 style->setFontWeight( QFont::Bold);
01126 style->setLogicalFontSize(4);
01127 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
01128 style-> setMargin(QStyleSheetItem::MarginTop, 14);
01129 style-> setMargin(QStyleSheetItem::MarginBottom, 12);
01130
01131 style = new QStyleSheetItem( this, QString::fromLatin1("h4") );
01132 style->setFontWeight( QFont::Bold);
01133 style->setLogicalFontSize(3);
01134 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
01135 style-> setMargin(QStyleSheetItem::MarginVertical, 12);
01136
01137 style = new QStyleSheetItem( this, QString::fromLatin1("h5") );
01138 style->setFontWeight( QFont::Bold);
01139 style->setLogicalFontSize(2);
01140 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
01141 style-> setMargin(QStyleSheetItem::MarginTop, 12);
01142 style-> setMargin(QStyleSheetItem::MarginBottom, 4);
01143
01144 style = new QStyleSheetItem( this, QString::fromLatin1("p") );
01145 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
01146 style-> setMargin(QStyleSheetItem::MarginVertical, 12);
01147 style->setSelfNesting( FALSE );
01148
01149 style = new QStyleSheetItem( this, QString::fromLatin1("center") );
01150 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
01151 style->setAlignment( AlignCenter );
01152
01153 style = new QStyleSheetItem( this, QString::fromLatin1("twocolumn") );
01154 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
01155 style->setNumberOfColumns( 2 );
01156
01157 style = new QStyleSheetItem( this, QString::fromLatin1("multicol") );
01158 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
01159 (void) new QStyleSheetItem( this, QString::fromLatin1("font") );
01160
01161 style = new QStyleSheetItem( this, QString::fromLatin1("ul") );
01162 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
01163 style->setListStyle( QStyleSheetItem::ListDisc );
01164 style-> setMargin(QStyleSheetItem::MarginVertical, 12);
01165 style->setMargin( QStyleSheetItem::MarginLeft, 40 );
01166
01167 style = new QStyleSheetItem( this, QString::fromLatin1("ol") );
01168 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
01169 style->setListStyle( QStyleSheetItem::ListDecimal );
01170 style-> setMargin(QStyleSheetItem::MarginVertical, 12);
01171 style->setMargin( QStyleSheetItem::MarginLeft, 40 );
01172
01173 style = new QStyleSheetItem( this, QString::fromLatin1("li") );
01174 style->setDisplayMode(QStyleSheetItem::DisplayListItem);
01175 style->setSelfNesting( FALSE );
01176
01177 style = new QStyleSheetItem( this, QString::fromLatin1("code") );
01178 style->setFontFamily( QString::fromLatin1("courier") );
01179
01180 style = new QStyleSheetItem( this, QString::fromLatin1("tt") );
01181 style->setFontFamily( QString::fromLatin1("courier") );
01182
01183 new QStyleSheetItem(this, QString::fromLatin1("img"));
01184 new QStyleSheetItem(this, QString::fromLatin1("br"));
01185 new QStyleSheetItem(this, QString::fromLatin1("hr"));
01186
01187 style = new QStyleSheetItem(this, QString::fromLatin1("sub"));
01188 style->setVerticalAlignment( QStyleSheetItem::VAlignSub );
01189 style = new QStyleSheetItem(this, QString::fromLatin1("sup"));
01190 style->setVerticalAlignment( QStyleSheetItem::VAlignSuper );
01191
01192 style = new QStyleSheetItem( this, QString::fromLatin1("pre") );
01193 style->setFontFamily( QString::fromLatin1("courier") );
01194 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
01195 style->setWhiteSpaceMode(QStyleSheetItem::WhiteSpacePre);
01196
01197 style = new QStyleSheetItem( this, QString::fromLatin1("blockquote") );
01198 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
01199 style->setMargin(QStyleSheetItem::MarginHorizontal, 40 );
01200
01201 style = new QStyleSheetItem( this, QString::fromLatin1("head") );
01202 style->setDisplayMode(QStyleSheetItem::DisplayNone);
01203 style = new QStyleSheetItem( this, QString::fromLatin1("body") );
01204 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
01205 style = new QStyleSheetItem( this, QString::fromLatin1("div") );
01206 style->setDisplayMode(QStyleSheetItem::DisplayBlock) ;
01207 style = new QStyleSheetItem( this, QString::fromLatin1("span") );
01208 style = new QStyleSheetItem( this, QString::fromLatin1("dl") );
01209 style-> setMargin(QStyleSheetItem::MarginVertical, 8);
01210 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
01211 style = new QStyleSheetItem( this, QString::fromLatin1("dt") );
01212 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
01213 style->setContexts(QString::fromLatin1("dl") );
01214 style = new QStyleSheetItem( this, QString::fromLatin1("dd") );
01215 style->setDisplayMode(QStyleSheetItem::DisplayBlock);
01216 style->setMargin(QStyleSheetItem::MarginLeft, 30);
01217 style->setContexts(QString::fromLatin1("dt dl") );
01218 style = new QStyleSheetItem( this, QString::fromLatin1("u") );
01219 style->setFontUnderline( TRUE);
01220 style = new QStyleSheetItem( this, QString::fromLatin1("s") );
01221 style->setFontStrikeOut( TRUE);
01222 style = new QStyleSheetItem( this, QString::fromLatin1("nobr") );
01223 style->setWhiteSpaceMode( QStyleSheetItem::WhiteSpaceNoWrap );
01224
01225
01226
01227 style = new QStyleSheetItem( this, QString::fromLatin1("wsp") );
01228 style->setWhiteSpaceMode( QStyleSheetItem::WhiteSpacePre );
01229
01230
01231 style = new QStyleSheetItem( this, QString::fromLatin1("table") );
01232 style = new QStyleSheetItem( this, QString::fromLatin1("tr") );
01233 style->setContexts(QString::fromLatin1("table"));
01234 style = new QStyleSheetItem( this, QString::fromLatin1("td") );
01235 style->setContexts(QString::fromLatin1("tr"));
01236 style = new QStyleSheetItem( this, QString::fromLatin1("th") );
01237 style->setFontWeight( QFont::Bold );
01238 style->setAlignment( Qt::AlignCenter );
01239 style->setContexts(QString::fromLatin1("tr"));
01240
01241 style = new QStyleSheetItem( this, QString::fromLatin1("html") );
01242 }
01243
01244
01245
01246 static QStyleSheet* defaultsheet = 0;
01247 static QSingleCleanupHandler<QStyleSheet> qt_cleanup_stylesheet;
01248
01259 QStyleSheet* QStyleSheet::defaultSheet()
01260 {
01261 if (!defaultsheet) {
01262 defaultsheet = new QStyleSheet();
01263 qt_cleanup_stylesheet.set( &defaultsheet );
01264 }
01265 return defaultsheet;
01266 }
01267
01275 void QStyleSheet::setDefaultSheet( QStyleSheet* sheet)
01276 {
01277 if ( defaultsheet != sheet ) {
01278 if ( defaultsheet )
01279 qt_cleanup_stylesheet.reset();
01280 delete defaultsheet;
01281 }
01282 defaultsheet = sheet;
01283 if ( defaultsheet )
01284 qt_cleanup_stylesheet.set( &defaultsheet );
01285 }
01286
01292 void QStyleSheet::insert( QStyleSheetItem* style )
01293 {
01294 styles.insert(style->name(), style);
01295 }
01296
01297
01301 QStyleSheetItem* QStyleSheet::item( const QString& name)
01302 {
01303 if ( name.isNull() )
01304 return 0;
01305 return styles[name];
01306 }
01307
01314 const QStyleSheetItem* QStyleSheet::item( const QString& name) const
01315 {
01316 if ( name.isNull() )
01317 return 0;
01318 return styles[name];
01319 }
01320
01321
01341 QTextCustomItem* QStyleSheet::tag( const QString& name,
01342 const QMap<QString, QString> &attr,
01343 const QString& context,
01344 const QMimeSourceFactory& factory,
01345 bool , QTextDocument *doc ) const
01346 {
01347 const QStyleSheetItem* style = item( name );
01348
01349 if ( !style )
01350 return 0;
01351 if ( style->name() == "img" )
01352 return new QTextImage( doc, attr, context, (QMimeSourceFactory&)factory );
01353 if ( style->name() == "hr" )
01354 return new QTextHorizontalLine( doc, attr, context, (QMimeSourceFactory&)factory );
01355 return 0;
01356 }
01357
01358
01369 QString QStyleSheet::convertFromPlainText( const QString& plain, QStyleSheetItem::WhiteSpaceMode mode )
01370 {
01371 int col = 0;
01372 QString rich;
01373 rich += "<p>";
01374 for ( int i = 0; i < int(plain.length()); ++i ) {
01375 if ( plain[i] == '\n' ){
01376 int c = 1;
01377 while ( i+1 < int(plain.length()) && plain[i+1] == '\n' ) {
01378 i++;
01379 c++;
01380 }
01381 if ( c == 1)
01382 rich += "<br>\n";
01383 else {
01384 rich += "</p>\n";
01385 while ( --c > 1 )
01386 rich += "<br>\n";
01387 rich += "<p>";
01388 }
01389 col = 0;
01390 } else {
01391 if ( mode == QStyleSheetItem::WhiteSpacePre && plain[i] == '\t' ){
01392 rich += 0x00a0U;
01393 ++col;
01394 while ( col % 8 ) {
01395 rich += 0x00a0U;
01396 ++col;
01397 }
01398 }
01399 else if ( mode == QStyleSheetItem::WhiteSpacePre && plain[i].isSpace() )
01400 rich += 0x00a0U;
01401 else if ( plain[i] == '<' )
01402 rich +="<";
01403 else if ( plain[i] == '>' )
01404 rich +=">";
01405 else if ( plain[i] == '&' )
01406 rich +="&";
01407 else
01408 rich += plain[i];
01409 ++col;
01410 }
01411 }
01412 if ( col != 0 )
01413 rich += "</p>";
01414 return rich;
01415 }
01416
01423 QString QStyleSheet::escape( const QString& plain)
01424 {
01425 QString rich;
01426 for ( int i = 0; i < int(plain.length()); ++i ) {
01427 if ( plain[i] == '<' )
01428 rich +="<";
01429 else if ( plain[i] == '>' )
01430 rich +=">";
01431 else if ( plain[i] == '&' )
01432 rich +="&";
01433 else
01434 rich += plain[i];
01435 }
01436 return rich;
01437 }
01438
01439
01440
01470 bool QStyleSheet::mightBeRichText( const QString& text)
01471 {
01472 if ( text.isEmpty() )
01473 return FALSE;
01474 if ( text.left(5).lower() == "<!doc" )
01475 return TRUE;
01476 int open = 0;
01477 while ( open < int(text.length()) && text[open] != '<'
01478 && text[open] != '\n' && text[open] != '&')
01479 ++open;
01480 if ( text[open] == '&' ) {
01481 if ( text.mid(open+1,3) == "lt;" )
01482 return TRUE;
01483 } else if ( text[open] == '<' ) {
01484 int close = text.find('>', open);
01485 if ( close > -1 ) {
01486 QString tag;
01487 for (int i = open+1; i < close; ++i) {
01488 if ( text[i].isDigit() || text[i].isLetter() )
01489 tag += text[i];
01490 else if ( !tag.isEmpty() && text[i].isSpace() )
01491 break;
01492 else if ( !text[i].isSpace() && (!tag.isEmpty() || text[i] != '!' ) )
01493 return FALSE;
01494 }
01495 return defaultSheet()->item( tag.lower() ) != 0;
01496 }
01497 }
01498 return FALSE;
01499 }
01500
01501
01515 void QStyleSheet::error( const QString& ) const
01516 {
01517 }
01518
01519
01531 void QStyleSheet::scaleFont( QFont& font, int logicalSize ) const
01532 {
01533 if ( logicalSize < 1 )
01534 logicalSize = 1;
01535 if ( logicalSize > 7 )
01536 logicalSize = 7;
01537 int baseSize = font.pointSize();
01538 bool pixel = FALSE;
01539 if ( baseSize == -1 ) {
01540 baseSize = font.pixelSize();
01541 pixel = TRUE;
01542 }
01543 int s;
01544 switch ( logicalSize ) {
01545 case 1:
01546 s = baseSize/2;
01547 break;
01548 case 2:
01549 s = (8 * baseSize) / 10;
01550 break;
01551 case 4:
01552 s = (12 * baseSize) / 10;
01553 break;
01554 case 5:
01555 s = (15 * baseSize) / 10;
01556 break;
01557 case 6:
01558 s = 2 * baseSize;
01559 break;
01560 case 7:
01561 s = (24 * baseSize) / 10;
01562 break;
01563 default:
01564 s = baseSize;
01565 }
01566 if ( pixel )
01567 font.setPixelSize( s );
01568 else
01569 font.setPointSize( s );
01570 }