diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-12-02 12:18:30 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-12-02 12:18:30 -0800 |
commit | 8677d53e8730efc20c80a1ad75be4e10a9db21d0 (patch) | |
tree | 8bec78dcb7c58ef7e5f6d360da1a1e4337d54396 /xfa/src | |
parent | cd4651d0fcab03c062112e9a2bbcc3aee30890c4 (diff) | |
download | pdfium-8677d53e8730efc20c80a1ad75be4e10a9db21d0.tar.xz |
Add MakeWidgetImpProperties() helper method.
Remove duplicate code from 10 places.
R=ochang@chromium.org
Review URL: https://codereview.chromium.org/1486283002 .
Diffstat (limited to 'xfa/src')
-rw-r--r-- | xfa/src/fwl/src/lightwidget/barcode.cpp | 18 | ||||
-rw-r--r-- | xfa/src/fwl/src/lightwidget/caret.cpp | 17 | ||||
-rw-r--r-- | xfa/src/fwl/src/lightwidget/combobox.cpp | 18 | ||||
-rw-r--r-- | xfa/src/fwl/src/lightwidget/datetimepicker.cpp | 19 | ||||
-rw-r--r-- | xfa/src/fwl/src/lightwidget/edit.cpp | 17 | ||||
-rw-r--r-- | xfa/src/fwl/src/lightwidget/listbox.cpp | 18 | ||||
-rw-r--r-- | xfa/src/fwl/src/lightwidget/picturebox.cpp | 18 | ||||
-rw-r--r-- | xfa/src/fwl/src/lightwidget/pushbutton.cpp | 18 | ||||
-rw-r--r-- | xfa/src/fwl/src/lightwidget/scrollbar.cpp | 17 | ||||
-rw-r--r-- | xfa/src/fwl/src/lightwidget/tooltipctrl.cpp | 18 | ||||
-rw-r--r-- | xfa/src/fwl/src/lightwidget/widget.cpp | 16 |
11 files changed, 57 insertions, 137 deletions
diff --git a/xfa/src/fwl/src/lightwidget/barcode.cpp b/xfa/src/fwl/src/lightwidget/barcode.cpp index 9c336ce81e..7d7d5a483d 100644 --- a/xfa/src/fwl/src/lightwidget/barcode.cpp +++ b/xfa/src/fwl/src/lightwidget/barcode.cpp @@ -13,21 +13,11 @@ FWL_ERR CFWL_Barcode::Initialize(const CFWL_WidgetProperties* pProperties) { if (pProperties) {
*m_pProperties = *pProperties;
}
- CFWL_WidgetImpProperties prop;
- prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
- prop.m_rtWidget = m_pProperties->m_rtWidget;
- prop.m_dwStyles = m_pProperties->m_dwStyles;
- prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
- prop.m_dwStates = m_pProperties->m_dwStates;
- prop.m_pDataProvider = &m_barcodeData;
- if (m_pProperties->m_pParent) {
- prop.m_pParent = m_pProperties->m_pParent->GetWidget();
- }
- if (m_pProperties->m_pOwner) {
- prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
- }
m_pIface = IFWL_Barcode::Create();
- FWL_ERR ret = ((IFWL_Barcode*)m_pIface)->Initialize(prop, nullptr);
+ FWL_ERR ret =
+ ((IFWL_Barcode*)m_pIface)
+ ->Initialize(m_pProperties->MakeWidgetImpProperties(&m_barcodeData),
+ nullptr);
if (ret == FWL_ERR_Succeeded) {
CFWL_Widget::Initialize();
}
diff --git a/xfa/src/fwl/src/lightwidget/caret.cpp b/xfa/src/fwl/src/lightwidget/caret.cpp index d977772295..a9391966ca 100644 --- a/xfa/src/fwl/src/lightwidget/caret.cpp +++ b/xfa/src/fwl/src/lightwidget/caret.cpp @@ -13,20 +13,11 @@ FWL_ERR CFWL_Caret::Initialize(const CFWL_WidgetProperties* pProperties) { if (pProperties) {
*m_pProperties = *pProperties;
}
- CFWL_WidgetImpProperties prop;
- prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
- prop.m_rtWidget = m_pProperties->m_rtWidget;
- prop.m_dwStyles = m_pProperties->m_dwStyles;
- prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
- prop.m_dwStates = m_pProperties->m_dwStates;
- if (m_pProperties->m_pParent) {
- prop.m_pParent = m_pProperties->m_pParent->GetWidget();
- }
- if (m_pProperties->m_pOwner) {
- prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
- }
m_pIface = IFWL_Caret::Create();
- FWL_ERR ret = ((IFWL_Caret*)m_pIface)->Initialize(prop, nullptr);
+ FWL_ERR ret =
+ ((IFWL_Caret*)m_pIface)
+ ->Initialize(m_pProperties->MakeWidgetImpProperties(nullptr),
+ nullptr);
if (ret == FWL_ERR_Succeeded) {
CFWL_Widget::Initialize();
}
diff --git a/xfa/src/fwl/src/lightwidget/combobox.cpp b/xfa/src/fwl/src/lightwidget/combobox.cpp index dd5508b40b..024a5f9a2d 100644 --- a/xfa/src/fwl/src/lightwidget/combobox.cpp +++ b/xfa/src/fwl/src/lightwidget/combobox.cpp @@ -13,21 +13,11 @@ FWL_ERR CFWL_ComboBox::Initialize(const CFWL_WidgetProperties* pProperties) { if (pProperties) {
*m_pProperties = *pProperties;
}
- CFWL_WidgetImpProperties prop;
- prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
- prop.m_rtWidget = m_pProperties->m_rtWidget;
- prop.m_dwStyles = m_pProperties->m_dwStyles;
- prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
- prop.m_dwStates = m_pProperties->m_dwStates;
- prop.m_pDataProvider = &m_comboBoxData;
- if (m_pProperties->m_pParent) {
- prop.m_pParent = m_pProperties->m_pParent->GetWidget();
- }
- if (m_pProperties->m_pOwner) {
- prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
- }
m_pIface = IFWL_ComboBox::Create();
- FWL_ERR ret = ((IFWL_ComboBox*)m_pIface)->Initialize(prop, nullptr);
+ FWL_ERR ret =
+ ((IFWL_ComboBox*)m_pIface)
+ ->Initialize(m_pProperties->MakeWidgetImpProperties(&m_comboBoxData),
+ nullptr);
if (ret == FWL_ERR_Succeeded) {
CFWL_Widget::Initialize();
}
diff --git a/xfa/src/fwl/src/lightwidget/datetimepicker.cpp b/xfa/src/fwl/src/lightwidget/datetimepicker.cpp index 84ddd5e3cb..d762030b49 100644 --- a/xfa/src/fwl/src/lightwidget/datetimepicker.cpp +++ b/xfa/src/fwl/src/lightwidget/datetimepicker.cpp @@ -14,21 +14,12 @@ FWL_ERR CFWL_DateTimePicker::Initialize( if (pProperties) {
*m_pProperties = *pProperties;
}
- CFWL_WidgetImpProperties prop;
- prop.m_dwStyles = m_pProperties->m_dwStyles;
- prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
- prop.m_dwStates = m_pProperties->m_dwStates;
- prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
- prop.m_pDataProvider = &m_DateTimePickerDP;
- if (m_pProperties->m_pParent) {
- prop.m_pParent = m_pProperties->m_pParent->GetWidget();
- }
- if (m_pProperties->m_pOwner) {
- prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
- }
- prop.m_rtWidget = m_pProperties->m_rtWidget;
m_pIface = IFWL_DateTimePicker::Create();
- FWL_ERR ret = ((IFWL_DateTimePicker*)m_pIface)->Initialize(prop, nullptr);
+ FWL_ERR ret =
+ ((IFWL_DateTimePicker*)m_pIface)
+ ->Initialize(
+ m_pProperties->MakeWidgetImpProperties(&m_DateTimePickerDP),
+ nullptr);
if (ret == FWL_ERR_Succeeded) {
CFWL_Widget::Initialize();
}
diff --git a/xfa/src/fwl/src/lightwidget/edit.cpp b/xfa/src/fwl/src/lightwidget/edit.cpp index adfac0d1dc..be20a0b3a3 100644 --- a/xfa/src/fwl/src/lightwidget/edit.cpp +++ b/xfa/src/fwl/src/lightwidget/edit.cpp @@ -13,20 +13,11 @@ FWL_ERR CFWL_Edit::Initialize(const CFWL_WidgetProperties* pProperties) { if (pProperties) {
*m_pProperties = *pProperties;
}
- CFWL_WidgetImpProperties prop;
- prop.m_dwStyles = m_pProperties->m_dwStyles;
- prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
- prop.m_dwStates = m_pProperties->m_dwStates;
- prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
- if (m_pProperties->m_pParent) {
- prop.m_pParent = m_pProperties->m_pParent->GetWidget();
- }
- if (m_pProperties->m_pOwner) {
- prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
- }
- prop.m_rtWidget = m_pProperties->m_rtWidget;
m_pIface = IFWL_Edit::Create();
- FWL_ERR ret = ((IFWL_Edit*)m_pIface)->Initialize(prop, nullptr);
+ FWL_ERR ret =
+ ((IFWL_Edit*)m_pIface)
+ ->Initialize(m_pProperties->MakeWidgetImpProperties(nullptr),
+ nullptr);
if (ret == FWL_ERR_Succeeded) {
CFWL_Widget::Initialize();
}
diff --git a/xfa/src/fwl/src/lightwidget/listbox.cpp b/xfa/src/fwl/src/lightwidget/listbox.cpp index 758ee36c0f..f67dd66012 100644 --- a/xfa/src/fwl/src/lightwidget/listbox.cpp +++ b/xfa/src/fwl/src/lightwidget/listbox.cpp @@ -13,21 +13,11 @@ FWL_ERR CFWL_ListBox::Initialize(const CFWL_WidgetProperties* pProperties) { if (pProperties) {
*m_pProperties = *pProperties;
}
- CFWL_WidgetImpProperties prop;
- prop.m_dwStyles = m_pProperties->m_dwStyles;
- prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
- prop.m_dwStates = m_pProperties->m_dwStates;
- prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
- prop.m_pDataProvider = &m_ListBoxDP;
- if (m_pProperties->m_pParent) {
- prop.m_pParent = m_pProperties->m_pParent->GetWidget();
- }
- if (m_pProperties->m_pOwner) {
- prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
- }
- prop.m_rtWidget = m_pProperties->m_rtWidget;
m_pIface = IFWL_ListBox::Create();
- FWL_ERR ret = ((IFWL_ListBox*)m_pIface)->Initialize(prop, nullptr);
+ FWL_ERR ret =
+ ((IFWL_ListBox*)m_pIface)
+ ->Initialize(m_pProperties->MakeWidgetImpProperties(&m_ListBoxDP),
+ nullptr);
if (ret == FWL_ERR_Succeeded) {
CFWL_Widget::Initialize();
}
diff --git a/xfa/src/fwl/src/lightwidget/picturebox.cpp b/xfa/src/fwl/src/lightwidget/picturebox.cpp index d4971306ca..4bc8a68d3b 100644 --- a/xfa/src/fwl/src/lightwidget/picturebox.cpp +++ b/xfa/src/fwl/src/lightwidget/picturebox.cpp @@ -13,21 +13,11 @@ FWL_ERR CFWL_PictureBox::Initialize(const CFWL_WidgetProperties* pProperties) { if (pProperties) {
*m_pProperties = *pProperties;
}
- CFWL_WidgetImpProperties prop;
- prop.m_dwStyles = m_pProperties->m_dwStyles;
- prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
- prop.m_dwStates = m_pProperties->m_dwStates;
- prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
- prop.m_pDataProvider = &m_PictureBoxDP;
- if (m_pProperties->m_pParent) {
- prop.m_pParent = m_pProperties->m_pParent->GetWidget();
- }
- if (m_pProperties->m_pOwner) {
- prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
- }
- prop.m_rtWidget = m_pProperties->m_rtWidget;
m_pIface = IFWL_PictureBox::Create();
- FWL_ERR ret = ((IFWL_PictureBox*)m_pIface)->Initialize(prop, nullptr);
+ FWL_ERR ret =
+ ((IFWL_PictureBox*)m_pIface)
+ ->Initialize(m_pProperties->MakeWidgetImpProperties(&m_PictureBoxDP),
+ nullptr);
if (ret == FWL_ERR_Succeeded) {
CFWL_Widget::Initialize();
}
diff --git a/xfa/src/fwl/src/lightwidget/pushbutton.cpp b/xfa/src/fwl/src/lightwidget/pushbutton.cpp index 3344d37bfd..e7c1a86115 100644 --- a/xfa/src/fwl/src/lightwidget/pushbutton.cpp +++ b/xfa/src/fwl/src/lightwidget/pushbutton.cpp @@ -13,21 +13,11 @@ FWL_ERR CFWL_PushButton::Initialize(const CFWL_WidgetProperties* pProperties) { if (pProperties) {
*m_pProperties = *pProperties;
}
- CFWL_WidgetImpProperties prop;
- prop.m_dwStyles = m_pProperties->m_dwStyles;
- prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
- prop.m_dwStates = m_pProperties->m_dwStates;
- prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
- prop.m_pDataProvider = &m_buttonData;
- if (m_pProperties->m_pParent) {
- prop.m_pParent = m_pProperties->m_pParent->GetWidget();
- }
- if (m_pProperties->m_pOwner) {
- prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
- }
- prop.m_rtWidget = m_pProperties->m_rtWidget;
m_pIface = IFWL_PushButton::Create();
- FWL_ERR ret = ((IFWL_PushButton*)m_pIface)->Initialize(prop, nullptr);
+ FWL_ERR ret =
+ ((IFWL_PushButton*)m_pIface)
+ ->Initialize(m_pProperties->MakeWidgetImpProperties(&m_buttonData),
+ nullptr);
if (ret == FWL_ERR_Succeeded) {
CFWL_Widget::Initialize();
}
diff --git a/xfa/src/fwl/src/lightwidget/scrollbar.cpp b/xfa/src/fwl/src/lightwidget/scrollbar.cpp index 8bf47f840e..9614e9edf7 100644 --- a/xfa/src/fwl/src/lightwidget/scrollbar.cpp +++ b/xfa/src/fwl/src/lightwidget/scrollbar.cpp @@ -13,20 +13,11 @@ FWL_ERR CFWL_ScrollBar::Initialize(const CFWL_WidgetProperties* pProperties) { if (pProperties) {
*m_pProperties = *pProperties;
}
- CFWL_WidgetImpProperties prop;
- prop.m_dwStyles = m_pProperties->m_dwStyles;
- prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
- prop.m_dwStates = m_pProperties->m_dwStates;
- prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
- if (m_pProperties->m_pParent) {
- prop.m_pParent = m_pProperties->m_pParent->GetWidget();
- }
- if (m_pProperties->m_pOwner) {
- prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
- }
- prop.m_rtWidget = m_pProperties->m_rtWidget;
m_pIface = IFWL_ScrollBar::Create();
- FWL_ERR ret = ((IFWL_ScrollBar*)m_pIface)->Initialize(prop, nullptr);
+ FWL_ERR ret =
+ ((IFWL_ScrollBar*)m_pIface)
+ ->Initialize(m_pProperties->MakeWidgetImpProperties(nullptr),
+ nullptr);
if (ret == FWL_ERR_Succeeded) {
CFWL_Widget::Initialize();
}
diff --git a/xfa/src/fwl/src/lightwidget/tooltipctrl.cpp b/xfa/src/fwl/src/lightwidget/tooltipctrl.cpp index a167148b46..76944880df 100644 --- a/xfa/src/fwl/src/lightwidget/tooltipctrl.cpp +++ b/xfa/src/fwl/src/lightwidget/tooltipctrl.cpp @@ -19,21 +19,11 @@ FWL_ERR CFWL_ToolTip::Initialize(const CFWL_WidgetProperties* pProperties) { if (pProperties) {
*m_pProperties = *pProperties;
}
- CFWL_WidgetImpProperties prop;
- prop.m_dwStyles = m_pProperties->m_dwStyles;
- prop.m_dwStyleExes = m_pProperties->m_dwStyleExes;
- prop.m_dwStates = m_pProperties->m_dwStates;
- prop.m_ctmOnParent = m_pProperties->m_ctmOnParent;
- prop.m_pDataProvider = &m_tooltipData;
- if (m_pProperties->m_pParent) {
- prop.m_pParent = m_pProperties->m_pParent->GetWidget();
- }
- if (m_pProperties->m_pOwner) {
- prop.m_pOwner = m_pProperties->m_pOwner->GetWidget();
- }
- prop.m_rtWidget = m_pProperties->m_rtWidget;
m_pIface = IFWL_ToolTip::Create();
- FWL_ERR ret = ((IFWL_ToolTip*)m_pIface)->Initialize(prop, nullptr);
+ FWL_ERR ret =
+ ((IFWL_ToolTip*)m_pIface)
+ ->Initialize(m_pProperties->MakeWidgetImpProperties(&m_tooltipData),
+ nullptr);
if (ret == FWL_ERR_Succeeded) {
CFWL_Widget::Initialize();
}
diff --git a/xfa/src/fwl/src/lightwidget/widget.cpp b/xfa/src/fwl/src/lightwidget/widget.cpp index 3d97675fdb..b9b889600f 100644 --- a/xfa/src/fwl/src/lightwidget/widget.cpp +++ b/xfa/src/fwl/src/lightwidget/widget.cpp @@ -10,6 +10,22 @@ #include "../core/include/fwl_noteimp.h"
#include "../core/include/fwl_widgetimp.h"
#include "../core/include/fwl_widgetmgrimp.h"
+
+CFWL_WidgetImpProperties CFWL_WidgetProperties::MakeWidgetImpProperties(
+ IFWL_DataProvider* pDataProvider) const {
+ CFWL_WidgetImpProperties result;
+ result.m_ctmOnParent = m_ctmOnParent;
+ result.m_rtWidget = m_rtWidget;
+ result.m_dwStyles = m_dwStyles;
+ result.m_dwStyleExes = m_dwStyleExes;
+ result.m_dwStates = m_dwStates;
+ if (m_pParent)
+ result.m_pParent = m_pParent->GetWidget();
+ if (m_pOwner)
+ result.m_pOwner = m_pOwner->GetWidget();
+ result.m_pDataProvider = pDataProvider;
+ return result;
+}
IFWL_Widget* CFWL_Widget::GetWidget() {
return m_pIface;
}
|