Krita Source Code Documentation
Loading...
Searching...
No Matches
KoSvgTextLoader Class Reference

#include <KoSvgTextLoader.h>

Classes

struct  Private
 

Public Member Functions

void enterNodeSubtree ()
 Set the current node to its first child, entering the subtree.
 
 KoSvgTextLoader (KoSvgTextShape *shape)
 
void leaveNodeSubtree ()
 Set the current node to its parent, leaving the subtree.
 
bool loadSvg (const QDomElement &element, SvgLoadingContext &context, bool root=false)
 Create a new text node.
 
bool loadSvgText (const QDomText &text, SvgLoadingContext &context)
 Loads the textt into the current node.
 
void nextNode ()
 Switch to next node.
 
void setStyleInfo (KoShape *s)
 Set the style info from the shape. This is necessary because SVGParser only understands loading the basic style into a KoShape.
 
void setTextPathOnCurrentNode (KoShape *s)
 Set the textPath on the current node.
 
 ~KoSvgTextLoader ()
 

Private Attributes

QScopedPointer< Privated
 

Detailed Description

Loading an SVG text is somewhat intricate, so we use a KoSvgTextLoader to keep track of where we are in the tree.

Definition at line 15 of file KoSvgTextLoader.h.

Constructor & Destructor Documentation

◆ KoSvgTextLoader()

KoSvgTextLoader::KoSvgTextLoader ( KoSvgTextShape * shape)

Definition at line 25 of file KoSvgTextLoader.cpp.

26 : d(new Private(shape))
27{
28
29}
QScopedPointer< Private > d

◆ ~KoSvgTextLoader()

KoSvgTextLoader::~KoSvgTextLoader ( )

Definition at line 31 of file KoSvgTextLoader.cpp.

32{
33 // run clean-up after parsing to remove empty spans and the like.
34 d->shape->cleanUp();
35 d->shape->d->isLoading = false;
36}

References d.

Member Function Documentation

◆ enterNodeSubtree()

void KoSvgTextLoader::enterNodeSubtree ( )

Set the current node to its first child, entering the subtree.

Definition at line 38 of file KoSvgTextLoader.cpp.

39{
40 if (KisForestDetail::isEnd(d->currentNode)) {
41 nextNode();
42 }
43 d->currentNode = childEnd(d->currentNode);
44}
void nextNode()
Switch to next node.
bool isEnd(const ChildIterator< T, is_const > &it)
Definition KisForest.h:341
ChildIterator< value_type, is_const > childEnd(const ChildIterator< value_type, is_const > &it)
Definition KisForest.h:300

References d, KisForestDetail::isEnd(), and nextNode().

◆ leaveNodeSubtree()

void KoSvgTextLoader::leaveNodeSubtree ( )

Set the current node to its parent, leaving the subtree.

Definition at line 46 of file KoSvgTextLoader.cpp.

47{
48 d->currentNode = KisForestDetail::parent(d->currentNode);
49}
ChildIterator< value_type, is_const > parent(const ChildIterator< value_type, is_const > &it)
Definition KisForest.h:327

References d, and KisForestDetail::parent().

◆ loadSvg()

bool KoSvgTextLoader::loadSvg ( const QDomElement & element,
SvgLoadingContext & context,
bool root = false )

Create a new text node.

Definition at line 56 of file KoSvgTextLoader.cpp.

57{
58 if (KisForestDetail::isEnd(d->currentNode)) {
59 nextNode();
60 }
61 return d->currentNode->loadSvg(element, context, root);
62}

References d, KisForestDetail::isEnd(), and nextNode().

◆ loadSvgText()

bool KoSvgTextLoader::loadSvgText ( const QDomText & text,
SvgLoadingContext & context )

Loads the textt into the current node.

Definition at line 64 of file KoSvgTextLoader.cpp.

65{
66 if (KisForestDetail::isEnd(d->currentNode)) {
67 nextNode();
68 }
69 return d->currentNode->loadSvgTextNode(text, context);
70}

References d, KisForestDetail::isEnd(), and nextNode().

◆ nextNode()

void KoSvgTextLoader::nextNode ( )

Switch to next node.

Definition at line 51 of file KoSvgTextLoader.cpp.

52{
53 d->currentNode = d->shape->d->textData.insert(KisForestDetail::siblingEnd(d->currentNode), KoSvgTextContentElement());
54}
ChildIterator< value_type, is_const > siblingEnd(const ChildIterator< value_type, is_const > &it)
Definition KisForest.h:255
The KoSvgTextContentElement struct.

References d, and KisForestDetail::siblingEnd().

◆ setStyleInfo()

void KoSvgTextLoader::setStyleInfo ( KoShape * s)

Set the style info from the shape. This is necessary because SVGParser only understands loading the basic style into a KoShape.

Definition at line 72 of file KoSvgTextLoader.cpp.

73{
74 if (!KisForestDetail::isEnd(d->currentNode)) {
75 // find closest parent stroke and fill so we can check for inheritance.
77 KoShapeStrokeModelSP parentStroke;
78 for (auto it = KisForestDetail::hierarchyBegin(d->currentNode); it != KisForestDetail::hierarchyEnd(d->currentNode); it++) {
79 if (it->properties.hasProperty(KoSvgTextProperties::FillId)) {
80 parentBg = it->properties.background();
81 break;
82 }
83 }
84 for (auto it = KisForestDetail::hierarchyBegin(d->currentNode); it != KisForestDetail::hierarchyEnd(d->currentNode); it++) {
85 if (it->properties.hasProperty(KoSvgTextProperties::StrokeId)) {
86 parentStroke = it->properties.stroke();
87 break;
88 }
89 }
90
91 if (!s->inheritBackground()) {
92 if ((parentBg && !parentBg->compareTo(s->background().data()))
93 || (!parentBg && s->background())) {
94 d->currentNode->properties.setProperty(KoSvgTextProperties::FillId,
95 QVariant::fromValue(KoSvgText::BackgroundProperty(s->background())));
96 }
97 }
98 if (!s->inheritStroke()) {
99 if ((parentStroke && (!parentStroke->compareFillTo(s->stroke().data()) || !parentStroke->compareStyleTo(s->stroke().data())))
100 || (!parentStroke && s->stroke())) {
101 d->currentNode->properties.setProperty(KoSvgTextProperties::StrokeId,
102 QVariant::fromValue(KoSvgText::StrokeProperty(s->stroke())));
103 }
104 }
105 d->currentNode->properties.setProperty(KoSvgTextProperties::Opacity,
106 s->transparency());
107 d->currentNode->properties.setProperty(KoSvgTextProperties::Visiblity,
108 s->isVisible());
109 if (!s->inheritPaintOrder()) {
110 d->currentNode->properties.setProperty(KoSvgTextProperties::PaintOrder,
111 QVariant::fromValue(s->paintOrder()));
112 }
113 }
114}
virtual QVector< PaintOrder > paintOrder() const
paintOrder
Definition KoShape.cpp:773
virtual KoShapeStrokeModelSP stroke() const
Definition KoShape.cpp:1067
bool inheritStroke() const
inheritStroke shows if the shape inherits the stroke from its parent
Definition KoShape.cpp:1098
bool inheritBackground() const
inheritBackground shows if the shape inherits background from its parent
Definition KoShape.cpp:949
virtual QSharedPointer< KoShapeBackground > background() const
Definition KoShape.cpp:926
bool inheritPaintOrder() const
inheritPaintOrder
Definition KoShape.cpp:795
bool isVisible(bool recursive=true) const
Definition KoShape.cpp:979
qreal transparency(bool recursive=false) const
Definition KoShape.cpp:730
@ Visiblity
Bool, CSS visibility.
@ PaintOrder
QVector<KoShape::PaintOrder>
@ Opacity
Double, SVG shape opacity.
@ StrokeId
KoSvgText::StrokeProperty.
@ FillId
KoSvgText::BackgroundProperty.
ResultIterator hierarchyBegin(Iterator it)
Definition KisForest.h:419
ResultIterator hierarchyEnd(Iterator it)
Definition KisForest.h:427
BackgroundProperty is a special wrapper around KoShapeBackground for managing it in KoSvgTextProperti...
Definition KoSvgText.h:714
StrokeProperty is a special wrapper around KoShapeStrokeModel for managing it in KoSvgTextProperties.
Definition KoSvgText.h:733

References KoShape::background(), d, KoSvgTextProperties::FillId, KisForestDetail::hierarchyBegin(), KisForestDetail::hierarchyEnd(), KoShape::inheritBackground(), KoShape::inheritPaintOrder(), KoShape::inheritStroke(), KisForestDetail::isEnd(), KoShape::isVisible(), KoSvgTextProperties::Opacity, KoShape::paintOrder(), KoSvgTextProperties::PaintOrder, KoShape::stroke(), KoSvgTextProperties::StrokeId, KoShape::transparency(), and KoSvgTextProperties::Visiblity.

◆ setTextPathOnCurrentNode()

void KoSvgTextLoader::setTextPathOnCurrentNode ( KoShape * s)

Set the textPath on the current node.

Definition at line 116 of file KoSvgTextLoader.cpp.

117{
118 if (!KisForestDetail::isEnd(d->currentNode)) {
119 d->currentNode->textPath.reset(s);
120 }
121}

References d, and KisForestDetail::isEnd().

Member Data Documentation

◆ d

QScopedPointer<Private> KoSvgTextLoader::d
private

Definition at line 40 of file KoSvgTextLoader.h.


The documentation for this class was generated from the following files: