Commit 4d519e8f authored by ElenaSubbotina's avatar ElenaSubbotina

x2t - version up, ..

parent 1bd2c0b8
......@@ -35,10 +35,6 @@ INCLUDEPATH += \
../../../DesktopEditor/xml/libxml2/include
core_mac {
DEFINES += \
_ASC_USE_UNICODE_CONVERTER_ \
UNICODECONVERTER_USE_DYNAMIC_LIBRARY
LIBS += $$DESTDIR -lUnicodeConverter
}
......
......@@ -36,9 +36,7 @@
#include "../../../Common/FileWriter.h"
#include "../../../Common/DocxFormat/Source/XML/Utils.h"
#ifdef _ASC_USE_UNICODE_CONVERTER_
#include "../../../UnicodeConverter/UnicodeConverter.h"
#endif
#include "../../../UnicodeConverter/UnicodeConverter.h"
#include "UniversalConverterUtils.h"
......@@ -695,7 +693,7 @@ public:
return 1252;//ANSI
}
#ifdef _ASC_USE_UNICODE_CONVERTER_
static std::wstring convert_string(std::string::const_iterator start, std::string::const_iterator end, int nCodepage = 0)
{
std::string sCodePage;
......@@ -737,100 +735,6 @@ public:
return oConverter.fromUnicode(inptr, insize, sCodePage.c_str());
}
#else
static std::wstring convert_string(std::string::const_iterator start, std::string::const_iterator end, int nCodepage = 0)
{
std::wstring w_out;
bool ansi = true;
size_t insize = end - start;
char *inptr = (char*)start.operator ->();
if (nCodepage > 0)
{
#if defined (_WIN32) || defined (_WIN64)
int insize = MultiByteToWideChar(nCodepage, 0, inptr, -1, NULL, NULL);
wchar_t *out = new wchar_t[insize];
if (out && MultiByteToWideChar(nCodepage, 0, inptr, -1, out, insize) > 0)
{
w_out = std::wstring(out);
ansi = false;
}
if (out) delete []out;
#else
std::string sCodepage = "CP" + std::to_string(nCodepage);
iconv_t ic= iconv_open("WCHAR_T", sCodepage.c_str());
if (ic != (iconv_t) -1)
{
size_t nconv = 0, avail = (insize) * sizeof(wchar_t);
wchar_t *out = new wchar_t[insize];
nconv = iconv (ic, &inptr, &insize, (char**)&out, &avail);
if (nconv == 0)
{
w_out = std::wstring(out);
ansi = false;
}
if (out) delete []out;
iconv_close(ic);
}
#endif
}
if (ansi)
w_out = std::wstring(start, end);
return w_out;
}
static std::string convert_string(std::wstring::const_iterator start, std::wstring::const_iterator end, int nCodepage = 0)
{
std::string out;
bool ansi = true;
size_t insize = end - start;
char *inptr = (char*)start.operator ->();
char* outptr = (char*)out.c_str();
if (nCodepage > 0)
{
#if defined (_WIN32) || defined (_WIN64)
insize = WideCharToMultiByte(nCodepage, 0, (LPCWSTR)inptr, -1, NULL, 0, NULL, NULL);
out.reserve(insize);
if (WideCharToMultiByte(nCodepage, 0, (LPCWSTR)inptr, -1, outptr, (int)insize, NULL, NULL) > 0)
{
out.resize(insize);
ansi = false;
}
#else
out.reserve(insize);
std::string sCodepage = "CP" + std::to_string(nCodepage);
iconv_t ic= iconv_open(sCodepage.c_str(), "WCHAR_T");
if (ic != (iconv_t) -1)
{
size_t nconv = 0, avail = insize * sizeof(wchar_t);
nconv = iconv (ic, &inptr, &insize, &outptr, &avail);
if (nconv == 0)
{
out.resize(insize);
ansi = false;
}
iconv_close(ic);
}
#endif
}
if (ansi)
out = std::string(start, end);
return out;
}
#endif
static int CodepageToCharset( int nCodepage )
{
#if defined (_WIN32) || defined(_WIN64)
......
......@@ -31,14 +31,6 @@
*/
#include "HelpFunc.h"
#ifndef _ASC_USE_UNICODE_CONVERTER_
#if defined (_WIN32) || defined (_WIN64)
#include "shlwapi.h"
#else
#include <iconv.h>
#endif
#endif
#include "../../../../UnicodeConverter/UnicodeConverter.h"
#include <Logic/Biff_structures/CellRangeRef.h>
......@@ -454,7 +446,6 @@ const size_t hex_str2int(const std::wstring::const_iterator& it_begin, const std
return numeric;
}
#ifdef _ASC_USE_UNICODE_CONVERTER_
const std::wstring toStdWString(std::string ansi_string, const unsigned int code_page)
{
std::string sCodePage;
......@@ -506,131 +497,6 @@ const std::string toStdString(std::wstring wide_string, const unsigned int code_
NSUnicodeConverter::CUnicodeConverter oConverter;
return oConverter.fromUnicode(wide_string, sCodePage.c_str());
}
#else
const std::string toStdString(std::wstring wide_string, const unsigned int code_page)
{
#if defined (_WIN32) || defined (_WIN64)
const int nSize = WideCharToMultiByte(code_page, 0, wide_string.c_str(), wide_string.length(), NULL, 0, NULL, NULL);
char *sTemp = new char[nSize];
if (!sTemp)
return std::string();
int size = WideCharToMultiByte(code_page, 0, wide_string.c_str(), wide_string.length(), sTemp, nSize, NULL, NULL);
std::string sResult(sTemp, size);
delete []sTemp;
return sResult;
#else
std::string out;
bool ansi = true;
size_t insize = wide_string.length();
out.reserve(insize);
char *inptr = (char*)wide_string.c_str();
char* outptr = (char*)out.c_str();
if (code_page >= 0)
{
std::string sCodepage = "CP" + std::to_string(code_page);
iconv_t ic= iconv_open(sCodepage.c_str(), "WCHAR_T");
if (ic != (iconv_t) -1)
{
size_t nconv = 0, avail = insize * sizeof(wchar_t);
nconv = iconv (ic, &inptr, &insize, &outptr, &avail);
if (nconv == 0) ansi = false;
iconv_close(ic);
}
}
if (ansi)
out = std::string(wide_string.begin(), wide_string.end());
return out;
#endif
}
const std::wstring toStdWString(char* ansi, int size, const unsigned int code_page)
{
std::string sCodePage;
for (int i = 0; i < UNICODE_CONVERTER_ENCODINGS_COUNT; ++i)
{
if (code_page == NSUnicodeConverter::Encodings[i].WindowsCodePage)
{
sCodePage = NSUnicodeConverter::Encodings[i].Name;
break;
}
}
if (!sCodePage.empty())
{
NSUnicodeConverter::CUnicodeConverter oConverter;
return oConverter.toUnicode(ansi, size, sCodePage.c_str());
}
#if defined (_WIN32) || defined (_WIN64)
const int nSize = MultiByteToWideChar(code_page, 0, ansi, size, NULL, 0);
wchar_t *sTemp = new wchar_t[nSize];
if (!sTemp)
return std::wstring();
int size_out = MultiByteToWideChar(code_page, 0, ansi, size, sTemp, nSize);
std::wstring sResult(sTemp, size_out);
delete []sTemp;
return sResult;
#else
bool bAnsi = true;
size_t insize = size;
std::wstring w_out;
char *inptr = ansi;
if (code_page >= 0)
{
std::string sCodepage = "CP" + std::to_string(code_page);
iconv_t ic= iconv_open("WCHAR_T", sCodepage.c_str());
if (ic != (iconv_t) -1)
{
size_t nconv = 0, avail = (insize + 1) * sizeof(wchar_t);
char* out_str = new char[avail];
char* outptr = out_str;
nconv = iconv (ic, &inptr, &insize, &outptr, &avail);
if (nconv == 0)
{
insize = size;
((wchar_t*)out_str)[insize] = 0;
w_out = std::wstring((wchar_t*)out_str, insize);
bAnsi = false;
}
iconv_close(ic);
delete []out_str;
}
}
if (bAnsi)
{
std::string ansi_string(ansi, size);
w_out = std::wstring(ansi_string.begin(), ansi_string.end());
}
return w_out;
#endif
}
const std::wstring toStdWString(std::string ansi_string, const unsigned int code_page)
{
return toStdWString((char*)ansi_string.c_str(), (int)ansi_string.length(), code_page);
}
#endif
} // namespace STR
......@@ -639,7 +505,6 @@ namespace XMLSTUFF
{;
const std::wstring tab2sheet_name(const short tabid, std::vector<std::wstring>& sheets_names)
{
if(tabid >= 0 && static_cast<unsigned short>(tabid) < sheets_names.size())
......
......@@ -29,10 +29,6 @@ DEFINES += _DEBUG
}
core_mac {
DEFINES += \
_ASC_USE_UNICODE_CONVERTER_ \
UNICODECONVERTER_USE_DYNAMIC_LIBRARY
LIBS += $$DESTDIR -lUnicodeConverter
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment