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

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: complete changes 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
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())
Lei Zhang 2016/08/05 17:34:18 auto* pWidget = GetWidget(); if (pWidget) pWidge
Wei Li 2016/08/08 23:55:37 Done.
38 return; 46 return;
39 static_cast<IFWL_Barcode*>(m_pIface)->SetType(type); 47 GetWidget()->SetType(type);
40 } 48 }
41 49
42 FX_BOOL CFWL_Barcode::IsProtectedType() { 50 FX_BOOL CFWL_Barcode::IsProtectedType() {
43 if (!m_pIface) 51 if (!GetWidget())
Lei Zhang 2016/08/05 17:34:18 auto* pWidget = GetWidget(); return pWidget ? pWid
Wei Li 2016/08/08 23:55:37 Done.
44 return 0; 52 return 0;
45 return static_cast<IFWL_Barcode*>(m_pIface)->IsProtectedType(); 53 return GetWidget()->IsProtectedType();
46 } 54 }
47 55
48 CFWL_Barcode::CFWL_BarcodeDP::CFWL_BarcodeDP() 56 CFWL_Barcode::CFWL_BarcodeDP::CFWL_BarcodeDP()
49 : m_dwAttributeMask(FWL_BCDATTRIBUTE_NONE) {} 57 : m_dwAttributeMask(FWL_BCDATTRIBUTE_NONE) {}
50 58
51 FWL_Error CFWL_Barcode::CFWL_BarcodeDP::GetCaption(IFWL_Widget* pWidget, 59 FWL_Error CFWL_Barcode::CFWL_BarcodeDP::GetCaption(IFWL_Widget* pWidget,
52 CFX_WideString& wsCaption) { 60 CFX_WideString& wsCaption) {
53 return FWL_Error::Succeeded; 61 return FWL_Error::Succeeded;
54 } 62 }
55 63
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 return m_nECLevel; 109 return m_nECLevel;
102 } 110 }
103 111
104 FX_BOOL CFWL_Barcode::CFWL_BarcodeDP::GetTruncated() { 112 FX_BOOL CFWL_Barcode::CFWL_BarcodeDP::GetTruncated() {
105 return m_bTruncated; 113 return m_bTruncated;
106 } 114 }
107 115
108 uint32_t CFWL_Barcode::CFWL_BarcodeDP::GetBarcodeAttributeMask() { 116 uint32_t CFWL_Barcode::CFWL_BarcodeDP::GetBarcodeAttributeMask() {
109 return m_dwAttributeMask; 117 return m_dwAttributeMask;
110 } 118 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698