summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-10-09 21:45:00 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-09 21:45:00 +0000
commitb7519ca7638007e6eaf79f095cdf1d4b25c4730b (patch)
tree21e454d6706f4e5733766a1098ba2c71b7158f63
parent69c3285d3a4d6bb60c8d3b88b289873371ca91f9 (diff)
downloadpdfium-b7519ca7638007e6eaf79f095cdf1d4b25c4730b.tar.xz
Clean up CPDF_FormControl.
Mark methods as const and remove dead code. Change-Id: Ib7baa9ac9783422439d8319cc8ddd1f78561b702 Reviewed-on: https://pdfium-review.googlesource.com/c/43613 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
-rw-r--r--core/fpdfdoc/cpdf_formcontrol.cpp51
-rw-r--r--core/fpdfdoc/cpdf_formcontrol.h32
2 files changed, 24 insertions, 59 deletions
diff --git a/core/fpdfdoc/cpdf_formcontrol.cpp b/core/fpdfdoc/cpdf_formcontrol.cpp
index fcf2175f9d..7b95c09464 100644
--- a/core/fpdfdoc/cpdf_formcontrol.cpp
+++ b/core/fpdfdoc/cpdf_formcontrol.cpp
@@ -8,16 +8,13 @@
#include <algorithm>
-#include "core/fpdfapi/page/cpdf_form.h"
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_document.h"
#include "core/fpdfapi/parser/cpdf_name.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/fpdf_parser_decode.h"
-#include "core/fpdfapi/render/cpdf_rendercontext.h"
#include "core/fpdfdoc/cpdf_interform.h"
-#include "core/fxge/cfx_renderdevice.h"
namespace {
@@ -58,7 +55,7 @@ ByteString CPDF_FormControl::GetOnStateName() const {
return ByteString();
}
-ByteString CPDF_FormControl::GetCheckedAPState() {
+ByteString CPDF_FormControl::GetCheckedAPState() const {
ASSERT(GetType() == CPDF_FormField::CheckBox ||
GetType() == CPDF_FormField::RadioButton);
ByteString csOn = GetOnStateName();
@@ -121,34 +118,8 @@ void CPDF_FormControl::CheckControl(bool bChecked) {
m_pWidgetDict->SetNewFor<CPDF_Name>("AS", csAS);
}
-void CPDF_FormControl::DrawControl(CFX_RenderDevice* pDevice,
- CFX_Matrix* pMatrix,
- CPDF_Page* pPage,
- CPDF_Annot::AppearanceMode mode,
- const CPDF_RenderOptions* pOptions) {
- if (m_pWidgetDict->GetIntegerFor("F") & ANNOTFLAG_HIDDEN)
- return;
-
- CPDF_Stream* pStream = GetAnnotAP(m_pWidgetDict.Get(), mode);
- if (!pStream)
- return;
-
- CFX_Matrix form_matrix = pStream->GetDict()->GetMatrixFor("Matrix");
- CFX_FloatRect form_bbox =
- form_matrix.TransformRect(pStream->GetDict()->GetRectFor("BBox"));
- CFX_FloatRect arect = m_pWidgetDict->GetRectFor("Rect");
- CFX_Matrix matrix;
- matrix.MatchRect(arect, form_bbox);
- matrix.Concat(*pMatrix);
- CPDF_Form form(m_pField->GetForm()->GetDocument(),
- m_pField->GetForm()->GetFormDict()->GetDictFor("DR"), pStream);
- form.ParseContent(nullptr, nullptr, nullptr, nullptr);
- CPDF_RenderContext context(pPage);
- context.AppendLayer(&form, &matrix);
- context.Render(pDevice, pOptions, nullptr);
-}
-
-CPDF_FormControl::HighlightingMode CPDF_FormControl::GetHighlightingMode() {
+CPDF_FormControl::HighlightingMode CPDF_FormControl::GetHighlightingMode()
+ const {
if (!m_pWidgetDict)
return Invert;
@@ -169,7 +140,7 @@ bool CPDF_FormControl::HasMKEntry(const ByteString& csEntry) const {
return GetMK().HasMKEntry(csEntry);
}
-int CPDF_FormControl::GetRotation() {
+int CPDF_FormControl::GetRotation() const {
return GetMK().GetRotation();
}
@@ -187,7 +158,7 @@ void CPDF_FormControl::GetOriginalColor(int& iColorType,
GetMK().GetOriginalColor(iColorType, fc, csEntry);
}
-WideString CPDF_FormControl::GetCaption(const ByteString& csEntry) {
+WideString CPDF_FormControl::GetCaption(const ByteString& csEntry) const {
return GetMK().GetCaption(csEntry);
}
@@ -195,15 +166,15 @@ CPDF_Stream* CPDF_FormControl::GetIcon(const ByteString& csEntry) {
return GetMK().GetIcon(csEntry);
}
-CPDF_IconFit CPDF_FormControl::GetIconFit() {
+CPDF_IconFit CPDF_FormControl::GetIconFit() const {
return GetMK().GetIconFit();
}
-int CPDF_FormControl::GetTextPosition() {
+int CPDF_FormControl::GetTextPosition() const {
return GetMK().GetTextPosition();
}
-CPDF_Action CPDF_FormControl::GetAction() {
+CPDF_Action CPDF_FormControl::GetAction() const {
if (!m_pWidgetDict)
return CPDF_Action(nullptr);
@@ -214,7 +185,7 @@ CPDF_Action CPDF_FormControl::GetAction() {
return CPDF_Action(pObj ? pObj->GetDict() : nullptr);
}
-CPDF_AAction CPDF_FormControl::GetAdditionalAction() {
+CPDF_AAction CPDF_FormControl::GetAdditionalAction() const {
if (!m_pWidgetDict)
return CPDF_AAction(nullptr);
@@ -223,7 +194,7 @@ CPDF_AAction CPDF_FormControl::GetAdditionalAction() {
return m_pField->GetAdditionalAction();
}
-CPDF_DefaultAppearance CPDF_FormControl::GetDefaultAppearance() {
+CPDF_DefaultAppearance CPDF_FormControl::GetDefaultAppearance() const {
if (!m_pWidgetDict)
return CPDF_DefaultAppearance();
@@ -276,7 +247,7 @@ CPDF_Font* CPDF_FormControl::GetDefaultControlFont() {
return nullptr;
}
-int CPDF_FormControl::GetControlAlignment() {
+int CPDF_FormControl::GetControlAlignment() const {
if (!m_pWidgetDict)
return 0;
if (m_pWidgetDict->KeyExist("Q"))
diff --git a/core/fpdfdoc/cpdf_formcontrol.h b/core/fpdfdoc/cpdf_formcontrol.h
index d29be14ed6..b89a08be18 100644
--- a/core/fpdfdoc/cpdf_formcontrol.h
+++ b/core/fpdfdoc/cpdf_formcontrol.h
@@ -50,21 +50,15 @@ class CPDF_FormControl {
CPDF_Dictionary* GetWidget() const { return m_pWidgetDict.Get(); }
CFX_FloatRect GetRect() const;
- void DrawControl(CFX_RenderDevice* pDevice,
- CFX_Matrix* pMatrix,
- CPDF_Page* pPage,
- CPDF_Annot::AppearanceMode mode,
- const CPDF_RenderOptions* pOptions);
-
- ByteString GetCheckedAPState();
+ ByteString GetCheckedAPState() const;
WideString GetExportValue() const;
bool IsChecked() const;
bool IsDefaultChecked() const;
- HighlightingMode GetHighlightingMode();
+ HighlightingMode GetHighlightingMode() const;
bool HasMKEntry(const ByteString& csEntry) const;
- int GetRotation();
+ int GetRotation() const;
FX_ARGB GetBorderColor(int& iColorType) { return GetColor(iColorType, "BC"); }
@@ -88,22 +82,22 @@ class CPDF_FormControl {
GetOriginalColor(iColorType, fc, "BG");
}
- WideString GetNormalCaption() { return GetCaption("CA"); }
- WideString GetRolloverCaption() { return GetCaption("RC"); }
- WideString GetDownCaption() { return GetCaption("AC"); }
+ WideString GetNormalCaption() const { return GetCaption("CA"); }
+ WideString GetRolloverCaption() const { return GetCaption("RC"); }
+ WideString GetDownCaption() const { return GetCaption("AC"); }
CPDF_Stream* GetNormalIcon() { return GetIcon("I"); }
CPDF_Stream* GetRolloverIcon() { return GetIcon("RI"); }
CPDF_Stream* GetDownIcon() { return GetIcon("IX"); }
- CPDF_IconFit GetIconFit();
+ CPDF_IconFit GetIconFit() const;
- int GetTextPosition();
- CPDF_Action GetAction();
- CPDF_AAction GetAdditionalAction();
- CPDF_DefaultAppearance GetDefaultAppearance();
+ int GetTextPosition() const;
+ CPDF_Action GetAction() const;
+ CPDF_AAction GetAdditionalAction() const;
+ CPDF_DefaultAppearance GetDefaultAppearance() const;
CPDF_Font* GetDefaultControlFont();
- int GetControlAlignment();
+ int GetControlAlignment() const;
ByteString GetOnStateName() const;
void CheckControl(bool bChecked);
@@ -115,7 +109,7 @@ class CPDF_FormControl {
float fc[4],
const ByteString& csEntry);
- WideString GetCaption(const ByteString& csEntry);
+ WideString GetCaption(const ByteString& csEntry) const;
CPDF_Stream* GetIcon(const ByteString& csEntry);
CPDF_ApSettings GetMK() const;