From 92cb5e580cecf0412b74d51e8863ed557e2bd47a Mon Sep 17 00:00:00 2001 From: dsinclair Date: Mon, 16 May 2016 11:38:28 -0700 Subject: Convert border style defines to an enum class. There were two defines, BBS_ and PBS_ for the various border styles in the system. They were the same, except PBS_ had an extra SHADOW define which was never used. This CL combines both of those into a single BorderStyle enum class and updates the code as needed. Also, removes ADDBIT, GETBIT unused defines. Updates barcode code to use the util.h defines instead of redefinition. fsdk_baseannot names starting with _ were cleaned up and some #defines moved to constants. Review-Url: https://codereview.chromium.org/1980973002 --- core/fpdfdoc/cpvt_generateap.cpp | 27 +++---- core/fpdfdoc/cpvt_generateap.h | 11 +-- core/fpdfdoc/include/fpdf_doc.h | 2 + core/fxcodec/codec/fx_codec_fax.cpp | 5 -- fpdfsdk/formfiller/cffl_formfiller.cpp | 23 ++---- fpdfsdk/fsdk_baseannot.cpp | 72 ++++++++++-------- fpdfsdk/fsdk_baseform.cpp | 124 ++++++++++++++----------------- fpdfsdk/include/fsdk_baseannot.h | 17 +---- fpdfsdk/include/fsdk_common.h | 6 -- fpdfsdk/javascript/Field.cpp | 27 +++---- fpdfsdk/pdfwindow/PWL_ComboBox.cpp | 6 +- fpdfsdk/pdfwindow/PWL_Edit.cpp | 30 +++++--- fpdfsdk/pdfwindow/PWL_EditCtrl.cpp | 2 +- fpdfsdk/pdfwindow/PWL_ScrollBar.cpp | 2 +- fpdfsdk/pdfwindow/PWL_Utils.cpp | 68 ++++++++--------- fpdfsdk/pdfwindow/PWL_Utils.h | 6 +- fpdfsdk/pdfwindow/PWL_Wnd.cpp | 52 ++++--------- fpdfsdk/pdfwindow/PWL_Wnd.h | 20 ++--- xfa/fwl/basewidget/fxmath_barcodeimp.cpp | 18 ++--- 19 files changed, 223 insertions(+), 295 deletions(-) diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp index adaee6363e..aa49f79c12 100644 --- a/core/fpdfdoc/cpvt_generateap.cpp +++ b/core/fpdfdoc/cpvt_generateap.cpp @@ -107,7 +107,8 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, rcAnnot.right - rcAnnot.left); break; } - int32_t nBorderStyle = PBS_SOLID; + + BorderStyle nBorderStyle = BorderStyle::SOLID; FX_FLOAT fBorderWidth = 1; CPVT_Dash dsBorder(3, 0, 0); CPVT_Color crLeftTop, crRightBottom; @@ -121,25 +122,25 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, } switch (pBSDict->GetStringBy("S").GetAt(0)) { case 'S': - nBorderStyle = PBS_SOLID; + nBorderStyle = BorderStyle::SOLID; break; case 'D': - nBorderStyle = PBS_DASH; + nBorderStyle = BorderStyle::DASH; break; case 'B': - nBorderStyle = PBS_BEVELED; + nBorderStyle = BorderStyle::BEVELED; fBorderWidth *= 2; crLeftTop = CPVT_Color(CPVT_Color::kGray, 1); crRightBottom = CPVT_Color(CPVT_Color::kGray, 0.5); break; case 'I': - nBorderStyle = PBS_INSET; + nBorderStyle = BorderStyle::INSET; fBorderWidth *= 2; crLeftTop = CPVT_Color(CPVT_Color::kGray, 0.5); crRightBottom = CPVT_Color(CPVT_Color::kGray, 0.75); break; case 'U': - nBorderStyle = PBS_UNDERLINED; + nBorderStyle = BorderStyle::UNDERLINE; break; } } @@ -318,7 +319,7 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, CFX_ByteString sButtonBorder = CPVT_GenerateAP::GenerateBorderAP( rcButton, 2, CPVT_Color(CPVT_Color::kGray, 0), CPVT_Color(CPVT_Color::kGray, 1), - CPVT_Color(CPVT_Color::kGray, 0.5), PBS_BEVELED, + CPVT_Color(CPVT_Color::kGray, 0.5), BorderStyle::BEVELED, CPVT_Dash(3, 0, 0)); if (sButtonBorder.GetLength() > 0) sAppStream << "q\n" << sButtonBorder << "Q\n"; @@ -589,7 +590,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateBorderAP( const CPVT_Color& color, const CPVT_Color& crLeftTop, const CPVT_Color& crRightBottom, - int32_t nStyle, + BorderStyle nStyle, const CPVT_Dash& dash) { CFX_ByteTextBuf sAppStream; CFX_ByteString sColor; @@ -601,7 +602,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateBorderAP( FX_FLOAT fHalfWidth = fWidth / 2.0f; switch (nStyle) { default: - case PBS_SOLID: + case BorderStyle::SOLID: sColor = GenerateColorAP(color, TRUE); if (sColor.GetLength() > 0) { sAppStream << sColor; @@ -613,7 +614,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateBorderAP( sAppStream << "f*\n"; } break; - case PBS_DASH: + case BorderStyle::DASH: sColor = GenerateColorAP(color, FALSE); if (sColor.GetLength() > 0) { sAppStream << sColor; @@ -632,8 +633,8 @@ CFX_ByteString CPVT_GenerateAP::GenerateBorderAP( << " l S\n"; } break; - case PBS_BEVELED: - case PBS_INSET: + case BorderStyle::BEVELED: + case BorderStyle::INSET: sColor = GenerateColorAP(crLeftTop, TRUE); if (sColor.GetLength() > 0) { sAppStream << sColor; @@ -676,7 +677,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateBorderAP( << fTop - fBottom - fHalfWidth * 2 << " re f*\n"; } break; - case PBS_UNDERLINED: + case BorderStyle::UNDERLINE: sColor = GenerateColorAP(color, FALSE); if (sColor.GetLength() > 0) { sAppStream << sColor; diff --git a/core/fpdfdoc/cpvt_generateap.h b/core/fpdfdoc/cpvt_generateap.h index 924de40ed4..1258643d3e 100644 --- a/core/fpdfdoc/cpvt_generateap.h +++ b/core/fpdfdoc/cpvt_generateap.h @@ -10,18 +10,11 @@ #include "core/fpdfdoc/cpvt_color.h" #include "core/fpdfdoc/cpvt_dash.h" #include "core/fpdfdoc/include/cpdf_variabletext.h" +#include "core/fpdfdoc/include/fpdf_doc.h" #include "core/fxcrt/include/fx_coordinates.h" #include "core/fxcrt/include/fx_string.h" #include "core/fxcrt/include/fx_system.h" -// border style -#define PBS_SOLID 0 -#define PBS_DASH 1 -#define PBS_BEVELED 2 -#define PBS_INSET 3 -#define PBS_UNDERLINED 4 -#define PBS_SHADOW 5 - class CPDF_Dictionary; class CPDF_Document; class IPVT_FontMap; @@ -48,7 +41,7 @@ class CPVT_GenerateAP { const CPVT_Color& color, const CPVT_Color& crLeftTop, const CPVT_Color& crRightBottom, - int32_t nStyle, + BorderStyle nStyle, const CPVT_Dash& dash); static CFX_ByteString GenerateColorAP(const CPVT_Color& color, const FX_BOOL& bFillOrStroke); diff --git a/core/fpdfdoc/include/fpdf_doc.h b/core/fpdfdoc/include/fpdf_doc.h index d69887bd78..8758ab9a42 100644 --- a/core/fpdfdoc/include/fpdf_doc.h +++ b/core/fpdfdoc/include/fpdf_doc.h @@ -48,6 +48,8 @@ class CPDF_ViewerPreferences; class CXML_Element; class CFX_RenderDevice; +enum class BorderStyle { SOLID, DASH, BEVELED, INSET, UNDERLINE }; + class CPDF_NameTree { public: explicit CPDF_NameTree(CPDF_Dictionary* pRoot) : m_pRoot(pRoot) {} diff --git a/core/fxcodec/codec/fx_codec_fax.cpp b/core/fxcodec/codec/fx_codec_fax.cpp index 91f9eb2eb8..97b7ee2ad6 100644 --- a/core/fxcodec/codec/fx_codec_fax.cpp +++ b/core/fxcodec/codec/fx_codec_fax.cpp @@ -132,11 +132,6 @@ void FaxFillBits(uint8_t* dest_buf, int columns, int startpos, int endpos) { #define NEXTBIT \ src_buf[bitpos / 8] & (1 << (7 - bitpos % 8)); \ bitpos++; -#define ADDBIT(code, bit) \ - code = code << 1; \ - if (bit) \ - code++; -#define GETBIT(bitpos) src_buf[bitpos / 8] & (1 << (7 - bitpos % 8)) const uint8_t FaxBlackRunIns[] = { 0, 2, 0x02, 3, 0, 0x03, diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp index b6f719db99..8ee6da387d 100644 --- a/fpdfsdk/formfiller/cffl_formfiller.cpp +++ b/fpdfsdk/formfiller/cffl_formfiller.cpp @@ -323,32 +323,23 @@ PWL_CREATEPARAM CFFL_FormFiller::GetCreateParam() { cp.fFontSize = m_pWidget->GetFontSize(); cp.dwBorderWidth = m_pWidget->GetBorderWidth(); - int nBorderStyle = m_pWidget->GetBorderStyle(); - - switch (nBorderStyle) { - case BBS_SOLID: - cp.nBorderStyle = PBS_SOLID; - break; - case BBS_DASH: - cp.nBorderStyle = PBS_DASH; + cp.nBorderStyle = m_pWidget->GetBorderStyle(); + switch (cp.nBorderStyle) { + case BorderStyle::DASH: cp.sDash = CPWL_Dash(3, 3, 0); break; - case BBS_BEVELED: - cp.nBorderStyle = PBS_BEVELED; + case BorderStyle::BEVELED: cp.dwBorderWidth *= 2; break; - case BBS_INSET: - cp.nBorderStyle = PBS_INSET; + case BorderStyle::INSET: cp.dwBorderWidth *= 2; break; - case BBS_UNDERLINE: - cp.nBorderStyle = PBS_UNDERLINED; + default: break; } - if (cp.fFontSize <= 0) { + if (cp.fFontSize <= 0) dwCreateFlags |= PWS_AUTOFONTSIZE; - } cp.dwFlags = dwCreateFlags; cp.pSystemHandler = m_pApp->GetSysHandler(); diff --git a/fpdfsdk/fsdk_baseannot.cpp b/fpdfsdk/fsdk_baseannot.cpp index 24aa846142..e2ee6f7c73 100644 --- a/fpdfsdk/fsdk_baseannot.cpp +++ b/fpdfsdk/fsdk_baseannot.cpp @@ -19,19 +19,24 @@ #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" #endif // PDF_ENABLE_XFA +namespace { + +const float kMinWidth = 1.0f; +const float kMinHeight = 1.0f; + int gAfxGetTimeZoneInSeconds(int8_t tzhour, uint8_t tzminute) { return (int)tzhour * 3600 + (int)tzminute * (tzhour >= 0 ? 60 : -60); } -FX_BOOL _gAfxIsLeapYear(int16_t year) { +bool gAfxIsLeapYear(int16_t year) { return ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))); } -uint16_t _gAfxGetYearDays(int16_t year) { - return (_gAfxIsLeapYear(year) == TRUE ? 366 : 365); +uint16_t gAfxGetYearDays(int16_t year) { + return (gAfxIsLeapYear(year) ? 366 : 365); } -uint8_t _gAfxGetMonthDays(int16_t year, uint8_t month) { +uint8_t gAfxGetMonthDays(int16_t year, uint8_t month) { uint8_t mDays; switch (month) { case 1: @@ -52,7 +57,7 @@ uint8_t _gAfxGetMonthDays(int16_t year, uint8_t month) { break; case 2: - if (_gAfxIsLeapYear(year) == TRUE) + if (gAfxIsLeapYear(year)) mDays = 29; else mDays = 28; @@ -66,6 +71,8 @@ uint8_t _gAfxGetMonthDays(int16_t year, uint8_t month) { return mDays; } +} // namespace + CPDFSDK_DateTime::CPDFSDK_DateTime() { ResetDateTime(); } @@ -406,24 +413,24 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::AddDays(short days) { yy = y; if (((uint16_t)m * 100 + d) > 300) yy++; - ydays = _gAfxGetYearDays(yy); + ydays = gAfxGetYearDays(yy); while (ldays >= ydays) { y++; ldays -= ydays; yy++; - mdays = _gAfxGetMonthDays(y, m); + mdays = gAfxGetMonthDays(y, m); if (d > mdays) { m++; d -= mdays; } - ydays = _gAfxGetYearDays(yy); + ydays = gAfxGetYearDays(yy); } - mdays = _gAfxGetMonthDays(y, m) - d + 1; + mdays = gAfxGetMonthDays(y, m) - d + 1; while (ldays >= mdays) { ldays -= mdays; m++; d = 1; - mdays = _gAfxGetMonthDays(y, m); + mdays = gAfxGetMonthDays(y, m); } d += ldays; } else { @@ -431,22 +438,22 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::AddDays(short days) { yy = y; if (((uint16_t)m * 100 + d) < 300) yy--; - ydays = _gAfxGetYearDays(yy); + ydays = gAfxGetYearDays(yy); while (ldays >= ydays) { y--; ldays -= ydays; yy--; - mdays = _gAfxGetMonthDays(y, m); + mdays = gAfxGetMonthDays(y, m); if (d > mdays) { m++; d -= mdays; } - ydays = _gAfxGetYearDays(yy); + ydays = gAfxGetYearDays(yy); } while (ldays >= d) { ldays -= d; m--; - mdays = _gAfxGetMonthDays(y, m); + mdays = gAfxGetMonthDays(y, m); d = mdays; } d -= ldays; @@ -677,7 +684,7 @@ int CPDFSDK_BAAnnot::GetBorderWidth() const { return 1; } -void CPDFSDK_BAAnnot::SetBorderStyle(int nStyle) { +void CPDFSDK_BAAnnot::SetBorderStyle(BorderStyle nStyle) { CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictBy("BS"); if (!pBSDict) { pBSDict = new CPDF_Dictionary; @@ -685,38 +692,40 @@ void CPDFSDK_BAAnnot::SetBorderStyle(int nStyle) { } switch (nStyle) { - case BBS_SOLID: + case BorderStyle::SOLID: pBSDict->SetAtName("S", "S"); break; - case BBS_DASH: + case BorderStyle::DASH: pBSDict->SetAtName("S", "D"); break; - case BBS_BEVELED: + case BorderStyle::BEVELED: pBSDict->SetAtName("S", "B"); break; - case BBS_INSET: + case BorderStyle::INSET: pBSDict->SetAtName("S", "I"); break; - case BBS_UNDERLINE: + case BorderStyle::UNDERLINE: pBSDict->SetAtName("S", "U"); break; + default: + break; } } -int CPDFSDK_BAAnnot::GetBorderStyle() const { +BorderStyle CPDFSDK_BAAnnot::GetBorderStyle() const { CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictBy("BS"); if (pBSDict) { CFX_ByteString sBorderStyle = pBSDict->GetStringBy("S", "S"); if (sBorderStyle == "S") - return BBS_SOLID; + return BorderStyle::SOLID; if (sBorderStyle == "D") - return BBS_DASH; + return BorderStyle::DASH; if (sBorderStyle == "B") - return BBS_BEVELED; + return BorderStyle::BEVELED; if (sBorderStyle == "I") - return BBS_INSET; + return BorderStyle::INSET; if (sBorderStyle == "U") - return BBS_UNDERLINE; + return BorderStyle::UNDERLINE; } CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArrayBy("Border"); @@ -724,11 +733,11 @@ int CPDFSDK_BAAnnot::GetBorderStyle() const { if (pBorder->GetCount() >= 4) { CPDF_Array* pDP = pBorder->GetArrayAt(3); if (pDP && pDP->GetCount() > 0) - return BBS_DASH; + return BorderStyle::DASH; } } - return BBS_SOLID; + return BorderStyle::SOLID; } void CPDFSDK_BAAnnot::SetColor(FX_COLORREF color) { @@ -832,15 +841,12 @@ void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType, FALSE); } -#define BA_ANNOT_MINWIDTH 1 -#define BA_ANNOT_MINHEIGHT 1 - FX_FLOAT CPDFSDK_Annot::GetMinWidth() const { - return BA_ANNOT_MINWIDTH; + return kMinWidth; } FX_FLOAT CPDFSDK_Annot::GetMinHeight() const { - return BA_ANNOT_MINHEIGHT; + return kMinHeight; } FX_BOOL CPDFSDK_BAAnnot::CreateFormFiller() { diff --git a/fpdfsdk/fsdk_baseform.cpp b/fpdfsdk/fsdk_baseform.cpp index 177e7de978..4e5c9f0065 100644 --- a/fpdfsdk/fsdk_baseform.cpp +++ b/fpdfsdk/fsdk_baseform.cpp @@ -880,32 +880,25 @@ void CPDFSDK_Widget::ResetAppearance_PushButton() { crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth(); - int32_t nBorderStyle = 0; CPWL_Dash dsBorder(3, 0, 0); CPWL_Color crLeftTop, crRightBottom; - switch (GetBorderStyle()) { - case BBS_DASH: - nBorderStyle = PBS_DASH; + BorderStyle nBorderStyle = GetBorderStyle(); + switch (nBorderStyle) { + case BorderStyle::DASH: dsBorder = CPWL_Dash(3, 3, 0); break; - case BBS_BEVELED: - nBorderStyle = PBS_BEVELED; + case BorderStyle::BEVELED: fBorderWidth *= 2; crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1); crRightBottom = CPWL_Utils::DevideColor(crBackground, 2); break; - case BBS_INSET: - nBorderStyle = PBS_INSET; + case BorderStyle::INSET: fBorderWidth *= 2; crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5); crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75); break; - case BBS_UNDERLINE: - nBorderStyle = PBS_UNDERLINED; - break; default: - nBorderStyle = PBS_SOLID; break; } @@ -1022,15 +1015,19 @@ void CPDFSDK_Widget::ResetAppearance_PushButton() { } switch (nBorderStyle) { - case PBS_BEVELED: { + case BorderStyle::BEVELED: { CPWL_Color crTemp = crLeftTop; crLeftTop = crRightBottom; crRightBottom = crTemp; - } break; - case PBS_INSET: + break; + } + case BorderStyle::INSET: { crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0); crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1); break; + } + default: + break; } font_map.SetAPType("D"); @@ -1068,32 +1065,25 @@ void CPDFSDK_Widget::ResetAppearance_CheckBox() { crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth(); - int32_t nBorderStyle = 0; CPWL_Dash dsBorder(3, 0, 0); CPWL_Color crLeftTop, crRightBottom; - switch (GetBorderStyle()) { - case BBS_DASH: - nBorderStyle = PBS_DASH; + BorderStyle nBorderStyle = GetBorderStyle(); + switch (nBorderStyle) { + case BorderStyle::DASH: dsBorder = CPWL_Dash(3, 3, 0); break; - case BBS_BEVELED: - nBorderStyle = PBS_BEVELED; + case BorderStyle::BEVELED: fBorderWidth *= 2; crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1); crRightBottom = CPWL_Utils::DevideColor(crBackground, 2); break; - case BBS_INSET: - nBorderStyle = PBS_INSET; + case BorderStyle::INSET: fBorderWidth *= 2; crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5); crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75); break; - case BBS_UNDERLINE: - nBorderStyle = PBS_UNDERLINED; - break; default: - nBorderStyle = PBS_SOLID; break; } @@ -1143,15 +1133,19 @@ void CPDFSDK_Widget::ResetAppearance_CheckBox() { CFX_ByteString csAP_N_OFF = csAP_N_ON; switch (nBorderStyle) { - case PBS_BEVELED: { + case BorderStyle::BEVELED: { CPWL_Color crTemp = crLeftTop; crLeftTop = crRightBottom; crRightBottom = crTemp; - } break; - case PBS_INSET: + break; + } + case BorderStyle::INSET: { crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0); crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1); break; + } + default: + break; } CFX_ByteString csAP_D_ON = @@ -1194,32 +1188,25 @@ void CPDFSDK_Widget::ResetAppearance_RadioButton() { crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth(); - int32_t nBorderStyle = 0; CPWL_Dash dsBorder(3, 0, 0); CPWL_Color crLeftTop, crRightBottom; - switch (GetBorderStyle()) { - case BBS_DASH: - nBorderStyle = PBS_DASH; + BorderStyle nBorderStyle = GetBorderStyle(); + switch (nBorderStyle) { + case BorderStyle::DASH: dsBorder = CPWL_Dash(3, 3, 0); break; - case BBS_BEVELED: - nBorderStyle = PBS_BEVELED; + case BorderStyle::BEVELED: fBorderWidth *= 2; crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1); crRightBottom = CPWL_Utils::DevideColor(crBackground, 2); break; - case BBS_INSET: - nBorderStyle = PBS_INSET; + case BorderStyle::INSET: fBorderWidth *= 2; crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5); crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75); break; - case BBS_UNDERLINE: - nBorderStyle = PBS_UNDERLINED; - break; default: - nBorderStyle = PBS_SOLID; break; } @@ -1266,10 +1253,10 @@ void CPDFSDK_Widget::ResetAppearance_RadioButton() { CPWL_Utils::DeflateRect(CPWL_Utils::GetCenterSquare(rcWindow), 1.0f); if (nStyle == PCS_CIRCLE) { - if (nBorderStyle == PBS_BEVELED) { + if (nBorderStyle == BorderStyle::BEVELED) { crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1); crRightBottom = CPWL_Utils::SubstractColor(crBackground, 0.25f); - } else if (nBorderStyle == PBS_INSET) { + } else if (nBorderStyle == BorderStyle::INSET) { crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5f); crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75f); } @@ -1288,26 +1275,30 @@ void CPDFSDK_Widget::ResetAppearance_RadioButton() { CFX_ByteString csAP_N_OFF = csAP_N_ON; switch (nBorderStyle) { - case PBS_BEVELED: { + case BorderStyle::BEVELED: { CPWL_Color crTemp = crLeftTop; crLeftTop = crRightBottom; crRightBottom = crTemp; - } break; - case PBS_INSET: + break; + } + case BorderStyle::INSET: { crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0); crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1); break; + } + default: + break; } CFX_ByteString csAP_D_ON; if (nStyle == PCS_CIRCLE) { CPWL_Color crBK = CPWL_Utils::SubstractColor(crBackground, 0.25f); - if (nBorderStyle == PBS_BEVELED) { + if (nBorderStyle == BorderStyle::BEVELED) { crLeftTop = CPWL_Utils::SubstractColor(crBackground, 0.25f); crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1); crBK = crBackground; - } else if (nBorderStyle == PBS_INSET) { + } else if (nBorderStyle == BorderStyle::INSET) { crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0); crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1); } @@ -1597,7 +1588,7 @@ void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) { if (bCharArray) { switch (GetBorderStyle()) { - case BBS_SOLID: { + case BorderStyle::SOLID: { CFX_ByteString sColor = CPWL_Utils::GetColorAppStream(GetBorderPWLColor(), FALSE); if (sColor.GetLength() > 0) { @@ -1617,8 +1608,9 @@ void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) { sLines << "Q\n"; } - } break; - case BBS_DASH: { + break; + } + case BorderStyle::DASH: { CFX_ByteString sColor = CPWL_Utils::GetColorAppStream(GetBorderPWLColor(), FALSE); if (sColor.GetLength() > 0) { @@ -1641,7 +1633,10 @@ void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) { sLines << "Q\n"; } - } break; + break; + } + default: + break; } } @@ -1656,10 +1651,12 @@ CFX_FloatRect CPDFSDK_Widget::GetClientRect() const { CFX_FloatRect rcWindow = GetRotatedRect(); FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth(); switch (GetBorderStyle()) { - case BBS_BEVELED: - case BBS_INSET: + case BorderStyle::BEVELED: + case BorderStyle::INSET: fBorderWidth *= 2.0f; break; + default: + break; } return CPWL_Utils::DeflateRect(rcWindow, fBorderWidth); @@ -1702,31 +1699,24 @@ CFX_ByteString CPDFSDK_Widget::GetBorderAppStream() const { CPWL_Color crLeftTop, crRightBottom; FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth(); - int32_t nBorderStyle = 0; CPWL_Dash dsBorder(3, 0, 0); - switch (GetBorderStyle()) { - case BBS_DASH: - nBorderStyle = PBS_DASH; + BorderStyle nBorderStyle = GetBorderStyle(); + switch (nBorderStyle) { + case BorderStyle::DASH: dsBorder = CPWL_Dash(3, 3, 0); break; - case BBS_BEVELED: - nBorderStyle = PBS_BEVELED; + case BorderStyle::BEVELED: fBorderWidth *= 2; crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1); crRightBottom = CPWL_Utils::DevideColor(crBackground, 2); break; - case BBS_INSET: - nBorderStyle = PBS_INSET; + case BorderStyle::INSET: fBorderWidth *= 2; crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5); crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75); break; - case BBS_UNDERLINE: - nBorderStyle = PBS_UNDERLINED; - break; default: - nBorderStyle = PBS_SOLID; break; } diff --git a/fpdfsdk/include/fsdk_baseannot.h b/fpdfsdk/include/fsdk_baseannot.h index cb7d49e789..236e2c7868 100644 --- a/fpdfsdk/include/fsdk_baseannot.h +++ b/fpdfsdk/include/fsdk_baseannot.h @@ -16,6 +16,7 @@ #include "core/fpdfdoc/include/fpdf_doc.h" #include "core/fxcrt/include/fx_basic.h" #include "fpdfsdk/cfx_systemhandler.h" +#include "fpdfsdk/include/fsdk_common.h" #include "fpdfsdk/include/fsdk_define.h" class CPDFSDK_PageView; @@ -155,29 +156,17 @@ class CPDFSDK_BAAnnot : public CPDFSDK_Annot { void SetStructParent(int key); int GetStructParent() const; - // border void SetBorderWidth(int nWidth); int GetBorderWidth() const; - // BBS_SOLID - // BBS_DASH - // BBS_BEVELED - // BBS_INSET - // BBS_UNDERLINE - - void SetBorderStyle(int nStyle); - int GetBorderStyle() const; - - // The background of the annotation's icon when closed - // The title bar of the annotation's pop-up window - // The border of a link annotation + void SetBorderStyle(BorderStyle nStyle); + BorderStyle GetBorderStyle() const; void SetColor(FX_COLORREF color); void RemoveColor(); FX_BOOL GetColor(FX_COLORREF& color) const; FX_BOOL IsVisible() const; - // action CPDF_Action GetAction() const; void SetAction(const CPDF_Action& a); diff --git a/fpdfsdk/include/fsdk_common.h b/fpdfsdk/include/fsdk_common.h index c20262dae8..5c5d24f2c8 100644 --- a/fpdfsdk/include/fsdk_common.h +++ b/fpdfsdk/include/fsdk_common.h @@ -33,10 +33,4 @@ #define FIELDFLAG_MULTISELECT (1 << 21) #define FIELDFLAG_COMMITONSELCHANGE (1 << 26) -#define BBS_SOLID 0 -#define BBS_DASH 1 -#define BBS_BEVELED 2 -#define BBS_INSET 3 -#define BBS_UNDERLINE 4 - #endif // FPDFSDK_INCLUDE_FSDK_COMMON_H_ diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp index 158d4d6a7f..c1838332ba 100644 --- a/fpdfsdk/javascript/Field.cpp +++ b/fpdfsdk/javascript/Field.cpp @@ -395,22 +395,20 @@ FX_BOOL Field::borderStyle(IJS_Context* cc, if (!pWidget) return FALSE; - int nBorderstyle = pWidget->GetBorderStyle(); - - switch (nBorderstyle) { - case BBS_SOLID: + switch (pWidget->GetBorderStyle()) { + case BorderStyle::SOLID: vp << L"solid"; break; - case BBS_DASH: + case BorderStyle::DASH: vp << L"dashed"; break; - case BBS_BEVELED: + case BorderStyle::BEVELED: vp << L"beveled"; break; - case BBS_INSET: + case BorderStyle::INSET: vp << L"inset"; break; - case BBS_UNDERLINE: + case BorderStyle::UNDERLINE: vp << L"underline"; break; default: @@ -428,18 +426,17 @@ void Field::SetBorderStyle(CPDFSDK_Document* pDocument, const CFX_ByteString& string) { ASSERT(pDocument); - int nBorderStyle = 0; - + BorderStyle nBorderStyle = BorderStyle::SOLID; if (string == "solid") - nBorderStyle = BBS_SOLID; + nBorderStyle = BorderStyle::SOLID; else if (string == "beveled") - nBorderStyle = BBS_BEVELED; + nBorderStyle = BorderStyle::BEVELED; else if (string == "dashed") - nBorderStyle = BBS_DASH; + nBorderStyle = BorderStyle::DASH; else if (string == "inset") - nBorderStyle = BBS_INSET; + nBorderStyle = BorderStyle::INSET; else if (string == "underline") - nBorderStyle = BBS_UNDERLINE; + nBorderStyle = BorderStyle::UNDERLINE; else return; diff --git a/fpdfsdk/pdfwindow/PWL_ComboBox.cpp b/fpdfsdk/pdfwindow/PWL_ComboBox.cpp index aa0db4b291..f49016123a 100644 --- a/fpdfsdk/pdfwindow/PWL_ComboBox.cpp +++ b/fpdfsdk/pdfwindow/PWL_ComboBox.cpp @@ -303,7 +303,7 @@ void CPWL_ComboBox::CreateEdit(const PWL_CREATEPARAM& cp) { ecp.rcRectWnd = CFX_FloatRect(0, 0, 0, 0); ecp.dwBorderWidth = 0; - ecp.nBorderStyle = PBS_SOLID; + ecp.nBorderStyle = BorderStyle::SOLID; m_pEdit->Create(ecp); } @@ -319,7 +319,7 @@ void CPWL_ComboBox::CreateButton(const PWL_CREATEPARAM& cp) { bcp.sBackgroundColor = PWL_SCROLLBAR_BKCOLOR; bcp.sBorderColor = PWL_DEFAULT_BLACKCOLOR; bcp.dwBorderWidth = 2; - bcp.nBorderStyle = PBS_BEVELED; + bcp.nBorderStyle = BorderStyle::BEVELED; bcp.eCursorType = FXCT_ARROW; m_pButton->Create(bcp); @@ -334,7 +334,7 @@ void CPWL_ComboBox::CreateListBox(const PWL_CREATEPARAM& cp) { lcp.pParentWnd = this; lcp.dwFlags = PWS_CHILD | PWS_BORDER | PWS_BACKGROUND | PLBS_HOVERSEL | PWS_VSCROLL; - lcp.nBorderStyle = PBS_SOLID; + lcp.nBorderStyle = BorderStyle::SOLID; lcp.dwBorderWidth = 1; lcp.eCursorType = FXCT_ARROW; lcp.rcRectWnd = CFX_FloatRect(0, 0, 0, 0); diff --git a/fpdfsdk/pdfwindow/PWL_Edit.cpp b/fpdfsdk/pdfwindow/PWL_Edit.cpp index ae95570d6c..e39b6c13c7 100644 --- a/fpdfsdk/pdfwindow/PWL_Edit.cpp +++ b/fpdfsdk/pdfwindow/PWL_Edit.cpp @@ -199,7 +199,7 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { if (nCharArray > 0) { switch (GetBorderStyle()) { - case PBS_SOLID: { + case BorderStyle::SOLID: { sLine << "q\n" << GetBorderWidth() << " w\n" << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) .AsStringC() @@ -215,8 +215,9 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { } sLine << "Q\n"; - } break; - case PBS_DASH: { + break; + } + case BorderStyle::DASH: { sLine << "q\n" << GetBorderWidth() << " w\n" << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) .AsStringC() @@ -234,7 +235,10 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { } sLine << "Q\n"; - } break; + break; + } + default: + break; } } @@ -318,7 +322,7 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, if (nCharArray > 0 && nCharArraySafe.IsValid()) { switch (GetBorderStyle()) { - case PBS_SOLID: { + case BorderStyle::SOLID: { CFX_GraphStateData gsd; gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); @@ -337,13 +341,15 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.top, FXPT_LINETO); } - if (path.GetPointCount() > 0) + if (path.GetPointCount() > 0) { pDevice->DrawPath( &path, pUser2Device, &gsd, 0, CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255), FXFILL_ALTERNATE); - } break; - case PBS_DASH: { + } + break; + } + case BorderStyle::DASH: { CFX_GraphStateData gsd; gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); @@ -367,12 +373,16 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.top, FXPT_LINETO); } - if (path.GetPointCount() > 0) + if (path.GetPointCount() > 0) { pDevice->DrawPath( &path, pUser2Device, &gsd, 0, CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255), FXFILL_ALTERNATE); - } break; + } + break; + } + default: + break; } } diff --git a/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp b/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp index 88046a2d86..aa653929bd 100644 --- a/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp +++ b/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp @@ -128,7 +128,7 @@ void CPWL_EditCtrl::CreateEditCaret(const PWL_CREATEPARAM& cp) { ecp.pParentWnd = this; ecp.dwFlags = PWS_CHILD | PWS_NOREFRESHCLIP; ecp.dwBorderWidth = 0; - ecp.nBorderStyle = PBS_SOLID; + ecp.nBorderStyle = BorderStyle::SOLID; ecp.rcRectWnd = CFX_FloatRect(0, 0, 0, 0); m_pEditCaret->Create(ecp); diff --git a/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp b/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp index 385ff44f4a..9532244bc9 100644 --- a/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp +++ b/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp @@ -852,7 +852,7 @@ void CPWL_ScrollBar::CreateButtons(const PWL_CREATEPARAM& cp) { PWL_CREATEPARAM scp = cp; scp.pParentWnd = this; scp.dwBorderWidth = 2; - scp.nBorderStyle = PBS_BEVELED; + scp.nBorderStyle = BorderStyle::BEVELED; scp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PWS_BACKGROUND | PWS_NOREFRESHCLIP; diff --git a/fpdfsdk/pdfwindow/PWL_Utils.cpp b/fpdfsdk/pdfwindow/PWL_Utils.cpp index 60949abd4e..e4232db5e8 100644 --- a/fpdfsdk/pdfwindow/PWL_Utils.cpp +++ b/fpdfsdk/pdfwindow/PWL_Utils.cpp @@ -714,7 +714,7 @@ CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect, const CPWL_Color& color, const CPWL_Color& crLeftTop, const CPWL_Color& crRightBottom, - int32_t nStyle, + BorderStyle nStyle, const CPWL_Dash& dash) { CFX_ByteTextBuf sAppStream; CFX_ByteString sColor; @@ -731,7 +731,7 @@ CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect, switch (nStyle) { default: - case PBS_SOLID: + case BorderStyle::SOLID: sColor = CPWL_Utils::GetColorAppStream(color, TRUE); if (sColor.GetLength() > 0) { sAppStream << sColor; @@ -743,7 +743,7 @@ CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect, sAppStream << "f*\n"; } break; - case PBS_DASH: + case BorderStyle::DASH: sColor = CPWL_Utils::GetColorAppStream(color, FALSE); if (sColor.GetLength() > 0) { sAppStream << sColor; @@ -762,8 +762,8 @@ CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect, << " l S\n"; } break; - case PBS_BEVELED: - case PBS_INSET: + case BorderStyle::BEVELED: + case BorderStyle::INSET: sColor = CPWL_Utils::GetColorAppStream(crLeftTop, TRUE); if (sColor.GetLength() > 0) { sAppStream << sColor; @@ -808,7 +808,7 @@ CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect, << fTop - fBottom - fHalfWidth * 2 << " re f*\n"; } break; - case PBS_UNDERLINED: + case BorderStyle::UNDERLINE: sColor = CPWL_Utils::GetColorAppStream(color, FALSE); if (sColor.GetLength() > 0) { sAppStream << sColor; @@ -831,7 +831,7 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream( const CPWL_Color& color, const CPWL_Color& crLeftTop, const CPWL_Color& crRightBottom, - int32_t nStyle, + BorderStyle nStyle, const CPWL_Dash& dash) { CFX_ByteTextBuf sAppStream; CFX_ByteString sColor; @@ -841,8 +841,8 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream( switch (nStyle) { default: - case PBS_SOLID: - case PBS_UNDERLINED: { + case BorderStyle::SOLID: + case BorderStyle::UNDERLINE: { sColor = CPWL_Utils::GetColorAppStream(color, FALSE); if (sColor.GetLength() > 0) { sAppStream << "q\n" << fWidth << " w\n" << sColor @@ -851,7 +851,7 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream( << " S\nQ\n"; } } break; - case PBS_DASH: { + case BorderStyle::DASH: { sColor = CPWL_Utils::GetColorAppStream(color, FALSE); if (sColor.GetLength() > 0) { sAppStream << "q\n" << fWidth << " w\n" @@ -862,7 +862,7 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream( << " S\nQ\n"; } } break; - case PBS_BEVELED: { + case BorderStyle::BEVELED: { FX_FLOAT fHalfWidth = fWidth / 2.0f; sColor = CPWL_Utils::GetColorAppStream(color, FALSE); @@ -889,7 +889,7 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream( << " S\nQ\n"; } } break; - case PBS_INSET: { + case BorderStyle::INSET: { FX_FLOAT fHalfWidth = fWidth / 2.0f; sColor = CPWL_Utils::GetColorAppStream(color, FALSE); @@ -1078,11 +1078,12 @@ CFX_ByteString CPWL_Utils::GetDropButtonAppStream(const CFX_FloatRect& rcBBox) { << rcBBox.top - rcBBox.bottom << " re f\n"; sAppStream << "Q\n"; - sAppStream << "q\n" << CPWL_Utils::GetBorderAppStream( - rcBBox, 2, CPWL_Color(COLORTYPE_GRAY, 0), - CPWL_Color(COLORTYPE_GRAY, 1), - CPWL_Color(COLORTYPE_GRAY, 0.5), PBS_BEVELED, - CPWL_Dash(3, 0, 0)) + sAppStream << "q\n" + << CPWL_Utils::GetBorderAppStream( + rcBBox, 2, CPWL_Color(COLORTYPE_GRAY, 0), + CPWL_Color(COLORTYPE_GRAY, 1), + CPWL_Color(COLORTYPE_GRAY, 0.5), BorderStyle::BEVELED, + CPWL_Dash(3, 0, 0)) << "Q\n"; CFX_FloatPoint ptCenter = CFX_FloatPoint((rcBBox.left + rcBBox.right) / 2, @@ -1322,7 +1323,7 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, const CPWL_Color& color, const CPWL_Color& crLeftTop, const CPWL_Color& crRightBottom, - int32_t nStyle, + BorderStyle nStyle, int32_t nTransparancy) { FX_FLOAT fLeft = rect.left; FX_FLOAT fRight = rect.right; @@ -1334,7 +1335,7 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, switch (nStyle) { default: - case PBS_SOLID: { + case BorderStyle::SOLID: { CFX_PathData path; path.AppendRect(fLeft, fBottom, fRight, fTop); path.AppendRect(fLeft + fWidth, fBottom + fWidth, fRight - fWidth, @@ -1342,8 +1343,9 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, pDevice->DrawPath(&path, pUser2Device, NULL, PWLColorToFXColor(color, nTransparancy), 0, FXFILL_ALTERNATE); - } break; - case PBS_DASH: { + break; + } + case BorderStyle::DASH: { CFX_PathData path; path.SetPointCount(5); @@ -1368,9 +1370,10 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, pDevice->DrawPath(&path, pUser2Device, &gsd, 0, PWLColorToFXColor(color, nTransparancy), FXFILL_WINDING); - } break; - case PBS_BEVELED: - case PBS_INSET: { + break; + } + case BorderStyle::BEVELED: + case BorderStyle::INSET: { CFX_GraphStateData gsd; gsd.m_LineWidth = fHalfWidth; @@ -1423,8 +1426,9 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, pDevice->DrawPath(&path, pUser2Device, &gsd, PWLColorToFXColor(color, nTransparancy), 0, FXFILL_ALTERNATE); - } break; - case PBS_UNDERLINED: { + break; + } + case BorderStyle::UNDERLINE: { CFX_PathData path; path.SetPointCount(2); @@ -1437,16 +1441,8 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, pDevice->DrawPath(&path, pUser2Device, &gsd, 0, PWLColorToFXColor(color, nTransparancy), FXFILL_ALTERNATE); - } break; - case PBS_SHADOW: { - CFX_PathData path; - path.AppendRect(fLeft, fBottom, fRight, fTop); - path.AppendRect(fLeft + fWidth, fBottom + fWidth, fRight - fWidth, - fTop - fWidth); - pDevice->DrawPath(&path, pUser2Device, NULL, - PWLColorToFXColor(color, nTransparancy / 2), 0, - FXFILL_ALTERNATE); - } break; + break; + } } } } diff --git a/fpdfsdk/pdfwindow/PWL_Utils.h b/fpdfsdk/pdfwindow/PWL_Utils.h index cdef768cfa..8ab08a857e 100644 --- a/fpdfsdk/pdfwindow/PWL_Utils.h +++ b/fpdfsdk/pdfwindow/PWL_Utils.h @@ -136,7 +136,7 @@ class CPWL_Utils { const CPWL_Color& color, const CPWL_Color& crLeftTop, const CPWL_Color& crRightBottom, - int32_t nStyle, + BorderStyle nStyle, const CPWL_Dash& dash); static CFX_ByteString GetCircleBorderAppStream( const CFX_FloatRect& rect, @@ -144,7 +144,7 @@ class CPWL_Utils { const CPWL_Color& color, const CPWL_Color& crLeftTop, const CPWL_Color& crRightBottom, - int32_t nStyle, + BorderStyle nStyle, const CPWL_Dash& dash); static CFX_ByteString GetRectFillAppStream(const CFX_FloatRect& rect, const CPWL_Color& color); @@ -213,7 +213,7 @@ class CPWL_Utils { const CPWL_Color& color, const CPWL_Color& crLeftTop, const CPWL_Color& crRightBottom, - int32_t nStyle, + BorderStyle nStyle, int32_t nTransparancy); static void DrawFillArea(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device, diff --git a/fpdfsdk/pdfwindow/PWL_Wnd.cpp b/fpdfsdk/pdfwindow/PWL_Wnd.cpp index bb424ffa43..310f2f3f90 100644 --- a/fpdfsdk/pdfwindow/PWL_Wnd.cpp +++ b/fpdfsdk/pdfwindow/PWL_Wnd.cpp @@ -585,11 +585,11 @@ CPWL_Color CPWL_Wnd::GetTextStrokeColor() const { return m_sPrivateParam.sTextStrokeColor; } -int32_t CPWL_Wnd::GetBorderStyle() const { +BorderStyle CPWL_Wnd::GetBorderStyle() const { return m_sPrivateParam.nBorderStyle; } -void CPWL_Wnd::SetBorderStyle(int32_t nBorderStyle) { +void CPWL_Wnd::SetBorderStyle(BorderStyle nBorderStyle) { if (HasFlag(PWS_BORDER)) m_sPrivateParam.nBorderStyle = nBorderStyle; } @@ -819,46 +819,26 @@ IPVT_FontMap* CPWL_Wnd::GetFontMap() const { return m_sPrivateParam.pFontMap; } -CPWL_Color CPWL_Wnd::GetBorderLeftTopColor(int32_t nBorderStyle) const { - CPWL_Color color; - +CPWL_Color CPWL_Wnd::GetBorderLeftTopColor(BorderStyle nBorderStyle) const { switch (nBorderStyle) { - case PBS_SOLID: - break; - case PBS_DASH: - break; - case PBS_BEVELED: - color = CPWL_Color(COLORTYPE_GRAY, 1); - break; - case PBS_INSET: - color = CPWL_Color(COLORTYPE_GRAY, 0.5f); - break; - case PBS_UNDERLINED: - break; + case BorderStyle::BEVELED: + return CPWL_Color(COLORTYPE_GRAY, 1); + case BorderStyle::INSET: + return CPWL_Color(COLORTYPE_GRAY, 0.5f); + default: + return CPWL_Color(); } - - return color; } -CPWL_Color CPWL_Wnd::GetBorderRightBottomColor(int32_t nBorderStyle) const { - CPWL_Color color; - +CPWL_Color CPWL_Wnd::GetBorderRightBottomColor(BorderStyle nBorderStyle) const { switch (nBorderStyle) { - case PBS_SOLID: - break; - case PBS_DASH: - break; - case PBS_BEVELED: - color = CPWL_Utils::DevideColor(GetBackgroundColor(), 2); - break; - case PBS_INSET: - color = CPWL_Color(COLORTYPE_GRAY, 0.75f); - break; - case PBS_UNDERLINED: - break; + case BorderStyle::BEVELED: + return CPWL_Utils::DevideColor(GetBackgroundColor(), 2); + case BorderStyle::INSET: + return CPWL_Color(COLORTYPE_GRAY, 0.75f); + default: + return CPWL_Color(); } - - return color; } int32_t CPWL_Wnd::GetTransparency() { diff --git a/fpdfsdk/pdfwindow/PWL_Wnd.h b/fpdfsdk/pdfwindow/PWL_Wnd.h index 319e6da9a4..c8552fb985 100644 --- a/fpdfsdk/pdfwindow/PWL_Wnd.h +++ b/fpdfsdk/pdfwindow/PWL_Wnd.h @@ -68,14 +68,6 @@ class IPWL_Provider; #define PRES_MULTIPAGES 0x0200L #define PRES_TEXTOVERFLOW 0x0400L -// border style -#define PBS_SOLID 0 -#define PBS_DASH 1 -#define PBS_BEVELED 2 -#define PBS_INSET 3 -#define PBS_UNDERLINED 4 -#define PBS_SHADOW 5 - // notification messages #define PNM_ADDCHILD 0x00000000L #define PNM_REMOVECHILD 0x00000001L @@ -203,7 +195,7 @@ struct PWL_CREATEPARAM { dwFlags(0), sBackgroundColor(), hAttachedWnd(NULL), - nBorderStyle(PBS_SOLID), + nBorderStyle(BorderStyle::SOLID), dwBorderWidth(1), sBorderColor(), sTextColor(), @@ -225,7 +217,7 @@ struct PWL_CREATEPARAM { uint32_t dwFlags; // optional CPWL_Color sBackgroundColor; // optional FX_HWND hAttachedWnd; // required for no-reader framework - int32_t nBorderStyle; // optional + BorderStyle nBorderStyle; // optional int32_t dwBorderWidth; // optional CPWL_Color sBorderColor; // optional CPWL_Color sTextColor; // optional @@ -322,14 +314,14 @@ class CPWL_Wnd : public CPWL_TimerHandler { virtual CPWL_Color GetTextStrokeColor() const; virtual FX_FLOAT GetFontSize() const; virtual int32_t GetInnerBorderWidth() const; - virtual CPWL_Color GetBorderLeftTopColor(int32_t nBorderStyle) const; - virtual CPWL_Color GetBorderRightBottomColor(int32_t nBorderStyle) const; + virtual CPWL_Color GetBorderLeftTopColor(BorderStyle nBorderStyle) const; + virtual CPWL_Color GetBorderRightBottomColor(BorderStyle nBorderStyle) const; virtual void SetFontSize(FX_FLOAT fFontSize); void SetBackgroundColor(const CPWL_Color& color); void SetClipRect(const CFX_FloatRect& rect); - void SetBorderStyle(int32_t eBorderStyle); + void SetBorderStyle(BorderStyle eBorderStyle); virtual CFX_FloatRect GetWindowRect() const; virtual CFX_FloatRect GetClientRect() const; @@ -341,7 +333,7 @@ class CPWL_Wnd : public CPWL_TimerHandler { void RemoveFlag(uint32_t dwFlags); const CFX_FloatRect& GetClipRect() const; CPWL_Wnd* GetParentWindow() const; - int32_t GetBorderStyle() const; + BorderStyle GetBorderStyle() const; const CPWL_Dash& GetBorderDash() const; void* GetAttachedData() const; diff --git a/xfa/fwl/basewidget/fxmath_barcodeimp.cpp b/xfa/fwl/basewidget/fxmath_barcodeimp.cpp index 1d3af697b1..a67952caa6 100644 --- a/xfa/fwl/basewidget/fxmath_barcodeimp.cpp +++ b/xfa/fwl/basewidget/fxmath_barcodeimp.cpp @@ -16,6 +16,7 @@ #include "xfa/fxbarcode/cbc_pdf417i.h" #include "xfa/fxbarcode/cbc_qrcode.h" #include "xfa/fxbarcode/cbc_upca.h" +#include "xfa/fxbarcode/utils.h" static CBC_CodeBase* FX_Barcode_CreateBarCodeEngineObject(BC_TYPE type) { switch (type) { @@ -320,15 +321,7 @@ FX_BOOL CFX_Barcode::SetTruncated(FX_BOOL truncated) { return m_pBCEngine && memptr ? ((m_pBCEngine->*memptr)(truncated), TRUE) : FALSE; } -#ifndef BCExceptionNO -#define BCExceptionNO 0 -#endif -#ifndef BCExceptionFormatException -#define BCExceptionFormatException 8 -#endif -#ifndef BCExceptionUnSupportedBarcode -#define BCExceptionUnSupportedBarcode 18 -#endif + FX_BOOL CFX_Barcode::Encode(const CFX_WideStringC& contents, FX_BOOL isDevice, int32_t& e) { @@ -351,13 +344,12 @@ FX_BOOL CFX_Barcode::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { } return m_pBCEngine->RenderBitmap(pOutBitmap, e); } -#define BC_TYPE_MIN BC_CODE39 -#define BC_TYPE_MAX BC_DATAMATRIX + CFX_WideString CFX_Barcode::Decode(uint8_t* buf, int32_t width, int32_t height, int32_t& errorCode) { - for (BC_TYPE t = BC_TYPE_MIN; t <= BC_TYPE_MAX; + for (BC_TYPE t = BC_CODE39; t <= BC_DATAMATRIX; t = (BC_TYPE)((int32_t)t + 1)) { CBC_CodeBase* pTmpEngine = FX_Barcode_CreateBarCodeEngineObject(t); if (!pTmpEngine) { @@ -372,7 +364,7 @@ CFX_WideString CFX_Barcode::Decode(uint8_t* buf, return CFX_WideString(); } CFX_WideString CFX_Barcode::Decode(CFX_DIBitmap* pBitmap, int32_t& errorCode) { - for (BC_TYPE t = BC_TYPE_MIN; t <= BC_TYPE_MAX; + for (BC_TYPE t = BC_CODE39; t <= BC_DATAMATRIX; t = (BC_TYPE)((int32_t)t + 1)) { CBC_CodeBase* pTmpEngine = FX_Barcode_CreateBarCodeEngineObject(t); if (!pTmpEngine) { -- cgit v1.2.3