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

tdehtml

  • tdehtml
  • dom
css_value.cpp
1/*
2 * This file is part of the DOM implementation for KDE.
3 *
4 * (C) 1999 Lars Knoll (knoll@kde.org)
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23#include "dom/css_rule.h"
24#include "dom/dom_exception.h"
25
26#include "css/css_renderstyledeclarationimpl.h"
27#include "css/css_valueimpl.h"
28
29namespace DOM {
30
31CSSStyleDeclaration::CSSStyleDeclaration()
32{
33 impl = 0;
34}
35
36CSSStyleDeclaration::CSSStyleDeclaration(const CSSStyleDeclaration &other)
37{
38 impl = other.impl;
39 if(impl) impl->ref();
40}
41
42CSSStyleDeclaration::CSSStyleDeclaration(CSSStyleDeclarationImpl *i)
43{
44 impl = i;
45 if(impl) impl->ref();
46}
47
48CSSStyleDeclaration &CSSStyleDeclaration::operator = (const CSSStyleDeclaration &other)
49{
50 if ( impl != other.impl ) {
51 if(impl) impl->deref();
52 impl = other.impl;
53 if(impl) impl->ref();
54 }
55 return *this;
56}
57
58CSSStyleDeclaration::~CSSStyleDeclaration()
59{
60 if(impl) impl->deref();
61}
62
63DOMString CSSStyleDeclaration::cssText() const
64{
65 if(!impl) return DOMString();
66 return static_cast<CSSStyleDeclarationImpl *>(impl)->cssText();
67}
68
69void CSSStyleDeclaration::setCssText( const DOMString &value )
70{
71 if(!impl) return;
72 impl->setCssText(value);
73}
74
75DOMString CSSStyleDeclaration::getPropertyValue( const DOMString &propertyName )
76{
77 return const_cast<const CSSStyleDeclaration*>( this )->getPropertyValue( propertyName );
78}
79
80DOMString CSSStyleDeclaration::getPropertyValue( const DOMString &propertyName ) const
81{
82 if(!impl) return DOMString();
83 int id = getPropertyID(propertyName.string().ascii(), propertyName.length());
84 if (!id) return DOMString();
85 return static_cast<CSSStyleDeclarationImpl *>(impl)->getPropertyValue(id);
86}
87
88CSSValue CSSStyleDeclaration::getPropertyCSSValue( const DOMString &propertyName )
89{
90 return const_cast<const CSSStyleDeclaration*>( this )->getPropertyCSSValue( propertyName );
91}
92
93CSSValue CSSStyleDeclaration::getPropertyCSSValue( const DOMString &propertyName ) const
94{
95 if(!impl) return 0;
96 int id = getPropertyID(propertyName.string().ascii(), propertyName.length());
97 if (!id) return 0;
98 return static_cast<CSSStyleDeclarationImpl *>(impl)->getPropertyCSSValue(id);
99}
100
101DOMString CSSStyleDeclaration::removeProperty( const DOMString &property )
102{
103 int id = getPropertyID(property.string().ascii(), property.length());
104 if(!impl || !id) return DOMString();
105 return static_cast<CSSStyleDeclarationImpl *>(impl)->removeProperty( id );
106}
107
108DOMString CSSStyleDeclaration::getPropertyPriority( const DOMString &propertyName )
109{
110 return const_cast<const CSSStyleDeclaration*>( this )->getPropertyPriority( propertyName );
111}
112
113DOMString CSSStyleDeclaration::getPropertyPriority( const DOMString &propertyName ) const
114{
115 int id = getPropertyID(propertyName.string().ascii(), propertyName.length());
116 if(!impl || !id) return DOMString();
117 if (impl->getPropertyPriority(id))
118 return DOMString("important");
119 return DOMString();
120}
121
122void CSSStyleDeclaration::setProperty( const DOMString &propName, const DOMString &value, const DOMString &priority )
123{
124 if(!impl) return;
125 int id = getPropertyID(propName.string().lower().ascii(), propName.length());
126 if (!id) return;
127 bool important = false;
128 TQString str = priority.string();
129 if (str.find("important", 0, false) != -1)
130 important = true;
131
132 static_cast<CSSStyleDeclarationImpl *>(impl)->setProperty( id, value, important );
133}
134
135unsigned long CSSStyleDeclaration::length() const
136{
137 if(!impl) return 0;
138 return static_cast<CSSStyleDeclarationImpl *>(impl)->length();
139}
140
141DOMString CSSStyleDeclaration::item( unsigned long index )
142{
143 return const_cast<const CSSStyleDeclaration*>( this )->item( index );
144}
145
146DOMString CSSStyleDeclaration::item( unsigned long index ) const
147{
148 if(!impl) return DOMString();
149 return static_cast<CSSStyleDeclarationImpl *>(impl)->item( index );
150}
151CSSRule CSSStyleDeclaration::parentRule() const
152{
153 if(!impl) return 0;
154 return static_cast<CSSStyleDeclarationImpl *>(impl)->parentRule();
155}
156
157CSSStyleDeclarationImpl *CSSStyleDeclaration::handle() const
158{
159 return impl;
160}
161
162bool CSSStyleDeclaration::isNull() const
163{
164 return (impl == 0);
165}
166
167// ----------------------------------------------------------
168
169CSSValue::CSSValue()
170{
171 impl = 0;
172}
173
174CSSValue::CSSValue(const CSSValue &other)
175{
176 impl = other.impl;
177 if(impl) impl->ref();
178}
179
180CSSValue::CSSValue(CSSValueImpl *i)
181{
182 impl = i;
183 if(impl) impl->ref();
184}
185
186CSSValue &CSSValue::operator = (const CSSValue &other)
187{
188 if ( impl != other.impl ) {
189 if(impl) impl->deref();
190 impl = other.impl;
191 if(impl) impl->ref();
192 }
193 return *this;
194}
195
196CSSValue::~CSSValue()
197{
198 if(impl) impl->deref();
199}
200
201DOMString CSSValue::cssText() const
202{
203 if(!impl) return DOMString();
204 return ((CSSValueImpl *)impl)->cssText();
205}
206
207void CSSValue::setCssText( const DOMString &/*value*/ )
208{
209 if(!impl) return;
210 ((CSSValueImpl *)impl)->cssText();
211}
212
213unsigned short CSSValue::cssValueType() const
214{
215 if(!impl) return 0;
216 return ((CSSValueImpl *)impl)->cssValueType();
217}
218
219bool CSSValue::isCSSValueList() const
220{
221 if(!impl) return false;
222 return ((CSSValueImpl *)impl)->isValueList();
223}
224
225bool CSSValue::isCSSPrimitiveValue() const
226{
227 if(!impl) return false;
228 return ((CSSValueImpl *)impl)->isPrimitiveValue();
229}
230
231CSSValueImpl *CSSValue::handle() const
232{
233 return impl;
234}
235
236bool CSSValue::isNull() const
237{
238 return (impl == 0);
239}
240
241// ----------------------------------------------------------
242
243CSSValueList::CSSValueList() : CSSValue()
244{
245}
246
247CSSValueList::CSSValueList(const CSSValueList &other) : CSSValue(other)
248{
249}
250
251CSSValueList::CSSValueList(const CSSValue &other)
252{
253 impl = 0;
254 operator=(other);
255}
256
257CSSValueList::CSSValueList(CSSValueListImpl *impl) : CSSValue(impl)
258{
259}
260
261CSSValueList &CSSValueList::operator = (const CSSValueList &other)
262{
263 if ( impl != other.impl ) {
264 if (impl) impl->deref();
265 impl = other.handle();
266 if (impl) impl->ref();
267 }
268 return *this;
269}
270
271CSSValueList &CSSValueList::operator = (const CSSValue &other)
272{
273 CSSValueImpl *ohandle = other.handle() ;
274 if ( impl != ohandle ) {
275 if (impl) impl->deref();
276 if (!other.isNull() && !other.isCSSValueList()) {
277 impl = 0;
278 } else {
279 impl = ohandle;
280 if (impl) impl->ref();
281 }
282 }
283 return *this;
284}
285
286CSSValueList::~CSSValueList()
287{
288}
289
290unsigned long CSSValueList::length() const
291{
292 if(!impl) return 0;
293 return ((CSSValueListImpl *)impl)->length();
294}
295
296CSSValue CSSValueList::item( unsigned long index )
297{
298 if(!impl) return 0;
299 return ((CSSValueListImpl *)impl)->item( index );
300}
301
302// ----------------------------------------------------------
303
304CSSPrimitiveValue::CSSPrimitiveValue() : CSSValue()
305{
306}
307
308CSSPrimitiveValue::CSSPrimitiveValue(const CSSPrimitiveValue &other) : CSSValue(other)
309{
310}
311
312CSSPrimitiveValue::CSSPrimitiveValue(const CSSValue &other) : CSSValue(other)
313{
314 impl = 0;
315 operator=(other);
316}
317
318CSSPrimitiveValue::CSSPrimitiveValue(CSSPrimitiveValueImpl *impl) : CSSValue(impl)
319{
320}
321
322CSSPrimitiveValue &CSSPrimitiveValue::operator = (const CSSPrimitiveValue &other)
323{
324 if ( impl != other.impl ) {
325 if (impl) impl->deref();
326 impl = other.handle();
327 if (impl) impl->ref();
328 }
329 return *this;
330}
331
332CSSPrimitiveValue &CSSPrimitiveValue::operator = (const CSSValue &other)
333{
334 CSSValueImpl *ohandle = other.handle();
335 if ( impl != ohandle ) {
336 if (impl) impl->deref();
337 if (!other.isNull() && !other.isCSSPrimitiveValue()) {
338 impl = 0;
339 } else {
340 impl = ohandle;
341 if (impl) impl->ref();
342 }
343 }
344 return *this;
345}
346
347CSSPrimitiveValue::~CSSPrimitiveValue()
348{
349}
350
351unsigned short CSSPrimitiveValue::primitiveType() const
352{
353 if(!impl) return 0;
354 return ((CSSPrimitiveValueImpl *)impl)->primitiveType();
355}
356
357void CSSPrimitiveValue::setFloatValue( unsigned short unitType, float floatValue )
358{
359 if(!impl) return;
360 int exceptioncode = 0;
361 ((CSSPrimitiveValueImpl *)impl)->setFloatValue( unitType, floatValue, exceptioncode );
362 if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET )
363 throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET );
364 if ( exceptioncode )
365 throw DOMException( exceptioncode );
366}
367
368float CSSPrimitiveValue::getFloatValue( unsigned short unitType )
369{
370 if(!impl) return 0;
371 // ### add unit conversion
372 if(primitiveType() != unitType)
373 throw CSSException(CSSException::SYNTAX_ERR);
374 return ((CSSPrimitiveValueImpl *)impl)->floatValue( unitType );
375}
376
377void CSSPrimitiveValue::setStringValue( unsigned short stringType, const DOMString &stringValue )
378{
379 int exceptioncode = 0;
380 if(impl)
381 ((CSSPrimitiveValueImpl *)impl)->setStringValue( stringType, stringValue, exceptioncode );
382 if ( exceptioncode >= CSSException::_EXCEPTION_OFFSET )
383 throw CSSException( exceptioncode - CSSException::_EXCEPTION_OFFSET );
384 if ( exceptioncode )
385 throw DOMException( exceptioncode );
386
387}
388
389DOMString CSSPrimitiveValue::getStringValue( )
390{
391 if(!impl) return DOMString();
392 return ((CSSPrimitiveValueImpl *)impl)->getStringValue( );
393}
394
395Counter CSSPrimitiveValue::getCounterValue( )
396{
397 if(!impl) return Counter();
398 return ((CSSPrimitiveValueImpl *)impl)->getCounterValue( );
399}
400
401Rect CSSPrimitiveValue::getRectValue( )
402{
403 if(!impl) return Rect();
404 return ((CSSPrimitiveValueImpl *)impl)->getRectValue( );
405}
406
407RGBColor CSSPrimitiveValue::getRGBColorValue( )
408{
409 // ###
410 return RGBColor();
411 //if(!impl) return RGBColor();
412 //return ((CSSPrimitiveValueImpl *)impl)->getRGBColorValue( );
413}
414
415// -------------------------------------------------------------------
416
417Counter::Counter()
418{
419}
420
421Counter::Counter(const Counter &/*other*/)
422{
423 impl = 0;
424}
425
426Counter &Counter::operator = (const Counter &other)
427{
428 if ( impl != other.impl ) {
429 if (impl) impl->deref();
430 impl = other.impl;
431 if (impl) impl->ref();
432 }
433 return *this;
434}
435
436Counter::Counter(CounterImpl *i)
437{
438 impl = i;
439 if (impl) impl->ref();
440}
441
442Counter::~Counter()
443{
444 if (impl) impl->deref();
445}
446
447DOMString Counter::identifier() const
448{
449 if (!impl) return DOMString();
450 return impl->identifier();
451}
452
453DOMString Counter::listStyle() const
454{
455 if (!impl) return DOMString();
456 return tdehtml::stringForListStyleType((tdehtml::EListStyleType)impl->listStyle());
457}
458
459DOMString Counter::separator() const
460{
461 if (!impl) return DOMString();
462 return impl->separator();
463}
464
465CounterImpl *Counter::handle() const
466{
467 return impl;
468}
469
470bool Counter::isNull() const
471{
472 return (impl == 0);
473}
474
475// --------------------------------------------------------------------
476
477RGBColor::RGBColor()
478{
479}
480
481RGBColor::RGBColor(const RGBColor &other)
482{
483 m_color = other.m_color;
484}
485
486RGBColor::RGBColor(TQRgb color)
487{
488 m_color = color;
489}
490
491RGBColor &RGBColor::operator = (const RGBColor &other)
492{
493 m_color = other.m_color;
494 return *this;
495}
496
497RGBColor::~RGBColor()
498{
499}
500
501CSSPrimitiveValue RGBColor::red() const
502{
503 return new CSSPrimitiveValueImpl(float(tqAlpha(m_color) ? tqRed(m_color) : 0), CSSPrimitiveValue::CSS_DIMENSION);
504}
505
506CSSPrimitiveValue RGBColor::green() const
507{
508 return new CSSPrimitiveValueImpl(float(tqAlpha(m_color) ? tqGreen(m_color) : 0), CSSPrimitiveValue::CSS_DIMENSION);
509}
510
511CSSPrimitiveValue RGBColor::blue() const
512{
513 return new CSSPrimitiveValueImpl(float(tqAlpha(m_color) ? tqBlue(m_color) : 0), CSSPrimitiveValue::CSS_DIMENSION);
514}
515
516
517// ---------------------------------------------------------------------
518
519Rect::Rect()
520{
521 impl = 0;
522}
523
524Rect::Rect(const Rect &other)
525{
526 impl = other.impl;
527 if (impl) impl->ref();
528}
529
530Rect::Rect(RectImpl *i)
531{
532 impl = i;
533 if (impl) impl->ref();
534}
535
536Rect &Rect::operator = (const Rect &other)
537{
538 if ( impl != other.impl ) {
539 if (impl) impl->deref();
540 impl = other.impl;
541 if (impl) impl->ref();
542 }
543 return *this;
544}
545
546Rect::~Rect()
547{
548 if (impl) impl->deref();
549}
550
551CSSPrimitiveValue Rect::top() const
552{
553 if (!impl) return 0;
554 return impl->top();
555}
556
557CSSPrimitiveValue Rect::right() const
558{
559 if (!impl) return 0;
560 return impl->right();
561}
562
563CSSPrimitiveValue Rect::bottom() const
564{
565 if (!impl) return 0;
566 return impl->bottom();
567}
568
569CSSPrimitiveValue Rect::left() const
570{
571 if (!impl) return 0;
572 return impl->left();
573}
574
575RectImpl *Rect::handle() const
576{
577 return impl;
578}
579
580bool Rect::isNull() const
581{
582 return (impl == 0);
583}
584
585} // namespace
586
587
DOM::CSSException
This exception is raised when a specific CSS operation is impossible to perform.
Definition: css_stylesheet.h:174
DOM::CSSPrimitiveValue
The CSSPrimitiveValue interface represents a single CSS value .
Definition: css_value.h:374
DOM::CSSPrimitiveValue::primitiveType
unsigned short primitiveType() const
The type of the value as defined by the constants specified above.
Definition: css_value.cpp:351
DOM::CSSPrimitiveValue::getCounterValue
Counter getCounterValue()
This method is used to get the Counter value.
Definition: css_value.cpp:395
DOM::CSSPrimitiveValue::getRGBColorValue
RGBColor getRGBColorValue()
This method is used to get the RGB color.
Definition: css_value.cpp:407
DOM::CSSPrimitiveValue::setFloatValue
void setFloatValue(unsigned short unitType, float floatValue)
A method to set the float value with a specified unit.
Definition: css_value.cpp:357
DOM::CSSPrimitiveValue::getFloatValue
float getFloatValue(unsigned short unitType)
This method is used to get a float value in a specified unit.
Definition: css_value.cpp:368
DOM::CSSPrimitiveValue::getRectValue
Rect getRectValue()
This method is used to get the Rect value.
Definition: css_value.cpp:401
DOM::CSSPrimitiveValue::setStringValue
void setStringValue(unsigned short stringType, const DOM::DOMString &stringValue)
A method to set the string value with a specified unit.
Definition: css_value.cpp:377
DOM::CSSPrimitiveValue::getStringValue
DOM::DOMString getStringValue()
This method is used to get the string value in a specified unit.
Definition: css_value.cpp:389
DOM::CSSRule
The CSSRule interface is the abstract base interface for any type of CSS statement .
Definition: css_rule.h:53
DOM::CSSStyleDeclaration
The CSSStyleDeclaration interface represents a single CSS declaration block .
Definition: css_value.h:61
DOM::CSSStyleDeclaration::parentRule
CSSRule parentRule() const
The CSS rule that contains this declaration block.
Definition: css_value.cpp:151
DOM::CSSStyleDeclaration::item
DOM::DOMString item(unsigned long index) const
Used to retrieve the properties that have been explicitly set in this declaration block.
Definition: css_value.cpp:146
DOM::CSSStyleDeclaration::getPropertyPriority
DOM::DOMString getPropertyPriority(const DOM::DOMString &propertyName) const
Used to retrieve the priority of a CSS property (e.g.
Definition: css_value.cpp:113
DOM::CSSStyleDeclaration::getPropertyCSSValue
CSSValue getPropertyCSSValue(const DOM::DOMString &propertyName) const
Used to retrieve the object representation of the value of a CSS property if it has been explicitly s...
Definition: css_value.cpp:93
DOM::CSSStyleDeclaration::getPropertyValue
DOM::DOMString getPropertyValue(const DOM::DOMString &propertyName) const
Used to retrieve the value of a CSS property if it has been explicitly set within this declaration bl...
Definition: css_value.cpp:80
DOM::CSSStyleDeclaration::setCssText
void setCssText(const DOM::DOMString &)
see cssText
Definition: css_value.cpp:69
DOM::CSSStyleDeclaration::length
unsigned long length() const
The number of properties that have been explicitly set in this declaration block.
Definition: css_value.cpp:135
DOM::CSSStyleDeclaration::cssText
DOM::DOMString cssText() const
The parsable textual representation of the declaration block (including the surrounding curly braces)...
Definition: css_value.cpp:63
DOM::CSSStyleDeclaration::removeProperty
DOM::DOMString removeProperty(const DOM::DOMString &propertyName)
Used to remove a CSS property if it has been explicitly set within this declaration block.
Definition: css_value.cpp:101
DOM::CSSStyleDeclaration::setProperty
void setProperty(const DOM::DOMString &propertyName, const DOM::DOMString &value, const DOM::DOMString &priority)
Used to set a property value and priority within this declaration block.
Definition: css_value.cpp:122
DOM::CSSValueList::item
CSSValue item(unsigned long index)
Used to retrieve a CSS rule by ordinal index.
Definition: css_value.cpp:296
DOM::CSSValueList::length
unsigned long length() const
The number of CSSValue s in the list.
Definition: css_value.cpp:290
DOM::CSSValue
The CSSValue interface represents a simple or a complexe value.
Definition: css_value.h:244
DOM::CSSValue::cssText
DOM::DOMString cssText() const
A string representation of the current value.
Definition: css_value.cpp:201
DOM::CSSValue::setCssText
void setCssText(const DOM::DOMString &)
see cssText
Definition: css_value.cpp:207
DOM::CSSValue::cssValueType
unsigned short cssValueType() const
A code defining the type of the value as defined above.
Definition: css_value.cpp:213
DOM::Counter
The Counter interface is used to represent any counter or counters function value.
Definition: css_value.h:700
DOM::Counter::identifier
DOM::DOMString identifier() const
This attribute is used for the identifier of the counter.
Definition: css_value.cpp:447
DOM::Counter::listStyle
DOM::DOMString listStyle() const
This attribute is used for the style of the list.
Definition: css_value.cpp:453
DOM::Counter::separator
DOM::DOMString separator() const
This attribute is used for the separator of nested counters.
Definition: css_value.cpp:459
DOM::DOMException
DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impos...
Definition: dom_exception.h:58
DOM::DOMString
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
DOM::RGBColor
The RGBColor interface is used to represent any RGB color value.
Definition: css_value.h:592
DOM::RGBColor::blue
CSSPrimitiveValue blue() const
This attribute is used for the blue value of the RGB color.
Definition: css_value.cpp:511
DOM::RGBColor::red
CSSPrimitiveValue red() const
This attribute is used for the red value of the RGB color.
Definition: css_value.cpp:501
DOM::RGBColor::green
CSSPrimitiveValue green() const
This attribute is used for the green value of the RGB color.
Definition: css_value.cpp:506
DOM::Rect
The Rect interface is used to represent any rect value.
Definition: css_value.h:643
DOM::Rect::bottom
CSSPrimitiveValue bottom() const
This attribute is used for the bottom of the rect.
Definition: css_value.cpp:563
DOM::Rect::left
CSSPrimitiveValue left() const
This attribute is used for the left of the rect.
Definition: css_value.cpp:569
DOM::Rect::right
CSSPrimitiveValue right() const
This attribute is used for the right of the rect.
Definition: css_value.cpp:557
DOM::Rect::top
CSSPrimitiveValue top() const
This attribute is used for the top of the rect.
Definition: css_value.cpp:551
DOM
The Document Object Model (DOM) is divided into two parts, the COREDOM core DOM, specifying some core...
Definition: design.h:57

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
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdehtml by doxygen 1.9.4
This website is maintained by Timothy Pearson.