summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfdoc/cpdf_annotlist.cpp1
-rw-r--r--core/fpdfdoc/cpdf_apsettings.cpp1
-rw-r--r--core/fpdfdoc/cpdf_defaultappearance.cpp43
-rw-r--r--core/fpdfdoc/cpdf_defaultappearance.h8
-rw-r--r--core/fpdfdoc/cpvt_generateap.h1
-rw-r--r--core/fxge/cfx_color.cpp4
-rw-r--r--core/fxge/cfx_color.h2
-rw-r--r--core/fxge/cfx_renderdevice.h1
-rw-r--r--fpdfsdk/cpdfsdk_widget.cpp7
-rw-r--r--fpdfsdk/cpdfsdk_widget.h1
-rw-r--r--fpdfsdk/pwl/cpwl_appstream.cpp6
-rw-r--r--fxjs/cjs_field.cpp2
12 files changed, 39 insertions, 38 deletions
diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp
index 192649d4a4..6b359f1eb5 100644
--- a/core/fpdfdoc/cpdf_annotlist.cpp
+++ b/core/fpdfdoc/cpdf_annotlist.cpp
@@ -19,6 +19,7 @@
#include "core/fpdfapi/parser/cpdf_string.h"
#include "core/fpdfapi/render/cpdf_renderoptions.h"
#include "core/fpdfdoc/cpdf_annot.h"
+#include "core/fpdfdoc/cpdf_formfield.h"
#include "core/fpdfdoc/cpdf_interform.h"
#include "core/fpdfdoc/cpdf_occontext.h"
#include "core/fpdfdoc/cpvt_generateap.h"
diff --git a/core/fpdfdoc/cpdf_apsettings.cpp b/core/fpdfdoc/cpdf_apsettings.cpp
index 076cdd9b9e..0f0989252e 100644
--- a/core/fpdfdoc/cpdf_apsettings.cpp
+++ b/core/fpdfdoc/cpdf_apsettings.cpp
@@ -10,6 +10,7 @@
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
+#include "core/fpdfdoc/cpdf_formcontrol.h"
#include "core/fxge/cfx_color.h"
CPDF_ApSettings::CPDF_ApSettings(CPDF_Dictionary* pDict) : m_pDict(pDict) {}
diff --git a/core/fpdfdoc/cpdf_defaultappearance.cpp b/core/fpdfdoc/cpdf_defaultappearance.cpp
index 8878dc0093..add1c26498 100644
--- a/core/fpdfdoc/cpdf_defaultappearance.cpp
+++ b/core/fpdfdoc/cpdf_defaultappearance.cpp
@@ -88,64 +88,61 @@ bool CPDF_DefaultAppearance::HasColor() {
return FindTagParamFromStart(&syntax, "k", 4);
}
-void CPDF_DefaultAppearance::GetColor(int& iColorType, float fc[4]) {
- iColorType = CFX_Color::kTransparent;
+CFX_Color::Type CPDF_DefaultAppearance::GetColor(float fc[4]) {
for (int c = 0; c < 4; c++)
fc[c] = 0;
if (m_csDA.IsEmpty())
- return;
+ return CFX_Color::kTransparent;
CPDF_SimpleParser syntax(m_csDA.AsStringView());
if (FindTagParamFromStart(&syntax, "g", 1)) {
- iColorType = CFX_Color::kGray;
fc[0] = FX_atof(syntax.GetWord());
- return;
+ return CFX_Color::kGray;
}
if (FindTagParamFromStart(&syntax, "rg", 3)) {
- iColorType = CFX_Color::kRGB;
fc[0] = FX_atof(syntax.GetWord());
fc[1] = FX_atof(syntax.GetWord());
fc[2] = FX_atof(syntax.GetWord());
- return;
+ return CFX_Color::kRGB;
}
if (FindTagParamFromStart(&syntax, "k", 4)) {
- iColorType = CFX_Color::kCMYK;
fc[0] = FX_atof(syntax.GetWord());
fc[1] = FX_atof(syntax.GetWord());
fc[2] = FX_atof(syntax.GetWord());
fc[3] = FX_atof(syntax.GetWord());
+ return CFX_Color::kCMYK;
}
+
+ return CFX_Color::kTransparent;
}
-void CPDF_DefaultAppearance::GetColor(FX_ARGB& color, int& iColorType) {
- color = 0;
+std::pair<CFX_Color::Type, FX_ARGB> CPDF_DefaultAppearance::GetColor() {
float values[4];
- GetColor(iColorType, values);
- if (iColorType == CFX_Color::kTransparent)
- return;
+ CFX_Color::Type type = GetColor(values);
+ if (type == CFX_Color::kTransparent)
+ return {type, 0};
- if (iColorType == CFX_Color::kGray) {
+ if (type == CFX_Color::kGray) {
int g = static_cast<int>(values[0] * 255 + 0.5f);
- color = ArgbEncode(255, g, g, g);
- return;
+ return {type, ArgbEncode(255, g, g, g)};
}
- if (iColorType == CFX_Color::kRGB) {
+ if (type == CFX_Color::kRGB) {
int r = static_cast<int>(values[0] * 255 + 0.5f);
int g = static_cast<int>(values[1] * 255 + 0.5f);
int b = static_cast<int>(values[2] * 255 + 0.5f);
- color = ArgbEncode(255, r, g, b);
- return;
+ return {type, ArgbEncode(255, r, g, b)};
}
- if (iColorType == CFX_Color::kCMYK) {
+ if (type == CFX_Color::kCMYK) {
float r = 1.0f - std::min(1.0f, values[0] + values[3]);
float g = 1.0f - std::min(1.0f, values[1] + values[3]);
float b = 1.0f - std::min(1.0f, values[2] + values[3]);
- color = ArgbEncode(255, static_cast<int>(r * 255 + 0.5f),
- static_cast<int>(g * 255 + 0.5f),
- static_cast<int>(b * 255 + 0.5f));
+ return {type, ArgbEncode(255, static_cast<int>(r * 255 + 0.5f),
+ static_cast<int>(g * 255 + 0.5f),
+ static_cast<int>(b * 255 + 0.5f))};
}
NOTREACHED();
+ return {CFX_Color::kTransparent, 0};
}
bool CPDF_DefaultAppearance::FindTagParamFromStartForTesting(
diff --git a/core/fpdfdoc/cpdf_defaultappearance.h b/core/fpdfdoc/cpdf_defaultappearance.h
index 79ad0bb526..79578930e1 100644
--- a/core/fpdfdoc/cpdf_defaultappearance.h
+++ b/core/fpdfdoc/cpdf_defaultappearance.h
@@ -7,11 +7,13 @@
#ifndef CORE_FPDFDOC_CPDF_DEFAULTAPPEARANCE_H_
#define CORE_FPDFDOC_CPDF_DEFAULTAPPEARANCE_H_
+#include <utility>
+
#include "core/fpdfapi/parser/cpdf_simple_parser.h"
-#include "core/fpdfdoc/cpdf_defaultappearance.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/fx_system.h"
+#include "core/fxge/cfx_color.h"
#include "core/fxge/fx_dib.h"
enum class BorderStyle { SOLID, DASH, BEVELED, INSET, UNDERLINE };
@@ -27,8 +29,8 @@ class CPDF_DefaultAppearance {
ByteString GetFont(float* fFontSize);
bool HasColor();
- void GetColor(int& iColorType, float fc[4]);
- void GetColor(FX_ARGB& color, int& iColorType);
+ CFX_Color::Type GetColor(float fc[4]);
+ std::pair<CFX_Color::Type, FX_ARGB> GetColor();
bool FindTagParamFromStartForTesting(CPDF_SimpleParser* parser,
const ByteStringView& token,
diff --git a/core/fpdfdoc/cpvt_generateap.h b/core/fpdfdoc/cpvt_generateap.h
index 6f56993575..52c26af020 100644
--- a/core/fpdfdoc/cpvt_generateap.h
+++ b/core/fpdfdoc/cpvt_generateap.h
@@ -9,6 +9,7 @@
#include <memory>
+#include "core/fpdfdoc/cpdf_annot.h"
#include "core/fpdfdoc/cpdf_defaultappearance.h"
#include "core/fpdfdoc/cpdf_variabletext.h"
#include "core/fxcrt/fx_coordinates.h"
diff --git a/core/fxge/cfx_color.cpp b/core/fxge/cfx_color.cpp
index 5175adc50a..8a2f42d920 100644
--- a/core/fxge/cfx_color.cpp
+++ b/core/fxge/cfx_color.cpp
@@ -87,10 +87,8 @@ CFX_Color CFX_Color::ParseColor(const ByteString& str) {
CPDF_DefaultAppearance appearance(str);
ASSERT(appearance.HasColor());
- int color_type;
float values[4];
- appearance.GetColor(color_type, values);
-
+ int color_type = appearance.GetColor(values);
if (color_type == CFX_Color::kTransparent)
return CFX_Color(CFX_Color::kTransparent);
if (color_type == CFX_Color::kGray)
diff --git a/core/fxge/cfx_color.h b/core/fxge/cfx_color.h
index 099e19b11e..aaa533cacb 100644
--- a/core/fxge/cfx_color.h
+++ b/core/fxge/cfx_color.h
@@ -7,7 +7,7 @@
#ifndef CORE_FXGE_CFX_COLOR_H_
#define CORE_FXGE_CFX_COLOR_H_
-#include "core/fpdfdoc/cpdf_formcontrol.h"
+#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fxge/fx_dib.h"
struct CFX_Color {
diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h
index 0eafe8c018..757dfdf17f 100644
--- a/core/fxge/cfx_renderdevice.h
+++ b/core/fxge/cfx_renderdevice.h
@@ -9,6 +9,7 @@
#include <memory>
+#include "core/fpdfdoc/cpdf_defaultappearance.h"
#include "core/fxcrt/unowned_ptr.h"
#include "core/fxge/cfx_color.h"
#include "core/fxge/fx_dib.h"
diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp
index 3a49f9c6a0..f7aae09933 100644
--- a/fpdfsdk/cpdfsdk_widget.cpp
+++ b/fpdfsdk/cpdfsdk_widget.cpp
@@ -435,8 +435,8 @@ bool CPDFSDK_Widget::GetTextColor(FX_COLORREF& color) const {
return false;
FX_ARGB argb;
- int iColorType = CFX_Color::kTransparent;
- da.GetColor(argb, iColorType);
+ int iColorType;
+ std::tie(iColorType, argb) = da.GetColor();
color = ArgbToColorRef(argb);
return iColorType != CFX_Color::kTransparent;
}
@@ -780,9 +780,8 @@ CFX_Color CPDFSDK_Widget::GetTextPWLColor() const {
CPDF_FormControl* pFormCtrl = GetFormControl();
CPDF_DefaultAppearance da = pFormCtrl->GetDefaultAppearance();
if (da.HasColor()) {
- int32_t iColorType;
float fc[4];
- da.GetColor(iColorType, fc);
+ int iColorType = da.GetColor(fc);
crText = CFX_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
}
diff --git a/fpdfsdk/cpdfsdk_widget.h b/fpdfsdk/cpdfsdk_widget.h
index 81d87376f9..e480fc921a 100644
--- a/fpdfsdk/cpdfsdk_widget.h
+++ b/fpdfsdk/cpdfsdk_widget.h
@@ -12,6 +12,7 @@
#include "core/fpdfdoc/cpdf_aaction.h"
#include "core/fpdfdoc/cpdf_action.h"
#include "core/fpdfdoc/cpdf_annot.h"
+#include "core/fpdfdoc/cpdf_formfield.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/unowned_ptr.h"
diff --git a/fpdfsdk/pwl/cpwl_appstream.cpp b/fpdfsdk/pwl/cpwl_appstream.cpp
index 38144d1735..0731398ae2 100644
--- a/fpdfsdk/pwl/cpwl_appstream.cpp
+++ b/fpdfsdk/pwl/cpwl_appstream.cpp
@@ -1181,7 +1181,7 @@ void CPWL_AppStream::SetAsPushButton() {
ByteString csNameTag;
CPDF_DefaultAppearance da = pControl->GetDefaultAppearance();
if (da.HasColor()) {
- da.GetColor(iColorType, fc);
+ iColorType = da.GetColor(fc);
crText = CFX_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
}
float fFontSize = 12.0f;
@@ -1355,7 +1355,7 @@ void CPWL_AppStream::SetAsCheckBox() {
CFX_FloatRect rcClient = rcWindow.GetDeflated(fBorderWidth, fBorderWidth);
CPDF_DefaultAppearance da = pControl->GetDefaultAppearance();
if (da.HasColor()) {
- da.GetColor(iColorType, fc);
+ iColorType = da.GetColor(fc);
crText = CFX_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
}
@@ -1471,7 +1471,7 @@ void CPWL_AppStream::SetAsRadioButton() {
CFX_FloatRect rcClient = rcWindow.GetDeflated(fBorderWidth, fBorderWidth);
CPDF_DefaultAppearance da = pControl->GetDefaultAppearance();
if (da.HasColor()) {
- da.GetColor(iColorType, fc);
+ iColorType = da.GetColor(fc);
crText = CFX_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
}
diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp
index 7b4c064a9e..acc0fe3188 100644
--- a/fxjs/cjs_field.cpp
+++ b/fxjs/cjs_field.cpp
@@ -1888,7 +1888,7 @@ CJS_Return CJS_Field::get_text_color(CJS_Runtime* pRuntime) {
int iColorType;
FX_ARGB color;
CPDF_DefaultAppearance FieldAppearance = pFormControl->GetDefaultAppearance();
- FieldAppearance.GetColor(color, iColorType);
+ std::tie(iColorType, color) = FieldAppearance.GetColor();
int32_t a;
int32_t r;