From c812495631df9f059bfd332ffe37e76dd011e96c Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 26 Jan 2016 14:36:36 -0800 Subject: Fix collison with Windows #define RGB macro. kGray and such are much safer. TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1638093002 . --- core/include/fpdfdoc/fpdf_ap.h | 4 ++-- core/src/fpdfdoc/doc_ap.cpp | 43 +++++++++++++++++++++--------------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/core/include/fpdfdoc/fpdf_ap.h b/core/include/fpdfdoc/fpdf_ap.h index dddbb6e0df..510b39cb9b 100644 --- a/core/include/fpdfdoc/fpdf_ap.h +++ b/core/include/fpdfdoc/fpdf_ap.h @@ -27,9 +27,9 @@ struct CPVT_Dash { }; struct CPVT_Color { - enum Type { TRANSPARENT = 0, GRAY, RGB, CMYK }; + enum Type { kTransparent = 0, kGray, kRGB, kCMYK }; - CPVT_Color(Type type = TRANSPARENT, + CPVT_Color(Type type = kTransparent, FX_FLOAT color1 = 0.0f, FX_FLOAT color2 = 0.0f, FX_FLOAT color3 = 0.0f, diff --git a/core/src/fpdfdoc/doc_ap.cpp b/core/src/fpdfdoc/doc_ap.cpp index d1cc44d0b3..15576965b1 100644 --- a/core/src/fpdfdoc/doc_ap.cpp +++ b/core/src/fpdfdoc/doc_ap.cpp @@ -230,14 +230,14 @@ static CPVT_Color ParseColor(const CFX_ByteString& str) { CPDF_SimpleParser syntax(str); syntax.SetPos(0); if (syntax.FindTagParam("g", 1)) { - return CPVT_Color(CPVT_Color::GRAY, FX_atof(syntax.GetWord())); + return CPVT_Color(CPVT_Color::kGray, FX_atof(syntax.GetWord())); } syntax.SetPos(0); if (syntax.FindTagParam("rg", 3)) { FX_FLOAT f1 = FX_atof(syntax.GetWord()); FX_FLOAT f2 = FX_atof(syntax.GetWord()); FX_FLOAT f3 = FX_atof(syntax.GetWord()); - return CPVT_Color(CPVT_Color::RGB, f1, f2, f3); + return CPVT_Color(CPVT_Color::kRGB, f1, f2, f3); } syntax.SetPos(0); if (syntax.FindTagParam("k", 4)) { @@ -245,22 +245,22 @@ static CPVT_Color ParseColor(const CFX_ByteString& str) { FX_FLOAT f2 = FX_atof(syntax.GetWord()); FX_FLOAT f3 = FX_atof(syntax.GetWord()); FX_FLOAT f4 = FX_atof(syntax.GetWord()); - return CPVT_Color(CPVT_Color::CMYK, f1, f2, f3, f4); + return CPVT_Color(CPVT_Color::kCMYK, f1, f2, f3, f4); } - return CPVT_Color(CPVT_Color::TRANSPARENT); + return CPVT_Color(CPVT_Color::kTransparent); } static CPVT_Color ParseColor(const CPDF_Array& array) { CPVT_Color rt; switch (array.GetCount()) { case 1: - rt = CPVT_Color(CPVT_Color::GRAY, array.GetFloat(0)); + rt = CPVT_Color(CPVT_Color::kGray, array.GetFloat(0)); break; case 3: - rt = CPVT_Color(CPVT_Color::RGB, array.GetFloat(0), array.GetFloat(1), + rt = CPVT_Color(CPVT_Color::kRGB, array.GetFloat(0), array.GetFloat(1), array.GetFloat(2)); break; case 4: - rt = CPVT_Color(CPVT_Color::CMYK, array.GetFloat(0), array.GetFloat(1), + rt = CPVT_Color(CPVT_Color::kCMYK, array.GetFloat(0), array.GetFloat(1), array.GetFloat(2), array.GetFloat(3)); break; } @@ -380,14 +380,14 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, case 'B': nBorderStyle = PBS_BEVELED; fBorderWidth *= 2; - crLeftTop = CPVT_Color(CPVT_Color::GRAY, 1); - crRightBottom = CPVT_Color(CPVT_Color::GRAY, 0.5); + crLeftTop = CPVT_Color(CPVT_Color::kGray, 1); + crRightBottom = CPVT_Color(CPVT_Color::kGray, 0.5); break; case 'I': nBorderStyle = PBS_INSET; fBorderWidth *= 2; - crLeftTop = CPVT_Color(CPVT_Color::GRAY, 0.5); - crRightBottom = CPVT_Color(CPVT_Color::GRAY, 0.75); + crLeftTop = CPVT_Color(CPVT_Color::kGray, 0.5); + crRightBottom = CPVT_Color(CPVT_Color::kGray, 0.75); break; case 'U': nBorderStyle = PBS_UNDERLINED; @@ -561,7 +561,7 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, << "Q\nEMC\n"; } CFX_ByteString sButton = CPVT_GenerateAP::GenerateColorAP( - CPVT_Color(CPVT_Color::RGB, 220.0f / 255.0f, 220.0f / 255.0f, + CPVT_Color(CPVT_Color::kRGB, 220.0f / 255.0f, 220.0f / 255.0f, 220.0f / 255.0f), TRUE); if (sButton.GetLength() > 0 && !rcButton.IsEmpty()) { @@ -570,9 +570,10 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, << rcButton.Width() << " " << rcButton.Height() << " re f\n"; sAppStream << "Q\n"; CFX_ByteString sButtonBorder = CPVT_GenerateAP::GenerateBorderAP( - rcButton, 2, CPVT_Color(CPVT_Color::GRAY, 0), - CPVT_Color(CPVT_Color::GRAY, 1), CPVT_Color(CPVT_Color::GRAY, 0.5), - PBS_BEVELED, CPVT_Dash(3, 0, 0)); + rcButton, 2, CPVT_Color(CPVT_Color::kGray, 0), + CPVT_Color(CPVT_Color::kGray, 1), + CPVT_Color(CPVT_Color::kGray, 0.5), PBS_BEVELED, + CPVT_Dash(3, 0, 0)); if (sButtonBorder.GetLength() > 0) { sAppStream << "q\n" << sButtonBorder << "Q\n"; } @@ -643,14 +644,14 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Rect rcItem = CPDF_Rect(rcBody.left, fy - fItemHeight, rcBody.right, fy); sBody << "q\n" << CPVT_GenerateAP::GenerateColorAP( - CPVT_Color(CPVT_Color::RGB, 0, + CPVT_Color(CPVT_Color::kRGB, 0, 51.0f / 255.0f, 113.0f / 255.0f), TRUE) << rcItem.left << " " << rcItem.bottom << " " << rcItem.Width() << " " << rcItem.Height() << " re f\n" << "Q\n"; sBody << "BT\n" << CPVT_GenerateAP::GenerateColorAP( - CPVT_Color(CPVT_Color::GRAY, 1), TRUE) + CPVT_Color(CPVT_Color::kGray, 1), TRUE) << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), CPDF_Point(0.0f, fy), TRUE, 0) @@ -911,21 +912,21 @@ CFX_ByteString CPVT_GenerateAP::GenerateColorAP(const CPVT_Color& color, const FX_BOOL& bFillOrStroke) { CFX_ByteTextBuf sColorStream; switch (color.nColorType) { - case CPVT_Color::RGB: + case CPVT_Color::kRGB: sColorStream << color.fColor1 << " " << color.fColor2 << " " << color.fColor3 << " " << (bFillOrStroke ? "rg" : "RG") << "\n"; break; - case CPVT_Color::GRAY: + case CPVT_Color::kGray: sColorStream << color.fColor1 << " " << (bFillOrStroke ? "g" : "G") << "\n"; break; - case CPVT_Color::CMYK: + case CPVT_Color::kCMYK: sColorStream << color.fColor1 << " " << color.fColor2 << " " << color.fColor3 << " " << color.fColor4 << " " << (bFillOrStroke ? "k" : "K") << "\n"; break; - case CPVT_Color::TRANSPARENT: + case CPVT_Color::kTransparent: break; } return sColorStream.GetByteString(); -- cgit v1.2.3