From 08a991619fbd4f803d52e698dd48f0f7f46d118e Mon Sep 17 00:00:00 2001 From: Artem Zhidkov Date: Mon, 29 Jun 2020 15:53:57 +0300 Subject: [PATCH] Task #3237: Allow usage of accented characters in ObjectBrowser Move string conversion to the separate package. --- CMakeLists.txt | 1 + src/Events/CMakeLists.txt | 5 ++ src/Events/Events_InfoMessage.cpp | 26 +----- src/ExchangePlugin/CMakeLists.txt | 2 + .../ExchangePlugin_ExportFeature.cpp | 12 +-- src/ExchangePlugin/ExchangePlugin_Import.cpp | 8 +- .../ExchangePlugin_ImportFeature.cpp | 10 ++- .../ExchangePlugin_ImportPart.cpp | 8 +- src/Locale/CMakeLists.txt | 43 ++++++++++ src/Locale/Locale_Convert.cpp | 83 +++++++++++++++++++ src/Locale/Locale_Convert.h | 51 ++++++++++++ src/Locale/Locale_def.h | 33 ++++++++ src/Model/CMakeLists.txt | 2 + src/Model/Model_Application.cpp | 4 +- src/Model/Model_AttributeSelection.cpp | 16 ++-- src/Model/Model_BodyBuilder.cpp | 8 +- src/Model/Model_Data.cpp | 5 +- src/Model/Model_Document.cpp | 8 +- src/Model/Model_Objects.cpp | 4 +- src/Model/Model_ResultField.cpp | 4 +- src/Model/Model_ResultPart.cpp | 4 +- src/ModelAPI/CMakeLists.txt | 2 + src/ModelAPI/ModelAPI_Tools.cpp | 52 +----------- src/ModelAPI/ModelAPI_Tools.h | 11 --- src/ModelHighAPI/CMakeLists.txt | 2 + src/ModelHighAPI/ModelHighAPI_Dumper.cpp | 20 +++-- .../ModelHighAPI_FeatureStore.cpp | 26 +++--- src/ModelHighAPI/ModelHighAPI_Tools.cpp | 18 ++-- src/ParametersPlugin/CMakeLists.txt | 6 +- .../ParametersPlugin_EvalListener.cpp | 24 +++--- .../ParametersPlugin_Parameter.cpp | 8 +- .../ParametersPlugin_Validators.cpp | 4 +- src/PartSet/CMakeLists.txt | 2 + src/PartSet/PartSet_Validators.cpp | 8 +- src/Selector/CMakeLists.txt | 2 + src/Selector/Selector_Modify.cpp | 8 +- src/Selector/Selector_Primitive.cpp | 4 +- src/SketchAPI/CMakeLists.txt | 3 +- src/SketchAPI/SketchAPI_BSpline.cpp | 4 +- src/SketchAPI/SketchAPI_Ellipse.cpp | 4 +- src/SketchPlugin/CMakeLists.txt | 4 +- .../SketchPlugin_MacroBSpline.cpp | 4 +- src/SketchPlugin/SketchPlugin_Split.cpp | 4 +- src/SketchPlugin/SketchPlugin_Tools.cpp | 4 +- src/SketchPlugin/SketchPlugin_Validators.cpp | 5 +- 45 files changed, 388 insertions(+), 178 deletions(-) create mode 100644 src/Locale/CMakeLists.txt create mode 100644 src/Locale/Locale_Convert.cpp create mode 100644 src/Locale/Locale_Convert.h create mode 100644 src/Locale/Locale_def.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b7e24ed3..6ac77169e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,6 +126,7 @@ SET(MAKE_TRANSLATION YES) ADD_DEFINITIONS( -DMAKE_TRANSLATION ) ADD_SUBDIRECTORY (src/Config) +ADD_SUBDIRECTORY (src/Locale) ADD_SUBDIRECTORY (src/Events) ADD_SUBDIRECTORY (src/Selector) ADD_SUBDIRECTORY (src/Model) diff --git a/src/Events/CMakeLists.txt b/src/Events/CMakeLists.txt index 1fd4485de..b01d40559 100644 --- a/src/Events/CMakeLists.txt +++ b/src/Events/CMakeLists.txt @@ -41,6 +41,10 @@ SET(PROJECT_SOURCES Events_InfoMessage.cpp ) +SET(PROJECT_LIBRARIES + Locale +) + ADD_DEFINITIONS(-DEVENTS_EXPORTS) ADD_LIBRARY(Events SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS}) @@ -50,6 +54,7 @@ SET_SOURCE_FILES_PROPERTIES(Events.i PROPERTIES CPLUSPLUS ON) SET_SOURCE_FILES_PROPERTIES(Events.i PROPERTIES SWIG_DEFINITIONS "-shadow") INCLUDE_DIRECTORIES( + ../Locale ) TARGET_LINK_LIBRARIES(Events ${PROJECT_LIBRARIES}) diff --git a/src/Events/Events_InfoMessage.cpp b/src/Events/Events_InfoMessage.cpp index ba26c145f..ee0483c2a 100644 --- a/src/Events/Events_InfoMessage.cpp +++ b/src/Events/Events_InfoMessage.cpp @@ -18,21 +18,9 @@ // #include "Events_InfoMessage.h" +#include #include -// To support old types of GCC (less than 5.0), check the wide-string conversion is working -#if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L) && \ - (__cplusplus >= 201402L || !defined(__GLIBCXX__) || \ - (defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE > 4)) -#define HAVE_WORKING_WIDESTRING 1 -#else -#define HAVE_WORKING_WIDESTRING 0 -#endif - -#if HAVE_WORKING_WIDESTRING -#include -#endif - void Events_InfoMessage::addParameter(double theParam) { std::stringstream aStream; @@ -55,16 +43,6 @@ void Events_InfoMessage::send() Events_InfoMessage& Events_InfoMessage::arg(const std::wstring& theParam) { -#if HAVE_WORKING_WIDESTRING - static std::wstring_convert > aConvertor; - addParameter(aConvertor.to_bytes(theParam)); -#else - char* aBuf = new char[2 * (theParam.size() + 1)]; - size_t aNbChars = std::wcstombs(aBuf, theParam.c_str(), theParam.size()); - if (aNbChars != (size_t)-1) - aBuf[aNbChars] = '\0'; - addParameter(aBuf); - delete[] aBuf; -#endif + addParameter(Locale::Convert::toString(theParam)); return *this; } diff --git a/src/ExchangePlugin/CMakeLists.txt b/src/ExchangePlugin/CMakeLists.txt index 30e5036e0..d35a2a6e4 100644 --- a/src/ExchangePlugin/CMakeLists.txt +++ b/src/ExchangePlugin/CMakeLists.txt @@ -22,6 +22,7 @@ INCLUDE(UnitTest) INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Events ${PROJECT_SOURCE_DIR}/src/Config + ${PROJECT_SOURCE_DIR}/src/Locale ${PROJECT_SOURCE_DIR}/src/ModelAPI ${PROJECT_SOURCE_DIR}/src/ModelHighAPI ${PROJECT_SOURCE_DIR}/src/GeomAPI @@ -70,6 +71,7 @@ SET(TEXT_RESOURCES SET(PROJECT_LIBRARIES Events Config + Locale ModelAPI ModelHighAPI GeomAPI diff --git a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp index d27a17086..a67e1bbe2 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp @@ -41,6 +41,8 @@ #include #include +#include + #include #include #include @@ -394,7 +396,7 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName) if (aGeometryName.empty() && aResults.size() == 1) { // get the name from the first result ResultPtr aResultBody = *aResults.begin(); - aGeometryName = ModelAPI_Tools::toString(aResultBody->data()->name()); + aGeometryName = Locale::Convert::toString(aResultBody->data()->name()); } aXao.getGeometry()->setName(aGeometryName); @@ -429,7 +431,7 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName) XAO::Dimension aGroupDimension = XAO::XaoUtils::stringToDimension(aDimensionString); XAO::Group* aXaoGroup = aXao.addGroup(aGroupDimension, - ModelAPI_Tools::toString(aResultGroup->data()->name())); + Locale::Convert::toString(aResultGroup->data()->name())); try { GeomAPI_ShapeExplorer aGroupResExplorer(aResultGroup->shape(), aSelType); @@ -448,7 +450,7 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName) } catch (XAO::XAO_Exception& e) { // LCOV_EXCL_START std::string msg = "An error occurred while exporting group " + - ModelAPI_Tools::toString(aResultGroup->data()->name()); + Locale::Convert::toString(aResultGroup->data()->name()); msg += ".\n"; msg += e.what(); msg += "\n"; @@ -485,7 +487,7 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName) XAO::Type aFieldType = XAO::XaoUtils::stringToFieldType(aTypeString); XAO::Field* aXaoField = aXao.addField(aFieldType, aFieldDimension, aTables->columns(), - ModelAPI_Tools::toString(aResultField->data()->name())); + Locale::Convert::toString(aResultField->data()->name())); try { @@ -546,7 +548,7 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName) } catch (XAO::XAO_Exception& e) { // LCOV_EXCL_START std::string msg = "An error occurred while exporting field " + - ModelAPI_Tools::toString(aResultField->data()->name()); + Locale::Convert::toString(aResultField->data()->name()); msg += ".\n"; msg += e.what(); msg += "\n"; diff --git a/src/ExchangePlugin/ExchangePlugin_Import.cpp b/src/ExchangePlugin/ExchangePlugin_Import.cpp index f6d04041d..ecaf3d821 100644 --- a/src/ExchangePlugin/ExchangePlugin_Import.cpp +++ b/src/ExchangePlugin/ExchangePlugin_Import.cpp @@ -20,6 +20,8 @@ #include "ExchangePlugin_Import.h" #include "ExchangePlugin_ImportFeature.h" +#include + #include #include @@ -101,7 +103,7 @@ void ExchangePlugin_Import::execute() SessionPtr aSession = ModelAPI_Session::get(); DocumentPtr aDoc = findDocument(aSession->moduleDocument(), - ModelAPI_Tools::toWString(aPartsAttr->value(aTargetAttr->value()))); + Locale::Convert::toWString(aPartsAttr->value(aTargetAttr->value()))); if (aDoc.get()) { FeaturePtr aImportFeature = aDoc->addFeature(ExchangePlugin_ImportFeature::ID()); @@ -145,7 +147,7 @@ void ExchangePlugin_Import::attributeChanged(const std::string& theID) aPartsAttr->setSize((int)anAcceptedValues.size()); std::list::iterator anIt = anAcceptedValues.begin(); for (int anInd = 0; anIt != anAcceptedValues.end(); ++anIt, ++anInd) - aPartsAttr->setValue(anInd, ModelAPI_Tools::toString(*anIt)); + aPartsAttr->setValue(anInd, Locale::Convert::toString(*anIt)); } else { // keep only the name of the current part @@ -153,7 +155,7 @@ void ExchangePlugin_Import::attributeChanged(const std::string& theID) FeaturePtr aPartFeature = ModelAPI_Tools::findPartFeature(aSession->moduleDocument(), aDoc); aPartsAttr->setSize(1); - aPartsAttr->setValue(0, ModelAPI_Tools::toString(aPartFeature->name())); + aPartsAttr->setValue(0, Locale::Convert::toString(aPartFeature->name())); aTargetAttr->setValue(0); } } diff --git a/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp index b2619119e..278ebf412 100644 --- a/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp @@ -34,6 +34,8 @@ #include #include +#include + #include #include #include @@ -138,7 +140,7 @@ void ExchangePlugin_ImportFeature::importFile(const std::string& theFileName) // Pass the results into the model std::string anObjectName = GeomAlgoAPI_Tools::File_Tools::name(theFileName); - data()->setName(ModelAPI_Tools::toWString(anObjectName)); + data()->setName(Locale::Convert::toWString(anObjectName)); setResult(createResultBody(aGeomShape)); } @@ -162,7 +164,7 @@ void ExchangePlugin_ImportFeature::importXAO(const std::string& theFileName) std::string aBodyName = aXaoGeometry->getName(); if (aBodyName.empty()) aBodyName = GeomAlgoAPI_Tools::File_Tools::name(theFileName); - data()->setName(ModelAPI_Tools::toWString(aBodyName)); + data()->setName(Locale::Convert::toWString(aBodyName)); ResultBodyPtr aResultBody = createResultBody(aGeomShape); setResult(aResultBody); @@ -188,7 +190,7 @@ void ExchangePlugin_ImportFeature::importXAO(const std::string& theFileName) // group name if (!aXaoGroup->getName().empty()) - aGroupFeature->data()->setName(ModelAPI_Tools::toWString(aXaoGroup->getName())); + aGroupFeature->data()->setName(Locale::Convert::toWString(aXaoGroup->getName())); // fill selection AttributeSelectionListPtr aSelectionList = aGroupFeature->selectionList("group_list"); @@ -218,7 +220,7 @@ void ExchangePlugin_ImportFeature::importXAO(const std::string& theFileName) // group name if (!aXaoField->getName().empty()) - aFieldFeature->data()->setName(ModelAPI_Tools::toWString(aXaoField->getName())); + aFieldFeature->data()->setName(Locale::Convert::toWString(aXaoField->getName())); // fill selection AttributeSelectionListPtr aSelectionList = aFieldFeature->selectionList("selected"); diff --git a/src/ExchangePlugin/ExchangePlugin_ImportPart.cpp b/src/ExchangePlugin/ExchangePlugin_ImportPart.cpp index 2dfedff11..c0930ef87 100644 --- a/src/ExchangePlugin/ExchangePlugin_ImportPart.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ImportPart.cpp @@ -19,6 +19,8 @@ #include +#include + #include #include #include @@ -103,7 +105,7 @@ void ExchangePlugin_ImportPart::attributeChanged(const std::string& theID) for (std::list::iterator aFIt = aSubFeatures.begin(); aFIt != aSubFeatures.end(); ++aFIt) { if ((*aFIt)->getKind() == PartSetPlugin_Part::ID()) - anAcceptedValues.push_back(ModelAPI_Tools::toString((*aFIt)->name())); + anAcceptedValues.push_back(Locale::Convert::toString((*aFIt)->name())); } if (aPartsAttr->size() != anAcceptedValues.size()) @@ -120,7 +122,7 @@ void ExchangePlugin_ImportPart::attributeChanged(const std::string& theID) FeaturePtr aPartFeature = ModelAPI_Tools::findPartFeature(aSession->moduleDocument(), aDoc); aPartsAttr->setSize(1); - aPartsAttr->setValue(0, ModelAPI_Tools::toString(aPartFeature->name())); + aPartsAttr->setValue(0, Locale::Convert::toString(aPartFeature->name())); aTargetAttr->setValue(0); } } @@ -149,7 +151,7 @@ DocumentPtr findDocument(DocumentPtr thePartSetDoc, const std::string& thePartNa for (std::list::iterator aFIt = aSubFeatures.begin(); aFIt != aSubFeatures.end(); ++aFIt) { if ((*aFIt)->getKind() == PartSetPlugin_Part::ID() && - ModelAPI_Tools::toString((*aFIt)->name()) == thePartName) { + Locale::Convert::toString((*aFIt)->name()) == thePartName) { aPartFeature = *aFIt; break; } diff --git a/src/Locale/CMakeLists.txt b/src/Locale/CMakeLists.txt new file mode 100644 index 000000000..aab6541bd --- /dev/null +++ b/src/Locale/CMakeLists.txt @@ -0,0 +1,43 @@ +# Copyright (C) 2020 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +INCLUDE(Common) + +INCLUDE_DIRECTORIES( + ${CMAKE_CURRENT_SOURCE_DIR} + ${Boost_INCLUDE_DIR} +) + +SET(PROJECT_HEADERS + Locale_def.h + Locale_Convert.h +) + +SET(PROJECT_SOURCES + Locale_Convert.cpp +) + +SET(PROJECT_LIBRARIES +) + +ADD_DEFINITIONS(-DLOCALE_EXPORTS) +ADD_LIBRARY(Locale SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS}) +TARGET_LINK_LIBRARIES(Locale ${PROJECT_LIBRARIES}) + +INSTALL(TARGETS Locale DESTINATION ${SHAPER_INSTALL_BIN}) diff --git a/src/Locale/Locale_Convert.cpp b/src/Locale/Locale_Convert.cpp new file mode 100644 index 000000000..f3263d8e4 --- /dev/null +++ b/src/Locale/Locale_Convert.cpp @@ -0,0 +1,83 @@ +// Copyright (C) 2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include + +#include + +////// To support old types of GCC (less than 5.0), check the wide-string conversion is working +////#if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L) && \ +//// (__cplusplus >= 201402L || !defined(__GLIBCXX__) || \ +//// (defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE > 4)) +////#define HAVE_WORKING_WIDESTRING 1 +////#else +////#define HAVE_WORKING_WIDESTRING 0 +////#endif +//// +////#if HAVE_WORKING_WIDESTRING +////#include +////#endif + +namespace Locale +{ + std::string Convert::toString(const std::wstring& theWStr) + { +////#if HAVE_WORKING_WIDESTRING +//// static std::wstring_convert > aConvertor; +//// return aConvertor.to_bytes(theWStr); +////#else +//// char* aBuf = new char[2 * (theWStr.size() + 1)]; +//// size_t aNbChars = std::wcstombs(aBuf, theWStr.c_str(), theWStr.size()); +//// if (aNbChars != (size_t)-1) +//// aBuf[aNbChars] = '\0'; +//// std::string aStr(aBuf); +//// delete[] aBuf; +//// return aStr; +////#endif + return boost::locale::conv::utf_to_utf(theWStr); + } + + std::string Convert::toString(const char16_t* theExtStr) + { + return boost::locale::conv::utf_to_utf(theExtStr); + } + + std::wstring Convert::toWString(const std::string& theStr) + { +////#if HAVE_WORKING_WIDESTRING +//// static std::wstring_convert > aConvertor; +//// return aConvertor.from_bytes(theStr); +////#else +//// wchar_t* aBuf = new wchar_t[theStr.size() + 1]; +//// size_t aNbWChars = std::mbstowcs(aBuf, theStr.c_str(), theStr.size()); +//// if (aNbWChars != (size_t)-1) +//// aBuf[aNbWChars] = L'\0'; +//// std::wstring aWStr(aBuf); +//// delete[] aBuf; +//// return aWStr; +////#endif + return boost::locale::conv::utf_to_utf(theStr); + } + + std::wstring Convert::toWString(const char16_t* theExtStr) + { + return boost::locale::conv::utf_to_utf(theExtStr); + } + +} diff --git a/src/Locale/Locale_Convert.h b/src/Locale/Locale_Convert.h new file mode 100644 index 000000000..9a44323a1 --- /dev/null +++ b/src/Locale/Locale_Convert.h @@ -0,0 +1,51 @@ +// Copyright (C) 2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef LOCALE_CONVERT_H +#define LOCALE_CONVERT_H + +#include + +#include + +namespace Locale +{ + /// Convert strings + namespace Convert + { + /// Converts a wide-string to a simple (byte) string + /// \param theWStr a wide-string + LOCALE_EXPORT std::string toString(const std::wstring& theWStr); + + /// Converts an extended string to a simple (byte) string + /// \param theExtStr an extended string + LOCALE_EXPORT std::string toString(const char16_t* theExtStr); + + /// Converts a byte string to a wide-string + /// \param theStr a byte string + LOCALE_EXPORT std::wstring toWString(const std::string& theStr); + + /// Converts an extended string to a wide-string + /// \param theStr a byte string + LOCALE_EXPORT std::wstring toWString(const char16_t* theExtStr); + + } +} + +#endif // Locale_Convert_H diff --git a/src/Locale/Locale_def.h b/src/Locale/Locale_def.h new file mode 100644 index 000000000..36587c92c --- /dev/null +++ b/src/Locale/Locale_def.h @@ -0,0 +1,33 @@ +// Copyright (C) 2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef LOCALE_DEF_H +#define LOCALE_DEF_H + +#if defined WIN32 +# if defined LOCALE_EXPORTS +# define LOCALE_EXPORT __declspec( dllexport ) +# else +# define LOCALE_EXPORT __declspec( dllimport ) +# endif +#else +# define LOCALE_EXPORT +#endif + +#endif diff --git a/src/Model/CMakeLists.txt b/src/Model/CMakeLists.txt index eaac6b906..81e140d18 100644 --- a/src/Model/CMakeLists.txt +++ b/src/Model/CMakeLists.txt @@ -104,6 +104,7 @@ SET(PROJECT_LIBRARIES GeomData GeomAPI GeomAlgoAPI + Locale ModelGeomAlgo ${OpenCASCADE_ApplicationFramework_LIBRARIES} ) @@ -116,6 +117,7 @@ SET(PROJECT_INCLUDES ../GeomDataAPI ../GeomAlgoAPI ../GeomAPI + ../Locale ../ModelGeomAlgo ../ConstructionPlugin ${OpenCASCADE_INCLUDE_DIR} diff --git a/src/Model/Model_Application.cpp b/src/Model/Model_Application.cpp index 36634ff15..ecdb234d4 100644 --- a/src/Model/Model_Application.cpp +++ b/src/Model/Model_Application.cpp @@ -23,6 +23,8 @@ #include #include +#include + #include #include @@ -71,7 +73,7 @@ bool Model_Application::loadDocument(const std::wstring theDocName, const int th bool aRes = true; // load it if it must be loaded by demand if (myLoadedByDemand.find(theDocName) != myLoadedByDemand.end() && !myPath.empty()) { - aRes = aNew->load(myPath.c_str(), ModelAPI_Tools::toString(theDocName).c_str(), aNew); + aRes = aNew->load(myPath.c_str(), Locale::Convert::toString(theDocName).c_str(), aNew); myLoadedByDemand.erase(theDocName); // done, don't do it anymore } else { // error aRes = false; diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 3127aeb85..180fb85e5 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -46,6 +46,8 @@ #include #include +#include + #include #include #include @@ -368,7 +370,7 @@ std::shared_ptr Model_AttributeSelection::internalValue(CenterTyp std::string aNameInPart = aSubShapeName.substr(aPartEnd + 1); int anIndex; std::string aType; // to reuse already existing selection the type is not needed - return aPart->shapeInPart(ModelAPI_Tools::toWString(aNameInPart), aType, anIndex); + return aPart->shapeInPart(Locale::Convert::toWString(aNameInPart), aType, anIndex); } } } @@ -763,7 +765,7 @@ std::wstring Model_AttributeSelection::namingName(const std::wstring& theDefault aShape = context()->shape(); std::wstring aName; if (aShape.get()) { - aName = ModelAPI_Tools::toWString(aShape->shapeTypeStr()); + aName = Locale::Convert::toWString(aShape->shapeTypeStr()); if (myParent) { std::wostringstream aStream; aStream << "_" << selectionLabel().Father().Tag(); @@ -781,7 +783,7 @@ std::wstring Model_AttributeSelection::namingName(const std::wstring& theDefault std::wstring aResName; // checking part-owner if (aContFeature->document() != owner()->document()) - aResName += ModelAPI_Tools::toWString(aContFeature->document()->kind()) + L"/"; + aResName += Locale::Convert::toWString(aContFeature->document()->kind()) + L"/"; // selection of a full feature if (aContFeature.get()) { return aResName + kWHOLE_FEATURE + aContFeature->name(); @@ -874,7 +876,7 @@ void Model_AttributeSelection::selectSubShape( if (aPartEnd != std::string::npos) { std::wstring aPartName = aSubShapeName.substr(0, aPartEnd); DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); - if (aPartName == ModelAPI_Tools::toWString(aRootDoc->kind())) { + if (aPartName == Locale::Convert::toWString(aRootDoc->kind())) { aDoc = std::dynamic_pointer_cast(aRootDoc); aSubShapeName = aSubShapeName.substr(aPartEnd + 1); } @@ -1135,7 +1137,7 @@ std::wstring Model_AttributeSelection::contextName(const ResultPtr& theContext) std::wstring aResult; if (owner()->document() != theContext->document()) { if (theContext->document() == ModelAPI_Session::get()->moduleDocument()) { - aResult = ModelAPI_Tools::toWString(theContext->document()->kind()) + L"/"; + aResult = Locale::Convert::toWString(theContext->document()->kind()) + L"/"; } else { ResultPtr aDocRes = ModelAPI_Tools::findPartResult( ModelAPI_Session::get()->moduleDocument(), theContext->document()); @@ -1883,7 +1885,7 @@ std::wstring Model_AttributeSelection::contextName(const TDF_Label theSelectionL aNumInHistoryNames--; } if (aBaseDocumnetUsed) - aContextName = ModelAPI_Tools::toWString(aDoc->kind()) + L"/" + aContextName; + aContextName = Locale::Convert::toWString(aDoc->kind()) + L"/" + aContextName; return aContextName; } } @@ -1914,7 +1916,7 @@ bool Model_AttributeSelection::restoreContext(std::wstring theName, // name in PartSet? aDoc = std::dynamic_pointer_cast( ModelAPI_Session::get()->moduleDocument()); - if (theName.find(ModelAPI_Tools::toWString(aDoc->kind())) == 0) { + if (theName.find(Locale::Convert::toWString(aDoc->kind())) == 0) { // remove the document identifier from name if exists aSubShapeName = theName.substr(aDoc->kind().size() + 1); aName = aSubShapeName; diff --git a/src/Model/Model_BodyBuilder.cpp b/src/Model/Model_BodyBuilder.cpp index fa9fc4468..3311c7bcb 100644 --- a/src/Model/Model_BodyBuilder.cpp +++ b/src/Model/Model_BodyBuilder.cpp @@ -19,6 +19,8 @@ #include +#include + #include #include #include @@ -202,7 +204,7 @@ void Model_BodyBuilder::store(const GeomShapePtr& theShape, if(!aBuilder.NamedShape()->IsEmpty()) { Handle(TDataStd_Name) anAttr; if(aBuilder.NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) { - std::wstring aName ((wchar_t*)anAttr->Get().ToExtString()); + std::wstring aName = Locale::Convert::toWString(anAttr->Get().ToExtString()); if(!aName.empty()) { std::shared_ptr aDoc = std::dynamic_pointer_cast(document()); @@ -255,7 +257,7 @@ void Model_BodyBuilder::storeGenerated(const GeomShapePtr& theFromShape, if(!aBuilder->NamedShape()->IsEmpty()) { Handle(TDataStd_Name) anAttr; if(aBuilder->NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(),anAttr)) { - std::wstring aName((wchar_t*)anAttr->Get().ToExtString()); + std::wstring aName = Locale::Convert::toWString(anAttr->Get().ToExtString()); if(!aName.empty()) { std::shared_ptr aDoc = std::dynamic_pointer_cast(document()); @@ -347,7 +349,7 @@ void Model_BodyBuilder::storeModified(const GeomShapePtr& theOldShape, if(!aBuilder->NamedShape()->IsEmpty()) { Handle(TDataStd_Name) anAttr; if(aBuilder->NamedShape()->Label().FindAttribute(TDataStd_Name::GetID(), anAttr)) { - std::wstring aName ((wchar_t*)anAttr->Get().ToExtString()); + std::wstring aName = Locale::Convert::toWString(anAttr->Get().ToExtString()); if(!aName.empty()) { std::shared_ptr aDoc = std::dynamic_pointer_cast(document()); diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index dea65b8a5..f667942f8 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -58,6 +58,8 @@ #include #include +#include + #include #include #include @@ -113,8 +115,7 @@ std::wstring Model_Data::name() #ifdef DEBUG_NAMES myObject->myName = TCollection_AsciiString(aName->Get()).ToCString(); #endif - return std::wstring((wchar_t*)aName->Get().ToExtString()); - //return std::wstring(TCollection_AsciiString(aName->Get()).ToCString()); + return Locale::Convert::toWString(aName->Get().ToExtString()); } return L""; // not defined } diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index a1babc015..4ce8f1184 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -34,6 +34,8 @@ #include #include +#include + #include #include #include @@ -522,7 +524,7 @@ bool Model_Document::save( ResultPartPtr aPart = std::dynamic_pointer_cast(*aPartRes); if (!aPart->isActivated()) { // copy not-activated document that is not in the memory - std::string aDocName = ModelAPI_Tools::toString(aPart->data()->name()); + std::string aDocName = Locale::Convert::toString(aPart->data()->name()); if (!aDocName.empty()) { // just copy file TCollection_AsciiString aSubPath(DocFileName(anApp->loadPath().c_str(), aDocName)); @@ -539,7 +541,7 @@ bool Model_Document::save( } } } else { // simply save opened document - std::string aDocName = ModelAPI_Tools::toString(aPart->data()->name()); + std::string aDocName = Locale::Convert::toString(aPart->data()->name()); isDone = std::dynamic_pointer_cast(aPart->partDoc())-> save(theDirName, aDocName.c_str(), theResults); } @@ -1706,7 +1708,7 @@ void Model_Document::changeNamingName(const std::wstring theOldName, TDF_ChildIDIterator aChild(theLabel, TDataStd_Name::GetID()); for(; aChild.More(); aChild.Next()) { Handle(TDataStd_Name) aSubName = Handle(TDataStd_Name)::DownCast(aChild.Value()); - std::wstring aName = (wchar_t*)aSubName->Get().ToExtString(); + std::wstring aName = Locale::Convert::toWString(aSubName->Get().ToExtString()); if (aName.find(theOldName) == 0) { // started from parent name std::wstring aNewSubName = theNewName + aName.substr(theOldName.size()); changeNamingName(aName, aNewSubName, aSubName->Label()); diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index ef4d72a52..3a9cfe583 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -38,6 +38,8 @@ #include #include +#include + #include #include #include @@ -734,7 +736,7 @@ static std::wstring composeName(const std::string& theFeatureKind, const int the { std::stringstream aNameStream; aNameStream << theFeatureKind << "_" << theIndex; - return ModelAPI_Tools::toWString(aNameStream.str()); + return Locale::Convert::toWString(aNameStream.str()); } void Model_Objects::setUniqueName(FeaturePtr theFeature) diff --git a/src/Model/Model_ResultField.cpp b/src/Model/Model_ResultField.cpp index ed6f3bece..fad43f23d 100644 --- a/src/Model/Model_ResultField.cpp +++ b/src/Model/Model_ResultField.cpp @@ -28,6 +28,8 @@ #include +#include + #include Model_ResultField::Model_ResultField(std::shared_ptr theOwnerData) @@ -156,7 +158,7 @@ std::shared_ptr Model_ResultField::ste std::wstring Model_ResultField::Model_FieldStep::name() { std::wostringstream aStream; aStream<data()->name()<textLine(myId)); + aStream<<"Step "<<(myId + 1)<<" "<< Locale::Convert::toWString(myParent->textLine(myId)); return aStream.str(); } // LCOV_EXCL_STOP diff --git a/src/Model/Model_ResultPart.cpp b/src/Model/Model_ResultPart.cpp index e6dc45453..1ecd9ce39 100644 --- a/src/Model/Model_ResultPart.cpp +++ b/src/Model/Model_ResultPart.cpp @@ -36,6 +36,8 @@ #include +#include + #include #include #include @@ -91,7 +93,7 @@ void Model_ResultPart::activate() SessionPtr aMgr = ModelAPI_Session::get(); if (!aMgr->isOperation()) { // open transaction even document is not created to set current docs in setActiveDocument - std::string aMsg = "Activation " + ModelAPI_Tools::toString(data()->name()); + std::string aMsg = "Activation " + Locale::Convert::toString(data()->name()); aMgr->startOperation(aMsg); isNewTransaction = true; } diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index 6df21ce5b..e3767a069 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -117,6 +117,7 @@ SET(PROJECT_SOURCES SET(PROJECT_LIBRARIES Config GeomAPI + Locale ) SET(CMAKE_SWIG_FLAGS -threads -w325,321,362,383,302,403,451,473) ADD_DEFINITIONS(-DMODELAPI_EXPORTS) @@ -129,6 +130,7 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Config ${PROJECT_SOURCE_DIR}/src/Events ${PROJECT_SOURCE_DIR}/src/GeomAPI ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI + ${PROJECT_SOURCE_DIR}/src/Locale ) diff --git a/src/ModelAPI/ModelAPI_Tools.cpp b/src/ModelAPI/ModelAPI_Tools.cpp index 8922813f0..1baf30d0c 100644 --- a/src/ModelAPI/ModelAPI_Tools.cpp +++ b/src/ModelAPI/ModelAPI_Tools.cpp @@ -38,20 +38,8 @@ #include #include -// To support old types of GCC (less than 5.0), check the wide-string conversion is working -#if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L) && \ - (__cplusplus >= 201402L || !defined(__GLIBCXX__) || \ - (defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE > 4)) -#define HAVE_WORKING_WIDESTRING 1 -#else -#define HAVE_WORKING_WIDESTRING 0 -#endif - -#if HAVE_WORKING_WIDESTRING -#include -#endif - #include +#include #include #include @@ -185,7 +173,7 @@ std::string getFeatureError(const FeaturePtr& theFeature) ObjectPtr objectByName(const DocumentPtr& theDocument, const std::string& theGroup, const std::string& theName) { - std::wstring aName = toWString(theName); + std::wstring aName = Locale::Convert::toWString(theName); for (int anIndex = 0; anIndex < theDocument->size(theGroup); ++anIndex) { ObjectPtr anObject = theDocument->object(theGroup, anIndex); if (anObject->data()->name() == aName) @@ -1117,41 +1105,5 @@ std::list referencedFeatures( } // LCOV_EXCL_STOP -std::string toString(const std::wstring& theWStr) -{ -#if HAVE_WORKING_WIDESTRING - static std::wstring_convert > aConvertor; - return aConvertor.to_bytes(theWStr); -#else - char* aBuf = new char[2 * (theWStr.size() + 1)]; - size_t aNbChars = std::wcstombs(aBuf, theWStr.c_str(), theWStr.size()); - if (aNbChars != (size_t)-1) - aBuf[aNbChars] = '\0'; - std::string aStr(aBuf); - delete[] aBuf; - return aStr; -#endif -} - -/*! Converts a byte string to an extended string -* \param theStr a byte string -*/ -std::wstring toWString(const std::string& theStr) -{ -#if HAVE_WORKING_WIDESTRING - static std::wstring_convert > aConvertor; - return aConvertor.from_bytes(theStr); -#else - wchar_t* aBuf = new wchar_t[theStr.size() + 1]; - size_t aNbWChars = std::mbstowcs(aBuf, theStr.c_str(), theStr.size()); - if (aNbWChars != (size_t)-1) - aBuf[aNbWChars] = L'\0'; - std::wstring aWStr(aBuf); - delete[] aBuf; - return aWStr; -#endif -} - - } // namespace ModelAPI_Tools diff --git a/src/ModelAPI/ModelAPI_Tools.h b/src/ModelAPI/ModelAPI_Tools.h index f927a67c7..3956b6621 100644 --- a/src/ModelAPI/ModelAPI_Tools.h +++ b/src/ModelAPI/ModelAPI_Tools.h @@ -299,17 +299,6 @@ MODELAPI_EXPORT void copyVisualizationAttrs(std::shared_ptr the MODELAPI_EXPORT std::list > referencedFeatures( std::shared_ptr theTarget, const std::string& theFeatureKind, const bool theSortResults); - -/*! Converts an extended string to a simple (byte) string -* \param theWStr an extended string -*/ -MODELAPI_EXPORT std::string toString(const std::wstring& theWStr); - -/*! Converts a byte string to an extended string -* \param theStr a byte string -*/ -MODELAPI_EXPORT std::wstring toWString(const std::string& theStr); - } #endif diff --git a/src/ModelHighAPI/CMakeLists.txt b/src/ModelHighAPI/CMakeLists.txt index 41a55586c..4b65cc8b4 100644 --- a/src/ModelHighAPI/CMakeLists.txt +++ b/src/ModelHighAPI/CMakeLists.txt @@ -55,6 +55,7 @@ SET(PROJECT_LIBRARIES GeomAPI GeomDataAPI GeomAlgoAPI + Locale ModelAPI ModelGeomAlgo ) @@ -83,6 +84,7 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/GeomAPI ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI ${PROJECT_SOURCE_DIR}/src/GeomDataAPI + ${PROJECT_SOURCE_DIR}/src/Locale ${PROJECT_SOURCE_DIR}/src/ModelAPI ${PROJECT_SOURCE_DIR}/src/ModelGeomAlgo ${PROJECT_SOURCE_DIR}/src/PartSetPlugin diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp index 1031cf854..d818d9406 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp @@ -37,6 +37,8 @@ #include #include +#include + #include #include #include @@ -315,7 +317,7 @@ void ModelHighAPI_Dumper::DumpStorage::write(const AttributeSelectionPtr& theAtt if (aShape.get()) { myDumpBuffer << "\"" << aShape->shapeTypeStr() << "\", \"" - << ModelAPI_Tools::toString(theAttrSelect->namingName()) << "\""; + << Locale::Convert::toString(theAttrSelect->namingName()) << "\""; } myDumpBuffer << ")"; @@ -496,7 +498,7 @@ void ModelHighAPI_Dumper::DumpStorageWeak::write(const AttributeSelectionPtr& th int anIndex = aNExplode.index(aShape); if (anIndex != 0) { // found a week-naming index, so, export it myDumpBuffer << "model.selection(\"" << aShape->shapeTypeStr() << "\", \"" - << ModelAPI_Tools::toString(theAttrSelect->contextName(aContext)) + << Locale::Convert::toString(theAttrSelect->contextName(aContext)) << "\", " << anIndex << ")"; aStandardDump = false; } @@ -588,12 +590,12 @@ const std::string& ModelHighAPI_Dumper::name(const EntityPtr& theEntity, std::ostringstream aDefaultName; FeaturePtr aFeature = std::dynamic_pointer_cast(theEntity); if (aFeature) { - aName = ModelAPI_Tools::toString(aFeature->name()); + aName = Locale::Convert::toString(aFeature->name()); aKind = aFeature->getKind(); } else { FolderPtr aFolder = std::dynamic_pointer_cast(theEntity); if (aFolder) { - aName = ModelAPI_Tools::toString(aFolder->data()->name()); + aName = Locale::Convert::toString(aFolder->data()->name()); aKind = ModelAPI_Folder::ID(); isSaveNotDumped = false; } @@ -687,8 +689,8 @@ void ModelHighAPI_Dumper::saveResultNames(const FeaturePtr& theFeature) ModelAPI_Tools::allResults(theFeature, allRes); for(std::list::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) { std::pair aName = ModelAPI_Tools::getDefaultName(*aRes); - std::string aDefaultName = ModelAPI_Tools::toString(aName.first); - std::string aResName = ModelAPI_Tools::toString((*aRes)->data()->name()); + std::string aDefaultName = Locale::Convert::toString(aName.first); + std::string aResName = Locale::Convert::toString((*aRes)->data()->name()); bool isUserDefined = !(isFeatureDefaultName && aDefaultName == aResName); myNames[*aRes] = EntityName(aResName, (isUserDefined ? aResName : std::string()), !isUserDefined); @@ -873,14 +875,14 @@ void ModelHighAPI_Dumper::dumpSubFeatureNameAndColor(const std::string theSubFea { name(theSubFeature, false); myNames[theSubFeature] = - EntityName(theSubFeatureGet, ModelAPI_Tools::toString(theSubFeature->name()), false); + EntityName(theSubFeatureGet, Locale::Convert::toString(theSubFeature->name()), false); // store results if they have user-defined names or colors std::list aResultsWithNameOrColor; const std::list& aResults = theSubFeature->results(); std::list::const_iterator aResIt = aResults.begin(); for (; aResIt != aResults.end(); ++aResIt) { - std::string aResName = ModelAPI_Tools::toString((*aResIt)->data()->name()); + std::string aResName = Locale::Convert::toString((*aResIt)->data()->name()); myNames[*aResIt] = EntityName(aResName, aResName, false); aResultsWithNameOrColor.push_back(*aResIt); } @@ -1093,7 +1095,7 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const std::string& theStrin ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const std::wstring& theString) { - *myDumpStorage << ModelAPI_Tools::toString(theString); + *myDumpStorage << Locale::Convert::toString(theString); return *this; } diff --git a/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp b/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp index 6bbc96cec..38d839ed5 100644 --- a/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp +++ b/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp @@ -46,6 +46,8 @@ #include #include +#include + #include #include @@ -75,7 +77,7 @@ ModelHighAPI_FeatureStore::ModelHighAPI_FeatureStore(ObjectPtr theObject) { std::string ModelHighAPI_FeatureStore::compare(ObjectPtr theObject) { std::string anError = compareData(theObject->data(), myAttrs); if (!anError.empty()) { - return "Features '" + ModelAPI_Tools::toString(theObject->data()->name()) + + return "Features '" + Locale::Convert::toString(theObject->data()->name()) + "' differ:" + anError; } @@ -88,13 +90,13 @@ std::string ModelHighAPI_FeatureStore::compare(ObjectPtr theObject) { for(; aRes != allResults.end() && aResIter != myRes.end(); aRes++, aResIter++) { anError = compareData((*aRes)->data(), *aResIter); if (!anError.empty()) - return "Results of feature '" + ModelAPI_Tools::toString(aFeature->name()) + - "' '" + ModelAPI_Tools::toString((*aRes)->data()->name()) + + return "Results of feature '" + Locale::Convert::toString(aFeature->name()) + + "' '" + Locale::Convert::toString((*aRes)->data()->name()) + "' differ:" + anError; } if (aRes != allResults.end()) { return "Current model has more results '" + - ModelAPI_Tools::toString((*aRes)->data()->name()) + "'"; + Locale::Convert::toString((*aRes)->data()->name()) + "'"; } if (aResIter != myRes.end()) { return "Original model had more results '" + (*aResIter)["__name__"] + "'"; @@ -107,7 +109,7 @@ void ModelHighAPI_FeatureStore::storeData(std::shared_ptr theData std::map& theAttrs) { // store name to keep also this information and output if needed - theAttrs["__name__"] = ModelAPI_Tools::toString(theData->name()); + theAttrs["__name__"] = Locale::Convert::toString(theData->name()); std::list > allAttrs = theData->attributes(""); std::list >::iterator anAttr = allAttrs.begin(); for(; anAttr != allAttrs.end(); anAttr++) { @@ -193,7 +195,7 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) { ResultPtr aRes = ModelAPI_Tools::findPartResult(aDoc, anAttr->value()); if (aRes.get()) { // Part result name (the same as saved file name) - aResult<< ModelAPI_Tools::toString(aRes->data()->name()); + aResult<< Locale::Convert::toString(aRes->data()->name()); } } else { aResult<kind(); // PartSet @@ -247,7 +249,7 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) { AttributeReferencePtr anAttr = std::dynamic_pointer_cast(theAttr); if (anAttr->value().get()) { - aResult<< ModelAPI_Tools::toString(anAttr->value()->data()->name()); + aResult<< Locale::Convert::toString(anAttr->value()->data()->name()); } else { aResult<<"__empty__"; } @@ -255,7 +257,7 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) { AttributeSelectionPtr anAttr = std::dynamic_pointer_cast(theAttr); if (anAttr->context().get()) - aResult<< ModelAPI_Tools::toString(anAttr->namingName()); + aResult<< Locale::Convert::toString(anAttr->namingName()); else aResult<<"__notinitialized__"; } else if (aType == ModelAPI_AttributeSelectionList::typeId()) { @@ -264,14 +266,14 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) { for(int a = 0; a < anAttr->size(); a++) { if (a != 0) aResult<<" "; - aResult<< ModelAPI_Tools::toString(anAttr->value(a)->namingName()); + aResult<< Locale::Convert::toString(anAttr->value(a)->namingName()); } } else if (aType == ModelAPI_AttributeRefAttr::typeId()) { AttributeRefAttrPtr anAttr = std::dynamic_pointer_cast(theAttr); ObjectPtr anObj = anAttr->isObject() ? anAttr->object() : anAttr->attr()->owner(); if (anObj.get()) { - aResult<< ModelAPI_Tools::toString(anObj->data()->name()); + aResult<< Locale::Convert::toString(anObj->data()->name()); if (!anAttr->isObject()) { aResult<<" "<attr()->id(); } @@ -297,7 +299,7 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) { if (aStr == "SketchConstraint") continue; // no need to dump and check constraints } - aResList.push_back(ModelAPI_Tools::toString((*aL)->data()->name())); + aResList.push_back(Locale::Convert::toString((*aL)->data()->name())); } else if (!isSketchFeatures) { aResList.push_back("__empty__"); } @@ -317,7 +319,7 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) { aResult<<" "; ObjectPtr anObj = aL->second.get() ? aL->second->owner() : aL->first; if (anObj.get()) { - aResult<< ModelAPI_Tools::toString(anObj->data()->name()); + aResult<< Locale::Convert::toString(anObj->data()->name()); if (aL->second.get()) { aResult<<" "<second->id(); } diff --git a/src/ModelHighAPI/ModelHighAPI_Tools.cpp b/src/ModelHighAPI/ModelHighAPI_Tools.cpp index 0eed22d58..f3a280488 100644 --- a/src/ModelHighAPI/ModelHighAPI_Tools.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Tools.cpp @@ -29,6 +29,8 @@ #include #include //-------------------------------------------------------------------------------------- +#include +//-------------------------------------------------------------------------------------- #include #include #include @@ -415,7 +417,7 @@ std::string storeFeatures(const std::wstring& theDocName, DocumentPtr theDoc, if (theCompare) { aDocFind = theStore.find(theDocName); if (aDocFind == theStore.end()) { - return "Document '" + ModelAPI_Tools::toString(theDocName) + "' not found"; + return "Document '" + Locale::Convert::toString(theDocName) + "' not found"; } } // store the model features information: iterate all features @@ -439,12 +441,12 @@ std::string storeFeatures(const std::wstring& theDocName, DocumentPtr theDoc, std::map::iterator anObjFind = aDocFind->second.find(anObject->data()->name()); if (anObjFind == aDocFind->second.end()) { - return "Document '" + ModelAPI_Tools::toString(theDocName) - + "' feature '" + ModelAPI_Tools::toString(anObject->data()->name()) + "' not found"; + return "Document '" + Locale::Convert::toString(theDocName) + + "' feature '" + Locale::Convert::toString(anObject->data()->name()) + "' not found"; } std::string anError = anObjFind->second.compare(anObject); if (!anError.empty()) { - anError = "Document " + ModelAPI_Tools::toString(theDocName) + " " + anError; + anError = "Document " + Locale::Convert::toString(theDocName) + " " + anError; return anError; } anObjectsCount++; @@ -483,9 +485,9 @@ std::string storeFeatures(const std::wstring& theDocName, DocumentPtr theDoc, aLostName = aLostIter->first; } } - return "For document '" + ModelAPI_Tools::toString(theDocName) + + return "For document '" + Locale::Convert::toString(theDocName) + "' the number of features is decreased, there is no feature '" + - ModelAPI_Tools::toString(aLostName) + "'"; + Locale::Convert::toString(aLostName) + "'"; } } return ""; // ok @@ -539,7 +541,7 @@ static bool checkDump(SessionPtr theSession, // compare with the stored data std::string anError = - storeFeatures(ModelAPI_Tools::toWString(theSession->moduleDocument()->kind()), + storeFeatures(Locale::Convert::toWString(theSession->moduleDocument()->kind()), theSession->moduleDocument(), theStorage, true); if (!anError.empty()) { std::cout << anError << std::endl; @@ -580,7 +582,7 @@ bool checkPyDump(const std::string& theFilenameNaming, // map from document name to feature name to feature data std::map > aStore; std::string anError = - storeFeatures(ModelAPI_Tools::toWString(aSession->moduleDocument()->kind()), + storeFeatures(Locale::Convert::toWString(aSession->moduleDocument()->kind()), aSession->moduleDocument(), aStore, false); if (!anError.empty()) { Events_InfoMessage anErrorMsg(std::string("checkPythonDump"), anError); diff --git a/src/ParametersPlugin/CMakeLists.txt b/src/ParametersPlugin/CMakeLists.txt index 8887619f9..c0d5a7544 100644 --- a/src/ParametersPlugin/CMakeLists.txt +++ b/src/ParametersPlugin/CMakeLists.txt @@ -22,7 +22,10 @@ INCLUDE(UnitTest) INCLUDE(UseQtExt) # additional include directories -INCLUDE_DIRECTORIES(${QT_INCLUDES}) +INCLUDE_DIRECTORIES( + ../Locale + ${QT_INCLUDES} +) # additional preprocessor / compiler flags ADD_DEFINITIONS(${QT_DEFINITIONS}) @@ -68,6 +71,7 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Events SET(PROJECT_LIBRARIES Events Config + Locale ModelAPI ModuleBase ${QT_LIBRARIES} diff --git a/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp b/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp index dec451209..6f0efee2c 100644 --- a/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp +++ b/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp @@ -24,6 +24,8 @@ #include +#include + #include #include #include @@ -244,16 +246,16 @@ bool isValidAttribute(const AttributePtr& theAttribute) void setParameterName(ResultParameterPtr theResultParameter, const std::string& theName) { bool aWasBlocked = theResultParameter->data()->blockSendAttributeUpdated(true); - theResultParameter->data()->setName(ModelAPI_Tools::toWString(theName)); + theResultParameter->data()->setName(Locale::Convert::toWString(theName)); theResultParameter->data()->blockSendAttributeUpdated(aWasBlocked, false); std::shared_ptr aParameter = std::dynamic_pointer_cast( ModelAPI_Feature::feature(theResultParameter)); - std::string anOldName = ModelAPI_Tools::toString(aParameter->name()); + std::string anOldName = Locale::Convert::toString(aParameter->name()); aWasBlocked = aParameter->data()->blockSendAttributeUpdated(true); - aParameter->data()->setName(ModelAPI_Tools::toWString(theName)); + aParameter->data()->setName(Locale::Convert::toWString(theName)); aParameter->string(ParametersPlugin_Parameter::VARIABLE_ID())->setValue(theName); aParameter->data()->blockSendAttributeUpdated(aWasBlocked); } @@ -295,28 +297,29 @@ void ParametersPlugin_EvalListener::processObjectRenamedEvent( ModuleBase_Tools::translate(aMsg), QMessageBox::No | QMessageBox::Yes, QMessageBox::No); if (aRes != QMessageBox::Yes) { - setParameterName(aResultParameter, ModelAPI_Tools::toString(aMessage->oldName())); + setParameterName(aResultParameter, Locale::Convert::toString(aMessage->oldName())); return; } } // try to update the parameter feature according the new name - setParameterName(aResultParameter, ModelAPI_Tools::toString(aMessage->newName())); + setParameterName(aResultParameter, Locale::Convert::toString(aMessage->newName())); if (!isValidAttribute(aParameter->string(ParametersPlugin_Parameter::VARIABLE_ID()))) { //setParameterName(aResultParameter, aMessage->oldName()); if (myOldNames.find(aParameter.get()) == myOldNames.end()) - myOldNames[aParameter.get()] = ModelAPI_Tools::toString(aMessage->oldName()); + myOldNames[aParameter.get()] = Locale::Convert::toString(aMessage->oldName()); return; } - std::string anOldName = ModelAPI_Tools::toString(aMessage->oldName()); + std::string anOldName = Locale::Convert::toString(aMessage->oldName()); if (myOldNames.find(aParameter.get()) != myOldNames.end()) { anOldName = myOldNames[aParameter.get()]; myOldNames.erase(aParameter.get()); aParameter->execute(); // to enable result because of previously incorrect name } - renameInDependents(aResultParameter, anOldName, ModelAPI_Tools::toString(aMessage->newName())); + renameInDependents(aResultParameter, anOldName, + Locale::Convert::toString(aMessage->newName())); } void ParametersPlugin_EvalListener::processReplaceParameterEvent( @@ -341,6 +344,7 @@ void ParametersPlugin_EvalListener::processReplaceParameterEvent( double aRealValue = aResultParameter->data()->real(ModelAPI_ResultParameter::VALUE())->value(); std::string aValue = toStdString(aRealValue); - renameInDependents(aResultParameter, ModelAPI_Tools::toString(aResultParameter->data()->name()), - aValue); + renameInDependents(aResultParameter, + Locale::Convert::toString(aResultParameter->data()->name()), + aValue); } diff --git a/src/ParametersPlugin/ParametersPlugin_Parameter.cpp b/src/ParametersPlugin/ParametersPlugin_Parameter.cpp index b49507bef..ac993a9cb 100644 --- a/src/ParametersPlugin/ParametersPlugin_Parameter.cpp +++ b/src/ParametersPlugin/ParametersPlugin_Parameter.cpp @@ -21,6 +21,8 @@ #include "ParametersPlugin_Parameter.h" +#include + #include #include #include @@ -74,11 +76,11 @@ void ParametersPlugin_Parameter::attributeChanged(const std::string& theID) void ParametersPlugin_Parameter::updateName() { std::string aName = string(VARIABLE_ID())->value(); - data()->setName(ModelAPI_Tools::toWString(aName)); + data()->setName(Locale::Convert::toWString(aName)); ResultParameterPtr aParam = document()->createParameter(data()); - std::string anOldName = ModelAPI_Tools::toString(aParam->data()->name()); - aParam->data()->setName(ModelAPI_Tools::toWString(aName)); + std::string anOldName = Locale::Convert::toString(aParam->data()->name()); + aParam->data()->setName(Locale::Convert::toWString(aName)); setResult(aParam); diff --git a/src/ParametersPlugin/ParametersPlugin_Validators.cpp b/src/ParametersPlugin/ParametersPlugin_Validators.cpp index 47b5ac0b2..d8ccf52f9 100644 --- a/src/ParametersPlugin/ParametersPlugin_Validators.cpp +++ b/src/ParametersPlugin/ParametersPlugin_Validators.cpp @@ -23,6 +23,8 @@ #include +#include + #include #include #include @@ -71,7 +73,7 @@ bool ParametersPlugin_VariableValidator::isUnique(const AttributePtr& theAttribu for (int anIndex = 0, aSize = aDocument->size(ModelAPI_ResultParameter::group()); anIndex < aSize; ++anIndex) { ObjectPtr aParamObj = aDocument->object(ModelAPI_ResultParameter::group(), anIndex); - if (ModelAPI_Tools::toString(aParamObj->data()->name()) != theString) + if (Locale::Convert::toString(aParamObj->data()->name()) != theString) continue; ResultParameterPtr aParam = std::dynamic_pointer_cast(aParamObj); if (!aParam.get()) diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 9f87f6c3f..d188c8dd8 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -131,6 +131,7 @@ SET(PROJECT_LIBRARIES ModuleBase ModelGeomAlgo Config + Locale GeomAPI GeomDataAPI SketcherPrs @@ -165,6 +166,7 @@ SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES} ${PROJECT_RESOURCES}) INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/XGUI ${PROJECT_SOURCE_DIR}/src/Config ${PROJECT_SOURCE_DIR}/src/Events + ${PROJECT_SOURCE_DIR}/src/Locale ${PROJECT_SOURCE_DIR}/src/ModuleBase ${PROJECT_SOURCE_DIR}/src/ModelAPI ${PROJECT_SOURCE_DIR}/src/ModelGeomAlgo diff --git a/src/PartSet/PartSet_Validators.cpp b/src/PartSet/PartSet_Validators.cpp index 76c8e6156..da53f90fc 100644 --- a/src/PartSet/PartSet_Validators.cpp +++ b/src/PartSet/PartSet_Validators.cpp @@ -53,6 +53,8 @@ #include #include +#include + #include #include #ifdef _DEBUG @@ -436,7 +438,7 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute if (isObject) { if (aRef->object() == anObject) { theError = errorMessage(EqualObjects, - anObject.get() ? ModelAPI_Tools::toString(anObject->data()->name()) : "", + anObject.get() ? Locale::Convert::toString(anObject->data()->name()) : "", theAttribute->id(), aRef->id()); return false; } @@ -514,7 +516,7 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute // check the object is already presented if (aRef->value() == anObject) { theError = errorMessage(EqualObjects, - anObject.get() ? ModelAPI_Tools::toString(anObject->data()->name()) : "", + anObject.get() ? Locale::Convert::toString(anObject->data()->name()) : "", theAttribute->id(), aRef->id()); return false; } @@ -611,7 +613,7 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute if (aCurSelObject == aRefSelList->object(j)) { theError = errorMessage(EqualObjects, aCurSelObject.get()? - ModelAPI_Tools::toString(aCurSelObject->data()->name()) : "", + Locale::Convert::toString(aCurSelObject->data()->name()) : "", theAttribute->id(), aCurSelList->id()); return false; } diff --git a/src/Selector/CMakeLists.txt b/src/Selector/CMakeLists.txt index 573dff40b..aa649d287 100644 --- a/src/Selector/CMakeLists.txt +++ b/src/Selector/CMakeLists.txt @@ -49,9 +49,11 @@ SET(PROJECT_SOURCES ) SET(PROJECT_LIBRARIES + Locale ${OpenCASCADE_ApplicationFramework_LIBRARIES} ) SET(PROJECT_INCLUDES + ../Locale ${OpenCASCADE_INCLUDE_DIR} ) diff --git a/src/Selector/Selector_Modify.cpp b/src/Selector/Selector_Modify.cpp index 149a8e89d..08ad66b0e 100644 --- a/src/Selector/Selector_Modify.cpp +++ b/src/Selector/Selector_Modify.cpp @@ -22,6 +22,8 @@ #include #include +#include + #include #include #include @@ -331,17 +333,17 @@ std::wstring Selector_Modify::name(Selector_NameGenerator* theNameGenerator) if (!myFinal.FindAttribute(TDataStd_Name::GetID(), aName)) return L""; aResult += theNameGenerator->contextName(myFinal) + L"/"; - aResult += (wchar_t*)aName->Get().ToExtString(); + aResult += Locale::Convert::toWString(aName->Get().ToExtString()); for(TDF_LabelList::iterator aBase = myBases.begin(); aBase != myBases.end(); aBase++) { if (!aBase->FindAttribute(TDataStd_Name::GetID(), aName)) return L""; aResult += L"&"; aResult += theNameGenerator->contextName(*aBase) + L"/"; - aResult += (wchar_t*)aName->Get().ToExtString(); + aResult += Locale::Convert::toWString(aName->Get().ToExtString()); } if (myWeakIndex != -1) { std::wostringstream aWeakStr; - aWeakStr<<"&"< +#include + #include #include @@ -80,7 +82,7 @@ std::wstring Selector_Primitive::name(Selector_NameGenerator* theNameGenerator) std::wstring aResult = theNameGenerator->contextName(myFinal); if (!aResult.empty()) { aResult += L"/"; - aResult += ((wchar_t*)aName->Get().ToExtString()); + aResult += Locale::Convert::toWString(aName->Get().ToExtString()); } return aResult; } diff --git a/src/SketchAPI/CMakeLists.txt b/src/SketchAPI/CMakeLists.txt index 3b5b81347..bb8848804 100644 --- a/src/SketchAPI/CMakeLists.txt +++ b/src/SketchAPI/CMakeLists.txt @@ -72,6 +72,7 @@ SET(PROJECT_SOURCES SET(PROJECT_LIBRARIES GeomAlgoAPI + Locale ModelAPI ModelHighAPI SketcherPrs @@ -88,8 +89,8 @@ INCLUDE_DIRECTORIES( # Plugin headers dependency INCLUDE_DIRECTORIES( - # TODO(spo): modify ConstructionPlugin headers to remove dependency on GeomAPI headers ${PROJECT_SOURCE_DIR}/src/Config + ${PROJECT_SOURCE_DIR}/src/Locale ${PROJECT_SOURCE_DIR}/src/GeomAPI ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI ${PROJECT_SOURCE_DIR}/src/SketchPlugin diff --git a/src/SketchAPI/SketchAPI_BSpline.cpp b/src/SketchAPI/SketchAPI_BSpline.cpp index c6667c55f..361f28be6 100644 --- a/src/SketchAPI/SketchAPI_BSpline.cpp +++ b/src/SketchAPI/SketchAPI_BSpline.cpp @@ -24,6 +24,8 @@ #include +#include + #include #include #include @@ -155,7 +157,7 @@ static void createPole(const CompositeFeaturePtr& theSketch, aPointFeature->execute(); std::wostringstream aName; - aName << theBSpline->name() << "_" << ModelAPI_Tools::toWString(thePoles->id()) + aName << theBSpline->name() << "_" << Locale::Convert::toWString(thePoles->id()) << "_" << thePoleIndex; aPointFeature->data()->setName(aName.str()); aPointFeature->lastResult()->data()->setName(aName.str()); diff --git a/src/SketchAPI/SketchAPI_Ellipse.cpp b/src/SketchAPI/SketchAPI_Ellipse.cpp index d05222b9f..88db2ec9a 100644 --- a/src/SketchAPI/SketchAPI_Ellipse.cpp +++ b/src/SketchAPI/SketchAPI_Ellipse.cpp @@ -21,6 +21,8 @@ #include +#include + #include #include #include @@ -209,7 +211,7 @@ static void createPoint(const CompositeFeaturePtr& theSketch, aPointFeature->reference(SketchPlugin_Point::PARENT_ID())->setValue(theEllipse); aPointFeature->execute(); - std::wstring aName = theEllipse->name() + L"_" + ModelAPI_Tools::toWString(theCoincident); + std::wstring aName = theEllipse->name() + L"_" + Locale::Convert::toWString(theCoincident); aPointFeature->data()->setName(aName); aPointFeature->lastResult()->data()->setName(aName); diff --git a/src/SketchPlugin/CMakeLists.txt b/src/SketchPlugin/CMakeLists.txt index 6a281bc4d..b6362a29b 100644 --- a/src/SketchPlugin/CMakeLists.txt +++ b/src/SketchPlugin/CMakeLists.txt @@ -137,11 +137,12 @@ SET(PROJECT_LIBRARIES Config GeomAPI GeomAlgoAPI + GeomDataAPI + Locale ModelAPI ModelGeomAlgo ModuleBase SketcherPrs - GeomDataAPI ) SET(XML_RESOURCES @@ -168,6 +169,7 @@ TARGET_LINK_LIBRARIES(SketchPlugin ${PROJECT_LIBRARIES}) INCLUDE_DIRECTORIES( ../Config ../Events + ../Locale ../ModelAPI ../ModelGeomAlgo ../ModuleBase diff --git a/src/SketchPlugin/SketchPlugin_MacroBSpline.cpp b/src/SketchPlugin/SketchPlugin_MacroBSpline.cpp index 4aa8f5418..497288dfb 100644 --- a/src/SketchPlugin/SketchPlugin_MacroBSpline.cpp +++ b/src/SketchPlugin/SketchPlugin_MacroBSpline.cpp @@ -27,6 +27,8 @@ #include #include +#include + #include #include #include @@ -270,7 +272,7 @@ void SketchPlugin_MacroBSpline::assignDefaultNameForAux(FeaturePtr theAuxFeature std::wostringstream aName; aName << aBSpline->name(); if (theAuxFeature->getKind() == SketchPlugin_Point::ID()) - aName << "_" << ModelAPI_Tools::toWString(theBSplinePoles->id()) << "_" << thePoleIndex1; + aName << "_" << Locale::Convert::toWString(theBSplinePoles->id()) << "_" << thePoleIndex1; else aName << "_segment_" << thePoleIndex1 << "_" << thePoleIndex2; diff --git a/src/SketchPlugin/SketchPlugin_Split.cpp b/src/SketchPlugin/SketchPlugin_Split.cpp index f6b5b88ec..98ce50d10 100644 --- a/src/SketchPlugin/SketchPlugin_Split.cpp +++ b/src/SketchPlugin/SketchPlugin_Split.cpp @@ -28,6 +28,8 @@ #include #include +#include + #include #include #include @@ -1389,7 +1391,7 @@ std::string SketchPlugin_Split::getFeatureInfo(const std::shared_ptrdata()->isValid()) - anInfo.append(ModelAPI_Tools::toString(theFeature->data()->name())); + anInfo.append(Locale::Convert::toString(theFeature->data()->name())); if (isUseAttributesInfo) { std::string aPointsInfo = ModelGeomAlgo_Point2D::getPontAttributesInfo(theFeature, diff --git a/src/SketchPlugin/SketchPlugin_Tools.cpp b/src/SketchPlugin/SketchPlugin_Tools.cpp index fd1475aca..b5db72f77 100644 --- a/src/SketchPlugin/SketchPlugin_Tools.cpp +++ b/src/SketchPlugin/SketchPlugin_Tools.cpp @@ -37,6 +37,8 @@ #include +#include + #include #include #include @@ -528,7 +530,7 @@ void createAuxiliaryPointOnEllipse(const FeaturePtr& theEllipseFeature, aPointFeature->execute(); std::wstring aName = theEllipseFeature->name() + L"_" + - ModelAPI_Tools::toWString(theEllipsePoint); + Locale::Convert::toWString(theEllipsePoint); aPointFeature->data()->setName(aName); aPointFeature->lastResult()->data()->setName(aName); diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index 883c0cbb1..42220392d 100644 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -46,6 +46,8 @@ #include +#include + #include #include #include @@ -329,7 +331,8 @@ bool SketchPlugin_NotFixedValidator::isValid(const AttributePtr& theAttribute, } else if (aRefAttr->attr() == aRAttr->attr()) { AttributePtr anAttribute = aRefAttr->attr(); - std::wstring aName = anAttribute.get() ? ModelAPI_Tools::toWString(anAttribute->id()) : L""; + std::wstring aName = + anAttribute.get() ? Locale::Convert::toWString(anAttribute->id()) : L""; theError = "The attribute %1 has been already fixed."; theError.arg(aName); return false; -- 2.30.2