diff options
author | Lei Zhang <thestig@chromium.org> | 2018-10-09 19:14:15 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-10-09 19:14:15 +0000 |
commit | c1bf9988bbe2f74d227ce071171455ae99c47dbb (patch) | |
tree | 19d6d95201a1fb04d9f2337ea13acd059b013471 /fpdfsdk | |
parent | 09ee087b894679ff7bc6bc17c7e8a8410e00f8b5 (diff) | |
download | pdfium-c1bf9988bbe2f74d227ce071171455ae99c47dbb.tar.xz |
Use CPDFSDK_BAAnnot::GetAnnotDict() in more places.
Also initialize CPDFSDK_Widget members in the header.
Change-Id: I55cfad3b0393b7d8e897c6ea1b91952b9c5a68d1
Reviewed-on: https://pdfium-review.googlesource.com/c/43598
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/cpdfsdk_baannot.cpp | 55 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_widget.cpp | 18 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_widget.h | 6 |
3 files changed, 33 insertions, 46 deletions
diff --git a/fpdfsdk/cpdfsdk_baannot.cpp b/fpdfsdk/cpdfsdk_baannot.cpp index 4b164982f7..e49a200480 100644 --- a/fpdfsdk/cpdfsdk_baannot.cpp +++ b/fpdfsdk/cpdfsdk_baannot.cpp @@ -42,9 +42,9 @@ CPDF_Dictionary* CPDFSDK_BAAnnot::GetAnnotDict() const { } CPDF_Dictionary* CPDFSDK_BAAnnot::GetAPDict() const { - CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictFor("AP"); + CPDF_Dictionary* pAPDict = GetAnnotDict()->GetDictFor("AP"); if (!pAPDict) - pAPDict = m_pAnnot->GetAnnotDict()->SetNewFor<CPDF_Dictionary>("AP"); + pAPDict = GetAnnotDict()->SetNewFor<CPDF_Dictionary>("AP"); return pAPDict; } @@ -52,7 +52,7 @@ void CPDFSDK_BAAnnot::SetRect(const CFX_FloatRect& rect) { ASSERT(rect.right - rect.left >= GetMinWidth()); ASSERT(rect.top - rect.bottom >= GetMinHeight()); - m_pAnnot->GetAnnotDict()->SetRectFor("Rect", rect); + GetAnnotDict()->SetRectFor("Rect", rect); } CFX_FloatRect CPDFSDK_BAAnnot::GetRect() const { @@ -72,11 +72,11 @@ void CPDFSDK_BAAnnot::DrawAppearance(CFX_RenderDevice* pDevice, } bool CPDFSDK_BAAnnot::IsAppearanceValid() { - return !!m_pAnnot->GetAnnotDict()->GetDictFor("AP"); + return !!GetAnnotDict()->GetDictFor("AP"); } bool CPDFSDK_BAAnnot::IsAppearanceValid(CPDF_Annot::AppearanceMode mode) { - CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDictFor("AP"); + CPDF_Dictionary* pAP = GetAnnotDict()->GetDictFor("AP"); if (!pAP) return false; @@ -95,65 +95,62 @@ bool CPDFSDK_BAAnnot::IsAppearanceValid(CPDF_Annot::AppearanceMode mode) { } void CPDFSDK_BAAnnot::SetAnnotName(const WideString& sName) { - if (sName.IsEmpty()) { - m_pAnnot->GetAnnotDict()->RemoveFor("NM"); - } else { - m_pAnnot->GetAnnotDict()->SetNewFor<CPDF_String>( - "NM", PDF_EncodeText(sName), false); - } + if (sName.IsEmpty()) + GetAnnotDict()->RemoveFor("NM"); + else + GetAnnotDict()->SetNewFor<CPDF_String>("NM", PDF_EncodeText(sName), false); } WideString CPDFSDK_BAAnnot::GetAnnotName() const { - return m_pAnnot->GetAnnotDict()->GetUnicodeTextFor("NM"); + return GetAnnotDict()->GetUnicodeTextFor("NM"); } void CPDFSDK_BAAnnot::SetFlags(uint32_t nFlags) { - m_pAnnot->GetAnnotDict()->SetNewFor<CPDF_Number>("F", - static_cast<int>(nFlags)); + GetAnnotDict()->SetNewFor<CPDF_Number>("F", static_cast<int>(nFlags)); } uint32_t CPDFSDK_BAAnnot::GetFlags() const { - return m_pAnnot->GetAnnotDict()->GetIntegerFor("F"); + return GetAnnotDict()->GetIntegerFor("F"); } void CPDFSDK_BAAnnot::SetAppState(const ByteString& str) { if (str.IsEmpty()) - m_pAnnot->GetAnnotDict()->RemoveFor("AS"); + GetAnnotDict()->RemoveFor("AS"); else - m_pAnnot->GetAnnotDict()->SetNewFor<CPDF_String>("AS", str, false); + GetAnnotDict()->SetNewFor<CPDF_String>("AS", str, false); } ByteString CPDFSDK_BAAnnot::GetAppState() const { - return m_pAnnot->GetAnnotDict()->GetStringFor("AS"); + return GetAnnotDict()->GetStringFor("AS"); } void CPDFSDK_BAAnnot::SetBorderWidth(int nWidth) { - CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayFor("Border"); + CPDF_Array* pBorder = GetAnnotDict()->GetArrayFor("Border"); if (pBorder) { pBorder->SetNewAt<CPDF_Number>(2, nWidth); } else { - CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictFor("BS"); + CPDF_Dictionary* pBSDict = GetAnnotDict()->GetDictFor("BS"); if (!pBSDict) - pBSDict = m_pAnnot->GetAnnotDict()->SetNewFor<CPDF_Dictionary>("BS"); + pBSDict = GetAnnotDict()->SetNewFor<CPDF_Dictionary>("BS"); pBSDict->SetNewFor<CPDF_Number>("W", nWidth); } } int CPDFSDK_BAAnnot::GetBorderWidth() const { - if (CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayFor("Border")) + if (CPDF_Array* pBorder = GetAnnotDict()->GetArrayFor("Border")) return pBorder->GetIntegerAt(2); - if (CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictFor("BS")) + if (CPDF_Dictionary* pBSDict = GetAnnotDict()->GetDictFor("BS")) return pBSDict->GetIntegerFor("W", 1); return 1; } void CPDFSDK_BAAnnot::SetBorderStyle(BorderStyle nStyle) { - CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictFor("BS"); + CPDF_Dictionary* pBSDict = GetAnnotDict()->GetDictFor("BS"); if (!pBSDict) - pBSDict = m_pAnnot->GetAnnotDict()->SetNewFor<CPDF_Dictionary>("BS"); + pBSDict = GetAnnotDict()->SetNewFor<CPDF_Dictionary>("BS"); switch (nStyle) { case BorderStyle::SOLID: @@ -177,7 +174,7 @@ void CPDFSDK_BAAnnot::SetBorderStyle(BorderStyle nStyle) { } BorderStyle CPDFSDK_BAAnnot::GetBorderStyle() const { - CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictFor("BS"); + CPDF_Dictionary* pBSDict = GetAnnotDict()->GetDictFor("BS"); if (pBSDict) { ByteString sBorderStyle = pBSDict->GetStringFor("S", "S"); if (sBorderStyle == "S") @@ -192,7 +189,7 @@ BorderStyle CPDFSDK_BAAnnot::GetBorderStyle() const { return BorderStyle::UNDERLINE; } - CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayFor("Border"); + CPDF_Array* pBorder = GetAnnotDict()->GetArrayFor("Border"); if (pBorder) { if (pBorder->GetCount() >= 4) { CPDF_Array* pDP = pBorder->GetArrayAt(3); @@ -211,11 +208,11 @@ bool CPDFSDK_BAAnnot::IsVisible() const { } CPDF_Action CPDFSDK_BAAnnot::GetAction() const { - return CPDF_Action(m_pAnnot->GetAnnotDict()->GetDictFor("A")); + return CPDF_Action(GetAnnotDict()->GetDictFor("A")); } CPDF_AAction CPDFSDK_BAAnnot::GetAAction() const { - return CPDF_AAction(m_pAnnot->GetAnnotDict()->GetDictFor("AA")); + return CPDF_AAction(GetAnnotDict()->GetDictFor("AA")); } CPDF_Action CPDFSDK_BAAnnot::GetAAction(CPDF_AAction::AActionType eAAT) { diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp index 82776e3298..70ad592f6f 100644 --- a/fpdfsdk/cpdfsdk_widget.cpp +++ b/fpdfsdk/cpdfsdk_widget.cpp @@ -44,19 +44,9 @@ CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView, CPDFSDK_InterForm* pInterForm) - : CPDFSDK_BAAnnot(pAnnot, pPageView), - m_pInterForm(pInterForm), - m_nAppearanceAge(0), - m_nValueAge(0) -#ifdef PDF_ENABLE_XFA - , - m_hMixXFAWidget(nullptr), - m_pWidgetHandler(nullptr) -#endif // PDF_ENABLE_XFA -{ -} + : CPDFSDK_BAAnnot(pAnnot, pPageView), m_pInterForm(pInterForm) {} -CPDFSDK_Widget::~CPDFSDK_Widget() {} +CPDFSDK_Widget::~CPDFSDK_Widget() = default; #ifdef PDF_ENABLE_XFA CXFA_FFWidget* CPDFSDK_Widget::GetMixXFAWidget() const { @@ -312,7 +302,7 @@ void CPDFSDK_Widget::Synchronize(bool bSynchronizeElse) { #endif // PDF_ENABLE_XFA bool CPDFSDK_Widget::IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode) { - CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDictFor("AP"); + CPDF_Dictionary* pAP = GetAnnotDict()->GetDictFor("AP"); if (!pAP) return false; @@ -371,7 +361,7 @@ int CPDFSDK_Widget::GetLayoutOrder() const { int CPDFSDK_Widget::GetFieldFlags() const { CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm(); CPDF_FormControl* pFormControl = - pPDFInterForm->GetControlByDict(m_pAnnot->GetAnnotDict()); + pPDFInterForm->GetControlByDict(GetAnnotDict()); CPDF_FormField* pFormField = pFormControl->GetField(); return pFormField->GetFieldFlags(); } diff --git a/fpdfsdk/cpdfsdk_widget.h b/fpdfsdk/cpdfsdk_widget.h index e7d5f6d3cd..6ccfdfd31f 100644 --- a/fpdfsdk/cpdfsdk_widget.h +++ b/fpdfsdk/cpdfsdk_widget.h @@ -132,9 +132,9 @@ class CPDFSDK_Widget final : public CPDFSDK_BAAnnot { #endif // PDF_ENABLE_XFA UnownedPtr<CPDFSDK_InterForm> const m_pInterForm; - bool m_bAppModified; - uint32_t m_nAppearanceAge; - uint32_t m_nValueAge; + bool m_bAppModified = false; + uint32_t m_nAppearanceAge = 0; + uint32_t m_nValueAge = 0; #ifdef PDF_ENABLE_XFA mutable UnownedPtr<CXFA_FFWidget> m_hMixXFAWidget; |