7#include "core/fpdfdoc/cpdf_formcontrol.h"
13#include "constants/form_fields.h"
14#include "core/fpdfapi/font/cpdf_font.h"
15#include "core/fpdfapi/page/cpdf_docpagedata.h"
16#include "core/fpdfapi/parser/cpdf_array.h"
17#include "core/fpdfapi/parser/cpdf_dictionary.h"
18#include "core/fpdfapi/parser/cpdf_name.h"
19#include "core/fpdfapi/parser/cpdf_stream.h"
20#include "core/fpdfapi/parser/fpdf_parser_decode.h"
21#include "core/fpdfapi/parser/fpdf_parser_utility.h"
22#include "core/fpdfdoc/cpdf_interactiveform.h"
23#include "core/fxcrt/check.h"
27constexpr std::array<
char, 5> kHighlightModes = {{
'N',
'I',
'O',
'P',
'T'}};
31 "HighlightingMode mismatch");
33 "HighlightingMode mismatch");
35 "HighlightingMode mismatch");
37 "HighlightingMode mismatch");
39 "HighlightingMode mismatch");
53 return m_pWidgetDict->GetRectFor(
"Rect");
57 DCHECK(GetType() == CPDF_FormField::kCheckBox ||
58 GetType() == CPDF_FormField::kRadioButton);
68 for (
const auto& it : locker) {
69 if (it.first !=
"Off")
76 DCHECK(GetType() == CPDF_FormField::kCheckBox ||
77 GetType() == CPDF_FormField::kRadioButton);
79 if (ToArray(m_pField->GetFieldAttr(
"Opt")))
80 csOn = ByteString::FormatInteger(m_pField->GetControlIndex(
this));
87 DCHECK(GetType() == CPDF_FormField::kCheckBox ||
88 GetType() == CPDF_FormField::kRadioButton);
92 csOn = pArray->GetByteStringAt(m_pField->GetControlIndex(
this));
95 return PDF_DecodeText(csOn.unsigned_span());
99 DCHECK(GetType() == CPDF_FormField::kCheckBox ||
100 GetType() == CPDF_FormField::kRadioButton);
102 ByteString csAS = m_pWidgetDict->GetByteStringFor(
"AS");
107 DCHECK(GetType() == CPDF_FormField::kCheckBox ||
108 GetType() == CPDF_FormField::kRadioButton);
115 return (csDV
== csOn);
119 DCHECK(GetType() == CPDF_FormField::kCheckBox ||
120 GetType() == CPDF_FormField::kRadioButton);
121 ByteString csOldAS = m_pWidgetDict->GetByteStringFor(
"AS",
"Off");
127 m_pWidgetDict->SetNewFor<CPDF_Name>(
"AS", csAS);
132 ByteString csH = m_pWidgetDict->GetByteStringFor(
"H",
"I");
133 for (size_t i = 0; i <
std::size(kHighlightModes); ++i) {
143 return CPDF_ApSettings(m_pWidgetDict->GetMutableDictFor(
"MK"));
185 if (m_pWidgetDict->KeyExist(pdfium::form_fields::kDA)) {
186 return CPDF_DefaultAppearance(
187 m_pWidgetDict->GetByteStringFor(pdfium::form_fields::kDA));
190 m_pField->GetFieldAttr(pdfium::form_fields::kDA);
194 return m_pForm->GetDefaultAppearance();
208 std::optional<
ByteString> csFontNameTag = cDA.GetFont(&fFontSize);
209 if (!csFontNameTag.has_value() || csFontNameTag->IsEmpty())
213 CPDF_FormField::GetMutableFieldAttrForDict(m_pWidgetDict.Get(),
"DR"));
216 if (ValidateFontResourceDict(pFonts.Get())) {
218 pFonts->GetMutableDictFor(csFontNameTag.value());
221 m_pForm->GetFontForElement(std::move(pElement));
233 CPDF_FormField::GetMutableFieldAttrForDict(pPageDict.Get(),
"Resources"));
238 if (!ValidateFontResourceDict(pFonts.Get()))
242 pFonts->GetMutableDictFor(csFontNameTag.value());
246 return m_pForm->GetFontForElement(std::move(pElement));
250 if (m_pWidgetDict->KeyExist(pdfium::form_fields::kQ))
251 return m_pWidgetDict->GetIntegerFor(pdfium::form_fields::kQ, 0);
254 m_pField->GetFieldAttr(pdfium::form_fields::kQ);
256 return pObj->GetInteger();
258 return m_pForm->GetFormAlignment();
fxcrt::ByteString ByteString
CFX_Color GetOriginalColor(const ByteString &csEntry) const
bool HasMKEntry(const ByteString &csEntry) const
RetainPtr< CPDF_Stream > GetIcon(const ByteString &csEntry) const
CPDF_IconFit GetIconFit() const
WideString GetCaption(const ByteString &csEntry) const
float GetOriginalColorComponent(int index, const ByteString &csEntry) const
CFX_Color::TypeAndARGB GetColorARGB(const ByteString &csEntry) const
int GetTextPosition() const
std::vector< RetainPtr< CPDF_Object > >::const_iterator const_iterator
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
bool operator==(const ByteString &other) const
ByteString & operator=(const char *str)
ByteString & operator=(ByteString &&that) noexcept
static WideString FromDefANSI(ByteStringView str)
fxcrt::ByteStringView ByteStringView
fxcrt::WideString WideString