mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Add STREAM_FILTER_ALREADY_DECODE
This commit is contained in:
@ -130,7 +130,7 @@ CFile.prototype._SplitPages = function(memoryBuffer)
|
||||
return ptr;
|
||||
};
|
||||
|
||||
CFile.prototype._MergePages = function(buffer)
|
||||
CFile.prototype._MergePages = function(buffer, maxID)
|
||||
{
|
||||
if (!buffer)
|
||||
return false;
|
||||
@ -139,7 +139,10 @@ CFile.prototype._MergePages = function(buffer)
|
||||
let stream2 = Module["_malloc"](data.length);
|
||||
Module["HEAP8"].set(data, stream2);
|
||||
|
||||
let bRes = Module["_MergePages"](this.nativeFile, stream2, data.length);
|
||||
if (!maxID)
|
||||
maxID = 0;
|
||||
|
||||
let bRes = Module["_MergePages"](this.nativeFile, stream2, data.length, maxID);
|
||||
if (bRes == 1)
|
||||
this.stream.push(stream2);
|
||||
else
|
||||
|
||||
@ -1627,13 +1627,34 @@ bool CPdfEditor::SplitPages(const int* arrPageIndex, unsigned int unLength, PDFD
|
||||
pageObj.dictGetValNF(nIndex, &oTemp);
|
||||
PdfWriter::CObjectBase* pBase = DictToCDictObject2(&oTemp, pDoc, xref, &m_mObjManager, nStartRefID);
|
||||
pPage->Add(chKey, pBase);
|
||||
if (strcmp("Contents", chKey) == 0)
|
||||
{
|
||||
if (pBase->GetType() == PdfWriter::object_type_ARRAY)
|
||||
{
|
||||
PdfWriter::CArrayObject* pArr = (PdfWriter::CArrayObject*)pBase;
|
||||
for (int j = 0; j < pArr->GetCount(); ++j)
|
||||
{
|
||||
pBase = pArr->Get(j);
|
||||
if (pBase->GetType() == PdfWriter::object_type_DICT)
|
||||
{
|
||||
PdfWriter::CDictObject* pDict = (PdfWriter::CDictObject*)pBase;
|
||||
if (pDict->Get("Filter"))
|
||||
pDict->SetFilter(STREAM_FILTER_ALREADY_DECODE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (pBase->GetType() == PdfWriter::object_type_DICT)
|
||||
{
|
||||
PdfWriter::CDictObject* pDict = (PdfWriter::CDictObject*)pBase;
|
||||
if (pDict->Get("Filter"))
|
||||
pDict->SetFilter(STREAM_FILTER_ALREADY_DECODE);
|
||||
}
|
||||
}
|
||||
oTemp.free();
|
||||
}
|
||||
pPage->Fix();
|
||||
if (m_nMode == Mode::WriteAppend)
|
||||
{
|
||||
// pPage->AddContents(); // TODO pPage->AddContents чтобы можно было дописать изменения, если понадобится
|
||||
}
|
||||
pDoc->FixEditPage(pPage);
|
||||
else
|
||||
m_pWriter->SetNeedAddHelvetica(false); // TODO дописывает шрифт для адекватного редактирования Adobe pdf без текст. Убрать при реализации map шрифтов
|
||||
pageObj.free();
|
||||
|
||||
@ -1522,6 +1522,18 @@ namespace PdfWriter
|
||||
|
||||
return true;
|
||||
}
|
||||
void CDocument::FixEditPage(CPage* _pPage, int nPageIndex)
|
||||
{
|
||||
CPage* pPage = _pPage ? _pPage : m_mEditPages[nPageIndex];
|
||||
if (!pPage)
|
||||
return;
|
||||
|
||||
pPage->AddContents(m_pXref);
|
||||
#ifndef FILTER_FLATE_DECODE_DISABLED
|
||||
if (m_unCompressMode & COMP_TEXT)
|
||||
pPage->SetFilter(STREAM_FILTER_FLATE_DECODE);
|
||||
#endif
|
||||
}
|
||||
void CDocument::AddEditPage(CPage* pPage, int nPageIndex)
|
||||
{
|
||||
m_mEditPages[nPageIndex] = pPage;
|
||||
|
||||
@ -196,6 +196,7 @@ namespace PdfWriter
|
||||
bool EditResources(CXref* pXref, CResourcesDict* pResources);
|
||||
std::pair<int, int> GetPageRef(int nPageIndex);
|
||||
bool EditPage(CXref* pXref, CPage* pPage, int nPageIndex);
|
||||
void FixEditPage(CPage* pPage, int nPageIndex = 0);
|
||||
void AddEditPage(CPage* pPage, int nPageIndex);
|
||||
CPage* AddPage(int nPageIndex, CPage* _pNewPage = NULL);
|
||||
bool DeletePage(int nPageIndex);
|
||||
|
||||
@ -467,7 +467,7 @@ namespace PdfWriter
|
||||
}
|
||||
void SetFilter(unsigned int unFiler)
|
||||
{
|
||||
m_unFilter = unFiler;
|
||||
m_unFilter |= unFiler;
|
||||
}
|
||||
void SetStream(CXref* pXref, CStream* pStream, bool bThis = true);
|
||||
|
||||
|
||||
@ -366,6 +366,12 @@ namespace PdfWriter
|
||||
m_pContents->Add(pNewContents);
|
||||
Add("Contents", m_pContents);
|
||||
}
|
||||
else if (pContents->GetType() == object_type_DICT)
|
||||
{
|
||||
m_pContents = new CArrayObject();
|
||||
m_pContents->Add(pContents);
|
||||
Add("Contents", m_pContents);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -476,7 +476,7 @@ namespace PdfWriter
|
||||
|
||||
#ifndef FILTER_FLATE_DECODE_DISABLED
|
||||
|
||||
if (unFilter & STREAM_FILTER_FLATE_DECODE)
|
||||
if ((unFilter & STREAM_FILTER_FLATE_DECODE) && !(unFilter & STREAM_FILTER_ALREADY_DECODE))
|
||||
return WriteStreamWithDeflate(pStream, pEncrypt);
|
||||
|
||||
#endif
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
#include "../../DesktopEditor/common/File.h"
|
||||
|
||||
#define STREAM_FILTER_NONE 0x0000
|
||||
#define STREAM_FILTER_ALREADY_DECODE 0x0001
|
||||
#define STREAM_FILTER_ASCIIHEX 0x0100
|
||||
#define STREAM_FILTER_ASCII85 0x0200
|
||||
#define STREAM_FILTER_FLATE_DECODE 0x0400
|
||||
|
||||
Reference in New Issue
Block a user