File indexing completed on 2024-05-26 04:26:22
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2003, 2005 Rob Buis <buis@kde.org> 0003 * SPDX-FileCopyrightText: 2007, 2009 Jan Hambrecht <jaham@gmx.net> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #include "SvgGraphicContext.h" 0009 0010 #include "kis_pointer_utils.h" 0011 0012 0013 SvgGraphicsContext::SvgGraphicsContext() 0014 : stroke(toQShared(new KoShapeStroke())) 0015 , textProperties(KoSvgTextProperties::defaultProperties()) 0016 { 0017 stroke->setLineStyle(Qt::NoPen, QVector<qreal>()); // default is no stroke 0018 stroke->setLineWidth(1.0); 0019 stroke->setCapStyle(Qt::FlatCap); 0020 stroke->setJoinStyle(Qt::MiterJoin); 0021 } 0022 0023 SvgGraphicsContext::SvgGraphicsContext(const SvgGraphicsContext &gc) 0024 : stroke(toQShared(new KoShapeStroke(*(gc.stroke.data())))) 0025 { 0026 KoShapeStrokeSP newStroke = stroke; 0027 *this = gc; 0028 this->stroke = newStroke; 0029 } 0030 0031 void SvgGraphicsContext::workaroundClearInheritedFillProperties() 0032 { 0033 /** 0034 * HACK ALERT: according to SVG patterns, clip paths and clip masks 0035 * must not inherit any properties from the referencing element. 0036 * We still don't support it, therefore we reset only fill/stroke 0037 * properties to avoid cyclic fill inheritance, which may cause 0038 * infinite recursion. 0039 */ 0040 0041 0042 strokeType = None; 0043 0044 stroke = toQShared(new KoShapeStroke()); 0045 stroke->setLineStyle(Qt::NoPen, QVector<qreal>()); // default is no stroke 0046 stroke->setLineWidth(1.0); 0047 stroke->setCapStyle(Qt::FlatCap); 0048 stroke->setJoinStyle(Qt::MiterJoin); 0049 0050 fillType = Solid; 0051 fillRule = Qt::WindingFill; 0052 fillColor = QColor(Qt::black); // default is black fill as per svg spec 0053 0054 opacity = 1.0; 0055 0056 currentColor = Qt::black; 0057 }