• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KHTML

css_value.cpp

Go to the documentation of this file.
00001 /*
00002  * This file is part of the DOM implementation for KDE.
00003  *
00004  * (C) 1999 Lars Knoll (knoll@kde.org)
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public License
00017  * along with this library; see the file COPYING.LIB.  If not, write to
00018  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "dom/css_rule.h"
00024 #include "dom/dom_exception.h"
00025 
00026 #include "css/css_renderstyledeclarationimpl.h"
00027 #include "css/css_valueimpl.h"
00028 
00029 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 CSSRule CSSStyleDeclaration::parentRule() const
00152 {
00153     if(!impl) return 0;
00154     return static_cast<CSSStyleDeclarationImpl *>(impl)->parentRule();
00155 }
00156 
00157 CSSStyleDeclarationImpl *CSSStyleDeclaration::handle() const
00158 {
00159     return impl;
00160 }
00161 
00162 bool CSSStyleDeclaration::isNull() const
00163 {
00164     return (impl == 0);
00165 }
00166 
00167 // ----------------------------------------------------------
00168 
00169 CSSValue::CSSValue()
00170 {
00171     impl = 0;
00172 }
00173 
00174 CSSValue::CSSValue(const CSSValue &other)
00175 {
00176     impl = other.impl;
00177     if(impl) impl->ref();
00178 }
00179 
00180 CSSValue::CSSValue(CSSValueImpl *i)
00181 {
00182     impl = i;
00183     if(impl) impl->ref();
00184 }
00185 
00186 CSSValue &CSSValue::operator = (const CSSValue &other)
00187 {
00188     if ( impl != other.impl ) {
00189         if(impl) impl->deref();
00190         impl = other.impl;
00191         if(impl) impl->ref();
00192     }
00193     return *this;
00194 }
00195 
00196 CSSValue::~CSSValue()
00197 {
00198     if(impl) impl->deref();
00199 }
00200 
00201 DOMString CSSValue::cssText() const
00202 {
00203     if(!impl) return DOMString();
00204     return ((CSSValueImpl *)impl)->cssText();
00205 }
00206 
00207 void CSSValue::setCssText( const DOMString &/*value*/ )
00208 {
00209     if(!impl) return;
00210     ((CSSValueImpl *)impl)->cssText();
00211 }
00212 
00213 unsigned short CSSValue::cssValueType() const
00214 {
00215     if(!impl) return 0;
00216     return ((CSSValueImpl *)impl)->cssValueType();
00217 }
00218 
00219 bool CSSValue::isCSSValueList() const
00220 {
00221     if(!impl) return false;
00222     return ((CSSValueImpl *)impl)->isValueList();
00223 }
00224 
00225 bool CSSValue::isCSSPrimitiveValue() const
00226 {
00227     if(!impl) return false;
00228     return ((CSSValueImpl *)impl)->isPrimitiveValue();
00229 }
00230 
00231 CSSValueImpl *CSSValue::handle() const
00232 {
00233     return impl;
00234 }
00235 
00236 bool CSSValue::isNull() const
00237 {
00238     return (impl == 0);
00239 }
00240 
00241 // ----------------------------------------------------------
00242 
00243 CSSValueList::CSSValueList() : CSSValue()
00244 {
00245 }
00246 
00247 CSSValueList::CSSValueList(const CSSValueList &other) : CSSValue(other)
00248 {
00249 }
00250 
00251 CSSValueList::CSSValueList(const CSSValue &other)
00252 {
00253    impl = 0;
00254    operator=(other);
00255 }
00256 
00257 CSSValueList::CSSValueList(CSSValueListImpl *impl) : CSSValue(impl)
00258 {
00259 }
00260 
00261 CSSValueList &CSSValueList::operator = (const CSSValueList &other)
00262 {
00263     if ( impl != other.impl ) {
00264         if (impl) impl->deref();
00265         impl = other.handle();
00266         if (impl) impl->ref();
00267     }
00268     return *this;
00269 }
00270 
00271 CSSValueList &CSSValueList::operator = (const CSSValue &other)
00272 {
00273     CSSValueImpl *ohandle = other.handle() ;
00274     if ( impl != ohandle ) {
00275         if (impl) impl->deref();
00276         if (!other.isNull() && !other.isCSSValueList()) {
00277             impl = 0;
00278     } else {
00279         impl = ohandle;
00280             if (impl) impl->ref();
00281     }
00282     }
00283     return *this;
00284 }
00285 
00286 CSSValueList::~CSSValueList()
00287 {
00288 }
00289 
00290 unsigned long CSSValueList::length() const
00291 {
00292     if(!impl) return 0;
00293     return ((CSSValueListImpl *)impl)->length();
00294 }
00295 
00296 CSSValue CSSValueList::item( unsigned long index )
00297 {
00298     if(!impl) return 0;
00299     return ((CSSValueListImpl *)impl)->item( index );
00300 }
00301 
00302 // ----------------------------------------------------------
00303 
00304 CSSPrimitiveValue::CSSPrimitiveValue() : CSSValue()
00305 {
00306 }
00307 
00308 CSSPrimitiveValue::CSSPrimitiveValue(const CSSPrimitiveValue &other) : CSSValue(other)
00309 {
00310 }
00311 
00312 CSSPrimitiveValue::CSSPrimitiveValue(const CSSValue &other) : CSSValue(other)
00313 {
00314     impl = 0;
00315     operator=(other);
00316 }
00317 
00318 CSSPrimitiveValue::CSSPrimitiveValue(CSSPrimitiveValueImpl *impl) : CSSValue(impl)
00319 {
00320 }
00321 
00322 CSSPrimitiveValue &CSSPrimitiveValue::operator = (const CSSPrimitiveValue &other)
00323 {
00324     if ( impl != other.impl ) {
00325         if (impl) impl->deref();
00326         impl = other.handle();
00327         if (impl) impl->ref();
00328     }
00329     return *this;
00330 }
00331 
00332 CSSPrimitiveValue &CSSPrimitiveValue::operator = (const CSSValue &other)
00333 {
00334     CSSValueImpl *ohandle = other.handle();
00335     if ( impl != ohandle ) {
00336         if (impl) impl->deref();
00337         if (!other.isNull() && !other.isCSSPrimitiveValue()) {
00338             impl = 0;
00339     } else {
00340         impl = ohandle;
00341             if (impl) impl->ref();
00342     }
00343     }
00344     return *this;
00345 }
00346 
00347 CSSPrimitiveValue::~CSSPrimitiveValue()
00348 {
00349 }
00350 
00351 unsigned short CSSPrimitiveValue::primitiveType() const
00352 {
00353     if(!impl) return 0;
00354     return ((CSSPrimitiveValueImpl *)impl)->primitiveType();
00355 }
00356 
00357 void CSSPrimitiveValue::setFloatValue( unsigned short unitType, float floatValue )
00358 {
00359     if(!impl) return;
00360     int exceptioncode = 0;
00361     ((CSSPrimitiveValueImpl *)impl)->setFloatValue( unitType, floatValue, exceptioncode );
00362     if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET )
00363     throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET );
00364     if ( exceptioncode )
00365     throw DOMException( exceptioncode );
00366 }
00367 
00368 float CSSPrimitiveValue::getFloatValue( unsigned short unitType )
00369 {
00370     if(!impl) return 0;
00371     // ### add unit conversion
00372     if(primitiveType() != unitType)
00373     throw CSSException(CSSException::SYNTAX_ERR);
00374     return ((CSSPrimitiveValueImpl *)impl)->floatValue( unitType );
00375 }
00376 
00377 void CSSPrimitiveValue::setStringValue( unsigned short stringType, const DOMString &stringValue )
00378 {
00379     int exceptioncode = 0;
00380     if(impl)
00381         ((CSSPrimitiveValueImpl *)impl)->setStringValue( stringType, stringValue, exceptioncode );
00382     if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET )
00383     throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET );
00384     if ( exceptioncode )
00385     throw DOMException( exceptioncode );
00386 
00387 }
00388 
00389 DOMString CSSPrimitiveValue::getStringValue(  )
00390 {
00391     if(!impl) return DOMString();
00392     return ((CSSPrimitiveValueImpl *)impl)->getStringValue(  );
00393 }
00394 
00395 Counter CSSPrimitiveValue::getCounterValue(  )
00396 {
00397     if(!impl) return Counter();
00398     return ((CSSPrimitiveValueImpl *)impl)->getCounterValue(  );
00399 }
00400 
00401 Rect CSSPrimitiveValue::getRectValue(  )
00402 {
00403     if(!impl) return Rect();
00404     return ((CSSPrimitiveValueImpl *)impl)->getRectValue(  );
00405 }
00406 
00407 RGBColor CSSPrimitiveValue::getRGBColorValue(  )
00408 {
00409     // ###
00410     return RGBColor();
00411     //if(!impl) return RGBColor();
00412     //return ((CSSPrimitiveValueImpl *)impl)->getRGBColorValue(  );
00413 }
00414 
00415 // -------------------------------------------------------------------
00416 
00417 Counter::Counter()
00418 {
00419 }
00420 
00421 Counter::Counter(const Counter &/*other*/)
00422 {
00423     impl = 0;
00424 }
00425 
00426 Counter &Counter::operator = (const Counter &other)
00427 {
00428     if ( impl != other.impl ) {
00429         if (impl) impl->deref();
00430         impl = other.impl;
00431         if (impl) impl->ref();
00432     }
00433     return *this;
00434 }
00435 
00436 Counter::Counter(CounterImpl *i)
00437 {
00438     impl = i;
00439     if (impl) impl->ref();
00440 }
00441 
00442 Counter::~Counter()
00443 {
00444     if (impl) impl->deref();
00445 }
00446 
00447 DOMString Counter::identifier() const
00448 {
00449   if (!impl) return DOMString();
00450   return impl->identifier();
00451 }
00452 
00453 DOMString Counter::listStyle() const
00454 {
00455   if (!impl) return DOMString();
00456   return khtml::stringForListStyleType((khtml::EListStyleType)impl->listStyle());
00457 }
00458 
00459 DOMString Counter::separator() const
00460 {
00461   if (!impl) return DOMString();
00462   return impl->separator();
00463 }
00464 
00465 CounterImpl *Counter::handle() const
00466 {
00467     return impl;
00468 }
00469 
00470 bool Counter::isNull() const
00471 {
00472     return (impl == 0);
00473 }
00474 
00475 // --------------------------------------------------------------------
00476 
00477 RGBColor::RGBColor()
00478 {
00479 }
00480 
00481 RGBColor::RGBColor(const RGBColor &other)
00482 {
00483     m_color = other.m_color;
00484 }
00485 
00486 RGBColor::RGBColor(QRgb color)
00487 {
00488     m_color = color;
00489 }
00490 
00491 RGBColor &RGBColor::operator = (const RGBColor &other)
00492 {
00493     m_color = other.m_color;
00494     return *this;
00495 }
00496 
00497 RGBColor::~RGBColor()
00498 {
00499 }
00500 
00501 CSSPrimitiveValue RGBColor::red() const
00502 {
00503     return new CSSPrimitiveValueImpl(float(qAlpha(m_color) ? qRed(m_color) : 0), CSSPrimitiveValue::CSS_DIMENSION);
00504 }
00505 
00506 CSSPrimitiveValue RGBColor::green() const
00507 {
00508     return new CSSPrimitiveValueImpl(float(qAlpha(m_color) ? qGreen(m_color) : 0), CSSPrimitiveValue::CSS_DIMENSION);
00509 }
00510 
00511 CSSPrimitiveValue RGBColor::blue() const
00512 {
00513     return new CSSPrimitiveValueImpl(float(qAlpha(m_color) ? qBlue(m_color) : 0), CSSPrimitiveValue::CSS_DIMENSION);
00514 }
00515 
00516 
00517 // ---------------------------------------------------------------------
00518 
00519 Rect::Rect()
00520 {
00521     impl = 0;
00522 }
00523 
00524 Rect::Rect(const Rect &other)
00525 {
00526     impl = other.impl;
00527     if (impl) impl->ref();
00528 }
00529 
00530 Rect::Rect(RectImpl *i)
00531 {
00532     impl = i;
00533     if (impl) impl->ref();
00534 }
00535 
00536 Rect &Rect::operator = (const Rect &other)
00537 {
00538     if ( impl != other.impl ) {
00539         if (impl) impl->deref();
00540         impl = other.impl;
00541         if (impl) impl->ref();
00542     }
00543     return *this;
00544 }
00545 
00546 Rect::~Rect()
00547 {
00548     if (impl) impl->deref();
00549 }
00550 
00551 CSSPrimitiveValue Rect::top() const
00552 {
00553     if (!impl) return 0;
00554     return impl->top();
00555 }
00556 
00557 CSSPrimitiveValue Rect::right() const
00558 {
00559     if (!impl) return 0;
00560     return impl->right();
00561 }
00562 
00563 CSSPrimitiveValue Rect::bottom() const
00564 {
00565     if (!impl) return 0;
00566     return impl->bottom();
00567 }
00568 
00569 CSSPrimitiveValue Rect::left() const
00570 {
00571     if (!impl) return 0;
00572     return impl->left();
00573 }
00574 
00575 RectImpl *Rect::handle() const
00576 {
00577     return impl;
00578 }
00579 
00580 bool Rect::isNull() const
00581 {
00582     return (impl == 0);
00583 }
00584 
00585 } // namespace
00586 
00587 

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal