formula/source/ui/dlg/formula.cxx  |   14 +++++++-------
 formula/source/ui/dlg/structpg.cxx |   11 +++++------
 formula/source/ui/dlg/structpg.hxx |    3 ++-
 include/formula/formula.hxx        |   10 ++++++----
 4 files changed, 20 insertions(+), 18 deletions(-)

New commits:
commit b96b0af82ef0081612a653db1a4dff7f68a5de9b
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Jul 3 06:50:19 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Jul 3 09:08:55 2025 +0200

    formula: Replace STRUCT_* constants with enum class
    
    Change-Id: I45f9cc4fd5c90b36efe942768b89f5c325a3772e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187295
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/formula/source/ui/dlg/formula.cxx 
b/formula/source/ui/dlg/formula.cxx
index 2fd606b89029..127c27614562 100644
--- a/formula/source/ui/dlg/formula.cxx
+++ b/formula/source/ui/dlg/formula.cxx
@@ -628,19 +628,19 @@ void FormulaDlg_Impl::MakeTree(StructPage* _pTree, 
weld::TreeIter* pParent, cons
 
                 if (eOp == ocBad)
                 {
-                    _pTree->InsertEntry(aResult, pParent, STRUCT_ERROR, 0, 
_pToken, *xEntry);
+                    _pTree->InsertEntry(aResult, pParent, StructType::Error, 
0, _pToken, *xEntry);
                 }
                 else if (!((SC_OPCODE_START_BIN_OP <= eOp && eOp < 
SC_OPCODE_STOP_BIN_OP) ||
                             (SC_OPCODE_START_UN_OP <= eOp && eOp < 
SC_OPCODE_STOP_UN_OP)))
                 {
                     // Not a binary or unary operator.
                     bCalcSubformula = true;
-                    _pTree->InsertEntry(aResult, pParent, STRUCT_FOLDER, 0, 
_pToken, *xEntry);
+                    _pTree->InsertEntry(aResult, pParent, StructType::Folder, 
0, _pToken, *xEntry);
                 }
                 else
                 {
                     /* TODO: question remains, why not sub calculate 
operators? */
-                    _pTree->InsertEntry(aResult, pParent, STRUCT_FOLDER, 0, 
_pToken, *xEntry);
+                    _pTree->InsertEntry(aResult, pParent, StructType::Folder, 
0, _pToken, *xEntry);
                 }
 
                 pEntry = xEntry.get();
@@ -680,7 +680,7 @@ void FormulaDlg_Impl::MakeTree(StructPage* _pTree, 
weld::TreeIter* pParent, cons
             std::unique_ptr<weld::TreeIter> 
xEntry(m_xStructPage->GetTlbStruct().make_iterator());
             if (eOp == ocBad)
             {
-                _pTree->InsertEntry( aResult, pParent, STRUCT_ERROR, 0, 
_pToken, *xEntry);
+                _pTree->InsertEntry(aResult, pParent, StructType::Error, 0, 
_pToken, *xEntry);
             }
             else if (eOp == ocPush)
             {
@@ -728,14 +728,14 @@ void FormulaDlg_Impl::MakeTree(StructPage* _pTree, 
weld::TreeIter* pParent, cons
                     // Cell is a formula, print subformula.
                     // With scalar values prints "A1:A3 = 2 {1;2;3}"
                     _pTree->InsertEntry( aResult + " = " + aUnforcedResult + 
aCellResult,
-                            pParent, STRUCT_END, 0, _pToken, *xEntry);
+                            pParent, StructType::End, 0, _pToken, *xEntry);
                 }
                 else
-                    _pTree->InsertEntry(aResult, pParent, STRUCT_END, 0, 
_pToken, *xEntry);
+                    _pTree->InsertEntry(aResult, pParent, StructType::End, 0, 
_pToken, *xEntry);
             }
             else
             {
-                _pTree->InsertEntry(aResult, pParent, STRUCT_END, 0, _pToken, 
*xEntry);
+                _pTree->InsertEntry(aResult, pParent, StructType::End, 0, 
_pToken, *xEntry);
             }
             --Count;
             MakeTree( _pTree, pParent, _pToken, 
m_oTokenArrayIterator->PrevRPN(), Count);
diff --git a/formula/source/ui/dlg/structpg.cxx 
b/formula/source/ui/dlg/structpg.cxx
index 94101f0da986..37d11be7b257 100644
--- a/formula/source/ui/dlg/structpg.cxx
+++ b/formula/source/ui/dlg/structpg.cxx
@@ -58,8 +58,7 @@ void StructPage::ClearStruct()
 }
 
 bool StructPage::InsertEntry(const OUString& rText, const weld::TreeIter* 
pParent,
-                             sal_uInt16 nFlag, int nPos,
-                             const FormulaToken* pIFormulaToken,
+                             StructType eStructType, int nPos, const 
FormulaToken* pIFormulaToken,
                              weld::TreeIter& rRet)
 {
     SetActiveFlag(false);
@@ -67,21 +66,21 @@ bool StructPage::InsertEntry(const OUString& rText, const 
weld::TreeIter* pParen
     OUString sId(weld::toId(pIFormulaToken));
 
     bool bEntry = false;
-    switch (nFlag)
+    switch (eStructType)
     {
-        case STRUCT_FOLDER:
+        case StructType::Folder:
             m_xTlbStruct->insert(pParent, nPos, &rText, &sId, nullptr, nullptr,
                                  false, &rRet);
             m_xTlbStruct->set_image(rRet, BMP_STR_OPEN);
             bEntry = true;
             break;
-        case STRUCT_END:
+        case StructType::End:
             m_xTlbStruct->insert(pParent, nPos, &rText, &sId, nullptr, nullptr,
                                  false, &rRet);
             m_xTlbStruct->set_image(rRet, maImgEnd);
             bEntry = true;
             break;
-        case STRUCT_ERROR:
+        case StructType::Error:
             m_xTlbStruct->insert(pParent, nPos, &rText, &sId, nullptr, nullptr,
                                  false, &rRet);
             m_xTlbStruct->set_image(rRet, maImgError);
diff --git a/formula/source/ui/dlg/structpg.hxx 
b/formula/source/ui/dlg/structpg.hxx
index 11640318990f..9c5f836823ed 100644
--- a/formula/source/ui/dlg/structpg.hxx
+++ b/formula/source/ui/dlg/structpg.hxx
@@ -19,6 +19,7 @@
 
 #pragma once
 
+#include <formula/formula.hxx>
 #include <vcl/weld.hxx>
 
 namespace formula
@@ -56,7 +57,7 @@ public:
 
     void            ClearStruct();
     bool InsertEntry(const OUString& rText, const weld::TreeIter* pParent,
-                     sal_uInt16 nFlag, int nPos,
+                     StructType eStructType, int nPos,
                      const FormulaToken* pIFormulaToken,
                      weld::TreeIter& rRet);
 
diff --git a/include/formula/formula.hxx b/include/formula/formula.hxx
index c99daabcfe97..fdea0ef371e8 100644
--- a/include/formula/formula.hxx
+++ b/include/formula/formula.hxx
@@ -37,10 +37,12 @@ class SfxChildWindow;
 
 namespace formula
 {
-
-#define STRUCT_END    1
-#define STRUCT_FOLDER 2
-#define STRUCT_ERROR  3
+enum class StructType
+{
+    End,
+    Folder,
+    Error,
+};
 
 enum class FormulaDlgMode { Formula, Edit };
 

Reply via email to