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/fxfa/app/xfa_ffbarcode.h" | 7 #include "xfa/fxfa/app/xfa_ffbarcode.h" |
8 | 8 |
9 #include "core/fxcrt/fx_ext.h" | 9 #include "core/fxcrt/fx_ext.h" |
| 10 #include "third_party/base/ptr_util.h" |
10 #include "xfa/fwl/core/cfwl_barcode.h" | 11 #include "xfa/fwl/core/cfwl_barcode.h" |
11 #include "xfa/fwl/core/fwl_noteimp.h" | 12 #include "xfa/fwl/core/fwl_noteimp.h" |
12 #include "xfa/fwl/core/ifwl_app.h" | 13 #include "xfa/fwl/core/ifwl_app.h" |
| 14 #include "xfa/fxfa/app/cxfa_fffielddelegate.h" |
13 #include "xfa/fxfa/app/xfa_fffield.h" | 15 #include "xfa/fxfa/app/xfa_fffield.h" |
14 #include "xfa/fxfa/app/xfa_fftextedit.h" | 16 #include "xfa/fxfa/app/xfa_fftextedit.h" |
15 #include "xfa/fxfa/app/xfa_fwladapter.h" | 17 #include "xfa/fxfa/app/xfa_fwladapter.h" |
16 #include "xfa/fxfa/xfa_ffpageview.h" | 18 #include "xfa/fxfa/xfa_ffpageview.h" |
17 #include "xfa/fxfa/xfa_ffwidget.h" | 19 #include "xfa/fxfa/xfa_ffwidget.h" |
18 | 20 |
19 namespace { | 21 namespace { |
20 | 22 |
21 const XFA_BARCODETYPEENUMINFO g_XFABarCodeTypeEnumData[] = { | 23 const XFA_BARCODETYPEENUMINFO g_XFABarCodeTypeEnumData[] = { |
22 {0x7fb4a18, L"ean13", XFA_BARCODETYPE_ean13, BC_EAN13}, | 24 {0x7fb4a18, L"ean13", XFA_BARCODETYPE_ean13, BC_EAN13}, |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 FX_BOOL CXFA_FFBarcode::LoadWidget() { | 127 FX_BOOL CXFA_FFBarcode::LoadWidget() { |
126 CFWL_Barcode* pFWLBarcode = new CFWL_Barcode(GetFWLApp()); | 128 CFWL_Barcode* pFWLBarcode = new CFWL_Barcode(GetFWLApp()); |
127 pFWLBarcode->Initialize(); | 129 pFWLBarcode->Initialize(); |
128 | 130 |
129 m_pNormalWidget = pFWLBarcode; | 131 m_pNormalWidget = pFWLBarcode; |
130 m_pNormalWidget->SetLayoutItem(this); | 132 m_pNormalWidget->SetLayoutItem(this); |
131 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); | 133 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); |
132 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); | 134 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); |
133 pNoteDriver->RegisterEventTarget(pWidget, pWidget); | 135 pNoteDriver->RegisterEventTarget(pWidget, pWidget); |
134 | 136 |
135 m_pOldDelegate = m_pNormalWidget->GetCurrentDelegate(); | 137 m_pNormalWidget->SetDelegate(pdfium::MakeUnique<CXFA_FFFieldDelegate>( |
136 m_pNormalWidget->SetCurrentDelegate(this); | 138 m_pNormalWidget->ReleaseDelegate(), this)); |
137 m_pNormalWidget->LockUpdate(); | 139 m_pNormalWidget->LockUpdate(); |
138 | 140 |
139 CFX_WideString wsText; | 141 CFX_WideString wsText; |
140 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); | 142 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); |
141 pFWLBarcode->SetText(wsText); | 143 pFWLBarcode->SetText(wsText); |
142 UpdateWidgetProperty(); | 144 UpdateWidgetProperty(); |
143 m_pNormalWidget->UnlockUpdate(); | 145 m_pNormalWidget->UnlockUpdate(); |
144 return CXFA_FFField::LoadWidget(); | 146 return CXFA_FFField::LoadWidget(); |
145 } | 147 } |
146 void CXFA_FFBarcode::RenderWidget(CFX_Graphics* pGS, | 148 void CXFA_FFBarcode::RenderWidget(CFX_Graphics* pGS, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 } | 241 } |
240 FX_BOOL CXFA_FFBarcode::OnRButtonDown(uint32_t dwFlags, | 242 FX_BOOL CXFA_FFBarcode::OnRButtonDown(uint32_t dwFlags, |
241 FX_FLOAT fx, | 243 FX_FLOAT fx, |
242 FX_FLOAT fy) { | 244 FX_FLOAT fy) { |
243 CFWL_Barcode* pBarCodeWidget = (CFWL_Barcode*)m_pNormalWidget; | 245 CFWL_Barcode* pBarCodeWidget = (CFWL_Barcode*)m_pNormalWidget; |
244 if (!pBarCodeWidget || pBarCodeWidget->IsProtectedType()) { | 246 if (!pBarCodeWidget || pBarCodeWidget->IsProtectedType()) { |
245 return FALSE; | 247 return FALSE; |
246 } | 248 } |
247 return CXFA_FFTextEdit::OnRButtonDown(dwFlags, fx, fy); | 249 return CXFA_FFTextEdit::OnRButtonDown(dwFlags, fx, fy); |
248 } | 250 } |
OLD | NEW |