|
Krita Source Code Documentation
|
#include <SvgParser.h>
Classes | |
| struct | DeferredUseStore |
Public Types | |
| typedef std::function< QByteArray(const QString &) | FileFetcherFunc) |
Public Member Functions | |
| QString | documentDescription () const |
| QString | documentTitle () const |
| QList< QExplicitlySharedDataPointer< KoMarker > > | knownMarkers () const |
| void | parseDefsElement (const QDomElement &e) |
| QList< KoShape * > | parseSvg (const QDomElement &e, QSizeF *fragmentSize=0) |
| Parses a svg fragment, returning the list of top level child shapes. | |
| KoShape * | parseTextElement (const QDomElement &e, KoSvgTextShape *mergeIntoShape=0) |
| void | setDefaultKraTextVersion (int version) |
| void | setFileFetcher (FileFetcherFunc func) |
| void | setFillStrokeInheritByDefault (const bool enable) |
| void | setResolution (const QRectF boundsInPixels, qreal pixelsPerInch) |
| void | setResolveTextPropertiesForTopLevel (const bool enable) |
| void | setXmlBaseDir (const QString &baseDir) |
| Sets the initial xml base directory (the directory form where the file is read) | |
| QList< KoShape * > | shapes () const |
| Returns the list of all shapes of the svg document. | |
| SvgParser (KoDocumentResourceManager *documentResourceManager) | |
| QVector< KoSvgSymbol * > | takeSymbols () |
| QStringList | warnings () const |
| virtual | ~SvgParser () |
Static Public Member Functions | |
| static QDomDocument | createDocumentFromSvg (const QByteArray &data, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0) |
| static QDomDocument | createDocumentFromSvg (const QString &data, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0) |
| static QDomDocument | createDocumentFromSvg (QIODevice *device, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0) |
| static QDomDocument | createDocumentFromSvg (QXmlStreamReader reader, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0) |
Protected Member Functions | |
| void | addToGroup (QList< KoShape * > shapes, KoShapeContainer *group) |
| Adds list of shapes to the given group shape. | |
| void | applyClipping (KoShape *shape, const QPointF &shapeToOriginalUserCoordinates) |
| Applies the current clip path to the object. | |
| void | applyCurrentBasicStyle (KoShape *shape) |
| void | applyCurrentStyle (KoShape *shape, const QPointF &shapeToOriginalUserCoordinates) |
| void | applyFillStyle (KoShape *shape) |
| Applies the current fill style to the object. | |
| void | applyFilter (KoShape *shape) |
| Applies the current filter to the object. | |
| void | applyId (const QString &id, KoShape *shape) |
| Applies id to specified shape. | |
| void | applyMarkers (KoPathShape *shape) |
| void | applyMaskClipping (KoShape *shape, const QPointF &shapeToOriginalUserCoordinates) |
| void | applyPaintOrder (KoShape *shape) |
| void | applyStrokeStyle (KoShape *shape) |
| Applies the current stroke style to the object. | |
| void | applyStyle (KoShape *, const QDomElement &, const QPointF &shapeToOriginalUserCoordinates) |
| Applies styles to the given shape. | |
| void | applyStyle (KoShape *, const SvgStyles &, const QPointF &shapeToOriginalUserCoordinates) |
| Applies styles to the given shape. | |
| void | applyViewBoxTransform (const QDomElement &element) |
| void | buildDocument (QList< KoShape * > shapes) |
| Builds the document from the given shapes list. | |
| QList< KoShape * > | createListOfShapesFromCSS (const QDomElement e, const QString value, SvgLoadingContext &context) |
| Create a list of shapes from a CSS shapes definition with potentially multiple shapes. | |
| KoShape * | createObject (const QDomElement &, const SvgStyles &style=SvgStyles()) |
| Creates an object from the given xml element. | |
| KoShape * | createObjectDirect (const QDomElement &b) |
| KoShape * | createPath (const QDomElement &) |
| Create path object from the given xml element. | |
| KoShape * | createShape (const QString &shapeID) |
| creates a shape from the given shape id | |
| KoShape * | createShapeFromCSS (const QDomElement e, const QString value, SvgLoadingContext &context) |
| Creates a shape from a CSS shapes definition. | |
| KoShape * | createShapeFromElement (const QDomElement &element, SvgLoadingContext &context) |
| Creates shape from specified svg element. | |
| SvgClipPathHelper * | findClipPath (const QString &id) |
| find clip path with given id in clip path map | |
| SvgFilterHelper * | findFilter (const QString &id, const QString &href=QString()) |
| find filter with given id in filter map | |
| SvgGradientHelper * | findGradient (const QString &id) |
| find gradient with given id in gradient map | |
| QSharedPointer< KoVectorPatternBackground > | findPattern (const QString &id, const KoShape *shape) |
| find pattern with given id in pattern map | |
| KoShape * | getTextPath (const QDomElement &e) |
| Get the path for the gives textPath element. | |
| QDomText | getTheOnlyTextChild (const QDomElement &e) |
| qreal | parseAngular (const QString &unit) |
| parses a angular attribute values, result in radians | |
| bool | parseClipMask (const QDomElement &e) |
| bool | parseClipPath (const QDomElement &) |
| Parses a clip path element. | |
| QList< KoShape * > | parseContainer (const QDomElement &) |
| Parses a container element, returning a list of child shapes. | |
| bool | parseFilter (const QDomElement &, const QDomElement &referencedBy=QDomElement()) |
| Parses a filter element. | |
| SvgGradientHelper * | parseGradient (const QDomElement &) |
| Parses a gradient element. | |
| KoShape * | parseGroup (const QDomElement &e, const QDomElement &overrideChildrenFrom=QDomElement(), bool createContext=true) |
| Parses a group-like element element, saving all its topmost properties. | |
| bool | parseMarker (const QDomElement &e) |
| SvgGradientHelper * | parseMeshGradient (const QDomElement &) |
| Parses mesh gradient element. | |
| QList< QPair< QString, QColor > > | parseMeshPatch (const QDomNode &meshpatch) |
| Parses a single meshpatch and returns the pointer. | |
| void | parseMetadataApplyToShape (const QDomElement &e, KoShape *shape) |
| This parses the SVG native title and desc elements and adds them into additional attributes. | |
| QSharedPointer< KoVectorPatternBackground > | parsePattern (const QDomElement &e, const KoShape *__shape) |
| Parses a pattern element. | |
| QList< KoShape * > | parseSingleElement (const QDomElement &b, DeferredUseStore *deferredUseStore=0) |
| XXX. | |
| bool | parseSymbol (const QDomElement &e) |
| void | parseTextChildren (const QDomElement &e, KoSvgTextLoader &textLoader) |
| parse children of a <text > element into the root shape. | |
| qreal | parseUnit (const QString &, bool horiz=false, bool vert=false, const QRectF &bbox=QRectF()) |
| parses a length attribute | |
| qreal | parseUnitX (const QString &unit) |
| parses a length attribute in x-direction | |
| qreal | parseUnitXY (const QString &unit) |
| parses a length attribute in xy-direction | |
| qreal | parseUnitY (const QString &unit) |
| parses a length attribute in y-direction | |
| KoShape * | parseUse (const QDomElement &, DeferredUseStore *deferredUseStore) |
| Parses a use element, returning a list of child shapes. | |
| KoShape * | resolveUse (const QDomElement &e, const QString &key) |
| void | uploadStyleToContext (const QDomElement &e) |
Private Attributes | |
| QMap< QString, QSharedPointer< KoClipMask > > | m_clipMasks |
| QMap< QString, SvgClipPathHelper > | m_clipPaths |
| SvgLoadingContext | m_context |
| QList< KoShape * > | m_defsShapes |
| QString | m_documentDescription |
| KoDocumentResourceManager * | m_documentResourceManager |
| QString | m_documentTitle |
| QMap< QString, SvgFilterHelper > | m_filters |
| QMap< QString, SvgGradientHelper > | m_gradients |
| bool | m_inheritStrokeFillByDefault = false |
| bool | m_isInsideTextSubtree = false |
| QMap< QString, QExplicitlySharedDataPointer< KoMarker > > | m_markers |
| bool | m_resolveTextPropertiesForTopLevel = true |
| QMap< KoShape *, QTransform > | m_shapeParentTransform |
| QList< KoShape * > | m_shapes |
| QMap< QString, KoSvgSymbol * > | m_symbols |
| QVector< KoID > | m_warnings |
Definition at line 39 of file SvgParser.h.
| typedef std::function<QByteArray(const QString&) SvgParser::FileFetcherFunc) |
Definition at line 82 of file SvgParser.h.
|
explicit |
Definition at line 127 of file SvgParser.cpp.
|
virtual |
Definition at line 133 of file SvgParser.cpp.
References m_defsShapes, and m_symbols.
|
protected |
Adds list of shapes to the given group shape.
Definition at line 1563 of file SvgParser.cpp.
References m_shapes, KoShapeGroupCommand::redo(), and shapes().
|
protected |
Applies the current clip path to the object.
Definition at line 1470 of file SvgParser.cpp.
References KoShape::applyAbsoluteTransformation(), SvgGraphicsContext::clipPathId, SvgClipPathHelper::clipPathUnits(), KoShape::cloneShape(), SvgLoadingContext::currentGC(), findClipPath(), SvgClipPathHelper::isEmpty(), KIS_ASSERT_RECOVER, m_context, KoFlake::ObjectBoundingBox, KoShape::setClipPath(), SvgClipPathHelper::shapes(), shapes(), and KoFlake::UserSpaceOnUse.
WARNING: here is a small inconsistency with the standard: in the standard, 'display' is not inherited, but in flake it is!
NOTE: though the standard says: "A value of 'display:none' indicates that the given element and <em><strong>its children</strong></em> shall not be rendered directly". Therefore, using setVisible(false) is fully legitimate here (DK 29.11.16).
Definition at line 972 of file SvgParser.cpp.
References applyFillStyle(), applyPaintOrder(), applyStrokeStyle(), SvgLoadingContext::currentGC(), SvgGraphicsContext::display, KIS_ASSERT, m_context, SvgGraphicsContext::opacity, KoShape::setTransparency(), KoShape::setVisible(), and SvgGraphicsContext::visible.
|
protected |
Definition at line 956 of file SvgParser.cpp.
References applyClipping(), applyCurrentBasicStyle(), applyFilter(), applyMarkers(), and applyMaskClipping().
Applies the current fill style to the object.
Definition at line 1170 of file SvgParser.cpp.
References SvgGraphicsContext::Complex, SvgLoadingContext::currentGC(), SvgGraphicsContext::fillColor, SvgGraphicsContext::fillId, SvgGraphicsContext::fillRule, SvgGraphicsContext::fillType, findGradient(), findPattern(), SvgGradientHelper::gradient(), SvgGraphicsContext::Inherit, SvgGradientHelper::isMeshGradient(), m_context, SvgGraphicsContext::None, prepareGradientForShape(), prepareMeshGradientForShape(), KoShape::setBackground(), KoPathShape::setFillRule(), KoShape::setInheritBackground(), SvgGraphicsContext::Solid, and toQShared().
Applies the current filter to the object.
Definition at line 1286 of file SvgParser.cpp.
References KoFilterEffectStack::appendFilterEffect(), SvgFilterHelper::content(), KoFilterEffectRegistry::createFilterEffectFromXml(), SvgLoadingContext::currentGC(), debugFlake, KoFilterEffectLoadingContext::enableFilterPrimitiveUnitsConversion(), KoFilterEffectLoadingContext::enableFilterUnitsConversion(), SvgGraphicsContext::filterId, KoFilterEffect::filterRect, SvgFilterHelper::filterUnits(), findFilter(), SvgUtil::fromPercentage(), KoFilterEffect::inputs, KoFilterEffectRegistry::instance(), m_context, KoFilterEffect::output, parseUnitX(), parseUnitY(), KoShape::position(), SvgFilterHelper::position(), SvgFilterHelper::primitiveUnits(), KoFilterEffectStack::setClipRect(), KoShape::setFilterEffectStack(), KoFilterEffect::setFilterRect(), KoFilterEffect::setInput(), KoFilterEffect::setOutput(), KoFilterEffectLoadingContext::setShapeBoundingBox(), KoShape::size(), SvgFilterHelper::size(), KoFlake::UserSpaceOnUse, SvgUtil::userSpaceToObject(), SvgGraphicsContext::viewboxTransform, and SvgLoadingContext::xmlBaseDir().
Applies id to specified shape.
Definition at line 2367 of file SvgParser.cpp.
References debugFlake, m_context, SvgLoadingContext::registerShape(), KoShape::setName(), and SvgLoadingContext::shapeById().
|
protected |
Definition at line 1414 of file SvgParser.cpp.
References SvgGraphicsContext::autoFillMarkers, SvgLoadingContext::currentGC(), KoFlake::EndMarker, m_context, m_markers, SvgGraphicsContext::markerEndId, SvgGraphicsContext::markerMidId, SvgGraphicsContext::markerStartId, KoFlake::MidMarker, KoPathShape::setAutoFillMarkers(), KoPathShape::setMarker(), and KoFlake::StartMarker.
|
protected |
Definition at line 1508 of file SvgParser.cpp.
References SvgGraphicsContext::clipMaskId, SvgLoadingContext::currentGC(), m_clipMasks, m_context, KoShape::setClipMask(), and KoClipMask::setExtraShapeOffset().
Definition at line 1435 of file SvgParser.cpp.
References SvgLoadingContext::currentGC(), KoShape::defaultPaintOrder(), KoShape::Fill, m_context, KoShape::Markers, p, SvgGraphicsContext::paintOrder, KoShape::setPaintOrder(), and KoShape::Stroke.
Applies the current stroke style to the object.
Definition at line 1243 of file SvgParser.cpp.
References applyDashes(), SvgGraphicsContext::Complex, SvgLoadingContext::currentGC(), findGradient(), SvgGraphicsContext::Inherit, m_context, SvgGraphicsContext::None, prepareGradientForShape(), KoShape::setInheritStroke(), KoShape::setStroke(), SvgGraphicsContext::Solid, SvgGraphicsContext::stroke, SvgGraphicsContext::strokeId, and SvgGraphicsContext::strokeType.
|
protected |
Applies styles to the given shape.
Definition at line 1003 of file SvgParser.cpp.
References applyStyle(), SvgStyleParser::collectStyles(), m_context, and SvgLoadingContext::styleParser.
|
protected |
Applies styles to the given shape.
Definition at line 1008 of file SvgParser.cpp.
References applyClipping(), applyFillStyle(), applyFilter(), applyMarkers(), applyMaskClipping(), applyPaintOrder(), applyStrokeStyle(), SvgLoadingContext::currentGC(), SvgGraphicsContext::display, m_context, m_inheritStrokeFillByDefault, SvgGraphicsContext::opacity, SvgStyleParser::parseStyle(), KoShape::setTransparency(), KoShape::setVisible(), SvgLoadingContext::styleParser, and SvgGraphicsContext::visible.
|
protected |
Applies viewBox transformation to the current graphical context NOTE: after applying the function currentBoundingBox can become null!
Definition at line 1674 of file SvgParser.cpp.
References SvgGraphicsContext::currentBoundingBox, SvgLoadingContext::currentGC(), m_context, SvgGraphicsContext::matrix, and SvgUtil::parseViewBox().
Builds the document from the given shapes list.
|
static |
Definition at line 146 of file SvgParser.cpp.
References createDocumentFromSvg().
|
static |
|
static |
|
static |
Definition at line 156 of file SvgParser.cpp.
|
protected |
Create a list of shapes from a CSS shapes definition with potentially multiple shapes.
Definition at line 2321 of file SvgParser.cpp.
References createShapeFromCSS(), and value().
|
protected |
Creates an object from the given xml element.
Definition at line 2176 of file SvgParser.cpp.
References KoShape::applyAbsoluteTransformation(), applyId(), applyStyle(), SvgStyleParser::collectStyles(), createShapeFromElement(), SvgLoadingContext::currentGC(), extraShapeOffset(), m_context, m_shapeParentTransform, SvgGraphicsContext::matrix, SvgLoadingContext::nextZIndex(), SvgStyleParser::parseFont(), parseMetadataApplyToShape(), SvgLoadingContext::popGraphicsContext(), SvgLoadingContext::pushGraphicsContext(), KoShape::setZIndex(), and SvgLoadingContext::styleParser.
|
protected |
Definition at line 2150 of file SvgParser.cpp.
References KoShape::applyAbsoluteTransformation(), applyCurrentStyle(), applyId(), createShapeFromElement(), SvgLoadingContext::currentGC(), extraShapeOffset(), m_context, m_shapeParentTransform, SvgGraphicsContext::matrix, SvgLoadingContext::nextZIndex(), parseMetadataApplyToShape(), SvgLoadingContext::popGraphicsContext(), SvgLoadingContext::pushGraphicsContext(), KoShape::setZIndex(), and uploadStyleToContext().
|
protected |
Create path object from the given xml element.
Definition at line 2080 of file SvgParser.cpp.
References KoPathShape::clear(), createShape(), SvgUtil::fromUserSpace(), KoPathShapeId, KoPathShapeLoader::parseSvg(), parseUnitX(), parseUnitY(), SvgUtil::simplifyList(), and KisDomUtils::toDouble().
|
protected |
creates a shape from the given shape id
Definition at line 2337 of file SvgParser.cpp.
References KoShapeFactoryBase::createDefaultShape(), debugFlake, KoGenericRegistry< T >::get(), KoShapeFactoryBase::id, KoShapeRegistry::instance(), m_documentResourceManager, KoShape::setBackground(), KoShape::setShapeId(), KoShape::setStroke(), KoShape::setTransformation(), and KoShape::shapeId().
|
protected |
Creates a shape from a CSS shapes definition.
Definition at line 2249 of file SvgParser.cpp.
References KoShape::absoluteTransformation(), KoShape::cloneShape(), createShapeFromElement(), SvgLoadingContext::currentGC(), m_context, m_shapeParentTransform, SvgUtil::parseUnitX(), SvgUtil::parseUnitXY(), SvgUtil::parseUnitY(), SvgLoadingContext::resolvedProperties(), KoShape::setTransformation(), SvgLoadingContext::shapeById(), SvgUtil::simplifyList(), KoShape::size(), and value().
|
protected |
Creates shape from specified svg element.
Definition at line 2204 of file SvgParser.cpp.
References createPath(), KoShapeRegistry::factoriesForElement(), KoShapeRegistry::instance(), SvgShape::loadSvg(), m_documentResourceManager, SvgUtil::mapExtendedShapeTag(), KoShape::setBackground(), KoShape::setStroke(), KoShape::setTransformation(), KoShape::stroke(), and KoXmlNS::svg.
| QString SvgParser::documentDescription | ( | ) | const |
| QString SvgParser::documentTitle | ( | ) | const |
|
protected |
find clip path with given id in clip path map
Definition at line 305 of file SvgParser.cpp.
References m_clipPaths.
|
protected |
find filter with given id in filter map
Definition at line 268 of file SvgParser.cpp.
References SvgLoadingContext::definition(), findFilter(), SvgLoadingContext::hasDefinition(), m_context, m_filters, and parseFilter().
|
protected |
find gradient with given id in gradient map
Definition at line 231 of file SvgParser.cpp.
References SvgLoadingContext::definition(), SvgLoadingContext::hasDefinition(), m_context, m_gradients, parseGradient(), and parseMeshGradient().
|
protected |
find pattern with given id in pattern map
Definition at line 253 of file SvgParser.cpp.
References SvgLoadingContext::definition(), SvgLoadingContext::hasDefinition(), m_context, and parsePattern().
|
protected |
Get the path for the gives textPath element.
Definition at line 1782 of file SvgParser.cpp.
References KoShape::absoluteTransformation(), KoShape::cloneShape(), createPath(), m_context, m_shapeParentTransform, p, KoShape::setTransformation(), and SvgLoadingContext::shapeById().
|
protected |
Definition at line 1775 of file SvgParser.cpp.
Definition at line 1700 of file SvgParser.cpp.
References m_markers.
|
protected |
parses a angular attribute values, result in radians
Definition at line 333 of file SvgParser.cpp.
References SvgLoadingContext::currentGC(), m_context, and SvgUtil::parseUnitAngular().
|
protected |
Definition at line 904 of file SvgParser.cpp.
References KoFlake::coordinatesFromString(), SvgLoadingContext::currentGC(), SvgUtil::fromPercentage(), m_clipMasks, m_context, SvgGraphicsContext::matrix, KoFlake::ObjectBoundingBox, parseGroup(), parseUnitX(), parseUnitY(), SvgLoadingContext::popGraphicsContext(), SvgLoadingContext::pushGraphicsContext(), KoFlake::UserSpaceOnUse, and SvgGraphicsContext::workaroundClearInheritedFillProperties().
|
protected |
Parses a clip path element.
Definition at line 877 of file SvgParser.cpp.
References KoFlake::coordinatesFromString(), SvgLoadingContext::currentGC(), m_clipPaths, m_context, SvgGraphicsContext::matrix, parseGroup(), SvgLoadingContext::popGraphicsContext(), SvgLoadingContext::pushGraphicsContext(), SvgClipPathHelper::setClipPathUnits(), SvgClipPathHelper::setShapes(), KoFlake::UserSpaceOnUse, and SvgGraphicsContext::workaroundClearInheritedFillProperties().
Parses a container element, returning a list of child shapes.
Definition at line 1944 of file SvgParser.cpp.
References parseSingleElement(), and shapes().
| void SvgParser::parseDefsElement | ( | const QDomElement & | e | ) |
Definition at line 1985 of file SvgParser.cpp.
References KIS_SAFE_ASSERT_RECOVER_RETURN, and parseSingleElement().
|
protected |
Parses a filter element.
Definition at line 724 of file SvgParser.cpp.
References SvgFilterHelper::filterUnits(), findFilter(), SvgUtil::fromPercentage(), m_filters, KoFlake::ObjectBoundingBox, parseUnitX(), parseUnitY(), SvgFilterHelper::setContent(), SvgFilterHelper::setFilterUnits(), SvgFilterHelper::setPosition(), SvgFilterHelper::setPrimitiveUnits(), SvgFilterHelper::setSize(), and KoFlake::UserSpaceOnUse.
|
protected |
Parses a gradient element.
Definition at line 339 of file SvgParser.cpp.
References SvgLoadingContext::currentGC(), debugFlake, findGradient(), SvgUtil::fromPercentage(), SvgGradientHelper::gradient(), SvgGradientHelper::gradientUnits(), m_context, m_gradients, KoFlake::ObjectBoundingBox, p, SvgStyleParser::parseColorStops(), parseUnitX(), parseUnitXY(), parseUnitY(), SvgLoadingContext::popGraphicsContext(), SvgLoadingContext::pushGraphicsContext(), SvgGradientHelper::setGradient(), SvgGradientHelper::setGradientUnits(), SvgGradientHelper::setSpreadMode(), SvgGradientHelper::setTransform(), SvgLoadingContext::styleParser, uploadStyleToContext(), and KoFlake::UserSpaceOnUse.
|
protected |
Parses a group-like element element, saving all its topmost properties.
Definition at line 1730 of file SvgParser.cpp.
References addToGroup(), KoShape::applyAbsoluteTransformation(), applyCurrentStyle(), applyId(), SvgLoadingContext::currentGC(), extraShapeOffset(), m_context, SvgGraphicsContext::matrix, SvgLoadingContext::nextZIndex(), parseContainer(), parseGroup(), parseMetadataApplyToShape(), parseSingleElement(), SvgLoadingContext::popGraphicsContext(), SvgLoadingContext::pushGraphicsContext(), KoShape::setZIndex(), and uploadStyleToContext().
|
protected |
Definition at line 773 of file SvgParser.cpp.
References KoMarker::coordinateSystemFromString(), SvgGraphicsContext::currentBoundingBox, SvgLoadingContext::currentGC(), m_context, m_markers, SvgGraphicsContext::matrix, parseAngular(), parseGroup(), parseUnitX(), parseUnitY(), SvgLoadingContext::popGraphicsContext(), and SvgLoadingContext::pushGraphicsContext().
|
protected |
Parses mesh gradient element.
Definition at line 450 of file SvgParser.cpp.
References SvgMeshGradient::BICUBIC, SvgMeshGradient::BILINEAR, SvgMeshPatch::Bottom, SvgMeshStop::color, debugFlake, findGradient(), m_gradients, p, parseMeshPatch(), parseUnitX(), parseUnitY(), SvgMeshStop::point, SvgMeshPatch::Right, SvgGradientHelper::setGradientUnits(), SvgGradientHelper::setMeshGradient(), SvgGradientHelper::setTransform(), and KoFlake::UserSpaceOnUse.
|
protected |
Parses a single meshpatch and returns the pointer.
Definition at line 541 of file SvgParser.cpp.
References SvgLoadingContext::currentGC(), forEachElement, m_context, SvgStyleParser::parseColorStop(), and SvgLoadingContext::styleParser.
This parses the SVG native title and desc elements and adds them into additional attributes.
Definition at line 857 of file SvgParser.cpp.
References getTheOnlyTextChild(), and KoShape::setAdditionalAttribute().
|
protected |
Parses a pattern element.
Unlike the gradient parsing function, this method is called every time we reference the pattern, not when we define it. Therefore we can already use the coordinate system of the destination.
In Krita shapes X,Y coordinates are baked into the shape global transform, but the pattern should be painted in "user" coordinates. Therefore, we should handle this offset separately.
TODO: Please also note that this offset is different from extraShapeOffset(), because A.inverted() * B != A * B.inverted(). I'm not sure which variant is correct (DK)
Definition at line 576 of file SvgParser.cpp.
References KoShape::absoluteTransformation(), KoShape::applyAbsoluteTransformation(), applyViewBoxTransform(), bakeShapeOffset(), KoFlake::coordinatesFromString(), SvgGraphicsContext::currentBoundingBox, SvgLoadingContext::currentGC(), extraShapeOffset(), findPattern(), SvgUtil::fromPercentage(), KIS_SAFE_ASSERT_RECOVER_NOOP, m_context, SvgGraphicsContext::matrix, KoFlake::ObjectBoundingBox, KoShape::outline(), p, parseContainer(), parseUnitX(), parseUnitY(), SvgLoadingContext::popGraphicsContext(), SvgLoadingContext::pushGraphicsContext(), toQShared(), KoFlake::UserSpaceOnUse, and SvgGraphicsContext::workaroundClearInheritedFillProperties().
|
protected |
XXX.
WARNING: 'defs' are basically 'display:none' style, therefore they should not play any role in shapes outline calculation. But setVisible(false) shapes do! Should be fixed in the future!
Definition at line 1991 of file SvgParser.cpp.
References SvgLoadingContext::addDefinition(), SvgLoadingContext::addStyleSheet(), KoShape::boundingRect(), SvgParser::DeferredUseStore::checkPendingUse(), createObject(), createObjectDirect(), debugFlake, m_context, m_defsShapes, KoShape::outline(), KoShape::outlineRect(), parseClipMask(), parseClipPath(), parseContainer(), parseFilter(), parseGroup(), parseMarker(), SvgLoadingContext::parseProfile(), parseSvg(), parseSymbol(), parseTextElement(), parseUse(), SvgLoadingContext::popGraphicsContext(), ppVar, SvgLoadingContext::pushGraphicsContext(), KisPortingUtils::setUtf8OnStream(), KoShape::setVisible(), KoShape::shapeId(), and shapes().
Parses a svg fragment, returning the list of top level child shapes.
In internal SVG coordinate systems pixels are linked to absolute values with a fixed ratio.
See CSS specification: https://www.w3.org/TR/css-values-3/#absolute-lengths
Definition at line 1575 of file SvgParser.cpp.
References applyStyle(), applyViewBoxTransform(), SvgGraphicsContext::currentBoundingBox, SvgLoadingContext::isRootContext(), m_context, m_documentDescription, m_documentTitle, SvgGraphicsContext::matrix, parseContainer(), parseUnit(), parseUnitX(), parseUnitY(), SvgUtil::parseViewBox(), SvgGraphicsContext::pixelsPerInch, SvgLoadingContext::popGraphicsContext(), SvgLoadingContext::pushGraphicsContext(), and shapes().
|
protected |
Definition at line 814 of file SvgParser.cpp.
References SvgGraphicsContext::currentBoundingBox, SvgLoadingContext::currentGC(), debugFlake, m_context, m_symbols, SvgGraphicsContext::matrix, parseGroup(), SvgLoadingContext::popGraphicsContext(), and SvgLoadingContext::pushGraphicsContext().
|
protected |
parse children of a <text > element into the root shape.
TODO: we should skip dublin core metadata too...
Definition at line 1808 of file SvgParser.cpp.
References applyCurrentBasicStyle(), KoSvgTextLoader::enterNodeSubtree(), getTextPath(), getTheOnlyTextChild(), KoSvgTextLoader::leaveNodeSubtree(), KoSvgTextLoader::loadSvg(), KoSvgTextLoader::loadSvgText(), m_context, KoSvgTextLoader::nextNode(), parseTextChildren(), SvgLoadingContext::popGraphicsContext(), SvgLoadingContext::pushGraphicsContext(), KoSvgTextLoader::setStyleInfo(), KoSvgTextLoader::setTextPathOnCurrentNode(), and uploadStyleToContext().
| KoShape * SvgParser::parseTextElement | ( | const QDomElement & | e, |
| KoSvgTextShape * | mergeIntoShape = 0 ) |
Definition at line 1841 of file SvgParser.cpp.
References KoShape::absoluteTransformation(), KoShape::applyAbsoluteTransformation(), applyCurrentBasicStyle(), applyCurrentStyle(), applyId(), KoShapeFactoryBase::createDefaultShape(), createListOfShapesFromCSS(), SvgLoadingContext::currentGC(), debugFlake, extraShapeOffset(), getTheOnlyTextChild(), KoSvgTextProperties::hasProperty(), KoShapeRegistry::instance(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, KoSvgTextProperties::KraTextVersionId, KoSvgTextLoader::loadSvg(), KoSvgTextLoader::loadSvgText(), m_context, m_documentResourceManager, m_isInsideTextSubtree, m_resolveTextPropertiesForTopLevel, m_warnings, SvgGraphicsContext::matrix, SvgLoadingContext::nextZIndex(), parseMetadataApplyToShape(), parseTextChildren(), SvgLoadingContext::popGraphicsContext(), KoSvgTextProperties::property(), SvgLoadingContext::pushGraphicsContext(), KoSvgTextShape::relayout(), KoSvgTextProperties::setProperty(), KoSvgTextShape::setShapesInside(), KoSvgTextShape::setShapesSubtract(), KoShape::setZIndex(), SvgGraphicsContext::shapeInsideValue, SvgGraphicsContext::shapeSubtractValue, SvgGraphicsContext::textProperties, uploadStyleToContext(), and KoGenericRegistry< T >::value().
|
protected |
parses a length attribute
Definition at line 313 of file SvgParser.cpp.
References SvgLoadingContext::currentGC(), m_context, SvgUtil::parseUnit(), and SvgLoadingContext::resolvedProperties().
|
protected |
parses a length attribute in x-direction
Definition at line 318 of file SvgParser.cpp.
References SvgLoadingContext::currentGC(), m_context, SvgUtil::parseUnitX(), and SvgLoadingContext::resolvedProperties().
|
protected |
parses a length attribute in xy-direction
Definition at line 328 of file SvgParser.cpp.
References SvgLoadingContext::currentGC(), m_context, SvgUtil::parseUnitXY(), and SvgLoadingContext::resolvedProperties().
|
protected |
parses a length attribute in y-direction
Definition at line 323 of file SvgParser.cpp.
References SvgLoadingContext::currentGC(), m_context, SvgUtil::parseUnitY(), and SvgLoadingContext::resolvedProperties().
|
protected |
Parses a use element, returning a list of child shapes.
Definition at line 1528 of file SvgParser.cpp.
References SvgParser::DeferredUseStore::add(), debugFlake, SvgLoadingContext::hasDefinition(), m_context, and resolveUse().
|
protected |
Definition at line 1547 of file SvgParser.cpp.
References SvgLoadingContext::definition(), m_context, SvgGraphicsContext::matrix, parseGroup(), parseUnitX(), parseUnitY(), SvgLoadingContext::popGraphicsContext(), and SvgLoadingContext::pushGraphicsContext().
| void SvgParser::setDefaultKraTextVersion | ( | int | version | ) |
Definition at line 200 of file SvgParser.cpp.
References SvgLoadingContext::currentGC(), KIS_SAFE_ASSERT_RECOVER_RETURN, KoSvgTextProperties::KraTextVersionId, m_context, KoSvgTextProperties::setProperty(), and SvgGraphicsContext::textProperties.
| void SvgParser::setFileFetcher | ( | SvgParser::FileFetcherFunc | func | ) |
Definition at line 1715 of file SvgParser.cpp.
References m_context, and SvgLoadingContext::setFileFetcher().
| void SvgParser::setFillStrokeInheritByDefault | ( | const bool | enable | ) |
Definition at line 206 of file SvgParser.cpp.
References m_inheritStrokeFillByDefault.
| void SvgParser::setResolution | ( | const QRectF | boundsInPixels, |
| qreal | pixelsPerInch ) |
Definition at line 187 of file SvgParser.cpp.
References SvgGraphicsContext::currentBoundingBox, SvgLoadingContext::currentGC(), SvgGraphicsContext::isResolutionFrame, KIS_ASSERT, m_context, SvgGraphicsContext::matrix, SvgGraphicsContext::pixelsPerInch, and SvgLoadingContext::pushGraphicsContext().
| void SvgParser::setResolveTextPropertiesForTopLevel | ( | const bool | enable | ) |
Definition at line 211 of file SvgParser.cpp.
References m_resolveTextPropertiesForTopLevel.
| void SvgParser::setXmlBaseDir | ( | const QString & | baseDir | ) |
Sets the initial xml base directory (the directory form where the file is read)
Definition at line 167 of file SvgParser.cpp.
References m_context, setFileFetcher(), SvgLoadingContext::setInitialXmlBaseDir(), and SvgLoadingContext::xmlBaseDir().
Returns the list of all shapes of the svg document.
Definition at line 216 of file SvgParser.cpp.
References m_shapes.
| QVector< KoSvgSymbol * > SvgParser::takeSymbols | ( | ) |
Takes the collection of symbols contained in the svg document. The parser will no longer know about the symbols.
Definition at line 221 of file SvgParser.cpp.
References m_symbols.
|
protected |
Definition at line 949 of file SvgParser.cpp.
References SvgStyleParser::collectStyles(), m_context, m_inheritStrokeFillByDefault, SvgStyleParser::parseFont(), SvgStyleParser::parseStyle(), and SvgLoadingContext::styleParser.
| QStringList SvgParser::warnings | ( | ) | const |
Definition at line 1689 of file SvgParser.cpp.
References m_warnings, and warnings().
|
private |
Definition at line 233 of file SvgParser.h.
|
private |
Definition at line 232 of file SvgParser.h.
|
private |
Definition at line 229 of file SvgParser.h.
Definition at line 238 of file SvgParser.h.
|
private |
Definition at line 241 of file SvgParser.h.
|
private |
Definition at line 235 of file SvgParser.h.
|
private |
Definition at line 240 of file SvgParser.h.
|
private |
Definition at line 231 of file SvgParser.h.
|
private |
Definition at line 230 of file SvgParser.h.
|
private |
Definition at line 244 of file SvgParser.h.
|
private |
Definition at line 239 of file SvgParser.h.
|
private |
Definition at line 234 of file SvgParser.h.
|
private |
Definition at line 245 of file SvgParser.h.
|
private |
Definition at line 243 of file SvgParser.h.
Definition at line 236 of file SvgParser.h.
|
private |
Definition at line 237 of file SvgParser.h.
Definition at line 242 of file SvgParser.h.