You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1308 lines
32 KiB
1308 lines
32 KiB
15 years ago
|
/*
|
||
|
Copyright (C) 2001-2003 KSVG Team
|
||
|
This file is part of the KDE project
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#include <kdebug.h>
|
||
|
|
||
15 years ago
|
#include <tqrect.h>
|
||
15 years ago
|
|
||
|
#include "CanvasItem.h"
|
||
|
#include "KSVGCanvas.h"
|
||
|
|
||
|
#include "SVGPaint.h"
|
||
|
#include "SVGColorImpl.h"
|
||
|
#include "SVGPaintImpl.h"
|
||
|
#include "SVGHelperImpl.h"
|
||
|
#include "SVGLengthImpl.h"
|
||
|
#include "SVGDocumentImpl.h"
|
||
|
#include "SVGStylableImpl.h"
|
||
|
#include "SVGSVGElementImpl.h"
|
||
|
#include "SVGStringListImpl.h"
|
||
|
#include "SVGImageElementImpl.h"
|
||
|
#include "SVGURIReferenceImpl.h"
|
||
|
#include "SVGAnimatedLengthImpl.h"
|
||
|
#include "SVGColorProfileElementImpl.h"
|
||
|
#include "SVGAnimatedLengthListImpl.h"
|
||
|
|
||
|
using namespace KSVG;
|
||
|
|
||
|
#include "SVGStylableImpl.lut.h"
|
||
|
#include "ksvg_scriptinterpreter.h"
|
||
|
#include "ksvg_bridge.h"
|
||
|
#include "ksvg_ecma.h"
|
||
|
|
||
|
SVGStylableImpl::SVGStylableImpl(SVGElementImpl *object) : m_object(object)
|
||
|
{
|
||
|
KSVG_EMPTY_FLAGS
|
||
|
|
||
|
// View propidx.html, if you want to verify those default values (Niko)
|
||
|
m_flags = SVG_STYLE_FLAG_NONE;
|
||
|
|
||
|
// Initialize all pointers to 0
|
||
|
// Important!
|
||
|
m_color = 0;
|
||
|
m_fillColor = 0;
|
||
|
m_stopColor = 0;
|
||
|
m_dashArray = 0;
|
||
|
m_dashOffset = 0;
|
||
|
m_strokeWidth = 0;
|
||
|
m_strokeColor = 0;
|
||
|
m_fontFamily = 0;
|
||
|
|
||
|
m_fillOpacity = 1;
|
||
|
m_strokeOpacity = 1;
|
||
|
m_opacity = 1;
|
||
|
|
||
|
// Special case, getFontSize() could be accessed
|
||
|
// _before_ processStyle() is called -> no default
|
||
|
// value for font-size yet -> crash
|
||
|
// SVGLengthImpl access it when parsing em/ex values (Niko)
|
||
|
m_fontSize = -1;
|
||
|
}
|
||
|
|
||
|
SVGStylableImpl::~SVGStylableImpl()
|
||
|
{
|
||
|
if(m_strokeWidth)
|
||
|
m_strokeWidth->deref();
|
||
|
if(m_fontFamily)
|
||
|
m_fontFamily->deref();
|
||
|
if(m_strokeColor)
|
||
|
m_strokeColor->deref();
|
||
|
if(m_fillColor)
|
||
|
m_fillColor->deref();
|
||
|
if(m_color)
|
||
|
m_color->deref();
|
||
|
if(m_stopColor)
|
||
|
m_stopColor->deref();
|
||
|
if(m_dashOffset)
|
||
|
m_dashOffset->deref();
|
||
|
if(m_dashArray)
|
||
|
m_dashArray->deref();
|
||
|
}
|
||
|
|
||
|
void SVGStylableImpl::processStyle()
|
||
|
{
|
||
14 years ago
|
SVGStylableImpl *parentStyle = 0;
|
||
15 years ago
|
if(m_object && m_object->ownerDoc())
|
||
14 years ago
|
parentStyle = dynamic_cast<SVGStylableImpl *>(m_object->ownerDoc()->getElementFromHandle((*m_object).parentNode().handle()));
|
||
15 years ago
|
|
||
|
// Spec: default "none"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_STROKE)
|
||
|
{
|
||
|
m_strokeColor = new SVGPaintImpl(m_object);
|
||
|
m_strokeColor->ref();
|
||
|
|
||
|
SVGPaintImpl *strokeColor = 0L;
|
||
14 years ago
|
if(parentStyle)
|
||
|
strokeColor = parentStyle->getStrokeColor();
|
||
15 years ago
|
|
||
|
if(strokeColor)
|
||
|
*m_strokeColor = *strokeColor;
|
||
|
else
|
||
|
m_strokeColor->setPaint(SVG_PAINTTYPE_NONE);
|
||
|
}
|
||
|
|
||
|
// Spec: default "black"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_FILL)
|
||
|
{
|
||
|
m_fillColor = new SVGPaintImpl(m_object);
|
||
|
m_fillColor->ref();
|
||
|
|
||
|
SVGPaintImpl *fillColor = 0;
|
||
14 years ago
|
if(parentStyle)
|
||
|
fillColor = parentStyle->getFillColor();
|
||
15 years ago
|
|
||
|
if(fillColor)
|
||
|
*m_fillColor = *fillColor;
|
||
|
else
|
||
|
m_fillColor->setRGBColor(DOM::DOMString("black"));
|
||
|
}
|
||
|
|
||
|
// Spec: no real default
|
||
|
if(~m_flags & SVG_STYLE_FLAG_COLOR)
|
||
|
{
|
||
|
m_color = new SVGColorImpl(m_object);
|
||
|
m_color->ref();
|
||
|
SVGColorImpl *color = 0;
|
||
14 years ago
|
if(parentStyle)
|
||
|
color = parentStyle->getColor();
|
||
15 years ago
|
|
||
|
if(color)
|
||
|
*m_color = *color;
|
||
|
}
|
||
|
|
||
|
// Spec: default sRGB
|
||
|
if(~m_flags & SVG_STYLE_FLAG_COLOR_INTERPOLATION)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_colorInterpolation = parentStyle->getColorInterpolation();
|
||
15 years ago
|
else
|
||
|
m_colorInterpolation = CI_SRGB;
|
||
|
}
|
||
|
|
||
|
// Spec: default "1"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_STROKE_WIDTH)
|
||
|
{
|
||
|
m_strokeWidth = new SVGAnimatedLengthImpl(LENGTHMODE_OTHER, m_object);
|
||
|
m_strokeWidth->ref();
|
||
|
|
||
|
SVGAnimatedLengthImpl *strokeWidth = 0;
|
||
14 years ago
|
if(parentStyle)
|
||
|
strokeWidth = parentStyle->getStrokeWidth();
|
||
15 years ago
|
|
||
|
if(strokeWidth)
|
||
|
*m_strokeWidth = *strokeWidth;
|
||
|
else
|
||
|
m_strokeWidth->baseVal()->setValue(1.0);
|
||
|
}
|
||
|
|
||
|
// Spec: default "4"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_STROKE_MITER_LIMIT)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_strokeMiterlimit = parentStyle->getStrokeMiterlimit();
|
||
15 years ago
|
else
|
||
|
m_strokeMiterlimit = 4;
|
||
|
}
|
||
|
|
||
|
// Spec: default "butt"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_STROKE_LINE_CAP)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_capStyle = parentStyle->getCapStyle();
|
||
15 years ago
|
else
|
||
|
m_capStyle = PATH_STROKE_CAP_BUTT;
|
||
|
}
|
||
|
|
||
|
// Spec: default "miter"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_STROKE_LINE_JOIN)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_joinStyle = parentStyle->getJoinStyle();
|
||
15 years ago
|
else
|
||
|
m_joinStyle = PATH_STROKE_JOIN_MITER;
|
||
|
}
|
||
|
|
||
|
// Spec: default "auto"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_CURSOR)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_cursor = parentStyle->getCursor();
|
||
15 years ago
|
else
|
||
|
m_cursor = CURSOR_AUTO;
|
||
|
}
|
||
|
|
||
|
// Spec: default "visiblePainted"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_POINTER_EVENTS)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_pointerEvents = parentStyle->getPointerEvents();
|
||
15 years ago
|
else
|
||
|
m_pointerEvents = PE_VISIBLE_PAINTED;
|
||
|
}
|
||
|
|
||
|
// Spec: default "0"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_STROKE_DASH_OFFSET)
|
||
|
{
|
||
|
m_dashOffset = new SVGAnimatedLengthImpl(LENGTHMODE_OTHER, m_object);
|
||
|
m_dashOffset->ref();
|
||
|
|
||
|
SVGAnimatedLengthImpl *dashOffset = 0;
|
||
14 years ago
|
if(parentStyle)
|
||
|
dashOffset = parentStyle->getDashOffset();
|
||
15 years ago
|
|
||
|
if(dashOffset)
|
||
|
*m_dashOffset = *dashOffset;
|
||
|
else
|
||
|
m_dashOffset->baseVal()->setValue(0);
|
||
|
}
|
||
|
|
||
|
// Spec: default "none" -> 0 == empty dash array
|
||
|
if(~m_flags & SVG_STYLE_FLAG_STROKE_DASH_ARRAY)
|
||
|
{
|
||
|
SVGAnimatedLengthListImpl *dashArray = 0;
|
||
14 years ago
|
if(parentStyle)
|
||
|
dashArray = parentStyle->getDashArray();
|
||
15 years ago
|
|
||
|
if(dashArray)
|
||
|
{
|
||
|
if (!m_dashArray)
|
||
|
{
|
||
|
m_dashArray = new SVGAnimatedLengthListImpl();
|
||
|
m_dashArray->ref();
|
||
|
}
|
||
|
*m_dashArray = *dashArray;
|
||
|
}
|
||
|
else
|
||
|
m_dashArray = 0;
|
||
|
}
|
||
|
|
||
|
// Spec: default "1" -> 1 == Not opaque
|
||
|
if(~m_flags & SVG_STYLE_FLAG_FILL_OPACITY)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_fillOpacity = parentStyle->getFillOpacity();
|
||
15 years ago
|
else
|
||
|
m_fillOpacity = 1;
|
||
|
}
|
||
|
|
||
|
if(~m_flags & SVG_STYLE_FLAG_STROKE_OPACITY)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_strokeOpacity = parentStyle->getStrokeOpacity();
|
||
15 years ago
|
else
|
||
|
m_strokeOpacity = 1;
|
||
|
}
|
||
|
|
||
13 years ago
|
// Fake group opacity by multiplying by our parent's group opacity
|
||
15 years ago
|
if(~m_flags & SVG_STYLE_FLAG_OPACITY)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_opacity = parentStyle->getOpacity();
|
||
15 years ago
|
else
|
||
|
m_opacity = 1;
|
||
|
}
|
||
|
else
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_opacity *= parentStyle->getOpacity();
|
||
15 years ago
|
|
||
|
if(~m_flags & SVG_STYLE_FLAG_CLIP_PATH)
|
||
|
m_clipPath = "";
|
||
|
|
||
|
if(~m_flags & SVG_STYLE_FLAG_MASK)
|
||
13 years ago
|
m_mask = "";
|
||
15 years ago
|
|
||
|
// Spec: default "nonzero"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_FILL_RULE)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_fillRule = parentStyle->getFillRule();
|
||
15 years ago
|
else
|
||
|
m_fillRule = RULE_NONZERO;
|
||
|
}
|
||
|
|
||
|
if(~m_flags & SVG_STYLE_FLAG_CLIP_RULE)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_clipRule = parentStyle->getClipRule();
|
||
15 years ago
|
else
|
||
|
m_clipRule = RULE_NONZERO;
|
||
|
}
|
||
|
|
||
|
// Spec: default "hidden"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_OVERFLOW)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_overflow = parentStyle->getOverflow();
|
||
15 years ago
|
else
|
||
|
m_overflow = false;
|
||
|
}
|
||
|
|
||
|
// We are not really, spec compatible here, we just
|
||
|
// define a bool, to indicate wheter an element should
|
||
|
// be rendered or not.
|
||
|
if(~m_flags & SVG_STYLE_FLAG_DISPLAY)
|
||
|
m_display = true;
|
||
|
|
||
|
if(~m_flags & SVG_STYLE_FLAG_VISIBILITY)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_visible = parentStyle->getVisible();
|
||
15 years ago
|
else
|
||
|
m_visible = true;
|
||
|
}
|
||
|
|
||
|
// Spec: default "medium"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_FONT_SIZE)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_fontSize = parentStyle->getFontSize();
|
||
15 years ago
|
else
|
||
|
m_fontSize = fontSizeForText("medium");
|
||
|
}
|
||
|
|
||
|
// Spec: default "depends on user agent" -> "Arial" for SVG
|
||
|
if(~m_flags & SVG_STYLE_FLAG_FONT_FAMILY)
|
||
|
{
|
||
|
if(!m_fontFamily)
|
||
|
{
|
||
|
m_fontFamily = new SVGStringListImpl();
|
||
|
m_fontFamily->ref();
|
||
|
}
|
||
|
|
||
|
SVGStringListImpl *fontFamily = 0;
|
||
14 years ago
|
if(parentStyle)
|
||
|
fontFamily = parentStyle->getFontFamily();
|
||
15 years ago
|
|
||
|
if(fontFamily)
|
||
|
*m_fontFamily = *fontFamily;
|
||
|
else
|
||
|
{
|
||
|
SharedString *string = new SharedString("Arial");
|
||
|
string->ref();
|
||
|
|
||
|
m_fontFamily->appendItem(string);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Spec: default "normal"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_FONT_STYLE)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_fontStyle = parentStyle->getFontStyle();
|
||
15 years ago
|
else
|
||
|
m_fontStyle = FSNORMAL;
|
||
|
}
|
||
|
|
||
|
// Spec: default "normal"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_FONT_WEIGHT)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_fontWeight = parentStyle->getFontWeight();
|
||
15 years ago
|
else
|
||
|
m_fontWeight = "normal";
|
||
|
}
|
||
|
|
||
|
// Spec: default "start"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_TEXT_ANCHOR)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_textAnchor = parentStyle->getTextAnchor();
|
||
15 years ago
|
else
|
||
|
m_textAnchor = TASTART;
|
||
|
}
|
||
|
|
||
|
// Spec: default "LTR"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_TEXT_DIRECTION)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_textDirection = parentStyle->getTextDirection();
|
||
15 years ago
|
else
|
||
|
m_textDirection = LTR;
|
||
|
}
|
||
|
|
||
|
// Spec: default "none"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_TEXT_DECORATION)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_textDecoration = parentStyle->getTextDecoration();
|
||
15 years ago
|
else
|
||
|
m_textDecoration = TDNONE;
|
||
|
}
|
||
|
|
||
|
// Spec: default "baseline"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_BASELINE_SHIFT)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_baselineShift = parentStyle->getBaselineShift();
|
||
15 years ago
|
else
|
||
|
m_baselineShift = "baseline";
|
||
|
}
|
||
|
|
||
|
// Spec: default "lr-tb", FIXME
|
||
|
if(~m_flags & SVG_STYLE_FLAG_TEXT_WRITING_MODE)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_textWritingMode = parentStyle->getTextWritingMode();
|
||
15 years ago
|
else
|
||
|
m_textWritingMode = LR;
|
||
|
}
|
||
|
|
||
|
// Spec: default "normal"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_TEXT_UNICODE_BIDI)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_textUnicodeBidi = parentStyle->getTextUnicodeBidi();
|
||
15 years ago
|
else
|
||
|
m_textUnicodeBidi = UBNORMAL;
|
||
|
}
|
||
|
|
||
|
// Spec: default "auto"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_GLYPH_ORIENTATION_VERTICAL)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_glyphOrientationVertical = parentStyle->getGlyphOrientationVertical();
|
||
15 years ago
|
else
|
||
|
m_glyphOrientationVertical = "auto";
|
||
|
}
|
||
|
|
||
|
// Spec: default "auto"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_GLYPH_ORIENTATION_HORIZONTAL)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_glyphOrientationHorizontal = parentStyle->getGlyphOrientationHorizontal();
|
||
15 years ago
|
else
|
||
|
m_glyphOrientationHorizontal = "auto";
|
||
|
}
|
||
|
|
||
|
// Spec: default "normal"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_LETTER_SPACING)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_letterSpacing = parentStyle->getLetterSpacing();
|
||
15 years ago
|
else
|
||
|
m_letterSpacing = "normal";
|
||
|
}
|
||
|
|
||
|
// Spec: default "normal"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_WORD_SPACING)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_wordSpacing = parentStyle->getWordSpacing();
|
||
15 years ago
|
else
|
||
|
m_wordSpacing = "normal";
|
||
|
}
|
||
|
|
||
|
// Spec: default "black"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_STOP)
|
||
|
{
|
||
|
m_stopColor = new SVGColorImpl(m_object);
|
||
|
m_stopColor->ref();
|
||
|
|
||
|
m_stopColor->setRGBColor(DOM::DOMString("black"));
|
||
|
}
|
||
|
|
||
|
// Spec: default "none"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_MARKER_START)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_startMarker = parentStyle->getStartMarker();
|
||
15 years ago
|
else
|
||
14 years ago
|
m_startMarker = TQString();
|
||
15 years ago
|
}
|
||
|
|
||
|
// Spec: default "none"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_MARKER_MID)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_midMarker = parentStyle->getMidMarker();
|
||
15 years ago
|
else
|
||
14 years ago
|
m_midMarker = TQString();
|
||
15 years ago
|
}
|
||
|
|
||
|
// Spec: default "none"
|
||
|
if(~m_flags & SVG_STYLE_FLAG_MARKER_END)
|
||
|
{
|
||
14 years ago
|
if(parentStyle)
|
||
|
m_endMarker = parentStyle->getEndMarker();
|
||
15 years ago
|
else
|
||
14 years ago
|
m_endMarker = TQString();
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
bool SVGStylableImpl::isStroked() const
|
||
|
{
|
||
|
if(!m_strokeColor)
|
||
|
return false;
|
||
|
|
||
|
return m_strokeColor->paintType() != SVG_PAINTTYPE_UNKNOWN &&
|
||
|
m_strokeColor->paintType() != SVG_PAINTTYPE_NONE &&
|
||
|
m_strokeColor->paintType() != SVG_PAINTTYPE_URI_NONE;
|
||
|
}
|
||
|
|
||
|
bool SVGStylableImpl::isFilled() const
|
||
|
{
|
||
|
if(!m_fillColor)
|
||
|
return false;
|
||
|
|
||
|
return m_fillColor->paintType() != SVG_PAINTTYPE_UNKNOWN &&
|
||
|
m_fillColor->paintType() != SVG_PAINTTYPE_NONE &&
|
||
|
m_fillColor->paintType() != SVG_PAINTTYPE_URI_NONE;
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString SVGStylableImpl::extractUrlId(const TQString &url)
|
||
15 years ago
|
{
|
||
15 years ago
|
TQString id;
|
||
15 years ago
|
|
||
|
if(url.startsWith("url(#"))
|
||
|
{
|
||
13 years ago
|
int idstart = url.find("#") + 1;
|
||
15 years ago
|
id = url.mid(idstart, url.length() - idstart - 1);
|
||
|
}
|
||
|
else
|
||
|
id = url;
|
||
|
|
||
|
return id;
|
||
|
}
|
||
|
|
||
15 years ago
|
void SVGStylableImpl::setMarkers(const TQString &marker)
|
||
15 years ago
|
{
|
||
|
setStartMarker(marker);
|
||
|
setMidMarker(marker);
|
||
|
setEndMarker(marker);
|
||
|
}
|
||
|
|
||
15 years ago
|
void SVGStylableImpl::setStartMarker(const TQString &startMarker)
|
||
15 years ago
|
{
|
||
|
if(startMarker.startsWith("url(#"))
|
||
|
{
|
||
13 years ago
|
int idstart = startMarker.find("#") + 1;
|
||
15 years ago
|
m_startMarker = startMarker.mid(idstart, startMarker.length() - idstart - 1);
|
||
|
}
|
||
|
else if(startMarker == "none")
|
||
14 years ago
|
m_startMarker = TQString();
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void SVGStylableImpl::setMidMarker(const TQString &midMarker)
|
||
15 years ago
|
{
|
||
|
if(midMarker.startsWith("url(#"))
|
||
|
{
|
||
13 years ago
|
int idstart = midMarker.find("#") + 1;
|
||
15 years ago
|
m_midMarker = midMarker.mid(idstart, midMarker.length() - idstart - 1);
|
||
|
}
|
||
|
else if(midMarker == "none")
|
||
14 years ago
|
m_midMarker = TQString();
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void SVGStylableImpl::setEndMarker(const TQString &endMarker)
|
||
15 years ago
|
{
|
||
|
if(endMarker.startsWith("url(#"))
|
||
|
{
|
||
13 years ago
|
int idstart = endMarker.find("#") + 1;
|
||
15 years ago
|
m_endMarker = endMarker.mid(idstart, endMarker.length() - idstart - 1);
|
||
|
}
|
||
|
else if(endMarker == "none")
|
||
14 years ago
|
m_endMarker = TQString();
|
||
15 years ago
|
}
|
||
|
|
||
|
bool SVGStylableImpl::hasMarkers() const
|
||
|
{
|
||
|
return !m_startMarker.isEmpty() || !m_midMarker.isEmpty() || !m_endMarker.isEmpty();
|
||
|
}
|
||
|
|
||
15 years ago
|
void SVGStylableImpl::setPaint(const TQString ¶m, SVGPaintImpl *svgPaint)
|
||
15 years ago
|
{
|
||
|
if(param.stripWhiteSpace() == "none")
|
||
|
svgPaint->setPaint(SVG_PAINTTYPE_NONE, DOM::DOMString(""), DOM::DOMString(""));
|
||
|
else if(SVGURIReferenceImpl::isUrl(param))
|
||
|
svgPaint->setUri(SVGURIReferenceImpl::getTarget(param));
|
||
|
else
|
||
|
setColor(param, svgPaint);
|
||
|
}
|
||
|
|
||
15 years ago
|
void SVGStylableImpl::setColor(const TQString ¶m, SVGColorImpl *svgColor)
|
||
15 years ago
|
{
|
||
|
if(param.stripWhiteSpace().startsWith("#"))
|
||
|
{
|
||
13 years ago
|
if(param.contains("icc-color"))
|
||
15 years ago
|
{
|
||
15 years ago
|
TQString first = param.left(7);
|
||
|
TQString last = param.right(param.length() - 8);
|
||
15 years ago
|
|
||
|
svgColor->setRGBColorICCColor(first, last);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
15 years ago
|
TQColor color;
|
||
15 years ago
|
color.setNamedColor(param.stripWhiteSpace());
|
||
|
svgColor->setRGBColor(color);
|
||
|
}
|
||
|
}
|
||
|
else if(param.stripWhiteSpace().startsWith("rgb("))
|
||
|
{
|
||
15 years ago
|
TQString parse = param.stripWhiteSpace();
|
||
|
TQStringList colors = TQStringList::split(',', parse);
|
||
|
TQString r = colors[0].right((colors[0].length() - 4));
|
||
|
TQString g = colors[1];
|
||
|
TQString b = colors[2].left((colors[2].length() - 1));
|
||
15 years ago
|
|
||
13 years ago
|
if(r.contains("%"))
|
||
15 years ago
|
{
|
||
|
r = r.left(r.length() - 1);
|
||
15 years ago
|
r = TQString::number(int((double(255 * r.toDouble()) / 100.0)));
|
||
15 years ago
|
}
|
||
|
|
||
13 years ago
|
if(g.contains("%"))
|
||
15 years ago
|
{
|
||
|
g = g.left(g.length() - 1);
|
||
15 years ago
|
g = TQString::number(int((double(255 * g.toDouble()) / 100.0)));
|
||
15 years ago
|
}
|
||
|
|
||
13 years ago
|
if(b.contains("%"))
|
||
15 years ago
|
{
|
||
|
b = b.left(b.length() - 1);
|
||
15 years ago
|
b = TQString::number(int((double(255 * b.toDouble()) / 100.0)));
|
||
15 years ago
|
}
|
||
|
|
||
|
svgColor->setRGBColor(int(r.toFloat()), int(g.toFloat()), int(b.toFloat()));
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if(param.stripWhiteSpace().lower() == "currentcolor")
|
||
|
svgColor->setColor(SVG_COLORTYPE_CURRENTCOLOR, DOM::DOMString(""), DOM::DOMString(""));
|
||
|
else
|
||
|
svgColor->setRGBColor(DOM::DOMString(param.stripWhiteSpace().lower()));
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
TQRect SVGStylableImpl::clip()
|
||
15 years ago
|
{
|
||
15 years ago
|
return TQRect();
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void SVGStylableImpl::setClip(const TQString &)
|
||
15 years ago
|
{
|
||
|
}
|
||
|
|
||
15 years ago
|
float SVGStylableImpl::fontSizeForText(const TQString &value)
|
||
15 years ago
|
{
|
||
|
float ret = -1;
|
||
|
|
||
|
// Spec: "On a computer screen a scaling factor of 1.2 is suggested between adjacent indexes"
|
||
|
const float factor = 1.2;
|
||
|
|
||
|
// Spec: "If the 'medium' font is 12pt, the 'large' font could be 14.4pt."
|
||
|
const float mediumFont = 12.0;
|
||
|
|
||
|
if(value == "xx-small")
|
||
|
ret = mediumFont - (3.0 * factor);
|
||
|
else if(value == "x-small")
|
||
|
ret = mediumFont - (2.0 * factor);
|
||
|
else if(value == "small")
|
||
|
ret = mediumFont - factor;
|
||
|
else if(value == "medium")
|
||
|
ret = mediumFont;
|
||
|
else if(value == "large")
|
||
|
ret = mediumFont + factor;
|
||
|
else if(value == "x-large")
|
||
|
ret = mediumFont + (2.0 * factor);
|
||
|
else if(value == "xx-large")
|
||
|
ret = mediumFont + (3.0 * factor);
|
||
|
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
// Ecma stuff
|
||
|
|
||
|
/*
|
||
|
@namespace KSVG
|
||
|
@begin SVGStylableImpl::s_hashTable 47
|
||
|
className SVGStylableImpl::ClassName DontDelete|ReadOnly
|
||
|
style SVGStylableImpl::Style DontDelete|ReadOnly
|
||
|
stroke-width SVGStylableImpl::StrokeWidth DontDelete|ReadOnly
|
||
|
stroke-miterlimit SVGStylableImpl::StrokeMiterlimit DontDelete|ReadOnly
|
||
|
stroke-linecap SVGStylableImpl::StrokeLineCap DontDelete|ReadOnly
|
||
|
stroke-linejoin SVGStylableImpl::StrokeLineJoin DontDelete|ReadOnly
|
||
|
stroke SVGStylableImpl::Stroke DontDelete|ReadOnly
|
||
|
fill SVGStylableImpl::Fill DontDelete|ReadOnly
|
||
|
color SVGStylableImpl::Color DontDelete|ReadOnly
|
||
|
stop-color SVGStylableImpl::StopColor DontDelete|ReadOnly
|
||
|
font-size SVGStylableImpl::FontSize DontDelete|ReadOnly
|
||
|
font-family SVGStylableImpl::FontFamily DontDelete|ReadOnly
|
||
|
font-weight SVGStylableImpl::FontWeight DontDelete|ReadOnly
|
||
|
font-style SVGStylableImpl::FontStyle DontDelete|ReadOnly
|
||
|
text-decoration SVGStylableImpl::TextDecoration DontDelete|ReadOnly
|
||
|
text-anchor SVGStylableImpl::TextAnchor DontDelete|ReadOnly
|
||
|
direction SVGStylableImpl::Direction DontDelete|ReadOnly
|
||
|
writing-mode SVGStylableImpl::WritingMode DontDelete|ReadOnly
|
||
13 years ago
|
unicode-bidi SVGStylableImpl::UnicodeBidi DontDelete|ReadOnly
|
||
15 years ago
|
opacity SVGStylableImpl::Opacity DontDelete|ReadOnly
|
||
|
fill-opacity SVGStylableImpl::FillOpacity DontDelete|ReadOnly
|
||
|
stroke-opacity SVGStylableImpl::StrokeOpacity DontDelete|ReadOnly
|
||
|
clip-path SVGStylableImpl::ClipPath DontDelete|ReadOnly
|
||
|
marker-start SVGStylableImpl::MarkerStart DontDelete|ReadOnly
|
||
|
marker-mid SVGStylableImpl::MarkerMid DontDelete|ReadOnly
|
||
|
marker-end SVGStylableImpl::MarkerEnd DontDelete|ReadOnly
|
||
|
marker SVGStylableImpl::Marker DontDelete|ReadOnly
|
||
|
cursor SVGStylableImpl::Cursor DontDelete|ReadOnly
|
||
|
display SVGStylableImpl::Display DontDelete|ReadOnly
|
||
|
overflow SVGStylableImpl::Overflow DontDelete|ReadOnly
|
||
|
clip SVGStylableImpl::Clip DontDelete|ReadOnly
|
||
|
visibility SVGStylableImpl::Visibility DontDelete|ReadOnly
|
||
|
fill-rule SVGStylableImpl::FillRule DontDelete|ReadOnly
|
||
|
clip-rule SVGStylableImpl::ClipRule DontDelete|ReadOnly
|
||
|
stroke-dashoffset SVGStylableImpl::StrokeDashOffset DontDelete|ReadOnly
|
||
|
stroke-dasharray SVGStylableImpl::StrokeDashArray DontDelete|ReadOnly
|
||
|
color-profile SVGStylableImpl::ColorProfile DontDelete|ReadOnly
|
||
|
baseline-shift SVGStylableImpl::BaselineShift DontDelete|ReadOnly
|
||
|
letter-spacing SVGStylableImpl::LetterSpacing DontDelete|ReadOnly
|
||
|
word-spacing SVGStylableImpl::WordSpacing DontDelete|ReadOnly
|
||
|
pointer-events SVGStylableImpl::PointerEvents DontDelete|ReadOnly
|
||
|
glyph-orientation-vertical SVGStylableImpl::GlyphOrientationVertical DontDelete|ReadOnly
|
||
|
glyph-orientation-horizontal SVGStylableImpl::GlyphOrientationHorizontal DontDelete|ReadOnly
|
||
|
color-interpolation SVGStylableImpl::ColorInterpolation DontDelete|ReadOnly
|
||
13 years ago
|
mask SVGStylableImpl::Mask DontDelete|ReadOnly
|
||
15 years ago
|
@end
|
||
|
@namespace KSVG
|
||
|
@begin SVGStylableImplProto::s_hashTable 2
|
||
|
getStyle SVGStylableImpl::GetStyle DontDelete|Function 0
|
||
|
@end
|
||
|
*/
|
||
|
|
||
|
KSVG_IMPLEMENT_PROTOTYPE("SVGStylable", SVGStylableImplProto, SVGStylableImplProtoFunc)
|
||
|
|
||
|
Value SVGStylableImpl::getValueProperty(ExecState *, int token) const
|
||
|
{
|
||
|
switch(token)
|
||
|
{
|
||
|
//case ClassName:
|
||
|
// return String(className().string());
|
||
|
case Style:
|
||
|
return String(m_object ? m_object->DOM::Element::getAttribute("style") : "");
|
||
|
case Visibility:
|
||
|
return String(m_visible ? "visible" : "hidden");
|
||
|
case Display:
|
||
|
return String(m_display ? "inline" : "none");
|
||
|
default:
|
||
|
kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl;
|
||
|
return Undefined();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void SVGStylableImpl::putValueProperty(ExecState *exec, int token, const Value &value, int attr)
|
||
|
{
|
||
|
// This class has just ReadOnly properties, only with the Internal flag set
|
||
|
// it's allowed to modify those.
|
||
|
if(!(attr & KJS::Internal))
|
||
|
return;
|
||
|
|
||
15 years ago
|
TQString param = value.toString(exec).qstring();
|
||
15 years ago
|
|
||
|
if (param.isEmpty())
|
||
|
return;
|
||
|
|
||
|
bool redraw = false;
|
||
|
bool inherit = (param == "inherit");
|
||
|
int update = -1;
|
||
|
|
||
|
switch(token)
|
||
|
{
|
||
|
case Style:
|
||
|
{
|
||
|
if(!m_object)
|
||
|
return;
|
||
|
|
||
15 years ago
|
TQStringList substyles = TQStringList::split(';', param);
|
||
|
for(TQStringList::Iterator it = substyles.begin(); it != substyles.end(); ++it)
|
||
15 years ago
|
{
|
||
15 years ago
|
TQStringList substyle = TQStringList::split(':', (*it));
|
||
15 years ago
|
m_object->setAttributeInternal(substyle[0].stripWhiteSpace(), substyle[1].stripWhiteSpace());
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
case StrokeWidth:
|
||
|
if(m_flags & SVG_STYLE_FLAG_STROKE_WIDTH)
|
||
|
{
|
||
|
redraw = true;
|
||
|
update = UPDATE_LINEWIDTH;
|
||
|
}
|
||
|
if(inherit)
|
||
|
m_flags &= ~SVG_STYLE_FLAG_STROKE_WIDTH;
|
||
|
else
|
||
|
{
|
||
|
m_flags |= SVG_STYLE_FLAG_STROKE_WIDTH;
|
||
|
|
||
|
if(!m_strokeWidth)
|
||
|
{
|
||
|
m_strokeWidth = new SVGAnimatedLengthImpl(LENGTHMODE_OTHER, m_object);
|
||
|
m_strokeWidth->ref();
|
||
|
}
|
||
|
|
||
|
m_strokeWidth->baseVal()->setValueAsString(param);
|
||
|
}
|
||
|
break;
|
||
|
case StrokeMiterlimit:
|
||
|
m_flags |= SVG_STYLE_FLAG_STROKE_MITER_LIMIT;
|
||
|
if(!inherit)
|
||
|
m_strokeMiterlimit = param.toUInt();
|
||
|
break;
|
||
|
case StrokeLineCap:
|
||
|
m_flags |= SVG_STYLE_FLAG_STROKE_LINE_CAP;
|
||
|
if(param == "butt")
|
||
|
m_capStyle = PATH_STROKE_CAP_BUTT;
|
||
|
else if(param == "round")
|
||
|
m_capStyle = PATH_STROKE_CAP_ROUND;
|
||
|
else if(param == "square")
|
||
|
m_capStyle = PATH_STROKE_CAP_SQUARE;
|
||
|
break;
|
||
|
case StrokeLineJoin:
|
||
|
m_flags |= SVG_STYLE_FLAG_STROKE_LINE_JOIN;
|
||
|
if(param == "miter")
|
||
|
m_joinStyle = PATH_STROKE_JOIN_MITER;
|
||
|
else if(param == "round")
|
||
|
m_joinStyle = PATH_STROKE_JOIN_ROUND;
|
||
|
else if(param == "bevel")
|
||
|
m_joinStyle = PATH_STROKE_JOIN_BEVEL;
|
||
|
break;
|
||
|
case Stroke:
|
||
|
if(m_flags & SVG_STYLE_FLAG_STROKE)
|
||
|
redraw = true;
|
||
|
if(inherit)
|
||
|
m_flags &= ~SVG_STYLE_FLAG_STROKE;
|
||
|
else
|
||
|
{
|
||
|
m_flags |= SVG_STYLE_FLAG_STROKE;
|
||
|
|
||
|
if(!m_strokeColor)
|
||
|
{
|
||
|
m_strokeColor = new SVGPaintImpl(m_object);
|
||
|
m_strokeColor->ref();
|
||
|
}
|
||
|
|
||
|
setPaint(param, m_strokeColor);
|
||
|
}
|
||
|
break;
|
||
|
case Fill:
|
||
|
if(m_flags & SVG_STYLE_FLAG_FILL)
|
||
|
{
|
||
|
redraw = true;
|
||
|
update = UPDATE_STYLE;
|
||
|
}
|
||
|
if(inherit)
|
||
|
m_flags &= ~SVG_STYLE_FLAG_FILL;
|
||
|
else
|
||
|
{
|
||
|
m_flags |= SVG_STYLE_FLAG_FILL;
|
||
|
|
||
|
if(!m_fillColor)
|
||
|
{
|
||
|
m_fillColor = new SVGPaintImpl(m_object);
|
||
|
m_fillColor->ref();
|
||
|
}
|
||
|
|
||
|
setPaint(param, m_fillColor);
|
||
|
}
|
||
|
break;
|
||
|
case Color:
|
||
|
if(m_flags & SVG_STYLE_FLAG_COLOR)
|
||
|
redraw = true;
|
||
|
if(inherit)
|
||
|
m_flags &= ~SVG_STYLE_FLAG_COLOR;
|
||
|
else
|
||
|
{
|
||
|
m_flags |= SVG_STYLE_FLAG_COLOR;
|
||
|
|
||
|
if(!m_color)
|
||
|
{
|
||
|
m_color = new SVGColorImpl(m_object);
|
||
|
m_color->ref();
|
||
|
}
|
||
|
setColor(param, m_color);
|
||
|
}
|
||
|
break;
|
||
|
case StopColor:
|
||
|
m_flags |= SVG_STYLE_FLAG_STOP;
|
||
|
|
||
|
if(!m_stopColor)
|
||
|
{
|
||
|
m_stopColor = new SVGColorImpl(m_object);
|
||
|
m_stopColor->ref();
|
||
|
}
|
||
|
|
||
|
if(!inherit)
|
||
|
setColor(param, m_stopColor);
|
||
|
break;
|
||
|
case ColorInterpolation:
|
||
|
if(inherit)
|
||
|
m_flags &= ~SVG_STYLE_FLAG_COLOR_INTERPOLATION;
|
||
|
else
|
||
|
{
|
||
|
m_flags |= SVG_STYLE_FLAG_COLOR_INTERPOLATION;
|
||
|
if(param == "auto" || param == "sRGB")
|
||
|
m_colorInterpolation = CI_SRGB;
|
||
|
else
|
||
|
if(param == "linearRGB")
|
||
|
m_colorInterpolation = CI_LINEARRGB;
|
||
|
}
|
||
|
break;
|
||
|
case FontSize:
|
||
|
{
|
||
|
m_flags |= SVG_STYLE_FLAG_FONT_SIZE;
|
||
|
if(!inherit)
|
||
|
{
|
||
|
double temp = fontSizeForText(param);
|
||
|
if(temp != -1) // Is "absolute-size"
|
||
|
{
|
||
|
m_fontSize = temp;
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
SVGLengthImpl *length = SVGSVGElementImpl::createSVGLength();
|
||
|
length->setContext(m_object);
|
||
|
length->setValueAsString(DOM::DOMString(param));
|
||
|
m_fontSize = length->value();
|
||
|
length->deref();
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
case FontFamily:
|
||
|
m_flags |= SVG_STYLE_FLAG_FONT_FAMILY;
|
||
|
|
||
|
// Hacks
|
||
|
// #1 Replace "'" characters by ""
|
||
13 years ago
|
param = param.replace('\'', TQString());
|
||
15 years ago
|
// #2 Replace "MS-Gothic" by "MS Gothic"
|
||
13 years ago
|
param = param.replace("MS-Gothic", "MS Gothic");
|
||
15 years ago
|
// #3 Replace "Helvetica" by "Arial"
|
||
13 years ago
|
param = param.replace("Helvetica", "Arial");
|
||
|
param = param.replace("helvetica", "Arial");
|
||
15 years ago
|
|
||
|
if(!m_fontFamily)
|
||
|
{
|
||
|
m_fontFamily = new SVGStringListImpl();
|
||
|
m_fontFamily->ref();
|
||
|
}
|
||
|
|
||
|
if(!inherit)
|
||
|
SVGHelperImpl::parseCommaSeperatedList(m_fontFamily, param);
|
||
|
break;
|
||
|
case FontWeight:
|
||
|
m_flags |= SVG_STYLE_FLAG_FONT_WEIGHT;
|
||
|
if(!inherit)
|
||
|
m_fontWeight = param;
|
||
|
break;
|
||
|
case FontStyle:
|
||
|
m_flags |= SVG_STYLE_FLAG_FONT_STYLE;
|
||
|
if(param == "normal")
|
||
|
m_fontStyle = FSNORMAL;
|
||
|
else if(param == "italic")
|
||
|
m_fontStyle = ITALIC;
|
||
|
else if(param == "oblique")
|
||
13 years ago
|
m_fontStyle = OBLIQUE;
|
||
15 years ago
|
break;
|
||
|
case TextDecoration:
|
||
|
m_flags |= SVG_STYLE_FLAG_TEXT_DECORATION;
|
||
|
if(param == "none")
|
||
|
m_textDecoration = TDNONE;
|
||
|
{
|
||
|
// CSS2 allows multiple decorations
|
||
|
m_textDecoration = TDNONE;
|
||
15 years ago
|
TQStringList decorations = TQStringList::split(' ', param);
|
||
|
for(TQStringList::Iterator it = decorations.begin(); it != decorations.end(); ++it)
|
||
15 years ago
|
{
|
||
|
if(*it == "underline")
|
||
|
m_textDecoration |= UNDERLINE;
|
||
|
else if(*it == "overline")
|
||
|
m_textDecoration |= OVERLINE;
|
||
|
else if(*it == "line-through")
|
||
|
m_textDecoration |= LINE_THROUGH;
|
||
|
}
|
||
|
}
|
||
|
break;
|
||
|
case TextAnchor:
|
||
|
m_flags |= SVG_STYLE_FLAG_TEXT_ANCHOR;
|
||
|
if(param == "start")
|
||
|
m_textAnchor = TASTART;
|
||
|
else if(param == "middle")
|
||
|
m_textAnchor = TAMIDDLE;
|
||
|
else if(param == "end")
|
||
|
m_textAnchor = TAEND;
|
||
|
break;
|
||
|
case Direction:
|
||
|
m_flags |= SVG_STYLE_FLAG_TEXT_DIRECTION;
|
||
13 years ago
|
// Spec: direction is only processed when unicode-bidi
|
||
15 years ago
|
// is set to bidi-override or embedded
|
||
|
if(m_textUnicodeBidi == OVERRIDE ||
|
||
|
m_textUnicodeBidi == EMBED ||
|
||
|
m_textUnicodeBidi == UBNORMAL)
|
||
|
{
|
||
|
if(param == "rtl")
|
||
|
m_textDirection = RTL;
|
||
|
else if(param == "ltr")
|
||
|
m_textDirection = LTR;
|
||
|
}
|
||
|
break;
|
||
|
case WritingMode:
|
||
|
m_flags |= SVG_STYLE_FLAG_TEXT_WRITING_MODE;
|
||
|
if(param == "lr-tb" || param == "lr")
|
||
|
m_textWritingMode = LR;
|
||
|
else if(param == "rl-tb" || param == "rl")
|
||
|
m_textWritingMode = RL;
|
||
|
else if(param == "tb-lr" || param == "tb")
|
||
|
m_textWritingMode = TB;
|
||
|
break;
|
||
|
case UnicodeBidi:
|
||
|
m_flags |= SVG_STYLE_FLAG_TEXT_UNICODE_BIDI;
|
||
|
if(param == "normal")
|
||
|
m_textUnicodeBidi = UBNORMAL;
|
||
|
else if(param == "embed")
|
||
|
m_textUnicodeBidi = EMBED;
|
||
|
else if(param == "bidi-override")
|
||
|
m_textUnicodeBidi = OVERRIDE;
|
||
|
break;
|
||
|
case GlyphOrientationVertical:
|
||
|
m_flags |= SVG_STYLE_FLAG_GLYPH_ORIENTATION_VERTICAL;
|
||
|
m_glyphOrientationVertical = param;
|
||
|
break;
|
||
|
case GlyphOrientationHorizontal:
|
||
|
m_flags |= SVG_STYLE_FLAG_GLYPH_ORIENTATION_HORIZONTAL;
|
||
|
m_glyphOrientationHorizontal = param;
|
||
|
break;
|
||
|
case Opacity:
|
||
|
m_flags |= SVG_STYLE_FLAG_OPACITY;
|
||
|
|
||
|
if(!inherit)
|
||
|
{
|
||
|
SVGLengthImpl::convertPercentageToFloat(value.toString(exec).qstring(), m_opacity);
|
||
|
}
|
||
|
break;
|
||
|
case FillOpacity:
|
||
|
m_flags |= SVG_STYLE_FLAG_FILL_OPACITY;
|
||
|
|
||
|
if(!inherit)
|
||
|
{
|
||
|
SVGLengthImpl::convertPercentageToFloat(value.toString(exec).qstring(), m_fillOpacity);
|
||
|
}
|
||
|
break;
|
||
|
case StrokeOpacity:
|
||
|
m_flags |= SVG_STYLE_FLAG_STROKE_OPACITY;
|
||
|
|
||
|
if(!inherit)
|
||
|
{
|
||
|
SVGLengthImpl::convertPercentageToFloat(value.toString(exec).qstring(), m_strokeOpacity);
|
||
|
}
|
||
|
break;
|
||
|
case ClipPath:
|
||
|
m_flags |= SVG_STYLE_FLAG_CLIP_PATH;
|
||
|
if(!inherit)
|
||
|
m_clipPath = extractUrlId(param);
|
||
|
break;
|
||
|
case Mask:
|
||
|
m_flags |= SVG_STYLE_FLAG_MASK;
|
||
|
if(!inherit)
|
||
13 years ago
|
m_mask = extractUrlId(param);
|
||
15 years ago
|
break;
|
||
|
case MarkerStart:
|
||
|
m_flags |= SVG_STYLE_FLAG_MARKER_START;
|
||
|
if(!inherit)
|
||
|
setStartMarker(param);
|
||
|
break;
|
||
|
case MarkerMid:
|
||
|
m_flags |= SVG_STYLE_FLAG_MARKER_MID;
|
||
|
if(!inherit)
|
||
|
setMidMarker(param);
|
||
|
break;
|
||
|
case MarkerEnd:
|
||
|
m_flags |= SVG_STYLE_FLAG_MARKER_END;
|
||
|
if(!inherit)
|
||
|
setEndMarker(param);
|
||
|
break;
|
||
|
case Marker:
|
||
|
m_flags |= (SVG_STYLE_FLAG_MARKER_START | SVG_STYLE_FLAG_MARKER_MID | SVG_STYLE_FLAG_MARKER_END);
|
||
|
if(!inherit)
|
||
|
setMarkers(param);
|
||
|
break;
|
||
|
case PointerEvents:
|
||
|
m_flags |= SVG_STYLE_FLAG_POINTER_EVENTS;
|
||
|
if(param == "none")
|
||
|
m_pointerEvents = PE_NONE;
|
||
|
else if(param == "stroke")
|
||
|
m_pointerEvents = PE_STROKE;
|
||
|
else if(param == "fill")
|
||
|
m_pointerEvents = PE_FILL;
|
||
|
else if(param == "painted")
|
||
|
m_pointerEvents = PE_PAINTED;
|
||
|
else if(param == "visibleStroke")
|
||
|
m_pointerEvents = PE_VISIBLE_STROKE;
|
||
|
else if(param == "visibleFill")
|
||
|
m_pointerEvents = PE_VISIBLE_FILL;
|
||
|
else if(param == "visiblePainted")
|
||
|
m_pointerEvents = PE_VISIBLE_PAINTED;
|
||
|
else if(param == "visible")
|
||
|
m_pointerEvents = PE_VISIBLE;
|
||
|
else if(param == "all")
|
||
|
m_pointerEvents = PE_ALL;
|
||
|
break;
|
||
|
case Cursor:
|
||
|
m_flags |= SVG_STYLE_FLAG_CURSOR;
|
||
|
if(param == "auto")
|
||
|
m_cursor = CURSOR_AUTO;
|
||
|
else if(param == "crosshair")
|
||
|
m_cursor = CURSOR_CROSSHAIR;
|
||
|
else if(param == "default")
|
||
|
m_cursor = CURSOR_DEFAULT;
|
||
|
else if(param == "pointer")
|
||
|
m_cursor = CURSOR_POINTER;
|
||
|
else if(param == "move")
|
||
|
m_cursor = CURSOR_MOVE;
|
||
|
else if(param == "e-resize")
|
||
|
m_cursor = CURSOR_E_RESIZE;
|
||
|
else if(param == "ne-resize")
|
||
|
m_cursor = CURSOR_NE_RESIZE;
|
||
|
else if(param == "nw-resize")
|
||
|
m_cursor = CURSOR_NW_RESIZE;
|
||
|
else if(param == "n-resize")
|
||
|
m_cursor = CURSOR_N_RESIZE;
|
||
|
else if(param == "se-resize")
|
||
|
m_cursor = CURSOR_SE_RESIZE;
|
||
|
else if(param == "sw-resize")
|
||
|
m_cursor = CURSOR_SW_RESIZE;
|
||
|
else if(param == "s-resize")
|
||
|
m_cursor = CURSOR_S_RESIZE;
|
||
|
else if(param == "w-resize")
|
||
|
m_cursor = CURSOR_W_RESIZE;
|
||
|
else if(param == "text")
|
||
|
m_cursor = CURSOR_TEXT;
|
||
|
else if(param == "wait")
|
||
|
m_cursor = CURSOR_WAIT;
|
||
|
else if(param == "help")
|
||
|
m_cursor = CURSOR_HELP;
|
||
|
break;
|
||
|
case Display:
|
||
|
m_flags |= SVG_STYLE_FLAG_DISPLAY;
|
||
|
|
||
|
if(param == "none")
|
||
|
m_display = false;
|
||
|
else if(!inherit)
|
||
|
m_display = true;
|
||
|
break;
|
||
|
case Overflow:
|
||
|
m_flags |= SVG_STYLE_FLAG_OVERFLOW;
|
||
|
if(param == "hidden" || param == "scroll")
|
||
|
m_overflow = false;
|
||
|
else if(!inherit)
|
||
|
m_overflow = true;
|
||
|
break;
|
||
|
case Clip:
|
||
|
m_flags |= SVG_STYLE_FLAG_CLIP_PATH;
|
||
|
if(!inherit)
|
||
|
setClip(param);
|
||
|
break;
|
||
|
case Visibility:
|
||
|
if(m_flags & SVG_STYLE_FLAG_VISIBILITY)
|
||
|
redraw = true;
|
||
|
if(inherit)
|
||
|
m_flags &= ~SVG_STYLE_FLAG_COLOR;
|
||
|
else
|
||
|
{
|
||
|
m_flags |= SVG_STYLE_FLAG_VISIBILITY;
|
||
|
|
||
|
if(param == "visible")
|
||
|
m_visible = true;
|
||
|
else if(!inherit)
|
||
|
m_visible = false;
|
||
|
|
||
|
// Just a quick fix for the script-* files (Niko)
|
||
|
// Any better solution??
|
||
|
update = UPDATE_TRANSFORM;
|
||
|
redraw = true;
|
||
|
}
|
||
|
SVGHelperImpl::applyContainer<SVGStylableImpl>(this, Visibility, param);
|
||
|
break;
|
||
|
case FillRule:
|
||
|
m_flags |= SVG_STYLE_FLAG_FILL_RULE;
|
||
|
if(!inherit)
|
||
|
m_fillRule = (param == "evenodd" ? RULE_EVENODD : RULE_NONZERO);
|
||
|
break;
|
||
|
case ClipRule:
|
||
|
m_flags |= SVG_STYLE_FLAG_CLIP_RULE;
|
||
|
if(!inherit)
|
||
|
m_clipRule = (param == "evenodd" ? RULE_EVENODD : RULE_NONZERO);
|
||
|
break;
|
||
|
case StrokeDashOffset:
|
||
|
m_flags |= SVG_STYLE_FLAG_STROKE_DASH_OFFSET;
|
||
|
|
||
|
if(!m_dashOffset)
|
||
|
{
|
||
|
m_dashOffset = new SVGAnimatedLengthImpl(LENGTHMODE_OTHER, m_object);
|
||
|
m_dashOffset->ref();
|
||
|
}
|
||
|
|
||
|
if(!inherit)
|
||
|
m_dashOffset->baseVal()->setValueAsString(param);
|
||
|
break;
|
||
|
case StrokeDashArray:
|
||
|
{
|
||
|
m_flags |= SVG_STYLE_FLAG_STROKE_DASH_ARRAY;
|
||
|
|
||
|
if(!m_dashArray)
|
||
|
{
|
||
|
m_dashArray = new SVGAnimatedLengthListImpl();
|
||
|
m_dashArray->ref();
|
||
|
}
|
||
|
else
|
||
|
m_dashArray->baseVal()->clear();
|
||
|
|
||
|
if(param != "none" && !inherit)
|
||
|
SVGHelperImpl::parseLengthList(m_dashArray, param);
|
||
|
break;
|
||
|
}
|
||
|
case ColorProfile:
|
||
|
{
|
||
|
m_flags |= SVG_STYLE_FLAG_COLOR_PROFILE;
|
||
|
if(!inherit)
|
||
|
{
|
||
|
if(!m_object)
|
||
|
return;
|
||
|
|
||
|
SVGColorProfileElementImpl *handle = static_cast<SVGColorProfileElementImpl *>(m_object->ownerSVGElement()->getElementById(SVGURIReferenceImpl::getTarget(param)));
|
||
|
if(handle)
|
||
|
SVGImageElementImpl::applyColorProfile(handle, static_cast<SVGImageElementImpl *>(this));
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
case BaselineShift:
|
||
|
{
|
||
|
m_flags |= SVG_STYLE_FLAG_BASELINE_SHIFT;
|
||
|
if(!inherit)
|
||
|
m_baselineShift = param;
|
||
|
break;
|
||
|
}
|
||
|
case LetterSpacing:
|
||
|
m_flags |= SVG_STYLE_FLAG_LETTER_SPACING;
|
||
|
case WordSpacing:
|
||
|
{
|
||
|
if(!inherit)
|
||
|
{
|
||
|
if(token == WordSpacing)
|
||
|
{
|
||
|
m_flags |= SVG_STYLE_FLAG_WORD_SPACING;
|
||
|
m_wordSpacing = param;
|
||
|
}
|
||
|
else
|
||
|
m_letterSpacing = param;
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
default:
|
||
|
kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl;
|
||
|
}
|
||
|
|
||
|
if(redraw)
|
||
|
{
|
||
13 years ago
|
SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(m_object);
|
||
15 years ago
|
if(inherit)
|
||
|
processStyle();
|
||
|
|
||
13 years ago
|
if(shape && shape->item())
|
||
15 years ago
|
{
|
||
|
if(update > -1)
|
||
13 years ago
|
shape->item()->update(static_cast<CanvasItemUpdate>(update));
|
||
15 years ago
|
else if(m_object)
|
||
13 years ago
|
m_object->ownerDoc()->canvas()->invalidate(shape->item(), false);
|
||
15 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Value SVGStylableImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &)
|
||
|
{
|
||
|
KSVG_CHECK_THIS(SVGStylableImpl)
|
||
|
|
||
|
switch(id)
|
||
|
{
|
||
|
case SVGStylableImpl::GetStyle:
|
||
|
return Undefined();
|
||
|
default:
|
||
|
kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl;
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
return Undefined();
|
||
|
}
|