diff options
Diffstat (limited to 'ksvg/impl')
370 files changed, 62077 insertions, 0 deletions
diff --git a/ksvg/impl/LRUCache.h b/ksvg/impl/LRUCache.h new file mode 100644 index 00000000..879f1856 --- /dev/null +++ b/ksvg/impl/LRUCache.h @@ -0,0 +1,169 @@ +/* + Copyright (C) 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 + aint 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. +*/ + +#ifndef LRUCACHE_H +#define LRUCACHE_H + +#include <qvaluelist.h> + +namespace KSVG +{ + +// A value-based LRU cache with a maximum total cost constraint, but with the exception that the +// most recently added item is kept in the cache even if its cost exceeds the maximum total cost. +template<class keyType, class valueType> +class MinOneLRUCache +{ +public: + MinOneLRUCache(int maxTotalCost = 0) : m_maxTotalCost(maxTotalCost), m_totalCost(0) {} + virtual ~MinOneLRUCache() {} + + void insert(const keyType& key, const valueType& value, int cost); + bool find(const keyType& key, valueType& result); + + void setMaxTotalCost(int maxTotalCost); + int maxTotalCost() const { return m_maxTotalCost; } + int totalCost() const { return m_totalCost; } + + void clear(); + +protected: + class CacheItem + { + public: + CacheItem() : m_cost(0) {} + CacheItem(const keyType& key, const valueType& value, int cost) : m_key(key), m_value(value), m_cost(cost) {} + + const keyType& key() const { return m_key; } + const valueType& value() const { return m_value; } + int cost() const { return m_cost; } + + private: + keyType m_key; + valueType m_value; + int m_cost; + }; + + typedef QValueList<CacheItem> CacheItemList; + + typename CacheItemList::iterator find(const keyType& key); + void enforceCostConstraint(); + + CacheItemList m_items; + int m_maxTotalCost; + int m_totalCost; +}; + +template<class keyType, class valueType> +void MinOneLRUCache<keyType, valueType>::insert(const keyType& key, const valueType& value, int cost) +{ + typename CacheItemList::iterator it = find(key); + + if(it != m_items.end()) + { + // Replace the existing item. + m_totalCost -= (*it).cost(); + m_items.erase(it); + } + + // We always hold the most recently added item in the cache, even if it exceeds + // the maximum total cost. + m_items.push_front(CacheItem(key, value, cost)); + m_totalCost += cost; + enforceCostConstraint(); +} + +template<class keyType, class valueType> +bool MinOneLRUCache<keyType, valueType>::find(const keyType& key, valueType& result) +{ + bool foundKey = false; + typename CacheItemList::iterator it = find(key); + + if(it != m_items.end()) + { + CacheItem item = *it; + result = item.value(); + + if(it != m_items.begin()) + { + // This is now the most recently used item. + m_items.erase(it); + m_items.push_front(item); + } + + foundKey = true; + } + + return foundKey; +} + +template<class keyType, class valueType> +typename MinOneLRUCache<keyType, valueType>::CacheItemList::iterator MinOneLRUCache<keyType, valueType>::find(const keyType& key) +{ + typename CacheItemList::iterator it; + + for(it = m_items.begin(); it != m_items.end(); it++) + { + if((*it).key() == key) + break; + } + + return it; +} + +template<class keyType, class valueType> +void MinOneLRUCache<keyType, valueType>::enforceCostConstraint() +{ + if(m_totalCost > m_maxTotalCost && m_items.size() > 1) + { + typename CacheItemList::iterator it = m_items.begin(); + m_totalCost = (*it).cost(); + ++it; + + while(it != m_items.end() && m_totalCost + (*it).cost() <= m_maxTotalCost) + { + m_totalCost += (*it).cost(); + ++it; + } + + // Remove the remainder + while(it != m_items.end()) + it = m_items.erase(it); + } +} + +template<class keyType, class valueType> +void MinOneLRUCache<keyType, valueType>::setMaxTotalCost(int maxTotalCost) +{ + m_maxTotalCost = maxTotalCost; + enforceCostConstraint(); +} + +template<class keyType, class valueType> +void MinOneLRUCache<keyType, valueType>::clear() +{ + m_items.clear(); + m_totalCost = 0; +} + +} + +#endif + diff --git a/ksvg/impl/Makefile.am b/ksvg/impl/Makefile.am new file mode 100644 index 00000000..24e40d67 --- /dev/null +++ b/ksvg/impl/Makefile.am @@ -0,0 +1,116 @@ +SUBDIRS = libs +noinst_LTLIBRARIES = libksvgdomimpl.la + +KDE_OPTIONS = nofinal + +# The makefile has the following structure: +# datatypes +# animated datatypes +# lists +# animated lists +# base classes +# document structure +# styling +# paths +# basic shapes +# text +# painting +# color +# gradients & patterns +# clipping & masking +# filters +# interactivity +# linking +# scripting +# animations +# font & glyph stuff +# metadata +# extensibility + +KDE_CXXFLAGS = $(USE_EXCEPTIONS) +libksvgdomimpl_la_SOURCES = \ +SVGLengthImpl.cc SVGNumberImpl.cc SVGPointImpl.cc SVGTransformImpl.cc \ +SVGMatrixImpl.cc SVGRectImpl.cc SVGAngleImpl.cc \ +\ +SVGAnimatedLengthImpl.cc SVGAnimatedNumberImpl.cc SVGAnimatedIntegerImpl.cc \ +SVGAnimatedBooleanImpl.cc SVGAnimatedEnumerationImpl.cc SVGAnimatedPreserveAspectRatioImpl.cc \ +SVGAnimatedRectImpl.cc SVGAnimatedAngleImpl.cc SVGAnimatedPathDataImpl.cc SVGAnimatedStringImpl.cc \ +\ +SVGLengthListImpl.cc SVGNumberListImpl.cc SVGPointListImpl.cc SVGTransformListImpl.cc \ +SVGStringListImpl.cc SVGPathSegListImpl.cc SVGElementInstanceListImpl.cc \ +\ +SVGAnimatedLengthListImpl.cc SVGAnimatedNumberListImpl.cc \ +SVGAnimatedPointsImpl.cc SVGAnimatedTransformListImpl.cc \ +\ +SVGShapeImpl.cc SVGContainerImpl.cc SVGBBoxTarget.cc SVGHelperImpl.cc \ +SVGStylableImpl.cc SVGTransformableImpl.cc SVGTestsImpl.cc SVGLangSpaceImpl.cc \ +SVGExternalResourcesRequiredImpl.cc SVGLocatableImpl.cc SVGFitToViewBoxImpl.cc \ +SVGPreserveAspectRatioImpl.cc SVGZoomAndPanImpl.cc SVGViewSpecImpl.cc \ +\ +SVGElementImpl.cc SVGElementInstanceImpl.cc \ +SVGDocumentImpl.cc SVGSVGElementImpl.cc SVGWindowImpl.cc \ +SVGDefsElementImpl.cc SVGUseElementImpl.cc \ +SVGDescElementImpl.cc SVGTitleElementImpl.cc \ +SVGGElementImpl.cc SVGSwitchElementImpl.cc \ +SVGSymbolElementImpl.cc SVGImageElementImpl.cc \ +SVGURIReferenceImpl.cc \ +\ +SVGStyleElementImpl.cc SVGCSSRuleImpl.cc \ +\ +SVGPathElementImpl.cc SVGPathSegImpl.cc SVGPathSegClosePathImpl.cc SVGPathSegArcImpl.cc \ +SVGPathSegMovetoImpl.cc SVGPathSegCurvetoQuadraticImpl.cc SVGPathSegCurvetoQuadraticSmoothImpl.cc \ +SVGPathSegCurvetoCubicImpl.cc SVGPathSegCurvetoCubicSmoothImpl.cc SVGPathSegLinetoImpl.cc \ +SVGPathSegLinetoHorizontalImpl.cc SVGPathSegLinetoVerticalImpl.cc \ +\ +SVGRectElementImpl.cc SVGCircleElementImpl.cc SVGEllipseElementImpl.cc SVGLineElementImpl.cc \ +SVGPolyElementImpl.cc SVGPolylineElementImpl.cc SVGPolygonElementImpl.cc \ +\ +SVGTextElementImpl.cc SVGTSpanElementImpl.cc SVGTRefElementImpl.cc \ +SVGTextPositioningElementImpl.cc SVGTextContentElementImpl.cc SVGTextPathElementImpl.cc \ +\ +SVGPaintImpl.cc SVGMarkerElementImpl.cc \ +\ +SVGColorImpl.cc SVGICCColorImpl.cc SVGColorProfileElementImpl.cc SVGColorProfileRuleImpl.cc \ +\ +SVGPaintServerImpl.cc SVGGradientElementImpl.cc SVGStopElementImpl.cc \ +SVGLinearGradientElementImpl.cc SVGRadialGradientElementImpl.cc SVGPatternElementImpl.cc \ +\ +SVGClipPathElementImpl.cc SVGMaskElementImpl.cc \ +\ +SVGFilterElementImpl.cc SVGFilterPrimitiveStandardAttributesImpl.cc \ +SVGFEBlendElementImpl.cc SVGFEColorMatrixElementImpl.cc \ +SVGFEComponentTransferElementImpl.cc SVGComponentTransferFunctionElementImpl.cc \ +SVGFEFuncAElementImpl.cc SVGFEFuncBElementImpl.cc SVGFEFuncGElementImpl.cc \ +SVGFEFuncRElementImpl.cc SVGFECompositeElementImpl.cc SVGFEConvolveMatrixElementImpl.cc \ +SVGFEFloodElementImpl.cc SVGFEGaussianBlurElementImpl.cc SVGFEDiffuseLightingElementImpl.cc \ +SVGFEDistantLightElementImpl.cc SVGFEPointLightElementImpl.cc SVGFESpotLightElementImpl.cc \ +SVGFEDisplacementMapElementImpl.cc SVGFEMergeElementImpl.cc SVGFEMergeNodeElementImpl.cc \ +SVGFEImageElementImpl.cc SVGFEMorphologyElementImpl.cc SVGFEOffsetElementImpl.cc \ +SVGFESpecularLightingElementImpl.cc SVGFETileElementImpl.cc SVGFETurbulenceElementImpl.cc \ +\ +SVGCursorElementImpl.cc \ +\ +SVGAElementImpl.cc SVGViewElementImpl.cc \ +\ +SVGScriptElementImpl.cc SVGEventImpl.cc SVGZoomEventImpl.cc \ +SVGEcma.cc generateddata.cpp \ +\ +SVGAnimationElementImpl.cc SVGAnimateElementImpl.cc SVGSetElementImpl.cc \ +SVGAnimateMotionElementImpl.cc SVGAnimateColorElementImpl.cc \ +SVGAnimateTransformElementImpl.cc SVGMPathElementImpl.cc SVGTimeScheduler.cc \ +\ +SVGFontElementImpl.cc SVGAltGlyphElementImpl.cc SVGAltGlyphDefElementImpl.cc \ +SVGGlyphRefElementImpl.cc SVGGlyphElementImpl.cc SVGMissingGlyphElementImpl.cc \ +SVGFontFaceElementImpl.cc SVGFontFaceFormatElementImpl.cc SVGFontFaceNameElementImpl.cc \ +SVGFontFaceSrcElementImpl.cc SVGFontFaceUriElementImpl.cc SVGDefinitionSrcElementImpl.cc \ +SVGHKernElementImpl.cc SVGVKernElementImpl.cc \ +\ +SVGMetadataElementImpl.cc \ +\ +SVGForeignObjectElementImpl.cc \ +\ +svgpathparser.cc + +libksvgdomimpl_la_METASOURCES = AUTO + +INCLUDES = $(FREETYPE_CFLAGS) -I$(top_srcdir)/ksvg/core -I$(top_srcdir)/ksvg/dom -I$(top_srcdir)/ksvg/ecma -I$(top_srcdir)/ksvg/data -I$(top_srcdir)/ksvg/impl/libs/art_support -I$(top_srcdir)/ksvg/impl/libs/libtext2path/src $(all_includes) diff --git a/ksvg/impl/SVGAElementImpl.cc b/ksvg/impl/SVGAElementImpl.cc new file mode 100644 index 00000000..153ff5ff --- /dev/null +++ b/ksvg/impl/SVGAElementImpl.cc @@ -0,0 +1,117 @@ +/* + 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> + +#include "SVGAElementImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGAnimatedStringImpl.h" + +using namespace KSVG; + +#include "SVGAElementImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +SVGAElementImpl::SVGAElementImpl(DOM::ElementImpl *impl) : SVGContainerImpl(impl), SVGURIReferenceImpl(), SVGTestsImpl(), SVGLangSpaceImpl(), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this), SVGTransformableImpl() +{ + KSVG_EMPTY_FLAGS + + m_target = new SVGAnimatedStringImpl(); + m_target->ref(); +} + +SVGAElementImpl::~SVGAElementImpl() +{ + if(m_target) + m_target->deref(); +} + +/* +@namespace KSVG +@begin SVGAElementImpl::s_hashTable 2 + target SVGAElementImpl::Target DontDelete|ReadOnly +@end +*/ + +Value SVGAElementImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case Target: + return m_target->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGAElementImpl::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; + + switch(token) + { + case Target: + { + if(m_target) + m_target->deref(); + + SVGAnimatedStringImpl *temp = new SVGAnimatedStringImpl(); + temp->ref(); + temp->setBaseVal(value.toString(exec).string()); + setTarget(temp); + break; + } + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +void SVGAElementImpl::setTarget(SVGAnimatedStringImpl *target) +{ + m_target = target; +} + +SVGAnimatedStringImpl *SVGAElementImpl::target() const +{ + return m_target; +} + +SVGAElementImpl *SVGAElementImpl::getLink(SVGElementImpl *sourceElem) +{ + for(DOM::Node node = *sourceElem; !node.isNull(); node = node.parentNode()) + { + SVGElementImpl *elem = sourceElem->ownerDoc()->getElementFromHandle(node.handle()); + if(elem) + { + SVGAElementImpl *link = dynamic_cast<SVGAElementImpl *>(elem); + if(link) + return link; + } + } + + return false; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAElementImpl.h b/ksvg/impl/SVGAElementImpl.h new file mode 100644 index 00000000..2da4c3d4 --- /dev/null +++ b/ksvg/impl/SVGAElementImpl.h @@ -0,0 +1,79 @@ +/* + 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. +*/ + +#ifndef SVGAElementImpl_H +#define SVGAElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGTestsImpl.h" +#include "SVGStylableImpl.h" +#include "SVGLangSpaceImpl.h" +#include "SVGContainerImpl.h" +#include "SVGURIReferenceImpl.h" +#include "SVGTransformableImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + + +namespace KSVG +{ + +class SVGAnimatedStringImpl; +class SVGAElementImpl : public SVGContainerImpl, + public SVGURIReferenceImpl, + public SVGTestsImpl, + public SVGLangSpaceImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl, + public SVGTransformableImpl +{ +public: + SVGAElementImpl(DOM::ElementImpl *); + virtual ~SVGAElementImpl(); + + void setTarget(SVGAnimatedStringImpl *target); + SVGAnimatedStringImpl *target() const; + + static SVGAElementImpl *getLink(SVGElementImpl *sourceElem); + +private: + SVGAnimatedStringImpl *m_target; + +public: + KSVG_GET + KSVG_PUT + KSVG_BRIDGE + + enum + { + // Properties + Target + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +KSVG_REGISTER_ELEMENT(SVGAElementImpl, "a") + +} + +#endif +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAltGlyphDefElementImpl.cc b/ksvg/impl/SVGAltGlyphDefElementImpl.cc new file mode 100644 index 00000000..2a0b5fe9 --- /dev/null +++ b/ksvg/impl/SVGAltGlyphDefElementImpl.cc @@ -0,0 +1,33 @@ +/* + 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 "SVGAltGlyphDefElementImpl.h" + +using namespace KSVG; + +SVGAltGlyphDefElementImpl::SVGAltGlyphDefElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl) +{ +} + +SVGAltGlyphDefElementImpl::~SVGAltGlyphDefElementImpl() +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAltGlyphDefElementImpl.h b/ksvg/impl/SVGAltGlyphDefElementImpl.h new file mode 100644 index 00000000..cc1c92f4 --- /dev/null +++ b/ksvg/impl/SVGAltGlyphDefElementImpl.h @@ -0,0 +1,49 @@ +/* + 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. +*/ + +#ifndef SVGAltGlyphDefElementImpl_H +#define SVGAltGlyphDefElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGElementImpl.h" + +namespace KSVG +{ + +class SVGAltGlyphDefElementImpl : public SVGElementImpl +{ +public: + SVGAltGlyphDefElementImpl(DOM::ElementImpl *); + virtual ~SVGAltGlyphDefElementImpl(); + +public: + KSVG_BRIDGE + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +KSVG_REGISTER_ELEMENT(SVGAltGlyphDefElementImpl, "altGlyphDef") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAltGlyphElementImpl.cc b/ksvg/impl/SVGAltGlyphElementImpl.cc new file mode 100644 index 00000000..d426bd74 --- /dev/null +++ b/ksvg/impl/SVGAltGlyphElementImpl.cc @@ -0,0 +1,50 @@ +/* + 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 "SVGSVGElementImpl.h" +#include "SVGAltGlyphElementImpl.h" + +using namespace KSVG; + +SVGAltGlyphElementImpl::SVGAltGlyphElementImpl(DOM::ElementImpl *impl) : SVGTSpanElementImpl(impl), SVGURIReferenceImpl() +{ +} + +SVGAltGlyphElementImpl::~SVGAltGlyphElementImpl() +{ +} + +void SVGAltGlyphElementImpl::setAttributes() +{ + SVGTSpanElementImpl::setAttributes(); +} + +DOM::DOMString SVGAltGlyphElementImpl::format() +{ + return ""; +} + +DOM::DOMString SVGAltGlyphElementImpl::glyphRef() +{ + return ""; +} + + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAltGlyphElementImpl.h b/ksvg/impl/SVGAltGlyphElementImpl.h new file mode 100644 index 00000000..8dcfe479 --- /dev/null +++ b/ksvg/impl/SVGAltGlyphElementImpl.h @@ -0,0 +1,55 @@ +/* + 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. +*/ + +#ifndef SVGAltGlyphElementImpl_H +#define SVGAltGlyphElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGTSpanElementImpl.h" +#include "SVGURIReferenceImpl.h" + +namespace KSVG +{ + +class SVGAltGlyphElementImpl : public SVGTSpanElementImpl, + public SVGURIReferenceImpl +{ +public: + SVGAltGlyphElementImpl(DOM::ElementImpl *); + virtual ~SVGAltGlyphElementImpl(); + virtual void setAttributes(); + + DOM::DOMString glyphRef(); + DOM::DOMString format(); + +public: + KSVG_BRIDGE + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +KSVG_REGISTER_ELEMENT(SVGAltGlyphElementImpl, "altGlyph") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAngleImpl.cc b/ksvg/impl/SVGAngleImpl.cc new file mode 100644 index 00000000..6102329d --- /dev/null +++ b/ksvg/impl/SVGAngleImpl.cc @@ -0,0 +1,277 @@ +/* + 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> + +#include "SVGAngle.h" + +#include "SVGAngleImpl.h" + +using namespace KSVG; + +#include "SVGAngleImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_cacheimpl.h" + +const double deg2rad = 0.017453292519943295769; // pi/180 +const double deg2grad = 400.0 / 360.0; +const double rad2grad = deg2grad / deg2rad; + +SVGAngleImpl::SVGAngleImpl() +{ + KSVG_EMPTY_FLAGS + + m_unitType = SVG_ANGLETYPE_UNKNOWN; + m_valueInSpecifiedUnits = 0; + m_value = 0; +} + +SVGAngleImpl::~SVGAngleImpl() +{ +} + +unsigned short SVGAngleImpl::unitType() const +{ + return m_unitType; +} + +void SVGAngleImpl::setValue(float value) +{ + m_value = value; +} + +float SVGAngleImpl::value() const +{ + return m_value; +} + +// calc m_value +void SVGAngleImpl::calculate() +{ + if(m_unitType == SVG_ANGLETYPE_GRAD) + m_value = m_valueInSpecifiedUnits / deg2grad; + else if(m_unitType == SVG_ANGLETYPE_RAD) + m_value = m_valueInSpecifiedUnits / deg2rad; + else if(m_unitType == SVG_ANGLETYPE_UNSPECIFIED || m_unitType == SVG_ANGLETYPE_DEG) + m_value = m_valueInSpecifiedUnits; +} + +void SVGAngleImpl::setValueInSpecifiedUnits(float valueInSpecifiedUnits) +{ + m_valueInSpecifiedUnits = valueInSpecifiedUnits; + calculate(); +} + +float SVGAngleImpl::valueInSpecifiedUnits() const +{ + return m_valueInSpecifiedUnits; +} + +void SVGAngleImpl::setValueAsString(const DOM::DOMString &valueAsString) +{ + m_valueAsString = valueAsString; + + QString s = valueAsString.string(); + + bool bOK; + m_valueInSpecifiedUnits = s.toFloat(&bOK); + m_unitType = SVG_ANGLETYPE_UNSPECIFIED; + + if(!bOK) + { + if(s.endsWith("deg")) + m_unitType = SVG_ANGLETYPE_DEG; + else if(s.endsWith("grad")) + m_unitType = SVG_ANGLETYPE_GRAD; + else if(s.endsWith("rad")) + m_unitType = SVG_ANGLETYPE_RAD; + } + + calculate(); +} + +DOM::DOMString SVGAngleImpl::valueAsString() const +{ + m_valueAsString.string().setNum(m_valueInSpecifiedUnits); + + switch(m_unitType) + { + case SVG_ANGLETYPE_UNSPECIFIED: + case SVG_ANGLETYPE_DEG: + m_valueAsString.string() += "deg"; + break; + case SVG_ANGLETYPE_RAD: + m_valueAsString.string() += "rad"; + break; + case SVG_ANGLETYPE_GRAD: + m_valueAsString.string() += "grad"; + break; + } + + return m_valueAsString; +} + +void SVGAngleImpl::newValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits) +{ + m_unitType = unitType; + m_valueInSpecifiedUnits = valueInSpecifiedUnits; + calculate(); +} + +void SVGAngleImpl::convertToSpecifiedUnits(unsigned short unitType) +{ + if(m_unitType == unitType) + return; + + if(m_unitType == SVG_ANGLETYPE_DEG && unitType == SVG_ANGLETYPE_RAD) + m_valueInSpecifiedUnits *= deg2rad; + else if(m_unitType == SVG_ANGLETYPE_GRAD && unitType == SVG_ANGLETYPE_RAD) + m_valueInSpecifiedUnits /= rad2grad; + else if(m_unitType == SVG_ANGLETYPE_DEG && unitType == SVG_ANGLETYPE_GRAD) + m_valueInSpecifiedUnits *= deg2grad; + else if(m_unitType == SVG_ANGLETYPE_RAD && unitType == SVG_ANGLETYPE_GRAD) + m_valueInSpecifiedUnits *= rad2grad; + else if(m_unitType == SVG_ANGLETYPE_RAD && unitType == SVG_ANGLETYPE_DEG) + m_valueInSpecifiedUnits /= deg2rad; + else if(m_unitType == SVG_ANGLETYPE_GRAD && unitType == SVG_ANGLETYPE_DEG) + m_valueInSpecifiedUnits /= deg2grad; + + m_unitType = unitType; +} + +// Helpers +double SVGAngleImpl::todeg(double rad) +{ + return rad / deg2rad; +} + +double SVGAngleImpl::torad(double deg) +{ + return deg * deg2rad; +} + +double SVGAngleImpl::shortestArcBisector(double angle1, double angle2) +{ + double bisector = (angle1 + angle2) / 2; + + if(fabs(angle1 - angle2) > 180) + bisector += 180; + + return bisector; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGAngleImpl::s_hashTable 5 + value SVGAngleImpl::Value DontDelete + valueInSpecifiedUnits SVGAngleImpl::ValueInSpecifiedUnits DontDelete + valueAsString SVGAngleImpl::ValueAsString DontDelete + unitType SVGAngleImpl::UnitType DontDelete +@end +@namespace KSVG +@begin SVGAngleImplProto::s_hashTable 3 + convertToSpecifiedUnits SVGAngleImpl::ConvertToSpecifiedUnits DontDelete|Function 1 + newValueSpecifiedUnits SVGAngleImpl::NewValueSpecifiedUnits DontDelete|Function 2 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGAngle", SVGAngleImplProto, SVGAngleImplProtoFunc) + +Value SVGAngleImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case Value: + return Number(value()); + case ValueInSpecifiedUnits: + return Number(valueInSpecifiedUnits()); + case ValueAsString: + return String(valueAsString().string()); + case UnitType: + return Number(unitType()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGAngleImpl::putValueProperty(ExecState *exec, int token, const KJS::Value &value, int) +{ + switch(token) + { + case Value: + setValue(value.toNumber(exec)); + break; + case ValueInSpecifiedUnits: + setValueInSpecifiedUnits(value.toNumber(exec)); + break; + case ValueAsString: + setValueAsString(value.toString(exec).string()); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +Value SVGAngleImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGAngleImpl) + + switch(id) + { + case SVGAngleImpl::ConvertToSpecifiedUnits: + obj->convertToSpecifiedUnits(static_cast<unsigned short>(args[0].toNumber(exec))); + break; + case SVGAngleImpl::NewValueSpecifiedUnits: + obj->newValueSpecifiedUnits(static_cast<unsigned short>(args[0].toNumber(exec)), args[1].toNumber(exec)); + break; + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return Undefined(); +} + +/* +@namespace KSVG +@begin SVGAngleImplConstructor::s_hashTable 7 + SVG_ANGLETYPE_UNKNOWN KSVG::SVG_ANGLETYPE_UNKNOWN DontDelete|ReadOnly + SVG_ANGLETYPE_UNSPECIFIED KSVG::SVG_ANGLETYPE_UNSPECIFIED DontDelete|ReadOnly + SVG_ANGLETYPE_RAD KSVG::SVG_ANGLETYPE_RAD DontDelete|ReadOnly + SVG_ANGLETYPE_DEG KSVG::SVG_ANGLETYPE_DEG DontDelete|ReadOnly + SVG_ANGLETYPE_GRAD KSVG::SVG_ANGLETYPE_GRAD DontDelete|ReadOnly +@end +*/ + +Value SVGAngleImplConstructor::getValueProperty(ExecState *, int token) const +{ + return Number(token); +} + +Value KSVG::getSVGAngleImplConstructor(ExecState *exec) +{ + return cacheGlobalBridge<SVGAngleImplConstructor>(exec, "[[svgangle.constructor]]"); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAngleImpl.h b/ksvg/impl/SVGAngleImpl.h new file mode 100644 index 00000000..d3c656de --- /dev/null +++ b/ksvg/impl/SVGAngleImpl.h @@ -0,0 +1,102 @@ +/* + 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. +*/ + +#ifndef SVGAngleImpl_H +#define SVGAngleImpl_H + +#include <dom/dom_misc.h> +#include <dom/dom_string.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAngleImpl : public DOM::DomShared +{ +public: + SVGAngleImpl(); + virtual ~SVGAngleImpl(); + + unsigned short unitType() const; + + void setValue(float value); + float value() const; + + void setValueInSpecifiedUnits(float valueInSpecifiedUnits); + float valueInSpecifiedUnits() const; + + void setValueAsString(const DOM::DOMString &valueAsString); + DOM::DOMString valueAsString() const; + + void newValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits); + void convertToSpecifiedUnits(unsigned short unitType); + + // Helpers + static double todeg(double rad); + static double torad(double deg); + + // Returns the angle that divides the shortest arc between the two angles. + static double shortestArcBisector(double angle1, double angle2); + +private: + unsigned short m_unitType; + float m_value; + float m_valueInSpecifiedUnits; + DOM::DOMString m_valueAsString; + + void calculate(); + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + Value, ValueInSpecifiedUnits, ValueAsString, UnitType, + // Functions + ConvertToSpecifiedUnits, NewValueSpecifiedUnits + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +class SVGAngleImplConstructor : public KJS::ObjectImp +{ +public: + SVGAngleImplConstructor(KJS::ExecState *) { } + KJS::Value getValueProperty(KJS::ExecState *, int token) const; + + // no put - all read-only + KSVG_GET +}; + +KJS::Value getSVGAngleImplConstructor(KJS::ExecState *exec); + +} + +KSVG_DEFINE_PROTOTYPE(SVGAngleImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGAngleImplProtoFunc, SVGAngleImpl) + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimateColorElementImpl.cc b/ksvg/impl/SVGAnimateColorElementImpl.cc new file mode 100644 index 00000000..c4cc0ad4 --- /dev/null +++ b/ksvg/impl/SVGAnimateColorElementImpl.cc @@ -0,0 +1,98 @@ +/* + 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 <math.h> + +#include <kdebug.h> + +#include "SVGColorImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGStylableImpl.h" +#include "SVGAnimateColorElementImpl.h" + +using namespace KSVG; + +SVGAnimateColorElementImpl::SVGAnimateColorElementImpl(DOM::ElementImpl *impl) : SVGAnimationElementImpl(impl) +{ + m_fromColor = new SVGColorImpl(this); + m_fromColor->ref(); + + m_toColor = new SVGColorImpl(this); + m_toColor->ref(); +} + +SVGAnimateColorElementImpl::~SVGAnimateColorElementImpl() +{ + m_fromColor->deref(); + m_toColor->deref(); +} + +/* + * Outstanding issues + * - 'values' support + * - 'by' support + */ + +void SVGAnimateColorElementImpl::setAttributes() +{ + SVGAnimationElementImpl::setAttributes(); + + SVGStylableImpl::setColor(getFrom(), m_fromColor); + SVGStylableImpl::setColor(getTo(), m_toColor); + + ownerDoc()->timeScheduler()->addTimer(this, int(getStartTime() * 1000.0)); +} + +void SVGAnimateColorElementImpl::handleTimerEvent() +{ + if(!m_connected) + { + double duration = getSimpleDuration() * 1000.0; + double dinterval = SVGTimeScheduler::staticTimerInterval; + + m_step = 0; + m_steps = (int) rint(duration / dinterval); + + m_connected = true; + ownerDoc()->timeScheduler()->connectIntervalTimer(this); + } + else + { + QColor fromColor(m_fromColor->rgbColor().color()); + QColor toColor(m_toColor->rgbColor().color()); + + int red = (int) rint(((toColor.red() - fromColor.red()) / static_cast<double>(m_steps)) * m_step + fromColor.red()); + int green = (int) rint(((toColor.green() - fromColor.green()) / static_cast<double>(m_steps)) * m_step + fromColor.green()); + int blue = (int) rint(((toColor.blue() - fromColor.blue()) / static_cast<double>(m_steps)) * m_step + fromColor.blue()); + + QString color = "rgb(" + QString::number(red) + "," + QString::number(green) + "," + QString::number(blue) + ")"; + applyAttribute(getAttributeName(), color); + } + + if(m_step < m_steps) + m_step++; + else + { + ownerDoc()->timeScheduler()->disconnectIntervalTimer(this); + m_connected = false; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimateColorElementImpl.h b/ksvg/impl/SVGAnimateColorElementImpl.h new file mode 100644 index 00000000..2832802e --- /dev/null +++ b/ksvg/impl/SVGAnimateColorElementImpl.h @@ -0,0 +1,60 @@ +/* + 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. +*/ + +#ifndef SVGAnimateColorElementImpl_H +#define SVGAnimateColorElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGAnimationElementImpl.h" + +class QTimer; + +namespace KSVG +{ + +class SVGColorImpl; +class SVGAnimateColorElementImpl : public SVGAnimationElementImpl +{ +public: + SVGAnimateColorElementImpl(DOM::ElementImpl *); + virtual ~SVGAnimateColorElementImpl(); + + virtual void handleTimerEvent(); + virtual void setAttributes(); + +private: + SVGColorImpl *m_toColor, *m_fromColor; + + int m_steps, m_step; + +public: + KSVG_BRIDGE + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +KSVG_REGISTER_ELEMENT(SVGAnimateColorElementImpl, "animateColor") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimateElementImpl.cc b/ksvg/impl/SVGAnimateElementImpl.cc new file mode 100644 index 00000000..ab9bc52c --- /dev/null +++ b/ksvg/impl/SVGAnimateElementImpl.cc @@ -0,0 +1,191 @@ +/* + 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> + +#include "SVGDocumentImpl.h" +#include "SVGAnimateElementImpl.h" + +using namespace KSVG; + +SVGAnimateElementImpl::SVGAnimateElementImpl(DOM::ElementImpl *impl) : SVGAnimationElementImpl(impl) +{ + m_animVal = 0.0; + m_addStep = 0.0; +} + +SVGAnimateElementImpl::~SVGAnimateElementImpl() +{ +} + +void SVGAnimateElementImpl::setAttributes() +{ + SVGAnimationElementImpl::setAttributes(); + + ownerDoc()->timeScheduler()->addTimer(this, int(getStartTime() * 1000.0)); +} + +void SVGAnimateElementImpl::handleTimerEvent() +{ + if(!m_connected) + { + double duration = getSimpleDuration() * 1000.0; + double dinterval = SVGTimeScheduler::staticTimerInterval; + + m_step = 0; + m_steps = (int) rint(duration / dinterval); + + double to = 0, from = 0; + if(getTo().isEmpty()) + to = targetElement()->getAttribute(getAttributeName()).string().toDouble(); + else + to = getTo().toDouble(); + + if(getFrom().isEmpty()) + from = targetElement()->getAttribute(getAttributeName()).string().toDouble(); + else + from = getFrom().toDouble(); + + // 'by' support + if(!getBy().isEmpty()) + { + m_animVal = from; + m_addStep = getBy().toDouble() / m_steps; + } + else + { + m_animVal = from; + m_addStep = (to - m_animVal) / m_steps; + } + + m_connected = true; + ownerDoc()->timeScheduler()->connectIntervalTimer(this); + } + else + { + m_animVal += m_addStep; + applyAttribute(getAttributeName(), QString::number(m_animVal)); + } + + if(m_step < m_steps) + m_step++; + else + { + ownerDoc()->timeScheduler()->disconnectIntervalTimer(this); + m_connected = false; + if(m_fill == REMOVE) + applyAttribute(getAttributeName(), targetElement()->getAttribute(getAttributeName()).string()); + } + +#if 0 + m_attributeTimer = addTimer(interval() * 1000, false); + + + /* + m_steps = (getSimpleDuration() * 1000) / SVGAnimationElementImpl::timerTime; + m_step = 0; + + if(m_additive == "sum" && m_times == 1 && !needCombine) + { + float add; + + SVGLengthImpl *temp = new SVGLengthImpl(); + temp->ref(); + temp->setValueAsString(targetElement()->getAttribute(m_attributeName).string()); + add = temp->value(); + temp->deref(); + + m_from += add; + m_newFrom += add; + m_to += add; + m_newTo += add; + + m_additiveAdded = add; + } + + m_addStep = (m_to - m_from) / m_steps; + m_attributeTimer = addTimer(SVGAnimationElementImpl::timerTime, false);*/ + } + else + { +/* m_from += m_addStep; + + if(m_additive == "replace" && needCombine) + needCombine = false; + + applyAttribute(m_attributeName, QString::number(m_from), needCombine); + + m_step++; + + if(m_step == m_steps) + { + removeTimer(m_attributeTimer); + + if(getRepeatDuration() == "indefinite" || getRepeatCount() == "indefinite") + { + m_times++; + m_firstEvent = true; + + if(m_accumulate != "sum") + { + m_from = m_newFrom; + m_to = m_newTo; + } + else + { + m_from += (m_newFrom - m_additiveAdded) / 2; + m_to += (m_newTo - m_additiveAdded) / 2; + } + + m_addStep = 0; + m_attributeTimer = 0; + + addTimer(1); + } + else if(!getRepeatCount().isEmpty()) + { + if(m_times <= getRepeatCount().toInt()) + { + m_times++; + m_firstEvent = true; + + if(m_accumulate != "sum") + { + m_from = m_newFrom; + m_to = m_newTo; + } + else + { + m_from += (m_newFrom - m_additiveAdded) / 2; + m_to += (m_newTo - m_additiveAdded) / 2; + } + + m_addStep = 0; + m_attributeTimer = 0; + + addTimer(1); + } + } + }*/ + } +#endif // 0 +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimateElementImpl.h b/ksvg/impl/SVGAnimateElementImpl.h new file mode 100644 index 00000000..855ced6e --- /dev/null +++ b/ksvg/impl/SVGAnimateElementImpl.h @@ -0,0 +1,59 @@ +/* + 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. +*/ + +#ifndef SVGAnimateElementImpl_H +#define SVGAnimateElementImpl_H + +#include "ksvg_lookup.h" +#include "SVGAnimationElementImpl.h" + +class QTimer; + +namespace KSVG +{ + +class SVGAnimateElementImpl : public SVGAnimationElementImpl +{ +public: + SVGAnimateElementImpl(DOM::ElementImpl *); + virtual ~SVGAnimateElementImpl(); + + virtual void handleTimerEvent(); + virtual void setAttributes(); + +private: + double m_addStep, m_animVal; + QTimer *m_timer; + + int m_steps, m_step; + +public: + KSVG_BRIDGE + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +KSVG_REGISTER_ELEMENT(SVGAnimateElementImpl, "animate") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimateMotionElementImpl.cc b/ksvg/impl/SVGAnimateMotionElementImpl.cc new file mode 100644 index 00000000..ce756d55 --- /dev/null +++ b/ksvg/impl/SVGAnimateMotionElementImpl.cc @@ -0,0 +1,102 @@ +/* + 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. +*/ + +// TODO: CLEANUP + +#include <dom/dom_doc.h> +#include "SVGDocumentImpl.h" +#include "SVGPathElementImpl.h" +#include "SVGAnimateMotionElementImpl.h" + +using namespace KSVG; + +SVGAnimateMotionElementImpl::SVGAnimateMotionElementImpl(DOM::ElementImpl *impl) : SVGAnimationElementImpl(impl) +{ +} + +SVGAnimateMotionElementImpl::~SVGAnimateMotionElementImpl() +{ +} + +void SVGAnimateMotionElementImpl::setAttributes() +{ + SVGAnimationElementImpl::setAttributes(); + +/* + // TODO: rotate.. + + DOM::DOMString _path = getAttribute("path"); + if(!_path.isNull()) + { + if(m_path) + m_path->deref(); + + m_path = new SVGPathElementImpl(reinterpret_cast<DOM::ElementImpl *>(static_cast<DOM::Document *>(ownerDoc())->createElement("path").handle())); + m_path->setOwnerDoc(ownerDoc()); + m_path->setAttribute("d", _path); + m_path->setAttributes(); + } + + addTimer(int(getStartTime() * 1000));*/ +} + +//void SVGAnimateMotionElementImpl::prerender(KSVGPainter *p) +//{ +// SVGAnimationElementImpl::prerender(p); + +/* if(!m_pathArray) + { + bool temp; + m_pathArray = m_path->preparePath(&temp, p->worldMatrix()); + }*/ +//} + +void SVGAnimateMotionElementImpl::handleTimerEvent(bool /*needCombine*/) +{ +/* if(m_firstEvent) + { + m_firstEvent = false; + + m_steps = (int) (getSimpleDuration() * 1000) / interval(); + m_step = 0; + + m_motionTimer = addTimer(interval() * 1000, false); + } + else + { + m_step++; + + if(m_step <= m_pathArray->count() - 1) + { + QPoint p = m_pathArray->point(m_step - 50); + applyAttribute("x", QString::number(p.x())); + applyAttribute("y", QString::number(p.y())); + kdDebug() << " X " << p.x() << " Y " << p.y() << " (" << m_pathArray->count() << "; " << m_step << ")" <<endl; + } + + if(m_step == m_steps) + { + // TODO: repeat + removeTimer(m_motionTimer); + } + }*/ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimateMotionElementImpl.h b/ksvg/impl/SVGAnimateMotionElementImpl.h new file mode 100644 index 00000000..fed4c550 --- /dev/null +++ b/ksvg/impl/SVGAnimateMotionElementImpl.h @@ -0,0 +1,56 @@ +/* + 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. +*/ + +#ifndef SVGAnimateMotionElementImpl_H +#define SVGAnimateMotionElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGAnimationElementImpl.h" + +namespace KSVG +{ + +class SVGPathElementImpl; +class SVGAnimateMotionElementImpl : public SVGAnimationElementImpl +{ +public: + SVGAnimateMotionElementImpl(DOM::ElementImpl *); + virtual ~SVGAnimateMotionElementImpl(); + + virtual void handleTimerEvent(bool needCombine = false); + virtual void setAttributes(); + +private: + int m_steps, m_step; + +public: + KSVG_BRIDGE + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +KSVG_REGISTER_ELEMENT(SVGAnimateMotionElementImpl, "animateMotion") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimateTransformElementImpl.cc b/ksvg/impl/SVGAnimateTransformElementImpl.cc new file mode 100644 index 00000000..d2634bb1 --- /dev/null +++ b/ksvg/impl/SVGAnimateTransformElementImpl.cc @@ -0,0 +1,257 @@ +/* + 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 <qstringlist.h> + +#include "SVGLengthImpl.h" +#include "SVGHelperImpl.h" +#include "SVGTransformImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGTransformListImpl.h" +#include "SVGAnimatedTransformListImpl.h" +#include "SVGAnimateTransformElementImpl.h" + +using namespace KSVG; + +SVGAnimateTransformElementImpl::SVGAnimateTransformElementImpl(DOM::ElementImpl *impl) : SVGAnimationElementImpl(impl) +{ + m_firstEvent = true; + m_setAttributes = false; + + m_rotateX = -1; + m_rotateY = -1; + m_times = 1; + m_from = 0; + m_to = 0; + + m_addStep = 0; +} + +SVGAnimateTransformElementImpl::~SVGAnimateTransformElementImpl() +{ +} + +void SVGAnimateTransformElementImpl::setAttributes() +{ + if(m_setAttributes) + return; + + m_setAttributes = true; + + SVGAnimationElementImpl::setAttributes(); + + /* + // TODO: much :) + + DOM::DOMString _type = getAttribute("type"); + if(!_type.isNull()) + m_type = _type.string().lower(); + + DOM::DOMString _from = getAttribute("from"); + if(!_from.isNull()) + { + if(m_type != "rotate") + { + SVGLengthImpl *temp = SVGSVGElementImpl::createSVGLength(); + temp->setValueAsString(_from.string()); + + m_from = temp->value(); + + temp->deref(); + } + else + { + SVGTransformListImpl *list = new SVGTransformListImpl(); + list->ref(); + + SVGHelperImpl::parseTransformAttribute(list, m_type + "(" + _from.string() + ")"); + + m_from = list->getFirst()->angle(); + + QStringList stringList = QStringList::split(' ', list->getFirst()->toString()); + m_rotateX = stringList[1].toInt(); + m_rotateY = stringList[2].mid(0, stringList[2].length() - 1).toInt(); + + list->deref(); + } + + m_newFrom = m_from; + m_addStep = m_from; + } + + DOM::DOMString _to = getAttribute("to"); + if(!_to.isNull()) + { + if(m_type != "rotate") + { + SVGLengthImpl *temp = SVGSVGElementImpl::createSVGLength(); + temp->setValueAsString(_to.string()); + + m_to = temp->value(); + + temp->deref(); + } + else + { + SVGTransformListImpl *list = new SVGTransformListImpl(); + list->ref(); + + SVGHelperImpl::parseTransformAttribute(list, m_type + "(" + _to.string() + ")"); + + m_to = list->getFirst()->angle(); + + list->deref(); + } + + m_newTo = m_to; + } + + // TODO: values + rotate including cx + cy + DOM::DOMString _values = getAttribute("values"); + if(!_values.isNull()) + { + QString test = _values.string(); + + if(test.contains(";")) + { + SVGLengthImpl *temp = SVGSVGElementImpl::createSVGLength(); + + QStringList list = QStringList::split(';', test); + temp->setValueAsString(list[0]); + m_from = temp->value(); + temp->setValueAsString(list[1]); + m_to = temp->value(); + + m_newFrom = m_from; + m_newTo = m_to; + m_addStep = m_from; + + temp->deref(); + } + } + + if(getStartTime() != -1) + addTimer(int(getStartTime() * 1000)); + else + addTimer(1); + */ +} + +void SVGAnimateTransformElementImpl::handleTimerEvent(bool) +{ /* + if(m_firstEvent) + { + m_firstEvent = false; + + m_steps = (int) (getSimpleDuration() * 1000) / interval(); + m_step = 0; + + m_addStep = (m_to - m_from) / m_steps; + + m_transformTimer = addTimer(interval() * 1000, false); + } + else + { + m_from += m_addStep; + + SVGTransformImpl *transform = SVGSVGElementImpl::createSVGTransform(); + + if(m_type == "rotate") + { + int x = 0, y = 0; + + if(m_rotateX != -1) + x = m_rotateX; + + if(m_rotateY != -1) + y = m_rotateY; + + transform->setRotate(m_from, x, y); + } + else if(m_type == "scale") + transform->setScale(m_from, m_from); + else if(m_type == "skewx") + transform->setSkewX(m_from); + else if(m_type == "skewy") + transform->setSkewY(m_from); + + QString trans = transform->toString(); + QString last = trans; + + if(targetElement()->hasAttribute("transform")) + { + trans += " " + targetElement()->getAttribute("transform").string(); + + if(!m_lastTransform.isEmpty()) + { + int pos = trans.find(m_lastTransform); + + QString extract; + extract += trans.mid(0, pos); + extract += trans.mid(pos + m_lastTransform.length() + 1, trans.length()); + + trans = extract; + } + } + + m_lastTransform = last; + + transform->deref(); + + applyAttribute("transform", trans); + + m_step++; + + if(m_step == m_steps) + { + removeTimer(m_transformTimer); + + if(getRepeatDuration() == "indefinite" || getRepeatCount() == "indefinite") + { + m_firstEvent = true; + m_from = m_newFrom; + m_to = m_newTo; + + m_addStep = 0; + m_transformTimer = 0; + + addTimer(1); + } + else if(!getRepeatCount().isEmpty()) + { + if(m_times <= getRepeatCount().toInt()) + { + m_times++; + m_firstEvent = true; + m_from = m_newFrom; + m_to = m_newTo; + + m_addStep = 0; + m_transformTimer = 0; + + addTimer(1); + } + } + } + } + */ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimateTransformElementImpl.h b/ksvg/impl/SVGAnimateTransformElementImpl.h new file mode 100644 index 00000000..7e6e2653 --- /dev/null +++ b/ksvg/impl/SVGAnimateTransformElementImpl.h @@ -0,0 +1,74 @@ +/* + 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. +*/ + +#ifndef SVGAnimateTransformElementImpl_H +#define SVGAnimateTransformElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGAnimationElementImpl.h" + +class QTimer; + +namespace KSVG +{ + +class SVGTransformImpl; +class SVGTransformListImpl; +class SVGAnimateTransformElementImpl : public SVGAnimationElementImpl +{ +public: + SVGAnimateTransformElementImpl(DOM::ElementImpl *); + virtual ~SVGAnimateTransformElementImpl(); + + virtual void handleTimerEvent(bool needCombine = false); + virtual void setAttributes(); + +private: + QString m_type, m_lastTransform; + + int m_times; + + int m_rotateX, m_rotateY; + + int m_steps, m_step; + + double m_from, m_to, m_newFrom, m_newTo; + double m_addStep; + + QTimer *m_transformTimer; + SVGTransformListImpl *m_transformList; + + bool m_firstEvent; + bool m_setAttributes; + +public: + KSVG_BRIDGE + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +KSVG_REGISTER_ELEMENT(SVGAnimateTransformElementImpl, "animateTransform") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedAngleImpl.cc b/ksvg/impl/SVGAnimatedAngleImpl.cc new file mode 100644 index 00000000..63f0c000 --- /dev/null +++ b/ksvg/impl/SVGAnimatedAngleImpl.cc @@ -0,0 +1,83 @@ +/* + 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> + +#include "SVGAngleImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGAnimatedAngleImpl.h" + +using namespace KSVG; + +#include "SVGAnimatedAngleImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +SVGAnimatedAngleImpl::SVGAnimatedAngleImpl() : DOM::DomShared() +{ + KSVG_EMPTY_FLAGS + + m_baseVal = SVGSVGElementImpl::createSVGAngle(); + m_animVal = SVGSVGElementImpl::createSVGAngle(); +} + +SVGAnimatedAngleImpl::~SVGAnimatedAngleImpl() +{ + if(m_baseVal) + m_baseVal->deref(); + if(m_animVal) + m_animVal->deref(); +} + +SVGAngleImpl *SVGAnimatedAngleImpl::baseVal() const +{ + return m_baseVal; +} + +SVGAngleImpl *SVGAnimatedAngleImpl::animVal() const +{ + return m_animVal; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGAnimatedAngleImpl::s_hashTable 3 + baseVal SVGAnimatedAngleImpl::BaseVal DontDelete|ReadOnly + animVal SVGAnimatedAngleImpl::AnimVal DontDelete|ReadOnly +@end +*/ + +Value SVGAnimatedAngleImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case BaseVal: + return m_baseVal->cache(exec); + case AnimVal: + return m_animVal->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedAngleImpl.h b/ksvg/impl/SVGAnimatedAngleImpl.h new file mode 100644 index 00000000..f6617ce6 --- /dev/null +++ b/ksvg/impl/SVGAnimatedAngleImpl.h @@ -0,0 +1,61 @@ +/* + 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. +*/ + +#ifndef SVGAnimatedAngleImpl_H +#define SVGAnimatedAngleImpl_H + +#include <dom/dom_misc.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAngleImpl; +class SVGAnimatedAngleImpl : public DOM::DomShared +{ +public: + SVGAnimatedAngleImpl(); + virtual ~SVGAnimatedAngleImpl(); + + SVGAngleImpl *baseVal() const; + SVGAngleImpl *animVal() const; + +private: + SVGAngleImpl *m_baseVal; + SVGAngleImpl *m_animVal; + +public: + KSVG_GET + + enum + { + // Properties + BaseVal, AnimVal + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedBooleanImpl.cc b/ksvg/impl/SVGAnimatedBooleanImpl.cc new file mode 100644 index 00000000..d30fa5ef --- /dev/null +++ b/ksvg/impl/SVGAnimatedBooleanImpl.cc @@ -0,0 +1,93 @@ +/* + 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> + +#include "SVGAnimatedBooleanImpl.h" + +using namespace KSVG; + +#include "SVGAnimatedBooleanImpl.lut.h" +#include "ksvg_bridge.h" + +SVGAnimatedBooleanImpl::SVGAnimatedBooleanImpl() : DOM::DomShared() +{ + KSVG_EMPTY_FLAGS + + m_baseVal = false; + m_animVal = false; +} + +SVGAnimatedBooleanImpl::~SVGAnimatedBooleanImpl() +{ +} + +void SVGAnimatedBooleanImpl::setBaseVal(bool baseVal) +{ + m_baseVal = baseVal; +} + +bool SVGAnimatedBooleanImpl::baseVal() const +{ + return m_baseVal; +} + +bool SVGAnimatedBooleanImpl::animVal() const +{ + return m_animVal; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGAnimatedBooleanImpl::s_hashTable 3 + baseVal SVGAnimatedBooleanImpl::BaseVal DontDelete + animVal SVGAnimatedBooleanImpl::AnimVal DontDelete|ReadOnly +@end +*/ + +Value SVGAnimatedBooleanImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case BaseVal: + return Number(baseVal()); + case AnimVal: + return Number(animVal()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGAnimatedBooleanImpl::putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int) +{ + switch(token) + { + case BaseVal: + setBaseVal(value.toBoolean(exec)); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedBooleanImpl.h b/ksvg/impl/SVGAnimatedBooleanImpl.h new file mode 100644 index 00000000..9e31792e --- /dev/null +++ b/ksvg/impl/SVGAnimatedBooleanImpl.h @@ -0,0 +1,64 @@ +/* + 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. +*/ + +#ifndef SVGAnimatedBooleanImpl_H +#define SVGAnimatedBooleanImpl_H + +#include <dom/dom_misc.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedBooleanImpl : public DOM::DomShared +{ +public: + SVGAnimatedBooleanImpl(); + virtual ~SVGAnimatedBooleanImpl(); + + void setBaseVal(bool baseVal); + bool baseVal() const; + + bool animVal() const; + +private: + bool m_baseVal; + bool m_animVal; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + BaseVal, AnimVal + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedEnumerationImpl.cc b/ksvg/impl/SVGAnimatedEnumerationImpl.cc new file mode 100644 index 00000000..f619f231 --- /dev/null +++ b/ksvg/impl/SVGAnimatedEnumerationImpl.cc @@ -0,0 +1,93 @@ +/* + 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> + +#include "SVGAnimatedEnumerationImpl.h" + +using namespace KSVG; + +#include "SVGAnimatedEnumerationImpl.lut.h" +#include "ksvg_bridge.h" + +SVGAnimatedEnumerationImpl::SVGAnimatedEnumerationImpl() : DOM::DomShared() +{ + KSVG_EMPTY_FLAGS + + m_baseVal = 0; + m_animVal = 0; +} + +SVGAnimatedEnumerationImpl::~SVGAnimatedEnumerationImpl() +{ +} + +void SVGAnimatedEnumerationImpl::setBaseVal(unsigned short baseVal) +{ + m_baseVal = baseVal; +} + +unsigned short SVGAnimatedEnumerationImpl::baseVal() const +{ + return m_baseVal; +} + +unsigned short SVGAnimatedEnumerationImpl::animVal() const +{ + return m_animVal; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGAnimatedEnumerationImpl::s_hashTable 3 + baseVal SVGAnimatedEnumerationImpl::BaseVal DontDelete + animVal SVGAnimatedEnumerationImpl::AnimVal DontDelete|ReadOnly +@end +*/ + +Value SVGAnimatedEnumerationImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case BaseVal: + return Number(baseVal()); + case AnimVal: + return Number(animVal()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGAnimatedEnumerationImpl::putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int) +{ + switch(token) + { + case BaseVal: + setBaseVal(static_cast<unsigned short>(value.toNumber(exec))); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedEnumerationImpl.h b/ksvg/impl/SVGAnimatedEnumerationImpl.h new file mode 100644 index 00000000..ae4638f4 --- /dev/null +++ b/ksvg/impl/SVGAnimatedEnumerationImpl.h @@ -0,0 +1,64 @@ +/* + 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. +*/ + +#ifndef SVGAnimatedEnumerationImpl_H +#define SVGAnimatedEnumerationImpl_H + +#include <dom/dom_misc.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedEnumerationImpl : public DOM::DomShared +{ +public: + SVGAnimatedEnumerationImpl(); + virtual ~SVGAnimatedEnumerationImpl(); + + void setBaseVal(unsigned short baseVal); + unsigned short baseVal() const; + + unsigned short animVal() const; + +private: + unsigned short m_baseVal; + unsigned short m_animVal; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + BaseVal, AnimVal + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedIntegerImpl.cc b/ksvg/impl/SVGAnimatedIntegerImpl.cc new file mode 100644 index 00000000..8bf08a87 --- /dev/null +++ b/ksvg/impl/SVGAnimatedIntegerImpl.cc @@ -0,0 +1,91 @@ +/* + 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> + +#include "SVGAnimatedIntegerImpl.h" + +using namespace KSVG; + +#include "SVGAnimatedIntegerImpl.lut.h" +#include "ksvg_bridge.h" + +SVGAnimatedIntegerImpl::SVGAnimatedIntegerImpl() : DOM::DomShared() +{ + KSVG_EMPTY_FLAGS + + m_baseVal = 0; + m_animVal = 0; +} + +SVGAnimatedIntegerImpl::~SVGAnimatedIntegerImpl() +{ +} + +void SVGAnimatedIntegerImpl::setBaseVal(long baseVal) +{ + m_baseVal = baseVal; +} + +long SVGAnimatedIntegerImpl::baseVal() const +{ + return m_baseVal; +} + +long SVGAnimatedIntegerImpl::animVal() const +{ + return m_animVal; +} + +/* +@namespace KSVG +@begin SVGAnimatedIntegerImpl::s_hashTable 3 + baseVal SVGAnimatedIntegerImpl::BaseVal DontDelete + animVal SVGAnimatedIntegerImpl::AnimVal DontDelete +@end +*/ + +Value SVGAnimatedIntegerImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case BaseVal: + return Number(baseVal()); + case AnimVal: + return Number(animVal()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } + return KJS::Undefined(); +} + +void SVGAnimatedIntegerImpl::putValueProperty(ExecState *exec, int token, const KJS::Value &value, int) +{ + switch(token) + { + case BaseVal: + setBaseVal(value.toInteger(exec)); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedIntegerImpl.h b/ksvg/impl/SVGAnimatedIntegerImpl.h new file mode 100644 index 00000000..8ad7ad88 --- /dev/null +++ b/ksvg/impl/SVGAnimatedIntegerImpl.h @@ -0,0 +1,64 @@ +/* + 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. +*/ + +#ifndef SVGAnimatedIntegerImpl_H +#define SVGAnimatedIntegerImpl_H + +#include <dom/dom_misc.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedIntegerImpl : public DOM::DomShared +{ +public: + SVGAnimatedIntegerImpl(); + virtual ~SVGAnimatedIntegerImpl(); + + void setBaseVal(long baseVal); + long baseVal() const; + + long animVal() const; + +private: + long m_baseVal; + long m_animVal; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + BaseVal, AnimVal + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedLengthImpl.cc b/ksvg/impl/SVGAnimatedLengthImpl.cc new file mode 100644 index 00000000..25176965 --- /dev/null +++ b/ksvg/impl/SVGAnimatedLengthImpl.cc @@ -0,0 +1,96 @@ +/* + 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> + +#include "SVGAnimatedLengthImpl.h" +#include "SVGElementImpl.h" + +using namespace KSVG; + +#include "SVGAnimatedLengthImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +SVGAnimatedLengthImpl::SVGAnimatedLengthImpl(LengthMode mode, SVGElementImpl *object) : DOM::DomShared() +{ + m_baseVal = new SVGLengthImpl(mode, object); + m_baseVal->ref(); + + m_animVal = new SVGLengthImpl(mode, object); + m_animVal->ref(); +} + +SVGAnimatedLengthImpl::SVGAnimatedLengthImpl(const SVGAnimatedLengthImpl &other) : DOM::DomShared() +{ + (*this) = other; +} + +SVGAnimatedLengthImpl::~SVGAnimatedLengthImpl() +{ + if(m_baseVal) + m_baseVal->deref(); + if(m_animVal) + m_animVal->deref(); +} + +SVGAnimatedLengthImpl &SVGAnimatedLengthImpl::operator=(const SVGAnimatedLengthImpl &other) +{ + *m_baseVal = *(other.m_baseVal); + *m_animVal = *(other.m_animVal); + + return *this; +} + +SVGLengthImpl *SVGAnimatedLengthImpl::baseVal() const +{ + return m_baseVal; +} + +SVGLengthImpl *SVGAnimatedLengthImpl::animVal() const +{ + return m_animVal; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGAnimatedLengthImpl::s_hashTable 3 + baseVal SVGAnimatedLengthImpl::BaseVal DontDelete|ReadOnly + animVal SVGAnimatedLengthImpl::AnimVal DontDelete|ReadOnly +@end +*/ + +Value SVGAnimatedLengthImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case BaseVal: + return m_baseVal->cache(exec); + case AnimVal: + return m_animVal->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedLengthImpl.h b/ksvg/impl/SVGAnimatedLengthImpl.h new file mode 100644 index 00000000..80f473db --- /dev/null +++ b/ksvg/impl/SVGAnimatedLengthImpl.h @@ -0,0 +1,65 @@ +/* + 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. +*/ + +#ifndef SVGAnimatedLengthImpl_H +#define SVGAnimatedLengthImpl_H + +#include <dom/dom_misc.h> + +#include "SVGLengthImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ +class SVGElementImpl; +class SVGAnimatedLengthImpl : public DOM::DomShared +{ +public: + SVGAnimatedLengthImpl(LengthMode mode = LENGTHMODE_UNKNOWN, SVGElementImpl *object = 0); + SVGAnimatedLengthImpl(const SVGAnimatedLengthImpl &); + virtual ~SVGAnimatedLengthImpl(); + + SVGAnimatedLengthImpl &operator=(const SVGAnimatedLengthImpl &); + + SVGLengthImpl *baseVal() const; + SVGLengthImpl *animVal() const; + +private: + SVGLengthImpl *m_baseVal; + SVGLengthImpl *m_animVal; + +public: + KSVG_GET + + enum + { + // Properties + BaseVal, AnimVal + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedLengthListImpl.cc b/ksvg/impl/SVGAnimatedLengthListImpl.cc new file mode 100644 index 00000000..296fa1ea --- /dev/null +++ b/ksvg/impl/SVGAnimatedLengthListImpl.cc @@ -0,0 +1,95 @@ +/* + 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> + +#include "SVGAnimatedLengthListImpl.h" + +using namespace KSVG; + +#include "SVGAnimatedLengthListImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +SVGAnimatedLengthListImpl::SVGAnimatedLengthListImpl() : DOM::DomShared() +{ + m_baseVal = new SVGLengthListImpl(); + m_baseVal->ref(); + + m_animVal = new SVGLengthListImpl(); + m_animVal->ref(); +} + +SVGAnimatedLengthListImpl::SVGAnimatedLengthListImpl(const SVGAnimatedLengthListImpl &other) : DOM::DomShared() +{ + (*this) = other; +} + +SVGAnimatedLengthListImpl::~SVGAnimatedLengthListImpl() +{ + if(m_baseVal) + m_baseVal->deref(); + if(m_animVal) + m_animVal->deref(); +} + +SVGAnimatedLengthListImpl &SVGAnimatedLengthListImpl::operator=(const SVGAnimatedLengthListImpl &other) +{ + *m_baseVal = *(other.m_baseVal); + *m_animVal = *(other.m_animVal); + + return *this; +} + +SVGLengthListImpl *SVGAnimatedLengthListImpl::baseVal() const +{ + return m_baseVal; +} + +SVGLengthListImpl *SVGAnimatedLengthListImpl::animVal() const +{ + return m_animVal; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGAnimatedLengthListImpl::s_hashTable 3 + baseVal SVGAnimatedLengthListImpl::BaseVal DontDelete|ReadOnly + animVal SVGAnimatedLengthListImpl::AnimVal DontDelete|ReadOnly +@end +*/ + +Value SVGAnimatedLengthListImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case BaseVal: + return m_baseVal->cache(exec); + case AnimVal: + return m_animVal->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedLengthListImpl.h b/ksvg/impl/SVGAnimatedLengthListImpl.h new file mode 100644 index 00000000..74f3cb1e --- /dev/null +++ b/ksvg/impl/SVGAnimatedLengthListImpl.h @@ -0,0 +1,61 @@ +/* + 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. +*/ + +#ifndef SVGAnimatedLengthListImpl_H +#define SVGAnimatedLengthListImpl_H + +#include "SVGLengthListImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedLengthListImpl : public DOM::DomShared +{ +public: + SVGAnimatedLengthListImpl(); + SVGAnimatedLengthListImpl(const SVGAnimatedLengthListImpl &); + virtual ~SVGAnimatedLengthListImpl(); + + SVGAnimatedLengthListImpl &operator=(const SVGAnimatedLengthListImpl &); + + SVGLengthListImpl *baseVal() const; + SVGLengthListImpl *animVal() const; + +private: + SVGLengthListImpl *m_baseVal; + SVGLengthListImpl *m_animVal; + +public: + KSVG_GET + + enum + { + // Properties + BaseVal, AnimVal + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; +}; + +} + +#endif diff --git a/ksvg/impl/SVGAnimatedNumberImpl.cc b/ksvg/impl/SVGAnimatedNumberImpl.cc new file mode 100644 index 00000000..2937c233 --- /dev/null +++ b/ksvg/impl/SVGAnimatedNumberImpl.cc @@ -0,0 +1,94 @@ +/* + 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> + +#include "SVGAnimatedNumberImpl.h" + +using namespace KSVG; + +#include "SVGAnimatedNumberImpl.lut.h" +#include "ksvg_bridge.h" + +SVGAnimatedNumberImpl::SVGAnimatedNumberImpl() : DOM::DomShared() +{ + KSVG_EMPTY_FLAGS + + m_baseVal = 0; + m_animVal = 0; +} + +SVGAnimatedNumberImpl::~SVGAnimatedNumberImpl() +{ +} + +void SVGAnimatedNumberImpl::setBaseVal(float baseVal) +{ + m_baseVal = baseVal; +} + +float SVGAnimatedNumberImpl::baseVal() const +{ + return m_baseVal; +} + +float SVGAnimatedNumberImpl::animVal() const +{ + return m_animVal; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGAnimatedNumberImpl::s_hashTable 3 + baseVal SVGAnimatedNumberImpl::BaseVal DontDelete + animVal SVGAnimatedNumberImpl::AnimVal DontDelete|ReadOnly +@end +*/ + +Value SVGAnimatedNumberImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case BaseVal: + return Number(baseVal()); + case AnimVal: + return Number(animVal()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } + + return Undefined(); +} + +void SVGAnimatedNumberImpl::putValueProperty(ExecState *exec, int token, const KJS::Value &value, int) +{ + switch(token) + { + case BaseVal: + setBaseVal(value.toNumber(exec)); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedNumberImpl.h b/ksvg/impl/SVGAnimatedNumberImpl.h new file mode 100644 index 00000000..81c9217b --- /dev/null +++ b/ksvg/impl/SVGAnimatedNumberImpl.h @@ -0,0 +1,63 @@ +/* + 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. +*/ + +#ifndef SVGAnimatedNumberImpl_H +#define SVGAnimatedNumberImpl_H + +#include <dom/dom_misc.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedNumberImpl : public DOM::DomShared +{ +public: + SVGAnimatedNumberImpl(); + virtual ~SVGAnimatedNumberImpl(); + + void setBaseVal(float baseVal); + float baseVal() const; + + float animVal() const; + +private: + float m_baseVal; + float m_animVal; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + BaseVal, AnimVal + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedNumberListImpl.cc b/ksvg/impl/SVGAnimatedNumberListImpl.cc new file mode 100644 index 00000000..d6ff44e0 --- /dev/null +++ b/ksvg/impl/SVGAnimatedNumberListImpl.cc @@ -0,0 +1,82 @@ +/* + 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> + +#include "SVGAnimatedNumberListImpl.h" + +using namespace KSVG; + +#include "SVGAnimatedNumberListImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +SVGAnimatedNumberListImpl::SVGAnimatedNumberListImpl() : DOM::DomShared() +{ + m_baseVal = new SVGNumberListImpl(); + m_baseVal->ref(); + + m_animVal = new SVGNumberListImpl(); + m_animVal->ref(); +} + +SVGAnimatedNumberListImpl::~SVGAnimatedNumberListImpl() +{ + if(m_baseVal) + m_baseVal->deref(); + if(m_animVal) + m_animVal->deref(); +} + +SVGNumberListImpl *SVGAnimatedNumberListImpl::baseVal() const +{ + return m_baseVal; +} + +SVGNumberListImpl *SVGAnimatedNumberListImpl::animVal() const +{ + return m_animVal; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGAnimatedNumberListImpl::s_hashTable 3 + baseVal SVGAnimatedNumberListImpl::BaseVal DontDelete|ReadOnly + animVal SVGAnimatedNumberListImpl::AnimVal DontDelete|ReadOnly +@end +*/ + +Value SVGAnimatedNumberListImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case BaseVal: + return m_baseVal->cache(exec); + case AnimVal: + return m_animVal->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedNumberListImpl.h b/ksvg/impl/SVGAnimatedNumberListImpl.h new file mode 100644 index 00000000..b44b3ffd --- /dev/null +++ b/ksvg/impl/SVGAnimatedNumberListImpl.h @@ -0,0 +1,58 @@ +/* + 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. +*/ + +#ifndef SVGAnimatedNumberListImpl_H +#define SVGAnimatedNumberListImpl_H + +#include "SVGNumberListImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedNumberListImpl : public DOM::DomShared +{ +public: + SVGAnimatedNumberListImpl(); + virtual ~SVGAnimatedNumberListImpl(); + + SVGNumberListImpl *baseVal() const; + SVGNumberListImpl *animVal() const; + +private: + SVGNumberListImpl *m_baseVal; + SVGNumberListImpl *m_animVal; + +public: + KSVG_GET + + enum + { + // Properties + BaseVal, AnimVal + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; +}; + +} + +#endif diff --git a/ksvg/impl/SVGAnimatedPathDataImpl.cc b/ksvg/impl/SVGAnimatedPathDataImpl.cc new file mode 100644 index 00000000..2b9ebf4c --- /dev/null +++ b/ksvg/impl/SVGAnimatedPathDataImpl.cc @@ -0,0 +1,108 @@ +/* + 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> + +#include "SVGPathSegListImpl.h" +#include "SVGAnimatedPathDataImpl.h" + +using namespace KSVG; + +#include "SVGAnimatedPathDataImpl.lut.h" +#include "ksvg_bridge.h" + +SVGAnimatedPathDataImpl::SVGAnimatedPathDataImpl() : DOM::DomShared() +{ + m_pathSegList = new SVGPathSegListImpl(); + m_pathSegList->ref(); + + m_normalizedPathSegList = new SVGPathSegListImpl(); + m_normalizedPathSegList->ref(); + + m_animatedPathSegList = new SVGPathSegListImpl(); + m_animatedPathSegList->ref(); + + m_animatedNormalizedPathSegList = new SVGPathSegListImpl(); + m_animatedNormalizedPathSegList->ref(); +} + +SVGAnimatedPathDataImpl::~SVGAnimatedPathDataImpl() +{ + if(m_pathSegList) + m_pathSegList->deref(); + if(m_normalizedPathSegList) + m_normalizedPathSegList->deref(); + if(m_animatedPathSegList) + m_animatedPathSegList->deref(); + if(m_animatedNormalizedPathSegList) + m_animatedNormalizedPathSegList->deref(); +} + +SVGPathSegListImpl *SVGAnimatedPathDataImpl::pathSegList() const +{ + return m_pathSegList; +} + +SVGPathSegListImpl *SVGAnimatedPathDataImpl::normalizedPathSegList() const +{ + return m_normalizedPathSegList; +} + +SVGPathSegListImpl *SVGAnimatedPathDataImpl::animatedPathSegList() const +{ + return m_animatedPathSegList; +} + +SVGPathSegListImpl *SVGAnimatedPathDataImpl::animatedNormalizedPathSegList() const +{ + return m_animatedNormalizedPathSegList; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGAnimatedPathDataImpl::s_hashTable 5 + pathSegList SVGAnimatedPathDataImpl::PathSegList DontDelete|ReadOnly + normalizedPathSegList SVGAnimatedPathDataImpl::NormalizedPathSegList DontDelete|ReadOnly + animatedPathSegList SVGAnimatedPathDataImpl::AnimatedPathSegList DontDelete|ReadOnly + animatedNormalizedPathSegList SVGAnimatedPathDataImpl::AnimatedNormalizedPathSegList DontDelete|ReadOnly +@end +*/ + +Value SVGAnimatedPathDataImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case PathSegList: + return pathSegList()->cache(exec); + case NormalizedPathSegList: + return normalizedPathSegList()->cache(exec); + case AnimatedPathSegList: + return animatedPathSegList()->cache(exec); + case AnimatedNormalizedPathSegList: + return animatedNormalizedPathSegList()->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); +} +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedPathDataImpl.h b/ksvg/impl/SVGAnimatedPathDataImpl.h new file mode 100644 index 00000000..2af1f893 --- /dev/null +++ b/ksvg/impl/SVGAnimatedPathDataImpl.h @@ -0,0 +1,67 @@ +/* + 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. +*/ + +#ifndef SVGAnimatedPathDataImpl_H +#define SVGAnimatedPathDataImpl_H + +#include <dom/dom_misc.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGPathSegListImpl; + +// special case, virtual public HAS to stay +class SVGAnimatedPathDataImpl : virtual public DOM::DomShared +{ +public: + SVGAnimatedPathDataImpl(); + virtual ~SVGAnimatedPathDataImpl(); + + SVGPathSegListImpl *pathSegList() const; + SVGPathSegListImpl *normalizedPathSegList() const; + SVGPathSegListImpl *animatedPathSegList() const; + SVGPathSegListImpl *animatedNormalizedPathSegList() const; + +private: + SVGPathSegListImpl *m_pathSegList; + SVGPathSegListImpl *m_normalizedPathSegList; + SVGPathSegListImpl *m_animatedPathSegList; + SVGPathSegListImpl *m_animatedNormalizedPathSegList; + +public: + KSVG_GET + + enum + { + // Properties + PathSegList, NormalizedPathSegList, AnimatedPathSegList, AnimatedNormalizedPathSegList + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedPointsImpl.cc b/ksvg/impl/SVGAnimatedPointsImpl.cc new file mode 100644 index 00000000..093ded77 --- /dev/null +++ b/ksvg/impl/SVGAnimatedPointsImpl.cc @@ -0,0 +1,139 @@ +/* + 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> + +#include <qstringlist.h> + +#include "CanvasItem.h" +#include "SVGPointListImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGAnimatedPointsImpl.h" + +using namespace KSVG; + +#include "SVGAnimatedPointsImpl.lut.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" + +SVGAnimatedPointsImpl::SVGAnimatedPointsImpl() : DOM::DomShared() +{ + KSVG_EMPTY_FLAGS + + m_points = new SVGPointListImpl(); + m_points->ref(); + + m_animatedPoints = new SVGPointListImpl(); + m_animatedPoints->ref(); +} + +SVGAnimatedPointsImpl::~SVGAnimatedPointsImpl() +{ + if(m_points) + m_points->deref(); + if(m_animatedPoints) + m_animatedPoints->deref(); +} + +SVGPointListImpl *SVGAnimatedPointsImpl::points() const +{ + return m_points; +} + +SVGPointListImpl *SVGAnimatedPointsImpl::animatedPoints() const +{ + return m_animatedPoints; +} + +void SVGAnimatedPointsImpl::parsePoints(QString _points, SVGPointListImpl *points) +{ + if(_points.isEmpty()) + return; + + _points = _points.simplifyWhiteSpace(); + + if(_points.contains(",,") || _points.contains(", ,")) + return; + + _points.replace(',', ' '); + _points.replace('\r', QString::null); + _points.replace('\n', QString::null); + + _points = _points.simplifyWhiteSpace(); + + QStringList pointList = QStringList::split(' ', _points); + for(QStringList::Iterator it = pointList.begin(); it != pointList.end(); it++) + { + SVGPointImpl *point = SVGSVGElementImpl::createSVGPoint(); + point->setX((*(it++)).toFloat()); + point->setY((*it).toFloat()); + + points->appendItem(point); + } +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGAnimatedPointsImpl::s_hashTable 3 + points SVGAnimatedPointsImpl::Points DontDelete|ReadOnly + animatedPoints SVGAnimatedPointsImpl::AnimatedPoints DontDelete|ReadOnly +@end +*/ + +Value SVGAnimatedPointsImpl::getValueProperty(ExecState *exec, int token) const +{ + //KSVG_CHECK_ATTRIBUTE + + switch(token) + { + case Points: // TODO: We need a pointList->toText function, quite trivial +// if(!attributeMode) + return points()->cache(exec); + case AnimatedPoints: + return animatedPoints()->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGAnimatedPointsImpl::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; + + switch(token) + { + case Points: + parsePoints(value.toString(exec).qstring(), m_points); + break; + case AnimatedPoints: + parsePoints(value.toString(exec).qstring(), m_animatedPoints); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedPointsImpl.h b/ksvg/impl/SVGAnimatedPointsImpl.h new file mode 100644 index 00000000..ef4dafca --- /dev/null +++ b/ksvg/impl/SVGAnimatedPointsImpl.h @@ -0,0 +1,67 @@ +/* + 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. +*/ + +#ifndef SVGAnimatedPointsImpl_H +#define SVGAnimatedPointsImpl_H + +#include <dom/dom_misc.h> + +#include "ksvg_lookup.h" + +class QString; + +namespace KSVG +{ + +class SVGPointListImpl; +class SVGAnimatedPointsImpl : virtual public DOM::DomShared +{ +public: + SVGAnimatedPointsImpl(); + virtual ~SVGAnimatedPointsImpl(); + + SVGPointListImpl *points() const; + SVGPointListImpl *animatedPoints() const; + + static void parsePoints(QString _points, SVGPointListImpl *points); + +protected: + SVGPointListImpl *m_points; + SVGPointListImpl *m_animatedPoints; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + Points, AnimatedPoints + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedPreserveAspectRatioImpl.cc b/ksvg/impl/SVGAnimatedPreserveAspectRatioImpl.cc new file mode 100644 index 00000000..166b987f --- /dev/null +++ b/ksvg/impl/SVGAnimatedPreserveAspectRatioImpl.cc @@ -0,0 +1,83 @@ +/* + 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> + +#include "SVGPreserveAspectRatioImpl.h" +#include "SVGAnimatedPreserveAspectRatioImpl.h" + +using namespace KSVG; + +#include "SVGAnimatedPreserveAspectRatioImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +SVGAnimatedPreserveAspectRatioImpl::SVGAnimatedPreserveAspectRatioImpl() : DOM::DomShared() +{ + m_baseVal = new SVGPreserveAspectRatioImpl(); + m_baseVal->ref(); + + m_animVal = new SVGPreserveAspectRatioImpl(); + m_animVal->ref(); +} + +SVGAnimatedPreserveAspectRatioImpl::~SVGAnimatedPreserveAspectRatioImpl() +{ + if(m_baseVal) + m_baseVal->deref(); + if(m_animVal) + m_animVal->deref(); +} + +SVGPreserveAspectRatioImpl *SVGAnimatedPreserveAspectRatioImpl::baseVal() const +{ + return m_baseVal; +} + +SVGPreserveAspectRatioImpl *SVGAnimatedPreserveAspectRatioImpl::animVal() const +{ + return m_animVal; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGAnimatedPreserveAspectRatioImpl::s_hashTable 3 + baseVal SVGAnimatedPreserveAspectRatioImpl::BaseVal DontDelete|ReadOnly + animVal SVGAnimatedPreserveAspectRatioImpl::AnimVal DontDelete|ReadOnly +@end +*/ + +Value SVGAnimatedPreserveAspectRatioImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case BaseVal: + return m_baseVal->cache(exec); + case AnimVal: + return m_animVal->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedPreserveAspectRatioImpl.h b/ksvg/impl/SVGAnimatedPreserveAspectRatioImpl.h new file mode 100644 index 00000000..30fb7c87 --- /dev/null +++ b/ksvg/impl/SVGAnimatedPreserveAspectRatioImpl.h @@ -0,0 +1,61 @@ +/* + 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. +*/ + +#ifndef SVGAnimatedPreserveAspectRatioImpl_H +#define SVGAnimatedPreserveAspectRatioImpl_H + +#include <dom/dom_misc.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGPreserveAspectRatioImpl; +class SVGAnimatedPreserveAspectRatioImpl : public DOM::DomShared +{ +public: + SVGAnimatedPreserveAspectRatioImpl(); + virtual ~SVGAnimatedPreserveAspectRatioImpl(); + + SVGPreserveAspectRatioImpl *baseVal() const; + SVGPreserveAspectRatioImpl *animVal() const; + +private: + SVGPreserveAspectRatioImpl *m_baseVal; + SVGPreserveAspectRatioImpl *m_animVal; + +public: + KSVG_GET + + enum + { + // Properties + BaseVal, AnimVal + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedRectImpl.cc b/ksvg/impl/SVGAnimatedRectImpl.cc new file mode 100644 index 00000000..4ba7a50d --- /dev/null +++ b/ksvg/impl/SVGAnimatedRectImpl.cc @@ -0,0 +1,81 @@ +/* + 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> + +#include "SVGRectImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGAnimatedRectImpl.h" + +using namespace KSVG; + +#include "SVGAnimatedRectImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +SVGAnimatedRectImpl::SVGAnimatedRectImpl() : DOM::DomShared() +{ + m_baseVal = SVGSVGElementImpl::createSVGRect(); + m_animVal = SVGSVGElementImpl::createSVGRect(); +} + +SVGAnimatedRectImpl::~SVGAnimatedRectImpl() +{ + if(m_baseVal) + m_baseVal->deref(); + if(m_animVal) + m_animVal->deref(); +} + +SVGRectImpl *SVGAnimatedRectImpl::baseVal() const +{ + return m_baseVal; +} + +SVGRectImpl *SVGAnimatedRectImpl::animVal() const +{ + return m_animVal; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGAnimatedRectImpl::s_hashTable 3 + baseVal SVGAnimatedRectImpl::BaseVal DontDelete + animVal SVGAnimatedRectImpl::AnimVal DontDelete +@end +*/ + +Value SVGAnimatedRectImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case BaseVal: + return m_baseVal->cache(exec); + case AnimVal: + return m_animVal->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedRectImpl.h b/ksvg/impl/SVGAnimatedRectImpl.h new file mode 100644 index 00000000..0619505d --- /dev/null +++ b/ksvg/impl/SVGAnimatedRectImpl.h @@ -0,0 +1,61 @@ +/* + 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. +*/ + +#ifndef SVGAnimatedRectImpl_H +#define SVGAnimatedRectImpl_H + +#include <dom/dom_misc.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGRectImpl; +class SVGAnimatedRectImpl : public DOM::DomShared +{ +public: + SVGAnimatedRectImpl(); + virtual ~SVGAnimatedRectImpl(); + + SVGRectImpl *baseVal() const; + SVGRectImpl *animVal() const; + +private: + SVGRectImpl *m_baseVal; + SVGRectImpl *m_animVal; + +public: + KSVG_GET + + enum + { + // Properties + BaseVal, AnimVal + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedStringImpl.cc b/ksvg/impl/SVGAnimatedStringImpl.cc new file mode 100644 index 00000000..1ce4f00b --- /dev/null +++ b/ksvg/impl/SVGAnimatedStringImpl.cc @@ -0,0 +1,90 @@ +/* + 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> + +#include "SVGAnimatedStringImpl.h" + +using namespace KSVG; + +#include "SVGAnimatedStringImpl.lut.h" +#include "ksvg_bridge.h" + +SVGAnimatedStringImpl::SVGAnimatedStringImpl() : DOM::DomShared() +{ + KSVG_EMPTY_FLAGS +} + +SVGAnimatedStringImpl::~SVGAnimatedStringImpl() +{ +} + +void SVGAnimatedStringImpl::setBaseVal(const DOM::DOMString &baseVal) +{ + m_baseVal = baseVal; +} + +DOM::DOMString SVGAnimatedStringImpl::baseVal() const +{ + return m_baseVal; +} + +DOM::DOMString SVGAnimatedStringImpl::animVal() const +{ + return m_animVal; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGAnimatedStringImpl::s_hashTable 3 + baseVal SVGAnimatedStringImpl::BaseVal DontDelete + animVal SVGAnimatedStringImpl::AnimVal DontDelete|ReadOnly +@end +*/ + +Value SVGAnimatedStringImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case BaseVal: + return String(baseVal().string()); + case AnimVal: + return String(animVal().string()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGAnimatedStringImpl::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case BaseVal: + setBaseVal(value.toString(exec).string()); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedStringImpl.h b/ksvg/impl/SVGAnimatedStringImpl.h new file mode 100644 index 00000000..cc15f7e2 --- /dev/null +++ b/ksvg/impl/SVGAnimatedStringImpl.h @@ -0,0 +1,65 @@ +/* + 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. +*/ + +#ifndef SVGAnimatedStringImpl_H +#define SVGAnimatedStringImpl_H + +#include <dom/dom_misc.h> +#include <dom/dom_string.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedStringImpl : public DOM::DomShared +{ +public: + SVGAnimatedStringImpl(); + virtual ~SVGAnimatedStringImpl(); + + void setBaseVal(const DOM::DOMString &baseVal); + DOM::DOMString baseVal() const; + + DOM::DOMString animVal() const; + +private: + DOM::DOMString m_baseVal; + DOM::DOMString m_animVal; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + BaseVal, AnimVal + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedTransformListImpl.cc b/ksvg/impl/SVGAnimatedTransformListImpl.cc new file mode 100644 index 00000000..2e3b5536 --- /dev/null +++ b/ksvg/impl/SVGAnimatedTransformListImpl.cc @@ -0,0 +1,83 @@ +/* + 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> + +#include "SVGTransformListImpl.h" +#include "SVGAnimatedTransformListImpl.h" + +using namespace KSVG; + +#include "SVGAnimatedTransformListImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +SVGAnimatedTransformListImpl::SVGAnimatedTransformListImpl() : DOM::DomShared() +{ + m_baseVal = new SVGTransformListImpl(); + m_baseVal->ref(); + + m_animVal = new SVGTransformListImpl(); + m_animVal->ref(); +} + +SVGAnimatedTransformListImpl::~SVGAnimatedTransformListImpl() +{ + if(m_baseVal) + m_baseVal->deref(); + if(m_animVal) + m_animVal->deref(); +} + +SVGTransformListImpl *SVGAnimatedTransformListImpl::baseVal() const +{ + return m_baseVal; +} + +SVGTransformListImpl *SVGAnimatedTransformListImpl::animVal() const +{ + return m_animVal; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGAnimatedTransformListImpl::s_hashTable 3 + baseVal SVGAnimatedTransformListImpl::BaseVal DontDelete|ReadOnly + animVal SVGAnimatedTransformListImpl::AnimVal DontDelete|ReadOnly +@end +*/ + +Value SVGAnimatedTransformListImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case BaseVal: + return m_baseVal->cache(exec); + case AnimVal: + return m_animVal->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimatedTransformListImpl.h b/ksvg/impl/SVGAnimatedTransformListImpl.h new file mode 100644 index 00000000..dc4be7e1 --- /dev/null +++ b/ksvg/impl/SVGAnimatedTransformListImpl.h @@ -0,0 +1,61 @@ +/* + 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. +*/ + +#ifndef SVGAnimatedTransformListImpl_H +#define SVGAnimatedTransformListImpl_H + +#include <dom/dom_misc.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGTransformListImpl; +class SVGAnimatedTransformListImpl : public DOM::DomShared +{ +public: + SVGAnimatedTransformListImpl(); + virtual ~SVGAnimatedTransformListImpl(); + + SVGTransformListImpl *baseVal() const; + SVGTransformListImpl *animVal() const; + +private: + SVGTransformListImpl *m_baseVal; + SVGTransformListImpl *m_animVal; + +public: + KSVG_GET + + enum + { + // Properties + BaseVal, AnimVal + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimationElementImpl.cc b/ksvg/impl/SVGAnimationElementImpl.cc new file mode 100644 index 00000000..454a323e --- /dev/null +++ b/ksvg/impl/SVGAnimationElementImpl.cc @@ -0,0 +1,465 @@ +/* + 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 <math.h> + +#include <kdebug.h> + +#include <qtimer.h> + +#include "CanvasItem.h" +#include "SVGHelperImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGStringListImpl.h" +#include "SVGURIReferenceImpl.h" +#include "SVGAnimationElementImpl.h" + +using namespace KSVG; + +#include "SVGAnimationElementImpl.lut.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" + +SVGAnimationElementImpl::SVGAnimationElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGTestsImpl(), SVGExternalResourcesRequiredImpl() +{ + KSVG_EMPTY_FLAGS + + m_connected = false; + m_targetElement = 0; + + m_values = new SVGStringListImpl(); + m_keyTimes= new SVGStringListImpl(); + m_keySplines = new SVGStringListImpl(); + + m_fill = REMOVE; + m_additive = REPLACE; + m_accumulate = ACCUMULATE_NONE; +} + +SVGAnimationElementImpl::~SVGAnimationElementImpl() +{ + if(m_targetElement) + m_targetElement->deref(); +} + +SVGElementImpl *SVGAnimationElementImpl::targetElement() const +{ + if(!m_targetElement) + { + SVGAnimationElementImpl *modify = const_cast<SVGAnimationElementImpl *>(this); + if(!m_href.isEmpty()) + modify->setTargetElement(ownerDoc()->getElementByIdRecursive(ownerSVGElement(), SVGURIReferenceImpl::getTarget(m_href))); + else if(!parentNode().isNull()) + modify->setTargetElement(ownerDoc()->getElementFromHandle(parentNode().handle())); + } + + return m_targetElement; +} + +double SVGAnimationElementImpl::parseClockValue(const QString &data) const +{ + QString parse = data.stripWhiteSpace(); + QString debugOutput = "parseClockValue(" + parse + ") -> "; + + if(parse == "indefinite") // Saves some time... + return -1; + + double result; + + int doublePointOne = parse.find(':'); + int doublePointTwo = parse.find(':', doublePointOne + 1); + + if(doublePointOne != -1 && doublePointTwo != -1) // Spec: "Full clock values" + { + unsigned int hours = parse.mid(0, 2).toUInt(); + unsigned int minutes = parse.mid(3, 2).toUInt(); + unsigned int seconds = parse.mid(6, 2).toUInt(); + unsigned int milliseconds = 0; + + result = (3600 * hours) + (60 * minutes) + seconds; + + if(parse.find('.') != -1) + { + QString temp = parse.mid(9, 2); + milliseconds = temp.toUInt(); + result += (milliseconds * (1 / pow(10.0, temp.length()))); + } + } + else if(doublePointOne != -1 && doublePointTwo == -1) // Spec: "Partial clock values" + { + unsigned int minutes = parse.mid(0, 2).toUInt(); + unsigned int seconds = parse.mid(3, 2).toUInt(); + unsigned int milliseconds = 0; + + result = (60 * minutes) + seconds; + + if(parse.find('.') != -1) + { + QString temp = parse.mid(6, 2); + milliseconds = temp.toUInt(); + result += (milliseconds * (1 / pow(10.0, temp.length()))); + } + } + else // Spec: "Timecount values" + { + int dotPosition = parse.find('.'); + + if(parse.endsWith("h")) + { + if(dotPosition == -1) + result = parse.mid(0, parse.length() - 1).toUInt() * 3600; + else + { + result = parse.mid(0, dotPosition).toUInt() * 3600; + QString temp = parse.mid(dotPosition + 1, parse.length() - dotPosition - 2); + result += (3600.0 * temp.toUInt()) * (1 / pow(10.0, temp.length())); + } + } + else if(parse.endsWith("min")) + { + if(dotPosition == -1) + result = parse.mid(0, parse.length() - 3).toUInt() * 60; + else + { + result = parse.mid(0, dotPosition).toUInt() * 60; + QString temp = parse.mid(dotPosition + 1, parse.length() - dotPosition - 4); + result += (60.0 * temp.toUInt()) * (1 / pow(10.0, temp.length())); + } + } + else if(parse.endsWith("ms")) + { + if(dotPosition == -1) + result = parse.mid(0, parse.length() - 2).toUInt() / 1000.0; + else + { + result = parse.mid(0, dotPosition).toUInt() / 1000.0; + QString temp = parse.mid(dotPosition + 1, parse.length() - dotPosition - 3); + result += (temp.toUInt() / 1000.0) * (1 / pow(10.0, temp.length())); + } + } + else if(parse.endsWith("s")) + { + if(dotPosition == -1) + result = parse.mid(0, parse.length() - 1).toUInt(); + else + { + result = parse.mid(0, dotPosition).toUInt(); + QString temp = parse.mid(dotPosition + 1, parse.length() - dotPosition - 2); + result += temp.toUInt() * (1 / pow(10.0, temp.length())); + } + } + else + result = parse.toDouble(); + } + + kdDebug() << debugOutput << result << endl; + return result; +} + +/* +@namespace KSVG +@begin SVGAnimationElementImpl::s_hashTable 23 + targetElement SVGAnimationElementImpl::TargetElement DontDelete|ReadOnly + href SVGAnimationElementImpl::Href DontDelete|ReadOnly + additive SVGAnimationElementImpl::Additive DontDelete|ReadOnly + accumulate SVGAnimationElementImpl::Accumulate DontDelete|ReadOnly + attributeName SVGAnimationElementImpl::AttributeName DontDelete|ReadOnly + attributeType SVGAnimationElementImpl::AttributeType DontDelete|ReadOnly + calcMode SVGAnimationElementImpl::CalcMode DontDelete|ReadOnly + values SVGAnimationElementImpl::Values DontDelete|ReadOnly + keyTimes SVGAnimationElementImpl::KeyTimes DontDelete|ReadOnly + keySplines SVGAnimationElementImpl::KeySplines DontDelete|ReadOnly + from SVGAnimationElementImpl::From DontDelete|ReadOnly + to SVGAnimationElementImpl::To DontDelete|ReadOnly + by SVGAnimationElementImpl::By DontDelete|ReadOnly + begin SVGAnimationElementImpl::Begin DontDelete|ReadOnly + dur SVGAnimationElementImpl::Dur DontDelete|ReadOnly + end SVGAnimationElementImpl::End DontDelete|ReadOnly + min SVGAnimationElementImpl::Min DontDelete|ReadOnly + max SVGAnimationElementImpl::Max DontDelete|ReadOnly + restart SVGAnimationElementImpl::Restart DontDelete|ReadOnly + repeatCount SVGAnimationElementImpl::RepeatCount DontDelete|ReadOnly + repeatDur SVGAnimationElementImpl::RepeatDur DontDelete|ReadOnly + fill SVGAnimationElementImpl::Fill DontDelete|ReadOnly +@end +@namespace KSVG +@begin SVGAnimationElementImplProto::s_hashTable 5 + getStartTime SVGAnimationElementImpl::GetStartTime DontDelete|Function 0 + getCurrentTime SVGAnimationElementImpl::GetCurrentTime DontDelete|Function 0 + getSimpleDuration SVGAnimationElementImpl::GetSimpleDuration DontDelete|Function 0 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGAnimationElement",SVGAnimationElementImplProto,SVGAnimationElementImplProtoFunc) + +Value SVGAnimationElementImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case TargetElement: + return m_targetElement->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGAnimationElementImpl::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; + + QString val = value.toString(exec).qstring(); + switch(token) + { + case Href: + m_href = val; + break; + case Additive: + m_additive = (val == "sum") ? SUM : REPLACE; + break; + case Accumulate: + m_accumulate = (val == "sum") ? ACCUMULATE_SUM : ACCUMULATE_NONE; + break; + case AttributeName: + m_attributeName = val; + break; + case AttributeType: + if(val == "css") + m_attributeType = CSS; + else if(val == "xml") + m_attributeType = XML; + else + m_attributeType = AUTO; + break; + case CalcMode: // FIXME: See spec for default values!!! + if(val == "discrete") + m_calcMode = DISCRETE; + else if(val == "linear") + m_calcMode = LINEAR; + else if(val == "spline") + m_calcMode = SPLINE; + else if(val == "paced") + m_calcMode = PACED; + break; + case Values: + SVGHelperImpl::parseSemicolonSeperatedList(m_values, val); + break; + case KeyTimes: + SVGHelperImpl::parseSemicolonSeperatedList(m_keyTimes, val); + break; + case KeySplines: + SVGHelperImpl::parseSemicolonSeperatedList(m_keySplines, val); + break; + case From: + m_from = val; + break; + case To: + m_to = val; + break; + case By: + m_by = val; + break; + case Begin: + case End: + { + // Create list + SVGStringListImpl *temp = new SVGStringListImpl(); + temp->ref(); + + // Feed data into list + SVGHelperImpl::parseSemicolonSeperatedList(temp, val); + + // Parse data + for(unsigned int i = 0; i < temp->numberOfItems(); i++) + { + QString current = temp->getItem(i)->string(); + + if(current.startsWith("accessKey")) + { + // Register keyDownEventListener for the character + QString character = current.mid(current.length() - 2, 1); + + kdDebug() << "ACCESSKEY CHARACTER " << character << endl; + } + else if(current.startsWith("wallclock")) + { + int firstBrace = current.find("("); + int secondBrace = current.find(")"); + + QString wallclockValue = current.mid(firstBrace + 1, secondBrace - firstBrace - 2); + + kdDebug() << "WALLCLOCK VALUE " << wallclockValue << endl; + } + else if(current.contains(".")) + { + int dotPosition = current.find("."); + + QString element = current.mid(0, dotPosition); + QString clockValue; + + if(current.contains("begin")) + clockValue = current.mid(dotPosition + 6); + else if(current.contains("end")) + clockValue = current.mid(dotPosition + 4); + else if(current.contains("repeat")) + clockValue = current.mid(dotPosition + 7); + else // DOM2 Event Reference + { + int plusMinusPosition = -1; + + if(current.contains("+")) + plusMinusPosition = current.find("+"); + else if(current.contains("-")) + plusMinusPosition = current.find("-"); + + QString event = current.mid(dotPosition + 1, plusMinusPosition - dotPosition - 1); + + clockValue = current.mid(dotPosition + event.length() + 1); + kdDebug() << "EVENT " << event << endl; + } + + kdDebug() << "ELEMENT " << element << " CLOCKVALUE " << clockValue << endl; + } + else + { + if(token == Begin) + m_begin = parseClockValue(current); + else + m_end = parseClockValue(current); + } + } + + temp->deref(); + + break; + } + case Dur: + m_duration = parseClockValue(val); + break; +// case Min: +// case Max: + case Restart: + if(val == "whenNotActive") + m_restart = WHENNOTACTIVE; + else if(val == "never") + m_restart = NEVER; + else + m_restart = ALWAYS; + break; + case RepeatCount: + m_repeatCount = val; + break; + case RepeatDur: + m_repeatDur = val; + break; + case Fill: + m_fill = (val == "freeze") ? FREEZE : REMOVE; + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +Value SVGAnimationElementImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &) +{ + KSVG_CHECK_THIS(SVGAnimationElementImpl) + + switch(id) + { + case SVGAnimationElementImpl::GetStartTime: + return Number(obj->getStartTime()); + case SVGAnimationElementImpl::GetCurrentTime: + return Number(obj->getCurrentTime()); + case SVGAnimationElementImpl::GetSimpleDuration: + return Number(obj->getSimpleDuration()); + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return Undefined(); +} + +void SVGAnimationElementImpl::setAttributes() +{ + SVGElementImpl::setAttributes(); + + // Spec: Default value is "replace" + if(KSVG_TOKEN_NOT_PARSED(Additive)) + KSVG_SET_ALT_ATTRIBUTE(Additive, "replace") + + // Spec: Default value is "none" + if(KSVG_TOKEN_NOT_PARSED(Accumulate)) + KSVG_SET_ALT_ATTRIBUTE(Accumulate, "none") + + // Spec: Default value is "always" + if(KSVG_TOKEN_NOT_PARSED(Restart)) + KSVG_SET_ALT_ATTRIBUTE(Restart, "always") +} + +void SVGAnimationElementImpl::setTargetElement(SVGElementImpl *target) +{ + if(m_targetElement) + m_targetElement->deref(); + + m_targetElement = target; + m_targetElement->ref(); +} + +void SVGAnimationElementImpl::applyAttribute(const QString &name, const QString &value) +{ + SVGElementImpl *target = targetElement(); + if(!target) + { + kdDebug() << k_funcinfo << " name: " << name << " value: " << value << " NO TARGET ELEMENT!" << endl; + return; + } + + // The only two cases I can imagine, where combining is needed (Niko) + bool combine = (name == "style" || name == "transform"); + + if(!combine) + target->setAttributeInternal(name, value); + else + { + kdDebug() << "TODO COMBINE: " << value << " NAME " << name << endl; + } +} + +double SVGAnimationElementImpl::getStartTime() const +{ + return m_begin; +} + +double SVGAnimationElementImpl::getCurrentTime() const +{ + return 0.0; +} + +double SVGAnimationElementImpl::getSimpleDuration() const +{ + return m_duration; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGAnimationElementImpl.h b/ksvg/impl/SVGAnimationElementImpl.h new file mode 100644 index 00000000..9fd9446e --- /dev/null +++ b/ksvg/impl/SVGAnimationElementImpl.h @@ -0,0 +1,149 @@ +/* + 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. +*/ + +#ifndef SVGAnimationElementImpl_H +#define SVGAnimationElementImpl_H + +#include "SVGElementImpl.h" +#include "SVGTestsImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +enum EFillMode +{ + REMOVE, + FREEZE +}; + +enum EAdditiveMode +{ + REPLACE, + SUM +}; + +enum EAccumulateMode +{ + ACCUMULATE_NONE, + ACCUMULATE_SUM +}; + +enum ECalcMode +{ + DISCRETE, + LINEAR, + PACED, + SPLINE +}; + +enum ERestart +{ + ALWAYS, + WHENNOTACTIVE, + NEVER +}; + +enum EAttributeType +{ + CSS, + XML, + AUTO +}; + +class SVGAnimationElementImpl : public SVGElementImpl, + public SVGTestsImpl, + public SVGExternalResourcesRequiredImpl +{ +public: + SVGAnimationElementImpl(DOM::ElementImpl *); + virtual ~SVGAnimationElementImpl(); + + SVGElementImpl *targetElement() const; + void setTargetElement(SVGElementImpl *target); + + void applyAttribute(const QString &name, const QString &value); + + virtual void handleTimerEvent() { } //= 0; + virtual void setAttributes(); + + double getStartTime() const; + double getCurrentTime() const; + double getSimpleDuration() const; + + QString getRepeatCount() const { return m_repeatCount; } + QString getRepeatDuration() const { return m_repeatDur; } + + QString getAttributeName() const { return m_attributeName; } + QString getFrom() const { return m_from; } + QString getTo() const { return m_to; } + QString getBy() const { return m_by; } + +protected: + double parseClockValue(const QString &data) const; + + bool m_connected; + EFillMode m_fill : 1; + EAdditiveMode m_additive : 1; + EAccumulateMode m_accumulate : 1; + ECalcMode m_calcMode : 2; + ERestart m_restart : 2; + EAttributeType m_attributeType : 2; + SVGElementImpl *m_targetElement; + + QString m_href; + QString m_attributeName; + QString m_from, m_to, m_by; + + double m_begin, m_end, m_duration; + + QString m_repeatCount, m_repeatDur; + + SVGStringListImpl *m_values, *m_keyTimes, *m_keySplines; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + TargetElement, + Href, Additive, Accumulate, AttributeName, AttributeType, + CalcMode, Values, KeyTimes, KeySplines, From, To, By, + Begin, Dur, End, Min, Max, Restart, RepeatCount, RepeatDur, Fill, + // Functions + GetStartTime, GetCurrentTime, GetSimpleDuration + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +KSVG_DEFINE_PROTOTYPE(SVGAnimationElementImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGAnimationElementImplProtoFunc, SVGAnimationElementImpl) + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGBBoxTarget.cc b/ksvg/impl/SVGBBoxTarget.cc new file mode 100644 index 00000000..fcef164e --- /dev/null +++ b/ksvg/impl/SVGBBoxTarget.cc @@ -0,0 +1,55 @@ +/* + 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 <dom/dom_misc.h> + +#include "SVGShapeImpl.h" +#include "SVGBBoxTarget.h" + +using namespace KSVG; + +SVGBBoxTarget::SVGBBoxTarget() +{ + m_target = 0; +} + +SVGBBoxTarget::~SVGBBoxTarget() +{ + if(m_target) + dynamic_cast<DOM::DomShared *>(m_target)->deref(); +} + +SVGShapeImpl *SVGBBoxTarget::getBBoxTarget() const +{ + return m_target; +} + +void SVGBBoxTarget::setBBoxTarget(SVGShapeImpl *target) +{ + if(m_target) + dynamic_cast<DOM::DomShared *>(m_target)->deref(); + + m_target = target; + + if(m_target) + dynamic_cast<DOM::DomShared *>(m_target)->ref(); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGBBoxTarget.h b/ksvg/impl/SVGBBoxTarget.h new file mode 100644 index 00000000..03de657d --- /dev/null +++ b/ksvg/impl/SVGBBoxTarget.h @@ -0,0 +1,45 @@ +/* + 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. +*/ + +#ifndef SVGBBoxTarget_H +#define SVGBBoxTarget_H + +namespace KSVG +{ + +class SVGShapeImpl; +class SVGBBoxTarget +{ +public: + SVGBBoxTarget(); + virtual ~SVGBBoxTarget(); + + SVGShapeImpl *getBBoxTarget() const; + void setBBoxTarget(SVGShapeImpl *target); + +protected: + SVGShapeImpl *m_target; +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGCSSRuleImpl.cc b/ksvg/impl/SVGCSSRuleImpl.cc new file mode 100644 index 00000000..991487e3 --- /dev/null +++ b/ksvg/impl/SVGCSSRuleImpl.cc @@ -0,0 +1,33 @@ +/* + 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 "SVGCSSRuleImpl.h" + +using namespace KSVG; + +SVGCSSRuleImpl::SVGCSSRuleImpl() : DOM::DomShared()//, css::CSSRule() +{ +} + +SVGCSSRuleImpl::~SVGCSSRuleImpl() +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGCSSRuleImpl.h b/ksvg/impl/SVGCSSRuleImpl.h new file mode 100644 index 00000000..03ab4e8b --- /dev/null +++ b/ksvg/impl/SVGCSSRuleImpl.h @@ -0,0 +1,42 @@ +/* + 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. +*/ + +#ifndef SVGCSSRuleImpl_H +#define SVGCSSRuleImpl_H + +#include <dom/dom_misc.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGCSSRuleImpl : public DOM::DomShared //, public css::CSSRule +{ +public: + SVGCSSRuleImpl(); + virtual ~SVGCSSRuleImpl(); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGCircleElementImpl.cc b/ksvg/impl/SVGCircleElementImpl.cc new file mode 100644 index 00000000..b6246d1a --- /dev/null +++ b/ksvg/impl/SVGCircleElementImpl.cc @@ -0,0 +1,178 @@ +/* + 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> +#include <klocale.h> + +#include "CanvasItem.h" +#include "KSVGCanvas.h" + +#include "SVGRectImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGCircleElementImpl.h" +#include "SVGAnimatedLengthImpl.h" + +using namespace KSVG; + +#include "SVGCircleElementImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" + +SVGCircleElementImpl::SVGCircleElementImpl(DOM::ElementImpl *impl) : SVGShapeImpl(impl), SVGTestsImpl(), SVGLangSpaceImpl(), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this), SVGTransformableImpl() +{ + KSVG_EMPTY_FLAGS + + m_cx = new SVGAnimatedLengthImpl(LENGTHMODE_WIDTH, this); + m_cx->ref(); + m_cx->baseVal()->setValueAsString("-1"); + + m_cy = new SVGAnimatedLengthImpl(LENGTHMODE_HEIGHT, this); + m_cy->ref(); + m_cy->baseVal()->setValueAsString("-1"); + + m_r = new SVGAnimatedLengthImpl(LENGTHMODE_OTHER, this); + m_r->ref(); + m_r->baseVal()->setValueAsString("-1"); +} + +SVGCircleElementImpl::~SVGCircleElementImpl() +{ + if(m_cx) + m_cx->deref(); + if(m_cy) + m_cy->deref(); + if(m_r) + m_r->deref(); +} + +SVGAnimatedLengthImpl *SVGCircleElementImpl::cx() +{ + return m_cx; +} + +SVGAnimatedLengthImpl *SVGCircleElementImpl::cy() +{ + return m_cy; +} + +SVGAnimatedLengthImpl *SVGCircleElementImpl::r() +{ + return m_r; +} + +/* +@namespace KSVG +@begin SVGCircleElementImpl::s_hashTable 5 + cx SVGCircleElementImpl::Cx DontDelete|ReadOnly + cy SVGCircleElementImpl::Cy DontDelete|ReadOnly + r SVGCircleElementImpl::R DontDelete|ReadOnly +@end +*/ + +Value SVGCircleElementImpl::getValueProperty(ExecState *exec, int token) const +{ + KSVG_CHECK_ATTRIBUTE + + switch(token) + { + case Cx: + if(!attributeMode) + return m_cx->cache(exec); + else + return Number(m_cx->baseVal()->value()); + case Cy: + if(!attributeMode) + return m_cy->cache(exec); + else + return Number(m_cy->baseVal()->value()); + case R: + if(!attributeMode) + return m_r->cache(exec); + else + return Number(m_r->baseVal()->value()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGCircleElementImpl::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; + + switch(token) + { + case Cx: + cx()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + case Cy: + cy()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + case R: + r()->baseVal()->setValueAsString(value.toString(exec).qstring()); + if(r()->baseVal()->value() < 0) // A negative value is an error + gotError(i18n("Negative value for attribute r of element <circle> is illegal")); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +SVGRectImpl *SVGCircleElementImpl::getBBox() +{ + SVGRectImpl *ret = SVGSVGElementImpl::createSVGRect(); + ret->setX(m_cx->baseVal()->value() - m_r->baseVal()->value()); + ret->setY(m_cy->baseVal()->value() - m_r->baseVal()->value()); + ret->setWidth(m_r->baseVal()->value() * 2.0); + ret->setHeight(m_r->baseVal()->value() * 2.0); + return ret; +} + +void SVGCircleElementImpl::setAttributes() +{ + SVGElementImpl::setAttributes(); + + // Spec: if not specified, effect is as if a value of "0" were specified + if(KSVG_TOKEN_NOT_PARSED(Cx)) + KSVG_SET_ALT_ATTRIBUTE(Cx, "0") + + // Spec: if not specified, effect is as if a value of "0" were specified + if(KSVG_TOKEN_NOT_PARSED(Cy)) + KSVG_SET_ALT_ATTRIBUTE(Cy, "0") +} + +void SVGCircleElementImpl::createItem(KSVGCanvas *c) +{ + if(!c) + c = ownerDoc()->canvas(); + + if(!m_item) + { + m_item = c->createCircle(this); + c->insert(m_item); + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGCircleElementImpl.h b/ksvg/impl/SVGCircleElementImpl.h new file mode 100644 index 00000000..29e0df3f --- /dev/null +++ b/ksvg/impl/SVGCircleElementImpl.h @@ -0,0 +1,84 @@ +/* + 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. +*/ + +#ifndef SVGCircleElementImpl_H +#define SVGCircleElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGShapeImpl.h" +#include "SVGTestsImpl.h" +#include "SVGStylableImpl.h" +#include "SVGLangSpaceImpl.h" +#include "SVGTransformableImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + +namespace KSVG +{ + +class SVGRectImpl; +class SVGAnimatedLengthImpl; +class SVGCircleElementImpl : public SVGShapeImpl, + public SVGTestsImpl, + public SVGLangSpaceImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl, + public SVGTransformableImpl +{ +public: + SVGCircleElementImpl(DOM::ElementImpl *); + virtual ~SVGCircleElementImpl(); + + SVGAnimatedLengthImpl *cx(); + SVGAnimatedLengthImpl *cy(); + SVGAnimatedLengthImpl *r(); + + virtual void createItem(KSVGCanvas *c = 0); + virtual void setAttributes(); + + virtual SVGRectImpl *getBBox(); + +private: + SVGAnimatedLengthImpl *m_cx; + SVGAnimatedLengthImpl *m_cy; + SVGAnimatedLengthImpl *m_r; + +public: + KSVG_GET + KSVG_PUT + KSVG_BRIDGE + + enum + { + // Properties + Cx, Cy, R + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +KSVG_REGISTER_ELEMENT(SVGCircleElementImpl, "circle") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGClipPathElementImpl.cc b/ksvg/impl/SVGClipPathElementImpl.cc new file mode 100644 index 00000000..87b4d4ac --- /dev/null +++ b/ksvg/impl/SVGClipPathElementImpl.cc @@ -0,0 +1,104 @@ +/* + 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 "SVGClipPathElement.h" +#include "SVGClipPathElementImpl.h" +#include "KSVGCanvas.h" +#include "SVGDocumentImpl.h" +#include "SVGAnimatedEnumerationImpl.h" + +using namespace KSVG; + +#include "SVGClipPathElementImpl.lut.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" + +SVGClipPathElementImpl::SVGClipPathElementImpl(DOM::ElementImpl *impl) : SVGContainerImpl(impl), SVGTestsImpl(), SVGLangSpaceImpl(), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this), SVGTransformableImpl(), SVGBBoxTarget() +{ + KSVG_EMPTY_FLAGS + + m_clipPathUnits = new SVGAnimatedEnumerationImpl(); + m_clipPathUnits->ref(); + m_clipPathUnits->setBaseVal(SVGClipPathElement::SVG_UNIT_TYPE_UNKNOWN); +} + +SVGClipPathElementImpl::~SVGClipPathElementImpl() +{ + if(m_clipPathUnits) + m_clipPathUnits->deref(); +} + +SVGAnimatedEnumerationImpl *SVGClipPathElementImpl::clipPathUnits() const +{ + return m_clipPathUnits; +} + +/* +@namespace KSVG +@begin SVGClipPathElementImpl::s_hashTable 2 + clipPathUnits SVGClipPathElementImpl::ClipPathUnits DontDelete|ReadOnly +@end +*/ + +Value SVGClipPathElementImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case ClipPathUnits: + return m_clipPathUnits->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGClipPathElementImpl::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; + + switch(token) + { + case ClipPathUnits: + if(value.toString(exec).qstring() == "objectBoundingBox") + m_clipPathUnits->setBaseVal(SVGClipPathElement::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX); + else + m_clipPathUnits->setBaseVal(SVGClipPathElement::SVG_UNIT_TYPE_USERSPACEONUSE); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +void SVGClipPathElementImpl::setAttributes() +{ + SVGElementImpl::setAttributes(); + + // Spec: if attribute not specified, use userSpaceOnUse + if(KSVG_TOKEN_NOT_PARSED(ClipPathUnits)) + KSVG_SET_ALT_ATTRIBUTE(ClipPathUnits, "userSpaceOnUse") + + if(!m_item) + m_item = ownerDoc()->canvas()->createClipPath(this); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGClipPathElementImpl.h b/ksvg/impl/SVGClipPathElementImpl.h new file mode 100644 index 00000000..1e1879a9 --- /dev/null +++ b/ksvg/impl/SVGClipPathElementImpl.h @@ -0,0 +1,80 @@ +/* + 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. +*/ + +#ifndef SVGClipPathElementImpl_H +#define SVGClipPathElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGTestsImpl.h" +#include "SVGBBoxTarget.h" +#include "SVGStylableImpl.h" +#include "SVGLangSpaceImpl.h" +#include "SVGContainerImpl.h" +#include "SVGTransformableImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + +namespace KSVG +{ + +class SVGAnimatedEnumerationImpl; +class SVGClipPathElementImpl : public SVGContainerImpl, + public SVGTestsImpl, + public SVGLangSpaceImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl, + public SVGTransformableImpl, + public SVGBBoxTarget +{ +public: + SVGClipPathElementImpl(DOM::ElementImpl *); + virtual ~SVGClipPathElementImpl(); + + SVGAnimatedEnumerationImpl *clipPathUnits() const; + + virtual void setAttributes(); + + virtual bool directRender() { return false; } + +private: + SVGAnimatedEnumerationImpl *m_clipPathUnits; + +public: + KSVG_GET + KSVG_PUT + KSVG_BRIDGE + + enum + { + // Properties + ClipPathUnits + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +KSVG_REGISTER_ELEMENT(SVGClipPathElementImpl, "clipPath") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGColorImpl.cc b/ksvg/impl/SVGColorImpl.cc new file mode 100644 index 00000000..a01e1113 --- /dev/null +++ b/ksvg/impl/SVGColorImpl.cc @@ -0,0 +1,540 @@ +/* + 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> + +#include <qstringlist.h> + +#include "SVGColor.h" + +#include "SVGColorImpl.h" +#include "SVGNumberImpl.h" +#include "SVGICCColorImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGNumberListImpl.h" +#include "SVGURIReferenceImpl.h" +#include "SVGColorProfileElementImpl.h" + +using namespace KSVG; + +#include "SVGColorImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_cacheimpl.h" + +SVGColorImpl::SVGColorImpl(SVGElementImpl *object) : m_object(object) +{ + m_colorType = SVG_COLORTYPE_UNKNOWN; + m_iccColor = 0; +} + +SVGColorImpl::SVGColorImpl(const SVGColorImpl &other) : DOM::DomShared() +{ + (*this) = other; +} + +SVGColorImpl::~SVGColorImpl() +{ + if(m_iccColor) + m_iccColor->deref(); +} + +SVGColorImpl &SVGColorImpl::operator=(const SVGColorImpl &other) +{ + m_colorType = other.m_colorType; + m_rgbColor = other.m_rgbColor; + + if(m_iccColor && other.m_iccColor) + *m_iccColor = *(other.m_iccColor); + + return *this; +} + +unsigned short SVGColorImpl::colorType() const +{ + return m_colorType; +} + +DOM::RGBColor SVGColorImpl::rgbColor() const +{ + return m_rgbColor; +} + +SVGICCColorImpl *SVGColorImpl::iccColor() const +{ + return m_iccColor; +} + +void SVGColorImpl::setRGBColor(QColor color) +{ + m_colorType = SVG_COLORTYPE_RGBCOLOR; + m_rgbColor = DOM::RGBColor(color.rgb()); +} + +void SVGColorImpl::setRGBColor(int r, int g, int b) +{ + m_colorType = SVG_COLORTYPE_RGBCOLOR; + m_rgbColor = DOM::RGBColor(QColor(r, g, b).rgb()); +} + +void SVGColorImpl::setRGBColor(const DOM::DOMString &rgbColor) +{ + if(rgbColor == "aliceblue") + setRGBColor(240, 248, 255); + else if(rgbColor == "antiquewhite") + setRGBColor(250, 235, 215); + else if(rgbColor == "aqua") + setRGBColor(0, 255, 255); + else if(rgbColor == "aquamarine") + setRGBColor(127, 255, 212); + else if(rgbColor == "azure") + setRGBColor(240, 255, 255); + else if(rgbColor == "beige") + setRGBColor(245, 245, 220); + else if(rgbColor == "bisque") + setRGBColor(255, 228, 196); + else if(rgbColor == "black") + setRGBColor(0, 0, 0); + else if(rgbColor == "blanchedalmond") + setRGBColor(255, 235, 205); + else if(rgbColor == "blue") + setRGBColor(0, 0, 255); + else if(rgbColor == "blueviolet") + setRGBColor(138, 43, 226); + else if(rgbColor == "brown") + setRGBColor(165, 42, 42); + else if(rgbColor == "burlywood") + setRGBColor(222, 184, 135); + else if(rgbColor == "cadetblue") + setRGBColor(95, 158, 160); + else if(rgbColor == "chartreuse") + setRGBColor(127, 255, 0); + else if(rgbColor == "chocolate") + setRGBColor(210, 105, 30); + else if(rgbColor == "coral") + setRGBColor(255, 127, 80); + else if(rgbColor == "cornflowerblue") + setRGBColor(100, 149, 237); + else if(rgbColor == "cornsilk") + setRGBColor(255, 248, 220); + else if(rgbColor == "crimson") + setRGBColor(220, 20, 60); + else if(rgbColor == "cyan") + setRGBColor(0, 255, 255); + else if(rgbColor == "darkblue") + setRGBColor(0, 0, 139); + else if(rgbColor == "darkcyan") + setRGBColor(0, 139, 139); + else if(rgbColor == "darkgoldenrod") + setRGBColor(184, 134, 11); + else if(rgbColor == "darkgray") + setRGBColor(169, 169, 169); + else if(rgbColor == "darkgrey") + setRGBColor(169, 169, 169); + else if(rgbColor == "darkgreen") + setRGBColor(0, 100, 0); + else if(rgbColor == "darkkhaki") + setRGBColor(189, 183, 107); + else if(rgbColor == "darkmagenta") + setRGBColor(139, 0, 139); + else if(rgbColor == "darkolivegreen") + setRGBColor(85, 107, 47); + else if(rgbColor == "darkorange") + setRGBColor(255, 140, 0); + else if(rgbColor == "darkorchid") + setRGBColor(153, 50, 204); + else if(rgbColor == "darkred") + setRGBColor(139, 0, 0); + else if(rgbColor == "darksalmon") + setRGBColor(233, 150, 122); + else if(rgbColor == "darkseagreen") + setRGBColor(143, 188, 143); + else if(rgbColor == "darkslateblue") + setRGBColor(72, 61, 139); + else if(rgbColor == "darkslategray") + setRGBColor(47, 79, 79); + else if(rgbColor == "darkslategrey") + setRGBColor(47, 79, 79); + else if(rgbColor == "darkturquoise") + setRGBColor(0, 206, 209); + else if(rgbColor == "darkviolet") + setRGBColor(148, 0, 211); + else if(rgbColor == "deeppink") + setRGBColor(255, 20, 147); + else if(rgbColor == "deepskyblue") + setRGBColor(0, 191, 255); + else if(rgbColor == "dimgray") + setRGBColor(105, 105, 105); + else if(rgbColor == "dimgrey") + setRGBColor(105, 105, 105); + else if(rgbColor == "dodgerblue") + setRGBColor(30, 144, 255); + else if(rgbColor == "firebrick") + setRGBColor(178, 34, 34); + else if(rgbColor == "floralwhite") + setRGBColor(255, 250, 240); + else if(rgbColor == "forestgreen") + setRGBColor(34, 139, 34); + else if(rgbColor == "fuchsia") + setRGBColor(255, 0, 255); + else if(rgbColor == "gainsboro") + setRGBColor(220, 220, 220); + else if(rgbColor == "ghostwhite") + setRGBColor(248, 248, 255); + else if(rgbColor == "gold") + setRGBColor(255, 215, 0); + else if(rgbColor == "goldenrod") + setRGBColor(218, 165, 32); + else if(rgbColor == "gray") + setRGBColor(128, 128, 128); + else if(rgbColor == "grey") + setRGBColor(128, 128, 128); + else if(rgbColor == "green") + setRGBColor(0, 128, 0); + else if(rgbColor == "greenyellow") + setRGBColor(173, 255, 47); + else if(rgbColor == "honeydew") + setRGBColor(240, 255, 240); + else if(rgbColor == "hotpink") + setRGBColor(255, 105, 180); + else if(rgbColor == "indianred") + setRGBColor(205, 92, 92); + else if(rgbColor == "indigo") + setRGBColor(75, 0, 130); + else if(rgbColor == "ivory") + setRGBColor(255, 255, 240); + else if(rgbColor == "khaki") + setRGBColor(240, 230, 140); + else if(rgbColor == "lavender") + setRGBColor(230, 230, 250); + else if(rgbColor == "lavenderblush") + setRGBColor(255, 240, 245); + else if(rgbColor == "lawngreen") + setRGBColor(124, 252, 0); + else if(rgbColor == "lemonchiffon") + setRGBColor(255, 250, 205); + else if(rgbColor == "lightblue") + setRGBColor(173, 216, 230); + else if(rgbColor == "lightcoral") + setRGBColor(240, 128, 128); + else if(rgbColor == "lightcyan") + setRGBColor(224, 255, 255); + else if(rgbColor == "lightgoldenrodyellow") + setRGBColor(250, 250, 210); + else if(rgbColor == "lightgray") + setRGBColor(211, 211, 211); + else if(rgbColor == "lightgrey") + setRGBColor(211, 211, 211); + else if(rgbColor == "lightgreen") + setRGBColor(144, 238, 144); + else if(rgbColor == "lightpink") + setRGBColor(255, 182, 193); + else if(rgbColor == "lightsalmon") + setRGBColor(255, 160, 122); + else if(rgbColor == "lightseagreen") + setRGBColor(32, 178, 170); + else if(rgbColor == "lightskyblue") + setRGBColor(135, 206, 250); + else if(rgbColor == "lightslategray") + setRGBColor(119, 136, 153); + else if(rgbColor == "lightslategrey") + setRGBColor(119, 136, 153); + else if(rgbColor == "lightsteelblue") + setRGBColor(176, 196, 222); + else if(rgbColor == "lightyellow") + setRGBColor(255, 255, 224); + else if(rgbColor == "lime") + setRGBColor(0, 255, 0); + else if(rgbColor == "limegreen") + setRGBColor(50, 205, 50); + else if(rgbColor == "linen") + setRGBColor(250, 240, 230); + else if(rgbColor == "magenta") + setRGBColor(255, 0, 255); + else if(rgbColor == "maroon") + setRGBColor(128, 0, 0); + else if(rgbColor == "mediumaquamarine") + setRGBColor(102, 205, 170); + else if(rgbColor == "mediumblue") + setRGBColor(0, 0, 205); + else if(rgbColor == "mediumorchid") + setRGBColor(186, 85, 211); + else if(rgbColor == "mediumpurple") + setRGBColor(147, 112, 219); + else if(rgbColor == "mediumseagreen") + setRGBColor(60, 179, 113); + else if(rgbColor == "mediumslateblue") + setRGBColor(123, 104, 238); + else if(rgbColor == "mediumspringgreen") + setRGBColor(0, 250, 154); + else if(rgbColor == "mediumturquoise") + setRGBColor(72, 209, 204); + else if(rgbColor == "mediumvioletred") + setRGBColor(199, 21, 133); + else if(rgbColor == "midnightblue") + setRGBColor(25, 25, 112); + else if(rgbColor == "mintcream") + setRGBColor(245, 255, 250); + else if(rgbColor == "mistyrose") + setRGBColor(255, 228, 225); + else if(rgbColor == "moccasin") + setRGBColor(255, 228, 181); + else if(rgbColor == "navajowhite") + setRGBColor(255, 222, 173); + else if(rgbColor == "navy") + setRGBColor(0, 0, 128); + else if(rgbColor == "oldlace") + setRGBColor(253, 245, 230); + else if(rgbColor == "olive") + setRGBColor(128, 128, 0); + else if(rgbColor == "olivedrab") + setRGBColor(107, 142, 35); + else if(rgbColor == "orange") + setRGBColor(255, 165, 0); + else if(rgbColor == "orangered") + setRGBColor(255, 69, 0); + else if(rgbColor == "orchid") + setRGBColor(218, 112, 214); + else if(rgbColor == "palegoldenrod") + setRGBColor(238, 232, 170); + else if(rgbColor == "palegreen") + setRGBColor(152, 251, 152); + else if(rgbColor == "paleturquoise") + setRGBColor(175, 238, 238); + else if(rgbColor == "palevioletred") + setRGBColor(219, 112, 147); + else if(rgbColor == "papayawhip") + setRGBColor(255, 239, 213); + else if(rgbColor == "peachpuff") + setRGBColor(255, 218, 185); + else if(rgbColor == "peru") + setRGBColor(205, 133, 63); + else if(rgbColor == "pink") + setRGBColor(255, 192, 203); + else if(rgbColor == "plum") + setRGBColor(221, 160, 221); + else if(rgbColor == "powderblue") + setRGBColor(176, 224, 230); + else if(rgbColor == "purple") + setRGBColor(128, 0, 128); + else if(rgbColor == "red") + setRGBColor(255, 0, 0); + else if(rgbColor == "rosybrown") + setRGBColor(188, 143, 143); + else if(rgbColor == "royalblue") + setRGBColor(65, 105, 225); + else if(rgbColor == "saddlebrown") + setRGBColor(139, 69, 19); + else if(rgbColor == "salmon") + setRGBColor(250, 128, 114); + else if(rgbColor == "sandybrown") + setRGBColor(244, 164, 96); + else if(rgbColor == "seagreen") + setRGBColor(46, 139, 87); + else if(rgbColor == "seashell") + setRGBColor(255, 245, 238); + else if(rgbColor == "sienna") + setRGBColor(160, 82, 45); + else if(rgbColor == "silver") + setRGBColor(192, 192, 192); + else if(rgbColor == "skyblue") + setRGBColor(135, 206, 235); + else if(rgbColor == "slateblue") + setRGBColor(106, 90, 205); + else if(rgbColor == "slategray") + setRGBColor(112, 128, 144); + else if(rgbColor == "slategrey") + setRGBColor(112, 128, 144); + else if(rgbColor == "snow") + setRGBColor(255, 250, 250); + else if(rgbColor == "springgreen") + setRGBColor(0, 255, 127); + else if(rgbColor == "steelblue") + setRGBColor(70, 130, 180); + else if(rgbColor == "tan") + setRGBColor(210, 180, 140); + else if(rgbColor == "teal") + setRGBColor(0, 128, 128); + else if(rgbColor == "thistle") + setRGBColor(216, 191, 216); + else if(rgbColor == "tomato") + setRGBColor(255, 99, 71); + else if(rgbColor == "turquoise") + setRGBColor(64, 224, 208); + else if(rgbColor == "violet") + setRGBColor(238, 130, 238); + else if(rgbColor == "wheat") + setRGBColor(245, 222, 179); + else if(rgbColor == "white") + setRGBColor(255, 255, 255); + else if(rgbColor == "whitesmoke") + setRGBColor(245, 245, 245); + else if(rgbColor == "yellow") + setRGBColor(255, 255, 0); + else if(rgbColor == "yellowgreen") + setRGBColor(154, 205, 50); +} + +void SVGColorImpl::setRGBColorICCColor(const DOM::DOMString &rgbColor, const DOM::DOMString &iccColor) +{ + QColor color; + + QString content = iccColor.string().right(iccColor.string().length() - 10); + QString iccTarget = content.mid(0, content.find(',')); + + QStringList colors = QStringList::split(',', content); + QString r = colors[1]; + QString g = colors[2]; + QString b = colors[3].left(colors[3].length() - 1); + + iccTarget = SVGURIReferenceImpl::getTarget(iccTarget); + + SVGColorProfileElementImpl *handle = 0; + if(m_object) + handle = static_cast<SVGColorProfileElementImpl *>(dynamic_cast<SVGElementImpl *>(m_object)->ownerDoc()->rootElement()->getElementById(iccTarget)); + + if(iccTarget.isEmpty() || !handle) + { + color.setNamedColor(rgbColor.string().stripWhiteSpace()); + setRGBColor(color); + } + else + { + color.setRgb(handle->correctPixel(r.toFloat() * 257, g.toFloat() * 257, b.toFloat() * 257)); + setRGBColor(color); + + m_colorType = SVG_COLORTYPE_RGBCOLOR_ICCCOLOR; + + if(!m_iccColor) + { + m_iccColor = new SVGICCColorImpl(); + m_iccColor->ref(); + } + + m_iccColor->setColorProfile(DOM::DOMString(content)); + + SVGNumberImpl *rnumber = SVGSVGElementImpl::createSVGNumber(); + rnumber->setValue(r.toFloat()); + + SVGNumberImpl *gnumber = SVGSVGElementImpl::createSVGNumber(); + gnumber->setValue(g.toFloat()); + + SVGNumberImpl *bnumber = SVGSVGElementImpl::createSVGNumber(); + bnumber->setValue(b.toFloat()); + + m_iccColor->colors()->clear(); + m_iccColor->colors()->appendItem(bnumber); + m_iccColor->colors()->appendItem(gnumber); + m_iccColor->colors()->appendItem(rnumber); + } +} + +void SVGColorImpl::setColor(unsigned short colorType, const DOM::DOMString &rgbColor, const DOM::DOMString &iccColor) +{ + m_colorType = colorType; + + if(m_colorType == SVG_COLORTYPE_UNKNOWN || m_colorType == SVG_COLORTYPE_CURRENTCOLOR) + return; + + setRGBColorICCColor(rgbColor, iccColor); +} + +// Ecma stuff +/* +@namespace KSVG +@begin SVGColorImpl::s_hashTable 5 + colorType SVGColorImpl::ColorType DontDelete|ReadOnly + RGBColor SVGColorImpl::RGBColor DontDelete|ReadOnly + ICCColor SVGColorImpl::ICCColor DontDelete|ReadOnly +@end +@namespace KSVG +@begin SVGColorImplProto::s_hashTable 5 + setRGBColor SVGColorImpl::SetRGBColor DontDelete|Function 1 + setRGBColorICCColor SVGColorImpl::SetRGBColorICCColor DontDelete|Function 2 + setColor SVGColorImpl::SetColor DontDelete|Function 3 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGColor", SVGColorImplProto, SVGColorImplProtoFunc) + +Value SVGColorImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case ColorType: + return Number(colorType()); +#ifdef __GNUC__ +#warning FIXME bridge stuff +#endif + case RGBColor: + return Undefined(); + case ICCColor: + return m_iccColor->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +Value SVGColorImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGColorImpl) + + switch(id) + { + case SVGColorImpl::SetRGBColor: + obj->setRGBColor(args[0].toString(exec).string()); + break; + case SVGColorImpl::SetRGBColorICCColor: + obj->setRGBColorICCColor(args[0].toString(exec).string(), args[1].toString(exec).string()); + break; + case SVGColorImpl::SetColor: + obj->setColor(static_cast<unsigned short>(args[0].toNumber(exec)), args[1].toString(exec).string(), args[2].toString(exec).string()); + break; + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return Undefined(); +} + +/* +@namespace KSVG +@begin SVGColorImplConstructor::s_hashTable 5 + SVG_COLORTYPE_UNKNOWN KSVG::SVG_COLORTYPE_UNKNOWN DontDelete|ReadOnly + SVG_COLORTYPE_RGBCOLOR KSVG::SVG_COLORTYPE_RGBCOLOR DontDelete|ReadOnly + SVG_COLORTYPE_RGBCOLOR_ICCCOLOR KSVG::SVG_COLORTYPE_RGBCOLOR_ICCCOLOR DontDelete|ReadOnly + SVG_COLORTYPE_CURRENTCOLOR KSVG::SVG_COLORTYPE_CURRENTCOLOR DontDelete|ReadOnly +@end +*/ + +Value SVGColorImplConstructor::getValueProperty(ExecState *, int token) const +{ + return Number(token); +} + +Value KSVG::getSVGColorImplConstructor(ExecState *exec) +{ + return cacheGlobalBridge<SVGColorImplConstructor>(exec, "[[svgcolor.constructor]]"); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGColorImpl.h b/ksvg/impl/SVGColorImpl.h new file mode 100644 index 00000000..d49c6f82 --- /dev/null +++ b/ksvg/impl/SVGColorImpl.h @@ -0,0 +1,94 @@ +/* + 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. +*/ + +#ifndef SVGColorImpl_H +#define SVGColorImpl_H + +#include <dom/dom_misc.h> +#include <dom/css_value.h> +#include <dom/dom_string.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ +class SVGElementImpl; +class SVGICCColorImpl; +class SVGColorImpl : public DOM::DomShared +{ +public: + SVGColorImpl(SVGElementImpl *object); + SVGColorImpl(const SVGColorImpl &); + virtual ~SVGColorImpl(); + + SVGColorImpl &operator=(const SVGColorImpl &); + + unsigned short colorType() const; + + DOM::RGBColor rgbColor() const; + SVGICCColorImpl *iccColor() const; + + virtual void setRGBColor(const DOM::DOMString &rgbColor); + virtual void setRGBColor(int r, int g, int b); + virtual void setRGBColor(QColor color); + virtual void setRGBColorICCColor(const DOM::DOMString &rgbColor, const DOM::DOMString &iccColor); + virtual void setColor(unsigned short colorType, const DOM::DOMString &rgbColor, const DOM::DOMString &iccColor); + +private: + unsigned short m_colorType; + DOM::RGBColor m_rgbColor; + SVGICCColorImpl *m_iccColor; + SVGElementImpl *m_object; + +public: + KSVG_BASECLASS_GET + + enum + { + // Properties + ColorType, RGBColor, ICCColor, + // Functions + SetRGBColor, SetRGBColorICCColor, SetColor + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +class SVGColorImplConstructor : public KJS::ObjectImp +{ +public: + SVGColorImplConstructor(KJS::ExecState *) { } + KJS::Value getValueProperty(KJS::ExecState *, int token) const; + + // no put - all read-only + KSVG_GET +}; + +KJS::Value getSVGColorImplConstructor(KJS::ExecState *exec); + +} + +KSVG_DEFINE_PROTOTYPE(SVGColorImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGColorImplProtoFunc, SVGColorImpl) + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGColorProfileElementImpl.cc b/ksvg/impl/SVGColorProfileElementImpl.cc new file mode 100644 index 00000000..f898188b --- /dev/null +++ b/ksvg/impl/SVGColorProfileElementImpl.cc @@ -0,0 +1,271 @@ +/* + 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 <kurl.h> +#include <kdebug.h> +#include <kio/netaccess.h> + +#include <qimage.h> + +#include "SVGDocumentImpl.h" +#include "SVGSVGElementImpl.h" + +#include "SVGRenderingIntent.h" + +#include "SVGAnimatedStringImpl.h" +#include "SVGColorProfileElementImpl.h" + +using namespace KSVG; + +#include "SVGColorProfileElementImpl.lut.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" + +SVGColorProfileElementImpl::SVGColorProfileElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGURIReferenceImpl() +{ + KSVG_EMPTY_FLAGS + + m_loaded = false; + + // Spec: Default value 'auto', if not overwritten later + m_renderingIntent = RENDERING_INTENT_AUTO; +} + +SVGColorProfileElementImpl::~SVGColorProfileElementImpl() +{ + if(m_loaded) + closeColorProfile(); +} + +/* +@namespace KSVG +@begin SVGColorProfileElementImpl::s_hashTable 5 + name SVGColorProfileElementImpl::Name DontDelete|ReadOnly + href SVGColorProfileElementImpl::Href DontDelete|ReadOnly + rendering-intent SVGColorProfileElementImpl::RenderingIntent DontDelete|ReadOnly +@end +*/ + +Value SVGColorProfileElementImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case Name: + return String(m_name); + case Href: + return href()->cache(exec); + case RenderingIntent: + return Number(m_renderingIntent); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGColorProfileElementImpl::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; + + switch(token) + { + case Name: + m_name = value.toString(exec).string(); + ownerDoc()->rootElement()->addToIdMap(m_name.string(), this); + break; + case Href: + href()->setBaseVal(value.toString(exec).string()); + break; + case RenderingIntent: + { + QString compare = value.toString(exec).qstring().lower(); + + if(compare == "perceptual") + m_renderingIntent = RENDERING_INTENT_PERCEPTUAL; + else if(compare == "relative-colorimetric") + m_renderingIntent = RENDERING_INTENT_RELATIVE_COLORIMETRIC; + else if(compare == "saturation") + m_renderingIntent = RENDERING_INTENT_SATURATION; + else if(compare == "absolute-colorimetric") + m_renderingIntent = RENDERING_INTENT_ABSOLUTE_COLORIMETRIC; + else + m_renderingIntent = RENDERING_INTENT_AUTO; + break; + } + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +void SVGColorProfileElementImpl::setLocal(const DOM::DOMString &local) +{ + m_local = local; +} + +DOM::DOMString SVGColorProfileElementImpl::local() const +{ + return m_local; +} + +void SVGColorProfileElementImpl::setName(const DOM::DOMString &name) +{ + m_name = name; +} + +DOM::DOMString SVGColorProfileElementImpl::name() const +{ + return m_name; +} + +void SVGColorProfileElementImpl::setRenderingIntent(unsigned short renderingIntent) +{ + m_renderingIntent = renderingIntent; +} + +unsigned short SVGColorProfileElementImpl::renderingIntent() const +{ + return m_renderingIntent; +} + +bool SVGColorProfileElementImpl::canLoad() +{ + QString open; + bool temp; + return canLoad(false, temp, open, true); +} + +bool SVGColorProfileElementImpl::canLoad(bool remote, bool &tempFile, QString &open, bool verbose) +{ + KURL file; + + if(!KURL::isRelativeURL(href()->baseVal().string())) + file = KURL(href()->baseVal().string()); + else + file = KURL(ownerDoc()->baseUrl(), href()->baseVal().string()); + + if(file.path().isEmpty()) + { + if(verbose) + kdDebug() << "Couldn't load color profile " << file.path() << "!" << endl; + + return false; + } + + if(file.isLocalFile()) + { + open = file.path(); + + if(!QFile::exists(open)) + { + if(verbose) + kdDebug() << "Couldn't load color profile " << file.path() << "! It does not exist." << endl; + + return false; + } + } + else + { + if(remote) + { + if(KIO::NetAccess::download(file, open, 0)) + tempFile = true; + } + } + + return true; +} + +bool SVGColorProfileElementImpl::loadColorProfile() +{ + QString open; + bool tempFile = false; + + if(!canLoad(true, tempFile, open, false)) + return false; + + m_hInput = cmsOpenProfileFromFile(open.latin1(), "r"); + m_hOutput = cmsCreate_sRGBProfile(); + + unsigned int dwIn = BYTES_SH(2) | CHANNELS_SH(_cmsChannelsOf(m_inputColorSpace)); + unsigned int dwOut = BYTES_SH(2) | CHANNELS_SH(_cmsChannelsOf(m_outputColorSpace)); + + if(m_renderingIntent != RENDERING_INTENT_AUTO) + m_hTrans = cmsCreateTransform(m_hInput, dwIn, m_hOutput, dwOut, m_renderingIntent - 2, cmsFLAGS_NOTPRECALC); + else + m_hTrans = cmsCreateTransform(m_hInput, dwIn, m_hOutput, dwOut, cmsTakeRenderingIntent(m_hInput), cmsFLAGS_NOTPRECALC); + + m_inputColorSpace = cmsGetColorSpace(m_hInput); + m_outputColorSpace = cmsGetColorSpace(m_hOutput); + m_loaded = true; + + if(tempFile) + KIO::NetAccess::removeTempFile(open); + + return true; +} + +void SVGColorProfileElementImpl::closeColorProfile() +{ + cmsDeleteTransform(m_hTrans); + cmsCloseProfile(m_hInput); +} + +QRgb SVGColorProfileElementImpl::correctPixel(float r, float g, float b) +{ + if(!m_loaded) + { + if(!loadColorProfile()) + return qRgb(0, 0, 0); + } + + unsigned short input[MAXCHANNELS], output[MAXCHANNELS]; + + input[0] = ((unsigned int) r) * 257; + input[1] = ((unsigned int) g) * 257; + input[2] = ((unsigned int) b) * 257; + + cmsDoTransform(m_hTrans, input, output, 1); + + if(m_outputColorSpace == icSigRgbData) + return qRgb(output[0] / 257, output[1] / 257, output[2] / 257); + + return qRgb(0, 0, 0); +} + +QImage *SVGColorProfileElementImpl::correctImage(QImage *input) +{ + if(!canLoad()) + return input; + + for(int y = 0; y < input->height(); y++) + { + for(int x = 0; x < input->width(); x++) + { + QRgb pixel = input->pixel(x, y); + input->setPixel(x, y, correctPixel(qRed(pixel), qGreen(pixel), qBlue(pixel))); + } + } + + return input; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGColorProfileElementImpl.h b/ksvg/impl/SVGColorProfileElementImpl.h new file mode 100644 index 00000000..2f735f03 --- /dev/null +++ b/ksvg/impl/SVGColorProfileElementImpl.h @@ -0,0 +1,100 @@ +/* + 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. +*/ + +#ifndef SVGColorProfileElementImpl_H +#define SVGColorProfileElementImpl_H + +#include <dom/dom_string.h> + +// Provided by configure checks.... +#include <config.h> +#undef QT_VERSION // Needed for 1.08 *grml* +#include LCMS_HEADER + +#include "SVGElementImpl.h" +#include "SVGURIReferenceImpl.h" + +#include "ksvg_lookup.h" + +class QImage; + +namespace KSVG +{ + +class SVGColorProfileElementImpl : public SVGElementImpl, + public SVGURIReferenceImpl +{ +public: + SVGColorProfileElementImpl(DOM::ElementImpl *); + virtual ~SVGColorProfileElementImpl(); + + void setLocal(const DOM::DOMString &local); + DOM::DOMString local() const; + + void setName(const DOM::DOMString &name); + DOM::DOMString name() const; + + void setRenderingIntent(unsigned short renderingIntent); + unsigned short renderingIntent() const; + + QImage *correctImage(QImage *input); + QRgb correctPixel(float r, float g, float b); + +private: + bool loadColorProfile(); + void closeColorProfile(); + + bool canLoad(); + bool canLoad(bool remote, bool &tempFile, QString &open, bool verbose); + + DOM::DOMString m_local; + DOM::DOMString m_name; + unsigned short m_renderingIntent; + + bool m_loaded; + + cmsHPROFILE m_hInput, m_hOutput; + cmsHTRANSFORM m_hTrans; + int m_intent; + + icColorSpaceSignature m_inputColorSpace, m_outputColorSpace; + +public: + KSVG_GET + KSVG_PUT + KSVG_BRIDGE + + enum + { + // Properties + Name, Href, RenderingIntent + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +KSVG_REGISTER_ELEMENT(SVGColorProfileElementImpl, "color-profile") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGColorProfileRuleImpl.cc b/ksvg/impl/SVGColorProfileRuleImpl.cc new file mode 100644 index 00000000..3cfca560 --- /dev/null +++ b/ksvg/impl/SVGColorProfileRuleImpl.cc @@ -0,0 +1,63 @@ +/* + 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 "SVGColorProfileRuleImpl.h" + +using namespace KSVG; + +SVGColorProfileRuleImpl::SVGColorProfileRuleImpl() : SVGCSSRuleImpl() +{ +} + +SVGColorProfileRuleImpl::~SVGColorProfileRuleImpl() +{ +} + +void SVGColorProfileRuleImpl::setSrc(const DOM::DOMString &src) +{ + m_src = src; +} + +DOM::DOMString SVGColorProfileRuleImpl::src() const +{ + return m_src; +} + +void SVGColorProfileRuleImpl::setName(const DOM::DOMString &name) +{ + m_name = name; +} + +DOM::DOMString SVGColorProfileRuleImpl::name() const +{ + return m_name; +} + +void SVGColorProfileRuleImpl::setRenderingIntent(unsigned short renderingIntent) +{ + m_renderingIntent = renderingIntent; +} + +unsigned short SVGColorProfileRuleImpl::renderingIntent() const +{ + return m_renderingIntent; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGColorProfileRuleImpl.h b/ksvg/impl/SVGColorProfileRuleImpl.h new file mode 100644 index 00000000..976a76a8 --- /dev/null +++ b/ksvg/impl/SVGColorProfileRuleImpl.h @@ -0,0 +1,58 @@ +/* + 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. +*/ + +#ifndef SVGColorProfileRuleImpl_H +#define SVGColorProfileRuleImpl_H + +#include <dom/dom_string.h> + +#include "SVGCSSRuleImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGColorProfileRuleImpl : public SVGCSSRuleImpl +{ +public: + SVGColorProfileRuleImpl(); + virtual ~SVGColorProfileRuleImpl(); + + void setSrc(const DOM::DOMString &src); + DOM::DOMString src() const; + + void setName(const DOM::DOMString &name); + DOM::DOMString name() const; + + void setRenderingIntent(unsigned short renderingIntent); + unsigned short renderingIntent() const; + +private: + DOM::DOMString m_src; + DOM::DOMString m_name; + unsigned short m_renderingIntent; +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGComponentTransferFunctionElementImpl.cc b/ksvg/impl/SVGComponentTransferFunctionElementImpl.cc new file mode 100644 index 00000000..0db14aae --- /dev/null +++ b/ksvg/impl/SVGComponentTransferFunctionElementImpl.cc @@ -0,0 +1,105 @@ +/* + 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 "SVGAnimatedNumberImpl.h" +#include "SVGAnimatedNumberListImpl.h" +#include "SVGAnimatedEnumerationImpl.h" +#include "SVGComponentTransferFunctionElementImpl.h" + +using namespace KSVG; + +SVGComponentTransferFunctionElementImpl::SVGComponentTransferFunctionElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl) +{ + m_type = new SVGAnimatedEnumerationImpl(); + m_type->ref(); + + m_tableValues = new SVGAnimatedNumberListImpl(); + m_tableValues->ref(); + + m_slope = new SVGAnimatedNumberImpl(); + m_slope->ref(); + + m_intercept = new SVGAnimatedNumberImpl(); + m_intercept->ref(); + + m_amplitude = new SVGAnimatedNumberImpl(); + m_amplitude->ref(); + + m_exponent = new SVGAnimatedNumberImpl(); + m_exponent->ref(); + + m_offset = new SVGAnimatedNumberImpl(); + m_offset->ref(); +} + +SVGComponentTransferFunctionElementImpl::~SVGComponentTransferFunctionElementImpl() +{ + if(m_type) + m_type->deref(); + if(m_tableValues) + m_tableValues->deref(); + if(m_slope) + m_slope->deref(); + if(m_intercept) + m_intercept->deref(); + if(m_amplitude) + m_amplitude->deref(); + if(m_exponent) + m_exponent->deref(); + if(m_offset) + m_offset->deref(); +} + +SVGAnimatedEnumerationImpl *SVGComponentTransferFunctionElementImpl::type() const +{ + return m_type; +} + +SVGAnimatedNumberListImpl *SVGComponentTransferFunctionElementImpl::tableValues() const +{ + return m_tableValues; +} + +SVGAnimatedNumberImpl *SVGComponentTransferFunctionElementImpl::slope() const +{ + return m_slope; +} + +SVGAnimatedNumberImpl *SVGComponentTransferFunctionElementImpl::intercept() const +{ + return m_intercept; +} + +SVGAnimatedNumberImpl *SVGComponentTransferFunctionElementImpl::amplitude() const +{ + return m_amplitude; +} + +SVGAnimatedNumberImpl *SVGComponentTransferFunctionElementImpl::exponent() const +{ + return m_exponent; +} + +SVGAnimatedNumberImpl *SVGComponentTransferFunctionElementImpl::offset() const +{ + return m_offset; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGComponentTransferFunctionElementImpl.h b/ksvg/impl/SVGComponentTransferFunctionElementImpl.h new file mode 100644 index 00000000..e277d462 --- /dev/null +++ b/ksvg/impl/SVGComponentTransferFunctionElementImpl.h @@ -0,0 +1,66 @@ +/* + 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. +*/ + +#ifndef SVGComponentTransferFunctionElementImpl_H +#define SVGComponentTransferFunctionElementImpl_H + +#include "SVGElementImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedNumberImpl; +class SVGAnimatedNumberListImpl; +class SVGAnimatedEnumerationImpl; +class SVGComponentTransferFunctionElementImpl : public SVGElementImpl +{ +public: + SVGComponentTransferFunctionElementImpl(DOM::ElementImpl *); + virtual ~SVGComponentTransferFunctionElementImpl(); + + SVGAnimatedEnumerationImpl *type() const; + SVGAnimatedNumberListImpl *tableValues() const; + SVGAnimatedNumberImpl *slope() const; + SVGAnimatedNumberImpl *intercept() const; + SVGAnimatedNumberImpl *amplitude() const; + SVGAnimatedNumberImpl *exponent() const; + SVGAnimatedNumberImpl *offset() const; + +private: + SVGAnimatedEnumerationImpl *m_type; + SVGAnimatedNumberListImpl *m_tableValues; + SVGAnimatedNumberImpl *m_slope; + SVGAnimatedNumberImpl *m_intercept; + SVGAnimatedNumberImpl *m_amplitude; + SVGAnimatedNumberImpl *m_exponent; + SVGAnimatedNumberImpl *m_offset; + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGContainerImpl.cc b/ksvg/impl/SVGContainerImpl.cc new file mode 100644 index 00000000..88fb87a8 --- /dev/null +++ b/ksvg/impl/SVGContainerImpl.cc @@ -0,0 +1,135 @@ +/* + 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 "SVGRectImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGContainerImpl.h" +#include "SVGSVGElementImpl.h" +#include "kdebug.h" + +using namespace KSVG; + +SVGContainerImpl::SVGContainerImpl(DOM::ElementImpl *impl) : SVGShapeImpl(impl) +{ +} + +SVGContainerImpl::~SVGContainerImpl() +{ +} + +SVGRectImpl *SVGContainerImpl::getBBox() +{ + // just get the union of the children bboxes + QRect rect; + DOM::Node node = firstChild(); + for(; !node.isNull(); node = node.nextSibling()) + { + SVGElementImpl *elem = ownerDoc()->getElementFromHandle(node.handle()); + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(elem); + SVGTestsImpl *tests = dynamic_cast<SVGTestsImpl *>(elem); + SVGStylableImpl *style = dynamic_cast<SVGStylableImpl *>(elem); + + bool ok = tests ? tests->ok() : true; + + if(shape && style && ok && style->getVisible() && style->getDisplay()) + { + SVGRectImpl *current = shape->getBBox(); + rect = rect.unite(current->qrect()); + current->deref(); + } + } + + SVGRectImpl *ret = SVGSVGElementImpl::createSVGRect(); + *ret = rect; + return ret; +} + +void SVGContainerImpl::createItem(KSVGCanvas *c) +{ + DOM::Node node = firstChild(); + for(; !node.isNull(); node = node.nextSibling()) + { + SVGElementImpl *elem = ownerDoc()->getElementFromHandle(node.handle()); + if(elem) + elem->createItem(c); + } +} + +void SVGContainerImpl::removeItem(KSVGCanvas *c) +{ + SVGShapeImpl::removeItem(c); + + for(DOM::Node node = firstChild(); !node.isNull(); node = node.nextSibling()) + { + SVGElementImpl *elem = ownerDoc()->getElementFromHandle(node.handle()); + if(elem) + elem->removeItem(c); + } +} + +void SVGContainerImpl::update(CanvasItemUpdate reason, int param1, int param2) +{ + SVGShapeImpl::update(reason, param1, param2); + + for(DOM::Node node = firstChild(); !node.isNull(); node = node.nextSibling()) + { + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(ownerDoc()->getElementFromHandle(node.handle())); + if(shape) + shape->update(reason, param1, param2); + } +} + +void SVGContainerImpl::invalidate(KSVGCanvas *c, bool recalc) +{ + SVGShapeImpl::invalidate(c, recalc); + + for(DOM::Node node = firstChild(); !node.isNull(); node = node.nextSibling()) + { + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(ownerDoc()->getElementFromHandle(node.handle())); + if(shape) + shape->invalidate(c, recalc); + } +} + +void SVGContainerImpl::setReferenced(bool referenced) +{ + SVGShapeImpl::setReferenced(referenced); + + for(DOM::Node node = firstChild(); !node.isNull(); node = node.nextSibling()) + { + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(ownerDoc()->getElementFromHandle(node.handle())); + if(shape) + shape->setReferenced(referenced); + } +} + +void SVGContainerImpl::draw() +{ + SVGShapeImpl::draw(); + + for(DOM::Node node = firstChild(); !node.isNull(); node = node.nextSibling()) + { + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(ownerDoc()->getElementFromHandle(node.handle())); + if(shape) + shape->draw(); + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGContainerImpl.h b/ksvg/impl/SVGContainerImpl.h new file mode 100644 index 00000000..353a6154 --- /dev/null +++ b/ksvg/impl/SVGContainerImpl.h @@ -0,0 +1,58 @@ +/* + 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. +*/ + +#ifndef SVGContainerImpl_H +#define SVGContainerImpl_H + +#include "SVGShapeImpl.h" + +namespace KSVG +{ +enum CanvasItemUpdate; +class KSVGCanvas; + +class SVGContainerImpl : public SVGShapeImpl +{ +public: + SVGContainerImpl(DOM::ElementImpl *); + virtual ~SVGContainerImpl(); + + virtual bool isContainer() const { return true; } + + virtual void createItem(KSVGCanvas *c = 0); + virtual void removeItem(KSVGCanvas *c); + + virtual void update(CanvasItemUpdate reason, int param1, int param2); + virtual void invalidate(KSVGCanvas *c, bool recalc); + virtual void setReferenced(bool referenced); + virtual void draw(); + + virtual SVGRectImpl *getBBox(); + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGCursorElementImpl.cc b/ksvg/impl/SVGCursorElementImpl.cc new file mode 100644 index 00000000..331f8826 --- /dev/null +++ b/ksvg/impl/SVGCursorElementImpl.cc @@ -0,0 +1,104 @@ +/* + 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> + +#include "SVGCursorElementImpl.h" +#include "SVGAnimatedLengthImpl.h" + +using namespace KSVG; + +#include "SVGCursorElementImpl.lut.h" +#include "ksvg_bridge.h" + +SVGCursorElementImpl::SVGCursorElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGURIReferenceImpl(), SVGTestsImpl(), SVGExternalResourcesRequiredImpl() +{ + KSVG_EMPTY_FLAGS + + m_x = new SVGAnimatedLengthImpl(); + m_x->ref(); + + m_y = new SVGAnimatedLengthImpl(); + m_y->ref(); +} + +SVGCursorElementImpl::~SVGCursorElementImpl() +{ + if(m_x) + m_x->deref(); + if(m_y) + m_y->deref(); +} + +SVGAnimatedLengthImpl *SVGCursorElementImpl::x() const +{ + return m_x; +} + +SVGAnimatedLengthImpl *SVGCursorElementImpl::y() const +{ + return m_y; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGCursorElementImpl::s_hashTable 3 + x SVGCursorElementImpl::X DontDelete|ReadOnly + y SVGCursorElementImpl::Y DontDelete|ReadOnly +@end +*/ + +Value SVGCursorElementImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case X: + return m_x->cache(exec); + case Y: + return m_y->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGCursorElementImpl::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; + + switch(token) + { + case X: + x()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + case Y: + y()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGCursorElementImpl.h b/ksvg/impl/SVGCursorElementImpl.h new file mode 100644 index 00000000..a063acd0 --- /dev/null +++ b/ksvg/impl/SVGCursorElementImpl.h @@ -0,0 +1,69 @@ +/* + 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. +*/ + +#ifndef SVGCursorElementImpl_H +#define SVGCursorElementImpl_H + +#include "SVGTestsImpl.h" +#include "SVGElementImpl.h" +#include "SVGURIReferenceImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedLengthImpl; +class SVGCursorElementImpl : public SVGElementImpl, + public SVGURIReferenceImpl, + public SVGTestsImpl, + public SVGExternalResourcesRequiredImpl +{ +public: + SVGCursorElementImpl(DOM::ElementImpl *); + virtual ~SVGCursorElementImpl(); + + SVGAnimatedLengthImpl *x() const; + SVGAnimatedLengthImpl *y() const; + +private: + SVGAnimatedLengthImpl *m_x; + SVGAnimatedLengthImpl *m_y; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + X, Y + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGDefinitionSrcElementImpl.cc b/ksvg/impl/SVGDefinitionSrcElementImpl.cc new file mode 100644 index 00000000..cf5d764c --- /dev/null +++ b/ksvg/impl/SVGDefinitionSrcElementImpl.cc @@ -0,0 +1,33 @@ +/* + 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 "SVGDefinitionSrcElementImpl.h" + +using namespace KSVG; + +SVGDefinitionSrcElementImpl::SVGDefinitionSrcElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl) +{ +} + +SVGDefinitionSrcElementImpl::~SVGDefinitionSrcElementImpl() +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGDefinitionSrcElementImpl.h b/ksvg/impl/SVGDefinitionSrcElementImpl.h new file mode 100644 index 00000000..65fb359c --- /dev/null +++ b/ksvg/impl/SVGDefinitionSrcElementImpl.h @@ -0,0 +1,46 @@ +/* + 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. +*/ + +#ifndef SVGDefinitionSrcElementImpl_H +#define SVGDefinitionSrcElementImpl_H + +#include "SVGElementImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGDefinitionSrcElementImpl : public SVGElementImpl +{ +public: + SVGDefinitionSrcElementImpl(DOM::ElementImpl *); + virtual ~SVGDefinitionSrcElementImpl(); + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGDefsElementImpl.cc b/ksvg/impl/SVGDefsElementImpl.cc new file mode 100644 index 00000000..e5d7d398 --- /dev/null +++ b/ksvg/impl/SVGDefsElementImpl.cc @@ -0,0 +1,34 @@ +/* + 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 "SVGDefsElementImpl.h" + +using namespace KSVG; + +SVGDefsElementImpl::SVGDefsElementImpl(DOM::ElementImpl *impl) : SVGContainerImpl(impl), SVGTestsImpl(), SVGLangSpaceImpl(), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this), SVGTransformableImpl() +{ + m_display = false; // implicit display=none +} + +SVGDefsElementImpl::~SVGDefsElementImpl() +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGDefsElementImpl.h b/ksvg/impl/SVGDefsElementImpl.h new file mode 100644 index 00000000..e32f0dc9 --- /dev/null +++ b/ksvg/impl/SVGDefsElementImpl.h @@ -0,0 +1,61 @@ +/* + 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. +*/ + +#ifndef SVGDefsElementImpl_H +#define SVGDefsElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGTestsImpl.h" +#include "SVGStylableImpl.h" +#include "SVGContainerImpl.h" +#include "SVGLangSpaceImpl.h" +#include "SVGTransformableImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + +namespace KSVG +{ + +class SVGDefsElementImpl : public SVGContainerImpl, + public SVGTestsImpl, + public SVGLangSpaceImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl, + public SVGTransformableImpl +{ +public: + SVGDefsElementImpl(DOM::ElementImpl *); + virtual ~SVGDefsElementImpl(); + + virtual bool directRender() { return false; } + +public: + KSVG_BRIDGE + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +KSVG_REGISTER_ELEMENT(SVGDefsElementImpl, "defs") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGDescElementImpl.cc b/ksvg/impl/SVGDescElementImpl.cc new file mode 100644 index 00000000..cb0958dd --- /dev/null +++ b/ksvg/impl/SVGDescElementImpl.cc @@ -0,0 +1,39 @@ +/* + 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 "SVGDocumentImpl.h" +#include "SVGDescElementImpl.h" + +using namespace KSVG; + +SVGDescElementImpl::SVGDescElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGLangSpaceImpl(), SVGStylableImpl(this) +{ +} + +SVGDescElementImpl::~SVGDescElementImpl() +{ +} + +void SVGDescElementImpl::createItem(KSVGCanvas *) +{ + emit ownerDoc()->gotDescription(collectText()); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGDescElementImpl.h b/ksvg/impl/SVGDescElementImpl.h new file mode 100644 index 00000000..c8136eb6 --- /dev/null +++ b/ksvg/impl/SVGDescElementImpl.h @@ -0,0 +1,55 @@ +/* + 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. +*/ + +#ifndef SVGDescElementImpl_H +#define SVGDescElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGElementImpl.h" +#include "SVGStylableImpl.h" +#include "SVGLangSpaceImpl.h" + +namespace KSVG +{ + +class SVGDescElementImpl : public SVGElementImpl, + public SVGLangSpaceImpl, + public SVGStylableImpl +{ +public: + SVGDescElementImpl(DOM::ElementImpl *impl); + virtual ~SVGDescElementImpl(); + + virtual void createItem(KSVGCanvas *c = 0); + +public: + KSVG_BRIDGE + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +KSVG_REGISTER_ELEMENT(SVGDescElementImpl, "desc") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGDocumentImpl.cc b/ksvg/impl/SVGDocumentImpl.cc new file mode 100644 index 00000000..4bbe2664 --- /dev/null +++ b/ksvg/impl/SVGDocumentImpl.cc @@ -0,0 +1,705 @@ +/* + 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> + +#define USE_VALGRIND 0 + +#if USE_VALGRIND +#include <valgrind/calltree.h> +#endif + +#include "SVGEvent.h" +#include "SVGMatrixImpl.h" +#include "SVGWindowImpl.h" +#include "SVGElementImpl.h" +#include "SVGDocumentImpl.moc" +#include "SVGSVGElementImpl.h" +#include "SVGImageElementImpl.h" +#include "SVGScriptElementImpl.h" +#include "SVGTitleElementImpl.h" +#include "SVGAnimationElementImpl.h" + +#include "KSVGReader.h" +#include "KSVGLoader.h" +#include "KSVGCanvas.h" +#include "CanvasItem.h" + +#include <qpaintdevicemetrics.h> + +using namespace KSVG; + +#include "SVGDocumentImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" + +// A sequence of prime numbers that sets the m_elemDict's hash table size as the +// number of elements in the dictionary passes each level. This keeps the lookup +// performance high as the number of elements grows. See the QDict documentation. +unsigned int SVGDocumentImpl::elemDictHashSizes [] = +{ + 101, + 211, + 401, + 809, + 1601, + 3203, + 6421, + 12809, + 25601, + 51203, + 102407, + 204803, + 409609, + 819229 +}; + +const int SVGDocumentImpl::numElemDictHashSizes = sizeof(elemDictHashSizes) / sizeof(elemDictHashSizes[0]); + +SVGDocumentImpl::SVGDocumentImpl(bool anim, bool fit, SVGImageElementImpl *parentImage) : QObject(), DOM::DomShared(), DOM::Document(), SVGDOMNodeBridge(static_cast<DOM::Node>(*this)) +{ + m_animations = anim; + + m_reader = 0; + m_loader = 0; + m_canvas = 0; + m_rootElement = 0; + m_lastTarget = 0; + m_window = 0; + + m_elemDictHashSizeIndex = 0; + m_elemDict.resize(elemDictHashSizes[m_elemDictHashSizeIndex]); + + m_timeScheduler = new SVGTimeScheduler(this); + m_ecmaEngine = new KSVGEcma(this); + m_ecmaEngine->setup(); + + m_finishedParsing = false; + m_finishedLoading = false; + m_resortZIndicesOnFinishedLoading = false; + m_fit = fit; + + m_parentImage = parentImage; + if(m_parentImage) + m_parentImage->ref(); +} + +SVGDocumentImpl::~SVGDocumentImpl() +{ + if(rootElement() && rootElement()->hasEventListener(SVGEvent::UNLOAD_EVENT, true)) + rootElement()->dispatchEvent(SVGEvent::UNLOAD_EVENT, false, false); + + QPtrList<SVGShapeImpl> killList; + + DOM::Node node = firstChild(); + for(; !node.isNull(); node = node.nextSibling()) + { + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(getElementFromHandle(node.handle())); + if(shape) + killList.append(shape); + } + + SVGShapeImpl *rend = 0; + for(rend = killList.first(); rend; rend = killList.next()) + delete rend; + + delete m_timeScheduler; + delete m_ecmaEngine; + delete m_reader; + delete m_loader; + + if(m_window) + m_window->deref(); + + if(m_parentImage) + m_parentImage->deref(); +} + +SVGWindowImpl *SVGDocumentImpl::window() +{ + if(!m_window) + { + m_window = new SVGWindowImpl(const_cast<SVGDocumentImpl *>(this)); + m_window->ref(); + } + + return m_window; +} + +float SVGDocumentImpl::screenPixelsPerMillimeterX() const +{ + if(canvas() && canvas()->drawWindow()) + { + QPaintDeviceMetrics metrics(canvas()->drawWindow()); + return float(metrics.width()) / float(metrics.widthMM()); + } + else + return 90.0; +} + +float SVGDocumentImpl::screenPixelsPerMillimeterY() const +{ + if(canvas() && canvas()->drawWindow()) + { + QPaintDeviceMetrics metrics(canvas()->drawWindow()); + return float(metrics.height()) / float(metrics.heightMM()); + } + else + return 90.0; +} + +DOM::DOMString SVGDocumentImpl::title() const +{ + DOM::Node n; + for(n = rootElement()->firstChild(); !n.isNull(); n = n.nextSibling()) + { + SVGElementImpl *elem = getElementFromHandle(n.handle()); + if(dynamic_cast<SVGTitleElementImpl *>(elem)) + return elem->collectText(); + } + return ""; +} + +DOM::DOMString SVGDocumentImpl::referrer() const +{ + return m_referrer; +} + +DOM::DOMString SVGDocumentImpl::domain() const +{ + return m_baseURL.host(); +} + +DOM::DOMString SVGDocumentImpl::URL() const +{ + return m_baseURL.prettyURL(); +} + +void SVGDocumentImpl::setReferrer(const DOM::DOMString &referrer) +{ + // TODO : better may be to request for referrer instead of storing it + m_referrer = referrer; +} + +void SVGDocumentImpl::setRootElement(SVGSVGElementImpl *elem) +{ + m_rootElement = elem; +} + +SVGSVGElementImpl *SVGDocumentImpl::rootElement() const +{ + return m_rootElement; +} + +SVGElementImpl *SVGDocumentImpl::createElement(const DOM::DOMString &name, DOM::Element impl, SVGDocumentImpl *doc) +{ + DOM::ElementImpl *handle = reinterpret_cast<DOM::ElementImpl *>(impl.handle()); + SVGElementImpl *element = SVGElementImpl::Factory::self()->create(std::string(name.string().latin1()), handle); + + if(!element) + element = new SVGElementImpl(handle); + + element->setOwnerDoc(doc); + element->ref(); + return element; +} + +bool SVGDocumentImpl::open(const ::KURL &url) +{ + if(!url.prettyURL().isEmpty()) + { + m_baseURL = url; + + if(!m_loader) + m_loader = new KSVGLoader(); + + connect(m_loader, SIGNAL(gotResult(QIODevice *)), this, SLOT(slotSVGContent(QIODevice *))); + m_loader->getSVGContent(url); + } + else + return false; + + return true; +} + +void SVGDocumentImpl::slotSVGContent(QIODevice *dev) +{ + QXmlInputSource *inputSource = new QXmlInputSource(dev); + + if(m_reader) + delete m_reader; + + KSVGReader::ParsingArgs args; + args.fit = m_fit; + args.getURLMode = false; + + QString url = m_baseURL.prettyURL(); + int pos = url.find('#'); // url can become like this.svg#svgView(viewBox(63,226,74,74)), get part after '#' + if(pos > -1) + args.SVGFragmentId = url.mid(pos + 1); + + m_reader = new KSVGReader(this, m_canvas, args); + connect(m_reader, SIGNAL(finished(bool, const QString &)), this, SLOT(slotFinishedParsing(bool, const QString &))); + m_t.start(); + +#if USE_VALGRIND + CALLTREE_ZERO_STATS(); +#endif + + m_reader->parse(inputSource); + delete dev; +} + +void SVGDocumentImpl::parseSVG(QXmlInputSource *inputSource, bool getURLMode) +{ + if(m_reader) + delete m_reader; + + KSVGReader::ParsingArgs args; + args.fit = m_fit; + args.getURLMode = getURLMode; + m_reader = new KSVGReader(this, 0, args); + connect(m_reader, SIGNAL(finished(bool, const QString &)), this, SLOT(slotFinishedParsing(bool, const QString &))); + +#if USE_VALGRIND + CALLTREE_ZERO_STATS(); +#endif + + m_reader->parse(inputSource); +} + +void SVGDocumentImpl::finishParsing(bool error, const QString &errorDesc) +{ + if(m_reader) + m_reader->finishParsing(error, errorDesc); +} + +void SVGDocumentImpl::slotFinishedParsing(bool error, const QString &errorDesc) +{ + kdDebug(26000) << k_funcinfo << "total time : " << m_t.elapsed() << endl; + +#if USE_VALGRIND + CALLTREE_DUMP_STATS(); +#endif + + if(m_animations) + m_timeScheduler->startAnimations(); + + if(m_canvas && !error && rootElement()) + executeScripts(); + + m_finishedParsing = true; + + emit finishedParsing(error, errorDesc); + if(!error) + emit finishedRendering(); + + checkFinishedLoading(); +} + +void SVGDocumentImpl::newImageJob(SVGImageElementImpl *image) +{ + kdDebug(26002) << "SVGDocumentImpl::newImageJob, " << image << endl; + m_loader->newImageJob(image, m_baseURL); +} + +void SVGDocumentImpl::notifyImageLoading(SVGImageElementImpl *image) +{ + m_imagesLoading.append(image); +} + +void SVGDocumentImpl::notifyImageLoaded(SVGImageElementImpl *image) +{ + m_imagesLoading.remove(image); + + if(m_imagesLoading.isEmpty()) + checkFinishedLoading(); +} + +void SVGDocumentImpl::checkFinishedLoading() +{ + if(m_finishedParsing && m_imagesLoading.isEmpty()) + { + m_finishedLoading = true; + + if(m_resortZIndicesOnFinishedLoading) + { + // Only resort if we're the 'outermost' document, i.e. we're not an svg image + // inside another document. We could resort as each image finishes loading, but it + // slows down the parsing phase. + if(m_parentImage == 0 && m_canvas && m_rootElement) + { + m_canvas->setElementItemZIndexRecursive(m_rootElement, 0); + m_canvas->update(); + } + } + + emit finishedLoading(); + } +} + +void SVGDocumentImpl::addForwardReferencingUseElement(SVGUseElementImpl *use) +{ + if(!m_forwardReferencingUseElements.contains(use)) + m_forwardReferencingUseElements.append(use); +} + +void SVGDocumentImpl::slotPaint() +{ + rerender(); +} + +void SVGDocumentImpl::rerender() +{ + m_canvas->update(); + emit finishedRendering(); +} + +void SVGDocumentImpl::attach(KSVG::KSVGCanvas *c) +{ + m_canvas = c; +} + +void SVGDocumentImpl::detach() +{ + m_canvas = 0; +} + +KSVG::KSVGCanvas *SVGDocumentImpl::canvas() const +{ + return m_canvas; +} + +void SVGDocumentImpl::syncCachedMatrices() +{ + if(rootElement()) + { + SVGMatrixImpl *parentMatrix = SVGSVGElementImpl::createSVGMatrix(); + rootElement()->checkCachedScreenCTM(parentMatrix); + parentMatrix->deref(); + } +} + +void SVGDocumentImpl::executeScriptsRecursive(DOM::Node start) +{ + DOM::Node node = start.firstChild(); + + for(; !node.isNull(); node = node.nextSibling()) + { + SVGElementImpl *element = getElementFromHandle(node.handle()); + + SVGContainerImpl *container = dynamic_cast<SVGContainerImpl *>(element); + if(container) + executeScriptsRecursive(node); + + SVGScriptElementImpl *script = dynamic_cast<SVGScriptElementImpl *>(element); + + if(script) + script->executeScript(DOM::Node()); + } +} + +bool SVGDocumentImpl::executeScriptsRecursiveCheck(DOM::Node start) +{ + bool test = true; + + DOM::Node node = start.firstChild(); + + for(; !node.isNull(); node = node.nextSibling()) + { + SVGElementImpl *element = getElementFromHandle(node.handle()); + + SVGContainerImpl *container = dynamic_cast<SVGContainerImpl *>(element); + if(container) + { + if(!executeScriptsRecursiveCheck(node)) + return false; + } + + SVGScriptElementImpl *script = dynamic_cast<SVGScriptElementImpl *>(element); + + if(script) + { + if(!script->canExecuteScript()) + { + test = false; + break; + } + } + } + + return test; +} + +void SVGDocumentImpl::executeScripts() +{ + bool test = executeScriptsRecursiveCheck(*rootElement()); + + if(!test) + QTimer::singleShot(50, this, SLOT(executeScripts())); + else + { + executeScriptsRecursive(*rootElement()); + + // mop: only rerender if an loadevent has been found + if(dispatchRecursiveEvent(SVGEvent::LOAD_EVENT, lastChild())) + m_canvas->update(); + } +} + +// Dispatches a non-cancelable, non-bubbles event to every child +bool SVGDocumentImpl::dispatchRecursiveEvent(SVGEvent::EventId id, DOM::Node start) +{ + bool eventExecuted = false; + + // Iterate the tree, backwards, and dispatch the event to every child + DOM::Node node = start; + for(; !node.isNull(); node = node.previousSibling()) + { + SVGElementImpl *element = getElementFromHandle(node.handle()); + + if(element && element->hasChildNodes()) + { + // Dispatch to all children + eventExecuted = dispatchRecursiveEvent(id, element->lastChild()) ? true : eventExecuted; + + // Dispatch, locally + if(element->hasEventListener(id, true)) + { + element->dispatchEvent(id, false, false); + eventExecuted = true; + } + } + else if(element && element->hasEventListener(id, true)) + { + element->dispatchEvent(id, false, false); + eventExecuted = true; + } + } + + return eventExecuted; +} + +SVGEventListener *SVGDocumentImpl::createEventListener(DOM::DOMString type) +{ + return m_ecmaEngine->createEventListener(type); +} + +SVGElementImpl *SVGDocumentImpl::recursiveSearch(DOM::Node start, const DOM::DOMString &id) +{ + DOM::Node node = start.firstChild(); + for(; !node.isNull(); node = node.nextSibling()) + { + SVGElementImpl *test = getElementFromHandle(node.handle()); + + // Look in containers + SVGContainerImpl *container = dynamic_cast<SVGContainerImpl *>(test); + if(container) + { + SVGElementImpl *found = recursiveSearch(node, id); + if(found) + return found; + } + + // Look in SVGSVGElementImpl's + SVGSVGElementImpl *svgtest = dynamic_cast<SVGSVGElementImpl *>(test); + if(svgtest) + { + SVGElementImpl *element = svgtest->getElementById(id); + if(element) + return element; + } + } + + return 0; +} + +/* +@namespace KSVG +@begin SVGDocumentImpl::s_hashTable 9 + title SVGDocumentImpl::Title DontDelete|ReadOnly + referrer SVGDocumentImpl::Referrer DontDelete|ReadOnly + domain SVGDocumentImpl::Domain DontDelete|ReadOnly + URL SVGDocumentImpl::Url DontDelete|ReadOnly + doctype SVGDocumentImpl::DocType DontDelete|ReadOnly + implementation SVGDocumentImpl::Implementation DontDelete|ReadOnly + rootElement SVGDocumentImpl::RootElement DontDelete|ReadOnly + documentElement SVGDocumentImpl::DocumentElement DontDelete|ReadOnly +@end +@namespace KSVG +@begin SVGDocumentImplProto::s_hashTable 7 + createTextNode SVGDocumentImpl::CreateTextNode DontDelete|Function 1 + createElement SVGDocumentImpl::CreateElement DontDelete|Function 1 + createElementNS SVGDocumentImpl::CreateElementNS DontDelete|Function 2 + getElementById SVGDocumentImpl::GetElementById DontDelete|Function 1 + getElementsByTagName SVGDocumentImpl::GetElementsByTagName DontDelete|Function 1 + getElementsByTagNameNS SVGDocumentImpl::GetElementsByTagNameNS DontDelete|Function 2 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGDocument", SVGDocumentImplProto, SVGDocumentImplProtoFunc) + +Value SVGDocumentImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case Title: + return String(title().string()); + case Referrer: + return String(referrer().string()); + case Domain: + return String(domain().string()); + case Url: + return String(URL().string()); + case DocType: + return getDOMNode(exec, doctype()); + case Implementation: + return (new SVGDOMDOMImplementationBridge(implementation()))->cache(exec); + case RootElement: + case DocumentElement: + return m_rootElement->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +Value SVGDocumentImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGDocumentImpl) + + switch(id) + { + case SVGDocumentImpl::CreateTextNode: + return getDOMNode(exec, obj->createTextNode(args[0].toString(exec).string())); + case SVGDocumentImpl::CreateElement: + case SVGDocumentImpl::CreateElementNS: + { + SVGElementImpl *newElement = 0; + + if(id == SVGDocumentImpl::CreateElement) + newElement = obj->createElement(args[0].toString(exec).qstring(), static_cast<DOM::Document *>(obj)->createElement(args[0].toString(exec).string()), obj); + else if(id == SVGDocumentImpl::CreateElementNS) + newElement = obj->createElement(args[1].toString(exec).qstring(), static_cast<DOM::Document *>(obj)->createElementNS(args[0].toString(exec).string(), args[1].toString(exec).string()), obj); + + newElement->setOwnerSVGElement(obj->rootElement()); // FIXME: Correct in all situations? + newElement->setViewportElement(obj->rootElement()); + newElement->setAttributes(); + + return getDOMNode(exec, *newElement); + } + case SVGDocumentImpl::GetElementById: + { + Value ret; + + SVGElementImpl *element = obj->rootElement()->getElementById(args[0].toString(exec).string()); + + if(element) + ret = getDOMNode(exec, *element); + else + { + element = obj->recursiveSearch(*obj, args[0].toString(exec).string()); + if(!element) + return Null(); + + ret = getDOMNode(exec, *element); + } + + return ret; + } + case SVGDocumentImpl::GetElementsByTagName: + return (new SVGDOMNodeListBridge(obj->getElementsByTagName(args[0].toString(exec).string())))->cache(exec); + case SVGDocumentImpl::GetElementsByTagNameNS: + return (new SVGDOMNodeListBridge(obj->getElementsByTagNameNS(args[0].toString(exec).string(), args[1].toString(exec).string())))->cache(exec); + default: + break; + } + + return KJS::Undefined(); +} + +SVGElementImpl *SVGDocumentImpl::getElementFromHandle(DOM::NodeImpl *handle) const +{ + return m_elemDict[handle]; +} + +void SVGDocumentImpl::addToElemDict(DOM::NodeImpl *handle, SVGElementImpl *obj) +{ + m_elemDict.insert(handle, obj); + + if(m_elemDict.count()>m_elemDict.size() && m_elemDictHashSizeIndex<numElemDictHashSizes-1) + { + // Increase the hash table size to maintain good lookup speed. + m_elemDictHashSizeIndex++; + m_elemDict.resize(elemDictHashSizes[m_elemDictHashSizeIndex]); + } +} + +void SVGDocumentImpl::removeFromElemDict(DOM::NodeImpl *handle) +{ + m_elemDict.remove(handle); +} + +SVGDocumentImpl *SVGDocumentImpl::getDocumentFromHandle(DOM::NodeImpl *handle) const +{ + return m_documentDict[handle]; +} + +void SVGDocumentImpl::addToDocumentDict(DOM::NodeImpl *handle, SVGDocumentImpl *obj) +{ + m_documentDict.insert(handle, obj); +} + +SVGElementImpl *SVGDocumentImpl::getElementByIdRecursive(SVGSVGElementImpl *start, const DOM::DOMString &elementId, bool dontSearch) +{ + SVGElementImpl *element = 0; + + // #1 Look in passed SVGSVGElementImpl + if(start) + { + element = start->getElementById(elementId); + + if(element) + return element; + } + + // #2 Search in all child SVGSVGElementImpl's + element = recursiveSearch(*this, elementId); + + if(element) + return element; + + // #3 Search in other documents + if(!dontSearch) + { + QPtrDictIterator<SVGDocumentImpl> it(m_documentDict); + for(; it.current(); ++it) + { + SVGElementImpl *temp = it.current()->getElementByIdRecursive(0, elementId, true); + if(temp) + return temp; + } + } + + return element; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGDocumentImpl.h b/ksvg/impl/SVGDocumentImpl.h new file mode 100644 index 00000000..c4156910 --- /dev/null +++ b/ksvg/impl/SVGDocumentImpl.h @@ -0,0 +1,245 @@ +/* + 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. +*/ + +#ifndef SVGDocumentImpl_H +#define SVGDocumentImpl_H + +#include <kurl.h> + +#include <qxml.h> +#include <qobject.h> +#include <qptrdict.h> +#include <qptrlist.h> +#include <qdatetime.h> +#include <qstringlist.h> + +#include <kjs/object.h> + +#include <dom/dom_doc.h> +#include <dom/dom_misc.h> +#include <dom/dom_string.h> + +#include "ksvg_lookup.h" + +#include "SVGEvent.h" +#include "SVGTimeScheduler.h" + +class KSVGEcma; +class KSVGRequest; + +namespace KJS +{ + class Value; + class UString; + class ExecState; + class Identifier; +} + +namespace KSVG +{ + +class SVGTimer; +class KSVGLoader; +class KSVGReader; +class KSVGCanvas; +class SVGImageElementImpl; +class SVGSVGElementImpl; +class SVGWindowImpl; +class SVGScriptElementImpl; +class SVGDescElementImpl; +class SVGTitleElementImpl; +class SVGUseElementImpl; +class SVGDocumentImpl : public QObject, + public DOM::DomShared, + public DOM::Document, + public SVGDOMNodeBridge +{ +Q_OBJECT +public: + SVGDocumentImpl(bool anim = true, bool bFit = false, SVGImageElementImpl *parentImage = 0); + virtual ~SVGDocumentImpl(); + + float screenPixelsPerMillimeterX() const; + float screenPixelsPerMillimeterY() const; + + DOM::DOMString title() const; + DOM::DOMString referrer() const; + DOM::DOMString domain() const; + DOM::DOMString URL() const; + + void setReferrer(const DOM::DOMString &referrer); + + void setRootElement(SVGSVGElementImpl *); + SVGSVGElementImpl *rootElement() const; + + SVGImageElementImpl *parentImage() const { return m_parentImage; } + + SVGWindowImpl *window(); + + static SVGElementImpl *createElement(const DOM::DOMString &name, DOM::Element impl, SVGDocumentImpl *doc = 0); + + bool open(const KURL &url); + void rerender(); + + void attach(KSVG::KSVGCanvas *p); + void detach(); + + bool ready() { return m_finishedParsing; } + + KURL baseUrl() { return m_baseURL; } + KSVGCanvas *canvas() const; + + // Ecma stuff + KSVGEcma *ecmaEngine() { return m_ecmaEngine; } + + void parseSVG(QXmlInputSource *inputSource, bool getURLMode = false); + + virtual bool implementsCall() const { return true; } + + void executeScriptsRecursive(DOM::Node start); + bool executeScriptsRecursiveCheck(DOM::Node start); + + bool dispatchRecursiveEvent(SVGEvent::EventId id, DOM::Node start); + + SVGElementImpl *getElementByIdRecursive(SVGSVGElementImpl *start, const DOM::DOMString &elementId, bool dontSearch = false); + + // Event stuff + SVGEventListener *createEventListener(DOM::DOMString type); + + void setLastTarget(SVGElementImpl *elem) { m_lastTarget = elem; } + SVGElementImpl *lastTarget() { return m_lastTarget; } + + // Animation stuff + SVGTimeScheduler *timeScheduler() const { return m_timeScheduler; } + + // Internal + SVGElementImpl *getElementFromHandle(DOM::NodeImpl *handle) const; + void addToElemDict(DOM::NodeImpl *handle, SVGElementImpl *obj); + void removeFromElemDict(DOM::NodeImpl *handle); + + SVGDocumentImpl *getDocumentFromHandle(DOM::NodeImpl *handle) const; + void addToDocumentDict(DOM::NodeImpl *handle, SVGDocumentImpl *obj); + + SVGElementImpl *recursiveSearch(DOM::Node start, const DOM::DOMString &id); + + void finishParsing(bool error, const QString &errorDesc); + + void newImageJob(SVGImageElementImpl *); + + void notifyImageLoading(SVGImageElementImpl *image); + void notifyImageLoaded(SVGImageElementImpl *image); + void resortZIndicesOnFinishedLoading() { m_resortZIndicesOnFinishedLoading = true; } + + void addForwardReferencingUseElement(SVGUseElementImpl *use); + QValueList<SVGUseElementImpl *> forwardReferencingUseElements() const { return m_forwardReferencingUseElements; } + + // Traverse the element hierarchy and update any cached matrices that are + // no longer valid. + void syncCachedMatrices(); + +public slots: + void slotPaint(); + void executeScripts(); + +private slots: + void slotSVGContent(QIODevice *); + void slotFinishedParsing(bool error, const QString &errorDesc); + +// KDE invents public signals :) +#undef signals +#define signals public +signals: + void gotDescription(const QString &); + void gotTitle(const QString &); + void gotURL(const QString &); + + void finishedParsing(bool error, const QString &errorDesc); + void finishedRendering(); + void finishedLoading(); + +private: + void checkFinishedLoading(); + + bool m_finishedParsing; + bool m_finishedLoading; + bool m_animations; + + SVGSVGElementImpl *m_rootElement; + + SVGTimeScheduler *m_timeScheduler; + + // Set if this document is being displayed by an 'image' element reference + // rather than as the main document, 0 otherwise. + SVGImageElementImpl *m_parentImage; + + KSVGReader *m_reader; + KSVGLoader *m_loader; + KSVGCanvas *m_canvas; + + KSVGEcma *m_ecmaEngine; + + QPtrDict<SVGElementImpl> m_elemDict; + QPtrDict<SVGDocumentImpl> m_documentDict; + + static uint elemDictHashSizes[]; + static const int numElemDictHashSizes; + int m_elemDictHashSizeIndex; + + SVGWindowImpl *m_window; + SVGElementImpl *m_lastTarget; + + KURL m_baseURL; + + DOM::DOMString m_referrer; + + bool m_fit; + + QTime m_t; + + QValueList<SVGImageElementImpl *> m_imagesLoading; + bool m_resortZIndicesOnFinishedLoading; + + QValueList<SVGUseElementImpl *> m_forwardReferencingUseElements; + +public: + KSVG_BASECLASS_GET + KSVG_PUT + + enum + { + // Properties + Title, Referrer, Domain, Url, + DocType, Implementation, RootElement, DocumentElement, + // Functions + CreateTextNode, CreateElement, CreateElementNS, + GetElementById, GetElementsByTagName, GetElementsByTagNameNS + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; +}; + +} + +KSVG_DEFINE_PROTOTYPE(SVGDocumentImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGDocumentImplProtoFunc, SVGDocumentImpl) + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGEcma.cc b/ksvg/impl/SVGEcma.cc new file mode 100644 index 00000000..08870d0c --- /dev/null +++ b/ksvg/impl/SVGEcma.cc @@ -0,0 +1,844 @@ +/* + Copyright (C) 2002-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 <typeinfo> + +#include <kdebug.h> + +#include <dom/dom_exception.h> + +#include "CanvasItem.h" +#include "KSVGCanvas.h" + +#include "SVGEcma.h" +#include "SVGShapeImpl.h" +#include "SVGHelperImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGSVGElementImpl.h" + +using namespace KSVG; + +#include "SVGEcma.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_ecmaeventlistener.h" +#include "ksvg_window.h" +#include "ksvg_ecma.h" + +// SVGDOMNodeBridge + +/* +@namespace KSVG +@begin SVGDOMNodeBridge::s_hashTable 17 + nodeName SVGDOMNodeBridge::NodeName DontDelete|ReadOnly + nodeValue SVGDOMNodeBridge::NodeValue DontDelete + nodeType SVGDOMNodeBridge::NodeType DontDelete|ReadOnly + parentNode SVGDOMNodeBridge::ParentNode DontDelete|ReadOnly + childNodes SVGDOMNodeBridge::ChildNodes DontDelete|ReadOnly + firstChild SVGDOMNodeBridge::FirstChild DontDelete|ReadOnly + lastChild SVGDOMNodeBridge::LastChild DontDelete|ReadOnly + previousSibling SVGDOMNodeBridge::PreviousSibling DontDelete|ReadOnly + nextSibling SVGDOMNodeBridge::NextSibling DontDelete|ReadOnly + attributes SVGDOMNodeBridge::Attributes DontDelete|ReadOnly + namespaceURI SVGDOMNodeBridge::NamespaceURI DontDelete|ReadOnly + prefix SVGDOMNodeBridge::Prefix DontDelete + localName SVGDOMNodeBridge::LocalName DontDelete|ReadOnly + ownerDocument SVGDOMNodeBridge::OwnerDocument DontDelete|ReadOnly +@end +@namespace KSVG +@begin SVGDOMNodeBridgeProto::s_hashTable 29 + insertBefore SVGDOMNodeBridge::InsertBefore DontDelete|Function 2 + replaceChild SVGDOMNodeBridge::ReplaceChild DontDelete|Function 2 + removeChild SVGDOMNodeBridge::RemoveChild DontDelete|Function 1 + appendChild SVGDOMNodeBridge::AppendChild DontDelete|Function 1 + hasAttributes SVGDOMNodeBridge::HasAttributes DontDelete|Function 0 + hasChildNodes SVGDOMNodeBridge::HasChildNodes DontDelete|Function 0 + cloneNode SVGDOMNodeBridge::CloneNode DontDelete|Function 1 + normalize SVGDOMNodeBridge::Normalize DontDelete|Function 0 + isSupported SVGDOMNodeBridge::IsSupported DontDelete|Function 2 + addEventListener SVGDOMNodeBridge::AddEventListener DontDelete|Function 3 + removeEventListener SVGDOMNodeBridge::RemoveEventListener DontDelete|Function 3 + contains SVGDOMNodeBridge::Contains DontDelete|Function 1 + getNodeName SVGDOMNodeBridge::GetNodeName DontDelete|Function 0 + getNodeValue SVGDOMNodeBridge::GetNodeValue DontDelete|Function 0 + getNodeType SVGDOMNodeBridge::GetNodeType DontDelete|Function 0 + getParentNode SVGDOMNodeBridge::GetParentNode DontDelete|Function 0 + getChildNodes SVGDOMNodeBridge::GetChildNodes DontDelete|Function 0 + getFirstChild SVGDOMNodeBridge::GetFirstChild DontDelete|Function 0 + getLastChild SVGDOMNodeBridge::GetLastChild DontDelete|Function 0 + getPreviousSibling SVGDOMNodeBridge::GetPreviousSibling DontDelete|Function 0 + getNextSibling SVGDOMNodeBridge::GetNextSibling DontDelete|Function 0 + getAttributes SVGDOMNodeBridge::GetAttributes DontDelete|Function 0 + getNamespaceURI SVGDOMNodeBridge::GetNamespaceURI DontDelete|Function 0 + getPrefix SVGDOMNodeBridge::GetPrefix DontDelete|Function 0 + getLocalName SVGDOMNodeBridge::GetLocalName DontDelete|Function 0 + getOwnerDocument SVGDOMNodeBridge::GetOwnerDocument DontDelete|Function 0 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("DOMNode", SVGDOMNodeBridgeProto, SVGDOMNodeBridgeProtoFunc) + +Value SVGDOMNodeBridge::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case NodeName: + return getString(m_impl.nodeName()); + case NodeValue: + return getString(m_impl.nodeValue()); + case NodeType: + return Number(m_impl.nodeType()); + case ParentNode: + return getDOMNode(exec, m_impl.parentNode()); + case ChildNodes: + return (new SVGDOMNodeListBridge(m_impl.childNodes()))->cache(exec); + case FirstChild: + return getDOMNode(exec, m_impl.firstChild()); + case LastChild: + return getDOMNode(exec, m_impl.lastChild()); + case PreviousSibling: + return getDOMNode(exec, m_impl.previousSibling()); + case NextSibling: + return getDOMNode(exec, m_impl.nextSibling()); +// case Attributes: // TODO + case NamespaceURI: + return getString(m_impl.namespaceURI()); + case Prefix: + return getString(m_impl.prefix()); + case LocalName: + return getString(m_impl.localName()); + case OwnerDocument: + return getDOMNode(exec, m_impl.ownerDocument()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGDOMNodeBridge::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case NodeValue: + m_impl.setNodeValue(value.toString(exec).string()); + break; + case Prefix: + m_impl.setPrefix(value.toString(exec).string()); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// Special variantion to update the <text> element, +// triggered by one of the child nodes +void updateTextItem(ExecState *exec, const DOM::Node node) +{ + DOM::Node parent; + while(!(parent = node.parentNode()).isNull()) + { + DOM::DOMString name = parent.nodeName(); + if(name == "text" || name == "tspan" || name == "tref") + { + SVGHelperImpl::updateItem(exec, parent); + break; + } + } +} + +// Remove item from canvas +void removeItem(ExecState *exec, DOM::Node &node) +{ + // Get document + SVGDocumentImpl *doc = KSVG::Window::retrieveActive(exec)->doc(); + + // Update canvas + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(doc->getElementFromHandle(node.handle())); + if(shape && shape->item()) + doc->canvas()->removeItem(shape->item()); +} + +// parseXML + getURL() need all these 5 functions to work properly +void correctHandles(SVGElementImpl *main, DOM::Node &node) +{ + DOM::Element old(node.handle()); + DOM::Element *replace = static_cast<DOM::Element *>(main->ownerDoc()->getElementFromHandle(node.handle())); + + if(replace && node.nodeType() == DOM::Node::ELEMENT_NODE) + *replace = old; + + if(node.hasChildNodes()) + { + for(DOM::Node iterate = node.firstChild(); !iterate.isNull(); iterate = iterate.nextSibling()) + correctHandles(main, iterate); + } +} + +void integrateTree(SVGElementImpl *main, DOM::Node &node, DOM::Node &newNode, SVGElementImpl *obj, SVGDocumentImpl *doc) +{ + if(!obj) + return; + + // Add to global element dicts + doc->addToElemDict(newNode.handle(), obj); + doc->addToElemDict(node.handle(), obj); + + if(node.hasChildNodes()) + { + DOM::Node iterate2 = newNode.firstChild(); + for(DOM::Node iterate = node.firstChild(); !iterate.isNull(); iterate = iterate.nextSibling()) + { + integrateTree(main, iterate, iterate2, obj->ownerDoc()->getElementFromHandle(iterate2.handle()), doc); + iterate2 = iterate2.nextSibling(); + } + } +} + +void correctDocument(SVGElementImpl *main, DOM::Node &node, SVGElementImpl *obj, SVGDocumentImpl *doc) +{ + if(!obj) + return; + + // Correct document + obj->setOwnerDoc(main->ownerDoc()); + + // Correct rootElement + if(!obj->ownerSVGElement()) + obj->setOwnerSVGElement(main->ownerSVGElement()); + + // Correct viewportElement + if(!obj->viewportElement()) + obj->setViewportElement(main->viewportElement()); + + // Properly (re-)register events in the current active document + obj->setupEventListeners(main->ownerDoc(), doc); + + if(node.hasChildNodes()) + { + for(DOM::Node iterate = node.firstChild(); !iterate.isNull(); iterate = iterate.nextSibling()) + correctDocument(main, iterate, doc->getElementFromHandle(iterate.handle()), doc); + } +} + +void registerAdditional(ExecState *exec, SVGDocumentImpl *doc, DOM::Node node) +{ + // Register ID in rootElement! + SVGElementImpl *resultElement = doc->getElementFromHandle(node.handle()); + if(resultElement && resultElement->hasAttribute("id")) + doc->rootElement()->addToIdMap(resultElement->getAttribute("id").string(), resultElement); + + if(node.hasChildNodes()) + { + for(DOM::Node iterate = node.firstChild(); !iterate.isNull(); iterate = iterate.nextSibling()) + registerAdditional(exec, doc, iterate); + } +} + +Value appendHelper(ExecState *exec, DOM::Node node, DOM::Node newNode) +{ + // This is quite tricky code by me (Niko) + // Don't even try to modify it. + if(!(node.ownerDocument() == newNode.ownerDocument())) + { + // Get document + SVGDocumentImpl *doc = KSVG::Window::retrieveActive(exec)->doc(); + + // Detect ownerDoc() of newNode + SVGDocumentImpl *newDoc = doc->getDocumentFromHandle(newNode.ownerDocument().handle()); + + // Get some SVGElementImpl's + SVGElementImpl *nodeElement = doc->getElementFromHandle(node.handle()); + SVGElementImpl *newNodeElement = newDoc->getElementFromHandle(newNode.handle()); + + // Import node into document + DOM::Node result = doc->importNode(newNode, true); + + // Associate the imported node 'result' with the + // 'newNodeElement' which belongs to 'newDoc' + integrateTree(nodeElement, result, newNode, newNodeElement, doc); + + // Correct handles in SVG* elements + correctHandles(nodeElement, result); + + // Correct ownerDoc() etc.. + correctDocument(nodeElement, newNode, newNodeElement, newDoc); + + // Register ID in global map + registerAdditional(exec, doc, result); + + // Recalc style + newNodeElement->setAttributes(); + + // Append + create + update element + Value retVal = getDOMNode(exec, node.appendChild(result)); + + doc->syncCachedMatrices(); + newNodeElement->createItem(doc->canvas()); + SVGHelperImpl::updateItem(exec, *newNodeElement); + + return retVal; + } + else + { + Value retVal = getDOMNode(exec, node.appendChild(newNode)); + + // Get document + SVGDocumentImpl *doc = KSVG::Window::retrieveActive(exec)->doc(); + doc->syncCachedMatrices(); + + // Get some SVGElementImpl's + SVGElementImpl *nodeElement = doc->getElementFromHandle(newNode.handle()); + // TODO : extra check needed to see if the new elements parent is already appended + // in the doc. Not really nice, should be some other way? (Rob) + if(nodeElement && !nodeElement->parentNode().parentNode().isNull()) + { + nodeElement->setAttributes(true); + nodeElement->createItem(); + SVGHelperImpl::updateItem(exec, newNode); + } + + return retVal; + } +} + +Value SVGDOMNodeBridgeProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGDOMNodeBridge) + DOM::Node node = obj->impl(); + + switch(id) + { + case SVGDOMNodeBridge::InsertBefore: + { + DOM::Node newChild = toNode(args[0]); + DOM::Node beforeChild = toNode(args[1]); + Value retVal = getDOMNode(exec, node.insertBefore(newChild, beforeChild)); + + // Get document + SVGDocumentImpl *doc = Window::retrieveActive(exec)->doc(); + + // Get some SVGElementImpl's + SVGShapeImpl *newShape = dynamic_cast<SVGShapeImpl *>(doc->getElementFromHandle(newChild.handle())); + SVGElementImpl *newElement = doc->getElementFromHandle(newChild.handle()); + SVGShapeImpl *beforeElement = dynamic_cast<SVGShapeImpl *>(doc->getElementFromHandle(beforeChild.handle())); + if(newShape && beforeElement && beforeElement->item()) + { + int z = beforeElement->item()->zIndex(); + newElement->createItem(); + doc->canvas()->insert(newShape->item(), z); + } + SVGHelperImpl::updateItem(exec, newChild); + + return retVal; + } + case SVGDOMNodeBridge::ReplaceChild: + { + DOM::Node newChild = toNode(args[0]); + Value retVal = getDOMNode(exec, node.replaceChild(newChild, toNode(args[1]))); + SVGHelperImpl::updateItem(exec, newChild); + return retVal; + } + case SVGDOMNodeBridge::RemoveChild: + { + DOM::Node remove = toNode(args[0]); + if(remove.isNull()) + return Undefined(); + + // New removeChild logic: + // - remove from DOM tree + // - delete element (also deletes it's child element's) + removeItem(exec, remove); + Value retVal = getDOMNode(exec, node.removeChild(remove)); + return retVal; + } + case SVGDOMNodeBridge::AppendChild: + return appendHelper(exec, node, toNode(args[0])); + case SVGDOMNodeBridge::HasAttributes: + { + SVGDocumentImpl *doc = Window::retrieveActive(exec)->doc(); + SVGElementImpl *element = doc->getElementFromHandle(node.handle()); + + if(!element) + return Undefined(); + + return Boolean(element->hasAttributes()); + } + case SVGDOMNodeBridge::HasChildNodes: + return Boolean(node.hasChildNodes()); + case SVGDOMNodeBridge::CloneNode: + { + SVGDocumentImpl *doc = Window::retrieveActive(exec)->doc(); + SVGElementImpl *element = doc->getElementFromHandle(node.handle()); + SVGElementImpl *newElement = element->cloneNode(args[0].toBoolean(exec)); + + return getDOMNode(exec, *newElement); + } + case SVGDOMNodeBridge::Normalize: + { + node.normalize(); + return Undefined(); + } + case SVGDOMNodeBridge::IsSupported: + return Boolean(node.isSupported(args[0].toString(exec).string(), args[1].toString(exec).string())); + case SVGDOMNodeBridge::AddEventListener: + { + SVGDocumentImpl *doc = Window::retrieveActive(exec)->doc(); + SVGElementImpl *element = doc->getElementFromHandle(node.handle()); + + if(element) + { + SVGEvent::EventId eventId = SVGEvent::typeToId(args[0].toString(exec).string()); + if(eventId != SVGEvent::UNKNOWN_EVENT) + element->setEventListener(eventId, new KSVGEcmaEventListener(Object::dynamicCast(args[1]), QString::null, doc->ecmaEngine())); + } + return Undefined(); + } + case SVGDOMNodeBridge::RemoveEventListener: + { + SVGDocumentImpl *doc = Window::retrieveActive(exec)->doc(); + SVGElementImpl *element = doc->getElementFromHandle(node.handle()); + + if(element) + { + SVGEvent::EventId eventId = SVGEvent::typeToId(args[0].toString(exec).string()); + if(eventId != SVGEvent::UNKNOWN_EVENT) + element->removeEventListener((int) eventId); + } + return Undefined(); + } +// case SVGDOMNodeBridge::Contains: // TODO + case SVGDOMNodeBridge::GetNodeName: + return getString(node.nodeName()); + case SVGDOMNodeBridge::GetNodeValue: + return getString(node.nodeValue()); + case SVGDOMNodeBridge::GetNodeType: + return Number(node.nodeType()); + case SVGDOMNodeBridge::GetParentNode: + return getDOMNode(exec, node.parentNode()); + case SVGDOMNodeBridge::GetChildNodes: + return (new SVGDOMNodeListBridge(node.childNodes()))->cache(exec); + case SVGDOMNodeBridge::GetFirstChild: + return getDOMNode(exec, node.firstChild()); + case SVGDOMNodeBridge::GetLastChild: + return getDOMNode(exec, node.lastChild()); + case SVGDOMNodeBridge::GetPreviousSibling: + return getDOMNode(exec, node.previousSibling()); + case SVGDOMNodeBridge::GetNextSibling: + return getDOMNode(exec, node.nextSibling()); +// case SVGDOMNodeBridge::GetAttributes: // TODO + case SVGDOMNodeBridge::GetNamespaceURI: + return getString(node.namespaceURI()); + case SVGDOMNodeBridge::GetPrefix: + return getString(node.prefix()); + case SVGDOMNodeBridge::GetLocalName: + return getString(node.localName()); + case SVGDOMNodeBridge::GetOwnerDocument: + return getDOMNode(exec, node.ownerDocument()); + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return Undefined(); +} + +// SVGDOMElementBridge + +/* +@namespace KSVG +@begin SVGDOMElementBridge::s_hashTable 2 + tagName SVGDOMElementBridge::TagName DontDelete|ReadOnly +@end +@namespace KSVG +@begin SVGDOMElementBridgeProto::s_hashTable 17 + getAttribute SVGDOMElementBridge::GetAttribute DontDelete|Function 1 + setAttribute SVGDOMElementBridge::SetAttribute DontDelete|Function 2 + removeAttribute SVGDOMElementBridge::RemoveAttribute DontDelete|Function 1 + getAttributeNode SVGDOMElementBridge::GetAttributeNode DontDelete|Function 1 + setAttributeNode SVGDOMElementBridge::SetAttributeNode DontDelete|Function 2 + removeAttributeNode SVGDOMElementBridge::RemoveAttributeNode DontDelete|Function 1 + getElementsByTagName SVGDOMElementBridge::GetElementsByTagName DontDelete|Function 1 + hasAttribute SVGDOMElementBridge::HasAttribute DontDelete|Function 1 + getAttributeNS SVGDOMElementBridge::GetAttributeNS DontDelete|Function 2 + setAttributeNS SVGDOMElementBridge::SetAttributeNS DontDelete|Function 3 + removeAttributeNS SVGDOMElementBridge::RemoveAttributeNS DontDelete|Function 2 + getAttributeNodeNS SVGDOMElementBridge::GetAttributeNodeNS DontDelete|Function 2 + setAttributeNodeNS SVGDOMElementBridge::SetAttributeNodeNS DontDelete|Function 1 + getElementByTagNameNS SVGDOMElementBridge::GetElementsByTagNameNS DontDelete|Function 2 + hasAttributeNS SVGDOMElementBridge::HasAttributeNS DontDelete|Function 2 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("DOMElement", SVGDOMElementBridgeProto, SVGDOMElementBridgeProtoFunc) + +Value SVGDOMElementBridge::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case TagName: + return getString(m_impl.tagName()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +Value SVGDOMElementBridgeProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGDOMElementBridge) + DOM::Element elem = obj->impl(); + + switch(id) + { + case SVGDOMElementBridge::GetAttribute: + { + SVGDocumentImpl *doc = Window::retrieveActive(exec)->doc(); + SVGElementImpl *element = doc->getElementFromHandle(elem.handle()); + if(element) + return String(element->getAttribute(args[0].toString(exec).string())); + else + return Undefined(); + } + case SVGDOMElementBridge::SetAttribute: + { + SVGDocumentImpl *doc = Window::retrieveActive(exec)->doc(); + SVGElementImpl *element = doc->getElementFromHandle(elem.handle()); + if(element) + { + element->setAttribute(args[0].toString(exec).string(), args[1].toString(exec).string()); + element->setAttributeInternal(args[0].toString(exec).string(), args[1].toString(exec).string()); + + SVGHelperImpl::updateItem(exec, elem); + } + + return Undefined(); + } + case SVGDOMElementBridge::RemoveAttribute: + { + elem.removeAttribute(args[0].toString(exec).string()); + return Undefined(); + } + case SVGDOMElementBridge::GetAttributeNode: + return getDOMNode(exec, elem.getAttributeNode(args[0].toString(exec).string())); + case SVGDOMElementBridge::SetAttributeNode: // TODO: Correct? + return getDOMNode(exec, elem.setAttributeNode(toNode(args[0]))); + case SVGDOMElementBridge::RemoveAttributeNode: // TODO: Correct? + return getDOMNode(exec, elem.removeAttributeNode(toNode(args[0]))); + case SVGDOMElementBridge::GetElementsByTagName: + return (new SVGDOMNodeListBridge(elem.getElementsByTagName(args[0].toString(exec).string())))->cache(exec); + case SVGDOMElementBridge::GetAttributeNS: + { + // This just skips NS! (Rob) + SVGDocumentImpl *doc = Window::retrieveActive(exec)->doc(); + SVGElementImpl *element = doc->getElementFromHandle(elem.handle()); + if(element) + return String(element->getAttribute(args[1].toString(exec).string())); + else + return Undefined(); + } + case SVGDOMElementBridge::SetAttributeNS: + { + // For now, we strip the NS part (Rob) + DOM::DOMString attr = args[1].toString(exec).string(); + int pos = attr.string().find(':'); + if(pos > -1) + attr = attr.string().mid(pos + 1); + + SVGDocumentImpl *doc = Window::retrieveActive(exec)->doc(); + SVGElementImpl *element = doc->getElementFromHandle(elem.handle()); + if(element) + { + element->setAttribute(attr.string(), args[2].toString(exec).string()); + element->setAttributeInternal(attr.string(), args[2].toString(exec).string()); + + SVGHelperImpl::updateItem(exec, *element); + } + + return Undefined(); + } + case SVGDOMElementBridge::RemoveAttributeNS: + { + elem.removeAttributeNS(args[0].toString(exec).string(), args[1].toString(exec).string()); + return Undefined(); + } + case SVGDOMElementBridge::GetAttributeNodeNS: + return getDOMNode(exec, elem.getAttributeNodeNS(args[0].toString(exec).string(), args[1].toString(exec).string())); + case SVGDOMElementBridge::SetAttributeNodeNS: // TODO: Correct? + return getDOMNode(exec, elem.setAttributeNodeNS(toNode(args[0]))); + case SVGDOMElementBridge::GetElementsByTagNameNS: + return (new SVGDOMNodeListBridge(elem.getElementsByTagNameNS(args[0].toString(exec).string(), args[1].toString(exec).string())))->cache(exec); + case SVGDOMElementBridge::HasAttribute: + return Boolean(elem.hasAttribute(args[0].toString(exec).string())); + case SVGDOMElementBridge::HasAttributeNS: + return Boolean(elem.hasAttributeNS(args[0].toString(exec).string(), args[1].toString(exec).string())); + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return Undefined(); +} + + +// SVGDOMNodeListBridge + +/* +@namespace KSVG +@begin SVGDOMNodeListBridge::s_hashTable 2 + length SVGDOMNodeListBridge::Length DontDelete +@end +@namespace KSVG +@begin SVGDOMNodeListBridgeProto::s_hashTable 3 + getLength SVGDOMNodeListBridge::GetLength DontDelete|Function 0 + item SVGDOMNodeListBridge::Item DontDelete|Function 1 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("DOMNodeList", SVGDOMNodeListBridgeProto, SVGDOMNodeListBridgeProtoFunc) + +Value SVGDOMNodeListBridge::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case Length: + return Number(m_impl.length()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +Value SVGDOMNodeListBridgeProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGDOMNodeListBridge) + DOM::NodeList nodeList = obj->impl(); + + switch(id) + { + case SVGDOMNodeListBridge::GetLength: + return Number(nodeList.length()); + case SVGDOMNodeListBridge::Item: + return getDOMNode(exec, nodeList.item((unsigned long)args[0].toNumber(exec))); + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return Undefined(); +} + +// SVGDOMCharacterDataBridge + +/* +@namespace KSVG +@begin SVGDOMCharacterDataBridge::s_hashTable 3 + data SVGDOMCharacterDataBridge::Data DontDelete + length SVGDOMCharacterDataBridge::Length DontDelete|ReadOnly +@end +@namespace KSVG +@begin SVGDOMCharacterDataBridgeProto::s_hashTable 11 + getData SVGDOMCharacterDataBridge::GetData DontDelete|Function 0 + setData SVGDOMCharacterDataBridge::SetData DontDelete|Function 1 + getLength SVGDOMCharacterDataBridge::GetLength DontDelete|Function 0 + substringData SVGDOMCharacterDataBridge::SubstringData DontDelete|Function 2 + appendData SVGDOMCharacterDataBridge::AppendData DontDelete|Function 1 + insertData SVGDOMCharacterDataBridge::InsertData DontDelete|Function 2 + deleteData SVGDOMCharacterDataBridge::DeleteData DontDelete|Function 2 + replaceData SVGDOMCharacterDataBridge::ReplaceData DontDelete|Function 2 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("DOMCharacterData", SVGDOMCharacterDataBridgeProto, SVGDOMCharacterDataBridgeProtoFunc) + +Value SVGDOMCharacterDataBridge::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case Data: + return String(m_impl.data()); + case Length: + return Number(m_impl.length()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGDOMCharacterDataBridge::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case Data: + m_impl.setData(value.toString(exec).string()); + updateTextItem(exec, m_impl); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +Value SVGDOMCharacterDataBridgeProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGDOMCharacterDataBridge) + DOM::CharacterData node = obj->impl(); + + switch(id) + { + case SVGDOMCharacterDataBridge::GetData: + return String(node.data()); + case SVGDOMCharacterDataBridge::SetData: + node.setData(args[0].toString(exec).string()); + updateTextItem(exec, node); + return Undefined(); + case SVGDOMCharacterDataBridge::GetLength: + return Number(node.length()); + case SVGDOMCharacterDataBridge::SubstringData: + { + DOM::DOMString ret = node.substringData(args[0].toInteger(exec), args[1].toInteger(exec)); + updateTextItem(exec, node); + return String(ret); + } + case SVGDOMCharacterDataBridge::AppendData: + node.appendData(args[0].toString(exec).string()); + updateTextItem(exec, node); + return Undefined(); + case SVGDOMCharacterDataBridge::InsertData: + node.insertData(args[0].toInteger(exec), args[1].toString(exec).string()); + updateTextItem(exec, node); + return Undefined(); + case SVGDOMCharacterDataBridge::DeleteData: + node.deleteData(args[0].toInteger(exec), args[1].toInteger(exec)); + updateTextItem(exec, node); + return Undefined(); + case SVGDOMCharacterDataBridge::ReplaceData: + node.replaceData(args[0].toInteger(exec), args[1].toInteger(exec), args[2].toString(exec).string()); + updateTextItem(exec, node); + return Undefined(); + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return Undefined(); +} + +// SVGDOMTextBridge + +/* +@namespace KSVG +@begin SVGDOMTextBridge::s_hashTable 2 + dummy SVGDOMTextBridge::Dummy DontDelete|ReadOnly +@end +@namespace KSVG +@begin SVGDOMTextBridgeProto::s_hashTable 2 + splitText SVGDOMTextBridge::SplitText DontDelete|Function 1 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("DOMText", SVGDOMTextBridgeProto, SVGDOMTextBridgeProtoFunc) + +Value SVGDOMTextBridge::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +Value SVGDOMTextBridgeProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGDOMTextBridge) + DOM::Text node = obj->impl(); + + switch(id) + { + case SVGDOMTextBridge::SplitText: + return getDOMNode(exec, node.splitText(args[0].toInteger(exec))); + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return Undefined(); +} + +// SVGDOMDOMImplementationBridge + +/* +@namespace KSVG +@begin SVGDOMDOMImplementationBridge::s_hashTable 2 + dummy SVGDOMDOMImplementationBridge::Dummy DontDelete|ReadOnly +@end +@namespace KSVG +@begin SVGDOMDOMImplementationBridgeProto::s_hashTable 2 + hasFeature SVGDOMDOMImplementationBridge::HasFeature DontDelete|Function 2 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("DOMDOMImplementation", SVGDOMDOMImplementationBridgeProto, SVGDOMDOMImplementationBridgeProtoFunc) + +Value SVGDOMDOMImplementationBridge::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +Value SVGDOMDOMImplementationBridgeProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGDOMDOMImplementationBridge) + DOM::DOMImplementation node = obj->impl(); + + switch(id) + { + case SVGDOMDOMImplementationBridge::HasFeature: + return Boolean(node.hasFeature(args[0].toString(exec).string(), args[1].toString(exec).string())); + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return Undefined(); +} + +// SVGDOMDocumentFragmentBridge + +/* +@namespace KSVG +@begin SVGDOMDocumentFragmentBridge::s_hashTable 2 + dummy SVGDOMDocumentFragmentBridge::Dummy DontDelete|ReadOnly +@end +*/ + +Value SVGDOMDocumentFragmentBridge::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGEcma.h b/ksvg/impl/SVGEcma.h new file mode 100644 index 00000000..adf1ec85 --- /dev/null +++ b/ksvg/impl/SVGEcma.h @@ -0,0 +1,250 @@ +/* + Copyright (C) 2002-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. +*/ + +#ifndef SVGEcma_H +#define SVGEcma_H + +#include <dom/dom_doc.h> +#include <dom/dom_node.h> +#include <dom/dom_text.h> +#include <dom/dom_element.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +// Access DOM::Node via js +class SVGDOMNodeBridge +{ +public: + SVGDOMNodeBridge(DOM::Node impl) : m_impl(impl) { KSVG_EMPTY_FLAGS } + virtual ~SVGDOMNodeBridge() { } + + DOM::Node impl() const { return m_impl; } + + KSVG_BASECLASS_GET + KSVG_PUT + + enum + { + // Properties + NodeName, NodeValue, NodeType, ParentNode, + ChildNodes, FirstChild, LastChild, PreviousSibling, + NextSibling, Attributes, NamespaceURI, Prefix, + LocalName, OwnerDocument, + // Functions + InsertBefore, ReplaceChild, RemoveChild, AppendChild, + HasAttributes, HasChildNodes, CloneNode, Normalize, + IsSupported, AddEventListener, RemoveEventListener, Contains, + GetNodeName, GetNodeValue, GetNodeType, GetParentNode, + GetChildNodes, GetFirstChild, GetLastChild, GetPreviousSibling, + GetNextSibling, GetAttributes, GetNamespaceURI, GetPrefix, + GetLocalName, GetOwnerDocument + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); + +private: + DOM::Node m_impl; +}; + +// Access DOM::Element via js +class SVGDOMElementBridge : public SVGDOMNodeBridge +{ +public: + SVGDOMElementBridge(DOM::Element impl) : SVGDOMNodeBridge(static_cast<DOM::Node>(impl)), m_impl(impl) { } + ~SVGDOMElementBridge() { } + + DOM::Element impl() const { return m_impl; } + + KSVG_GET + KSVG_FORWARDPUT + + enum + { + // Properties + TagName, + // Functions + GetAttribute, SetAttribute, RemoveAttribute, GetAttributeNode, + SetAttributeNode, RemoveAttributeNode, GetElementsByTagName, + GetAttributeNS, SetAttributeNS, RemoveAttributeNS, GetAttributeNodeNS, + SetAttributeNodeNS, GetElementsByTagNameNS, HasAttribute, HasAttributeNS + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + +private: + DOM::Element m_impl; +}; + +// Access DOM::NodeList via js +class SVGDOMNodeListBridge +{ +public: + SVGDOMNodeListBridge(DOM::NodeList impl) : m_impl(impl) { } + ~SVGDOMNodeListBridge() { } + + DOM::NodeList impl() const { return m_impl; } + + KSVG_GET + + enum + { + // Properties + Length, + // Functions + GetLength, Item + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + +private: + DOM::NodeList m_impl; +}; + +// Access DOM::CharacterData via js +class SVGDOMCharacterDataBridge : public SVGDOMNodeBridge +{ +public: + SVGDOMCharacterDataBridge(DOM::CharacterData impl) : SVGDOMNodeBridge(static_cast<DOM::Node>(impl)), m_impl(impl) { KSVG_EMPTY_FLAGS } + ~SVGDOMCharacterDataBridge() { } + + DOM::CharacterData impl() const { return m_impl; } + + KSVG_GET + KSVG_PUT + + enum + { + // Properties + Data, Length, + // Functions + GetData, SetData, GetLength, + SubstringData, AppendData, InsertData, DeleteData, ReplaceData + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); + +private: + DOM::CharacterData m_impl; +}; + +// Access DOM::Text via js +class SVGDOMTextBridge : public SVGDOMCharacterDataBridge +{ +public: + SVGDOMTextBridge(DOM::Text impl) : SVGDOMCharacterDataBridge(static_cast<DOM::CharacterData>(impl)), m_impl(impl) { } + ~SVGDOMTextBridge() { } + + DOM::Text impl() const { return m_impl; } + + KSVG_GET + KSVG_FORWARDPUT + + enum + { + // Properties + Dummy, + // Functions + SplitText + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + +private: + DOM::Text m_impl; +}; + +// Access DOM::DOMImplementation via js +class SVGDOMDOMImplementationBridge +{ +public: + SVGDOMDOMImplementationBridge(DOM::DOMImplementation impl) : m_impl(impl) { } + ~SVGDOMDOMImplementationBridge() { } + + DOM::DOMImplementation impl() const { return m_impl; } + + KSVG_GET + KSVG_FORWARDPUT + + enum + { + // Properties + Dummy, + // Functions + HasFeature + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + +private: + DOM::DOMImplementation m_impl; +}; + +// Access DOM::DocumentFragment via js +class SVGDOMDocumentFragmentBridge : public SVGDOMNodeBridge +{ +public: + SVGDOMDocumentFragmentBridge(DOM::DocumentFragment impl) : SVGDOMNodeBridge(static_cast<DOM::Node>(impl)), m_impl(impl) { } + ~SVGDOMDocumentFragmentBridge() { } + + DOM::DocumentFragment impl() const { return m_impl; } + + KSVG_GET + KSVG_FORWARDPUT + + enum + { + // Properties + Dummy + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + +private: + DOM::DocumentFragment m_impl; +}; + +} + +KSVG_DEFINE_PROTOTYPE(SVGDOMNodeBridgeProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGDOMNodeBridgeProtoFunc, SVGDOMNodeBridge) + +KSVG_DEFINE_PROTOTYPE(SVGDOMElementBridgeProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGDOMElementBridgeProtoFunc, SVGDOMElementBridge) + +KSVG_DEFINE_PROTOTYPE(SVGDOMNodeListBridgeProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGDOMNodeListBridgeProtoFunc, SVGDOMNodeListBridge) + +KSVG_DEFINE_PROTOTYPE(SVGDOMCharacterDataBridgeProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGDOMCharacterDataBridgeProtoFunc, SVGDOMCharacterDataBridge) + +KSVG_DEFINE_PROTOTYPE(SVGDOMTextBridgeProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGDOMTextBridgeProtoFunc, SVGDOMTextBridge) + +KSVG_DEFINE_PROTOTYPE(SVGDOMDOMImplementationBridgeProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGDOMDOMImplementationBridgeProtoFunc, SVGDOMDOMImplementationBridge) + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGElementImpl.cc b/ksvg/impl/SVGElementImpl.cc new file mode 100644 index 00000000..2f3d70c6 --- /dev/null +++ b/ksvg/impl/SVGElementImpl.cc @@ -0,0 +1,713 @@ +/* + 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 <qxml.h> + +#include <kdebug.h> + +#include "SVGEvent.h" +#include "SVGEventImpl.h" +#include "SVGHelperImpl.h" +#include "SVGElementImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGSVGElementImpl.h" + +using namespace KSVG; + +#include "SVGElementImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_ecma.h" + +SVGElementImpl::Factory *SVGElementImpl::Factory::m_instance = 0; + +SVGElementImpl::SVGElementImpl(DOM::ElementImpl *impl) : DOM::DomShared(), DOM::Element(impl), SVGDOMElementBridge(static_cast<DOM::Element>(*this)) +{ + KSVG_EMPTY_FLAGS + + m_ownerSVGElement = 0; + m_viewportElement = 0; + m_ownerDoc = 0; + + m_mouseOver = false; + m_focus = false; + + m_eventListeners.setAutoDelete(true); + m_attributes.setAutoDelete(true); +} + +SVGElementImpl::~SVGElementImpl() +{ + if(m_ownerSVGElement) + m_ownerSVGElement->deref(); +} + +void SVGElementImpl::setEventListener(int id, SVGEventListener *listener) +{ + if(listener) + listener->ref(); + + removeEventListener(id); + + if(listener) + { + SVGRegisteredEventListener *rl = new SVGRegisteredEventListener(static_cast<SVGEvent::EventId>(id), listener, false); + m_eventListeners.append(rl); + + listener->deref(); + } +} + +int SVGElementImpl::getEventListeners(bool local) +{ + int events = 0; + + QPtrListIterator<SVGRegisteredEventListener> it(m_eventListeners); + for(; it.current(); ++it) + events |= (1 << it.current()->id); + + if(local) + return events; + + for(DOM::Node node = parentNode(); !node.isNull(); node = node.parentNode()) + { + SVGElementImpl *element = ownerDoc()->getElementFromHandle(node.handle()); + + if(element) + { + QPtrListIterator<SVGRegisteredEventListener> it(element->m_eventListeners); + for(; it.current(); ++it) + events |= (1 << it.current()->id); + } + } + + return events; +} + +void SVGElementImpl::setupEventListeners(SVGDocumentImpl *doc, SVGDocumentImpl *newDoc) +{ + if(!doc || !newDoc) + return; + + // Changes the document where the eventlisteners are registered + // Needed for parseXML'ed elements with events, their listeners + // are created in the temporary document fragment and need to be + // registered in the main document (Niko) + QPtrListIterator<SVGRegisteredEventListener> it(m_eventListeners); + for(; it.current(); ++it) + { + SVGRegisteredEventListener *current = it.current(); + + QString valueOfCurrent = newDoc->ecmaEngine()->valueOfEventListener(current->listener); + setEventListener(current->id, doc->createEventListener(valueOfCurrent)); + } +} + +bool SVGElementImpl::hasEventListener(int id, bool local) +{ + // First check if we have the listener, locally + QPtrListIterator<SVGRegisteredEventListener> it(m_eventListeners); + for(; it.current(); ++it) + { + if(it.current()->id == id) + return true; + } + + // We have no local listeners, if we are just interessted + // in those listeners, then return now... + if(local) + return false; + + // Check every parent element + for(DOM::Node node = parentNode(); !node.isNull(); node = node.parentNode()) + { + SVGElementImpl *element = ownerDoc()->getElementFromHandle(node.handle()); + + if(element) + { + QPtrListIterator<SVGRegisteredEventListener> it(element->m_eventListeners); + for(; it.current(); ++it) + { + if(it.current()->id == id) + return true; + } + } + } + + return false; +} + +void SVGElementImpl::removeEventListener(int id) +{ + QPtrListIterator<SVGRegisteredEventListener> it(m_eventListeners); + for(; it.current(); ++it) + { + if(it.current()->id == id) + { + m_eventListeners.removeRef(it.current()); + break; + } + } +} + +void SVGElementImpl::handleLocalEvents(SVGEventImpl *evt, bool useCapture) +{ + QPtrListIterator<SVGRegisteredEventListener> it(m_eventListeners); + for(; it.current(); ++it) + { + if(it.current()->id == evt->id() && it.current()->useCapture == useCapture) + { + it.current()->listener->handleEvent(evt); + break; + } + } +} + +void SVGElementImpl::defaultEventHandler(SVGEventImpl *) +{ +} + +/* +@namespace KSVG +@begin SVGElementImpl::s_hashTable 23 + id SVGElementImpl::ElementId DontDelete + ownerSVGElement SVGElementImpl::OwnerSvgElement DontDelete|ReadOnly + viewportElement SVGElementImpl::ViewportElement DontDelete|ReadOnly + xmlbase SVGElementImpl::XmlBase DontDelete + base SVGElementImpl::XmlBase DontDelete + onmouseup SVGElementImpl::OnMouseUp DontDelete + onmousedown SVGElementImpl::OnMouseDown DontDelete + onmousemove SVGElementImpl::OnMouseMove DontDelete + onmouseover SVGElementImpl::OnMouseOver DontDelete + onmouseout SVGElementImpl::OnMouseOut DontDelete + onclick SVGElementImpl::OnClick DontDelete + onmouseclick SVGElementImpl::OnClick DontDelete + onactivate SVGElementImpl::OnActivate DontDelete + onkeydown SVGElementImpl::OnKeyDown DontDelete + onkeyup SVGElementImpl::OnKeyUp DontDelete + onkeypress SVGElementImpl::OnKeyPress DontDelete + onload SVGElementImpl::OnLoad DontDelete + onfocusin SVGElementImpl::OnFocusIn DontDelete + onfocusout SVGElementImpl::OnFocusOut DontDelete + onerror SVGElementImpl::OnError DontDelete + onabort SVGElementImpl::OnAbort DontDelete +@end +@namespace KSVG +@begin SVGElementImplProto::s_hashTable 5 + getStyle SVGElementImpl::GetStyle DontDelete|Function 0 + setProperty SVGElementImpl::SetProperty DontDelete|Function 2 + getPropertyValue SVGElementImpl::GetPropertyValue DontDelete|Function 1 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGElement", SVGElementImplProto, SVGElementImplProtoFunc) + +Value SVGElementImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case ElementId: + return String(id().string()); + case XmlBase: + return String(xmlbase().string()); + case OwnerSvgElement: + return getDOMNode(exec, *ownerSVGElement()); + case ViewportElement: + return getDOMNode(exec, *viewportElement()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGElementImpl::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case ElementId: + setId(value.toString(exec).string()); + break; + case XmlBase: + setXmlbase(value.toString(exec).string()); + break; + case OnMouseUp: + setEventListener(SVGEvent::MOUSEUP_EVENT, m_ownerDoc->createEventListener(value.toString(exec).string())); + break; + case OnMouseDown: + setEventListener(SVGEvent::MOUSEDOWN_EVENT, m_ownerDoc->createEventListener(value.toString(exec).string())); + break; + case OnMouseMove: + setEventListener(SVGEvent::MOUSEMOVE_EVENT, m_ownerDoc->createEventListener(value.toString(exec).string())); + break; + case OnMouseOver: + setEventListener(SVGEvent::MOUSEOVER_EVENT, m_ownerDoc->createEventListener(value.toString(exec).string())); + break; + case OnMouseOut: + setEventListener(SVGEvent::MOUSEOUT_EVENT, m_ownerDoc->createEventListener(value.toString(exec).string())); + break; + case OnClick: + setEventListener(SVGEvent::CLICK_EVENT, m_ownerDoc->createEventListener(value.toString(exec).string())); + break; + case OnActivate: + setEventListener(SVGEvent::DOMACTIVATE_EVENT, m_ownerDoc->createEventListener(value.toString(exec).string())); + break; + case OnKeyDown: + setEventListener(SVGEvent::KEYDOWN_EVENT, m_ownerDoc->createEventListener(value.toString(exec).string())); + break; + case OnKeyUp: + setEventListener(SVGEvent::KEYUP_EVENT, m_ownerDoc->createEventListener(value.toString(exec).string())); + break; + case OnKeyPress: + setEventListener(SVGEvent::KEYPRESS_EVENT, m_ownerDoc->createEventListener(value.toString(exec).string())); + break; + case OnLoad: + setEventListener(SVGEvent::LOAD_EVENT, m_ownerDoc->createEventListener(value.toString(exec).string())); + break; + case OnFocusIn: + setEventListener(SVGEvent::DOMFOCUSIN_EVENT, m_ownerDoc->createEventListener(value.toString(exec).string())); + break; + case OnFocusOut: + setEventListener(SVGEvent::DOMFOCUSOUT_EVENT, m_ownerDoc->createEventListener(value.toString(exec).string())); + break; + case OnError: + setEventListener(SVGEvent::ERROR_EVENT, m_ownerDoc->createEventListener(value.toString(exec).string())); + break; + case OnAbort: + setEventListener(SVGEvent::ABORT_EVENT, m_ownerDoc->createEventListener(value.toString(exec).string())); + break; + default: + kdWarning() << k_funcinfo << "unhandled token " << token << endl; + } +} + +Value SVGElementImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGElementImpl) + + switch(id) + { + case SVGElementImpl::GetStyle: + return obj->cache(exec); + case SVGElementImpl::SetProperty: + { + DOM::DOMString attribute = args[0].toString(exec).qstring().lower(); + DOM::DOMString value = args[1].toString(exec).qstring(); + obj->setAttribute(attribute, value); + break; + } + case SVGElementImpl::GetPropertyValue: + return String(obj->getAttribute(args[0].toString(exec).qstring())); + default: + break; + } + + return Undefined(); +} + +QDict<DOM::DOMString> &SVGElementImpl::attributes() +{ + return m_attributes; +} + +// khtml overrides +void SVGElementImpl::setAttribute(const DOM::DOMString &name, const DOM::DOMString &value) +{ + m_attributes.replace(name.string(), new DOM::DOMString(value)); +} + +// Changes internal value. This will have no effect on getAttribute(). +void SVGElementImpl::setAttributeInternal(const DOM::DOMString &name, const DOM::DOMString &value) +{ + ExecState *exec = ownerDoc()->ecmaEngine()->globalExec(); + + static_cast<KSVGScriptInterpreter *>(exec->interpreter())->setAttributeSetMode(true); + bridge(exec)->put(exec, Identifier(UString(name)), String(value), KJS::Internal); + static_cast<KSVGScriptInterpreter *>(exec->interpreter())->setAttributeSetMode(false); +} + +// This gets the actual attribute as set in the svg source +DOM::DOMString SVGElementImpl::getAttribute(const DOM::DOMString &name) const +{ + DOM::DOMString *result = m_attributes[name.string()]; + if(result) + return *result; + else + return DOM::DOMString(); +} + +// This gets the internal, real-time value. This means it can return a default value +// for an attribute even if its not explicitly set in the svg source. +DOM::DOMString SVGElementImpl::getAttributeInternal(const DOM::DOMString &name) +{ + ExecState *exec = ownerDoc()->ecmaEngine()->globalExec(); + + DOM::DOMString retVal; + + static_cast<KSVGScriptInterpreter *>(exec->interpreter())->setAttributeGetMode(true); + retVal = bridge(exec)->get(exec, Identifier(UString(name))).toString(exec).string(); + static_cast<KSVGScriptInterpreter *>(exec->interpreter())->setAttributeGetMode(false); + + return retVal; +} + +bool SVGElementImpl::hasAttribute(const DOM::DOMString &name) +{ + return m_attributes.find(name.string()) != 0; +} + +bool SVGElementImpl::hasAttributes() +{ + return m_attributes.count() > 0; +} + +void SVGElementImpl::setApplyAttribute(const QString &name, const QString &value) +{ + if(hasAttribute(name)) + { + QString cur = getAttribute(name).string(); + cur = cur.simplifyWhiteSpace(); + + if(!cur.endsWith(";")) + cur += "; "; + + cur += value; + + setAttribute(name, cur); + } + else + setAttribute(name, value); +} + +void SVGElementImpl::setId(DOM::DOMString id) +{ + setAttribute("id", id); + + if(ownerDoc() && ownerDoc()->rootElement() && !id.isEmpty()) + ownerDoc()->rootElement()->addToIdMap(id.string(), this); + else if(m_ownerSVGElement && !id.isEmpty()) + m_ownerSVGElement->addToIdMap(id.string(), this); +} + +DOM::DOMString SVGElementImpl::id() const +{ + return getAttribute("id"); +} + +void SVGElementImpl::setXmlbase(DOM::DOMString xmlbase) +{ + setAttribute("xml:base", xmlbase); +} + +DOM::DOMString SVGElementImpl::xmlbase() const +{ + return getAttribute("xml:base"); +} + +void SVGElementImpl::setOwnerSVGElement(SVGSVGElementImpl *owner) +{ + if(m_ownerSVGElement) + m_ownerSVGElement->deref(); + + m_ownerSVGElement = owner; + + if(m_ownerSVGElement) + m_ownerSVGElement->ref(); +} + +void SVGElementImpl::setViewportElement(SVGElementImpl *viewport) +{ + if(m_viewportElement) + m_viewportElement->deref(); + + m_viewportElement = viewport; + + if(m_viewportElement) + m_viewportElement->ref(); +} + +SVGSVGElementImpl *SVGElementImpl::ownerSVGElement() const +{ + return m_ownerSVGElement; +} + +SVGElementImpl *SVGElementImpl::viewportElement() const +{ + return m_viewportElement; +} + +void SVGElementImpl::setAttributes(const QXmlAttributes &attrs) +{ + for(int i = 0; i < attrs.length(); i++) + { + setAttribute(attrs.localName(i), attrs.value(i)); + setAttributeInternal(attrs.localName(i), attrs.value(i)); + } + + setAttributes(); +} + +void SVGElementImpl::setAttributes() +{ + // Finalize style + SVGStylableImpl *style = dynamic_cast<SVGStylableImpl *>(this); + + if(style) + style->processStyle(); +} + +void SVGElementImpl::setAttributes(bool deep) +{ + // Finalize style + SVGStylableImpl *style = dynamic_cast<SVGStylableImpl *>(this); + + if(style) + style->processStyle(); + + if(deep) + { + if(hasChildNodes()) + { + DOM::Node n; + for(n = firstChild(); !n.isNull(); n = n.nextSibling()) + { + SVGElementImpl *elem = ownerDoc()->getElementFromHandle(n.handle()); + if(elem) + elem->setAttributes(true); + } + } + } +} + +bool SVGElementImpl::prepareMouseEvent(const QPoint &p, const QPoint &a, SVGMouseEventImpl *mev) +{ + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(this); + if(shape) + return shape->prepareMouseEvent(p, a, mev); + + return false; +} + +bool SVGElementImpl::dispatchEvent(int id, bool canBubbleArg, bool cancelableArg) +{ + SVGEventImpl *evt = new SVGEventImpl(static_cast<SVGEvent::EventId>(id), canBubbleArg, cancelableArg); + + evt->ref(); + bool ret = dispatchEvent(evt, true); + evt->deref(); + + return ret; +} + +bool SVGElementImpl::dispatchEvent(SVGEventImpl *evt, bool tempEvent) +{ + evt->setTarget(this); + + // Find out, where to send to -> collect parent nodes + QPtrList<SVGElementImpl> nodeChain; + + for(DOM::Element e = *this; !e.isNull(); e = e.parentNode()) + nodeChain.prepend(ownerDoc()->getElementFromHandle(e.handle())); + + // Trigger any capturing event handlers on our way down + evt->setEventPhase(DOM::Event::CAPTURING_PHASE); + + QPtrListIterator<SVGElementImpl> it(nodeChain); + for(; it.current() && it.current() != this && !evt->propagationStopped(); ++it) + { + evt->setCurrentTarget(it.current()); + + if(it.current()) + it.current()->handleLocalEvents(evt, true); + } + + // Dispatch to the actual target node + it.toLast(); + if(!evt->propagationStopped()) + { + evt->setEventPhase(DOM::Event::AT_TARGET); + evt->setCurrentTarget(it.current()); + + if(it.current()) + it.current()->handleLocalEvents(evt, false); + } + + --it; + + // Bubble up again + if(evt->bubbles()) + { + evt->setEventPhase(DOM::Event::BUBBLING_PHASE); + for(; it.current() && !evt->propagationStopped(); --it) + { + evt->setCurrentTarget(it.current()); + + if(it.current()) + it.current()->handleLocalEvents(evt, false); + } + } + + evt->setCurrentTarget(0); + evt->setEventPhase(0); // I guess this is correct, the spec does not seem to say + // anything about the default event handler phase. + + if(evt->bubbles()) + { + // now we call all default event handlers (this is not part of DOM - it is internal to ksvg) + it.toLast(); + for(; it.current() && !evt->propagationStopped() && !evt->defaultPrevented() && !evt->defaultHandled(); --it) + it.current()->defaultEventHandler(evt); + } + + // If tempEvent is true, this means that the DOM implementation will not be storing a reference to the event, i.e. + // there is no way to retrieve it from javascript if a script does not already have a reference to it in a variable. + // So there is no need for the interpreter to keep the event in its cache + if(tempEvent) + ownerDoc()->ecmaEngine()->finishedWithEvent(evt); + + return !evt->defaultPrevented(); // ### what if defaultPrevented was called before dispatchEvent? +} + +bool SVGElementImpl::dispatchKeyEvent(QKeyEvent *ke) +{ + DOM::AbstractView temp; + + SVGEvent::EventId evtId = SVGEvent::UNKNOWN_EVENT; + + if(ke->type() == QEvent::KeyRelease && !ke->isAutoRepeat()) + evtId = SVGEvent::KEYUP_EVENT; + else if(ke->isAutoRepeat()) + evtId = SVGEvent::KEYPRESS_EVENT; + else if(ke->type() == QEvent::KeyPress) + evtId = SVGEvent::KEYDOWN_EVENT; + + if(evtId == SVGEvent::KEYUP_EVENT && hasEventListener(SVGEvent::DOMACTIVATE_EVENT, false)) + dispatchEvent(SVGEvent::DOMACTIVATE_EVENT, true, true); + + if(!hasEventListener(evtId, false)) + return false; + + SVGEventImpl *evt = new SVGKeyEventImpl(ke, temp, evtId); + + evt->ref(); + bool ret = dispatchEvent(evt, true); + evt->deref(); + + // Rerender now! Once! (Niko) + ownerDoc()->rerender(); + + return ret; +} + +bool SVGElementImpl::dispatchMouseEvent(int id, bool canBubbleArg, bool cancelableArg, long detailArg, long screenXArg, long screenYArg, long clientXArg, long clientYArg, bool ctrlKeyArg, bool altKeyArg, bool shiftKeyArg, bool metaKeyArg, unsigned short buttonArg, SVGElementImpl *relatedTargetArg) +{ + DOM::AbstractView temp; + + SVGEventImpl *evt = new SVGMouseEventImpl(static_cast<SVGEvent::EventId>(id), + canBubbleArg, cancelableArg, temp, detailArg, + screenXArg, screenYArg, + clientXArg, clientYArg, + ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg, + buttonArg, relatedTargetArg); + + evt->ref(); + bool ret = dispatchEvent(evt, true); + evt->deref(); + + return ret; +} + +void SVGElementImpl::setOwnerDoc(SVGDocumentImpl *doc) +{ + if(m_ownerDoc) + m_ownerDoc->removeFromElemDict(handle()); + + m_ownerDoc = doc; + + if(m_ownerDoc) + m_ownerDoc->addToElemDict(handle(), this); +} + +SVGDocumentImpl *SVGElementImpl::ownerDoc() const +{ + return m_ownerDoc; +} + +SVGElementImpl *SVGElementImpl::cloneNode(bool deep) +{ + DOM::Element impl = static_cast<DOM::Document *>(ownerDoc())->createElementNS("", tagName()); + SVGElementImpl *newElement = SVGDocumentImpl::createElement(tagName(), impl.cloneNode(false), ownerDoc()); + newElement->setOwnerSVGElement(ownerSVGElement()); + newElement->setViewportElement(viewportElement()); + + SVGHelperImpl::copyAttributes(this, newElement); + + // Recalc style + //newElement->setAttributes(); + + if(deep) + cloneChildNodes(newElement); + + return newElement; +} + +void SVGElementImpl::cloneChildNodes(SVGElementImpl *clone) +{ + DOM::Node n; + for(n = firstChild(); !n.isNull(); n = n.nextSibling()) + { + SVGElementImpl *elem = ownerDoc()->getElementFromHandle(n.handle()); + if(elem) + clone->appendChild(*elem->cloneNode(true)); + else if(n.nodeType() == DOM::Node::TEXT_NODE) + clone->appendChild(n.cloneNode(true)); + } +} + +void SVGElementImpl::gotError(const QString &errorDesc) +{ + if(ownerDoc()) + { + ownerDoc()->finishParsing(true, errorDesc); + if(hasEventListener(SVGEvent::ERROR_EVENT, true)) + dispatchEvent(SVGEvent::ERROR_EVENT, false, false); + } +} + +QString SVGElementImpl::collectText() +{ + QString text; + + if(hasChildNodes()) + { + DOM::Node node = firstChild(); + + for(; !node.isNull(); node = node.nextSibling()) + { + if(node.nodeType() == DOM::Node::TEXT_NODE) + { + DOM::Text textNode = node; + text += textNode.data().string(); + } + } + } + + return text; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGElementImpl.h b/ksvg/impl/SVGElementImpl.h new file mode 100644 index 00000000..c69a83e8 --- /dev/null +++ b/ksvg/impl/SVGElementImpl.h @@ -0,0 +1,229 @@ +/* + 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. +*/ + +#ifndef SVGElementImpl_H +#define SVGElementImpl_H + +#include <map> +#include <string> + +#include <qdict.h> +#include <qptrlist.h> + +#include <dom/dom_string.h> + +#include "SVGEcma.h" + +#include "ksvg_lookup.h" + +class QKeyEvent; +class QXmlAttributes; + +namespace KJS +{ + class Value; + class UString; + class ExecState; +} + +namespace KSVG +{ + +class KSVGCanvas; +class SVGEventImpl; +class SVGDocumentImpl; +class SVGEventListener; +class SVGSVGElementImpl; +class SVGMouseEventImpl; +class SVGRegisteredEventListener; +class SVGElementImpl : virtual public DOM::DomShared, + public DOM::Element, + public SVGDOMElementBridge +{ +public: + SVGElementImpl(DOM::ElementImpl *impl); + virtual ~SVGElementImpl(); + + // Attribute setting + // "Override" khtml's functions with ours + void setAttribute(const DOM::DOMString &name, const DOM::DOMString &value); + void setAttributeInternal(const DOM::DOMString &name, const DOM::DOMString &value); + DOM::DOMString getAttribute(const DOM::DOMString &name) const; + DOM::DOMString getAttributeInternal(const DOM::DOMString &name); + bool hasAttribute(const DOM::DOMString &name); + bool hasAttributes(); + + QDict<DOM::DOMString> &attributes(); + void setApplyAttribute(const QString &name, const QString &value); + + void setId(DOM::DOMString); + DOM::DOMString id() const; + + void setXmlbase(DOM::DOMString); + DOM::DOMString xmlbase() const; + + void setOwnerSVGElement(SVGSVGElementImpl *owner); + void setViewportElement(SVGElementImpl *viewport); + + SVGSVGElementImpl *ownerSVGElement() const; + SVGElementImpl *viewportElement() const; + + void setAttributes(const QXmlAttributes &); + virtual void setAttributes(); + void setAttributes(bool deep); + + QString collectText(); + + void setOwnerDoc(SVGDocumentImpl *doc); + SVGDocumentImpl *ownerDoc() const; + + virtual SVGElementImpl *cloneNode(bool deep); + void cloneChildNodes(SVGElementImpl *clone); + + // Event stuff + bool dispatchEvent(int id, bool canBubbleArg, bool cancelableArg); + bool dispatchEvent(SVGEventImpl *evt, bool tempEvent); + bool dispatchMouseEvent(int id, bool canBubbleArg, bool cancelableArg, long detailArg, long screenXArg, long screenYArg, long clientXArg, long clientYArg, bool ctrlKeyArg, bool altKeyArg, bool shiftKeyArg, bool metaKeyArg, unsigned short buttonArg, SVGElementImpl *relatedTargetArg); + bool dispatchKeyEvent(QKeyEvent *ke); + + void setEventListener(int id, SVGEventListener *listener); + bool hasEventListener(int id, bool local); + int getEventListeners(bool local); + void removeEventListener(int id); + void setupEventListeners(SVGDocumentImpl *doc, SVGDocumentImpl *newDoc); + + // Use with care! Internal only. + const QPtrList<SVGRegisteredEventListener> &eventListeners() { return m_eventListeners; } + + void handleLocalEvents(SVGEventImpl *evt, bool useCapture); + virtual void defaultEventHandler(SVGEventImpl *evt); + + bool mouseOver() { return m_mouseOver; } + void setMouseOver(bool v) { m_mouseOver = v; } + + bool focus() { return m_focus; } + void setFocus(bool v) { m_focus = v; } + + virtual bool prepareMouseEvent(const QPoint &, const QPoint &, SVGMouseEventImpl *); + + virtual void createItem(KSVGCanvas *c = 0) { Q_UNUSED(c); } + virtual void removeItem(KSVGCanvas *c) { Q_UNUSED(c); } + + // Element creation + typedef SVGElementImpl *(*FactoryFn)(DOM::ElementImpl *impl); + class Factory + { + public: + static Factory *self() + { + if(!m_instance) + m_instance = new Factory(); + + return m_instance; + } + + void announce(SVGElementImpl::FactoryFn factoryFn, const std::string &tag) + { + if(m_elementMap.find(tag) == m_elementMap.end()) + m_elementMap[tag] = factoryFn; + } + + SVGElementImpl *create(const std::string &tag, DOM::ElementImpl *impl) const + { + ElementMap::const_iterator it = m_elementMap.find(tag); + if(it != m_elementMap.end()) + return it->second(impl); + return 0; + } + + private: + Factory() { } + Factory(const Factory &rhs); + Factory &operator=(const Factory &rhs); + + static Factory *m_instance; + + typedef std::map<std::string, SVGElementImpl::FactoryFn> ElementMap; + mutable ElementMap m_elementMap; + }; + + template <class T> + class Registrar + { + public: + Registrar(const std::string &tag) + { + SVGElementImpl::Factory::self()->announce(&factoryFn, tag); + } + + static SVGElementImpl *factoryFn(DOM::ElementImpl *impl) + { + return new T(impl); + } + }; + +#define KSVG_REGISTER_ELEMENT(Class, Tag) \ + static SVGElementImpl::Registrar<Class> Class##Registrar(Tag); + +protected: + void gotError(const QString &errorDesc); + +private: + SVGSVGElementImpl *m_ownerSVGElement; + SVGElementImpl *m_viewportElement; + SVGDocumentImpl *m_ownerDoc; + + bool m_mouseOver : 1; + bool m_focus : 1; + + QPtrList<SVGRegisteredEventListener> m_eventListeners; + QDict<DOM::DOMString> m_attributes; + +public: + KSVG_BASECLASS_GET + KSVG_PUT + + virtual KJS::ObjectImp *bridge(KJS::ExecState *exec) const; // NEEDS TO BE VIRTUAL HERE + + enum + { + // Properties + ElementId, OwnerSvgElement, ViewportElement, XmlBase, + OnMouseUp, OnMouseDown, OnMouseMove, OnMouseOver, OnMouseOut, + OnClick, OnActivate, OnKeyDown, OnKeyUp, OnKeyPress, OnLoad, + OnFocusIn, OnFocusOut, OnError, OnAbort, + // Functions + GetStyle, + // these do not really belong here, but the css doesnt work yet... + SetProperty, GetPropertyValue + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +KSVG_DEFINE_PROTOTYPE(SVGElementImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGElementImplProtoFunc, SVGElementImpl) + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGElementInstanceImpl.cc b/ksvg/impl/SVGElementInstanceImpl.cc new file mode 100644 index 00000000..97cd28a2 --- /dev/null +++ b/ksvg/impl/SVGElementInstanceImpl.cc @@ -0,0 +1,108 @@ +/* + 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 "SVGElementImpl.h" +#include "SVGUseElementImpl.h" +#include "SVGElementInstanceImpl.h" +#include "SVGElementInstanceListImpl.h" + +using namespace KSVG; + +SVGElementInstanceImpl::SVGElementInstanceImpl()//FIXME : events::EventTarget() +{ + m_correspondingElement = 0; + m_correspondingUseElement = 0; + m_parentNode = 0; + m_childNodes = 0; + m_firstChild = 0; + m_lastChild = 0; + m_previousSibling = 0; + m_nextSibling = 0; +} + +SVGElementInstanceImpl::~SVGElementInstanceImpl() +{ + if(m_correspondingElement) + m_correspondingElement->deref(); + if(m_correspondingUseElement) + m_correspondingUseElement->deref(); + if(m_parentNode) + m_parentNode->deref(); + if(m_childNodes) + m_childNodes->deref(); + if(m_firstChild) + m_firstChild->deref(); + if(m_lastChild) + m_lastChild->deref(); + if(m_previousSibling) + m_previousSibling->deref(); + if(m_nextSibling) + m_nextSibling->deref(); +} + +void SVGElementInstanceImpl::setCorrespondingElement(SVGElementImpl *corresponding) +{ + m_correspondingElement = corresponding; + + if(m_correspondingElement) + m_correspondingElement->ref(); +} + +SVGElementImpl *SVGElementInstanceImpl::correspondingElement() const +{ + return m_correspondingElement; +} + +SVGUseElementImpl *SVGElementInstanceImpl::correspondingUseElement() const +{ + return m_correspondingUseElement; +} + +SVGElementInstanceImpl *SVGElementInstanceImpl::parentNode() const +{ + return m_parentNode; +} + +SVGElementInstanceListImpl *SVGElementInstanceImpl::childNodes() const +{ + return m_childNodes; +} + +SVGElementInstanceImpl *SVGElementInstanceImpl::firstChild() const +{ + return m_firstChild; +} + +SVGElementInstanceImpl *SVGElementInstanceImpl::lastChild() const +{ + return m_lastChild; +} + +SVGElementInstanceImpl *SVGElementInstanceImpl::previousSibling() const +{ + return m_previousSibling; +} + +SVGElementInstanceImpl *SVGElementInstanceImpl::nextSibling() const +{ + return m_nextSibling; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGElementInstanceImpl.h b/ksvg/impl/SVGElementInstanceImpl.h new file mode 100644 index 00000000..d9f3afae --- /dev/null +++ b/ksvg/impl/SVGElementInstanceImpl.h @@ -0,0 +1,70 @@ +/* + 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. +*/ + +#ifndef SVGElementInstanceImpl_H +#define SVGElementInstanceImpl_H + +#include <dom/dom_misc.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGElementImpl; +class SVGUseElementImpl; +class SVGElementInstanceImpl; +class SVGElementInstanceListImpl; +class SVGElementInstanceImpl : public DOM::DomShared +{ +public: + SVGElementInstanceImpl(); + virtual ~SVGElementInstanceImpl(); + + SVGElementImpl *correspondingElement() const; + SVGUseElementImpl *correspondingUseElement() const; + SVGElementInstanceImpl *parentNode() const; + SVGElementInstanceListImpl *childNodes() const; + SVGElementInstanceImpl *firstChild() const; + SVGElementInstanceImpl *lastChild() const; + SVGElementInstanceImpl *previousSibling() const; + SVGElementInstanceImpl *nextSibling() const; + + void setCorrespondingElement(SVGElementImpl *); + +private: + SVGElementImpl *m_correspondingElement; + SVGUseElementImpl *m_correspondingUseElement; + SVGElementInstanceImpl *m_parentNode; + SVGElementInstanceListImpl *m_childNodes; + SVGElementInstanceImpl *m_firstChild; + SVGElementInstanceImpl *m_lastChild; + SVGElementInstanceImpl *m_previousSibling; + SVGElementInstanceImpl *m_nextSibling; + +public: + //KSVG_FORWARDGET +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGElementInstanceListImpl.cc b/ksvg/impl/SVGElementInstanceListImpl.cc new file mode 100644 index 00000000..187255ab --- /dev/null +++ b/ksvg/impl/SVGElementInstanceListImpl.cc @@ -0,0 +1,44 @@ +/* + 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 "SVGElementInstanceImpl.h" +#include "SVGElementInstanceListImpl.h" + +using namespace KSVG; + +SVGElementInstanceListImpl::SVGElementInstanceListImpl() +{ +} + +SVGElementInstanceListImpl::~SVGElementInstanceListImpl() +{ +} + +unsigned long SVGElementInstanceListImpl::length() const +{ + return m_length; +} + +SVGElementInstanceImpl *SVGElementInstanceListImpl::item(unsigned long /*index*/) +{ + return 0; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGElementInstanceListImpl.h b/ksvg/impl/SVGElementInstanceListImpl.h new file mode 100644 index 00000000..c9ac0dd2 --- /dev/null +++ b/ksvg/impl/SVGElementInstanceListImpl.h @@ -0,0 +1,49 @@ +/* + 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. +*/ + +#ifndef SVGElementInstanceListImpl_H +#define SVGElementInstanceListImpl_H + +#include <dom/dom_misc.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGElementInstanceImpl; +class SVGElementInstanceListImpl : public DOM::DomShared +{ +public: + SVGElementInstanceListImpl(); + virtual ~SVGElementInstanceListImpl(); + + unsigned long length() const; + SVGElementInstanceImpl *item(unsigned long index); + +private: + unsigned long m_length; +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGEllipseElementImpl.cc b/ksvg/impl/SVGEllipseElementImpl.cc new file mode 100644 index 00000000..9908941a --- /dev/null +++ b/ksvg/impl/SVGEllipseElementImpl.cc @@ -0,0 +1,200 @@ +/* + 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> +#include <klocale.h> + +#include "CanvasItem.h" +#include "KSVGCanvas.h" + +#include "SVGRectImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGEllipseElementImpl.h" +#include "SVGAnimatedLengthImpl.h" + +using namespace KSVG; + +#include "SVGEllipseElementImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" + +SVGEllipseElementImpl::SVGEllipseElementImpl(DOM::ElementImpl *impl) : SVGShapeImpl(impl), SVGTestsImpl(), SVGLangSpaceImpl(), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this), SVGTransformableImpl() +{ + KSVG_EMPTY_FLAGS + + m_cx = new SVGAnimatedLengthImpl(LENGTHMODE_WIDTH, this); + m_cx->ref(); + m_cx->baseVal()->setValueAsString("-1"); + + m_cy = new SVGAnimatedLengthImpl(LENGTHMODE_HEIGHT, this); + m_cy->ref(); + m_cy->baseVal()->setValueAsString("-1"); + + m_rx = new SVGAnimatedLengthImpl(LENGTHMODE_WIDTH, this); + m_rx->ref(); + m_rx->baseVal()->setValueAsString("-1"); + + m_ry = new SVGAnimatedLengthImpl(LENGTHMODE_HEIGHT, this); + m_ry->ref(); + m_ry->baseVal()->setValueAsString("-1"); +} + +SVGEllipseElementImpl::~SVGEllipseElementImpl() +{ + if(m_cx) + m_cx->deref(); + if(m_cy) + m_cy->deref(); + if(m_rx) + m_rx->deref(); + if(m_ry) + m_ry->deref(); +} + +SVGAnimatedLengthImpl *SVGEllipseElementImpl::cx() +{ + return m_cx; +} + +SVGAnimatedLengthImpl *SVGEllipseElementImpl::cy() +{ + return m_cy; +} + +SVGAnimatedLengthImpl *SVGEllipseElementImpl::rx() +{ + return m_rx; +} + +SVGAnimatedLengthImpl *SVGEllipseElementImpl::ry() +{ + return m_ry; +} + +/* +@namespace KSVG +@begin SVGEllipseElementImpl::s_hashTable 5 + cx SVGEllipseElementImpl::Cx DontDelete|ReadOnly + cy SVGEllipseElementImpl::Cy DontDelete|ReadOnly + rx SVGEllipseElementImpl::Rx DontDelete|ReadOnly + ry SVGEllipseElementImpl::Ry DontDelete|ReadOnly +@end +*/ + +Value SVGEllipseElementImpl::getValueProperty(ExecState *exec, int token) const +{ + KSVG_CHECK_ATTRIBUTE + + switch(token) + { + case Cx: + if(!attributeMode) + return m_cx->cache(exec); + else + return Number(m_cx->baseVal()->value()); + case Cy: + if(!attributeMode) + return m_cy->cache(exec); + else + return Number(m_cy->baseVal()->value()); + case Rx: + if(!attributeMode) + return m_rx->cache(exec); + else + return Number(m_rx->baseVal()->value()); + case Ry: + if(!attributeMode) + return m_ry->cache(exec); + else + return Number(m_ry->baseVal()->value()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGEllipseElementImpl::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; + + switch(token) + { + case Cx: + cx()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + case Cy: + cy()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + case Rx: + rx()->baseVal()->setValueAsString(value.toString(exec).qstring()); + if(rx()->baseVal()->value() < 0) // A negative value is an error + gotError("Negative value for attribute rx of element <ellipse> is illegal"); + break; + case Ry: + ry()->baseVal()->setValueAsString(value.toString(exec).qstring()); + if(ry()->baseVal()->value() < 0) // A negative value is an error + gotError(i18n("Negative value for attribute ry of element <ellipse> is illegal")); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +SVGRectImpl *SVGEllipseElementImpl::getBBox() +{ + SVGRectImpl *ret = SVGSVGElementImpl::createSVGRect(); + ret->setX(m_cx->baseVal()->value() - m_rx->baseVal()->value()); + ret->setY(m_cy->baseVal()->value() - m_ry->baseVal()->value()); + ret->setWidth(m_rx->baseVal()->value() * 2.0); + ret->setHeight(m_ry->baseVal()->value() * 2.0); + return ret; +} + +void SVGEllipseElementImpl::setAttributes() +{ + SVGElementImpl::setAttributes(); + + // Spec: if not specified, effect is as if a value of "0" were specified + if(KSVG_TOKEN_NOT_PARSED(Cx)) + KSVG_SET_ALT_ATTRIBUTE(Cx, "0") + + // Spec: if not specified, effect is as if a value of "0" were specified + if(KSVG_TOKEN_NOT_PARSED(Cy)) + KSVG_SET_ALT_ATTRIBUTE(Cy, "0") +} + +void SVGEllipseElementImpl::createItem(KSVGCanvas *c) +{ + if(!c) + c = ownerDoc()->canvas(); + + if(!m_item) + { + m_item = c->createEllipse(this); + c->insert(m_item); + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGEllipseElementImpl.h b/ksvg/impl/SVGEllipseElementImpl.h new file mode 100644 index 00000000..131098ba --- /dev/null +++ b/ksvg/impl/SVGEllipseElementImpl.h @@ -0,0 +1,86 @@ +/* + 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. +*/ + +#ifndef SVGEllipseElementImpl_H +#define SVGEllipseElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGShapeImpl.h" +#include "SVGTestsImpl.h" +#include "SVGStylableImpl.h" +#include "SVGLangSpaceImpl.h" +#include "SVGTransformableImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + +namespace KSVG +{ + +class SVGRectImpl; +class SVGAnimatedLengthImpl; +class SVGEllipseElementImpl : public SVGShapeImpl, + public SVGTestsImpl, + public SVGLangSpaceImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl, + public SVGTransformableImpl +{ +public: + SVGEllipseElementImpl(DOM::ElementImpl *); + virtual ~SVGEllipseElementImpl(); + + SVGAnimatedLengthImpl *cx(); + SVGAnimatedLengthImpl *cy(); + SVGAnimatedLengthImpl *rx(); + SVGAnimatedLengthImpl *ry(); + + virtual void createItem(KSVGCanvas *c = 0); + virtual void setAttributes(); + + virtual SVGRectImpl *getBBox(); + +private: + SVGAnimatedLengthImpl *m_cx; + SVGAnimatedLengthImpl *m_cy; + SVGAnimatedLengthImpl *m_rx; + SVGAnimatedLengthImpl *m_ry; + +public: + KSVG_GET + KSVG_PUT + KSVG_BRIDGE + + enum + { + // Properties + Cx, Cy, Rx, Ry + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +KSVG_REGISTER_ELEMENT(SVGEllipseElementImpl, "ellipse") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGEventImpl.cc b/ksvg/impl/SVGEventImpl.cc new file mode 100644 index 00000000..418e0044 --- /dev/null +++ b/ksvg/impl/SVGEventImpl.cc @@ -0,0 +1,992 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + Additional copyright: + (C) 2001 Peter Kelly <pmk@post.com> + (C) 2001 Tobias Anton <anton@stud.fbi.fh-darmstadt.de> + + 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 "SVGDocumentImpl.h" +#include "SVGEventImpl.h" + +#include <kdebug.h> + +using namespace KSVG; + +#include "ksvg_scriptinterpreter.h" +#include "SVGEventImpl.lut.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" + +SVGEventImpl::SVGEventImpl() +{ + m_canBubble = false; + m_cancelable = false; + + m_propagationStopped = false; + m_defaultPrevented = false; + m_id = SVGEvent::UNKNOWN_EVENT; + m_eventPhase = 0; + m_createTime = QDateTime::currentDateTime(); + m_defaultHandled = false; + + m_target = 0; + m_currentTarget = 0; +} + +SVGEventImpl::SVGEventImpl(SVGEvent::EventId _id, bool canBubbleArg, bool cancelableArg) +{ + DOM::DOMString t = SVGEvent::idToType(_id); + m_type = t.implementation(); + + m_canBubble = canBubbleArg; + m_cancelable = cancelableArg; + + m_propagationStopped = false; + m_defaultPrevented = false; + m_id = _id; + m_eventPhase = 0; + m_createTime = QDateTime::currentDateTime(); + m_defaultHandled = false; + + m_target = 0; + m_currentTarget = 0; +} + +SVGEventImpl::~SVGEventImpl() +{ +} + +DOM::DOMString SVGEventImpl::type() const +{ + return m_type; +} + +SVGElementImpl *SVGEventImpl::target() const +{ + return m_target; +} + +void SVGEventImpl::setTarget(SVGElementImpl *_target) +{ + m_target = _target; +} + +SVGElementImpl *SVGEventImpl::currentTarget() const +{ + return m_currentTarget; +} + +void SVGEventImpl::setCurrentTarget(SVGElementImpl *_currentTarget) +{ + m_currentTarget = _currentTarget; +} + +unsigned short SVGEventImpl::eventPhase() const +{ + return m_eventPhase; +} + +void SVGEventImpl::setEventPhase(unsigned short _eventPhase) +{ + m_eventPhase = _eventPhase; +} + +bool SVGEventImpl::bubbles() const +{ + return m_canBubble; +} + +bool SVGEventImpl::cancelable() const +{ + return m_cancelable; +} + +DOM::DOMTimeStamp SVGEventImpl::timeStamp() +{ + QDateTime epoch(QDate(1970, 1, 1), QTime(0, 0)); + + // ### kjs does not yet support long long (?) so the value wraps around + return epoch.secsTo(m_createTime) * 1000 + m_createTime.time().msec(); +} + +void SVGEventImpl::stopPropagation() +{ + m_propagationStopped = true; +} + +void SVGEventImpl::preventDefault() +{ + if(m_cancelable) + m_defaultPrevented = true; +} + +void SVGEventImpl::initEvent(const DOM::DOMString &eventTypeArg, bool canBubbleArg, bool cancelableArg) +{ + // ### ensure this is not called after we have been dispatched (also for subclasses) + m_type = eventTypeArg.implementation(); + m_id = SVGEvent::typeToId(eventTypeArg); + + m_canBubble = canBubbleArg; + m_cancelable = cancelableArg; +} + +void SVGEventImpl::setDefaultHandled() +{ + m_defaultHandled = true; +} + +/* +@namespace KSVG +@begin SVGEventImpl::s_hashTable 11 + type SVGEventImpl::Type DontDelete|ReadOnly + target SVGEventImpl::Target DontDelete|ReadOnly + currentTarget SVGEventImpl::CurrentTarget DontDelete|ReadOnly + eventPhase SVGEventImpl::EventPhase DontDelete|ReadOnly + bubbles SVGEventImpl::Bubbles DontDelete|ReadOnly + cancelable SVGEventImpl::Cancelable DontDelete|ReadOnly + timeStamp SVGEventImpl::TimeStamp DontDelete|ReadOnly +@end +@namespace KSVG +@begin SVGEventImplProto::s_hashTable 13 + getType SVGEventImpl::GetType DontDelete|Function 0 + getTarget SVGEventImpl::GetTarget DontDelete|Function 0 + getCurrentTarget SVGEventImpl::GetCurrentTarget DontDelete|Function 0 + getCurrentNode SVGEventImpl::GetCurrentNode DontDelete|Function 0 + getEventphase SVGEventImpl::GetEventPhase DontDelete|Function 0 + getBubbles SVGEventImpl::GetBubbles DontDelete|Function 0 + getCancelable SVGEventImpl::GetCancelable DontDelete|Function 0 + getTimeStamp SVGEventImpl::GetTimeStamp DontDelete|Function 0 + stopPropagation SVGEventImpl::StopPropagation DontDelete|Function 0 + preventDefault SVGEventImpl::PreventDefault DontDelete|Function 0 + initEvent SVGEventImpl::InitEvent DontDelete|Function 3 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGEvent", SVGEventImplProto, SVGEventImplProtoFunc) + +Value SVGEventImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case Type: + return String(type()); + case Target: + return getDOMNode(exec, *target()); + case CurrentTarget: + return getDOMNode(exec, *currentTarget()); + case EventPhase: + return Number(eventPhase()); + case Bubbles: + return Boolean(bubbles()); + case Cancelable: + return Boolean(cancelable()); +// case TimeStamp: // TODO + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return KJS::Undefined(); + } +} + +Value SVGEventImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGEventImpl) + + switch(id) + { + case SVGEventImpl::GetType: + return String(obj->type()); + case SVGEventImpl::GetTarget: + return getDOMNode(exec, *obj->target()); + case SVGEventImpl::GetCurrentTarget: + case SVGEventImpl::GetCurrentNode: + return getDOMNode(exec, *obj->currentTarget()); + case SVGEventImpl::GetEventPhase: + return Number(obj->eventPhase()); + case SVGEventImpl::GetBubbles: + return Boolean(obj->bubbles()); + case SVGEventImpl::GetCancelable: + return Boolean(obj->cancelable()); +// case SVGEventImpl::GetTimeStamp: // TODO + case SVGEventImpl::StopPropagation: + { + obj->stopPropagation(); + return Undefined(); + } + case SVGEventImpl::PreventDefault: + { + obj->preventDefault(); + return Undefined(); + } + case SVGEventImpl::InitEvent: + { + obj->initEvent(args[0].toString(exec).string(), args[1].toBoolean(exec), args[2].toBoolean(exec)); + return Undefined(); + } + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return Undefined(); +} + + + + + +SVGUIEventImpl::SVGUIEventImpl() : SVGEventImpl() +{ + m_detail = 0; +} + +SVGUIEventImpl::SVGUIEventImpl(SVGEvent::EventId _id, bool canBubbleArg, bool cancelableArg, DOM::AbstractView &viewArg, long detailArg) +: SVGEventImpl(_id, canBubbleArg, cancelableArg) +{ + m_view = viewArg; + m_detail = detailArg; +} + +SVGUIEventImpl::~SVGUIEventImpl() +{ +} + +DOM::AbstractView SVGUIEventImpl::view() const +{ + return m_view; +} + +long SVGUIEventImpl::detail() const +{ + return m_detail; +} + +void SVGUIEventImpl::initUIEvent(const DOM::DOMString &typeArg, + bool canBubbleArg, + bool cancelableArg, + const DOM::AbstractView &viewArg, + long detailArg) +{ + SVGEventImpl::initEvent(typeArg, canBubbleArg, cancelableArg); + + m_view = viewArg; + m_detail = detailArg; +} + +/* +@namespace KSVG +@begin SVGUIEventImpl::s_hashTable 3 + view SVGUIEventImpl::View DontDelete|ReadOnly + detail SVGUIEventImpl::Detail DontDelete|ReadOnly +@end +@namespace KSVG +@begin SVGUIEventImplProto::s_hashTable 5 + getView SVGUIEventImpl::GetView DontDelete|Function 0 + getDetail SVGUIEventImpl::GetDetail DontDelete|Function 0 + initUIEvent SVGUIEventImpl::InitUIEvent DontDelete|Function 5 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGUIEvent", SVGUIEventImplProto, SVGUIEventImplProtoFunc) + +Value SVGUIEventImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { +// case View: // TODO + case Detail: + return Number(detail()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return KJS::Undefined(); + } +} + +Value SVGUIEventImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &) +{ + KSVG_CHECK_THIS(SVGUIEventImpl) + + switch(id) + { +// case SVGUIEventImpl::GetView: // TODO + case SVGUIEventImpl::GetDetail: + return Number(obj->detail()); +// case SVGUIEventImpl::InitUIEvent: // TODO + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return Undefined(); +} + +SVGKeyEventImpl::SVGKeyEventImpl() : SVGUIEventImpl() +{ + qKeyEvent = 0; +} + +SVGKeyEventImpl::SVGKeyEventImpl(QKeyEvent *key, DOM::AbstractView &view, SVGEvent::EventId _id) : SVGUIEventImpl(_id, true, true, view, 0) +{ + qKeyEvent = new QKeyEvent(key->type(), key->key(), key->ascii(), key->state(), key->text(), key->isAutoRepeat(), key->count()); + + // Events are supposed to be accepted by default in Qt! + // This line made QLineEdit's keyevents be ignored, so they were sent to the khtmlview + // (and e.g. space would make it scroll down) + //qKeyEvent->ignore(); + + m_detail = key->count(); + + m_numPad = false; + m_keyVal = 0; + m_virtKeyVal = DOM_VK_UNDEFINED; + m_inputGenerated = true; + + switch(key->key()) + { + case Qt::Key_Enter: + m_numPad = true; + /* fall through */ + case Qt::Key_Return: + m_virtKeyVal = DOM_VK_ENTER; + break; + case Qt::Key_NumLock: + m_numPad = true; + m_virtKeyVal = DOM_VK_NUM_LOCK; + break; + case Qt::Key_Alt: + m_virtKeyVal = DOM_VK_RIGHT_ALT; + // ### DOM_VK_LEFT_ALT; + break; + case Qt::Key_Control: + m_virtKeyVal = DOM_VK_LEFT_CONTROL; + // ### DOM_VK_RIGHT_CONTROL + break; + case Qt::Key_Shift: + m_virtKeyVal = DOM_VK_LEFT_SHIFT; + // ### DOM_VK_RIGHT_SHIFT + break; + case Qt::Key_Meta: + m_virtKeyVal = DOM_VK_LEFT_META; + // ### DOM_VK_RIGHT_META + break; + case Qt::Key_CapsLock: + m_virtKeyVal = DOM_VK_CAPS_LOCK; + break; + case Qt::Key_Delete: + m_virtKeyVal = DOM_VK_DELETE; + break; + case Qt::Key_End: + m_virtKeyVal = DOM_VK_END; + break; + case Qt::Key_Escape: + m_virtKeyVal = DOM_VK_ESCAPE; + break; + case Qt::Key_Home: + m_virtKeyVal = DOM_VK_HOME; + break; + case Qt::Key_Insert: + m_virtKeyVal = DOM_VK_INSERT; + break; + case Qt::Key_Pause: + m_virtKeyVal = DOM_VK_PAUSE; + break; + case Qt::Key_Print: + m_virtKeyVal = DOM_VK_PRINTSCREEN; + break; + case Qt::Key_ScrollLock: + m_virtKeyVal = DOM_VK_SCROLL_LOCK; + break; + case Qt::Key_Left: + m_virtKeyVal = DOM_VK_LEFT; + break; + case Qt::Key_Right: + m_virtKeyVal = DOM_VK_RIGHT; + break; + case Qt::Key_Up: + m_virtKeyVal = DOM_VK_UP; + break; + case Qt::Key_Down: + m_virtKeyVal = DOM_VK_DOWN; + break; + case Qt::Key_Next: + m_virtKeyVal = DOM_VK_PAGE_DOWN; + break; + case Qt::Key_Prior: + m_virtKeyVal = DOM_VK_PAGE_UP; + break; + case Qt::Key_F1: + m_virtKeyVal = DOM_VK_F1; + break; + case Qt::Key_F2: + m_virtKeyVal = DOM_VK_F2; + break; + case Qt::Key_F3: + m_virtKeyVal = DOM_VK_F3; + break; + case Qt::Key_F4: + m_virtKeyVal = DOM_VK_F4; + break; + case Qt::Key_F5: + m_virtKeyVal = DOM_VK_F5; + break; + case Qt::Key_F6: + m_virtKeyVal = DOM_VK_F6; + break; + case Qt::Key_F7: + m_virtKeyVal = DOM_VK_F7; + break; + case Qt::Key_F8: + m_virtKeyVal = DOM_VK_F8; + break; + case Qt::Key_F9: + m_virtKeyVal = DOM_VK_F9; + break; + case Qt::Key_F10: + m_virtKeyVal = DOM_VK_F10; + break; + case Qt::Key_F11: + m_virtKeyVal = DOM_VK_F11; + break; + case Qt::Key_F12: + m_virtKeyVal = DOM_VK_F12; + break; + case Qt::Key_F13: + m_virtKeyVal = DOM_VK_F13; + break; + case Qt::Key_F14: + m_virtKeyVal = DOM_VK_F14; + break; + case Qt::Key_F15: + m_virtKeyVal = DOM_VK_F15; + break; + case Qt::Key_F16: + m_virtKeyVal = DOM_VK_F16; + break; + case Qt::Key_F17: + m_virtKeyVal = DOM_VK_F17; + break; + case Qt::Key_F18: + m_virtKeyVal = DOM_VK_F18; + break; + case Qt::Key_F19: + m_virtKeyVal = DOM_VK_F19; + break; + case Qt::Key_F20: + m_virtKeyVal = DOM_VK_F20; + break; + case Qt::Key_F21: + m_virtKeyVal = DOM_VK_F21; + break; + case Qt::Key_F22: + m_virtKeyVal = DOM_VK_F22; + break; + case Qt::Key_F23: + m_virtKeyVal = DOM_VK_F23; + break; + case Qt::Key_F24: + m_virtKeyVal = DOM_VK_F24; + break; + default: + m_virtKeyVal = DOM_VK_UNDEFINED; + break; + } + + // m_keyVal should contain the unicode value + // of the pressed key if available. + if (!key->text().isNull()) + m_keyVal = key->text().unicode()[0]; + + // m_numPad = ??? + + // key->state returns enum ButtonState, which is ShiftButton, ControlButton and AltButton or'ed together. + m_modifier = key->state(); + + // key->text() returns the unicode sequence as a QString + m_outputString = DOM::DOMString(key->text()); +} + +SVGKeyEventImpl::SVGKeyEventImpl(SVGEvent::EventId _id, + bool canBubbleArg, + bool cancelableArg, + DOM::AbstractView &viewArg, + unsigned short detailArg, + DOM::DOMString &outputStringArg, + unsigned long keyValArg, + unsigned long virtKeyValArg, + bool inputGeneratedArg, + bool numPadArg) +: SVGUIEventImpl(_id, canBubbleArg, cancelableArg, viewArg, detailArg) +{ + qKeyEvent = 0; + m_keyVal = keyValArg; + m_virtKeyVal = virtKeyValArg; + m_inputGenerated = inputGeneratedArg; + m_outputString = outputStringArg; + m_numPad = numPadArg; + m_modifier = 0; +} + +SVGKeyEventImpl::~SVGKeyEventImpl() +{ + delete qKeyEvent; +} + +bool SVGKeyEventImpl::checkModifier(unsigned long modifierArg) +{ + return ((m_modifier && modifierArg) == modifierArg); +} + +void SVGKeyEventImpl::initKeyEvent(DOM::DOMString &typeArg, + bool canBubbleArg, + bool cancelableArg, + const DOM::AbstractView &viewArg, + long detailArg, + DOM::DOMString &outputStringArg, + unsigned long keyValArg, + unsigned long virtKeyValArg, + bool inputGeneratedArg, + bool numPadArg) +{ + SVGUIEventImpl::initUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg); + + m_outputString = outputStringArg; + m_keyVal = keyValArg; + m_virtKeyVal = virtKeyValArg; + m_inputGenerated = inputGeneratedArg; + m_numPad = numPadArg; +} + +void SVGKeyEventImpl::initModifier(unsigned long modifierArg, bool valueArg) +{ + if(valueArg) + m_modifier |= modifierArg; + else + m_modifier &= (modifierArg ^ 0xFFFFFFFF); +} + +bool SVGKeyEventImpl::inputGenerated() const +{ + return m_inputGenerated; +} + +unsigned long SVGKeyEventImpl::keyVal() const +{ + return m_keyVal; +} + +DOM::DOMString SVGKeyEventImpl::outputString() const +{ + return m_outputString; +} + +/* +@namespace KSVG +@begin SVGKeyEventImpl::s_hashTable 7 + keyVal SVGKeyEventImpl::KeyVal DontDelete|ReadOnly + keyCode SVGKeyEventImpl::KeyVal DontDelete|ReadOnly + charCode SVGKeyEventImpl::KeyVal DontDelete|ReadOnly + outputString SVGKeyEventImpl::OutputString DontDelete|ReadOnly + virtKeyVal SVGKeyEventImpl::VirtKeyVal DontDelete|ReadOnly +# todo visibleOutputGenerated numPad +@end +@namespace KSVG +@begin SVGKeyEventImplProto::s_hashTable 7 + checkModifier SVGKeyEventImpl::CheckModifier DontDelete|Function 1 + getKeyCode SVGKeyEventImpl::GetKeyVal DontDelete|Function 0 + getCharCode SVGKeyEventImpl::GetKeyVal DontDelete|Function 0 + getKeyVal SVGKeyEventImpl::GetKeyVal DontDelete|Function 0 + getCharCode SVGKeyEventImpl::GetCharCode DontDelete|Function 0 +# todo initModifier +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGKeyEvent", SVGKeyEventImplProto, SVGKeyEventImplProtoFunc) + +Value SVGKeyEventImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case KeyVal: + return Number(keyVal()); + case VirtKeyVal: + return Number(virtKeyVal()); + case OutputString: + return String(outputString()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +Value SVGKeyEventImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGKeyEventImpl) + + switch(id) + { + case SVGKeyEventImpl::CheckModifier: + return Boolean((static_cast<KSVGBridge<SVGKeyEventImpl> *>(static_cast<ObjectImp *>(thisObj.imp()))->impl())->checkModifier(args[0].toUInt32(exec))); + case SVGKeyEventImpl::GetKeyVal: + case SVGKeyEventImpl::GetCharCode: + return Number((static_cast<KSVGBridge<SVGKeyEventImpl> *>(static_cast<ObjectImp *>(thisObj.imp()))->impl())->keyVal()); + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return Undefined(); +} + + + +// ----------------------------------------------------------------------------- + +SVGMouseEventImpl::SVGMouseEventImpl() : SVGUIEventImpl() +{ + m_screenX = 0; + m_screenY = 0; + m_clientX = 0; + m_clientY = 0; + m_ctrlKey = false; + m_altKey = false; + m_shiftKey = false; + m_metaKey = false; + m_button = 0; +} + +SVGMouseEventImpl::SVGMouseEventImpl(SVGEvent::EventId _id, + bool canBubbleArg, + bool cancelableArg, + DOM::AbstractView &viewArg, + long detailArg, + long screenXArg, + long screenYArg, + long clientXArg, + long clientYArg, + bool ctrlKeyArg, + bool altKeyArg, + bool shiftKeyArg, + bool metaKeyArg, + unsigned short buttonArg, + SVGElementImpl *relatedTargetArg) +: SVGUIEventImpl(_id, canBubbleArg, cancelableArg, viewArg, detailArg) +{ + m_screenX = screenXArg; + m_screenY = screenYArg; + m_clientX = clientXArg; + m_clientY = clientYArg; + m_ctrlKey = ctrlKeyArg; + m_altKey = altKeyArg; + m_shiftKey = shiftKeyArg; + m_metaKey = metaKeyArg; + m_button = buttonArg; + m_relatedTarget = relatedTargetArg; +} + +SVGMouseEventImpl::~SVGMouseEventImpl() +{ +} + +long SVGMouseEventImpl::screenX() const +{ + return m_screenX; +} + +long SVGMouseEventImpl::screenY() const +{ + return m_screenY; +} + +long SVGMouseEventImpl::clientX() const +{ + return m_clientX; +} + +long SVGMouseEventImpl::clientY() const +{ + return m_clientY; +} + +bool SVGMouseEventImpl::ctrlKey() const +{ + return m_ctrlKey; +} + +bool SVGMouseEventImpl::shiftKey() const +{ + return m_shiftKey; +} + +bool SVGMouseEventImpl::altKey() const +{ + return m_altKey; +} + +bool SVGMouseEventImpl::metaKey() const +{ + return m_metaKey; +} + +unsigned short SVGMouseEventImpl::button() const +{ + return m_button; +} + +SVGElementImpl *SVGMouseEventImpl::relatedTarget() const +{ + return m_relatedTarget; +} + +DOM::DOMString SVGMouseEventImpl::url() const +{ + return m_url; +} + +void SVGMouseEventImpl::setURL(DOM::DOMString url) +{ + m_url = url; +} + +void SVGMouseEventImpl::initMouseEvent(const DOM::DOMString &typeArg, + bool canBubbleArg, + bool cancelableArg, + const DOM::AbstractView &viewArg, + long detailArg, + long screenXArg, + long screenYArg, + long clientXArg, + long clientYArg, + bool ctrlKeyArg, + bool altKeyArg, + bool shiftKeyArg, + bool metaKeyArg, + unsigned short buttonArg, + SVGElementImpl *relatedTargetArg) +{ + SVGUIEventImpl::initUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg); + + m_screenX = screenXArg; + m_screenY = screenYArg; + m_clientX = clientXArg; + m_clientY = clientYArg; + m_ctrlKey = ctrlKeyArg; + m_altKey = altKeyArg; + m_shiftKey = shiftKeyArg; + m_metaKey = metaKeyArg; + m_button = buttonArg; + m_relatedTarget = relatedTargetArg; +} + +/* +@namespace KSVG +@begin SVGMouseEventImpl::s_hashTable 11 + screenX SVGMouseEventImpl::ScreenX DontDelete|ReadOnly + screenY SVGMouseEventImpl::ScreenY DontDelete|ReadOnly + clientX SVGMouseEventImpl::ClientX DontDelete|ReadOnly + clientY SVGMouseEventImpl::ClientY DontDelete|ReadOnly + ctrlKey SVGMouseEventImpl::CtrlKey DontDelete|ReadOnly + shiftKey SVGMouseEventImpl::ShiftKey DontDelete|ReadOnly + altKey SVGMouseEventImpl::AltKey DontDelete|ReadOnly + metaKey SVGMouseEventImpl::MetaKey DontDelete|ReadOnly + button SVGMouseEventImpl::Button DontDelete|ReadOnly + relatedTarget SVGMouseEventImpl::RelatedTarget DontDelete|ReadOnly +@end +@namespace KSVG +@begin SVGMouseEventImplProto::s_hashTable 13 + getScreenX SVGMouseEventImpl::GetScreenX DontDelete|Function 0 + getScreenY SVGMouseEventImpl::GetScreenY DontDelete|Function 0 + getClientX SVGMouseEventImpl::GetClientX DontDelete|Function 0 + getClientY SVGMouseEventImpl::GetClientY DontDelete|Function 0 + getCtrlKey SVGMouseEventImpl::GetCtrlKey DontDelete|Function 0 + getShiftKey SVGMouseEventImpl::GetShiftKey DontDelete|Function 0 + getAltKey SVGMouseEventImpl::GetAltKey DontDelete|Function 0 + getMetaKey SVGMouseEventImpl::GetMetaKey DontDelete|Function 0 + getButton SVGMouseEventImpl::GetButton DontDelete|Function 0 + getRelatedTarget SVGMouseEventImpl::GetRelatedTarget DontDelete|Function 0 + initMouseEvent SVGMouseEventImpl::InitMouseEvent DontDelete|Function 15 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGMouseEvent", SVGMouseEventImplProto, SVGMouseEventImplProtoFunc) + +Value SVGMouseEventImpl::getValueProperty(ExecState *exec, int token) const +{ + kdDebug(26004) << k_funcinfo << endl; + switch(token) + { + case ScreenX: + return Number(screenX()); + case ScreenY: + return Number(screenY()); + case ClientX: + return Number(clientX()); + case ClientY: + return Number(clientY()); + case CtrlKey: + return Number(ctrlKey()); + case ShiftKey: + return Number(shiftKey()); + case AltKey: + return Number(altKey()); + case MetaKey: + return Number(metaKey()); + case Button: + return Number(button()); + case RelatedTarget: + return getDOMNode(exec, *relatedTarget()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return KJS::Undefined(); + } +} + +Value SVGMouseEventImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &) +{ + kdDebug(26004) << k_funcinfo << endl; + KSVG_CHECK_THIS(SVGMouseEventImpl) + + switch(id) + { + case SVGMouseEventImpl::GetScreenX: + return Number(obj->screenX()); + case SVGMouseEventImpl::GetScreenY: + return Number(obj->screenY()); + case SVGMouseEventImpl::GetClientX: + return Number(obj->clientX()); + case SVGMouseEventImpl::GetClientY: + return Number(obj->clientY()); + case SVGMouseEventImpl::GetCtrlKey: + return Number(obj->ctrlKey()); + case SVGMouseEventImpl::GetShiftKey: + return Number(obj->shiftKey()); + case SVGMouseEventImpl::GetAltKey: + return Number(obj->altKey()); + case SVGMouseEventImpl::GetMetaKey: + return Number(obj->metaKey()); + case SVGMouseEventImpl::GetButton: + return Number(obj->button()); + case SVGMouseEventImpl::GetRelatedTarget: + return getDOMNode(exec, *obj->relatedTarget()); +// case SVGMouseEventImpl::InitMouseEvent: // TODO + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return Undefined(); +} + + + + +SVGMutationEventImpl::SVGMutationEventImpl() : SVGEventImpl() +{ + m_attrChange = 0; +} + +SVGMutationEventImpl::SVGMutationEventImpl(SVGEvent::EventId _id, + bool canBubbleArg, + bool cancelableArg, + SVGElementImpl *relatedNodeArg, + const DOM::DOMString &prevValueArg, + const DOM::DOMString &newValueArg, + const DOM::DOMString &attrNameArg, + unsigned short attrChangeArg) +: SVGEventImpl(_id, canBubbleArg, cancelableArg) +{ + m_relatedNode = relatedNodeArg; + m_prevValue = prevValueArg.implementation(); + m_newValue = newValueArg.implementation(); + m_attrName = attrNameArg.implementation(); + m_attrChange = attrChangeArg; +} + +SVGMutationEventImpl::~SVGMutationEventImpl() +{ +} + +SVGElementImpl *SVGMutationEventImpl::relatedNode() const +{ + return m_relatedNode; +} + +DOM::DOMString SVGMutationEventImpl::prevValue() const +{ + return m_prevValue; +} + +DOM::DOMString SVGMutationEventImpl::newValue() const +{ + return m_newValue; +} + +DOM::DOMString SVGMutationEventImpl::attrName() const +{ + return m_attrName; +} + +unsigned short SVGMutationEventImpl::attrChange() const +{ + return m_attrChange; +} + +void SVGMutationEventImpl::initMutationEvent(const DOM::DOMString &typeArg, + bool canBubbleArg, + bool cancelableArg, + SVGElementImpl *relatedNodeArg, + const DOM::DOMString &prevValueArg, + const DOM::DOMString &newValueArg, + const DOM::DOMString &attrNameArg, + unsigned short attrChangeArg) +{ + SVGEventImpl::initEvent(typeArg, canBubbleArg, cancelableArg); + + m_relatedNode = relatedNodeArg; + m_prevValue = prevValueArg.implementation(); + m_newValue = newValueArg.implementation(); + m_attrName = attrNameArg.implementation(); + m_attrChange = attrChangeArg; +} + + + + + +SVGRegisteredEventListener::SVGRegisteredEventListener(SVGEvent::EventId _id, SVGEventListener *_listener, bool _useCapture) +{ + id = _id; + listener = _listener; + useCapture = _useCapture; + + listener->ref(); +} + +SVGRegisteredEventListener::~SVGRegisteredEventListener() +{ + listener->deref(); +} + +bool SVGRegisteredEventListener::operator==(const SVGRegisteredEventListener &other) +{ + return (id == other.id && + listener == other.listener && + useCapture == other.useCapture); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGEventImpl.h b/ksvg/impl/SVGEventImpl.h new file mode 100644 index 00000000..a123b09e --- /dev/null +++ b/ksvg/impl/SVGEventImpl.h @@ -0,0 +1,468 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + Additional copyright: + (C) 2001 Peter Kelly <pmk@post.com> + (C) 2001 Tobias Anton <anton@stud.fbi.fh-darmstadt.de> + + 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. +*/ + +#ifndef SVGEventImpl_H +#define SVGEventImpl_H + +#include <qevent.h> +#include <qdatetime.h> + +#include <dom/dom_misc.h> +#include <dom/dom_node.h> +#include <dom/dom2_views.h> +#include <dom/dom_string.h> + +#include "SVGEvent.h" +#include "SVGElementImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +// @ecma-checked 07/07/02@ +class SVGEventImpl : public DOM::DomShared +{ +public: + SVGEventImpl(); + SVGEventImpl(SVGEvent::EventId _id, bool canBubbleArg, bool cancelableArg); + virtual ~SVGEventImpl(); + + SVGEvent::EventId id() { return m_id; } + + DOM::DOMString type() const; + + SVGElementImpl *target() const; + void setTarget(SVGElementImpl *_target); + + SVGElementImpl *currentTarget() const; + void setCurrentTarget(SVGElementImpl *_currentTarget); + + unsigned short eventPhase() const; + void setEventPhase(unsigned short _eventPhase); + + bool bubbles() const; + bool cancelable() const; + + DOM::DOMTimeStamp timeStamp(); + + void stopPropagation(); + void preventDefault(); + void initEvent(const DOM::DOMString &eventTypeArg, bool canBubbleArg, bool cancelableArg); + + virtual bool isUIEvent() { return false; } + virtual bool isMouseEvent() { return false; } + virtual bool isMutationEvent() { return false; } + virtual bool isKeyEvent() { return false; } + + virtual DOM::DOMString eventModuleName() { return ""; } + + virtual bool propagationStopped() { return m_propagationStopped; } + virtual bool defaultPrevented() { return m_defaultPrevented; } + + void setDefaultHandled(); + bool defaultHandled() const { return m_defaultHandled; } + +protected: + DOM::DOMString m_type; + bool m_canBubble; + bool m_cancelable; + + bool m_propagationStopped; + bool m_defaultPrevented; + bool m_defaultHandled; + + SVGEvent::EventId m_id; + SVGElementImpl *m_currentTarget; + SVGElementImpl *m_target; + + unsigned short m_eventPhase; + QDateTime m_createTime; + +public: + KSVG_BASECLASS_GET + + enum + { + // Properties + Type, Target, CurrentTarget, EventPhase, + Bubbles, Cancelable, TimeStamp, + // Functions + GetType, GetTarget, GetCurrentTarget, GetEventPhase, + GetBubbles, GetCancelable, GetTimeStamp, + StopPropagation, PreventDefault, InitEvent, + GetCurrentNode // Out-Of-Spec + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; +}; + +class SVGEventListener : public DOM::DomShared +{ +public: + SVGEventListener() { } + virtual ~SVGEventListener() { } + + virtual void handleEvent(SVGEventImpl *) { } + virtual DOM::DOMString eventListenerType() { return ""; } +}; + +// @ecma-checked 07/07/02@ +class SVGUIEventImpl : public SVGEventImpl +{ +public: + SVGUIEventImpl(); + SVGUIEventImpl(SVGEvent::EventId _id, + bool canBubbleArg, + bool cancelableArg, + DOM::AbstractView &viewArg, + long detailArg); + + virtual ~SVGUIEventImpl(); + + DOM::AbstractView view() const; + long detail() const; + + void initUIEvent(const DOM::DOMString &typeArg, + bool canBubbleArg, + bool cancelableArg, + const DOM::AbstractView &viewArg, + long detailArg); + + virtual bool isUIEvent() { return true; } + virtual DOM::DOMString eventModuleName() { return "UIEvents"; } + +protected: + DOM::AbstractView m_view; + long m_detail; + +public: + KSVG_GET + + enum + { + // Properties + View, Detail, + // Functions + GetView, GetDetail, InitUIEvent + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; +}; + +// @ecma-checked 07/07/02@ +// Introduced in DOM Level 2: - internal +class SVGMouseEventImpl : public SVGUIEventImpl +{ +public: + SVGMouseEventImpl(); + SVGMouseEventImpl(SVGEvent::EventId _id, + bool canBubbleArg, + bool cancelableArg, + DOM::AbstractView &viewArg, + long detailArg, + long screenXArg, + long screenYArg, + long clientXArg, + long clientYArg, + bool ctrlKeyArg, + bool altKeyArg, + bool shiftKeyArg, + bool metaKeyArg, + unsigned short buttonArg, + SVGElementImpl *relatedTargetArg); + + virtual ~SVGMouseEventImpl(); + + long screenX() const; + long screenY() const; + long clientX() const; + long clientY() const; + bool ctrlKey() const; + bool shiftKey() const; + bool altKey() const; + bool metaKey() const; + + unsigned short button() const; + + SVGElementImpl *relatedTarget() const; + + void initMouseEvent(const DOM::DOMString &typeArg, + bool canBubbleArg, + bool cancelableArg, + const DOM::AbstractView &viewArg, + long detailArg, + long screenXArg, + long screenYArg, + long clientXArg, + long clientYArg, + bool ctrlKeyArg, + bool altKeyArg, + bool shiftKeyArg, + bool metaKeyArg, + unsigned short buttonArg, + SVGElementImpl *relatedTargetArg); + + virtual bool isMouseEvent() { return true; } + virtual DOM::DOMString eventModuleName() { return "MouseEvents"; } + + // KSVG extensions + DOM::DOMString url() const; + void setURL(DOM::DOMString url); + +protected: + long m_screenX; + long m_screenY; + long m_clientX; + long m_clientY; + bool m_ctrlKey; + bool m_altKey; + bool m_shiftKey; + bool m_metaKey; + unsigned short m_button; + SVGElementImpl *m_relatedTarget; + + // KSVG extension + DOM::DOMString m_url; + +public: + KSVG_GET + + enum + { + // Properties + ScreenX, ScreenY, ClientX, ClientY, CtrlKey, + ShiftKey, AltKey, MetaKey, Button, RelatedTarget, + // Functions + GetScreenX, GetScreenY, GetClientX, GetClientY, GetCtrlKey, + GetShiftKey, GetAltKey, GetMetaKey, GetButton, GetRelatedTarget, + InitMouseEvent + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; +}; + +class SVGKeyEventImpl : public SVGUIEventImpl +{ +public: + SVGKeyEventImpl(); + SVGKeyEventImpl(SVGEvent::EventId _id, + bool canBubbleArg, + bool cancelableArg, + DOM::AbstractView &viewArg, + unsigned short detailArg, + DOM::DOMString &outputStringArg, + unsigned long keyValArg, + unsigned long virtKeyValArg, + bool inputGeneratedArg, + bool numPadArg); + + SVGKeyEventImpl(QKeyEvent *key, DOM::AbstractView &view, SVGEvent::EventId _id); + + virtual bool isKeyEvent() { return true; } + + virtual ~SVGKeyEventImpl(); + + enum KeyCodes + { + DOM_VK_UNDEFINED = 0x0, + DOM_VK_RIGHT_ALT = 0x01, + DOM_VK_LEFT_ALT = 0x02, + DOM_VK_LEFT_CONTROL = 0x03, + DOM_VK_RIGHT_CONTROL = 0x04, + DOM_VK_LEFT_SHIFT = 0x05, + DOM_VK_RIGHT_SHIFT = 0x06, + DOM_VK_LEFT_META = 0x07, + DOM_VK_RIGHT_META = 0x08, + DOM_VK_CAPS_LOCK = 0x09, + DOM_VK_DELETE = 0x0A, + DOM_VK_END = 0x0B, + DOM_VK_ENTER = 0x0C, + DOM_VK_ESCAPE = 0x0D, + DOM_VK_HOME = 0x0E, + DOM_VK_INSERT = 0x0F, + DOM_VK_NUM_LOCK = 0x10, + DOM_VK_PAUSE = 0x11, + DOM_VK_PRINTSCREEN = 0x12, + DOM_VK_SCROLL_LOCK = 0x13, + DOM_VK_LEFT = 0x14, + DOM_VK_RIGHT = 0x15, + DOM_VK_UP = 0x16, + DOM_VK_DOWN = 0x17, + DOM_VK_PAGE_DOWN = 0x18, + DOM_VK_PAGE_UP = 0x19, + DOM_VK_F1 = 0x1A, + DOM_VK_F2 = 0x1B, + DOM_VK_F3 = 0x1C, + DOM_VK_F4 = 0x1D, + DOM_VK_F5 = 0x1E, + DOM_VK_F6 = 0x1F, + DOM_VK_F7 = 0x20, + DOM_VK_F8 = 0x21, + DOM_VK_F9 = 0x22, + DOM_VK_F10 = 0x23, + DOM_VK_F11 = 0x24, + DOM_VK_F12 = 0x25, + DOM_VK_F13 = 0x26, + DOM_VK_F14 = 0x27, + DOM_VK_F15 = 0x28, + DOM_VK_F16 = 0x29, + DOM_VK_F17 = 0x2A, + DOM_VK_F18 = 0x2B, + DOM_VK_F19 = 0x2C, + DOM_VK_F20 = 0x2D, + DOM_VK_F21 = 0x2E, + DOM_VK_F22 = 0x2F, + DOM_VK_F23 = 0x30, + DOM_VK_F24 = 0x31 + }; + + + bool checkModifier(unsigned long modiferArg); + + void initKeyEvent(DOM::DOMString &typeArg, + bool canBubbleArg, + bool cancelableArg, + const DOM::AbstractView &viewArg, + long detailArg, + DOM::DOMString &outputStringArg, + unsigned long keyValArg, + unsigned long virtKeyValArg, + bool inputGeneratedArg, + bool numPadArg); + + void initModifier(unsigned long modifierArg, bool valueArg); + + bool inputGenerated() const; + + unsigned long keyVal() const; + + bool numPad() const { return m_numPad; } + DOM::DOMString outputString() const; + + unsigned long virtKeyVal() const { return m_virtKeyVal; } + + QKeyEvent *qKeyEvent; + +private: + unsigned long m_keyVal; + unsigned long m_virtKeyVal; + bool m_inputGenerated; + DOM::DOMString m_outputString; + bool m_numPad; + + // bitfield containing state of modifiers. not part of the dom. + unsigned long m_modifier; + +public: + KSVG_GET + + enum + { + // Properties + KeyVal, VirtKeyVal, OutputString, + // Functions + CheckModifier, GetKeyVal, GetCharCode + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; +}; + +class SVGMutationEventImpl : public SVGEventImpl +{ +public: + SVGMutationEventImpl(); + SVGMutationEventImpl(SVGEvent::EventId _id, + bool canBubbleArg, + bool cancelableArg, + SVGElementImpl *relatedNodeArg, + const DOM::DOMString &prevValueArg, + const DOM::DOMString &newValueArg, + const DOM::DOMString &attrNameArg, + unsigned short attrChangeArg); + ~SVGMutationEventImpl(); + + SVGElementImpl *relatedNode() const; + DOM::DOMString prevValue() const; + DOM::DOMString newValue() const; + DOM::DOMString attrName() const; + unsigned short attrChange() const; + + void initMutationEvent(const DOM::DOMString &typeArg, + bool canBubbleArg, + bool cancelableArg, + SVGElementImpl *relatedNodeArg, + const DOM::DOMString &prevValueArg, + const DOM::DOMString &newValueArg, + const DOM::DOMString &attrNameArg, + unsigned short attrChangeArg); + + virtual bool isMutationEvent() { return true; } + virtual DOM::DOMString eventModuleName() { return "MutationEvents"; } + +protected: + SVGElementImpl *m_relatedNode; + DOM::DOMString m_prevValue; + DOM::DOMString m_newValue; + DOM::DOMString m_attrName; + unsigned short m_attrChange; + +public: + KSVG_FORWARDGET +}; + +class SVGRegisteredEventListener +{ +public: + SVGRegisteredEventListener(SVGEvent::EventId _id, SVGEventListener *_listener, bool _useCapture); + ~SVGRegisteredEventListener(); + + bool operator==(const SVGRegisteredEventListener &other); + + SVGEvent::EventId id; + SVGEventListener *listener; + bool useCapture; + +private: + SVGRegisteredEventListener(const SVGRegisteredEventListener &); + SVGRegisteredEventListener &operator=(const SVGRegisteredEventListener &); +}; + +} + +KSVG_DEFINE_PROTOTYPE(SVGEventImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGEventImplProtoFunc, SVGEventImpl) + +KSVG_DEFINE_PROTOTYPE(SVGUIEventImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGUIEventImplProtoFunc, SVGUIEventImpl) + +KSVG_DEFINE_PROTOTYPE(SVGMouseEventImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGMouseEventImplProtoFunc, SVGMouseEventImpl) + +KSVG_DEFINE_PROTOTYPE(SVGKeyEventImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGKeyEventImplProtoFunc, SVGKeyEventImpl) + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGExternalResourcesRequiredImpl.cc b/ksvg/impl/SVGExternalResourcesRequiredImpl.cc new file mode 100644 index 00000000..90fd9141 --- /dev/null +++ b/ksvg/impl/SVGExternalResourcesRequiredImpl.cc @@ -0,0 +1,88 @@ +/* + 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> + +#include "SVGAnimatedBooleanImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + +using namespace KSVG; + +#include "SVGExternalResourcesRequiredImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +SVGExternalResourcesRequiredImpl::SVGExternalResourcesRequiredImpl() +{ + KSVG_EMPTY_FLAGS + + m_externalResourcesRequired = new SVGAnimatedBooleanImpl(); + m_externalResourcesRequired->ref(); +} + +SVGExternalResourcesRequiredImpl::~SVGExternalResourcesRequiredImpl() +{ + if(m_externalResourcesRequired) + m_externalResourcesRequired->deref(); +} + +SVGAnimatedBooleanImpl *SVGExternalResourcesRequiredImpl::externalResourcesRequired() const +{ + return m_externalResourcesRequired; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGExternalResourcesRequiredImpl::s_hashTable 2 + externalResourcesRequired SVGExternalResourcesRequiredImpl::ExternalResourcesRequired DontDelete|ReadOnly +@end +*/ + +Value SVGExternalResourcesRequiredImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case ExternalResourcesRequired: + return m_externalResourcesRequired->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGExternalResourcesRequiredImpl::putValueProperty(ExecState *exec, int token, const KJS::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; + switch(token) + { + case ExternalResourcesRequired: + m_externalResourcesRequired->setBaseVal(value.toBoolean(exec)); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGExternalResourcesRequiredImpl.h b/ksvg/impl/SVGExternalResourcesRequiredImpl.h new file mode 100644 index 00000000..9c5b93eb --- /dev/null +++ b/ksvg/impl/SVGExternalResourcesRequiredImpl.h @@ -0,0 +1,59 @@ +/* + 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. +*/ + +#ifndef SVGExternalResourcesRequiredImpl_H +#define SVGExternalResourcesRequiredImpl_H + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedBooleanImpl; +class SVGExternalResourcesRequiredImpl +{ +public: + SVGExternalResourcesRequiredImpl(); + ~SVGExternalResourcesRequiredImpl(); + + SVGAnimatedBooleanImpl *externalResourcesRequired() const; + +private: + SVGAnimatedBooleanImpl *m_externalResourcesRequired; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + ExternalResourcesRequired + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEBlendElementImpl.cc b/ksvg/impl/SVGFEBlendElementImpl.cc new file mode 100644 index 00000000..8b29cad5 --- /dev/null +++ b/ksvg/impl/SVGFEBlendElementImpl.cc @@ -0,0 +1,64 @@ +/* + 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 "SVGFEBlendElementImpl.h" +#include "SVGAnimatedStringImpl.h" +#include "SVGAnimatedEnumerationImpl.h" + +using namespace KSVG; + +SVGFEBlendElementImpl::SVGFEBlendElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGFilterPrimitiveStandardAttributesImpl() +{ + m_in1 = new SVGAnimatedStringImpl(); + m_in1->ref(); + + m_in2 = new SVGAnimatedStringImpl(); + m_in2->ref(); + + m_mode = new SVGAnimatedEnumerationImpl(); + m_mode->ref(); +} + +SVGFEBlendElementImpl::~SVGFEBlendElementImpl() +{ + if(m_in1) + m_in1->deref(); + if(m_in2) + m_in2->deref(); + if(m_mode) + m_mode->deref(); +} + +SVGAnimatedStringImpl *SVGFEBlendElementImpl::in1() const +{ + return m_in1; +} + +SVGAnimatedStringImpl *SVGFEBlendElementImpl::in2() const +{ + return m_in2; +} + +SVGAnimatedEnumerationImpl *SVGFEBlendElementImpl::mode() const +{ + return m_mode; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEBlendElementImpl.h b/ksvg/impl/SVGFEBlendElementImpl.h new file mode 100644 index 00000000..36aab059 --- /dev/null +++ b/ksvg/impl/SVGFEBlendElementImpl.h @@ -0,0 +1,59 @@ +/* + 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. +*/ + +#ifndef SVGFEBlendElementImpl_H +#define SVGFEBlendElementImpl_H + +#include "SVGElementImpl.h" +#include "SVGFilterPrimitiveStandardAttributesImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedStringImpl; +class SVGAnimatedEnumerationImpl; +class SVGFEBlendElementImpl : public SVGElementImpl, + public SVGFilterPrimitiveStandardAttributesImpl +{ +public: + SVGFEBlendElementImpl(DOM::ElementImpl *); + virtual ~SVGFEBlendElementImpl(); + + SVGAnimatedStringImpl *in1() const; + SVGAnimatedStringImpl *in2() const; + SVGAnimatedEnumerationImpl *mode() const; + +private: + SVGAnimatedStringImpl *m_in1; + SVGAnimatedStringImpl *m_in2; + SVGAnimatedEnumerationImpl *m_mode; + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEColorMatrixElementImpl.cc b/ksvg/impl/SVGFEColorMatrixElementImpl.cc new file mode 100644 index 00000000..14c68a56 --- /dev/null +++ b/ksvg/impl/SVGFEColorMatrixElementImpl.cc @@ -0,0 +1,65 @@ +/* + 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 "SVGAnimatedStringImpl.h" +#include "SVGAnimatedNumberListImpl.h" +#include "SVGAnimatedEnumerationImpl.h" +#include "SVGFEColorMatrixElementImpl.h" + +using namespace KSVG; + +SVGFEColorMatrixElementImpl::SVGFEColorMatrixElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGFilterPrimitiveStandardAttributesImpl() +{ + m_in1 = new SVGAnimatedStringImpl(); + m_in1->ref(); + + m_type = new SVGAnimatedEnumerationImpl(); + m_type->ref(); + + m_values = new SVGAnimatedNumberListImpl(); + m_values->ref(); +} + +SVGFEColorMatrixElementImpl::~SVGFEColorMatrixElementImpl() +{ + if(m_in1) + m_in1->deref(); + if(m_type) + m_type->deref(); + if(m_values) + m_values->deref(); +} + +SVGAnimatedStringImpl *SVGFEColorMatrixElementImpl::in1() const +{ + return m_in1; +} + +SVGAnimatedEnumerationImpl *SVGFEColorMatrixElementImpl::type() const +{ + return m_type; +} + +SVGAnimatedNumberListImpl *SVGFEColorMatrixElementImpl::values() const +{ + return m_values; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEColorMatrixElementImpl.h b/ksvg/impl/SVGFEColorMatrixElementImpl.h new file mode 100644 index 00000000..b637690b --- /dev/null +++ b/ksvg/impl/SVGFEColorMatrixElementImpl.h @@ -0,0 +1,60 @@ +/* + 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. +*/ + +#ifndef SVGFEColorMatrixElementImpl_H +#define SVGFEColorMatrixElementImpl_H + +#include "SVGElementImpl.h" +#include "SVGFilterPrimitiveStandardAttributesImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedStringImpl; +class SVGAnimatedEnumerationImpl; +class SVGAnimatedNumberListImpl; +class SVGFEColorMatrixElementImpl : public SVGElementImpl, + public SVGFilterPrimitiveStandardAttributesImpl +{ +public: + SVGFEColorMatrixElementImpl(DOM::ElementImpl *); + virtual ~SVGFEColorMatrixElementImpl(); + + SVGAnimatedStringImpl *in1() const; + SVGAnimatedEnumerationImpl *type() const; + SVGAnimatedNumberListImpl *values() const; + +private: + SVGAnimatedStringImpl *m_in1; + SVGAnimatedEnumerationImpl *m_type; + SVGAnimatedNumberListImpl *m_values; + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEComponentTransferElementImpl.cc b/ksvg/impl/SVGFEComponentTransferElementImpl.cc new file mode 100644 index 00000000..71ee4629 --- /dev/null +++ b/ksvg/impl/SVGFEComponentTransferElementImpl.cc @@ -0,0 +1,43 @@ +/* + 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 "SVGAnimatedStringImpl.h" +#include "SVGFEComponentTransferElementImpl.h" + +using namespace KSVG; + +SVGFEComponentTransferElementImpl::SVGFEComponentTransferElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGFilterPrimitiveStandardAttributesImpl() +{ + m_in1 = new SVGAnimatedStringImpl(); + m_in1->ref(); +} + +SVGFEComponentTransferElementImpl::~SVGFEComponentTransferElementImpl() +{ + if(m_in1) + m_in1->deref(); +} + +SVGAnimatedStringImpl *SVGFEComponentTransferElementImpl::in1() const +{ + return m_in1; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEComponentTransferElementImpl.h b/ksvg/impl/SVGFEComponentTransferElementImpl.h new file mode 100644 index 00000000..21c0fd88 --- /dev/null +++ b/ksvg/impl/SVGFEComponentTransferElementImpl.h @@ -0,0 +1,54 @@ +/* + 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. +*/ + +#ifndef SVGFEComponentTransferElementImpl_H +#define SVGFEComponentTransferElementImpl_H + +#include "SVGElementImpl.h" +#include "SVGFilterPrimitiveStandardAttributesImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedStringImpl; +class SVGFEComponentTransferElementImpl : public SVGElementImpl, + public SVGFilterPrimitiveStandardAttributesImpl +{ +public: + SVGFEComponentTransferElementImpl(DOM::ElementImpl *); + virtual ~SVGFEComponentTransferElementImpl(); + + SVGAnimatedStringImpl *in1() const; + +private: + SVGAnimatedStringImpl *m_in1; + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFECompositeElementImpl.cc b/ksvg/impl/SVGFECompositeElementImpl.cc new file mode 100644 index 00000000..e8b91b95 --- /dev/null +++ b/ksvg/impl/SVGFECompositeElementImpl.cc @@ -0,0 +1,105 @@ +/* + 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 "SVGAnimatedNumberImpl.h" +#include "SVGAnimatedStringImpl.h" +#include "SVGFECompositeElementImpl.h" +#include "SVGAnimatedEnumerationImpl.h" + +using namespace KSVG; + +SVGFECompositeElementImpl::SVGFECompositeElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGFilterPrimitiveStandardAttributesImpl() +{ + m_in1 = new SVGAnimatedStringImpl(); + m_in1->ref(); + + m_in2 = new SVGAnimatedStringImpl(); + m_in2->ref(); + + m_operator = new SVGAnimatedEnumerationImpl(); + m_operator->ref(); + + m_k1 = new SVGAnimatedNumberImpl(); + m_k1->ref(); + + m_k2 = new SVGAnimatedNumberImpl(); + m_k2->ref(); + + m_k3 = new SVGAnimatedNumberImpl(); + m_k3->ref(); + + m_k4 = new SVGAnimatedNumberImpl(); + m_k4->ref(); +} + +SVGFECompositeElementImpl::~SVGFECompositeElementImpl() +{ + if(m_in1) + m_in1->deref(); + if(m_in2) + m_in2->deref(); + if(m_operator) + m_operator->deref(); + if(m_k1) + m_k1->deref(); + if(m_k2) + m_k2->deref(); + if(m_k3) + m_k3->deref(); + if(m_k4) + m_k4->deref(); +} + +SVGAnimatedStringImpl *SVGFECompositeElementImpl::in1() const +{ + return m_in1; +} + +SVGAnimatedStringImpl *SVGFECompositeElementImpl::in2() const +{ + return m_in2; +} + +SVGAnimatedEnumerationImpl *SVGFECompositeElementImpl::Operator() const +{ + return m_operator; +} + +SVGAnimatedNumberImpl *SVGFECompositeElementImpl::k1() const +{ + return m_k1; +} + +SVGAnimatedNumberImpl *SVGFECompositeElementImpl::k2() const +{ + return m_k2; +} + +SVGAnimatedNumberImpl *SVGFECompositeElementImpl::k3() const +{ + return m_k3; +} + +SVGAnimatedNumberImpl *SVGFECompositeElementImpl::k4() const +{ + return m_k4; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFECompositeElementImpl.h b/ksvg/impl/SVGFECompositeElementImpl.h new file mode 100644 index 00000000..10796ec1 --- /dev/null +++ b/ksvg/impl/SVGFECompositeElementImpl.h @@ -0,0 +1,68 @@ +/* + 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. +*/ + +#ifndef SVGFECompositeElementImpl_H +#define SVGFECompositeElementImpl_H + +#include "SVGElementImpl.h" +#include "SVGFilterPrimitiveStandardAttributesImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedStringImpl; +class SVGAnimatedNumberImpl; +class SVGAnimatedEnumerationImpl; +class SVGFECompositeElementImpl : public SVGElementImpl, + public SVGFilterPrimitiveStandardAttributesImpl +{ +public: + SVGFECompositeElementImpl(DOM::ElementImpl *); + virtual ~SVGFECompositeElementImpl(); + + SVGAnimatedStringImpl *in1() const; + SVGAnimatedStringImpl *in2() const; + SVGAnimatedEnumerationImpl *Operator() const; + SVGAnimatedNumberImpl *k1() const; + SVGAnimatedNumberImpl *k2() const; + SVGAnimatedNumberImpl *k3() const; + SVGAnimatedNumberImpl *k4() const; + +private: + SVGAnimatedStringImpl *m_in1; + SVGAnimatedStringImpl *m_in2; + SVGAnimatedEnumerationImpl *m_operator; + SVGAnimatedNumberImpl *m_k1; + SVGAnimatedNumberImpl *m_k2; + SVGAnimatedNumberImpl *m_k3; + SVGAnimatedNumberImpl *m_k4; + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEConvolveMatrixElementImpl.cc b/ksvg/impl/SVGFEConvolveMatrixElementImpl.cc new file mode 100644 index 00000000..88eb00ee --- /dev/null +++ b/ksvg/impl/SVGFEConvolveMatrixElementImpl.cc @@ -0,0 +1,149 @@ +/* + 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 "SVGAnimatedNumberImpl.h" +#include "SVGAnimatedLengthImpl.h" +#include "SVGAnimatedIntegerImpl.h" +#include "SVGAnimatedBooleanImpl.h" +#include "SVGAnimatedIntegerImpl.h" +#include "SVGAnimatedNumberListImpl.h" +#include "SVGAnimatedEnumerationImpl.h" +#include "SVGFEConvolveMatrixElementImpl.h" + +using namespace KSVG; + +SVGFEConvolveMatrixElementImpl::SVGFEConvolveMatrixElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGFilterPrimitiveStandardAttributesImpl() +{ + m_orderX = new SVGAnimatedIntegerImpl(); + m_orderX->ref(); + + m_orderY = new SVGAnimatedIntegerImpl(); + m_orderY->ref(); + + m_kernelMatrix = new SVGAnimatedNumberListImpl(); + m_kernelMatrix->ref(); + + m_divisor = new SVGAnimatedNumberImpl(); + m_divisor->ref(); + + m_bias = new SVGAnimatedNumberImpl(); + m_bias->ref(); + + m_targetX = new SVGAnimatedIntegerImpl(); + m_targetX->ref(); + + m_targetY = new SVGAnimatedIntegerImpl(); + m_targetY->ref(); + + m_edgeMode = new SVGAnimatedEnumerationImpl(); + m_edgeMode->ref(); + + m_kernelUnitLengthX = new SVGAnimatedLengthImpl(); + m_kernelUnitLengthX->ref(); + + m_kernelUnitLengthY = new SVGAnimatedLengthImpl(); + m_kernelUnitLengthY->ref(); + + m_preserveAlpha = new SVGAnimatedBooleanImpl(); + m_preserveAlpha->ref(); +} + +SVGFEConvolveMatrixElementImpl::~SVGFEConvolveMatrixElementImpl() +{ + if(m_orderX) + m_orderX->deref(); + if(m_orderY) + m_orderY->deref(); + if(m_kernelMatrix) + m_kernelMatrix->deref(); + if(m_divisor) + m_divisor->deref(); + if(m_bias) + m_bias->deref(); + if(m_targetX) + m_targetX->deref(); + if(m_targetY) + m_targetY->deref(); + if(m_edgeMode) + m_edgeMode->deref(); + if(m_kernelUnitLengthX) + m_kernelUnitLengthX->deref(); + if(m_kernelUnitLengthY) + m_kernelUnitLengthY->deref(); + if(m_preserveAlpha) + m_preserveAlpha->deref(); +} + +SVGAnimatedIntegerImpl *SVGFEConvolveMatrixElementImpl::orderX() const +{ + return m_orderX; +} + +SVGAnimatedIntegerImpl *SVGFEConvolveMatrixElementImpl::orderY() const +{ + return m_orderY; +} + +SVGAnimatedNumberListImpl *SVGFEConvolveMatrixElementImpl::kernelMatrix() const +{ + return m_kernelMatrix; +} + +SVGAnimatedNumberImpl *SVGFEConvolveMatrixElementImpl::divisor() const +{ + return m_divisor; +} + +SVGAnimatedNumberImpl *SVGFEConvolveMatrixElementImpl::bias() const +{ + return m_bias; +} + +SVGAnimatedIntegerImpl *SVGFEConvolveMatrixElementImpl::targetX() const +{ + return m_targetX; +} + +SVGAnimatedIntegerImpl *SVGFEConvolveMatrixElementImpl::targetY() const +{ + return m_targetY; +} + +SVGAnimatedEnumerationImpl *SVGFEConvolveMatrixElementImpl::edgeMode() const +{ + return m_edgeMode; +} + +SVGAnimatedLengthImpl *SVGFEConvolveMatrixElementImpl::kernelUnitLengthX() const +{ + return m_kernelUnitLengthX; +} + +SVGAnimatedLengthImpl *SVGFEConvolveMatrixElementImpl::kernelUnitLengthY() const +{ + return m_kernelUnitLengthY; +} + +SVGAnimatedBooleanImpl *SVGFEConvolveMatrixElementImpl::preserveAlpha() const +{ + return m_preserveAlpha; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEConvolveMatrixElementImpl.h b/ksvg/impl/SVGFEConvolveMatrixElementImpl.h new file mode 100644 index 00000000..e26518d5 --- /dev/null +++ b/ksvg/impl/SVGFEConvolveMatrixElementImpl.h @@ -0,0 +1,80 @@ +/* + 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. +*/ + +#ifndef SVGFEConvolveMatrixElementImpl_H +#define SVGFEConvolveMatrixElementImpl_H + +#include "SVGElementImpl.h" +#include "SVGFilterPrimitiveStandardAttributesImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedNumberImpl; +class SVGAnimatedLengthImpl; +class SVGAnimatedIntegerImpl; +class SVGAnimatedIntegerImpl; +class SVGAnimatedBooleanImpl; +class SVGAnimatedNumberListImpl; +class SVGAnimatedEnumerationImpl; +class SVGFEConvolveMatrixElementImpl : public SVGElementImpl, + public SVGFilterPrimitiveStandardAttributesImpl +{ +public: + SVGFEConvolveMatrixElementImpl(DOM::ElementImpl *); + virtual ~SVGFEConvolveMatrixElementImpl(); + + SVGAnimatedIntegerImpl *orderX() const; + SVGAnimatedIntegerImpl *orderY() const; + SVGAnimatedNumberListImpl *kernelMatrix() const; + SVGAnimatedNumberImpl *divisor() const; + SVGAnimatedNumberImpl *bias() const; + SVGAnimatedIntegerImpl *targetX() const; + SVGAnimatedIntegerImpl *targetY() const; + SVGAnimatedEnumerationImpl *edgeMode() const; + SVGAnimatedLengthImpl *kernelUnitLengthX() const; + SVGAnimatedLengthImpl *kernelUnitLengthY() const; + SVGAnimatedBooleanImpl *preserveAlpha() const; + +private: + SVGAnimatedIntegerImpl *m_orderX; + SVGAnimatedIntegerImpl *m_orderY; + SVGAnimatedNumberListImpl *m_kernelMatrix; + SVGAnimatedNumberImpl *m_divisor; + SVGAnimatedNumberImpl *m_bias; + SVGAnimatedIntegerImpl *m_targetX; + SVGAnimatedIntegerImpl *m_targetY; + SVGAnimatedEnumerationImpl *m_edgeMode; + SVGAnimatedLengthImpl *m_kernelUnitLengthX; + SVGAnimatedLengthImpl *m_kernelUnitLengthY; + SVGAnimatedBooleanImpl *m_preserveAlpha; + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEDiffuseLightingElementImpl.cc b/ksvg/impl/SVGFEDiffuseLightingElementImpl.cc new file mode 100644 index 00000000..0b5c2565 --- /dev/null +++ b/ksvg/impl/SVGFEDiffuseLightingElementImpl.cc @@ -0,0 +1,64 @@ +/* + 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 "SVGAnimatedStringImpl.h" +#include "SVGAnimatedNumberImpl.h" +#include "SVGFEDiffuseLightingElementImpl.h" + +using namespace KSVG; + +SVGFEDiffuseLightingElementImpl::SVGFEDiffuseLightingElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGFilterPrimitiveStandardAttributesImpl() +{ + m_in1 = new SVGAnimatedStringImpl(); + m_in1->ref(); + + m_surfaceScale = new SVGAnimatedNumberImpl(); + m_surfaceScale->ref(); + + m_diffuseConstant = new SVGAnimatedNumberImpl(); + m_diffuseConstant->ref(); +} + +SVGFEDiffuseLightingElementImpl::~SVGFEDiffuseLightingElementImpl() +{ + if(m_in1) + m_in1->deref(); + if(m_surfaceScale) + m_surfaceScale->deref(); + if(m_diffuseConstant) + m_diffuseConstant->deref(); +} + +SVGAnimatedStringImpl *SVGFEDiffuseLightingElementImpl::in1() const +{ + return m_in1; +} + +SVGAnimatedNumberImpl *SVGFEDiffuseLightingElementImpl::surfaceScale() const +{ + return m_surfaceScale; +} + +SVGAnimatedNumberImpl *SVGFEDiffuseLightingElementImpl::diffuseConstant() const +{ + return m_diffuseConstant; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEDiffuseLightingElementImpl.h b/ksvg/impl/SVGFEDiffuseLightingElementImpl.h new file mode 100644 index 00000000..0be4f7f1 --- /dev/null +++ b/ksvg/impl/SVGFEDiffuseLightingElementImpl.h @@ -0,0 +1,59 @@ +/* + 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. +*/ + +#ifndef SVGFEDiffuseLightingElementImpl_H +#define SVGFEDiffuseLightingElementImpl_H + +#include "SVGElementImpl.h" +#include "SVGFilterPrimitiveStandardAttributesImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedStringImpl; +class SVGAnimatedNumberImpl; +class SVGFEDiffuseLightingElementImpl : public SVGElementImpl, + public SVGFilterPrimitiveStandardAttributesImpl +{ +public: + SVGFEDiffuseLightingElementImpl(DOM::ElementImpl *); + virtual ~SVGFEDiffuseLightingElementImpl(); + + SVGAnimatedStringImpl *in1() const; + SVGAnimatedNumberImpl *surfaceScale() const; + SVGAnimatedNumberImpl *diffuseConstant() const; + +private: + SVGAnimatedStringImpl *m_in1; + SVGAnimatedNumberImpl *m_surfaceScale; + SVGAnimatedNumberImpl *m_diffuseConstant; + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEDisplacementMapElementImpl.cc b/ksvg/impl/SVGFEDisplacementMapElementImpl.cc new file mode 100644 index 00000000..92665ec7 --- /dev/null +++ b/ksvg/impl/SVGFEDisplacementMapElementImpl.cc @@ -0,0 +1,85 @@ +/* + 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 "SVGAnimatedStringImpl.h" +#include "SVGAnimatedNumberImpl.h" +#include "SVGAnimatedEnumerationImpl.h" +#include "SVGFEDisplacementMapElementImpl.h" + +using namespace KSVG; + +SVGFEDisplacementMapElementImpl::SVGFEDisplacementMapElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGFilterPrimitiveStandardAttributesImpl() +{ + m_in1 = new SVGAnimatedStringImpl(); + m_in1->ref(); + + m_in2 = new SVGAnimatedStringImpl(); + m_in2->ref(); + + m_scale = new SVGAnimatedNumberImpl(); + m_scale->ref(); + + m_xChannelSelector = new SVGAnimatedEnumerationImpl(); + m_xChannelSelector->ref(); + + m_yChannelSelector = new SVGAnimatedEnumerationImpl(); + m_yChannelSelector->ref(); +} + +SVGFEDisplacementMapElementImpl::~SVGFEDisplacementMapElementImpl() +{ + if(m_in1) + m_in1->deref(); + if(m_in2) + m_in2->deref(); + if(m_scale) + m_scale->deref(); + if(m_xChannelSelector) + m_xChannelSelector->deref(); + if(m_yChannelSelector) + m_yChannelSelector->deref(); +} + +SVGAnimatedStringImpl *SVGFEDisplacementMapElementImpl::in1() const +{ + return m_in1; +} + +SVGAnimatedStringImpl *SVGFEDisplacementMapElementImpl::in2() const +{ + return m_in2; +} + +SVGAnimatedNumberImpl *SVGFEDisplacementMapElementImpl::scale() const +{ + return m_scale; +} + +SVGAnimatedEnumerationImpl *SVGFEDisplacementMapElementImpl::xChannelSelector() const +{ + return m_xChannelSelector; +} + +SVGAnimatedEnumerationImpl *SVGFEDisplacementMapElementImpl::yChannelSelector() const +{ + return m_yChannelSelector; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEDisplacementMapElementImpl.h b/ksvg/impl/SVGFEDisplacementMapElementImpl.h new file mode 100644 index 00000000..3774b6cc --- /dev/null +++ b/ksvg/impl/SVGFEDisplacementMapElementImpl.h @@ -0,0 +1,64 @@ +/* + 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. +*/ + +#ifndef SVGFEDisplacementMapElementImpl_H +#define SVGFEDisplacementMapElementImpl_H + +#include "SVGElementImpl.h" +#include "SVGFilterPrimitiveStandardAttributesImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedStringImpl; +class SVGAnimatedNumberImpl; +class SVGAnimatedEnumerationImpl; +class SVGFEDisplacementMapElementImpl : public SVGElementImpl, + public SVGFilterPrimitiveStandardAttributesImpl +{ +public: + SVGFEDisplacementMapElementImpl(DOM::ElementImpl *); + virtual ~SVGFEDisplacementMapElementImpl(); + + SVGAnimatedStringImpl *in1() const; + SVGAnimatedStringImpl *in2() const; + SVGAnimatedNumberImpl *scale() const; + SVGAnimatedEnumerationImpl *xChannelSelector() const; + SVGAnimatedEnumerationImpl *yChannelSelector() const; + +private: + SVGAnimatedStringImpl *m_in1; + SVGAnimatedStringImpl *m_in2; + SVGAnimatedNumberImpl *m_scale; + SVGAnimatedEnumerationImpl *m_xChannelSelector; + SVGAnimatedEnumerationImpl *m_yChannelSelector; + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEDistantLightElementImpl.cc b/ksvg/impl/SVGFEDistantLightElementImpl.cc new file mode 100644 index 00000000..b40885e0 --- /dev/null +++ b/ksvg/impl/SVGFEDistantLightElementImpl.cc @@ -0,0 +1,53 @@ +/* + 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 "SVGAnimatedNumberImpl.h" +#include "SVGFEDistantLightElementImpl.h" + +using namespace KSVG; + +SVGFEDistantLightElementImpl::SVGFEDistantLightElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl) +{ + m_azimuth = new SVGAnimatedNumberImpl(); + m_azimuth->ref(); + + m_elevation = new SVGAnimatedNumberImpl(); + m_elevation->ref(); +} + +SVGFEDistantLightElementImpl::~SVGFEDistantLightElementImpl() +{ + if(m_azimuth) + m_azimuth->deref(); + if(m_elevation) + m_elevation->deref(); +} + +SVGAnimatedNumberImpl *SVGFEDistantLightElementImpl::azimuth() const +{ + return m_azimuth; +} + +SVGAnimatedNumberImpl *SVGFEDistantLightElementImpl::elevation() const +{ + return m_elevation; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEDistantLightElementImpl.h b/ksvg/impl/SVGFEDistantLightElementImpl.h new file mode 100644 index 00000000..4d995a44 --- /dev/null +++ b/ksvg/impl/SVGFEDistantLightElementImpl.h @@ -0,0 +1,54 @@ +/* + 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. +*/ + +#ifndef SVGFEDistantLightElementImpl_H +#define SVGFEDistantLightElementImpl_H + +#include "SVGElementImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedNumberImpl; +class SVGFEDistantLightElementImpl : public SVGElementImpl +{ +public: + SVGFEDistantLightElementImpl(DOM::ElementImpl *); + virtual ~SVGFEDistantLightElementImpl(); + + SVGAnimatedNumberImpl *azimuth() const; + SVGAnimatedNumberImpl *elevation() const; + +private: + SVGAnimatedNumberImpl *m_azimuth; + SVGAnimatedNumberImpl *m_elevation; + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEFloodElementImpl.cc b/ksvg/impl/SVGFEFloodElementImpl.cc new file mode 100644 index 00000000..7cbecafd --- /dev/null +++ b/ksvg/impl/SVGFEFloodElementImpl.cc @@ -0,0 +1,43 @@ +/* + 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 "SVGFEFloodElementImpl.h" +#include "SVGAnimatedStringImpl.h" + +using namespace KSVG; + +SVGFEFloodElementImpl::SVGFEFloodElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGStylableImpl(this), SVGFilterPrimitiveStandardAttributesImpl() +{ + m_in1 = new SVGAnimatedStringImpl(); + m_in1->ref(); +} + +SVGFEFloodElementImpl::~SVGFEFloodElementImpl() +{ + if(m_in1) + m_in1->deref(); +} + +SVGAnimatedStringImpl *SVGFEFloodElementImpl::in1() const +{ + return m_in1; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEFloodElementImpl.h b/ksvg/impl/SVGFEFloodElementImpl.h new file mode 100644 index 00000000..858959a9 --- /dev/null +++ b/ksvg/impl/SVGFEFloodElementImpl.h @@ -0,0 +1,56 @@ +/* + 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. +*/ + +#ifndef SVGFEFloodElementImpl_H +#define SVGFEFloodElementImpl_H + +#include "SVGElementImpl.h" +#include "SVGStylableImpl.h" +#include "SVGFilterPrimitiveStandardAttributesImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedStringImpl; +class SVGFEFloodElementImpl : public SVGElementImpl, + public SVGStylableImpl, + public SVGFilterPrimitiveStandardAttributesImpl +{ +public: + SVGFEFloodElementImpl(DOM::ElementImpl *); + virtual ~SVGFEFloodElementImpl(); + + SVGAnimatedStringImpl *in1() const; + +private: + SVGAnimatedStringImpl *m_in1; + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEFuncAElementImpl.cc b/ksvg/impl/SVGFEFuncAElementImpl.cc new file mode 100644 index 00000000..c7a535fa --- /dev/null +++ b/ksvg/impl/SVGFEFuncAElementImpl.cc @@ -0,0 +1,33 @@ +/* + 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 "SVGFEFuncAElementImpl.h" + +using namespace KSVG; + +SVGFEFuncAElementImpl::SVGFEFuncAElementImpl(DOM::ElementImpl *impl) : SVGComponentTransferFunctionElementImpl(impl) +{ +} + +SVGFEFuncAElementImpl::~SVGFEFuncAElementImpl() +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEFuncAElementImpl.h b/ksvg/impl/SVGFEFuncAElementImpl.h new file mode 100644 index 00000000..7999c7e2 --- /dev/null +++ b/ksvg/impl/SVGFEFuncAElementImpl.h @@ -0,0 +1,46 @@ +/* + 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. +*/ + +#ifndef SVGFEFuncAElementImpl_H +#define SVGFEFuncAElementImpl_H + +#include "SVGComponentTransferFunctionElementImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGFEFuncAElementImpl : public SVGComponentTransferFunctionElementImpl +{ +public: + SVGFEFuncAElementImpl(DOM::ElementImpl *); + virtual ~SVGFEFuncAElementImpl(); + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEFuncBElementImpl.cc b/ksvg/impl/SVGFEFuncBElementImpl.cc new file mode 100644 index 00000000..4b0bbf71 --- /dev/null +++ b/ksvg/impl/SVGFEFuncBElementImpl.cc @@ -0,0 +1,33 @@ +/* + 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 "SVGFEFuncBElementImpl.h" + +using namespace KSVG; + +SVGFEFuncBElementImpl::SVGFEFuncBElementImpl(DOM::ElementImpl *impl) : SVGComponentTransferFunctionElementImpl(impl) +{ +} + +SVGFEFuncBElementImpl::~SVGFEFuncBElementImpl() +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEFuncBElementImpl.h b/ksvg/impl/SVGFEFuncBElementImpl.h new file mode 100644 index 00000000..7236debb --- /dev/null +++ b/ksvg/impl/SVGFEFuncBElementImpl.h @@ -0,0 +1,45 @@ +/* + 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. +*/ + +#ifndef SVGFEFuncBElementImpl_H +#define SVGFEFuncBElementImpl_H + +#include "SVGComponentTransferFunctionElementImpl.h" +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGFEFuncBElementImpl : public SVGComponentTransferFunctionElementImpl +{ +public: + SVGFEFuncBElementImpl(DOM::ElementImpl *); + virtual ~SVGFEFuncBElementImpl(); + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEFuncGElementImpl.cc b/ksvg/impl/SVGFEFuncGElementImpl.cc new file mode 100644 index 00000000..8a60fbee --- /dev/null +++ b/ksvg/impl/SVGFEFuncGElementImpl.cc @@ -0,0 +1,33 @@ +/* + 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 "SVGFEFuncGElementImpl.h" + +using namespace KSVG; + +SVGFEFuncGElementImpl::SVGFEFuncGElementImpl(DOM::ElementImpl *impl) : SVGComponentTransferFunctionElementImpl(impl) +{ +} + +SVGFEFuncGElementImpl::~SVGFEFuncGElementImpl() +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEFuncGElementImpl.h b/ksvg/impl/SVGFEFuncGElementImpl.h new file mode 100644 index 00000000..44baec8d --- /dev/null +++ b/ksvg/impl/SVGFEFuncGElementImpl.h @@ -0,0 +1,46 @@ +/* + 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. +*/ + +#ifndef SVGFEFuncGElementImpl_H +#define SVGFEFuncGElementImpl_H + +#include "SVGComponentTransferFunctionElementImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGFEFuncGElementImpl : public SVGComponentTransferFunctionElementImpl +{ +public: + SVGFEFuncGElementImpl(DOM::ElementImpl *); + virtual ~SVGFEFuncGElementImpl(); + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEFuncRElementImpl.cc b/ksvg/impl/SVGFEFuncRElementImpl.cc new file mode 100644 index 00000000..fe1b2d44 --- /dev/null +++ b/ksvg/impl/SVGFEFuncRElementImpl.cc @@ -0,0 +1,33 @@ +/* + 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 "SVGFEFuncRElementImpl.h" + +using namespace KSVG; + +SVGFEFuncRElementImpl::SVGFEFuncRElementImpl(DOM::ElementImpl *impl) : SVGComponentTransferFunctionElementImpl(impl) +{ +} + +SVGFEFuncRElementImpl::~SVGFEFuncRElementImpl() +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEFuncRElementImpl.h b/ksvg/impl/SVGFEFuncRElementImpl.h new file mode 100644 index 00000000..17aa7812 --- /dev/null +++ b/ksvg/impl/SVGFEFuncRElementImpl.h @@ -0,0 +1,46 @@ +/* + 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. +*/ + +#ifndef SVGFEFuncRElementImpl_H +#define SVGFEFuncRElementImpl_H + +#include "SVGComponentTransferFunctionElementImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGFEFuncRElementImpl : public SVGComponentTransferFunctionElementImpl +{ +public: + SVGFEFuncRElementImpl(DOM::ElementImpl *); + virtual ~SVGFEFuncRElementImpl(); + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEGaussianBlurElementImpl.cc b/ksvg/impl/SVGFEGaussianBlurElementImpl.cc new file mode 100644 index 00000000..bcc2e0bf --- /dev/null +++ b/ksvg/impl/SVGFEGaussianBlurElementImpl.cc @@ -0,0 +1,68 @@ +/* + 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 "SVGAnimatedStringImpl.h" +#include "SVGAnimatedNumberImpl.h" +#include "SVGFEGaussianBlurElementImpl.h" + +using namespace KSVG; + +SVGFEGaussianBlurElementImpl::SVGFEGaussianBlurElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGFilterPrimitiveStandardAttributesImpl() +{ + m_in1 = new SVGAnimatedStringImpl(); + m_in1->ref(); + + m_stdDeviationX = new SVGAnimatedNumberImpl(); + m_stdDeviationX->ref(); + + m_stdDeviationY = new SVGAnimatedNumberImpl(); + m_stdDeviationY->ref(); +} + +SVGFEGaussianBlurElementImpl::~SVGFEGaussianBlurElementImpl() +{ + if(m_in1) + m_in1->deref(); + if(m_stdDeviationX) + m_stdDeviationX->deref(); + if(m_stdDeviationY) + m_stdDeviationY->deref(); +} + +SVGAnimatedStringImpl *SVGFEGaussianBlurElementImpl::in1() const +{ + return m_in1; +} + +SVGAnimatedNumberImpl *SVGFEGaussianBlurElementImpl::stdDeviationX() const +{ + return m_stdDeviationX; +} + +SVGAnimatedNumberImpl *SVGFEGaussianBlurElementImpl::stdDeviationY() const +{ + return m_stdDeviationY; +} + +void SVGFEGaussianBlurElementImpl::setStdDeviation(float /*stdDeviationX*/, float /*stdDeviationY*/) +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEGaussianBlurElementImpl.h b/ksvg/impl/SVGFEGaussianBlurElementImpl.h new file mode 100644 index 00000000..97707edb --- /dev/null +++ b/ksvg/impl/SVGFEGaussianBlurElementImpl.h @@ -0,0 +1,60 @@ +/* + 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. +*/ + +#ifndef SVGFEGaussianBlurElementImpl_H +#define SVGFEGaussianBlurElementImpl_H + +#include "SVGElementImpl.h" +#include "SVGFilterPrimitiveStandardAttributesImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedStringImpl; +class SVGAnimatedNumberImpl; +class SVGFEGaussianBlurElementImpl : public SVGElementImpl, + public SVGFilterPrimitiveStandardAttributesImpl +{ +public: + SVGFEGaussianBlurElementImpl(DOM::ElementImpl *); + virtual ~SVGFEGaussianBlurElementImpl(); + + SVGAnimatedStringImpl *in1() const; + SVGAnimatedNumberImpl *stdDeviationX() const; + SVGAnimatedNumberImpl *stdDeviationY() const; + void setStdDeviation(float stdDeviationX, float stdDeviationY); + +private: + SVGAnimatedStringImpl *m_in1; + SVGAnimatedNumberImpl *m_stdDeviationX; + SVGAnimatedNumberImpl *m_stdDeviationY; + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEImageElementImpl.cc b/ksvg/impl/SVGFEImageElementImpl.cc new file mode 100644 index 00000000..f41e482d --- /dev/null +++ b/ksvg/impl/SVGFEImageElementImpl.cc @@ -0,0 +1,33 @@ +/* + 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 "SVGFEImageElementImpl.h" + +using namespace KSVG; + +SVGFEImageElementImpl::SVGFEImageElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGURIReferenceImpl(), SVGLangSpaceImpl(), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this), SVGFilterPrimitiveStandardAttributesImpl() +{ +} + +SVGFEImageElementImpl::~SVGFEImageElementImpl() +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEImageElementImpl.h b/ksvg/impl/SVGFEImageElementImpl.h new file mode 100644 index 00000000..3d03e77d --- /dev/null +++ b/ksvg/impl/SVGFEImageElementImpl.h @@ -0,0 +1,56 @@ +/* + 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. +*/ + +#ifndef SVGFEImageElementImpl_H +#define SVGFEImageElementImpl_H + +#include "SVGElementImpl.h" +#include "SVGStylableImpl.h" +#include "SVGLangSpaceImpl.h" +#include "SVGURIReferenceImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" +#include "SVGFilterPrimitiveStandardAttributesImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGFEImageElementImpl : public SVGElementImpl, + public SVGURIReferenceImpl, + public SVGLangSpaceImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl, + public SVGFilterPrimitiveStandardAttributesImpl +{ +public: + SVGFEImageElementImpl(DOM::ElementImpl *); + virtual ~SVGFEImageElementImpl(); + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEMergeElementImpl.cc b/ksvg/impl/SVGFEMergeElementImpl.cc new file mode 100644 index 00000000..6eca907a --- /dev/null +++ b/ksvg/impl/SVGFEMergeElementImpl.cc @@ -0,0 +1,33 @@ +/* + 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 "SVGFEMergeElementImpl.h" + +using namespace KSVG; + +SVGFEMergeElementImpl::SVGFEMergeElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGFilterPrimitiveStandardAttributesImpl() +{ +} + +SVGFEMergeElementImpl::~SVGFEMergeElementImpl() +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEMergeElementImpl.h b/ksvg/impl/SVGFEMergeElementImpl.h new file mode 100644 index 00000000..f4b6aaaf --- /dev/null +++ b/ksvg/impl/SVGFEMergeElementImpl.h @@ -0,0 +1,48 @@ +/* + 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. +*/ + +#ifndef SVGFEMergeElementImpl_H +#define SVGFEMergeElementImpl_H + +#include "SVGElementImpl.h" +#include "SVGFilterPrimitiveStandardAttributesImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGFEMergeElementImpl : public SVGElementImpl, + public SVGFilterPrimitiveStandardAttributesImpl +{ +public: + SVGFEMergeElementImpl(DOM::ElementImpl *); + virtual ~SVGFEMergeElementImpl(); + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEMergeNodeElementImpl.cc b/ksvg/impl/SVGFEMergeNodeElementImpl.cc new file mode 100644 index 00000000..1191df3b --- /dev/null +++ b/ksvg/impl/SVGFEMergeNodeElementImpl.cc @@ -0,0 +1,43 @@ +/* + 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 "SVGAnimatedStringImpl.h" +#include "SVGFEMergeNodeElementImpl.h" + +using namespace KSVG; + +SVGFEMergeNodeElementImpl::SVGFEMergeNodeElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl) +{ + m_in1 = new SVGAnimatedStringImpl(); + m_in1->ref(); +} + +SVGFEMergeNodeElementImpl::~SVGFEMergeNodeElementImpl() +{ + if(m_in1) + m_in1->deref(); +} + +SVGAnimatedStringImpl *SVGFEMergeNodeElementImpl::in1() const +{ + return m_in1; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEMergeNodeElementImpl.h b/ksvg/impl/SVGFEMergeNodeElementImpl.h new file mode 100644 index 00000000..5b380757 --- /dev/null +++ b/ksvg/impl/SVGFEMergeNodeElementImpl.h @@ -0,0 +1,52 @@ +/* + 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. +*/ + +#ifndef SVGFEMergeNodeElementImpl_H +#define SVGFEMergeNodeElementImpl_H + +#include "SVGElementImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedStringImpl; +class SVGFEMergeNodeElementImpl : public SVGElementImpl +{ +public: + SVGFEMergeNodeElementImpl(DOM::ElementImpl *); + virtual ~SVGFEMergeNodeElementImpl(); + + SVGAnimatedStringImpl *in1() const; + +private: + SVGAnimatedStringImpl *m_in1; + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEMorphologyElementImpl.cc b/ksvg/impl/SVGFEMorphologyElementImpl.cc new file mode 100644 index 00000000..e7f1a100 --- /dev/null +++ b/ksvg/impl/SVGFEMorphologyElementImpl.cc @@ -0,0 +1,75 @@ +/* + 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 "SVGAnimatedStringImpl.h" +#include "SVGAnimatedLengthImpl.h" +#include "SVGAnimatedEnumerationImpl.h" +#include "SVGFEMorphologyElementImpl.h" + +using namespace KSVG; + +SVGFEMorphologyElementImpl::SVGFEMorphologyElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGFilterPrimitiveStandardAttributesImpl() +{ + m_in1 = new SVGAnimatedStringImpl(); + m_in1->ref(); + + m_operator = new SVGAnimatedEnumerationImpl(); + m_operator->ref(); + + m_radiusX = new SVGAnimatedLengthImpl(); + m_radiusX->ref(); + + m_radiusY = new SVGAnimatedLengthImpl(); + m_radiusY->ref(); +} + +SVGFEMorphologyElementImpl::~SVGFEMorphologyElementImpl() +{ + if(m_in1) + m_in1->deref(); + if(m_operator) + m_operator->deref(); + if(m_radiusX) + m_radiusX->deref(); + if(m_radiusY) + m_radiusY->deref(); +} + +SVGAnimatedStringImpl *SVGFEMorphologyElementImpl::in1() const +{ + return m_in1; +} + +SVGAnimatedEnumerationImpl *SVGFEMorphologyElementImpl::Operator() const +{ + return m_operator; +} + +SVGAnimatedLengthImpl *SVGFEMorphologyElementImpl::radiusX() const +{ + return m_radiusX; +} + +SVGAnimatedLengthImpl *SVGFEMorphologyElementImpl::radiusY() const +{ + return m_radiusY; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEMorphologyElementImpl.h b/ksvg/impl/SVGFEMorphologyElementImpl.h new file mode 100644 index 00000000..7941e772 --- /dev/null +++ b/ksvg/impl/SVGFEMorphologyElementImpl.h @@ -0,0 +1,62 @@ +/* + 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. +*/ + +#ifndef SVGFEMorphologyElementImpl_H +#define SVGFEMorphologyElementImpl_H + +#include "SVGElementImpl.h" +#include "SVGFilterPrimitiveStandardAttributesImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedStringImpl; +class SVGAnimatedLengthImpl; +class SVGAnimatedEnumerationImpl; +class SVGFEMorphologyElementImpl : public SVGElementImpl, + public SVGFilterPrimitiveStandardAttributesImpl +{ +public: + SVGFEMorphologyElementImpl(DOM::ElementImpl *impl); + virtual ~SVGFEMorphologyElementImpl(); + + SVGAnimatedStringImpl *in1() const; + SVGAnimatedEnumerationImpl *Operator() const; + SVGAnimatedLengthImpl *radiusX() const; + SVGAnimatedLengthImpl *radiusY() const; + +private: + SVGAnimatedStringImpl *m_in1; + SVGAnimatedEnumerationImpl *m_operator; + SVGAnimatedLengthImpl *m_radiusX; + SVGAnimatedLengthImpl *m_radiusY; + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEOffsetElementImpl.cc b/ksvg/impl/SVGFEOffsetElementImpl.cc new file mode 100644 index 00000000..8c8bfbeb --- /dev/null +++ b/ksvg/impl/SVGFEOffsetElementImpl.cc @@ -0,0 +1,64 @@ +/* + 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 "SVGAnimatedStringImpl.h" +#include "SVGAnimatedNumberImpl.h" +#include "SVGFEOffsetElementImpl.h" + +using namespace KSVG; + +SVGFEOffsetElementImpl::SVGFEOffsetElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGFilterPrimitiveStandardAttributesImpl() +{ + m_in1 = new SVGAnimatedStringImpl(); + m_in1->ref(); + + m_dx = new SVGAnimatedNumberImpl(); + m_dx->ref(); + + m_dy = new SVGAnimatedNumberImpl(); + m_dy->ref(); +} + +SVGFEOffsetElementImpl::~SVGFEOffsetElementImpl() +{ + if(m_in1) + m_in1->deref(); + if(m_dx) + m_dx->deref(); + if(m_dy) + m_dy->deref(); +} + +SVGAnimatedStringImpl *SVGFEOffsetElementImpl::in1() const +{ + return m_in1; +} + +SVGAnimatedNumberImpl *SVGFEOffsetElementImpl::dx() const +{ + return m_dx; +} + +SVGAnimatedNumberImpl *SVGFEOffsetElementImpl::dy() const +{ + return m_dy; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEOffsetElementImpl.h b/ksvg/impl/SVGFEOffsetElementImpl.h new file mode 100644 index 00000000..e8c3448a --- /dev/null +++ b/ksvg/impl/SVGFEOffsetElementImpl.h @@ -0,0 +1,59 @@ +/* + 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. +*/ + +#ifndef SVGFEOffsetElementImpl_H +#define SVGFEOffsetElementImpl_H + +#include "SVGElementImpl.h" +#include "SVGFilterPrimitiveStandardAttributesImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedStringImpl; +class SVGAnimatedNumberImpl; +class SVGFEOffsetElementImpl : public SVGElementImpl, + public SVGFilterPrimitiveStandardAttributesImpl +{ +public: + SVGFEOffsetElementImpl(DOM::ElementImpl *impl); + virtual ~SVGFEOffsetElementImpl(); + + SVGAnimatedStringImpl *in1() const; + SVGAnimatedNumberImpl *dx() const; + SVGAnimatedNumberImpl *dy() const; + +private: + SVGAnimatedStringImpl *m_in1; + SVGAnimatedNumberImpl *m_dx; + SVGAnimatedNumberImpl *m_dy; + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEPointLightElementImpl.cc b/ksvg/impl/SVGFEPointLightElementImpl.cc new file mode 100644 index 00000000..ad95d20a --- /dev/null +++ b/ksvg/impl/SVGFEPointLightElementImpl.cc @@ -0,0 +1,63 @@ +/* + 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 "SVGAnimatedNumberImpl.h" +#include "SVGFEPointLightElementImpl.h" + +using namespace KSVG; + +SVGFEPointLightElementImpl::SVGFEPointLightElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl) +{ + m_x = new SVGAnimatedNumberImpl(); + m_x->ref(); + + m_y = new SVGAnimatedNumberImpl(); + m_y->ref(); + + m_z = new SVGAnimatedNumberImpl(); + m_z->ref(); +} + +SVGFEPointLightElementImpl::~SVGFEPointLightElementImpl() +{ + if(m_x) + m_x->deref(); + if(m_y) + m_y->deref(); + if(m_z) + m_z->deref(); +} + +SVGAnimatedNumberImpl *SVGFEPointLightElementImpl::x() const +{ + return m_x; +} + +SVGAnimatedNumberImpl *SVGFEPointLightElementImpl::y() const +{ + return m_y; +} + +SVGAnimatedNumberImpl *SVGFEPointLightElementImpl::z() const +{ + return m_z; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFEPointLightElementImpl.h b/ksvg/impl/SVGFEPointLightElementImpl.h new file mode 100644 index 00000000..6d66c98b --- /dev/null +++ b/ksvg/impl/SVGFEPointLightElementImpl.h @@ -0,0 +1,56 @@ +/* + 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. +*/ + +#ifndef SVGFEPointLightElementImpl_H +#define SVGFEPointLightElementImpl_H + +#include "SVGElementImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedNumberImpl; +class SVGFEPointLightElementImpl : public SVGElementImpl +{ +public: + SVGFEPointLightElementImpl(DOM::ElementImpl *); + virtual ~SVGFEPointLightElementImpl(); + + SVGAnimatedNumberImpl *x() const; + SVGAnimatedNumberImpl *y() const; + SVGAnimatedNumberImpl *z() const; + +private: + SVGAnimatedNumberImpl *m_x; + SVGAnimatedNumberImpl *m_y; + SVGAnimatedNumberImpl *m_z; + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFESpecularLightingElementImpl.cc b/ksvg/impl/SVGFESpecularLightingElementImpl.cc new file mode 100644 index 00000000..9974e146 --- /dev/null +++ b/ksvg/impl/SVGFESpecularLightingElementImpl.cc @@ -0,0 +1,74 @@ +/* + 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 "SVGAnimatedStringImpl.h" +#include "SVGAnimatedNumberImpl.h" +#include "SVGFESpecularLightingElementImpl.h" + +using namespace KSVG; + +SVGFESpecularLightingElementImpl::SVGFESpecularLightingElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGFilterPrimitiveStandardAttributesImpl() +{ + m_in1 = new SVGAnimatedStringImpl(); + m_in1->ref(); + + m_surfaceScale = new SVGAnimatedNumberImpl(); + m_surfaceScale->ref(); + + m_specularConstant = new SVGAnimatedNumberImpl(); + m_specularConstant->ref(); + + m_specularExponent = new SVGAnimatedNumberImpl(); + m_specularExponent->ref(); +} + +SVGFESpecularLightingElementImpl::~SVGFESpecularLightingElementImpl() +{ + if(m_in1) + m_in1->deref(); + if(m_surfaceScale) + m_surfaceScale->deref(); + if(m_specularConstant) + m_specularConstant->deref(); + if(m_specularExponent) + m_specularExponent->deref(); +} + +SVGAnimatedStringImpl *SVGFESpecularLightingElementImpl::in1() const +{ + return m_in1; +} + +SVGAnimatedNumberImpl *SVGFESpecularLightingElementImpl::surfaceScale() const +{ + return m_surfaceScale; +} + +SVGAnimatedNumberImpl *SVGFESpecularLightingElementImpl::specularConstant() const +{ + return m_specularConstant; +} + +SVGAnimatedNumberImpl *SVGFESpecularLightingElementImpl::specularExponent() const +{ + return m_specularExponent; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFESpecularLightingElementImpl.h b/ksvg/impl/SVGFESpecularLightingElementImpl.h new file mode 100644 index 00000000..527e7f5b --- /dev/null +++ b/ksvg/impl/SVGFESpecularLightingElementImpl.h @@ -0,0 +1,61 @@ +/* + 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. +*/ + +#ifndef SVGFESpecularLightingElementImpl_H +#define SVGFESpecularLightingElementImpl_H + +#include "SVGElementImpl.h" +#include "SVGFilterPrimitiveStandardAttributesImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedStringImpl; +class SVGAnimatedNumberImpl; +class SVGFESpecularLightingElementImpl : public SVGElementImpl, + public SVGFilterPrimitiveStandardAttributesImpl +{ +public: + SVGFESpecularLightingElementImpl(DOM::ElementImpl *); + virtual ~SVGFESpecularLightingElementImpl(); + + SVGAnimatedStringImpl *in1() const; + SVGAnimatedNumberImpl *surfaceScale() const; + SVGAnimatedNumberImpl *specularConstant() const; + SVGAnimatedNumberImpl *specularExponent() const; + +private: + SVGAnimatedStringImpl *m_in1; + SVGAnimatedNumberImpl *m_surfaceScale; + SVGAnimatedNumberImpl *m_specularConstant; + SVGAnimatedNumberImpl *m_specularExponent; + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFESpotLightElementImpl.cc b/ksvg/impl/SVGFESpotLightElementImpl.cc new file mode 100644 index 00000000..96950eda --- /dev/null +++ b/ksvg/impl/SVGFESpotLightElementImpl.cc @@ -0,0 +1,113 @@ +/* + 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 "SVGAnimatedNumberImpl.h" +#include "SVGFESpotLightElementImpl.h" + +using namespace KSVG; + +SVGFESpotLightElementImpl::SVGFESpotLightElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl) +{ + m_x = new SVGAnimatedNumberImpl(); + m_x->ref(); + + m_y = new SVGAnimatedNumberImpl(); + m_y->ref(); + + m_z = new SVGAnimatedNumberImpl(); + m_z->ref(); + + m_pointsAtX = new SVGAnimatedNumberImpl(); + m_pointsAtX->ref(); + + m_pointsAtY = new SVGAnimatedNumberImpl(); + m_pointsAtY->ref(); + + m_pointsAtZ = new SVGAnimatedNumberImpl(); + m_pointsAtZ->ref(); + + m_specularExponent = new SVGAnimatedNumberImpl(); + m_specularExponent->ref(); + + m_limitingConeAngle = new SVGAnimatedNumberImpl(); + m_limitingConeAngle->ref(); +} + +SVGFESpotLightElementImpl::~SVGFESpotLightElementImpl() +{ + if(m_x) + m_x->deref(); + if(m_y) + m_y->deref(); + if(m_z) + m_z->deref(); + if(m_pointsAtX) + m_pointsAtX->deref(); + if(m_pointsAtY) + m_pointsAtY->deref(); + if(m_pointsAtZ) + m_pointsAtZ->deref(); + if(m_specularExponent) + m_specularExponent->deref(); + if(m_limitingConeAngle) + m_limitingConeAngle->deref(); +} + +SVGAnimatedNumberImpl *SVGFESpotLightElementImpl::x() const +{ + return m_x; +} + +SVGAnimatedNumberImpl *SVGFESpotLightElementImpl::y() const +{ + return m_y; +} + +SVGAnimatedNumberImpl *SVGFESpotLightElementImpl::z() const +{ + return m_z; +} + +SVGAnimatedNumberImpl *SVGFESpotLightElementImpl::pointsAtX() const +{ + return m_pointsAtX; +} + +SVGAnimatedNumberImpl *SVGFESpotLightElementImpl::pointsAtY() const +{ + return m_pointsAtY; +} + +SVGAnimatedNumberImpl *SVGFESpotLightElementImpl::pointsAtZ() const +{ + return m_pointsAtZ; +} + +SVGAnimatedNumberImpl *SVGFESpotLightElementImpl::specularExponent() const +{ + return m_specularExponent; +} + +SVGAnimatedNumberImpl *SVGFESpotLightElementImpl::limitingConeAngle() const +{ + return m_limitingConeAngle; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFESpotLightElementImpl.h b/ksvg/impl/SVGFESpotLightElementImpl.h new file mode 100644 index 00000000..3c808698 --- /dev/null +++ b/ksvg/impl/SVGFESpotLightElementImpl.h @@ -0,0 +1,65 @@ +/* + 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. +*/ + +#ifndef SVGFESpotLightElementImpl_H +#define SVGFESpotLightElementImpl_H + +#include "SVGElementImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedNumberImpl; +class SVGFESpotLightElementImpl : public SVGElementImpl +{ +public: + SVGFESpotLightElementImpl(DOM::ElementImpl *); + virtual ~SVGFESpotLightElementImpl(); + + SVGAnimatedNumberImpl *x() const; + SVGAnimatedNumberImpl *y() const; + SVGAnimatedNumberImpl *z() const; + SVGAnimatedNumberImpl *pointsAtX() const; + SVGAnimatedNumberImpl *pointsAtY() const; + SVGAnimatedNumberImpl *pointsAtZ() const; + SVGAnimatedNumberImpl *specularExponent() const; + SVGAnimatedNumberImpl *limitingConeAngle() const; + +private: + SVGAnimatedNumberImpl *m_x; + SVGAnimatedNumberImpl *m_y; + SVGAnimatedNumberImpl *m_z; + SVGAnimatedNumberImpl *m_pointsAtX; + SVGAnimatedNumberImpl *m_pointsAtY; + SVGAnimatedNumberImpl *m_pointsAtZ; + SVGAnimatedNumberImpl *m_specularExponent; + SVGAnimatedNumberImpl *m_limitingConeAngle; +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFETileElementImpl.cc b/ksvg/impl/SVGFETileElementImpl.cc new file mode 100644 index 00000000..2a794302 --- /dev/null +++ b/ksvg/impl/SVGFETileElementImpl.cc @@ -0,0 +1,43 @@ +/* + 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 "SVGFETileElementImpl.h" +#include "SVGAnimatedStringImpl.h" + +using namespace KSVG; + +SVGFETileElementImpl::SVGFETileElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGFilterPrimitiveStandardAttributesImpl() +{ + m_in1 = new SVGAnimatedStringImpl(); + m_in1->ref(); +} + +SVGFETileElementImpl::~SVGFETileElementImpl() +{ + if(m_in1) + m_in1->deref(); +} + +SVGAnimatedStringImpl *SVGFETileElementImpl::in1() const +{ + return m_in1; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFETileElementImpl.h b/ksvg/impl/SVGFETileElementImpl.h new file mode 100644 index 00000000..29cd4167 --- /dev/null +++ b/ksvg/impl/SVGFETileElementImpl.h @@ -0,0 +1,54 @@ +/* + 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. +*/ + +#ifndef SVGFETileElementImpl_H +#define SVGFETileElementImpl_H + +#include "SVGElementImpl.h" +#include "SVGFilterPrimitiveStandardAttributesImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedStringImpl; +class SVGFETileElementImpl : public SVGElementImpl, + public SVGFilterPrimitiveStandardAttributesImpl +{ +public: + SVGFETileElementImpl(DOM::ElementImpl *); + virtual ~SVGFETileElementImpl(); + + SVGAnimatedStringImpl *in1() const; + +private: + SVGAnimatedStringImpl *m_in1; + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFETurbulenceElementImpl.cc b/ksvg/impl/SVGFETurbulenceElementImpl.cc new file mode 100644 index 00000000..79c68de3 --- /dev/null +++ b/ksvg/impl/SVGFETurbulenceElementImpl.cc @@ -0,0 +1,100 @@ +/* + 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 "SVGAnimatedNumberImpl.h" +#include "SVGAnimatedIntegerImpl.h" +#include "SVGAnimatedEnumerationImpl.h" +#include "SVGFETurbulenceElementImpl.h" + +using namespace KSVG; + +SVGFETurbulenceElementImpl::SVGFETurbulenceElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGFilterPrimitiveStandardAttributesImpl() +{ + m_baseFrequencyX = new SVGAnimatedNumberImpl(); + m_baseFrequencyX->ref(); + + m_baseFrequencyY = new SVGAnimatedNumberImpl(); + m_baseFrequencyY->ref(); + + m_numOctaves = new SVGAnimatedIntegerImpl(); + m_numOctaves->ref(); + + m_seed = new SVGAnimatedNumberImpl(); + m_seed->ref(); + + m_stitchTiles = new SVGAnimatedEnumerationImpl(); + m_stitchTiles->ref(); + + m_type = new SVGAnimatedEnumerationImpl(); + m_type->ref(); +} + +SVGFETurbulenceElementImpl::~SVGFETurbulenceElementImpl() +{ + if(m_baseFrequencyX) + m_baseFrequencyX->deref(); + + if(m_baseFrequencyY) + m_baseFrequencyY->deref(); + + if(m_numOctaves) + m_numOctaves->deref(); + + if(m_seed) + m_seed->deref(); + + if(m_stitchTiles) + m_stitchTiles->deref(); + + if(m_type) + m_type->deref(); +} + +SVGAnimatedNumberImpl *SVGFETurbulenceElementImpl::baseFrequencyX() const +{ + return m_baseFrequencyX; +} + +SVGAnimatedNumberImpl *SVGFETurbulenceElementImpl::baseFrequencyY() const +{ + return m_baseFrequencyY; +} + +SVGAnimatedIntegerImpl *SVGFETurbulenceElementImpl::numOctaves() const +{ + return m_numOctaves; +} + +SVGAnimatedNumberImpl *SVGFETurbulenceElementImpl::seed() const +{ + return m_seed; +} + +SVGAnimatedEnumerationImpl *SVGFETurbulenceElementImpl::stitchTiles() const +{ + return m_stitchTiles; +} + +SVGAnimatedEnumerationImpl *SVGFETurbulenceElementImpl::type() const +{ + return m_type; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFETurbulenceElementImpl.h b/ksvg/impl/SVGFETurbulenceElementImpl.h new file mode 100644 index 00000000..1275f8ca --- /dev/null +++ b/ksvg/impl/SVGFETurbulenceElementImpl.h @@ -0,0 +1,65 @@ +/* + 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. +*/ + +#ifndef SVGFETurbulenceElementImpl_H +#define SVGFETurbulenceElementImpl_H + +#include "SVGElementImpl.h" +#include "SVGFilterPrimitiveStandardAttributesImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedNumberImpl; +class SVGAnimatedIntegerImpl; +class SVGAnimatedEnumerationImpl; +class SVGFETurbulenceElementImpl : public SVGElementImpl, public SVGFilterPrimitiveStandardAttributesImpl +{ +public: + SVGFETurbulenceElementImpl(DOM::ElementImpl *); + virtual ~SVGFETurbulenceElementImpl(); + + SVGAnimatedNumberImpl *baseFrequencyX() const; + SVGAnimatedNumberImpl *baseFrequencyY() const; + SVGAnimatedIntegerImpl *numOctaves() const; + SVGAnimatedNumberImpl *seed() const; + SVGAnimatedEnumerationImpl *stitchTiles() const; + SVGAnimatedEnumerationImpl *type() const; + +private: + SVGAnimatedNumberImpl *m_baseFrequencyX; + SVGAnimatedNumberImpl *m_baseFrequencyY; + SVGAnimatedIntegerImpl *m_numOctaves; + SVGAnimatedNumberImpl *m_seed; + SVGAnimatedEnumerationImpl *m_stitchTiles; + SVGAnimatedEnumerationImpl *m_type; + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFilterElementImpl.cc b/ksvg/impl/SVGFilterElementImpl.cc new file mode 100644 index 00000000..eb83ad4b --- /dev/null +++ b/ksvg/impl/SVGFilterElementImpl.cc @@ -0,0 +1,119 @@ +/* + 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 "SVGFilterElementImpl.h" +#include "SVGAnimatedLengthImpl.h" +#include "SVGAnimatedIntegerImpl.h" +#include "SVGAnimatedEnumerationImpl.h" + +using namespace KSVG; + +SVGFilterElementImpl::SVGFilterElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGURIReferenceImpl(), SVGLangSpaceImpl(), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this) +{ + m_filterUnits = new SVGAnimatedEnumerationImpl(); + m_filterUnits->ref(); + + m_primitiveUnits = new SVGAnimatedEnumerationImpl(); + m_primitiveUnits->ref(); + + m_x = new SVGAnimatedLengthImpl(); + m_x->ref(); + + m_y = new SVGAnimatedLengthImpl(); + m_y->ref(); + + m_width = new SVGAnimatedLengthImpl(); + m_width->ref(); + + m_height = new SVGAnimatedLengthImpl(); + m_height->ref(); + + m_filterResX = new SVGAnimatedIntegerImpl(); + m_filterResX->ref(); + + m_filterResY = new SVGAnimatedIntegerImpl(); + m_filterResY->ref(); +} + +SVGFilterElementImpl::~SVGFilterElementImpl() +{ + if(m_filterUnits) + m_filterUnits->deref(); + if(m_primitiveUnits) + m_primitiveUnits->deref(); + if(m_x) + m_x->deref(); + if(m_y) + m_y->deref(); + if(m_width) + m_width->deref(); + if(m_height) + m_height->deref(); + if(m_filterResX) + m_filterResX->deref(); + if(m_filterResY) + m_filterResY->deref(); +} + +SVGAnimatedEnumerationImpl *SVGFilterElementImpl::filterUnits() const +{ + return m_filterUnits; +} + +SVGAnimatedEnumerationImpl *SVGFilterElementImpl::primitiveUnits() const +{ + return m_primitiveUnits; +} + +SVGAnimatedLengthImpl *SVGFilterElementImpl::x() const +{ + return m_x; +} + +SVGAnimatedLengthImpl *SVGFilterElementImpl::y() const +{ + return m_y; +} + +SVGAnimatedLengthImpl *SVGFilterElementImpl::width() const +{ + return m_width; +} + +SVGAnimatedLengthImpl *SVGFilterElementImpl::height() const +{ + return m_height; +} + +SVGAnimatedIntegerImpl *SVGFilterElementImpl::filterResX() const +{ + return m_filterResX; +} + +SVGAnimatedIntegerImpl *SVGFilterElementImpl::filterResY() const +{ + return m_filterResY; +} + +void SVGFilterElementImpl::setFilterRes(unsigned long /*filterResX*/, unsigned long /*filterResY*/) +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFilterElementImpl.h b/ksvg/impl/SVGFilterElementImpl.h new file mode 100644 index 00000000..ad12a9e9 --- /dev/null +++ b/ksvg/impl/SVGFilterElementImpl.h @@ -0,0 +1,76 @@ +/* + 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. +*/ + +#ifndef SVGFilterElementImpl_H +#define SVGFilterElementImpl_H + +#include "SVGElementImpl.h" +#include "SVGStylableImpl.h" +#include "SVGLangSpaceImpl.h" +#include "SVGURIReferenceImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedLengthImpl; +class SVGAnimatedIntegerImpl; +class SVGAnimatedEnumerationImpl; +class SVGFilterElementImpl : public SVGElementImpl, + public SVGURIReferenceImpl, + public SVGLangSpaceImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl +{ +public: + SVGFilterElementImpl(DOM::ElementImpl *); + virtual ~SVGFilterElementImpl(); + + SVGAnimatedEnumerationImpl *filterUnits() const; + SVGAnimatedEnumerationImpl *primitiveUnits() const; + SVGAnimatedLengthImpl *x() const; + SVGAnimatedLengthImpl *y() const; + SVGAnimatedLengthImpl *width() const; + SVGAnimatedLengthImpl *height() const; + SVGAnimatedIntegerImpl *filterResX() const; + SVGAnimatedIntegerImpl *filterResY() const; + void setFilterRes(unsigned long filterResX, unsigned long filterResY); + +private: + SVGAnimatedEnumerationImpl *m_filterUnits; + SVGAnimatedEnumerationImpl *m_primitiveUnits; + SVGAnimatedLengthImpl *m_x; + SVGAnimatedLengthImpl *m_y; + SVGAnimatedLengthImpl *m_width; + SVGAnimatedLengthImpl *m_height; + SVGAnimatedIntegerImpl *m_filterResX; + SVGAnimatedIntegerImpl *m_filterResY; +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFilterPrimitiveStandardAttributesImpl.cc b/ksvg/impl/SVGFilterPrimitiveStandardAttributesImpl.cc new file mode 100644 index 00000000..3f403009 --- /dev/null +++ b/ksvg/impl/SVGFilterPrimitiveStandardAttributesImpl.cc @@ -0,0 +1,84 @@ +/* + 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 "SVGAnimatedLengthImpl.h" +#include "SVGAnimatedStringImpl.h" +#include "SVGFilterPrimitiveStandardAttributesImpl.h" + +using namespace KSVG; + +SVGFilterPrimitiveStandardAttributesImpl::SVGFilterPrimitiveStandardAttributesImpl() +{ + m_x = new SVGAnimatedLengthImpl(); + m_x->ref(); + + m_y = new SVGAnimatedLengthImpl(); + m_y->ref(); + + m_width = new SVGAnimatedLengthImpl(); + m_width->ref(); + + m_height = new SVGAnimatedLengthImpl(); + m_height->ref(); + + m_result = new SVGAnimatedStringImpl(); + m_result->ref(); +} + +SVGFilterPrimitiveStandardAttributesImpl::~SVGFilterPrimitiveStandardAttributesImpl() +{ + if(m_x) + m_x->deref(); + if(m_y) + m_y->deref(); + if(m_width) + m_width->deref(); + if(m_height) + m_height->deref(); + if(m_result) + m_result->deref(); +} + +SVGAnimatedLengthImpl *SVGFilterPrimitiveStandardAttributesImpl::x() const +{ + return m_x; +} + +SVGAnimatedLengthImpl *SVGFilterPrimitiveStandardAttributesImpl::y() const +{ + return m_y; +} + +SVGAnimatedLengthImpl *SVGFilterPrimitiveStandardAttributesImpl::width() const +{ + return m_width; +} + +SVGAnimatedLengthImpl *SVGFilterPrimitiveStandardAttributesImpl::height() const +{ + return m_height; +} + +SVGAnimatedStringImpl *SVGFilterPrimitiveStandardAttributesImpl::result() const +{ + return m_result; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFilterPrimitiveStandardAttributesImpl.h b/ksvg/impl/SVGFilterPrimitiveStandardAttributesImpl.h new file mode 100644 index 00000000..45bcd4d0 --- /dev/null +++ b/ksvg/impl/SVGFilterPrimitiveStandardAttributesImpl.h @@ -0,0 +1,55 @@ +/* + 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. +*/ + +#ifndef SVGPrimitiveStandardAttributesImpl_H +#define SVGPrimitiveStandardAttributesImpl_H + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedLengthImpl; +class SVGAnimatedStringImpl; +class SVGFilterPrimitiveStandardAttributesImpl +{ +public: + SVGFilterPrimitiveStandardAttributesImpl(); + virtual ~SVGFilterPrimitiveStandardAttributesImpl(); + + SVGAnimatedLengthImpl *x() const; + SVGAnimatedLengthImpl *y() const; + SVGAnimatedLengthImpl *width() const; + SVGAnimatedLengthImpl *height() const; + SVGAnimatedStringImpl *result() const; + +private: + SVGAnimatedLengthImpl *m_x; + SVGAnimatedLengthImpl *m_y; + SVGAnimatedLengthImpl *m_width; + SVGAnimatedLengthImpl *m_height; + SVGAnimatedStringImpl *m_result; +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFitToViewBoxImpl.cc b/ksvg/impl/SVGFitToViewBoxImpl.cc new file mode 100644 index 00000000..fee367b9 --- /dev/null +++ b/ksvg/impl/SVGFitToViewBoxImpl.cc @@ -0,0 +1,141 @@ +/* + 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> + +#include <qstring.h> +#include <qstringlist.h> + +#include "SVGPreserveAspectRatio.h" + +#include "SVGRectImpl.h" +#include "SVGFitToViewBoxImpl.h" +#include "SVGAnimatedRectImpl.h" +#include "SVGPreserveAspectRatioImpl.h" +#include "SVGAnimatedPreserveAspectRatioImpl.h" +#include "SVGSVGElementImpl.h" + +using namespace KSVG; + +#include "SVGFitToViewBoxImpl.lut.h" + +SVGFitToViewBoxImpl::SVGFitToViewBoxImpl() +{ + KSVG_EMPTY_FLAGS + + m_viewBox = new SVGAnimatedRectImpl(); + m_viewBox->ref(); + + m_preserveAspectRatio = new SVGAnimatedPreserveAspectRatioImpl(); + m_preserveAspectRatio->ref(); +} + +SVGFitToViewBoxImpl::~SVGFitToViewBoxImpl() +{ + if(m_viewBox) + m_viewBox->deref(); + if(m_preserveAspectRatio) + m_preserveAspectRatio->deref(); +} + +SVGAnimatedRectImpl *SVGFitToViewBoxImpl::viewBox() const +{ + return m_viewBox; +} + +SVGAnimatedPreserveAspectRatioImpl *SVGFitToViewBoxImpl::preserveAspectRatio() const +{ + return m_preserveAspectRatio; +} + +void SVGFitToViewBoxImpl::parseViewBox(const QString &s) +{ + // Set default if preserveAspectRatio wasnt parsed earlier (Rob) + if(m_preserveAspectRatio->baseVal()->align() == SVG_PRESERVEASPECTRATIO_UNKNOWN) + m_preserveAspectRatio->baseVal()->setAlign(SVG_PRESERVEASPECTRATIO_XMIDYMID); + if(m_preserveAspectRatio->baseVal()->meetOrSlice() == SVG_MEETORSLICE_UNKNOWN) + m_preserveAspectRatio->baseVal()->setMeetOrSlice(SVG_MEETORSLICE_MEET); + + // allow for viewbox def with ',' or whitespace + QString viewbox(s); + QStringList points = QStringList::split(' ', viewbox.replace(',', ' ').simplifyWhiteSpace()); + + viewBox()->baseVal()->setX(points[0].toFloat()); + viewBox()->baseVal()->setY(points[1].toFloat()); + viewBox()->baseVal()->setWidth(points[2].toFloat()); + viewBox()->baseVal()->setHeight(points[3].toFloat()); +} + +SVGMatrixImpl *SVGFitToViewBoxImpl::viewBoxToViewTransform(float viewWidth, float viewHeight) const +{ + if(viewBox()->baseVal()->width() == 0 || viewBox()->baseVal()->height() == 0) + return SVGSVGElementImpl::createSVGMatrix(); + else + return preserveAspectRatio()->baseVal()->getCTM(viewBox()->baseVal()->x(), + viewBox()->baseVal()->y(), viewBox()->baseVal()->width(), viewBox()->baseVal()->height(), + 0, 0, viewWidth, viewHeight); +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGFitToViewBoxImpl::s_hashTable 3 + viewBox SVGFitToViewBoxImpl::ViewBox DontDelete + preserveAspectRatio SVGFitToViewBoxImpl::PreserveAspectRatio DontDelete +@end +*/ + +Value SVGFitToViewBoxImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case ViewBox: + return m_viewBox->cache(exec); + case PreserveAspectRatio: + return m_preserveAspectRatio->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGFitToViewBoxImpl::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; + + switch(token) + { + case ViewBox: + parseViewBox(value.toString(exec).qstring()); + break; + case PreserveAspectRatio: + if(preserveAspectRatio()) + preserveAspectRatio()->baseVal()->parsePreserveAspectRatio(value.toString(exec).qstring()); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFitToViewBoxImpl.h b/ksvg/impl/SVGFitToViewBoxImpl.h new file mode 100644 index 00000000..b511d63e --- /dev/null +++ b/ksvg/impl/SVGFitToViewBoxImpl.h @@ -0,0 +1,69 @@ +/* + 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. +*/ + +#ifndef SVGFitToViewBoxImpl_H +#define SVGFitToViewBoxImpl_H + +#include "ksvg_lookup.h" + +class QString; + +namespace KSVG +{ + +class SVGAnimatedRectImpl; +class SVGAnimatedPreserveAspectRatioImpl; +class SVGMatrixImpl; +class SVGFitToViewBoxImpl +{ +public: + SVGFitToViewBoxImpl(); + ~SVGFitToViewBoxImpl(); + + SVGAnimatedRectImpl *viewBox() const; + SVGAnimatedPreserveAspectRatioImpl *preserveAspectRatio() const; + + void parseViewBox(const QString &); + + SVGMatrixImpl *viewBoxToViewTransform(float viewWidth, float viewHeight) const; + +protected: + SVGAnimatedRectImpl *m_viewBox; + SVGAnimatedPreserveAspectRatioImpl *m_preserveAspectRatio; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + ViewBox, PreserveAspectRatio + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFontElementImpl.cc b/ksvg/impl/SVGFontElementImpl.cc new file mode 100644 index 00000000..30d4f63f --- /dev/null +++ b/ksvg/impl/SVGFontElementImpl.cc @@ -0,0 +1,33 @@ +/* + 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 "SVGFontElementImpl.h" + +using namespace KSVG; + +SVGFontElementImpl::SVGFontElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this) +{ +} + +SVGFontElementImpl::~SVGFontElementImpl() +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFontElementImpl.h b/ksvg/impl/SVGFontElementImpl.h new file mode 100644 index 00000000..3a753797 --- /dev/null +++ b/ksvg/impl/SVGFontElementImpl.h @@ -0,0 +1,49 @@ +/* + 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. +*/ + +#ifndef SVGFontElementImpl_H +#define SVGFontElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGElementImpl.h" +#include "SVGStylableImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + +namespace KSVG +{ + +class SVGFontElementImpl : public SVGElementImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl +{ +public: + SVGFontElementImpl(DOM::ElementImpl *); + virtual ~SVGFontElementImpl(); +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFontFaceElementImpl.cc b/ksvg/impl/SVGFontFaceElementImpl.cc new file mode 100644 index 00000000..d53e70ad --- /dev/null +++ b/ksvg/impl/SVGFontFaceElementImpl.cc @@ -0,0 +1,33 @@ +/* + 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 "SVGFontFaceElementImpl.h" + +using namespace KSVG; + +SVGFontFaceElementImpl::SVGFontFaceElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl) +{ +} + +SVGFontFaceElementImpl::~SVGFontFaceElementImpl() +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFontFaceElementImpl.h b/ksvg/impl/SVGFontFaceElementImpl.h new file mode 100644 index 00000000..0479ccea --- /dev/null +++ b/ksvg/impl/SVGFontFaceElementImpl.h @@ -0,0 +1,46 @@ +/* + 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. +*/ + +#ifndef SVGFontFaceElementImpl_H +#define SVGFontFaceElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGElementImpl.h" + +namespace KSVG +{ + +class SVGFontFaceElementImpl : public SVGElementImpl +{ +public: + SVGFontFaceElementImpl(DOM::ElementImpl *); + virtual ~SVGFontFaceElementImpl(); + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFontFaceFormatElementImpl.cc b/ksvg/impl/SVGFontFaceFormatElementImpl.cc new file mode 100644 index 00000000..48651a68 --- /dev/null +++ b/ksvg/impl/SVGFontFaceFormatElementImpl.cc @@ -0,0 +1,33 @@ +/* + 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 "SVGFontFaceFormatElementImpl.h" + +using namespace KSVG; + +SVGFontFaceFormatElementImpl::SVGFontFaceFormatElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl) +{ +} + +SVGFontFaceFormatElementImpl::~SVGFontFaceFormatElementImpl() +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFontFaceFormatElementImpl.h b/ksvg/impl/SVGFontFaceFormatElementImpl.h new file mode 100644 index 00000000..380e29b1 --- /dev/null +++ b/ksvg/impl/SVGFontFaceFormatElementImpl.h @@ -0,0 +1,46 @@ +/* + 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. +*/ + +#ifndef SVGFontFaceFormatElementImpl_H +#define SVGFontFaceFormatElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGElementImpl.h" + +namespace KSVG +{ + +class SVGFontFaceFormatElementImpl : public SVGElementImpl +{ +public: + SVGFontFaceFormatElementImpl(DOM::ElementImpl *); + virtual ~SVGFontFaceFormatElementImpl(); + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFontFaceNameElementImpl.cc b/ksvg/impl/SVGFontFaceNameElementImpl.cc new file mode 100644 index 00000000..276f3ae3 --- /dev/null +++ b/ksvg/impl/SVGFontFaceNameElementImpl.cc @@ -0,0 +1,33 @@ +/* + 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 "SVGFontFaceNameElementImpl.h" + +using namespace KSVG; + +SVGFontFaceNameElementImpl::SVGFontFaceNameElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl) +{ +} + +SVGFontFaceNameElementImpl::~SVGFontFaceNameElementImpl() +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFontFaceNameElementImpl.h b/ksvg/impl/SVGFontFaceNameElementImpl.h new file mode 100644 index 00000000..797ee17e --- /dev/null +++ b/ksvg/impl/SVGFontFaceNameElementImpl.h @@ -0,0 +1,46 @@ +/* + 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. +*/ + +#ifndef SVGFontFaceNameElementImpl_H +#define SVGFontFaceNameElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGElementImpl.h" + +namespace KSVG +{ + +class SVGFontFaceNameElementImpl : public SVGElementImpl +{ +public: + SVGFontFaceNameElementImpl(DOM::ElementImpl *); + virtual ~SVGFontFaceNameElementImpl(); + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFontFaceSrcElementImpl.cc b/ksvg/impl/SVGFontFaceSrcElementImpl.cc new file mode 100644 index 00000000..bdc40611 --- /dev/null +++ b/ksvg/impl/SVGFontFaceSrcElementImpl.cc @@ -0,0 +1,33 @@ +/* + 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 "SVGFontFaceSrcElementImpl.h" + +using namespace KSVG; + +SVGFontFaceSrcElementImpl::SVGFontFaceSrcElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl) +{ +} + +SVGFontFaceSrcElementImpl::~SVGFontFaceSrcElementImpl() +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFontFaceSrcElementImpl.h b/ksvg/impl/SVGFontFaceSrcElementImpl.h new file mode 100644 index 00000000..f858e829 --- /dev/null +++ b/ksvg/impl/SVGFontFaceSrcElementImpl.h @@ -0,0 +1,45 @@ +/* + 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. +*/ + +#ifndef SVGFontFaceSrcElementImpl_H +#define SVGFontFaceSrcElementImpl_H + +#include "ksvg_lookup.h" +#include "SVGElementImpl.h" + +namespace KSVG +{ + +class SVGFontFaceSrcElementImpl : public SVGElementImpl +{ +public: + SVGFontFaceSrcElementImpl(DOM::ElementImpl *); + virtual ~SVGFontFaceSrcElementImpl(); + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFontFaceUriElementImpl.cc b/ksvg/impl/SVGFontFaceUriElementImpl.cc new file mode 100644 index 00000000..cef5a30f --- /dev/null +++ b/ksvg/impl/SVGFontFaceUriElementImpl.cc @@ -0,0 +1,33 @@ +/* + 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 "SVGFontFaceUriElementImpl.h" + +using namespace KSVG; + +SVGFontFaceUriElementImpl::SVGFontFaceUriElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl) +{ +} + +SVGFontFaceUriElementImpl::~SVGFontFaceUriElementImpl() +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGFontFaceUriElementImpl.h b/ksvg/impl/SVGFontFaceUriElementImpl.h new file mode 100644 index 00000000..2b670a82 --- /dev/null +++ b/ksvg/impl/SVGFontFaceUriElementImpl.h @@ -0,0 +1,46 @@ +/* + 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. +*/ + +#ifndef SVGFontFaceUriElementImpl_H +#define SVGFontFaceUriElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGElementImpl.h" + +namespace KSVG +{ + +class SVGFontFaceUriElementImpl : public SVGElementImpl +{ +public: + SVGFontFaceUriElementImpl(DOM::ElementImpl *); + virtual ~SVGFontFaceUriElementImpl(); + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGForeignObjectElementImpl.cc b/ksvg/impl/SVGForeignObjectElementImpl.cc new file mode 100644 index 00000000..ff605cf0 --- /dev/null +++ b/ksvg/impl/SVGForeignObjectElementImpl.cc @@ -0,0 +1,121 @@ +/* + Copyright (C) 2001-20032 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> + +#include "SVGRectImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGAnimatedLengthImpl.h" +#include "SVGForeignObjectElementImpl.h" + +using namespace KSVG; + +#include "SVGForeignObjectElementImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +SVGForeignObjectElementImpl::SVGForeignObjectElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGTestsImpl(), SVGLangSpaceImpl(), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this), SVGTransformableImpl() +{ + m_x = new SVGAnimatedLengthImpl(); + m_x->ref(); + + m_y = new SVGAnimatedLengthImpl(); + m_y->ref(); + + m_width = new SVGAnimatedLengthImpl(); + m_width->ref(); + + m_height = new SVGAnimatedLengthImpl(); + m_height->ref(); +} + +SVGForeignObjectElementImpl::~SVGForeignObjectElementImpl() +{ + if(m_x) + m_x->deref(); + if(m_y) + m_y->deref(); + if(m_width) + m_width->deref(); + if(m_height) + m_height->deref(); +} + +SVGRectImpl *SVGForeignObjectElementImpl::getBBox() +{ + SVGRectImpl *ret = SVGSVGElementImpl::createSVGRect(); + ret->setX(m_x->baseVal()->value()); + ret->setY(m_y->baseVal()->value()); + ret->setWidth(m_width->baseVal()->value()); + ret->setHeight(m_height->baseVal()->value()); + return ret; +} + +SVGAnimatedLengthImpl *SVGForeignObjectElementImpl::x() const +{ + return m_x; +} + +SVGAnimatedLengthImpl *SVGForeignObjectElementImpl::y() const +{ + return m_y; +} + +SVGAnimatedLengthImpl *SVGForeignObjectElementImpl::width() const +{ + return m_width; +} + +SVGAnimatedLengthImpl *SVGForeignObjectElementImpl::height() const +{ + return m_height; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGForeignObjectElementImpl::s_hashTable 5 + x SVGForeignObjectElementImpl::X DontDelete|ReadOnly + y SVGForeignObjectElementImpl::Y DontDelete|ReadOnly + width SVGForeignObjectElementImpl::Width DontDelete|ReadOnly + height SVGForeignObjectElementImpl::Height DontDelete|ReadOnly +@end +*/ + +Value SVGForeignObjectElementImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case X: + return m_x->cache(exec); + case Y: + return m_y->cache(exec); + case Width: + return m_width->cache(exec); + case Height: + return m_height->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGForeignObjectElementImpl.h b/ksvg/impl/SVGForeignObjectElementImpl.h new file mode 100644 index 00000000..3fea4877 --- /dev/null +++ b/ksvg/impl/SVGForeignObjectElementImpl.h @@ -0,0 +1,78 @@ +/* + 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. +*/ + +#ifndef SVGForeignObjectElementImpl_H +#define SVGForeignObjectElementImpl_H + +#include "SVGTestsImpl.h" +#include "SVGElementImpl.h" +#include "SVGLangSpaceImpl.h" +#include "SVGStylableImpl.h" +#include "SVGTransformableImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedLengthImpl; +class SVGForeignObjectElementImpl : public SVGElementImpl, + public SVGTestsImpl, + public SVGLangSpaceImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl, + public SVGTransformableImpl +{ +public: + SVGForeignObjectElementImpl(DOM::ElementImpl *); + virtual ~SVGForeignObjectElementImpl(); + + virtual SVGRectImpl *getBBox(); + + SVGAnimatedLengthImpl *x() const; + SVGAnimatedLengthImpl *y() const; + SVGAnimatedLengthImpl *width() const; + SVGAnimatedLengthImpl *height() const; + +private: + SVGAnimatedLengthImpl *m_x; + SVGAnimatedLengthImpl *m_y; + SVGAnimatedLengthImpl *m_width; + SVGAnimatedLengthImpl *m_height; + +public: + KSVG_GET + KSVG_FORWARDPUT + + enum + { + // Properties + X, Y, Width, Height + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGGElementImpl.cc b/ksvg/impl/SVGGElementImpl.cc new file mode 100644 index 00000000..9f355540 --- /dev/null +++ b/ksvg/impl/SVGGElementImpl.cc @@ -0,0 +1,36 @@ +/* + 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 "SVGGElementImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGAElementImpl.h" +#include "SVGAnimatedStringImpl.h" + +using namespace KSVG; + +SVGGElementImpl::SVGGElementImpl(DOM::ElementImpl *impl) : SVGContainerImpl(impl), SVGTestsImpl(), SVGLangSpaceImpl(), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this), SVGTransformableImpl() +{ +} + +SVGGElementImpl::~SVGGElementImpl() +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGGElementImpl.h b/ksvg/impl/SVGGElementImpl.h new file mode 100644 index 00000000..ca4a9b4e --- /dev/null +++ b/ksvg/impl/SVGGElementImpl.h @@ -0,0 +1,59 @@ +/* + 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. +*/ + +#ifndef SVGGElementImpl_H +#define SVGGElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGTestsImpl.h" +#include "SVGStylableImpl.h" +#include "SVGContainerImpl.h" +#include "SVGLangSpaceImpl.h" +#include "SVGTransformableImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + +namespace KSVG +{ + +class SVGGElementImpl : public SVGContainerImpl, + public SVGTestsImpl, + public SVGLangSpaceImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl, + public SVGTransformableImpl +{ +public: + SVGGElementImpl(DOM::ElementImpl *); + virtual ~SVGGElementImpl(); + +public: + KSVG_BRIDGE + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +KSVG_REGISTER_ELEMENT(SVGGElementImpl, "g") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGGlyphElementImpl.cc b/ksvg/impl/SVGGlyphElementImpl.cc new file mode 100644 index 00000000..dd201466 --- /dev/null +++ b/ksvg/impl/SVGGlyphElementImpl.cc @@ -0,0 +1,98 @@ +/* + 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> + +#include "SVGGlyphElementImpl.h" + +using namespace KSVG; + +#include "SVGGlyphElementImpl.lut.h" + +SVGGlyphElementImpl::SVGGlyphElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGStylableImpl(this) +{ + KSVG_EMPTY_FLAGS +} + +SVGGlyphElementImpl::~SVGGlyphElementImpl() +{ +} + +QString SVGGlyphElementImpl::d() const +{ + return m_d; +} + +/* +@namespace KSVG +@begin SVGGlyphElementImpl::s_hashTable 11 + unicode SVGGlyphElementImpl::Unicode DontDelete|ReadOnly + glyph-name SVGGlyphElementImpl::GlyphName DontDelete|ReadOnly + d SVGGlyphElementImpl::D DontDelete|ReadOnly + orientation SVGGlyphElementImpl::Orientation DontDelete|ReadOnly + arabic-form SVGGlyphElementImpl::ArabicForm DontDelete|ReadOnly + lang SVGGlyphElementImpl::Lang DontDelete|ReadOnly + horiz-adv-x SVGGlyphElementImpl::HorizAdvX DontDelete|ReadOnly + vert-origin-x SVGGlyphElementImpl::VertOriginX DontDelete|ReadOnly + vert-origin-y SVGGlyphElementImpl::VertOriginY DontDelete|ReadOnly + vert-adv-y SVGGlyphElementImpl::VertAdvY DontDelete|ReadOnly +@end +*/ + +Value SVGGlyphElementImpl::getValueProperty(ExecState *, int token) const +{ + //KSVG_CHECK_ATTRIBUTE + + switch(token) + { + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGGlyphElementImpl::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; + + switch(token) + { + case D: + m_d = value.toString(exec).qstring(); + break; + case Unicode: + case GlyphName: + case Orientation: + case ArabicForm: + case Lang: + case HorizAdvX: + case VertOriginX: + case VertOriginY: + case VertAdvY: + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGGlyphElementImpl.h b/ksvg/impl/SVGGlyphElementImpl.h new file mode 100644 index 00000000..35781b2c --- /dev/null +++ b/ksvg/impl/SVGGlyphElementImpl.h @@ -0,0 +1,66 @@ +/* + 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. +*/ + +#ifndef SVGGlyphElementImpl_H +#define SVGGlyphElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGElementImpl.h" +#include "SVGStylableImpl.h" + +namespace KSVG +{ + +class SVGGlyphElementImpl : public SVGElementImpl, + public SVGStylableImpl +{ +public: + SVGGlyphElementImpl(DOM::ElementImpl *); + virtual ~SVGGlyphElementImpl(); + + QString d() const; + +private: + QString m_d; + +public: + KSVG_GET + KSVG_PUT + KSVG_BRIDGE + + enum + { + // Properties + Unicode, GlyphName, D, Orientation, ArabicForm, + Lang, HorizAdvX, VertOriginX, VertOriginY, VertAdvY + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +KSVG_REGISTER_ELEMENT(SVGGlyphElementImpl, "glyph") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGGlyphRefElementImpl.cc b/ksvg/impl/SVGGlyphRefElementImpl.cc new file mode 100644 index 00000000..438fa0b0 --- /dev/null +++ b/ksvg/impl/SVGGlyphRefElementImpl.cc @@ -0,0 +1,134 @@ +/* + 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 "SVGSVGElementImpl.h" +#include "SVGGlyphRefElementImpl.h" + +using namespace KSVG; + +#include "SVGGlyphRefElementImpl.lut.h" +#include "ksvg_lookup.h" + +SVGGlyphRefElementImpl::SVGGlyphRefElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGURIReferenceImpl(), SVGStylableImpl(this) +{ +} + +SVGGlyphRefElementImpl::~SVGGlyphRefElementImpl() +{ +} + +void SVGGlyphRefElementImpl::setAttributes() +{ + SVGElementImpl::setAttributes(); +} + +DOM::DOMString SVGGlyphRefElementImpl::format() +{ + return ""; +} + +DOM::DOMString SVGGlyphRefElementImpl::glyphRef() +{ + return ""; +} + +float SVGGlyphRefElementImpl::x() const +{ + return m_x; +} + +float SVGGlyphRefElementImpl::y() const +{ + return m_y; +} + +float SVGGlyphRefElementImpl::dx() const +{ + return m_dx; +} + +float SVGGlyphRefElementImpl::dy() const +{ + return m_dy; +} + +/* +@namespace KSVG +@begin SVGGlyphRefElementImpl::s_hashTable 7 + glyphRef SVGGlyphRefElementImpl::GlyphRef DontDelete|ReadOnly + format SVGGlyphRefElementImpl::Format DontDelete|ReadOnly + x SVGGlyphRefElementImpl::X DontDelete|ReadOnly + y SVGGlyphRefElementImpl::Y DontDelete|ReadOnly + dx SVGGlyphRefElementImpl::Dx DontDelete|ReadOnly + dy SVGGlyphRefElementImpl::Dy DontDelete|ReadOnly +@end +*/ + +Value SVGGlyphRefElementImpl::getValueProperty(ExecState *, int token) const +{ + //KSVG_CHECK_ATTRIBUTE + + switch(token) + { + case GlyphRef: return String(m_glyphRef); + case Format: return String(m_format); + case X: return Number(m_x); + case Y: return Number(m_y); + case Dx: return Number(m_dx); + case Dy: return Number(m_dy); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGGlyphRefElementImpl::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; + + switch(token) + { + case GlyphRef: + m_glyphRef = value.toString(exec).string(); + break; + case Format: + m_format = value.toString(exec).string(); + break; + case X: + m_x = value.toNumber(exec); + break; + case Y: + m_y = value.toNumber(exec); + break; + case Dx: + m_dx = value.toNumber(exec); + break; + case Dy: + m_dy = value.toNumber(exec); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGGlyphRefElementImpl.h b/ksvg/impl/SVGGlyphRefElementImpl.h new file mode 100644 index 00000000..6a292a64 --- /dev/null +++ b/ksvg/impl/SVGGlyphRefElementImpl.h @@ -0,0 +1,79 @@ +/* + 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. +*/ + +#ifndef SVGGlyphRefElementImpl_H +#define SVGGlyphRefElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGElementImpl.h" +#include "SVGURIReferenceImpl.h" +#include "SVGStylableImpl.h" + +namespace KSVG +{ + +class SVGGlyphRefElementImpl : public SVGElementImpl, + public SVGURIReferenceImpl, + public SVGStylableImpl +{ +public: + SVGGlyphRefElementImpl(DOM::ElementImpl *); + virtual ~SVGGlyphRefElementImpl(); + virtual void setAttributes(); + + DOM::DOMString glyphRef(); + DOM::DOMString format(); + + float x() const; + float y() const; + float dx() const; + float dy() const; + +private: + DOM::DOMString m_glyphRef; + DOM::DOMString m_format; + float m_x; + float m_y; + float m_dx; + float m_dy; + +public: + KSVG_BRIDGE + KSVG_GET + KSVG_PUT + + enum + { + // Properties + GlyphRef, Format, X, Y, Dx, Dy + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +KSVG_REGISTER_ELEMENT(SVGGlyphRefElementImpl, "glyphRef") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGGradientElementImpl.cc b/ksvg/impl/SVGGradientElementImpl.cc new file mode 100644 index 00000000..180b230a --- /dev/null +++ b/ksvg/impl/SVGGradientElementImpl.cc @@ -0,0 +1,264 @@ +/* + 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 "SVGGradientElement.h" +#include "SVGGradientElementImpl.h" +#include "SVGStopElementImpl.h" +#include "SVGAnimatedStringImpl.h" +#include "SVGSVGElementImpl.h" + +#include "KSVGCanvas.h" +#include "CanvasItems.h" +#include "SVGHelperImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGAnimatedEnumerationImpl.h" +#include "SVGAnimatedTransformListImpl.h" +#include "SVGTransformListImpl.h" +#include "SVGUnitConverter.h" + +using namespace KSVG; + +#include "SVGGradientElementImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" +#include "ksvg_cacheimpl.h" + +SVGGradientElementImpl::SVGGradientElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGURIReferenceImpl(), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this), SVGPaintServerImpl() +{ + KSVG_EMPTY_FLAGS + + m_gradientUnits = new SVGAnimatedEnumerationImpl(); + m_gradientUnits->ref(); + + m_gradientTransform = new SVGAnimatedTransformListImpl(); + m_gradientTransform->ref(); + + m_spreadMethod = new SVGAnimatedEnumerationImpl(); + m_spreadMethod->ref(); + + m_converter = new SVGUnitConverter(); +} + +SVGGradientElementImpl::~SVGGradientElementImpl() +{ + if(m_gradientUnits) + m_gradientUnits->deref(); + if(m_gradientTransform) + m_gradientTransform->deref(); + if(m_spreadMethod) + m_spreadMethod->deref(); + delete m_converter; +} + +SVGAnimatedEnumerationImpl *SVGGradientElementImpl::gradientUnits() const +{ + return m_gradientUnits; +} + +SVGAnimatedTransformListImpl *SVGGradientElementImpl::gradientTransform() const +{ + return m_gradientTransform; +} + +SVGAnimatedEnumerationImpl *SVGGradientElementImpl::spreadMethod() const +{ + return m_spreadMethod; +} + +/* +@namespace KSVG +@begin SVGGradientElementImpl::s_hashTable 5 + gradientUnits SVGGradientElementImpl::GradientUnits DontDelete|ReadOnly + gradientTransform SVGGradientElementImpl::GradientTransform DontDelete|ReadOnly + spreadMethod SVGGradientElementImpl::SpreadMethod DontDelete|ReadOnly +@end +*/ + +Value SVGGradientElementImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case GradientUnits: + return m_gradientUnits->cache(exec); + case GradientTransform: + return m_gradientTransform->cache(exec); + case SpreadMethod: + return m_spreadMethod->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGGradientElementImpl::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; + + switch(token) + { + case GradientUnits: + if(value.toString(exec).qstring() == "userSpaceOnUse") + m_gradientUnits->setBaseVal(SVGGradientElement::SVG_UNIT_TYPE_USERSPACEONUSE); + else + m_gradientUnits->setBaseVal(SVGGradientElement::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX); + break; + case GradientTransform: + m_gradientTransform->baseVal()->clear(); + SVGHelperImpl::parseTransformAttribute(m_gradientTransform->baseVal(), value.toString(exec).qstring()); + break; + case SpreadMethod: + { + QString spreadMethod = value.toString(exec).qstring(); + + if(spreadMethod == "repeat") + m_spreadMethod->setBaseVal(SVG_SPREADMETHOD_REPEAT); + else if(spreadMethod == "reflect") + m_spreadMethod->setBaseVal(SVG_SPREADMETHOD_REFLECT); + else + m_spreadMethod->setBaseVal(SVG_SPREADMETHOD_PAD); + break; + } + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +void SVGGradientElementImpl::setAttributes() +{ + SVGElementImpl::setAttributes(); + setAttributesFromHref(); + + // Spec: if attribute not specified, use "pad" + if(KSVG_TOKEN_NOT_PARSED(SpreadMethod)) + KSVG_SET_ALT_ATTRIBUTE(SpreadMethod, "pad") + + // Spec: if attribute not specified, use objectBoundingBox + if(KSVG_TOKEN_NOT_PARSED(GradientUnits)) + KSVG_SET_ALT_ATTRIBUTE(GradientUnits, "objectBoundingBox") +} + +void SVGGradientElementImpl::setAttributesFromHref() +{ + QString _href = SVGURIReferenceImpl::getTarget(href()->baseVal().string()); + + if(!_href.isEmpty()) + { + SVGGradientElementImpl *refGradient = dynamic_cast<SVGGradientElementImpl *>(ownerSVGElement()->getElementById(_href)); + + if(refGradient) + { + QMap<QString, DOM::DOMString> refAttributes = refGradient->gradientAttributes(); + QMap<QString, DOM::DOMString>::iterator it; + + for(it = refAttributes.begin(); it != refAttributes.end(); ++it) + { + QString name = it.key(); + DOM::DOMString value = it.data(); + + if(!hasAttribute(name)) + { + setAttribute(name, value); + setAttributeInternal(name, value); + } + } + } + } +} + +SVGGradientElementImpl *SVGGradientElementImpl::stopsSource() +{ + // Spec: + // If this element has no defined gradient stops, and the referenced element does + // (possibly due to its own href attribute), then this element inherits the gradient stop from the referenced element. + // Inheritance can be indirect to an arbitrary level; thus, if the referenced element inherits attribute or gradient stops + // due to its own href attribute, then the current element can inherit those attributes or gradient stops. (mop) + bool haveStops = false; + + for(DOM::Node node = firstChild(); !node.isNull(); node = node.nextSibling()) + { + SVGStopElementImpl *stop = dynamic_cast<SVGStopElementImpl *>(ownerDoc()->getElementFromHandle(node.handle())); + + if(stop) + { + haveStops = true; + break; + } + } + + SVGGradientElementImpl *source = this; + + if(!haveStops) + { + QString _href = SVGURIReferenceImpl::getTarget(href()->baseVal().string()); + + if(!_href.isEmpty()) + { + SVGGradientElementImpl *refGradient = dynamic_cast<SVGGradientElementImpl *>(ownerSVGElement()->getElementById(_href)); + + if(refGradient) + source = refGradient->stopsSource(); + } + } + + return source; +} + +void SVGGradientElementImpl::createItem(KSVGCanvas *c) +{ + if(!c) + c = ownerDoc()->canvas(); + + if(!m_paintServer) + m_paintServer = c->createPaintServer(this); +} + +void SVGGradientElementImpl::removeItem(KSVGCanvas *) +{ + delete m_paintServer; + m_paintServer = 0; +} + +/* +@namespace KSVG +@begin SVGGradientElementImplConstructor::s_hashTable 5 + SVG_SPREADMETHOD_UNKNOWN KSVG::SVG_SPREADMETHOD_UNKNOWN DontDelete|ReadOnly + SVG_SPREADMETHOD_PAD KSVG::SVG_SPREADMETHOD_PAD DontDelete|ReadOnly + SVG_SPREADMETHOD_REFLECT KSVG::SVG_SPREADMETHOD_REFLECT DontDelete|ReadOnly + SVG_SPREADMETHOD_REPEAT KSVG::SVG_SPREADMETHOD_REPEAT DontDelete|ReadOnly +@end +*/ + +using namespace KJS; + +Value SVGGradientElementImplConstructor::getValueProperty(ExecState *, int token) const +{ + return Number(token); +} + +Value KSVG::getSVGGradientElementImplConstructor(ExecState *exec) +{ + return cacheGlobalBridge<SVGGradientElementImplConstructor>(exec, "[[svggradientelement.constructor]]"); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGGradientElementImpl.h b/ksvg/impl/SVGGradientElementImpl.h new file mode 100644 index 00000000..e9be92d8 --- /dev/null +++ b/ksvg/impl/SVGGradientElementImpl.h @@ -0,0 +1,110 @@ +/* + 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. +*/ + +#ifndef SVGGradientElementImpl_H +#define SVGGradientElementImpl_H + +#include <qmap.h> + +#include "SVGElementImpl.h" +#include "SVGStylableImpl.h" +#include "SVGURIReferenceImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" +#include "SVGPaintServerImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGUnitConverter; +class SVGAnimatedEnumerationImpl; +class SVGAnimatedTransformListImpl; +class SVGGradientElementImpl : public SVGElementImpl, + public SVGURIReferenceImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl, + public SVGPaintServerImpl +{ +public: + SVGGradientElementImpl(DOM::ElementImpl *); + virtual ~SVGGradientElementImpl(); + + SVGAnimatedEnumerationImpl *gradientUnits() const; + SVGAnimatedTransformListImpl *gradientTransform() const; + SVGAnimatedEnumerationImpl *spreadMethod() const; + + virtual void setAttributes(); + + virtual void createItem(KSVGCanvas *c = 0); + virtual void removeItem(KSVGCanvas *c); + + SVGUnitConverter *converter() const { return m_converter; } + + // Returns the gradient element that holds the stops for this gradient, + // taking into account indirection through href. + SVGGradientElementImpl *stopsSource(); + + // Returns the linear/radial gradient attributes set on this element, + // taking into account indirection through href. + virtual QMap<QString, DOM::DOMString> gradientAttributes() = 0; + +protected: + void setAttributesFromHref(); + +private: + SVGAnimatedEnumerationImpl *m_gradientUnits; + SVGAnimatedTransformListImpl *m_gradientTransform; + SVGAnimatedEnumerationImpl *m_spreadMethod; + + SVGUnitConverter *m_converter; + +public: + KSVG_GET + KSVG_PUT + KSVG_NO_TAG_BRIDGE + + enum + { + // Properties + GradientUnits, GradientTransform, SpreadMethod + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +class SVGGradientElementImplConstructor : public KJS::ObjectImp +{ +public: + SVGGradientElementImplConstructor(KJS::ExecState *) { } + KJS::Value getValueProperty(KJS::ExecState *, int token) const; + + // no put - all read-only + KSVG_GET +}; + +KJS::Value getSVGGradientElementImplConstructor(KJS::ExecState *exec); + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGHKernElementImpl.cc b/ksvg/impl/SVGHKernElementImpl.cc new file mode 100644 index 00000000..df310d6e --- /dev/null +++ b/ksvg/impl/SVGHKernElementImpl.cc @@ -0,0 +1,33 @@ +/* + 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 "SVGHKernElementImpl.h" + +using namespace KSVG; + +SVGHKernElementImpl::SVGHKernElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl) +{ +} + +SVGHKernElementImpl::~SVGHKernElementImpl() +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGHKernElementImpl.h b/ksvg/impl/SVGHKernElementImpl.h new file mode 100644 index 00000000..6858b5be --- /dev/null +++ b/ksvg/impl/SVGHKernElementImpl.h @@ -0,0 +1,46 @@ +/* + 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. +*/ + +#ifndef SVGHKernElementImpl_H +#define SVGHKernElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGElementImpl.h" + +namespace KSVG +{ + +class SVGHKernElementImpl : public SVGElementImpl +{ +public: + SVGHKernElementImpl(DOM::ElementImpl *); + virtual ~SVGHKernElementImpl(); + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGHelperImpl.cc b/ksvg/impl/SVGHelperImpl.cc new file mode 100644 index 00000000..ed7e8be4 --- /dev/null +++ b/ksvg/impl/SVGHelperImpl.cc @@ -0,0 +1,230 @@ +/* + Copyright (C) 2002-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> + +#include <qregexp.h> + +#include "SVGRectImpl.h" +#include "SVGMatrixImpl.h" +#include "SVGHelperImpl.h" +#include "SVGElementImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGStylableImpl.h" +#include "SVGTransformImpl.h" +#include "SVGStringListImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGTransformListImpl.h" +#include "SVGTransformableImpl.h" +#include "SVGAnimatedLengthImpl.h" +#include "SVGAnimatedLengthListImpl.h" + +#include "KSVGCanvas.h" +#include "CanvasItem.h" + +using namespace KSVG; + +#include "ksvg_ecma.h" +#include "ksvg_window.h" + +SVGHelperImpl::SVGHelperImpl() +{ +} + +SVGHelperImpl::~SVGHelperImpl() +{ +} + +void SVGHelperImpl::updateItem(KJS::ExecState *exec, const DOM::Node node) +{ + // Get document + SVGDocumentImpl *doc = Window::retrieveActive(exec)->doc(); + + // Update canvas, recursively if needed + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(doc->getElementFromHandle(node.handle())); + + if(shape && shape->item()) + { + shape->item()->update(UPDATE_TRANSFORM); + shape->item()->draw(); + shape->blit(doc->canvas()); + } + + if(const_cast<DOM::Node &>(node).hasChildNodes()) + { + DOM::Node iterate = node.firstChild(); + for(; !iterate.isNull(); iterate = iterate.nextSibling()) + updateItem(exec, iterate); + } +} + +void SVGHelperImpl::copyAttributes(SVGElementImpl *src, SVGElementImpl *dst) +{ + QDictIterator<DOM::DOMString> it(src->attributes()); + for(; it.current(); ++it) + { + DOM::DOMString name = it.currentKey(); + DOM::DOMString value = it.current()->string(); + + if(name != "id" && !dst->hasAttribute(name)) + { + dst->setAttribute(name, value); + dst->setAttributeInternal(name, value); + } + } +} + +void SVGHelperImpl::parseList(SVGStringListImpl *list, char seperator, const QString &data) +{ + // TODO : more error checking/reporting + list->clear(); + + QStringList substrings = QStringList::split(seperator, data); + QStringList::ConstIterator it = substrings.begin(); + QStringList::ConstIterator end = substrings.end(); + for(; it != end; ++it) + { + SharedString *string = new SharedString(*it); + string->ref(); + + list->appendItem(string); + } +} + +void SVGHelperImpl::parseLengthList(SVGAnimatedLengthListImpl *list, const QString &lengths, LengthMode mode, SVGElementImpl *object) +{ + // get either comma or space delimited lists + // TODO : more error checking/reporting + QStringList sublengths = QStringList::split(QRegExp("[, ]"), lengths); + QStringList::ConstIterator it = sublengths.begin(); + QStringList::ConstIterator end = sublengths.end(); + + SVGLengthImpl *lengthImpl = 0; + for(; it != end; ++it) + { + lengthImpl = new SVGLengthImpl(mode, object); + lengthImpl->ref(); + + lengthImpl->setValueAsString(*it); + list->baseVal()->appendItem(lengthImpl); + } +} + +void SVGHelperImpl::parseCommaSeperatedList(SVGStringListImpl *list, const QString &data) +{ + parseList(list, ',', data); +} + +void SVGHelperImpl::parseSemicolonSeperatedList(SVGStringListImpl *list, const QString &data) +{ + parseList(list, ';', data); +} + +void SVGHelperImpl::parseTransformAttribute(SVGTransformListImpl *list, const QString &transform) +{ + // Split string for handling 1 transform statement at a time + QStringList subtransforms = QStringList::split(')', transform); + QStringList::ConstIterator it = subtransforms.begin(); + QStringList::ConstIterator end = subtransforms.end(); + for(; it != end; ++it) + { + QStringList subtransform = QStringList::split('(', (*it)); + + subtransform[0] = subtransform[0].stripWhiteSpace().lower(); + subtransform[1] = subtransform[1].simplifyWhiteSpace(); + QRegExp reg("([-]?\\d*\\.?\\d+(?:e[-]?\\d+)?)"); + + int pos = 0; + QStringList params; + + while(pos >= 0) + { + pos = reg.search(subtransform[1], pos); + if(pos != -1) + { + params += reg.cap(1); + pos += reg.matchedLength(); + } + } + + if(subtransform[0].startsWith(";") || subtransform[0].startsWith(",")) + subtransform[0] = subtransform[0].right(subtransform[0].length() - 1); + + SVGTransformImpl *t = SVGSVGElementImpl::createSVGTransform(); + + if(subtransform[0] == "rotate") + { + if(params.count() == 3) + t->setRotate(params[0].toDouble(), + params[1].toDouble(), + params[2].toDouble()); + else + t->setRotate(params[0].toDouble(), 0, 0); + } + else if(subtransform[0] == "translate") + { + if(params.count() == 2) + t->setTranslate(params[0].toDouble(), params[1].toDouble()); + else // Spec : if only one param given, assume 2nd param to be 0 + t->setTranslate(params[0].toDouble(), 0); + } + else if(subtransform[0] == "scale") + { + if(params.count() == 2) + t->setScale(params[0].toDouble(), params[1].toDouble()); + else // Spec : if only one param given, assume uniform scaling + t->setScale(params[0].toDouble(), params[0].toDouble()); + } + else if(subtransform[0] == "skewx") + t->setSkewX(params[0].toDouble()); + else if(subtransform[0] == "skewy") + t->setSkewY(params[0].toDouble()); + else if(subtransform[0] == "matrix") + { + if(params.count() >= 6) + { + SVGMatrixImpl *ret = new SVGMatrixImpl(params[0].toDouble(), + params[1].toDouble(), + params[2].toDouble(), + params[3].toDouble(), + params[4].toDouble(), + params[5].toDouble()); + t->setMatrix(ret); + } + } + + list->appendItem(t); + } +} + +/// convert from user space to "real" pixels on rendering area +QRect SVGHelperImpl::fromUserspace(SVGElementImpl *obj, const QRect &r) +{ + QRect sr; + + SVGLocatableImpl *locate = dynamic_cast<SVGLocatableImpl *>(obj); + + if(locate) + sr = locate->screenCTM()->qmatrix().mapRect(r); + + return sr; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGHelperImpl.h b/ksvg/impl/SVGHelperImpl.h new file mode 100644 index 00000000..e8bbdb39 --- /dev/null +++ b/ksvg/impl/SVGHelperImpl.h @@ -0,0 +1,88 @@ +/* + Copyright (C) 2002-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. +*/ + +#ifndef SVGHelperImpl_H +#define SVGHelperImpl_H + +#include <dom/dom_element.h> + +#include "SVGElementImpl.h" +#include "SVGLengthImpl.h" +#include "SVGDocumentImpl.h" +#include "ksvg_ecma.h" + +#include "ksvg_lookup.h" + +class QRect; +class QString; + +namespace KSVG +{ +class SVGStringListImpl; +class SVGTransformListImpl; +class SVGAnimatedLengthListImpl; + +class SVGHelperImpl +{ +public: + SVGHelperImpl(); + ~SVGHelperImpl(); + + // Dynamic attribute updating + template<class T> + static void applyContainer(T *obj, int token, const QString &value) + { + SVGElementImpl *element = dynamic_cast<SVGElementImpl *>(obj); + if(!element || !element->hasChildNodes()) + return; + + // Very fast propagation of attributes, when the token is known! (Niko) + for(DOM::Node node = element->firstChild(); !node.isNull(); node = node.nextSibling()) + { + T *cast = dynamic_cast<T *>(element->ownerDoc()->getElementFromHandle(node.handle())); + if(cast) + cast->putValueProperty(element->ownerDoc()->ecmaEngine()->globalExec(), token, KJS::String(value), KJS::Internal); + } + } + + // Update item on canvas + static void updateItem(KJS::ExecState *exec, const DOM::Node node); + static void copyAttributes(SVGElementImpl *src, SVGElementImpl *dst); + + // SVGAnimatedLengthList + static void parseLengthList(SVGAnimatedLengthListImpl *list, const QString &lengths, LengthMode mode = LENGTHMODE_UNKNOWN, SVGElementImpl *object = 0); + + // SVGStringList + static void parseList(SVGStringListImpl *list, char seperator, const QString &data); + static void parseCommaSeperatedList(SVGStringListImpl *list, const QString &data); + static void parseSemicolonSeperatedList(SVGStringListImpl *list, const QString &data); + + // SVGTransformList + static void parseTransformAttribute(SVGTransformListImpl *list, const QString &transform); + + // Tools + static QRect fromUserspace(SVGElementImpl *, const QRect &); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGICCColorImpl.cc b/ksvg/impl/SVGICCColorImpl.cc new file mode 100644 index 00000000..3e708ee9 --- /dev/null +++ b/ksvg/impl/SVGICCColorImpl.cc @@ -0,0 +1,107 @@ +/* + 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> + +#include "SVGICCColorImpl.h" +#include "SVGNumberListImpl.h" + +using namespace KSVG; + +#include "SVGICCColorImpl.lut.h" +#include "ksvg_bridge.h" + +SVGICCColorImpl::SVGICCColorImpl() : DOM::DomShared() +{ + m_colors = new SVGNumberListImpl(); + m_colors->ref(); +} + +SVGICCColorImpl::SVGICCColorImpl(const SVGICCColorImpl &other) : DOM::DomShared() +{ + (*this) = other; +} + +SVGICCColorImpl::~SVGICCColorImpl() +{ + if(m_colors) + m_colors->deref(); +} + +SVGICCColorImpl &SVGICCColorImpl::operator=(const SVGICCColorImpl &other) +{ + m_colorProfile = other.m_colorProfile; + *m_colors = *(other.m_colors); + + return *this; +} + +DOM::DOMString SVGICCColorImpl::colorProfile() const +{ + return m_colorProfile; +} + +void SVGICCColorImpl::setColorProfile(const DOM::DOMString &colorProfile) +{ + m_colorProfile = colorProfile; +} + +SVGNumberListImpl *SVGICCColorImpl::colors() const +{ + return m_colors; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGICCColorImpl::s_hashTable 3 + colorProfile SVGICCColorImpl::ColorProfile DontDelete + colors SVGICCColorImpl::Colors DontDelete|ReadOnly +@end +*/ + +Value SVGICCColorImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case ColorProfile: + return String(m_colorProfile.string()); + case Colors: + return m_colors->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGICCColorImpl::putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int) +{ + switch(token) + { + case ColorProfile: + m_colorProfile = value.toString(exec).string(); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGICCColorImpl.h b/ksvg/impl/SVGICCColorImpl.h new file mode 100644 index 00000000..1427e59c --- /dev/null +++ b/ksvg/impl/SVGICCColorImpl.h @@ -0,0 +1,67 @@ +/* + 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. +*/ + +#ifndef SVGICCColorImpl_H +#define SVGICCColorImpl_H + +#include <dom/dom_misc.h> +#include <dom/dom_string.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGNumberListImpl; +class SVGICCColorImpl : public DOM::DomShared +{ +public: + SVGICCColorImpl(); + SVGICCColorImpl(const SVGICCColorImpl &); + virtual ~SVGICCColorImpl(); + + SVGICCColorImpl &operator=(const SVGICCColorImpl &); + + void setColorProfile(const DOM::DOMString &colorProfile); + DOM::DOMString colorProfile() const; + SVGNumberListImpl *colors() const; + +private: + DOM::DOMString m_colorProfile; + SVGNumberListImpl *m_colors; + +public: + KSVG_GET + + enum + { + // Properties + ColorProfile, Colors + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGImageElementImpl.cc b/ksvg/impl/SVGImageElementImpl.cc new file mode 100644 index 00000000..608dbda5 --- /dev/null +++ b/ksvg/impl/SVGImageElementImpl.cc @@ -0,0 +1,522 @@ +/* + 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 <qimage.h> +#include <qtimer.h> + +#include <kdebug.h> + +#include "CanvasItem.h" +#include "KSVGCanvas.h" +#include "KSVGHelper.h" + +#include "SVGRectImpl.h" +#include "SVGEventImpl.h" +#include "SVGMatrixImpl.h" +#include "SVGHelperImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGTransformImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGTransformListImpl.h" +#include "SVGAnimatedStringImpl.h" +#include "SVGAnimatedLengthImpl.h" +#include "SVGImageElementImpl.moc" +#include "SVGColorProfileElementImpl.h" +#include "SVGPreserveAspectRatioImpl.h" +#include "SVGAnimatedTransformListImpl.h" +#include "SVGAnimatedPreserveAspectRatioImpl.h" +#include "SVGPatternElementImpl.h" + +using namespace KSVG; + +#include "SVGImageElementImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" + +SVGImageElementImpl::SVGImageElementImpl(DOM::ElementImpl *impl) : QObject(), SVGShapeImpl(impl), SVGURIReferenceImpl(), SVGTestsImpl(), SVGLangSpaceImpl(), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this), SVGTransformableImpl() +{ + KSVG_EMPTY_FLAGS + + m_x = new SVGAnimatedLengthImpl(LENGTHMODE_WIDTH, this); + m_x->ref(); + m_x->baseVal()->setValueAsString("-1"); + + m_y = new SVGAnimatedLengthImpl(LENGTHMODE_HEIGHT, this); + m_y->ref(); + m_y->baseVal()->setValueAsString("-1"); + + m_width = new SVGAnimatedLengthImpl(LENGTHMODE_WIDTH, this); + m_width->ref(); + m_width->baseVal()->setValueAsString("-1"); + + m_height = new SVGAnimatedLengthImpl(LENGTHMODE_HEIGHT, this); + m_height->ref(); + m_height->baseVal()->setValueAsString("-1"); + + m_preserveAspectRatio = 0; + + m_doc = 0; + m_image = 0; + m_svgRoot = 0; + m_colorProfile = 0; + m_colorProfileApplied = false; +} + +SVGImageElementImpl::~SVGImageElementImpl() +{ + if(m_x) + m_x->deref(); + if(m_y) + m_y->deref(); + if(m_width) + m_width->deref(); + if(m_height) + m_height->deref(); + if(m_preserveAspectRatio) + m_preserveAspectRatio->deref(); + if(m_doc) + m_doc->deref(); + + delete m_image; +} + +SVGAnimatedLengthImpl *SVGImageElementImpl::x() +{ + return m_x; +} + +SVGAnimatedLengthImpl *SVGImageElementImpl::y() +{ + return m_y; +} + +SVGAnimatedLengthImpl *SVGImageElementImpl::width() +{ + return m_width; +} + +SVGAnimatedLengthImpl *SVGImageElementImpl::height() +{ + return m_height; +} + +SVGAnimatedPreserveAspectRatioImpl *SVGImageElementImpl::preserveAspectRatio() const +{ + return m_preserveAspectRatio; +} + +/* +@namespace KSVG +@namespace KSVG +@begin SVGImageElementImpl::s_hashTable 7 + x SVGImageElementImpl::X DontDelete|ReadOnly + y SVGImageElementImpl::Y DontDelete|ReadOnly + width SVGImageElementImpl::Width DontDelete|ReadOnly + height SVGImageElementImpl::Height DontDelete|ReadOnly + preserveAspectRatio SVGImageElementImpl::PreserveAspectRatio DontDelete|ReadOnly + href SVGImageElementImpl::Href DontDelete|ReadOnly +@end +*/ + +Value SVGImageElementImpl::getValueProperty(ExecState *exec, int token) const +{ + KSVG_CHECK_ATTRIBUTE + + switch(token) + { + case X: + if(!attributeMode) + return m_x->cache(exec); + else + return Number(m_x->baseVal()->value()); + case Y: + if(!attributeMode) + return m_y->cache(exec); + else + return Number(m_y->baseVal()->value()); + case Width: + if(!attributeMode) + return m_width->cache(exec); + else + return Number(m_width->baseVal()->value()); + case Height: + if(!attributeMode) + return m_height->cache(exec); + else + return Number(m_height->baseVal()->value()); + case PreserveAspectRatio: + if(m_preserveAspectRatio) + return m_preserveAspectRatio->cache(exec); + else + return Undefined(); + case Href: + SVGURIReferenceImpl::getValueProperty(exec, token); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGImageElementImpl::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; + + switch(token) + { + case X: + x()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + case Y: + y()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + case Width: + width()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + case Height: + height()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + case PreserveAspectRatio: + if(!preserveAspectRatio()) + { + m_preserveAspectRatio = new SVGAnimatedPreserveAspectRatioImpl(); + m_preserveAspectRatio->ref(); + } + + preserveAspectRatio()->baseVal()->parsePreserveAspectRatio(value.toString(exec).qstring()); + break; + case Href: + SVGURIReferenceImpl::putValueProperty(exec, SVGURIReferenceImpl::Href, value, attr); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +SVGRectImpl *SVGImageElementImpl::getBBox() +{ + SVGRectImpl *ret = SVGSVGElementImpl::createSVGRect(); + ret->setX(m_x->baseVal()->value()); + ret->setY(m_y->baseVal()->value()); + ret->setWidth(m_width->baseVal()->value()); + ret->setHeight(m_height->baseVal()->value()); + return ret; +} + +void SVGImageElementImpl::setAttributes() +{ + SVGElementImpl::setAttributes(); + + if(KSVG_TOKEN_NOT_PARSED(X)) + KSVG_SET_ALT_ATTRIBUTE(X, "0") + + if(KSVG_TOKEN_NOT_PARSED(Y)) + KSVG_SET_ALT_ATTRIBUTE(Y, "0") + + if(KSVG_TOKEN_NOT_PARSED(PreserveAspectRatio)) + { + setAttribute("preserveAspectRatio", "xMidYMid meet"); + KSVG_SET_ALT_ATTRIBUTE(PreserveAspectRatio, "xMidYMid meet") + } +} + +void SVGImageElementImpl::slotParsingFinished(bool error, const QString &errorDesc) +{ + if(error) + kdDebug(26003) << "Finished with error : " << errorDesc << endl; + else + kdDebug(26003) << "Finished without errors!" << endl; + + m_svgRoot = m_doc->rootElement(); +} + +void SVGImageElementImpl::slotLoadingFinished() +{ + ownerDoc()->notifyImageLoaded(this); +} + +void SVGImageElementImpl::createItem(KSVGCanvas *c) +{ + if(!m_item) + { + if(!c) + c = ownerDoc()->canvas(); + + m_item = c->createImage(this); + c->insert(m_item); + + if(href()->baseVal().string().endsWith(".svg") || href()->baseVal().string().endsWith(".svgz")) + { + if(!m_svgRoot) + { + m_doc = new SVGDocumentImpl(true, false, this); + m_doc->ref(); + m_doc->attach(c); + + connect(m_doc, SIGNAL(finishedParsing(bool, const QString &)), this, SLOT(slotParsingFinished(bool, const QString &))); + connect(m_doc, SIGNAL(finishedLoading()), this, SLOT(slotLoadingFinished())); + + KURL file; + + if(!KURL::isRelativeURL(href()->baseVal().string())) + file = KURL(href()->baseVal().string()); + else + file = KURL(ownerDoc()->baseUrl(), href()->baseVal().string()); + + m_doc->open(file); + + // The svg image will add items to the canvas in parallel with the main + // document, so the z-order will not be correct. Get it to fix this when everything's + // finished loading. + ownerDoc()->resortZIndicesOnFinishedLoading(); + ownerDoc()->notifyImageLoading(this); + } + else + m_svgRoot->createItem(c); + } + else + { + if(!m_image) + { + ownerDoc()->newImageJob(this); + ownerDoc()->notifyImageLoading(this); + } + } + } +} + +void SVGImageElementImpl::removeItem(KSVGCanvas *c) +{ + if(m_item && c) + { + if(m_svgRoot) + m_svgRoot->removeItem(c); + + c->removeItem(m_item); + m_item = 0; + } +} + +void SVGImageElementImpl::setupSVGElement(SVGSVGElementImpl *svg) +{ + // Set up the root svg for an svg image. + svg->setAttributeInternal("x", QString("%1").arg(x()->baseVal()->value())); + svg->setAttributeInternal("y", QString("%1").arg(y()->baseVal()->value())); + svg->setAttributeInternal("width", QString("%1").arg(width()->baseVal()->value())); + svg->setAttributeInternal("height", QString("%1").arg(height()->baseVal()->value())); + + QString par = getAttribute("preserveAspectRatio").string().stripWhiteSpace(); + + if(par.startsWith("defer")) + { + if(svg->getAttribute("preserveAspectRatio").isEmpty()) + { + par.remove("defer"); + svg->setAttribute("preserveAspectRatio", par); + svg->setAttributeInternal("preserveAspectRatio", par); + } + } + else + { + svg->setAttribute("preserveAspectRatio", par); + svg->setAttributeInternal("preserveAspectRatio", par); + } + + svg->setAttributes(); + svg->setRootParentScreenCTM(getScreenCTM()); +} + +void SVGImageElementImpl::onScreenCTMUpdated() +{ + if(m_svgRoot) + { + SVGMatrixImpl *ctm = getScreenCTM(); + + m_svgRoot->setRootParentScreenCTM(ctm); + m_svgRoot->invalidateCachedMatrices(); + m_svgRoot->ownerDoc()->syncCachedMatrices(); + } +} + +bool SVGImageElementImpl::prepareMouseEvent(const QPoint &p, const QPoint &, SVGMouseEventImpl *mev) +{ + // TODO : pointer-events should be stored here, not in SVGStylableImpl. + SVGStylableImpl *style = dynamic_cast<SVGStylableImpl *>(this); + if(!style || style->getPointerEvents() == PE_NONE) + return false; + bool test = true; + switch(style->getPointerEvents()) + { + case PE_VISIBLE: + case PE_VISIBLE_PAINTED: + case PE_VISIBLE_FILL: + case PE_VISIBLE_STROKE: test = style->getVisible(); break; + case PE_PAINTED: + case PE_FILL: + case PE_STROKE: + case PE_ALL: break; + default: test = false; + }; + + if(test && m_item) + { + if(m_item->bbox().contains(p)) + { + mev->setTarget(dynamic_cast<SVGElementImpl *>(this)); + return true; + } + } + + return false; +} + +void SVGImageElementImpl::setImage(QImage *image) +{ + m_image = image; + + if(m_image) + { + *m_image = m_image->convertDepth(32); + + if(m_colorProfile != 0 && !m_colorProfileApplied) + { + m_colorProfileApplied = true; + applyColorProfile(); + } + + SVGPatternElementImpl::flushCachedTiles(); + + if(m_item) + { + ownerDoc()->canvas()->invalidate(m_item, false); + ownerDoc()->rerender(); + } + } + + ownerDoc()->notifyImageLoaded(this); +} + +QImage SVGImageElementImpl::scaledImage() +{ + SVGMatrixImpl *matrix = imageMatrix(); + double sx, sy; + + matrix->removeScale(&sx, &sy); + matrix->deref(); + + QImage img; + + if(sx != 1 || sy != 1) + { + int scaledWidth = static_cast<int>(m_image->width() * sx + 0.5); + int scaledHeight = static_cast<int>(m_image->height() * sy + 0.5); + + img = m_image->smoothScale(scaledWidth, scaledHeight); + } + else + img = *m_image; + + return img; +} + +SVGMatrixImpl *SVGImageElementImpl::imageMatrix() +{ + SVGMatrixImpl *ctm = getScreenCTM(); + + ctm->translate(x()->baseVal()->value(), y()->baseVal()->value()); + + SVGMatrixImpl *viewboxMatrix = preserveAspectRatio()->baseVal()->getCTM(0, 0, image()->width(), image()->height(), 0, 0, width()->baseVal()->value(), height()->baseVal()->value()); + + ctm->multiply(viewboxMatrix); + viewboxMatrix->deref(); + + return ctm; +} + +SVGMatrixImpl *SVGImageElementImpl::scaledImageMatrix() +{ + SVGMatrixImpl *matrix = imageMatrix(); + double sx, sy; + + matrix->removeScale(&sx, &sy); + + if(sx != 1 || sy != 1) + { + int imageWidth = static_cast<int>(m_image->width() * sx + 0.5); + int imageHeight = static_cast<int>(m_image->height() * sy + 0.5); + + double trueWidth = m_image->width() * sx; + double trueHeight = m_image->height() * sy; + + matrix->scaleNonUniform(trueWidth / imageWidth, trueHeight / imageHeight); + } + + return matrix; +} + +KSVGPolygon SVGImageElementImpl::clippingShape() +{ + KSVGRectangle viewport(0, 0, width()->baseVal()->value(), height()->baseVal()->value()); + SVGMatrixImpl *matrix = preserveAspectRatio()->baseVal()->getCTM(0, 0, image()->width(), image()->height(), 0, 0, width()->baseVal()->value(), height()->baseVal()->value()); + KSVGPolygon p = matrix->inverseMap(viewport); + matrix->deref(); + + matrix = imageMatrix(); + p = matrix->map(p); + matrix->deref(); + + return p; +} + +QString SVGImageElementImpl::fileName() const +{ + return href()->baseVal().string(); +} + +void SVGImageElementImpl::applyColorProfile() +{ + m_image = m_colorProfile->correctImage(m_image); +} + +void SVGImageElementImpl::applyColorProfile(SVGColorProfileElementImpl *profile, SVGImageElementImpl *image) +{ + // Only apply once, if it's the same (Niko) + if(image->m_colorProfile == profile) + return; + + image->m_colorProfile = profile; + + if(image->m_image) + { + // Image is already painted, we apply the color profile and repaint it + image->applyColorProfile(); + + if(image->item()) + { + image->ownerDoc()->canvas()->invalidate(image->item(), false); + image->ownerDoc()->rerender(); + } + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGImageElementImpl.h b/ksvg/impl/SVGImageElementImpl.h new file mode 100644 index 00000000..35ae161f --- /dev/null +++ b/ksvg/impl/SVGImageElementImpl.h @@ -0,0 +1,140 @@ +/* + 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. +*/ + +#ifndef SVGImageElementImpl_H +#define SVGImageElementImpl_H + +#include <qobject.h> + +#include "ksvg_lookup.h" + +#include "SVGTestsImpl.h" +#include "SVGShapeImpl.h" +#include "SVGStylableImpl.h" +#include "SVGLangSpaceImpl.h" +#include "SVGURIReferenceImpl.h" +#include "SVGTransformableImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + +namespace KSVG +{ + +class KSVGPolygon; +class SVGDocumentImpl; +class SVGSVGElementImpl; +class SVGAnimatedLengthImpl; +class SVGColorProfileElementImpl; +class SVGAnimatedPreserveAspectRatioImpl; +class SVGImageElementImpl : public QObject, + public SVGShapeImpl, + public SVGURIReferenceImpl, + public SVGTestsImpl, + public SVGLangSpaceImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl, + public SVGTransformableImpl +{ +Q_OBJECT +public: + SVGImageElementImpl(DOM::ElementImpl *); + virtual ~SVGImageElementImpl(); + + SVGAnimatedLengthImpl *x(); + SVGAnimatedLengthImpl *y(); + SVGAnimatedLengthImpl *width(); + SVGAnimatedLengthImpl *height(); + SVGAnimatedPreserveAspectRatioImpl *preserveAspectRatio() const; + + virtual void createItem(KSVGCanvas *c); + virtual void removeItem(KSVGCanvas *c); + + virtual void setAttributes(); + + virtual bool prepareMouseEvent(const QPoint &p, const QPoint &a, SVGMouseEventImpl *mev); + + void setImage(QImage *image); + QImage *image() { return m_image; } + + QImage scaledImage(); + SVGMatrixImpl *imageMatrix(); + SVGMatrixImpl *scaledImageMatrix(); + + SVGSVGElementImpl *svgImageRootElement() const { return m_svgRoot; } + + void applyColorProfile(); + static void applyColorProfile(SVGColorProfileElementImpl *profile, SVGImageElementImpl *image); + + QString fileName() const; + + virtual SVGRectImpl *getBBox(); + + // Screen-space clipping shape + KSVGPolygon clippingShape(); + + void onScreenCTMUpdated(); + + void setupSVGElement(SVGSVGElementImpl *svg); + +private slots: + void slotParsingFinished(bool error, const QString &errorDesc); + void slotLoadingFinished(); + +private: + SVGAnimatedLengthImpl *m_x; + SVGAnimatedLengthImpl *m_y; + SVGAnimatedLengthImpl *m_width; + SVGAnimatedLengthImpl *m_height; + + QImage *m_image; + + bool m_colorProfileApplied; + SVGAnimatedPreserveAspectRatioImpl *m_preserveAspectRatio; + SVGColorProfileElementImpl *m_colorProfile; + SVGSVGElementImpl *m_svgRoot; + SVGDocumentImpl *m_doc; + +public: + KSVG_GET + KSVG_BRIDGE + KSVG_PUT + + enum + { + // Properties + X, Y, Width, Height, PreserveAspectRatio, Href + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +struct ImageStreamMap +{ + QByteArray *data; + SVGImageElementImpl *imageElement; +}; + +KSVG_REGISTER_ELEMENT(SVGImageElementImpl, "image") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGLangSpaceImpl.cc b/ksvg/impl/SVGLangSpaceImpl.cc new file mode 100644 index 00000000..0eaada47 --- /dev/null +++ b/ksvg/impl/SVGLangSpaceImpl.cc @@ -0,0 +1,130 @@ +/* + 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> + +#include "SVGLangSpaceImpl.h" + +using namespace KSVG; + +#include "SVGLangSpaceImpl.lut.h" +#include "ksvg_bridge.h" + +SVGLangSpaceImpl::SVGLangSpaceImpl() +{ + KSVG_EMPTY_FLAGS + + // Spec: default for xml:space is "default" + setXmlspace("default"); +} + +SVGLangSpaceImpl::~SVGLangSpaceImpl() +{ +} + +void SVGLangSpaceImpl::setXmllang(const DOM::DOMString &xmllang) +{ + m_xmllang = xmllang; +} + +DOM::DOMString SVGLangSpaceImpl::xmllang() const +{ + return m_xmllang; +} + +void SVGLangSpaceImpl::setXmlspace(const DOM::DOMString &xmlspace) +{ + m_xmlspace = xmlspace; +} + +DOM::DOMString SVGLangSpaceImpl::xmlspace() const +{ + return m_xmlspace; +} + +QString SVGLangSpaceImpl::handleText(const QString &data) const +{ + QString result = data; + + if(xmlspace() == "preserve") + { + // Spec: What to do here? + // It will convert all newline and tab characters into space characters + result.replace("\n\r", QString(" ")); + result.replace("\r\n", QString(" ")); + result.replace('\t', ' '); + } + else if(xmlspace() == "default") + { + // Spec: What to do here? + // First, it will remove all newline characters (replace) + // Then it will convert all tab characters into space characters (simplifyWhiteSpace) + // Then, it will strip off all leading and trailing space characters (stripWhiteSpace) + // Then, all contiguous space characters will be consolidated. (simplifyWhiteSpace) + result.replace('\n', QString::null); + result.replace('\r', QString::null); + result = result.stripWhiteSpace().simplifyWhiteSpace(); + } + + return result; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGLangSpaceImpl::s_hashTable 5 + xmllang SVGLangSpaceImpl::XmlLang DontDelete + xmlspace SVGLangSpaceImpl::XmlSpace DontDelete + lang SVGLangSpaceImpl::XmlLang DontDelete + space SVGLangSpaceImpl::XmlSpace DontDelete +@end +*/ + +Value SVGLangSpaceImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case XmlLang: + return String(m_xmllang.string()); + case XmlSpace: + return String(m_xmlspace.string()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGLangSpaceImpl::putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int /*attr*/) +{ + switch(token) + { + case XmlLang: + m_xmllang = value.toString(exec).string(); + break; + case XmlSpace: + m_xmlspace = value.toString(exec).string(); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGLangSpaceImpl.h b/ksvg/impl/SVGLangSpaceImpl.h new file mode 100644 index 00000000..4a8c199a --- /dev/null +++ b/ksvg/impl/SVGLangSpaceImpl.h @@ -0,0 +1,67 @@ +/* + 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. +*/ + +#ifndef SVGLangSpaceImpl_H +#define SVGLangSpaceImpl_H + +#include <dom/dom_string.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGLangSpaceImpl +{ +public: + SVGLangSpaceImpl(); + virtual ~SVGLangSpaceImpl(); + + void setXmllang(const DOM::DOMString &xmllang); + DOM::DOMString xmllang() const; + + void setXmlspace(const DOM::DOMString &xmlspace); + DOM::DOMString xmlspace() const; + + QString handleText(const QString &data) const; + +private: + DOM::DOMString m_xmllang; + DOM::DOMString m_xmlspace; + +public: + KSVG_BASECLASS_GET + KSVG_PUT + + enum + { + // Properties + XmlLang, XmlSpace + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGLengthImpl.cc b/ksvg/impl/SVGLengthImpl.cc new file mode 100644 index 00000000..46529022 --- /dev/null +++ b/ksvg/impl/SVGLengthImpl.cc @@ -0,0 +1,510 @@ +/* + 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> + +#include <qfont.h> +#include <qregexp.h> +#include <qwidget.h> +#include <qpaintdevicemetrics.h> + +#include "SVGLength.h" + +#include "SVGRectImpl.h" +#include "SVGLengthImpl.h" +#include "SVGMatrixImpl.h" +#include "SVGHelperImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGStringListImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGAnimatedLengthImpl.h" +#include "SVGAnimatedRectImpl.h" +#include "svgpathparser.h" + +#include "KSVGCanvas.h" + +using namespace KSVG; + +#include "SVGLengthImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_cacheimpl.h" + +// keep track of textual description of the unit type +QString UnitText[] = +{ + "", "", "%", "em", "ex", "px", "cm", "mm", "in", "pt", "pc" +}; + +SVGLengthImpl::SVGLengthImpl(LengthMode mode, SVGElementImpl *context) : DOM::DomShared(), m_mode(mode), m_context(context) +{ + KSVG_EMPTY_FLAGS + + m_unitType = SVG_LENGTHTYPE_UNKNOWN; + m_value = 0; + m_valueInSpecifiedUnits = 0; + m_bboxContext = 0; +} + +SVGLengthImpl::SVGLengthImpl(const SVGLengthImpl &other) : DOM::DomShared() +{ + (*this) = other; +} + +SVGLengthImpl::~SVGLengthImpl() +{ +} + +double SVGLengthImpl::dpi() +{ + if(m_context && m_context->ownerDoc()) + { + if(m_mode == LENGTHMODE_WIDTH) + return 25.4 * m_context->ownerDoc()->screenPixelsPerMillimeterX(); + else if(m_mode == LENGTHMODE_HEIGHT) + return 25.4 * m_context->ownerDoc()->screenPixelsPerMillimeterY(); + else if(m_mode == LENGTHMODE_OTHER) + return 25.4 * m_context->ownerDoc()->screenPixelsPerMillimeterX(); + } + return 90.0; +} + +SVGLengthImpl &SVGLengthImpl::operator=(const SVGLengthImpl &other) +{ + m_unitType = other.m_unitType; + m_value = other.m_value; + m_valueInSpecifiedUnits = other.m_valueInSpecifiedUnits; + m_bboxContext = other.m_bboxContext; + m_mode = other.m_mode; + m_context = other.m_context; + + return *this; +} + +unsigned short SVGLengthImpl::unitType() const +{ + return m_unitType; +} + +void SVGLengthImpl::setValue(float value) +{ + m_value = value; + getValFromPx(); +} + +float SVGLengthImpl::value() +{ + if(m_unitType == SVG_LENGTHTYPE_PERCENTAGE) + { + float value = m_valueInSpecifiedUnits / 100.0; + SVGRectImpl *bbox = 0; + if(m_bboxContext && (bbox = m_bboxContext->getBBox())) + { + float result = 0; + if(m_mode == LENGTHMODE_WIDTH) + result = value * bbox->width(); + else if(m_mode == LENGTHMODE_HEIGHT) + result = value * bbox->height(); + else if(m_mode == LENGTHMODE_OTHER) + result = value * sqrt(pow(bbox->width(), 2) + pow(bbox->height(), 2)) / sqrt(2.0); + + bbox->deref(); + return result; + } + else + return percentageOfViewport(); + } + else + return m_value; +} + +void SVGLengthImpl::setValueInSpecifiedUnits(float valueInSpecifiedUnits) +{ + m_valueInSpecifiedUnits = valueInSpecifiedUnits; + convertNumToPx(); +} + +float SVGLengthImpl::valueInSpecifiedUnits() const +{ + return m_valueInSpecifiedUnits; +} + +void SVGLengthImpl::setValueAsString(const DOM::DOMString &valueAsString) +{ + convertStringToPx(valueAsString.string()); +} + +DOM::DOMString SVGLengthImpl::valueAsString() const +{ + DOM::DOMString valueAsString = QString::number(m_valueInSpecifiedUnits); + valueAsString += UnitText[m_unitType]; + return valueAsString; +} + +void SVGLengthImpl::newValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits) +{ + m_valueInSpecifiedUnits = valueInSpecifiedUnits; + m_unitType = unitType; + convertNumToPx(); +} + +void SVGLengthImpl::convertToSpecifiedUnits(unsigned short unitType) +{ + m_unitType = unitType; + getValFromPx(); +} + +SVGLengthImpl::operator float() +{ + return valueInSpecifiedUnits(); +} + +bool SVGLengthImpl::getValFromPx() +{ + if(m_unitType == SVG_LENGTHTYPE_UNKNOWN) + return false; + + switch(m_unitType) + { + // case SVG_LENGTHTYPE_PERCENTAGE: TODO + // case SVG_LENGTHTYPE_EMS: TODO + // case SVG_LENGTHTYPE_EXS: TODO + //break; + case SVG_LENGTHTYPE_PX: + m_valueInSpecifiedUnits = m_value; + break; + case SVG_LENGTHTYPE_CM: + m_valueInSpecifiedUnits = m_value / dpi() * 2.54; + break; + case SVG_LENGTHTYPE_MM: + m_valueInSpecifiedUnits = m_value / dpi() * 25.4; + break; + case SVG_LENGTHTYPE_IN: + m_valueInSpecifiedUnits = m_value / dpi(); + break; + case SVG_LENGTHTYPE_PT: + m_valueInSpecifiedUnits = m_value / dpi() * 72.0; + break; + case SVG_LENGTHTYPE_PC: + m_valueInSpecifiedUnits = m_value / dpi() * 6.0; + break; + }; + return true; +} + +void SVGLengthImpl::convertStringToPx(QString s) +{ + if(s.isEmpty()) + return; + + double convNum = 0; + const char *start = s.latin1(); + const char *end = getNumber(start, convNum); + m_valueInSpecifiedUnits = convNum; + + if(uint(end - start) < s.length()) + { + if(s.endsWith(UnitText[SVG_LENGTHTYPE_PX])) + m_unitType = SVG_LENGTHTYPE_PX; + else if(s.endsWith(UnitText[SVG_LENGTHTYPE_CM])) + m_unitType = SVG_LENGTHTYPE_CM; + else if(s.endsWith(UnitText[SVG_LENGTHTYPE_PC])) + m_unitType = SVG_LENGTHTYPE_PC; + else if(s.endsWith(UnitText[SVG_LENGTHTYPE_MM])) + m_unitType = SVG_LENGTHTYPE_MM; + else if(s.endsWith(UnitText[SVG_LENGTHTYPE_IN])) + m_unitType = SVG_LENGTHTYPE_IN; + else if(s.endsWith(UnitText[SVG_LENGTHTYPE_PT])) + m_unitType = SVG_LENGTHTYPE_PT; + else if(s.endsWith(UnitText[SVG_LENGTHTYPE_PERCENTAGE])) + m_unitType = SVG_LENGTHTYPE_PERCENTAGE; + else if(s.endsWith(UnitText[SVG_LENGTHTYPE_EMS])) + m_unitType = SVG_LENGTHTYPE_EMS; + else if(s.endsWith(UnitText[SVG_LENGTHTYPE_EXS])) + m_unitType = SVG_LENGTHTYPE_EXS; + else if(s.isEmpty()) + m_unitType = SVG_LENGTHTYPE_NUMBER; + else + m_unitType = SVG_LENGTHTYPE_UNKNOWN; + } + else + m_unitType = SVG_LENGTHTYPE_PX; + convertNumToPx(); +} + +void SVGLengthImpl::convertNumToPx() +{ + switch(m_unitType) + { + case SVG_LENGTHTYPE_PX: + m_value = m_valueInSpecifiedUnits; + break; + case SVG_LENGTHTYPE_CM: + m_value = (m_valueInSpecifiedUnits / 2.54) * dpi(); + break; + case SVG_LENGTHTYPE_MM: + m_value = (m_valueInSpecifiedUnits / 25.4) * dpi(); + break; + case SVG_LENGTHTYPE_IN: + m_value = m_valueInSpecifiedUnits * dpi(); + break; + case SVG_LENGTHTYPE_PT: + m_value = (m_valueInSpecifiedUnits / 72.0) * dpi(); + break; + case SVG_LENGTHTYPE_PC: + m_value = (m_valueInSpecifiedUnits / 6.0) * dpi(); + break; + case SVG_LENGTHTYPE_EMS: // Be careful here, always recheck coords-units-BE-01.svg after touching (Niko) + case SVG_LENGTHTYPE_EXS: + if(m_context) + { + SVGStylableImpl *style = dynamic_cast<SVGStylableImpl *>(m_context); + if(!style) + break; + + bool sizeLocal = (style->getFontSize() != -1); + bool familyLocal = (style->getFontFamily() && style->getFontFamily()->getFirst()); + + SVGStylableImpl *parentStyle = 0; + if((!sizeLocal || !familyLocal) && m_context) + parentStyle = dynamic_cast<SVGStylableImpl *>(m_context->ownerDoc()->getElementFromHandle(m_context->parentNode().handle())); + + // Look up font-size in a SAFE way, because at this place + // processStyle() has NOT yet been called, so we need + // a different solution (Niko) + QString useFont = "Arial"; + double useSize = 12; + + if(sizeLocal) + useSize = style->getFontSize(); + else if(parentStyle && parentStyle->getFontSize() != -1) + useSize = parentStyle->getFontSize(); + + if(familyLocal) + useFont = style->getFontFamily()->getFirst()->string(); + else if(parentStyle && parentStyle->getFontFamily() && parentStyle->getFontFamily()->getFirst()) + useFont = parentStyle->getFontFamily()->getFirst()->string(); + + if(m_unitType == SVG_LENGTHTYPE_EMS) + m_value = m_valueInSpecifiedUnits * useSize; + else + { + // Easiest way, use qfont (Niko) + QFont font(useFont); + font.setPixelSize(static_cast<int>(useSize)); + + QFontMetrics fm(font); + m_value = m_valueInSpecifiedUnits * fm.boundingRect('x').height(); + } + } + break; + }; +} + +void SVGLengthImpl::convertPercentageToFloat(const QString &perc, float &result) +{ + // TODO : more error checking ? + if(perc.endsWith("%")) + result = perc.left(perc.length() - 1).toFloat() / 100.0; + else + result = perc.toFloat(); +} + +QString SVGLengthImpl::convertValToPercentage(const QString &val, float benchmark) +{ + if(val.endsWith("%")) + return val; + + QString result; + float temp = val.toFloat(); + + temp = (temp / benchmark) * 100.0; + result.setNum(temp); + result.append("%"); + + return result; +} + +SVGElementImpl *SVGLengthImpl::context() const +{ + return m_context; +} + +void SVGLengthImpl::setContext(SVGElementImpl *context) +{ + m_context = context; +} + +void SVGLengthImpl::setBBoxContext(SVGShapeImpl *bbox) +{ + m_bboxContext = bbox; + convertNumToPx(); +} + +float SVGLengthImpl::percentageOfViewport() +{ + float width = 0, height = 0; + float value = m_valueInSpecifiedUnits / 100.0; + if(m_context->viewportElement()) + { + SVGSVGElementImpl *svg = dynamic_cast<SVGSVGElementImpl *>(m_context->viewportElement()); + if(svg) + { + // Calculate against viewBox, otherwise svg width/height + width = svg->viewBox()->baseVal()->width(); + if(width == 0) + width = svg->width()->baseVal()->value(); + height = svg->viewBox()->baseVal()->height(); + if(height == 0) + height = svg->height()->baseVal()->value(); + } + + if(m_mode == LENGTHMODE_WIDTH) + return value * width; + else if(m_mode == LENGTHMODE_HEIGHT) + return value * height; + else if(m_mode == LENGTHMODE_OTHER) + return value * sqrt(pow(width, 2) + pow(height, 2)) / sqrt(2.0); + } + else if(m_context == m_context->ownerDoc()->rootElement()) + { + if(!m_context->ownerDoc()->canvas()) // Happens when parsing <svg width="100%"> with printnodetest + return 0.0; + + QPaintDeviceMetrics metrics(m_context->ownerDoc()->canvas()->drawWindow()); + + if(m_mode == LENGTHMODE_WIDTH) + return value * metrics.width(); + else if(m_mode == LENGTHMODE_HEIGHT) + return value * metrics.height(); + else if(m_mode == LENGTHMODE_OTHER) + return value * sqrt(pow(metrics.width(), 2) + pow(metrics.height(), 2)) / sqrt(2.0); + } + + return 0; +} + +// Ecma stuff +// +/* +@namespace KSVG +@begin SVGLengthImpl::s_hashTable 5 + unitType SVGLengthImpl::UnitType DontDelete|ReadOnly + value SVGLengthImpl::Value DontDelete + valueAsString SVGLengthImpl::ValueAsString DontDelete + valueInSpecifiedUnits SVGLengthImpl::ValueInSpecifiedUnits DontDelete +@end +@namespace KSVG +@begin SVGLengthImplProto::s_hashTable 3 + newValueSpecifiedUnits SVGLengthImpl::NewValueSpecifiedUnits DontDelete|Function 2 + convertToSpecifiedUnits SVGLengthImpl::ConvertToSpecifiedUnits DontDelete|Function 1 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGLength", SVGLengthImplProto, SVGLengthImplProtoFunc) + +Value SVGLengthImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case UnitType: + return Number(unitType()); + case Value: + return Number(m_value); + case ValueAsString: + return String(valueAsString().string()); + case ValueInSpecifiedUnits: + return Number(valueInSpecifiedUnits()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return KJS::Undefined(); + } +} + +void SVGLengthImpl::putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int) +{ + switch(token) + { + case Value: + setValue(value.toNumber(exec)); + SVGHelperImpl::updateItem(exec, *m_context); + break; + case ValueAsString: + setValueAsString(value.toString(exec).string()); + SVGHelperImpl::updateItem(exec, *m_context); + break; + case ValueInSpecifiedUnits: + setValueInSpecifiedUnits(value.toNumber(exec)); + SVGHelperImpl::updateItem(exec, *m_context); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +Value SVGLengthImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGLengthImpl) + + switch(id) + { + case SVGLengthImpl::NewValueSpecifiedUnits: + obj->newValueSpecifiedUnits(static_cast<unsigned short>(args[0].toNumber(exec)), args[1].toNumber(exec)); + SVGHelperImpl::updateItem(exec, *obj->context()); + return Undefined(); + case SVGLengthImpl::ConvertToSpecifiedUnits: + obj->convertToSpecifiedUnits(static_cast<unsigned short>(args[0].toNumber(exec))); + SVGHelperImpl::updateItem(exec, *obj->context()); + return Undefined(); + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return Undefined(); +} + +/* +@namespace KSVG +@begin SVGLengthImplConstructor::s_hashTable 11 + SVG_LENGTHTYPE_UNKNOWN KSVG::SVG_LENGTHTYPE_UNKNOWN DontDelete|ReadOnly + SVG_LENGTHTYPE_NUMBER KSVG::SVG_LENGTHTYPE_NUMBER DontDelete|ReadOnly + SVG_LENGTHTYPE_PERCENTAGE KSVG::SVG_LENGTHTYPE_PERCENTAGE DontDelete|ReadOnly + SVG_LENGTHTYPE_EMS KSVG::SVG_LENGTHTYPE_EMS DontDelete|ReadOnly + SVG_LENGTHTYPE_EXS KSVG::SVG_LENGTHTYPE_EXS DontDelete|ReadOnly + SVG_LENGTHTYPE_PX KSVG::SVG_LENGTHTYPE_PX DontDelete|ReadOnly + SVG_LENGTHTYPE_CM KSVG::SVG_LENGTHTYPE_CM DontDelete|ReadOnly + SVG_LENGTHTYPE_MM KSVG::SVG_LENGTHTYPE_MM DontDelete|ReadOnly + SVG_LENGTHTYPE_PT KSVG::SVG_LENGTHTYPE_PT DontDelete|ReadOnly + SVG_LENGTHTYPE_PC KSVG::SVG_LENGTHTYPE_PC DontDelete|ReadOnly +@end +*/ + +Value SVGLengthImplConstructor::getValueProperty(ExecState *, int token) const +{ + return Number(token); +} + +Value KSVG::getSVGLengthImplConstructor(ExecState *exec) +{ + return cacheGlobalBridge<SVGLengthImplConstructor>(exec, "[[svglength.constructor]]"); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGLengthImpl.h b/ksvg/impl/SVGLengthImpl.h new file mode 100644 index 00000000..5879a091 --- /dev/null +++ b/ksvg/impl/SVGLengthImpl.h @@ -0,0 +1,136 @@ +/* + 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. +*/ + +#ifndef SVGLengthImpl_H +#define SVGLengthImpl_H + +#include <dom/dom_misc.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +enum LengthMode +{ + LENGTHMODE_UNKNOWN = 0, + LENGTHMODE_WIDTH = 1, + LENGTHMODE_HEIGHT = 2, + LENGTHMODE_OTHER = 3 +}; + +class SVGShapeImpl; +class SVGLocatableImpl; +class SVGElementImpl; +class SVGLengthImpl : public DOM::DomShared +{ +public: + SVGLengthImpl(LengthMode mode = LENGTHMODE_UNKNOWN, SVGElementImpl *context = 0); + SVGLengthImpl(const SVGLengthImpl &); + virtual ~SVGLengthImpl(); + + SVGLengthImpl &operator=(const SVGLengthImpl &); + + unsigned short unitType() const; + + void setValue(float value); + float value(); + + void setValueInSpecifiedUnits(float valueInSpecifiedUnits); + float valueInSpecifiedUnits() const; + + void setValueAsString(const DOM::DOMString &); + DOM::DOMString valueAsString() const; + + void newValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits); + void convertToSpecifiedUnits(unsigned short unitType); + + operator float(); + + static void convertPercentageToFloat(const QString &perc, float &result); + + // This method converts the value val to percentage notation ("xxx%"). + // If the value string ends with the percentage sign it is returned, + // else the value is calculated against benchmark, ie. "0.2" -> "20%" + // for benchmark 1.0. This method should be useful in contexts that + // know the values should be in percentages up front, like bbox + // calculations. + static QString convertValToPercentage(const QString &val, float benchmark = 1.0); + + SVGElementImpl *context() const; + void setContext(SVGElementImpl *context); + void setBBoxContext(SVGShapeImpl *bbox); + +private: + float m_value; + float m_valueInSpecifiedUnits; + + float percentageOfViewport(); + + void convertStringToPx(QString s); + void convertNumToPx(); + bool getValFromPx(); + + unsigned short m_unitType : 4; + + // KSVG extension + LengthMode m_mode : 2; + SVGElementImpl *m_context; + SVGShapeImpl *m_bboxContext; + + double dpi(); + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + UnitType, Value, ValueAsString, ValueInSpecifiedUnits, + // Functions + NewValueSpecifiedUnits, ConvertToSpecifiedUnits + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); + +}; + +class SVGLengthImplConstructor : public KJS::ObjectImp +{ +public: + SVGLengthImplConstructor(KJS::ExecState *) { } + KJS::Value getValueProperty(KJS::ExecState *, int token) const; + + // no put - all read-only + KSVG_GET +}; + +KJS::Value getSVGLengthImplConstructor(KJS::ExecState *exec); + +} + +KSVG_DEFINE_PROTOTYPE(SVGLengthImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGLengthImplProtoFunc, SVGLengthImpl) + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGLengthListImpl.cc b/ksvg/impl/SVGLengthListImpl.cc new file mode 100644 index 00000000..31215ddd --- /dev/null +++ b/ksvg/impl/SVGLengthListImpl.cc @@ -0,0 +1,64 @@ +/* + 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> + +#include "SVGLengthListImpl.h" + +using namespace KSVG; + +#include "SVGLengthListImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGLengthListImpl::s_hashTable 2 + numberOfItems SVGListDefs::NumberOfItems DontDelete|ReadOnly +@end +@namespace KSVG +@begin SVGLengthListImplProto::s_hashTable 11 + getItem SVGListDefs::GetItem DontDelete|Function 1 + removeItem SVGListDefs::RemoveItem DontDelete|Function 1 + appendItem SVGListDefs::AppendItem DontDelete|Function 1 + initialize SVGListDefs::Initialize DontDelete|Function 1 + insertItemBefore SVGListDefs::InsertItemBefore DontDelete|Function 2 + replaceItem SVGListDefs::ReplaceItem DontDelete|Function 2 + clear SVGListDefs::Clear DontDelete|Function 0 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGLengthList", SVGLengthListImplProto, SVGLengthListImplProtoFunc) + +Value SVGLengthListImpl::getValueProperty(ExecState *exec, int token) const +{ + return SVGList<SVGLengthImpl>::getValueProperty(exec, token); +} + +Value SVGLengthListImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGLengthListImpl) + + return obj->call(exec, static_cast<SVGList<SVGLengthImpl> *>(obj), args, id); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGLengthListImpl.h b/ksvg/impl/SVGLengthListImpl.h new file mode 100644 index 00000000..7ef8c80d --- /dev/null +++ b/ksvg/impl/SVGLengthListImpl.h @@ -0,0 +1,48 @@ +/* + 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. +*/ + +#ifndef SVGLengthListImpl_H +#define SVGLengthListImpl_H + +#include "ksvg_lookup.h" + +#include "SVGList.h" + +#include "SVGLengthImpl.h" + +namespace KSVG +{ + +class SVGLengthListImpl : public SVGList<SVGLengthImpl> +{ +public: + KSVG_GET + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; +}; + +} + +KSVG_DEFINE_PROTOTYPE(SVGLengthListImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGLengthListImplProtoFunc, SVGLengthListImpl) + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGLineElementImpl.cc b/ksvg/impl/SVGLineElementImpl.cc new file mode 100644 index 00000000..7e13f46c --- /dev/null +++ b/ksvg/impl/SVGLineElementImpl.cc @@ -0,0 +1,213 @@ +/* + 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 <math.h> +#include <kglobal.h> + +#include <kdebug.h> + +#include "CanvasItem.h" +#include "KSVGCanvas.h" + +#include "SVGRectImpl.h" +#include "SVGAngleImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGLineElementImpl.h" +#include "SVGAnimatedLengthImpl.h" + +using namespace KSVG; + +#include "SVGLineElementImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" + +SVGLineElementImpl::SVGLineElementImpl(DOM::ElementImpl *impl) : SVGShapeImpl(impl), SVGTestsImpl(), SVGLangSpaceImpl(), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this), SVGTransformableImpl() +{ + KSVG_EMPTY_FLAGS + + m_x1 = new SVGAnimatedLengthImpl(LENGTHMODE_WIDTH, this); + m_x1->ref(); + m_x1->baseVal()->setValueAsString("-1"); + + m_y1 = new SVGAnimatedLengthImpl(LENGTHMODE_HEIGHT, this); + m_y1->ref(); + m_y1->baseVal()->setValueAsString("-1"); + + m_x2 = new SVGAnimatedLengthImpl(LENGTHMODE_WIDTH, this); + m_x2->ref(); + m_x2->baseVal()->setValueAsString("-1"); + + m_y2 = new SVGAnimatedLengthImpl(LENGTHMODE_HEIGHT, this); + m_y2->ref(); + m_y2->baseVal()->setValueAsString("-1"); +} + +SVGLineElementImpl::~SVGLineElementImpl() +{ + if(m_x1) + m_x1->deref(); + if(m_x2) + m_x2->deref(); + if(m_y1) + m_y1->deref(); + if(m_y2) + m_y2->deref(); +} + +SVGAnimatedLengthImpl *SVGLineElementImpl::x1() +{ + return m_x1; +} + +SVGAnimatedLengthImpl *SVGLineElementImpl::y1() +{ + return m_y1; +} + +SVGAnimatedLengthImpl *SVGLineElementImpl::x2() +{ + return m_x2; +} + +SVGAnimatedLengthImpl *SVGLineElementImpl::y2() +{ + return m_y2; +} + +/* +@namespace KSVG +@begin SVGLineElementImpl::s_hashTable 5 + x1 SVGLineElementImpl::X1 DontDelete|ReadOnly + y1 SVGLineElementImpl::Y1 DontDelete|ReadOnly + x2 SVGLineElementImpl::X2 DontDelete|ReadOnly + y2 SVGLineElementImpl::Y2 DontDelete|ReadOnly +@end +*/ + +Value SVGLineElementImpl::getValueProperty(ExecState *exec, int token) const +{ + KSVG_CHECK_ATTRIBUTE + + switch(token) + { + case X1: + if(!attributeMode) + return m_x1->cache(exec); + else + return Number(m_x1->baseVal()->value()); + case Y1: + if(!attributeMode) + return m_y1->cache(exec); + else + return Number(m_y1->baseVal()->value()); + case X2: + if(!attributeMode) + return m_x2->cache(exec); + else + return Number(m_x2->baseVal()->value()); + case Y2: + if(!attributeMode) + return m_y2->cache(exec); + else + return Number(m_y2->baseVal()->value()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGLineElementImpl::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; + + switch(token) + { + case X1: + x1()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + case Y1: + y1()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + case X2: + x2()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + case Y2: + y2()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +SVGRectImpl *SVGLineElementImpl::getBBox() +{ + SVGRectImpl *ret = SVGSVGElementImpl::createSVGRect(); + + float minx = kMin(m_x1->baseVal()->value(), m_x2->baseVal()->value()); + float miny = kMin(m_y1->baseVal()->value(), m_y2->baseVal()->value()); + float maxx = kMax(m_x1->baseVal()->value(), m_x2->baseVal()->value()); + float maxy = kMax(m_y1->baseVal()->value(), m_y2->baseVal()->value()); + ret->setX(minx); + ret->setY(miny); + ret->setWidth(maxx - minx); + ret->setHeight(maxy - miny); + + return ret; +} + +void SVGLineElementImpl::setAttributes() +{ + SVGElementImpl::setAttributes(); + + // Spec: if not specified, effect is as if a value of "0" were specified + if(KSVG_TOKEN_NOT_PARSED(X1)) + KSVG_SET_ALT_ATTRIBUTE(X1, "0") + + // Spec: if not specified, effect is as if a value of "0" were specified + if(KSVG_TOKEN_NOT_PARSED(Y1)) + KSVG_SET_ALT_ATTRIBUTE(Y1, "0") + + // Spec: if not specified, effect is as if a value of "0" were specified + if(KSVG_TOKEN_NOT_PARSED(X2)) + KSVG_SET_ALT_ATTRIBUTE(X2, "0") + + // Spec: if not specified, effect is as if a value of "0" were specified + if(KSVG_TOKEN_NOT_PARSED(Y2)) + KSVG_SET_ALT_ATTRIBUTE(Y2, "0") +} + +void SVGLineElementImpl::createItem(KSVGCanvas *c) +{ + if(!c) + c = ownerDoc()->canvas(); + + if(!m_item) + { + m_item = c->createLine(this); + c->insert(m_item); + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGLineElementImpl.h b/ksvg/impl/SVGLineElementImpl.h new file mode 100644 index 00000000..725881a3 --- /dev/null +++ b/ksvg/impl/SVGLineElementImpl.h @@ -0,0 +1,86 @@ +/* + 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. +*/ + +#ifndef SVGLineElementImpl_H +#define SVGLineElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGShapeImpl.h" +#include "SVGTestsImpl.h" +#include "SVGStylableImpl.h" +#include "SVGLangSpaceImpl.h" +#include "SVGTransformableImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + +namespace KSVG +{ + +class SVGRectImpl; +class SVGAnimatedLengthImpl; +class SVGLineElementImpl : public SVGShapeImpl, + public SVGTestsImpl, + public SVGLangSpaceImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl, + public SVGTransformableImpl +{ +public: + SVGLineElementImpl(DOM::ElementImpl *); + virtual ~SVGLineElementImpl(); + + SVGAnimatedLengthImpl *x1(); + SVGAnimatedLengthImpl *y1(); + SVGAnimatedLengthImpl *x2(); + SVGAnimatedLengthImpl *y2(); + + virtual void createItem(KSVGCanvas *c = 0); + virtual void setAttributes(); + + virtual SVGRectImpl *getBBox(); + +private: + SVGAnimatedLengthImpl *m_x1; + SVGAnimatedLengthImpl *m_y1; + SVGAnimatedLengthImpl *m_x2; + SVGAnimatedLengthImpl *m_y2; + +public: + KSVG_GET + KSVG_PUT + KSVG_BRIDGE + + enum + { + // Properties + X1, Y1, X2, Y2 + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +KSVG_REGISTER_ELEMENT(SVGLineElementImpl, "line") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGLinearGradientElementImpl.cc b/ksvg/impl/SVGLinearGradientElementImpl.cc new file mode 100644 index 00000000..54c97f01 --- /dev/null +++ b/ksvg/impl/SVGLinearGradientElementImpl.cc @@ -0,0 +1,201 @@ +/* + 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 "SVGGradientElement.h" +#include "SVGLinearGradientElementImpl.h" + +#include "SVGDocumentImpl.h" +#include "KSVGCanvas.h" +#include "SVGAnimatedLengthImpl.h" +#include "SVGLengthImpl.h" +#include "SVGUnitConverter.h" + +using namespace KSVG; + +#include "SVGLinearGradientElementImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" + +SVGLinearGradientElementImpl::SVGLinearGradientElementImpl(DOM::ElementImpl *impl) : SVGGradientElementImpl(impl) +{ + KSVG_EMPTY_FLAGS + + m_x1 = new SVGAnimatedLengthImpl(LENGTHMODE_WIDTH, this); + m_x1->ref(); + + m_y1 = new SVGAnimatedLengthImpl(LENGTHMODE_HEIGHT, this); + m_y1->ref(); + + m_x2 = new SVGAnimatedLengthImpl(LENGTHMODE_WIDTH, this); + m_x2->ref(); + + m_y2 = new SVGAnimatedLengthImpl(LENGTHMODE_HEIGHT, this); + m_y2->ref(); + + converter()->add(m_x1); + converter()->add(m_y1); + converter()->add(m_x2); + converter()->add(m_y2); +} + +SVGLinearGradientElementImpl::~SVGLinearGradientElementImpl() +{ + if(m_x1) + m_x1->deref(); + if(m_y1) + m_y1->deref(); + if(m_x2) + m_x2->deref(); + if(m_y2) + m_y2->deref(); +} + +SVGAnimatedLengthImpl *SVGLinearGradientElementImpl::x1() const +{ + return m_x1; +} + +SVGAnimatedLengthImpl *SVGLinearGradientElementImpl::y1() const +{ + return m_y1; +} + +SVGAnimatedLengthImpl *SVGLinearGradientElementImpl::x2() const +{ + return m_x2; +} + +SVGAnimatedLengthImpl *SVGLinearGradientElementImpl::y2() const +{ + return m_y2; +} + +/* +@namespace KSVG +@begin SVGLinearGradientElementImpl::s_hashTable 5 + x1 SVGLinearGradientElementImpl::X1 DontDelete|ReadOnly + y1 SVGLinearGradientElementImpl::Y1 DontDelete|ReadOnly + x2 SVGLinearGradientElementImpl::X2 DontDelete|ReadOnly + y2 SVGLinearGradientElementImpl::Y2 DontDelete|ReadOnly +@end +*/ + +Value SVGLinearGradientElementImpl::getValueProperty(ExecState *exec, int token) const +{ + KSVG_CHECK_ATTRIBUTE + + switch(token) + { + case X1: + if(!attributeMode) + return m_x1->cache(exec); + else + return Number(m_x1->baseVal()->value()); + case Y1: + if(!attributeMode) + return m_y1->cache(exec); + else + return Number(m_y1->baseVal()->value()); + case X2: + if(!attributeMode) + return m_x2->cache(exec); + else + return Number(m_x2->baseVal()->value()); + case Y2: + if(!attributeMode) + return m_y2->cache(exec); + else + return Number(m_y2->baseVal()->value()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGLinearGradientElementImpl::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; + + switch(token) + { + case X1: + converter()->modify(x1(), value.toString(exec).qstring()); + break; + case Y1: + converter()->modify(y1(), value.toString(exec).qstring()); + break; + case X2: + converter()->modify(x2(), value.toString(exec).qstring()); + break; + case Y2: + converter()->modify(y2(), value.toString(exec).qstring()); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +void SVGLinearGradientElementImpl::setAttributes() +{ + SVGGradientElementImpl::setAttributes(); + + // Spec: no attribute, effect is af value 0% is specified + if(KSVG_TOKEN_NOT_PARSED(X1)) + KSVG_SET_ALT_ATTRIBUTE(X1, "0") + + // Spec: no attribute, effect is af value 0% is specified + if(KSVG_TOKEN_NOT_PARSED(Y1)) + KSVG_SET_ALT_ATTRIBUTE(Y1, "0") + + // Spec: no attribute, effect is af value 100% is specified + if(KSVG_TOKEN_NOT_PARSED(X2)) + KSVG_SET_ALT_ATTRIBUTE(X2, "100%") + + // Spec: no attribute, effect is af value 0% is specified + if(KSVG_TOKEN_NOT_PARSED(Y2)) + KSVG_SET_ALT_ATTRIBUTE(Y2, "0") +} + +QMap<QString, DOM::DOMString> SVGLinearGradientElementImpl::gradientAttributes() +{ + setAttributes(); + + QMap<QString, DOM::DOMString> gradAttributes; + QDictIterator<DOM::DOMString> it(attributes()); + + for(; it.current(); ++it) + { + DOM::DOMString name = it.currentKey(); + DOM::DOMString value = it.current()->string(); + + if(name == "gradientUnits" || name == "gradientTransform" || name == "spreadMethod" || name == "x1" || name == "x2" || name == "y1" || name == "y2") + { + gradAttributes.insert(name.string(), value.copy()); + } + } + + return gradAttributes; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGLinearGradientElementImpl.h b/ksvg/impl/SVGLinearGradientElementImpl.h new file mode 100644 index 00000000..a230a0fe --- /dev/null +++ b/ksvg/impl/SVGLinearGradientElementImpl.h @@ -0,0 +1,74 @@ +/* + 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. +*/ + +#ifndef SVGLinearGradientElementImpl_H +#define SVGLinearGradientElementImpl_H + +#include "SVGGradientElementImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedLengthImpl; +class SVGLinearGradientElementImpl : public SVGGradientElementImpl +{ +public: + SVGLinearGradientElementImpl(DOM::ElementImpl *); + virtual ~SVGLinearGradientElementImpl(); + + SVGAnimatedLengthImpl *x1() const; + SVGAnimatedLengthImpl *y1() const; + SVGAnimatedLengthImpl *x2() const; + SVGAnimatedLengthImpl *y2() const; + + virtual void setAttributes(); + + virtual QMap<QString, DOM::DOMString> gradientAttributes(); + +private: + SVGAnimatedLengthImpl *m_x1; + SVGAnimatedLengthImpl *m_y1; + SVGAnimatedLengthImpl *m_x2; + SVGAnimatedLengthImpl *m_y2; + +public: + KSVG_GET + KSVG_PUT + KSVG_BRIDGE + + enum + { + // Properties + X1, X2, Y1, Y2, Href + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +KSVG_REGISTER_ELEMENT(SVGLinearGradientElementImpl, "linearGradient") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGList.h b/ksvg/impl/SVGList.h new file mode 100644 index 00000000..45eb81ba --- /dev/null +++ b/ksvg/impl/SVGList.h @@ -0,0 +1,174 @@ +/* + 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 + aint 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. +*/ + +#ifndef SVGList_H +#define SVGList_H + +#include "ksvg_bridge.h" +#include "ksvg_lookup.h" +#include "ksvg_scriptinterpreter.h" +#include <qptrlist.h> +#include <dom/dom_misc.h> + +namespace KSVG +{ + +class SVGListDefs +{ +public: + enum + { + // Properties + NumberOfItems, + // Functions + GetItem, RemoveItem, AppendItem, Initialize, + InsertItemBefore, ReplaceItem, Clear + }; +}; + +template<class T> +class SVGList : public DOM::DomShared +{ +public: + SVGList() { m_impl.setAutoDelete(false); } + SVGList(const SVGList &other) { *this = other; } + ~SVGList() { clear(); } + + SVGList<T> &operator=(const SVGList<T> &other) + { + // Clear own list + clear(); + + // Clone other's elements and append them + SVGList<T> &get = const_cast<SVGList<T> &>(other); + for(unsigned int i = 0; i < other.numberOfItems(); i++) + { + T *obj = new T(*get.getItem(i)); + obj->ref(); + + appendItem(obj); + } + + return *this; + } + + unsigned int numberOfItems() const { return m_impl.count(); } + + void clear() + { + for(unsigned int i = 0; i < numberOfItems(); i++) + getItem(i)->deref(); + + m_impl.clear(); + } + + T *initialize(T *newItem) + { + clear(); + return appendItem(newItem); + } + + T *getFirst() const { return m_impl.getFirst(); } + + T *getLast() const { return m_impl.getLast(); } + + T *getItem(unsigned int index) { return m_impl.at(index); } + const T *getItem(unsigned int index) const { return const_cast<SVGList<T> *>(this)->m_impl.at(index); } + + T *insertItemBefore(T *newItem, unsigned int index) + { + if (index < m_vector.size()) { + m_vector.insert(index, newItem); + } else { + m_vector.append(newItem); + } + return newItem; + } + + T *replaceItem(T *newItem, unsigned int index) + { + m_impl.take(index); + m_impl.insert(index, newItem); + return newItem; + } + + T *removeItem(unsigned int index) + { + return m_impl.take(index); + } + + void removeItem(const T *item) + { + m_impl.remove(item); + } + + T *appendItem(T *newItem) + { + m_impl.append(newItem); + return newItem; + } + + // Ecma stuff + KJS::Value getValueProperty(KJS::ExecState *, int token) const + { + switch(token) + { + case SVGListDefs::NumberOfItems: + return KJS::Number(numberOfItems()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return KJS::Undefined(); + } + } + + KJS::Value call(KJS::ExecState *exec, SVGList<T> *obj, const KJS::List &args, int id) + { + switch(id) + { + case SVGListDefs::GetItem: + return obj->getItem(static_cast<unsigned int>(args[0].toNumber(exec)))->cache(exec); + case SVGListDefs::RemoveItem: + return obj->removeItem(static_cast<unsigned int>(args[0].toNumber(exec)))->cache(exec); + case SVGListDefs::AppendItem: + return obj->appendItem(static_cast<KSVGBridge<T> *>(args[0].imp())->impl())->cache(exec); + case SVGListDefs::InsertItemBefore: + return obj->insertItemBefore(static_cast<KSVGBridge<T> *>(args[0].imp())->impl(), static_cast<unsigned int>(args[1].toNumber(exec)))->cache(exec); + case SVGListDefs::Initialize: + return obj->initialize(static_cast<KSVGBridge<T> *>(args[0].imp())->impl())->cache(exec); + case SVGListDefs::Clear: + { + obj->clear(); + return KJS::Undefined(); + } + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return KJS::Undefined(); + } + +private: + QPtrList<T> m_impl; +}; + +} + +#endif diff --git a/ksvg/impl/SVGLocatableImpl.cc b/ksvg/impl/SVGLocatableImpl.cc new file mode 100644 index 00000000..0ae143fa --- /dev/null +++ b/ksvg/impl/SVGLocatableImpl.cc @@ -0,0 +1,208 @@ +/* + 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> + +#include "SVGRectImpl.h" +#include "SVGShapeImpl.h" +#include "SVGContainerImpl.h" +#include "SVGMatrixImpl.h" +#include "SVGElementImpl.h" +#include "SVGLocatableImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGDocumentImpl.h" + +using namespace KSVG; + +#include "SVGLocatableImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +SVGLocatableImpl::SVGLocatableImpl() +{ + m_nearestViewportElement = 0; + m_farthestViewportElement = 0; + m_cachedScreenCTM = SVGSVGElementImpl::createSVGMatrix(); + m_cachedScreenCTMIsValid = false; +} + +SVGLocatableImpl::~SVGLocatableImpl() +{ + if(m_nearestViewportElement) + m_nearestViewportElement->deref(); + if(m_farthestViewportElement) + m_farthestViewportElement->deref(); + if(m_cachedScreenCTM) + m_cachedScreenCTM->deref(); +} + +SVGRectImpl *SVGLocatableImpl::getBBox() +{ + SVGRectImpl *ret = SVGSVGElementImpl::createSVGRect(); + return ret; +} + +SVGMatrixImpl *SVGLocatableImpl::getCTM() +{ + SVGMatrixImpl *ret = SVGSVGElementImpl::createSVGMatrix(); + return ret; +} + +SVGMatrixImpl *SVGLocatableImpl::getScreenCTM() +{ + SVGMatrixImpl *ret = SVGSVGElementImpl::createSVGMatrix(); + ret->copy(m_cachedScreenCTM); + + return ret; +} + +SVGMatrixImpl *SVGLocatableImpl::getTransformToElement(SVGElementImpl *) +{ + SVGMatrixImpl *ret = SVGSVGElementImpl::createSVGMatrix(); + return ret; +} + +void SVGLocatableImpl::updateCachedScreenCTM(const SVGMatrixImpl *parentScreenCTM) +{ + m_cachedScreenCTM->copy(parentScreenCTM); + + const SVGMatrixImpl *local = localMatrix(); + + if(local) + m_cachedScreenCTM->multiply(local); + m_cachedScreenCTMIsValid = true; + + // Notify the element + onScreenCTMUpdated(); + + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(this); + + if(shape) + { + // TODO: Update due to matrix animations + //if(shape->item()) + // shape->item()->update(updateReason); + + SVGElementImpl *element = dynamic_cast<SVGElementImpl *>(this); + + DOM::Node node = element->firstChild(); + for(; !node.isNull(); node = node.nextSibling()) + { + SVGElementImpl *child = element->ownerDoc()->getElementFromHandle(node.handle()); + SVGLocatableImpl *locatable = dynamic_cast<SVGLocatableImpl *>(child); + + if(child && locatable) + locatable->updateCachedScreenCTM(m_cachedScreenCTM); + } + } +} + +void SVGLocatableImpl::checkCachedScreenCTM(const SVGMatrixImpl *parentScreenCTM) +{ + if(m_cachedScreenCTMIsValid) + { + SVGElementImpl *element = dynamic_cast<SVGElementImpl *>(this); + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(this); + + if(shape) + { + DOM::Node node = element->firstChild(); + for(; !node.isNull(); node = node.nextSibling()) + { + SVGElementImpl *child = element->ownerDoc()->getElementFromHandle(node.handle()); + SVGLocatableImpl *locatable = dynamic_cast<SVGLocatableImpl *>(child); + + if(child && locatable) + locatable->checkCachedScreenCTM(m_cachedScreenCTM); + } + } + } + else + updateCachedScreenCTM(parentScreenCTM); +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGLocatableImpl::s_hashTable 3 + nearestViewportElement SVGLocatableImpl::NearestViewportElement DontDelete + farthestViewportElement SVGLocatableImpl::FarthestViewportElement DontDelete +@end +@namespace KSVG +@begin SVGLocatableImplProto::s_hashTable 5 + getBBox SVGLocatableImpl::GetBBox DontDelete|Function 0 + getCTM SVGLocatableImpl::GetCTM DontDelete|Function 0 + getScreenCTM SVGLocatableImpl::GetScreenCTM DontDelete|Function 0 + getTransformToElement SVGLocatableImpl::GetTransformToElement DontDelete|Function 1 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGLocatable", SVGLocatableImplProto, SVGLocatableImplProtoFunc) + +Value SVGLocatableImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case NearestViewportElement: + return nearestViewportElement() ? nearestViewportElement()->cache(exec) : Undefined(); + case FarthestViewportElement: + return farthestViewportElement() ? farthestViewportElement()->cache(exec) : Undefined(); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +Value SVGLocatableImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGLocatableImpl) + + switch(id) + { + case SVGLocatableImpl::GetBBox: + { + SVGContainerImpl *container = dynamic_cast<SVGContainerImpl *>(obj); + if(container) + return container->getBBox()->cache(exec); + else + { + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(obj); + if(shape) + return shape->getBBox()->cache(exec); + else + return obj->getBBox()->cache(exec); + } + } + case SVGLocatableImpl::GetCTM: + return obj->getCTM()->cache(exec); + case SVGLocatableImpl::GetScreenCTM: + return obj->getScreenCTM()->cache(exec); + case SVGLocatableImpl::GetTransformToElement: + return obj->getTransformToElement(static_cast<KSVGBridge<SVGElementImpl> *>(args[0].imp())->impl())->cache(exec); + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return Undefined(); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGLocatableImpl.h b/ksvg/impl/SVGLocatableImpl.h new file mode 100644 index 00000000..81ce3326 --- /dev/null +++ b/ksvg/impl/SVGLocatableImpl.h @@ -0,0 +1,94 @@ +/* + 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. +*/ + +#ifndef SVGLocatableImpl_H +#define SVGLocatableImpl_H + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGRectImpl; +class SVGMatrixImpl; +class SVGElementImpl; +class SVGLocatableImpl +{ +public: + SVGLocatableImpl(); + virtual ~SVGLocatableImpl(); + + SVGElementImpl *nearestViewportElement() const { return m_nearestViewportElement; } + SVGElementImpl *farthestViewportElement() const{ return m_farthestViewportElement; } + + virtual SVGRectImpl *getBBox(); + virtual SVGMatrixImpl *getCTM(); + virtual SVGMatrixImpl *getScreenCTM(); + + // Faster access for when a new copy isn't required. + const SVGMatrixImpl *screenCTM() const { return m_cachedScreenCTM; } + + SVGMatrixImpl *getTransformToElement(SVGElementImpl *element); + + // The local transformations concatenated together. 0 if + // there are no local transformations. + virtual const SVGMatrixImpl *localMatrix() { return 0; } + + bool cachedScreenCTMIsValid() const { return m_cachedScreenCTMIsValid; } + void invalidateCachedMatrices() { m_cachedScreenCTMIsValid = false; } + + // If the cached matrix is invalid, update it and update any child elements + // recursively. Otherwise, check child elements recursively. + virtual void checkCachedScreenCTM(const SVGMatrixImpl *parentScreenCTM); + // Update the cached matrix, and update child element cached matrices, + // recursively. + virtual void updateCachedScreenCTM(const SVGMatrixImpl *parentScreenCTM); + + // Called immediately after the screen ctm has been updated. + virtual void onScreenCTMUpdated() {} + +protected: + SVGElementImpl *m_nearestViewportElement; + SVGElementImpl *m_farthestViewportElement; + SVGMatrixImpl *m_cachedScreenCTM; + bool m_cachedScreenCTMIsValid; + +public: + KSVG_BASECLASS_GET + + enum + { + // Properties + NearestViewportElement, FarthestViewportElement, + // Functions + GetBBox, GetCTM, GetScreenCTM, GetTransformToElement + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; +}; + +} + +KSVG_DEFINE_PROTOTYPE(SVGLocatableImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGLocatableImplProtoFunc, SVGLocatableImpl) + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGMPathElementImpl.cc b/ksvg/impl/SVGMPathElementImpl.cc new file mode 100644 index 00000000..84d48274 --- /dev/null +++ b/ksvg/impl/SVGMPathElementImpl.cc @@ -0,0 +1,33 @@ +/* + 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 "SVGMPathElementImpl.h" + +using namespace KSVG; + +SVGMPathElementImpl::SVGMPathElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGURIReferenceImpl(), SVGExternalResourcesRequiredImpl() +{ +} + +SVGMPathElementImpl::~SVGMPathElementImpl() +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGMPathElementImpl.h b/ksvg/impl/SVGMPathElementImpl.h new file mode 100644 index 00000000..8d0bd96b --- /dev/null +++ b/ksvg/impl/SVGMPathElementImpl.h @@ -0,0 +1,50 @@ +/* + 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. +*/ + +#ifndef SVGMPathElementImpl_H +#define SVGMPathElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGElementImpl.h" +#include "SVGURIReferenceImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + +namespace KSVG +{ + +class SVGMPathElementImpl : public SVGElementImpl, + public SVGURIReferenceImpl, + public SVGExternalResourcesRequiredImpl +{ +public: + SVGMPathElementImpl(DOM::ElementImpl *); + virtual ~SVGMPathElementImpl(); + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGMarkerElementImpl.cc b/ksvg/impl/SVGMarkerElementImpl.cc new file mode 100644 index 00000000..0fc1d263 --- /dev/null +++ b/ksvg/impl/SVGMarkerElementImpl.cc @@ -0,0 +1,424 @@ +/* + 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> + +#include "SVGMarkerElement.h" + +#include "SVGRectImpl.h" +#include "SVGAngleImpl.h" +#include "SVGMatrixImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGTransformImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGAnimatedRectImpl.h" +#include "SVGMarkerElementImpl.h" +#include "SVGAnimatedAngleImpl.h" +#include "SVGAnimatedLengthImpl.h" +#include "SVGAnimatedEnumerationImpl.h" +#include "SVGPreserveAspectRatioImpl.h" +#include "SVGAnimatedPreserveAspectRatioImpl.h" + +#include "KSVGCanvas.h" + +using namespace KSVG; + +#include "SVGMarkerElementImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" +#include "ksvg_cacheimpl.h" + +SVGMarkerElementImpl::SVGMarkerElementImpl(DOM::ElementImpl *impl) : SVGContainerImpl(impl), SVGLangSpaceImpl(), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this), SVGFitToViewBoxImpl() +{ + KSVG_EMPTY_FLAGS + + m_refX = new SVGAnimatedLengthImpl(); + m_refX->ref(); + + m_refY = new SVGAnimatedLengthImpl(); + m_refY->ref(); + + m_markerUnits = new SVGAnimatedEnumerationImpl(); + m_markerUnits->ref(); + + m_markerWidth = new SVGAnimatedLengthImpl(); + m_markerWidth->ref(); + + m_markerHeight = new SVGAnimatedLengthImpl(); + m_markerHeight->ref(); + + m_orientType = new SVGAnimatedEnumerationImpl(); + m_orientType->ref(); + + m_orientAngle = new SVGAnimatedAngleImpl(); + m_orientAngle->ref(); +} + +SVGMarkerElementImpl::~SVGMarkerElementImpl() +{ + if(m_refX) + m_refX->deref(); + if(m_refY) + m_refY->deref(); + if(m_markerUnits) + m_markerUnits->deref(); + if(m_markerWidth) + m_markerWidth->deref(); + if(m_markerHeight) + m_markerHeight->deref(); + if(m_orientType) + m_orientType->deref(); + if(m_orientAngle) + m_orientAngle->deref(); +} + +SVGAnimatedLengthImpl *SVGMarkerElementImpl::refX() const +{ + return m_refX; +} + +SVGAnimatedLengthImpl *SVGMarkerElementImpl::refY() const +{ + return m_refY; +} + +SVGAnimatedEnumerationImpl *SVGMarkerElementImpl::markerUnits() const +{ + return m_markerUnits; +} + +SVGAnimatedLengthImpl *SVGMarkerElementImpl::markerWidth() const +{ + return m_markerWidth; +} + +SVGAnimatedLengthImpl *SVGMarkerElementImpl::markerHeight() const +{ + return m_markerHeight; +} + +SVGAnimatedEnumerationImpl *SVGMarkerElementImpl::orientType() const +{ + return m_orientType; +} + +SVGAnimatedAngleImpl *SVGMarkerElementImpl::orientAngle() const +{ + return m_orientAngle; +} + +void SVGMarkerElementImpl::setOrientToAuto() +{ + orientType()->setBaseVal(SVG_MARKER_ORIENT_AUTO); +} + +void SVGMarkerElementImpl::setOrientToAngle(SVGAngleImpl *angle) +{ + m_orientAngle->baseVal()->setValue(angle->value()); +} + +void SVGMarkerElementImpl::setAttributes() +{ + SVGElementImpl::setAttributes(); + + // Spec: if not specified, effect is as if a value of "0" were specified + if(KSVG_TOKEN_NOT_PARSED(RefX)) + KSVG_SET_ALT_ATTRIBUTE(RefX, "0") + + // Spec: if not specified, effect is as if a value of "0" were specified + if(KSVG_TOKEN_NOT_PARSED(RefY)) + KSVG_SET_ALT_ATTRIBUTE(RefY, "0") + + // Spec: if not specified, effect is as if a value of "3" were specified + if(KSVG_TOKEN_NOT_PARSED(MarkerWidth)) + KSVG_SET_ALT_ATTRIBUTE(MarkerWidth, "3") + + // Spec: if not specified, effect is as if a value of "3" were specified + if(KSVG_TOKEN_NOT_PARSED(MarkerHeight)) + KSVG_SET_ALT_ATTRIBUTE(MarkerHeight, "3") + + // Spec: if attribute not specified, use strokeWidth + if(KSVG_TOKEN_NOT_PARSED(MarkerUnits)) + KSVG_SET_ALT_ATTRIBUTE(MarkerUnits, "strokeWidth") + + // Spec: if attribute not specified, use angle + if(KSVG_TOKEN_NOT_PARSED(Orient)) + KSVG_SET_ALT_ATTRIBUTE(Orient, "angle") +} + +void SVGMarkerElementImpl::createItem(KSVGCanvas *c) +{ + if(!c) + c = ownerDoc()->canvas(); + + if(!m_item) + { + m_item = c->createCanvasMarker(this); + c->insert(m_item); + } +} + +void SVGMarkerElementImpl::draw(SVGShapeImpl *referencingElement, double x, double y, double lwidth, double angle) +{ + SVGMatrixImpl *mtx = dynamic_cast<SVGLocatableImpl *>(referencingElement)->getScreenCTM(); + + // move to dest + mtx->translate(x, y); + + // scale by linewidth if marker units == strokewidth + if(markerUnits()->baseVal() == SVG_MARKERUNITS_STROKEWIDTH) + mtx->scale(lwidth); + + // select appropriate rotation + if(orientType()->baseVal() == SVG_MARKER_ORIENT_AUTO) + mtx->rotate(angle); + else + mtx->rotate(orientAngle()->baseVal()->value()); + + SVGRectImpl *viewBoxRect = viewBox()->baseVal(); + SVGMatrixImpl *pres = preserveAspectRatio()->baseVal()->getCTM(viewBoxRect->x(), viewBoxRect->y(), + viewBoxRect->width(), viewBoxRect->height(), + 0, 0, markerWidth()->baseVal()->value(), + markerHeight()->baseVal()->value()); + + // viewbox stuff + mtx->multiply(pres); + + // Get the vertex position in viewbox coordinates. The vertex is at (0, 0) in viewport coordinates. + double vertexX, vertexY; + pres->qmatrix().invert().map(0, 0, &vertexX, &vertexY); + + // Translate so that the vertex is at (refX, refY) in viewbox coordinates. + mtx->translate(vertexX - refX()->baseVal()->value(), vertexY - refY()->baseVal()->value()); + + if(getOverflow()) + m_clipShape.clear(); + else + { + KSVGRectangle viewport; + + if(hasAttribute("viewBox")) + { + // Get the viewport ((0, 0) - (markerWidth, markerHeight)) in viewbox coordinates. + double w, h; + pres->qmatrix().invert().map(markerWidth()->baseVal()->value(), markerHeight()->baseVal()->value(), &w, &h); + + viewport = KSVGRectangle(vertexX, vertexY, w - vertexX, h - vertexY); + } + else + viewport = KSVGRectangle(0, 0, markerWidth()->baseVal()->value(), markerHeight()->baseVal()->value()); + + // Transform to screen coordinates. + m_clipShape = mtx->map(viewport); + } + + pres->deref(); + + DOM::Node node = firstChild(); + for(; !node.isNull(); node = node.nextSibling()) + { + SVGElementImpl *element = ownerDoc()->getElementFromHandle(node.handle()); + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(element); + SVGTestsImpl *tests = dynamic_cast<SVGTestsImpl *>(element); + SVGStylableImpl *style = dynamic_cast<SVGStylableImpl *>(element); + + bool ok = tests ? tests->ok() : true; + if(element && shape && style && ok && style->getVisible() && style->getDisplay()) + { + SVGLocatableImpl *locatable = dynamic_cast<SVGLocatableImpl *>(element); + if(locatable) + locatable->updateCachedScreenCTM(mtx); + + shape->update(UPDATE_TRANSFORM); + shape->setReferenced(true); + shape->draw(); + shape->setReferenced(false); + } + } + + mtx->deref(); +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGMarkerElementImpl::s_hashTable 11 + refX SVGMarkerElementImpl::RefX DontDelete|ReadOnly + refY SVGMarkerElementImpl::RefY DontDelete|ReadOnly + markerUnits SVGMarkerElementImpl::MarkerUnits DontDelete|ReadOnly + markerWidth SVGMarkerElementImpl::MarkerWidth DontDelete|ReadOnly + markerHeight SVGMarkerElementImpl::MarkerHeight DontDelete|ReadOnly + orientType SVGMarkerElementImpl::OrientType DontDelete|ReadOnly + orientAngle SVGMarkerElementImpl::OrientAngle DontDelete|ReadOnly + orient SVGMarkerElementImpl::Orient DontDelete|ReadOnly +@end +@namespace KSVG +@begin SVGMarkerElementImplProto::s_hashTable 3 + setOrientToAuto SVGMarkerElementImpl::SetOrientToAuto DontDelete|Function 0 + setOrientToAngle SVGMarkerElementImpl::SetOrientToAngle DontDelete|Function 0 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGMarkerElement", SVGMarkerElementImplProto, SVGMarkerElementImplProtoFunc) + +Value SVGMarkerElementImpl::getValueProperty(ExecState *exec, int token) const +{ + KSVG_CHECK_ATTRIBUTE + + switch(token) + { + case RefX: + if(!attributeMode) + return m_refX->cache(exec); + else + return Number(m_refX->baseVal()->value()); + case RefY: + if(!attributeMode) + return m_refY->cache(exec); + else + return Number(m_refY->baseVal()->value()); + case MarkerUnits: + if(!attributeMode) + return m_markerUnits->cache(exec); + else + return Number(m_markerUnits->baseVal()); + case MarkerWidth: + if(!attributeMode) + return m_markerWidth->cache(exec); + else + return Number(m_markerWidth->baseVal()->value()); + case MarkerHeight: + if(!attributeMode) + return m_markerHeight->cache(exec); + else + return Number(m_markerHeight->baseVal()->value()); + case OrientType: + if(!attributeMode) + return m_orientType->cache(exec); + else + return Number(m_orientType->baseVal()); + case OrientAngle: + if(!attributeMode) + return m_orientAngle->cache(exec); + else + return Number(m_orientAngle->baseVal()->value()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGMarkerElementImpl::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; + + switch(token) + { + case RefX: + refX()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + case RefY: + refY()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + case MarkerWidth: + markerWidth()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + case MarkerHeight: + markerHeight()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + case MarkerUnits: + if(value.toString(exec).qstring() == "userSpaceOnUse") + markerUnits()->setBaseVal(SVG_MARKERUNITS_USERSPACEONUSE); + else + markerUnits()->setBaseVal(SVG_MARKERUNITS_STROKEWIDTH); + break; + case Orient: + { + QString param = value.toString(exec).qstring(); + + if(param == "auto") + orientType()->setBaseVal(SVG_MARKER_ORIENT_AUTO); + else + { + orientType()->setBaseVal(SVG_MARKER_ORIENT_ANGLE); + m_orientAngle->baseVal()->setValueAsString(param); + } + break; + } + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +Value SVGMarkerElementImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGMarkerElementImpl) + + switch(id) + { + case SVGMarkerElementImpl::SetOrientToAuto: + obj->setOrientToAuto(); + return Undefined(); +#ifdef __GNUC__ +#warning FIXME cache stuff +#endif + case SVGMarkerElementImpl::SetOrientToAngle: + obj->setOrientToAngle(static_cast<KSVGBridge<SVGAngleImpl> *>(args[0].imp())->impl()); + return Undefined(); + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return Undefined(); +} + +// CONSTANTS + +/* +@namespace KSVG +@begin SVGMarkerElementImplConstructor::s_hashTable 7 + SVG_MARKERUNITS_UNKNOWN KSVG::SVG_MARKERUNITS_UNKNOWN DontDelete|ReadOnly + SVG_MARKERUNITS_USERSPACEONUSE KSVG::SVG_MARKERUNITS_USERSPACEONUSE DontDelete|ReadOnly + SVG_MARKERUNITS_STROKEWIDTH KSVG::SVG_MARKERUNITS_STROKEWIDTH DontDelete|ReadOnly + SVG_MARKER_ORIENT_UNKNOWN KSVG::SVG_MARKER_ORIENT_UNKNOWN DontDelete|ReadOnly + SVG_MARKER_ORIENT_AUTO KSVG::SVG_MARKER_ORIENT_AUTO DontDelete|ReadOnly + SVG_MARKER_ORIENT_ANGLE KSVG::SVG_MARKER_ORIENT_ANGLE DontDelete|ReadOnly +@end +*/ + +using namespace KJS; + +Value SVGMarkerElementImplConstructor::getValueProperty(ExecState *, int token) const +{ + return Number(token); +} + +Value KSVG::getSVGMarkerElementImplConstructor(ExecState *exec) +{ + return cacheGlobalBridge<SVGMarkerElementImplConstructor>(exec, "[[svgmarkerelement.constructor]]"); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGMarkerElementImpl.h b/ksvg/impl/SVGMarkerElementImpl.h new file mode 100644 index 00000000..7e6539e3 --- /dev/null +++ b/ksvg/impl/SVGMarkerElementImpl.h @@ -0,0 +1,121 @@ +/* + 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. +*/ + +#ifndef SVGMarkerElementImpl_H +#define SVGMarkerElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGStylableImpl.h" +#include "SVGLangSpaceImpl.h" +#include "SVGContainerImpl.h" +#include "SVGFitToViewBoxImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" +#include "KSVGHelper.h" + +namespace KSVG +{ + +class SVGAngleImpl; +class SVGAnimatedAngleImpl; +class SVGAnimatedLengthImpl; +class SVGAnimatedEnumerationImpl; +class SVGMarkerElementImpl : public SVGContainerImpl, + public SVGLangSpaceImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl, + public SVGFitToViewBoxImpl +{ +public: + SVGMarkerElementImpl(DOM::ElementImpl *); + virtual ~SVGMarkerElementImpl(); + + SVGAnimatedLengthImpl *refX() const; + SVGAnimatedLengthImpl *refY() const; + SVGAnimatedEnumerationImpl *markerUnits() const; + SVGAnimatedLengthImpl *markerWidth() const; + SVGAnimatedLengthImpl *markerHeight() const; + SVGAnimatedEnumerationImpl *orientType() const; + SVGAnimatedAngleImpl *orientAngle() const; + + void setOrientToAuto(); + void setOrientToAngle(SVGAngleImpl *angle); + + virtual void setAttributes(); + virtual void createItem(KSVGCanvas *c = 0); + + void draw(SVGShapeImpl *referencingElement, double x, double y, double lwidth, double angle); + + KSVGPolygon clipShape() const { return m_clipShape; } + + virtual bool directRender() { return false; } + virtual bool isContainer() const { return false; } + +private: + SVGAnimatedLengthImpl *m_refX; + SVGAnimatedLengthImpl *m_refY; + SVGAnimatedEnumerationImpl *m_markerUnits; + SVGAnimatedLengthImpl *m_markerWidth; + SVGAnimatedLengthImpl *m_markerHeight; + SVGAnimatedEnumerationImpl *m_orientType; + SVGAnimatedAngleImpl *m_orientAngle; + + KSVGPolygon m_clipShape; + +public: + KSVG_GET + KSVG_PUT + KSVG_BRIDGE + + enum + { + // Properties + RefX, RefY, MarkerUnits, MarkerWidth, MarkerHeight, OrientType, OrientAngle, + Orient, ViewBox, PreserveAspectRatio, + // Functions + SetOrientToAuto, SetOrientToAngle + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +class SVGMarkerElementImplConstructor : public KJS::ObjectImp +{ +public: + SVGMarkerElementImplConstructor(KJS::ExecState *) { } + KJS::Value getValueProperty(KJS::ExecState *, int token) const; + + // no put - all read-only + KSVG_GET +}; + +KJS::Value getSVGMarkerElementImplConstructor(KJS::ExecState *exec); + +KSVG_REGISTER_ELEMENT(SVGMarkerElementImpl, "marker") + +} + +KSVG_DEFINE_PROTOTYPE(SVGMarkerElementImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGMarkerElementImplProtoFunc, SVGMarkerElementImpl) + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGMaskElementImpl.cc b/ksvg/impl/SVGMaskElementImpl.cc new file mode 100644 index 00000000..5cd2151e --- /dev/null +++ b/ksvg/impl/SVGMaskElementImpl.cc @@ -0,0 +1,542 @@ +/* + 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 <cfloat> + +#include <kdebug.h> +#include <qimage.h> + +#include "SVGMaskElement.h" + +#include "SVGRectImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGMaskElementImpl.h" +#include "SVGAnimatedLengthImpl.h" +#include "SVGAnimatedEnumerationImpl.h" +#include "SVGUnitConverter.h" +#include "SVGShapeImpl.h" +#include "SVGMatrixImpl.h" +#include "KSVGCanvas.h" +#include "CanvasItems.h" +#include "CanvasFactory.h" +#include "KSVGHelper.h" + +#include <X11/Xos.h> + +using namespace KSVG; + +#include "SVGMaskElementImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_ecma.h" + +SVGMaskElementImpl::SVGMaskElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGTestsImpl(), SVGLangSpaceImpl(), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this), SVGBBoxTarget() +{ + KSVG_EMPTY_FLAGS + + m_x = new SVGAnimatedLengthImpl(LENGTHMODE_WIDTH, this); + m_x->ref(); + + m_y = new SVGAnimatedLengthImpl(LENGTHMODE_HEIGHT, this); + m_y->ref(); + + m_width = new SVGAnimatedLengthImpl(LENGTHMODE_WIDTH, this); + m_width->ref(); + + m_height = new SVGAnimatedLengthImpl(LENGTHMODE_HEIGHT, this); + m_height->ref(); + + m_maskUnits = new SVGAnimatedEnumerationImpl(); + m_maskUnits->ref(); + + m_maskContentUnits = new SVGAnimatedEnumerationImpl(); + m_maskContentUnits->ref(); + + m_converter = new SVGUnitConverter(); + m_converter->add(m_x); + m_converter->add(m_y); + m_converter->add(m_width); + m_converter->add(m_height); + + m_canvas = 0; + + m_maskCache.setMaxTotalCost(1024 * 1024); +} + +SVGMaskElementImpl::~SVGMaskElementImpl() +{ + if(m_x) + m_x->deref(); + if(m_y) + m_y->deref(); + if(m_width) + m_width->deref(); + if(m_height) + m_height->deref(); + if(m_maskUnits) + m_maskContentUnits->deref(); + if(m_maskUnits) + m_maskContentUnits->deref(); + delete m_converter; + if(m_canvas) + delete m_canvas; +} + +SVGAnimatedEnumerationImpl *SVGMaskElementImpl::maskUnits() const +{ + return m_maskUnits; +} + +SVGAnimatedEnumerationImpl *SVGMaskElementImpl::maskContentUnits() const +{ + return m_maskContentUnits; +} + +SVGAnimatedLengthImpl *SVGMaskElementImpl::x() const +{ + return m_x; +} + +SVGAnimatedLengthImpl *SVGMaskElementImpl::y() const +{ + return m_y; +} + +SVGAnimatedLengthImpl *SVGMaskElementImpl::width() const +{ + return m_width; +} + +SVGAnimatedLengthImpl *SVGMaskElementImpl::height() const +{ + return m_height; +} + +/* +@namespace KSVG +@begin SVGMaskElementImpl::s_hashTable 7 + maskUnits SVGMaskElementImpl::MaskUnits DontDelete|ReadOnly + maskContentUnits SVGMaskElementImpl::MaskContentUnits DontDelete|ReadOnly + x SVGMaskElementImpl::X DontDelete|ReadOnly + y SVGMaskElementImpl::Y DontDelete|ReadOnly + width SVGMaskElementImpl::Width DontDelete|ReadOnly + height SVGMaskElementImpl::Height DontDelete|ReadOnly +@end +*/ +Value SVGMaskElementImpl::getValueProperty(ExecState *exec, int token) const +{ + KSVG_CHECK_ATTRIBUTE + + switch(token) + { + case MaskUnits: + if(!attributeMode) + return m_maskUnits->cache(exec); + else + return Number(m_maskUnits->baseVal()); + case MaskContentUnits: + if(!attributeMode) + return m_maskContentUnits->cache(exec); + else + return Number(m_maskContentUnits->baseVal()); + case X: + if(!attributeMode) + return m_x->cache(exec); + else + return Number(m_x->baseVal()->value()); + case Y: + if(!attributeMode) + return m_y->cache(exec); + else + return Number(m_y->baseVal()->value()); + case Width: + if(!attributeMode) + return m_width->cache(exec); + else + return Number(m_width->baseVal()->value()); + + case Height: + if(!attributeMode) + return m_height->cache(exec); + else + return Number(m_height->baseVal()->value()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGMaskElementImpl::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; + + switch(token) + { + case MaskUnits: + if(value.toString(exec).qstring() == "objectBoundingBox") + m_maskUnits->setBaseVal(SVGMaskElement::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX); + else + m_maskUnits->setBaseVal(SVGMaskElement::SVG_UNIT_TYPE_USERSPACEONUSE); + break; + case MaskContentUnits: + if(value.toString(exec).qstring() == "objectBoundingBox") + m_maskContentUnits->setBaseVal(SVGMaskElement::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX); + else + m_maskContentUnits->setBaseVal(SVGMaskElement::SVG_UNIT_TYPE_USERSPACEONUSE); + break; + case X: + converter()->modify(x(), value.toString(exec).qstring()); + break; + case Y: + converter()->modify(y(), value.toString(exec).qstring()); + break; + case Width: + converter()->modify(width(), value.toString(exec).qstring()); + break; + case Height: + converter()->modify(height(), value.toString(exec).qstring()); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +SVGRectImpl *SVGMaskElementImpl::getBBox() +{ + SVGRectImpl *ret = SVGSVGElementImpl::createSVGRect(); + ret->setX(m_x->baseVal()->value()); + ret->setY(m_y->baseVal()->value()); + ret->setWidth(m_width->baseVal()->value()); + ret->setHeight(m_height->baseVal()->value()); + return ret; +} + +void SVGMaskElementImpl::setAttributes() +{ + SVGElementImpl::setAttributes(); + + // Spec: if attribute not specified, use objectBoundingBox + if(KSVG_TOKEN_NOT_PARSED(MaskUnits)) + KSVG_SET_ALT_ATTRIBUTE(MaskUnits, "objectBoundingBox") + + // Spec: if attribute not specified, use userSpaceOnUse + if(KSVG_TOKEN_NOT_PARSED(MaskContentUnits)) + KSVG_SET_ALT_ATTRIBUTE(MaskContentUnits, "userSpaceOnUse") + + // Spec: if attribute not specified, use "-10%" + if(KSVG_TOKEN_NOT_PARSED(X)) + KSVG_SET_ALT_ATTRIBUTE(X, "-10%"); + + // Spec: if attribute not specified, use "-10%" + if(KSVG_TOKEN_NOT_PARSED(Y)) + KSVG_SET_ALT_ATTRIBUTE(Y, "-10%"); + + // Spec: if attribute not specified, use "120%" + if(KSVG_TOKEN_NOT_PARSED(Width)) + KSVG_SET_ALT_ATTRIBUTE(Width, "120%"); + + // Spec: if attribute not specified, use "120%" + if(KSVG_TOKEN_NOT_PARSED(Height)) + KSVG_SET_ALT_ATTRIBUTE(Height, "120%"); +} + +SVGMaskElementImpl::Mask SVGMaskElementImpl::createMask(SVGShapeImpl *referencingElement, int imageWidth, int imageHeight) +{ + converter()->finalize(referencingElement, ownerSVGElement(), maskUnits()->baseVal()); + + Q_UINT32 *imageBits = new Q_UINT32[imageWidth * imageHeight]; + + if(m_canvas == 0) + m_canvas = CanvasFactory::self()->loadCanvas(imageWidth, imageHeight); + + m_canvas->setup(reinterpret_cast<unsigned char *>(imageBits), imageWidth, imageHeight); + m_canvas->setBackgroundColor(qRgba(0, 0, 0, 0)); + + SVGMatrixImpl *baseMatrix = SVGSVGElementImpl::createSVGMatrix(); + + // Set the scale to map the mask onto the image + double xScale = static_cast<double>(imageWidth) / width()->baseVal()->value(); + double yScale = static_cast<double>(imageHeight) / height()->baseVal()->value(); + + baseMatrix->scaleNonUniform(xScale, yScale); + + SVGRectImpl *bbox = referencingElement->getBBox(); + + if(maskUnits()->baseVal() == SVGMaskElement::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) + baseMatrix->translate(-(bbox->x() + x()->baseVal()->value()), -(bbox->y() + y()->baseVal()->value())); + else + baseMatrix->translate(-x()->baseVal()->value(), -y()->baseVal()->value()); + + if(maskContentUnits()->baseVal() == SVGMaskElement::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) + { + baseMatrix->translate(bbox->x(), bbox->y()); + baseMatrix->scaleNonUniform(bbox->width(), bbox->height()); + } + + for(DOM::Node node = firstChild(); !node.isNull(); node = node.nextSibling()) + { + SVGElementImpl *element = ownerDoc()->getElementFromHandle(node.handle()); + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(element); + SVGTestsImpl *tests = dynamic_cast<SVGTestsImpl *>(element); + SVGStylableImpl *style = dynamic_cast<SVGStylableImpl *>(element); + + bool ok = tests ? tests->ok() : true; + if(element && shape && style && ok && style->getVisible() && style->getDisplay()) + { + SVGLocatableImpl *locatable = dynamic_cast<SVGLocatableImpl *>(element); + if(locatable) + locatable->updateCachedScreenCTM(baseMatrix); + + element->createItem(m_canvas); + if(shape->item()) + { + shape->item()->setReferenced(true); + m_canvas->invalidate(shape->item(), true); + } + } + } + + m_canvas->update(float(1)); + + for(DOM::Node node = firstChild(); !node.isNull(); node = node.nextSibling()) + { + SVGElementImpl *element = ownerDoc()->getElementFromHandle(node.handle()); + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(element); + SVGTestsImpl *tests = dynamic_cast<SVGTestsImpl *>(element); + SVGStylableImpl *style = dynamic_cast<SVGStylableImpl *>(element); + + bool ok = tests ? tests->ok() : true; + if(element && shape && style && ok && style->getVisible() && style->getDisplay()) + { + if(shape) + shape->removeItem(m_canvas); + } + } + + + { + // Note: r and b reversed + //QImage maskImage(reinterpret_cast<unsigned char *>(imageBits), imageWidth, imageHeight, 32, 0, 0, QImage::IgnoreEndian); + //maskImage.setAlphaBuffer(true); + //maskImage.save("mask.png", "PNG"); + } + + QByteArray maskData(imageWidth * imageHeight); + const double epsilon = DBL_EPSILON; + + // Convert the rgba image into an 8-bit mask, according to the specs. + for(int i = 0; i < imageWidth * imageHeight; i++) + { + Q_UINT32 rgba = imageBits[i]; + +#if X_BYTE_ORDER == X_LITTLE_ENDIAN + double r = (rgba & 0xff) / 255.0; + double g = ((rgba >> 8) & 0xff) / 255.0; + double b = ((rgba >> 16) & 0xff) / 255.0; + double a = ((rgba >> 24) & 0xff) / 255.0; +#else + double a = (rgba & 0xff) / 255.0; + double b = ((rgba >> 8) & 0xff) / 255.0; + double g = ((rgba >> 16) & 0xff) / 255.0; + double r = ((rgba >> 24) & 0xff) / 255.0; +#endif + + // Remove pre-multiplication by alpha. + if(a > epsilon) + { + r /= a; + g /= a; + b /= a; + } + + // Convert to linear RGB + r = KSVGHelper::linearRGBFromsRGB(int(r * 255 + 0.5)) / 255.0; + g = KSVGHelper::linearRGBFromsRGB(int(g * 255 + 0.5)) / 255.0; + b = KSVGHelper::linearRGBFromsRGB(int(b * 255 + 0.5)) / 255.0; + + // Convert 'luminance to alpha' + double luminanceAlpha = 0.2125 * r + 0.7154 * g + 0.0721 * b; + + // Multiply by alpha. + double maskValue = luminanceAlpha * a; + + maskData[i] = static_cast<unsigned char>(maskValue * 255 + 0.5); + } + + delete [] imageBits; + + baseMatrix->deref(); + bbox->deref(); + + // The screenToMask matrix is calculated each time the mask is used so we don't + // need to set it here. + QWMatrix tempMatrix; + + return Mask(maskData, tempMatrix, imageWidth, imageHeight); +} + +SVGMaskElementImpl::Mask SVGMaskElementImpl::createMask(SVGShapeImpl *referencingElement) +{ + converter()->finalize(referencingElement, ownerSVGElement(), maskUnits()->baseVal()); + + SVGMatrixImpl *refCTM = 0; + SVGLocatableImpl *locatableRef = dynamic_cast<SVGLocatableImpl *>(referencingElement); + if(locatableRef) + refCTM = locatableRef->getScreenCTM(); + else + refCTM = SVGSVGElementImpl::createSVGMatrix(); + + double xScale, yScale; + + refCTM->removeScale(&xScale, &yScale); + refCTM->deref(); + + int imageWidth = static_cast<int>(width()->baseVal()->value() * xScale + 0.5); + int imageHeight = static_cast<int>(height()->baseVal()->value() * yScale + 0.5); + + Mask mask; + + if(imageWidth > 0 && imageHeight > 0) + { + CacheKey key(referencingElement, imageWidth, imageHeight); + + if(!m_maskCache.find(key, mask)) + { + mask = createMask(referencingElement, imageWidth, imageHeight); + m_maskCache.insert(key, mask, imageWidth * imageHeight); + } + + // Generate a mask-coordinates to screen-coordinates matrix + SVGMatrixImpl *matrix = 0; + if(locatableRef) + matrix = locatableRef->getScreenCTM(); + else + matrix = SVGSVGElementImpl::createSVGMatrix(); + + if(maskUnits()->baseVal() == SVGMaskElement::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) + { + SVGRectImpl *bbox = referencingElement->getBBox(); + matrix->translate(bbox->x() + x()->baseVal()->value(), bbox->y() + y()->baseVal()->value()); + bbox->deref(); + } + else + matrix->translate(x()->baseVal()->value(), y()->baseVal()->value()); + + matrix->scaleNonUniform(1 / xScale, 1 / yScale); + + QWMatrix screenToMask = matrix->qmatrix().invert(); + matrix->deref(); + + mask.setScreenToMask(screenToMask); + } + + return mask; +} + +QByteArray SVGMaskElementImpl::maskRectangle(SVGShapeImpl *shape, const QRect& screenRectangle) +{ + QByteArray cumulativeMask; + + do + { + SVGStylableImpl *style = dynamic_cast<SVGStylableImpl *>(shape); + + if(style && style->hasMask()) + { + SVGElementImpl *element = shape->ownerDoc()->rootElement()->getElementById(style->getMask()); + + if(element) + { + SVGMaskElementImpl *maskElement = dynamic_cast<SVGMaskElementImpl *>(element); + + if(maskElement) + { + SVGMaskElementImpl::Mask mask = maskElement->createMask(shape); + + if(!mask.isEmpty()) + { + QByteArray maskData = mask.rectangle(screenRectangle); + + if(cumulativeMask.size() == 0) + cumulativeMask = maskData; + else + { + int size = cumulativeMask.size(); + + // Multiply into the cumulative mask (using fast divide by 255) + for(int i = 0; i < size; i++) + { + int tmp = maskData[i] * cumulativeMask[i] + 0x80; + cumulativeMask[i] = (tmp + (tmp >> 8)) >> 8; + } + } + } + } + } + } + + DOM::Node parentNode = shape->parentNode(); + + if(!parentNode.isNull()) + { + SVGElementImpl *parent = shape->ownerDoc()->getElementFromHandle(parentNode.handle()); + + if(parent) + shape = dynamic_cast<SVGShapeImpl *>(parent); + else + shape = 0; + } + else + shape = 0; + + } while(shape); + + return cumulativeMask; +} + +SVGMaskElementImpl::Mask::Mask(const QByteArray& mask, const QWMatrix& screenToMask, int width, int height) + : m_width(width), m_height(height), m_mask(mask), m_screenToMask(screenToMask) +{ +} + +QByteArray SVGMaskElementImpl::Mask::rectangle(int screenX, int screenY, int width, int height) +{ + QByteArray rect(width * height); + + for(int x = 0; x < width; x++) + { + for(int y = 0; y < height; y++) + { + rect[x + y * width] = value(screenX + x, screenY + y); + } + } + + return rect; +} + +QByteArray SVGMaskElementImpl::Mask::rectangle(const QRect& rect) +{ + return rectangle(rect.x(), rect.y(), rect.width(), rect.height()); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGMaskElementImpl.h b/ksvg/impl/SVGMaskElementImpl.h new file mode 100644 index 00000000..cdd1c125 --- /dev/null +++ b/ksvg/impl/SVGMaskElementImpl.h @@ -0,0 +1,158 @@ +/* + 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. +*/ + +#ifndef SVGMaskElementImpl_H +#define SVGMaskElementImpl_H + +#include <qwmatrix.h> + +#include "SVGTestsImpl.h" +#include "SVGBBoxTarget.h" +#include "SVGElementImpl.h" +#include "SVGStylableImpl.h" +#include "SVGLangSpaceImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" +#include "LRUCache.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + + +class SVGUnitConverter; +class KSVGCanvas; +class SVGShapeImpl; +class SVGRectImpl; +class SVGAnimatedLengthImpl; +class SVGAnimatedEnumerationImpl; +class SVGMaskElementImpl : public SVGElementImpl, + public SVGTestsImpl, + public SVGLangSpaceImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl, + public SVGBBoxTarget +{ +public: + + class Mask + { + public: + Mask() : m_width(0), m_height(0) {} + Mask(const QByteArray& mask, const QWMatrix& screenToMask, int width, int height); + ~Mask() {} + + bool isEmpty() const { return m_width == 0; } + unsigned char value(int screenX, int screenY) const; + QByteArray rectangle(int screenX, int screenY, int width, int height); + QByteArray rectangle(const QRect& rect); + void setScreenToMask(const QWMatrix& matrix) { m_screenToMask = matrix; } + + private: + int m_width; + int m_height; + QByteArray m_mask; + QWMatrix m_screenToMask; + }; + + SVGMaskElementImpl(DOM::ElementImpl *); + virtual ~SVGMaskElementImpl(); + + SVGAnimatedEnumerationImpl *maskUnits() const; + SVGAnimatedEnumerationImpl *maskContentUnits() const; + SVGAnimatedLengthImpl *x() const; + SVGAnimatedLengthImpl *y() const; + SVGAnimatedLengthImpl *width() const; + SVGAnimatedLengthImpl *height() const; + + virtual SVGRectImpl *getBBox(); + virtual void setAttributes(); + + SVGUnitConverter *converter() const { return m_converter; } + + Mask createMask(SVGShapeImpl *referencingElement); + + // Compute the mask on a given shape, taking into account all masks defined + // on the shape's ancestors. This is a workaround for us not having a buffer + // for container elements, so we can't mask containers directly. + static QByteArray maskRectangle(SVGShapeImpl *shape, const QRect& screenRectangle); + +private: + class CacheKey + { + public: + CacheKey() : m_element(0), m_width(0), m_height(0) {} + CacheKey(SVGElementImpl *element, int width, int height) : m_element(element), m_width(width), m_height(height) {} + bool operator==(const CacheKey& other) const { return m_element == other.m_element && m_width == other.m_width && m_height == other.m_height; } + + private: + SVGElementImpl *m_element; + int m_width; + int m_height; + }; + + Mask createMask(SVGShapeImpl *referencingElement, int imageWidth, int imageHeight); + + SVGAnimatedEnumerationImpl *m_maskUnits; + SVGAnimatedEnumerationImpl *m_maskContentUnits; + SVGAnimatedLengthImpl *m_x; + SVGAnimatedLengthImpl *m_y; + SVGAnimatedLengthImpl *m_width; + SVGAnimatedLengthImpl *m_height; + + SVGUnitConverter *m_converter; + KSVGCanvas *m_canvas; + + MinOneLRUCache<CacheKey, Mask> m_maskCache; + +public: + KSVG_GET + KSVG_PUT + KSVG_BRIDGE + + enum + { + // Properties + MaskUnits, MaskContentUnits, X, Y, Width, Height + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +KSVG_REGISTER_ELEMENT(SVGMaskElementImpl, "mask") + +inline unsigned char SVGMaskElementImpl::Mask::value(int screenX, int screenY) const +{ + int x, y; + + m_screenToMask.map(screenX, screenY, &x, &y); + + if(x >= 0 && x < m_width && y >= 0 && y < m_height) + return m_mask[x + y * m_width]; + else + return 0; +} + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGMatrixImpl.cc b/ksvg/impl/SVGMatrixImpl.cc new file mode 100644 index 00000000..81f14f66 --- /dev/null +++ b/ksvg/impl/SVGMatrixImpl.cc @@ -0,0 +1,460 @@ +/* + 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 <math.h> + +#include <kdebug.h> + +#include "SVGAngleImpl.h" +#include "SVGMatrixImpl.h" +#include "KSVGHelper.h" + +using namespace KSVG; + +#include "SVGMatrixImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +SVGMatrixImpl::SVGMatrixImpl() +{ + KSVG_EMPTY_FLAGS +} + +SVGMatrixImpl::SVGMatrixImpl(QWMatrix mat) +{ + m_mat = mat; +} + +SVGMatrixImpl::SVGMatrixImpl(double a, double b, double c, double d, double e, double f) +{ + m_mat.setMatrix(a, b, c, d, e, f); +} + +SVGMatrixImpl::~SVGMatrixImpl() +{ +} + +void SVGMatrixImpl::setA(const double &a) +{ + m_mat.setMatrix(a, m_mat.m12(), m_mat.m21(), m_mat.m22(), m_mat.dx(), m_mat.dy()); +} + +double SVGMatrixImpl::a() const +{ + return m_mat.m11(); +} + +void SVGMatrixImpl::setB(const double &b) +{ + m_mat.setMatrix(m_mat.m11(), b, m_mat.m21(), m_mat.m22(), m_mat.dx(), m_mat.dy()); +} + +double SVGMatrixImpl::b() const +{ + return m_mat.m12(); +} + +void SVGMatrixImpl::setC(const double &c) +{ + m_mat.setMatrix(m_mat.m11(), m_mat.m12(), c, m_mat.m22(), m_mat.dx(), m_mat.dy()); +} + +double SVGMatrixImpl::c() const +{ + return m_mat.m21(); +} + +void SVGMatrixImpl::setD(const double &d) +{ + m_mat.setMatrix(m_mat.m11(), m_mat.m12(), m_mat.m21(), d, m_mat.dx(), m_mat.dy()); +} + +double SVGMatrixImpl::d() const +{ + return m_mat.m22(); +} + +void SVGMatrixImpl::setE(const double &e) +{ + m_mat.setMatrix(m_mat.m11(), m_mat.m12(), m_mat.m21(), m_mat.m22(), e, m_mat.dy()); +} + +double SVGMatrixImpl::e() const +{ + return m_mat.dx(); +} + +void SVGMatrixImpl::setF(const double &f) +{ + m_mat.setMatrix(m_mat.m11(), m_mat.m12(), m_mat.m21(), m_mat.m22(), m_mat.dx(), f); +} + +double SVGMatrixImpl::f() const +{ + return m_mat.dy(); +} + +void SVGMatrixImpl::copy(const SVGMatrixImpl *other) +{ + m_mat.setMatrix(other->m_mat.m11(), other->m_mat.m12(), other->m_mat.m21(), other->m_mat.m22(), other->m_mat.dx(), other->m_mat.dy()); +} + +SVGMatrixImpl *SVGMatrixImpl::postMultiply(const SVGMatrixImpl *secondMatrix) +{ + QWMatrix temp(secondMatrix->a(), secondMatrix->b(), secondMatrix->c(), secondMatrix->d(), secondMatrix->e(), secondMatrix->f()); + m_mat *= temp; + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::inverse() +{ + m_mat = m_mat.invert(); + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::postTranslate(const double &x, const double &y) +{ + // Could optimise these. + QWMatrix temp; + temp.translate(x, y); + m_mat *= temp; + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::postScale(const double &scaleFactor) +{ + QWMatrix temp; + temp.scale(scaleFactor, scaleFactor); + m_mat *= temp; + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::postScaleNonUniform(const double &scaleFactorX, const double &scaleFactorY) +{ + QWMatrix temp; + temp.scale(scaleFactorX, scaleFactorY); + m_mat *= temp; + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::postRotate(const double &angle) +{ + QWMatrix temp; + temp.rotate(angle); + m_mat *= temp; + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::postRotateFromVector(const double &x, const double &y) +{ + QWMatrix temp; + temp.rotate(SVGAngleImpl::todeg(atan2(y, x))); + m_mat *= temp; + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::postFlipX() +{ + QWMatrix temp(-1.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0F); + m_mat *= temp; + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::postFlipY() +{ + QWMatrix temp(1.0F, 0.0F, 0.0F, -1.0F, 0.0F, 0.0F); + m_mat *= temp; + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::postSkewX(const double &angle) +{ + QWMatrix temp; + temp.shear(tan(SVGAngleImpl::torad(angle)), 0.0F); + m_mat *= temp; + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::postSkewY(const double &angle) +{ + QWMatrix temp; + temp.shear(0.0F, tan(SVGAngleImpl::torad(angle))); + m_mat *= temp; + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::multiply(const SVGMatrixImpl *secondMatrix) +{ + QWMatrix temp(secondMatrix->a(), secondMatrix->b(), secondMatrix->c(), secondMatrix->d(), secondMatrix->e(), secondMatrix->f()); + temp *= m_mat; + m_mat = temp; + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::translate(const double &x, const double &y) +{ + m_mat.translate(x, y); + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::scale(const double &scaleFactor) +{ + m_mat.scale(scaleFactor, scaleFactor); + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::scaleNonUniform(const double &scaleFactorX, const double &scaleFactorY) +{ + m_mat.scale(scaleFactorX, scaleFactorY); + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::rotate(const double &angle) +{ + m_mat.rotate(angle); + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::rotateFromVector(const double &x, const double &y) +{ + m_mat.rotate(SVGAngleImpl::todeg(atan2(y, x))); + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::flipX() +{ + m_mat.scale(-1.0f, 1.0f); + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::flipY() +{ + m_mat.scale(1.0f, -1.0f); + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::skewX(const double &angle) +{ + m_mat.shear(tan(SVGAngleImpl::torad(angle)), 0.0F); + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::skewY(const double &angle) +{ + m_mat.shear(0.0F, tan(SVGAngleImpl::torad(angle))); + return this; +} + +void SVGMatrixImpl::setMatrix(QWMatrix mat) +{ + m_mat = mat; +} + +QWMatrix &SVGMatrixImpl::qmatrix() +{ + return m_mat; +} + +const QWMatrix &SVGMatrixImpl::qmatrix() const +{ + return m_mat; +} + +void SVGMatrixImpl::reset() +{ + m_mat.reset(); +} + +void SVGMatrixImpl::removeScale(double *xScale, double *yScale) +{ + double sx = sqrt(a()*a() + b()*b()); + double sy = sqrt(c()*c() + d()*d()); + + // Remove the scaling from the matrix. + + setA(a()/sx); + setB(b()/sx); + setC(c()/sy); + setD(d()/sy); + + *xScale = sx; + *yScale = sy; +} + +KSVGPolygon SVGMatrixImpl::map(const KSVGPolygon& polygon) const +{ + KSVGPolygon mapped; + + for(unsigned int i = 0; i < polygon.numPoints(); i++) + { + double x, y; + + m_mat.map(polygon.point(i).x(), polygon.point(i).y(), &x, &y); + mapped.addPoint(x, y); + } + + return mapped; +} + +KSVGPolygon SVGMatrixImpl::inverseMap(const KSVGPolygon& polygon) const +{ + QWMatrix inverse = m_mat.invert(); + KSVGPolygon mapped; + + for(unsigned int i = 0; i < polygon.numPoints(); i++) + { + double x, y; + + inverse.map(polygon.point(i).x(), polygon.point(i).y(), &x, &y); + mapped.addPoint(x, y); + } + + return mapped; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGMatrixImpl::s_hashTable 7 + a SVGMatrixImpl::A DontDelete + b SVGMatrixImpl::B DontDelete + c SVGMatrixImpl::C DontDelete + d SVGMatrixImpl::D DontDelete + e SVGMatrixImpl::E DontDelete + f SVGMatrixImpl::F DontDelete +@end +@namespace KSVG +@begin SVGMatrixImplProto::s_hashTable 13 + inverse SVGMatrixImpl::Inverse DontDelete|Function 0 + multiply SVGMatrixImpl::Multiply DontDelete|Function 1 + translate SVGMatrixImpl::Translate DontDelete|Function 2 + scale SVGMatrixImpl::Scale DontDelete|Function 1 + rotate SVGMatrixImpl::Rotate DontDelete|Function 1 + rotateFromVector SVGMatrixImpl::RotateFromVector DontDelete|Function 2 + scaleNonUniform SVGMatrixImpl::ScaleNonUniform DontDelete|Function 2 + flipX SVGMatrixImpl::FlipX DontDelete|Function 0 + flipY SVGMatrixImpl::FlipY DontDelete|Function 0 + skewX SVGMatrixImpl::SkewX DontDelete|Function 1 + skewY SVGMatrixImpl::SkewY DontDelete|Function 1 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGMatrix", SVGMatrixImplProto, SVGMatrixImplProtoFunc) + +Value SVGMatrixImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case A: + return Number(a()); + case B: + return Number(b()); + case C: + return Number(c()); + case D: + return Number(d()); + case E: + return Number(e()); + case F: + return Number(f()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return KJS::Undefined(); + } +} + + +void SVGMatrixImpl::putValueProperty(ExecState *exec, int token, const KJS::Value &value, int) +{ + switch(token) + { + case A: + setA(value.toNumber(exec)); + break; + case B: + setB(value.toNumber(exec)); + break; + case C: + setC(value.toNumber(exec)); + break; + case D: + setD(value.toNumber(exec)); + break; + case E: + setE(value.toNumber(exec)); + break; + case F: + setF(value.toNumber(exec)); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + break; + } +} + +Value SVGMatrixImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGMatrixImpl) + + switch(id) + { + case SVGMatrixImpl::Inverse: + return obj->inverse()->cache(exec); + break; + case SVGMatrixImpl::Multiply: + return obj->multiply(static_cast<KSVGBridge<SVGMatrixImpl> *>(args[0].imp())->impl())->cache(exec); + break; + case SVGMatrixImpl::Translate: + return obj->translate(args[0].toNumber(exec), args[1].toNumber(exec))->cache(exec); + break; + case SVGMatrixImpl::Scale: + return obj->scale(args[0].toNumber(exec))->cache(exec); + break; + case SVGMatrixImpl::Rotate: + return obj->rotate(args[0].toNumber(exec))->cache(exec); + break; + case SVGMatrixImpl::RotateFromVector: + return obj->rotateFromVector(args[0].toNumber(exec), args[1].toNumber(exec))->cache(exec); + break; + case SVGMatrixImpl::ScaleNonUniform: + return obj->scaleNonUniform(args[0].toNumber(exec), args[1].toNumber(exec))->cache(exec); + break; + case SVGMatrixImpl::FlipX: + return obj->flipX()->cache(exec); + break; + case SVGMatrixImpl::FlipY: + return obj->flipY()->cache(exec); + break; + case SVGMatrixImpl::SkewX: + return obj->skewX(args[0].toNumber(exec))->cache(exec); + break; + case SVGMatrixImpl::SkewY: + return obj->skewY(args[0].toNumber(exec))->cache(exec);; + break; + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return Undefined(); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGMatrixImpl.h b/ksvg/impl/SVGMatrixImpl.h new file mode 100644 index 00000000..a5d8edf3 --- /dev/null +++ b/ksvg/impl/SVGMatrixImpl.h @@ -0,0 +1,130 @@ +/* + 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. +*/ + +#ifndef SVGMatrixImpl_H +#define SVGMatrixImpl_H + +#include <qwmatrix.h> + +#include <dom/dom_misc.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ +class KSVGPolygon; + +class SVGMatrixImpl : public DOM::DomShared +{ +public: + SVGMatrixImpl(); + SVGMatrixImpl(QWMatrix mat); + SVGMatrixImpl(double, double, double, double, double, double); + ~SVGMatrixImpl(); + + void setA(const double &); + double a() const; + + void setB(const double &); + double b() const; + + void setC(const double &); + double c() const; + + void setD(const double &); + double d() const; + + void setE(const double &); + double e() const; + + void setF(const double &); + double f() const; + + void copy(const SVGMatrixImpl *other); + + SVGMatrixImpl *inverse(); + + // Pre-multiplied operations, as per the specs. + SVGMatrixImpl *multiply(const SVGMatrixImpl *secondMatrix); + SVGMatrixImpl *translate(const double &x, const double &y); + SVGMatrixImpl *scale(const double &scaleFactor); + SVGMatrixImpl *scaleNonUniform(const double &scaleFactorX, const double &scaleFactorY); + SVGMatrixImpl *rotate(const double &angle); + SVGMatrixImpl *rotateFromVector(const double &x, const double &y); + SVGMatrixImpl *flipX(); + SVGMatrixImpl *flipY(); + SVGMatrixImpl *skewX(const double &angle); + SVGMatrixImpl *skewY(const double &angle); + + // Post-multiplied operations + SVGMatrixImpl *postMultiply(const SVGMatrixImpl *secondMatrix); + SVGMatrixImpl *postTranslate(const double &x, const double &y); + SVGMatrixImpl *postScale(const double &scaleFactor); + SVGMatrixImpl *postScaleNonUniform(const double &scaleFactorX, const double &scaleFactorY); + SVGMatrixImpl *postRotate(const double &angle); + SVGMatrixImpl *postRotateFromVector(const double &x, const double &y); + SVGMatrixImpl *postFlipX(); + SVGMatrixImpl *postFlipY(); + SVGMatrixImpl *postSkewX(const double &angle); + SVGMatrixImpl *postSkewY(const double &angle); + + void reset(); + + // KSVG helper method + QWMatrix &qmatrix(); + const QWMatrix &qmatrix() const; + + // Determine the scaling component of the matrix and factor it out. After + // this operation, the matrix has x and y scale of one. + void removeScale(double *xScale, double *yScale); + + KSVGPolygon map(const KSVGPolygon& polygon) const; + KSVGPolygon inverseMap(const KSVGPolygon& polygon) const; + +private: + void setMatrix(QWMatrix mat); + QWMatrix m_mat; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + A, B, C, D, E, F, + // Functions + Inverse, Multiply, Translate, Scale, Rotate, + RotateFromVector, ScaleNonUniform, + FlipX, FlipY, SkewX, SkewY + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +KSVG_DEFINE_PROTOTYPE(SVGMatrixImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGMatrixImplProtoFunc, SVGMatrixImpl) + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGMetadataElementImpl.cc b/ksvg/impl/SVGMetadataElementImpl.cc new file mode 100644 index 00000000..d55d4302 --- /dev/null +++ b/ksvg/impl/SVGMetadataElementImpl.cc @@ -0,0 +1,33 @@ +/* + 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 "SVGMetadataElementImpl.h" + +using namespace KSVG; + +SVGMetadataElementImpl::SVGMetadataElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl) +{ +} + +SVGMetadataElementImpl::~SVGMetadataElementImpl() +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGMetadataElementImpl.h b/ksvg/impl/SVGMetadataElementImpl.h new file mode 100644 index 00000000..363a9c11 --- /dev/null +++ b/ksvg/impl/SVGMetadataElementImpl.h @@ -0,0 +1,46 @@ +/* + 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. +*/ + +#ifndef SVGMetadataElementImpl_H +#define SVGMetadataElementImpl_H + +#include "SVGElementImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGMetadataElementImpl : public SVGElementImpl +{ +public: + SVGMetadataElementImpl(DOM::ElementImpl *); + virtual ~SVGMetadataElementImpl(); + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGMissingGlyphElementImpl.cc b/ksvg/impl/SVGMissingGlyphElementImpl.cc new file mode 100644 index 00000000..986750c3 --- /dev/null +++ b/ksvg/impl/SVGMissingGlyphElementImpl.cc @@ -0,0 +1,33 @@ +/* + 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 "SVGMissingGlyphElementImpl.h" + +using namespace KSVG; + +SVGMissingGlyphElementImpl::SVGMissingGlyphElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGStylableImpl(this) +{ +} + +SVGMissingGlyphElementImpl::~SVGMissingGlyphElementImpl() +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGMissingGlyphElementImpl.h b/ksvg/impl/SVGMissingGlyphElementImpl.h new file mode 100644 index 00000000..275aba86 --- /dev/null +++ b/ksvg/impl/SVGMissingGlyphElementImpl.h @@ -0,0 +1,47 @@ +/* + 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. +*/ + +#ifndef SVGMissingGlyphElementImpl_H +#define SVGMissingGlyphElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGElementImpl.h" +#include "SVGStylableImpl.h" + +namespace KSVG +{ + +class SVGMissingGlyphElementImpl : public SVGElementImpl, + public SVGStylableImpl +{ +public: + SVGMissingGlyphElementImpl(DOM::ElementImpl *); + virtual ~SVGMissingGlyphElementImpl(); +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGNumberImpl.cc b/ksvg/impl/SVGNumberImpl.cc new file mode 100644 index 00000000..b926e9c2 --- /dev/null +++ b/ksvg/impl/SVGNumberImpl.cc @@ -0,0 +1,83 @@ +/* + 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> + +#include "SVGNumberImpl.h" + +using namespace KSVG; + +#include "SVGNumberImpl.lut.h" +#include "ksvg_bridge.h" + +SVGNumberImpl::SVGNumberImpl() +{ + KSVG_EMPTY_FLAGS + + m_value = 0; +} + +SVGNumberImpl::~SVGNumberImpl() +{ +} + +void SVGNumberImpl::setValue(float value) +{ + m_value = value; +} + +float SVGNumberImpl::value() +{ + return m_value; +} + +/* +@namespace KSVG +@begin SVGNumberImpl::s_hashTable 2 + value SVGNumberImpl::Value DontDelete +@end +*/ + +Value SVGNumberImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case Value: + return Number(m_value); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } + + return Undefined(); +} + +void SVGNumberImpl::putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int) +{ + switch(token) + { + case Value: + m_value = value.toNumber(exec); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGNumberImpl.h b/ksvg/impl/SVGNumberImpl.h new file mode 100644 index 00000000..d94b3d63 --- /dev/null +++ b/ksvg/impl/SVGNumberImpl.h @@ -0,0 +1,61 @@ +/* + 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. +*/ + +#ifndef SVGNumberImpl_H +#define SVGNumberImpl_H + +#include <dom/dom_misc.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGNumberImpl : public DOM::DomShared +{ +public: + SVGNumberImpl(); + virtual ~SVGNumberImpl(); + + void setValue(float value); + float value(); + +private: + float m_value; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + Value + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGNumberListImpl.cc b/ksvg/impl/SVGNumberListImpl.cc new file mode 100644 index 00000000..8048640c --- /dev/null +++ b/ksvg/impl/SVGNumberListImpl.cc @@ -0,0 +1,64 @@ +/* + 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> + +#include "SVGNumberListImpl.h" + +using namespace KSVG; + +#include "SVGNumberListImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGNumberListImpl::s_hashTable 2 + numberOfItems SVGListDefs::NumberOfItems DontDelete|ReadOnly +@end +@namespace KSVG +@begin SVGNumberListImplProto::s_hashTable 11 + getItem SVGListDefs::GetItem DontDelete|Function 1 + removeItem SVGListDefs::RemoveItem DontDelete|Function 1 + appendItem SVGListDefs::AppendItem DontDelete|Function 1 + initialize SVGListDefs::Initialize DontDelete|Function 1 + insertItemBefore SVGListDefs::InsertItemBefore DontDelete|Function 2 + replaceItem SVGListDefs::ReplaceItem DontDelete|Function 2 + clear SVGListDefs::Clear DontDelete|Function 0 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGNumberList", SVGNumberListImplProto, SVGNumberListImplProtoFunc) + +Value SVGNumberListImpl::getValueProperty(ExecState *exec, int token) const +{ + return SVGList<SVGNumberImpl>::getValueProperty(exec, token); +} + +Value SVGNumberListImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGNumberListImpl) + + return obj->call(exec, static_cast<SVGList<SVGNumberImpl> *>(obj), args, id); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGNumberListImpl.h b/ksvg/impl/SVGNumberListImpl.h new file mode 100644 index 00000000..87dadb6f --- /dev/null +++ b/ksvg/impl/SVGNumberListImpl.h @@ -0,0 +1,48 @@ +/* + 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. +*/ + +#ifndef SVGNumberListImpl_H +#define SVGNumberListImpl_H + +#include "SVGList.h" + +#include "SVGNumberImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGNumberListImpl : public SVGList<SVGNumberImpl> +{ +public: + KSVG_GET + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; +}; + +} + +KSVG_DEFINE_PROTOTYPE(SVGNumberListImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGNumberListImplProtoFunc, SVGNumberListImpl) + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPaintImpl.cc b/ksvg/impl/SVGPaintImpl.cc new file mode 100644 index 00000000..c1818892 --- /dev/null +++ b/ksvg/impl/SVGPaintImpl.cc @@ -0,0 +1,175 @@ +/* + 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> + +#include "SVGPaint.h" +#include "SVGColor.h" + +#include "SVGPaintImpl.h" + +using namespace KSVG; + +#include "SVGPaintImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_cacheimpl.h" + +SVGPaintImpl::SVGPaintImpl(SVGElementImpl *object) : SVGColorImpl(object) +{ + m_paintType = SVG_PAINTTYPE_UNKNOWN; +} + +SVGPaintImpl::SVGPaintImpl(const SVGPaintImpl &other) : SVGColorImpl(other) +{ + (*this) = other; +} + +SVGPaintImpl::~SVGPaintImpl() +{ +} + +SVGPaintImpl &SVGPaintImpl::operator=(const SVGPaintImpl &other) +{ + m_uri = other.m_uri; + m_paintType = other.m_paintType; + + *(static_cast<SVGColorImpl *>(this)) = other; + + return *this; +} + +unsigned short SVGPaintImpl::paintType() const +{ + return m_paintType; +} + +DOM::DOMString SVGPaintImpl::uri() const +{ + return m_uri; +} + +void SVGPaintImpl::setUri(const DOM::DOMString &uri) +{ + m_uri = uri; + m_paintType = SVG_PAINTTYPE_URI; +} + +void SVGPaintImpl::setPaint(unsigned short paintType, const DOM::DOMString &/*uri*/, const DOM::DOMString &/*rgbColor*/, const DOM::DOMString &/*iccColor*/) +{ + m_paintType = paintType; +} + +void SVGPaintImpl::setRGBColor(QColor color) +{ + m_paintType = SVG_PAINTTYPE_RGBCOLOR; + SVGColorImpl::setRGBColor(color); +} + +void SVGPaintImpl::setRGBColor(int r, int g, int b) +{ + m_paintType = SVG_PAINTTYPE_RGBCOLOR; + SVGColorImpl::setRGBColor(r, g, b); +} + +void SVGPaintImpl::setRGBColor(const DOM::DOMString &rgbColor) +{ + m_paintType = SVG_PAINTTYPE_RGBCOLOR; + SVGColorImpl::setRGBColor(rgbColor); +} + +void SVGPaintImpl::setRGBColorICCColor(const DOM::DOMString &rgbColor, const DOM::DOMString &iccColor) +{ + m_paintType = SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR; + SVGColorImpl::setRGBColorICCColor(rgbColor, iccColor); +} + +void SVGPaintImpl::setColor(unsigned short colorType, const DOM::DOMString &rgbColor, const DOM::DOMString &iccColor) +{ + SVGColorImpl::setColor(colorType, rgbColor, iccColor); + + switch(colorType) + { + case SVG_COLORTYPE_CURRENTCOLOR: + m_paintType = SVG_PAINTTYPE_CURRENTCOLOR; + break; + case SVG_COLORTYPE_RGBCOLOR: + m_paintType = SVG_PAINTTYPE_CURRENTCOLOR; + break; + case SVG_COLORTYPE_RGBCOLOR_ICCCOLOR: + m_paintType = SVG_PAINTTYPE_CURRENTCOLOR; + break; + case SVG_COLORTYPE_UNKNOWN: + m_paintType = SVG_PAINTTYPE_UNKNOWN; + break; + } +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPaintImpl::s_hashTable 3 + paintType SVGPaintImpl::PaintType DontDelete + uri SVGPaintImpl::URI DontDelete +@end +*/ + +Value SVGPaintImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case PaintType: + return Number(paintType()); + case URI: + return String(uri().string()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +/* +@namespace KSVG +@begin SVGPaintImplConstructor::s_hashTable 11 +SVG_PAINTTYPE_UNKNOWN KSVG::SVG_PAINTTYPE_UNKNOWN DontDelete|ReadOnly +SVG_PAINTTYPE_CURRENTCOLOR KSVG::SVG_PAINTTYPE_CURRENTCOLOR DontDelete|ReadOnly +SVG_PAINTTYPE_RGBCOLOR KSVG::SVG_PAINTTYPE_RGBCOLOR DontDelete|ReadOnly +SVG_PAINTTYPE_RGBCOLOR KSVG::SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR DontDelete|ReadOnly +SVG_PAINTTYPE_NONE KSVG::SVG_PAINTTYPE_NONE DontDelete|ReadOnly +SVG_PAINTTYPE_URI_NONE KSVG::SVG_PAINTTYPE_URI_NONE DontDelete|ReadOnly +SVG_PAINTTYPE_URI_RGBCOLOR KSVG::SVG_PAINTTYPE_URI_RGBCOLOR DontDelete|ReadOnly +SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR KSVG::SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR DontDelete|ReadOnly +SVG_PAINTTYPE_URI_CURRENTCOLOR KSVG::SVG_PAINTTYPE_URI_CURRENTCOLOR DontDelete|ReadOnly +SVG_PAINTTYPE_URI KSVG::SVG_PAINTTYPE_URI DontDelete|ReadOnly +@end +*/ + +Value SVGPaintImplConstructor::getValueProperty(ExecState *, int token) const +{ + return Number(token); +} + +Value KSVG::getSVGPaintImplConstructor(ExecState *exec) +{ + return cacheGlobalBridge<SVGPaintImplConstructor>(exec, "[[svgpaint.constructor]]"); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPaintImpl.h b/ksvg/impl/SVGPaintImpl.h new file mode 100644 index 00000000..f2aa0691 --- /dev/null +++ b/ksvg/impl/SVGPaintImpl.h @@ -0,0 +1,85 @@ +/* + 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. +*/ + +#ifndef SVGPaintImpl_H +#define SVGPaintImpl_H + +#include <dom/dom_string.h> + +#include "ksvg_lookup.h" + +#include "SVGColorImpl.h" + +namespace KSVG +{ + +class SVGPaintImpl : public SVGColorImpl +{ +public: + SVGPaintImpl(SVGElementImpl *object); + SVGPaintImpl(const SVGPaintImpl &); + virtual ~SVGPaintImpl(); + + SVGPaintImpl &operator=(const SVGPaintImpl &); + + unsigned short paintType() const; + DOM::DOMString uri() const; + void setUri(const DOM::DOMString &uri); + void setPaint(unsigned short paintType, const DOM::DOMString &uri = "", const DOM::DOMString &rgbColor = "", const DOM::DOMString &iccColor = ""); + + virtual void setRGBColor(const DOM::DOMString &rgbColor); + virtual void setRGBColor(int r, int g, int b); + virtual void setRGBColor(QColor color); + virtual void setRGBColorICCColor(const DOM::DOMString &rgbColor, const DOM::DOMString &iccColor); + virtual void setColor(unsigned short colorType, const DOM::DOMString &rgbColor, const DOM::DOMString &iccColor); + +private: + unsigned short m_paintType; + DOM::DOMString m_uri; + +public: + KSVG_GET + + enum + { + // Properties + PaintType, URI + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; +}; + +class SVGPaintImplConstructor : public KJS::ObjectImp +{ +public: + SVGPaintImplConstructor(KJS::ExecState *) { } + KJS::Value getValueProperty(KJS::ExecState *, int token) const; + + // no put - all read-only + KSVG_GET +}; + +KJS::Value getSVGPaintImplConstructor(KJS::ExecState *exec); + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPaintServerImpl.cc b/ksvg/impl/SVGPaintServerImpl.cc new file mode 100644 index 00000000..b3275231 --- /dev/null +++ b/ksvg/impl/SVGPaintServerImpl.cc @@ -0,0 +1,55 @@ +/* + Copyright (C) 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> + +#include "SVGPaintServerImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGSVGElementImpl.h" + +using namespace KSVG; + +SVGPaintServerImpl::SVGPaintServerImpl() +{ + m_paintServer = 0; +} + +SVGPaintServerImpl::~SVGPaintServerImpl() +{ +} + +CanvasPaintServer *SVGPaintServerImpl::paintServer(SVGDocumentImpl *doc, const QString& id) +{ + CanvasPaintServer *pserver = 0; + SVGElementImpl *element = doc->rootElement()->getElementById(id); + + if(element) + { + SVGPaintServerImpl *paintServerElement = dynamic_cast<SVGPaintServerImpl *>(element); + + if(paintServerElement) + pserver = paintServerElement->paintServer(); + } + + return pserver; +} + +// vim:ts=4:noet + diff --git a/ksvg/impl/SVGPaintServerImpl.h b/ksvg/impl/SVGPaintServerImpl.h new file mode 100644 index 00000000..df276758 --- /dev/null +++ b/ksvg/impl/SVGPaintServerImpl.h @@ -0,0 +1,52 @@ +/* + Copyright (C) 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. +*/ + +#ifndef SVGPaintServerImpl_H +#define SVGPaintServerImpl_H + +namespace KSVG +{ + +class SVGDocumentImpl; + +class CanvasPaintServer; + +class SVGPaintServerImpl +{ +public: + SVGPaintServerImpl(); + virtual ~SVGPaintServerImpl(); + + CanvasPaintServer *paintServer() { return m_paintServer; } + + static CanvasPaintServer *paintServer(SVGDocumentImpl *doc, const QString& id); + +protected: + CanvasPaintServer *m_paintServer; + +private: +}; + +} + +#endif + +// vim:ts=4:noet + diff --git a/ksvg/impl/SVGPathElementImpl.cc b/ksvg/impl/SVGPathElementImpl.cc new file mode 100644 index 00000000..f34600b8 --- /dev/null +++ b/ksvg/impl/SVGPathElementImpl.cc @@ -0,0 +1,868 @@ +/* + 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 <math.h> +#include <cfloat> + +#include <kdebug.h> +#include <klocale.h> + +#include "SVGRectImpl.h" +#include "SVGPaintImpl.h" +#include "SVGPointImpl.h" +#include "SVGAngleImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGPathSegArcImpl.h" +#include "SVGPathSegListImpl.h" +#include "SVGPathElementImpl.h" +#include "SVGPathSegLinetoImpl.h" +#include "SVGPathSegMovetoImpl.h" +#include "SVGAnimatedNumberImpl.h" +#include "SVGPathSegClosePathImpl.h" +#include "SVGPathSegCurvetoCubicImpl.h" +#include "SVGPathSegLinetoVerticalImpl.h" +#include "SVGPathSegLinetoHorizontalImpl.h" +#include "SVGPathSegCurvetoQuadraticImpl.h" +#include "SVGPathSegCurvetoCubicSmoothImpl.h" +#include "SVGPathSegCurvetoQuadraticSmoothImpl.h" + +#include "SVGPaint.h" + +#include "CanvasItem.h" +#include "KSVGCanvas.h" +#include "BezierPath.h" +#include "Point.h" + +using namespace KSVG; + +#include "SVGPathElementImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" + +SVGPathElementImpl::SVGPathElementImpl(DOM::ElementImpl *impl) : SVGShapeImpl(impl), SVGTestsImpl(), SVGLangSpaceImpl(), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this), SVGTransformableImpl(), SVGAnimatedPathDataImpl(), SVGPathParser() +{ + KSVG_EMPTY_FLAGS + + m_pathLength = new SVGAnimatedNumberImpl(); + m_pathLength->ref(); + + m_pathLength->setBaseVal(0); +} + +SVGPathElementImpl::~SVGPathElementImpl() +{ + pathSegList()->clear(); + + if(m_pathLength) + m_pathLength->deref(); +} + +SVGAnimatedNumberImpl *SVGPathElementImpl::pathLength() const +{ + return m_pathLength; +} + +double SVGPathElementImpl::getTotalLength() +{ + T2P::BezierPath *path = ownerDoc()->canvas()->toBezierPath(m_item); + if(path) + return path->length(); + + return 0; +} + +SVGPointImpl *SVGPathElementImpl::getPointAtLength(double distance) +{ + SVGPointImpl *ret = SVGSVGElementImpl::createSVGPoint(); + double totalDistance = getTotalLength(); + T2P::BezierPath *path = ownerDoc()->canvas()->toBezierPath(m_item); + if(path) + { + T2P::Point p; + path->pointTangentNormalAt(distance / totalDistance, &p); + ret->setX(p.x()); + ret->setY(p.y()); + } + + return ret; +} + +unsigned long SVGPathElementImpl::getPathSegAtLength(double) +{ + return 0; +} + +SVGPathSegClosePathImpl *SVGPathElementImpl::createSVGPathSegClosePath() +{ + SVGPathSegClosePathImpl *temp = new SVGPathSegClosePathImpl(); + temp->ref(); + + return temp; +} + +SVGPathSegMovetoAbsImpl *SVGPathElementImpl::createSVGPathSegMovetoAbs(double x, double y) +{ + SVGPathSegMovetoAbsImpl *temp = new SVGPathSegMovetoAbsImpl(); + temp->ref(); + + temp->setX(x); + temp->setY(y); + return temp; +} + +SVGPathSegMovetoRelImpl *SVGPathElementImpl::createSVGPathSegMovetoRel(double x, double y) +{ + SVGPathSegMovetoRelImpl *temp = new SVGPathSegMovetoRelImpl(); + temp->ref(); + + temp->setX(x); + temp->setY(y); + return temp; +} + +SVGPathSegLinetoAbsImpl *SVGPathElementImpl::createSVGPathSegLinetoAbs(double x, double y) +{ + SVGPathSegLinetoAbsImpl *temp = new SVGPathSegLinetoAbsImpl(); + temp->ref(); + + temp->setX(x); + temp->setY(y); + return temp; +} + +SVGPathSegLinetoRelImpl *SVGPathElementImpl::createSVGPathSegLinetoRel(double x, double y) +{ + SVGPathSegLinetoRelImpl *temp = new SVGPathSegLinetoRelImpl(); + temp->ref(); + + temp->setX(x); + temp->setY(y); + return temp; +} + +SVGPathSegCurvetoCubicAbsImpl *SVGPathElementImpl::createSVGPathSegCurvetoCubicAbs(double x, double y, double x1, double y1, double x2, double y2) +{ + SVGPathSegCurvetoCubicAbsImpl *temp = new SVGPathSegCurvetoCubicAbsImpl(); + temp->ref(); + + temp->setX(x); + temp->setY(y); + temp->setX1(x1); + temp->setY1(y1); + temp->setX2(x2); + temp->setY2(y2); + return temp; +} + +SVGPathSegCurvetoCubicRelImpl *SVGPathElementImpl::createSVGPathSegCurvetoCubicRel(double x, double y, double x1, double y1, double x2, double y2) +{ + SVGPathSegCurvetoCubicRelImpl *temp = new SVGPathSegCurvetoCubicRelImpl(); + temp->ref(); + + temp->setX(x); + temp->setY(y); + temp->setX1(x1); + temp->setY1(y1); + temp->setX2(x2); + temp->setY2(y2); + return temp; +} + +SVGPathSegCurvetoQuadraticAbsImpl *SVGPathElementImpl::createSVGPathSegCurvetoQuadraticAbs(double x, double y, double x1, double y1) +{ + SVGPathSegCurvetoQuadraticAbsImpl *temp = new SVGPathSegCurvetoQuadraticAbsImpl(); + temp->ref(); + + temp->setX(x); + temp->setY(y); + temp->setX1(x1); + temp->setY1(y1); + return temp; +} + +SVGPathSegCurvetoQuadraticRelImpl *SVGPathElementImpl::createSVGPathSegCurvetoQuadraticRel(double x, double y, double x1, double y1) +{ + SVGPathSegCurvetoQuadraticRelImpl *temp = new SVGPathSegCurvetoQuadraticRelImpl(); + temp->ref(); + + temp->setX(x); + temp->setY(y); + temp->setX1(x1); + temp->setY1(y1); + return temp; +} + +SVGPathSegArcAbsImpl *SVGPathElementImpl::createSVGPathSegArcAbs(double x, double y, double r1, double r2, double angle, bool largeArcFlag, bool sweepFlag) +{ + SVGPathSegArcAbsImpl *temp = new SVGPathSegArcAbsImpl(); + temp->ref(); + + temp->setX(x); + temp->setY(y); + temp->setR1(r1); + temp->setR2(r2); + temp->setAngle(angle); + temp->setLargeArcFlag(largeArcFlag); + temp->setSweepFlag(sweepFlag); + return temp; +} + +SVGPathSegArcRelImpl *SVGPathElementImpl::createSVGPathSegArcRel(double x, double y, double r1, double r2, double angle, bool largeArcFlag, bool sweepFlag) +{ + SVGPathSegArcRelImpl *temp = new SVGPathSegArcRelImpl(); + temp->ref(); + + temp->setX(x); + temp->setY(y); + temp->setR1(r1); + temp->setR2(r2); + temp->setAngle(angle); + temp->setLargeArcFlag(largeArcFlag); + temp->setSweepFlag(sweepFlag); + return temp; +} + +SVGPathSegLinetoHorizontalAbsImpl *SVGPathElementImpl::createSVGPathSegLinetoHorizontalAbs(double x) +{ + SVGPathSegLinetoHorizontalAbsImpl *temp = new SVGPathSegLinetoHorizontalAbsImpl(); + temp->ref(); + + temp->setX(x); + return temp; +} + +SVGPathSegLinetoHorizontalRelImpl *SVGPathElementImpl::createSVGPathSegLinetoHorizontalRel(double x) +{ + SVGPathSegLinetoHorizontalRelImpl *temp = new SVGPathSegLinetoHorizontalRelImpl(); + temp->ref(); + + temp->setX(x); + return temp; +} + +SVGPathSegLinetoVerticalAbsImpl *SVGPathElementImpl::createSVGPathSegLinetoVerticalAbs(double y) +{ + SVGPathSegLinetoVerticalAbsImpl *temp = new SVGPathSegLinetoVerticalAbsImpl(); + temp->ref(); + + temp->setY(y); + return temp; +} + +SVGPathSegLinetoVerticalRelImpl *SVGPathElementImpl::createSVGPathSegLinetoVerticalRel(double y) +{ + SVGPathSegLinetoVerticalRelImpl *temp = new SVGPathSegLinetoVerticalRelImpl(); + temp->ref(); + + temp->setY(y); + return temp; +} + +SVGPathSegCurvetoCubicSmoothAbsImpl *SVGPathElementImpl::createSVGPathSegCurvetoCubicSmoothAbs(double x, double y, double x2, double y2) +{ + SVGPathSegCurvetoCubicSmoothAbsImpl *temp = new SVGPathSegCurvetoCubicSmoothAbsImpl(); + temp->ref(); + + temp->setX(x); + temp->setY(y); + temp->setX2(x2); + temp->setY2(y2); + return temp; +} + +SVGPathSegCurvetoCubicSmoothRelImpl *SVGPathElementImpl::createSVGPathSegCurvetoCubicSmoothRel(double x, double y, double x2, double y2) +{ + SVGPathSegCurvetoCubicSmoothRelImpl *temp = new SVGPathSegCurvetoCubicSmoothRelImpl(); + temp->ref(); + + temp->setX(x); + temp->setY(y); + temp->setX2(x2); + temp->setY2(y2); + return temp; +} + +SVGPathSegCurvetoQuadraticSmoothAbsImpl *SVGPathElementImpl::createSVGPathSegCurvetoQuadraticSmoothAbs(double x, double y) +{ + SVGPathSegCurvetoQuadraticSmoothAbsImpl *temp = new SVGPathSegCurvetoQuadraticSmoothAbsImpl(); + temp->ref(); + + temp->setX(x); + temp->setY(y); + return temp; +} + +SVGPathSegCurvetoQuadraticSmoothRelImpl *SVGPathElementImpl::createSVGPathSegCurvetoQuadraticSmoothRel(double x, double y) +{ + SVGPathSegCurvetoQuadraticSmoothRelImpl *temp = new SVGPathSegCurvetoQuadraticSmoothRelImpl(); + temp->ref(); + + temp->setX(x); + temp->setY(y); + return temp; +} + +void SVGPathElementImpl::svgMoveTo(double x1, double y1, bool, bool abs) +{ + if(abs) + pathSegList()->appendItem(createSVGPathSegMovetoAbs(x1, y1)); + else + pathSegList()->appendItem(createSVGPathSegMovetoRel(x1, y1)); +} + +void SVGPathElementImpl::svgLineTo(double x1, double y1, bool abs) +{ + if(abs) + pathSegList()->appendItem(createSVGPathSegLinetoAbs(x1, y1)); + else + pathSegList()->appendItem(createSVGPathSegLinetoRel(x1, y1)); +} + +void SVGPathElementImpl::svgLineToHorizontal(double x, bool abs) +{ + if(abs) + pathSegList()->appendItem(createSVGPathSegLinetoHorizontalAbs(x)); + else + pathSegList()->appendItem(createSVGPathSegLinetoHorizontalRel(x)); +} + +void SVGPathElementImpl::svgLineToVertical(double y, bool abs) +{ + if(abs) + pathSegList()->appendItem(createSVGPathSegLinetoVerticalAbs(y)); + else + pathSegList()->appendItem(createSVGPathSegLinetoVerticalRel(y)); +} + +void SVGPathElementImpl::svgCurveToCubic(double x1, double y1, double x2, double y2, double x, double y, bool abs) +{ + if(abs) + pathSegList()->appendItem(createSVGPathSegCurvetoCubicAbs(x, y, x1, y1, x2, y2)); + else + pathSegList()->appendItem(createSVGPathSegCurvetoCubicRel(x, y, x1, y1, x2, y2)); +} + +void SVGPathElementImpl::svgCurveToCubicSmooth(double x, double y, double x2, double y2, bool abs) +{ + if(abs) + pathSegList()->appendItem(createSVGPathSegCurvetoCubicSmoothAbs(x2, y2, x, y)); + else + pathSegList()->appendItem(createSVGPathSegCurvetoCubicSmoothRel(x2, y2, x, y)); +} + +void SVGPathElementImpl::svgCurveToQuadratic(double x, double y, double x1, double y1, bool abs) +{ + if(abs) + pathSegList()->appendItem(createSVGPathSegCurvetoQuadraticAbs(x1, y1, x, y)); + else + pathSegList()->appendItem(createSVGPathSegCurvetoQuadraticRel(x1, y1, x, y)); +} + +void SVGPathElementImpl::svgCurveToQuadraticSmooth(double x, double y, bool abs) +{ + if(abs) + pathSegList()->appendItem(createSVGPathSegCurvetoQuadraticSmoothAbs(x, y)); + else + pathSegList()->appendItem(createSVGPathSegCurvetoQuadraticSmoothRel(x, y)); +} + +void SVGPathElementImpl::svgArcTo(double x, double y, double r1, double r2, double angle, bool largeArcFlag, bool sweepFlag, bool abs) +{ + if(abs) + pathSegList()->appendItem(createSVGPathSegArcAbs(x, y, r1, r2, angle, largeArcFlag, sweepFlag)); + else + pathSegList()->appendItem(createSVGPathSegArcRel(x, y, r1, r2, angle, largeArcFlag, sweepFlag)); +} + +void SVGPathElementImpl::svgClosePath() +{ + pathSegList()->appendItem(createSVGPathSegClosePath()); +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPathElementImpl::s_hashTable 3 + d SVGPathElementImpl::D DontDelete|ReadOnly + pathLength SVGPathElementImpl::PathLength DontDelete|ReadOnly +@end +@namespace KSVG +@begin SVGPathElementImplProto::s_hashTable 23 + getTotalLength SVGPathElementImpl::GetTotalLength DontDelete|Function 0 + getPointAtLength SVGPathElementImpl::GetPointAtLength DontDelete|Function 1 + getPathSegAtLength SVGPathElementImpl::GetPathSegAtLength DontDelete|Function 1 + createSVGPathSegClosePath SVGPathElementImpl::CreateSVGPathSegClosePath DontDelete|Function 0 + createSVGPathSegMovetoAbs SVGPathElementImpl::CreateSVGPathSegMovetoAbs DontDelete|Function 2 + createSVGPathSegMovetoRel SVGPathElementImpl::CreateSVGPathSegMovetoRel DontDelete|Function 2 + createSVGPathSegLinetoAbs SVGPathElementImpl::CreateSVGPathSegLinetoAbs DontDelete|Function 2 + createSVGPathSegLinetoRel SVGPathElementImpl::CreateSVGPathSegLinetoRel DontDelete|Function 2 + createSVGPathSegArcAbs SVGPathElementImpl::CreateSVGPathSegArcAbs DontDelete|Function 7 + createSVGPathSegArcRel SVGPathElementImpl::CreateSVGPathSegArcRel DontDelete|Function 7 + createSVGPathSegCurvetoCubicAbs SVGPathElementImpl::CreateSVGPathSegCurvetoCubicAbs DontDelete|Function 6 + createSVGPathSegCurvetoCubicRel SVGPathElementImpl::CreateSVGPathSegCurvetoCubicRel DontDelete|Function 6 + createSVGPathSegCurvetoQuadraticAbs SVGPathElementImpl::CreateSVGPathSegCurvetoQuadraticAbs DontDelete|Function 4 + createSVGPathSegCurvetoQuadraticRel SVGPathElementImpl::CreateSVGPathSegCurvetoQuadraticRel DontDelete|Function 4 + createSVGPathSegLinetoHorizontalAbs SVGPathElementImpl::CreateSVGPathSegLinetoHorizontalAbs DontDelete|Function 1 + createSVGPathSegLinetoHorizontalRel SVGPathElementImpl::CreateSVGPathSegLinetoHorizontalRel DontDelete|Function 1 + createSVGPathSegLinetoVerticalAbs SVGPathElementImpl::CreateSVGPathSegLinetoVerticalAbs DontDelete|Function 1 + createSVGPathSegLinetoVerticalRel SVGPathElementImpl::CreateSVGPathSegLinetoVerticalRel DontDelete|Function 1 + createSVGPathSegCurvetoCubicAbs SVGPathElementImpl::CreateSVGPathSegCurvetoCubicAbs DontDelete|Function 4 + createSVGPathSegCurvetoCubicRel SVGPathElementImpl::CreateSVGPathSegCurvetoCubicRel DontDelete|Function 4 + createSVGPathSegCurvetoQuadraticAbs SVGPathElementImpl::CreateSVGPathSegCurvetoQuadraticAbs DontDelete|Function 2 + createSVGPathSegCurvetoQuadraticRel SVGPathElementImpl::CreateSVGPathSegCurvetoQuadraticRel DontDelete|Function 2 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGPathElementImpl", SVGPathElementImplProto, SVGPathElementImplProtoFunc) + +Value SVGPathElementImpl::getValueProperty(ExecState *exec, int token) const +{ + //KSVG_CHECK_ATTRIBUTE + + switch(token) + { + case PathLength: + return m_pathLength->cache(exec); + case D: +// if(!attributeMode) + { + QString d; + unsigned int nrSegs = pathSegList()->numberOfItems(); + SVGPathSegImpl *curseg = 0; + for(unsigned int i = 0; i < nrSegs; i++) + { + curseg = pathSegList()->getItem(i); + if(curseg) + d += curseg->toString() + " "; + } + return String(d); + } + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGPathElementImpl::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; + + switch(token) + { + case D: + { + pathSegList()->clear(); + QString d = value.toString(exec).qstring(); + parseSVG(d, false); + if(hasMarkers()) + m_markerData = MarkerData(pathSegList()); + break; + } + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +Value SVGPathElementImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGPathElementImpl) + + switch(id) + { + case SVGPathElementImpl::GetTotalLength: + return Number(obj->getTotalLength()); + case SVGPathElementImpl::GetPointAtLength: + return obj->getPointAtLength(args[0].toNumber(exec))->cache(exec); + case SVGPathElementImpl::GetPathSegAtLength: + return Number(obj->getPathSegAtLength(args[0].toNumber(exec))); + case SVGPathElementImpl::CreateSVGPathSegClosePath: + return obj->createSVGPathSegClosePath()->cache(exec); + case SVGPathElementImpl::CreateSVGPathSegMovetoAbs: + return obj->createSVGPathSegMovetoAbs(args[0].toNumber(exec), args[1].toNumber(exec))->cache(exec); + case SVGPathElementImpl::CreateSVGPathSegMovetoRel: + return obj->createSVGPathSegMovetoRel(args[0].toNumber(exec), args[1].toNumber(exec))->cache(exec); + case SVGPathElementImpl::CreateSVGPathSegLinetoAbs: + return obj->createSVGPathSegLinetoAbs(args[0].toNumber(exec), args[1].toNumber(exec))->cache(exec); + case SVGPathElementImpl::CreateSVGPathSegLinetoRel: + return obj->createSVGPathSegLinetoRel(args[0].toNumber(exec), args[1].toNumber(exec))->cache(exec); + case SVGPathElementImpl::CreateSVGPathSegCurvetoCubicAbs: + return obj->createSVGPathSegCurvetoCubicAbs(args[0].toNumber(exec), args[1].toNumber(exec), args[2].toNumber(exec), args[3].toNumber(exec), args[4].toNumber(exec), args[5].toNumber(exec))->cache(exec); + case SVGPathElementImpl::CreateSVGPathSegCurvetoCubicRel: + return obj->createSVGPathSegCurvetoCubicRel(args[0].toNumber(exec), args[1].toNumber(exec), args[2].toNumber(exec), args[3].toNumber(exec), args[4].toNumber(exec), args[5].toNumber(exec))->cache(exec); + case SVGPathElementImpl::CreateSVGPathSegCurvetoQuadraticAbs: + return obj->createSVGPathSegCurvetoQuadraticAbs(args[0].toNumber(exec), args[1].toNumber(exec), args[2].toNumber(exec), args[3].toNumber(exec))->cache(exec); + case SVGPathElementImpl::CreateSVGPathSegCurvetoQuadraticRel: + return obj->createSVGPathSegCurvetoQuadraticRel(args[0].toNumber(exec), args[1].toNumber(exec), args[2].toNumber(exec), args[3].toNumber(exec))->cache(exec); + case SVGPathElementImpl::CreateSVGPathSegArcAbs: + return obj->createSVGPathSegArcAbs(args[0].toNumber(exec), args[1].toNumber(exec), args[2].toNumber(exec), args[3].toNumber(exec), args[4].toNumber(exec), args[5].toBoolean(exec), args[6].toBoolean(exec))->cache(exec); + case SVGPathElementImpl::CreateSVGPathSegArcRel: + return obj->createSVGPathSegArcRel(args[0].toNumber(exec), args[1].toNumber(exec), args[2].toNumber(exec), args[3].toNumber(exec), args[4].toNumber(exec), args[5].toBoolean(exec), args[6].toBoolean(exec))->cache(exec); + case SVGPathElementImpl::CreateSVGPathSegLinetoHorizontalAbs: + return obj->createSVGPathSegLinetoHorizontalAbs(args[0].toNumber(exec))->cache(exec); + case SVGPathElementImpl::CreateSVGPathSegLinetoHorizontalRel: + return obj->createSVGPathSegLinetoHorizontalRel(args[0].toNumber(exec))->cache(exec); + case SVGPathElementImpl::CreateSVGPathSegLinetoVerticalAbs: + return obj->createSVGPathSegLinetoVerticalAbs(args[0].toNumber(exec))->cache(exec); + case SVGPathElementImpl::CreateSVGPathSegLinetoVerticalRel: + return obj->createSVGPathSegLinetoVerticalRel(args[0].toNumber(exec))->cache(exec); + case SVGPathElementImpl::CreateSVGPathSegCurvetoCubicSmoothAbs: + return obj->createSVGPathSegCurvetoCubicSmoothAbs(args[0].toNumber(exec), args[1].toNumber(exec), args[2].toNumber(exec), args[3].toNumber(exec))->cache(exec); + case SVGPathElementImpl::CreateSVGPathSegCurvetoCubicSmoothRel: + return obj->createSVGPathSegCurvetoCubicSmoothRel(args[0].toNumber(exec), args[1].toNumber(exec), args[2].toNumber(exec), args[3].toNumber(exec))->cache(exec); + case SVGPathElementImpl::CreateSVGPathSegCurvetoQuadraticSmoothAbs: + return obj->createSVGPathSegCurvetoQuadraticSmoothAbs(args[0].toNumber(exec), args[1].toNumber(exec))->cache(exec); + case SVGPathElementImpl::CreateSVGPathSegCurvetoQuadraticSmoothRel: + return obj->createSVGPathSegCurvetoQuadraticSmoothRel(args[0].toNumber(exec), args[1].toNumber(exec))->cache(exec); + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return Undefined(); +} + +SVGRectImpl *SVGPathElementImpl::getBBox() +{ + SVGRectImpl *ret = SVGSVGElementImpl::createSVGRect(); + + if(m_item) + { + T2P::BezierPath *path = ownerDoc()->canvas()->toBezierPath(m_item); + if(path) + { + T2P::Point topLeft; + T2P::Point bottomRight; + + path->boundingBox(&topLeft, &bottomRight); + + ret->setX(topLeft.x()); + ret->setY(topLeft.y()); + ret->setWidth(bottomRight.x() - topLeft.x()); + ret->setHeight(bottomRight.y() - topLeft.y()); + } + } + return ret; +} + +void SVGPathElementImpl::createItem(KSVGCanvas *c) +{ + if(!c) + c = ownerDoc()->canvas(); + + if(!m_item) + { + // TODO : this is a quick fix for this problem: + // d attribute encountered before marker attributes. + // Try to process the attributes in the right order, ie. + // d attr processing should be last. + if(hasMarkers() && m_markerData.numMarkers() == 0) + m_markerData = MarkerData(pathSegList()); + m_item = c->createPath(this); + c->insert(m_item); + } +} + +SVGPathElementImpl::MarkerData::MarkerData(SVGPathSegListImpl *path) +{ + unsigned int numSegments = path->numberOfItems(); + double curx = 0; + double cury = 0; + int currentSubpathStartIndex = -1; + double previousQuadraticX1 = 0; + double previousQuadraticY1 = 0; + double previousCubicX2 = 0; + double previousCubicY2 = 0; + + QValueVector<SegmentData> pathSegmentData(numSegments); + + for(unsigned int i = 0; i < numSegments; i++) + { + SVGPathSegImpl *segment = path->getItem(i); + struct SegmentData data; + + data.type = segment->pathSegType(); + + if(segment->pathSegType() == PATHSEG_MOVETO_ABS || segment->pathSegType() == PATHSEG_MOVETO_REL) + { + if(currentSubpathStartIndex >= 0) + { + // Finish the previous subpath. + for(unsigned int j = currentSubpathStartIndex; j < i; j++) + { + pathSegmentData[j].subpathStartIndex = currentSubpathStartIndex; + pathSegmentData[j].subpathEndIndex = i - 1; + pathSegmentData[j].subpathIsClosed = false; + } + } + + currentSubpathStartIndex = i; + } + else if(segment->pathSegType() == PATHSEG_CLOSEPATH) + { + if(currentSubpathStartIndex >= 0) + { + SVGPathSegClosePathImpl *s = static_cast<SVGPathSegClosePathImpl *>(segment); + + s->setX(pathSegmentData[currentSubpathStartIndex].startx + pathSegmentData[currentSubpathStartIndex].dx); + s->setY(pathSegmentData[currentSubpathStartIndex].starty + pathSegmentData[currentSubpathStartIndex].dy); + + for(unsigned int j = currentSubpathStartIndex; j < i; j++) + { + pathSegmentData[j].subpathStartIndex = currentSubpathStartIndex; + pathSegmentData[j].subpathEndIndex = i; + pathSegmentData[j].subpathIsClosed = true; + } + + data.subpathStartIndex = currentSubpathStartIndex; + data.subpathEndIndex = i; + data.subpathIsClosed = true; + } + + currentSubpathStartIndex = i + 1; + } + + switch(segment->pathSegType()) + { + case PATHSEG_CURVETO_CUBIC_ABS: + { + SVGPathSegCurvetoCubicAbsImpl *s = static_cast<SVGPathSegCurvetoCubicAbsImpl *>(segment); + previousCubicX2 = s->x2(); + previousCubicY2 = s->y2(); + break; + } + case PATHSEG_CURVETO_CUBIC_REL: + { + SVGPathSegCurvetoCubicRelImpl *s = static_cast<SVGPathSegCurvetoCubicRelImpl *>(segment); + previousCubicX2 = curx + s->x2(); + previousCubicY2 = cury + s->y2(); + break; + } + case PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: + { + SVGPathSegCurvetoCubicSmoothAbsImpl *s = static_cast<SVGPathSegCurvetoCubicSmoothAbsImpl *>(segment); + s->setPreviousX2(previousCubicX2); + s->setPreviousY2(previousCubicY2); + previousCubicX2 = s->x2(); + previousCubicY2 = s->y2(); + break; + } + case PATHSEG_CURVETO_CUBIC_SMOOTH_REL: + { + SVGPathSegCurvetoCubicSmoothRelImpl *s = static_cast<SVGPathSegCurvetoCubicSmoothRelImpl *>(segment); + s->setPreviousAbsX2(previousCubicX2); + s->setPreviousAbsY2(previousCubicY2); + previousCubicX2 = curx + s->x2(); + previousCubicY2 = cury + s->y2(); + break; + } + case PATHSEG_CURVETO_QUADRATIC_ABS: + { + SVGPathSegCurvetoQuadraticAbsImpl *s = static_cast<SVGPathSegCurvetoQuadraticAbsImpl *>(segment); + previousQuadraticX1 = s->x1(); + previousQuadraticY1 = s->y1(); + break; + } + case PATHSEG_CURVETO_QUADRATIC_REL: + { + SVGPathSegCurvetoQuadraticRelImpl *s = static_cast<SVGPathSegCurvetoQuadraticRelImpl *>(segment); + previousQuadraticX1 = curx + s->x1(); + previousQuadraticY1 = cury + s->y1(); + break; + } + case PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: + { + SVGPathSegCurvetoQuadraticSmoothAbsImpl *s = static_cast<SVGPathSegCurvetoQuadraticSmoothAbsImpl *>(segment); + s->setPreviousX1(previousQuadraticX1); + s->setPreviousY1(previousQuadraticY1); + previousQuadraticX1 = s->x1(curx); + previousQuadraticY1 = s->y1(cury); + break; + } + case PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: + { + SVGPathSegCurvetoQuadraticSmoothRelImpl *s = static_cast<SVGPathSegCurvetoQuadraticSmoothRelImpl *>(segment); + s->setPreviousAbsX1(previousQuadraticX1); + s->setPreviousAbsY1(previousQuadraticY1); + previousQuadraticX1 = s->absX1(curx); + previousQuadraticY1 = s->absY1(cury); + break; + } + default: + previousCubicX2 = curx; + previousCubicY2 = cury; + previousQuadraticX1 = curx; + previousQuadraticY1 = cury; + break; + } + + data.startx = curx; + data.starty = cury; + + segment->getDeltasAndSlopes(curx, cury, &data.dx, &data.dy, &data.startSlope, &data.endSlope); + + pathSegmentData[i] = data; + + curx += data.dx; + cury += data.dy; + } + + if(currentSubpathStartIndex >= 0) + { + // Finish the previous subpath. + for(unsigned int j = currentSubpathStartIndex; j < numSegments; j++) + { + pathSegmentData[j].subpathStartIndex = currentSubpathStartIndex; + pathSegmentData[j].subpathEndIndex = numSegments - 1; + pathSegmentData[j].subpathIsClosed = false; + } + } + + m_markers.resize(numSegments); + + for(unsigned int i = 0; i < numSegments; i++) + { + struct Marker marker; + + marker.x = pathSegmentData[i].startx + pathSegmentData[i].dx; + marker.y = pathSegmentData[i].starty + pathSegmentData[i].dy; + + double inSlope; + double outSlope; + bool haveInSlope = false; + bool haveOutSlope = false; + + if(pathSegmentData[i].subpathStartIndex == i && pathSegmentData[i].subpathIsClosed) + { + // Spec: For closed subpaths, the marker for the initial vertex uses the end direction + // of the corresponding closepath for its incoming slope and the first segment's + // start slope for its outgoing slope. + haveInSlope = getEndSlope(pathSegmentData, pathSegmentData[i].subpathEndIndex, &inSlope); + haveOutSlope = getStartSlope(pathSegmentData, i + 1, &outSlope); + } + else if(pathSegmentData[i].type == PATHSEG_CLOSEPATH) + { + haveInSlope = getEndSlope(pathSegmentData, i, &inSlope); + + // Spec: If the segment following a closepath is other than a moveto, the marker + // for the closepath uses the following segment's start direction as its + // outgoing direction. + if(i + 1 < numSegments && (pathSegmentData[i + 1].type != PATHSEG_MOVETO_ABS && pathSegmentData[i + 1].type != PATHSEG_MOVETO_REL)) + haveOutSlope = getStartSlope(pathSegmentData, i + 1, &outSlope); + else + haveOutSlope = getStartSlope(pathSegmentData, pathSegmentData[i].subpathStartIndex, &outSlope); + } + else + { + haveOutSlope = getStartSlope(pathSegmentData, i + 1, &outSlope); + haveInSlope = getEndSlope(pathSegmentData, i, &inSlope); + } + + if(!haveInSlope && !haveOutSlope) + { + outSlope = 0; + inSlope = 0; + } + else if(haveInSlope && !haveOutSlope) + outSlope = inSlope; + else if(!haveInSlope && haveOutSlope) + inSlope = outSlope; + + double bisector = SVGAngleImpl::shortestArcBisector(inSlope, outSlope); + marker.angle = bisector; + + m_markers[i] = marker; + } +} + +bool SVGPathElementImpl::MarkerData::getStartSlope(QValueVector<SegmentData> segments, unsigned int i, double *pStartSlope) +{ + if(i > segments.count() - 1 || segments[i].type == PATHSEG_MOVETO_ABS || segments[i].type == PATHSEG_MOVETO_REL) + return false; + else + { + const double epsilon = DBL_EPSILON; + + if(fabs(segments[i].dx) > epsilon || fabs(segments[i].dy) > epsilon) + { + *pStartSlope = segments[i].startSlope; + return true; + } + else + { + int subpathStartIndex = segments[i].subpathStartIndex; + + for(int j = i - 1; j >= subpathStartIndex; j--) + { + if(segments[j].type == PATHSEG_MOVETO_ABS || segments[j].type == PATHSEG_MOVETO_REL) + return false; + + if(fabs(segments[j].dx) > epsilon || fabs(segments[j].dy) > epsilon) + { + *pStartSlope = segments[j].endSlope; + return true; + } + } + + return false; + } + } +} + +bool SVGPathElementImpl::MarkerData::getEndSlope(QValueVector<SegmentData> segments, unsigned int i, double *pEndSlope) +{ + if(i > segments.count() - 1 || segments[i].type == PATHSEG_MOVETO_ABS || segments[i].type == PATHSEG_MOVETO_REL) + return false; + else + { + const double epsilon = DBL_EPSILON; + + if(fabs(segments[i].dx) > epsilon || fabs(segments[i].dy) > epsilon) + { + *pEndSlope = segments[i].endSlope; + return true; + } + else + { + int subpathEndIndex = segments[i].subpathEndIndex; + + for(int j = i + 1; j <= subpathEndIndex; j++) + { + if(segments[j].type == PATHSEG_MOVETO_ABS || segments[j].type == PATHSEG_MOVETO_REL) + return false; + + if(fabs(segments[j].dx) > epsilon || fabs(segments[j].dy) > epsilon) + { + *pEndSlope = segments[j].startSlope; + return true; + } + } + + return false; + } + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathElementImpl.h b/ksvg/impl/SVGPathElementImpl.h new file mode 100644 index 00000000..a9af56fc --- /dev/null +++ b/ksvg/impl/SVGPathElementImpl.h @@ -0,0 +1,194 @@ +/* + 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. +*/ + +#ifndef SVGPathElementImpl_H +#define SVGPathElementImpl_H + +#include <qvaluevector.h> + +#include "svgpathparser.h" + +#include "ksvg_lookup.h" + +#include "SVGShapeImpl.h" +#include "SVGTestsImpl.h" +#include "SVGStylableImpl.h" +#include "SVGLangSpaceImpl.h" +#include "SVGTransformableImpl.h" +#include "SVGAnimatedPathDataImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + +namespace KSVG +{ + +class SVGPointImpl; +class SVGPathSegImpl; +class SVGPathSegArcAbsImpl; +class SVGPathSegArcRelImpl; +class SVGAnimatedNumberImpl; +class SVGPathSegClosePathImpl; +class SVGPathSegLinetoAbsImpl; +class SVGPathSegLinetoRelImpl; +class SVGPathSegMovetoAbsImpl; +class SVGPathSegMovetoRelImpl; +class SVGPathSegCurvetoCubicAbsImpl; +class SVGPathSegCurvetoCubicRelImpl; +class SVGPathSegLinetoVerticalAbsImpl; +class SVGPathSegLinetoVerticalRelImpl; +class SVGPathSegLinetoHorizontalAbsImpl; +class SVGPathSegLinetoHorizontalRelImpl; +class SVGPathSegCurvetoQuadraticAbsImpl; +class SVGPathSegCurvetoQuadraticRelImpl; +class SVGPathSegCurvetoCubicSmoothAbsImpl; +class SVGPathSegCurvetoCubicSmoothRelImpl; +class SVGPathSegCurvetoQuadraticSmoothAbsImpl; +class SVGPathSegCurvetoQuadraticSmoothRelImpl; +class SVGPathElementImpl : public SVGShapeImpl, + public SVGTestsImpl, + public SVGLangSpaceImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl, + public SVGTransformableImpl, + public SVGAnimatedPathDataImpl, + public ::SVGPathParser +{ +public: + SVGPathElementImpl(DOM::ElementImpl *impl); + virtual ~SVGPathElementImpl(); + + SVGAnimatedNumberImpl *pathLength() const; + double getTotalLength(); + SVGPointImpl *getPointAtLength(double distance); + unsigned long getPathSegAtLength(double distance); + + SVGPathSegClosePathImpl *createSVGPathSegClosePath(); + SVGPathSegMovetoAbsImpl *createSVGPathSegMovetoAbs(double x, double y); + SVGPathSegMovetoRelImpl *createSVGPathSegMovetoRel(double x, double y); + SVGPathSegLinetoAbsImpl *createSVGPathSegLinetoAbs(double x, double y); + SVGPathSegLinetoRelImpl *createSVGPathSegLinetoRel(double x, double y); + SVGPathSegCurvetoCubicAbsImpl *createSVGPathSegCurvetoCubicAbs(double x, double y, double x1, double y1, double x2, double y2); + SVGPathSegCurvetoCubicRelImpl *createSVGPathSegCurvetoCubicRel(double x, double y, double x1, double y1, double x2, double y2); + SVGPathSegCurvetoQuadraticAbsImpl *createSVGPathSegCurvetoQuadraticAbs(double x, double y, double x1, double y1); + SVGPathSegCurvetoQuadraticRelImpl *createSVGPathSegCurvetoQuadraticRel(double x, double y, double x1, double y1); + SVGPathSegArcAbsImpl *createSVGPathSegArcAbs(double x, double y, double r1, double r2, double angle, bool largeArcFlag, bool sweepFlag); + SVGPathSegArcRelImpl *createSVGPathSegArcRel(double x, double y, double r1, double r2, double angle, bool largeArcFlag, bool sweepFlag); + SVGPathSegLinetoHorizontalAbsImpl *createSVGPathSegLinetoHorizontalAbs(double x); + SVGPathSegLinetoHorizontalRelImpl *createSVGPathSegLinetoHorizontalRel(double x); + SVGPathSegLinetoVerticalAbsImpl *createSVGPathSegLinetoVerticalAbs(double y); + SVGPathSegLinetoVerticalRelImpl *createSVGPathSegLinetoVerticalRel(double y); + SVGPathSegCurvetoCubicSmoothAbsImpl *createSVGPathSegCurvetoCubicSmoothAbs(double x, double y, double x2, double y2); + SVGPathSegCurvetoCubicSmoothRelImpl *createSVGPathSegCurvetoCubicSmoothRel(double x, double y, double x2, double y2); + SVGPathSegCurvetoQuadraticSmoothAbsImpl *createSVGPathSegCurvetoQuadraticSmoothAbs(double x, double y); + SVGPathSegCurvetoQuadraticSmoothRelImpl *createSVGPathSegCurvetoQuadraticSmoothRel(double x, double y); + + virtual void createItem(KSVGCanvas *c = 0); + + virtual SVGRectImpl *getBBox(); + + class MarkerData + { + public: + struct Marker + { + double x; + double y; + double angle; + }; + + MarkerData() {} + MarkerData(SVGPathSegListImpl *path); + + const Marker& marker(unsigned int i) const { return m_markers[i]; } + unsigned int numMarkers() const { return m_markers.count(); } + + private: + struct SegmentData + { + double startx; + double starty; + double dx; + double dy; + double startSlope; + double endSlope; + unsigned int subpathStartIndex; + unsigned int subpathEndIndex; + bool subpathIsClosed; + int type; + }; + + static bool getStartSlope(QValueVector<SegmentData> segments, unsigned int i, double *pStartSlope); + static bool getEndSlope(QValueVector<SegmentData> segments, unsigned int i, double *pEndSlope); + + QValueVector<Marker> m_markers; + }; + + MarkerData markerData() const { return m_markerData; } + +private: + SVGAnimatedNumberImpl *m_pathLength; + MarkerData m_markerData; + + virtual void svgMoveTo(double x1, double y1, bool closed, bool abs = true); + virtual void svgLineTo(double x1, double y1, bool abs = true); + virtual void svgLineToHorizontal(double x, bool abs = true); + virtual void svgLineToVertical(double y, bool abs = true); + virtual void svgCurveToCubic(double x1, double y1, double x2, double y2, double x, double y, bool abs = true); + virtual void svgCurveToCubicSmooth(double x, double y, double x2, double y2, bool abs = true); + virtual void svgCurveToQuadratic(double x, double y, double x1, double y1, bool abs = true); + virtual void svgCurveToQuadraticSmooth(double x, double y, bool abs = true); + virtual void svgArcTo(double x, double y, double r1, double r2, double angle, bool largeArcFlag, bool sweepFlag, bool abs = true); + virtual void svgClosePath(); + +public: + KSVG_GET + KSVG_PUT + KSVG_BRIDGE + + enum + { + // Properties + D, PathLength, + // Functions + GetTotalLength, GetPointAtLength, GetPathSegAtLength, + CreateSVGPathSegClosePath, CreateSVGPathSegMovetoAbs, CreateSVGPathSegMovetoRel, + CreateSVGPathSegLinetoAbs, CreateSVGPathSegLinetoRel, CreateSVGPathSegCurvetoCubicAbs, + CreateSVGPathSegCurvetoCubicRel, CreateSVGPathSegCurvetoQuadraticAbs, + CreateSVGPathSegCurvetoQuadraticRel, CreateSVGPathSegArcAbs, + CreateSVGPathSegArcRel, CreateSVGPathSegLinetoHorizontalAbs, + CreateSVGPathSegLinetoHorizontalRel, CreateSVGPathSegLinetoVerticalAbs, + CreateSVGPathSegLinetoVerticalRel, CreateSVGPathSegCurvetoCubicSmoothAbs, + CreateSVGPathSegCurvetoCubicSmoothRel, CreateSVGPathSegCurvetoQuadraticSmoothAbs, + CreateSVGPathSegCurvetoQuadraticSmoothRel + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +KSVG_REGISTER_ELEMENT(SVGPathElementImpl, "path") + +} + +KSVG_DEFINE_PROTOTYPE(SVGPathElementImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGPathElementImplProtoFunc, SVGPathElementImpl) + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegArcImpl.cc b/ksvg/impl/SVGPathSegArcImpl.cc new file mode 100644 index 00000000..9fb4190f --- /dev/null +++ b/ksvg/impl/SVGPathSegArcImpl.cc @@ -0,0 +1,495 @@ +/* + 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 <math.h> + +#include <kdebug.h> + +#include "SVGPathSegArcImpl.h" +#include "SVGAngleImpl.h" + +using namespace KSVG; + +#include "SVGPathSegArcImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +static void getArcSlopes(bool relative, double curx, double cury, double angle, double x, double y, double r1, double r2, bool largeArcFlag, bool sweepFlag, double *pStartSlope, double *pEndSlope) +{ + double sin_th, cos_th; + double a00, a01, a10, a11; + double x0, y0, x1, y1, xc, yc; + double d, sfactor, sfactor_sq; + double th0, th1, th_arc; + int i, n_segs; + + sin_th = sin(angle * (M_PI / 180.0)); + cos_th = cos(angle * (M_PI / 180.0)); + + double dx; + + if(!relative) + dx = (curx - x) / 2.0; + else + dx = -x / 2.0; + + double dy; + + if(!relative) + dy = (cury - y) / 2.0; + else + dy = -y / 2.0; + + double _x1 = cos_th * dx + sin_th * dy; + double _y1 = -sin_th * dx + cos_th * dy; + double Pr1 = r1 * r1; + double Pr2 = r2 * r2; + double Px = _x1 * _x1; + double Py = _y1 * _y1; + + // Spec : check if radii are large enough + double check = Px / Pr1 + Py / Pr2; + if(check > 1) + { + r1 = r1 * sqrt(check); + r2 = r2 * sqrt(check); + } + + a00 = cos_th / r1; + a01 = sin_th / r1; + a10 = -sin_th / r2; + a11 = cos_th / r2; + + x0 = a00 * curx + a01 * cury; + y0 = a10 * curx + a11 * cury; + + if(!relative) + x1 = a00 * x + a01 * y; + else + x1 = a00 * (curx + x) + a01 * (cury + y); + + if(!relative) + y1 = a10 * x + a11 * y; + else + y1 = a10 * (curx + x) + a11 * (cury + y); + + /* (x0, y0) is current point in transformed coordinate space. + (x1, y1) is new point in transformed coordinate space. + + The arc fits a unit-radius circle in this space. + */ + + d = (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0); + + sfactor_sq = 1.0 / d - 0.25; + + if(sfactor_sq < 0) + sfactor_sq = 0; + + sfactor = sqrt(sfactor_sq); + + if(sweepFlag == largeArcFlag) + sfactor = -sfactor; + + xc = 0.5 * (x0 + x1) - sfactor * (y1 - y0); + yc = 0.5 * (y0 + y1) + sfactor * (x1 - x0); + + /* (xc, yc) is center of the circle. */ + th0 = atan2(y0 - yc, x0 - xc); + th1 = atan2(y1 - yc, x1 - xc); + + th_arc = th1 - th0; + if(th_arc < 0 && sweepFlag) + th_arc += 2 * M_PI; + else if(th_arc > 0 && !sweepFlag) + th_arc -= 2 * M_PI; + + n_segs = (int) (int) ceil(fabs(th_arc / (M_PI * 0.5 + 0.001))); + + for(int step = 0; step < 2; step++) + { + i = step == 0 ? 0 : n_segs - 1; + + double sin_th, cos_th; + double a00, a01, a10, a11; + double x1, y1, x2, y2, x3, y3; + double t; + double th_half; + + double _th0 = th0 + i * th_arc / n_segs; + double _th1 = th0 + (i + 1) * th_arc / n_segs; + + sin_th = sin(angle * (M_PI / 180.0)); + cos_th = cos(angle * (M_PI / 180.0)); + + /* inverse transform compared with rsvg_path_arc */ + a00 = cos_th * r1; + a01 = -sin_th * r2; + a10 = sin_th * r1; + a11 = cos_th * r2; + + th_half = 0.5 * (_th1 - _th0); + t = (8.0 / 3.0) * sin(th_half * 0.5) * sin(th_half * 0.5) / sin(th_half); + x1 = xc + cos(_th0) - t * sin(_th0); + y1 = yc + sin(_th0) + t * cos(_th0); + x3 = xc + cos(_th1); + y3 = yc + sin(_th1); + x2 = x3 + t * sin(_th1); + y2 = y3 - t * cos(_th1); + + double bezX1 = a00 * x1 + a01 * y1; + double bezY1 = a10 * x1 + a11 * y1; + double bezX2 = a00 * x2 + a01 * y2; + double bezY2 = a10 * x2 + a11 * y2; + double bezX = a00 * x3 + a01 * y3; + double bezY = a10 * x3 + a11 * y3; + + if(step == 0) + *pStartSlope = SVGAngleImpl::todeg(atan2(bezY1 - cury, bezX1 - curx)); + else + *pEndSlope = SVGAngleImpl::todeg(atan2(bezY - bezY2, bezX - bezX2)); + } +} + +SVGPathSegArcAbsImpl::SVGPathSegArcAbsImpl() : SVGPathSegImpl() +{ + KSVG_EMPTY_FLAGS +} + +SVGPathSegArcAbsImpl::~SVGPathSegArcAbsImpl() +{ +} + +void SVGPathSegArcAbsImpl::setX(double x) +{ + m_x = x; +} + +double SVGPathSegArcAbsImpl::x() const +{ + return m_x; +} + +void SVGPathSegArcAbsImpl::setY(double y) +{ + m_y = y; +} + +double SVGPathSegArcAbsImpl::y() const +{ + return m_y; +} + +void SVGPathSegArcAbsImpl::setR1(double r1) +{ + m_r1 = r1; +} + +double SVGPathSegArcAbsImpl::r1() const +{ + return m_r1; +} + +void SVGPathSegArcAbsImpl::setR2(double r2) +{ + m_r2 = r2; +} + +double SVGPathSegArcAbsImpl::r2() const +{ + return m_r2; +} + +void SVGPathSegArcAbsImpl::setAngle(double angle) +{ + m_angle = angle; +} + +double SVGPathSegArcAbsImpl::angle() const +{ + return m_angle; +} + +void SVGPathSegArcAbsImpl::setLargeArcFlag(bool largeArcFlag) +{ + m_largeArcFlag = largeArcFlag; +} + +bool SVGPathSegArcAbsImpl::largeArcFlag() const +{ + return m_largeArcFlag; +} + +void SVGPathSegArcAbsImpl::setSweepFlag(bool sweepFlag) +{ + m_sweepFlag = sweepFlag; +} + +bool SVGPathSegArcAbsImpl::sweepFlag() const +{ + return m_sweepFlag; +} + +void SVGPathSegArcAbsImpl::getDeltasAndSlopes(double curx, double cury, double *pDx, double *pDy, double *pStartSlope, double *pEndSlope) const +{ + double dx = x() - curx; + double dy = y() - cury; + double startSlope; + double endSlope; + getArcSlopes(false, curx, cury, angle(), x(), y(), r1(), r2(), largeArcFlag(), sweepFlag(), &startSlope, &endSlope); + *pDx = dx; + *pDy = dy; + *pStartSlope = startSlope; + *pEndSlope = endSlope; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPathSegArcAbsImpl::s_hashTable 11 + x SVGPathSegArcAbsImpl::X DontDelete + y SVGPathSegArcAbsImpl::Y DontDelete + r1 SVGPathSegArcAbsImpl::R1 DontDelete + r2 SVGPathSegArcAbsImpl::R2 DontDelete + angle SVGPathSegArcAbsImpl::Angle DontDelete + largeArcFlag SVGPathSegArcAbsImpl::LargeArcFlag DontDelete + sweepFlag SVGPathSegArcAbsImpl::SweepFlag DontDelete +@end +*/ + +Value SVGPathSegArcAbsImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case X: + return Number(x()); + case Y: + return Number(y()); + case R1: + return Number(r1()); + case R2: + return Number(r2()); + case Angle: + return Number(angle()); + case LargeArcFlag: + return Boolean(largeArcFlag()); + case SweepFlag: + return Boolean(sweepFlag()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGPathSegArcAbsImpl::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case X: + m_x = value.toNumber(exec); + break; + case Y: + m_y = value.toNumber(exec); + break; + case R1: + m_r1 = value.toNumber(exec); + break; + case R2: + m_r2 = value.toNumber(exec); + break; + case Angle: + m_angle = value.toNumber(exec); + break; + case LargeArcFlag: + m_largeArcFlag = value.toBoolean(exec); + break; + case SweepFlag: + m_sweepFlag = value.toBoolean(exec); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + + + +SVGPathSegArcRelImpl::SVGPathSegArcRelImpl() : SVGPathSegImpl() +{ + KSVG_EMPTY_FLAGS +} + +SVGPathSegArcRelImpl::~SVGPathSegArcRelImpl() +{ +} + +void SVGPathSegArcRelImpl::setX(double x) +{ + m_x = x; +} + +double SVGPathSegArcRelImpl::x() const +{ + return m_x; +} + +void SVGPathSegArcRelImpl::setY(double y) +{ + m_y = y; +} + +double SVGPathSegArcRelImpl::y() const +{ + return m_y; +} + +void SVGPathSegArcRelImpl::setR1(double r1) +{ + m_r1 = r1; +} + +double SVGPathSegArcRelImpl::r1() const +{ + return m_r1; +} + +void SVGPathSegArcRelImpl::setR2(double r2) +{ + m_r2 = r2; +} + +double SVGPathSegArcRelImpl::r2() const +{ + return m_r2; +} + +void SVGPathSegArcRelImpl::setAngle(double angle) +{ + m_angle = angle; +} + +double SVGPathSegArcRelImpl::angle() const +{ + return m_angle; +} + +void SVGPathSegArcRelImpl::setLargeArcFlag(bool largeArcFlag) +{ + m_largeArcFlag = largeArcFlag; +} + +bool SVGPathSegArcRelImpl::largeArcFlag() const +{ + return m_largeArcFlag; +} + +void SVGPathSegArcRelImpl::setSweepFlag(bool sweepFlag) +{ + m_sweepFlag = sweepFlag; +} + +bool SVGPathSegArcRelImpl::sweepFlag() const +{ + return m_sweepFlag; +} + +void SVGPathSegArcRelImpl::getDeltasAndSlopes(double curx, double cury, double *pDx, double *pDy, double *pStartSlope, double *pEndSlope) const +{ + double dx = x(); + double dy = y(); + double startSlope; + double endSlope; + getArcSlopes(true, curx, cury, angle(), x(), y(), r1(), r2(), largeArcFlag(), sweepFlag(), &startSlope, &endSlope); + *pDx = dx; + *pDy = dy; + *pStartSlope = startSlope; + *pEndSlope = endSlope; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPathSegArcRelImpl::s_hashTable 11 + x SVGPathSegArcRelImpl::X DontDelete + y SVGPathSegArcRelImpl::Y DontDelete + r1 SVGPathSegArcRelImpl::R1 DontDelete + r2 SVGPathSegArcRelImpl::R2 DontDelete + angle SVGPathSegArcRelImpl::Angle DontDelete + largeArcFlag SVGPathSegArcRelImpl::LargeArcFlag DontDelete + sweepFlag SVGPathSegArcRelImpl::SweepFlag DontDelete +@end +*/ + +Value SVGPathSegArcRelImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case X: + return Number(x()); + case Y: + return Number(y()); + case R1: + return Number(r1()); + case R2: + return Number(r2()); + case Angle: + return Number(angle()); + case LargeArcFlag: + return Boolean(largeArcFlag()); + case SweepFlag: + return Boolean(sweepFlag()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGPathSegArcRelImpl::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case X: + m_x = value.toNumber(exec); + break; + case Y: + m_y = value.toNumber(exec); + break; + case R1: + m_r1 = value.toNumber(exec); + break; + case R2: + m_r2 = value.toNumber(exec); + break; + case Angle: + m_angle = value.toNumber(exec); + break; + case LargeArcFlag: + m_largeArcFlag = value.toBoolean(exec); + break; + case SweepFlag: + m_sweepFlag = value.toBoolean(exec); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegArcImpl.h b/ksvg/impl/SVGPathSegArcImpl.h new file mode 100644 index 00000000..f0e375d6 --- /dev/null +++ b/ksvg/impl/SVGPathSegArcImpl.h @@ -0,0 +1,150 @@ +/* + 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. +*/ + +#ifndef SVGPathSegArcImpl_H +#define SVGPathSegArcImpl_H + +#include "ksvg_lookup.h" + +#include "SVGPathSegImpl.h" + +namespace KSVG +{ + +class SVGPathSegArcAbsImpl : public SVGPathSegImpl +{ +public: + SVGPathSegArcAbsImpl(); + virtual ~SVGPathSegArcAbsImpl(); + + virtual unsigned short pathSegType() const { return PATHSEG_ARC_ABS; } + virtual DOM::DOMString pathSegTypeAsLetter() const { return "A"; } + virtual QString toString() const { return QString("A %1 %2 %3 %4 %5 %6 %7").arg(m_r1).arg(m_r2).arg(m_angle).arg(m_largeArcFlag).arg(m_sweepFlag).arg(m_x).arg(m_y); } + + void setX(double x); + double x() const; + + void setY(double y); + double y() const; + + void setR1(double r1); + double r1() const; + + void setR2(double r2); + double r2() const; + + void setAngle(double angle); + double angle() const; + + void setLargeArcFlag(bool largeArcFlag); + bool largeArcFlag() const; + + void setSweepFlag(bool sweepFlag); + bool sweepFlag() const; + + virtual void getDeltasAndSlopes(double curx, double cury, double *dx, double *dy, double *startSlope, double *endSlope) const; + +private: + double m_x; + double m_y; + double m_r1; + double m_r2; + double m_angle; + + bool m_largeArcFlag : 1; + bool m_sweepFlag : 1; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + X, Y, R1, R2, Angle, LargeArcFlag, SweepFlag + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + + +class SVGPathSegArcRelImpl : public SVGPathSegImpl +{ +public: + SVGPathSegArcRelImpl(); + virtual ~SVGPathSegArcRelImpl(); + + virtual unsigned short pathSegType() const { return PATHSEG_ARC_REL; } + virtual DOM::DOMString pathSegTypeAsLetter() const { return "a"; } + virtual QString toString() const { return QString("a %1 %2 %3 %4 %5 %6 %7").arg(m_r1).arg(m_r2).arg(m_angle).arg(m_largeArcFlag).arg(m_sweepFlag).arg(m_x).arg(m_y); } + + void setX(double x); + double x() const; + + void setY(double y); + double y() const; + + void setR1(double r1); + double r1() const; + + void setR2(double r2); + double r2() const; + + void setAngle(double angle); + double angle() const; + + void setLargeArcFlag(bool largeArcFlag); + bool largeArcFlag() const; + + void setSweepFlag(bool sweepFlag); + bool sweepFlag() const; + + virtual void getDeltasAndSlopes(double curx, double cury, double *dx, double *dy, double *startSlope, double *endSlope) const; + +private: + double m_x; + double m_y; + double m_r1; + double m_r2; + double m_angle; + + bool m_largeArcFlag : 1; + bool m_sweepFlag : 1; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + X, Y, R1, R2, Angle, LargeArcFlag, SweepFlag + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegClosePathImpl.cc b/ksvg/impl/SVGPathSegClosePathImpl.cc new file mode 100644 index 00000000..c18e6027 --- /dev/null +++ b/ksvg/impl/SVGPathSegClosePathImpl.cc @@ -0,0 +1,46 @@ +/* + 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 "SVGPathSegClosePathImpl.h" +#include "SVGAngleImpl.h" + +using namespace KSVG; + +SVGPathSegClosePathImpl::SVGPathSegClosePathImpl() : SVGPathSegImpl() +{ +} + +SVGPathSegClosePathImpl::~SVGPathSegClosePathImpl() +{ +} + +void SVGPathSegClosePathImpl::getDeltasAndSlopes(double curx, double cury, double *pdx, double *pdy, double *pstartSlope, double *pendSlope) const +{ + double dx = x() - curx; + double dy = y() - cury; + double startSlope = SVGAngleImpl::todeg(atan2(dy, dx)); + double endSlope = startSlope; + *pdx = dx; + *pdy = dy; + *pstartSlope = startSlope; + *pendSlope = endSlope; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegClosePathImpl.h b/ksvg/impl/SVGPathSegClosePathImpl.h new file mode 100644 index 00000000..c4cf63ce --- /dev/null +++ b/ksvg/impl/SVGPathSegClosePathImpl.h @@ -0,0 +1,61 @@ +/* + 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. +*/ + +#ifndef SVGPathSegClosePathImpl_H +#define SVGPathSegClosePathImpl_H + +#include "ksvg_lookup.h" + +#include "SVGPathSegImpl.h" + +namespace KSVG +{ + +class SVGPathSegClosePathImpl : public SVGPathSegImpl +{ +public: + SVGPathSegClosePathImpl(); + virtual ~SVGPathSegClosePathImpl(); + + virtual unsigned short pathSegType() const { return PATHSEG_CLOSEPATH; } + virtual DOM::DOMString pathSegTypeAsLetter() const { return "Z"; } + virtual QString toString() const { return "Z"; } + + void setX(double x) { m_x = x; } + void setY(double y) { m_y = y; } + + double x() const { return m_x; } + double y() const { return m_y; } + + virtual void getDeltasAndSlopes(double curx, double cury, double *dx, double *dy, double *startSlope, double *endSlope) const; + +private: + double m_x; + double m_y; + +public: + KSVG_FORWARDGET +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegCurvetoCubicImpl.cc b/ksvg/impl/SVGPathSegCurvetoCubicImpl.cc new file mode 100644 index 00000000..468b1fb3 --- /dev/null +++ b/ksvg/impl/SVGPathSegCurvetoCubicImpl.cc @@ -0,0 +1,325 @@ +/* + 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> + +#include "SVGPathSegCurvetoCubicImpl.h" +#include "SVGAngleImpl.h" + +using namespace KSVG; + +#include "SVGPathSegCurvetoCubicImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +SVGPathSegCurvetoCubicAbsImpl::SVGPathSegCurvetoCubicAbsImpl() : SVGPathSegImpl() +{ + KSVG_EMPTY_FLAGS +} + +SVGPathSegCurvetoCubicAbsImpl::~SVGPathSegCurvetoCubicAbsImpl() +{ +} + +void SVGPathSegCurvetoCubicAbsImpl::setX(const double &x) +{ + m_x = x; +} + +double SVGPathSegCurvetoCubicAbsImpl::x() const +{ + return m_x; +} + +void SVGPathSegCurvetoCubicAbsImpl::setY(const double &y) +{ + m_y = y; +} + +double SVGPathSegCurvetoCubicAbsImpl::y() const +{ + return m_y; +} + +void SVGPathSegCurvetoCubicAbsImpl::setX1(const double &x1) +{ + m_x1 = x1; +} + +double SVGPathSegCurvetoCubicAbsImpl::x1() const +{ + return m_x1; +} + +void SVGPathSegCurvetoCubicAbsImpl::setY1(const double &y1) +{ + m_y1 = y1; +} + +double SVGPathSegCurvetoCubicAbsImpl::y1() const +{ + return m_y1; +} + +void SVGPathSegCurvetoCubicAbsImpl::setX2(const double &x2) +{ + m_x2 = x2; +} + +double SVGPathSegCurvetoCubicAbsImpl::x2() const +{ + return m_x2; +} + +void SVGPathSegCurvetoCubicAbsImpl::setY2(const double &y2) +{ + m_y2 = y2; +} + +double SVGPathSegCurvetoCubicAbsImpl::y2() const +{ + return m_y2; +} + +void SVGPathSegCurvetoCubicAbsImpl::getDeltasAndSlopes(double curx, double cury, double *pDx, double *pDy, double *pStartSlope, double *pEndSlope) const +{ + double dx = x() - curx; + double dy = y() - cury; + double startSlope = SVGAngleImpl::todeg(atan2(y1() - cury, x1() - curx)); + double endSlope = SVGAngleImpl::todeg(atan2(y() - y2(), x() - x2())); + *pDx = dx; + *pDy = dy; + *pStartSlope = startSlope; + *pEndSlope = endSlope; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPathSegCurvetoCubicAbsImpl::s_hashTable 7 + x SVGPathSegCurvetoCubicAbsImpl::X DontDelete + y SVGPathSegCurvetoCubicAbsImpl::Y DontDelete + x1 SVGPathSegCurvetoCubicAbsImpl::X1 DontDelete + y1 SVGPathSegCurvetoCubicAbsImpl::Y1 DontDelete + x2 SVGPathSegCurvetoCubicAbsImpl::X2 DontDelete + y2 SVGPathSegCurvetoCubicAbsImpl::Y2 DontDelete +@end +*/ + +Value SVGPathSegCurvetoCubicAbsImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case X: + return Number(x()); + case Y: + return Number(y()); + case X1: + return Number(x1()); + case Y1: + return Number(y1()); + case X2: + return Number(x2()); + case Y2: + return Number(y2()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGPathSegCurvetoCubicAbsImpl::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case X: + m_x = value.toNumber(exec); + break; + case Y: + m_y = value.toNumber(exec); + break; + case X1: + m_x1 = value.toNumber(exec); + break; + case Y1: + m_y1 = value.toNumber(exec); + break; + case X2: + m_x2 = value.toNumber(exec); + break; + case Y2: + m_y2 = value.toNumber(exec); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + + + + +SVGPathSegCurvetoCubicRelImpl::SVGPathSegCurvetoCubicRelImpl() : SVGPathSegImpl() +{ + KSVG_EMPTY_FLAGS +} + +SVGPathSegCurvetoCubicRelImpl::~SVGPathSegCurvetoCubicRelImpl() +{ +} + +void SVGPathSegCurvetoCubicRelImpl::setX(const double &x) +{ + m_x = x; +} + +double SVGPathSegCurvetoCubicRelImpl::x() const +{ + return m_x; +} + +void SVGPathSegCurvetoCubicRelImpl::setY(const double &y) +{ + m_y = y; +} + +double SVGPathSegCurvetoCubicRelImpl::y() const +{ + return m_y; +} + +void SVGPathSegCurvetoCubicRelImpl::setX1(const double &x1) +{ + m_x1 = x1; +} + +double SVGPathSegCurvetoCubicRelImpl::x1() const +{ + return m_x1; +} + +void SVGPathSegCurvetoCubicRelImpl::setY1(const double &y1) +{ + m_y1 = y1; +} + +double SVGPathSegCurvetoCubicRelImpl::y1() const +{ + return m_y1; +} + +void SVGPathSegCurvetoCubicRelImpl::setX2(const double &x2) +{ + m_x2 = x2; +} + +double SVGPathSegCurvetoCubicRelImpl::x2() const +{ + return m_x2; +} + +void SVGPathSegCurvetoCubicRelImpl::setY2(const double &y2) +{ + m_y2 = y2; +} + +double SVGPathSegCurvetoCubicRelImpl::y2() const +{ + return m_y2; +} + +void SVGPathSegCurvetoCubicRelImpl::getDeltasAndSlopes(double curx, double cury, double *pDx, double *pDy, double *pStartSlope, double *pEndSlope) const +{ + Q_UNUSED(curx); + Q_UNUSED(cury); + double dx = x(); + double dy = y(); + double startSlope = SVGAngleImpl::todeg(atan2(y1(), x1())); + double endSlope = SVGAngleImpl::todeg(atan2(y() - y2(), x() - x2())); + *pDx = dx; + *pDy = dy; + *pStartSlope = startSlope; + *pEndSlope = endSlope; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPathSegCurvetoCubicRelImpl::s_hashTable 7 + x SVGPathSegCurvetoCubicRelImpl::X DontDelete + y SVGPathSegCurvetoCubicRelImpl::Y DontDelete + x1 SVGPathSegCurvetoCubicRelImpl::X1 DontDelete + y1 SVGPathSegCurvetoCubicRelImpl::Y1 DontDelete + x2 SVGPathSegCurvetoCubicRelImpl::X2 DontDelete + y2 SVGPathSegCurvetoCubicRelImpl::Y2 DontDelete +@end +*/ + +Value SVGPathSegCurvetoCubicRelImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case X: + return Number(x()); + case Y: + return Number(y()); + case X1: + return Number(x1()); + case Y1: + return Number(y1()); + case X2: + return Number(x2()); + case Y2: + return Number(y2()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGPathSegCurvetoCubicRelImpl::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case X: + m_x = value.toNumber(exec); + break; + case Y: + m_y = value.toNumber(exec); + break; + case X1: + m_x1 = value.toNumber(exec); + break; + case Y1: + m_y1 = value.toNumber(exec); + break; + case X2: + m_x2 = value.toNumber(exec); + break; + case Y2: + m_y2 = value.toNumber(exec); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegCurvetoCubicImpl.h b/ksvg/impl/SVGPathSegCurvetoCubicImpl.h new file mode 100644 index 00000000..8f408f91 --- /dev/null +++ b/ksvg/impl/SVGPathSegCurvetoCubicImpl.h @@ -0,0 +1,139 @@ +/* + 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. +*/ + +#ifndef SVGPathSegCurvetoCubicImpl_H +#define SVGPathSegCurvetoCubicImpl_H + +#include "ksvg_lookup.h" + +#include "SVGPathSegImpl.h" + +namespace KSVG +{ + +class SVGPathSegCurvetoCubicAbsImpl : public SVGPathSegImpl +{ +public: + SVGPathSegCurvetoCubicAbsImpl(); + virtual ~SVGPathSegCurvetoCubicAbsImpl(); + + virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_CUBIC_ABS; } + virtual DOM::DOMString pathSegTypeAsLetter() const { return "C"; } + virtual QString toString() const { return QString("C %1 %2 %3 %4 %5 %6").arg(m_x1).arg(m_y1).arg(m_x2).arg(m_y2).arg(m_x).arg(m_y); } + + void setX(const double &); + double x() const; + + void setY(const double &); + double y() const; + + void setX1(const double &); + double x1() const; + + void setY1(const double &); + double y1() const; + + void setX2(const double &); + double x2() const; + + void setY2(const double &); + double y2() const; + + virtual void getDeltasAndSlopes(double curx, double cury, double *dx, double *dy, double *startSlope, double *endSlope) const; + +private: + double m_x; + double m_y; + double m_x1; + double m_y1; + double m_x2; + double m_y2; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + X, Y, X1, Y1, X2, Y2 + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +class SVGPathSegCurvetoCubicRelImpl : public SVGPathSegImpl +{ +public: + SVGPathSegCurvetoCubicRelImpl(); + virtual ~SVGPathSegCurvetoCubicRelImpl(); + + virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_CUBIC_REL; } + virtual DOM::DOMString pathSegTypeAsLetter() const { return "c"; } + virtual QString toString() const { return QString("c %1 %2 %3 %4 %5 %6").arg(m_x1).arg(m_y1).arg(m_x2).arg(m_y2).arg(m_x).arg(m_y); } + + void setX(const double &); + double x() const; + + void setY(const double &); + double y() const; + + void setX1(const double &); + double x1() const; + + void setY1(const double &); + double y1() const; + + void setX2(const double &); + double x2() const; + + void setY2(const double &); + double y2() const; + + virtual void getDeltasAndSlopes(double curx, double cury, double *dx, double *dy, double *startSlope, double *endSlope) const; + +private: + double m_x; + double m_y; + double m_x1; + double m_y1; + double m_x2; + double m_y2; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + X, Y, X1, Y1, X2, Y2 + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegCurvetoCubicSmoothImpl.cc b/ksvg/impl/SVGPathSegCurvetoCubicSmoothImpl.cc new file mode 100644 index 00000000..1d5c124a --- /dev/null +++ b/ksvg/impl/SVGPathSegCurvetoCubicSmoothImpl.cc @@ -0,0 +1,298 @@ +/* + 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> + +#include "SVGPathSegCurvetoCubicSmoothImpl.h" +#include "SVGAngleImpl.h" + +using namespace KSVG; + +#include "SVGPathSegCurvetoCubicSmoothImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +SVGPathSegCurvetoCubicSmoothAbsImpl::SVGPathSegCurvetoCubicSmoothAbsImpl() : SVGPathSegImpl() +{ + KSVG_EMPTY_FLAGS +} + +SVGPathSegCurvetoCubicSmoothAbsImpl::~SVGPathSegCurvetoCubicSmoothAbsImpl() +{ +} + +void SVGPathSegCurvetoCubicSmoothAbsImpl::setX(const double &x) +{ + m_x = x; +} + +double SVGPathSegCurvetoCubicSmoothAbsImpl::x() const +{ + return m_x; +} + +void SVGPathSegCurvetoCubicSmoothAbsImpl::setY(const double &y) +{ + m_y = y; +} + +double SVGPathSegCurvetoCubicSmoothAbsImpl::y() const +{ + return m_y; +} + +void SVGPathSegCurvetoCubicSmoothAbsImpl::setX2(const double &x2) +{ + m_x2 = x2; +} + +double SVGPathSegCurvetoCubicSmoothAbsImpl::x2() const +{ + return m_x2; +} + +void SVGPathSegCurvetoCubicSmoothAbsImpl::setY2(const double &y2) +{ + m_y2 = y2; +} + +double SVGPathSegCurvetoCubicSmoothAbsImpl::y2() const +{ + return m_y2; +} + +void SVGPathSegCurvetoCubicSmoothAbsImpl::setPreviousX2(double x2) +{ + m_previousX2 = x2; +} + +void SVGPathSegCurvetoCubicSmoothAbsImpl::setPreviousY2(double y2) +{ + m_previousY2 = y2; +} + +double SVGPathSegCurvetoCubicSmoothAbsImpl::x1(double curx) const +{ + return curx - (m_previousX2 - curx); +} + +double SVGPathSegCurvetoCubicSmoothAbsImpl::y1(double cury) const +{ + return cury - (m_previousY2 - cury); +} + +void SVGPathSegCurvetoCubicSmoothAbsImpl::getDeltasAndSlopes(double curx, double cury, double *pDx, double *pDy, double *pStartSlope, double *pEndSlope) const +{ + double dx = x() - curx; + double dy = y() - cury; + double startSlope = SVGAngleImpl::todeg(atan2(y1(cury) - cury, x1(curx) - curx)); + double endSlope = SVGAngleImpl::todeg(atan2(y() - y2(), x() - x2())); + *pDx = dx; + *pDy = dy; + *pStartSlope = startSlope; + *pEndSlope = endSlope; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPathSegCurvetoCubicSmoothAbsImpl::s_hashTable 5 + x SVGPathSegCurvetoCubicSmoothAbsImpl::X DontDelete + y SVGPathSegCurvetoCubicSmoothAbsImpl::Y DontDelete + x2 SVGPathSegCurvetoCubicSmoothAbsImpl::X2 DontDelete + y2 SVGPathSegCurvetoCubicSmoothAbsImpl::Y2 DontDelete +@end +*/ + +Value SVGPathSegCurvetoCubicSmoothAbsImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case X: + return Number(x()); + case Y: + return Number(y()); + case X2: + return Number(x2()); + case Y2: + return Number(y2()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGPathSegCurvetoCubicSmoothAbsImpl::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case X: + m_x = value.toNumber(exec); + break; + case Y: + m_y = value.toNumber(exec); + break; + case X2: + m_x2 = value.toNumber(exec); + break; + case Y2: + m_y2 = value.toNumber(exec); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + + + +SVGPathSegCurvetoCubicSmoothRelImpl::SVGPathSegCurvetoCubicSmoothRelImpl() : SVGPathSegImpl() +{ + KSVG_EMPTY_FLAGS +} + +SVGPathSegCurvetoCubicSmoothRelImpl::~SVGPathSegCurvetoCubicSmoothRelImpl() +{ +} + +void SVGPathSegCurvetoCubicSmoothRelImpl::setX(const double &x) +{ + m_x = x; +} + +double SVGPathSegCurvetoCubicSmoothRelImpl::x() const +{ + return m_x; +} + +void SVGPathSegCurvetoCubicSmoothRelImpl::setY(const double &y) +{ + m_y = y; +} + +double SVGPathSegCurvetoCubicSmoothRelImpl::y() const +{ + return m_y; +} + +void SVGPathSegCurvetoCubicSmoothRelImpl::setX2(const double &x2) +{ + m_x2 = x2; +} + +double SVGPathSegCurvetoCubicSmoothRelImpl::x2() const +{ + return m_x2; +} + +void SVGPathSegCurvetoCubicSmoothRelImpl::setY2(const double &y2) +{ + m_y2 = y2; +} + +double SVGPathSegCurvetoCubicSmoothRelImpl::y2() const +{ + return m_y2; +} + +void SVGPathSegCurvetoCubicSmoothRelImpl::setPreviousAbsX2(double x2) +{ + m_previousAbsX2 = x2; +} + +void SVGPathSegCurvetoCubicSmoothRelImpl::setPreviousAbsY2(double y2) +{ + m_previousAbsY2 = y2; +} + +double SVGPathSegCurvetoCubicSmoothRelImpl::absX1(double curx) const +{ + return curx - (m_previousAbsX2 - curx); +} + +double SVGPathSegCurvetoCubicSmoothRelImpl::absY1(double cury) const +{ + return cury - (m_previousAbsY2 - cury); +} + +void SVGPathSegCurvetoCubicSmoothRelImpl::getDeltasAndSlopes(double curx, double cury, double *pDx, double *pDy, double *pStartSlope, double *pEndSlope) const +{ + double dx = x(); + double dy = y(); + double startSlope = SVGAngleImpl::todeg(atan2(absY1(cury) - cury, absX1(curx) - curx)); + double endSlope = SVGAngleImpl::todeg(atan2(y() - y2(), x() - x2())); + *pDx = dx; + *pDy = dy; + *pStartSlope = startSlope; + *pEndSlope = endSlope; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPathSegCurvetoCubicSmoothRelImpl::s_hashTable 5 + x SVGPathSegCurvetoCubicSmoothRelImpl::X DontDelete + y SVGPathSegCurvetoCubicSmoothRelImpl::Y DontDelete + x2 SVGPathSegCurvetoCubicSmoothRelImpl::X2 DontDelete + y2 SVGPathSegCurvetoCubicSmoothRelImpl::Y2 DontDelete +@end +*/ + +Value SVGPathSegCurvetoCubicSmoothRelImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case X: + return Number(x()); + case Y: + return Number(y()); + case X2: + return Number(x2()); + case Y2: + return Number(y2()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGPathSegCurvetoCubicSmoothRelImpl::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case X: + m_x = value.toNumber(exec); + break; + case Y: + m_y = value.toNumber(exec); + break; + case X2: + m_x2 = value.toNumber(exec); + break; + case Y2: + m_y2 = value.toNumber(exec); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegCurvetoCubicSmoothImpl.h b/ksvg/impl/SVGPathSegCurvetoCubicSmoothImpl.h new file mode 100644 index 00000000..0def6514 --- /dev/null +++ b/ksvg/impl/SVGPathSegCurvetoCubicSmoothImpl.h @@ -0,0 +1,139 @@ +/* + 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. +*/ + +#ifndef SVGPathSegCurvetoCubicSmoothImpl_H +#define SVGPathSegCurvetoCubicSmoothImpl_H + +#include "ksvg_lookup.h" + +#include "SVGPathSegImpl.h" + +namespace KSVG +{ + +class SVGPathSegCurvetoCubicSmoothAbsImpl : public SVGPathSegImpl +{ +public: + SVGPathSegCurvetoCubicSmoothAbsImpl(); + virtual ~SVGPathSegCurvetoCubicSmoothAbsImpl(); + + virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_CUBIC_SMOOTH_ABS; } + virtual DOM::DOMString pathSegTypeAsLetter() const { return "S"; } + virtual QString toString() const { return QString("S %1 %2 %3 %4").arg(m_x2).arg(m_y2).arg(m_x).arg(m_y); } + + void setX(const double &); + double x() const; + + void setY(const double &); + double y() const; + + void setX2(const double &); + double x2() const; + + void setY2(const double &); + double y2() const; + + void setPreviousX2(double x2); + void setPreviousY2(double y2); + + double x1(double curx) const; + double y1(double cury) const; + + virtual void getDeltasAndSlopes(double curx, double cury, double *dx, double *dy, double *startSlope, double *endSlope) const; + +private: + double m_x; + double m_y; + double m_x2; + double m_y2; + double m_previousX2; + double m_previousY2; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + X, Y, X2, Y2 + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +class SVGPathSegCurvetoCubicSmoothRelImpl : public SVGPathSegImpl +{ +public: + SVGPathSegCurvetoCubicSmoothRelImpl(); + virtual ~SVGPathSegCurvetoCubicSmoothRelImpl(); + + virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_CUBIC_SMOOTH_REL; } + virtual DOM::DOMString pathSegTypeAsLetter() const { return "s"; } + virtual QString toString() const { return QString("s %1 %2 %3 %4").arg(m_x2).arg(m_y2).arg(m_x).arg(m_y); } + + void setX(const double &); + double x() const; + + void setY(const double &); + double y() const; + + void setX2(const double &); + double x2() const; + + void setY2(const double &); + double y2() const; + + void setPreviousAbsX2(double x2); + void setPreviousAbsY2(double y2); + + double absX1(double curx) const; + double absY1(double cury) const; + + virtual void getDeltasAndSlopes(double curx, double cury, double *dx, double *dy, double *startSlope, double *endSlope) const; + +private: + double m_x; + double m_y; + double m_x2; + double m_y2; + double m_previousAbsX2; + double m_previousAbsY2; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + X, Y, X2, Y2 + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegCurvetoQuadraticImpl.cc b/ksvg/impl/SVGPathSegCurvetoQuadraticImpl.cc new file mode 100644 index 00000000..e6199a21 --- /dev/null +++ b/ksvg/impl/SVGPathSegCurvetoQuadraticImpl.cc @@ -0,0 +1,260 @@ +/* + 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> + +#include "SVGPathSegCurvetoQuadraticImpl.h" +#include "SVGAngleImpl.h" + +using namespace KSVG; + +#include "SVGPathSegCurvetoQuadraticImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +SVGPathSegCurvetoQuadraticAbsImpl::SVGPathSegCurvetoQuadraticAbsImpl() : SVGPathSegImpl() +{ + KSVG_EMPTY_FLAGS +} + +SVGPathSegCurvetoQuadraticAbsImpl::~SVGPathSegCurvetoQuadraticAbsImpl() +{ +} + +void SVGPathSegCurvetoQuadraticAbsImpl::setX(const double &x) +{ + m_x = x; +} + +double SVGPathSegCurvetoQuadraticAbsImpl::x() const +{ + return m_x; +} + +void SVGPathSegCurvetoQuadraticAbsImpl::setY(const double &y) +{ + m_y = y; +} + +double SVGPathSegCurvetoQuadraticAbsImpl::y() const +{ + return m_y; +} + +void SVGPathSegCurvetoQuadraticAbsImpl::setX1(const double &x1) +{ + m_x1 = x1; +} + +double SVGPathSegCurvetoQuadraticAbsImpl::x1() const +{ + return m_x1; +} + +void SVGPathSegCurvetoQuadraticAbsImpl::setY1(const double &y1) +{ + m_y1 = y1; +} + +double SVGPathSegCurvetoQuadraticAbsImpl::y1() const +{ + return m_y1; +} + +void SVGPathSegCurvetoQuadraticAbsImpl::getDeltasAndSlopes(double curx, double cury, double *pDx, double *pDy, double *pStartSlope, double *pEndSlope) const +{ + double dx = x() - curx; + double dy = y() - cury; + double startSlope = SVGAngleImpl::todeg(atan2(y1() - cury, x1() - curx)); + double endSlope = SVGAngleImpl::todeg(atan2(y() - y1(), x() - x1())); + *pDx = dx; + *pDy = dy; + *pStartSlope = startSlope; + *pEndSlope = endSlope; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPathSegCurvetoQuadraticAbsImpl::s_hashTable 5 + x SVGPathSegCurvetoQuadraticAbsImpl::X DontDelete + y SVGPathSegCurvetoQuadraticAbsImpl::Y DontDelete + x1 SVGPathSegCurvetoQuadraticAbsImpl::X1 DontDelete + y1 SVGPathSegCurvetoQuadraticAbsImpl::Y1 DontDelete +@end +*/ + +Value SVGPathSegCurvetoQuadraticAbsImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case X: + return Number(x()); + case Y: + return Number(y()); + case X1: + return Number(x1()); + case Y1: + return Number(y1()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGPathSegCurvetoQuadraticAbsImpl::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case X: + m_x = value.toNumber(exec); + break; + case Y: + m_y = value.toNumber(exec); + break; + case X1: + m_x1 = value.toNumber(exec); + break; + case Y1: + m_y1 = value.toNumber(exec); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + + + +SVGPathSegCurvetoQuadraticRelImpl::SVGPathSegCurvetoQuadraticRelImpl() : SVGPathSegImpl() +{ + KSVG_EMPTY_FLAGS +} + +SVGPathSegCurvetoQuadraticRelImpl::~SVGPathSegCurvetoQuadraticRelImpl() +{ +} + +void SVGPathSegCurvetoQuadraticRelImpl::setX(const double &x) +{ + m_x = x; +} + +double SVGPathSegCurvetoQuadraticRelImpl::x() const +{ + return m_x; +} + +void SVGPathSegCurvetoQuadraticRelImpl::setY(const double &y) +{ + m_y = y; +} + +double SVGPathSegCurvetoQuadraticRelImpl::y() const +{ + return m_y; +} + +void SVGPathSegCurvetoQuadraticRelImpl::setX1(const double &x1) +{ + m_x1 = x1; +} + +double SVGPathSegCurvetoQuadraticRelImpl::x1() const +{ + return m_x1; +} + +void SVGPathSegCurvetoQuadraticRelImpl::setY1(const double &y1) +{ + m_y1 = y1; +} + +double SVGPathSegCurvetoQuadraticRelImpl::y1() const +{ + return m_y1; +} + +void SVGPathSegCurvetoQuadraticRelImpl::getDeltasAndSlopes(double curx, double cury, double *pDx, double *pDy, double *pStartSlope, double *pEndSlope) const +{ + Q_UNUSED(curx); + Q_UNUSED(cury); + double dx = x(); + double dy = y(); + double startSlope = SVGAngleImpl::todeg(atan2(y1(), x1())); + double endSlope = SVGAngleImpl::todeg(atan2(y() - y1(), x() - x1())); + *pDx = dx; + *pDy = dy; + *pStartSlope = startSlope; + *pEndSlope = endSlope; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPathSegCurvetoQuadraticRelImpl::s_hashTable 5 + x SVGPathSegCurvetoQuadraticRelImpl::X DontDelete + y SVGPathSegCurvetoQuadraticRelImpl::Y DontDelete + x1 SVGPathSegCurvetoQuadraticRelImpl::X1 DontDelete + y1 SVGPathSegCurvetoQuadraticRelImpl::Y1 DontDelete +@end +*/ + +Value SVGPathSegCurvetoQuadraticRelImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case X: + return Number(x()); + case Y: + return Number(y()); + case X1: + return Number(x1()); + case Y1: + return Number(y1()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGPathSegCurvetoQuadraticRelImpl::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case X: + m_x = value.toNumber(exec); + break; + case Y: + m_y = value.toNumber(exec); + break; + case X1: + m_x1 = value.toNumber(exec); + break; + case Y1: + m_y1 = value.toNumber(exec); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegCurvetoQuadraticImpl.h b/ksvg/impl/SVGPathSegCurvetoQuadraticImpl.h new file mode 100644 index 00000000..6fe9ef15 --- /dev/null +++ b/ksvg/impl/SVGPathSegCurvetoQuadraticImpl.h @@ -0,0 +1,123 @@ +/* + 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. +*/ + +#ifndef SVGPathSegCurvetoQuadraticImpl_H +#define SVGPathSegCurvetoQuadraticImpl_H + +#include "ksvg_lookup.h" + +#include "SVGPathSegImpl.h" + +namespace KSVG +{ + +class SVGPathSegCurvetoQuadraticAbsImpl : public SVGPathSegImpl +{ +public: + SVGPathSegCurvetoQuadraticAbsImpl(); + virtual ~SVGPathSegCurvetoQuadraticAbsImpl(); + + virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_QUADRATIC_ABS; } + virtual DOM::DOMString pathSegTypeAsLetter() const { return "Q"; } + virtual QString toString() const { return QString("Q %1 %2 %3 %4").arg(m_x1).arg(m_y1).arg(m_x).arg(m_y); } + + void setX(const double &); + double x() const; + + void setY(const double &); + double y() const; + + void setX1(const double &); + double x1() const; + + void setY1(const double &); + double y1() const; + + virtual void getDeltasAndSlopes(double curx, double cury, double *dx, double *dy, double *startSlope, double *endSlope) const; + +private: + double m_x; + double m_y; + double m_x1; + double m_y1; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + X, Y, X1, Y1 + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +class SVGPathSegCurvetoQuadraticRelImpl : public SVGPathSegImpl +{ +public: + SVGPathSegCurvetoQuadraticRelImpl(); + virtual ~SVGPathSegCurvetoQuadraticRelImpl(); + + virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_QUADRATIC_REL; } + virtual DOM::DOMString pathSegTypeAsLetter() const { return "q"; } + virtual QString toString() const { return QString("q %1 %2 %3 %4").arg(m_x1).arg(m_y1).arg(m_x).arg(m_y); } + + void setX(const double &); + double x() const; + + void setY(const double &); + double y() const; + + void setX1(const double &); + double x1() const; + + void setY1(const double &); + double y1() const; + + virtual void getDeltasAndSlopes(double curx, double cury, double *dx, double *dy, double *startSlope, double *endSlope) const; + +private: + double m_x; + double m_y; + double m_x1; + double m_y1; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + X, Y, X1, Y1 + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegCurvetoQuadraticSmoothImpl.cc b/ksvg/impl/SVGPathSegCurvetoQuadraticSmoothImpl.cc new file mode 100644 index 00000000..f8c141da --- /dev/null +++ b/ksvg/impl/SVGPathSegCurvetoQuadraticSmoothImpl.cc @@ -0,0 +1,235 @@ +/* + 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> + +#include "SVGPathSegCurvetoQuadraticSmoothImpl.h" +#include "SVGAngleImpl.h" + +using namespace KSVG; + +#include "SVGPathSegCurvetoQuadraticSmoothImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +SVGPathSegCurvetoQuadraticSmoothAbsImpl::SVGPathSegCurvetoQuadraticSmoothAbsImpl() : SVGPathSegImpl() +{ + KSVG_EMPTY_FLAGS +} + +SVGPathSegCurvetoQuadraticSmoothAbsImpl::~SVGPathSegCurvetoQuadraticSmoothAbsImpl() +{ +} + +void SVGPathSegCurvetoQuadraticSmoothAbsImpl::setX(const double &x) +{ + m_x = x; +} + +double SVGPathSegCurvetoQuadraticSmoothAbsImpl::x() const +{ + return m_x; +} + +void SVGPathSegCurvetoQuadraticSmoothAbsImpl::setY(const double &y) +{ + m_y = y; +} + +double SVGPathSegCurvetoQuadraticSmoothAbsImpl::y() const +{ + return m_y; +} + +void SVGPathSegCurvetoQuadraticSmoothAbsImpl::setPreviousX1(double x1) +{ + m_previousX1 = x1; +} + +void SVGPathSegCurvetoQuadraticSmoothAbsImpl::setPreviousY1(double y1) +{ + m_previousY1 = y1; +} + +double SVGPathSegCurvetoQuadraticSmoothAbsImpl::x1(double curx) const +{ + return curx - (m_previousX1 - curx); +} + +double SVGPathSegCurvetoQuadraticSmoothAbsImpl::y1(double cury) const +{ + return cury - (m_previousY1 - cury); +} + +void SVGPathSegCurvetoQuadraticSmoothAbsImpl::getDeltasAndSlopes(double curx, double cury, double *pDx, double *pDy, double *pStartSlope, double *pEndSlope) const +{ + double dx = x() - curx; + double dy = y() - cury; + double startSlope = SVGAngleImpl::todeg(atan2(y1(cury) - cury, x1(curx) - curx)); + double endSlope = SVGAngleImpl::todeg(atan2(y() - y1(cury), x() - x1(curx))); + *pDx = dx; + *pDy = dy; + *pStartSlope = startSlope; + *pEndSlope = endSlope; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPathSegCurvetoQuadraticSmoothAbsImpl::s_hashTable 3 + x SVGPathSegCurvetoQuadraticSmoothAbsImpl::X DontDelete + y SVGPathSegCurvetoQuadraticSmoothAbsImpl::Y DontDelete +@end +*/ + +Value SVGPathSegCurvetoQuadraticSmoothAbsImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case X: + return Number(x()); + case Y: + return Number(y()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGPathSegCurvetoQuadraticSmoothAbsImpl::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case X: + m_x = value.toNumber(exec); + break; + case Y: + m_y = value.toNumber(exec); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + + + + +SVGPathSegCurvetoQuadraticSmoothRelImpl::SVGPathSegCurvetoQuadraticSmoothRelImpl() : SVGPathSegImpl() +{ + KSVG_EMPTY_FLAGS +} + +SVGPathSegCurvetoQuadraticSmoothRelImpl::~SVGPathSegCurvetoQuadraticSmoothRelImpl() +{ +} + +void SVGPathSegCurvetoQuadraticSmoothRelImpl::setX(const double &x) +{ + m_x = x; +} + +double SVGPathSegCurvetoQuadraticSmoothRelImpl::x() const +{ + return m_x; +} + +void SVGPathSegCurvetoQuadraticSmoothRelImpl::setY(const double &y) +{ + m_y = y; +} + +double SVGPathSegCurvetoQuadraticSmoothRelImpl::y() const +{ + return m_y; +} + +void SVGPathSegCurvetoQuadraticSmoothRelImpl::setPreviousAbsX1(double x1) +{ + m_previousAbsX1 = x1; +} + +void SVGPathSegCurvetoQuadraticSmoothRelImpl::setPreviousAbsY1(double y1) +{ + m_previousAbsY1 = y1; +} + +double SVGPathSegCurvetoQuadraticSmoothRelImpl::absX1(double curx) const +{ + return curx - (m_previousAbsX1 - curx); +} + +double SVGPathSegCurvetoQuadraticSmoothRelImpl::absY1(double cury) const +{ + return cury - (m_previousAbsY1 - cury); +} + +void SVGPathSegCurvetoQuadraticSmoothRelImpl::getDeltasAndSlopes(double curx, double cury, double *pDx, double *pDy, double *pStartSlope, double *pEndSlope) const +{ + double dx = x(); + double dy = y(); + double startSlope = SVGAngleImpl::todeg(atan2(absY1(cury) - cury, absX1(curx) - curx)); + double endSlope = SVGAngleImpl::todeg(atan2(cury + y() - absY1(cury), curx + x() - absX1(curx))); + *pDx = dx; + *pDy = dy; + *pStartSlope = startSlope; + *pEndSlope = endSlope; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPathSegCurvetoQuadraticSmoothRelImpl::s_hashTable 3 + x SVGPathSegCurvetoQuadraticSmoothRelImpl::X DontDelete + y SVGPathSegCurvetoQuadraticSmoothRelImpl::Y DontDelete +@end +*/ + +Value SVGPathSegCurvetoQuadraticSmoothRelImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case X: + return Number(x()); + case Y: + return Number(y()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGPathSegCurvetoQuadraticSmoothRelImpl::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case X: + m_x = value.toNumber(exec); + break; + case Y: + m_y = value.toNumber(exec); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegCurvetoQuadraticSmoothImpl.h b/ksvg/impl/SVGPathSegCurvetoQuadraticSmoothImpl.h new file mode 100644 index 00000000..dffa3355 --- /dev/null +++ b/ksvg/impl/SVGPathSegCurvetoQuadraticSmoothImpl.h @@ -0,0 +1,123 @@ +/* + 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. +*/ + +#ifndef SVGPathSegCurvetoQuadraticSmoothImpl_H +#define SVGPathSegCurvetoQuadraticSmoothImpl_H + +#include "ksvg_lookup.h" + +#include "SVGPathSegImpl.h" + +namespace KSVG +{ + +class SVGPathSegCurvetoQuadraticSmoothAbsImpl : public SVGPathSegImpl +{ +public: + SVGPathSegCurvetoQuadraticSmoothAbsImpl(); + virtual ~SVGPathSegCurvetoQuadraticSmoothAbsImpl(); + + virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS; } + virtual DOM::DOMString pathSegTypeAsLetter() const { return "T"; } + virtual QString toString() const { return QString("T %1 %2").arg(m_x).arg(m_y); } + + void setX(const double &); + double x() const; + + void setY(const double &); + double y() const; + + void setPreviousX1(double x1); + void setPreviousY1(double y1); + + double x1(double curx) const; + double y1(double cury) const; + + virtual void getDeltasAndSlopes(double curx, double cury, double *dx, double *dy, double *startSlope, double *endSlope) const; + +private: + double m_x; + double m_y; + double m_previousX1; + double m_previousY1; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + X, Y + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +class SVGPathSegCurvetoQuadraticSmoothRelImpl : public SVGPathSegImpl +{ +public: + SVGPathSegCurvetoQuadraticSmoothRelImpl(); + virtual ~SVGPathSegCurvetoQuadraticSmoothRelImpl(); + + virtual unsigned short pathSegType() const { return PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL; } + virtual DOM::DOMString pathSegTypeAsLetter() const { return "t"; } + virtual QString toString() const { return QString("t %1 %2").arg(m_x).arg(m_y); } + + void setX(const double &); + double x() const; + + void setY(const double &); + double y() const; + + void setPreviousAbsX1(double x1); + void setPreviousAbsY1(double y1); + + double absX1(double curx) const; + double absY1(double cury) const; + + virtual void getDeltasAndSlopes(double curx, double cury, double *dx, double *dy, double *startSlope, double *endSlope) const; + +private: + double m_x; + double m_y; + double m_previousAbsX1; + double m_previousAbsY1; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + X, Y + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegImpl.cc b/ksvg/impl/SVGPathSegImpl.cc new file mode 100644 index 00000000..c1f2934d --- /dev/null +++ b/ksvg/impl/SVGPathSegImpl.cc @@ -0,0 +1,107 @@ +/* + 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> + +#include "SVGPathSegImpl.h" + +using namespace KSVG; + +#include "SVGPathSegImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_cacheimpl.h" + +SVGPathSegImpl::SVGPathSegImpl() +{ +} + +SVGPathSegImpl::~SVGPathSegImpl() +{ +} + +void SVGPathSegImpl::getDeltasAndSlopes(double, double, double *dx, double *dy, double *startSlope, double *endSlope) const +{ + *dx = 0; + *dy = 0; + *startSlope = 0; + *endSlope = 0; +} + +// Exma stuff + +/* +@namespace KSVG +@begin SVGPathSegImpl::s_hashTable 3 + pathSegType SVGPathSegImpl::PathSegType DontDelete|ReadOnly + pathSegTypeAsLetter SVGPathSegImpl::PathSegTypeAsLetter DontDelete|ReadOnly +@end +*/ + +Value SVGPathSegImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case PathSegType: + return Number(pathSegType()); + case PathSegTypeAsLetter: + return String(pathSegTypeAsLetter().string()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +/* +@namespace KSVG +@begin SVGPathSegImplConstructor::s_hashTable 23 + PATHSEG_UNKNOWN KSVG::PATHSEG_UNKNOWN DontDelete|ReadOnly + PATHSEG_CLOSEPATH KSVG::PATHSEG_CLOSEPATH DontDelete|ReadOnly + PATHSEG_MOVETO_ABS KSVG::PATHSEG_MOVETO_ABS DontDelete|ReadOnly + PATHSEG_MOVETO_REL KSVG::PATHSEG_MOVETO_REL DontDelete|ReadOnly + PATHSEG_LINETO_ABS KSVG::PATHSEG_LINETO_ABS DontDelete|ReadOnly + PATHSEG_LINETO_REL KSVG::PATHSEG_LINETO_REL DontDelete|ReadOnly + PATHSEG_CURVETO_CUBIC_ABS KSVG::PATHSEG_CURVETO_CUBIC_ABS DontDelete|ReadOnly + PATHSEG_CURVETO_CUBIC_REL KSVG::PATHSEG_CURVETO_CUBIC_REL DontDelete|ReadOnly + PATHSEG_CURVETO_QUADRATIC_ABS KSVG::PATHSEG_CURVETO_QUADRATIC_ABS DontDelete|ReadOnly + PATHSEG_CURVETO_QUADRATIC_REL KSVG::PATHSEG_CURVETO_QUADRATIC_REL DontDelete|ReadOnly + PATHSEG_ARC_ABS KSVG::PATHSEG_ARC_ABS DontDelete|ReadOnly + PATHSEG_ARC_REL KSVG::PATHSEG_ARC_REL DontDelete|ReadOnly + PATHSEG_LINETO_HORIZONTAL_ABS KSVG::PATHSEG_LINETO_HORIZONTAL_ABS DontDelete|ReadOnly + PATHSEG_LINETO_HORIZONTAL_REL KSVG::PATHSEG_LINETO_HORIZONTAL_REL DontDelete|ReadOnly + PATHSEG_LINETO_VERTICAL_ABS KSVG::PATHSEG_LINETO_VERTICAL_ABS DontDelete|ReadOnly + PATHSEG_LINETO_VERTICAL_REL KSVG::PATHSEG_LINETO_VERTICAL_REL DontDelete|ReadOnly + PATHSEG_CURVETO_CUBIC_SMOOTH_ABS KSVG::PATHSEG_CURVETO_CUBIC_SMOOTH_ABS DontDelete|ReadOnly + PATHSEG_CURVETO_CUBIC_SMOOTH_REL KSVG::PATHSEG_CURVETO_CUBIC_SMOOTH_REL DontDelete|ReadOnly + PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS KSVG::PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS DontDelete|ReadOnly + PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL KSVG::PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL DontDelete|ReadOnly +@end +*/ + +Value SVGPathSegImplConstructor::getValueProperty(ExecState *, int token) const +{ + return Number(token); +} + +Value KSVG::getSVGPathSegImplConstructor(ExecState *exec) +{ + return cacheGlobalBridge<SVGPathSegImplConstructor>(exec, "[[svgpathseg.constructor]]"); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegImpl.h b/ksvg/impl/SVGPathSegImpl.h new file mode 100644 index 00000000..64d8b5b0 --- /dev/null +++ b/ksvg/impl/SVGPathSegImpl.h @@ -0,0 +1,75 @@ +/* + 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. +*/ + +#ifndef SVGPathSegImpl_H +#define SVGPathSegImpl_H + +#include <dom/dom_misc.h> + +#include "ksvg_lookup.h" + +#include "SVGPathSeg.h" + +namespace KSVG +{ + +class SVGPathElementImpl; +class SVGPathSegImpl : public DOM::DomShared +{ +public: + SVGPathSegImpl(); + virtual ~SVGPathSegImpl(); + + virtual unsigned short pathSegType() const { return PATHSEG_UNKNOWN; } + virtual DOM::DOMString pathSegTypeAsLetter() const { return ""; } + virtual QString toString() const { return ""; } + + virtual void getDeltasAndSlopes(double curx, double cury, double *dx, double *dy, double *startSlope, double *endSlope) const; + +public: + KSVG_BASECLASS_GET + + enum + { + // Properties + PathSegType, PathSegTypeAsLetter + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + +}; + +class SVGPathSegImplConstructor : public KJS::ObjectImp +{ +public: + SVGPathSegImplConstructor(KJS::ExecState *) { } + KJS::Value getValueProperty(KJS::ExecState *, int token) const; + + // no put - all read-only + KSVG_GET +}; + +KJS::Value getSVGPathSegImplConstructor(KJS::ExecState *exec); + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegLinetoHorizontalImpl.cc b/ksvg/impl/SVGPathSegLinetoHorizontalImpl.cc new file mode 100644 index 00000000..e36e49de --- /dev/null +++ b/ksvg/impl/SVGPathSegLinetoHorizontalImpl.cc @@ -0,0 +1,167 @@ +/* + 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> + +#include "SVGPathSegLinetoHorizontalImpl.h" +#include "SVGAngleImpl.h" + +using namespace KSVG; + +#include "SVGPathSegLinetoHorizontalImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +SVGPathSegLinetoHorizontalAbsImpl::SVGPathSegLinetoHorizontalAbsImpl() : SVGPathSegImpl() +{ + KSVG_EMPTY_FLAGS +} + +SVGPathSegLinetoHorizontalAbsImpl::~SVGPathSegLinetoHorizontalAbsImpl() +{ +} + +void SVGPathSegLinetoHorizontalAbsImpl::setX(const double &x) +{ + m_x = x; +} + +double SVGPathSegLinetoHorizontalAbsImpl::x() const +{ + return m_x; +} + +void SVGPathSegLinetoHorizontalAbsImpl::getDeltasAndSlopes(double curx, double cury, double *pdx, double *pdy, double *pstartSlope, double *pendSlope) const +{ + Q_UNUSED(cury); + double dx = x() - curx; + double dy = 0; + double startSlope = SVGAngleImpl::todeg(atan2(dy, dx)); + double endSlope = startSlope; + *pdx = dx; + *pdy = dy; + *pstartSlope = startSlope; + *pendSlope = endSlope; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPathSegLinetoHorizontalAbsImpl::s_hashTable 2 + x SVGPathSegLinetoHorizontalAbsImpl::X DontDelete +@end +*/ + +Value SVGPathSegLinetoHorizontalAbsImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case X: + return Number(x()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGPathSegLinetoHorizontalAbsImpl::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case X: + m_x = value.toNumber(exec); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + + + + + +SVGPathSegLinetoHorizontalRelImpl::SVGPathSegLinetoHorizontalRelImpl() : SVGPathSegImpl() +{ + KSVG_EMPTY_FLAGS +} + +SVGPathSegLinetoHorizontalRelImpl::~SVGPathSegLinetoHorizontalRelImpl() +{ +} + +void SVGPathSegLinetoHorizontalRelImpl::setX(const double &x) +{ + m_x = x; +} + +double SVGPathSegLinetoHorizontalRelImpl::x() const +{ + return m_x; +} + +void SVGPathSegLinetoHorizontalRelImpl::getDeltasAndSlopes(double curx, double cury, double *pdx, double *pdy, double *pstartSlope, double *pendSlope) const +{ + Q_UNUSED(curx); + Q_UNUSED(cury); + double dx = x(); + double dy = 0; + double startSlope = SVGAngleImpl::todeg(atan2(dy, dx)); + double endSlope = startSlope; + *pdx = dx; + *pdy = dy; + *pstartSlope = startSlope; + *pendSlope = endSlope; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPathSegLinetoHorizontalRelImpl::s_hashTable 2 + x SVGPathSegLinetoHorizontalRelImpl::X DontDelete +@end +*/ + +Value SVGPathSegLinetoHorizontalRelImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case X: + return Number(x()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGPathSegLinetoHorizontalRelImpl::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case X: + m_x = value.toNumber(exec); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegLinetoHorizontalImpl.h b/ksvg/impl/SVGPathSegLinetoHorizontalImpl.h new file mode 100644 index 00000000..020d29d7 --- /dev/null +++ b/ksvg/impl/SVGPathSegLinetoHorizontalImpl.h @@ -0,0 +1,99 @@ +/* + 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. +*/ + +#ifndef SVGPathSegLinetoHorizontalImpl_H +#define SVGPathSegLinetoHorizontalImpl_H + +#include "ksvg_lookup.h" + +#include "SVGPathSegImpl.h" + +namespace KSVG +{ + +class SVGPathSegLinetoHorizontalAbsImpl : public SVGPathSegImpl +{ +public: + SVGPathSegLinetoHorizontalAbsImpl(); + virtual ~SVGPathSegLinetoHorizontalAbsImpl(); + + virtual unsigned short pathSegType() const { return PATHSEG_LINETO_HORIZONTAL_ABS; } + virtual DOM::DOMString pathSegTypeAsLetter() const { return "H"; } + virtual QString toString() const { return QString("H %1").arg(m_x); } + + void setX(const double &); + double x() const; + + virtual void getDeltasAndSlopes(double curx, double cury, double *dx, double *dy, double *startSlope, double *endSlope) const; + +private: + double m_x; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + X + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +class SVGPathSegLinetoHorizontalRelImpl : public SVGPathSegImpl +{ +public: + SVGPathSegLinetoHorizontalRelImpl(); + virtual ~SVGPathSegLinetoHorizontalRelImpl(); + + virtual unsigned short pathSegType() const { return PATHSEG_LINETO_HORIZONTAL_REL; } + virtual DOM::DOMString pathSegTypeAsLetter() const { return "h"; } + virtual QString toString() const { return QString("h %1").arg(m_x); } + + void setX(const double &); + double x() const; + + virtual void getDeltasAndSlopes(double curx, double cury, double *dx, double *dy, double *startSlope, double *endSlope) const; + +private: + double m_x; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + X + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegLinetoImpl.cc b/ksvg/impl/SVGPathSegLinetoImpl.cc new file mode 100644 index 00000000..04203352 --- /dev/null +++ b/ksvg/impl/SVGPathSegLinetoImpl.cc @@ -0,0 +1,196 @@ +/* + 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> + +#include "SVGPathSegLinetoImpl.h" +#include "SVGAngleImpl.h" + +using namespace KSVG; + +#include "SVGPathSegLinetoImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +SVGPathSegLinetoAbsImpl::SVGPathSegLinetoAbsImpl() : SVGPathSegImpl() +{ + KSVG_EMPTY_FLAGS +} + +SVGPathSegLinetoAbsImpl::~SVGPathSegLinetoAbsImpl() +{ +} + +void SVGPathSegLinetoAbsImpl::setX(const double &x) +{ + m_x = x; +} + +double SVGPathSegLinetoAbsImpl::x() const +{ + return m_x; +} + +void SVGPathSegLinetoAbsImpl::setY(const double &y) +{ + m_y = y; +} + +double SVGPathSegLinetoAbsImpl::y() const +{ + return m_y; +} + +void SVGPathSegLinetoAbsImpl::getDeltasAndSlopes(double curx, double cury, double *pdx, double *pdy, double *pstartSlope, double *pendSlope) const +{ + double dx = x() - curx; + double dy = y() - cury; + double startSlope = SVGAngleImpl::todeg(atan2(dy, dx)); + double endSlope = startSlope; + *pdx = dx; + *pdy = dy; + *pstartSlope = startSlope; + *pendSlope = endSlope; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPathSegLinetoAbsImpl::s_hashTable 3 + x SVGPathSegLinetoAbsImpl::X DontDelete + y SVGPathSegLinetoAbsImpl::Y DontDelete +@end +*/ + +Value SVGPathSegLinetoAbsImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case X: + return Number(x()); + case Y: + return Number(y()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGPathSegLinetoAbsImpl::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case X: + m_x = value.toNumber(exec); + break; + case Y: + m_y = value.toNumber(exec); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + + + +SVGPathSegLinetoRelImpl::SVGPathSegLinetoRelImpl() : SVGPathSegImpl() +{ + KSVG_EMPTY_FLAGS +} + +SVGPathSegLinetoRelImpl::~SVGPathSegLinetoRelImpl() +{ +} + +void SVGPathSegLinetoRelImpl::setX(const double &x) +{ + m_x = x; +} + +double SVGPathSegLinetoRelImpl::x() const +{ + return m_x; +} + +void SVGPathSegLinetoRelImpl::setY(const double &y) +{ + m_y = y; +} + +double SVGPathSegLinetoRelImpl::y() const +{ + return m_y; +} + +void SVGPathSegLinetoRelImpl::getDeltasAndSlopes(double curx, double cury, double *pdx, double *pdy, double *pstartSlope, double *pendSlope) const +{ + Q_UNUSED(curx); + Q_UNUSED(cury); + double dx = x(); + double dy = y(); + double startSlope = SVGAngleImpl::todeg(atan2(dy, dx)); + double endSlope = startSlope; + *pdx = dx; + *pdy = dy; + *pstartSlope = startSlope; + *pendSlope = endSlope; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPathSegLinetoRelImpl::s_hashTable 3 + x SVGPathSegLinetoRelImpl::X DontDelete + y SVGPathSegLinetoRelImpl::Y DontDelete +@end +*/ + +Value SVGPathSegLinetoRelImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case X: + return Number(x()); + case Y: + return Number(y()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGPathSegLinetoRelImpl::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case X: + m_x = value.toNumber(exec); + break; + case Y: + m_y = value.toNumber(exec); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegLinetoImpl.h b/ksvg/impl/SVGPathSegLinetoImpl.h new file mode 100644 index 00000000..3e315022 --- /dev/null +++ b/ksvg/impl/SVGPathSegLinetoImpl.h @@ -0,0 +1,107 @@ +/* + 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. +*/ + +#ifndef SVGPathSegLinetoImpl_H +#define SVGPathSegLinetoImpl_H + +#include "ksvg_lookup.h" + +#include "SVGPathSegImpl.h" + +namespace KSVG +{ + +class SVGPathSegLinetoAbsImpl : public SVGPathSegImpl +{ +public: + SVGPathSegLinetoAbsImpl(); + virtual ~SVGPathSegLinetoAbsImpl(); + + virtual unsigned short pathSegType() const { return PATHSEG_LINETO_ABS; } + virtual DOM::DOMString pathSegTypeAsLetter() const { return "L"; } + virtual QString toString() const { return QString("L %1 %2").arg(m_x).arg(m_y); } + + void setX(const double &); + double x() const; + + void setY(const double &); + double y() const; + + virtual void getDeltasAndSlopes(double curx, double cury, double *dx, double *dy, double *startSlope, double *endSlope) const; + +private: + double m_x; + double m_y; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + X, Y + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +class SVGPathSegLinetoRelImpl : public SVGPathSegImpl +{ +public: + SVGPathSegLinetoRelImpl(); + virtual ~SVGPathSegLinetoRelImpl(); + + virtual unsigned short pathSegType() const { return PATHSEG_LINETO_REL; } + virtual DOM::DOMString pathSegTypeAsLetter() const { return "l"; } + virtual QString toString() const { return QString("l %1 %2").arg(m_x).arg(m_y); } + + void setX(const double &); + double x() const; + + void setY(const double &); + double y() const; + + virtual void getDeltasAndSlopes(double curx, double cury, double *dx, double *dy, double *startSlope, double *endSlope) const; + +private: + double m_x; + double m_y; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + X, Y + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegLinetoVerticalImpl.cc b/ksvg/impl/SVGPathSegLinetoVerticalImpl.cc new file mode 100644 index 00000000..0eca1280 --- /dev/null +++ b/ksvg/impl/SVGPathSegLinetoVerticalImpl.cc @@ -0,0 +1,165 @@ +/* + 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> + +#include "SVGPathSegLinetoVerticalImpl.h" +#include "SVGAngleImpl.h" + +using namespace KSVG; + +#include "SVGPathSegLinetoVerticalImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +SVGPathSegLinetoVerticalAbsImpl::SVGPathSegLinetoVerticalAbsImpl() : SVGPathSegImpl() +{ + KSVG_EMPTY_FLAGS +} + +SVGPathSegLinetoVerticalAbsImpl::~SVGPathSegLinetoVerticalAbsImpl() +{ +} + +void SVGPathSegLinetoVerticalAbsImpl::setY(const double &y) +{ + m_y = y; +} + +double SVGPathSegLinetoVerticalAbsImpl::y() const +{ + return m_y; +} + +void SVGPathSegLinetoVerticalAbsImpl::getDeltasAndSlopes(double curx, double cury, double *pdx, double *pdy, double *pstartSlope, double *pendSlope) const +{ + Q_UNUSED(curx); + double dx = 0; + double dy = y() - cury; + double startSlope = SVGAngleImpl::todeg(atan2(dy, dx)); + double endSlope = startSlope; + *pdx = dx; + *pdy = dy; + *pstartSlope = startSlope; + *pendSlope = endSlope; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPathSegLinetoVerticalAbsImpl::s_hashTable 2 + y SVGPathSegLinetoVerticalAbsImpl::Y DontDelete +@end +*/ + +Value SVGPathSegLinetoVerticalAbsImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case Y: + return Number(y()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGPathSegLinetoVerticalAbsImpl::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case Y: + m_y = value.toNumber(exec); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + + + +SVGPathSegLinetoVerticalRelImpl::SVGPathSegLinetoVerticalRelImpl() : SVGPathSegImpl() +{ + KSVG_EMPTY_FLAGS +} + +SVGPathSegLinetoVerticalRelImpl::~SVGPathSegLinetoVerticalRelImpl() +{ +} + +void SVGPathSegLinetoVerticalRelImpl::setY(const double &y) +{ + m_y = y; +} + +double SVGPathSegLinetoVerticalRelImpl::y() const +{ + return m_y; +} + +void SVGPathSegLinetoVerticalRelImpl::getDeltasAndSlopes(double curx, double cury, double *pdx, double *pdy, double *pstartSlope, double *pendSlope) const +{ + Q_UNUSED(curx); + Q_UNUSED(cury); + double dx = 0; + double dy = y(); + double startSlope = SVGAngleImpl::todeg(atan2(dy, dx)); + double endSlope = startSlope; + *pdx = dx; + *pdy = dy; + *pstartSlope = startSlope; + *pendSlope = endSlope; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPathSegLinetoVerticalRelImpl::s_hashTable 2 + y SVGPathSegLinetoVerticalRelImpl::Y DontDelete +@end +*/ + +Value SVGPathSegLinetoVerticalRelImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case Y: + return Number(y()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGPathSegLinetoVerticalRelImpl::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case Y: + m_y = value.toNumber(exec); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegLinetoVerticalImpl.h b/ksvg/impl/SVGPathSegLinetoVerticalImpl.h new file mode 100644 index 00000000..c50906d9 --- /dev/null +++ b/ksvg/impl/SVGPathSegLinetoVerticalImpl.h @@ -0,0 +1,99 @@ +/* + 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. +*/ + +#ifndef SVGPathSegLinetoVerticalImpl_H +#define SVGPathSegLinetoVerticalImpl_H + +#include "ksvg_lookup.h" + +#include "SVGPathSegImpl.h" + +namespace KSVG +{ + +class SVGPathSegLinetoVerticalAbsImpl : public SVGPathSegImpl +{ +public: + SVGPathSegLinetoVerticalAbsImpl(); + virtual~SVGPathSegLinetoVerticalAbsImpl(); + + virtual unsigned short pathSegType() const { return PATHSEG_LINETO_VERTICAL_ABS; } + virtual DOM::DOMString pathSegTypeAsLetter() const { return "V"; } + virtual QString toString() const { return QString("V %1").arg(m_y); } + + void setY(const double &); + double y() const; + + virtual void getDeltasAndSlopes(double curx, double cury, double *dx, double *dy, double *startSlope, double *endSlope) const; + +private: + double m_y; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + Y + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +class SVGPathSegLinetoVerticalRelImpl : public SVGPathSegImpl +{ +public: + SVGPathSegLinetoVerticalRelImpl(); + virtual ~SVGPathSegLinetoVerticalRelImpl(); + + virtual unsigned short pathSegType() const { return PATHSEG_LINETO_VERTICAL_REL; } + virtual DOM::DOMString pathSegTypeAsLetter() const { return "v"; } + virtual QString toString() const { return QString("v %1").arg(m_y); } + + void setY(const double &); + double y() const; + + virtual void getDeltasAndSlopes(double curx, double cury, double *dx, double *dy, double *startSlope, double *endSlope) const; + +private: + double m_y; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + Y + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegListImpl.cc b/ksvg/impl/SVGPathSegListImpl.cc new file mode 100644 index 00000000..ee316938 --- /dev/null +++ b/ksvg/impl/SVGPathSegListImpl.cc @@ -0,0 +1,64 @@ +/* + 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> + +#include "SVGPathSegListImpl.h" + +using namespace KSVG; + +#include "SVGPathSegListImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPathSegListImpl::s_hashTable 2 + numberOfItems SVGListDefs::NumberOfItems DontDelete|ReadOnly +@end +@namespace KSVG +@begin SVGPathSegListImplProto::s_hashTable 11 + getItem SVGListDefs::GetItem DontDelete|Function 1 + removeItem SVGListDefs::RemoveItem DontDelete|Function 1 + appendItem SVGListDefs::AppendItem DontDelete|Function 1 + initialize SVGListDefs::Initialize DontDelete|Function 1 + insertItemBefore SVGListDefs::InsertItemBefore DontDelete|Function 2 + replaceItem SVGListDefs::ReplaceItem DontDelete|Function 2 + clear SVGListDefs::Clear DontDelete|Function 0 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGPathSegList", SVGPathSegListImplProto, SVGPathSegListImplProtoFunc) + +Value SVGPathSegListImpl::getValueProperty(ExecState *exec, int token) const +{ + return SVGList<SVGPathSegImpl>::getValueProperty(exec, token); +} + +Value SVGPathSegListImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGPathSegListImpl) + + return obj->call(exec, static_cast<SVGList<SVGPathSegImpl> *>(obj), args, id); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegListImpl.h b/ksvg/impl/SVGPathSegListImpl.h new file mode 100644 index 00000000..ef9c8c6e --- /dev/null +++ b/ksvg/impl/SVGPathSegListImpl.h @@ -0,0 +1,48 @@ +/* + 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. +*/ + +#ifndef SVGPathSegListImpl_H +#define SVGPathSegListImpl_H + +#include "SVGList.h" + +#include "SVGPathSegImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGPathSegListImpl : public SVGList<SVGPathSegImpl> +{ +public: + KSVG_GET + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; +}; + +} + +KSVG_DEFINE_PROTOTYPE(SVGPathSegListImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGPathSegListImplProtoFunc, SVGPathSegListImpl) + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegMovetoImpl.cc b/ksvg/impl/SVGPathSegMovetoImpl.cc new file mode 100644 index 00000000..2eb64b41 --- /dev/null +++ b/ksvg/impl/SVGPathSegMovetoImpl.cc @@ -0,0 +1,196 @@ +/* + 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> + +#include "SVGPathSegMovetoImpl.h" +#include "SVGAngleImpl.h" + +using namespace KSVG; + +#include "SVGPathSegMovetoImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +SVGPathSegMovetoAbsImpl::SVGPathSegMovetoAbsImpl() : SVGPathSegImpl() +{ + KSVG_EMPTY_FLAGS +} + +SVGPathSegMovetoAbsImpl::~SVGPathSegMovetoAbsImpl() +{ +} + +void SVGPathSegMovetoAbsImpl::setX(const double &x) +{ + m_x = x; +} + +double SVGPathSegMovetoAbsImpl::x() const +{ + return m_x; +} + +void SVGPathSegMovetoAbsImpl::setY(const double &y) +{ + m_y = y; +} + +double SVGPathSegMovetoAbsImpl::y() const +{ + return m_y; +} + +void SVGPathSegMovetoAbsImpl::getDeltasAndSlopes(double curx, double cury, double *pdx, double *pdy, double *pstartSlope, double *pendSlope) const +{ + double dx = x() - curx; + double dy = y() - cury; + double startSlope = 0; + double endSlope = 0; + *pdx = dx; + *pdy = dy; + *pstartSlope = startSlope; + *pendSlope = endSlope; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPathSegMovetoAbsImpl::s_hashTable 3 + x SVGPathSegMovetoAbsImpl::X DontDelete + y SVGPathSegMovetoAbsImpl::Y DontDelete +@end +*/ + +Value SVGPathSegMovetoAbsImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case X: + return Number(x()); + case Y: + return Number(y()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGPathSegMovetoAbsImpl::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case X: + m_x = value.toNumber(exec); + break; + case Y: + m_y = value.toNumber(exec); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + + + +SVGPathSegMovetoRelImpl::SVGPathSegMovetoRelImpl() : SVGPathSegImpl() +{ + KSVG_EMPTY_FLAGS +} + +SVGPathSegMovetoRelImpl::~SVGPathSegMovetoRelImpl() +{ +} + +void SVGPathSegMovetoRelImpl::setX(const double &x) +{ + m_x = x; +} + +double SVGPathSegMovetoRelImpl::x() const +{ + return m_x; +} + +void SVGPathSegMovetoRelImpl::setY(const double &y) +{ + m_y = y; +} + +double SVGPathSegMovetoRelImpl::y() const +{ + return m_y; +} + +void SVGPathSegMovetoRelImpl::getDeltasAndSlopes(double curx, double cury, double *pdx, double *pdy, double *pstartSlope, double *pendSlope) const +{ + Q_UNUSED(curx); + Q_UNUSED(cury); + double dx = x(); + double dy = y(); + double startSlope = 0; + double endSlope = 0; + *pdx = dx; + *pdy = dy; + *pstartSlope = startSlope; + *pendSlope = endSlope; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPathSegMovetoRelImpl::s_hashTable 3 + x SVGPathSegMovetoRelImpl::X DontDelete + y SVGPathSegMovetoRelImpl::Y DontDelete +@end +*/ + +Value SVGPathSegMovetoRelImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case X: + return Number(x()); + case Y: + return Number(y()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGPathSegMovetoRelImpl::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case X: + m_x = value.toNumber(exec); + break; + case Y: + m_y = value.toNumber(exec); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPathSegMovetoImpl.h b/ksvg/impl/SVGPathSegMovetoImpl.h new file mode 100644 index 00000000..dfbad355 --- /dev/null +++ b/ksvg/impl/SVGPathSegMovetoImpl.h @@ -0,0 +1,107 @@ +/* + 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. +*/ + +#ifndef SVGPathSegMovetoImpl_H +#define SVGPathSegMovetoImpl_H + +#include "ksvg_lookup.h" + +#include "SVGPathSegImpl.h" + +namespace KSVG +{ + +class SVGPathSegMovetoAbsImpl : public SVGPathSegImpl +{ +public: + SVGPathSegMovetoAbsImpl(); + virtual ~SVGPathSegMovetoAbsImpl(); + + virtual unsigned short pathSegType() const { return PATHSEG_MOVETO_ABS; } + virtual DOM::DOMString pathSegTypeAsLetter() const { return "M"; } + virtual QString toString() const { return QString("M %1 %2").arg(m_x).arg(m_y); } + + void setX(const double &); + double x() const; + + void setY(const double &); + double y() const; + + virtual void getDeltasAndSlopes(double curx, double cury, double *dx, double *dy, double *startSlope, double *endSlope) const; + +private: + double m_x; + double m_y; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + X, Y + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +class SVGPathSegMovetoRelImpl : public SVGPathSegImpl +{ +public: + SVGPathSegMovetoRelImpl(); + virtual ~SVGPathSegMovetoRelImpl(); + + virtual unsigned short pathSegType() const { return PATHSEG_MOVETO_REL; } + virtual DOM::DOMString pathSegTypeAsLetter() const { return "m"; } + virtual QString toString() const { return QString("m %1 %2").arg(m_x).arg(m_y); } + + void setX(const double &); + double x() const; + + void setY(const double &); + double y() const; + + virtual void getDeltasAndSlopes(double curx, double cury, double *dx, double *dy, double *startSlope, double *endSlope) const; + +private: + double m_x; + double m_y; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + X, Y + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPatternElementImpl.cc b/ksvg/impl/SVGPatternElementImpl.cc new file mode 100644 index 00000000..0b591487 --- /dev/null +++ b/ksvg/impl/SVGPatternElementImpl.cc @@ -0,0 +1,509 @@ +/* + 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> +#include <klocale.h> + +#include "SVGPatternElement.h" +#include "SVGPatternElementImpl.h" + +#include "CanvasFactory.h" +#include "KSVGCanvas.h" +#include "CanvasItems.h" +#include "SVGHelperImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGTransformListImpl.h" +#include "SVGAnimatedTransformListImpl.h" +#include "SVGAnimatedLengthImpl.h" +#include "SVGAnimatedEnumerationImpl.h" +#include "SVGAnimatedStringImpl.h" +#include "SVGUnitConverter.h" +#include "SVGShapeImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGMatrixImpl.h" +#include "SVGRectImpl.h" + +using namespace KSVG; + +#include "SVGPatternElementImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" + +QValueList<SVGPatternElementImpl *> SVGPatternElementImpl::m_patternElements; + +SVGPatternElementImpl::SVGPatternElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGURIReferenceImpl(), SVGTestsImpl(), SVGLangSpaceImpl(), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this), SVGFitToViewBoxImpl(), SVGPaintServerImpl() +{ + KSVG_EMPTY_FLAGS + + m_patternUnits = new SVGAnimatedEnumerationImpl(); + m_patternUnits->ref(); + + m_patternContentUnits = new SVGAnimatedEnumerationImpl(); + m_patternContentUnits->ref(); + + m_patternTransform = new SVGAnimatedTransformListImpl(); + m_patternTransform->ref(); + + m_x = new SVGAnimatedLengthImpl(LENGTHMODE_WIDTH, this); + m_x->ref(); + + m_y = new SVGAnimatedLengthImpl(LENGTHMODE_HEIGHT, this); + m_y->ref(); + + m_width = new SVGAnimatedLengthImpl(LENGTHMODE_WIDTH, this); + m_width->ref(); + + m_height = new SVGAnimatedLengthImpl(LENGTHMODE_HEIGHT, this); + m_height->ref(); + + m_converter = new SVGUnitConverter(); + m_converter->add(m_x); + m_converter->add(m_y); + m_converter->add(m_width); + m_converter->add(m_height); + + m_patternElements.append(this); + + m_canvas = 0; + m_location = this; + + m_tileCache.setMaxTotalCost(1024 * 1024); +} + +SVGPatternElementImpl::~SVGPatternElementImpl() +{ + if(m_patternUnits) + m_patternUnits->deref(); + if(m_patternContentUnits) + m_patternContentUnits->deref(); + if(m_patternTransform) + m_patternTransform->deref(); + if(m_x) + m_x->deref(); + if(m_y) + m_y->deref(); + if(m_width) + m_width->deref(); + if(m_height) + m_height->deref(); + delete m_converter; + m_patternElements.remove(this); +} + +SVGAnimatedEnumerationImpl *SVGPatternElementImpl::patternUnits() const +{ + return m_patternUnits; +} + +SVGAnimatedEnumerationImpl *SVGPatternElementImpl::patternContentUnits() const +{ + return m_patternContentUnits; +} + +SVGAnimatedTransformListImpl *SVGPatternElementImpl::patternTransform() const +{ + return m_patternTransform; +} + +SVGAnimatedLengthImpl *SVGPatternElementImpl::x() const +{ + return m_x; +} + +SVGAnimatedLengthImpl *SVGPatternElementImpl::y() const +{ + return m_y; +} + +SVGAnimatedLengthImpl *SVGPatternElementImpl::width() const +{ + return m_width; +} + +SVGAnimatedLengthImpl *SVGPatternElementImpl::height() const +{ + return m_height; +} + +void SVGPatternElementImpl::createItem(KSVGCanvas *c) +{ + if(!c) + c = ownerDoc()->canvas(); + + if(!m_paintServer) + m_paintServer = c->createPaintServer(this); +} + +void SVGPatternElementImpl::removeItem(KSVGCanvas *) +{ + delete m_paintServer; + m_paintServer = 0; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPatternElementImpl::s_hashTable 11 + x SVGPatternElementImpl::X DontDelete|ReadOnly + y SVGPatternElementImpl::Y DontDelete|ReadOnly + width SVGPatternElementImpl::Width DontDelete|ReadOnly + height SVGPatternElementImpl::Height DontDelete|ReadOnly + patternUnits SVGPatternElementImpl::PatternUnits DontDelete|ReadOnly + patternContentUnits SVGPatternElementImpl::PatternContentUnits DontDelete|ReadOnly + patternTransform SVGPatternElementImpl::PatternTransform DontDelete|ReadOnly +@end +*/ + +Value SVGPatternElementImpl::getValueProperty(ExecState *exec, int token) const +{ + KSVG_CHECK_ATTRIBUTE + + switch(token) + { + case X: + if(!attributeMode) + return m_x->cache(exec); + else + return Number(m_x->baseVal()->value()); + case Y: + if(!attributeMode) + return m_y->cache(exec); + else + return Number(m_y->baseVal()->value()); + case Width: + if(!attributeMode) + return m_width->cache(exec); + else + return Number(m_width->baseVal()->value()); + case Height: + if(!attributeMode) + return m_height->cache(exec); + else + return Number(m_height->baseVal()->value()); + case PatternUnits: + if(!attributeMode) + return m_patternUnits->cache(exec); + else + return Number(m_patternUnits->baseVal()); + case PatternContentUnits: + if(!attributeMode) + return m_patternContentUnits->cache(exec); + else + return Number(m_patternContentUnits->baseVal()); + case PatternTransform: + //if(!attributeMode) + return m_patternTransform->cache(exec); + //else + // return Number(m_patternTransform->baseVal()->value()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGPatternElementImpl::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; + + switch(token) + { + case X: + converter()->modify(x(), value.toString(exec).qstring()); + break; + case Y: + converter()->modify(y(), value.toString(exec).qstring()); + break; + case Width: + converter()->modify(width(), value.toString(exec).qstring()); + if(width()->baseVal()->value() < 0) // A negative value is an error + gotError(i18n("Negative value for attribute width of element <pattern> is illegal")); + break; + case Height: + converter()->modify(height(), value.toString(exec).qstring()); + if(height()->baseVal()->value() < 0) // A negative value is an error + gotError(i18n("Negative value for attribute height of element <pattern> is illegal")); + break; + case PatternUnits: + if(value.toString(exec).qstring() == "userSpaceOnUse") + m_patternUnits->setBaseVal(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE); + else + m_patternUnits->setBaseVal(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX); + break; + case PatternContentUnits: + if(value.toString(exec).qstring() == "userSpaceOnUse") + m_patternContentUnits->setBaseVal(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE); + else + m_patternContentUnits->setBaseVal(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX); + break; + case PatternTransform: + m_patternTransform->baseVal()->clear(); + SVGHelperImpl::parseTransformAttribute(m_patternTransform->baseVal(), value.toString(exec).qstring()); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +void SVGPatternElementImpl::setAttributes() +{ + SVGElementImpl::setAttributes(); + + // Spec: if attribute not specified, use a value of 0 + if(KSVG_TOKEN_NOT_PARSED(X)) + KSVG_SET_ALT_ATTRIBUTE(X, "0") + + // Spec: if attribute not specified, use a value of 0 + if(KSVG_TOKEN_NOT_PARSED(Y)) + KSVG_SET_ALT_ATTRIBUTE(Y, "0") + + // Spec: if attribute not specified, use objectBoundingBox + if(KSVG_TOKEN_NOT_PARSED(PatternUnits)) + KSVG_SET_ALT_ATTRIBUTE(PatternUnits, "objectBoundingBox") + + // Spec: If attribute not specified, use userSpaceOnUse + if(KSVG_TOKEN_NOT_PARSED(PatternContentUnits)) + KSVG_SET_ALT_ATTRIBUTE(PatternContentUnits, "userSpaceOnUse") + + // Spec: default value + if(KSVG_TOKEN_NOT_PARSED(PreserveAspectRatio)) + KSVG_SET_ALT_ATTRIBUTE(PreserveAspectRatio, "xMidYMid meet") +} + +void SVGPatternElementImpl::flushCachedTiles() +{ + QValueList<SVGPatternElementImpl *>::iterator it; + + for(it = m_patternElements.begin(); it != m_patternElements.end(); it++) + { + SVGPatternElementImpl *pattern = *it; + + if(pattern->paintServer()) + pattern->paintServer()->resetFinalized(); + } +} + +QImage SVGPatternElementImpl::createTile(SVGShapeImpl *referencingElement, int imageWidth, int imageHeight) +{ + converter()->finalize(referencingElement, ownerSVGElement(), patternUnits()->baseVal()); + + QImage image(imageWidth, imageHeight, 32); + image.setAlphaBuffer(true); + + if(m_canvas == 0) + { + m_canvas = CanvasFactory::self()->loadCanvas(image.width(), image.height()); + m_canvas->setBackgroundColor(qRgba(0, 0, 0, 0)); + } + + m_canvas->setup(image.bits(), image.width(), image.height()); + + SVGMatrixImpl *baseMatrix = SVGSVGElementImpl::createSVGMatrix(); + + // Set the scale to map the tile onto the integral sized image + double xScale = static_cast<double>(imageWidth) / width()->baseVal()->value(); + double yScale = static_cast<double>(imageHeight) / height()->baseVal()->value(); + + baseMatrix->scaleNonUniform(xScale, yScale); + + if(hasAttribute("viewBox")) + { + SVGMatrixImpl *viewboxMatrix = viewBoxToViewTransform(width()->baseVal()->value(), height()->baseVal()->value()); + + baseMatrix->multiply(viewboxMatrix); + viewboxMatrix->deref(); + } + else + { + if(patternContentUnits()->baseVal() == SVGPatternElement::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) + { + // Get local coordinate bounding box + SVGRectImpl *rect = referencingElement->getBBox(); + + baseMatrix->translate(rect->qrect().x(), rect->qrect().y()); + baseMatrix->scaleNonUniform(rect->qrect().width(), rect->qrect().height()); + rect->deref(); + } + } + + for(DOM::Node node = m_location->firstChild(); !node.isNull(); node = node.nextSibling()) + { + SVGElementImpl *element = ownerDoc()->getElementFromHandle(node.handle()); + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(element); + SVGTestsImpl *tests = dynamic_cast<SVGTestsImpl *>(element); + SVGStylableImpl *style = dynamic_cast<SVGStylableImpl *>(element); + + bool ok = tests ? tests->ok() : true; + if(element && shape && style && ok && style->getVisible() && style->getDisplay()) + { + SVGLocatableImpl *locatable = dynamic_cast<SVGLocatableImpl *>(element); + if(locatable) + locatable->updateCachedScreenCTM(baseMatrix); + + element->createItem(m_canvas); + if(shape->item()) + { + shape->item()->setReferenced(true); + m_canvas->invalidate(shape->item(), true); + } + } + } + + baseMatrix->deref(); + + m_canvas->update(float(1)); + + if(getOverflow()) + { + QPtrList<CanvasItem> items = m_canvas->allItems(); + QRect allItemsBBox; + + QPtrListIterator<CanvasItem> it(items); + CanvasItem *item; + + while((item = *it) != 0) + { + QRect bbox = item->bbox(); + allItemsBBox |= bbox; + ++it; + } + + if(allItemsBBox.left() < 0 || allItemsBBox.right() >= imageWidth || allItemsBBox.top() < 0 || allItemsBBox.bottom() >= imageHeight) + { + // Get the range in whole-tile units that covers the bounding box, where (0, 0) is the + // usual tile position. + int tileLeft = (allItemsBBox.left() - (imageWidth - 1)) / imageWidth; + int tileRight = allItemsBBox.right() / imageWidth; + int tileTop = (allItemsBBox.top() - (imageHeight - 1)) / imageHeight; + int tileBottom = allItemsBBox.bottom() / imageHeight; + + for(int tileX = tileLeft; tileX <= tileRight; tileX++) + { + for(int tileY = tileTop; tileY <= tileBottom; tileY++) + { + if(tileX != 0 || tileY !=0) + { + QPoint panPoint(-(tileX * imageWidth), -(tileY * imageHeight)); + m_canvas->update(panPoint, false); + } + } + } + } + } + + for(DOM::Node node = m_location->firstChild(); !node.isNull(); node = node.nextSibling()) + { + SVGElementImpl *element = ownerDoc()->getElementFromHandle(node.handle()); + + if(element) + element->removeItem(m_canvas); + } + + return image; +} + +void SVGPatternElementImpl::reference(const QString &href) +{ + // Copy attributes + SVGElementImpl *src = ownerSVGElement()->getElementById(href); + + if(src) + { + SVGHelperImpl::copyAttributes(src, this); + + // Spec: Change location to referenced element so we + // can take the children elements to render from there + if(m_location == this) + m_location = src; + } +} + +void SVGPatternElementImpl::finalizePaintServer() +{ + // Clear out any cached tiles since we may be being refinalised after an image + // inside a pattern has finished loading. + m_tileCache.clear(); + + QString _href = SVGURIReferenceImpl::getTarget(href()->baseVal().string()); + if(!_href.isEmpty()) + reference(_href); +} + +SVGPatternElementImpl::Tile SVGPatternElementImpl::createTile(SVGShapeImpl *referencingElement) +{ + converter()->finalize(referencingElement, ownerSVGElement(), patternUnits()->baseVal()); + + SVGTransformableImpl *transformable = dynamic_cast<SVGTransformableImpl *>(referencingElement); + SVGMatrixImpl *matrix = 0; + if(transformable) + matrix = transformable->getScreenCTM(); + else + matrix = SVGSVGElementImpl::createSVGMatrix(); + + matrix->translate(x()->baseVal()->value(), y()->baseVal()->value()); + + SVGMatrixImpl *patTransform = patternTransform()->baseVal()->concatenate(); + if(patTransform) + { + matrix->multiply(patTransform); + patTransform->deref(); + } + + double xScale, yScale; + matrix->removeScale(&xScale, &yScale); + + double tileWidth = width()->baseVal()->value() * xScale; + double tileHeight = height()->baseVal()->value() * yScale; + + int imageWidth = static_cast<int>(tileWidth + 0.5); + int imageHeight = static_cast<int>(tileHeight + 0.5); + + Tile tile; + + if(imageWidth > 0 && imageHeight > 0) + { + QSize size(imageWidth, imageHeight); + QImage image; + + if(!m_tileCache.find(size, image)) + { + image = createTile(referencingElement, imageWidth, imageHeight); + m_tileCache.insert(size, image, image.width() * image.height() * 4); + } + + // Map integral tile dimensions onto its true size + double adjustXScale = tileWidth / imageWidth; + double adjustYScale = tileHeight / imageHeight; + + matrix->scaleNonUniform(adjustXScale, adjustYScale); + QWMatrix screenToTile = matrix->qmatrix().invert(); + + tile = Tile(image, screenToTile); + } + + matrix->deref(); + + return tile; +} + diff --git a/ksvg/impl/SVGPatternElementImpl.h b/ksvg/impl/SVGPatternElementImpl.h new file mode 100644 index 00000000..612fcfae --- /dev/null +++ b/ksvg/impl/SVGPatternElementImpl.h @@ -0,0 +1,136 @@ +/* + 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. +*/ + +#ifndef SVGPatternElementImpl_H +#define SVGPatternElementImpl_H + +#include <qimage.h> +#include <qwmatrix.h> + +#include "SVGTestsImpl.h" +#include "SVGElementImpl.h" +#include "SVGStylableImpl.h" +#include "SVGLangSpaceImpl.h" +#include "SVGURIReferenceImpl.h" +#include "SVGFitToViewBoxImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" +#include "SVGPaintServerImpl.h" +#include "LRUCache.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGUnitConverter; +class SVGAnimatedLengthImpl; +class SVGAnimatedEnumerationImpl; +class SVGAnimatedTransformListImpl; +class SVGShapeImpl; +class SVGPatternElementImpl : public SVGElementImpl, + public SVGURIReferenceImpl, + public SVGTestsImpl, + public SVGLangSpaceImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl, + public SVGFitToViewBoxImpl, + public SVGPaintServerImpl +{ +public: + SVGPatternElementImpl(DOM::ElementImpl *); + virtual ~SVGPatternElementImpl(); + + SVGAnimatedEnumerationImpl *patternUnits() const; + SVGAnimatedEnumerationImpl *patternContentUnits() const; + SVGAnimatedTransformListImpl *patternTransform() const; + SVGAnimatedLengthImpl *x() const; + SVGAnimatedLengthImpl *y() const; + SVGAnimatedLengthImpl *width() const; + SVGAnimatedLengthImpl *height() const; + + virtual void setAttributes(); + + virtual void createItem(KSVGCanvas *c = 0); + virtual void removeItem(KSVGCanvas *c); + + SVGUnitConverter *converter() const { return m_converter; } + + void reference(const QString &href); + void finalizePaintServer(); + + class Tile + { + public: + Tile() {} + Tile(const QImage& image, const QWMatrix& screenToTile) : m_image(image), m_screenToTile(screenToTile) {} + + QImage image() const { return m_image; } + const QWMatrix& screenToTile() const { return m_screenToTile; } + + private: + QImage m_image; + QWMatrix m_screenToTile; + }; + + Tile createTile(SVGShapeImpl *referencingElement); + + static void flushCachedTiles(); + +private: + QImage createTile(SVGShapeImpl *referencingElement, int imageWidth, int imageHeight); + + SVGAnimatedEnumerationImpl *m_patternUnits; + SVGAnimatedEnumerationImpl *m_patternContentUnits; + SVGAnimatedTransformListImpl *m_patternTransform; + SVGAnimatedLengthImpl *m_x; + SVGAnimatedLengthImpl *m_y; + SVGAnimatedLengthImpl *m_width; + SVGAnimatedLengthImpl *m_height; + + SVGUnitConverter *m_converter; + + KSVGCanvas *m_canvas; + SVGElementImpl *m_location; // the referenced element + MinOneLRUCache<QSize, QImage> m_tileCache; + + static QValueList<SVGPatternElementImpl *> m_patternElements; + +public: + KSVG_GET + KSVG_PUT + KSVG_BRIDGE + + enum + { + // Properties + X, Y, Width, Height, PatternUnits, PatternContentUnits, PatternTransform + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +KSVG_REGISTER_ELEMENT(SVGPatternElementImpl, "pattern") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPointImpl.cc b/ksvg/impl/SVGPointImpl.cc new file mode 100644 index 00000000..c3697f58 --- /dev/null +++ b/ksvg/impl/SVGPointImpl.cc @@ -0,0 +1,108 @@ +/* + 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> + +#include "SVGPointImpl.h" +#include "SVGSVGElementImpl.h" + +using namespace KSVG; + +#include "SVGPointImpl.lut.h" +#include "ksvg_bridge.h" + +SVGPointImpl::SVGPointImpl() : DOM::DomShared() +{ + KSVG_EMPTY_FLAGS + + m_x = 0; + m_y = 0; +} + +SVGPointImpl::~SVGPointImpl() +{ +} + +void SVGPointImpl::setX(float x) +{ + m_x = x; +} + +float SVGPointImpl::x() const +{ + return m_x; +} + +void SVGPointImpl::setY(float y) +{ + m_y = y; +} + +float SVGPointImpl::y() const +{ + return m_y; +} + +SVGPointImpl *SVGPointImpl::matrixTransform(const SVGMatrixImpl &) +{ + SVGPointImpl *ret = SVGSVGElementImpl::createSVGPoint(); + return ret; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPointImpl::s_hashTable 3 + x SVGPointImpl::X DontDelete + y SVGPointImpl::Y DontDelete +@end +*/ + +Value SVGPointImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case X: + return Number(x()); + case Y: + return Number(y()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGPointImpl::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case X: + m_x = value.toNumber(exec); + break; + case Y: + m_y = value.toNumber(exec); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPointImpl.h b/ksvg/impl/SVGPointImpl.h new file mode 100644 index 00000000..55132cf3 --- /dev/null +++ b/ksvg/impl/SVGPointImpl.h @@ -0,0 +1,66 @@ +/* + 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. +*/ + +#ifndef SVGPointImpl_H +#define SVGPointImpl_H + +#include <dom/dom_misc.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGMatrixImpl; +class SVGPointImpl : public DOM::DomShared +{ +public: + SVGPointImpl(); + virtual ~SVGPointImpl(); + + void setX(float x); + float x() const; + + void setY(float y); + float y() const; + + SVGPointImpl *matrixTransform(const SVGMatrixImpl &matrix); + +private: + float m_x; + float m_y; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + X, Y + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif diff --git a/ksvg/impl/SVGPointListImpl.cc b/ksvg/impl/SVGPointListImpl.cc new file mode 100644 index 00000000..34574b60 --- /dev/null +++ b/ksvg/impl/SVGPointListImpl.cc @@ -0,0 +1,64 @@ +/* + 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> + +#include "SVGPointListImpl.h" + +using namespace KSVG; + +#include "SVGPointListImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPointListImpl::s_hashTable 2 + numberOfItems SVGListDefs::NumberOfItems DontDelete|ReadOnly +@end +@namespace KSVG +@begin SVGPointListImplProto::s_hashTable 11 + getItem SVGListDefs::GetItem DontDelete|Function 1 + removeItem SVGListDefs::RemoveItem DontDelete|Function 1 + appendItem SVGListDefs::AppendItem DontDelete|Function 1 + initialize SVGListDefs::Initialize DontDelete|Function 1 + insertItemBefore SVGListDefs::InsertItemBefore DontDelete|Function 2 + replaceItem SVGListDefs::ReplaceItem DontDelete|Function 2 + clear SVGListDefs::Clear DontDelete|Function 0 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGPointList", SVGPointListImplProto, SVGPointListImplProtoFunc) + +Value SVGPointListImpl::getValueProperty(ExecState *exec, int token) const +{ + return SVGList<SVGPointImpl>::getValueProperty(exec, token); +} + +Value SVGPointListImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGPointListImpl) + + return obj->call(exec, static_cast<SVGList<SVGPointImpl> *>(obj), args, id); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPointListImpl.h b/ksvg/impl/SVGPointListImpl.h new file mode 100644 index 00000000..61d93731 --- /dev/null +++ b/ksvg/impl/SVGPointListImpl.h @@ -0,0 +1,48 @@ +/* + 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. +*/ + +#ifndef SVGPointListImpl_H +#define SVGPointListImpl_H + +#include "SVGList.h" + +#include "SVGPointImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGPointListImpl : public SVGList<SVGPointImpl> +{ +public: + KSVG_GET + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; +}; + +} + +KSVG_DEFINE_PROTOTYPE(SVGPointListImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGPointListImplProtoFunc, SVGPointListImpl) + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPolyElementImpl.cc b/ksvg/impl/SVGPolyElementImpl.cc new file mode 100644 index 00000000..69ef57cd --- /dev/null +++ b/ksvg/impl/SVGPolyElementImpl.cc @@ -0,0 +1,141 @@ +/* + 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 <math.h> +#include <cfloat> + +#include <kdebug.h> + +#include "SVGRectImpl.h" +#include "SVGPointListImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGPolyElementImpl.h" +#include "SVGAngleImpl.h" + +using namespace KSVG; + +SVGPolyElementImpl::SVGPolyElementImpl(DOM::ElementImpl *impl) : SVGShapeImpl(impl), SVGTestsImpl(), SVGLangSpaceImpl(), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this), SVGTransformableImpl(), SVGAnimatedPointsImpl() +{ +} + +SVGPolyElementImpl::~SVGPolyElementImpl() +{ +} + +SVGRectImpl *SVGPolyElementImpl::getBBox() +{ + SVGRectImpl *ret = SVGSVGElementImpl::createSVGRect(); + + unsigned int nrPoints = points()->numberOfItems(); + float minx, miny, maxx, maxy, tempx, tempy; + minx = points()->getItem(0)->x(); + miny = points()->getItem(0)->y(); + maxx = points()->getItem(0)->x(); + maxy = points()->getItem(0)->y(); + + for(unsigned int i = 1; i < nrPoints; ++i) + { + tempx = points()->getItem(i)->x(); + tempy = points()->getItem(i)->y(); + + if(tempx < minx) + minx = tempx; + if(tempx > maxx) + maxx = tempx; + if(tempy < miny) + miny = tempy; + if(tempy > maxy) + maxy = tempy; + } + + ret->setX(minx); + ret->setY(miny); + ret->setWidth(maxx - minx); + ret->setHeight(maxy - miny); + return ret; +} + +bool SVGPolyElementImpl::findOutSlope(unsigned int point, double *outSlope) const +{ + unsigned int nextPoint; + + if(point == points()->numberOfItems() - 1) + { + if(m_isOpenPath) + return false; + else + nextPoint = 0; + } + else + nextPoint = point + 1; + + if(point == nextPoint) + return false; + + double x = points()->getItem(point)->x(); + double y = points()->getItem(point)->y(); + double nextX = points()->getItem(nextPoint)->x(); + double nextY = points()->getItem(nextPoint)->y(); + const double epsilon = DBL_EPSILON; + + if(fabs(x - nextX) < epsilon && fabs(y - nextY) < epsilon) + return findOutSlope(nextPoint, outSlope); + else + { + double slope = SVGAngleImpl::todeg(atan2(nextY - y, nextX - x)); + *outSlope = slope; + return true; + } +} + +bool SVGPolyElementImpl::findInSlope(unsigned int point, double *inSlope) const +{ + unsigned int prevPoint; + + if(point == 0) + { + if(m_isOpenPath) + return false; + else + prevPoint = points()->numberOfItems() - 1; + } + else + prevPoint = point - 1; + + if(point == prevPoint) + return false; + + double x = points()->getItem(point)->x(); + double y = points()->getItem(point)->y(); + double prevX = points()->getItem(prevPoint)->x(); + double prevY = points()->getItem(prevPoint)->y(); + const double epsilon = DBL_EPSILON; + + if(fabs(x - prevX) < epsilon && fabs(y - prevY) < epsilon) + return findInSlope(prevPoint, inSlope); + else + { + double slope = SVGAngleImpl::todeg(atan2(y - prevY, x - prevX)); + *inSlope = slope; + return true; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPolyElementImpl.h b/ksvg/impl/SVGPolyElementImpl.h new file mode 100644 index 00000000..ded41d0c --- /dev/null +++ b/ksvg/impl/SVGPolyElementImpl.h @@ -0,0 +1,70 @@ +/* + 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. +*/ + +#ifndef SVGPolyElementImpl_H +#define SVGPolyElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGShapeImpl.h" +#include "SVGTestsImpl.h" +#include "SVGStylableImpl.h" +#include "SVGLangSpaceImpl.h" +#include "SVGTransformableImpl.h" +#include "SVGAnimatedPointsImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + +namespace KSVG +{ + +class SVGPointListImpl; +class SVGPolyElementImpl : public SVGShapeImpl, + public SVGTestsImpl, + public SVGLangSpaceImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl, + public SVGTransformableImpl, + public SVGAnimatedPointsImpl +{ +public: + SVGPolyElementImpl(DOM::ElementImpl *); + virtual ~SVGPolyElementImpl(); + + virtual SVGRectImpl *getBBox(); + + virtual void drawMarkers() = 0; + +protected: + bool findOutSlope(unsigned int point, double *outSlope) const; + bool findInSlope(unsigned int point, double *inSlope) const; + + bool m_isOpenPath; + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT + KSVG_NO_TAG_BRIDGE +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPolygonElementImpl.cc b/ksvg/impl/SVGPolygonElementImpl.cc new file mode 100644 index 00000000..bf38ff37 --- /dev/null +++ b/ksvg/impl/SVGPolygonElementImpl.cc @@ -0,0 +1,88 @@ +/* + 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 "SVGPointListImpl.h" +#include "SVGPolygonElementImpl.h" +#include "SVGDocumentImpl.h" +#include "KSVGCanvas.h" +#include "SVGAngleImpl.h" + +using namespace KSVG; + +SVGPolygonElementImpl::SVGPolygonElementImpl(DOM::ElementImpl *impl) : SVGPolyElementImpl(impl) +{ + m_isOpenPath = false; +} + +void SVGPolygonElementImpl::createItem(KSVGCanvas *c) +{ + if(!c) + c = ownerDoc()->canvas(); + + if(!m_item) + { + m_item = c->createPolygon(this); + c->insert(m_item); + } +} + +void SVGPolygonElementImpl::drawMarkers() +{ + SVGPointListImpl *pts = points(); + unsigned int nrPoints = pts->numberOfItems(); + + if(nrPoints > 0 && hasMarkers()) + { + for(unsigned int i = 0; i < nrPoints; ++i) + { + double inSlope; + double outSlope; + bool haveInSlope = findInSlope(i, &inSlope); + bool haveOutSlope = findOutSlope(i, &outSlope); + + if(!haveInSlope && haveOutSlope) + inSlope = outSlope; + else if(haveInSlope && !haveOutSlope) + outSlope = inSlope; + else if(!haveInSlope && !haveOutSlope) + { + inSlope = 0; + outSlope = 0; + } + + double bisector = SVGAngleImpl::shortestArcBisector(inSlope, outSlope); + + if(i == 0) + { + if(hasStartMarker()) + doStartMarker(this, this, pts->getItem(i)->x(), pts->getItem(i)->y(), bisector); + if(hasEndMarker()) + doEndMarker(this, this, pts->getItem(i)->x(), pts->getItem(i)->y(), bisector); + } + else + { + if(hasMidMarker()) + doMidMarker(this, this, pts->getItem(i)->x(), pts->getItem(i)->y(), bisector); + } + } + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPolygonElementImpl.h b/ksvg/impl/SVGPolygonElementImpl.h new file mode 100644 index 00000000..1c7e8c3b --- /dev/null +++ b/ksvg/impl/SVGPolygonElementImpl.h @@ -0,0 +1,54 @@ +/* + 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. +*/ + +#ifndef SVGPolygonElementImpl_H +#define SVGPolygonElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGPolyElementImpl.h" +#include "CanvasItems.h" + +namespace KSVG +{ + +class SVGPolygonElementImpl : public SVGPolyElementImpl, public MarkerHelper +{ +public: + SVGPolygonElementImpl(DOM::ElementImpl *); + virtual ~SVGPolygonElementImpl() { } + + virtual void createItem(KSVGCanvas *c = 0); + + virtual void drawMarkers(); + +public: + KSVG_BRIDGE + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +KSVG_REGISTER_ELEMENT(SVGPolygonElementImpl, "polygon") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPolylineElementImpl.cc b/ksvg/impl/SVGPolylineElementImpl.cc new file mode 100644 index 00000000..9c95a928 --- /dev/null +++ b/ksvg/impl/SVGPolylineElementImpl.cc @@ -0,0 +1,100 @@ +/* + 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 "SVGPointListImpl.h" +#include "SVGPolylineElementImpl.h" +#include "SVGDocumentImpl.h" +#include "KSVGCanvas.h" +#include "SVGAngleImpl.h" + +using namespace KSVG; + +SVGPolylineElementImpl::SVGPolylineElementImpl(DOM::ElementImpl *impl) : SVGPolyElementImpl(impl) +{ + m_isOpenPath = true; +} + +void SVGPolylineElementImpl::createItem(KSVGCanvas *c) +{ + if(!c) + c = ownerDoc()->canvas(); + + if(!m_item) + { + m_item = c->createPolyline(this); + c->insert(m_item); + } +} + +void SVGPolylineElementImpl::drawMarkers() +{ + SVGPointListImpl *pts = points(); + unsigned int nrPoints = pts->numberOfItems(); + + if(nrPoints > 0 && hasMarkers()) + { + if(hasStartMarker()) + { + double outSlope; + + if(!findOutSlope(0, &outSlope)) + outSlope = 0; + + doStartMarker(this, this, pts->getItem(0)->x(), pts->getItem(0)->y(), outSlope); + } + + if(hasMidMarker()) + { + for(unsigned int i = 1; i < nrPoints - 1; ++i) + { + double inSlope; + double outSlope; + bool haveInSlope = findInSlope(i, &inSlope); + bool haveOutSlope = findOutSlope(i, &outSlope); + + if(!haveInSlope && haveOutSlope) + inSlope = outSlope; + else if(haveInSlope && !haveOutSlope) + outSlope = inSlope; + else if(!haveInSlope && !haveOutSlope) + { + inSlope = 0; + outSlope = 0; + } + + double bisector = SVGAngleImpl::shortestArcBisector(inSlope, outSlope); + + doMidMarker(this, this, pts->getItem(i)->x(), pts->getItem(i)->y(), bisector); + } + } + + if(hasEndMarker()) + { + double inSlope; + + if(!findInSlope(nrPoints - 1, &inSlope)) + inSlope = 0; + + doEndMarker(this, this, pts->getItem(nrPoints - 1)->x(), pts->getItem(nrPoints - 1)->y(), inSlope); + } + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPolylineElementImpl.h b/ksvg/impl/SVGPolylineElementImpl.h new file mode 100644 index 00000000..c6ea5885 --- /dev/null +++ b/ksvg/impl/SVGPolylineElementImpl.h @@ -0,0 +1,54 @@ +/* + 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. +*/ + +#ifndef SVGPolylineElementImpl_H +#define SVGPolylineElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGPolyElementImpl.h" +#include "CanvasItems.h" + +namespace KSVG +{ + +class SVGPolylineElementImpl : public SVGPolyElementImpl, public MarkerHelper +{ +public: + SVGPolylineElementImpl(DOM::ElementImpl *); + virtual ~SVGPolylineElementImpl() { } + + virtual void createItem(KSVGCanvas *c = 0); + + virtual void drawMarkers(); + +public: + KSVG_BRIDGE + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +KSVG_REGISTER_ELEMENT(SVGPolylineElementImpl, "polyline") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPreserveAspectRatioImpl.cc b/ksvg/impl/SVGPreserveAspectRatioImpl.cc new file mode 100644 index 00000000..c8660e61 --- /dev/null +++ b/ksvg/impl/SVGPreserveAspectRatioImpl.cc @@ -0,0 +1,217 @@ +/* + 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> + +#include <qstring.h> +#include <qstringlist.h> + +#include "SVGPreserveAspectRatio.h" + +#include "SVGMatrixImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGPreserveAspectRatioImpl.h" + +using namespace KSVG; + +#include "SVGPreserveAspectRatioImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_cacheimpl.h" + +SVGPreserveAspectRatioImpl::SVGPreserveAspectRatioImpl() +{ + KSVG_EMPTY_FLAGS + + m_meetOrSlice = SVG_MEETORSLICE_UNKNOWN; + m_align = SVG_PRESERVEASPECTRATIO_UNKNOWN; +} + +SVGPreserveAspectRatioImpl::~SVGPreserveAspectRatioImpl() +{ +} + +void SVGPreserveAspectRatioImpl::setAlign(unsigned short align) +{ + m_align = align; +} + +unsigned short SVGPreserveAspectRatioImpl::align() const +{ + return m_align; +} + +void SVGPreserveAspectRatioImpl::setMeetOrSlice(unsigned short meetOrSlice) +{ + m_meetOrSlice = meetOrSlice; +} + +unsigned short SVGPreserveAspectRatioImpl::meetOrSlice() const +{ + return m_meetOrSlice; +} + +void SVGPreserveAspectRatioImpl::parsePreserveAspectRatio(const QString &str) +{ + // Spec: set the defaults + setAlign(SVG_PRESERVEASPECTRATIO_NONE); + setMeetOrSlice(SVG_MEETORSLICE_MEET); + + QStringList params = QStringList::split(' ', str.simplifyWhiteSpace()); + + if(params[0].compare("none") == 0) + m_align = SVG_PRESERVEASPECTRATIO_NONE; + else if(params[0].compare("xMinYMin") == 0) + m_align = SVG_PRESERVEASPECTRATIO_XMINYMIN; + else if(params[0].compare("xMidYMin") == 0) + m_align = SVG_PRESERVEASPECTRATIO_XMIDYMIN; + else if(params[0].compare("xMaxYMin") == 0) + m_align = SVG_PRESERVEASPECTRATIO_XMAXYMIN; + else if(params[0].compare("xMinYMid") == 0) + m_align = SVG_PRESERVEASPECTRATIO_XMINYMID; + else if(params[0].compare("xMidYMid") == 0) + m_align = SVG_PRESERVEASPECTRATIO_XMIDYMID; + else if(params[0].compare("xMaxYMid") == 0) + m_align = SVG_PRESERVEASPECTRATIO_XMAXYMID; + else if(params[0].compare("xMinYMax") == 0) + m_align = SVG_PRESERVEASPECTRATIO_XMINYMAX; + else if(params[0].compare("xMidYMax") == 0) + m_align = SVG_PRESERVEASPECTRATIO_XMIDYMAX; + else if(params[0].compare("xMaxYMax") == 0) + m_align = SVG_PRESERVEASPECTRATIO_XMAXYMAX; + + if(params[1].compare("slice") == 0) + m_meetOrSlice = SVG_MEETORSLICE_SLICE; + else + m_meetOrSlice = SVG_MEETORSLICE_MEET; +} + +SVGMatrixImpl *SVGPreserveAspectRatioImpl::getCTM(float logicX, float logicY, float logicWidth, float logicHeight, + float /*physX*/, float /*physY*/, float physWidth, float physHeight) +{ + SVGMatrixImpl *temp = SVGSVGElementImpl::createSVGMatrix(); + + if(align() == SVG_PRESERVEASPECTRATIO_UNKNOWN) + return temp; + + float vpar = logicWidth / logicHeight; + float svgar = physWidth / physHeight; + + if(align() == SVG_PRESERVEASPECTRATIO_NONE) + { + temp->scaleNonUniform(physWidth / logicWidth, physHeight / logicHeight); + temp->translate(-logicX, -logicY); + } + else if(vpar < svgar && (meetOrSlice() == SVG_MEETORSLICE_MEET) || vpar >= svgar && (meetOrSlice() == SVG_MEETORSLICE_SLICE)) + { + temp->scale(physHeight / logicHeight); + + if(align() == SVG_PRESERVEASPECTRATIO_XMINYMIN || align() == SVG_PRESERVEASPECTRATIO_XMINYMID || align() == SVG_PRESERVEASPECTRATIO_XMINYMAX) + temp->translate(-logicX, -logicY); + else if(align() == SVG_PRESERVEASPECTRATIO_XMIDYMIN || align() == SVG_PRESERVEASPECTRATIO_XMIDYMID || align() == SVG_PRESERVEASPECTRATIO_XMIDYMAX) + temp->translate(-logicX - (logicWidth - physWidth * logicHeight / physHeight) / 2, -logicY); + else + temp->translate(-logicX - (logicWidth - physWidth * logicHeight / physHeight), -logicY); + } + else + { + temp->scale(physWidth / logicWidth); + + if(align() == SVG_PRESERVEASPECTRATIO_XMINYMIN || align() == SVG_PRESERVEASPECTRATIO_XMIDYMIN || align() == SVG_PRESERVEASPECTRATIO_XMAXYMIN) + temp->translate(-logicX, -logicY); + else if(align() == SVG_PRESERVEASPECTRATIO_XMINYMID || align() == SVG_PRESERVEASPECTRATIO_XMIDYMID || align() == SVG_PRESERVEASPECTRATIO_XMAXYMID) + temp->translate(-logicX, -logicY - (logicHeight - physHeight * logicWidth / physWidth) / 2); + else + temp->translate(-logicX, -logicY - (logicHeight - physHeight * logicWidth / physWidth)); + } + + return temp; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGPreserveAspectRatioImpl::s_hashTable 3 + align SVGPreserveAspectRatioImpl::Align DontDelete + meetOrSlice SVGPreserveAspectRatioImpl::MeetOrSlice DontDelete +@end +*/ + +Value SVGPreserveAspectRatioImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case Align: + return Number(align()); + case MeetOrSlice: + return Number(meetOrSlice()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return KJS::Undefined(); + } +} + +void SVGPreserveAspectRatioImpl::putValueProperty(ExecState *exec, int token, const KJS::Value &value, int) +{ + switch(token) + { + case Align: + m_align = static_cast<unsigned short>(value.toNumber(exec)); + break; + case MeetOrSlice: + m_meetOrSlice = static_cast<unsigned short>(value.toNumber(exec)); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +/* +@namespace KSVG +@begin SVGPreserveAspectRatioImplConstructor::s_hashTable 17 + SVG_PRESERVEASPECTRATIO_UNKNOWN KSVG::SVG_PRESERVEASPECTRATIO_UNKNOWN DontDelete|ReadOnly + SVG_PRESERVEASPECTRATIO_NONE KSVG::SVG_PRESERVEASPECTRATIO_NONE DontDelete|ReadOnly + SVG_PRESERVEASPECTRATIO_XMINYMIN KSVG::SVG_PRESERVEASPECTRATIO_XMINYMIN DontDelete|ReadOnly + SVG_PRESERVEASPECTRATIO_XMIDYMIN KSVG::SVG_PRESERVEASPECTRATIO_XMIDYMIN DontDelete|ReadOnly + SVG_PRESERVEASPECTRATIO_XMAXYMIN KSVG::SVG_PRESERVEASPECTRATIO_XMAXYMIN DontDelete|ReadOnly + SVG_PRESERVEASPECTRATIO_XMINYMID KSVG::SVG_PRESERVEASPECTRATIO_XMINYMID DontDelete|ReadOnly + SVG_PRESERVEASPECTRATIO_XMIDYMID KSVG::SVG_PRESERVEASPECTRATIO_XMIDYMID DontDelete|ReadOnly + SVG_PRESERVEASPECTRATIO_XMAXYMID KSVG::SVG_PRESERVEASPECTRATIO_XMAXYMID DontDelete|ReadOnly + SVG_PRESERVEASPECTRATIO_XMINYMAX KSVG::SVG_PRESERVEASPECTRATIO_XMINYMAX DontDelete|ReadOnly + SVG_PRESERVEASPECTRATIO_XMIDYMAX KSVG::SVG_PRESERVEASPECTRATIO_XMIDYMAX DontDelete|ReadOnly + SVG_PRESERVEASPECTRATIO_XMAXYMAX KSVG::SVG_PRESERVEASPECTRATIO_XMAXYMAX DontDelete|ReadOnly + SVG_MEETORSLICE_UNKNOWN KSVG::SVG_MEETORSLICE_UNKNOWN DontDelete|ReadOnly + SVG_MEETORSLICE_MEET KSVG::SVG_MEETORSLICE_MEET DontDelete|ReadOnly + SVG_MEETORSLICE_SLICE KSVG::SVG_MEETORSLICE_SLICE DontDelete|ReadOnly +@end +*/ + +Value SVGPreserveAspectRatioImplConstructor::getValueProperty(ExecState *, int token) const +{ + return Number(token > SVG_PRESERVEASPECTRATIO_XMAXYMAX ? token - SVG_MEETORSLICE_UNKNOWN : token); +} + +Value KSVG::getSVGPreserveAspectRatioImplConstructor(ExecState *exec) +{ + return cacheGlobalBridge<SVGPreserveAspectRatioImplConstructor>(exec, "[[svgpreserveaspectratio.constructor]]"); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGPreserveAspectRatioImpl.h b/ksvg/impl/SVGPreserveAspectRatioImpl.h new file mode 100644 index 00000000..4a14a6b0 --- /dev/null +++ b/ksvg/impl/SVGPreserveAspectRatioImpl.h @@ -0,0 +1,84 @@ +/* + 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. +*/ + +#ifndef SVGPreserveAspectRatioImpl_H +#define SVGPreserveAspectRatioImpl_H + +#include <dom/dom_misc.h> + +#include "ksvg_lookup.h" + +class QString; + +namespace KSVG +{ + +class SVGMatrixImpl; +class SVGPreserveAspectRatioImpl : public DOM::DomShared +{ +public: + SVGPreserveAspectRatioImpl(); + virtual ~SVGPreserveAspectRatioImpl(); + + void setAlign(unsigned short); + unsigned short align() const; + + void setMeetOrSlice(unsigned short); + unsigned short meetOrSlice() const; + + void parsePreserveAspectRatio(const QString &); + SVGMatrixImpl *getCTM(float logicX, float logicY, float logicWidth, float logicHeight, + float physX, float physY, float physWidth, float physHeight); + +protected: + unsigned short m_align; + unsigned short m_meetOrSlice; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + Align, MeetOrSlice + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +class SVGPreserveAspectRatioImplConstructor : public KJS::ObjectImp +{ +public: + SVGPreserveAspectRatioImplConstructor(KJS::ExecState *) { } + KJS::Value getValueProperty(KJS::ExecState *, int token) const; + + // no put - all read-only + KSVG_GET +}; + +KJS::Value getSVGPreserveAspectRatioImplConstructor(KJS::ExecState *exec); + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGRadialGradientElementImpl.cc b/ksvg/impl/SVGRadialGradientElementImpl.cc new file mode 100644 index 00000000..8d00cf15 --- /dev/null +++ b/ksvg/impl/SVGRadialGradientElementImpl.cc @@ -0,0 +1,216 @@ +/* + 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 "SVGGradientElement.h" +#include "SVGRadialGradientElementImpl.h" + +#include "SVGDocumentImpl.h" +#include "KSVGCanvas.h" +#include "SVGAnimatedLengthImpl.h" +#include "SVGUnitConverter.h" + +using namespace KSVG; + +#include "SVGRadialGradientElementImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" + +SVGRadialGradientElementImpl::SVGRadialGradientElementImpl(DOM::ElementImpl *impl) : SVGGradientElementImpl(impl) +{ + KSVG_EMPTY_FLAGS + + m_cx = new SVGAnimatedLengthImpl(LENGTHMODE_WIDTH, this); + m_cx->ref(); + + m_cy = new SVGAnimatedLengthImpl(LENGTHMODE_HEIGHT, this); + m_cy->ref(); + + m_r = new SVGAnimatedLengthImpl(LENGTHMODE_OTHER, this); + m_r->ref(); + + m_fx = new SVGAnimatedLengthImpl(LENGTHMODE_WIDTH, this); + m_fx->ref(); + + m_fy = new SVGAnimatedLengthImpl(LENGTHMODE_HEIGHT, this); + m_fy->ref(); + + converter()->add(m_cx); + converter()->add(m_cy); + converter()->add(m_r); + converter()->add(m_fx); + converter()->add(m_fy); +} + +SVGRadialGradientElementImpl::~SVGRadialGradientElementImpl() +{ + if(m_cx) + m_cx->deref(); + if(m_cy) + m_cy->deref(); + if(m_r) + m_r->deref(); + if(m_fx) + m_fx->deref(); + if(m_fy) + m_fy->deref(); +} + +SVGAnimatedLengthImpl *SVGRadialGradientElementImpl::cx() const +{ + return m_cx; +} + +SVGAnimatedLengthImpl *SVGRadialGradientElementImpl::cy() const +{ + return m_cy; +} + +SVGAnimatedLengthImpl *SVGRadialGradientElementImpl::r() const +{ + return m_r; +} + +SVGAnimatedLengthImpl *SVGRadialGradientElementImpl::fx() const +{ + return m_fx; +} + +SVGAnimatedLengthImpl *SVGRadialGradientElementImpl::fy() const +{ + return m_fy; +} + +/* +@namespace KSVG +@begin SVGRadialGradientElementImpl::s_hashTable 7 + cx SVGRadialGradientElementImpl::Cx DontDelete|ReadOnly + cy SVGRadialGradientElementImpl::Cy DontDelete|ReadOnly + r SVGRadialGradientElementImpl::R DontDelete|ReadOnly + fx SVGRadialGradientElementImpl::Fx DontDelete|ReadOnly + fy SVGRadialGradientElementImpl::Fy DontDelete|ReadOnly +@end +*/ + +Value SVGRadialGradientElementImpl::getValueProperty(ExecState *exec, int token) const +{ + KSVG_CHECK_ATTRIBUTE + + switch(token) + { + case Cx: + if(!attributeMode) + return m_cx->cache(exec); + else + return Number(m_cx->baseVal()->value()); + case Cy: + if(!attributeMode) + return m_cy->cache(exec); + else + return Number(m_cy->baseVal()->value()); + case R: + if(!attributeMode) + return m_r->cache(exec); + else + return Number(m_r->baseVal()->value()); + case Fx: + if(!attributeMode) + return m_fx->cache(exec); + else + return Number(m_fx->baseVal()->value()); + case Fy: + if(!attributeMode) + return m_fy->cache(exec); + else + return Number(m_fy->baseVal()->value()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGRadialGradientElementImpl::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; + + switch(token) + { + case Cx: + converter()->modify(cx(), value.toString(exec).qstring()); + break; + case Cy: + converter()->modify(cy(), value.toString(exec).qstring()); + break; + case R: + converter()->modify(r(), value.toString(exec).qstring()); + break; + case Fx: + converter()->modify(fx(), value.toString(exec).qstring()); + break; + case Fy: + converter()->modify(fy(), value.toString(exec).qstring()); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +void SVGRadialGradientElementImpl::setAttributes() +{ + SVGGradientElementImpl::setAttributes(); + + // Spec: no attribute, effect is af value 50% is specified + if(KSVG_TOKEN_NOT_PARSED(Cx)) + KSVG_SET_ALT_ATTRIBUTE(Cx, "50%") + + // Spec: no attribute, effect is af value 50% is specified + if(KSVG_TOKEN_NOT_PARSED(Cy)) + KSVG_SET_ALT_ATTRIBUTE(Cy, "50%") + + // Spec: no attribute, effect is af value 50% is specified + if(KSVG_TOKEN_NOT_PARSED(R)) + KSVG_SET_ALT_ATTRIBUTE(R, "50%") +} + +QMap<QString, DOM::DOMString> SVGRadialGradientElementImpl::gradientAttributes() +{ + setAttributes(); + + QMap<QString, DOM::DOMString> gradAttributes; + QDictIterator<DOM::DOMString> it(attributes()); + + for(; it.current(); ++it) + { + DOM::DOMString name = it.currentKey(); + DOM::DOMString value = it.current()->string(); + + if(name == "gradientUnits" || name == "gradientTransform" || name == "spreadMethod" || name == "cx" || name == "cy" || name == "r" || name == "fx" || name == "fy") + { + gradAttributes.insert(name.string(), value.copy()); + } + } + + return gradAttributes; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGRadialGradientElementImpl.h b/ksvg/impl/SVGRadialGradientElementImpl.h new file mode 100644 index 00000000..2f6c58c1 --- /dev/null +++ b/ksvg/impl/SVGRadialGradientElementImpl.h @@ -0,0 +1,76 @@ +/* + 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. +*/ + +#ifndef SVGRadialGradientElementImpl_H +#define SVGRadialGradientElementImpl_H + +#include "SVGGradientElementImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedLengthImpl; +class SVGRadialGradientElementImpl : public SVGGradientElementImpl +{ +public: + SVGRadialGradientElementImpl(DOM::ElementImpl *); + virtual ~SVGRadialGradientElementImpl(); + + SVGAnimatedLengthImpl *cx() const; + SVGAnimatedLengthImpl *cy() const; + SVGAnimatedLengthImpl *r() const; + SVGAnimatedLengthImpl *fx() const; + SVGAnimatedLengthImpl *fy() const; + + virtual void setAttributes(); + + virtual QMap<QString, DOM::DOMString> gradientAttributes(); + +private: + SVGAnimatedLengthImpl *m_cx; + SVGAnimatedLengthImpl *m_cy; + SVGAnimatedLengthImpl *m_r; + SVGAnimatedLengthImpl *m_fx; + SVGAnimatedLengthImpl *m_fy; + +public: + KSVG_GET + KSVG_PUT + KSVG_BRIDGE + + enum + { + // Properties + Cx, Cy, R, Fx, Fy, Href + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +KSVG_REGISTER_ELEMENT(SVGRadialGradientElementImpl, "radialGradient") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGRectElementImpl.cc b/ksvg/impl/SVGRectElementImpl.cc new file mode 100644 index 00000000..3dad7cbf --- /dev/null +++ b/ksvg/impl/SVGRectElementImpl.cc @@ -0,0 +1,244 @@ +/* + 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> +#include <klocale.h> + +#include "SVGRectImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGRectElementImpl.h" +#include "SVGAnimatedLengthImpl.h" + +#include "KSVGCanvas.h" +#include "CanvasItem.h" + +using namespace KSVG; + +#include "SVGRectElementImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" + +SVGRectElementImpl::SVGRectElementImpl(DOM::ElementImpl *impl) : SVGShapeImpl(impl), SVGTestsImpl(), SVGLangSpaceImpl(), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this), SVGTransformableImpl() +{ + KSVG_EMPTY_FLAGS + + m_x = new SVGAnimatedLengthImpl(LENGTHMODE_WIDTH, this); + m_x->ref(); + m_x->baseVal()->setValueAsString("-1"); + + m_y = new SVGAnimatedLengthImpl(LENGTHMODE_HEIGHT, this); + m_y->ref(); + m_y->baseVal()->setValueAsString("-1"); + + m_width = new SVGAnimatedLengthImpl(LENGTHMODE_WIDTH, this); + m_width->ref(); + m_width->baseVal()->setValueAsString("-1"); + + m_height = new SVGAnimatedLengthImpl(LENGTHMODE_HEIGHT, this); + m_height->ref(); + m_height->baseVal()->setValueAsString("-1"); + + m_rx = new SVGAnimatedLengthImpl(LENGTHMODE_WIDTH, this); + m_rx->ref(); + m_rx->baseVal()->setValueAsString("-1"); + + m_ry = new SVGAnimatedLengthImpl(LENGTHMODE_HEIGHT, this); + m_ry->ref(); + m_ry->baseVal()->setValueAsString("-1"); +} + +SVGRectElementImpl::~SVGRectElementImpl() +{ + if(m_x) + m_x->deref(); + if(m_y) + m_y->deref(); + if(m_width) + m_width->deref(); + if(m_height) + m_height->deref(); + if(m_rx) + m_rx->deref(); + if(m_ry) + m_ry->deref(); +} + +SVGAnimatedLengthImpl *SVGRectElementImpl::x() +{ + return m_x; +} + +SVGAnimatedLengthImpl *SVGRectElementImpl::y() +{ + return m_y; +} + +SVGAnimatedLengthImpl *SVGRectElementImpl::width() +{ + return m_width; +} + +SVGAnimatedLengthImpl *SVGRectElementImpl::height() +{ + return m_height; +} + +SVGAnimatedLengthImpl *SVGRectElementImpl::rx() +{ + return m_rx; +} + +SVGAnimatedLengthImpl *SVGRectElementImpl::ry() +{ + return m_ry; +} + +/* +@namespace KSVG +@begin SVGRectElementImpl::s_hashTable 7 + x SVGRectElementImpl::X DontDelete|ReadOnly + y SVGRectElementImpl::Y DontDelete|ReadOnly + width SVGRectElementImpl::Width DontDelete|ReadOnly + height SVGRectElementImpl::Height DontDelete|ReadOnly + rx SVGRectElementImpl::Rx DontDelete|ReadOnly + ry SVGRectElementImpl::Ry DontDelete|ReadOnly +@end +*/ + +Value SVGRectElementImpl::getValueProperty(ExecState *exec, int token) const +{ + KSVG_CHECK_ATTRIBUTE + + switch(token) + { + case X: + if(!attributeMode) + return m_x->cache(exec); + else + return Number(m_x->baseVal()->value()); + case Y: + if(!attributeMode) + return m_y->cache(exec); + else + return Number(m_y->baseVal()->value()); + case Width: + if(!attributeMode) + return m_width->cache(exec); + else + return Number(m_width->baseVal()->value()); + case Height: + if(!attributeMode) + return m_height->cache(exec); + else + return Number(m_height->baseVal()->value()); + case Rx: + if(!attributeMode) + return m_rx->cache(exec); + else + return Number(m_rx->baseVal()->value()); + case Ry: + if(!attributeMode) + return m_ry->cache(exec); + else + return Number(m_ry->baseVal()->value()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGRectElementImpl::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; + + switch(token) + { + case X: + x()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + case Y: + y()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + case Width: + width()->baseVal()->setValueAsString(value.toString(exec).qstring()); + if(width()->baseVal()->value() < 0) // A negative value is an error + gotError(i18n("Negative value for attribute width of element <rect> is illegal")); + break; + case Height: + height()->baseVal()->setValueAsString(value.toString(exec).qstring()); + if(height()->baseVal()->value() < 0) // A negative value is an error + gotError(i18n("Negative value for attribute height of element <rect> is illegal")); + break; + case Rx: + rx()->baseVal()->setValueAsString(value.toString(exec).qstring()); + if(rx()->baseVal()->value() < 0) // A negative value is an error + gotError(i18n("Negative value for attribute rx of element <rect> is illegal")); + break; + case Ry: + ry()->baseVal()->setValueAsString(value.toString(exec).qstring()); + if(ry()->baseVal()->value() < 0) // A negative value is an error + gotError(i18n("Negative value for attribute ry of element <rect> is illegal")); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +SVGRectImpl *SVGRectElementImpl::getBBox() +{ + SVGRectImpl *ret = SVGSVGElementImpl::createSVGRect(); + ret->setX(m_x->baseVal()->value()); + ret->setY(m_y->baseVal()->value()); + ret->setWidth(m_width->baseVal()->value()); + ret->setHeight(m_height->baseVal()->value()); + return ret; +} + +void SVGRectElementImpl::setAttributes() +{ + SVGElementImpl::setAttributes(); + + // Spec: if not specified, effect is as if a value of "0" were specified + if(KSVG_TOKEN_NOT_PARSED(X)) + KSVG_SET_ALT_ATTRIBUTE(X, "0") + + // Spec: if not specified, effect is as if a value of "0" were specified + if(KSVG_TOKEN_NOT_PARSED(Y)) + KSVG_SET_ALT_ATTRIBUTE(Y, "0") +} + +void SVGRectElementImpl::createItem(KSVGCanvas *c) +{ + if(!c) + c = ownerDoc()->canvas(); + + if(!m_item) + { + m_item = c->createRectangle(this); + c->insert(m_item); + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGRectElementImpl.h b/ksvg/impl/SVGRectElementImpl.h new file mode 100644 index 00000000..690084d7 --- /dev/null +++ b/ksvg/impl/SVGRectElementImpl.h @@ -0,0 +1,90 @@ +/* + 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. +*/ + +#ifndef SVGRectElementImpl_H +#define SVGRectElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGShapeImpl.h" +#include "SVGTestsImpl.h" +#include "SVGStylableImpl.h" +#include "SVGLangSpaceImpl.h" +#include "SVGTransformableImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + +namespace KSVG +{ + +class SVGRectImpl; +class SVGAnimatedLengthImpl; +class SVGRectElementImpl : public SVGShapeImpl, + public SVGTestsImpl, + public SVGLangSpaceImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl, + public SVGTransformableImpl +{ +public: + SVGRectElementImpl(DOM::ElementImpl *); + virtual ~SVGRectElementImpl(); + + SVGAnimatedLengthImpl *x(); + SVGAnimatedLengthImpl *y(); + SVGAnimatedLengthImpl *width(); + SVGAnimatedLengthImpl *height(); + SVGAnimatedLengthImpl *rx(); + SVGAnimatedLengthImpl *ry(); + + virtual void createItem(KSVGCanvas *c = 0); + virtual void setAttributes(); + + virtual SVGRectImpl *getBBox(); + +private: + SVGAnimatedLengthImpl *m_x; + SVGAnimatedLengthImpl *m_y; + SVGAnimatedLengthImpl *m_width; + SVGAnimatedLengthImpl *m_height; + SVGAnimatedLengthImpl *m_rx; + SVGAnimatedLengthImpl *m_ry; + +public: + KSVG_GET + KSVG_PUT + KSVG_BRIDGE + + enum + { + // Properties + X, Y, Width, Height, Rx, Ry + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +KSVG_REGISTER_ELEMENT(SVGRectElementImpl, "rect") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGRectImpl.cc b/ksvg/impl/SVGRectImpl.cc new file mode 100644 index 00000000..1f6c0d51 --- /dev/null +++ b/ksvg/impl/SVGRectImpl.cc @@ -0,0 +1,157 @@ +/* + 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> + +#include <qrect.h> + +#include "SVGRectImpl.h" + +using namespace KSVG; + +#include "SVGRectImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +SVGRectImpl::SVGRectImpl() +{ + KSVG_EMPTY_FLAGS + + m_x = 0; + m_y = 0; + m_width = 0; + m_height = 0; +} + +SVGRectImpl::SVGRectImpl(const QRect &other) +{ + (*this) = other; +} + +SVGRectImpl::~SVGRectImpl() +{ +} + +void SVGRectImpl::setX(float x) +{ + m_x = x; +} + +float SVGRectImpl::x() const +{ + return m_x; +} + +void SVGRectImpl::setY(float y) +{ + m_y = y; +} + +float SVGRectImpl::y() const +{ + return m_y; +} + +void SVGRectImpl::setWidth(float width) +{ + m_width = width; +} + +float SVGRectImpl::width() const +{ + return m_width; +} + +void SVGRectImpl::setHeight(float height) +{ + m_height = height; +} + +float SVGRectImpl::height() const +{ + return m_height; +} + +QRect SVGRectImpl::qrect() const +{ + // ceil() so the integer rectangle contains the whole real one. + return QRect(int(m_x), int(m_y), int(ceil(m_width)), int(ceil(m_height))); +} + +SVGRectImpl &SVGRectImpl::operator=(const QRect &other) +{ + m_x = other.x(); + m_y = other.y(); + m_width = other.width(); + m_height = other.height(); + + return *this; +} + +/* +@namespace KSVG +@begin SVGRectImpl::s_hashTable 5 + x SVGRectImpl::X DontDelete + y SVGRectImpl::Y DontDelete + width SVGRectImpl::Width DontDelete + height SVGRectImpl::Height DontDelete +@end +*/ + +Value SVGRectImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case X: + return Number(m_x); + case Y: + return Number(m_y); + case Width: + return Number(m_width); + case Height: + return Number(m_height); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGRectImpl::putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int) +{ + switch(token) + { + case X: + m_x = value.toNumber(exec); + break; + case Y: + m_y = value.toNumber(exec); + break; + case Width: + m_width = value.toNumber(exec); + break; + case Height: + m_height = value.toNumber(exec); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGRectImpl.h b/ksvg/impl/SVGRectImpl.h new file mode 100644 index 00000000..e0b0e889 --- /dev/null +++ b/ksvg/impl/SVGRectImpl.h @@ -0,0 +1,80 @@ +/* + 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. +*/ + +#ifndef SVGRectImpl_H +#define SVGRectImpl_H + +#include <dom/dom_misc.h> + +#include "ksvg_lookup.h" + +class QRect; + +namespace KSVG +{ + +class SVGRectImpl : public DOM::DomShared +{ +public: + SVGRectImpl(); + SVGRectImpl(const QRect &); + virtual ~SVGRectImpl(); + + void setX(float x); + float x() const; + + void setY(float y); + float y() const; + + void setWidth(float width); + float width() const; + + void setHeight(float height); + float height() const; + + QRect qrect() const; + + SVGRectImpl &operator=(const QRect &); + +private: + float m_x; + float m_y; + float m_width; + float m_height; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + X, Y, Width, Height + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGSVGElementImpl.cc b/ksvg/impl/SVGSVGElementImpl.cc new file mode 100644 index 00000000..b54cf521 --- /dev/null +++ b/ksvg/impl/SVGSVGElementImpl.cc @@ -0,0 +1,982 @@ +/* + 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> + +#include <qtimer.h> +#include <qstringlist.h> +#include <qdatetime.h> + +#define USE_VALGRIND 0 + +#if USE_VALGRIND +#include <valgrind/calltree.h> +#endif + +#include "SVGLength.h" + +#include "SVGRectImpl.h" +#include "SVGAngleImpl.h" +#include "SVGShapeImpl.h" +#include "SVGPointImpl.h" +#include "SVGNumberImpl.h" +#include "SVGMatrixImpl.h" + +#include "SVGEventImpl.h" +#include "SVGAElementImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGViewSpecImpl.h" +#include "SVGTransformImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGAnimatedRectImpl.h" +#include "SVGTransformListImpl.h" +#include "SVGAnimatedLengthImpl.h" +#include "SVGAnimatedStringImpl.h" +#include "SVGPreserveAspectRatioImpl.h" +#include "SVGAnimatedTransformListImpl.h" +#include "SVGAnimatedPreserveAspectRatioImpl.h" + +#include "CanvasItem.h" +#include "KSVGCanvas.h" + +using namespace KSVG; + +#include "SVGSVGElementImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" + +SVGSVGElementImpl::SVGSVGElementImpl(DOM::ElementImpl *impl) : SVGContainerImpl(impl), SVGTestsImpl(), SVGLangSpaceImpl(), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this), SVGLocatableImpl(), SVGFitToViewBoxImpl(), SVGZoomAndPanImpl() +{ + KSVG_EMPTY_FLAGS + + m_x = new SVGAnimatedLengthImpl(LENGTHMODE_WIDTH, this); + m_x->ref(); + + m_y = new SVGAnimatedLengthImpl(LENGTHMODE_HEIGHT, this); + m_y->ref(); + + m_width = new SVGAnimatedLengthImpl(LENGTHMODE_WIDTH, this); + m_width->ref(); + + m_height = new SVGAnimatedLengthImpl(LENGTHMODE_HEIGHT, this); + m_height->ref(); + + m_viewport = SVGSVGElementImpl::createSVGRect(); + + m_currentTranslate = SVGSVGElementImpl::createSVGPoint(); + + m_currentView = new SVGViewSpecImpl(); + m_currentView->ref(); + + m_currentScale = 1.0; + + m_useCurrentView = false; + + m_clip[0] = 0; + m_clip[1] = 0; + m_clip[2] = 0; + m_clip[3] = 0; + + m_rootParentScreenCTM = 0; + + m_localMatrix = SVGSVGElementImpl::createSVGMatrix(); +} + +SVGSVGElementImpl::~SVGSVGElementImpl() +{ + if(m_x) + m_x->deref(); + if(m_y) + m_y->deref(); + if(m_width) + m_width->deref(); + if(m_height) + m_height->deref(); + if(m_viewport) + m_viewport->deref(); + if(m_currentTranslate) + m_currentTranslate->deref(); + if(m_currentView) + m_currentView->deref(); + if(m_rootParentScreenCTM) + m_rootParentScreenCTM->deref(); + if(m_localMatrix) + m_localMatrix->deref(); +} + +bool SVGSVGElementImpl::isRootElement() const +{ + return ownerDoc()->rootElement() == this; +} + +void SVGSVGElementImpl::setAttributes() +{ + SVGElementImpl::setAttributes(); + + // Spec: if not specified, effect is as if a value of "0" were specified + if(KSVG_TOKEN_NOT_PARSED(X)) + KSVG_SET_ALT_ATTRIBUTE(X, "0") + + // Spec: if not specified, effect is as if a value of "0" were specified + if(KSVG_TOKEN_NOT_PARSED(Y)) + KSVG_SET_ALT_ATTRIBUTE(Y, "0") + + // Spec: If the attribute is not specified, the effect is as if a value of "100%" were specified. + if(KSVG_TOKEN_NOT_PARSED(Width)) + KSVG_SET_ALT_ATTRIBUTE(Width, "100%") + + // Spec: If the attribute is not specified, the effect is as if a value of "100%" were specified. + if(KSVG_TOKEN_NOT_PARSED(Height)) + KSVG_SET_ALT_ATTRIBUTE(Height, "100%") + + // Spec: The contentScriptType should default to "text/ecmascript". + if(KSVG_TOKEN_NOT_PARSED(ContentScriptType)) + KSVG_SET_ALT_ATTRIBUTE(ContentScriptType, "text/ecmascript") + + // Spec: The contentStyleType should default to "text/css". + if(KSVG_TOKEN_NOT_PARSED(ContentStyleType)) + KSVG_SET_ALT_ATTRIBUTE(ContentStyleType, "text/css") + + if(m_useCurrentView) + { + parseViewBox(m_currentView->viewBoxString().string()); + preserveAspectRatio()->baseVal()->parsePreserveAspectRatio(m_currentView->preserveAspectRatioString().string()); + } + + m_viewport->setX(x()->baseVal()->value()); + m_viewport->setY(y()->baseVal()->value()); + m_viewport->setWidth(width()->baseVal()->value()); + m_viewport->setHeight(height()->baseVal()->value()); + + if(isRootElement() && ownerDoc()->parentImage() == 0) + { + if(ownerDoc()->canvas()) + ownerDoc()->canvas()->setViewportDimension(int(ceil(width()->baseVal()->value() * currentScale())), int(ceil(height()->baseVal()->value() * currentScale()))); + + // Special case for outermost svg element: + // We need to register our id manually, because + // m_ownerSVGElement is 0 in SVGElementImpl::setAttributes (Niko) + if(!id().isNull()) + addToIdMap(id().string(), this); + } +} + +SVGAnimatedLengthImpl *SVGSVGElementImpl::x() +{ + return m_x; +} + +SVGAnimatedLengthImpl *SVGSVGElementImpl::y() +{ + return m_y; +} + +SVGAnimatedLengthImpl *SVGSVGElementImpl::width() +{ + return m_width; +} + +SVGAnimatedLengthImpl *SVGSVGElementImpl::height() +{ + return m_height; +} + +void SVGSVGElementImpl::setContentScriptType(const DOM::DOMString &contentScriptType) +{ + setAttribute("contentScriptType", contentScriptType); +} + +DOM::DOMString SVGSVGElementImpl::contentScriptType() const +{ + return getAttribute("contentScriptType"); +} + +void SVGSVGElementImpl::setContentStyleType(const DOM::DOMString &contentStyleType) +{ + setAttribute("contentStyleType", contentStyleType); +} + +DOM::DOMString SVGSVGElementImpl::contentStyleType() const +{ + return getAttribute("contentStyleType"); +} + +SVGRectImpl *SVGSVGElementImpl::viewport() +{ + return m_viewport; +} + +SVGRectImpl *SVGSVGElementImpl::getBBox() +{ + SVGRectImpl *ret = new SVGRectImpl(getCTM()->qmatrix().invert().map(m_viewport->qrect())); + ret->ref(); + return ret; +} + +float SVGSVGElementImpl::pixelUnitToMillimeterX() const +{ + return ownerDoc()->screenPixelsPerMillimeterX(); +} + +float SVGSVGElementImpl::pixelUnitToMillimeterY() const +{ + return ownerDoc()->screenPixelsPerMillimeterY(); +} + +float SVGSVGElementImpl::screenPixelToMillimeterX() const +{ + return pixelUnitToMillimeterX(); +} + +float SVGSVGElementImpl::screenPixelToMillimeterY() const +{ + return pixelUnitToMillimeterY(); +} + +void SVGSVGElementImpl::setUseCurrentView(bool useCurrentView) +{ + m_useCurrentView = useCurrentView; +} + +bool SVGSVGElementImpl::useCurrentView() const +{ + return m_useCurrentView; +} + +SVGViewSpecImpl *SVGSVGElementImpl::currentView() const +{ + return m_currentView; +} + +void SVGSVGElementImpl::setCurrentScale(float currentScale) +{ + if( m_currentScale != currentScale ) + { + m_currentScale = currentScale; + invalidateCachedMatrices(); + + if(hasEventListener(SVGEvent::ZOOM_EVENT, true)) + dispatchEvent(SVGEvent::ZOOM_EVENT, false, false); + } +} + +float SVGSVGElementImpl::currentScale() const +{ + return m_currentScale; +} + +void SVGSVGElementImpl::setCurrentTranslate(const QPoint &p) +{ + if(m_currentTranslate->x() != p.x() || m_currentTranslate->y() != p.y()) + { + m_currentTranslate->setX(p.x()); + m_currentTranslate->setY(p.y()); + invalidateCachedMatrices(); + if(hasEventListener(SVGEvent::SCROLL_EVENT, true)) + dispatchEvent(SVGEvent::SCROLL_EVENT, false, false); + } +} + +SVGPointImpl *SVGSVGElementImpl::currentTranslate() +{ + return m_currentTranslate; +} + +unsigned long SVGSVGElementImpl::suspendRedraw(unsigned long) +{ + return 0; +} + +void SVGSVGElementImpl::unsuspendRedraw(unsigned long) +{ +} + +void SVGSVGElementImpl::unsuspendRedrawAll() +{ +} + +void SVGSVGElementImpl::forceRedraw() +{ +#if USE_VALGRIND + CALLTREE_ZERO_STATS(); +#endif + + QTime timer; + timer.start(); + + if(ownerDoc() && ownerDoc()->canvas()) + ownerDoc()->canvas()->update(); + + kdDebug(26000) << "forceRedraw in " << timer.elapsed()/1000.0 << " seconds" << endl; + +#if USE_VALGRIND + CALLTREE_DUMP_STATS(); +#endif +} + +void SVGSVGElementImpl::pauseAnimations() +{ + if(!ownerDoc()->timeScheduler()->animationsPaused()) + ownerDoc()->timeScheduler()->toggleAnimations(); +} + +void SVGSVGElementImpl::unpauseAnimations() +{ + if(ownerDoc()->timeScheduler()->animationsPaused()) + ownerDoc()->timeScheduler()->toggleAnimations(); +} + +bool SVGSVGElementImpl::animationsPaused() +{ + return ownerDoc()->timeScheduler()->animationsPaused(); +} + +float SVGSVGElementImpl::getCurrentTime() const +{ + return ownerDoc()->timeScheduler()->elapsed(); +} + +void SVGSVGElementImpl::setCurrentTime(float) +{ +} + +DOM::NodeList SVGSVGElementImpl::getIntersectionList(SVGRectImpl *, SVGElementImpl *) +{ + // TODO : implement me + return DOM::NodeList(); +} + +DOM::NodeList SVGSVGElementImpl::getEnclosureList(SVGRectImpl *rect, SVGElementImpl */*referenceElement*/) +{ + DOM::NodeList list; + + DOM::Node node = firstChild(); + for(; !node.isNull(); node = node.nextSibling()) + { + SVGElementImpl *element = ownerDoc()->getElementFromHandle(node.handle()); + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(element); + if(shape) + { + if(shape->isContainer()) + // TODO : pass it on to container::getEnclosureList() which should return a NodeList + kdDebug() << "!shape" << endl; + else + { + // TODO : add the shape to list if the test succeeds + SVGRectImpl *current = shape->getBBox(); + if(rect->qrect().contains(current->qrect(), true)) + kdDebug() << "shape : " << element->nodeName().string() << " is fully enclosed" << endl; + + current->deref(); + } + } + } + + return list; +} + +bool SVGSVGElementImpl::checkIntersection(SVGElementImpl *element, SVGRectImpl *rect) +{ + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(element); + if(!shape) + return false; + + SVGRectImpl *current = shape->getBBox(); + bool result = rect->qrect().intersects(current->qrect()); + current->deref(); + return result; +} + +bool SVGSVGElementImpl::checkEnclosure(SVGElementImpl *element, SVGRectImpl *rect) +{ + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(element); + if(!shape) + return false; + + SVGRectImpl *current = shape->getBBox(); + bool result = rect->qrect().contains(current->qrect()); + current->deref(); + return result; +} + +void SVGSVGElementImpl::deSelectAll() +{ +} + +SVGNumberImpl *SVGSVGElementImpl::createSVGNumber() +{ + // Spec: Creates an SVGNumber object outside of any document + // trees. The object is initialized to a value of zero. + SVGNumberImpl *ret = new SVGNumberImpl(); + ret->ref(); + return ret; +} + +SVGLengthImpl *SVGSVGElementImpl::createSVGLength() +{ + // Spec: Creates an SVGLength object outside of any document + // trees. The object is initialized to the value of 0 user units. + SVGLengthImpl *ret = new SVGLengthImpl(); + ret->ref(); + return ret; +} + +SVGAngleImpl *SVGSVGElementImpl::createSVGAngle() +{ + // Spec: Creates an SVGAngle object outside of any document + // trees. The object is initialized to the value 0 degrees (unitless). + SVGAngleImpl *ret = new SVGAngleImpl(); + ret->ref(); + return ret; +} + +SVGPointImpl *SVGSVGElementImpl::createSVGPoint() +{ + // Spec: Creates an SVGPoint object outside of any document + // trees. The object is initialized to the point (0,0) in the user coordinate system. + SVGPointImpl *ret = new SVGPointImpl(); + ret->ref(); + return ret; +} + +SVGMatrixImpl *SVGSVGElementImpl::createSVGMatrix() +{ + // Spec: Creates an SVGMatrix object outside of any document + // trees. The object is initialized to the identity matrix. + SVGMatrixImpl *ret = new SVGMatrixImpl(QWMatrix(1.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0F)); + ret->ref(); + return ret; +} + +SVGRectImpl *SVGSVGElementImpl::createSVGRect() +{ + // Spec: Creates an SVGRect object outside of any document + // trees. The object is initialized such that all values are set to 0 user units. + SVGRectImpl *ret = new SVGRectImpl(); + ret->ref(); + return ret; +} + +SVGTransformImpl *SVGSVGElementImpl::createSVGTransform() +{ + // Spec: Creates an SVGTransform object outside of any document + // trees. The object is initialized to an identity matrix transform (SVG_TRANSFORM_MATRIX). + SVGTransformImpl *transform = createSVGTransformFromMatrix(createSVGMatrix()); + + // createSVGMatrix already ref's the matrix, the SVGTransformImpl->setMatrix + // call also does this, prevent non deleting of the object by deref'ing (Niko) + transform->matrix()->deref(); + + return transform; +} + +SVGTransformImpl *SVGSVGElementImpl::createSVGTransformFromMatrix(SVGMatrixImpl *mat) +{ + // Spec: Creates an SVGTransform object outside of any document + // trees. The object is initialized to the given matrix transform (i.e., SVG_TRANSFORM_MATRIX). + SVGTransformImpl *ret = new SVGTransformImpl(); + ret->setMatrix(mat); + ret->ref(); + return ret; +} + +SVGElementImpl *SVGSVGElementImpl::getElementById(const DOM::DOMString &elementId) +{ + return m_map[elementId.string()]; +} + +void SVGSVGElementImpl::addToIdMap(const QString &id, SVGElementImpl *obj) +{ + m_map.insert(id, obj); +} + +SVGMatrixImpl *SVGSVGElementImpl::getCTM() +{ + return viewBoxToViewTransform(width()->baseVal()->value(), height()->baseVal()->value()); +} + +const SVGMatrixImpl *SVGSVGElementImpl::localMatrix() +{ + // TODO: only update the matrix when needed and just return m_localMatrix + + m_localMatrix->reset(); + + if(ownerSVGElement() == 0) + { + if(m_rootParentScreenCTM != 0) + m_localMatrix->copy(m_rootParentScreenCTM); + + // We're the outermost svg element. + // Put the zoom scale and translate into the matrix. + m_localMatrix->translate(currentTranslate()->x(), currentTranslate()->y()); + m_localMatrix->scale(currentScale()); + } + + // Apply viewport translation. + m_localMatrix->translate(x()->baseVal()->value(), y()->baseVal()->value()); + + // And viewbox. + SVGMatrixImpl *viewboxMatrix = viewBoxToViewTransform(width()->baseVal()->value(), height()->baseVal()->value()); + + m_localMatrix->multiply(viewboxMatrix); + viewboxMatrix->deref(); + + return m_localMatrix; +} + +void SVGSVGElementImpl::setClip(const QString &clip) +{ + // TODO : this routine should probably be shared between all classes that establish new viewports (Rob) + if(!clip.startsWith("rect(") || !clip.endsWith(")")) + return; + + QString work = clip.mid(5, clip.length() - 6); + QStringList substrings = QStringList::split(',', clip); + QStringList::ConstIterator it = substrings.begin(); + + if(m_clip[0]) + m_clip[0]->deref(); + m_clip[0] = SVGSVGElementImpl::createSVGLength(); + + if(*it != "auto") + m_clip[0]->setValueAsString(*it); + ++it; + + if(m_clip[1]) + m_clip[1]->deref(); + m_clip[1] = SVGSVGElementImpl::createSVGLength(); + + if(*it != "auto") + m_clip[1]->setValueAsString(*it); + ++it; + + if(m_clip[2]) + m_clip[2]->deref(); + m_clip[2] = SVGSVGElementImpl::createSVGLength(); + + if(*it != "auto") + m_clip[2]->setValueAsString(*it); + ++it; + + if(m_clip[3]) + m_clip[3]->deref(); + m_clip[3] = SVGSVGElementImpl::createSVGLength(); + + if(*it != "auto") + m_clip[3]->setValueAsString(*it); +} + +QRect SVGSVGElementImpl::clip() +{ + // Get viewport in user coordinates. + QRect v(0, 0, m_viewport->qrect().width(), m_viewport->qrect().height()); + + SVGMatrixImpl *ctm = getCTM(); + QRect r = ctm->qmatrix().invert().mapRect(v); + ctm->deref(); + + if(m_clip[0]) + r.setTop(static_cast<int>(r.top() + m_clip[0]->value())); + if(m_clip[1]) + r.setRight(static_cast<int>(r.right() - m_clip[1]->value())); + if(m_clip[2]) + r.setBottom(static_cast<int>(r.bottom() - m_clip[2]->value())); + if(m_clip[3]) + r.setLeft(static_cast<int>(r.left() + m_clip[3]->value())); + + return r; +} + +void SVGSVGElementImpl::setRootParentScreenCTM(SVGMatrixImpl *screenCTM) +{ + if(m_rootParentScreenCTM != 0) + m_rootParentScreenCTM->deref(); + + m_rootParentScreenCTM = screenCTM; + screenCTM->ref(); +} + +bool SVGSVGElementImpl::prepareMouseEvent(const QPoint &p, const QPoint &a, SVGMouseEventImpl *mev) +{ + // mop: central bool var which turns to true once the current "mouseover" element has been found + bool ret = false, dorerender = false; + SVGElementImpl *elem = 0; + + SVGMatrixImpl *ctm = getCTM(); + QPoint userA = ctm->qmatrix().invert().map(a); + ctm->deref(); + + // Just check the lastTarget once (mop) + if(ownerDoc()->lastTarget()) + { + elem = ownerDoc()->lastTarget(); + ret = elem->prepareMouseEvent(p, userA, mev); + + // mop: only proceed if element is not the current element anymore. rest is done in the lower part + if(!ret) + { + if(elem->hasEventListener(SVGEvent::MOUSEOUT_EVENT, false)) + { + dorerender = true; + elem->setMouseOver(false); + elem->dispatchMouseEvent(SVGEvent::MOUSEOUT_EVENT, true, true, 0, mev->screenX(), mev->screenY(), mev->clientX(), mev->clientY(), mev->ctrlKey(), mev->altKey(), mev->shiftKey(), mev->metaKey(), mev->button(), elem); + } + + if(elem->hasEventListener(SVGEvent::DOMFOCUSOUT_EVENT, false) && elem->focus()) + { + dorerender = true; + elem->setFocus(false); + elem->dispatchEvent(SVGEvent::DOMFOCUSOUT_EVENT, true, true); + } + + // mop: unset last target once we left it + ownerDoc()->setLastTarget(0); + } + } + + // mop: DAMN...logic doesn't work :( + // we cant use the results of the above check because something like this + // _________ + // | ____ | + // ||____| | + // |_________| + // + // wouldn't work because even if the mousepointer would be in the inner rect it would still be inside the bbox + // of the outer (assuming that the outer is the lastTarget). :( + ret = false; + + // mop: just check for a node until the element where the mouse is over is found + // mop: "ret" can be set from the above stuff too... + // find the element here and do the event stuff in the lower part..much cleaner + CanvasItemList hits = ownerDoc()->canvas()->collisions(p, true); + for(CanvasItemList::Iterator it = hits.begin(); it != hits.end(); ++it) + { + elem = (*it)->element(); + if(elem) + { + // Check if mouse is over a certain shape... + // mop: once an element has been found check eventlisteners and leave immediately + ret = elem->prepareMouseEvent(p, userA, mev); + if(ret) break; + } + } + + // mop: has an element been found? + if(ret) + { + int events = mev->target()->getEventListeners(false); + + // Dispatch mousemove, mousedown, mouseup and mouseclick events + bool cancel = (mev->id() != SVGEvent::MOUSEMOVE_EVENT); + + if(events & 1 << mev->id()) + { + mev->target()->dispatchMouseEvent(mev->id(), true, cancel, 0, mev->screenX(), mev->screenY(), mev->clientX(), mev->clientY(), mev->ctrlKey(), mev->altKey(), mev->shiftKey(), mev->metaKey(), mev->button(), elem); + dorerender = true; // mop: if it has the event then rerender + } + + // If a mouse "moves" over a shape, it's also "over" the shape + if(mev->id() == SVGEvent::MOUSEMOVE_EVENT) + { + mev->target()->setMouseOver(true); + if(events & 1 << SVGEvent::MOUSEOVER_EVENT) + { + mev->target()->dispatchMouseEvent(SVGEvent::MOUSEOVER_EVENT, true, cancel, 0, mev->screenX(), mev->screenY(), mev->clientX(), mev->clientY(), mev->ctrlKey(), mev->altKey(), mev->shiftKey(), mev->metaKey(), mev->button(), elem); + dorerender = true; + } + + } + + // Also send an domactivate + focusin event on mouseup + bool dolinktest = true; + if(mev->id() == SVGEvent::MOUSEUP_EVENT) + { + mev->target()->setFocus(true); + + if(events & 1 << SVGEvent::CLICK_EVENT) + { + dolinktest = mev->target()->dispatchEvent(SVGEvent::CLICK_EVENT, true, true); + dorerender = true; + } + + if(events & 1 << SVGEvent::DOMACTIVATE_EVENT) + { + mev->target()->dispatchEvent(SVGEvent::DOMACTIVATE_EVENT, true, true); + dorerender = true; + } + + if(events & 1 << SVGEvent::DOMFOCUSIN_EVENT) + { + mev->target()->dispatchEvent(SVGEvent::DOMFOCUSIN_EVENT, true, true); + dorerender = true; + } + } + + // Hyperlink support + SVGAElementImpl* link=0; + if(dolinktest && !mev->defaultPrevented()) + { + link = SVGAElementImpl::getLink(elem); + if(link) + { + mev->setURL(link->href()->baseVal()); + emit ownerDoc()->gotURL(link->target()->baseVal().string()); + } + } + + // The mouse is over a shape, so we have a target..we need to register that for a mouseout + ownerDoc()->setLastTarget(mev->target()); + } + + // mop: all events may trigger changed style, add elements etc. this is definately needed :( + if(dorerender) + ownerDoc()->rerender(); + + return dorerender; // mop: some kind of event has been found and executed +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGSVGElementImpl::s_hashTable 23 + x SVGSVGElementImpl::X DontDelete|ReadOnly + y SVGSVGElementImpl::Y DontDelete|ReadOnly + width SVGSVGElementImpl::Width DontDelete|ReadOnly + height SVGSVGElementImpl::Height DontDelete|ReadOnly + viewport SVGSVGElementImpl::Viewport DontDelete|ReadOnly + contentScriptType SVGSVGElementImpl::ContentScriptType DontDelete + contentStyleType SVGSVGElementImpl::ContentStyleType DontDelete + pixelUnitToMillimeterX SVGSVGElementImpl::PixelUnitToMillimeterX DontDelete|ReadOnly + pixelUnitToMillimeterY SVGSVGElementImpl::PixelUnitToMillimeterY DontDelete|ReadOnly + screenPixelToMillimeterX SVGSVGElementImpl::ScreenPixelToMillimeterX DontDelete|ReadOnly + screenPixelToMillimeterY SVGSVGElementImpl::ScreenPixelToMillimeterY DontDelete|ReadOnly + useCurrentView SVGSVGElementImpl::UseCurrentView DontDelete + currentScale SVGSVGElementImpl::CurrentScale DontDelete + currentTranslate SVGSVGElementImpl::CurrentTranslate DontDelete|ReadOnly + onunload SVGSVGElementImpl::OnUnload DontDelete + onerror SVGSVGElementImpl::OnError DontDelete + onresize SVGSVGElementImpl::OnResize DontDelete + onzoom SVGSVGElementImpl::OnZoom DontDelete + onscroll SVGSVGElementImpl::OnScroll DontDelete +@end +@namespace KSVG +@begin SVGSVGElementImplProto::s_hashTable 29 + createSVGNumber SVGSVGElementImpl::CreateSVGNumber DontDelete|Function 0 + createSVGLength SVGSVGElementImpl::CreateSVGLength DontDelete|Function 0 + createSVGAngle SVGSVGElementImpl::CreateSVGAngle DontDelete|Function 0 + createSVGPoint SVGSVGElementImpl::CreateSVGPoint DontDelete|Function 0 + createSVGMatrix SVGSVGElementImpl::CreateSVGMatrix DontDelete|Function 0 + createSVGRect SVGSVGElementImpl::CreateSVGRect DontDelete|Function 0 + createSVGTransform SVGSVGElementImpl::CreateSVGTransform DontDelete|Function 0 + createSVGTransformFromMatrix SVGSVGElementImpl::CreateSVGTransformFromMatrix DontDelete|Function 1 + suspendRedraw SVGSVGElementImpl::SuspendRedraw DontDelete|Function 1 + unsuspendRedraw SVGSVGElementImpl::UnsuspendRedraw DontDelete|Function 1 + unsuspendRedrawAll SVGSVGElementImpl::UnsuspendRedrawAll DontDelete|Function 0 + forceRedraw SVGSVGElementImpl::ForceRedraw DontDelete|Function 0 + pauseAnimations SVGSVGElementImpl::PauseAnimations DontDelete|Function 0 + unpauseAnimations SVGSVGElementImpl::UnpauseAnimations DontDelete|Function 0 + animationsPaused SVGSVGElementImpl::AnimationsPaused DontDelete|Function 0 + getCurrentTime SVGSVGElementImpl::GetCurrentTime DontDelete|Function 0 + setCurrentTime SVGSVGElementImpl::SetCurrentTime DontDelete|Function 1 + getIntersectionList SVGSVGElementImpl::GetIntersectionList DontDelete|Function 2 + getEnclosureList SVGSVGElementImpl::GetEnclosureList DontDelete|Function 2 + checkIntersection SVGSVGElementImpl::CheckIntersection DontDelete|Function 2 + checkEnclosure SVGSVGElementImpl::CheckEnclosure DontDelete|Function 2 + deselectAll SVGSVGElementImpl::DeselectAll DontDelete|Function 0 + getElementById SVGSVGElementImpl::GetElementById DontDelete|Function 1 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGSVGElement", SVGSVGElementImplProto, SVGSVGElementImplProtoFunc) + +Value SVGSVGElementImpl::getValueProperty(ExecState *exec, int token) const +{ + KSVG_CHECK_ATTRIBUTE + + switch(token) + { + case X: + if(!attributeMode) + return m_x->cache(exec); + else + return Number(m_x->baseVal()->value()); + case Y: + if(!attributeMode) + return m_y->cache(exec); + else + return Number(m_y->baseVal()->value()); + case Width: + if(!attributeMode) + return m_width->cache(exec); + else + return Number(m_width->baseVal()->value()); + case Height: + if(!attributeMode) + return m_height->cache(exec); + else + return Number(m_height->baseVal()->value()); + case Viewport: + return m_viewport->cache(exec); + case ContentScriptType: + return String(contentScriptType().string()); + case ContentStyleType: + return String(contentStyleType().string()); + case PixelUnitToMillimeterX: + return Number(pixelUnitToMillimeterX()); + case PixelUnitToMillimeterY: + return Number(pixelUnitToMillimeterY()); + case ScreenPixelToMillimeterX: + return Number(screenPixelToMillimeterX()); + case ScreenPixelToMillimeterY: + return Number(screenPixelToMillimeterY()); + case UseCurrentView: + return Boolean(useCurrentView()); + case CurrentScale: + return Number(currentScale()); + case CurrentTranslate: + return m_currentTranslate->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGSVGElementImpl::putValueProperty(ExecState *exec, int token, const Value &value, int) +{ + switch(token) + { + case ContentScriptType: + setContentScriptType(value.toString(exec).string()); + break; + case ContentStyleType: + setContentStyleType(value.toString(exec).string()); + break; + case CurrentScale: + m_currentScale = value.toNumber(exec); + break; + case X: + x()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + case Y: + y()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + case Width: + width()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + case Height: + height()->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + case OnUnload: + // Spec: only applicable to outermost 'svg' elements + if(isRootElement()) + setEventListener(SVGEvent::UNLOAD_EVENT, ownerDoc()->createEventListener(value.toString(exec).qstring())); + break; + case OnError: + setEventListener(SVGEvent::ERROR_EVENT, ownerDoc()->createEventListener(value.toString(exec).qstring())); + break; + case OnResize: + // Spec: only applicable to outermost 'svg' elements + if(isRootElement()) + setEventListener(SVGEvent::RESIZE_EVENT, ownerDoc()->createEventListener(value.toString(exec).qstring())); + break; + case OnZoom: + // Spec: only applicable to outermost 'svg' elements + if(isRootElement()) + setEventListener(SVGEvent::ZOOM_EVENT, ownerDoc()->createEventListener(value.toString(exec).qstring())); + break; + case OnScroll: + // Spec: only applicable to outermost 'svg' elements + if(isRootElement()) + setEventListener(SVGEvent::SCROLL_EVENT, ownerDoc()->createEventListener(value.toString(exec).qstring())); + break; + default: + kdWarning() << k_funcinfo << "unhandled token " << token << endl; + } +} + +Value SVGSVGElementImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGSVGElementImpl) + + switch(id) + { + case SVGSVGElementImpl::CreateSVGNumber: + return obj->createSVGNumber()->cache(exec); + case SVGSVGElementImpl::CreateSVGLength: + return obj->createSVGLength()->cache(exec); + case SVGSVGElementImpl::CreateSVGAngle: + return obj->createSVGAngle()->cache(exec); + case SVGSVGElementImpl::CreateSVGPoint: + return obj->createSVGPoint()->cache(exec); + case SVGSVGElementImpl::CreateSVGMatrix: + return obj->createSVGMatrix()->cache(exec); + case SVGSVGElementImpl::CreateSVGRect: + return obj->createSVGRect()->cache(exec); + case SVGSVGElementImpl::CreateSVGTransform: + return obj->createSVGTransform()->cache(exec); + case SVGSVGElementImpl::CreateSVGTransformFromMatrix: + return obj->createSVGTransformFromMatrix(static_cast<KSVGBridge<SVGMatrixImpl> *>(args[0].imp())->impl())->cache(exec); + case SVGSVGElementImpl::GetElementById: + { + // Keep in sync with SVGDocumentImpl's version. + Value ret; + + SVGElementImpl *element = obj->getElementById(args[0].toString(exec).string()); + + if(element) + ret = getDOMNode(exec, *element); + else + { + element = obj->ownerDoc()->recursiveSearch(*(obj->ownerDoc()), args[0].toString(exec).string()); + if(!element) + return Null(); + + ret = getDOMNode(exec, *element); + } + + return ret; + } + case SVGSVGElementImpl::GetCurrentTime: + return Number(obj->getCurrentTime()); + case SVGSVGElementImpl::SetCurrentTime: + obj->setCurrentTime(args[0].toNumber(exec)); + return Undefined(); + case SVGSVGElementImpl::DeselectAll: + obj->deSelectAll(); + return Undefined(); + case SVGSVGElementImpl::PauseAnimations: + obj->pauseAnimations(); + return Undefined(); + case SVGSVGElementImpl::UnpauseAnimations: + obj->unpauseAnimations(); + return Undefined(); + case SVGSVGElementImpl::AnimationsPaused: + return Boolean(obj->animationsPaused()); + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return Undefined(); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGSVGElementImpl.h b/ksvg/impl/SVGSVGElementImpl.h new file mode 100644 index 00000000..2405458e --- /dev/null +++ b/ksvg/impl/SVGSVGElementImpl.h @@ -0,0 +1,198 @@ +/* + 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. +*/ + +#ifndef SVGSVGElementImpl_H +#define SVGSVGElementImpl_H + +#include <dom/dom_string.h> + +#include <qmap.h> + +#include "SVGTestsImpl.h" +#include "SVGElementImpl.h" +#include "SVGStylableImpl.h" +#include "SVGLocatableImpl.h" +#include "SVGContainerImpl.h" +#include "SVGLangSpaceImpl.h" +#include "SVGZoomAndPanImpl.h" +#include "SVGFitToViewBoxImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGPointImpl; +class SVGAngleImpl; +class SVGNumberImpl; +class SVGLengthImpl; +class SVGMatrixImpl; +class SVGViewSpecImpl; +class SVGTransformImpl; +class SVGAnimatedLengthImpl; +class SVGAnimationElementImpl; +class SVGSVGElementImpl : public SVGContainerImpl, + public SVGTestsImpl, + public SVGLangSpaceImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl, + public SVGLocatableImpl, + public SVGFitToViewBoxImpl, + public SVGZoomAndPanImpl +{ +public: + SVGSVGElementImpl(DOM::ElementImpl *); + virtual ~SVGSVGElementImpl(); + + bool isRootElement() const; + + SVGAnimatedLengthImpl *x(); + SVGAnimatedLengthImpl *y(); + SVGAnimatedLengthImpl *width(); + SVGAnimatedLengthImpl *height(); + + void setContentScriptType(const DOM::DOMString &); + DOM::DOMString contentScriptType() const; + + void setContentStyleType(const DOM::DOMString &); + DOM::DOMString contentStyleType() const; + + SVGRectImpl *viewport(); + SVGRectImpl *getBBox(); + + float pixelUnitToMillimeterX() const; + float pixelUnitToMillimeterY() const; + float screenPixelToMillimeterX() const; + float screenPixelToMillimeterY() const; + + void setUseCurrentView(bool); + bool useCurrentView() const; + SVGViewSpecImpl *currentView() const; + + void setCurrentScale(float); + float currentScale() const; + + SVGPointImpl *currentTranslate(); + void setCurrentTranslate(const QPoint &p); + + unsigned long suspendRedraw(unsigned long max_wait_milliseconds); + void unsuspendRedraw(unsigned long suspend_handle_id); + void unsuspendRedrawAll(); + void forceRedraw(); + + void pauseAnimations(); + void unpauseAnimations(); + + bool animationsPaused(); + + float getCurrentTime() const; + void setCurrentTime(float seconds); + DOM::NodeList getIntersectionList(SVGRectImpl *rect, SVGElementImpl *referenceElement); + DOM::NodeList getEnclosureList(SVGRectImpl *rect, SVGElementImpl *referenceElement); + bool checkIntersection(SVGElementImpl *element, SVGRectImpl *rect); + bool checkEnclosure(SVGElementImpl *element, SVGRectImpl *rect); + void deSelectAll(); + + // Static creators for svg primitives + static SVGNumberImpl *createSVGNumber(); + static SVGLengthImpl *createSVGLength(); + static SVGAngleImpl *createSVGAngle(); + static SVGPointImpl *createSVGPoint(); + static SVGMatrixImpl *createSVGMatrix(); + static SVGRectImpl *createSVGRect(); + static SVGTransformImpl *createSVGTransform(); + static SVGTransformImpl *createSVGTransformFromMatrix(SVGMatrixImpl *matrix); + + SVGElementImpl *getElementById(const DOM::DOMString &elementId); + void addToIdMap(const QString &id, SVGElementImpl *obj); + + virtual SVGMatrixImpl *getCTM(); + virtual const SVGMatrixImpl *localMatrix(); + + void setAttributes(); + + bool prepareMouseEvent(const QPoint &p, const QPoint &a, SVGMouseEventImpl *event); + + virtual bool isContainer() const { return true; } + + virtual void setClip(const QString &clip); + virtual QRect clip(); + + void setRootParentScreenCTM(SVGMatrixImpl *screenCTM); + +private: + SVGAnimatedLengthImpl *m_x; + SVGAnimatedLengthImpl *m_y; + SVGAnimatedLengthImpl *m_width; + SVGAnimatedLengthImpl *m_height; + + SVGRectImpl *m_viewport; + + bool m_useCurrentView; + + SVGViewSpecImpl *m_currentView; + + float m_currentScale; + + SVGPointImpl *m_currentTranslate; + + SVGLengthImpl *m_clip[4]; + + QMap<QString, SVGElementImpl *> m_map; + + // Transformation provided by the 'parent' of the outermost svg element + SVGMatrixImpl *m_rootParentScreenCTM; + + SVGMatrixImpl *m_localMatrix; + +public: + KSVG_GET + KSVG_PUT + KSVG_BRIDGE + + enum + { + // Properties + X, Y, Width, Height, ContentScriptType, ContentStyleType, Viewport, + PixelUnitToMillimeterX, PixelUnitToMillimeterY, ScreenPixelToMillimeterX, ScreenPixelToMillimeterY, + UseCurrentView, CurrentScale, CurrentTranslate, OnUnload, OnError, OnResize, OnZoom, OnScroll, + // Functions + CreateSVGNumber, CreateSVGLength, CreateSVGAngle, CreateSVGPoint, CreateSVGMatrix, CreateSVGRect, CreateSVGTransform, + CreateSVGTransformFromMatrix, SuspendRedraw, UnsuspendRedraw, UnsuspendRedrawAll, ForceRedraw, + PauseAnimations, UnpauseAnimations, AnimationsPaused, GetCurrentTime, SetCurrentTime, + GetIntersectionList, GetEnclosureList, CheckIntersection, CheckEnclosure, + DeselectAll, GetElementById + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +KSVG_REGISTER_ELEMENT(SVGSVGElementImpl, "svg") + +} + +KSVG_DEFINE_PROTOTYPE(SVGSVGElementImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGSVGElementImplProtoFunc, SVGSVGElementImpl) + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGScriptElementImpl.cc b/ksvg/impl/SVGScriptElementImpl.cc new file mode 100644 index 00000000..9a211425 --- /dev/null +++ b/ksvg/impl/SVGScriptElementImpl.cc @@ -0,0 +1,185 @@ +/* + 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> + +#include <kio/job.h> +#include <kfilterdev.h> +#include <qbuffer.h> + +#include "SVGDocumentImpl.h" +#include "SVGAnimatedStringImpl.h" +#include "SVGScriptElementImpl.moc" + +using namespace KSVG; + +#include "SVGScriptElementImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" + +SVGScriptElementImpl::SVGScriptElementImpl(DOM::ElementImpl *impl) : QObject(), SVGElementImpl(impl), SVGURIReferenceImpl(), SVGExternalResourcesRequiredImpl() +{ + KSVG_EMPTY_FLAGS + + m_job = 0; + m_added = false; +} + +SVGScriptElementImpl::~SVGScriptElementImpl() +{ +} + +void SVGScriptElementImpl::setType(const DOM::DOMString &type) +{ + setAttribute("type", type); +} + +DOM::DOMString SVGScriptElementImpl::type() const +{ + return getAttribute("type"); +} + +void SVGScriptElementImpl::setAttributes() +{ + SVGElementImpl::setAttributes(); + + // Spec: provide a default type + if(KSVG_TOKEN_NOT_PARSED(Type)) + KSVG_SET_ALT_ATTRIBUTE(Type, "text/ecmascript") + + // Remote downloading + QString href = m_href->baseVal().string(); + + if(!href.isEmpty()) + { + KURL url(ownerDoc()->baseUrl(), href); + + if(m_job == 0) + m_job = KIO::get(url, false, false); + + connect(m_job, SIGNAL(data(KIO::Job *, const QByteArray &)), this, SLOT(slotData(KIO::Job *, const QByteArray &))); + connect(m_job, SIGNAL(result(KIO::Job *)), this, SLOT(slotResult(KIO::Job *))); + } +} + +void SVGScriptElementImpl::slotData(KIO::Job *, const QByteArray &data) +{ + QDataStream dataStream(m_data, IO_WriteOnly | IO_Append); + dataStream.writeRawBytes(data.data(), data.size()); +} + +void SVGScriptElementImpl::slotResult(KIO::Job *) +{ + m_job = 0; + + // Append a NULL terminator so we don't die + m_data.resize(m_data.size() + 1); + m_data[m_data.size() - 1] = '\0'; + + QBuffer buf(m_data); + QIODevice *dev = KFilterDev::device(&buf, "application/x-gzip", false); + QByteArray contents; + if(dev->open(IO_ReadOnly)) + contents = dev->readAll(); + delete dev; + m_text = QString::fromUtf8(contents.data()); + + m_data.resize(0); +} + +bool SVGScriptElementImpl::canExecuteScript() +{ + if(!m_added) + { + m_added = true; + m_text += collectText(); + } + + if(m_text.isEmpty() && !getAttribute("href").isNull() && !getAttribute("href").string().isEmpty()) + return false; + + return true; +} + +bool SVGScriptElementImpl::executeScript(DOM::Node node) +{ + return SVGScriptElementImpl::executeScript(node, ownerDoc(), m_text); +} + +bool SVGScriptElementImpl::executeScript(DOM::Node node, SVGDocumentImpl *document, const QString &text) +{ +#ifdef KJS_VERBOSE + kdDebug(6070) << "SVGScriptElementImpl::executeScript n=" << node.nodeName().string().latin1() << "(" << (node.isNull() ? 0 : node.nodeType()) << ") " << text << endl; +#endif + KSVGEcma *ecmaEngine = document->ecmaEngine(); + + if(!ecmaEngine->initialized()) + ecmaEngine->setup(); + + KJS::Value thisNode = node.isNull() ? ecmaEngine->globalObject() : getDOMNode(ecmaEngine->globalExec(), node); + + KJS::UString code(text); + KJS::Completion comp = ecmaEngine->evaluate(code, thisNode); + + // TODO: If that's needed find a better solution which + // doesn't cause endless loops if the func, specified in + // onerror="..." isn't yet available + // onerror support +// if(comp.complType() == Throw) +// document->rootElement()->dispatchEvent(SVGEventImpl::ERROR_EVENT, false, false); + + return (comp.complType() == KJS::Normal) || (comp.complType() == KJS::ReturnValue); +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGScriptElementImpl::s_hashTable 2 + type SVGScriptElementImpl::Type DontDelete +@end +*/ + +Value SVGScriptElementImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case Type: + return String(type()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGScriptElementImpl::putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int) +{ + switch(token) + { + case Type: + setType(value.toString(exec).string()); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGScriptElementImpl.h b/ksvg/impl/SVGScriptElementImpl.h new file mode 100644 index 00000000..95affee2 --- /dev/null +++ b/ksvg/impl/SVGScriptElementImpl.h @@ -0,0 +1,90 @@ +/* + 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. +*/ + +#ifndef SVGScriptElementImpl_H +#define SVGScriptElementImpl_H + +#include <dom/dom_string.h> + +#include <kio/jobclasses.h> + +#include <qobject.h> + +#include "SVGElementImpl.h" +#include "SVGURIReferenceImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGScriptElementImpl : public QObject, + public SVGElementImpl, + public SVGURIReferenceImpl, + public SVGExternalResourcesRequiredImpl +{ +Q_OBJECT +public: + SVGScriptElementImpl(DOM::ElementImpl *); + virtual ~SVGScriptElementImpl(); + + void setType(const DOM::DOMString &type); + DOM::DOMString type() const; + + virtual void setAttributes(); + + bool canExecuteScript(); + bool executeScript(DOM::Node node); + + static bool executeScript(DOM::Node node, SVGDocumentImpl *document, const QString &text); + +private slots: + void slotData(KIO::Job *, const QByteArray &); + void slotResult(KIO::Job *); + +private: + KIO::TransferJob *m_job; + QByteArray m_data; + QString m_text; + bool m_added; + +public: + KSVG_GET + KSVG_PUT + KSVG_BRIDGE + + enum + { + // Properties + Type + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +KSVG_REGISTER_ELEMENT(SVGScriptElementImpl, "script") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGSetElementImpl.cc b/ksvg/impl/SVGSetElementImpl.cc new file mode 100644 index 00000000..66460db9 --- /dev/null +++ b/ksvg/impl/SVGSetElementImpl.cc @@ -0,0 +1,48 @@ +/* + 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 "SVGDocumentImpl.h" +#include "SVGSetElementImpl.h" + +using namespace KSVG; + +SVGSetElementImpl::SVGSetElementImpl(DOM::ElementImpl *impl) : SVGAnimationElementImpl(impl) +{ +} + +SVGSetElementImpl::~SVGSetElementImpl() +{ +} + +void SVGSetElementImpl::setAttributes() +{ + SVGAnimationElementImpl::setAttributes(); + + // Always create singleShot timers when used by <set> (Niko) + // Those are automatically deleted by the scheduler after timeout. + ownerDoc()->timeScheduler()->addTimer(this, int(getStartTime() * 1000.0)); +} + +void SVGSetElementImpl::handleTimerEvent() +{ + applyAttribute(getAttributeName(), getTo()); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGSetElementImpl.h b/ksvg/impl/SVGSetElementImpl.h new file mode 100644 index 00000000..ab9f5ec5 --- /dev/null +++ b/ksvg/impl/SVGSetElementImpl.h @@ -0,0 +1,54 @@ +/* + 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. +*/ + +#ifndef SVGSetElementImpl_H +#define SVGSetElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGAnimationElementImpl.h" + +class QTimer; + +namespace KSVG +{ + +class SVGSetElementImpl : public SVGAnimationElementImpl +{ +public: + SVGSetElementImpl(DOM::ElementImpl *); + virtual ~SVGSetElementImpl(); + + virtual void handleTimerEvent(); + virtual void setAttributes(); + +public: + KSVG_BRIDGE + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +KSVG_REGISTER_ELEMENT(SVGSetElementImpl, "set") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGShapeImpl.cc b/ksvg/impl/SVGShapeImpl.cc new file mode 100644 index 00000000..68e89aaa --- /dev/null +++ b/ksvg/impl/SVGShapeImpl.cc @@ -0,0 +1,162 @@ +/* + 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> + +#include "SVGPaint.h" + +#include "SVGRectImpl.h" +#include "SVGEventImpl.h" +#include "SVGShapeImpl.h" +#include "SVGPaintImpl.h" +#include "SVGMatrixImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGAnimatedLengthImpl.h" +#include "SVGClipPathElementImpl.h" +#include "SVGAnimatedLengthListImpl.h" + +#include "CanvasItem.h" +#include "KSVGCanvas.h" + +using namespace KSVG; + +SVGShapeImpl::SVGShapeImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl) +{ + m_item = 0; +} + +SVGShapeImpl::~SVGShapeImpl() +{ + if(hasChildNodes()) + { + DOM::Node node = firstChild(); + for(; !node.isNull(); node = node.nextSibling()) + { + SVGShapeImpl *rend = dynamic_cast<SVGShapeImpl *>(ownerDoc()->getElementFromHandle(node.handle())); + if(rend) + rend->deref(); + } + } +} + +bool SVGShapeImpl::directRender() +{ + SVGShapeImpl *parent = dynamic_cast<SVGShapeImpl *>(ownerDoc()->getElementFromHandle(parentNode().handle())); + if(parent) + return parent->directRender(); + else + return true; +} + +SVGRectImpl *SVGShapeImpl::getBBox() +{ + SVGRectImpl *rect = SVGSVGElementImpl::createSVGRect(); + return rect; +} + +SVGRectImpl *SVGShapeImpl::getBBoxInternal() +{ + SVGRectImpl *ret = SVGSVGElementImpl::createSVGRect(); + if(m_item) + { + QRect r = m_item->bbox(); + ret->setX(r.x()); + ret->setY(r.y()); + ret->setWidth(r.width()); + ret->setHeight(r.height()); + } + return ret; +} + +bool SVGShapeImpl::prepareMouseEvent(const QPoint &p, const QPoint &, SVGMouseEventImpl *mev) +{ + // TODO : pointer-events should be stored here, not in SVGStylableImpl. + SVGStylableImpl *style = dynamic_cast<SVGStylableImpl *>(this); + if(!style || style->getPointerEvents() == PE_NONE) + return false; + bool testFill = false; + bool testStroke = false; + switch(style->getPointerEvents()) + { + case PE_VISIBLE: testFill = testStroke = style->getVisible(); break; + case PE_VISIBLE_PAINTED: testStroke = style->getVisible() && style->isStroked(); + case PE_VISIBLE_FILL: testFill = style->getVisible() && style->isFilled(); break; + case PE_VISIBLE_STROKE: testStroke = style->getVisible() && style->isStroked(); break; + case PE_PAINTED: testStroke = style->isStroked(); + case PE_FILL: testFill = style->isFilled(); break; + case PE_STROKE: testStroke = style->isStroked(); break; + case PE_ALL: + default: testFill = testStroke = true; + }; + + if(testFill || testStroke) + { + if((testFill && m_item->fillContains(p)) || (testStroke && m_item->strokeContains(p))) + { + mev->setTarget(this); + return true; + } + } + + return false; +} + +void SVGShapeImpl::update(CanvasItemUpdate reason, int param1, int param2) +{ + if(m_item) + m_item->update(reason, param1, param2); +} + +void SVGShapeImpl::invalidate(KSVGCanvas *c, bool recalc) +{ + if(m_item && c) + c->invalidate(m_item, recalc); +} + +void SVGShapeImpl::setReferenced(bool referenced) +{ + if(m_item) + m_item->setReferenced(referenced); +} + +void SVGShapeImpl::draw() +{ + if(m_item) + m_item->draw(); +} + +void SVGShapeImpl::blit(KSVGCanvas *c) +{ + SVGRectImpl *rect = getBBoxInternal(); + c->blit(rect->qrect(), true); + rect->deref(); +} + +void SVGShapeImpl::removeItem(KSVGCanvas *c) +{ + if(m_item && c) + { + c->removeItem(m_item); + m_item = 0; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGShapeImpl.h b/ksvg/impl/SVGShapeImpl.h new file mode 100644 index 00000000..ae183251 --- /dev/null +++ b/ksvg/impl/SVGShapeImpl.h @@ -0,0 +1,73 @@ +/* + 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. +*/ + +#ifndef SVGShapeImpl_H +#define SVGShapeImpl_H + +#include "SVGElementImpl.h" +#include "CanvasItem.h" + +class QPoint; + +namespace KSVG +{ + +class KSVGCanvas; + +class SVGRectImpl; +class SVGMouseEventImpl; + +class SVGShapeImpl : public SVGElementImpl +{ +public: + SVGShapeImpl(DOM::ElementImpl *); + virtual ~SVGShapeImpl(); + + virtual SVGRectImpl *getBBox(); + virtual SVGRectImpl *getBBoxInternal(); + + virtual bool prepareMouseEvent(const QPoint &p, const QPoint &a, SVGMouseEventImpl *mev); + + virtual bool directRender(); + virtual bool isContainer() const { return false; } + + virtual void update(CanvasItemUpdate reason, int param1 = 0, int param2 = 0); + virtual void invalidate(KSVGCanvas *c, bool recalc); + virtual void setReferenced(bool referenced); + virtual void draw(); + virtual void blit(KSVGCanvas *); + + virtual void removeItem(KSVGCanvas *c); + + CanvasItem *item() { return m_item; } + +protected: + CanvasItem *m_item; + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGStopElementImpl.cc b/ksvg/impl/SVGStopElementImpl.cc new file mode 100644 index 00000000..09761232 --- /dev/null +++ b/ksvg/impl/SVGStopElementImpl.cc @@ -0,0 +1,125 @@ +/* + 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> +#include "SVGLengthImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGStopElementImpl.h" +#include "SVGAnimatedNumberImpl.h" +#include "SVGColorImpl.h" + +using namespace KSVG; + +#include "SVGStopElementImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" + +SVGStopElementImpl::SVGStopElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGStylableImpl(this) +{ + KSVG_EMPTY_FLAGS + + m_offset = new SVGAnimatedNumberImpl(); + m_offset->ref(); + + m_stopOpacity = 1; +} + +SVGStopElementImpl::~SVGStopElementImpl() +{ + if(m_offset) + m_offset->deref(); +} + +SVGAnimatedNumberImpl *SVGStopElementImpl::offset() const +{ + return m_offset; +} + +float SVGStopElementImpl::stopOpacity() const +{ + return m_stopOpacity; +} + + +/* +@namespace KSVG +@begin SVGStopElementImpl::s_hashTable 3 + offset SVGStopElementImpl::Offset DontDelete|ReadOnly + stop-opacity SVGStopElementImpl::StopOpacity DontDelete|ReadOnly +@end +*/ + +Value SVGStopElementImpl::getValueProperty(ExecState *exec, int token) const +{ + KSVG_CHECK_ATTRIBUTE + + switch(token) + { + case Offset: + if(!attributeMode) + return m_offset->cache(exec); + else + return Number(m_offset->baseVal()); + case StopOpacity: + if(!attributeMode) + return Undefined(); + else + return Number(m_stopOpacity); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGStopElementImpl::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; + + switch(token) + { + case Offset: + float temp; + SVGLengthImpl::convertPercentageToFloat(value.toString(exec).qstring(), temp); + offset()->setBaseVal(temp); + break; + case StopOpacity: + { + SVGLengthImpl::convertPercentageToFloat(value.toString(exec).qstring(), m_stopOpacity); + break; + } + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +void SVGStopElementImpl::setAttributes() +{ + SVGElementImpl::setAttributes(); + + // Spec: if not set, specifiy 0 + if(KSVG_TOKEN_NOT_PARSED(Offset)) + KSVG_SET_ALT_ATTRIBUTE(Offset, "0") +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGStopElementImpl.h b/ksvg/impl/SVGStopElementImpl.h new file mode 100644 index 00000000..369b7867 --- /dev/null +++ b/ksvg/impl/SVGStopElementImpl.h @@ -0,0 +1,70 @@ +/* + 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. +*/ + +#ifndef SVGStopElementImpl_H +#define SVGStopElementImpl_H + +#include "SVGElementImpl.h" +#include "SVGStylableImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGAnimatedNumberImpl; +class SVGStopElementImpl : public SVGElementImpl, + public SVGStylableImpl +{ +public: + SVGStopElementImpl(DOM::ElementImpl *); + virtual ~SVGStopElementImpl(); + + SVGAnimatedNumberImpl *offset() const; + float stopOpacity() const; + + virtual void setAttributes(); + +private: + SVGAnimatedNumberImpl *m_offset; + float m_stopOpacity; + +public: + KSVG_GET + KSVG_PUT + KSVG_BRIDGE + + enum + { + // Properties + Offset, StopOpacity + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +KSVG_REGISTER_ELEMENT(SVGStopElementImpl, "stop") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGStringListImpl.cc b/ksvg/impl/SVGStringListImpl.cc new file mode 100644 index 00000000..b70adfdd --- /dev/null +++ b/ksvg/impl/SVGStringListImpl.cc @@ -0,0 +1,93 @@ +/* + 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> + +#include "SVGStringListImpl.h" + +using namespace KSVG; + +#include "SVGStringListImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +// Ecma stuff + +/* +@namespace KSVG +@begin SharedString::s_hashTable 2 + dummy SharedString::Dummy DontDelete|ReadOnly +@end +*/ + +/* +@namespace KSVG +@begin SVGStringListImpl::s_hashTable 2 + numberOfItems SVGListDefs::NumberOfItems DontDelete|ReadOnly +@end +@namespace KSVG +@begin SVGStringListImplProto::s_hashTable 11 + getItem SVGListDefs::GetItem DontDelete|Function 1 + removeItem SVGListDefs::RemoveItem DontDelete|Function 1 + appendItem SVGListDefs::AppendItem DontDelete|Function 1 + initialize SVGListDefs::Initialize DontDelete|Function 1 + insertItemBefore SVGListDefs::InsertItemBefore DontDelete|Function 2 + replaceItem SVGListDefs::ReplaceItem DontDelete|Function 2 + clear SVGListDefs::Clear DontDelete|Function 0 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGStringList", SVGStringListImplProto, SVGStringListImplProtoFunc) + +Value SVGStringListImpl::getValueProperty(ExecState *exec, int token) const +{ + return SVGList<SharedString>::getValueProperty(exec, token); +} + +Value SVGStringListImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGStringListImpl) + + return obj->call(exec, static_cast<SVGList<SharedString> *>(obj), args, id); +} + +QString SVGStringListImpl::join(const QString &seperator) const +{ + SVGStringListImpl *self = const_cast<SVGStringListImpl *>(this); + + QString result; + + if(!self->getItem(0)) + return result; + else + result += self->getItem(0)->string(); + + for(unsigned int i = 1; i <= numberOfItems(); i++) + { + DOM::DOMString *string = self->getItem(i); + + if(string) + result += seperator + string->string(); + } + + return result; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGStringListImpl.h b/ksvg/impl/SVGStringListImpl.h new file mode 100644 index 00000000..7f69a3c9 --- /dev/null +++ b/ksvg/impl/SVGStringListImpl.h @@ -0,0 +1,82 @@ +/* + 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. +*/ + +#ifndef SVGStringListImpl_H +#define SVGStringListImpl_H + +#include <dom/dom_string.h> + +#include "SVGList.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SharedString : public DOM::DomShared, + public DOM::DOMString +{ +public: + SharedString() : DOM::DomShared(), DOM::DOMString() { } + SharedString(const QString &string) : DOM::DomShared(), DOM::DOMString(string) { } + SharedString(const SharedString &string) : DOM::DomShared(), DOM::DOMString(string) { } + SharedString(DOM::DOMString *string) : DOM::DomShared(), DOM::DOMString(string->implementation()) { } + virtual ~SharedString() { } + +public: + KSVG_GET + + enum + { + // Properties + Dummy + }; + + KJS::Value getValueProperty(KJS::ExecState *, int token) const + { + switch(token) + { + case Dummy: + return KJS::Undefined(); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return KJS::Undefined(); + } + } +}; + +class SVGStringListImpl : public SVGList<SharedString> +{ +public: + KSVG_GET + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + + QString join(const QString &seperator) const; +}; + +} + +KSVG_DEFINE_PROTOTYPE(SVGStringListImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGStringListImplProtoFunc, SVGStringListImpl) + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGStylableImpl.cc b/ksvg/impl/SVGStylableImpl.cc new file mode 100644 index 00000000..096ebf93 --- /dev/null +++ b/ksvg/impl/SVGStylableImpl.cc @@ -0,0 +1,1309 @@ +/* + 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> + +#include <qrect.h> + +#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() +{ + SVGStylableImpl *parentStyle = 0; + if(m_object && m_object->ownerDoc()) + parentStyle = dynamic_cast<SVGStylableImpl *>(m_object->ownerDoc()->getElementFromHandle((*m_object).parentNode().handle())); + + // Spec: default "none" + if(~m_flags & SVG_STYLE_FLAG_STROKE) + { + m_strokeColor = new SVGPaintImpl(m_object); + m_strokeColor->ref(); + + SVGPaintImpl *strokeColor = 0L; + if(parentStyle) + strokeColor = parentStyle->getStrokeColor(); + + 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; + if(parentStyle) + fillColor = parentStyle->getFillColor(); + + 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; + if(parentStyle) + color = parentStyle->getColor(); + + if(color) + *m_color = *color; + } + + // Spec: default sRGB + if(~m_flags & SVG_STYLE_FLAG_COLOR_INTERPOLATION) + { + if(parentStyle) + m_colorInterpolation = parentStyle->getColorInterpolation(); + 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; + if(parentStyle) + strokeWidth = parentStyle->getStrokeWidth(); + + if(strokeWidth) + *m_strokeWidth = *strokeWidth; + else + m_strokeWidth->baseVal()->setValue(1.0); + } + + // Spec: default "4" + if(~m_flags & SVG_STYLE_FLAG_STROKE_MITER_LIMIT) + { + if(parentStyle) + m_strokeMiterlimit = parentStyle->getStrokeMiterlimit(); + else + m_strokeMiterlimit = 4; + } + + // Spec: default "butt" + if(~m_flags & SVG_STYLE_FLAG_STROKE_LINE_CAP) + { + if(parentStyle) + m_capStyle = parentStyle->getCapStyle(); + else + m_capStyle = PATH_STROKE_CAP_BUTT; + } + + // Spec: default "miter" + if(~m_flags & SVG_STYLE_FLAG_STROKE_LINE_JOIN) + { + if(parentStyle) + m_joinStyle = parentStyle->getJoinStyle(); + else + m_joinStyle = PATH_STROKE_JOIN_MITER; + } + + // Spec: default "auto" + if(~m_flags & SVG_STYLE_FLAG_CURSOR) + { + if(parentStyle) + m_cursor = parentStyle->getCursor(); + else + m_cursor = CURSOR_AUTO; + } + + // Spec: default "visiblePainted" + if(~m_flags & SVG_STYLE_FLAG_POINTER_EVENTS) + { + if(parentStyle) + m_pointerEvents = parentStyle->getPointerEvents(); + 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; + if(parentStyle) + dashOffset = parentStyle->getDashOffset(); + + 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; + if(parentStyle) + dashArray = parentStyle->getDashArray(); + + 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) + { + if(parentStyle) + m_fillOpacity = parentStyle->getFillOpacity(); + else + m_fillOpacity = 1; + } + + if(~m_flags & SVG_STYLE_FLAG_STROKE_OPACITY) + { + if(parentStyle) + m_strokeOpacity = parentStyle->getStrokeOpacity(); + else + m_strokeOpacity = 1; + } + + // Fake group opacity by multiplying by our parent's group opacity + if(~m_flags & SVG_STYLE_FLAG_OPACITY) + { + if(parentStyle) + m_opacity = parentStyle->getOpacity(); + else + m_opacity = 1; + } + else + if(parentStyle) + m_opacity *= parentStyle->getOpacity(); + + if(~m_flags & SVG_STYLE_FLAG_CLIP_PATH) + m_clipPath = ""; + + if(~m_flags & SVG_STYLE_FLAG_MASK) + m_mask = ""; + + // Spec: default "nonzero" + if(~m_flags & SVG_STYLE_FLAG_FILL_RULE) + { + if(parentStyle) + m_fillRule = parentStyle->getFillRule(); + else + m_fillRule = RULE_NONZERO; + } + + if(~m_flags & SVG_STYLE_FLAG_CLIP_RULE) + { + if(parentStyle) + m_clipRule = parentStyle->getClipRule(); + else + m_clipRule = RULE_NONZERO; + } + + // Spec: default "hidden" + if(~m_flags & SVG_STYLE_FLAG_OVERFLOW) + { + if(parentStyle) + m_overflow = parentStyle->getOverflow(); + 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) + { + if(parentStyle) + m_visible = parentStyle->getVisible(); + else + m_visible = true; + } + + // Spec: default "medium" + if(~m_flags & SVG_STYLE_FLAG_FONT_SIZE) + { + if(parentStyle) + m_fontSize = parentStyle->getFontSize(); + 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; + if(parentStyle) + fontFamily = parentStyle->getFontFamily(); + + 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) + { + if(parentStyle) + m_fontStyle = parentStyle->getFontStyle(); + else + m_fontStyle = FSNORMAL; + } + + // Spec: default "normal" + if(~m_flags & SVG_STYLE_FLAG_FONT_WEIGHT) + { + if(parentStyle) + m_fontWeight = parentStyle->getFontWeight(); + else + m_fontWeight = "normal"; + } + + // Spec: default "start" + if(~m_flags & SVG_STYLE_FLAG_TEXT_ANCHOR) + { + if(parentStyle) + m_textAnchor = parentStyle->getTextAnchor(); + else + m_textAnchor = TASTART; + } + + // Spec: default "LTR" + if(~m_flags & SVG_STYLE_FLAG_TEXT_DIRECTION) + { + if(parentStyle) + m_textDirection = parentStyle->getTextDirection(); + else + m_textDirection = LTR; + } + + // Spec: default "none" + if(~m_flags & SVG_STYLE_FLAG_TEXT_DECORATION) + { + if(parentStyle) + m_textDecoration = parentStyle->getTextDecoration(); + else + m_textDecoration = TDNONE; + } + + // Spec: default "baseline" + if(~m_flags & SVG_STYLE_FLAG_BASELINE_SHIFT) + { + if(parentStyle) + m_baselineShift = parentStyle->getBaselineShift(); + else + m_baselineShift = "baseline"; + } + + // Spec: default "lr-tb", FIXME + if(~m_flags & SVG_STYLE_FLAG_TEXT_WRITING_MODE) + { + if(parentStyle) + m_textWritingMode = parentStyle->getTextWritingMode(); + else + m_textWritingMode = LR; + } + + // Spec: default "normal" + if(~m_flags & SVG_STYLE_FLAG_TEXT_UNICODE_BIDI) + { + if(parentStyle) + m_textUnicodeBidi = parentStyle->getTextUnicodeBidi(); + else + m_textUnicodeBidi = UBNORMAL; + } + + // Spec: default "auto" + if(~m_flags & SVG_STYLE_FLAG_GLYPH_ORIENTATION_VERTICAL) + { + if(parentStyle) + m_glyphOrientationVertical = parentStyle->getGlyphOrientationVertical(); + else + m_glyphOrientationVertical = "auto"; + } + + // Spec: default "auto" + if(~m_flags & SVG_STYLE_FLAG_GLYPH_ORIENTATION_HORIZONTAL) + { + if(parentStyle) + m_glyphOrientationHorizontal = parentStyle->getGlyphOrientationHorizontal(); + else + m_glyphOrientationHorizontal = "auto"; + } + + // Spec: default "normal" + if(~m_flags & SVG_STYLE_FLAG_LETTER_SPACING) + { + if(parentStyle) + m_letterSpacing = parentStyle->getLetterSpacing(); + else + m_letterSpacing = "normal"; + } + + // Spec: default "normal" + if(~m_flags & SVG_STYLE_FLAG_WORD_SPACING) + { + if(parentStyle) + m_wordSpacing = parentStyle->getWordSpacing(); + 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) + { + if(parentStyle) + m_startMarker = parentStyle->getStartMarker(); + else + m_startMarker = QString::null; + } + + // Spec: default "none" + if(~m_flags & SVG_STYLE_FLAG_MARKER_MID) + { + if(parentStyle) + m_midMarker = parentStyle->getMidMarker(); + else + m_midMarker = QString::null; + } + + // Spec: default "none" + if(~m_flags & SVG_STYLE_FLAG_MARKER_END) + { + if(parentStyle) + m_endMarker = parentStyle->getEndMarker(); + else + m_endMarker = QString::null; + } +} + +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; +} + +QString SVGStylableImpl::extractUrlId(const QString &url) +{ + QString id; + + if(url.startsWith("url(#")) + { + int idstart = url.find("#") + 1; + id = url.mid(idstart, url.length() - idstart - 1); + } + else + id = url; + + return id; +} + +void SVGStylableImpl::setMarkers(const QString &marker) +{ + setStartMarker(marker); + setMidMarker(marker); + setEndMarker(marker); +} + +void SVGStylableImpl::setStartMarker(const QString &startMarker) +{ + if(startMarker.startsWith("url(#")) + { + int idstart = startMarker.find("#") + 1; + m_startMarker = startMarker.mid(idstart, startMarker.length() - idstart - 1); + } + else if(startMarker == "none") + m_startMarker = QString::null; +} + +void SVGStylableImpl::setMidMarker(const QString &midMarker) +{ + if(midMarker.startsWith("url(#")) + { + int idstart = midMarker.find("#") + 1; + m_midMarker = midMarker.mid(idstart, midMarker.length() - idstart - 1); + } + else if(midMarker == "none") + m_midMarker = QString::null; +} + +void SVGStylableImpl::setEndMarker(const QString &endMarker) +{ + if(endMarker.startsWith("url(#")) + { + int idstart = endMarker.find("#") + 1; + m_endMarker = endMarker.mid(idstart, endMarker.length() - idstart - 1); + } + else if(endMarker == "none") + m_endMarker = QString::null; +} + +bool SVGStylableImpl::hasMarkers() const +{ + return !m_startMarker.isEmpty() || !m_midMarker.isEmpty() || !m_endMarker.isEmpty(); +} + +void SVGStylableImpl::setPaint(const QString ¶m, SVGPaintImpl *svgPaint) +{ + 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); +} + +void SVGStylableImpl::setColor(const QString ¶m, SVGColorImpl *svgColor) +{ + if(param.stripWhiteSpace().startsWith("#")) + { + if(param.contains("icc-color")) + { + QString first = param.left(7); + QString last = param.right(param.length() - 8); + + svgColor->setRGBColorICCColor(first, last); + } + else + { + QColor color; + color.setNamedColor(param.stripWhiteSpace()); + svgColor->setRGBColor(color); + } + } + else if(param.stripWhiteSpace().startsWith("rgb(")) + { + QString parse = param.stripWhiteSpace(); + QStringList colors = QStringList::split(',', parse); + QString r = colors[0].right((colors[0].length() - 4)); + QString g = colors[1]; + QString b = colors[2].left((colors[2].length() - 1)); + + if(r.contains("%")) + { + r = r.left(r.length() - 1); + r = QString::number(int((double(255 * r.toDouble()) / 100.0))); + } + + if(g.contains("%")) + { + g = g.left(g.length() - 1); + g = QString::number(int((double(255 * g.toDouble()) / 100.0))); + } + + if(b.contains("%")) + { + b = b.left(b.length() - 1); + b = QString::number(int((double(255 * b.toDouble()) / 100.0))); + } + + 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())); + } +} + +QRect SVGStylableImpl::clip() +{ + return QRect(); +} + +void SVGStylableImpl::setClip(const QString &) +{ +} + +float SVGStylableImpl::fontSizeForText(const QString &value) +{ + 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 + unicode-bidi SVGStylableImpl::UnicodeBidi DontDelete|ReadOnly + 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 + mask SVGStylableImpl::Mask DontDelete|ReadOnly +@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; + + QString param = value.toString(exec).qstring(); + + if (param.isEmpty()) + return; + + bool redraw = false; + bool inherit = (param == "inherit"); + int update = -1; + + switch(token) + { + case Style: + { + if(!m_object) + return; + + QStringList substyles = QStringList::split(';', param); + for(QStringList::Iterator it = substyles.begin(); it != substyles.end(); ++it) + { + QStringList substyle = QStringList::split(':', (*it)); + 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 "" + param = param.replace('\'', QString::null); + // #2 Replace "MS-Gothic" by "MS Gothic" + param = param.replace("MS-Gothic", "MS Gothic"); + // #3 Replace "Helvetica" by "Arial" + param = param.replace("Helvetica", "Arial"); + param = param.replace("helvetica", "Arial"); + + 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") + m_fontStyle = OBLIQUE; + break; + case TextDecoration: + m_flags |= SVG_STYLE_FLAG_TEXT_DECORATION; + if(param == "none") + m_textDecoration = TDNONE; + { + // CSS2 allows multiple decorations + m_textDecoration = TDNONE; + QStringList decorations = QStringList::split(' ', param); + for(QStringList::Iterator it = decorations.begin(); it != decorations.end(); ++it) + { + 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; + // Spec: direction is only processed when unicode-bidi + // 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) + m_mask = extractUrlId(param); + 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) + { + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(m_object); + if(inherit) + processStyle(); + + if(shape && shape->item()) + { + if(update > -1) + shape->item()->update(static_cast<CanvasItemUpdate>(update)); + else if(m_object) + m_object->ownerDoc()->canvas()->invalidate(shape->item(), false); + } + } +} + +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(); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGStylableImpl.h b/ksvg/impl/SVGStylableImpl.h new file mode 100644 index 00000000..0a399a4c --- /dev/null +++ b/ksvg/impl/SVGStylableImpl.h @@ -0,0 +1,327 @@ +/* + 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. +*/ + +#ifndef SVGStylableImpl_H +#define SVGStylableImpl_H + +#include <qstring.h> +#include <qstringlist.h> + +#include <dom/dom_string.h> + +#include "ksvg_lookup.h" + +class QRect; + +// from libart, but now no dependency +typedef enum +{ + PATH_STROKE_JOIN_MITER, + PATH_STROKE_JOIN_ROUND, + PATH_STROKE_JOIN_BEVEL +} PathStrokeJoinType; + +typedef enum +{ + PATH_STROKE_CAP_BUTT, + PATH_STROKE_CAP_ROUND, + PATH_STROKE_CAP_SQUARE +} PathStrokeCapType; + +#define SVG_STYLE_FLAG_NONE 0x0000000000000ULL +#define SVG_STYLE_FLAG_BASELINE_SHIFT 0x0000000000001ULL +#define SVG_STYLE_FLAG_CLIP_PATH 0x0000000000002ULL +#define SVG_STYLE_FLAG_CLIP_RULE 0x0000000000004ULL +#define SVG_STYLE_FLAG_COLOR 0x0000000000008ULL +#define SVG_STYLE_FLAG_COLOR_INTERPOLATION 0x0000000000010ULL +#define SVG_STYLE_FLAG_COLOR_INTERPOLATION_FILTERS 0x0000000000020ULL +#define SVG_STYLE_FLAG_COLOR_PROFILE 0x0000000000040ULL +#define SVG_STYLE_FLAG_COLOR_RENDERING 0x0000000000080ULL +#define SVG_STYLE_FLAG_CURSOR 0x0000000000100ULL +#define SVG_STYLE_FLAG_DIRECTION 0x0000000000200ULL +#define SVG_STYLE_FLAG_DISPLAY 0x0000000000400ULL +#define SVG_STYLE_FLAG_FILL 0x0000000000800ULL +#define SVG_STYLE_FLAG_FILL_OPACITY 0x0000000001000ULL +#define SVG_STYLE_FLAG_FILL_RULE 0x0000000002000ULL +#define SVG_STYLE_FLAG_FONT_FAMILY 0x0000000004000ULL +#define SVG_STYLE_FLAG_FONT_SIZE 0x0000000008000ULL +#define SVG_STYLE_FLAG_FONT_SIZE_ADJUST 0x0000000010000ULL +#define SVG_STYLE_FLAG_FONT_STRETCH 0x0000000020000ULL +#define SVG_STYLE_FLAG_FONT_STYLE 0x0000000040000ULL +#define SVG_STYLE_FLAG_FONT_VARIANT 0x0000000080000ULL +#define SVG_STYLE_FLAG_FONT_WEIGHT 0x0000000100000ULL +#define SVG_STYLE_FLAG_GLYPH_ORIENTATION_HORIZONTAL 0x0000000200000ULL +#define SVG_STYLE_FLAG_GLYPH_ORIENTATION_VERTICAL 0x0000000400000ULL +#define SVG_STYLE_FLAG_IMAGE_RENDERING 0x0000000800000ULL +#define SVG_STYLE_FLAG_KERNING 0x0000001000000ULL +#define SVG_STYLE_FLAG_LETTER_SPACING 0x0000002000000ULL +#define SVG_STYLE_FLAG_MARKER 0x0000004000000ULL +#define SVG_STYLE_FLAG_MARKER_END 0x0000008000000ULL +#define SVG_STYLE_FLAG_MARKER_MID 0x0000010000000ULL +#define SVG_STYLE_FLAG_MARKER_START 0x0000020000000ULL +#define SVG_STYLE_FLAG_OPACITY 0x0000040000000ULL +#define SVG_STYLE_FLAG_POINTER_EVENTS 0x0000080000000ULL +#define SVG_STYLE_FLAG_SHAPE_RENDERING 0x0000100000000ULL +#define SVG_STYLE_FLAG_STOP 0x0000200000000ULL +#define SVG_STYLE_FLAG_STROKE_DASH_ARRAY 0x0000400000000ULL +#define SVG_STYLE_FLAG_STROKE_DASH_OFFSET 0x0000800000000ULL +#define SVG_STYLE_FLAG_STROKE_LINE_CAP 0x0001000000000ULL +#define SVG_STYLE_FLAG_STROKE_LINE_JOIN 0x0002000000000ULL +#define SVG_STYLE_FLAG_STROKE_MITER_LIMIT 0x0004000000000ULL +#define SVG_STYLE_FLAG_STROKE_OPACITY 0x0008000000000ULL +#define SVG_STYLE_FLAG_STROKE 0x0010000000000ULL +#define SVG_STYLE_FLAG_STROKE_WIDTH 0x0020000000000ULL +#define SVG_STYLE_FLAG_TEXT_ANCHOR 0x0040000000000ULL +#define SVG_STYLE_FLAG_TEXT_DECORATION 0x0080000000000ULL +#define SVG_STYLE_FLAG_TEXT_DIRECTION 0x0100000000000ULL +#define SVG_STYLE_FLAG_TEXT_RENDERING 0x0200000000000ULL +#define SVG_STYLE_FLAG_TEXT_UNICODE_BIDI 0x0400000000000ULL +#define SVG_STYLE_FLAG_TEXT_WRITING_MODE 0x0800000000000ULL +#define SVG_STYLE_FLAG_VISIBILITY 0x1000000000000ULL +#define SVG_STYLE_FLAG_WORD_SPACING 0x2000000000000ULL +#define SVG_STYLE_FLAG_OVERFLOW 0x4000000000000ULL +#define SVG_STYLE_FLAG_MASK 0x0008000000000000ULL + +//?#define SVG_STYLE_FLAG_MASK_INHERIT 0x0010000000000000ULL + +// Helper macros +#define STYLE_GET(Return, Name, Member) \ +protected:\ + Return Member;\ +public:\ +Return get ##Name () const { return Member; } + +#define STYLE_GET_OPTIM(Return, Name, Member, Optim) \ +protected:\ + Return Member : Optim;\ +public:\ +Return get ##Name () const { return Member; } + +#define STYLE_HAS(Name, Member) \ +bool has##Name () { return ! Member .isEmpty(); } + +namespace KSVG +{ + +enum ECursor +{ + CURSOR_AUTO, + CURSOR_CROSSHAIR, + CURSOR_DEFAULT, + CURSOR_POINTER, + CURSOR_MOVE, + CURSOR_E_RESIZE, + CURSOR_NE_RESIZE, + CURSOR_N_RESIZE, + CURSOR_NW_RESIZE, + CURSOR_SE_RESIZE, + CURSOR_SW_RESIZE, + CURSOR_S_RESIZE, + CURSOR_W_RESIZE, + CURSOR_TEXT, + CURSOR_WAIT, + CURSOR_HELP +}; + +enum ETextDirection +{ + LTR, RTL +}; + +enum ETextDecoration +{ + TDNONE = 0, UNDERLINE = 1, OVERLINE = 2, LINE_THROUGH = 4 +}; + +enum ETextAnchor +{ + TASTART, TAMIDDLE, TAEND +}; + +enum EUnicodeBidi +{ + UBNORMAL, EMBED, OVERRIDE, INHERIT +}; + +enum EFontStyle +{ + FSNORMAL, ITALIC, OBLIQUE +}; + +enum ETextWritingMode +{ + LR, RL, TB +}; + +enum EWindRule +{ + RULE_NONZERO, + RULE_EVENODD +}; + +enum EPointerEvents +{ + PE_NONE, + PE_STROKE, + PE_FILL, + PE_PAINTED, + PE_VISIBLE, + PE_VISIBLE_STROKE, + PE_VISIBLE_FILL, + PE_VISIBLE_PAINTED, + PE_ALL, + PE_INHERIT +}; + +enum EColorInterpolation +{ + CI_SRGB, + CI_LINEARRGB +}; + +class SVGColorImpl; +class SVGPaintImpl; +class SVGLengthImpl; +class SVGAnimatedLengthImpl; +class SVGAnimatedLengthListImpl; +class SVGMatrixImpl; +class SVGStringListImpl; +class SVGElementImpl; +class SVGStylableImpl +{ +public: + SVGStylableImpl(SVGElementImpl *object); + virtual ~SVGStylableImpl(); + + static void setColor(const QString &, SVGColorImpl *); + + STYLE_GET(SVGAnimatedLengthImpl *, DashOffset, m_dashOffset) + STYLE_GET(SVGAnimatedLengthListImpl *, DashArray, m_dashArray) + STYLE_GET(SVGPaintImpl *, StrokeColor, m_strokeColor) + STYLE_GET(SVGPaintImpl *, FillColor, m_fillColor) + STYLE_GET(SVGColorImpl *, StopColor, m_stopColor) + STYLE_GET(SVGColorImpl *, Color, m_color) + STYLE_GET(SVGAnimatedLengthImpl *, StrokeWidth, m_strokeWidth) + STYLE_GET(SVGStringListImpl *, FontFamily, m_fontFamily); + STYLE_GET(float, FontSize, m_fontSize) + STYLE_GET(QString, LetterSpacing, m_letterSpacing) + STYLE_GET(QString, WordSpacing, m_wordSpacing) + STYLE_GET(QString, FontWeight, m_fontWeight) + STYLE_GET(QString, ClipPath, m_clipPath) + STYLE_GET(QString, Mask, m_mask) + STYLE_GET(QString, StartMarker, m_startMarker) + STYLE_GET(QString, MidMarker, m_midMarker) + STYLE_GET(QString, EndMarker, m_endMarker) + STYLE_GET(QString, BaselineShift, m_baselineShift) + STYLE_GET(QString, GlyphOrientationVertical, m_glyphOrientationVertical) + STYLE_GET(QString, GlyphOrientationHorizontal, m_glyphOrientationHorizontal) + STYLE_GET(float, Opacity, m_opacity) + STYLE_GET(float, FillOpacity, m_fillOpacity) + STYLE_GET(float, StrokeOpacity, m_strokeOpacity) + STYLE_GET(unsigned int, StrokeMiterlimit, m_strokeMiterlimit) + + STYLE_GET_OPTIM(EPointerEvents, PointerEvents, m_pointerEvents, 4) + STYLE_GET_OPTIM(ECursor, Cursor, m_cursor, 4) + STYLE_GET_OPTIM(EWindRule, FillRule, m_fillRule, 1) + STYLE_GET_OPTIM(EWindRule, ClipRule, m_clipRule, 1) + STYLE_GET_OPTIM(PathStrokeCapType, CapStyle, m_capStyle, 2) + STYLE_GET_OPTIM(PathStrokeJoinType, JoinStyle, m_joinStyle, 2) + STYLE_GET_OPTIM(ETextDirection, TextDirection, m_textDirection, 1) + STYLE_GET_OPTIM(unsigned int, TextDecoration, m_textDecoration, 3) + STYLE_GET_OPTIM(ETextAnchor, TextAnchor, m_textAnchor, 2) + STYLE_GET_OPTIM(EUnicodeBidi, TextUnicodeBidi, m_textUnicodeBidi, 2) + STYLE_GET_OPTIM(ETextWritingMode, TextWritingMode, m_textWritingMode, 2) + STYLE_GET_OPTIM(EFontStyle, FontStyle, m_fontStyle, 2) + STYLE_GET_OPTIM(bool, Overflow, m_overflow, 1) + STYLE_GET_OPTIM(bool, Visible, m_visible, 1) + STYLE_GET_OPTIM(bool, Display, m_display, 1) + STYLE_GET_OPTIM(EColorInterpolation, ColorInterpolation, m_colorInterpolation, 1) + + STYLE_HAS(ClipPath, m_clipPath) + STYLE_HAS(Mask, m_mask) + STYLE_HAS(StartMarker, m_startMarker) + STYLE_HAS(MidMarker, m_midMarker) + STYLE_HAS(EndMarker, m_endMarker) + + // Special "set" cases + void setStartMarker(const QString &); + void setMidMarker(const QString &); + void setEndMarker(const QString &); + void setMarkers(const QString &); + + // Special "has" cases + bool hasMarkers() const; + + // Special "is" cases + bool isStroked() const; + bool isFilled() const; + + // Function which sets default values + void processStyle(); + + // Special virtual functions + virtual void setClip(const QString &clip); + virtual QRect clip(); + +protected: + float fontSizeForText(const QString &); + + SVGElementImpl *m_object; + +private: + void setPaint(const QString &, SVGPaintImpl *); + QString extractUrlId(const QString& string); + + unsigned long long m_flags; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + ClassName, Style, + StrokeWidth, StrokeMiterlimit, StrokeLineCap, StrokeLineJoin, + Stroke, Fill, Color, StopColor, FontSize, FontFamily, FontWeight, + FontStyle, TextDecoration, TextAnchor, Direction, WritingMode, + UnicodeBidi, Opacity, FillOpacity, StrokeOpacity, ClipPath, + MarkerStart, MarkerMid, MarkerEnd, Marker, Cursor, Display, + Overflow, Clip, Visibility, FillRule, ClipRule, + StrokeDashOffset, StrokeDashArray, ColorProfile, BaselineShift, + LetterSpacing, WordSpacing, PointerEvents, + GlyphOrientationVertical, GlyphOrientationHorizontal, + ColorInterpolation, Mask, + // Functions + GetStyle + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +KSVG_DEFINE_PROTOTYPE(SVGStylableImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGStylableImplProtoFunc, SVGStylableImpl) + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGStyleElementImpl.cc b/ksvg/impl/SVGStyleElementImpl.cc new file mode 100644 index 00000000..d826441b --- /dev/null +++ b/ksvg/impl/SVGStyleElementImpl.cc @@ -0,0 +1,135 @@ +/* + 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> + +#include "SVGStyleElementImpl.h" + +using namespace KSVG; + +#include "SVGStyleElementImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" + +SVGStyleElementImpl::SVGStyleElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl) +{ + KSVG_EMPTY_FLAGS +} + +SVGStyleElementImpl::~SVGStyleElementImpl() +{ +} + +void SVGStyleElementImpl::setXmlspace(const DOM::DOMString &xmlspace) +{ + setAttribute("xml:space", xmlspace); +} + +DOM::DOMString SVGStyleElementImpl::xmlspace() const +{ + return getAttribute("xml:space"); +} + +void SVGStyleElementImpl::setType(const DOM::DOMString &type) +{ + setAttribute("type", type); +} + +DOM::DOMString SVGStyleElementImpl::type() const +{ + return getAttribute("type"); +} + +void SVGStyleElementImpl::setMedia(const DOM::DOMString &media) +{ + setAttribute("media", media); +} + +DOM::DOMString SVGStyleElementImpl::media() const +{ + return getAttribute("media"); +} + +void SVGStyleElementImpl::setTitle(const DOM::DOMString &title) +{ + setAttribute("title", title); +} + +DOM::DOMString SVGStyleElementImpl::title() const +{ + return getAttribute("title"); +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGStyleElementImpl::s_hashTable 5 + xmlspace SVGStyleElementImpl::Xmlspace DontDelete + type SVGStyleElementImpl::Type DontDelete + media SVGStyleElementImpl::Media DontDelete + title SVGStyleElementImpl::Title DontDelete +@end +*/ + +Value SVGStyleElementImpl::getValueProperty(ExecState *, int token) const +{ + //KSVG_CHECK_ATTRIBUTE + + switch(token) + { + case Xmlspace: + return String(xmlspace()); + case Type: + return String(type()); + case Media: + return String(media()); + case Title: + return String(title()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGStyleElementImpl::putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int) +{ + switch(token) + { + case Xmlspace: + setXmlspace(value.toString(exec).string()); + break; + case Type: + setType(value.toString(exec).string()); + break; + case Media: + setMedia(value.toString(exec).string()); + break; + case Title: + setTitle(value.toString(exec).string()); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + break; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGStyleElementImpl.h b/ksvg/impl/SVGStyleElementImpl.h new file mode 100644 index 00000000..fcf7b152 --- /dev/null +++ b/ksvg/impl/SVGStyleElementImpl.h @@ -0,0 +1,72 @@ +/* + 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. +*/ + +#ifndef SVGStyleElementImpl_H +#define SVGStyleElementImpl_H + +#include <dom/dom_string.h> + +#include "SVGElementImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGStyleElementImpl : public SVGElementImpl +{ +public: + SVGStyleElementImpl(DOM::ElementImpl *); + virtual ~SVGStyleElementImpl(); + + void setXmlspace(const DOM::DOMString &xmlspace); + DOM::DOMString xmlspace() const; + + void setType(const DOM::DOMString &type); + DOM::DOMString type() const; + + void setMedia(const DOM::DOMString &media); + DOM::DOMString media() const; + + void setTitle(const DOM::DOMString &title); + DOM::DOMString title() const; + +public: + KSVG_GET + KSVG_PUT + KSVG_BRIDGE + + enum + { + // Properties + Xmlspace, Type, Media, Title + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +KSVG_REGISTER_ELEMENT(SVGStyleElementImpl, "style") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGSwitchElementImpl.cc b/ksvg/impl/SVGSwitchElementImpl.cc new file mode 100644 index 00000000..613a1982 --- /dev/null +++ b/ksvg/impl/SVGSwitchElementImpl.cc @@ -0,0 +1,58 @@ +/* + 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 "SVGDocumentImpl.h" +#include "SVGSwitchElementImpl.h" +#include "KSVGCanvas.h" + +using namespace KSVG; + +SVGSwitchElementImpl::SVGSwitchElementImpl(DOM::ElementImpl *impl) : SVGContainerImpl(impl), SVGTestsImpl(), SVGLangSpaceImpl(), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this), SVGTransformableImpl() +{ +} + +SVGSwitchElementImpl::~SVGSwitchElementImpl() +{ +} + +void SVGSwitchElementImpl::createItem(KSVGCanvas *c) +{ + if(!c) + c = ownerDoc()->canvas(); + + DOM::Node node = firstChild(); + for(; !node.isNull(); node = node.nextSibling()) + { + SVGElementImpl *element = ownerDoc()->getElementFromHandle(node.handle()); + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(element); + SVGTestsImpl *tests = dynamic_cast<SVGTestsImpl *>(element); + SVGStylableImpl *style = dynamic_cast<SVGStylableImpl *>(element); + + bool ok = tests ? tests->ok() : true; + + if(element && shape && ok && style->getVisible() && style->getDisplay() && (shape->directRender() || !directRender())) + { + element->createItem(c); + break; + } + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGSwitchElementImpl.h b/ksvg/impl/SVGSwitchElementImpl.h new file mode 100644 index 00000000..2b29d2a4 --- /dev/null +++ b/ksvg/impl/SVGSwitchElementImpl.h @@ -0,0 +1,62 @@ +/* + 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. +*/ + +#ifndef SVGSwitchElementImpl_H +#define SVGSwitchElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGTestsImpl.h" +#include "SVGStylableImpl.h" +#include "SVGContainerImpl.h" +#include "SVGLangSpaceImpl.h" +#include "SVGTransformableImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + +namespace KSVG +{ + +class SVGSwitchElementImpl : public SVGContainerImpl, + public SVGTestsImpl, + public SVGLangSpaceImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl, + public SVGTransformableImpl +{ +public: + SVGSwitchElementImpl(DOM::ElementImpl *); + virtual ~SVGSwitchElementImpl(); + + virtual void createItem(KSVGCanvas *c = 0); + virtual bool isContainer() const { return true; } + +public: + KSVG_BRIDGE + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +KSVG_REGISTER_ELEMENT(SVGSwitchElementImpl, "switch") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGSymbolElementImpl.cc b/ksvg/impl/SVGSymbolElementImpl.cc new file mode 100644 index 00000000..da0b5b90 --- /dev/null +++ b/ksvg/impl/SVGSymbolElementImpl.cc @@ -0,0 +1,106 @@ +/* + 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> + +#include "SVGRectImpl.h" +#include "SVGMatrixImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGAnimatedRectImpl.h" +#include "SVGSymbolElementImpl.h" +#include "SVGAnimatedLengthImpl.h" +#include "SVGPreserveAspectRatioImpl.h" +#include "SVGAnimatedPreserveAspectRatioImpl.h" +#include "KSVGCanvas.h" + +using namespace KSVG; + +#include "SVGSymbolElementImpl.lut.h" +#include "ksvg_scriptinterpreter.h" + +SVGSymbolElementImpl::SVGSymbolElementImpl(DOM::ElementImpl *impl) : SVGShapeImpl(impl), SVGLangSpaceImpl(), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this), SVGFitToViewBoxImpl() +{ + KSVG_EMPTY_FLAGS + + m_width = new SVGAnimatedLengthImpl(LENGTHMODE_WIDTH, this); + m_width->ref(); + + m_height = new SVGAnimatedLengthImpl(LENGTHMODE_HEIGHT, this); + m_height->ref(); +} + +SVGSymbolElementImpl::~SVGSymbolElementImpl() +{ + if(m_width) + m_width->deref(); + if(m_height) + m_height->deref(); +} +/* +@namespace KSVG +@begin SVGSymbolElementImpl::s_hashTable 3 + width SVGSymbolElementImpl::Width DontDelete|ReadOnly + height SVGSymbolElementImpl::Height DontDelete|ReadOnly +@end +*/ + +Value SVGSymbolElementImpl::getValueProperty(ExecState *exec, int token) const +{ + KSVG_CHECK_ATTRIBUTE + + switch(token) + { + case Width: + if(!attributeMode) + return m_width->cache(exec); + else + return Number(m_width->baseVal()->value()); + case Height: + if(!attributeMode) + return m_height->cache(exec); + else + return Number(m_height->baseVal()->value()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGSymbolElementImpl::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; + + switch(token) + { + case Width: + m_width->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + case Height: + m_height->baseVal()->setValueAsString(value.toString(exec).qstring()); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGSymbolElementImpl.h b/ksvg/impl/SVGSymbolElementImpl.h new file mode 100644 index 00000000..19278ea0 --- /dev/null +++ b/ksvg/impl/SVGSymbolElementImpl.h @@ -0,0 +1,76 @@ +/* + 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. +*/ + +#ifndef SVGSymbolElementImpl_H +#define SVGSymbolElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGShapeImpl.h" +#include "SVGStylableImpl.h" +#include "SVGLangSpaceImpl.h" +#include "SVGFitToViewBoxImpl.h" +#include "SVGTransformableImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + +namespace KSVG +{ + +class SVGFitToViewBoxImpl; +class SVGAnimatedLengthImpl; +class SVGSymbolElementImpl : public SVGShapeImpl, + public SVGLangSpaceImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl, + public SVGFitToViewBoxImpl +{ +public: + SVGSymbolElementImpl(DOM::ElementImpl *); + virtual ~SVGSymbolElementImpl(); + + virtual bool isContainer() const { return true; } + virtual bool directRender() { return false; } + +private: + SVGAnimatedLengthImpl *m_width; + SVGAnimatedLengthImpl *m_height; + +public: + KSVG_GET + KSVG_PUT + KSVG_BRIDGE + + enum + { + // Properties + Width, Height + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +KSVG_REGISTER_ELEMENT(SVGSymbolElementImpl, "symbol") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTRefElementImpl.cc b/ksvg/impl/SVGTRefElementImpl.cc new file mode 100644 index 00000000..c1c7e540 --- /dev/null +++ b/ksvg/impl/SVGTRefElementImpl.cc @@ -0,0 +1,76 @@ +/* + 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 "SVGDocumentImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGTRefElementImpl.h" +#include "SVGTextElementImpl.h" +#include "SVGAnimatedStringImpl.h" + +#include "KSVGLoader.h" + +using namespace KSVG; + +SVGTRefElementImpl::SVGTRefElementImpl(DOM::ElementImpl *impl) : SVGTSpanElementImpl(impl), SVGURIReferenceImpl() +{ +} + +SVGTRefElementImpl::~SVGTRefElementImpl() +{ +} + +void SVGTRefElementImpl::setAttributes() +{ + SVGTSpanElementImpl::setAttributes(); + + DOM::DOMString _href = href()->baseVal(); + + if(!_href.isNull()) + href()->setBaseVal(DOM::DOMString(SVGURIReferenceImpl::getTarget(_href.string()))); + + // get the text of the referenced element + QString text; + + QString url = _href.string().stripWhiteSpace(), filename, id; + if(!SVGURIReferenceImpl::parseURIReference(url, filename, id)) + return; + + if(!filename.isEmpty()) // a reference into another svg + text = KSVGLoader::getCharacterData(KURL(ownerDoc()->baseUrl().path(), filename), id); + else + { + // a reference to an element in this svg + SVGElementImpl *target = ownerSVGElement()->getElementById(id); + SVGTextElementImpl *textTarget = dynamic_cast<SVGTextElementImpl *>(target); + + if(textTarget) + text = textTarget->text(); + } + + text = handleText(text); + + if(!text.isEmpty()) + { + DOM::Text impl = static_cast<DOM::Document *>(ownerDoc())->createTextNode(text); + appendChild(impl); + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTRefElementImpl.h b/ksvg/impl/SVGTRefElementImpl.h new file mode 100644 index 00000000..60d82231 --- /dev/null +++ b/ksvg/impl/SVGTRefElementImpl.h @@ -0,0 +1,52 @@ +/* + 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. +*/ + +#ifndef SVGTRefElementImpl_H +#define SVGTRefElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGTSpanElementImpl.h" +#include "SVGURIReferenceImpl.h" + +namespace KSVG +{ + +class SVGTRefElementImpl : public SVGTSpanElementImpl, + public SVGURIReferenceImpl +{ +public: + SVGTRefElementImpl(DOM::ElementImpl *); + virtual ~SVGTRefElementImpl(); + virtual void setAttributes(); + +public: + KSVG_BRIDGE + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +KSVG_REGISTER_ELEMENT(SVGTRefElementImpl, "tref") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTSpanElementImpl.cc b/ksvg/impl/SVGTSpanElementImpl.cc new file mode 100644 index 00000000..7265c66e --- /dev/null +++ b/ksvg/impl/SVGTSpanElementImpl.cc @@ -0,0 +1,64 @@ +/* + 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 <Glyph.h> + +#include "SVGDocumentImpl.h" +#include "SVGTextElementImpl.h" +#include "SVGTSpanElementImpl.h" +#include "SVGAnimatedLengthListImpl.h" + +#include "KSVGCanvas.h" +#include "KSVGTextChunk.h" + +using namespace KSVG; +using namespace KJS; + +SVGTSpanElementImpl::SVGTSpanElementImpl(DOM::ElementImpl *impl) : SVGTextPositioningElementImpl(impl) +{ +} + +SVGTSpanElementImpl::~SVGTSpanElementImpl() +{ +} + +long SVGTSpanElementImpl::getNumberOfChars() +{ + return text().length(); +} + +QString SVGTSpanElementImpl::text() +{ + // Otherwhise some js scripts which require a child, don't work (Niko) + if(!hasChildNodes()) + { + DOM::Text impl = static_cast<DOM::Document *>(ownerDoc())->createTextNode(DOM::DOMString("")); + appendChild(impl); + } + + return textDirectionAwareText(); +} + +void SVGTSpanElementImpl::setAttributes() +{ + SVGTextPositioningElementImpl::setAttributes(); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTSpanElementImpl.h b/ksvg/impl/SVGTSpanElementImpl.h new file mode 100644 index 00000000..26e4903d --- /dev/null +++ b/ksvg/impl/SVGTSpanElementImpl.h @@ -0,0 +1,55 @@ +/* + 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. +*/ + +#ifndef SVGTSpanElementImpl_H +#define SVGTSpanElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGTextPositioningElementImpl.h" + +namespace KSVG +{ + +class SVGTSpanElementImpl : public SVGTextPositioningElementImpl +{ +public: + SVGTSpanElementImpl(DOM::ElementImpl *); + virtual ~SVGTSpanElementImpl(); + + QString text(); + + virtual long getNumberOfChars(); + + virtual void setAttributes(); + +public: + KSVG_BRIDGE + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +KSVG_REGISTER_ELEMENT(SVGTSpanElementImpl, "tspan") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTestsImpl.cc b/ksvg/impl/SVGTestsImpl.cc new file mode 100644 index 00000000..8bbccf80 --- /dev/null +++ b/ksvg/impl/SVGTestsImpl.cc @@ -0,0 +1,178 @@ +/* + 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 <klocale.h> +#include <kglobal.h> + +#include "SVGTestsImpl.h" +#include "SVGStringListImpl.h" + +using namespace KSVG; + +#include "SVGTestsImpl.lut.h" + +SVGTestsImpl::SVGTestsImpl() +{ + KSVG_EMPTY_FLAGS + + m_requiredFeatures = new SVGStringListImpl(); + m_requiredFeatures->ref(); + + m_requiredExtensions = new SVGStringListImpl(); + m_requiredExtensions->ref(); + + m_systemLanguage = new SVGStringListImpl(); + m_systemLanguage->ref(); +} + +SVGTestsImpl::~SVGTestsImpl() +{ + if(m_requiredFeatures) + m_requiredFeatures->deref(); + if(m_requiredExtensions) + m_requiredExtensions->deref(); + if(m_systemLanguage) + m_systemLanguage->deref(); +} + +void SVGTestsImpl::parseRequiredFeatures(const QString &/*value*/) +{ + // FIXME +} + +void SVGTestsImpl::parseRequiredExtensions(const QString &value) +{ + m_requiredExtensions->appendItem(new SharedString(value)); +} + +void SVGTestsImpl::parseSystemLanguage(const QString &value) +{ + m_systemLanguage->appendItem(new SharedString(value)); +} + +SVGStringListImpl *SVGTestsImpl::requiredFeatures() const +{ + return m_requiredFeatures; +} + +SVGStringListImpl *SVGTestsImpl::requiredExtensions() const +{ + return m_requiredExtensions; +} + +SVGStringListImpl *SVGTestsImpl::systemLanguage() const +{ + return m_systemLanguage; +} + +bool SVGTestsImpl::ok() +{ + for(unsigned int i = 0;i < m_requiredExtensions->numberOfItems();i++) + { + // FIXME + return false; + } + for(unsigned int i = 0;i < m_systemLanguage->numberOfItems();i++) + { + QString value = m_systemLanguage->getItem(i)->string(); + if(value.isEmpty() || value != (KGlobal::locale()->language()).left(2)) + return false; + } + return true; +} + +bool SVGTestsImpl::hasExtension(const DOM::DOMString &/*extension*/) +{ + return false; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGTestsImpl::s_hashTable 5 + requiredFeatures SVGTestsImpl::RequiredFeatures DontDelete|ReadOnly + requiredExtensions SVGTestsImpl::RequiredExtensions DontDelete|ReadOnly + systemLanguage SVGTestsImpl::SystemLanguage DontDelete|ReadOnly +@end +@namespace KSVG +@begin SVGTestsImplProto::s_hashTable 2 + hasExtension SVGTestsImpl::HasExtension DontDelete|Function 1 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGTests", SVGTestsImplProto, SVGTestsImplProtoFunc) + +Value SVGTestsImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case RequiredFeatures: + return m_requiredFeatures->cache(exec); + case RequiredExtensions: + return m_requiredExtensions->cache(exec); + case SystemLanguage: + return m_systemLanguage->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGTestsImpl::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; + + switch(token) + { + case RequiredFeatures: + parseRequiredFeatures(value.toString(exec).qstring()); + break; + case RequiredExtensions: + parseRequiredExtensions(value.toString(exec).qstring()); + break; + case SystemLanguage: + parseSystemLanguage(value.toString(exec).qstring()); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +Value SVGTestsImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGTestsImpl) + + switch(id) + { + case SVGTestsImpl::HasExtension: + return Boolean(obj->hasExtension(args[0].toString(exec).string())); + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return Undefined(); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTestsImpl.h b/ksvg/impl/SVGTestsImpl.h new file mode 100644 index 00000000..c5b05a5f --- /dev/null +++ b/ksvg/impl/SVGTestsImpl.h @@ -0,0 +1,77 @@ +/* + 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. +*/ + +#ifndef SVGTestsImpl_H +#define SVGTestsImpl_H + +#include <dom/dom_string.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGStringListImpl; +class SVGTestsImpl +{ +public: + SVGTestsImpl(); + ~SVGTestsImpl(); + + void parseRequiredFeatures(const QString &value); + void parseRequiredExtensions(const QString &value); + void parseSystemLanguage(const QString &value); + + SVGStringListImpl *requiredFeatures() const; + SVGStringListImpl *requiredExtensions() const; + SVGStringListImpl *systemLanguage() const; + + bool ok(); + bool hasExtension(const DOM::DOMString &extension); + +private: + SVGStringListImpl *m_requiredFeatures; + SVGStringListImpl *m_requiredExtensions; + SVGStringListImpl *m_systemLanguage; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + RequiredFeatures, RequiredExtensions, SystemLanguage, + // Functions + HasExtension + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +KSVG_DEFINE_PROTOTYPE(SVGTestsImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGTestsImplProtoFunc, SVGTestsImpl) + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTextContentElementImpl.cc b/ksvg/impl/SVGTextContentElementImpl.cc new file mode 100644 index 00000000..f51d8807 --- /dev/null +++ b/ksvg/impl/SVGTextContentElementImpl.cc @@ -0,0 +1,285 @@ +/* + 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> +#include <klocale.h> + +#include "Glyph.h" + +#include "SVGStringListImpl.h" +#include "SVGAnimatedLengthImpl.h" +#include "SVGTextContentElementImpl.h" +#include "SVGTextElementImpl.h" +#include "SVGAnimatedEnumerationImpl.h" +#include "SVGDocumentImpl.h" + +using namespace KSVG; + +#include "SVGTextContentElementImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_cacheimpl.h" + +SVGTextContentElementImpl::SVGTextContentElementImpl(DOM::ElementImpl *impl) : SVGShapeImpl(impl), SVGTestsImpl(), SVGLangSpaceImpl(), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this) +{ + KSVG_EMPTY_FLAGS + + m_lengthAdjust = new SVGAnimatedEnumerationImpl(); + m_lengthAdjust->ref(); + + // Spec: default value 'spacing' + m_lengthAdjust->setBaseVal(LENGTHADJUST_SPACING); + + m_textLength = new SVGAnimatedLengthImpl(); + m_textLength->baseVal()->setValueAsString("-1"); + m_textLength->ref(); +} + +SVGTextContentElementImpl::~SVGTextContentElementImpl() +{ + if(m_lengthAdjust) + m_lengthAdjust->deref(); + if(m_textLength) + m_textLength->deref(); +} + +QString SVGTextContentElementImpl::textDirectionAwareText() +{ + QString text; + + if(hasChildNodes()) + { + bool ltr = getTextDirection() == LTR; + DOM::Node node = ltr ? firstChild() : lastChild(); + + for(; !node.isNull(); node = ltr ? node.nextSibling() : node.previousSibling()) + { + if(node.nodeType() == TEXT_NODE) + { + DOM::Text textNode = node; + QString temp = textNode.data().string(); + + if(!ltr) + { + QString convert = temp; + + for(int i = temp.length(); i > 0; i--) + convert[temp.length() - i] = temp[i - 1]; + + text += convert; + } + else + text += temp; + } + else + return text; + } + } + + return text; +} + +T2P::GlyphLayoutParams *SVGTextContentElementImpl::layoutParams() const +{ + SVGStylableImpl *style = const_cast<SVGTextContentElementImpl *>(this); + + T2P::GlyphLayoutParams *params = new T2P::GlyphLayoutParams(); + params->setTb(style->getTextWritingMode() == TB); + params->setUseBidi(style->getTextUnicodeBidi() == UBNORMAL); + if(!dynamic_cast<SVGTextElementImpl *>(m_object)) // not allowed for <text> + params->setBaselineShift(style->getBaselineShift().latin1()); + + bool worked = true; + int deg = style->getGlyphOrientationVertical().toInt(&worked); + if(!worked) + params->setGlyphOrientationVertical(-90); + else + params->setGlyphOrientationVertical(deg); + + worked = true; + deg = style->getGlyphOrientationHorizontal().toInt(&worked); + if(!worked) + params->setGlyphOrientationHorizontal(-90); + else + params->setGlyphOrientationHorizontal(deg); + + SVGLengthImpl *length = new SVGLengthImpl(LENGTHMODE_OTHER, const_cast<SVGTextContentElementImpl *>(this)); + length->ref(); + + if(style->getLetterSpacing() != "normal" && style->getLetterSpacing() != "inherit") + length->setValueAsString(DOM::DOMString(style->getLetterSpacing())); + params->setLetterSpacing(length->value()); + + if(style->getWordSpacing() != "normal" && style->getWordSpacing() != "inherit") + length->setValueAsString(DOM::DOMString(style->getWordSpacing())); + params->setWordSpacing(length->value()); + + length->deref(); + + return params; +} + +SVGAnimatedLengthImpl *SVGTextContentElementImpl::textLength() const +{ + return m_textLength; +} + +SVGAnimatedEnumerationImpl *SVGTextContentElementImpl::lengthAdjust() const +{ + return m_lengthAdjust; +} + +long SVGTextContentElementImpl::getNumberOfChars() +{ + return 0; +} + +float SVGTextContentElementImpl::getComputedTextLength() +{ + return 0.0; +} + +/* +float SVGTextContentElementImpl::getSubStringLength(const unsigned long &charnum,const unsigned long &nchars) +{ +} + +SVGPoint SVGTextContentElementImpl::getStartPositionOfChar(const unsigned long &charnum) +{ +} + +SVGPoint SVGTextContentElementImpl::getEndPositionOfChar(const unsigned long &charnum) +{ +} + +SVGRect SVGTextContentElementImpl::getExtentOfChar(const unsigned long &charnum) +{ +} + +float SVGTextContentElementImpl::getRotationOfChar(const unsigned long &charnum) +{ +} + +long SVGTextContentElementImpl::getCharNumAtPosition(const SVGPoint &point) +{ +} + +void SVGTextContentElementImpl::selectSubString(const unsigned long &charnum,const unsigned long &nchars) +{ +} +*/ + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGTextContentElementImpl::s_hashTable 3 + textLength SVGTextContentElementImpl::TextLength DontDelete|ReadOnly + lengthAdjust SVGTextContentElementImpl::LengthAdjust DontDelete|ReadOnly +@end +@namespace KSVG +@begin SVGTextContentElementImplProto::s_hashTable 11 + getNumberOfChars SVGTextContentElementImpl::GetNumberOfChars DontDelete|Function 0 + getComputedTextLength SVGTextContentElementImpl::GetComputedTextLength DontDelete|Function 0 + getSubStringLength SVGTextContentElementImpl::GetSubStringLength DontDelete|Function 2 + getStartPositionOfChar SVGTextContentElementImpl::GetStartPositionOfChar DontDelete|Function 1 + getEndPositionOfChar SVGTextContentElementImpl::GetEndPositionOfChar DontDelete|Function 1 + getExtentOfChar SVGTextContentElementImpl::GetExtentOfChar DontDelete|Function 1 + getRotationOfChar SVGTextContentElementImpl::GetRotationOfChar DontDelete|Function 1 + getCharNumAtPosition SVGTextContentElementImpl::GetCharNumAtPosition DontDelete|Function 1 + selectSubString SVGTextContentElementImpl::SelectSubString DontDelete|Function 2 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGTextContentElement", SVGTextContentElementImplProto, SVGTextContentElementImplProtoFunc) + +Value SVGTextContentElementImpl::getValueProperty(ExecState *, int token) const +{ + //KSVG_CHECK_ATTRIBUTE + + switch(token) + { + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGTextContentElementImpl::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; + + switch(token) + { + case TextLength: + m_textLength->baseVal()->setValueAsString(value.toString(exec).string()); + if(m_textLength->baseVal()->value() < 0) // A negative value is an error + gotError(i18n("Negative value for attribute textLength of element <text> is illegal")); + break; + case LengthAdjust: + { + QString temp = value.toString(exec).qstring(); + if(temp == "spacingAndGlyphs") + m_lengthAdjust->setBaseVal(LENGTHADJUST_SPACINGANDGLYPHS); + else if(temp == "spacing") + m_lengthAdjust->setBaseVal(LENGTHADJUST_SPACING); + break; + } + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +Value SVGTextContentElementImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &) +{ + KSVG_CHECK_THIS(SVGTextContentElementImpl) + + switch(id) + { + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return Undefined(); +} + +/* +@namespace KSVG +@begin SVGTextContentElementImplConstructor::s_hashTable 5 + LENGTHADJUST_UNKNOWN KSVG::LENGTHADJUST_UNKNOWN DontDelete|ReadOnly + LENGTHADJUST_SPACING KSVG::LENGTHADJUST_SPACING DontDelete|ReadOnly + LENGTHADJUST_SPACINGANDGLYPHS KSVG::LENGTHADJUST_SPACINGANDGLYPHS DontDelete|ReadOnly +@end +*/ + +Value SVGTextContentElementImplConstructor::getValueProperty(ExecState *, int token) const +{ + return Number(token); +} + +Value KSVG::getSVGTextContentElementImplConstructor(ExecState *exec) +{ + return cacheGlobalBridge<SVGTextContentElementImplConstructor>(exec, "[[svgtextcontentelement.constructor]]"); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTextContentElementImpl.h b/ksvg/impl/SVGTextContentElementImpl.h new file mode 100644 index 00000000..26bbc041 --- /dev/null +++ b/ksvg/impl/SVGTextContentElementImpl.h @@ -0,0 +1,115 @@ +/* + 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. +*/ + +#ifndef SVGTextContentElementImpl_H +#define SVGTextContentElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGShapeImpl.h" +#include "SVGTestsImpl.h" +#include "SVGStylableImpl.h" +#include "SVGLangSpaceImpl.h" +#include "SVGTextContentElement.h" +#include "SVGExternalResourcesRequiredImpl.h" + +namespace T2P +{ + class GlyphLayoutParams; +} + +namespace KSVG +{ + +class SVGAnimatedLengthImpl; +class SVGAnimatedEnumerationImpl; +class SVGTextContentElementImpl : public SVGShapeImpl, + public SVGTestsImpl, + public SVGLangSpaceImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl +{ +public: + SVGTextContentElementImpl(DOM::ElementImpl *impl); + virtual ~SVGTextContentElementImpl(); + + QString textDirectionAwareText(); + + virtual T2P::GlyphLayoutParams *layoutParams() const; + + SVGAnimatedLengthImpl *textLength() const; + SVGAnimatedEnumerationImpl *lengthAdjust() const; + + virtual long getNumberOfChars(); + float getComputedTextLength(); + +// float getSubStringLength(const unsigned long &charnum, const unsigned long &nchars); +// SVGPoint getStartPositionOfChar(const unsigned long &charnum); +// SVGPoint getEndPositionOfChar(const unsigned long &charnum); +// SVGRect getExtentOfChar(const unsigned long &charnum); +// float getRotationOfChar(const unsigned long &charnum); +// long getCharNumAtPosition(const SVGPoint &point); +// void selectSubString(const unsigned long &charnum, const unsigned long &nchars); + +private: + SVGAnimatedEnumerationImpl *m_lengthAdjust; + SVGAnimatedLengthImpl *m_textLength; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + TextLength, LengthAdjust, + // Functions + GetTextLength, GetLengthAdjust, + GetNumberOfChars, GetComputedTextLength, + GetSubStringLength, GetStartPositionOfChar, + GetEndPositionOfChar, GetExtentOfChar, + GetRotationOfChar, GetCharNumAtPosition, + SelectSubString + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +class SVGTextContentElementImplConstructor : public KJS::ObjectImp +{ +public: + SVGTextContentElementImplConstructor(KJS::ExecState *) { } + KJS::Value getValueProperty(KJS::ExecState *, int token) const; + + // no put - all read-only + KSVG_GET +}; + +KJS::Value getSVGTextContentElementImplConstructor(KJS::ExecState *exec); + +} + +KSVG_DEFINE_PROTOTYPE(SVGTextContentElementImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGTextContentElementImplProtoFunc, SVGTextContentElementImpl) + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTextElementImpl.cc b/ksvg/impl/SVGTextElementImpl.cc new file mode 100644 index 00000000..634c227d --- /dev/null +++ b/ksvg/impl/SVGTextElementImpl.cc @@ -0,0 +1,124 @@ +/* + 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 <Glyph.h> + +#include "SVGRectImpl.h" +#include "SVGEventImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGTextElementImpl.h" + +#include "CanvasItem.h" +#include "KSVGCanvas.h" + +using namespace KSVG; + +SVGTextElementImpl::SVGTextElementImpl(DOM::ElementImpl *impl) : SVGTextPositioningElementImpl(impl), SVGTransformableImpl() +{ + m_bboxX = 0; + m_bboxY = 0; + + m_bboxWidth = 0; + m_bboxHeight = 0; +} + +SVGTextElementImpl::~SVGTextElementImpl() +{ +} + +long SVGTextElementImpl::getNumberOfChars() +{ + return text().length(); +} + +QString SVGTextElementImpl::text() +{ + // Otherwhise some js scripts which require a child, don't work (Niko) + if(!hasChildNodes()) + { + DOM::Text impl = static_cast<DOM::Document *>(ownerDoc())->createTextNode(DOM::DOMString("")); + appendChild(impl); + } + + return textDirectionAwareText(); +} + +SVGRectImpl *SVGTextElementImpl::getBBox() +{ + SVGRectImpl *ret = SVGSVGElementImpl::createSVGRect(); + ret->setX(m_bboxX); + ret->setY(m_bboxY); + ret->setWidth(m_bboxWidth); + ret->setHeight(m_bboxHeight); + return ret; +} + +void SVGTextElementImpl::createItem(KSVGCanvas *c ) +{ + if(!c) + c = ownerDoc()->canvas(); + + if(!m_item) + { + m_item = c->createText(this); + // Set up bbox before insert(), as that may render the item + QRect rect = m_item->bbox(); + m_bboxX = rect.x(); + m_bboxY = rect.y(); + m_bboxWidth = rect.width(); + m_bboxHeight = rect.height(); + c->insert(m_item); + } +} + +bool SVGTextElementImpl::prepareMouseEvent(const QPoint &p, const QPoint &, SVGMouseEventImpl *mev) +{ + // TODO : pointer-events should be stored here, not in SVGStylableImpl. + SVGStylableImpl *style = dynamic_cast<SVGStylableImpl *>(this); + if(!style || style->getPointerEvents() == PE_NONE) + return false; + bool test = false; + switch(style->getPointerEvents()) + { + case PE_VISIBLE: test = style->getVisible(); break; + case PE_VISIBLE_PAINTED: test = style->getVisible() && (style->isStroked() || style->isFilled()) ; break; + case PE_VISIBLE_FILL: test = style->getVisible() && style->isFilled(); break; + case PE_VISIBLE_STROKE: test = style->getVisible() && style->isStroked(); break; + case PE_PAINTED: test = style->isStroked() || style->isFilled(); break; + case PE_FILL: test = style->isFilled(); break; + case PE_STROKE: test = style->isStroked(); break; + case PE_ALL: + default: test = true; + }; + + if(test) + { + if(m_item->bbox().contains(p)) + { + mev->setTarget(dynamic_cast<SVGElementImpl *>(this)); + return true; + } + } + + return false; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTextElementImpl.h b/ksvg/impl/SVGTextElementImpl.h new file mode 100644 index 00000000..e0c2ca8d --- /dev/null +++ b/ksvg/impl/SVGTextElementImpl.h @@ -0,0 +1,65 @@ +/* + 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. +*/ + +#ifndef SVGTextElementImpl_H +#define SVGTextElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGTransformableImpl.h" +#include "SVGTextPositioningElementImpl.h" + +namespace KSVG +{ + +class SVGRectImpl; +class SVGTextElementImpl : public SVGTextPositioningElementImpl, + public SVGTransformableImpl +{ +public: + SVGTextElementImpl(DOM::ElementImpl *); + virtual ~SVGTextElementImpl(); + + QString text(); + + virtual long getNumberOfChars(); + + virtual void createItem(KSVGCanvas *c = 0); + + virtual SVGRectImpl *getBBox(); + + virtual bool prepareMouseEvent(const QPoint &p, const QPoint &a, SVGMouseEventImpl *mev); + +private: + int m_bboxX, m_bboxY, m_bboxWidth, m_bboxHeight; + +public: + KSVG_BRIDGE + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +KSVG_REGISTER_ELEMENT(SVGTextElementImpl, "text") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTextPathElementImpl.cc b/ksvg/impl/SVGTextPathElementImpl.cc new file mode 100644 index 00000000..ec218046 --- /dev/null +++ b/ksvg/impl/SVGTextPathElementImpl.cc @@ -0,0 +1,240 @@ +/* + 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> +#include <klocale.h> + +#include "Glyph.h" + +#include "SVGDocumentImpl.h" +#include "SVGTextPathElement.h" +#include "SVGAnimatedLengthImpl.h" +#include "SVGTextPathElementImpl.h" +#include "SVGAnimatedEnumerationImpl.h" + +using namespace KSVG; + +#include "SVGTextPathElementImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_ecma.h" +#include "ksvg_cacheimpl.h" + +SVGTextPathElementImpl::SVGTextPathElementImpl(DOM::ElementImpl *impl) : SVGTextContentElementImpl(impl), SVGURIReferenceImpl() +{ + KSVG_EMPTY_FLAGS + + m_startOffset = new SVGAnimatedLengthImpl(); + m_startOffset->ref(); + + m_method = new SVGAnimatedEnumerationImpl(); + m_method->ref(); + + m_spacing = new SVGAnimatedEnumerationImpl(); + m_spacing->ref(); +} + +SVGTextPathElementImpl::~SVGTextPathElementImpl() +{ + if(m_startOffset) + m_startOffset->deref(); + if(m_method) + m_method->deref(); + if(m_spacing) + m_spacing->deref(); +} + +SVGAnimatedLengthImpl *SVGTextPathElementImpl::startOffset() const +{ + return m_startOffset; +} + +SVGAnimatedEnumerationImpl *SVGTextPathElementImpl::method() const +{ + return m_method; +} + +SVGAnimatedEnumerationImpl *SVGTextPathElementImpl::spacing() const +{ + return m_spacing; +} + +QString SVGTextPathElementImpl::text() +{ + // Otherwhise some js scripts which require a child, don't work (Niko) + if(!hasChildNodes()) + { + DOM::Text impl = static_cast<DOM::Document *>(ownerDoc())->createTextNode(DOM::DOMString("")); + appendChild(impl); + } + + return textDirectionAwareText(); +} + +void SVGTextPathElementImpl::setAttributes() +{ + SVGElementImpl::setAttributes(); + + // Spec: if not specified, effect is as if a value of "0" were specified + if(KSVG_TOKEN_NOT_PARSED(StartOffset)) + KSVG_SET_ALT_ATTRIBUTE(StartOffset, "0") + + // Spec: if not specified, effect is as if a value of "align" were specified + if(KSVG_TOKEN_NOT_PARSED(Method)) + KSVG_SET_ALT_ATTRIBUTE(Method, "align") + + // Spec: if not specified, effect is as if a value of "exact" were specified + if(KSVG_TOKEN_NOT_PARSED(Spacing)) + KSVG_SET_ALT_ATTRIBUTE(Spacing, "exact") +} + +T2P::GlyphLayoutParams *SVGTextPathElementImpl::layoutParams() const +{ + T2P::GlyphLayoutParams *params = SVGTextContentElementImpl::layoutParams(); + params->setTextPathStartOffset(startOffset()->baseVal()->value()); + return params; +} + + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGTextPathElementImpl::s_hashTable 5 + startOffset SVGTextPathElementImpl::StartOffset DontDelete|ReadOnly + method SVGTextPathElementImpl::Method DontDelete|ReadOnly + spacing SVGTextPathElementImpl::Spacing DontDelete|ReadOnly +@end +*/ + +Value SVGTextPathElementImpl::getValueProperty(ExecState *exec, int token) const +{ + KSVG_CHECK_ATTRIBUTE + + switch(token) + { + case StartOffset: + if(!attributeMode) + return m_startOffset->cache(exec); + else + return Number(m_startOffset->baseVal()->value()); + case Method: + if(!attributeMode) + return m_method->cache(exec); + else + return Number(m_method->baseVal()); + case Spacing: + if(!attributeMode) + return m_spacing->cache(exec); + else + return Number(m_spacing->baseVal()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGTextPathElementImpl::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; + + switch(token) + { + case StartOffset: + { + QString param = value.toString(exec).qstring(); + + if(param.endsWith("%")) + { + QString value = param.left(param.length() - 1); + bool ok = false; + double dValue = value.toDouble(&ok); + if(ok) + startOffset()->baseVal()->setValue(dValue / 100.0); + else + kdDebug() << "Couldn't parse startOffset: " << value << endl; + } + else + startOffset()->baseVal()->setValueAsString(value.toString(exec).qstring()); + + if(startOffset()->baseVal()->value() < 0) // A negative value is an error + gotError(i18n("Negative value for attribute startOffset of element <textPath> is illegal")); + break; + } + case Method: + { + QString param = value.toString(exec).qstring(); + + if(param == "align") + method()->setBaseVal(TEXTPATH_METHODTYPE_ALIGN); + else if(param == "stretch") + method()->setBaseVal(TEXTPATH_METHODTYPE_STRETCH); + else + method()->setBaseVal(TEXTPATH_METHODTYPE_UNKNOWN); + + break; + } + case Spacing: + { + QString param = value.toString(exec).qstring(); + + if(param == "auto") + spacing()->setBaseVal(TEXTPATH_SPACINGTYPE_AUTO); + else if(param == "exact") + spacing()->setBaseVal(TEXTPATH_SPACINGTYPE_EXACT); + else + spacing()->setBaseVal(TEXTPATH_SPACINGTYPE_UNKNOWN); + + break; + } + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// CONSTANTS + +/* +@namespace KSVG +@begin SVGTextPathElementImplConstructor::s_hashTable 7 + TEXTPATH_METHODTYPE_UNKNOWN KSVG::TEXTPATH_METHODTYPE_UNKNOWN DontDelete|ReadOnly + TEXTPATH_METHODTYPE_ALIGN KSVG::TEXTPATH_METHODTYPE_ALIGN DontDelete|ReadOnly + TEXTPATH_METHODTYPE_STRETCH KSVG::TEXTPATH_METHODTYPE_STRETCH DontDelete|ReadOnly + TEXTPATH_SPACINGTYPE_UNKNOWN KSVG::TEXTPATH_SPACINGTYPE_UNKNOWN DontDelete|ReadOnly + TEXTPATH_SPACINGTYPE_AUTO KSVG::TEXTPATH_SPACINGTYPE_AUTO DontDelete|ReadOnly + TEXTPATH_SPACINGTYPE_EXACT KSVG::TEXTPATH_SPACINGTYPE_EXACT DontDelete|ReadOnly +@end +*/ + +using namespace KJS; + +Value SVGTextPathElementImplConstructor::getValueProperty(ExecState *, int token) const +{ + return Number(token); +} + +Value KSVG::getSVGTextPathElementImplConstructor(ExecState *exec) +{ + return cacheGlobalBridge<SVGTextPathElementImplConstructor>(exec, "[[svgtextpathelement.constructor]]"); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTextPathElementImpl.h b/ksvg/impl/SVGTextPathElementImpl.h new file mode 100644 index 00000000..8231f0cd --- /dev/null +++ b/ksvg/impl/SVGTextPathElementImpl.h @@ -0,0 +1,84 @@ +/* + 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. +*/ + +#ifndef SVGTextPathElementImpl_H +#define SVGTextPathElementImpl_H + +#include "SVGURIReferenceImpl.h" +#include "SVGTextContentElementImpl.h" + +namespace KSVG +{ + +class SVGTextPathElementImpl : public SVGTextContentElementImpl, + public SVGURIReferenceImpl +{ +public: + SVGTextPathElementImpl(DOM::ElementImpl *); + virtual ~SVGTextPathElementImpl(); + + QString text(); + + SVGAnimatedLengthImpl *startOffset() const; + SVGAnimatedEnumerationImpl *method() const; + SVGAnimatedEnumerationImpl *spacing() const; + + virtual void setAttributes(); + virtual T2P::GlyphLayoutParams *layoutParams() const; + +private: + SVGAnimatedLengthImpl *m_startOffset; + SVGAnimatedEnumerationImpl *m_method; + SVGAnimatedEnumerationImpl *m_spacing; + +public: + KSVG_GET + KSVG_PUT + KSVG_BRIDGE + + enum + { + // Properties + StartOffset, Method, Spacing + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +class SVGTextPathElementImplConstructor : public KJS::ObjectImp +{ +public: + SVGTextPathElementImplConstructor(KJS::ExecState *) { } + KJS::Value getValueProperty(KJS::ExecState *, int token) const; + + // no put - all read-only + KSVG_GET +}; + +KJS::Value getSVGTextPathElementImplConstructor(KJS::ExecState *exec); + +KSVG_REGISTER_ELEMENT(SVGTextPathElementImpl, "textPath") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTextPositioningElementImpl.cc b/ksvg/impl/SVGTextPositioningElementImpl.cc new file mode 100644 index 00000000..924fd091 --- /dev/null +++ b/ksvg/impl/SVGTextPositioningElementImpl.cc @@ -0,0 +1,198 @@ +/* + 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> + +#include "SVGHelperImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGAnimatedLengthListImpl.h" +#include "SVGAnimatedNumberListImpl.h" +#include "SVGTextPositioningElementImpl.h" + +using namespace KSVG; + +#include "SVGTextPositioningElementImpl.lut.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" + +SVGTextPositioningElementImpl::SVGTextPositioningElementImpl(DOM::ElementImpl *impl) : SVGTextContentElementImpl(impl) +{ + KSVG_EMPTY_FLAGS + + m_x = new SVGAnimatedLengthListImpl(); + m_x->ref(); + + m_y = new SVGAnimatedLengthListImpl(); + m_y->ref(); + + m_dx = new SVGAnimatedLengthListImpl(); + m_dx->ref(); + + m_dy = new SVGAnimatedLengthListImpl(); + m_dy->ref(); + + m_rotate = new SVGAnimatedNumberListImpl(); + m_rotate->ref(); +} + +SVGTextPositioningElementImpl::~SVGTextPositioningElementImpl() +{ + if(m_x) + m_x->deref(); + if(m_y) + m_y->deref(); + if(m_dx) + m_dx->deref(); + if(m_dy) + m_dy->deref(); + if(m_rotate) + m_rotate->deref(); +} + +SVGAnimatedLengthListImpl *SVGTextPositioningElementImpl::x() +{ + return m_x; +} + +SVGAnimatedLengthListImpl *SVGTextPositioningElementImpl::y() +{ + return m_y; +} + +SVGAnimatedLengthListImpl *SVGTextPositioningElementImpl::dx() +{ + return m_dx; +} + +SVGAnimatedLengthListImpl *SVGTextPositioningElementImpl::dy() +{ + return m_dy; +} + +SVGAnimatedNumberListImpl *SVGTextPositioningElementImpl::rotate() +{ + return m_rotate; +} + +/* +@namespace KSVG +@begin SVGTextPositioningElementImpl::s_hashTable 7 + x SVGTextPositioningElementImpl::X DontDelete|ReadOnly + y SVGTextPositioningElementImpl::Y DontDelete|ReadOnly + dx SVGTextPositioningElementImpl::Dx DontDelete|ReadOnly + dy SVGTextPositioningElementImpl::Dy DontDelete|ReadOnly + rotate SVGTextPositioningElementImpl::Rotate DontDelete|ReadOnly +@end +*/ + +Value SVGTextPositioningElementImpl::getValueProperty(ExecState *exec, int token) const +{ + KSVG_CHECK_ATTRIBUTE + + switch(token) + { + case X: + if(!attributeMode) + return m_x->cache(exec); + else + return Number(m_x->baseVal()->getItem(0)->value()); + case Y: + if(!attributeMode) + return m_y->cache(exec); + else + return Number(m_y->baseVal()->getItem(0)->value()); + case Dx: + if(!attributeMode) + return m_dx->cache(exec); + else + return Number(m_dx->baseVal()->getItem(0)->value()); + case Dy: + if(!attributeMode) + return m_dy->cache(exec); + else + return Number(m_dy->baseVal()->getItem(0)->value()); + case Rotate: + if(!attributeMode) + return m_rotate->cache(exec); + else + return Number(m_rotate->baseVal()->getItem(0)->value()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGTextPositioningElementImpl::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; + + switch(token) + { + case X: + x()->baseVal()->clear(); + SVGHelperImpl::parseLengthList(x(), value.toString(exec).qstring(), LENGTHMODE_WIDTH, this); + break; + case Y: + y()->baseVal()->clear(); + SVGHelperImpl::parseLengthList(y(), value.toString(exec).qstring(), LENGTHMODE_HEIGHT, this); + break; + case Dx: + dx()->baseVal()->clear(); + SVGHelperImpl::parseLengthList(dx(), value.toString(exec).qstring(), LENGTHMODE_WIDTH, this); + break; + case Dy: + dy()->baseVal()->clear(); + SVGHelperImpl::parseLengthList(dy(), value.toString(exec).qstring(), LENGTHMODE_HEIGHT, this); + break; + case Rotate: + { + rotate()->baseVal()->clear(); + + SVGNumberImpl *number = SVGSVGElementImpl::createSVGNumber(); + number->setValue(value.toNumber(exec)); + rotate()->baseVal()->appendItem(number); + break; + } + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +void SVGTextPositioningElementImpl::setAttributes() +{ + SVGElementImpl::setAttributes(); + + if(tagName() != "text") + return; + + // Spec: If the attribute is not specified, the effect is as if a value of "0" were specified. + if(KSVG_TOKEN_NOT_PARSED(X)) + KSVG_SET_ALT_ATTRIBUTE(X, "0") + + // Spec: If the attribute is not specified, the effect is as if a value of "0" were specified. + if(KSVG_TOKEN_NOT_PARSED(Y)) + KSVG_SET_ALT_ATTRIBUTE(Y, "0") +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTextPositioningElementImpl.h b/ksvg/impl/SVGTextPositioningElementImpl.h new file mode 100644 index 00000000..c80b48ff --- /dev/null +++ b/ksvg/impl/SVGTextPositioningElementImpl.h @@ -0,0 +1,83 @@ +/* + 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. +*/ + +#ifndef SVGTextPositioningElementImpl_H +#define SVGTextPositioningElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGTextContentElementImpl.h" + +namespace KJS +{ + class Value; + class Object; + class UString; + class ExecState; +} + +namespace KSVG +{ + +class SVGShapeImpl; +class GlyphLayoutParams; +class SVGAnimatedLengthListImpl; +class SVGAnimatedNumberListImpl; + +class SVGTextPositioningElementImpl : public SVGTextContentElementImpl +{ +public: + SVGTextPositioningElementImpl(DOM::ElementImpl *impl); + virtual ~SVGTextPositioningElementImpl(); + + SVGAnimatedLengthListImpl *x(); + SVGAnimatedLengthListImpl *y(); + SVGAnimatedLengthListImpl *dx(); + SVGAnimatedLengthListImpl *dy(); + SVGAnimatedNumberListImpl *rotate(); + + virtual void setAttributes(); + +private: + SVGAnimatedLengthListImpl *m_x; + SVGAnimatedLengthListImpl *m_y; + SVGAnimatedLengthListImpl *m_dx; + SVGAnimatedLengthListImpl *m_dy; + SVGAnimatedNumberListImpl *m_rotate; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + X, Y, Dx, Dy, Rotate + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTimeScheduler.cc b/ksvg/impl/SVGTimeScheduler.cc new file mode 100644 index 00000000..efff77ac --- /dev/null +++ b/ksvg/impl/SVGTimeScheduler.cc @@ -0,0 +1,234 @@ +/* + Copyright (C) 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 "KSVGCanvas.h" +#include "CanvasItem.h" +#include "SVGShapeImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGTimeScheduler.moc" + +using namespace KSVG; + +SVGTimer::SVGTimer(QObject *scheduler, unsigned int ms, bool singleShot) +{ + m_ms = ms; + m_singleShot = singleShot; + m_timer = new QTimer(scheduler); +} + +SVGTimer::~SVGTimer() +{ + delete m_timer; +} + +bool SVGTimer::operator==(const QTimer *timer) +{ + return (m_timer == timer); +} + +const QTimer *SVGTimer::qtimer() const +{ + return m_timer; +} + +void SVGTimer::start(QObject *receiver, const char *member) +{ + QObject::connect(m_timer, SIGNAL(timeout()), receiver, member); + m_timer->start(m_ms, m_singleShot); +} + +void SVGTimer::stop() +{ + m_timer->stop(); +} + +bool SVGTimer::isActive() const +{ + return m_timer->isActive(); +} + +unsigned int SVGTimer::ms() const +{ + return m_ms; +} + +bool SVGTimer::singleShot() const +{ + return m_singleShot; +} + +void SVGTimer::notifyAll() +{ + if(m_notifyList.isEmpty()) + return; + + QValueList<SVGElementImpl *> elements; + for(unsigned int i = m_notifyList.count();i > 0; i--) + { + SVGElementImpl *element = m_notifyList[i - 1]; + if(!element) + continue; + + SVGAnimationElementImpl *animation = dynamic_cast<SVGAnimationElementImpl *>(element); + if(animation) + { + animation->handleTimerEvent(); + + SVGElementImpl *target = animation->targetElement(); + if(!elements.contains(target)) + elements.append(target); + } + } + + // Optimized update logic (to avoid 4 updates, on the same element) + QValueList<SVGElementImpl *>::iterator it2; + for(it2 = elements.begin(); it2 != elements.end(); ++it2) + { + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(*it2); + if(shape && shape->item()) + shape->item()->update(UPDATE_TRANSFORM); + } +} + +void SVGTimer::addNotify(SVGElementImpl *element) +{ + m_notifyList.append(element); +} + +void SVGTimer::removeNotify(SVGElementImpl *element) +{ + m_notifyList.remove(element); + + if(m_notifyList.isEmpty()) + stop(); +} + +const unsigned int SVGTimeScheduler::staticTimerInterval = 15; // milliseconds + +SVGTimeScheduler::SVGTimeScheduler(SVGDocumentImpl *doc) : QObject(), m_doc(doc) +{ + // Create static interval timers but don't start it yet! + m_intervalTimer = new SVGTimer(this, staticTimerInterval, false); + m_creationTime.start(); +} + +SVGTimeScheduler::~SVGTimeScheduler() +{ + // Usually singleShot timers cleanup themselves, after usage + SVGTimerList::iterator it; + for(it = m_timerList.begin(); it != m_timerList.end(); ++it) + { + SVGTimer *svgTimer = *it; + delete svgTimer; + } + delete m_intervalTimer; +} + +void SVGTimeScheduler::addTimer(SVGElementImpl *element, unsigned int ms) +{ + SVGTimer *svgTimer = new SVGTimer(this, ms, true); + svgTimer->addNotify(element); + m_timerList.append(svgTimer); +} + +void SVGTimeScheduler::connectIntervalTimer(SVGElementImpl *element) +{ + m_intervalTimer->addNotify(element); +} + +void SVGTimeScheduler::disconnectIntervalTimer(SVGElementImpl *element) +{ + m_intervalTimer->removeNotify(element); +} + +void SVGTimeScheduler::startAnimations() +{ + SVGTimerList::iterator it; + for(it = m_timerList.begin(); it != m_timerList.end(); ++it) + { + SVGTimer *svgTimer = *it; + if(svgTimer && !svgTimer->isActive()) + svgTimer->start(this, SLOT(slotTimerNotify())); + } +} + +void SVGTimeScheduler::toggleAnimations() +{ + if(m_intervalTimer->isActive()) + m_intervalTimer->stop(); + else + m_intervalTimer->start(this, SLOT(slotTimerNotify())); +} + +bool SVGTimeScheduler::animationsPaused() const +{ + return !m_intervalTimer->isActive(); +} + +void SVGTimeScheduler::slotTimerNotify() +{ + QTimer *senderTimer = const_cast<QTimer *>(static_cast<const QTimer *>(sender())); + + SVGTimer *svgTimer = 0; + SVGTimerList::iterator it; + for(it = m_timerList.begin(); it != m_timerList.end(); ++it) + { + SVGTimer *cur = *it; + if(*cur == senderTimer) + { + svgTimer = cur; + break; + } + } + + if(!svgTimer) + { + svgTimer = (*m_intervalTimer == senderTimer) ? m_intervalTimer : 0; + + if(!svgTimer) + return; + } + + svgTimer->notifyAll(); + + // Animations need direct updates + if(m_doc->canvas()) + m_doc->canvas()->update(); + emit m_doc->finishedRendering(); + + if(svgTimer->singleShot()) + { + m_timerList.remove(svgTimer); + delete svgTimer; + } + + // The singleShot timers of ie. <animate> with begin="3s" are notified + // by the previous call, and now all connections to the interval timer + // are created and now we just need to fire that timer (Niko) + if(svgTimer != m_intervalTimer && !m_intervalTimer->isActive()) + m_intervalTimer->start(this, SLOT(slotTimerNotify())); +} + +float SVGTimeScheduler::elapsed() const +{ + return float(m_creationTime.elapsed()) / 1000.0; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTimeScheduler.h b/ksvg/impl/SVGTimeScheduler.h new file mode 100644 index 00000000..ae4c6d37 --- /dev/null +++ b/ksvg/impl/SVGTimeScheduler.h @@ -0,0 +1,104 @@ +/* + Copyright (C) 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. +*/ + +#ifndef SVGTimeScheduler_H +#define SVGTimeScheduler_H + +#include <qtimer.h> +#include <qdatetime.h> +#include <qobject.h> +#include <qvaluelist.h> + +#include "SVGElementImpl.h" +#include "SVGAnimationElementImpl.h" + +namespace KSVG +{ + +typedef QValueList<SVGElementImpl *> SVGNotifyList; +class SVGTimer +{ +public: + SVGTimer(QObject *scheduler, unsigned int ms, bool singleShot); + ~SVGTimer(); + + bool operator==(const QTimer *timer); + const QTimer *qtimer() const; + + void start(QObject *receiver, const char *member); + void stop(); + + bool isActive() const; + + unsigned int ms() const; + bool singleShot() const; + + void notifyAll(); + void addNotify(SVGElementImpl *element); + void removeNotify(SVGElementImpl *element); + +private: + unsigned int m_ms; + bool m_invoked, m_singleShot; + + QTimer *m_timer; + SVGNotifyList m_notifyList; +}; + +typedef QValueList<SVGTimer *> SVGTimerList; +class SVGDocumentImpl; +class SVGTimeScheduler : public QObject +{ +Q_OBJECT +public: + SVGTimeScheduler(SVGDocumentImpl *doc); + ~SVGTimeScheduler(); + + // Adds singleShot Timers + void addTimer(SVGElementImpl *element, unsigned int ms); + + // (Dis-)Connects to interval timer with ms = 'staticTimerInterval' + void connectIntervalTimer(SVGElementImpl *element); + void disconnectIntervalTimer(SVGElementImpl *element); + + void startAnimations(); + void toggleAnimations(); + bool animationsPaused() const; + + // time elapsed in seconds after creation of this object + float elapsed() const; + + static const unsigned int staticTimerInterval; + +private slots: + void slotTimerNotify(); + +private: + SVGDocumentImpl *m_doc; + SVGTimerList m_timerList; + SVGTimer *m_intervalTimer; + QTime m_creationTime; +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTitleElementImpl.cc b/ksvg/impl/SVGTitleElementImpl.cc new file mode 100644 index 00000000..5bfe2936 --- /dev/null +++ b/ksvg/impl/SVGTitleElementImpl.cc @@ -0,0 +1,39 @@ +/* + 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 "SVGDocumentImpl.h" +#include "SVGTitleElementImpl.h" + +using namespace KSVG; + +SVGTitleElementImpl::SVGTitleElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGLangSpaceImpl(), SVGStylableImpl(this) +{ +} + +SVGTitleElementImpl::~SVGTitleElementImpl() +{ +} + +void SVGTitleElementImpl::createItem(KSVGCanvas *) +{ + emit ownerDoc()->gotTitle(collectText()); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTitleElementImpl.h b/ksvg/impl/SVGTitleElementImpl.h new file mode 100644 index 00000000..7c948842 --- /dev/null +++ b/ksvg/impl/SVGTitleElementImpl.h @@ -0,0 +1,55 @@ +/* + 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. +*/ + +#ifndef SVGTitleElementImpl_H +#define SVGTitleElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGElementImpl.h" +#include "SVGStylableImpl.h" +#include "SVGLangSpaceImpl.h" + +namespace KSVG +{ + +class SVGTitleElementImpl : public SVGElementImpl, + public SVGLangSpaceImpl, + public SVGStylableImpl +{ +public: + SVGTitleElementImpl(DOM::ElementImpl *); + virtual ~SVGTitleElementImpl(); + + virtual void createItem(KSVGCanvas *c = 0); + +public: + KSVG_BRIDGE + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +KSVG_REGISTER_ELEMENT(SVGTitleElementImpl, "title") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTransformImpl.cc b/ksvg/impl/SVGTransformImpl.cc new file mode 100644 index 00000000..53ea9bf3 --- /dev/null +++ b/ksvg/impl/SVGTransformImpl.cc @@ -0,0 +1,240 @@ +/* + 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> + +#include "SVGTransform.h" + +#include "SVGMatrixImpl.h" +#include "SVGTransformImpl.h" +#include "SVGSVGElementImpl.h" + +using namespace KSVG; + +#include "SVGTransformImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_cacheimpl.h" + +SVGTransformImpl::SVGTransformImpl() +{ + m_matrix = SVGSVGElementImpl::createSVGMatrix(); + + m_type = SVG_TRANSFORM_UNKNOWN; + m_angle = 0; +} + +SVGTransformImpl::~SVGTransformImpl() +{ + if(m_matrix) + m_matrix->deref(); +} + +unsigned short SVGTransformImpl::type() const +{ + return m_type; +} + +SVGMatrixImpl *SVGTransformImpl::matrix() const +{ + return m_matrix; +} + +double SVGTransformImpl::angle() const +{ + return m_angle; +} + +void SVGTransformImpl::setMatrix(SVGMatrixImpl *matrix) +{ + if(!matrix) + return; + + m_type = SVG_TRANSFORM_MATRIX; + m_angle = 0; + + m_matrix->deref(); + m_matrix = matrix; + m_matrix->ref(); +} + +void SVGTransformImpl::setTranslate(double tx, double ty) +{ + m_type = SVG_TRANSFORM_TRANSLATE; + m_angle = 0; + m_matrix->reset(); + m_matrix->translate(tx, ty); +} + +void SVGTransformImpl::setScale(double sx, double sy) +{ + m_type = SVG_TRANSFORM_SCALE; + m_angle = 0; + m_matrix->reset(); + m_matrix->scaleNonUniform(sx, sy); +} + +void SVGTransformImpl::setRotate(double angle, double cx, double cy) +{ + m_type = SVG_TRANSFORM_ROTATE; + // mop: evil...fix that...needed to make toString() work correctly + m_cx = cx; + m_cy = cy; + m_angle = angle; + m_matrix->reset(); + m_matrix->translate(cx, cy); + m_matrix->rotate(angle); + m_matrix->translate(-cx, -cy); +} + +void SVGTransformImpl::setSkewX(double angle) +{ + m_type = SVG_TRANSFORM_SKEWX; + m_angle = angle; + m_matrix->reset(); + m_matrix->skewX(angle); +} + +void SVGTransformImpl::setSkewY(double angle) +{ + m_type = SVG_TRANSFORM_SKEWY; + m_angle = angle; + m_matrix->reset(); + m_matrix->skewY(angle); +} + +QString SVGTransformImpl::toString() const +{ + switch (m_type) + { + case SVG_TRANSFORM_UNKNOWN: + return QString(); + case SVG_TRANSFORM_MATRIX: + return QString("matrix(" + QString::number(m_matrix->a()) + " " + QString::number(m_matrix->b()) + " " + QString::number(m_matrix->c()) + " " + QString::number(m_matrix->d()) + " " + QString::number(m_matrix->e()) + " " + QString::number(m_matrix->f()) + ")"); + case SVG_TRANSFORM_TRANSLATE: + return QString("translate(" + QString::number(m_matrix->e()) + " " + QString::number(m_matrix->f()) + ")"); + case SVG_TRANSFORM_SCALE: + return QString("scale(" + QString::number(m_matrix->a()) + " " + QString::number(m_matrix->d()) + ")"); + case SVG_TRANSFORM_ROTATE: + return QString("rotate(" + QString::number(m_angle) + " " + QString::number(m_cx) + " " + QString::number(m_cy) + ")"); + case SVG_TRANSFORM_SKEWX: + return QString("skewX(" + QString::number(m_angle) + ")"); + case SVG_TRANSFORM_SKEWY: + return QString("skewY(" + QString::number(m_angle) + ")"); + default: + kdWarning() << "Unknown transform type " << m_type << endl; + return QString(); + } +} + +// ECMA binding + +/* +@namespace KSVG +@begin SVGTransformImpl::s_hashTable 5 + type SVGTransformImpl::Type DontDelete|ReadOnly + matrix SVGTransformImpl::Matrix DontDelete|ReadOnly + angle SVGTransformImpl::Angle DontDelete|ReadOnly +@end +@namespace KSVG +@begin SVGTransformImplProto::s_hashTable 7 + setMatrix SVGTransformImpl::SetMatrix DontDelete|Function 1 + setTranslate SVGTransformImpl::SetTranslate DontDelete|Function 2 + setScale SVGTransformImpl::SetScale DontDelete|Function 2 + setRotate SVGTransformImpl::SetRotate DontDelete|Function 3 + setSkewX SVGTransformImpl::SetSkewX DontDelete|Function 1 + setSkewY SVGTransformImpl::SetSkewY DontDelete|Function 1 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGTransform", SVGTransformImplProto, SVGTransformImplProtoFunc) + +Value SVGTransformImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case Type: + return Number(m_type); + case Matrix: + return m_matrix->cache(exec); + case Angle: + return Number(m_angle); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +Value SVGTransformImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGTransformImpl) + + switch(id) + { + case SVGTransformImpl::SetMatrix: + obj->setMatrix(static_cast<KSVGBridge<SVGMatrixImpl> *>(args[0].imp())->impl()); + break; + case SVGTransformImpl::SetTranslate: + obj->setTranslate(args[0].toNumber(exec), args[1].toNumber(exec)); + break; + case SVGTransformImpl::SetScale: + obj->setScale(args[0].toNumber(exec), args[1].toNumber(exec)); + break; + case SVGTransformImpl::SetRotate: + obj->setRotate(args[0].toNumber(exec), args[1].toNumber(exec), args[2].toNumber(exec)); + break; + case SVGTransformImpl::SetSkewX: + obj->setSkewX(args[0].toNumber(exec)); + break; + case SVGTransformImpl::SetSkewY: + obj->setSkewY(args[0].toNumber(exec)); + break; + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return Undefined(); +} + +/* +@namespace KSVG +@begin SVGTransformImplConstructor::s_hashTable 11 + SVG_TRANSFORM_UNKNOWN KSVG::SVG_TRANSFORM_UNKNOWN DontDelete|ReadOnly + SVG_TRANSFORM_MATRIX KSVG::SVG_TRANSFORM_MATRIX DontDelete|ReadOnly + SVG_TRANSFORM_TRANSLATE KSVG::SVG_TRANSFORM_TRANSLATE DontDelete|ReadOnly + SVG_TRANSFORM_SCALE KSVG::SVG_TRANSFORM_SCALE DontDelete|ReadOnly + SVG_TRANSFORM_ROTATE KSVG::SVG_TRANSFORM_ROTATE DontDelete|ReadOnly + SVG_TRANSFORM_SKEWX KSVG::SVG_TRANSFORM_SKEWX DontDelete|ReadOnly + SVG_TRANSFORM_SKEWY KSVG::SVG_TRANSFORM_SKEWY DontDelete|ReadOnly +@end +*/ + +Value SVGTransformImplConstructor::getValueProperty(ExecState *, int token) const +{ + return Number(token); +} + +Value KSVG::getSVGTransformImplConstructor(ExecState *exec) +{ + return cacheGlobalBridge<SVGTransformImplConstructor>(exec, "[[svgtransform.constructor]]"); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTransformImpl.h b/ksvg/impl/SVGTransformImpl.h new file mode 100644 index 00000000..69d71b8f --- /dev/null +++ b/ksvg/impl/SVGTransformImpl.h @@ -0,0 +1,99 @@ +/* + 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. +*/ + +#ifndef SVGTransformImpl_H +#define SVGTransformImpl_H + +#include <dom/dom_misc.h> +#include <dom/dom_string.h> + +#include "ksvg_lookup.h" + +class QString; + +namespace KSVG +{ + +class SVGMatrixImpl; +class SVGTransformImpl : public DOM::DomShared +{ +public: + SVGTransformImpl(); + virtual ~SVGTransformImpl(); + + unsigned short type() const; + + SVGMatrixImpl *matrix() const; + + double angle() const; + + void setMatrix(SVGMatrixImpl *); + void setTranslate(double, double); + void setScale(double, double); + void setRotate(double, double, double); + void setSkewX(double); + void setSkewY(double); + + QString toString() const; + +private: + // mop: we have to store the optional rotate stuff :( anyone with a better solution please fix that ;) + double m_cx; + double m_cy; + + unsigned short m_type; + SVGMatrixImpl *m_matrix; + double m_angle; + +public: + KSVG_GET + + enum + { + // Properties + Type, Matrix, Angle, + // Functions + SetMatrix, SetTranslate, SetScale, + SetRotate, SetSkewX, SetSkewY + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; +}; + +class SVGTransformImplConstructor : public KJS::ObjectImp +{ +public: + SVGTransformImplConstructor(KJS::ExecState *) { } + KJS::Value getValueProperty(KJS::ExecState *, int token) const; + + // no put - all read-only + KSVG_GET +}; + +KJS::Value getSVGTransformImplConstructor(KJS::ExecState *exec); + +} + +KSVG_DEFINE_PROTOTYPE(SVGTransformImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGTransformImplProtoFunc, SVGTransformImpl) + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTransformListImpl.cc b/ksvg/impl/SVGTransformListImpl.cc new file mode 100644 index 00000000..5ecc16b6 --- /dev/null +++ b/ksvg/impl/SVGTransformListImpl.cc @@ -0,0 +1,103 @@ +/* + 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> + +#include "SVGMatrixImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGTransformListImpl.h" + +using namespace KSVG; + +#include "SVGTransformListImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGTransformListImpl::s_hashTable 2 + numberOfItems SVGListDefs::NumberOfItems DontDelete|ReadOnly +@end +@namespace KSVG +@begin SVGTransformListImplProto::s_hashTable 11 + getItem SVGListDefs::GetItem DontDelete|Function 1 + removeItem SVGListDefs::RemoveItem DontDelete|Function 1 + appendItem SVGListDefs::AppendItem DontDelete|Function 1 + initialize SVGListDefs::Initialize DontDelete|Function 1 + insertItemBefore SVGListDefs::InsertItemBefore DontDelete|Function 2 + replaceItem SVGListDefs::ReplaceItem DontDelete|Function 2 + clear SVGListDefs::Clear DontDelete|Function 0 +@end +*/ + +KSVG_IMPLEMENT_PROTOTYPE("SVGTransformList", SVGTransformListImplProto, SVGTransformListImplProtoFunc) + +Value SVGTransformListImpl::getValueProperty(ExecState *exec, int token) const +{ + return SVGList<SVGTransformImpl>::getValueProperty(exec, token); +} + +Value SVGTransformListImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGTransformListImpl) + + return obj->call(exec, static_cast<SVGList<SVGTransformImpl> *>(obj), args, id); +} + +SVGTransformImpl *SVGTransformListImpl::consolidate() +{ + SVGTransformImpl *trans = 0; + + if(numberOfItems()>0) + { + trans = SVGSVGElementImpl::createSVGTransform(); + SVGMatrixImpl *matrix = SVGSVGElementImpl::createSVGMatrix(); + + for(unsigned int i = 0; i < numberOfItems(); i++) + matrix->multiply(getItem(i)->matrix()); + + // Pedantic - sets type to MATRIX as per spec. + trans->setMatrix(matrix); + matrix->deref(); + initialize(trans); + trans->ref(); + } + + return trans; +} + +SVGMatrixImpl *SVGTransformListImpl::concatenate() const +{ + SVGMatrixImpl *matrix = 0; + + if(numberOfItems()>0) + { + matrix = SVGSVGElementImpl::createSVGMatrix(); + + for(unsigned int i = 0; i < numberOfItems(); i++) + matrix->multiply(getItem(i)->matrix()); + } + + return matrix; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTransformListImpl.h b/ksvg/impl/SVGTransformListImpl.h new file mode 100644 index 00000000..d59c6046 --- /dev/null +++ b/ksvg/impl/SVGTransformListImpl.h @@ -0,0 +1,53 @@ +/* + 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. +*/ + +#ifndef SVGTransformListImpl_H +#define SVGTransformListImpl_H + +#include "SVGList.h" + +#include "SVGTransformImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGTransformListImpl : public SVGList<SVGTransformImpl> +{ +public: + KSVG_GET + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + + SVGTransformImpl *consolidate(); + + // Concatenate the transforms. Returns 0 if list is empty + SVGMatrixImpl *concatenate() const; +}; + +} + +KSVG_DEFINE_PROTOTYPE(SVGTransformListImplProto) +KSVG_IMPLEMENT_PROTOFUNC(SVGTransformListImplProtoFunc, SVGTransformListImpl) + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTransformableImpl.cc b/ksvg/impl/SVGTransformableImpl.cc new file mode 100644 index 00000000..59dd904b --- /dev/null +++ b/ksvg/impl/SVGTransformableImpl.cc @@ -0,0 +1,169 @@ +/* + 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> + +#include "SVGMatrixImpl.h" +#include "SVGHelperImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGTransformableImpl.h" +#include "SVGTransformListImpl.h" +#include "SVGAnimatedTransformListImpl.h" +#include "SVGElementImpl.h" +#include "SVGDocumentImpl.h" + +using namespace KSVG; + +#include "SVGTransformableImpl.lut.h" +#include "ksvg_bridge.h" + +SVGTransformableImpl::SVGTransformableImpl() : SVGLocatableImpl() +{ + KSVG_EMPTY_FLAGS + + m_transform = new SVGAnimatedTransformListImpl(); + m_transform->ref(); + + m_localMatrix = 0; +} + +SVGTransformableImpl::SVGTransformableImpl(const SVGTransformableImpl &other) : SVGLocatableImpl() +{ + (*this) = other; +} + +SVGTransformableImpl::~SVGTransformableImpl() +{ + if(m_transform) + m_transform->deref(); + if(m_localMatrix) + m_localMatrix->deref(); +} + +SVGTransformableImpl &SVGTransformableImpl::operator=(const SVGTransformableImpl &other) +{ + SVGTransformListImpl *otherTransform = other.m_transform->baseVal(); + + // Concat computed values + for(unsigned int i = 0;i < otherTransform->numberOfItems(); i++) + { + SVGTransformImpl *trafo = otherTransform->getItem(i); + m_transform->baseVal()->insertItemBefore(SVGSVGElementImpl::createSVGTransformFromMatrix(trafo->matrix()), i); + } + + return *this; +} + +SVGAnimatedTransformListImpl *SVGTransformableImpl::transform() const +{ + return m_transform; +} + +SVGMatrixImpl *SVGTransformableImpl::getCTM() +{ + SVGMatrixImpl *ctm = SVGSVGElementImpl::createSVGMatrix(); + + SVGElementImpl *element = dynamic_cast<SVGElementImpl *>(this); + Q_ASSERT(element); + + DOM::Node parentNde = element->parentNode(); + + if(!parentNde.isNull() && parentNde.nodeType() != DOM::Node::DOCUMENT_NODE) + { + SVGElementImpl *parent = element->ownerDoc()->getElementFromHandle(parentNde.handle()); + SVGLocatableImpl *locatableParent = dynamic_cast<SVGLocatableImpl *>(parent); + + if(locatableParent) + { + SVGMatrixImpl *parentCTM = locatableParent->getCTM(); + ctm->multiply(parentCTM); + parentCTM->deref(); + } + } + + if(m_localMatrix) + { + ctm->multiply(m_localMatrix); + } + + return ctm; +} + +void SVGTransformableImpl::updateLocalMatrix() +{ + if(m_transform->baseVal()->numberOfItems()>0) + { + if(m_localMatrix) + m_localMatrix->deref(); + + m_localMatrix = m_transform->baseVal()->concatenate(); + } + else + { + if(m_localMatrix) + { + m_localMatrix->deref(); + m_localMatrix = 0; + } + } + + invalidateCachedMatrices(); +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGTransformableImpl::s_hashTable 2 + transform SVGTransformableImpl::Transform DontDelete +@end +*/ + +Value SVGTransformableImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case Transform: + return m_transform->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGTransformableImpl::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; + + switch(token) + { + case Transform: + SVGHelperImpl::parseTransformAttribute(m_transform->baseVal(), value.toString(exec).qstring()); + updateLocalMatrix(); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGTransformableImpl.h b/ksvg/impl/SVGTransformableImpl.h new file mode 100644 index 00000000..edff5831 --- /dev/null +++ b/ksvg/impl/SVGTransformableImpl.h @@ -0,0 +1,77 @@ +/* + 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. +*/ + +#ifndef SVGTransformableImpl_H +#define SVGTransformableImpl_H + +#include <qstring.h> + +#include "SVGLocatableImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGMatrixImpl; +class SVGAnimatedTransformListImpl; + +class SVGTransformableImpl : public SVGLocatableImpl +{ +public: + SVGTransformableImpl(); + SVGTransformableImpl(const SVGTransformableImpl &); + virtual ~SVGTransformableImpl(); + + SVGTransformableImpl &operator=(const SVGTransformableImpl &); + + SVGAnimatedTransformListImpl *transform() const; + + virtual SVGMatrixImpl *getCTM(); + + // The local transformations concatenated together. 0 if + // there are no local transformations. + virtual const SVGMatrixImpl *localMatrix() { return m_localMatrix; } + +private: + SVGAnimatedTransformListImpl *m_transform; + SVGMatrixImpl *m_localMatrix; + + void updateLocalMatrix(); + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + Transform + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGURIReferenceImpl.cc b/ksvg/impl/SVGURIReferenceImpl.cc new file mode 100644 index 00000000..a68b7442 --- /dev/null +++ b/ksvg/impl/SVGURIReferenceImpl.cc @@ -0,0 +1,135 @@ +/* + 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> + +#include "SVGURIReferenceImpl.h" +#include "SVGAnimatedStringImpl.h" + +using namespace KSVG; + +#include "SVGURIReferenceImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" + +SVGURIReferenceImpl::SVGURIReferenceImpl() +{ + KSVG_EMPTY_FLAGS + + m_href = new SVGAnimatedStringImpl(); + m_href->ref(); +} + +SVGURIReferenceImpl::~SVGURIReferenceImpl() +{ + if(m_href) + m_href->deref(); +} + +SVGAnimatedStringImpl *SVGURIReferenceImpl::href() const +{ + return m_href; +} + +bool SVGURIReferenceImpl::parseURIReference(const QString &urireference, QString &uri, QString &elementreference) +{ + int seperator = urireference.find("#"); + + if(seperator == -1) + return false; + + uri = urireference.left(seperator); + elementreference = urireference.mid(seperator + 1); + + return true; +} + +bool SVGURIReferenceImpl::isUrl(const QString &url) +{ + QString temp = url.stripWhiteSpace(); + return temp.startsWith("url(#") && temp.endsWith(")"); +} + +QString SVGURIReferenceImpl::getTarget(const QString &url) +{ + if(url.startsWith("url(")) // URI References, ie. fill:url(#target) + { + unsigned int start = url.find("#") + 1; + unsigned int end = url.findRev(")"); + + return url.mid(start, end - start); + } + else if(url.find("#") > -1) // format is #target + { + unsigned int start = url.find("#") + 1; + + return url.mid(start, url.length() - start); + } + else // Normal Reference, ie. style="color-profile:changeColor" + return url; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGURIReferenceImpl::s_hashTable 2 + href SVGURIReferenceImpl::Href DontDelete|ReadOnly +@end +*/ + +Value SVGURIReferenceImpl::getValueProperty(ExecState *exec, int token) const +{ + switch(token) + { + case Href: + return m_href->cache(exec); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGURIReferenceImpl::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; + + switch(token) + { + case Href: + { + if(m_href) + m_href->deref(); + + SVGAnimatedStringImpl *temp = new SVGAnimatedStringImpl(); + temp->ref(); + temp->setBaseVal(value.toString(exec).string()); + m_href = temp; + break; + } + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGURIReferenceImpl.h b/ksvg/impl/SVGURIReferenceImpl.h new file mode 100644 index 00000000..d6ee42c5 --- /dev/null +++ b/ksvg/impl/SVGURIReferenceImpl.h @@ -0,0 +1,64 @@ +/* + 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. +*/ + +#ifndef SVGURIReferenceImpl_H +#define SVGURIReferenceImpl_H + +#include "ksvg_lookup.h" + +class QString; + +namespace KSVG +{ + +class SVGAnimatedStringImpl; +class SVGURIReferenceImpl +{ +public: + SVGURIReferenceImpl(); + ~SVGURIReferenceImpl(); + + SVGAnimatedStringImpl *href() const; + static QString getTarget(const QString &url); + static bool isUrl(const QString &url); + static bool parseURIReference(const QString &urireference, QString &uri, QString &elementreference); + +protected: + SVGAnimatedStringImpl *m_href; + +public: + KSVG_GET + KSVG_PUT + + enum + { + // Properties + Href + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGUnitConverter.h b/ksvg/impl/SVGUnitConverter.h new file mode 100644 index 00000000..90c95796 --- /dev/null +++ b/ksvg/impl/SVGUnitConverter.h @@ -0,0 +1,100 @@ +/* + Copyright (C) 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. +*/ + +#ifndef SVGUnitConverter_H +#define SVGUnitConverter_H + +#include <qptrdict.h> + +#include <dom/dom_string.h> + +#include "SVGUnitTypes.h" +#include "SVGShapeImpl.h" +#include "SVGAnimatedLengthImpl.h" + +namespace KSVG +{ + +class SVGUnitConverter +{ +public: + SVGUnitConverter() { m_dict.setAutoDelete(true); } + ~SVGUnitConverter() { } + + void add(SVGAnimatedLengthImpl *obj) + { + UnitData *data = new UnitData(); + data->valueAsString = QString::null; + + m_dict.insert(obj, data); + } + + void modify(SVGAnimatedLengthImpl *obj, const QString &value) + { + UnitData *data = m_dict.find(obj); + + if(data) + data->valueAsString = value; + } + + void finalize(SVGShapeImpl *bboxContext, SVGShapeImpl *userContext, unsigned short unitType) + { + bool user = (unitType == SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE); + bool bbox = (unitType == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX); + + if(!user && !bbox) // Invalid unit type + return; + + QPtrDictIterator<UnitData> it(m_dict); + for(; it.current(); ++it) + { + UnitData *data = it.current(); + + if(!data) + continue; + + SVGAnimatedLengthImpl *obj = static_cast<SVGAnimatedLengthImpl *>(it.currentKey()); + + if(bbox) + obj->baseVal()->setBBoxContext(bboxContext); + else + obj->baseVal()->setBBoxContext(userContext); + + if(user) // Just assign value, no conversion needed! + obj->baseVal()->setValueAsString(data->valueAsString); + else // Convert to objectBoundingBox + obj->baseVal()->setValueAsString(SVGLengthImpl::convertValToPercentage(data->valueAsString)); + } + } + +private: + typedef struct + { + QString valueAsString; // Original value + } UnitData; + + QPtrDict<UnitData> m_dict; +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGUseElementImpl.cc b/ksvg/impl/SVGUseElementImpl.cc new file mode 100644 index 00000000..3bd38a42 --- /dev/null +++ b/ksvg/impl/SVGUseElementImpl.cc @@ -0,0 +1,409 @@ +/* + 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> + +#include <qstring.h> + +#include "KSVGLoader.h" +#include "KSVGCanvas.h" + +#include "SVGRectImpl.h" +#include "SVGEventImpl.h" +#include "SVGHelperImpl.h" +#include "SVGMatrixImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGTransformImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGUseElementImpl.h" +#include "SVGSymbolElementImpl.h" +#include "SVGTransformListImpl.h" +#include "SVGAnimatedStringImpl.h" +#include "SVGAnimatedLengthImpl.h" +#include "SVGElementInstanceImpl.h" +#include "SVGAnimatedTransformListImpl.h" + +using namespace KSVG; + +#include "SVGUseElementImpl.lut.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" + +SVGUseElementImpl::SVGUseElementImpl(DOM::ElementImpl *impl) : SVGShapeImpl(impl), SVGURIReferenceImpl(), SVGTestsImpl(), SVGLangSpaceImpl(), SVGExternalResourcesRequiredImpl(), SVGStylableImpl(this), SVGTransformableImpl() +{ + KSVG_EMPTY_FLAGS + + m_x = new SVGAnimatedLengthImpl(); + m_x->ref(); + + m_y = new SVGAnimatedLengthImpl(); + m_y->ref(); + + m_width = new SVGAnimatedLengthImpl(); + m_width->ref(); + + m_height = new SVGAnimatedLengthImpl(); + m_height->ref(); + + m_instanceRoot = 0; +} + +SVGUseElementImpl::~SVGUseElementImpl() +{ + if(m_x) + m_x->deref(); + if(m_y) + m_y->deref(); + if(m_width) + m_width->deref(); + if(m_height) + m_height->deref(); + if(m_instanceRoot) + m_instanceRoot->deref(); +} + +SVGAnimatedLengthImpl *SVGUseElementImpl::x() const +{ + return m_x; +} + +SVGAnimatedLengthImpl *SVGUseElementImpl::y() const +{ + return m_y; +} + +SVGAnimatedLengthImpl *SVGUseElementImpl::width() const +{ + return m_width; +} + +SVGAnimatedLengthImpl *SVGUseElementImpl::height() const +{ + return m_height; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGUseElementImpl::s_hashTable 11 + x SVGUseElementImpl::X DontDelete|ReadOnly + y SVGUseElementImpl::Y DontDelete|ReadOnly + width SVGUseElementImpl::Width DontDelete|ReadOnly + height SVGUseElementImpl::Height DontDelete|ReadOnly + href SVGUseElementImpl::Href DontDelete|ReadOnly + instanceRoot SVGUseElementImpl::InstanceRoot DontDelete|ReadOnly + animatedInstanceRoot SVGUseElementImpl::AnimatedInstanceRoot DontDelete|ReadOnly +@end +*/ + +Value SVGUseElementImpl::getValueProperty(ExecState *exec, int token) const +{ + KSVG_CHECK_ATTRIBUTE + + switch(token) + { + case X: + if(!attributeMode) + return m_x->cache(exec); + else + return Number(m_x->baseVal()->value()); + case Y: + if(!attributeMode) + return m_y->cache(exec); + else + return Number(m_y->baseVal()->value()); + case Width: + if(!attributeMode) + return m_width->cache(exec); + else + return Number(m_width->baseVal()->value()); + case Height: + if(!attributeMode) + return m_height->cache(exec); + else + return Number(m_height->baseVal()->value()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGUseElementImpl::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; + + switch(token) + { + case X: + x()->baseVal()->setValue(value.toNumber(exec)); + break; + case Y: + y()->baseVal()->setValue(value.toNumber(exec)); + break; + case Width: + width()->baseVal()->setValue(value.toNumber(exec)); + break; + case Height: + height()->baseVal()->setValue(value.toNumber(exec)); + break; + case Href: + { + QString url = value.toString(exec).qstring(); + href()->setBaseVal(SVGURIReferenceImpl::getTarget(url)); + break; + } + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +SVGRectImpl *SVGUseElementImpl::getBBox() +{ + if(m_instanceRoot) + { + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(m_instanceRoot->correspondingElement()); + if(KSVG_TOKEN_NOT_PARSED(Width) && KSVG_TOKEN_NOT_PARSED(Height) && shape) + return shape->getBBox(); + } + + SVGRectImpl *ret = new SVGRectImpl(); + ret->ref(); + ret->setX(m_x->baseVal()->value()); + ret->setY(m_y->baseVal()->value()); + ret->setWidth(m_width->baseVal()->value()); + ret->setHeight(m_height->baseVal()->value()); + return ret; +} + +SVGElementInstanceImpl *SVGUseElementImpl::instanceRoot() const +{ + return m_instanceRoot; +} + +SVGElementInstanceImpl *SVGUseElementImpl::animatedInstanceRoot() const +{ + return m_animatedInstanceRoot; +} + +void SVGUseElementImpl::createItem(KSVGCanvas *c) +{ + if(!m_instanceRoot) + { + // ownerSVGElement()->getElementById() is wrong here. + // It could reference elements from other documents when using getURL (Niko) + QString filename, id; + DOM::DOMString url = getAttribute("href"); + if(!SVGURIReferenceImpl::parseURIReference(url.string(), filename, id)) + return; + + SVGElementImpl *orig; + if(!filename.isEmpty()) + { + KURL fragmentUrl(ownerDoc()->baseUrl(), url.string()); + + id = fragmentUrl.ref(); + fragmentUrl.setRef(QString::null); + + orig = KSVGLoader::getSVGFragment(fragmentUrl, ownerDoc(), id); + } + else + { + orig = ownerDoc()->getElementByIdRecursive(ownerSVGElement(), href()->baseVal()); + + if(orig == 0) + { + // The document will try to create this item again once the parsing has finished. + ownerDoc()->addForwardReferencingUseElement(this); + } + } + + if(orig == 0) + return; + + setReferencedElement(orig); + + // Create a parent, a <g> + SVGElementImpl *parent = 0; + DOM::Element impl = static_cast<DOM::Document *>(ownerDoc())->createElement("g"); + parent = SVGDocumentImpl::createElement("g", impl, ownerDoc()); + SVGElementImpl *clone = orig->cloneNode(true); + + // Apply the use-correction + QString trans; + trans += " translate("; + trans += QString::number(x()->baseVal()->value()); + trans += " "; + trans += QString::number(y()->baseVal()->value()); + trans += ")"; + + // Apply the transform attribute and render the element + parent->setAttributeInternal("transform", trans); + parent->setAttribute("transform", trans); + + // Apply width/height if symbol + if(dynamic_cast<SVGSymbolElementImpl *>(clone)) + { + DOM::Element impl = static_cast<DOM::Document *>(ownerDoc())->createElement("svg"); + SVGElementImpl *symbolSvg = SVGDocumentImpl::createElement("svg", impl, ownerDoc()); + + SVGHelperImpl::copyAttributes(orig, symbolSvg); + + symbolSvg->setAttribute("width", getAttribute("width")); + symbolSvg->setAttributeInternal("width", getAttribute("width")); + symbolSvg->setAttribute("height", getAttribute("height")); + symbolSvg->setAttributeInternal("height", getAttribute("height")); + DOM::Node node = clone->firstChild(); + for(; !node.isNull(); node = clone->firstChild()) + symbolSvg->appendChild(node); + + clone = symbolSvg; + } + else if(dynamic_cast<SVGSVGElementImpl *>(clone)) + { + if(!getAttribute("width").isEmpty()) + { + clone->setAttribute("width", getAttribute("width")); + clone->setAttributeInternal("width", getAttribute("width")); + } + + if(!getAttribute("height").isEmpty()) + { + clone->setAttribute("height", getAttribute("height")); + clone->setAttributeInternal("height", getAttribute("height")); + } + } + + appendChild(*parent); + parent->appendChild(*clone); + + setupSubtree(parent, ownerSVGElement(), viewportElement()); + + m_instanceRoot->setCorrespondingElement(clone); + + dynamic_cast<SVGLocatableImpl *>(parent)->updateCachedScreenCTM(screenCTM()); + + // Redirect local ecma event handlers to the correspondingElement + QPtrListIterator<SVGRegisteredEventListener> it(eventListeners()); + SVGRegisteredEventListener *eventListener; + while((eventListener = it.current()) != 0) + { + ++it; + clone->setEventListener(eventListener->id, eventListener->listener); + } + } + + if(m_instanceRoot) + { + SVGElementImpl *element = m_instanceRoot->correspondingElement(); + element->createItem(c); + } +} + +void SVGUseElementImpl::removeItem(KSVGCanvas *c) +{ + if(m_instanceRoot) + { + SVGElementImpl *element = m_instanceRoot->correspondingElement(); + element->removeItem(c); + } +} + +void SVGUseElementImpl::setupSubtree(SVGElementImpl *element, SVGSVGElementImpl *ownerSVG, SVGElementImpl *viewport) +{ + element->setOwnerSVGElement(ownerSVG); + element->setViewportElement(viewport); + element->setAttributes(); + + SVGSVGElementImpl *thisSVG = dynamic_cast<SVGSVGElementImpl *>(element); + + if(thisSVG != 0) + { + ownerSVG = thisSVG; + viewport = element; + } + + DOM::Node child = element->firstChild(); + for(; !child.isNull(); child = child.nextSibling()) + { + SVGElementImpl *childElement = ownerDoc()->getElementFromHandle(child.handle()); + if(childElement != 0) + setupSubtree(childElement, ownerSVG, viewport); + } +} + +void SVGUseElementImpl::setReferencedElement(SVGElementImpl *referenced) +{ + if(!referenced) + return; + + if(!m_instanceRoot) + { + m_instanceRoot = new SVGElementInstanceImpl(); + m_instanceRoot->ref(); + } + + m_instanceRoot->setCorrespondingElement(referenced); +} + +void SVGUseElementImpl::update(CanvasItemUpdate reason, int param1, int param2) +{ + if(m_instanceRoot) + { + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(m_instanceRoot->correspondingElement()); + if(shape) + shape->update(reason, param1, param2); + } +} + +void SVGUseElementImpl::invalidate(KSVGCanvas *c, bool recalc) +{ + if(m_instanceRoot) + { + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(m_instanceRoot->correspondingElement()); + if(shape) + shape->invalidate(c, recalc); + } +} + +void SVGUseElementImpl::setReferenced(bool referenced) +{ + if(m_instanceRoot) + { + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(m_instanceRoot->correspondingElement()); + if(shape) + shape->setReferenced(referenced); + } +} + +void SVGUseElementImpl::draw() +{ + if(m_instanceRoot) + { + SVGShapeImpl *shape = dynamic_cast<SVGShapeImpl *>(m_instanceRoot->correspondingElement()); + if(shape) + shape->draw(); + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGUseElementImpl.h b/ksvg/impl/SVGUseElementImpl.h new file mode 100644 index 00000000..02eb8d88 --- /dev/null +++ b/ksvg/impl/SVGUseElementImpl.h @@ -0,0 +1,101 @@ +/* + 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. +*/ + +#ifndef SVGUseElementImpl_H +#define SVGUseElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGTestsImpl.h" +#include "SVGShapeImpl.h" +#include "SVGStylableImpl.h" +#include "SVGLangSpaceImpl.h" +#include "SVGURIReferenceImpl.h" +#include "SVGTransformableImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + +namespace KSVG +{ + +class SVGAnimatedLengthImpl; +class SVGElementInstanceImpl; +class SVGUseElementImpl : public SVGShapeImpl, + public SVGURIReferenceImpl, + public SVGTestsImpl, + public SVGLangSpaceImpl, + public SVGExternalResourcesRequiredImpl, + public SVGStylableImpl, + public SVGTransformableImpl +{ +public: + SVGUseElementImpl(DOM::ElementImpl *); + virtual ~SVGUseElementImpl(); + + SVGAnimatedLengthImpl *x() const; + SVGAnimatedLengthImpl *y() const; + SVGAnimatedLengthImpl *width() const; + SVGAnimatedLengthImpl *height() const; + + SVGElementInstanceImpl *instanceRoot() const; + SVGElementInstanceImpl *animatedInstanceRoot() const; + + virtual void createItem(KSVGCanvas *c); + virtual void removeItem(KSVGCanvas *c); + virtual void update(CanvasItemUpdate reason, int param1, int param2); + virtual void invalidate(KSVGCanvas *c, bool recalc); + virtual void setReferenced(bool referenced); + virtual void draw(); + + virtual SVGRectImpl *getBBox(); + + void setReferencedElement(SVGElementImpl *); + +private: + SVGAnimatedLengthImpl *m_x; + SVGAnimatedLengthImpl *m_y; + SVGAnimatedLengthImpl *m_width; + SVGAnimatedLengthImpl *m_height; + SVGElementInstanceImpl *m_instanceRoot; + SVGElementInstanceImpl *m_animatedInstanceRoot; + + void setupSubtree(SVGElementImpl *element, SVGSVGElementImpl *ownerSVG, SVGElementImpl *viewport); + +public: + KSVG_GET + KSVG_PUT + KSVG_BRIDGE + + enum + { + // Properties + X, Y, Width, Height, Href, InstanceRoot, AnimatedInstanceRoot + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +KSVG_REGISTER_ELEMENT(SVGUseElementImpl, "use") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGVKernElementImpl.cc b/ksvg/impl/SVGVKernElementImpl.cc new file mode 100644 index 00000000..b89d6e6f --- /dev/null +++ b/ksvg/impl/SVGVKernElementImpl.cc @@ -0,0 +1,33 @@ +/* + 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 "SVGVKernElementImpl.h" + +using namespace KSVG; + +SVGVKernElementImpl::SVGVKernElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl) +{ +} + +SVGVKernElementImpl::~SVGVKernElementImpl() +{ +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGVKernElementImpl.h b/ksvg/impl/SVGVKernElementImpl.h new file mode 100644 index 00000000..c8302c35 --- /dev/null +++ b/ksvg/impl/SVGVKernElementImpl.h @@ -0,0 +1,46 @@ +/* + 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. +*/ + +#ifndef SVGVKernElementImpl_H +#define SVGVKernElementImpl_H + +#include "ksvg_lookup.h" + +#include "SVGElementImpl.h" + +namespace KSVG +{ + +class SVGVKernElementImpl : public SVGElementImpl +{ +public: + SVGVKernElementImpl(DOM::ElementImpl *impl); + virtual ~SVGVKernElementImpl(); + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGViewElementImpl.cc b/ksvg/impl/SVGViewElementImpl.cc new file mode 100644 index 00000000..a051fba0 --- /dev/null +++ b/ksvg/impl/SVGViewElementImpl.cc @@ -0,0 +1,94 @@ +/* + 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> + +#include "SVGStringListImpl.h" +#include "SVGViewElementImpl.h" + +using namespace KSVG; + +#include "SVGViewElementImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_ecma.h" + +SVGViewElementImpl::SVGViewElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGExternalResourcesRequiredImpl(), SVGFitToViewBoxImpl(), SVGZoomAndPanImpl() +{ + KSVG_EMPTY_FLAGS + + m_viewTarget = new SVGStringListImpl(); + m_viewTarget->ref(); +} + +SVGViewElementImpl::~SVGViewElementImpl() +{ + if(m_viewTarget) + m_viewTarget->deref(); +} + +SVGStringListImpl *SVGViewElementImpl::viewTarget() const +{ + return m_viewTarget; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGViewElementImpl::s_hashTable 2 + viewTarget SVGViewElementImpl::ViewTarget DontDelete|ReadOnly +@end +*/ + +Value SVGViewElementImpl::getValueProperty(ExecState *, int token) const +{ + //KSVG_CHECK_ATTRIBUTE + + switch(token) + { + case ViewTarget: + // TODO + return Undefined(); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +void SVGViewElementImpl::putValueProperty(ExecState *, int token, const 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; + + switch(token) + { + case ViewTarget: + // TODO + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGViewElementImpl.h b/ksvg/impl/SVGViewElementImpl.h new file mode 100644 index 00000000..8b8d7e0b --- /dev/null +++ b/ksvg/impl/SVGViewElementImpl.h @@ -0,0 +1,70 @@ +/* + 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. +*/ + +#ifndef SVGViewElementImpl_H +#define SVGViewElementImpl_H + +#include "SVGElementImpl.h" +#include "SVGZoomAndPanImpl.h" +#include "SVGFitToViewBoxImpl.h" +#include "SVGExternalResourcesRequiredImpl.h" + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGStringListImpl; +class SVGViewElementImpl : public SVGElementImpl, + public SVGExternalResourcesRequiredImpl, + public SVGFitToViewBoxImpl, + public SVGZoomAndPanImpl +{ +public: + SVGViewElementImpl(DOM::ElementImpl *); + virtual ~SVGViewElementImpl(); + + SVGStringListImpl *viewTarget() const; + +private: + SVGStringListImpl *m_viewTarget; + +public: + KSVG_GET + KSVG_PUT + KSVG_BRIDGE + + enum + { + // Properties + ViewTarget + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +KSVG_REGISTER_ELEMENT(SVGViewElementImpl, "view") + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGViewSpecImpl.cc b/ksvg/impl/SVGViewSpecImpl.cc new file mode 100644 index 00000000..07412cc5 --- /dev/null +++ b/ksvg/impl/SVGViewSpecImpl.cc @@ -0,0 +1,98 @@ +/* + 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> + +#include <qstringlist.h> + +#include "SVGElementImpl.h" +#include "SVGViewSpecImpl.h" +#include "SVGTransformListImpl.h" + +using namespace KSVG; + +SVGViewSpecImpl::SVGViewSpecImpl() : SVGZoomAndPanImpl(), SVGFitToViewBoxImpl() +{ + m_transform = new SVGTransformListImpl(); + m_transform->ref(); + + m_viewTarget = new SVGElementImpl(0); + m_viewTarget->ref(); +} + +SVGViewSpecImpl::~SVGViewSpecImpl() +{ + if(m_transform) + m_transform->deref(); + if(m_viewTarget) + m_viewTarget->deref(); +} + +SVGTransformListImpl *SVGViewSpecImpl::transform() const +{ + return m_transform; +} + +SVGElementImpl *SVGViewSpecImpl::viewTarget() const +{ + return m_viewTarget; +} + +DOM::DOMString SVGViewSpecImpl::viewBoxString() const +{ + return m_viewBoxString; +} + +DOM::DOMString SVGViewSpecImpl::preserveAspectRatioString() const +{ + return m_preserveAspectRatioString; +} + +DOM::DOMString SVGViewSpecImpl::transformString() const +{ + return m_transformString; +} + +DOM::DOMString SVGViewSpecImpl::viewTargetString() const +{ + return m_viewTargetString; +} + +bool SVGViewSpecImpl::parseViewSpec(const QString &s) +{ + if(!s.startsWith("svgView(")) + return false; + + // remove 'svgView(' and ')' + QStringList subAttrs = QStringList::split(';', s.mid(8)); + + for(QStringList::ConstIterator it = subAttrs.begin() ; it != subAttrs.end(); ++it) + { + if((*it).startsWith("viewBox(")) + m_viewBoxString = (*it).mid(8); + else if((*it).startsWith("zoomAndPan(")) + parseZoomAndPan(DOM::DOMString((*it).mid(11))); + else if((*it).startsWith("preserveAspectRatio(")) + m_preserveAspectRatioString = (*it).mid(20); + } + return true; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGViewSpecImpl.h b/ksvg/impl/SVGViewSpecImpl.h new file mode 100644 index 00000000..f9e01e48 --- /dev/null +++ b/ksvg/impl/SVGViewSpecImpl.h @@ -0,0 +1,69 @@ +/* + 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. +*/ + +#ifndef SVGViewSpecImpl_H +#define SVGViewSpecImpl_H + +#include <dom/dom_string.h> +#include <dom/dom_misc.h> + +#include "ksvg_lookup.h" + +#include "SVGZoomAndPanImpl.h" +#include "SVGFitToViewBoxImpl.h" + +namespace KSVG +{ + +class SVGElementImpl; +class SVGTransformListImpl; +class SVGViewSpecImpl : public DOM::DomShared, public SVGZoomAndPanImpl, public SVGFitToViewBoxImpl +{ +public: + SVGViewSpecImpl(); + virtual ~SVGViewSpecImpl(); + + SVGTransformListImpl *transform() const; + SVGElementImpl *viewTarget() const; + DOM::DOMString viewBoxString() const; + DOM::DOMString preserveAspectRatioString() const; + DOM::DOMString transformString() const; + DOM::DOMString viewTargetString() const; + + bool parseViewSpec(const QString &); + +private: + SVGTransformListImpl *m_transform; + SVGElementImpl *m_viewTarget; + DOM::DOMString m_viewBoxString; + DOM::DOMString m_preserveAspectRatioString; + DOM::DOMString m_transformString; + DOM::DOMString m_viewTargetString; + +public: + KSVG_FORWARDGET + KSVG_FORWARDPUT +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGWindowImpl.cc b/ksvg/impl/SVGWindowImpl.cc new file mode 100644 index 00000000..b19847a4 --- /dev/null +++ b/ksvg/impl/SVGWindowImpl.cc @@ -0,0 +1,187 @@ +/* + 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 "SVGWindowImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGEvent.h" +#include "KSVGCanvas.h" +#include <ksvg_ecma.h> +#include <ksvg_scriptinterpreter.h> + +#include <qstylesheet.h> + +#include <kurl.h> +#include <kmessagebox.h> +#include <kinputdialog.h> +#include <klocale.h> + +using namespace KSVG; + + +SVGWindowImpl::SVGWindowImpl() +{ + m_document = 0; +} + +SVGWindowImpl::SVGWindowImpl(SVGDocumentImpl *doc) +{ + m_document = doc; + if(m_document) + m_document->ref(); +} + +SVGWindowImpl::~SVGWindowImpl() +{ + if(m_document) + m_document->deref(); +} + +/*StyleSheet SVGWindowImpl::defaultStyleSheet() const +{ + return m_defaultStyleSheet; +}*/ + +SVGDocumentImpl *SVGWindowImpl::document() const +{ + return m_document; +} + +DOM::Event SVGWindowImpl::evt() const +{ + return KSVG::SVGEvent(m_document->ecmaEngine()->interpreter()->currentEvent()); +} + +long SVGWindowImpl::innerHeight() const +{ + return m_document ? int(m_document->canvas()->height()) : -1; +} + +long SVGWindowImpl::innerWidth() const +{ + return m_document ? int(m_document->canvas()->width()) : -1; +} + +void SVGWindowImpl::setSrc(const DOM::DOMString &/*src*/) +{ + // TODO : make KURL, load and parse doc +} + +DOM::DOMString SVGWindowImpl::src() const +{ + if(!m_document) + return DOM::DOMString(); + return m_document->baseUrl().prettyURL(); +} + +void SVGWindowImpl::clearInterval(long /*interval*/) +{ +} + +void SVGWindowImpl::clearTimeout(long /*timeout*/) +{ +} + +void SVGWindowImpl::getURL(const DOM::DOMString &/*uri*/, const DOM::EventListener &/*callback*/) +{ +} + +/*DocumentFragment SVGWindowImpl::parseXML(const DOM::DOMString &source, const Document &document) +{ +}*/ + +void SVGWindowImpl::postURL(const DOM::DOMString &/*uri*/, const DOM::DOMString &/*data*/, const DOM::EventListener &/*callback*/, const DOM::DOMString &/*mimeType*/, const DOM::DOMString &/*contentEncoding*/) +{ +} + +DOM::DOMString SVGWindowImpl::printNode(const DOM::Node &node, unsigned short level) +{ + QString ret; + if(node.isNull()) return ret; + SVGElementImpl *elem = m_document->getElementFromHandle(node.handle()); + if(node.nodeType() == DOM::Node::DOCUMENT_NODE) + { + ret += "<\?xml version=\"1.0\" encoding=\"UTF-8\"\?><!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n" + printNode(node.firstChild()).string() + "\n"; + } + else if(node.nodeType() == DOM::Node::TEXT_NODE) + { + printIndentation(ret, level); + ret += node.nodeValue().string(); + } + else if(elem) + { + printIndentation(ret, level); + ret += "<" + elem->tagName().string(); + // handle attrs + QDictIterator<DOM::DOMString> it(elem->attributes()); + for(;it.current(); ++it) + ret += " " + it.currentKey() + "=\"" + it.current()->string() + '\"'; + if(elem->firstChild().isNull()) // no children + ret += " />\n"; + else // handle children + { + ret += ">\n"; + for(DOM::Node child = node.firstChild();!child.isNull();child = child.nextSibling()) + ret += printNode(child, level + 1).string(); + printIndentation(ret, level); + ret += "</" + elem->tagName().string() + ">\n"; + } + } + return ret; +} + +void SVGWindowImpl::printIndentation(QString &ret, unsigned short level, unsigned short indent) +{ + for(int i = 0;i < indent * level;i++) + ret += " "; +} + +long SVGWindowImpl::setInterval(const DOM::DOMString &/*code*/, const long &/*delay*/) +{ + return 0; +} + +long SVGWindowImpl::setTimeout(const DOM::DOMString &/*code*/, const long &/*delay*/) +{ + return 0; +} + +void SVGWindowImpl::alert(const DOM::DOMString &message, const QString &title) +{ + KMessageBox::error(0L, QStyleSheet::convertFromPlainText(message.string()), title); +} + +bool SVGWindowImpl::confirm(const DOM::DOMString &message, const QString &title) +{ + return KMessageBox::warningContinueCancel(0L, QStyleSheet::convertFromPlainText(message.string()), title, KStdGuiItem::ok()) == KMessageBox::Continue; +} + +DOM::DOMString SVGWindowImpl::prompt(const DOM::DOMString &message, const DOM::DOMString &_default, const QString &) +{ + bool ok; + QString str; + str = KInputDialog::getText(i18n("Prompt"), QStyleSheet::convertFromPlainText(message.string()), _default.string(), &ok); + if(ok) + return str; + else + return ""; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGWindowImpl.h b/ksvg/impl/SVGWindowImpl.h new file mode 100644 index 00000000..0861809e --- /dev/null +++ b/ksvg/impl/SVGWindowImpl.h @@ -0,0 +1,73 @@ +/* + 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. +*/ + +#ifndef SVGWindowImpl_H +#define SVGWindowImpl_H + +#include <dom/dom_string.h> +#include <dom/dom_node.h> +#include <dom/dom_misc.h> +#include <dom/dom2_events.h> + +namespace KSVG +{ +class SVGDocumentImpl; + +class SVGWindowImpl : public DOM::DomShared +{ +public: + SVGWindowImpl(); + SVGWindowImpl(SVGDocumentImpl *doc); + virtual ~SVGWindowImpl(); + + //StyleSheet defaultStyleSheet() const; + SVGDocumentImpl *document() const; + DOM::Event evt() const; + long innerHeight() const; + long innerWidth() const; + + void setSrc(const DOM::DOMString &src); + DOM::DOMString src() const; + + void clearInterval(long interval); + void clearTimeout(long timeout); + void getURL(const DOM::DOMString &uri, const DOM::EventListener &callback); + //DocumentFragment parseXML(const DOM::DOMString &source, const Document &document); + void postURL(const DOM::DOMString &uri, const DOM::DOMString &data, const DOM::EventListener &callback, const DOM::DOMString &mimeType, const DOM::DOMString &contentEncoding); + DOM::DOMString printNode(const DOM::Node &node, unsigned short level = 0); + long setInterval(const DOM::DOMString &code, const long &delay); + long setTimeout(const DOM::DOMString &code, const long &delay); + static void alert(const DOM::DOMString &message, const QString &title = "SVG Window"); + static bool confirm(const DOM::DOMString &message, const QString &title = "SVG Window"); + static DOM::DOMString prompt(const DOM::DOMString &message, const DOM::DOMString &_default, const QString &title = "SVG Window"); + +private: + void printIndentation(QString &ret, unsigned short level, unsigned short indent = 2); + +private: + //StyleSheet m_defaultStyleSheet; + SVGDocumentImpl *m_document; +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGZoomAndPanImpl.cc b/ksvg/impl/SVGZoomAndPanImpl.cc new file mode 100644 index 00000000..f3bf96ce --- /dev/null +++ b/ksvg/impl/SVGZoomAndPanImpl.cc @@ -0,0 +1,112 @@ +/* + 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> + +#include "SVGZoomAndPan.h" +#include "SVGZoomAndPanImpl.h" + +using namespace KSVG; + +#include "SVGZoomAndPanImpl.lut.h" +#include "ksvg_scriptinterpreter.h" +#include "ksvg_bridge.h" +#include "ksvg_cacheimpl.h" + +SVGZoomAndPanImpl::SVGZoomAndPanImpl() +{ + KSVG_EMPTY_FLAGS + + m_zoomAndPan = SVG_ZOOMANDPAN_MAGNIFY; +} + +SVGZoomAndPanImpl::~SVGZoomAndPanImpl() +{ +} + +void SVGZoomAndPanImpl::setZoomAndPan(unsigned short zoomAndPan) +{ + m_zoomAndPan = zoomAndPan; +} + +unsigned short SVGZoomAndPanImpl::zoomAndPan() const +{ + return m_zoomAndPan; +} + +void SVGZoomAndPanImpl::parseZoomAndPan(const DOM::DOMString &attr) +{ + if(attr == "disable") + m_zoomAndPan = SVG_ZOOMANDPAN_DISABLE; +} + +// Ecma stuff + +/* +@namespace KSVG +@begin SVGZoomAndPanImpl::s_hashTable 2 + zoomAndPan SVGZoomAndPanImpl::ZoomAndPan DontDelete +@end +*/ + +Value SVGZoomAndPanImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case ZoomAndPan: + return Number(zoomAndPan()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return KJS::Undefined(); + } +} + +void SVGZoomAndPanImpl::putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int) +{ + switch(token) + { + case ZoomAndPan: + parseZoomAndPan(value.toString(exec).string()); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} + +/* +@namespace KSVG +@begin SVGZoomAndPanImplConstructor::s_hashTable 5 + SVG_ZOOMANDPAN_UNKNOWN KSVG::SVG_ZOOMANDPAN_UNKNOWN DontDelete|ReadOnly + SVG_ZOOMANDPAN_DISABLE KSVG::SVG_ZOOMANDPAN_DISABLE DontDelete|ReadOnly + SVG_ZOOMANDPAN_MAGNIFY KSVG::SVG_ZOOMANDPAN_MAGNIFY DontDelete|ReadOnly +@end +*/ + +Value SVGZoomAndPanImplConstructor::getValueProperty(ExecState *, int token) const +{ + return Number(token); +} + +Value KSVG::getSVGZoomAndPanImplConstructor(ExecState *exec) +{ + return cacheGlobalBridge<SVGZoomAndPanImplConstructor>(exec, "[[svgzoomandpan.constructor]]"); +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGZoomAndPanImpl.h b/ksvg/impl/SVGZoomAndPanImpl.h new file mode 100644 index 00000000..ed7fef98 --- /dev/null +++ b/ksvg/impl/SVGZoomAndPanImpl.h @@ -0,0 +1,76 @@ +/* + 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. +*/ + +#ifndef SVGZoomAndPanImpl_H +#define SVGZoomAndPanImpl_H + +#include <dom/dom_misc.h> +#include <dom/dom_string.h> + +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGZoomAndPanImpl +{ +public: + SVGZoomAndPanImpl(); + virtual ~SVGZoomAndPanImpl(); + + void setZoomAndPan(unsigned short zoomAndPan); + unsigned short zoomAndPan() const; + + void parseZoomAndPan(const DOM::DOMString &attr); + +private: + unsigned short m_zoomAndPan; + +public: + KSVG_BASECLASS_GET + KSVG_PUT + + enum + { + // Properties + ZoomAndPan + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; + void putValueProperty(KJS::ExecState *exec, int token, const KJS::Value &value, int attr); +}; + +class SVGZoomAndPanImplConstructor : public KJS::ObjectImp +{ +public: + SVGZoomAndPanImplConstructor(KJS::ExecState *) { } + KJS::Value getValueProperty(KJS::ExecState *, int token) const; + + // no put - all read-only + KSVG_GET +}; + +KJS::Value getSVGZoomAndPanImplConstructor(KJS::ExecState *exec); + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGZoomEventImpl.cc b/ksvg/impl/SVGZoomEventImpl.cc new file mode 100644 index 00000000..448309f0 --- /dev/null +++ b/ksvg/impl/SVGZoomEventImpl.cc @@ -0,0 +1,111 @@ +/* + 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> +#include "SVGRectImpl.h" +#include "SVGPointImpl.h" +#include "SVGZoomEventImpl.h" + +using namespace KSVG; + +#include "SVGZoomEventImpl.lut.h" +#include "SVGSVGElementImpl.h" + +using namespace KJS; + +SVGZoomEventImpl::SVGZoomEventImpl(SVGEvent::EventId _id, + bool canBubbleArg, + bool cancelableArg, + DOM::AbstractView &viewArg, + long detailArg, + float previousScale, SVGPointImpl *previousTranslate, + float newScale, SVGPointImpl *newTranslate) +: SVGUIEventImpl(_id, canBubbleArg, cancelableArg, viewArg, detailArg), m_previousScale( previousScale ), m_newScale( newScale ) +{ + m_zoomRectScreen = SVGSVGElementImpl::createSVGRect(); + m_previousTranslate = previousTranslate; + if(m_previousTranslate) + m_previousTranslate->ref(); + m_newTranslate = newTranslate; + if(m_newTranslate) + m_newTranslate->ref(); +} + +SVGZoomEventImpl::~SVGZoomEventImpl() +{ + if(m_zoomRectScreen) + m_zoomRectScreen->deref(); + if(m_previousTranslate) + m_previousTranslate->deref(); + if(m_newTranslate) + m_newTranslate->deref(); +} + +SVGRectImpl *SVGZoomEventImpl::zoomRectScreen() const +{ + return m_zoomRectScreen; +} + +float SVGZoomEventImpl::previousScale() const +{ + return m_previousScale; +} + +SVGPointImpl *SVGZoomEventImpl::previousTranslate() const +{ + return m_previousTranslate; +} + +float SVGZoomEventImpl::newScale() const +{ + return m_newScale; +} + +SVGPointImpl *SVGZoomEventImpl::newTranslate() const +{ + return m_newTranslate; +} + +/* +@namespace KSVG +@begin SVGZoomEventImpl::s_hashTable 7 + zoomRectScreen SVGZoomEventImpl::ZoomRectScreen DontDelete|ReadOnly + previousScale SVGZoomEventImpl::PreviousScale DontDelete|ReadOnly + previousTranslate SVGZoomEventImpl::PreviousTranslate DontDelete|ReadOnly + newScale SVGZoomEventImpl::NewScale DontDelete|ReadOnly + newTranslate SVGZoomEventImpl::NewTranslate DontDelete|ReadOnly +@end +*/ + +Value SVGZoomEventImpl::getValueProperty(ExecState *, int token) const +{ + switch(token) + { + case PreviousScale: + return Number(previousScale()); + case NewScale: + return Number(newScale()); + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + return Undefined(); + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/SVGZoomEventImpl.h b/ksvg/impl/SVGZoomEventImpl.h new file mode 100644 index 00000000..41706a37 --- /dev/null +++ b/ksvg/impl/SVGZoomEventImpl.h @@ -0,0 +1,77 @@ +/* + 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. +*/ + +#ifndef SVGZoomEventImpl_H +#define SVGZoomEventImpl_H + +#include "SVGEventImpl.h" +#include "ksvg_lookup.h" + +namespace KSVG +{ + +class SVGRectImpl; +class SVGPointImpl; +class SVGZoomEventImpl : public SVGUIEventImpl +{ +public: + SVGZoomEventImpl(SVGEvent::EventId _id, + bool canBubbleArg, + bool cancelableArg, + DOM::AbstractView &viewArg, + long detailArg, + float previousScale, SVGPointImpl *previousTranslate, + float newScale, SVGPointImpl *newTranslate); + virtual ~SVGZoomEventImpl(); + + SVGRectImpl *zoomRectScreen() const; + + float previousScale() const; + SVGPointImpl *previousTranslate() const; + + float newScale() const; + SVGPointImpl *newTranslate() const; + +private: + SVGRectImpl *m_zoomRectScreen; + + float m_previousScale; + SVGPointImpl *m_previousTranslate; + + float m_newScale; + SVGPointImpl *m_newTranslate; + +public: + KSVG_GET + + enum + { + // Properties + ZoomRectScreen, PreviousScale, PreviousTranslate, NewScale, NewTranslate + }; + + KJS::Value getValueProperty(KJS::ExecState *exec, int token) const; +}; + +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/TODO b/ksvg/impl/TODO new file mode 100644 index 00000000..8cfd4c4a --- /dev/null +++ b/ksvg/impl/TODO @@ -0,0 +1,5 @@ +* cleanup SVGSVGElementImpl +* cleanup SVGShapeImpl +* fix SVGStringListImpl +* attriubuteMode get() for SVGGlyphElementImpl +* default attributes, ... for SVGGlyphElementImpl diff --git a/ksvg/impl/generateddata.cpp b/ksvg/impl/generateddata.cpp new file mode 100644 index 00000000..5a4b3d7b --- /dev/null +++ b/ksvg/impl/generateddata.cpp @@ -0,0 +1,8899 @@ +#include <ksvg_lookup.h> +#include <ksvg_ecma.h> +#include <SVGZoomEventImpl.h> +#include <SVGVKernElementImpl.h> +#include <SVGList.h> +#include <SVGTRefElementImpl.h> +#include <SVGSVGElementImpl.h> +#include <SVGFETurbulenceElementImpl.h> +#include <SVGElementInstanceImpl.h> +#include <SVGAnimateElementImpl.h> +#include <SVGFEGaussianBlurElementImpl.h> +#include <SVGZoomAndPanImpl.h> +#include <SVGFEFuncRElementImpl.h> +#include <SVGPathSegListImpl.h> +#include <SVGFEFuncAElementImpl.h> +#include <SVGFESpecularLightingElementImpl.h> +#include <SVGComponentTransferFunctionElementImpl.h> +#include <SVGICCColorImpl.h> +#include <SVGFEPointLightElementImpl.h> +#include <SVGMissingGlyphElementImpl.h> +#include <SVGFontFaceFormatElementImpl.h> +#include <SVGFontFaceUriElementImpl.h> +#include <SVGFEMorphologyElementImpl.h> +#include <SVGPaintServerImpl.h> +#include <SVGStringListImpl.h> +#include <SVGPolyElementImpl.h> +#include <SVGLinearGradientElementImpl.h> +#include <svgpathparser.h> +#include <SVGTextPathElementImpl.h> +#include <SVGNumberImpl.h> +#include <SVGPathSegImpl.h> +#include <SVGElementInstanceListImpl.h> +#include <SVGAnimatedIntegerImpl.h> +#include <SVGLocatableImpl.h> +#include <SVGAngleImpl.h> +#include <SVGAnimatedPreserveAspectRatioImpl.h> +#include <SVGColorImpl.h> +#include <SVGEllipseElementImpl.h> +#include <SVGGlyphRefElementImpl.h> +#include <SVGScriptElementImpl.h> +#include <SVGDocumentImpl.h> +#include <SVGAElementImpl.h> +#include <SVGAltGlyphDefElementImpl.h> +#include <SVGPathSegCurvetoQuadraticSmoothImpl.h> +#include <SVGFontElementImpl.h> +#include <SVGGElementImpl.h> +#include <SVGPathSegLinetoImpl.h> +#include <SVGForeignObjectElementImpl.h> +#include <SVGAnimatedStringImpl.h> +#include <SVGAnimatedTransformListImpl.h> +#include <SVGPatternElementImpl.h> +#include <SVGAltGlyphElementImpl.h> +#include <SVGElementImpl.h> +#include <SVGStylableImpl.h> +#include <SVGCSSRuleImpl.h> +#include <SVGFESpotLightElementImpl.h> +#include <SVGPreserveAspectRatioImpl.h> +#include <SVGColorProfileRuleImpl.h> +#include <SVGContainerImpl.h> +#include <SVGAnimateTransformElementImpl.h> +#include <SVGMatrixImpl.h> +#include <SVGEcma.h> +#include <SVGAnimatedLengthListImpl.h> +#include <SVGAnimatedAngleImpl.h> +#include <SVGURIReferenceImpl.h> +#include <SVGPolylineElementImpl.h> +#include <SVGDefinitionSrcElementImpl.h> +#include <SVGPathSegLinetoHorizontalImpl.h> +#include <SVGCursorElementImpl.h> +#include <SVGFitToViewBoxImpl.h> +#include <SVGEventImpl.h> +#include <SVGMetadataElementImpl.h> +#include <SVGLengthImpl.h> +#include <SVGTransformableImpl.h> +#include <SVGLengthListImpl.h> +#include <SVGTitleElementImpl.h> +#include <SVGTSpanElementImpl.h> +#include <SVGDescElementImpl.h> +#include <SVGTextContentElementImpl.h> +#include <SVGFEFuncBElementImpl.h> +#include <SVGMPathElementImpl.h> +#include <SVGDefsElementImpl.h> +#include <SVGAnimateMotionElementImpl.h> +#include <SVGStyleElementImpl.h> +#include <SVGSwitchElementImpl.h> +#include <SVGTransformListImpl.h> +#include <SVGPointListImpl.h> +#include <SVGFECompositeElementImpl.h> +#include <SVGHKernElementImpl.h> +#include <SVGFontFaceElementImpl.h> +#include <SVGPathSegMovetoImpl.h> +#include <SVGPathSegLinetoVerticalImpl.h> +#include <SVGAnimatedLengthImpl.h> +#include <SVGFEBlendElementImpl.h> +#include <SVGLangSpaceImpl.h> +#include <SVGRadialGradientElementImpl.h> +#include <SVGAnimatedRectImpl.h> +#include <SVGFilterPrimitiveStandardAttributesImpl.h> +#include <SVGPathElementImpl.h> +#include <SVGStopElementImpl.h> +#include <SVGAnimateColorElementImpl.h> +#include <SVGPathSegArcImpl.h> +#include <SVGAnimatedPointsImpl.h> +#include <SVGUseElementImpl.h> +#include <SVGViewSpecImpl.h> +#include <SVGFEMergeNodeElementImpl.h> +#include <SVGHelperImpl.h> +#include <SVGFEDiffuseLightingElementImpl.h> +#include <SVGSymbolElementImpl.h> +#include <SVGFEFloodElementImpl.h> +#include <SVGAnimatedNumberListImpl.h> +#include <SVGExternalResourcesRequiredImpl.h> +#include <SVGFETileElementImpl.h> +#include <SVGTextPositioningElementImpl.h> +#include <SVGGlyphElementImpl.h> +#include <SVGAnimatedBooleanImpl.h> +#include <SVGSetElementImpl.h> +#include <SVGFontFaceSrcElementImpl.h> +#include <SVGTextElementImpl.h> +#include <SVGFEMergeElementImpl.h> +#include <SVGMarkerElementImpl.h> +#include <SVGViewElementImpl.h> +#include <SVGFEFuncGElementImpl.h> +#include <SVGColorProfileElementImpl.h> +#include <SVGGradientElementImpl.h> +#include <SVGFEConvolveMatrixElementImpl.h> +#include <SVGFontFaceNameElementImpl.h> +#include <SVGLineElementImpl.h> +#include <SVGUnitConverter.h> +#include <SVGFEColorMatrixElementImpl.h> +#include <SVGCircleElementImpl.h> +#include <SVGTestsImpl.h> +#include <SVGRectElementImpl.h> +#include <SVGRectImpl.h> +#include <SVGPolygonElementImpl.h> +#include <SVGTimeScheduler.h> +#include <SVGNumberListImpl.h> +#include <SVGPathSegCurvetoCubicSmoothImpl.h> +#include <SVGPointImpl.h> +#include <SVGFEDistantLightElementImpl.h> +#include <SVGPathSegCurvetoCubicImpl.h> +#include <SVGFEComponentTransferElementImpl.h> +#include <SVGWindowImpl.h> +#include <SVGMaskElementImpl.h> +#include <SVGShapeImpl.h> +#include <SVGAnimatedEnumerationImpl.h> +#include <SVGAnimatedPathDataImpl.h> +#include <SVGFEOffsetElementImpl.h> +#include <SVGPaintImpl.h> +#include <SVGFilterElementImpl.h> +#include <SVGImageElementImpl.h> +#include <SVGAnimatedNumberImpl.h> +#include <SVGAnimationElementImpl.h> +#include <SVGFEDisplacementMapElementImpl.h> +#include <SVGPathSegClosePathImpl.h> +#include <SVGTransformImpl.h> +#include <SVGFEImageElementImpl.h> +#include <SVGPathSegCurvetoQuadraticImpl.h> +#include <SVGClipPathElementImpl.h> + +using namespace KSVG; +using namespace KJS; + +#include "ksvg_cacheimpl.h" + +// For all classes with generated data: the ClassInfo +const DOM::DOMString SVGAElementImpl::s_tagName = "a"; +const ClassInfo SVGAElementImpl::s_classInfo = {"KSVG::SVGAElementImpl",0,&SVGAElementImpl::s_hashTable,0}; +const DOM::DOMString SVGAltGlyphDefElementImpl::s_tagName = "altGlyphDef"; +const ClassInfo SVGAltGlyphDefElementImpl::s_classInfo = {"KSVG::SVGAltGlyphDefElementImpl",0,0,0}; +const DOM::DOMString SVGAltGlyphElementImpl::s_tagName = "altGlyph"; +const ClassInfo SVGAltGlyphElementImpl::s_classInfo = {"KSVG::SVGAltGlyphElementImpl",0,0,0}; +const ClassInfo SVGAngleImpl::s_classInfo = {"KSVG::SVGAngleImpl",0,&SVGAngleImpl::s_hashTable,0}; +const ClassInfo SVGAngleImplConstructor::s_classInfo = {"KSVG::SVGAngleImplConstructor",0,&SVGAngleImplConstructor::s_hashTable,0}; +const DOM::DOMString SVGAnimateColorElementImpl::s_tagName = "animateColor"; +const ClassInfo SVGAnimateColorElementImpl::s_classInfo = {"KSVG::SVGAnimateColorElementImpl",0,0,0}; +const DOM::DOMString SVGAnimateElementImpl::s_tagName = "animate"; +const ClassInfo SVGAnimateElementImpl::s_classInfo = {"KSVG::SVGAnimateElementImpl",0,0,0}; +const DOM::DOMString SVGAnimateMotionElementImpl::s_tagName = "animateMotion"; +const ClassInfo SVGAnimateMotionElementImpl::s_classInfo = {"KSVG::SVGAnimateMotionElementImpl",0,0,0}; +const DOM::DOMString SVGAnimateTransformElementImpl::s_tagName = "animateTransform"; +const ClassInfo SVGAnimateTransformElementImpl::s_classInfo = {"KSVG::SVGAnimateTransformElementImpl",0,0,0}; +const ClassInfo SVGAnimatedAngleImpl::s_classInfo = {"KSVG::SVGAnimatedAngleImpl",0,&SVGAnimatedAngleImpl::s_hashTable,0}; +const ClassInfo SVGAnimatedBooleanImpl::s_classInfo = {"KSVG::SVGAnimatedBooleanImpl",0,&SVGAnimatedBooleanImpl::s_hashTable,0}; +const ClassInfo SVGAnimatedEnumerationImpl::s_classInfo = {"KSVG::SVGAnimatedEnumerationImpl",0,&SVGAnimatedEnumerationImpl::s_hashTable,0}; +const ClassInfo SVGAnimatedIntegerImpl::s_classInfo = {"KSVG::SVGAnimatedIntegerImpl",0,&SVGAnimatedIntegerImpl::s_hashTable,0}; +const ClassInfo SVGAnimatedLengthImpl::s_classInfo = {"KSVG::SVGAnimatedLengthImpl",0,&SVGAnimatedLengthImpl::s_hashTable,0}; +const ClassInfo SVGAnimatedLengthListImpl::s_classInfo = {"KSVG::SVGAnimatedLengthListImpl",0,&SVGAnimatedLengthListImpl::s_hashTable,0}; +const ClassInfo SVGAnimatedNumberImpl::s_classInfo = {"KSVG::SVGAnimatedNumberImpl",0,&SVGAnimatedNumberImpl::s_hashTable,0}; +const ClassInfo SVGAnimatedNumberListImpl::s_classInfo = {"KSVG::SVGAnimatedNumberListImpl",0,&SVGAnimatedNumberListImpl::s_hashTable,0}; +const ClassInfo SVGAnimatedPathDataImpl::s_classInfo = {"KSVG::SVGAnimatedPathDataImpl",0,&SVGAnimatedPathDataImpl::s_hashTable,0}; +const ClassInfo SVGAnimatedPointsImpl::s_classInfo = {"KSVG::SVGAnimatedPointsImpl",0,&SVGAnimatedPointsImpl::s_hashTable,0}; +const ClassInfo SVGAnimatedPreserveAspectRatioImpl::s_classInfo = {"KSVG::SVGAnimatedPreserveAspectRatioImpl",0,&SVGAnimatedPreserveAspectRatioImpl::s_hashTable,0}; +const ClassInfo SVGAnimatedRectImpl::s_classInfo = {"KSVG::SVGAnimatedRectImpl",0,&SVGAnimatedRectImpl::s_hashTable,0}; +const ClassInfo SVGAnimatedStringImpl::s_classInfo = {"KSVG::SVGAnimatedStringImpl",0,&SVGAnimatedStringImpl::s_hashTable,0}; +const ClassInfo SVGAnimatedTransformListImpl::s_classInfo = {"KSVG::SVGAnimatedTransformListImpl",0,&SVGAnimatedTransformListImpl::s_hashTable,0}; +const ClassInfo SVGAnimationElementImpl::s_classInfo = {"KSVG::SVGAnimationElementImpl",0,&SVGAnimationElementImpl::s_hashTable,0}; +const DOM::DOMString SVGCircleElementImpl::s_tagName = "circle"; +const ClassInfo SVGCircleElementImpl::s_classInfo = {"KSVG::SVGCircleElementImpl",0,&SVGCircleElementImpl::s_hashTable,0}; +const DOM::DOMString SVGClipPathElementImpl::s_tagName = "clipPath"; +const ClassInfo SVGClipPathElementImpl::s_classInfo = {"KSVG::SVGClipPathElementImpl",0,&SVGClipPathElementImpl::s_hashTable,0}; +const ClassInfo SVGColorImpl::s_classInfo = {"KSVG::SVGColorImpl",0,&SVGColorImpl::s_hashTable,0}; +const ClassInfo SVGColorImplConstructor::s_classInfo = {"KSVG::SVGColorImplConstructor",0,&SVGColorImplConstructor::s_hashTable,0}; +const DOM::DOMString SVGColorProfileElementImpl::s_tagName = "color-profile"; +const ClassInfo SVGColorProfileElementImpl::s_classInfo = {"KSVG::SVGColorProfileElementImpl",0,&SVGColorProfileElementImpl::s_hashTable,0}; +const ClassInfo SVGComponentTransferFunctionElementImpl::s_classInfo = {"KSVG::SVGComponentTransferFunctionElementImpl",0,0,0}; +const ClassInfo SVGContainerImpl::s_classInfo = {"KSVG::SVGContainerImpl",0,0,0}; +const ClassInfo SVGCursorElementImpl::s_classInfo = {"KSVG::SVGCursorElementImpl",0,&SVGCursorElementImpl::s_hashTable,0}; +const ClassInfo SVGDOMCharacterDataBridge::s_classInfo = {"KSVG::SVGDOMCharacterDataBridge",0,&SVGDOMCharacterDataBridge::s_hashTable,0}; +const ClassInfo SVGDOMDOMImplementationBridge::s_classInfo = {"KSVG::SVGDOMDOMImplementationBridge",0,&SVGDOMDOMImplementationBridge::s_hashTable,0}; +const ClassInfo SVGDOMDocumentFragmentBridge::s_classInfo = {"KSVG::SVGDOMDocumentFragmentBridge",0,&SVGDOMDocumentFragmentBridge::s_hashTable,0}; +const ClassInfo SVGDOMElementBridge::s_classInfo = {"KSVG::SVGDOMElementBridge",0,&SVGDOMElementBridge::s_hashTable,0}; +const ClassInfo SVGDOMNodeBridge::s_classInfo = {"KSVG::SVGDOMNodeBridge",0,&SVGDOMNodeBridge::s_hashTable,0}; +const ClassInfo SVGDOMNodeListBridge::s_classInfo = {"KSVG::SVGDOMNodeListBridge",0,&SVGDOMNodeListBridge::s_hashTable,0}; +const ClassInfo SVGDOMTextBridge::s_classInfo = {"KSVG::SVGDOMTextBridge",0,&SVGDOMTextBridge::s_hashTable,0}; +const ClassInfo SVGDefinitionSrcElementImpl::s_classInfo = {"KSVG::SVGDefinitionSrcElementImpl",0,0,0}; +const DOM::DOMString SVGDefsElementImpl::s_tagName = "defs"; +const ClassInfo SVGDefsElementImpl::s_classInfo = {"KSVG::SVGDefsElementImpl",0,0,0}; +const DOM::DOMString SVGDescElementImpl::s_tagName = "desc"; +const ClassInfo SVGDescElementImpl::s_classInfo = {"KSVG::SVGDescElementImpl",0,0,0}; +const ClassInfo SVGDocumentImpl::s_classInfo = {"KSVG::SVGDocumentImpl",0,&SVGDocumentImpl::s_hashTable,0}; +const ClassInfo SVGElementImpl::s_classInfo = {"KSVG::SVGElementImpl",0,&SVGElementImpl::s_hashTable,0}; +const DOM::DOMString SVGEllipseElementImpl::s_tagName = "ellipse"; +const ClassInfo SVGEllipseElementImpl::s_classInfo = {"KSVG::SVGEllipseElementImpl",0,&SVGEllipseElementImpl::s_hashTable,0}; +const ClassInfo SVGEventImpl::s_classInfo = {"KSVG::SVGEventImpl",0,&SVGEventImpl::s_hashTable,0}; +const ClassInfo SVGExternalResourcesRequiredImpl::s_classInfo = {"KSVG::SVGExternalResourcesRequiredImpl",0,&SVGExternalResourcesRequiredImpl::s_hashTable,0}; +const ClassInfo SVGFEBlendElementImpl::s_classInfo = {"KSVG::SVGFEBlendElementImpl",0,0,0}; +const ClassInfo SVGFEColorMatrixElementImpl::s_classInfo = {"KSVG::SVGFEColorMatrixElementImpl",0,0,0}; +const ClassInfo SVGFEComponentTransferElementImpl::s_classInfo = {"KSVG::SVGFEComponentTransferElementImpl",0,0,0}; +const ClassInfo SVGFECompositeElementImpl::s_classInfo = {"KSVG::SVGFECompositeElementImpl",0,0,0}; +const ClassInfo SVGFEConvolveMatrixElementImpl::s_classInfo = {"KSVG::SVGFEConvolveMatrixElementImpl",0,0,0}; +const ClassInfo SVGFEDiffuseLightingElementImpl::s_classInfo = {"KSVG::SVGFEDiffuseLightingElementImpl",0,0,0}; +const ClassInfo SVGFEDisplacementMapElementImpl::s_classInfo = {"KSVG::SVGFEDisplacementMapElementImpl",0,0,0}; +const ClassInfo SVGFEDistantLightElementImpl::s_classInfo = {"KSVG::SVGFEDistantLightElementImpl",0,0,0}; +const ClassInfo SVGFEFloodElementImpl::s_classInfo = {"KSVG::SVGFEFloodElementImpl",0,0,0}; +const ClassInfo SVGFEFuncAElementImpl::s_classInfo = {"KSVG::SVGFEFuncAElementImpl",0,0,0}; +const ClassInfo SVGFEFuncBElementImpl::s_classInfo = {"KSVG::SVGFEFuncBElementImpl",0,0,0}; +const ClassInfo SVGFEFuncGElementImpl::s_classInfo = {"KSVG::SVGFEFuncGElementImpl",0,0,0}; +const ClassInfo SVGFEFuncRElementImpl::s_classInfo = {"KSVG::SVGFEFuncRElementImpl",0,0,0}; +const ClassInfo SVGFEGaussianBlurElementImpl::s_classInfo = {"KSVG::SVGFEGaussianBlurElementImpl",0,0,0}; +const ClassInfo SVGFEImageElementImpl::s_classInfo = {"KSVG::SVGFEImageElementImpl",0,0,0}; +const ClassInfo SVGFEMergeElementImpl::s_classInfo = {"KSVG::SVGFEMergeElementImpl",0,0,0}; +const ClassInfo SVGFEMergeNodeElementImpl::s_classInfo = {"KSVG::SVGFEMergeNodeElementImpl",0,0,0}; +const ClassInfo SVGFEMorphologyElementImpl::s_classInfo = {"KSVG::SVGFEMorphologyElementImpl",0,0,0}; +const ClassInfo SVGFEOffsetElementImpl::s_classInfo = {"KSVG::SVGFEOffsetElementImpl",0,0,0}; +const ClassInfo SVGFEPointLightElementImpl::s_classInfo = {"KSVG::SVGFEPointLightElementImpl",0,0,0}; +const ClassInfo SVGFESpecularLightingElementImpl::s_classInfo = {"KSVG::SVGFESpecularLightingElementImpl",0,0,0}; +const ClassInfo SVGFESpotLightElementImpl::s_classInfo = {"KSVG::SVGFESpotLightElementImpl",0,0,0}; +const ClassInfo SVGFETileElementImpl::s_classInfo = {"KSVG::SVGFETileElementImpl",0,0,0}; +const ClassInfo SVGFETurbulenceElementImpl::s_classInfo = {"KSVG::SVGFETurbulenceElementImpl",0,0,0}; +const ClassInfo SVGFilterElementImpl::s_classInfo = {"KSVG::SVGFilterElementImpl",0,0,0}; +const ClassInfo SVGFitToViewBoxImpl::s_classInfo = {"KSVG::SVGFitToViewBoxImpl",0,&SVGFitToViewBoxImpl::s_hashTable,0}; +const ClassInfo SVGFontElementImpl::s_classInfo = {"KSVG::SVGFontElementImpl",0,0,0}; +const ClassInfo SVGFontFaceElementImpl::s_classInfo = {"KSVG::SVGFontFaceElementImpl",0,0,0}; +const ClassInfo SVGFontFaceFormatElementImpl::s_classInfo = {"KSVG::SVGFontFaceFormatElementImpl",0,0,0}; +const ClassInfo SVGFontFaceNameElementImpl::s_classInfo = {"KSVG::SVGFontFaceNameElementImpl",0,0,0}; +const ClassInfo SVGFontFaceSrcElementImpl::s_classInfo = {"KSVG::SVGFontFaceSrcElementImpl",0,0,0}; +const ClassInfo SVGFontFaceUriElementImpl::s_classInfo = {"KSVG::SVGFontFaceUriElementImpl",0,0,0}; +const ClassInfo SVGForeignObjectElementImpl::s_classInfo = {"KSVG::SVGForeignObjectElementImpl",0,&SVGForeignObjectElementImpl::s_hashTable,0}; +const DOM::DOMString SVGGElementImpl::s_tagName = "g"; +const ClassInfo SVGGElementImpl::s_classInfo = {"KSVG::SVGGElementImpl",0,0,0}; +const DOM::DOMString SVGGlyphElementImpl::s_tagName = "glyph"; +const ClassInfo SVGGlyphElementImpl::s_classInfo = {"KSVG::SVGGlyphElementImpl",0,&SVGGlyphElementImpl::s_hashTable,0}; +const DOM::DOMString SVGGlyphRefElementImpl::s_tagName = "glyphRef"; +const ClassInfo SVGGlyphRefElementImpl::s_classInfo = {"KSVG::SVGGlyphRefElementImpl",0,&SVGGlyphRefElementImpl::s_hashTable,0}; +const ClassInfo SVGGradientElementImpl::s_classInfo = {"KSVG::SVGGradientElementImpl",0,&SVGGradientElementImpl::s_hashTable,0}; +const ClassInfo SVGGradientElementImplConstructor::s_classInfo = {"KSVG::SVGGradientElementImplConstructor",0,&SVGGradientElementImplConstructor::s_hashTable,0}; +const ClassInfo SVGHKernElementImpl::s_classInfo = {"KSVG::SVGHKernElementImpl",0,0,0}; +const ClassInfo SVGICCColorImpl::s_classInfo = {"KSVG::SVGICCColorImpl",0,&SVGICCColorImpl::s_hashTable,0}; +const DOM::DOMString SVGImageElementImpl::s_tagName = "image"; +const ClassInfo SVGImageElementImpl::s_classInfo = {"KSVG::SVGImageElementImpl",0,&SVGImageElementImpl::s_hashTable,0}; +const ClassInfo SVGKeyEventImpl::s_classInfo = {"KSVG::SVGKeyEventImpl",0,&SVGKeyEventImpl::s_hashTable,0}; +const ClassInfo SVGLangSpaceImpl::s_classInfo = {"KSVG::SVGLangSpaceImpl",0,&SVGLangSpaceImpl::s_hashTable,0}; +const ClassInfo SVGLengthImpl::s_classInfo = {"KSVG::SVGLengthImpl",0,&SVGLengthImpl::s_hashTable,0}; +const ClassInfo SVGLengthImplConstructor::s_classInfo = {"KSVG::SVGLengthImplConstructor",0,&SVGLengthImplConstructor::s_hashTable,0}; +const ClassInfo SVGLengthListImpl::s_classInfo = {"KSVG::SVGLengthListImpl",0,&SVGLengthListImpl::s_hashTable,0}; +const DOM::DOMString SVGLineElementImpl::s_tagName = "line"; +const ClassInfo SVGLineElementImpl::s_classInfo = {"KSVG::SVGLineElementImpl",0,&SVGLineElementImpl::s_hashTable,0}; +const DOM::DOMString SVGLinearGradientElementImpl::s_tagName = "linearGradient"; +const ClassInfo SVGLinearGradientElementImpl::s_classInfo = {"KSVG::SVGLinearGradientElementImpl",0,&SVGLinearGradientElementImpl::s_hashTable,0}; +const ClassInfo SVGLocatableImpl::s_classInfo = {"KSVG::SVGLocatableImpl",0,&SVGLocatableImpl::s_hashTable,0}; +const ClassInfo SVGMPathElementImpl::s_classInfo = {"KSVG::SVGMPathElementImpl",0,0,0}; +const DOM::DOMString SVGMarkerElementImpl::s_tagName = "marker"; +const ClassInfo SVGMarkerElementImpl::s_classInfo = {"KSVG::SVGMarkerElementImpl",0,&SVGMarkerElementImpl::s_hashTable,0}; +const ClassInfo SVGMarkerElementImplConstructor::s_classInfo = {"KSVG::SVGMarkerElementImplConstructor",0,&SVGMarkerElementImplConstructor::s_hashTable,0}; +const DOM::DOMString SVGMaskElementImpl::s_tagName = "mask"; +const ClassInfo SVGMaskElementImpl::s_classInfo = {"KSVG::SVGMaskElementImpl",0,&SVGMaskElementImpl::s_hashTable,0}; +const ClassInfo SVGMatrixImpl::s_classInfo = {"KSVG::SVGMatrixImpl",0,&SVGMatrixImpl::s_hashTable,0}; +const ClassInfo SVGMetadataElementImpl::s_classInfo = {"KSVG::SVGMetadataElementImpl",0,0,0}; +const ClassInfo SVGMissingGlyphElementImpl::s_classInfo = {"KSVG::SVGMissingGlyphElementImpl",0,0,0}; +const ClassInfo SVGMouseEventImpl::s_classInfo = {"KSVG::SVGMouseEventImpl",0,&SVGMouseEventImpl::s_hashTable,0}; +const ClassInfo SVGMutationEventImpl::s_classInfo = {"KSVG::SVGMutationEventImpl",0,0,0}; +const ClassInfo SVGNumberImpl::s_classInfo = {"KSVG::SVGNumberImpl",0,&SVGNumberImpl::s_hashTable,0}; +const ClassInfo SVGNumberListImpl::s_classInfo = {"KSVG::SVGNumberListImpl",0,&SVGNumberListImpl::s_hashTable,0}; +const ClassInfo SVGPaintImpl::s_classInfo = {"KSVG::SVGPaintImpl",0,&SVGPaintImpl::s_hashTable,0}; +const ClassInfo SVGPaintImplConstructor::s_classInfo = {"KSVG::SVGPaintImplConstructor",0,&SVGPaintImplConstructor::s_hashTable,0}; +const DOM::DOMString SVGPathElementImpl::s_tagName = "path"; +const ClassInfo SVGPathElementImpl::s_classInfo = {"KSVG::SVGPathElementImpl",0,&SVGPathElementImpl::s_hashTable,0}; +const ClassInfo SVGPathSegArcAbsImpl::s_classInfo = {"KSVG::SVGPathSegArcAbsImpl",0,&SVGPathSegArcAbsImpl::s_hashTable,0}; +const ClassInfo SVGPathSegArcRelImpl::s_classInfo = {"KSVG::SVGPathSegArcRelImpl",0,&SVGPathSegArcRelImpl::s_hashTable,0}; +const ClassInfo SVGPathSegClosePathImpl::s_classInfo = {"KSVG::SVGPathSegClosePathImpl",0,0,0}; +const ClassInfo SVGPathSegCurvetoCubicAbsImpl::s_classInfo = {"KSVG::SVGPathSegCurvetoCubicAbsImpl",0,&SVGPathSegCurvetoCubicAbsImpl::s_hashTable,0}; +const ClassInfo SVGPathSegCurvetoCubicRelImpl::s_classInfo = {"KSVG::SVGPathSegCurvetoCubicRelImpl",0,&SVGPathSegCurvetoCubicRelImpl::s_hashTable,0}; +const ClassInfo SVGPathSegCurvetoCubicSmoothAbsImpl::s_classInfo = {"KSVG::SVGPathSegCurvetoCubicSmoothAbsImpl",0,&SVGPathSegCurvetoCubicSmoothAbsImpl::s_hashTable,0}; +const ClassInfo SVGPathSegCurvetoCubicSmoothRelImpl::s_classInfo = {"KSVG::SVGPathSegCurvetoCubicSmoothRelImpl",0,&SVGPathSegCurvetoCubicSmoothRelImpl::s_hashTable,0}; +const ClassInfo SVGPathSegCurvetoQuadraticAbsImpl::s_classInfo = {"KSVG::SVGPathSegCurvetoQuadraticAbsImpl",0,&SVGPathSegCurvetoQuadraticAbsImpl::s_hashTable,0}; +const ClassInfo SVGPathSegCurvetoQuadraticRelImpl::s_classInfo = {"KSVG::SVGPathSegCurvetoQuadraticRelImpl",0,&SVGPathSegCurvetoQuadraticRelImpl::s_hashTable,0}; +const ClassInfo SVGPathSegCurvetoQuadraticSmoothAbsImpl::s_classInfo = {"KSVG::SVGPathSegCurvetoQuadraticSmoothAbsImpl",0,&SVGPathSegCurvetoQuadraticSmoothAbsImpl::s_hashTable,0}; +const ClassInfo SVGPathSegCurvetoQuadraticSmoothRelImpl::s_classInfo = {"KSVG::SVGPathSegCurvetoQuadraticSmoothRelImpl",0,&SVGPathSegCurvetoQuadraticSmoothRelImpl::s_hashTable,0}; +const ClassInfo SVGPathSegImpl::s_classInfo = {"KSVG::SVGPathSegImpl",0,&SVGPathSegImpl::s_hashTable,0}; +const ClassInfo SVGPathSegImplConstructor::s_classInfo = {"KSVG::SVGPathSegImplConstructor",0,&SVGPathSegImplConstructor::s_hashTable,0}; +const ClassInfo SVGPathSegLinetoAbsImpl::s_classInfo = {"KSVG::SVGPathSegLinetoAbsImpl",0,&SVGPathSegLinetoAbsImpl::s_hashTable,0}; +const ClassInfo SVGPathSegLinetoHorizontalAbsImpl::s_classInfo = {"KSVG::SVGPathSegLinetoHorizontalAbsImpl",0,&SVGPathSegLinetoHorizontalAbsImpl::s_hashTable,0}; +const ClassInfo SVGPathSegLinetoHorizontalRelImpl::s_classInfo = {"KSVG::SVGPathSegLinetoHorizontalRelImpl",0,&SVGPathSegLinetoHorizontalRelImpl::s_hashTable,0}; +const ClassInfo SVGPathSegLinetoRelImpl::s_classInfo = {"KSVG::SVGPathSegLinetoRelImpl",0,&SVGPathSegLinetoRelImpl::s_hashTable,0}; +const ClassInfo SVGPathSegLinetoVerticalAbsImpl::s_classInfo = {"KSVG::SVGPathSegLinetoVerticalAbsImpl",0,&SVGPathSegLinetoVerticalAbsImpl::s_hashTable,0}; +const ClassInfo SVGPathSegLinetoVerticalRelImpl::s_classInfo = {"KSVG::SVGPathSegLinetoVerticalRelImpl",0,&SVGPathSegLinetoVerticalRelImpl::s_hashTable,0}; +const ClassInfo SVGPathSegListImpl::s_classInfo = {"KSVG::SVGPathSegListImpl",0,&SVGPathSegListImpl::s_hashTable,0}; +const ClassInfo SVGPathSegMovetoAbsImpl::s_classInfo = {"KSVG::SVGPathSegMovetoAbsImpl",0,&SVGPathSegMovetoAbsImpl::s_hashTable,0}; +const ClassInfo SVGPathSegMovetoRelImpl::s_classInfo = {"KSVG::SVGPathSegMovetoRelImpl",0,&SVGPathSegMovetoRelImpl::s_hashTable,0}; +const DOM::DOMString SVGPatternElementImpl::s_tagName = "pattern"; +const ClassInfo SVGPatternElementImpl::s_classInfo = {"KSVG::SVGPatternElementImpl",0,&SVGPatternElementImpl::s_hashTable,0}; +const ClassInfo SVGPointImpl::s_classInfo = {"KSVG::SVGPointImpl",0,&SVGPointImpl::s_hashTable,0}; +const ClassInfo SVGPointListImpl::s_classInfo = {"KSVG::SVGPointListImpl",0,&SVGPointListImpl::s_hashTable,0}; +const ClassInfo SVGPolyElementImpl::s_classInfo = {"KSVG::SVGPolyElementImpl",0,0,0}; +const DOM::DOMString SVGPolygonElementImpl::s_tagName = "polygon"; +const ClassInfo SVGPolygonElementImpl::s_classInfo = {"KSVG::SVGPolygonElementImpl",0,0,0}; +const DOM::DOMString SVGPolylineElementImpl::s_tagName = "polyline"; +const ClassInfo SVGPolylineElementImpl::s_classInfo = {"KSVG::SVGPolylineElementImpl",0,0,0}; +const ClassInfo SVGPreserveAspectRatioImpl::s_classInfo = {"KSVG::SVGPreserveAspectRatioImpl",0,&SVGPreserveAspectRatioImpl::s_hashTable,0}; +const ClassInfo SVGPreserveAspectRatioImplConstructor::s_classInfo = {"KSVG::SVGPreserveAspectRatioImplConstructor",0,&SVGPreserveAspectRatioImplConstructor::s_hashTable,0}; +const DOM::DOMString SVGRadialGradientElementImpl::s_tagName = "radialGradient"; +const ClassInfo SVGRadialGradientElementImpl::s_classInfo = {"KSVG::SVGRadialGradientElementImpl",0,&SVGRadialGradientElementImpl::s_hashTable,0}; +const DOM::DOMString SVGRectElementImpl::s_tagName = "rect"; +const ClassInfo SVGRectElementImpl::s_classInfo = {"KSVG::SVGRectElementImpl",0,&SVGRectElementImpl::s_hashTable,0}; +const ClassInfo SVGRectImpl::s_classInfo = {"KSVG::SVGRectImpl",0,&SVGRectImpl::s_hashTable,0}; +const DOM::DOMString SVGSVGElementImpl::s_tagName = "svg"; +const ClassInfo SVGSVGElementImpl::s_classInfo = {"KSVG::SVGSVGElementImpl",0,&SVGSVGElementImpl::s_hashTable,0}; +const DOM::DOMString SVGScriptElementImpl::s_tagName = "script"; +const ClassInfo SVGScriptElementImpl::s_classInfo = {"KSVG::SVGScriptElementImpl",0,&SVGScriptElementImpl::s_hashTable,0}; +const DOM::DOMString SVGSetElementImpl::s_tagName = "set"; +const ClassInfo SVGSetElementImpl::s_classInfo = {"KSVG::SVGSetElementImpl",0,0,0}; +const ClassInfo SVGShapeImpl::s_classInfo = {"KSVG::SVGShapeImpl",0,0,0}; +const DOM::DOMString SVGStopElementImpl::s_tagName = "stop"; +const ClassInfo SVGStopElementImpl::s_classInfo = {"KSVG::SVGStopElementImpl",0,&SVGStopElementImpl::s_hashTable,0}; +const ClassInfo SVGStringListImpl::s_classInfo = {"KSVG::SVGStringListImpl",0,&SVGStringListImpl::s_hashTable,0}; +const ClassInfo SVGStylableImpl::s_classInfo = {"KSVG::SVGStylableImpl",0,&SVGStylableImpl::s_hashTable,0}; +const DOM::DOMString SVGStyleElementImpl::s_tagName = "style"; +const ClassInfo SVGStyleElementImpl::s_classInfo = {"KSVG::SVGStyleElementImpl",0,&SVGStyleElementImpl::s_hashTable,0}; +const DOM::DOMString SVGSwitchElementImpl::s_tagName = "switch"; +const ClassInfo SVGSwitchElementImpl::s_classInfo = {"KSVG::SVGSwitchElementImpl",0,0,0}; +const DOM::DOMString SVGSymbolElementImpl::s_tagName = "symbol"; +const ClassInfo SVGSymbolElementImpl::s_classInfo = {"KSVG::SVGSymbolElementImpl",0,&SVGSymbolElementImpl::s_hashTable,0}; +const DOM::DOMString SVGTRefElementImpl::s_tagName = "tref"; +const ClassInfo SVGTRefElementImpl::s_classInfo = {"KSVG::SVGTRefElementImpl",0,0,0}; +const DOM::DOMString SVGTSpanElementImpl::s_tagName = "tspan"; +const ClassInfo SVGTSpanElementImpl::s_classInfo = {"KSVG::SVGTSpanElementImpl",0,0,0}; +const ClassInfo SVGTestsImpl::s_classInfo = {"KSVG::SVGTestsImpl",0,&SVGTestsImpl::s_hashTable,0}; +const ClassInfo SVGTextContentElementImpl::s_classInfo = {"KSVG::SVGTextContentElementImpl",0,&SVGTextContentElementImpl::s_hashTable,0}; +const ClassInfo SVGTextContentElementImplConstructor::s_classInfo = {"KSVG::SVGTextContentElementImplConstructor",0,&SVGTextContentElementImplConstructor::s_hashTable,0}; +const DOM::DOMString SVGTextElementImpl::s_tagName = "text"; +const ClassInfo SVGTextElementImpl::s_classInfo = {"KSVG::SVGTextElementImpl",0,0,0}; +const DOM::DOMString SVGTextPathElementImpl::s_tagName = "textPath"; +const ClassInfo SVGTextPathElementImpl::s_classInfo = {"KSVG::SVGTextPathElementImpl",0,&SVGTextPathElementImpl::s_hashTable,0}; +const ClassInfo SVGTextPathElementImplConstructor::s_classInfo = {"KSVG::SVGTextPathElementImplConstructor",0,&SVGTextPathElementImplConstructor::s_hashTable,0}; +const ClassInfo SVGTextPositioningElementImpl::s_classInfo = {"KSVG::SVGTextPositioningElementImpl",0,&SVGTextPositioningElementImpl::s_hashTable,0}; +const DOM::DOMString SVGTitleElementImpl::s_tagName = "title"; +const ClassInfo SVGTitleElementImpl::s_classInfo = {"KSVG::SVGTitleElementImpl",0,0,0}; +const ClassInfo SVGTransformImpl::s_classInfo = {"KSVG::SVGTransformImpl",0,&SVGTransformImpl::s_hashTable,0}; +const ClassInfo SVGTransformImplConstructor::s_classInfo = {"KSVG::SVGTransformImplConstructor",0,&SVGTransformImplConstructor::s_hashTable,0}; +const ClassInfo SVGTransformListImpl::s_classInfo = {"KSVG::SVGTransformListImpl",0,&SVGTransformListImpl::s_hashTable,0}; +const ClassInfo SVGTransformableImpl::s_classInfo = {"KSVG::SVGTransformableImpl",0,&SVGTransformableImpl::s_hashTable,0}; +const ClassInfo SVGUIEventImpl::s_classInfo = {"KSVG::SVGUIEventImpl",0,&SVGUIEventImpl::s_hashTable,0}; +const ClassInfo SVGURIReferenceImpl::s_classInfo = {"KSVG::SVGURIReferenceImpl",0,&SVGURIReferenceImpl::s_hashTable,0}; +const DOM::DOMString SVGUseElementImpl::s_tagName = "use"; +const ClassInfo SVGUseElementImpl::s_classInfo = {"KSVG::SVGUseElementImpl",0,&SVGUseElementImpl::s_hashTable,0}; +const ClassInfo SVGVKernElementImpl::s_classInfo = {"KSVG::SVGVKernElementImpl",0,0,0}; +const DOM::DOMString SVGViewElementImpl::s_tagName = "view"; +const ClassInfo SVGViewElementImpl::s_classInfo = {"KSVG::SVGViewElementImpl",0,&SVGViewElementImpl::s_hashTable,0}; +const ClassInfo SVGViewSpecImpl::s_classInfo = {"KSVG::SVGViewSpecImpl",0,0,0}; +const ClassInfo SVGZoomAndPanImpl::s_classInfo = {"KSVG::SVGZoomAndPanImpl",0,&SVGZoomAndPanImpl::s_hashTable,0}; +const ClassInfo SVGZoomAndPanImplConstructor::s_classInfo = {"KSVG::SVGZoomAndPanImplConstructor",0,&SVGZoomAndPanImplConstructor::s_hashTable,0}; +const ClassInfo SVGZoomEventImpl::s_classInfo = {"KSVG::SVGZoomEventImpl",0,&SVGZoomEventImpl::s_hashTable,0}; +const ClassInfo SharedString::s_classInfo = {"KSVG::SharedString",0,&SharedString::s_hashTable,0}; + +bool SVGAElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGAElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGContainerImpl::hasProperty(p1,p2)) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + if(SVGTestsImpl::hasProperty(p1,p2)) return true; + if(SVGTransformableImpl::hasProperty(p1,p2)) return true; + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGAElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGAElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGAElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGContainerImpl::hasProperty(p1,p2)) return SVGContainerImpl::get(p1,p2,p3); + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + if(SVGTestsImpl::hasProperty(p1,p2)) return SVGTestsImpl::get(p1,p2,p3); + if(SVGTransformableImpl::hasProperty(p1,p2)) return SVGTransformableImpl::get(p1,p2,p3); + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return SVGURIReferenceImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGAElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGAElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGAElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGContainerImpl::hasProperty(p1,p2)) { + SVGContainerImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTestsImpl::hasProperty(p1,p2)) { + SVGTestsImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTransformableImpl::hasProperty(p1,p2)) { + SVGTransformableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGURIReferenceImpl::hasProperty(p1,p2)) { + SVGURIReferenceImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGAElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGAElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGAElementImpl>(p1,const_cast<SVGAElementImpl *>(this)); +} + +Value SVGAElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAElementImpl,KSVGRWBridge<SVGAElementImpl> >(p1,const_cast<SVGAElementImpl *>(this))); +} + +bool SVGAltGlyphDefElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGAltGlyphDefElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGAltGlyphDefElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGAltGlyphDefElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGAltGlyphDefElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGAltGlyphDefElementImpl>(p1,const_cast<SVGAltGlyphDefElementImpl *>(this)); +} + +Value SVGAltGlyphDefElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAltGlyphDefElementImpl,KSVGRWBridge<SVGAltGlyphDefElementImpl> >(p1,const_cast<SVGAltGlyphDefElementImpl *>(this))); +} + +bool SVGAltGlyphElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGTSpanElementImpl::hasProperty(p1,p2)) return true; + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGAltGlyphElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGTSpanElementImpl::hasProperty(p1,p2)) return SVGTSpanElementImpl::get(p1,p2,p3); + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return SVGURIReferenceImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGAltGlyphElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGTSpanElementImpl::hasProperty(p1,p2)) { + SVGTSpanElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGURIReferenceImpl::hasProperty(p1,p2)) { + SVGURIReferenceImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGAltGlyphElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGAltGlyphElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGAltGlyphElementImpl>(p1,const_cast<SVGAltGlyphElementImpl *>(this)); +} + +Value SVGAltGlyphElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAltGlyphElementImpl,KSVGRWBridge<SVGAltGlyphElementImpl> >(p1,const_cast<SVGAltGlyphElementImpl *>(this))); +} + +bool SVGAngleImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGAngleImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGAngleImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + return false; +} + +Value SVGAngleImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGAngleImplProtoFunc,SVGAngleImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGAngleImpl *SVGAngleImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGAngleImpl> *test = dynamic_cast<const KSVGBridge<SVGAngleImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGAngleImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGAngleImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + Q_UNUSED(p3); + return Undefined(); +} + +bool SVGAngleImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGAngleImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGAngleImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGAngleImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGAngleImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGAngleImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAngleImpl,KSVGRWBridge<SVGAngleImpl> >(p1,const_cast<SVGAngleImpl *>(this))); +} + +bool SVGAngleImplConstructor::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGAngleImplConstructor::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGAngleImplConstructor::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGAngleImplConstructor>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGAngleImplConstructor::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +Object SVGAngleImplConstructor::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGAngleImplConstructor::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAngleImplConstructor,KSVGBridge<SVGAngleImplConstructor> >(p1,const_cast<SVGAngleImplConstructor *>(this))); +} + +bool SVGAnimateColorElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGAnimationElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGAnimateColorElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGAnimationElementImpl::hasProperty(p1,p2)) return SVGAnimationElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGAnimateColorElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGAnimationElementImpl::hasProperty(p1,p2)) { + SVGAnimationElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGAnimateColorElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGAnimateColorElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGAnimateColorElementImpl>(p1,const_cast<SVGAnimateColorElementImpl *>(this)); +} + +Value SVGAnimateColorElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAnimateColorElementImpl,KSVGRWBridge<SVGAnimateColorElementImpl> >(p1,const_cast<SVGAnimateColorElementImpl *>(this))); +} + +bool SVGAnimateElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGAnimationElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGAnimateElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGAnimationElementImpl::hasProperty(p1,p2)) return SVGAnimationElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGAnimateElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGAnimationElementImpl::hasProperty(p1,p2)) { + SVGAnimationElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGAnimateElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGAnimateElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGAnimateElementImpl>(p1,const_cast<SVGAnimateElementImpl *>(this)); +} + +Value SVGAnimateElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAnimateElementImpl,KSVGRWBridge<SVGAnimateElementImpl> >(p1,const_cast<SVGAnimateElementImpl *>(this))); +} + +bool SVGAnimateMotionElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGAnimationElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGAnimateMotionElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGAnimationElementImpl::hasProperty(p1,p2)) return SVGAnimationElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGAnimateMotionElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGAnimationElementImpl::hasProperty(p1,p2)) { + SVGAnimationElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGAnimateMotionElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGAnimateMotionElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGAnimateMotionElementImpl>(p1,const_cast<SVGAnimateMotionElementImpl *>(this)); +} + +Value SVGAnimateMotionElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAnimateMotionElementImpl,KSVGRWBridge<SVGAnimateMotionElementImpl> >(p1,const_cast<SVGAnimateMotionElementImpl *>(this))); +} + +bool SVGAnimateTransformElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGAnimationElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGAnimateTransformElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGAnimationElementImpl::hasProperty(p1,p2)) return SVGAnimationElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGAnimateTransformElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGAnimationElementImpl::hasProperty(p1,p2)) { + SVGAnimationElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGAnimateTransformElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGAnimateTransformElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGAnimateTransformElementImpl>(p1,const_cast<SVGAnimateTransformElementImpl *>(this)); +} + +Value SVGAnimateTransformElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAnimateTransformElementImpl,KSVGRWBridge<SVGAnimateTransformElementImpl> >(p1,const_cast<SVGAnimateTransformElementImpl *>(this))); +} + +bool SVGAnimatedAngleImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGAnimatedAngleImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGAnimatedAngleImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGAnimatedAngleImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGAnimatedAngleImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +Object SVGAnimatedAngleImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGAnimatedAngleImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAnimatedAngleImpl,KSVGBridge<SVGAnimatedAngleImpl> >(p1,const_cast<SVGAnimatedAngleImpl *>(this))); +} + +bool SVGAnimatedBooleanImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGAnimatedBooleanImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGAnimatedBooleanImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGAnimatedBooleanImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGAnimatedBooleanImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +bool SVGAnimatedBooleanImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGAnimatedBooleanImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGAnimatedBooleanImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGAnimatedBooleanImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGAnimatedBooleanImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAnimatedBooleanImpl,KSVGRWBridge<SVGAnimatedBooleanImpl> >(p1,const_cast<SVGAnimatedBooleanImpl *>(this))); +} + +bool SVGAnimatedEnumerationImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGAnimatedEnumerationImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGAnimatedEnumerationImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGAnimatedEnumerationImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGAnimatedEnumerationImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +bool SVGAnimatedEnumerationImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGAnimatedEnumerationImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGAnimatedEnumerationImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGAnimatedEnumerationImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGAnimatedEnumerationImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAnimatedEnumerationImpl,KSVGRWBridge<SVGAnimatedEnumerationImpl> >(p1,const_cast<SVGAnimatedEnumerationImpl *>(this))); +} + +bool SVGAnimatedIntegerImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGAnimatedIntegerImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGAnimatedIntegerImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGAnimatedIntegerImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGAnimatedIntegerImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +bool SVGAnimatedIntegerImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGAnimatedIntegerImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGAnimatedIntegerImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGAnimatedIntegerImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGAnimatedIntegerImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAnimatedIntegerImpl,KSVGRWBridge<SVGAnimatedIntegerImpl> >(p1,const_cast<SVGAnimatedIntegerImpl *>(this))); +} + +bool SVGAnimatedLengthImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGAnimatedLengthImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGAnimatedLengthImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGAnimatedLengthImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGAnimatedLengthImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +Object SVGAnimatedLengthImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGAnimatedLengthImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAnimatedLengthImpl,KSVGBridge<SVGAnimatedLengthImpl> >(p1,const_cast<SVGAnimatedLengthImpl *>(this))); +} + +bool SVGAnimatedLengthListImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGAnimatedLengthListImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGAnimatedLengthListImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGAnimatedLengthListImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGAnimatedLengthListImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +Object SVGAnimatedLengthListImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGAnimatedLengthListImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAnimatedLengthListImpl,KSVGBridge<SVGAnimatedLengthListImpl> >(p1,const_cast<SVGAnimatedLengthListImpl *>(this))); +} + +bool SVGAnimatedNumberImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGAnimatedNumberImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGAnimatedNumberImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGAnimatedNumberImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGAnimatedNumberImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +bool SVGAnimatedNumberImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGAnimatedNumberImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGAnimatedNumberImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGAnimatedNumberImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGAnimatedNumberImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAnimatedNumberImpl,KSVGRWBridge<SVGAnimatedNumberImpl> >(p1,const_cast<SVGAnimatedNumberImpl *>(this))); +} + +bool SVGAnimatedNumberListImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGAnimatedNumberListImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGAnimatedNumberListImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGAnimatedNumberListImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGAnimatedNumberListImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +Object SVGAnimatedNumberListImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGAnimatedNumberListImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAnimatedNumberListImpl,KSVGBridge<SVGAnimatedNumberListImpl> >(p1,const_cast<SVGAnimatedNumberListImpl *>(this))); +} + +bool SVGAnimatedPathDataImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGAnimatedPathDataImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGAnimatedPathDataImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGAnimatedPathDataImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGAnimatedPathDataImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +Object SVGAnimatedPathDataImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGAnimatedPathDataImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAnimatedPathDataImpl,KSVGBridge<SVGAnimatedPathDataImpl> >(p1,const_cast<SVGAnimatedPathDataImpl *>(this))); +} + +bool SVGAnimatedPointsImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGAnimatedPointsImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGAnimatedPointsImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGAnimatedPointsImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGAnimatedPointsImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +bool SVGAnimatedPointsImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGAnimatedPointsImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGAnimatedPointsImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGAnimatedPointsImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGAnimatedPointsImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAnimatedPointsImpl,KSVGRWBridge<SVGAnimatedPointsImpl> >(p1,const_cast<SVGAnimatedPointsImpl *>(this))); +} + +bool SVGAnimatedPreserveAspectRatioImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGAnimatedPreserveAspectRatioImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGAnimatedPreserveAspectRatioImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGAnimatedPreserveAspectRatioImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGAnimatedPreserveAspectRatioImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +Object SVGAnimatedPreserveAspectRatioImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGAnimatedPreserveAspectRatioImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAnimatedPreserveAspectRatioImpl,KSVGBridge<SVGAnimatedPreserveAspectRatioImpl> >(p1,const_cast<SVGAnimatedPreserveAspectRatioImpl *>(this))); +} + +bool SVGAnimatedRectImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGAnimatedRectImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGAnimatedRectImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGAnimatedRectImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGAnimatedRectImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +Object SVGAnimatedRectImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGAnimatedRectImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAnimatedRectImpl,KSVGBridge<SVGAnimatedRectImpl> >(p1,const_cast<SVGAnimatedRectImpl *>(this))); +} + +bool SVGAnimatedStringImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGAnimatedStringImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGAnimatedStringImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGAnimatedStringImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGAnimatedStringImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +bool SVGAnimatedStringImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGAnimatedStringImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGAnimatedStringImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGAnimatedStringImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGAnimatedStringImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAnimatedStringImpl,KSVGRWBridge<SVGAnimatedStringImpl> >(p1,const_cast<SVGAnimatedStringImpl *>(this))); +} + +bool SVGAnimatedTransformListImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGAnimatedTransformListImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGAnimatedTransformListImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGAnimatedTransformListImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGAnimatedTransformListImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +Object SVGAnimatedTransformListImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGAnimatedTransformListImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAnimatedTransformListImpl,KSVGBridge<SVGAnimatedTransformListImpl> >(p1,const_cast<SVGAnimatedTransformListImpl *>(this))); +} + +bool SVGAnimationElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGAnimationElementImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGAnimationElementImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + if(SVGElementImpl::hasProperty(p1,p2)) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGTestsImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGAnimationElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGAnimationElementImplProtoFunc,SVGAnimationElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGAnimationElementImpl *SVGAnimationElementImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGAnimationElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimationElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimateColorElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimateColorElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimateElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimateElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimateMotionElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimateMotionElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimateTransformElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimateTransformElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGSetElementImpl> *test = dynamic_cast<const KSVGBridge<SVGSetElementImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGAnimationElementImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGAnimationElementImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGTestsImpl::hasProperty(p1,p2)) return SVGTestsImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGAnimationElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGAnimationElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGAnimationElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTestsImpl::hasProperty(p1,p2)) { + SVGTestsImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGAnimationElementImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGAnimationElementImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGAnimationElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGAnimationElementImpl,KSVGRWBridge<SVGAnimationElementImpl> >(p1,const_cast<SVGAnimationElementImpl *>(this))); +} + +bool SVGCircleElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGCircleElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGShapeImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + if(SVGTestsImpl::hasProperty(p1,p2)) return true; + if(SVGTransformableImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGCircleElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGCircleElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGCircleElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGShapeImpl::hasProperty(p1,p2)) return SVGShapeImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + if(SVGTestsImpl::hasProperty(p1,p2)) return SVGTestsImpl::get(p1,p2,p3); + if(SVGTransformableImpl::hasProperty(p1,p2)) return SVGTransformableImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGCircleElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGCircleElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGCircleElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGShapeImpl::hasProperty(p1,p2)) { + SVGShapeImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTestsImpl::hasProperty(p1,p2)) { + SVGTestsImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTransformableImpl::hasProperty(p1,p2)) { + SVGTransformableImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGCircleElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGCircleElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGCircleElementImpl>(p1,const_cast<SVGCircleElementImpl *>(this)); +} + +Value SVGCircleElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGCircleElementImpl,KSVGRWBridge<SVGCircleElementImpl> >(p1,const_cast<SVGCircleElementImpl *>(this))); +} + +bool SVGClipPathElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGClipPathElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGContainerImpl::hasProperty(p1,p2)) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + if(SVGTestsImpl::hasProperty(p1,p2)) return true; + if(SVGTransformableImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGClipPathElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGClipPathElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGClipPathElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGContainerImpl::hasProperty(p1,p2)) return SVGContainerImpl::get(p1,p2,p3); + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + if(SVGTestsImpl::hasProperty(p1,p2)) return SVGTestsImpl::get(p1,p2,p3); + if(SVGTransformableImpl::hasProperty(p1,p2)) return SVGTransformableImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGClipPathElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGClipPathElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGClipPathElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGContainerImpl::hasProperty(p1,p2)) { + SVGContainerImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTestsImpl::hasProperty(p1,p2)) { + SVGTestsImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTransformableImpl::hasProperty(p1,p2)) { + SVGTransformableImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGClipPathElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGClipPathElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGClipPathElementImpl>(p1,const_cast<SVGClipPathElementImpl *>(this)); +} + +Value SVGClipPathElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGClipPathElementImpl,KSVGRWBridge<SVGClipPathElementImpl> >(p1,const_cast<SVGClipPathElementImpl *>(this))); +} + +bool SVGColorImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGColorImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGColorImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + return false; +} + +Value SVGColorImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGColorImplProtoFunc,SVGColorImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGColorImpl *SVGColorImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGColorImpl> *test = dynamic_cast<const KSVGBridge<SVGColorImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPaintImpl> *test = dynamic_cast<const KSVGBridge<SVGPaintImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGColorImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGColorImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + Q_UNUSED(p3); + return Undefined(); +} + +Object SVGColorImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGColorImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGColorImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGColorImpl,KSVGBridge<SVGColorImpl> >(p1,const_cast<SVGColorImpl *>(this))); +} + +bool SVGColorImplConstructor::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGColorImplConstructor::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGColorImplConstructor::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGColorImplConstructor>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGColorImplConstructor::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +Object SVGColorImplConstructor::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGColorImplConstructor::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGColorImplConstructor,KSVGBridge<SVGColorImplConstructor> >(p1,const_cast<SVGColorImplConstructor *>(this))); +} + +bool SVGColorProfileElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGColorProfileElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGElementImpl::hasProperty(p1,p2)) return true; + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGColorProfileElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGColorProfileElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGColorProfileElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return SVGURIReferenceImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGColorProfileElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGColorProfileElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGColorProfileElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGURIReferenceImpl::hasProperty(p1,p2)) { + SVGURIReferenceImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGColorProfileElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGColorProfileElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGColorProfileElementImpl>(p1,const_cast<SVGColorProfileElementImpl *>(this)); +} + +Value SVGColorProfileElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGColorProfileElementImpl,KSVGRWBridge<SVGColorProfileElementImpl> >(p1,const_cast<SVGColorProfileElementImpl *>(this))); +} + +bool SVGComponentTransferFunctionElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGComponentTransferFunctionElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGComponentTransferFunctionElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGComponentTransferFunctionElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGComponentTransferFunctionElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGComponentTransferFunctionElementImpl,KSVGRWBridge<SVGComponentTransferFunctionElementImpl> >(p1,const_cast<SVGComponentTransferFunctionElementImpl *>(this))); +} + +bool SVGContainerImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGShapeImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGContainerImpl::get(GET_METHOD_ARGS) const +{ + if(SVGShapeImpl::hasProperty(p1,p2)) return SVGShapeImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGContainerImpl::put(PUT_METHOD_ARGS) +{ + if(SVGShapeImpl::hasProperty(p1,p2)) { + SVGShapeImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGContainerImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGContainerImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGContainerImpl,KSVGRWBridge<SVGContainerImpl> >(p1,const_cast<SVGContainerImpl *>(this))); +} + +bool SVGCursorElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGCursorElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGElementImpl::hasProperty(p1,p2)) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGTestsImpl::hasProperty(p1,p2)) return true; + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGCursorElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGCursorElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGCursorElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGTestsImpl::hasProperty(p1,p2)) return SVGTestsImpl::get(p1,p2,p3); + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return SVGURIReferenceImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGCursorElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGCursorElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGCursorElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTestsImpl::hasProperty(p1,p2)) { + SVGTestsImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGURIReferenceImpl::hasProperty(p1,p2)) { + SVGURIReferenceImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGCursorElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGCursorElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGCursorElementImpl,KSVGRWBridge<SVGCursorElementImpl> >(p1,const_cast<SVGCursorElementImpl *>(this))); +} + +bool SVGDOMCharacterDataBridge::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGDOMCharacterDataBridge::s_hashTable,p2); + if(e) return true; + Object proto = SVGDOMCharacterDataBridgeProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + if(SVGDOMNodeBridge::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGDOMCharacterDataBridge::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGDOMCharacterDataBridgeProtoFunc,SVGDOMCharacterDataBridge>(p1,p2,&s_hashTable,this,p3); +} + +SVGDOMCharacterDataBridge *SVGDOMCharacterDataBridgeProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGDOMCharacterDataBridge> *test = dynamic_cast<const KSVGBridge<SVGDOMCharacterDataBridge> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGDOMTextBridge> *test = dynamic_cast<const KSVGBridge<SVGDOMTextBridge> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGDOMCharacterDataBridge::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGDOMCharacterDataBridgeProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + if(SVGDOMNodeBridge::hasProperty(p1,p2)) return SVGDOMNodeBridge::get(p1,p2,p3); + return Undefined(); +} + +bool SVGDOMCharacterDataBridge::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGDOMCharacterDataBridge>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGDOMCharacterDataBridge::putInParents(PUT_METHOD_ARGS) +{ + if(SVGDOMNodeBridge::hasProperty(p1,p2)) { + SVGDOMNodeBridge::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGDOMCharacterDataBridge::prototype(ExecState *p1) const +{ + if(p1) return SVGDOMCharacterDataBridgeProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGDOMCharacterDataBridge::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGDOMCharacterDataBridge,KSVGRWBridge<SVGDOMCharacterDataBridge> >(p1,const_cast<SVGDOMCharacterDataBridge *>(this))); +} + +bool SVGDOMDOMImplementationBridge::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGDOMDOMImplementationBridge::s_hashTable,p2); + if(e) return true; + Object proto = SVGDOMDOMImplementationBridgeProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + return false; +} + +Value SVGDOMDOMImplementationBridge::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGDOMDOMImplementationBridgeProtoFunc,SVGDOMDOMImplementationBridge>(p1,p2,&s_hashTable,this,p3); +} + +SVGDOMDOMImplementationBridge *SVGDOMDOMImplementationBridgeProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGDOMDOMImplementationBridge> *test = dynamic_cast<const KSVGBridge<SVGDOMDOMImplementationBridge> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGDOMDOMImplementationBridge::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGDOMDOMImplementationBridgeProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + Q_UNUSED(p3); + return Undefined(); +} + +bool SVGDOMDOMImplementationBridge::put(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGDOMDOMImplementationBridge::prototype(ExecState *p1) const +{ + if(p1) return SVGDOMDOMImplementationBridgeProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGDOMDOMImplementationBridge::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGDOMDOMImplementationBridge,KSVGRWBridge<SVGDOMDOMImplementationBridge> >(p1,const_cast<SVGDOMDOMImplementationBridge *>(this))); +} + +bool SVGDOMDocumentFragmentBridge::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGDOMDocumentFragmentBridge::s_hashTable,p2); + if(e) return true; + if(SVGDOMNodeBridge::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGDOMDocumentFragmentBridge::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGDOMDocumentFragmentBridge>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGDOMDocumentFragmentBridge::getInParents(GET_METHOD_ARGS) const +{ + if(SVGDOMNodeBridge::hasProperty(p1,p2)) return SVGDOMNodeBridge::get(p1,p2,p3); + return Undefined(); +} + +bool SVGDOMDocumentFragmentBridge::put(PUT_METHOD_ARGS) +{ + if(SVGDOMNodeBridge::hasProperty(p1,p2)) { + SVGDOMNodeBridge::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGDOMDocumentFragmentBridge::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGDOMDocumentFragmentBridge::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGDOMDocumentFragmentBridge,KSVGRWBridge<SVGDOMDocumentFragmentBridge> >(p1,const_cast<SVGDOMDocumentFragmentBridge *>(this))); +} + +bool SVGDOMElementBridge::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGDOMElementBridge::s_hashTable,p2); + if(e) return true; + Object proto = SVGDOMElementBridgeProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + if(SVGDOMNodeBridge::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGDOMElementBridge::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGDOMElementBridgeProtoFunc,SVGDOMElementBridge>(p1,p2,&s_hashTable,this,p3); +} + +SVGDOMElementBridge *SVGDOMElementBridgeProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGDOMElementBridge> *test = dynamic_cast<const KSVGBridge<SVGDOMElementBridge> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAltGlyphDefElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAltGlyphDefElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAltGlyphElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAltGlyphElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimateColorElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimateColorElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimateElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimateElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimateMotionElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimateMotionElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimateTransformElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimateTransformElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimationElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimationElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGCircleElementImpl> *test = dynamic_cast<const KSVGBridge<SVGCircleElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGClipPathElementImpl> *test = dynamic_cast<const KSVGBridge<SVGClipPathElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGColorProfileElementImpl> *test = dynamic_cast<const KSVGBridge<SVGColorProfileElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGComponentTransferFunctionElementImpl> *test = dynamic_cast<const KSVGBridge<SVGComponentTransferFunctionElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGContainerImpl> *test = dynamic_cast<const KSVGBridge<SVGContainerImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGCursorElementImpl> *test = dynamic_cast<const KSVGBridge<SVGCursorElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGDefinitionSrcElementImpl> *test = dynamic_cast<const KSVGBridge<SVGDefinitionSrcElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGDefsElementImpl> *test = dynamic_cast<const KSVGBridge<SVGDefsElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGDescElementImpl> *test = dynamic_cast<const KSVGBridge<SVGDescElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGElementImpl> *test = dynamic_cast<const KSVGBridge<SVGElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGEllipseElementImpl> *test = dynamic_cast<const KSVGBridge<SVGEllipseElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEBlendElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEBlendElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEColorMatrixElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEColorMatrixElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEComponentTransferElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEComponentTransferElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFECompositeElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFECompositeElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEConvolveMatrixElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEConvolveMatrixElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEDiffuseLightingElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEDiffuseLightingElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEDisplacementMapElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEDisplacementMapElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEDistantLightElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEDistantLightElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEFloodElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEFloodElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEFuncAElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEFuncAElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEFuncBElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEFuncBElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEFuncGElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEFuncGElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEFuncRElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEFuncRElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEGaussianBlurElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEGaussianBlurElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEImageElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEImageElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEMergeElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEMergeElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEMergeNodeElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEMergeNodeElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEMorphologyElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEMorphologyElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEOffsetElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEOffsetElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEPointLightElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEPointLightElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFESpecularLightingElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFESpecularLightingElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFESpotLightElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFESpotLightElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFETileElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFETileElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFETurbulenceElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFETurbulenceElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFilterElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFilterElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFontElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFontElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFontFaceElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFontFaceElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFontFaceFormatElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFontFaceFormatElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFontFaceNameElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFontFaceNameElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFontFaceSrcElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFontFaceSrcElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFontFaceUriElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFontFaceUriElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGForeignObjectElementImpl> *test = dynamic_cast<const KSVGBridge<SVGForeignObjectElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGGElementImpl> *test = dynamic_cast<const KSVGBridge<SVGGElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGGlyphElementImpl> *test = dynamic_cast<const KSVGBridge<SVGGlyphElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGGlyphRefElementImpl> *test = dynamic_cast<const KSVGBridge<SVGGlyphRefElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGGradientElementImpl> *test = dynamic_cast<const KSVGBridge<SVGGradientElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGHKernElementImpl> *test = dynamic_cast<const KSVGBridge<SVGHKernElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGImageElementImpl> *test = dynamic_cast<const KSVGBridge<SVGImageElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGLineElementImpl> *test = dynamic_cast<const KSVGBridge<SVGLineElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGLinearGradientElementImpl> *test = dynamic_cast<const KSVGBridge<SVGLinearGradientElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGMPathElementImpl> *test = dynamic_cast<const KSVGBridge<SVGMPathElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGMarkerElementImpl> *test = dynamic_cast<const KSVGBridge<SVGMarkerElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGMaskElementImpl> *test = dynamic_cast<const KSVGBridge<SVGMaskElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGMetadataElementImpl> *test = dynamic_cast<const KSVGBridge<SVGMetadataElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGMissingGlyphElementImpl> *test = dynamic_cast<const KSVGBridge<SVGMissingGlyphElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPathElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPathElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPatternElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPatternElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPolyElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPolyElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPolygonElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPolygonElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPolylineElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPolylineElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGRadialGradientElementImpl> *test = dynamic_cast<const KSVGBridge<SVGRadialGradientElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGRectElementImpl> *test = dynamic_cast<const KSVGBridge<SVGRectElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGSVGElementImpl> *test = dynamic_cast<const KSVGBridge<SVGSVGElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGScriptElementImpl> *test = dynamic_cast<const KSVGBridge<SVGScriptElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGSetElementImpl> *test = dynamic_cast<const KSVGBridge<SVGSetElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGShapeImpl> *test = dynamic_cast<const KSVGBridge<SVGShapeImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGStopElementImpl> *test = dynamic_cast<const KSVGBridge<SVGStopElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGStyleElementImpl> *test = dynamic_cast<const KSVGBridge<SVGStyleElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGSwitchElementImpl> *test = dynamic_cast<const KSVGBridge<SVGSwitchElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGSymbolElementImpl> *test = dynamic_cast<const KSVGBridge<SVGSymbolElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTRefElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTRefElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTSpanElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTSpanElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextContentElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextContentElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextPathElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextPathElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextPositioningElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextPositioningElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTitleElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTitleElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGUseElementImpl> *test = dynamic_cast<const KSVGBridge<SVGUseElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGVKernElementImpl> *test = dynamic_cast<const KSVGBridge<SVGVKernElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGViewElementImpl> *test = dynamic_cast<const KSVGBridge<SVGViewElementImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGDOMElementBridge::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGDOMElementBridgeProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + if(SVGDOMNodeBridge::hasProperty(p1,p2)) return SVGDOMNodeBridge::get(p1,p2,p3); + return Undefined(); +} + +bool SVGDOMElementBridge::put(PUT_METHOD_ARGS) +{ + if(SVGDOMNodeBridge::hasProperty(p1,p2)) { + SVGDOMNodeBridge::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGDOMElementBridge::prototype(ExecState *p1) const +{ + if(p1) return SVGDOMElementBridgeProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGDOMElementBridge::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGDOMElementBridge,KSVGRWBridge<SVGDOMElementBridge> >(p1,const_cast<SVGDOMElementBridge *>(this))); +} + +bool SVGDOMNodeBridge::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGDOMNodeBridge::s_hashTable,p2); + if(e) return true; + Object proto = SVGDOMNodeBridgeProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + return false; +} + +Value SVGDOMNodeBridge::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGDOMNodeBridgeProtoFunc,SVGDOMNodeBridge>(p1,p2,&s_hashTable,this,p3); +} + +SVGDOMNodeBridge *SVGDOMNodeBridgeProtoFunc::cast(const ObjectImp *p1) const +{ + return KSVG::toNodeBridge(p1); +} + +SVGDOMNodeBridge *KSVG::toNodeBridge(const ObjectImp *p1) +{ + { const KSVGBridge<SVGDOMNodeBridge> *test = dynamic_cast<const KSVGBridge<SVGDOMNodeBridge> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAltGlyphDefElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAltGlyphDefElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAltGlyphElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAltGlyphElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimateColorElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimateColorElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimateElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimateElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimateMotionElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimateMotionElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimateTransformElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimateTransformElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimationElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimationElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGCircleElementImpl> *test = dynamic_cast<const KSVGBridge<SVGCircleElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGClipPathElementImpl> *test = dynamic_cast<const KSVGBridge<SVGClipPathElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGColorProfileElementImpl> *test = dynamic_cast<const KSVGBridge<SVGColorProfileElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGComponentTransferFunctionElementImpl> *test = dynamic_cast<const KSVGBridge<SVGComponentTransferFunctionElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGContainerImpl> *test = dynamic_cast<const KSVGBridge<SVGContainerImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGCursorElementImpl> *test = dynamic_cast<const KSVGBridge<SVGCursorElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGDOMCharacterDataBridge> *test = dynamic_cast<const KSVGBridge<SVGDOMCharacterDataBridge> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGDOMDocumentFragmentBridge> *test = dynamic_cast<const KSVGBridge<SVGDOMDocumentFragmentBridge> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGDOMElementBridge> *test = dynamic_cast<const KSVGBridge<SVGDOMElementBridge> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGDOMTextBridge> *test = dynamic_cast<const KSVGBridge<SVGDOMTextBridge> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGDefinitionSrcElementImpl> *test = dynamic_cast<const KSVGBridge<SVGDefinitionSrcElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGDefsElementImpl> *test = dynamic_cast<const KSVGBridge<SVGDefsElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGDescElementImpl> *test = dynamic_cast<const KSVGBridge<SVGDescElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGDocumentImpl> *test = dynamic_cast<const KSVGBridge<SVGDocumentImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGElementImpl> *test = dynamic_cast<const KSVGBridge<SVGElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGEllipseElementImpl> *test = dynamic_cast<const KSVGBridge<SVGEllipseElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEBlendElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEBlendElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEColorMatrixElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEColorMatrixElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEComponentTransferElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEComponentTransferElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFECompositeElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFECompositeElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEConvolveMatrixElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEConvolveMatrixElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEDiffuseLightingElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEDiffuseLightingElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEDisplacementMapElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEDisplacementMapElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEDistantLightElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEDistantLightElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEFloodElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEFloodElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEFuncAElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEFuncAElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEFuncBElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEFuncBElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEFuncGElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEFuncGElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEFuncRElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEFuncRElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEGaussianBlurElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEGaussianBlurElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEImageElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEImageElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEMergeElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEMergeElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEMergeNodeElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEMergeNodeElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEMorphologyElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEMorphologyElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEOffsetElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEOffsetElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEPointLightElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEPointLightElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFESpecularLightingElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFESpecularLightingElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFESpotLightElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFESpotLightElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFETileElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFETileElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFETurbulenceElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFETurbulenceElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFilterElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFilterElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFontElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFontElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFontFaceElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFontFaceElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFontFaceFormatElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFontFaceFormatElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFontFaceNameElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFontFaceNameElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFontFaceSrcElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFontFaceSrcElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFontFaceUriElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFontFaceUriElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGForeignObjectElementImpl> *test = dynamic_cast<const KSVGBridge<SVGForeignObjectElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGGElementImpl> *test = dynamic_cast<const KSVGBridge<SVGGElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGGlyphElementImpl> *test = dynamic_cast<const KSVGBridge<SVGGlyphElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGGlyphRefElementImpl> *test = dynamic_cast<const KSVGBridge<SVGGlyphRefElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGGradientElementImpl> *test = dynamic_cast<const KSVGBridge<SVGGradientElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGHKernElementImpl> *test = dynamic_cast<const KSVGBridge<SVGHKernElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGImageElementImpl> *test = dynamic_cast<const KSVGBridge<SVGImageElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGLineElementImpl> *test = dynamic_cast<const KSVGBridge<SVGLineElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGLinearGradientElementImpl> *test = dynamic_cast<const KSVGBridge<SVGLinearGradientElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGMPathElementImpl> *test = dynamic_cast<const KSVGBridge<SVGMPathElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGMarkerElementImpl> *test = dynamic_cast<const KSVGBridge<SVGMarkerElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGMaskElementImpl> *test = dynamic_cast<const KSVGBridge<SVGMaskElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGMetadataElementImpl> *test = dynamic_cast<const KSVGBridge<SVGMetadataElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGMissingGlyphElementImpl> *test = dynamic_cast<const KSVGBridge<SVGMissingGlyphElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPathElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPathElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPatternElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPatternElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPolyElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPolyElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPolygonElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPolygonElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPolylineElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPolylineElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGRadialGradientElementImpl> *test = dynamic_cast<const KSVGBridge<SVGRadialGradientElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGRectElementImpl> *test = dynamic_cast<const KSVGBridge<SVGRectElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGSVGElementImpl> *test = dynamic_cast<const KSVGBridge<SVGSVGElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGScriptElementImpl> *test = dynamic_cast<const KSVGBridge<SVGScriptElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGSetElementImpl> *test = dynamic_cast<const KSVGBridge<SVGSetElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGShapeImpl> *test = dynamic_cast<const KSVGBridge<SVGShapeImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGStopElementImpl> *test = dynamic_cast<const KSVGBridge<SVGStopElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGStyleElementImpl> *test = dynamic_cast<const KSVGBridge<SVGStyleElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGSwitchElementImpl> *test = dynamic_cast<const KSVGBridge<SVGSwitchElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGSymbolElementImpl> *test = dynamic_cast<const KSVGBridge<SVGSymbolElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTRefElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTRefElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTSpanElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTSpanElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextContentElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextContentElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextPathElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextPathElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextPositioningElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextPositioningElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTitleElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTitleElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGUseElementImpl> *test = dynamic_cast<const KSVGBridge<SVGUseElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGVKernElementImpl> *test = dynamic_cast<const KSVGBridge<SVGVKernElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGViewElementImpl> *test = dynamic_cast<const KSVGBridge<SVGViewElementImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGDOMNodeBridge::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGDOMNodeBridgeProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + Q_UNUSED(p3); + return Undefined(); +} + +bool SVGDOMNodeBridge::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGDOMNodeBridge>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGDOMNodeBridge::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGDOMNodeBridge::prototype(ExecState *p1) const +{ + if(p1) return SVGDOMNodeBridgeProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGDOMNodeBridge::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGDOMNodeBridge,KSVGRWBridge<SVGDOMNodeBridge> >(p1,const_cast<SVGDOMNodeBridge *>(this))); +} + +bool SVGDOMNodeListBridge::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGDOMNodeListBridge::s_hashTable,p2); + if(e) return true; + Object proto = SVGDOMNodeListBridgeProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + return false; +} + +Value SVGDOMNodeListBridge::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGDOMNodeListBridgeProtoFunc,SVGDOMNodeListBridge>(p1,p2,&s_hashTable,this,p3); +} + +SVGDOMNodeListBridge *SVGDOMNodeListBridgeProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGDOMNodeListBridge> *test = dynamic_cast<const KSVGBridge<SVGDOMNodeListBridge> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGDOMNodeListBridge::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGDOMNodeListBridgeProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + Q_UNUSED(p3); + return Undefined(); +} + +Object SVGDOMNodeListBridge::prototype(ExecState *p1) const +{ + if(p1) return SVGDOMNodeListBridgeProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGDOMNodeListBridge::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGDOMNodeListBridge,KSVGBridge<SVGDOMNodeListBridge> >(p1,const_cast<SVGDOMNodeListBridge *>(this))); +} + +bool SVGDOMTextBridge::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGDOMTextBridge::s_hashTable,p2); + if(e) return true; + Object proto = SVGDOMTextBridgeProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + if(SVGDOMCharacterDataBridge::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGDOMTextBridge::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGDOMTextBridgeProtoFunc,SVGDOMTextBridge>(p1,p2,&s_hashTable,this,p3); +} + +SVGDOMTextBridge *SVGDOMTextBridgeProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGDOMTextBridge> *test = dynamic_cast<const KSVGBridge<SVGDOMTextBridge> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGDOMTextBridge::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGDOMTextBridgeProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + if(SVGDOMCharacterDataBridge::hasProperty(p1,p2)) return SVGDOMCharacterDataBridge::get(p1,p2,p3); + return Undefined(); +} + +bool SVGDOMTextBridge::put(PUT_METHOD_ARGS) +{ + if(SVGDOMCharacterDataBridge::hasProperty(p1,p2)) { + SVGDOMCharacterDataBridge::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGDOMTextBridge::prototype(ExecState *p1) const +{ + if(p1) return SVGDOMTextBridgeProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGDOMTextBridge::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGDOMTextBridge,KSVGRWBridge<SVGDOMTextBridge> >(p1,const_cast<SVGDOMTextBridge *>(this))); +} + +bool SVGDefinitionSrcElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGDefinitionSrcElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGDefinitionSrcElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGDefinitionSrcElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGDefinitionSrcElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGDefinitionSrcElementImpl,KSVGRWBridge<SVGDefinitionSrcElementImpl> >(p1,const_cast<SVGDefinitionSrcElementImpl *>(this))); +} + +bool SVGDefsElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGContainerImpl::hasProperty(p1,p2)) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + if(SVGTestsImpl::hasProperty(p1,p2)) return true; + if(SVGTransformableImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGDefsElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGContainerImpl::hasProperty(p1,p2)) return SVGContainerImpl::get(p1,p2,p3); + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + if(SVGTestsImpl::hasProperty(p1,p2)) return SVGTestsImpl::get(p1,p2,p3); + if(SVGTransformableImpl::hasProperty(p1,p2)) return SVGTransformableImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGDefsElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGContainerImpl::hasProperty(p1,p2)) { + SVGContainerImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTestsImpl::hasProperty(p1,p2)) { + SVGTestsImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTransformableImpl::hasProperty(p1,p2)) { + SVGTransformableImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGDefsElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGDefsElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGDefsElementImpl>(p1,const_cast<SVGDefsElementImpl *>(this)); +} + +Value SVGDefsElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGDefsElementImpl,KSVGRWBridge<SVGDefsElementImpl> >(p1,const_cast<SVGDefsElementImpl *>(this))); +} + +bool SVGDescElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGDescElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGDescElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGDescElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGDescElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGDescElementImpl>(p1,const_cast<SVGDescElementImpl *>(this)); +} + +Value SVGDescElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGDescElementImpl,KSVGRWBridge<SVGDescElementImpl> >(p1,const_cast<SVGDescElementImpl *>(this))); +} + +bool SVGDocumentImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGDocumentImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGDocumentImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + if(SVGDOMNodeBridge::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGDocumentImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGDocumentImplProtoFunc,SVGDocumentImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGDocumentImpl *SVGDocumentImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGDocumentImpl> *test = dynamic_cast<const KSVGBridge<SVGDocumentImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGDocumentImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGDocumentImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + if(SVGDOMNodeBridge::hasProperty(p1,p2)) return SVGDOMNodeBridge::get(p1,p2,p3); + return Undefined(); +} + +bool SVGDocumentImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGDocumentImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGDocumentImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGDOMNodeBridge::hasProperty(p1,p2)) { + SVGDOMNodeBridge::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGDocumentImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGDocumentImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGDocumentImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGDocumentImpl,KSVGRWBridge<SVGDocumentImpl> >(p1,const_cast<SVGDocumentImpl *>(this))); +} + +bool SVGElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGElementImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGElementImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + if(SVGDOMElementBridge::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGElementImplProtoFunc,SVGElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGElementImpl *SVGElementImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGElementImpl> *test = dynamic_cast<const KSVGBridge<SVGElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAltGlyphDefElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAltGlyphDefElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAltGlyphElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAltGlyphElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimateColorElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimateColorElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimateElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimateElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimateMotionElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimateMotionElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimateTransformElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimateTransformElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimationElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimationElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGCircleElementImpl> *test = dynamic_cast<const KSVGBridge<SVGCircleElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGClipPathElementImpl> *test = dynamic_cast<const KSVGBridge<SVGClipPathElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGColorProfileElementImpl> *test = dynamic_cast<const KSVGBridge<SVGColorProfileElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGComponentTransferFunctionElementImpl> *test = dynamic_cast<const KSVGBridge<SVGComponentTransferFunctionElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGContainerImpl> *test = dynamic_cast<const KSVGBridge<SVGContainerImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGCursorElementImpl> *test = dynamic_cast<const KSVGBridge<SVGCursorElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGDefinitionSrcElementImpl> *test = dynamic_cast<const KSVGBridge<SVGDefinitionSrcElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGDefsElementImpl> *test = dynamic_cast<const KSVGBridge<SVGDefsElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGDescElementImpl> *test = dynamic_cast<const KSVGBridge<SVGDescElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGEllipseElementImpl> *test = dynamic_cast<const KSVGBridge<SVGEllipseElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEBlendElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEBlendElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEColorMatrixElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEColorMatrixElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEComponentTransferElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEComponentTransferElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFECompositeElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFECompositeElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEConvolveMatrixElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEConvolveMatrixElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEDiffuseLightingElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEDiffuseLightingElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEDisplacementMapElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEDisplacementMapElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEDistantLightElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEDistantLightElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEFloodElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEFloodElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEFuncAElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEFuncAElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEFuncBElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEFuncBElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEFuncGElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEFuncGElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEFuncRElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEFuncRElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEGaussianBlurElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEGaussianBlurElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEImageElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEImageElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEMergeElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEMergeElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEMergeNodeElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEMergeNodeElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEMorphologyElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEMorphologyElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEOffsetElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEOffsetElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEPointLightElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEPointLightElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFESpecularLightingElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFESpecularLightingElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFESpotLightElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFESpotLightElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFETileElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFETileElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFETurbulenceElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFETurbulenceElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFilterElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFilterElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFontElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFontElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFontFaceElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFontFaceElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFontFaceFormatElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFontFaceFormatElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFontFaceNameElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFontFaceNameElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFontFaceSrcElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFontFaceSrcElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFontFaceUriElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFontFaceUriElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGForeignObjectElementImpl> *test = dynamic_cast<const KSVGBridge<SVGForeignObjectElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGGElementImpl> *test = dynamic_cast<const KSVGBridge<SVGGElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGGlyphElementImpl> *test = dynamic_cast<const KSVGBridge<SVGGlyphElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGGlyphRefElementImpl> *test = dynamic_cast<const KSVGBridge<SVGGlyphRefElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGGradientElementImpl> *test = dynamic_cast<const KSVGBridge<SVGGradientElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGHKernElementImpl> *test = dynamic_cast<const KSVGBridge<SVGHKernElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGImageElementImpl> *test = dynamic_cast<const KSVGBridge<SVGImageElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGLineElementImpl> *test = dynamic_cast<const KSVGBridge<SVGLineElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGLinearGradientElementImpl> *test = dynamic_cast<const KSVGBridge<SVGLinearGradientElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGMPathElementImpl> *test = dynamic_cast<const KSVGBridge<SVGMPathElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGMarkerElementImpl> *test = dynamic_cast<const KSVGBridge<SVGMarkerElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGMaskElementImpl> *test = dynamic_cast<const KSVGBridge<SVGMaskElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGMetadataElementImpl> *test = dynamic_cast<const KSVGBridge<SVGMetadataElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGMissingGlyphElementImpl> *test = dynamic_cast<const KSVGBridge<SVGMissingGlyphElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPathElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPathElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPatternElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPatternElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPolyElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPolyElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPolygonElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPolygonElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPolylineElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPolylineElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGRadialGradientElementImpl> *test = dynamic_cast<const KSVGBridge<SVGRadialGradientElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGRectElementImpl> *test = dynamic_cast<const KSVGBridge<SVGRectElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGSVGElementImpl> *test = dynamic_cast<const KSVGBridge<SVGSVGElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGScriptElementImpl> *test = dynamic_cast<const KSVGBridge<SVGScriptElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGSetElementImpl> *test = dynamic_cast<const KSVGBridge<SVGSetElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGShapeImpl> *test = dynamic_cast<const KSVGBridge<SVGShapeImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGStopElementImpl> *test = dynamic_cast<const KSVGBridge<SVGStopElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGStyleElementImpl> *test = dynamic_cast<const KSVGBridge<SVGStyleElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGSwitchElementImpl> *test = dynamic_cast<const KSVGBridge<SVGSwitchElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGSymbolElementImpl> *test = dynamic_cast<const KSVGBridge<SVGSymbolElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTRefElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTRefElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTSpanElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTSpanElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextContentElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextContentElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextPathElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextPathElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextPositioningElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextPositioningElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTitleElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTitleElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGUseElementImpl> *test = dynamic_cast<const KSVGBridge<SVGUseElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGVKernElementImpl> *test = dynamic_cast<const KSVGBridge<SVGVKernElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGViewElementImpl> *test = dynamic_cast<const KSVGBridge<SVGViewElementImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGElementImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGElementImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + if(SVGDOMElementBridge::hasProperty(p1,p2)) return SVGDOMElementBridge::get(p1,p2,p3); + return Undefined(); +} + +bool SVGElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGDOMElementBridge::hasProperty(p1,p2)) { + SVGDOMElementBridge::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGElementImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGElementImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGElementImpl>(p1,const_cast<SVGElementImpl *>(this)); +} + +Value SVGElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGElementImpl,KSVGRWBridge<SVGElementImpl> >(p1,const_cast<SVGElementImpl *>(this))); +} + +bool SVGEllipseElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGEllipseElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGShapeImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + if(SVGTestsImpl::hasProperty(p1,p2)) return true; + if(SVGTransformableImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGEllipseElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGEllipseElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGEllipseElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGShapeImpl::hasProperty(p1,p2)) return SVGShapeImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + if(SVGTestsImpl::hasProperty(p1,p2)) return SVGTestsImpl::get(p1,p2,p3); + if(SVGTransformableImpl::hasProperty(p1,p2)) return SVGTransformableImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGEllipseElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGEllipseElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGEllipseElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGShapeImpl::hasProperty(p1,p2)) { + SVGShapeImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTestsImpl::hasProperty(p1,p2)) { + SVGTestsImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTransformableImpl::hasProperty(p1,p2)) { + SVGTransformableImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGEllipseElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGEllipseElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGEllipseElementImpl>(p1,const_cast<SVGEllipseElementImpl *>(this)); +} + +Value SVGEllipseElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGEllipseElementImpl,KSVGRWBridge<SVGEllipseElementImpl> >(p1,const_cast<SVGEllipseElementImpl *>(this))); +} + +bool SVGEventImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGEventImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGEventImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + return false; +} + +Value SVGEventImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGEventImplProtoFunc,SVGEventImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGEventImpl *SVGEventImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGEventImpl> *test = dynamic_cast<const KSVGBridge<SVGEventImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGKeyEventImpl> *test = dynamic_cast<const KSVGBridge<SVGKeyEventImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGMouseEventImpl> *test = dynamic_cast<const KSVGBridge<SVGMouseEventImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGMutationEventImpl> *test = dynamic_cast<const KSVGBridge<SVGMutationEventImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGUIEventImpl> *test = dynamic_cast<const KSVGBridge<SVGUIEventImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGZoomEventImpl> *test = dynamic_cast<const KSVGBridge<SVGZoomEventImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGEventImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGEventImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + Q_UNUSED(p3); + return Undefined(); +} + +Object SVGEventImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGEventImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGEventImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGEventImpl,KSVGBridge<SVGEventImpl> >(p1,const_cast<SVGEventImpl *>(this))); +} + +bool SVGExternalResourcesRequiredImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGExternalResourcesRequiredImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGExternalResourcesRequiredImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGExternalResourcesRequiredImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGExternalResourcesRequiredImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +bool SVGExternalResourcesRequiredImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGExternalResourcesRequiredImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGExternalResourcesRequiredImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGExternalResourcesRequiredImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGExternalResourcesRequiredImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGExternalResourcesRequiredImpl,KSVGRWBridge<SVGExternalResourcesRequiredImpl> >(p1,const_cast<SVGExternalResourcesRequiredImpl *>(this))); +} + +bool SVGFEBlendElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFEBlendElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFEBlendElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFEBlendElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFEBlendElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFEBlendElementImpl,KSVGRWBridge<SVGFEBlendElementImpl> >(p1,const_cast<SVGFEBlendElementImpl *>(this))); +} + +bool SVGFEColorMatrixElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFEColorMatrixElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFEColorMatrixElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFEColorMatrixElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFEColorMatrixElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFEColorMatrixElementImpl,KSVGRWBridge<SVGFEColorMatrixElementImpl> >(p1,const_cast<SVGFEColorMatrixElementImpl *>(this))); +} + +bool SVGFEComponentTransferElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFEComponentTransferElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFEComponentTransferElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFEComponentTransferElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFEComponentTransferElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFEComponentTransferElementImpl,KSVGRWBridge<SVGFEComponentTransferElementImpl> >(p1,const_cast<SVGFEComponentTransferElementImpl *>(this))); +} + +bool SVGFECompositeElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFECompositeElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFECompositeElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFECompositeElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFECompositeElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFECompositeElementImpl,KSVGRWBridge<SVGFECompositeElementImpl> >(p1,const_cast<SVGFECompositeElementImpl *>(this))); +} + +bool SVGFEConvolveMatrixElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFEConvolveMatrixElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFEConvolveMatrixElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFEConvolveMatrixElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFEConvolveMatrixElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFEConvolveMatrixElementImpl,KSVGRWBridge<SVGFEConvolveMatrixElementImpl> >(p1,const_cast<SVGFEConvolveMatrixElementImpl *>(this))); +} + +bool SVGFEDiffuseLightingElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFEDiffuseLightingElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFEDiffuseLightingElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFEDiffuseLightingElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFEDiffuseLightingElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFEDiffuseLightingElementImpl,KSVGRWBridge<SVGFEDiffuseLightingElementImpl> >(p1,const_cast<SVGFEDiffuseLightingElementImpl *>(this))); +} + +bool SVGFEDisplacementMapElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFEDisplacementMapElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFEDisplacementMapElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFEDisplacementMapElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFEDisplacementMapElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFEDisplacementMapElementImpl,KSVGRWBridge<SVGFEDisplacementMapElementImpl> >(p1,const_cast<SVGFEDisplacementMapElementImpl *>(this))); +} + +bool SVGFEDistantLightElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFEDistantLightElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFEDistantLightElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFEDistantLightElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFEDistantLightElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFEDistantLightElementImpl,KSVGRWBridge<SVGFEDistantLightElementImpl> >(p1,const_cast<SVGFEDistantLightElementImpl *>(this))); +} + +bool SVGFEFloodElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFEFloodElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFEFloodElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFEFloodElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFEFloodElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFEFloodElementImpl,KSVGRWBridge<SVGFEFloodElementImpl> >(p1,const_cast<SVGFEFloodElementImpl *>(this))); +} + +bool SVGFEFuncAElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGComponentTransferFunctionElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFEFuncAElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGComponentTransferFunctionElementImpl::hasProperty(p1,p2)) return SVGComponentTransferFunctionElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFEFuncAElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGComponentTransferFunctionElementImpl::hasProperty(p1,p2)) { + SVGComponentTransferFunctionElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFEFuncAElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFEFuncAElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFEFuncAElementImpl,KSVGRWBridge<SVGFEFuncAElementImpl> >(p1,const_cast<SVGFEFuncAElementImpl *>(this))); +} + +bool SVGFEFuncBElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGComponentTransferFunctionElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFEFuncBElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGComponentTransferFunctionElementImpl::hasProperty(p1,p2)) return SVGComponentTransferFunctionElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFEFuncBElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGComponentTransferFunctionElementImpl::hasProperty(p1,p2)) { + SVGComponentTransferFunctionElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFEFuncBElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFEFuncBElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFEFuncBElementImpl,KSVGRWBridge<SVGFEFuncBElementImpl> >(p1,const_cast<SVGFEFuncBElementImpl *>(this))); +} + +bool SVGFEFuncGElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGComponentTransferFunctionElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFEFuncGElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGComponentTransferFunctionElementImpl::hasProperty(p1,p2)) return SVGComponentTransferFunctionElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFEFuncGElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGComponentTransferFunctionElementImpl::hasProperty(p1,p2)) { + SVGComponentTransferFunctionElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFEFuncGElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFEFuncGElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFEFuncGElementImpl,KSVGRWBridge<SVGFEFuncGElementImpl> >(p1,const_cast<SVGFEFuncGElementImpl *>(this))); +} + +bool SVGFEFuncRElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGComponentTransferFunctionElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFEFuncRElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGComponentTransferFunctionElementImpl::hasProperty(p1,p2)) return SVGComponentTransferFunctionElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFEFuncRElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGComponentTransferFunctionElementImpl::hasProperty(p1,p2)) { + SVGComponentTransferFunctionElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFEFuncRElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFEFuncRElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFEFuncRElementImpl,KSVGRWBridge<SVGFEFuncRElementImpl> >(p1,const_cast<SVGFEFuncRElementImpl *>(this))); +} + +bool SVGFEGaussianBlurElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFEGaussianBlurElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFEGaussianBlurElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFEGaussianBlurElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFEGaussianBlurElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFEGaussianBlurElementImpl,KSVGRWBridge<SVGFEGaussianBlurElementImpl> >(p1,const_cast<SVGFEGaussianBlurElementImpl *>(this))); +} + +bool SVGFEImageElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFEImageElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return SVGURIReferenceImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFEImageElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGURIReferenceImpl::hasProperty(p1,p2)) { + SVGURIReferenceImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFEImageElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFEImageElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFEImageElementImpl,KSVGRWBridge<SVGFEImageElementImpl> >(p1,const_cast<SVGFEImageElementImpl *>(this))); +} + +bool SVGFEMergeElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFEMergeElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFEMergeElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFEMergeElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFEMergeElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFEMergeElementImpl,KSVGRWBridge<SVGFEMergeElementImpl> >(p1,const_cast<SVGFEMergeElementImpl *>(this))); +} + +bool SVGFEMergeNodeElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFEMergeNodeElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFEMergeNodeElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFEMergeNodeElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFEMergeNodeElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFEMergeNodeElementImpl,KSVGRWBridge<SVGFEMergeNodeElementImpl> >(p1,const_cast<SVGFEMergeNodeElementImpl *>(this))); +} + +bool SVGFEMorphologyElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFEMorphologyElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFEMorphologyElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFEMorphologyElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFEMorphologyElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFEMorphologyElementImpl,KSVGRWBridge<SVGFEMorphologyElementImpl> >(p1,const_cast<SVGFEMorphologyElementImpl *>(this))); +} + +bool SVGFEOffsetElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFEOffsetElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFEOffsetElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFEOffsetElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFEOffsetElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFEOffsetElementImpl,KSVGRWBridge<SVGFEOffsetElementImpl> >(p1,const_cast<SVGFEOffsetElementImpl *>(this))); +} + +bool SVGFEPointLightElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFEPointLightElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFEPointLightElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFEPointLightElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFEPointLightElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFEPointLightElementImpl,KSVGRWBridge<SVGFEPointLightElementImpl> >(p1,const_cast<SVGFEPointLightElementImpl *>(this))); +} + +bool SVGFESpecularLightingElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFESpecularLightingElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFESpecularLightingElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFESpecularLightingElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFESpecularLightingElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFESpecularLightingElementImpl,KSVGRWBridge<SVGFESpecularLightingElementImpl> >(p1,const_cast<SVGFESpecularLightingElementImpl *>(this))); +} + +bool SVGFESpotLightElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFESpotLightElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFESpotLightElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFESpotLightElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFESpotLightElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFESpotLightElementImpl,KSVGRWBridge<SVGFESpotLightElementImpl> >(p1,const_cast<SVGFESpotLightElementImpl *>(this))); +} + +bool SVGFETileElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFETileElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFETileElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFETileElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFETileElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFETileElementImpl,KSVGRWBridge<SVGFETileElementImpl> >(p1,const_cast<SVGFETileElementImpl *>(this))); +} + +bool SVGFETurbulenceElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFETurbulenceElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFETurbulenceElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFETurbulenceElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFETurbulenceElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFETurbulenceElementImpl,KSVGRWBridge<SVGFETurbulenceElementImpl> >(p1,const_cast<SVGFETurbulenceElementImpl *>(this))); +} + +bool SVGFilterElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFilterElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return SVGURIReferenceImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFilterElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGURIReferenceImpl::hasProperty(p1,p2)) { + SVGURIReferenceImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFilterElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFilterElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFilterElementImpl,KSVGRWBridge<SVGFilterElementImpl> >(p1,const_cast<SVGFilterElementImpl *>(this))); +} + +bool SVGFitToViewBoxImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGFitToViewBoxImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGFitToViewBoxImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGFitToViewBoxImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGFitToViewBoxImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +bool SVGFitToViewBoxImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGFitToViewBoxImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGFitToViewBoxImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGFitToViewBoxImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFitToViewBoxImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFitToViewBoxImpl,KSVGRWBridge<SVGFitToViewBoxImpl> >(p1,const_cast<SVGFitToViewBoxImpl *>(this))); +} + +bool SVGFontElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFontElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFontElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFontElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFontElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFontElementImpl,KSVGRWBridge<SVGFontElementImpl> >(p1,const_cast<SVGFontElementImpl *>(this))); +} + +bool SVGFontFaceElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFontFaceElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFontFaceElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFontFaceElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFontFaceElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFontFaceElementImpl,KSVGRWBridge<SVGFontFaceElementImpl> >(p1,const_cast<SVGFontFaceElementImpl *>(this))); +} + +bool SVGFontFaceFormatElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFontFaceFormatElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFontFaceFormatElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFontFaceFormatElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFontFaceFormatElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFontFaceFormatElementImpl,KSVGRWBridge<SVGFontFaceFormatElementImpl> >(p1,const_cast<SVGFontFaceFormatElementImpl *>(this))); +} + +bool SVGFontFaceNameElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFontFaceNameElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFontFaceNameElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFontFaceNameElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFontFaceNameElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFontFaceNameElementImpl,KSVGRWBridge<SVGFontFaceNameElementImpl> >(p1,const_cast<SVGFontFaceNameElementImpl *>(this))); +} + +bool SVGFontFaceSrcElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFontFaceSrcElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFontFaceSrcElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFontFaceSrcElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFontFaceSrcElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFontFaceSrcElementImpl,KSVGRWBridge<SVGFontFaceSrcElementImpl> >(p1,const_cast<SVGFontFaceSrcElementImpl *>(this))); +} + +bool SVGFontFaceUriElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGFontFaceUriElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGFontFaceUriElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGFontFaceUriElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGFontFaceUriElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGFontFaceUriElementImpl,KSVGRWBridge<SVGFontFaceUriElementImpl> >(p1,const_cast<SVGFontFaceUriElementImpl *>(this))); +} + +bool SVGForeignObjectElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGForeignObjectElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGElementImpl::hasProperty(p1,p2)) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + if(SVGTestsImpl::hasProperty(p1,p2)) return true; + if(SVGTransformableImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGForeignObjectElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGForeignObjectElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGForeignObjectElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + if(SVGTestsImpl::hasProperty(p1,p2)) return SVGTestsImpl::get(p1,p2,p3); + if(SVGTransformableImpl::hasProperty(p1,p2)) return SVGTransformableImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGForeignObjectElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTestsImpl::hasProperty(p1,p2)) { + SVGTestsImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTransformableImpl::hasProperty(p1,p2)) { + SVGTransformableImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGForeignObjectElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGForeignObjectElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGForeignObjectElementImpl,KSVGRWBridge<SVGForeignObjectElementImpl> >(p1,const_cast<SVGForeignObjectElementImpl *>(this))); +} + +bool SVGGElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGContainerImpl::hasProperty(p1,p2)) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + if(SVGTestsImpl::hasProperty(p1,p2)) return true; + if(SVGTransformableImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGGElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGContainerImpl::hasProperty(p1,p2)) return SVGContainerImpl::get(p1,p2,p3); + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + if(SVGTestsImpl::hasProperty(p1,p2)) return SVGTestsImpl::get(p1,p2,p3); + if(SVGTransformableImpl::hasProperty(p1,p2)) return SVGTransformableImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGGElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGContainerImpl::hasProperty(p1,p2)) { + SVGContainerImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTestsImpl::hasProperty(p1,p2)) { + SVGTestsImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTransformableImpl::hasProperty(p1,p2)) { + SVGTransformableImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGGElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGGElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGGElementImpl>(p1,const_cast<SVGGElementImpl *>(this)); +} + +Value SVGGElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGGElementImpl,KSVGRWBridge<SVGGElementImpl> >(p1,const_cast<SVGGElementImpl *>(this))); +} + +bool SVGGlyphElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGGlyphElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGElementImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGGlyphElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGGlyphElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGGlyphElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGGlyphElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGGlyphElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGGlyphElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGGlyphElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGGlyphElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGGlyphElementImpl>(p1,const_cast<SVGGlyphElementImpl *>(this)); +} + +Value SVGGlyphElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGGlyphElementImpl,KSVGRWBridge<SVGGlyphElementImpl> >(p1,const_cast<SVGGlyphElementImpl *>(this))); +} + +bool SVGGlyphRefElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGGlyphRefElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGElementImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGGlyphRefElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGGlyphRefElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGGlyphRefElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return SVGURIReferenceImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGGlyphRefElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGGlyphRefElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGGlyphRefElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGURIReferenceImpl::hasProperty(p1,p2)) { + SVGURIReferenceImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGGlyphRefElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGGlyphRefElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGGlyphRefElementImpl>(p1,const_cast<SVGGlyphRefElementImpl *>(this)); +} + +Value SVGGlyphRefElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGGlyphRefElementImpl,KSVGRWBridge<SVGGlyphRefElementImpl> >(p1,const_cast<SVGGlyphRefElementImpl *>(this))); +} + +bool SVGGradientElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGGradientElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGElementImpl::hasProperty(p1,p2)) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGGradientElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGGradientElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGGradientElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return SVGURIReferenceImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGGradientElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGGradientElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGGradientElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGURIReferenceImpl::hasProperty(p1,p2)) { + SVGURIReferenceImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGGradientElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGGradientElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGGradientElementImpl,KSVGRWBridge<SVGGradientElementImpl> >(p1,const_cast<SVGGradientElementImpl *>(this))); +} + +bool SVGGradientElementImplConstructor::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGGradientElementImplConstructor::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGGradientElementImplConstructor::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGGradientElementImplConstructor>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGGradientElementImplConstructor::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +Object SVGGradientElementImplConstructor::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGGradientElementImplConstructor::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGGradientElementImplConstructor,KSVGBridge<SVGGradientElementImplConstructor> >(p1,const_cast<SVGGradientElementImplConstructor *>(this))); +} + +bool SVGHKernElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGHKernElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGHKernElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGHKernElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGHKernElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGHKernElementImpl,KSVGRWBridge<SVGHKernElementImpl> >(p1,const_cast<SVGHKernElementImpl *>(this))); +} + +bool SVGICCColorImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGICCColorImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGICCColorImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGICCColorImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGICCColorImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +Object SVGICCColorImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGICCColorImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGICCColorImpl,KSVGBridge<SVGICCColorImpl> >(p1,const_cast<SVGICCColorImpl *>(this))); +} + +bool SVGImageElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGImageElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGShapeImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + if(SVGTestsImpl::hasProperty(p1,p2)) return true; + if(SVGTransformableImpl::hasProperty(p1,p2)) return true; + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGImageElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGImageElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGImageElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGShapeImpl::hasProperty(p1,p2)) return SVGShapeImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + if(SVGTestsImpl::hasProperty(p1,p2)) return SVGTestsImpl::get(p1,p2,p3); + if(SVGTransformableImpl::hasProperty(p1,p2)) return SVGTransformableImpl::get(p1,p2,p3); + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return SVGURIReferenceImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGImageElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGImageElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGImageElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGShapeImpl::hasProperty(p1,p2)) { + SVGShapeImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTestsImpl::hasProperty(p1,p2)) { + SVGTestsImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTransformableImpl::hasProperty(p1,p2)) { + SVGTransformableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGURIReferenceImpl::hasProperty(p1,p2)) { + SVGURIReferenceImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGImageElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGImageElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGImageElementImpl>(p1,const_cast<SVGImageElementImpl *>(this)); +} + +Value SVGImageElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGImageElementImpl,KSVGRWBridge<SVGImageElementImpl> >(p1,const_cast<SVGImageElementImpl *>(this))); +} + +bool SVGKeyEventImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGKeyEventImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGKeyEventImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + if(SVGUIEventImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGKeyEventImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGKeyEventImplProtoFunc,SVGKeyEventImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGKeyEventImpl *SVGKeyEventImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGKeyEventImpl> *test = dynamic_cast<const KSVGBridge<SVGKeyEventImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGKeyEventImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGKeyEventImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + if(SVGUIEventImpl::hasProperty(p1,p2)) return SVGUIEventImpl::get(p1,p2,p3); + return Undefined(); +} + +Object SVGKeyEventImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGKeyEventImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGKeyEventImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGKeyEventImpl,KSVGBridge<SVGKeyEventImpl> >(p1,const_cast<SVGKeyEventImpl *>(this))); +} + +bool SVGLangSpaceImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGLangSpaceImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGLangSpaceImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGLangSpaceImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGLangSpaceImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +bool SVGLangSpaceImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGLangSpaceImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGLangSpaceImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGLangSpaceImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGLangSpaceImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGLangSpaceImpl,KSVGRWBridge<SVGLangSpaceImpl> >(p1,const_cast<SVGLangSpaceImpl *>(this))); +} + +bool SVGLengthImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGLengthImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGLengthImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + return false; +} + +Value SVGLengthImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGLengthImplProtoFunc,SVGLengthImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGLengthImpl *SVGLengthImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGLengthImpl> *test = dynamic_cast<const KSVGBridge<SVGLengthImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGLengthImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGLengthImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + Q_UNUSED(p3); + return Undefined(); +} + +bool SVGLengthImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGLengthImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGLengthImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGLengthImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGLengthImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGLengthImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGLengthImpl,KSVGRWBridge<SVGLengthImpl> >(p1,const_cast<SVGLengthImpl *>(this))); +} + +bool SVGLengthImplConstructor::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGLengthImplConstructor::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGLengthImplConstructor::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGLengthImplConstructor>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGLengthImplConstructor::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +Object SVGLengthImplConstructor::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGLengthImplConstructor::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGLengthImplConstructor,KSVGBridge<SVGLengthImplConstructor> >(p1,const_cast<SVGLengthImplConstructor *>(this))); +} + +bool SVGLengthListImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGLengthListImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGLengthListImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + return false; +} + +Value SVGLengthListImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGLengthListImplProtoFunc,SVGLengthListImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGLengthListImpl *SVGLengthListImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGLengthListImpl> *test = dynamic_cast<const KSVGBridge<SVGLengthListImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGLengthListImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGLengthListImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + Q_UNUSED(p3); + return Undefined(); +} + +Object SVGLengthListImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGLengthListImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGLengthListImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGLengthListImpl,KSVGBridge<SVGLengthListImpl> >(p1,const_cast<SVGLengthListImpl *>(this))); +} + +bool SVGLineElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGLineElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGShapeImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + if(SVGTestsImpl::hasProperty(p1,p2)) return true; + if(SVGTransformableImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGLineElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGLineElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGLineElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGShapeImpl::hasProperty(p1,p2)) return SVGShapeImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + if(SVGTestsImpl::hasProperty(p1,p2)) return SVGTestsImpl::get(p1,p2,p3); + if(SVGTransformableImpl::hasProperty(p1,p2)) return SVGTransformableImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGLineElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGLineElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGLineElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGShapeImpl::hasProperty(p1,p2)) { + SVGShapeImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTestsImpl::hasProperty(p1,p2)) { + SVGTestsImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTransformableImpl::hasProperty(p1,p2)) { + SVGTransformableImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGLineElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGLineElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGLineElementImpl>(p1,const_cast<SVGLineElementImpl *>(this)); +} + +Value SVGLineElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGLineElementImpl,KSVGRWBridge<SVGLineElementImpl> >(p1,const_cast<SVGLineElementImpl *>(this))); +} + +bool SVGLinearGradientElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGLinearGradientElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGGradientElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGLinearGradientElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGLinearGradientElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGLinearGradientElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGGradientElementImpl::hasProperty(p1,p2)) return SVGGradientElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGLinearGradientElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGLinearGradientElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGLinearGradientElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGGradientElementImpl::hasProperty(p1,p2)) { + SVGGradientElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGLinearGradientElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGLinearGradientElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGLinearGradientElementImpl>(p1,const_cast<SVGLinearGradientElementImpl *>(this)); +} + +Value SVGLinearGradientElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGLinearGradientElementImpl,KSVGRWBridge<SVGLinearGradientElementImpl> >(p1,const_cast<SVGLinearGradientElementImpl *>(this))); +} + +bool SVGLocatableImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGLocatableImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGLocatableImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + return false; +} + +Value SVGLocatableImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGLocatableImplProtoFunc,SVGLocatableImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGLocatableImpl *SVGLocatableImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGLocatableImpl> *test = dynamic_cast<const KSVGBridge<SVGLocatableImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGCircleElementImpl> *test = dynamic_cast<const KSVGBridge<SVGCircleElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGClipPathElementImpl> *test = dynamic_cast<const KSVGBridge<SVGClipPathElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGDefsElementImpl> *test = dynamic_cast<const KSVGBridge<SVGDefsElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGEllipseElementImpl> *test = dynamic_cast<const KSVGBridge<SVGEllipseElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGForeignObjectElementImpl> *test = dynamic_cast<const KSVGBridge<SVGForeignObjectElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGGElementImpl> *test = dynamic_cast<const KSVGBridge<SVGGElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGImageElementImpl> *test = dynamic_cast<const KSVGBridge<SVGImageElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGLineElementImpl> *test = dynamic_cast<const KSVGBridge<SVGLineElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPathElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPathElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPolyElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPolyElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPolygonElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPolygonElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPolylineElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPolylineElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGRectElementImpl> *test = dynamic_cast<const KSVGBridge<SVGRectElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGSVGElementImpl> *test = dynamic_cast<const KSVGBridge<SVGSVGElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGSwitchElementImpl> *test = dynamic_cast<const KSVGBridge<SVGSwitchElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTransformableImpl> *test = dynamic_cast<const KSVGBridge<SVGTransformableImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGUseElementImpl> *test = dynamic_cast<const KSVGBridge<SVGUseElementImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGLocatableImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGLocatableImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + Q_UNUSED(p3); + return Undefined(); +} + +Object SVGLocatableImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGLocatableImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGLocatableImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGLocatableImpl,KSVGBridge<SVGLocatableImpl> >(p1,const_cast<SVGLocatableImpl *>(this))); +} + +bool SVGMPathElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGMPathElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return SVGURIReferenceImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGMPathElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGURIReferenceImpl::hasProperty(p1,p2)) { + SVGURIReferenceImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGMPathElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGMPathElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGMPathElementImpl,KSVGRWBridge<SVGMPathElementImpl> >(p1,const_cast<SVGMPathElementImpl *>(this))); +} + +bool SVGMarkerElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGMarkerElementImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGMarkerElementImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + if(SVGContainerImpl::hasProperty(p1,p2)) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGFitToViewBoxImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGMarkerElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGMarkerElementImplProtoFunc,SVGMarkerElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGMarkerElementImpl *SVGMarkerElementImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGMarkerElementImpl> *test = dynamic_cast<const KSVGBridge<SVGMarkerElementImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGMarkerElementImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGMarkerElementImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + if(SVGContainerImpl::hasProperty(p1,p2)) return SVGContainerImpl::get(p1,p2,p3); + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGFitToViewBoxImpl::hasProperty(p1,p2)) return SVGFitToViewBoxImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGMarkerElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGMarkerElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGMarkerElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGContainerImpl::hasProperty(p1,p2)) { + SVGContainerImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGFitToViewBoxImpl::hasProperty(p1,p2)) { + SVGFitToViewBoxImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGMarkerElementImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGMarkerElementImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGMarkerElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGMarkerElementImpl>(p1,const_cast<SVGMarkerElementImpl *>(this)); +} + +Value SVGMarkerElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGMarkerElementImpl,KSVGRWBridge<SVGMarkerElementImpl> >(p1,const_cast<SVGMarkerElementImpl *>(this))); +} + +bool SVGMarkerElementImplConstructor::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGMarkerElementImplConstructor::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGMarkerElementImplConstructor::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGMarkerElementImplConstructor>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGMarkerElementImplConstructor::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +Object SVGMarkerElementImplConstructor::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGMarkerElementImplConstructor::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGMarkerElementImplConstructor,KSVGBridge<SVGMarkerElementImplConstructor> >(p1,const_cast<SVGMarkerElementImplConstructor *>(this))); +} + +bool SVGMaskElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGMaskElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGElementImpl::hasProperty(p1,p2)) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + if(SVGTestsImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGMaskElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGMaskElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGMaskElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + if(SVGTestsImpl::hasProperty(p1,p2)) return SVGTestsImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGMaskElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGMaskElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGMaskElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTestsImpl::hasProperty(p1,p2)) { + SVGTestsImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGMaskElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGMaskElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGMaskElementImpl>(p1,const_cast<SVGMaskElementImpl *>(this)); +} + +Value SVGMaskElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGMaskElementImpl,KSVGRWBridge<SVGMaskElementImpl> >(p1,const_cast<SVGMaskElementImpl *>(this))); +} + +bool SVGMatrixImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGMatrixImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGMatrixImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + return false; +} + +Value SVGMatrixImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGMatrixImplProtoFunc,SVGMatrixImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGMatrixImpl *SVGMatrixImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGMatrixImpl> *test = dynamic_cast<const KSVGBridge<SVGMatrixImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGMatrixImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGMatrixImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + Q_UNUSED(p3); + return Undefined(); +} + +bool SVGMatrixImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGMatrixImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGMatrixImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGMatrixImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGMatrixImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGMatrixImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGMatrixImpl,KSVGRWBridge<SVGMatrixImpl> >(p1,const_cast<SVGMatrixImpl *>(this))); +} + +bool SVGMetadataElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGMetadataElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGMetadataElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGMetadataElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGMetadataElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGMetadataElementImpl,KSVGRWBridge<SVGMetadataElementImpl> >(p1,const_cast<SVGMetadataElementImpl *>(this))); +} + +bool SVGMissingGlyphElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGMissingGlyphElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGMissingGlyphElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGMissingGlyphElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGMissingGlyphElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGMissingGlyphElementImpl,KSVGRWBridge<SVGMissingGlyphElementImpl> >(p1,const_cast<SVGMissingGlyphElementImpl *>(this))); +} + +bool SVGMouseEventImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGMouseEventImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGMouseEventImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + if(SVGUIEventImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGMouseEventImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGMouseEventImplProtoFunc,SVGMouseEventImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGMouseEventImpl *SVGMouseEventImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGMouseEventImpl> *test = dynamic_cast<const KSVGBridge<SVGMouseEventImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGMouseEventImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGMouseEventImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + if(SVGUIEventImpl::hasProperty(p1,p2)) return SVGUIEventImpl::get(p1,p2,p3); + return Undefined(); +} + +Object SVGMouseEventImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGMouseEventImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGMouseEventImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGMouseEventImpl,KSVGBridge<SVGMouseEventImpl> >(p1,const_cast<SVGMouseEventImpl *>(this))); +} + +bool SVGMutationEventImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGEventImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGMutationEventImpl::get(GET_METHOD_ARGS) const +{ + if(SVGEventImpl::hasProperty(p1,p2)) return SVGEventImpl::get(p1,p2,p3); + return Undefined(); +} + +Object SVGMutationEventImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGMutationEventImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGMutationEventImpl,KSVGBridge<SVGMutationEventImpl> >(p1,const_cast<SVGMutationEventImpl *>(this))); +} + +bool SVGNumberImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGNumberImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGNumberImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGNumberImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGNumberImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +bool SVGNumberImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGNumberImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGNumberImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGNumberImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGNumberImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGNumberImpl,KSVGRWBridge<SVGNumberImpl> >(p1,const_cast<SVGNumberImpl *>(this))); +} + +bool SVGNumberListImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGNumberListImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGNumberListImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + return false; +} + +Value SVGNumberListImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGNumberListImplProtoFunc,SVGNumberListImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGNumberListImpl *SVGNumberListImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGNumberListImpl> *test = dynamic_cast<const KSVGBridge<SVGNumberListImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGNumberListImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGNumberListImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + Q_UNUSED(p3); + return Undefined(); +} + +Object SVGNumberListImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGNumberListImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGNumberListImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGNumberListImpl,KSVGBridge<SVGNumberListImpl> >(p1,const_cast<SVGNumberListImpl *>(this))); +} + +bool SVGPaintImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPaintImpl::s_hashTable,p2); + if(e) return true; + if(SVGColorImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPaintImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPaintImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPaintImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGColorImpl::hasProperty(p1,p2)) return SVGColorImpl::get(p1,p2,p3); + return Undefined(); +} + +Object SVGPaintImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPaintImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPaintImpl,KSVGBridge<SVGPaintImpl> >(p1,const_cast<SVGPaintImpl *>(this))); +} + +bool SVGPaintImplConstructor::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPaintImplConstructor::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGPaintImplConstructor::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPaintImplConstructor>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPaintImplConstructor::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +Object SVGPaintImplConstructor::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPaintImplConstructor::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPaintImplConstructor,KSVGBridge<SVGPaintImplConstructor> >(p1,const_cast<SVGPaintImplConstructor *>(this))); +} + +bool SVGPathElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPathElementImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGPathElementImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + if(SVGAnimatedPathDataImpl::hasProperty(p1,p2)) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGShapeImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + if(SVGTestsImpl::hasProperty(p1,p2)) return true; + if(SVGTransformableImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPathElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGPathElementImplProtoFunc,SVGPathElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGPathElementImpl *SVGPathElementImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGPathElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPathElementImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGPathElementImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGPathElementImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + if(SVGAnimatedPathDataImpl::hasProperty(p1,p2)) return SVGAnimatedPathDataImpl::get(p1,p2,p3); + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGShapeImpl::hasProperty(p1,p2)) return SVGShapeImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + if(SVGTestsImpl::hasProperty(p1,p2)) return SVGTestsImpl::get(p1,p2,p3); + if(SVGTransformableImpl::hasProperty(p1,p2)) return SVGTransformableImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGPathElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGPathElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGPathElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGShapeImpl::hasProperty(p1,p2)) { + SVGShapeImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTestsImpl::hasProperty(p1,p2)) { + SVGTestsImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTransformableImpl::hasProperty(p1,p2)) { + SVGTransformableImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGPathElementImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGPathElementImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGPathElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGPathElementImpl>(p1,const_cast<SVGPathElementImpl *>(this)); +} + +Value SVGPathElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPathElementImpl,KSVGRWBridge<SVGPathElementImpl> >(p1,const_cast<SVGPathElementImpl *>(this))); +} + +bool SVGPathSegArcAbsImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPathSegArcAbsImpl::s_hashTable,p2); + if(e) return true; + if(SVGPathSegImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPathSegArcAbsImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPathSegArcAbsImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPathSegArcAbsImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGPathSegImpl::hasProperty(p1,p2)) return SVGPathSegImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGPathSegArcAbsImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGPathSegArcAbsImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGPathSegArcAbsImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGPathSegArcAbsImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPathSegArcAbsImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPathSegArcAbsImpl,KSVGRWBridge<SVGPathSegArcAbsImpl> >(p1,const_cast<SVGPathSegArcAbsImpl *>(this))); +} + +bool SVGPathSegArcRelImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPathSegArcRelImpl::s_hashTable,p2); + if(e) return true; + if(SVGPathSegImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPathSegArcRelImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPathSegArcRelImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPathSegArcRelImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGPathSegImpl::hasProperty(p1,p2)) return SVGPathSegImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGPathSegArcRelImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGPathSegArcRelImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGPathSegArcRelImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGPathSegArcRelImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPathSegArcRelImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPathSegArcRelImpl,KSVGRWBridge<SVGPathSegArcRelImpl> >(p1,const_cast<SVGPathSegArcRelImpl *>(this))); +} + +bool SVGPathSegClosePathImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGPathSegImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPathSegClosePathImpl::get(GET_METHOD_ARGS) const +{ + if(SVGPathSegImpl::hasProperty(p1,p2)) return SVGPathSegImpl::get(p1,p2,p3); + return Undefined(); +} + +Object SVGPathSegClosePathImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPathSegClosePathImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPathSegClosePathImpl,KSVGBridge<SVGPathSegClosePathImpl> >(p1,const_cast<SVGPathSegClosePathImpl *>(this))); +} + +bool SVGPathSegCurvetoCubicAbsImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPathSegCurvetoCubicAbsImpl::s_hashTable,p2); + if(e) return true; + if(SVGPathSegImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPathSegCurvetoCubicAbsImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPathSegCurvetoCubicAbsImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPathSegCurvetoCubicAbsImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGPathSegImpl::hasProperty(p1,p2)) return SVGPathSegImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGPathSegCurvetoCubicAbsImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGPathSegCurvetoCubicAbsImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGPathSegCurvetoCubicAbsImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGPathSegCurvetoCubicAbsImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPathSegCurvetoCubicAbsImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPathSegCurvetoCubicAbsImpl,KSVGRWBridge<SVGPathSegCurvetoCubicAbsImpl> >(p1,const_cast<SVGPathSegCurvetoCubicAbsImpl *>(this))); +} + +bool SVGPathSegCurvetoCubicRelImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPathSegCurvetoCubicRelImpl::s_hashTable,p2); + if(e) return true; + if(SVGPathSegImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPathSegCurvetoCubicRelImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPathSegCurvetoCubicRelImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPathSegCurvetoCubicRelImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGPathSegImpl::hasProperty(p1,p2)) return SVGPathSegImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGPathSegCurvetoCubicRelImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGPathSegCurvetoCubicRelImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGPathSegCurvetoCubicRelImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGPathSegCurvetoCubicRelImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPathSegCurvetoCubicRelImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPathSegCurvetoCubicRelImpl,KSVGRWBridge<SVGPathSegCurvetoCubicRelImpl> >(p1,const_cast<SVGPathSegCurvetoCubicRelImpl *>(this))); +} + +bool SVGPathSegCurvetoCubicSmoothAbsImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPathSegCurvetoCubicSmoothAbsImpl::s_hashTable,p2); + if(e) return true; + if(SVGPathSegImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPathSegCurvetoCubicSmoothAbsImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPathSegCurvetoCubicSmoothAbsImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPathSegCurvetoCubicSmoothAbsImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGPathSegImpl::hasProperty(p1,p2)) return SVGPathSegImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGPathSegCurvetoCubicSmoothAbsImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGPathSegCurvetoCubicSmoothAbsImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGPathSegCurvetoCubicSmoothAbsImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGPathSegCurvetoCubicSmoothAbsImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPathSegCurvetoCubicSmoothAbsImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPathSegCurvetoCubicSmoothAbsImpl,KSVGRWBridge<SVGPathSegCurvetoCubicSmoothAbsImpl> >(p1,const_cast<SVGPathSegCurvetoCubicSmoothAbsImpl *>(this))); +} + +bool SVGPathSegCurvetoCubicSmoothRelImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPathSegCurvetoCubicSmoothRelImpl::s_hashTable,p2); + if(e) return true; + if(SVGPathSegImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPathSegCurvetoCubicSmoothRelImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPathSegCurvetoCubicSmoothRelImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPathSegCurvetoCubicSmoothRelImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGPathSegImpl::hasProperty(p1,p2)) return SVGPathSegImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGPathSegCurvetoCubicSmoothRelImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGPathSegCurvetoCubicSmoothRelImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGPathSegCurvetoCubicSmoothRelImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGPathSegCurvetoCubicSmoothRelImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPathSegCurvetoCubicSmoothRelImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPathSegCurvetoCubicSmoothRelImpl,KSVGRWBridge<SVGPathSegCurvetoCubicSmoothRelImpl> >(p1,const_cast<SVGPathSegCurvetoCubicSmoothRelImpl *>(this))); +} + +bool SVGPathSegCurvetoQuadraticAbsImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPathSegCurvetoQuadraticAbsImpl::s_hashTable,p2); + if(e) return true; + if(SVGPathSegImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPathSegCurvetoQuadraticAbsImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPathSegCurvetoQuadraticAbsImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPathSegCurvetoQuadraticAbsImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGPathSegImpl::hasProperty(p1,p2)) return SVGPathSegImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGPathSegCurvetoQuadraticAbsImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGPathSegCurvetoQuadraticAbsImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGPathSegCurvetoQuadraticAbsImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGPathSegCurvetoQuadraticAbsImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPathSegCurvetoQuadraticAbsImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPathSegCurvetoQuadraticAbsImpl,KSVGRWBridge<SVGPathSegCurvetoQuadraticAbsImpl> >(p1,const_cast<SVGPathSegCurvetoQuadraticAbsImpl *>(this))); +} + +bool SVGPathSegCurvetoQuadraticRelImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPathSegCurvetoQuadraticRelImpl::s_hashTable,p2); + if(e) return true; + if(SVGPathSegImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPathSegCurvetoQuadraticRelImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPathSegCurvetoQuadraticRelImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPathSegCurvetoQuadraticRelImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGPathSegImpl::hasProperty(p1,p2)) return SVGPathSegImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGPathSegCurvetoQuadraticRelImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGPathSegCurvetoQuadraticRelImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGPathSegCurvetoQuadraticRelImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGPathSegCurvetoQuadraticRelImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPathSegCurvetoQuadraticRelImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPathSegCurvetoQuadraticRelImpl,KSVGRWBridge<SVGPathSegCurvetoQuadraticRelImpl> >(p1,const_cast<SVGPathSegCurvetoQuadraticRelImpl *>(this))); +} + +bool SVGPathSegCurvetoQuadraticSmoothAbsImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPathSegCurvetoQuadraticSmoothAbsImpl::s_hashTable,p2); + if(e) return true; + if(SVGPathSegImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPathSegCurvetoQuadraticSmoothAbsImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPathSegCurvetoQuadraticSmoothAbsImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPathSegCurvetoQuadraticSmoothAbsImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGPathSegImpl::hasProperty(p1,p2)) return SVGPathSegImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGPathSegCurvetoQuadraticSmoothAbsImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGPathSegCurvetoQuadraticSmoothAbsImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGPathSegCurvetoQuadraticSmoothAbsImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGPathSegCurvetoQuadraticSmoothAbsImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPathSegCurvetoQuadraticSmoothAbsImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPathSegCurvetoQuadraticSmoothAbsImpl,KSVGRWBridge<SVGPathSegCurvetoQuadraticSmoothAbsImpl> >(p1,const_cast<SVGPathSegCurvetoQuadraticSmoothAbsImpl *>(this))); +} + +bool SVGPathSegCurvetoQuadraticSmoothRelImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPathSegCurvetoQuadraticSmoothRelImpl::s_hashTable,p2); + if(e) return true; + if(SVGPathSegImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPathSegCurvetoQuadraticSmoothRelImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPathSegCurvetoQuadraticSmoothRelImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPathSegCurvetoQuadraticSmoothRelImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGPathSegImpl::hasProperty(p1,p2)) return SVGPathSegImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGPathSegCurvetoQuadraticSmoothRelImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGPathSegCurvetoQuadraticSmoothRelImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGPathSegCurvetoQuadraticSmoothRelImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGPathSegCurvetoQuadraticSmoothRelImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPathSegCurvetoQuadraticSmoothRelImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPathSegCurvetoQuadraticSmoothRelImpl,KSVGRWBridge<SVGPathSegCurvetoQuadraticSmoothRelImpl> >(p1,const_cast<SVGPathSegCurvetoQuadraticSmoothRelImpl *>(this))); +} + +bool SVGPathSegImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPathSegImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGPathSegImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPathSegImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPathSegImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +Object SVGPathSegImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPathSegImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPathSegImpl,KSVGBridge<SVGPathSegImpl> >(p1,const_cast<SVGPathSegImpl *>(this))); +} + +bool SVGPathSegImplConstructor::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPathSegImplConstructor::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGPathSegImplConstructor::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPathSegImplConstructor>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPathSegImplConstructor::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +Object SVGPathSegImplConstructor::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPathSegImplConstructor::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPathSegImplConstructor,KSVGBridge<SVGPathSegImplConstructor> >(p1,const_cast<SVGPathSegImplConstructor *>(this))); +} + +bool SVGPathSegLinetoAbsImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPathSegLinetoAbsImpl::s_hashTable,p2); + if(e) return true; + if(SVGPathSegImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPathSegLinetoAbsImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPathSegLinetoAbsImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPathSegLinetoAbsImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGPathSegImpl::hasProperty(p1,p2)) return SVGPathSegImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGPathSegLinetoAbsImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGPathSegLinetoAbsImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGPathSegLinetoAbsImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGPathSegLinetoAbsImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPathSegLinetoAbsImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPathSegLinetoAbsImpl,KSVGRWBridge<SVGPathSegLinetoAbsImpl> >(p1,const_cast<SVGPathSegLinetoAbsImpl *>(this))); +} + +bool SVGPathSegLinetoHorizontalAbsImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPathSegLinetoHorizontalAbsImpl::s_hashTable,p2); + if(e) return true; + if(SVGPathSegImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPathSegLinetoHorizontalAbsImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPathSegLinetoHorizontalAbsImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPathSegLinetoHorizontalAbsImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGPathSegImpl::hasProperty(p1,p2)) return SVGPathSegImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGPathSegLinetoHorizontalAbsImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGPathSegLinetoHorizontalAbsImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGPathSegLinetoHorizontalAbsImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGPathSegLinetoHorizontalAbsImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPathSegLinetoHorizontalAbsImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPathSegLinetoHorizontalAbsImpl,KSVGRWBridge<SVGPathSegLinetoHorizontalAbsImpl> >(p1,const_cast<SVGPathSegLinetoHorizontalAbsImpl *>(this))); +} + +bool SVGPathSegLinetoHorizontalRelImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPathSegLinetoHorizontalRelImpl::s_hashTable,p2); + if(e) return true; + if(SVGPathSegImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPathSegLinetoHorizontalRelImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPathSegLinetoHorizontalRelImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPathSegLinetoHorizontalRelImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGPathSegImpl::hasProperty(p1,p2)) return SVGPathSegImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGPathSegLinetoHorizontalRelImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGPathSegLinetoHorizontalRelImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGPathSegLinetoHorizontalRelImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGPathSegLinetoHorizontalRelImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPathSegLinetoHorizontalRelImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPathSegLinetoHorizontalRelImpl,KSVGRWBridge<SVGPathSegLinetoHorizontalRelImpl> >(p1,const_cast<SVGPathSegLinetoHorizontalRelImpl *>(this))); +} + +bool SVGPathSegLinetoRelImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPathSegLinetoRelImpl::s_hashTable,p2); + if(e) return true; + if(SVGPathSegImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPathSegLinetoRelImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPathSegLinetoRelImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPathSegLinetoRelImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGPathSegImpl::hasProperty(p1,p2)) return SVGPathSegImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGPathSegLinetoRelImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGPathSegLinetoRelImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGPathSegLinetoRelImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGPathSegLinetoRelImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPathSegLinetoRelImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPathSegLinetoRelImpl,KSVGRWBridge<SVGPathSegLinetoRelImpl> >(p1,const_cast<SVGPathSegLinetoRelImpl *>(this))); +} + +bool SVGPathSegLinetoVerticalAbsImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPathSegLinetoVerticalAbsImpl::s_hashTable,p2); + if(e) return true; + if(SVGPathSegImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPathSegLinetoVerticalAbsImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPathSegLinetoVerticalAbsImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPathSegLinetoVerticalAbsImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGPathSegImpl::hasProperty(p1,p2)) return SVGPathSegImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGPathSegLinetoVerticalAbsImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGPathSegLinetoVerticalAbsImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGPathSegLinetoVerticalAbsImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGPathSegLinetoVerticalAbsImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPathSegLinetoVerticalAbsImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPathSegLinetoVerticalAbsImpl,KSVGRWBridge<SVGPathSegLinetoVerticalAbsImpl> >(p1,const_cast<SVGPathSegLinetoVerticalAbsImpl *>(this))); +} + +bool SVGPathSegLinetoVerticalRelImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPathSegLinetoVerticalRelImpl::s_hashTable,p2); + if(e) return true; + if(SVGPathSegImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPathSegLinetoVerticalRelImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPathSegLinetoVerticalRelImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPathSegLinetoVerticalRelImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGPathSegImpl::hasProperty(p1,p2)) return SVGPathSegImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGPathSegLinetoVerticalRelImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGPathSegLinetoVerticalRelImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGPathSegLinetoVerticalRelImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGPathSegLinetoVerticalRelImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPathSegLinetoVerticalRelImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPathSegLinetoVerticalRelImpl,KSVGRWBridge<SVGPathSegLinetoVerticalRelImpl> >(p1,const_cast<SVGPathSegLinetoVerticalRelImpl *>(this))); +} + +bool SVGPathSegListImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPathSegListImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGPathSegListImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPathSegListImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGPathSegListImplProtoFunc,SVGPathSegListImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGPathSegListImpl *SVGPathSegListImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGPathSegListImpl> *test = dynamic_cast<const KSVGBridge<SVGPathSegListImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGPathSegListImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGPathSegListImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + Q_UNUSED(p3); + return Undefined(); +} + +Object SVGPathSegListImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGPathSegListImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGPathSegListImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPathSegListImpl,KSVGBridge<SVGPathSegListImpl> >(p1,const_cast<SVGPathSegListImpl *>(this))); +} + +bool SVGPathSegMovetoAbsImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPathSegMovetoAbsImpl::s_hashTable,p2); + if(e) return true; + if(SVGPathSegImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPathSegMovetoAbsImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPathSegMovetoAbsImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPathSegMovetoAbsImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGPathSegImpl::hasProperty(p1,p2)) return SVGPathSegImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGPathSegMovetoAbsImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGPathSegMovetoAbsImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGPathSegMovetoAbsImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGPathSegMovetoAbsImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPathSegMovetoAbsImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPathSegMovetoAbsImpl,KSVGRWBridge<SVGPathSegMovetoAbsImpl> >(p1,const_cast<SVGPathSegMovetoAbsImpl *>(this))); +} + +bool SVGPathSegMovetoRelImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPathSegMovetoRelImpl::s_hashTable,p2); + if(e) return true; + if(SVGPathSegImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPathSegMovetoRelImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPathSegMovetoRelImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPathSegMovetoRelImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGPathSegImpl::hasProperty(p1,p2)) return SVGPathSegImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGPathSegMovetoRelImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGPathSegMovetoRelImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGPathSegMovetoRelImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGPathSegMovetoRelImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPathSegMovetoRelImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPathSegMovetoRelImpl,KSVGRWBridge<SVGPathSegMovetoRelImpl> >(p1,const_cast<SVGPathSegMovetoRelImpl *>(this))); +} + +bool SVGPatternElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPatternElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGElementImpl::hasProperty(p1,p2)) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGFitToViewBoxImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + if(SVGTestsImpl::hasProperty(p1,p2)) return true; + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPatternElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPatternElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPatternElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGFitToViewBoxImpl::hasProperty(p1,p2)) return SVGFitToViewBoxImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + if(SVGTestsImpl::hasProperty(p1,p2)) return SVGTestsImpl::get(p1,p2,p3); + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return SVGURIReferenceImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGPatternElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGPatternElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGPatternElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGFitToViewBoxImpl::hasProperty(p1,p2)) { + SVGFitToViewBoxImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTestsImpl::hasProperty(p1,p2)) { + SVGTestsImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGURIReferenceImpl::hasProperty(p1,p2)) { + SVGURIReferenceImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGPatternElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGPatternElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGPatternElementImpl>(p1,const_cast<SVGPatternElementImpl *>(this)); +} + +Value SVGPatternElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPatternElementImpl,KSVGRWBridge<SVGPatternElementImpl> >(p1,const_cast<SVGPatternElementImpl *>(this))); +} + +bool SVGPointImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPointImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGPointImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPointImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPointImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +bool SVGPointImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGPointImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGPointImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGPointImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPointImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPointImpl,KSVGRWBridge<SVGPointImpl> >(p1,const_cast<SVGPointImpl *>(this))); +} + +bool SVGPointListImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPointListImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGPointListImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPointListImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGPointListImplProtoFunc,SVGPointListImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGPointListImpl *SVGPointListImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGPointListImpl> *test = dynamic_cast<const KSVGBridge<SVGPointListImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGPointListImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGPointListImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + Q_UNUSED(p3); + return Undefined(); +} + +Object SVGPointListImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGPointListImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGPointListImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPointListImpl,KSVGBridge<SVGPointListImpl> >(p1,const_cast<SVGPointListImpl *>(this))); +} + +bool SVGPolyElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGAnimatedPointsImpl::hasProperty(p1,p2)) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGShapeImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + if(SVGTestsImpl::hasProperty(p1,p2)) return true; + if(SVGTransformableImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPolyElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGAnimatedPointsImpl::hasProperty(p1,p2)) return SVGAnimatedPointsImpl::get(p1,p2,p3); + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGShapeImpl::hasProperty(p1,p2)) return SVGShapeImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + if(SVGTestsImpl::hasProperty(p1,p2)) return SVGTestsImpl::get(p1,p2,p3); + if(SVGTransformableImpl::hasProperty(p1,p2)) return SVGTransformableImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGPolyElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGAnimatedPointsImpl::hasProperty(p1,p2)) { + SVGAnimatedPointsImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGShapeImpl::hasProperty(p1,p2)) { + SVGShapeImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTestsImpl::hasProperty(p1,p2)) { + SVGTestsImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTransformableImpl::hasProperty(p1,p2)) { + SVGTransformableImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGPolyElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPolyElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPolyElementImpl,KSVGRWBridge<SVGPolyElementImpl> >(p1,const_cast<SVGPolyElementImpl *>(this))); +} + +bool SVGPolygonElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGPolyElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPolygonElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGPolyElementImpl::hasProperty(p1,p2)) return SVGPolyElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGPolygonElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGPolyElementImpl::hasProperty(p1,p2)) { + SVGPolyElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGPolygonElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGPolygonElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGPolygonElementImpl>(p1,const_cast<SVGPolygonElementImpl *>(this)); +} + +Value SVGPolygonElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPolygonElementImpl,KSVGRWBridge<SVGPolygonElementImpl> >(p1,const_cast<SVGPolygonElementImpl *>(this))); +} + +bool SVGPolylineElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGPolyElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGPolylineElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGPolyElementImpl::hasProperty(p1,p2)) return SVGPolyElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGPolylineElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGPolyElementImpl::hasProperty(p1,p2)) { + SVGPolyElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGPolylineElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGPolylineElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGPolylineElementImpl>(p1,const_cast<SVGPolylineElementImpl *>(this)); +} + +Value SVGPolylineElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPolylineElementImpl,KSVGRWBridge<SVGPolylineElementImpl> >(p1,const_cast<SVGPolylineElementImpl *>(this))); +} + +bool SVGPreserveAspectRatioImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPreserveAspectRatioImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGPreserveAspectRatioImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPreserveAspectRatioImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPreserveAspectRatioImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +bool SVGPreserveAspectRatioImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGPreserveAspectRatioImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGPreserveAspectRatioImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGPreserveAspectRatioImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPreserveAspectRatioImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPreserveAspectRatioImpl,KSVGRWBridge<SVGPreserveAspectRatioImpl> >(p1,const_cast<SVGPreserveAspectRatioImpl *>(this))); +} + +bool SVGPreserveAspectRatioImplConstructor::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGPreserveAspectRatioImplConstructor::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGPreserveAspectRatioImplConstructor::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGPreserveAspectRatioImplConstructor>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGPreserveAspectRatioImplConstructor::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +Object SVGPreserveAspectRatioImplConstructor::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGPreserveAspectRatioImplConstructor::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGPreserveAspectRatioImplConstructor,KSVGBridge<SVGPreserveAspectRatioImplConstructor> >(p1,const_cast<SVGPreserveAspectRatioImplConstructor *>(this))); +} + +bool SVGRadialGradientElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGRadialGradientElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGGradientElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGRadialGradientElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGRadialGradientElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGRadialGradientElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGGradientElementImpl::hasProperty(p1,p2)) return SVGGradientElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGRadialGradientElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGRadialGradientElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGRadialGradientElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGGradientElementImpl::hasProperty(p1,p2)) { + SVGGradientElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGRadialGradientElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGRadialGradientElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGRadialGradientElementImpl>(p1,const_cast<SVGRadialGradientElementImpl *>(this)); +} + +Value SVGRadialGradientElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGRadialGradientElementImpl,KSVGRWBridge<SVGRadialGradientElementImpl> >(p1,const_cast<SVGRadialGradientElementImpl *>(this))); +} + +bool SVGRectElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGRectElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGShapeImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + if(SVGTestsImpl::hasProperty(p1,p2)) return true; + if(SVGTransformableImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGRectElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGRectElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGRectElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGShapeImpl::hasProperty(p1,p2)) return SVGShapeImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + if(SVGTestsImpl::hasProperty(p1,p2)) return SVGTestsImpl::get(p1,p2,p3); + if(SVGTransformableImpl::hasProperty(p1,p2)) return SVGTransformableImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGRectElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGRectElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGRectElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGShapeImpl::hasProperty(p1,p2)) { + SVGShapeImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTestsImpl::hasProperty(p1,p2)) { + SVGTestsImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTransformableImpl::hasProperty(p1,p2)) { + SVGTransformableImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGRectElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGRectElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGRectElementImpl>(p1,const_cast<SVGRectElementImpl *>(this)); +} + +Value SVGRectElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGRectElementImpl,KSVGRWBridge<SVGRectElementImpl> >(p1,const_cast<SVGRectElementImpl *>(this))); +} + +bool SVGRectImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGRectImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGRectImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGRectImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGRectImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +bool SVGRectImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGRectImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGRectImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGRectImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGRectImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGRectImpl,KSVGRWBridge<SVGRectImpl> >(p1,const_cast<SVGRectImpl *>(this))); +} + +bool SVGSVGElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGSVGElementImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGSVGElementImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + if(SVGContainerImpl::hasProperty(p1,p2)) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGFitToViewBoxImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGLocatableImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + if(SVGTestsImpl::hasProperty(p1,p2)) return true; + if(SVGZoomAndPanImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGSVGElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGSVGElementImplProtoFunc,SVGSVGElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGSVGElementImpl *SVGSVGElementImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGSVGElementImpl> *test = dynamic_cast<const KSVGBridge<SVGSVGElementImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGSVGElementImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGSVGElementImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + if(SVGContainerImpl::hasProperty(p1,p2)) return SVGContainerImpl::get(p1,p2,p3); + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGFitToViewBoxImpl::hasProperty(p1,p2)) return SVGFitToViewBoxImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGLocatableImpl::hasProperty(p1,p2)) return SVGLocatableImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + if(SVGTestsImpl::hasProperty(p1,p2)) return SVGTestsImpl::get(p1,p2,p3); + if(SVGZoomAndPanImpl::hasProperty(p1,p2)) return SVGZoomAndPanImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGSVGElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGSVGElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGSVGElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGContainerImpl::hasProperty(p1,p2)) { + SVGContainerImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGFitToViewBoxImpl::hasProperty(p1,p2)) { + SVGFitToViewBoxImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTestsImpl::hasProperty(p1,p2)) { + SVGTestsImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGZoomAndPanImpl::hasProperty(p1,p2)) { + SVGZoomAndPanImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGSVGElementImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGSVGElementImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGSVGElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGSVGElementImpl>(p1,const_cast<SVGSVGElementImpl *>(this)); +} + +Value SVGSVGElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGSVGElementImpl,KSVGRWBridge<SVGSVGElementImpl> >(p1,const_cast<SVGSVGElementImpl *>(this))); +} + +bool SVGScriptElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGScriptElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGElementImpl::hasProperty(p1,p2)) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGScriptElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGScriptElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGScriptElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return SVGURIReferenceImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGScriptElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGScriptElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGScriptElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGURIReferenceImpl::hasProperty(p1,p2)) { + SVGURIReferenceImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGScriptElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGScriptElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGScriptElementImpl>(p1,const_cast<SVGScriptElementImpl *>(this)); +} + +Value SVGScriptElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGScriptElementImpl,KSVGRWBridge<SVGScriptElementImpl> >(p1,const_cast<SVGScriptElementImpl *>(this))); +} + +bool SVGSetElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGAnimationElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGSetElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGAnimationElementImpl::hasProperty(p1,p2)) return SVGAnimationElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGSetElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGAnimationElementImpl::hasProperty(p1,p2)) { + SVGAnimationElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGSetElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGSetElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGSetElementImpl>(p1,const_cast<SVGSetElementImpl *>(this)); +} + +Value SVGSetElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGSetElementImpl,KSVGRWBridge<SVGSetElementImpl> >(p1,const_cast<SVGSetElementImpl *>(this))); +} + +bool SVGShapeImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGShapeImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGShapeImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGShapeImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGShapeImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGShapeImpl,KSVGRWBridge<SVGShapeImpl> >(p1,const_cast<SVGShapeImpl *>(this))); +} + +bool SVGStopElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGStopElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGElementImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGStopElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGStopElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGStopElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGStopElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGStopElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGStopElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGStopElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGStopElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGStopElementImpl>(p1,const_cast<SVGStopElementImpl *>(this)); +} + +Value SVGStopElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGStopElementImpl,KSVGRWBridge<SVGStopElementImpl> >(p1,const_cast<SVGStopElementImpl *>(this))); +} + +bool SVGStringListImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGStringListImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGStringListImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + return false; +} + +Value SVGStringListImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGStringListImplProtoFunc,SVGStringListImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGStringListImpl *SVGStringListImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGStringListImpl> *test = dynamic_cast<const KSVGBridge<SVGStringListImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGStringListImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGStringListImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + Q_UNUSED(p3); + return Undefined(); +} + +Object SVGStringListImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGStringListImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGStringListImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGStringListImpl,KSVGBridge<SVGStringListImpl> >(p1,const_cast<SVGStringListImpl *>(this))); +} + +bool SVGStylableImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGStylableImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGStylableImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + return false; +} + +Value SVGStylableImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGStylableImplProtoFunc,SVGStylableImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGStylableImpl *SVGStylableImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGStylableImpl> *test = dynamic_cast<const KSVGBridge<SVGStylableImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAltGlyphElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAltGlyphElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGCircleElementImpl> *test = dynamic_cast<const KSVGBridge<SVGCircleElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGClipPathElementImpl> *test = dynamic_cast<const KSVGBridge<SVGClipPathElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGDefsElementImpl> *test = dynamic_cast<const KSVGBridge<SVGDefsElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGDescElementImpl> *test = dynamic_cast<const KSVGBridge<SVGDescElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGEllipseElementImpl> *test = dynamic_cast<const KSVGBridge<SVGEllipseElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEFloodElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEFloodElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFEImageElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFEImageElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFilterElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFilterElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGFontElementImpl> *test = dynamic_cast<const KSVGBridge<SVGFontElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGForeignObjectElementImpl> *test = dynamic_cast<const KSVGBridge<SVGForeignObjectElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGGElementImpl> *test = dynamic_cast<const KSVGBridge<SVGGElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGGlyphElementImpl> *test = dynamic_cast<const KSVGBridge<SVGGlyphElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGGlyphRefElementImpl> *test = dynamic_cast<const KSVGBridge<SVGGlyphRefElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGGradientElementImpl> *test = dynamic_cast<const KSVGBridge<SVGGradientElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGImageElementImpl> *test = dynamic_cast<const KSVGBridge<SVGImageElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGLineElementImpl> *test = dynamic_cast<const KSVGBridge<SVGLineElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGLinearGradientElementImpl> *test = dynamic_cast<const KSVGBridge<SVGLinearGradientElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGMarkerElementImpl> *test = dynamic_cast<const KSVGBridge<SVGMarkerElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGMaskElementImpl> *test = dynamic_cast<const KSVGBridge<SVGMaskElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGMissingGlyphElementImpl> *test = dynamic_cast<const KSVGBridge<SVGMissingGlyphElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPathElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPathElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPatternElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPatternElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPolyElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPolyElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPolygonElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPolygonElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPolylineElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPolylineElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGRadialGradientElementImpl> *test = dynamic_cast<const KSVGBridge<SVGRadialGradientElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGRectElementImpl> *test = dynamic_cast<const KSVGBridge<SVGRectElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGSVGElementImpl> *test = dynamic_cast<const KSVGBridge<SVGSVGElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGStopElementImpl> *test = dynamic_cast<const KSVGBridge<SVGStopElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGSwitchElementImpl> *test = dynamic_cast<const KSVGBridge<SVGSwitchElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGSymbolElementImpl> *test = dynamic_cast<const KSVGBridge<SVGSymbolElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTRefElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTRefElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTSpanElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTSpanElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextContentElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextContentElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextPathElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextPathElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextPositioningElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextPositioningElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTitleElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTitleElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGUseElementImpl> *test = dynamic_cast<const KSVGBridge<SVGUseElementImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGStylableImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGStylableImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + Q_UNUSED(p3); + return Undefined(); +} + +bool SVGStylableImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGStylableImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGStylableImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGStylableImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGStylableImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGStylableImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGStylableImpl,KSVGRWBridge<SVGStylableImpl> >(p1,const_cast<SVGStylableImpl *>(this))); +} + +bool SVGStyleElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGStyleElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGStyleElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGStyleElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGStyleElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGStyleElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGStyleElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGStyleElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGStyleElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGStyleElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGStyleElementImpl>(p1,const_cast<SVGStyleElementImpl *>(this)); +} + +Value SVGStyleElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGStyleElementImpl,KSVGRWBridge<SVGStyleElementImpl> >(p1,const_cast<SVGStyleElementImpl *>(this))); +} + +bool SVGSwitchElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGContainerImpl::hasProperty(p1,p2)) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + if(SVGTestsImpl::hasProperty(p1,p2)) return true; + if(SVGTransformableImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGSwitchElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGContainerImpl::hasProperty(p1,p2)) return SVGContainerImpl::get(p1,p2,p3); + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + if(SVGTestsImpl::hasProperty(p1,p2)) return SVGTestsImpl::get(p1,p2,p3); + if(SVGTransformableImpl::hasProperty(p1,p2)) return SVGTransformableImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGSwitchElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGContainerImpl::hasProperty(p1,p2)) { + SVGContainerImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTestsImpl::hasProperty(p1,p2)) { + SVGTestsImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTransformableImpl::hasProperty(p1,p2)) { + SVGTransformableImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGSwitchElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGSwitchElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGSwitchElementImpl>(p1,const_cast<SVGSwitchElementImpl *>(this)); +} + +Value SVGSwitchElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGSwitchElementImpl,KSVGRWBridge<SVGSwitchElementImpl> >(p1,const_cast<SVGSwitchElementImpl *>(this))); +} + +bool SVGSymbolElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGSymbolElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGFitToViewBoxImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGShapeImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGSymbolElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGSymbolElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGSymbolElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGFitToViewBoxImpl::hasProperty(p1,p2)) return SVGFitToViewBoxImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGShapeImpl::hasProperty(p1,p2)) return SVGShapeImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGSymbolElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGSymbolElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGSymbolElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGFitToViewBoxImpl::hasProperty(p1,p2)) { + SVGFitToViewBoxImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGShapeImpl::hasProperty(p1,p2)) { + SVGShapeImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGSymbolElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGSymbolElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGSymbolElementImpl>(p1,const_cast<SVGSymbolElementImpl *>(this)); +} + +Value SVGSymbolElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGSymbolElementImpl,KSVGRWBridge<SVGSymbolElementImpl> >(p1,const_cast<SVGSymbolElementImpl *>(this))); +} + +bool SVGTRefElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGTSpanElementImpl::hasProperty(p1,p2)) return true; + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGTRefElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGTSpanElementImpl::hasProperty(p1,p2)) return SVGTSpanElementImpl::get(p1,p2,p3); + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return SVGURIReferenceImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGTRefElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGTSpanElementImpl::hasProperty(p1,p2)) { + SVGTSpanElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGURIReferenceImpl::hasProperty(p1,p2)) { + SVGURIReferenceImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGTRefElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGTRefElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGTRefElementImpl>(p1,const_cast<SVGTRefElementImpl *>(this)); +} + +Value SVGTRefElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGTRefElementImpl,KSVGRWBridge<SVGTRefElementImpl> >(p1,const_cast<SVGTRefElementImpl *>(this))); +} + +bool SVGTSpanElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGTextPositioningElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGTSpanElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGTextPositioningElementImpl::hasProperty(p1,p2)) return SVGTextPositioningElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGTSpanElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGTextPositioningElementImpl::hasProperty(p1,p2)) { + SVGTextPositioningElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGTSpanElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGTSpanElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGTSpanElementImpl>(p1,const_cast<SVGTSpanElementImpl *>(this)); +} + +Value SVGTSpanElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGTSpanElementImpl,KSVGRWBridge<SVGTSpanElementImpl> >(p1,const_cast<SVGTSpanElementImpl *>(this))); +} + +bool SVGTestsImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGTestsImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGTestsImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + return false; +} + +Value SVGTestsImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGTestsImplProtoFunc,SVGTestsImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGTestsImpl *SVGTestsImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGTestsImpl> *test = dynamic_cast<const KSVGBridge<SVGTestsImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAltGlyphElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAltGlyphElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimateColorElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimateColorElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimateElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimateElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimateMotionElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimateMotionElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimateTransformElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimateTransformElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAnimationElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAnimationElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGCircleElementImpl> *test = dynamic_cast<const KSVGBridge<SVGCircleElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGClipPathElementImpl> *test = dynamic_cast<const KSVGBridge<SVGClipPathElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGCursorElementImpl> *test = dynamic_cast<const KSVGBridge<SVGCursorElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGDefsElementImpl> *test = dynamic_cast<const KSVGBridge<SVGDefsElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGEllipseElementImpl> *test = dynamic_cast<const KSVGBridge<SVGEllipseElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGForeignObjectElementImpl> *test = dynamic_cast<const KSVGBridge<SVGForeignObjectElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGGElementImpl> *test = dynamic_cast<const KSVGBridge<SVGGElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGImageElementImpl> *test = dynamic_cast<const KSVGBridge<SVGImageElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGLineElementImpl> *test = dynamic_cast<const KSVGBridge<SVGLineElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGMaskElementImpl> *test = dynamic_cast<const KSVGBridge<SVGMaskElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPathElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPathElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPatternElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPatternElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPolyElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPolyElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPolygonElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPolygonElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGPolylineElementImpl> *test = dynamic_cast<const KSVGBridge<SVGPolylineElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGRectElementImpl> *test = dynamic_cast<const KSVGBridge<SVGRectElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGSVGElementImpl> *test = dynamic_cast<const KSVGBridge<SVGSVGElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGSetElementImpl> *test = dynamic_cast<const KSVGBridge<SVGSetElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGSwitchElementImpl> *test = dynamic_cast<const KSVGBridge<SVGSwitchElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTRefElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTRefElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTSpanElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTSpanElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextContentElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextContentElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextPathElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextPathElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextPositioningElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextPositioningElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGUseElementImpl> *test = dynamic_cast<const KSVGBridge<SVGUseElementImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGTestsImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGTestsImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + Q_UNUSED(p3); + return Undefined(); +} + +bool SVGTestsImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGTestsImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGTestsImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGTestsImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGTestsImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGTestsImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGTestsImpl,KSVGRWBridge<SVGTestsImpl> >(p1,const_cast<SVGTestsImpl *>(this))); +} + +bool SVGTextContentElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGTextContentElementImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGTextContentElementImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGShapeImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + if(SVGTestsImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGTextContentElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGTextContentElementImplProtoFunc,SVGTextContentElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGTextContentElementImpl *SVGTextContentElementImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGTextContentElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextContentElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGAltGlyphElementImpl> *test = dynamic_cast<const KSVGBridge<SVGAltGlyphElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTRefElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTRefElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTSpanElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTSpanElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextPathElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextPathElementImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGTextPositioningElementImpl> *test = dynamic_cast<const KSVGBridge<SVGTextPositioningElementImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGTextContentElementImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGTextContentElementImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGShapeImpl::hasProperty(p1,p2)) return SVGShapeImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + if(SVGTestsImpl::hasProperty(p1,p2)) return SVGTestsImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGTextContentElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGTextContentElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGTextContentElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGShapeImpl::hasProperty(p1,p2)) { + SVGShapeImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTestsImpl::hasProperty(p1,p2)) { + SVGTestsImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGTextContentElementImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGTextContentElementImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGTextContentElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGTextContentElementImpl,KSVGRWBridge<SVGTextContentElementImpl> >(p1,const_cast<SVGTextContentElementImpl *>(this))); +} + +bool SVGTextContentElementImplConstructor::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGTextContentElementImplConstructor::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGTextContentElementImplConstructor::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGTextContentElementImplConstructor>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGTextContentElementImplConstructor::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +Object SVGTextContentElementImplConstructor::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGTextContentElementImplConstructor::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGTextContentElementImplConstructor,KSVGBridge<SVGTextContentElementImplConstructor> >(p1,const_cast<SVGTextContentElementImplConstructor *>(this))); +} + +bool SVGTextElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGTextPositioningElementImpl::hasProperty(p1,p2)) return true; + if(SVGTransformableImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGTextElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGTextPositioningElementImpl::hasProperty(p1,p2)) return SVGTextPositioningElementImpl::get(p1,p2,p3); + if(SVGTransformableImpl::hasProperty(p1,p2)) return SVGTransformableImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGTextElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGTextPositioningElementImpl::hasProperty(p1,p2)) { + SVGTextPositioningElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTransformableImpl::hasProperty(p1,p2)) { + SVGTransformableImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGTextElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGTextElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGTextElementImpl>(p1,const_cast<SVGTextElementImpl *>(this)); +} + +Value SVGTextElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGTextElementImpl,KSVGRWBridge<SVGTextElementImpl> >(p1,const_cast<SVGTextElementImpl *>(this))); +} + +bool SVGTextPathElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGTextPathElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGTextContentElementImpl::hasProperty(p1,p2)) return true; + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGTextPathElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGTextPathElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGTextPathElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGTextContentElementImpl::hasProperty(p1,p2)) return SVGTextContentElementImpl::get(p1,p2,p3); + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return SVGURIReferenceImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGTextPathElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGTextPathElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGTextPathElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGTextContentElementImpl::hasProperty(p1,p2)) { + SVGTextContentElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGURIReferenceImpl::hasProperty(p1,p2)) { + SVGURIReferenceImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGTextPathElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGTextPathElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGTextPathElementImpl>(p1,const_cast<SVGTextPathElementImpl *>(this)); +} + +Value SVGTextPathElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGTextPathElementImpl,KSVGRWBridge<SVGTextPathElementImpl> >(p1,const_cast<SVGTextPathElementImpl *>(this))); +} + +bool SVGTextPathElementImplConstructor::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGTextPathElementImplConstructor::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGTextPathElementImplConstructor::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGTextPathElementImplConstructor>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGTextPathElementImplConstructor::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +Object SVGTextPathElementImplConstructor::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGTextPathElementImplConstructor::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGTextPathElementImplConstructor,KSVGBridge<SVGTextPathElementImplConstructor> >(p1,const_cast<SVGTextPathElementImplConstructor *>(this))); +} + +bool SVGTextPositioningElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGTextPositioningElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGTextContentElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGTextPositioningElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGTextPositioningElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGTextPositioningElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGTextContentElementImpl::hasProperty(p1,p2)) return SVGTextContentElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGTextPositioningElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGTextPositioningElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGTextPositioningElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGTextContentElementImpl::hasProperty(p1,p2)) { + SVGTextContentElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGTextPositioningElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGTextPositioningElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGTextPositioningElementImpl,KSVGRWBridge<SVGTextPositioningElementImpl> >(p1,const_cast<SVGTextPositioningElementImpl *>(this))); +} + +bool SVGTitleElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGTitleElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGTitleElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGTitleElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGTitleElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGTitleElementImpl>(p1,const_cast<SVGTitleElementImpl *>(this)); +} + +Value SVGTitleElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGTitleElementImpl,KSVGRWBridge<SVGTitleElementImpl> >(p1,const_cast<SVGTitleElementImpl *>(this))); +} + +bool SVGTransformImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGTransformImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGTransformImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + return false; +} + +Value SVGTransformImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGTransformImplProtoFunc,SVGTransformImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGTransformImpl *SVGTransformImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGTransformImpl> *test = dynamic_cast<const KSVGBridge<SVGTransformImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGTransformImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGTransformImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + Q_UNUSED(p3); + return Undefined(); +} + +Object SVGTransformImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGTransformImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGTransformImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGTransformImpl,KSVGBridge<SVGTransformImpl> >(p1,const_cast<SVGTransformImpl *>(this))); +} + +bool SVGTransformImplConstructor::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGTransformImplConstructor::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGTransformImplConstructor::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGTransformImplConstructor>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGTransformImplConstructor::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +Object SVGTransformImplConstructor::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGTransformImplConstructor::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGTransformImplConstructor,KSVGBridge<SVGTransformImplConstructor> >(p1,const_cast<SVGTransformImplConstructor *>(this))); +} + +bool SVGTransformListImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGTransformListImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGTransformListImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + return false; +} + +Value SVGTransformListImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGTransformListImplProtoFunc,SVGTransformListImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGTransformListImpl *SVGTransformListImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGTransformListImpl> *test = dynamic_cast<const KSVGBridge<SVGTransformListImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGTransformListImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGTransformListImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + Q_UNUSED(p3); + return Undefined(); +} + +Object SVGTransformListImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGTransformListImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGTransformListImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGTransformListImpl,KSVGBridge<SVGTransformListImpl> >(p1,const_cast<SVGTransformListImpl *>(this))); +} + +bool SVGTransformableImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGTransformableImpl::s_hashTable,p2); + if(e) return true; + if(SVGLocatableImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGTransformableImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGTransformableImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGTransformableImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGLocatableImpl::hasProperty(p1,p2)) return SVGLocatableImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGTransformableImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGTransformableImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGTransformableImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGTransformableImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGTransformableImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGTransformableImpl,KSVGRWBridge<SVGTransformableImpl> >(p1,const_cast<SVGTransformableImpl *>(this))); +} + +bool SVGUIEventImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGUIEventImpl::s_hashTable,p2); + if(e) return true; + Object proto = SVGUIEventImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return true; + if(SVGEventImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGUIEventImpl::get(GET_METHOD_ARGS) const +{ + return lookupGet<SVGUIEventImplProtoFunc,SVGUIEventImpl>(p1,p2,&s_hashTable,this,p3); +} + +SVGUIEventImpl *SVGUIEventImplProtoFunc::cast(const ObjectImp *p1) const +{ + { const KSVGBridge<SVGUIEventImpl> *test = dynamic_cast<const KSVGBridge<SVGUIEventImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGKeyEventImpl> *test = dynamic_cast<const KSVGBridge<SVGKeyEventImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGMouseEventImpl> *test = dynamic_cast<const KSVGBridge<SVGMouseEventImpl> * >(p1); + if(test) return test->impl(); } + { const KSVGBridge<SVGZoomEventImpl> *test = dynamic_cast<const KSVGBridge<SVGZoomEventImpl> * >(p1); + if(test) return test->impl(); } + return 0; +} + +Value SVGUIEventImpl::getInParents(GET_METHOD_ARGS) const +{ + Object proto = SVGUIEventImplProto::self(p1); + if(proto.hasProperty(p1,p2)) return proto.get(p1,p2); + if(SVGEventImpl::hasProperty(p1,p2)) return SVGEventImpl::get(p1,p2,p3); + return Undefined(); +} + +Object SVGUIEventImpl::prototype(ExecState *p1) const +{ + if(p1) return SVGUIEventImplProto::self(p1); + return Object::dynamicCast(Null()); +} + +Value SVGUIEventImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGUIEventImpl,KSVGBridge<SVGUIEventImpl> >(p1,const_cast<SVGUIEventImpl *>(this))); +} + +bool SVGURIReferenceImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGURIReferenceImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGURIReferenceImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGURIReferenceImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGURIReferenceImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +bool SVGURIReferenceImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGURIReferenceImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGURIReferenceImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGURIReferenceImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGURIReferenceImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGURIReferenceImpl,KSVGRWBridge<SVGURIReferenceImpl> >(p1,const_cast<SVGURIReferenceImpl *>(this))); +} + +bool SVGUseElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGUseElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return true; + if(SVGShapeImpl::hasProperty(p1,p2)) return true; + if(SVGStylableImpl::hasProperty(p1,p2)) return true; + if(SVGTestsImpl::hasProperty(p1,p2)) return true; + if(SVGTransformableImpl::hasProperty(p1,p2)) return true; + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGUseElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGUseElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGUseElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGLangSpaceImpl::hasProperty(p1,p2)) return SVGLangSpaceImpl::get(p1,p2,p3); + if(SVGShapeImpl::hasProperty(p1,p2)) return SVGShapeImpl::get(p1,p2,p3); + if(SVGStylableImpl::hasProperty(p1,p2)) return SVGStylableImpl::get(p1,p2,p3); + if(SVGTestsImpl::hasProperty(p1,p2)) return SVGTestsImpl::get(p1,p2,p3); + if(SVGTransformableImpl::hasProperty(p1,p2)) return SVGTransformableImpl::get(p1,p2,p3); + if(SVGURIReferenceImpl::hasProperty(p1,p2)) return SVGURIReferenceImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGUseElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGUseElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGUseElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGLangSpaceImpl::hasProperty(p1,p2)) { + SVGLangSpaceImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGShapeImpl::hasProperty(p1,p2)) { + SVGShapeImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGStylableImpl::hasProperty(p1,p2)) { + SVGStylableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTestsImpl::hasProperty(p1,p2)) { + SVGTestsImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGTransformableImpl::hasProperty(p1,p2)) { + SVGTransformableImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGURIReferenceImpl::hasProperty(p1,p2)) { + SVGURIReferenceImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGUseElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGUseElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGUseElementImpl>(p1,const_cast<SVGUseElementImpl *>(this)); +} + +Value SVGUseElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGUseElementImpl,KSVGRWBridge<SVGUseElementImpl> >(p1,const_cast<SVGUseElementImpl *>(this))); +} + +bool SVGVKernElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGVKernElementImpl::get(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGVKernElementImpl::put(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGVKernElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGVKernElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGVKernElementImpl,KSVGRWBridge<SVGVKernElementImpl> >(p1,const_cast<SVGVKernElementImpl *>(this))); +} + +bool SVGViewElementImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGViewElementImpl::s_hashTable,p2); + if(e) return true; + if(SVGElementImpl::hasProperty(p1,p2)) return true; + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return true; + if(SVGFitToViewBoxImpl::hasProperty(p1,p2)) return true; + if(SVGZoomAndPanImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGViewElementImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGViewElementImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGViewElementImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGElementImpl::hasProperty(p1,p2)) return SVGElementImpl::get(p1,p2,p3); + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) return SVGExternalResourcesRequiredImpl::get(p1,p2,p3); + if(SVGFitToViewBoxImpl::hasProperty(p1,p2)) return SVGFitToViewBoxImpl::get(p1,p2,p3); + if(SVGZoomAndPanImpl::hasProperty(p1,p2)) return SVGZoomAndPanImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGViewElementImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGViewElementImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGViewElementImpl::putInParents(PUT_METHOD_ARGS) +{ + if(SVGElementImpl::hasProperty(p1,p2)) { + SVGElementImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGExternalResourcesRequiredImpl::hasProperty(p1,p2)) { + SVGExternalResourcesRequiredImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGFitToViewBoxImpl::hasProperty(p1,p2)) { + SVGFitToViewBoxImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGZoomAndPanImpl::hasProperty(p1,p2)) { + SVGZoomAndPanImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGViewElementImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +ObjectImp *SVGViewElementImpl::bridge(ExecState *p1) const +{ + return new KSVGRWBridge<SVGViewElementImpl>(p1,const_cast<SVGViewElementImpl *>(this)); +} + +Value SVGViewElementImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGViewElementImpl,KSVGRWBridge<SVGViewElementImpl> >(p1,const_cast<SVGViewElementImpl *>(this))); +} + +bool SVGViewSpecImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + if(SVGFitToViewBoxImpl::hasProperty(p1,p2)) return true; + if(SVGZoomAndPanImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGViewSpecImpl::get(GET_METHOD_ARGS) const +{ + if(SVGFitToViewBoxImpl::hasProperty(p1,p2)) return SVGFitToViewBoxImpl::get(p1,p2,p3); + if(SVGZoomAndPanImpl::hasProperty(p1,p2)) return SVGZoomAndPanImpl::get(p1,p2,p3); + return Undefined(); +} + +bool SVGViewSpecImpl::put(PUT_METHOD_ARGS) +{ + if(SVGFitToViewBoxImpl::hasProperty(p1,p2)) { + SVGFitToViewBoxImpl::put(p1,p2,p3,p4); + return true; + } + if(SVGZoomAndPanImpl::hasProperty(p1,p2)) { + SVGZoomAndPanImpl::put(p1,p2,p3,p4); + return true; + } + return false; +} + +Object SVGViewSpecImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGViewSpecImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGViewSpecImpl,KSVGRWBridge<SVGViewSpecImpl> >(p1,const_cast<SVGViewSpecImpl *>(this))); +} + +bool SVGZoomAndPanImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGZoomAndPanImpl::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGZoomAndPanImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGZoomAndPanImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGZoomAndPanImpl::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +bool SVGZoomAndPanImpl::put(PUT_METHOD_ARGS) +{ + return lookupPut<SVGZoomAndPanImpl>(p1,p2,p3,p4,&s_hashTable,this); +} + +bool SVGZoomAndPanImpl::putInParents(PUT_METHOD_ARGS) +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4); + return false; +} + +Object SVGZoomAndPanImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGZoomAndPanImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGZoomAndPanImpl,KSVGRWBridge<SVGZoomAndPanImpl> >(p1,const_cast<SVGZoomAndPanImpl *>(this))); +} + +bool SVGZoomAndPanImplConstructor::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGZoomAndPanImplConstructor::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SVGZoomAndPanImplConstructor::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGZoomAndPanImplConstructor>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGZoomAndPanImplConstructor::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +Object SVGZoomAndPanImplConstructor::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGZoomAndPanImplConstructor::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGZoomAndPanImplConstructor,KSVGBridge<SVGZoomAndPanImplConstructor> >(p1,const_cast<SVGZoomAndPanImplConstructor *>(this))); +} + +bool SVGZoomEventImpl::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SVGZoomEventImpl::s_hashTable,p2); + if(e) return true; + if(SVGUIEventImpl::hasProperty(p1,p2)) return true; + return false; +} + +Value SVGZoomEventImpl::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SVGZoomEventImpl>(p1,p2,&s_hashTable,this,p3); +} + +Value SVGZoomEventImpl::getInParents(GET_METHOD_ARGS) const +{ + if(SVGUIEventImpl::hasProperty(p1,p2)) return SVGUIEventImpl::get(p1,p2,p3); + return Undefined(); +} + +Object SVGZoomEventImpl::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SVGZoomEventImpl::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SVGZoomEventImpl,KSVGBridge<SVGZoomEventImpl> >(p1,const_cast<SVGZoomEventImpl *>(this))); +} + +bool SharedString::hasProperty(ExecState *p1,const Identifier &p2) const +{ + const HashEntry *e = Lookup::findEntry(&SharedString::s_hashTable,p2); + if(e) return true; + Q_UNUSED(p1); + return false; +} + +Value SharedString::get(GET_METHOD_ARGS) const +{ + return lookupGetValue<SharedString>(p1,p2,&s_hashTable,this,p3); +} + +Value SharedString::getInParents(GET_METHOD_ARGS) const +{ + Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); + return Undefined(); +} + +Object SharedString::prototype(ExecState *p1) const +{ + if(p1) return p1->interpreter()->builtinObjectPrototype(); + return Object::dynamicCast(Null()); +} + +Value SharedString::cache(ExecState *p1) const +{ + return KJS::Value(cacheDOMObject<SharedString,KSVGBridge<SharedString> >(p1,const_cast<SharedString *>(this))); +} + diff --git a/ksvg/impl/libs/Makefile.am b/ksvg/impl/libs/Makefile.am new file mode 100644 index 00000000..76f41e24 --- /dev/null +++ b/ksvg/impl/libs/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = xrgbrender art_support libtext2path diff --git a/ksvg/impl/libs/art_support/Makefile.am b/ksvg/impl/libs/art_support/Makefile.am new file mode 100644 index 00000000..4bf00dd7 --- /dev/null +++ b/ksvg/impl/libs/art_support/Makefile.am @@ -0,0 +1,4 @@ +noinst_LTLIBRARIES = libksvgart.la +libksvgart_la_SOURCES = art_render_misc.c art_rgba_svp.c art_misc.c + +INCLUDES = $(LIBART_CFLAGS) $(all_includes) diff --git a/ksvg/impl/libs/art_support/art_misc.c b/ksvg/impl/libs/art_support/art_misc.c new file mode 100644 index 00000000..69b45306 --- /dev/null +++ b/ksvg/impl/libs/art_support/art_misc.c @@ -0,0 +1,1841 @@ +#include <libart_lgpl/art_vpath.h> +#include <libart_lgpl/art_bpath.h> +#include <libart_lgpl/art_misc.h> +#include <libart_lgpl/art_affine.h> +#include <libart_lgpl/art_svp_render_aa.h> + +#include "art_misc.h" + +extern double ceil(double x); +extern double floor(double x); + +/** + * art_vpath_render_bez: Render a bezier segment into the vpath. + * @p_vpath: Where the pointer to the #ArtVpath structure is stored. + * @pn_points: Pointer to the number of points in *@p_vpath. + * @pn_points_max: Pointer to the number of points allocated. + * @x0: X coordinate of starting bezier point. + * @y0: Y coordinate of starting bezier point. + * @x1: X coordinate of first bezier control point. + * @y1: Y coordinate of first bezier control point. + * @x2: X coordinate of second bezier control point. + * @y2: Y coordinate of second bezier control point. + * @x3: X coordinate of ending bezier point. + * @y3: Y coordinate of ending bezier point. + * @flatness: Flatness control. + * + * Renders a bezier segment into the vector path, reallocating and + * updating *@p_vpath and *@pn_vpath_max as necessary. *@pn_vpath is + * incremented by the number of vector points added. + * + * This step includes (@x0, @y0) but not (@x3, @y3). + * + * The @flatness argument guides the amount of subdivision. The Adobe + * PostScript reference manual defines flatness as the maximum + * deviation between the any point on the vpath approximation and the + * corresponding point on the "true" curve, and we follow this + * definition here. A value of 0.25 should ensure high quality for aa + * rendering. + **/ + void +ksvg_art_vpath_render_bez (ArtVpath **p_vpath, int *pn, int *pn_max, + double x0, double y0, + double x1, double y1, + double x2, double y2, + double x3, double y3, + double flatness) +{ + double x3_0, y3_0; + double z3_0_dot; + double z1_dot, z2_dot; + double z1_perp, z2_perp; + double max_perp_sq; + + double x_m, y_m; + double xa1, ya1; + double xa2, ya2; + double xb1, yb1; + double xb2, yb2; + + /* It's possible to optimize this routine a fair amount. + + First, once the _dot conditions are met, they will also be met in + all further subdivisions. So we might recurse to a different + routine that only checks the _perp conditions. + + Second, the distance _should_ decrease according to fairly + predictable rules (a factor of 4 with each subdivision). So it might + be possible to note that the distance is within a factor of 4 of + acceptable, and subdivide once. But proving this might be hard. + + Third, at the last subdivision, x_m and y_m can be computed more + expeditiously (as in the routine above). + + Finally, if we were able to subdivide by, say 2 or 3, this would + allow considerably finer-grain control, i.e. fewer points for the + same flatness tolerance. This would speed things up downstream. + + In any case, this routine is unlikely to be the bottleneck. It's + just that I have this undying quest for more speed... + +*/ + + x3_0 = x3 - x0; + y3_0 = y3 - y0; + + /* z3_0_dot is dist z0-z3 squared */ + z3_0_dot = x3_0 * x3_0 + y3_0 * y3_0; + + /* todo: this test is far from satisfactory. */ + if (z3_0_dot < 0.001) + goto nosubdivide; + + /* we can avoid subdivision if: + + z1 has distance no more than flatness from the z0-z3 line + + z1 is no more z0'ward than flatness past z0-z3 + + z1 is more z0'ward than z3'ward on the line traversing z0-z3 + + and correspondingly for z2 */ + + /* perp is distance from line, multiplied by dist z0-z3 */ + max_perp_sq = flatness * flatness * z3_0_dot; + z1_perp = (y1 - y0) * x3_0 - (x1 - x0) * y3_0; + if (z1_perp * z1_perp > max_perp_sq) + goto subdivide; + + z2_perp = (y3 - y2) * x3_0 - (x3 - x2) * y3_0; + if (z2_perp * z2_perp > max_perp_sq) + goto subdivide; + + z1_dot = (x1 - x0) * x3_0 + (y1 - y0) * y3_0; + if (z1_dot < 0 && z1_dot * z1_dot > max_perp_sq) + goto subdivide; + + z2_dot = (x3 - x2) * x3_0 + (y3 - y2) * y3_0; + if (z2_dot < 0 && z2_dot * z2_dot > max_perp_sq) + goto subdivide; + + if (z1_dot + z1_dot > z3_0_dot) + goto subdivide; + + if (z2_dot + z2_dot > z3_0_dot) + goto subdivide; + +nosubdivide: + /* don't subdivide */ + art_vpath_add_point (p_vpath, pn, pn_max, + ART_LINETO, x3, y3); + return; + +subdivide: + + xa1 = (x0 + x1) * 0.5; + ya1 = (y0 + y1) * 0.5; + xa2 = (x0 + 2 * x1 + x2) * 0.25; + ya2 = (y0 + 2 * y1 + y2) * 0.25; + xb1 = (x1 + 2 * x2 + x3) * 0.25; + yb1 = (y1 + 2 * y2 + y3) * 0.25; + xb2 = (x2 + x3) * 0.5; + yb2 = (y2 + y3) * 0.5; + x_m = (xa2 + xb1) * 0.5; + y_m = (ya2 + yb1) * 0.5; +#ifdef VERBOSE + printf ("%g,%g %g,%g %g,%g %g,%g\n", xa1, ya1, xa2, ya2, + xb1, yb1, xb2, yb2); +#endif + ksvg_art_vpath_render_bez (p_vpath, pn, pn_max, + x0, y0, xa1, ya1, xa2, ya2, x_m, y_m, flatness); + ksvg_art_vpath_render_bez (p_vpath, pn, pn_max, + x_m, y_m, xb1, yb1, xb2, yb2, x3, y3, flatness); +} + +#define RENDER_LEVEL 4 +#define RENDER_SIZE (1 << (RENDER_LEVEL)) + +/** + * ksvg_art_bez_path_to_vec: Create vpath from bezier path. + * @bez: Bezier path. + * @flatness: Flatness control. + * + * Creates a vector path closely approximating the bezier path defined by + * @bez. The @flatness argument controls the amount of subdivision. In + * general, the resulting vpath deviates by at most @flatness pixels + * from the "ideal" path described by @bez. + * + * Return value: Newly allocated vpath. + **/ + ArtVpath * +ksvg_art_bez_path_to_vec(const ArtBpath *bez, double flatness) +{ + ArtVpath *vec; + int vec_n, vec_n_max; + int bez_index; + double x, y; + + vec_n = 0; + vec_n_max = RENDER_SIZE; + vec = art_new (ArtVpath, vec_n_max); + + /* Initialization is unnecessary because of the precondition that the + bezier path does not begin with LINETO or CURVETO, but is here + to make the code warning-free. */ + x = 0; + y = 0; + + bez_index = 0; + do + { +#ifdef VERBOSE + printf ("%s %g %g\n", + bez[bez_index].code == ART_CURVETO ? "curveto" : + bez[bez_index].code == ART_LINETO ? "lineto" : + bez[bez_index].code == ART_MOVETO ? "moveto" : + bez[bez_index].code == ART_MOVETO_OPEN ? "moveto-open" : + "end", bez[bez_index].x3, bez[bez_index].y3); +#endif + /* make sure space for at least one more code */ + if (vec_n >= vec_n_max) + art_expand (vec, ArtVpath, vec_n_max); + switch (bez[bez_index].code) + { + case ART_MOVETO_OPEN: + case ART_MOVETO: + case ART_LINETO: + x = bez[bez_index].x3; + y = bez[bez_index].y3; + vec[vec_n].code = bez[bez_index].code; + vec[vec_n].x = x; + vec[vec_n].y = y; + vec_n++; + break; + case ART_END: + vec[vec_n].code = ART_END; + vec[vec_n].x = 0; + vec[vec_n].y = 0; + vec_n++; + break; + case ART_END2: + vec[vec_n].code = (ArtPathcode)ART_END2; + vec[vec_n].x = bez[bez_index].x3; + vec[vec_n].y = bez[bez_index].y3; + vec_n++; + break; + case ART_CURVETO: +#ifdef VERBOSE + printf ("%g,%g %g,%g %g,%g %g,%g\n", x, y, + bez[bez_index].x1, bez[bez_index].y1, + bez[bez_index].x2, bez[bez_index].y2, + bez[bez_index].x3, bez[bez_index].y3); +#endif + ksvg_art_vpath_render_bez (&vec, &vec_n, &vec_n_max, + x, y, + bez[bez_index].x1, bez[bez_index].y1, + bez[bez_index].x2, bez[bez_index].y2, + bez[bez_index].x3, bez[bez_index].y3, + flatness); + x = bez[bez_index].x3; + y = bez[bez_index].y3; + break; + } + } + while (bez[bez_index++].code != ART_END); + return vec; +} + +/* Private functions for the rgb affine image compositors - primarily, +* the determination of runs, eliminating the need for source image +* bbox calculation in the inner loop. */ + +/* Determine a "run", such that the inverse affine of all pixels from +* (x0, y) inclusive to (x1, y) exclusive fit within the bounds +* of the source image. +* +* Initial values of x0, x1, and result values stored in first two +* pointer arguments. +* */ + +#define EPSILON 1e-6 + + void ksvg_art_rgb_affine_run (int *p_x0, int *p_x1, int y, + int src_width, int src_height, + const double affine[6]) +{ + int x0, x1; + double z; + double x_intercept; + int xi; + + x0 = *p_x0; + x1 = *p_x1; + + /* do left and right edges */ + if (affine[0] > EPSILON) + { + z = affine[2] * (y + 0.5) + affine[4]; + x_intercept = -z / affine[0]; + xi = ceil (x_intercept + EPSILON - 0.5); + if (xi > x0) + x0 = xi; + x_intercept = (-z + src_width) / affine[0]; + xi = ceil (x_intercept - EPSILON - 0.5); + if (xi < x1) + x1 = xi; + } + else if (affine[0] < -EPSILON) + { + z = affine[2] * (y + 0.5) + affine[4]; + x_intercept = (-z + src_width) / affine[0]; + xi = ceil (x_intercept + EPSILON - 0.5); + if (xi > x0) + x0 = xi; + x_intercept = -z / affine[0]; + xi = ceil (x_intercept - EPSILON - 0.5); + if (xi < x1) + x1 = xi; + } + else + { + z = affine[2] * (y + 0.5) + affine[4]; + if (z < 0 || z >= src_width) + { + *p_x1 = *p_x0; + return; + } + } + /* do top and bottom edges */ + if (affine[1] > EPSILON) + { + z = affine[3] * (y + 0.5) + affine[5]; + x_intercept = -z / affine[1]; + xi = ceil (x_intercept + EPSILON - 0.5); + if (xi > x0) + x0 = xi; + x_intercept = (-z + src_height) / affine[1]; + xi = ceil (x_intercept - EPSILON - 0.5); + if (xi < x1) + x1 = xi; + } + else if (affine[1] < -EPSILON) + { + z = affine[3] * (y + 0.5) + affine[5]; + x_intercept = (-z + src_height) / affine[1]; + xi = ceil (x_intercept + EPSILON - 0.5); + if (xi > x0) + x0 = xi; + x_intercept = -z / affine[1]; + xi = ceil (x_intercept - EPSILON - 0.5); + if (xi < x1) + x1 = xi; + } + else + { + z = affine[3] * (y + 0.5) + affine[5]; + if (z < 0 || z >= src_height) + { + *p_x1 = *p_x0; + return; + } + } + + *p_x0 = x0; + *p_x1 = x1; +} + +/** + * ksvg_art_rgb_affine: Affine transform source RGB image and composite. + * @dst: Destination image RGB buffer. + * @x0: Left coordinate of destination rectangle. + * @y0: Top coordinate of destination rectangle. + * @x1: Right coordinate of destination rectangle. + * @y1: Bottom coordinate of destination rectangle. + * @dst_rowstride: Rowstride of @dst buffer. + * @src: Source image RGB buffer. + * @src_width: Width of source image. + * @src_height: Height of source image. + * @src_rowstride: Rowstride of @src buffer. + * @affine: Affine transform. + * @level: Filter level. + * @alphagamma: #ArtAlphaGamma for gamma-correcting the compositing. + * @alpha: Alpha, range 0..256. + * + * Affine transform the source image stored in @src, compositing over + * the area of destination image @dst specified by the rectangle + * (@x0, @y0) - (@x1, @y1). As usual in libart, the left and top edges + * of this rectangle are included, and the right and bottom edges are + * excluded. + * + * The @alphagamma parameter specifies that the alpha compositing be done + * in a gamma-corrected color space. Since the source image is opaque RGB, + * this argument only affects the edges. In the current implementation, + * it is ignored. + * + * The @level parameter specifies the speed/quality tradeoff of the + * image interpolation. Currently, only ART_FILTER_NEAREST is + * implemented. + * + * KSVG additions : we have changed this function to support an alpha level as well. +* also we made sure compositing an rgba image over an rgb buffer works. +**/ + void ksvg_art_rgb_affine (art_u8 *dst, int x0, int y0, int x1, int y1, int dst_rowstride, + const art_u8 *src, + int src_width, int src_height, int src_rowstride, + const double affine[6], + ArtFilterLevel level, + ArtAlphaGamma *alphagamma, + int alpha) +{ + /* Note: this is a slow implementation, and is missing all filter + levels other than NEAREST. It is here for clarity of presentation + and to establish the interface. */ + int x, y; + double inv[6]; + art_u8 *dst_p, *dst_linestart; + const art_u8 *src_p; + ArtPoint pt, src_pt; + int src_x, src_y; + int run_x0, run_x1; + + dst_linestart = dst; + art_affine_invert (inv, affine); + + if(alpha == 255) + for (y = y0; y < y1; y++) + { + pt.y = y + 0.5; + run_x0 = x0; + run_x1 = x1; + ksvg_art_rgb_affine_run (&run_x0, &run_x1, y, src_width, src_height, + inv); + dst_p = dst_linestart + (run_x0 - x0) * 3; + for (x = run_x0; x < run_x1; x++) + { + pt.x = x + 0.5; + art_affine_point (&src_pt, &pt, inv); + src_x = floor (src_pt.x); + src_y = floor (src_pt.y); + src_p = src + (src_y * src_rowstride) + src_x * 4; + dst_p[0] = dst_p[0] + (((src_p[2] - dst_p[0]) * src_p[3] + 0x80) >> 8); + dst_p[1] = dst_p[1] + (((src_p[1] - dst_p[1]) * src_p[3] + 0x80) >> 8); + dst_p[2] = dst_p[2] + (((src_p[0] - dst_p[2]) * src_p[3] + 0x80) >> 8); + dst_p += 3; + } + dst_linestart += dst_rowstride; + } + else + for (y = y0; y < y1; y++) + { + pt.y = y + 0.5; + run_x0 = x0; + run_x1 = x1; + ksvg_art_rgb_affine_run (&run_x0, &run_x1, y, src_width, src_height, + inv); + dst_p = dst_linestart + (run_x0 - x0) * 3; + for (x = run_x0; x < run_x1; x++) + { + pt.x = x + 0.5; + art_affine_point (&src_pt, &pt, inv); + src_x = floor (src_pt.x); + src_y = floor (src_pt.y); + src_p = src + (src_y * src_rowstride) + src_x * 4; + dst_p[0] = dst_p[0] + (((src_p[2] - dst_p[0]) * alpha + 0x80) >> 8); + dst_p[1] = dst_p[1] + (((src_p[1] - dst_p[1]) * alpha + 0x80) >> 8); + dst_p[2] = dst_p[2] + (((src_p[0] - dst_p[2]) * alpha + 0x80) >> 8); + dst_p += 3; + } + dst_linestart += dst_rowstride; + } +} + + +typedef struct _ksvgArtRgbAffineClipAlphaData ksvgArtRgbAffineClipAlphaData; + +struct _ksvgArtRgbAffineClipAlphaData +{ + int alphatab[256]; + art_u8 alpha; + art_u8 *dst; + int dst_rowstride; + int x0, x1; + double inv[6]; + const art_u8 *src; + int src_width; + int src_height; + int src_rowstride; + const art_u8 *mask; + int y0; +}; + +static +void ksvg_art_rgb_affine_clip_run(art_u8 *dst_p, int x0, int x1, int y, const double inv[6], + int alpha, const art_u8 *src, int src_rowstride, int src_width, int src_height) +{ + const art_u8 *src_p; + ArtPoint pt, src_pt; + int src_x, src_y; + int x; + + if(alpha > 255) + alpha = 255; + + pt.y = y; + + for(x = x0; x < x1; x++) + { + pt.x = x; + + art_affine_point(&src_pt, &pt, inv); + + src_x = (int)(src_pt.x); + src_y = (int)(src_pt.y); + + if(src_x >= 0 && src_x < src_width && src_y >= 0 && src_y < src_height) + { + int s; + int d; + int tmp; + int srcAlpha; + + src_p = src + (src_y * src_rowstride) + src_x * 4; + + srcAlpha = alpha * src_p[3] + 0x80; + srcAlpha = (srcAlpha + (srcAlpha >> 8)) >> 8; + + d = *dst_p; + s = src_p[2]; + + tmp = srcAlpha * (s - d) + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + *dst_p++ = d + tmp; + + d = *dst_p; + s = src_p[1]; + + tmp = srcAlpha * (s - d) + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + *dst_p++ = d + tmp; + + d = *dst_p; + s = src_p[0]; + + tmp = srcAlpha * (s - d) + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + *dst_p++ = d + tmp; + } + else + dst_p += 3; + } +} + +static void +ksvg_art_rgb_affine_clip_callback (void *callback_data, int y, + int start, ArtSVPRenderAAStep *steps, int n_steps) +{ + ksvgArtRgbAffineClipAlphaData *data = (ksvgArtRgbAffineClipAlphaData *)callback_data; + art_u8 *linebuf; + int run_x0, run_x1; + art_u32 running_sum = start; + int x0, x1; + int k; + int *alphatab; + int alpha; + + linebuf = data->dst; + x0 = data->x0; + x1 = data->x1; + + alphatab = data->alphatab; + + if(n_steps > 0) + { + run_x1 = steps[0].x; + if(run_x1 > x0) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgb_affine_clip_run(linebuf, x0, run_x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + + for(k = 0; k < n_steps - 1; k++) + { + running_sum += steps[k].delta; + run_x0 = run_x1; + run_x1 = steps[k + 1].x; + if(run_x1 > run_x0) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgb_affine_clip_run(linebuf + (run_x0 - x0) * 3, run_x0, run_x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + } + running_sum += steps[k].delta; + if(x1 > run_x1) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgb_affine_clip_run(linebuf + (run_x1 - x0) * 3, run_x1, x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + } + else + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgb_affine_clip_run(linebuf, x0, x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + + data->dst += data->dst_rowstride; +} + +static +void ksvg_art_rgb_affine_clip_mask_run(art_u8 *dst_p, const art_u8 *mask, int x0, int x1, int y, const double inv[6], + int alpha, const art_u8 *src, int src_rowstride, int src_width, int src_height) +{ + const art_u8 *src_p; + ArtPoint pt, src_pt; + int src_x, src_y; + int x; + + if(alpha > 255) + alpha = 255; + + pt.y = y; + + for(x = x0; x < x1; x++) + { + pt.x = x; + + art_affine_point(&src_pt, &pt, inv); + + src_x = (int)(src_pt.x); + src_y = (int)(src_pt.y); + + if(src_x >= 0 && src_x < src_width && src_y >= 0 && src_y < src_height) + { + int s; + int d; + int tmp; + int srcAlpha; + + src_p = src + (src_y * src_rowstride) + src_x * 4; + + srcAlpha = alpha * src_p[3] + 0x80; + srcAlpha = (srcAlpha + (srcAlpha >> 8)) >> 8; + + srcAlpha = (srcAlpha * *mask++) + 0x80; + srcAlpha = (srcAlpha + (srcAlpha >> 8)) >> 8; + + d = *dst_p; + s = src_p[2]; + + tmp = srcAlpha * (s - d) + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + *dst_p++ = d + tmp; + + d = *dst_p; + s = src_p[1]; + + tmp = srcAlpha * (s - d) + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + *dst_p++ = d + tmp; + + d = *dst_p; + s = src_p[0]; + + tmp = srcAlpha * (s - d) + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + *dst_p++ = d + tmp; + } + else + { + dst_p += 3; + mask++; + } + } +} + +static void +ksvg_art_rgb_affine_clip_mask_callback (void *callback_data, int y, + int start, ArtSVPRenderAAStep *steps, int n_steps) +{ + ksvgArtRgbAffineClipAlphaData *data = (ksvgArtRgbAffineClipAlphaData *)callback_data; + art_u8 *linebuf; + int run_x0, run_x1; + art_u32 running_sum = start; + int x0, x1; + int k; + int *alphatab; + int alpha; + const art_u8 *maskbuf; + + linebuf = data->dst; + x0 = data->x0; + x1 = data->x1; + + alphatab = data->alphatab; + maskbuf = data->mask + (y - data->y0) * (x1 - x0); + + if(n_steps > 0) + { + run_x1 = steps[0].x; + if(run_x1 > x0) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgb_affine_clip_mask_run(linebuf, maskbuf, x0, run_x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + + for(k = 0; k < n_steps - 1; k++) + { + running_sum += steps[k].delta; + run_x0 = run_x1; + run_x1 = steps[k + 1].x; + if(run_x1 > run_x0) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgb_affine_clip_mask_run(linebuf + (run_x0 - x0) * 3, maskbuf + (run_x0 - x0), run_x0, run_x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + } + running_sum += steps[k].delta; + if(x1 > run_x1) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgb_affine_clip_mask_run(linebuf + (run_x1 - x0) * 3, maskbuf + (run_x1 - x0), run_x1, x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + } + else + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgb_affine_clip_mask_run(linebuf, maskbuf, x0, x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + + data->dst += data->dst_rowstride; +} + +static +void ksvg_art_rgba_affine_clip_run(art_u8 *dst_p, int x0, int x1, int y, const double inv[6], + int alpha, const art_u8 *src, int src_rowstride, int src_width, int src_height) +{ + const art_u8 *src_p; + ArtPoint pt, src_pt; + int src_x, src_y; + int x; + + if(alpha > 255) + alpha = 255; + + pt.y = y; + + for(x = x0; x < x1; x++) + { + pt.x = x; + + art_affine_point(&src_pt, &pt, inv); + + src_x = (int)(src_pt.x); + src_y = (int)(src_pt.y); + + if(src_x >= 0 && src_x < src_width && src_y >= 0 && src_y < src_height) + { + int s; + int d; + int tmp; + int srcAlpha; + + src_p = src + (src_y * src_rowstride) + src_x * 4; + + srcAlpha = alpha * src_p[3] + 0x80; + srcAlpha = (srcAlpha + (srcAlpha >> 8)) >> 8; + + d = *dst_p; + s = src_p[2]; + + tmp = srcAlpha * (s - d) + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + *dst_p++ = d + tmp; + + d = *dst_p; + s = src_p[1]; + + tmp = srcAlpha * (s - d) + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + *dst_p++ = d + tmp; + + d = *dst_p; + s = src_p[0]; + + tmp = srcAlpha * (s - d) + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + *dst_p++ = d + tmp; + + d = *dst_p; + + tmp = srcAlpha * (255 - d) + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + *dst_p++ = d + tmp; + } + else + dst_p += 4; + } +} + +static void +ksvg_art_rgba_affine_clip_callback (void *callback_data, int y, + int start, ArtSVPRenderAAStep *steps, int n_steps) +{ + ksvgArtRgbAffineClipAlphaData *data = (ksvgArtRgbAffineClipAlphaData *)callback_data; + art_u8 *linebuf; + int run_x0, run_x1; + art_u32 running_sum = start; + int x0, x1; + int k; + int *alphatab; + int alpha; + + linebuf = data->dst; + x0 = data->x0; + x1 = data->x1; + + alphatab = data->alphatab; + + if(n_steps > 0) + { + run_x1 = steps[0].x; + if(run_x1 > x0) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgba_affine_clip_run(linebuf, x0, run_x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + + for(k = 0; k < n_steps - 1; k++) + { + running_sum += steps[k].delta; + run_x0 = run_x1; + run_x1 = steps[k + 1].x; + if(run_x1 > run_x0) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgba_affine_clip_run(linebuf + (run_x0 - x0) * 4, run_x0, run_x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + } + running_sum += steps[k].delta; + if(x1 > run_x1) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgba_affine_clip_run(linebuf + (run_x1 - x0) * 4, run_x1, x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + } + else + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgba_affine_clip_run(linebuf, x0, x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + + data->dst += data->dst_rowstride; +} + +static +void ksvg_art_rgba_affine_clip_mask_run(art_u8 *dst_p, const art_u8 *mask, int x0, int x1, int y, const double inv[6], + int alpha, const art_u8 *src, int src_rowstride, int src_width, int src_height) +{ + const art_u8 *src_p; + ArtPoint pt, src_pt; + int src_x, src_y; + int x; + + if(alpha > 255) + alpha = 255; + + pt.y = y; + + for(x = x0; x < x1; x++) + { + pt.x = x; + + art_affine_point(&src_pt, &pt, inv); + + src_x = (int)(src_pt.x); + src_y = (int)(src_pt.y); + + if(src_x >= 0 && src_x < src_width && src_y >= 0 && src_y < src_height) + { + int s; + int d; + int tmp; + int srcAlpha; + + src_p = src + (src_y * src_rowstride) + src_x * 4; + + srcAlpha = alpha * src_p[3] + 0x80; + srcAlpha = (srcAlpha + (srcAlpha >> 8)) >> 8; + + srcAlpha = (srcAlpha * *mask++) + 0x80; + srcAlpha = (srcAlpha + (srcAlpha >> 8)) >> 8; + + d = *dst_p; + s = src_p[2]; + + tmp = srcAlpha * (s - d) + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + *dst_p++ = d + tmp; + + d = *dst_p; + s = src_p[1]; + + tmp = srcAlpha * (s - d) + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + *dst_p++ = d + tmp; + + d = *dst_p; + s = src_p[0]; + + tmp = srcAlpha * (s - d) + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + *dst_p++ = d + tmp; + + d = *dst_p; + + tmp = srcAlpha * (255 - d) + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + *dst_p++ = d + tmp; + } + else + { + dst_p += 4; + mask++; + } + } +} + +static void +ksvg_art_rgba_affine_clip_mask_callback (void *callback_data, int y, + int start, ArtSVPRenderAAStep *steps, int n_steps) +{ + ksvgArtRgbAffineClipAlphaData *data = (ksvgArtRgbAffineClipAlphaData *)callback_data; + art_u8 *linebuf; + int run_x0, run_x1; + art_u32 running_sum = start; + int x0, x1; + int k; + int *alphatab; + int alpha; + const art_u8 *maskbuf; + + linebuf = data->dst; + x0 = data->x0; + x1 = data->x1; + + alphatab = data->alphatab; + maskbuf = data->mask + (y - data->y0) * (x1 - x0); + + if(n_steps > 0) + { + run_x1 = steps[0].x; + if(run_x1 > x0) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgba_affine_clip_mask_run(linebuf, maskbuf, x0, run_x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + + for(k = 0; k < n_steps - 1; k++) + { + running_sum += steps[k].delta; + run_x0 = run_x1; + run_x1 = steps[k + 1].x; + if(run_x1 > run_x0) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgba_affine_clip_mask_run(linebuf + (run_x0 - x0) * 4, maskbuf + (run_x0 - x0), run_x0, run_x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + } + running_sum += steps[k].delta; + if(x1 > run_x1) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgba_affine_clip_mask_run(linebuf + (run_x1 - x0) * 4, maskbuf + (run_x1 - x0), run_x1, x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + } + else + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgba_affine_clip_mask_run(linebuf, maskbuf, x0, x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + + data->dst += data->dst_rowstride; +} + +/** + * ksvg_art_rgb_affine_clip: Affine transform source RGB image and composite, with clipping path. + * @svp: Clipping path. + * @dst: Destination image RGB buffer. + * @x0: Left coordinate of destination rectangle. + * @y0: Top coordinate of destination rectangle. + * @x1: Right coordinate of destination rectangle. + * @y1: Bottom coordinate of destination rectangle. + * @dst_rowstride: Rowstride of @dst buffer. + * @src: Source image RGB buffer. + * @src_width: Width of source image. + * @src_height: Height of source image. + * @src_rowstride: Rowstride of @src buffer. + * @affine: Affine transform. + * @level: Filter level. + * @alphagamma: #ArtAlphaGamma for gamma-correcting the compositing. + * @alpha: Alpha, range 0..256. + * + * Affine transform the source image stored in @src, compositing over + * the area of destination image @dst specified by the rectangle + * (@x0, @y0) - (@x1, @y1). As usual in libart, the left and top edges + * of this rectangle are included, and the right and bottom edges are + * excluded. + * + * The @alphagamma parameter specifies that the alpha compositing be done + * in a gamma-corrected color space. Since the source image is opaque RGB, + * this argument only affects the edges. In the current implementation, + * it is ignored. + * + * The @level parameter specifies the speed/quality tradeoff of the + * image interpolation. Currently, only ART_FILTER_NEAREST is + * implemented. + * + * KSVG additions : we have changed this function to support an alpha level as well. +* also we made sure compositing an rgba image over an rgb buffer works. +**/ +void ksvg_art_rgb_affine_clip(const ArtSVP *svp, art_u8 *dst, int x0, int y0, int x1, int y1, int dst_rowstride, int dst_channels, + const art_u8 *src, + int src_width, int src_height, int src_rowstride, + const double affine[6], + int alpha, const art_u8 *mask) +{ + ksvgArtRgbAffineClipAlphaData data; + int i; + int a, da; + + data.alpha = alpha; + + a = 0x8000; + da = (alpha * 66051 + 0x80) >> 8; /* 66051 equals 2 ^ 32 / (255 * 255) */ + + for(i = 0; i < 256; i++) + { + data.alphatab[i] = a >> 16; + a += da; + } + + data.dst = dst; + data.dst_rowstride = dst_rowstride; + data.x0 = x0; + data.x1 = x1; + data.y0 = y0; + data.mask = mask; + + art_affine_invert(data.inv, affine); + + data.src = src; + data.src_width = src_width; + data.src_height = src_height; + data.src_rowstride = src_rowstride; + + if(dst_channels == 3) + { + if(mask) + art_svp_render_aa(svp, x0, y0, x1, y1, ksvg_art_rgb_affine_clip_mask_callback, &data); + else + art_svp_render_aa(svp, x0, y0, x1, y1, ksvg_art_rgb_affine_clip_callback, &data); + } + else + { + if(mask) + art_svp_render_aa(svp, x0, y0, x1, y1, ksvg_art_rgba_affine_clip_mask_callback, &data); + else + art_svp_render_aa(svp, x0, y0, x1, y1, ksvg_art_rgba_affine_clip_callback, &data); + } +} + + +static +void ksvg_art_rgb_texture_run(art_u8 *dst_p, int x0, int x1, int y, const double inv[6], + int alpha, const art_u8 *src, int src_rowstride, int src_width, int src_height) +{ + const art_u8 *src_p; + ArtPoint pt, src_pt; + int src_x, src_y; + int x; + int srcAlpha; + + if(alpha > 255) + alpha = 255; + + /* TODO: optimise and filter? */ + pt.y = y + 0.5; + + for(x = x0; x < x1; x++) + { + int s; + int d; + int tmp; + int tmp2; + + pt.x = x + 0.5; + + art_affine_point(&src_pt, &pt, inv); + + src_x = (int)floor(src_pt.x); + src_y = (int)floor(src_pt.y); + + if(src_x < 0) + { + /* Can't assume % behaviour with negative values */ + src_x += ((src_x / -src_width) + 1) * src_width; + } + + if(src_y < 0) + { + src_y += ((src_y / -src_height) + 1) * src_height; + } + + src_x %= src_width; + src_y %= src_height; + + src_p = src + (src_y * src_rowstride) + src_x * 4; + + /* Pattern source is in RGBA format, premultiplied. + * alpha represents fill/stroke/group opacity. + * + * Multiply source alpha by 'alpha' then composite over. + * For each channel, d = d + alpha * (s - srcAlpha * d). + */ + + srcAlpha = src_p[3]; + + d = *dst_p; + s = *src_p++; + + tmp = srcAlpha * d + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + tmp2 = alpha * (s - tmp) + 0x80; + tmp2 = (tmp2 + (tmp2 >> 8)) >> 8; + + *dst_p++ = d + tmp2; + + d = *dst_p; + s = *src_p++; + + tmp = srcAlpha * d + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + tmp2 = alpha * (s - tmp) + 0x80; + tmp2 = (tmp2 + (tmp2 >> 8)) >> 8; + + *dst_p++ = d + tmp2; + + d = *dst_p; + s = *src_p++; + + tmp = srcAlpha * d + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + tmp2 = alpha * (s - tmp) + 0x80; + tmp2 = (tmp2 + (tmp2 >> 8)) >> 8; + + *dst_p++ = d + tmp2; + } +} + +static void +ksvg_art_rgb_texture_callback (void *callback_data, int y, + int start, ArtSVPRenderAAStep *steps, int n_steps) +{ + ksvgArtRgbAffineClipAlphaData *data = (ksvgArtRgbAffineClipAlphaData *)callback_data; + art_u8 *linebuf; + int run_x0, run_x1; + art_u32 running_sum = start; + int x0, x1; + int k; + int *alphatab; + int alpha; + + linebuf = data->dst; + x0 = data->x0; + x1 = data->x1; + + alphatab = data->alphatab; + + if(n_steps > 0) + { + run_x1 = steps[0].x; + if(run_x1 > x0) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgb_texture_run(linebuf, x0, run_x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + + for(k = 0; k < n_steps - 1; k++) + { + running_sum += steps[k].delta; + run_x0 = run_x1; + run_x1 = steps[k + 1].x; + if(run_x1 > run_x0) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgb_texture_run(linebuf + (run_x0 - x0) * 3, run_x0, run_x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + } + running_sum += steps[k].delta; + if(x1 > run_x1) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgb_texture_run(linebuf + (run_x1 - x0) * 3, run_x1, x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + } + else + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgb_texture_run(linebuf, x0, x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + + data->dst += data->dst_rowstride; +} + +static +void ksvg_art_rgb_texture_mask_run(art_u8 *dst_p, const art_u8 *mask, int x0, int x1, int y, const double inv[6], + int alpha, const art_u8 *src, int src_rowstride, int src_width, int src_height) +{ + const art_u8 *src_p; + ArtPoint pt, src_pt; + int src_x, src_y; + int x; + int srcAlpha; + + if(alpha > 255) + alpha = 255; + + /* TODO: optimise and filter? */ + pt.y = y + 0.5; + + for(x = x0; x < x1; x++) + { + int s; + int d; + int am; + int tmp; + int tmp2; + + pt.x = x + 0.5; + + art_affine_point(&src_pt, &pt, inv); + + src_x = (int)floor(src_pt.x); + src_y = (int)floor(src_pt.y); + + if(src_x < 0) + { + /* Can't assume % behaviour with negative values */ + src_x += ((src_x / -src_width) + 1) * src_width; + } + + if(src_y < 0) + { + src_y += ((src_y / -src_height) + 1) * src_height; + } + + src_x %= src_width; + src_y %= src_height; + + src_p = src + (src_y * src_rowstride) + src_x * 4; + + /* Pattern source is in RGBA format, premultiplied. + * alpha represents fill/stroke/group opacity. + * + * Multiply source alpha by 'alpha' and mask value then composite over. + * For each channel, d = d + alpha * mask * (s - srcAlpha * d). + */ + + am = (alpha * *mask++) + 0x80; + am = (am + (am >> 8)) >> 8; + + srcAlpha = src_p[3]; + + d = *dst_p; + s = *src_p++; + + tmp = srcAlpha * d + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + tmp2 = am * (s - tmp) + 0x80; + tmp2 = (tmp2 + (tmp2 >> 8)) >> 8; + + *dst_p++ = d + tmp2; + + d = *dst_p; + s = *src_p++; + + tmp = srcAlpha * d + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + tmp2 = am * (s - tmp) + 0x80; + tmp2 = (tmp2 + (tmp2 >> 8)) >> 8; + + *dst_p++ = d + tmp2; + + d = *dst_p; + s = *src_p++; + + tmp = srcAlpha * d + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + tmp2 = am * (s - tmp) + 0x80; + tmp2 = (tmp2 + (tmp2 >> 8)) >> 8; + + *dst_p++ = d + tmp2; + } +} + +static void +ksvg_art_rgb_texture_mask_callback (void *callback_data, int y, + int start, ArtSVPRenderAAStep *steps, int n_steps) +{ + ksvgArtRgbAffineClipAlphaData *data = (ksvgArtRgbAffineClipAlphaData *)callback_data; + art_u8 *linebuf; + int run_x0, run_x1; + art_u32 running_sum = start; + int x0, x1; + int k; + int *alphatab; + int alpha; + const art_u8 *maskbuf; + + linebuf = data->dst; + x0 = data->x0; + x1 = data->x1; + + alphatab = data->alphatab; + + maskbuf = data->mask + (y - data->y0) * (x1 - x0); + + if(n_steps > 0) + { + run_x1 = steps[0].x; + if(run_x1 > x0) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgb_texture_mask_run(linebuf, maskbuf, x0, run_x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + + for(k = 0; k < n_steps - 1; k++) + { + running_sum += steps[k].delta; + run_x0 = run_x1; + run_x1 = steps[k + 1].x; + if(run_x1 > run_x0) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgb_texture_mask_run(linebuf + (run_x0 - x0) * 3, maskbuf + (run_x0 - x0), run_x0, run_x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + } + running_sum += steps[k].delta; + if(x1 > run_x1) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgb_texture_mask_run(linebuf + (run_x1 - x0) * 3, maskbuf + (run_x1 - x0), run_x1, x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + } + else + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgb_texture_mask_run(linebuf, maskbuf, x0, x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + + data->dst += data->dst_rowstride; +} + +static +void ksvg_art_rgba_texture_run(art_u8 *dst_p, int x0, int x1, int y, const double inv[6], + int alpha, const art_u8 *src, int src_rowstride, int src_width, int src_height) +{ + const art_u8 *src_p; + ArtPoint pt, src_pt; + int src_x, src_y; + int x; + int srcAlpha; + + if(alpha > 255) + alpha = 255; + + /* TODO: optimise and filter? */ + pt.y = y + 0.5; + + for(x = x0; x < x1; x++) + { + int s; + int d; + int tmp; + int tmp2; + + pt.x = x + 0.5; + + art_affine_point(&src_pt, &pt, inv); + + src_x = (int)floor(src_pt.x); + src_y = (int)floor(src_pt.y); + + if(src_x < 0) + { + /* Can't assume % behaviour with negative values */ + src_x += ((src_x / -src_width) + 1) * src_width; + } + + if(src_y < 0) + { + src_y += ((src_y / -src_height) + 1) * src_height; + } + + src_x %= src_width; + src_y %= src_height; + + src_p = src + (src_y * src_rowstride) + src_x * 4; + + /* Pattern source is in RGBA format, premultiplied. + * alpha represents fill/stroke/group opacity. + * + * Multiply source alpha by 'alpha' then composite over. + * For each colour channel, d = d + alpha * (s - srcAlpha * d). + */ + + srcAlpha = src_p[3]; + + d = *dst_p; + s = *src_p++; + + tmp = srcAlpha * d + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + tmp2 = alpha * (s - tmp) + 0x80; + tmp2 = (tmp2 + (tmp2 >> 8)) >> 8; + + *dst_p++ = d + tmp2; + + d = *dst_p; + s = *src_p++; + + tmp = srcAlpha * d + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + tmp2 = alpha * (s - tmp) + 0x80; + tmp2 = (tmp2 + (tmp2 >> 8)) >> 8; + + *dst_p++ = d + tmp2; + + d = *dst_p; + s = *src_p++; + + tmp = srcAlpha * d + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + tmp2 = alpha * (s - tmp) + 0x80; + tmp2 = (tmp2 + (tmp2 >> 8)) >> 8; + + *dst_p++ = d + tmp2; + + /* dstAlpha = dstAlpha + srcAlpha * alpha * (1 - dstAlpha) */ + d = *dst_p; + + tmp = srcAlpha * alpha + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + tmp2 = tmp * (255 - d) + 0x80; + tmp2 = (tmp2 + (tmp2 >> 8)) >> 8; + + *dst_p++ = d + tmp2; + src_p++; + } +} + +static void +ksvg_art_rgba_texture_callback (void *callback_data, int y, + int start, ArtSVPRenderAAStep *steps, int n_steps) +{ + ksvgArtRgbAffineClipAlphaData *data = (ksvgArtRgbAffineClipAlphaData *)callback_data; + art_u8 *linebuf; + int run_x0, run_x1; + art_u32 running_sum = start; + int x0, x1; + int k; + int *alphatab; + int alpha; + + linebuf = data->dst; + x0 = data->x0; + x1 = data->x1; + + alphatab = data->alphatab; + + if(n_steps > 0) + { + run_x1 = steps[0].x; + if(run_x1 > x0) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgba_texture_run(linebuf, x0, run_x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + + for(k = 0; k < n_steps - 1; k++) + { + running_sum += steps[k].delta; + run_x0 = run_x1; + run_x1 = steps[k + 1].x; + if(run_x1 > run_x0) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgba_texture_run(linebuf + (run_x0 - x0) * 4, run_x0, run_x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + } + running_sum += steps[k].delta; + if(x1 > run_x1) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgba_texture_run(linebuf + (run_x1 - x0) * 4, run_x1, x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + } + else + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgba_texture_run(linebuf, x0, x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + + data->dst += data->dst_rowstride; +} + +static +void ksvg_art_rgba_texture_mask_run(art_u8 *dst_p, const art_u8 *mask, int x0, int x1, int y, const double inv[6], + int alpha, const art_u8 *src, int src_rowstride, int src_width, int src_height) +{ + const art_u8 *src_p; + ArtPoint pt, src_pt; + int src_x, src_y; + int x; + int srcAlpha; + + if(alpha > 255) + alpha = 255; + + /* TODO: optimise and filter? */ + pt.y = y + 0.5; + + for(x = x0; x < x1; x++) + { + int s; + int d; + int am; + int tmp; + int tmp2; + + pt.x = x + 0.5; + + art_affine_point(&src_pt, &pt, inv); + + src_x = (int)floor(src_pt.x); + src_y = (int)floor(src_pt.y); + + if(src_x < 0) + { + /* Can't assume % behaviour with negative values */ + src_x += ((src_x / -src_width) + 1) * src_width; + } + + if(src_y < 0) + { + src_y += ((src_y / -src_height) + 1) * src_height; + } + + src_x %= src_width; + src_y %= src_height; + + src_p = src + (src_y * src_rowstride) + src_x * 4; + + /* Pattern source is in RGBA format, premultiplied. + * alpha represents fill/stroke/group opacity. + * + * Multiply source alpha by 'alpha' and mask value then composite over. + * For each channel, d = d + alpha * mask * (s - srcAlpha * d). + */ + + am = (alpha * *mask++) + 0x80; + am = (am + (am >> 8)) >> 8; + + srcAlpha = src_p[3]; + + d = *dst_p; + s = *src_p++; + + tmp = srcAlpha * d + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + tmp2 = am * (s - tmp) + 0x80; + tmp2 = (tmp2 + (tmp2 >> 8)) >> 8; + + *dst_p++ = d + tmp2; + + d = *dst_p; + s = *src_p++; + + tmp = srcAlpha * d + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + tmp2 = am * (s - tmp) + 0x80; + tmp2 = (tmp2 + (tmp2 >> 8)) >> 8; + + *dst_p++ = d + tmp2; + + d = *dst_p; + s = *src_p++; + + tmp = srcAlpha * d + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + tmp2 = am * (s - tmp) + 0x80; + tmp2 = (tmp2 + (tmp2 >> 8)) >> 8; + + *dst_p++ = d + tmp2; + + /* dstAlpha = dstAlpha + srcAlpha * alpha * mask * (1 - dstAlpha) */ + d = *dst_p; + + tmp = srcAlpha * am + 0x80; + tmp = (tmp + (tmp >> 8)) >> 8; + + tmp2 = tmp * (255 - d) + 0x80; + tmp2 = (tmp2 + (tmp2 >> 8)) >> 8; + + *dst_p++ = d + tmp2; + src_p++; + } +} + +static void +ksvg_art_rgba_texture_mask_callback (void *callback_data, int y, + int start, ArtSVPRenderAAStep *steps, int n_steps) +{ + ksvgArtRgbAffineClipAlphaData *data = (ksvgArtRgbAffineClipAlphaData *)callback_data; + art_u8 *linebuf; + int run_x0, run_x1; + art_u32 running_sum = start; + int x0, x1; + int k; + int *alphatab; + int alpha; + const art_u8 *maskbuf; + + linebuf = data->dst; + x0 = data->x0; + x1 = data->x1; + + alphatab = data->alphatab; + + maskbuf = data->mask + (y - data->y0) * (x1 - x0); + + if(n_steps > 0) + { + run_x1 = steps[0].x; + if(run_x1 > x0) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgba_texture_mask_run(linebuf, maskbuf, x0, run_x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + + for(k = 0; k < n_steps - 1; k++) + { + running_sum += steps[k].delta; + run_x0 = run_x1; + run_x1 = steps[k + 1].x; + if(run_x1 > run_x0) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgba_texture_mask_run(linebuf + (run_x0 - x0) * 4, maskbuf + (run_x0 - x0), run_x0, run_x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + } + running_sum += steps[k].delta; + if(x1 > run_x1) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgba_texture_mask_run(linebuf + (run_x1 - x0) * 4, maskbuf + (run_x1 - x0), run_x1, x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + } + else + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + ksvg_art_rgba_texture_mask_run(linebuf, maskbuf, x0, x1, y, data->inv, alphatab[alpha], data->src, data->src_rowstride, data->src_width, data->src_height); + } + + data->dst += data->dst_rowstride; +} + +/** + * ksvg_art_rgb_texture: Affine transform source RGB image and composite, with clipping path. + * @svp: Clipping path. + * @dst: Destination image RGB buffer. + * @x0: Left coordinate of destination rectangle. + * @y0: Top coordinate of destination rectangle. + * @x1: Right coordinate of destination rectangle. + * @y1: Bottom coordinate of destination rectangle. + * @dst_rowstride: Rowstride of @dst buffer. + * @src: Source image RGB buffer. + * @src_width: Width of source image. + * @src_height: Height of source image. + * @src_rowstride: Rowstride of @src buffer. + * @affine: Affine transform. + * @level: Filter level. + * @alphagamma: #ArtAlphaGamma for gamma-correcting the compositing. + * @alpha: Alpha, range 0..256. + * + * Affine transform the source image stored in @src, compositing over + * the area of destination image @dst specified by the rectangle + * (@x0, @y0) - (@x1, @y1). As usual in libart, the left and top edges + * of this rectangle are included, and the right and bottom edges are + * excluded. + * + * The @alphagamma parameter specifies that the alpha compositing be done + * in a gamma-corrected color space. Since the source image is opaque RGB, + * this argument only affects the edges. In the current implementation, + * it is ignored. + * + * The @level parameter specifies the speed/quality tradeoff of the + * image interpolation. Currently, only ART_FILTER_NEAREST is + * implemented. + * + * KSVG additions : we have changed this function to support an alpha level as well. +* also we made sure compositing an rgba image over an rgb buffer works. +**/ +void ksvg_art_rgb_texture(const ArtSVP *svp, art_u8 *dst, int x0, int y0, int x1, int y1, int dst_rowstride, + int dst_channels, + const art_u8 *src, + int src_width, int src_height, int src_rowstride, + const double affine[6], + ArtFilterLevel level, + ArtAlphaGamma *alphaGamma, + int alpha, + const art_u8 *mask) +{ + ksvgArtRgbAffineClipAlphaData data; + int i; + int a, da; + + data.alpha = alpha; + + a = 0x8000; + da = (alpha * 66051 + 0x80) >> 8; /* 66051 equals 2 ^ 32 / (255 * 255) */ + + for(i = 0; i < 256; i++) + { + data.alphatab[i] = a >> 16; + a += da; + } + + data.dst = dst; + data.dst_rowstride = dst_rowstride; + data.x0 = x0; + data.x1 = x1; + + data.inv[0] = affine[0]; + data.inv[1] = affine[1]; + data.inv[2] = affine[2]; + data.inv[3] = affine[3]; + data.inv[4] = affine[4]; + data.inv[5] = affine[5]; + + data.src = src; + data.src_width = src_width; + data.src_height = src_height; + data.src_rowstride = src_rowstride; + + data.mask = mask; + data.y0 = y0; + + if(mask) + { + if(dst_channels == 3) + art_svp_render_aa(svp, x0, y0, x1, y1, ksvg_art_rgb_texture_mask_callback, &data); + else + art_svp_render_aa(svp, x0, y0, x1, y1, ksvg_art_rgba_texture_mask_callback, &data); + } + else + { + if(dst_channels == 3) + art_svp_render_aa(svp, x0, y0, x1, y1, ksvg_art_rgb_texture_callback, &data); + else + art_svp_render_aa(svp, x0, y0, x1, y1, ksvg_art_rgba_texture_callback, &data); + } +} + +/** + * ksvg_art_svp_move: moves an svp relatively to the current position. + * @svp: SVP to move. + * @dx: relative amount to move horizontally. + * @dy: relative amount to move vertically. + * + * Note : this function always moves the svp, not taking into account render buffer + * boundaries. + **/ +void ksvg_art_svp_move(ArtSVP *svp, int dx, int dy) +{ + int i, j; + ArtSVPSeg *seg; + + if(dx == 0 && dy == 0) return; + for(i = 0;i < svp->n_segs;i++) + { + seg = &svp->segs[i]; + for(j = 0;j < seg->n_points;j++) + { + seg->points[j].x += dx; + seg->points[j].y += dy; + } + seg->bbox.x0 += dx; + seg->bbox.y0 += dy; + seg->bbox.x1 += dx; + seg->bbox.y1 += dy; + } +} + diff --git a/ksvg/impl/libs/art_support/art_misc.h b/ksvg/impl/libs/art_support/art_misc.h new file mode 100644 index 00000000..52f09a63 --- /dev/null +++ b/ksvg/impl/libs/art_support/art_misc.h @@ -0,0 +1,79 @@ +/* Libart_LGPL - library of basic graphic primitives + * Copyright (C) 1998 Raph Levien + * + * 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; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __KSVG_ART_H__ +#define __KSVG_ART_H__ + +#include <libart_lgpl/art_misc.h> +#include <libart_lgpl/art_bpath.h> +#include <libart_lgpl/art_vpath.h> +#include <libart_lgpl/art_alphagamma.h> +#include <libart_lgpl/art_filterlevel.h> +#include <libart_lgpl/art_svp.h> + +#define ART_END2 10 + +#ifdef __cplusplus +extern "C" { +#endif + + void ksvg_art_vpath_render_bez (ArtVpath **p_vpath, int *pn, int *pn_max, + double x0, double y0, + double x1, double y1, + double x2, double y2, + double x3, double y3, + double flatness); + + ArtVpath *ksvg_art_bez_path_to_vec(const ArtBpath *bez, double flatness); + + void ksvg_art_rgb_affine_run (int *p_x0, int *p_x1, int y, + int src_width, int src_height, + const double affine[6]); + + void ksvg_art_rgb_affine (art_u8 *dst, int x0, int y0, int x1, int y1, int dst_rowstride, + const art_u8 *src, + int src_width, int src_height, int src_rowstride, + const double affine[6], + ArtFilterLevel level, + ArtAlphaGamma *alphagamma, + int alpha); + + void ksvg_art_rgb_affine_clip(const ArtSVP *svp, art_u8 *dst, int x0, int y0, int x1, int y1, int dst_rowstride, int dst_channels, + const art_u8 *src, + int src_width, int src_height, int src_rowstride, + const double affine[6], + int alpha, const art_u8 *mask); + + void ksvg_art_rgb_texture(const ArtSVP *svp, art_u8 *dst, int x0, int y0, int x1, int y1, int dst_rowstride, + int dst_channels, + const art_u8 *src, + int src_width, int src_height, int src_rowstride, + const double affine[6], + ArtFilterLevel level, + ArtAlphaGamma *alphaGamma, + int alpha, + const art_u8 *mask); + + void ksvg_art_svp_move(ArtSVP *svp, int dx, int dy); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ksvg/impl/libs/art_support/art_render_misc.c b/ksvg/impl/libs/art_support/art_render_misc.c new file mode 100644 index 00000000..1603da1e --- /dev/null +++ b/ksvg/impl/libs/art_support/art_render_misc.c @@ -0,0 +1,774 @@ +/* This file is part of the KDE project. + * art_render_misc.c: Here I store some routines I feel should be in libart :) + * + * Copyright (C) 2001-2003 KSVG Team + * + * This code is adapted from : + * + * art_render_gradient.c: Gradient image source for modular rendering. + * + * Libart_LGPL - library of basic graphic primitives + * Copyright (C) 2000 Raph Levien + * + * 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; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * Authors: Raph Levien <raph@acm.org> + * Alexander Larsson <alla@lysator.liu.se> + */ + +#include "config.h" +#include "art_render_misc.h" + +#include <math.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +/* These are in KSVGHelper.cpp */ +int linearRGBFromsRGB(int sRGB8bit); +int sRGBFromLinearRGB(int linearRGB8bit); + +typedef struct _ArtImageSourceGradRad ArtImageSourceGradRad; + +struct _ArtImageSourceGradRad { + ArtImageSource super; + const ArtKSVGGradientRadial *gradient; + double a; +}; + +#define EPSILON 1e-6 + +/** + * art_ksvg_render_gradient_setpix: Set a gradient pixel. + * @render: The render object. + * @dst: Pointer to destination (where to store pixel). + * @n_stops: Number of stops in @stops. + * @stops: The stops for the gradient. + * @offset: The offset. + * + * @n_stops must be > 0. + * + * Sets a gradient pixel, storing it at @dst. + **/ +static void +art_ksvg_render_gradient_setpix (ArtRender *render, + art_u8 *dst, + int n_stops, ArtGradientStop *stops, + double offset, ArtKSVGGradientInterpolation interpolation) +{ + int ix; + int j; + double off0, off1; + int n_ch = render->n_chan + 1; + + for (ix = 0; ix < n_stops; ix++) + if (stops[ix].offset > offset) + break; + /* stops[ix - 1].offset < offset < stops[ix].offset */ + if (ix > 0 && ix < n_stops) + { + off0 = stops[ix - 1].offset; + off1 = stops[ix].offset; + if (fabs (off1 - off0) > EPSILON) + { + double interp; + + interp = (offset - off0) / (off1 - off0); + if(interpolation == ART_KSVG_LINEARRGB_INTERPOLATION) + { + for (j = 0; j < n_ch; j++) + { + int z0, z1; + int z; + int z0_8bit, z0_linearRGB_8bit; + int z1_8bit, z1_linearRGB_8bit; + int z_8bit, z_sRGB_8bit; + + /* Note: Using explicit variables for intermediate steps since */ + /* the ART_PIX macros reference the argument more than once. */ + z0 = stops[ix - 1].color[j]; + z0_8bit = ART_PIX_8_FROM_MAX(z0); + z0_linearRGB_8bit = linearRGBFromsRGB(z0_8bit); + z0 = ART_PIX_MAX_FROM_8(z0_linearRGB_8bit); + + z1 = stops[ix].color[j]; + z1_8bit = ART_PIX_8_FROM_MAX(z1); + z1_linearRGB_8bit = linearRGBFromsRGB(z1_8bit); + z1 = ART_PIX_MAX_FROM_8(z1_linearRGB_8bit); + + z = floor (z0 + (z1 - z0) * interp + 0.5); + z_8bit = ART_PIX_8_FROM_MAX(z); + z_sRGB_8bit = sRGBFromLinearRGB(z_8bit); + + if (render->buf_depth == 8) + dst[j] = z_sRGB_8bit; + else /* (render->buf_depth == 16) */ + ((art_u16 *)dst)[j] = ART_PIX_MAX_FROM_8(z_sRGB_8bit); + } + } + else + { + /* sRGB interpolation */ + for (j = 0; j < n_ch; j++) + { + int z0, z1; + int z; + z0 = stops[ix - 1].color[j]; + z1 = stops[ix].color[j]; + z = floor (z0 + (z1 - z0) * interp + 0.5); + if (render->buf_depth == 8) + dst[j] = ART_PIX_8_FROM_MAX (z); + else /* (render->buf_depth == 16) */ + ((art_u16 *)dst)[j] = z; + } + } + return; + } + } + else if (ix == n_stops) + ix--; + + for (j = 0; j < n_ch; j++) + { + int z; + z = stops[ix].color[j]; + if (render->buf_depth == 8) + dst[j] = ART_PIX_8_FROM_MAX (z); + else /* (render->buf_depth == 16) */ + ((art_u16 *)dst)[j] = z; + } +} + +static void +art_ksvg_render_gradient_radial_done (ArtRenderCallback *self, ArtRender *render) +{ + art_free (self); +} + +static void +art_ksvg_render_gradient_radial_render (ArtRenderCallback *self, ArtRender *render, + art_u8 *dest, int y) +{ + ArtImageSourceGradRad *z = (ArtImageSourceGradRad *)self; + const ArtKSVGGradientRadial *gradient = z->gradient; + int pixstride = (render->n_chan + 1) * (render->depth >> 3); + int x; + int x0 = render->x0; + int width = render->x1 - x0; + int n_stops = gradient->n_stops; + ArtGradientStop *stops = gradient->stops; + art_u8 *bufp = render->image_buf; + double fx = gradient->fx; + double fy = gradient->fy; + double dx, dy; + double *affine = gradient->affine; + double aff0 = affine[0]; + double aff1 = affine[1]; + const double a = z->a; + const double arecip = 1.0 / a; + double b, db; + double c, dc, ddc; + double b_a, db_a; + double rad, drad, ddrad; + ArtGradientSpread spread = gradient->spread; + + dx = x0 * aff0 + y * affine[2] + affine[4] - fx; + dy = x0 * aff1 + y * affine[3] + affine[5] - fy; + b = dx * fx + dy * fy; + db = aff0 * fx + aff1 * fy; + c = dx * dx + dy * dy; + dc = 2 * aff0 * dx + aff0 * aff0 + 2 * aff1 * dy + aff1 * aff1; + ddc = 2 * aff0 * aff0 + 2 * aff1 * aff1; + + b_a = b * arecip; + db_a = db * arecip; + + rad = b_a * b_a + c * arecip; + drad = 2 * b_a * db_a + db_a * db_a + dc * arecip; + ddrad = 2 * db_a * db_a + ddc * arecip; + + for (x = 0; x < width; x++) + { + double z; + + if (rad > 0) + z = b_a + sqrt (rad); + else + z = b_a; + + if (spread == ART_GRADIENT_REPEAT) + z = z - floor (z); + else if (spread == ART_GRADIENT_REFLECT) + { + double tmp; + + tmp = z - 2 * floor (0.5 * z); + z = tmp > 1 ? 2 - tmp : tmp; + } + + art_ksvg_render_gradient_setpix (render, bufp, n_stops, stops, z, gradient->interpolation); + bufp += pixstride; + b_a += db_a; + rad += drad; + drad += ddrad; + } +} + +static void +art_ksvg_render_gradient_radial_negotiate (ArtImageSource *self, ArtRender *render, + ArtImageSourceFlags *p_flags, + int *p_buf_depth, ArtAlphaType *p_alpha) +{ + self->super.render = art_ksvg_render_gradient_radial_render; + *p_flags = 0; + *p_buf_depth = render->depth; + *p_alpha = ART_ALPHA_SEPARATE; +} + +/** + * art_ksvg_render_gradient_radial: Add a radial gradient image source. + * @render: The render object. + * @gradient: The radial gradient. + * + * Adds the radial gradient @gradient as the image source for rendering + * in the render object @render. + **/ +void +art_ksvg_render_gradient_radial (ArtRender *render, + const ArtKSVGGradientRadial *gradient, + ArtFilterLevel level) +{ + ArtImageSourceGradRad *image_source = art_new (ArtImageSourceGradRad, 1); + double fx = gradient->fx; + double fy = gradient->fy; + + image_source->super.super.render = NULL; + image_source->super.super.done = art_ksvg_render_gradient_radial_done; + image_source->super.negotiate = art_ksvg_render_gradient_radial_negotiate; + + image_source->gradient = gradient; + /* todo: sanitycheck fx, fy? */ + image_source->a = 1 - fx * fx - fy * fy; + + art_render_add_image_source (render, &image_source->super); +} + + +/* Hack to find out how to define alloca on different platforms. + * Modified version of glib/galloca.h. + */ + +#ifdef __GNUC__ +/* GCC does the right thing */ + #undef alloca + #define alloca(size) __builtin_alloca (size) +#elif defined (HAVE_ALLOCA_H) +/* a native and working alloca.h is there */ + #include <alloca.h> +#else /* !__GNUC__ && !HAVE_ALLOCA_H */ + #ifdef _MSC_VER + #include <malloc.h> + #define alloca _alloca + #else /* !_MSC_VER */ + #ifdef _AIX + #pragma alloca + #else /* !_AIX */ + #ifndef alloca /* predefined by HP cc +Olibcalls */ +char *alloca (); + #endif /* !alloca */ + #endif /* !_AIX */ + #endif /* !_MSC_VER */ +#endif /* !__GNUC__ && !HAVE_ALLOCA_H */ + +#undef DEBUG_SPEW + +typedef struct _ArtImageSourceGradLin ArtImageSourceGradLin; + +/* The stops will be copied right after this structure */ +struct _ArtImageSourceGradLin +{ + ArtImageSource super; + ArtKSVGGradientLinear gradient; + ArtGradientStop stops[1]; +}; + +#ifndef MAX + #define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#endif /* MAX */ + +#ifndef MIN + #define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#endif /* MIN */ + +static void +art_ksvg_rgba_gradient_run (art_u8 *buf, + art_u8 *color1, + art_u8 *color2, + int len) +{ + int i; + int r, g, b, a; + int dr, dg, db, da; + +#ifdef DEBUG_SPEW + printf ("gradient run from %3d %3d %3d %3d to %3d %3d %3d %3d in %d pixels\n", + color1[0], color1[1], color1[2], color1[3], + color2[0], color2[1], color2[2], color2[3], + len); +#endif + + r = (color1[0] << 16) + 0x8000; + g = (color1[1] << 16) + 0x8000; + b = (color1[2] << 16) + 0x8000; + a = (color1[3] << 16) + 0x8000; + dr = ((color2[0] - color1[0]) << 16) / len; + dg = ((color2[1] - color1[1]) << 16) / len; + db = ((color2[2] - color1[2]) << 16) / len; + da = ((color2[3] - color1[3]) << 16) / len; + + for(i = 0; i < len; i++) + { + *buf++ = (r>>16); + *buf++ = (g>>16); + *buf++ = (b>>16); + *buf++ = (a>>16); + + r += dr; + g += dg; + b += db; + a += da; + } +} + +static void +ksvg_calc_color_at (ArtGradientStop *stops, + int n_stops, + ArtGradientSpread spread, + double offset, + double offset_fraction, + int favor_start, + int ix, + art_u8 *color) +{ + double off0, off1; + int j; + + if(spread == ART_GRADIENT_PAD) + { + if(offset < EPSILON) + { + color[0] = ART_PIX_8_FROM_MAX (stops[0].color[0]); + color[1] = ART_PIX_8_FROM_MAX (stops[0].color[1]); + color[2] = ART_PIX_8_FROM_MAX (stops[0].color[2]); + color[3] = ART_PIX_8_FROM_MAX (stops[0].color[3]); + return; + } + if(offset >= 1.0 - EPSILON) + { + color[0] = ART_PIX_8_FROM_MAX (stops[n_stops-1].color[0]); + color[1] = ART_PIX_8_FROM_MAX (stops[n_stops-1].color[1]); + color[2] = ART_PIX_8_FROM_MAX (stops[n_stops-1].color[2]); + color[3] = ART_PIX_8_FROM_MAX (stops[n_stops-1].color[3]); + return; + } + } + + if(ix > 0 && ix < n_stops) + { + off0 = stops[ix - 1].offset; + off1 = stops[ix].offset; + if(fabs (off1 - off0) > EPSILON) + { + double interp; + double o; + o = offset_fraction; + + if((fabs (o) < EPSILON) && (!favor_start)) + o = 1.0; + else if((fabs (o-1.0) < EPSILON) && (favor_start)) + o = 0.0; + + /* + if (offset_fraction == 0.0 && !favor_start) + offset_fraction = 1.0; + */ + + interp = (o - off0) / (off1 - off0); + for(j = 0; j < 4; j++) + { + int z0, z1; + int z; + z0 = stops[ix - 1].color[j]; + z1 = stops[ix].color[j]; + z = floor (z0 + (z1 - z0) * interp + 0.5); + color[j] = ART_PIX_8_FROM_MAX (z); + } + return; + } + /* If offsets are too close to safely do the division, just + pick the ix color. */ + color[0] = ART_PIX_8_FROM_MAX (stops[ix].color[0]); + color[1] = ART_PIX_8_FROM_MAX (stops[ix].color[1]); + color[2] = ART_PIX_8_FROM_MAX (stops[ix].color[2]); + color[3] = ART_PIX_8_FROM_MAX (stops[ix].color[3]); + return; + } + + /*printf ("WARNING! bad ix %d in calc_color_at() [internal error]\n", ix); + assert (0);*/ +} + +static void +art_ksvg_render_gradient_linear_render_8 (ArtRenderCallback *self, + ArtRender *render, + art_u8 *dest, int y) +{ + ArtImageSourceGradLin *z = (ArtImageSourceGradLin *)self; + const ArtKSVGGradientLinear *gradient = &(z->gradient); + int i; + int width = render->x1 - render->x0; + int len; + double offset, d_offset; + double offset_fraction; + int next_stop; + int ix; + art_u8 color1[4], color2[4]; + int n_stops = gradient->n_stops; + int extra_stops; + ArtGradientStop *stops = gradient->stops; + ArtGradientStop *tmp_stops; + art_u8 *bufp = render->image_buf; + ArtGradientSpread spread = gradient->spread; + +#ifdef DEBUG_SPEW + printf ("x1: %d, x2: %d, y: %d\n", render->x0, render->x1, y); + printf ("spread: %d, stops:", gradient->spread); + for(i=0;i<n_stops;i++) + { + printf ("%f, ", gradient->stops[i].offset); + } + printf ("\n"); + printf ("a: %f, b: %f, c: %f\n", gradient->a, gradient->b, gradient->c); +#endif + + offset = render->x0 * gradient->affine[0] + y * gradient->affine[2] + gradient->affine[4]; + d_offset = gradient->affine[0]; + + /* We need to force the gradient to extend the whole 0..1 segment, + because the rest of the code doesn't handle partial gradients + correctly */ + if((gradient->stops[0].offset > EPSILON /* == 0.0 */) || + (gradient->stops[n_stops-1].offset < (1.0 - EPSILON))) + { + extra_stops = 0; + tmp_stops = stops = alloca (sizeof (ArtGradientStop) * (n_stops + 2)); + if(gradient->stops[0].offset > EPSILON /* 0.0 */) + { + memcpy (tmp_stops, gradient->stops, sizeof (ArtGradientStop)); + tmp_stops[0].offset = 0.0; + tmp_stops += 1; + extra_stops++; + } + memcpy (tmp_stops, gradient->stops, sizeof (ArtGradientStop) * n_stops); + if(gradient->stops[n_stops-1].offset < (1.0 - EPSILON)) + { + tmp_stops += n_stops; + memcpy (tmp_stops, &gradient->stops[n_stops-1], sizeof (ArtGradientStop)); + tmp_stops[0].offset = 1.0; + extra_stops++; + } + n_stops += extra_stops; + + +#ifdef DEBUG_SPEW + printf ("start/stop modified stops:"); + for(i=0;i<n_stops;i++) + { + printf ("%f, ", stops[i].offset); + } + printf ("\n"); +#endif + + } + + if(spread == ART_GRADIENT_REFLECT) + { + tmp_stops = stops; + stops = alloca (sizeof (ArtGradientStop) * n_stops * 2); + memcpy (stops, tmp_stops, sizeof (ArtGradientStop) * n_stops); + + for(i = 0; i< n_stops; i++) + { + stops[n_stops * 2 - 1 - i].offset = (1.0 - stops[i].offset / 2.0); + memcpy (stops[n_stops * 2 - 1 - i].color, stops[i].color, sizeof (stops[i].color)); + stops[i].offset = stops[i].offset / 2.0; + } + + spread = ART_GRADIENT_REPEAT; + offset = offset / 2.0; + d_offset = d_offset / 2.0; + + n_stops = 2 * n_stops; + +#ifdef DEBUG_SPEW + printf ("reflect modified stops:"); + for(i=0;i<n_stops;i++) + { + printf ("%f, ", stops[i].offset); + } + printf ("\n"); +#endif + } + + offset_fraction = offset - floor (offset); +#ifdef DEBUG_SPEW + printf ("inital offset: %f, fraction: %f d_offset: %f\n", offset, offset_fraction, d_offset); +#endif + /* ix is selected so that offset_fraction is + stops[ix-1] <= offset_fraction <= stops[ix] + If offset_fraction is equal to one of the edges, ix + is selected so the the section of the line extending + in the same direction as d_offset is between ix-1 and ix. + */ + for(ix = 0; ix < n_stops; ix++) + if(stops[ix].offset > offset_fraction || + (d_offset < 0.0 && fabs (stops[ix].offset - offset_fraction) < EPSILON)) + break; + if(ix == 0) + ix = n_stops - 1; + else if(ix == n_stops) + ix = n_stops - 1; + +#ifdef DEBUG_SPEW + printf ("Initial ix: %d\n", ix); +#endif +#if 0 + assert (ix > 0); + assert (ix < n_stops); + assert ((stops[ix-1].offset <= offset_fraction + EPSILON) || + ((stops[ix].offset > (1.0 - EPSILON)) && (offset_fraction < EPSILON /* == 0.0*/))); + /*assert (offset_fraction <= stops[ix].offset);*/ + /* FIXME: These asserts may be broken, it is for now + safer to not use them. Should be fixed! + See bug #121850 + assert ((offset_fraction != stops[ix-1].offset) || + (d_offset >= 0.0)); + assert ((offset_fraction != stops[ix].offset) || + (d_offset <= 0.0)); + */ +#endif + while(width > 0) + { +#ifdef DEBUG_SPEW + printf ("ix: %d\n", ix); + printf ("start offset: %f\n", offset); +#endif + ksvg_calc_color_at (stops, n_stops, + spread, + offset, + offset_fraction, + (d_offset > -EPSILON), + ix, + color1); + + if(d_offset > 0) + next_stop = ix; + else + next_stop = ix-1; + +#ifdef DEBUG_SPEW + printf ("next_stop: %d\n", next_stop); +#endif + if(fabs (d_offset) > EPSILON) + { + double o; + o = offset_fraction; + + if((fabs (o) <= EPSILON) && (ix == n_stops - 1)) + o = 1.0; + else if((fabs (o-1.0) <= EPSILON) && (ix == 1)) + o = 0.0; + +#ifdef DEBUG_SPEW + printf ("o: %f\n", o); +#endif + len = (int)floor (fabs ((stops[next_stop].offset - o) / d_offset)) + 1; + len = MAX (len, 0); + len = MIN (len, width); + } + else + { + len = width; + } +#ifdef DEBUG_SPEW + printf ("len: %d\n", len); +#endif + if(len > 0) + { + offset = offset + (len-1) * d_offset; + offset_fraction = offset - floor (offset); +#ifdef DEBUG_SPEW + printf ("end offset: %f, fraction: %f\n", offset, offset_fraction); +#endif + ksvg_calc_color_at (stops, n_stops, + spread, + offset, + offset_fraction, + (d_offset < EPSILON), + ix, + color2); + + art_ksvg_rgba_gradient_run (bufp, + color1, + color2, + len); + offset += d_offset; + offset_fraction = offset - floor (offset); + } + + if(d_offset > 0) + { + do + { + ix++; + if(ix == n_stops) + ix = 1; + /* Note: offset_fraction can actually be one here on x86 machines that + does calculations with extended precision, but later rounds to 64bit. + This happens if the 80bit offset_fraction is larger than the + largest 64bit double that is less than one. + */ + } + while(!((stops[ix-1].offset <= offset_fraction && + offset_fraction < stops[ix].offset) || + (ix == 1 && offset_fraction > (1.0 - EPSILON)))); + } + else + { + do + { + ix--; + if(ix == 0) + ix = n_stops - 1; + } + while(!((stops[ix-1].offset < offset_fraction && + offset_fraction <= stops[ix].offset) || + (ix == n_stops - 1 && offset_fraction < EPSILON /* == 0.0*/))); + } + + bufp += 4*len; + width -= len; + } +} + +static void +art_ksvg_render_gradient_linear_done (ArtRenderCallback *self, ArtRender *render) +{ + art_free (self); +} + +static void +art_ksvg_render_gradient_linear_render (ArtRenderCallback *self, ArtRender *render, + art_u8 *dest, int y) +{ + ArtImageSourceGradLin *z = (ArtImageSourceGradLin *)self; + const ArtKSVGGradientLinear *gradient = &(z->gradient); + int pixstride = (render->n_chan + 1) * (render->depth >> 3); + int x; + int width = render->x1 - render->x0; + double offset, d_offset; + double actual_offset; + int n_stops = gradient->n_stops; + ArtGradientStop *stops = gradient->stops; + art_u8 *bufp = render->image_buf; + ArtGradientSpread spread = gradient->spread; + + offset = render->x0 * gradient->affine[0] + y * gradient->affine[2] + gradient->affine[4]; + d_offset = gradient->affine[0]; + + for(x = 0; x < width; x++) + { + if(spread == ART_GRADIENT_PAD) + actual_offset = offset; + else if(spread == ART_GRADIENT_REPEAT) + actual_offset = offset - floor (offset); + else /* (spread == ART_GRADIENT_REFLECT) */ + { + double tmp; + + tmp = offset - 2 * floor (0.5 * offset); + actual_offset = tmp > 1 ? 2 - tmp : tmp; + } + art_ksvg_render_gradient_setpix (render, bufp, n_stops, stops, actual_offset, gradient->interpolation); + offset += d_offset; + bufp += pixstride; + } +} + +static void +art_ksvg_render_gradient_linear_negotiate (ArtImageSource *self, ArtRender *render, + ArtImageSourceFlags *p_flags, + int *p_buf_depth, ArtAlphaType *p_alpha) +{ + ArtImageSourceGradLin *z = (ArtImageSourceGradLin *)self; + + if(render->depth == 8 && + render->n_chan == 3 && + z->gradient.interpolation == ART_KSVG_SRGB_INTERPOLATION) + { + /* The optimised renderer doesn't support linearRGB interpolation at the moment */ + /* so we only use it for sRGB, which is more common anyway. */ + self->super.render = art_ksvg_render_gradient_linear_render_8; + *p_flags = 0; + *p_buf_depth = 8; + *p_alpha = ART_ALPHA_SEPARATE; + return; + } + + self->super.render = art_ksvg_render_gradient_linear_render; + *p_flags = 0; + *p_buf_depth = render->depth; + *p_alpha = ART_ALPHA_SEPARATE; +} + +/** + * art_render_gradient_linear: Add a linear gradient image source. + * @render: The render object. + * @gradient: The linear gradient. + * + * Adds the linear gradient @gradient as the image source for rendering + * in the render object @render. + **/ +void +art_ksvg_render_gradient_linear (ArtRender *render, + const ArtKSVGGradientLinear *gradient, + ArtFilterLevel level) +{ + ArtImageSourceGradLin *image_source = art_alloc (sizeof (ArtImageSourceGradLin) + + sizeof (ArtGradientStop) * (gradient->n_stops - 1)); + + image_source->super.super.render = NULL; + image_source->super.super.done = art_ksvg_render_gradient_linear_done; + image_source->super.negotiate = art_ksvg_render_gradient_linear_negotiate; + + /* copy the gradient into the structure */ + image_source->gradient = *gradient; + image_source->gradient.stops = image_source->stops; + memcpy (image_source->gradient.stops, gradient->stops, sizeof (ArtGradientStop) * gradient->n_stops); + + art_render_add_image_source (render, &image_source->super); +} + diff --git a/ksvg/impl/libs/art_support/art_render_misc.h b/ksvg/impl/libs/art_support/art_render_misc.h new file mode 100644 index 00000000..d1f3690b --- /dev/null +++ b/ksvg/impl/libs/art_support/art_render_misc.h @@ -0,0 +1,90 @@ +/* This file is part of the KDE project. + * art_render_misc.c: Here I store some routines I feel should be in libart :) + * + * Copyright (C) 2001-2002 KSVG Team + * + * This code is adapted from : + * + * art_render_gradient.h: Gradient image source for modular rendering. + * + * Libart_LGPL - library of basic graphic primitives + * Copyright (C) 2000 Raph Levien + * + * 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; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * Authors: Raph Levien <raph@acm.org> + * Alexander Larsson <alla@lysator.liu.se> + */ + +#ifndef __ART_RENDER_MISC_H__ +#define __ART_RENDER_MISC_H__ + +#ifdef LIBART_COMPILATION +#include "art_filterlevel.h" +#include "art_render.h" +#include "art_render_gradient.h" +#else +#include <libart_lgpl/art_filterlevel.h> +#include <libart_lgpl/art_render.h> +#include <libart_lgpl/art_render_gradient.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +typedef enum +{ + ART_KSVG_SRGB_INTERPOLATION, + ART_KSVG_LINEARRGB_INTERPOLATION +} ArtKSVGGradientInterpolation; + +typedef struct _ArtKSVGGradientRadial ArtKSVGGradientRadial; + +struct _ArtKSVGGradientRadial { + double affine[6]; /* transforms user coordinates to unit circle */ + double fx, fy; /* focal point in unit circle coords */ + int n_stops; + ArtGradientSpread spread; + ArtGradientStop *stops; + ArtKSVGGradientInterpolation interpolation; +}; + +void +art_ksvg_render_gradient_radial (ArtRender *render, + const ArtKSVGGradientRadial *gradient, + ArtFilterLevel level); + +typedef struct _ArtKSVGGradientLinear ArtKSVGGradientLinear; + +struct _ArtKSVGGradientLinear { + double affine[6]; /* transforms screen gradient vector to unit vector (1, 0) */ + ArtGradientSpread spread; + int n_stops; + ArtGradientStop *stops; + ArtKSVGGradientInterpolation interpolation; +}; + +void +art_ksvg_render_gradient_linear (ArtRender *render, + const ArtKSVGGradientLinear *gradient, + ArtFilterLevel level); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __ART_RENDER_MISC_H__ */ diff --git a/ksvg/impl/libs/art_support/art_rgba_svp.c b/ksvg/impl/libs/art_support/art_rgba_svp.c new file mode 100644 index 00000000..47c7d924 --- /dev/null +++ b/ksvg/impl/libs/art_support/art_rgba_svp.c @@ -0,0 +1,659 @@ +/* Libart_LGPL - library of basic graphic primitives + * Copyright (C) 1998 Raph Levien + * + * 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; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +/* Render a sorted vector path into an RGB buffer. */ + +#include <X11/Xos.h> + +#include "art_rgba_svp.h" + +#include <libart_lgpl/art_svp.h> +#include <libart_lgpl/art_svp_render_aa.h> +#include <libart_lgpl/art_rgba.h> +#include <libart_lgpl/art_rgb.h> + +/* RGBA renderers */ + +typedef struct _ArtKSVGRgbaSVPAlphaData ArtKSVGRgbaSVPAlphaData; + +struct _ArtKSVGRgbaSVPAlphaData { + int alphatab[256]; + art_u8 r, g, b, alpha; + art_u32 rgba; + art_u8 *buf; + art_u8 *mask; + int rowstride; + int x0, x1; + int y0; +}; + +/** + * art_rgba_fill_run: fill an RGBA buffer a solid RGB color. + * @buf: Buffer to fill. + * @r: Red, range 0..255. + * @g: Green, range 0..255. + * @b: Blue, range 0..255. + * @n: Number of RGB triples to fill. + * + * Fills a buffer with @n copies of the (@r, @g, @b) triple, solid + * alpha. Thus, locations @buf (inclusive) through @buf + 4 * @n + * (exclusive) are written. + **/ +static void +art_ksvg_rgba_fill_run (art_u8 *buf, art_u8 r, art_u8 g, art_u8 b, int n) +{ + int i; +#if X_BYTE_ORDER == X_BIG_ENDIAN + art_u32 src_rgba; +#else + art_u32 src_abgr; +#endif + +#if X_BYTE_ORDER == X_BIG_ENDIAN + src_rgba = (r << 24) | (g << 16) | (b << 8) | 255; +#else + src_abgr = (255 << 24) | (b << 16) | (g << 8) | r; +#endif + for(i = 0; i < n; i++) + { +#if X_BYTE_ORDER == X_BIG_ENDIAN + ((art_u32 *)buf)[i] = src_rgba; +#else + ((art_u32 *)buf)[i] = src_abgr; +#endif + } +} + +/** + * art_rgba_run_alpha: Render semitransparent color over RGBA buffer. + * @buf: Buffer for rendering. + * @r: Red, range 0..255. + * @g: Green, range 0..255. + * @b: Blue, range 0..255. + * @alpha: Alpha, range 0..255. + * @n: Number of RGB triples to render. + * + * Renders a sequential run of solid (@r, @g, @b) color over @buf with + * opacity @alpha. Note that the range of @alpha is 0..255, in contrast + * to art_rgb_run_alpha, which has a range of 0..256. + **/ +static void +art_ksvg_rgba_run_alpha (art_u8 *buf, art_u8 r, art_u8 g, art_u8 b, int alpha, int n) +{ + int i; + int v; + int tmp; + + if(alpha > 255) + alpha = 255; + + for(i = 0; i < n; i++) + { + v = *buf; + tmp = (r - v) * alpha + 0x80; + *buf++ = v + ((tmp + (tmp >> 8)) >> 8); + + v = *buf; + tmp = (g - v) * alpha + 0x80; + *buf++ = v + ((tmp + (tmp >> 8)) >> 8); + + v = *buf; + tmp = (b - v) * alpha + 0x80; + *buf++ = v + ((tmp + (tmp >> 8)) >> 8); + + v = *buf; + tmp = (255 - alpha) * v + 0x80; + *buf++ = alpha + ((tmp + (tmp >> 8)) >> 8); + } +} + +static void +art_ksvg_rgba_mask_run_alpha (art_u8 *buf, art_u8 *mask, art_u8 r, art_u8 g, art_u8 b, int alpha, int n) +{ + int i; + int v; + int am; + int tmp; + + if(alpha > 255) + alpha = 255; + + for(i = 0; i < n; i++) + { + am = (alpha * *mask++) + 0x80; + am = (am + (am >> 8)) >> 8; + + v = *buf; + tmp = (r - v) * am + 0x80; + *buf++ = v + ((tmp + (tmp >> 8)) >> 8); + + v = *buf; + tmp = (g - v) * am + 0x80; + *buf++ = v + ((tmp + (tmp >> 8)) >> 8); + + v = *buf; + tmp = (b - v) * am + 0x80; + *buf++ = v + ((tmp + (tmp >> 8)) >> 8); + + v = *buf; + tmp = (255 - am) * v + 0x80; + *buf++ = am + ((tmp + (tmp >> 8)) >> 8); + } +} + +static void +art_ksvg_rgba_svp_alpha_callback(void *callback_data, int y, + int start, ArtSVPRenderAAStep *steps, int n_steps) +{ + ArtKSVGRgbaSVPAlphaData *data = (ArtKSVGRgbaSVPAlphaData *)callback_data; + art_u8 *linebuf; + int run_x0, run_x1; + art_u32 running_sum = start; + int x0, x1; + int k; + art_u8 r, g, b; + int *alphatab; + int alpha; + + linebuf = data->buf; + x0 = data->x0; + x1 = data->x1; + + r = data->r; + g = data->g; + b = data->b; + alphatab = data->alphatab; + + if (n_steps > 0) + { + run_x1 = steps[0].x; + if (run_x1 > x0) + { + alpha = (running_sum >> 16) & 0xff; + if (alpha) + art_ksvg_rgba_run_alpha (linebuf, + r, g, b, alphatab[alpha], + run_x1 - x0); + } + + for (k = 0; k < n_steps - 1; k++) + { + running_sum += steps[k].delta; + run_x0 = run_x1; + run_x1 = steps[k + 1].x; + if (run_x1 > run_x0) + { + alpha = (running_sum >> 16) & 0xff; + if (alpha) + art_ksvg_rgba_run_alpha (linebuf + (run_x0 - x0) * 4, + r, g, b, alphatab[alpha], + run_x1 - run_x0); + } + } + running_sum += steps[k].delta; + if (x1 > run_x1) + { + alpha = (running_sum >> 16) & 0xff; + if (alpha) + art_ksvg_rgba_run_alpha (linebuf + (run_x1 - x0) * 4, + r, g, b, alphatab[alpha], + x1 - run_x1); + } + } + else + { + alpha = (running_sum >> 16) & 0xff; + if (alpha) + art_ksvg_rgba_run_alpha (linebuf, + r, g, b, alphatab[alpha], + x1 - x0); + } + + data->buf += data->rowstride; +} + +static void +art_ksvg_rgba_svp_alpha_opaque_callback(void *callback_data, int y, + int start, + ArtSVPRenderAAStep *steps, int n_steps) +{ + ArtKSVGRgbaSVPAlphaData *data = (ArtKSVGRgbaSVPAlphaData *)callback_data; + art_u8 *linebuf; + int run_x0, run_x1; + art_u32 running_sum = start; + int x0, x1; + int k; + art_u8 r, g, b; + art_u32 rgba; + int *alphatab; + int alpha; + + linebuf = data->buf; + x0 = data->x0; + x1 = data->x1; + + r = data->r; + g = data->g; + b = data->b; + rgba = data->rgba; + alphatab = data->alphatab; + + if (n_steps > 0) + { + run_x1 = steps[0].x; + if (run_x1 > x0) + { + alpha = running_sum >> 16; + if (alpha) + { + if (alpha >= 255) + art_ksvg_rgba_fill_run (linebuf, + r, g, b, + run_x1 - x0); + else + art_ksvg_rgba_run_alpha (linebuf, + r, g, b, alphatab[alpha], + run_x1 - x0); + } + } + + for (k = 0; k < n_steps - 1; k++) + { + running_sum += steps[k].delta; + run_x0 = run_x1; + run_x1 = steps[k + 1].x; + if (run_x1 > run_x0) + { + alpha = running_sum >> 16; + if (alpha) + { + if (alpha >= 255) + art_ksvg_rgba_fill_run (linebuf + (run_x0 - x0) * 4, + r, g, b, + run_x1 - run_x0); + else + art_ksvg_rgba_run_alpha (linebuf + (run_x0 - x0) * 4, + r, g, b, alphatab[alpha], + run_x1 - run_x0); + } + } + } + running_sum += steps[k].delta; + if (x1 > run_x1) + { + alpha = running_sum >> 16; + if (alpha) + { + if (alpha >= 255) + art_ksvg_rgba_fill_run (linebuf + (run_x1 - x0) * 4, + r, g, b, + x1 - run_x1); + else + art_ksvg_rgba_run_alpha (linebuf + (run_x1 - x0) * 4, + r, g, b, alphatab[alpha], + x1 - run_x1); + } + } + } + else + { + alpha = running_sum >> 16; + if (alpha) + { + if (alpha >= 255) + art_ksvg_rgba_fill_run (linebuf, + r, g, b, + x1 - x0); + else + art_ksvg_rgba_run_alpha (linebuf, + r, g, b, alphatab[alpha], + x1 - x0); + } + } + data->buf += data->rowstride; +} + +static void +art_ksvg_rgba_svp_alpha_mask_callback(void *callback_data, int y, + int start, ArtSVPRenderAAStep *steps, int n_steps) +{ + ArtKSVGRgbaSVPAlphaData *data = (ArtKSVGRgbaSVPAlphaData *)callback_data; + art_u8 *linebuf; + int run_x0, run_x1; + art_u32 running_sum = start; + int x0, x1; + int k; + art_u8 r, g, b; + int *alphatab; + int alpha; + art_u8 *maskbuf; + + linebuf = data->buf; + x0 = data->x0; + x1 = data->x1; + + r = data->r; + g = data->g; + b = data->b; + alphatab = data->alphatab; + + maskbuf = data->mask + (y - data->y0) * (data->x1 - data->x0); + + if(n_steps > 0) + { + run_x1 = steps[0].x; + if(run_x1 > x0) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + art_ksvg_rgba_mask_run_alpha (linebuf, maskbuf, + r, g, b, alphatab[alpha], + run_x1 - x0); + } + + for(k = 0; k < n_steps - 1; k++) + { + running_sum += steps[k].delta; + run_x0 = run_x1; + run_x1 = steps[k + 1].x; + if(run_x1 > run_x0) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + art_ksvg_rgba_mask_run_alpha (linebuf + (run_x0 - x0) * 4, maskbuf + (run_x0 - x0), + r, g, b, alphatab[alpha], + run_x1 - run_x0); + } + } + running_sum += steps[k].delta; + if(x1 > run_x1) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + art_ksvg_rgba_mask_run_alpha (linebuf + (run_x1 - x0) * 4, maskbuf + (run_x1 - x0) , + r, g, b, alphatab[alpha], + x1 - run_x1); + } + } + else + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + art_ksvg_rgba_mask_run_alpha (linebuf, maskbuf, + r, g, b, alphatab[alpha], + x1 - x0); + } + + data->buf += data->rowstride; +} + +/** + * art_rgb_svp_alpha: Alpha-composite sorted vector path over RGB buffer. + * @svp: The source sorted vector path. + * @x0: Left coordinate of destination rectangle. + * @y0: Top coordinate of destination rectangle. + * @x1: Right coordinate of destination rectangle. + * @y1: Bottom coordinate of destination rectangle. + * @rgba: Color in 0xRRGGBBAA format. + * @buf: Destination RGB buffer. + * @rowstride: Rowstride of @buf buffer. + * @alphagamma: #ArtAlphaGamma for gamma-correcting the compositing. + * + * Renders the shape specified with @svp over the @buf RGB buffer. + * @x1 - @x0 specifies the width, and @y1 - @y0 specifies the height, + * of the rectangle rendered. The new pixels are stored starting at + * the first byte of @buf. Thus, the @x0 and @y0 parameters specify + * an offset within @svp, and may be tweaked as a way of doing + * integer-pixel translations without fiddling with @svp itself. + * + * The @rgba argument specifies the color for the rendering. Pixels of + * entirely 0 winding number are left untouched. Pixels of entirely + * 1 winding number have the color @rgba composited over them (ie, + * are replaced by the red, green, blue components of @rgba if the alpha + * component is 0xff). Pixels of intermediate coverage are interpolated + * according to the rule in @alphagamma, or default to linear if + * @alphagamma is NULL. + **/ +void +art_ksvg_rgba_svp_alpha(const ArtSVP *svp, + int x0, int y0, int x1, int y1, + art_u32 rgba, + art_u8 *buf, int rowstride, + ArtAlphaGamma *alphagamma, + art_u8 *mask) +{ + ArtKSVGRgbaSVPAlphaData data; + int r, g, b; + int i; + int a, da; + int alpha; + + r = (rgba >> 24) & 0xff; + g = (rgba >> 16) & 0xff; + b = (rgba >> 8) & 0xff; + alpha = rgba & 0xff; + + data.r = r; + data.g = g; + data.b = b; + data.alpha = alpha; + data.rgba = rgba; + data.mask = mask; + + a = 0x8000; + da = (alpha * 66051 + 0x80) >> 8; /* 66051 equals 2 ^ 32 / (255 * 255) */ + + for (i = 0; i < 256; i++) + { + data.alphatab[i] = a >> 16; + a += da; + } + + data.buf = buf; + data.rowstride = rowstride; + data.x0 = x0; + data.x1 = x1; + data.y0 = y0; + + if(mask) + art_svp_render_aa (svp, x0, y0, x1, y1, art_ksvg_rgba_svp_alpha_mask_callback, &data); + else + { + if (alpha == 255) + art_svp_render_aa (svp, x0, y0, x1, y1, art_ksvg_rgba_svp_alpha_opaque_callback, &data); + else + art_svp_render_aa (svp, x0, y0, x1, y1, art_ksvg_rgba_svp_alpha_callback, &data); + } +} + +/* RGB renderers */ + +static void +art_ksvg_rgb_mask_run_alpha(art_u8 *buf, art_u8 *mask, art_u8 r, art_u8 g, art_u8 b, int alpha, int n) +{ + int i; + int v; + int am; + int tmp; + + if(alpha > 255) + alpha = 255; + + for(i = 0; i < n; i++) + { + am = (alpha * *mask++) + 0x80; + am = (am + (am >> 8)) >> 8; + + v = *buf; + tmp = (r - v) * am + 0x80; + *buf++ = v + ((tmp + (tmp >> 8)) >> 8); + + v = *buf; + tmp = (g - v) * am + 0x80; + *buf++ = v + ((tmp + (tmp >> 8)) >> 8); + + v = *buf; + tmp = (b - v) * am + 0x80; + *buf++ = v + ((tmp + (tmp >> 8)) >> 8); + } +} + +static void +art_ksvg_rgb_svp_alpha_mask_callback(void *callback_data, int y, + int start, ArtSVPRenderAAStep *steps, int n_steps) +{ + ArtKSVGRgbaSVPAlphaData *data = (ArtKSVGRgbaSVPAlphaData *)callback_data; + art_u8 *linebuf; + int run_x0, run_x1; + art_u32 running_sum = start; + int x0, x1; + int k; + art_u8 r, g, b; + int *alphatab; + int alpha; + art_u8 *maskbuf; + + linebuf = data->buf; + x0 = data->x0; + x1 = data->x1; + + r = data->r; + g = data->g; + b = data->b; + alphatab = data->alphatab; + + maskbuf = data->mask + (y - data->y0) * (data->x1 - data->x0); + + if(n_steps > 0) + { + run_x1 = steps[0].x; + if(run_x1 > x0) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + art_ksvg_rgb_mask_run_alpha (linebuf, maskbuf, + r, g, b, alphatab[alpha], + run_x1 - x0); + } + + for(k = 0; k < n_steps - 1; k++) + { + running_sum += steps[k].delta; + run_x0 = run_x1; + run_x1 = steps[k + 1].x; + if(run_x1 > run_x0) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + art_ksvg_rgb_mask_run_alpha (linebuf + (run_x0 - x0) * 3, maskbuf + (run_x0 - x0), + r, g, b, alphatab[alpha], + run_x1 - run_x0); + } + } + running_sum += steps[k].delta; + if(x1 > run_x1) + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + art_ksvg_rgb_mask_run_alpha (linebuf + (run_x1 - x0) * 3, maskbuf + (run_x1 - x0) , + r, g, b, alphatab[alpha], + x1 - run_x1); + } + } + else + { + alpha = (running_sum >> 16) & 0xff; + if(alpha) + art_ksvg_rgb_mask_run_alpha (linebuf, maskbuf, + r, g, b, alphatab[alpha], + x1 - x0); + } + + data->buf += data->rowstride; +} + +/** + * art_rgb_svp_alpha: Alpha-composite sorted vector path over RGB buffer. + * @svp: The source sorted vector path. + * @x0: Left coordinate of destination rectangle. + * @y0: Top coordinate of destination rectangle. + * @x1: Right coordinate of destination rectangle. + * @y1: Bottom coordinate of destination rectangle. + * @rgba: Color in 0xRRGGBBAA format. + * @buf: Destination RGB buffer. + * @rowstride: Rowstride of @buf buffer. + * @alphagamma: #ArtAlphaGamma for gamma-correcting the compositing. + * + * Renders the shape specified with @svp over the @buf RGB buffer. + * @x1 - @x0 specifies the width, and @y1 - @y0 specifies the height, + * of the rectangle rendered. The new pixels are stored starting at + * the first byte of @buf. Thus, the @x0 and @y0 parameters specify + * an offset within @svp, and may be tweaked as a way of doing + * integer-pixel translations without fiddling with @svp itself. + * + * The @rgba argument specifies the color for the rendering. Pixels of + * entirely 0 winding number are left untouched. Pixels of entirely + * 1 winding number have the color @rgba composited over them (ie, + * are replaced by the red, green, blue components of @rgba if the alpha + * component is 0xff). Pixels of intermediate coverage are interpolated + * according to the rule in @alphagamma, or default to linear if + * @alphagamma is NULL. + **/ +void +art_ksvg_rgb_svp_alpha_mask(const ArtSVP *svp, + int x0, int y0, int x1, int y1, + art_u32 rgba, + art_u8 *buf, int rowstride, + ArtAlphaGamma *alphagamma, + art_u8 *mask) +{ + ArtKSVGRgbaSVPAlphaData data; + int r, g, b, alpha; + int i; + int a, da; + + r = rgba >> 24; + g = (rgba >> 16) & 0xff; + b = (rgba >> 8) & 0xff; + alpha = rgba & 0xff; + + data.r = r; + data.g = g; + data.b = b; + data.alpha = alpha; + data.mask = mask; + + a = 0x8000; + da = (alpha * 66051 + 0x80) >> 8; /* 66051 equals 2 ^ 32 / (255 * 255) */ + + for(i = 0; i < 256; i++) + { + data.alphatab[i] = a >> 16; + a += da; + } + + data.buf = buf; + data.rowstride = rowstride; + data.x0 = x0; + data.x1 = x1; + data.y0 = y0; + + art_svp_render_aa(svp, x0, y0, x1, y1, art_ksvg_rgb_svp_alpha_mask_callback, &data); +} + diff --git a/ksvg/impl/libs/art_support/art_rgba_svp.h b/ksvg/impl/libs/art_support/art_rgba_svp.h new file mode 100644 index 00000000..b59096d4 --- /dev/null +++ b/ksvg/impl/libs/art_support/art_rgba_svp.h @@ -0,0 +1,57 @@ +/* Libart_LGPL - library of basic graphic primitives + * Copyright (C) 1998 Raph Levien + * + * 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; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __ART_RGBA_SVP_H__ +#define __ART_RGBA_SVP_H__ + +/* Render a sorted vector path into an RGB buffer. */ + +#ifdef LIBART_COMPILATION +#include "art_alphagamma.h" +#include "art_svp.h" +#else +#include <libart_lgpl/art_alphagamma.h> +#include <libart_lgpl/art_svp.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +void +art_ksvg_rgba_svp_alpha(const ArtSVP *svp, + int x0, int y0, int x1, int y1, + art_u32 rgba, + art_u8 *buf, int rowstride, + ArtAlphaGamma *alphagamma, + art_u8 *mask); + +void +art_ksvg_rgb_svp_alpha_mask(const ArtSVP *svp, + int x0, int y0, int x1, int y1, + art_u32 rgba, + art_u8 *buf, int rowstride, + ArtAlphaGamma *alphagamma, + art_u8 *mask); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __ART_RGB_SVP_H__ */ diff --git a/ksvg/impl/libs/libtext2path/AUTHORS b/ksvg/impl/libs/libtext2path/AUTHORS new file mode 100644 index 00000000..efa499dd --- /dev/null +++ b/ksvg/impl/libs/libtext2path/AUTHORS @@ -0,0 +1 @@ +Nikolas Zimmermann <wildfox@kde.org> diff --git a/ksvg/impl/libs/libtext2path/COPYING b/ksvg/impl/libs/libtext2path/COPYING new file mode 100644 index 00000000..0b84a43f --- /dev/null +++ b/ksvg/impl/libs/libtext2path/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) 19yy <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/ksvg/impl/libs/libtext2path/ChangeLog b/ksvg/impl/libs/libtext2path/ChangeLog new file mode 100644 index 00000000..fad2a19b --- /dev/null +++ b/ksvg/impl/libs/libtext2path/ChangeLog @@ -0,0 +1,2 @@ +Fri Jul 25 08:30:43 CEST 2003 - Nikolas Zimmermann <wildfox@kde.org> + o Initial Creation diff --git a/ksvg/impl/libs/libtext2path/INSTALL b/ksvg/impl/libs/libtext2path/INSTALL new file mode 100644 index 00000000..28fadaa7 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/INSTALL @@ -0,0 +1,181 @@ +Basic Installation +================== + + These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, a file +`config.cache' that saves the results of its tests to speed up +reconfiguring, and a file `config.log' containing compiler output +(useful mainly for debugging `configure'). + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If at some point `config.cache' +contains results you don't want to keep, you may remove or edit it. + + The file `configure.in' is used to create `configure' by a program +called `autoconf'. You only need `configure.in' if you want to change +it or regenerate `configure' using a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. You can give `configure' +initial values for variables by setting them in the environment. Using +a Bourne-compatible shell, you can do that on the command line like +this: + CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure + +Or on systems that have the `env' program, you can do it like this: + env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not supports the `VPATH' +variable, you have to compile the package for one architecture at a time +in the source code directory. After you have installed the package for +one architecture, use `make distclean' before reconfiguring for another +architecture. + +Installation Names +================== + + By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PATH', the package will use +PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=PATH' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + + There may be some features `configure' can not figure out +automatically, but needs to determine by the type of host the package +will run on. Usually `configure' can figure that out, but if it prints +a message saying it can not guess the host type, give it the +`--host=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name with three fields: + CPU-COMPANY-SYSTEM + +See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the host type. + + If you are building compiler tools for cross-compiling, you can also +use the `--target=TYPE' option to select the type of system they will +produce code for and the `--build=TYPE' option to select the type of +system on which you are compiling the package. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Operation Controls +================== + + `configure' recognizes the following options to control how it +operates. + +`--cache-file=FILE' + Use and save the results of the tests in FILE instead of + `./config.cache'. Set FILE to `/dev/null' to disable caching, for + debugging `configure'. + +`--help' + Print a summary of the options to `configure', and exit. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--version' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`configure' also accepts some other, not widely useful, options. + diff --git a/ksvg/impl/libs/libtext2path/Makefile.am b/ksvg/impl/libs/libtext2path/Makefile.am new file mode 100644 index 00000000..c7f2f390 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/Makefile.am @@ -0,0 +1,7 @@ +SUBDIRS = src +DIST_SUBDIRS = src + +#pkgconfigdir = $(libdir)/pkgconfig +#kgconfig_DATA = libtext2path-0.1.pc + +#EXTRA_DIST = autogen.sh diff --git a/ksvg/impl/libs/libtext2path/NEWS b/ksvg/impl/libs/libtext2path/NEWS new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/NEWS @@ -0,0 +1 @@ + diff --git a/ksvg/impl/libs/libtext2path/README b/ksvg/impl/libs/libtext2path/README new file mode 100644 index 00000000..b9493b88 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/README @@ -0,0 +1,4 @@ +libtext2path v0.1 +Nikolas Zimmermann <wildfox@kde.org> +---------------------------------------------------------------------- +TODO: Write documentation! :) diff --git a/ksvg/impl/libs/libtext2path/VERSION b/ksvg/impl/libs/libtext2path/VERSION new file mode 100644 index 00000000..6c2cb464 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/VERSION @@ -0,0 +1 @@ +libtext2path-0.1 diff --git a/ksvg/impl/libs/libtext2path/configure.in.in b/ksvg/impl/libs/libtext2path/configure.in.in new file mode 100644 index 00000000..2198ab52 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/configure.in.in @@ -0,0 +1,41 @@ +#AC_INIT(src/Converter.h) +#AM_CONFIG_HEADER(config.h) + +dnl ----------------------------------------------- +dnl Package name and version number (user defined) +dnl ----------------------------------------------- +GENERIC_LIBRARY_NAME=libtext2path-0.1 + +# release versioning +GENERIC_MAJOR_VERSION=0 +GENERIC_MINOR_VERSION=1 +GENERIC_MICRO_VERSION=0 + +# API version (often = GENERIC_MAJOR_VERSION.GENERIC_MINOR_VERSION) +GENERIC_API_VERSION=0.1 +AC_SUBST(GENERIC_API_VERSION) + +#shared library versioning +GENERIC_LIBRARY_VERSION=0:1:0 + +dnl -------------------------------- +dnl Package name and version number +dnl -------------------------------- +AC_SUBST(GENERIC_LIBRARY_VERSION) + +AC_SUBST(GENERIC_LIBRARY_NAME) + +GENERIC_VERSION=$GENERIC_MAJOR_VERSION.$GENERIC_MINOR_VERSION.$GENERIC_MICRO_VERSION +GENERIC_RELEASE=$GENERIC_MAJOR_VERSION.$GENERIC_MINOR_VERSION +AC_SUBST(GENERIC_RELEASE) +AC_SUBST(GENERIC_VERSION) + + +dnl ----------------------------------------------- +dnl Checks for programs. +dnl ----------------------------------------------- + +dnl Check for fontconfig +# PKG_CHECK_MODULES(DEPS, fontconfig >= 2.2.0) +#AC_SUBST(DEPS_CFLAGS) +#AC_SUBST(DEPS_LIBS) diff --git a/ksvg/impl/libs/libtext2path/libtext2path.lsm b/ksvg/impl/libs/libtext2path/libtext2path.lsm new file mode 100644 index 00000000..7407a0ff --- /dev/null +++ b/ksvg/impl/libs/libtext2path/libtext2path.lsm @@ -0,0 +1,16 @@ +Begin4 +Title: libtext2path -- Some description +Version: 0.1 +Entered-date: YYYY-MM-DD +Description: +Keywords: KDE3 Qt +Author: Nikolas Zimmermann <wildfox@kde.org> +Maintained-by: Nikolas Zimmermann <wildfox@kde.org> +Home-page: +Alternate-site: +Primary-site: ftp://ftp.kde.org/pub/kde/unstable/apps/utils + xxxxxx libtext2path-0.1.tar.gz + xxx libtext2path-0.1.lsm +Platform: Linux. Needs KDE 2.x +Copying-policy: GPL +End diff --git a/ksvg/impl/libs/libtext2path/libtext2path.pc.in b/ksvg/impl/libs/libtext2path/libtext2path.pc.in new file mode 100644 index 00000000..1d4b4210 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/libtext2path.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libtext2path +Description: Converts FreeType glyphs to bezier paths +Version: @VERSION@ +Libs: -L${libdir} -ltext2path +Cflags: -I${includedir}/@GENERIC_LIBRARY_NAME@ -I${libdir}/@GENERIC_LIBRARY_NAME@/include + diff --git a/ksvg/impl/libs/libtext2path/libtext2path.spec b/ksvg/impl/libs/libtext2path/libtext2path.spec new file mode 100644 index 00000000..e0c217bd --- /dev/null +++ b/ksvg/impl/libs/libtext2path/libtext2path.spec @@ -0,0 +1,41 @@ +%define distversion %( perl -e 'Creating /home/nikoz/Projects/libtext2path/libtext2path.spec...=\<\>;/(\d+)\.(\d)\.?(\d)?/; print "".(||0)' /etc/*-release) +Name: libtext2path +Summary: libtext2path -- Some description +Version: 0.1 +Release: %{_vendor}_%{distversion} +Copyright: GPL +Group: X11/KDE/Utilities +Source: ftp://ftp.kde.org/pub/kde/unstable/apps/utils/%{name}-%{version}.tar.gz +Packager: Nikolas Zimmermann <wildfox@kde.org> +BuildRoot: /tmp/%{name}-%{version} +Prefix: /usr/kde/cvs + +%description +A long description + +%prep +rm -rf $RPM_BUILD_ROOT +%setup -n %{name}-%{version} +CFLAGS="" CXXFLAGS="" ./configure --disable-debug --enable-final --prefix=%{prefix} + +%build +# Setup for parallel builds +numprocs=1 +if [ "" = "0" ]; then + numprocs=1 +fi + +make -j + +%install +make install-strip DESTDIR=$RPM_BUILD_ROOT + +cd +find . -type d | sed '1,2d;s,^\.,\%attr(-\,root\,root) \%dir ,' > /%{name}-master.list +find . -type f -o -type l | sed 's|^\.||' >> $RPM_BUILD_DIR/%{name}-master.list + +%clean +rm -rf $RPM_BUILD_DIR/%{name}-%{version} +rm -rf $RPM_BUILD_DIR/-master.list + +%files -f $RPM_BUILD_DIR/%{name}-master.list diff --git a/ksvg/impl/libs/libtext2path/src/Affine.cpp b/ksvg/impl/libs/libtext2path/src/Affine.cpp new file mode 100644 index 00000000..d06b53bc --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/Affine.cpp @@ -0,0 +1,174 @@ +/* + Copyright (C) 2003 Nikolas Zimmermann <wildfox@kde.org> + 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 + aint 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 <math.h> + +#include "Point.h" +#include "Affine.h" + +using namespace T2P; + +Affine::Affine() +{ + m_affine[0] = 1.0; + m_affine[1] = 0.0; + m_affine[2] = 0.0; + m_affine[3] = 1.0; + m_affine[4] = 0.0; + m_affine[5] = 0.0; +} + +Affine::Affine(double affine[6]) +{ + for(int i = 0; i < 6; i++) + m_affine[i] = affine[i]; +} + +Affine::Affine(const Affine &other) +{ + (*this) = other; +} + +Affine::Affine(double m11, double m12, double m21, double m22, double dx, double dy) +{ + m_affine[0] = m11; m_affine[1] = m12; m_affine[2] = m21; + m_affine[3] = m22; m_affine[4] = dx; m_affine[5] = dy; +} + +Affine::~Affine() +{ +} + +Affine &Affine::operator*=(Affine &other) +{ + double d0 = m11() * other.m11() + m12() * other.m21(); + double d1 = m11() * other.m12() + m12() * other.m22(); + double d2 = m21() * other.m11() + m22() * other.m21(); + double d3 = m21() * other.m12() + m22() * other.m22(); + double d4 = dx() * other.m11() + dy() * other.m21() + other.dx(); + double d5 = dx() * other.m12() + dy() * other.m22() + other.dy(); + + m_affine[0] = d0; m_affine[1] = d1; m_affine[2] = d2; + m_affine[3] = d3; m_affine[4] = d4; m_affine[5] = d5; + + return *this; +} + +Affine &Affine::operator=(const Affine &other) +{ + for(int i = 0; i < 6; i++) + m_affine[i] = other.m_affine[i]; + + return *this; +} + +double &Affine::m11() +{ + return m_affine[0]; +} + +double &Affine::m12() +{ + return m_affine[1]; +} + +double &Affine::m21() +{ + return m_affine[2]; +} + +double &Affine::m22() +{ + return m_affine[3]; +} + +double &Affine::dx() +{ + return m_affine[4]; +} + +double &Affine::dy() +{ + return m_affine[5]; +} + +void Affine::scale(double s) +{ + scale(s, s); +} + +void Affine::scale(double sx, double sy) +{ + m_affine[0] = sx; + m_affine[3] = sy; +} + +void Affine::translate(const Point &point) +{ + m_affine[4] += point.x(); + m_affine[5] += point.y(); +} + +void Affine::translate(double tx, double ty) +{ + m_affine[4] += tx * m_affine[0] + ty * m_affine[2]; + m_affine[5] += tx * m_affine[1] + ty * m_affine[3]; +} + +void Affine::rotate(double angle) +{ + double sina = sin(angle); + double cosa = cos(angle); + + double tm11 = cosa * m_affine[0] + sina * m_affine[2]; + double tm12 = cosa * m_affine[1] + sina * m_affine[3]; + double tm21 = -sina * m_affine[0] + cosa * m_affine[2]; + double tm22 = -sina * m_affine[1] + cosa * m_affine[3]; + + m_affine[0] = tm11; m_affine[1] = tm12; + m_affine[2] = tm21; m_affine[3] = tm22; +} + +void Affine::rotateAround(double angle, const Point &point) +{ + translate(point); + rotate(angle); + translate(point.invert()); +} + +void Affine::rotateAround(double angle, double cx, double cy) +{ + translate(-cx, -cy); + rotate(angle); + translate(cx, cy); +} + +Point Affine::mapPoint(const Point &p) const +{ + return Point(p.x() * m_affine[0] + p.y() * m_affine[2] + m_affine[4], + p.x() * m_affine[1] + p.y() * m_affine[3] + m_affine[5]); +} + +double *Affine::data() +{ + return m_affine; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/libs/libtext2path/src/Affine.h b/ksvg/impl/libs/libtext2path/src/Affine.h new file mode 100644 index 00000000..c0f11e9b --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/Affine.h @@ -0,0 +1,67 @@ +/* + Copyright (C) 2003 Nikolas Zimmermann <wildfox@kde.org> + 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 + aint 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. +*/ + +#ifndef T2P_AFFINE_H +#define T2P_AFFINE_H + +namespace T2P +{ + class Point; + class Affine + { + public: + Affine(); + Affine(double affine[6]); + Affine(const Affine &other); + Affine(double m11, double m12, double m21, double m22, double dx, double dy); + ~Affine(); + + Affine &operator*=(Affine &other); + Affine &operator=(const Affine &other); + + double &m11(); + double &m12(); + double &m21(); + double &m22(); + double &dx(); + double &dy(); + + void scale(double s); + void scale(double sx, double sy); + void translate(const Point &point); // Assumes point is already transformed + void translate(double tx, double ty); + + void rotate(double angle); + void rotateAround(double angle, const Point &point); // Assumes point is already transformed + void rotateAround(double angle, double cx, double cy); + + Point mapPoint(const Point &p) const; + + // Internal + double *data(); + + private: + double m_affine[6]; + }; +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/libs/libtext2path/src/BezierPath.h b/ksvg/impl/libs/libtext2path/src/BezierPath.h new file mode 100644 index 00000000..1c357abd --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/BezierPath.h @@ -0,0 +1,56 @@ +/* + Copyright (C) 2003 Nikolas Zimmermann <wildfox@kde.org> + 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 + aint 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. +*/ + +#ifndef T2P_BEZIERPATH_H +#define T2P_BEZIERPATH_H + +#include <list> + +namespace T2P +{ + class Point; + class BezierPath + { + public: + BezierPath() { } + virtual ~BezierPath() { } + + /** + * Calculates the arclength from p0 to the point parametrized by 0 <= t <= 1. + */ + virtual double length(double t = 1.0) = 0; + + /** + * Calculates the point, the tangent vector and the normal vector for + * 0 <= t <= 1. The tangent vector and the normal vector are + * normalized (length=1). + */ + virtual void pointTangentNormalAt(double t, Point *p = 0, Point *tn = 0, Point *n = 0) = 0; + + /** + * Calculates the axis-aligned bounding box. + */ + virtual void boundingBox(Point *topLeft, Point *bottomRight) = 0; + }; +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/libs/libtext2path/src/Cache.h b/ksvg/impl/libs/libtext2path/src/Cache.h new file mode 100644 index 00000000..a85fdf92 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/Cache.h @@ -0,0 +1,156 @@ +/* + Copyright (C) 2003 Nikolas Zimmermann <wildfox@kde.org> + 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 + aint 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. +*/ + +#ifndef T2P_CACHE_H +#define T2P_CACHE_H + +#include <map> +#include <string> +#include <vector> +#include <iostream> + +#include "myboost/shared_ptr.hpp" + +namespace T2P +{ + class CacheElement + { + public: + CacheElement(std::string key) : m_key(key), m_usage(0) { } + ~CacheElement() { } + + std::string key() const { return m_key; } + int usage() const { return m_usage; } + + void incUsage() { m_usage++; } + + private: + std::string m_key; + int m_usage; + }; + + template<typename T> + class Cache + { + public: + typedef myboost::shared_ptr<T> SharedT; + + Cache(int maxSize = 10) : m_size(0), m_maxSize(maxSize) { } + ~Cache() { clear(); } + + // Number of elements in cache + int size() const { return m_size; } + + // Maximum number of elements in cache + int maxSize() const { return m_maxSize; } + + // Add new entry + void insert(const std::string &key, SharedT &value) + { + // TODO: Add real LRU logic, now i will just delete the less + // used item when inserting a new item would exceed maxSize + if(m_size == m_maxSize) + { + // Find less used item + typename std::map<SharedT, CacheElement *>::const_iterator it = m_cacheMap.begin(); + int usage = (*it).second->usage(); std::string keyUsage = (*it).second->key(); + for(it++; it != m_cacheMap.end(); ++it) + { + int curUsage = (*it).second->usage(); + if(curUsage < usage) + { + usage = curUsage; + keyUsage = (*it).second->key(); + } + } + +// std::cout << "[CACHE] Removing less used element with key: " << keyUsage << " (Used " << usage << " times!)" << std::endl; + remove(keyUsage); + } + + m_size++; + m_entries.push_back(value); + m_cacheMap[value] = new CacheElement(key); + } + + // Remove single entry + void remove(const std::string &key) + { + for(typename std::vector<SharedT>::iterator it = m_entries.begin(); it != m_entries.end(); ++it) + { + SharedT cur = *it; + if(m_cacheMap[cur]->key() == key) + { + m_size--; + + typename std::map<SharedT, CacheElement *>::iterator cacheElement = m_cacheMap.find(cur); + m_cacheMap.erase(cacheElement); + delete cacheElement->second; + m_entries.erase(it); // Only valid to write because we don't go on here! + break; // Otherwhise the iterators _may_ be invalid! + } + } + } + + // Remove all entries + void clear() + { + m_size = 0; + m_entries.clear(); + m_cacheMap.clear(); + } + + // Lookup entry + SharedT find(const std::string &key) + { + for(typename std::vector<SharedT>::const_iterator it = m_entries.begin(); it != m_entries.end(); ++it) + { + SharedT cur = *it; + if(m_cacheMap[cur]->key() == key) + { + m_cacheMap[cur]->incUsage(); + return cur; + } + } + + return SharedT(); + } + + void dump() + { + std::cout << "[CACHE] " << size() << " of " << maxSize() << " Objects in the cache." << std::endl; + + for(typename std::vector<SharedT>::iterator it = m_entries.begin(); it != m_entries.end(); ++it) + { + SharedT cur = *it; + std::cout << "[CACHE] - " << m_cacheMap[cur]->key() << " -> " << cur << " (Usage: " << m_cacheMap[cur]->usage() << ")" << std::endl; + } + } + + private: + std::vector<SharedT> m_entries; + std::map<SharedT, CacheElement *> m_cacheMap; + int m_size, m_maxSize; + }; +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/libs/libtext2path/src/Converter.cpp b/ksvg/impl/libs/libtext2path/src/Converter.cpp new file mode 100644 index 00000000..7810b417 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/Converter.cpp @@ -0,0 +1,505 @@ +/* + Copyright (C) 2003 Nikolas Zimmermann <wildfox@kde.org> + 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 + aint 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 <math.h> + +#include "myboost/shared_ptr.hpp" +#include <fontconfig/fontconfig.h> +#include <fribidi/fribidi.h> +#include <fribidi/fribidi_types.h> + +#include "Font.h" +#include "Glyph.h" +#include "Tools.h" +#include "Rectangle.h" +#include "Converter.h" +#include "QtUnicode.h" +#include "GlyphTracer.h" + +// Macros +#define FT_TRUNC(x) ((x) >> 6) +#define FT_TOFLOAT(x) ((x) * (1.0 / 64.0)) +#define FT_FROMFLOAT(x) ((int) floor ((x) * 64.0 + 0.5)) + +const double deg2rad = 0.017453292519943295769; // pi/180 + +using namespace T2P; + +// Font engine. The core component. +Converter::Converter(GlyphTracer *tracer) : m_glyphTracer(tracer) +{ + m_init = false; + m_kerning = true; + m_library = 0; +} + +Converter::~Converter() +{ + if(m_glyphTracer) + delete m_glyphTracer; + + m_fontCache.clear(); + m_glyphCache.clear(); + + // Close FreeType2 library + if(m_library) + FT_Done_FreeType(m_library); +} + +void Converter::init() +{ + // Initialize FreeType2 + m_init = (FT_Init_FreeType(&m_library) == 0); +} + +bool Converter::ready() +{ + return m_init; +} + +void Converter::setKerning(bool mode) +{ + m_kerning = mode; +} + +// Lookup font in cache or create new font +SharedFont Converter::requestFont(const FontVisualParams *params) +{ + std::string cacheKey = cacheFontKey(params); + SharedFont cached = m_fontCache.find(cacheKey); + + // If not available in cache, create new one and cache it :) + if(cached) + { + delete params; + return cached; + } + else + { + // Create a new Font + SharedFont newFont(new Font(this)); + + // Load the font + if(!newFont->load(params)) + { + delete params; + return SharedFont(); + } + + // Append to cache + m_fontCache.insert(cacheKey, newFont); + return newFont; + } +} + +GlyphAffinePair *Converter::requestGlyph(GlyphRenderParams *params, Rectangle &bbox, Affine &affine, bool onlyLatin) +{ + // 1. Select glyph to have glyphIndex information, + // needed to generate the cache lookup key + selectGlyph(params); + + SharedGlyph cached = m_glyphCache.find(cacheGlyphKey(params)); + + // If not available in cache, render new one and cache it :) + // If we're mixing ie. japanese and latin characters (TTB layout), + // then we also have to re-calculate the glyph again with the appropriate rotation matrix (Niko) + if(!cached || !onlyLatin) + cached = calcGlyph(params, affine, onlyLatin); + + // Correct bezier path by setting up the correct scaling matrix + // and multiplying with the current glyph affine + double fontSize = params->font()->fontParams()->size(); + + T2P::Affine correctAffine; + correctAffine.scale(0.001 * fontSize, -0.001 * fontSize); + correctAffine *= affine; + + // Get bbox information + Point p1(FT_TRUNC(cached->ftBbox()->xMin), FT_TRUNC(cached->ftBbox()->yMin)); + Point p2(FT_TRUNC(cached->ftBbox()->xMax), FT_TRUNC(cached->ftBbox()->yMax)); + + bbox.setA(affine.mapPoint(p1)); + bbox.setB(affine.mapPoint(p2)); + + return new GlyphAffinePair(cached.get(), correctAffine); +} + +void Converter::selectGlyph(GlyphRenderParams *params) +{ + // 1. Select glyph + test if it exists + // | + // |-> if it doesn't exist, replace by a '?' and check if exists + // |-> if it does exist, use it! + params->setGlyphIndex(FT_Get_Char_Index(params->font()->fontFace(), (FT_ULong) params->character())); + + if(params->glyphIndex() == 0) + params->setGlyphIndex(FT_Get_Char_Index(params->font()->fontFace(), '?')); + + // 2. Load glyph into font's glyphSlot, according to the GlyphLayoutParams + int flags = FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP; + + // 3. Don't pass FT_LOAD_VERTICAL_LAYOUT on TTB layouts when rendering + // a latin glyph because it needs to be rotated... + if(params->layout()->tb()) + { + Script script; + SCRIPT_FOR_CHAR(script, params->character()) + if(script != Latin || params->layout()->glyphOrientationVertical() == 0) + flags |= FT_LOAD_VERTICAL_LAYOUT; + } + + FT_Error error = FT_Load_Glyph(params->font()->fontFace(), params->glyphIndex(), flags); + if(error) + params->setGlyphIndex(0); +} + +SharedGlyph Converter::calcGlyph(const GlyphRenderParams *params, Affine &affine, bool onlyLatin) +{ + // 2. Apply kerning if needed + if(m_kerning && params->lastGlyph() != 0 && params->glyphIndex() != 0) + { + FT_Vector kerningVector; + double kx, ky; + + FT_Get_Kerning(params->font()->fontFace(), params->lastGlyph(), params->glyphIndex(), ft_kerning_default, &kerningVector); + + kx = FT_TRUNC(kerningVector.x); + ky = FT_TRUNC(kerningVector.y); + + affine.dx() += kx + affine.m21() * ky; + + // Only apply y kerning in TB mode + if(params->layout()->tb()) + affine.dy() += kx + affine.m22() * ky; + } + + // 3. Prepare path tracing + FT_OutlineGlyph ftGlyph; + FT_Get_Glyph(params->font()->fontFace()->glyph, reinterpret_cast<FT_Glyph *>(&ftGlyph)); + + // 3a. Prepare tracing matrix + Affine traceAffine; + traceAffine.scale(1000.0 / params->font()->fontFace()->units_per_EM); + + // 3b. Enable character rotation, if needed + if(params->layout()->tb()) + { + Script script; + SCRIPT_FOR_CHAR(script, params->character()) + if(!onlyLatin && script == Latin) + { + FT_Matrix matrix; + + double angle = deg2rad * params->layout()->glyphOrientationVertical(); + matrix.xx = (FT_Fixed)( cos(angle) * 0x10000L); + matrix.xy = (FT_Fixed)(-sin(angle) * 0x10000L); + matrix.yx = (FT_Fixed)( sin(angle) * 0x10000L); + matrix.yy = (FT_Fixed)( cos(angle) * 0x10000L); + + FT_Glyph_Transform(reinterpret_cast<FT_Glyph>(ftGlyph), &matrix, 0); + } + } + + // 4. Begin path tracing + // - Setup glyphOutlineing glyph + // - Start tracing + // - Close path + FT_Outline *ftOut = &ftGlyph->outline; + + SharedGlyph glyphOutline(new Glyph()); + glyphOutline->setBezierPath(m_glyphTracer->allocBezierPath(ftOut->n_points * 2 + ftOut->n_contours + 1)); + glyphOutline->setAffine(traceAffine); + + FT_Outline_Decompose(ftOut, m_glyphTracer->outlineFuncs(), glyphOutline.get()); + + m_glyphTracer->closePath(glyphOutline.get()); + + // 5. Determine bounding box (aka "cbox") + FT_Glyph_Get_CBox(reinterpret_cast<FT_Glyph>(ftGlyph), ft_glyph_bbox_unscaled, glyphOutline->ftBbox()); + + // 6. Cache glyph! + m_glyphCache.insert(cacheGlyphKey(params), glyphOutline); + + FT_Done_Glyph(reinterpret_cast<FT_Glyph>(ftGlyph)); + + return glyphOutline; +} + +GlyphSet *Converter::calcString(Font *font, const unsigned short *text, unsigned int length, Affine &affine, const GlyphLayoutParams *params, BezierPath *bpath) +{ + unsigned short *bidi = 0; + + // 0. Apply BiDi Rules + if(params->useBidi()) + { + FriBidiCharType baseDir = FRIBIDI_TYPE_N; + FriBidiChar *unicodeIn = new FriBidiChar[length + 1]; + FriBidiChar *unicodeOut = new FriBidiChar[length + 1]; + bidi = new unsigned short[length + 1]; + + for(unsigned int i = 0; i < length; i++) + unicodeIn[i] = text[i]; + + fribidi_log2vis(unicodeIn, length, &baseDir, unicodeOut, 0, 0, 0); + + for(unsigned int i = 0; i < length; i++) + bidi[i] = unicodeOut[i]; + + bidi[length] = 0; + delete []unicodeIn; + delete []unicodeOut; + } + else + bidi = const_cast<unsigned short *>(text); + + // Detect character rotation if needed, + // probably working in 0.1% of the cases :/ + Script script; + bool onlyLatin = true; + for(unsigned int i = 0; i < length; i++) + { + SCRIPT_FOR_CHAR(script, bidi[i]) + if(script != Latin) + { + onlyLatin = false; + break; + } + } + + // 1. Set initial font size + double fontSize = font->fontParams()->size(); + FT_Set_Char_Size(font->fontFace(), FT_FROMFLOAT(fontSize), FT_FROMFLOAT(fontSize), 0, 0); + + // 2. Compute positioning metrics + // - See http://www.freetype.org/freetype2/docs/tutorial/stepX.html (X = 1 or 2) + int pixelHeight = (int) (FT_TOFLOAT(font->fontFace()->size->metrics.ascender - font->fontFace()->size->metrics.descender) * affine.m22()); + int pixelBaseline = (int) (FT_TOFLOAT(font->fontFace()->size->metrics.ascender) * affine.m22()); + int pixelUnderlinePosition = (int) (((font->fontFace()->ascender - font->fontFace()->underline_position - font->fontFace()->underline_thickness / 2) * fontSize / font->fontFace()->units_per_EM) * affine.m22()); + int pixelUnderlineThickness = T2PMAX(1, (int) ((font->fontFace()->underline_thickness * fontSize / font->fontFace()->units_per_EM) * affine.m22())); + + // 3. Prepare needed variables for the rendering loop + // - rendering params (layout, font...) + // - bounding box (per glyph, overall) + // - glyph matrix (overall) + // - resulting glyph sets + GlyphRenderParams *renderParams = new GlyphRenderParams(); + renderParams->setFont(font); + renderParams->setLayout(params); + renderParams->setLastGlyph(0); + renderParams->setGlyphIndex(0); + + Affine glyphAffine(affine); + Rectangle bbox, currentBbox; + GlyphSet *result = new GlyphSet(); + + // Align to path start, if bpath != 0 + Point pathPoint, pathTangent, pathNormal; + double pathLength = 0, pathAdvance = 0; + double startOffset = params->textPathStartOffset(); + + if(bpath) + { + pathLength = bpath->length(); + bpath->pointTangentNormalAt(startOffset, &pathPoint, &pathTangent); + + glyphAffine.dx() = pathPoint.x(); + glyphAffine.dy() = pathPoint.y(); + glyphAffine.rotate(atan2(pathTangent.y(), pathTangent.x())); + + std::cout << "[T2P] Starting textPath at: " << pathPoint.x() << ", " << pathPoint.y() << std::endl; + } + + // <tspan> elements can have different baseline-shift's + // baseline-shift support (Niko) + double baseline = 0; + if(!params->baselineShift().empty()) + { + if(params->baselineShift() == "sub") + baseline += fontSize / 5 + 1; + else if(params->baselineShift() == "super") + baseline -= fontSize / 3 + 1; + else + { + std::string temp = params->baselineShift(); + if(temp.find("%") > 0) + baseline -= (atof(temp.c_str()) / 100.0) * fontSize; + else + baseline -= atoi(temp.c_str()); + } + + if(!params->tb()) + glyphAffine.translate(0, baseline); + else + glyphAffine.translate(-baseline, 0); + } + + // 4. Enter main rendering loop + for(unsigned int i = 0; i < length; i++) + { + // 4a. Modify character to render + renderParams->setCharacter(bidi[i]); + + // 4c. Get glyph outline + GlyphAffinePair *glyphOutline = requestGlyph(renderParams, currentBbox, glyphAffine, onlyLatin); + m_glyphTracer->correctGlyph(glyphOutline); + + // 4d. Save advance values + result->m_glyphXAdvance.push_back((font->fontFace()->glyph->advance.x * fontSize / font->fontFace()->units_per_EM) * affine.m11()); + result->m_glyphYAdvance.push_back((font->fontFace()->glyph->advance.y * fontSize / font->fontFace()->units_per_EM) * affine.m22()); + + // 4e. Misc + // - union current + overall bounding box + // - add glyph to list of glyphs + // - apply letter & word spacing + if(renderParams->glyphIndex() != 0) + { + // Remember last glyph for kerning + renderParams->setLastGlyph(renderParams->glyphIndex()); + + // Union current + overall bounding box + bbox.bboxUnion(bbox, currentBbox); + + // Move glyph locations for the next glyph to be + // rendered apply letter & word spacing + bool addGlyph = true; + if(!params->tb()) + { + if(bpath) + { + double advance = startOffset + (pathAdvance / pathLength); + if(advance < 0.0 || advance > 1.0) // dont render off-path glyphs + addGlyph = false; + + pathAdvance += (result->m_glyphXAdvance.back() + params->letterSpacing() * affine.m11()) + ((bidi[(i + 1)] == ' ') ? params->wordSpacing() * affine.m11() : 0); + + std::cout << "[T2P] Adjusting textPath advance: " << pathAdvance << " Path Length: " << pathLength << " StartOffset: " << startOffset << " Position in Path (relative 0-1): " << pathAdvance/pathLength << " Adjusted by offset: " << startOffset + (pathAdvance / pathLength) << std::endl; + + bpath->pointTangentNormalAt(startOffset + (pathAdvance / pathLength), &pathPoint, &pathTangent, &pathNormal); + + glyphAffine.m11() = affine.m11(); + glyphAffine.m12() = affine.m12(); + glyphAffine.m21() = affine.m21(); + glyphAffine.m22() = affine.m22(); + glyphAffine.dx() = pathPoint.x(); + glyphAffine.dy() = pathPoint.y(); + + glyphAffine.rotateAround(atan2(pathTangent.y(), pathTangent.x()), Point(result->m_glyphXAdvance.back() / 2, result->m_glyphYAdvance.back() / 2)); + + std::cout << "[T2P] Aligning textPath to: " << pathPoint.x() << ", " << pathPoint.y() << std::endl; + if(!params->tb()) + glyphAffine.translate(0, baseline); + else + glyphAffine.translate(-baseline, 0); + } + else + glyphAffine.dx() += (result->m_glyphXAdvance.back() + params->letterSpacing() * affine.m11()) + ((bidi[(i + 1)] == ' ') ? params->wordSpacing() * affine.m11() : 0); + } + else + { + double advy = result->m_glyphYAdvance.back(); + + Script script; + SCRIPT_FOR_CHAR(script, bidi[i]) + if(!onlyLatin && script == Latin && params->glyphOrientationVertical() != 0) + advy = result->m_glyphXAdvance.back(); + + glyphAffine.dy() += (advy + params->letterSpacing() * affine.m22()) + ((bidi[(i + 1)] == ' ') ? params->wordSpacing() * affine.m22() : 0); + } + + // Copy bezier path/affine pair + if(addGlyph) + { + result->m_set.push_back(glyphOutline); + result->m_glyphCount++; + } + else + delete glyphOutline; + } + } + + // 5. Fill out resulting data structures + result->m_underlinePosition = pixelUnderlinePosition; + result->m_overlinePosition = pixelHeight - pixelUnderlinePosition; + result->m_strikeThroughPosition = (result->m_underlinePosition + result->m_overlinePosition) / 2; + result->m_pixelBaseline = pixelBaseline; + result->m_underlineThickness = pixelUnderlineThickness; + + result->m_xpen = glyphAffine.dx() - affine.dx(); + result->m_ypen = glyphAffine.dy() - affine.dy(); + + result->m_bboxX = T2PMAX(1, int(bbox.a().x())); + result->m_bboxY = T2PMAX(1, int(bbox.a().y() - int(pixelHeight / 2))); + result->m_height = T2PMAX(1, int(bbox.b().y() - bbox.a().y())); + + // Correct bounding box information also on + // vertical layouts! (Niko) + if(!params->tb()) + { + if(bpath) + result->m_width = int(pathAdvance); + else + result->m_width = T2PMAX(1, int(bbox.b().x() - bbox.a().x())); + } + else + result->m_width = T2PMAX(1, pixelHeight); + + // 6. Cleanup memory + if(text != bidi) + delete []bidi; + + delete renderParams; + + // 7. Eventually, dump cache statistics + // m_glyphCache.dump(); + // m_fontCache.dump(); + + return result; +} + +std::string Converter::cacheFontKey(const FontVisualParams *params) const +{ + // TODO: Tune the key + std::string key; + + key += Tools::joinList('|', const_cast<FontVisualParams *>(params)->fontList()); + key += Tools::a2str(params->weight()); + key += Tools::a2str(params->slant()); + key += Tools::a2str(params->size()); + + // std::cout << "Font cache key: " << key << std::endl; + return key; +} + +std::string Converter::cacheGlyphKey(const GlyphRenderParams *params) const +{ + // TODO: Tune the key + std::string key; + + key += params->font()->fontFile(); + key += Tools::a2str(params->character()); + key += Tools::a2str(params->glyphIndex()); + key += Tools::a2str(params->font()->fontParams()->size()); + key += Tools::a2str(params->font()->fontParams()->weight()); + key += Tools::a2str(params->font()->fontParams()->slant()); + + // std::cout << "Glyph cache key: " << key << std::endl; + return key; +} +// vim:ts=4:noet diff --git a/ksvg/impl/libs/libtext2path/src/Converter.h b/ksvg/impl/libs/libtext2path/src/Converter.h new file mode 100644 index 00000000..d6e19521 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/Converter.h @@ -0,0 +1,94 @@ +/* + Copyright (C) 2003 Nikolas Zimmermann <wildfox@kde.org> + 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 + aint 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. +*/ + +#ifndef T2P_CONVERTER_H +#define T2P_CONVERTER_H + +#include "Cache.h" + +// FreeType 2 includes +#include <ft2build.h> +#include FT_FREETYPE_H +#include FT_OUTLINE_H +#include FT_GLYPH_H + +namespace T2P +{ + class BezierPath; + + class Font; + class Glyph; + class Affine; + class GlyphSet; + class Rectangle; + class GlyphTracer; + class GlyphAffinePair; + class FontVisualParams; + class GlyphLayoutParams; + class GlyphRenderParams; + + typedef myboost::shared_ptr<Font> SharedFont; + typedef myboost::shared_ptr<Glyph> SharedGlyph; + + class Converter + { + public: + Converter(GlyphTracer *tracer); + ~Converter(); + + // Is initialized? + void init(); + bool ready(); + + // Kerning control + void setKerning(bool mode); + + SharedFont requestFont(const FontVisualParams *params); + GlyphAffinePair *requestGlyph(GlyphRenderParams *params, Rectangle &bbox, Affine &affine, bool onlyLatin); + + GlyphSet *calcString(Font *font, const unsigned short *text, unsigned int length, Affine &affine, const GlyphLayoutParams *params, BezierPath *bpath = 0); + SharedGlyph calcGlyph(const GlyphRenderParams *params, Affine &affine, bool onlyLatin); + + void selectGlyph(GlyphRenderParams *params); + + protected: + friend class Font; + + // Internal + FT_Library library() { return m_library; } + + private: + std::string cacheFontKey(const FontVisualParams *params) const; + std::string cacheGlyphKey(const GlyphRenderParams *params) const; + + FT_Library m_library; + + GlyphTracer *m_glyphTracer; + + Cache<Glyph> m_glyphCache; + Cache<Font> m_fontCache; + + bool m_init, m_kerning; + }; +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/libs/libtext2path/src/Font.cpp b/ksvg/impl/libs/libtext2path/src/Font.cpp new file mode 100644 index 00000000..1d6f7005 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/Font.cpp @@ -0,0 +1,252 @@ +/* + Copyright (C) 2003 Nikolas Zimmermann <wildfox@kde.org> + 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 + aint 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 <math.h> +#include <iostream> +#include <fontconfig/fontconfig.h> + +#include "Font.h" +#include "Tools.h" +#include "Converter.h" + +// Macros +#define FT_TRUNC(x) ((x) >> 6) +#define FT_TOFLOAT(x) ((x) * (1.0 / 64.0)) +#define FT_FROMFLOAT(x) ((int) floor ((x) * 64.0 + 0.5)) + +using namespace T2P; + +FontVisualParams::FontVisualParams() +{ + m_size = 0.0; + m_slant = 0; + m_weight = 0; +} + +FontVisualParams::FontVisualParams(const FontVisualParams &other) +{ + (*this) = other; +} + +FontVisualParams::~FontVisualParams() +{ +} + +FontVisualParams &FontVisualParams::operator=(const FontVisualParams &other) +{ + m_size = other.m_size; + m_slant = other.m_slant; + m_weight = other.m_weight; + m_fontList = other.m_fontList; + + return *this; +} + +void FontVisualParams::setWeight(int weight) +{ + m_weight = weight; +} + +int FontVisualParams::weight() const +{ + return m_weight; +} + +void FontVisualParams::setSlant(int slant) +{ + m_slant = slant; +} + +int FontVisualParams::slant() const +{ + return m_slant; +} + +void FontVisualParams::setSize(double size) +{ + m_size = size; +} + +double FontVisualParams::size() const +{ + return m_size; +} + +std::list<std::string> &FontVisualParams::fontList() +{ + return m_fontList; +} + +// ##### + +Font::Font(Converter *context) : m_context(context) +{ + m_ready = false; + + m_fontFace = 0; + m_fontParams = 0; +} + +Font::~Font() +{ + // Release font face + if(m_ready && m_fontFace) + { + // FIXME: Debug that! + //std::cout << "CALLING DONE FACE " << m_fontFace << std::endl; + FT_Done_Face(m_fontFace); + } + + delete m_fontParams; +} + +std::string Font::buildRequest(const FontVisualParams *fontParams, int &id) +{ + // Use FontConfig to locate & select fonts and use + // FreeType2 to open them + FcPattern *pattern; + std::string fileName; + + pattern = FcPatternBuild(0, + FC_WEIGHT, FcTypeInteger, fontParams->weight(), + FC_SLANT, FcTypeInteger, fontParams->slant(), + FC_SIZE, FcTypeDouble, fontParams->size(), + NULL); + + // Add multiple font names + std::list<std::string> &fontList = const_cast<FontVisualParams *>(fontParams)->fontList(); + + for(std::list<std::string>::const_iterator it = fontList.begin(); it != fontList.end(); ++it) + { + std::string string = *it; + + if(!string.empty()) + FcPatternAddString(pattern, FC_FAMILY, reinterpret_cast<const FcChar8 *>(string.c_str())); + } + + // Always load vertical layout + FcPatternAddBool(pattern, FC_VERTICAL_LAYOUT, true); + + // Disable hinting + FcPatternAddBool(pattern, FC_HINTING, false); + + // Perform the default font pattern modification operations. + FcDefaultSubstitute(pattern); + FcConfigSubstitute(FcConfigGetCurrent(), pattern, FcMatchPattern); + + // Match the pattern! + FcResult result; + FcPattern *match = FcFontMatch(0, pattern, &result); + + // Destroy pattern + FcPatternDestroy(pattern); + + // Get index & filename + FcChar8 *temp; + + if(match) + { + FcPattern *pattern = FcPatternDuplicate(match); + + // Get index & filename + if(FcPatternGetString(pattern, FC_FILE, 0, &temp) != FcResultMatch || + FcPatternGetInteger(pattern, FC_INDEX, 0, &id) != FcResultMatch) + { + std::cout << "Font::buildRequest(), could not load font file for requested font \"" << Tools::joinList('|', fontList) << "\"" << std::endl; + return fileName; + } + + fileName = reinterpret_cast<const char *>(temp); + + // Kill pattern + FcPatternDestroy(pattern); + } + + // Kill pattern + FcPatternDestroy(match); + + return fileName; +} + +bool Font::load(const FontVisualParams *fontParams) +{ + // Build FontConfig request pattern + int id = -1; + std::string filename = Font::buildRequest(fontParams, id); + + // Load font directly using FreeType2 + std::cout << "Font::load(), loading " << filename << " for requested font \"" << Tools::joinList('|', const_cast<FontVisualParams *>(fontParams)->fontList()) << "\"" << std::endl; + + FT_Error error = FT_New_Face(m_context->library(), filename.c_str(), id, &m_fontFace); + if(error) + { + std::cout << "Font::load(), could not load font. Aborting!" << std::endl; + return false; + } + if(!FT_IS_SCALABLE(m_fontFace)) + { + std::cout << "Font::load(), font does not contain outlines. Aborting!" << std::endl; + FT_Done_Face(m_fontFace); + m_fontFace = 0; + return false; + } + + // Choose unicode charmap + for(int charmap = 0; charmap < m_fontFace->num_charmaps; charmap++) + { + if(m_fontFace->charmaps[charmap]->encoding == ft_encoding_unicode) + { + FT_Error error = FT_Set_Charmap(m_fontFace, m_fontFace->charmaps[charmap]); + + if(error) + { + std::cout << "Font::load(), unable to select unicode charmap. Aborting!" << std::endl; + + FT_Done_Face(m_fontFace); + m_fontFace = 0; + + return false; + } + } + } + + m_fontParams = fontParams; + m_fontFile = filename; + m_ready = true; + + return true; +} + +FT_Face &Font::fontFace() +{ + return m_fontFace; +} + +std::string Font::fontFile() const +{ + return m_fontFile; +} + +const FontVisualParams *Font::fontParams() const +{ + return m_fontParams; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/libs/libtext2path/src/Font.h b/ksvg/impl/libs/libtext2path/src/Font.h new file mode 100644 index 00000000..72844285 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/Font.h @@ -0,0 +1,91 @@ +/* + Copyright (C) 2003 Nikolas Zimmermann <wildfox@kde.org> + 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 + aint 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. +*/ + +#ifndef T2P_FONT_H +#define T2P_FONT_H + +#include <list> +#include <string> + +// FreeType 2 includes +#include <ft2build.h> +#include FT_FREETYPE_H + +namespace T2P +{ + class Converter; + + class FontVisualParams + { + public: + FontVisualParams(); + FontVisualParams(const FontVisualParams &other); + ~FontVisualParams(); + + FontVisualParams &operator=(const FontVisualParams &other); + + void setWeight(int weight); + int weight() const; + + void setSlant(int slant); + int slant() const; + + void setSize(double size); + double size() const; + + std::list<std::string> &fontList(); + + private: + int m_weight, m_slant; + double m_size; + + std::list<std::string> m_fontList; + }; + + class Font + { + public: + Font(Converter *context); + ~Font(); + + // Build font loading request for FontConfig + static std::string buildRequest(const FontVisualParams *fontParams, int &id); + + // Load it! :) + bool load(const FontVisualParams *fontParams); + + FT_Face &fontFace(); + std::string fontFile() const; + const FontVisualParams *fontParams() const; + + private: + FT_Face m_fontFace; + std::string m_fontFile; + + Converter *m_context; + const FontVisualParams *m_fontParams; + + bool m_ready; + }; +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/libs/libtext2path/src/Glyph.cpp b/ksvg/impl/libs/libtext2path/src/Glyph.cpp new file mode 100644 index 00000000..5d172018 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/Glyph.cpp @@ -0,0 +1,353 @@ +/* + Copyright (C) 2003 Nikolas Zimmermann <wildfox@kde.org> + 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 + aint 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 <iostream> +#include "Glyph.h" + +using namespace T2P; + +Glyph::Glyph() +{ + m_bezierPath = 0; +} + +Glyph::~Glyph() +{ + delete m_bezierPath; + m_bezierPath = 0; +} + +Affine &Glyph::affine() +{ + return m_affine; +} + +void Glyph::setAffine(const Affine &affine) +{ + m_affine = affine; +} + +const BezierPath *Glyph::bezierPath() const +{ + return const_cast<const BezierPath *>(m_bezierPath); +} + +BezierPath *Glyph::modifiableBezierPath() +{ + return m_bezierPath; +} + +void Glyph::setBezierPath(const BezierPath *bpath) +{ + m_bezierPath = const_cast<BezierPath *>(bpath); +} + +FT_BBox *Glyph::ftBbox() +{ + return m_ftBbox; +} + +// ##### + +GlyphAffinePair::GlyphAffinePair(const Glyph *glyph, const Affine &affine) +{ + m_glyph = glyph; + m_affine = affine; + m_transformatedPath = 0; +} + +GlyphAffinePair::~GlyphAffinePair() +{ + // The glyphs are shared and thus not deleted (Niko) + delete m_transformatedPath; +} + +void GlyphAffinePair::setTransformatedPath(const BezierPath *path) +{ + m_transformatedPath = path; +} + +const BezierPath *GlyphAffinePair::transformatedPath() const +{ + return m_transformatedPath; +} + +const Glyph *GlyphAffinePair::glyph() const +{ + return m_glyph; +} + +Affine &GlyphAffinePair::affine() +{ + return m_affine; +} + +// ##### + +GlyphSet::GlyphSet() +{ + m_glyphCount = 0; + + m_bboxX = 0; + m_bboxY = 0; + m_width = 0; + m_height = 0; + + m_xpen = 0; + m_ypen = 0; + + m_underlinePosition = 0; + m_underlineThickness = 0; + m_overlinePosition = 0; + m_strikeThroughPosition = 0; + m_pixelBaseline = 0; +} + +GlyphSet::~GlyphSet() +{ + m_set.clear(); +} + +std::vector<GlyphAffinePair *> &GlyphSet::set() +{ + return m_set; +} + +std::list<float> GlyphSet::glyphXAdvance() +{ + return m_glyphXAdvance; +} + +std::list<float> GlyphSet::glyphYAdvance() +{ + return m_glyphYAdvance; +} + +unsigned int GlyphSet::glyphCount() const +{ + return m_glyphCount; +} + +int GlyphSet::width() const +{ + return m_width; +} + +int GlyphSet::height() const +{ + return m_height; +} + +int GlyphSet::bboxX() const +{ + return m_bboxX; +} + +int GlyphSet::bboxY() const +{ + return m_bboxY; +} + +double GlyphSet::xpen() const +{ + return m_xpen; +} + +double GlyphSet::ypen() const +{ + return m_ypen; +} + +int GlyphSet::underlinePosition() const +{ + return m_underlinePosition; +} + +int GlyphSet::underlineThickness() const +{ + return m_underlineThickness; +} + +int GlyphSet::overlinePosition() const +{ + return m_overlinePosition; +} + +int GlyphSet::strikeThroughPosition() const +{ + return m_strikeThroughPosition; +} + +int GlyphSet::pixelBaseline() const +{ + return m_pixelBaseline; +} + +// ##### + +GlyphLayoutParams::GlyphLayoutParams() +{ +} + +GlyphLayoutParams::~GlyphLayoutParams() +{ +} + +bool GlyphLayoutParams::tb() const +{ + return m_tb; +} + +void GlyphLayoutParams::setTb(bool tb) +{ + m_tb = tb; +} + +bool GlyphLayoutParams::useBidi() const +{ + return m_useBidi; +} + +void GlyphLayoutParams::setUseBidi(bool bidi) +{ + m_useBidi = bidi; +} + +double GlyphLayoutParams::wordSpacing() const +{ + return m_wordSpacing; +} + +void GlyphLayoutParams::setWordSpacing(double wordSpacing) +{ + m_wordSpacing = wordSpacing; +} + +double GlyphLayoutParams::letterSpacing() const +{ + return m_letterSpacing; +} + +void GlyphLayoutParams::setLetterSpacing(double letterSpacing) +{ + m_letterSpacing = letterSpacing; +} + +std::string GlyphLayoutParams::baselineShift() const +{ + return m_baseline; +} + +void GlyphLayoutParams::setBaselineShift(const std::string &baseline) +{ + m_baseline = baseline; +} + +int GlyphLayoutParams::glyphOrientationVertical() const +{ + return m_glyphOrientationVertical; +} + +void GlyphLayoutParams::setGlyphOrientationVertical(int orient) +{ + m_glyphOrientationVertical = orient; +} + +int GlyphLayoutParams::glyphOrientationHorizontal() const +{ + return m_glyphOrientationHorizontal; +} + +void GlyphLayoutParams::setGlyphOrientationHorizontal(int orient) +{ + m_glyphOrientationHorizontal = orient; +} + +double GlyphLayoutParams::textPathStartOffset() const +{ + return m_textPathStartOffset; +} + +void GlyphLayoutParams::setTextPathStartOffset(double offset) +{ + m_textPathStartOffset = offset; +} + +// ##### + +GlyphRenderParams::GlyphRenderParams() +{ +} + +GlyphRenderParams::~GlyphRenderParams() +{ +} + +Font *GlyphRenderParams::font() const +{ + return m_font; +} + +void GlyphRenderParams::setFont(Font *font) +{ + m_font = font; +} + +const GlyphLayoutParams *GlyphRenderParams::layout() const +{ + return m_layout; +} + +void GlyphRenderParams::setLayout(const GlyphLayoutParams *layout) +{ + m_layout = layout; +} + +unsigned int GlyphRenderParams::glyphIndex() const +{ + return m_glyphIndex; +} + +void GlyphRenderParams::setGlyphIndex(unsigned int glyphIndex) +{ + m_glyphIndex = glyphIndex; +} + +unsigned int GlyphRenderParams::lastGlyph() const +{ + return m_lastGlyph; +} + +void GlyphRenderParams::setLastGlyph(unsigned int lastGlyph) +{ + m_lastGlyph = lastGlyph; +} + +unsigned short GlyphRenderParams::character() const +{ + return m_character; +} + +void GlyphRenderParams::setCharacter(unsigned short character) +{ + m_character = character; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/libs/libtext2path/src/Glyph.h b/ksvg/impl/libs/libtext2path/src/Glyph.h new file mode 100644 index 00000000..b3bd3fb5 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/Glyph.h @@ -0,0 +1,198 @@ +/* + Copyright (C) 2003 Nikolas Zimmermann <wildfox@kde.org> + 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 + aint 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. +*/ + +#ifndef T2P_GLYPH_H +#define T2P_GLYPH_H + +#include <list> +#include <vector> +#include <string> + +#include "Affine.h" +#include "BezierPath.h" + +// FreeType 2 includes +#include <ft2build.h> +#include FT_FREETYPE_H + +namespace T2P +{ + class Font; + + // Represent one single glyph in cache + class Glyph + { + public: + Glyph(); + ~Glyph(); + + Affine &affine(); // Initial tracing affine + void setAffine(const Affine &affine); + + const BezierPath *bezierPath() const; // Non-modifyable bezierPath belonging to this glyph + BezierPath *modifiableBezierPath(); // ONLY USED BY GLYPHTRACER, DO NOT USE SOMEWHERE ELSE! + void setBezierPath(const BezierPath *bpath); + + FT_BBox *ftBbox(); + + private: + Affine m_affine; + FT_BBox m_ftBbox[4]; + BezierPath *m_bezierPath; + }; + + // Is created for every character which needs to + // be rendered and has to be deleted by the "client" + class GlyphAffinePair + { + public: + GlyphAffinePair(const Glyph *glyph, const Affine &affine); + ~GlyphAffinePair(); + + void setTransformatedPath(const BezierPath *path); + const BezierPath *transformatedPath() const; + + const Glyph *glyph() const; + Affine &affine(); + + private: + const Glyph *m_glyph; + const BezierPath *m_transformatedPath; + Affine m_affine; + }; + + class GlyphSet + { + public: + GlyphSet(); + ~GlyphSet(); + + std::vector<GlyphAffinePair *> &set(); + std::list<float> glyphXAdvance(); + std::list<float> glyphYAdvance(); + + unsigned int glyphCount() const; + + int width() const; + int height() const; + + int bboxX() const; + int bboxY() const; + + double xpen() const; + double ypen() const; + + int underlinePosition() const; + int underlineThickness() const; + int overlinePosition() const; + int strikeThroughPosition() const; + int pixelBaseline() const; + + private: + friend class Converter; + unsigned int m_glyphCount; // Number of glyphs in the set + + int m_bboxX, m_bboxY; // Bounding box locations (x,y) + (x + width, y + width) + int m_width, m_height; + + double m_xpen, m_ypen; // relative pen locations + + int m_underlinePosition, m_underlineThickness, m_overlinePosition, m_strikeThroughPosition, m_pixelBaseline; + + std::vector<GlyphAffinePair *> m_set; // Bezier paths in the set + + std::list<float> m_glyphXAdvance; // List of advance values needed ie. for text paths + std::list<float> m_glyphYAdvance; + }; + + class GlyphLayoutParams + { + public: + GlyphLayoutParams(); + ~GlyphLayoutParams(); + + bool tb() const; + void setTb(bool tb); + + bool useBidi() const; + void setUseBidi(bool bidi); + + double wordSpacing() const; + void setWordSpacing(double wordSpacing); + + double letterSpacing() const; + void setLetterSpacing(double letterSpacing); + + std::string baselineShift() const; + void setBaselineShift(const std::string &baseline); + + int glyphOrientationVertical() const; + void setGlyphOrientationVertical(int orient); + + int glyphOrientationHorizontal() const; + void setGlyphOrientationHorizontal(int orient); + + // textOnPath specific stuff + double textPathStartOffset() const; + void setTextPathStartOffset(double offset); + + private: + bool m_tb; // Top-To-Bottom or Bottom-To-Top ? + bool m_useBidi; // Use Bidi ? + double m_wordSpacing, m_letterSpacing; // word/character spacing + double m_textPathStartOffset; // range: 0.0 - 1.0; start offset in the path + int m_glyphOrientationVertical, m_glyphOrientationHorizontal; // Degrees... + std::string m_baseline; // baseline description, using same system as svg + }; + + class GlyphRenderParams + { + public: + GlyphRenderParams(); + ~GlyphRenderParams(); + + Font *font() const; + void setFont(Font *font); + + const GlyphLayoutParams *layout() const; + void setLayout(const GlyphLayoutParams *layout); + + unsigned int glyphIndex() const; + void setGlyphIndex(unsigned int glyphIndex); + + unsigned int lastGlyph() const; + void setLastGlyph(unsigned int lastGlyph); + + unsigned short character() const; + void setCharacter(unsigned short character); + + private: + Font *m_font; + const GlyphLayoutParams *m_layout; // Glyph layouting params + + unsigned int m_glyphIndex; // 'character' index in font + unsigned int m_lastGlyph; // Kerning + unsigned short m_character; // Unicode glyph to process + }; +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/libs/libtext2path/src/GlyphTracer.cpp b/ksvg/impl/libs/libtext2path/src/GlyphTracer.cpp new file mode 100644 index 00000000..42457553 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/GlyphTracer.cpp @@ -0,0 +1,76 @@ +/* + Copyright (C) 2003 Nikolas Zimmermann <wildfox@kde.org> + 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 + aint 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 "GlyphTracer.h" + +using namespace T2P; + +GlyphTracer::GlyphTracer() +{ + m_moveTo = 0; + m_lineTo = 0; + m_conicBezier = 0; + m_cubicBezier = 0; + m_outlineMethods = 0; +} + +GlyphTracer::~GlyphTracer() +{ + delete m_outlineMethods; +} + +void GlyphTracer::setMoveto(FT_Outline_MoveToFunc funcPtr) +{ + m_moveTo = funcPtr; +} + +void GlyphTracer::setLineto(FT_Outline_LineToFunc funcPtr) +{ + m_lineTo = funcPtr; +} + +void GlyphTracer::setConicBezier(FT_Outline_ConicToFunc funcPtr) +{ + m_conicBezier = funcPtr; +} + +void GlyphTracer::setCubicBezier(FT_Outline_CubicToFunc funcPtr) +{ + m_cubicBezier = funcPtr; +} + +FT_Outline_Funcs *GlyphTracer::outlineFuncs() +{ + if(m_outlineMethods) + return m_outlineMethods; + + FT_Outline_Funcs *ret = new FT_Outline_Funcs(); + ret->move_to = m_moveTo; + ret->line_to = m_lineTo; + ret->conic_to = m_conicBezier; + ret->cubic_to = m_cubicBezier; + ret->shift = 0; + ret->delta = 0; + + m_outlineMethods = ret; + return m_outlineMethods; +} + +// vim:ts=4:noet diff --git a/ksvg/impl/libs/libtext2path/src/GlyphTracer.h b/ksvg/impl/libs/libtext2path/src/GlyphTracer.h new file mode 100644 index 00000000..7607ecad --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/GlyphTracer.h @@ -0,0 +1,65 @@ +/* + Copyright (C) 2003 Nikolas Zimmermann <wildfox@kde.org> + 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 + aint 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. +*/ + +#ifndef T2P_GLYPHTRACER_H +#define T2P_GLYPHTRACER_H + +// FreeType 2 includes +#include <ft2build.h> +#include FT_FREETYPE_H + +namespace T2P +{ + class Glyph; + class BezierPath; + class GlyphAffinePair; + + class GlyphTracer + { + public: + GlyphTracer(); + virtual ~GlyphTracer(); + + // Needs to be implemented + virtual void correctGlyph(GlyphAffinePair *glyphAffine) = 0; + virtual BezierPath *allocBezierPath(int size) = 0; + virtual void closePath(Glyph *glyph) = 0; + + // FreeType glyph tracing functions + void setMoveto(FT_Outline_MoveToFunc funcPtr); + void setLineto(FT_Outline_LineToFunc funcPtr); + void setConicBezier(FT_Outline_ConicToFunc funcPtr); + void setCubicBezier(FT_Outline_CubicToFunc funcPtr); + + FT_Outline_Funcs *outlineFuncs(); + + private: + FT_Outline_Funcs *m_outlineMethods; + + FT_Outline_MoveToFunc m_moveTo; + FT_Outline_LineToFunc m_lineTo; + FT_Outline_ConicToFunc m_conicBezier; + FT_Outline_CubicToFunc m_cubicBezier; + }; +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/libs/libtext2path/src/Makefile.am b/ksvg/impl/libs/libtext2path/src/Makefile.am new file mode 100644 index 00000000..175e1a91 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/Makefile.am @@ -0,0 +1,10 @@ +lib_LTLIBRARIES = libtext2path.la + +KDE_CXXFLAGS = $(USE_EXCEPTIONS) +INCLUDES = $(FRIBIDI_CFLAGS) $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) $(all_includes) + +libtext2path_includedir=$(includedir)/libtext2path-0.1 +libtext2path_include_HEADERS = BezierPath.h Glyph.h GlyphTracer.h + +libtext2path_la_SOURCES = Affine.cpp Rectangle.cpp Font.cpp Glyph.cpp GlyphTracer.cpp Converter.cpp QtUnicode.cpp +libtext2path_la_LDFLAGS = $(FRIBIDI_LIBS) $(FONTCONFIG_LIBS) diff --git a/ksvg/impl/libs/libtext2path/src/Point.h b/ksvg/impl/libs/libtext2path/src/Point.h new file mode 100644 index 00000000..d95742a2 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/Point.h @@ -0,0 +1,65 @@ +/* + Copyright (C) 2003 Nikolas Zimmermann <wildfox@kde.org> + 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 + aint 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. +*/ + +#ifndef T2P_POINT_H +#define T2P_POINT_H + +namespace T2P +{ + class Point + { + public: + Point() { m_x = 0.0; m_y = 0.0; } + Point(double x, double y) { m_x = x; m_y = y; } + Point &operator=(const Point &other) { m_x = other.x(); m_y = other.y(); return *this; } + + friend inline Point operator+(const Point &, const Point &); + friend inline Point operator-(const Point &, const Point &); + friend inline Point operator*(const double &, const Point &); + friend inline Point operator*(const Point &, const double &); + + double x() const { return m_x; } + double y() const { return m_y; } + + void setX(double x) { m_x = x; } + void setY(double y) { m_y = y; } + + const Point invert() const + { + Point temp; + temp.setX(-x()); + temp.setY(-y()); + return temp; + } + + private: + double m_x; + double m_y; + }; + + inline Point operator+(const Point &p1, const Point &p2) { return Point(p1.m_x + p2.m_x, p1.m_y + p2.m_y); } + inline Point operator-(const Point &p1, const Point &p2) { return Point(p1.m_x - p2.m_x, p1.m_y - p2.m_y); } + inline Point operator*(const double &c, const Point &p) { return Point(p.m_x * c, p.m_y * c); } + inline Point operator*(const Point &p, const double &c) { return Point(p.m_x * c, p.m_y * c); } +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/libs/libtext2path/src/QtUnicode.cpp b/ksvg/impl/libs/libtext2path/src/QtUnicode.cpp new file mode 100644 index 00000000..694ed5c7 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/QtUnicode.cpp @@ -0,0 +1,164 @@ +/**************************************************************************** +** +** +** ??? +** +** Copyright (C) 2002-2003 Trolltech AS. All rights reserved. +** +** This file is part of the kernel module of the Qt GUI Toolkit. +** +** This file may be distributed under the terms of the Q Public License +** as defined by Trolltech AS of Norway and appearing in the file +** LICENSE.QPL included in the packaging of this file. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition +** licenses may use this file in accordance with the Qt Commercial License +** Agreement provided with the Software. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for +** information about Qt Commercial License Agreements. +** See http://www.trolltech.com/qpl/ for QPL licensing information. +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#include "QtUnicode.h" + +using namespace T2P; +// START OF GENERATED DATA + +// copied form qfont.h, as we can't include it in tools. Do not modify without +// changing the script enum in qfont.h aswell. +const unsigned char QtUnicode::otherScripts [120] = { +#define SCRIPTS_02 0 + 0xaf, Latin, 0xff, SpacingModifiers, // row 0x02, index 0 +#define SCRIPTS_03 4 + 0x6f, CombiningMarks, 0xff, Greek, // row 0x03, index 4 +#define SCRIPTS_05 8 + 0x2f, Cyrillic, 0x8f, Armenian, 0xff, Hebrew, // row 0x05, index 8 +#define SCRIPTS_07 14 + 0x4f, Syriac, 0x7f, Unicode, 0xbf, Thaana, + 0xff, Unicode, // row 0x07, index 14 +#define SCRIPTS_10 22 + 0x9f, Myanmar, 0xff, Georgian, // row 0x10, index 20 +#define SCRIPTS_13 26 + 0x7f, Ethiopic, 0x9f, Unicode, 0xff, Cherokee, // row 0x13, index 24 +#define SCRIPTS_16 32 + 0x7f, CanadianAboriginal, 0x9f, Ogham, + 0xff, Runic, // row 0x16 index 30 +#define SCRIPTS_17 38 + 0x1f, Tagalog, 0x3f, Hanunoo, 0x5f, Buhid, + 0x7f, Tagbanwa, 0xff, Khmer, // row 0x17, index 36 +#define SCRIPTS_18 48 + 0xaf, Mongolian, 0xff, Unicode, // row 0x18, index 46 +#define SCRIPTS_20 52 + 0x0b, Unicode, 0x0d, UnknownScript, 0x6f, Unicode, 0x9f, NumberForms, + 0xab, CurrencySymbols, 0xac, Latin, + 0xcf, CurrencySymbols, 0xff, CombiningMarks, // row 0x20, index 50 +#define SCRIPTS_21 68 + 0x4f, LetterlikeSymbols, 0x8f, NumberForms, + 0xff, MathematicalOperators, // row 0x21, index 62 +#define SCRIPTS_24 74 + 0x5f, TechnicalSymbols, 0xff, EnclosedAndSquare, // row 0x24, index 68 +#define SCRIPTS_2e 78 + 0x7f, Unicode, 0xff, Han, // row 0x2e, index 72 +#define SCRIPTS_30 82 + 0x3f, Han, 0x9f, Hiragana, 0xff, Katakana, // row 0x30, index 76 +#define SCRIPTS_31 88 + 0x2f, Bopomofo, 0x8f, Hangul, 0x9f, Han, + 0xff, Unicode, // row 0x31, index 82 +#define SCRIPTS_fb 96 + 0x06, Latin, 0x1c, Unicode, 0x4f, Hebrew, + 0xff, Arabic, // row 0xfb, index 90 +#define SCRIPTS_fe 104 + 0x1f, Unicode, 0x2f, CombiningMarks, 0x6f, Unicode, + 0xff, Arabic, // row 0xfe, index 98 +#define SCRIPTS_ff 112 + 0x5e, Katakana, 0x60, Unicode, // row 0xff, index 106 + 0x9f, KatakanaHalfWidth, 0xff, Unicode +}; + +// (uc-0x0900)>>7 +const unsigned char QtUnicode::indicScripts [] = +{ + Devanagari, Bengali, + Gurmukhi, Gujarati, + Oriya, Tamil, + Telugu, Kannada, + Malayalam, Sinhala, + Thai, Lao +}; + + +// 0x80 + x: x is the offset into the otherScripts table +const unsigned char QtUnicode::scriptTable[256] = +{ + Latin, Latin, 0x80+SCRIPTS_02, 0x80+SCRIPTS_03, + Cyrillic, 0x80+SCRIPTS_05, Arabic, 0x80+SCRIPTS_07, + Unicode, SCRIPTS_INDIC, SCRIPTS_INDIC, SCRIPTS_INDIC, + SCRIPTS_INDIC, SCRIPTS_INDIC, SCRIPTS_INDIC, Tibetan, + + 0x80+SCRIPTS_10, Hangul, Ethiopic, 0x80+SCRIPTS_13, + CanadianAboriginal, CanadianAboriginal, 0x80+SCRIPTS_16, 0x80+SCRIPTS_17, + 0x80+SCRIPTS_18, Unicode, Unicode, Unicode, + Unicode, Unicode, Latin, Greek, + + 0x80+SCRIPTS_20, 0x80+SCRIPTS_21, MathematicalOperators, TechnicalSymbols, + 0x80+SCRIPTS_24, GeometricSymbols, MiscellaneousSymbols, MiscellaneousSymbols, + Braille, Unicode, Unicode, Unicode, + Unicode, Unicode, 0x80+SCRIPTS_2e, Han, + + 0x80+SCRIPTS_30, 0x80+SCRIPTS_31, EnclosedAndSquare, EnclosedAndSquare, + Han, Han, Han, Han, + Han, Han, Han, Han, + Han, Han, Han, Han, + + Han, Han, Han, Han, Han, Han, Han, Han, + Han, Han, Han, Han, Han, Han, Han, Han, + + Han, Han, Han, Han, Han, Han, Han, Han, + Han, Han, Han, Han, Han, Han, Han, Han, + + Han, Han, Han, Han, Han, Han, Han, Han, + Han, Han, Han, Han, Han, Han, Han, Han, + + Han, Han, Han, Han, Han, Han, Han, Han, + Han, Han, Han, Han, Han, Han, Han, Han, + + + Han, Han, Han, Han, Han, Han, Han, Han, + Han, Han, Han, Han, Han, Han, Han, Han, + + Han, Han, Han, Han, Han, Han, Han, Han, + Han, Han, Han, Han, Han, Han, Han, Han, + + Yi, Yi, Yi, Yi, Yi, Unicode, Unicode, Unicode, + Unicode, Unicode, Unicode, Unicode, Hangul, Hangul, Hangul, Hangul, + + Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, + Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, + + Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, + Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, + + Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, + Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, + + Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, + Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, + + Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, + Unicode, Han, Han, 0x80+SCRIPTS_fb, Arabic, Arabic, 0x80+SCRIPTS_fe, 0x80+SCRIPTS_ff +}; + diff --git a/ksvg/impl/libs/libtext2path/src/QtUnicode.h b/ksvg/impl/libs/libtext2path/src/QtUnicode.h new file mode 100644 index 00000000..41008500 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/QtUnicode.h @@ -0,0 +1,149 @@ +/* + Copyright (C) 2003 Nikolas Zimmermann <wildfox@kde.org> + 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 + aint 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. +*/ + +#ifndef T2P_QT_UNICODE_H +#define T2P_QT_UNICODE_H + +namespace T2P +{ + enum Script + { + // European Alphabetic Scripts + Latin, + Greek, + Cyrillic, + Armenian, + Georgian, + Runic, + Ogham, + SpacingModifiers, + CombiningMarks, + + // Middle Eastern Scripts + Hebrew, + Arabic, + Syriac, + Thaana, + + // South and Southeast Asian Scripts + Devanagari, + Bengali, + Gurmukhi, + Gujarati, + Oriya, + Tamil, + Telugu, + Kannada, + Malayalam, + Sinhala, + Thai, + Lao, + Tibetan, + Myanmar, + Khmer, + + // East Asian Scripts + Han, + Hiragana, + Katakana, + Hangul, + Bopomofo, + Yi, + + // Additional Scripts + Ethiopic, + Cherokee, + CanadianAboriginal, + Mongolian, + + // Symbols + CurrencySymbols, + LetterlikeSymbols, + NumberForms, + MathematicalOperators, + TechnicalSymbols, + GeometricSymbols, + MiscellaneousSymbols, + EnclosedAndSquare, + Braille, + + Unicode, + + // some scripts added in Unicode 3.2 + Tagalog, + Hanunoo, + Buhid, + Tagbanwa, + + KatakanaHalfWidth, + + // End + NScripts, + UnknownScript = NScripts + }; + + class QtUnicode + { + public: + QtUnicode() { } + ~QtUnicode() { } + + static int scriptForChar(unsigned short uc) + { + unsigned char script = QtUnicode::scriptTable[(uc >> 8)]; + if(script >= QtUnicode::SCRIPTS_INDIC) + { + if(script == QtUnicode::SCRIPTS_INDIC) + script = QtUnicode::indicScripts[(uc - 0x0900) >> 7]; + else + { + // 0x80 + SCRIPTS_xx + unsigned char index = script - 0x80; + unsigned char cell = uc & 0xff; + while(QtUnicode::otherScripts[index++] < cell) + index++; + script = QtUnicode::otherScripts[index]; + } + } + + return script; + } + + private: + enum + { + SCRIPTS_INDIC = 0x7e + }; + + static const unsigned char otherScripts[]; + static const unsigned char indicScripts[]; + static const unsigned char scriptTable[]; + }; +} + +#define SCRIPT_FOR_CHAR(script, c) \ +if(c < 0x100) \ + script = T2P::Latin; \ +else \ + script = (T2P::Script) QtUnicode::scriptForChar(c); + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/libs/libtext2path/src/Rectangle.cpp b/ksvg/impl/libs/libtext2path/src/Rectangle.cpp new file mode 100644 index 00000000..ef59d6be --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/Rectangle.cpp @@ -0,0 +1,102 @@ +/* + Copyright (C) 2003 Nikolas Zimmermann <wildfox@kde.org> + 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 + aint 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 "Tools.h" +#include "Rectangle.h" + +using namespace T2P; + +Rectangle::Rectangle() +{ +} + +Rectangle::Rectangle(const Rectangle &other) +{ + (*this) = other; +} + +Rectangle::Rectangle(const Point &a, const Point &b) : m_a(a), m_b(b) +{ +} + +Rectangle::Rectangle(double x, double y, double width, double height) +{ + m_a = Point(x, y); + m_b = Point(x + width, y + height); +} + +Rectangle::~Rectangle() +{ +} + +Rectangle &Rectangle::operator=(const Rectangle &other) +{ + m_a = other.m_a; + m_b = other.m_b; + + return *this; +} + +Point Rectangle::a() const +{ + return m_a; +} + +void Rectangle::setA(const Point &a) +{ + m_a = a; +} + +Point Rectangle::b() const +{ + return m_b; +} + +void Rectangle::setB(const Point &b) +{ + m_b = b; +} + +void Rectangle::bboxUnion(const Rectangle &src1, const Rectangle &src2) +{ + double src1x0 = src1.a().x(), src1x1 = src1.b().x(); + double src1y0 = src1.a().y(), src1y1 = src1.b().y(); + + double src2x0 = src2.a().x(), src2x1 = src2.b().x(); + double src2y0 = src2.a().y(), src2y1 = src2.b().y(); + + if(src1x1 <= src1x0 || src1y1 <= src1y0) // Is src1 empty? + { // Copy src2 to dst + setA(Point(src2x0, src2y0)); + setB(Point(src2x1, src2y1)); + } + else if(src2x1 <= src2x0 || src2y1 <= src2y0) // Is src2 empty? + { // Copy src1 to dest + setA(Point(src1x0, src1y0)); + setB(Point(src1x1, src1y1)); + } + else + { + setA(Point(T2PMIN(src1x0, src2x0), T2PMIN(src1y0, src2y0))); + setB(Point(T2PMAX(src1x1, src2x1), T2PMAX(src1y1, src2y1))); + } +} + +// vim:ts=4:noet diff --git a/ksvg/impl/libs/libtext2path/src/Rectangle.h b/ksvg/impl/libs/libtext2path/src/Rectangle.h new file mode 100644 index 00000000..1a5eeeb1 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/Rectangle.h @@ -0,0 +1,55 @@ +/* + Copyright (C) 2003 Nikolas Zimmermann <wildfox@kde.org> + 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 + aint 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. +*/ + +#ifndef T2P_RECTANGLE_H +#define T2P_RECTANGLE_H + +#include "Point.h" + +namespace T2P +{ + class Rectangle + { + public: + Rectangle(); + Rectangle(const Rectangle &other); + Rectangle(const Point &a, const Point &b); + Rectangle(double x, double y, double width, double height); + ~Rectangle(); + + Rectangle &operator=(const Rectangle &other); + + Point a() const; + void setA(const Point &a); + + Point b() const; + void setB(const Point &b); + + // Finds the smallest rectangle that includes src1 and src2. + void bboxUnion(const Rectangle &src1, const Rectangle &src2); + + private: + Point m_a, m_b; + }; +} + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/libs/libtext2path/src/Tools.h b/ksvg/impl/libs/libtext2path/src/Tools.h new file mode 100644 index 00000000..c7753365 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/Tools.h @@ -0,0 +1,85 @@ +/* + Copyright (C) 2003 Nikolas Zimmermann <wildfox@kde.org> + 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 + aint 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. +*/ + +#ifndef T2P_TOOLS_H +#define T2P_TOOLS_H + +#include <list> +#include <string> +#include <config.h> +#ifdef HAVE_SSTREAM +# include <sstream> +#else +# include <strstream> +# define ostringstream ostrstream +#endif + +#define T2PMAX(a, b) ((b) < (a) ? (a) : (b)) +#define T2PMIN(a, b) ((a) < (b) ? (a) : (b)) + +namespace T2P +{ + class Tools + { + public: + static std::string joinList(char seperator, std::list<std::string> &list) + { + std::string result; + + if(list.empty()) + return result; + + bool first = true; + for(std::list<std::string>::const_iterator it = list.begin(); it != list.end(); ++it) + { + std::string string = *it; + + if(!string.empty()) + { + if(!first) + result += seperator + string; + else + { + result += string; + first = false; + } + } + } + + return result; + } + + template<typename T> + static std::string a2str(T arg) + { + std::ostringstream buffer; + buffer << arg; + return buffer.str(); + } + }; +} + +#ifdef ostringstream +# undef ostringstream +#endif + +#endif + +// vim:ts=4:noet diff --git a/ksvg/impl/libs/libtext2path/src/myboost/assert.hpp b/ksvg/impl/libs/libtext2path/src/myboost/assert.hpp new file mode 100644 index 00000000..3f3c61c2 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/myboost/assert.hpp @@ -0,0 +1,24 @@ +// +// boost/assert.hpp - BOOST_ASSERT(expr) +// +// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +// Note: There are no include guards. This is intentional. +// +// See http://www.boost.org/libs/utility/assert.html for documentation. +// + +#ifndef ASSERT_HPP +#define ASSERT_HPP + +#undef BOOST_ASSERT + +# include <assert.h> +# define BOOST_ASSERT(expr) assert(expr) + +#endif diff --git a/ksvg/impl/libs/libtext2path/src/myboost/checked_delete.hpp b/ksvg/impl/libs/libtext2path/src/myboost/checked_delete.hpp new file mode 100644 index 00000000..73afd5f5 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/myboost/checked_delete.hpp @@ -0,0 +1,61 @@ +#ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED +#define BOOST_CHECKED_DELETE_HPP_INCLUDED + +// +// boost/checked_delete.hpp +// +// Copyright (c) 1999, 2000, 2001, 2002 boost.org +// Copyright (c) 2002, 2003 Peter Dimov +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +// See http://www.boost.org/libs/utility/checked_delete.html for documentation. +// + +namespace myboost +{ + +// verify that types are complete for increased safety + +template<class T> inline void checked_delete(T * x) +{ + // Intel 7 accepts sizeof(incomplete) as 0 in system headers + typedef char type_must_be_complete[ sizeof(T)? 1: -1 ]; + delete x; +} + +template<class T> inline void checked_array_delete(T * x) +{ + typedef char type_must_be_complete[ sizeof(T)? 1: -1 ]; + delete [] x; +} + +template<class T> struct checked_deleter +{ + typedef void result_type; + typedef T * argument_type; + + void operator()(T * x) const + { + // boost:: disables ADL + myboost::checked_delete(x); + } +}; + +template<class T> struct checked_array_deleter +{ + typedef void result_type; + typedef T * argument_type; + + void operator()(T * x) const + { + myboost::checked_array_delete(x); + } +}; + +} // namespace myboost + +#endif // #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED diff --git a/ksvg/impl/libs/libtext2path/src/myboost/lightweight_mutex.hpp b/ksvg/impl/libs/libtext2path/src/myboost/lightweight_mutex.hpp new file mode 100644 index 00000000..10db127c --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/myboost/lightweight_mutex.hpp @@ -0,0 +1,74 @@ +#ifndef BOOST_DETAIL_LWM_PTHREADS_HPP_INCLUDED +#define BOOST_DETAIL_LWM_PTHREADS_HPP_INCLUDED + +// +// boost/detail/lwm_pthreads.hpp +// +// Copyright (c) 2002 Peter Dimov and Multi Media Ltd. +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// + +#include <pthread.h> + +namespace myboost +{ + +namespace detail +{ + +class lightweight_mutex +{ +private: + + pthread_mutex_t m_; + + lightweight_mutex(lightweight_mutex const &); + lightweight_mutex & operator=(lightweight_mutex const &); + +public: + + lightweight_mutex() + { + pthread_mutex_init(&m_, 0); + } + + ~lightweight_mutex() + { + pthread_mutex_destroy(&m_); + } + + class scoped_lock; + friend class scoped_lock; + + class scoped_lock + { + private: + + pthread_mutex_t & m_; + + scoped_lock(scoped_lock const &); + scoped_lock & operator=(scoped_lock const &); + + public: + + scoped_lock(lightweight_mutex & m): m_(m.m_) + { + pthread_mutex_lock(&m_); + } + + ~scoped_lock() + { + pthread_mutex_unlock(&m_); + } + }; +}; + +} // namespace detail + +} // namespace myboost + +#endif // #ifndef BOOST_DETAIL_LWM_PTHREADS_HPP_INCLUDED diff --git a/ksvg/impl/libs/libtext2path/src/myboost/shared_count.hpp b/ksvg/impl/libs/libtext2path/src/myboost/shared_count.hpp new file mode 100644 index 00000000..e8ec19a8 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/myboost/shared_count.hpp @@ -0,0 +1,367 @@ +#ifndef BOOST_DETAIL_SHARED_COUNT_HPP_INCLUDED +#define BOOST_DETAIL_SHARED_COUNT_HPP_INCLUDED + +// +// detail/shared_count.hpp +// +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// + +#include "myboost/checked_delete.hpp" +#include "myboost/throw_exception.hpp" +#include "myboost/lightweight_mutex.hpp" + +#include <memory> // std::auto_ptr, std::allocator +#include <functional> // std::less +#include <exception> // std::exception +#include <new> // std::bad_alloc +#include <typeinfo> // std::type_info in get_deleter +#include <cstddef> // std::size_t + +namespace myboost +{ + +class bad_weak_ptr: public std::exception +{ +public: + + virtual char const * what() const throw() + { + return "myboost::bad_weak_ptr"; + } +}; + +namespace detail +{ + +class sp_counted_base +{ +private: + + typedef detail::lightweight_mutex mutex_type; + +public: + + sp_counted_base(): use_count_(1), weak_count_(1) + { + } + + virtual ~sp_counted_base() // nothrow + { + } + + // dispose() is called when use_count_ drops to zero, to release + // the resources managed by *this. + + virtual void dispose() = 0; // nothrow + + // destruct() is called when weak_count_ drops to zero. + + virtual void destruct() // nothrow + { + delete this; + } + + virtual void * get_deleter(std::type_info const & ti) = 0; + + void add_ref_copy() + { + mutex_type::scoped_lock lock(mtx_); + ++use_count_; + } + + void add_ref_lock() + { + mutex_type::scoped_lock lock(mtx_); + if(use_count_ == 0) myboost::throw_exception(myboost::bad_weak_ptr()); + ++use_count_; + } + + void release() // nothrow + { + { + mutex_type::scoped_lock lock(mtx_); + long new_use_count = --use_count_; + + if(new_use_count != 0) return; + } + + dispose(); + weak_release(); + } + + void weak_add_ref() // nothrow + { + mutex_type::scoped_lock lock(mtx_); + ++weak_count_; + } + + void weak_release() // nothrow + { + long new_weak_count; + + { + mutex_type::scoped_lock lock(mtx_); + new_weak_count = --weak_count_; + } + + if(new_weak_count == 0) + { + destruct(); + } + } + + long use_count() const // nothrow + { + mutex_type::scoped_lock lock(mtx_); + return use_count_; + } + +private: + + sp_counted_base(sp_counted_base const &); + sp_counted_base & operator= (sp_counted_base const &); + + long use_count_; // #shared + long weak_count_; // #weak + (#shared != 0) + + mutable mutex_type mtx_; +}; + +template<class P, class D> class sp_counted_base_impl: public sp_counted_base +{ +private: + + P ptr; // copy constructor must not throw + D del; // copy constructor must not throw + + sp_counted_base_impl(sp_counted_base_impl const &); + sp_counted_base_impl & operator= (sp_counted_base_impl const &); + + typedef sp_counted_base_impl<P, D> this_type; + +public: + + // pre: initial_use_count <= initial_weak_count, d(p) must not throw + + sp_counted_base_impl(P p, D d): ptr(p), del(d) + { + } + + virtual void dispose() // nothrow + { + del(ptr); + } + + virtual void * get_deleter(std::type_info const & ti) + { + return ti == typeid(D)? &del: 0; + } + + void * operator new(std::size_t) + { + return std::allocator<this_type>().allocate(1, static_cast<this_type *>(0)); + } + + void operator delete(void * p) + { + std::allocator<this_type>().deallocate(static_cast<this_type *>(p), 1); + } +}; + +class weak_count; + +class shared_count +{ +private: + + sp_counted_base * pi_; + + friend class weak_count; + +public: + + shared_count(): pi_(0) // nothrow + { + } + + template<class P, class D> shared_count(P p, D d): pi_(0) + { + + try + { + pi_ = new sp_counted_base_impl<P, D>(p, d); + } + catch(...) + { + d(p); // delete p + throw; + } + + + pi_ = new sp_counted_base_impl<P, D>(p, d); + + if(pi_ == 0) + { + d(p); // delete p + myboost::throw_exception(std::bad_alloc()); + } + } + + // auto_ptr<Y> is special cased to provide the strong guarantee + + template<class Y> + explicit shared_count(std::auto_ptr<Y> & r): pi_(new sp_counted_base_impl< Y *, checked_deleter<Y> >(r.get(), checked_deleter<Y>())) + { + r.release(); + } + + ~shared_count() // nothrow + { + if(pi_ != 0) pi_->release(); + } + + shared_count(shared_count const & r): pi_(r.pi_) // nothrow + { + if(pi_ != 0) pi_->add_ref_copy(); + } + + explicit shared_count(weak_count const & r); // throws bad_weak_ptr when r.use_count() == 0 + + shared_count & operator= (shared_count const & r) // nothrow + { + sp_counted_base * tmp = r.pi_; + if(tmp != 0) tmp->add_ref_copy(); + if(pi_ != 0) pi_->release(); + pi_ = tmp; + + return *this; + } + + void swap(shared_count & r) // nothrow + { + sp_counted_base * tmp = r.pi_; + r.pi_ = pi_; + pi_ = tmp; + } + + long use_count() const // nothrow + { + return pi_ != 0? pi_->use_count(): 0; + } + + bool unique() const // nothrow + { + return use_count() == 1; + } + + friend inline bool operator==(shared_count const & a, shared_count const & b) + { + return a.pi_ == b.pi_; + } + + friend inline bool operator<(shared_count const & a, shared_count const & b) + { + return std::less<sp_counted_base *>()(a.pi_, b.pi_); + } + + void * get_deleter(std::type_info const & ti) const + { + return pi_? pi_->get_deleter(ti): 0; + } +}; + +class weak_count +{ +private: + + sp_counted_base * pi_; + + friend class shared_count; + +public: + + weak_count(): pi_(0) // nothrow + { + } + + weak_count(shared_count const & r): pi_(r.pi_) // nothrow + { + if(pi_ != 0) pi_->weak_add_ref(); + } + + weak_count(weak_count const & r): pi_(r.pi_) // nothrow + { + if(pi_ != 0) pi_->weak_add_ref(); + } + + ~weak_count() // nothrow + { + if(pi_ != 0) pi_->weak_release(); + } + + weak_count & operator= (shared_count const & r) // nothrow + { + sp_counted_base * tmp = r.pi_; + if(tmp != 0) tmp->weak_add_ref(); + if(pi_ != 0) pi_->weak_release(); + pi_ = tmp; + + return *this; + } + + weak_count & operator= (weak_count const & r) // nothrow + { + sp_counted_base * tmp = r.pi_; + if(tmp != 0) tmp->weak_add_ref(); + if(pi_ != 0) pi_->weak_release(); + pi_ = tmp; + + return *this; + } + + void swap(weak_count & r) // nothrow + { + sp_counted_base * tmp = r.pi_; + r.pi_ = pi_; + pi_ = tmp; + } + + long use_count() const // nothrow + { + return pi_ != 0? pi_->use_count(): 0; + } + + friend inline bool operator==(weak_count const & a, weak_count const & b) + { + return a.pi_ == b.pi_; + } + + friend inline bool operator<(weak_count const & a, weak_count const & b) + { + return std::less<sp_counted_base *>()(a.pi_, b.pi_); + } +}; + +inline shared_count::shared_count(weak_count const & r): pi_(r.pi_) +{ + if(pi_ != 0) + { + pi_->add_ref_lock(); + } + else + { + myboost::throw_exception(myboost::bad_weak_ptr()); + } +} + +} // namespace detail + +} // namespace myboost + +#endif // #ifndef BOOST_DETAIL_SHARED_COUNT_HPP_INCLUDED diff --git a/ksvg/impl/libs/libtext2path/src/myboost/shared_ptr.hpp b/ksvg/impl/libs/libtext2path/src/myboost/shared_ptr.hpp new file mode 100644 index 00000000..3f2fe30d --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/myboost/shared_ptr.hpp @@ -0,0 +1,395 @@ +#ifndef BOOST_SHARED_PTR_HPP_INCLUDED +#define BOOST_SHARED_PTR_HPP_INCLUDED + +// shared_ptr.hpp +// +// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. +// Copyright (c) 2001, 2002, 2003 Peter Dimov +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +// See http://www.boost.org/libs/smart_ptr/shared_ptr.htm for documentation. +// + +#include "myboost/assert.hpp" +#include "myboost/checked_delete.hpp" +#include "myboost/throw_exception.hpp" +#include "myboost/shared_count.hpp" + +#include <memory> // for std::auto_ptr +#include <algorithm> // for std::swap +#include <functional> // for std::less +#include <typeinfo> // for std::bad_cast +#include <iosfwd> // for std::basic_ostream + +namespace myboost +{ + +template<class T> class weak_ptr; +template<class T> class enable_shared_from_this; + +namespace detail +{ + +struct static_cast_tag {}; +struct const_cast_tag {}; +struct dynamic_cast_tag {}; +struct polymorphic_cast_tag {}; + +template<class T> struct shared_ptr_traits +{ + typedef T & reference; +}; + +template<> struct shared_ptr_traits<void> +{ + typedef void reference; +}; + +template<> struct shared_ptr_traits<void const> +{ + typedef void reference; +}; + +template<> struct shared_ptr_traits<void volatile> +{ + typedef void reference; +}; + +template<> struct shared_ptr_traits<void const volatile> +{ + typedef void reference; +}; + +// enable_shared_from_this support + +template<class T, class Y> void sp_enable_shared_from_this(myboost::enable_shared_from_this<T> * pe, Y * px, shared_count const & pn) +{ + if(pe != 0) pe->_internal_weak_this._internal_assign(px, pn); +} + +inline void sp_enable_shared_from_this(void const *, void const *, shared_count const &) +{ +} + +} // namespace detail + + +// +// shared_ptr +// +// An enhanced relative of scoped_ptr with reference counted copy semantics. +// The object pointed to is deleted when the last shared_ptr pointing to it +// is destroyed or reset. +// + +template<class T> class shared_ptr +{ +private: + + // Borland 5.5.1 specific workaround + typedef shared_ptr<T> this_type; + +public: + + typedef T element_type; + typedef T value_type; + typedef T * pointer; + typedef typename detail::shared_ptr_traits<T>::reference reference; + + shared_ptr(): px(0), pn() // never throws in 1.30+ + { + } + + template<class Y> + explicit shared_ptr(Y * p): px(p), pn(p, checked_deleter<Y>()) // Y must be complete + { + detail::sp_enable_shared_from_this(p, p, pn); + } + + // + // Requirements: D's copy constructor must not throw + // + // shared_ptr will release p by calling d(p) + // + + template<class Y, class D> shared_ptr(Y * p, D d): px(p), pn(p, d) + { + detail::sp_enable_shared_from_this(p, p, pn); + } + +// generated copy constructor, assignment, destructor are fine... +// except that Borland C++ has a bug, and g++ with -Wsynth warns + shared_ptr & operator=(shared_ptr const & r) // never throws + { + px = r.px; + pn = r.pn; // shared_count::op= doesn't throw + return *this; + } + + template<class Y> + explicit shared_ptr(weak_ptr<Y> const & r): pn(r.pn) // may throw + { + // it is now safe to copy r.px, as pn(r.pn) did not throw + px = r.px; + } + + template<class Y> + shared_ptr(shared_ptr<Y> const & r): px(r.px), pn(r.pn) // never throws + { + } + + template<class Y> + shared_ptr(shared_ptr<Y> const & r, detail::static_cast_tag): px(static_cast<element_type *>(r.px)), pn(r.pn) + { + } + + template<class Y> + shared_ptr(shared_ptr<Y> const & r, detail::const_cast_tag): px(const_cast<element_type *>(r.px)), pn(r.pn) + { + } + + template<class Y> + shared_ptr(shared_ptr<Y> const & r, detail::dynamic_cast_tag): px(dynamic_cast<element_type *>(r.px)), pn(r.pn) + { + if(px == 0) // need to allocate new counter -- the cast failed + { + pn = detail::shared_count(); + } + } + + template<class Y> + shared_ptr(shared_ptr<Y> const & r, detail::polymorphic_cast_tag): px(dynamic_cast<element_type *>(r.px)), pn(r.pn) + { + if(px == 0) + { + myboost::throw_exception(std::bad_cast()); + } + } + + template<class Y> + explicit shared_ptr(std::auto_ptr<Y> & r): px(r.get()), pn() + { + Y * tmp = r.get(); + pn = detail::shared_count(r); + detail::sp_enable_shared_from_this(tmp, tmp, pn); + } + + template<class Y> + shared_ptr & operator=(shared_ptr<Y> const & r) // never throws + { + px = r.px; + pn = r.pn; // shared_count::op= doesn't throw + return *this; + } + + template<class Y> + shared_ptr & operator=(std::auto_ptr<Y> & r) + { + this_type(r).swap(*this); + return *this; + } + + void reset() // never throws in 1.30+ + { + this_type().swap(*this); + } + + template<class Y> void reset(Y * p) // Y must be complete + { + BOOST_ASSERT(p == 0 || p != px); // catch self-reset errors + this_type(p).swap(*this); + } + + template<class Y, class D> void reset(Y * p, D d) + { + this_type(p, d).swap(*this); + } + + reference operator* () const // never throws + { + BOOST_ASSERT(px != 0); + return *px; + } + + T * operator-> () const // never throws + { + BOOST_ASSERT(px != 0); + return px; + } + + T * get() const // never throws + { + return px; + } + + typedef T * (this_type::*unspecified_bool_type)() const; + + operator unspecified_bool_type() const // never throws + { + return px == 0? 0: &this_type::get; + } + + // operator! is redundant, but some compilers need it + + bool operator! () const // never throws + { + return px == 0; + } + + bool unique() const // never throws + { + return pn.unique(); + } + + long use_count() const // never throws + { + return pn.use_count(); + } + + void swap(shared_ptr<T> & other) // never throws + { + std::swap(px, other.px); + pn.swap(other.pn); + } + + template<class Y> bool _internal_less(shared_ptr<Y> const & rhs) const + { + return pn < rhs.pn; + } + + void * _internal_get_deleter(std::type_info const & ti) const + { + return pn.get_deleter(ti); + } + +// Tasteless as this may seem, making all members public allows member templates +// to work in the absence of member template friends. (Matthew Langston) + +# if __GNUC__ >= 2 && __GNUC_MINOR__ >= 97 +private: + + template<class Y> friend class shared_ptr; + template<class Y> friend class weak_ptr; +#endif + + T * px; // contained pointer + detail::shared_count pn; // reference counter + +}; // shared_ptr + +template<class T, class U> inline bool operator==(shared_ptr<T> const & a, shared_ptr<U> const & b) +{ + return a.get() == b.get(); +} + +template<class T, class U> inline bool operator!=(shared_ptr<T> const & a, shared_ptr<U> const & b) +{ + return a.get() != b.get(); +} + +#if __GNUC__ == 2 && __GNUC_MINOR__ <= 96 + +// Resolve the ambiguity between our op!= and the one in rel_ops + +template<class T> inline bool operator!=(shared_ptr<T> const & a, shared_ptr<T> const & b) +{ + return a.get() != b.get(); +} + +#endif + +template<class T, class U> inline bool operator<(shared_ptr<T> const & a, shared_ptr<U> const & b) +{ + return a._internal_less(b); +} + +template<class T> inline void swap(shared_ptr<T> & a, shared_ptr<T> & b) +{ + a.swap(b); +} + +template<class T, class U> shared_ptr<T> static_pointer_cast(shared_ptr<U> const & r) +{ + return shared_ptr<T>(r, detail::static_cast_tag()); +} + +template<class T, class U> shared_ptr<T> const_pointer_cast(shared_ptr<U> const & r) +{ + return shared_ptr<T>(r, detail::const_cast_tag()); +} + +template<class T, class U> shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const & r) +{ + return shared_ptr<T>(r, detail::dynamic_cast_tag()); +} + +// shared_*_cast names are deprecated. Use *_pointer_cast instead. + +template<class T, class U> shared_ptr<T> shared_static_cast(shared_ptr<U> const & r) +{ + return shared_ptr<T>(r, detail::static_cast_tag()); +} + +template<class T, class U> shared_ptr<T> shared_dynamic_cast(shared_ptr<U> const & r) +{ + return shared_ptr<T>(r, detail::dynamic_cast_tag()); +} + +template<class T, class U> shared_ptr<T> shared_polymorphic_cast(shared_ptr<U> const & r) +{ + return shared_ptr<T>(r, detail::polymorphic_cast_tag()); +} + +template<class T, class U> shared_ptr<T> shared_polymorphic_downcast(shared_ptr<U> const & r) +{ + BOOST_ASSERT(dynamic_cast<T *>(r.get()) == r.get()); + return shared_static_cast<T>(r); +} + +// get_pointer() enables boost::mem_fn to recognize shared_ptr + +template<class T> inline T * get_pointer(shared_ptr<T> const & p) +{ + return p.get(); +} + +// operator<< + + +template<class Y> std::ostream & operator<< (std::ostream & os, shared_ptr<Y> const & p) +{ + os << p.get(); + return os; +} + + +// get_deleter (experimental) + +#if (defined(__GNUC__) && (__GNUC__ < 3)) || (defined(__EDG_VERSION__) && (__EDG_VERSION__ <= 238)) + +// g++ 2.9x doesn't allow static_cast<X const *>(void *) +// apparently EDG 2.38 also doesn't accept it + +template<class D, class T> D * get_deleter(shared_ptr<T> const & p) +{ + void const * q = p._internal_get_deleter(typeid(D)); + return const_cast<D *>(static_cast<D const *>(q)); +} + +#else + +template<class D, class T> D * get_deleter(shared_ptr<T> const & p) +{ + return static_cast<D *>(p._internal_get_deleter(typeid(D))); +} + +#endif + +} // namespace boost + + +#endif // #ifndef BOOST_SHARED_PTR_HPP_INCLUDED diff --git a/ksvg/impl/libs/libtext2path/src/myboost/throw_exception.hpp b/ksvg/impl/libs/libtext2path/src/myboost/throw_exception.hpp new file mode 100644 index 00000000..dd32ec43 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/myboost/throw_exception.hpp @@ -0,0 +1,30 @@ +#ifndef BOOST_THROW_EXCEPTION_HPP_INCLUDED +#define BOOST_THROW_EXCEPTION_HPP_INCLUDED + + +// +// boost/throw_exception.hpp +// +// Copyright (c) 2002 Peter Dimov and Multi Media Ltd. +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +// http://www.boost.org/libs/utility/throw_exception.html +// + +# include <exception> + +namespace myboost +{ + +template<class E> void throw_exception(E const & e) +{ + throw e; +} + +} // namespace myboost + +#endif // #ifndef BOOST_THROW_EXCEPTION_HPP_INCLUDED diff --git a/ksvg/impl/libs/xrgbrender/Makefile.am b/ksvg/impl/libs/xrgbrender/Makefile.am new file mode 100644 index 00000000..1e9ebcc1 --- /dev/null +++ b/ksvg/impl/libs/xrgbrender/Makefile.am @@ -0,0 +1,5 @@ +INCLUDES = $(all_includes) + +noinst_LTLIBRARIES = libksvgxrgbrender.la + +libksvgxrgbrender_la_SOURCES = gdk-pixbuf-xlib.c gdk-pixbuf-xlib-drawable.c gdk-pixbuf-xlibrgb.c diff --git a/ksvg/impl/libs/xrgbrender/gdk-pixbuf-xlib-drawable.c b/ksvg/impl/libs/xrgbrender/gdk-pixbuf-xlib-drawable.c new file mode 100644 index 00000000..01f60976 --- /dev/null +++ b/ksvg/impl/libs/xrgbrender/gdk-pixbuf-xlib-drawable.c @@ -0,0 +1,1137 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* GdkPixbuf library - convert X drawable information to RGB + * + * Copyright (C) 1999 Michael Zucchi + * + * Authors: Michael Zucchi <zucchi@zedzone.mmc.com.au> + * Cody Russell <bratsche@dfw.net> + * Federico Mena-Quintero <federico@gimp.org> + * + * 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; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +/* Ported to Xlib by John Harper <john@dcs.warwick.ac.uk> */ + + +#include <config.h> +#include <stdio.h> +#include <string.h> +#include "gdk-pixbuf-xlib-private.h" +#include <X11/Xlib.h> +#include <X11/Xutil.h> + +#if (X_BYTE_ORDER == X_LITTLE_ENDIAN) +#define LITTLE +#endif +#define d(x) + + + +static unsigned int mask_table[] = { + 0x00000000, 0x00000001, 0x00000003, 0x00000007, + 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, + 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, + 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, + 0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff, + 0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff, + 0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff, + 0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, + 0xffffffff +}; + + +/* color handling */ + +typedef struct xlib_colormap_struct xlib_colormap; +struct xlib_colormap_struct { + int size; + XColor *colors; + Visual *visual; + Colormap colormap; +}; + + +/* from gdkvisual.c */ +static void +visual_decompose_mask (unsigned long mask, + int *shift, + int *prec) +{ + *shift = 0; + *prec = 0; + + while (!(mask & 0x1)) { + (*shift)++; + mask >>= 1; + } + + while (mask & 0x1) { + (*prec)++; + mask >>= 1; + } +} + +static int x_error; + +static int +handle_x_error (Display *dpy, XErrorEvent *ev) +{ + x_error = 1; + return 0; +} + +static int +drawable_is_pixmap (Drawable d) +{ + /* copied from Imlib */ + + XErrorHandler errh; + XWindowAttributes wa; + int is_pixmap; + + errh = XSetErrorHandler (handle_x_error); + x_error = 0; + XGetWindowAttributes (gdk_pixbuf_dpy, d, &wa); + XSync (gdk_pixbuf_dpy, False); + is_pixmap = x_error; + XSetErrorHandler (errh); + + return is_pixmap; +} + + + +/* + convert 1 bits-pixel data + no alpha +*/ +static void +rgb1 (XImage *image, unsigned char *pixels, int rowstride, xlib_colormap *colormap) +{ + int xx, yy; + int width, height; + int bpl; + unsigned char *s; + register unsigned char data; + unsigned char *o; + unsigned char *srow = image->data, *orow = pixels; + + d (printf ("1 bits/pixel\n")); + + /* convert upto 8 pixels/time */ + /* its probably not worth trying to make this run very fast, who uses + 1 bit displays anymore? */ + width = image->width; + height = image->height; + bpl = image->bytes_per_line; + + for (yy = 0; yy < height; yy++) { + s = srow; + o = orow; + + for (xx = 0; xx < width; xx ++) { + data = srow[xx >> 3] >> (7 - (xx & 7)) & 1; + *o++ = colormap->colors[data].red; + *o++ = colormap->colors[data].green; + *o++ = colormap->colors[data].blue; + } + srow += bpl; + orow += rowstride; + } +} + +/* + convert 1 bits/pixel data + with alpha +*/ +static void +rgb1a (XImage *image, unsigned char *pixels, int rowstride, xlib_colormap *colormap) +{ + int xx, yy; + int width, height; + int bpl; + unsigned char *s; + register unsigned char data; + unsigned char *o; + unsigned char *srow = image->data, *orow = pixels; + unsigned int remap[2]; + + d (printf ("1 bits/pixel\n")); + + /* convert upto 8 pixels/time */ + /* its probably not worth trying to make this run very fast, who uses + 1 bit displays anymore? */ + width = image->width; + height = image->height; + bpl = image->bytes_per_line; + + for (xx = 0; xx < 2; xx++) { +#ifdef LITTLE + remap[xx] = 0xff000000 + | colormap->colors[xx].blue << 16 + | colormap->colors[xx].green << 8 + | colormap->colors[xx].red; +#else + remap[xx] = 0xff + | colormap->colors[xx].red << 24 + | colormap->colors[xx].green << 16 + | colormap->colors[xx].blue << 8; +#endif + } + + for (yy = 0; yy < height; yy++) { + s = srow; + o = orow; + + for (xx = 0; xx < width; xx ++) { + data = srow[xx >> 3] >> (7 - (xx & 7)) & 1; + *o++ = remap[data]; + } + srow += bpl; + orow += rowstride; + } +} + +/* + convert 8 bits/pixel data + no alpha +*/ +static void +rgb8 (XImage *image, unsigned char *pixels, int rowstride, xlib_colormap *colormap) +{ + int xx, yy; + int width, height; + int bpl; + unsigned int mask; + register unsigned int data; + unsigned char *srow = image->data, *orow = pixels; + register unsigned char *s; + register unsigned char *o; + + width = image->width; + height = image->height; + bpl = image->bytes_per_line; + + d (printf ("8 bit, no alpha output\n")); + + mask = mask_table[image->depth]; + + for (yy = 0; yy < height; yy++) { + s = srow; + o = orow; + for (xx = 0; xx < width; xx++) { + data = *s++ & mask; + *o++ = colormap->colors[data].red; + *o++ = colormap->colors[data].green; + *o++ = colormap->colors[data].blue; + } + srow += bpl; + orow += rowstride; + } +} + +/* + convert 8 bits/pixel data + with alpha +*/ +static void +rgb8a (XImage *image, unsigned char *pixels, int rowstride, xlib_colormap *colormap) +{ + int xx, yy; + int width, height; + int bpl; + unsigned int mask; + register unsigned int data; + unsigned int remap[256]; + register unsigned char *s; /* read 2 pixels at once */ + register unsigned int *o; + unsigned char *srow = image->data, *orow = pixels; + + width = image->width; + height = image->height; + bpl = image->bytes_per_line; + + d (printf ("8 bit, with alpha output\n")); + + mask = mask_table[image->depth]; + + for (xx = 0; xx < colormap->size; xx++) { +#ifdef LITTLE + remap[xx] = 0xff000000 + | colormap->colors[xx].blue << 16 + | colormap->colors[xx].green << 8 + | colormap->colors[xx].red; +#else + remap[xx] = 0xff + | colormap->colors[xx].red << 24 + | colormap->colors[xx].green << 16 + | colormap->colors[xx].blue << 8; +#endif + } + + for (yy = 0; yy < height; yy++) { + s = srow; + o = (unsigned int *) orow; + for (xx = 0; xx < width; xx ++) { + data = *s++ & mask; + *o++ = remap[data]; + } + srow += bpl; + orow += rowstride; + } +} + +/* + convert 16 bits/pixel data + no alpha + data in lsb format +*/ +static void +rgb565lsb (XImage *image, unsigned char *pixels, int rowstride, xlib_colormap *colormap) +{ + int xx, yy; + int width, height; + int bpl; + +#ifdef LITTLE + register unsigned int *s; /* read 2 pixels at once */ +#else + register unsigned char *s; /* read 2 pixels at once */ +#endif + register unsigned short *o; + unsigned char *srow = image->data, *orow = pixels; + + width = image->width; + height = image->height; + bpl = image->bytes_per_line; + + for (yy = 0; yy < height; yy++) { +#ifdef LITTLE + s = (unsigned int *) srow; +#else + s = srow; +#endif + o = (unsigned short *) orow; + for (xx = 1; xx < width; xx += 2) { + register unsigned int data; +#ifdef LITTLE + data = *s++; + *o++ = (data & 0xf800) >> 8 | (data & 0xe000) >> 13 + | (data & 0x7e0) << 5 | (data & 0x600) >> 1; + *o++ = (data & 0x1f) << 3 | (data & 0x1c) >> 2 + | (data & 0xf8000000) >> 16 | (data & 0xe0000000) >> 21; + *o++ = (data & 0x7e00000) >> 19 | (data & 0x6000000) >> 25 + | (data & 0x1f0000) >> 5 | (data & 0x1c0000) >> 10; +#else + /* swap endianness first */ + data = s[0] | s[1] << 8 | s[2] << 16 | s[3] << 24; + s += 4; + *o++ = (data & 0xf800) | (data & 0xe000) >> 5 + | (data & 0x7e0) >> 3 | (data & 0x600) >> 9; + *o++ = (data & 0x1f) << 11 | (data & 0x1c) << 6 + | (data & 0xf8000000) >> 24 | (data & 0xe0000000) >> 29; + *o++ = (data & 0x7e00000) >> 11 | (data & 0x6000000) >> 17 + | (data & 0x1f0000) >> 13 | (data & 0x1c0000) >> 18; +#endif + } + /* check for last remaining pixel */ + if (width & 1) { + register unsigned short data; +#ifdef LITTLE + data = *((short *) s); +#else + data = *((short *) s); + data = ((data >> 8) & 0xff) | ((data & 0xff) << 8); +#endif + ((char *) o)[0] = ((data >> 8) & 0xf8) | ((data >> 13) & 0x7); + ((char *) o)[1] = ((data >> 3) & 0xfc) | ((data >> 9) & 0x3); + ((char *) o)[2] = ((data << 3) & 0xf8) | ((data >> 2) & 0x7); + } + srow += bpl; + orow += rowstride; + } +} + +/* + convert 16 bits/pixel data + no alpha + data in msb format +*/ +static void +rgb565msb (XImage *image, unsigned char *pixels, int rowstride, xlib_colormap *colormap) +{ + int xx, yy; + int width, height; + int bpl; + +#ifdef LITTLE + register unsigned char *s; /* need to swap data order */ +#else + register unsigned int *s; /* read 2 pixels at once */ +#endif + register unsigned short *o; + unsigned char *srow = image->data, *orow = pixels; + + width = image->width; + height = image->height; + bpl = image->bytes_per_line; + + for (yy = 0; yy < height; yy++) { +#ifdef LITTLE + s = srow; +#else + s = (unsigned int *) srow; +#endif + o = (unsigned short *) orow; + for (xx = 1; xx < width; xx += 2) { + register unsigned int data; +#ifdef LITTLE + /* swap endianness first */ + data = s[0] | s[1] << 8 | s[2] << 16 | s[3] << 24; + s += 4; + *o++ = (data & 0xf800) >> 8 | (data & 0xe000) >> 13 + | (data & 0x7e0) << 5 | (data & 0x600) >> 1; + *o++ = (data & 0x1f) << 3 | (data & 0x1c) >> 2 + | (data & 0xf8000000) >> 16 | (data & 0xe0000000) >> 21; + *o++ = (data & 0x7e00000) >> 19 | (data & 0x6000000) >> 25 + | (data & 0x1f0000) >> 5 | (data & 0x1c0000) >> 10; +#else + data = *s++; + *o++ = (data & 0xf800) | (data & 0xe000) >> 5 + | (data & 0x7e0) >> 3 | (data & 0x600) >> 9; + *o++ = (data & 0x1f) << 11 | (data & 0x1c) << 6 + | (data & 0xf8000000) >> 24 | (data & 0xe0000000) >> 29; + *o++ = (data & 0x7e00000) >> 11 | (data & 0x6000000) >> 17 + | (data & 0x1f0000) >> 13 | (data & 0x1c0000) >> 18; +#endif + } + /* check for last remaining pixel */ + if (width & 1) { + register unsigned short data; +#ifdef LITTLE + data = *((short *) s); + data = ((data >> 8) & 0xff) | ((data & 0xff) << 8); +#else + data = *((short *) s); +#endif + ((char *) o)[0] = ((data >> 8) & 0xf8) | ((data >> 13) & 0x7); + ((char *) o)[1] = ((data >> 3) & 0xfc) | ((data >> 9) & 0x3); + ((char *) o)[2] = ((data << 3) & 0xf8) | ((data >> 2) & 0x7); + } + srow += bpl; + orow += rowstride; + } +} + +/* + convert 16 bits/pixel data + with alpha + data in lsb format +*/ +static void +rgb565alsb (XImage *image, unsigned char *pixels, int rowstride, xlib_colormap *colormap) +{ + int xx, yy; + int width, height; + int bpl; + +#ifdef LITTLE + register unsigned short *s; /* read 1 pixels at once */ +#else + register unsigned char *s; +#endif + register unsigned int *o; + + unsigned char *srow = image->data, *orow = pixels; + + width = image->width; + height = image->height; + bpl = image->bytes_per_line; + + for (yy = 0; yy < height; yy++) { +#ifdef LITTLE + s = (unsigned short *) srow; +#else + s = (unsigned char *) srow; +#endif + o = (unsigned int *) orow; + for (xx = 0; xx < width; xx ++) { + register unsigned int data; + /* rrrrrggg gggbbbbb -> rrrrrRRR ggggggGG bbbbbBBB aaaaaaaa */ + /* little endian: aaaaaaaa bbbbbBBB ggggggGG rrrrrRRR */ +#ifdef LITTLE + data = *s++; + *o++ = (data & 0xf800) >> 8 | (data & 0xe000) >> 13 + | (data & 0x7e0) << 5 | (data & 0x600) >> 1 + | (data & 0x1f) << 19 | (data & 0x1c) << 14 + | 0xff000000; +#else + /* swap endianness first */ + data = s[0] | s[1] << 8; + s += 2; + *o++ = (data & 0xf800) << 16 | (data & 0xe000) << 11 + | (data & 0x7e0) << 13 | (data & 0x600) << 7 + | (data & 0x1f) << 11 | (data & 0x1c) << 6 + | 0xff; +#endif + } + srow += bpl; + orow += rowstride; + } +} + +/* + convert 16 bits/pixel data + with alpha + data in msb format +*/ +static void +rgb565amsb (XImage *image, unsigned char *pixels, int rowstride, xlib_colormap *colormap) +{ + int xx, yy; + int width, height; + int bpl; + +#ifdef LITTLE + register unsigned char *s; +#else + register unsigned short *s; /* read 1 pixels at once */ +#endif + register unsigned int *o; + + unsigned char *srow = image->data, *orow = pixels; + + width = image->width; + height = image->height; + bpl = image->bytes_per_line; + + for (yy = 0; yy < height; yy++) { + s = srow; + o = (unsigned int *) orow; + for (xx = 0; xx < width; xx ++) { + register unsigned int data; + /* rrrrrggg gggbbbbb -> rrrrrRRR gggggg00 bbbbbBBB aaaaaaaa */ + /* little endian: aaaaaaaa bbbbbBBB gggggg00 rrrrrRRR */ +#ifdef LITTLE + /* swap endianness first */ + data = s[0] | s[1] << 8; + s += 2; + *o++ = (data & 0xf800) >> 8 | (data & 0xe000) >> 13 + | (data & 0x7e0) << 5 | (data & 0x600) >> 1 + | (data & 0x1f) << 19 | (data & 0x1c) << 14 + | 0xff000000; +#else + data = *s++; + *o++ = (data & 0xf800) << 16 | (data & 0xe000) << 11 + | (data & 0x7e0) << 13 | (data & 0x600) << 7 + | (data & 0x1f) << 11 | (data & 0x1c) << 6 + | 0xff; +#endif + } + srow += bpl; + orow += rowstride; + } +} + +/* + convert 15 bits/pixel data + no alpha + data in lsb format +*/ +static void +rgb555lsb (XImage *image, unsigned char *pixels, int rowstride, xlib_colormap *colormap) +{ + int xx, yy; + int width, height; + int bpl; + +#ifdef LITTLE + register unsigned int *s; /* read 2 pixels at once */ +#else + register unsigned char *s; /* read 2 pixels at once */ +#endif + register unsigned short *o; + unsigned char *srow = image->data, *orow = pixels; + + width = image->width; + height = image->height; + bpl = image->bytes_per_line; + + for (yy = 0; yy < height; yy++) { +#ifdef LITTLE + s = (unsigned int *) srow; +#else + s = srow; +#endif + o = (unsigned short *) orow; + for (xx = 1; xx < width; xx += 2) { + register unsigned int data; +#ifdef LITTLE + data = *s++; + *o++ = (data & 0x7c00) >> 7 | (data & 0x7000) >> 12 + | (data & 0x3e0) << 6 | (data & 0x380) << 1; + *o++ = (data & 0x1f) << 3 | (data & 0x1c) >> 2 + | (data & 0x7c000000) >> 15 | (data & 0x70000000) >> 20; + *o++ = (data & 0x3e00000) >> 18 | (data & 0x3800000) >> 23 + | (data & 0x1f0000) >> 5 | (data & 0x1c0000) >> 10; +#else + /* swap endianness first */ + data = s[0] | s[1] << 8 | s[2] << 16 | s[3] << 24; + s += 4; + *o++ = (data & 0x7c00) << 1 | (data & 0x7000) >> 4 + | (data & 0x3e0) >> 2 | (data & 0x380) >> 7; + *o++ = (data & 0x1f) << 11 | (data & 0x1c) << 6 + | (data & 0x7c000000) >> 23 | (data & 0x70000000) >> 28; + *o++ = (data & 0x3e00000) >> 10 | (data & 0x3800000) >> 15 + | (data & 0x1f0000) >> 13 | (data & 0x1c0000) >> 18; +#endif + } + /* check for last remaining pixel */ + if (width & 1) { + register unsigned short data; +#ifdef LITTLE + data = *((short *) s); +#else + data = *((short *) s); + data = ((data >> 8) & 0xff) | ((data & 0xff) << 8); +#endif + ((char *) o)[0] = (data & 0x7c00) >> 7 | (data & 0x7000) >> 12; + ((char *) o)[1] = (data & 0x3e0) >> 2 | (data & 0x380) >> 7; + ((char *) o)[2] = (data & 0x1f) << 3 | (data & 0x1c) >> 2; + } + srow += bpl; + orow += rowstride; + } +} + +/* + convert 15 bits/pixel data + no alpha + data in msb format +*/ +static void +rgb555msb (XImage *image, unsigned char *pixels, int rowstride, xlib_colormap *colormap) +{ + int xx, yy; + int width, height; + int bpl; + +#ifdef LITTLE + register unsigned char *s; /* read 2 pixels at once */ +#else + register unsigned int *s; /* read 2 pixels at once */ +#endif + register unsigned short *o; + unsigned char *srow = image->data, *orow = pixels; + + width = image->width; + height = image->height; + bpl = image->bytes_per_line; + + for (yy = 0; yy < height; yy++) { + s = srow; + o = (unsigned short *) orow; + for (xx = 1; xx < width; xx += 2) { + register unsigned int data; +#ifdef LITTLE + /* swap endianness first */ + data = s[0] | s[1] << 8 | s[2] << 16 | s[3] << 24; + s += 4; + *o++ = (data & 0x7c00) >> 7 | (data & 0x7000) >> 12 + | (data & 0x3e0) << 6 | (data & 0x380) << 1; + *o++ = (data & 0x1f) << 3 | (data & 0x1c) >> 2 + | (data & 0x7c000000) >> 15 | (data & 0x70000000) >> 20; + *o++ = (data & 0x3e00000) >> 18 | (data & 0x3800000) >> 23 + | (data & 0x1f0000) >> 5 | (data & 0x1c0000) >> 10; +#else + data = *s++; + *o++ = (data & 0x7c00) << 1 | (data & 0x7000) >> 4 + | (data & 0x3e0) >> 2 | (data & 0x380) >> 7; + *o++ = (data & 0x1f) << 11 | (data & 0x1c) << 6 + | (data & 0x7c000000) >> 23 | (data & 0x70000000) >> 28; + *o++ = (data & 0x3e00000) >> 10 | (data & 0x3800000) >> 15 + | (data & 0x1f0000) >> 13 | (data & 0x1c0000) >> 18; +#endif + } + /* check for last remaining pixel */ + if (width & 1) { + register unsigned short data; +#ifdef LITTLE + data = *((short *) s); + data = ((data >> 8) & 0xff) | ((data & 0xff) << 8); +#else + data = *((short *) s); +#endif + ((char *) o)[0] = (data & 0x7c00) >> 7 | (data & 0x7000) >> 12; + ((char *) o)[1] = (data & 0x3e0) >> 2 | (data & 0x380) >> 7; + ((char *) o)[2] = (data & 0x1f) << 3 | (data & 0x1c) >> 2; + } + srow += bpl; + orow += rowstride; + } +} + +/* + convert 15 bits/pixel data + with alpha + data in lsb format +*/ +static void +rgb555alsb (XImage *image, unsigned char *pixels, int rowstride, xlib_colormap *colormap) +{ + int xx, yy; + int width, height; + int bpl; + +#ifdef LITTLE + register unsigned short *s; /* read 1 pixels at once */ +#else + register unsigned char *s; +#endif + register unsigned int *o; + + unsigned char *srow = image->data, *orow = pixels; + + width = image->width; + height = image->height; + bpl = image->bytes_per_line; + + for (yy = 0; yy < height; yy++) { +#ifdef LITTLE + s = (unsigned short *) srow; +#else + s = srow; +#endif + o = (unsigned int *) orow; + for (xx = 0; xx < width; xx++) { + register unsigned int data; + /* rrrrrggg gggbbbbb -> rrrrrRRR gggggGGG bbbbbBBB aaaaaaaa */ + /* little endian: aaaaaaaa bbbbbBBB gggggGGG rrrrrRRR */ +#ifdef LITTLE + data = *s++; + *o++ = (data & 0x7c00) >> 7 | (data & 0x7000) >> 12 + | (data & 0x3e0) << 6 | (data & 0x380) << 1 + | (data & 0x1f) << 19 | (data & 0x1c) << 14 + | 0xff000000; +#else + /* swap endianness first */ + data = s[0] | s[1] << 8; + s += 2; + *o++ = (data & 0x7c00) << 17 | (data & 0x7000) << 12 + | (data & 0x3e0) << 14 | (data & 0x380) << 9 + | (data & 0x1f) << 11 | (data & 0x1c) << 6 + | 0xff; +#endif + } + srow += bpl; + orow += rowstride; + } +} + +/* + convert 15 bits/pixel data + with alpha + data in msb format +*/ +static void +rgb555amsb (XImage *image, unsigned char *pixels, int rowstride, xlib_colormap *colormap) +{ + int xx, yy; + int width, height; + int bpl; + +#ifdef LITTLE + register unsigned short *s; /* read 1 pixels at once */ +#else + register unsigned char *s; +#endif + register unsigned int *o; + + unsigned char *srow = image->data, *orow = pixels; + + width = image->width; + height = image->height; + bpl = image->bytes_per_line; + + for (yy = 0; yy < height; yy++) { +#ifdef LITTLE + s = (unsigned short *) srow; +#else + s = srow; +#endif + o = (unsigned int *) orow; + for (xx = 0; xx < width; xx++) { + register unsigned int data; + /* rrrrrggg gggbbbbb -> rrrrrRRR gggggGGG bbbbbBBB aaaaaaaa */ + /* little endian: aaaaaaaa bbbbbBBB gggggGGG rrrrrRRR */ +#ifdef LITTLE + /* swap endianness first */ + data = s[0] | s[1] << 8; + s += 2; + *o++ = (data & 0x7c00) >> 7 | (data & 0x7000) >> 12 + | (data & 0x3e0) << 6 | (data & 0x380) << 1 + | (data & 0x1f) << 19 | (data & 0x1c) << 14 + | 0xff000000; +#else + data = *s++; + *o++ = (data & 0x7c00) << 17 | (data & 0x7000) << 12 + | (data & 0x3e0) << 14 | (data & 0x380) << 9 + | (data & 0x1f) << 11 | (data & 0x1c) << 6 + | 0xff; +#endif + } + srow += bpl; + orow += rowstride; + } +} + + +static void +rgb888alsb (XImage *image, unsigned char *pixels, int rowstride, xlib_colormap *colormap) +{ + int xx, yy; + int width, height; + int bpl; + + unsigned char *s; /* for byte order swapping */ + unsigned char *o; + unsigned char *srow = image->data, *orow = pixels; + + width = image->width; + height = image->height; + bpl = image->bytes_per_line; + + d (printf ("32 bits/pixel with alpha\n")); + + /* lsb data */ + for (yy = 0; yy < height; yy++) { + s = srow; + o = orow; + for (xx = 0; xx < width; xx++) { + *o++ = s[2]; + *o++ = s[1]; + *o++ = s[0]; + *o++ = 0xff; + s += 4; + } + srow += bpl; + orow += rowstride; + } +} + +static void +rgb888lsb (XImage *image, unsigned char *pixels, int rowstride, xlib_colormap *colormap) +{ + int xx, yy; + int width, height; + int bpl; + + unsigned char *srow = image->data, *orow = pixels; + unsigned char *o, *s; + + width = image->width; + height = image->height; + bpl = image->bytes_per_line; + + d (printf ("32 bit, lsb, no alpha\n")); + + for (yy = 0; yy < height; yy++) { + s = srow; + o = orow; + for (xx = 0; xx < width; xx++) { + *o++ = s[2]; + *o++ = s[1]; + *o++ = s[0]; + s += 4; + } + srow += bpl; + orow += rowstride; + } +} + +static void +rgb888amsb (XImage *image, unsigned char *pixels, int rowstride, xlib_colormap *colormap) +{ + int xx, yy; + int width, height; + int bpl; + + unsigned char *srow = image->data, *orow = pixels; +#ifdef LITTLE + unsigned int *o; + unsigned int *s; +#else + unsigned char *s; /* for byte order swapping */ + unsigned char *o; +#endif + + d (printf ("32 bit, msb, with alpha\n")); + + width = image->width; + height = image->height; + bpl = image->bytes_per_line; + + /* msb data */ + for (yy = 0; yy < height; yy++) { +#ifdef LITTLE + s = (unsigned int *) srow; + o = (unsigned int *) orow; +#else + s = srow; + o = orow; +#endif + for (xx = 0; xx < width; xx++) { +#ifdef LITTLE + *o++ = s[1]; + *o++ = s[2]; + *o++ = s[3]; + *o++ = 0xff; + s += 4; +#else + *o++ = (*s << 8) | 0xff; /* untested */ + s++; +#endif + } + srow += bpl; + orow += rowstride; + } +} + +static void +rgb888msb (XImage *image, unsigned char *pixels, int rowstride, xlib_colormap *colormap) +{ + int xx, yy; + int width, height; + int bpl; + + unsigned char *srow = image->data, *orow = pixels; + unsigned char *s; + unsigned char *o; + + d (printf ("32 bit, msb, no alpha\n")); + + width = image->width; + height = image->height; + bpl = image->bytes_per_line; + + for (yy = 0; yy < height; yy++) { + s = srow; + o = orow; + for (xx = 0; xx < width; xx++) { + *o++ = s[1]; + *o++ = s[2]; + *o++ = s[3]; + s += 4; + } + srow += bpl; + orow += rowstride; + } +} + +/* + This should work correctly with any display/any endianness, but will probably + run quite slow +*/ +static void +convert_real_slow (XImage *image, unsigned char *pixels, int rowstride, xlib_colormap *cmap, int alpha) +{ + int xx, yy; + int width, height; + int bpl; + unsigned char *srow = image->data, *orow = pixels; + unsigned char *s; + unsigned char *o; + unsigned int pixel; + Visual *v; + unsigned char component; + int i; + int red_shift, red_prec, green_shift, green_prec, blue_shift, blue_prec; + + width = image->width; + height = image->height; + bpl = image->bytes_per_line; + v = cmap->visual; + + visual_decompose_mask (v->red_mask, &red_shift, &red_prec); + visual_decompose_mask (v->green_mask, &green_shift, &green_prec); + visual_decompose_mask (v->blue_mask, &blue_shift, &blue_prec); + + d(printf("rgb mask/shift/prec = %x:%x:%x %d:%d:%d %d:%d:%d\n", + v->red_mask, v->green_mask, v->blue_mask, + red_shift, green_shift, blue_shift, + red_prec, green_prec, blue_prec)); + + for (yy = 0; yy < height; yy++) { + s = srow; + o = orow; + for (xx = 0; xx < width; xx++) { + pixel = XGetPixel (image, xx, yy); + switch (v->class) { + /* I assume this is right for static & greyscale's too? */ + case StaticGray: + case GrayScale: + case StaticColor: + case PseudoColor: + *o++ = cmap->colors[pixel].red; + *o++ = cmap->colors[pixel].green; + *o++ = cmap->colors[pixel].blue; + break; + case TrueColor: + /* This is odd because it must sometimes shift left (otherwise + I'd just shift >> (*_shift - 8 + *_prec + <0-7>). This logic + should work for all bit sizes/shifts/etc. */ + component = 0; + for (i = 24; i < 32; i += red_prec) + component |= ((pixel & v->red_mask) << (32 - red_shift - red_prec)) >> i; + *o++ = component; + component = 0; + for (i = 24; i < 32; i += green_prec) + component |= ((pixel & v->green_mask) << (32 - green_shift - green_prec)) >> i; + *o++ = component; + component = 0; + for (i = 24; i < 32; i += blue_prec) + component |= ((pixel & v->blue_mask) << (32 - blue_shift - blue_prec)) >> i; + *o++ = component; + break; + case DirectColor: + *o++ = cmap->colors[((pixel & v->red_mask) << (32 - red_shift - red_prec)) >> 24].red; + *o++ = cmap->colors[((pixel & v->green_mask) << (32 - green_shift - green_prec)) >> 24].green; + *o++ = cmap->colors[((pixel & v->blue_mask) << (32 - blue_shift - blue_prec)) >> 24].blue; + break; + } + if (alpha) + *o++ = 0xff; + } + srow += bpl; + orow += rowstride; + } +} + +typedef void (* cfunc) (XImage *image, unsigned char *pixels, int rowstride, xlib_colormap *cmap); + +static cfunc convert_map[] = { + rgb1,rgb1,rgb1a,rgb1a, + rgb8,rgb8,rgb8a,rgb8a, + rgb555lsb,rgb555msb,rgb555alsb,rgb555amsb, + rgb565lsb,rgb565msb,rgb565alsb,rgb565amsb, + rgb888lsb,rgb888msb,rgb888alsb,rgb888amsb +}; + +/* + perform actual conversion + + If we can, try and use the optimised code versions, but as a default + fallback, and always for direct colour, use the generic/slow but complete + conversion function. +*/ +static void +rgbconvert (XImage *image, unsigned char *pixels, int rowstride, int alpha, xlib_colormap *cmap) +{ + int index = (image->byte_order == MSBFirst) | (alpha != 0) << 1; + int bank=5; /* default fallback converter */ + Visual *v = cmap->visual; + + d(printf("masks = %x:%x:%x\n", v->red_mask, v->green_mask, v->blue_mask)); + d(printf("image depth = %d, bpp = %d\n", image->depth, image->bits_per_pixel)); + + switch (v->class) { + /* I assume this is right for static & greyscale's too? */ + case StaticGray: + case GrayScale: + case StaticColor: + case PseudoColor: + switch (image->bits_per_pixel) { + case 1: + bank = 0; + break; + case 8: + bank = 1; + break; + } + break; + case TrueColor: + switch (image->depth) { + case 15: + if (v->red_mask == 0x7c00 && v->green_mask == 0x3e0 && v->blue_mask == 0x1f + && image->bits_per_pixel == 16) + bank = 2; + break; + case 16: + if (v->red_mask == 0xf800 && v->green_mask == 0x7e0 && v->blue_mask == 0x1f + && image->bits_per_pixel == 16) + bank = 3; + break; + case 24: + case 32: + if (v->red_mask == 0xff0000 && v->green_mask == 0xff00 && v->blue_mask == 0xff + && image->bits_per_pixel == 32) + bank = 4; + break; + } + break; + case DirectColor: + /* always use the slow version */ + break; + } + + d(printf("converting using conversion function in bank %d\n", bank)); + + if (bank==5) { + convert_real_slow(image, pixels, rowstride, cmap, alpha); + } else { + index |= bank << 2; + (* convert_map[index]) (image, pixels, rowstride, cmap); + } +} + +static int +xlib_window_is_viewable (Window w) +{ + XWindowAttributes wa; + + while (w != 0) { + Window parent, root, *children; + int nchildren; + + XGetWindowAttributes (gdk_pixbuf_dpy, w, &wa); + if (wa.map_state != IsViewable) + return 0; + + if (!XQueryTree (gdk_pixbuf_dpy, w, &root, + &parent, &children, &nchildren)) + return 0; + + if (nchildren > 0) + XFree (children); + + if (parent == root) + return 1; + + w = parent; + } + + return 0; +} + +static int +xlib_window_get_origin (Window w, int *x, int *y) +{ + Window child; + return XTranslateCoordinates (gdk_pixbuf_dpy, w, + RootWindow (gdk_pixbuf_dpy, + gdk_pixbuf_screen), + 0, 0, x, y, &child); +} diff --git a/ksvg/impl/libs/xrgbrender/gdk-pixbuf-xlib-private.h b/ksvg/impl/libs/xrgbrender/gdk-pixbuf-xlib-private.h new file mode 100644 index 00000000..f1113339 --- /dev/null +++ b/ksvg/impl/libs/xrgbrender/gdk-pixbuf-xlib-private.h @@ -0,0 +1,30 @@ +/* GdkPixbuf library - Xlib header file + * + * Authors: John Harper <john@dcs.warwick.ac.uk> + * + * 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; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef GDK_PIXBUF_XLIB_PRIVATE_H +#define GDK_PIXBUF_XLIB_PRIVATE_H + +#include "gdk-pixbuf-xlib.h" +#include <X11/Xlib.h> + +extern Display *gdk_pixbuf_dpy; +extern int gdk_pixbuf_screen; + +#endif diff --git a/ksvg/impl/libs/xrgbrender/gdk-pixbuf-xlib.c b/ksvg/impl/libs/xrgbrender/gdk-pixbuf-xlib.c new file mode 100644 index 00000000..8383246b --- /dev/null +++ b/ksvg/impl/libs/xrgbrender/gdk-pixbuf-xlib.c @@ -0,0 +1,46 @@ +/* GdkPixbuf library - Initialization functions + * + * Author: John Harper <john@dcs.warwick.ac.uk> + * + * 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; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include <config.h> +#include <X11/Xlib.h> +/*#include <gdk-pixbuf/gdk-pixbuf-private.h>*/ +#include "gdk-pixbuf-xlib-private.h" + +Display *gdk_pixbuf_dpy = NULL; +int gdk_pixbuf_screen = -1; + +/** + * gdk_pixbuf_xlib_init_with_depth: + * @display: X display to use. + * @screen_num: Screen number. + * @prefDepth: Preferred depth for XlibRGB. + * + * Similar to gdk_pixbuf_xlib_init(), but also lets you specify the preferred + * depth for XlibRGB if you do not want it to use the default depth it picks. + **/ +void +gdk_pixbuf_xlib_init_with_depth (Display *display, + int screen_num, int prefDepth) +{ + xlib_rgb_init_with_depth (display, ScreenOfDisplay (display, screen_num), + prefDepth); + gdk_pixbuf_dpy = display; + gdk_pixbuf_screen = screen_num; +} diff --git a/ksvg/impl/libs/xrgbrender/gdk-pixbuf-xlib.h b/ksvg/impl/libs/xrgbrender/gdk-pixbuf-xlib.h new file mode 100644 index 00000000..aa94c7c6 --- /dev/null +++ b/ksvg/impl/libs/xrgbrender/gdk-pixbuf-xlib.h @@ -0,0 +1,78 @@ +/* GdkPixbuf library - Xlib header file + * + * Authors: John Harper <john@dcs.warwick.ac.uk> + * + * 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; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef GDK_PIXBUF_XLIB_H +#define GDK_PIXBUF_XLIB_H + +/* #include <gdk-pixbuf/gdk-pixbuf.h> */ +/* #include <gdk-pixbuf-xlib/gdk-pixbuf-xlibrgb.h> */ +#include <X11/Xlib.h> + + + +/* init */ + +void gdk_pixbuf_xlib_init_with_depth (Display *display, int screen_num, + int prefDepth); + + + +/* render */ +/* +void gdk_pixbuf_xlib_render_threshold_alpha (GdkPixbuf *pixbuf, Pixmap bitmap, + int src_x, int src_y, + int dest_x, int dest_y, + int width, int height, + int alpha_threshold); + +void gdk_pixbuf_xlib_render_to_drawable (GdkPixbuf *pixbuf, + Drawable drawable, GC gc, + int src_x, int src_y, + int dest_x, int dest_y, + int width, int height, + XlibRgbDither dither, + int x_dither, int y_dither); + + +void gdk_pixbuf_xlib_render_to_drawable_alpha (GdkPixbuf *pixbuf, + Drawable drawable, + int src_x, int src_y, + int dest_x, int dest_y, + int width, int height, + GdkPixbufAlphaMode alpha_mode, + int alpha_threshold, + XlibRgbDither dither, + int x_dither, int y_dither); + +void gdk_pixbuf_xlib_render_pixmap_and_mask (GdkPixbuf *pixbuf, + Pixmap *pixmap_return, + Pixmap *mask_return, + int alpha_threshold); + + + +GdkPixbuf *gdk_pixbuf_xlib_get_from_drawable (GdkPixbuf *dest, + Drawable src, + Colormap cmap, Visual *visual, + int src_x, int src_y, + int dest_x, int dest_y, + int width, int height); +*/ +#endif /* GDK_PIXBUF_XLIB_H */ diff --git a/ksvg/impl/libs/xrgbrender/gdk-pixbuf-xlibrgb.c b/ksvg/impl/libs/xrgbrender/gdk-pixbuf-xlibrgb.c new file mode 100644 index 00000000..eb7e4cdf --- /dev/null +++ b/ksvg/impl/libs/xrgbrender/gdk-pixbuf-xlibrgb.c @@ -0,0 +1,3425 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.1 (the "MPL"); you may not use this file except in + * compliance with the MPL. You may obtain a copy of the MPL at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the MPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL + * for the specific language governing rights and limitations under the + * MPL. + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU Library General Public License (the "LGPL"), in + * which case the provisions of the LGPL are applicable instead of + * those above. If you wish to allow use of your version of this file + * only under the terms of the LGPL and not to allow others to use + * your version of this file under the MPL, indicate your decision by + * deleting the provisions above and replace them with the notice and + * other provisions required by the LGPL. If you do not delete the + * provisions above, a recipient may use your version of this file + * under either the MPL or the LGPL. + */ + +/* + * This code is derived from GdkRgb. + * For more information on GdkRgb, see http://www.levien.com/gdkrgb/ + * Raph Levien <raph@acm.org> + */ + +/* Ported by Christopher Blizzard to Xlib. With permission from the + * original authors and the copyright holders of this file, the + * contents of this file are also redistributable under the terms of + * the Mozilla Public license. For information about the Mozilla + * Public License, please see the license information at + * http://www.mozilla.org/MPL/ */ + +/* This code is copyright the following authors: + * Raph Levien <raph@acm.org> + * Manish Singh <manish@gtk.org> + * Tim Janik <timj@gtk.org> + * Peter Mattis <petm@xcf.berkeley.edu> + * Spencer Kimball <spencer@xcf.berkeley.edu> + * Josh MacDonald <jmacd@xcf.berkeley.edu> + * Christopher Blizzard <blizzard@redhat.com> + * Owen Taylor <otaylor@redhat.com> + * Shawn T. Amundson <amundson@gtk.org> +*/ + +#include <math.h> + +#if HAVE_CONFIG_H +# include <config.h> +# if STDC_HEADERS +# include <stdio.h> +# include <stdlib.h> +# include <string.h> +# endif +#else +# include <stdio.h> +# include <stdlib.h> +#endif + +#define ENABLE_GRAYSCALE + +/* include this before so that we can get endian definitions if + they are there... */ + +#include "gdk-pixbuf-xlibrgb.h" +#include "gdk-pixbuf-xlib-private.h" + +#ifndef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#endif + +#ifndef MAX +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#endif + +typedef enum { + LSB_FIRST, + MSB_FIRST +} ByteOrder; + + +typedef struct _XlibRgbInfo XlibRgbInfo; + +typedef void (*XlibRgbConvFunc) (XImage *image, + int ax, int ay, + int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, + XlibRgbCmap *cmap); + +/* Some of these fields should go, as they're not being used at all. + Globals should generally migrate into here - it's very likely that + we'll want to run more than one GdkRgbInfo context at the same time + (i.e. some but not all windows have privately installed + colormaps). */ + +struct _XlibRgbInfo +{ + Display *display; + Screen *screen; + int screen_num; + XVisualInfo *x_visual_info; + Colormap cmap; + XColor *cmap_colors; + Visual *default_visualid; + Colormap default_colormap; + + unsigned long *color_pixels; + unsigned long *gray_pixels; + unsigned long *reserved_pixels; + + unsigned long red_shift; + unsigned long red_prec; + unsigned long blue_shift; + unsigned long blue_prec; + unsigned long green_shift; + unsigned long green_prec; + + unsigned int nred_shades; + unsigned int ngreen_shades; + unsigned int nblue_shades; + unsigned int ngray_shades; + unsigned int nreserved; + + unsigned int bpp; + unsigned int cmap_alloced; + double gamma_val; + + /* Generally, the stage buffer is used to convert 32bit RGB, gray, + and indexed images into 24 bit packed RGB. */ + unsigned char *stage_buf; + + XlibRgbCmap *gray_cmap; + + Bool dith_default; + + Bool bitmap; /* set true if in 1 bit per pixel mode */ + GC own_gc; + + /* Convert functions */ + XlibRgbConvFunc conv; + XlibRgbConvFunc conv_d; + + XlibRgbConvFunc conv_32; + XlibRgbConvFunc conv_32_d; + + XlibRgbConvFunc conv_gray; + XlibRgbConvFunc conv_gray_d; + + XlibRgbConvFunc conv_indexed; + XlibRgbConvFunc conv_indexed_d; +}; + +static Bool xlib_rgb_install_cmap = FALSE; +static int xlib_rgb_min_colors = 5 * 5 * 5; +static Bool xlib_rgb_verbose = FALSE; + +#define IMAGE_WIDTH 256 +#define STAGE_ROWSTRIDE (IMAGE_WIDTH * 3) +#define IMAGE_HEIGHT 64 +#define N_IMAGES 6 + +static XlibRgbInfo *image_info = NULL; +static XImage *static_image[N_IMAGES]; +static int static_image_idx; + +static unsigned char *colorcube; +static unsigned char *colorcube_d; + +static unsigned long +xlib_get_prec_from_mask(unsigned long val) +{ + unsigned long retval = 0; + unsigned int cur_bit = 0; + /* walk through the number, incrementing the value if + the bit in question is set. */ + while (cur_bit < (sizeof(unsigned long) * 8)) { + if ((val >> cur_bit) & 0x1) { + retval++; + } + cur_bit++; + } + return retval; +} + +static unsigned long +xlib_get_shift_from_mask(unsigned long val) +{ + unsigned long cur_bit = 0; + /* walk through the number, looking for the first 1 */ + while (cur_bit < (sizeof(unsigned long) * 8)) { + if ((val >> cur_bit) & 0x1) { + return cur_bit; + } + cur_bit++; + } + return cur_bit; +} + + +static int +xlib_rgb_cmap_fail (const char *msg, Colormap cmap, unsigned long *pixels) +{ + unsigned long free_pixels[256]; + int n_free; + int i; + +#ifdef VERBOSE + printf ("%s", msg); +#endif + n_free = 0; + for (i = 0; i < 256; i++) + if (pixels[i] < 256) + free_pixels[n_free++] = pixels[i]; + + if (n_free) + XFreeColors(image_info->display, + cmap, + free_pixels, + n_free, + 0); + return 0; +} + +static void +xlib_rgb_make_colorcube (unsigned long *pixels, int nr, int ng, int nb) +{ + unsigned char rt[16], gt[16], bt[16]; + int i; + + colorcube = malloc(sizeof(unsigned char) * 4096); + memset(colorcube, 0, (sizeof(unsigned char) * 4096)); + for (i = 0; i < 16; i++) + { + rt[i] = ng * nb * ((i * 17 * (nr - 1) + 128) >> 8); + gt[i] = nb * ((i * 17 * (ng - 1) + 128) >> 8); + bt[i] = ((i * 17 * (nb - 1) + 128) >> 8); + } + + for (i = 0; i < 4096; i++) + { + colorcube[i] = pixels[rt[i >> 8] + gt[(i >> 4) & 0x0f] + bt[i & 0x0f]]; +#ifdef VERBOSE + printf ("%03x %02x %x %x %x\n", i, colorcube[i], rt[i >> 8], gt[(i >> 4) & 0x0f], bt[i & 0x0f]); +#endif + } +} + +/* this is the colorcube suitable for dithering */ +static void +xlib_rgb_make_colorcube_d (unsigned long *pixels, int nr, int ng, int nb) +{ + int r, g, b; + int i; + + colorcube_d = malloc(sizeof(unsigned char) * 512); + memset(colorcube_d, 0, (sizeof(unsigned char) * 512)); + for (i = 0; i < 512; i++) + { + r = MIN (nr - 1, i >> 6); + g = MIN (ng - 1, (i >> 3) & 7); + b = MIN (nb - 1, i & 7); + colorcube_d[i] = pixels[(r * ng + g) * nb + b]; + } +} + +/* Try installing a color cube of the specified size. + Make the colorcube and return TRUE on success */ +static int +xlib_rgb_try_colormap (int nr, int ng, int nb) +{ + int r, g, b; + int ri, gi, bi; + int r0, g0, b0; + Colormap cmap; + XVisualInfo *visual; + XColor *colors = NULL; + XColor color; + unsigned long pixels[256]; + unsigned long junk[256]; + int i; + int d2; + unsigned int colors_needed; + int idx; + int best[256]; + + if (nr * ng * nb < xlib_rgb_min_colors) + return FALSE; + + if (image_info->cmap_alloced) { + cmap = image_info->cmap; + visual = image_info->x_visual_info; + } + else { + cmap = image_info->default_colormap; + visual = image_info->x_visual_info; + } + colors_needed = nr * ng * nb; + for (i = 0; i < 256; i++) + { + best[i] = 192; + pixels[i] = 256; + } + +#ifndef GAMMA + if (!xlib_rgb_install_cmap) { + /* go out and get the colors for this colormap. */ + colors = malloc(sizeof(XColor) * visual->colormap_size); + for (i=0; i < visual->colormap_size; i++){ + colors[i].pixel = i; + } + XQueryColors (image_info->display, + cmap, + colors, visual->colormap_size); + /* find color cube colors that are already present */ + for (i = 0; i < MIN (256, visual->colormap_size); i++) + { + r = colors[i].red >> 8; + g = colors[i].green >> 8; + b = colors[i].blue >> 8; + ri = (r * (nr - 1) + 128) >> 8; + gi = (g * (ng - 1) + 128) >> 8; + bi = (b * (nb - 1) + 128) >> 8; + r0 = ri * 255 / (nr - 1); + g0 = gi * 255 / (ng - 1); + b0 = bi * 255 / (nb - 1); + idx = ((ri * nr) + gi) * nb + bi; + d2 = (r - r0) * (r - r0) + (g - g0) * (g - g0) + (b - b0) * (b - b0); + if (d2 < best[idx]) { + if (pixels[idx] < 256) + XFreeColors(image_info->display, + cmap, + pixels + idx, + 1, 0); + else + colors_needed--; + color.pixel = colors[i].pixel; + color.red = colors[i].red; + color.green = colors[i].green; + color.blue = colors[i].blue; + color.flags = 0; + if (!XAllocColor(image_info->display, cmap, &color)) + return xlib_rgb_cmap_fail ("error allocating system color\n", + cmap, pixels); + pixels[idx] = color.pixel; /* which is almost certainly i */ + best[idx] = d2; + } + } + } + +#endif + + if (colors_needed) + { + if (!XAllocColorCells(image_info->display, cmap, 0, NULL, 0, junk, colors_needed)) + { + char tmp_str[80]; + + sprintf (tmp_str, + "%d %d %d colormap failed (in XAllocColorCells)\n", + nr, ng, nb); + return xlib_rgb_cmap_fail (tmp_str, cmap, pixels); + } + XFreeColors(image_info->display, cmap, junk, (int)colors_needed, 0); + } + + for (r = 0, i = 0; r < nr; r++) + for (g = 0; g < ng; g++) + for (b = 0; b < nb; b++, i++) + { + if (pixels[i] == 256) + { + color.red = r * 65535 / (nr - 1); + color.green = g * 65535 / (ng - 1); + color.blue = b * 65535 / (nb - 1); + +#ifdef GAMMA + color.red = 65535 * pow (color.red / 65535.0, 0.5); + color.green = 65535 * pow (color.green / 65535.0, 0.5); + color.blue = 65535 * pow (color.blue / 65535.0, 0.5); +#endif + + /* This should be a raw XAllocColor call */ + if (!XAllocColor(image_info->display, cmap, &color)) + { + char tmp_str[80]; + + sprintf (tmp_str, "%d %d %d colormap failed\n", + nr, ng, nb); + return xlib_rgb_cmap_fail (tmp_str, + cmap, pixels); + } + pixels[i] = color.pixel; + } +#ifdef VERBOSE + printf ("%d: %lx\n", i, pixels[i]); +#endif + } + + image_info->nred_shades = nr; + image_info->ngreen_shades = ng; + image_info->nblue_shades = nb; + xlib_rgb_make_colorcube (pixels, nr, ng, nb); + xlib_rgb_make_colorcube_d (pixels, nr, ng, nb); + if (colors) + free(colors); + return TRUE; +} + +/* Return TRUE on success. */ +static Bool +xlib_rgb_do_colormaps (void) +{ + static const int sizes[][3] = { + /* { 6, 7, 6 }, */ + { 6, 6, 6 }, + { 6, 6, 5 }, + { 6, 6, 4 }, + { 5, 5, 5 }, + { 5, 5, 4 }, + { 4, 4, 4 }, + { 4, 4, 3 }, + { 3, 3, 3 }, + { 2, 2, 2 } + }; + static const int n_sizes = sizeof(sizes) / (3 * sizeof(int)); + int i; + + for (i = 0; i < n_sizes; i++) + if (xlib_rgb_try_colormap (sizes[i][0], sizes[i][1], sizes[i][2])) + return TRUE; + return FALSE; +} + +/* Make a 2 x 2 x 2 colorcube */ +static void +xlib_rgb_colorcube_222 (void) +{ + int i; + XColor color; + Colormap cmap; + + if (image_info->cmap_alloced) + cmap = image_info->cmap; + else + cmap = image_info->default_colormap; + + colorcube_d = malloc(sizeof(unsigned char) * 512); + + for (i = 0; i < 8; i++) + { + color.red = ((i & 4) >> 2) * 65535; + color.green = ((i & 2) >> 1) * 65535; + color.blue = (i & 1) * 65535; + XAllocColor (image_info->display, cmap, &color); + colorcube_d[((i & 4) << 4) | ((i & 2) << 2) | (i & 1)] = color.pixel; + } +} + +/** + * xlib_rgb_set_verbose: + * @verbose: %True to be verbose + * + * Enables/disables debug spew. + **/ +void +xlib_rgb_set_verbose (Bool verbose) +{ + xlib_rgb_verbose = verbose; +} + +/** + * xlib_rgb_set_install: + * @install: %True to install a colormap + * + * Sets whether we install an RGB colormap. + **/ +void +xlib_rgb_set_install (Bool install) +{ + xlib_rgb_install_cmap = install; +} + +/** + * xlib_rgb_set_min_colors: + * @min_colors: minimum colors to use + * + * Sets the minimum number of colors in the color cube. + **/ +void +xlib_rgb_set_min_colors (int min_colors) +{ + xlib_rgb_min_colors = min_colors; +} + +/* Return a "score" based on the following criteria (in hex): + + x000 is the quality - 1 is 1bpp, 2 is 4bpp, + 4 is 8bpp, + 7 is 15bpp truecolor, 8 is 16bpp truecolor, + 9 is 24bpp truecolor. + 0x00 is the speed - 1 is the normal case, + 2 means faster than normal + 00x0 gets a point for being the system visual + 000x gets a point for being pseudocolor + + A caveat: in the 8bpp modes, being the system visual seems to be + quite important. Thus, all of the 8bpp modes should be ranked at + the same speed. +*/ + +static unsigned int +xlib_rgb_score_visual (XVisualInfo *visual) +{ + unsigned int quality, speed, pseudo, sys; + static const char* visual_names[] = + { + "static gray", + "grayscale", + "static color", + "pseudo color", + "true color", + "direct color", + }; + + + quality = 0; + speed = 1; + sys = 0; + if (visual->class == TrueColor || + visual->class == DirectColor) + { + if (visual->depth == 24) + { + quality = 9; + /* Should test for MSB visual here, and set speed if so. */ + } + else if (visual->depth == 16) + quality = 8; + else if (visual->depth == 15) + quality = 7; + else if (visual->depth == 8) + quality = 4; + } + else if (visual->class == PseudoColor || + visual->class == StaticColor) + { + if (visual->depth == 8) + quality = 4; + else if (visual->depth == 4) + quality = 2; + else if (visual->depth == 1) + quality = 1; + } + else if (visual->class == StaticGray +#ifdef ENABLE_GRAYSCALE + || visual->class == GrayScale +#endif + ) + { + if (visual->depth == 8) + quality = 4; + else if (visual->depth == 4) + quality = 2; + else if (visual->depth == 1) + quality = 1; + } + + if (quality == 0) + return 0; + + sys = (visual->visualid == image_info->default_visualid->visualid); + + pseudo = (visual->class == PseudoColor || visual->class == TrueColor); + + if (xlib_rgb_verbose) + printf ("Visual 0x%x, type = %s, depth = %d, %ld:%ld:%ld%s; score=%x\n", + (int)visual->visualid, + visual_names[visual->class], + visual->depth, + visual->red_mask, + visual->green_mask, + visual->blue_mask, + sys ? " (system)" : "", + (quality << 12) | (speed << 8) | (sys << 4) | pseudo); + + return (quality << 12) | (speed << 8) | (sys << 4) | pseudo; +} + +static void +xlib_rgb_choose_visual (void) +{ + XVisualInfo *visuals; + XVisualInfo *visual; + XVisualInfo *best_visual; + XVisualInfo *final_visual; + XVisualInfo template; + int num_visuals; + unsigned int score, best_score; + int cur_visual = 1; + int i; + + template.screen = image_info->screen_num; + visuals = XGetVisualInfo(image_info->display, VisualScreenMask, + &template, &num_visuals); + + best_visual = visuals; + best_score = xlib_rgb_score_visual (best_visual); + + for (i = cur_visual; i < num_visuals; i++) + { + visual = &visuals[i]; + score = xlib_rgb_score_visual (visual); + if (score > best_score) + { + best_score = score; + best_visual = visual; + } + } + /* make a copy of the visual so that we can free + the allocated visual list above. */ + final_visual = malloc(sizeof(XVisualInfo)); + memcpy(final_visual, best_visual, sizeof(XVisualInfo)); + image_info->x_visual_info = final_visual; + XFree(visuals); + /* set up the shift and the precision for the red, green and blue. + this only applies to cool visuals like true color and direct color. */ + if (image_info->x_visual_info->class == TrueColor || + image_info->x_visual_info->class == DirectColor) { + image_info->red_shift = xlib_get_shift_from_mask(image_info->x_visual_info->red_mask); + image_info->red_prec = xlib_get_prec_from_mask(image_info->x_visual_info->red_mask); + image_info->green_shift = xlib_get_shift_from_mask(image_info->x_visual_info->green_mask); + image_info->green_prec = xlib_get_prec_from_mask(image_info->x_visual_info->green_mask); + image_info->blue_shift = xlib_get_shift_from_mask(image_info->x_visual_info->blue_mask); + image_info->blue_prec = xlib_get_prec_from_mask(image_info->x_visual_info->blue_mask); + } +} + +static void +xlib_rgb_choose_visual_for_xprint (int aDepth) +{ + XVisualInfo *visuals; + XVisualInfo *visual; + XVisualInfo *best_visual; + XVisualInfo *final_visual; + XVisualInfo template; + int num_visuals; + int cur_visual = 1; + int i; + + XWindowAttributes win_att; + Status ret_stat; + Visual *root_visual; + + ret_stat = XGetWindowAttributes(image_info->display, + RootWindow(image_info->display, image_info->screen_num), + &win_att); + root_visual = win_att.visual; + template.screen = image_info->screen_num; + visuals = XGetVisualInfo(image_info->display, VisualScreenMask, + &template, &num_visuals); + + best_visual = visuals; + if (best_visual->visual != root_visual) { + for (i = cur_visual; i < num_visuals; i++) { + visual = &visuals[i]; + if (visual->visual == root_visual) { + best_visual = visual; + break; + } + } + } + /* make a copy of the visual so that we can free + the allocated visual list above. */ + final_visual = malloc(sizeof(XVisualInfo)); + memcpy(final_visual, best_visual, sizeof(XVisualInfo)); + image_info->x_visual_info = final_visual; + XFree(visuals); + /* set up the shift and the precision for the red, green and blue. + this only applies to cool visuals like true color and direct color. */ + if (image_info->x_visual_info->class == TrueColor || + image_info->x_visual_info->class == DirectColor) { + image_info->red_shift = xlib_get_shift_from_mask(image_info->x_visual_info->red_mask); + image_info->red_prec = xlib_get_prec_from_mask(image_info->x_visual_info->red_mask); + image_info->green_shift = xlib_get_shift_from_mask(image_info->x_visual_info->green_mask); + image_info->green_prec = xlib_get_prec_from_mask(image_info->x_visual_info->green_mask); + image_info->blue_shift = xlib_get_shift_from_mask(image_info->x_visual_info->blue_mask); + image_info->blue_prec = xlib_get_prec_from_mask(image_info->x_visual_info->blue_mask); + } +} + +static void xlib_rgb_select_conv (XImage *image, ByteOrder byte_order); + +static void +xlib_rgb_set_gray_cmap (Colormap cmap) +{ + int i; + XColor color; + int status; + unsigned long pixels[256]; + int r, g, b, gray; + + for (i = 0; i < 256; i++) + { + color.pixel = i; + color.red = i * 257; + color.green = i * 257; + color.blue = i * 257; + status = XAllocColor(image_info->display, cmap, &color); + pixels[i] = color.pixel; +#ifdef VERBOSE + printf ("allocating pixel %d, %x %x %x, result %d\n", + color.pixel, color.red, color.green, color.blue, status); +#endif + } + + /* Now, we make fake colorcubes - we ultimately just use the pseudocolor + methods. */ + + colorcube = malloc(sizeof(unsigned char) * 4096); + + for (i = 0; i < 4096; i++) + { + r = (i >> 4) & 0xf0; + r = r | r >> 4; + g = i & 0xf0; + g = g | g >> 4; + b = (i << 4 & 0xf0); + b = b | b >> 4; + gray = (g + ((r + b) >> 1)) >> 1; + colorcube[i] = pixels[gray]; + } +} + +/** + * xlib_rgb_init_with_depth: + * @display: X display to use. + * @screen: Screen to use. + * @prefDepth: Visual depth to use for color substitution tables. This must + * be one of the supported visual depths in the specified @display. + * + * Initializes the XlibRGB machinery with a particular depth you specify, + * instead of automatically picking the best depth in the display. This + * function or xlib_rgb_init() must be called before using any of the other + * functions in XlibRGB. + **/ +void +xlib_rgb_init_with_depth (Display *display, Screen *screen, int prefDepth) +{ + int i; + static const int byte_order[1] = { 1 }; + + static int initialized = 0; + + if (initialized) + { + return; + } + + initialized = 1; + +#if X_BYTE_ORDER == X_BIG_ENDIAN + if (((char *)byte_order)[0] == 1) { + printf ("xlib_rgb_init: compiled for big endian, but this is a little endian machine.\n\n"); + exit(1); + } +#else + if (((char *)byte_order)[0] != 1) { + printf ("xlib_rgb_init: compiled for little endian, but this is a big endian machine.\n\n"); + exit(1); + } +#endif + + if (image_info == NULL) + { + image_info = malloc(sizeof(XlibRgbInfo)); + memset(image_info, 0, sizeof(XlibRgbInfo)); + + image_info->display = display; + image_info->screen = screen; + image_info->screen_num = XScreenNumberOfScreen(screen); + image_info->x_visual_info = NULL; + image_info->cmap = 0; + image_info->default_visualid = DefaultVisual(display, image_info->screen_num); + image_info->default_colormap = DefaultColormap(display, image_info->screen_num); + + image_info->color_pixels = NULL; + image_info->gray_pixels = NULL; + image_info->reserved_pixels = NULL; + + image_info->nred_shades = 6; + image_info->ngreen_shades = 6; + image_info->nblue_shades = 4; + image_info->ngray_shades = 24; + image_info->nreserved = 0; + + image_info->bpp = 0; + image_info->cmap_alloced = FALSE; + image_info->gamma_val = 1.0; + + image_info->stage_buf = NULL; + + image_info->own_gc = 0; + + image_info->red_shift = 0; + image_info->red_prec = 0; + image_info->green_shift = 0; + image_info->green_prec = 0; + image_info->blue_shift = 0; + image_info->blue_prec = 0; + + if (prefDepth != -1) + xlib_rgb_choose_visual_for_xprint (prefDepth); + else + xlib_rgb_choose_visual (); + + if ((image_info->x_visual_info->class == PseudoColor || + image_info->x_visual_info->class == StaticColor) && + image_info->x_visual_info->depth < 8 && + image_info->x_visual_info->depth >= 3) + { + image_info->cmap = image_info->default_colormap; + xlib_rgb_colorcube_222 (); + } + else if (image_info->x_visual_info->class == PseudoColor) + { + if (xlib_rgb_install_cmap || + image_info->x_visual_info->visualid != image_info->default_visualid->visualid) + { + image_info->cmap = XCreateColormap(image_info->display, + RootWindow(image_info->display, image_info->screen_num), + image_info->x_visual_info->visual, + AllocNone); + image_info->cmap_alloced = TRUE; + } + if (!xlib_rgb_do_colormaps ()) + { + image_info->cmap = XCreateColormap(image_info->display, + RootWindow(image_info->display, image_info->screen_num), + image_info->x_visual_info->visual, + AllocNone); + image_info->cmap_alloced = TRUE; + xlib_rgb_do_colormaps (); + } + if (xlib_rgb_verbose) + printf ("color cube: %d x %d x %d\n", + image_info->nred_shades, + image_info->ngreen_shades, + image_info->nblue_shades); + + if (!image_info->cmap_alloced) + image_info->cmap = image_info->default_colormap; + } +#ifdef ENABLE_GRAYSCALE + else if (image_info->x_visual_info->class == GrayScale) + { + image_info->cmap = XCreateColormap(image_info->display, + RootWindow(image_info->display, image_info->screen_num), + image_info->x_visual_info->visual, + AllocNone); + xlib_rgb_set_gray_cmap (image_info->cmap); + image_info->cmap_alloced = TRUE; + } +#endif + else + { + /* Always install colormap in direct color. */ + if (image_info->x_visual_info->class != DirectColor && + image_info->x_visual_info->visualid == image_info->default_visualid->visualid) + image_info->cmap = image_info->default_colormap; + else + { + image_info->cmap = XCreateColormap(image_info->display, + RootWindow(image_info->display, image_info->screen_num), + image_info->x_visual_info->visual, + AllocNone); + image_info->cmap_alloced = TRUE; + } + } + + image_info->bitmap = (image_info->x_visual_info->depth == 1); + + for (i = 0; i < N_IMAGES; i++) { + if (image_info->bitmap) { + /* Use malloc() instead of g_malloc since X will free() this mem */ + static_image[i] = XCreateImage(image_info->display, + image_info->x_visual_info->visual, + 1, + XYBitmap, + 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, + 8, + 0); + static_image[i]->data = malloc(IMAGE_WIDTH * IMAGE_HEIGHT >> 3); + static_image[i]->bitmap_bit_order = MSBFirst; + static_image[i]->byte_order = MSBFirst; + } + else { + static_image[i] = XCreateImage(image_info->display, + image_info->x_visual_info->visual, + (unsigned int)image_info->x_visual_info->depth, + ZPixmap, + 0, 0, + IMAGE_WIDTH, + IMAGE_HEIGHT, + 32, 0); + /* remove this when we are using shared memory.. */ + static_image[i]->data = malloc((size_t)IMAGE_WIDTH * IMAGE_HEIGHT * image_info->x_visual_info->depth); + static_image[i]->bitmap_bit_order = MSBFirst; + static_image[i]->byte_order = MSBFirst; + } + } + /* ok, so apparently, image_info->bpp is actually + BYTES per pixel. What fun! */ + switch (static_image[0]->bits_per_pixel) { + case 1: + case 8: + image_info->bpp = 1; + break; + case 16: + image_info->bpp = 2; + break; + case 24: + image_info->bpp = 3; + break; + case 32: + image_info->bpp = 4; + break; + } + xlib_rgb_select_conv (static_image[0], MSB_FIRST); + } +} + + + +#if X_BYTE_ORDER == X_LITTLE_ENDIAN +#define HAIRY_CONVERT_8 +#endif + +#ifdef HAIRY_CONVERT_8 +static void +xlib_rgb_convert_8 (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int x, y; + int bpl; + unsigned char *obuf, *obptr; + unsigned char *bptr, *bp2; + int r, g, b; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax; + for (y = 0; y < height; y++) + { + bp2 = bptr; + obptr = obuf; + if (((unsigned long)obuf | (unsigned long) bp2) & 3) + { + for (x = 0; x < width; x++) + { + r = *bp2++; + g = *bp2++; + b = *bp2++; + obptr[0] = colorcube[((r & 0xf0) << 4) | + (g & 0xf0) | + (b >> 4)]; + obptr++; + } + } + else + { + for (x = 0; x < width - 3; x += 4) + { + unsigned int r1b0g0r0; + unsigned int g2r2b1g1; + unsigned int b3g3r3b2; + + r1b0g0r0 = ((unsigned int *)bp2)[0]; + g2r2b1g1 = ((unsigned int *)bp2)[1]; + b3g3r3b2 = ((unsigned int *)bp2)[2]; + ((unsigned int *)obptr)[0] = + colorcube[((r1b0g0r0 & 0xf0) << 4) | + ((r1b0g0r0 & 0xf000) >> 8) | + ((r1b0g0r0 & 0xf00000) >> 20)] | + (colorcube[((r1b0g0r0 & 0xf0000000) >> 20) | + (g2r2b1g1 & 0xf0) | + ((g2r2b1g1 & 0xf000) >> 12)] << 8) | + (colorcube[((g2r2b1g1 & 0xf00000) >> 12) | + ((g2r2b1g1 & 0xf0000000) >> 24) | + ((b3g3r3b2 & 0xf0) >> 4)] << 16) | + (colorcube[((b3g3r3b2 & 0xf000) >> 4) | + ((b3g3r3b2 & 0xf00000) >> 16) | + (b3g3r3b2 >> 28)] << 24); + bp2 += 12; + obptr += 4; + } + for (; x < width; x++) + { + r = *bp2++; + g = *bp2++; + b = *bp2++; + obptr[0] = colorcube[((r & 0xf0) << 4) | + (g & 0xf0) | + (b >> 4)]; + obptr++; + } + } + bptr += rowstride; + obuf += bpl; + } +} +#else +static void +xlib_rgb_convert_8 (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int x, y; + int bpl; + unsigned char *obuf, *obptr; + unsigned char *bptr, *bp2; + int r, g, b; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax; + for (y = 0; y < height; y++) + { + bp2 = bptr; + obptr = obuf; + for (x = 0; x < width; x++) + { + r = *bp2++; + g = *bp2++; + b = *bp2++; + obptr[0] = colorcube[((r & 0xf0) << 4) | + (g & 0xf0) | + (b >> 4)]; + obptr++; + } + bptr += rowstride; + obuf += bpl; + } +} +#endif + +#if 1 + +/* This dither table was generated by Raph Levien using patented + technology (US Patent 5,276,535). The dither table itself is in the + public domain. */ + +#define DM_WIDTH 128 +#define DM_WIDTH_SHIFT 7 +#define DM_HEIGHT 128 +static const unsigned char DM[128][128] = +{ + { 0, 41, 23, 5, 17, 39, 7, 15, 62, 23, 40, 51, 31, 47, 9, 32, 52, 27, 57, 25, 6, 61, 27, 52, 37, 7, 40, 63, 18, 36, 10, 42, 25, 62, 45, 34, 20, 42, 37, 14, 35, 29, 50, 10, 61, 2, 40, 8, 37, 12, 58, 22, 5, 41, 10, 39, 0, 60, 11, 46, 2, 55, 38, 17, 36, 59, 13, 54, 37, 56, 8, 29, 16, 13, 63, 22, 41, 55, 7, 20, 49, 14, 23, 55, 37, 23, 19, 36, 15, 49, 23, 63, 30, 14, 38, 27, 53, 13, 22, 41, 19, 31, 7, 19, 50, 30, 49, 16, 3, 32, 56, 40, 29, 34, 8, 48, 19, 45, 4, 51, 12, 46, 35, 49, 16, 42, 12, 62 }, + { 30, 57, 36, 54, 47, 34, 52, 27, 43, 4, 28, 7, 17, 36, 62, 13, 44, 7, 18, 48, 33, 21, 44, 14, 30, 47, 12, 33, 5, 55, 31, 58, 13, 30, 4, 17, 52, 10, 60, 26, 46, 0, 39, 27, 42, 22, 47, 25, 60, 32, 9, 38, 48, 17, 59, 30, 49, 18, 34, 25, 51, 19, 5, 48, 21, 8, 28, 46, 1, 32, 41, 19, 54, 47, 37, 18, 28, 11, 44, 30, 39, 56, 2, 33, 8, 42, 61, 28, 58, 8, 46, 9, 41, 4, 58, 7, 21, 48, 59, 10, 52, 14, 42, 57, 12, 25, 7, 53, 42, 24, 11, 50, 17, 59, 42, 2, 36, 60, 32, 17, 63, 29, 21, 7, 59, 32, 24, 39 }, + { 22, 8, 16, 32, 3, 25, 13, 57, 18, 45, 58, 39, 55, 20, 5, 42, 23, 34, 63, 1, 51, 10, 58, 4, 60, 23, 53, 27, 44, 21, 3, 48, 8, 50, 43, 54, 27, 32, 5, 55, 21, 58, 12, 53, 6, 36, 14, 50, 17, 29, 53, 15, 24, 52, 7, 36, 13, 42, 4, 53, 9, 35, 61, 26, 56, 32, 49, 15, 62, 23, 6, 60, 2, 31, 4, 48, 58, 38, 15, 61, 5, 25, 47, 28, 50, 15, 7, 40, 3, 32, 33, 52, 25, 50, 35, 42, 61, 3, 28, 36, 23, 63, 4, 33, 46, 62, 36, 23, 60, 6, 54, 28, 4, 37, 23, 55, 25, 8, 42, 54, 14, 6, 56, 38, 19, 52, 4, 46 }, + { 48, 53, 43, 12, 45, 63, 30, 37, 9, 34, 21, 1, 25, 47, 29, 58, 3, 54, 15, 39, 29, 17, 38, 35, 20, 43, 1, 49, 15, 59, 29, 39, 22, 35, 16, 23, 1, 47, 39, 18, 8, 44, 25, 31, 57, 19, 63, 4, 45, 3, 42, 61, 1, 31, 45, 20, 57, 29, 62, 21, 32, 41, 14, 44, 3, 39, 5, 34, 10, 43, 51, 35, 23, 52, 40, 10, 21, 1, 53, 18, 51, 43, 12, 62, 18, 54, 26, 51, 20, 57, 14, 1, 62, 16, 11, 18, 32, 39, 17, 44, 1, 48, 26, 37, 18, 2, 51, 14, 28, 45, 35, 18, 57, 13, 47, 11, 51, 20, 2, 39, 31, 47, 25, 1, 50, 11, 60, 7 }, + { 18, 28, 1, 56, 21, 10, 51, 2, 46, 54, 14, 61, 11, 50, 13, 38, 19, 31, 45, 9, 55, 24, 47, 5, 54, 9, 62, 11, 35, 8, 51, 14, 57, 6, 63, 40, 58, 14, 51, 28, 62, 34, 15, 48, 1, 41, 30, 35, 55, 21, 34, 11, 49, 37, 8, 52, 4, 23, 15, 43, 1, 58, 11, 23, 53, 16, 55, 26, 58, 18, 27, 12, 45, 14, 25, 63, 42, 33, 27, 35, 9, 31, 21, 38, 1, 44, 34, 12, 48, 38, 21, 44, 29, 47, 26, 53, 1, 46, 54, 8, 59, 29, 11, 55, 22, 41, 33, 20, 39, 1, 48, 9, 44, 32, 5, 62, 29, 44, 57, 23, 10, 58, 34, 43, 15, 37, 26, 33 }, + { 51, 38, 59, 24, 35, 42, 19, 60, 5, 32, 41, 26, 43, 33, 7, 53, 48, 11, 59, 23, 42, 2, 61, 30, 16, 40, 32, 24, 56, 41, 19, 33, 37, 26, 47, 9, 31, 22, 2, 45, 9, 54, 4, 37, 21, 52, 11, 23, 7, 57, 16, 25, 55, 18, 63, 27, 46, 39, 56, 10, 50, 37, 29, 47, 19, 63, 24, 9, 46, 2, 39, 60, 9, 57, 30, 7, 49, 11, 59, 3, 45, 57, 5, 60, 29, 22, 5, 60, 30, 9, 59, 18, 40, 6, 57, 36, 30, 12, 24, 34, 15, 40, 52, 6, 49, 9, 58, 4, 63, 12, 26, 61, 22, 53, 38, 16, 35, 14, 28, 50, 42, 17, 5, 28, 62, 20, 54, 12 }, + { 26, 6, 31, 15, 49, 6, 38, 27, 22, 49, 16, 56, 2, 62, 30, 21, 0, 36, 28, 6, 49, 32, 13, 52, 26, 50, 19, 46, 3, 26, 62, 0, 53, 12, 29, 3, 53, 41, 60, 24, 38, 13, 58, 16, 43, 9, 59, 39, 46, 28, 44, 40, 2, 33, 13, 41, 16, 6, 47, 31, 26, 17, 57, 6, 38, 0, 42, 36, 29, 52, 20, 31, 48, 0, 34, 56, 20, 36, 23, 54, 14, 41, 24, 37, 10, 55, 46, 25, 16, 45, 36, 4, 55, 23, 15, 8, 50, 62, 5, 56, 44, 20, 13, 28, 59, 31, 24, 47, 31, 52, 37, 17, 40, 0, 26, 49, 3, 60, 7, 33, 0, 61, 53, 40, 8, 45, 2, 41 }, + { 16, 63, 43, 4, 61, 24, 56, 13, 53, 8, 36, 12, 24, 41, 16, 46, 60, 26, 52, 39, 14, 57, 21, 37, 0, 45, 7, 59, 38, 17, 43, 10, 45, 20, 61, 43, 19, 11, 33, 17, 50, 32, 23, 61, 28, 49, 26, 0, 18, 51, 5, 60, 22, 58, 29, 0, 59, 34, 19, 62, 3, 52, 7, 44, 30, 59, 13, 50, 15, 62, 7, 17, 38, 22, 44, 15, 40, 4, 47, 28, 33, 17, 49, 16, 51, 40, 10, 56, 0, 53, 13, 49, 28, 38, 60, 21, 43, 19, 37, 27, 3, 51, 34, 39, 0, 45, 15, 43, 10, 21, 3, 55, 8, 33, 59, 10, 41, 18, 52, 24, 46, 20, 30, 13, 58, 22, 36, 57 }, + { 50, 34, 11, 47, 29, 17, 44, 0, 33, 63, 28, 46, 52, 5, 57, 10, 42, 18, 4, 63, 20, 8, 44, 10, 56, 34, 14, 29, 5, 54, 23, 59, 32, 49, 7, 34, 49, 27, 56, 0, 42, 7, 46, 3, 40, 6, 54, 32, 62, 13, 36, 10, 47, 8, 35, 49, 24, 51, 12, 40, 22, 35, 60, 12, 22, 51, 33, 4, 40, 25, 43, 55, 5, 54, 12, 61, 26, 51, 8, 62, 0, 53, 7, 63, 2, 32, 19, 34, 42, 24, 31, 63, 2, 10, 45, 33, 0, 48, 9, 61, 22, 47, 8, 62, 18, 56, 7, 54, 27, 57, 46, 30, 50, 19, 45, 30, 56, 36, 22, 47, 11, 38, 3, 51, 32, 48, 18, 9 }, + { 0, 21, 40, 19, 52, 9, 37, 48, 20, 40, 3, 18, 27, 38, 35, 22, 31, 56, 13, 35, 46, 28, 60, 40, 27, 18, 61, 50, 41, 30, 7, 36, 2, 25, 16, 57, 5, 15, 47, 29, 55, 19, 30, 52, 15, 34, 20, 12, 43, 30, 20, 54, 25, 44, 53, 12, 38, 5, 55, 27, 48, 15, 33, 27, 45, 8, 19, 28, 56, 11, 33, 49, 18, 36, 29, 2, 45, 16, 39, 19, 31, 43, 27, 35, 20, 52, 26, 6, 61, 11, 41, 17, 29, 51, 20, 56, 25, 32, 41, 17, 53, 31, 25, 14, 42, 23, 35, 16, 38, 6, 34, 12, 15, 62, 6, 21, 13, 1, 63, 9, 55, 27, 43, 25, 14, 4, 31, 55 }, + { 44, 29, 61, 2, 35, 58, 26, 15, 60, 10, 51, 59, 14, 55, 8, 50, 2, 44, 25, 51, 1, 33, 16, 4, 48, 36, 2, 21, 12, 57, 48, 13, 51, 55, 40, 28, 37, 62, 8, 39, 12, 63, 36, 10, 59, 24, 56, 47, 9, 50, 41, 1, 32, 17, 6, 21, 61, 30, 9, 43, 1, 54, 41, 2, 54, 37, 48, 61, 1, 46, 21, 3, 58, 24, 50, 32, 60, 10, 57, 25, 46, 12, 59, 4, 45, 13, 57, 47, 27, 39, 5, 58, 47, 14, 35, 4, 52, 13, 60, 6, 36, 10, 45, 55, 4, 50, 29, 2, 61, 50, 25, 58, 44, 24, 36, 42, 54, 28, 40, 32, 16, 56, 6, 62, 46, 39, 60, 23 }, + { 7, 48, 14, 54, 23, 40, 4, 45, 30, 22, 42, 32, 1, 44, 20, 29, 58, 8, 37, 19, 41, 54, 24, 58, 9, 53, 25, 46, 34, 16, 23, 38, 27, 11, 18, 1, 52, 21, 35, 22, 48, 5, 25, 45, 18, 38, 2, 27, 35, 4, 57, 15, 62, 39, 57, 28, 42, 16, 36, 60, 24, 18, 10, 63, 20, 5, 16, 23, 37, 14, 59, 27, 41, 8, 13, 42, 21, 35, 6, 50, 3, 38, 15, 48, 30, 39, 17, 3, 49, 14, 53, 33, 24, 7, 61, 44, 11, 39, 23, 49, 19, 58, 1, 32, 36, 12, 60, 41, 20, 13, 41, 4, 39, 1, 48, 8, 18, 51, 14, 44, 5, 37, 21, 34, 1, 26, 10, 37 }, + { 53, 36, 27, 9, 50, 12, 32, 55, 2, 57, 7, 17, 48, 34, 63, 15, 40, 26, 62, 11, 49, 6, 31, 39, 22, 42, 6, 63, 1, 39, 60, 4, 42, 61, 32, 45, 24, 44, 2, 60, 16, 41, 53, 1, 33, 61, 49, 17, 63, 23, 45, 26, 33, 3, 23, 46, 2, 50, 20, 4, 45, 34, 49, 30, 39, 58, 44, 31, 53, 34, 6, 52, 30, 47, 63, 1, 53, 22, 42, 31, 58, 23, 54, 22, 61, 8, 36, 59, 22, 35, 21, 1, 55, 40, 27, 16, 30, 54, 2, 29, 43, 16, 39, 63, 21, 46, 26, 10, 48, 32, 19, 53, 30, 56, 26, 60, 33, 4, 61, 23, 49, 59, 15, 53, 19, 58, 42, 16 }, + { 20, 5, 59, 46, 25, 62, 7, 19, 43, 25, 37, 61, 11, 24, 4, 54, 12, 52, 3, 32, 17, 61, 12, 47, 15, 55, 18, 31, 53, 28, 9, 50, 21, 6, 55, 9, 58, 14, 54, 26, 33, 7, 31, 58, 13, 21, 8, 42, 29, 6, 37, 11, 48, 52, 14, 60, 11, 39, 56, 32, 14, 58, 7, 26, 17, 4, 42, 8, 11, 47, 19, 38, 10, 17, 26, 37, 9, 55, 28, 13, 18, 40, 6, 33, 1, 43, 25, 11, 51, 7, 62, 43, 18, 37, 3, 57, 45, 9, 38, 58, 5, 52, 27, 7, 17, 53, 5, 57, 37, 2, 63, 9, 22, 15, 11, 38, 25, 45, 35, 0, 28, 10, 41, 30, 50, 8, 31, 57 }, + { 49, 33, 16, 38, 1, 42, 51, 34, 53, 14, 28, 49, 30, 56, 36, 23, 43, 20, 38, 56, 22, 45, 28, 0, 62, 35, 26, 44, 11, 19, 52, 35, 44, 15, 30, 38, 10, 31, 40, 4, 46, 50, 20, 40, 27, 44, 51, 14, 56, 53, 19, 59, 7, 29, 41, 19, 35, 25, 8, 52, 22, 44, 13, 53, 50, 32, 61, 24, 56, 25, 63, 0, 45, 57, 33, 59, 16, 46, 4, 62, 50, 11, 60, 37, 52, 19, 55, 29, 37, 46, 13, 26, 48, 10, 50, 34, 21, 63, 26, 13, 42, 33, 22, 55, 35, 28, 43, 15, 24, 51, 27, 34, 46, 49, 58, 3, 52, 9, 57, 19, 48, 55, 3, 35, 12, 45, 24, 3 }, + { 41, 11, 56, 28, 18, 31, 22, 10, 37, 6, 47, 13, 3, 41, 9, 46, 0, 48, 29, 6, 34, 10, 55, 37, 20, 8, 49, 3, 41, 59, 14, 25, 0, 63, 19, 47, 27, 51, 17, 57, 23, 10, 61, 6, 54, 3, 38, 31, 0, 22, 34, 43, 20, 55, 31, 0, 49, 63, 29, 38, 3, 62, 28, 40, 0, 22, 14, 35, 2, 48, 15, 43, 23, 14, 3, 29, 49, 20, 39, 34, 0, 44, 29, 9, 15, 47, 5, 42, 0, 31, 58, 5, 31, 61, 23, 15, 0, 47, 19, 50, 24, 3, 59, 11, 44, 0, 31, 59, 6, 42, 17, 60, 0, 39, 20, 31, 43, 17, 29, 40, 12, 25, 60, 22, 52, 15, 63, 29 }, + { 20, 52, 8, 44, 62, 4, 59, 49, 17, 63, 21, 39, 60, 18, 52, 27, 33, 59, 14, 51, 59, 43, 24, 5, 51, 30, 57, 17, 32, 5, 37, 56, 48, 34, 42, 3, 60, 5, 36, 13, 43, 37, 18, 34, 25, 12, 59, 24, 47, 36, 11, 50, 3, 38, 9, 58, 16, 5, 43, 18, 47, 10, 37, 18, 59, 46, 29, 52, 40, 12, 34, 28, 56, 36, 53, 7, 43, 8, 24, 52, 26, 17, 56, 43, 24, 32, 63, 20, 57, 16, 22, 52, 36, 8, 41, 56, 29, 32, 54, 7, 35, 57, 14, 48, 20, 62, 13, 39, 53, 29, 8, 45, 13, 29, 7, 61, 14, 54, 6, 63, 38, 32, 18, 43, 2, 39, 6, 47 }, + { 0, 58, 23, 35, 13, 46, 12, 39, 0, 31, 55, 24, 5, 35, 15, 61, 17, 5, 39, 25, 18, 2, 50, 33, 41, 13, 39, 23, 62, 46, 29, 12, 22, 8, 56, 25, 20, 49, 32, 62, 0, 56, 11, 46, 63, 42, 9, 16, 55, 5, 60, 15, 62, 26, 45, 21, 36, 51, 13, 57, 31, 24, 55, 6, 35, 9, 57, 5, 20, 60, 7, 51, 5, 19, 40, 25, 61, 32, 56, 12, 36, 48, 21, 2, 58, 12, 39, 28, 9, 50, 40, 12, 44, 18, 25, 49, 6, 38, 11, 62, 18, 46, 30, 9, 40, 25, 49, 19, 10, 36, 55, 22, 33, 52, 41, 18, 37, 27, 49, 21, 2, 46, 7, 53, 33, 61, 27, 35 }, + { 41, 31, 5, 39, 51, 26, 33, 57, 27, 41, 9, 44, 54, 29, 48, 7, 44, 36, 57, 10, 31, 63, 16, 45, 11, 60, 1, 47, 7, 20, 43, 3, 58, 36, 13, 52, 39, 7, 15, 28, 22, 48, 30, 21, 1, 29, 49, 44, 27, 17, 40, 30, 24, 42, 12, 53, 33, 7, 47, 20, 1, 42, 11, 49, 25, 43, 17, 32, 45, 27, 41, 21, 31, 62, 11, 49, 2, 15, 42, 5, 63, 7, 41, 27, 49, 6, 54, 23, 46, 34, 2, 28, 54, 3, 59, 12, 46, 17, 42, 28, 40, 1, 37, 51, 5, 55, 2, 34, 47, 16, 3, 62, 47, 5, 23, 56, 1, 44, 12, 34, 51, 16, 57, 11, 25, 17, 54, 13 }, + { 60, 26, 55, 18, 3, 60, 20, 6, 52, 15, 50, 19, 32, 11, 23, 53, 26, 21, 1, 47, 42, 27, 8, 58, 21, 27, 53, 36, 26, 54, 31, 50, 17, 30, 45, 1, 29, 59, 44, 53, 41, 4, 35, 58, 51, 19, 32, 4, 52, 34, 48, 8, 51, 5, 56, 2, 25, 61, 27, 38, 54, 27, 62, 21, 51, 1, 39, 62, 10, 50, 1, 58, 13, 47, 38, 18, 35, 54, 22, 51, 30, 19, 59, 34, 14, 32, 44, 4, 60, 15, 52, 62, 20, 43, 30, 35, 21, 60, 4, 52, 12, 24, 61, 18, 30, 42, 23, 61, 25, 50, 27, 38, 11, 59, 12, 35, 50, 30, 59, 24, 8, 42, 28, 37, 48, 9, 44, 21 }, + { 10, 47, 15, 50, 30, 43, 8, 45, 29, 2, 36, 59, 1, 58, 41, 3, 63, 31, 54, 20, 13, 55, 35, 38, 4, 44, 15, 9, 61, 2, 14, 38, 61, 10, 23, 54, 18, 12, 24, 2, 14, 55, 16, 8, 38, 14, 41, 60, 10, 23, 1, 58, 32, 17, 28, 37, 41, 15, 3, 60, 15, 33, 4, 36, 16, 59, 28, 14, 23, 55, 37, 18, 44, 28, 2, 57, 30, 10, 27, 46, 14, 38, 3, 53, 21, 61, 17, 35, 10, 41, 26, 7, 33, 9, 57, 1, 53, 37, 26, 20, 56, 48, 9, 33, 58, 16, 37, 7, 45, 1, 57, 15, 32, 26, 42, 23, 7, 20, 4, 54, 31, 62, 22, 1, 59, 30, 4, 51 }, + { 36, 2, 38, 11, 24, 36, 54, 22, 62, 47, 25, 8, 28, 45, 16, 38, 12, 43, 9, 37, 49, 3, 23, 52, 18, 30, 50, 33, 19, 42, 49, 26, 6, 40, 47, 35, 63, 38, 50, 33, 60, 26, 36, 47, 24, 57, 6, 26, 39, 63, 19, 44, 14, 46, 61, 9, 50, 30, 45, 23, 10, 50, 44, 8, 31, 54, 6, 46, 36, 4, 30, 54, 8, 52, 22, 41, 4, 60, 40, 0, 58, 24, 45, 10, 37, 1, 48, 30, 56, 17, 38, 48, 24, 47, 19, 39, 14, 8, 45, 32, 2, 34, 27, 44, 4, 52, 11, 56, 31, 21, 40, 19, 44, 51, 2, 63, 46, 58, 36, 43, 14, 5, 50, 38, 14, 56, 40, 23 }, + { 61, 46, 32, 63, 54, 1, 14, 34, 12, 40, 18, 49, 37, 10, 61, 30, 51, 24, 60, 7, 29, 40, 62, 11, 46, 58, 6, 56, 24, 10, 34, 52, 21, 59, 16, 3, 27, 5, 20, 46, 9, 40, 7, 62, 2, 30, 53, 15, 48, 10, 28, 35, 54, 6, 21, 34, 18, 55, 7, 40, 57, 19, 26, 60, 41, 13, 24, 51, 19, 61, 9, 25, 34, 15, 63, 11, 45, 17, 20, 47, 33, 8, 31, 62, 43, 26, 53, 7, 24, 59, 0, 13, 55, 4, 62, 27, 51, 31, 63, 15, 58, 7, 54, 14, 46, 22, 28, 43, 12, 63, 8, 54, 5, 17, 39, 33, 15, 10, 27, 17, 47, 34, 19, 45, 27, 12, 33, 17 }, + { 5, 28, 21, 7, 17, 48, 42, 58, 23, 4, 63, 14, 55, 21, 34, 5, 19, 0, 45, 17, 52, 15, 25, 32, 0, 22, 40, 13, 45, 62, 18, 0, 43, 11, 33, 55, 30, 42, 57, 19, 51, 31, 22, 43, 18, 45, 34, 0, 43, 31, 56, 3, 23, 40, 59, 0, 44, 13, 48, 35, 2, 32, 46, 0, 21, 48, 35, 3, 40, 32, 43, 59, 0, 48, 33, 26, 53, 36, 55, 12, 51, 16, 55, 5, 18, 29, 11, 39, 51, 19, 45, 31, 42, 21, 35, 6, 22, 47, 10, 38, 23, 50, 20, 36, 0, 60, 38, 4, 50, 35, 48, 34, 24, 57, 9, 53, 28, 48, 61, 0, 56, 24, 53, 3, 63, 6, 42, 57 }, + { 13, 53, 45, 40, 58, 27, 6, 16, 38, 51, 33, 30, 43, 2, 47, 56, 40, 50, 33, 57, 27, 5, 47, 42, 60, 36, 16, 54, 28, 4, 37, 57, 28, 51, 22, 8, 45, 14, 6, 39, 0, 54, 11, 59, 28, 12, 50, 21, 61, 13, 19, 38, 49, 11, 25, 37, 58, 29, 22, 63, 14, 56, 12, 53, 30, 63, 9, 57, 26, 12, 47, 16, 23, 39, 50, 6, 31, 2, 25, 6, 28, 41, 36, 22, 50, 57, 42, 3, 34, 8, 28, 61, 11, 50, 16, 54, 41, 0, 55, 43, 5, 29, 41, 63, 25, 16, 53, 18, 26, 10, 21, 0, 61, 30, 41, 22, 3, 38, 20, 39, 29, 8, 41, 16, 36, 52, 22, 19 }, + { 55, 34, 0, 25, 10, 32, 56, 44, 28, 0, 57, 7, 26, 53, 23, 8, 13, 35, 22, 12, 36, 60, 20, 8, 14, 29, 48, 2, 41, 49, 23, 13, 39, 7, 48, 58, 25, 53, 34, 62, 28, 16, 48, 4, 37, 56, 27, 5, 36, 52, 46, 7, 62, 33, 52, 11, 17, 53, 5, 28, 41, 24, 38, 17, 5, 39, 20, 45, 15, 56, 5, 38, 60, 8, 14, 57, 21, 48, 62, 39, 59, 13, 1, 60, 9, 32, 16, 63, 44, 25, 52, 15, 36, 2, 60, 29, 12, 33, 25, 17, 59, 45, 13, 8, 49, 32, 6, 40, 59, 29, 45, 37, 13, 47, 6, 55, 30, 45, 9, 52, 13, 59, 25, 47, 32, 1, 49, 30 }, + { 9, 39, 14, 61, 49, 37, 3, 20, 50, 13, 41, 19, 46, 17, 38, 59, 28, 62, 4, 44, 54, 1, 34, 51, 55, 7, 63, 32, 21, 8, 56, 31, 62, 19, 36, 1, 41, 17, 24, 12, 42, 35, 25, 52, 20, 8, 44, 59, 25, 2, 22, 42, 16, 29, 4, 46, 20, 36, 43, 9, 51, 8, 49, 26, 58, 33, 54, 1, 37, 29, 52, 20, 27, 45, 19, 35, 42, 16, 10, 32, 20, 49, 46, 27, 40, 4, 47, 22, 13, 55, 4, 47, 26, 44, 23, 40, 58, 19, 48, 13, 31, 2, 57, 34, 42, 19, 61, 32, 14, 55, 5, 51, 26, 19, 58, 16, 49, 14, 62, 5, 33, 44, 21, 7, 60, 26, 11, 41 }, + { 62, 24, 47, 29, 8, 19, 53, 11, 60, 24, 32, 61, 4, 55, 31, 2, 49, 16, 39, 9, 31, 24, 43, 17, 26, 38, 11, 25, 58, 43, 12, 35, 3, 46, 15, 32, 63, 4, 49, 56, 2, 60, 10, 32, 63, 17, 39, 12, 55, 30, 57, 9, 48, 55, 39, 24, 60, 2, 58, 31, 19, 61, 34, 3, 42, 11, 22, 46, 7, 61, 10, 42, 3, 55, 32, 1, 58, 28, 44, 54, 4, 34, 23, 15, 56, 20, 37, 58, 6, 30, 38, 18, 63, 9, 32, 5, 51, 3, 62, 37, 52, 18, 39, 23, 3, 51, 9, 47, 1, 23, 43, 15, 60, 35, 11, 40, 1, 36, 31, 26, 57, 2, 37, 54, 18, 44, 58, 16 }, + { 5, 51, 3, 33, 43, 62, 21, 42, 35, 9, 48, 15, 36, 10, 22, 42, 20, 46, 26, 56, 50, 12, 59, 3, 48, 19, 45, 53, 1, 27, 47, 17, 52, 24, 56, 11, 51, 21, 37, 30, 20, 46, 14, 41, 1, 47, 33, 7, 41, 17, 35, 27, 20, 1, 14, 54, 26, 33, 18, 47, 1, 44, 14, 59, 16, 52, 28, 18, 49, 31, 25, 34, 63, 13, 51, 24, 9, 50, 3, 23, 38, 63, 7, 52, 29, 46, 11, 33, 50, 22, 57, 36, 1, 57, 49, 17, 39, 28, 9, 35, 6, 27, 53, 15, 55, 30, 24, 58, 36, 41, 11, 52, 32, 3, 44, 25, 62, 23, 51, 15, 42, 22, 50, 10, 39, 4, 31, 35 }, + { 46, 22, 57, 17, 12, 39, 26, 5, 31, 59, 1, 45, 27, 62, 52, 7, 58, 33, 6, 18, 39, 22, 33, 41, 57, 5, 35, 18, 40, 16, 60, 5, 29, 42, 7, 39, 27, 44, 9, 47, 8, 26, 54, 22, 51, 29, 24, 49, 15, 61, 4, 51, 31, 63, 43, 6, 50, 8, 39, 12, 53, 37, 23, 30, 40, 6, 62, 43, 14, 53, 2, 49, 7, 36, 17, 41, 61, 37, 18, 56, 11, 18, 44, 35, 2, 19, 61, 0, 41, 14, 8, 30, 43, 12, 24, 46, 14, 54, 42, 21, 44, 61, 10, 46, 37, 11, 44, 7, 18, 63, 20, 29, 7, 49, 28, 54, 8, 43, 4, 48, 18, 63, 12, 29, 48, 24, 59, 20 }, + { 13, 36, 28, 54, 35, 2, 56, 46, 16, 49, 22, 40, 11, 34, 14, 43, 29, 12, 63, 48, 2, 61, 7, 15, 28, 30, 50, 9, 61, 33, 38, 23, 54, 13, 61, 33, 3, 59, 16, 35, 58, 40, 5, 38, 13, 57, 3, 58, 37, 21, 45, 12, 39, 7, 35, 30, 13, 56, 22, 62, 27, 6, 55, 10, 48, 21, 33, 2, 38, 23, 40, 20, 44, 29, 59, 4, 26, 12, 33, 47, 28, 53, 31, 13, 59, 41, 27, 49, 26, 54, 45, 16, 53, 21, 35, 7, 59, 26, 11, 56, 1, 24, 33, 4, 28, 62, 21, 49, 31, 2, 56, 39, 24, 58, 13, 17, 37, 21, 56, 10, 38, 0, 34, 55, 15, 43, 1, 52 }, + { 42, 9, 50, 6, 25, 60, 14, 38, 10, 29, 53, 18, 57, 3, 25, 51, 0, 53, 25, 17, 29, 37, 52, 46, 0, 62, 14, 37, 4, 50, 10, 44, 0, 46, 20, 25, 50, 19, 55, 0, 23, 31, 62, 34, 11, 45, 19, 32, 0, 53, 10, 59, 23, 47, 18, 60, 42, 28, 37, 3, 50, 15, 35, 44, 0, 51, 27, 60, 9, 57, 16, 58, 11, 22, 46, 15, 53, 48, 7, 42, 0, 60, 5, 49, 24, 54, 9, 17, 39, 5, 34, 62, 3, 40, 60, 31, 0, 47, 29, 16, 49, 39, 59, 17, 50, 0, 40, 13, 53, 38, 16, 46, 0, 42, 34, 60, 2, 53, 29, 31, 58, 46, 27, 6, 61, 8, 37, 28 }, + { 0, 63, 21, 40, 45, 18, 51, 23, 63, 34, 6, 43, 28, 38, 55, 19, 40, 35, 8, 41, 54, 10, 21, 32, 39, 23, 53, 26, 55, 28, 22, 63, 30, 34, 9, 48, 6, 38, 29, 43, 49, 6, 18, 52, 27, 61, 9, 43, 28, 42, 33, 26, 56, 3, 51, 23, 0, 48, 16, 45, 32, 25, 63, 20, 57, 17, 42, 12, 35, 47, 5, 31, 39, 56, 6, 30, 34, 21, 61, 25, 14, 40, 22, 38, 15, 6, 36, 56, 20, 60, 25, 12, 51, 27, 10, 56, 42, 20, 36, 63, 32, 6, 21, 41, 12, 34, 60, 26, 5, 48, 27, 10, 62, 19, 6, 47, 39, 14, 45, 7, 24, 17, 41, 32, 23, 51, 19, 56 }, + { 45, 31, 15, 59, 4, 33, 7, 47, 0, 41, 13, 61, 4, 47, 9, 23, 60, 14, 57, 31, 4, 45, 59, 6, 58, 10, 44, 20, 8, 42, 15, 6, 55, 17, 58, 31, 53, 12, 61, 10, 15, 57, 43, 2, 23, 35, 48, 14, 54, 6, 18, 49, 15, 38, 11, 34, 62, 9, 21, 58, 11, 41, 4, 31, 38, 8, 29, 55, 19, 36, 27, 52, 0, 25, 50, 43, 1, 39, 8, 55, 35, 51, 10, 30, 45, 62, 29, 2, 46, 10, 32, 48, 18, 38, 5, 22, 33, 8, 51, 3, 14, 44, 54, 25, 57, 30, 18, 52, 33, 22, 59, 28, 36, 52, 32, 21, 26, 50, 5, 55, 35, 60, 14, 54, 4, 40, 16, 33 }, + { 27, 3, 49, 10, 30, 40, 55, 27, 57, 24, 52, 21, 32, 17, 60, 30, 5, 44, 27, 49, 19, 34, 13, 24, 43, 36, 3, 49, 31, 59, 37, 48, 26, 41, 2, 41, 14, 36, 21, 32, 40, 26, 13, 49, 55, 5, 16, 40, 25, 60, 36, 1, 63, 29, 17, 44, 25, 40, 52, 5, 29, 47, 54, 13, 46, 24, 60, 4, 51, 22, 63, 14, 45, 18, 12, 62, 17, 57, 19, 42, 3, 26, 58, 48, 1, 21, 40, 52, 23, 37, 44, 1, 29, 58, 43, 50, 15, 61, 19, 45, 58, 28, 7, 48, 2, 46, 8, 42, 3, 55, 8, 50, 12, 4, 55, 10, 63, 33, 20, 40, 11, 3, 46, 20, 48, 26, 61, 11 }, + { 44, 56, 24, 36, 53, 19, 12, 37, 16, 44, 7, 36, 49, 54, 11, 37, 48, 21, 15, 1, 62, 25, 47, 56, 16, 18, 51, 12, 40, 1, 24, 11, 52, 16, 23, 59, 28, 1, 45, 53, 4, 60, 37, 21, 39, 30, 63, 20, 52, 10, 30, 45, 8, 41, 54, 4, 57, 7, 34, 55, 36, 18, 23, 59, 2, 48, 11, 32, 44, 1, 41, 8, 33, 54, 38, 23, 30, 46, 6, 29, 62, 18, 32, 16, 55, 34, 14, 11, 61, 7, 55, 16, 53, 13, 23, 2, 55, 37, 26, 10, 33, 23, 36, 16, 38, 22, 56, 15, 24, 43, 35, 17, 44, 40, 25, 46, 16, 1, 57, 25, 49, 36, 28, 62, 9, 35, 7, 53 }, + { 17, 38, 8, 61, 1, 50, 26, 62, 3, 31, 56, 15, 1, 26, 40, 2, 34, 51, 56, 36, 42, 9, 38, 2, 29, 60, 32, 57, 19, 62, 34, 47, 4, 57, 39, 7, 44, 63, 24, 18, 46, 28, 8, 54, 1, 34, 7, 46, 3, 37, 50, 23, 57, 21, 13, 46, 31, 20, 43, 15, 1, 61, 8, 33, 37, 17, 56, 26, 15, 49, 24, 59, 28, 3, 56, 9, 52, 32, 13, 49, 10, 43, 5, 45, 8, 25, 59, 42, 28, 33, 19, 40, 8, 63, 35, 47, 25, 4, 40, 52, 1, 60, 12, 53, 63, 9, 29, 60, 37, 19, 1, 62, 31, 20, 58, 12, 41, 30, 43, 9, 18, 52, 22, 1, 39, 30, 58, 21 }, + { 13, 47, 29, 18, 43, 34, 5, 48, 20, 42, 10, 45, 30, 58, 20, 63, 24, 11, 6, 28, 54, 14, 22, 52, 41, 7, 26, 5, 45, 15, 53, 13, 35, 27, 18, 50, 12, 33, 5, 56, 10, 17, 45, 24, 59, 15, 50, 26, 56, 13, 19, 5, 32, 52, 27, 36, 2, 61, 12, 26, 49, 40, 27, 52, 13, 50, 6, 39, 61, 34, 10, 37, 48, 20, 41, 27, 2, 36, 59, 24, 54, 33, 63, 20, 38, 50, 3, 17, 52, 4, 58, 27, 45, 21, 32, 11, 48, 17, 57, 20, 46, 38, 25, 43, 4, 34, 51, 6, 13, 45, 57, 26, 6, 48, 2, 35, 53, 23, 61, 34, 59, 6, 42, 56, 13, 51, 2, 41 }, + { 32, 5, 55, 23, 58, 14, 22, 52, 29, 15, 61, 25, 51, 8, 43, 13, 53, 41, 46, 20, 3, 33, 63, 11, 48, 21, 54, 38, 28, 3, 30, 43, 21, 62, 9, 31, 55, 22, 51, 29, 37, 62, 32, 12, 42, 29, 41, 9, 33, 44, 62, 28, 43, 1, 59, 19, 48, 30, 51, 39, 24, 4, 58, 19, 42, 29, 22, 43, 3, 18, 53, 5, 13, 50, 16, 60, 45, 21, 7, 40, 15, 0, 26, 53, 13, 31, 43, 24, 47, 31, 15, 49, 2, 41, 6, 59, 29, 42, 9, 30, 14, 7, 49, 18, 31, 47, 20, 39, 49, 32, 11, 41, 54, 15, 61, 18, 7, 38, 4, 13, 44, 28, 15, 32, 45, 19, 27, 49 }, + { 63, 34, 11, 39, 2, 45, 37, 8, 59, 39, 33, 4, 36, 17, 48, 5, 29, 18, 32, 61, 39, 50, 5, 27, 35, 0, 46, 12, 22, 49, 60, 6, 54, 0, 38, 49, 2, 42, 15, 40, 0, 47, 20, 51, 3, 57, 18, 61, 22, 0, 39, 16, 55, 12, 35, 8, 41, 22, 6, 59, 16, 45, 10, 36, 0, 62, 9, 54, 30, 58, 21, 43, 63, 31, 7, 35, 12, 48, 58, 28, 47, 37, 41, 9, 57, 20, 61, 0, 36, 11, 57, 35, 23, 52, 37, 18, 0, 62, 22, 55, 35, 62, 27, 54, 0, 15, 61, 28, 2, 59, 22, 9, 37, 27, 33, 51, 29, 48, 19, 50, 25, 37, 10, 57, 5, 37, 60, 8 }, + { 20, 25, 46, 52, 31, 60, 12, 55, 0, 19, 11, 46, 62, 35, 23, 38, 57, 0, 55, 10, 16, 30, 58, 44, 17, 59, 29, 63, 42, 8, 36, 20, 33, 46, 16, 61, 25, 35, 8, 54, 26, 7, 58, 22, 34, 6, 47, 14, 53, 31, 48, 9, 37, 25, 49, 63, 16, 55, 45, 14, 34, 63, 21, 53, 25, 33, 46, 16, 35, 7, 46, 29, 0, 39, 25, 55, 22, 34, 18, 4, 56, 11, 23, 51, 28, 6, 39, 14, 62, 44, 19, 8, 60, 12, 56, 28, 50, 34, 39, 5, 51, 3, 41, 12, 57, 35, 10, 53, 25, 17, 52, 30, 47, 0, 43, 14, 5, 57, 31, 55, 0, 63, 47, 23, 54, 24, 14, 43 }, + { 0, 57, 16, 6, 26, 19, 35, 28, 49, 42, 54, 26, 21, 1, 59, 27, 9, 47, 26, 44, 50, 22, 13, 40, 8, 37, 10, 34, 17, 56, 25, 58, 13, 27, 44, 9, 20, 58, 31, 17, 60, 36, 10, 41, 53, 25, 36, 39, 4, 24, 58, 17, 60, 4, 22, 38, 10, 32, 0, 50, 31, 7, 28, 47, 12, 57, 5, 26, 52, 23, 14, 40, 57, 17, 47, 5, 53, 1, 44, 31, 19, 60, 46, 2, 35, 48, 30, 54, 22, 5, 51, 39, 25, 31, 4, 43, 14, 9, 45, 16, 24, 44, 19, 29, 40, 23, 44, 7, 38, 42, 4, 63, 12, 54, 23, 59, 22, 42, 8, 15, 40, 21, 8, 34, 3, 41, 30, 50 }, + { 39, 10, 48, 33, 41, 54, 5, 47, 23, 13, 32, 7, 52, 44, 14, 39, 58, 18, 35, 6, 37, 2, 60, 24, 55, 19, 53, 2, 51, 32, 1, 41, 51, 4, 40, 29, 47, 3, 52, 44, 13, 49, 28, 16, 1, 62, 11, 27, 52, 35, 5, 42, 29, 47, 14, 56, 28, 53, 26, 38, 9, 56, 40, 3, 38, 15, 41, 60, 1, 37, 50, 25, 11, 28, 61, 19, 42, 62, 10, 52, 39, 6, 32, 14, 58, 17, 7, 26, 42, 34, 27, 10, 54, 40, 20, 63, 26, 53, 21, 61, 32, 7, 59, 48, 3, 56, 18, 31, 58, 14, 49, 21, 36, 16, 45, 9, 36, 24, 62, 45, 27, 31, 53, 17, 49, 12, 62, 18 }, + { 28, 59, 21, 58, 2, 16, 38, 9, 62, 3, 56, 41, 10, 31, 50, 4, 32, 52, 12, 63, 23, 46, 33, 31, 4, 48, 25, 43, 14, 23, 47, 11, 22, 55, 14, 60, 23, 37, 11, 39, 23, 2, 45, 56, 31, 43, 19, 55, 16, 46, 21, 51, 11, 33, 44, 2, 41, 18, 5, 52, 23, 44, 17, 60, 27, 49, 11, 32, 44, 10, 54, 2, 56, 33, 8, 38, 13, 29, 36, 16, 24, 63, 27, 51, 21, 43, 56, 12, 49, 3, 59, 48, 1, 15, 46, 7, 36, 2, 47, 11, 50, 27, 37, 13, 33, 8, 51, 46, 1, 34, 28, 40, 3, 33, 60, 29, 47, 1, 35, 11, 59, 42, 2, 60, 26, 46, 6, 35 }, + { 4, 43, 9, 29, 36, 63, 24, 44, 20, 50, 30, 17, 60, 22, 16, 43, 25, 3, 42, 19, 51, 15, 8, 54, 42, 15, 61, 5, 39, 57, 18, 61, 31, 48, 34, 2, 50, 19, 57, 5, 63, 33, 19, 38, 13, 27, 48, 7, 32, 61, 2, 26, 58, 6, 24, 50, 13, 61, 42, 20, 62, 2, 35, 20, 51, 4, 62, 18, 23, 58, 20, 31, 43, 15, 51, 45, 26, 50, 4, 55, 45, 3, 35, 9, 38, 1, 32, 61, 20, 45, 17, 33, 24, 57, 29, 51, 22, 58, 38, 30, 15, 1, 54, 21, 63, 43, 26, 12, 24, 56, 8, 60, 50, 19, 5, 52, 13, 54, 17, 50, 4, 16, 36, 12, 32, 56, 22, 54 }, + { 51, 25, 40, 53, 12, 49, 15, 57, 34, 7, 38, 47, 2, 36, 55, 8, 61, 30, 56, 7, 28, 59, 48, 11, 27, 35, 21, 45, 28, 36, 9, 38, 6, 16, 24, 63, 10, 32, 28, 43, 21, 53, 5, 60, 8, 57, 3, 45, 11, 37, 15, 54, 40, 20, 62, 36, 27, 34, 11, 48, 30, 15, 54, 8, 30, 42, 22, 34, 48, 13, 35, 63, 4, 37, 22, 2, 59, 9, 41, 23, 13, 41, 49, 18, 59, 24, 40, 5, 37, 30, 9, 61, 44, 6, 37, 11, 33, 17, 5, 55, 41, 60, 23, 39, 17, 5, 30, 62, 41, 16, 46, 25, 11, 56, 39, 26, 20, 38, 29, 39, 22, 52, 44, 20, 48, 1, 38, 14 }, + { 15, 33, 2, 18, 44, 6, 27, 0, 32, 61, 25, 12, 58, 28, 40, 20, 47, 13, 34, 43, 38, 1, 23, 62, 40, 0, 51, 10, 63, 3, 52, 26, 44, 30, 45, 6, 41, 54, 0, 51, 12, 30, 46, 24, 49, 22, 40, 33, 63, 23, 43, 30, 9, 47, 0, 17, 54, 7, 57, 3, 37, 47, 24, 46, 13, 55, 7, 52, 2, 42, 6, 26, 49, 18, 60, 34, 16, 57, 33, 20, 61, 30, 8, 54, 14, 46, 12, 53, 16, 55, 38, 13, 22, 53, 18, 59, 46, 27, 43, 19, 32, 10, 45, 6, 49, 36, 52, 2, 20, 55, 6, 39, 32, 15, 44, 3, 58, 10, 63, 6, 56, 30, 7, 58, 9, 40, 19, 63 }, + { 10, 47, 61, 23, 55, 31, 52, 42, 17, 45, 4, 51, 27, 6, 15, 53, 0, 49, 26, 10, 56, 18, 36, 6, 20, 58, 32, 30, 13, 49, 19, 56, 0, 59, 12, 53, 27, 17, 38, 25, 48, 9, 15, 36, 14, 30, 59, 17, 0, 50, 8, 58, 18, 56, 31, 45, 21, 41, 29, 19, 60, 6, 32, 59, 0, 36, 29, 39, 19, 59, 46, 12, 55, 30, 10, 47, 24, 3, 28, 48, 0, 55, 44, 27, 33, 4, 63, 29, 49, 0, 26, 50, 34, 2, 42, 14, 0, 62, 9, 56, 3, 52, 28, 34, 58, 9, 20, 48, 37, 32, 22, 53, 0, 62, 27, 49, 34, 46, 21, 33, 41, 14, 25, 37, 53, 29, 31, 45 }, + { 56, 28, 7, 37, 11, 36, 20, 9, 54, 14, 39, 19, 34, 63, 45, 37, 24, 17, 60, 31, 21, 45, 53, 29, 47, 15, 7, 55, 40, 23, 34, 14, 42, 20, 37, 35, 15, 59, 7, 62, 34, 40, 59, 1, 51, 42, 10, 28, 54, 21, 35, 5, 38, 13, 36, 4, 59, 12, 39, 53, 15, 43, 9, 21, 39, 62, 16, 56, 25, 9, 32, 38, 0, 41, 14, 51, 40, 53, 43, 11, 37, 17, 5, 22, 57, 39, 19, 7, 42, 21, 60, 10, 31, 63, 25, 52, 30, 49, 36, 25, 48, 17, 61, 14, 22, 42, 29, 13, 60, 11, 47, 18, 35, 41, 7, 23, 4, 16, 51, 11, 0, 48, 61, 3, 17, 50, 5, 24 }, + { 0, 42, 21, 49, 60, 3, 57, 40, 29, 48, 23, 56, 42, 11, 22, 5, 59, 39, 4, 50, 3, 41, 12, 57, 25, 50, 44, 18, 4, 46, 7, 62, 33, 50, 4, 56, 21, 32, 43, 18, 3, 23, 55, 34, 20, 4, 53, 38, 12, 46, 29, 52, 25, 61, 23, 51, 26, 46, 1, 34, 25, 57, 28, 51, 26, 11, 50, 3, 44, 28, 53, 21, 57, 27, 62, 6, 31, 19, 8, 63, 26, 59, 36, 47, 15, 29, 50, 25, 35, 47, 18, 41, 4, 48, 8, 40, 12, 23, 6, 44, 13, 40, 1, 31, 55, 0, 61, 43, 4, 50, 26, 58, 9, 53, 24, 61, 42, 55, 31, 43, 57, 20, 34, 27, 43, 8, 59, 39 }, + { 18, 51, 30, 13, 26, 16, 46, 22, 2, 59, 8, 30, 1, 48, 33, 51, 29, 9, 46, 16, 62, 14, 33, 2, 38, 9, 27, 60, 37, 26, 53, 17, 28, 10, 24, 46, 2, 49, 8, 57, 29, 45, 6, 26, 62, 44, 18, 25, 61, 3, 42, 14, 49, 10, 43, 6, 17, 32, 63, 10, 49, 4, 40, 14, 45, 33, 22, 37, 12, 61, 5, 17, 43, 7, 23, 37, 15, 58, 49, 13, 39, 21, 10, 52, 1, 62, 9, 56, 12, 2, 58, 28, 36, 16, 56, 28, 56, 35, 20, 63, 24, 37, 51, 8, 45, 25, 16, 33, 27, 38, 2, 44, 13, 30, 17, 36, 12, 26, 5, 18, 28, 47, 13, 60, 23, 45, 13, 33 }, + { 55, 4, 62, 34, 52, 38, 7, 63, 32, 37, 13, 53, 25, 62, 18, 12, 55, 41, 27, 35, 24, 49, 31, 52, 17, 63, 34, 1, 56, 12, 41, 2, 48, 58, 39, 16, 61, 27, 41, 52, 13, 19, 50, 39, 11, 31, 57, 6, 32, 40, 20, 55, 1, 28, 33, 57, 48, 8, 37, 22, 44, 18, 53, 1, 61, 5, 54, 16, 47, 36, 50, 24, 55, 34, 48, 45, 1, 30, 33, 46, 2, 50, 32, 42, 25, 34, 43, 21, 38, 52, 23, 45, 14, 54, 21, 4, 44, 16, 53, 29, 10, 47, 19, 57, 12, 54, 39, 10, 51, 15, 63, 21, 57, 40, 51, 1, 48, 57, 37, 62, 2, 38, 9, 52, 1, 35, 58, 22 }, + { 36, 46, 10, 42, 1, 27, 43, 15, 50, 21, 45, 16, 41, 3, 35, 44, 20, 1, 57, 11, 55, 7, 43, 8, 22, 42, 13, 46, 21, 39, 31, 60, 22, 5, 29, 44, 11, 35, 20, 4, 36, 58, 32, 15, 47, 2, 36, 48, 16, 60, 8, 35, 44, 63, 16, 2, 40, 26, 55, 14, 58, 35, 24, 31, 19, 42, 31, 58, 1, 29, 10, 40, 2, 19, 12, 54, 22, 61, 7, 24, 56, 5, 28, 16, 54, 3, 15, 58, 6, 30, 8, 62, 1, 43, 31, 47, 7, 59, 1, 38, 58, 4, 34, 27, 38, 5, 31, 59, 7, 46, 30, 3, 34, 6, 28, 59, 20, 8, 32, 15, 53, 24, 55, 31, 19, 49, 11, 26 }, + { 2, 24, 16, 58, 19, 55, 5, 35, 10, 61, 4, 28, 57, 24, 58, 7, 31, 47, 22, 38, 19, 28, 61, 36, 54, 5, 59, 29, 6, 52, 15, 11, 43, 36, 8, 54, 52, 1, 62, 25, 47, 9, 1, 60, 28, 53, 24, 14, 46, 27, 51, 22, 12, 24, 38, 53, 20, 11, 51, 3, 29, 7, 48, 63, 8, 49, 9, 21, 52, 14, 63, 32, 46, 60, 35, 4, 41, 16, 52, 35, 18, 42, 59, 7, 36, 61, 45, 27, 33, 51, 19, 39, 34, 11, 61, 18, 33, 41, 28, 15, 54, 22, 42, 3, 49, 21, 47, 18, 36, 23, 55, 19, 48, 24, 45, 10, 33, 44, 50, 40, 7, 35, 15, 41, 63, 6, 40, 54 }, + { 62, 41, 32, 8, 47, 28, 60, 24, 44, 30, 38, 49, 9, 33, 14, 40, 50, 14, 60, 2, 54, 40, 0, 20, 25, 39, 16, 49, 24, 35, 57, 47, 19, 61, 33, 18, 23, 37, 13, 55, 31, 43, 22, 41, 17, 8, 42, 58, 0, 37, 5, 56, 31, 54, 7, 30, 60, 33, 42, 17, 59, 39, 12, 27, 38, 17, 35, 41, 27, 45, 20, 7, 25, 15, 29, 58, 27, 47, 11, 40, 14, 54, 23, 46, 19, 31, 11, 40, 13, 49, 5, 58, 24, 51, 26, 6, 50, 20, 49, 9, 32, 46, 17, 60, 14, 63, 24, 1, 57, 41, 9, 43, 14, 62, 16, 52, 3, 27, 14, 22, 61, 45, 4, 28, 9, 47, 29, 17 }, + { 5, 50, 12, 53, 38, 18, 11, 51, 0, 55, 17, 6, 47, 54, 19, 63, 5, 26, 34, 45, 13, 30, 47, 58, 10, 48, 32, 3, 62, 9, 26, 0, 25, 14, 50, 3, 47, 30, 42, 16, 6, 63, 12, 49, 33, 55, 21, 10, 34, 63, 18, 41, 3, 47, 19, 43, 0, 49, 8, 28, 46, 20, 52, 0, 56, 24, 60, 3, 59, 5, 39, 57, 48, 52, 9, 38, 3, 21, 26, 60, 0, 32, 12, 38, 4, 48, 53, 0, 60, 15, 29, 44, 18, 10, 38, 57, 13, 60, 2, 26, 62, 7, 50, 29, 35, 8, 40, 53, 28, 12, 60, 33, 38, 5, 37, 29, 60, 39, 56, 0, 30, 18, 50, 34, 59, 25, 14, 44 }, + { 20, 31, 60, 22, 3, 49, 33, 25, 40, 13, 34, 59, 22, 36, 0, 28, 37, 56, 8, 18, 51, 16, 4, 45, 27, 12, 53, 42, 18, 44, 51, 31, 55, 40, 28, 58, 7, 60, 10, 51, 27, 37, 24, 56, 5, 26, 44, 29, 50, 23, 45, 11, 34, 15, 59, 27, 13, 23, 62, 37, 4, 57, 15, 32, 42, 6, 47, 11, 30, 43, 23, 13, 0, 36, 18, 44, 63, 51, 37, 29, 49, 20, 57, 27, 62, 9, 24, 35, 23, 53, 37, 3, 42, 55, 0, 36, 23, 39, 31, 43, 17, 37, 24, 11, 52, 43, 19, 32, 5, 50, 26, 0, 56, 21, 54, 11, 19, 6, 47, 25, 59, 42, 12, 54, 21, 3, 38, 57 }, + { 48, 0, 35, 27, 44, 14, 59, 7, 57, 46, 26, 2, 42, 12, 52, 43, 10, 27, 53, 42, 32, 62, 37, 21, 34, 61, 7, 23, 36, 4, 38, 12, 41, 5, 17, 45, 22, 27, 39, 21, 59, 0, 45, 18, 39, 62, 3, 38, 14, 7, 54, 26, 61, 39, 9, 52, 45, 36, 18, 50, 10, 34, 44, 22, 50, 14, 36, 55, 17, 34, 53, 62, 33, 26, 56, 6, 31, 12, 6, 53, 9, 44, 2, 50, 20, 40, 55, 17, 47, 7, 26, 63, 22, 32, 48, 16, 46, 8, 52, 12, 57, 41, 0, 56, 25, 3, 61, 14, 45, 35, 18, 44, 12, 46, 23, 42, 32, 51, 35, 10, 17, 36, 23, 1, 45, 52, 32, 10 }, + { 37, 15, 43, 8, 63, 39, 21, 31, 16, 37, 19, 62, 30, 46, 17, 60, 21, 48, 1, 23, 6, 25, 11, 56, 1, 40, 30, 58, 15, 54, 21, 59, 9, 63, 35, 56, 11, 51, 2, 46, 34, 14, 53, 7, 30, 11, 51, 19, 60, 40, 30, 1, 24, 50, 20, 32, 3, 56, 5, 25, 31, 13, 61, 2, 29, 60, 25, 20, 51, 2, 27, 8, 18, 42, 10, 45, 21, 34, 43, 17, 62, 29, 41, 14, 34, 6, 30, 43, 2, 57, 33, 13, 45, 12, 27, 62, 4, 55, 21, 35, 5, 27, 45, 33, 16, 47, 30, 54, 22, 10, 51, 27, 63, 7, 49, 1, 58, 22, 15, 43, 53, 7, 57, 39, 27, 12, 61, 24 }, + { 56, 51, 26, 56, 19, 2, 41, 54, 5, 52, 9, 48, 6, 23, 39, 4, 32, 15, 63, 35, 59, 49, 43, 15, 52, 19, 50, 9, 46, 33, 1, 29, 48, 20, 32, 1, 38, 33, 19, 54, 9, 32, 24, 48, 58, 35, 16, 48, 4, 52, 13, 57, 33, 5, 45, 59, 15, 29, 41, 55, 47, 39, 23, 53, 9, 40, 4, 57, 10, 44, 48, 40, 50, 14, 61, 24, 55, 1, 59, 22, 33, 8, 51, 25, 58, 46, 11, 59, 20, 41, 17, 51, 6, 56, 35, 25, 42, 30, 15, 58, 48, 18, 61, 9, 58, 39, 13, 2, 37, 59, 40, 2, 31, 16, 34, 41, 8, 30, 62, 3, 29, 48, 33, 5, 63, 16, 41, 7 }, + { 22, 4, 46, 11, 33, 51, 29, 10, 62, 24, 43, 27, 15, 58, 50, 25, 54, 44, 9, 38, 18, 3, 29, 57, 32, 5, 26, 43, 17, 61, 24, 52, 8, 42, 23, 53, 15, 61, 7, 28, 57, 43, 4, 40, 20, 2, 43, 25, 32, 35, 21, 43, 17, 48, 10, 22, 38, 54, 11, 21, 1, 58, 16, 30, 48, 18, 46, 32, 38, 13, 22, 4, 59, 35, 2, 51, 30, 39, 15, 47, 4, 56, 13, 37, 1, 28, 16, 52, 32, 9, 61, 29, 38, 19, 3, 52, 10, 48, 1, 32, 11, 40, 20, 36, 6, 22, 49, 29, 55, 6, 20, 56, 36, 52, 19, 60, 26, 46, 18, 54, 40, 13, 20, 46, 35, 19, 49, 29 }, + { 61, 17, 34, 53, 23, 6, 48, 35, 20, 40, 1, 56, 36, 29, 11, 34, 7, 41, 14, 30, 55, 20, 46, 8, 24, 38, 63, 2, 37, 10, 45, 14, 34, 49, 6, 13, 44, 25, 49, 41, 21, 12, 61, 15, 54, 29, 63, 12, 56, 8, 49, 2, 62, 36, 28, 61, 0, 25, 41, 63, 35, 8, 44, 6, 37, 62, 7, 21, 63, 28, 55, 31, 16, 24, 41, 19, 9, 57, 27, 36, 18, 42, 31, 62, 22, 55, 38, 4, 27, 47, 1, 40, 14, 54, 43, 20, 60, 23, 38, 63, 25, 51, 2, 53, 26, 63, 10, 42, 17, 34, 47, 25, 13, 5, 44, 11, 55, 2, 38, 27, 6, 60, 52, 25, 9, 55, 1, 40 }, + { 8, 30, 58, 3, 42, 61, 17, 38, 13, 59, 32, 10, 54, 3, 51, 20, 61, 26, 57, 2, 46, 33, 12, 60, 41, 13, 48, 29, 55, 20, 39, 27, 57, 18, 62, 29, 55, 2, 31, 16, 37, 50, 26, 36, 6, 46, 9, 41, 27, 57, 23, 39, 26, 6, 51, 12, 31, 46, 7, 16, 27, 52, 19, 56, 26, 12, 33, 53, 1, 41, 8, 57, 46, 7, 54, 32, 47, 5, 49, 11, 60, 23, 5, 48, 10, 43, 19, 63, 35, 24, 49, 21, 59, 5, 31, 37, 14, 44, 7, 42, 6, 30, 46, 13, 44, 32, 19, 50, 4, 58, 8, 30, 62, 38, 28, 53, 21, 36, 13, 50, 21, 33, 15, 2, 44, 31, 14, 47 }, + { 37, 13, 39, 16, 28, 9, 57, 0, 25, 49, 21, 45, 18, 47, 12, 42, 0, 49, 22, 39, 16, 53, 25, 36, 0, 52, 22, 16, 6, 60, 4, 51, 0, 26, 37, 47, 10, 36, 63, 5, 57, 0, 18, 59, 23, 33, 51, 19, 0, 44, 15, 11, 54, 17, 42, 35, 53, 18, 58, 33, 49, 4, 34, 42, 0, 50, 43, 25, 16, 49, 34, 20, 37, 28, 12, 63, 16, 38, 25, 44, 0, 40, 52, 17, 35, 3, 50, 14, 8, 53, 11, 36, 25, 45, 9, 62, 0, 54, 28, 17, 50, 55, 15, 24, 57, 0, 53, 34, 23, 41, 15, 45, 0, 49, 16, 4, 48, 9, 63, 45, 0, 42, 58, 37, 61, 22, 54, 26 }, + { 0, 50, 21, 47, 54, 36, 27, 45, 52, 4, 34, 15, 63, 29, 37, 59, 17, 31, 6, 61, 28, 5, 48, 18, 59, 27, 34, 56, 44, 31, 35, 12, 41, 59, 16, 3, 40, 20, 50, 22, 30, 40, 52, 10, 45, 3, 59, 22, 37, 61, 29, 46, 31, 58, 2, 22, 9, 43, 3, 39, 14, 61, 24, 54, 15, 29, 11, 60, 39, 17, 5, 61, 0, 44, 50, 3, 31, 14, 58, 21, 54, 28, 15, 45, 60, 26, 33, 58, 44, 22, 60, 2, 57, 34, 49, 27, 18, 34, 21, 59, 29, 4, 36, 41, 8, 39, 28, 11, 62, 26, 53, 20, 35, 24, 59, 32, 29, 39, 24, 31, 57, 23, 11, 28, 5, 36, 11, 59 }, + { 44, 32, 63, 5, 20, 12, 41, 7, 30, 61, 42, 8, 39, 5, 33, 8, 24, 53, 45, 11, 37, 58, 7, 44, 10, 50, 3, 40, 8, 22, 53, 19, 46, 9, 33, 52, 24, 58, 8, 44, 13, 47, 8, 34, 38, 30, 14, 47, 7, 34, 4, 55, 9, 19, 40, 49, 56, 26, 60, 21, 30, 45, 10, 19, 40, 58, 23, 36, 3, 52, 45, 23, 54, 13, 22, 42, 53, 45, 7, 33, 10, 36, 57, 6, 29, 12, 41, 0, 30, 15, 41, 30, 17, 7, 16, 53, 40, 56, 2, 39, 12, 61, 10, 52, 31, 60, 16, 45, 1, 37, 7, 61, 40, 10, 43, 17, 58, 7, 54, 14, 4, 51, 39, 49, 18, 56, 42, 20 }, + { 14, 6, 24, 36, 56, 49, 22, 60, 18, 14, 23, 51, 26, 57, 21, 52, 41, 14, 35, 50, 19, 31, 40, 23, 33, 14, 63, 17, 32, 47, 7, 62, 23, 30, 56, 11, 42, 27, 14, 60, 35, 19, 28, 61, 17, 55, 25, 39, 53, 17, 42, 21, 38, 63, 25, 5, 14, 36, 12, 50, 1, 37, 59, 32, 2, 51, 6, 56, 27, 32, 11, 30, 38, 26, 60, 8, 26, 19, 62, 39, 50, 2, 21, 39, 53, 23, 56, 19, 49, 39, 5, 46, 55, 23, 42, 4, 31, 11, 47, 26, 45, 22, 48, 18, 21, 5, 48, 25, 57, 14, 47, 30, 3, 56, 12, 50, 1, 42, 19, 47, 35, 17, 8, 30, 45, 25, 4, 51 }, + { 28, 58, 43, 1, 31, 8, 33, 2, 44, 55, 32, 1, 60, 12, 46, 27, 4, 62, 23, 1, 56, 13, 62, 2, 54, 36, 25, 51, 1, 57, 26, 42, 3, 49, 17, 38, 1, 48, 31, 4, 54, 3, 50, 24, 1, 49, 5, 63, 13, 27, 52, 1, 48, 13, 45, 33, 52, 30, 46, 20, 55, 28, 6, 48, 24, 38, 20, 47, 14, 62, 48, 9, 58, 4, 36, 30, 56, 1, 34, 12, 18, 63, 25, 48, 4, 16, 37, 7, 62, 10, 52, 28, 13, 50, 36, 63, 24, 51, 15, 58, 8, 33, 1, 38, 56, 35, 42, 9, 33, 51, 22, 18, 48, 32, 27, 37, 23, 61, 33, 11, 59, 29, 62, 1, 53, 10, 60, 33 }, + { 12, 39, 17, 52, 26, 46, 53, 38, 25, 11, 48, 36, 16, 43, 2, 35, 55, 17, 39, 29, 43, 9, 28, 45, 20, 5, 46, 12, 42, 28, 13, 52, 36, 6, 60, 22, 54, 17, 62, 39, 25, 42, 15, 55, 44, 20, 31, 10, 35, 57, 24, 32, 29, 6, 59, 18, 7, 62, 3, 41, 10, 44, 16, 54, 13, 62, 31, 9, 41, 1, 21, 43, 18, 47, 15, 40, 11, 49, 28, 55, 46, 30, 8, 43, 32, 61, 28, 47, 25, 34, 21, 61, 32, 1, 20, 9, 46, 6, 35, 19, 41, 54, 27, 63, 14, 3, 51, 20, 62, 2, 38, 55, 8, 21, 63, 6, 46, 9, 26, 51, 3, 24, 43, 34, 16, 41, 18, 48 }, + { 62, 23, 55, 9, 15, 62, 19, 13, 58, 40, 6, 30, 54, 19, 50, 31, 10, 44, 6, 59, 21, 47, 51, 15, 60, 39, 30, 54, 21, 61, 19, 33, 14, 29, 43, 11, 34, 45, 7, 21, 10, 56, 36, 6, 38, 11, 58, 42, 2, 47, 11, 60, 50, 16, 41, 28, 38, 23, 47, 17, 35, 63, 22, 33, 42, 5, 45, 17, 53, 35, 25, 56, 33, 6, 51, 19, 60, 23, 43, 15, 5, 40, 58, 13, 51, 1, 45, 11, 54, 3, 43, 8, 37, 48, 59, 29, 39, 21, 61, 43, 3, 31, 10, 44, 24, 29, 60, 12, 28, 40, 11, 25, 43, 52, 14, 41, 16, 57, 44, 20, 40, 55, 12, 21, 57, 27, 35, 2 }, + { 37, 6, 31, 42, 40, 4, 29, 50, 0, 20, 63, 28, 9, 58, 14, 24, 63, 26, 48, 16, 34, 4, 32, 38, 23, 11, 58, 4, 37, 9, 45, 5, 63, 48, 26, 57, 2, 28, 32, 51, 46, 29, 13, 62, 27, 46, 28, 18, 50, 15, 40, 4, 19, 34, 54, 0, 53, 9, 26, 58, 28, 5, 49, 0, 57, 27, 19, 60, 29, 8, 59, 12, 37, 63, 24, 46, 3, 37, 6, 52, 26, 32, 20, 36, 9, 22, 59, 18, 35, 51, 14, 57, 17, 24, 12, 44, 56, 0, 30, 13, 59, 20, 49, 17, 54, 43, 6, 34, 46, 17, 58, 36, 0, 34, 29, 54, 25, 2, 36, 15, 60, 6, 37, 46, 4, 50, 9, 45 }, + { 19, 59, 48, 3, 24, 60, 44, 22, 34, 51, 15, 45, 41, 5, 33, 47, 0, 37, 12, 55, 25, 54, 8, 57, 0, 47, 18, 34, 49, 15, 55, 24, 40, 20, 8, 35, 53, 13, 41, 18, 0, 59, 22, 33, 4, 52, 8, 60, 24, 36, 31, 56, 45, 26, 10, 43, 15, 56, 36, 4, 51, 14, 39, 30, 12, 55, 36, 2, 39, 49, 4, 44, 17, 0, 32, 13, 53, 35, 59, 17, 62, 0, 55, 24, 52, 38, 31, 6, 42, 19, 29, 40, 4, 54, 33, 5, 16, 27, 52, 37, 23, 55, 7, 37, 0, 39, 23, 49, 4, 53, 31, 15, 59, 10, 50, 4, 60, 34, 48, 7, 31, 49, 27, 14, 62, 22, 53, 29 }, + { 46, 21, 14, 51, 36, 17, 7, 57, 10, 32, 3, 37, 22, 60, 39, 18, 56, 20, 42, 3, 36, 10, 44, 26, 41, 29, 53, 27, 2, 39, 30, 52, 0, 59, 15, 48, 23, 61, 6, 58, 37, 12, 40, 49, 16, 39, 20, 44, 0, 62, 8, 21, 3, 59, 23, 32, 49, 31, 12, 44, 22, 59, 18, 50, 24, 7, 43, 52, 15, 23, 41, 26, 51, 28, 55, 39, 21, 27, 10, 42, 12, 45, 27, 47, 3, 15, 63, 26, 55, 0, 60, 26, 45, 18, 62, 38, 58, 49, 8, 47, 4, 33, 46, 29, 57, 13, 56, 16, 59, 21, 5, 47, 23, 39, 18, 44, 13, 22, 28, 53, 19, 0, 58, 32, 41, 7, 26, 13 }, + { 0, 56, 34, 28, 11, 55, 31, 47, 26, 41, 56, 13, 53, 28, 11, 49, 7, 52, 32, 61, 50, 22, 63, 17, 13, 56, 7, 19, 43, 62, 10, 21, 37, 32, 43, 4, 38, 19, 44, 25, 31, 54, 5, 23, 61, 30, 53, 12, 35, 22, 43, 53, 37, 48, 7, 62, 20, 2, 61, 41, 8, 34, 47, 9, 63, 34, 28, 10, 55, 33, 14, 57, 7, 47, 9, 61, 4, 49, 31, 50, 21, 38, 8, 16, 57, 44, 33, 5, 49, 36, 12, 50, 7, 34, 10, 25, 2, 22, 36, 15, 26, 61, 18, 9, 22, 46, 32, 8, 27, 37, 44, 30, 55, 3, 62, 24, 38, 56, 5, 45, 38, 24, 43, 10, 19, 54, 39, 61 }, + { 41, 30, 8, 63, 43, 23, 38, 3, 62, 19, 8, 49, 25, 1, 58, 30, 23, 40, 9, 28, 18, 40, 6, 38, 49, 22, 35, 59, 8, 27, 50, 5, 56, 17, 11, 50, 30, 9, 55, 2, 51, 19, 34, 47, 9, 41, 6, 26, 48, 57, 14, 28, 17, 12, 39, 13, 37, 46, 25, 19, 54, 27, 1, 37, 16, 45, 20, 60, 1, 48, 20, 38, 31, 22, 42, 15, 19, 44, 1, 61, 6, 34, 56, 40, 29, 10, 20, 46, 13, 22, 41, 23, 59, 42, 30, 51, 45, 13, 63, 53, 42, 12, 51, 38, 62, 2, 26, 41, 50, 1, 61, 10, 19, 42, 31, 8, 49, 32, 12, 63, 9, 52, 16, 56, 36, 2, 31, 16 }, + { 52, 5, 47, 20, 1, 53, 12, 50, 16, 35, 43, 21, 33, 43, 16, 44, 3, 59, 14, 46, 1, 30, 60, 33, 2, 45, 12, 42, 31, 47, 14, 33, 46, 25, 55, 27, 60, 36, 16, 42, 14, 46, 26, 1, 55, 15, 63, 32, 2, 38, 5, 47, 33, 61, 30, 52, 4, 57, 6, 38, 11, 43, 61, 24, 52, 3, 31, 22, 42, 10, 62, 3, 59, 11, 35, 57, 33, 54, 24, 14, 29, 48, 18, 2, 60, 41, 53, 24, 32, 62, 3, 53, 15, 1, 55, 17, 32, 40, 6, 31, 1, 40, 28, 5, 35, 52, 19, 63, 13, 33, 17, 41, 52, 26, 15, 57, 1, 20, 42, 17, 35, 27, 48, 5, 25, 50, 44, 11 }, + { 35, 25, 38, 57, 33, 17, 40, 6, 59, 27, 54, 5, 61, 10, 52, 26, 36, 19, 51, 35, 57, 48, 11, 20, 54, 25, 61, 16, 1, 58, 24, 61, 3, 39, 7, 47, 1, 22, 49, 28, 63, 10, 58, 32, 17, 36, 45, 19, 51, 29, 59, 10, 50, 1, 23, 42, 18, 29, 51, 21, 56, 32, 14, 5, 40, 58, 47, 13, 54, 35, 29, 45, 18, 52, 26, 2, 38, 8, 46, 36, 58, 11, 52, 35, 17, 28, 1, 58, 9, 39, 17, 28, 37, 48, 20, 9, 57, 24, 50, 19, 58, 16, 48, 25, 43, 11, 35, 6, 45, 24, 56, 4, 36, 7, 47, 35, 52, 28, 59, 30, 2, 61, 21, 33, 63, 12, 18, 59 }, + { 3, 49, 15, 10, 27, 61, 25, 45, 30, 0, 14, 47, 31, 38, 17, 62, 7, 55, 27, 4, 15, 24, 42, 52, 10, 34, 5, 51, 36, 18, 41, 11, 35, 21, 62, 13, 33, 57, 8, 35, 5, 40, 21, 43, 52, 3, 24, 56, 11, 16, 33, 25, 41, 20, 55, 8, 60, 35, 15, 48, 2, 57, 30, 49, 18, 25, 6, 39, 17, 57, 7, 25, 43, 5, 49, 16, 62, 22, 55, 4, 25, 43, 23, 7, 50, 11, 37, 48, 14, 51, 33, 57, 7, 27, 39, 46, 4, 29, 11, 43, 34, 56, 7, 60, 20, 54, 30, 57, 22, 49, 9, 33, 54, 14, 63, 23, 6, 43, 10, 40, 50, 13, 44, 8, 38, 33, 46, 23 }, + { 55, 39, 22, 50, 44, 4, 36, 9, 52, 23, 37, 59, 21, 2, 46, 13, 31, 41, 11, 45, 62, 29, 6, 37, 19, 48, 30, 23, 44, 7, 53, 28, 54, 16, 41, 29, 44, 18, 52, 24, 60, 15, 48, 7, 27, 59, 9, 34, 42, 54, 7, 63, 4, 46, 31, 27, 45, 0, 40, 26, 34, 17, 37, 10, 53, 29, 36, 50, 2, 27, 51, 11, 61, 37, 23, 41, 30, 7, 18, 50, 39, 14, 63, 32, 45, 61, 19, 30, 25, 44, 2, 47, 23, 63, 11, 34, 59, 37, 60, 3, 22, 14, 44, 30, 15, 0, 47, 15, 3, 38, 61, 20, 27, 45, 11, 39, 51, 16, 55, 3, 22, 54, 29, 58, 1, 57, 6, 29 }, + { 9, 17, 60, 2, 34, 56, 20, 62, 39, 12, 49, 6, 29, 56, 34, 48, 0, 58, 22, 38, 18, 43, 56, 0, 63, 14, 55, 3, 59, 31, 15, 45, 0, 49, 6, 58, 3, 38, 12, 45, 0, 37, 29, 57, 13, 39, 30, 49, 0, 23, 44, 36, 16, 57, 13, 54, 11, 24, 63, 9, 53, 7, 62, 42, 0, 59, 15, 23, 63, 34, 40, 16, 32, 0, 53, 12, 48, 28, 59, 33, 0, 53, 9, 27, 3, 22, 54, 5, 56, 9, 61, 13, 42, 14, 52, 19, 0, 21, 47, 27, 53, 36, 3, 50, 39, 58, 25, 40, 53, 28, 12, 50, 0, 59, 32, 2, 21, 34, 26, 46, 37, 7, 18, 47, 24, 14, 53, 42 }, + { 61, 32, 13, 54, 29, 7, 46, 13, 28, 57, 18, 41, 53, 15, 9, 39, 24, 49, 33, 3, 53, 9, 26, 32, 40, 28, 46, 39, 25, 9, 56, 21, 63, 37, 26, 22, 51, 27, 17, 56, 31, 53, 4, 43, 22, 46, 12, 18, 60, 40, 20, 26, 50, 21, 39, 5, 49, 33, 16, 44, 22, 46, 20, 32, 24, 45, 8, 43, 12, 46, 4, 48, 56, 20, 29, 58, 3, 40, 10, 42, 31, 21, 47, 41, 56, 38, 15, 42, 36, 27, 20, 33, 55, 3, 26, 44, 31, 54, 12, 35, 9, 63, 28, 10, 21, 32, 9, 60, 17, 8, 43, 29, 40, 16, 36, 48, 60, 7, 57, 14, 62, 31, 42, 15, 36, 40, 20, 26 }, + { 0, 37, 47, 23, 41, 18, 32, 48, 1, 35, 8, 25, 4, 26, 63, 20, 54, 8, 16, 61, 35, 23, 51, 15, 58, 7, 12, 20, 50, 34, 42, 4, 38, 10, 32, 47, 8, 60, 41, 20, 9, 25, 50, 19, 62, 1, 37, 56, 28, 8, 53, 11, 3, 58, 34, 43, 19, 60, 38, 4, 58, 31, 3, 51, 11, 55, 38, 30, 21, 58, 19, 26, 9, 44, 36, 13, 46, 20, 62, 24, 13, 60, 5, 28, 12, 34, 7, 59, 0, 53, 45, 6, 38, 30, 50, 7, 62, 16, 41, 5, 46, 18, 55, 42, 51, 5, 45, 23, 34, 48, 19, 58, 5, 25, 54, 19, 13, 41, 28, 21, 0, 49, 10, 60, 4, 51, 9, 45 }, + { 19, 28, 6, 58, 10, 51, 4, 22, 55, 42, 60, 45, 34, 51, 42, 5, 30, 45, 27, 40, 13, 47, 4, 49, 21, 38, 60, 29, 2, 57, 17, 27, 52, 19, 61, 14, 30, 34, 2, 44, 63, 33, 11, 35, 16, 51, 25, 6, 14, 47, 31, 61, 37, 29, 18, 8, 52, 2, 28, 54, 13, 41, 15, 62, 35, 18, 2, 60, 6, 33, 41, 61, 31, 6, 56, 17, 34, 50, 6, 52, 44, 35, 16, 51, 59, 24, 48, 18, 31, 40, 16, 49, 21, 60, 17, 39, 10, 49, 32, 57, 24, 39, 1, 25, 18, 62, 37, 12, 56, 1, 37, 11, 52, 44, 9, 30, 47, 4, 51, 40, 55, 25, 34, 27, 56, 30, 32, 54 }, + { 63, 40, 49, 15, 43, 26, 63, 38, 16, 20, 30, 12, 57, 14, 19, 60, 36, 12, 59, 2, 57, 17, 42, 31, 1, 44, 16, 35, 47, 11, 32, 48, 13, 43, 1, 39, 51, 12, 57, 23, 6, 40, 53, 3, 55, 31, 39, 60, 35, 44, 5, 15, 45, 1, 62, 41, 26, 14, 47, 22, 36, 27, 50, 9, 26, 47, 52, 28, 54, 16, 1, 13, 51, 39, 23, 63, 1, 30, 15, 26, 2, 57, 19, 37, 1, 44, 21, 50, 13, 63, 8, 24, 56, 1, 35, 25, 58, 20, 2, 28, 14, 51, 33, 59, 13, 30, 4, 49, 31, 24, 63, 26, 33, 3, 58, 38, 62, 24, 32, 8, 17, 45, 5, 48, 18, 3, 43, 11 }, + { 21, 4, 24, 34, 59, 1, 37, 11, 53, 5, 47, 2, 22, 40, 32, 1, 24, 50, 21, 29, 38, 25, 63, 8, 55, 24, 53, 6, 62, 23, 59, 3, 54, 20, 58, 24, 5, 46, 15, 38, 48, 14, 27, 42, 23, 7, 46, 10, 17, 58, 25, 52, 23, 32, 49, 12, 55, 30, 40, 7, 59, 1, 56, 21, 39, 4, 23, 15, 37, 46, 55, 42, 21, 4, 48, 8, 45, 54, 37, 55, 32, 8, 46, 10, 30, 54, 4, 41, 25, 29, 36, 48, 11, 43, 14, 47, 5, 43, 53, 36, 61, 10, 45, 6, 41, 54, 27, 43, 16, 55, 6, 46, 18, 42, 23, 15, 1, 45, 12, 60, 37, 22, 62, 12, 39, 59, 16, 52 }, + { 47, 35, 56, 7, 19, 46, 31, 50, 33, 24, 61, 35, 50, 7, 53, 44, 55, 6, 46, 10, 52, 5, 21, 43, 36, 10, 18, 41, 26, 37, 8, 29, 40, 36, 9, 49, 34, 26, 61, 21, 7, 59, 18, 62, 29, 54, 20, 32, 51, 0, 40, 10, 55, 6, 20, 36, 9, 61, 5, 51, 44, 19, 33, 43, 13, 57, 40, 63, 8, 24, 29, 10, 60, 34, 27, 40, 25, 18, 10, 42, 21, 49, 26, 62, 38, 12, 33, 61, 5, 57, 2, 19, 54, 28, 62, 22, 38, 31, 16, 7, 22, 47, 29, 17, 35, 8, 20, 51, 2, 40, 22, 50, 13, 61, 28, 53, 35, 20, 56, 30, 2, 53, 14, 41, 23, 34, 8, 31 }, + { 12, 2, 42, 29, 52, 13, 21, 8, 55, 14, 41, 17, 28, 58, 23, 11, 17, 36, 31, 62, 17, 34, 50, 14, 28, 61, 33, 52, 2, 51, 17, 45, 7, 25, 62, 30, 18, 55, 0, 42, 30, 35, 45, 1, 12, 48, 3, 63, 21, 36, 30, 48, 19, 59, 43, 27, 46, 17, 34, 25, 12, 29, 53, 6, 48, 31, 11, 34, 49, 3, 36, 50, 19, 47, 14, 61, 11, 36, 58, 4, 60, 14, 39, 22, 6, 52, 15, 35, 17, 46, 31, 42, 9, 34, 3, 52, 12, 60, 26, 56, 40, 2, 53, 23, 57, 38, 62, 14, 36, 59, 10, 31, 39, 6, 49, 9, 41, 26, 5, 48, 43, 27, 33, 58, 1, 50, 25, 57 }, + { 61, 37, 15, 61, 3, 39, 58, 43, 26, 0, 44, 10, 47, 3, 37, 63, 28, 43, 13, 39, 3, 57, 30, 59, 0, 48, 5, 43, 13, 22, 60, 33, 55, 15, 42, 4, 52, 10, 45, 13, 54, 4, 24, 49, 37, 26, 41, 14, 42, 9, 61, 13, 38, 23, 3, 53, 0, 58, 21, 42, 63, 10, 17, 61, 25, 0, 58, 28, 17, 44, 57, 12, 27, 0, 55, 5, 52, 28, 23, 47, 29, 0, 43, 17, 58, 28, 47, 23, 55, 10, 58, 23, 51, 40, 18, 33, 45, 0, 49, 8, 32, 61, 19, 48, 0, 26, 7, 47, 29, 18, 44, 0, 56, 34, 20, 59, 15, 51, 37, 18, 10, 52, 7, 20, 46, 9, 38, 17 }, + { 6, 27, 48, 23, 45, 29, 5, 18, 38, 62, 27, 56, 20, 32, 15, 9, 48, 0, 54, 22, 45, 20, 7, 41, 23, 39, 19, 27, 58, 31, 44, 0, 12, 50, 23, 56, 20, 39, 32, 59, 16, 52, 33, 9, 57, 22, 6, 58, 28, 50, 24, 2, 56, 35, 16, 45, 32, 38, 15, 54, 2, 38, 46, 22, 35, 45, 20, 5, 52, 25, 7, 35, 59, 32, 22, 43, 38, 3, 51, 16, 34, 53, 32, 50, 3, 40, 8, 43, 0, 39, 27, 4, 14, 61, 8, 55, 15, 41, 20, 44, 27, 13, 39, 11, 46, 42, 54, 33, 4, 52, 23, 61, 14, 25, 43, 2, 33, 11, 63, 29, 61, 17, 40, 55, 22, 62, 28, 44 }, + { 20, 54, 8, 56, 35, 10, 63, 31, 52, 12, 48, 6, 59, 41, 52, 33, 19, 58, 25, 49, 11, 37, 47, 12, 54, 15, 56, 35, 7, 47, 16, 53, 28, 34, 5, 37, 28, 8, 48, 3, 28, 38, 18, 61, 16, 43, 53, 32, 4, 17, 47, 27, 44, 8, 63, 10, 25, 49, 6, 37, 24, 52, 32, 3, 50, 12, 41, 56, 38, 14, 62, 20, 40, 16, 53, 31, 18, 63, 41, 9, 59, 7, 13, 25, 57, 20, 63, 26, 53, 18, 48, 62, 30, 46, 21, 25, 58, 29, 36, 4, 55, 34, 6, 60, 31, 16, 21, 12, 58, 38, 9, 29, 47, 7, 52, 30, 57, 44, 22, 0, 35, 45, 3, 31, 14, 36, 0, 51 }, + { 42, 14, 33, 24, 16, 49, 40, 2, 22, 33, 16, 36, 25, 1, 21, 61, 38, 8, 33, 4, 62, 26, 29, 60, 6, 46, 30, 11, 63, 4, 36, 40, 19, 57, 46, 11, 41, 63, 22, 25, 58, 10, 46, 2, 34, 27, 11, 38, 56, 34, 12, 53, 18, 33, 41, 51, 13, 28, 60, 20, 47, 14, 29, 59, 16, 62, 8, 22, 32, 47, 9, 49, 2, 44, 7, 12, 45, 6, 20, 27, 45, 24, 62, 42, 36, 11, 33, 15, 37, 7, 32, 10, 37, 1, 35, 50, 6, 11, 63, 24, 52, 15, 50, 24, 3, 37, 56, 27, 34, 22, 49, 16, 36, 62, 17, 39, 4, 15, 54, 24, 50, 8, 58, 26, 49, 54, 11, 30 }, + { 4, 59, 41, 1, 53, 12, 25, 45, 59, 7, 51, 39, 54, 14, 46, 4, 27, 53, 16, 44, 18, 51, 1, 32, 25, 2, 50, 40, 20, 54, 24, 9, 62, 2, 27, 60, 1, 17, 36, 50, 6, 40, 30, 55, 41, 19, 49, 1, 21, 60, 40, 5, 62, 1, 22, 30, 57, 4, 43, 31, 1, 55, 40, 7, 27, 37, 30, 54, 1, 19, 42, 30, 56, 26, 62, 49, 24, 57, 37, 56, 2, 39, 16, 5, 30, 55, 3, 49, 60, 23, 56, 44, 17, 52, 13, 42, 28, 48, 18, 45, 9, 37, 21, 41, 58, 10, 48, 1, 63, 5, 41, 57, 2, 24, 12, 48, 27, 42, 32, 46, 13, 38, 19, 34, 5, 41, 25, 60 }, + { 39, 28, 21, 46, 32, 57, 36, 9, 19, 42, 4, 29, 11, 43, 30, 49, 13, 42, 35, 56, 9, 39, 15, 52, 36, 61, 18, 26, 45, 14, 31, 48, 21, 43, 14, 33, 49, 54, 14, 44, 21, 62, 13, 23, 8, 62, 15, 51, 44, 7, 30, 37, 20, 42, 56, 7, 39, 18, 50, 11, 61, 9, 19, 43, 57, 2, 48, 11, 39, 60, 28, 4, 37, 17, 35, 1, 33, 11, 31, 14, 48, 19, 35, 51, 46, 21, 44, 29, 12, 41, 2, 22, 58, 26, 54, 4, 59, 38, 2, 33, 57, 1, 63, 13, 28, 51, 15, 40, 18, 45, 8, 30, 43, 37, 54, 19, 8, 59, 21, 6, 60, 29, 55, 10, 63, 15, 47, 17 }, + { 3, 50, 10, 62, 18, 5, 27, 49, 60, 23, 55, 18, 62, 24, 56, 10, 59, 28, 2, 23, 34, 59, 43, 20, 10, 42, 8, 49, 1, 37, 57, 6, 51, 29, 53, 7, 23, 31, 5, 32, 51, 0, 35, 54, 45, 31, 5, 26, 36, 24, 55, 15, 48, 29, 14, 48, 26, 60, 21, 41, 36, 26, 50, 33, 14, 44, 17, 24, 52, 15, 46, 23, 54, 6, 47, 21, 60, 50, 4, 53, 29, 61, 8, 23, 1, 60, 19, 6, 53, 16, 47, 34, 6, 39, 16, 31, 12, 20, 53, 22, 30, 43, 25, 46, 35, 6, 44, 32, 53, 26, 55, 19, 11, 59, 5, 33, 51, 1, 35, 53, 25, 3, 42, 23, 44, 32, 7, 53 }, + { 22, 44, 37, 6, 26, 51, 38, 0, 34, 13, 31, 46, 3, 37, 6, 19, 40, 21, 47, 63, 12, 5, 29, 55, 22, 58, 34, 28, 60, 22, 11, 41, 17, 38, 9, 44, 59, 39, 56, 19, 11, 47, 25, 15, 3, 39, 57, 17, 61, 11, 46, 3, 58, 9, 54, 35, 2, 34, 8, 45, 15, 56, 5, 23, 53, 33, 63, 35, 4, 59, 10, 51, 13, 61, 29, 41, 15, 25, 43, 19, 40, 10, 54, 33, 41, 12, 38, 51, 31, 26, 61, 9, 30, 45, 24, 62, 49, 40, 10, 61, 14, 49, 5, 17, 54, 20, 60, 23, 3, 13, 35, 50, 32, 23, 46, 27, 38, 63, 16, 12, 39, 48, 18, 51, 1, 27, 56, 35 }, + { 63, 15, 30, 55, 43, 14, 57, 17, 53, 44, 7, 48, 26, 50, 32, 60, 0, 53, 14, 31, 50, 24, 46, 0, 38, 13, 4, 52, 16, 45, 30, 59, 0, 25, 55, 35, 16, 10, 26, 42, 58, 29, 60, 38, 50, 22, 28, 47, 0, 50, 28, 19, 33, 39, 11, 44, 16, 52, 24, 59, 3, 38, 27, 51, 0, 21, 7, 42, 26, 34, 21, 40, 33, 18, 39, 3, 54, 38, 8, 59, 0, 44, 27, 15, 58, 28, 57, 9, 43, 0, 36, 50, 20, 59, 8, 34, 0, 27, 47, 7, 36, 19, 56, 32, 0, 38, 11, 29, 62, 47, 6, 61, 0, 41, 14, 56, 10, 23, 45, 31, 57, 8, 36, 13, 58, 38, 11, 19 }, + { 0, 34, 12, 47, 21, 2, 40, 30, 11, 25, 61, 20, 40, 15, 35, 22, 45, 36, 7, 41, 17, 57, 9, 48, 32, 62, 44, 24, 35, 3, 54, 13, 33, 63, 19, 4, 48, 22, 62, 2, 37, 8, 33, 6, 20, 52, 9, 32, 43, 13, 39, 63, 25, 4, 49, 23, 62, 32, 9, 30, 48, 18, 63, 12, 46, 29, 58, 13, 48, 8, 57, 31, 0, 51, 9, 58, 12, 22, 47, 29, 35, 22, 49, 5, 46, 4, 34, 20, 63, 24, 56, 11, 41, 3, 51, 19, 56, 35, 17, 58, 28, 42, 9, 45, 59, 26, 51, 42, 17, 36, 25, 15, 53, 21, 44, 3, 30, 55, 5, 50, 21, 28, 61, 32, 6, 49, 28, 46 }, + { 58, 42, 60, 4, 31, 59, 22, 63, 35, 38, 9, 54, 1, 57, 8, 51, 16, 58, 27, 53, 3, 38, 30, 15, 27, 6, 19, 56, 10, 50, 21, 36, 47, 5, 43, 28, 51, 32, 13, 46, 18, 54, 16, 43, 63, 12, 36, 59, 22, 34, 5, 52, 17, 59, 27, 41, 0, 19, 55, 37, 13, 43, 6, 34, 41, 10, 36, 55, 19, 44, 3, 16, 58, 27, 49, 25, 32, 62, 17, 55, 13, 63, 18, 52, 25, 37, 17, 48, 13, 32, 5, 46, 28, 37, 14, 43, 25, 5, 51, 39, 3, 52, 33, 22, 8, 40, 12, 4, 57, 9, 46, 39, 28, 58, 13, 62, 17, 42, 19, 36, 0, 47, 16, 43, 24, 21, 54, 13 }, + { 25, 9, 23, 50, 36, 8, 45, 14, 3, 51, 16, 28, 44, 12, 42, 29, 4, 26, 10, 47, 22, 61, 18, 54, 51, 39, 46, 13, 41, 26, 58, 7, 18, 39, 12, 57, 15, 1, 52, 27, 41, 23, 48, 1, 27, 45, 18, 2, 57, 26, 55, 8, 43, 31, 6, 58, 14, 51, 40, 5, 61, 31, 24, 54, 17, 60, 22, 1, 39, 30, 53, 45, 36, 13, 43, 5, 45, 2, 37, 6, 34, 42, 2, 39, 10, 62, 7, 54, 40, 18, 60, 15, 52, 21, 63, 8, 55, 46, 15, 30, 23, 13, 62, 16, 50, 24, 58, 31, 48, 21, 34, 2, 49, 7, 31, 37, 26, 48, 9, 61, 40, 11, 52, 2, 60, 40, 4, 37 }, + { 52, 28, 39, 16, 54, 19, 29, 55, 42, 20, 58, 33, 24, 63, 18, 55, 39, 62, 43, 34, 12, 40, 6, 35, 2, 25, 8, 62, 34, 1, 31, 42, 61, 27, 53, 24, 40, 61, 34, 8, 59, 4, 30, 56, 40, 6, 53, 42, 10, 48, 16, 37, 12, 46, 21, 36, 47, 11, 28, 45, 22, 10, 57, 2, 49, 31, 14, 44, 61, 11, 25, 6, 23, 63, 18, 36, 28, 56, 20, 51, 11, 48, 27, 56, 32, 22, 45, 30, 2, 42, 27, 39, 1, 44, 23, 31, 38, 22, 11, 61, 43, 54, 4, 47, 35, 2, 44, 16, 28, 54, 12, 62, 18, 43, 10, 52, 1, 58, 33, 15, 29, 56, 20, 34, 9, 30, 48, 17 }, + { 46, 2, 56, 11, 41, 1, 49, 6, 27, 47, 2, 48, 5, 32, 37, 3, 13, 19, 32, 1, 55, 28, 60, 17, 43, 59, 32, 20, 49, 16, 55, 23, 14, 46, 2, 36, 6, 30, 20, 49, 12, 47, 35, 14, 21, 60, 29, 14, 35, 24, 46, 1, 56, 29, 53, 8, 33, 23, 56, 1, 35, 46, 20, 39, 26, 4, 53, 28, 17, 38, 60, 34, 48, 9, 55, 15, 46, 7, 41, 31, 60, 24, 16, 36, 1, 59, 19, 52, 35, 6, 55, 11, 59, 33, 7, 57, 4, 29, 48, 1, 19, 26, 37, 30, 18, 63, 37, 6, 59, 1, 40, 24, 56, 33, 46, 22, 35, 7, 24, 53, 39, 5, 26, 45, 55, 18, 62, 7 }, + { 20, 60, 29, 34, 20, 62, 33, 52, 10, 36, 13, 60, 41, 21, 50, 27, 56, 49, 8, 51, 21, 45, 11, 48, 8, 23, 53, 3, 29, 44, 5, 52, 9, 32, 50, 17, 43, 56, 3, 38, 24, 10, 62, 25, 51, 9, 33, 49, 61, 7, 30, 62, 22, 19, 2, 42, 63, 5, 49, 18, 60, 15, 52, 7, 43, 56, 23, 50, 5, 50, 2, 20, 41, 30, 1, 52, 22, 61, 14, 26, 3, 43, 53, 7, 47, 28, 11, 14, 23, 58, 33, 25, 47, 13, 50, 17, 40, 54, 34, 60, 41, 6, 59, 14, 50, 7, 25, 55, 20, 42, 51, 8, 27, 4, 16, 60, 28, 50, 44, 3, 22, 49, 63, 12, 33, 1, 43, 31 }, + { 36, 5, 46, 8, 44, 24, 13, 39, 25, 57, 31, 18, 8, 52, 10, 45, 6, 30, 36, 24, 63, 4, 33, 26, 57, 40, 15, 56, 37, 12, 40, 25, 37, 58, 11, 63, 21, 45, 16, 60, 31, 53, 18, 33, 3, 45, 23, 0, 20, 54, 40, 15, 50, 38, 60, 16, 25, 42, 29, 38, 7, 41, 25, 62, 18, 33, 8, 35, 42, 16, 32, 56, 12, 39, 59, 19, 34, 9, 49, 38, 57, 12, 21, 50, 14, 40, 61, 44, 50, 9, 49, 19, 3, 29, 35, 62, 12, 24, 7, 18, 52, 32, 10, 46, 21, 41, 32, 11, 36, 29, 14, 34, 60, 38, 54, 11, 41, 14, 19, 57, 32, 16, 7, 41, 51, 25, 14, 57 }, + { 53, 18, 26, 50, 15, 58, 4, 63, 17, 43, 7, 40, 61, 35, 15, 41, 23, 60, 16, 38, 14, 42, 19, 50, 0, 31, 10, 46, 27, 63, 18, 60, 0, 20, 29, 39, 8, 26, 37, 5, 42, 0, 44, 39, 57, 17, 58, 41, 28, 37, 4, 32, 9, 44, 12, 31, 54, 10, 59, 14, 27, 53, 12, 36, 0, 47, 13, 63, 21, 58, 10, 24, 50, 27, 4, 26, 44, 53, 31, 0, 18, 42, 29, 33, 57, 4, 32, 26, 0, 38, 16, 61, 41, 53, 20, 0, 42, 44, 49, 27, 10, 56, 39, 0, 57, 15, 53, 49, 3, 61, 22, 47, 17, 5, 49, 26, 2, 63, 39, 10, 47, 27, 37, 23, 4, 59, 38, 10 }, + { 23, 39, 61, 3, 37, 28, 48, 31, 0, 34, 51, 23, 2, 26, 58, 0, 53, 11, 46, 1, 57, 29, 52, 14, 37, 61, 21, 35, 2, 49, 7, 34, 47, 55, 4, 33, 54, 13, 58, 52, 19, 50, 22, 7, 13, 29, 36, 11, 51, 17, 60, 25, 55, 4, 34, 51, 0, 35, 20, 48, 32, 3, 51, 30, 59, 28, 40, 3, 46, 29, 54, 43, 7, 62, 47, 11, 39, 4, 23, 46, 55, 8, 63, 5, 25, 37, 18, 46, 21, 56, 31, 5, 36, 8, 45, 58, 26, 15, 2, 36, 47, 21, 29, 44, 25, 34, 3, 27, 43, 10, 52, 0, 45, 30, 24, 36, 43, 18, 34, 59, 0, 52, 61, 15, 44, 19, 30, 49 }, + { 0, 27, 12, 43, 54, 9, 22, 53, 21, 46, 15, 55, 29, 47, 20, 33, 39, 28, 59, 35, 9, 44, 5, 24, 47, 7, 52, 17, 56, 22, 30, 42, 14, 26, 45, 18, 49, 1, 24, 34, 11, 27, 55, 32, 61, 47, 2, 56, 6, 44, 13, 47, 36, 27, 58, 22, 16, 47, 40, 4, 57, 38, 21, 45, 16, 9, 56, 26, 11, 38, 0, 22, 36, 17, 33, 57, 16, 30, 62, 15, 35, 40, 20, 45, 59, 10, 54, 8, 63, 13, 52, 27, 22, 57, 28, 12, 32, 51, 55, 22, 63, 4, 16, 54, 12, 62, 45, 19, 58, 13, 32, 40, 20, 56, 7, 57, 9, 54, 6, 29, 42, 21, 8, 55, 35, 47, 6, 41 }, + { 56, 33, 58, 32, 19, 35, 42, 6, 59, 11, 38, 5, 49, 12, 62, 7, 52, 17, 5, 25, 54, 20, 61, 31, 54, 27, 41, 11, 44, 5, 59, 12, 36, 51, 10, 61, 28, 41, 48, 9, 43, 63, 5, 40, 20, 8, 49, 26, 34, 21, 58, 1, 18, 45, 7, 39, 61, 26, 8, 50, 23, 10, 63, 5, 55, 37, 19, 49, 52, 15, 59, 47, 13, 54, 1, 25, 42, 58, 10, 48, 3, 27, 50, 1, 17, 48, 34, 41, 16, 40, 2, 45, 10, 39, 17, 61, 5, 38, 19, 9, 41, 31, 60, 38, 5, 23, 36, 8, 30, 55, 24, 63, 12, 48, 14, 51, 31, 20, 45, 25, 12, 50, 32, 2, 28, 11, 62, 14 }, + { 44, 16, 7, 48, 1, 62, 16, 50, 27, 33, 61, 25, 17, 44, 31, 14, 22, 43, 32, 48, 18, 40, 8, 36, 3, 16, 33, 62, 23, 38, 25, 53, 2, 21, 41, 6, 22, 15, 59, 29, 16, 37, 26, 15, 52, 42, 23, 15, 54, 39, 10, 30, 53, 11, 49, 24, 2, 43, 55, 17, 34, 44, 15, 31, 24, 44, 2, 32, 7, 35, 25, 5, 40, 45, 29, 51, 6, 21, 37, 52, 24, 60, 13, 31, 53, 23, 2, 28, 49, 24, 31, 60, 20, 51, 1, 34, 48, 14, 59, 33, 50, 1, 18, 33, 48, 60, 17, 51, 39, 6, 38, 2, 35, 29, 40, 23, 1, 62, 15, 53, 37, 17, 46, 57, 40, 51, 24, 22 }, + { 5, 37, 52, 24, 45, 13, 40, 3, 45, 9, 19, 42, 56, 4, 37, 46, 56, 2, 63, 11, 51, 1, 49, 13, 59, 45, 39, 1, 48, 15, 58, 9, 46, 31, 54, 35, 57, 38, 3, 46, 56, 4, 47, 57, 1, 30, 38, 63, 3, 46, 28, 63, 41, 14, 33, 62, 19, 32, 13, 28, 61, 1, 53, 42, 11, 60, 22, 62, 27, 42, 61, 31, 19, 8, 61, 12, 32, 55, 2, 18, 33, 12, 43, 36, 9, 62, 30, 55, 6, 58, 35, 7, 43, 29, 54, 23, 43, 30, 3, 25, 11, 45, 52, 28, 7, 14, 42, 1, 22, 50, 16, 53, 19, 59, 4, 46, 33, 41, 4, 35, 58, 5, 26, 13, 20, 2, 34, 54 }, + { 30, 63, 21, 10, 26, 55, 29, 59, 23, 39, 53, 1, 36, 24, 59, 27, 10, 34, 23, 38, 30, 60, 22, 42, 28, 19, 9, 57, 30, 19, 43, 33, 13, 63, 3, 19, 11, 50, 31, 20, 14, 34, 10, 35, 17, 59, 7, 31, 19, 25, 50, 5, 20, 57, 29, 6, 52, 41, 4, 46, 20, 37, 26, 17, 49, 6, 39, 18, 53, 14, 3, 49, 57, 23, 34, 48, 14, 41, 28, 38, 56, 6, 58, 25, 39, 19, 43, 15, 37, 11, 47, 18, 53, 4, 37, 9, 62, 21, 53, 40, 57, 24, 13, 40, 56, 26, 47, 31, 59, 25, 45, 27, 10, 43, 21, 61, 13, 27, 48, 9, 23, 43, 31, 62, 38, 59, 9, 47 }, + { 25, 4, 40, 60, 34, 6, 18, 36, 8, 57, 12, 30, 49, 14, 6, 54, 41, 16, 50, 6, 43, 15, 34, 4, 53, 24, 50, 35, 4, 51, 7, 55, 28, 24, 39, 44, 60, 7, 25, 62, 42, 53, 24, 61, 28, 45, 52, 12, 48, 37, 9, 35, 43, 3, 37, 48, 12, 58, 30, 52, 9, 59, 6, 57, 33, 29, 48, 4, 37, 45, 20, 34, 10, 39, 0, 60, 22, 45, 8, 63, 21, 42, 14, 49, 3, 56, 11, 46, 21, 61, 0, 42, 25, 13, 63, 17, 36, 8, 46, 16, 6, 35, 63, 0, 21, 37, 4, 57, 9, 34, 5, 61, 48, 32, 8, 37, 54, 17, 56, 30, 60, 0, 50, 16, 7, 29, 42, 17 }, + { 32, 50, 15, 48, 2, 43, 52, 25, 47, 16, 32, 63, 21, 52, 40, 19, 0, 61, 29, 58, 20, 56, 26, 46, 12, 55, 6, 22, 62, 32, 17, 40, 0, 49, 34, 8, 27, 32, 48, 0, 21, 39, 5, 44, 12, 6, 22, 40, 0, 57, 16, 60, 23, 17, 54, 22, 36, 15, 24, 39, 19, 34, 47, 23, 0, 54, 13, 51, 24, 9, 55, 16, 52, 27, 44, 20, 4, 54, 26, 49, 0, 30, 46, 16, 29, 51, 34, 4, 52, 28, 33, 15, 57, 39, 26, 49, 0, 56, 27, 31, 48, 20, 43, 29, 53, 11, 46, 19, 41, 13, 55, 18, 0, 57, 26, 51, 2, 44, 6, 38, 14, 40, 22, 45, 36, 53, 3, 57 }, + { 44, 12, 37, 28, 22, 57, 11, 38, 0, 51, 9, 41, 4, 29, 11, 47, 33, 45, 12, 26, 3, 36, 9, 63, 31, 16, 38, 44, 14, 47, 25, 61, 20, 58, 15, 47, 17, 57, 13, 36, 9, 51, 18, 29, 50, 36, 54, 20, 61, 27, 32, 13, 53, 44, 9, 27, 0, 63, 45, 2, 56, 10, 14, 43, 41, 28, 58, 11, 35, 60, 30, 41, 6, 63, 11, 51, 37, 32, 15, 10, 35, 53, 5, 61, 22, 7, 26, 59, 23, 9, 44, 48, 21, 3, 51, 32, 24, 41, 12, 61, 2, 55, 9, 15, 35, 58, 28, 15, 62, 30, 37, 23, 42, 29, 11, 17, 35, 24, 63, 20, 52, 28, 8, 55, 11, 23, 47, 19 }, + { 0, 56, 8, 53, 14, 31, 61, 20, 55, 28, 62, 18, 35, 60, 25, 57, 7, 23, 39, 54, 47, 17, 43, 0, 40, 59, 29, 2, 56, 10, 37, 5, 43, 11, 29, 52, 1, 23, 54, 41, 59, 30, 55, 1, 62, 15, 33, 4, 43, 10, 47, 39, 1, 31, 40, 60, 49, 33, 7, 55, 26, 50, 31, 61, 8, 18, 21, 32, 44, 1, 25, 47, 18, 36, 30, 23, 59, 7, 40, 59, 27, 19, 38, 32, 44, 54, 40, 17, 38, 60, 27, 6, 35, 55, 10, 14, 44, 5, 50, 17, 38, 26, 42, 50, 18, 3, 44, 52, 2, 49, 7, 52, 15, 46, 62, 39, 55, 10, 31, 48, 3, 58, 33, 18, 61, 34, 13, 59 }, + { 39, 27, 63, 20, 35, 41, 4, 45, 26, 5, 38, 13, 44, 2, 50, 17, 37, 52, 2, 13, 28, 58, 24, 51, 21, 8, 34, 48, 27, 42, 18, 51, 31, 56, 5, 36, 38, 44, 4, 17, 26, 11, 38, 23, 42, 8, 56, 39, 24, 51, 5, 56, 21, 59, 14, 6, 18, 42, 22, 35, 16, 37, 3, 25, 39, 46, 63, 5, 50, 17, 58, 8, 55, 3, 50, 12, 43, 17, 47, 2, 51, 9, 62, 12, 1, 35, 13, 50, 1, 37, 12, 51, 19, 29, 46, 59, 22, 58, 33, 45, 22, 60, 10, 32, 61, 39, 8, 33, 25, 36, 20, 60, 38, 4, 21, 5, 28, 45, 12, 18, 42, 11, 49, 1, 27, 40, 6, 30 }, + { 24, 16, 42, 1, 50, 10, 48, 17, 33, 43, 24, 48, 21, 55, 31, 42, 10, 21, 63, 35, 49, 6, 33, 13, 41, 53, 10, 20, 60, 6, 53, 26, 12, 41, 22, 60, 14, 28, 63, 33, 49, 3, 45, 16, 48, 26, 14, 46, 18, 30, 35, 26, 8, 50, 29, 51, 25, 57, 12, 47, 53, 9, 62, 20, 54, 2, 36, 15, 40, 28, 33, 13, 38, 24, 46, 1, 29, 56, 33, 20, 44, 24, 41, 26, 57, 20, 63, 8, 30, 55, 5, 41, 62, 8, 34, 2, 37, 10, 19, 6, 37, 1, 53, 23, 5, 27, 58, 22, 43, 12, 50, 26, 9, 34, 54, 32, 49, 1, 59, 37, 22, 46, 25, 36, 51, 15, 54, 46 }, + { 52, 7, 45, 33, 26, 58, 14, 60, 7, 54, 3, 58, 8, 34, 14, 5, 59, 30, 18, 44, 8, 22, 48, 62, 3, 26, 55, 38, 23, 16, 39, 1, 62, 24, 49, 9, 53, 19, 46, 7, 19, 60, 31, 58, 2, 34, 53, 7, 59, 2, 62, 42, 46, 19, 36, 11, 44, 4, 38, 28, 1, 43, 32, 51, 12, 29, 56, 22, 52, 2, 62, 49, 22, 60, 14, 35, 63, 5, 25, 57, 14, 53, 4, 46, 18, 31, 42, 22, 47, 20, 58, 31, 16, 43, 23, 54, 30, 42, 52, 57, 29, 49, 30, 13, 45, 48, 16, 55, 6, 63, 1, 44, 14, 58, 19, 47, 15, 24, 51, 34, 6, 55, 5, 63, 20, 41, 21, 9 }, + { 30, 62, 18, 55, 5, 23, 39, 29, 49, 30, 15, 36, 28, 46, 60, 25, 39, 46, 4, 32, 61, 40, 15, 30, 36, 45, 14, 2, 49, 33, 57, 45, 18, 32, 3, 45, 30, 2, 35, 52, 40, 27, 13, 21, 38, 63, 20, 28, 37, 23, 16, 10, 13, 55, 2, 62, 21, 32, 60, 17, 58, 23, 5, 40, 16, 48, 7, 45, 10, 26, 43, 19, 6, 31, 52, 21, 39, 16, 48, 9, 37, 28, 36, 55, 7, 48, 3, 59, 15, 45, 25, 1, 53, 13, 47, 7, 62, 15, 4, 25, 12, 41, 18, 60, 38, 11, 34, 19, 39, 31, 29, 56, 23, 42, 3, 27, 60, 41, 8, 16, 61, 29, 43, 9, 32, 2, 60, 34 }, + { 3, 38, 13, 37, 52, 44, 2, 19, 12, 42, 63, 19, 40, 1, 20, 50, 12, 55, 15, 56, 27, 1, 54, 11, 57, 18, 32, 63, 44, 4, 29, 13, 37, 61, 35, 16, 42, 57, 12, 22, 6, 55, 43, 10, 50, 5, 44, 11, 48, 52, 34, 58, 28, 41, 38, 30, 7, 52, 11, 49, 30, 14, 45, 27, 59, 34, 21, 38, 32, 58, 11, 36, 56, 42, 9, 41, 3, 54, 31, 42, 0, 60, 16, 11, 39, 24, 52, 33, 6, 36, 10, 40, 32, 60, 26, 20, 39, 28, 47, 34, 63, 8, 54, 3, 24, 56, 0, 51, 13, 47, 16, 40, 7, 35, 52, 11, 36, 4, 57, 30, 39, 13, 18, 50, 58, 28, 12, 48 }, + { 57, 24, 49, 21, 10, 31, 61, 36, 56, 0, 22, 53, 11, 56, 32, 7, 36, 27, 41, 9, 46, 19, 34, 42, 25, 7, 50, 9, 28, 21, 54, 8, 50, 7, 27, 59, 10, 25, 48, 62, 37, 0, 33, 58, 25, 18, 32, 61, 0, 15, 45, 5, 50, 3, 23, 55, 47, 17, 40, 6, 60, 34, 53, 8, 41, 0, 61, 13, 54, 4, 46, 28, 0, 17, 48, 27, 58, 13, 23, 61, 33, 21, 50, 30, 62, 8, 14, 29, 56, 27, 61, 49, 17, 2, 44, 11, 51, 0, 59, 17, 40, 20, 32, 47, 36, 21, 42, 28, 60, 4, 54, 10, 59, 17, 30, 62, 21, 43, 26, 48, 0, 56, 36, 25, 8, 44, 39, 17 }, + { 10, 42, 4, 59, 27, 47, 8, 23, 51, 32, 45, 6, 37, 26, 48, 43, 62, 0, 21, 53, 38, 12, 51, 5, 60, 47, 24, 37, 59, 15, 35, 47, 22, 55, 0, 50, 21, 40, 6, 29, 15, 52, 24, 8, 41, 55, 13, 29, 40, 56, 24, 31, 19, 33, 61, 15, 0, 35, 24, 42, 21, 2, 19, 57, 24, 15, 30, 50, 20, 25, 40, 16, 57, 34, 61, 8, 29, 45, 6, 49, 11, 47, 2, 44, 19, 57, 38, 50, 12, 42, 21, 4, 35, 52, 28, 56, 23, 36, 13, 45, 4, 52, 27, 14, 6, 62, 9, 45, 21, 37, 25, 46, 33, 49, 0, 44, 7, 53, 13, 19, 53, 31, 3, 47, 15, 56, 22, 51 }, + { 35, 28, 53, 32, 1, 16, 54, 40, 9, 17, 25, 58, 14, 59, 3, 22, 16, 51, 31, 5, 23, 58, 28, 17, 35, 20, 0, 42, 11, 52, 3, 31, 41, 17, 43, 13, 32, 54, 18, 60, 32, 45, 17, 49, 2, 36, 51, 22, 7, 36, 9, 63, 48, 12, 46, 26, 43, 28, 63, 13, 48, 37, 51, 33, 5, 47, 55, 9, 42, 63, 7, 51, 24, 12, 37, 19, 55, 34, 18, 38, 15, 28, 54, 34, 5, 43, 22, 0, 48, 14, 54, 24, 58, 9, 38, 5, 32, 55, 21, 30, 49, 9, 59, 43, 30, 51, 35, 26, 7, 53, 2, 22, 14, 27, 57, 18, 38, 24, 33, 45, 10, 41, 20, 60, 37, 5, 32, 0 }, + { 63, 19, 15, 40, 62, 35, 14, 28, 46, 61, 4, 49, 35, 10, 29, 54, 33, 8, 45, 62, 37, 1, 43, 55, 10, 52, 61, 30, 19, 40, 25, 62, 11, 38, 27, 58, 36, 3, 46, 8, 39, 4, 62, 28, 47, 20, 4, 54, 47, 27, 43, 1, 21, 38, 8, 58, 10, 54, 4, 56, 9, 26, 12, 39, 60, 27, 18, 37, 1, 31, 35, 5, 45, 50, 2, 43, 26, 1, 59, 23, 56, 40, 7, 26, 58, 17, 32, 63, 25, 39, 7, 31, 45, 19, 63, 15, 48, 8, 37, 61, 16, 34, 1, 56, 18, 3, 15, 58, 49, 32, 63, 41, 55, 5, 40, 22, 50, 6, 59, 2, 63, 23, 52, 11, 26, 61, 44, 23 }, + { 11, 56, 46, 6, 22, 43, 58, 3, 34, 21, 38, 30, 18, 44, 52, 13, 41, 57, 17, 28, 14, 49, 25, 7, 33, 39, 26, 6, 56, 48, 1, 20, 56, 5, 46, 9, 19, 51, 30, 25, 56, 21, 35, 14, 57, 42, 16, 33, 10, 57, 17, 59, 41, 25, 53, 37, 20, 40, 30, 18, 31, 62, 44, 22, 3, 44, 11, 48, 23, 53, 18, 60, 29, 22, 62, 15, 53, 47, 10, 41, 3, 19, 52, 36, 13, 46, 10, 35, 3, 61, 41, 16, 1, 50, 26, 42, 18, 46, 2, 25, 54, 20, 39, 23, 47, 31, 41, 12, 38, 17, 8, 19, 31, 48, 12, 61, 9, 54, 29, 35, 15, 38, 6, 43, 34, 14, 7, 47 }, + { 39, 2, 33, 26, 53, 8, 18, 50, 41, 12, 53, 1, 63, 24, 19, 39, 2, 24, 47, 10, 60, 38, 19, 63, 48, 4, 15, 45, 32, 14, 60, 36, 29, 53, 23, 63, 34, 12, 61, 1, 43, 11, 53, 30, 1, 26, 60, 45, 23, 39, 3, 29, 12, 50, 4, 16, 51, 3, 45, 36, 50, 1, 16, 54, 35, 14, 57, 30, 58, 9, 46, 14, 41, 10, 32, 38, 4, 30, 21, 51, 32, 63, 25, 1, 60, 27, 53, 18, 51, 22, 28, 55, 34, 12, 40, 3, 60, 29, 57, 41, 6, 44, 11, 53, 8, 61, 24, 57, 1, 28, 44, 59, 36, 3, 34, 25, 41, 31, 16, 44, 22, 47, 28, 58, 1, 49, 54, 29 }, + { 58, 25, 50, 13, 38, 30, 60, 24, 6, 57, 27, 42, 9, 45, 6, 61, 30, 50, 4, 34, 29, 3, 46, 13, 22, 42, 58, 28, 9, 39, 23, 44, 7, 15, 44, 2, 40, 15, 47, 41, 23, 37, 7, 59, 38, 11, 34, 6, 62, 14, 52, 35, 55, 19, 32, 61, 33, 24, 57, 6, 22, 59, 29, 7, 49, 25, 40, 3, 17, 39, 27, 52, 0, 55, 16, 57, 24, 61, 36, 6, 29, 12, 48, 39, 20, 44, 6, 40, 33, 5, 48, 10, 57, 36, 22, 51, 33, 9, 24, 12, 62, 29, 50, 35, 14, 43, 5, 33, 47, 52, 13, 23, 10, 51, 56, 16, 46, 1, 49, 4, 61, 9, 52, 18, 31, 21, 36, 17 }, + { 19, 42, 9, 48, 2, 44, 11, 37, 48, 20, 33, 16, 55, 35, 49, 15, 37, 20, 59, 16, 53, 22, 56, 31, 50, 11, 34, 54, 16, 51, 4, 49, 33, 53, 21, 28, 56, 24, 31, 9, 52, 16, 48, 24, 44, 13, 51, 20, 31, 49, 18, 6, 34, 2, 44, 14, 47, 8, 15, 43, 13, 41, 33, 52, 20, 61, 7, 51, 34, 62, 4, 20, 36, 33, 43, 8, 46, 13, 53, 17, 45, 42, 9, 31, 52, 11, 30, 56, 13, 59, 17, 44, 27, 6, 62, 11, 43, 17, 49, 38, 26, 2, 16, 27, 58, 21, 54, 18, 26, 5, 35, 61, 43, 27, 7, 39, 14, 58, 37, 55, 20, 33, 13, 40, 62, 10, 55, 5 }, + { 51, 14, 61, 29, 59, 20, 55, 31, 0, 49, 11, 60, 3, 26, 22, 56, 0, 40, 12, 43, 41, 8, 36, 0, 17, 57, 24, 2, 46, 26, 61, 18, 0, 38, 12, 59, 6, 49, 3, 57, 19, 63, 5, 33, 18, 54, 28, 56, 0, 43, 26, 46, 63, 27, 56, 22, 27, 54, 38, 28, 63, 24, 10, 45, 0, 31, 42, 21, 12, 25, 44, 49, 59, 6, 26, 50, 3, 34, 27, 59, 0, 35, 62, 16, 4, 58, 47, 0, 43, 24, 37, 2, 54, 20, 46, 31, 0, 56, 34, 5, 55, 45, 60, 37, 0, 40, 10, 38, 63, 46, 15, 20, 0, 53, 21, 62, 30, 11, 24, 27, 40, 0, 57, 26, 3, 45, 27, 35 }, +}; + +#else +#define DM_WIDTH 8 +#define DM_WIDTH_SHIFT 3 +#define DM_HEIGHT 8 +static const unsigned char DM[8][8] = +{ + { 0, 32, 8, 40, 2, 34, 10, 42 }, + { 48, 16, 56, 24, 50, 18, 58, 26 }, + { 12, 44, 4, 36, 14, 46, 6, 38 }, + { 60, 28, 52, 20, 62, 30, 54, 22 }, + { 3, 35, 11, 43, 1, 33, 9, 41 }, + { 51, 19, 59, 27, 49, 17, 57, 25 }, + { 15, 47, 7, 39, 13, 45, 5, 37 }, + { 63, 31, 55, 23, 61, 29, 53, 21 } +}; +#endif + +static unsigned int *DM_565 = NULL; + +static void +xlib_rgb_preprocess_dm_565 (void) +{ + int i; + unsigned int dith; + + if (DM_565 == NULL) + { + DM_565 = malloc(sizeof(unsigned int) * DM_WIDTH * DM_HEIGHT); + for (i = 0; i < DM_WIDTH * DM_HEIGHT; i++) + { + dith = DM[0][i] >> 3; + DM_565[i] = (dith << 20) | dith | (((7 - dith) >> 1) << 10); +#ifdef VERBOSE + printf ("%i %x %x\n", i, dith, DM_565[i]); +#endif + } + } +} + +static void +xlib_rgb_convert_8_d666 (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int x, y; + int bpl; + unsigned char *obuf, *obptr; + unsigned char *bptr, *bp2; + int r, g, b; + const unsigned char *dmp; + int dith; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax; + for (y = 0; y < height; y++) + { + dmp = DM[(y_align + y) & (DM_HEIGHT - 1)]; + bp2 = bptr; + obptr = obuf; + for (x = 0; x < width; x++) + { + r = *bp2++; + g = *bp2++; + b = *bp2++; + dith = (dmp[(x_align + x) & (DM_WIDTH - 1)] << 2) | 7; + r = ((r * 5) + dith) >> 8; + g = ((g * 5) + (262 - dith)) >> 8; + b = ((b * 5) + dith) >> 8; + obptr[0] = colorcube_d[(r << 6) | (g << 3) | b]; + obptr++; + } + bptr += rowstride; + obuf += bpl; + } +} + +static void +xlib_rgb_convert_8_d (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, + XlibRgbCmap *cmap) +{ + int x, y; + int bpl; + unsigned char *obuf, *obptr; + unsigned char *bptr, *bp2; + int r, g, b; + const unsigned char *dmp; + int dith; + int rs, gs, bs; + + bptr = buf; + bpl = image->bytes_per_line; + rs = image_info->nred_shades - 1; + gs = image_info->ngreen_shades - 1; + bs = image_info->nblue_shades - 1; + obuf = ((unsigned char *)image->data) + ay * bpl + ax; + for (y = 0; y < height; y++) + { + dmp = DM[(y_align + y) & (DM_HEIGHT - 1)]; + bp2 = bptr; + obptr = obuf; + for (x = 0; x < width; x++) + { + r = *bp2++; + g = *bp2++; + b = *bp2++; + dith = (dmp[(x_align + x) & (DM_WIDTH - 1)] << 2) | 7; + r = ((r * rs) + dith) >> 8; + g = ((g * gs) + (262 - dith)) >> 8; + b = ((b * bs) + dith) >> 8; + obptr[0] = colorcube_d[(r << 6) | (g << 3) | b]; + obptr++; + } + bptr += rowstride; + obuf += bpl; + } +} + +static void +xlib_rgb_convert_8_indexed (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int x, y; + int bpl; + unsigned char *obuf, *obptr; + unsigned char *bptr, *bp2; + unsigned char c; + unsigned char *lut; + + lut = cmap->lut; + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax; + for (y = 0; y < height; y++) + { + bp2 = bptr; + obptr = obuf; + for (x = 0; x < width; x++) + { + c = *bp2++; + obptr[0] = lut[c]; + obptr++; + } + bptr += rowstride; + obuf += bpl; + } +} + +static void +xlib_rgb_convert_gray8 (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int x, y; + int bpl; + unsigned char *obuf, *obptr; + unsigned char *bptr, *bp2; + int r, g, b; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax; + for (y = 0; y < height; y++) + { + bp2 = bptr; + obptr = obuf; + for (x = 0; x < width; x++) + { + r = *bp2++; + g = *bp2++; + b = *bp2++; + obptr[0] = (g + ((b + r) >> 1)) >> 1; + obptr++; + } + bptr += rowstride; + obuf += bpl; + } +} + +static void +xlib_rgb_convert_gray8_gray (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int y; + int bpl; + unsigned char *obuf; + unsigned char *bptr; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax; + for (y = 0; y < height; y++) + { + memcpy (obuf, bptr, (unsigned int)width); + bptr += rowstride; + obuf += bpl; + } +} + +#if X_BYTE_ORDER == X_LITTLE_ENDIAN +#define HAIRY_CONVERT_565 +#endif + +#ifdef HAIRY_CONVERT_565 +/* Render a 24-bit RGB image in buf into the GdkImage, without dithering. + This assumes native byte ordering - what should really be done is to + check whether static_image->byte_order is consistent with the _ENDIAN + config flag, and if not, use a different function. + + This one is even faster than the one below - its inner loop loads 3 + words (i.e. 4 24-bit pixels), does a lot of shifting and masking, + then writes 2 words. */ +static void +xlib_rgb_convert_565 (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int x, y; + unsigned char *obuf, *obptr; + int bpl; + unsigned char *bptr, *bp2; + unsigned char r, g, b; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax * 2; + for (y = 0; y < height; y++) + { + bp2 = bptr; + obptr = obuf; + if (((unsigned long)obuf | (unsigned long) bp2) & 3) + { + for (x = 0; x < width; x++) + { + r = *bp2++; + g = *bp2++; + b = *bp2++; + ((unsigned short *)obptr)[0] = ((r & 0xf8) << 8) | + ((g & 0xfc) << 3) | + (b >> 3); + obptr += 2; + } + } + else + { + for (x = 0; x < width - 3; x += 4) + { + unsigned int r1b0g0r0; + unsigned int g2r2b1g1; + unsigned int b3g3r3b2; + + r1b0g0r0 = ((unsigned int *)bp2)[0]; + g2r2b1g1 = ((unsigned int *)bp2)[1]; + b3g3r3b2 = ((unsigned int *)bp2)[2]; + ((unsigned int *)obptr)[0] = + ((r1b0g0r0 & 0xf8) << 8) | + ((r1b0g0r0 & 0xfc00) >> 5) | + ((r1b0g0r0 & 0xf80000) >> 19) | + (r1b0g0r0 & 0xf8000000) | + ((g2r2b1g1 & 0xfc) << 19) | + ((g2r2b1g1 & 0xf800) << 5); + ((unsigned int *)obptr)[1] = + ((g2r2b1g1 & 0xf80000) >> 8) | + ((g2r2b1g1 & 0xfc000000) >> 21) | + ((b3g3r3b2 & 0xf8) >> 3) | + ((b3g3r3b2 & 0xf800) << 16) | + ((b3g3r3b2 & 0xfc0000) << 3) | + ((b3g3r3b2 & 0xf8000000) >> 11); + bp2 += 12; + obptr += 8; + } + for (; x < width; x++) + { + r = *bp2++; + g = *bp2++; + b = *bp2++; + ((unsigned short *)obptr)[0] = ((r & 0xf8) << 8) | + ((g & 0xfc) << 3) | + (b >> 3); + obptr += 2; + } + } + bptr += rowstride; + obuf += bpl; + } +} +#else +/* Render a 24-bit RGB image in buf into the GdkImage, without dithering. + This assumes native byte ordering - what should really be done is to + check whether static_image->byte_order is consistent with the _ENDIAN + config flag, and if not, use a different function. + + This routine is faster than the one included with Gtk 1.0 for a number + of reasons: + + 1. Shifting instead of lookup tables (less memory traffic). + + 2. Much less register pressure, especially because shifts are + in the code. + + 3. A memcpy is avoided (i.e. the transfer function). + + 4. On big-endian architectures, byte swapping is avoided. + + That said, it wouldn't be hard to make it even faster - just make an + inner loop that reads 3 words (i.e. 4 24-bit pixels), does a lot of + shifting and masking, then writes 2 words. +*/ +static void +xlib_rgb_convert_565 (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int x, y; + unsigned char *obuf; + int bpl; + unsigned char *bptr, *bp2; + unsigned char r, g, b; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax * 2; + for (y = 0; y < height; y++) + { + bp2 = bptr; + for (x = 0; x < width; x++) + { + r = *bp2++; + g = *bp2++; + b = *bp2++; + ((unsigned short *)obuf)[x] = ((r & 0xf8) << 8) | + ((g & 0xfc) << 3) | + (b >> 3); + } + bptr += rowstride; + obuf += bpl; + } +} +#endif + +#ifdef HAIRY_CONVERT_565 +static void +xlib_rgb_convert_565_gray (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int x, y; + unsigned char *obuf, *obptr; + int bpl; + unsigned char *bptr, *bp2; + unsigned char g; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax * 2; + for (y = 0; y < height; y++) + { + bp2 = bptr; + obptr = obuf; + if (((unsigned long)obuf | (unsigned long) bp2) & 3) + { + for (x = 0; x < width; x++) + { + g = *bp2++; + ((unsigned short *)obptr)[0] = ((g & 0xf8) << 8) | + ((g & 0xfc) << 3) | + (g >> 3); + obptr += 2; + } + } + else + { + for (x = 0; x < width - 3; x += 4) + { + unsigned int g3g2g1g0; + + g3g2g1g0 = ((unsigned int *)bp2)[0]; + ((unsigned int *)obptr)[0] = + ((g3g2g1g0 & 0xf8) << 8) | + ((g3g2g1g0 & 0xfc) << 3) | + ((g3g2g1g0 & 0xf8) >> 3) | + (g3g2g1g0 & 0xf800) << 16 | + ((g3g2g1g0 & 0xfc00) << 11) | + ((g3g2g1g0 & 0xf800) << 5); + ((unsigned int *)obptr)[1] = + ((g3g2g1g0 & 0xf80000) >> 8) | + ((g3g2g1g0 & 0xfc0000) >> 13) | + ((g3g2g1g0 & 0xf80000) >> 19) | + (g3g2g1g0 & 0xf8000000) | + ((g3g2g1g0 & 0xfc000000) >> 5) | + ((g3g2g1g0 & 0xf8000000) >> 11); + bp2 += 4; + obptr += 8; + } + for (; x < width; x++) + { + g = *bp2++; + ((unsigned short *)obptr)[0] = ((g & 0xf8) << 8) | + ((g & 0xfc) << 3) | + (g >> 3); + obptr += 2; + } + } + bptr += rowstride; + obuf += bpl; + } +} +#else +static void +xlib_rgb_convert_565_gray (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int x, y; + unsigned char *obuf; + int bpl; + unsigned char *bptr, *bp2; + unsigned char g; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax * 2; + for (y = 0; y < height; y++) + { + bp2 = bptr; + for (x = 0; x < width; x++) + { + g = *bp2++; + ((unsigned short *)obuf)[x] = ((g & 0xf8) << 8) | + ((g & 0xfc) << 3) | + (g >> 3); + } + bptr += rowstride; + obuf += bpl; + } +} +#endif + +static void +xlib_rgb_convert_565_br (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int x, y; + unsigned char *obuf; + int bpl; + unsigned char *bptr, *bp2; + unsigned char r, g, b; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax * 2; + for (y = 0; y < height; y++) + { + bp2 = bptr; + for (x = 0; x < width; x++) + { + r = *bp2++; + g = *bp2++; + b = *bp2++; + /* final word is: + g4 g3 g2 b7 b6 b5 b4 b3 r7 r6 r5 r4 r3 g7 g6 g5 + */ + ((unsigned short *)obuf)[x] = (r & 0xf8) | + ((g & 0xe0) >> 5) | + ((g & 0x1c) << 11) | + ((b & 0xf8) << 5); + } + bptr += rowstride; + obuf += bpl; + } +} + +/* Thanks to Ray Lehtiniemi for a patch that resulted in a ~25% speedup + in this mode. */ +#ifdef HAIRY_CONVERT_565 +static void +xlib_rgb_convert_565_d (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + /* Now this is what I'd call some highly tuned code! */ + int x, y; + unsigned char *obuf, *obptr; + int bpl; + unsigned char *bptr, *bp2; + + width += x_align; + height += y_align; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax * 2; + for (y = y_align; y < height; y++) + { + unsigned int *dmp = DM_565 + ((y & (DM_HEIGHT - 1)) << DM_WIDTH_SHIFT); + bp2 = bptr; + obptr = obuf; + if (((unsigned long)obuf | (unsigned long) bp2) & 3) + { + for (x = x_align; x < width; x++) + { + int rgb = *bp2++ << 20; + rgb += *bp2++ << 10; + rgb += *bp2++; + rgb += dmp[x & (DM_WIDTH - 1)]; + rgb += 0x10040100 + - ((rgb & 0x1e0001e0) >> 5) + - ((rgb & 0x00070000) >> 6); + + ((unsigned short *)obptr)[0] = + ((rgb & 0x0f800000) >> 12) | + ((rgb & 0x0003f000) >> 7) | + ((rgb & 0x000000f8) >> 3); + obptr += 2; + } + } + else + { + for (x = x_align; x < width - 3; x += 4) + { + unsigned int r1b0g0r0; + unsigned int g2r2b1g1; + unsigned int b3g3r3b2; + unsigned int rgb02, rgb13; + + r1b0g0r0 = ((unsigned int *)bp2)[0]; + g2r2b1g1 = ((unsigned int *)bp2)[1]; + b3g3r3b2 = ((unsigned int *)bp2)[2]; + rgb02 = + ((r1b0g0r0 & 0xff) << 20) + + ((r1b0g0r0 & 0xff00) << 2) + + ((r1b0g0r0 & 0xff0000) >> 16) + + dmp[x & (DM_WIDTH - 1)]; + rgb02 += 0x10040100 + - ((rgb02 & 0x1e0001e0) >> 5) + - ((rgb02 & 0x00070000) >> 6); + rgb13 = + ((r1b0g0r0 & 0xff000000) >> 4) + + ((g2r2b1g1 & 0xff) << 10) + + ((g2r2b1g1 & 0xff00) >> 8) + + dmp[(x + 1) & (DM_WIDTH - 1)]; + rgb13 += 0x10040100 + - ((rgb13 & 0x1e0001e0) >> 5) + - ((rgb13 & 0x00070000) >> 6); + ((unsigned int *)obptr)[0] = + ((rgb02 & 0x0f800000) >> 12) | + ((rgb02 & 0x0003f000) >> 7) | + ((rgb02 & 0x000000f8) >> 3) | + ((rgb13 & 0x0f800000) << 4) | + ((rgb13 & 0x0003f000) << 9) | + ((rgb13 & 0x000000f8) << 13); + rgb02 = + ((g2r2b1g1 & 0xff0000) << 4) + + ((g2r2b1g1 & 0xff000000) >> 14) + + (b3g3r3b2 & 0xff) + + dmp[(x + 2) & (DM_WIDTH - 1)]; + rgb02 += 0x10040100 + - ((rgb02 & 0x1e0001e0) >> 5) + - ((rgb02 & 0x00070000) >> 6); + rgb13 = + ((b3g3r3b2 & 0xff00) << 12) + + ((b3g3r3b2 & 0xff0000) >> 6) + + ((b3g3r3b2 & 0xff000000) >> 24) + + dmp[(x + 3) & (DM_WIDTH - 1)]; + rgb13 += 0x10040100 + - ((rgb13 & 0x1e0001e0) >> 5) + - ((rgb13 & 0x00070000) >> 6); + ((unsigned int *)obptr)[1] = + ((rgb02 & 0x0f800000) >> 12) | + ((rgb02 & 0x0003f000) >> 7) | + ((rgb02 & 0x000000f8) >> 3) | + ((rgb13 & 0x0f800000) << 4) | + ((rgb13 & 0x0003f000) << 9) | + ((rgb13 & 0x000000f8) << 13); + bp2 += 12; + obptr += 8; + } + for (; x < width; x++) + { + int rgb = *bp2++ << 20; + rgb += *bp2++ << 10; + rgb += *bp2++; + rgb += dmp[x & (DM_WIDTH - 1)]; + rgb += 0x10040100 + - ((rgb & 0x1e0001e0) >> 5) + - ((rgb & 0x00070000) >> 6); + + ((unsigned short *)obptr)[0] = + ((rgb & 0x0f800000) >> 12) | + ((rgb & 0x0003f000) >> 7) | + ((rgb & 0x000000f8) >> 3); + obptr += 2; + } + } + bptr += rowstride; + obuf += bpl; + } +} +#else +static void +xlib_rgb_convert_565_d (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int x, y; + unsigned char *obuf; + int bpl; + unsigned char *bptr; + + width += x_align; + height += y_align; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + (ax - x_align) * 2; + + for (y = y_align; y < height; y++) + { + unsigned int *dmp = DM_565 + ((y & (DM_HEIGHT - 1)) << DM_WIDTH_SHIFT); + unsigned char *bp2 = bptr; + + for (x = x_align; x < width; x++) + { + int rgb = *bp2++ << 20; + rgb += *bp2++ << 10; + rgb += *bp2++; + rgb += dmp[x & (DM_WIDTH - 1)]; + rgb += 0x10040100 + - ((rgb & 0x1e0001e0) >> 5) + - ((rgb & 0x00070000) >> 6); + + ((unsigned short *)obuf)[x] = + ((rgb & 0x0f800000) >> 12) | + ((rgb & 0x0003f000) >> 7) | + ((rgb & 0x000000f8) >> 3); + } + + bptr += rowstride; + obuf += bpl; + } +} +#endif + +static void +xlib_rgb_convert_555 (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int x, y; + unsigned char *obuf; + int bpl; + unsigned char *bptr, *bp2; + unsigned char r, g, b; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax * 2; + for (y = 0; y < height; y++) + { + bp2 = bptr; + for (x = 0; x < width; x++) + { + r = *bp2++; + g = *bp2++; + b = *bp2++; + ((unsigned short *)obuf)[x] = ((r & 0xf8) << 7) | + ((g & 0xf8) << 2) | + (b >> 3); + } + bptr += rowstride; + obuf += bpl; + } +} + +static void +xlib_rgb_convert_555_br (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int x, y; + unsigned char *obuf; + int bpl; + unsigned char *bptr, *bp2; + unsigned char r, g, b; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax * 2; + for (y = 0; y < height; y++) + { + bp2 = bptr; + for (x = 0; x < width; x++) + { + r = *bp2++; + g = *bp2++; + b = *bp2++; + /* final word is: + g5 g4 g3 b7 b6 b5 b4 b3 0 r7 r6 r5 r4 r3 g7 g6 + */ + ((unsigned short *)obuf)[x] = ((r & 0xf8) >> 1) | + ((g & 0xc0) >> 6) | + ((g & 0x18) << 10) | + ((b & 0xf8) << 5); + } + bptr += rowstride; + obuf += bpl; + } +} + +static void +xlib_rgb_convert_888_msb (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int y; + unsigned char *obuf; + int bpl; + unsigned char *bptr; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax * 3; + for (y = 0; y < height; y++) + { + memcpy (obuf, bptr, (unsigned int)(width + width + width)); + bptr += rowstride; + obuf += bpl; + } +} + +/* todo: optimize this */ +#if X_BYTE_ORDER == X_LITTLE_ENDIAN +#define HAIRY_CONVERT_888 +#endif + +#ifdef HAIRY_CONVERT_888 +static void +xlib_rgb_convert_888_lsb (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int x, y; + unsigned char *obuf, *obptr; + int bpl; + unsigned char *bptr, *bp2; + int r, g, b; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax * 3; + for (y = 0; y < height; y++) + { + bp2 = bptr; + obptr = obuf; + if (((unsigned long)obuf | (unsigned long) bp2) & 3) + { + for (x = 0; x < width; x++) + { + r = bp2[0]; + g = bp2[1]; + b = bp2[2]; + *obptr++ = b; + *obptr++ = g; + *obptr++ = r; + bp2 += 3; + } + } + else + { + for (x = 0; x < width - 3; x += 4) + { + unsigned int r1b0g0r0; + unsigned int g2r2b1g1; + unsigned int b3g3r3b2; + + r1b0g0r0 = ((unsigned int *)bp2)[0]; + g2r2b1g1 = ((unsigned int *)bp2)[1]; + b3g3r3b2 = ((unsigned int *)bp2)[2]; + ((unsigned int *)obptr)[0] = + (r1b0g0r0 & 0xff00) | + ((r1b0g0r0 & 0xff0000) >> 16) | + (((g2r2b1g1 & 0xff00) | (r1b0g0r0 & 0xff)) << 16); + ((unsigned int *)obptr)[1] = + (g2r2b1g1 & 0xff0000ff) | + ((r1b0g0r0 & 0xff000000) >> 16) | + ((b3g3r3b2 & 0xff) << 16); + ((unsigned int *)obptr)[2] = + (((g2r2b1g1 & 0xff0000) | (b3g3r3b2 & 0xff000000)) >> 16) | + ((b3g3r3b2 & 0xff00) << 16) | + ((b3g3r3b2 & 0xff0000)); + bp2 += 12; + obptr += 12; + } + for (; x < width; x++) + { + r = bp2[0]; + g = bp2[1]; + b = bp2[2]; + *obptr++ = b; + *obptr++ = g; + *obptr++ = r; + bp2 += 3; + } + } + bptr += rowstride; + obuf += bpl; + } +} +#else +static void +xlib_rgb_convert_888_lsb (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int x, y; + unsigned char *obuf; + int bpl; + unsigned char *bptr, *bp2; + int r, g, b; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax * 3; + for (y = 0; y < height; y++) + { + bp2 = bptr; + for (x = 0; x < width; x++) + { + r = bp2[0]; + g = bp2[1]; + b = bp2[2]; + obuf[x * 3] = b; + obuf[x * 3 + 1] = g; + obuf[x * 3 + 2] = r; + bp2 += 3; + } + bptr += rowstride; + obuf += bpl; + } +} +#endif + +/* convert 24-bit packed to 32-bit unpacked */ +/* todo: optimize this */ +static void +xlib_rgb_convert_0888 (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int x, y; + unsigned char *obuf; + int bpl; + unsigned char *bptr, *bp2; + int r, g, b; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax * 4; + for (y = 0; y < height; y++) + { + bp2 = bptr; + for (x = 0; x < width; x++) + { + r = bp2[0]; + g = bp2[1]; + b = bp2[2]; + ((unsigned int *)obuf)[x] = (r << 16) | (g << 8) | b; + bp2 += 3; + } + bptr += rowstride; + obuf += bpl; + } +} + +static void +xlib_rgb_convert_0888_br (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int x, y; + unsigned char *obuf; + int bpl; + unsigned char *bptr, *bp2; + int r, g, b; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax * 4; + for (y = 0; y < height; y++) + { + bp2 = bptr; + for (x = 0; x < width; x++) + { + r = bp2[0]; + g = bp2[1]; + b = bp2[2]; + ((unsigned int *)obuf)[x] = (b << 24) | (g << 16) | (r << 8); + bp2 += 3; + } + bptr += rowstride; + obuf += bpl; + } +} + +static void +xlib_rgb_convert_8880_br (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int x, y; + unsigned char *obuf; + int bpl; + unsigned char *bptr, *bp2; + int r, g, b; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax * 4; + for (y = 0; y < height; y++) + { + bp2 = bptr; + for (x = 0; x < width; x++) + { + r = bp2[0]; + g = bp2[1]; + b = bp2[2]; + ((unsigned int *)obuf)[x] = (b << 16) | (g << 8) | r; + bp2 += 3; + } + bptr += rowstride; + obuf += bpl; + } +} + +/* Generic truecolor/directcolor conversion function. Slow, but these + are oddball modes. */ +static void +xlib_rgb_convert_truecolor_lsb (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, + XlibRgbCmap *cmap) +{ + int x, y; + unsigned char *obuf, *obptr; + int bpl; + unsigned char *bptr, *bp2; + int r, g, b; + int r_right, r_left; + int g_right, g_left; + int b_right, b_left; + int bpp; + unsigned int pixel; + int i; + + r_right = 8 - image_info->red_prec; + r_left = image_info->red_shift; + g_right = 8 - image_info->green_prec; + g_left = image_info->green_shift; + b_right = 8 - image_info->blue_prec; + b_left = image_info->blue_shift; + bpp = image_info->bpp; + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax * bpp; + for (y = 0; y < height; y++) + { + obptr = obuf; + bp2 = bptr; + for (x = 0; x < width; x++) + { + r = bp2[0]; + g = bp2[1]; + b = bp2[2]; + pixel = ((r >> r_right) << r_left) | + ((g >> g_right) << g_left) | + ((b >> b_right) << b_left); + for (i = 0; i < bpp; i++) + { + *obptr++ = pixel & 0xff; + pixel >>= 8; + } + bp2 += 3; + } + bptr += rowstride; + obuf += bpl; + } +} + +static void +xlib_rgb_convert_truecolor_lsb_d (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, + XlibRgbCmap *cmap) +{ + int x, y; + unsigned char *obuf, *obptr; + int bpl; + unsigned char *bptr, *bp2; + int r, g, b; + int r_right, r_left, r_prec; + int g_right, g_left, g_prec; + int b_right, b_left, b_prec; + int bpp; + unsigned int pixel; + int i; + int dith; + int r1, g1, b1; + const unsigned char *dmp; + + r_right = 8 - image_info->red_prec; + r_left = image_info->red_shift; + r_prec = image_info->red_prec; + g_right = 8 - image_info->green_prec; + g_left = image_info->green_shift; + g_prec = image_info->green_prec; + b_right = 8 - image_info->blue_prec; + b_left = image_info->blue_shift; + b_prec = image_info->blue_prec; + bpp = image_info->bpp; + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax * bpp; + for (y = 0; y < height; y++) + { + dmp = DM[(y_align + y) & (DM_HEIGHT - 1)]; + obptr = obuf; + bp2 = bptr; + for (x = 0; x < width; x++) + { + r = bp2[0]; + g = bp2[1]; + b = bp2[2]; + dith = dmp[(x_align + x) & (DM_WIDTH - 1)] << 2; + r1 = r + (dith >> r_prec); + g1 = g + ((252 - dith) >> g_prec); + b1 = b + (dith >> b_prec); + pixel = (((r1 - (r1 >> r_prec)) >> r_right) << r_left) | + (((g1 - (g1 >> g_prec)) >> g_right) << g_left) | + (((b1 - (b1 >> b_prec)) >> b_right) << b_left); + for (i = 0; i < bpp; i++) + { + *obptr++ = pixel & 0xff; + pixel >>= 8; + } + bp2 += 3; + } + bptr += rowstride; + obuf += bpl; + } +} + +static void +xlib_rgb_convert_truecolor_msb (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, + XlibRgbCmap *cmap) +{ + int x, y; + unsigned char *obuf, *obptr; + int bpl; + unsigned char *bptr, *bp2; + int r, g, b; + int r_right, r_left; + int g_right, g_left; + int b_right, b_left; + int bpp; + unsigned int pixel; + int shift, shift_init; + + r_right = 8 - image_info->red_prec; + r_left = image_info->red_shift; + g_right = 8 - image_info->green_prec; + g_left = image_info->green_shift; + b_right = 8 - image_info->blue_prec; + b_left = image_info->blue_shift; + bpp = image_info->bpp; + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax * bpp; + shift_init = (bpp - 1) << 3; + for (y = 0; y < height; y++) + { + obptr = obuf; + bp2 = bptr; + for (x = 0; x < width; x++) + { + r = bp2[0]; + g = bp2[1]; + b = bp2[2]; + pixel = ((r >> r_right) << r_left) | + ((g >> g_right) << g_left) | + ((b >> b_right) << b_left); + for (shift = shift_init; shift >= 0; shift -= 8) + { + *obptr++ = (pixel >> shift) & 0xff; + } + bp2 += 3; + } + bptr += rowstride; + obuf += bpl; + } +} + +static void +xlib_rgb_convert_truecolor_msb_d (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, + XlibRgbCmap *cmap) +{ + int x, y; + unsigned char *obuf, *obptr; + int bpl; + unsigned char *bptr, *bp2; + int r, g, b; + int r_right, r_left, r_prec; + int g_right, g_left, g_prec; + int b_right, b_left, b_prec; + int bpp; + unsigned int pixel; + int shift, shift_init; + int dith; + int r1, g1, b1; + const unsigned char *dmp; + + r_right = 8 - image_info->red_prec; + r_left = image_info->red_shift; + r_prec = image_info->red_prec; + g_right = 8 - image_info->green_prec; + g_left = image_info->green_shift; + g_prec = image_info->green_prec; + b_right = 8 - image_info->blue_prec; + b_left = image_info->blue_shift; + b_prec = image_info->blue_prec; + bpp = image_info->bpp; + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax * bpp; + shift_init = (bpp - 1) << 3; + for (y = 0; y < height; y++) + { + dmp = DM[(y_align + y) & (DM_HEIGHT - 1)]; + obptr = obuf; + bp2 = bptr; + for (x = 0; x < width; x++) + { + r = bp2[0]; + g = bp2[1]; + b = bp2[2]; + dith = dmp[(x_align + x) & (DM_WIDTH - 1)] << 2; + r1 = r + (dith >> r_prec); + g1 = g + ((252 - dith) >> g_prec); + b1 = b + (dith >> b_prec); + pixel = (((r1 - (r1 >> r_prec)) >> r_right) << r_left) | + (((g1 - (g1 >> g_prec)) >> g_right) << g_left) | + (((b1 - (b1 >> b_prec)) >> b_right) << b_left); + for (shift = shift_init; shift >= 0; shift -= 8) + { + *obptr++ = (pixel >> shift) & 0xff; + } + bp2 += 3; + } + bptr += rowstride; + obuf += bpl; + } +} + +/* This actually works for depths from 3 to 7 */ +static void +xlib_rgb_convert_4 (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, + XlibRgbCmap *cmap) +{ + int x, y; + int bpl; + unsigned char *obuf, *obptr; + unsigned char *bptr, *bp2; + int r, g, b; + const unsigned char *dmp; + int dith; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax; + for (y = 0; y < height; y++) + { + dmp = DM[(y_align + y) & (DM_HEIGHT - 1)]; + bp2 = bptr; + obptr = obuf; + for (x = 0; x < width; x += 1) + { + r = *bp2++; + g = *bp2++; + b = *bp2++; + dith = (dmp[(x_align + x) & (DM_WIDTH - 1)] << 2) | 3; + obptr[0] = colorcube_d[(((r + dith) & 0x100) >> 2) | + (((g + 258 - dith) & 0x100) >> 5) | + (((b + dith) & 0x100) >> 8)]; + obptr++; + } + bptr += rowstride; + obuf += bpl; + } +} + +/* This actually works for depths from 3 to 7 */ +static void +xlib_rgb_convert_gray4 (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int x, y; + int bpl; + unsigned char *obuf, *obptr; + unsigned char *bptr, *bp2; + int r, g, b; + int shift; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax; + shift = 9 - image_info->x_visual_info->depth; + for (y = 0; y < height; y++) + { + bp2 = bptr; + obptr = obuf; + for (x = 0; x < width; x++) + { + r = *bp2++; + g = *bp2++; + b = *bp2++; + obptr[0] = (g + ((b + r) >> 1)) >> shift; + obptr++; + } + bptr += rowstride; + obuf += bpl; + } +} + +static void +xlib_rgb_convert_gray4_pack (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int x, y; + int bpl; + unsigned char *obuf, *obptr; + unsigned char *bptr, *bp2; + int r, g, b; + int shift; + unsigned char pix0, pix1; + /* todo: this is hardcoded to big-endian. Make endian-agile. */ + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + (ax >> 1); + shift = 9 - image_info->x_visual_info->depth; + for (y = 0; y < height; y++) + { + bp2 = bptr; + obptr = obuf; + for (x = 0; x < width; x += 2) + { + r = *bp2++; + g = *bp2++; + b = *bp2++; + pix0 = (g + ((b + r) >> 1)) >> shift; + r = *bp2++; + g = *bp2++; + b = *bp2++; + pix1 = (g + ((b + r) >> 1)) >> shift; + obptr[0] = (pix0 << 4) | pix1; + obptr++; + } + if (width & 1) + { + r = *bp2++; + g = *bp2++; + b = *bp2++; + pix0 = (g + ((b + r) >> 1)) >> shift; + obptr[0] = (pix0 << 4); + } + bptr += rowstride; + obuf += bpl; + } +} + +/* This actually works for depths from 3 to 7 */ +static void +xlib_rgb_convert_gray4_d (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int x, y; + int bpl; + unsigned char *obuf, *obptr; + unsigned char *bptr, *bp2; + int r, g, b; + const unsigned char *dmp; + int prec, right; + int gray; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + ax; + prec = image_info->x_visual_info->depth; + right = 8 - prec; + for (y = 0; y < height; y++) + { + bp2 = bptr; + obptr = obuf; + dmp = DM[(y_align + y) & (DM_HEIGHT - 1)]; + for (x = 0; x < width; x++) + { + r = *bp2++; + g = *bp2++; + b = *bp2++; + gray = (g + ((b + r) >> 1)) >> 1; + gray += (dmp[(x_align + x) & (DM_WIDTH - 1)] << 2) >> prec; + obptr[0] = (gray - (gray >> prec)) >> right; + obptr++; + } + bptr += rowstride; + obuf += bpl; + } +} + +static void +xlib_rgb_convert_gray4_d_pack (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + int x, y; + int bpl; + unsigned char *obuf, *obptr; + unsigned char *bptr, *bp2; + int r, g, b; + const unsigned char *dmp; + int prec, right; + int gray; + unsigned char pix0, pix1; + /* todo: this is hardcoded to big-endian. Make endian-agile. */ + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + (ax >> 1); + prec = image_info->x_visual_info->depth; + right = 8 - prec; + for (y = 0; y < height; y++) + { + bp2 = bptr; + obptr = obuf; + dmp = DM[(y_align + y) & (DM_HEIGHT - 1)]; + for (x = 0; x < width; x += 2) + { + r = *bp2++; + g = *bp2++; + b = *bp2++; + gray = (g + ((b + r) >> 1)) >> 1; + gray += (dmp[(x_align + x) & (DM_WIDTH - 1)] << 2) >> prec; + pix0 = (gray - (gray >> prec)) >> right; + r = *bp2++; + g = *bp2++; + b = *bp2++; + gray = (g + ((b + r) >> 1)) >> 1; + gray += (dmp[(x_align + x + 1) & (DM_WIDTH - 1)] << 2) >> prec; + pix1 = (gray - (gray >> prec)) >> right; + obptr[0] = (pix0 << 4) | pix1; + obptr++; + } + if (width & 1) + { + r = *bp2++; + g = *bp2++; + b = *bp2++; + gray = (g + ((b + r) >> 1)) >> 1; + gray += (dmp[(x_align + x + 1) & (DM_WIDTH - 1)] << 2) >> prec; + pix0 = (gray - (gray >> prec)) >> right; + obptr[0] = (pix0 << 4); + } + bptr += rowstride; + obuf += bpl; + } +} + +static void +xlib_rgb_convert_1 (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, + XlibRgbCmap *cmap) +{ + int x, y; + int bpl; + unsigned char *obuf, *obptr; + unsigned char *bptr, *bp2; + int r, g, b; + const unsigned char *dmp; + int dith; + unsigned char byte; + + bptr = buf; + bpl = image->bytes_per_line; + obuf = ((unsigned char *)image->data) + ay * bpl + (ax >> 3); + byte = 0; /* unnecessary, but it keeps gcc from complaining */ + for (y = 0; y < height; y++) + { + dmp = DM[(y_align + y) & (DM_HEIGHT - 1)]; + bp2 = bptr; + obptr = obuf; + for (x = 0; x < width; x++) + { + r = *bp2++; + g = *bp2++; + b = *bp2++; + dith = (dmp[(x_align + x) & (DM_WIDTH - 1)] << 4) | 4; + byte += byte + (r + g + g + b + dith > 1020); + if ((x & 7) == 7) + { + obptr[0] = byte; + obptr++; + } + } + if (x & 7) + obptr[0] = byte << (8 - (x & 7)); + bptr += rowstride; + obuf += bpl; + } +} + +/* Returns a pointer to the stage buffer. */ +static unsigned char * +xlib_rgb_ensure_stage (void) +{ + if (image_info->stage_buf == NULL) + image_info->stage_buf = malloc (IMAGE_HEIGHT * STAGE_ROWSTRIDE); + return image_info->stage_buf; +} + +/* This is slow. Speed me up, please. */ +static void +xlib_rgb_32_to_stage (unsigned char *buf, int rowstride, int width, int height) +{ + int x, y; + unsigned char *pi_start, *po_start; + unsigned char *pi, *po; + + pi_start = buf; + po_start = xlib_rgb_ensure_stage (); + for (y = 0; y < height; y++) + { + pi = pi_start; + po = po_start; + for (x = 0; x < width; x++) + { + *po++ = *pi++; + *po++ = *pi++; + *po++ = *pi++; + pi++; + } + pi_start += rowstride; + po_start += STAGE_ROWSTRIDE; + } +} + +/* Generic 32bit RGB conversion function - convert to 24bit packed, then + go from there. */ +static void +xlib_rgb_convert_32_generic (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + xlib_rgb_32_to_stage (buf, rowstride, width, height); + + (*image_info->conv) (image, ax, ay, width, height, + image_info->stage_buf, STAGE_ROWSTRIDE, + x_align, y_align, cmap); +} + +/* Generic 32bit RGB conversion function - convert to 24bit packed, then + go from there. */ +static void +xlib_rgb_convert_32_generic_d (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + xlib_rgb_32_to_stage (buf, rowstride, width, height); + + (*image_info->conv_d) (image, ax, ay, width, height, + image_info->stage_buf, STAGE_ROWSTRIDE, + x_align, y_align, cmap); +} + +/* This is slow. Speed me up, please. */ +static void +xlib_rgb_gray_to_stage (unsigned char *buf, int rowstride, int width, int height) +{ + int x, y; + unsigned char *pi_start, *po_start; + unsigned char *pi, *po; + unsigned char gray; + + pi_start = buf; + po_start = xlib_rgb_ensure_stage (); + for (y = 0; y < height; y++) + { + pi = pi_start; + po = po_start; + for (x = 0; x < width; x++) + { + gray = *pi++; + *po++ = gray; + *po++ = gray; + *po++ = gray; + } + pi_start += rowstride; + po_start += STAGE_ROWSTRIDE; + } +} + +/* Generic gray conversion function - convert to 24bit packed, then go + from there. */ +static void +xlib_rgb_convert_gray_generic (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + xlib_rgb_gray_to_stage (buf, rowstride, width, height); + + (*image_info->conv) (image, ax, ay, width, height, + image_info->stage_buf, STAGE_ROWSTRIDE, + x_align, y_align, cmap); +} + +static void +xlib_rgb_convert_gray_generic_d (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + xlib_rgb_gray_to_stage (buf, rowstride, width, height); + + (*image_info->conv_d) (image, ax, ay, width, height, + image_info->stage_buf, STAGE_ROWSTRIDE, + x_align, y_align, cmap); +} + +/* Render grayscale using indexed method. */ +static void +xlib_rgb_convert_gray_cmap (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + (*image_info->conv_indexed) (image, ax, ay, width, height, + buf, rowstride, + x_align, y_align, image_info->gray_cmap); +} + +#if 0 +static void +xlib_rgb_convert_gray_cmap_d (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + (*image_info->conv_indexed_d) (image, ax, ay, width, height, + buf, rowstride, + x_align, y_align, image_info->gray_cmap); +} +#endif + +/* This is slow. Speed me up, please. */ +static void +xlib_rgb_indexed_to_stage (unsigned char *buf, int rowstride, int width, int height, + XlibRgbCmap *cmap) +{ + int x, y; + unsigned char *pi_start, *po_start; + unsigned char *pi, *po; + int rgb; + + pi_start = buf; + po_start = xlib_rgb_ensure_stage (); + for (y = 0; y < height; y++) + { + pi = pi_start; + po = po_start; + for (x = 0; x < width; x++) + { + rgb = cmap->colors[*pi++]; + *po++ = rgb >> 16; + *po++ = (rgb >> 8) & 0xff; + *po++ = rgb & 0xff; + } + pi_start += rowstride; + po_start += STAGE_ROWSTRIDE; + } +} + +/* Generic gray conversion function - convert to 24bit packed, then go + from there. */ +static void +xlib_rgb_convert_indexed_generic (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, XlibRgbCmap *cmap) +{ + xlib_rgb_indexed_to_stage (buf, rowstride, width, height, cmap); + + (*image_info->conv) (image, ax, ay, width, height, + image_info->stage_buf, STAGE_ROWSTRIDE, + x_align, y_align, cmap); +} + +static void +xlib_rgb_convert_indexed_generic_d (XImage *image, + int ax, int ay, int width, int height, + unsigned char *buf, int rowstride, + int x_align, int y_align, + XlibRgbCmap *cmap) +{ + xlib_rgb_indexed_to_stage (buf, rowstride, width, height, cmap); + + (*image_info->conv_d) (image, ax, ay, width, height, + image_info->stage_buf, STAGE_ROWSTRIDE, + x_align, y_align, cmap); +} + +/* Select a conversion function based on the visual and a + representative image. */ +static void +xlib_rgb_select_conv (XImage *image, ByteOrder byte_order) +{ + int depth, byterev; + int vtype; /* visual type */ + int bpp; /* bits per pixel - from the visual */ + unsigned int red_mask, green_mask, blue_mask; + XlibRgbConvFunc conv, conv_d; + XlibRgbConvFunc conv_32, conv_32_d; + XlibRgbConvFunc conv_gray, conv_gray_d; + XlibRgbConvFunc conv_indexed, conv_indexed_d; + Bool mask_rgb, mask_bgr; + + depth = image_info->x_visual_info->depth; + bpp = image->bits_per_pixel; + if (xlib_rgb_verbose) + printf ("Chose visual 0x%x, image bpp=%d, %s first\n", + (int)image_info->x_visual_info->visual->visualid, + bpp, byte_order == LSB_FIRST ? "lsb" : "msb"); + +#if X_BYTE_ORDER == X_BIG_ENDIAN + byterev = (byte_order == LSB_FIRST); +#else + byterev = (byte_order == MSB_FIRST); +#endif + + vtype = image_info->x_visual_info->class; + if (vtype == DirectColor) + vtype = TrueColor; + + red_mask = image_info->x_visual_info->red_mask; + green_mask = image_info->x_visual_info->green_mask; + blue_mask = image_info->x_visual_info->blue_mask; + + mask_rgb = red_mask == 0xff0000 && green_mask == 0xff00 && blue_mask == 0xff; + mask_bgr = red_mask == 0xff && green_mask == 0xff00 && blue_mask == 0xff0000; + + conv = NULL; + conv_d = NULL; + + conv_32 = xlib_rgb_convert_32_generic; + conv_32_d = xlib_rgb_convert_32_generic_d; + + conv_gray = xlib_rgb_convert_gray_generic; + conv_gray_d = xlib_rgb_convert_gray_generic_d; + + conv_indexed = xlib_rgb_convert_indexed_generic; + conv_indexed_d = xlib_rgb_convert_indexed_generic_d; + + image_info->dith_default = FALSE; + + if (image_info->bitmap) + conv = xlib_rgb_convert_1; + else if (bpp == 16 && depth == 16 && !byterev && + red_mask == 0xf800 && green_mask == 0x7e0 && blue_mask == 0x1f) + { + conv = xlib_rgb_convert_565; + conv_d = xlib_rgb_convert_565_d; + conv_gray = xlib_rgb_convert_565_gray; + xlib_rgb_preprocess_dm_565 (); + } + else if (bpp == 16 && depth == 16 && + vtype == TrueColor&& byterev && + red_mask == 0xf800 && green_mask == 0x7e0 && blue_mask == 0x1f) + conv = xlib_rgb_convert_565_br; + + else if (bpp == 16 && depth == 15 && + vtype == TrueColor && !byterev && + red_mask == 0x7c00 && green_mask == 0x3e0 && blue_mask == 0x1f) + conv = xlib_rgb_convert_555; + + else if (bpp == 16 && depth == 15 && + vtype == TrueColor && byterev && + red_mask == 0x7c00 && green_mask == 0x3e0 && blue_mask == 0x1f) + conv = xlib_rgb_convert_555_br; + + /* I'm not 100% sure about the 24bpp tests - but testing will show*/ + else if (bpp == 24 && depth == 24 && vtype == TrueColor && + ((mask_rgb && byte_order == LSB_FIRST) || + (mask_bgr && byte_order == MSB_FIRST))) + conv = xlib_rgb_convert_888_lsb; + else if (bpp == 24 && depth == 24 && vtype == TrueColor && + ((mask_rgb && byte_order == MSB_FIRST) || + (mask_bgr && byte_order == LSB_FIRST))) + conv = xlib_rgb_convert_888_msb; +#if X_BYTE_ORDER == X_BIG_ENDIAN + else if (bpp == 32 && depth == 24 && vtype == TrueColor && + (mask_rgb && byte_order == LSB_FIRST)) + conv = xlib_rgb_convert_0888_br; + else if (bpp == 32 && depth == 24 && vtype == TrueColor && + (mask_rgb && byte_order == MSB_FIRST)) + conv = xlib_rgb_convert_0888; + else if (bpp == 32 && depth == 24 && vtype == TrueColor && + (mask_bgr && byte_order == MSB_FIRST)) + conv = xlib_rgb_convert_8880_br; +#else + else if (bpp == 32 && depth == 24 && vtype == TrueColor && + (mask_rgb && byte_order == MSB_FIRST)) + conv = xlib_rgb_convert_0888_br; + else if (bpp == 32 && (depth == 32 || depth == 24) && vtype == TrueColor && + (mask_rgb && byte_order == LSB_FIRST)) + conv = xlib_rgb_convert_0888; + else if (bpp == 32 && depth == 24 && vtype == TrueColor && + (mask_bgr && byte_order == LSB_FIRST)) + conv = xlib_rgb_convert_8880_br; +#endif + + else if (vtype == TrueColor && byte_order == LSB_FIRST) + { + conv = xlib_rgb_convert_truecolor_lsb; + conv_d = xlib_rgb_convert_truecolor_lsb_d; + } + else if (vtype == TrueColor && byte_order == MSB_FIRST) + { + conv = xlib_rgb_convert_truecolor_msb; + conv_d = xlib_rgb_convert_truecolor_msb_d; + } + else if (bpp == 8 && depth == 8 && (vtype == PseudoColor +#ifdef ENABLE_GRAYSCALE + || vtype == GrayScale +#endif + )) + { + image_info->dith_default = TRUE; + conv = xlib_rgb_convert_8; + if (vtype != GrayScale) + { + if (image_info->nred_shades == 6 && + image_info->ngreen_shades == 6 && + image_info->nblue_shades == 6) + conv_d = xlib_rgb_convert_8_d666; + else + conv_d = xlib_rgb_convert_8_d; + } + conv_indexed = xlib_rgb_convert_8_indexed; + conv_gray = xlib_rgb_convert_gray_cmap; + } + else if (bpp == 8 && depth == 8 && (vtype == StaticGray +#ifdef not_ENABLE_GRAYSCALE + || vtype == GrayScale +#endif + )) + { + conv = xlib_rgb_convert_gray8; + conv_gray = xlib_rgb_convert_gray8_gray; + } + else if (bpp == 8 && depth < 8 && depth >= 2 && + (vtype == StaticGray + || vtype == GrayScale)) + { + conv = xlib_rgb_convert_gray4; + conv_d = xlib_rgb_convert_gray4_d; + } + else if (bpp == 8 && depth < 8 && depth >= 3) + { + conv = xlib_rgb_convert_4; + } + else if (bpp == 4 && depth <= 4 && depth >= 2 && + (vtype == StaticGray + || vtype == GrayScale)) + { + conv = xlib_rgb_convert_gray4_pack; + conv_d = xlib_rgb_convert_gray4_d_pack; + } + + if (conv_d == NULL) + conv_d = conv; + + image_info->conv = conv; + image_info->conv_d = conv_d; + + image_info->conv_32 = conv_32; + image_info->conv_32_d = conv_32_d; + + image_info->conv_gray = conv_gray; + image_info->conv_gray_d = conv_gray_d; + + image_info->conv_indexed = conv_indexed; + image_info->conv_indexed_d = conv_indexed_d; +} + +static int horiz_idx; +static int horiz_y = IMAGE_HEIGHT; +static int vert_idx; +static int vert_x = IMAGE_WIDTH; +static int tile_idx; +static int tile_x = IMAGE_WIDTH; +static int tile_y1 = IMAGE_HEIGHT; +static int tile_y2 = IMAGE_HEIGHT; + +#ifdef VERBOSE +static int sincelast; +#endif + +/* Defining NO_FLUSH can cause inconsistent screen updates, but is useful + for performance evaluation. */ + +#undef NO_FLUSH + +static int +xlib_rgb_alloc_scratch_image (void) +{ + if (static_image_idx == N_IMAGES) + { +#ifndef NO_FLUSH + XFlush(image_info->display); +#endif +#ifdef VERBOSE + printf ("flush, %d puts since last flush\n", sincelast); + sincelast = 0; +#endif + static_image_idx = 0; + horiz_y = IMAGE_HEIGHT; + vert_x = IMAGE_WIDTH; + tile_x = IMAGE_WIDTH; + tile_y1 = tile_y2 = IMAGE_HEIGHT; + } + return static_image_idx++; +} + +static XImage * +xlib_rgb_alloc_scratch (int width, int height, int *ax, int *ay) +{ + XImage *image; + int idx; + + if (width >= (IMAGE_WIDTH >> 1)) + { + if (height >= (IMAGE_HEIGHT >> 1)) + { + idx = xlib_rgb_alloc_scratch_image (); + *ax = 0; + *ay = 0; + } + else + { + if (height + horiz_y > IMAGE_HEIGHT) + { + horiz_idx = xlib_rgb_alloc_scratch_image (); + horiz_y = 0; + } + idx = horiz_idx; + *ax = 0; + *ay = horiz_y; + horiz_y += height; + } + } + else + { + if (height >= (IMAGE_HEIGHT >> 1)) + { + if (width + vert_x > IMAGE_WIDTH) + { + vert_idx = xlib_rgb_alloc_scratch_image (); + vert_x = 0; + } + idx = vert_idx; + *ax = vert_x; + *ay = 0; + /* using 3 and -4 would be slightly more efficient on 32-bit machines + with > 1bpp displays */ + vert_x += (width + 7) & -8; + } + else + { + if (width + tile_x > IMAGE_WIDTH) + { + tile_y1 = tile_y2; + tile_x = 0; + } + if (height + tile_y1 > IMAGE_HEIGHT) + { + tile_idx = xlib_rgb_alloc_scratch_image (); + tile_x = 0; + tile_y1 = 0; + tile_y2 = 0; + } + if (height + tile_y1 > tile_y2) + tile_y2 = height + tile_y1; + idx = tile_idx; + *ax = tile_x; + *ay = tile_y1; + tile_x += (width + 7) & -8; + } + } + image = static_image[idx]; +#ifdef VERBOSE + printf ("index %d, x %d, y %d (%d x %d)\n", idx, *ax, *ay, width, height); + sincelast++; +#endif + return image; +} + +static void +xlib_draw_rgb_image_core (Drawable drawable, + GC gc, + int x, + int y, + int width, + int height, + unsigned char *buf, + int pixstride, + int rowstride, + XlibRgbConvFunc conv, + XlibRgbCmap *cmap, + int xdith, + int ydith) +{ + int ay, ax; + int xs0, ys0; + XImage *image; + int width1, height1; + unsigned char *buf_ptr; + + if (image_info->bitmap) + { + if (image_info->own_gc == 0) + { + XColor color; + + image_info->own_gc = XCreateGC(image_info->display, + drawable, + 0, NULL); + color.pixel = WhitePixel(image_info->display, + image_info->screen_num); + XSetForeground(image_info->display, image_info->own_gc, color.pixel); + color.pixel = BlackPixel(image_info->display, + image_info->screen_num); + XSetBackground(image_info->display, image_info->own_gc, color.pixel); + } + gc = image_info->own_gc; + } + for (ay = 0; ay < height; ay += IMAGE_HEIGHT) + { + height1 = MIN (height - ay, IMAGE_HEIGHT); + for (ax = 0; ax < width; ax += IMAGE_WIDTH) + { + width1 = MIN (width - ax, IMAGE_WIDTH); + buf_ptr = buf + ay * rowstride + ax * pixstride; + + image = xlib_rgb_alloc_scratch (width1, height1, &xs0, &ys0); + + conv (image, xs0, ys0, width1, height1, buf_ptr, rowstride, + x + ax + xdith, y + ay + ydith, cmap); + +#ifndef DONT_ACTUALLY_DRAW + XPutImage(image_info->display, drawable, gc, image, + xs0, ys0, x + ax, y + ay, (unsigned int)width1, (unsigned int)height1); +#endif + } + } +} + + +/** + * xlib_draw_rgb_image: + * @drawable: Destination drawable. + * @gc: A graphic context. + * @x: Leftmost coordinate of the destination rectangle. + * @y: Upper coordinate of the destination rectangle. + * @width: Width of the destination rectangle, in pixels. + * @height: Height of the destination rectangle, in pixels. + * @dith: Dithering method to use. + * @rgb_buf: Pointer to the pixel in the RGB buffer that corresponds to the + * upper-left corner of the rectangular region to render. + * @rowstride: Offset between pixel rows in the RGB buffer, in bytes. + * + * Renders an RGB buffer to a drawable. Pixels are specified as RGB triplets + * with 8 bits per channel. An image will thus look like an RGBRGBRGBRGB + * sequence of 8-bit values. This function does not let you specify dither + * offsets; applications that need to render partial regions of a buffer to + * build the final image should use xlib_draw_rgb_image_dithalign() instead. + **/ +void +xlib_draw_rgb_image (Drawable drawable, + GC gc, + int x, + int y, + int width, + int height, + XlibRgbDither dith, + unsigned char *rgb_buf, + int rowstride) +{ + if (dith == XLIB_RGB_DITHER_NONE || (dith == XLIB_RGB_DITHER_NORMAL && + !image_info->dith_default)) + xlib_draw_rgb_image_core (drawable, gc, x, y, width, height, + rgb_buf, 3, rowstride, image_info->conv, NULL, + 0, 0); + else + xlib_draw_rgb_image_core (drawable, gc, x, y, width, height, + rgb_buf, 3, rowstride, image_info->conv_d, NULL, + 0, 0); +} + + + +/** + * xlib_rgb_cmap_free: + * @cmap: An XlibRGB colormap. + * + * Frees an XlibRGB colormap. + **/ +void +xlib_rgb_cmap_free (XlibRgbCmap *cmap) +{ + free (cmap); +} + +/** + * xlib_draw_indexed_image: + * @drawable: FIXME + * @gc: FIXME + * @x: FIXME + * @y: FIXME + * @width: FIXME + * @height: FIXME + * @dith: FIXME + * @buf: FIXME + * @rowstride: FIXME + * @cmap: FIXME + * + * FIXME + **/ +void +xlib_draw_indexed_image (Drawable drawable, + GC gc, + int x, + int y, + int width, + int height, + XlibRgbDither dith, + unsigned char *buf, + int rowstride, + XlibRgbCmap *cmap) +{ + if (dith == XLIB_RGB_DITHER_NONE || (dith == XLIB_RGB_DITHER_NORMAL && + !image_info->dith_default)) + xlib_draw_rgb_image_core (drawable, gc, x, y, width, height, + buf, 1, rowstride, + image_info->conv_indexed, cmap, 0, 0); + else + xlib_draw_rgb_image_core (drawable, gc, x, y, width, height, + buf, 1, rowstride, + image_info->conv_indexed_d, cmap, 0, 0); +} + +/** + * xlib_rgb_ditherable: + * + * Queries whether XlibRGB supports dithering for its chosen visual. + * + * Return value: TRUE if dithering can be performed for the visual that XlibRGB + * is using, FALSE otherwise. + **/ +Bool +xlib_rgb_ditherable (void) +{ + return (image_info->conv != image_info->conv_d); +} + +/** + * xlib_rgb_get_cmap: + * + * Queries the X colormap that XlibRGB is using. + * + * Return value: An X colormap. + **/ +Colormap +xlib_rgb_get_cmap (void) +{ + /* xlib_rgb_init (); */ + if (image_info) + return image_info->cmap; + else + return 0; +} + +/** + * xlib_rgb_get_visual: + * + * Queries the visual that XlibRGB is using. + * + * Return value: An X visual. + **/ +Visual * +xlib_rgb_get_visual (void) +{ + /* xlib_rgb_init (); */ + if (image_info) + return image_info->x_visual_info->visual; + else + return 0; +} + +/** + * xlib_rgb_get_visual_info: + * + * Queries the visual info structure for the visual that XlibRGB is using. + * + * Return value: An XVisualInfo structure. + **/ +XVisualInfo * +xlib_rgb_get_visual_info (void) +{ + /* xlib_rgb_init (); */ + if (image_info) + return image_info->x_visual_info; + else + return 0; +} + +/** + * xlib_rgb_get_depth: + * + * Queries the depth of the visual that XlibRGB is using. + * + * Return value: Bit depth. + **/ +int +xlib_rgb_get_depth (void) +{ + XVisualInfo * v = xlib_rgb_get_visual_info(); + + if (v) + { + return v->depth; + } + + return 0; +} + +/** + * xlib_rgb_get_display: + * + * Queries the X display that XlibRGB is using. + * + * Return value: An X display. + **/ +Display * +xlib_rgb_get_display (void) +{ + if (image_info) + return image_info->display; + + return NULL; +} + +/** + * xlib_rgb_get_screen: + * + * Queries the screen that XlibRGB is using. + * + * Return value: An X screen. + **/ +Screen * +xlib_rgb_get_screen (void) +{ + if (image_info) + return image_info->screen; + + return NULL; +} diff --git a/ksvg/impl/libs/xrgbrender/gdk-pixbuf-xlibrgb.h b/ksvg/impl/libs/xrgbrender/gdk-pixbuf-xlibrgb.h new file mode 100644 index 00000000..afde174e --- /dev/null +++ b/ksvg/impl/libs/xrgbrender/gdk-pixbuf-xlibrgb.h @@ -0,0 +1,145 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.1 (the "MPL"); you may not use this file except in + * compliance with the MPL. You may obtain a copy of the MPL at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the MPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL + * for the specific language governing rights and limitations under the + * MPL. + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU Library General Public License (the "LGPL"), in + * which case the provisions of the LGPL are applicable instead of + * those above. If you wish to allow use of your version of this file + * only under the terms of the LGPL and not to allow others to use + * your version of this file under the MPL, indicate your decision by + * deleting the provisions above and replace them with the notice and + * other provisions required by the LGPL. If you do not delete the + * provisions above, a recipient may use your version of this file + * under either the MPL or the LGPL. + */ + +/* + * This code is derived from GdkRgb. + * For more information on GdkRgb, see http://www.levien.com/gdkrgb/ + * Raph Levien <raph@acm.org> + */ + +/* Ported by Christopher Blizzard to Xlib. With permission from the + * original authors of this file, the contents of this file are also + * redistributable under the terms of the Mozilla Public license. For + * information about the Mozilla Public License, please see the + * license information at http://www.mozilla.org/MPL/ + */ + +/* This code is copyright the following authors: + * Raph Levien <raph@acm.org> + * Manish Singh <manish@gtk.org> + * Tim Janik <timj@gtk.org> + * Peter Mattis <petm@xcf.berkeley.edu> + * Spencer Kimball <spencer@xcf.berkeley.edu> + * Josh MacDonald <jmacd@xcf.berkeley.edu> + * Christopher Blizzard <blizzard@redhat.com> + * Owen Taylor <otaylor@redhat.com> + * Shawn T. Amundson <amundson@gtk.org> +*/ + + +#ifndef __XLIB_RGB_H__ +#define __XLIB_RGB_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#include <X11/Xos.h> +#include <X11/Intrinsic.h> + + +typedef struct _XlibRgbCmap XlibRgbCmap; + +struct _XlibRgbCmap { + unsigned int colors[256]; + unsigned char lut[256]; /* for 8-bit modes */ +}; + +void +xlib_rgb_init_with_depth (Display *display, Screen *screen, int prefDepth); + +typedef enum +{ + XLIB_RGB_DITHER_NONE, + XLIB_RGB_DITHER_NORMAL, + XLIB_RGB_DITHER_MAX +} XlibRgbDither; + +void +xlib_draw_rgb_image (Drawable drawable, + GC gc, + int x, + int y, + int width, + int height, + XlibRgbDither dith, + unsigned char *rgb_buf, + int rowstride); + +void +xlib_rgb_cmap_free (XlibRgbCmap *cmap); + +void +xlib_draw_indexed_image (Drawable drawable, + GC gc, + int x, + int y, + int width, + int height, + XlibRgbDither dith, + unsigned char *buf, + int rowstride, + XlibRgbCmap *cmap); + +/* Below are some functions which are primarily useful for debugging + and experimentation. */ +Bool +xlib_rgb_ditherable (void); + +void +xlib_rgb_set_verbose (Bool verbose); + +/* experimental colormap stuff */ +void +xlib_rgb_set_install (Bool install); + +void +xlib_rgb_set_min_colors (int min_colors); + +Colormap +xlib_rgb_get_cmap (void); + +Visual * +xlib_rgb_get_visual (void); + +XVisualInfo * +xlib_rgb_get_visual_info (void); + +int +xlib_rgb_get_depth (void); + +Display * +xlib_rgb_get_display (void); + +Screen * +xlib_rgb_get_screen (void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __XLIB_RGB_H__ */ diff --git a/ksvg/impl/svgpathparser.cc b/ksvg/impl/svgpathparser.cc new file mode 100644 index 00000000..0f7521e0 --- /dev/null +++ b/ksvg/impl/svgpathparser.cc @@ -0,0 +1,564 @@ +/* This file is part of the KDE project + Copyright (C) 2002, 2003 The Karbon Developers + + 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 "svgpathparser.h" +#include <qstring.h> +#include <math.h> + +// parses the number into parameter number +const char * +KSVG::getNumber( const char *ptr, double &number ) +{ + int integer, exponent; + double decimal, frac; + int sign, expsign; + + exponent = 0; + integer = 0; + frac = 1.0; + decimal = 0; + sign = 1; + expsign = 1; + + // read the sign + if(*ptr == '+') + ptr++; + else if(*ptr == '-') + { + ptr++; + sign = -1; + } + + // read the integer part + while(*ptr != '\0' && *ptr >= '0' && *ptr <= '9') + integer = (integer * 10) + *(ptr++) - '0'; + if(*ptr == '.') // read the decimals + { + ptr++; + while(*ptr != '\0' && *ptr >= '0' && *ptr <= '9') + decimal += (*(ptr++) - '0') * (frac *= 0.1); + } + + if(*ptr == 'e' || *ptr == 'E') // read the exponent part + { + ptr++; + + // read the sign of the exponent + if(*ptr == '+') + ptr++; + else if(*ptr == '-') + { + ptr++; + expsign = -1; + } + + exponent = 0; + while(*ptr != '\0' && *ptr >= '0' && *ptr <= '9') + { + exponent *= 10; + exponent += *ptr - '0'; + ptr++; + } + } + number = integer + decimal; + number *= sign * pow( (double)10, double( expsign * exponent ) ); + + return ptr; +} + +// parses the coord into parameter number and forwards to the next coord in the path data +const char * +SVGPathParser::getCoord( const char *ptr, double &number ) +{ + ptr = KSVG::getNumber( ptr, number ); + // skip the following space + if(*ptr == ' ') + ptr++; + + return ptr; +} + +void +SVGPathParser::parseSVG( const QString &s, bool process ) +{ + if(!s.isEmpty()) + { + QString d = s; + d = d.replace(',', ' '); + d = d.simplifyWhiteSpace(); + const char *ptr = d.latin1(); + const char *end = d.latin1() + d.length() + 1; + + double contrlx, contrly, curx, cury, subpathx, subpathy, tox, toy, x1, y1, x2, y2, xc, yc; + double px1, py1, px2, py2, px3, py3; + bool relative, closed = true; + char command = *(ptr++), lastCommand = ' '; + + subpathx = subpathy = curx = cury = contrlx = contrly = 0.0; + while( ptr < end ) + { + if( *ptr == ' ' ) + ptr++; + + relative = false; + + //std::cout << "Command : " << command << std::endl; + switch( command ) + { + case 'm': + relative = true; + case 'M': + { + ptr = getCoord( ptr, tox ); + ptr = getCoord( ptr, toy ); + + if( process ) + { + subpathx = curx = relative ? curx + tox : tox; + subpathy = cury = relative ? cury + toy : toy; + + svgMoveTo( curx, cury, closed ); + } + else + svgMoveTo( tox, toy, closed, !relative ); + closed = false; + break; + } + case 'l': + relative = true; + case 'L': + { + ptr = getCoord( ptr, tox ); + ptr = getCoord( ptr, toy ); + + if( process ) + { + curx = relative ? curx + tox : tox; + cury = relative ? cury + toy : toy; + + svgLineTo( curx, cury ); + } + else + svgLineTo( tox, toy, !relative ); + break; + } + case 'h': + { + ptr = getCoord( ptr, tox ); + if( process ) + { + curx = curx + tox; + svgLineTo( curx, cury ); + } + else + svgLineToHorizontal( tox, false ); + break; + } + case 'H': + { + ptr = getCoord( ptr, tox ); + if( process ) + { + curx = tox; + svgLineTo( curx, cury ); + } + else + svgLineToHorizontal( tox ); + break; + } + case 'v': + { + ptr = getCoord( ptr, toy ); + if( process ) + { + cury = cury + toy; + svgLineTo( curx, cury ); + } + else + svgLineToVertical( toy, false ); + break; + } + case 'V': + { + ptr = getCoord( ptr, toy ); + if( process ) + { + cury = toy; + svgLineTo( curx, cury ); + } + else + svgLineToVertical( toy ); + break; + } + case 'z': + case 'Z': + { + // reset curx, cury for next path + if( process ) + { + curx = subpathx; + cury = subpathy; + } + closed = true; + svgClosePath(); + break; + } + case 'c': + relative = true; + case 'C': + { + ptr = getCoord( ptr, x1 ); + ptr = getCoord( ptr, y1 ); + ptr = getCoord( ptr, x2 ); + ptr = getCoord( ptr, y2 ); + ptr = getCoord( ptr, tox ); + ptr = getCoord( ptr, toy ); + + if( process ) + { + px1 = relative ? curx + x1 : x1; + py1 = relative ? cury + y1 : y1; + px2 = relative ? curx + x2 : x2; + py2 = relative ? cury + y2 : y2; + px3 = relative ? curx + tox : tox; + py3 = relative ? cury + toy : toy; + + svgCurveToCubic( px1, py1, px2, py2, px3, py3 ); + + contrlx = relative ? curx + x2 : x2; + contrly = relative ? cury + y2 : y2; + curx = relative ? curx + tox : tox; + cury = relative ? cury + toy : toy; + } + else + svgCurveToCubic( x1, y1, x2, y2, tox, toy, !relative ); + + break; + } + case 's': + relative = true; + case 'S': + { + ptr = getCoord( ptr, x2 ); + ptr = getCoord( ptr, y2 ); + ptr = getCoord( ptr, tox ); + ptr = getCoord( ptr, toy ); + + if( process ) + { + px1 = 2 * curx - contrlx; + py1 = 2 * cury - contrly; + px2 = relative ? curx + x2 : x2; + py2 = relative ? cury + y2 : y2; + px3 = relative ? curx + tox : tox; + py3 = relative ? cury + toy : toy; + + svgCurveToCubic( px1, py1, px2, py2, px3, py3 ); + + contrlx = relative ? curx + x2 : x2; + contrly = relative ? cury + y2 : y2; + curx = relative ? curx + tox : tox; + cury = relative ? cury + toy : toy; + } + else + svgCurveToCubicSmooth( x2, y2, tox, toy, !relative ); + break; + } + case 'q': + relative = true; + case 'Q': + { + ptr = getCoord( ptr, x1 ); + ptr = getCoord( ptr, y1 ); + ptr = getCoord( ptr, tox ); + ptr = getCoord( ptr, toy ); + + if( process ) + { + px1 = relative ? (curx + 2 * (x1 + curx)) * (1.0 / 3.0) : (curx + 2 * x1) * (1.0 / 3.0); + py1 = relative ? (cury + 2 * (y1 + cury)) * (1.0 / 3.0) : (cury + 2 * y1) * (1.0 / 3.0); + px2 = relative ? ((curx + tox) + 2 * (x1 + curx)) * (1.0 / 3.0) : (tox + 2 * x1) * (1.0 / 3.0); + py2 = relative ? ((cury + toy) + 2 * (y1 + cury)) * (1.0 / 3.0) : (toy + 2 * y1) * (1.0 / 3.0); + px3 = relative ? curx + tox : tox; + py3 = relative ? cury + toy : toy; + + svgCurveToCubic( px1, py1, px2, py2, px3, py3 ); + + contrlx = relative ? curx + x1 : (tox + 2 * x1) * (1.0 / 3.0); + contrly = relative ? cury + y1 : (toy + 2 * y1) * (1.0 / 3.0); + curx = relative ? curx + tox : tox; + cury = relative ? cury + toy : toy; + } + else + svgCurveToQuadratic( x1, y1, tox, toy, !relative ); + break; + } + case 't': + relative = true; + case 'T': + { + ptr = getCoord(ptr, tox); + ptr = getCoord(ptr, toy); + + if( process ) + { + xc = 2 * curx - contrlx; + yc = 2 * cury - contrly; + + px1 = (curx + 2 * xc) * (1.0 / 3.0); + py1 = (cury + 2 * yc) * (1.0 / 3.0); + px2 = relative ? ((curx + tox) + 2 * xc) * (1.0 / 3.0) : (tox + 2 * xc) * (1.0 / 3.0); + py2 = relative ? ((cury + toy) + 2 * yc) * (1.0 / 3.0) : (toy + 2 * yc) * (1.0 / 3.0); + px3 = relative ? curx + tox : tox; + py3 = relative ? cury + toy : toy; + + svgCurveToCubic( px1, py1, px2, py2, px3, py3 ); + + contrlx = xc; + contrly = yc; + curx = relative ? curx + tox : tox; + cury = relative ? cury + toy : toy; + } + else + svgCurveToQuadraticSmooth( tox, toy, !relative ); + break; + } + case 'a': + relative = true; + case 'A': + { + bool largeArc, sweep; + double angle, rx, ry; + ptr = getCoord( ptr, rx ); + ptr = getCoord( ptr, ry ); + ptr = getCoord( ptr, angle ); + ptr = getCoord( ptr, tox ); + largeArc = tox == 1; + ptr = getCoord( ptr, tox ); + sweep = tox == 1; + ptr = getCoord( ptr, tox ); + ptr = getCoord( ptr, toy ); + + // Spec: radii are nonnegative numbers + rx = fabs(rx); + ry = fabs(ry); + + if( process ) + calculateArc( relative, curx, cury, angle, tox, toy, rx, ry, largeArc, sweep ); + else + svgArcTo( tox, toy, rx, ry, angle, largeArc, sweep, !relative ); + } + } + + lastCommand = command; + + if(*ptr == '+' || *ptr == '-' || (*ptr >= '0' && *ptr <= '9')) + { + // there are still coords in this command + if(command == 'M') + command = 'L'; + else if(command == 'm') + command = 'l'; + } + else + command = *(ptr++); + + if( lastCommand != 'C' && lastCommand != 'c' && + lastCommand != 'S' && lastCommand != 's' && + lastCommand != 'Q' && lastCommand != 'q' && + lastCommand != 'T' && lastCommand != 't') + { + contrlx = curx; + contrly = cury; + } + } + } +} + +// This works by converting the SVG arc to "simple" beziers. +// For each bezier found a svgToCurve call is done. +// Adapted from Niko's code in kdelibs/kdecore/svgicons. +// Maybe this can serve in some shared lib? (Rob) +void +SVGPathParser::calculateArc(bool relative, double &curx, double &cury, double angle, double x, double y, double r1, double r2, bool largeArcFlag, bool sweepFlag) +{ + double sin_th, cos_th; + double a00, a01, a10, a11; + double x0, y0, x1, y1, xc, yc; + double d, sfactor, sfactor_sq; + double th0, th1, th_arc; + int i, n_segs; + + sin_th = sin(angle * (M_PI / 180.0)); + cos_th = cos(angle * (M_PI / 180.0)); + + double dx; + + if(!relative) + dx = (curx - x) / 2.0; + else + dx = -x / 2.0; + + double dy; + + if(!relative) + dy = (cury - y) / 2.0; + else + dy = -y / 2.0; + + double _x1 = cos_th * dx + sin_th * dy; + double _y1 = -sin_th * dx + cos_th * dy; + double Pr1 = r1 * r1; + double Pr2 = r2 * r2; + double Px = _x1 * _x1; + double Py = _y1 * _y1; + + // Spec : check if radii are large enough + double check = Px / Pr1 + Py / Pr2; + if(check > 1) + { + r1 = r1 * sqrt(check); + r2 = r2 * sqrt(check); + } + + a00 = cos_th / r1; + a01 = sin_th / r1; + a10 = -sin_th / r2; + a11 = cos_th / r2; + + x0 = a00 * curx + a01 * cury; + y0 = a10 * curx + a11 * cury; + + if(!relative) + x1 = a00 * x + a01 * y; + else + x1 = a00 * (curx + x) + a01 * (cury + y); + + if(!relative) + y1 = a10 * x + a11 * y; + else + y1 = a10 * (curx + x) + a11 * (cury + y); + + /* (x0, y0) is current point in transformed coordinate space. + (x1, y1) is new point in transformed coordinate space. + + The arc fits a unit-radius circle in this space. + */ + + d = (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0); + + sfactor_sq = 1.0 / d - 0.25; + + if(sfactor_sq < 0) + sfactor_sq = 0; + + sfactor = sqrt(sfactor_sq); + + if(sweepFlag == largeArcFlag) + sfactor = -sfactor; + + xc = 0.5 * (x0 + x1) - sfactor * (y1 - y0); + yc = 0.5 * (y0 + y1) + sfactor * (x1 - x0); + + /* (xc, yc) is center of the circle. */ + th0 = atan2(y0 - yc, x0 - xc); + th1 = atan2(y1 - yc, x1 - xc); + + th_arc = th1 - th0; + if(th_arc < 0 && sweepFlag) + th_arc += 2 * M_PI; + else if(th_arc > 0 && !sweepFlag) + th_arc -= 2 * M_PI; + + n_segs = (int) (int) ceil(fabs(th_arc / (M_PI * 0.5 + 0.001))); + + for(i = 0; i < n_segs; i++) + { + { + double sin_th, cos_th; + double a00, a01, a10, a11; + double x1, y1, x2, y2, x3, y3; + double t; + double th_half; + + double _th0 = th0 + i * th_arc / n_segs; + double _th1 = th0 + (i + 1) * th_arc / n_segs; + + sin_th = sin(angle * (M_PI / 180.0)); + cos_th = cos(angle * (M_PI / 180.0)); + + /* inverse transform compared with rsvg_path_arc */ + a00 = cos_th * r1; + a01 = -sin_th * r2; + a10 = sin_th * r1; + a11 = cos_th * r2; + + th_half = 0.5 * (_th1 - _th0); + t = (8.0 / 3.0) * sin(th_half * 0.5) * sin(th_half * 0.5) / sin(th_half); + x1 = xc + cos(_th0) - t * sin(_th0); + y1 = yc + sin(_th0) + t * cos(_th0); + x3 = xc + cos(_th1); + y3 = yc + sin(_th1); + x2 = x3 + t * sin(_th1); + y2 = y3 - t * cos(_th1); + + svgCurveToCubic( a00 * x1 + a01 * y1, a10 * x1 + a11 * y1, a00 * x2 + a01 * y2, a10 * x2 + a11 * y2, a00 * x3 + a01 * y3, a10 * x3 + a11 * y3 ); + } + } + + if(!relative) + curx = x; + else + curx += x; + + if(!relative) + cury = y; + else + cury += y; +} + +void +SVGPathParser::svgLineToHorizontal( double, bool ) +{ +} + +void +SVGPathParser::svgLineToVertical( double, bool ) +{ +} + +void +SVGPathParser::svgCurveToCubicSmooth( double, double, double, double, bool ) +{ +} + +void +SVGPathParser::svgCurveToQuadratic( double, double, double, double, bool ) +{ +} + +void +SVGPathParser::svgCurveToQuadraticSmooth( double, double, bool ) +{ +} + +void +SVGPathParser::svgArcTo( double, double, double, double, double, bool, bool, bool ) +{ +} diff --git a/ksvg/impl/svgpathparser.h b/ksvg/impl/svgpathparser.h new file mode 100644 index 00000000..3a9495d0 --- /dev/null +++ b/ksvg/impl/svgpathparser.h @@ -0,0 +1,63 @@ +/* This file is part of the KDE project + Copyright (C) 2002, 2003 The Karbon Developers + + 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. +*/ + +#ifndef __SVGPATHPARSER_H__ +#define __SVGPATHPARSER_H__ + +class QString; + +namespace KSVG +{ + const char *getNumber( const char *, double & ); +} + +/** + * Parser for svg path data, contained in the d attribute. + * + * The parser delivers encountered commands and parameters by calling + * methods that correspond to those commands. Clients have to derive + * from this class and implement the abstract command methods. + * + * There are two operating modes. By default the parser just delivers unaltered + * svg path data commands and parameters. In the second mode, it will convert all + * relative coordinates to absolute ones, and convert all curves to cubic beziers. + */ +class SVGPathParser +{ +public: + void parseSVG( const QString &d, bool process = false ); + + static const char *getCoord( const char *, double & ); + +protected: + virtual void svgMoveTo( double x1, double y1, bool closed, bool abs = true ) = 0; + virtual void svgLineTo( double x1, double y1, bool abs = true ) = 0; + virtual void svgLineToHorizontal( double x, bool abs = true ); + virtual void svgLineToVertical( double y, bool abs = true ); + virtual void svgCurveToCubic( double x1, double y1, double x2, double y2, double x, double y, bool abs = true ) = 0; + virtual void svgCurveToCubicSmooth( double x, double y, double x2, double y2, bool abs = true ); + virtual void svgCurveToQuadratic( double x, double y, double x1, double y1, bool abs = true ); + virtual void svgCurveToQuadraticSmooth( double x, double y, bool abs = true ); + virtual void svgArcTo( double x, double y, double r1, double r2, double angle, bool largeArcFlag, bool sweepFlag, bool abs = true ); + virtual void svgClosePath() = 0; +private: + void calculateArc( bool relative, double &curx, double &cury, double angle, double x, double y, double r1, double r2, bool largeArcFlag, bool sweepFlag ); +}; + +#endif |