c++ fix merge with develop

This commit is contained in:
Kulikova Svetlana
2021-10-04 18:11:05 +03:00
parent e0fd7ff1f0
commit 7569534cfd
32 changed files with 4583 additions and 4560 deletions

View File

@ -39,7 +39,8 @@ DEFINES -= _UNICODE
LIBS += -lgdi32 \
-ladvapi32 \
-luser32 \
-lshell32
-lshell32 \
-lOle32
}
# graphics
@ -514,7 +515,7 @@ HEADERS += \
$$DJVU_ROOT_DIR/libdjvu/GRect.h \
$$DJVU_ROOT_DIR/libdjvu/GScaler.h \
$$DJVU_ROOT_DIR/libdjvu/GSmartPointer.h \
$$DJVU_ROOT_DIR/libdjvu/GString.h \
$$DJVU_ROOT_DIR/libdjvu/DjVuGString.h \
$$DJVU_ROOT_DIR/libdjvu/GThreads.h \
$$DJVU_ROOT_DIR/libdjvu/GURL.h \
$$DJVU_ROOT_DIR/libdjvu/IFFByteStream.h \
@ -570,7 +571,7 @@ SOURCES += \
$$DJVU_ROOT_DIR/libdjvu/GRect.cpp \
$$DJVU_ROOT_DIR/libdjvu/GScaler.cpp \
$$DJVU_ROOT_DIR/libdjvu/GSmartPointer.cpp \
$$DJVU_ROOT_DIR/libdjvu/GString.cpp \
$$DJVU_ROOT_DIR/libdjvu/DjVuGString.cpp \
$$DJVU_ROOT_DIR/libdjvu/GThreads.cpp \
$$DJVU_ROOT_DIR/libdjvu/GUnicode.cpp \
#$$DJVU_ROOT_DIR/libdjvu/GURL.cpp \
@ -599,6 +600,37 @@ DEFINES += CRYPTOPP_DISABLE_ASM
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCryptoPPLib
PDF_ROOT_DIR = $$PWD/../../../../../PdfReader
INCLUDEPATH += \
$$PDF_ROOT_DIR/lib/goo \
$$PDF_ROOT_DIR/lib/fofi \
$$PDF_ROOT_DIR/lib/splash \
$$PDF_ROOT_DIR/lib
HEADERS += \
$$PDF_ROOT_DIR/lib/aconf.h \
$$$files($$PDF_ROOT_DIR/lib/*.h)
SOURCES += $$files($$PDF_ROOT_DIR/lib/*.c, true)
SOURCES += $$files($$PDF_ROOT_DIR/lib/*.cc, true)
SOURCES -= \
$$PDF_ROOT_DIR/lib/xpdf/HTMLGen.cc \
$$PDF_ROOT_DIR/lib/xpdf/pdftohtml.cc \
$$PDF_ROOT_DIR/lib/xpdf/pdftopng.cc \
$$PDF_ROOT_DIR/lib/xpdf/pdftoppm.cc \
$$PDF_ROOT_DIR/lib/xpdf/pdftops.cc \
$$PDF_ROOT_DIR/lib/xpdf/pdftotext.cc \
$$PDF_ROOT_DIR/lib/xpdf/pdfdetach.cc \
$$PDF_ROOT_DIR/lib/xpdf/pdffonts.cc \
$$PDF_ROOT_DIR/lib/xpdf/pdfimages.cc \
$$PDF_ROOT_DIR/lib/xpdf/pdfinfo.cc
SOURCES += \
$$PDF_ROOT_DIR/Src/RendererOutputDev.cpp \
$$PDF_ROOT_DIR/Src/Adaptors.cpp \
$$PDF_ROOT_DIR/Src/GfxClip.cpp \
$$PDF_ROOT_DIR/PdfReader.cpp
HEADERS +=\
$$PDF_ROOT_DIR/Resources/Fontd050000l.h \
$$PDF_ROOT_DIR/Resources/Fontn019003l.h \
@ -614,103 +646,11 @@ HEADERS +=\
$$PDF_ROOT_DIR/Resources/Fontn022023l.h \
$$PDF_ROOT_DIR/Resources/Fontn022024l.h \
$$PDF_ROOT_DIR/Resources/Fonts050000l.h \
$$PDF_ROOT_DIR/Src/Annot.h \
$$PDF_ROOT_DIR/Src/Array.h \
$$PDF_ROOT_DIR/Src/BuiltinFont.h \
$$PDF_ROOT_DIR/Src/BuiltinFontTables.h \
$$PDF_ROOT_DIR/Src/Catalog.h \
$$PDF_ROOT_DIR/Src/CCITT-Tables.h \
$$PDF_ROOT_DIR/Src/CharCodeToUnicode.h \
$$PDF_ROOT_DIR/Src/CharTypes.h \
$$PDF_ROOT_DIR/Src/CMap.h \
$$PDF_ROOT_DIR/Src/Constants.h \
$$PDF_ROOT_DIR/Src/Decrypt.h \
$$PDF_ROOT_DIR/Src/Dict.h \
$$PDF_ROOT_DIR/Src/EncodingTables.h \
$$PDF_ROOT_DIR/Src/ErrorConstants.h \
$$PDF_ROOT_DIR/Src/ExtractImageOutputDev.h \
$$PDF_ROOT_DIR/Src/File.h \
$$PDF_ROOT_DIR/Src/FontFileBase.h \
$$PDF_ROOT_DIR/Src/FontFileEncodings.h \
$$PDF_ROOT_DIR/Src/FontFileTrueType.h \
$$PDF_ROOT_DIR/Src/FontFileType1.h \
$$PDF_ROOT_DIR/Src/FontFileType1C.h \
$$PDF_ROOT_DIR/Src/Function.h \
$$PDF_ROOT_DIR/Src/GFont.h \
$$PDF_ROOT_DIR/Src/GlobalParams.h \
$$PDF_ROOT_DIR/Src/Graphics.h \
$$PDF_ROOT_DIR/Src/GState.h \
$$PDF_ROOT_DIR/Src/Hash.h \
$$PDF_ROOT_DIR/Src/JArithmeticDecoder.h \
$$PDF_ROOT_DIR/Src/JBIG2Stream.h \
$$PDF_ROOT_DIR/Src/JPXStream.h \
$$PDF_ROOT_DIR/Src/Lexer.h \
$$PDF_ROOT_DIR/Src/Link.h \
$$PDF_ROOT_DIR/Src/List.h \
$$PDF_ROOT_DIR/Src/MemoryUtils.h \
$$PDF_ROOT_DIR/Src/NameToCharCode.h \
$$PDF_ROOT_DIR/Src/NameToUnicodeTable.h \
$$PDF_ROOT_DIR/Src/Object.h \
$$PDF_ROOT_DIR/Src/Outline.h \
$$PDF_ROOT_DIR/Src/OutputDevice.h \
$$PDF_ROOT_DIR/Src/Page.h \
$$PDF_ROOT_DIR/Src/PageLabels.h \
$$PDF_ROOT_DIR/Src/Parser.h \
$$PDF_ROOT_DIR/Src/PDFDoc.h \
$$PDF_ROOT_DIR/Src/PDFDocEncoding.h \
$$PDF_ROOT_DIR/Src/PSLexer.h \
$$PDF_ROOT_DIR/Src/RendererOutputDev.h \
$$PDF_ROOT_DIR/Src/SecurityHandler.h \
$$PDF_ROOT_DIR/Src/Stream.h \
$$PDF_ROOT_DIR/Src/StringExt.h \
$$PDF_ROOT_DIR/Src/UnicodeMap.h \
$$PDF_ROOT_DIR/Src/UnicodeMapTables.h \
$$PDF_ROOT_DIR/Src/UTF8.h \
$$PDF_ROOT_DIR/Src/XmlUtils.h \
$$PDF_ROOT_DIR/Src/XRef.h \
$$PDF_ROOT_DIR/Src/Adaptors.h \
$$PDF_ROOT_DIR/Src/MemoryUtils.h \
$$PDF_ROOT_DIR/Src/GfxClip.h \
$$PDF_ROOT_DIR/PdfReader.h
SOURCES += \
$$PDF_ROOT_DIR/Src/Annot.cpp \
$$PDF_ROOT_DIR/Src/Array.cpp \
$$PDF_ROOT_DIR/Src/Catalog.cpp \
$$PDF_ROOT_DIR/Src/CharCodeToUnicode.cpp \
$$PDF_ROOT_DIR/Src/CMap.cpp \
$$PDF_ROOT_DIR/Src/Decrypt.cpp \
$$PDF_ROOT_DIR/Src/Dict.cpp \
$$PDF_ROOT_DIR/Src/ExtractImageOutputDev.cpp \
$$PDF_ROOT_DIR/Src/FontFileBase.cpp \
$$PDF_ROOT_DIR/Src/FontFileTrueType.cpp \
$$PDF_ROOT_DIR/Src/FontFileType1.cpp \
$$PDF_ROOT_DIR/Src/FontFileType1C.cpp \
$$PDF_ROOT_DIR/Src/Function.cpp \
$$PDF_ROOT_DIR/Src/GFont.cpp \
$$PDF_ROOT_DIR/Src/GlobalParams.cpp \
$$PDF_ROOT_DIR/Src/Graphics.cpp \
$$PDF_ROOT_DIR/Src/GState.cpp \
$$PDF_ROOT_DIR/Src/Hash.cpp \
$$PDF_ROOT_DIR/Src/JArithmeticDecoder.cpp \
$$PDF_ROOT_DIR/Src/JBIG2Stream.cpp \
$$PDF_ROOT_DIR/Src/JPXStream.cpp \
$$PDF_ROOT_DIR/Src/Lexer.cpp \
$$PDF_ROOT_DIR/Src/Link.cpp \
$$PDF_ROOT_DIR/Src/List.cpp \
$$PDF_ROOT_DIR/Src/NameToCharCode.cpp \
$$PDF_ROOT_DIR/Src/Object.cpp \
$$PDF_ROOT_DIR/Src/Outline.cpp \
$$PDF_ROOT_DIR/Src/OutputDevice.cpp \
$$PDF_ROOT_DIR/Src/Page.cpp \
$$PDF_ROOT_DIR/Src/PageLabels.cpp \
$$PDF_ROOT_DIR/Src/Parser.cpp \
$$PDF_ROOT_DIR/Src/PDFDoc.cpp \
$$PDF_ROOT_DIR/Src/PSLexer.cpp \
$$PDF_ROOT_DIR/Src/RendererOutputDev.cpp \
$$PDF_ROOT_DIR/Src/SecurityHandler.cpp \
$$PDF_ROOT_DIR/Src/Stream.cpp \
$$PDF_ROOT_DIR/Src/StringExt.cpp \
$$PDF_ROOT_DIR/Src/UnicodeMap.cpp \
$$PDF_ROOT_DIR/Src/XRef.cpp \
$$PDF_ROOT_DIR/PdfReader.cpp
HEADERS += ../wasm/src/drawingfile.h
SOURCES += ../wasm/src/drawingfile.cpp

View File

@ -83,7 +83,7 @@ SOURCES += DjVu.cpp \
libdjvu/GRect.cpp \
libdjvu/GScaler.cpp \
libdjvu/GSmartPointer.cpp \
libdjvu/GString.cpp \
libdjvu/DjVuGString.cpp \
libdjvu/GThreads.cpp \
libdjvu/GUnicode.cpp \
libdjvu/GURL.cpp \
@ -139,7 +139,7 @@ HEADERS += DjVu.h \
libdjvu/GRect.h \
libdjvu/GScaler.h \
libdjvu/GSmartPointer.h \
libdjvu/GString.h \
libdjvu/DjVuGString.h \
libdjvu/GThreads.h \
libdjvu/GURL.h \
libdjvu/IFFByteStream.h \

View File

@ -68,7 +68,7 @@
#include "BSByteStream.h"
#include "GString.h"
#include "DjVuGString.h"
#undef BSORT_TIMER
#ifdef BSORT_TIMER
#include "GOS.h"

View File

@ -65,7 +65,7 @@
#include "DataPool.h"
#include "IFFByteStream.h"
#include "GString.h"
#include "DjVuGString.h"
#include "GOS.h"
#include "GURL.h"
#include "debug.h"

View File

@ -67,7 +67,7 @@
#include "GThreads.h"
#include "GString.h"
#include "DjVuGString.h"
#include "GURL.h"
#ifdef HAVE_NAMESPACES

View File

@ -118,7 +118,7 @@
#include "GString.h"
#include "DjVuGString.h"
#include "GThreads.h"
#ifdef HAVE_NAMESPACES

View File

@ -66,7 +66,7 @@
#endif
#include "GString.h"
#include "DjVuGString.h"
#ifdef HAVE_NAMESPACES
namespace DJVU {

View File

@ -66,7 +66,7 @@
#endif
#include "DjVuGlobal.h"
#include "GString.h"
#include "DjVuGString.h"
#include "GThreads.h"
#ifdef HAVE_NAMESPACES

View File

@ -91,7 +91,7 @@
//@{
#include "GString.h"
#include "DjVuGString.h"
#ifdef HAVE_NAMESPACES
namespace DJVU {

File diff suppressed because it is too large Load Diff

View File

@ -66,7 +66,7 @@
#include "DjVuInfo.h"
#include "GException.h"
#include "ByteStream.h"
#include "GString.h"
#include "DjVuGString.h"
#ifdef HAVE_NAMESPACES

View File

@ -71,7 +71,7 @@
// and added support for non I18N messages.
#include "GString.h"
#include "DjVuGString.h"
#ifdef HAVE_NAMESPACES
namespace DJVU {

View File

@ -66,7 +66,7 @@
#endif
#include "GString.h"
#include "DjVuGString.h"
#include "GThreads.h"
#include "GURL.h"

View File

@ -66,7 +66,7 @@
#include "GBitmap.h"
#include "ByteStream.h"
#include "GRect.h"
#include "GString.h"
#include "DjVuGString.h"
#include "GThreads.h"
#include "GException.h"
#include <string.h>

View File

@ -70,7 +70,7 @@
#include "GContainer.h"
#include "Arrays.h"
#include "GSmartPointer.h"
#include "GString.h"
#include "DjVuGString.h"
#ifdef HAVE_NAMESPACES
namespace DJVU {

View File

@ -68,7 +68,7 @@
#include "GSmartPointer.h"
#include "GContainer.h"
#include "GString.h"
#include "DjVuGString.h"
#include "GRect.h"
#include "GURL.h"

View File

@ -87,7 +87,7 @@
//@{
#include "DjVuGlobal.h"
#include "GString.h"
#include "DjVuGString.h"
#ifdef HAVE_NAMESPACES
namespace DJVU {

View File

@ -70,7 +70,7 @@
#include "GPixmap.h"
#include "GString.h"
#include "DjVuGString.h"
#include "GException.h"
#include "ByteStream.h"
#include "GRect.h"

View File

@ -66,7 +66,7 @@
#endif
#include "GString.h"
#include "DjVuGString.h"
#include "Arrays.h"
#include "GThreads.h"

View File

@ -63,7 +63,7 @@
# pragma implementation
#endif
#include "GString.h"
#include "DjVuGString.h"
#if HAS_ICONV
#include <iconv.h>
#endif

View File

@ -132,7 +132,7 @@
#include <stdio.h>
#include <string.h>
#include "GException.h"
#include "GString.h"
#include "DjVuGString.h"
#include "ByteStream.h"

View File

@ -173,7 +173,7 @@
//@{
#include "GString.h"
#include "DjVuGString.h"
#include "ZPCodec.h"

View File

@ -99,7 +99,7 @@ extern "C" {
#include "GPixmap.h"
#ifdef LIBJPEGNAME
#include "DjVuDynamic.h"
#include "GString.h"
#include "DjVuGString.h"
#endif // LIBJPEGNAME

View File

@ -88,7 +88,7 @@
//@{
#include "DjVuGlobal.h"
#include "GString.h"
#include "DjVuGString.h"
#include "ByteStream.h"

View File

@ -69,7 +69,7 @@
// This is purely Lizardtech stuff.
#include "GContainer.h"
#include "GString.h"
#include "DjVuGString.h"
#ifdef HAVE_NAMESPACES
namespace DJVU {

View File

@ -69,8 +69,8 @@
#include "GThreads.h"
#include "GContainer.h"
#include "GString.h"
#include "GString.h"
#include "DjVuGString.h"
#include "DjVuGString.h"
#include "ByteStream.h"
#include "GURL.h"

View File

@ -171,13 +171,21 @@ namespace PdfReader
pMeasurerCache->SetStreams(m_pInternal->m_pAppFonts->GetStreams());
m_pInternal->m_pFontManager->SetOwnerCache(pMeasurerCache);
pMeasurerCache->SetCacheSize(1);
m_pInternal->m_pGlobalParams->SetFontManager(m_pInternal->m_pFontManager);
((GlobalParamsAdaptor*)globalParams)->SetFontManager(m_pInternal->m_pFontManager);
//------------------------------------------------------
RELEASEOBJECT(m_pInternal->m_pPDFDocument);
m_pInternal->m_pPDFDocument = new PDFDoc(m_pInternal->m_pGlobalParams, data, length, owner_password, user_password);
m_eError = m_pInternal->m_pPDFDocument ? m_pInternal->m_pPDFDocument->GetErrorCode() : errorMemory;
if (!m_pInternal->m_pPDFDocument || !m_pInternal->m_pPDFDocument->CheckValidation())
RELEASEOBJECT(m_pInternal->m_pPDFDocument);
m_eError = errNone;
GString* owner_pswd = NSStrings::CreateString(owner_password);
GString* user_pswd = NSStrings::CreateString(user_password);
m_pInternal->m_pPDFDocument = new PDFDoc(data, length, owner_pswd, user_pswd);
delete owner_pswd;
delete user_pswd;
m_eError = m_pInternal->m_pPDFDocument ? m_pInternal->m_pPDFDocument->getErrorCode() : errMemory;
if (!m_pInternal->m_pPDFDocument || !m_pInternal->m_pPDFDocument->isOk())
{
RELEASEOBJECT(m_pInternal->m_pPDFDocument);
return false;
@ -185,7 +193,7 @@ namespace PdfReader
m_pInternal->m_pFontList->Clear();
return (errorNone == m_eError);
return (errNone == m_eError);
}
void CPdfReader::Close()
{

View File

@ -69,6 +69,8 @@ namespace PdfReader
virtual bool LoadFromFile(const std::wstring& file, const std::wstring& options = L"",
const std::wstring& owner_password = L"", const std::wstring& user_password = L"");
virtual bool LoadFromMemory(BYTE* data, DWORD length, const std::wstring& options = L"",
const std::wstring& owner_password = L"", const std::wstring& user_password = L"");
virtual void Close();
@ -80,6 +82,7 @@ namespace PdfReader
virtual int GetPagesCount();
virtual void GetPageInfo(int nPageIndex, double* pdWidth, double* pdHeight, double* pdDpiX, double* pdDpiY);
virtual void DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pBreak);
virtual BYTE* ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH, bool bIsFlip = false);
virtual void ConvertToRaster(int nPageIndex, const std::wstring& path, int nImageType, const int nRasterW = -1, const int nRasterH = -1);
int GetError();
@ -94,6 +97,11 @@ namespace PdfReader
NSFonts::IFontManager* GetFontManager();
std::wstring ToXml(const std::wstring& wsXmlPath);
#ifdef BUILDING_WASM_MODULE
virtual BYTE* GetStructure();
virtual BYTE* GetGlyphs(int nPageIndex, int nRasterW, int nRasterH);
virtual BYTE* GetLinks (int nPageIndex, int nRasterW, int nRasterH);
#endif
private:
CPdfReader_Private* m_pInternal;

View File

@ -55,6 +55,10 @@
#include "../../HtmlRenderer/include/HTMLRenderer3.h"
#include "../../PdfWriter/PdfRenderer.h"
#ifdef BUILDING_WASM_MODULE
#include <time.h>
#include "../../DesktopEditor/graphics/GraphicsRenderer.h"
#endif
// TODO: 1. Реализовать по-нормальному градиентные заливки (Axial и Radial)
// 2. m_pRenderer->SetAdditionalParam(L"TilingHtmlPattern", oWriter.GetXmlString());
@ -655,6 +659,22 @@ namespace PdfReader
case fontCIDType2OT: wsExt = L".cid_2ot"; break;
}
#ifdef BUILDING_WASM_MODULE
std::wstring wsTemp = ((GlobalParamsAdaptor *)globalParams)->GetTempFolder() + L"/x";
int nTime = (int)time(NULL);
for (int nIndex = 0; nIndex < 1000; ++nIndex)
{
wsTempFileName = wsTemp + std::to_wstring(nTime + nIndex) + wsExt;
if (!CApplicationFontStreams::m_pMemoryStorage->Get(wsTempFileName))
break;
}
if (CApplicationFontStreams::m_pMemoryStorage->Get(wsTempFileName))
{
pEntry->bAvailable = true;
return;
}
#else
FILE* pTempFile = NULL;
if (!NSFile::CFileBinary::OpenTempFile(&wsTempFileName, &pTempFile, L"wb", (wchar_t*)wsExt.c_str(),
(wchar_t*)((GlobalParamsAdaptor *)globalParams)->GetTempFolder().c_str(), NULL))
@ -665,6 +685,7 @@ namespace PdfReader
pEntry->bAvailable = true;
return;
}
#endif
Object oReferenceObject, oStreamObject;
oReferenceObject.initRef(oEmbRef.num, oEmbRef.gen);
@ -674,23 +695,50 @@ namespace PdfReader
{
// Внедренный шрифт неправильно записан
oStreamObject.free();
#ifndef BUILDING_WASM_MODULE
fclose(pTempFile);
if (L"" != wsTempFileName)
NSFile::CFileBinary::Remove(wsTempFileName);
#endif
pEntry->bAvailable = true;
return;
}
oStreamObject.streamReset();
#ifdef BUILDING_WASM_MODULE
LONG nCurrentPos = 0;
LONG nCurrentSize = 0xffff;
BYTE* pTempStream = new BYTE[nCurrentSize];
int nChar;
while ((nChar = oStreamObject.streamGetChar()) != EOF)
{
if (nCurrentPos >= nCurrentSize)
{
LONG nNewSize = nCurrentSize + 0xffff;
BYTE* NewBuffer = new BYTE[nNewSize];
memcpy(NewBuffer, pTempStream, nCurrentSize);
RELEASEARRAYOBJECTS(pTempStream);
pTempStream = NewBuffer;
nCurrentSize = nNewSize;
}
pTempStream[nCurrentPos++] = nChar;
}
BYTE* pResBuffer = new BYTE[nCurrentPos];
memcpy(pResBuffer, pTempStream, nCurrentPos);
RELEASEARRAYOBJECTS(pTempStream);
CApplicationFontStreams::m_pMemoryStorage->Add(wsTempFileName, pResBuffer, nCurrentPos, true);
RELEASEARRAYOBJECTS(pResBuffer);
#else
int nChar;
while ((nChar = oStreamObject.streamGetChar()) != EOF)
{
fputc(nChar, pTempFile);
}
fclose(pTempFile);
#endif
oStreamObject.streamClose();
oStreamObject.free();
fclose(pTempFile);
wsFileName = wsTempFileName;
// Для шрифтов типа Type1 нужно дописать Afm файл с метриками

View File

@ -218,6 +218,23 @@ PDFDoc::PDFDoc(char *fileNameA, GString *ownerPassword,
ok = setup(ownerPassword, userPassword);
}
PDFDoc::PDFDoc(BYTE* data, DWORD length, GString *ownerPassword,
GString *userPassword, PDFCore *coreA)
{
Object obj;
init(coreA);
fileName = NULL;
#ifdef _WIN32
fileNameU = NULL;
#endif
obj.initNull();
str = new MemStream((char*)data, 0, length, &obj);
ok = setup(ownerPassword, userPassword);
}
PDFDoc::PDFDoc(BaseStream *strA, GString *ownerPassword,
GString *userPassword, PDFCore *coreA) {
#ifdef _WIN32

View File

@ -50,6 +50,8 @@ public:
// Windows).
PDFDoc(char *fileNameA, GString *ownerPassword = NULL,
GString *userPassword = NULL, PDFCore *coreA = NULL);
PDFDoc(BYTE* data, DWORD length, GString *ownerPassword = NULL,
GString *userPassword = NULL, PDFCore *coreA = NULL);
PDFDoc(BaseStream *strA, GString *ownerPassword = NULL,
GString *userPassword = NULL, PDFCore *coreA = NULL);