css_value.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "dom/css_rule.h"
00024 #include "dom/dom_exception.h"
00025
00026 #include "css/css_valueimpl.h"
00027
00028 namespace DOM {
00029
00030 CSSStyleDeclaration::CSSStyleDeclaration()
00031 {
00032 impl = 0;
00033 }
00034
00035 CSSStyleDeclaration::CSSStyleDeclaration(const CSSStyleDeclaration &other)
00036 {
00037 impl = other.impl;
00038 if(impl) impl->ref();
00039 }
00040
00041 CSSStyleDeclaration::CSSStyleDeclaration(CSSStyleDeclarationImpl *i)
00042 {
00043 impl = i;
00044 if(impl) impl->ref();
00045 }
00046
00047 CSSStyleDeclaration &CSSStyleDeclaration::operator = (const CSSStyleDeclaration &other)
00048 {
00049 if ( impl != other.impl ) {
00050 if(impl) impl->deref();
00051 impl = other.impl;
00052 if(impl) impl->ref();
00053 }
00054 return *this;
00055 }
00056
00057 CSSStyleDeclaration::~CSSStyleDeclaration()
00058 {
00059 if(impl) impl->deref();
00060 }
00061
00062 DOMString CSSStyleDeclaration::cssText() const
00063 {
00064 if(!impl) return DOMString();
00065 return static_cast<CSSStyleDeclarationImpl *>(impl)->cssText();
00066 }
00067
00068 void CSSStyleDeclaration::setCssText( const DOMString &value )
00069 {
00070 if(!impl) return;
00071 impl->setCssText(value);
00072 }
00073
00074 DOMString CSSStyleDeclaration::getPropertyValue( const DOMString &propertyName )
00075 {
00076 return const_cast<const CSSStyleDeclaration*>( this )->getPropertyValue( propertyName );
00077 }
00078
00079 DOMString CSSStyleDeclaration::getPropertyValue( const DOMString &propertyName ) const
00080 {
00081 if(!impl) return DOMString();
00082 int id = getPropertyID(propertyName.string().ascii(), propertyName.length());
00083 if (!id) return DOMString();
00084 return static_cast<CSSStyleDeclarationImpl *>(impl)->getPropertyValue(id);
00085 }
00086
00087 CSSValue CSSStyleDeclaration::getPropertyCSSValue( const DOMString &propertyName )
00088 {
00089 return const_cast<const CSSStyleDeclaration*>( this )->getPropertyCSSValue( propertyName );
00090 }
00091
00092 CSSValue CSSStyleDeclaration::getPropertyCSSValue( const DOMString &propertyName ) const
00093 {
00094 if(!impl) return 0;
00095 int id = getPropertyID(propertyName.string().ascii(), propertyName.length());
00096 if (!id) return 0;
00097 return static_cast<CSSStyleDeclarationImpl *>(impl)->getPropertyCSSValue(id);
00098 }
00099
00100 DOMString CSSStyleDeclaration::removeProperty( const DOMString &property )
00101 {
00102 int id = getPropertyID(property.string().ascii(), property.length());
00103 if(!impl || !id) return DOMString();
00104 return static_cast<CSSStyleDeclarationImpl *>(impl)->removeProperty( id );
00105 }
00106
00107 DOMString CSSStyleDeclaration::getPropertyPriority( const DOMString &propertyName )
00108 {
00109 return const_cast<const CSSStyleDeclaration*>( this )->getPropertyPriority( propertyName );
00110 }
00111
00112 DOMString CSSStyleDeclaration::getPropertyPriority( const DOMString &propertyName ) const
00113 {
00114 int id = getPropertyID(propertyName.string().ascii(), propertyName.length());
00115 if(!impl || !id) return DOMString();
00116 if (impl->getPropertyPriority(id))
00117 return DOMString("important");
00118 return DOMString();
00119 }
00120
00121 void CSSStyleDeclaration::setProperty( const DOMString &propName, const DOMString &value, const DOMString &priority )
00122 {
00123 if(!impl) return;
00124 int id = getPropertyID(propName.string().lower().ascii(), propName.length());
00125 if (!id) return;
00126 bool important = false;
00127 QString str = priority.string();
00128 if (str.find("important", 0, false) != -1)
00129 important = true;
00130
00131 static_cast<CSSStyleDeclarationImpl *>(impl)->setProperty( id, value, important );
00132 }
00133
00134 unsigned long CSSStyleDeclaration::length() const
00135 {
00136 if(!impl) return 0;
00137 return static_cast<CSSStyleDeclarationImpl *>(impl)->length();
00138 }
00139
00140 DOMString CSSStyleDeclaration::item( unsigned long index )
00141 {
00142 return const_cast<const CSSStyleDeclaration*>( this )->item( index );
00143 }
00144
00145 DOMString CSSStyleDeclaration::item( unsigned long index ) const
00146 {
00147 if(!impl) return DOMString();
00148 return static_cast<CSSStyleDeclarationImpl *>(impl)->item( index );
00149 }
00150 CSSRule CSSStyleDeclaration::parentRule() const
00151 {
00152 if(!impl) return 0;
00153 return static_cast<CSSStyleDeclarationImpl *>(impl)->parentRule();
00154 }
00155
00156 CSSStyleDeclarationImpl *CSSStyleDeclaration::handle() const
00157 {
00158 return impl;
00159 }
00160
00161 bool CSSStyleDeclaration::isNull() const
00162 {
00163 return (impl == 0);
00164 }
00165
00166
00167
00168 CSSValue::CSSValue()
00169 {
00170 impl = 0;
00171 }
00172
00173 CSSValue::CSSValue(const CSSValue &other)
00174 {
00175 impl = other.impl;
00176 if(impl) impl->ref();
00177 }
00178
00179 CSSValue::CSSValue(CSSValueImpl *i)
00180 {
00181 impl = i;
00182 if(impl) impl->ref();
00183 }
00184
00185 CSSValue &CSSValue::operator = (const CSSValue &other)
00186 {
00187 if ( impl != other.impl ) {
00188 if(impl) impl->deref();
00189 impl = other.impl;
00190 if(impl) impl->ref();
00191 }
00192 return *this;
00193 }
00194
00195 CSSValue::~CSSValue()
00196 {
00197 if(impl) impl->deref();
00198 }
00199
00200 DOMString CSSValue::cssText() const
00201 {
00202 if(!impl) return DOMString();
00203 return ((CSSValueImpl *)impl)->cssText();
00204 }
00205
00206 void CSSValue::setCssText( const DOMString & )
00207 {
00208 if(!impl) return;
00209 ((CSSValueImpl *)impl)->cssText();
00210 }
00211
00212 unsigned short CSSValue::cssValueType() const
00213 {
00214 if(!impl) return 0;
00215 return ((CSSValueImpl *)impl)->cssValueType();
00216 }
00217
00218 bool CSSValue::isCSSValueList() const
00219 {
00220 if(!impl) return false;
00221 return ((CSSValueImpl *)impl)->isValueList();
00222 }
00223
00224 bool CSSValue::isCSSPrimitiveValue() const
00225 {
00226 if(!impl) return false;
00227 return ((CSSValueImpl *)impl)->isPrimitiveValue();
00228 }
00229
00230 CSSValueImpl *CSSValue::handle() const
00231 {
00232 return impl;
00233 }
00234
00235 bool CSSValue::isNull() const
00236 {
00237 return (impl == 0);
00238 }
00239
00240
00241
00242 CSSValueList::CSSValueList() : CSSValue()
00243 {
00244 }
00245
00246 CSSValueList::CSSValueList(const CSSValueList &other) : CSSValue(other)
00247 {
00248 }
00249
00250 CSSValueList::CSSValueList(const CSSValue &other)
00251 {
00252 impl = 0;
00253 operator=(other);
00254 }
00255
00256 CSSValueList::CSSValueList(CSSValueListImpl *impl) : CSSValue(impl)
00257 {
00258 }
00259
00260 CSSValueList &CSSValueList::operator = (const CSSValueList &other)
00261 {
00262 if ( impl != other.impl ) {
00263 if (impl) impl->deref();
00264 impl = other.handle();
00265 if (impl) impl->ref();
00266 }
00267 return *this;
00268 }
00269
00270 CSSValueList &CSSValueList::operator = (const CSSValue &other)
00271 {
00272 CSSValueImpl *ohandle = other.handle() ;
00273 if ( impl != ohandle ) {
00274 if (impl) impl->deref();
00275 if (!other.isNull() && !other.isCSSValueList()) {
00276 impl = 0;
00277 } else {
00278 impl = ohandle;
00279 if (impl) impl->ref();
00280 }
00281 }
00282 return *this;
00283 }
00284
00285 CSSValueList::~CSSValueList()
00286 {
00287 }
00288
00289 unsigned long CSSValueList::length() const
00290 {
00291 if(!impl) return 0;
00292 return ((CSSValueListImpl *)impl)->length();
00293 }
00294
00295 CSSValue CSSValueList::item( unsigned long index )
00296 {
00297 if(!impl) return 0;
00298 return ((CSSValueListImpl *)impl)->item( index );
00299 }
00300
00301
00302
00303 CSSPrimitiveValue::CSSPrimitiveValue() : CSSValue()
00304 {
00305 }
00306
00307 CSSPrimitiveValue::CSSPrimitiveValue(const CSSPrimitiveValue &other) : CSSValue(other)
00308 {
00309 }
00310
00311 CSSPrimitiveValue::CSSPrimitiveValue(const CSSValue &other) : CSSValue(other)
00312 {
00313 impl = 0;
00314 operator=(other);
00315 }
00316
00317 CSSPrimitiveValue::CSSPrimitiveValue(CSSPrimitiveValueImpl *impl) : CSSValue(impl)
00318 {
00319 }
00320
00321 CSSPrimitiveValue &CSSPrimitiveValue::operator = (const CSSPrimitiveValue &other)
00322 {
00323 if ( impl != other.impl ) {
00324 if (impl) impl->deref();
00325 impl = other.handle();
00326 if (impl) impl->ref();
00327 }
00328 return *this;
00329 }
00330
00331 CSSPrimitiveValue &CSSPrimitiveValue::operator = (const CSSValue &other)
00332 {
00333 CSSValueImpl *ohandle = other.handle();
00334 if ( impl != ohandle ) {
00335 if (impl) impl->deref();
00336 if (!other.isNull() && !other.isCSSPrimitiveValue()) {
00337 impl = 0;
00338 } else {
00339 impl = ohandle;
00340 if (impl) impl->ref();
00341 }
00342 }
00343 return *this;
00344 }
00345
00346 CSSPrimitiveValue::~CSSPrimitiveValue()
00347 {
00348 }
00349
00350 unsigned short CSSPrimitiveValue::primitiveType() const
00351 {
00352 if(!impl) return 0;
00353 return ((CSSPrimitiveValueImpl *)impl)->primitiveType();
00354 }
00355
00356 void CSSPrimitiveValue::setFloatValue( unsigned short unitType, float floatValue )
00357 {
00358 if(!impl) return;
00359 int exceptioncode = 0;
00360 ((CSSPrimitiveValueImpl *)impl)->setFloatValue( unitType, floatValue, exceptioncode );
00361 if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET )
00362 throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET );
00363 if ( exceptioncode )
00364 throw DOMException( exceptioncode );
00365 }
00366
00367 float CSSPrimitiveValue::getFloatValue( unsigned short unitType )
00368 {
00369 if(!impl) return 0;
00370
00371 if(primitiveType() != unitType)
00372 throw CSSException(CSSException::SYNTAX_ERR);
00373 return ((CSSPrimitiveValueImpl *)impl)->floatValue( unitType );
00374 }
00375
00376 void CSSPrimitiveValue::setStringValue( unsigned short stringType, const DOMString &stringValue )
00377 {
00378 int exceptioncode = 0;
00379 if(impl)
00380 ((CSSPrimitiveValueImpl *)impl)->setStringValue( stringType, stringValue, exceptioncode );
00381 if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET )
00382 throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET );
00383 if ( exceptioncode )
00384 throw DOMException( exceptioncode );
00385
00386 }
00387
00388 DOMString CSSPrimitiveValue::getStringValue( )
00389 {
00390 if(!impl) return DOMString();
00391 return ((CSSPrimitiveValueImpl *)impl)->getStringValue( );
00392 }
00393
00394 Counter CSSPrimitiveValue::getCounterValue( )
00395 {
00396 if(!impl) return Counter();
00397 return ((CSSPrimitiveValueImpl *)impl)->getCounterValue( );
00398 }
00399
00400 Rect CSSPrimitiveValue::getRectValue( )
00401 {
00402 if(!impl) return Rect();
00403 return ((CSSPrimitiveValueImpl *)impl)->getRectValue( );
00404 }
00405
00406 RGBColor CSSPrimitiveValue::getRGBColorValue( )
00407 {
00408
00409 return RGBColor();
00410
00411
00412 }
00413
00414
00415
00416 Counter::Counter()
00417 {
00418 }
00419
00420 Counter::Counter(const Counter &)
00421 {
00422 impl = 0;
00423 }
00424
00425 Counter &Counter::operator = (const Counter &other)
00426 {
00427 if ( impl != other.impl ) {
00428 if (impl) impl->deref();
00429 impl = other.impl;
00430 if (impl) impl->ref();
00431 }
00432 return *this;
00433 }
00434
00435 Counter::Counter(CounterImpl *i)
00436 {
00437 impl = i;
00438 if (impl) impl->ref();
00439 }
00440
00441 Counter::~Counter()
00442 {
00443 if (impl) impl->deref();
00444 }
00445
00446 DOMString Counter::identifier() const
00447 {
00448 if (!impl) return DOMString();
00449 return impl->identifier();
00450 }
00451
00452 DOMString Counter::listStyle() const
00453 {
00454 if (!impl) return DOMString();
00455 return impl->listStyle();
00456 }
00457
00458 DOMString Counter::separator() const
00459 {
00460 if (!impl) return DOMString();
00461 return impl->separator();
00462 }
00463
00464 CounterImpl *Counter::handle() const
00465 {
00466 return impl;
00467 }
00468
00469 bool Counter::isNull() const
00470 {
00471 return (impl == 0);
00472 }
00473
00474
00475
00476 RGBColor::RGBColor()
00477 {
00478 }
00479
00480 RGBColor::RGBColor(const RGBColor &other)
00481 {
00482 m_color = other.m_color;
00483 }
00484
00485 RGBColor::RGBColor(QRgb color)
00486 {
00487 m_color = color;
00488 }
00489
00490 RGBColor &RGBColor::operator = (const RGBColor &other)
00491 {
00492 m_color = other.m_color;
00493 return *this;
00494 }
00495
00496 RGBColor::~RGBColor()
00497 {
00498 }
00499
00500 CSSPrimitiveValue RGBColor::red() const
00501 {
00502 return new CSSPrimitiveValueImpl(float(qAlpha(m_color) ? qRed(m_color) : 0), CSSPrimitiveValue::CSS_DIMENSION);
00503 }
00504
00505 CSSPrimitiveValue RGBColor::green() const
00506 {
00507 return new CSSPrimitiveValueImpl(float(qAlpha(m_color) ? qGreen(m_color) : 0), CSSPrimitiveValue::CSS_DIMENSION);
00508 }
00509
00510 CSSPrimitiveValue RGBColor::blue() const
00511 {
00512 return new CSSPrimitiveValueImpl(float(qAlpha(m_color) ? qBlue(m_color) : 0), CSSPrimitiveValue::CSS_DIMENSION);
00513 }
00514
00515
00516
00517
00518 Rect::Rect()
00519 {
00520 impl = 0;
00521 }
00522
00523 Rect::Rect(const Rect &other)
00524 {
00525 impl = other.impl;
00526 if (impl) impl->ref();
00527 }
00528
00529 Rect::Rect(RectImpl *i)
00530 {
00531 impl = i;
00532 if (impl) impl->ref();
00533 }
00534
00535 Rect &Rect::operator = (const Rect &other)
00536 {
00537 if ( impl != other.impl ) {
00538 if (impl) impl->deref();
00539 impl = other.impl;
00540 if (impl) impl->ref();
00541 }
00542 return *this;
00543 }
00544
00545 Rect::~Rect()
00546 {
00547 if (impl) impl->deref();
00548 }
00549
00550 CSSPrimitiveValue Rect::top() const
00551 {
00552 if (!impl) return 0;
00553 return impl->top();
00554 }
00555
00556 CSSPrimitiveValue Rect::right() const
00557 {
00558 if (!impl) return 0;
00559 return impl->right();
00560 }
00561
00562 CSSPrimitiveValue Rect::bottom() const
00563 {
00564 if (!impl) return 0;
00565 return impl->bottom();
00566 }
00567
00568 CSSPrimitiveValue Rect::left() const
00569 {
00570 if (!impl) return 0;
00571 return impl->left();
00572 }
00573
00574 RectImpl *Rect::handle() const
00575 {
00576 return impl;
00577 }
00578
00579 bool Rect::isNull() const
00580 {
00581 return (impl == 0);
00582 }
00583
00584 }
00585
00586
This file is part of the documentation for khtml Library Version 3.3.2.