From d92c01c247551ec47ac97227a4390f66c9999348 Mon Sep 17 00:00:00 2001 From: "Ilya.Kirillov" Date: Tue, 19 May 2015 07:36:15 +0000 Subject: [PATCH] =?UTF-8?q?=D0=9A=D0=BE=D0=BD=D0=B2=D0=B5=D1=80=D1=82?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D0=B8=20=D1=81=D1=82=D1=80=D0=BE=D0=BA=20?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=D0=B5=D0=BB=D0=B0=D0=BD=D1=8B=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B8=20?= =?UTF-8?q?=D0=B8=D0=B7=20DesktopEditor/Common?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62616 954022d7-b5bf-4e40-9824-e11837661b57 --- DjVuFile/DjVuFile.pro | 15 ++++--- DjVuFile/DjVuFileImplementation.cpp | 64 ++++------------------------- 2 files changed, 14 insertions(+), 65 deletions(-) diff --git a/DjVuFile/DjVuFile.pro b/DjVuFile/DjVuFile.pro index e8f0f91139..450881a5da 100644 --- a/DjVuFile/DjVuFile.pro +++ b/DjVuFile/DjVuFile.pro @@ -15,7 +15,8 @@ DEFINES += _UNICODE DEFINES += _USE_LIBXML2_READER_ DEFINES += LIBXML_READER_ENABLED -SOURCES += djvufile.cpp \ +SOURCES += DjVu.cpp \ + DjVuFileImplementation.cpp \ libdjvu/Arrays.cpp \ libdjvu/atomic.cpp \ libdjvu/BSByteStream.cpp \ @@ -70,11 +71,10 @@ SOURCES += djvufile.cpp \ libdjvu/UnicodeByteStream.cpp \ libdjvu/XMLParser.cpp \ libdjvu/XMLTags.cpp \ - libdjvu/ZPCodec.cpp \ - DjVu.cpp \ - DjVuFileImplementation.cpp + libdjvu/ZPCodec.cpp -HEADERS += djvufile.h \ +HEADERS += DjVu.h \ + DjVuFileImplementation.h \ libdjvu/Arrays.h \ libdjvu/atomic.h \ libdjvu/BSByteStream.h \ @@ -124,9 +124,8 @@ HEADERS += djvufile.h \ libdjvu/UnicodeByteStream.h \ libdjvu/XMLParser.h \ libdjvu/XMLTags.h \ - libdjvu/ZPCodec.h \ - DjVu.h \ - DjVuFileImplementation.h + libdjvu/ZPCodec.h + unix { target.path = /usr/lib INSTALLS += target diff --git a/DjVuFile/DjVuFileImplementation.cpp b/DjVuFile/DjVuFileImplementation.cpp index 206709056d..0883204a08 100644 --- a/DjVuFile/DjVuFileImplementation.cpp +++ b/DjVuFile/DjVuFileImplementation.cpp @@ -21,65 +21,15 @@ namespace NSDjvu { static GUTF8String MakeUTF8String(const std::wstring& wsText) { - int nSize; - -#ifdef _UNICODE - LPCWSTR pszUnicodeText = wsText.c_str(); -#else - nSize = ::MultiByteToWideChar(CP_ACP, 0, (LPCSTR)strText, -1, NULL, 0); - if (nSize == 0) - return ""; - - LPWSTR pszUnicodeText = new WCHAR[nSize]; - ::MultiByteToWideChar(CP_ACP, 0, (LPCSTR)strText, -1, pszUnicodeText, nSize); -#endif - - nSize = ::WideCharToMultiByte(CP_UTF8, 0, pszUnicodeText, -1, NULL, 0, NULL, NULL); - if (nSize == 0) - { -#ifndef _UNICODE - delete[] pszUnicodeText; -#endif - return ""; - } - - LPSTR pszTextUTF8 = new CHAR[nSize]; - ::WideCharToMultiByte(CP_UTF8, 0, pszUnicodeText, -1, pszTextUTF8, nSize, NULL, NULL); - - GUTF8String utf8String(pszTextUTF8); - delete[] pszTextUTF8; - -#ifndef _UNICODE - delete[] pszUnicodeText; -#endif - - return utf8String; - - //std::string sText = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(wsText); - //GUTF8String utf8String(sText.c_str()); - //return utf8String; + std::string sText = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(wsText); + GUTF8String utf8String(sText.c_str()); + return utf8String; } static CString MakeCString(GUTF8String& strText) { - int nSize; - - LPSTR pszUtf8Text = strText.getbuf(); - - //nSize = ::WideCharToMultiByte(CP_UTF8, 0, pszUtf8Text, -1, NULL, 0, NULL, NULL); - nSize = ::MultiByteToWideChar(CP_UTF8, 0, pszUtf8Text, -1, NULL, 0); - - if (nSize == 0) - { - return _T(""); - } - - LPWSTR pszUnicodeText = new WCHAR[nSize]; - ::MultiByteToWideChar(CP_UTF8, 0, pszUtf8Text, -1, pszUnicodeText, nSize); - - CString String(pszUnicodeText); - delete[] pszUnicodeText; - - return String; + std::string sString(strText.getbuf()); + std::wstring wsString = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sString.c_str(), sString.length()); + return CString(wsString.c_str()); } static int GetInteger(const std::wstring& wsString) { @@ -672,4 +622,4 @@ void CDjVuFileImplementation::ParseCoords(const std::wstring& wsCo pdCoords[nIndex] = NSDjvu::GetInteger(vCoords.at(nIndex)) * dKoef; } } -} \ No newline at end of file +}