diff options
Diffstat (limited to 'xfa')
24 files changed, 181 insertions, 206 deletions
diff --git a/xfa/fxfa/cxfa_ffbarcode.cpp b/xfa/fxfa/cxfa_ffbarcode.cpp index a7a66afa49..6aac5dd7f2 100644 --- a/xfa/fxfa/cxfa_ffbarcode.cpp +++ b/xfa/fxfa/cxfa_ffbarcode.cpp @@ -167,53 +167,52 @@ void CXFA_FFBarcode::UpdateWidgetProperty() { pBarCodeWidget->SetType(pBarcodeInfo->eBCType); CXFA_WidgetAcc* pAcc = GetDataAcc(); - pdfium::Optional<BC_CHAR_ENCODING> encoding = + Optional<BC_CHAR_ENCODING> encoding = pAcc->GetBarcodeAttribute_CharEncoding(); if (encoding) pBarCodeWidget->SetCharEncoding(*encoding); - pdfium::Optional<bool> calcChecksum = pAcc->GetBarcodeAttribute_Checksum(); + Optional<bool> calcChecksum = pAcc->GetBarcodeAttribute_Checksum(); if (calcChecksum) pBarCodeWidget->SetCalChecksum(*calcChecksum); - pdfium::Optional<int32_t> dataLen = pAcc->GetBarcodeAttribute_DataLength(); + Optional<int32_t> dataLen = pAcc->GetBarcodeAttribute_DataLength(); if (dataLen) pBarCodeWidget->SetDataLength(*dataLen); - pdfium::Optional<char> startChar = pAcc->GetBarcodeAttribute_StartChar(); + Optional<char> startChar = pAcc->GetBarcodeAttribute_StartChar(); if (startChar) pBarCodeWidget->SetStartChar(*startChar); - pdfium::Optional<char> endChar = pAcc->GetBarcodeAttribute_EndChar(); + Optional<char> endChar = pAcc->GetBarcodeAttribute_EndChar(); if (endChar) pBarCodeWidget->SetEndChar(*endChar); - pdfium::Optional<int32_t> ecLevel = pAcc->GetBarcodeAttribute_ECLevel(); + Optional<int32_t> ecLevel = pAcc->GetBarcodeAttribute_ECLevel(); if (ecLevel) pBarCodeWidget->SetErrorCorrectionLevel(*ecLevel); - pdfium::Optional<int32_t> width = pAcc->GetBarcodeAttribute_ModuleWidth(); + Optional<int32_t> width = pAcc->GetBarcodeAttribute_ModuleWidth(); if (width) pBarCodeWidget->SetModuleWidth(*width); - pdfium::Optional<int32_t> height = pAcc->GetBarcodeAttribute_ModuleHeight(); + Optional<int32_t> height = pAcc->GetBarcodeAttribute_ModuleHeight(); if (height) pBarCodeWidget->SetModuleHeight(*height); - pdfium::Optional<bool> printCheck = pAcc->GetBarcodeAttribute_PrintChecksum(); + Optional<bool> printCheck = pAcc->GetBarcodeAttribute_PrintChecksum(); if (printCheck) pBarCodeWidget->SetPrintChecksum(*printCheck); - pdfium::Optional<BC_TEXT_LOC> textLoc = - pAcc->GetBarcodeAttribute_TextLocation(); + Optional<BC_TEXT_LOC> textLoc = pAcc->GetBarcodeAttribute_TextLocation(); if (textLoc) pBarCodeWidget->SetTextLocation(*textLoc); - pdfium::Optional<bool> truncate = pAcc->GetBarcodeAttribute_Truncate(); + Optional<bool> truncate = pAcc->GetBarcodeAttribute_Truncate(); if (truncate) pBarCodeWidget->SetTruncated(*truncate); - pdfium::Optional<int8_t> ratio = pAcc->GetBarcodeAttribute_WideNarrowRatio(); + Optional<int8_t> ratio = pAcc->GetBarcodeAttribute_WideNarrowRatio(); if (ratio) pBarCodeWidget->SetWideNarrowRatio(*ratio); diff --git a/xfa/fxfa/cxfa_ffdatetimeedit.cpp b/xfa/fxfa/cxfa_ffdatetimeedit.cpp index d6b892360c..728ad0e11f 100644 --- a/xfa/fxfa/cxfa_ffdatetimeedit.cpp +++ b/xfa/fxfa/cxfa_ffdatetimeedit.cpp @@ -84,7 +84,7 @@ void CXFA_FFDateTimeEdit::UpdateWidgetProperty() { m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); uint32_t dwEditStyles = 0; - pdfium::Optional<int32_t> numCells = m_pDataAcc->GetNumberOfCells(); + Optional<int32_t> numCells = m_pDataAcc->GetNumberOfCells(); if (numCells && *numCells > 0) { dwEditStyles |= FWL_STYLEEXT_EDT_CombText; pWidget->SetEditLimit(*numCells); diff --git a/xfa/fxfa/cxfa_ffnumericedit.cpp b/xfa/fxfa/cxfa_ffnumericedit.cpp index 197905c56b..6229fdcd2c 100644 --- a/xfa/fxfa/cxfa_ffnumericedit.cpp +++ b/xfa/fxfa/cxfa_ffnumericedit.cpp @@ -53,7 +53,7 @@ void CXFA_FFNumericEdit::UpdateWidgetProperty() { if (!m_pDataAcc->IsHorizontalScrollPolicyOff()) dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll; - pdfium::Optional<int32_t> numCells = m_pDataAcc->GetNumberOfCells(); + Optional<int32_t> numCells = m_pDataAcc->GetNumberOfCells(); if (numCells && *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 1305938db3..40eeea5d9e 100644 --- a/xfa/fxfa/cxfa_ffpageview.cpp +++ b/xfa/fxfa/cxfa_ffpageview.cpp @@ -316,7 +316,7 @@ CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetTraverseWidget( CXFA_Traverse* pTraverse = pTraversal->GetChild<CXFA_Traverse>(0, XFA_Element::Traverse, false); if (pTraverse) { - pdfium::Optional<WideString> traverseWidgetName = + Optional<WideString> traverseWidgetName = pTraverse->JSObject()->TryAttribute(XFA_Attribute::Ref, true); if (traverseWidgetName) return FindWidgetByName(*traverseWidgetName, pWidget); diff --git a/xfa/fxfa/cxfa_fftextedit.cpp b/xfa/fxfa/cxfa_fftextedit.cpp index d6fd5be4ca..f1ca3cc565 100644 --- a/xfa/fxfa/cxfa_fftextedit.cpp +++ b/xfa/fxfa/cxfa_fftextedit.cpp @@ -92,7 +92,7 @@ void CXFA_FFTextEdit::UpdateWidgetProperty() { if (eType == XFA_Element::ExData) iMaxChars = 0; - pdfium::Optional<int32_t> numCells = m_pDataAcc->GetNumberOfCells(); + Optional<int32_t> numCells = m_pDataAcc->GetNumberOfCells(); if (!numCells) { pWidget->SetLimit(iMaxChars); } else if (*numCells == 0) { diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index 2f4dcb4755..467cc7568b 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -62,8 +62,8 @@ void XFA_BOX_GetPath_Arc(CXFA_Box* box, rtDraw.top = center.y - b; rtDraw.width = a + a; rtDraw.height = b + b; - pdfium::Optional<int32_t> startAngle = box->GetStartAngle(); - pdfium::Optional<int32_t> sweepAngle = box->GetSweepAngle(); + Optional<int32_t> startAngle = box->GetStartAngle(); + Optional<int32_t> sweepAngle = box->GetSweepAngle(); if (!startAngle && !sweepAngle) { fillPath.AddEllipse(rtDraw); return; diff --git a/xfa/fxfa/cxfa_textprovider.cpp b/xfa/fxfa/cxfa_textprovider.cpp index b0c1433135..a091baa24f 100644 --- a/xfa/fxfa/cxfa_textprovider.cpp +++ b/xfa/fxfa/cxfa_textprovider.cpp @@ -50,9 +50,8 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(bool& bRichText) { CXFA_Node* pChildNode = pValueNode->GetNodeItem(XFA_NODEITEM_FirstChild); if (pChildNode && pChildNode->GetElementType() == XFA_Element::ExData) { - pdfium::Optional<WideString> contentType = - pChildNode->JSObject()->TryAttribute(XFA_Attribute::ContentType, - false); + Optional<WideString> contentType = pChildNode->JSObject()->TryAttribute( + XFA_Attribute::ContentType, false); if (contentType && *contentType == L"text/html") bRichText = true; } @@ -90,9 +89,8 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(bool& bRichText) { CXFA_Node* pChildNode = pValueNode->GetNodeItem(XFA_NODEITEM_FirstChild); if (pChildNode && pChildNode->GetElementType() == XFA_Element::ExData) { - pdfium::Optional<WideString> contentType = - pChildNode->JSObject()->TryAttribute(XFA_Attribute::ContentType, - false); + Optional<WideString> contentType = pChildNode->JSObject()->TryAttribute( + XFA_Attribute::ContentType, false); if (contentType && *contentType == L"text/html") bRichText = true; } diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp index 8313e6074d..96701512f9 100644 --- a/xfa/fxfa/cxfa_widgetacc.cpp +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -975,28 +975,28 @@ bool CXFA_WidgetAcc::CalculateWidgetAutoSize(CFX_SizeF& size) { if (para) size.width += para->GetMarginLeft() + para->GetTextIndent(); - pdfium::Optional<float> width = TryWidth(); + Optional<float> width = TryWidth(); if (width) { size.width = *width; } else { - pdfium::Optional<float> min = TryMinWidth(); + Optional<float> min = TryMinWidth(); if (min) size.width = std::max(size.width, *min); - pdfium::Optional<float> max = TryMaxWidth(); + Optional<float> max = TryMaxWidth(); if (max && *max > 0) size.width = std::min(size.width, *max); } - pdfium::Optional<float> height = TryHeight(); + Optional<float> height = TryHeight(); if (height) { size.height = *height; } else { - pdfium::Optional<float> min = TryMinHeight(); + Optional<float> min = TryMinHeight(); if (min) size.height = std::max(size.height, *min); - pdfium::Optional<float> max = TryMaxHeight(); + Optional<float> max = TryMaxHeight(); if (max && *max > 0) size.height = std::min(size.height, *max); } @@ -1104,7 +1104,7 @@ CFX_SizeF CXFA_WidgetAcc::CalculateImageSize(float img_width, XFA_UnitPx2Pt(img_height, dpi_y)); CFX_RectF rtFit; - pdfium::Optional<float> width = TryWidth(); + Optional<float> width = TryWidth(); if (width) { rtFit.width = *width; GetWidthWithoutMargin(rtFit.width); @@ -1112,7 +1112,7 @@ CFX_SizeF CXFA_WidgetAcc::CalculateImageSize(float img_width, rtFit.width = rtImage.width; } - pdfium::Optional<float> height = TryHeight(); + Optional<float> height = TryHeight(); if (height) { rtFit.height = *height; GetHeightWithoutMargin(rtFit.height); @@ -1206,11 +1206,11 @@ float CXFA_WidgetAcc::CalculateWidgetAutoWidth(float fWidthCalc) { if (margin) fWidthCalc += margin->GetLeftInset() + margin->GetRightInset(); - pdfium::Optional<float> min = TryMinWidth(); + Optional<float> min = TryMinWidth(); if (min) fWidthCalc = std::max(fWidthCalc, *min); - pdfium::Optional<float> max = TryMaxWidth(); + Optional<float> max = TryMaxWidth(); if (max && *max > 0) fWidthCalc = std::min(fWidthCalc, *max); @@ -1229,11 +1229,11 @@ float CXFA_WidgetAcc::CalculateWidgetAutoHeight(float fHeightCalc) { if (margin) fHeightCalc += margin->GetTopInset() + margin->GetBottomInset(); - pdfium::Optional<float> min = TryMinHeight(); + Optional<float> min = TryMinHeight(); if (min) fHeightCalc = std::max(fHeightCalc, *min); - pdfium::Optional<float> max = TryMaxHeight(); + Optional<float> max = TryMaxHeight(); if (max && *max > 0) fHeightCalc = std::min(fHeightCalc, *max); @@ -1261,7 +1261,7 @@ void CXFA_WidgetAcc::StartWidgetLayout(float& fCalcWidth, float& fCalcHeight) { m_pLayoutData->m_fWidgetHeight = -1; float fWidth = 0; if (fCalcWidth > 0 && fCalcHeight < 0) { - pdfium::Optional<float> height = TryHeight(); + Optional<float> height = TryHeight(); if (height) fCalcHeight = *height; else @@ -1271,8 +1271,8 @@ void CXFA_WidgetAcc::StartWidgetLayout(float& fCalcWidth, float& fCalcHeight) { return; } if (fCalcWidth < 0 && fCalcHeight < 0) { - pdfium::Optional<float> height; - pdfium::Optional<float> width = TryWidth(); + Optional<float> height; + Optional<float> width = TryWidth(); if (width) { fWidth = *width; @@ -1605,7 +1605,7 @@ void CXFA_WidgetAcc::StartTextLayout(float& fCalcWidth, float& fCalcHeight) { } if (fCalcWidth < 0 && fCalcHeight < 0) { - pdfium::Optional<float> width = TryWidth(); + Optional<float> width = TryWidth(); if (width) { pTextLayout->StartLayout(GetWidthWithoutMargin(*width)); fCalcWidth = *width; @@ -1743,7 +1743,7 @@ bool CXFA_WidgetAcc::IsOpenAccess() const { } int32_t CXFA_WidgetAcc::GetRotate() const { - pdfium::Optional<int32_t> degrees = + Optional<int32_t> degrees = m_pNode->JSObject()->TryInteger(XFA_Attribute::Rotate, false); return degrees ? XFA_MapRotation(*degrees) / 90 * 90 : 0; } @@ -1823,27 +1823,27 @@ CXFA_Bind* CXFA_WidgetAcc::GetBind() { false); } -pdfium::Optional<float> CXFA_WidgetAcc::TryWidth() { +Optional<float> CXFA_WidgetAcc::TryWidth() { return m_pNode->JSObject()->TryMeasureAsFloat(XFA_Attribute::W); } -pdfium::Optional<float> CXFA_WidgetAcc::TryHeight() { +Optional<float> CXFA_WidgetAcc::TryHeight() { return m_pNode->JSObject()->TryMeasureAsFloat(XFA_Attribute::H); } -pdfium::Optional<float> CXFA_WidgetAcc::TryMinWidth() { +Optional<float> CXFA_WidgetAcc::TryMinWidth() { return m_pNode->JSObject()->TryMeasureAsFloat(XFA_Attribute::MinW); } -pdfium::Optional<float> CXFA_WidgetAcc::TryMinHeight() { +Optional<float> CXFA_WidgetAcc::TryMinHeight() { return m_pNode->JSObject()->TryMeasureAsFloat(XFA_Attribute::MinH); } -pdfium::Optional<float> CXFA_WidgetAcc::TryMaxWidth() { +Optional<float> CXFA_WidgetAcc::TryMaxWidth() { return m_pNode->JSObject()->TryMeasureAsFloat(XFA_Attribute::MaxW); } -pdfium::Optional<float> CXFA_WidgetAcc::TryMaxHeight() { +Optional<float> CXFA_WidgetAcc::TryMaxHeight() { return m_pNode->JSObject()->TryMeasureAsFloat(XFA_Attribute::MaxH); } @@ -1869,10 +1869,10 @@ CFX_RectF CXFA_WidgetAcc::GetUIMargin() { if (border && border->GetPresence() != XFA_AttributeEnum::Visible) return CFX_RectF(); - pdfium::Optional<float> left = mgUI->TryLeftInset(); - pdfium::Optional<float> top = mgUI->TryTopInset(); - pdfium::Optional<float> right = mgUI->TryRightInset(); - pdfium::Optional<float> bottom = mgUI->TryBottomInset(); + Optional<float> left = mgUI->TryLeftInset(); + Optional<float> top = mgUI->TryTopInset(); + Optional<float> right = mgUI->TryRightInset(); + Optional<float> bottom = mgUI->TryBottomInset(); if (border) { bool bVisible = false; float fThickness = 0; @@ -1977,8 +1977,7 @@ XFA_CHECKSTATE CXFA_WidgetAcc::GetCheckState() { CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); int32_t i = 0; while (pText) { - pdfium::Optional<WideString> wsContent = - pText->JSObject()->TryContent(false, true); + Optional<WideString> wsContent = pText->JSObject()->TryContent(false, true); if (wsContent && *wsContent == wsValue) return static_cast<XFA_CHECKSTATE>(i); @@ -2213,9 +2212,8 @@ int32_t CXFA_WidgetAcc::CountChoiceListItems(bool bSaveValue) { return pItem->CountChildren(XFA_Element::Unknown, false); } -pdfium::Optional<WideString> CXFA_WidgetAcc::GetChoiceListItem( - int32_t nIndex, - bool bSaveValue) { +Optional<WideString> CXFA_WidgetAcc::GetChoiceListItem(int32_t nIndex, + bool bSaveValue) { std::vector<CXFA_Node*> pItemsArray; int32_t iCount = 0; for (CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); pNode; @@ -2634,7 +2632,7 @@ bool CXFA_WidgetAcc::IsVerticalScrollPolicyOff() { return false; } -pdfium::Optional<int32_t> CXFA_WidgetAcc::GetNumberOfCells() { +Optional<int32_t> CXFA_WidgetAcc::GetNumberOfCells() { CXFA_Node* pUIChild = GetUIChild(); if (!pUIChild) return {}; @@ -2651,9 +2649,8 @@ WideString CXFA_WidgetAcc::GetBarcodeType() { : WideString(); } -pdfium::Optional<BC_CHAR_ENCODING> -CXFA_WidgetAcc::GetBarcodeAttribute_CharEncoding() { - pdfium::Optional<WideString> wsCharEncoding = +Optional<BC_CHAR_ENCODING> CXFA_WidgetAcc::GetBarcodeAttribute_CharEncoding() { + Optional<WideString> wsCharEncoding = GetUIChild()->JSObject()->TryCData(XFA_Attribute::CharEncoding, true); if (!wsCharEncoding) return {}; @@ -2664,8 +2661,8 @@ CXFA_WidgetAcc::GetBarcodeAttribute_CharEncoding() { return {}; } -pdfium::Optional<bool> CXFA_WidgetAcc::GetBarcodeAttribute_Checksum() { - pdfium::Optional<XFA_AttributeEnum> checksum = +Optional<bool> CXFA_WidgetAcc::GetBarcodeAttribute_Checksum() { + Optional<XFA_AttributeEnum> checksum = GetUIChild()->JSObject()->TryEnum(XFA_Attribute::Checksum, true); if (!checksum) return {}; @@ -2684,8 +2681,8 @@ pdfium::Optional<bool> CXFA_WidgetAcc::GetBarcodeAttribute_Checksum() { return {}; } -pdfium::Optional<int32_t> CXFA_WidgetAcc::GetBarcodeAttribute_DataLength() { - pdfium::Optional<WideString> wsDataLength = +Optional<int32_t> CXFA_WidgetAcc::GetBarcodeAttribute_DataLength() { + Optional<WideString> wsDataLength = GetUIChild()->JSObject()->TryCData(XFA_Attribute::DataLength, true); if (!wsDataLength) return {}; @@ -2693,8 +2690,8 @@ pdfium::Optional<int32_t> CXFA_WidgetAcc::GetBarcodeAttribute_DataLength() { return {FXSYS_wtoi(wsDataLength->c_str())}; } -pdfium::Optional<char> CXFA_WidgetAcc::GetBarcodeAttribute_StartChar() { - pdfium::Optional<WideString> wsStartEndChar = +Optional<char> CXFA_WidgetAcc::GetBarcodeAttribute_StartChar() { + Optional<WideString> wsStartEndChar = GetUIChild()->JSObject()->TryCData(XFA_Attribute::StartChar, true); if (!wsStartEndChar || wsStartEndChar->IsEmpty()) return {}; @@ -2702,8 +2699,8 @@ pdfium::Optional<char> CXFA_WidgetAcc::GetBarcodeAttribute_StartChar() { return {static_cast<char>((*wsStartEndChar)[0])}; } -pdfium::Optional<char> CXFA_WidgetAcc::GetBarcodeAttribute_EndChar() { - pdfium::Optional<WideString> wsStartEndChar = +Optional<char> CXFA_WidgetAcc::GetBarcodeAttribute_EndChar() { + Optional<WideString> wsStartEndChar = GetUIChild()->JSObject()->TryCData(XFA_Attribute::EndChar, true); if (!wsStartEndChar || wsStartEndChar->IsEmpty()) return {}; @@ -2711,16 +2708,16 @@ pdfium::Optional<char> CXFA_WidgetAcc::GetBarcodeAttribute_EndChar() { return {static_cast<char>((*wsStartEndChar)[0])}; } -pdfium::Optional<int32_t> CXFA_WidgetAcc::GetBarcodeAttribute_ECLevel() { - pdfium::Optional<WideString> wsECLevel = GetUIChild()->JSObject()->TryCData( +Optional<int32_t> CXFA_WidgetAcc::GetBarcodeAttribute_ECLevel() { + Optional<WideString> wsECLevel = GetUIChild()->JSObject()->TryCData( XFA_Attribute::ErrorCorrectionLevel, true); if (!wsECLevel) return {}; return {FXSYS_wtoi(wsECLevel->c_str())}; } -pdfium::Optional<int32_t> CXFA_WidgetAcc::GetBarcodeAttribute_ModuleWidth() { - pdfium::Optional<CXFA_Measurement> moduleWidthHeight = +Optional<int32_t> CXFA_WidgetAcc::GetBarcodeAttribute_ModuleWidth() { + Optional<CXFA_Measurement> moduleWidthHeight = GetUIChild()->JSObject()->TryMeasure(XFA_Attribute::ModuleWidth, true); if (!moduleWidthHeight) return {}; @@ -2728,8 +2725,8 @@ pdfium::Optional<int32_t> CXFA_WidgetAcc::GetBarcodeAttribute_ModuleWidth() { return {static_cast<int32_t>(moduleWidthHeight->ToUnit(XFA_Unit::Pt))}; } -pdfium::Optional<int32_t> CXFA_WidgetAcc::GetBarcodeAttribute_ModuleHeight() { - pdfium::Optional<CXFA_Measurement> moduleWidthHeight = +Optional<int32_t> CXFA_WidgetAcc::GetBarcodeAttribute_ModuleHeight() { + Optional<CXFA_Measurement> moduleWidthHeight = GetUIChild()->JSObject()->TryMeasure(XFA_Attribute::ModuleHeight, true); if (!moduleWidthHeight) return {}; @@ -2737,14 +2734,13 @@ pdfium::Optional<int32_t> CXFA_WidgetAcc::GetBarcodeAttribute_ModuleHeight() { return {static_cast<int32_t>(moduleWidthHeight->ToUnit(XFA_Unit::Pt))}; } -pdfium::Optional<bool> CXFA_WidgetAcc::GetBarcodeAttribute_PrintChecksum() { +Optional<bool> CXFA_WidgetAcc::GetBarcodeAttribute_PrintChecksum() { return GetUIChild()->JSObject()->TryBoolean(XFA_Attribute::PrintCheckDigit, true); } -pdfium::Optional<BC_TEXT_LOC> -CXFA_WidgetAcc::GetBarcodeAttribute_TextLocation() { - pdfium::Optional<XFA_AttributeEnum> textLocation = +Optional<BC_TEXT_LOC> CXFA_WidgetAcc::GetBarcodeAttribute_TextLocation() { + Optional<XFA_AttributeEnum> textLocation = GetUIChild()->JSObject()->TryEnum(XFA_Attribute::TextLocation, true); if (!textLocation) return {}; @@ -2766,17 +2762,17 @@ CXFA_WidgetAcc::GetBarcodeAttribute_TextLocation() { return {}; } -pdfium::Optional<bool> CXFA_WidgetAcc::GetBarcodeAttribute_Truncate() { +Optional<bool> CXFA_WidgetAcc::GetBarcodeAttribute_Truncate() { return GetUIChild()->JSObject()->TryBoolean(XFA_Attribute::Truncate, true); } -pdfium::Optional<int8_t> CXFA_WidgetAcc::GetBarcodeAttribute_WideNarrowRatio() { - pdfium::Optional<WideString> wsWideNarrowRatio = +Optional<int8_t> CXFA_WidgetAcc::GetBarcodeAttribute_WideNarrowRatio() { + Optional<WideString> wsWideNarrowRatio = GetUIChild()->JSObject()->TryCData(XFA_Attribute::WideNarrowRatio, true); if (!wsWideNarrowRatio) return {}; - pdfium::Optional<size_t> ptPos = wsWideNarrowRatio->Find(':'); + Optional<size_t> ptPos = wsWideNarrowRatio->Find(':'); if (!ptPos) return {static_cast<int8_t>(FXSYS_wtoi(wsWideNarrowRatio->c_str()))}; @@ -2916,7 +2912,7 @@ WideString CXFA_WidgetAcc::GetPictureContent(XFA_VALUEPICTURE ePicture) { m_pNode->GetChild<CXFA_Format>(0, XFA_Element::Format, false)) { if (CXFA_Picture* pPicture = pFormat->GetChild<CXFA_Picture>( 0, XFA_Element::Picture, false)) { - pdfium::Optional<WideString> picture = + Optional<WideString> picture = pPicture->JSObject()->TryContent(false, true); if (picture) return *picture; @@ -2948,7 +2944,7 @@ WideString CXFA_WidgetAcc::GetPictureContent(XFA_VALUEPICTURE ePicture) { if (pUI) { if (CXFA_Picture* pPicture = pUI->GetChild<CXFA_Picture>(0, XFA_Element::Picture, false)) { - pdfium::Optional<WideString> picture = + Optional<WideString> picture = pPicture->JSObject()->TryContent(false, true); if (picture) return *picture; diff --git a/xfa/fxfa/cxfa_widgetacc.h b/xfa/fxfa/cxfa_widgetacc.h index e2810571bc..976540df4d 100644 --- a/xfa/fxfa/cxfa_widgetacc.h +++ b/xfa/fxfa/cxfa_widgetacc.h @@ -137,12 +137,12 @@ class CXFA_WidgetAcc { std::vector<CXFA_Event*> GetEventByActivity(XFA_AttributeEnum iActivity, bool bIsFormReady); - pdfium::Optional<float> TryWidth(); - pdfium::Optional<float> TryHeight(); - pdfium::Optional<float> TryMinWidth(); - pdfium::Optional<float> TryMinHeight(); - pdfium::Optional<float> TryMaxWidth(); - pdfium::Optional<float> TryMaxHeight(); + Optional<float> TryWidth(); + Optional<float> TryHeight(); + Optional<float> TryMinWidth(); + Optional<float> TryMinHeight(); + Optional<float> TryMaxWidth(); + Optional<float> TryMaxHeight(); XFA_AttributeEnum GetButtonHighlight(); bool HasButtonRollover() const; @@ -166,8 +166,7 @@ class CXFA_WidgetAcc { CXFA_Node* GetExclGroupNextMember(CXFA_Node* pNode); int32_t CountChoiceListItems(bool bSaveValue); - pdfium::Optional<WideString> GetChoiceListItem(int32_t nIndex, - bool bSaveValue); + Optional<WideString> GetChoiceListItem(int32_t nIndex, bool bSaveValue); bool IsChoiceListMultiSelect(); bool IsChoiceListCommitOnSelect(); std::vector<WideString> GetChoiceListItems(bool bSaveValue); @@ -197,7 +196,7 @@ class CXFA_WidgetAcc { bool IsHorizontalScrollPolicyOff(); bool IsVerticalScrollPolicyOff(); - pdfium::Optional<int32_t> GetNumberOfCells(); + Optional<int32_t> GetNumberOfCells(); bool SetValue(XFA_VALUEPICTURE eValueType, const WideString& wsValue); WideString GetValue(XFA_VALUEPICTURE eValueType); @@ -210,18 +209,18 @@ class CXFA_WidgetAcc { WideString NormalizeNumStr(const WideString& wsValue); WideString GetBarcodeType(); - pdfium::Optional<BC_CHAR_ENCODING> GetBarcodeAttribute_CharEncoding(); - pdfium::Optional<bool> GetBarcodeAttribute_Checksum(); - pdfium::Optional<int32_t> GetBarcodeAttribute_DataLength(); - pdfium::Optional<char> GetBarcodeAttribute_StartChar(); - pdfium::Optional<char> GetBarcodeAttribute_EndChar(); - pdfium::Optional<int32_t> GetBarcodeAttribute_ECLevel(); - pdfium::Optional<int32_t> GetBarcodeAttribute_ModuleWidth(); - pdfium::Optional<int32_t> GetBarcodeAttribute_ModuleHeight(); - pdfium::Optional<bool> GetBarcodeAttribute_PrintChecksum(); - pdfium::Optional<BC_TEXT_LOC> GetBarcodeAttribute_TextLocation(); - pdfium::Optional<bool> GetBarcodeAttribute_Truncate(); - pdfium::Optional<int8_t> GetBarcodeAttribute_WideNarrowRatio(); + Optional<BC_CHAR_ENCODING> GetBarcodeAttribute_CharEncoding(); + Optional<bool> GetBarcodeAttribute_Checksum(); + Optional<int32_t> GetBarcodeAttribute_DataLength(); + Optional<char> GetBarcodeAttribute_StartChar(); + Optional<char> GetBarcodeAttribute_EndChar(); + Optional<int32_t> GetBarcodeAttribute_ECLevel(); + Optional<int32_t> GetBarcodeAttribute_ModuleWidth(); + Optional<int32_t> GetBarcodeAttribute_ModuleHeight(); + Optional<bool> GetBarcodeAttribute_PrintChecksum(); + Optional<BC_TEXT_LOC> GetBarcodeAttribute_TextLocation(); + Optional<bool> GetBarcodeAttribute_Truncate(); + Optional<int8_t> GetBarcodeAttribute_WideNarrowRatio(); WideString GetPasswordChar(); std::pair<XFA_Element, int32_t> GetMaxChars(); diff --git a/xfa/fxfa/parser/cxfa_box.cpp b/xfa/fxfa/parser/cxfa_box.cpp index ccb4e713ff..3bc641bbcd 100644 --- a/xfa/fxfa/parser/cxfa_box.cpp +++ b/xfa/fxfa/parser/cxfa_box.cpp @@ -94,11 +94,11 @@ bool CXFA_Box::IsCircular() { return JSObject()->GetBoolean(XFA_Attribute::Circular); } -pdfium::Optional<int32_t> CXFA_Box::GetStartAngle() { +Optional<int32_t> CXFA_Box::GetStartAngle() { return JSObject()->TryInteger(XFA_Attribute::StartAngle, false); } -pdfium::Optional<int32_t> CXFA_Box::GetSweepAngle() { +Optional<int32_t> CXFA_Box::GetSweepAngle() { return JSObject()->TryInteger(XFA_Attribute::SweepAngle, false); } diff --git a/xfa/fxfa/parser/cxfa_box.h b/xfa/fxfa/parser/cxfa_box.h index 5c2c8d20af..f995f5bb09 100644 --- a/xfa/fxfa/parser/cxfa_box.h +++ b/xfa/fxfa/parser/cxfa_box.h @@ -36,8 +36,8 @@ class CXFA_Box : public CXFA_Node { std::vector<CXFA_Stroke*> GetStrokes(); - pdfium::Optional<int32_t> GetStartAngle(); - pdfium::Optional<int32_t> GetSweepAngle(); + Optional<int32_t> GetStartAngle(); + Optional<int32_t> GetSweepAngle(); protected: CXFA_Box(CXFA_Document* pDoc, diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp index de057aa933..b7c9be517f 100644 --- a/xfa/fxfa/parser/cxfa_document.cpp +++ b/xfa/fxfa/parser/cxfa_document.cpp @@ -167,12 +167,12 @@ CXFA_Object* CXFA_Document::GetXFAObject(XFA_HashCode dwNodeNameHash) { if (pDatasetsChild->GetNameHash() != XFA_HASHCODE_Data) continue; - pdfium::Optional<WideString> namespaceURI = + Optional<WideString> namespaceURI = pDatasetsChild->JSObject()->TryNamespace(); if (!namespaceURI) continue; - pdfium::Optional<WideString> datasetsURI = + Optional<WideString> datasetsURI = pDatasetsNode->JSObject()->TryNamespace(); if (!datasetsURI) continue; diff --git a/xfa/fxfa/parser/cxfa_fill.cpp b/xfa/fxfa/parser/cxfa_fill.cpp index f5138d5e2e..5b6c69eb24 100644 --- a/xfa/fxfa/parser/cxfa_fill.cpp +++ b/xfa/fxfa/parser/cxfa_fill.cpp @@ -74,7 +74,7 @@ void CXFA_Fill::SetColor(FX_ARGB color) { FX_ARGB CXFA_Fill::GetColor(bool bText) { if (CXFA_Color* pNode = GetChild<CXFA_Color>(0, XFA_Element::Color, false)) { - pdfium::Optional<WideString> wsColor = + Optional<WideString> wsColor = pNode->JSObject()->TryCData(XFA_Attribute::Value, false); if (wsColor) return StringToFXARGB(wsColor->AsStringView()); @@ -103,7 +103,7 @@ XFA_AttributeEnum CXFA_Fill::GetPatternType() { FX_ARGB CXFA_Fill::GetPatternColor() { if (CXFA_Color* pColor = GetPattern()->GetChild<CXFA_Color>(0, XFA_Element::Color, false)) { - pdfium::Optional<WideString> wsColor = + Optional<WideString> wsColor = pColor->JSObject()->TryCData(XFA_Attribute::Value, false); if (wsColor) return StringToFXARGB(wsColor->AsStringView()); @@ -121,7 +121,7 @@ int32_t CXFA_Fill::GetStippleRate() { FX_ARGB CXFA_Fill::GetStippleColor() { if (CXFA_Color* pColor = GetStipple()->GetChild<CXFA_Color>(0, XFA_Element::Color, false)) { - pdfium::Optional<WideString> wsColor = + Optional<WideString> wsColor = pColor->JSObject()->TryCData(XFA_Attribute::Value, false); if (wsColor) return StringToFXARGB(wsColor->AsStringView()); @@ -139,7 +139,7 @@ XFA_AttributeEnum CXFA_Fill::GetLinearType() { FX_ARGB CXFA_Fill::GetLinearColor() { if (CXFA_Color* pColor = GetLinear()->GetChild<CXFA_Color>(0, XFA_Element::Color, false)) { - pdfium::Optional<WideString> wsColor = + Optional<WideString> wsColor = pColor->JSObject()->TryCData(XFA_Attribute::Value, false); if (wsColor) return StringToFXARGB(wsColor->AsStringView()); @@ -157,7 +157,7 @@ bool CXFA_Fill::IsRadialToEdge() { FX_ARGB CXFA_Fill::GetRadialColor() { if (CXFA_Color* pColor = GetRadial()->GetChild<CXFA_Color>(0, XFA_Element::Color, false)) { - pdfium::Optional<WideString> wsColor = + Optional<WideString> wsColor = pColor->JSObject()->TryCData(XFA_Attribute::Value, false); if (wsColor) return StringToFXARGB(wsColor->AsStringView()); diff --git a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp index 61863d13b4..bd21cdcf11 100644 --- a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp +++ b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp @@ -92,14 +92,14 @@ CFX_SizeF CalculateContainerSpecifiedSize(CXFA_Node* pFormNode, CFX_SizeF containerSize; if (eType == XFA_Element::Subform || eType == XFA_Element::ExclGroup) { - pdfium::Optional<CXFA_Measurement> wValue = + Optional<CXFA_Measurement> wValue = pFormNode->JSObject()->TryMeasure(XFA_Attribute::W, false); if (wValue && wValue->GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { containerSize.width = wValue->ToUnit(XFA_Unit::Pt); *bContainerWidthAutoSize = false; } - pdfium::Optional<CXFA_Measurement> hValue = + Optional<CXFA_Measurement> hValue = pFormNode->JSObject()->TryMeasure(XFA_Attribute::H, false); if (hValue && hValue->GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { containerSize.height = hValue->ToUnit(XFA_Unit::Pt); @@ -108,14 +108,14 @@ CFX_SizeF CalculateContainerSpecifiedSize(CXFA_Node* pFormNode, } if (*bContainerWidthAutoSize && eType == XFA_Element::Subform) { - pdfium::Optional<CXFA_Measurement> maxW = + Optional<CXFA_Measurement> maxW = pFormNode->JSObject()->TryMeasure(XFA_Attribute::MaxW, false); if (maxW && maxW->GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { containerSize.width = maxW->ToUnit(XFA_Unit::Pt); *bContainerWidthAutoSize = false; } - pdfium::Optional<CXFA_Measurement> maxH = + Optional<CXFA_Measurement> maxH = pFormNode->JSObject()->TryMeasure(XFA_Attribute::MaxH, false); if (maxH && maxH->GetValue() > XFA_LAYOUT_FLOAT_PERCISION) { containerSize.height = maxH->ToUnit(XFA_Unit::Pt); @@ -138,12 +138,12 @@ CFX_SizeF CalculateContainerComponentSizeFromContentSize( if (bContainerWidthAutoSize) { componentSize.width = fContentCalculatedWidth; if (pMarginNode) { - pdfium::Optional<CXFA_Measurement> leftInset = + Optional<CXFA_Measurement> leftInset = pMarginNode->JSObject()->TryMeasure(XFA_Attribute::LeftInset, false); if (leftInset) componentSize.width += leftInset->ToUnit(XFA_Unit::Pt); - pdfium::Optional<CXFA_Measurement> rightInset = + Optional<CXFA_Measurement> rightInset = pMarginNode->JSObject()->TryMeasure(XFA_Attribute::RightInset, false); if (rightInset) componentSize.width += rightInset->ToUnit(XFA_Unit::Pt); @@ -153,12 +153,12 @@ CFX_SizeF CalculateContainerComponentSizeFromContentSize( if (bContainerHeightAutoSize) { componentSize.height = fContentCalculatedHeight; if (pMarginNode) { - pdfium::Optional<CXFA_Measurement> topInset = + Optional<CXFA_Measurement> topInset = pMarginNode->JSObject()->TryMeasure(XFA_Attribute::TopInset, false); if (topInset) componentSize.height += topInset->ToUnit(XFA_Unit::Pt); - pdfium::Optional<CXFA_Measurement> bottomInset = + Optional<CXFA_Measurement> bottomInset = pMarginNode->JSObject()->TryMeasure(XFA_Attribute::BottomInset, false); if (bottomInset) @@ -504,7 +504,7 @@ float InsertPendingItems(CXFA_ItemLayoutProcessor* pProcessor, XFA_AttributeEnum GetLayout(CXFA_Node* pFormNode, bool* bRootForceTb) { *bRootForceTb = false; - pdfium::Optional<XFA_AttributeEnum> layoutMode = + Optional<XFA_AttributeEnum> layoutMode = pFormNode->JSObject()->TryEnum(XFA_Attribute::Layout, false); if (layoutMode) return *layoutMode; @@ -537,7 +537,7 @@ bool ExistContainerKeep(CXFA_Node* pCurNode, bool bPreFind) { if (!bPreFind) eKeepType = XFA_Attribute::Next; - pdfium::Optional<XFA_AttributeEnum> previous = + Optional<XFA_AttributeEnum> previous = pKeep->JSObject()->TryEnum(eKeepType, false); if (previous) { if (*previous == XFA_AttributeEnum::ContentArea || @@ -555,7 +555,7 @@ bool ExistContainerKeep(CXFA_Node* pCurNode, bool bPreFind) { if (!bPreFind) eKeepType = XFA_Attribute::Previous; - pdfium::Optional<XFA_AttributeEnum> next = + Optional<XFA_AttributeEnum> next = pKeep->JSObject()->TryEnum(eKeepType, false); if (!next) return false; diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp index b511cf8d3d..61caae762f 100644 --- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp +++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp @@ -153,7 +153,7 @@ CXFA_Node* ResolveBreakTarget(CXFA_Node* pPageSetRoot, bool bTargetAllFind = true; while (iSplitIndex != -1) { WideString wsExpr; - pdfium::Optional<size_t> iSplitNextIndex = 0; + Optional<size_t> iSplitNextIndex = 0; if (!bTargetAllFind) { iSplitNextIndex = wsTargetAll.Find(' ', iSplitIndex); if (!iSplitNextIndex.has_value()) @@ -1151,7 +1151,7 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_Ordered( CXFA_Node* pOccurNode = pPageSet->GetFirstChildByClass<CXFA_Occur>(XFA_Element::Occur); if (pOccurNode) { - pdfium::Optional<int32_t> ret = + Optional<int32_t> ret = pOccurNode->JSObject()->TryInteger(XFA_Attribute::Max, false); if (ret) iMax = *ret; @@ -1324,7 +1324,7 @@ bool CXFA_LayoutPageMgr::MatchPageAreaOddOrEven(CXFA_Node* pPageArea) { if (m_ePageSetMode != XFA_AttributeEnum::DuplexPaginated) return true; - pdfium::Optional<XFA_AttributeEnum> ret = + Optional<XFA_AttributeEnum> ret = pPageArea->JSObject()->TryEnum(XFA_Attribute::OddOrEven, true); if (!ret || *ret == XFA_AttributeEnum::Any) return true; @@ -1354,7 +1354,7 @@ CXFA_Node* CXFA_LayoutPageMgr::GetNextAvailPageArea( CXFA_Node* pOccurNode = m_pCurPageArea->GetFirstChildByClass<CXFA_Occur>(XFA_Element::Occur); if (pOccurNode) { - pdfium::Optional<int32_t> ret = + Optional<int32_t> ret = pOccurNode->JSObject()->TryInteger(XFA_Attribute::Max, false); if (ret) iMax = *ret; @@ -1460,7 +1460,7 @@ int32_t CXFA_LayoutPageMgr::CreateMinPageRecord(CXFA_Node* pPageArea, return 0; int32_t iMin = 0; - pdfium::Optional<int32_t> ret; + Optional<int32_t> ret; CXFA_Node* pOccurNode = pPageArea->GetFirstChildByClass<CXFA_Occur>(XFA_Element::Occur); if (pOccurNode) { @@ -1507,7 +1507,7 @@ void CXFA_LayoutPageMgr::CreateMinPageSetRecord(CXFA_Node* pPageSet, if (!pOccurNode) return; - pdfium::Optional<int32_t> iMin = + Optional<int32_t> iMin = pOccurNode->JSObject()->TryInteger(XFA_Attribute::Min, false); if (!iMin || iCurSetCount >= *iMin) return; @@ -1572,7 +1572,7 @@ bool CXFA_LayoutPageMgr::GetNextAvailContentHeight(float fChildHeight) { CXFA_Node* pOccurNode = pPageNode->GetFirstChildByClass<CXFA_Occur>(XFA_Element::Occur); int32_t iMax = 0; - pdfium::Optional<int32_t> ret; + Optional<int32_t> ret; if (pOccurNode) { ret = pOccurNode->JSObject()->TryInteger(XFA_Attribute::Max, false); if (ret) diff --git a/xfa/fxfa/parser/cxfa_margin.cpp b/xfa/fxfa/parser/cxfa_margin.cpp index 6dd4d39ee4..265d7e92c8 100644 --- a/xfa/fxfa/parser/cxfa_margin.cpp +++ b/xfa/fxfa/parser/cxfa_margin.cpp @@ -56,18 +56,18 @@ float CXFA_Margin::GetBottomInset() const { return TryBottomInset().value_or(0); } -pdfium::Optional<float> CXFA_Margin::TryLeftInset() const { +Optional<float> CXFA_Margin::TryLeftInset() const { return JSObject()->TryMeasureAsFloat(XFA_Attribute::LeftInset); } -pdfium::Optional<float> CXFA_Margin::TryTopInset() const { +Optional<float> CXFA_Margin::TryTopInset() const { return JSObject()->TryMeasureAsFloat(XFA_Attribute::TopInset); } -pdfium::Optional<float> CXFA_Margin::TryRightInset() const { +Optional<float> CXFA_Margin::TryRightInset() const { return JSObject()->TryMeasureAsFloat(XFA_Attribute::RightInset); } -pdfium::Optional<float> CXFA_Margin::TryBottomInset() const { +Optional<float> CXFA_Margin::TryBottomInset() const { return JSObject()->TryMeasureAsFloat(XFA_Attribute::BottomInset); } diff --git a/xfa/fxfa/parser/cxfa_margin.h b/xfa/fxfa/parser/cxfa_margin.h index 621704ab7a..e7f95b6c9c 100644 --- a/xfa/fxfa/parser/cxfa_margin.h +++ b/xfa/fxfa/parser/cxfa_margin.h @@ -19,10 +19,10 @@ class CXFA_Margin : public CXFA_Node { float GetRightInset() const; float GetBottomInset() const; - pdfium::Optional<float> TryLeftInset() const; - pdfium::Optional<float> TryTopInset() const; - pdfium::Optional<float> TryRightInset() const; - pdfium::Optional<float> TryBottomInset() const; + Optional<float> TryLeftInset() const; + Optional<float> TryTopInset() const; + Optional<float> TryRightInset() const; + Optional<float> TryBottomInset() const; }; #endif // XFA_FXFA_PARSER_CXFA_MARGIN_H_ diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index f6f2675c29..3d132fedbc 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -142,7 +142,7 @@ WideString CXFA_Node::AttributeEnumToName(XFA_AttributeEnum item) { } // static -pdfium::Optional<XFA_AttributeEnum> CXFA_Node::NameToAttributeEnum( +Optional<XFA_AttributeEnum> CXFA_Node::NameToAttributeEnum( const WideStringView& name) { if (name.IsEmpty()) return {}; @@ -309,8 +309,7 @@ uint8_t CXFA_Node::PropertyOccuranceCount(XFA_Element property) const { return data ? data->occurance_count : 0; } -pdfium::Optional<XFA_Element> CXFA_Node::GetFirstPropertyWithFlag( - uint8_t flag) { +Optional<XFA_Element> CXFA_Node::GetFirstPropertyWithFlag(uint8_t flag) { if (m_Properties == nullptr) return {}; @@ -439,7 +438,7 @@ std::vector<CXFA_Node*> CXFA_Node::GetNodeList(uint32_t dwTypeFilter, if (m_Properties == nullptr) return nodes; - pdfium::Optional<XFA_Element> property = + Optional<XFA_Element> property = GetFirstPropertyWithFlag(XFA_PROPERTYFLAG_DefaultOneOf); if (!property) return nodes; @@ -637,7 +636,7 @@ bool CXFA_Node::GetLocaleName(WideString& wsLocaleName) { CXFA_Node* pLocaleNode = this; do { - pdfium::Optional<WideString> ret = + Optional<WideString> ret = pLocaleNode->JSObject()->TryCData(XFA_Attribute::Locale, false); if (ret) { wsLocaleName = *ret; @@ -652,7 +651,7 @@ bool CXFA_Node::GetLocaleName(WideString& wsLocaleName) { return true; if (pTopSubform) { - pdfium::Optional<WideString> ret = + Optional<WideString> ret = pTopSubform->JSObject()->TryCData(XFA_Attribute::Locale, false); if (ret) { wsLocaleName = *ret; @@ -674,7 +673,7 @@ XFA_AttributeEnum CXFA_Node::GetIntact() { ->TryEnum(XFA_Attribute::Layout, true) .value_or(XFA_AttributeEnum::Position); if (pKeep) { - pdfium::Optional<XFA_AttributeEnum> intact = + Optional<XFA_AttributeEnum> intact = pKeep->JSObject()->TryEnum(XFA_Attribute::Intact, false); if (intact) { if (*intact == XFA_AttributeEnum::None && @@ -685,7 +684,7 @@ XFA_AttributeEnum CXFA_Node::GetIntact() { if (pPreviewRow && pPreviewRow->JSObject()->GetEnum(XFA_Attribute::Layout) == XFA_AttributeEnum::Row) { - pdfium::Optional<XFA_AttributeEnum> value = + Optional<XFA_AttributeEnum> value = pKeep->JSObject()->TryEnum(XFA_Attribute::Previous, false); if (value && (*value == XFA_AttributeEnum::ContentArea || *value == XFA_AttributeEnum::PageArea)) { @@ -694,7 +693,7 @@ XFA_AttributeEnum CXFA_Node::GetIntact() { CXFA_Keep* pNode = pPreviewRow->GetFirstChildByClass<CXFA_Keep>(XFA_Element::Keep); - pdfium::Optional<XFA_AttributeEnum> ret; + Optional<XFA_AttributeEnum> ret; if (pNode) ret = pNode->JSObject()->TryEnum(XFA_Attribute::Next, false); if (ret && (*ret == XFA_AttributeEnum::ContentArea || @@ -734,7 +733,7 @@ XFA_AttributeEnum CXFA_Node::GetIntact() { XFA_VERSION version = m_pDocument->GetCurVersionMode(); if (eParLayout == XFA_AttributeEnum::Tb && version < XFA_VERSION_208) { - pdfium::Optional<CXFA_Measurement> measureH = + Optional<CXFA_Measurement> measureH = JSObject()->TryMeasure(XFA_Attribute::H, false); if (measureH) return XFA_AttributeEnum::ContentArea; @@ -1326,27 +1325,23 @@ CXFA_Node* CXFA_Node::CreateInstance(bool bDataMerge) { return pInstance; } -pdfium::Optional<bool> CXFA_Node::GetDefaultBoolean(XFA_Attribute attr) const { - pdfium::Optional<void*> value = - GetDefaultValue(attr, XFA_AttributeType::Boolean); +Optional<bool> CXFA_Node::GetDefaultBoolean(XFA_Attribute attr) const { + Optional<void*> value = GetDefaultValue(attr, XFA_AttributeType::Boolean); if (!value) return {}; return {!!*value}; } -pdfium::Optional<int32_t> CXFA_Node::GetDefaultInteger( - XFA_Attribute attr) const { - pdfium::Optional<void*> value = - GetDefaultValue(attr, XFA_AttributeType::Integer); +Optional<int32_t> CXFA_Node::GetDefaultInteger(XFA_Attribute attr) const { + Optional<void*> value = GetDefaultValue(attr, XFA_AttributeType::Integer); if (!value) return {}; return {static_cast<int32_t>(reinterpret_cast<uintptr_t>(*value))}; } -pdfium::Optional<CXFA_Measurement> CXFA_Node::GetDefaultMeasurement( +Optional<CXFA_Measurement> CXFA_Node::GetDefaultMeasurement( XFA_Attribute attr) const { - pdfium::Optional<void*> value = - GetDefaultValue(attr, XFA_AttributeType::Measure); + Optional<void*> value = GetDefaultValue(attr, XFA_AttributeType::Measure); if (!value) return {}; @@ -1354,28 +1349,24 @@ pdfium::Optional<CXFA_Measurement> CXFA_Node::GetDefaultMeasurement( return {CXFA_Measurement(str.AsStringView())}; } -pdfium::Optional<WideString> CXFA_Node::GetDefaultCData( - XFA_Attribute attr) const { - pdfium::Optional<void*> value = - GetDefaultValue(attr, XFA_AttributeType::CData); +Optional<WideString> CXFA_Node::GetDefaultCData(XFA_Attribute attr) const { + Optional<void*> value = GetDefaultValue(attr, XFA_AttributeType::CData); if (!value) return {}; return {WideString(static_cast<const wchar_t*>(*value))}; } -pdfium::Optional<XFA_AttributeEnum> CXFA_Node::GetDefaultEnum( +Optional<XFA_AttributeEnum> CXFA_Node::GetDefaultEnum( XFA_Attribute attr) const { - pdfium::Optional<void*> value = - GetDefaultValue(attr, XFA_AttributeType::Enum); + Optional<void*> value = GetDefaultValue(attr, XFA_AttributeType::Enum); if (!value) return {}; return {static_cast<XFA_AttributeEnum>(reinterpret_cast<uintptr_t>(*value))}; } -pdfium::Optional<void*> CXFA_Node::GetDefaultValue( - XFA_Attribute attr, - XFA_AttributeType eType) const { +Optional<void*> CXFA_Node::GetDefaultValue(XFA_Attribute attr, + XFA_AttributeType eType) const { const AttributeData* data = GetAttributeData(attr); if (!data) return {}; diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h index e6683b24dc..cc8d5e8f8d 100644 --- a/xfa/fxfa/parser/cxfa_node.h +++ b/xfa/fxfa/parser/cxfa_node.h @@ -65,7 +65,7 @@ class CXFA_Node : public CXFA_Object { #endif // NDEBUG static WideString AttributeEnumToName(XFA_AttributeEnum item); - static pdfium::Optional<XFA_AttributeEnum> NameToAttributeEnum( + static Optional<XFA_AttributeEnum> NameToAttributeEnum( const WideStringView& name); static XFA_Attribute NameToAttribute(const WideStringView& name); static WideString AttributeToName(XFA_Attribute attr); @@ -210,12 +210,11 @@ class CXFA_Node : public CXFA_Object { CXFA_Occur* GetOccur(); - pdfium::Optional<bool> GetDefaultBoolean(XFA_Attribute attr) const; - pdfium::Optional<int32_t> GetDefaultInteger(XFA_Attribute attr) const; - pdfium::Optional<CXFA_Measurement> GetDefaultMeasurement( - XFA_Attribute attr) const; - pdfium::Optional<WideString> GetDefaultCData(XFA_Attribute attr) const; - pdfium::Optional<XFA_AttributeEnum> GetDefaultEnum(XFA_Attribute attr) const; + Optional<bool> GetDefaultBoolean(XFA_Attribute attr) const; + Optional<int32_t> GetDefaultInteger(XFA_Attribute attr) const; + Optional<CXFA_Measurement> GetDefaultMeasurement(XFA_Attribute attr) const; + Optional<WideString> GetDefaultCData(XFA_Attribute attr) const; + Optional<XFA_AttributeEnum> GetDefaultEnum(XFA_Attribute attr) const; void SyncValue(const WideString& wsValue, bool bNotify); @@ -243,10 +242,10 @@ class CXFA_Node : public CXFA_Object { CXFA_Node* Deprecated_GetPrevSibling(); const PropertyData* GetPropertyData(XFA_Element property) const; const AttributeData* GetAttributeData(XFA_Attribute attr) const; - pdfium::Optional<XFA_Element> GetFirstPropertyWithFlag(uint8_t flag); + Optional<XFA_Element> GetFirstPropertyWithFlag(uint8_t flag); void OnRemoved(bool bNotify); - pdfium::Optional<void*> GetDefaultValue(XFA_Attribute attr, - XFA_AttributeType eType) const; + Optional<void*> GetDefaultValue(XFA_Attribute attr, + XFA_AttributeType eType) const; CXFA_Node* GetChildInternal(int32_t index, XFA_Element eType, bool bOnlyChild); diff --git a/xfa/fxfa/parser/cxfa_occur.cpp b/xfa/fxfa/parser/cxfa_occur.cpp index 441394c567..7be3f7066d 100644 --- a/xfa/fxfa/parser/cxfa_occur.cpp +++ b/xfa/fxfa/parser/cxfa_occur.cpp @@ -40,14 +40,12 @@ CXFA_Occur::CXFA_Occur(CXFA_Document* doc, XFA_PacketType packet) CXFA_Occur::~CXFA_Occur() {} int32_t CXFA_Occur::GetMax() { - pdfium::Optional<int32_t> max = - JSObject()->TryInteger(XFA_Attribute::Max, true); + Optional<int32_t> max = JSObject()->TryInteger(XFA_Attribute::Max, true); return max ? *max : GetMin(); } int32_t CXFA_Occur::GetMin() { - pdfium::Optional<int32_t> min = - JSObject()->TryInteger(XFA_Attribute::Min, true); + Optional<int32_t> min = JSObject()->TryInteger(XFA_Attribute::Min, true); return min && *min >= 0 ? *min : 1; } @@ -55,7 +53,7 @@ std::tuple<int32_t, int32_t, int32_t> CXFA_Occur::GetOccurInfo() { int32_t iMin = GetMin(); int32_t iMax = GetMax(); - pdfium::Optional<int32_t> init = + Optional<int32_t> init = JSObject()->TryInteger(XFA_Attribute::Initial, false); return {iMin, iMax, init && *init >= iMin ? *init : iMin}; } diff --git a/xfa/fxfa/parser/cxfa_script.cpp b/xfa/fxfa/parser/cxfa_script.cpp index 1b784b331b..1e4eb7e0aa 100644 --- a/xfa/fxfa/parser/cxfa_script.cpp +++ b/xfa/fxfa/parser/cxfa_script.cpp @@ -48,7 +48,7 @@ CXFA_Script::CXFA_Script(CXFA_Document* doc, XFA_PacketType packet) CXFA_Script::~CXFA_Script() {} CXFA_Script::Type CXFA_Script::GetContentType() { - pdfium::Optional<WideString> cData = + Optional<WideString> cData = JSObject()->TryCData(XFA_Attribute::ContentType, false); if (!cData || *cData == L"application/x-formcalc") return Type::Formcalc; diff --git a/xfa/fxfa/parser/cxfa_validate.cpp b/xfa/fxfa/parser/cxfa_validate.cpp index 665c606632..35479ca1f5 100644 --- a/xfa/fxfa/parser/cxfa_validate.cpp +++ b/xfa/fxfa/parser/cxfa_validate.cpp @@ -59,7 +59,7 @@ XFA_AttributeEnum CXFA_Validate::GetFormatTest() { } void CXFA_Validate::SetNullTest(const WideString& wsValue) { - pdfium::Optional<XFA_AttributeEnum> item = + Optional<XFA_AttributeEnum> item = CXFA_Node::NameToAttributeEnum(wsValue.AsStringView()); JSObject()->SetEnum(XFA_Attribute::NullTest, item ? *item : XFA_AttributeEnum::Disabled, false); diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp index 5a42f21159..192a7f2fe5 100644 --- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp @@ -90,7 +90,7 @@ bool FormValueNode_SetChildContent(CXFA_Node* pValueNode, if (!pContentRawDataNode) { XFA_Element element = XFA_Element::Sharptext; if (pChildNode->GetElementType() == XFA_Element::ExData) { - pdfium::Optional<WideString> contentType = + Optional<WideString> contentType = pChildNode->JSObject()->TryAttribute(XFA_Attribute::ContentType, false); if (contentType) { @@ -1058,8 +1058,7 @@ CXFA_Node* MaybeCreateDataNode(CXFA_Document* pDocument, if (pDDGroupNode->GetElementType() != XFA_Element::DataGroup) continue; - pdfium::Optional<WideString> ns = - pDDGroupNode->JSObject()->TryNamespace(); + Optional<WideString> ns = pDDGroupNode->JSObject()->TryNamespace(); if (!ns || *ns != L"http://ns.adobe.com/data-description/") continue; } @@ -1238,8 +1237,7 @@ void UpdateDataRelation(CXFA_Node* pDataNode, CXFA_Node* pDataDescriptionNode) { if (pDDGroupNode->GetElementType() != XFA_Element::DataGroup) continue; - pdfium::Optional<WideString> ns = - pDDGroupNode->JSObject()->TryNamespace(); + Optional<WideString> ns = pDDGroupNode->JSObject()->TryNamespace(); if (!ns || *ns != L"http://ns.adobe.com/data-description/") continue; } @@ -1416,14 +1414,14 @@ void CXFA_Document::DoDataMerge() { continue; if (!pDDRoot && pChildNode->GetNameHash() == XFA_HASHCODE_DataDescription) { - pdfium::Optional<WideString> namespaceURI = + Optional<WideString> namespaceURI = pChildNode->JSObject()->TryNamespace(); if (!namespaceURI) continue; if (*namespaceURI == L"http://ns.adobe.com/data-description/") pDDRoot = pChildNode; } else if (!pDataRoot && pChildNode->GetNameHash() == XFA_HASHCODE_Data) { - pdfium::Optional<WideString> namespaceURI = + Optional<WideString> namespaceURI = pChildNode->JSObject()->TryNamespace(); if (!namespaceURI) continue; diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp index f891d47f23..0105752937 100644 --- a/xfa/fxfa/parser/xfa_utils.cpp +++ b/xfa/fxfa/parser/xfa_utils.cpp @@ -128,7 +128,7 @@ bool AttributeSaveInDataModel(CXFA_Node* pNode, XFA_Attribute eAttribute) { } bool ContentNodeNeedtoExport(CXFA_Node* pContentNode) { - pdfium::Optional<WideString> wsContent = + Optional<WideString> wsContent = pContentNode->JSObject()->TryContent(false, false); if (!wsContent) return false; @@ -159,8 +159,7 @@ void SaveAttribute(CXFA_Node* pNode, if (!bProto && !pNode->JSObject()->HasAttribute(eName)) return; - pdfium::Optional<WideString> value = - pNode->JSObject()->TryAttribute(eName, false); + Optional<WideString> value = pNode->JSObject()->TryAttribute(eName, false); if (!value) return; @@ -206,7 +205,7 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode, if (!pRawValueNode) break; - pdfium::Optional<WideString> contentType = + Optional<WideString> contentType = pNode->JSObject()->TryAttribute(XFA_Attribute::ContentType, false); if (pRawValueNode->GetElementType() == XFA_Element::SharpxHTML && (contentType && *contentType == L"text/html")) { @@ -229,9 +228,8 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode, ByteStringView(pMemStream->GetBuffer(), pMemStream->GetSize())); } else if (pRawValueNode->GetElementType() == XFA_Element::Sharpxml && (contentType && *contentType == L"text/xml")) { - pdfium::Optional<WideString> rawValue = - pRawValueNode->JSObject()->TryAttribute(XFA_Attribute::Value, - false); + Optional<WideString> rawValue = pRawValueNode->JSObject()->TryAttribute( + XFA_Attribute::Value, false); if (!rawValue || rawValue->IsEmpty()) break; @@ -399,8 +397,7 @@ void RecognizeXFAVersionNumber(CXFA_Node* pTemplateRoot, if (!pTemplateRoot) return; - pdfium::Optional<WideString> templateNS = - pTemplateRoot->JSObject()->TryNamespace(); + Optional<WideString> templateNS = pTemplateRoot->JSObject()->TryNamespace(); if (!templateNS) return; |