https://bugs.documentfoundation.org/show_bug.cgi?id=145614
Bug ID: 145614
Summary: Convert #define to enum or constexpr
Product: LibreOffice
Version: unspecified
Hardware: All
OS: All
Status: UNCONFIRMED
Keywords: difficultyBeginner, easyHack, skillCpp
Severity: normal
Priority: medium
Component: LibreOffice
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
In some older parts of the code, there are several consecutive symbolic
constants that are #defined, and possibly have similar prefixes. You can
improve this by replacing them with:
a) 'enum class' or 'enum': where facing multiple values of the same category or
with similar prefixes. Some of these enums come from standards or other
external documents or sources. It is good to find the source, and cross-check
the values with it.
'enum class' is preferred to 'enum', but enums with binary or comparison
operations can not be easily converted to 'enum class'.
b) 'constexpr': where there is a single value
For example, in emfio/inc/mtftools.hxx:
/* Mapping modes */
#define MM_TEXT 1
#define MM_LOMETRIC 2
#define MM_HIMETRIC 3
#define MM_LOENGLISH 4
#define MM_HIENGLISH 5
#define MM_TWIPS 6
#define MM_ISOTROPIC 7
#define MM_ANISOTROPIC 8
#define LF_FACESIZE 32
is converted to:
/* Mapping modes */
enum MappingMode
{
MM_TEXT = 0x01,
MM_LOMETRIC = 0x02,
MM_HIMETRIC = 0x03,
MM_LOENGLISH = 0x04,
MM_HIENGLISH = 0x05,
MM_TWIPS = 0x06,
MM_ISOTROPIC = 0x07,
MM_ANISOTROPIC = 0x08
};
constexpr sal_Int32 LF_FACESIZE = 32;
--
You are receiving this mail because:
You are the assignee for the bug.