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