Skip to content

Commit

Permalink
TechDraw: SVG export refactoring - Fix russian templates rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
pavltom authored and WandererFan committed Jun 11, 2019
1 parent dab8a3c commit 1cd8f26
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Mod/TechDraw/App/DrawSVGTemplate.cpp
Expand Up @@ -184,9 +184,9 @@ App::DocumentObjectExecReturn * DrawSVGTemplate::execute(void)
QDomElement tspan = model.toDomNode(queryResult.current().toNodeModelIndex()).toElement();

// Replace the editable text spans with new nodes holding actual values
QString editableName = tspan.parentNode().toElement().attribute(QString::fromUtf8("freecad:editable"));
std::map<std::string, std::string>::iterator item =
substitutions.find(tspan.parentNode().toElement()
.attribute(QString::fromUtf8("freecad:editable")).toStdString());
substitutions.find(std::string(editableName.toUtf8().constData()));
if (item != substitutions.end()) {
// Keep all spaces in the text node
tspan.setAttribute(QString::fromUtf8("xml:space"), QString::fromUtf8("preserve"));
Expand Down Expand Up @@ -273,6 +273,7 @@ std::map<std::string, std::string> DrawSVGTemplate::getEditableTextsFromTemplate
return editables;
}


QDomDocument templateDocument;
if (!templateDocument.setContent(&templateFile)) {
Base::Console().Message("DrawPage::getEditableTextsFromTemplate() - failed to parse file: %s\n",
Expand All @@ -294,13 +295,14 @@ std::map<std::string, std::string> DrawSVGTemplate::getEditableTextsFromTemplate
QXmlResultItems queryResult;
query.evaluateTo(&queryResult);

while (!queryResult.next().isNull())
{
while (!queryResult.next().isNull()) {
QDomElement tspan = model.toDomNode(queryResult.current().toNodeModelIndex()).toElement();

// Takeover the names stored as attributes and the values stored as text items
editables[tspan.parentNode().toElement().attribute(QString::fromUtf8("freecad:editable"))
.toStdString()] = tspan.firstChild().nodeValue().toStdString();
QString editableName = tspan.parentNode().toElement().attribute(QString::fromUtf8("freecad:editable"));
QString editableValue = tspan.firstChild().nodeValue();

editables[std::string(editableName.toUtf8().constData())] =
std::string(editableValue.toUtf8().constData());
}

return editables;
Expand Down

0 comments on commit 1cd8f26

Please sign in to comment.