Use virtual function to retrieve interface pointer
Use virtual function to return the actual interface type instead
of the base interface type to avoid a lot of casts.
Also tidy up CFWL_Widget by encapsulating variables, and use
smart pointers for class owned member variables.
Review-Url: https://codereview.chromium.org/2209153002
diff --git a/xfa/fwl/lightwidget/cfwl_barcode.h b/xfa/fwl/lightwidget/cfwl_barcode.h
index 466ff6e..cf394f6 100644
--- a/xfa/fwl/lightwidget/cfwl_barcode.h
+++ b/xfa/fwl/lightwidget/cfwl_barcode.h
@@ -17,6 +17,10 @@
class CFWL_Barcode : public CFWL_Edit {
public:
static CFWL_Barcode* Create();
+
+ IFWL_Barcode* GetWidget() override;
+ const IFWL_Barcode* GetWidget() const override;
+
FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = nullptr);
void SetType(BC_TYPE type);
FX_BOOL IsProtectedType();
@@ -36,7 +40,7 @@
void SetDataLength(int32_t dataLength) {
m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_DATALENGTH;
m_barcodeData.m_nDataLength = dataLength;
- static_cast<IFWL_Barcode*>(m_pIface)->SetLimit(dataLength);
+ GetWidget()->SetLimit(dataLength);
}
void SetCalChecksum(int32_t calChecksum) {
m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_CALCHECKSUM;