Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(450)

Side by Side Diff: xfa/fwl/lightwidget/cfwl_barcode.cpp

Issue 2209153002: Use virtual function to retrieve interface pointer (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: address comment Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fwl/lightwidget/cfwl_barcode.h ('k') | xfa/fwl/lightwidget/cfwl_checkbox.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/lightwidget/cfwl_barcode.h" 7 #include "xfa/fwl/lightwidget/cfwl_barcode.h"
8 8
9 #include <memory> 9 #include <memory>
10 10
11 IFWL_Barcode* CFWL_Barcode::GetWidget() {
12 return static_cast<IFWL_Barcode*>(m_pIface.get());
13 }
14
15 const IFWL_Barcode* CFWL_Barcode::GetWidget() const {
16 return static_cast<IFWL_Barcode*>(m_pIface.get());
17 }
18
11 CFWL_Barcode* CFWL_Barcode::Create() { 19 CFWL_Barcode* CFWL_Barcode::Create() {
12 return new CFWL_Barcode; 20 return new CFWL_Barcode;
13 } 21 }
14 22
15 FWL_Error CFWL_Barcode::Initialize(const CFWL_WidgetProperties* pProperties) { 23 FWL_Error CFWL_Barcode::Initialize(const CFWL_WidgetProperties* pProperties) {
16 if (m_pIface) 24 if (m_pIface)
17 return FWL_Error::Indefinite; 25 return FWL_Error::Indefinite;
18 if (pProperties) { 26 if (pProperties) {
19 *m_pProperties = *pProperties; 27 *m_pProperties = *pProperties;
20 } 28 }
21 std::unique_ptr<IFWL_Barcode> pBarcode(IFWL_Barcode::Create( 29 std::unique_ptr<IFWL_Barcode> pBarcode(IFWL_Barcode::Create(
22 m_pProperties->MakeWidgetImpProperties(&m_barcodeData))); 30 m_pProperties->MakeWidgetImpProperties(&m_barcodeData)));
23 FWL_Error ret = pBarcode->Initialize(); 31 FWL_Error ret = pBarcode->Initialize();
24 if (ret != FWL_Error::Succeeded) { 32 if (ret != FWL_Error::Succeeded) {
25 return ret; 33 return ret;
26 } 34 }
27 m_pIface = pBarcode.release(); 35 m_pIface = std::move(pBarcode);
28 CFWL_Widget::Initialize(); 36 CFWL_Widget::Initialize();
29 return FWL_Error::Succeeded; 37 return FWL_Error::Succeeded;
30 } 38 }
31 39
32 CFWL_Barcode::CFWL_Barcode() {} 40 CFWL_Barcode::CFWL_Barcode() {}
33 41
34 CFWL_Barcode::~CFWL_Barcode() {} 42 CFWL_Barcode::~CFWL_Barcode() {}
35 43
36 void CFWL_Barcode::SetType(BC_TYPE type) { 44 void CFWL_Barcode::SetType(BC_TYPE type) {
37 if (!m_pIface) 45 if (GetWidget())
38 return; 46 GetWidget()->SetType(type);
39 static_cast<IFWL_Barcode*>(m_pIface)->SetType(type);
40 } 47 }
41 48
42 FX_BOOL CFWL_Barcode::IsProtectedType() { 49 FX_BOOL CFWL_Barcode::IsProtectedType() {
43 if (!m_pIface) 50 return GetWidget() ? GetWidget()->IsProtectedType() : FALSE;
44 return 0;
45 return static_cast<IFWL_Barcode*>(m_pIface)->IsProtectedType();
46 } 51 }
47 52
48 CFWL_Barcode::CFWL_BarcodeDP::CFWL_BarcodeDP() 53 CFWL_Barcode::CFWL_BarcodeDP::CFWL_BarcodeDP()
49 : m_dwAttributeMask(FWL_BCDATTRIBUTE_NONE) {} 54 : m_dwAttributeMask(FWL_BCDATTRIBUTE_NONE) {}
50 55
51 FWL_Error CFWL_Barcode::CFWL_BarcodeDP::GetCaption(IFWL_Widget* pWidget, 56 FWL_Error CFWL_Barcode::CFWL_BarcodeDP::GetCaption(IFWL_Widget* pWidget,
52 CFX_WideString& wsCaption) { 57 CFX_WideString& wsCaption) {
53 return FWL_Error::Succeeded; 58 return FWL_Error::Succeeded;
54 } 59 }
55 60
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 return m_nECLevel; 106 return m_nECLevel;
102 } 107 }
103 108
104 FX_BOOL CFWL_Barcode::CFWL_BarcodeDP::GetTruncated() { 109 FX_BOOL CFWL_Barcode::CFWL_BarcodeDP::GetTruncated() {
105 return m_bTruncated; 110 return m_bTruncated;
106 } 111 }
107 112
108 uint32_t CFWL_Barcode::CFWL_BarcodeDP::GetBarcodeAttributeMask() { 113 uint32_t CFWL_Barcode::CFWL_BarcodeDP::GetBarcodeAttributeMask() {
109 return m_dwAttributeMask; 114 return m_dwAttributeMask;
110 } 115 }
OLDNEW
« no previous file with comments | « xfa/fwl/lightwidget/cfwl_barcode.h ('k') | xfa/fwl/lightwidget/cfwl_checkbox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698