From 572681bfc7bb141c9f16694df05a505e9d9f1a88 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Sat, 25 Jan 2020 12:11:26 +0100 Subject: Change some #define to constexpr ...plus loplugin:unnecessaryparen fallout in sw/source/uibase/docvw/edtwin.cxx. Each of the files contained at least one #define that would have caused warnings with upcoming loplugin:unsignedcompare. For consistency, I changed all #defines in those files (using a variable of a specific type if the original #define used a cast to that type, otherwise using 'auto'). Change-Id: I66f71b2d83394c9dc6952ae19df774cdd4d0b76a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87374 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- include/basic/sbxdef.hxx | 58 +++---- include/editeng/adjustitem.hxx | 2 +- include/editeng/boxitem.hxx | 4 +- include/editeng/brushitem.hxx | 2 +- include/editeng/fhgtitem.hxx | 4 +- include/editeng/formatbreakitem.hxx | 2 +- include/store/types.h | 14 +- include/svtools/ruler.hxx | 32 ++-- include/vcl/keycodes.hxx | 256 +++++++++++++++--------------- include/vcl/menu.hxx | 6 +- include/vcl/toolbox.hxx | 4 +- reportdesign/source/ui/inc/CondFormat.hxx | 2 +- sal/rtl/alloc_arena.hxx | 14 +- store/source/storbios.cxx | 2 +- sw/source/uibase/docvw/edtwin.cxx | 2 +- 15 files changed, 202 insertions(+), 202 deletions(-) diff --git a/include/basic/sbxdef.hxx b/include/basic/sbxdef.hxx index 93cad7008f6f..2acbac0c98be 100644 --- a/include/basic/sbxdef.hxx +++ b/include/basic/sbxdef.hxx @@ -156,55 +156,55 @@ namespace o3tl // List of all creators for Load/Store -#define SBXCR_SBX 0x20584253 // SBX(blank) +constexpr auto SBXCR_SBX = 0x20584253; // SBX(blank) // List of predefined SBX-IDs. New SBX-IDs must be precisely defined so that // they are unique within the Stream and appropriate Factory. -#define SBXID_VALUE 0x4E4E // NN: SbxValue -#define SBXID_VARIABLE 0x4156 // VA: SbxVariable -#define SBXID_ARRAY 0x5241 // AR: SbxArray -#define SBXID_DIMARRAY 0x4944 // DI: SbxDimArray -#define SBXID_OBJECT 0x424F // OB: SbxObject -#define SBXID_COLLECTION 0x4F43 // CO: SbxCollection -#define SBXID_FIXCOLLECTION 0x4346 // FC: SbxStdCollection -#define SBXID_METHOD 0x454D // ME: SbxMethod -#define SBXID_PROPERTY 0x5250 // PR: SbxProperty +constexpr auto SBXID_VALUE = 0x4E4E; // NN: SbxValue +constexpr auto SBXID_VARIABLE = 0x4156; // VA: SbxVariable +constexpr auto SBXID_ARRAY = 0x5241; // AR: SbxArray +constexpr auto SBXID_DIMARRAY = 0x4944; // DI: SbxDimArray +constexpr auto SBXID_OBJECT = 0x424F; // OB: SbxObject +constexpr auto SBXID_COLLECTION = 0x4F43; // CO: SbxCollection +constexpr auto SBXID_FIXCOLLECTION = 0x4346; // FC: SbxStdCollection +constexpr auto SBXID_METHOD = 0x454D; // ME: SbxMethod +constexpr auto SBXID_PROPERTY = 0x5250; // PR: SbxProperty // StarBASIC restricts the base data type to different intervals. // These intervals are fixed to create 'portability and independent // of the implementation. Only type double is greedy and takes // what it gets. -#define SbxMAXCHAR (u'\xFFFF') -#define SbxMINCHAR (0) -#define SbxMAXBYTE ( 255) -#define SbxMAXINT ( 32767) -#define SbxMININT (-32768) -#define SbxMAXUINT (sal_uInt16(65535)) -#define SbxMAXLNG ( 2147483647) -#define SbxMINLNG (sal_Int32(-2147483647-1)) -#define SbxMAXULNG (sal_uInt32(0xffffffff)) +constexpr auto SbxMAXCHAR = u'\xFFFF'; +constexpr auto SbxMINCHAR = 0; +constexpr auto SbxMAXBYTE = 255; +constexpr auto SbxMAXINT = 32767; +constexpr auto SbxMININT = -32768; +constexpr sal_uInt16 SbxMAXUINT = 65535; +constexpr auto SbxMAXLNG = 2147483647; +constexpr sal_Int32 SbxMINLNG = -2147483647-1; +constexpr sal_uInt32 SbxMAXULNG = 0xffffffff; // Currency stored as SbxSALINT64 == sal_Int64 // value range limits are ~(2^63 - 1)/10000 // fixed precision has 4 digits right of decimal pt -#define CURRENCY_FACTOR (10000) -#define CURRENCY_FACTOR_SQUARE (100000000) +constexpr auto CURRENCY_FACTOR = 10000; +constexpr auto CURRENCY_FACTOR_SQUARE = 100000000; // TODO effective MAX/MINCURR limits: // true value ( 922337203685477.5807) is too precise for correct comparison to 64bit double -#define SbxMAXCURR ( 922337203685477.5807) -#define SbxMINCURR (-922337203685477.5808) +constexpr auto SbxMAXCURR = 922337203685477.5807; +constexpr auto SbxMINCURR = -922337203685477.5808; -#define SbxMAXSNG ( 3.402823e+38) -#define SbxMINSNG (-3.402823e+38) -#define SbxMAXSNG2 ( 1.175494351e-38) -#define SbxMINSNG2 (-1.175494351e-38) +constexpr auto SbxMAXSNG = 3.402823e+38; +constexpr auto SbxMINSNG = -3.402823e+38; +constexpr auto SbxMAXSNG2 = 1.175494351e-38; +constexpr auto SbxMINSNG2 = -1.175494351e-38; // Max valid offset index of a Sbx-Array (due to 64K limit) -#define SBX_MAXINDEX 0x3FF0 -#define SBX_MAXINDEX32 SbxMAXLNG +constexpr auto SBX_MAXINDEX = 0x3FF0; +constexpr auto SBX_MAXINDEX32 = SbxMAXLNG; // The numeric values of sal_True and FALSE enum SbxBOOL { SbxFALSE = 0, SbxTRUE = -1 }; diff --git a/include/editeng/adjustitem.hxx b/include/editeng/adjustitem.hxx index 5075901273ba..e2793907736c 100644 --- a/include/editeng/adjustitem.hxx +++ b/include/editeng/adjustitem.hxx @@ -30,7 +30,7 @@ [Description] This item describes the row orientation. */ -#define ADJUST_LASTBLOCK_VERSION (sal_uInt16(0x0001)) +constexpr sal_uInt16 ADJUST_LASTBLOCK_VERSION = 0x0001; class EDITENG_DLLPUBLIC SvxAdjustItem final : public SfxEnumItemInterface { diff --git a/include/editeng/boxitem.hxx b/include/editeng/boxitem.hxx index c63953cf5909..7ebb52b12212 100644 --- a/include/editeng/boxitem.hxx +++ b/include/editeng/boxitem.hxx @@ -45,12 +45,12 @@ enum class SvxBoxItemLine This version causes SvxBoxItem to store the 4 cell spacing distances separately when serializing to stream. */ -#define BOX_4DISTS_VERSION (sal_uInt16(1)) +constexpr sal_uInt16 BOX_4DISTS_VERSION = 1; /** This version causes SvxBoxItem to store the styles for its border lines when serializing to stream. */ -#define BOX_BORDER_STYLE_VERSION (sal_uInt16(2)) +constexpr sal_uInt16 BOX_BORDER_STYLE_VERSION = 2; class EDITENG_DLLPUBLIC SvxBoxItem final : public SfxPoolItem { diff --git a/include/editeng/brushitem.hxx b/include/editeng/brushitem.hxx index 61550a15d2a6..ab93873740a8 100644 --- a/include/editeng/brushitem.hxx +++ b/include/editeng/brushitem.hxx @@ -30,7 +30,7 @@ class Graphic; class GraphicObject; -#define BRUSH_GRAPHIC_VERSION (sal_uInt16(0x0001)) +constexpr sal_uInt16 BRUSH_GRAPHIC_VERSION = 0x0001; enum SvxGraphicPosition { diff --git a/include/editeng/fhgtitem.hxx b/include/editeng/fhgtitem.hxx index fd636afa54ee..2bd3f583d293 100644 --- a/include/editeng/fhgtitem.hxx +++ b/include/editeng/fhgtitem.hxx @@ -33,8 +33,8 @@ This item describes the font height */ -#define FONTHEIGHT_16_VERSION (sal_uInt16(0x0001)) -#define FONTHEIGHT_UNIT_VERSION (sal_uInt16(0x0002)) +constexpr sal_uInt16 FONTHEIGHT_16_VERSION = 0x0001; +constexpr sal_uInt16 FONTHEIGHT_UNIT_VERSION = 0x0002; class EDITENG_DLLPUBLIC SvxFontHeightItem final : public SfxPoolItem { diff --git a/include/editeng/formatbreakitem.hxx b/include/editeng/formatbreakitem.hxx index 36aacdf4d919..71f33176990f 100644 --- a/include/editeng/formatbreakitem.hxx +++ b/include/editeng/formatbreakitem.hxx @@ -31,7 +31,7 @@ This item describes a wrap-attribute Automatic?, Page or column break, before or after? */ -#define FMTBREAK_NOAUTO (sal_uInt16(0x0001)) +constexpr sal_uInt16 FMTBREAK_NOAUTO = 0x0001; class EDITENG_DLLPUBLIC SvxFormatBreakItem final : public SfxEnumItem { diff --git a/include/store/types.h b/include/store/types.h index d31482fd946c..309456c3cce8 100644 --- a/include/store/types.h +++ b/include/store/types.h @@ -29,29 +29,29 @@ extern "C" { /** PageSize (recommended) default. @see store_openFile() */ -#define STORE_DEFAULT_PAGESIZE ((sal_uInt16)0x0400) +constexpr sal_uInt16 STORE_DEFAULT_PAGESIZE = 0x0400; /** PageSize (enforced) limits. @see store_openFile() */ -#define STORE_MINIMUM_PAGESIZE ((sal_uInt16)0x0200) -#define STORE_MAXIMUM_PAGESIZE ((sal_uInt16)0x8000) +constexpr sal_uInt16 STORE_MINIMUM_PAGESIZE = 0x0200; +constexpr sal_uInt16 STORE_MAXIMUM_PAGESIZE = 0x8000; /** NameSize (enforced) limit. @see any param pName @see store_E_NameTooLong */ -#define STORE_MAXIMUM_NAMESIZE 256 +constexpr auto STORE_MAXIMUM_NAMESIZE = 256; /** Attributes (predefined). @see store_attrib() */ -#define STORE_ATTRIB_ISLINK ((sal_uInt32)0x10000000) -#define STORE_ATTRIB_ISDIR ((sal_uInt32)0x20000000) -#define STORE_ATTRIB_ISFILE ((sal_uInt32)0x40000000) +constexpr sal_uInt32 STORE_ATTRIB_ISLINK = 0x10000000; +constexpr sal_uInt32 STORE_ATTRIB_ISDIR = 0x20000000; +constexpr sal_uInt32 STORE_ATTRIB_ISFILE = 0x40000000; /** Access Mode enumeration. diff --git a/include/svtools/ruler.hxx b/include/svtools/ruler.hxx index 2bd3a4b132bb..2872fbf82073 100644 --- a/include/svtools/ruler.hxx +++ b/include/svtools/ruler.hxx @@ -460,9 +460,9 @@ Tips for the use of the ruler: *************************************************************************/ -#define WB_EXTRAFIELD (WinBits(0x00004000)) -#define WB_RIGHT_ALIGNED (WinBits(0x00008000)) -#define WB_STDRULER WB_HORZ +constexpr WinBits WB_EXTRAFIELD = 0x00004000; +constexpr WinBits WB_RIGHT_ALIGNED = 0x00008000; +constexpr auto WB_STDRULER = WB_HORZ; enum class RulerType { DontKnow, Outside, @@ -471,9 +471,9 @@ enum class RulerType { DontKnow, Outside, enum class RulerExtra { DontKnow, NullOffset, Tab }; -#define RULER_STYLE_HIGHLIGHT (sal_uInt16(0x8000)) -#define RULER_STYLE_DONTKNOW (sal_uInt16(0x4000)) -#define RULER_STYLE_INVISIBLE (sal_uInt16(0x2000)) +constexpr sal_uInt16 RULER_STYLE_HIGHLIGHT = 0x8000; +constexpr sal_uInt16 RULER_STYLE_DONTKNOW = 0x4000; +constexpr sal_uInt16 RULER_STYLE_INVISIBLE = 0x2000; enum class RulerDragSize { Move, @@ -481,9 +481,9 @@ enum class RulerDragSize { N2 }; -#define RULER_MOUSE_BORDERMOVE 5 -#define RULER_MOUSE_BORDERWIDTH 5 -#define RULER_MOUSE_MARGINWIDTH 3 +constexpr auto RULER_MOUSE_BORDERMOVE = 5; +constexpr auto RULER_MOUSE_BORDERWIDTH = 5; +constexpr auto RULER_MOUSE_MARGINWIDTH = 3; enum class RulerMarginStyle { @@ -527,13 +527,13 @@ struct RulerIndent }; -#define RULER_TAB_LEFT (sal_uInt16(0x0000)) -#define RULER_TAB_RIGHT (sal_uInt16(0x0001)) -#define RULER_TAB_CENTER (sal_uInt16(0x0002)) -#define RULER_TAB_DECIMAL (sal_uInt16(0x0003)) -#define RULER_TAB_DEFAULT (sal_uInt16(0x0004)) -#define RULER_TAB_STYLE (sal_uInt16(0x000F)) -#define RULER_TAB_RTL (sal_uInt16(0x0010)) +constexpr sal_uInt16 RULER_TAB_LEFT = 0x0000; +constexpr sal_uInt16 RULER_TAB_RIGHT = 0x0001; +constexpr sal_uInt16 RULER_TAB_CENTER = 0x0002; +constexpr sal_uInt16 RULER_TAB_DECIMAL = 0x0003; +constexpr sal_uInt16 RULER_TAB_DEFAULT = 0x0004; +constexpr sal_uInt16 RULER_TAB_STYLE = 0x000F; +constexpr sal_uInt16 RULER_TAB_RTL = 0x0010; struct RulerTab { diff --git a/include/vcl/keycodes.hxx b/include/vcl/keycodes.hxx index a17da6f95bd4..c262610fd35b 100644 --- a/include/vcl/keycodes.hxx +++ b/include/vcl/keycodes.hxx @@ -24,140 +24,140 @@ #include #include -#define KEY_CODE_MASK (sal_uInt16(0x0FFF)) +constexpr sal_uInt16 KEY_CODE_MASK = 0x0FFF; // Modifier keys -#define KEY_SHIFT (sal_uInt16(0x1000)) -#define KEY_MOD1 (sal_uInt16(0x2000)) -#define KEY_MOD2 (sal_uInt16(0x4000)) -#define KEY_MOD3 (sal_uInt16(0x8000)) -#define KEY_MODIFIERS_MASK (sal_uInt16(0xF000)) +constexpr sal_uInt16 KEY_SHIFT = 0x1000; +constexpr sal_uInt16 KEY_MOD1 = 0x2000; +constexpr sal_uInt16 KEY_MOD2 = 0x4000; +constexpr sal_uInt16 KEY_MOD3 = 0x8000; +constexpr sal_uInt16 KEY_MODIFIERS_MASK = 0xF000; // Key groups -#define KEYGROUP_NUM (sal_uInt16(css::awt::KeyGroup::NUM)) -#define KEYGROUP_ALPHA (sal_uInt16(css::awt::KeyGroup::ALPHA)) -#define KEYGROUP_FKEYS (sal_uInt16(css::awt::KeyGroup::FKEYS)) -#define KEYGROUP_CURSOR (sal_uInt16(css::awt::KeyGroup::CURSOR)) -#define KEYGROUP_MISC (sal_uInt16(css::awt::KeyGroup::MISC)) -#define KEYGROUP_TYPE (sal_uInt16(css::awt::KeyGroup::TYPE)) +constexpr sal_uInt16 KEYGROUP_NUM = css::awt::KeyGroup::NUM; +constexpr sal_uInt16 KEYGROUP_ALPHA = css::awt::KeyGroup::ALPHA; +constexpr sal_uInt16 KEYGROUP_FKEYS = css::awt::KeyGroup::FKEYS; +constexpr sal_uInt16 KEYGROUP_CURSOR = css::awt::KeyGroup::CURSOR; +constexpr sal_uInt16 KEYGROUP_MISC = css::awt::KeyGroup::MISC; +constexpr sal_uInt16 KEYGROUP_TYPE = css::awt::KeyGroup::TYPE; // Key codes -#define KEY_0 (sal_uInt16(css::awt::Key::NUM0)) -#define KEY_1 (sal_uInt16(css::awt::Key::NUM1)) -#define KEY_2 (sal_uInt16(css::awt::Key::NUM2)) -#define KEY_3 (sal_uInt16(css::awt::Key::NUM3)) -#define KEY_4 (sal_uInt16(css::awt::Key::NUM4)) -#define KEY_5 (sal_uInt16(css::awt::Key::NUM5)) -#define KEY_6 (sal_uInt16(css::awt::Key::NUM6)) -#define KEY_7 (sal_uInt16(css::awt::Key::NUM7)) -#define KEY_8 (sal_uInt16(css::awt::Key::NUM8)) -#define KEY_9 (sal_uInt16(css::awt::Key::NUM9)) - -#define KEY_A (sal_uInt16(css::awt::Key::A)) -#define KEY_B (sal_uInt16(css::awt::Key::B)) -#define KEY_C (sal_uInt16(css::awt::Key::C)) -#define KEY_D (sal_uInt16(css::awt::Key::D)) -#define KEY_E (sal_uInt16(css::awt::Key::E)) -#define KEY_F (sal_uInt16(css::awt::Key::F)) -#define KEY_G (sal_uInt16(css::awt::Key::G)) -#define KEY_H (sal_uInt16(css::awt::Key::H)) -#define KEY_I (sal_uInt16(css::awt::Key::I)) -#define KEY_J (sal_uInt16(css::awt::Key::J)) -#define KEY_K (sal_uInt16(css::awt::Key::K)) -#define KEY_L (sal_uInt16(css::awt::Key::L)) -#define KEY_M (sal_uInt16(css::awt::Key::M)) -#define KEY_N (sal_uInt16(css::awt::Key::N)) -#define KEY_O (sal_uInt16(css::awt::Key::O)) -#define KEY_P (sal_uInt16(css::awt::Key::P)) -#define KEY_Q (sal_uInt16(css::awt::Key::Q)) -#define KEY_R (sal_uInt16(css::awt::Key::R)) -#define KEY_S (sal_uInt16(css::awt::Key::S)) -#define KEY_T (sal_uInt16(css::awt::Key::T)) -#define KEY_U (sal_uInt16(css::awt::Key::U)) -#define KEY_V (sal_uInt16(css::awt::Key::V)) -#define KEY_W (sal_uInt16(css::awt::Key::W)) -#define KEY_X (sal_uInt16(css::awt::Key::X)) -#define KEY_Y (sal_uInt16(css::awt::Key::Y)) -#define KEY_Z (sal_uInt16(css::awt::Key::Z)) - -#define KEY_F1 (sal_uInt16(css::awt::Key::F1)) -#define KEY_F2 (sal_uInt16(css::awt::Key::F2)) -#define KEY_F3 (sal_uInt16(css::awt::Key::F3)) -#define KEY_F4 (sal_uInt16(css::awt::Key::F4)) -#define KEY_F5 (sal_uInt16(css::awt::Key::F5)) -#define KEY_F6 (sal_uInt16(css::awt::Key::F6)) -#define KEY_F7 (sal_uInt16(css::awt::Key::F7)) -#define KEY_F8 (sal_uInt16(css::awt::Key::F8)) -#define KEY_F9 (sal_uInt16(css::awt::Key::F9)) -#define KEY_F10 (sal_uInt16(css::awt::Key::F10)) -#define KEY_F11 (sal_uInt16(css::awt::Key::F11)) -#define KEY_F12 (sal_uInt16(css::awt::Key::F12)) -#define KEY_F13 (sal_uInt16(css::awt::Key::F13)) -#define KEY_F14 (sal_uInt16(css::awt::Key::F14)) -#define KEY_F15 (sal_uInt16(css::awt::Key::F15)) -#define KEY_F16 (sal_uInt16(css::awt::Key::F16)) -#define KEY_F17 (sal_uInt16(css::awt::Key::F17)) -#define KEY_F18 (sal_uInt16(css::awt::Key::F18)) -#define KEY_F19 (sal_uInt16(css::awt::Key::F19)) -#define KEY_F20 (sal_uInt16(css::awt::Key::F20)) -#define KEY_F21 (sal_uInt16(css::awt::Key::F21)) -#define KEY_F22 (sal_uInt16(css::awt::Key::F22)) -#define KEY_F23 (sal_uInt16(css::awt::Key::F23)) -#define KEY_F24 (sal_uInt16(css::awt::Key::F24)) -#define KEY_F25 (sal_uInt16(css::awt::Key::F25)) -#define KEY_F26 (sal_uInt16(css::awt::Key::F26)) - -#define KEY_DOWN (sal_uInt16(css::awt::Key::DOWN)) -#define KEY_UP (sal_uInt16(css::awt::Key::UP)) -#define KEY_LEFT (sal_uInt16(css::awt::Key::LEFT)) -#define KEY_RIGHT (sal_uInt16(css::awt::Key::RIGHT)) -#define KEY_HOME (sal_uInt16(css::awt::Key::HOME)) -#define KEY_END (sal_uInt16(css::awt::Key::END)) -#define KEY_PAGEUP (sal_uInt16(css::awt::Key::PAGEUP)) -#define KEY_PAGEDOWN (sal_uInt16(css::awt::Key::PAGEDOWN)) - -#define KEY_RETURN (sal_uInt16(css::awt::Key::RETURN)) -#define KEY_ESCAPE (sal_uInt16(css::awt::Key::ESCAPE)) -#define KEY_TAB (sal_uInt16(css::awt::Key::TAB)) -#define KEY_BACKSPACE (sal_uInt16(css::awt::Key::BACKSPACE)) -#define KEY_SPACE (sal_uInt16(css::awt::Key::SPACE)) -#define KEY_INSERT (sal_uInt16(css::awt::Key::INSERT)) -#define KEY_DELETE (sal_uInt16(css::awt::Key::DELETE)) - -#define KEY_ADD (sal_uInt16(css::awt::Key::ADD)) -#define KEY_SUBTRACT (sal_uInt16(css::awt::Key::SUBTRACT)) -#define KEY_MULTIPLY (sal_uInt16(css::awt::Key::MULTIPLY)) -#define KEY_DIVIDE (sal_uInt16(css::awt::Key::DIVIDE)) -#define KEY_POINT (sal_uInt16(css::awt::Key::POINT)) -#define KEY_COMMA (sal_uInt16(css::awt::Key::COMMA)) -#define KEY_LESS (sal_uInt16(css::awt::Key::LESS)) -#define KEY_GREATER (sal_uInt16(css::awt::Key::GREATER)) -#define KEY_EQUAL (sal_uInt16(css::awt::Key::EQUAL)) - -#define KEY_OPEN (sal_uInt16(css::awt::Key::OPEN)) -#define KEY_CUT (sal_uInt16(css::awt::Key::CUT)) -#define KEY_COPY (sal_uInt16(css::awt::Key::COPY)) -#define KEY_PASTE (sal_uInt16(css::awt::Key::PASTE)) -#define KEY_UNDO (sal_uInt16(css::awt::Key::UNDO)) -#define KEY_REPEAT (sal_uInt16(css::awt::Key::REPEAT)) -#define KEY_FIND (sal_uInt16(css::awt::Key::FIND)) -#define KEY_PROPERTIES (sal_uInt16(css::awt::Key::PROPERTIES)) -#define KEY_FRONT (sal_uInt16(css::awt::Key::FRONT)) -#define KEY_CONTEXTMENU (sal_uInt16(css::awt::Key::CONTEXTMENU)) -#define KEY_MENU (sal_uInt16(css::awt::Key::MENU)) -#define KEY_HELP (sal_uInt16(css::awt::Key::HELP)) -#define KEY_HANGUL_HANJA (sal_uInt16(css::awt::Key::HANGUL_HANJA)) -#define KEY_DECIMAL (sal_uInt16(css::awt::Key::DECIMAL)) -#define KEY_TILDE (sal_uInt16(css::awt::Key::TILDE)) -#define KEY_QUOTELEFT (sal_uInt16(css::awt::Key::QUOTELEFT)) -#define KEY_BRACKETLEFT (sal_uInt16(css::awt::Key::BRACKETLEFT)) -#define KEY_BRACKETRIGHT (sal_uInt16(css::awt::Key::BRACKETRIGHT)) -#define KEY_SEMICOLON (sal_uInt16(css::awt::Key::SEMICOLON)) -#define KEY_QUOTERIGHT (sal_uInt16(css::awt::Key::QUOTERIGHT)) - -#define KEY_CAPSLOCK (sal_uInt16(css::awt::Key::CAPSLOCK)) -#define KEY_NUMLOCK (sal_uInt16(css::awt::Key::NUMLOCK)) -#define KEY_SCROLLLOCK (sal_uInt16(css::awt::Key::SCROLLLOCK)) +constexpr sal_uInt16 KEY_0 = css::awt::Key::NUM0; +constexpr sal_uInt16 KEY_1 = css::awt::Key::NUM1; +constexpr sal_uInt16 KEY_2 = css::awt::Key::NUM2; +constexpr sal_uInt16 KEY_3 = css::awt::Key::NUM3; +constexpr sal_uInt16 KEY_4 = css::awt::Key::NUM4; +constexpr sal_uInt16 KEY_5 = css::awt::Key::NUM5; +constexpr sal_uInt16 KEY_6 = css::awt::Key::NUM6; +constexpr sal_uInt16 KEY_7 = css::awt::Key::NUM7; +constexpr sal_uInt16 KEY_8 = css::awt::Key::NUM8; +constexpr sal_uInt16 KEY_9 = css::awt::Key::NUM9; + +constexpr sal_uInt16 KEY_A = css::awt::Key::A; +constexpr sal_uInt16 KEY_B = css::awt::Key::B; +constexpr sal_uInt16 KEY_C = css::awt::Key::C; +constexpr sal_uInt16 KEY_D = css::awt::Key::D; +constexpr sal_uInt16 KEY_E = css::awt::Key::E; +constexpr sal_uInt16 KEY_F = css::awt::Key::F; +constexpr sal_uInt16 KEY_G = css::awt::Key::G; +constexpr sal_uInt16 KEY_H = css::awt::Key::H; +constexpr sal_uInt16 KEY_I = css::awt::Key::I; +constexpr sal_uInt16 KEY_J = css::awt::Key::J; +constexpr sal_uInt16 KEY_K = css::awt::Key::K; +constexpr sal_uInt16 KEY_L = css::awt::Key::L; +constexpr sal_uInt16 KEY_M = css::awt::Key::M; +constexpr sal_uInt16 KEY_N = css::awt::Key::N; +constexpr sal_uInt16 KEY_O = css::awt::Key::O; +constexpr sal_uInt16 KEY_P = css::awt::Key::P; +constexpr sal_uInt16 KEY_Q = css::awt::Key::Q; +constexpr sal_uInt16 KEY_R = css::awt::Key::R; +constexpr sal_uInt16 KEY_S = css::awt::Key::S; +constexpr sal_uInt16 KEY_T = css::awt::Key::T; +constexpr sal_uInt16 KEY_U = css::awt::Key::U; +constexpr sal_uInt16 KEY_V = css::awt::Key::V; +constexpr sal_uInt16 KEY_W = css::awt::Key::W; +constexpr sal_uInt16 KEY_X = css::awt::Key::X; +constexpr sal_uInt16 KEY_Y = css::awt::Key::Y; +constexpr sal_uInt16 KEY_Z = css::awt::Key::Z; + +constexpr sal_uInt16 KEY_F1 = css::awt::Key::F1; +constexpr sal_uInt16 KEY_F2 = css::awt::Key::F2; +constexpr sal_uInt16 KEY_F3 = css::awt::Key::F3; +constexpr sal_uInt16 KEY_F4 = css::awt::Key::F4; +constexpr sal_uInt16 KEY_F5 = css::awt::Key::F5; +constexpr sal_uInt16 KEY_F6 = css::awt::Key::F6; +constexpr sal_uInt16 KEY_F7 = css::awt::Key::F7; +constexpr sal_uInt16 KEY_F8 = css::awt::Key::F8; +constexpr sal_uInt16 KEY_F9 = css::awt::Key::F9; +constexpr sal_uInt16 KEY_F10 = css::awt::Key::F10; +constexpr sal_uInt16 KEY_F11 = css::awt::Key::F11; +constexpr sal_uInt16 KEY_F12 = css::awt::Key::F12; +constexpr sal_uInt16 KEY_F13 = css::awt::Key::F13; +constexpr sal_uInt16 KEY_F14 = css::awt::Key::F14; +constexpr sal_uInt16 KEY_F15 = css::awt::Key::F15; +constexpr sal_uInt16 KEY_F16 = css::awt::Key::F16; +constexpr sal_uInt16 KEY_F17 = css::awt::Key::F17; +constexpr sal_uInt16 KEY_F18 = css::awt::Key::F18; +constexpr sal_uInt16 KEY_F19 = css::awt::Key::F19; +constexpr sal_uInt16 KEY_F20 = css::awt::Key::F20; +constexpr sal_uInt16 KEY_F21 = css::awt::Key::F21; +constexpr sal_uInt16 KEY_F22 = css::awt::Key::F22; +constexpr sal_uInt16 KEY_F23 = css::awt::Key::F23; +constexpr sal_uInt16 KEY_F24 = css::awt::Key::F24; +constexpr sal_uInt16 KEY_F25 = css::awt::Key::F25; +constexpr sal_uInt16 KEY_F26 = css::awt::Key::F26; + +constexpr sal_uInt16 KEY_DOWN = css::awt::Key::DOWN; +constexpr sal_uInt16 KEY_UP = css::awt::Key::UP; +constexpr sal_uInt16 KEY_LEFT = css::awt::Key::LEFT; +constexpr sal_uInt16 KEY_RIGHT = css::awt::Key::RIGHT; +constexpr sal_uInt16 KEY_HOME = css::awt::Key::HOME; +constexpr sal_uInt16 KEY_END = css::awt::Key::END; +constexpr sal_uInt16 KEY_PAGEUP = css::awt::Key::PAGEUP; +constexpr sal_uInt16 KEY_PAGEDOWN = css::awt::Key::PAGEDOWN; + +constexpr sal_uInt16 KEY_RETURN = css::awt::Key::RETURN; +constexpr sal_uInt16 KEY_ESCAPE = css::awt::Key::ESCAPE; +constexpr sal_uInt16 KEY_TAB = css::awt::Key::TAB; +constexpr sal_uInt16 KEY_BACKSPACE = css::awt::Key::BACKSPACE; +constexpr sal_uInt16 KEY_SPACE = css::awt::Key::SPACE; +constexpr sal_uInt16 KEY_INSERT = css::awt::Key::INSERT; +constexpr sal_uInt16 KEY_DELETE = css::awt::Key::DELETE; + +constexpr sal_uInt16 KEY_ADD = css::awt::Key::ADD; +constexpr sal_uInt16 KEY_SUBTRACT = css::awt::Key::SUBTRACT; +constexpr sal_uInt16 KEY_MULTIPLY = css::awt::Key::MULTIPLY; +constexpr sal_uInt16 KEY_DIVIDE = css::awt::Key::DIVIDE; +constexpr sal_uInt16 KEY_POINT = css::awt::Key::POINT; +constexpr sal_uInt16 KEY_COMMA = css::awt::Key::COMMA; +constexpr sal_uInt16 KEY_LESS = css::awt::Key::LESS; +constexpr sal_uInt16 KEY_GREATER = css::awt::Key::GREATER; +constexpr sal_uInt16 KEY_EQUAL = css::awt::Key::EQUAL; + +constexpr sal_uInt16 KEY_OPEN = css::awt::Key::OPEN; +constexpr sal_uInt16 KEY_CUT = css::awt::Key::CUT; +constexpr sal_uInt16 KEY_COPY = css::awt::Key::COPY; +constexpr sal_uInt16 KEY_PASTE = css::awt::Key::PASTE; +constexpr sal_uInt16 KEY_UNDO = css::awt::Key::UNDO; +constexpr sal_uInt16 KEY_REPEAT = css::awt::Key::REPEAT; +constexpr sal_uInt16 KEY_FIND = css::awt::Key::FIND; +constexpr sal_uInt16 KEY_PROPERTIES = css::awt::Key::PROPERTIES; +constexpr sal_uInt16 KEY_FRONT = css::awt::Key::FRONT; +constexpr sal_uInt16 KEY_CONTEXTMENU = css::awt::Key::CONTEXTMENU; +constexpr sal_uInt16 KEY_MENU = css::awt::Key::MENU; +constexpr sal_uInt16 KEY_HELP = css::awt::Key::HELP; +constexpr sal_uInt16 KEY_HANGUL_HANJA = css::awt::Key::HANGUL_HANJA; +constexpr sal_uInt16 KEY_DECIMAL = css::awt::Key::DECIMAL; +constexpr sal_uInt16 KEY_TILDE = css::awt::Key::TILDE; +constexpr sal_uInt16 KEY_QUOTELEFT = css::awt::Key::QUOTELEFT; +constexpr sal_uInt16 KEY_BRACKETLEFT = css::awt::Key::BRACKETLEFT; +constexpr sal_uInt16 KEY_BRACKETRIGHT = css::awt::Key::BRACKETRIGHT; +constexpr sal_uInt16 KEY_SEMICOLON = css::awt::Key::SEMICOLON; +constexpr sal_uInt16 KEY_QUOTERIGHT = css::awt::Key::QUOTERIGHT; + +constexpr sal_uInt16 KEY_CAPSLOCK = css::awt::Key::CAPSLOCK; +constexpr sal_uInt16 KEY_NUMLOCK = css::awt::Key::NUMLOCK; +constexpr sal_uInt16 KEY_SCROLLLOCK = css::awt::Key::SCROLLLOCK; // extended Modifier-Keys (only used for modkey events) enum class ModKeyFlags { diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx index 1e8542c0206c..a4360d93ac93 100644 --- a/include/vcl/menu.hxx +++ b/include/vcl/menu.hxx @@ -63,8 +63,8 @@ typedef OutputDevice RenderContext; // same as in include/vcl/outdev.hxx class ILibreOfficeKitNotifier; } -#define MENU_APPEND (sal_uInt16(0xFFFF)) -#define MENU_ITEM_NOTFOUND (sal_uInt16(0xFFFF)) +constexpr sal_uInt16 MENU_APPEND = 0xFFFF; +constexpr sal_uInt16 MENU_ITEM_NOTFOUND = 0xFFFF; // Must match the definitions in css::awt::PopupMenuDirection.idl enum class PopupMenuFlags @@ -103,7 +103,7 @@ namespace o3tl } /// Invalid menu item id -#define ITEMPOS_INVALID 0xFFFF +constexpr auto ITEMPOS_INVALID = 0xFFFF; struct ImplMenuDelData { diff --git a/include/vcl/toolbox.hxx b/include/vcl/toolbox.hxx index a6fd1579560f..a7a9f0598c07 100644 --- a/include/vcl/toolbox.hxx +++ b/include/vcl/toolbox.hxx @@ -42,10 +42,10 @@ class PopupMenu; class VclMenuEvent; class StyleSettings; -#define TOOLBOX_STYLE_FLAT (sal_uInt16(0x0004)) +constexpr sal_uInt16 TOOLBOX_STYLE_FLAT = 0x0004; // item ids in the custom menu may not exceed this constant -#define TOOLBOX_MENUITEM_START (sal_uInt16(0x1000)) +constexpr sal_uInt16 TOOLBOX_MENUITEM_START = 0x1000; // defines for the menubutton enum class ToolBoxMenuType { diff --git a/reportdesign/source/ui/inc/CondFormat.hxx b/reportdesign/source/ui/inc/CondFormat.hxx index 6e87acb9857d..9b648be10c9e 100644 --- a/reportdesign/source/ui/inc/CondFormat.hxx +++ b/reportdesign/source/ui/inc/CondFormat.hxx @@ -28,7 +28,7 @@ namespace rptui { - #define MAX_CONDITIONS size_t(3) + constexpr size_t MAX_CONDITIONS = 3; class OReportController; class Condition; diff --git a/sal/rtl/alloc_arena.hxx b/sal/rtl/alloc_arena.hxx index 7da1c532e30e..7226ef3f111a 100644 --- a/sal/rtl/alloc_arena.hxx +++ b/sal/rtl/alloc_arena.hxx @@ -39,10 +39,10 @@ struct rtl_arena_stat_type /** rtl_arena_segment_type * @internal */ -#define RTL_ARENA_SEGMENT_TYPE_HEAD (sal_Size(0x01)) -#define RTL_ARENA_SEGMENT_TYPE_SPAN (sal_Size(0x02)) -#define RTL_ARENA_SEGMENT_TYPE_FREE (sal_Size(0x04)) -#define RTL_ARENA_SEGMENT_TYPE_USED (sal_Size(0x08)) +constexpr sal_Size RTL_ARENA_SEGMENT_TYPE_HEAD = 0x01; +constexpr sal_Size RTL_ARENA_SEGMENT_TYPE_SPAN = 0x02; +constexpr sal_Size RTL_ARENA_SEGMENT_TYPE_FREE = 0x04; +constexpr sal_Size RTL_ARENA_SEGMENT_TYPE_USED = 0x08; struct rtl_arena_segment_type { @@ -63,10 +63,10 @@ struct rtl_arena_segment_type /** rtl_arena_type * @internal */ -#define RTL_ARENA_FREELIST_SIZE (sizeof(void*) * 8) -#define RTL_ARENA_HASH_SIZE 64 +constexpr auto RTL_ARENA_FREELIST_SIZE = sizeof(void*) * 8; +constexpr auto RTL_ARENA_HASH_SIZE = 64; -#define RTL_ARENA_FLAG_RESCALE 1 /* within hash rescale operation */ +constexpr auto RTL_ARENA_FLAG_RESCALE = 1; /* within hash rescale operation */ struct rtl_arena_st { diff --git a/store/source/storbios.cxx b/store/source/storbios.cxx index a98f4e9a35a3..091d819824b8 100644 --- a/store/source/storbios.cxx +++ b/store/source/storbios.cxx @@ -41,7 +41,7 @@ using namespace store; * OStoreSuperBlock. * *======================================================================*/ -#define STORE_MAGIC_SUPERBLOCK sal_uInt32(0x484D5343) +constexpr sal_uInt32 STORE_MAGIC_SUPERBLOCK = 0x484D5343; namespace { diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index 1a81d0851182..e190e0f1b391 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -2229,7 +2229,7 @@ KEYINPUT_CHECKTABLE_INSDEL: eKeyState = SwKeyState::End; bNormalChar = !rKeyCode.IsMod2() && - rKeyCode.GetModifier() != (KEY_MOD1) && + rKeyCode.GetModifier() != KEY_MOD1 && rKeyCode.GetModifier() != (KEY_MOD1|KEY_SHIFT) && SW_ISPRINTABLE( aCh ); -- cgit