Fix build.

This commit is contained in:
Roman Telezhynskyi 2023-08-22 15:16:20 +03:00
parent 5f091344fa
commit 904c18a7f9
14 changed files with 60285 additions and 60492 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,12 +1,14 @@
#ifndef DRW_CPTABLES_H
#define DRW_CPTABLES_H
#include <array>
//first entry in all tables are 0x80
#define CPOFFSET 0x80
#define CPLENGTHCOMMON 128
constexpr int CPLENGTHCOMMON = 128;
//Table 874
static const int DRW_Table874[] = {
static const std::array<int, CPLENGTHCOMMON> DRW_Table874 = {
0x20AC, //1 #EURO SIGN
0x00 , //2 #UNDEFINED
0x00 , //3 #UNDEFINED
@ -138,7 +140,7 @@ static const int DRW_Table874[] = {
};
//Table 1250
static const int DRW_Table1250[] = {
static const std::array<int, CPLENGTHCOMMON> DRW_Table1250 = {
0x20AC, //1 #EURO SIGN
0x00, //2 #UNDEFINED
0x201A, //3 #SINGLE LOW-9 QUOTATION MARK
@ -271,7 +273,7 @@ static const int DRW_Table1250[] = {
//Table 1251
static const int DRW_Table1251[] = {
static const std::array<int, CPLENGTHCOMMON> DRW_Table1251 = {
0x0402, //1 #CYRILLIC CAPITAL LETTER DJE
0x0403, //2 #CYRILLIC CAPITAL LETTER GJE
0x201A, //3 #SINGLE LOW-9 QUOTATION MARK
@ -404,7 +406,7 @@ static const int DRW_Table1251[] = {
//Table 1252
static const int DRW_Table1252[] = {
static const std::array<int, CPLENGTHCOMMON> DRW_Table1252 = {
0x20AC, //1 #EURO SIGN
0x00, //2 #UNDEFINED
0x201A, //3 #SINGLE LOW-9 QUOTATION MARK
@ -536,7 +538,7 @@ static const int DRW_Table1252[] = {
};
//Table 1253
static const int DRW_Table1253[] = {
static const std::array<int, CPLENGTHCOMMON> DRW_Table1253 = {
0x20AC, //1 #EURO SIGN
0x00 , //2 #UNDEFINED
0x201A, //3 #SINGLE LOW-9 QUOTATION MARK
@ -668,7 +670,7 @@ static const int DRW_Table1253[] = {
};
//Table 1254
static const int DRW_Table1254[] = {
static const std::array<int, CPLENGTHCOMMON> DRW_Table1254 = {
0x20AC, //1 #EURO SIGN
0x00 , //2 #UNDEFINED
0x201A, //3 #SINGLE LOW-9 QUOTATION MARK
@ -800,7 +802,7 @@ static const int DRW_Table1254[] = {
};
//Table 1255
static const int DRW_Table1255[] = {
static const std::array<int, CPLENGTHCOMMON> DRW_Table1255 = {
0x20AC, //1 #EURO SIGN
0x00 , //2 #UNDEFINED
0x201A, //3 #SINGLE LOW-9 QUOTATION MARK
@ -932,7 +934,7 @@ static const int DRW_Table1255[] = {
};
//Table 1256
static const int DRW_Table1256[] = {
static const std::array<int, CPLENGTHCOMMON> DRW_Table1256 = {
0x20AC, //1 #EURO SIGN
0x067E, //2 #ARABIC LETTER PEH
0x201A, //3 #SINGLE LOW-9 QUOTATION MARK
@ -1064,7 +1066,7 @@ static const int DRW_Table1256[] = {
};
//Table 1257
static const int DRW_Table1257[] = {
static const std::array<int, CPLENGTHCOMMON> DRW_Table1257 = {
0x20AC, //1 #EURO SIGN
0x00 , //2 #UNDEFINED
0x201A, //3 #SINGLE LOW-9 QUOTATION MARK
@ -1196,7 +1198,7 @@ static const int DRW_Table1257[] = {
};
//Table 1258
static const int DRW_Table1258[] = {
static const std::array<int, CPLENGTHCOMMON> DRW_Table1258 = {
0x20AC, //1 #EURO SIGN
0x00 , //2 #UNDEFINED
0x201A, //3 #SINGLE LOW-9 QUOTATION MARK

View file

@ -6,8 +6,10 @@
#include "drw_cptable950.h"
#include "drw_cptables.h"
#include <QDebug>
#include <QSet>
#include <QString>
#include <algorithm>
#include <cstddef>
#include <cstring>
#include <iomanip>
#include <memory>
@ -15,7 +17,7 @@
DRW_TextCodec::DRW_TextCodec()
: version(DRW::AC1021),
conv(new DRW_Converter(nullptr, 0))
conv(new DRW_Converter())
{
}
@ -98,7 +100,7 @@ void DRW_TextCodec::setCodePage(const std::string &c, bool dxfFormat)
{
if (cp == "ANSI_874")
{
conv = std::make_unique<DRW_ConvTable>(DRW_Table874, CPLENGTHCOMMON);
conv = std::make_unique<DRW_ConvTable>(DRW_Table874);
}
else if (cp == "ANSI_932")
{
@ -106,63 +108,63 @@ void DRW_TextCodec::setCodePage(const std::string &c, bool dxfFormat)
}
else if (cp == "ANSI_936")
{
conv = std::make_unique<DRW_ConvDBCSTable>(DRW_Table936, DRW_LeadTable936, DRW_DoubleTable936, CPLENGTH936);
conv = std::make_unique<DRW_ConvDBCSTable<CPLENGTH936>>(DRW_LeadTable936, DRW_DoubleTable936);
}
else if (cp == "ANSI_949")
{
conv = std::make_unique<DRW_ConvDBCSTable>(DRW_Table949, DRW_LeadTable949, DRW_DoubleTable949, CPLENGTH949);
conv = std::make_unique<DRW_ConvDBCSTable<CPLENGTH949>>(DRW_LeadTable949, DRW_DoubleTable949);
}
else if (cp == "ANSI_950")
{
conv = std::make_unique<DRW_ConvDBCSTable>(DRW_Table950, DRW_LeadTable950, DRW_DoubleTable950, CPLENGTH950);
conv = std::make_unique<DRW_ConvDBCSTable<CPLENGTH950>>(DRW_LeadTable950, DRW_DoubleTable950);
}
else if (cp == "ANSI_1250")
{
conv = std::make_unique<DRW_ConvTable>(DRW_Table1250, CPLENGTHCOMMON);
conv = std::make_unique<DRW_ConvTable>(DRW_Table1250);
}
else if (cp == "ANSI_1251")
{
conv = std::make_unique<DRW_ConvTable>(DRW_Table1251, CPLENGTHCOMMON);
conv = std::make_unique<DRW_ConvTable>(DRW_Table1251);
}
else if (cp == "ANSI_1253")
{
conv = std::make_unique<DRW_ConvTable>(DRW_Table1253, CPLENGTHCOMMON);
conv = std::make_unique<DRW_ConvTable>(DRW_Table1253);
}
else if (cp == "ANSI_1254")
{
conv = std::make_unique<DRW_ConvTable>(DRW_Table1254, CPLENGTHCOMMON);
conv = std::make_unique<DRW_ConvTable>(DRW_Table1254);
}
else if (cp == "ANSI_1255")
{
conv = std::make_unique<DRW_ConvTable>(DRW_Table1255, CPLENGTHCOMMON);
conv = std::make_unique<DRW_ConvTable>(DRW_Table1255);
}
else if (cp == "ANSI_1256")
{
conv = std::make_unique<DRW_ConvTable>(DRW_Table1256, CPLENGTHCOMMON);
conv = std::make_unique<DRW_ConvTable>(DRW_Table1256);
}
else if (cp == "ANSI_1257")
{
conv = std::make_unique<DRW_ConvTable>(DRW_Table1257, CPLENGTHCOMMON);
conv = std::make_unique<DRW_ConvTable>(DRW_Table1257);
}
else if (cp == "ANSI_1258")
{
conv = std::make_unique<DRW_ConvTable>(DRW_Table1258, CPLENGTHCOMMON);
conv = std::make_unique<DRW_ConvTable>(DRW_Table1258);
}
else if (cp == "UTF-8")
{ // DXF older than 2007 are write in win codepages
cp = "ANSI_1252";
conv = std::make_unique<DRW_Converter>(nullptr, 0);
conv = std::make_unique<DRW_Converter>();
}
else
{
conv = std::make_unique<DRW_ConvTable>(DRW_Table1252, CPLENGTHCOMMON);
conv = std::make_unique<DRW_ConvTable>(DRW_Table1252);
}
}
else
{
if (dxfFormat)
{
conv = std::make_unique<DRW_Converter>(nullptr, 0); // utf16 to utf8
conv = std::make_unique<DRW_Converter>(); // utf16 to utf8
}
else
{
@ -187,7 +189,7 @@ auto DRW_TextCodec::correctCodePage(const std::string &s) -> std::string
std::string cp = s;
transform(cp.begin(), cp.end(), cp.begin(), toupper);
static auto map = QMap<std::string, QSet<std::string>>{
static auto map = QMap<std::string, QSet<QString>>{
// Latin/Thai
{"ANSI_874", {"ANSI_874", "CP874", "ISO8859-11", "TIS-620"}}, // Central Europe and Eastern Europe
{"ANSI_1250", {"ANSI_1250", "CP1250", "ISO8859-2"}}, // Cyrillic script
@ -217,7 +219,8 @@ auto DRW_TextCodec::correctCodePage(const std::string &s) -> std::string
auto i = map.constBegin();
while (i != map.constEnd())
{
if (i.value().contains(cp))
// TODO: Since Qt 6.1 possible to use std::string instead of QString
if (i.value().contains(QString::fromStdString(cp)))
{
return i.key();
}
@ -282,7 +285,7 @@ auto DRW_ConvTable::fromUtf8(const std::string &s) -> std::string
j = i + l;
i = j - 1;
notFound = true;
for (int k = 0; k < cpLength; k++)
for (size_t k = 0; k < table.size(); k++)
{
if (table[k] == code)
{
@ -432,7 +435,7 @@ auto DRW_Converter::decodeNum(const std::string &s, unsigned int *b) -> int
return code;
}
auto DRW_ConvDBCSTable::fromUtf8(const std::string &s) -> std::string
template <size_t DoubleTableSize> auto DRW_ConvDBCSTable<DoubleTableSize>::fromUtf8(const std::string &s) -> std::string
{
std::string result;
bool notFound;
@ -451,11 +454,11 @@ auto DRW_ConvDBCSTable::fromUtf8(const std::string &s) -> std::string
j = i + l;
i = j - 1;
notFound = true;
for (int k = 0; k < cpLength; k++)
for (const auto &row : doubleTable)
{
if (doubleTable[k][1] == code)
if (row[1] == code)
{
int data = doubleTable[k][0];
int data = row[0];
char d[3];
d[0] = static_cast<char>(data >> 8);
d[1] = static_cast<char>(data & 0xFF);
@ -476,7 +479,7 @@ auto DRW_ConvDBCSTable::fromUtf8(const std::string &s) -> std::string
return result;
}
auto DRW_ConvDBCSTable::toUtf8(const std::string &s) -> std::string
template <size_t DoubleTableSize> auto DRW_ConvDBCSTable<DoubleTableSize>::toUtf8(const std::string &s) -> std::string
{
std::string res;
for (auto it = s.begin(); it < s.end(); ++it)
@ -513,7 +516,7 @@ auto DRW_ConvDBCSTable::toUtf8(const std::string &s) -> std::string
int code = (c << 8) | static_cast<unsigned char>(*it);
int sta = leadTable[c - 0x81];
int end = leadTable[c - 0x80];
for (int k = sta; k < end; k++)
for (size_t k = static_cast<size_t>(sta); k < static_cast<size_t>(end); k++)
{
if (doubleTable[k][0] == code)
{
@ -533,11 +536,6 @@ auto DRW_ConvDBCSTable::toUtf8(const std::string &s) -> std::string
return res;
}
DRW_Conv932Table::DRW_Conv932Table()
: DRW_Converter(DRW_Table932, CPLENGTH932)
{
}
auto DRW_Conv932Table::fromUtf8(const std::string &s) -> std::string
{
std::string result;
@ -566,11 +564,11 @@ auto DRW_Conv932Table::fromUtf8(const std::string &s) -> std::string
if (notFound &&
(code < 0xF8 || (code > 0x390 && code < 0x542) || (code > 0x200F && code < 0x9FA1) || code > 0xF928))
{
for (int k = 0; k < cpLength; k++)
for (const auto &row : DRW_DoubleTable932)
{
if (DRW_DoubleTable932[k][1] == code)
if (row[1] == code)
{
int data = DRW_DoubleTable932[k][0];
int data = row[0];
char d[3];
d[0] = static_cast<char>(data >> 8);
d[1] = static_cast<char>(data & 0xFF);
@ -641,7 +639,7 @@ auto DRW_Conv932Table::toUtf8(const std::string &s) -> std::string
}
if (end > 0)
{
for (int k = sta; k < end; k++)
for (size_t k = static_cast<size_t>(sta); k < static_cast<size_t>(end); k++)
{
if (DRW_DoubleTable932[k][0] == code)
{

View file

@ -4,6 +4,7 @@
#include "../drw_base.h"
#include <QtCore/qcontainerfwd.h>
#include <QtGlobal>
#include <array>
#include <memory>
#include <string>
@ -40,12 +41,9 @@ private:
class DRW_Converter
{
public:
DRW_Converter(const int *t, int l)
: table{t},
cpLength{l}
{
}
DRW_Converter() = default;
virtual ~DRW_Converter() = default;
virtual auto fromUtf8(const std::string &s) -> std::string { return s; }
virtual auto toUtf8(const std::string &s) -> std::string;
@ -54,56 +52,75 @@ public:
static auto encodeNum(int c) -> std::string;
static auto decodeNum(const std::string &s, unsigned int *b) -> int;
const int *table{nullptr};
int cpLength;
private:
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(DRW_Converter) // NOLINT
};
class DRW_ConvUTF16 : public DRW_Converter
{
public:
DRW_ConvUTF16()
: DRW_Converter(nullptr, 0)
{
}
auto fromUtf8(const std::string &s) -> std::string override;
auto toUtf8(const std::string &s) -> std::string override;
};
class DRW_ConvTable : public DRW_Converter
{
public:
DRW_ConvTable(const int *t, int l)
: DRW_Converter(t, l)
{
}
auto fromUtf8(const std::string &s) -> std::string override;
auto toUtf8(const std::string &s) -> std::string override;
};
class DRW_ConvDBCSTable : public DRW_Converter
{
public:
DRW_ConvDBCSTable(const int *t, const int *lt, const int dt[][2], int l)
: DRW_Converter(t, l),
leadTable{lt},
doubleTable{dt}
{
}
DRW_ConvUTF16() = default;
~DRW_ConvUTF16() override = default;
auto fromUtf8(const std::string &s) -> std::string override;
auto toUtf8(const std::string &s) -> std::string override;
private:
const int *leadTable{nullptr};
const int (*doubleTable)[2];
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(DRW_ConvUTF16) // NOLINT
};
class DRW_ConvTable : public DRW_Converter
{
public:
explicit DRW_ConvTable(const std::array<int, 128> &t)
: table{t}
{
}
~DRW_ConvTable() override = default;
auto fromUtf8(const std::string &s) -> std::string override;
auto toUtf8(const std::string &s) -> std::string override;
private:
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(DRW_ConvTable) // NOLINT
const std::array<int, 128> &table;
};
template <size_t DoubleTableSize> class DRW_ConvDBCSTable : public DRW_Converter
{
public:
DRW_ConvDBCSTable(const std::array<int, 127> &lt, const std::array<std::array<int, 2>, DoubleTableSize> &dt)
: leadTable{lt},
doubleTable{dt}
{
}
~DRW_ConvDBCSTable() override = default;
auto fromUtf8(const std::string &s) -> std::string override;
auto toUtf8(const std::string &s) -> std::string override;
private:
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(DRW_ConvDBCSTable) // NOLINT
const std::array<int, 127> &leadTable;
const std::array<std::array<int, 2>, DoubleTableSize> &doubleTable;
};
class DRW_Conv932Table : public DRW_Converter
{
public:
DRW_Conv932Table();
DRW_Conv932Table() = default;
~DRW_Conv932Table() override = default;
auto fromUtf8(const std::string &s) -> std::string override;
auto toUtf8(const std::string &s) -> std::string override;
private:
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(DRW_Conv932Table) // NOLINT
};
#endif // DRW_TEXTCODEC_H

View file

@ -12,7 +12,6 @@
#include "libdxfrw.h"
#include "intern/drw_dbg.h"
#include "intern/drw_textcodec.h"
#include "intern/dxfreader.h"
#include "intern/dxfwriter.h"
#include <QScopedPointer>
@ -34,24 +33,7 @@
};*/
dxfRW::dxfRW(const char *name)
: version(),
fileName(name),
codePage(),
binFile(),
reader(nullptr),
writer(nullptr),
iface(),
header(),
nextentity(),
entCount(),
wlayer0(),
dimstyleStd(),
applyExt(false),
writingBlock(),
elParts(128), // parts number when convert ellipse to polyline
blockMap(),
imageDef(),
currHandle()
: fileName(name)
{
DRW_DBGSL(DRW_dbg::Level::None);
}
@ -60,8 +42,10 @@ dxfRW::~dxfRW()
{
delete reader;
delete writer;
for (std::vector<DRW_ImageDef *>::iterator it = imageDef.begin(); it != imageDef.end(); ++it)
delete *it;
for (auto &it : imageDef)
{
delete it;
}
imageDef.clear();
}
@ -3772,7 +3756,7 @@ auto dxfRW::getError() const -> DRW::error
return error;
}
auto dxfRW::setError(const DRW::error lastError) -> bool
auto dxfRW::setError(DRW::error lastError) -> bool
{
error = lastError;
return (DRW::BAD_NONE == error);

View file

@ -33,6 +33,7 @@ class dxfRW
public:
explicit dxfRW(const char *name);
~dxfRW();
static void setDebug(DRW::DebugLevel lvl);
/// reads the file specified in constructor
/*!
@ -136,32 +137,32 @@ private:
static auto toHexStr(int n) -> std::string; // RLZ removeme
auto writeAppData(const std::list<std::list<DRW_Variant>> &appData) -> bool;
auto setError(const DRW::error lastError) -> bool;
auto setError(DRW::error lastError) -> bool;
private:
DRW::Version version;
DRW::Version version{};
DRW::error error{DRW::BAD_NONE};
std::string fileName;
std::string codePage;
bool binFile;
std::string codePage{};
bool binFile{false};
bool m_xSpaceBlock{true};
dxfReader *reader;
dxfWriter *writer;
DRW_Interface *iface;
DRW_Header header;
dxfReader *reader{nullptr};
dxfWriter *writer{nullptr};
DRW_Interface *iface{nullptr};
DRW_Header header{};
// int section;
std::string nextentity;
int entCount;
bool wlayer0;
bool dimstyleStd;
bool applyExt;
bool writingBlock;
int elParts; /*!< parts number when convert ellipse to polyline */
std::unordered_map<std::string, int> blockMap;
std::unordered_map<std::string, int> textStyleMap;
std::vector<DRW_ImageDef *> imageDef; /*!< imageDef list */
std::string nextentity{};
int entCount{};
bool wlayer0{};
bool dimstyleStd{};
bool applyExt{false};
bool writingBlock{};
int elParts{128}; /*!< parts number when convert ellipse to polyline */
std::unordered_map<std::string, int> blockMap{};
std::unordered_map<std::string, int> textStyleMap{};
std::vector<DRW_ImageDef *> imageDef{}; /*!< imageDef list */
int currHandle;
int currHandle{};
std::string errorString{};
};

View file

@ -52,7 +52,6 @@ DEFINES += SRCDIR=\\\"$$PWD/\\\"
SOURCES += \
qttestmainlambda.cpp \
tst_dxf.cpp \
tst_vdomdocument.cpp \
tst_vposter.cpp \
tst_vspline.cpp \
@ -82,7 +81,6 @@ SOURCES += \
*msvc*:SOURCES += stable.cpp
HEADERS += \
tst_dxf.h \
tst_vdomdocument.h \
tst_vposter.h \
tst_vspline.h \

View file

@ -25,7 +25,6 @@ VTestApp {
files: [
"qttestmainlambda.cpp",
"tst_dxf.cpp",
"tst_vdomdocument.cpp",
"tst_vposter.cpp",
"tst_vspline.cpp",
@ -51,7 +50,6 @@ VTestApp {
"tst_vtranslatevars.cpp",
"tst_vabstractpiece.cpp",
"tst_vtooluniondetails.cpp",
"tst_dxf.h",
"tst_vdomdocument.h",
"tst_vposter.h",
"tst_vspline.h",

View file

@ -32,7 +32,7 @@
#include <xercesc/util/PlatformUtils.hpp>
#endif
#include "tst_dxf.h"
#include "../vmisc/testvapplication.h"
#include "tst_findpoint.h"
#include "tst_misc.h"
#include "tst_nameregexp.h"
@ -59,14 +59,10 @@
#include "tst_vtranslatevars.h"
#include "tst_xsdschema.h"
#include "../qmuparser/qmudef.h"
#include "../vmisc/def.h"
#include "../vmisc/testvapplication.h"
//---------------------------------------------------------------------------------------------------------------------
auto main(int argc, char **argv) -> int
{
Q_INIT_RESOURCE(schema);
Q_INIT_RESOURCE(schema); // NOLINT
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
XERCES_CPP_NAMESPACE::XMLPlatformUtils::Initialize();
@ -107,9 +103,9 @@ auto main(int argc, char **argv) -> int
ASSERT_TEST(new TST_ReadVal());
ASSERT_TEST(new TST_VTranslateVars());
ASSERT_TEST(new TST_VToolUnionDetails());
ASSERT_TEST(new TST_DXF());
ASSERT_TEST(new TST_XSDShema());
ASSERT_TEST(new TST_VSVGPathTokenizer());
ASSERT_TEST(new TST_VDomDocument());
return status;
}

View file

@ -1,134 +0,0 @@
/************************************************************************
**
** @file tst_dxf.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 15 1, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "tst_dxf.h"
#include <QtTest>
#include "../vmisc/compatibility.h"
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include "../vdxf/dxfdef.h"
#include "../vdxf/libdxfrw/intern/drw_textcodec.h"
#include "../vmisc/def.h"
#endif
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include "../vmisc/vtextcodec.h"
#else
#include <QTextCodec>
#endif
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
#include "../vmisc/backport/text.h"
#endif
namespace
{
//---------------------------------------------------------------------------------------------------------------------
auto AvailableCodecs() -> QStringList
{
QList<QByteArray> codecs = VTextCodec::availableCodecs();
QSet<QString> uniqueNames;
for (auto &codec : codecs)
{
uniqueNames.insert(codec);
}
return ConvertToList(uniqueNames);
}
} // namespace
//---------------------------------------------------------------------------------------------------------------------
TST_DXF::TST_DXF(QObject *parent)
: QObject(parent)
{
}
//---------------------------------------------------------------------------------------------------------------------
void TST_DXF::initTestCase()
{
QTextStream ts(stdout);
ts << QStringLiteral("Available codecs:\n%2.").arg(AvailableCodecs().join(", ")) << Qt::endl;
}
//---------------------------------------------------------------------------------------------------------------------
void TST_DXF::TestCodecPage_data()
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QTest::addColumn<QString>("locale");
QStringList locales = SupportedLocales();
for (auto &locale : locales)
{
QTest::newRow(locale.toLatin1()) << locale;
}
#endif
}
//---------------------------------------------------------------------------------------------------------------------
void TST_DXF::TestCodecPage()
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QFETCH(QString, locale);
static QMap<QString, QString> locMap = LocaleMap();
locMap.insert("en", "ISO8859-1");
locMap.insert("en_US", "ISO8859-1");
locMap.insert("en_CA", "ISO8859-1");
locMap.insert("en_IN", "ISO8859-1");
QString language = QLocale(locale).name();
QVERIFY(locMap.contains(language));
QString codePage = locMap.value(language);
codePage = codePage.toUpper();
QMap<QString, QStringList> codeMap = DRW_TextCodec::DXFCodePageMap();
QString dxfCodePage;
auto i = codeMap.constBegin();
while (i != codeMap.constEnd())
{
if (i.value().contains(codePage))
{
dxfCodePage = i.key();
break;
}
++i;
}
QVERIFY(not dxfCodePage.isEmpty());
VTextCodec *codec = DRW_TextCodec::CodecForName(dxfCodePage);
QVERIFY2(codec != nullptr, qUtf8Printable(QStringLiteral("No codec for dxf codepage %1 found.").arg(dxfCodePage)));
#else
QSKIP("No full support for old codecs since Qt6.");
#endif
}

View file

@ -1,53 +0,0 @@
/************************************************************************
**
** @file tst_dxf.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 15 1, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef TST_DXF_H
#define TST_DXF_H
#include <QObject>
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
#include "../vmisc/defglobal.h"
#endif
class TST_DXF :public QObject
{
Q_OBJECT // NOLINT
public:
explicit TST_DXF(QObject *parent = nullptr);
~TST_DXF() override = default;
private slots:
void initTestCase();
void TestCodecPage_data();
void TestCodecPage();
private:
Q_DISABLE_COPY_MOVE(TST_DXF) // NOLINT
};
#endif // TST_DXF_H