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

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
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
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