Krita Source Code Documentation
Loading...
Searching...
No Matches
SvgParser::DeferredUseStore Struct Reference

Classes

struct  El
 

Public Member Functions

void add (const QDomElement *useE, const QString &key)
 
void checkPendingUse (const QDomElement &b, QList< KoShape * > &shapes)
 
 DeferredUseStore (SvgParser *p)
 
bool empty () const
 
 ~DeferredUseStore ()
 

Public Attributes

SvgParserm_parse
 
std::vector< Elm_uses
 

Detailed Description

Definition at line 70 of file SvgParser.cpp.

Constructor & Destructor Documentation

◆ DeferredUseStore()

SvgParser::DeferredUseStore::DeferredUseStore ( SvgParser * p)
inline

Definition at line 78 of file SvgParser.cpp.

78 :
79 m_parse(p) {
80 }
const Params2D p

◆ ~DeferredUseStore()

SvgParser::DeferredUseStore::~DeferredUseStore ( )
inline

Definition at line 113 of file SvgParser.cpp.

113 {
114 while (!m_uses.empty()) {
115 const El& el = m_uses.back();
116 debugFlake << "WARNING: could not find path in <use xlink:href=\"#xxxxx\" expression. Losing data here. Key:"
117 << el.m_key;
118 m_uses.pop_back();
119 }
120 }
#define debugFlake
Definition FlakeDebug.h:15
std::vector< El > m_uses

References debugFlake, SvgParser::DeferredUseStore::El::m_key, and m_uses.

Member Function Documentation

◆ add()

void SvgParser::DeferredUseStore::add ( const QDomElement * useE,
const QString & key )
inline

Definition at line 82 of file SvgParser.cpp.

82 {
83 m_uses.push_back(El(useE, key));
84 }

References m_uses.

◆ checkPendingUse()

void SvgParser::DeferredUseStore::checkPendingUse ( const QDomElement & b,
QList< KoShape * > & shapes )
inline

Definition at line 89 of file SvgParser.cpp.

89 {
90 KoShape* shape = 0;
91 const QString id = b.attribute("id");
92
93 if (id.isEmpty())
94 return;
95
96 // debugFlake << "Checking id: " << id;
97 auto i = std::partition(m_uses.begin(), m_uses.end(),
98 [&](const El& e) -> bool {return e.m_key != id;});
99
100 while (i != m_uses.end()) {
101 const El& el = m_uses.back();
102 if (m_parse->m_context.hasDefinition(el.m_key)) {
103 // debugFlake << "Found pending use for id: " << el.m_key;
104 shape = m_parse->resolveUse(*(el.m_useElement), el.m_key);
105 if (shape) {
106 shapes.append(shape);
107 }
108 }
109 m_uses.pop_back();
110 }
111 }
bool hasDefinition(const QString &id) const
Checks if a definition with the specified id exists.
QList< KoShape * > shapes() const
Returns the list of all shapes of the svg document.
SvgLoadingContext m_context
Definition SvgParser.h:225
KoShape * resolveUse(const QDomElement &e, const QString &key)

References SvgLoadingContext::hasDefinition(), SvgParser::m_context, SvgParser::DeferredUseStore::El::m_key, m_parse, SvgParser::DeferredUseStore::El::m_useElement, m_uses, SvgParser::resolveUse(), and SvgParser::shapes().

◆ empty()

bool SvgParser::DeferredUseStore::empty ( ) const
inline

Definition at line 85 of file SvgParser.cpp.

85 {
86 return m_uses.empty();
87 }

References m_uses.

Member Data Documentation

◆ m_parse

SvgParser* SvgParser::DeferredUseStore::m_parse

Definition at line 121 of file SvgParser.cpp.

◆ m_uses

std::vector<El> SvgParser::DeferredUseStore::m_uses

Definition at line 122 of file SvgParser.cpp.


The documentation for this struct was generated from the following file: