mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Fix name of AP.N.Yes
This commit is contained in:
@ -1401,14 +1401,120 @@ bool CPdfEditor::DeleteAnnot(int nID, Object* oAnnots)
|
||||
Object oAnnotRef, oAnnot;
|
||||
if (oAnnots->arrayGetNF(i, &oAnnotRef)->isRef() && oAnnotRef.getRefNum() == nID)
|
||||
{
|
||||
bRes = pDoc->DeleteAnnot(oAnnotRef.getRefNum(), oAnnotRef.getRefGen());
|
||||
bool bNeed = false;
|
||||
if (oAnnotRef.fetch(xref, &oAnnot)->isDict())
|
||||
{
|
||||
Object oPopupRef;
|
||||
if (oAnnot.dictLookupNF("Popup", &oPopupRef)->isRef())
|
||||
pDoc->DeleteAnnot(oPopupRef.getRefNum(), oPopupRef.getRefGen());
|
||||
oPopupRef.free();
|
||||
Object oType;
|
||||
if (oAnnot.dictLookup("Subtype", &oType)->isName("Widget"))
|
||||
{
|
||||
char* sName = NULL;
|
||||
Object oFT;
|
||||
if (oAnnot.dictLookup("FT", &oFT)->isName())
|
||||
sName = oFT.getName();
|
||||
|
||||
if (!sName)
|
||||
{
|
||||
Object oParent, oParent2;
|
||||
oAnnot.dictLookup("Parent", &oParent);
|
||||
while (oParent.isDict())
|
||||
{
|
||||
if (oParent.dictLookup("FT", &oFT)->isName())
|
||||
{
|
||||
sName = oFT.getName();
|
||||
break;
|
||||
}
|
||||
oFT.free();
|
||||
oParent.dictLookup("Parent", &oParent2);
|
||||
oParent.free();
|
||||
oParent = oParent2;
|
||||
}
|
||||
oParent.free();
|
||||
}
|
||||
|
||||
if (sName && strcmp("Btn", sName) == 0)
|
||||
{
|
||||
bool bPushButton = false;
|
||||
oFT.free();
|
||||
int nFf = 0;
|
||||
if (oAnnot.dictLookup("Ff", &oFT)->isInt())
|
||||
nFf = oFT.getInt();
|
||||
if (!nFf)
|
||||
{
|
||||
Object oParent, oParent2;
|
||||
oAnnot.dictLookup("Parent", &oParent);
|
||||
while (oParent.isDict())
|
||||
{
|
||||
if (oParent.dictLookup("Ff", &oFT)->isInt())
|
||||
{
|
||||
nFf = oFT.getInt();
|
||||
break;
|
||||
}
|
||||
oFT.free();
|
||||
oParent.dictLookup("Parent", &oParent2);
|
||||
oParent.free();
|
||||
oParent = oParent2;
|
||||
}
|
||||
oParent.free();
|
||||
}
|
||||
|
||||
bPushButton = (bool)((nFf >> 16) & 1);
|
||||
if (!bPushButton)
|
||||
{
|
||||
oFT.free();
|
||||
bNeed = oAnnot.dictLookup("Opt", &oFT)->isArray();
|
||||
if (!bNeed)
|
||||
{
|
||||
Object oParent, oParent2;
|
||||
oAnnot.dictLookup("Parent", &oParent);
|
||||
while (oParent.isDict())
|
||||
{
|
||||
if (oParent.dictLookup("Opt", &oFT)->isArray())
|
||||
{
|
||||
bNeed = true;
|
||||
break;
|
||||
}
|
||||
oFT.free();
|
||||
oParent.dictLookup("Parent", &oParent2);
|
||||
oParent.free();
|
||||
oParent = oParent2;
|
||||
}
|
||||
oParent.free();
|
||||
}
|
||||
if (bNeed && EditAnnot(m_nEditPage, nID))
|
||||
{
|
||||
PdfWriter::CAnnotation* pAnnot = pDoc->GetAnnot(nID);
|
||||
if (pAnnot)
|
||||
{
|
||||
pAnnot->SetHidden();
|
||||
|
||||
// TODO у родителя убрать аннотацию из Kids и Opt. У всех детей переименовать AP.N.Yes
|
||||
|
||||
Object oPopupRef;
|
||||
if (oAnnot.dictLookupNF("Popup", &oPopupRef)->isRef())
|
||||
{
|
||||
pAnnot = pDoc->GetAnnot(oPopupRef.getRefNum());
|
||||
if (pAnnot)
|
||||
pAnnot->SetHidden();
|
||||
}
|
||||
oPopupRef.free();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
oFT.free();
|
||||
}
|
||||
oType.free();
|
||||
|
||||
if (!bNeed)
|
||||
{
|
||||
Object oPopupRef;
|
||||
if (oAnnot.dictLookupNF("Popup", &oPopupRef)->isRef())
|
||||
pDoc->DeleteAnnot(oPopupRef.getRefNum(), oPopupRef.getRefGen());
|
||||
oPopupRef.free();
|
||||
}
|
||||
}
|
||||
if (!bNeed)
|
||||
bRes = pDoc->DeleteAnnot(oAnnotRef.getRefNum(), oAnnotRef.getRefGen());
|
||||
}
|
||||
else if (oAnnots->arrayGet(i, &oAnnot)->isDict())
|
||||
{
|
||||
|
||||
@ -2386,6 +2386,15 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
|
||||
// ВНЕШНИЙ ВИД
|
||||
if (!pButtonWidget->Get("AP"))
|
||||
pButtonWidget->SetAP();
|
||||
|
||||
if (nFlags & (1 << 9))
|
||||
{
|
||||
std::wstring sValue = pPrB->GetV();
|
||||
if (sValue != L"Off")
|
||||
pButtonWidget->Yes();
|
||||
else
|
||||
pButtonWidget->Off();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (oInfo.IsTextWidget())
|
||||
@ -2663,15 +2672,15 @@ HRESULT CPdfWriter::EditWidgetParents(NSFonts::IApplicationFonts* pAppFonts, CWi
|
||||
}
|
||||
}
|
||||
}
|
||||
int nIndexName = 0;
|
||||
std::map<std::wstring, std::wstring> mNameAP_N_Yes;
|
||||
if (nFlags & (1 << 6))
|
||||
{
|
||||
PdfWriter::CArrayObject* pArray = new PdfWriter::CArrayObject();
|
||||
pParentObj->Add("Opt", pArray);
|
||||
|
||||
for (const std::pair<std::wstring, std::wstring>& PV : pParent->arrOpt)
|
||||
for (int i = 0; i < pParent->arrOpt.size(); ++i)
|
||||
{
|
||||
std::pair<std::wstring, std::wstring> PV = pParent->arrOpt[i];
|
||||
std::string sValue;
|
||||
if (PV.first.empty())
|
||||
{
|
||||
@ -2679,7 +2688,7 @@ HRESULT CPdfWriter::EditWidgetParents(NSFonts::IApplicationFonts* pAppFonts, CWi
|
||||
pArray->Add(new PdfWriter::CStringObject(sValue.c_str(), true));
|
||||
|
||||
if (mNameAP_N_Yes.find(PV.second) == mNameAP_N_Yes.end())
|
||||
mNameAP_N_Yes[PV.second] = std::to_wstring(nIndexName++);
|
||||
mNameAP_N_Yes[PV.second] = std::to_wstring(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2690,7 +2699,7 @@ HRESULT CPdfWriter::EditWidgetParents(NSFonts::IApplicationFonts* pAppFonts, CWi
|
||||
pArray2->Add(new PdfWriter::CStringObject(sValue.c_str(), true));
|
||||
|
||||
if (mNameAP_N_Yes.find(PV.first) == mNameAP_N_Yes.end())
|
||||
mNameAP_N_Yes[PV.first] = std::to_wstring(nIndexName++);
|
||||
mNameAP_N_Yes[PV.first] = std::to_wstring(i);
|
||||
|
||||
sValue = U_TO_UTF8(PV.second);
|
||||
pArray2->Add(new PdfWriter::CStringObject(sValue.c_str(), true));
|
||||
@ -2702,6 +2711,10 @@ HRESULT CPdfWriter::EditWidgetParents(NSFonts::IApplicationFonts* pAppFonts, CWi
|
||||
std::string sV = U_TO_UTF8(pParent->sV);
|
||||
if (sFT == "Btn")
|
||||
{
|
||||
int nFf = 0;
|
||||
if (nFlags & (1 << 7))
|
||||
nFf = pParent->nFieldFlag;
|
||||
bool bRadiosInUnison = nFf & (1 << 25);
|
||||
int nOptIndex = -1;
|
||||
if (isdigit(sV[0]))
|
||||
nOptIndex = std::stoi(sV);
|
||||
@ -2730,9 +2743,9 @@ HRESULT CPdfWriter::EditWidgetParents(NSFonts::IApplicationFonts* pAppFonts, CWi
|
||||
PV = pParent->arrOpt[i];
|
||||
std::wstring sOptI = PV.first.empty() ? PV.second : PV.first;
|
||||
if (pKid->NeedAP_N_Yes())
|
||||
pKid->SetAP_N_Yes(mNameAP_N_Yes[sOptI]);
|
||||
pKid->SetAP_N_Yes((bRadiosInUnison || nType == PdfWriter::WidgetCheckbox) ? mNameAP_N_Yes[sOptI] : std::to_wstring(i));
|
||||
|
||||
if (sOptI == sOpt)
|
||||
if (((bRadiosInUnison || nType == PdfWriter::WidgetCheckbox) && sOptI == sOpt) || (!bRadiosInUnison && i == nOptIndex))
|
||||
sV = pKid->Yes();
|
||||
else
|
||||
pKid->Off();
|
||||
|
||||
@ -1853,7 +1853,8 @@ namespace PdfWriter
|
||||
void CCheckBoxWidget::SetAP_N_Yes(const std::wstring& wsAP_N_Yes)
|
||||
{
|
||||
std::string sValue = U_TO_UTF8(wsAP_N_Yes);
|
||||
m_sAP_N_Yes = sValue;
|
||||
if (m_sAP_N_Yes.empty())
|
||||
m_sAP_N_Yes = sValue;
|
||||
|
||||
if (m_pAP)
|
||||
{
|
||||
|
||||
@ -1123,8 +1123,8 @@ namespace PdfWriter
|
||||
|
||||
for (int i = 0; i < pArray->GetCount(); i++)
|
||||
{
|
||||
CObjectBase* pObj = pArray->Get(i, false);
|
||||
if (pObj->GetType() == object_type_PROXY && ((CProxyObject*)pObj)->Get()->GetObjId() == nID)
|
||||
CObjectBase* pObj = pArray->Get(i);
|
||||
if (pObj->GetObjId() == nID)
|
||||
{
|
||||
CObjectBase* pDelete = pArray->Remove(i);
|
||||
RELEASEOBJECT(pDelete);
|
||||
|
||||
Reference in New Issue
Block a user