From eb0b3f0b94c20a0db4341acf691d868df08717e2 Mon Sep 17 00:00:00 2001 From: marioalexis Date: Fri, 10 Sep 2021 17:18:19 -0300 Subject: [PATCH] TechDraw: Fix Unicode and UTF-8 encoding character behavior --- src/Mod/TechDraw/App/DrawViewSymbol.cpp | 4 ++-- src/Mod/TechDraw/Gui/QGIViewAnnotation.cpp | 17 ++++------------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewSymbol.cpp b/src/Mod/TechDraw/App/DrawViewSymbol.cpp index 3671a6c83f..d31f763720 100644 --- a/src/Mod/TechDraw/App/DrawViewSymbol.cpp +++ b/src/Mod/TechDraw/App/DrawViewSymbol.cpp @@ -111,7 +111,7 @@ void DrawViewSymbol::onChanged(const App::Property* prop) while (!queryResult.next().isNull()) { QDomElement tspanElement = model.toDomNode(queryResult.current().toNodeModelIndex()).toElement(); - editables.push_back(Base::Tools::escapedUnicodeFromUtf8(tspanElement.text().toStdString().c_str())); + editables.push_back(tspanElement.text().toStdString()); } } else { @@ -188,7 +188,7 @@ App::DocumentObjectExecReturn *DrawViewSymbol::execute(void) // Finally append text node with editable replacement as the only descendant tspanElement.appendChild(symbolDocument.createTextNode( - QString::fromUtf8(Base::Tools::escapedUnicodeToUtf8(editText[count]).c_str()))); + QString::fromUtf8(editText[count].c_str()))); ++count; } diff --git a/src/Mod/TechDraw/Gui/QGIViewAnnotation.cpp b/src/Mod/TechDraw/Gui/QGIViewAnnotation.cpp index 7c88c270cc..5a252d0b54 100644 --- a/src/Mod/TechDraw/Gui/QGIViewAnnotation.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewAnnotation.cpp @@ -160,18 +160,9 @@ void QGIViewAnnotation::drawAnnotation() if (it != annoText.begin()) { ss << "
"; } - //TODO: there is still a bug here. entering "'" works, save and restore works, but edit after - // save and restore brings "\'" back into text. manually deleting the "\" fixes it until the next - // save/restore/edit cycle. - // a guess is that the editor for propertyStringList is too enthusiastic about substituting. - // the substituting might be necessary for using the strings in Python. - // ' doesn't seem to help in this case. - std::string u8String = Base::Tools::escapedUnicodeToUtf8(*it); //from \x??\x?? to real utf8 - std::string apos = std::regex_replace((u8String), std::regex("\\\\"), ""); //remove doubles. - apos = std::regex_replace((apos), std::regex("\\'"), "'"); //replace escaped apos //"less than" symbol chops off line. need to use html sub. - std::string lt = std::regex_replace((apos), std::regex("<"), "<"); + std::string lt = std::regex_replace((*it), std::regex("<"), "<"); ss << lt; } ss << "

\n\n "; @@ -203,11 +194,11 @@ void QGIViewAnnotation::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) const std::vector &values = annotation->Text.getValues(); QString text; if (values.size() > 0) { - text = QString::fromUtf8(Base::Tools::escapedUnicodeToUtf8(values[0]).c_str()); + text = QString::fromUtf8(values[0].c_str()); for (unsigned int i = 1; i < values.size(); ++i) { text += QChar::fromLatin1('\n'); - text += QString::fromUtf8(Base::Tools::escapedUnicodeToUtf8(values[i]).c_str()); + text += QString::fromUtf8(values[i].c_str()); } } @@ -233,7 +224,7 @@ void QGIViewAnnotation::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) std::vector newValues; for (int i = 0; i < list.size(); ++i) { - newValues.push_back(Base::Tools::escapedUnicodeFromUtf8(list[i].toStdString().c_str())); + newValues.push_back(list[i].toStdString()); } App::GetApplication().setActiveTransaction("Set Annotation Text");