chart2/qa/extras/chart2dump/chart2dump.cxx                             |    4 
 chart2/source/controller/dialogs/dlg_CreationWizard.cxx                |   57 
++++---
 chart2/source/controller/dialogs/tp_AxisPositions.cxx                  |   19 
+-
 chart2/source/controller/dialogs/tp_PointGeometry.cxx                  |    4 
 chart2/source/controller/dialogs/tp_SeriesToAxis.cxx                   |    8 -
 chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx |    5 
 chart2/source/inc/chartview/ChartSfxItemIds.hxx                        |   77 
+++++++---
 chart2/source/view/main/ChartItemPool.cxx                              |    6 
 8 files changed, 106 insertions(+), 74 deletions(-)

New commits:
commit ea2ecf0406e08a94343d3aacdb913dac5972596b
Author:     Sergey Anisimov <[email protected]>
AuthorDate: Mon Oct 6 18:26:25 2025 +0300
Commit:     Hossein <[email protected]>
CommitDate: Fri Oct 31 17:45:16 2025 +0100

    tdf#145614 - Convert #define to enum or constexpr
    
    Change-Id: Ica8f4afdbb40adb3d26bfc56f4bfc91c110001ff
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191983
    Reviewed-by: Mike Kaganski <[email protected]>
    Reviewed-by: Hossein <[email protected]>
    Tested-by: Jenkins

diff --git a/chart2/qa/extras/chart2dump/chart2dump.cxx 
b/chart2/qa/extras/chart2dump/chart2dump.cxx
index b9fb4e455b74..f0838bffef47 100644
--- a/chart2/qa/extras/chart2dump/chart2dump.cxx
+++ b/chart2/qa/extras/chart2dump/chart2dump.cxx
@@ -24,9 +24,9 @@
 #include <string_view>
 
 #if defined(X86)
-#define INT_EPS     2.1
+constexpr double INT_EPS = 2.1;
 #else
-#define INT_EPS     0.1
+constexpr double INT_EPS = 0.1;
 #endif
 
 #define DECLARE_DUMP_TEST(TestName, BaseClass, DumpMode) \
diff --git a/chart2/source/controller/dialogs/dlg_CreationWizard.cxx 
b/chart2/source/controller/dialogs/dlg_CreationWizard.cxx
index ddfa7a3b4e3e..1de4e9fb093c 100644
--- a/chart2/source/controller/dialogs/dlg_CreationWizard.cxx
+++ b/chart2/source/controller/dialogs/dlg_CreationWizard.cxx
@@ -39,12 +39,17 @@ using vcl::RoadmapWizardTypes::PathId;
 
 namespace chart
 {
-#define STATE_FIRST        0
-#define STATE_CHARTTYPE    STATE_FIRST
-#define STATE_SIMPLE_RANGE 1
-#define STATE_DATA_SERIES  2
-#define STATE_OBJECTS      3
-#define STATE_LAST         STATE_OBJECTS
+
+namespace {
+    enum CreationWizardState{
+        First       = 0,
+        CharType    = First,
+        SimpleRange = 1,
+        DataSeries  = 2,
+        Objects     = 3,
+        Last        = Objects
+    };
+}
 
 CreationWizard::CreationWizard(weld::Window* pParent, const 
rtl::Reference<::chart::ChartModel>& xChartModel,
                                uno::Reference<uno::XComponentContext> xContext)
@@ -61,15 +66,15 @@ CreationWizard::CreationWizard(weld::Window* pParent, const 
rtl::Reference<::cha
     setTitleBase(SchResId(STR_DLG_CHART_WIZARD));
 
     // tdf#134386 set m_pTemplateProvider before creating any other pages
-    m_pTemplateProvider = 
static_cast<ChartTypeTabPage*>(GetOrCreatePage(STATE_CHARTTYPE));
+    m_pTemplateProvider = 
static_cast<ChartTypeTabPage*>(GetOrCreatePage(CreationWizardState::CharType));
     assert(m_pTemplateProvider && "must exist");
     m_pDialogModel->setTemplate(m_pTemplateProvider->getCurrentTemplate());
 
     WizardPath aPath = {
-        STATE_CHARTTYPE,
-        STATE_SIMPLE_RANGE,
-        STATE_DATA_SERIES,
-        STATE_OBJECTS
+        CreationWizardState::CharType,
+        CreationWizardState::SimpleRange,
+        CreationWizardState::DataSeries,
+        CreationWizardState::Objects
     };
 
     declarePath(PathId::COMPLETE, aPath);
@@ -79,8 +84,8 @@ CreationWizard::CreationWizard(weld::Window* pParent, const 
rtl::Reference<::cha
 
     if (!m_pDialogModel->getModel().isDataFromSpreadsheet())
     {
-        enableState(STATE_SIMPLE_RANGE, false);
-        enableState(STATE_DATA_SERIES, false);
+        enableState(CreationWizardState::SimpleRange, false);
+        enableState(CreationWizardState::DataSeries, false);
     }
 
     // Call ActivatePage, to create and activate the first page
@@ -100,25 +105,25 @@ std::unique_ptr<BuilderPage> 
CreationWizard::createPage(WizardState nState)
 
     switch( nState )
     {
-        case STATE_CHARTTYPE:
+        case CreationWizardState::CharType:
         {
             m_aTimerTriggeredControllerLock.startTimer();
             xRet = std::make_unique<ChartTypeTabPage>(pPageContainer, this, 
m_xChartModel);
             break;
         }
-        case STATE_SIMPLE_RANGE:
+        case CreationWizardState::SimpleRange:
         {
             m_aTimerTriggeredControllerLock.startTimer();
             xRet = std::make_unique<RangeChooserTabPage>(pPageContainer, this, 
*m_pDialogModel, m_pTemplateProvider);
             break;
         }
-        case STATE_DATA_SERIES:
+        case CreationWizardState::DataSeries:
         {
             m_aTimerTriggeredControllerLock.startTimer();
             xRet = std::make_unique<DataSourceTabPage>(pPageContainer, this, 
*m_pDialogModel, m_pTemplateProvider);
             break;
         }
-        case STATE_OBJECTS:
+        case CreationWizardState::Objects:
         {
             xRet = std::make_unique<TitlesAndObjectsTabPage>(pPageContainer, 
this, m_xChartModel, m_xComponentContext);
             m_aTimerTriggeredControllerLock.startTimer();
@@ -143,19 +148,19 @@ vcl::WizardTypes::WizardState 
CreationWizard::determineNextState( WizardState nC
 {
     if( !m_bCanTravel )
         return WZS_INVALID_STATE;
-    if( nCurrentState == STATE_LAST )
+    if( nCurrentState == CreationWizardState::Last)
         return WZS_INVALID_STATE;
     vcl::WizardTypes::WizardState nNextState = nCurrentState + 1;
-    while( !isStateEnabled( nNextState ) && nNextState <= STATE_LAST )
+    while( !isStateEnabled( nNextState ) && nNextState <= 
CreationWizardState::Last )
         ++nNextState;
-    return (nNextState==STATE_LAST+1) ? WZS_INVALID_STATE : nNextState;
+    return (nNextState==CreationWizardState::Last+1) ? WZS_INVALID_STATE : 
nNextState;
 }
 
 void CreationWizard::enterState(WizardState nState)
 {
     m_aTimerTriggeredControllerLock.startTimer();
-    enableButtons( WizardButtonFlags::PREVIOUS, nState > STATE_FIRST );
-    enableButtons( WizardButtonFlags::NEXT, nState < STATE_LAST );
+    enableButtons( WizardButtonFlags::PREVIOUS, nState > 
CreationWizardState::First);
+    enableButtons( WizardButtonFlags::NEXT, nState < 
CreationWizardState::Last);
     if( isStateEnabled( nState ))
         vcl::RoadmapWizardMachine::enterState(nState);
 }
@@ -177,16 +182,16 @@ OUString CreationWizard::getStateDisplayName( WizardState 
nState ) const
     TranslateId pResId;
     switch( nState )
     {
-    case STATE_CHARTTYPE:
+    case CreationWizardState::CharType:
         pResId = STR_PAGE_CHARTTYPE;
         break;
-    case STATE_SIMPLE_RANGE:
+    case CreationWizardState::SimpleRange:
         pResId = STR_PAGE_DATA_RANGE;
         break;
-    case STATE_DATA_SERIES:
+    case CreationWizardState::DataSeries:
         pResId = STR_OBJECT_DATASERIES_PLURAL;
         break;
-    case STATE_OBJECTS:
+    case CreationWizardState::Objects:
         pResId = STR_PAGE_CHART_ELEMENTS;
         break;
     default:
diff --git a/chart2/source/controller/dialogs/tp_AxisPositions.cxx 
b/chart2/source/controller/dialogs/tp_AxisPositions.cxx
index 2faddaad81dd..0ec5d1cca509 100644
--- a/chart2/source/controller/dialogs/tp_AxisPositions.cxx
+++ b/chart2/source/controller/dialogs/tp_AxisPositions.cxx
@@ -102,13 +102,13 @@ bool AxisPositionsTabPage::FillItemSet(SfxItemSet* 
rOutAttrs)
     sal_Int32 nMinorTicks=0;
 
     if(m_xCB_MinorInner->get_active())
-        nMinorTicks|=CHAXIS_MARK_INNER;
+        AFTicks::setFlagFor(nMinorTicks, AxisTicksAtr::Inner);
     if(m_xCB_MinorOuter->get_active())
-        nMinorTicks|=CHAXIS_MARK_OUTER;
+        AFTicks::setFlagFor(nMinorTicks, AxisTicksAtr::Outer);
     if(m_xCB_TicksInner->get_active())
-        nTicks|=CHAXIS_MARK_INNER;
+        AFTicks::setFlagFor(nTicks, AxisTicksAtr::Inner);
     if(m_xCB_TicksOuter->get_active())
-        nTicks|=CHAXIS_MARK_OUTER;
+        AFTicks::setFlagFor(nTicks, AxisTicksAtr::Outer);
 
     rOutAttrs->Put(SfxInt32Item(SCHATTR_AXIS_TICKS,nTicks));
     rOutAttrs->Put(SfxInt32Item(SCHATTR_AXIS_HELPTICKS,nMinorTicks));
@@ -209,16 +209,15 @@ void AxisPositionsTabPage::Reset(const SfxItemSet* 
rInAttrs)
     PlaceLabelsSelectHdl( *m_xLB_PlaceLabels );
 
     // Tick marks
-    tools::Long nTicks = 0, nMinorTicks = 0;
+    sal_Int32 nTicks = 0, nMinorTicks = 0;
     if (const SfxInt32Item* pTicksItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_TICKS))
         nTicks = pTicksItem->GetValue();
     if (const SfxInt32Item* pHelpTicksItem = 
rInAttrs->GetItemIfSet(SCHATTR_AXIS_HELPTICKS))
         nMinorTicks = pHelpTicksItem->GetValue();
-
-    m_xCB_TicksInner->set_active(bool(nTicks&CHAXIS_MARK_INNER));
-    m_xCB_TicksOuter->set_active(bool(nTicks&CHAXIS_MARK_OUTER));
-    m_xCB_MinorInner->set_active(bool(nMinorTicks&CHAXIS_MARK_INNER));
-    m_xCB_MinorOuter->set_active(bool(nMinorTicks&CHAXIS_MARK_OUTER));
+    m_xCB_TicksInner->set_active(AFTicks::checkFlagFor(nTicks, 
AxisTicksAtr::Inner));
+    m_xCB_TicksOuter->set_active(AFTicks::checkFlagFor(nTicks, 
AxisTicksAtr::Outer));
+    m_xCB_MinorInner->set_active(AFTicks::checkFlagFor(nMinorTicks, 
AxisTicksAtr::Inner));
+    m_xCB_MinorOuter->set_active(AFTicks::checkFlagFor(nMinorTicks, 
AxisTicksAtr::Outer));
 
     // Tick position
     if( const SfxInt32Item* pMarkPosItem = rInAttrs->GetItemIfSet( 
SCHATTR_AXIS_MARK_POSITION, false) )
diff --git a/chart2/source/controller/dialogs/tp_PointGeometry.cxx 
b/chart2/source/controller/dialogs/tp_PointGeometry.cxx
index e9f1d1b957d7..72f6a706f695 100644
--- a/chart2/source/controller/dialogs/tp_PointGeometry.cxx
+++ b/chart2/source/controller/dialogs/tp_PointGeometry.cxx
@@ -46,12 +46,12 @@ std::unique_ptr<SfxTabPage> 
SchLayoutTabPage::Create(weld::Container* pPage, wel
 
 bool SchLayoutTabPage::FillItemSet(SfxItemSet* rOutAttrs)
 {
-    int nShape = m_pGeometryResources ? 
m_pGeometryResources->get_selected_index() : -1;
+    sal_Int32 nShape = m_pGeometryResources ? 
m_pGeometryResources->get_selected_index() : -1;
     if (nShape != -1)
     {
         tools::Long nSegs=32;
 
-        if (nShape==CHART_SHAPE3D_PYRAMID)
+        if (nShape==AFShapes(StyleShapeAtr::Pyramid))
             nSegs=4;
 
         rOutAttrs->Put(SfxInt32Item(SCHATTR_STYLE_SHAPE,nShape));
diff --git a/chart2/source/controller/dialogs/tp_SeriesToAxis.cxx 
b/chart2/source/controller/dialogs/tp_SeriesToAxis.cxx
index ee6dabc07a6f..4b96c309be7c 100644
--- a/chart2/source/controller/dialogs/tp_SeriesToAxis.cxx
+++ b/chart2/source/controller/dialogs/tp_SeriesToAxis.cxx
@@ -77,9 +77,9 @@ std::unique_ptr<SfxTabPage> 
SchOptionTabPage::Create(weld::Container* pPage, wel
 bool SchOptionTabPage::FillItemSet(SfxItemSet* rOutAttrs)
 {
     if(m_xRbtAxis2->get_active())
-        rOutAttrs->Put(SfxInt32Item(SCHATTR_AXIS,CHART_AXIS_SECONDARY_Y));
+        
rOutAttrs->Put(SfxInt32Item(SCHATTR_AXIS,AFAxix::toNum(AxisAtr::SecondaryY)));
     else
-        rOutAttrs->Put(SfxInt32Item(SCHATTR_AXIS,CHART_AXIS_PRIMARY_Y));
+        
rOutAttrs->Put(SfxInt32Item(SCHATTR_AXIS,AFAxix::toNum(AxisAtr::PrimaryY)));
 
     if(m_xMTGap->get_visible())
         rOutAttrs->Put(SfxInt32Item(SCHATTR_BAR_GAPWIDTH,static_cast< 
sal_Int32 >( m_xMTGap->get_value(FieldUnit::PERCENT))));
@@ -117,8 +117,8 @@ void SchOptionTabPage::Reset(const SfxItemSet* rInAttrs)
     m_xRbtAxis2->set_active(false);
     if (const SfxInt32Item* pAxisItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS))
     {
-        tools::Long nVal = pAxisItem->GetValue();
-        if(nVal==CHART_AXIS_SECONDARY_Y)
+        sal_Int32 nVal = pAxisItem->GetValue();
+        if(nVal==AFAxix(AxisAtr::SecondaryY))
         {
             m_xRbtAxis2->set_active(true);
             m_xRbtAxis1->set_active(false);
diff --git 
a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
index 6884b8a71ce1..a1b12bc472be 100644
--- a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
@@ -175,7 +175,7 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( 
sal_uInt16 nWhichId, const Sf
         {
             sal_Int32 nItemValue = static_cast< const SfxInt32Item & >(
                     rItemSet.Get( nWhichId )).GetValue();
-            bool bAttachToMainAxis = nItemValue == CHART_AXIS_PRIMARY_Y;
+            bool bAttachToMainAxis = nItemValue == AFAxix(AxisAtr::PrimaryY);
             if( bAttachToMainAxis != m_bAttachToMainAxis )
             {
                 //change model:
@@ -356,8 +356,7 @@ void SeriesOptionsItemConverter::FillSpecialItem(
     {
         case SCHATTR_AXIS:
         {
-            sal_Int32 nItemValue = m_bAttachToMainAxis ? CHART_AXIS_PRIMARY_Y 
: CHART_AXIS_SECONDARY_Y;
-            rOutItemSet.Put( SfxInt32Item(nWhichId,nItemValue ) );
+            rOutItemSet.Put( 
SfxInt32Item(nWhichId,AFAxix::toNum(m_bAttachToMainAxis ? AxisAtr::PrimaryY : 
AxisAtr::SecondaryY) ) );
             break;
         }
         case SCHATTR_BAR_OVERLAP:
diff --git a/chart2/source/inc/chartview/ChartSfxItemIds.hxx 
b/chart2/source/inc/chartview/ChartSfxItemIds.hxx
index 43341728d4da..e01165611772 100644
--- a/chart2/source/inc/chartview/ChartSfxItemIds.hxx
+++ b/chart2/source/inc/chartview/ChartSfxItemIds.hxx
@@ -211,31 +211,62 @@ inline constexpr sal_uInt16 SCHATTR_END 
(SCHATTR_COLOR_PALETTE_END);
 // values for Items
 
 // values for SCHATTR_AXIS_TICKS and SCHATTR_AXIS_HELPTICKS items
-#define CHAXIS_MARK_BOTH   3
-#define CHAXIS_MARK_OUTER  2
-#define CHAXIS_MARK_INNER  1
-#define CHAXIS_MARK_NONE   0
-
+enum class AxisTicksAtr {
+    None  = 0,
+    Inner = 1,
+    Outer = 2,
+    Both  = 3
+};
 // values for SCHATTR_AXISTYPE items
-#define CHART_AXIS_REALNUMBER   0
-#define CHART_AXIS_PERCENT      1
-#define CHART_AXIS_CATEGORY     2
-#define CHART_AXIS_SERIES       3
-#define CHART_AXIS_DATE         4
-
+enum class AxisTypesAtr{
+    RealNumber  = 0,
+    Percent     = 1,
+    Category    = 2,
+    Series      = 3,
+    Date        = 4
+};
 // values for SCHATTR_STYLE_SHAPE items
-#define CHART_SHAPE3D_IGNORE  -2 //internal! (GetChartShapeStyle()!)
-#define CHART_SHAPE3D_SQUARE   0
-#define CHART_SHAPE3D_CYLINDER 1
-#define CHART_SHAPE3D_CONE     2
-#define CHART_SHAPE3D_PYRAMID  3 //reserved
-#define CHART_SHAPE3D_HANOI    4
-
+constexpr sal_Int32 CHART_SHAPE3D_IGNORE = -2;
+enum class StyleShapeAtr{
+    Square   = 0,
+    Cylinder = 1,
+    Cone     = 2,
+    Pyramid  = 3, //reserved
+    Hanoi    = 4
+};
 // values for SCHATTR_AXIS items
-#define CHART_AXIS_PRIMARY_X    1
-#define CHART_AXIS_PRIMARY_Y    2
-#define CHART_AXIS_PRIMARY_Z    3
-#define CHART_AXIS_SECONDARY_Y  4
-#define CHART_AXIS_SECONDARY_X  5
+enum class AxisAtr{
+    PrimaryX    = 1,
+    PrimaryY    = 2,
+    PrimaryZ    = 3,
+    SecondaryY  = 4,
+    SecondaryX  = 5
+};
+
+
+template <typename T>
+concept enumerator = std::is_enum_v<T>;
+
+template <typename T>
+concept integral = std::is_integral_v<T>;
+
+template <integral T, enumerator U>
+struct AxisFlags{
+    AxisFlags(const U&& fl):m(fl){}
+
+    static void setFlagFor( T& val, const U&& fl){val |= static_cast<T>(fl);}
+    static bool checkFlagFor( const T& val, const U&& fl){ return val & 
static_cast<T>(fl);}
+    static T toNum (const U&& fl){ return static_cast<T>(fl);}
+    bool operator==(const T& val){return val == static_cast<T>(m);}
+    bool operator==(const U& fl){return fl == m;}
+    bool operator==(const AxisFlags& other){return other==this;}
+private:
+    U m;
+};
+
+typedef AxisFlags<sal_Int32,AxisTicksAtr> AFTicks;
+typedef AxisFlags<sal_Int32,AxisTypesAtr> AFTypes;
+typedef AxisFlags<sal_Int32,StyleShapeAtr> AFShapes;
+typedef AxisFlags<sal_Int32,AxisAtr> AFAxix;
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/main/ChartItemPool.cxx 
b/chart2/source/view/main/ChartItemPool.cxx
index e5599ef3fcd5..36f049a55c97 100644
--- a/chart2/source/view/main/ChartItemPool.cxx
+++ b/chart2/source/view/main/ChartItemPool.cxx
@@ -93,11 +93,9 @@ static ItemInfoPackage& getItemInfoPackageChart()
             { SCHATTR_STYLE_SPLINES, new SfxInt32Item (SCHATTR_STYLE_SPLINES, 
0), 0, SFX_ITEMINFOFLAG_NONE },
             { SCHATTR_STYLE_SYMBOL, new SfxInt32Item (SCHATTR_STYLE_SYMBOL, 
0), SID_ATTR_SYMBOLTYPE, SFX_ITEMINFOFLAG_NONE },
             { SCHATTR_STYLE_SHAPE, new SfxInt32Item (SCHATTR_STYLE_SHAPE, 0), 
0, SFX_ITEMINFOFLAG_NONE },
-
             { SCHATTR_AXIS, new SfxInt32Item(SCHATTR_AXIS,2), 0, 
SFX_ITEMINFOFLAG_NONE },
-
             //axis scale
-            { SCHATTR_AXISTYPE, new SfxInt32Item(SCHATTR_AXISTYPE, 
CHART_AXIS_REALNUMBER), 0, SFX_ITEMINFOFLAG_NONE },
+            { SCHATTR_AXISTYPE, new SfxInt32Item(SCHATTR_AXISTYPE, 
AFTypes::toNum(AxisTypesAtr::RealNumber)), 0, SFX_ITEMINFOFLAG_NONE },
             { SCHATTR_AXIS_REVERSE, new 
SfxBoolItem(SCHATTR_AXIS_REVERSE,false), 0, SFX_ITEMINFOFLAG_NONE },
             { SCHATTR_AXIS_AUTO_MIN, new SfxBoolItem(SCHATTR_AXIS_AUTO_MIN), 
0, SFX_ITEMINFOFLAG_NONE },
             { SCHATTR_AXIS_MIN, new SvxDoubleItem(0.0, SCHATTR_AXIS_MIN), 0, 
SFX_ITEMINFOFLAG_NONE },
@@ -118,7 +116,7 @@ static ItemInfoPackage& getItemInfoPackageChart()
             { SCHATTR_AXIS_ORIGIN, new SvxDoubleItem(0.0, 
SCHATTR_AXIS_ORIGIN), 0, SFX_ITEMINFOFLAG_NONE },
 
             //axis position
-            { SCHATTR_AXIS_TICKS, new 
SfxInt32Item(SCHATTR_AXIS_TICKS,CHAXIS_MARK_OUTER), 0, SFX_ITEMINFOFLAG_NONE },
+            { SCHATTR_AXIS_TICKS, new 
SfxInt32Item(SCHATTR_AXIS_TICKS,AFTicks::toNum(AxisTicksAtr::Outer)), 0, 
SFX_ITEMINFOFLAG_NONE },
             { SCHATTR_AXIS_HELPTICKS, new 
SfxInt32Item(SCHATTR_AXIS_HELPTICKS,0), 0, SFX_ITEMINFOFLAG_NONE },
             { SCHATTR_AXIS_POSITION, new 
SfxInt32Item(SCHATTR_AXIS_POSITION,0), 0, SFX_ITEMINFOFLAG_NONE },
             { SCHATTR_AXIS_POSITION_VALUE, new SvxDoubleItem(0.0, 
SCHATTR_AXIS_POSITION_VALUE), 0, SFX_ITEMINFOFLAG_NONE },

Reply via email to