From 9a5cb77ca0d0b1ecbc75994edd1ea0fb2f815d7d Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Tue, 7 Jan 2020 19:08:08 +0300 Subject: [PATCH] developing... --- .gitignore | 4 +- Common/3dParty/cryptopp/project/cryptopp.pro | 4 + Common/base.pri | 7 + DesktopEditor/cximage/CxImage/ximaraw.cpp | 4 - DesktopEditor/cximage/raw/libdcr.h | 23 +++- DesktopEditor/doctrenderer/doctrenderer.pro | 3 + DjVuFile/DjVuFile.pro | 25 +--- PdfWriter/PdfWriter.pro | 3 + UnicodeConverter/UnicodeConverter.pro | 6 + .../UnicodeConverter_internal_android.cpp | 126 ++++++++++++++++++ 10 files changed, 175 insertions(+), 30 deletions(-) create mode 100644 UnicodeConverter/UnicodeConverter_internal_android.cpp diff --git a/.gitignore b/.gitignore index 0b59340e4e..693ed3c09e 100644 --- a/.gitignore +++ b/.gitignore @@ -51,9 +51,7 @@ ASCOfficeXlsFile2/win32/_ASCOfficeXlsFile2_i.c ASCOfficeXlsFile2/win32/_ASCOfficeXlsFile2_p.c ASCOfficeXlsFile2/win32/dlldata.c OfficeUtils/win32/OfficeUtilsLib/OfficeUtilsLib/ReadMe.txt -X2tConverter/**/Makefile.* -X2tConverter/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/Makefile -X2tConverter/Common/DocxFormat/DocxFormatLib/Makefile +**/Makefile* *.7z *.obj *.pdb diff --git a/Common/3dParty/cryptopp/project/cryptopp.pro b/Common/3dParty/cryptopp/project/cryptopp.pro index 946aa7b0f3..bdd8fe8e2c 100644 --- a/Common/3dParty/cryptopp/project/cryptopp.pro +++ b/Common/3dParty/cryptopp/project/cryptopp.pro @@ -24,6 +24,10 @@ core_windows { DEFINES += CRYPTOPP_DISABLE_ASM +core_android { + INCLUDEPATH += $$(ANDROID_NDK_ROOT)/sources/android/cpufeatures +} + HEADERS += \ ../3way.h \ ../adler32.h \ diff --git a/Common/base.pri b/Common/base.pri index d07376962e..b4a7e2c1fb 100644 --- a/Common/base.pri +++ b/Common/base.pri @@ -189,6 +189,10 @@ core_ios { } core_android { CORE_BUILDS_PLATFORM_PREFIX = $$join(ANDROID_TARGET_ARCH, ANDROID_TARGET_ARCH, "android_", "") + + !core_android_no_unistd { + DEFINES += HAVE_UNISTD_H + } } core_debug { @@ -263,3 +267,6 @@ core_windows { DEFINES += CRYPTOPP_DISABLE_ASM } + +ADD_INC_PATH = $$(ADDITIONAL_INCLUDE_PATH) +!isEmpty(ADD_INC_PATH):INCLUDEPATH += $$ADD_INC_PATH diff --git a/DesktopEditor/cximage/CxImage/ximaraw.cpp b/DesktopEditor/cximage/CxImage/ximaraw.cpp index af6dd0def0..e5661d2005 100644 --- a/DesktopEditor/cximage/CxImage/ximaraw.cpp +++ b/DesktopEditor/cximage/CxImage/ximaraw.cpp @@ -10,10 +10,6 @@ * Copyright 1997-2007 by Dave Coffin, dcoffin a cybercom o net */ -#ifdef __ANDROID__ -#include -#endif - #include "ximaraw.h" #include "../../common/File.h" diff --git a/DesktopEditor/cximage/raw/libdcr.h b/DesktopEditor/cximage/raw/libdcr.h index 212c15a2e4..96fcaddfd3 100644 --- a/DesktopEditor/cximage/raw/libdcr.h +++ b/DesktopEditor/cximage/raw/libdcr.h @@ -45,9 +45,30 @@ #if defined(_LINUX) || defined(__APPLE__) #include #include - #define _swab swab #define _getcwd getcwd #include + +#ifdef __ANDROID__ +#include +#if __ANDROID_API__ < 28 +static void swab(const char* __src, char* __dst, ssize_t __byte_count) +{ + ssize_t len = __byte_count; + if (1 == (len & 1)) + { + __dst[len - 1] = __src[len - 1]; + len -= 1; + } + for (ssize_t i = 0; i < len; i++) + { + __dst[i] = __src[i + 1]; + __dst[i + 1] = __src[i]; + } +} +#endif +#define _swab swab +#endif + #endif #define DCR_VERSION "8.93" diff --git a/DesktopEditor/doctrenderer/doctrenderer.pro b/DesktopEditor/doctrenderer/doctrenderer.pro index 0819c50bf9..6c84b11c88 100644 --- a/DesktopEditor/doctrenderer/doctrenderer.pro +++ b/DesktopEditor/doctrenderer/doctrenderer.pro @@ -35,6 +35,9 @@ LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lUnicodeConverter -lkernel -lgraphics core_ios { CONFIG += doct_renderer_empty } +core_android { + CONFIG += doct_renderer_empty +} doct_renderer_empty { SOURCES += doctrenderer_empty.cpp diff --git a/DjVuFile/DjVuFile.pro b/DjVuFile/DjVuFile.pro index 7dfe19f87e..f05622b035 100644 --- a/DjVuFile/DjVuFile.pro +++ b/DjVuFile/DjVuFile.pro @@ -23,7 +23,7 @@ DEFINES -= \ UNICODE \ _UNICODE -core_linux { +!core_windows { DEFINES += \ HAVE_UNISTD_H \ HAVE_MBSTATE_T \ @@ -33,27 +33,8 @@ core_linux { UNIX \ HAVE_STDINCLUDES } - -core_mac { - DEFINES += \ - HAVE_UNISTD_H \ - HAVE_MBSTATE_T \ - GCONTAINER_NO_MEMBER_TEMPLATES="1" \ - HAS_WCHAR \ - HAVE_WCHAR_H \ - UNIX \ - HAVE_STDINCLUDES -} - -core_ios { - DEFINES += \ - HAVE_UNISTD_H \ - HAVE_MBSTATE_T \ - GCONTAINER_NO_MEMBER_TEMPLATES="1" \ - HAS_WCHAR \ - HAVE_WCHAR_H \ - UNIX \ - HAVE_STDINCLUDES +core_android { + DEFINES += HAS_MBSTATE="1" } core_windows { diff --git a/PdfWriter/PdfWriter.pro b/PdfWriter/PdfWriter.pro index 6db8509a26..fc5ca74c0f 100644 --- a/PdfWriter/PdfWriter.pro +++ b/PdfWriter/PdfWriter.pro @@ -25,6 +25,9 @@ DEFINES += NOMINMAX core_linux { QMAKE_CXXFLAGS += -Wno-narrowing } +core_android { + QMAKE_CXXFLAGS += -Wno-narrowing +} core_windows { DEFINES -= UNICODE diff --git a/UnicodeConverter/UnicodeConverter.pro b/UnicodeConverter/UnicodeConverter.pro index 45adf72c35..536becc886 100644 --- a/UnicodeConverter/UnicodeConverter.pro +++ b/UnicodeConverter/UnicodeConverter.pro @@ -25,6 +25,12 @@ core_ios { OBJECTIVE_SOURCES += UnicodeConverter_internal_ios.mm } +core_android { + CONFIG += core_disable_icu + + SOURCES += UnicodeConverter_internal_android.cpp +} + !core_disable_icu { include(../Common/3dParty/icu/icu.pri) diff --git a/UnicodeConverter/UnicodeConverter_internal_android.cpp b/UnicodeConverter/UnicodeConverter_internal_android.cpp new file mode 100644 index 0000000000..e109ab0e76 --- /dev/null +++ b/UnicodeConverter/UnicodeConverter_internal_android.cpp @@ -0,0 +1,126 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ +#include "./UnicodeConverter.h" +#include "../DesktopEditor/common/File.h" + +namespace NSUnicodeConverter +{ + class CUnicodeConverter_Private + { + public: + CUnicodeConverter_Private() + { + } + ~CUnicodeConverter_Private() + { + } + + std::string SASLprepToUtf8(const wchar_t* sInput, const unsigned int& nInputLen) + { + // TODO: + return ""; + } + + std::string fromUnicode(const wchar_t* sInput, const unsigned int& nInputLen, const char* converterName) + { + std::string sRes = ""; + if (sRes.empty() && nInputLen > 0) + { + std::wstring ws(sInput, nInputLen); + sRes = std::string(ws.begin(), ws.end()); + } + return sRes; + } + + std::wstring toUnicode(const char* sInput, const unsigned int& nInputLen, int nCodePage, bool isExact) + { + std::wstring sRes = L""; + if (!isExact && sRes.empty() && nInputLen > 0) + { + std::string ws(sInput, nInputLen); + sRes = std::wstring(ws.begin(), ws.end()); + } + return sRes; + } + std::wstring toUnicode(const char* sInput, const unsigned int& nInputLen, const char* converterName, bool isExact) + { + std::wstring sRes = L""; + if (isExact && sRes.empty() && nInputLen > 0) + { + std::string ws(sInput, nInputLen); + sRes = std::wstring(ws.begin(), ws.end()); + } + return sRes; + } + }; +} + +namespace NSUnicodeConverter +{ + CUnicodeConverter::CUnicodeConverter() + { + m_pInternal = new CUnicodeConverter_Private(); + } + CUnicodeConverter::~CUnicodeConverter() + { + delete m_pInternal; + } + + std::string CUnicodeConverter::fromUnicode(const wchar_t* sInput, const unsigned int& nInputLen, const char* converterName) + { + return m_pInternal->fromUnicode(sInput, nInputLen, converterName); + } + std::string CUnicodeConverter::fromUnicode(const std::wstring &sInput, const char *converterName) + { + return this->fromUnicode(sInput.c_str(), (unsigned int)sInput.size(), converterName); + } + std::wstring CUnicodeConverter::toUnicode(const char* sInput, const unsigned int& nInputLen, const char* converterName, bool isExact) + { + return m_pInternal->toUnicode(sInput, nInputLen, converterName, isExact); + } + std::wstring CUnicodeConverter::toUnicode(const std::string &sInput, const char *converterName, bool isExact) + { + return this->toUnicode(sInput.c_str(), (unsigned int)sInput.size(), converterName, isExact); + } + std::wstring CUnicodeConverter::toUnicode(const char* sInput, const unsigned int& nInputLen, int nCodePage, bool isExact) + { + return m_pInternal->toUnicode(sInput, nInputLen, nCodePage, isExact); + } + std::wstring CUnicodeConverter::toUnicode(const std::string &sInput, int nCodePage, bool isExact) + { + return this->toUnicode(sInput.c_str(), (unsigned int)sInput.size(), nCodePage, isExact); + } + std::string CUnicodeConverter::SASLprepToUtf8(const std::wstring &sSrc) + { + return m_pInternal->SASLprepToUtf8(sSrc.c_str(), sSrc.length()); + } +}