Rename Yes AP

This commit is contained in:
Svetlana Kulikova
2025-04-01 18:03:16 +03:00
parent 1aaec18152
commit 5692732901
3 changed files with 41 additions and 16 deletions

View File

@ -2670,7 +2670,7 @@ HRESULT CPdfWriter::EditWidgetParents(NSFonts::IApplicationFonts* pAppFonts, CWi
{
PdfWriter::CCheckBoxWidget* pKid = dynamic_cast<PdfWriter::CCheckBoxWidget*>(pObj);
if (pKid)
pKid->SwitchAP(sV);
pKid->SwitchAP(sV, i);
}
if (nType == PdfWriter::WidgetCombobox || nType == PdfWriter::WidgetListbox)
{

View File

@ -1829,6 +1829,7 @@ namespace PdfWriter
{
m_nSubtype = WidgetCheckbox;
m_nStyle = ECheckBoxStyle::Circle;
m_pAP = NULL;
}
void CCheckBoxWidget::SetV(const std::wstring& wsV)
{
@ -1856,34 +1857,41 @@ namespace PdfWriter
}
void CCheckBoxWidget::SetAP()
{
if (Get("AP"))
return;
CCheckBoxAnnotAppearance* pAP = new CCheckBoxAnnotAppearance(m_pXref, this, m_sAP_N_Yes.empty() ? NULL : m_sAP_N_Yes.c_str());
Add("AP", pAP);
if (!m_pAP)
{
m_pAP = new CCheckBoxAnnotAppearance(m_pXref, this, m_sAP_N_Yes.empty() ? NULL : m_sAP_N_Yes.c_str());
Add("AP", m_pAP);
}
if (m_nStyle == ECheckBoxStyle::Circle && m_nSubtype == WidgetRadiobutton)
{
pAP->GetYesN()->DrawCheckBoxCircle(true, true);
pAP->GetOffN()->DrawCheckBoxCircle(false, true);
pAP->GetYesD()->DrawCheckBoxCircle(true, false);
pAP->GetOffD()->DrawCheckBoxCircle(false, false);
m_pAP->GetYesN()->DrawCheckBoxCircle(true, true);
m_pAP->GetOffN()->DrawCheckBoxCircle(false, true);
m_pAP->GetYesD()->DrawCheckBoxCircle(true, false);
m_pAP->GetOffD()->DrawCheckBoxCircle(false, false);
}
else
{
pAP->GetYesN()->DrawCheckBoxSquare(true, true);
pAP->GetOffN()->DrawCheckBoxSquare(false, true);
pAP->GetYesD()->DrawCheckBoxSquare(true, false);
pAP->GetOffD()->DrawCheckBoxSquare(false, false);
m_pAP->GetYesN()->DrawCheckBoxSquare(true, true);
m_pAP->GetOffN()->DrawCheckBoxSquare(false, true);
m_pAP->GetYesD()->DrawCheckBoxSquare(true, false);
m_pAP->GetOffD()->DrawCheckBoxSquare(false, false);
}
}
void CCheckBoxWidget::SwitchAP(const std::string& sV)
void CCheckBoxWidget::SwitchAP(const std::string& sV, int nI)
{
CObjectBase* pAP, *pAPN;
Add("AS", "Off");
CObjectBase* pObj = GetObjValue("Opt");
if (!m_sAP_N_Yes.empty() && pObj && pObj->GetType() == object_type_ARRAY)
{
if (m_pAP)
{
CDictObject* pDict = (CDictObject*)m_pAP->Get("N");
pDict->Remove(m_sAP_N_Yes);
pDict = (CDictObject*)m_pAP->Get("D");
pDict->Remove(m_sAP_N_Yes);
}
CArrayObject* pArr = (CArrayObject*)pObj;
for (int i = 0; i < pArr->GetCount(); ++i)
{
@ -1903,9 +1911,25 @@ namespace PdfWriter
}
}
Add("AS", m_sAP_N_Yes.c_str());
if (nI >= 0 && m_pAP)
{
CDictObject* pDict = (CDictObject*)m_pAP->Get("N");
pDict->Add(m_sAP_N_Yes, m_pAP->GetYesN());
pDict = (CDictObject*)m_pAP->Get("D");
pDict->Add(m_sAP_N_Yes, m_pAP->GetYesD());
}
}
else if ((pAP = Get("AP")) && pAP->GetType() == object_type_DICT && (pAPN = ((CDictObject*)pAP)->Get("N")) && pAPN->GetType() == object_type_DICT && ((CDictObject*)pAPN)->Get(sV))
Add("AS", sV.c_str());
else if (nI >= 0 && m_pAP)
{
CDictObject* pDict = (CDictObject*)m_pAP->Get("N");
pDict->Add(std::to_string(nI), m_pAP->GetYesN());
pDict->Remove("Yes");
pDict = (CDictObject*)m_pAP->Get("D");
pDict->Add(std::to_string(nI), m_pAP->GetYesD());
pDict->Remove("Yes");
}
}
void CCheckBoxWidget::SetFlag(const int& nFlag)
{

View File

@ -530,6 +530,7 @@ namespace PdfWriter
private:
std::string m_sAP_N_Yes;
ECheckBoxStyle m_nStyle;
CCheckBoxAnnotAppearance* m_pAP;
public:
CCheckBoxWidget(CXref* pXref);
@ -540,7 +541,7 @@ namespace PdfWriter
void SetAP_N_Yes(const std::wstring& wsAP_N_Yes);
virtual void SetFlag (const int& nFlag);
void SetAP();
void SwitchAP(const std::string& sV);
void SwitchAP(const std::string& sV, int nI = -1);
};
class CTextWidget : public CWidgetAnnotation
{