mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-10 17:38:38 +08:00
Merge branch 'release/v9.4.0' of https://git.onlyoffice.com/ONLYOFFICE/core into release/v9.4.0
This commit is contained in:
@ -897,6 +897,7 @@ CAnnotFieldInfo::CWidgetAnnotPr::CButtonWidgetPr* CAnnotFieldInfo::CWidgetAnn
|
||||
CAnnotFieldInfo::CWidgetAnnotPr::CTextWidgetPr* CAnnotFieldInfo::CWidgetAnnotPr::GetTextWidgetPr() { return m_pTextPr; }
|
||||
CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr* CAnnotFieldInfo::CWidgetAnnotPr::GetChoiceWidgetPr() { return m_pChoicePr; }
|
||||
CAnnotFieldInfo::CWidgetAnnotPr::CSignatureWidgetPr* CAnnotFieldInfo::CWidgetAnnotPr::GetSignatureWidgetPr() { return m_pSignaturePr; }
|
||||
void CAnnotFieldInfo::CWidgetAnnotPr::SetFontName(const std::wstring& sName) { m_wsFN = sName; }
|
||||
CAnnotFieldInfo::CWidgetAnnotPr::CWidgetAnnotPr(BYTE nType)
|
||||
{
|
||||
m_pButtonPr = NULL;
|
||||
|
||||
@ -203,6 +203,8 @@ public:
|
||||
const std::vector<double>& GetBG();
|
||||
const std::vector<CActionFieldPr*>& GetActions();
|
||||
|
||||
void SetFontName(const std::wstring& sName);
|
||||
|
||||
CButtonWidgetPr* GetButtonWidgetPr();
|
||||
CTextWidgetPr* GetTextWidgetPr();
|
||||
CChoiceWidgetPr* GetChoiceWidgetPr();
|
||||
|
||||
@ -1098,7 +1098,10 @@ bool CPdfEditor::IncrementalUpdates()
|
||||
return true;
|
||||
|
||||
m_nMode = Mode::WriteAppend;
|
||||
PDFDoc* pPDFDocument = m_pReader->GetPDFDocument(0);
|
||||
PDFDoc* pPDFDocument = NULL;
|
||||
PdfReader::CPdfFontList* pFontList = NULL;
|
||||
int nStartRefID = 0;
|
||||
m_pReader->GetPageIndex(0, &pPDFDocument, &pFontList, &nStartRefID);
|
||||
XRef* xref = pPDFDocument->getXRef();
|
||||
PdfWriter::CDocument* pDoc = m_pWriter->GetDocument();
|
||||
|
||||
@ -1330,14 +1333,28 @@ bool CPdfEditor::IncrementalUpdates()
|
||||
bRes = pDoc->EditResources(pDRXref, pDR);
|
||||
}
|
||||
pagesRefObj.free();
|
||||
|
||||
if (form)
|
||||
{
|
||||
Object oDR;
|
||||
Object* oAcroForm = form->getAcroFormObj();
|
||||
if (oAcroForm->dictLookup("DR", &oDR)->isDict())
|
||||
{
|
||||
Dict* pResources = oDR.getDict();
|
||||
ScanFonts(pPDFDocument, pResources);
|
||||
}
|
||||
oDR.free();
|
||||
}
|
||||
return bRes;
|
||||
}
|
||||
void CPdfEditor::NewFrom()
|
||||
{
|
||||
PdfWriter::CDocument* pDoc = m_pWriter->GetDocument();
|
||||
Object oCatalog;
|
||||
PDFDoc* pPDFDocument = m_pReader->GetPDFDocument(0);
|
||||
PDFDoc* pPDFDocument = NULL;
|
||||
PdfReader::CPdfFontList* pFontList = NULL;
|
||||
int nStartRefID = 0;
|
||||
m_pReader->GetPageIndex(0, &pPDFDocument, &pFontList, &nStartRefID);
|
||||
XRef* xref = pPDFDocument->getXRef();
|
||||
if (!xref->getCatalog(&oCatalog)->isDict())
|
||||
{
|
||||
@ -1564,8 +1581,12 @@ void CPdfEditor::NewFrom()
|
||||
}
|
||||
}
|
||||
}
|
||||
oTemp2.free(); oTemp.free();
|
||||
oTemp2.free();
|
||||
pDR->Fix();
|
||||
|
||||
Dict* pResources = oTemp.getDict();
|
||||
ScanFonts(pPDFDocument, pResources);
|
||||
oTemp.free();
|
||||
continue;
|
||||
}
|
||||
else
|
||||
@ -2724,7 +2745,11 @@ bool CPdfEditor::SplitPages(const int* arrPageIndex, unsigned int unLength, PDFD
|
||||
}
|
||||
}
|
||||
}
|
||||
oTemp2.free(); oTemp.free();
|
||||
oTemp2.free();
|
||||
|
||||
Dict* pResources = oTemp.getDict();
|
||||
ScanFonts(pPDFDocument, pResources);
|
||||
oTemp.free();
|
||||
continue;
|
||||
}
|
||||
else
|
||||
@ -4189,12 +4214,7 @@ void CPdfEditor::ClearPage()
|
||||
// Mode::WriteAppend && Mode::WriteNew
|
||||
// Reading and processing fonts from page
|
||||
Dict* pResources = pOPage->getResourceDict();
|
||||
if (pResources)
|
||||
{
|
||||
std::vector<int> arrUniqueResources;
|
||||
ScanAndProcessFonts(pPDFDocument, xref, pResources, 0, arrUniqueResources, pFontList, nStartRefID);
|
||||
m_pReader->SetFonts(m_nEditPage);
|
||||
}
|
||||
ScanFonts(pPDFDocument, pResources);
|
||||
oAnnots.free();
|
||||
}
|
||||
void CPdfEditor::AddShapeXML(const std::string& sXML)
|
||||
@ -4443,6 +4463,18 @@ std::vector<double> CPdfEditor::WriteRedact(const std::vector<std::wstring>& arr
|
||||
}
|
||||
return arrRes;
|
||||
}
|
||||
void CPdfEditor::ScanFonts(PDFDoc* pPDFDocument, Dict* pResources)
|
||||
{
|
||||
if (!pResources)
|
||||
return;
|
||||
XRef* xref = pPDFDocument->getXRef();
|
||||
int nStartRefID = m_pReader->GetStartRefID(pPDFDocument);
|
||||
PdfReader::CPdfFontList* pFontList = m_pReader->GetFontList(pPDFDocument);
|
||||
|
||||
std::vector<int> arrUniqueResources;
|
||||
ScanAndProcessFonts(pPDFDocument, xref, pResources, 0, arrUniqueResources, pFontList, nStartRefID);
|
||||
m_pReader->SetFonts(pFontList);
|
||||
}
|
||||
void CPdfEditor::ScanAndProcessFonts(PDFDoc* pPDFDocument, XRef* xref, Dict* pResources, int nDepth, std::vector<int>& arrUniqueResources, PdfReader::CPdfFontList* pFontList, int nStartRefID)
|
||||
{
|
||||
if (nDepth > 5 || !pResources)
|
||||
|
||||
@ -116,6 +116,7 @@ private:
|
||||
bool SplitPages(const int* arrPageIndex, unsigned int unLength, PDFDoc* _pDoc, int nStartRefID);
|
||||
bool ChangeFullNameParent(int nParent, const std::string& sPrefixForm, std::vector<int>& arrRename);
|
||||
void ScanAndProcessFonts(PDFDoc* pPDFDocument, XRef* xref, Dict* pResources, int nDepth, std::vector<int>& arrUniqueResources, PdfReader::CPdfFontList* pFontList, int nStartRefID);
|
||||
void ScanFonts(PDFDoc* pPDFDocument, Dict* pResources);
|
||||
|
||||
struct CRedactData
|
||||
{
|
||||
|
||||
@ -508,7 +508,12 @@ BYTE* CPdfFile::GetWidgets()
|
||||
void CPdfFile::SetPageFonts(int nPageIndex)
|
||||
{
|
||||
if (m_pInternal->pReader)
|
||||
m_pInternal->pReader->SetFonts(nPageIndex);
|
||||
{
|
||||
PDFDoc* pDoc = NULL;
|
||||
PdfReader::CPdfFontList* pFontList = NULL;
|
||||
m_pInternal->pReader->GetPageIndex(nPageIndex, &pDoc, &pFontList);
|
||||
m_pInternal->pReader->SetFonts(pFontList);
|
||||
}
|
||||
}
|
||||
BYTE* CPdfFile::GetAnnotEmbeddedFonts()
|
||||
{
|
||||
@ -1444,6 +1449,34 @@ HRESULT CPdfFile::AdvancedCommand(IAdvancedCommand* command)
|
||||
if (nFlags & (1 << 15))
|
||||
m_pInternal->pEditor->EditAnnot(pCommand->GetPage(), pCommand->GetCopyAP());
|
||||
}
|
||||
if (pCommand->IsWidget())
|
||||
{
|
||||
CAnnotFieldInfo::CWidgetAnnotPr* pPr = pCommand->GetWidgetAnnotPr();
|
||||
std::wstring wsFontName = pPr->GetFontName();
|
||||
|
||||
size_t lastSpace = wsFontName.find_last_of(L' ');
|
||||
if (lastSpace != std::wstring::npos && lastSpace + 1 == wsFontName.size() - 32)
|
||||
{
|
||||
std::wstring sHash = wsFontName.substr(lastSpace + 1);
|
||||
bool bValidHash = true;
|
||||
for (wchar_t c : sHash)
|
||||
{
|
||||
if (!((c >= L'A' && c <= L'F') || (c >= L'0' && c <= L'9')))
|
||||
{
|
||||
bValidHash = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bValidHash)
|
||||
{
|
||||
std::wstring sName = wsFontName.substr(0, lastSpace);
|
||||
wsFontName = sName;
|
||||
}
|
||||
}
|
||||
|
||||
pPr->SetFontName(wsFontName);
|
||||
}
|
||||
}
|
||||
return m_pInternal->pWriter->AddAnnotField(m_pInternal->pAppFonts, pCommand);
|
||||
}
|
||||
|
||||
@ -245,6 +245,18 @@ int CPdfReader::GetNumPagesBefore(PDFDoc* _pDoc)
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
PdfReader::CPdfFontList* CPdfReader::GetFontList(PDFDoc* _pDoc)
|
||||
{
|
||||
for (CPdfReaderContext* pPDFContext : m_vPDFContext)
|
||||
{
|
||||
if (!pPDFContext || !pPDFContext->m_pDocument)
|
||||
continue;
|
||||
PDFDoc* pDoc = pPDFContext->m_pDocument;
|
||||
if (_pDoc == pDoc)
|
||||
return pPDFContext->m_pFontList;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
std::string CPdfReader::GetPrefixForm(PDFDoc* _pDoc)
|
||||
{
|
||||
for (CPdfReaderContext* pPDFContext : m_vPDFContext)
|
||||
@ -1299,15 +1311,11 @@ BYTE* CPdfReader::GetWidgets()
|
||||
oRes.ClearWithoutAttack();
|
||||
return bRes;
|
||||
}
|
||||
void CPdfReader::SetFonts(int _nPageIndex)
|
||||
void CPdfReader::SetFonts(PdfReader::CPdfFontList* pFontList)
|
||||
{
|
||||
if (m_vPDFContext.empty())
|
||||
return;
|
||||
|
||||
PDFDoc* pDoc = NULL;
|
||||
PdfReader::CPdfFontList* pFontList = NULL;
|
||||
GetPageIndex(_nPageIndex, &pDoc, &pFontList);
|
||||
|
||||
const std::map<Ref, PdfReader::TFontEntry*>& mapFonts = pFontList->GetFonts();
|
||||
for (std::map<Ref, PdfReader::TFontEntry*>::const_iterator it = mapFonts.begin(); it != mapFonts.end(); ++it)
|
||||
{
|
||||
|
||||
@ -110,11 +110,12 @@ public:
|
||||
PDFDoc* GetPDFDocument(int PDFIndex);
|
||||
int GetStartRefID(PDFDoc* pDoc);
|
||||
int GetNumPagesBefore(PDFDoc* pDoc);
|
||||
PdfReader::CPdfFontList* GetFontList(PDFDoc* pDoc);
|
||||
std::string GetPrefixForm(PDFDoc* pDoc);
|
||||
int FindRefNum(int nObjID, PDFDoc** pDoc = NULL, int* nStartRefID = NULL);
|
||||
int GetPageIndex(int nPageIndex, PDFDoc** pDoc = NULL, PdfReader::CPdfFontList** pFontList = NULL, int* nStartRefID = NULL);
|
||||
|
||||
void SetFonts(int nPageIndex);
|
||||
void SetFonts(PdfReader::CPdfFontList* pFontList);
|
||||
BYTE* GetStructure();
|
||||
BYTE* GetLinks(int nPageIndex);
|
||||
BYTE* GetWidgets();
|
||||
|
||||
Reference in New Issue
Block a user