From c57343e948aa9f3346ad866ad88d4b1330d098b8 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sun, 13 Dec 2020 19:22:19 +0900 Subject: Renaming of files in preparation for code style tools. Signed-off-by: Michele Calgaro (cherry picked from commit 14d0fbe96c6abdb9da80e99953aec672f999948c) --- ksvg/impl/CMakeLists.txt | 118 +- ksvg/impl/Makefile.am | 118 +- ksvg/impl/SVGAElementImpl.cc | 115 -- ksvg/impl/SVGAElementImpl.cpp | 115 ++ ksvg/impl/SVGAltGlyphDefElementImpl.cc | 31 - ksvg/impl/SVGAltGlyphDefElementImpl.cpp | 31 + ksvg/impl/SVGAltGlyphElementImpl.cc | 47 - ksvg/impl/SVGAltGlyphElementImpl.cpp | 47 + ksvg/impl/SVGAngleImpl.cc | 275 ---- ksvg/impl/SVGAngleImpl.cpp | 275 ++++ ksvg/impl/SVGAnimateColorElementImpl.cc | 96 -- ksvg/impl/SVGAnimateColorElementImpl.cpp | 96 ++ ksvg/impl/SVGAnimateElementImpl.cc | 189 --- ksvg/impl/SVGAnimateElementImpl.cpp | 189 +++ ksvg/impl/SVGAnimateMotionElementImpl.cc | 100 -- ksvg/impl/SVGAnimateMotionElementImpl.cpp | 100 ++ ksvg/impl/SVGAnimateTransformElementImpl.cc | 255 ---- ksvg/impl/SVGAnimateTransformElementImpl.cpp | 255 ++++ ksvg/impl/SVGAnimatedAngleImpl.cc | 81 -- ksvg/impl/SVGAnimatedAngleImpl.cpp | 81 ++ ksvg/impl/SVGAnimatedBooleanImpl.cc | 91 -- ksvg/impl/SVGAnimatedBooleanImpl.cpp | 91 ++ ksvg/impl/SVGAnimatedEnumerationImpl.cc | 91 -- ksvg/impl/SVGAnimatedEnumerationImpl.cpp | 91 ++ ksvg/impl/SVGAnimatedIntegerImpl.cc | 89 -- ksvg/impl/SVGAnimatedIntegerImpl.cpp | 89 ++ ksvg/impl/SVGAnimatedLengthImpl.cc | 94 -- ksvg/impl/SVGAnimatedLengthImpl.cpp | 94 ++ ksvg/impl/SVGAnimatedLengthListImpl.cc | 93 -- ksvg/impl/SVGAnimatedLengthListImpl.cpp | 93 ++ ksvg/impl/SVGAnimatedNumberImpl.cc | 92 -- ksvg/impl/SVGAnimatedNumberImpl.cpp | 92 ++ ksvg/impl/SVGAnimatedNumberListImpl.cc | 80 -- ksvg/impl/SVGAnimatedNumberListImpl.cpp | 80 ++ ksvg/impl/SVGAnimatedPathDataImpl.cc | 106 -- ksvg/impl/SVGAnimatedPathDataImpl.cpp | 106 ++ ksvg/impl/SVGAnimatedPointsImpl.cc | 137 -- ksvg/impl/SVGAnimatedPointsImpl.cpp | 137 ++ ksvg/impl/SVGAnimatedPreserveAspectRatioImpl.cc | 81 -- ksvg/impl/SVGAnimatedPreserveAspectRatioImpl.cpp | 81 ++ ksvg/impl/SVGAnimatedRectImpl.cc | 79 -- ksvg/impl/SVGAnimatedRectImpl.cpp | 79 ++ ksvg/impl/SVGAnimatedStringImpl.cc | 88 -- ksvg/impl/SVGAnimatedStringImpl.cpp | 88 ++ ksvg/impl/SVGAnimatedTransformListImpl.cc | 81 -- ksvg/impl/SVGAnimatedTransformListImpl.cpp | 81 ++ ksvg/impl/SVGAnimationElementImpl.cc | 463 ------- ksvg/impl/SVGAnimationElementImpl.cpp | 463 +++++++ ksvg/impl/SVGBBoxTarget.cc | 53 - ksvg/impl/SVGBBoxTarget.cpp | 53 + ksvg/impl/SVGCSSRuleImpl.cc | 31 - ksvg/impl/SVGCSSRuleImpl.cpp | 31 + ksvg/impl/SVGCircleElementImpl.cc | 176 --- ksvg/impl/SVGCircleElementImpl.cpp | 176 +++ ksvg/impl/SVGClipPathElementImpl.cc | 102 -- ksvg/impl/SVGClipPathElementImpl.cpp | 102 ++ ksvg/impl/SVGColorImpl.cc | 538 -------- ksvg/impl/SVGColorImpl.cpp | 538 ++++++++ ksvg/impl/SVGColorProfileElementImpl.cc | 269 ---- ksvg/impl/SVGColorProfileElementImpl.cpp | 269 ++++ ksvg/impl/SVGColorProfileRuleImpl.cc | 61 - ksvg/impl/SVGColorProfileRuleImpl.cpp | 61 + .../SVGComponentTransferFunctionElementImpl.cc | 103 -- .../SVGComponentTransferFunctionElementImpl.cpp | 103 ++ ksvg/impl/SVGContainerImpl.cc | 133 -- ksvg/impl/SVGContainerImpl.cpp | 133 ++ ksvg/impl/SVGCursorElementImpl.cc | 102 -- ksvg/impl/SVGCursorElementImpl.cpp | 102 ++ ksvg/impl/SVGDefinitionSrcElementImpl.cc | 31 - ksvg/impl/SVGDefinitionSrcElementImpl.cpp | 31 + ksvg/impl/SVGDefsElementImpl.cc | 32 - ksvg/impl/SVGDefsElementImpl.cpp | 32 + ksvg/impl/SVGDescElementImpl.cc | 37 - ksvg/impl/SVGDescElementImpl.cpp | 37 + ksvg/impl/SVGDocumentImpl.cc | 703 ----------- ksvg/impl/SVGDocumentImpl.cpp | 703 +++++++++++ ksvg/impl/SVGEcma.cc | 842 ------------- ksvg/impl/SVGEcma.cpp | 842 +++++++++++++ ksvg/impl/SVGElementImpl.cc | 711 ----------- ksvg/impl/SVGElementImpl.cpp | 711 +++++++++++ ksvg/impl/SVGElementInstanceImpl.cc | 106 -- ksvg/impl/SVGElementInstanceImpl.cpp | 106 ++ ksvg/impl/SVGElementInstanceListImpl.cc | 42 - ksvg/impl/SVGElementInstanceListImpl.cpp | 42 + ksvg/impl/SVGEllipseElementImpl.cc | 198 --- ksvg/impl/SVGEllipseElementImpl.cpp | 198 +++ ksvg/impl/SVGEventImpl.cc | 990 --------------- ksvg/impl/SVGEventImpl.cpp | 990 +++++++++++++++ ksvg/impl/SVGExternalResourcesRequiredImpl.cc | 86 -- ksvg/impl/SVGExternalResourcesRequiredImpl.cpp | 86 ++ ksvg/impl/SVGFEBlendElementImpl.cc | 62 - ksvg/impl/SVGFEBlendElementImpl.cpp | 62 + ksvg/impl/SVGFEColorMatrixElementImpl.cc | 63 - ksvg/impl/SVGFEColorMatrixElementImpl.cpp | 63 + ksvg/impl/SVGFEComponentTransferElementImpl.cc | 41 - ksvg/impl/SVGFEComponentTransferElementImpl.cpp | 41 + ksvg/impl/SVGFECompositeElementImpl.cc | 103 -- ksvg/impl/SVGFECompositeElementImpl.cpp | 103 ++ ksvg/impl/SVGFEConvolveMatrixElementImpl.cc | 147 --- ksvg/impl/SVGFEConvolveMatrixElementImpl.cpp | 147 +++ ksvg/impl/SVGFEDiffuseLightingElementImpl.cc | 62 - ksvg/impl/SVGFEDiffuseLightingElementImpl.cpp | 62 + ksvg/impl/SVGFEDisplacementMapElementImpl.cc | 83 -- ksvg/impl/SVGFEDisplacementMapElementImpl.cpp | 83 ++ ksvg/impl/SVGFEDistantLightElementImpl.cc | 51 - ksvg/impl/SVGFEDistantLightElementImpl.cpp | 51 + ksvg/impl/SVGFEFloodElementImpl.cc | 41 - ksvg/impl/SVGFEFloodElementImpl.cpp | 41 + ksvg/impl/SVGFEFuncAElementImpl.cc | 31 - ksvg/impl/SVGFEFuncAElementImpl.cpp | 31 + ksvg/impl/SVGFEFuncBElementImpl.cc | 31 - ksvg/impl/SVGFEFuncBElementImpl.cpp | 31 + ksvg/impl/SVGFEFuncGElementImpl.cc | 31 - ksvg/impl/SVGFEFuncGElementImpl.cpp | 31 + ksvg/impl/SVGFEFuncRElementImpl.cc | 31 - ksvg/impl/SVGFEFuncRElementImpl.cpp | 31 + ksvg/impl/SVGFEGaussianBlurElementImpl.cc | 66 - ksvg/impl/SVGFEGaussianBlurElementImpl.cpp | 66 + ksvg/impl/SVGFEImageElementImpl.cc | 31 - ksvg/impl/SVGFEImageElementImpl.cpp | 31 + ksvg/impl/SVGFEMergeElementImpl.cc | 31 - ksvg/impl/SVGFEMergeElementImpl.cpp | 31 + ksvg/impl/SVGFEMergeNodeElementImpl.cc | 41 - ksvg/impl/SVGFEMergeNodeElementImpl.cpp | 41 + ksvg/impl/SVGFEMorphologyElementImpl.cc | 73 -- ksvg/impl/SVGFEMorphologyElementImpl.cpp | 73 ++ ksvg/impl/SVGFEOffsetElementImpl.cc | 62 - ksvg/impl/SVGFEOffsetElementImpl.cpp | 62 + ksvg/impl/SVGFEPointLightElementImpl.cc | 61 - ksvg/impl/SVGFEPointLightElementImpl.cpp | 61 + ksvg/impl/SVGFESpecularLightingElementImpl.cc | 72 -- ksvg/impl/SVGFESpecularLightingElementImpl.cpp | 72 ++ ksvg/impl/SVGFESpotLightElementImpl.cc | 111 -- ksvg/impl/SVGFESpotLightElementImpl.cpp | 111 ++ ksvg/impl/SVGFETileElementImpl.cc | 41 - ksvg/impl/SVGFETileElementImpl.cpp | 41 + ksvg/impl/SVGFETurbulenceElementImpl.cc | 98 -- ksvg/impl/SVGFETurbulenceElementImpl.cpp | 98 ++ ksvg/impl/SVGFilterElementImpl.cc | 117 -- ksvg/impl/SVGFilterElementImpl.cpp | 117 ++ .../SVGFilterPrimitiveStandardAttributesImpl.cc | 82 -- .../SVGFilterPrimitiveStandardAttributesImpl.cpp | 82 ++ ksvg/impl/SVGFitToViewBoxImpl.cc | 139 --- ksvg/impl/SVGFitToViewBoxImpl.cpp | 139 +++ ksvg/impl/SVGFontElementImpl.cc | 31 - ksvg/impl/SVGFontElementImpl.cpp | 31 + ksvg/impl/SVGFontFaceElementImpl.cc | 31 - ksvg/impl/SVGFontFaceElementImpl.cpp | 31 + ksvg/impl/SVGFontFaceFormatElementImpl.cc | 31 - ksvg/impl/SVGFontFaceFormatElementImpl.cpp | 31 + ksvg/impl/SVGFontFaceNameElementImpl.cc | 31 - ksvg/impl/SVGFontFaceNameElementImpl.cpp | 31 + ksvg/impl/SVGFontFaceSrcElementImpl.cc | 31 - ksvg/impl/SVGFontFaceSrcElementImpl.cpp | 31 + ksvg/impl/SVGFontFaceUriElementImpl.cc | 31 - ksvg/impl/SVGFontFaceUriElementImpl.cpp | 31 + ksvg/impl/SVGForeignObjectElementImpl.cc | 119 -- ksvg/impl/SVGForeignObjectElementImpl.cpp | 119 ++ ksvg/impl/SVGGElementImpl.cc | 34 - ksvg/impl/SVGGElementImpl.cpp | 34 + ksvg/impl/SVGGlyphElementImpl.cc | 96 -- ksvg/impl/SVGGlyphElementImpl.cpp | 96 ++ ksvg/impl/SVGGlyphRefElementImpl.cc | 132 -- ksvg/impl/SVGGlyphRefElementImpl.cpp | 132 ++ ksvg/impl/SVGGradientElementImpl.cc | 262 ---- ksvg/impl/SVGGradientElementImpl.cpp | 262 ++++ ksvg/impl/SVGHKernElementImpl.cc | 31 - ksvg/impl/SVGHKernElementImpl.cpp | 31 + ksvg/impl/SVGHelperImpl.cc | 228 ---- ksvg/impl/SVGHelperImpl.cpp | 228 ++++ ksvg/impl/SVGICCColorImpl.cc | 105 -- ksvg/impl/SVGICCColorImpl.cpp | 105 ++ ksvg/impl/SVGImageElementImpl.cc | 520 -------- ksvg/impl/SVGImageElementImpl.cpp | 520 ++++++++ ksvg/impl/SVGLangSpaceImpl.cc | 128 -- ksvg/impl/SVGLangSpaceImpl.cpp | 128 ++ ksvg/impl/SVGLengthImpl.cc | 508 -------- ksvg/impl/SVGLengthImpl.cpp | 508 ++++++++ ksvg/impl/SVGLengthListImpl.cc | 62 - ksvg/impl/SVGLengthListImpl.cpp | 62 + ksvg/impl/SVGLineElementImpl.cc | 211 ---- ksvg/impl/SVGLineElementImpl.cpp | 211 ++++ ksvg/impl/SVGLinearGradientElementImpl.cc | 199 --- ksvg/impl/SVGLinearGradientElementImpl.cpp | 199 +++ ksvg/impl/SVGLocatableImpl.cc | 206 --- ksvg/impl/SVGLocatableImpl.cpp | 206 +++ ksvg/impl/SVGMPathElementImpl.cc | 31 - ksvg/impl/SVGMPathElementImpl.cpp | 31 + ksvg/impl/SVGMarkerElementImpl.cc | 422 ------- ksvg/impl/SVGMarkerElementImpl.cpp | 422 +++++++ ksvg/impl/SVGMaskElementImpl.cc | 540 -------- ksvg/impl/SVGMaskElementImpl.cpp | 540 ++++++++ ksvg/impl/SVGMatrixImpl.cc | 458 ------- ksvg/impl/SVGMatrixImpl.cpp | 458 +++++++ ksvg/impl/SVGMetadataElementImpl.cc | 31 - ksvg/impl/SVGMetadataElementImpl.cpp | 31 + ksvg/impl/SVGMissingGlyphElementImpl.cc | 31 - ksvg/impl/SVGMissingGlyphElementImpl.cpp | 31 + ksvg/impl/SVGNumberImpl.cc | 81 -- ksvg/impl/SVGNumberImpl.cpp | 81 ++ ksvg/impl/SVGNumberListImpl.cc | 62 - ksvg/impl/SVGNumberListImpl.cpp | 62 + ksvg/impl/SVGPaintImpl.cc | 173 --- ksvg/impl/SVGPaintImpl.cpp | 173 +++ ksvg/impl/SVGPaintServerImpl.cc | 52 - ksvg/impl/SVGPaintServerImpl.cpp | 52 + ksvg/impl/SVGPathElementImpl.cc | 866 ------------- ksvg/impl/SVGPathElementImpl.cpp | 866 +++++++++++++ ksvg/impl/SVGPathSegArcImpl.cc | 493 -------- ksvg/impl/SVGPathSegArcImpl.cpp | 493 ++++++++ ksvg/impl/SVGPathSegClosePathImpl.cc | 44 - ksvg/impl/SVGPathSegClosePathImpl.cpp | 44 + ksvg/impl/SVGPathSegCurvetoCubicImpl.cc | 323 ----- ksvg/impl/SVGPathSegCurvetoCubicImpl.cpp | 323 +++++ ksvg/impl/SVGPathSegCurvetoCubicSmoothImpl.cc | 296 ----- ksvg/impl/SVGPathSegCurvetoCubicSmoothImpl.cpp | 296 +++++ ksvg/impl/SVGPathSegCurvetoQuadraticImpl.cc | 258 ---- ksvg/impl/SVGPathSegCurvetoQuadraticImpl.cpp | 258 ++++ ksvg/impl/SVGPathSegCurvetoQuadraticSmoothImpl.cc | 233 ---- ksvg/impl/SVGPathSegCurvetoQuadraticSmoothImpl.cpp | 233 ++++ ksvg/impl/SVGPathSegImpl.cc | 105 -- ksvg/impl/SVGPathSegImpl.cpp | 105 ++ ksvg/impl/SVGPathSegLinetoHorizontalImpl.cc | 165 --- ksvg/impl/SVGPathSegLinetoHorizontalImpl.cpp | 165 +++ ksvg/impl/SVGPathSegLinetoImpl.cc | 194 --- ksvg/impl/SVGPathSegLinetoImpl.cpp | 194 +++ ksvg/impl/SVGPathSegLinetoVerticalImpl.cc | 163 --- ksvg/impl/SVGPathSegLinetoVerticalImpl.cpp | 163 +++ ksvg/impl/SVGPathSegListImpl.cc | 62 - ksvg/impl/SVGPathSegListImpl.cpp | 62 + ksvg/impl/SVGPathSegMovetoImpl.cc | 194 --- ksvg/impl/SVGPathSegMovetoImpl.cpp | 194 +++ ksvg/impl/SVGPatternElementImpl.cc | 509 -------- ksvg/impl/SVGPatternElementImpl.cpp | 509 ++++++++ ksvg/impl/SVGPointImpl.cc | 106 -- ksvg/impl/SVGPointImpl.cpp | 106 ++ ksvg/impl/SVGPointListImpl.cc | 62 - ksvg/impl/SVGPointListImpl.cpp | 62 + ksvg/impl/SVGPolyElementImpl.cc | 139 --- ksvg/impl/SVGPolyElementImpl.cpp | 139 +++ ksvg/impl/SVGPolygonElementImpl.cc | 86 -- ksvg/impl/SVGPolygonElementImpl.cpp | 86 ++ ksvg/impl/SVGPolylineElementImpl.cc | 98 -- ksvg/impl/SVGPolylineElementImpl.cpp | 98 ++ ksvg/impl/SVGPreserveAspectRatioImpl.cc | 215 ---- ksvg/impl/SVGPreserveAspectRatioImpl.cpp | 215 ++++ ksvg/impl/SVGRadialGradientElementImpl.cc | 214 ---- ksvg/impl/SVGRadialGradientElementImpl.cpp | 214 ++++ ksvg/impl/SVGRectElementImpl.cc | 242 ---- ksvg/impl/SVGRectElementImpl.cpp | 242 ++++ ksvg/impl/SVGRectImpl.cc | 155 --- ksvg/impl/SVGRectImpl.cpp | 155 +++ ksvg/impl/SVGSVGElementImpl.cc | 980 --------------- ksvg/impl/SVGSVGElementImpl.cpp | 980 +++++++++++++++ ksvg/impl/SVGScriptElementImpl.cc | 183 --- ksvg/impl/SVGScriptElementImpl.cpp | 183 +++ ksvg/impl/SVGSetElementImpl.cc | 46 - ksvg/impl/SVGSetElementImpl.cpp | 46 + ksvg/impl/SVGShapeImpl.cc | 160 --- ksvg/impl/SVGShapeImpl.cpp | 160 +++ ksvg/impl/SVGStopElementImpl.cc | 123 -- ksvg/impl/SVGStopElementImpl.cpp | 123 ++ ksvg/impl/SVGStringListImpl.cc | 91 -- ksvg/impl/SVGStringListImpl.cpp | 91 ++ ksvg/impl/SVGStylableImpl.cc | 1307 -------------------- ksvg/impl/SVGStylableImpl.cpp | 1307 ++++++++++++++++++++ ksvg/impl/SVGStyleElementImpl.cc | 133 -- ksvg/impl/SVGStyleElementImpl.cpp | 133 ++ ksvg/impl/SVGSwitchElementImpl.cc | 56 - ksvg/impl/SVGSwitchElementImpl.cpp | 56 + ksvg/impl/SVGSymbolElementImpl.cc | 104 -- ksvg/impl/SVGSymbolElementImpl.cpp | 104 ++ ksvg/impl/SVGTRefElementImpl.cc | 74 -- ksvg/impl/SVGTRefElementImpl.cpp | 74 ++ ksvg/impl/SVGTSpanElementImpl.cc | 62 - ksvg/impl/SVGTSpanElementImpl.cpp | 62 + ksvg/impl/SVGTestsImpl.cc | 176 --- ksvg/impl/SVGTestsImpl.cpp | 176 +++ ksvg/impl/SVGTextContentElementImpl.cc | 283 ----- ksvg/impl/SVGTextContentElementImpl.cpp | 283 +++++ ksvg/impl/SVGTextElementImpl.cc | 122 -- ksvg/impl/SVGTextElementImpl.cpp | 122 ++ ksvg/impl/SVGTextPathElementImpl.cc | 238 ---- ksvg/impl/SVGTextPathElementImpl.cpp | 238 ++++ ksvg/impl/SVGTextPositioningElementImpl.cc | 196 --- ksvg/impl/SVGTextPositioningElementImpl.cpp | 196 +++ ksvg/impl/SVGTimeScheduler.cc | 232 ---- ksvg/impl/SVGTimeScheduler.cpp | 232 ++++ ksvg/impl/SVGTitleElementImpl.cc | 37 - ksvg/impl/SVGTitleElementImpl.cpp | 37 + ksvg/impl/SVGTransformImpl.cc | 238 ---- ksvg/impl/SVGTransformImpl.cpp | 238 ++++ ksvg/impl/SVGTransformListImpl.cc | 101 -- ksvg/impl/SVGTransformListImpl.cpp | 101 ++ ksvg/impl/SVGTransformableImpl.cc | 167 --- ksvg/impl/SVGTransformableImpl.cpp | 167 +++ ksvg/impl/SVGURIReferenceImpl.cc | 133 -- ksvg/impl/SVGURIReferenceImpl.cpp | 133 ++ ksvg/impl/SVGUseElementImpl.cc | 407 ------ ksvg/impl/SVGUseElementImpl.cpp | 407 ++++++ ksvg/impl/SVGVKernElementImpl.cc | 31 - ksvg/impl/SVGVKernElementImpl.cpp | 31 + ksvg/impl/SVGViewElementImpl.cc | 92 -- ksvg/impl/SVGViewElementImpl.cpp | 92 ++ ksvg/impl/SVGViewSpecImpl.cc | 96 -- ksvg/impl/SVGViewSpecImpl.cpp | 96 ++ ksvg/impl/SVGWindowImpl.cc | 185 --- ksvg/impl/SVGWindowImpl.cpp | 185 +++ ksvg/impl/SVGZoomAndPanImpl.cc | 110 -- ksvg/impl/SVGZoomAndPanImpl.cpp | 110 ++ ksvg/impl/SVGZoomEventImpl.cc | 109 -- ksvg/impl/SVGZoomEventImpl.cpp | 109 ++ ksvg/impl/libs/libtext2path/src/Cache.h | 2 +- ksvg/impl/libs/libtext2path/src/Converter.cpp | 2 +- ksvg/impl/libs/libtext2path/src/myboost/assert.h | 24 + ksvg/impl/libs/libtext2path/src/myboost/assert.hpp | 24 - .../libs/libtext2path/src/myboost/checked_delete.h | 61 + .../libtext2path/src/myboost/checked_delete.hpp | 61 - .../libtext2path/src/myboost/lightweight_mutex.h | 74 ++ .../libtext2path/src/myboost/lightweight_mutex.hpp | 74 -- .../libs/libtext2path/src/myboost/shared_count.h | 367 ++++++ .../libs/libtext2path/src/myboost/shared_count.hpp | 367 ------ .../libs/libtext2path/src/myboost/shared_ptr.h | 395 ++++++ .../libs/libtext2path/src/myboost/shared_ptr.hpp | 395 ------ .../libtext2path/src/myboost/throw_exception.h | 30 + .../libtext2path/src/myboost/throw_exception.hpp | 30 - ksvg/impl/svgpathparser.cc | 564 --------- ksvg/impl/svgpathparser.cpp | 564 +++++++++ 328 files changed, 28039 insertions(+), 28039 deletions(-) delete mode 100644 ksvg/impl/SVGAElementImpl.cc create mode 100644 ksvg/impl/SVGAElementImpl.cpp delete mode 100644 ksvg/impl/SVGAltGlyphDefElementImpl.cc create mode 100644 ksvg/impl/SVGAltGlyphDefElementImpl.cpp delete mode 100644 ksvg/impl/SVGAltGlyphElementImpl.cc create mode 100644 ksvg/impl/SVGAltGlyphElementImpl.cpp delete mode 100644 ksvg/impl/SVGAngleImpl.cc create mode 100644 ksvg/impl/SVGAngleImpl.cpp delete mode 100644 ksvg/impl/SVGAnimateColorElementImpl.cc create mode 100644 ksvg/impl/SVGAnimateColorElementImpl.cpp delete mode 100644 ksvg/impl/SVGAnimateElementImpl.cc create mode 100644 ksvg/impl/SVGAnimateElementImpl.cpp delete mode 100644 ksvg/impl/SVGAnimateMotionElementImpl.cc create mode 100644 ksvg/impl/SVGAnimateMotionElementImpl.cpp delete mode 100644 ksvg/impl/SVGAnimateTransformElementImpl.cc create mode 100644 ksvg/impl/SVGAnimateTransformElementImpl.cpp delete mode 100644 ksvg/impl/SVGAnimatedAngleImpl.cc create mode 100644 ksvg/impl/SVGAnimatedAngleImpl.cpp delete mode 100644 ksvg/impl/SVGAnimatedBooleanImpl.cc create mode 100644 ksvg/impl/SVGAnimatedBooleanImpl.cpp delete mode 100644 ksvg/impl/SVGAnimatedEnumerationImpl.cc create mode 100644 ksvg/impl/SVGAnimatedEnumerationImpl.cpp delete mode 100644 ksvg/impl/SVGAnimatedIntegerImpl.cc create mode 100644 ksvg/impl/SVGAnimatedIntegerImpl.cpp delete mode 100644 ksvg/impl/SVGAnimatedLengthImpl.cc create mode 100644 ksvg/impl/SVGAnimatedLengthImpl.cpp delete mode 100644 ksvg/impl/SVGAnimatedLengthListImpl.cc create mode 100644 ksvg/impl/SVGAnimatedLengthListImpl.cpp delete mode 100644 ksvg/impl/SVGAnimatedNumberImpl.cc create mode 100644 ksvg/impl/SVGAnimatedNumberImpl.cpp delete mode 100644 ksvg/impl/SVGAnimatedNumberListImpl.cc create mode 100644 ksvg/impl/SVGAnimatedNumberListImpl.cpp delete mode 100644 ksvg/impl/SVGAnimatedPathDataImpl.cc create mode 100644 ksvg/impl/SVGAnimatedPathDataImpl.cpp delete mode 100644 ksvg/impl/SVGAnimatedPointsImpl.cc create mode 100644 ksvg/impl/SVGAnimatedPointsImpl.cpp delete mode 100644 ksvg/impl/SVGAnimatedPreserveAspectRatioImpl.cc create mode 100644 ksvg/impl/SVGAnimatedPreserveAspectRatioImpl.cpp delete mode 100644 ksvg/impl/SVGAnimatedRectImpl.cc create mode 100644 ksvg/impl/SVGAnimatedRectImpl.cpp delete mode 100644 ksvg/impl/SVGAnimatedStringImpl.cc create mode 100644 ksvg/impl/SVGAnimatedStringImpl.cpp delete mode 100644 ksvg/impl/SVGAnimatedTransformListImpl.cc create mode 100644 ksvg/impl/SVGAnimatedTransformListImpl.cpp delete mode 100644 ksvg/impl/SVGAnimationElementImpl.cc create mode 100644 ksvg/impl/SVGAnimationElementImpl.cpp delete mode 100644 ksvg/impl/SVGBBoxTarget.cc create mode 100644 ksvg/impl/SVGBBoxTarget.cpp delete mode 100644 ksvg/impl/SVGCSSRuleImpl.cc create mode 100644 ksvg/impl/SVGCSSRuleImpl.cpp delete mode 100644 ksvg/impl/SVGCircleElementImpl.cc create mode 100644 ksvg/impl/SVGCircleElementImpl.cpp delete mode 100644 ksvg/impl/SVGClipPathElementImpl.cc create mode 100644 ksvg/impl/SVGClipPathElementImpl.cpp delete mode 100644 ksvg/impl/SVGColorImpl.cc create mode 100644 ksvg/impl/SVGColorImpl.cpp delete mode 100644 ksvg/impl/SVGColorProfileElementImpl.cc create mode 100644 ksvg/impl/SVGColorProfileElementImpl.cpp delete mode 100644 ksvg/impl/SVGColorProfileRuleImpl.cc create mode 100644 ksvg/impl/SVGColorProfileRuleImpl.cpp delete mode 100644 ksvg/impl/SVGComponentTransferFunctionElementImpl.cc create mode 100644 ksvg/impl/SVGComponentTransferFunctionElementImpl.cpp delete mode 100644 ksvg/impl/SVGContainerImpl.cc create mode 100644 ksvg/impl/SVGContainerImpl.cpp delete mode 100644 ksvg/impl/SVGCursorElementImpl.cc create mode 100644 ksvg/impl/SVGCursorElementImpl.cpp delete mode 100644 ksvg/impl/SVGDefinitionSrcElementImpl.cc create mode 100644 ksvg/impl/SVGDefinitionSrcElementImpl.cpp delete mode 100644 ksvg/impl/SVGDefsElementImpl.cc create mode 100644 ksvg/impl/SVGDefsElementImpl.cpp delete mode 100644 ksvg/impl/SVGDescElementImpl.cc create mode 100644 ksvg/impl/SVGDescElementImpl.cpp delete mode 100644 ksvg/impl/SVGDocumentImpl.cc create mode 100644 ksvg/impl/SVGDocumentImpl.cpp delete mode 100644 ksvg/impl/SVGEcma.cc create mode 100644 ksvg/impl/SVGEcma.cpp delete mode 100644 ksvg/impl/SVGElementImpl.cc create mode 100644 ksvg/impl/SVGElementImpl.cpp delete mode 100644 ksvg/impl/SVGElementInstanceImpl.cc create mode 100644 ksvg/impl/SVGElementInstanceImpl.cpp delete mode 100644 ksvg/impl/SVGElementInstanceListImpl.cc create mode 100644 ksvg/impl/SVGElementInstanceListImpl.cpp delete mode 100644 ksvg/impl/SVGEllipseElementImpl.cc create mode 100644 ksvg/impl/SVGEllipseElementImpl.cpp delete mode 100644 ksvg/impl/SVGEventImpl.cc create mode 100644 ksvg/impl/SVGEventImpl.cpp delete mode 100644 ksvg/impl/SVGExternalResourcesRequiredImpl.cc create mode 100644 ksvg/impl/SVGExternalResourcesRequiredImpl.cpp delete mode 100644 ksvg/impl/SVGFEBlendElementImpl.cc create mode 100644 ksvg/impl/SVGFEBlendElementImpl.cpp delete mode 100644 ksvg/impl/SVGFEColorMatrixElementImpl.cc create mode 100644 ksvg/impl/SVGFEColorMatrixElementImpl.cpp delete mode 100644 ksvg/impl/SVGFEComponentTransferElementImpl.cc create mode 100644 ksvg/impl/SVGFEComponentTransferElementImpl.cpp delete mode 100644 ksvg/impl/SVGFECompositeElementImpl.cc create mode 100644 ksvg/impl/SVGFECompositeElementImpl.cpp delete mode 100644 ksvg/impl/SVGFEConvolveMatrixElementImpl.cc create mode 100644 ksvg/impl/SVGFEConvolveMatrixElementImpl.cpp delete mode 100644 ksvg/impl/SVGFEDiffuseLightingElementImpl.cc create mode 100644 ksvg/impl/SVGFEDiffuseLightingElementImpl.cpp delete mode 100644 ksvg/impl/SVGFEDisplacementMapElementImpl.cc create mode 100644 ksvg/impl/SVGFEDisplacementMapElementImpl.cpp delete mode 100644 ksvg/impl/SVGFEDistantLightElementImpl.cc create mode 100644 ksvg/impl/SVGFEDistantLightElementImpl.cpp delete mode 100644 ksvg/impl/SVGFEFloodElementImpl.cc create mode 100644 ksvg/impl/SVGFEFloodElementImpl.cpp delete mode 100644 ksvg/impl/SVGFEFuncAElementImpl.cc create mode 100644 ksvg/impl/SVGFEFuncAElementImpl.cpp delete mode 100644 ksvg/impl/SVGFEFuncBElementImpl.cc create mode 100644 ksvg/impl/SVGFEFuncBElementImpl.cpp delete mode 100644 ksvg/impl/SVGFEFuncGElementImpl.cc create mode 100644 ksvg/impl/SVGFEFuncGElementImpl.cpp delete mode 100644 ksvg/impl/SVGFEFuncRElementImpl.cc create mode 100644 ksvg/impl/SVGFEFuncRElementImpl.cpp delete mode 100644 ksvg/impl/SVGFEGaussianBlurElementImpl.cc create mode 100644 ksvg/impl/SVGFEGaussianBlurElementImpl.cpp delete mode 100644 ksvg/impl/SVGFEImageElementImpl.cc create mode 100644 ksvg/impl/SVGFEImageElementImpl.cpp delete mode 100644 ksvg/impl/SVGFEMergeElementImpl.cc create mode 100644 ksvg/impl/SVGFEMergeElementImpl.cpp delete mode 100644 ksvg/impl/SVGFEMergeNodeElementImpl.cc create mode 100644 ksvg/impl/SVGFEMergeNodeElementImpl.cpp delete mode 100644 ksvg/impl/SVGFEMorphologyElementImpl.cc create mode 100644 ksvg/impl/SVGFEMorphologyElementImpl.cpp delete mode 100644 ksvg/impl/SVGFEOffsetElementImpl.cc create mode 100644 ksvg/impl/SVGFEOffsetElementImpl.cpp delete mode 100644 ksvg/impl/SVGFEPointLightElementImpl.cc create mode 100644 ksvg/impl/SVGFEPointLightElementImpl.cpp delete mode 100644 ksvg/impl/SVGFESpecularLightingElementImpl.cc create mode 100644 ksvg/impl/SVGFESpecularLightingElementImpl.cpp delete mode 100644 ksvg/impl/SVGFESpotLightElementImpl.cc create mode 100644 ksvg/impl/SVGFESpotLightElementImpl.cpp delete mode 100644 ksvg/impl/SVGFETileElementImpl.cc create mode 100644 ksvg/impl/SVGFETileElementImpl.cpp delete mode 100644 ksvg/impl/SVGFETurbulenceElementImpl.cc create mode 100644 ksvg/impl/SVGFETurbulenceElementImpl.cpp delete mode 100644 ksvg/impl/SVGFilterElementImpl.cc create mode 100644 ksvg/impl/SVGFilterElementImpl.cpp delete mode 100644 ksvg/impl/SVGFilterPrimitiveStandardAttributesImpl.cc create mode 100644 ksvg/impl/SVGFilterPrimitiveStandardAttributesImpl.cpp delete mode 100644 ksvg/impl/SVGFitToViewBoxImpl.cc create mode 100644 ksvg/impl/SVGFitToViewBoxImpl.cpp delete mode 100644 ksvg/impl/SVGFontElementImpl.cc create mode 100644 ksvg/impl/SVGFontElementImpl.cpp delete mode 100644 ksvg/impl/SVGFontFaceElementImpl.cc create mode 100644 ksvg/impl/SVGFontFaceElementImpl.cpp delete mode 100644 ksvg/impl/SVGFontFaceFormatElementImpl.cc create mode 100644 ksvg/impl/SVGFontFaceFormatElementImpl.cpp delete mode 100644 ksvg/impl/SVGFontFaceNameElementImpl.cc create mode 100644 ksvg/impl/SVGFontFaceNameElementImpl.cpp delete mode 100644 ksvg/impl/SVGFontFaceSrcElementImpl.cc create mode 100644 ksvg/impl/SVGFontFaceSrcElementImpl.cpp delete mode 100644 ksvg/impl/SVGFontFaceUriElementImpl.cc create mode 100644 ksvg/impl/SVGFontFaceUriElementImpl.cpp delete mode 100644 ksvg/impl/SVGForeignObjectElementImpl.cc create mode 100644 ksvg/impl/SVGForeignObjectElementImpl.cpp delete mode 100644 ksvg/impl/SVGGElementImpl.cc create mode 100644 ksvg/impl/SVGGElementImpl.cpp delete mode 100644 ksvg/impl/SVGGlyphElementImpl.cc create mode 100644 ksvg/impl/SVGGlyphElementImpl.cpp delete mode 100644 ksvg/impl/SVGGlyphRefElementImpl.cc create mode 100644 ksvg/impl/SVGGlyphRefElementImpl.cpp delete mode 100644 ksvg/impl/SVGGradientElementImpl.cc create mode 100644 ksvg/impl/SVGGradientElementImpl.cpp delete mode 100644 ksvg/impl/SVGHKernElementImpl.cc create mode 100644 ksvg/impl/SVGHKernElementImpl.cpp delete mode 100644 ksvg/impl/SVGHelperImpl.cc create mode 100644 ksvg/impl/SVGHelperImpl.cpp delete mode 100644 ksvg/impl/SVGICCColorImpl.cc create mode 100644 ksvg/impl/SVGICCColorImpl.cpp delete mode 100644 ksvg/impl/SVGImageElementImpl.cc create mode 100644 ksvg/impl/SVGImageElementImpl.cpp delete mode 100644 ksvg/impl/SVGLangSpaceImpl.cc create mode 100644 ksvg/impl/SVGLangSpaceImpl.cpp delete mode 100644 ksvg/impl/SVGLengthImpl.cc create mode 100644 ksvg/impl/SVGLengthImpl.cpp delete mode 100644 ksvg/impl/SVGLengthListImpl.cc create mode 100644 ksvg/impl/SVGLengthListImpl.cpp delete mode 100644 ksvg/impl/SVGLineElementImpl.cc create mode 100644 ksvg/impl/SVGLineElementImpl.cpp delete mode 100644 ksvg/impl/SVGLinearGradientElementImpl.cc create mode 100644 ksvg/impl/SVGLinearGradientElementImpl.cpp delete mode 100644 ksvg/impl/SVGLocatableImpl.cc create mode 100644 ksvg/impl/SVGLocatableImpl.cpp delete mode 100644 ksvg/impl/SVGMPathElementImpl.cc create mode 100644 ksvg/impl/SVGMPathElementImpl.cpp delete mode 100644 ksvg/impl/SVGMarkerElementImpl.cc create mode 100644 ksvg/impl/SVGMarkerElementImpl.cpp delete mode 100644 ksvg/impl/SVGMaskElementImpl.cc create mode 100644 ksvg/impl/SVGMaskElementImpl.cpp delete mode 100644 ksvg/impl/SVGMatrixImpl.cc create mode 100644 ksvg/impl/SVGMatrixImpl.cpp delete mode 100644 ksvg/impl/SVGMetadataElementImpl.cc create mode 100644 ksvg/impl/SVGMetadataElementImpl.cpp delete mode 100644 ksvg/impl/SVGMissingGlyphElementImpl.cc create mode 100644 ksvg/impl/SVGMissingGlyphElementImpl.cpp delete mode 100644 ksvg/impl/SVGNumberImpl.cc create mode 100644 ksvg/impl/SVGNumberImpl.cpp delete mode 100644 ksvg/impl/SVGNumberListImpl.cc create mode 100644 ksvg/impl/SVGNumberListImpl.cpp delete mode 100644 ksvg/impl/SVGPaintImpl.cc create mode 100644 ksvg/impl/SVGPaintImpl.cpp delete mode 100644 ksvg/impl/SVGPaintServerImpl.cc create mode 100644 ksvg/impl/SVGPaintServerImpl.cpp delete mode 100644 ksvg/impl/SVGPathElementImpl.cc create mode 100644 ksvg/impl/SVGPathElementImpl.cpp delete mode 100644 ksvg/impl/SVGPathSegArcImpl.cc create mode 100644 ksvg/impl/SVGPathSegArcImpl.cpp delete mode 100644 ksvg/impl/SVGPathSegClosePathImpl.cc create mode 100644 ksvg/impl/SVGPathSegClosePathImpl.cpp delete mode 100644 ksvg/impl/SVGPathSegCurvetoCubicImpl.cc create mode 100644 ksvg/impl/SVGPathSegCurvetoCubicImpl.cpp delete mode 100644 ksvg/impl/SVGPathSegCurvetoCubicSmoothImpl.cc create mode 100644 ksvg/impl/SVGPathSegCurvetoCubicSmoothImpl.cpp delete mode 100644 ksvg/impl/SVGPathSegCurvetoQuadraticImpl.cc create mode 100644 ksvg/impl/SVGPathSegCurvetoQuadraticImpl.cpp delete mode 100644 ksvg/impl/SVGPathSegCurvetoQuadraticSmoothImpl.cc create mode 100644 ksvg/impl/SVGPathSegCurvetoQuadraticSmoothImpl.cpp delete mode 100644 ksvg/impl/SVGPathSegImpl.cc create mode 100644 ksvg/impl/SVGPathSegImpl.cpp delete mode 100644 ksvg/impl/SVGPathSegLinetoHorizontalImpl.cc create mode 100644 ksvg/impl/SVGPathSegLinetoHorizontalImpl.cpp delete mode 100644 ksvg/impl/SVGPathSegLinetoImpl.cc create mode 100644 ksvg/impl/SVGPathSegLinetoImpl.cpp delete mode 100644 ksvg/impl/SVGPathSegLinetoVerticalImpl.cc create mode 100644 ksvg/impl/SVGPathSegLinetoVerticalImpl.cpp delete mode 100644 ksvg/impl/SVGPathSegListImpl.cc create mode 100644 ksvg/impl/SVGPathSegListImpl.cpp delete mode 100644 ksvg/impl/SVGPathSegMovetoImpl.cc create mode 100644 ksvg/impl/SVGPathSegMovetoImpl.cpp delete mode 100644 ksvg/impl/SVGPatternElementImpl.cc create mode 100644 ksvg/impl/SVGPatternElementImpl.cpp delete mode 100644 ksvg/impl/SVGPointImpl.cc create mode 100644 ksvg/impl/SVGPointImpl.cpp delete mode 100644 ksvg/impl/SVGPointListImpl.cc create mode 100644 ksvg/impl/SVGPointListImpl.cpp delete mode 100644 ksvg/impl/SVGPolyElementImpl.cc create mode 100644 ksvg/impl/SVGPolyElementImpl.cpp delete mode 100644 ksvg/impl/SVGPolygonElementImpl.cc create mode 100644 ksvg/impl/SVGPolygonElementImpl.cpp delete mode 100644 ksvg/impl/SVGPolylineElementImpl.cc create mode 100644 ksvg/impl/SVGPolylineElementImpl.cpp delete mode 100644 ksvg/impl/SVGPreserveAspectRatioImpl.cc create mode 100644 ksvg/impl/SVGPreserveAspectRatioImpl.cpp delete mode 100644 ksvg/impl/SVGRadialGradientElementImpl.cc create mode 100644 ksvg/impl/SVGRadialGradientElementImpl.cpp delete mode 100644 ksvg/impl/SVGRectElementImpl.cc create mode 100644 ksvg/impl/SVGRectElementImpl.cpp delete mode 100644 ksvg/impl/SVGRectImpl.cc create mode 100644 ksvg/impl/SVGRectImpl.cpp delete mode 100644 ksvg/impl/SVGSVGElementImpl.cc create mode 100644 ksvg/impl/SVGSVGElementImpl.cpp delete mode 100644 ksvg/impl/SVGScriptElementImpl.cc create mode 100644 ksvg/impl/SVGScriptElementImpl.cpp delete mode 100644 ksvg/impl/SVGSetElementImpl.cc create mode 100644 ksvg/impl/SVGSetElementImpl.cpp delete mode 100644 ksvg/impl/SVGShapeImpl.cc create mode 100644 ksvg/impl/SVGShapeImpl.cpp delete mode 100644 ksvg/impl/SVGStopElementImpl.cc create mode 100644 ksvg/impl/SVGStopElementImpl.cpp delete mode 100644 ksvg/impl/SVGStringListImpl.cc create mode 100644 ksvg/impl/SVGStringListImpl.cpp delete mode 100644 ksvg/impl/SVGStylableImpl.cc create mode 100644 ksvg/impl/SVGStylableImpl.cpp delete mode 100644 ksvg/impl/SVGStyleElementImpl.cc create mode 100644 ksvg/impl/SVGStyleElementImpl.cpp delete mode 100644 ksvg/impl/SVGSwitchElementImpl.cc create mode 100644 ksvg/impl/SVGSwitchElementImpl.cpp delete mode 100644 ksvg/impl/SVGSymbolElementImpl.cc create mode 100644 ksvg/impl/SVGSymbolElementImpl.cpp delete mode 100644 ksvg/impl/SVGTRefElementImpl.cc create mode 100644 ksvg/impl/SVGTRefElementImpl.cpp delete mode 100644 ksvg/impl/SVGTSpanElementImpl.cc create mode 100644 ksvg/impl/SVGTSpanElementImpl.cpp delete mode 100644 ksvg/impl/SVGTestsImpl.cc create mode 100644 ksvg/impl/SVGTestsImpl.cpp delete mode 100644 ksvg/impl/SVGTextContentElementImpl.cc create mode 100644 ksvg/impl/SVGTextContentElementImpl.cpp delete mode 100644 ksvg/impl/SVGTextElementImpl.cc create mode 100644 ksvg/impl/SVGTextElementImpl.cpp delete mode 100644 ksvg/impl/SVGTextPathElementImpl.cc create mode 100644 ksvg/impl/SVGTextPathElementImpl.cpp delete mode 100644 ksvg/impl/SVGTextPositioningElementImpl.cc create mode 100644 ksvg/impl/SVGTextPositioningElementImpl.cpp delete mode 100644 ksvg/impl/SVGTimeScheduler.cc create mode 100644 ksvg/impl/SVGTimeScheduler.cpp delete mode 100644 ksvg/impl/SVGTitleElementImpl.cc create mode 100644 ksvg/impl/SVGTitleElementImpl.cpp delete mode 100644 ksvg/impl/SVGTransformImpl.cc create mode 100644 ksvg/impl/SVGTransformImpl.cpp delete mode 100644 ksvg/impl/SVGTransformListImpl.cc create mode 100644 ksvg/impl/SVGTransformListImpl.cpp delete mode 100644 ksvg/impl/SVGTransformableImpl.cc create mode 100644 ksvg/impl/SVGTransformableImpl.cpp delete mode 100644 ksvg/impl/SVGURIReferenceImpl.cc create mode 100644 ksvg/impl/SVGURIReferenceImpl.cpp delete mode 100644 ksvg/impl/SVGUseElementImpl.cc create mode 100644 ksvg/impl/SVGUseElementImpl.cpp delete mode 100644 ksvg/impl/SVGVKernElementImpl.cc create mode 100644 ksvg/impl/SVGVKernElementImpl.cpp delete mode 100644 ksvg/impl/SVGViewElementImpl.cc create mode 100644 ksvg/impl/SVGViewElementImpl.cpp delete mode 100644 ksvg/impl/SVGViewSpecImpl.cc create mode 100644 ksvg/impl/SVGViewSpecImpl.cpp delete mode 100644 ksvg/impl/SVGWindowImpl.cc create mode 100644 ksvg/impl/SVGWindowImpl.cpp delete mode 100644 ksvg/impl/SVGZoomAndPanImpl.cc create mode 100644 ksvg/impl/SVGZoomAndPanImpl.cpp delete mode 100644 ksvg/impl/SVGZoomEventImpl.cc create mode 100644 ksvg/impl/SVGZoomEventImpl.cpp create mode 100644 ksvg/impl/libs/libtext2path/src/myboost/assert.h delete mode 100644 ksvg/impl/libs/libtext2path/src/myboost/assert.hpp create mode 100644 ksvg/impl/libs/libtext2path/src/myboost/checked_delete.h delete mode 100644 ksvg/impl/libs/libtext2path/src/myboost/checked_delete.hpp create mode 100644 ksvg/impl/libs/libtext2path/src/myboost/lightweight_mutex.h delete mode 100644 ksvg/impl/libs/libtext2path/src/myboost/lightweight_mutex.hpp create mode 100644 ksvg/impl/libs/libtext2path/src/myboost/shared_count.h delete mode 100644 ksvg/impl/libs/libtext2path/src/myboost/shared_count.hpp create mode 100644 ksvg/impl/libs/libtext2path/src/myboost/shared_ptr.h delete mode 100644 ksvg/impl/libs/libtext2path/src/myboost/shared_ptr.hpp create mode 100644 ksvg/impl/libs/libtext2path/src/myboost/throw_exception.h delete mode 100644 ksvg/impl/libs/libtext2path/src/myboost/throw_exception.hpp delete mode 100644 ksvg/impl/svgpathparser.cc create mode 100644 ksvg/impl/svgpathparser.cpp (limited to 'ksvg/impl') diff --git a/ksvg/impl/CMakeLists.txt b/ksvg/impl/CMakeLists.txt index 64599da1..82980a01 100644 --- a/ksvg/impl/CMakeLists.txt +++ b/ksvg/impl/CMakeLists.txt @@ -30,64 +30,64 @@ include_directories( tde_add_library( ksvgdomimpl STATIC_PIC AUTOMOC 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 + SVGLengthImpl.cpp SVGNumberImpl.cpp SVGPointImpl.cpp SVGTransformImpl.cpp + SVGMatrixImpl.cpp SVGRectImpl.cpp SVGAngleImpl.cpp SVGAnimatedLengthImpl.cpp + SVGAnimatedNumberImpl.cpp SVGAnimatedIntegerImpl.cpp SVGAnimatedBooleanImpl.cpp + SVGAnimatedEnumerationImpl.cpp SVGAnimatedPreserveAspectRatioImpl.cpp + SVGAnimatedRectImpl.cpp SVGAnimatedAngleImpl.cpp SVGAnimatedPathDataImpl.cpp + SVGAnimatedStringImpl.cpp SVGLengthListImpl.cpp SVGNumberListImpl.cpp + SVGPointListImpl.cpp SVGTransformListImpl.cpp SVGStringListImpl.cpp + SVGPathSegListImpl.cpp SVGElementInstanceListImpl.cpp + SVGAnimatedLengthListImpl.cpp SVGAnimatedNumberListImpl.cpp + SVGAnimatedPointsImpl.cpp SVGAnimatedTransformListImpl.cpp + SVGShapeImpl.cpp SVGContainerImpl.cpp SVGBBoxTarget.cpp SVGHelperImpl.cpp + SVGStylableImpl.cpp SVGTransformableImpl.cpp SVGTestsImpl.cpp SVGLangSpaceImpl.cpp + SVGExternalResourcesRequiredImpl.cpp SVGLocatableImpl.cpp SVGFitToViewBoxImpl.cpp + SVGPreserveAspectRatioImpl.cpp SVGZoomAndPanImpl.cpp SVGViewSpecImpl.cpp + SVGElementImpl.cpp SVGElementInstanceImpl.cpp SVGDocumentImpl.cpp + SVGSVGElementImpl.cpp SVGWindowImpl.cpp SVGDefsElementImpl.cpp + SVGUseElementImpl.cpp SVGDescElementImpl.cpp SVGTitleElementImpl.cpp + SVGGElementImpl.cpp SVGSwitchElementImpl.cpp SVGSymbolElementImpl.cpp + SVGImageElementImpl.cpp SVGURIReferenceImpl.cpp SVGStyleElementImpl.cpp + SVGCSSRuleImpl.cpp SVGPathElementImpl.cpp SVGPathSegImpl.cpp + SVGPathSegClosePathImpl.cpp SVGPathSegArcImpl.cpp SVGPathSegMovetoImpl.cpp + SVGPathSegCurvetoQuadraticImpl.cpp SVGPathSegCurvetoQuadraticSmoothImpl.cpp + SVGPathSegCurvetoCubicImpl.cpp SVGPathSegCurvetoCubicSmoothImpl.cpp + SVGPathSegLinetoImpl.cpp SVGPathSegLinetoHorizontalImpl.cpp + SVGPathSegLinetoVerticalImpl.cpp SVGRectElementImpl.cpp SVGCircleElementImpl.cpp + SVGEllipseElementImpl.cpp SVGLineElementImpl.cpp SVGPolyElementImpl.cpp + SVGPolylineElementImpl.cpp SVGPolygonElementImpl.cpp SVGTextElementImpl.cpp + SVGTSpanElementImpl.cpp SVGTRefElementImpl.cpp SVGTextPositioningElementImpl.cpp + SVGTextContentElementImpl.cpp SVGTextPathElementImpl.cpp SVGPaintImpl.cpp + SVGMarkerElementImpl.cpp SVGColorImpl.cpp SVGICCColorImpl.cpp + SVGColorProfileElementImpl.cpp SVGColorProfileRuleImpl.cpp SVGPaintServerImpl.cpp + SVGGradientElementImpl.cpp SVGStopElementImpl.cpp SVGLinearGradientElementImpl.cpp + SVGRadialGradientElementImpl.cpp SVGPatternElementImpl.cpp + SVGClipPathElementImpl.cpp SVGMaskElementImpl.cpp SVGFilterElementImpl.cpp + SVGFilterPrimitiveStandardAttributesImpl.cpp SVGFEBlendElementImpl.cpp + SVGFEColorMatrixElementImpl.cpp SVGFEComponentTransferElementImpl.cpp + SVGComponentTransferFunctionElementImpl.cpp SVGFEFuncAElementImpl.cpp + SVGFEFuncBElementImpl.cpp SVGFEFuncGElementImpl.cpp SVGFEFuncRElementImpl.cpp + SVGFECompositeElementImpl.cpp SVGFEConvolveMatrixElementImpl.cpp + SVGFEFloodElementImpl.cpp SVGFEGaussianBlurElementImpl.cpp + SVGFEDiffuseLightingElementImpl.cpp SVGFEDistantLightElementImpl.cpp + SVGFEPointLightElementImpl.cpp SVGFESpotLightElementImpl.cpp + SVGFEDisplacementMapElementImpl.cpp SVGFEMergeElementImpl.cpp + SVGFEMergeNodeElementImpl.cpp SVGFEImageElementImpl.cpp + SVGFEMorphologyElementImpl.cpp SVGFEOffsetElementImpl.cpp + SVGFESpecularLightingElementImpl.cpp SVGFETileElementImpl.cpp + SVGFETurbulenceElementImpl.cpp SVGCursorElementImpl.cpp + SVGAElementImpl.cpp SVGViewElementImpl.cpp SVGScriptElementImpl.cpp + SVGEventImpl.cpp SVGZoomEventImpl.cpp SVGEcma.cpp generateddata.cpp + SVGAnimationElementImpl.cpp SVGAnimateElementImpl.cpp SVGSetElementImpl.cpp + SVGAnimateMotionElementImpl.cpp SVGAnimateColorElementImpl.cpp + SVGAnimateTransformElementImpl.cpp SVGMPathElementImpl.cpp SVGTimeScheduler.cpp + SVGFontElementImpl.cpp SVGAltGlyphElementImpl.cpp SVGAltGlyphDefElementImpl.cpp + SVGGlyphRefElementImpl.cpp SVGGlyphElementImpl.cpp SVGMissingGlyphElementImpl.cpp + SVGFontFaceElementImpl.cpp SVGFontFaceFormatElementImpl.cpp + SVGFontFaceNameElementImpl.cpp SVGFontFaceSrcElementImpl.cpp + SVGFontFaceUriElementImpl.cpp SVGDefinitionSrcElementImpl.cpp + SVGHKernElementImpl.cpp SVGVKernElementImpl.cpp SVGMetadataElementImpl.cpp + SVGForeignObjectElementImpl.cpp svgpathparser.cpp LINK kjs-shared ) diff --git a/ksvg/impl/Makefile.am b/ksvg/impl/Makefile.am index 24e40d67..8509022f 100644 --- a/ksvg/impl/Makefile.am +++ b/ksvg/impl/Makefile.am @@ -29,87 +29,87 @@ KDE_OPTIONS = nofinal KDE_CXXFLAGS = $(USE_EXCEPTIONS) libksvgdomimpl_la_SOURCES = \ -SVGLengthImpl.cc SVGNumberImpl.cc SVGPointImpl.cc SVGTransformImpl.cc \ -SVGMatrixImpl.cc SVGRectImpl.cc SVGAngleImpl.cc \ +SVGLengthImpl.cpp SVGNumberImpl.cpp SVGPointImpl.cpp SVGTransformImpl.cpp \ +SVGMatrixImpl.cpp SVGRectImpl.cpp SVGAngleImpl.cpp \ \ -SVGAnimatedLengthImpl.cc SVGAnimatedNumberImpl.cc SVGAnimatedIntegerImpl.cc \ -SVGAnimatedBooleanImpl.cc SVGAnimatedEnumerationImpl.cc SVGAnimatedPreserveAspectRatioImpl.cc \ -SVGAnimatedRectImpl.cc SVGAnimatedAngleImpl.cc SVGAnimatedPathDataImpl.cc SVGAnimatedStringImpl.cc \ +SVGAnimatedLengthImpl.cpp SVGAnimatedNumberImpl.cpp SVGAnimatedIntegerImpl.cpp \ +SVGAnimatedBooleanImpl.cpp SVGAnimatedEnumerationImpl.cpp SVGAnimatedPreserveAspectRatioImpl.cpp \ +SVGAnimatedRectImpl.cpp SVGAnimatedAngleImpl.cpp SVGAnimatedPathDataImpl.cpp SVGAnimatedStringImpl.cpp \ \ -SVGLengthListImpl.cc SVGNumberListImpl.cc SVGPointListImpl.cc SVGTransformListImpl.cc \ -SVGStringListImpl.cc SVGPathSegListImpl.cc SVGElementInstanceListImpl.cc \ +SVGLengthListImpl.cpp SVGNumberListImpl.cpp SVGPointListImpl.cpp SVGTransformListImpl.cpp \ +SVGStringListImpl.cpp SVGPathSegListImpl.cpp SVGElementInstanceListImpl.cpp \ \ -SVGAnimatedLengthListImpl.cc SVGAnimatedNumberListImpl.cc \ -SVGAnimatedPointsImpl.cc SVGAnimatedTransformListImpl.cc \ +SVGAnimatedLengthListImpl.cpp SVGAnimatedNumberListImpl.cpp \ +SVGAnimatedPointsImpl.cpp SVGAnimatedTransformListImpl.cpp \ \ -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 \ +SVGShapeImpl.cpp SVGContainerImpl.cpp SVGBBoxTarget.cpp SVGHelperImpl.cpp \ +SVGStylableImpl.cpp SVGTransformableImpl.cpp SVGTestsImpl.cpp SVGLangSpaceImpl.cpp \ +SVGExternalResourcesRequiredImpl.cpp SVGLocatableImpl.cpp SVGFitToViewBoxImpl.cpp \ +SVGPreserveAspectRatioImpl.cpp SVGZoomAndPanImpl.cpp SVGViewSpecImpl.cpp \ \ -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 \ +SVGElementImpl.cpp SVGElementInstanceImpl.cpp \ +SVGDocumentImpl.cpp SVGSVGElementImpl.cpp SVGWindowImpl.cpp \ +SVGDefsElementImpl.cpp SVGUseElementImpl.cpp \ +SVGDescElementImpl.cpp SVGTitleElementImpl.cpp \ +SVGGElementImpl.cpp SVGSwitchElementImpl.cpp \ +SVGSymbolElementImpl.cpp SVGImageElementImpl.cpp \ +SVGURIReferenceImpl.cpp \ \ -SVGStyleElementImpl.cc SVGCSSRuleImpl.cc \ +SVGStyleElementImpl.cpp SVGCSSRuleImpl.cpp \ \ -SVGPathElementImpl.cc SVGPathSegImpl.cc SVGPathSegClosePathImpl.cc SVGPathSegArcImpl.cc \ -SVGPathSegMovetoImpl.cc SVGPathSegCurvetoQuadraticImpl.cc SVGPathSegCurvetoQuadraticSmoothImpl.cc \ -SVGPathSegCurvetoCubicImpl.cc SVGPathSegCurvetoCubicSmoothImpl.cc SVGPathSegLinetoImpl.cc \ -SVGPathSegLinetoHorizontalImpl.cc SVGPathSegLinetoVerticalImpl.cc \ +SVGPathElementImpl.cpp SVGPathSegImpl.cpp SVGPathSegClosePathImpl.cpp SVGPathSegArcImpl.cpp \ +SVGPathSegMovetoImpl.cpp SVGPathSegCurvetoQuadraticImpl.cpp SVGPathSegCurvetoQuadraticSmoothImpl.cpp \ +SVGPathSegCurvetoCubicImpl.cpp SVGPathSegCurvetoCubicSmoothImpl.cpp SVGPathSegLinetoImpl.cpp \ +SVGPathSegLinetoHorizontalImpl.cpp SVGPathSegLinetoVerticalImpl.cpp \ \ -SVGRectElementImpl.cc SVGCircleElementImpl.cc SVGEllipseElementImpl.cc SVGLineElementImpl.cc \ -SVGPolyElementImpl.cc SVGPolylineElementImpl.cc SVGPolygonElementImpl.cc \ +SVGRectElementImpl.cpp SVGCircleElementImpl.cpp SVGEllipseElementImpl.cpp SVGLineElementImpl.cpp \ +SVGPolyElementImpl.cpp SVGPolylineElementImpl.cpp SVGPolygonElementImpl.cpp \ \ -SVGTextElementImpl.cc SVGTSpanElementImpl.cc SVGTRefElementImpl.cc \ -SVGTextPositioningElementImpl.cc SVGTextContentElementImpl.cc SVGTextPathElementImpl.cc \ +SVGTextElementImpl.cpp SVGTSpanElementImpl.cpp SVGTRefElementImpl.cpp \ +SVGTextPositioningElementImpl.cpp SVGTextContentElementImpl.cpp SVGTextPathElementImpl.cpp \ \ -SVGPaintImpl.cc SVGMarkerElementImpl.cc \ +SVGPaintImpl.cpp SVGMarkerElementImpl.cpp \ \ -SVGColorImpl.cc SVGICCColorImpl.cc SVGColorProfileElementImpl.cc SVGColorProfileRuleImpl.cc \ +SVGColorImpl.cpp SVGICCColorImpl.cpp SVGColorProfileElementImpl.cpp SVGColorProfileRuleImpl.cpp \ \ -SVGPaintServerImpl.cc SVGGradientElementImpl.cc SVGStopElementImpl.cc \ -SVGLinearGradientElementImpl.cc SVGRadialGradientElementImpl.cc SVGPatternElementImpl.cc \ +SVGPaintServerImpl.cpp SVGGradientElementImpl.cpp SVGStopElementImpl.cpp \ +SVGLinearGradientElementImpl.cpp SVGRadialGradientElementImpl.cpp SVGPatternElementImpl.cpp \ \ -SVGClipPathElementImpl.cc SVGMaskElementImpl.cc \ +SVGClipPathElementImpl.cpp SVGMaskElementImpl.cpp \ \ -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 \ +SVGFilterElementImpl.cpp SVGFilterPrimitiveStandardAttributesImpl.cpp \ +SVGFEBlendElementImpl.cpp SVGFEColorMatrixElementImpl.cpp \ +SVGFEComponentTransferElementImpl.cpp SVGComponentTransferFunctionElementImpl.cpp \ +SVGFEFuncAElementImpl.cpp SVGFEFuncBElementImpl.cpp SVGFEFuncGElementImpl.cpp \ +SVGFEFuncRElementImpl.cpp SVGFECompositeElementImpl.cpp SVGFEConvolveMatrixElementImpl.cpp \ +SVGFEFloodElementImpl.cpp SVGFEGaussianBlurElementImpl.cpp SVGFEDiffuseLightingElementImpl.cpp \ +SVGFEDistantLightElementImpl.cpp SVGFEPointLightElementImpl.cpp SVGFESpotLightElementImpl.cpp \ +SVGFEDisplacementMapElementImpl.cpp SVGFEMergeElementImpl.cpp SVGFEMergeNodeElementImpl.cpp \ +SVGFEImageElementImpl.cpp SVGFEMorphologyElementImpl.cpp SVGFEOffsetElementImpl.cpp \ +SVGFESpecularLightingElementImpl.cpp SVGFETileElementImpl.cpp SVGFETurbulenceElementImpl.cpp \ \ -SVGCursorElementImpl.cc \ +SVGCursorElementImpl.cpp \ \ -SVGAElementImpl.cc SVGViewElementImpl.cc \ +SVGAElementImpl.cpp SVGViewElementImpl.cpp \ \ -SVGScriptElementImpl.cc SVGEventImpl.cc SVGZoomEventImpl.cc \ -SVGEcma.cc generateddata.cpp \ +SVGScriptElementImpl.cpp SVGEventImpl.cpp SVGZoomEventImpl.cpp \ +SVGEcma.cpp generateddata.cpp \ \ -SVGAnimationElementImpl.cc SVGAnimateElementImpl.cc SVGSetElementImpl.cc \ -SVGAnimateMotionElementImpl.cc SVGAnimateColorElementImpl.cc \ -SVGAnimateTransformElementImpl.cc SVGMPathElementImpl.cc SVGTimeScheduler.cc \ +SVGAnimationElementImpl.cpp SVGAnimateElementImpl.cpp SVGSetElementImpl.cpp \ +SVGAnimateMotionElementImpl.cpp SVGAnimateColorElementImpl.cpp \ +SVGAnimateTransformElementImpl.cpp SVGMPathElementImpl.cpp SVGTimeScheduler.cpp \ \ -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 \ +SVGFontElementImpl.cpp SVGAltGlyphElementImpl.cpp SVGAltGlyphDefElementImpl.cpp \ +SVGGlyphRefElementImpl.cpp SVGGlyphElementImpl.cpp SVGMissingGlyphElementImpl.cpp \ +SVGFontFaceElementImpl.cpp SVGFontFaceFormatElementImpl.cpp SVGFontFaceNameElementImpl.cpp \ +SVGFontFaceSrcElementImpl.cpp SVGFontFaceUriElementImpl.cpp SVGDefinitionSrcElementImpl.cpp \ +SVGHKernElementImpl.cpp SVGVKernElementImpl.cpp \ \ -SVGMetadataElementImpl.cc \ +SVGMetadataElementImpl.cpp \ \ -SVGForeignObjectElementImpl.cc \ +SVGForeignObjectElementImpl.cpp \ \ -svgpathparser.cc +svgpathparser.cpp libksvgdomimpl_la_METASOURCES = AUTO diff --git a/ksvg/impl/SVGAElementImpl.cc b/ksvg/impl/SVGAElementImpl.cc deleted file mode 100644 index 0885f254..00000000 --- a/ksvg/impl/SVGAElementImpl.cc +++ /dev/null @@ -1,115 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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(elem); - if(link) - return link; - } - } - - return 0; -} diff --git a/ksvg/impl/SVGAElementImpl.cpp b/ksvg/impl/SVGAElementImpl.cpp new file mode 100644 index 00000000..0885f254 --- /dev/null +++ b/ksvg/impl/SVGAElementImpl.cpp @@ -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. +*/ + +#include + +#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(elem); + if(link) + return link; + } + } + + return 0; +} diff --git a/ksvg/impl/SVGAltGlyphDefElementImpl.cc b/ksvg/impl/SVGAltGlyphDefElementImpl.cc deleted file mode 100644 index 6c60d72c..00000000 --- a/ksvg/impl/SVGAltGlyphDefElementImpl.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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() -{ -} diff --git a/ksvg/impl/SVGAltGlyphDefElementImpl.cpp b/ksvg/impl/SVGAltGlyphDefElementImpl.cpp new file mode 100644 index 00000000..6c60d72c --- /dev/null +++ b/ksvg/impl/SVGAltGlyphDefElementImpl.cpp @@ -0,0 +1,31 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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() +{ +} diff --git a/ksvg/impl/SVGAltGlyphElementImpl.cc b/ksvg/impl/SVGAltGlyphElementImpl.cc deleted file mode 100644 index 724fa50c..00000000 --- a/ksvg/impl/SVGAltGlyphElementImpl.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 ""; -} diff --git a/ksvg/impl/SVGAltGlyphElementImpl.cpp b/ksvg/impl/SVGAltGlyphElementImpl.cpp new file mode 100644 index 00000000..724fa50c --- /dev/null +++ b/ksvg/impl/SVGAltGlyphElementImpl.cpp @@ -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. +*/ + +#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 ""; +} diff --git a/ksvg/impl/SVGAngleImpl.cc b/ksvg/impl/SVGAngleImpl.cc deleted file mode 100644 index b69d95e8..00000000 --- a/ksvg/impl/SVGAngleImpl.cc +++ /dev/null @@ -1,275 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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; - - TQString 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(args[0].toNumber(exec))); - break; - case SVGAngleImpl::NewValueSpecifiedUnits: - obj->newValueSpecifiedUnits(static_cast(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(exec, "[[svgangle.constructor]]"); -} diff --git a/ksvg/impl/SVGAngleImpl.cpp b/ksvg/impl/SVGAngleImpl.cpp new file mode 100644 index 00000000..b69d95e8 --- /dev/null +++ b/ksvg/impl/SVGAngleImpl.cpp @@ -0,0 +1,275 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#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; + + TQString 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(args[0].toNumber(exec))); + break; + case SVGAngleImpl::NewValueSpecifiedUnits: + obj->newValueSpecifiedUnits(static_cast(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(exec, "[[svgangle.constructor]]"); +} diff --git a/ksvg/impl/SVGAnimateColorElementImpl.cc b/ksvg/impl/SVGAnimateColorElementImpl.cc deleted file mode 100644 index 0d2f0ff7..00000000 --- a/ksvg/impl/SVGAnimateColorElementImpl.cc +++ /dev/null @@ -1,96 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#include - -#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 - { - TQColor fromColor(m_fromColor->rgbColor().color()); - TQColor toColor(m_toColor->rgbColor().color()); - - int red = (int) rint(((toColor.red() - fromColor.red()) / static_cast(m_steps)) * m_step + fromColor.red()); - int green = (int) rint(((toColor.green() - fromColor.green()) / static_cast(m_steps)) * m_step + fromColor.green()); - int blue = (int) rint(((toColor.blue() - fromColor.blue()) / static_cast(m_steps)) * m_step + fromColor.blue()); - - TQString color = "rgb(" + TQString::number(red) + "," + TQString::number(green) + "," + TQString::number(blue) + ")"; - applyAttribute(getAttributeName(), color); - } - - if(m_step < m_steps) - m_step++; - else - { - ownerDoc()->timeScheduler()->disconnectIntervalTimer(this); - m_connected = false; - } -} diff --git a/ksvg/impl/SVGAnimateColorElementImpl.cpp b/ksvg/impl/SVGAnimateColorElementImpl.cpp new file mode 100644 index 00000000..0d2f0ff7 --- /dev/null +++ b/ksvg/impl/SVGAnimateColorElementImpl.cpp @@ -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 + +#include + +#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 + { + TQColor fromColor(m_fromColor->rgbColor().color()); + TQColor toColor(m_toColor->rgbColor().color()); + + int red = (int) rint(((toColor.red() - fromColor.red()) / static_cast(m_steps)) * m_step + fromColor.red()); + int green = (int) rint(((toColor.green() - fromColor.green()) / static_cast(m_steps)) * m_step + fromColor.green()); + int blue = (int) rint(((toColor.blue() - fromColor.blue()) / static_cast(m_steps)) * m_step + fromColor.blue()); + + TQString color = "rgb(" + TQString::number(red) + "," + TQString::number(green) + "," + TQString::number(blue) + ")"; + applyAttribute(getAttributeName(), color); + } + + if(m_step < m_steps) + m_step++; + else + { + ownerDoc()->timeScheduler()->disconnectIntervalTimer(this); + m_connected = false; + } +} diff --git a/ksvg/impl/SVGAnimateElementImpl.cc b/ksvg/impl/SVGAnimateElementImpl.cc deleted file mode 100644 index a67a9837..00000000 --- a/ksvg/impl/SVGAnimateElementImpl.cc +++ /dev/null @@ -1,189 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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(), TQString::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, TQString::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 -} diff --git a/ksvg/impl/SVGAnimateElementImpl.cpp b/ksvg/impl/SVGAnimateElementImpl.cpp new file mode 100644 index 00000000..a67a9837 --- /dev/null +++ b/ksvg/impl/SVGAnimateElementImpl.cpp @@ -0,0 +1,189 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#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(), TQString::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, TQString::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 +} diff --git a/ksvg/impl/SVGAnimateMotionElementImpl.cc b/ksvg/impl/SVGAnimateMotionElementImpl.cc deleted file mode 100644 index 3de6bab2..00000000 --- a/ksvg/impl/SVGAnimateMotionElementImpl.cc +++ /dev/null @@ -1,100 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 -#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(static_cast(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) - { - TQPoint p = m_pathArray->point(m_step - 50); - applyAttribute("x", TQString::number(p.x())); - applyAttribute("y", TQString::number(p.y())); - kdDebug() << " X " << p.x() << " Y " << p.y() << " (" << m_pathArray->count() << "; " << m_step << ")" < +#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(static_cast(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) + { + TQPoint p = m_pathArray->point(m_step - 50); + applyAttribute("x", TQString::number(p.x())); + applyAttribute("y", TQString::number(p.y())); + kdDebug() << " X " << p.x() << " Y " << p.y() << " (" << m_pathArray->count() << "; " << m_step << ")" < - -#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(); - - TQStringList stringList = TQStringList::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()) - { - TQString test = _values.string(); - - if(test.contains(";")) - { - SVGLengthImpl *temp = SVGSVGElementImpl::createSVGLength(); - - TQStringList list = TQStringList::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); - - TQString trans = transform->toString(); - TQString last = trans; - - if(targetElement()->hasAttribute("transform")) - { - trans += " " + targetElement()->getAttribute("transform").string(); - - if(!m_lastTransform.isEmpty()) - { - int pos = trans.find(m_lastTransform); - - TQString 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); - } - } - } - } - */ -} diff --git a/ksvg/impl/SVGAnimateTransformElementImpl.cpp b/ksvg/impl/SVGAnimateTransformElementImpl.cpp new file mode 100644 index 00000000..3eae35dd --- /dev/null +++ b/ksvg/impl/SVGAnimateTransformElementImpl.cpp @@ -0,0 +1,255 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#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(); + + TQStringList stringList = TQStringList::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()) + { + TQString test = _values.string(); + + if(test.contains(";")) + { + SVGLengthImpl *temp = SVGSVGElementImpl::createSVGLength(); + + TQStringList list = TQStringList::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); + + TQString trans = transform->toString(); + TQString last = trans; + + if(targetElement()->hasAttribute("transform")) + { + trans += " " + targetElement()->getAttribute("transform").string(); + + if(!m_lastTransform.isEmpty()) + { + int pos = trans.find(m_lastTransform); + + TQString 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); + } + } + } + } + */ +} diff --git a/ksvg/impl/SVGAnimatedAngleImpl.cc b/ksvg/impl/SVGAnimatedAngleImpl.cc deleted file mode 100644 index 41429847..00000000 --- a/ksvg/impl/SVGAnimatedAngleImpl.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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(); - } -} diff --git a/ksvg/impl/SVGAnimatedAngleImpl.cpp b/ksvg/impl/SVGAnimatedAngleImpl.cpp new file mode 100644 index 00000000..41429847 --- /dev/null +++ b/ksvg/impl/SVGAnimatedAngleImpl.cpp @@ -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 + +#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(); + } +} diff --git a/ksvg/impl/SVGAnimatedBooleanImpl.cc b/ksvg/impl/SVGAnimatedBooleanImpl.cc deleted file mode 100644 index f60b6a04..00000000 --- a/ksvg/impl/SVGAnimatedBooleanImpl.cc +++ /dev/null @@ -1,91 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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; - } -} diff --git a/ksvg/impl/SVGAnimatedBooleanImpl.cpp b/ksvg/impl/SVGAnimatedBooleanImpl.cpp new file mode 100644 index 00000000..f60b6a04 --- /dev/null +++ b/ksvg/impl/SVGAnimatedBooleanImpl.cpp @@ -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 + +#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; + } +} diff --git a/ksvg/impl/SVGAnimatedEnumerationImpl.cc b/ksvg/impl/SVGAnimatedEnumerationImpl.cc deleted file mode 100644 index 11e769ba..00000000 --- a/ksvg/impl/SVGAnimatedEnumerationImpl.cc +++ /dev/null @@ -1,91 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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(value.toNumber(exec))); - break; - default: - kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; - } -} diff --git a/ksvg/impl/SVGAnimatedEnumerationImpl.cpp b/ksvg/impl/SVGAnimatedEnumerationImpl.cpp new file mode 100644 index 00000000..11e769ba --- /dev/null +++ b/ksvg/impl/SVGAnimatedEnumerationImpl.cpp @@ -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 + +#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(value.toNumber(exec))); + break; + default: + kdWarning() << "Unhandled token in " << k_funcinfo << " : " << token << endl; + } +} diff --git a/ksvg/impl/SVGAnimatedIntegerImpl.cc b/ksvg/impl/SVGAnimatedIntegerImpl.cc deleted file mode 100644 index 00999e0e..00000000 --- a/ksvg/impl/SVGAnimatedIntegerImpl.cc +++ /dev/null @@ -1,89 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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; - } -} diff --git a/ksvg/impl/SVGAnimatedIntegerImpl.cpp b/ksvg/impl/SVGAnimatedIntegerImpl.cpp new file mode 100644 index 00000000..00999e0e --- /dev/null +++ b/ksvg/impl/SVGAnimatedIntegerImpl.cpp @@ -0,0 +1,89 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#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; + } +} diff --git a/ksvg/impl/SVGAnimatedLengthImpl.cc b/ksvg/impl/SVGAnimatedLengthImpl.cc deleted file mode 100644 index 1dead454..00000000 --- a/ksvg/impl/SVGAnimatedLengthImpl.cc +++ /dev/null @@ -1,94 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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(); - } -} diff --git a/ksvg/impl/SVGAnimatedLengthImpl.cpp b/ksvg/impl/SVGAnimatedLengthImpl.cpp new file mode 100644 index 00000000..1dead454 --- /dev/null +++ b/ksvg/impl/SVGAnimatedLengthImpl.cpp @@ -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 + +#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(); + } +} diff --git a/ksvg/impl/SVGAnimatedLengthListImpl.cc b/ksvg/impl/SVGAnimatedLengthListImpl.cc deleted file mode 100644 index cd603f27..00000000 --- a/ksvg/impl/SVGAnimatedLengthListImpl.cc +++ /dev/null @@ -1,93 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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(); - } -} diff --git a/ksvg/impl/SVGAnimatedLengthListImpl.cpp b/ksvg/impl/SVGAnimatedLengthListImpl.cpp new file mode 100644 index 00000000..cd603f27 --- /dev/null +++ b/ksvg/impl/SVGAnimatedLengthListImpl.cpp @@ -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 + +#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(); + } +} diff --git a/ksvg/impl/SVGAnimatedNumberImpl.cc b/ksvg/impl/SVGAnimatedNumberImpl.cc deleted file mode 100644 index 890d1895..00000000 --- a/ksvg/impl/SVGAnimatedNumberImpl.cc +++ /dev/null @@ -1,92 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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; - } -} diff --git a/ksvg/impl/SVGAnimatedNumberImpl.cpp b/ksvg/impl/SVGAnimatedNumberImpl.cpp new file mode 100644 index 00000000..890d1895 --- /dev/null +++ b/ksvg/impl/SVGAnimatedNumberImpl.cpp @@ -0,0 +1,92 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#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; + } +} diff --git a/ksvg/impl/SVGAnimatedNumberListImpl.cc b/ksvg/impl/SVGAnimatedNumberListImpl.cc deleted file mode 100644 index b04b31c0..00000000 --- a/ksvg/impl/SVGAnimatedNumberListImpl.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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(); - } -} diff --git a/ksvg/impl/SVGAnimatedNumberListImpl.cpp b/ksvg/impl/SVGAnimatedNumberListImpl.cpp new file mode 100644 index 00000000..b04b31c0 --- /dev/null +++ b/ksvg/impl/SVGAnimatedNumberListImpl.cpp @@ -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. +*/ + +#include + +#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(); + } +} diff --git a/ksvg/impl/SVGAnimatedPathDataImpl.cc b/ksvg/impl/SVGAnimatedPathDataImpl.cc deleted file mode 100644 index d0d7faae..00000000 --- a/ksvg/impl/SVGAnimatedPathDataImpl.cc +++ /dev/null @@ -1,106 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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(); -} -} diff --git a/ksvg/impl/SVGAnimatedPathDataImpl.cpp b/ksvg/impl/SVGAnimatedPathDataImpl.cpp new file mode 100644 index 00000000..d0d7faae --- /dev/null +++ b/ksvg/impl/SVGAnimatedPathDataImpl.cpp @@ -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 + +#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(); +} +} diff --git a/ksvg/impl/SVGAnimatedPointsImpl.cc b/ksvg/impl/SVGAnimatedPointsImpl.cc deleted file mode 100644 index 22246286..00000000 --- a/ksvg/impl/SVGAnimatedPointsImpl.cc +++ /dev/null @@ -1,137 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#include - -#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(TQString _points, SVGPointListImpl *points) -{ - if(_points.isEmpty()) - return; - - _points = _points.simplifyWhiteSpace(); - - if(_points.contains(",,") || _points.contains(", ,")) - return; - - _points.replace(',', ' '); - _points.replace('\r', TQString()); - _points.replace('\n', TQString()); - - _points = _points.simplifyWhiteSpace(); - - TQStringList pointList = TQStringList::split(' ', _points); - for(TQStringList::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; - } -} diff --git a/ksvg/impl/SVGAnimatedPointsImpl.cpp b/ksvg/impl/SVGAnimatedPointsImpl.cpp new file mode 100644 index 00000000..22246286 --- /dev/null +++ b/ksvg/impl/SVGAnimatedPointsImpl.cpp @@ -0,0 +1,137 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#include + +#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(TQString _points, SVGPointListImpl *points) +{ + if(_points.isEmpty()) + return; + + _points = _points.simplifyWhiteSpace(); + + if(_points.contains(",,") || _points.contains(", ,")) + return; + + _points.replace(',', ' '); + _points.replace('\r', TQString()); + _points.replace('\n', TQString()); + + _points = _points.simplifyWhiteSpace(); + + TQStringList pointList = TQStringList::split(' ', _points); + for(TQStringList::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; + } +} diff --git a/ksvg/impl/SVGAnimatedPreserveAspectRatioImpl.cc b/ksvg/impl/SVGAnimatedPreserveAspectRatioImpl.cc deleted file mode 100644 index 24ab74a5..00000000 --- a/ksvg/impl/SVGAnimatedPreserveAspectRatioImpl.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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(); - } -} diff --git a/ksvg/impl/SVGAnimatedPreserveAspectRatioImpl.cpp b/ksvg/impl/SVGAnimatedPreserveAspectRatioImpl.cpp new file mode 100644 index 00000000..24ab74a5 --- /dev/null +++ b/ksvg/impl/SVGAnimatedPreserveAspectRatioImpl.cpp @@ -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 + +#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(); + } +} diff --git a/ksvg/impl/SVGAnimatedRectImpl.cc b/ksvg/impl/SVGAnimatedRectImpl.cc deleted file mode 100644 index 62a35e1e..00000000 --- a/ksvg/impl/SVGAnimatedRectImpl.cc +++ /dev/null @@ -1,79 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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(); - } -} diff --git a/ksvg/impl/SVGAnimatedRectImpl.cpp b/ksvg/impl/SVGAnimatedRectImpl.cpp new file mode 100644 index 00000000..62a35e1e --- /dev/null +++ b/ksvg/impl/SVGAnimatedRectImpl.cpp @@ -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. +*/ + +#include + +#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(); + } +} diff --git a/ksvg/impl/SVGAnimatedStringImpl.cc b/ksvg/impl/SVGAnimatedStringImpl.cc deleted file mode 100644 index 90b58d83..00000000 --- a/ksvg/impl/SVGAnimatedStringImpl.cc +++ /dev/null @@ -1,88 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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; - } -} diff --git a/ksvg/impl/SVGAnimatedStringImpl.cpp b/ksvg/impl/SVGAnimatedStringImpl.cpp new file mode 100644 index 00000000..90b58d83 --- /dev/null +++ b/ksvg/impl/SVGAnimatedStringImpl.cpp @@ -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 + +#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; + } +} diff --git a/ksvg/impl/SVGAnimatedTransformListImpl.cc b/ksvg/impl/SVGAnimatedTransformListImpl.cc deleted file mode 100644 index 6c191c06..00000000 --- a/ksvg/impl/SVGAnimatedTransformListImpl.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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(); - } -} diff --git a/ksvg/impl/SVGAnimatedTransformListImpl.cpp b/ksvg/impl/SVGAnimatedTransformListImpl.cpp new file mode 100644 index 00000000..6c191c06 --- /dev/null +++ b/ksvg/impl/SVGAnimatedTransformListImpl.cpp @@ -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 + +#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(); + } +} diff --git a/ksvg/impl/SVGAnimationElementImpl.cc b/ksvg/impl/SVGAnimationElementImpl.cc deleted file mode 100644 index b87a9829..00000000 --- a/ksvg/impl/SVGAnimationElementImpl.cc +++ /dev/null @@ -1,463 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#include - -#include - -#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(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 TQString &data) const -{ - TQString parse = data.stripWhiteSpace(); - TQString 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) - { - TQString 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) - { - TQString 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; - TQString 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; - TQString 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; - TQString 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(); - TQString 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; - - TQString 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++) - { - TQString current = temp->getItem(i)->string(); - - if(current.startsWith("accessKey")) - { - // Register keyDownEventListener for the character - TQString 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(")"); - - TQString wallclockValue = current.mid(firstBrace + 1, secondBrace - firstBrace - 2); - - kdDebug() << "WALLCLOCK VALUE " << wallclockValue << endl; - } - else if(current.contains(".")) - { - int dotPosition = current.find("."); - - TQString element = current.mid(0, dotPosition); - TQString 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("-"); - - TQString 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 TQString &name, const TQString &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; -} diff --git a/ksvg/impl/SVGAnimationElementImpl.cpp b/ksvg/impl/SVGAnimationElementImpl.cpp new file mode 100644 index 00000000..b87a9829 --- /dev/null +++ b/ksvg/impl/SVGAnimationElementImpl.cpp @@ -0,0 +1,463 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#include + +#include + +#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(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 TQString &data) const +{ + TQString parse = data.stripWhiteSpace(); + TQString 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) + { + TQString 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) + { + TQString 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; + TQString 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; + TQString 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; + TQString 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(); + TQString 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; + + TQString 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++) + { + TQString current = temp->getItem(i)->string(); + + if(current.startsWith("accessKey")) + { + // Register keyDownEventListener for the character + TQString 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(")"); + + TQString wallclockValue = current.mid(firstBrace + 1, secondBrace - firstBrace - 2); + + kdDebug() << "WALLCLOCK VALUE " << wallclockValue << endl; + } + else if(current.contains(".")) + { + int dotPosition = current.find("."); + + TQString element = current.mid(0, dotPosition); + TQString 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("-"); + + TQString 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 TQString &name, const TQString &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; +} diff --git a/ksvg/impl/SVGBBoxTarget.cc b/ksvg/impl/SVGBBoxTarget.cc deleted file mode 100644 index 7d690373..00000000 --- a/ksvg/impl/SVGBBoxTarget.cc +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#include "SVGShapeImpl.h" -#include "SVGBBoxTarget.h" - -using namespace KSVG; - -SVGBBoxTarget::SVGBBoxTarget() -{ - m_target = 0; -} - -SVGBBoxTarget::~SVGBBoxTarget() -{ - if(m_target) - dynamic_cast(m_target)->deref(); -} - -SVGShapeImpl *SVGBBoxTarget::getBBoxTarget() const -{ - return m_target; -} - -void SVGBBoxTarget::setBBoxTarget(SVGShapeImpl *target) -{ - if(m_target) - dynamic_cast(m_target)->deref(); - - m_target = target; - - if(m_target) - dynamic_cast(m_target)->ref(); -} diff --git a/ksvg/impl/SVGBBoxTarget.cpp b/ksvg/impl/SVGBBoxTarget.cpp new file mode 100644 index 00000000..7d690373 --- /dev/null +++ b/ksvg/impl/SVGBBoxTarget.cpp @@ -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 + +#include "SVGShapeImpl.h" +#include "SVGBBoxTarget.h" + +using namespace KSVG; + +SVGBBoxTarget::SVGBBoxTarget() +{ + m_target = 0; +} + +SVGBBoxTarget::~SVGBBoxTarget() +{ + if(m_target) + dynamic_cast(m_target)->deref(); +} + +SVGShapeImpl *SVGBBoxTarget::getBBoxTarget() const +{ + return m_target; +} + +void SVGBBoxTarget::setBBoxTarget(SVGShapeImpl *target) +{ + if(m_target) + dynamic_cast(m_target)->deref(); + + m_target = target; + + if(m_target) + dynamic_cast(m_target)->ref(); +} diff --git a/ksvg/impl/SVGCSSRuleImpl.cc b/ksvg/impl/SVGCSSRuleImpl.cc deleted file mode 100644 index 250ed687..00000000 --- a/ksvg/impl/SVGCSSRuleImpl.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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() -{ -} diff --git a/ksvg/impl/SVGCSSRuleImpl.cpp b/ksvg/impl/SVGCSSRuleImpl.cpp new file mode 100644 index 00000000..250ed687 --- /dev/null +++ b/ksvg/impl/SVGCSSRuleImpl.cpp @@ -0,0 +1,31 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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() +{ +} diff --git a/ksvg/impl/SVGCircleElementImpl.cc b/ksvg/impl/SVGCircleElementImpl.cc deleted file mode 100644 index b50f2661..00000000 --- a/ksvg/impl/SVGCircleElementImpl.cc +++ /dev/null @@ -1,176 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 -#include - -#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 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); - } -} diff --git a/ksvg/impl/SVGCircleElementImpl.cpp b/ksvg/impl/SVGCircleElementImpl.cpp new file mode 100644 index 00000000..b50f2661 --- /dev/null +++ b/ksvg/impl/SVGCircleElementImpl.cpp @@ -0,0 +1,176 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 +#include + +#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 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); + } +} diff --git a/ksvg/impl/SVGClipPathElementImpl.cc b/ksvg/impl/SVGClipPathElementImpl.cc deleted file mode 100644 index 03512a41..00000000 --- a/ksvg/impl/SVGClipPathElementImpl.cc +++ /dev/null @@ -1,102 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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); -} diff --git a/ksvg/impl/SVGClipPathElementImpl.cpp b/ksvg/impl/SVGClipPathElementImpl.cpp new file mode 100644 index 00000000..03512a41 --- /dev/null +++ b/ksvg/impl/SVGClipPathElementImpl.cpp @@ -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. +*/ + +#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); +} diff --git a/ksvg/impl/SVGColorImpl.cc b/ksvg/impl/SVGColorImpl.cc deleted file mode 100644 index c5c44bcc..00000000 --- a/ksvg/impl/SVGColorImpl.cc +++ /dev/null @@ -1,538 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option); any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#include - -#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(TQColor 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(TQColor(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) -{ - TQColor color; - - TQString content = iccColor.string().right(iccColor.string().length() - 10); - TQString iccTarget = content.mid(0, content.find(',')); - - TQStringList colors = TQStringList::split(',', content); - TQString r = colors[1]; - TQString g = colors[2]; - TQString b = colors[3].left(colors[3].length() - 1); - - iccTarget = SVGURIReferenceImpl::getTarget(iccTarget); - - SVGColorProfileElementImpl *handle = 0; - if(m_object) - handle = static_cast(dynamic_cast(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(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(exec, "[[svgcolor.constructor]]"); -} diff --git a/ksvg/impl/SVGColorImpl.cpp b/ksvg/impl/SVGColorImpl.cpp new file mode 100644 index 00000000..c5c44bcc --- /dev/null +++ b/ksvg/impl/SVGColorImpl.cpp @@ -0,0 +1,538 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option); any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#include + +#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(TQColor 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(TQColor(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) +{ + TQColor color; + + TQString content = iccColor.string().right(iccColor.string().length() - 10); + TQString iccTarget = content.mid(0, content.find(',')); + + TQStringList colors = TQStringList::split(',', content); + TQString r = colors[1]; + TQString g = colors[2]; + TQString b = colors[3].left(colors[3].length() - 1); + + iccTarget = SVGURIReferenceImpl::getTarget(iccTarget); + + SVGColorProfileElementImpl *handle = 0; + if(m_object) + handle = static_cast(dynamic_cast(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(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(exec, "[[svgcolor.constructor]]"); +} diff --git a/ksvg/impl/SVGColorProfileElementImpl.cc b/ksvg/impl/SVGColorProfileElementImpl.cc deleted file mode 100644 index 89770494..00000000 --- a/ksvg/impl/SVGColorProfileElementImpl.cc +++ /dev/null @@ -1,269 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 -#include -#include - -#include - -#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: - { - TQString 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() -{ - TQString open; - bool temp; - return canLoad(false, temp, open, true); -} - -bool SVGColorProfileElementImpl::canLoad(bool remote, bool &tempFile, TQString &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(!TQFile::exists(open)) - { - if(verbose) - kdDebug() << "Couldn't load color profile " << file.path() << "! It does not exist." << endl; - - return false; - } - } - else - { - if(remote) - { - if(TDEIO::NetAccess::download(file, open, 0)) - tempFile = true; - } - } - - return true; -} - -bool SVGColorProfileElementImpl::loadColorProfile() -{ - TQString 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_NOOPTIMIZE); - else - m_hTrans = cmsCreateTransform(m_hInput, dwIn, m_hOutput, dwOut, cmsGetHeaderRenderingIntent(m_hInput), cmsFLAGS_NOOPTIMIZE); - - m_inputColorSpace = cmsGetColorSpace(m_hInput); - m_outputColorSpace = cmsGetColorSpace(m_hOutput); - m_loaded = true; - - if(tempFile) - TDEIO::NetAccess::removeTempFile(open); - - return true; -} - -void SVGColorProfileElementImpl::closeColorProfile() -{ - cmsDeleteTransform(m_hTrans); - cmsCloseProfile(m_hInput); -} - -TQRgb SVGColorProfileElementImpl::correctPixel(float r, float g, float b) -{ - if(!m_loaded) - { - if(!loadColorProfile()) - return tqRgb(0, 0, 0); - } - - unsigned short input[cmsMAXCHANNELS], output[cmsMAXCHANNELS]; - - 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 == cmsSigRgbData) - return tqRgb(output[0] / 257, output[1] / 257, output[2] / 257); - - return tqRgb(0, 0, 0); -} - -TQImage *SVGColorProfileElementImpl::correctImage(TQImage *input) -{ - if(!canLoad()) - return input; - - for(int y = 0; y < input->height(); y++) - { - for(int x = 0; x < input->width(); x++) - { - TQRgb pixel = input->pixel(x, y); - input->setPixel(x, y, correctPixel(tqRed(pixel), tqGreen(pixel), tqBlue(pixel))); - } - } - - return input; -} diff --git a/ksvg/impl/SVGColorProfileElementImpl.cpp b/ksvg/impl/SVGColorProfileElementImpl.cpp new file mode 100644 index 00000000..89770494 --- /dev/null +++ b/ksvg/impl/SVGColorProfileElementImpl.cpp @@ -0,0 +1,269 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 +#include +#include + +#include + +#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: + { + TQString 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() +{ + TQString open; + bool temp; + return canLoad(false, temp, open, true); +} + +bool SVGColorProfileElementImpl::canLoad(bool remote, bool &tempFile, TQString &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(!TQFile::exists(open)) + { + if(verbose) + kdDebug() << "Couldn't load color profile " << file.path() << "! It does not exist." << endl; + + return false; + } + } + else + { + if(remote) + { + if(TDEIO::NetAccess::download(file, open, 0)) + tempFile = true; + } + } + + return true; +} + +bool SVGColorProfileElementImpl::loadColorProfile() +{ + TQString 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_NOOPTIMIZE); + else + m_hTrans = cmsCreateTransform(m_hInput, dwIn, m_hOutput, dwOut, cmsGetHeaderRenderingIntent(m_hInput), cmsFLAGS_NOOPTIMIZE); + + m_inputColorSpace = cmsGetColorSpace(m_hInput); + m_outputColorSpace = cmsGetColorSpace(m_hOutput); + m_loaded = true; + + if(tempFile) + TDEIO::NetAccess::removeTempFile(open); + + return true; +} + +void SVGColorProfileElementImpl::closeColorProfile() +{ + cmsDeleteTransform(m_hTrans); + cmsCloseProfile(m_hInput); +} + +TQRgb SVGColorProfileElementImpl::correctPixel(float r, float g, float b) +{ + if(!m_loaded) + { + if(!loadColorProfile()) + return tqRgb(0, 0, 0); + } + + unsigned short input[cmsMAXCHANNELS], output[cmsMAXCHANNELS]; + + 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 == cmsSigRgbData) + return tqRgb(output[0] / 257, output[1] / 257, output[2] / 257); + + return tqRgb(0, 0, 0); +} + +TQImage *SVGColorProfileElementImpl::correctImage(TQImage *input) +{ + if(!canLoad()) + return input; + + for(int y = 0; y < input->height(); y++) + { + for(int x = 0; x < input->width(); x++) + { + TQRgb pixel = input->pixel(x, y); + input->setPixel(x, y, correctPixel(tqRed(pixel), tqGreen(pixel), tqBlue(pixel))); + } + } + + return input; +} diff --git a/ksvg/impl/SVGColorProfileRuleImpl.cc b/ksvg/impl/SVGColorProfileRuleImpl.cc deleted file mode 100644 index 74fffb47..00000000 --- a/ksvg/impl/SVGColorProfileRuleImpl.cc +++ /dev/null @@ -1,61 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; -} diff --git a/ksvg/impl/SVGColorProfileRuleImpl.cpp b/ksvg/impl/SVGColorProfileRuleImpl.cpp new file mode 100644 index 00000000..74fffb47 --- /dev/null +++ b/ksvg/impl/SVGColorProfileRuleImpl.cpp @@ -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. +*/ + +#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; +} diff --git a/ksvg/impl/SVGComponentTransferFunctionElementImpl.cc b/ksvg/impl/SVGComponentTransferFunctionElementImpl.cc deleted file mode 100644 index 9407b2a6..00000000 --- a/ksvg/impl/SVGComponentTransferFunctionElementImpl.cc +++ /dev/null @@ -1,103 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; -} diff --git a/ksvg/impl/SVGComponentTransferFunctionElementImpl.cpp b/ksvg/impl/SVGComponentTransferFunctionElementImpl.cpp new file mode 100644 index 00000000..9407b2a6 --- /dev/null +++ b/ksvg/impl/SVGComponentTransferFunctionElementImpl.cpp @@ -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 "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; +} diff --git a/ksvg/impl/SVGContainerImpl.cc b/ksvg/impl/SVGContainerImpl.cc deleted file mode 100644 index efaf62e8..00000000 --- a/ksvg/impl/SVGContainerImpl.cc +++ /dev/null @@ -1,133 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - TQRect rect; - DOM::Node node = firstChild(); - for(; !node.isNull(); node = node.nextSibling()) - { - SVGElementImpl *elem = ownerDoc()->getElementFromHandle(node.handle()); - SVGShapeImpl *shape = dynamic_cast(elem); - SVGTestsImpl *tests = dynamic_cast(elem); - SVGStylableImpl *style = dynamic_cast(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(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(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(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(ownerDoc()->getElementFromHandle(node.handle())); - if(shape) - shape->draw(); - } -} diff --git a/ksvg/impl/SVGContainerImpl.cpp b/ksvg/impl/SVGContainerImpl.cpp new file mode 100644 index 00000000..efaf62e8 --- /dev/null +++ b/ksvg/impl/SVGContainerImpl.cpp @@ -0,0 +1,133 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + TQRect rect; + DOM::Node node = firstChild(); + for(; !node.isNull(); node = node.nextSibling()) + { + SVGElementImpl *elem = ownerDoc()->getElementFromHandle(node.handle()); + SVGShapeImpl *shape = dynamic_cast(elem); + SVGTestsImpl *tests = dynamic_cast(elem); + SVGStylableImpl *style = dynamic_cast(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(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(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(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(ownerDoc()->getElementFromHandle(node.handle())); + if(shape) + shape->draw(); + } +} diff --git a/ksvg/impl/SVGCursorElementImpl.cc b/ksvg/impl/SVGCursorElementImpl.cc deleted file mode 100644 index a83afd73..00000000 --- a/ksvg/impl/SVGCursorElementImpl.cc +++ /dev/null @@ -1,102 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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; - } -} diff --git a/ksvg/impl/SVGCursorElementImpl.cpp b/ksvg/impl/SVGCursorElementImpl.cpp new file mode 100644 index 00000000..a83afd73 --- /dev/null +++ b/ksvg/impl/SVGCursorElementImpl.cpp @@ -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. +*/ + +#include + +#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; + } +} diff --git a/ksvg/impl/SVGDefinitionSrcElementImpl.cc b/ksvg/impl/SVGDefinitionSrcElementImpl.cc deleted file mode 100644 index fdd5b159..00000000 --- a/ksvg/impl/SVGDefinitionSrcElementImpl.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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() -{ -} diff --git a/ksvg/impl/SVGDefinitionSrcElementImpl.cpp b/ksvg/impl/SVGDefinitionSrcElementImpl.cpp new file mode 100644 index 00000000..fdd5b159 --- /dev/null +++ b/ksvg/impl/SVGDefinitionSrcElementImpl.cpp @@ -0,0 +1,31 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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() +{ +} diff --git a/ksvg/impl/SVGDefsElementImpl.cc b/ksvg/impl/SVGDefsElementImpl.cc deleted file mode 100644 index f388e482..00000000 --- a/ksvg/impl/SVGDefsElementImpl.cc +++ /dev/null @@ -1,32 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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() -{ -} diff --git a/ksvg/impl/SVGDefsElementImpl.cpp b/ksvg/impl/SVGDefsElementImpl.cpp new file mode 100644 index 00000000..f388e482 --- /dev/null +++ b/ksvg/impl/SVGDefsElementImpl.cpp @@ -0,0 +1,32 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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() +{ +} diff --git a/ksvg/impl/SVGDescElementImpl.cc b/ksvg/impl/SVGDescElementImpl.cc deleted file mode 100644 index 9d8ceef2..00000000 --- a/ksvg/impl/SVGDescElementImpl.cc +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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()); -} diff --git a/ksvg/impl/SVGDescElementImpl.cpp b/ksvg/impl/SVGDescElementImpl.cpp new file mode 100644 index 00000000..9d8ceef2 --- /dev/null +++ b/ksvg/impl/SVGDescElementImpl.cpp @@ -0,0 +1,37 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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()); +} diff --git a/ksvg/impl/SVGDocumentImpl.cc b/ksvg/impl/SVGDocumentImpl.cc deleted file mode 100644 index ce6de16e..00000000 --- a/ksvg/impl/SVGDocumentImpl.cc +++ /dev/null @@ -1,703 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#define USE_VALGRIND 0 - -#if USE_VALGRIND -#include -#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 - -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 TQDict 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) : TQObject(), DOM::DomShared(), DOM::Document(), SVGDOMNodeBridge(static_cast(*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); - - TQPtrList killList; - - DOM::Node node = firstChild(); - for(; !node.isNull(); node = node.nextSibling()) - { - SVGShapeImpl *shape = dynamic_cast(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(this)); - m_window->ref(); - } - - return m_window; -} - -float SVGDocumentImpl::screenPixelsPerMillimeterX() const -{ - if(canvas() && canvas()->drawWindow()) - { - TQPaintDeviceMetrics metrics(canvas()->drawWindow()); - return float(metrics.width()) / float(metrics.widthMM()); - } - else - return 90.0; -} - -float SVGDocumentImpl::screenPixelsPerMillimeterY() const -{ - if(canvas() && canvas()->drawWindow()) - { - TQPaintDeviceMetrics 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(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(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, TQT_SIGNAL(gotResult(TQIODevice *)), this, TQT_SLOT(slotSVGContent(TQIODevice *))); - m_loader->getSVGContent(url); - } - else - return false; - - return true; -} - -void SVGDocumentImpl::slotSVGContent(TQIODevice *dev) -{ - TQXmlInputSource *inputSource = new TQXmlInputSource(dev); - - if(m_reader) - delete m_reader; - - KSVGReader::ParsingArgs args; - args.fit = m_fit; - args.getURLMode = false; - - TQString 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, TQT_SIGNAL(finished(bool, const TQString &)), this, TQT_SLOT(slotFinishedParsing(bool, const TQString &))); - m_t.start(); - -#if USE_VALGRIND - CALLTREE_ZERO_STATS(); -#endif - - m_reader->parse(inputSource); - delete dev; -} - -void SVGDocumentImpl::parseSVG(TQXmlInputSource *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, TQT_SIGNAL(finished(bool, const TQString &)), this, TQT_SLOT(slotFinishedParsing(bool, const TQString &))); - -#if USE_VALGRIND - CALLTREE_ZERO_STATS(); -#endif - - m_reader->parse(inputSource); -} - -void SVGDocumentImpl::finishParsing(bool error, const TQString &errorDesc) -{ - if(m_reader) - m_reader->finishParsing(error, errorDesc); -} - -void SVGDocumentImpl::slotFinishedParsing(bool error, const TQString &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(element); - if(container) - executeScriptsRecursive(node); - - SVGScriptElementImpl *script = dynamic_cast(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(element); - if(container) - { - if(!executeScriptsRecursiveCheck(node)) - return false; - } - - SVGScriptElementImpl *script = dynamic_cast(element); - - if(script) - { - if(!script->canExecuteScript()) - { - test = false; - break; - } - } - } - - return test; -} - -void SVGDocumentImpl::executeScripts() -{ - bool test = executeScriptsRecursiveCheck(*rootElement()); - - if(!test) - TQTimer::singleShot(50, this, TQT_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(test); - if(container) - { - SVGElementImpl *found = recursiveSearch(node, id); - if(found) - return found; - } - - // Look in SVGSVGElementImpl's - SVGSVGElementImpl *svgtest = dynamic_cast(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(obj)->createElement(args[0].toString(exec).string()), obj); - else if(id == SVGDocumentImpl::CreateElementNS) - newElement = obj->createElement(args[1].toString(exec).qstring(), static_cast(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_elemDictHashSizeIndexgetElementById(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) - { - TQPtrDictIterator it(m_documentDict); - for(; it.current(); ++it) - { - SVGElementImpl *temp = it.current()->getElementByIdRecursive(0, elementId, true); - if(temp) - return temp; - } - } - - return element; -} diff --git a/ksvg/impl/SVGDocumentImpl.cpp b/ksvg/impl/SVGDocumentImpl.cpp new file mode 100644 index 00000000..ce6de16e --- /dev/null +++ b/ksvg/impl/SVGDocumentImpl.cpp @@ -0,0 +1,703 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#define USE_VALGRIND 0 + +#if USE_VALGRIND +#include +#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 + +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 TQDict 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) : TQObject(), DOM::DomShared(), DOM::Document(), SVGDOMNodeBridge(static_cast(*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); + + TQPtrList killList; + + DOM::Node node = firstChild(); + for(; !node.isNull(); node = node.nextSibling()) + { + SVGShapeImpl *shape = dynamic_cast(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(this)); + m_window->ref(); + } + + return m_window; +} + +float SVGDocumentImpl::screenPixelsPerMillimeterX() const +{ + if(canvas() && canvas()->drawWindow()) + { + TQPaintDeviceMetrics metrics(canvas()->drawWindow()); + return float(metrics.width()) / float(metrics.widthMM()); + } + else + return 90.0; +} + +float SVGDocumentImpl::screenPixelsPerMillimeterY() const +{ + if(canvas() && canvas()->drawWindow()) + { + TQPaintDeviceMetrics 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(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(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, TQT_SIGNAL(gotResult(TQIODevice *)), this, TQT_SLOT(slotSVGContent(TQIODevice *))); + m_loader->getSVGContent(url); + } + else + return false; + + return true; +} + +void SVGDocumentImpl::slotSVGContent(TQIODevice *dev) +{ + TQXmlInputSource *inputSource = new TQXmlInputSource(dev); + + if(m_reader) + delete m_reader; + + KSVGReader::ParsingArgs args; + args.fit = m_fit; + args.getURLMode = false; + + TQString 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, TQT_SIGNAL(finished(bool, const TQString &)), this, TQT_SLOT(slotFinishedParsing(bool, const TQString &))); + m_t.start(); + +#if USE_VALGRIND + CALLTREE_ZERO_STATS(); +#endif + + m_reader->parse(inputSource); + delete dev; +} + +void SVGDocumentImpl::parseSVG(TQXmlInputSource *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, TQT_SIGNAL(finished(bool, const TQString &)), this, TQT_SLOT(slotFinishedParsing(bool, const TQString &))); + +#if USE_VALGRIND + CALLTREE_ZERO_STATS(); +#endif + + m_reader->parse(inputSource); +} + +void SVGDocumentImpl::finishParsing(bool error, const TQString &errorDesc) +{ + if(m_reader) + m_reader->finishParsing(error, errorDesc); +} + +void SVGDocumentImpl::slotFinishedParsing(bool error, const TQString &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(element); + if(container) + executeScriptsRecursive(node); + + SVGScriptElementImpl *script = dynamic_cast(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(element); + if(container) + { + if(!executeScriptsRecursiveCheck(node)) + return false; + } + + SVGScriptElementImpl *script = dynamic_cast(element); + + if(script) + { + if(!script->canExecuteScript()) + { + test = false; + break; + } + } + } + + return test; +} + +void SVGDocumentImpl::executeScripts() +{ + bool test = executeScriptsRecursiveCheck(*rootElement()); + + if(!test) + TQTimer::singleShot(50, this, TQT_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(test); + if(container) + { + SVGElementImpl *found = recursiveSearch(node, id); + if(found) + return found; + } + + // Look in SVGSVGElementImpl's + SVGSVGElementImpl *svgtest = dynamic_cast(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(obj)->createElement(args[0].toString(exec).string()), obj); + else if(id == SVGDocumentImpl::CreateElementNS) + newElement = obj->createElement(args[1].toString(exec).qstring(), static_cast(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_elemDictHashSizeIndexgetElementById(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) + { + TQPtrDictIterator it(m_documentDict); + for(; it.current(); ++it) + { + SVGElementImpl *temp = it.current()->getElementByIdRecursive(0, elementId, true); + if(temp) + return temp; + } + } + + return element; +} diff --git a/ksvg/impl/SVGEcma.cc b/ksvg/impl/SVGEcma.cc deleted file mode 100644 index 5036f591..00000000 --- a/ksvg/impl/SVGEcma.cc +++ /dev/null @@ -1,842 +0,0 @@ -/* - 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 - -#include - -#include - -#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 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(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(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(doc->getElementFromHandle(newChild.handle())); - SVGElementImpl *newElement = doc->getElementFromHandle(newChild.handle()); - SVGShapeImpl *beforeElement = dynamic_cast(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]), TQString(), 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(); - } -} diff --git a/ksvg/impl/SVGEcma.cpp b/ksvg/impl/SVGEcma.cpp new file mode 100644 index 00000000..5036f591 --- /dev/null +++ b/ksvg/impl/SVGEcma.cpp @@ -0,0 +1,842 @@ +/* + 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 + +#include + +#include + +#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 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(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(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(doc->getElementFromHandle(newChild.handle())); + SVGElementImpl *newElement = doc->getElementFromHandle(newChild.handle()); + SVGShapeImpl *beforeElement = dynamic_cast(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]), TQString(), 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(); + } +} diff --git a/ksvg/impl/SVGElementImpl.cc b/ksvg/impl/SVGElementImpl.cc deleted file mode 100644 index 523c5807..00000000 --- a/ksvg/impl/SVGElementImpl.cc +++ /dev/null @@ -1,711 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#include - -#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(*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(id), listener, false); - m_eventListeners.append(rl); - - listener->deref(); - } -} - -int SVGElementImpl::getEventListeners(bool local) -{ - int events = 0; - - TQPtrListIterator 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) - { - TQPtrListIterator 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) - TQPtrListIterator it(m_eventListeners); - for(; it.current(); ++it) - { - SVGRegisteredEventListener *current = it.current(); - - TQString 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 - TQPtrListIterator 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) - { - TQPtrListIterator it(element->m_eventListeners); - for(; it.current(); ++it) - { - if(it.current()->id == id) - return true; - } - } - } - - return false; -} - -void SVGElementImpl::removeEventListener(int id) -{ - TQPtrListIterator 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) -{ - TQPtrListIterator 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(); -} - -TQDict &SVGElementImpl::attributes() -{ - return m_attributes; -} - -// tdehtml 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(exec->interpreter())->setAttributeSetMode(true); - bridge(exec)->put(exec, Identifier(UString(name)), String(value), KJS::Internal); - static_cast(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(exec->interpreter())->setAttributeGetMode(true); - retVal = bridge(exec)->get(exec, Identifier(UString(name))).toString(exec).string(); - static_cast(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 TQString &name, const TQString &value) -{ - if(hasAttribute(name)) - { - TQString 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 TQXmlAttributes &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(this); - - if(style) - style->processStyle(); -} - -void SVGElementImpl::setAttributes(bool deep) -{ - // Finalize style - SVGStylableImpl *style = dynamic_cast(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 TQPoint &p, const TQPoint &a, SVGMouseEventImpl *mev) -{ - SVGShapeImpl *shape = dynamic_cast(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(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 - TQPtrList 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); - - TQPtrListIterator 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(TQKeyEvent *ke) -{ - DOM::AbstractView temp; - - SVGEvent::EventId evtId = SVGEvent::UNKNOWN_EVENT; - - if(ke->type() == TQEvent::KeyRelease && !ke->isAutoRepeat()) - evtId = SVGEvent::KEYUP_EVENT; - else if(ke->isAutoRepeat()) - evtId = SVGEvent::KEYPRESS_EVENT; - else if(ke->type() == TQEvent::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(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(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 TQString &errorDesc) -{ - if(ownerDoc()) - { - ownerDoc()->finishParsing(true, errorDesc); - if(hasEventListener(SVGEvent::ERROR_EVENT, true)) - dispatchEvent(SVGEvent::ERROR_EVENT, false, false); - } -} - -TQString SVGElementImpl::collectText() -{ - TQString 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; -} diff --git a/ksvg/impl/SVGElementImpl.cpp b/ksvg/impl/SVGElementImpl.cpp new file mode 100644 index 00000000..523c5807 --- /dev/null +++ b/ksvg/impl/SVGElementImpl.cpp @@ -0,0 +1,711 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#include + +#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(*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(id), listener, false); + m_eventListeners.append(rl); + + listener->deref(); + } +} + +int SVGElementImpl::getEventListeners(bool local) +{ + int events = 0; + + TQPtrListIterator 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) + { + TQPtrListIterator 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) + TQPtrListIterator it(m_eventListeners); + for(; it.current(); ++it) + { + SVGRegisteredEventListener *current = it.current(); + + TQString 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 + TQPtrListIterator 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) + { + TQPtrListIterator it(element->m_eventListeners); + for(; it.current(); ++it) + { + if(it.current()->id == id) + return true; + } + } + } + + return false; +} + +void SVGElementImpl::removeEventListener(int id) +{ + TQPtrListIterator 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) +{ + TQPtrListIterator 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(); +} + +TQDict &SVGElementImpl::attributes() +{ + return m_attributes; +} + +// tdehtml 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(exec->interpreter())->setAttributeSetMode(true); + bridge(exec)->put(exec, Identifier(UString(name)), String(value), KJS::Internal); + static_cast(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(exec->interpreter())->setAttributeGetMode(true); + retVal = bridge(exec)->get(exec, Identifier(UString(name))).toString(exec).string(); + static_cast(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 TQString &name, const TQString &value) +{ + if(hasAttribute(name)) + { + TQString 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 TQXmlAttributes &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(this); + + if(style) + style->processStyle(); +} + +void SVGElementImpl::setAttributes(bool deep) +{ + // Finalize style + SVGStylableImpl *style = dynamic_cast(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 TQPoint &p, const TQPoint &a, SVGMouseEventImpl *mev) +{ + SVGShapeImpl *shape = dynamic_cast(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(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 + TQPtrList 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); + + TQPtrListIterator 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(TQKeyEvent *ke) +{ + DOM::AbstractView temp; + + SVGEvent::EventId evtId = SVGEvent::UNKNOWN_EVENT; + + if(ke->type() == TQEvent::KeyRelease && !ke->isAutoRepeat()) + evtId = SVGEvent::KEYUP_EVENT; + else if(ke->isAutoRepeat()) + evtId = SVGEvent::KEYPRESS_EVENT; + else if(ke->type() == TQEvent::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(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(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 TQString &errorDesc) +{ + if(ownerDoc()) + { + ownerDoc()->finishParsing(true, errorDesc); + if(hasEventListener(SVGEvent::ERROR_EVENT, true)) + dispatchEvent(SVGEvent::ERROR_EVENT, false, false); + } +} + +TQString SVGElementImpl::collectText() +{ + TQString 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; +} diff --git a/ksvg/impl/SVGElementInstanceImpl.cc b/ksvg/impl/SVGElementInstanceImpl.cc deleted file mode 100644 index bd1fc58d..00000000 --- a/ksvg/impl/SVGElementInstanceImpl.cc +++ /dev/null @@ -1,106 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; -} diff --git a/ksvg/impl/SVGElementInstanceImpl.cpp b/ksvg/impl/SVGElementInstanceImpl.cpp new file mode 100644 index 00000000..bd1fc58d --- /dev/null +++ b/ksvg/impl/SVGElementInstanceImpl.cpp @@ -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 "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; +} diff --git a/ksvg/impl/SVGElementInstanceListImpl.cc b/ksvg/impl/SVGElementInstanceListImpl.cc deleted file mode 100644 index c0748008..00000000 --- a/ksvg/impl/SVGElementInstanceListImpl.cc +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; -} diff --git a/ksvg/impl/SVGElementInstanceListImpl.cpp b/ksvg/impl/SVGElementInstanceListImpl.cpp new file mode 100644 index 00000000..c0748008 --- /dev/null +++ b/ksvg/impl/SVGElementInstanceListImpl.cpp @@ -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. +*/ + +#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; +} diff --git a/ksvg/impl/SVGEllipseElementImpl.cc b/ksvg/impl/SVGEllipseElementImpl.cc deleted file mode 100644 index 1487d79b..00000000 --- a/ksvg/impl/SVGEllipseElementImpl.cc +++ /dev/null @@ -1,198 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 -#include - -#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 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 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); - } -} diff --git a/ksvg/impl/SVGEllipseElementImpl.cpp b/ksvg/impl/SVGEllipseElementImpl.cpp new file mode 100644 index 00000000..1487d79b --- /dev/null +++ b/ksvg/impl/SVGEllipseElementImpl.cpp @@ -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 +#include + +#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 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 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); + } +} diff --git a/ksvg/impl/SVGEventImpl.cc b/ksvg/impl/SVGEventImpl.cc deleted file mode 100644 index 9ff61abc..00000000 --- a/ksvg/impl/SVGEventImpl.cc +++ /dev/null @@ -1,990 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - Additional copyright: - (C) 2001 Peter Kelly - (C) 2001 Tobias Anton - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -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 = TQDateTime::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 = TQDateTime::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() -{ - TQDateTime epoch(TQDate(1970, 1, 1), TQTime(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(TQKeyEvent *key, DOM::AbstractView &view, SVGEvent::EventId _id) : SVGUIEventImpl(_id, true, true, view, 0) -{ - qKeyEvent = new TQKeyEvent(key->type(), key->key(), key->ascii(), key->state(), key->text(), key->isAutoRepeat(), key->count()); - - // Events are supposed to be accepted by default in TQt! - // This line made TQLineEdit's keyevents be ignored, so they were sent to the tdehtmlview - // (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 TQt::Key_Enter: - m_numPad = true; - /* fall through */ - case TQt::Key_Return: - m_virtKeyVal = DOM_VK_ENTER; - break; - case TQt::Key_NumLock: - m_numPad = true; - m_virtKeyVal = DOM_VK_NUM_LOCK; - break; - case TQt::Key_Alt: - m_virtKeyVal = DOM_VK_RIGHT_ALT; - // ### DOM_VK_LEFT_ALT; - break; - case TQt::Key_Control: - m_virtKeyVal = DOM_VK_LEFT_CONTROL; - // ### DOM_VK_RIGHT_CONTROL - break; - case TQt::Key_Shift: - m_virtKeyVal = DOM_VK_LEFT_SHIFT; - // ### DOM_VK_RIGHT_SHIFT - break; - case TQt::Key_Meta: - m_virtKeyVal = DOM_VK_LEFT_META; - // ### DOM_VK_RIGHT_META - break; - case TQt::Key_CapsLock: - m_virtKeyVal = DOM_VK_CAPS_LOCK; - break; - case TQt::Key_Delete: - m_virtKeyVal = DOM_VK_DELETE; - break; - case TQt::Key_End: - m_virtKeyVal = DOM_VK_END; - break; - case TQt::Key_Escape: - m_virtKeyVal = DOM_VK_ESCAPE; - break; - case TQt::Key_Home: - m_virtKeyVal = DOM_VK_HOME; - break; - case TQt::Key_Insert: - m_virtKeyVal = DOM_VK_INSERT; - break; - case TQt::Key_Pause: - m_virtKeyVal = DOM_VK_PAUSE; - break; - case TQt::Key_Print: - m_virtKeyVal = DOM_VK_PRINTSCREEN; - break; - case TQt::Key_ScrollLock: - m_virtKeyVal = DOM_VK_SCROLL_LOCK; - break; - case TQt::Key_Left: - m_virtKeyVal = DOM_VK_LEFT; - break; - case TQt::Key_Right: - m_virtKeyVal = DOM_VK_RIGHT; - break; - case TQt::Key_Up: - m_virtKeyVal = DOM_VK_UP; - break; - case TQt::Key_Down: - m_virtKeyVal = DOM_VK_DOWN; - break; - case TQt::Key_Next: - m_virtKeyVal = DOM_VK_PAGE_DOWN; - break; - case TQt::Key_Prior: - m_virtKeyVal = DOM_VK_PAGE_UP; - break; - case TQt::Key_F1: - m_virtKeyVal = DOM_VK_F1; - break; - case TQt::Key_F2: - m_virtKeyVal = DOM_VK_F2; - break; - case TQt::Key_F3: - m_virtKeyVal = DOM_VK_F3; - break; - case TQt::Key_F4: - m_virtKeyVal = DOM_VK_F4; - break; - case TQt::Key_F5: - m_virtKeyVal = DOM_VK_F5; - break; - case TQt::Key_F6: - m_virtKeyVal = DOM_VK_F6; - break; - case TQt::Key_F7: - m_virtKeyVal = DOM_VK_F7; - break; - case TQt::Key_F8: - m_virtKeyVal = DOM_VK_F8; - break; - case TQt::Key_F9: - m_virtKeyVal = DOM_VK_F9; - break; - case TQt::Key_F10: - m_virtKeyVal = DOM_VK_F10; - break; - case TQt::Key_F11: - m_virtKeyVal = DOM_VK_F11; - break; - case TQt::Key_F12: - m_virtKeyVal = DOM_VK_F12; - break; - case TQt::Key_F13: - m_virtKeyVal = DOM_VK_F13; - break; - case TQt::Key_F14: - m_virtKeyVal = DOM_VK_F14; - break; - case TQt::Key_F15: - m_virtKeyVal = DOM_VK_F15; - break; - case TQt::Key_F16: - m_virtKeyVal = DOM_VK_F16; - break; - case TQt::Key_F17: - m_virtKeyVal = DOM_VK_F17; - break; - case TQt::Key_F18: - m_virtKeyVal = DOM_VK_F18; - break; - case TQt::Key_F19: - m_virtKeyVal = DOM_VK_F19; - break; - case TQt::Key_F20: - m_virtKeyVal = DOM_VK_F20; - break; - case TQt::Key_F21: - m_virtKeyVal = DOM_VK_F21; - break; - case TQt::Key_F22: - m_virtKeyVal = DOM_VK_F22; - break; - case TQt::Key_F23: - m_virtKeyVal = DOM_VK_F23; - break; - case TQt::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 = TQString(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 TQString - 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 *>(static_cast(thisObj.imp()))->impl())->checkModifier(args[0].toUInt32(exec))); - case SVGKeyEventImpl::GetKeyVal: - case SVGKeyEventImpl::GetCharCode: - return Number((static_cast *>(static_cast(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); -} diff --git a/ksvg/impl/SVGEventImpl.cpp b/ksvg/impl/SVGEventImpl.cpp new file mode 100644 index 00000000..9ff61abc --- /dev/null +++ b/ksvg/impl/SVGEventImpl.cpp @@ -0,0 +1,990 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + Additional copyright: + (C) 2001 Peter Kelly + (C) 2001 Tobias Anton + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +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 = TQDateTime::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 = TQDateTime::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() +{ + TQDateTime epoch(TQDate(1970, 1, 1), TQTime(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(TQKeyEvent *key, DOM::AbstractView &view, SVGEvent::EventId _id) : SVGUIEventImpl(_id, true, true, view, 0) +{ + qKeyEvent = new TQKeyEvent(key->type(), key->key(), key->ascii(), key->state(), key->text(), key->isAutoRepeat(), key->count()); + + // Events are supposed to be accepted by default in TQt! + // This line made TQLineEdit's keyevents be ignored, so they were sent to the tdehtmlview + // (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 TQt::Key_Enter: + m_numPad = true; + /* fall through */ + case TQt::Key_Return: + m_virtKeyVal = DOM_VK_ENTER; + break; + case TQt::Key_NumLock: + m_numPad = true; + m_virtKeyVal = DOM_VK_NUM_LOCK; + break; + case TQt::Key_Alt: + m_virtKeyVal = DOM_VK_RIGHT_ALT; + // ### DOM_VK_LEFT_ALT; + break; + case TQt::Key_Control: + m_virtKeyVal = DOM_VK_LEFT_CONTROL; + // ### DOM_VK_RIGHT_CONTROL + break; + case TQt::Key_Shift: + m_virtKeyVal = DOM_VK_LEFT_SHIFT; + // ### DOM_VK_RIGHT_SHIFT + break; + case TQt::Key_Meta: + m_virtKeyVal = DOM_VK_LEFT_META; + // ### DOM_VK_RIGHT_META + break; + case TQt::Key_CapsLock: + m_virtKeyVal = DOM_VK_CAPS_LOCK; + break; + case TQt::Key_Delete: + m_virtKeyVal = DOM_VK_DELETE; + break; + case TQt::Key_End: + m_virtKeyVal = DOM_VK_END; + break; + case TQt::Key_Escape: + m_virtKeyVal = DOM_VK_ESCAPE; + break; + case TQt::Key_Home: + m_virtKeyVal = DOM_VK_HOME; + break; + case TQt::Key_Insert: + m_virtKeyVal = DOM_VK_INSERT; + break; + case TQt::Key_Pause: + m_virtKeyVal = DOM_VK_PAUSE; + break; + case TQt::Key_Print: + m_virtKeyVal = DOM_VK_PRINTSCREEN; + break; + case TQt::Key_ScrollLock: + m_virtKeyVal = DOM_VK_SCROLL_LOCK; + break; + case TQt::Key_Left: + m_virtKeyVal = DOM_VK_LEFT; + break; + case TQt::Key_Right: + m_virtKeyVal = DOM_VK_RIGHT; + break; + case TQt::Key_Up: + m_virtKeyVal = DOM_VK_UP; + break; + case TQt::Key_Down: + m_virtKeyVal = DOM_VK_DOWN; + break; + case TQt::Key_Next: + m_virtKeyVal = DOM_VK_PAGE_DOWN; + break; + case TQt::Key_Prior: + m_virtKeyVal = DOM_VK_PAGE_UP; + break; + case TQt::Key_F1: + m_virtKeyVal = DOM_VK_F1; + break; + case TQt::Key_F2: + m_virtKeyVal = DOM_VK_F2; + break; + case TQt::Key_F3: + m_virtKeyVal = DOM_VK_F3; + break; + case TQt::Key_F4: + m_virtKeyVal = DOM_VK_F4; + break; + case TQt::Key_F5: + m_virtKeyVal = DOM_VK_F5; + break; + case TQt::Key_F6: + m_virtKeyVal = DOM_VK_F6; + break; + case TQt::Key_F7: + m_virtKeyVal = DOM_VK_F7; + break; + case TQt::Key_F8: + m_virtKeyVal = DOM_VK_F8; + break; + case TQt::Key_F9: + m_virtKeyVal = DOM_VK_F9; + break; + case TQt::Key_F10: + m_virtKeyVal = DOM_VK_F10; + break; + case TQt::Key_F11: + m_virtKeyVal = DOM_VK_F11; + break; + case TQt::Key_F12: + m_virtKeyVal = DOM_VK_F12; + break; + case TQt::Key_F13: + m_virtKeyVal = DOM_VK_F13; + break; + case TQt::Key_F14: + m_virtKeyVal = DOM_VK_F14; + break; + case TQt::Key_F15: + m_virtKeyVal = DOM_VK_F15; + break; + case TQt::Key_F16: + m_virtKeyVal = DOM_VK_F16; + break; + case TQt::Key_F17: + m_virtKeyVal = DOM_VK_F17; + break; + case TQt::Key_F18: + m_virtKeyVal = DOM_VK_F18; + break; + case TQt::Key_F19: + m_virtKeyVal = DOM_VK_F19; + break; + case TQt::Key_F20: + m_virtKeyVal = DOM_VK_F20; + break; + case TQt::Key_F21: + m_virtKeyVal = DOM_VK_F21; + break; + case TQt::Key_F22: + m_virtKeyVal = DOM_VK_F22; + break; + case TQt::Key_F23: + m_virtKeyVal = DOM_VK_F23; + break; + case TQt::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 = TQString(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 TQString + 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 *>(static_cast(thisObj.imp()))->impl())->checkModifier(args[0].toUInt32(exec))); + case SVGKeyEventImpl::GetKeyVal: + case SVGKeyEventImpl::GetCharCode: + return Number((static_cast *>(static_cast(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); +} diff --git a/ksvg/impl/SVGExternalResourcesRequiredImpl.cc b/ksvg/impl/SVGExternalResourcesRequiredImpl.cc deleted file mode 100644 index 0303a75b..00000000 --- a/ksvg/impl/SVGExternalResourcesRequiredImpl.cc +++ /dev/null @@ -1,86 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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; - } -} diff --git a/ksvg/impl/SVGExternalResourcesRequiredImpl.cpp b/ksvg/impl/SVGExternalResourcesRequiredImpl.cpp new file mode 100644 index 00000000..0303a75b --- /dev/null +++ b/ksvg/impl/SVGExternalResourcesRequiredImpl.cpp @@ -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. +*/ + +#include + +#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; + } +} diff --git a/ksvg/impl/SVGFEBlendElementImpl.cc b/ksvg/impl/SVGFEBlendElementImpl.cc deleted file mode 100644 index cec9cb88..00000000 --- a/ksvg/impl/SVGFEBlendElementImpl.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; -} diff --git a/ksvg/impl/SVGFEBlendElementImpl.cpp b/ksvg/impl/SVGFEBlendElementImpl.cpp new file mode 100644 index 00000000..cec9cb88 --- /dev/null +++ b/ksvg/impl/SVGFEBlendElementImpl.cpp @@ -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. +*/ + +#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; +} diff --git a/ksvg/impl/SVGFEColorMatrixElementImpl.cc b/ksvg/impl/SVGFEColorMatrixElementImpl.cc deleted file mode 100644 index 0bd0c542..00000000 --- a/ksvg/impl/SVGFEColorMatrixElementImpl.cc +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; -} diff --git a/ksvg/impl/SVGFEColorMatrixElementImpl.cpp b/ksvg/impl/SVGFEColorMatrixElementImpl.cpp new file mode 100644 index 00000000..0bd0c542 --- /dev/null +++ b/ksvg/impl/SVGFEColorMatrixElementImpl.cpp @@ -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 "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; +} diff --git a/ksvg/impl/SVGFEComponentTransferElementImpl.cc b/ksvg/impl/SVGFEComponentTransferElementImpl.cc deleted file mode 100644 index cdc4a053..00000000 --- a/ksvg/impl/SVGFEComponentTransferElementImpl.cc +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; -} diff --git a/ksvg/impl/SVGFEComponentTransferElementImpl.cpp b/ksvg/impl/SVGFEComponentTransferElementImpl.cpp new file mode 100644 index 00000000..cdc4a053 --- /dev/null +++ b/ksvg/impl/SVGFEComponentTransferElementImpl.cpp @@ -0,0 +1,41 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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; +} diff --git a/ksvg/impl/SVGFECompositeElementImpl.cc b/ksvg/impl/SVGFECompositeElementImpl.cc deleted file mode 100644 index 0ddaed6e..00000000 --- a/ksvg/impl/SVGFECompositeElementImpl.cc +++ /dev/null @@ -1,103 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; -} diff --git a/ksvg/impl/SVGFECompositeElementImpl.cpp b/ksvg/impl/SVGFECompositeElementImpl.cpp new file mode 100644 index 00000000..0ddaed6e --- /dev/null +++ b/ksvg/impl/SVGFECompositeElementImpl.cpp @@ -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 "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; +} diff --git a/ksvg/impl/SVGFEConvolveMatrixElementImpl.cc b/ksvg/impl/SVGFEConvolveMatrixElementImpl.cc deleted file mode 100644 index 4888eed7..00000000 --- a/ksvg/impl/SVGFEConvolveMatrixElementImpl.cc +++ /dev/null @@ -1,147 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; -} diff --git a/ksvg/impl/SVGFEConvolveMatrixElementImpl.cpp b/ksvg/impl/SVGFEConvolveMatrixElementImpl.cpp new file mode 100644 index 00000000..4888eed7 --- /dev/null +++ b/ksvg/impl/SVGFEConvolveMatrixElementImpl.cpp @@ -0,0 +1,147 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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; +} diff --git a/ksvg/impl/SVGFEDiffuseLightingElementImpl.cc b/ksvg/impl/SVGFEDiffuseLightingElementImpl.cc deleted file mode 100644 index 151b02bf..00000000 --- a/ksvg/impl/SVGFEDiffuseLightingElementImpl.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; -} diff --git a/ksvg/impl/SVGFEDiffuseLightingElementImpl.cpp b/ksvg/impl/SVGFEDiffuseLightingElementImpl.cpp new file mode 100644 index 00000000..151b02bf --- /dev/null +++ b/ksvg/impl/SVGFEDiffuseLightingElementImpl.cpp @@ -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. +*/ + +#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; +} diff --git a/ksvg/impl/SVGFEDisplacementMapElementImpl.cc b/ksvg/impl/SVGFEDisplacementMapElementImpl.cc deleted file mode 100644 index 6bdd9aea..00000000 --- a/ksvg/impl/SVGFEDisplacementMapElementImpl.cc +++ /dev/null @@ -1,83 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; -} diff --git a/ksvg/impl/SVGFEDisplacementMapElementImpl.cpp b/ksvg/impl/SVGFEDisplacementMapElementImpl.cpp new file mode 100644 index 00000000..6bdd9aea --- /dev/null +++ b/ksvg/impl/SVGFEDisplacementMapElementImpl.cpp @@ -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 "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; +} diff --git a/ksvg/impl/SVGFEDistantLightElementImpl.cc b/ksvg/impl/SVGFEDistantLightElementImpl.cc deleted file mode 100644 index f9556ab1..00000000 --- a/ksvg/impl/SVGFEDistantLightElementImpl.cc +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; -} diff --git a/ksvg/impl/SVGFEDistantLightElementImpl.cpp b/ksvg/impl/SVGFEDistantLightElementImpl.cpp new file mode 100644 index 00000000..f9556ab1 --- /dev/null +++ b/ksvg/impl/SVGFEDistantLightElementImpl.cpp @@ -0,0 +1,51 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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; +} diff --git a/ksvg/impl/SVGFEFloodElementImpl.cc b/ksvg/impl/SVGFEFloodElementImpl.cc deleted file mode 100644 index 15d74945..00000000 --- a/ksvg/impl/SVGFEFloodElementImpl.cc +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; -} diff --git a/ksvg/impl/SVGFEFloodElementImpl.cpp b/ksvg/impl/SVGFEFloodElementImpl.cpp new file mode 100644 index 00000000..15d74945 --- /dev/null +++ b/ksvg/impl/SVGFEFloodElementImpl.cpp @@ -0,0 +1,41 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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; +} diff --git a/ksvg/impl/SVGFEFuncAElementImpl.cc b/ksvg/impl/SVGFEFuncAElementImpl.cc deleted file mode 100644 index 7afec020..00000000 --- a/ksvg/impl/SVGFEFuncAElementImpl.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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() -{ -} diff --git a/ksvg/impl/SVGFEFuncAElementImpl.cpp b/ksvg/impl/SVGFEFuncAElementImpl.cpp new file mode 100644 index 00000000..7afec020 --- /dev/null +++ b/ksvg/impl/SVGFEFuncAElementImpl.cpp @@ -0,0 +1,31 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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() +{ +} diff --git a/ksvg/impl/SVGFEFuncBElementImpl.cc b/ksvg/impl/SVGFEFuncBElementImpl.cc deleted file mode 100644 index 4c38afb6..00000000 --- a/ksvg/impl/SVGFEFuncBElementImpl.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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() -{ -} diff --git a/ksvg/impl/SVGFEFuncBElementImpl.cpp b/ksvg/impl/SVGFEFuncBElementImpl.cpp new file mode 100644 index 00000000..4c38afb6 --- /dev/null +++ b/ksvg/impl/SVGFEFuncBElementImpl.cpp @@ -0,0 +1,31 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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() +{ +} diff --git a/ksvg/impl/SVGFEFuncGElementImpl.cc b/ksvg/impl/SVGFEFuncGElementImpl.cc deleted file mode 100644 index 67712b9b..00000000 --- a/ksvg/impl/SVGFEFuncGElementImpl.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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() -{ -} diff --git a/ksvg/impl/SVGFEFuncGElementImpl.cpp b/ksvg/impl/SVGFEFuncGElementImpl.cpp new file mode 100644 index 00000000..67712b9b --- /dev/null +++ b/ksvg/impl/SVGFEFuncGElementImpl.cpp @@ -0,0 +1,31 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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() +{ +} diff --git a/ksvg/impl/SVGFEFuncRElementImpl.cc b/ksvg/impl/SVGFEFuncRElementImpl.cc deleted file mode 100644 index 703eae13..00000000 --- a/ksvg/impl/SVGFEFuncRElementImpl.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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() -{ -} diff --git a/ksvg/impl/SVGFEFuncRElementImpl.cpp b/ksvg/impl/SVGFEFuncRElementImpl.cpp new file mode 100644 index 00000000..703eae13 --- /dev/null +++ b/ksvg/impl/SVGFEFuncRElementImpl.cpp @@ -0,0 +1,31 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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() +{ +} diff --git a/ksvg/impl/SVGFEGaussianBlurElementImpl.cc b/ksvg/impl/SVGFEGaussianBlurElementImpl.cc deleted file mode 100644 index 1c10d564..00000000 --- a/ksvg/impl/SVGFEGaussianBlurElementImpl.cc +++ /dev/null @@ -1,66 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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*/) -{ -} diff --git a/ksvg/impl/SVGFEGaussianBlurElementImpl.cpp b/ksvg/impl/SVGFEGaussianBlurElementImpl.cpp new file mode 100644 index 00000000..1c10d564 --- /dev/null +++ b/ksvg/impl/SVGFEGaussianBlurElementImpl.cpp @@ -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. +*/ + +#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*/) +{ +} diff --git a/ksvg/impl/SVGFEImageElementImpl.cc b/ksvg/impl/SVGFEImageElementImpl.cc deleted file mode 100644 index 4bcd64ed..00000000 --- a/ksvg/impl/SVGFEImageElementImpl.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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() -{ -} diff --git a/ksvg/impl/SVGFEImageElementImpl.cpp b/ksvg/impl/SVGFEImageElementImpl.cpp new file mode 100644 index 00000000..4bcd64ed --- /dev/null +++ b/ksvg/impl/SVGFEImageElementImpl.cpp @@ -0,0 +1,31 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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() +{ +} diff --git a/ksvg/impl/SVGFEMergeElementImpl.cc b/ksvg/impl/SVGFEMergeElementImpl.cc deleted file mode 100644 index fb188bae..00000000 --- a/ksvg/impl/SVGFEMergeElementImpl.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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() -{ -} diff --git a/ksvg/impl/SVGFEMergeElementImpl.cpp b/ksvg/impl/SVGFEMergeElementImpl.cpp new file mode 100644 index 00000000..fb188bae --- /dev/null +++ b/ksvg/impl/SVGFEMergeElementImpl.cpp @@ -0,0 +1,31 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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() +{ +} diff --git a/ksvg/impl/SVGFEMergeNodeElementImpl.cc b/ksvg/impl/SVGFEMergeNodeElementImpl.cc deleted file mode 100644 index 13f6eefe..00000000 --- a/ksvg/impl/SVGFEMergeNodeElementImpl.cc +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; -} diff --git a/ksvg/impl/SVGFEMergeNodeElementImpl.cpp b/ksvg/impl/SVGFEMergeNodeElementImpl.cpp new file mode 100644 index 00000000..13f6eefe --- /dev/null +++ b/ksvg/impl/SVGFEMergeNodeElementImpl.cpp @@ -0,0 +1,41 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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; +} diff --git a/ksvg/impl/SVGFEMorphologyElementImpl.cc b/ksvg/impl/SVGFEMorphologyElementImpl.cc deleted file mode 100644 index 373d0b08..00000000 --- a/ksvg/impl/SVGFEMorphologyElementImpl.cc +++ /dev/null @@ -1,73 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; -} diff --git a/ksvg/impl/SVGFEMorphologyElementImpl.cpp b/ksvg/impl/SVGFEMorphologyElementImpl.cpp new file mode 100644 index 00000000..373d0b08 --- /dev/null +++ b/ksvg/impl/SVGFEMorphologyElementImpl.cpp @@ -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. +*/ + +#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; +} diff --git a/ksvg/impl/SVGFEOffsetElementImpl.cc b/ksvg/impl/SVGFEOffsetElementImpl.cc deleted file mode 100644 index b402fbc0..00000000 --- a/ksvg/impl/SVGFEOffsetElementImpl.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; -} diff --git a/ksvg/impl/SVGFEOffsetElementImpl.cpp b/ksvg/impl/SVGFEOffsetElementImpl.cpp new file mode 100644 index 00000000..b402fbc0 --- /dev/null +++ b/ksvg/impl/SVGFEOffsetElementImpl.cpp @@ -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. +*/ + +#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; +} diff --git a/ksvg/impl/SVGFEPointLightElementImpl.cc b/ksvg/impl/SVGFEPointLightElementImpl.cc deleted file mode 100644 index 1a705f43..00000000 --- a/ksvg/impl/SVGFEPointLightElementImpl.cc +++ /dev/null @@ -1,61 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; -} diff --git a/ksvg/impl/SVGFEPointLightElementImpl.cpp b/ksvg/impl/SVGFEPointLightElementImpl.cpp new file mode 100644 index 00000000..1a705f43 --- /dev/null +++ b/ksvg/impl/SVGFEPointLightElementImpl.cpp @@ -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. +*/ + +#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; +} diff --git a/ksvg/impl/SVGFESpecularLightingElementImpl.cc b/ksvg/impl/SVGFESpecularLightingElementImpl.cc deleted file mode 100644 index 188dc0bd..00000000 --- a/ksvg/impl/SVGFESpecularLightingElementImpl.cc +++ /dev/null @@ -1,72 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; -} diff --git a/ksvg/impl/SVGFESpecularLightingElementImpl.cpp b/ksvg/impl/SVGFESpecularLightingElementImpl.cpp new file mode 100644 index 00000000..188dc0bd --- /dev/null +++ b/ksvg/impl/SVGFESpecularLightingElementImpl.cpp @@ -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. +*/ + +#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; +} diff --git a/ksvg/impl/SVGFESpotLightElementImpl.cc b/ksvg/impl/SVGFESpotLightElementImpl.cc deleted file mode 100644 index f92b4ccd..00000000 --- a/ksvg/impl/SVGFESpotLightElementImpl.cc +++ /dev/null @@ -1,111 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; -} diff --git a/ksvg/impl/SVGFESpotLightElementImpl.cpp b/ksvg/impl/SVGFESpotLightElementImpl.cpp new file mode 100644 index 00000000..f92b4ccd --- /dev/null +++ b/ksvg/impl/SVGFESpotLightElementImpl.cpp @@ -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 "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; +} diff --git a/ksvg/impl/SVGFETileElementImpl.cc b/ksvg/impl/SVGFETileElementImpl.cc deleted file mode 100644 index 2ca931a2..00000000 --- a/ksvg/impl/SVGFETileElementImpl.cc +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; -} diff --git a/ksvg/impl/SVGFETileElementImpl.cpp b/ksvg/impl/SVGFETileElementImpl.cpp new file mode 100644 index 00000000..2ca931a2 --- /dev/null +++ b/ksvg/impl/SVGFETileElementImpl.cpp @@ -0,0 +1,41 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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; +} diff --git a/ksvg/impl/SVGFETurbulenceElementImpl.cc b/ksvg/impl/SVGFETurbulenceElementImpl.cc deleted file mode 100644 index 7c6638ef..00000000 --- a/ksvg/impl/SVGFETurbulenceElementImpl.cc +++ /dev/null @@ -1,98 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; -} diff --git a/ksvg/impl/SVGFETurbulenceElementImpl.cpp b/ksvg/impl/SVGFETurbulenceElementImpl.cpp new file mode 100644 index 00000000..7c6638ef --- /dev/null +++ b/ksvg/impl/SVGFETurbulenceElementImpl.cpp @@ -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 "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; +} diff --git a/ksvg/impl/SVGFilterElementImpl.cc b/ksvg/impl/SVGFilterElementImpl.cc deleted file mode 100644 index 5ed2dd8c..00000000 --- a/ksvg/impl/SVGFilterElementImpl.cc +++ /dev/null @@ -1,117 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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*/) -{ -} diff --git a/ksvg/impl/SVGFilterElementImpl.cpp b/ksvg/impl/SVGFilterElementImpl.cpp new file mode 100644 index 00000000..5ed2dd8c --- /dev/null +++ b/ksvg/impl/SVGFilterElementImpl.cpp @@ -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 "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*/) +{ +} diff --git a/ksvg/impl/SVGFilterPrimitiveStandardAttributesImpl.cc b/ksvg/impl/SVGFilterPrimitiveStandardAttributesImpl.cc deleted file mode 100644 index 07517afd..00000000 --- a/ksvg/impl/SVGFilterPrimitiveStandardAttributesImpl.cc +++ /dev/null @@ -1,82 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; -} diff --git a/ksvg/impl/SVGFilterPrimitiveStandardAttributesImpl.cpp b/ksvg/impl/SVGFilterPrimitiveStandardAttributesImpl.cpp new file mode 100644 index 00000000..07517afd --- /dev/null +++ b/ksvg/impl/SVGFilterPrimitiveStandardAttributesImpl.cpp @@ -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 "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; +} diff --git a/ksvg/impl/SVGFitToViewBoxImpl.cc b/ksvg/impl/SVGFitToViewBoxImpl.cc deleted file mode 100644 index a33bc0fc..00000000 --- a/ksvg/impl/SVGFitToViewBoxImpl.cc +++ /dev/null @@ -1,139 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#include -#include - -#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 TQString &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 - TQString viewbox(s); - TQStringList points = TQStringList::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; - } -} diff --git a/ksvg/impl/SVGFitToViewBoxImpl.cpp b/ksvg/impl/SVGFitToViewBoxImpl.cpp new file mode 100644 index 00000000..a33bc0fc --- /dev/null +++ b/ksvg/impl/SVGFitToViewBoxImpl.cpp @@ -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 + +#include +#include + +#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 TQString &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 + TQString viewbox(s); + TQStringList points = TQStringList::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; + } +} diff --git a/ksvg/impl/SVGFontElementImpl.cc b/ksvg/impl/SVGFontElementImpl.cc deleted file mode 100644 index 49ed035c..00000000 --- a/ksvg/impl/SVGFontElementImpl.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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() -{ -} diff --git a/ksvg/impl/SVGFontElementImpl.cpp b/ksvg/impl/SVGFontElementImpl.cpp new file mode 100644 index 00000000..49ed035c --- /dev/null +++ b/ksvg/impl/SVGFontElementImpl.cpp @@ -0,0 +1,31 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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() +{ +} diff --git a/ksvg/impl/SVGFontFaceElementImpl.cc b/ksvg/impl/SVGFontFaceElementImpl.cc deleted file mode 100644 index b8ee49e1..00000000 --- a/ksvg/impl/SVGFontFaceElementImpl.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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() -{ -} diff --git a/ksvg/impl/SVGFontFaceElementImpl.cpp b/ksvg/impl/SVGFontFaceElementImpl.cpp new file mode 100644 index 00000000..b8ee49e1 --- /dev/null +++ b/ksvg/impl/SVGFontFaceElementImpl.cpp @@ -0,0 +1,31 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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() +{ +} diff --git a/ksvg/impl/SVGFontFaceFormatElementImpl.cc b/ksvg/impl/SVGFontFaceFormatElementImpl.cc deleted file mode 100644 index aecf957c..00000000 --- a/ksvg/impl/SVGFontFaceFormatElementImpl.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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() -{ -} diff --git a/ksvg/impl/SVGFontFaceFormatElementImpl.cpp b/ksvg/impl/SVGFontFaceFormatElementImpl.cpp new file mode 100644 index 00000000..aecf957c --- /dev/null +++ b/ksvg/impl/SVGFontFaceFormatElementImpl.cpp @@ -0,0 +1,31 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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() +{ +} diff --git a/ksvg/impl/SVGFontFaceNameElementImpl.cc b/ksvg/impl/SVGFontFaceNameElementImpl.cc deleted file mode 100644 index c4a295fc..00000000 --- a/ksvg/impl/SVGFontFaceNameElementImpl.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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() -{ -} diff --git a/ksvg/impl/SVGFontFaceNameElementImpl.cpp b/ksvg/impl/SVGFontFaceNameElementImpl.cpp new file mode 100644 index 00000000..c4a295fc --- /dev/null +++ b/ksvg/impl/SVGFontFaceNameElementImpl.cpp @@ -0,0 +1,31 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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() +{ +} diff --git a/ksvg/impl/SVGFontFaceSrcElementImpl.cc b/ksvg/impl/SVGFontFaceSrcElementImpl.cc deleted file mode 100644 index 9a2bd71e..00000000 --- a/ksvg/impl/SVGFontFaceSrcElementImpl.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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() -{ -} diff --git a/ksvg/impl/SVGFontFaceSrcElementImpl.cpp b/ksvg/impl/SVGFontFaceSrcElementImpl.cpp new file mode 100644 index 00000000..9a2bd71e --- /dev/null +++ b/ksvg/impl/SVGFontFaceSrcElementImpl.cpp @@ -0,0 +1,31 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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() +{ +} diff --git a/ksvg/impl/SVGFontFaceUriElementImpl.cc b/ksvg/impl/SVGFontFaceUriElementImpl.cc deleted file mode 100644 index 4a4153ae..00000000 --- a/ksvg/impl/SVGFontFaceUriElementImpl.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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() -{ -} diff --git a/ksvg/impl/SVGFontFaceUriElementImpl.cpp b/ksvg/impl/SVGFontFaceUriElementImpl.cpp new file mode 100644 index 00000000..4a4153ae --- /dev/null +++ b/ksvg/impl/SVGFontFaceUriElementImpl.cpp @@ -0,0 +1,31 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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() +{ +} diff --git a/ksvg/impl/SVGForeignObjectElementImpl.cc b/ksvg/impl/SVGForeignObjectElementImpl.cc deleted file mode 100644 index bf6b3c7a..00000000 --- a/ksvg/impl/SVGForeignObjectElementImpl.cc +++ /dev/null @@ -1,119 +0,0 @@ -/* - 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 - -#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(); - } -} diff --git a/ksvg/impl/SVGForeignObjectElementImpl.cpp b/ksvg/impl/SVGForeignObjectElementImpl.cpp new file mode 100644 index 00000000..bf6b3c7a --- /dev/null +++ b/ksvg/impl/SVGForeignObjectElementImpl.cpp @@ -0,0 +1,119 @@ +/* + 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 + +#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(); + } +} diff --git a/ksvg/impl/SVGGElementImpl.cc b/ksvg/impl/SVGGElementImpl.cc deleted file mode 100644 index 5cba29a3..00000000 --- a/ksvg/impl/SVGGElementImpl.cc +++ /dev/null @@ -1,34 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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() -{ -} diff --git a/ksvg/impl/SVGGElementImpl.cpp b/ksvg/impl/SVGGElementImpl.cpp new file mode 100644 index 00000000..5cba29a3 --- /dev/null +++ b/ksvg/impl/SVGGElementImpl.cpp @@ -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 "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() +{ +} diff --git a/ksvg/impl/SVGGlyphElementImpl.cc b/ksvg/impl/SVGGlyphElementImpl.cc deleted file mode 100644 index 9b909960..00000000 --- a/ksvg/impl/SVGGlyphElementImpl.cc +++ /dev/null @@ -1,96 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#include "SVGGlyphElementImpl.h" - -using namespace KSVG; - -#include "SVGGlyphElementImpl.lut.h" - -SVGGlyphElementImpl::SVGGlyphElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGStylableImpl(this) -{ - KSVG_EMPTY_FLAGS -} - -SVGGlyphElementImpl::~SVGGlyphElementImpl() -{ -} - -TQString 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::Qt::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; - } -} diff --git a/ksvg/impl/SVGGlyphElementImpl.cpp b/ksvg/impl/SVGGlyphElementImpl.cpp new file mode 100644 index 00000000..9b909960 --- /dev/null +++ b/ksvg/impl/SVGGlyphElementImpl.cpp @@ -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 + +#include "SVGGlyphElementImpl.h" + +using namespace KSVG; + +#include "SVGGlyphElementImpl.lut.h" + +SVGGlyphElementImpl::SVGGlyphElementImpl(DOM::ElementImpl *impl) : SVGElementImpl(impl), SVGStylableImpl(this) +{ + KSVG_EMPTY_FLAGS +} + +SVGGlyphElementImpl::~SVGGlyphElementImpl() +{ +} + +TQString 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::Qt::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; + } +} diff --git a/ksvg/impl/SVGGlyphRefElementImpl.cc b/ksvg/impl/SVGGlyphRefElementImpl.cc deleted file mode 100644 index 10366dd9..00000000 --- a/ksvg/impl/SVGGlyphRefElementImpl.cc +++ /dev/null @@ -1,132 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; - } -} diff --git a/ksvg/impl/SVGGlyphRefElementImpl.cpp b/ksvg/impl/SVGGlyphRefElementImpl.cpp new file mode 100644 index 00000000..10366dd9 --- /dev/null +++ b/ksvg/impl/SVGGlyphRefElementImpl.cpp @@ -0,0 +1,132 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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; + } +} diff --git a/ksvg/impl/SVGGradientElementImpl.cc b/ksvg/impl/SVGGradientElementImpl.cc deleted file mode 100644 index b59679e2..00000000 --- a/ksvg/impl/SVGGradientElementImpl.cc +++ /dev/null @@ -1,262 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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: - { - TQString 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() -{ - TQString _href = SVGURIReferenceImpl::getTarget(href()->baseVal().string()); - - if(!_href.isEmpty()) - { - SVGGradientElementImpl *refGradient = dynamic_cast(ownerSVGElement()->getElementById(_href)); - - if(refGradient) - { - TQMap refAttributes = refGradient->gradientAttributes(); - TQMap::iterator it; - - for(it = refAttributes.begin(); it != refAttributes.end(); ++it) - { - TQString 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(ownerDoc()->getElementFromHandle(node.handle())); - - if(stop) - { - haveStops = true; - break; - } - } - - SVGGradientElementImpl *source = this; - - if(!haveStops) - { - TQString _href = SVGURIReferenceImpl::getTarget(href()->baseVal().string()); - - if(!_href.isEmpty()) - { - SVGGradientElementImpl *refGradient = dynamic_cast(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(exec, "[[svggradientelement.constructor]]"); -} diff --git a/ksvg/impl/SVGGradientElementImpl.cpp b/ksvg/impl/SVGGradientElementImpl.cpp new file mode 100644 index 00000000..b59679e2 --- /dev/null +++ b/ksvg/impl/SVGGradientElementImpl.cpp @@ -0,0 +1,262 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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: + { + TQString 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() +{ + TQString _href = SVGURIReferenceImpl::getTarget(href()->baseVal().string()); + + if(!_href.isEmpty()) + { + SVGGradientElementImpl *refGradient = dynamic_cast(ownerSVGElement()->getElementById(_href)); + + if(refGradient) + { + TQMap refAttributes = refGradient->gradientAttributes(); + TQMap::iterator it; + + for(it = refAttributes.begin(); it != refAttributes.end(); ++it) + { + TQString 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(ownerDoc()->getElementFromHandle(node.handle())); + + if(stop) + { + haveStops = true; + break; + } + } + + SVGGradientElementImpl *source = this; + + if(!haveStops) + { + TQString _href = SVGURIReferenceImpl::getTarget(href()->baseVal().string()); + + if(!_href.isEmpty()) + { + SVGGradientElementImpl *refGradient = dynamic_cast(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(exec, "[[svggradientelement.constructor]]"); +} diff --git a/ksvg/impl/SVGHKernElementImpl.cc b/ksvg/impl/SVGHKernElementImpl.cc deleted file mode 100644 index 64efce26..00000000 --- a/ksvg/impl/SVGHKernElementImpl.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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() -{ -} diff --git a/ksvg/impl/SVGHKernElementImpl.cpp b/ksvg/impl/SVGHKernElementImpl.cpp new file mode 100644 index 00000000..64efce26 --- /dev/null +++ b/ksvg/impl/SVGHKernElementImpl.cpp @@ -0,0 +1,31 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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() +{ +} diff --git a/ksvg/impl/SVGHelperImpl.cc b/ksvg/impl/SVGHelperImpl.cc deleted file mode 100644 index fb546fbe..00000000 --- a/ksvg/impl/SVGHelperImpl.cc +++ /dev/null @@ -1,228 +0,0 @@ -/* - 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 - -#include - -#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(doc->getElementFromHandle(node.handle())); - - if(shape && shape->item()) - { - shape->item()->update(UPDATE_TRANSFORM); - shape->item()->draw(); - shape->blit(doc->canvas()); - } - - if(const_cast(node).hasChildNodes()) - { - DOM::Node iterate = node.firstChild(); - for(; !iterate.isNull(); iterate = iterate.nextSibling()) - updateItem(exec, iterate); - } -} - -void SVGHelperImpl::copyAttributes(SVGElementImpl *src, SVGElementImpl *dst) -{ - TQDictIterator 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 TQString &data) -{ - // TODO : more error checking/reporting - list->clear(); - - TQStringList substrings = TQStringList::split(seperator, data); - TQStringList::ConstIterator it = substrings.begin(); - TQStringList::ConstIterator end = substrings.end(); - for(; it != end; ++it) - { - SharedString *string = new SharedString(*it); - string->ref(); - - list->appendItem(string); - } -} - -void SVGHelperImpl::parseLengthList(SVGAnimatedLengthListImpl *list, const TQString &lengths, LengthMode mode, SVGElementImpl *object) -{ - // get either comma or space delimited lists - // TODO : more error checking/reporting - TQStringList sublengths = TQStringList::split(TQRegExp("[, ]"), lengths); - TQStringList::ConstIterator it = sublengths.begin(); - TQStringList::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 TQString &data) -{ - parseList(list, ',', data); -} - -void SVGHelperImpl::parseSemicolonSeperatedList(SVGStringListImpl *list, const TQString &data) -{ - parseList(list, ';', data); -} - -void SVGHelperImpl::parseTransformAttribute(SVGTransformListImpl *list, const TQString &transform) -{ - // Split string for handling 1 transform statement at a time - TQStringList subtransforms = TQStringList::split(')', transform); - TQStringList::ConstIterator it = subtransforms.begin(); - TQStringList::ConstIterator end = subtransforms.end(); - for(; it != end; ++it) - { - TQStringList subtransform = TQStringList::split('(', (*it)); - - subtransform[0] = subtransform[0].stripWhiteSpace().lower(); - subtransform[1] = subtransform[1].simplifyWhiteSpace(); - TQRegExp reg("([-]?\\d*\\.?\\d+(?:e[-]?\\d+)?)"); - - int pos = 0; - TQStringList 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 -TQRect SVGHelperImpl::fromUserspace(SVGElementImpl *obj, const TQRect &r) -{ - TQRect sr; - - SVGLocatableImpl *locate = dynamic_cast(obj); - - if(locate) - sr = locate->screenCTM()->qmatrix().mapRect(r); - - return sr; -} diff --git a/ksvg/impl/SVGHelperImpl.cpp b/ksvg/impl/SVGHelperImpl.cpp new file mode 100644 index 00000000..fb546fbe --- /dev/null +++ b/ksvg/impl/SVGHelperImpl.cpp @@ -0,0 +1,228 @@ +/* + 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 + +#include + +#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(doc->getElementFromHandle(node.handle())); + + if(shape && shape->item()) + { + shape->item()->update(UPDATE_TRANSFORM); + shape->item()->draw(); + shape->blit(doc->canvas()); + } + + if(const_cast(node).hasChildNodes()) + { + DOM::Node iterate = node.firstChild(); + for(; !iterate.isNull(); iterate = iterate.nextSibling()) + updateItem(exec, iterate); + } +} + +void SVGHelperImpl::copyAttributes(SVGElementImpl *src, SVGElementImpl *dst) +{ + TQDictIterator 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 TQString &data) +{ + // TODO : more error checking/reporting + list->clear(); + + TQStringList substrings = TQStringList::split(seperator, data); + TQStringList::ConstIterator it = substrings.begin(); + TQStringList::ConstIterator end = substrings.end(); + for(; it != end; ++it) + { + SharedString *string = new SharedString(*it); + string->ref(); + + list->appendItem(string); + } +} + +void SVGHelperImpl::parseLengthList(SVGAnimatedLengthListImpl *list, const TQString &lengths, LengthMode mode, SVGElementImpl *object) +{ + // get either comma or space delimited lists + // TODO : more error checking/reporting + TQStringList sublengths = TQStringList::split(TQRegExp("[, ]"), lengths); + TQStringList::ConstIterator it = sublengths.begin(); + TQStringList::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 TQString &data) +{ + parseList(list, ',', data); +} + +void SVGHelperImpl::parseSemicolonSeperatedList(SVGStringListImpl *list, const TQString &data) +{ + parseList(list, ';', data); +} + +void SVGHelperImpl::parseTransformAttribute(SVGTransformListImpl *list, const TQString &transform) +{ + // Split string for handling 1 transform statement at a time + TQStringList subtransforms = TQStringList::split(')', transform); + TQStringList::ConstIterator it = subtransforms.begin(); + TQStringList::ConstIterator end = subtransforms.end(); + for(; it != end; ++it) + { + TQStringList subtransform = TQStringList::split('(', (*it)); + + subtransform[0] = subtransform[0].stripWhiteSpace().lower(); + subtransform[1] = subtransform[1].simplifyWhiteSpace(); + TQRegExp reg("([-]?\\d*\\.?\\d+(?:e[-]?\\d+)?)"); + + int pos = 0; + TQStringList 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 +TQRect SVGHelperImpl::fromUserspace(SVGElementImpl *obj, const TQRect &r) +{ + TQRect sr; + + SVGLocatableImpl *locate = dynamic_cast(obj); + + if(locate) + sr = locate->screenCTM()->qmatrix().mapRect(r); + + return sr; +} diff --git a/ksvg/impl/SVGICCColorImpl.cc b/ksvg/impl/SVGICCColorImpl.cc deleted file mode 100644 index 50af51c9..00000000 --- a/ksvg/impl/SVGICCColorImpl.cc +++ /dev/null @@ -1,105 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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; - } -} diff --git a/ksvg/impl/SVGICCColorImpl.cpp b/ksvg/impl/SVGICCColorImpl.cpp new file mode 100644 index 00000000..50af51c9 --- /dev/null +++ b/ksvg/impl/SVGICCColorImpl.cpp @@ -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 + +#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; + } +} diff --git a/ksvg/impl/SVGImageElementImpl.cc b/ksvg/impl/SVGImageElementImpl.cc deleted file mode 100644 index 65c678d2..00000000 --- a/ksvg/impl/SVGImageElementImpl.cc +++ /dev/null @@ -1,520 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 -#include - -#include - -#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) : TQObject(), 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 TQString &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, TQT_SIGNAL(finishedParsing(bool, const TQString &)), this, TQT_SLOT(slotParsingFinished(bool, const TQString &))); - connect(m_doc, TQT_SIGNAL(finishedLoading()), this, TQT_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", TQString("%1").arg(x()->baseVal()->value())); - svg->setAttributeInternal("y", TQString("%1").arg(y()->baseVal()->value())); - svg->setAttributeInternal("width", TQString("%1").arg(width()->baseVal()->value())); - svg->setAttributeInternal("height", TQString("%1").arg(height()->baseVal()->value())); - - TQString 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 TQPoint &p, const TQPoint &, SVGMouseEventImpl *mev) -{ - // TODO : pointer-events should be stored here, not in SVGStylableImpl. - SVGStylableImpl *style = dynamic_cast(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(this)); - return true; - } - } - - return false; -} - -void SVGImageElementImpl::setImage(TQImage *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); -} - -TQImage SVGImageElementImpl::scaledImage() -{ - SVGMatrixImpl *matrix = imageMatrix(); - double sx, sy; - - matrix->removeScale(&sx, &sy); - matrix->deref(); - - TQImage img; - - if(sx != 1 || sy != 1) - { - int scaledWidth = static_cast(m_image->width() * sx + 0.5); - int scaledHeight = static_cast(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(m_image->width() * sx + 0.5); - int imageHeight = static_cast(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; -} - -TQString 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(); - } - } -} diff --git a/ksvg/impl/SVGImageElementImpl.cpp b/ksvg/impl/SVGImageElementImpl.cpp new file mode 100644 index 00000000..65c678d2 --- /dev/null +++ b/ksvg/impl/SVGImageElementImpl.cpp @@ -0,0 +1,520 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 +#include + +#include + +#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) : TQObject(), 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 TQString &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, TQT_SIGNAL(finishedParsing(bool, const TQString &)), this, TQT_SLOT(slotParsingFinished(bool, const TQString &))); + connect(m_doc, TQT_SIGNAL(finishedLoading()), this, TQT_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", TQString("%1").arg(x()->baseVal()->value())); + svg->setAttributeInternal("y", TQString("%1").arg(y()->baseVal()->value())); + svg->setAttributeInternal("width", TQString("%1").arg(width()->baseVal()->value())); + svg->setAttributeInternal("height", TQString("%1").arg(height()->baseVal()->value())); + + TQString 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 TQPoint &p, const TQPoint &, SVGMouseEventImpl *mev) +{ + // TODO : pointer-events should be stored here, not in SVGStylableImpl. + SVGStylableImpl *style = dynamic_cast(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(this)); + return true; + } + } + + return false; +} + +void SVGImageElementImpl::setImage(TQImage *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); +} + +TQImage SVGImageElementImpl::scaledImage() +{ + SVGMatrixImpl *matrix = imageMatrix(); + double sx, sy; + + matrix->removeScale(&sx, &sy); + matrix->deref(); + + TQImage img; + + if(sx != 1 || sy != 1) + { + int scaledWidth = static_cast(m_image->width() * sx + 0.5); + int scaledHeight = static_cast(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(m_image->width() * sx + 0.5); + int imageHeight = static_cast(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; +} + +TQString 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(); + } + } +} diff --git a/ksvg/impl/SVGLangSpaceImpl.cc b/ksvg/impl/SVGLangSpaceImpl.cc deleted file mode 100644 index f6081401..00000000 --- a/ksvg/impl/SVGLangSpaceImpl.cc +++ /dev/null @@ -1,128 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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; -} - -TQString SVGLangSpaceImpl::handleText(const TQString &data) const -{ - TQString 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", TQString(" ")); - result.replace("\r\n", TQString(" ")); - 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', TQString()); - result.replace('\r', TQString()); - 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; - } -} diff --git a/ksvg/impl/SVGLangSpaceImpl.cpp b/ksvg/impl/SVGLangSpaceImpl.cpp new file mode 100644 index 00000000..f6081401 --- /dev/null +++ b/ksvg/impl/SVGLangSpaceImpl.cpp @@ -0,0 +1,128 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#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; +} + +TQString SVGLangSpaceImpl::handleText(const TQString &data) const +{ + TQString 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", TQString(" ")); + result.replace("\r\n", TQString(" ")); + 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', TQString()); + result.replace('\r', TQString()); + 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; + } +} diff --git a/ksvg/impl/SVGLengthImpl.cc b/ksvg/impl/SVGLengthImpl.cc deleted file mode 100644 index 36789ffe..00000000 --- a/ksvg/impl/SVGLengthImpl.cc +++ /dev/null @@ -1,508 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#include -#include -#include -#include - -#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 -TQString 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 = TQString::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(TQString 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(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(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) - TQString 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) - TQFont font(useFont); - font.setPixelSize(static_cast(useSize)); - - TQFontMetrics fm(font); - m_value = m_valueInSpecifiedUnits * fm.boundingRect('x').height(); - } - } - break; - }; -} - -void SVGLengthImpl::convertPercentageToFloat(const TQString &perc, float &result) -{ - // TODO : more error checking ? - if(perc.endsWith("%")) - result = perc.left(perc.length() - 1).toFloat() / 100.0; - else - result = perc.toFloat(); -} - -TQString SVGLengthImpl::convertValToPercentage(const TQString &val, float benchmark) -{ - if(val.endsWith("%")) - return val; - - TQString 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(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 with printnodetest - return 0.0; - - TQPaintDeviceMetrics 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(args[0].toNumber(exec)), args[1].toNumber(exec)); - SVGHelperImpl::updateItem(exec, *obj->context()); - return Undefined(); - case SVGLengthImpl::ConvertToSpecifiedUnits: - obj->convertToSpecifiedUnits(static_cast(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(exec, "[[svglength.constructor]]"); -} diff --git a/ksvg/impl/SVGLengthImpl.cpp b/ksvg/impl/SVGLengthImpl.cpp new file mode 100644 index 00000000..36789ffe --- /dev/null +++ b/ksvg/impl/SVGLengthImpl.cpp @@ -0,0 +1,508 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#include +#include +#include +#include + +#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 +TQString 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 = TQString::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(TQString 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(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(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) + TQString 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) + TQFont font(useFont); + font.setPixelSize(static_cast(useSize)); + + TQFontMetrics fm(font); + m_value = m_valueInSpecifiedUnits * fm.boundingRect('x').height(); + } + } + break; + }; +} + +void SVGLengthImpl::convertPercentageToFloat(const TQString &perc, float &result) +{ + // TODO : more error checking ? + if(perc.endsWith("%")) + result = perc.left(perc.length() - 1).toFloat() / 100.0; + else + result = perc.toFloat(); +} + +TQString SVGLengthImpl::convertValToPercentage(const TQString &val, float benchmark) +{ + if(val.endsWith("%")) + return val; + + TQString 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(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 with printnodetest + return 0.0; + + TQPaintDeviceMetrics 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(args[0].toNumber(exec)), args[1].toNumber(exec)); + SVGHelperImpl::updateItem(exec, *obj->context()); + return Undefined(); + case SVGLengthImpl::ConvertToSpecifiedUnits: + obj->convertToSpecifiedUnits(static_cast(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(exec, "[[svglength.constructor]]"); +} diff --git a/ksvg/impl/SVGLengthListImpl.cc b/ksvg/impl/SVGLengthListImpl.cc deleted file mode 100644 index 2966dec8..00000000 --- a/ksvg/impl/SVGLengthListImpl.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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::getValueProperty(exec, token); -} - -Value SVGLengthListImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) -{ - KSVG_CHECK_THIS(SVGLengthListImpl) - - return obj->call(exec, static_cast *>(obj), args, id); -} diff --git a/ksvg/impl/SVGLengthListImpl.cpp b/ksvg/impl/SVGLengthListImpl.cpp new file mode 100644 index 00000000..2966dec8 --- /dev/null +++ b/ksvg/impl/SVGLengthListImpl.cpp @@ -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. +*/ + +#include + +#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::getValueProperty(exec, token); +} + +Value SVGLengthListImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGLengthListImpl) + + return obj->call(exec, static_cast *>(obj), args, id); +} diff --git a/ksvg/impl/SVGLineElementImpl.cc b/ksvg/impl/SVGLineElementImpl.cc deleted file mode 100644 index eee19d06..00000000 --- a/ksvg/impl/SVGLineElementImpl.cc +++ /dev/null @@ -1,211 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 -#include - -#include - -#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); - } -} diff --git a/ksvg/impl/SVGLineElementImpl.cpp b/ksvg/impl/SVGLineElementImpl.cpp new file mode 100644 index 00000000..eee19d06 --- /dev/null +++ b/ksvg/impl/SVGLineElementImpl.cpp @@ -0,0 +1,211 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 +#include + +#include + +#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); + } +} diff --git a/ksvg/impl/SVGLinearGradientElementImpl.cc b/ksvg/impl/SVGLinearGradientElementImpl.cc deleted file mode 100644 index 0a01a748..00000000 --- a/ksvg/impl/SVGLinearGradientElementImpl.cc +++ /dev/null @@ -1,199 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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") -} - -TQMap SVGLinearGradientElementImpl::gradientAttributes() -{ - setAttributes(); - - TQMap gradAttributes; - TQDictIterator 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; -} diff --git a/ksvg/impl/SVGLinearGradientElementImpl.cpp b/ksvg/impl/SVGLinearGradientElementImpl.cpp new file mode 100644 index 00000000..0a01a748 --- /dev/null +++ b/ksvg/impl/SVGLinearGradientElementImpl.cpp @@ -0,0 +1,199 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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") +} + +TQMap SVGLinearGradientElementImpl::gradientAttributes() +{ + setAttributes(); + + TQMap gradAttributes; + TQDictIterator 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; +} diff --git a/ksvg/impl/SVGLocatableImpl.cc b/ksvg/impl/SVGLocatableImpl.cc deleted file mode 100644 index 1bf17fb6..00000000 --- a/ksvg/impl/SVGLocatableImpl.cc +++ /dev/null @@ -1,206 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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(this); - - if(shape) - { - // TODO: Update due to matrix animations - //if(shape->item()) - // shape->item()->update(updateReason); - - SVGElementImpl *element = dynamic_cast(this); - - DOM::Node node = element->firstChild(); - for(; !node.isNull(); node = node.nextSibling()) - { - SVGElementImpl *child = element->ownerDoc()->getElementFromHandle(node.handle()); - SVGLocatableImpl *locatable = dynamic_cast(child); - - if(child && locatable) - locatable->updateCachedScreenCTM(m_cachedScreenCTM); - } - } -} - -void SVGLocatableImpl::checkCachedScreenCTM(const SVGMatrixImpl *parentScreenCTM) -{ - if(m_cachedScreenCTMIsValid) - { - SVGElementImpl *element = dynamic_cast(this); - SVGShapeImpl *shape = dynamic_cast(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(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(obj); - if(container) - return container->getBBox()->cache(exec); - else - { - SVGShapeImpl *shape = dynamic_cast(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 *>(args[0].imp())->impl())->cache(exec); - default: - kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; - break; - } - - return Undefined(); -} diff --git a/ksvg/impl/SVGLocatableImpl.cpp b/ksvg/impl/SVGLocatableImpl.cpp new file mode 100644 index 00000000..1bf17fb6 --- /dev/null +++ b/ksvg/impl/SVGLocatableImpl.cpp @@ -0,0 +1,206 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#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(this); + + if(shape) + { + // TODO: Update due to matrix animations + //if(shape->item()) + // shape->item()->update(updateReason); + + SVGElementImpl *element = dynamic_cast(this); + + DOM::Node node = element->firstChild(); + for(; !node.isNull(); node = node.nextSibling()) + { + SVGElementImpl *child = element->ownerDoc()->getElementFromHandle(node.handle()); + SVGLocatableImpl *locatable = dynamic_cast(child); + + if(child && locatable) + locatable->updateCachedScreenCTM(m_cachedScreenCTM); + } + } +} + +void SVGLocatableImpl::checkCachedScreenCTM(const SVGMatrixImpl *parentScreenCTM) +{ + if(m_cachedScreenCTMIsValid) + { + SVGElementImpl *element = dynamic_cast(this); + SVGShapeImpl *shape = dynamic_cast(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(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(obj); + if(container) + return container->getBBox()->cache(exec); + else + { + SVGShapeImpl *shape = dynamic_cast(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 *>(args[0].imp())->impl())->cache(exec); + default: + kdWarning() << "Unhandled function id in " << k_funcinfo << " : " << id << endl; + break; + } + + return Undefined(); +} diff --git a/ksvg/impl/SVGMPathElementImpl.cc b/ksvg/impl/SVGMPathElementImpl.cc deleted file mode 100644 index 8348e07a..00000000 --- a/ksvg/impl/SVGMPathElementImpl.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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() -{ -} diff --git a/ksvg/impl/SVGMPathElementImpl.cpp b/ksvg/impl/SVGMPathElementImpl.cpp new file mode 100644 index 00000000..8348e07a --- /dev/null +++ b/ksvg/impl/SVGMPathElementImpl.cpp @@ -0,0 +1,31 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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() +{ +} diff --git a/ksvg/impl/SVGMarkerElementImpl.cc b/ksvg/impl/SVGMarkerElementImpl.cc deleted file mode 100644 index 554f56b7..00000000 --- a/ksvg/impl/SVGMarkerElementImpl.cc +++ /dev/null @@ -1,422 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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(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(element); - SVGTestsImpl *tests = dynamic_cast(element); - SVGStylableImpl *style = dynamic_cast(element); - - bool ok = tests ? tests->ok() : true; - if(element && shape && style && ok && style->getVisible() && style->getDisplay()) - { - SVGLocatableImpl *locatable = dynamic_cast(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: - { - TQString 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 *>(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(exec, "[[svgmarkerelement.constructor]]"); -} diff --git a/ksvg/impl/SVGMarkerElementImpl.cpp b/ksvg/impl/SVGMarkerElementImpl.cpp new file mode 100644 index 00000000..554f56b7 --- /dev/null +++ b/ksvg/impl/SVGMarkerElementImpl.cpp @@ -0,0 +1,422 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#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(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(element); + SVGTestsImpl *tests = dynamic_cast(element); + SVGStylableImpl *style = dynamic_cast(element); + + bool ok = tests ? tests->ok() : true; + if(element && shape && style && ok && style->getVisible() && style->getDisplay()) + { + SVGLocatableImpl *locatable = dynamic_cast(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: + { + TQString 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 *>(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(exec, "[[svgmarkerelement.constructor]]"); +} diff --git a/ksvg/impl/SVGMaskElementImpl.cc b/ksvg/impl/SVGMaskElementImpl.cc deleted file mode 100644 index d3947ff4..00000000 --- a/ksvg/impl/SVGMaskElementImpl.cc +++ /dev/null @@ -1,540 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#include -#include - -#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 - -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()); - - TQ_UINT32 *imageBits = new TQ_UINT32[imageWidth * imageHeight]; - - if(m_canvas == 0) - m_canvas = CanvasFactory::self()->loadCanvas(imageWidth, imageHeight); - - m_canvas->setup(reinterpret_cast(imageBits), imageWidth, imageHeight); - m_canvas->setBackgroundColor(tqRgba(0, 0, 0, 0)); - - SVGMatrixImpl *baseMatrix = SVGSVGElementImpl::createSVGMatrix(); - - // Set the scale to map the mask onto the image - double xScale = static_cast(imageWidth) / width()->baseVal()->value(); - double yScale = static_cast(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(element); - SVGTestsImpl *tests = dynamic_cast(element); - SVGStylableImpl *style = dynamic_cast(element); - - bool ok = tests ? tests->ok() : true; - if(element && shape && style && ok && style->getVisible() && style->getDisplay()) - { - SVGLocatableImpl *locatable = dynamic_cast(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(element); - SVGTestsImpl *tests = dynamic_cast(element); - SVGStylableImpl *style = dynamic_cast(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 - //TQImage maskImage(reinterpret_cast(imageBits), imageWidth, imageHeight, 32, 0, 0, TQImage::IgnoreEndian); - //maskImage.setAlphaBuffer(true); - //maskImage.save("mask.png", "PNG"); - } - - TQByteArray 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++) - { - TQ_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(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. - TQWMatrix 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(referencingElement); - if(locatableRef) - refCTM = locatableRef->getScreenCTM(); - else - refCTM = SVGSVGElementImpl::createSVGMatrix(); - - double xScale, yScale; - - refCTM->removeScale(&xScale, &yScale); - refCTM->deref(); - - int imageWidth = static_cast(width()->baseVal()->value() * xScale + 0.5); - int imageHeight = static_cast(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); - - TQWMatrix screenToMask = matrix->qmatrix().invert(); - matrix->deref(); - - mask.setScreenToMask(screenToMask); - } - - return mask; -} - -TQByteArray SVGMaskElementImpl::maskRectangle(SVGShapeImpl *shape, const TQRect& screenRectangle) -{ - TQByteArray cumulativeMask; - - do - { - SVGStylableImpl *style = dynamic_cast(shape); - - if(style && style->hasMask()) - { - SVGElementImpl *element = shape->ownerDoc()->rootElement()->getElementById(style->getMask()); - - if(element) - { - SVGMaskElementImpl *maskElement = dynamic_cast(element); - - if(maskElement) - { - SVGMaskElementImpl::Mask mask = maskElement->createMask(shape); - - if(!mask.isEmpty()) - { - TQByteArray 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(parent); - else - shape = 0; - } - else - shape = 0; - - } while(shape); - - return cumulativeMask; -} - -SVGMaskElementImpl::Mask::Mask(const TQByteArray& mask, const TQWMatrix& screenToMask, int width, int height) - : m_width(width), m_height(height), m_mask(mask), m_screenToMask(screenToMask) -{ -} - -TQByteArray SVGMaskElementImpl::Mask::rectangle(int screenX, int screenY, int width, int height) -{ - TQByteArray 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; -} - -TQByteArray SVGMaskElementImpl::Mask::rectangle(const TQRect& rect) -{ - return rectangle(rect.x(), rect.y(), rect.width(), rect.height()); -} diff --git a/ksvg/impl/SVGMaskElementImpl.cpp b/ksvg/impl/SVGMaskElementImpl.cpp new file mode 100644 index 00000000..d3947ff4 --- /dev/null +++ b/ksvg/impl/SVGMaskElementImpl.cpp @@ -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 + +#include +#include + +#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 + +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()); + + TQ_UINT32 *imageBits = new TQ_UINT32[imageWidth * imageHeight]; + + if(m_canvas == 0) + m_canvas = CanvasFactory::self()->loadCanvas(imageWidth, imageHeight); + + m_canvas->setup(reinterpret_cast(imageBits), imageWidth, imageHeight); + m_canvas->setBackgroundColor(tqRgba(0, 0, 0, 0)); + + SVGMatrixImpl *baseMatrix = SVGSVGElementImpl::createSVGMatrix(); + + // Set the scale to map the mask onto the image + double xScale = static_cast(imageWidth) / width()->baseVal()->value(); + double yScale = static_cast(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(element); + SVGTestsImpl *tests = dynamic_cast(element); + SVGStylableImpl *style = dynamic_cast(element); + + bool ok = tests ? tests->ok() : true; + if(element && shape && style && ok && style->getVisible() && style->getDisplay()) + { + SVGLocatableImpl *locatable = dynamic_cast(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(element); + SVGTestsImpl *tests = dynamic_cast(element); + SVGStylableImpl *style = dynamic_cast(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 + //TQImage maskImage(reinterpret_cast(imageBits), imageWidth, imageHeight, 32, 0, 0, TQImage::IgnoreEndian); + //maskImage.setAlphaBuffer(true); + //maskImage.save("mask.png", "PNG"); + } + + TQByteArray 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++) + { + TQ_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(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. + TQWMatrix 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(referencingElement); + if(locatableRef) + refCTM = locatableRef->getScreenCTM(); + else + refCTM = SVGSVGElementImpl::createSVGMatrix(); + + double xScale, yScale; + + refCTM->removeScale(&xScale, &yScale); + refCTM->deref(); + + int imageWidth = static_cast(width()->baseVal()->value() * xScale + 0.5); + int imageHeight = static_cast(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); + + TQWMatrix screenToMask = matrix->qmatrix().invert(); + matrix->deref(); + + mask.setScreenToMask(screenToMask); + } + + return mask; +} + +TQByteArray SVGMaskElementImpl::maskRectangle(SVGShapeImpl *shape, const TQRect& screenRectangle) +{ + TQByteArray cumulativeMask; + + do + { + SVGStylableImpl *style = dynamic_cast(shape); + + if(style && style->hasMask()) + { + SVGElementImpl *element = shape->ownerDoc()->rootElement()->getElementById(style->getMask()); + + if(element) + { + SVGMaskElementImpl *maskElement = dynamic_cast(element); + + if(maskElement) + { + SVGMaskElementImpl::Mask mask = maskElement->createMask(shape); + + if(!mask.isEmpty()) + { + TQByteArray 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(parent); + else + shape = 0; + } + else + shape = 0; + + } while(shape); + + return cumulativeMask; +} + +SVGMaskElementImpl::Mask::Mask(const TQByteArray& mask, const TQWMatrix& screenToMask, int width, int height) + : m_width(width), m_height(height), m_mask(mask), m_screenToMask(screenToMask) +{ +} + +TQByteArray SVGMaskElementImpl::Mask::rectangle(int screenX, int screenY, int width, int height) +{ + TQByteArray 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; +} + +TQByteArray SVGMaskElementImpl::Mask::rectangle(const TQRect& rect) +{ + return rectangle(rect.x(), rect.y(), rect.width(), rect.height()); +} diff --git a/ksvg/impl/SVGMatrixImpl.cc b/ksvg/impl/SVGMatrixImpl.cc deleted file mode 100644 index 1f48848d..00000000 --- a/ksvg/impl/SVGMatrixImpl.cc +++ /dev/null @@ -1,458 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#include - -#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(TQWMatrix 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) -{ - TQWMatrix 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. - TQWMatrix temp; - temp.translate(x, y); - m_mat *= temp; - return this; -} - -SVGMatrixImpl *SVGMatrixImpl::postScale(const double &scaleFactor) -{ - TQWMatrix temp; - temp.scale(scaleFactor, scaleFactor); - m_mat *= temp; - return this; -} - -SVGMatrixImpl *SVGMatrixImpl::postScaleNonUniform(const double &scaleFactorX, const double &scaleFactorY) -{ - TQWMatrix temp; - temp.scale(scaleFactorX, scaleFactorY); - m_mat *= temp; - return this; -} - -SVGMatrixImpl *SVGMatrixImpl::postRotate(const double &angle) -{ - TQWMatrix temp; - temp.rotate(angle); - m_mat *= temp; - return this; -} - -SVGMatrixImpl *SVGMatrixImpl::postRotateFromVector(const double &x, const double &y) -{ - TQWMatrix temp; - temp.rotate(SVGAngleImpl::todeg(atan2(y, x))); - m_mat *= temp; - return this; -} - -SVGMatrixImpl *SVGMatrixImpl::postFlipX() -{ - TQWMatrix temp(-1.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0F); - m_mat *= temp; - return this; -} - -SVGMatrixImpl *SVGMatrixImpl::postFlipY() -{ - TQWMatrix temp(1.0F, 0.0F, 0.0F, -1.0F, 0.0F, 0.0F); - m_mat *= temp; - return this; -} - -SVGMatrixImpl *SVGMatrixImpl::postSkewX(const double &angle) -{ - TQWMatrix temp; - temp.shear(tan(SVGAngleImpl::torad(angle)), 0.0F); - m_mat *= temp; - return this; -} - -SVGMatrixImpl *SVGMatrixImpl::postSkewY(const double &angle) -{ - TQWMatrix temp; - temp.shear(0.0F, tan(SVGAngleImpl::torad(angle))); - m_mat *= temp; - return this; -} - -SVGMatrixImpl *SVGMatrixImpl::multiply(const SVGMatrixImpl *secondMatrix) -{ - TQWMatrix 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(TQWMatrix mat) -{ - m_mat = mat; -} - -TQWMatrix &SVGMatrixImpl::qmatrix() -{ - return m_mat; -} - -const TQWMatrix &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 -{ - TQWMatrix 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 *>(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(); -} diff --git a/ksvg/impl/SVGMatrixImpl.cpp b/ksvg/impl/SVGMatrixImpl.cpp new file mode 100644 index 00000000..1f48848d --- /dev/null +++ b/ksvg/impl/SVGMatrixImpl.cpp @@ -0,0 +1,458 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#include + +#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(TQWMatrix 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) +{ + TQWMatrix 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. + TQWMatrix temp; + temp.translate(x, y); + m_mat *= temp; + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::postScale(const double &scaleFactor) +{ + TQWMatrix temp; + temp.scale(scaleFactor, scaleFactor); + m_mat *= temp; + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::postScaleNonUniform(const double &scaleFactorX, const double &scaleFactorY) +{ + TQWMatrix temp; + temp.scale(scaleFactorX, scaleFactorY); + m_mat *= temp; + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::postRotate(const double &angle) +{ + TQWMatrix temp; + temp.rotate(angle); + m_mat *= temp; + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::postRotateFromVector(const double &x, const double &y) +{ + TQWMatrix temp; + temp.rotate(SVGAngleImpl::todeg(atan2(y, x))); + m_mat *= temp; + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::postFlipX() +{ + TQWMatrix temp(-1.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0F); + m_mat *= temp; + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::postFlipY() +{ + TQWMatrix temp(1.0F, 0.0F, 0.0F, -1.0F, 0.0F, 0.0F); + m_mat *= temp; + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::postSkewX(const double &angle) +{ + TQWMatrix temp; + temp.shear(tan(SVGAngleImpl::torad(angle)), 0.0F); + m_mat *= temp; + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::postSkewY(const double &angle) +{ + TQWMatrix temp; + temp.shear(0.0F, tan(SVGAngleImpl::torad(angle))); + m_mat *= temp; + return this; +} + +SVGMatrixImpl *SVGMatrixImpl::multiply(const SVGMatrixImpl *secondMatrix) +{ + TQWMatrix 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(TQWMatrix mat) +{ + m_mat = mat; +} + +TQWMatrix &SVGMatrixImpl::qmatrix() +{ + return m_mat; +} + +const TQWMatrix &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 +{ + TQWMatrix 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 *>(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(); +} diff --git a/ksvg/impl/SVGMetadataElementImpl.cc b/ksvg/impl/SVGMetadataElementImpl.cc deleted file mode 100644 index 9fa245bf..00000000 --- a/ksvg/impl/SVGMetadataElementImpl.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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() -{ -} diff --git a/ksvg/impl/SVGMetadataElementImpl.cpp b/ksvg/impl/SVGMetadataElementImpl.cpp new file mode 100644 index 00000000..9fa245bf --- /dev/null +++ b/ksvg/impl/SVGMetadataElementImpl.cpp @@ -0,0 +1,31 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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() +{ +} diff --git a/ksvg/impl/SVGMissingGlyphElementImpl.cc b/ksvg/impl/SVGMissingGlyphElementImpl.cc deleted file mode 100644 index f522dff6..00000000 --- a/ksvg/impl/SVGMissingGlyphElementImpl.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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() -{ -} diff --git a/ksvg/impl/SVGMissingGlyphElementImpl.cpp b/ksvg/impl/SVGMissingGlyphElementImpl.cpp new file mode 100644 index 00000000..f522dff6 --- /dev/null +++ b/ksvg/impl/SVGMissingGlyphElementImpl.cpp @@ -0,0 +1,31 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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() +{ +} diff --git a/ksvg/impl/SVGNumberImpl.cc b/ksvg/impl/SVGNumberImpl.cc deleted file mode 100644 index b1ec38b6..00000000 --- a/ksvg/impl/SVGNumberImpl.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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; - } -} diff --git a/ksvg/impl/SVGNumberImpl.cpp b/ksvg/impl/SVGNumberImpl.cpp new file mode 100644 index 00000000..b1ec38b6 --- /dev/null +++ b/ksvg/impl/SVGNumberImpl.cpp @@ -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 + +#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; + } +} diff --git a/ksvg/impl/SVGNumberListImpl.cc b/ksvg/impl/SVGNumberListImpl.cc deleted file mode 100644 index a528b474..00000000 --- a/ksvg/impl/SVGNumberListImpl.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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::getValueProperty(exec, token); -} - -Value SVGNumberListImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) -{ - KSVG_CHECK_THIS(SVGNumberListImpl) - - return obj->call(exec, static_cast *>(obj), args, id); -} diff --git a/ksvg/impl/SVGNumberListImpl.cpp b/ksvg/impl/SVGNumberListImpl.cpp new file mode 100644 index 00000000..a528b474 --- /dev/null +++ b/ksvg/impl/SVGNumberListImpl.cpp @@ -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. +*/ + +#include + +#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::getValueProperty(exec, token); +} + +Value SVGNumberListImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGNumberListImpl) + + return obj->call(exec, static_cast *>(obj), args, id); +} diff --git a/ksvg/impl/SVGPaintImpl.cc b/ksvg/impl/SVGPaintImpl.cc deleted file mode 100644 index 8e56baae..00000000 --- a/ksvg/impl/SVGPaintImpl.cc +++ /dev/null @@ -1,173 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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(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(TQColor 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(exec, "[[svgpaint.constructor]]"); -} diff --git a/ksvg/impl/SVGPaintImpl.cpp b/ksvg/impl/SVGPaintImpl.cpp new file mode 100644 index 00000000..8e56baae --- /dev/null +++ b/ksvg/impl/SVGPaintImpl.cpp @@ -0,0 +1,173 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#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(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(TQColor 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(exec, "[[svgpaint.constructor]]"); +} diff --git a/ksvg/impl/SVGPaintServerImpl.cc b/ksvg/impl/SVGPaintServerImpl.cc deleted file mode 100644 index 006ba853..00000000 --- a/ksvg/impl/SVGPaintServerImpl.cc +++ /dev/null @@ -1,52 +0,0 @@ -/* - 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 - -#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 TQString& id) -{ - CanvasPaintServer *pserver = 0; - SVGElementImpl *element = doc->rootElement()->getElementById(id); - - if(element) - { - SVGPaintServerImpl *paintServerElement = dynamic_cast(element); - - if(paintServerElement) - pserver = paintServerElement->paintServer(); - } - - return pserver; -} diff --git a/ksvg/impl/SVGPaintServerImpl.cpp b/ksvg/impl/SVGPaintServerImpl.cpp new file mode 100644 index 00000000..006ba853 --- /dev/null +++ b/ksvg/impl/SVGPaintServerImpl.cpp @@ -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. +*/ + +#include + +#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 TQString& id) +{ + CanvasPaintServer *pserver = 0; + SVGElementImpl *element = doc->rootElement()->getElementById(id); + + if(element) + { + SVGPaintServerImpl *paintServerElement = dynamic_cast(element); + + if(paintServerElement) + pserver = paintServerElement->paintServer(); + } + + return pserver; +} diff --git a/ksvg/impl/SVGPathElementImpl.cc b/ksvg/impl/SVGPathElementImpl.cc deleted file mode 100644 index d64aede3..00000000 --- a/ksvg/impl/SVGPathElementImpl.cc +++ /dev/null @@ -1,866 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 -#include - -#include -#include - -#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) - { - TQString 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(); - TQString 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; - - TQValueVector 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(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(segment); - previousCubicX2 = s->x2(); - previousCubicY2 = s->y2(); - break; - } - case PATHSEG_CURVETO_CUBIC_REL: - { - SVGPathSegCurvetoCubicRelImpl *s = static_cast(segment); - previousCubicX2 = curx + s->x2(); - previousCubicY2 = cury + s->y2(); - break; - } - case PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: - { - SVGPathSegCurvetoCubicSmoothAbsImpl *s = static_cast(segment); - s->setPreviousX2(previousCubicX2); - s->setPreviousY2(previousCubicY2); - previousCubicX2 = s->x2(); - previousCubicY2 = s->y2(); - break; - } - case PATHSEG_CURVETO_CUBIC_SMOOTH_REL: - { - SVGPathSegCurvetoCubicSmoothRelImpl *s = static_cast(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(segment); - previousQuadraticX1 = s->x1(); - previousQuadraticY1 = s->y1(); - break; - } - case PATHSEG_CURVETO_QUADRATIC_REL: - { - SVGPathSegCurvetoQuadraticRelImpl *s = static_cast(segment); - previousQuadraticX1 = curx + s->x1(); - previousQuadraticY1 = cury + s->y1(); - break; - } - case PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: - { - SVGPathSegCurvetoQuadraticSmoothAbsImpl *s = static_cast(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(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(TQValueVector 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(TQValueVector 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; - } - } -} diff --git a/ksvg/impl/SVGPathElementImpl.cpp b/ksvg/impl/SVGPathElementImpl.cpp new file mode 100644 index 00000000..d64aede3 --- /dev/null +++ b/ksvg/impl/SVGPathElementImpl.cpp @@ -0,0 +1,866 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 +#include + +#include +#include + +#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) + { + TQString 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(); + TQString 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; + + TQValueVector 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(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(segment); + previousCubicX2 = s->x2(); + previousCubicY2 = s->y2(); + break; + } + case PATHSEG_CURVETO_CUBIC_REL: + { + SVGPathSegCurvetoCubicRelImpl *s = static_cast(segment); + previousCubicX2 = curx + s->x2(); + previousCubicY2 = cury + s->y2(); + break; + } + case PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: + { + SVGPathSegCurvetoCubicSmoothAbsImpl *s = static_cast(segment); + s->setPreviousX2(previousCubicX2); + s->setPreviousY2(previousCubicY2); + previousCubicX2 = s->x2(); + previousCubicY2 = s->y2(); + break; + } + case PATHSEG_CURVETO_CUBIC_SMOOTH_REL: + { + SVGPathSegCurvetoCubicSmoothRelImpl *s = static_cast(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(segment); + previousQuadraticX1 = s->x1(); + previousQuadraticY1 = s->y1(); + break; + } + case PATHSEG_CURVETO_QUADRATIC_REL: + { + SVGPathSegCurvetoQuadraticRelImpl *s = static_cast(segment); + previousQuadraticX1 = curx + s->x1(); + previousQuadraticY1 = cury + s->y1(); + break; + } + case PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: + { + SVGPathSegCurvetoQuadraticSmoothAbsImpl *s = static_cast(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(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(TQValueVector 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(TQValueVector 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; + } + } +} diff --git a/ksvg/impl/SVGPathSegArcImpl.cc b/ksvg/impl/SVGPathSegArcImpl.cc deleted file mode 100644 index 9d5cc76a..00000000 --- a/ksvg/impl/SVGPathSegArcImpl.cc +++ /dev/null @@ -1,493 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#include - -#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; - } -} diff --git a/ksvg/impl/SVGPathSegArcImpl.cpp b/ksvg/impl/SVGPathSegArcImpl.cpp new file mode 100644 index 00000000..9d5cc76a --- /dev/null +++ b/ksvg/impl/SVGPathSegArcImpl.cpp @@ -0,0 +1,493 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#include + +#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; + } +} diff --git a/ksvg/impl/SVGPathSegClosePathImpl.cc b/ksvg/impl/SVGPathSegClosePathImpl.cc deleted file mode 100644 index f5e15f88..00000000 --- a/ksvg/impl/SVGPathSegClosePathImpl.cc +++ /dev/null @@ -1,44 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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; -} diff --git a/ksvg/impl/SVGPathSegClosePathImpl.cpp b/ksvg/impl/SVGPathSegClosePathImpl.cpp new file mode 100644 index 00000000..f5e15f88 --- /dev/null +++ b/ksvg/impl/SVGPathSegClosePathImpl.cpp @@ -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 "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; +} diff --git a/ksvg/impl/SVGPathSegCurvetoCubicImpl.cc b/ksvg/impl/SVGPathSegCurvetoCubicImpl.cc deleted file mode 100644 index 597b5bdc..00000000 --- a/ksvg/impl/SVGPathSegCurvetoCubicImpl.cc +++ /dev/null @@ -1,323 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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; - } -} diff --git a/ksvg/impl/SVGPathSegCurvetoCubicImpl.cpp b/ksvg/impl/SVGPathSegCurvetoCubicImpl.cpp new file mode 100644 index 00000000..597b5bdc --- /dev/null +++ b/ksvg/impl/SVGPathSegCurvetoCubicImpl.cpp @@ -0,0 +1,323 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#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; + } +} diff --git a/ksvg/impl/SVGPathSegCurvetoCubicSmoothImpl.cc b/ksvg/impl/SVGPathSegCurvetoCubicSmoothImpl.cc deleted file mode 100644 index 8bc5460e..00000000 --- a/ksvg/impl/SVGPathSegCurvetoCubicSmoothImpl.cc +++ /dev/null @@ -1,296 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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; - } -} diff --git a/ksvg/impl/SVGPathSegCurvetoCubicSmoothImpl.cpp b/ksvg/impl/SVGPathSegCurvetoCubicSmoothImpl.cpp new file mode 100644 index 00000000..8bc5460e --- /dev/null +++ b/ksvg/impl/SVGPathSegCurvetoCubicSmoothImpl.cpp @@ -0,0 +1,296 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#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; + } +} diff --git a/ksvg/impl/SVGPathSegCurvetoQuadraticImpl.cc b/ksvg/impl/SVGPathSegCurvetoQuadraticImpl.cc deleted file mode 100644 index fa78804f..00000000 --- a/ksvg/impl/SVGPathSegCurvetoQuadraticImpl.cc +++ /dev/null @@ -1,258 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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; - } -} diff --git a/ksvg/impl/SVGPathSegCurvetoQuadraticImpl.cpp b/ksvg/impl/SVGPathSegCurvetoQuadraticImpl.cpp new file mode 100644 index 00000000..fa78804f --- /dev/null +++ b/ksvg/impl/SVGPathSegCurvetoQuadraticImpl.cpp @@ -0,0 +1,258 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#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; + } +} diff --git a/ksvg/impl/SVGPathSegCurvetoQuadraticSmoothImpl.cc b/ksvg/impl/SVGPathSegCurvetoQuadraticSmoothImpl.cc deleted file mode 100644 index a6cb362f..00000000 --- a/ksvg/impl/SVGPathSegCurvetoQuadraticSmoothImpl.cc +++ /dev/null @@ -1,233 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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; - } -} diff --git a/ksvg/impl/SVGPathSegCurvetoQuadraticSmoothImpl.cpp b/ksvg/impl/SVGPathSegCurvetoQuadraticSmoothImpl.cpp new file mode 100644 index 00000000..a6cb362f --- /dev/null +++ b/ksvg/impl/SVGPathSegCurvetoQuadraticSmoothImpl.cpp @@ -0,0 +1,233 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#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; + } +} diff --git a/ksvg/impl/SVGPathSegImpl.cc b/ksvg/impl/SVGPathSegImpl.cc deleted file mode 100644 index 3ad83d35..00000000 --- a/ksvg/impl/SVGPathSegImpl.cc +++ /dev/null @@ -1,105 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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(exec, "[[svgpathseg.constructor]]"); -} diff --git a/ksvg/impl/SVGPathSegImpl.cpp b/ksvg/impl/SVGPathSegImpl.cpp new file mode 100644 index 00000000..3ad83d35 --- /dev/null +++ b/ksvg/impl/SVGPathSegImpl.cpp @@ -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 + +#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(exec, "[[svgpathseg.constructor]]"); +} diff --git a/ksvg/impl/SVGPathSegLinetoHorizontalImpl.cc b/ksvg/impl/SVGPathSegLinetoHorizontalImpl.cc deleted file mode 100644 index a0f11829..00000000 --- a/ksvg/impl/SVGPathSegLinetoHorizontalImpl.cc +++ /dev/null @@ -1,165 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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; - } -} diff --git a/ksvg/impl/SVGPathSegLinetoHorizontalImpl.cpp b/ksvg/impl/SVGPathSegLinetoHorizontalImpl.cpp new file mode 100644 index 00000000..a0f11829 --- /dev/null +++ b/ksvg/impl/SVGPathSegLinetoHorizontalImpl.cpp @@ -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 + +#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; + } +} diff --git a/ksvg/impl/SVGPathSegLinetoImpl.cc b/ksvg/impl/SVGPathSegLinetoImpl.cc deleted file mode 100644 index c47b6fcc..00000000 --- a/ksvg/impl/SVGPathSegLinetoImpl.cc +++ /dev/null @@ -1,194 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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; - } -} diff --git a/ksvg/impl/SVGPathSegLinetoImpl.cpp b/ksvg/impl/SVGPathSegLinetoImpl.cpp new file mode 100644 index 00000000..c47b6fcc --- /dev/null +++ b/ksvg/impl/SVGPathSegLinetoImpl.cpp @@ -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. +*/ + +#include + +#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; + } +} diff --git a/ksvg/impl/SVGPathSegLinetoVerticalImpl.cc b/ksvg/impl/SVGPathSegLinetoVerticalImpl.cc deleted file mode 100644 index 47ced875..00000000 --- a/ksvg/impl/SVGPathSegLinetoVerticalImpl.cc +++ /dev/null @@ -1,163 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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; - } -} diff --git a/ksvg/impl/SVGPathSegLinetoVerticalImpl.cpp b/ksvg/impl/SVGPathSegLinetoVerticalImpl.cpp new file mode 100644 index 00000000..47ced875 --- /dev/null +++ b/ksvg/impl/SVGPathSegLinetoVerticalImpl.cpp @@ -0,0 +1,163 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#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; + } +} diff --git a/ksvg/impl/SVGPathSegListImpl.cc b/ksvg/impl/SVGPathSegListImpl.cc deleted file mode 100644 index 7e3ff83e..00000000 --- a/ksvg/impl/SVGPathSegListImpl.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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::getValueProperty(exec, token); -} - -Value SVGPathSegListImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) -{ - KSVG_CHECK_THIS(SVGPathSegListImpl) - - return obj->call(exec, static_cast *>(obj), args, id); -} diff --git a/ksvg/impl/SVGPathSegListImpl.cpp b/ksvg/impl/SVGPathSegListImpl.cpp new file mode 100644 index 00000000..7e3ff83e --- /dev/null +++ b/ksvg/impl/SVGPathSegListImpl.cpp @@ -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. +*/ + +#include + +#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::getValueProperty(exec, token); +} + +Value SVGPathSegListImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGPathSegListImpl) + + return obj->call(exec, static_cast *>(obj), args, id); +} diff --git a/ksvg/impl/SVGPathSegMovetoImpl.cc b/ksvg/impl/SVGPathSegMovetoImpl.cc deleted file mode 100644 index 0cafbc25..00000000 --- a/ksvg/impl/SVGPathSegMovetoImpl.cc +++ /dev/null @@ -1,194 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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; - } -} diff --git a/ksvg/impl/SVGPathSegMovetoImpl.cpp b/ksvg/impl/SVGPathSegMovetoImpl.cpp new file mode 100644 index 00000000..0cafbc25 --- /dev/null +++ b/ksvg/impl/SVGPathSegMovetoImpl.cpp @@ -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. +*/ + +#include + +#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; + } +} diff --git a/ksvg/impl/SVGPatternElementImpl.cc b/ksvg/impl/SVGPatternElementImpl.cc deleted file mode 100644 index 37825869..00000000 --- a/ksvg/impl/SVGPatternElementImpl.cc +++ /dev/null @@ -1,509 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 -#include - -#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" - -TQValueList 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 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 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() -{ - TQValueList::iterator it; - - for(it = m_patternElements.begin(); it != m_patternElements.end(); it++) - { - SVGPatternElementImpl *pattern = *it; - - if(pattern->paintServer()) - pattern->paintServer()->resetFinalized(); - } -} - -TQImage SVGPatternElementImpl::createTile(SVGShapeImpl *referencingElement, int imageWidth, int imageHeight) -{ - converter()->finalize(referencingElement, ownerSVGElement(), patternUnits()->baseVal()); - - TQImage image(imageWidth, imageHeight, 32); - image.setAlphaBuffer(true); - - if(m_canvas == 0) - { - m_canvas = CanvasFactory::self()->loadCanvas(image.width(), image.height()); - m_canvas->setBackgroundColor(tqRgba(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(imageWidth) / width()->baseVal()->value(); - double yScale = static_cast(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(element); - SVGTestsImpl *tests = dynamic_cast(element); - SVGStylableImpl *style = dynamic_cast(element); - - bool ok = tests ? tests->ok() : true; - if(element && shape && style && ok && style->getVisible() && style->getDisplay()) - { - SVGLocatableImpl *locatable = dynamic_cast(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()) - { - TQPtrList items = m_canvas->allItems(); - TQRect allItemsBBox; - - TQPtrListIterator it(items); - CanvasItem *item; - - while((item = *it) != 0) - { - TQRect 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) - { - TQPoint 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 TQString &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(); - - TQString _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(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(tileWidth + 0.5); - int imageHeight = static_cast(tileHeight + 0.5); - - Tile tile; - - if(imageWidth > 0 && imageHeight > 0) - { - TQSize size(imageWidth, imageHeight); - TQImage 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); - TQWMatrix screenToTile = matrix->qmatrix().invert(); - - tile = Tile(image, screenToTile); - } - - matrix->deref(); - - return tile; -} - diff --git a/ksvg/impl/SVGPatternElementImpl.cpp b/ksvg/impl/SVGPatternElementImpl.cpp new file mode 100644 index 00000000..37825869 --- /dev/null +++ b/ksvg/impl/SVGPatternElementImpl.cpp @@ -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 +#include + +#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" + +TQValueList 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 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 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() +{ + TQValueList::iterator it; + + for(it = m_patternElements.begin(); it != m_patternElements.end(); it++) + { + SVGPatternElementImpl *pattern = *it; + + if(pattern->paintServer()) + pattern->paintServer()->resetFinalized(); + } +} + +TQImage SVGPatternElementImpl::createTile(SVGShapeImpl *referencingElement, int imageWidth, int imageHeight) +{ + converter()->finalize(referencingElement, ownerSVGElement(), patternUnits()->baseVal()); + + TQImage image(imageWidth, imageHeight, 32); + image.setAlphaBuffer(true); + + if(m_canvas == 0) + { + m_canvas = CanvasFactory::self()->loadCanvas(image.width(), image.height()); + m_canvas->setBackgroundColor(tqRgba(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(imageWidth) / width()->baseVal()->value(); + double yScale = static_cast(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(element); + SVGTestsImpl *tests = dynamic_cast(element); + SVGStylableImpl *style = dynamic_cast(element); + + bool ok = tests ? tests->ok() : true; + if(element && shape && style && ok && style->getVisible() && style->getDisplay()) + { + SVGLocatableImpl *locatable = dynamic_cast(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()) + { + TQPtrList items = m_canvas->allItems(); + TQRect allItemsBBox; + + TQPtrListIterator it(items); + CanvasItem *item; + + while((item = *it) != 0) + { + TQRect 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) + { + TQPoint 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 TQString &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(); + + TQString _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(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(tileWidth + 0.5); + int imageHeight = static_cast(tileHeight + 0.5); + + Tile tile; + + if(imageWidth > 0 && imageHeight > 0) + { + TQSize size(imageWidth, imageHeight); + TQImage 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); + TQWMatrix screenToTile = matrix->qmatrix().invert(); + + tile = Tile(image, screenToTile); + } + + matrix->deref(); + + return tile; +} + diff --git a/ksvg/impl/SVGPointImpl.cc b/ksvg/impl/SVGPointImpl.cc deleted file mode 100644 index ebce509a..00000000 --- a/ksvg/impl/SVGPointImpl.cc +++ /dev/null @@ -1,106 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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; - } -} diff --git a/ksvg/impl/SVGPointImpl.cpp b/ksvg/impl/SVGPointImpl.cpp new file mode 100644 index 00000000..ebce509a --- /dev/null +++ b/ksvg/impl/SVGPointImpl.cpp @@ -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 + +#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; + } +} diff --git a/ksvg/impl/SVGPointListImpl.cc b/ksvg/impl/SVGPointListImpl.cc deleted file mode 100644 index ba492c32..00000000 --- a/ksvg/impl/SVGPointListImpl.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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::getValueProperty(exec, token); -} - -Value SVGPointListImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) -{ - KSVG_CHECK_THIS(SVGPointListImpl) - - return obj->call(exec, static_cast *>(obj), args, id); -} diff --git a/ksvg/impl/SVGPointListImpl.cpp b/ksvg/impl/SVGPointListImpl.cpp new file mode 100644 index 00000000..ba492c32 --- /dev/null +++ b/ksvg/impl/SVGPointListImpl.cpp @@ -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. +*/ + +#include + +#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::getValueProperty(exec, token); +} + +Value SVGPointListImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGPointListImpl) + + return obj->call(exec, static_cast *>(obj), args, id); +} diff --git a/ksvg/impl/SVGPolyElementImpl.cc b/ksvg/impl/SVGPolyElementImpl.cc deleted file mode 100644 index b1557aa3..00000000 --- a/ksvg/impl/SVGPolyElementImpl.cc +++ /dev/null @@ -1,139 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 -#include - -#include - -#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; - } -} diff --git a/ksvg/impl/SVGPolyElementImpl.cpp b/ksvg/impl/SVGPolyElementImpl.cpp new file mode 100644 index 00000000..b1557aa3 --- /dev/null +++ b/ksvg/impl/SVGPolyElementImpl.cpp @@ -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 +#include + +#include + +#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; + } +} diff --git a/ksvg/impl/SVGPolygonElementImpl.cc b/ksvg/impl/SVGPolygonElementImpl.cc deleted file mode 100644 index 0187ce43..00000000 --- a/ksvg/impl/SVGPolygonElementImpl.cc +++ /dev/null @@ -1,86 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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); - } - } - } -} diff --git a/ksvg/impl/SVGPolygonElementImpl.cpp b/ksvg/impl/SVGPolygonElementImpl.cpp new file mode 100644 index 00000000..0187ce43 --- /dev/null +++ b/ksvg/impl/SVGPolygonElementImpl.cpp @@ -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. +*/ + +#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); + } + } + } +} diff --git a/ksvg/impl/SVGPolylineElementImpl.cc b/ksvg/impl/SVGPolylineElementImpl.cc deleted file mode 100644 index 487f2630..00000000 --- a/ksvg/impl/SVGPolylineElementImpl.cc +++ /dev/null @@ -1,98 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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); - } - } -} diff --git a/ksvg/impl/SVGPolylineElementImpl.cpp b/ksvg/impl/SVGPolylineElementImpl.cpp new file mode 100644 index 00000000..487f2630 --- /dev/null +++ b/ksvg/impl/SVGPolylineElementImpl.cpp @@ -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 "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); + } + } +} diff --git a/ksvg/impl/SVGPreserveAspectRatioImpl.cc b/ksvg/impl/SVGPreserveAspectRatioImpl.cc deleted file mode 100644 index bce71948..00000000 --- a/ksvg/impl/SVGPreserveAspectRatioImpl.cc +++ /dev/null @@ -1,215 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#include -#include - -#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 TQString &str) -{ - // Spec: set the defaults - setAlign(SVG_PRESERVEASPECTRATIO_NONE); - setMeetOrSlice(SVG_MEETORSLICE_MEET); - - TQStringList params = TQStringList::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(value.toNumber(exec)); - break; - case MeetOrSlice: - m_meetOrSlice = static_cast(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(exec, "[[svgpreserveaspectratio.constructor]]"); -} diff --git a/ksvg/impl/SVGPreserveAspectRatioImpl.cpp b/ksvg/impl/SVGPreserveAspectRatioImpl.cpp new file mode 100644 index 00000000..bce71948 --- /dev/null +++ b/ksvg/impl/SVGPreserveAspectRatioImpl.cpp @@ -0,0 +1,215 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#include +#include + +#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 TQString &str) +{ + // Spec: set the defaults + setAlign(SVG_PRESERVEASPECTRATIO_NONE); + setMeetOrSlice(SVG_MEETORSLICE_MEET); + + TQStringList params = TQStringList::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(value.toNumber(exec)); + break; + case MeetOrSlice: + m_meetOrSlice = static_cast(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(exec, "[[svgpreserveaspectratio.constructor]]"); +} diff --git a/ksvg/impl/SVGRadialGradientElementImpl.cc b/ksvg/impl/SVGRadialGradientElementImpl.cc deleted file mode 100644 index 6a52ab68..00000000 --- a/ksvg/impl/SVGRadialGradientElementImpl.cc +++ /dev/null @@ -1,214 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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%") -} - -TQMap SVGRadialGradientElementImpl::gradientAttributes() -{ - setAttributes(); - - TQMap gradAttributes; - TQDictIterator 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; -} diff --git a/ksvg/impl/SVGRadialGradientElementImpl.cpp b/ksvg/impl/SVGRadialGradientElementImpl.cpp new file mode 100644 index 00000000..6a52ab68 --- /dev/null +++ b/ksvg/impl/SVGRadialGradientElementImpl.cpp @@ -0,0 +1,214 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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%") +} + +TQMap SVGRadialGradientElementImpl::gradientAttributes() +{ + setAttributes(); + + TQMap gradAttributes; + TQDictIterator 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; +} diff --git a/ksvg/impl/SVGRectElementImpl.cc b/ksvg/impl/SVGRectElementImpl.cc deleted file mode 100644 index 30a527ca..00000000 --- a/ksvg/impl/SVGRectElementImpl.cc +++ /dev/null @@ -1,242 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 -#include - -#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 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 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 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 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); - } -} diff --git a/ksvg/impl/SVGRectElementImpl.cpp b/ksvg/impl/SVGRectElementImpl.cpp new file mode 100644 index 00000000..30a527ca --- /dev/null +++ b/ksvg/impl/SVGRectElementImpl.cpp @@ -0,0 +1,242 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 +#include + +#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 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 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 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 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); + } +} diff --git a/ksvg/impl/SVGRectImpl.cc b/ksvg/impl/SVGRectImpl.cc deleted file mode 100644 index f02b5a4d..00000000 --- a/ksvg/impl/SVGRectImpl.cc +++ /dev/null @@ -1,155 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#include - -#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 TQRect &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; -} - -TQRect SVGRectImpl::qrect() const -{ - // ceil() so the integer rectangle contains the whole real one. - return TQRect(int(m_x), int(m_y), int(ceil(m_width)), int(ceil(m_height))); -} - -SVGRectImpl &SVGRectImpl::operator=(const TQRect &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; - } -} diff --git a/ksvg/impl/SVGRectImpl.cpp b/ksvg/impl/SVGRectImpl.cpp new file mode 100644 index 00000000..f02b5a4d --- /dev/null +++ b/ksvg/impl/SVGRectImpl.cpp @@ -0,0 +1,155 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#include + +#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 TQRect &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; +} + +TQRect SVGRectImpl::qrect() const +{ + // ceil() so the integer rectangle contains the whole real one. + return TQRect(int(m_x), int(m_y), int(ceil(m_width)), int(ceil(m_height))); +} + +SVGRectImpl &SVGRectImpl::operator=(const TQRect &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; + } +} diff --git a/ksvg/impl/SVGSVGElementImpl.cc b/ksvg/impl/SVGSVGElementImpl.cc deleted file mode 100644 index 98106d7c..00000000 --- a/ksvg/impl/SVGSVGElementImpl.cc +++ /dev/null @@ -1,980 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#include -#include -#include - -#define USE_VALGRIND 0 - -#if USE_VALGRIND -#include -#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 TQPoint &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 - - TQTime 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(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(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(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(TQWMatrix(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 TQString &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 TQString &clip) -{ - // TODO : this routine should probably be shared between all classes that establish new viewports (Rob) - if(!clip.startsWith("rect(") || !clip.endsWith(")")) - return; - - TQString work = clip.mid(5, clip.length() - 6); - TQStringList substrings = TQStringList::split(',', clip); - TQStringList::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); -} - -TQRect SVGSVGElementImpl::clip() -{ - // Get viewport in user coordinates. - TQRect v(0, 0, m_viewport->qrect().width(), m_viewport->qrect().height()); - - SVGMatrixImpl *ctm = getCTM(); - TQRect r = ctm->qmatrix().invert().mapRect(v); - ctm->deref(); - - if(m_clip[0]) - r.setTop(static_cast(r.top() + m_clip[0]->value())); - if(m_clip[1]) - r.setRight(static_cast(r.right() - m_clip[1]->value())); - if(m_clip[2]) - r.setBottom(static_cast(r.bottom() - m_clip[2]->value())); - if(m_clip[3]) - r.setLeft(static_cast(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 TQPoint &p, const TQPoint &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(); - TQPoint 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 *>(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(); -} diff --git a/ksvg/impl/SVGSVGElementImpl.cpp b/ksvg/impl/SVGSVGElementImpl.cpp new file mode 100644 index 00000000..98106d7c --- /dev/null +++ b/ksvg/impl/SVGSVGElementImpl.cpp @@ -0,0 +1,980 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#include +#include +#include + +#define USE_VALGRIND 0 + +#if USE_VALGRIND +#include +#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 TQPoint &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 + + TQTime 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(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(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(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(TQWMatrix(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 TQString &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 TQString &clip) +{ + // TODO : this routine should probably be shared between all classes that establish new viewports (Rob) + if(!clip.startsWith("rect(") || !clip.endsWith(")")) + return; + + TQString work = clip.mid(5, clip.length() - 6); + TQStringList substrings = TQStringList::split(',', clip); + TQStringList::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); +} + +TQRect SVGSVGElementImpl::clip() +{ + // Get viewport in user coordinates. + TQRect v(0, 0, m_viewport->qrect().width(), m_viewport->qrect().height()); + + SVGMatrixImpl *ctm = getCTM(); + TQRect r = ctm->qmatrix().invert().mapRect(v); + ctm->deref(); + + if(m_clip[0]) + r.setTop(static_cast(r.top() + m_clip[0]->value())); + if(m_clip[1]) + r.setRight(static_cast(r.right() - m_clip[1]->value())); + if(m_clip[2]) + r.setBottom(static_cast(r.bottom() - m_clip[2]->value())); + if(m_clip[3]) + r.setLeft(static_cast(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 TQPoint &p, const TQPoint &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(); + TQPoint 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 *>(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(); +} diff --git a/ksvg/impl/SVGScriptElementImpl.cc b/ksvg/impl/SVGScriptElementImpl.cc deleted file mode 100644 index f97ebf89..00000000 --- a/ksvg/impl/SVGScriptElementImpl.cc +++ /dev/null @@ -1,183 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#include -#include -#include - -#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) : TQObject(), 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 - TQString href = m_href->baseVal().string(); - - if(!href.isEmpty()) - { - KURL url(ownerDoc()->baseUrl(), href); - - if(m_job == 0) - m_job = TDEIO::get(url, false, false); - - connect(m_job, TQT_SIGNAL(data(TDEIO::Job *, const TQByteArray &)), this, TQT_SLOT(slotData(TDEIO::Job *, const TQByteArray &))); - connect(m_job, TQT_SIGNAL(result(TDEIO::Job *)), this, TQT_SLOT(slotResult(TDEIO::Job *))); - } -} - -void SVGScriptElementImpl::slotData(TDEIO::Job *, const TQByteArray &data) -{ - TQDataStream dataStream(m_data, IO_WriteOnly | IO_Append); - dataStream.writeRawBytes(data.data(), data.size()); -} - -void SVGScriptElementImpl::slotResult(TDEIO::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'; - - TQBuffer buf(m_data); - TQIODevice *dev = KFilterDev::device(TQT_TQIODEVICE(&buf), "application/x-gzip", false); - TQByteArray contents; - if(dev->open(IO_ReadOnly)) - contents = dev->readAll(); - delete dev; - m_text = TQString::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 TQString &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; - } -} diff --git a/ksvg/impl/SVGScriptElementImpl.cpp b/ksvg/impl/SVGScriptElementImpl.cpp new file mode 100644 index 00000000..f97ebf89 --- /dev/null +++ b/ksvg/impl/SVGScriptElementImpl.cpp @@ -0,0 +1,183 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#include +#include +#include + +#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) : TQObject(), 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 + TQString href = m_href->baseVal().string(); + + if(!href.isEmpty()) + { + KURL url(ownerDoc()->baseUrl(), href); + + if(m_job == 0) + m_job = TDEIO::get(url, false, false); + + connect(m_job, TQT_SIGNAL(data(TDEIO::Job *, const TQByteArray &)), this, TQT_SLOT(slotData(TDEIO::Job *, const TQByteArray &))); + connect(m_job, TQT_SIGNAL(result(TDEIO::Job *)), this, TQT_SLOT(slotResult(TDEIO::Job *))); + } +} + +void SVGScriptElementImpl::slotData(TDEIO::Job *, const TQByteArray &data) +{ + TQDataStream dataStream(m_data, IO_WriteOnly | IO_Append); + dataStream.writeRawBytes(data.data(), data.size()); +} + +void SVGScriptElementImpl::slotResult(TDEIO::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'; + + TQBuffer buf(m_data); + TQIODevice *dev = KFilterDev::device(TQT_TQIODEVICE(&buf), "application/x-gzip", false); + TQByteArray contents; + if(dev->open(IO_ReadOnly)) + contents = dev->readAll(); + delete dev; + m_text = TQString::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 TQString &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; + } +} diff --git a/ksvg/impl/SVGSetElementImpl.cc b/ksvg/impl/SVGSetElementImpl.cc deleted file mode 100644 index 9e506eac..00000000 --- a/ksvg/impl/SVGSetElementImpl.cc +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 (Niko) - // Those are automatically deleted by the scheduler after timeout. - ownerDoc()->timeScheduler()->addTimer(this, int(getStartTime() * 1000.0)); -} - -void SVGSetElementImpl::handleTimerEvent() -{ - applyAttribute(getAttributeName(), getTo()); -} diff --git a/ksvg/impl/SVGSetElementImpl.cpp b/ksvg/impl/SVGSetElementImpl.cpp new file mode 100644 index 00000000..9e506eac --- /dev/null +++ b/ksvg/impl/SVGSetElementImpl.cpp @@ -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 "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 (Niko) + // Those are automatically deleted by the scheduler after timeout. + ownerDoc()->timeScheduler()->addTimer(this, int(getStartTime() * 1000.0)); +} + +void SVGSetElementImpl::handleTimerEvent() +{ + applyAttribute(getAttributeName(), getTo()); +} diff --git a/ksvg/impl/SVGShapeImpl.cc b/ksvg/impl/SVGShapeImpl.cc deleted file mode 100644 index dc9b728f..00000000 --- a/ksvg/impl/SVGShapeImpl.cc +++ /dev/null @@ -1,160 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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(ownerDoc()->getElementFromHandle(node.handle())); - if(rend) - rend->deref(); - } - } -} - -bool SVGShapeImpl::directRender() -{ - SVGShapeImpl *parent = dynamic_cast(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) - { - TQRect 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 TQPoint &p, const TQPoint &, SVGMouseEventImpl *mev) -{ - // TODO : pointer-events should be stored here, not in SVGStylableImpl. - SVGStylableImpl *style = dynamic_cast(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; - } -} diff --git a/ksvg/impl/SVGShapeImpl.cpp b/ksvg/impl/SVGShapeImpl.cpp new file mode 100644 index 00000000..dc9b728f --- /dev/null +++ b/ksvg/impl/SVGShapeImpl.cpp @@ -0,0 +1,160 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#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(ownerDoc()->getElementFromHandle(node.handle())); + if(rend) + rend->deref(); + } + } +} + +bool SVGShapeImpl::directRender() +{ + SVGShapeImpl *parent = dynamic_cast(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) + { + TQRect 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 TQPoint &p, const TQPoint &, SVGMouseEventImpl *mev) +{ + // TODO : pointer-events should be stored here, not in SVGStylableImpl. + SVGStylableImpl *style = dynamic_cast(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; + } +} diff --git a/ksvg/impl/SVGStopElementImpl.cc b/ksvg/impl/SVGStopElementImpl.cc deleted file mode 100644 index f15fb0a6..00000000 --- a/ksvg/impl/SVGStopElementImpl.cc +++ /dev/null @@ -1,123 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 -#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") -} diff --git a/ksvg/impl/SVGStopElementImpl.cpp b/ksvg/impl/SVGStopElementImpl.cpp new file mode 100644 index 00000000..f15fb0a6 --- /dev/null +++ b/ksvg/impl/SVGStopElementImpl.cpp @@ -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. +*/ + +#include +#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") +} diff --git a/ksvg/impl/SVGStringListImpl.cc b/ksvg/impl/SVGStringListImpl.cc deleted file mode 100644 index 331b4393..00000000 --- a/ksvg/impl/SVGStringListImpl.cc +++ /dev/null @@ -1,91 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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::getValueProperty(exec, token); -} - -Value SVGStringListImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) -{ - KSVG_CHECK_THIS(SVGStringListImpl) - - return obj->call(exec, static_cast *>(obj), args, id); -} - -TQString SVGStringListImpl::join(const TQString &seperator) const -{ - SVGStringListImpl *self = const_cast(this); - - TQString 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; -} diff --git a/ksvg/impl/SVGStringListImpl.cpp b/ksvg/impl/SVGStringListImpl.cpp new file mode 100644 index 00000000..331b4393 --- /dev/null +++ b/ksvg/impl/SVGStringListImpl.cpp @@ -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 + +#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::getValueProperty(exec, token); +} + +Value SVGStringListImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGStringListImpl) + + return obj->call(exec, static_cast *>(obj), args, id); +} + +TQString SVGStringListImpl::join(const TQString &seperator) const +{ + SVGStringListImpl *self = const_cast(this); + + TQString 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; +} diff --git a/ksvg/impl/SVGStylableImpl.cc b/ksvg/impl/SVGStylableImpl.cc deleted file mode 100644 index 4400b236..00000000 --- a/ksvg/impl/SVGStylableImpl.cc +++ /dev/null @@ -1,1307 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#include - -#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(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 = TQString(); - } - - // Spec: default "none" - if(~m_flags & SVG_STYLE_FLAG_MARKER_MID) - { - if(parentStyle) - m_midMarker = parentStyle->getMidMarker(); - else - m_midMarker = TQString(); - } - - // Spec: default "none" - if(~m_flags & SVG_STYLE_FLAG_MARKER_END) - { - if(parentStyle) - m_endMarker = parentStyle->getEndMarker(); - else - m_endMarker = TQString(); - } -} - -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; -} - -TQString SVGStylableImpl::extractUrlId(const TQString &url) -{ - TQString 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 TQString &marker) -{ - setStartMarker(marker); - setMidMarker(marker); - setEndMarker(marker); -} - -void SVGStylableImpl::setStartMarker(const TQString &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 = TQString(); -} - -void SVGStylableImpl::setMidMarker(const TQString &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 = TQString(); -} - -void SVGStylableImpl::setEndMarker(const TQString &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 = TQString(); -} - -bool SVGStylableImpl::hasMarkers() const -{ - return !m_startMarker.isEmpty() || !m_midMarker.isEmpty() || !m_endMarker.isEmpty(); -} - -void SVGStylableImpl::setPaint(const TQString ¶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 TQString ¶m, SVGColorImpl *svgColor) -{ - if(param.stripWhiteSpace().startsWith("#")) - { - if(param.contains("icc-color")) - { - TQString first = param.left(7); - TQString last = param.right(param.length() - 8); - - svgColor->setRGBColorICCColor(first, last); - } - else - { - TQColor color; - color.setNamedColor(param.stripWhiteSpace()); - svgColor->setRGBColor(color); - } - } - else if(param.stripWhiteSpace().startsWith("rgb(")) - { - TQString parse = param.stripWhiteSpace(); - TQStringList colors = TQStringList::split(',', parse); - TQString r = colors[0].right((colors[0].length() - 4)); - TQString g = colors[1]; - TQString b = colors[2].left((colors[2].length() - 1)); - - if(r.contains("%")) - { - r = r.left(r.length() - 1); - r = TQString::number(int((double(255 * r.toDouble()) / 100.0))); - } - - if(g.contains("%")) - { - g = g.left(g.length() - 1); - g = TQString::number(int((double(255 * g.toDouble()) / 100.0))); - } - - if(b.contains("%")) - { - b = b.left(b.length() - 1); - b = TQString::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())); - } -} - -TQRect SVGStylableImpl::clip() -{ - return TQRect(); -} - -void SVGStylableImpl::setClip(const TQString &) -{ -} - -float SVGStylableImpl::fontSizeForText(const TQString &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; - - TQString 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; - - TQStringList substyles = TQStringList::split(';', param); - for(TQStringList::Iterator it = substyles.begin(); it != substyles.end(); ++it) - { - TQStringList substyle = TQStringList::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('\'', TQString()); - // #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; - TQStringList decorations = TQStringList::split(' ', param); - for(TQStringList::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(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(m_object->ownerSVGElement()->getElementById(SVGURIReferenceImpl::getTarget(param))); - if(handle) - SVGImageElementImpl::applyColorProfile(handle, static_cast(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(m_object); - if(inherit) - processStyle(); - - if(shape && shape->item()) - { - if(update > -1) - shape->item()->update(static_cast(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(); -} diff --git a/ksvg/impl/SVGStylableImpl.cpp b/ksvg/impl/SVGStylableImpl.cpp new file mode 100644 index 00000000..4400b236 --- /dev/null +++ b/ksvg/impl/SVGStylableImpl.cpp @@ -0,0 +1,1307 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#include + +#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(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 = TQString(); + } + + // Spec: default "none" + if(~m_flags & SVG_STYLE_FLAG_MARKER_MID) + { + if(parentStyle) + m_midMarker = parentStyle->getMidMarker(); + else + m_midMarker = TQString(); + } + + // Spec: default "none" + if(~m_flags & SVG_STYLE_FLAG_MARKER_END) + { + if(parentStyle) + m_endMarker = parentStyle->getEndMarker(); + else + m_endMarker = TQString(); + } +} + +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; +} + +TQString SVGStylableImpl::extractUrlId(const TQString &url) +{ + TQString 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 TQString &marker) +{ + setStartMarker(marker); + setMidMarker(marker); + setEndMarker(marker); +} + +void SVGStylableImpl::setStartMarker(const TQString &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 = TQString(); +} + +void SVGStylableImpl::setMidMarker(const TQString &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 = TQString(); +} + +void SVGStylableImpl::setEndMarker(const TQString &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 = TQString(); +} + +bool SVGStylableImpl::hasMarkers() const +{ + return !m_startMarker.isEmpty() || !m_midMarker.isEmpty() || !m_endMarker.isEmpty(); +} + +void SVGStylableImpl::setPaint(const TQString ¶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 TQString ¶m, SVGColorImpl *svgColor) +{ + if(param.stripWhiteSpace().startsWith("#")) + { + if(param.contains("icc-color")) + { + TQString first = param.left(7); + TQString last = param.right(param.length() - 8); + + svgColor->setRGBColorICCColor(first, last); + } + else + { + TQColor color; + color.setNamedColor(param.stripWhiteSpace()); + svgColor->setRGBColor(color); + } + } + else if(param.stripWhiteSpace().startsWith("rgb(")) + { + TQString parse = param.stripWhiteSpace(); + TQStringList colors = TQStringList::split(',', parse); + TQString r = colors[0].right((colors[0].length() - 4)); + TQString g = colors[1]; + TQString b = colors[2].left((colors[2].length() - 1)); + + if(r.contains("%")) + { + r = r.left(r.length() - 1); + r = TQString::number(int((double(255 * r.toDouble()) / 100.0))); + } + + if(g.contains("%")) + { + g = g.left(g.length() - 1); + g = TQString::number(int((double(255 * g.toDouble()) / 100.0))); + } + + if(b.contains("%")) + { + b = b.left(b.length() - 1); + b = TQString::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())); + } +} + +TQRect SVGStylableImpl::clip() +{ + return TQRect(); +} + +void SVGStylableImpl::setClip(const TQString &) +{ +} + +float SVGStylableImpl::fontSizeForText(const TQString &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; + + TQString 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; + + TQStringList substyles = TQStringList::split(';', param); + for(TQStringList::Iterator it = substyles.begin(); it != substyles.end(); ++it) + { + TQStringList substyle = TQStringList::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('\'', TQString()); + // #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; + TQStringList decorations = TQStringList::split(' ', param); + for(TQStringList::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(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(m_object->ownerSVGElement()->getElementById(SVGURIReferenceImpl::getTarget(param))); + if(handle) + SVGImageElementImpl::applyColorProfile(handle, static_cast(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(m_object); + if(inherit) + processStyle(); + + if(shape && shape->item()) + { + if(update > -1) + shape->item()->update(static_cast(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(); +} diff --git a/ksvg/impl/SVGStyleElementImpl.cc b/ksvg/impl/SVGStyleElementImpl.cc deleted file mode 100644 index c376cb30..00000000 --- a/ksvg/impl/SVGStyleElementImpl.cc +++ /dev/null @@ -1,133 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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; - } -} diff --git a/ksvg/impl/SVGStyleElementImpl.cpp b/ksvg/impl/SVGStyleElementImpl.cpp new file mode 100644 index 00000000..c376cb30 --- /dev/null +++ b/ksvg/impl/SVGStyleElementImpl.cpp @@ -0,0 +1,133 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#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; + } +} diff --git a/ksvg/impl/SVGSwitchElementImpl.cc b/ksvg/impl/SVGSwitchElementImpl.cc deleted file mode 100644 index d69483f7..00000000 --- a/ksvg/impl/SVGSwitchElementImpl.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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(element); - SVGTestsImpl *tests = dynamic_cast(element); - SVGStylableImpl *style = dynamic_cast(element); - - bool ok = tests ? tests->ok() : true; - - if(element && shape && ok && style->getVisible() && style->getDisplay() && (shape->directRender() || !directRender())) - { - element->createItem(c); - break; - } - } -} diff --git a/ksvg/impl/SVGSwitchElementImpl.cpp b/ksvg/impl/SVGSwitchElementImpl.cpp new file mode 100644 index 00000000..d69483f7 --- /dev/null +++ b/ksvg/impl/SVGSwitchElementImpl.cpp @@ -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. +*/ + +#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(element); + SVGTestsImpl *tests = dynamic_cast(element); + SVGStylableImpl *style = dynamic_cast(element); + + bool ok = tests ? tests->ok() : true; + + if(element && shape && ok && style->getVisible() && style->getDisplay() && (shape->directRender() || !directRender())) + { + element->createItem(c); + break; + } + } +} diff --git a/ksvg/impl/SVGSymbolElementImpl.cc b/ksvg/impl/SVGSymbolElementImpl.cc deleted file mode 100644 index bbbef0b8..00000000 --- a/ksvg/impl/SVGSymbolElementImpl.cc +++ /dev/null @@ -1,104 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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; - } -} diff --git a/ksvg/impl/SVGSymbolElementImpl.cpp b/ksvg/impl/SVGSymbolElementImpl.cpp new file mode 100644 index 00000000..bbbef0b8 --- /dev/null +++ b/ksvg/impl/SVGSymbolElementImpl.cpp @@ -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 + +#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; + } +} diff --git a/ksvg/impl/SVGTRefElementImpl.cc b/ksvg/impl/SVGTRefElementImpl.cc deleted file mode 100644 index 1f352f9b..00000000 --- a/ksvg/impl/SVGTRefElementImpl.cc +++ /dev/null @@ -1,74 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - TQString text; - - TQString 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(target); - - if(textTarget) - text = textTarget->text(); - } - - text = handleText(text); - - if(!text.isEmpty()) - { - DOM::Text impl = static_cast(ownerDoc())->createTextNode(text); - appendChild(impl); - } -} diff --git a/ksvg/impl/SVGTRefElementImpl.cpp b/ksvg/impl/SVGTRefElementImpl.cpp new file mode 100644 index 00000000..1f352f9b --- /dev/null +++ b/ksvg/impl/SVGTRefElementImpl.cpp @@ -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 "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 + TQString text; + + TQString 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(target); + + if(textTarget) + text = textTarget->text(); + } + + text = handleText(text); + + if(!text.isEmpty()) + { + DOM::Text impl = static_cast(ownerDoc())->createTextNode(text); + appendChild(impl); + } +} diff --git a/ksvg/impl/SVGTSpanElementImpl.cc b/ksvg/impl/SVGTSpanElementImpl.cc deleted file mode 100644 index 2cc35d05..00000000 --- a/ksvg/impl/SVGTSpanElementImpl.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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(); -} - -TQString SVGTSpanElementImpl::text() -{ - // Otherwhise some js scripts which require a child, don't work (Niko) - if(!hasChildNodes()) - { - DOM::Text impl = static_cast(ownerDoc())->createTextNode(DOM::DOMString("")); - appendChild(impl); - } - - return textDirectionAwareText(); -} - -void SVGTSpanElementImpl::setAttributes() -{ - SVGTextPositioningElementImpl::setAttributes(); -} diff --git a/ksvg/impl/SVGTSpanElementImpl.cpp b/ksvg/impl/SVGTSpanElementImpl.cpp new file mode 100644 index 00000000..2cc35d05 --- /dev/null +++ b/ksvg/impl/SVGTSpanElementImpl.cpp @@ -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. +*/ + +#include + +#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(); +} + +TQString SVGTSpanElementImpl::text() +{ + // Otherwhise some js scripts which require a child, don't work (Niko) + if(!hasChildNodes()) + { + DOM::Text impl = static_cast(ownerDoc())->createTextNode(DOM::DOMString("")); + appendChild(impl); + } + + return textDirectionAwareText(); +} + +void SVGTSpanElementImpl::setAttributes() +{ + SVGTextPositioningElementImpl::setAttributes(); +} diff --git a/ksvg/impl/SVGTestsImpl.cc b/ksvg/impl/SVGTestsImpl.cc deleted file mode 100644 index 15f8bcc6..00000000 --- a/ksvg/impl/SVGTestsImpl.cc +++ /dev/null @@ -1,176 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 -#include - -#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 TQString &/*value*/) -{ - // FIXME -} - -void SVGTestsImpl::parseRequiredExtensions(const TQString &value) -{ - m_requiredExtensions->appendItem(new SharedString(value)); -} - -void SVGTestsImpl::parseSystemLanguage(const TQString &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++) - { - TQString value = m_systemLanguage->getItem(i)->string(); - if(value.isEmpty() || value != (TDEGlobal::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(); -} diff --git a/ksvg/impl/SVGTestsImpl.cpp b/ksvg/impl/SVGTestsImpl.cpp new file mode 100644 index 00000000..15f8bcc6 --- /dev/null +++ b/ksvg/impl/SVGTestsImpl.cpp @@ -0,0 +1,176 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 +#include + +#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 TQString &/*value*/) +{ + // FIXME +} + +void SVGTestsImpl::parseRequiredExtensions(const TQString &value) +{ + m_requiredExtensions->appendItem(new SharedString(value)); +} + +void SVGTestsImpl::parseSystemLanguage(const TQString &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++) + { + TQString value = m_systemLanguage->getItem(i)->string(); + if(value.isEmpty() || value != (TDEGlobal::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(); +} diff --git a/ksvg/impl/SVGTextContentElementImpl.cc b/ksvg/impl/SVGTextContentElementImpl.cc deleted file mode 100644 index a772672b..00000000 --- a/ksvg/impl/SVGTextContentElementImpl.cc +++ /dev/null @@ -1,283 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 -#include - -#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(); -} - -TQString SVGTextContentElementImpl::textDirectionAwareText() -{ - TQString 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; - TQString temp = textNode.data().string(); - - if(!ltr) - { - TQString 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(this); - - T2P::GlyphLayoutParams *params = new T2P::GlyphLayoutParams(); - params->setTb(style->getTextWritingMode() == TB); - params->setUseBidi(style->getTextUnicodeBidi() == UBNORMAL); - if(!dynamic_cast(m_object)) // not allowed for - 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(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 is illegal")); - break; - case LengthAdjust: - { - TQString 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(exec, "[[svgtextcontentelement.constructor]]"); -} diff --git a/ksvg/impl/SVGTextContentElementImpl.cpp b/ksvg/impl/SVGTextContentElementImpl.cpp new file mode 100644 index 00000000..a772672b --- /dev/null +++ b/ksvg/impl/SVGTextContentElementImpl.cpp @@ -0,0 +1,283 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 +#include + +#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(); +} + +TQString SVGTextContentElementImpl::textDirectionAwareText() +{ + TQString 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; + TQString temp = textNode.data().string(); + + if(!ltr) + { + TQString 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(this); + + T2P::GlyphLayoutParams *params = new T2P::GlyphLayoutParams(); + params->setTb(style->getTextWritingMode() == TB); + params->setUseBidi(style->getTextUnicodeBidi() == UBNORMAL); + if(!dynamic_cast(m_object)) // not allowed for + 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(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 is illegal")); + break; + case LengthAdjust: + { + TQString 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(exec, "[[svgtextcontentelement.constructor]]"); +} diff --git a/ksvg/impl/SVGTextElementImpl.cc b/ksvg/impl/SVGTextElementImpl.cc deleted file mode 100644 index 7617f7de..00000000 --- a/ksvg/impl/SVGTextElementImpl.cc +++ /dev/null @@ -1,122 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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(); -} - -TQString SVGTextElementImpl::text() -{ - // Otherwhise some js scripts which require a child, don't work (Niko) - if(!hasChildNodes()) - { - DOM::Text impl = static_cast(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 - TQRect 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 TQPoint &p, const TQPoint &, SVGMouseEventImpl *mev) -{ - // TODO : pointer-events should be stored here, not in SVGStylableImpl. - SVGStylableImpl *style = dynamic_cast(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(this)); - return true; - } - } - - return false; -} diff --git a/ksvg/impl/SVGTextElementImpl.cpp b/ksvg/impl/SVGTextElementImpl.cpp new file mode 100644 index 00000000..7617f7de --- /dev/null +++ b/ksvg/impl/SVGTextElementImpl.cpp @@ -0,0 +1,122 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#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(); +} + +TQString SVGTextElementImpl::text() +{ + // Otherwhise some js scripts which require a child, don't work (Niko) + if(!hasChildNodes()) + { + DOM::Text impl = static_cast(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 + TQRect 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 TQPoint &p, const TQPoint &, SVGMouseEventImpl *mev) +{ + // TODO : pointer-events should be stored here, not in SVGStylableImpl. + SVGStylableImpl *style = dynamic_cast(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(this)); + return true; + } + } + + return false; +} diff --git a/ksvg/impl/SVGTextPathElementImpl.cc b/ksvg/impl/SVGTextPathElementImpl.cc deleted file mode 100644 index 4a116715..00000000 --- a/ksvg/impl/SVGTextPathElementImpl.cc +++ /dev/null @@ -1,238 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 -#include - -#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; -} - -TQString SVGTextPathElementImpl::text() -{ - // Otherwhise some js scripts which require a child, don't work (Niko) - if(!hasChildNodes()) - { - DOM::Text impl = static_cast(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: - { - TQString param = value.toString(exec).qstring(); - - if(param.endsWith("%")) - { - TQString 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 is illegal")); - break; - } - case Method: - { - TQString 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: - { - TQString 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(exec, "[[svgtextpathelement.constructor]]"); -} diff --git a/ksvg/impl/SVGTextPathElementImpl.cpp b/ksvg/impl/SVGTextPathElementImpl.cpp new file mode 100644 index 00000000..4a116715 --- /dev/null +++ b/ksvg/impl/SVGTextPathElementImpl.cpp @@ -0,0 +1,238 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 +#include + +#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; +} + +TQString SVGTextPathElementImpl::text() +{ + // Otherwhise some js scripts which require a child, don't work (Niko) + if(!hasChildNodes()) + { + DOM::Text impl = static_cast(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: + { + TQString param = value.toString(exec).qstring(); + + if(param.endsWith("%")) + { + TQString 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 is illegal")); + break; + } + case Method: + { + TQString 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: + { + TQString 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(exec, "[[svgtextpathelement.constructor]]"); +} diff --git a/ksvg/impl/SVGTextPositioningElementImpl.cc b/ksvg/impl/SVGTextPositioningElementImpl.cc deleted file mode 100644 index e6b02745..00000000 --- a/ksvg/impl/SVGTextPositioningElementImpl.cc +++ /dev/null @@ -1,196 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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") -} diff --git a/ksvg/impl/SVGTextPositioningElementImpl.cpp b/ksvg/impl/SVGTextPositioningElementImpl.cpp new file mode 100644 index 00000000..e6b02745 --- /dev/null +++ b/ksvg/impl/SVGTextPositioningElementImpl.cpp @@ -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 + +#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") +} diff --git a/ksvg/impl/SVGTimeScheduler.cc b/ksvg/impl/SVGTimeScheduler.cc deleted file mode 100644 index b38eceaa..00000000 --- a/ksvg/impl/SVGTimeScheduler.cc +++ /dev/null @@ -1,232 +0,0 @@ -/* - 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(TQObject *scheduler, unsigned int ms, bool singleShot) -{ - m_ms = ms; - m_singleShot = singleShot; - m_timer = new TQTimer(scheduler); -} - -SVGTimer::~SVGTimer() -{ - delete m_timer; -} - -bool SVGTimer::operator==(const TQTimer *timer) -{ - return (m_timer == timer); -} - -const TQTimer *SVGTimer::qtimer() const -{ - return m_timer; -} - -void SVGTimer::start(TQObject *receiver, const char *member) -{ - TQObject::connect(m_timer, TQT_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; - - TQValueList elements; - for(unsigned int i = m_notifyList.count();i > 0; i--) - { - SVGElementImpl *element = m_notifyList[i - 1]; - if(!element) - continue; - - SVGAnimationElementImpl *animation = dynamic_cast(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) - TQValueList::iterator it2; - for(it2 = elements.begin(); it2 != elements.end(); ++it2) - { - SVGShapeImpl *shape = dynamic_cast(*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) : TQObject(), 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, TQT_SLOT(slotTimerNotify())); - } -} - -void SVGTimeScheduler::toggleAnimations() -{ - if(m_intervalTimer->isActive()) - m_intervalTimer->stop(); - else - m_intervalTimer->start(this, TQT_SLOT(slotTimerNotify())); -} - -bool SVGTimeScheduler::animationsPaused() const -{ - return !m_intervalTimer->isActive(); -} - -void SVGTimeScheduler::slotTimerNotify() -{ - TQTimer *senderTimer = const_cast(static_cast(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. 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, TQT_SLOT(slotTimerNotify())); -} - -float SVGTimeScheduler::elapsed() const -{ - return float(m_creationTime.elapsed()) / 1000.0; -} diff --git a/ksvg/impl/SVGTimeScheduler.cpp b/ksvg/impl/SVGTimeScheduler.cpp new file mode 100644 index 00000000..b38eceaa --- /dev/null +++ b/ksvg/impl/SVGTimeScheduler.cpp @@ -0,0 +1,232 @@ +/* + 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(TQObject *scheduler, unsigned int ms, bool singleShot) +{ + m_ms = ms; + m_singleShot = singleShot; + m_timer = new TQTimer(scheduler); +} + +SVGTimer::~SVGTimer() +{ + delete m_timer; +} + +bool SVGTimer::operator==(const TQTimer *timer) +{ + return (m_timer == timer); +} + +const TQTimer *SVGTimer::qtimer() const +{ + return m_timer; +} + +void SVGTimer::start(TQObject *receiver, const char *member) +{ + TQObject::connect(m_timer, TQT_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; + + TQValueList elements; + for(unsigned int i = m_notifyList.count();i > 0; i--) + { + SVGElementImpl *element = m_notifyList[i - 1]; + if(!element) + continue; + + SVGAnimationElementImpl *animation = dynamic_cast(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) + TQValueList::iterator it2; + for(it2 = elements.begin(); it2 != elements.end(); ++it2) + { + SVGShapeImpl *shape = dynamic_cast(*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) : TQObject(), 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, TQT_SLOT(slotTimerNotify())); + } +} + +void SVGTimeScheduler::toggleAnimations() +{ + if(m_intervalTimer->isActive()) + m_intervalTimer->stop(); + else + m_intervalTimer->start(this, TQT_SLOT(slotTimerNotify())); +} + +bool SVGTimeScheduler::animationsPaused() const +{ + return !m_intervalTimer->isActive(); +} + +void SVGTimeScheduler::slotTimerNotify() +{ + TQTimer *senderTimer = const_cast(static_cast(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. 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, TQT_SLOT(slotTimerNotify())); +} + +float SVGTimeScheduler::elapsed() const +{ + return float(m_creationTime.elapsed()) / 1000.0; +} diff --git a/ksvg/impl/SVGTitleElementImpl.cc b/ksvg/impl/SVGTitleElementImpl.cc deleted file mode 100644 index 838f27fe..00000000 --- a/ksvg/impl/SVGTitleElementImpl.cc +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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()); -} diff --git a/ksvg/impl/SVGTitleElementImpl.cpp b/ksvg/impl/SVGTitleElementImpl.cpp new file mode 100644 index 00000000..838f27fe --- /dev/null +++ b/ksvg/impl/SVGTitleElementImpl.cpp @@ -0,0 +1,37 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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()); +} diff --git a/ksvg/impl/SVGTransformImpl.cc b/ksvg/impl/SVGTransformImpl.cc deleted file mode 100644 index dba50b09..00000000 --- a/ksvg/impl/SVGTransformImpl.cc +++ /dev/null @@ -1,238 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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); -} - -TQString SVGTransformImpl::toString() const -{ - switch (m_type) - { - case SVG_TRANSFORM_UNKNOWN: - return TQString(); - case SVG_TRANSFORM_MATRIX: - return TQString("matrix(" + TQString::number(m_matrix->a()) + " " + TQString::number(m_matrix->b()) + " " + TQString::number(m_matrix->c()) + " " + TQString::number(m_matrix->d()) + " " + TQString::number(m_matrix->e()) + " " + TQString::number(m_matrix->f()) + ")"); - case SVG_TRANSFORM_TRANSLATE: - return TQString("translate(" + TQString::number(m_matrix->e()) + " " + TQString::number(m_matrix->f()) + ")"); - case SVG_TRANSFORM_SCALE: - return TQString("scale(" + TQString::number(m_matrix->a()) + " " + TQString::number(m_matrix->d()) + ")"); - case SVG_TRANSFORM_ROTATE: - return TQString("rotate(" + TQString::number(m_angle) + " " + TQString::number(m_cx) + " " + TQString::number(m_cy) + ")"); - case SVG_TRANSFORM_SKEWX: - return TQString("skewX(" + TQString::number(m_angle) + ")"); - case SVG_TRANSFORM_SKEWY: - return TQString("skewY(" + TQString::number(m_angle) + ")"); - default: - kdWarning() << "Unknown transform type " << m_type << endl; - return TQString(); - } -} - -// 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 *>(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(exec, "[[svgtransform.constructor]]"); -} diff --git a/ksvg/impl/SVGTransformImpl.cpp b/ksvg/impl/SVGTransformImpl.cpp new file mode 100644 index 00000000..dba50b09 --- /dev/null +++ b/ksvg/impl/SVGTransformImpl.cpp @@ -0,0 +1,238 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#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); +} + +TQString SVGTransformImpl::toString() const +{ + switch (m_type) + { + case SVG_TRANSFORM_UNKNOWN: + return TQString(); + case SVG_TRANSFORM_MATRIX: + return TQString("matrix(" + TQString::number(m_matrix->a()) + " " + TQString::number(m_matrix->b()) + " " + TQString::number(m_matrix->c()) + " " + TQString::number(m_matrix->d()) + " " + TQString::number(m_matrix->e()) + " " + TQString::number(m_matrix->f()) + ")"); + case SVG_TRANSFORM_TRANSLATE: + return TQString("translate(" + TQString::number(m_matrix->e()) + " " + TQString::number(m_matrix->f()) + ")"); + case SVG_TRANSFORM_SCALE: + return TQString("scale(" + TQString::number(m_matrix->a()) + " " + TQString::number(m_matrix->d()) + ")"); + case SVG_TRANSFORM_ROTATE: + return TQString("rotate(" + TQString::number(m_angle) + " " + TQString::number(m_cx) + " " + TQString::number(m_cy) + ")"); + case SVG_TRANSFORM_SKEWX: + return TQString("skewX(" + TQString::number(m_angle) + ")"); + case SVG_TRANSFORM_SKEWY: + return TQString("skewY(" + TQString::number(m_angle) + ")"); + default: + kdWarning() << "Unknown transform type " << m_type << endl; + return TQString(); + } +} + +// 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 *>(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(exec, "[[svgtransform.constructor]]"); +} diff --git a/ksvg/impl/SVGTransformListImpl.cc b/ksvg/impl/SVGTransformListImpl.cc deleted file mode 100644 index 18e737b5..00000000 --- a/ksvg/impl/SVGTransformListImpl.cc +++ /dev/null @@ -1,101 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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::getValueProperty(exec, token); -} - -Value SVGTransformListImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) -{ - KSVG_CHECK_THIS(SVGTransformListImpl) - - return obj->call(exec, static_cast *>(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; -} diff --git a/ksvg/impl/SVGTransformListImpl.cpp b/ksvg/impl/SVGTransformListImpl.cpp new file mode 100644 index 00000000..18e737b5 --- /dev/null +++ b/ksvg/impl/SVGTransformListImpl.cpp @@ -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. +*/ + +#include + +#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::getValueProperty(exec, token); +} + +Value SVGTransformListImplProtoFunc::call(ExecState *exec, Object &thisObj, const List &args) +{ + KSVG_CHECK_THIS(SVGTransformListImpl) + + return obj->call(exec, static_cast *>(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; +} diff --git a/ksvg/impl/SVGTransformableImpl.cc b/ksvg/impl/SVGTransformableImpl.cc deleted file mode 100644 index 6d9e4055..00000000 --- a/ksvg/impl/SVGTransformableImpl.cc +++ /dev/null @@ -1,167 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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(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(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; - } -} diff --git a/ksvg/impl/SVGTransformableImpl.cpp b/ksvg/impl/SVGTransformableImpl.cpp new file mode 100644 index 00000000..6d9e4055 --- /dev/null +++ b/ksvg/impl/SVGTransformableImpl.cpp @@ -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 + +#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(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(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; + } +} diff --git a/ksvg/impl/SVGURIReferenceImpl.cc b/ksvg/impl/SVGURIReferenceImpl.cc deleted file mode 100644 index 0d634e13..00000000 --- a/ksvg/impl/SVGURIReferenceImpl.cc +++ /dev/null @@ -1,133 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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 TQString &urireference, TQString &uri, TQString &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 TQString &url) -{ - TQString temp = url.stripWhiteSpace(); - return temp.startsWith("url(#") && temp.endsWith(")"); -} - -TQString SVGURIReferenceImpl::getTarget(const TQString &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; - } -} diff --git a/ksvg/impl/SVGURIReferenceImpl.cpp b/ksvg/impl/SVGURIReferenceImpl.cpp new file mode 100644 index 00000000..0d634e13 --- /dev/null +++ b/ksvg/impl/SVGURIReferenceImpl.cpp @@ -0,0 +1,133 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#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 TQString &urireference, TQString &uri, TQString &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 TQString &url) +{ + TQString temp = url.stripWhiteSpace(); + return temp.startsWith("url(#") && temp.endsWith(")"); +} + +TQString SVGURIReferenceImpl::getTarget(const TQString &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; + } +} diff --git a/ksvg/impl/SVGUseElementImpl.cc b/ksvg/impl/SVGUseElementImpl.cc deleted file mode 100644 index b7f36be5..00000000 --- a/ksvg/impl/SVGUseElementImpl.cc +++ /dev/null @@ -1,407 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#include - -#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: - { - TQString 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(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) - TQString 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(TQString()); - - 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 - SVGElementImpl *parent = 0; - DOM::Element impl = static_cast(ownerDoc())->createElement("g"); - parent = SVGDocumentImpl::createElement("g", impl, ownerDoc()); - SVGElementImpl *clone = orig->cloneNode(true); - - // Apply the use-correction - TQString trans; - trans += " translate("; - trans += TQString::number(x()->baseVal()->value()); - trans += " "; - trans += TQString::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(clone)) - { - DOM::Element impl = static_cast(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(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(parent)->updateCachedScreenCTM(screenCTM()); - - // Redirect local ecma event handlers to the correspondingElement - TQPtrListIterator 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(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(m_instanceRoot->correspondingElement()); - if(shape) - shape->update(reason, param1, param2); - } -} - -void SVGUseElementImpl::invalidate(KSVGCanvas *c, bool recalc) -{ - if(m_instanceRoot) - { - SVGShapeImpl *shape = dynamic_cast(m_instanceRoot->correspondingElement()); - if(shape) - shape->invalidate(c, recalc); - } -} - -void SVGUseElementImpl::setReferenced(bool referenced) -{ - if(m_instanceRoot) - { - SVGShapeImpl *shape = dynamic_cast(m_instanceRoot->correspondingElement()); - if(shape) - shape->setReferenced(referenced); - } -} - -void SVGUseElementImpl::draw() -{ - if(m_instanceRoot) - { - SVGShapeImpl *shape = dynamic_cast(m_instanceRoot->correspondingElement()); - if(shape) - shape->draw(); - } -} diff --git a/ksvg/impl/SVGUseElementImpl.cpp b/ksvg/impl/SVGUseElementImpl.cpp new file mode 100644 index 00000000..b7f36be5 --- /dev/null +++ b/ksvg/impl/SVGUseElementImpl.cpp @@ -0,0 +1,407 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#include + +#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: + { + TQString 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(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) + TQString 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(TQString()); + + 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 + SVGElementImpl *parent = 0; + DOM::Element impl = static_cast(ownerDoc())->createElement("g"); + parent = SVGDocumentImpl::createElement("g", impl, ownerDoc()); + SVGElementImpl *clone = orig->cloneNode(true); + + // Apply the use-correction + TQString trans; + trans += " translate("; + trans += TQString::number(x()->baseVal()->value()); + trans += " "; + trans += TQString::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(clone)) + { + DOM::Element impl = static_cast(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(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(parent)->updateCachedScreenCTM(screenCTM()); + + // Redirect local ecma event handlers to the correspondingElement + TQPtrListIterator 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(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(m_instanceRoot->correspondingElement()); + if(shape) + shape->update(reason, param1, param2); + } +} + +void SVGUseElementImpl::invalidate(KSVGCanvas *c, bool recalc) +{ + if(m_instanceRoot) + { + SVGShapeImpl *shape = dynamic_cast(m_instanceRoot->correspondingElement()); + if(shape) + shape->invalidate(c, recalc); + } +} + +void SVGUseElementImpl::setReferenced(bool referenced) +{ + if(m_instanceRoot) + { + SVGShapeImpl *shape = dynamic_cast(m_instanceRoot->correspondingElement()); + if(shape) + shape->setReferenced(referenced); + } +} + +void SVGUseElementImpl::draw() +{ + if(m_instanceRoot) + { + SVGShapeImpl *shape = dynamic_cast(m_instanceRoot->correspondingElement()); + if(shape) + shape->draw(); + } +} diff --git a/ksvg/impl/SVGVKernElementImpl.cc b/ksvg/impl/SVGVKernElementImpl.cc deleted file mode 100644 index 2f07baee..00000000 --- a/ksvg/impl/SVGVKernElementImpl.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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() -{ -} diff --git a/ksvg/impl/SVGVKernElementImpl.cpp b/ksvg/impl/SVGVKernElementImpl.cpp new file mode 100644 index 00000000..2f07baee --- /dev/null +++ b/ksvg/impl/SVGVKernElementImpl.cpp @@ -0,0 +1,31 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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() +{ +} diff --git a/ksvg/impl/SVGViewElementImpl.cc b/ksvg/impl/SVGViewElementImpl.cc deleted file mode 100644 index 19d56dc5..00000000 --- a/ksvg/impl/SVGViewElementImpl.cc +++ /dev/null @@ -1,92 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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; - } -} diff --git a/ksvg/impl/SVGViewElementImpl.cpp b/ksvg/impl/SVGViewElementImpl.cpp new file mode 100644 index 00000000..19d56dc5 --- /dev/null +++ b/ksvg/impl/SVGViewElementImpl.cpp @@ -0,0 +1,92 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 + +#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; + } +} diff --git a/ksvg/impl/SVGViewSpecImpl.cc b/ksvg/impl/SVGViewSpecImpl.cc deleted file mode 100644 index ff42db43..00000000 --- a/ksvg/impl/SVGViewSpecImpl.cc +++ /dev/null @@ -1,96 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#include - -#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 TQString &s) -{ - if(!s.startsWith("svgView(")) - return false; - - // remove 'svgView(' and ')' - TQStringList subAttrs = TQStringList::split(';', s.mid(8)); - - for(TQStringList::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; -} diff --git a/ksvg/impl/SVGViewSpecImpl.cpp b/ksvg/impl/SVGViewSpecImpl.cpp new file mode 100644 index 00000000..ff42db43 --- /dev/null +++ b/ksvg/impl/SVGViewSpecImpl.cpp @@ -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 + +#include + +#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 TQString &s) +{ + if(!s.startsWith("svgView(")) + return false; + + // remove 'svgView(' and ')' + TQStringList subAttrs = TQStringList::split(';', s.mid(8)); + + for(TQStringList::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; +} diff --git a/ksvg/impl/SVGWindowImpl.cc b/ksvg/impl/SVGWindowImpl.cc deleted file mode 100644 index 5edd4b4e..00000000 --- a/ksvg/impl/SVGWindowImpl.cc +++ /dev/null @@ -1,185 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 -#include - -#include - -#include -#include -#include -#include - -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) -{ - TQString 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\"\?>\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 - TQDictIterator 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 += "tagName().string() + ">\n"; - } - } - return ret; -} - -void SVGWindowImpl::printIndentation(TQString &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 TQString &title) -{ - KMessageBox::error(0L, TQStyleSheet::convertFromPlainText(message.string()), title); -} - -bool SVGWindowImpl::confirm(const DOM::DOMString &message, const TQString &title) -{ - return KMessageBox::warningContinueCancel(0L, TQStyleSheet::convertFromPlainText(message.string()), title, KStdGuiItem::ok()) == KMessageBox::Continue; -} - -DOM::DOMString SVGWindowImpl::prompt(const DOM::DOMString &message, const DOM::DOMString &_default, const TQString &) -{ - bool ok; - TQString str; - str = KInputDialog::getText(i18n("Prompt"), TQStyleSheet::convertFromPlainText(message.string()), _default.string(), &ok); - if(ok) - return str; - else - return ""; -} diff --git a/ksvg/impl/SVGWindowImpl.cpp b/ksvg/impl/SVGWindowImpl.cpp new file mode 100644 index 00000000..5edd4b4e --- /dev/null +++ b/ksvg/impl/SVGWindowImpl.cpp @@ -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 "SVGWindowImpl.h" +#include "SVGDocumentImpl.h" +#include "SVGSVGElementImpl.h" +#include "SVGEvent.h" +#include "KSVGCanvas.h" +#include +#include + +#include + +#include +#include +#include +#include + +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) +{ + TQString 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\"\?>\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 + TQDictIterator 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 += "tagName().string() + ">\n"; + } + } + return ret; +} + +void SVGWindowImpl::printIndentation(TQString &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 TQString &title) +{ + KMessageBox::error(0L, TQStyleSheet::convertFromPlainText(message.string()), title); +} + +bool SVGWindowImpl::confirm(const DOM::DOMString &message, const TQString &title) +{ + return KMessageBox::warningContinueCancel(0L, TQStyleSheet::convertFromPlainText(message.string()), title, KStdGuiItem::ok()) == KMessageBox::Continue; +} + +DOM::DOMString SVGWindowImpl::prompt(const DOM::DOMString &message, const DOM::DOMString &_default, const TQString &) +{ + bool ok; + TQString str; + str = KInputDialog::getText(i18n("Prompt"), TQStyleSheet::convertFromPlainText(message.string()), _default.string(), &ok); + if(ok) + return str; + else + return ""; +} diff --git a/ksvg/impl/SVGZoomAndPanImpl.cc b/ksvg/impl/SVGZoomAndPanImpl.cc deleted file mode 100644 index c632a4dc..00000000 --- a/ksvg/impl/SVGZoomAndPanImpl.cc +++ /dev/null @@ -1,110 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 - -#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(exec, "[[svgzoomandpan.constructor]]"); -} diff --git a/ksvg/impl/SVGZoomAndPanImpl.cpp b/ksvg/impl/SVGZoomAndPanImpl.cpp new file mode 100644 index 00000000..c632a4dc --- /dev/null +++ b/ksvg/impl/SVGZoomAndPanImpl.cpp @@ -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. +*/ + +#include + +#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(exec, "[[svgzoomandpan.constructor]]"); +} diff --git a/ksvg/impl/SVGZoomEventImpl.cc b/ksvg/impl/SVGZoomEventImpl.cc deleted file mode 100644 index 0164779c..00000000 --- a/ksvg/impl/SVGZoomEventImpl.cc +++ /dev/null @@ -1,109 +0,0 @@ -/* - Copyright (C) 2001-2003 KSVG Team - This file is part of the KDE project - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; 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 -#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(); - } -} diff --git a/ksvg/impl/SVGZoomEventImpl.cpp b/ksvg/impl/SVGZoomEventImpl.cpp new file mode 100644 index 00000000..0164779c --- /dev/null +++ b/ksvg/impl/SVGZoomEventImpl.cpp @@ -0,0 +1,109 @@ +/* + Copyright (C) 2001-2003 KSVG Team + This file is part of the KDE project + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; 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 +#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(); + } +} diff --git a/ksvg/impl/libs/libtext2path/src/Cache.h b/ksvg/impl/libs/libtext2path/src/Cache.h index 39536179..6f6ca705 100644 --- a/ksvg/impl/libs/libtext2path/src/Cache.h +++ b/ksvg/impl/libs/libtext2path/src/Cache.h @@ -26,7 +26,7 @@ #include #include -#include "myboost/shared_ptr.hpp" +#include "myboost/shared_ptr.h" namespace T2P { diff --git a/ksvg/impl/libs/libtext2path/src/Converter.cpp b/ksvg/impl/libs/libtext2path/src/Converter.cpp index f8e3d20e..88af02ae 100644 --- a/ksvg/impl/libs/libtext2path/src/Converter.cpp +++ b/ksvg/impl/libs/libtext2path/src/Converter.cpp @@ -22,7 +22,7 @@ #include -#include "myboost/shared_ptr.hpp" +#include "myboost/shared_ptr.h" #include #include diff --git a/ksvg/impl/libs/libtext2path/src/myboost/assert.h b/ksvg/impl/libs/libtext2path/src/myboost/assert.h new file mode 100644 index 00000000..ebedcd32 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/myboost/assert.h @@ -0,0 +1,24 @@ +// +// boost/assert.h - 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_H +#define ASSERT_H + +#undef BOOST_ASSERT + +# include +# define BOOST_ASSERT(expr) assert(expr) + +#endif diff --git a/ksvg/impl/libs/libtext2path/src/myboost/assert.hpp b/ksvg/impl/libs/libtext2path/src/myboost/assert.hpp deleted file mode 100644 index 3f3c61c2..00000000 --- a/ksvg/impl/libs/libtext2path/src/myboost/assert.hpp +++ /dev/null @@ -1,24 +0,0 @@ -// -// 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 -# define BOOST_ASSERT(expr) assert(expr) - -#endif diff --git a/ksvg/impl/libs/libtext2path/src/myboost/checked_delete.h b/ksvg/impl/libs/libtext2path/src/myboost/checked_delete.h new file mode 100644 index 00000000..ba5b534c --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/myboost/checked_delete.h @@ -0,0 +1,61 @@ +#ifndef BOOST_CHECKED_DELETE_H_INCLUDED +#define BOOST_CHECKED_DELETE_H_INCLUDED + +// +// boost/checked_delete.h +// +// 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 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 inline void checked_array_delete(T * x) +{ + typedef char type_must_be_complete[ sizeof(T)? 1: -1 ]; + delete [] x; +} + +template struct checked_deleter +{ + typedef void result_type; + typedef T * argument_type; + + void operator()(T * x) const + { + // boost:: disables ADL + myboost::checked_delete(x); + } +}; + +template 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_H_INCLUDED diff --git a/ksvg/impl/libs/libtext2path/src/myboost/checked_delete.hpp b/ksvg/impl/libs/libtext2path/src/myboost/checked_delete.hpp deleted file mode 100644 index 73afd5f5..00000000 --- a/ksvg/impl/libs/libtext2path/src/myboost/checked_delete.hpp +++ /dev/null @@ -1,61 +0,0 @@ -#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 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 inline void checked_array_delete(T * x) -{ - typedef char type_must_be_complete[ sizeof(T)? 1: -1 ]; - delete [] x; -} - -template struct checked_deleter -{ - typedef void result_type; - typedef T * argument_type; - - void operator()(T * x) const - { - // boost:: disables ADL - myboost::checked_delete(x); - } -}; - -template 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.h b/ksvg/impl/libs/libtext2path/src/myboost/lightweight_mutex.h new file mode 100644 index 00000000..2c09ca8b --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/myboost/lightweight_mutex.h @@ -0,0 +1,74 @@ +#ifndef BOOST_DETAIL_LWM_PTHREADS_H_INCLUDED +#define BOOST_DETAIL_LWM_PTHREADS_H_INCLUDED + +// +// boost/detail/lwm_pthreads.h +// +// 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 + +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_H_INCLUDED diff --git a/ksvg/impl/libs/libtext2path/src/myboost/lightweight_mutex.hpp b/ksvg/impl/libs/libtext2path/src/myboost/lightweight_mutex.hpp deleted file mode 100644 index 10db127c..00000000 --- a/ksvg/impl/libs/libtext2path/src/myboost/lightweight_mutex.hpp +++ /dev/null @@ -1,74 +0,0 @@ -#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 - -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.h b/ksvg/impl/libs/libtext2path/src/myboost/shared_count.h new file mode 100644 index 00000000..b240ff8f --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/myboost/shared_count.h @@ -0,0 +1,367 @@ +#ifndef BOOST_DETAIL_SHARED_COUNT_H_INCLUDED +#define BOOST_DETAIL_SHARED_COUNT_H_INCLUDED + +// +// detail/shared_count.h +// +// 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.h" +#include "myboost/throw_exception.h" +#include "myboost/lightweight_mutex.h" + +#include // std::auto_ptr, std::allocator +#include // std::less +#include // std::exception +#include // std::bad_alloc +#include // std::type_info in get_deleter +#include // 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 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 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().allocate(1, static_cast(0)); + } + + void operator delete(void * p) + { + std::allocator().deallocate(static_cast(p), 1); + } +}; + +class weak_count; + +class shared_count +{ +private: + + sp_counted_base * pi_; + + friend class weak_count; + +public: + + shared_count(): pi_(0) // nothrow + { + } + + template shared_count(P p, D d): pi_(0) + { + + try + { + pi_ = new sp_counted_base_impl(p, d); + } + catch(...) + { + d(p); // delete p + throw; + } + + + pi_ = new sp_counted_base_impl(p, d); + + if(pi_ == 0) + { + d(p); // delete p + myboost::throw_exception(std::bad_alloc()); + } + } + + // auto_ptr is special cased to provide the strong guarantee + + template + explicit shared_count(std::auto_ptr & r): pi_(new sp_counted_base_impl< Y *, checked_deleter >(r.get(), checked_deleter())) + { + 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()(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()(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_H_INCLUDED diff --git a/ksvg/impl/libs/libtext2path/src/myboost/shared_count.hpp b/ksvg/impl/libs/libtext2path/src/myboost/shared_count.hpp deleted file mode 100644 index e8ec19a8..00000000 --- a/ksvg/impl/libs/libtext2path/src/myboost/shared_count.hpp +++ /dev/null @@ -1,367 +0,0 @@ -#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 // std::auto_ptr, std::allocator -#include // std::less -#include // std::exception -#include // std::bad_alloc -#include // std::type_info in get_deleter -#include // 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 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 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().allocate(1, static_cast(0)); - } - - void operator delete(void * p) - { - std::allocator().deallocate(static_cast(p), 1); - } -}; - -class weak_count; - -class shared_count -{ -private: - - sp_counted_base * pi_; - - friend class weak_count; - -public: - - shared_count(): pi_(0) // nothrow - { - } - - template shared_count(P p, D d): pi_(0) - { - - try - { - pi_ = new sp_counted_base_impl(p, d); - } - catch(...) - { - d(p); // delete p - throw; - } - - - pi_ = new sp_counted_base_impl(p, d); - - if(pi_ == 0) - { - d(p); // delete p - myboost::throw_exception(std::bad_alloc()); - } - } - - // auto_ptr is special cased to provide the strong guarantee - - template - explicit shared_count(std::auto_ptr & r): pi_(new sp_counted_base_impl< Y *, checked_deleter >(r.get(), checked_deleter())) - { - 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()(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()(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.h b/ksvg/impl/libs/libtext2path/src/myboost/shared_ptr.h new file mode 100644 index 00000000..435be678 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/myboost/shared_ptr.h @@ -0,0 +1,395 @@ +#ifndef BOOST_SHARED_PTR_H_INCLUDED +#define BOOST_SHARED_PTR_H_INCLUDED + +// shared_ptr.h +// +// (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.h" +#include "myboost/checked_delete.h" +#include "myboost/throw_exception.h" +#include "myboost/shared_count.h" + +#include // for std::auto_ptr +#include // for std::swap +#include // for std::less +#include // for std::bad_cast +#include // for std::basic_ostream + +namespace myboost +{ + +template class weak_ptr; +template class enable_shared_from_this; + +namespace detail +{ + +struct static_cast_tag {}; +struct const_cast_tag {}; +struct dynamic_cast_tag {}; +struct polymorphic_cast_tag {}; + +template struct shared_ptr_traits +{ + typedef T & reference; +}; + +template<> struct shared_ptr_traits +{ + typedef void reference; +}; + +template<> struct shared_ptr_traits +{ + typedef void reference; +}; + +template<> struct shared_ptr_traits +{ + typedef void reference; +}; + +template<> struct shared_ptr_traits +{ + typedef void reference; +}; + +// enable_shared_from_this support + +template void sp_enable_shared_from_this(myboost::enable_shared_from_this * 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 shared_ptr +{ +private: + + // Borland 5.5.1 specific workaround + typedef shared_ptr this_type; + +public: + + typedef T element_type; + typedef T value_type; + typedef T * pointer; + typedef typename detail::shared_ptr_traits::reference reference; + + shared_ptr(): px(0), pn() // never throws in 1.30+ + { + } + + template + explicit shared_ptr(Y * p): px(p), pn(p, checked_deleter()) // 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 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 + explicit shared_ptr(weak_ptr 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 + shared_ptr(shared_ptr const & r): px(r.px), pn(r.pn) // never throws + { + } + + template + shared_ptr(shared_ptr const & r, detail::static_cast_tag): px(static_cast(r.px)), pn(r.pn) + { + } + + template + shared_ptr(shared_ptr const & r, detail::const_cast_tag): px(const_cast(r.px)), pn(r.pn) + { + } + + template + shared_ptr(shared_ptr const & r, detail::dynamic_cast_tag): px(dynamic_cast(r.px)), pn(r.pn) + { + if(px == 0) // need to allocate new counter -- the cast failed + { + pn = detail::shared_count(); + } + } + + template + shared_ptr(shared_ptr const & r, detail::polymorphic_cast_tag): px(dynamic_cast(r.px)), pn(r.pn) + { + if(px == 0) + { + myboost::throw_exception(std::bad_cast()); + } + } + + template + explicit shared_ptr(std::auto_ptr & r): px(r.get()), pn() + { + Y * tmp = r.get(); + pn = detail::shared_count(r); + detail::sp_enable_shared_from_this(tmp, tmp, pn); + } + + template + shared_ptr & operator=(shared_ptr const & r) // never throws + { + px = r.px; + pn = r.pn; // shared_count::op= doesn't throw + return *this; + } + + template + shared_ptr & operator=(std::auto_ptr & r) + { + this_type(r).swap(*this); + return *this; + } + + void reset() // never throws in 1.30+ + { + this_type().swap(*this); + } + + template void reset(Y * p) // Y must be complete + { + BOOST_ASSERT(p == 0 || p != px); // catch self-reset errors + this_type(p).swap(*this); + } + + template 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 & other) // never throws + { + std::swap(px, other.px); + pn.swap(other.pn); + } + + template bool _internal_less(shared_ptr 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 friend class shared_ptr; + template friend class weak_ptr; +#endif + + T * px; // contained pointer + detail::shared_count pn; // reference counter + +}; // shared_ptr + +template inline bool operator==(shared_ptr const & a, shared_ptr const & b) +{ + return a.get() == b.get(); +} + +template inline bool operator!=(shared_ptr const & a, shared_ptr 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 inline bool operator!=(shared_ptr const & a, shared_ptr const & b) +{ + return a.get() != b.get(); +} + +#endif + +template inline bool operator<(shared_ptr const & a, shared_ptr const & b) +{ + return a._internal_less(b); +} + +template inline void swap(shared_ptr & a, shared_ptr & b) +{ + a.swap(b); +} + +template shared_ptr static_pointer_cast(shared_ptr const & r) +{ + return shared_ptr(r, detail::static_cast_tag()); +} + +template shared_ptr const_pointer_cast(shared_ptr const & r) +{ + return shared_ptr(r, detail::const_cast_tag()); +} + +template shared_ptr dynamic_pointer_cast(shared_ptr const & r) +{ + return shared_ptr(r, detail::dynamic_cast_tag()); +} + +// shared_*_cast names are deprecated. Use *_pointer_cast instead. + +template shared_ptr shared_static_cast(shared_ptr const & r) +{ + return shared_ptr(r, detail::static_cast_tag()); +} + +template shared_ptr shared_dynamic_cast(shared_ptr const & r) +{ + return shared_ptr(r, detail::dynamic_cast_tag()); +} + +template shared_ptr shared_polymorphic_cast(shared_ptr const & r) +{ + return shared_ptr(r, detail::polymorphic_cast_tag()); +} + +template shared_ptr shared_polymorphic_downcast(shared_ptr const & r) +{ + BOOST_ASSERT(dynamic_cast(r.get()) == r.get()); + return shared_static_cast(r); +} + +// get_pointer() enables boost::mem_fn to recognize shared_ptr + +template inline T * get_pointer(shared_ptr const & p) +{ + return p.get(); +} + +// operator<< + + +template std::ostream & operator<< (std::ostream & os, shared_ptr 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(void *) +// apparently EDG 2.38 also doesn't accept it + +template D * get_deleter(shared_ptr const & p) +{ + void const * q = p._internal_get_deleter(typeid(D)); + return const_cast(static_cast(q)); +} + +#else + +template D * get_deleter(shared_ptr const & p) +{ + return static_cast(p._internal_get_deleter(typeid(D))); +} + +#endif + +} // namespace boost + + +#endif // #ifndef BOOST_SHARED_PTR_H_INCLUDED diff --git a/ksvg/impl/libs/libtext2path/src/myboost/shared_ptr.hpp b/ksvg/impl/libs/libtext2path/src/myboost/shared_ptr.hpp deleted file mode 100644 index 3f2fe30d..00000000 --- a/ksvg/impl/libs/libtext2path/src/myboost/shared_ptr.hpp +++ /dev/null @@ -1,395 +0,0 @@ -#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 // for std::auto_ptr -#include // for std::swap -#include // for std::less -#include // for std::bad_cast -#include // for std::basic_ostream - -namespace myboost -{ - -template class weak_ptr; -template class enable_shared_from_this; - -namespace detail -{ - -struct static_cast_tag {}; -struct const_cast_tag {}; -struct dynamic_cast_tag {}; -struct polymorphic_cast_tag {}; - -template struct shared_ptr_traits -{ - typedef T & reference; -}; - -template<> struct shared_ptr_traits -{ - typedef void reference; -}; - -template<> struct shared_ptr_traits -{ - typedef void reference; -}; - -template<> struct shared_ptr_traits -{ - typedef void reference; -}; - -template<> struct shared_ptr_traits -{ - typedef void reference; -}; - -// enable_shared_from_this support - -template void sp_enable_shared_from_this(myboost::enable_shared_from_this * 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 shared_ptr -{ -private: - - // Borland 5.5.1 specific workaround - typedef shared_ptr this_type; - -public: - - typedef T element_type; - typedef T value_type; - typedef T * pointer; - typedef typename detail::shared_ptr_traits::reference reference; - - shared_ptr(): px(0), pn() // never throws in 1.30+ - { - } - - template - explicit shared_ptr(Y * p): px(p), pn(p, checked_deleter()) // 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 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 - explicit shared_ptr(weak_ptr 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 - shared_ptr(shared_ptr const & r): px(r.px), pn(r.pn) // never throws - { - } - - template - shared_ptr(shared_ptr const & r, detail::static_cast_tag): px(static_cast(r.px)), pn(r.pn) - { - } - - template - shared_ptr(shared_ptr const & r, detail::const_cast_tag): px(const_cast(r.px)), pn(r.pn) - { - } - - template - shared_ptr(shared_ptr const & r, detail::dynamic_cast_tag): px(dynamic_cast(r.px)), pn(r.pn) - { - if(px == 0) // need to allocate new counter -- the cast failed - { - pn = detail::shared_count(); - } - } - - template - shared_ptr(shared_ptr const & r, detail::polymorphic_cast_tag): px(dynamic_cast(r.px)), pn(r.pn) - { - if(px == 0) - { - myboost::throw_exception(std::bad_cast()); - } - } - - template - explicit shared_ptr(std::auto_ptr & r): px(r.get()), pn() - { - Y * tmp = r.get(); - pn = detail::shared_count(r); - detail::sp_enable_shared_from_this(tmp, tmp, pn); - } - - template - shared_ptr & operator=(shared_ptr const & r) // never throws - { - px = r.px; - pn = r.pn; // shared_count::op= doesn't throw - return *this; - } - - template - shared_ptr & operator=(std::auto_ptr & r) - { - this_type(r).swap(*this); - return *this; - } - - void reset() // never throws in 1.30+ - { - this_type().swap(*this); - } - - template void reset(Y * p) // Y must be complete - { - BOOST_ASSERT(p == 0 || p != px); // catch self-reset errors - this_type(p).swap(*this); - } - - template 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 & other) // never throws - { - std::swap(px, other.px); - pn.swap(other.pn); - } - - template bool _internal_less(shared_ptr 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 friend class shared_ptr; - template friend class weak_ptr; -#endif - - T * px; // contained pointer - detail::shared_count pn; // reference counter - -}; // shared_ptr - -template inline bool operator==(shared_ptr const & a, shared_ptr const & b) -{ - return a.get() == b.get(); -} - -template inline bool operator!=(shared_ptr const & a, shared_ptr 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 inline bool operator!=(shared_ptr const & a, shared_ptr const & b) -{ - return a.get() != b.get(); -} - -#endif - -template inline bool operator<(shared_ptr const & a, shared_ptr const & b) -{ - return a._internal_less(b); -} - -template inline void swap(shared_ptr & a, shared_ptr & b) -{ - a.swap(b); -} - -template shared_ptr static_pointer_cast(shared_ptr const & r) -{ - return shared_ptr(r, detail::static_cast_tag()); -} - -template shared_ptr const_pointer_cast(shared_ptr const & r) -{ - return shared_ptr(r, detail::const_cast_tag()); -} - -template shared_ptr dynamic_pointer_cast(shared_ptr const & r) -{ - return shared_ptr(r, detail::dynamic_cast_tag()); -} - -// shared_*_cast names are deprecated. Use *_pointer_cast instead. - -template shared_ptr shared_static_cast(shared_ptr const & r) -{ - return shared_ptr(r, detail::static_cast_tag()); -} - -template shared_ptr shared_dynamic_cast(shared_ptr const & r) -{ - return shared_ptr(r, detail::dynamic_cast_tag()); -} - -template shared_ptr shared_polymorphic_cast(shared_ptr const & r) -{ - return shared_ptr(r, detail::polymorphic_cast_tag()); -} - -template shared_ptr shared_polymorphic_downcast(shared_ptr const & r) -{ - BOOST_ASSERT(dynamic_cast(r.get()) == r.get()); - return shared_static_cast(r); -} - -// get_pointer() enables boost::mem_fn to recognize shared_ptr - -template inline T * get_pointer(shared_ptr const & p) -{ - return p.get(); -} - -// operator<< - - -template std::ostream & operator<< (std::ostream & os, shared_ptr 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(void *) -// apparently EDG 2.38 also doesn't accept it - -template D * get_deleter(shared_ptr const & p) -{ - void const * q = p._internal_get_deleter(typeid(D)); - return const_cast(static_cast(q)); -} - -#else - -template D * get_deleter(shared_ptr const & p) -{ - return static_cast(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.h b/ksvg/impl/libs/libtext2path/src/myboost/throw_exception.h new file mode 100644 index 00000000..3223b564 --- /dev/null +++ b/ksvg/impl/libs/libtext2path/src/myboost/throw_exception.h @@ -0,0 +1,30 @@ +#ifndef BOOST_THROW_EXCEPTION_H_INCLUDED +#define BOOST_THROW_EXCEPTION_H_INCLUDED + + +// +// boost/throw_exception.h +// +// 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 + +namespace myboost +{ + +template void throw_exception(E const & e) +{ + throw e; +} + +} // namespace myboost + +#endif // #ifndef BOOST_THROW_EXCEPTION_H_INCLUDED diff --git a/ksvg/impl/libs/libtext2path/src/myboost/throw_exception.hpp b/ksvg/impl/libs/libtext2path/src/myboost/throw_exception.hpp deleted file mode 100644 index dd32ec43..00000000 --- a/ksvg/impl/libs/libtext2path/src/myboost/throw_exception.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#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 - -namespace myboost -{ - -template void throw_exception(E const & e) -{ - throw e; -} - -} // namespace myboost - -#endif // #ifndef BOOST_THROW_EXCEPTION_HPP_INCLUDED diff --git a/ksvg/impl/svgpathparser.cc b/ksvg/impl/svgpathparser.cc deleted file mode 100644 index 87a03aca..00000000 --- a/ksvg/impl/svgpathparser.cc +++ /dev/null @@ -1,564 +0,0 @@ -/* 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 -#include - -// 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 TQString &s, bool process ) -{ - if(!s.isEmpty()) - { - TQString 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 == '.' || (*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 tdelibs/tdecore/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.cpp b/ksvg/impl/svgpathparser.cpp new file mode 100644 index 00000000..87a03aca --- /dev/null +++ b/ksvg/impl/svgpathparser.cpp @@ -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 +#include + +// 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 TQString &s, bool process ) +{ + if(!s.isEmpty()) + { + TQString 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 == '.' || (*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 tdelibs/tdecore/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 ) +{ +} -- cgit v1.2.1