• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

KHTML

css_stylesheet.cpp

Go to the documentation of this file.
00001 
00024 #include "dom/dom_exception.h"
00025 #include "dom/css_rule.h"
00026 #include "dom/dom_doc.h"
00027 
00028 #include "xml/dom_docimpl.h"
00029 
00030 #include "html/html_headimpl.h"
00031 
00032 #include "css/css_stylesheetimpl.h"
00033 
00034 #include <stdio.h>
00035 
00036 using namespace DOM;
00037 
00038 StyleSheet::StyleSheet()
00039 {
00040     impl = 0;
00041 }
00042 
00043 StyleSheet::StyleSheet(const StyleSheet &other)
00044 {
00045     impl = other.impl;
00046     if(impl) impl->ref();
00047 }
00048 
00049 StyleSheet::StyleSheet(StyleSheetImpl *i)
00050 {
00051     impl = i;
00052     if(impl) impl->ref();
00053 }
00054 
00055 StyleSheet &StyleSheet::operator = (const StyleSheet &other)
00056 {
00057     if ( impl != other.impl ) {
00058         if(impl) impl->deref();
00059         impl = other.impl;
00060         if(impl) impl->ref();
00061     }
00062     return *this;
00063 }
00064 
00065 StyleSheet::~StyleSheet()
00066 {
00067     if(impl) impl->deref();
00068 }
00069 
00070 DOMString StyleSheet::type() const
00071 {
00072     if(!impl) return DOMString();
00073     return ((StyleSheetImpl *)impl)->type();
00074 }
00075 
00076 bool StyleSheet::disabled() const
00077 {
00078     if(!impl) return 0;
00079     return ((StyleSheetImpl *)impl)->disabled();
00080 }
00081 
00082 void StyleSheet::setDisabled( bool _disabled )
00083 {
00084     if(impl)
00085         ((StyleSheetImpl *)impl)->setDisabled( _disabled );
00086 }
00087 
00088 DOM::Node StyleSheet::ownerNode() const
00089 {
00090     if(!impl) return Node();
00091     return ((StyleSheetImpl *)impl)->ownerNode();
00092 }
00093 
00094 StyleSheet StyleSheet::parentStyleSheet() const
00095 {
00096     if(!impl) return 0;
00097     return ((StyleSheetImpl *)impl)->parentStyleSheet();
00098 }
00099 
00100 DOMString StyleSheet::href() const
00101 {
00102     if(!impl) return DOMString();
00103     return ((StyleSheetImpl *)impl)->href();
00104 }
00105 
00106 DOMString StyleSheet::title() const
00107 {
00108     if(!impl) return DOMString();
00109     return ((StyleSheetImpl *)impl)->title();
00110 }
00111 
00112 MediaList StyleSheet::media() const
00113 {
00114     if(!impl) return 0;
00115     return ((StyleSheetImpl *)impl)->media();
00116 }
00117 
00118 bool StyleSheet::isCSSStyleSheet() const
00119 {
00120     if(!impl) return false;
00121     return ((StyleSheetImpl *)impl)->isCSSStyleSheet();
00122 }
00123 
00124 KUrl StyleSheet::baseUrl() {
00125     if(!impl) return KUrl();
00126     return ((StyleSheetImpl *)impl)->baseURL();
00127 }
00128 
00129 DOMString CSSException::codeAsString() const
00130 {
00131     return codeAsString(code);
00132 }
00133 
00134 bool CSSException::isCSSExceptionCode(int exceptioncode)
00135 {
00136     return exceptioncode >= _EXCEPTION_OFFSET && exceptioncode < _EXCEPTION_MAX;
00137 }
00138 
00139 DOMString CSSException::codeAsString(int code)
00140 {
00141     switch ( code ) {
00142     case SYNTAX_ERR:
00143         return DOMString( "SYNTAX_ERR" );
00144     case INVALID_MODIFICATION_ERR:
00145         return DOMString( "INVALID_MODIFICATION_ERR" );
00146     default:
00147         return DOMString( "(unknown exception code)" );
00148     }
00149 }
00150 
00151 CSSStyleSheet::CSSStyleSheet() : StyleSheet()
00152 {
00153 }
00154 
00155 CSSStyleSheet::CSSStyleSheet(const CSSStyleSheet &other) : StyleSheet(other)
00156 {
00157 }
00158 
00159 CSSStyleSheet::CSSStyleSheet(const StyleSheet &other)
00160 {
00161     if (!other.isCSSStyleSheet())
00162     impl = 0;
00163     else
00164     operator=(other);
00165 }
00166 
00167 CSSStyleSheet::CSSStyleSheet(CSSStyleSheetImpl *impl) : StyleSheet(impl)
00168 {
00169 }
00170 
00171 CSSStyleSheet &CSSStyleSheet::operator = (const CSSStyleSheet &other)
00172 {
00173     StyleSheet::operator = (other);
00174     return *this;
00175 }
00176 
00177 CSSStyleSheet &CSSStyleSheet::operator = (const StyleSheet &other)
00178 {
00179     if(!other.handle()->isCSSStyleSheet())
00180     {
00181         if(impl) impl->deref();
00182         impl = 0;
00183     } else {
00184     StyleSheet::operator = (other);
00185     }
00186     return *this;
00187 }
00188 
00189 CSSStyleSheet::~CSSStyleSheet()
00190 {
00191 }
00192 
00193 CSSRule CSSStyleSheet::ownerRule() const
00194 {
00195     if(!impl) return 0;
00196     return ((CSSStyleSheetImpl *)impl)->ownerRule();
00197 }
00198 
00199 CSSRuleList CSSStyleSheet::cssRules() const
00200 {
00201     if(!impl) return (CSSRuleListImpl*)0;
00202     return ((CSSStyleSheetImpl *)impl)->cssRules();
00203 }
00204 
00205 unsigned long CSSStyleSheet::insertRule( const DOMString &rule, unsigned long index )
00206 {
00207     int exceptioncode = 0;
00208     if(!impl) return 0;
00209     unsigned long retval = ((CSSStyleSheetImpl *)impl)->insertRule( rule, index, exceptioncode );
00210     if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET )
00211         throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET );
00212     if ( exceptioncode )
00213         throw DOMException( exceptioncode );
00214     return retval;
00215 }
00216 
00217 void CSSStyleSheet::deleteRule( unsigned long index )
00218 {
00219     int exceptioncode = 0;
00220     if(impl)
00221         ((CSSStyleSheetImpl *)impl)->deleteRule( index, exceptioncode );
00222     if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET )
00223         throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET );
00224     if ( exceptioncode )
00225         throw DOMException( exceptioncode );
00226 }
00227 
00228 DOM::DOMString CSSStyleSheet::charset() const {
00229     if(!impl) return DOMString();
00230     return static_cast<CSSStyleSheetImpl *>(impl)->charset();
00231 }
00232 
00233 
00234 StyleSheetList::StyleSheetList()
00235 {
00236     impl = 0;
00237 }
00238 
00239 StyleSheetList::StyleSheetList(const StyleSheetList &other)
00240 {
00241     impl = other.impl;
00242     if(impl) impl->ref();
00243 }
00244 
00245 StyleSheetList::StyleSheetList(StyleSheetListImpl *i)
00246 {
00247     impl = i;
00248     if(impl) impl->ref();
00249 }
00250 
00251 StyleSheetList &StyleSheetList::operator = (const StyleSheetList &other)
00252 {
00253     if ( impl != other.impl ) {
00254         if(impl) impl->deref();
00255         impl = other.impl;
00256         if(impl) impl->ref();
00257     }
00258     return *this;
00259 }
00260 
00261 StyleSheetList::~StyleSheetList()
00262 {
00263     if(impl) impl->deref();
00264 }
00265 
00266 unsigned long StyleSheetList::length() const
00267 {
00268     if(!impl) return 0;
00269     return ((StyleSheetListImpl *)impl)->length();
00270 }
00271 
00272 StyleSheet StyleSheetList::item( unsigned long index )
00273 {
00274     if(!impl) return StyleSheet();
00275     return ((StyleSheetListImpl *)impl)->item( index );
00276 }
00277 
00278 StyleSheetListImpl *StyleSheetList::handle() const
00279 {
00280     return impl;
00281 }
00282 
00283 bool StyleSheetList::isNull() const
00284 {
00285     return (impl == 0);
00286 }
00287 
00288 // ----------------------------------------------------------
00289 
00290 MediaList::MediaList()
00291 {
00292     impl = 0;
00293 }
00294 
00295 MediaList::MediaList(const MediaList &other)
00296 {
00297     impl = other.impl;
00298     if(impl) impl->ref();
00299 }
00300 
00301 MediaList::MediaList(MediaListImpl *i)
00302 {
00303     impl = i;
00304     if(impl) impl->ref();
00305 }
00306 
00307 MediaList &MediaList::operator = (const MediaList &other)
00308 {
00309     if ( impl != other.impl ) {
00310         if(impl) impl->deref();
00311         impl = other.impl;
00312         if(impl) impl->ref();
00313     }
00314     return *this;
00315 }
00316 
00317 MediaList::~MediaList()
00318 {
00319     if(impl) impl->deref();
00320 }
00321 
00322 DOM::DOMString MediaList::mediaText() const
00323 {
00324     if(!impl) return DOMString();
00325     return static_cast<MediaListImpl *>(impl)->mediaText();
00326 }
00327 
00328 void MediaList::setMediaText(const DOM::DOMString &value )
00329 {
00330     if(!impl)
00331         return;
00332     int exceptioncode = 0;
00333     static_cast<MediaListImpl *>(impl)->setMediaText( value, exceptioncode );
00334     if ( exceptioncode )
00335         throw DOMException( exceptioncode );
00336 }
00337 
00338 unsigned long MediaList::length() const
00339 {
00340     if(!impl) return 0;
00341     return ((MediaListImpl *)impl)->length();
00342 }
00343 
00344 DOM::DOMString MediaList::item(unsigned long index) const
00345 {
00346     if(!impl) return DOMString();
00347     return ((MediaListImpl *)impl)->item( index );
00348 }
00349 
00350 void MediaList::deleteMedium(const DOM::DOMString &oldMedium)
00351 {
00352     if(!impl)
00353         return;
00354     int exceptioncode = 0;
00355     ((MediaListImpl *)impl)->deleteMedium( oldMedium, exceptioncode );
00356     if ( exceptioncode )
00357         throw DOMException( exceptioncode );
00358 }
00359 
00360 void MediaList::appendMedium(const DOM::DOMString &newMedium)
00361 {
00362     if(!impl)
00363         return;
00364     int exceptioncode = 0;
00365     ((MediaListImpl *)impl)->appendMedium( newMedium, exceptioncode );
00366     if ( exceptioncode )
00367         throw DOMException( exceptioncode );
00368 }
00369 
00370 MediaListImpl *MediaList::handle() const
00371 {
00372     return impl;
00373 }
00374 
00375 bool MediaList::isNull() const
00376 {
00377     return (impl == 0);
00378 }
00379 
00380 // ----------------------------------------------------------
00381 
00382 LinkStyle::LinkStyle()
00383 {
00384     node = 0;
00385 }
00386 
00387 LinkStyle::LinkStyle(const LinkStyle &other)
00388 {
00389     node = other.node;
00390     if(node) node->ref();
00391 }
00392 
00393 LinkStyle & LinkStyle::operator = (const LinkStyle &other)
00394 {
00395     if ( node != other.node ) {
00396         if(node) node->deref();
00397         node = other.node;
00398         if(node) node->ref();
00399     }
00400     return *this;
00401 }
00402 
00403 LinkStyle & LinkStyle::operator = (const Node &other)
00404 {
00405     if(node) node->deref();
00406     node = 0;
00407     // ### add processing instructions
00408     NodeImpl *n = other.handle();
00409 
00410     // ### check link is really linking a style sheet
00411     if( n && n->isElementNode() &&
00412     (n->id() == ID_STYLE || n->id() == ID_LINK) ) {
00413     node = n;
00414     if(node) node->ref();
00415     }
00416     return *this;
00417 }
00418 
00419 LinkStyle::~LinkStyle()
00420 {
00421     if(node) node->deref();
00422 }
00423 
00424 StyleSheet LinkStyle::sheet()
00425 {
00426     int id = node ? node->id() : 0;
00427     // ### add PI
00428     return
00429     ( id == ID_STYLE) ?
00430     static_cast<HTMLStyleElementImpl *>(node)->sheet()
00431     : ( (id == ID_LINK) ?
00432         static_cast<HTMLLinkElementImpl *>(node)->sheet()
00433         : StyleSheet() );
00434 }
00435 
00436 bool LinkStyle::isNull() const
00437 {
00438     return (node == 0);
00439 }
00440 
00441 
00442 // ----------------------------------------------------------
00443 
00444 DocumentStyle::DocumentStyle()
00445 {
00446     doc = 0;
00447 }
00448 
00449 DocumentStyle::DocumentStyle(const DocumentStyle &other)
00450 {
00451     doc = other.doc;
00452     if(doc) doc->ref();
00453 }
00454 
00455 DocumentStyle & DocumentStyle::operator = (const DocumentStyle &other)
00456 {
00457     if ( doc != other.doc ) {
00458         if(doc) doc->deref();
00459         doc = other.doc;
00460         if(doc) doc->ref();
00461     }
00462     return *this;
00463 }
00464 
00465 DocumentStyle & DocumentStyle::operator = (const Document &other)
00466 {
00467     DocumentImpl *odoc = static_cast<DocumentImpl *>(other.handle());
00468     if ( doc != odoc ) {
00469     if(doc) doc->deref();
00470     doc = odoc;
00471     if(doc) doc->ref();
00472     }
00473     return *this;
00474 }
00475 
00476 DocumentStyle::~DocumentStyle()
00477 {
00478     if(doc) doc->deref();
00479 }
00480 
00481 StyleSheetList DocumentStyle::styleSheets() const
00482 {
00483     return doc->styleSheets();
00484 }
00485 
00486 DOMString DocumentStyle::preferredStylesheetSet() const
00487 {
00488     return doc->preferredStylesheetSet();
00489 }
00490 
00491 void DocumentStyle::setSelectedStylesheetSet(const DOMString& aStr)
00492 {
00493     return doc->setSelectedStylesheetSet(aStr);
00494 }
00495 
00496 DOMString DocumentStyle::selectedStylesheetSet() const
00497 {
00498     return doc->selectedStylesheetSet();
00499 }

KHTML

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
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