Fix regression with CheckStyleFromCaption().
CheckStyleFromCaption() should default to different styles for
check boxes and radio buttons. This regressed in
https://pdfium-review.googlesource.com/66330 which always used the check
style.
Change-Id: I186815e6fb230bc4cf687048d9df20ac0ee37be9
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/66391
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/cpdfsdk_appstream.cpp b/fpdfsdk/cpdfsdk_appstream.cpp
index 89b8d19..a0fc3b0 100644
--- a/fpdfsdk/cpdfsdk_appstream.cpp
+++ b/fpdfsdk/cpdfsdk_appstream.cpp
@@ -1115,12 +1115,15 @@
pImageDict->SetNewFor<CPDF_String>("Name", name, false);
}
-CheckStyle CheckStyleFromCaption(const WideString& wsCaption) {
- if (wsCaption.IsEmpty())
- return CheckStyle::kCheck;
+CheckStyle CheckStyleFromCaption(const WideString& caption,
+ CheckStyle default_style) {
+ if (caption.IsEmpty())
+ return default_style;
// Character values are ZapfDingbats encodings of named glyphs.
- switch (wsCaption[0]) {
+ switch (caption[0]) {
+ case L'4':
+ return CheckStyle::kCheck;
case L'l':
return CheckStyle::kCircle;
case L'8':
@@ -1131,9 +1134,8 @@
return CheckStyle::kSquare;
case L'H':
return CheckStyle::kStar;
- case L'4':
default:
- return CheckStyle::kCheck;
+ return default_style;
}
}
@@ -1379,7 +1381,9 @@
crText = CFX_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
}
- CheckStyle nStyle = CheckStyleFromCaption(pControl->GetNormalCaption());
+ CheckStyle nStyle =
+ CheckStyleFromCaption(pControl->GetNormalCaption(),
+ /*default_style=*/CheckStyle::kCheck);
ByteString csAP_N_ON =
GetRectFillAppStream(rcWindow, crBackground) +
GetBorderAppStreamInternal(rcWindow, fBorderWidth, crBorder, crLeftTop,
@@ -1472,7 +1476,9 @@
crText = CFX_Color(iColorType, fc[0], fc[1], fc[2], fc[3]);
}
- CheckStyle nStyle = CheckStyleFromCaption(pControl->GetNormalCaption());
+ CheckStyle nStyle =
+ CheckStyleFromCaption(pControl->GetNormalCaption(),
+ /*default_style=*/CheckStyle::kCircle);
ByteString csAP_N_ON;
CFX_FloatRect rcCenter = rcWindow.GetCenterSquare().GetDeflated(1.0f, 1.0f);