| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fwl/core/ifwl_barcode.h" | 7 #include "xfa/fwl/core/ifwl_barcode.h" |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 59 } |
| 60 IFWL_Edit::DrawWidget(pGraphics, pMatrix); | 60 IFWL_Edit::DrawWidget(pGraphics, pMatrix); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void IFWL_Barcode::GenerateBarcodeImageCache() { | 63 void IFWL_Barcode::GenerateBarcodeImageCache() { |
| 64 if ((m_dwStatus & XFA_BCS_NeedUpdate) == 0) | 64 if ((m_dwStatus & XFA_BCS_NeedUpdate) == 0) |
| 65 return; | 65 return; |
| 66 | 66 |
| 67 m_dwStatus = 0; | 67 m_dwStatus = 0; |
| 68 CreateBarcodeEngine(); | 68 CreateBarcodeEngine(); |
| 69 IFWL_Barcode::DataProvider* pData = | |
| 70 static_cast<IFWL_Barcode::DataProvider*>(m_pProperties->m_pDataProvider); | |
| 71 if (!pData) | |
| 72 return; | |
| 73 if (!m_pBarcodeEngine) | 69 if (!m_pBarcodeEngine) |
| 74 return; | 70 return; |
| 75 | 71 |
| 76 CFX_WideString wsText; | 72 CFX_WideString wsText; |
| 77 GetText(wsText); | 73 GetText(wsText); |
| 78 | 74 |
| 79 CFWL_ThemePart part; | 75 CFWL_ThemePart part; |
| 80 part.m_pWidget = this; | 76 part.m_pWidget = this; |
| 81 | 77 |
| 82 IFWL_ThemeProvider* pTheme = GetAvailableTheme(); | 78 IFWL_ThemeProvider* pTheme = GetAvailableTheme(); |
| 83 CFGAS_GEFont* pFont = static_cast<CFGAS_GEFont*>( | 79 CFGAS_GEFont* pFont = static_cast<CFGAS_GEFont*>( |
| 84 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Font)); | 80 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Font)); |
| 85 CFX_Font* pCXFont = pFont ? pFont->GetDevFont() : nullptr; | 81 CFX_Font* pCXFont = pFont ? pFont->GetDevFont() : nullptr; |
| 86 if (pCXFont) | 82 if (pCXFont) |
| 87 m_pBarcodeEngine->SetFont(pCXFont); | 83 m_pBarcodeEngine->SetFont(pCXFont); |
| 88 | 84 |
| 89 FX_FLOAT* pFontSize = static_cast<FX_FLOAT*>( | 85 FX_FLOAT* pFontSize = static_cast<FX_FLOAT*>( |
| 90 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::FontSize)); | 86 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::FontSize)); |
| 91 if (pFontSize) | 87 if (pFontSize) |
| 92 m_pBarcodeEngine->SetFontSize(*pFontSize); | 88 m_pBarcodeEngine->SetFontSize(*pFontSize); |
| 93 | 89 |
| 94 FX_ARGB* pFontColor = static_cast<FX_ARGB*>( | 90 FX_ARGB* pFontColor = static_cast<FX_ARGB*>( |
| 95 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TextColor)); | 91 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TextColor)); |
| 96 if (pFontColor) | 92 if (pFontColor) |
| 97 m_pBarcodeEngine->SetFontColor(*pFontColor); | 93 m_pBarcodeEngine->SetFontColor(*pFontColor); |
| 98 | 94 |
| 99 m_pBarcodeEngine->SetHeight(int32_t(GetRTClient().height)); | 95 m_pBarcodeEngine->SetHeight(int32_t(GetRTClient().height)); |
| 100 m_pBarcodeEngine->SetWidth(int32_t(GetRTClient().width)); | 96 m_pBarcodeEngine->SetWidth(int32_t(GetRTClient().width)); |
| 101 uint32_t dwAttributeMask = pData->GetBarcodeAttributeMask(); | 97 uint32_t dwAttributeMask = m_pDataProvider->GetBarcodeAttributeMask(); |
| 102 if (dwAttributeMask & FWL_BCDATTRIBUTE_CHARENCODING) | 98 if (dwAttributeMask & FWL_BCDATTRIBUTE_CHARENCODING) |
| 103 m_pBarcodeEngine->SetCharEncoding(pData->GetCharEncoding()); | 99 m_pBarcodeEngine->SetCharEncoding(m_pDataProvider->GetCharEncoding()); |
| 104 if (dwAttributeMask & FWL_BCDATTRIBUTE_MODULEHEIGHT) | 100 if (dwAttributeMask & FWL_BCDATTRIBUTE_MODULEHEIGHT) |
| 105 m_pBarcodeEngine->SetModuleHeight(pData->GetModuleHeight()); | 101 m_pBarcodeEngine->SetModuleHeight(m_pDataProvider->GetModuleHeight()); |
| 106 if (dwAttributeMask & FWL_BCDATTRIBUTE_MODULEWIDTH) | 102 if (dwAttributeMask & FWL_BCDATTRIBUTE_MODULEWIDTH) |
| 107 m_pBarcodeEngine->SetModuleWidth(pData->GetModuleWidth()); | 103 m_pBarcodeEngine->SetModuleWidth(m_pDataProvider->GetModuleWidth()); |
| 108 if (dwAttributeMask & FWL_BCDATTRIBUTE_DATALENGTH) | 104 if (dwAttributeMask & FWL_BCDATTRIBUTE_DATALENGTH) |
| 109 m_pBarcodeEngine->SetDataLength(pData->GetDataLength()); | 105 m_pBarcodeEngine->SetDataLength(m_pDataProvider->GetDataLength()); |
| 110 if (dwAttributeMask & FWL_BCDATTRIBUTE_CALCHECKSUM) | 106 if (dwAttributeMask & FWL_BCDATTRIBUTE_CALCHECKSUM) |
| 111 m_pBarcodeEngine->SetCalChecksum(pData->GetCalChecksum()); | 107 m_pBarcodeEngine->SetCalChecksum(m_pDataProvider->GetCalChecksum()); |
| 112 if (dwAttributeMask & FWL_BCDATTRIBUTE_PRINTCHECKSUM) | 108 if (dwAttributeMask & FWL_BCDATTRIBUTE_PRINTCHECKSUM) |
| 113 m_pBarcodeEngine->SetPrintChecksum(pData->GetPrintChecksum()); | 109 m_pBarcodeEngine->SetPrintChecksum(m_pDataProvider->GetPrintChecksum()); |
| 114 if (dwAttributeMask & FWL_BCDATTRIBUTE_TEXTLOCATION) | 110 if (dwAttributeMask & FWL_BCDATTRIBUTE_TEXTLOCATION) |
| 115 m_pBarcodeEngine->SetTextLocation(pData->GetTextLocation()); | 111 m_pBarcodeEngine->SetTextLocation(m_pDataProvider->GetTextLocation()); |
| 116 if (dwAttributeMask & FWL_BCDATTRIBUTE_WIDENARROWRATIO) | 112 if (dwAttributeMask & FWL_BCDATTRIBUTE_WIDENARROWRATIO) |
| 117 m_pBarcodeEngine->SetWideNarrowRatio(pData->GetWideNarrowRatio()); | 113 m_pBarcodeEngine->SetWideNarrowRatio(m_pDataProvider->GetWideNarrowRatio()); |
| 118 if (dwAttributeMask & FWL_BCDATTRIBUTE_STARTCHAR) | 114 if (dwAttributeMask & FWL_BCDATTRIBUTE_STARTCHAR) |
| 119 m_pBarcodeEngine->SetStartChar(pData->GetStartChar()); | 115 m_pBarcodeEngine->SetStartChar(m_pDataProvider->GetStartChar()); |
| 120 if (dwAttributeMask & FWL_BCDATTRIBUTE_ENDCHAR) | 116 if (dwAttributeMask & FWL_BCDATTRIBUTE_ENDCHAR) |
| 121 m_pBarcodeEngine->SetEndChar(pData->GetEndChar()); | 117 m_pBarcodeEngine->SetEndChar(m_pDataProvider->GetEndChar()); |
| 122 if (dwAttributeMask & FWL_BCDATTRIBUTE_VERSION) | 118 if (dwAttributeMask & FWL_BCDATTRIBUTE_VERSION) |
| 123 m_pBarcodeEngine->SetVersion(pData->GetVersion()); | 119 m_pBarcodeEngine->SetVersion(m_pDataProvider->GetVersion()); |
| 124 if (dwAttributeMask & FWL_BCDATTRIBUTE_ECLEVEL) | 120 if (dwAttributeMask & FWL_BCDATTRIBUTE_ECLEVEL) { |
| 125 m_pBarcodeEngine->SetErrorCorrectionLevel(pData->GetErrorCorrectionLevel()); | 121 m_pBarcodeEngine->SetErrorCorrectionLevel( |
| 122 m_pDataProvider->GetErrorCorrectionLevel()); |
| 123 } |
| 126 if (dwAttributeMask & FWL_BCDATTRIBUTE_TRUNCATED) | 124 if (dwAttributeMask & FWL_BCDATTRIBUTE_TRUNCATED) |
| 127 m_pBarcodeEngine->SetTruncated(pData->GetTruncated()); | 125 m_pBarcodeEngine->SetTruncated(m_pDataProvider->GetTruncated()); |
| 128 | 126 |
| 129 int32_t errorCode = 0; | 127 int32_t errorCode = 0; |
| 130 m_dwStatus = m_pBarcodeEngine->Encode(wsText.AsStringC(), true, errorCode) | 128 m_dwStatus = m_pBarcodeEngine->Encode(wsText.AsStringC(), true, errorCode) |
| 131 ? XFA_BCS_EncodeSuccess | 129 ? XFA_BCS_EncodeSuccess |
| 132 : 0; | 130 : 0; |
| 133 } | 131 } |
| 134 | 132 |
| 135 void IFWL_Barcode::CreateBarcodeEngine() { | 133 void IFWL_Barcode::CreateBarcodeEngine() { |
| 136 if (m_pBarcodeEngine || m_type == BC_UNKNOWN) | 134 if (m_pBarcodeEngine || m_type == BC_UNKNOWN) |
| 137 return; | 135 return; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 168 return false; | 166 return false; |
| 169 } | 167 } |
| 170 | 168 |
| 171 void IFWL_Barcode::OnProcessEvent(CFWL_Event* pEvent) { | 169 void IFWL_Barcode::OnProcessEvent(CFWL_Event* pEvent) { |
| 172 if (pEvent->GetClassID() == CFWL_EventType::TextChanged) { | 170 if (pEvent->GetClassID() == CFWL_EventType::TextChanged) { |
| 173 m_pBarcodeEngine.reset(); | 171 m_pBarcodeEngine.reset(); |
| 174 m_dwStatus = XFA_BCS_NeedUpdate; | 172 m_dwStatus = XFA_BCS_NeedUpdate; |
| 175 } | 173 } |
| 176 IFWL_Edit::OnProcessEvent(pEvent); | 174 IFWL_Edit::OnProcessEvent(pEvent); |
| 177 } | 175 } |
| OLD | NEW |