mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Merge remote-tracking branch 'origin/release/v9.0.0' into feature/pdf-page
# Conflicts: # DesktopEditor/graphics/pro/js/wasm/js/drawingfile.js # PdfFile/OnlineOfficeBinToPdf.cpp # PdfFile/PdfEditor.cpp # PdfFile/PdfFile.cpp # PdfFile/PdfFile.h # PdfFile/SrcReader/PdfAnnot.cpp # PdfFile/SrcReader/PdfAnnot.h # PdfFile/SrcWriter/Document.cpp # PdfFile/SrcWriter/Document.h # PdfFile/test/test.cpp
This commit is contained in:
@ -1174,7 +1174,7 @@ CAnnotWidgetBtn::CAnnotWidgetBtn(PDFDoc* pdfDoc, AcroFormField* pField, int nSta
|
||||
|
||||
// 14 - Имя вкл состояния - AP - N - Yes
|
||||
Object oNorm;
|
||||
if (pField->fieldLookup("AP", &oObj)->isDict() && oObj.dictLookup("N", &oNorm)->isDict())
|
||||
if (pField->fieldLookup("AP", &oObj)->isDict() && oObj.dictLookup("N", &oNorm)->isDict() && oOpt.isNull())
|
||||
{
|
||||
for (int j = 0, nNormLength = oNorm.dictGetLength(); j < nNormLength; ++j)
|
||||
{
|
||||
@ -1183,36 +1183,6 @@ CAnnotWidgetBtn::CAnnotWidgetBtn(PDFDoc* pdfDoc, AcroFormField* pField, int nSta
|
||||
{
|
||||
m_unFlags |= (1 << 14);
|
||||
m_sAP_N_Yes = sNormName;
|
||||
|
||||
int nOptI;
|
||||
if (oOpt.isArray() && isdigit(sNormName[0]) && (nOptI = std::stoi(sNormName)) >= 0 && nOptI < oOpt.arrayGetLength())
|
||||
{
|
||||
Object oOptJ;
|
||||
if (!oOpt.arrayGet(nOptI, &oOptJ) || !(oOptJ.isString() || oOptJ.isArray()))
|
||||
{
|
||||
oOptJ.free();
|
||||
break;
|
||||
}
|
||||
|
||||
if (oOptJ.isString())
|
||||
{
|
||||
TextString* s = new TextString(oOptJ.getString());
|
||||
m_sAP_N_Yes = NSStringExt::CConverter::GetUtf8FromUTF32(s->getUnicode(), s->getLength());
|
||||
delete s;
|
||||
}
|
||||
else if (oOptJ.isArray() && oOptJ.arrayGetLength() > 0)
|
||||
{
|
||||
Object oOptJ2;
|
||||
if (oOptJ.arrayGet(0, &oOptJ2)->isString())
|
||||
{
|
||||
TextString* s = new TextString(oOptJ2.getString());
|
||||
m_sAP_N_Yes = NSStringExt::CConverter::GetUtf8FromUTF32(s->getUnicode(), s->getLength());
|
||||
delete s;
|
||||
}
|
||||
oOptJ2.free();
|
||||
}
|
||||
oOptJ.free();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1268,7 +1238,7 @@ CAnnotWidgetCh::CAnnotWidgetCh(PDFDoc* pdfDoc, AcroFormField* pField, int nStart
|
||||
|
||||
Object oOpt;
|
||||
// 10 - Список значений
|
||||
if (pField->fieldLookup("Opt", &oOpt)->isArray())
|
||||
if (oField.dictLookup("Opt", &oOpt)->isArray())
|
||||
{
|
||||
m_unFlags |= (1 << 10);
|
||||
int nOptLength = oOpt.arrayGetLength();
|
||||
@ -1411,7 +1381,10 @@ CAnnotWidget::CAnnotWidget(PDFDoc* pdfDoc, AcroFormField* pField, int nStartRefI
|
||||
}
|
||||
|
||||
// Флаг - Ff
|
||||
m_unFieldFlag = pField->getFlags();
|
||||
m_unFieldFlag = -1;
|
||||
if (oField.dictLookup("Ff", &oObj)->isInt())
|
||||
m_unFieldFlag = oObj.getInt();
|
||||
oObj.free();
|
||||
|
||||
// 0 - Альтернативное имя поля, используется во всплывающей подсказке и сообщениях об ошибке - TU
|
||||
m_sTU = FieldLookupString(pField, "TU", 0);
|
||||
@ -1495,9 +1468,12 @@ CAnnotWidget::CAnnotWidget(PDFDoc* pdfDoc, AcroFormField* pField, int nStartRefI
|
||||
// 18 - Частичное имя поля - T
|
||||
m_sT = DictLookupString(&oField, "T", 18);
|
||||
|
||||
// 20 - OO метаданные форм - OMetadata
|
||||
m_sOMetadata = DictLookupString(&oField, "OMetadata", 20);
|
||||
|
||||
// Action - A
|
||||
Object oAction;
|
||||
if (pField->fieldLookup("A", &oAction)->isDict())
|
||||
if (oField.dictLookup("A", &oAction)->isDict())
|
||||
{
|
||||
std::string sAA = "A";
|
||||
CAction* pA = getAction(pdfDoc, &oAction);
|
||||
@ -1511,11 +1487,6 @@ CAnnotWidget::CAnnotWidget(PDFDoc* pdfDoc, AcroFormField* pField, int nStartRefI
|
||||
|
||||
// Actions - AA
|
||||
Object oAA;
|
||||
Object parent, parent2;
|
||||
bool bParent = oField.dictLookup("Parent", &parent)->isDict();
|
||||
bool bAA = bParent && parent.dictLookup("AA", &oAA)->isDict();
|
||||
oAA.free();
|
||||
|
||||
if (oField.dictLookup("AA", &oAA)->isDict())
|
||||
{
|
||||
for (int j = 0; j < oAA.dictGetLength(); ++j)
|
||||
@ -1523,8 +1494,6 @@ CAnnotWidget::CAnnotWidget(PDFDoc* pdfDoc, AcroFormField* pField, int nStartRefI
|
||||
if (oAA.dictGetVal(j, &oAction)->isDict())
|
||||
{
|
||||
std::string sAA(oAA.dictGetKey(j));
|
||||
if (bAA && (sAA == "K" || sAA == "F" || sAA == "V" || sAA == "C"))
|
||||
continue;
|
||||
CAction* pA = getAction(pdfDoc, &oAction);
|
||||
if (pA)
|
||||
{
|
||||
@ -1537,39 +1506,6 @@ CAnnotWidget::CAnnotWidget(PDFDoc* pdfDoc, AcroFormField* pField, int nStartRefI
|
||||
}
|
||||
oAA.free();
|
||||
|
||||
if (bParent)
|
||||
{
|
||||
int depth = 0;
|
||||
while (parent.isDict() && depth < 50)
|
||||
{
|
||||
if (parent.dictLookup("AA", &oAA)->isDict())
|
||||
{
|
||||
for (int j = 0; j < oAA.dictGetLength(); ++j)
|
||||
{
|
||||
if (oAA.dictGetVal(j, &oAction)->isDict())
|
||||
{
|
||||
std::string sAA(oAA.dictGetKey(j));
|
||||
if (sAA == "E" || sAA == "X" || sAA == "D" || sAA == "U" || sAA == "Fo" || sAA == "Bl" || sAA == "PO" || sAA == "PC" || sAA == "PV" || sAA == "PI")
|
||||
continue;
|
||||
CAction* pA = getAction(pdfDoc, &oAction);
|
||||
if (pA)
|
||||
{
|
||||
pA->sType = sAA;
|
||||
m_arrAction.push_back(pA);
|
||||
}
|
||||
}
|
||||
oAction.free();
|
||||
}
|
||||
}
|
||||
oAA.free();
|
||||
parent.dictLookup("Parent", &parent2);
|
||||
parent.free();
|
||||
parent = parent2;
|
||||
++depth;
|
||||
}
|
||||
}
|
||||
parent.free();
|
||||
|
||||
oField.free();
|
||||
}
|
||||
CAnnotWidget::~CAnnotWidget()
|
||||
@ -2569,7 +2505,7 @@ void CAnnots::getParents(XRef* xref, Object* oFieldRef, int nStartRefID)
|
||||
|
||||
Object oField;
|
||||
CAnnotParent* pAnnotParent = new CAnnotParent();
|
||||
if (!pAnnotParent || !oFieldRef->fetch(xref, &oField)->isDict())
|
||||
if (!pAnnotParent || !oFieldRef->fetch(pdfDoc->getXRef(), &oField)->isDict())
|
||||
{
|
||||
oField.free();
|
||||
RELEASEOBJECT(pAnnotParent);
|
||||
@ -2645,22 +2581,90 @@ void CAnnots::getParents(XRef* xref, Object* oFieldRef, int nStartRefID)
|
||||
for (int j = 0; j < nOptLength; ++j)
|
||||
{
|
||||
Object oOptJ;
|
||||
if (!oOpt.arrayGet(j, &oOptJ) || !oOptJ.isString())
|
||||
if (!oOpt.arrayGet(j, &oOptJ) || !(oOptJ.isString() || oOptJ.isArray()))
|
||||
{
|
||||
oOptJ.free();
|
||||
continue;
|
||||
}
|
||||
|
||||
TextString* s = new TextString(oOptJ.getString());
|
||||
pAnnotParent->arrOpt.push_back(NSStringExt::CConverter::GetUtf8FromUTF32(s->getUnicode(), s->getLength()));
|
||||
delete s;
|
||||
std::string sOpt1, sOpt2;
|
||||
if (oOptJ.isArray() && oOptJ.arrayGetLength() > 1)
|
||||
{
|
||||
Object oOptJ2;
|
||||
if (oOptJ.arrayGet(0, &oOptJ2)->isString())
|
||||
{
|
||||
TextString* s = new TextString(oOptJ2.getString());
|
||||
sOpt1 = NSStringExt::CConverter::GetUtf8FromUTF32(s->getUnicode(), s->getLength());
|
||||
delete s;
|
||||
}
|
||||
oOptJ2.free();
|
||||
if (oOptJ.arrayGet(1, &oOptJ2)->isString())
|
||||
{
|
||||
TextString* s = new TextString(oOptJ2.getString());
|
||||
sOpt2 = NSStringExt::CConverter::GetUtf8FromUTF32(s->getUnicode(), s->getLength());
|
||||
delete s;
|
||||
}
|
||||
oOptJ2.free();
|
||||
}
|
||||
else if (oOptJ.isString())
|
||||
{
|
||||
TextString* s = new TextString(oOptJ.getString());
|
||||
sOpt2 = NSStringExt::CConverter::GetUtf8FromUTF32(s->getUnicode(), s->getLength());
|
||||
delete s;
|
||||
}
|
||||
pAnnotParent->arrOpt.push_back(std::make_pair(sOpt1, sOpt2));
|
||||
oOptJ.free();
|
||||
}
|
||||
|
||||
if (!pAnnotParent->arrOpt.empty())
|
||||
pAnnotParent->unFlags |= (1 << 6);
|
||||
}
|
||||
oOpt.free();
|
||||
|
||||
// 7 - Флаг - Ff
|
||||
if (oField.dictLookup("Ff", &oObj)->isInt())
|
||||
{
|
||||
pAnnotParent->unFieldFlag = oObj.getInt();
|
||||
pAnnotParent->unFlags |= (1 << 7);
|
||||
}
|
||||
oObj.free();
|
||||
|
||||
// 8 - Actions - A/AA
|
||||
Object oAction;
|
||||
if (oField.dictLookup("A", &oAction)->isDict())
|
||||
{
|
||||
std::string sAA = "A";
|
||||
CAction* pA = getAction(pdfDoc, &oAction);
|
||||
if (pA)
|
||||
{
|
||||
pA->sType = sAA;
|
||||
pAnnotParent->arrAction.push_back(pA);
|
||||
pAnnotParent->unFlags |= (1 << 8);
|
||||
}
|
||||
}
|
||||
oAction.free();
|
||||
|
||||
Object oAA;
|
||||
if (oField.dictLookup("AA", &oAA)->isDict())
|
||||
{
|
||||
for (int j = 0; j < oAA.dictGetLength(); ++j)
|
||||
{
|
||||
if (oAA.dictGetVal(j, &oAction)->isDict())
|
||||
{
|
||||
std::string sAA(oAA.dictGetKey(j));
|
||||
CAction* pA = getAction(pdfDoc, &oAction);
|
||||
if (pA)
|
||||
{
|
||||
pA->sType = sAA;
|
||||
pAnnotParent->arrAction.push_back(pA);
|
||||
pAnnotParent->unFlags |= (1 << 8);
|
||||
}
|
||||
}
|
||||
oAction.free();
|
||||
}
|
||||
}
|
||||
oAA.free();
|
||||
|
||||
m_arrParents.push_back(pAnnotParent);
|
||||
|
||||
Object oParentRefObj;
|
||||
@ -3470,6 +3474,7 @@ void CAnnotAP::Draw(PDFDoc* pdfDoc, Object* oAP, int nRasterH, int nBackgroundCo
|
||||
void CAnnotAP::Draw(PDFDoc* pdfDoc, Object* oAP, int nRasterH, int nBackgroundColor, Object* oAnnotRef, const char* sView)
|
||||
{
|
||||
((GlobalParamsAdaptor*)globalParams)->setDrawFormField(true);
|
||||
|
||||
// Отрисовка внешних видов аннотации
|
||||
Object oAnnot;
|
||||
XRef* xref = pdfDoc->getXRef();
|
||||
@ -3602,9 +3607,23 @@ void CAnnots::CAnnotParent::ToWASM(NSWasm::CData& oRes)
|
||||
}
|
||||
if (unFlags & (1 << 6))
|
||||
{
|
||||
oRes.AddInt((unsigned int)arrOpt.size());
|
||||
oRes.AddInt(arrOpt.size());
|
||||
for (int i = 0; i < arrOpt.size(); ++i)
|
||||
oRes.WriteString(arrOpt[i]);
|
||||
{
|
||||
oRes.WriteString(arrOpt[i].first);
|
||||
oRes.WriteString(arrOpt[i].second);
|
||||
}
|
||||
}
|
||||
if (unFlags & (1 << 7))
|
||||
oRes.AddInt(unFieldFlag);
|
||||
if (unFlags & (1 << 8))
|
||||
{
|
||||
oRes.AddInt(arrAction.size());
|
||||
for (int i = 0; i < arrAction.size(); ++i)
|
||||
{
|
||||
oRes.WriteString(arrAction[i]->sType);
|
||||
arrAction[i]->ToWASM(oRes);
|
||||
}
|
||||
}
|
||||
}
|
||||
void CAnnot::ToWASM(NSWasm::CData& oRes)
|
||||
@ -3701,6 +3720,8 @@ void CAnnotWidget::ToWASM(NSWasm::CData& oRes)
|
||||
oRes.WriteString(m_sT);
|
||||
if (m_unFlags & (1 << 19))
|
||||
oRes.WriteString(m_sButtonFontName);
|
||||
if (m_unFlags & (1 << 20))
|
||||
oRes.WriteString(m_sOMetadata);
|
||||
oRes.AddInt(m_arrAction.size());
|
||||
for (int i = 0; i < m_arrAction.size(); ++i)
|
||||
{
|
||||
@ -3842,7 +3863,7 @@ void CAnnotWidgetTx::ToWASM(NSWasm::CData& oRes)
|
||||
oRes.WriteString(m_sV);
|
||||
if (m_unFlags & (1 << 10))
|
||||
oRes.AddInt(m_unMaxLen);
|
||||
if (m_unFieldFlag & (1 << 25))
|
||||
if (m_unFlags & (1 << 11))
|
||||
oRes.WriteString(m_sRV);
|
||||
}
|
||||
void CAnnotWidgetCh::ToWASM(NSWasm::CData& oRes)
|
||||
|
||||
Reference in New Issue
Block a user