chart2/source/controller/dialogs/ChartResourceGroups.cxx | 77 ++++++++------- chart2/source/inc/ChartResourceGroups.hxx | 13 +- 2 files changed, 53 insertions(+), 37 deletions(-)
New commits: commit 3113bed7f5919b8e743d36e87c668167d764113f Author: Jason Whitmore <jason@whitmore.email> AuthorDate: Wed Sep 3 16:16:55 2025 -0700 Commit: Hossein <hoss...@libreoffice.org> CommitDate: Mon Sep 15 10:11:18 2025 +0200 tdf#145614 convert #define statements to enum class Define statements in ChartResourceGroups.hxx have been replaced with an enum class. Two wrapper functions were created to simplify code. The .cxx file has been updated to use this enum. Other formatting changes made to satisfy clang. Change-Id: Ib7d095ce4fb3fbf433dcb9693f23958601dc89e7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190604 Tested-by: Jenkins Reviewed-by: Hossein <hoss...@libreoffice.org> diff --git a/chart2/source/controller/dialogs/ChartResourceGroups.cxx b/chart2/source/controller/dialogs/ChartResourceGroups.cxx index f773eefd7062..b344a1fda3c8 100644 --- a/chart2/source/controller/dialogs/ChartResourceGroups.cxx +++ b/chart2/source/controller/dialogs/ChartResourceGroups.cxx @@ -228,17 +228,27 @@ void SplineResourceGroup::showControls(bool bShow) m_xPB_DetailsDialog->set_visible(bShow); } +void SplineResourceGroup::setActiveLineType(PosLineType type) +{ + m_xLB_LineType->set_active(static_cast<sal_Int32>(type)); +} + +PosLineType SplineResourceGroup::getActiveLineType() const +{ + return static_cast<PosLineType>(m_xLB_LineType->get_active()); +} + void SplineResourceGroup::fillControls(const ChartTypeParameter& rParameter) { switch (rParameter.eCurveStyle) { case CurveStyle_LINES: - m_xLB_LineType->set_active(POS_LINETYPE_STRAIGHT); + setActiveLineType(PosLineType::Straight); m_xPB_DetailsDialog->set_sensitive(false); break; case CurveStyle_CUBIC_SPLINES: case CurveStyle_B_SPLINES: - m_xLB_LineType->set_active(POS_LINETYPE_SMOOTH); + setActiveLineType(PosLineType::Smooth); m_xPB_DetailsDialog->set_sensitive(true); m_xPB_DetailsDialog->connect_clicked( LINK(this, SplineResourceGroup, SplineDetailsDialogHdl)); @@ -249,7 +259,7 @@ void SplineResourceGroup::fillControls(const ChartTypeParameter& rParameter) case CurveStyle_STEP_END: case CurveStyle_STEP_CENTER_X: case CurveStyle_STEP_CENTER_Y: - m_xLB_LineType->set_active(POS_LINETYPE_STEPPED); + setActiveLineType(PosLineType::Stepped); m_xPB_DetailsDialog->set_sensitive(true); m_xPB_DetailsDialog->connect_clicked( LINK(this, SplineResourceGroup, SteppedDetailsDialogHdl)); @@ -257,18 +267,18 @@ void SplineResourceGroup::fillControls(const ChartTypeParameter& rParameter) getSteppedPropertiesDialog()->fillControls(rParameter); break; default: - m_xLB_LineType->set_active(-1); + setActiveLineType(PosLineType::None); m_xPB_DetailsDialog->set_sensitive(false); } } void SplineResourceGroup::fillParameter(ChartTypeParameter& rParameter) { - switch (m_xLB_LineType->get_active()) + switch (getActiveLineType()) { - case POS_LINETYPE_SMOOTH: + case PosLineType::Smooth: getSplinePropertiesDialog()->fillParameter(rParameter, true); break; - case POS_LINETYPE_STEPPED: + case PosLineType::Stepped: getSteppedPropertiesDialog()->fillParameter(rParameter, true); break; default: // includes POS_LINETYPE_STRAIGHT @@ -287,41 +297,41 @@ IMPL_LINK_NOARG(SplineResourceGroup, SplineDetailsDialogHdl, weld::Button&, void { ChartTypeParameter aOldParameter; std::shared_ptr<SplinePropertiesDialog> xDlg = getSplinePropertiesDialog(); - xDlg->fillParameter(aOldParameter, m_xLB_LineType->get_active() == POS_LINETYPE_SMOOTH); + xDlg->fillParameter(aOldParameter, getActiveLineType() == PosLineType::Smooth); const sal_Int32 iOldLineTypePos = m_xLB_LineType->get_active(); - m_xLB_LineType->set_active(POS_LINETYPE_SMOOTH); - weld::GenericDialogController::runAsync(xDlg, [this, xDlg, aOldParameter, - iOldLineTypePos](sal_Int32 nResult) { - m_xSplinePropertiesDialog = nullptr; - auto xNewDlg = getSplinePropertiesDialog(); - - if (nResult == RET_OK) - { - ChartTypeParameter aNewParameter; - xDlg->fillParameter(aNewParameter, m_xLB_LineType->get_active() == POS_LINETYPE_SMOOTH); - xNewDlg->fillControls(aNewParameter); - - if (m_pChangeListener) - m_pChangeListener->stateChanged(); - } - else - { - //restore old state: - m_xLB_LineType->set_active(iOldLineTypePos); - xNewDlg->fillControls(aOldParameter); - } - }); + setActiveLineType(PosLineType::Smooth); + weld::GenericDialogController::runAsync( + xDlg, [this, xDlg, aOldParameter, iOldLineTypePos](sal_Int32 nResult) { + m_xSplinePropertiesDialog = nullptr; + auto xNewDlg = getSplinePropertiesDialog(); + + if (nResult == RET_OK) + { + ChartTypeParameter aNewParameter; + xDlg->fillParameter(aNewParameter, getActiveLineType() == PosLineType::Smooth); + xNewDlg->fillControls(aNewParameter); + + if (m_pChangeListener) + m_pChangeListener->stateChanged(); + } + else + { + //restore old state: + m_xLB_LineType->set_active(iOldLineTypePos); + xNewDlg->fillControls(aOldParameter); + } + }); } IMPL_LINK_NOARG(SplineResourceGroup, SteppedDetailsDialogHdl, weld::Button&, void) { ChartTypeParameter aOldParameter; std::shared_ptr<SteppedPropertiesDialog> xDlg = getSteppedPropertiesDialog(); - xDlg->fillParameter(aOldParameter, m_xLB_LineType->get_active() == POS_LINETYPE_STEPPED); + xDlg->fillParameter(aOldParameter, getActiveLineType() == PosLineType::Stepped); const sal_Int32 iOldLineTypePos = m_xLB_LineType->get_active(); - m_xLB_LineType->set_active(POS_LINETYPE_STEPPED); + setActiveLineType(PosLineType::Stepped); weld::GenericDialogController::runAsync( xDlg, [this, xDlg, aOldParameter, iOldLineTypePos](sal_Int32 nResult) { @@ -331,8 +341,7 @@ IMPL_LINK_NOARG(SplineResourceGroup, SteppedDetailsDialogHdl, weld::Button&, voi if (nResult == RET_OK) { ChartTypeParameter aNewParameter; - xDlg->fillParameter(aNewParameter, - m_xLB_LineType->get_active() == POS_LINETYPE_STEPPED); + xDlg->fillParameter(aNewParameter, getActiveLineType() == PosLineType::Stepped); xNewDlg->fillControls(aNewParameter); if (m_pChangeListener) diff --git a/chart2/source/inc/ChartResourceGroups.hxx b/chart2/source/inc/ChartResourceGroups.hxx index de3d86707a6b..a3ce6f564cc2 100644 --- a/chart2/source/inc/ChartResourceGroups.hxx +++ b/chart2/source/inc/ChartResourceGroups.hxx @@ -92,9 +92,13 @@ private: std::unique_ptr<weld::RadioButton> m_xRB_Stack_Z; }; -#define POS_LINETYPE_STRAIGHT 0 -#define POS_LINETYPE_SMOOTH 1 -#define POS_LINETYPE_STEPPED 2 +enum class PosLineType +{ + None = -1, + Straight = 0, + Smooth = 1, + Stepped = 2 +}; class SplineResourceGroup final : public ChangingResource { @@ -106,6 +110,9 @@ public: void fillControls(const ChartTypeParameter& rParameter); void fillParameter(ChartTypeParameter& rParameter); + void setActiveLineType(PosLineType type); + PosLineType getActiveLineType() const; + private: DECL_LINK(LineTypeChangeHdl, weld::ComboBox&, void); DECL_LINK(SplineDetailsDialogHdl, weld::Button&, void);