[code health] Prefer Optional<>::has_value() to implicit operator bool()
Per offline discussion, this improves readability when the underlying
type T is convertible to bool itself. Do so consistently for all types,
but stop short of removing operator bool() from PDFium's copy of
third_party/base/optional.h since several gtest macros depend on its
presence.
-- Remove some `auto` and/or spell out full return type.
Change-Id: Id9a9788e2357d99f0ae7ca53b3b66808c70ac754
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/81350
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_docpagedata.cpp b/core/fpdfapi/page/cpdf_docpagedata.cpp
index 7b1b032..47b5af2 100644
--- a/core/fpdfapi/page/cpdf_docpagedata.cpp
+++ b/core/fpdfapi/page/cpdf_docpagedata.cpp
@@ -459,7 +459,9 @@
const ByteString& fontName,
const CPDF_FontEncoding* pEncoding) {
ByteString mutable_name(fontName);
- if (!CFX_FontMapper::GetStandardFontName(&mutable_name))
+ Optional<CFX_FontMapper::StandardFont> font_id =
+ CFX_FontMapper::GetStandardFontName(&mutable_name);
+ if (!font_id.has_value())
return nullptr;
return GetStandardFont(mutable_name, pEncoding);
}
diff --git a/core/fpdfapi/page/cpdf_stitchfunc.cpp b/core/fpdfapi/page/cpdf_stitchfunc.cpp
index 10f1eb1..3e903b7 100644
--- a/core/fpdfapi/page/cpdf_stitchfunc.cpp
+++ b/core/fpdfapi/page/cpdf_stitchfunc.cpp
@@ -84,7 +84,7 @@
if (nFuncOutputs == 0)
return false;
- if (nOutputs) {
+ if (nOutputs.has_value()) {
if (nFuncOutputs != *nOutputs)
return false;
} else {
diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp
index d31639a..a3ea904 100644
--- a/core/fpdfapi/parser/cpdf_data_avail.cpp
+++ b/core/fpdfapi/parser/cpdf_data_avail.cpp
@@ -494,7 +494,7 @@
if (GetValidator()->has_read_problems())
return kDataNotAvailable;
- if (!header_offset)
+ if (!header_offset.has_value())
return kDataError;
m_parser.m_pSyntax =
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp
index f5491dd..03c9bcd 100644
--- a/core/fpdfapi/parser/cpdf_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_parser.cpp
@@ -119,7 +119,7 @@
bool CPDF_Parser::InitSyntaxParser(
const RetainPtr<CPDF_ReadValidator>& validator) {
const Optional<FX_FILESIZE> header_offset = GetHeaderOffset(validator);
- if (!header_offset)
+ if (!header_offset.has_value())
return false;
if (validator->GetSize() < *header_offset + kPDFHeaderSize)
return false;
diff --git a/core/fpdfdoc/cpdf_formcontrol.cpp b/core/fpdfdoc/cpdf_formcontrol.cpp
index 50dcc17..6e25393 100644
--- a/core/fpdfdoc/cpdf_formcontrol.cpp
+++ b/core/fpdfdoc/cpdf_formcontrol.cpp
@@ -199,7 +199,7 @@
float fFontSize;
CPDF_DefaultAppearance cDA = GetDefaultAppearance();
Optional<ByteString> csFontNameTag = cDA.GetFont(&fFontSize);
- if (!csFontNameTag || csFontNameTag->IsEmpty())
+ if (!csFontNameTag.has_value() || csFontNameTag->IsEmpty())
return nullptr;
CPDF_Object* pObj = CPDF_FormField::GetFieldAttr(m_pWidgetDict.Get(), "DR");
diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp
index 0391657..d1fc368 100644
--- a/core/fpdfdoc/cpdf_formfield.cpp
+++ b/core/fpdfdoc/cpdf_formfield.cpp
@@ -857,7 +857,7 @@
CPDF_DefaultAppearance appearance(DA);
Optional<ByteString> font_name = appearance.GetFont(&m_FontSize);
- if (!font_name)
+ if (!font_name.has_value())
return;
CPDF_Dictionary* pFontDict = pFont->GetDictFor(*font_name);
diff --git a/core/fpdfdoc/cpdf_generateap.cpp b/core/fpdfdoc/cpdf_generateap.cpp
index f98bd5c..2c3dd64 100644
--- a/core/fpdfdoc/cpdf_generateap.cpp
+++ b/core/fpdfdoc/cpdf_generateap.cpp
@@ -938,7 +938,7 @@
float fFontSize = 0;
Optional<ByteString> font = appearance.GetFont(&fFontSize);
- if (!font)
+ if (!font.has_value())
return;
ByteString font_name = *font;
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index f4bf8e2..ef5a46f 100644
--- a/core/fpdftext/cpdf_textpage.cpp
+++ b/core/fpdftext/cpdf_textpage.cpp
@@ -618,7 +618,7 @@
void CPDF_TextPage::AppendGeneratedCharacter(wchar_t unicode,
const CFX_Matrix& formMatrix) {
Optional<CharInfo> pGenerateChar = GenerateCharInfo(unicode);
- if (!pGenerateChar)
+ if (!pGenerateChar.has_value())
return;
m_TextBuf.AppendChar(unicode);
@@ -982,7 +982,7 @@
break;
case GenerateCharacter::kSpace: {
Optional<CharInfo> pGenerateChar = GenerateCharInfo(L' ');
- if (pGenerateChar) {
+ if (pGenerateChar.has_value()) {
if (!form_matrix.IsIdentity())
pGenerateChar->m_Matrix = form_matrix;
m_TempTextBuf.AppendChar(L' ');
diff --git a/core/fpdftext/cpdf_textpagefind.cpp b/core/fpdftext/cpdf_textpagefind.cpp
index 2bc46f1..b874ddd 100644
--- a/core/fpdftext/cpdf_textpagefind.cpp
+++ b/core/fpdftext/cpdf_textpagefind.cpp
@@ -129,7 +129,7 @@
int index = 0;
while (1) {
Optional<WideString> word = ExtractSubString(findwhat.c_str(), index);
- if (!word)
+ if (!word.has_value())
break;
if (word->IsEmpty()) {
diff --git a/core/fxcodec/jbig2/JBig2_TrdProc.cpp b/core/fxcodec/jbig2/JBig2_TrdProc.cpp
index a009000..328bc88 100644
--- a/core/fxcodec/jbig2/JBig2_TrdProc.cpp
+++ b/core/fxcodec/jbig2/JBig2_TrdProc.cpp
@@ -162,14 +162,14 @@
Optional<uint32_t> WOI = CheckTRDDimension(IBOI->width(), RDWI);
Optional<uint32_t> HOI = CheckTRDDimension(IBOI->height(), RDHI);
- if (!WOI || !HOI)
+ if (!WOI.has_value() || !HOI.has_value())
return nullptr;
Optional<int32_t> GRREFERENCEDX =
CheckTRDReferenceDimension(RDWI, 2, RDXI);
Optional<int32_t> GRREFERENCEDY =
CheckTRDReferenceDimension(RDHI, 2, RDYI);
- if (!GRREFERENCEDX || !GRREFERENCEDY)
+ if (!GRREFERENCEDX.has_value() || !GRREFERENCEDY.has_value())
return nullptr;
auto pGRRD = std::make_unique<CJBig2_GRRDProc>();
@@ -342,14 +342,14 @@
Optional<uint32_t> WOI = CheckTRDDimension(IBOI->width(), RDWI);
Optional<uint32_t> HOI = CheckTRDDimension(IBOI->height(), RDHI);
- if (!WOI || !HOI)
+ if (!WOI.has_value() || !HOI.has_value())
return nullptr;
Optional<int32_t> GRREFERENCEDX =
CheckTRDReferenceDimension(RDWI, 1, RDXI);
Optional<int32_t> GRREFERENCEDY =
CheckTRDReferenceDimension(RDHI, 1, RDYI);
- if (!GRREFERENCEDX || !GRREFERENCEDY)
+ if (!GRREFERENCEDX.has_value() || !GRREFERENCEDY.has_value())
return nullptr;
auto pGRRD = std::make_unique<CJBig2_GRRDProc>();
diff --git a/core/fxcrt/widestring.cpp b/core/fxcrt/widestring.cpp
index 13939da..4cb8423 100644
--- a/core/fxcrt/widestring.cpp
+++ b/core/fxcrt/widestring.cpp
@@ -308,7 +308,7 @@
TryVSWPrintf(static_cast<size_t>(maxLen), format, argListCopy);
va_end(argListCopy);
- if (ret)
+ if (ret.has_value())
return *ret;
maxLen *= 2;
}
diff --git a/fpdfsdk/cpdfsdk_appstream.cpp b/fpdfsdk/cpdfsdk_appstream.cpp
index 187029c..e8c8b48 100644
--- a/fpdfsdk/cpdfsdk_appstream.cpp
+++ b/fpdfsdk/cpdfsdk_appstream.cpp
@@ -1207,7 +1207,7 @@
float fFontSize;
ByteString csNameTag;
Optional<ByteString> font = da.GetFont(&fFontSize);
- if (font)
+ if (font.has_value())
csNameTag = *font;
else
fFontSize = 12.0f;
diff --git a/fpdfsdk/cpdfsdk_interactiveform.cpp b/fpdfsdk/cpdfsdk_interactiveform.cpp
index 289520d..14f9c71 100644
--- a/fpdfsdk/cpdfsdk_interactiveform.cpp
+++ b/fpdfsdk/cpdfsdk_interactiveform.cpp
@@ -280,7 +280,7 @@
pContext->OnField_Calculate(pFormField, pField, &sValue, &bRC);
Optional<IJS_Runtime::JS_Error> err = pContext->RunScript(csJS);
- if (!err && bRC && sValue != sOldValue)
+ if (!err.has_value() && bRC && sValue != sOldValue)
pField->SetValue(sValue, NotificationOption::kNotify);
}
}
@@ -308,7 +308,7 @@
IJS_Runtime::ScopedEventContext pContext(pRuntime);
pContext->OnField_Format(pFormField, &sValue);
Optional<IJS_Runtime::JS_Error> err = pContext->RunScript(script);
- if (!err)
+ if (!err.has_value())
return sValue;
}
}
diff --git a/fpdfsdk/fpdf_formfill.cpp b/fpdfsdk/fpdf_formfill.cpp
index 04b6606..322c78b 100644
--- a/fpdfsdk/fpdf_formfill.cpp
+++ b/fpdfsdk/fpdf_formfill.cpp
@@ -697,7 +697,7 @@
Optional<FormFieldType> cast_input =
CPDF_FormField::IntToFormFieldType(fieldType);
- if (!cast_input)
+ if (!cast_input.has_value())
return;
if (cast_input.value() == FormFieldType::kUnknown)
diff --git a/fpdfsdk/fpdf_view.cpp b/fpdfsdk/fpdf_view.cpp
index 5f8bf5c..fb35ad8 100644
--- a/fpdfsdk/fpdf_view.cpp
+++ b/fpdfsdk/fpdf_view.cpp
@@ -752,7 +752,7 @@
const FX_RECT rect(start_x, start_y, start_x + size_x, start_y + size_y);
Optional<CFX_PointF> pos =
pPage->DeviceToPage(rect, rotate, CFX_PointF(device_x, device_y));
- if (!pos)
+ if (!pos.has_value())
return false;
*page_x = pos->x;
@@ -777,7 +777,7 @@
const FX_RECT rect(start_x, start_y, start_x + size_x, start_y + size_y);
CFX_PointF page_point(static_cast<float>(page_x), static_cast<float>(page_y));
Optional<CFX_PointF> pos = pPage->PageToDevice(rect, rotate, page_point);
- if (!pos)
+ if (!pos.has_value())
return false;
*device_x = FXSYS_roundf(pos->x);
@@ -1009,7 +1009,7 @@
CPDF_ViewerPreferences viewRef(pDoc);
Optional<ByteString> bsVal = viewRef.GenericName(key);
- if (!bsVal)
+ if (!bsVal.has_value())
return 0;
return NulTerminateMaybeCopyAndReturnLength(*bsVal, buffer, length);
diff --git a/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp b/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp
index ed51f81..025e8d8 100644
--- a/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp
+++ b/fxbarcode/datamatrix/BC_ASCIIEncoder.cpp
@@ -69,7 +69,7 @@
if (n >= 2) {
Optional<wchar_t> code = EncodeASCIIDigits(
context->m_msg[context->m_pos], context->m_msg[context->m_pos + 1]);
- if (!code)
+ if (!code.has_value())
return false;
context->writeCodeword(*code);
diff --git a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
index 5d7d613..ef12f71 100644
--- a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
+++ b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
@@ -455,7 +455,7 @@
qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth());
Optional<int32_t> maskPattern = ChooseMaskPattern(
&finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get());
- if (!maskPattern)
+ if (!maskPattern.has_value())
return false;
qrCode->SetMaskPattern(*maskPattern);
diff --git a/fxjs/xfa/cfxjse_engine.cpp b/fxjs/xfa/cfxjse_engine.cpp
index 7fdf91e..f437915 100644
--- a/fxjs/xfa/cfxjse_engine.cpp
+++ b/fxjs/xfa/cfxjse_engine.cpp
@@ -489,9 +489,11 @@
if (pObject->JSObject()->HasMethod(wsPropName))
return FXJSE_ClassPropType_Method;
- if (bQueryIn &&
- !XFA_GetScriptAttributeByName(eType, wsPropName.AsStringView())) {
- return FXJSE_ClassPropType_None;
+ if (bQueryIn) {
+ Optional<XFA_SCRIPTATTRIBUTEINFO> maybe_info =
+ XFA_GetScriptAttributeByName(eType, wsPropName.AsStringView());
+ if (!maybe_info.has_value())
+ return FXJSE_ClassPropType_None;
}
return FXJSE_ClassPropType_Property;
}
@@ -569,7 +571,7 @@
Optional<WideString> wsScript =
pTextNode->JSObject()->TryCData(XFA_Attribute::Value, true);
- if (!wsScript)
+ if (!wsScript.has_value())
return false;
ByteString btScript = wsScript->ToUTF8();
diff --git a/fxjs/xfa/cfxjse_formcalc_context.cpp b/fxjs/xfa/cfxjse_formcalc_context.cpp
index 4c21178..930b1aa 100644
--- a/fxjs/xfa/cfxjse_formcalc_context.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context.cpp
@@ -1597,7 +1597,7 @@
if (CXFA_Node* pXFANode = pNode->AsNode()) {
Optional<WideString> ret =
pXFANode->JSObject()->TryAttribute(XFA_Attribute::Name, false);
- if (ret)
+ if (ret.has_value())
wsName = *ret;
}
if (wsName.IsEmpty())
diff --git a/fxjs/xfa/cjx_field.cpp b/fxjs/xfa/cjx_field.cpp
index d2e223d..c0e813e 100644
--- a/fxjs/xfa/cjx_field.cpp
+++ b/fxjs/xfa/cjx_field.cpp
@@ -111,7 +111,7 @@
return CJS_Result::Success(runtime->NewNull());
Optional<WideString> value = node->GetChoiceListItem(iIndex, true);
- if (!value)
+ if (!value.has_value())
return CJS_Result::Success(runtime->NewNull());
return CJS_Result::Success(
@@ -177,7 +177,7 @@
return CJS_Result::Success(runtime->NewNull());
Optional<WideString> value = node->GetChoiceListItem(iIndex, false);
- if (!value)
+ if (!value.has_value())
return CJS_Result::Success(runtime->NewNull());
return CJS_Result::Success(
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index 3c5aa1b..7f1a6eb 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -209,7 +209,8 @@
case XFA_AttributeType::Enum: {
Optional<XFA_AttributeValue> item =
XFA_GetAttributeValueByName(wsValue.AsStringView());
- SetEnum(eAttr, item ? *item : *(GetXFANode()->GetDefaultEnum(eAttr)),
+ SetEnum(eAttr,
+ item.has_value() ? *item : *(GetXFANode()->GetDefaultEnum(eAttr)),
bNotify);
break;
}
@@ -263,7 +264,7 @@
switch (GetXFANode()->GetAttributeType(eAttr)) {
case XFA_AttributeType::Enum: {
Optional<XFA_AttributeValue> value = TryEnum(eAttr, bUseDefault);
- if (!value)
+ if (!value.has_value())
return {};
return WideString::FromASCII(XFA_AttributeValueToName(*value));
}
@@ -272,19 +273,19 @@
case XFA_AttributeType::Boolean: {
Optional<bool> value = TryBoolean(eAttr, bUseDefault);
- if (!value)
+ if (!value.has_value())
return {};
return WideString(*value ? L"1" : L"0");
}
case XFA_AttributeType::Integer: {
Optional<int32_t> iValue = TryInteger(eAttr, bUseDefault);
- if (!iValue)
+ if (!iValue.has_value())
return {};
return WideString::Format(L"%d", *iValue);
}
case XFA_AttributeType::Measure: {
Optional<CXFA_Measurement> value = TryMeasure(eAttr, bUseDefault);
- if (!value)
+ if (!value.has_value())
return {};
return value->ToString();
@@ -397,7 +398,7 @@
Optional<float> CJX_Object::TryMeasureAsFloat(XFA_Attribute attr) const {
Optional<CXFA_Measurement> measure = TryMeasure(attr, false);
- if (!measure)
+ if (!measure.has_value())
return pdfium::nullopt;
return measure->ToUnit(XFA_Unit::Pt);
}
@@ -613,7 +614,7 @@
if (GetXFANode()->GetElementType() == XFA_Element::ExData) {
Optional<WideString> ret =
TryAttribute(XFA_Attribute::ContentType, false);
- if (ret)
+ if (ret.has_value())
wsContentType = *ret;
if (wsContentType.EqualsASCII("text/html")) {
wsContentType.clear();
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index 7967758..8f31b1d 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -532,8 +532,8 @@
return false;
}
std::string path = value;
- auto expanded_path = ExpandDirectoryPath(path);
- if (!expanded_path) {
+ Optional<std::string> expanded_path = ExpandDirectoryPath(path);
+ if (!expanded_path.has_value()) {
fprintf(stderr, "Failed to expand --font-dir, %s\n", path.c_str());
return false;
}
@@ -581,8 +581,8 @@
return false;
}
std::string path = value;
- auto expanded_path = ExpandDirectoryPath(path);
- if (!expanded_path) {
+ Optional<std::string> expanded_path = ExpandDirectoryPath(path);
+ if (!expanded_path.has_value()) {
fprintf(stderr, "Failed to expand --bin-dir, %s\n", path.c_str());
return false;
}
diff --git a/xfa/fxfa/cxfa_ffbarcode.cpp b/xfa/fxfa/cxfa_ffbarcode.cpp
index 9a73b2d..e564133 100644
--- a/xfa/fxfa/cxfa_ffbarcode.cpp
+++ b/xfa/fxfa/cxfa_ffbarcode.cpp
@@ -195,56 +195,56 @@
pBarCodeWidget->SetType(info->eBCType);
Optional<WideString> encoding_string = barcode_->GetCharEncoding();
- if (encoding_string) {
+ if (encoding_string.has_value()) {
Optional<BC_CHAR_ENCODING> encoding =
CharEncodingFromString(*encoding_string);
- if (encoding)
+ if (encoding.has_value())
pBarCodeWidget->SetCharEncoding(*encoding);
}
Optional<bool> calcChecksum = barcode_->GetChecksum();
- if (calcChecksum)
+ if (calcChecksum.has_value())
pBarCodeWidget->SetCalChecksum(*calcChecksum);
Optional<int32_t> dataLen = barcode_->GetDataLength();
- if (dataLen)
+ if (dataLen.has_value())
pBarCodeWidget->SetDataLength(*dataLen);
Optional<char> startChar = barcode_->GetStartChar();
- if (startChar)
+ if (startChar.has_value())
pBarCodeWidget->SetStartChar(*startChar);
Optional<char> endChar = barcode_->GetEndChar();
- if (endChar)
+ if (endChar.has_value())
pBarCodeWidget->SetEndChar(*endChar);
Optional<int32_t> ecLevel = barcode_->GetECLevel();
- if (ecLevel)
+ if (ecLevel.has_value())
pBarCodeWidget->SetErrorCorrectionLevel(*ecLevel);
Optional<int32_t> width = barcode_->GetModuleWidth();
- if (width)
+ if (width.has_value())
pBarCodeWidget->SetModuleWidth(*width);
Optional<int32_t> height = barcode_->GetModuleHeight();
- if (height)
+ if (height.has_value())
pBarCodeWidget->SetModuleHeight(*height);
Optional<bool> printCheck = barcode_->GetPrintChecksum();
- if (printCheck)
+ if (printCheck.has_value())
pBarCodeWidget->SetPrintChecksum(*printCheck);
Optional<XFA_AttributeValue> text_attr = barcode_->GetTextLocation();
- if (text_attr) {
+ if (text_attr.has_value()) {
Optional<BC_TEXT_LOC> textLoc = TextLocFromAttribute(*text_attr);
- if (textLoc)
+ if (textLoc.has_value())
pBarCodeWidget->SetTextLocation(*textLoc);
}
// Truncated is currently not a supported flag.
Optional<int8_t> ratio = barcode_->GetWideNarrowRatio();
- if (ratio)
+ if (ratio.has_value())
pBarCodeWidget->SetWideNarrowRatio(*ratio);
if (info->eName == BarcodeType::code3Of9 ||
diff --git a/xfa/fxfa/cxfa_ffdatetimeedit.cpp b/xfa/fxfa/cxfa_ffdatetimeedit.cpp
index a8b5f7d..0cd34ee 100644
--- a/xfa/fxfa/cxfa_ffdatetimeedit.cpp
+++ b/xfa/fxfa/cxfa_ffdatetimeedit.cpp
@@ -93,7 +93,7 @@
uint32_t dwEditStyles = 0;
Optional<int32_t> numCells = m_pNode->GetNumberOfCells();
- if (numCells && *numCells > 0) {
+ if (numCells.has_value() && *numCells > 0) {
dwEditStyles |= FWL_STYLEEXT_EDT_CombText;
pPicker->SetEditLimit(*numCells);
}
diff --git a/xfa/fxfa/cxfa_ffnumericedit.cpp b/xfa/fxfa/cxfa_ffnumericedit.cpp
index e464d71..2067ffa 100644
--- a/xfa/fxfa/cxfa_ffnumericedit.cpp
+++ b/xfa/fxfa/cxfa_ffnumericedit.cpp
@@ -56,7 +56,7 @@
dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll;
Optional<int32_t> numCells = m_pNode->GetNumberOfCells();
- if (numCells && *numCells > 0) {
+ if (numCells.has_value() && *numCells > 0) {
dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText;
pWidget->SetLimit(*numCells);
}
diff --git a/xfa/fxfa/cxfa_ffpageview.cpp b/xfa/fxfa/cxfa_ffpageview.cpp
index ab92161..6d357c6 100644
--- a/xfa/fxfa/cxfa_ffpageview.cpp
+++ b/xfa/fxfa/cxfa_ffpageview.cpp
@@ -431,7 +431,7 @@
if (pTraverse) {
Optional<WideString> traverseWidgetName =
pTraverse->JSObject()->TryAttribute(XFA_Attribute::Ref, true);
- if (traverseWidgetName)
+ if (traverseWidgetName.has_value())
return FindWidgetByName(*traverseWidgetName, pWidget);
}
}
diff --git a/xfa/fxfa/cxfa_fftextedit.cpp b/xfa/fxfa/cxfa_fftextedit.cpp
index 92e139c..5c0b665 100644
--- a/xfa/fxfa/cxfa_fftextedit.cpp
+++ b/xfa/fxfa/cxfa_fftextedit.cpp
@@ -103,7 +103,7 @@
iMaxChars = 0;
Optional<int32_t> numCells = m_pNode->GetNumberOfCells();
- if (!numCells) {
+ if (!numCells.has_value()) {
pWidget->SetLimit(iMaxChars);
} else if (*numCells == 0) {
dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText;
@@ -273,7 +273,7 @@
bool bUpdate = false;
if (m_pNode->GetFFWidgetType() == XFA_FFWidgetType::kTextEdit &&
- !m_pNode->GetNumberOfCells()) {
+ !m_pNode->GetNumberOfCells().has_value()) {
XFA_Element elementType;
int32_t iMaxChars;
std::tie(elementType, iMaxChars) = m_pNode->GetMaxChars();
diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp
index 2872d9a..c760d47 100644
--- a/xfa/fxfa/cxfa_textlayout.cpp
+++ b/xfa/fxfa/cxfa_textlayout.cpp
@@ -812,7 +812,7 @@
} else {
Optional<WideString> obj =
m_pTextParser->GetEmbeddedObj(m_pTextProvider, pXMLNode);
- if (obj)
+ if (obj.has_value())
wsText = *obj;
}
}
diff --git a/xfa/fxfa/cxfa_textprovider.cpp b/xfa/fxfa/cxfa_textprovider.cpp
index 176d70c..824d7d4 100644
--- a/xfa/fxfa/cxfa_textprovider.cpp
+++ b/xfa/fxfa/cxfa_textprovider.cpp
@@ -143,7 +143,7 @@
bool CXFA_TextProvider::IsCheckButtonAndAutoWidth() const {
if (m_pNode->GetFFWidgetType() != XFA_FFWidgetType::kCheckButton)
return false;
- return !m_pNode->TryWidth();
+ return !m_pNode->TryWidth().has_value();
}
Optional<WideString> CXFA_TextProvider::GetEmbeddedObj(
diff --git a/xfa/fxfa/layout/cxfa_contentlayoutprocessor.cpp b/xfa/fxfa/layout/cxfa_contentlayoutprocessor.cpp
index e3726aa..8a4f613 100644
--- a/xfa/fxfa/layout/cxfa_contentlayoutprocessor.cpp
+++ b/xfa/fxfa/layout/cxfa_contentlayoutprocessor.cpp
@@ -95,14 +95,14 @@
if (eType == XFA_Element::Subform || eType == XFA_Element::ExclGroup) {
Optional<CXFA_Measurement> wValue =
pFormNode->JSObject()->TryMeasure(XFA_Attribute::W, false);
- if (wValue && wValue->GetValue() > kXFALayoutPrecision) {
+ if (wValue.has_value() && wValue->GetValue() > kXFALayoutPrecision) {
containerSize.width = wValue->ToUnit(XFA_Unit::Pt);
*bContainerWidthAutoSize = false;
}
Optional<CXFA_Measurement> hValue =
pFormNode->JSObject()->TryMeasure(XFA_Attribute::H, false);
- if (hValue && hValue->GetValue() > kXFALayoutPrecision) {
+ if (hValue.has_value() && hValue->GetValue() > kXFALayoutPrecision) {
containerSize.height = hValue->ToUnit(XFA_Unit::Pt);
*bContainerHeightAutoSize = false;
}
@@ -111,14 +111,14 @@
if (*bContainerWidthAutoSize && eType == XFA_Element::Subform) {
Optional<CXFA_Measurement> maxW =
pFormNode->JSObject()->TryMeasure(XFA_Attribute::MaxW, false);
- if (maxW && maxW->GetValue() > kXFALayoutPrecision) {
+ if (maxW.has_value() && maxW->GetValue() > kXFALayoutPrecision) {
containerSize.width = maxW->ToUnit(XFA_Unit::Pt);
*bContainerWidthAutoSize = false;
}
Optional<CXFA_Measurement> maxH =
pFormNode->JSObject()->TryMeasure(XFA_Attribute::MaxH, false);
- if (maxH && maxH->GetValue() > kXFALayoutPrecision) {
+ if (maxH.has_value() && maxH->GetValue() > kXFALayoutPrecision) {
containerSize.height = maxH->ToUnit(XFA_Unit::Pt);
*bContainerHeightAutoSize = false;
}
@@ -141,12 +141,12 @@
if (pMarginNode) {
Optional<CXFA_Measurement> leftInset =
pMarginNode->JSObject()->TryMeasure(XFA_Attribute::LeftInset, false);
- if (leftInset)
+ if (leftInset.has_value())
componentSize.width += leftInset->ToUnit(XFA_Unit::Pt);
Optional<CXFA_Measurement> rightInset =
pMarginNode->JSObject()->TryMeasure(XFA_Attribute::RightInset, false);
- if (rightInset)
+ if (rightInset.has_value())
componentSize.width += rightInset->ToUnit(XFA_Unit::Pt);
}
}
@@ -156,13 +156,13 @@
if (pMarginNode) {
Optional<CXFA_Measurement> topInset =
pMarginNode->JSObject()->TryMeasure(XFA_Attribute::TopInset, false);
- if (topInset)
+ if (topInset.has_value())
componentSize.height += topInset->ToUnit(XFA_Unit::Pt);
Optional<CXFA_Measurement> bottomInset =
pMarginNode->JSObject()->TryMeasure(XFA_Attribute::BottomInset,
false);
- if (bottomInset)
+ if (bottomInset.has_value())
componentSize.height += bottomInset->ToUnit(XFA_Unit::Pt);
}
}
@@ -340,7 +340,7 @@
*bRootForceTb = false;
Optional<XFA_AttributeValue> layoutMode =
pFormNode->JSObject()->TryEnum(XFA_Attribute::Layout, false);
- if (layoutMode)
+ if (layoutMode.has_value())
return *layoutMode;
CXFA_Node* pParentNode = pFormNode->GetParent();
@@ -369,7 +369,7 @@
Optional<XFA_AttributeValue> previous =
pKeep->JSObject()->TryEnum(eKeepType, false);
- if (previous) {
+ if (previous.has_value()) {
if (*previous == XFA_AttributeValue::ContentArea ||
*previous == XFA_AttributeValue::PageArea) {
return true;
@@ -387,7 +387,7 @@
Optional<XFA_AttributeValue> next =
pKeep->JSObject()->TryEnum(eKeepType, false);
- if (!next)
+ if (!next.has_value())
return false;
if (*next == XFA_AttributeValue::ContentArea ||
*next == XFA_AttributeValue::PageArea) {
diff --git a/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp b/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp
index 17fd7fa..f207e8c 100644
--- a/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp
+++ b/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp
@@ -1156,7 +1156,7 @@
if (pOccurNode) {
Optional<int32_t> ret =
pOccurNode->JSObject()->TryInteger(XFA_Attribute::Max, false);
- if (ret)
+ if (ret.has_value())
iMax = *ret;
}
if (iMax >= 0 && iMax <= iPageSetCount)
@@ -1325,7 +1325,7 @@
Optional<XFA_AttributeValue> ret =
pPageArea->JSObject()->TryEnum(XFA_Attribute::OddOrEven, true);
- if (!ret || *ret == XFA_AttributeValue::Any)
+ if (!ret.has_value() || *ret == XFA_AttributeValue::Any)
return true;
int32_t iPageLast = GetPageCount() % 2;
@@ -1354,7 +1354,7 @@
if (pOccurNode) {
Optional<int32_t> ret =
pOccurNode->JSObject()->TryInteger(XFA_Attribute::Max, false);
- if (ret)
+ if (ret.has_value())
iMax = *ret;
}
if ((iMax < 0 || m_nCurPageCount < iMax)) {
@@ -1461,11 +1461,11 @@
pPageArea->GetFirstChildByClass<CXFA_Occur>(XFA_Element::Occur);
if (pOccurNode) {
ret = pOccurNode->JSObject()->TryInteger(XFA_Attribute::Min, false);
- if (ret)
+ if (ret.has_value())
iMin = *ret;
}
- if (!ret && !bTargetPageArea)
+ if (!ret.has_value() && !bTargetPageArea)
return iMin;
CXFA_Node* pContentArea = pPageArea->GetFirstChildByClass<CXFA_ContentArea>(
@@ -1502,7 +1502,7 @@
Optional<int32_t> iMin =
pOccurNode->JSObject()->TryInteger(XFA_Attribute::Min, false);
- if (!iMin || iCurSetCount >= *iMin)
+ if (!iMin.has_value() || iCurSetCount >= *iMin)
return;
for (int32_t i = 0; i < *iMin - iCurSetCount; i++) {
@@ -1568,10 +1568,10 @@
Optional<int32_t> ret;
if (pOccurNode) {
ret = pOccurNode->JSObject()->TryInteger(XFA_Attribute::Max, false);
- if (ret)
+ if (ret.has_value())
iMax = *ret;
}
- if (ret) {
+ if (ret.has_value()) {
if (m_nCurPageCount == iMax) {
CXFA_Node* pSrcPage = m_pCurPageArea;
int32_t nSrcPageCount = m_nCurPageCount;
diff --git a/xfa/fxfa/parser/cxfa_barcode.cpp b/xfa/fxfa/parser/cxfa_barcode.cpp
index 3e028ca..5ae3b66 100644
--- a/xfa/fxfa/parser/cxfa_barcode.cpp
+++ b/xfa/fxfa/parser/cxfa_barcode.cpp
@@ -71,7 +71,7 @@
Optional<bool> CXFA_Barcode::GetChecksum() {
Optional<XFA_AttributeValue> checksum =
JSObject()->TryEnum(XFA_Attribute::Checksum, true);
- if (!checksum)
+ if (!checksum.has_value())
return {};
switch (*checksum) {
@@ -91,7 +91,7 @@
Optional<int32_t> CXFA_Barcode::GetDataLength() {
Optional<WideString> wsDataLength =
JSObject()->TryCData(XFA_Attribute::DataLength, true);
- if (!wsDataLength)
+ if (!wsDataLength.has_value())
return {};
return {FXSYS_wtoi(wsDataLength->c_str())};
@@ -100,7 +100,7 @@
Optional<char> CXFA_Barcode::GetStartChar() {
Optional<WideString> wsStartEndChar =
JSObject()->TryCData(XFA_Attribute::StartChar, true);
- if (!wsStartEndChar || wsStartEndChar->IsEmpty())
+ if (!wsStartEndChar.has_value() || wsStartEndChar->IsEmpty())
return {};
return {static_cast<char>((*wsStartEndChar)[0])};
@@ -109,7 +109,7 @@
Optional<char> CXFA_Barcode::GetEndChar() {
Optional<WideString> wsStartEndChar =
JSObject()->TryCData(XFA_Attribute::EndChar, true);
- if (!wsStartEndChar || wsStartEndChar->IsEmpty())
+ if (!wsStartEndChar.has_value() || wsStartEndChar->IsEmpty())
return {};
return {static_cast<char>((*wsStartEndChar)[0])};
@@ -118,7 +118,7 @@
Optional<int32_t> CXFA_Barcode::GetECLevel() {
Optional<WideString> wsECLevel =
JSObject()->TryCData(XFA_Attribute::ErrorCorrectionLevel, true);
- if (!wsECLevel)
+ if (!wsECLevel.has_value())
return {};
return {FXSYS_wtoi(wsECLevel->c_str())};
}
@@ -126,7 +126,7 @@
Optional<int32_t> CXFA_Barcode::GetModuleWidth() {
Optional<CXFA_Measurement> moduleWidthHeight =
JSObject()->TryMeasure(XFA_Attribute::ModuleWidth, true);
- if (!moduleWidthHeight)
+ if (!moduleWidthHeight.has_value())
return {};
return {static_cast<int32_t>(moduleWidthHeight->ToUnit(XFA_Unit::Pt))};
@@ -135,7 +135,7 @@
Optional<int32_t> CXFA_Barcode::GetModuleHeight() {
Optional<CXFA_Measurement> moduleWidthHeight =
JSObject()->TryMeasure(XFA_Attribute::ModuleHeight, true);
- if (!moduleWidthHeight)
+ if (!moduleWidthHeight.has_value())
return {};
return {static_cast<int32_t>(moduleWidthHeight->ToUnit(XFA_Unit::Pt))};
@@ -156,11 +156,11 @@
Optional<int8_t> CXFA_Barcode::GetWideNarrowRatio() {
Optional<WideString> wsWideNarrowRatio =
JSObject()->TryCData(XFA_Attribute::WideNarrowRatio, true);
- if (!wsWideNarrowRatio)
+ if (!wsWideNarrowRatio.has_value())
return {};
Optional<size_t> ptPos = wsWideNarrowRatio->Find(':');
- if (!ptPos)
+ if (!ptPos.has_value())
return {static_cast<int8_t>(FXSYS_wtoi(wsWideNarrowRatio->c_str()))};
int32_t fB = FXSYS_wtoi(
diff --git a/xfa/fxfa/parser/cxfa_box.cpp b/xfa/fxfa/parser/cxfa_box.cpp
index 772db0f..ff00a0d 100644
--- a/xfa/fxfa/parser/cxfa_box.cpp
+++ b/xfa/fxfa/parser/cxfa_box.cpp
@@ -257,7 +257,7 @@
rtDraw.height = b + b;
Optional<int32_t> startAngle = GetStartAngle();
Optional<int32_t> sweepAngle = GetSweepAngle();
- if (!startAngle && !sweepAngle) {
+ if (!startAngle.has_value() && !sweepAngle.has_value()) {
fillPath->AddEllipse(rtDraw);
return;
}
diff --git a/xfa/fxfa/parser/cxfa_color.cpp b/xfa/fxfa/parser/cxfa_color.cpp
index ef77b7f..3f3da16 100644
--- a/xfa/fxfa/parser/cxfa_color.cpp
+++ b/xfa/fxfa/parser/cxfa_color.cpp
@@ -41,12 +41,12 @@
FX_ARGB CXFA_Color::GetValue() {
Optional<WideString> val = JSObject()->TryCData(XFA_Attribute::Value, false);
- return val ? StringToFXARGB(val->AsStringView()) : 0xFF000000;
+ return val.has_value() ? StringToFXARGB(val->AsStringView()) : 0xFF000000;
}
FX_ARGB CXFA_Color::GetValueOrDefault(FX_ARGB defaultValue) {
Optional<WideString> val = JSObject()->TryCData(XFA_Attribute::Value, false);
- return val ? StringToFXARGB(val->AsStringView()) : defaultValue;
+ return val.has_value() ? StringToFXARGB(val->AsStringView()) : defaultValue;
}
void CXFA_Color::SetValue(FX_ARGB color) {
diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp
index 1ac2e2c..99008b2 100644
--- a/xfa/fxfa/parser/cxfa_document.cpp
+++ b/xfa/fxfa/parser/cxfa_document.cpp
@@ -1341,12 +1341,12 @@
Optional<WideString> namespaceURI =
pDatasetsChild->JSObject()->TryNamespace();
- if (!namespaceURI)
+ if (!namespaceURI.has_value())
continue;
Optional<WideString> datasetsURI =
pDatasetsNode->JSObject()->TryNamespace();
- if (!datasetsURI)
+ if (!datasetsURI.has_value())
continue;
if (*namespaceURI == *datasetsURI)
return pDatasetsChild;
@@ -1690,7 +1690,7 @@
} else if (!pDataRoot && pChildNode->GetNameHash() == XFA_HASHCODE_Data) {
Optional<WideString> namespaceURI =
pChildNode->JSObject()->TryNamespace();
- if (!namespaceURI)
+ if (!namespaceURI.has_value())
continue;
if (*namespaceURI == wsDatasetsURI)
pDataRoot = pChildNode;
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 32ef519..0330b0b 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -1452,7 +1452,7 @@
layout.value_or(XFA_AttributeValue::Position);
if (pKeep) {
Optional<XFA_AttributeValue> intact = GetIntactFromKeep(pKeep, eLayoutType);
- if (intact)
+ if (intact.has_value())
return *intact;
}
@@ -1485,7 +1485,7 @@
if (eParLayout == XFA_AttributeValue::Tb && version < XFA_VERSION_208) {
Optional<CXFA_Measurement> measureH =
JSObject()->TryMeasure(XFA_Attribute::H, false);
- if (measureH)
+ if (measureH.has_value())
return XFA_AttributeValue::ContentArea;
}
return XFA_AttributeValue::None;
@@ -2020,14 +2020,14 @@
Optional<bool> CXFA_Node::GetDefaultBoolean(XFA_Attribute attr) const {
Optional<void*> value = GetDefaultValue(attr, XFA_AttributeType::Boolean);
- if (!value)
+ if (!value.has_value())
return {};
return {!!*value};
}
Optional<int32_t> CXFA_Node::GetDefaultInteger(XFA_Attribute attr) const {
Optional<void*> value = GetDefaultValue(attr, XFA_AttributeType::Integer);
- if (!value)
+ if (!value.has_value())
return {};
return {static_cast<int32_t>(reinterpret_cast<uintptr_t>(*value))};
}
@@ -2035,7 +2035,7 @@
Optional<CXFA_Measurement> CXFA_Node::GetDefaultMeasurement(
XFA_Attribute attr) const {
Optional<void*> value = GetDefaultValue(attr, XFA_AttributeType::Measure);
- if (!value)
+ if (!value.has_value())
return {};
WideString str = WideString(static_cast<const wchar_t*>(*value));
@@ -2044,7 +2044,7 @@
Optional<WideString> CXFA_Node::GetDefaultCData(XFA_Attribute attr) const {
Optional<void*> value = GetDefaultValue(attr, XFA_AttributeType::CData);
- if (!value)
+ if (!value.has_value())
return {};
return {WideString(static_cast<const wchar_t*>(*value))};
@@ -2053,7 +2053,7 @@
Optional<XFA_AttributeValue> CXFA_Node::GetDefaultEnum(
XFA_Attribute attr) const {
Optional<void*> value = GetDefaultValue(attr, XFA_AttributeType::Enum);
- if (!value)
+ if (!value.has_value())
return {};
return {static_cast<XFA_AttributeValue>(reinterpret_cast<uintptr_t>(*value))};
}
@@ -2231,7 +2231,7 @@
int32_t CXFA_Node::GetRotate() const {
Optional<int32_t> degrees =
JSObject()->TryInteger(XFA_Attribute::Rotate, false);
- return degrees ? XFA_MapRotation(*degrees) / 90 * 90 : 0;
+ return degrees.has_value() ? XFA_MapRotation(*degrees) / 90 * 90 : 0;
}
CXFA_Border* CXFA_Node::GetBorderIfExists() const {
@@ -2343,8 +2343,8 @@
Optional<XFA_AttributeValue> value =
pKeep->JSObject()->TryEnum(XFA_Attribute::Previous, false);
- if (value && (*value == XFA_AttributeValue::ContentArea ||
- *value == XFA_AttributeValue::PageArea)) {
+ if (value.has_value() && (*value == XFA_AttributeValue::ContentArea ||
+ *value == XFA_AttributeValue::PageArea)) {
return XFA_AttributeValue::ContentArea;
}
@@ -2355,7 +2355,7 @@
Optional<XFA_AttributeValue> ret =
pNode->JSObject()->TryEnum(XFA_Attribute::Next, false);
- if (!ret)
+ if (!ret.has_value())
return intact;
return (*ret == XFA_AttributeValue::ContentArea ||
@@ -3004,15 +3004,16 @@
float fThickness = 0;
XFA_AttributeValue iType = XFA_AttributeValue::Unknown;
std::tie(iType, bVisible, fThickness) = border->Get3DStyle();
- if (!left || !top || !right || !bottom) {
+ if (!left.has_value() || !top.has_value() || !right.has_value() ||
+ !bottom.has_value()) {
std::vector<CXFA_Stroke*> strokes = border->GetStrokes();
- if (!top)
+ if (!top.has_value())
top = GetEdgeThickness(strokes, bVisible, 0);
- if (!right)
+ if (!right.has_value())
right = GetEdgeThickness(strokes, bVisible, 1);
- if (!bottom)
+ if (!bottom.has_value())
bottom = GetEdgeThickness(strokes, bVisible, 2);
- if (!left)
+ if (!left.has_value())
left = GetEdgeThickness(strokes, bVisible, 3);
}
}
@@ -3242,28 +3243,28 @@
pSize->width += para->GetMarginLeft() + para->GetTextIndent();
Optional<float> width = TryWidth();
- if (width) {
+ if (width.has_value()) {
pSize->width = *width;
} else {
Optional<float> min = TryMinWidth();
- if (min)
+ if (min.has_value())
pSize->width = std::max(pSize->width, *min);
Optional<float> max = TryMaxWidth();
- if (max && *max > 0)
+ if (max.has_value() && *max > 0)
pSize->width = std::min(pSize->width, *max);
}
Optional<float> height = TryHeight();
- if (height) {
+ if (height.has_value()) {
pSize->height = *height;
} else {
Optional<float> min = TryMinHeight();
- if (min)
+ if (min.has_value())
pSize->height = std::max(pSize->height, *min);
Optional<float> max = TryMaxHeight();
- if (max && *max > 0)
+ if (max.has_value() && *max > 0)
pSize->height = std::min(pSize->height, *max);
}
return true;
@@ -3372,7 +3373,7 @@
CFX_RectF rtFit;
Optional<float> width = TryWidth();
- if (width) {
+ if (width.has_value()) {
rtFit.width = *width;
GetWidthWithoutMargin(rtFit.width);
} else {
@@ -3380,7 +3381,7 @@
}
Optional<float> height = TryHeight();
- if (height) {
+ if (height.has_value()) {
rtFit.height = *height;
GetHeightWithoutMargin(rtFit.height);
} else {
@@ -3446,11 +3447,11 @@
fWidthCalc += margin->GetLeftInset() + margin->GetRightInset();
Optional<float> min = TryMinWidth();
- if (min)
+ if (min.has_value())
fWidthCalc = std::max(fWidthCalc, *min);
Optional<float> max = TryMaxWidth();
- if (max && *max > 0)
+ if (max.has_value() && *max > 0)
fWidthCalc = std::min(fWidthCalc, *max);
return fWidthCalc;
@@ -3469,11 +3470,11 @@
fHeightCalc += margin->GetTopInset() + margin->GetBottomInset();
Optional<float> min = TryMinHeight();
- if (min)
+ if (min.has_value())
fHeightCalc = std::max(fHeightCalc, *min);
Optional<float> max = TryMaxHeight();
- if (max && *max > 0)
+ if (max.has_value() && *max > 0)
fHeightCalc = std::min(fHeightCalc, *max);
return fHeightCalc;
@@ -3503,7 +3504,7 @@
float fWidth = 0;
if (*pCalcWidth > 0 && *pCalcHeight < 0) {
Optional<float> height = TryHeight();
- if (height) {
+ if (height.has_value()) {
*pCalcHeight = *height;
} else {
CFX_SizeF size = CalculateAccWidthAndHeight(doc, *pCalcWidth);
@@ -3517,14 +3518,13 @@
if (*pCalcWidth < 0 && *pCalcHeight < 0) {
Optional<float> height;
Optional<float> width = TryWidth();
- if (width) {
+ if (width.has_value()) {
fWidth = *width;
-
height = TryHeight();
- if (height)
+ if (height.has_value())
*pCalcHeight = *height;
}
- if (!width || !height) {
+ if (!width.has_value() || !height.has_value()) {
CFX_SizeF size = CalculateAccWidthAndHeight(doc, fWidth);
*pCalcWidth = size.width;
*pCalcHeight = size.height;
@@ -3856,7 +3856,7 @@
}
if (*pCalcWidth < 0 && *pCalcHeight < 0) {
Optional<float> width = TryWidth();
- if (width) {
+ if (width.has_value()) {
pTextLayout->StartLayout(GetWidthWithoutMargin(*width));
*pCalcWidth = *width;
} else {
@@ -3989,7 +3989,7 @@
int32_t i = 0;
while (pText) {
Optional<WideString> wsContent = pText->JSObject()->TryContent(false, true);
- if (wsContent && *wsContent == wsValue)
+ if (wsContent.has_value() && *wsContent == wsValue)
return static_cast<XFA_CheckState>(i);
i++;
@@ -4720,7 +4720,7 @@
0, XFA_Element::Picture, false)) {
Optional<WideString> picture =
pPicture->JSObject()->TryContent(false, true);
- if (picture)
+ if (picture.has_value())
return *picture;
}
}
@@ -4755,7 +4755,7 @@
pUI->GetChild<CXFA_Picture>(0, XFA_Element::Picture, false)) {
Optional<WideString> picture =
pPicture->JSObject()->TryContent(false, true);
- if (picture)
+ if (picture.has_value())
return *picture;
}
}
diff --git a/xfa/fxfa/parser/cxfa_occur.cpp b/xfa/fxfa/parser/cxfa_occur.cpp
index bdcfc3c..a9281bc 100644
--- a/xfa/fxfa/parser/cxfa_occur.cpp
+++ b/xfa/fxfa/parser/cxfa_occur.cpp
@@ -42,12 +42,12 @@
int32_t CXFA_Occur::GetMax() {
Optional<int32_t> max = JSObject()->TryInteger(XFA_Attribute::Max, true);
- return max ? *max : GetMin();
+ return max.has_value() ? *max : GetMin();
}
int32_t CXFA_Occur::GetMin() {
Optional<int32_t> min = JSObject()->TryInteger(XFA_Attribute::Min, true);
- return min && *min >= 0 ? *min : 1;
+ return min.has_value() && *min >= 0 ? *min : 1;
}
std::tuple<int32_t, int32_t, int32_t> CXFA_Occur::GetOccurInfo() {
@@ -56,7 +56,7 @@
Optional<int32_t> init =
JSObject()->TryInteger(XFA_Attribute::Initial, false);
- return {iMin, iMax, init && *init >= iMin ? *init : iMin};
+ return {iMin, iMax, init.has_value() && *init >= iMin ? *init : iMin};
}
void CXFA_Occur::SetMax(int32_t iMax) {
diff --git a/xfa/fxfa/parser/cxfa_validate.cpp b/xfa/fxfa/parser/cxfa_validate.cpp
index 4834cb3..44e8cd8 100644
--- a/xfa/fxfa/parser/cxfa_validate.cpp
+++ b/xfa/fxfa/parser/cxfa_validate.cpp
@@ -65,7 +65,8 @@
Optional<XFA_AttributeValue> item =
XFA_GetAttributeValueByName(wsValue.AsStringView());
JSObject()->SetEnum(XFA_Attribute::NullTest,
- item ? *item : XFA_AttributeValue::Disabled, false);
+ item.has_value() ? *item : XFA_AttributeValue::Disabled,
+ false);
}
XFA_AttributeValue CXFA_Validate::GetNullTest() {
diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp
index b4c05ca..580b333 100644
--- a/xfa/fxfa/parser/xfa_utils.cpp
+++ b/xfa/fxfa/parser/xfa_utils.cpp
@@ -115,7 +115,7 @@
bool ContentNodeNeedtoExport(CXFA_Node* pContentNode) {
Optional<WideString> wsContent =
pContentNode->JSObject()->TryContent(false, false);
- if (!wsContent)
+ if (!wsContent.has_value())
return false;
DCHECK(pContentNode->IsContentNode());
@@ -142,7 +142,7 @@
return;
Optional<WideString> value = pNode->JSObject()->TryAttribute(eName, false);
- if (!value)
+ if (!value.has_value())
return;
wsOutput += L" ";
@@ -209,7 +209,7 @@
contentType.value().EqualsASCII("text/xml")) {
Optional<WideString> rawValue = pRawValueNode->JSObject()->TryAttribute(
XFA_Attribute::Value, false);
- if (!rawValue || rawValue->IsEmpty())
+ if (!rawValue.has_value() || rawValue->IsEmpty())
break;
std::vector<WideString> wsSelTextArray =
@@ -362,7 +362,7 @@
return WideString();
Optional<WideString> templateNS = pTemplateRoot->JSObject()->TryNamespace();
- if (!templateNS)
+ if (!templateNS.has_value())
return WideString();
XFA_VERSION eVersion =