Bug 84938 - replace #defined constants with ‘enum class’
Summary: replace #defined constants with ‘enum class’
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Libreoffice (show other bugs)
Version: unspecified
Hardware: Other All
: medium enhancement
Assignee: Not Assigned
QA Contact:
URL:
Whiteboard: EasyHack DifficultyInteresting SkillC...
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-12 15:39 UTC by Noel Grandin
Modified: 2015-01-12 10:58 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Noel Grandin 2014-10-12 15:39:47 UTC
Use something like this to find them:

$ git grep -P ‘#define\s+\w+\s+\d+’ — *.hxx

Pick any one and convert it to an enum class type.

Along the way convert any required fields and parameters and local variables to use the new enum class type.

Special case: if the pattern of constant values looks like this:

    #define XXX_1   1
    #define XXX_1   2
    #define XXX_1   4

then it is a set of flags and you need to use the template library in

    include/o3tl/typed_flags.hxx

to convert it to a enum.
Comment 1 Terrence Enger 2014-10-13 03:13:25 UTC
Be warned that you need to type in the search command that Noel
provided in the description rather than copying and pasting it into a
command line:

(*) The characters that look like single quotes paste as x'e28098' and
    x'e28099'.  You, of course, want to type single quotes.

(*) The dash should be two hyphens.
Comment 2 Commit Notification 2014-11-01 14:53:56 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=a7542d38ddeebd37ddea233fa1e4cf15b2e03c49

fdo#84938: replace MIB_ constants with enum

It will be available in 4.4.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 3 Commit Notification 2014-11-05 06:47:07 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=3c58f0768049718fae3d47d5ebfa6c7485ad52b1

fdo#84938: replace TOOLBOXITEM_ constants with enum

It will be available in 4.4.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 4 Commit Notification 2014-11-07 12:55:17 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=31d902d3c00fdc5f088aff433b7ebf308a718339

fdo#84938: replace MOUSE_ modifier constants with enum

It will be available in 4.4.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 5 Terrence Enger 2014-11-09 17:00:23 UTC
I have started hacking on the names starting DSID_ defined in
dbaccess/source/ui/inc/dsitems.hxx.  Some observations and questions
arising:

(*) I have the name DatasourceItemId for the class.  Is this good?

(*) The member name looks like a #defined name: uppercase with
    underscores between "words".  Does anybody care for more details?

(*) I have changed to types of data members in some other classes.  I
    do not see why these variables are necessary, but I have not dug
    into the question.

(*) So far, I have arbitrarily limited my changes to dbaccess; when
    an item goes outside the module--SfxItemSet comes to mind--I have
    cast the item to int.  Is this a reasonable way to do it?  Failing
    that, is the result worth anything?

(*) The TODO comments in DriverSettings.cxx were invaluable in
    relieving the feeling of disorientation which comes from thinking,
    over and over, "Damn.  I thought I already changed this."

My plan now is to play with Base a bit.

Terry.
Comment 6 Noel Grandin 2014-11-10 06:05:02 UTC
Glad to here you are working on this!

(In reply to Terrence Enger from comment #5)
> (*) I have the name DatasourceItemId for the class.  Is this good?
> 
Sounds finee.

> (*) The member name looks like a #defined name: uppercase with
>     underscores between "words".  Does anybody care for more details?
> 
Sounds fine.

> (*) I have changed to types of data members in some other classes.  I
>     do not see why these variables are necessary, but I have not dug
>     into the question.
> 
That's pretty normal.

> (*) So far, I have arbitrarily limited my changes to dbaccess; when
>     an item goes outside the module--SfxItemSet comes to mind--I have
>     cast the item to int.  Is this a reasonable way to do it?  Failing
>     that, is the result worth anything?
> 
That's a normal approach, except for cases where something else might be
#including headers from dbaccess, in which case I'd except the code to
be modified to use the new 'enum class' type.
Comment 7 Commit Notification 2014-11-11 06:18:39 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=a52f29216d2a70ea4a0a0347d71273cdbf8830e3

fdo#84938: replace HELPMODE_ constants with enum

It will be available in 4.4.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 8 Commit Notification 2014-12-01 07:44:49 UTC
Tobias Madl committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=14596452e781f6a66bcc63b0c447c852df1f2896

fdo#84938: replace EVENT_ constants with enum

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 9 Commit Notification 2014-12-03 08:26:40 UTC
Tobias Madl committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=57fe57677887dd951000d3317690f8c628a58e02

fdo#84938 replace BASERR_REASON_ constants -> enum

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 10 Commit Notification 2014-12-05 07:59:13 UTC
Jennifer Liebel committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=e53f881b5c5c8968ab060b5e19a2fbebc1510e00

fdo#84938: removed unused defines

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 11 Commit Notification 2014-12-05 08:45:52 UTC
Jennifer Liebel committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=e2e94f1a1241481941548fa94f32bf63e162967b

fdo#84938: removed unused defines

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 12 Commit Notification 2014-12-12 08:08:28 UTC
Tobias Madl committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=f5c5bab09f2e3a7e13a6b397faf4bdfcb898f295

fdo#84938 replace PPT_LAYOUT_ constants with enum

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 13 Commit Notification 2014-12-15 06:49:25 UTC
Tobias Madl committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=e5a03da8eb02c333502d6b427625e7bf554ff203

fdo#84938 replace PPT_PLACEHOLDER_ constants->enum

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 14 Commit Notification 2015-01-05 10:59:22 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=8130714148d58dd2bf1ef12dcc6dd6d5838be0d1

fdo#84938: replace NUMBERFORMAT_INT_ constants with 'enum class'

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 15 Commit Notification 2015-01-06 09:07:17 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=bae855e667993ea6cddd551452c6e2fa60bdc2f3

fdo#84938: replace BUTTONTYPE_ constants with 'enum class'

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 16 Commit Notification 2015-01-06 09:07:21 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=d1ce6effb62745e9f9c85badd44a1be0aa4a1d8f

fdo#84938: convert TEXT_PROP_MAP #defines to 'enum class'

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 17 Commit Notification 2015-01-06 09:07:28 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=dc28e90d200a839d4017d548217ee5ce8a23f848

fdo#84938: convert IMPORT_ constants to 'enum class'

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 18 Commit Notification 2015-01-06 09:07:32 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=ec5bf66d366cd42774a87465e1187271f48a4ab1

fdo#84938: convert XML_EXPORT_FLAG_ to 'enum class'

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 19 Commit Notification 2015-01-06 09:07:36 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=c29657e0d6bb707345584ac7a7f5ae5016f37297

fdo#84938: convert EXPORT_ #defines to 'enum class'

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 20 Commit Notification 2015-01-06 09:07:39 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=8447eeb192acf7e3255f7fdf92977470b28a18f9

fdo#84938: convert ERROR_ #defines to 'enum class'

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 21 Commit Notification 2015-01-06 09:07:43 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=64cccf36f26f6398906a0cc6fc48e76defbe057d

fdo#84938: convert SEF_EXPORT_ #defines to 'enum class'

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 22 Commit Notification 2015-01-06 09:07:48 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=a48d8465c3f9f36a02fb3c6a79f5dbb5851174f7

fdo#84938: convert SELENG_ #defines to 'enum class'

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 23 Commit Notification 2015-01-06 09:07:54 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=abe670157b69aa7fe4b478f1fd13757d7b7fcc4b

fdo#84938: convert CTRL_STATE_ #defines to 'enum class'

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 24 Commit Notification 2015-01-07 09:22:17 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=079590c9097a9491b31f1ef1b30d67d42bd0139a

fdo#84938: convert INDICATOR_ #defines to 'enum class'

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 25 Commit Notification 2015-01-07 09:22:22 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=8aa3cb98adb8675ff3f09d2c1da35d2423e57493

fdo#84938: convert VCL_INPUT_ #defines to 'enum class'

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 26 Commit Notification 2015-01-07 09:22:26 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=7f8f277b94704a289fbbd1b836e4e5d66311580d

fdo#84938: convert STREAM_ #defines to 'enum class'

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 27 Commit Notification 2015-01-07 10:56:01 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=306f04830300c239fd74677bcc61efcb5a4532ea

fdo#84938: convert COMPRESSMODE_ #defines to 'enum class'

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 28 Commit Notification 2015-01-09 07:10:39 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=278b400511a76a9be5e0afc0377a9c69823cc230

fdo#84938: convert POLY_OPTIMIZE_ #defines to 'enum class'

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 29 Commit Notification 2015-01-09 08:09:08 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=cd9e2ecba38c31eb30e05d3ee2c9f4629dd89d40

fdo#84938: replace SYSTEMWINDOW_MODE constants with 'enum class'

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 30 Commit Notification 2015-01-09 08:09:11 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=901e5c3a21a1299d10c44bc844246fe8c329bb82

fdo#84938: convert FRMTYPE_ #defines to 'enum class'

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 31 Commit Notification 2015-01-12 10:58:50 UTC
Noel Grandin committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=a5b5ad9f9306d868430ed9efd210b95c24a15161

fdo#84938: replace DATACHANGED_ constants with 'enum class'

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.