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/cpdfsdk_baannot.cpp | |
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/cpdfsdk_baannot.cpp')
-rw-r--r-- | fpdfsdk/cpdfsdk_baannot.cpp | 55 |
1 files changed, 26 insertions, 29 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) { |