[Libreoffice-commits] core.git: 2 commits - bin/find-unused-defines.awk bin/find-unused-defines.py bin/find-unused-defines.sh connectivity/inc editeng/inc editeng/source filter/source include/editeng include/filter include/sfx2 include/svtools include/svx package/inc package/source sc/inc sc/source sd/inc sd/source sw/inc sw/source

Noel Grandin noel.grandin at collabora.co.uk
Tue Dec 5 06:33:41 UTC 2017


 bin/find-unused-defines.awk              |   19 ---
 bin/find-unused-defines.py               |  163 +++++++++++++++++++++++++++++++
 bin/find-unused-defines.sh               |   30 -----
 connectivity/inc/strings.hrc             |    2 
 editeng/inc/editdoc.hxx                  |    2 
 editeng/source/editeng/editobj2.hxx      |    2 
 editeng/source/editeng/impedit.hxx       |    2 
 filter/source/msfilter/msdffimp.cxx      |    2 
 filter/source/msfilter/svdfppt.cxx       |    4 
 include/editeng/boxitem.hxx              |    2 
 include/filter/msfilter/msdffimp.hxx     |   10 -
 include/sfx2/strings.hrc                 |    1 
 include/svtools/strings.hrc              |    1 
 include/svx/strings.hrc                  |   14 --
 package/inc/ZipOutputEntry.hxx           |    4 
 package/source/zippackage/ZipPackage.cxx |    4 
 sc/inc/globstr.hrc                       |    6 -
 sc/inc/sc.hrc                            |   17 ---
 sc/source/filter/excel/xiescher.cxx      |    2 
 sd/inc/app.hrc                           |    2 
 sd/inc/strings.hrc                       |    4 
 sd/source/filter/ppt/pptin.cxx           |    4 
 sw/inc/strings.hrc                       |    3 
 sw/source/filter/ww8/ww8graf2.cxx        |    2 
 24 files changed, 183 insertions(+), 119 deletions(-)

New commits:
commit eaf89e477af94bd3977aca17d72dd442c7604e63
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Dec 4 13:52:55 2017 +0200

    loplugin:countusersofdefaultparams in editeng..package
    
    Change-Id: I4c20235a04d9ab5ea5edbb6b1b2413677b18a305
    Reviewed-on: https://gerrit.libreoffice.org/45795
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx
index 45cd7f0bf907..760d9a079cc3 100644
--- a/editeng/inc/editdoc.hxx
+++ b/editeng/inc/editdoc.hxx
@@ -772,7 +772,7 @@ public:
     void            SetDefTab( sal_uInt16 nTab )    { nDefTab = nTab ? nTab : DEFTAB; }
     sal_uInt16      GetDefTab() const           { return nDefTab; }
 
-    void            SetVertical( bool bVertical, bool bTopToBottom = true )
+    void            SetVertical( bool bVertical, bool bTopToBottom )
                     { bIsVertical = bVertical; bIsTopToBottomVert = bVertical && bTopToBottom; }
     bool            IsVertical() const              { return bIsVertical; }
     bool            IsTopToBottom() const           { return bIsTopToBottomVert; }
diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx
index f7c853668bac..f8645a5e93c4 100644
--- a/editeng/source/editeng/editobj2.hxx
+++ b/editeng/source/editeng/editobj2.hxx
@@ -215,7 +215,7 @@ public:
 
     bool                    IsVertical() const;
     bool                    IsTopToBottom() const;
-    void                    SetVertical( bool bVert, bool bTopToBottom = true);
+    void                    SetVertical( bool bVert, bool bTopToBottom);
 
     SvtScriptType           GetScriptType() const { return nScriptType;}
     void                    SetScriptType( SvtScriptType nType );
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index d9ec9a17136a..06fec2bc7e6a 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -740,7 +740,7 @@ public:
     const Size&             GetPaperSize() const                    { return aPaperSize; }
     void                    SetPaperSize( const Size& rSz )         { aPaperSize = rSz; }
 
-    void                    SetVertical( bool bVertical, bool bTopToBottom = true);
+    void                    SetVertical( bool bVertical, bool bTopToBottom);
     bool                    IsVertical() const                      { return GetEditDoc().IsVertical(); }
     bool                    IsTopToBottom() const                   { return GetEditDoc().IsTopToBottom(); }
 
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 38d7e5ed9e8d..75ee77299717 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -6266,7 +6266,7 @@ bool SvxMSDffManager::GetShape(sal_uLong nId, SdrObject*&         rpShape,
         if (!bSeeked || rStCtrl.GetError())
             rStCtrl.ResetError();
         else
-            rpShape = ImportObj( rStCtrl, &rData, rData.aParentRect, rData.aParentRect );
+            rpShape = ImportObj( rStCtrl, &rData, rData.aParentRect, rData.aParentRect, /*nCalledByGroup*/0, /*pShapeId*/nullptr );
 
         // restore old FilePos of the stream(s)
         rStCtrl.Seek( nOldPosCtrl );
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index aedba3aad7b9..cf0527555ea8 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -2819,7 +2819,7 @@ void SdrPowerPointImport::ImportPage( SdrPage* pRet, const PptSlidePersistEntry*
                                                 // do not follow master colorscheme?
                                                 sal_uInt32 nPos = rStCtrl.Tell();
                                                 rStCtrl.Seek( pE->nBackgroundOffset );
-                                                rSlidePersist.pBObj = ImportObj( rStCtrl, static_cast<void*>(&aProcessData), aPageSize, aPageSize );
+                                                rSlidePersist.pBObj = ImportObj( rStCtrl, static_cast<void*>(&aProcessData), aPageSize, aPageSize, /*nCalledByGroup*/0, /*pShapeId*/nullptr );
                                                 rStCtrl.Seek( nPos );
                                             }
                                         }
@@ -2835,7 +2835,7 @@ void SdrPowerPointImport::ImportPage( SdrPage* pRet, const PptSlidePersistEntry*
                                             if ( ShapeFlag(nSpFlags) & ShapeFlag::Background )
                                             {
                                                 aEscherObjListHd.SeekToBegOfRecord( rStCtrl );
-                                                rSlidePersist.pBObj = ImportObj( rStCtrl, static_cast<void*>(&aProcessData), aPageSize, aPageSize );
+                                                rSlidePersist.pBObj = ImportObj( rStCtrl, static_cast<void*>(&aProcessData), aPageSize, aPageSize, /*nCalledByGroup*/0, /*pShapeId*/nullptr );
                                             }
                                         }
                                     }
diff --git a/include/editeng/boxitem.hxx b/include/editeng/boxitem.hxx
index d0d2143c576f..d2c155e822b3 100644
--- a/include/editeng/boxitem.hxx
+++ b/include/editeng/boxitem.hxx
@@ -112,7 +112,7 @@ public:
     // bEvenIfNoLine = TRUE -> Also return distance, when no Line is set
     sal_uInt16  CalcLineWidth( SvxBoxItemLine nLine ) const;
     sal_uInt16  CalcLineSpace( SvxBoxItemLine nLine, bool bEvenIfNoLine = false ) const;
-    bool HasBorder( bool bTreatPaddingAsBorder = false ) const;
+    bool HasBorder( bool bTreatPaddingAsBorder ) const;
     static css::table::BorderLine2 SvxLineToLine( const editeng::SvxBorderLine* pLine, bool bConvert );
     static bool LineToSvxLine(const css::table::BorderLine& rLine, editeng::SvxBorderLine& rSvxLine, bool bConvert);
     static bool LineToSvxLine(const css::table::BorderLine2& rLine, editeng::SvxBorderLine& rSvxLine, bool bConvert);
diff --git a/include/filter/msfilter/msdffimp.hxx b/include/filter/msfilter/msdffimp.hxx
index 9e5e814016ba..ed0954111fa7 100644
--- a/include/filter/msfilter/msdffimp.hxx
+++ b/include/filter/msfilter/msdffimp.hxx
@@ -580,7 +580,7 @@ public:
                      sal_uInt32 nOffsDgg,
                      SvStream* pStData,
                      SdrModel* pSdrModel_,
-                     long      nApplicationScale    =  0,
+                     long      nApplicationScale,
                      ColorData mnDefaultColor_      =  COL_DEFAULT,
                      SvStream* pStData2_            =  nullptr,
                      bool bSkipImages               =  false );
@@ -644,22 +644,22 @@ public:
                           void* pData,
                           tools::Rectangle& rClientRect,
                           const tools::Rectangle& rGlobalChildRect,
-                          int nCalledByGroup = 0,
-                          sal_Int32* pShapeId = nullptr);
+                          int nCalledByGroup,
+                          sal_Int32* pShapeId);
     SdrObject* ImportGroup( const DffRecordHeader& rHd,
                             SvStream& rSt,
                             void* pData,
                             tools::Rectangle& rClientRect,
                             const tools::Rectangle& rGlobalChildRect,
                             int nCalledByGroup,
-                            sal_Int32* pShapeId = nullptr );
+                            sal_Int32* pShapeId );
     SdrObject* ImportShape( const DffRecordHeader& rHd,
                             SvStream& rSt,
                             void* pData,
                             tools::Rectangle& rClientRect,
                             const tools::Rectangle& rGlobalChildRect,
                             int nCalledByGroup,
-                            sal_Int32* pShapeId = nullptr);
+                            sal_Int32* pShapeId);
 
     tools::Rectangle GetGlobalChildAnchor( const DffRecordHeader& rHd,
                                     SvStream& rSt,
diff --git a/package/inc/ZipOutputEntry.hxx b/package/inc/ZipOutputEntry.hxx
index 016e220fa06e..2e6c11dfa129 100644
--- a/package/inc/ZipOutputEntry.hxx
+++ b/package/inc/ZipOutputEntry.hxx
@@ -60,7 +60,7 @@ public:
     ZipOutputEntry(
         const css::uno::Reference< css::io::XOutputStream >& rxOutStream,
         const css::uno::Reference< css::uno::XComponentContext >& rxContext,
-        ZipEntry& rEntry, ZipPackageStream* pStream, bool bEncrypt = false);
+        ZipEntry& rEntry, ZipPackageStream* pStream, bool bEncrypt);
 
     ~ZipOutputEntry();
 
@@ -68,7 +68,7 @@ public:
        data is retrieved via getData */
     ZipOutputEntry(
         const css::uno::Reference< css::uno::XComponentContext >& rxContext,
-        ZipEntry& rEntry, ZipPackageStream* pStream, bool bEncrypt = false);
+        ZipEntry& rEntry, ZipPackageStream* pStream, bool bEncrypt);
     void createBufferFile();
     void setParallelDeflateException(const ::css::uno::Any &rAny) { m_aParallelDeflateException = rAny; }
     css::uno::Reference< css::io::XInputStream > getData() const;
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 021ad2ad6792..7eef97c5341f 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -1019,7 +1019,7 @@ void ZipPackage::WriteManifest( ZipOutputStream& aZipOut, const vector< uno::Seq
     // the manifest.xml is never encrypted - so pass an empty reference
     ZipOutputStream::setEntry(pEntry);
     aZipOut.writeLOC(pEntry);
-    ZipOutputEntry aZipEntry(aZipOut.getStream(), m_xContext, *pEntry, nullptr);
+    ZipOutputEntry aZipEntry(aZipOut.getStream(), m_xContext, *pEntry, nullptr, /*bEncrypt*/false);
     aZipEntry.write(pBuffer->getSequence());
     aZipEntry.closeEntry();
     aZipOut.rawCloseEntry();
@@ -1072,7 +1072,7 @@ void ZipPackage::WriteContentTypes( ZipOutputStream& aZipOut, const vector< uno:
     // there is no encryption in this format currently
     ZipOutputStream::setEntry(pEntry);
     aZipOut.writeLOC(pEntry);
-    ZipOutputEntry aZipEntry(aZipOut.getStream(), m_xContext, *pEntry, nullptr);
+    ZipOutputEntry aZipEntry(aZipOut.getStream(), m_xContext, *pEntry, nullptr, /*bEncrypt*/false);
     aZipEntry.write(pBuffer->getSequence());
     aZipEntry.closeEntry();
     aZipOut.rawCloseEntry();
diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx
index 36205c5867e9..e883101f20e2 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -3755,7 +3755,7 @@ bool XclImpDffConverter::ProcessShContainer( SvStream& rDffStrm, const DffRecord
         and the returned group object contains them all. ImportObj() calls the
         virtual functions ProcessClientAnchor2() and ProcessObj() and writes
         the pointer to the related draw object data (OBJ record) into pDrawObj. */
-    SdrObjectPtr xSdrObj( ImportObj( rDffStrm, &pDrawObj, aDummy, aDummy ) );
+    SdrObjectPtr xSdrObj( ImportObj( rDffStrm, &pDrawObj, aDummy, aDummy, /*nCalledByGroup*/0, /*pShapeId*/nullptr ) );
     if( pDrawObj && xSdrObj )
         InsertSdrObject( GetConvData().mrSdrPage, *pDrawObj, xSdrObj.release() );
     return rShHeader.SeekToEndOfRecord( rDffStrm );
diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx
index 87928bb4655f..1852f0bfe8b9 100644
--- a/sd/source/filter/ppt/pptin.cxx
+++ b/sd/source/filter/ppt/pptin.cxx
@@ -810,7 +810,7 @@ bool ImplSdPPTImport::Import()
                                                         ::tools::Rectangle aEmpty;
                                                         if (!aHd2.SeekToBegOfRecord(rStCtrl))
                                                             break;
-                                                        SdrObject* pImpObj = ImportObj( rStCtrl, static_cast<void*>(&aProcessData), aEmpty, aEmpty );
+                                                        SdrObject* pImpObj = ImportObj( rStCtrl, static_cast<void*>(&aProcessData), aEmpty, aEmpty, /*nCalledByGroup*/0, /*pShapeId*/ nullptr );
                                                         if ( pImpObj )
                                                         {
                                                             pImpObj->SetLayer( mnBackgroundObjectsLayerID );
@@ -1442,7 +1442,7 @@ void ImplSdPPTImport::SetHeaderFooterPageSettings( SdPage* pPage, const PptSlide
                     bVisible = false;
                     rStCtrl.Seek( nPosition );
                     ProcessData aProcessData( rSlidePersist, SdPageCapsule(pPage) );
-                    SdrObject* pObj = ImportObj( rStCtrl, static_cast<void*>(&aProcessData), aEmpty, aEmpty );
+                    SdrObject* pObj = ImportObj( rStCtrl, static_cast<void*>(&aProcessData), aEmpty, aEmpty, /*nCalledByGroup*/0, /*pShapeId*/nullptr );
                     if ( pObj )
                         pPage->NbcInsertObject( pObj, 0 );
                 }
diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx
index a2eb61857d7f..04f5d1b33626 100644
--- a/sw/source/filter/ww8/ww8graf2.cxx
+++ b/sw/source/filter/ww8/ww8graf2.cxx
@@ -556,7 +556,7 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj const * pTextObj,
             tools::Rectangle aChildRect;
             tools::Rectangle aClientRect( 0,0, aPD.nWidth,  aPD.nHeight);
             SvxMSDffImportData aData( aClientRect );
-            pObject = m_xMSDffManager->ImportObj(*m_pDataStream, &aData, aClientRect, aChildRect );
+            pObject = m_xMSDffManager->ImportObj(*m_pDataStream, &aData, aClientRect, aChildRect, /*nCalledByGroup*/0, /*pShapeId*/nullptr );
             if (pObject)
             {
                 // for the frame
commit ebc5774c0546cd0b4ca4ad5a125fd9f8ec0e9ce4
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Dec 4 09:49:32 2017 +0200

    remove some unused defines
    
    and move the script to python
    
    Change-Id: I97bca04053d9d38b59c74fcf61caafbc2c137cc9
    Reviewed-on: https://gerrit.libreoffice.org/45776
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/bin/find-unused-defines.awk b/bin/find-unused-defines.awk
deleted file mode 100644
index fb3997ab4f54..000000000000
--- a/bin/find-unused-defines.awk
+++ /dev/null
@@ -1,19 +0,0 @@
-{
-    x++
-    y=$0
-}
-
-END { 
-    tmp = substr(y, 0, index(y, ":")-1)
-    if (x==1) print "sed -i '/[[:space:]]" p1 "[[:space:]]/d' " tmp
-    # mark these as potential places to inline a constant
-    if (x==2) print "#inline " p1 " " tmp
-}
-
-
-
-
-# | xargs -P 4 -Ixxx sh -c "git grep -w 'xxx' | awk '{ x++; y=\$0 } END { if (x==1) print y }' && echo \"xxx\" 1>&2"
-# 	sed -i '' '/pattern/d'
-# | awk  'arr[$0]++ END { for (i in arr) { if(arr[i]==1) print i } }' \
-# | awk -f find-unused-defines.awk
diff --git a/bin/find-unused-defines.py b/bin/find-unused-defines.py
new file mode 100755
index 000000000000..7f5f27cb6bc7
--- /dev/null
+++ b/bin/find-unused-defines.py
@@ -0,0 +1,163 @@
+#!/usr/bin/python
+
+# Search for unused constants in header files.
+#
+# 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
+#
+
+import subprocess
+import sys
+
+exclusionSet = set([
+    # List of RID constants where we compute a value using a base before calling one of the RESSTR methods
+    # Found with: git grep -P 'RID_\w+\s*\+' -- :/ ':!*.hrc' ':!*.src' ':!*.java' ':!*.py' ':!*.xba'
+    "RID_SVXSTR_KEY_",
+    "RID_UPDATE_BUBBLE_TEXT_",
+    "RID_UPDATE_BUBBLE_T_TEXT_",
+    "RID_SVXSTR_TBLAFMT_",
+    "RID_BMP_CONTENT_",
+    "RID_DROPMODE_",
+    "RID_BMP_LEVEL",
+    "RID_SVXSTR_BULLET_DESCRIPTION",
+    "RID_SVXSTR_SINGLENUM_DESCRIPTION",
+    "RID_SVXSTR_OUTLINENUM_DESCRIPTION",
+    "RID_SVXSTR_RULER_",
+    "RID_GALLERYSTR_THEME_",
+    "RID_SVXSTR_BULLET_DESCRIPTION",
+    "RID_SVXSTR_SINGLENUM_DESCRIPTION",
+    "RID_SVXSTR_OUTLINENUM_DESCRIPTION",
+    # doing some weird stuff in svx/source/unodraw/unoprov.cxx involving mapping of UNO api names to translated names and back again
+    "RID_SVXSTR_GRDT",
+    "RID_SVXSTR_HATCH",
+    "RID_SVXSTR_BMP",
+    "RID_SVXSTR_DASH",
+    "RID_SVXSTR_LEND",
+    "RID_SVXSTR_TRASNGR",
+    # other places doing calculations
+    "RID_SVXSTR_DEPTH",
+    "RID_SUBSETSTR_",
+    "ANALYSIS_",
+    "FLD_DOCINFO_CHANGE",
+    "FLD_EU_",
+    "FLD_INPUT_",
+    "FLD_PAGEREF_",
+    "FLD_STAT_",
+    "FMT_AUTHOR_",
+    "FMT_CHAPTER_",
+    "FMT_DBFLD_",
+    "FMT_FF_",
+    "FMT_GETVAR_",
+    "FMT_MARK_",
+    "FMT_REF_",
+    "FMT_SETVAR_",
+    "STR_AUTH_FIELD_ADDRESS_",
+    "STR_AUTH_TYPE_",
+    "STR_AUTOFMTREDL_",
+    "STR_CONTENT_TYPE_",
+    "STR_UPDATE_ALL",
+    "STR_UPDATE_INDEX",
+    "STR_UPDATE_LINK",
+    "BMP_PLACEHOLDER_",
+    "STR_RPT_HELP_",
+    "STR_TEMPLATE_NAME",
+    "UID_BRWEVT_",
+    "HID_EVT_",
+    "HID_PROP_",
+    "STR_VOBJ_MODE_",
+    "STR_COND_",
+    "SCSTR_CONTENT_",
+    "DATE_FUNCDESC_",
+    "DATE_FUNCNAME_",
+    "DATE_DEFFUNCNAME_",
+    "PRICING_DEFFUNCNAME_",
+    "PRICING_FUNCDESC_",
+    "PRICING_FUNCNAME_",
+    "STR_ItemValCAPTION",
+    "STR_ItemValCIRC",
+    "STR_ItemValEDGE",
+    "STR_ItemValFITTOSIZE",
+    "STR_ItemValMEASURE_",
+    "STR_ItemValMEASURETEXT_",
+    "STR_ItemValTEXTANI_",
+    "STR_ItemValTEXTHADJ",
+    "STR_ItemValTEXTVADJ",
+    "RID_SVXITEMS_VERJUST",
+    "RID_SVXITEMS_ORI",
+    "RID_SVXITEMS_JUSTMETHOD",
+    "RID_SVXITEMS_HORJUST",
+    "MM_PART",
+    ])
+
+
+def in_exclusion_set( a ):
+    for f in exclusionSet:
+        if a.startswith(f):
+            return True;
+    return False;
+
+a = subprocess.Popen("git grep -hP '^#define\s+\w+\s+' -- \"[!e][!x][!t]*\" | 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)
+        idName = line[idx1+8 : idx2].strip()
+        if idName.startswith("INCLUDED_"): continue
+        # the various _START and _END constants are normally unused outside of the .hrc and .src files, and that's fine
+        if idName.endswith("_START"): continue
+        if idName.endswith("_BEGIN"): continue
+        if idName.endswith("_END"): continue
+        if idName == "RID_SVX_FIRSTFREE": continue
+        if in_exclusion_set(idName): continue
+        # search for the constant
+        b = subprocess.Popen(["git", "grep", "-w", idName], stdout=subprocess.PIPE)
+        found_reason_to_exclude = False
+        with b.stdout as txt2:
+            cnt = 0
+            for line2 in txt2:
+                line2 = line2.strip() # otherwise the comparisons below will not work
+                # check if we found one in actual code
+                if idName.startswith("SID_"):
+                    if not ".hrc:" in line2 and not ".src:" in line2 and not ".sdi:" in line2: found_reason_to_exclude = True
+                else:
+                    if not ".hrc:" in line2 and not ".src:" in line2: found_reason_to_exclude = True
+                if idName.startswith("RID_"):
+                        # is the constant being used as an identifier by entries in .src files?
+                        if ".src:" in line2 and "Identifier = " in line2: found_reason_to_exclude = True
+                        # is the constant being used by the property controller extension or reportdesigner inspection,
+                        # which use macros to declare constants, hiding them from a search
+                        if "extensions/source/propctrlr" in line2: found_reason_to_exclude = True
+                        if "reportdesign/source/ui/inspection/inspection.src" in line2: found_reason_to_exclude = True
+                if idName.startswith("HID_"):
+                        # is the constant being used as an identifier by entries in .src files
+                        if ".src:" in line2 and "HelpId = " in line2: found_reason_to_exclude = True
+                # is it being used as a constant in an ItemList  in .src files?
+                if ".src:" in line2 and (";> ;" in line2 or "; >;" in line2): found_reason_to_exclude = True
+                # these are used in calculations in other .hrc files
+                if "sw/inc/rcid.hrc:" in line2: found_reason_to_exclude = True
+                # calculations
+                if "sw/source/uibase/inc/ribbar.hrc:" in line2 and "ST_" in idName: found_reason_to_exclude = True
+                if "sw/source/uibase/inc/ribbar.hrc:" in line2 and "STR_IMGBTN_" in idName: found_reason_to_exclude = True
+                if "sw/source/core/undo/undo.hrc:" in line2: found_reason_to_exclude = True
+                if "sw/inc/poolfmt.hrc:" in line2: found_reason_to_exclude = True
+                # not sure about these, looks suspicious
+                if "sd/source/ui/app/strings.src:" in line2 and idName.endswith("_TOOLBOX"): found_reason_to_exclude = True
+                # used via a macro that hides them from search
+                if "dbaccess/" in line2 and idName.startswith("PROPERTY_ID_"): found_reason_to_exclude = True
+                if "reportdesign/" in line2 and idName.startswith("HID_RPT_PROP_"): found_reason_to_exclude = True
+                if "reportdesign/" in line2 and idName.startswith("RID_STR_"): found_reason_to_exclude = True
+                if "forms/" in line2 and idName.startswith("PROPERTY_"): found_reason_to_exclude = True
+                if "svx/source/tbxctrls/extrusioncontrols.hrc:" in line2 and idName.startswith("DIRECTION_"): found_reason_to_exclude = True
+                if "svx/source/tbxctrls/extrusioncontrols.hrc:" in line2 and idName.startswith("FROM_"): found_reason_to_exclude = True
+                # if we see more than a few lines then it's probably one of the BASE/START/BEGIN things
+                cnt = cnt + 1
+                if cnt > 4: found_reason_to_exclude = True
+        if not found_reason_to_exclude:
+            print(idName)
+            # 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", idName])
+
diff --git a/bin/find-unused-defines.sh b/bin/find-unused-defines.sh
deleted file mode 100755
index d9a39f76be84..000000000000
--- a/bin/find-unused-defines.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# This is a pretty brute-force approach. It takes several hours to run on a top-spec MacbookAir.
-# It also produces some false positives, so it requires careful examination and testing of the results.
-#
-# Algorithm Summary:
-#   First we find all #defines,
-#   then we search for each of them in turn,
-#   and if we find only one instance of a #define, we print it out.
-#
-# Algorithm Detail:
-# (1) find #defines, excluding the externals folder
-# (2) extract just the constant name from the search results
-# (3) sort and uniq the results, mostly so I have an idea how far along the process is
-# (4) for each result:
-#   (5) grep for the constant
-#   (6) use awk to check if only one match for a given constant was found
-#   (7) if so, generate a sed command to remove the #define
-#
-( git grep -hP '^\w*#define\s+\w+.*\\' -- "[!e][!x][!t]*" \
-  && \
-  git grep -hP '^\w*#define\s+\w+\s*$' -- "[!e][!x][!t]*" ) \
-  | sed -r 's/[ ]*#define[ ]+([a-zA-Z0-9_]+).*/\1/' \
-  | grep -v '_idl' \
-  | grep -vE '^INCLUDED_' \
-  | sort \
-  | uniq \
-  | xargs -Ixxx -n 1 -P 8 sh -c \
-    "git grep -w 'xxx' | awk -f bin/find-unused-defines.awk -v p1=xxx && echo \"xxx\" 1>&2"
-
-
diff --git a/connectivity/inc/strings.hrc b/connectivity/inc/strings.hrc
index d1062d766817..d2380e45b92f 100644
--- a/connectivity/inc/strings.hrc
+++ b/connectivity/inc/strings.hrc
@@ -117,8 +117,6 @@
 #define STR_UNKNOWN_PARA_TYPE                   NC_("STR_UNKNOWN_PARA_TYPE", "The type of parameter at position '$position$' is unknown.")
 #define STR_UNKNOWN_COLUMN_TYPE                 NC_("STR_UNKNOWN_COLUMN_TYPE", "The type of column at position '$position$' is unknown.")
 // KAB
-#define STR_NO_KDE_INST                         NC_("STR_NO_KDE_INST", "No suitable KDE installation was found.")
-#define STR_KDE_VERSION_TOO_OLD                 NC_("STR_KDE_VERSION_TOO_OLD", "KDE version $major$.$minor$ or higher is required to access the KDE Address Book.")
 #define STR_PARA_ONLY_PREPARED                  NC_("STR_PARA_ONLY_PREPARED", "Parameters can appear only in prepared statements.")
 // MACAB
 #define STR_NO_TABLE                            NC_("STR_NO_TABLE", "No such table!")
diff --git a/include/sfx2/strings.hrc b/include/sfx2/strings.hrc
index 9f0b9657a729..9dadd7078b90 100644
--- a/include/sfx2/strings.hrc
+++ b/include/sfx2/strings.hrc
@@ -205,7 +205,6 @@
 #define STR_DELETE_STYLE_USED                   NC_("STR_DELETE_STYLE_USED", "One or more of the selected styles is in use in this document.\nIf you delete these styles, text will revert to the parent style.\nDo you still wish to delete these styles?\n")
 #define STR_DELETE_STYLE                        NC_("STR_DELETE_STYLE", "Styles in use: ")
 #define STR_SID_NAVIGATOR                       NC_("STR_SID_NAVIGATOR", "Navigator")
-#define STR_SID_SIDEBAR                         NC_("STR_SID_SIDEBAR", "Sidebar")
 #define STR_ERROR_WRONG_CONFIRM                 NC_("STR_ERROR_WRONG_CONFIRM", "Faulty password confirmation")
 #define STR_PDF_EXPORT_SEND                     NC_("STR_PDF_EXPORT_SEND", "Send")
 #define STR_FONT_TABPAGE                        NC_("STR_FONT_TABPAGE", "Font")
diff --git a/include/svtools/strings.hrc b/include/svtools/strings.hrc
index 7580610f79bc..e9e05f2f8109 100644
--- a/include/svtools/strings.hrc
+++ b/include/svtools/strings.hrc
@@ -98,7 +98,6 @@
 
 #define STR_ERROR_OBJNOCREATE                   NC_("STR_ERROR_OBJNOCREATE", "Object % could not be inserted.")
 #define STR_ERROR_OBJNOCREATE_FROM_FILE         NC_("STR_ERROR_OBJNOCREATE_FROM_FILE", "Object from file % could not be inserted.")
-#define STR_ERROR_OBJNOCREATE_PLUGIN            NC_("STR_ERROR_OBJNOCREATE_PLUGIN", "Plug-in from document % could not be inserted.")
 #define STR_FURTHER_OBJECT                      NC_("STR_FURTHER_OBJECT", "Further objects")
 #define STR_UNKNOWN_SOURCE                      NC_("STR_UNKNOWN_SOURCE", "Unknown source")
 
diff --git a/include/svx/strings.hrc b/include/svx/strings.hrc
index a528db2322c1..1143bb74bd37 100644
--- a/include/svx/strings.hrc
+++ b/include/svx/strings.hrc
@@ -39,16 +39,12 @@
 #define STR_ObjNamePluralQUAD                               NC_("STR_ObjNamePluralQUAD", "Squares")
 #define STR_ObjNameSingulPARAL                              NC_("STR_ObjNameSingulPARAL", "Parallelogram")
 #define STR_ObjNamePluralPARAL                              NC_("STR_ObjNamePluralPARAL", "Parallelograms")
-#define STR_ObjNameSingulRAUTE                              NC_("STR_ObjNameSingulRAUTE", "Rhombus")
-#define STR_ObjNamePluralRAUTE                              NC_("STR_ObjNamePluralRAUTE", "Rhombuses")
 #define STR_ObjNameSingulRECTRND                            NC_("STR_ObjNameSingulRECTRND", "Rounded rectangle")
 #define STR_ObjNamePluralRECTRND                            NC_("STR_ObjNamePluralRECTRND", "Rounded Rectangles")
 #define STR_ObjNameSingulQUADRND                            NC_("STR_ObjNameSingulQUADRND", "rounded square")
 #define STR_ObjNamePluralQUADRND                            NC_("STR_ObjNamePluralQUADRND", "Rounded Squares")
 #define STR_ObjNameSingulPARALRND                           NC_("STR_ObjNameSingulPARALRND", "Rounded Parallelogram")
 #define STR_ObjNamePluralPARALRND                           NC_("STR_ObjNamePluralPARALRND", "Rounded parallelograms")
-#define STR_ObjNameSingulRAUTERND                           NC_("STR_ObjNameSingulRAUTERND", "rounded rhombus")
-#define STR_ObjNamePluralRAUTERND                           NC_("STR_ObjNamePluralRAUTERND", "Rounded rhombuses")
 #define STR_ObjNameSingulCIRC                               NC_("STR_ObjNameSingulCIRC", "Circle")
 #define STR_ObjNamePluralCIRC                               NC_("STR_ObjNamePluralCIRC", "Circles")
 #define STR_ObjNameSingulSECT                               NC_("STR_ObjNameSingulSECT", "Circle sector")
@@ -1072,8 +1068,6 @@
 // SvxRectCtl
 #define RID_SVXSTR_RECTCTL_ACC_CORN_NAME                    NC_("RID_SVXSTR_RECTCTL_ACC_CORN_NAME", "Corner control")
 #define RID_SVXSTR_RECTCTL_ACC_CORN_DESCR                   NC_("RID_SVXSTR_RECTCTL_ACC_CORN_DESCR", "Selection of a corner point.")
-#define RID_SVXSTR_RECTCTL_ACC_ANGL_NAME                    NC_("RID_SVXSTR_RECTCTL_ACC_ANGL_NAME", "Angle control")
-#define RID_SVXSTR_RECTCTL_ACC_ANGL_DESCR                   NC_("RID_SVXSTR_RECTCTL_ACC_ANGL_DESCR", "Selection of a major angle.")
 #define RID_SVXSTR_RECTCTL_ACC_CHLD_LT                      NC_("RID_SVXSTR_RECTCTL_ACC_CHLD_LT", "Top left")
 #define RID_SVXSTR_RECTCTL_ACC_CHLD_MT                      NC_("RID_SVXSTR_RECTCTL_ACC_CHLD_MT", "Top middle")
 #define RID_SVXSTR_RECTCTL_ACC_CHLD_RT                      NC_("RID_SVXSTR_RECTCTL_ACC_CHLD_RT", "Top right")
@@ -1083,14 +1077,6 @@
 #define RID_SVXSTR_RECTCTL_ACC_CHLD_LB                      NC_("RID_SVXSTR_RECTCTL_ACC_CHLD_LB", "Bottom left")
 #define RID_SVXSTR_RECTCTL_ACC_CHLD_MB                      NC_("RID_SVXSTR_RECTCTL_ACC_CHLD_MB", "Bottom middle")
 #define RID_SVXSTR_RECTCTL_ACC_CHLD_RB                      NC_("RID_SVXSTR_RECTCTL_ACC_CHLD_RB", "Bottom right")
-#define RID_SVXSTR_RECTCTL_ACC_CHLD_A000                    NC_("RID_SVXSTR_RECTCTL_ACC_CHLD_A000", "0 degrees")
-#define RID_SVXSTR_RECTCTL_ACC_CHLD_A045                    NC_("RID_SVXSTR_RECTCTL_ACC_CHLD_A045", "45 degrees")
-#define RID_SVXSTR_RECTCTL_ACC_CHLD_A090                    NC_("RID_SVXSTR_RECTCTL_ACC_CHLD_A090", "90 degrees")
-#define RID_SVXSTR_RECTCTL_ACC_CHLD_A135                    NC_("RID_SVXSTR_RECTCTL_ACC_CHLD_A135", "135 degrees")
-#define RID_SVXSTR_RECTCTL_ACC_CHLD_A180                    NC_("RID_SVXSTR_RECTCTL_ACC_CHLD_A180", "180 degrees")
-#define RID_SVXSTR_RECTCTL_ACC_CHLD_A225                    NC_("RID_SVXSTR_RECTCTL_ACC_CHLD_A225", "225 degrees")
-#define RID_SVXSTR_RECTCTL_ACC_CHLD_A270                    NC_("RID_SVXSTR_RECTCTL_ACC_CHLD_A270", "270 degrees")
-#define RID_SVXSTR_RECTCTL_ACC_CHLD_A315                    NC_("RID_SVXSTR_RECTCTL_ACC_CHLD_A315", "315 degrees")
 // SvxGraphCtrlAccessibleContext
 #define RID_SVXSTR_GRAPHCTRL_ACC_NAME                       NC_("RID_SVXSTR_GRAPHCTRL_ACC_NAME", "Contour control")
 #define RID_SVXSTR_GRAPHCTRL_ACC_DESCRIPTION                NC_("RID_SVXSTR_GRAPHCTRL_ACC_DESCRIPTION", "This is where you can edit the contour.")
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index bd27e9ef0bba..ffa5101df16b 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -197,12 +197,6 @@
 #define STR_HEADER                              NC_("STR_HEADER", "Header")
 #define STR_FOOTER                              NC_("STR_FOOTER", "Footer")
 #define STR_TEXTATTRS                           NC_("STR_TEXTATTRS", "Text Attributes")
-#define STR_HFCMD_PAGE                          NC_("STR_HFCMD_PAGE", "PAGE")
-#define STR_HFCMD_PAGES                         NC_("STR_HFCMD_PAGES", "PAGES")
-#define STR_HFCMD_DATE                          NC_("STR_HFCMD_DATE", "DATE")
-#define STR_HFCMD_TIME                          NC_("STR_HFCMD_TIME", "TIME")
-#define STR_HFCMD_FILE                          NC_("STR_HFCMD_FILE", "FILE")
-#define STR_HFCMD_TABLE                         NC_("STR_HFCMD_TABLE", "SHEET")
 #define STR_PROTECTIONERR                       NC_("STR_PROTECTIONERR", "Protected cells can not be modified.")
 #define STR_READONLYERR                         NC_("STR_READONLYERR", "Document opened in read-only mode.")
 #define STR_MATRIXFRAGMENTERR                   NC_("STR_MATRIXFRAGMENTERR", "You cannot change only part of an array.")
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index 0786090df192..5c128a402ee8 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -55,23 +55,6 @@
 #define HID_SC_SHEET_PAGE_STD   (HID_SC_SHEET_START +10 )
 #define HID_SC_SHEET_PAGE_REP   (HID_SC_SHEET_START +11 )
 
-// help IDs for shells (helper) (max. 20)
-#define HID_SCSHELL_DOCSH       (HID_SC_SHELL_START +1 )
-#define HID_SCSHELL_DRAWSH      (HID_SC_SHELL_START +2 )
-#define HID_SCSHELL_DRTXTOB     (HID_SC_SHELL_START +3 )
-#define HID_SCSHELL_PIVOTSH     (HID_SC_SHELL_START +4 )
-#define HID_SCSHELL_PREVWSH     (HID_SC_SHELL_START +5 )
-#define HID_SCSHELL_TABVWSH     (HID_SC_SHELL_START +6 )
-#define HID_SCSHELL_AUDIT       (HID_SC_SHELL_START +7 )
-#define HID_SCSHELL_DRAWFORMSH  (HID_SC_SHELL_START +8 )
-#define HID_SCSHELL_CELLSH      (HID_SC_SHELL_START +9 )
-#define HID_SCSHELL_FORMATSH    (HID_SC_SHELL_START +10)
-#define HID_SCSHELL_OLEOBEJCTSH (HID_SC_SHELL_START +11)
-#define HID_SCSHELL_CHARTSH     (HID_SC_SHELL_START +12)
-#define HID_SCSHELL_GRAPHIC     (HID_SC_SHELL_START +13)
-#define HID_SCSHELL_PAGEBREAK   (HID_SC_SHELL_START +14)
-#define HID_SCSHELL_MEDIA       (HID_SC_SHELL_START +15)
-
 // view-functions (max. 100)
 #define FID_SCALESTATUS         (SC_VIEW_START + 10)
 #define SID_UPDATECHART         (SC_VIEW_START + 13)
diff --git a/sd/inc/app.hrc b/sd/inc/app.hrc
index 81f83b2a8297..f6c6752e8c66 100644
--- a/sd/inc/app.hrc
+++ b/sd/inc/app.hrc
@@ -256,8 +256,6 @@
 #define ID_VAL_ISPRINTABLE                  (SID_SD_START+232)
 #define ID_VAL_PAGEHEIGHT                   (SID_SD_START+233)
 #define ID_VAL_ZOOM                         (SID_SD_START+234)
-#define ID_VAL_ANCHOR_X                     (SID_SD_START+235)
-#define ID_VAL_ANCHOR_Y                     (SID_SD_START+236)
 #define ID_VAL_RED                          (SID_SD_START+237)
 #define ID_VAL_GREEN                        (SID_SD_START+238)
 #define ID_VAL_BLUE                         (SID_SD_START+239)
diff --git a/sd/inc/strings.hrc b/sd/inc/strings.hrc
index 4850e5d63b2d..924bc5acdc42 100644
--- a/sd/inc/strings.hrc
+++ b/sd/inc/strings.hrc
@@ -69,7 +69,6 @@
 #define STR_DESC_LINEEND                                NC_("STR_DESC_LINEEND", "Please enter a name for the new arrowhead:")
 #define STR_WARN_NAME_DUPLICATE                         NC_("STR_WARN_NAME_DUPLICATE", "The name chosen already exists. \nPlease enter another name.")
 #define STR_UNDO_ANIMATION                              NC_("STR_UNDO_ANIMATION", "Animation parameters")
-#define STR_EXPORT_HTML_NAME                            NC_("STR_EXPORT_HTML_NAME", "Web Page")
 #define STR_UNDO_COPYOBJECTS                            NC_("STR_UNDO_COPYOBJECTS", "Duplicate")
 #define STR_TITLE_NAMEGROUP                             NC_("STR_TITLE_NAMEGROUP", "Name Object")
 #define STR_DESC_NAMEGROUP                              NC_("STR_DESC_NAMEGROUP", "Name")
@@ -173,7 +172,6 @@
 #define STR_PUBLISH_OUTLINE                             NC_("STR_PUBLISH_OUTLINE", "Overview")
 #define STR_EYEDROPPER                                  NC_("STR_EYEDROPPER", "Color Replacer")
 #define STR_UNDO_MORPHING                               NC_("STR_UNDO_MORPHING", "Cross-fading")
-#define STR_UNDO_COLORRESOLUTION                        NC_("STR_UNDO_COLORRESOLUTION", "Color resolution")
 #define STR_UNDO_EXPAND_PAGE                            NC_("STR_UNDO_EXPAND_PAGE", "Expand Slide")
 #define STR_UNDO_SUMMARY_PAGE                           NC_("STR_UNDO_SUMMARY_PAGE", "Table of Contents Slide")
 #define STR_TWAIN_NO_SOURCE_UNX                         NC_("STR_TWAIN_NO_SOURCE_UNX", "No SANE source is available at the moment.")
@@ -270,8 +268,6 @@
 #define STRING_DRAG_AND_DROP_SLIDES                     NC_("STRING_DRAG_AND_DROP_SLIDES", "Drag and Drop Slides" )
 #define STR_PHOTO_ALBUM_EMPTY_WARNING                   NC_("STR_PHOTO_ALBUM_EMPTY_WARNING", "Please add Images to the Album." )
 #define STR_PHOTO_ALBUM_TEXTBOX                         NC_("STR_PHOTO_ALBUM_TEXTBOX", "Text Slide")
-#define STR_INSERT_3D_MODEL_TITLE                       NC_("STR_INSERT_3D_MODEL_TITLE", "Insert 3D Model")
-#define STR_INSERT_3D_MODEL_ALL_SUPPORTED_FORMATS       NC_("STR_INSERT_3D_MODEL_ALL_SUPPORTED_FORMATS", "All supported formats")
 #define STR_OBJECTS_TREE                                NC_("STR_OBJECTS_TREE", "Page Tree")
 #define STR_OVERWRITE_WARNING                           NC_("STR_OVERWRITE_WARNING", "The local target directory '%FILENAME' is not empty. Some files might be overwritten. Do you want to continue?")
 
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index a0d2b3ae3bc4..f5872466d24a 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -1264,9 +1264,6 @@
 #define STR_FRMUI_TOP_BASE                      NC_("STR_FRMUI_TOP_BASE", "Base line at ~top")
 #define STR_FRMUI_BOTTOM_BASE                   NC_("STR_FRMUI_BOTTOM_BASE", "~Base line at bottom")
 #define STR_FRMUI_CENTER_BASE                   NC_("STR_FRMUI_CENTER_BASE", "Base line ~centered")
-#define STR_FRMUI_LINE_TOP                      NC_("STR_FRMUI_LINE_TOP", "Top of line")
-#define STR_FRMUI_LINE_BOTTOM                   NC_("STR_FRMUI_LINE_BOTTOM", "Bottom of line")
-#define STR_FRMUI_LINE_CENTER                   NC_("STR_FRMUI_LINE_CENTER", "Center of line")
 #define STR_FRMUI_OLE_INSERT                    NC_("STR_FRMUI_OLE_INSERT", "Insert object")
 #define STR_FRMUI_OLE_EDIT                      NC_("STR_FRMUI_OLE_EDIT", "Edit object")
 #define STR_FRMUI_COLL_HEADER                   NC_("STR_FRMUI_COLL_HEADER", " (Template: ")


More information about the Libreoffice-commits mailing list