From d3ae179dab3f63625e5dd3ddf0aa33176f8ee65c Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 16 Jan 2018 15:15:05 +0000 Subject: Cleanup CXFA_Fill This CL cleans up the CXFA_Fill internal getters to handle nullptr returns correctly and moves some of the logic to the specific XFA classes. Change-Id: Icac487105a026a25cc9981d00fbc152e459ad0b8 Reviewed-on: https://pdfium-review.googlesource.com/22770 Reviewed-by: Ryan Harrison Commit-Queue: dsinclair --- xfa/fxfa/parser/cxfa_color.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'xfa/fxfa/parser/cxfa_color.cpp') diff --git a/xfa/fxfa/parser/cxfa_color.cpp b/xfa/fxfa/parser/cxfa_color.cpp index a072d0302b..95c0ad345b 100644 --- a/xfa/fxfa/parser/cxfa_color.cpp +++ b/xfa/fxfa/parser/cxfa_color.cpp @@ -37,3 +37,23 @@ CXFA_Color::CXFA_Color(CXFA_Document* doc, XFA_PacketType packet) pdfium::MakeUnique(this)) {} CXFA_Color::~CXFA_Color() {} + +FX_ARGB CXFA_Color::GetValue() { + Optional val = JSObject()->TryCData(XFA_Attribute::Value, false); + return val ? StringToFXARGB(val->AsStringView()) : 0xFF000000; +} + +FX_ARGB CXFA_Color::GetValueOrDefault(FX_ARGB defaultValue) { + Optional val = JSObject()->TryCData(XFA_Attribute::Value, false); + return val ? StringToFXARGB(val->AsStringView()) : defaultValue; +} + +void CXFA_Color::SetValue(FX_ARGB color) { + int a; + int r; + int g; + int b; + std::tie(a, r, g, b) = ArgbDecode(color); + JSObject()->SetCData(XFA_Attribute::Value, + WideString::Format(L"%d,%d,%d", r, g, b), false, false); +} -- cgit v1.2.3