| Index: xfa/fwl/core/ifwl_barcode.cpp
|
| diff --git a/xfa/fwl/core/ifwl_barcode.cpp b/xfa/fwl/core/ifwl_barcode.cpp
|
| deleted file mode 100644
|
| index b4cd13a6c14e43521c425f1263df8d0515bbfc40..0000000000000000000000000000000000000000
|
| --- a/xfa/fwl/core/ifwl_barcode.cpp
|
| +++ /dev/null
|
| @@ -1,175 +0,0 @@
|
| -// Copyright 2014 PDFium Authors. All rights reserved.
|
| -// Use of this source code is governed by a BSD-style license that can be
|
| -// found in the LICENSE file.
|
| -
|
| -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
|
| -
|
| -#include "xfa/fwl/core/ifwl_barcode.h"
|
| -
|
| -#include <utility>
|
| -
|
| -#include "third_party/base/ptr_util.h"
|
| -#include "xfa/fgas/font/cfgas_gefont.h"
|
| -#include "xfa/fwl/core/cfwl_notedriver.h"
|
| -#include "xfa/fwl/core/cfwl_themepart.h"
|
| -#include "xfa/fwl/core/cfx_barcode.h"
|
| -#include "xfa/fwl/core/ifwl_themeprovider.h"
|
| -
|
| -IFWL_Barcode::IFWL_Barcode(const CFWL_App* app,
|
| - std::unique_ptr<CFWL_WidgetProperties> properties)
|
| - : IFWL_Edit(app, std::move(properties), nullptr),
|
| - m_dwStatus(0),
|
| - m_type(BC_UNKNOWN) {}
|
| -
|
| -IFWL_Barcode::~IFWL_Barcode() {}
|
| -
|
| -FWL_Type IFWL_Barcode::GetClassID() const {
|
| - return FWL_Type::Barcode;
|
| -}
|
| -
|
| -void IFWL_Barcode::Update() {
|
| - if (IsLocked())
|
| - return;
|
| -
|
| - IFWL_Edit::Update();
|
| - GenerateBarcodeImageCache();
|
| -}
|
| -
|
| -void IFWL_Barcode::DrawWidget(CFX_Graphics* pGraphics,
|
| - const CFX_Matrix* pMatrix) {
|
| - if (!pGraphics)
|
| - return;
|
| - if (!m_pProperties->m_pThemeProvider)
|
| - return;
|
| - if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
|
| - GenerateBarcodeImageCache();
|
| - if (!m_pBarcodeEngine || (m_dwStatus & XFA_BCS_EncodeSuccess) == 0)
|
| - return;
|
| -
|
| - CFX_Matrix mt;
|
| - mt.e = GetRTClient().left;
|
| - mt.f = GetRTClient().top;
|
| - if (pMatrix)
|
| - mt.Concat(*pMatrix);
|
| -
|
| - int32_t errorCode = 0;
|
| - m_pBarcodeEngine->RenderDevice(pGraphics->GetRenderDevice(), pMatrix,
|
| - errorCode);
|
| - return;
|
| - }
|
| - IFWL_Edit::DrawWidget(pGraphics, pMatrix);
|
| -}
|
| -
|
| -void IFWL_Barcode::GenerateBarcodeImageCache() {
|
| - if ((m_dwStatus & XFA_BCS_NeedUpdate) == 0)
|
| - return;
|
| -
|
| - m_dwStatus = 0;
|
| - CreateBarcodeEngine();
|
| - if (!m_pBarcodeEngine)
|
| - return;
|
| -
|
| - CFX_WideString wsText;
|
| - GetText(wsText);
|
| -
|
| - CFWL_ThemePart part;
|
| - part.m_pWidget = this;
|
| -
|
| - IFWL_ThemeProvider* pTheme = GetAvailableTheme();
|
| - CFGAS_GEFont* pFont = static_cast<CFGAS_GEFont*>(
|
| - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Font));
|
| - CFX_Font* pCXFont = pFont ? pFont->GetDevFont() : nullptr;
|
| - if (pCXFont)
|
| - m_pBarcodeEngine->SetFont(pCXFont);
|
| -
|
| - FX_FLOAT* pFontSize = static_cast<FX_FLOAT*>(
|
| - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::FontSize));
|
| - if (pFontSize)
|
| - m_pBarcodeEngine->SetFontSize(*pFontSize);
|
| -
|
| - FX_ARGB* pFontColor = static_cast<FX_ARGB*>(
|
| - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TextColor));
|
| - if (pFontColor)
|
| - m_pBarcodeEngine->SetFontColor(*pFontColor);
|
| -
|
| - m_pBarcodeEngine->SetHeight(int32_t(GetRTClient().height));
|
| - m_pBarcodeEngine->SetWidth(int32_t(GetRTClient().width));
|
| - uint32_t dwAttributeMask = m_pDataProvider->GetBarcodeAttributeMask();
|
| - if (dwAttributeMask & FWL_BCDATTRIBUTE_CHARENCODING)
|
| - m_pBarcodeEngine->SetCharEncoding(m_pDataProvider->GetCharEncoding());
|
| - if (dwAttributeMask & FWL_BCDATTRIBUTE_MODULEHEIGHT)
|
| - m_pBarcodeEngine->SetModuleHeight(m_pDataProvider->GetModuleHeight());
|
| - if (dwAttributeMask & FWL_BCDATTRIBUTE_MODULEWIDTH)
|
| - m_pBarcodeEngine->SetModuleWidth(m_pDataProvider->GetModuleWidth());
|
| - if (dwAttributeMask & FWL_BCDATTRIBUTE_DATALENGTH)
|
| - m_pBarcodeEngine->SetDataLength(m_pDataProvider->GetDataLength());
|
| - if (dwAttributeMask & FWL_BCDATTRIBUTE_CALCHECKSUM)
|
| - m_pBarcodeEngine->SetCalChecksum(m_pDataProvider->GetCalChecksum());
|
| - if (dwAttributeMask & FWL_BCDATTRIBUTE_PRINTCHECKSUM)
|
| - m_pBarcodeEngine->SetPrintChecksum(m_pDataProvider->GetPrintChecksum());
|
| - if (dwAttributeMask & FWL_BCDATTRIBUTE_TEXTLOCATION)
|
| - m_pBarcodeEngine->SetTextLocation(m_pDataProvider->GetTextLocation());
|
| - if (dwAttributeMask & FWL_BCDATTRIBUTE_WIDENARROWRATIO)
|
| - m_pBarcodeEngine->SetWideNarrowRatio(m_pDataProvider->GetWideNarrowRatio());
|
| - if (dwAttributeMask & FWL_BCDATTRIBUTE_STARTCHAR)
|
| - m_pBarcodeEngine->SetStartChar(m_pDataProvider->GetStartChar());
|
| - if (dwAttributeMask & FWL_BCDATTRIBUTE_ENDCHAR)
|
| - m_pBarcodeEngine->SetEndChar(m_pDataProvider->GetEndChar());
|
| - if (dwAttributeMask & FWL_BCDATTRIBUTE_VERSION)
|
| - m_pBarcodeEngine->SetVersion(m_pDataProvider->GetVersion());
|
| - if (dwAttributeMask & FWL_BCDATTRIBUTE_ECLEVEL) {
|
| - m_pBarcodeEngine->SetErrorCorrectionLevel(
|
| - m_pDataProvider->GetErrorCorrectionLevel());
|
| - }
|
| - if (dwAttributeMask & FWL_BCDATTRIBUTE_TRUNCATED)
|
| - m_pBarcodeEngine->SetTruncated(m_pDataProvider->GetTruncated());
|
| -
|
| - int32_t errorCode = 0;
|
| - m_dwStatus = m_pBarcodeEngine->Encode(wsText.AsStringC(), true, errorCode)
|
| - ? XFA_BCS_EncodeSuccess
|
| - : 0;
|
| -}
|
| -
|
| -void IFWL_Barcode::CreateBarcodeEngine() {
|
| - if (m_pBarcodeEngine || m_type == BC_UNKNOWN)
|
| - return;
|
| -
|
| - std::unique_ptr<CFX_Barcode> pBarcode(new CFX_Barcode);
|
| - if (pBarcode->Create(m_type))
|
| - m_pBarcodeEngine = std::move(pBarcode);
|
| -}
|
| -
|
| -void IFWL_Barcode::SetType(BC_TYPE type) {
|
| - if (m_type == type)
|
| - return;
|
| -
|
| - m_pBarcodeEngine.reset();
|
| - m_type = type;
|
| - m_dwStatus = XFA_BCS_NeedUpdate;
|
| -}
|
| -
|
| -void IFWL_Barcode::SetText(const CFX_WideString& wsText) {
|
| - m_pBarcodeEngine.reset();
|
| - m_dwStatus = XFA_BCS_NeedUpdate;
|
| - IFWL_Edit::SetText(wsText);
|
| -}
|
| -
|
| -bool IFWL_Barcode::IsProtectedType() const {
|
| - if (!m_pBarcodeEngine)
|
| - return true;
|
| -
|
| - BC_TYPE tEngineType = m_pBarcodeEngine->GetType();
|
| - if (tEngineType == BC_QR_CODE || tEngineType == BC_PDF417 ||
|
| - tEngineType == BC_DATAMATRIX) {
|
| - return true;
|
| - }
|
| - return false;
|
| -}
|
| -
|
| -void IFWL_Barcode::OnProcessEvent(CFWL_Event* pEvent) {
|
| - if (pEvent->GetClassID() == CFWL_EventType::TextChanged) {
|
| - m_pBarcodeEngine.reset();
|
| - m_dwStatus = XFA_BCS_NeedUpdate;
|
| - }
|
| - IFWL_Edit::OnProcessEvent(pEvent);
|
| -}
|
|
|