mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
PdfReader and PdfWriter moved entirely to PdfFile
This commit is contained in:
61
PdfFile/Resources/CMapMemory/autogen.py
Normal file
61
PdfFile/Resources/CMapMemory/autogen.py
Normal file
@ -0,0 +1,61 @@
|
||||
import sys
|
||||
sys.path.append("../../../../build_tools/scripts")
|
||||
import base
|
||||
import codecs
|
||||
|
||||
base.configure_common_apps()
|
||||
|
||||
cmap_directory = "./../CMap/"
|
||||
cmap_names = ["Adobe-GB1", "Adobe-Korea1", "Adobe-KR", "Adobe-Japan1"]
|
||||
cmap_values = {}
|
||||
|
||||
for item in cmap_names:
|
||||
cmap_values[item] = {}
|
||||
cmap_content = base.readFile(cmap_directory + item + ".cidToUnicode")
|
||||
arr_str_cidToUnicode = cmap_content.splitlines()
|
||||
arr_int_cidToUnicode = [int(i, 16) for i in arr_str_cidToUnicode]
|
||||
cmap_values[item]["code"] = "const unsigned int c_arr" + item.replace("-", "_") + "[] = {" + ",".join(map(str, arr_int_cidToUnicode)) + "};"
|
||||
cmap_values[item]["len"] = str(len(arr_int_cidToUnicode))
|
||||
|
||||
cmap_directory = "./../CMap/"
|
||||
|
||||
content_cpp_file = []
|
||||
content_cpp_file.append("#include <map>")
|
||||
content_cpp_file.append("#include \"./cmap_memory.h\"")
|
||||
content_cpp_file.append("")
|
||||
content_cpp_file.append("// This file was generated and should not edited by hand")
|
||||
content_cpp_file.append("")
|
||||
|
||||
for item in cmap_names:
|
||||
content_cpp_file.append(cmap_values[item]["code"])
|
||||
|
||||
content_cpp_file.append("struct TCidToUnicodeData")
|
||||
content_cpp_file.append("{")
|
||||
content_cpp_file.append(" const unsigned int* Data;")
|
||||
content_cpp_file.append(" unsigned int Size;")
|
||||
content_cpp_file.append("};")
|
||||
|
||||
content_cpp_file.append("")
|
||||
|
||||
content_cpp_file.append("std::map<std::string, TCidToUnicodeData> g_memory_cid_to_unicode;")
|
||||
content_cpp_file.append("bool PdfReader::GetCidToUnicodeMemoryMap(const char* name, const unsigned int*& data, unsigned int& size)")
|
||||
content_cpp_file.append("{")
|
||||
content_cpp_file.append(" if (g_memory_cid_to_unicode.empty())")
|
||||
content_cpp_file.append(" {")
|
||||
for item in cmap_names:
|
||||
content_cpp_file.append(" g_memory_cid_to_unicode.insert(std::pair<std::string, TCidToUnicodeData>(\"" + item + "\", { c_arr" + item.replace("-", "_") + ", " + cmap_values[item]["len"] + " }));")
|
||||
content_cpp_file.append(" }")
|
||||
content_cpp_file.append(" std::map<std::string, TCidToUnicodeData>::const_iterator iter = g_memory_cid_to_unicode.find(name);")
|
||||
content_cpp_file.append(" if (iter != g_memory_cid_to_unicode.end())")
|
||||
content_cpp_file.append(" {")
|
||||
content_cpp_file.append(" data = iter->second.Data;")
|
||||
content_cpp_file.append(" size = iter->second.Size;")
|
||||
content_cpp_file.append(" return true;")
|
||||
content_cpp_file.append(" }")
|
||||
content_cpp_file.append(" data = NULL;")
|
||||
content_cpp_file.append(" size = 0;")
|
||||
content_cpp_file.append(" return false;")
|
||||
content_cpp_file.append("}")
|
||||
content_cpp_file.append("")
|
||||
|
||||
base.writeFile("./cmap_memory.cpp", "\n".join(content_cpp_file))
|
||||
36
PdfFile/Resources/CMapMemory/cmap_memory.cpp
Normal file
36
PdfFile/Resources/CMapMemory/cmap_memory.cpp
Normal file
File diff suppressed because one or more lines are too long
42
PdfFile/Resources/CMapMemory/cmap_memory.h
Normal file
42
PdfFile/Resources/CMapMemory/cmap_memory.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* (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 _PDF_READER_USE_CMAP_MEMORY_H
|
||||
#define _PDF_READER_USE_CMAP_MEMORY_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace PdfReader
|
||||
{
|
||||
bool GetCidToUnicodeMemoryMap(const char* name, const unsigned int*& data, unsigned int& size);
|
||||
}
|
||||
|
||||
#endif //_PDF_READER_USE_CMAP_MEMORY_H
|
||||
Reference in New Issue
Block a user