summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-03-14 15:53:49 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-03-15 06:46:20 +0000
commit2589f090875f3b81d91211e72cf36a6f1441c01a (patch)
treea656787f593cc946971eb55e6c2bccf7071ada6b
parent7f8bc0af4b35c22ead1310984926b26749b3143d (diff)
remove unused HRC defines in sd/
improve the existing 'find unused RID constants' script Change-Id: I6facbf9ef929bd31dc59eba4a1807c72b87cdb2f Reviewed-on: https://gerrit.libreoffice.org/35186 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rwxr-xr-xbin/find-unused-defines-in-hrc-files.py (renamed from bin/find-unused-rid.py)64
-rw-r--r--sd/inc/sdattr.hrc57
2 files changed, 41 insertions, 80 deletions
diff --git a/bin/find-unused-rid.py b/bin/find-unused-defines-in-hrc-files.py
index 82ea29303b0c..f24e1a61b6fe 100755
--- a/bin/find-unused-rid.py
+++ b/bin/find-unused-defines-in-hrc-files.py
@@ -1,10 +1,11 @@
#!/usr/bin/python
-# Search for unused RID_ constants.
+# Search for unused constants in .hrc files.
#
-# Note that sometimes RID constants are calculated, so some careful checking of the output is necessary.
+# Note that sometimes these constants are calculated, so some careful checking of the output is necessary.
+#
+# Takes about 4 hours to run this on a fast machine with an SSD
#
-# Takes about 30min to run this on a fast machine.
import subprocess
import sys
@@ -55,49 +56,54 @@ exclusionSet = set([
"RID_SVXSTR_TRASNGR",
# other places doing calculations
"RID_SVXSTR_DEPTH",
- "RID_SUBSETSTR_"
+ "RID_SUBSETSTR_",
+ "ANALYSIS_"
])
-def startswith_one_of( a, aset ):
- for f in aset:
+def in_exclusion_set( a ):
+ for f in exclusionSet:
if a.startswith(f):
return True;
return False;
-a = subprocess.Popen("git grep -P '^#define\s+RID_\w+\s+' -- *.hrc | sort -u", stdout=subprocess.PIPE, shell=True)
+a = subprocess.Popen("git grep -hP '^#define\s+\w+\s+' -- *.hrc | sort -u", stdout=subprocess.PIPE, shell=True)
with a.stdout as txt:
for line in txt:
idx1 = line.find("#define ")
idx2 = line.find(" ", idx1 + 9)
- ridName = line[idx1+8 : idx2]
+ idName = line[idx1+8 : idx2]
# the various _START and _END constants are normally unused outside of the .hrc and .src files, and that's fine
- if ridName.endswith("_START"): continue
- if ridName.endswith("_BEGIN"): continue
- if ridName.endswith("_END"): continue
- if ridName == "RID_GROUPS_SFXOFFSET": continue
- if ridName == "RID_SVX_FIRSTFREE": continue
- if startswith_one_of(ridName, exclusionSet): continue
+ if idName.endswith("_START"): continue
+ if idName.endswith("_BEGIN"): continue
+ if idName.endswith("_END"): continue
+ if idName.startswith("RID_"):
+ if idName == "RID_GROUPS_SFXOFFSET": continue
+ if idName == "RID_SVX_FIRSTFREE": continue
+ if in_exclusion_set(idName): continue
# search for the constant
- b = subprocess.Popen(["git", "grep", "-w", ridName], stdout=subprocess.PIPE)
- # check if we found one in actual code
- found_in_code = False
- # check that the constant is not being used as an identifier by MenuItem entries in .src files
- found_menu_identifier = False
- # check that the constant is not being used by the property controller extension or report inspection, which use macros
- # to declare constants, hiding them from a search
- found_property_macros = False
+ b = subprocess.Popen(["git", "grep", "-wl", idName], stdout=subprocess.PIPE)
+ found_reason_to_exclude = False
with b.stdout as txt2:
for line2 in txt2:
- if not line2.endswith(".hrc") and not line2.endswith(".src"): found_in_code = True
- if line2.find("Identifier = ") != -1: found_menu_identifier = True
- if line2.find("extensions/source/propctrlr") != -1: found_property_macros = True
- if line2.find("reportdesign/source/ui/inspection/inspection.src") != -1: found_property_macros = True
- if not found_in_code and not found_menu_identifier and not found_property_macros:
- sys.stdout.write(ridName + '\n')
+ line2 = line2.strip() # otherwise the comparisons below will not work
+ # check if we found one in actual code
+ if not line2.endswith(".hrc") and not line2.endswith(".src"): found_reason_to_exclude = True
+ if idName.startswith("RID_"):
+ # check that the constant is not being used as an identifier by entries in .src files
+ if line2.endswith(".src") and line2.find("Identifier = ") != -1: found_reason_to_exclude = True
+ # check that the constant is not being used by the property controller extension or reportdesigner inspection,
+ # which use macros to declare constants, hiding them from a search
+ if line2.find("extensions/source/propctrlr") != -1: found_reason_to_exclude = True
+ if line2.find("reportdesign/source/ui/inspection/inspection.src") != -1: found_reason_to_exclude = True
+ if idName.startswith("HID_"):
+ # check that the constant is not being used as an identifier by entries in .src files
+ if line2.endswith(".src") and line2.find("HelpId = ") != -1: found_reason_to_exclude = True
+ if not found_reason_to_exclude:
+ sys.stdout.write(idName + '\n')
# otherwise the previous line of output will be incorrectly mixed into the below git output, because of buffering
sys.stdout.flush()
# search again, so we log the location and filename of stuff we want to remove
- subprocess.call(["git", "grep", "-wn", ridName])
+ subprocess.call(["git", "grep", "-wn", idName])
diff --git a/sd/inc/sdattr.hrc b/sd/inc/sdattr.hrc
index e275090134ec..791c03121d2e 100644
--- a/sd/inc/sdattr.hrc
+++ b/sd/inc/sdattr.hrc
@@ -22,14 +22,8 @@
#include <sfx2/sfx.hrc>
-// Begin page attributes
-#define ATTR_PAGE_START SID_SD_START + 1234
-#define ATTR_PAGE_OBJECTS ATTR_PAGE_START + 2
-#define ATTR_PAGE_LAYOUT ATTR_PAGE_START + 3
-#define ATTR_PAGE_END ATTR_PAGE_LAYOUT
-
// Layer attributes
-#define ATTR_LAYER_START ATTR_PAGE_END + 1
+#define ATTR_LAYER_START SID_SD_START + 1234
#define ATTR_LAYER_NAME ATTR_LAYER_START
#define ATTR_LAYER_VISIBLE ATTR_LAYER_START + 1
#define ATTR_LAYER_PRINTABLE ATTR_LAYER_START + 2
@@ -39,17 +33,8 @@
#define ATTR_LAYER_DESC ATTR_LAYER_START + 6
#define ATTR_LAYER_END ATTR_LAYER_DESC
-// Begin Dia attribute
-#define ATTR_DIA_START ATTR_LAYER_END + 1
-#define ATTR_DIA_EFFECT ATTR_DIA_START
-#define ATTR_DIA_SPEED ATTR_DIA_START + 1
-#define ATTR_DIA_AUTO ATTR_DIA_START + 2
-#define ATTR_DIA_TIME ATTR_DIA_START + 3
-#define ATTR_DIA_SOUNDFILE ATTR_DIA_START + 5
-#define ATTR_DIA_END ATTR_DIA_SOUNDFILE
-
// presentation attributes
-#define ATTR_PRESENT_START ATTR_DIA_END + 1
+#define ATTR_PRESENT_START ATTR_LAYER_END + 1
#define ATTR_PRESENT_ALL ATTR_PRESENT_START
#define ATTR_PRESENT_CUSTOMSHOW ATTR_PRESENT_START + 1
#define ATTR_PRESENT_DIANAME ATTR_PRESENT_START + 2
@@ -67,25 +52,8 @@
#define ATTR_PRESENT_DISPLAY ATTR_PRESENT_START + 15
#define ATTR_PRESENT_END ATTR_PRESENT_DISPLAY
-// transformation attributes
-#define ATTR_TRANSF_START ATTR_PRESENT_END + 1
-#define ATTR_TRANSF_ANGLE ATTR_TRANSF_START + 7
-#define ATTR_TRANSF_END ATTR_TRANSF_ANGLE
-
-// grid attributes
-#define ATTR_GRID_START ATTR_TRANSF_END + 1
-#define ATTR_GRID_ORIGIN_Y ATTR_GRID_START + 8
-#define ATTR_GRID_END ATTR_GRID_ORIGIN_Y
-
-// display attributes
-#define ATTR_DISPLAY_START ATTR_GRID_END + 1
-#define ATTR_DISPLAY_ADJUSTLINES ATTR_DISPLAY_START + 8
-#define ATTR_DISPLAY_END ATTR_DISPLAY_ADJUSTLINES
-
-#define ATTR_TBX_DUMMY ATTR_DISPLAY_END + 1
-
// animation attributes
-#define ATTR_ANIMATION_START ATTR_TBX_DUMMY + 1
+#define ATTR_ANIMATION_START ATTR_PRESENT_END + 1
#define ATTR_ANIMATION_ACTIVE ATTR_ANIMATION_START
#define ATTR_ANIMATION_EFFECT ATTR_ANIMATION_START + 1
#define ATTR_ANIMATION_SPEED ATTR_ANIMATION_START + 2
@@ -107,11 +75,7 @@
#define ATTR_ACTION_PLAYFULL ATTR_ACTION_START + 5
#define ATTR_ACTION_END ATTR_ACTION_PLAYFULL
-#define ATTR_PRINTOPTIONS_START ATTR_ACTION_END + 1
-#define ATTR_PRINTOPTIONS_PAGENAME ATTR_PRINTOPTIONS_START + 5
-#define ATTR_PRINTOPTIONS_END ATTR_PRINTOPTIONS_PAGENAME
-
-#define ATTR_COPY_START ATTR_PRINTOPTIONS_END + 1
+#define ATTR_COPY_START ATTR_ACTION_END + 1
#define ATTR_COPY_NUMBER ATTR_COPY_START
#define ATTR_COPY_MOVE_X ATTR_COPY_START + 1
#define ATTR_COPY_MOVE_Y ATTR_COPY_START + 2
@@ -143,24 +107,15 @@
#define ATTR_OPTIONS_SCALE_HEIGHT ATTR_OPTIONS_SCALE_START + 3
#define ATTR_OPTIONS_SCALE_END ATTR_OPTIONS_SCALE_HEIGHT
-#define ATTR_PUBLISH_START ATTR_OPTIONS_SCALE_END + 1
-#define ATTR_PUBLISH_SLIDESOUND ATTR_PUBLISH_START + 32
-#define ATTR_PUBLISH_END ATTR_PUBLISH_SLIDESOUND
-
-#define ATTR_PRESLAYOUT_START ATTR_PUBLISH_END + 1
+#define ATTR_PRESLAYOUT_START ATTR_OPTIONS_SCALE_END + 1
#define ATTR_PRESLAYOUT_NAME ATTR_PRESLAYOUT_START
#define ATTR_PRESLAYOUT_LOAD ATTR_PRESLAYOUT_START + 1
#define ATTR_PRESLAYOUT_MASTER_PAGE ATTR_PRESLAYOUT_START + 2
#define ATTR_PRESLAYOUT_CHECK_MASTERS ATTR_PRESLAYOUT_START + 3
#define ATTR_PRESLAYOUT_END ATTR_PRESLAYOUT_CHECK_MASTERS
-// Pack & go attributes
-#define ATTR_PACKNGO_START ATTR_PRESLAYOUT_END + 1
-#define ATTR_PACKNGO_MEDIUMSIZE ATTR_PACKNGO_START + 3
-// ATTR_PACKNGO_END ATTR_PACKNGO_MEDIUMSIZE
-
// paragraph numbering attributes
-#define ATTR_PARANUMBERING_START ATTR_PACKNGO_MEDIUMSIZE + 1
+#define ATTR_PARANUMBERING_START ATTR_PRESLAYOUT_END + 1
#define ATTR_NUMBER_NEWSTART ATTR_PARANUMBERING_START
#define ATTR_NUMBER_NEWSTART_AT ATTR_PARANUMBERING_START + 1
#define ATTR_PARANUMBERING_END ATTR_NUMBER_NEWSTART_AT