diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2018-01-29 20:38:16 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-01-29 20:38:16 +0000 |
commit | 59cdc7dc88310bd8cdf2ace60e0f567561d38dbb (patch) | |
tree | 298be106e7d44cb418e8ee7592428fc3d94b7796 /xfa/fxfa/parser/cxfa_node.cpp | |
parent | 32d5de5948ff8a54b24d79e1f032857874b6053f (diff) | |
download | pdfium-59cdc7dc88310bd8cdf2ace60e0f567561d38dbb.tar.xz |
Move barcode code to CXFA_Barcode
This CL moves the barcode specific code out of CXFA_Node and into
CXFA_Barcode. The CXFA_FFBarcode widget was modified to take the barcode
as a parameter.
Change-Id: I8ff91cb58402665f4ba63f2eeced45feeaa9ff50
Reviewed-on: https://pdfium-review.googlesource.com/24450
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_node.cpp')
-rw-r--r-- | xfa/fxfa/parser/cxfa_node.cpp | 149 |
1 files changed, 0 insertions, 149 deletions
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 5b04700010..2ccdd1d919 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -2371,155 +2371,6 @@ std::pair<int32_t, bool> CXFA_Node::ExecuteBoolScript( return {iRet, pTmpRetValue->IsBoolean() ? pTmpRetValue->ToBoolean() : false}; } -WideString CXFA_Node::GetBarcodeType() { - CXFA_Node* pUIChild = GetUIChildNode(); - return pUIChild - ? WideString(pUIChild->JSObject()->GetCData(XFA_Attribute::Type)) - : WideString(); -} - -Optional<BC_CHAR_ENCODING> CXFA_Node::GetBarcodeAttribute_CharEncoding() { - Optional<WideString> wsCharEncoding = - GetUIChildNode()->JSObject()->TryCData(XFA_Attribute::CharEncoding, true); - if (!wsCharEncoding) - return {}; - if (wsCharEncoding->CompareNoCase(L"UTF-16")) - return {CHAR_ENCODING_UNICODE}; - if (wsCharEncoding->CompareNoCase(L"UTF-8")) - return {CHAR_ENCODING_UTF8}; - return {}; -} - -Optional<bool> CXFA_Node::GetBarcodeAttribute_Checksum() { - Optional<XFA_AttributeEnum> checksum = - GetUIChildNode()->JSObject()->TryEnum(XFA_Attribute::Checksum, true); - if (!checksum) - return {}; - - switch (*checksum) { - case XFA_AttributeEnum::None: - return {false}; - case XFA_AttributeEnum::Auto: - return {true}; - case XFA_AttributeEnum::Checksum_1mod10: - case XFA_AttributeEnum::Checksum_1mod10_1mod11: - case XFA_AttributeEnum::Checksum_2mod10: - default: - break; - } - return {}; -} - -Optional<int32_t> CXFA_Node::GetBarcodeAttribute_DataLength() { - Optional<WideString> wsDataLength = - GetUIChildNode()->JSObject()->TryCData(XFA_Attribute::DataLength, true); - if (!wsDataLength) - return {}; - - return {FXSYS_wtoi(wsDataLength->c_str())}; -} - -Optional<char> CXFA_Node::GetBarcodeAttribute_StartChar() { - Optional<WideString> wsStartEndChar = - GetUIChildNode()->JSObject()->TryCData(XFA_Attribute::StartChar, true); - if (!wsStartEndChar || wsStartEndChar->IsEmpty()) - return {}; - - return {static_cast<char>((*wsStartEndChar)[0])}; -} - -Optional<char> CXFA_Node::GetBarcodeAttribute_EndChar() { - Optional<WideString> wsStartEndChar = - GetUIChildNode()->JSObject()->TryCData(XFA_Attribute::EndChar, true); - if (!wsStartEndChar || wsStartEndChar->IsEmpty()) - return {}; - - return {static_cast<char>((*wsStartEndChar)[0])}; -} - -Optional<int32_t> CXFA_Node::GetBarcodeAttribute_ECLevel() { - Optional<WideString> wsECLevel = GetUIChildNode()->JSObject()->TryCData( - XFA_Attribute::ErrorCorrectionLevel, true); - if (!wsECLevel) - return {}; - return {FXSYS_wtoi(wsECLevel->c_str())}; -} - -Optional<int32_t> CXFA_Node::GetBarcodeAttribute_ModuleWidth() { - Optional<CXFA_Measurement> moduleWidthHeight = - GetUIChildNode()->JSObject()->TryMeasure(XFA_Attribute::ModuleWidth, - true); - if (!moduleWidthHeight) - return {}; - - return {static_cast<int32_t>(moduleWidthHeight->ToUnit(XFA_Unit::Pt))}; -} - -Optional<int32_t> CXFA_Node::GetBarcodeAttribute_ModuleHeight() { - Optional<CXFA_Measurement> moduleWidthHeight = - GetUIChildNode()->JSObject()->TryMeasure(XFA_Attribute::ModuleHeight, - true); - if (!moduleWidthHeight) - return {}; - - return {static_cast<int32_t>(moduleWidthHeight->ToUnit(XFA_Unit::Pt))}; -} - -Optional<bool> CXFA_Node::GetBarcodeAttribute_PrintChecksum() { - return GetUIChildNode()->JSObject()->TryBoolean( - XFA_Attribute::PrintCheckDigit, true); -} - -Optional<BC_TEXT_LOC> CXFA_Node::GetBarcodeAttribute_TextLocation() { - Optional<XFA_AttributeEnum> textLocation = - GetUIChildNode()->JSObject()->TryEnum(XFA_Attribute::TextLocation, true); - if (!textLocation) - return {}; - - switch (*textLocation) { - case XFA_AttributeEnum::None: - return {BC_TEXT_LOC_NONE}; - case XFA_AttributeEnum::Above: - return {BC_TEXT_LOC_ABOVE}; - case XFA_AttributeEnum::Below: - return {BC_TEXT_LOC_BELOW}; - case XFA_AttributeEnum::AboveEmbedded: - return {BC_TEXT_LOC_ABOVEEMBED}; - case XFA_AttributeEnum::BelowEmbedded: - return {BC_TEXT_LOC_BELOWEMBED}; - default: - break; - } - return {}; -} - -Optional<bool> CXFA_Node::GetBarcodeAttribute_Truncate() { - return GetUIChildNode()->JSObject()->TryBoolean(XFA_Attribute::Truncate, - true); -} - -Optional<int8_t> CXFA_Node::GetBarcodeAttribute_WideNarrowRatio() { - Optional<WideString> wsWideNarrowRatio = - GetUIChildNode()->JSObject()->TryCData(XFA_Attribute::WideNarrowRatio, - true); - if (!wsWideNarrowRatio) - return {}; - - Optional<size_t> ptPos = wsWideNarrowRatio->Find(':'); - if (!ptPos) - return {static_cast<int8_t>(FXSYS_wtoi(wsWideNarrowRatio->c_str()))}; - - int32_t fB = FXSYS_wtoi( - wsWideNarrowRatio->Right(wsWideNarrowRatio->GetLength() - (*ptPos + 1)) - .c_str()); - if (!fB) - return {0}; - - int32_t fA = FXSYS_wtoi(wsWideNarrowRatio->Left(*ptPos).c_str()); - float result = static_cast<float>(fA) / static_cast<float>(fB); - return {static_cast<int8_t>(result)}; -} - std::pair<XFA_FFWidgetType, CXFA_Ui*> CXFA_Node::CreateChildUIAndValueNodesIfNeeded() { XFA_Element eType = GetElementType(); |