* [TD]add method to clean win filespecs - '\' in strings passed to Python as filespecs is interpreted as an escape of the following character. - replace '\' with '/' * [TD]remove '\' from filespecs before use
This commit is contained in:
@@ -94,6 +94,7 @@ std::pair<Base::Vector3d, Base::Vector3d> viewDirection();
|
||||
class Vertex;
|
||||
using namespace TechDrawGui;
|
||||
using namespace TechDraw;
|
||||
using DU = DrawUtil;
|
||||
|
||||
//===========================================================================
|
||||
// TechDraw_PageDefault
|
||||
@@ -137,7 +138,8 @@ void CmdTechDrawPageDefault::activated(int iMsg)
|
||||
svgTemplate->translateLabel("DrawSVGTemplate", "Template", svgTemplate->getNameInDocument());
|
||||
|
||||
page->Template.setValue(svgTemplate);
|
||||
svgTemplate->Template.setValue(templateFileName.toStdString());
|
||||
auto filespec = DU::cleanFilespecBackslash(Base::Tools::toStdString(templateFileName));
|
||||
svgTemplate->Template.setValue(filespec);
|
||||
|
||||
updateActive();
|
||||
commitCommand();
|
||||
@@ -207,7 +209,8 @@ void CmdTechDrawPageTemplate::activated(int iMsg)
|
||||
svgTemplate->translateLabel("DrawSVGTemplate", "Template", svgTemplate->getNameInDocument());
|
||||
|
||||
page->Template.setValue(svgTemplate);
|
||||
svgTemplate->Template.setValue(templateFileName.toStdString());
|
||||
auto filespec = DU::cleanFilespecBackslash(Base::Tools::toStdString(templateFileName));
|
||||
svgTemplate->Template.setValue(filespec);
|
||||
|
||||
updateActive();
|
||||
commitCommand();
|
||||
@@ -448,8 +451,9 @@ void CmdTechDrawView::activated(int iMsg)
|
||||
|| filename.endsWith(QString::fromLatin1(".svgz"), Qt::CaseInsensitive)) {
|
||||
std::string FeatName = getUniqueObjectName("Symbol");
|
||||
filename = Base::Tools::escapeEncodeFilename(filename);
|
||||
auto filespec = DU::cleanFilespecBackslash(Base::Tools::toStdString(filename));
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Create Symbol"));
|
||||
doCommand(Doc, "f = open(\"%s\", 'r')", (const char*)filename.toUtf8());
|
||||
doCommand(Doc, "f = open(\"%s\", 'r')", filespec.c_str());
|
||||
doCommand(Doc, "svg = f.read()");
|
||||
doCommand(Doc, "f.close()");
|
||||
doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewSymbol', '%s')",
|
||||
@@ -463,11 +467,12 @@ void CmdTechDrawView::activated(int iMsg)
|
||||
else {
|
||||
std::string FeatName = getUniqueObjectName("Image");
|
||||
filename = Base::Tools::escapeEncodeFilename(filename);
|
||||
auto filespec = DU::cleanFilespecBackslash(Base::Tools::toStdString(filename));
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Create Image"));
|
||||
doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewImage', '%s')", FeatName.c_str());
|
||||
doCommand(Doc, "App.activeDocument().%s.translateLabel('DrawViewImage', 'Image', '%s')",
|
||||
FeatName.c_str(), FeatName.c_str());
|
||||
doCommand(Doc, "App.activeDocument().%s.ImageFile = '%s'", FeatName.c_str(), filename.toUtf8().constData());
|
||||
doCommand(Doc, "App.activeDocument().%s.ImageFile = '%s'", FeatName.c_str(), filespec.c_str());
|
||||
doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str());
|
||||
updateActive();
|
||||
commitCommand();
|
||||
@@ -1541,8 +1546,9 @@ void CmdTechDrawSymbol::activated(int iMsg)
|
||||
if (!filename.isEmpty()) {
|
||||
std::string FeatName = getUniqueObjectName("Symbol");
|
||||
filename = Base::Tools::escapeEncodeFilename(filename);
|
||||
auto filespec = DU::cleanFilespecBackslash(Base::Tools::toStdString(filename));
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Create Symbol"));
|
||||
doCommand(Doc, "f = open(\"%s\", 'r')", (const char*)filename.toUtf8());
|
||||
doCommand(Doc, "f = open(\"%s\", 'r')", (const char*)filespec.c_str());
|
||||
doCommand(Doc, "svg = f.read()");
|
||||
doCommand(Doc, "f.close()");
|
||||
doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewSymbol', '%s')",
|
||||
@@ -1853,8 +1859,9 @@ void CmdTechDrawExportPageDXF::activated(int iMsg)
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Save page to DXF"));
|
||||
doCommand(Doc, "import TechDraw");
|
||||
fileName = Base::Tools::escapeEncodeFilename(fileName);
|
||||
auto filespec = DU::cleanFilespecBackslash(Base::Tools::toStdString(fileName));
|
||||
doCommand(Doc, "TechDraw.writeDXFPage(App.activeDocument().%s, u\"%s\")", PageName.c_str(),
|
||||
(const char*)fileName.toUtf8());
|
||||
filespec.c_str());
|
||||
commitCommand();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user