From ae7a9171a340c5f699c05d9e186b1d0197c3c0bb Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 23 Nov 2015 09:22:46 -0800 Subject: Merge to XFA: Add constant CPDFSDK_InterForm::kNumFieldTypes Bumping this one line from 6 to 7 in XFA saves a bunch of diffs. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1458363005 . (cherry picked from commit 7711b60efc62db14748711727560367d948745f1) BUG= Review URL: https://codereview.chromium.org/1470563002 . --- fpdfsdk/include/fsdk_baseform.h | 5 +++-- fpdfsdk/src/fsdk_baseform.cpp | 14 ++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'fpdfsdk') diff --git a/fpdfsdk/include/fsdk_baseform.h b/fpdfsdk/include/fsdk_baseform.h index 788ba5fade..e648558a3a 100644 --- a/fpdfsdk/include/fsdk_baseform.h +++ b/fpdfsdk/include/fsdk_baseform.h @@ -344,9 +344,10 @@ class CPDFSDK_InterForm : public CPDF_FormNotify { FX_COLORREF GetHighlightColor(int nFieldType); private: - FX_COLORREF m_aHighlightColor[7]; + static const int kNumFieldTypes = 7; + FX_COLORREF m_aHighlightColor[kNumFieldTypes]; uint8_t m_iHighlightAlpha; - FX_BOOL m_bNeedHightlight[7]; + FX_BOOL m_bNeedHightlight[kNumFieldTypes]; }; #define BAI_STRUCTURE 0 diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp index ea5ccd71b2..5a94649494 100644 --- a/fpdfsdk/src/fsdk_baseform.cpp +++ b/fpdfsdk/src/fsdk_baseform.cpp @@ -2145,7 +2145,7 @@ CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument) new CPDF_InterForm(m_pDocument->GetDocument()->GetPDFDoc(), FALSE); m_pInterForm->SetFormNotify(this); - for (int i = 0; i < 6; i++) + for (int i = 0; i < kNumFieldTypes; ++i) m_bNeedHightlight[i] = FALSE; m_iHighlightAlpha = 0; } @@ -2917,20 +2917,22 @@ int CPDFSDK_InterForm::AfterFormImportData(const CPDF_InterForm* pForm) { } FX_BOOL CPDFSDK_InterForm::IsNeedHighLight(int nFieldType) { - if (nFieldType < 1 || nFieldType > 7) + if (nFieldType < 1 || nFieldType > kNumFieldTypes) return FALSE; return m_bNeedHightlight[nFieldType - 1]; } void CPDFSDK_InterForm::RemoveAllHighLight() { - memset((void*)m_bNeedHightlight, 0, 7 * sizeof(FX_BOOL)); + for (int i = 0; i < kNumFieldTypes; ++i) + m_bNeedHightlight[i] = FALSE; } + void CPDFSDK_InterForm::SetHighlightColor(FX_COLORREF clr, int nFieldType) { - if (nFieldType < 0 || nFieldType > 7) + if (nFieldType < 0 || nFieldType > kNumFieldTypes) return; switch (nFieldType) { case 0: { - for (int i = 0; i < 7; i++) { + for (int i = 0; i < kNumFieldTypes; ++i) { m_aHighlightColor[i] = clr; m_bNeedHightlight[i] = TRUE; } @@ -2945,7 +2947,7 @@ void CPDFSDK_InterForm::SetHighlightColor(FX_COLORREF clr, int nFieldType) { } FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(int nFieldType) { - if (nFieldType < 0 || nFieldType > 7) + if (nFieldType < 0 || nFieldType > kNumFieldTypes) return FXSYS_RGB(255, 255, 255); if (nFieldType == 0) return m_aHighlightColor[0]; -- cgit v1.2.3