• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdehtml
 

tdehtml

  • tdehtml
  • dom
css_stylesheet.cpp
1 
24 #include "dom/dom_exception.h"
25 #include "dom/css_rule.h"
26 #include "dom/dom_doc.h"
27 
28 #include "xml/dom_docimpl.h"
29 
30 #include "html/html_headimpl.h"
31 
32 #include "css/css_stylesheetimpl.h"
33 #include "misc/htmlhashes.h"
34 
35 #include <stdio.h>
36 
37 using namespace DOM;
38 
39 StyleSheet::StyleSheet()
40 {
41  impl = 0;
42 }
43 
44 StyleSheet::StyleSheet(const StyleSheet &other)
45 {
46  impl = other.impl;
47  if(impl) impl->ref();
48 }
49 
50 StyleSheet::StyleSheet(StyleSheetImpl *i)
51 {
52  impl = i;
53  if(impl) impl->ref();
54 }
55 
56 StyleSheet &StyleSheet::operator = (const StyleSheet &other)
57 {
58  if ( impl != other.impl ) {
59  if(impl) impl->deref();
60  impl = other.impl;
61  if(impl) impl->ref();
62  }
63  return *this;
64 }
65 
66 StyleSheet::~StyleSheet()
67 {
68  if(impl) impl->deref();
69 }
70 
71 DOMString StyleSheet::type() const
72 {
73  if(!impl) return DOMString();
74  return ((StyleSheetImpl *)impl)->type();
75 }
76 
77 bool StyleSheet::disabled() const
78 {
79  if(!impl) return 0;
80  return ((StyleSheetImpl *)impl)->disabled();
81 }
82 
83 void StyleSheet::setDisabled( bool _disabled )
84 {
85  if(impl)
86  ((StyleSheetImpl *)impl)->setDisabled( _disabled );
87 }
88 
89 DOM::Node StyleSheet::ownerNode() const
90 {
91  if(!impl) return Node();
92  return ((StyleSheetImpl *)impl)->ownerNode();
93 }
94 
95 StyleSheet StyleSheet::parentStyleSheet() const
96 {
97  if(!impl) return 0;
98  return ((StyleSheetImpl *)impl)->parentStyleSheet();
99 }
100 
101 DOMString StyleSheet::href() const
102 {
103  if(!impl) return DOMString();
104  return ((StyleSheetImpl *)impl)->href();
105 }
106 
107 DOMString StyleSheet::title() const
108 {
109  if(!impl) return DOMString();
110  return ((StyleSheetImpl *)impl)->title();
111 }
112 
113 MediaList StyleSheet::media() const
114 {
115  if(!impl) return 0;
116  return ((StyleSheetImpl *)impl)->media();
117 }
118 
119 bool StyleSheet::isCSSStyleSheet() const
120 {
121  if(!impl) return false;
122  return ((StyleSheetImpl *)impl)->isCSSStyleSheet();
123 }
124 
125 CSSStyleSheet::CSSStyleSheet() : StyleSheet()
126 {
127 }
128 
129 CSSStyleSheet::CSSStyleSheet(const CSSStyleSheet &other) : StyleSheet(other)
130 {
131 }
132 
133 CSSStyleSheet::CSSStyleSheet(const StyleSheet &other)
134 {
135  if (!other.isCSSStyleSheet())
136  impl = 0;
137  else
138  operator=(other);
139 }
140 
141 CSSStyleSheet::CSSStyleSheet(CSSStyleSheetImpl *impl) : StyleSheet(impl)
142 {
143 }
144 
145 CSSStyleSheet &CSSStyleSheet::operator = (const CSSStyleSheet &other)
146 {
147  StyleSheet::operator = (other);
148  return *this;
149 }
150 
151 CSSStyleSheet &CSSStyleSheet::operator = (const StyleSheet &other)
152 {
153  if(!other.handle()->isCSSStyleSheet())
154  {
155  if(impl) impl->deref();
156  impl = 0;
157  } else {
158  StyleSheet::operator = (other);
159  }
160  return *this;
161 }
162 
163 CSSStyleSheet::~CSSStyleSheet()
164 {
165 }
166 
167 CSSRule CSSStyleSheet::ownerRule() const
168 {
169  if(!impl) return 0;
170  return ((CSSStyleSheetImpl *)impl)->ownerRule();
171 }
172 
173 CSSRuleList CSSStyleSheet::cssRules() const
174 {
175  if(!impl) return (CSSRuleListImpl*)0;
176  return ((CSSStyleSheetImpl *)impl)->cssRules();
177 }
178 
179 unsigned long CSSStyleSheet::insertRule( const DOMString &rule, unsigned long index )
180 {
181  int exceptioncode = 0;
182  if(!impl) return 0;
183  unsigned long retval = ((CSSStyleSheetImpl *)impl)->insertRule( rule, index, exceptioncode );
184  if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET )
185  throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET );
186  if ( exceptioncode )
187  throw DOMException( exceptioncode );
188  return retval;
189 }
190 
191 void CSSStyleSheet::deleteRule( unsigned long index )
192 {
193  int exceptioncode = 0;
194  if(impl)
195  ((CSSStyleSheetImpl *)impl)->deleteRule( index, exceptioncode );
196  if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET )
197  throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET );
198  if ( exceptioncode )
199  throw DOMException( exceptioncode );
200 }
201 
202 
203 
204 StyleSheetList::StyleSheetList()
205 {
206  impl = 0;
207 }
208 
209 StyleSheetList::StyleSheetList(const StyleSheetList &other)
210 {
211  impl = other.impl;
212  if(impl) impl->ref();
213 }
214 
215 StyleSheetList::StyleSheetList(StyleSheetListImpl *i)
216 {
217  impl = i;
218  if(impl) impl->ref();
219 }
220 
221 StyleSheetList &StyleSheetList::operator = (const StyleSheetList &other)
222 {
223  if ( impl != other.impl ) {
224  if(impl) impl->deref();
225  impl = other.impl;
226  if(impl) impl->ref();
227  }
228  return *this;
229 }
230 
231 StyleSheetList::~StyleSheetList()
232 {
233  if(impl) impl->deref();
234 }
235 
236 unsigned long StyleSheetList::length() const
237 {
238  if(!impl) return 0;
239  return ((StyleSheetListImpl *)impl)->length();
240 }
241 
242 StyleSheet StyleSheetList::item( unsigned long index )
243 {
244  if(!impl) return StyleSheet();
245  return ((StyleSheetListImpl *)impl)->item( index );
246 }
247 
248 StyleSheetListImpl *StyleSheetList::handle() const
249 {
250  return impl;
251 }
252 
253 bool StyleSheetList::isNull() const
254 {
255  return (impl == 0);
256 }
257 
258 // ----------------------------------------------------------
259 
260 MediaList::MediaList()
261 {
262  impl = 0;
263 }
264 
265 MediaList::MediaList(const MediaList &other)
266 {
267  impl = other.impl;
268  if(impl) impl->ref();
269 }
270 
271 MediaList::MediaList(MediaListImpl *i)
272 {
273  impl = i;
274  if(impl) impl->ref();
275 }
276 
277 MediaList &MediaList::operator = (const MediaList &other)
278 {
279  if ( impl != other.impl ) {
280  if(impl) impl->deref();
281  impl = other.impl;
282  if(impl) impl->ref();
283  }
284  return *this;
285 }
286 
287 MediaList::~MediaList()
288 {
289  if(impl) impl->deref();
290 }
291 
292 DOM::DOMString MediaList::mediaText() const
293 {
294  if(!impl) return DOMString();
295  return static_cast<MediaListImpl *>(impl)->mediaText();
296 }
297 
298 void MediaList::setMediaText(const DOM::DOMString &value )
299 {
300  if(impl)
301  static_cast<MediaListImpl *>(impl)->setMediaText( value );
302 }
303 
304 unsigned long MediaList::length() const
305 {
306  if(!impl) return 0;
307  return ((MediaListImpl *)impl)->length();
308 }
309 
310 DOM::DOMString MediaList::item(unsigned long index) const
311 {
312  if(!impl) return DOMString();
313  return ((MediaListImpl *)impl)->item( index );
314 }
315 
316 void MediaList::deleteMedium(const DOM::DOMString &oldMedium)
317 {
318  if(impl)
319  ((MediaListImpl *)impl)->deleteMedium( oldMedium );
320 }
321 
322 void MediaList::appendMedium(const DOM::DOMString &newMedium)
323 {
324  if(impl)
325  ((MediaListImpl *)impl)->appendMedium( newMedium );
326 }
327 
328 MediaListImpl *MediaList::handle() const
329 {
330  return impl;
331 }
332 
333 bool MediaList::isNull() const
334 {
335  return (impl == 0);
336 }
337 
338 // ----------------------------------------------------------
339 
340 LinkStyle::LinkStyle()
341 {
342  node = 0;
343 }
344 
345 LinkStyle::LinkStyle(const LinkStyle &other)
346 {
347  node = other.node;
348  if(node) node->ref();
349 }
350 
351 LinkStyle & LinkStyle::operator = (const LinkStyle &other)
352 {
353  if ( node != other.node ) {
354  if(node) node->deref();
355  node = other.node;
356  if(node) node->ref();
357  }
358  return *this;
359 }
360 
361 LinkStyle & LinkStyle::operator = (const Node &other)
362 {
363  if(node) node->deref();
364  node = 0;
365  // ### add processing instructions
366  NodeImpl *n = other.handle();
367 
368  // ### check link is really linking a style sheet
369  if( n && n->isElementNode() &&
370  (n->id() == ID_STYLE || n->id() == ID_LINK) ) {
371  node = n;
372  if(node) node->ref();
373  }
374  return *this;
375 }
376 
377 LinkStyle::~LinkStyle()
378 {
379  if(node) node->deref();
380 }
381 
382 StyleSheet LinkStyle::sheet()
383 {
384  int id = node ? node->id() : 0;
385  // ### add PI
386  return
387  ( id == ID_STYLE) ?
388  static_cast<HTMLStyleElementImpl *>(node)->sheet()
389  : ( (id == ID_LINK) ?
390  static_cast<HTMLLinkElementImpl *>(node)->sheet()
391  : StyleSheet() );
392 }
393 
394 bool LinkStyle::isNull() const
395 {
396  return (node == 0);
397 }
398 
399 
400 // ----------------------------------------------------------
401 
402 DocumentStyle::DocumentStyle()
403 {
404  doc = 0;
405 }
406 
407 DocumentStyle::DocumentStyle(const DocumentStyle &other)
408 {
409  doc = other.doc;
410  if(doc) doc->ref();
411 }
412 
413 DocumentStyle & DocumentStyle::operator = (const DocumentStyle &other)
414 {
415  if ( doc != other.doc ) {
416  if(doc) doc->deref();
417  doc = other.doc;
418  if(doc) doc->ref();
419  }
420  return *this;
421 }
422 
423 DocumentStyle & DocumentStyle::operator = (const Document &other)
424 {
425  DocumentImpl *odoc = static_cast<DocumentImpl *>(other.handle());
426  if ( doc != odoc ) {
427  if(doc) doc->deref();
428  doc = odoc;
429  if(doc) doc->ref();
430  }
431  return *this;
432 }
433 
434 DocumentStyle::~DocumentStyle()
435 {
436  if(doc) doc->deref();
437 }
438 
439 StyleSheetList DocumentStyle::styleSheets()
440 {
441  return doc->styleSheets();
442 }
443 
444 DOMString DocumentStyle::preferredStylesheetSet() const
445 {
446  return doc->preferredStylesheetSet();
447 }
448 
449 void DocumentStyle::setSelectedStylesheetSet(const DOMString& aStr)
450 {
451  return doc->setSelectedStylesheetSet(aStr);
452 }
453 
454 DOMString DocumentStyle::selectedStylesheetSet() const
455 {
456  return doc->selectedStylesheetSet();
457 }
DOM::StyleSheet::href
DOM::DOMString href() const
If the style sheet is a linked style sheet, the value of its attribute is its location.
Definition: css_stylesheet.cpp:101
DOM::Node
The Node interface is the primary datatype for the entire Document Object Model.
Definition: dom_node.h:274
DOM::StyleSheet::parentStyleSheet
StyleSheet parentStyleSheet() const
For style sheet languages that support the concept of style sheet inclusion, this attribute represent...
Definition: css_stylesheet.cpp:95
DOM::StyleSheet::disabled
bool disabled() const
false if the style sheet is applied to the document.
Definition: css_stylesheet.cpp:77
DOM::CSSStyleSheet::cssRules
CSSRuleList cssRules() const
The list of all CSS rules contained within the style sheet.
Definition: css_stylesheet.cpp:173
DOM::MediaList::setMediaText
void setMediaText(const DOM::DOMString &value)
see mediaText
Definition: css_stylesheet.cpp:298
DOM::CSSStyleSheet::ownerRule
CSSRule ownerRule() const
If this style sheet comes from an @import rule, the ownerRule attribute will contain the CSSImportRul...
Definition: css_stylesheet.cpp:167
DOM::MediaList::item
DOM::DOMString item(unsigned long index) const
Returns the indexth in the list.
Definition: css_stylesheet.cpp:310
DOM::DOMException
DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impos...
Definition: dom_exception.h:57
DOM::CSSStyleSheet::insertRule
unsigned long insertRule(const DOM::DOMString &rule, unsigned long index)
Used to insert a new rule into the style sheet.
Definition: css_stylesheet.cpp:179
DOM::CSSStyleSheet
The CSSStyleSheet interface is a concrete interface used to represent a CSS style sheet i...
Definition: css_stylesheet.h:207
DOM::StyleSheet::setDisabled
void setDisabled(bool)
see disabled
Definition: css_stylesheet.cpp:83
DOM::StyleSheet::media
MediaList media() const
The intended destination media for style information.
Definition: css_stylesheet.cpp:113
DOM::MediaList
The MediaList interface provides the abstraction of an ordered collection of media, without defining or constraining how this collection is implemented.
Definition: css_stylesheet.h:363
DOM::StyleSheet::title
DOM::DOMString title() const
The advisory title.
Definition: css_stylesheet.cpp:107
DOM::StyleSheetList
The StyleSheetList interface provides the abstraction of an ordered collection of style sheets...
Definition: css_stylesheet.h:309
DOM::MediaList::deleteMedium
void deleteMedium(const DOM::DOMString &oldMedium)
Deletes the medium indicated by oldMedium from the list.
Definition: css_stylesheet.cpp:316
DOM::DOMString
This class implements the basic string we use in the DOM.
Definition: dom_string.h:43
DOM::Document
The Document interface represents the entire HTML or XML document.
Definition: dom_doc.h:245
DOM::MediaList::length
unsigned long length() const
The number of media in the list.
Definition: css_stylesheet.cpp:304
DOM::CSSStyleSheet::deleteRule
void deleteRule(unsigned long index)
Used to delete a rule from the style sheet.
Definition: css_stylesheet.cpp:191
DOM::MediaList::mediaText
DOM::DOMString mediaText() const
The parsable textual representation of the media list.
Definition: css_stylesheet.cpp:292
DOM
The Document Object Model (DOM) is divided into two parts, the COREDOM core DOM, specifying some core...
Definition: design.h:56
DOM::MediaList::appendMedium
void appendMedium(const DOM::DOMString &newMedium)
Adds the medium newMedium to the end of the list.
Definition: css_stylesheet.cpp:322
DOM::CSSRuleList
The CSSRuleList interface provides the abstraction of an ordered collection of CSS rules...
Definition: css_rule.h:484
DOM::StyleSheet
The StyleSheet interface is the abstract base interface for any type of style sheet.
Definition: css_stylesheet.h:58
DOM::StyleSheet::type
DOM::DOMString type() const
This specifies the style sheet language for this style sheet.
Definition: css_stylesheet.cpp:71
DOM::StyleSheetList::length
unsigned long length() const
The number of StyleSheet in the list.
Definition: css_stylesheet.cpp:236
DOM::CSSRule
The CSSRule interface is the abstract base interface for any type of CSS statement ...
Definition: css_rule.h:52
DOM::StyleSheetList::item
StyleSheet item(unsigned long index)
Used to retrieve a style sheet by ordinal index.
Definition: css_stylesheet.cpp:242
DOM::StyleSheet::ownerNode
DOM::Node ownerNode() const
The node that associates this style sheet with the document.
Definition: css_stylesheet.cpp:89
DOM::CSSException
This exception is raised when a specific CSS operation is impossible to perform.
Definition: css_stylesheet.h:173

tdehtml

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

tdehtml

Skip menu "tdehtml"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdehtml by doxygen 1.8.8
This website is maintained by Timothy Pearson.