summaryrefslogtreecommitdiff
path: root/fpdfsdk/cpdfsdk_widget.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-10-10 18:39:14 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-10 18:39:14 +0000
commitb353f8c32b2d17cbea5ace6eb5f7edb8663e37be (patch)
treead10260cd60754e1b9aa521db6a524b48462b5e9 /fpdfsdk/cpdfsdk_widget.cpp
parent461acb276e1c38c9ebb3546c5b3254fa5cf9c585 (diff)
downloadpdfium-b353f8c32b2d17cbea5ace6eb5f7edb8663e37be.tar.xz
Use pdfium::Optional in CPDFSDK_Widget.
Also make some methods const. Change-Id: Ie2d0f7e691ad9448b4e77227ce3c0b2b065e0da0 Reviewed-on: https://pdfium-review.googlesource.com/c/43602 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/cpdfsdk_widget.cpp')
-rw-r--r--fpdfsdk/cpdfsdk_widget.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp
index 70ad592f6f..c2a4754edc 100644
--- a/fpdfsdk/cpdfsdk_widget.cpp
+++ b/fpdfsdk/cpdfsdk_widget.cpp
@@ -72,7 +72,7 @@ CXFA_FFWidget* CPDFSDK_Widget::GetMixXFAWidget() const {
return nullptr;
}
-CXFA_FFWidget* CPDFSDK_Widget::GetGroupMixXFAWidget() {
+CXFA_FFWidget* CPDFSDK_Widget::GetGroupMixXFAWidget() const {
CPDFXFA_Context* pContext = m_pPageView->GetFormFillEnv()->GetXFAContext();
if (pContext->GetFormType() != FormType::kXFAForeground)
return nullptr;
@@ -173,7 +173,7 @@ static XFA_EVENTTYPE GetXFAEventType(CPDF_AAction::AActionType eAAT,
return eEventType;
}
-bool CPDFSDK_Widget::HasXFAAAction(PDFSDK_XFAAActionType eXFAAAT) {
+bool CPDFSDK_Widget::HasXFAAAction(PDFSDK_XFAAActionType eXFAAAT) const {
CXFA_FFWidget* hWidget = GetMixXFAWidget();
if (!hWidget)
return false;
@@ -398,31 +398,37 @@ WideString CPDFSDK_Widget::GetName() const {
}
#endif // PDF_ENABLE_XFA
-bool CPDFSDK_Widget::GetFillColor(FX_COLORREF& color) const {
+Optional<FX_COLORREF> CPDFSDK_Widget::GetFillColor() const {
CPDF_FormControl* pFormCtrl = GetFormControl();
int iColorType = 0;
- color = ArgbToColorRef(pFormCtrl->GetBackgroundColor(iColorType));
- return iColorType != CFX_Color::kTransparent;
+ FX_COLORREF color = ArgbToColorRef(pFormCtrl->GetBackgroundColor(iColorType));
+ if (iColorType == CFX_Color::kTransparent)
+ return {};
+ return color;
}
-bool CPDFSDK_Widget::GetBorderColor(FX_COLORREF& color) const {
+Optional<FX_COLORREF> CPDFSDK_Widget::GetBorderColor() const {
CPDF_FormControl* pFormCtrl = GetFormControl();
int iColorType = 0;
- color = ArgbToColorRef(pFormCtrl->GetBorderColor(iColorType));
- return iColorType != CFX_Color::kTransparent;
+ FX_COLORREF color = ArgbToColorRef(pFormCtrl->GetBorderColor(iColorType));
+ if (iColorType == CFX_Color::kTransparent)
+ return {};
+ return color;
}
-bool CPDFSDK_Widget::GetTextColor(FX_COLORREF& color) const {
+Optional<FX_COLORREF> CPDFSDK_Widget::GetTextColor() const {
CPDF_FormControl* pFormCtrl = GetFormControl();
CPDF_DefaultAppearance da = pFormCtrl->GetDefaultAppearance();
FX_ARGB argb;
Optional<CFX_Color::Type> iColorType;
std::tie(iColorType, argb) = da.GetColor();
- if (!iColorType)
- return false;
+ if (!iColorType.has_value())
+ return {};
- color = ArgbToColorRef(argb);
- return *iColorType != CFX_Color::kTransparent;
+ FX_COLORREF color = ArgbToColorRef(argb);
+ if (iColorType.value() == CFX_Color::kTransparent)
+ return {};
+ return color;
}
float CPDFSDK_Widget::GetFontSize() const {