From a2614b00204cd82989590a65622b17f1a883071a Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Tue, 7 Jun 2022 12:46:02 +0300 Subject: [PATCH] Change memorystream engine --- DesktopEditor/doctrenderer/doctrenderer.pro | 1 - .../doctrenderer/embed/MemoryStreamEmbed.h | 2 +- DesktopEditor/doctrenderer/memorystream.h | 208 ------------------ 3 files changed, 1 insertion(+), 210 deletions(-) delete mode 100644 DesktopEditor/doctrenderer/memorystream.h diff --git a/DesktopEditor/doctrenderer/doctrenderer.pro b/DesktopEditor/doctrenderer/doctrenderer.pro index 002af235cd..2af8bd2786 100644 --- a/DesktopEditor/doctrenderer/doctrenderer.pro +++ b/DesktopEditor/doctrenderer/doctrenderer.pro @@ -48,7 +48,6 @@ SOURCES += \ HEADERS += \ docbuilder_p.h \ - memorystream.h \ nativecontrol.h \ graphics.h diff --git a/DesktopEditor/doctrenderer/embed/MemoryStreamEmbed.h b/DesktopEditor/doctrenderer/embed/MemoryStreamEmbed.h index f7ae41856f..e1ffa76b17 100644 --- a/DesktopEditor/doctrenderer/embed/MemoryStreamEmbed.h +++ b/DesktopEditor/doctrenderer/embed/MemoryStreamEmbed.h @@ -1,7 +1,7 @@ #ifndef _BUILD_NATIVE_MEMORYSTREAM_EMBED_H_ #define _BUILD_NATIVE_MEMORYSTREAM_EMBED_H_ -#include "../memorystream.h" +#include "../fontengine/MemoryStream.h" #include "../js_internal/js_base.h" using namespace NSJSBase; diff --git a/DesktopEditor/doctrenderer/memorystream.h b/DesktopEditor/doctrenderer/memorystream.h deleted file mode 100644 index 1636a5bf67..0000000000 --- a/DesktopEditor/doctrenderer/memorystream.h +++ /dev/null @@ -1,208 +0,0 @@ -/* - * (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 - * - */ -#ifndef MEMORYSTREAM -#define MEMORYSTREAM - -#include -#include "../common/Types.h" -#include "../common/File.h" - -namespace NSMemoryStream -{ -class CMemoryStream -{ -private: - // сам метафайл - BYTE* m_pBuffer; - BYTE* m_pBufferMem; - - size_t m_lSize; - -public: - CMemoryStream() - { - m_pBuffer = NULL; - m_pBufferMem = NULL; - - m_lSize = 0; - } - ~CMemoryStream() - { - RELEASEARRAYOBJECTS(m_pBuffer); - } - - inline BYTE* GetData() - { - return m_pBuffer; - } - inline int GetSize() - { - return (int)(m_pBufferMem - m_pBuffer); - } - - inline void Clear() - { - m_lSize = 0; - - m_pBuffer = NULL; - m_pBufferMem = NULL; - } - - inline void ClearNoAttack() - { - m_pBufferMem = m_pBuffer; - } - - inline void Copy(const CMemoryStream* pData, const size_t& nPos, const size_t& nLen) - { - CheckBufferSize(nLen); - memcpy(m_pBufferMem, pData->m_pBuffer + nPos, nLen); - m_pBufferMem += nLen; - } - - inline void CheckBufferSize(size_t lPlus) - { - if (NULL != m_pBuffer) - { - size_t nNewSize = (m_pBufferMem - m_pBuffer) + lPlus; - if (nNewSize >= m_lSize) - { - while (nNewSize >= m_lSize) - { - m_lSize *= 2; - } - - BYTE* pNew = new BYTE[m_lSize]; - memcpy(pNew, m_pBuffer, m_pBufferMem - m_pBuffer); - - m_pBufferMem = pNew + (m_pBufferMem - m_pBuffer); - - RELEASEARRAYOBJECTS(m_pBuffer); - m_pBuffer = pNew; - } - } - else - { - m_lSize = 1000; - m_pBuffer = new BYTE[m_lSize]; - m_pBufferMem = m_pBuffer; - - CheckBufferSize(lPlus); - } - } - - inline void WriteBYTE(const BYTE& lValue) - { - CheckBufferSize(sizeof(BYTE)); - *m_pBufferMem = lValue; - m_pBufferMem += sizeof(BYTE); - } - inline void WriteLONG(const LONG& lValue) - { - CheckBufferSize(sizeof(LONG)); - *((LONG*)(m_pBufferMem)) = lValue; - m_pBufferMem += sizeof(LONG); - } - inline void WriteDouble(const double& dValue) - { - CheckBufferSize(sizeof(double)); - *((double*)(m_pBufferMem)) = dValue; - m_pBufferMem += sizeof(double); - } - inline void WriteStringA(const char* pData, int nLen) - { - CheckBufferSize(nLen + sizeof(USHORT)); - *((USHORT*)(m_pBufferMem)) = (USHORT)nLen; - m_pBufferMem += sizeof(USHORT); - - memcpy(m_pBufferMem, pData, nLen); - m_pBufferMem += nLen; - } - inline void WriteStringA2(const char* pData, int nLen) - { - CheckBufferSize(nLen + sizeof(LONG)); - *((LONG*)(m_pBufferMem)) = (LONG)nLen; - m_pBufferMem += sizeof(LONG); - - memcpy(m_pBufferMem, pData, nLen); - m_pBufferMem += nLen; - } - - inline void WriteString(const wchar_t* pData, int nLen) - { - CheckBufferSize(nLen + sizeof(USHORT)); - *((USHORT*)(m_pBufferMem)) = (USHORT)nLen; - m_pBufferMem += sizeof(USHORT); - - int nLen2 = nLen << 1; - if (sizeof(wchar_t) == 2) - { - memcpy(m_pBufferMem, pData, nLen2); - } - else - { - int len = nLen >> 1; - USHORT* mass = new USHORT[len]; - for (int i = 0; i < len; ++i) - mass[i] = (USHORT)pData[i]; - memcpy(m_pBufferMem, mass, nLen2); - RELEASEARRAYOBJECTS(mass); - } - m_pBufferMem += nLen2; - } - inline void WriteString2(const wchar_t* pData, int nLen) - { - int nLen2 = nLen << 1; - - CheckBufferSize(nLen2 + sizeof(LONG)); - *((LONG*)(m_pBufferMem)) = (LONG)nLen2; - m_pBufferMem += sizeof(LONG); - - if (sizeof(wchar_t) == 2) - { - memcpy(m_pBufferMem, pData, nLen2); - } - else - { - USHORT* mass = new USHORT[nLen]; - for (int i = 0; i < nLen; ++i) - mass[i] = (USHORT)pData[i]; - memcpy(m_pBufferMem, mass, nLen2); - RELEASEARRAYOBJECTS(mass); - } - m_pBufferMem += nLen2; - } -}; -} - -#endif // MEMORYSTREAM -