[Libreoffice-commits] core.git: basctl/source basic/source bridges/source chart2/source comphelper/source compilerplugins/clang cui/source desktop/source drawinglayer/source editeng/source extensions/source filter/source forms/source fpicker/source framework/source l10ntools/source linguistic/source o3tl/qa oox/source sal/osl sal/qa sal/rtl sax/source sc/source sd/source sfx2/source starmath/source svl/source svtools/source svx/source sw/source ucb/source UnoControls/source unotools/source vcl/source vcl/unx vcl/workben xmloff/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Sat Nov 16 23:29:18 UTC 2019


 UnoControls/source/controls/framecontrol.cxx                       |    4 
 basctl/source/basicide/doceventnotifier.cxx                        |    4 
 basic/source/classes/sbunoobj.cxx                                  |    6 
 basic/source/runtime/methods1.cxx                                  |    3 
 bridges/source/cpp_uno/gcc3_linux_x86-64/abi.cxx                   |    4 
 chart2/source/controller/dialogs/tp_Scale.cxx                      |    4 
 comphelper/source/container/enumerablemap.cxx                      |    2 
 comphelper/source/misc/syntaxhighlight.cxx                         |    5 
 compilerplugins/clang/external.cxx                                 |  239 +++++++++-
 compilerplugins/clang/sharedvisitor/analyzer.cxx                   |   25 +
 compilerplugins/clang/test/external.cxx                            |   61 ++
 cui/source/dialogs/colorpicker.cxx                                 |   13 
 cui/source/options/optdict.cxx                                     |    4 
 cui/source/options/optlingu.cxx                                    |    4 
 cui/source/tabpages/autocdlg.cxx                                   |    8 
 cui/source/tabpages/paragrph.cxx                                   |    4 
 cui/source/tabpages/swpossizetabpage.cxx                           |    9 
 cui/source/tabpages/tparea.cxx                                     |    4 
 cui/source/tabpages/tpbitmap.cxx                                   |    4 
 desktop/source/lib/init.cxx                                        |    4 
 drawinglayer/source/tools/emfphelperdata.cxx                       |    4 
 drawinglayer/source/tools/emfppen.cxx                              |    4 
 editeng/source/items/paraitem.cxx                                  |    2 
 editeng/source/misc/svxacorr.cxx                                   |    5 
 extensions/source/propctrlr/browserlistbox.cxx                     |    4 
 extensions/source/scanner/sane.cxx                                 |    4 
 filter/source/graphicfilter/ios2met/ios2met.cxx                    |    3 
 filter/source/graphicfilter/ipcd/ipcd.cxx                          |    4 
 filter/source/graphicfilter/ipict/ipict.cxx                        |    4 
 forms/source/misc/limitedformats.cxx                               |    2 
 fpicker/source/office/fileview.cxx                                 |    5 
 framework/source/fwe/classes/actiontriggerpropertyset.cxx          |    4 
 framework/source/fwe/classes/actiontriggerseparatorpropertyset.cxx |    4 
 framework/source/services/desktop.cxx                              |    4 
 l10ntools/source/common.cxx                                        |    4 
 linguistic/source/misc2.cxx                                        |    5 
 o3tl/qa/test-typed_flags.cxx                                       |    3 
 oox/source/core/filterbase.cxx                                     |    4 
 oox/source/drawingml/customshapegeometry.cxx                       |    5 
 sal/osl/unx/profile.cxx                                            |    4 
 sal/qa/osl/condition/osl_Condition.cxx                             |    4 
 sal/qa/osl/file/osl_File.cxx                                       |    4 
 sal/rtl/ustring.cxx                                                |    4 
 sax/source/tools/converter.cxx                                     |    4 
 sc/source/core/opencl/op_statistical.cxx                           |    4 
 sc/source/core/tool/cellkeytranslator.cxx                          |    4 
 sc/source/core/tool/compiler.cxx                                   |    4 
 sc/source/core/tool/detfunc.cxx                                    |    4 
 sc/source/filter/oox/formulabase.cxx                               |    5 
 sc/source/filter/oox/pagesettings.cxx                              |    4 
 sc/source/ui/app/inputwin.cxx                                      |    4 
 sc/source/ui/dbgui/scuiasciiopt.cxx                                |    4 
 sc/source/ui/docshell/impex.cxx                                    |   12 
 sc/source/ui/unoobj/fielduno.cxx                                   |    4 
 sc/source/ui/view/gridwin.cxx                                      |    4 
 sc/source/ui/view/prevloc.cxx                                      |    4 
 sc/source/ui/view/viewfun2.cxx                                     |    4 
 sd/source/filter/eppt/pptx-epptooxml.cxx                           |    4 
 sd/source/ui/sidebar/SlideBackground.cxx                           |    4 
 sd/source/ui/unoidl/UnoDocumentSettings.cxx                        |    4 
 sd/source/ui/unoidl/facreg.cxx                                     |    5 
 sd/source/ui/unoidl/unoobj.cxx                                     |    5 
 sd/source/ui/unoidl/unopage.cxx                                    |    4 
 sfx2/source/control/unoctitm.cxx                                   |    4 
 sfx2/source/dialog/filedlghelper.cxx                               |    5 
 sfx2/source/view/viewsh.cxx                                        |    3 
 starmath/source/unomodel.cxx                                       |    4 
 svl/source/numbers/zforfind.cxx                                    |    3 
 svl/source/numbers/zformat.cxx                                     |    8 
 svl/source/numbers/zforscan.cxx                                    |    4 
 svtools/source/config/helpopt.cxx                                  |    3 
 svtools/source/config/htmlcfg.cxx                                  |    5 
 svtools/source/control/ctrltool.cxx                                |    5 
 svtools/source/svhtml/parhtml.cxx                                  |    4 
 svx/source/fmcomp/fmgridcl.cxx                                     |    4 
 svx/source/sidebar/area/AreaPropertyPanelBase.cxx                  |    4 
 svx/source/svdraw/svdibrow.cxx                                     |    3 
 svx/source/svdraw/svdocapt.cxx                                     |    3 
 svx/source/table/tablecontroller.cxx                               |    5 
 svx/source/tbxctrls/tbcontrl.cxx                                   |    5 
 svx/source/xml/xmlxtimp.cxx                                        |    3 
 sw/source/core/access/acccontext.cxx                               |    4 
 sw/source/core/crsr/pam.cxx                                        |    4 
 sw/source/core/doc/docglbl.cxx                                     |    4 
 sw/source/core/layout/paintfrm.cxx                                 |   10 
 sw/source/core/txtnode/thints.cxx                                  |    5 
 sw/source/core/unocore/unoobj.cxx                                  |    4 
 sw/source/filter/html/css1atr.cxx                                  |    5 
 sw/source/filter/html/htmlatr.cxx                                  |    4 
 sw/source/filter/html/htmlform.cxx                                 |    4 
 sw/source/filter/html/svxcss1.cxx                                  |    4 
 sw/source/filter/ww8/ww8par2.cxx                                   |    4 
 sw/source/filter/xml/xmlbrsh.cxx                                   |    4 
 sw/source/filter/xml/xmlimp.cxx                                    |    4 
 sw/source/filter/xml/xmlmeta.cxx                                   |    4 
 sw/source/filter/xml/xmltbli.cxx                                   |    4 
 sw/source/filter/xml/xmltexte.cxx                                  |    4 
 sw/source/ui/fldui/fldref.cxx                                      |    4 
 sw/source/ui/frmdlg/frmpage.cxx                                    |    5 
 sw/source/uibase/config/modcfg.cxx                                 |    5 
 sw/source/uibase/dbui/dbmgr.cxx                                    |   10 
 sw/source/uibase/sidebar/PageStylesPanel.cxx                       |    4 
 sw/source/uibase/uno/SwXDocumentSettings.cxx                       |    4 
 sw/source/uibase/uno/unomailmerge.cxx                              |    5 
 sw/source/uibase/uno/unomod.cxx                                    |    4 
 sw/source/uibase/utlui/content.cxx                                 |    4 
 sw/source/uibase/utlui/glbltree.cxx                                |    4 
 sw/source/uibase/utlui/navipi.cxx                                  |    4 
 ucb/source/ucp/ftp/ftpcontent.cxx                                  |    4 
 ucb/source/ucp/ftp/ftpurl.cxx                                      |    4 
 unotools/source/config/configvaluecontainer.cxx                    |    4 
 unotools/source/config/fltrcfg.cxx                                 |    5 
 unotools/source/misc/fontcvt.cxx                                   |    4 
 vcl/source/app/settings.cxx                                        |    4 
 vcl/source/control/fmtfield.cxx                                    |    4 
 vcl/source/filter/igif/gifread.cxx                                 |    4 
 vcl/source/filter/ixbm/xbmread.cxx                                 |    4 
 vcl/source/filter/ixpm/xpmread.cxx                                 |    4 
 vcl/source/fontsubset/sft.cxx                                      |    8 
 vcl/source/gdi/regionband.cxx                                      |    4 
 vcl/source/graphic/UnoGraphicDescriptor.cxx                        |    3 
 vcl/unx/gtk3/a11y/gtk3atktextattributes.cxx                        |    4 
 vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx                          |    4 
 vcl/workben/vcldemo.cxx                                            |    4 
 xmloff/source/chart/XMLSymbolImageContext.cxx                      |    4 
 xmloff/source/draw/XMLImageMapContext.cxx                          |    3 
 xmloff/source/draw/animationimport.cxx                             |    4 
 xmloff/source/draw/animexp.cxx                                     |    4 
 xmloff/source/draw/animimp.cxx                                     |    4 
 xmloff/source/draw/shapeexport.cxx                                 |    4 
 xmloff/source/style/DashStyle.cxx                                  |    4 
 xmloff/source/style/GradientStyle.cxx                              |    4 
 xmloff/source/style/HatchStyle.cxx                                 |    4 
 xmloff/source/style/ImageStyle.cxx                                 |    4 
 xmloff/source/style/TransGradientStyle.cxx                         |    4 
 xmloff/source/style/XMLBackgroundImageContext.cxx                  |    5 
 xmloff/source/style/XMLFontStylesContext.cxx                       |    4 
 xmloff/source/style/xmlnumfi.cxx                                   |    3 
 xmloff/source/style/xmlnumi.cxx                                    |   13 
 xmloff/source/style/xmltabi.cxx                                    |    4 
 xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx       |    4 
 xmloff/source/text/XMLFootnoteImportContext.cxx                    |    3 
 xmloff/source/text/XMLIndexTemplateContext.cxx                     |    3 
 xmloff/source/text/XMLSectionExport.cxx                            |    3 
 xmloff/source/text/XMLSectionImportContext.cxx                     |    3 
 xmloff/source/text/XMLSectionSourceDDEImportContext.cxx            |    4 
 xmloff/source/text/XMLSectionSourceImportContext.cxx               |    3 
 xmloff/source/text/XMLTextColumnsContext.cxx                       |    4 
 xmloff/source/text/XMLTextMarkImportContext.cxx                    |    4 
 xmloff/source/text/txtdropi.cxx                                    |    3 
 xmloff/source/text/txtfldi.cxx                                     |    3 
 xmloff/source/text/txtparae.cxx                                    |    8 
 xmloff/source/text/txtvfldi.cxx                                    |    3 
 xmloff/source/transform/OOo2Oasis.cxx                              |    4 
 xmloff/source/transform/Oasis2OOo.cxx                              |    4 
 155 files changed, 975 insertions(+), 13 deletions(-)

New commits:
commit 314f15bff08b76bf96acf99141776ef64d2f1355
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Sat Nov 16 21:00:53 2019 +0100
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Sun Nov 17 00:28:17 2019 +0100

    Extend loplugin:external to warn about enums
    
    To mitigate the dangers of silently breaking ADL when moving enums into unnamed
    namespaces (see the commit message of 206b5b2661be37efdff3c6aedb6f248c4636be79
    "New loplugin:external"), note all functions that are affected.  (The plan is to
    extend loplugin:external further to also warn about classes and class templates,
    and the code to identify affected functions already takes that into account, so
    some parts of that code are not actually relevant for enums.)
    
    But it appears that none of the functions that are actually affected by the
    changes in this commit relied on being found through ADL, so no adaptions were
    necessary for them.
    
    (clang::DeclContext::collectAllContexts is non-const, which recursively means
    that External's Visit... functions must take non-const Decl*.  Which required
    compilerplugins/clang/sharedvisitor/analyzer.cxx to be generalized to support
    such Visit... functions with non-const Decl* parameters.)
    
    Change-Id: Ia215291402bf850d43defdab3cff4db5b270d1bd
    Reviewed-on: https://gerrit.libreoffice.org/83001
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/UnoControls/source/controls/framecontrol.cxx b/UnoControls/source/controls/framecontrol.cxx
index a954c112d6f1..004facf6f942 100644
--- a/UnoControls/source/controls/framecontrol.cxx
+++ b/UnoControls/source/controls/framecontrol.cxx
@@ -44,6 +44,8 @@ using namespace ::com::sun::star::util;
 
 namespace unocontrols {
 
+namespace {
+
 enum PropertyHandle  // values represent index in PropertyArray
 {                   // for FrameControl
     Componenturl    = 0,
@@ -51,6 +53,8 @@ enum PropertyHandle  // values represent index in PropertyArray
     Loaderarguments = 2
 };
 
+}
+
 //  construct/destruct
 
 FrameControl::FrameControl( const Reference< XComponentContext >& rxContext)
diff --git a/basctl/source/basicide/doceventnotifier.cxx b/basctl/source/basicide/doceventnotifier.cxx
index 36ed3d3548c5..96eea35b662b 100644
--- a/basctl/source/basicide/doceventnotifier.cxx
+++ b/basctl/source/basicide/doceventnotifier.cxx
@@ -52,12 +52,16 @@ namespace basctl
     typedef ::cppu::WeakComponentImplHelper<   XDocumentEventListener
                                            >   DocumentEventNotifier_Impl_Base;
 
+    namespace {
+
     enum ListenerAction
     {
         RegisterListener,
         RemoveListener
     };
 
+    }
+
     /** impl class for DocumentEventNotifier
     */
     class DocumentEventNotifier::Impl   :public ::cppu::BaseMutex
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index 26aedddd3a40..8fbb3dd66c03 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -1488,11 +1488,17 @@ static void processAutomationParams( SbxArray* pParams, Sequence< Any >& args, s
     }
 
 }
+
+namespace {
+
 enum class INVOKETYPE
 {
    GetProp = 0,
    Func
 };
+
+}
+
 static Any invokeAutomationMethod( const OUString& Name, Sequence< Any > const & args, SbxArray* pParams, sal_uInt32 nParamCount, Reference< XInvocation > const & rxInvocation, INVOKETYPE invokeType )
 {
     Sequence< sal_Int16 > OutParamIndex;
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx
index 19f0acaa8c0a..ea65461ff73c 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -1771,6 +1771,7 @@ void SbRtl_Weekday(StarBASIC *, SbxArray & rPar, bool)
     }
 }
 
+namespace {
 
 enum Interval
 {
@@ -1786,6 +1787,8 @@ enum Interval
     INTERVAL_S
 };
 
+}
+
 struct IntervalInfo
 {
     Interval    meInterval;
diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/abi.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/abi.cxx
index 3da3adac5fc3..ceed901f9e11 100644
--- a/bridges/source/cpp_uno/gcc3_linux_x86-64/abi.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/abi.cxx
@@ -58,6 +58,8 @@
 
 using namespace x86_64;
 
+namespace {
+
 /* Register class used for passing given 64bit part of the argument.
    These represent classes as documented by the PS ABI, with the exception
    of SSESF, SSEDF classes, that are basically SSE class, just gcc will
@@ -80,6 +82,8 @@ enum x86_64_reg_class
     X86_64_MEMORY_CLASS
 };
 
+}
+
 #define MAX_CLASSES 4
 
 /* x86-64 register passing implementation.  See x86-64 ABI for details.  Goal
diff --git a/chart2/source/controller/dialogs/tp_Scale.cxx b/chart2/source/controller/dialogs/tp_Scale.cxx
index fccdf87c900f..ea47532878a4 100644
--- a/chart2/source/controller/dialogs/tp_Scale.cxx
+++ b/chart2/source/controller/dialogs/tp_Scale.cxx
@@ -193,6 +193,8 @@ IMPL_LINK( ScaleTabPage, EnableValueHdl, weld::ToggleButton&, rCbx, void )
     }
 }
 
+namespace {
+
 enum AxisTypeListBoxEntry
 {
     TYPE_AUTO=0,
@@ -200,6 +202,8 @@ enum AxisTypeListBoxEntry
     TYPE_DATE=2
 };
 
+}
+
 IMPL_LINK_NOARG(ScaleTabPage, SelectAxisTypeHdl, weld::ComboBox&, void)
 {
     const sal_Int32 nPos = m_xLB_AxisType->get_active();
diff --git a/comphelper/source/container/enumerablemap.cxx b/comphelper/source/container/enumerablemap.cxx
index f003fe0e02ee..bee5d03963b2 100644
--- a/comphelper/source/container/enumerablemap.cxx
+++ b/comphelper/source/container/enumerablemap.cxx
@@ -194,12 +194,14 @@ namespace comphelper
         MapData             m_aData;
     };
 
+    namespace {
 
     enum EnumerationType
     {
         eKeys, eValues, eBoth
     };
 
+    }
 
     class MapEnumerator final
     {
diff --git a/comphelper/source/misc/syntaxhighlight.cxx b/comphelper/source/misc/syntaxhighlight.cxx
index b3f62a70365b..60ecc7b97c94 100644
--- a/comphelper/source/misc/syntaxhighlight.cxx
+++ b/comphelper/source/misc/syntaxhighlight.cxx
@@ -26,6 +26,8 @@
 #include <comphelper/syntaxhighlight.hxx>
 #include <o3tl/typed_flags_set.hxx>
 
+namespace {
+
 // Flags for character properties
 enum class CharFlags {
     StartIdentifier   = 0x0001,
@@ -39,6 +41,9 @@ enum class CharFlags {
     Space             = 0x0100,
     EOL               = 0x0200
 };
+
+}
+
 namespace o3tl {
     template<> struct typed_flags<CharFlags> : is_typed_flags<CharFlags, 0x03ff> {};
 }
diff --git a/compilerplugins/clang/external.cxx b/compilerplugins/clang/external.cxx
index 2b6b689ea315..e4a6b0df6e42 100644
--- a/compilerplugins/clang/external.cxx
+++ b/compilerplugins/clang/external.cxx
@@ -10,6 +10,9 @@
 
 #include <algorithm>
 #include <cassert>
+#include <iterator>
+#include <list>
+#include <set>
 
 #include "clang/Sema/SemaDiagnostic.h"
 
@@ -45,6 +48,79 @@ bool isInjectedFunction(FunctionDecl const* decl)
     return true;
 }
 
+// Whether type1 mentions type2 (in a way relevant for argument-dependent name lookup):
+bool mentions(QualType type1, QualType type2)
+{
+    auto t1 = type1;
+    for (;;)
+    {
+        if (auto const t2 = t1->getAs<ReferenceType>())
+        {
+            t1 = t2->getPointeeType();
+        }
+        else if (auto const t3 = t1->getAs<PointerType>())
+        {
+            t1 = t3->getPointeeType();
+        }
+        else if (auto const t4 = t1->getAsArrayTypeUnsafe())
+        {
+            t1 = t4->getElementType();
+        }
+        else
+        {
+            break;
+        }
+    }
+    if (t1.getCanonicalType().getTypePtr() == type2.getTypePtr())
+    {
+        return true;
+    }
+    if (auto const t2 = t1->getAs<TemplateSpecializationType>())
+    {
+        for (auto a = t2->begin(); a != t2->end(); ++a)
+        {
+            if (a->getKind() != TemplateArgument::Type)
+            {
+                continue;
+            }
+            if (mentions(a->getAsType(), type2))
+            {
+                return true;
+            }
+        }
+        auto const t3 = t2->desugar();
+        if (t3.getTypePtr() == t2)
+        {
+            return false;
+        }
+        return mentions(t3, type2);
+    }
+    if (auto const t2 = t1->getAs<FunctionProtoType>())
+    {
+        if (mentions(t2->getReturnType(), type2))
+        {
+            return true;
+        }
+        for (auto t3 = t2->param_type_begin(); t3 != t2->param_type_end(); ++t3)
+        {
+            if (mentions(*t3, type2))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+    if (auto const t2 = t1->getAs<MemberPointerType>())
+    {
+        if (t2->getClass()->getUnqualifiedDesugaredType() == type2.getTypePtr())
+        {
+            return true;
+        }
+        return mentions(t2->getPointeeType(), type2);
+    }
+    return false;
+}
+
 class External : public loplugin::FilteringPlugin<External>
 {
 public:
@@ -55,10 +131,11 @@ public:
 
     void run() override { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
 
-    bool VisitTagDecl(TagDecl const* decl)
+    bool VisitTagDecl(TagDecl* decl)
     {
         /*TODO:*/
-        return true; // in general, moving classes or enumerations into an unnamed namespace can break ADL
+        if (!isa<EnumDecl>(decl))
+            return true; // in general, moving classes into an unnamed namespace can break ADL
         if (isa<ClassTemplateSpecializationDecl>(decl))
         {
             return true;
@@ -102,7 +179,7 @@ public:
         return handleDeclaration(decl);
     }
 
-    bool VisitFunctionDecl(FunctionDecl const* decl)
+    bool VisitFunctionDecl(FunctionDecl* decl)
     {
         if (isa<CXXMethodDecl>(decl))
         {
@@ -166,7 +243,7 @@ public:
         return handleDeclaration(decl);
     }
 
-    bool VisitVarDecl(VarDecl const* decl)
+    bool VisitVarDecl(VarDecl* decl)
     {
         if (decl->isStaticDataMember())
         {
@@ -187,7 +264,7 @@ public:
         return handleDeclaration(decl);
     }
 
-    bool VisitClassTemplateDecl(ClassTemplateDecl const* decl)
+    bool VisitClassTemplateDecl(ClassTemplateDecl* decl)
     {
         /*TODO:*/
         return true; // in general, moving classes or enumerations into an unnamed namespace can break ADL
@@ -202,7 +279,7 @@ public:
         return handleDeclaration(decl);
     }
 
-    bool VisitFunctionTemplateDecl(FunctionTemplateDecl const* decl)
+    bool VisitFunctionTemplateDecl(FunctionTemplateDecl* decl)
     {
         if (!decl->isThisDeclarationADefinition())
         {
@@ -219,7 +296,7 @@ public:
         return handleDeclaration(decl);
     }
 
-    bool VisitVarTemplateDecl(VarTemplateDecl const* decl)
+    bool VisitVarTemplateDecl(VarTemplateDecl* decl)
     {
         if (!decl->isThisDeclarationADefinition())
         {
@@ -243,7 +320,149 @@ private:
         }
     }
 
-    bool handleDeclaration(NamedDecl const* decl)
+    void computeAffectedTypes(Decl const* decl, std::vector<QualType>* affected)
+    {
+        assert(affected != nullptr);
+        if (auto const d = dyn_cast<EnumDecl>(decl))
+        {
+            affected->push_back(compiler.getASTContext().getEnumType(d));
+        }
+        else
+        {
+            CXXRecordDecl const* rec;
+            if (auto const d = dyn_cast<ClassTemplateDecl>(decl))
+            {
+                rec = d->getTemplatedDecl();
+            }
+            else
+            {
+                rec = cast<CXXRecordDecl>(decl);
+            }
+            affected->push_back(compiler.getASTContext().getRecordType(rec));
+            for (auto d = rec->decls_begin(); d != rec->decls_end(); ++d)
+            {
+                if (*d != (*d)->getCanonicalDecl())
+                {
+                    continue;
+                }
+                if (isa<TagDecl>(*d) || isa<ClassTemplateDecl>(*d))
+                {
+                    if (auto const d1 = dyn_cast<RecordDecl>(*d))
+                    {
+                        if (d1->isInjectedClassName())
+                        {
+                            continue;
+                        }
+                    }
+                    computeAffectedTypes(*d, affected);
+                }
+            }
+        }
+    }
+
+    void reportAssociatingFunctions(std::vector<QualType> const& affected, Decl* decl)
+    {
+        auto c = decl->getDeclContext();
+        while (isa<LinkageSpecDecl>(c) || c->isInlineNamespace())
+        {
+            c = c->getParent();
+        }
+        assert(c->isTranslationUnit() || c->isNamespace());
+        SmallVector<DeclContext*, 2> parts;
+        c->collectAllContexts(parts);
+        std::list<DeclContext const*> ctxs;
+        std::copy(parts.begin(), parts.end(),
+                  std::back_insert_iterator<std::list<DeclContext const*>>(ctxs));
+        if (auto const d = dyn_cast<CXXRecordDecl>(decl))
+        {
+            // To find friend functions declared in the class:
+            ctxs.push_back(d);
+        }
+        std::set<FunctionDecl const*> fdecls; // to report every function just once
+        for (auto ctx = ctxs.begin(); ctx != ctxs.end(); ++ctx)
+        {
+            for (auto i = (*ctx)->decls_begin(); i != (*ctx)->decls_end(); ++i)
+            {
+                auto d = *i;
+                if (auto const d1 = dyn_cast<LinkageSpecDecl>(d))
+                {
+                    ctxs.push_back(d1);
+                    continue;
+                }
+                if (auto const d1 = dyn_cast<NamespaceDecl>(d))
+                {
+                    if (d1->isInline())
+                    {
+                        ctxs.push_back(d1);
+                    }
+                    continue;
+                }
+                if (auto const d1 = dyn_cast<FriendDecl>(d))
+                {
+                    d = d1->getFriendDecl();
+                }
+                FunctionDecl const* f;
+                if (auto const d1 = dyn_cast<FunctionTemplateDecl>(d))
+                {
+                    f = d1->getTemplatedDecl();
+                }
+                else
+                {
+                    f = dyn_cast<FunctionDecl>(d);
+                    if (f == nullptr)
+                    {
+                        continue;
+                    }
+                }
+                if (!fdecls.insert(f->getCanonicalDecl()).second)
+                {
+                    continue;
+                }
+                if (isa<CXXMethodDecl>(f))
+                {
+                    continue;
+                }
+                for (auto const t : affected)
+                {
+                    auto const tc = t.getCanonicalType();
+                    for (auto p = f->param_begin(); p != f->param_end(); ++p)
+                    {
+                        if (mentions((*p)->getType(), tc))
+                        {
+                            report(DiagnosticsEngine::Note,
+                                   "a %select{function|function template|function template "
+                                   "specialization}0 associating %1 is declared here",
+                                   f->getLocation())
+                                << (f->isFunctionTemplateSpecialization()
+                                        ? 2
+                                        : f->getDescribedFunctionTemplate() != nullptr ? 1 : 0)
+                                << t << f->getSourceRange();
+                            for (auto f1 = f->redecls_begin(); f1 != f->redecls_end(); ++f1)
+                            {
+                                if (*f1 == f)
+                                {
+                                    continue;
+                                }
+                                report(DiagnosticsEngine::Note, "another declaration is here",
+                                       f1->getLocation())
+                                    << f1->getSourceRange();
+                            }
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    void reportAssociatingFunctions(Decl* decl)
+    {
+        std::vector<QualType> affected; // enum/class/class template + recursively affected members
+        computeAffectedTypes(decl, &affected);
+        reportAssociatingFunctions(affected, decl);
+    }
+
+    bool handleDeclaration(NamedDecl* decl)
     {
         if (ignoreLocation(decl))
         {
@@ -364,6 +583,10 @@ private:
         {
             reportSpecializations(d->specializations());
         }
+        if (isa<TagDecl>(decl) || isa<ClassTemplateDecl>(decl))
+        {
+            reportAssociatingFunctions(decl);
+        }
         return true;
     }
 };
diff --git a/compilerplugins/clang/sharedvisitor/analyzer.cxx b/compilerplugins/clang/sharedvisitor/analyzer.cxx
index d0f5d4e7a8a7..745064647c81 100644
--- a/compilerplugins/clang/sharedvisitor/analyzer.cxx
+++ b/compilerplugins/clang/sharedvisitor/analyzer.cxx
@@ -14,6 +14,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/StringExtras.h"
 
+#include <cassert>
 #include <cstddef>
 #include <cstring>
 #include <iostream>
@@ -55,6 +56,8 @@ class CheckFileVisitor
     : public RecursiveASTVisitor< CheckFileVisitor >
 {
 public:
+    void setContext(ASTContext const& context) { context_ = &context; }
+
     bool VisitCXXRecordDecl(CXXRecordDecl *Declaration);
 
     bool TraverseNamespaceDecl(NamespaceDecl * decl)
@@ -67,6 +70,21 @@ public:
         }
         return RecursiveASTVisitor<CheckFileVisitor>::TraverseNamespaceDecl(decl);
     }
+
+private:
+    ASTContext const* context_ = nullptr;
+
+    QualType unqualifyPointeeType(QualType type)
+    {
+        assert(context_ != nullptr);
+        if (auto const t = type->getAs<PointerType>())
+        {
+            return context_->getQualifiedType(
+                context_->getPointerType(t->getPointeeType().getUnqualifiedType()),
+                type.getQualifiers());
+        }
+        return type;
+    }
 };
 
 static bool inheritsPluginClassCheck( const Decl* decl )
@@ -116,7 +134,8 @@ bool CheckFileVisitor::VisitCXXRecordDecl( CXXRecordDecl* decl )
                 cout << "VisitFunctionStart" << endl;
                 cout << "VisitFunctionName:" << method->getName().str() << endl;
                 cout << "VisitFunctionArgument:"
-                    << method->getParamDecl( 0 )->getTypeSourceInfo()->getType().getAsString()
+                    << unqualifyPointeeType(
+                        method->getParamDecl( 0 )->getTypeSourceInfo()->getType()).getAsString()
                     << endl;
                 cout << "VisitFunctionEnd" << endl;
             }
@@ -185,6 +204,10 @@ class FindNamedClassConsumer
     : public ASTConsumer
 {
 public:
+    void Initialize(ASTContext& context) override
+    {
+        visitor.setContext(context);
+    }
     virtual void HandleTranslationUnit(ASTContext& context) override
     {
         visitor.TraverseDecl( context.getTranslationUnitDecl());
diff --git a/compilerplugins/clang/test/external.cxx b/compilerplugins/clang/test/external.cxx
index ff996f54a467..28b7c6df01b7 100644
--- a/compilerplugins/clang/test/external.cxx
+++ b/compilerplugins/clang/test/external.cxx
@@ -7,6 +7,10 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#include <sal/config.h>
+
+#include <vector>
+
 // expected-error at +1 {{externally available entity 'n1' is not previously declared in an included file (if it is only used in this translation unit, make it static or put it in an unnamed namespace; otherwise, provide a declaration of it in an included file) [loplugin:external]}}
 int n1 = 0;
 // expected-note at +1 {{another declaration is here [loplugin:external]}}
@@ -42,11 +46,68 @@ static void g()
 // expected-note at +1 {{another declaration is here [loplugin:external]}}
 void f2();
 
+namespace N
+{
+inline namespace I1
+{
+extern "C++" {
+// expected-note at +1 {{another declaration is here [loplugin:external]}}
+enum E : int;
+
+// expected-error at +1 {{externally available entity 'E' is not previously declared in an included file (if it is only used in this translation unit, put it in an unnamed namespace; otherwise, provide a declaration of it in an included file) [loplugin:external]}}
+enum E : int
+{
+};
+}
+}
+
+// expected-note at +1 {{a function associating 'N::I1::E' is declared here [loplugin:external]}}
+static void g(std::vector<E>)
+{
+    // expected-note at +1 {{another declaration is here [loplugin:external]}}
+    void f(E const*);
+}
+
+// expected-note at +1 {{a function associating 'N::I1::E' is declared here [loplugin:external]}}
+void f(E const*);
+
+extern "C++" {
+// expected-note at +1 {{a function associating 'N::I1::E' is declared here [loplugin:external]}}
+void fc(E const*);
+}
+
+struct S1
+{
+    struct S2;
+    // No note about associating function; injected friend function not found by ADL:
+    friend void f2(E const*);
+};
+
+inline namespace I2
+{
+// expected-note at +1 {{a function associating 'N::I1::E' is declared here [loplugin:external]}}
+void f3(E);
+
+inline namespace I3
+{
+// expected-note at +1 {{a function associating 'N::I1::E' is declared here [loplugin:external]}}
+void f4(E);
+}
+}
+}
+
+struct N::S1::S2
+{
+    // expected-note at +1 {{another declaration is here [loplugin:external]}}
+    friend void f(E const*);
+};
+
 int main()
 {
     (void)n2;
     (void)n3;
     g();
+    (void)&N::g;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/cui/source/dialogs/colorpicker.cxx b/cui/source/dialogs/colorpicker.cxx
index bddca8e8ca81..e3b46bcdec87 100644
--- a/cui/source/dialogs/colorpicker.cxx
+++ b/cui/source/dialogs/colorpicker.cxx
@@ -43,6 +43,8 @@ using namespace ::com::sun::star::ui::dialogs;
 using namespace ::com::sun::star::beans;
 using namespace ::basegfx;
 
+namespace {
+
 enum class UpdateFlags
 {
     NONE         = 0x00,
@@ -54,6 +56,9 @@ enum class UpdateFlags
     Hex          = 0x20,
     All          = 0x3f,
 };
+
+}
+
 namespace o3tl {
     template<> struct typed_flags<UpdateFlags> : is_typed_flags<UpdateFlags, 0x3f> {};
 }
@@ -62,6 +67,8 @@ namespace o3tl {
 namespace cui
 {
 
+namespace {
+
 enum class ColorComponent {
     Red,
     Green,
@@ -75,6 +82,7 @@ enum class ColorComponent {
     Key,
 };
 
+}
 
 // color space conversion helpers
 
@@ -171,7 +179,12 @@ void ColorPreviewControl::Paint(vcl::RenderContext& rRenderContext, const tools:
     rRenderContext.DrawRect(tools::Rectangle(Point(0, 0), GetOutputSizePixel()));
 }
 
+namespace {
+
 enum ColorMode { HUE, SATURATION, BRIGHTNESS, RED, GREEN, BLUE };
+
+}
+
 const ColorMode DefaultMode = HUE;
 
 class ColorFieldControl : public weld::CustomWidgetController
diff --git a/cui/source/options/optdict.cxx b/cui/source/options/optdict.cxx
index 07080a75184a..9e00183209e3 100644
--- a/cui/source/options/optdict.cxx
+++ b/cui/source/options/optdict.cxx
@@ -66,9 +66,13 @@ static OUString getNormDicEntry_Impl(const OUString &rText)
     return aTmp.replaceAll("=", "");
 }
 
+namespace {
+
 // Compare Dictionary Entry  result
 enum CDE_RESULT { CDE_EQUAL, CDE_SIMILAR, CDE_DIFFERENT };
 
+}
+
 static CDE_RESULT cmpDicEntry_Impl( const OUString &rText1, const OUString &rText2 )
 {
     CDE_RESULT eRes = CDE_DIFFERENT;
diff --git a/cui/source/options/optlingu.cxx b/cui/source/options/optlingu.cxx
index 2026c73826a9..5e394e9753e3 100644
--- a/cui/source/options/optlingu.cxx
+++ b/cui/source/options/optlingu.cxx
@@ -172,6 +172,8 @@ DicUserData::DicUserData(
     Entry IDs for options listbox of dialog
 --------------------------------------------------*/
 
+namespace {
+
 enum EID_OPTIONS
 {
     EID_SPELL_AUTO,
@@ -186,6 +188,8 @@ enum EID_OPTIONS
     EID_HYPH_SPECIAL
 };
 
+}
+
 //! this array must have an entry for every value of EID_OPTIONS.
 //  It is used to get the respective property name.
 static const char * aEidToPropName[] =
diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx
index cae7b77fdd40..edb129d8c227 100644
--- a/cui/source/tabpages/autocdlg.cxx
+++ b/cui/source/tabpages/autocdlg.cxx
@@ -321,6 +321,8 @@ public:
 /*                                                                   */
 /*********************************************************************/
 
+namespace {
+
 enum OfaAutoFmtOptions
 {
     USE_REPLACE_TABLE,
@@ -343,6 +345,8 @@ enum OfaAutoFmtOptions
     MERGE_SINGLE_LINE_PARA
 };
 
+}
+
 OfaSwAutoFmtOptionsPage::OfaSwAutoFmtOptionsPage(weld::Container* pPage, weld::DialogController* pController,
                                                  const SfxItemSet& rSet )
     : SfxTabPage(pPage, pController, "cui/ui/applyautofmtpage.ui", "ApplyAutoFmtPage", &rSet)
@@ -1516,12 +1520,16 @@ IMPL_LINK(OfaAutocorrExceptPage, ModifyHdl, weld::Entry&, rEdt, void)
     }
 }
 
+namespace {
+
 enum OfaQuoteOptions
 {
     ADD_NONBRK_SPACE,
     REPLACE_1ST
 };
 
+}
+
 void OfaQuoteTabPage::CreateEntry(weld::TreeView& rCheckLB, const OUString& rTxt, sal_uInt16 nCol, sal_uInt16 nTextCol)
 {
     rCheckLB.append();
diff --git a/cui/source/tabpages/paragrph.cxx b/cui/source/tabpages/paragrph.cxx
index 7990744f1cc3..8cfb01fa1a31 100644
--- a/cui/source/tabpages/paragrph.cxx
+++ b/cui/source/tabpages/paragrph.cxx
@@ -84,6 +84,8 @@ const sal_uInt16 SvxExtParagraphTabPage::pExtRanges[] =
                             // according to BP
 #define FIX_DIST_DEF 283    // standard fix distance 0,5 cm
 
+namespace {
+
 enum LineSpaceList
 {
     LLINESPACE_1    = 0,
@@ -96,6 +98,8 @@ enum LineSpaceList
     LLINESPACE_FIX  = 7
 };
 
+}
+
 static void SetLineSpace_Impl( SvxLineSpacingItem&, int, long lValue = 0 );
 
 void SetLineSpace_Impl( SvxLineSpacingItem& rLineSpace,
diff --git a/cui/source/tabpages/swpossizetabpage.cxx b/cui/source/tabpages/swpossizetabpage.cxx
index 46a210559892..33a0649d21e6 100644
--- a/cui/source/tabpages/swpossizetabpage.cxx
+++ b/cui/source/tabpages/swpossizetabpage.cxx
@@ -41,8 +41,12 @@ using namespace ::com::sun::star::text;
 
 #define SwFPos SvxSwFramePosString
 
+namespace {
+
 enum class LB;
 
+}
+
 struct FrmMap
 {
     SvxSwFramePosString::StringId   eStrId;
@@ -64,6 +68,8 @@ struct StringIdPair_Impl
     SvxSwFramePosString::StringId eVert;
 };
 
+namespace {
+
 enum class LB {
     NONE                = 0x000000,
     Frame               = 0x000001, // paragraph text area
@@ -96,6 +102,9 @@ enum class LB {
 
     LAST = VertLine
 };
+
+}
+
 namespace o3tl {
     template<> struct typed_flags<LB> : is_typed_flags<LB, 0x0fffff> {};
 }
diff --git a/cui/source/tabpages/tparea.cxx b/cui/source/tabpages/tparea.cxx
index d0c70b60c456..079b717c3efe 100644
--- a/cui/source/tabpages/tparea.cxx
+++ b/cui/source/tabpages/tparea.cxx
@@ -32,6 +32,8 @@ using namespace com::sun::star;
 
 // static ----------------------------------------------------------------
 
+namespace {
+
 enum FillType
 {
     TRANSPARENT,
@@ -42,6 +44,8 @@ enum FillType
     PATTERN
 };
 
+}
+
 const sal_uInt16 SvxAreaTabPage::pAreaRanges[] =
 {
     XATTR_GRADIENTSTEPCOUNT,
diff --git a/cui/source/tabpages/tpbitmap.cxx b/cui/source/tabpages/tpbitmap.cxx
index 7d1f17be236b..aea68537a5fa 100644
--- a/cui/source/tabpages/tpbitmap.cxx
+++ b/cui/source/tabpages/tpbitmap.cxx
@@ -48,6 +48,8 @@
 
 using namespace com::sun::star;
 
+namespace {
+
 enum BitmapStyle
 {
     CUSTOM,
@@ -61,6 +63,8 @@ enum TileOffset
     COLUMN
 };
 
+}
+
 const sal_uInt16 SvxBitmapTabPage::pBitmapRanges[] =
 {
     SID_ATTR_TRANSFORM_WIDTH,
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index bc0fd62eb78a..1e97c1aecc4b 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -4261,12 +4261,16 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
     return pJson;
 }
 
+namespace {
+
 enum class UndoOrRedo
 {
     UNDO,
     REDO
 };
 
+}
+
 /// Returns the JSON representation of either an undo or a redo stack.
 static char* getUndoOrRedo(LibreOfficeKitDocument* pThis, UndoOrRedo eCommand)
 {
diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx
index b72c026bc6fe..debbf5c0add1 100644
--- a/drawinglayer/source/tools/emfphelperdata.cxx
+++ b/drawinglayer/source/tools/emfphelperdata.cxx
@@ -104,6 +104,8 @@ namespace emfplushelper
     {
     }
 
+    namespace {
+
     typedef enum
     {
         StringAlignmentNear = 0x00000000,
@@ -111,6 +113,8 @@ namespace emfplushelper
         StringAlignmentFar = 0x00000002
     } StringAlignment;
 
+    }
+
     float EmfPlusHelperData::getUnitToPixelMultiplier(const UnitType aUnitType)
     {
         switch (aUnitType)
diff --git a/drawinglayer/source/tools/emfppen.cxx b/drawinglayer/source/tools/emfppen.cxx
index 039a5c02d612..85a5e176c1f3 100644
--- a/drawinglayer/source/tools/emfppen.cxx
+++ b/drawinglayer/source/tools/emfppen.cxx
@@ -28,6 +28,8 @@ using namespace ::basegfx;
 
 namespace emfplushelper
 {
+    namespace {
+
     enum EmfPlusPenData
     {
         PenDataTransform        = 0x00000001,
@@ -45,6 +47,8 @@ namespace emfplushelper
         PenDataCustomEndCap     = 0x00001000
     };
 
+    }
+
     EMFPPen::EMFPPen()
         : EMFPBrush()
         , penDataFlags(0)
diff --git a/editeng/source/items/paraitem.cxx b/editeng/source/items/paraitem.cxx
index 983f210dec3a..fd3c1e555997 100644
--- a/editeng/source/items/paraitem.cxx
+++ b/editeng/source/items/paraitem.cxx
@@ -67,6 +67,7 @@ SfxPoolItem* SvxFormatSplitItem::CreateDefault() { return new  SvxFormatSplitIte
 SfxPoolItem* SvxPageModelItem::CreateDefault() { return new  SvxPageModelItem(0);}
 SfxPoolItem* SvxParaVertAlignItem::CreateDefault() { return new  SvxParaVertAlignItem(Align::Automatic, 0);}
 
+namespace {
 
 enum class SvxSpecialLineSpace
 {
@@ -77,6 +78,7 @@ enum class SvxSpecialLineSpace
     End
 };
 
+}
 
 SvxLineSpacingItem::SvxLineSpacingItem( sal_uInt16 nHeight, const sal_uInt16 nId )
     : SfxEnumItemInterface( nId )
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index 8d0d34648540..71249b9b051e 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -89,12 +89,17 @@ using namespace ::com::sun::star;
 using namespace ::xmloff::token;
 using namespace ::utl;
 
+namespace {
+
 enum class Flags {
     NONE            = 0x00,
     FullStop        = 0x01,
     ExclamationMark = 0x02,
     QuestionMark    = 0x04,
 };
+
+}
+
 namespace o3tl {
     template<> struct typed_flags<Flags> : is_typed_flags<Flags, 0x07> {};
 }
diff --git a/extensions/source/propctrlr/browserlistbox.cxx b/extensions/source/propctrlr/browserlistbox.cxx
index d64c86774f11..1e77361f9400 100644
--- a/extensions/source/propctrlr/browserlistbox.cxx
+++ b/extensions/source/propctrlr/browserlistbox.cxx
@@ -59,6 +59,8 @@ namespace pcr
 
     namespace PropertyControlType = ::com::sun::star::inspection::PropertyControlType;
 
+    namespace {
+
     enum ControlEventType
     {
         FOCUS_GAINED,
@@ -66,6 +68,8 @@ namespace pcr
         ACTIVATE_NEXT
     };
 
+    }
+
     struct ControlEvent : public ::comphelper::AnyEvent
     {
         Reference< XPropertyControl >   xControl;
diff --git a/extensions/source/scanner/sane.cxx b/extensions/source/scanner/sane.cxx
index 47055a2b0968..67889ce00416 100644
--- a/extensions/source/scanner/sane.cxx
+++ b/extensions/source/scanner/sane.cxx
@@ -466,10 +466,14 @@ void Sane::SetOptionValue( int n, double const * pSet )
     ControlOption( n, SANE_ACTION_SET_VALUE, pFixedSet.get() );
 }
 
+namespace {
+
 enum FrameStyleType {
     FrameStyle_BW, FrameStyle_Gray, FrameStyle_RGB, FrameStyle_Separated
 };
 
+}
+
 #define BYTE_BUFFER_SIZE 32768
 
 static sal_uInt8 ReadValue( FILE* fp, int depth )
diff --git a/filter/source/graphicfilter/ios2met/ios2met.cxx b/filter/source/graphicfilter/ios2met/ios2met.cxx
index 236506aff7cc..b0426d5c47d3 100644
--- a/filter/source/graphicfilter/ios2met/ios2met.cxx
+++ b/filter/source/graphicfilter/ios2met/ios2met.cxx
@@ -35,8 +35,11 @@
 
 class FilterConfigItem;
 
+namespace {
+
 enum PenStyle { PEN_NULL, PEN_SOLID, PEN_DOT, PEN_DASH, PEN_DASHDOT };
 
+}
 
 // -----------------------------Field Types-------------------------------
 
diff --git a/filter/source/graphicfilter/ipcd/ipcd.cxx b/filter/source/graphicfilter/ipcd/ipcd.cxx
index f76ba225def7..c1b3f0061201 100644
--- a/filter/source/graphicfilter/ipcd/ipcd.cxx
+++ b/filter/source/graphicfilter/ipcd/ipcd.cxx
@@ -29,6 +29,8 @@
 
 //============================ PCDReader ==================================
 
+namespace {
+
 // these resolutions are contained in a PCD file:
 enum PCDResolution {
     PCDRES_BASE16,  //  192 x  128
@@ -40,6 +42,8 @@ enum PCDResolution {
     PCDRES_16BASE   // 3072 x 3072
 };
 
+}
+
 class PCDReader {
 
 private:
diff --git a/filter/source/graphicfilter/ipict/ipict.cxx b/filter/source/graphicfilter/ipict/ipict.cxx
index e2d0e9cacd3d..8fc618bc3b10 100644
--- a/filter/source/graphicfilter/ipict/ipict.cxx
+++ b/filter/source/graphicfilter/ipict/ipict.cxx
@@ -138,11 +138,15 @@ namespace PictReaderInternal {
 
 //============================ PictReader ==================================
 
+namespace {
+
 enum class PictDrawingMethod {
     FRAME, PAINT, ERASE, INVERT, FILL,
     TEXT, UNDEFINED
 };
 
+}
+
 class PictReader {
   typedef class PictReaderInternal::Pattern Pattern;
 private:
diff --git a/forms/source/misc/limitedformats.cxx b/forms/source/misc/limitedformats.cxx
index a0eaf0245105..c079591e61b8 100644
--- a/forms/source/misc/limitedformats.cxx
+++ b/forms/source/misc/limitedformats.cxx
@@ -43,6 +43,7 @@ namespace frm
 
     //=
 
+    namespace {
 
     enum LocaleType
     {
@@ -51,6 +52,7 @@ namespace frm
         ltSystem
     };
 
+    }
 
     static const Locale& getLocale(LocaleType _eType)
     {
diff --git a/fpicker/source/office/fileview.cxx b/fpicker/source/office/fileview.cxx
index ce6564402a46..c544da915ec7 100644
--- a/fpicker/source/office/fileview.cxx
+++ b/fpicker/source/office/fileview.cxx
@@ -82,6 +82,8 @@ using ::svt::FolderDescriptor;
 
 #define QUICK_SEARCH_TIMEOUT    1500    // time in mSec before the quicksearch string will be reset
 
+namespace {
+
 enum class FileViewFlags
 {
     NONE               = 0x00,
@@ -89,6 +91,9 @@ enum class FileViewFlags
     SHOW_TYPE          = 0x04,
     SHOW_NONE          = 0x20,
 };
+
+}
+
 namespace o3tl
 {
     template<> struct typed_flags<FileViewFlags> : is_typed_flags<FileViewFlags, 0x26> {};
diff --git a/framework/source/fwe/classes/actiontriggerpropertyset.cxx b/framework/source/fwe/classes/actiontriggerpropertyset.cxx
index 66cc5dd14bdc..128f5815bb1a 100644
--- a/framework/source/fwe/classes/actiontriggerpropertyset.cxx
+++ b/framework/source/fwe/classes/actiontriggerpropertyset.cxx
@@ -33,6 +33,8 @@ using namespace com::sun::star::awt;
 
 //struct SAL_DLLPUBLIC_IMPORT ::cppu::OBroadcastHelperVar< OMultiTypeInterfaceContainerHelper, OMultiTypeInterfaceContainerHelper::keyType >;
 
+namespace {
+
 // Handles for properties
 // (PLEASE SORT THIS FIELD, IF YOU ADD NEW PROPERTIES!)
 // We use an enum to define these handles, to use all numbers from 0 to nn and
@@ -48,6 +50,8 @@ enum EPROPERTIES
     PROPERTYCOUNT
 };
 
+}
+
 namespace framework
 {
 
diff --git a/framework/source/fwe/classes/actiontriggerseparatorpropertyset.cxx b/framework/source/fwe/classes/actiontriggerseparatorpropertyset.cxx
index aa8397a657aa..eb9d6d2ec71f 100644
--- a/framework/source/fwe/classes/actiontriggerseparatorpropertyset.cxx
+++ b/framework/source/fwe/classes/actiontriggerseparatorpropertyset.cxx
@@ -31,6 +31,8 @@ using namespace com::sun::star::beans;
 using namespace com::sun::star::lang;
 using namespace com::sun::star::awt;
 
+namespace {
+
 // Handles for properties
 // (PLEASE SORT THIS FIELD, IF YOU ADD NEW PROPERTIES!)
 // We use an enum to define these handles, to use all numbers from 0 to nn and
@@ -42,6 +44,8 @@ enum EPROPERTIES
     PROPERTYCOUNT
 };
 
+}
+
 namespace framework
 {
 
diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx
index cce5892f0646..49104168dc86 100644
--- a/framework/source/services/desktop.cxx
+++ b/framework/source/services/desktop.cxx
@@ -76,10 +76,14 @@
 
 namespace framework{
 
+namespace {
+
 enum PropHandle {
     ActiveFrame, DispatchRecorderSupplier, IsPlugged, SuspendQuickstartVeto,
     Title };
 
+}
+
 OUString SAL_CALL Desktop::getImplementationName()
 {
     return "com.sun.star.comp.framework.Desktop";
diff --git a/l10ntools/source/common.cxx b/l10ntools/source/common.cxx
index 92dc802aa872..84adb767c7ba 100644
--- a/l10ntools/source/common.cxx
+++ b/l10ntools/source/common.cxx
@@ -9,11 +9,15 @@
 
 #include <common.hxx>
 
+namespace {
+
 //flags for handleArguments()
 enum class State {
     NONE, Input, Output, MergeSrc, Languages
 };
 
+}
+
 namespace common {
 
 bool handleArguments(
diff --git a/linguistic/source/misc2.cxx b/linguistic/source/misc2.cxx
index 664812f4b279..6e48fc7aa52c 100644
--- a/linguistic/source/misc2.cxx
+++ b/linguistic/source/misc2.cxx
@@ -30,6 +30,8 @@
 
 using namespace com::sun::star;
 
+namespace {
+
 /// Flags to be used with the multi-path related functions
 /// @see GetDictionaryPaths
 enum class DictionaryPathFlags
@@ -38,6 +40,9 @@ enum class DictionaryPathFlags
     INTERNAL  = 0x01,
     USER      = 0x02,
 };
+
+}
+
 namespace o3tl
 {
     template<> struct typed_flags<DictionaryPathFlags> : is_typed_flags<DictionaryPathFlags, 0x03> {};
diff --git a/o3tl/qa/test-typed_flags.cxx b/o3tl/qa/test-typed_flags.cxx
index e9c7bb6b7d2c..ef6e4faaedce 100644
--- a/o3tl/qa/test-typed_flags.cxx
+++ b/o3tl/qa/test-typed_flags.cxx
@@ -15,9 +15,12 @@
 
 using namespace ::o3tl;
 
+namespace {
 
 enum class ConfigurationChangedHint { NONE, ONE, TWO };
 
+}
+
 namespace o3tl
 {
     template<> struct typed_flags< ConfigurationChangedHint> : is_typed_flags< ConfigurationChangedHint, 0xFF> {};
diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx
index b7acbe084a5c..fced97e765fe 100644
--- a/oox/source/core/filterbase.cxx
+++ b/oox/source/core/filterbase.cxx
@@ -111,8 +111,6 @@ DocumentOpenedGuard::~DocumentOpenedGuard()
         rUrlPool.maUrls.erase( maUrl );
 }
 
-} // namespace
-
 /** Specifies whether this filter is an import or export filter. */
 enum FilterDirection
 {
@@ -121,6 +119,8 @@ enum FilterDirection
     FILTERDIRECTION_EXPORT
 };
 
+} // namespace
+
 struct FilterBaseImpl
 {
     typedef std::shared_ptr< GraphicHelper >        GraphicHelperRef;
diff --git a/oox/source/drawingml/customshapegeometry.cxx b/oox/source/drawingml/customshapegeometry.cxx
index 5991b0a60322..20db50d0d865 100644
--- a/oox/source/drawingml/customshapegeometry.cxx
+++ b/oox/source/drawingml/customshapegeometry.cxx
@@ -39,6 +39,8 @@ using namespace ::com::sun::star::xml::sax;
 
 namespace oox { namespace drawingml {
 
+namespace {
+
 enum FormularCommand
 {
     FC_MULDIV = 0,
@@ -60,6 +62,9 @@ enum FormularCommand
     FC_TAN,
     FC_VAL
 };
+
+}
+
 struct FormularCommandNameTable
 {
     const char*     pS;
diff --git a/sal/osl/unx/profile.cxx b/sal/osl/unx/profile.cxx
index 44e7243c4b13..ad8868b5490c 100644
--- a/sal/osl/unx/profile.cxx
+++ b/sal/osl/unx/profile.cxx
@@ -51,11 +51,15 @@
 
 typedef time_t  osl_TStamp;
 
+namespace {
+
 enum osl_TLockMode
 {
     un_lock, read_lock, write_lock
 };
 
+}
+
 struct osl_TFile
 {
     int     m_Handle;
diff --git a/sal/qa/osl/condition/osl_Condition.cxx b/sal/qa/osl/condition/osl_Condition.cxx
index e2c50fb309e6..0d3cba799583 100644
--- a/sal/qa/osl/condition/osl_Condition.cxx
+++ b/sal/qa/osl/condition/osl_Condition.cxx
@@ -22,6 +22,8 @@
 
 using namespace osl;
 
+namespace {
+
 enum ConditionType
 {
     thread_type_set,
@@ -29,6 +31,8 @@ enum ConditionType
     thread_type_wait
 };
 
+}
+
 /** thread for testing Condition.
  */
 class ConditionThread : public Thread
diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx
index 6b17d07098c6..54c0e01b90ff 100644
--- a/sal/qa/osl/file/osl_File.cxx
+++ b/sal/qa/osl/file/osl_File.cxx
@@ -277,6 +277,8 @@ static void deleteTestDirectory(const OUString& basename, const OUString& dirnam
     deleteTestDirectory(aBaseURL);
 }
 
+namespace {
+
 /** Check for the file and directory access right.
 */
 enum class oslCheckMode {
@@ -285,6 +287,8 @@ enum class oslCheckMode {
     WriteAccess
 };
 
+}
+
 /** check if the file exist
 */
 static bool ifFileExist(const OUString & str)
diff --git a/sal/rtl/ustring.cxx b/sal/rtl/ustring.cxx
index dafccb4d7d28..f60fdc95aefc 100644
--- a/sal/rtl/ustring.cxx
+++ b/sal/rtl/ustring.cxx
@@ -890,11 +890,15 @@ void SAL_CALL rtl_string2UString( rtl_uString** ppThis,
 
 /* ----------------------------------------------------------------------- */
 
+namespace {
+
 enum StrLifecycle {
     CANNOT_RETURN,
     CAN_RETURN = 1
 };
 
+}
+
 static oslMutex
 getInternMutex()
 {
diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index a0790ce0e114..b94e1f9fe597 100644
--- a/sax/source/tools/converter.cxx
+++ b/sax/source/tools/converter.cxx
@@ -944,8 +944,12 @@ void Converter::convertDuration(OUStringBuffer& rBuffer,
     }
 }
 
+namespace {
+
 enum Result { R_NOTHING, R_OVERFLOW, R_SUCCESS };
 
+}
+
 static Result
 readUnsignedNumber(const OUString & rString,
     sal_Int32 & io_rnPos, sal_Int32 & o_rNumber)
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index ad0cf0358223..4a9bec3be0b1 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -7645,6 +7645,8 @@ void OpHypGeomDist::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "}\n";
 }
 
+namespace {
+
 enum MixDoubleString
 {
     svDoubleVectorRefDoubleString,
@@ -7658,6 +7660,8 @@ enum MixDoubleString
     svDoubleDouble
 };
 
+}
+
 void OpMinA::GenSlidingWindowFunction(
     std::stringstream &ss, const std::string &sSymName, SubArguments &vSubArguments)
 {
diff --git a/sc/source/core/tool/cellkeytranslator.cxx b/sc/source/core/tool/cellkeytranslator.cxx
index 5999204b83bb..5ad71ca4c833 100644
--- a/sc/source/core/tool/cellkeytranslator.cxx
+++ b/sc/source/core/tool/cellkeytranslator.cxx
@@ -32,6 +32,8 @@ using ::com::sun::star::uno::Sequence;
 
 using namespace ::com::sun::star;
 
+namespace {
+
 enum LocaleMatch
 {
     LOCALE_MATCH_NONE = 0,
@@ -41,6 +43,8 @@ enum LocaleMatch
     LOCALE_MATCH_ALL
 };
 
+}
+
 static LocaleMatch lclLocaleCompare(const lang::Locale& rLocale1, const LanguageTag& rLanguageTag2)
 {
     LocaleMatch eMatchLevel = LOCALE_MATCH_NONE;
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index f0c755fa1b8c..ac0390d4ee56 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -81,6 +81,8 @@ using ::std::vector;
 CharClass*                          ScCompiler::pCharClassEnglish = nullptr;
 const ScCompiler::Convention*       ScCompiler::pConventions[ ]   = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
 
+namespace {
+
 enum ScanState
 {
     ssGetChar,
@@ -97,6 +99,8 @@ enum ScanState
     ssStop
 };
 
+}
+
 static const sal_Char* pInternal[2] = { "TTT", "__DEBUG_VAR" };
 
 using namespace ::com::sun::star::i18n;
diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx
index 740a4af583fd..3ea84ef59bbf 100644
--- a/sc/source/core/tool/detfunc.cxx
+++ b/sc/source/core/tool/detfunc.cxx
@@ -81,12 +81,16 @@ using namespace com::sun::star;
 // The checkForUniqueItem method then finds a unique name for the item's value.
 #define SC_LINEEND_NAME     EMPTY_OUSTRING
 
+namespace {
+
 enum DetInsertResult {              // return-values for inserting in one level
             DET_INS_CONTINUE,
             DET_INS_INSERTED,
             DET_INS_EMPTY,
             DET_INS_CIRCULAR };
 
+}
+
 class ScDetectiveData
 {
 private:
diff --git a/sc/source/filter/oox/formulabase.cxx b/sc/source/filter/oox/formulabase.cxx
index 2e49ffd94447..9af3ad97048a 100644
--- a/sc/source/filter/oox/formulabase.cxx
+++ b/sc/source/filter/oox/formulabase.cxx
@@ -43,6 +43,8 @@
 #include <oox/token/properties.hxx>
 #include <o3tl/typed_flags_set.hxx>
 
+namespace {
+
 enum class FuncFlags : sal_uInt16 {
     NONE              = 0x0000,
     VOLATILE          = 0x0001,   /// Result is volatile (e.g. NOW() function).
@@ -64,6 +66,9 @@ enum class FuncFlags : sal_uInt16 {
     INTERNAL          = 0x2000,   /// Function is internal in Calc.
     EUROTOOL          = 0x4000,   /// function of euro tool lib, FUNCLIB_EUROTOOL
 };
+
+}
+
 namespace o3tl {
     template<> struct typed_flags<FuncFlags> : is_typed_flags<FuncFlags, 0x77ff> {};
 }
diff --git a/sc/source/filter/oox/pagesettings.cxx b/sc/source/filter/oox/pagesettings.cxx
index f52d4f638d74..14e4f9baaf82 100644
--- a/sc/source/filter/oox/pagesettings.cxx
+++ b/sc/source/filter/oox/pagesettings.cxx
@@ -343,6 +343,8 @@ void PageSettings::importPictureData( const Relations& rRelations, const OUStrin
     }
 }
 
+namespace {
+
 enum HFPortionId
 {
     HF_LEFT,
@@ -351,6 +353,8 @@ enum HFPortionId
     HF_COUNT
 };
 
+}
+
 struct HFPortionInfo
 {
     Reference<text::XText>  mxText;                 /// XText interface of this portion.
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 7d5695a63b9f..dae95abdd797 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -88,6 +88,8 @@ using com::sun::star::uno::UNO_QUERY;
 using com::sun::star::frame::XLayoutManager;
 using com::sun::star::beans::XPropertySet;
 
+namespace {
+
 enum ScNameInputType
 {
     SC_NAME_INPUT_CELL,
@@ -102,6 +104,8 @@ enum ScNameInputType
     SC_MANAGE_NAMES
 };
 
+}
+
 ScTextWndBase::ScTextWndBase( vcl::Window* pParent,  WinBits nStyle )
     : Window ( pParent, nStyle )
 {
diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx
index 75d915438f44..2cc37704d7ac 100644
--- a/sc/source/ui/dbgui/scuiasciiopt.cxx
+++ b/sc/source/ui/dbgui/scuiasciiopt.cxx
@@ -42,6 +42,8 @@ const SCSIZE ASCIIDLG_MAXROWS                = MAXROWCOUNT;
 
 using namespace com::sun::star::uno;
 
+namespace {
+
 // Defines - CSV Import Preserve Options
 enum CSVImportOptionsIndex
 {
@@ -59,6 +61,8 @@ enum CSVImportOptionsIndex
     CSVIO_PasteSkipEmptyCells
 };
 
+}
+
 const ::std::vector<OUString> CSVImportOptionNames =
 {
     "MergeDelimiters",
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 7015c16a8fdc..317fc2e0d642 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -85,6 +85,8 @@ namespace
     }
 }
 
+namespace {
+
 enum class SylkVersion
 {
     SCALC3,    // Wrote wrongly quoted strings and unescaped semicolons.
@@ -93,6 +95,8 @@ enum class SylkVersion
     OTHER      // Assume that aliens wrote correct strings.
 };
 
+}
+
 // Whole document without Undo
 ScImportExport::ScImportExport( ScDocument* p )
     : pDocSh( dynamic_cast< ScDocShell* >(p->GetDocumentShell()) ), pDoc( p ),
@@ -544,6 +548,8 @@ void ScImportExport::SetNoEndianSwap( SvStream& rStrm )
 #endif
 }
 
+namespace {
+
 enum QuoteType
 {
     FIELDSTART_QUOTE,
@@ -553,6 +559,8 @@ enum QuoteType
     DONTKNOW_QUOTE
 };
 
+}
+
 /** Determine if *p is a quote that ends a quoted field.
 
     Precondition: we are parsing a quoted field already and *p is a quote.
@@ -638,12 +646,16 @@ static bool lcl_appendLineData( OUString& rField, const sal_Unicode* p1, const s
     }
 }
 
+namespace {
+
 enum class DoubledQuoteMode
 {
     KEEP_ALL,   // both are taken, additionally start and end quote are included in string
     ESCAPE,     // escaped quote, one is taken, one ignored
 };
 
+}
+
 static const sal_Unicode* lcl_ScanString( const sal_Unicode* p, OUString& rString,
             const sal_Unicode* pSeps, sal_Unicode cStr, DoubledQuoteMode eMode, bool& rbOverflowCell )
 {
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index 61948b461c4f..4e6b6332be89 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -147,6 +147,8 @@ sal_Int16 lcl_SvxToUnoFileFormat( SvxFileFormat nSvxValue )
 SC_SIMPLE_SERVICE_INFO( ScCellFieldsObj, "ScCellFieldsObj", "com.sun.star.text.TextFields" )
 SC_SIMPLE_SERVICE_INFO( ScHeaderFieldsObj, "ScHeaderFieldsObj", "com.sun.star.text.TextFields" )
 
+namespace {
+
 enum ScUnoCollectMode
 {
     SC_UNO_COLLECT_NONE,
@@ -155,6 +157,8 @@ enum ScUnoCollectMode
     SC_UNO_COLLECT_FINDPOS
 };
 
+}
+
 /**
  * This class exists solely to allow searching through field items.  TODO:
  * Look into providing the same functionality directly in EditEngine, to
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 17c1bc503600..725937aac476 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -140,12 +140,16 @@
 using namespace css;
 using namespace css::uno;
 
+namespace {
+
 enum class ScFilterBoxMode
 {
     DataSelect,
     Scenario
 };
 
+}
+
 struct ScGridWindow::MouseEventState
 {
     bool mbActivatePart;
diff --git a/sc/source/ui/view/prevloc.cxx b/sc/source/ui/view/prevloc.cxx
index 030f3c7d6436..2c00bf260cd1 100644
--- a/sc/source/ui/view/prevloc.cxx
+++ b/sc/source/ui/view/prevloc.cxx
@@ -23,6 +23,8 @@
 #include <osl/diagnose.h>
 #include <vcl/outdev.hxx>
 
+namespace {
+
 enum ScPreviewLocationType
 {
     SC_PLOC_CELLRANGE,
@@ -36,6 +38,8 @@ enum ScPreviewLocationType
     SC_PLOC_NOTETEXT
 };
 
+}
+
 struct ScPreviewLocationEntry
 {
     ScPreviewLocationType const   eType;
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 0ab2d088b0e7..1f6a66ab8db2 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -229,6 +229,8 @@ bool ScViewFunc::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow )
     return bChanged;
 }
 
+namespace {
+
 enum ScAutoSum
 {
     ScAutoSumNone = 0,
@@ -240,6 +242,8 @@ enum ScAutoSum
     ScAutoSumCount
 };
 
+}
+
 static ScAutoSum lcl_IsAutoSumData( ScDocument* pDoc, SCCOL nCol, SCROW nRow,
         SCTAB nTab, ScDirection eDir, SCCOLROW& nExtend )
 {
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx
index 8a7db7302ff0..9ef75df597ad 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -133,6 +133,8 @@ void WriteSndAc(const FSHelperPtr& pFS, const OUString& sSoundRelId, const OUStr
 }
 }
 
+namespace {
+
 enum PPTXLayout
 {
     LAYOUT_BLANK,
@@ -150,6 +152,8 @@ enum PPTXLayout
     LAYOUT_SIZE
 };
 
+}
+
 struct PPTXLayoutInfo
 {
     int const nType;
diff --git a/sd/source/ui/sidebar/SlideBackground.cxx b/sd/source/ui/sidebar/SlideBackground.cxx
index 98e57e7d594e..873bbd46759e 100644
--- a/sd/source/ui/sidebar/SlideBackground.cxx
+++ b/sd/source/ui/sidebar/SlideBackground.cxx
@@ -67,6 +67,8 @@ using ::com::sun::star::uno::Reference;
 
 namespace sd { namespace sidebar {
 
+namespace {
+
 enum eFillStyle
 {
     NONE,
@@ -77,6 +79,8 @@ enum eFillStyle
     PATTERN
 };
 
+}
+
 SlideBackground::SlideBackground(
     Window * pParent,
     ViewShellBase& rBase,
diff --git a/sd/source/ui/unoidl/UnoDocumentSettings.cxx b/sd/source/ui/unoidl/UnoDocumentSettings.cxx
index b765dc59a0dc..701c5462bae6 100644
--- a/sd/source/ui/unoidl/UnoDocumentSettings.cxx
+++ b/sd/source/ui/unoidl/UnoDocumentSettings.cxx
@@ -128,6 +128,8 @@ namespace sd
         return static_cast<XWeak*>(new DocumentSettings( pModel ));
     }
 
+namespace {
+
 enum SdDocumentSettingsPropertyHandles
 {
     HANDLE_PRINTDRAWING, HANDLE_PRINTNOTES, HANDLE_PRINTHANDOUT, HANDLE_PRINTOUTLINE, HANDLE_MEASUREUNIT, HANDLE_SCALE_NUM,
@@ -144,6 +146,8 @@ enum SdDocumentSettingsPropertyHandles
     HANDLE_EMBED_LATIN_SCRIPT_FONTS, HANDLE_EMBED_ASIAN_SCRIPT_FONTS, HANDLE_EMBED_COMPLEX_SCRIPT_FONTS,
 };
 
+}
+
 #define MID_PRINTER 1
 
     static rtl::Reference<PropertySetInfo> createSettingsInfoImpl( bool bIsDraw )
diff --git a/sd/source/ui/unoidl/facreg.cxx b/sd/source/ui/unoidl/facreg.cxx
index dc93ddb06810..9314a60b4fe2 100644
--- a/sd/source/ui/unoidl/facreg.cxx
+++ b/sd/source/ui/unoidl/facreg.cxx
@@ -33,11 +33,16 @@ using namespace com::sun::star;
 // Declaration and initialization of a map from service names to locally
 // unique factory identifiers.
 
+namespace {
+
 enum FactoryId
 {
     SdDrawingDocumentFactoryId,
     SdPresentationDocumentFactoryId,
 };
+
+}
+
 typedef std::unordered_map<OUString, FactoryId> FactoryMap;
 
 namespace {
diff --git a/sd/source/ui/unoidl/unoobj.cxx b/sd/source/ui/unoidl/unoobj.cxx
index 9bcc2126eedf..ae275dd57e82 100644
--- a/sd/source/ui/unoidl/unoobj.cxx
+++ b/sd/source/ui/unoidl/unoobj.cxx
@@ -1080,6 +1080,8 @@ SdUnoEventsAccess::SdUnoEventsAccess( SdXShape* pShape ) throw()
 {
 }
 
+namespace {
+
 enum class FoundFlags {
     NONE          = 0x0000,
     ClickAction   = 0x0001,
@@ -1093,6 +1095,9 @@ enum class FoundFlags {
     Macro         = 0x0100,
     Library       = 0x0200,
 };
+
+}
+
 namespace o3tl {
     template<> struct typed_flags<FoundFlags> : is_typed_flags<FoundFlags, 0x03ff> {};
 }
diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx
index 244c27bce6a4..55340b4b91d5 100644
--- a/sd/source/ui/unoidl/unopage.cxx
+++ b/sd/source/ui/unoidl/unopage.cxx
@@ -78,6 +78,8 @@ using namespace ::com::sun::star::container;
 using namespace ::com::sun::star::drawing;
 using namespace ::com::sun::star::office;
 
+namespace {
+
 // this are the ids for page properties
 enum WID_PAGE
 {
@@ -93,6 +95,8 @@ enum WID_PAGE
     WID_NAVORDER, WID_PAGE_PREVIEWMETAFILE
 };
 
+}
+
 static sal_Char const sEmptyPageName[sizeof("page")] = "page";
 
 // this function stores the property maps for draw pages in impress and draw
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index f8e1b2821b6b..496ea66b497f 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -82,6 +82,8 @@ using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::util;
 
+namespace {
+
 enum URLTypeId
 {
     URLType_BOOL,
@@ -95,6 +97,8 @@ enum URLTypeId
     URLType_COUNT
 };
 
+}
+
 const char* const URLTypeNames[URLType_COUNT] =
 {
     "bool",
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index e5fad08ec881..c5a350afa608 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -815,7 +815,12 @@ static bool lcl_isSystemFilePicker( const uno::Reference< XFilePicker3 >& _rxFP
     return false;
 }
 
+namespace {
+
 enum open_or_save_t {OPEN, SAVE, UNDEFINED};
+
+}
+
 static open_or_save_t lcl_OpenOrSave(sal_Int16 const nDialogType)
 {
     switch (nDialogType)
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index a0598191f3f7..1c7638349b79 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -298,6 +298,7 @@ static OUString impl_retrieveFilterNameFromTypeAndModule(
     return aFoundFilterName;
 }
 
+namespace {
 
 /** search for an internal typename, which map to the current app module
     and map also to a "family" of file formats as e.g. PDF/MS Doc/OOo Doc.
@@ -308,6 +309,8 @@ enum ETypeFamily
     E_OOO_DOC
 };
 
+}
+
 static OUString impl_searchFormatTypeForApp(const css::uno::Reference< css::frame::XFrame >& xFrame     ,
                                                   ETypeFamily                                eTypeFamily)
 {
diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx
index ad21f46a002c..b00e5878038d 100644
--- a/starmath/source/unomodel.cxx
+++ b/starmath/source/unomodel.cxx
@@ -154,6 +154,8 @@ SmPrintUIOptions::SmPrintUIOptions()
 
 // class SmModel
 
+namespace {
+
 enum SmModelPropertyHandles
 {
     HANDLE_FORMULA,
@@ -225,6 +227,8 @@ enum SmModelPropertyHandles
     HANDLE_INTEROP_GRAB_BAG,
 };
 
+}
+
 static rtl::Reference<PropertySetInfo> lcl_createModelPropertyInfo ()
 {
     static PropertyMapEntry aModelPropertyInfoMap[] =
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index cd889ce4d9d6..e56a5cef8502 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -182,6 +182,7 @@ double ImpSvNumberInputScan::StringToDouble( const OUString& rStr, bool bForceFr
     return fNum;
 }
 
+namespace {
 
 /**
  * Splits up the input into numbers and strings for further processing
@@ -209,6 +210,8 @@ enum ScanState  // States of the Turing machine
     SsGetString = 3
 };
 
+}
+
 bool ImpSvNumberInputScan::NextNumberStringSymbol( const sal_Unicode*& pStr,
                                                    OUString& rSymbol )
 {
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index ce04f095c68f..0ba7c9b02f73 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -348,6 +348,8 @@ bool ImpSvNumFor::GetNewCurrencySymbol( OUString& rSymbol,
  * SvNumberformat
  */
 
+namespace {
+
 enum BracketFormatSymbolType
 {
     BRACKET_SYMBOLTYPE_FORMAT   = -1,   // subformat string
@@ -385,6 +387,8 @@ enum BracketFormatSymbolType
     BRACKET_SYMBOLTYPE_NATNUM19 = -33
 };
 
+}
+
 void SvNumberformat::ImpCopyNumberformat( const SvNumberformat& rFormat )
 {
     sFormatstring = rFormat.sFormatstring;
@@ -1408,6 +1412,8 @@ SvNumberformat::~SvNumberformat()
  * ---------------+-------------------+----------------------------+---------------
  */
 
+namespace {
+
 enum ScanState
 {
     SsStop,
@@ -1420,6 +1426,8 @@ enum ScanState
     SsGetQuoted         // quoted text
 };
 
+}
+
 // read a string until ']' and delete spaces in input
 // static
 sal_Int32 SvNumberformat::ImpGetNumber(OUStringBuffer& rString,
diff --git a/svl/source/numbers/zforscan.cxx b/svl/source/numbers/zforscan.cxx
index 04e86ea2ca5b..1216ae6756a7 100644
--- a/svl/source/numbers/zforscan.cxx
+++ b/svl/source/numbers/zforscan.cxx
@@ -757,6 +757,8 @@ short ImpSvNumberformatScan::GetKeyWord( const OUString& sSymbol, sal_Int32 nPos
  * we write back the rest of the characters!
  */
 
+namespace {
+
 enum ScanState
 {
     SsStop      = 0,
@@ -768,6 +770,8 @@ enum ScanState
     SsGetBlank  = 6
 };
 
+}
+
 short ImpSvNumberformatScan::Next_Symbol( const OUString& rStr,
                                           sal_Int32& nPos,
                                           OUString& sSymbol ) const
diff --git a/svtools/source/config/helpopt.cxx b/svtools/source/config/helpopt.cxx
index 07834d8bf76c..1137caaef436 100644
--- a/svtools/source/config/helpopt.cxx
+++ b/svtools/source/config/helpopt.cxx
@@ -38,7 +38,6 @@ using namespace com::sun::star;
 namespace {
     //global
     std::weak_ptr<SvtHelpOptions_Impl> g_pHelpOptions;
-}
 
 enum class HelpProperty
 {
@@ -50,6 +49,8 @@ enum class HelpProperty
     OfflineHelpPopUp = 5
 };
 
+}
+
 class SvtHelpOptions_Impl : public utl::ConfigItem
 {
     bool            bExtendedHelp;
diff --git a/svtools/source/config/htmlcfg.cxx b/svtools/source/config/htmlcfg.cxx
index ed8fbfe49f96..fbd7f57e282f 100644
--- a/svtools/source/config/htmlcfg.cxx
+++ b/svtools/source/config/htmlcfg.cxx
@@ -29,6 +29,8 @@
 #include <o3tl/typed_flags_set.hxx>
 #include <com/sun/star/uno/Sequence.hxx>
 
+namespace {
+
 enum class HtmlCfgFlags {
     NONE                  = 0x000,
     UnknownTags           = 0x001,
@@ -39,6 +41,9 @@ enum class HtmlCfgFlags {
     IsBasicWarning        = 0x080,
     NumbersEnglishUS      = 0x100,
 };
+
+}
+
 namespace o3tl {
     template<> struct typed_flags<HtmlCfgFlags> : is_typed_flags<HtmlCfgFlags, 0x1f9> {};
 }
diff --git a/svtools/source/control/ctrltool.cxx b/svtools/source/control/ctrltool.cxx
index 2ba347bf73d9..957e153e916a 100644
--- a/svtools/source/control/ctrltool.cxx
+++ b/svtools/source/control/ctrltool.cxx
@@ -89,12 +89,17 @@ public:
     OutputDevice*           GetDevice() const { return mpDevice; }
 };
 
+namespace {
+
 enum class FontListFontNameType
 {
     NONE              = 0x00,
     PRINTER           = 0x01,
     SCREEN            = 0x02,
 };
+
+}
+
 namespace o3tl
 {
     template<> struct typed_flags<FontListFontNameType> : is_typed_flags<FontListFontNameType, 0x3> {};
diff --git a/svtools/source/svhtml/parhtml.cxx b/svtools/source/svhtml/parhtml.cxx
index 6ce236566e61..523ed4fb28e4 100644
--- a/svtools/source/svhtml/parhtml.cxx
+++ b/svtools/source/svhtml/parhtml.cxx
@@ -1894,6 +1894,8 @@ bool HTMLParser::InternalImgToPrivateURL( OUString& rURL )
     return bFound;
 }
 
+namespace {
+
 enum class HtmlMeta {
     NONE = 0,
     Author,
@@ -1910,6 +1912,8 @@ enum class HtmlMeta {
     ContentType
 };
 
+}
+
 // <META NAME=xxx>
 static HTMLOptionEnum<HtmlMeta> const aHTMLMetaNameTable[] =
 {
diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx
index ebbe12f2b96f..a96e8d984a5d 100644
--- a/svx/source/fmcomp/fmgridcl.cxx
+++ b/svx/source/fmcomp/fmgridcl.cxx
@@ -777,8 +777,12 @@ void FmGridHeader::PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMe
     }
 }
 
+namespace {
+
 enum InspectorAction { eOpenInspector, eCloseInspector, eUpdateInspector, eNone };
 
+}
+
 void FmGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMenu& rMenu, sal_uInt16 nExecutionResult)
 {
     Reference< css::container::XIndexContainer >  xCols(static_cast<FmGridControl*>(GetParent())->GetPeer()->getColumns());
diff --git a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
index a4388ce61232..d83a9a08ae66 100644
--- a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
+++ b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
@@ -45,6 +45,8 @@ const char UNO_SIDEBARGRADIENT[] = ".uno:sidebargradient";
 
 namespace svx { namespace sidebar {
 
+namespace {
+
 enum eFillStyle
 {
     NONE,
@@ -55,6 +57,8 @@ enum eFillStyle
     PATTERN
 };
 
+}
+
 const sal_Int32 AreaPropertyPanelBase::DEFAULT_CENTERX = 50;
 const sal_Int32 AreaPropertyPanelBase::DEFAULT_CENTERY = 50;
 const sal_Int32 AreaPropertyPanelBase::DEFAULT_ANGLE = 0;
diff --git a/svx/source/svdraw/svdibrow.cxx b/svx/source/svdraw/svdibrow.cxx
index a19219d6f7cb..a08d358530a5 100644
--- a/svx/source/svdraw/svdibrow.cxx
+++ b/svx/source/svdraw/svdibrow.cxx
@@ -74,6 +74,8 @@ using namespace com::sun::star;
 
 #define ITEM_NOT_FOUND std::numeric_limits<std::size_t>::max()
 
+namespace {
+
 enum class ItemType {
     DONTKNOW, BYTE, INT16, UINT16, INT32, UINT32,
     ENUM, BOOL, FLAG, STRING, POINT, RECT, RANGE,
@@ -83,6 +85,7 @@ enum class ItemType {
     FONT, FONTHEIGHT, FONTWIDTH, FIELD
 };
 
+}
 
 class ImpItemListRow
 {
diff --git a/svx/source/svdraw/svdocapt.cxx b/svx/source/svdraw/svdocapt.cxx
index b4714c9e9ee5..ea96430322c0 100644
--- a/svx/source/svdraw/svdocapt.cxx
+++ b/svx/source/svdraw/svdocapt.cxx
@@ -63,9 +63,12 @@
 #include <vcl/canvastools.hxx>
 #include <vcl/ptrstyle.hxx>
 
+namespace {
 
 enum EscDir {LKS,RTS,OBN,UNT};
 
+}
+
 class ImpCaptParams
 {
 public:
diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
index ffd6ca9f1e90..d4c5ab1ad43b 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -88,6 +88,8 @@ using namespace ::com::sun::star::container;
 using namespace ::com::sun::star::text;
 using namespace ::com::sun::star::style;
 
+namespace {
+
 enum class CellPosFlag  // signals the relative position of a cell to a selection
 {
     NONE   = 0x0000, // not set or inside
@@ -102,6 +104,9 @@ enum class CellPosFlag  // signals the relative position of a cell to a selectio
     Bottom = 0x0040,
     Lower  = 0x0080
 };
+
+}
+
 namespace o3tl
 { template<> struct typed_flags<CellPosFlag> : is_typed_flags<CellPosFlag, 0xff> {}; }
 
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 1b8d6fe09092..782dd2cc16cb 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -2427,6 +2427,8 @@ void SvxFrameWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt )
     }
 }
 
+namespace {
+
 enum class FrmValidFlags {
     NONE      = 0x00,
     Left      = 0x01,
@@ -2437,6 +2439,9 @@ enum class FrmValidFlags {
     VInner    = 0x20,
     AllMask   = 0x3f,
 };
+
+}
+
 namespace o3tl {
     template<> struct typed_flags<FrmValidFlags> : is_typed_flags<FrmValidFlags, 0x3f> {};
 }
diff --git a/svx/source/xml/xmlxtimp.cxx b/svx/source/xml/xmlxtimp.cxx
index c9b5ecf6481a..4fbed121ddc5 100644
--- a/svx/source/xml/xmlxtimp.cxx
+++ b/svx/source/xml/xmlxtimp.cxx
@@ -66,8 +66,11 @@ using namespace com::sun::star::xml::sax;
 using namespace ::xmloff::token;
 using namespace cppu;
 
+namespace {
+
 enum class SvxXMLTableImportContextEnum { Color, Marker, Dash, Hatch, Gradient, Bitmap };
 
+}
 
 class SvxXMLTableImportContext : public SvXMLImportContext
 {
diff --git a/sw/source/core/access/acccontext.cxx b/sw/source/core/access/acccontext.cxx
index d1436b3f0c1d..d3bb318584b5 100644
--- a/sw/source/core/access/acccontext.cxx
+++ b/sw/source/core/access/acccontext.cxx
@@ -113,9 +113,13 @@ const SwCursorShell* SwAccessibleContext::GetCursorShell() const
     return dynamic_cast<const SwCursorShell*>( pViewShell);
 }
 
+namespace {
+
 enum class Action { NONE, SCROLLED, SCROLLED_WITHIN,
                           SCROLLED_IN, SCROLLED_OUT };
 
+}
+
 void SwAccessibleContext::ChildrenScrolled( const SwFrame *pFrame,
                                             const SwRect& rOldVisArea )
 {
diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx
index 437864f6df56..afc89c8bee0c 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -191,8 +191,12 @@ std::ostream &operator <<(std::ostream& s, const SwPosition& position)
     return s << "SwPosition (node " << position.nNode.GetIndex() << ", offset " << position.nContent.GetIndex() << ")";
 }
 
+namespace {
+
 enum CHKSECTION { Chk_Both, Chk_One, Chk_None };
 
+}
+
 static CHKSECTION lcl_TstIdx( sal_uLong nSttIdx, sal_uLong nEndIdx, const SwNode& rEndNd )
 {
     sal_uLong nStt = rEndNd.StartOfSectionIndex(), nEnd = rEndNd.GetIndex();
diff --git a/sw/source/core/doc/docglbl.cxx b/sw/source/core/doc/docglbl.cxx
index f467449d5c0f..3a226356bb7b 100644
--- a/sw/source/core/doc/docglbl.cxx
+++ b/sw/source/core/doc/docglbl.cxx
@@ -51,12 +51,16 @@
 
 using namespace ::com::sun::star;
 
+namespace {
+
 enum SwSplitDocType
 {
     SPLITDOC_TO_GLOBALDOC,
     SPLITDOC_TO_HTML
 };
 
+}
+
 bool SwDoc::GenerateGlobalDoc( const OUString& rPath,
                                    const SwTextFormatColl* pSplitColl )
 {
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index eeb6fd480fce..5e69b24d94c1 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -129,6 +129,8 @@ using std::make_pair;
 
 struct SwPaintProperties;
 
+namespace {
+
 //Class declaration; here because they are only used in this file
 enum class SubColFlags {
     Page     = 0x01,    //Helplines of the page
@@ -136,6 +138,9 @@ enum class SubColFlags {
     Fly      = 0x10,    //Helplines inside fly frames
     Sect     = 0x20,    //Helplines inside sections
 };
+
+}
+
 namespace o3tl {
     template<> struct typed_flags<SubColFlags> : is_typed_flags<SubColFlags, 0x39> {};
 }
@@ -5698,7 +5703,12 @@ bool SwPageFrame::IsLeftShadowNeeded() const
     }
 }
 
+namespace {
+
 enum PaintArea {LEFT, RIGHT, TOP, BOTTOM};
+
+}
+
 #define BORDER_TILE_SIZE 512
 
 /// Wrapper around pOut->DrawBitmapEx.
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index 1e4009a50f64..0005d65e276a 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -181,7 +181,12 @@ bool isSplittable(const sal_uInt16 nWhich)
     return false;
 }
 
+namespace {
+
 enum Split_t { FAIL, SPLIT_NEW, SPLIT_OTHER };
+
+}
+
 /**
   Calculate splitting policy for overlapping hints, based on what kind of
   hint is inserted, and what kind of existing hint overlaps.
diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx
index dc47a6d5dac2..74b70cdf42e7 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -789,8 +789,12 @@ void SwXTextCursor::DeleteAndInsert(const OUString& rText,
     }
 }
 
+namespace {
+
 enum ForceIntoMetaMode { META_CHECK_BOTH, META_INIT_START, META_INIT_END };
 
+}
+
 static bool
 lcl_ForceIntoMeta(SwPaM & rCursor,
         uno::Reference<text::XText> const & xParentText,
diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx
index 62b0071e13c3..909ec61ba98c 100644
--- a/sw/source/filter/html/css1atr.cxx
+++ b/sw/source/filter/html/css1atr.cxx
@@ -99,6 +99,8 @@ using editeng::SvxBorderLine;
 
 #define HTML_HEADSPACE (12*20)
 
+namespace {
+
 enum class Css1Background {
     Attr    = 1,
     Page    = 2,
@@ -115,6 +117,9 @@ enum class Css1FrameSize {
     AnyHeight  = 0x06,
     Pixel      = 0x10,
 };
+
+}
+
 namespace o3tl {
     template<> struct typed_flags<Css1FrameSize> : is_typed_flags<Css1FrameSize, 0x17> {};
 }
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
index c54d31149d50..67ca2a1b4aec 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -1057,6 +1057,8 @@ HTMLStartEndPos::HTMLStartEndPos( const SfxPoolItem& rItem, sal_Int32 nStt,
 
 typedef std::vector<HTMLStartEndPos *> HTMLStartEndPositions;
 
+namespace {
+
 enum HTMLOnOffState { HTML_NOT_SUPPORTED,   // unsupported Attribute
                       HTML_REAL_VALUE,      // Attribute with value
                       HTML_ON_VALUE,        // Attribute is On-Tag
@@ -1067,6 +1069,8 @@ enum HTMLOnOffState { HTML_NOT_SUPPORTED,   // unsupported Attribute
                       HTML_DROPCAP_VALUE,   // DropCap-Attribute
                       HTML_AUTOFMT_VALUE }; // Attribute for automatic character styles
 
+}
+
 class HTMLEndPosLst
 {
     HTMLStartEndPositions aStartLst;  // list, sorted for start positions
diff --git a/sw/source/filter/html/htmlform.cxx b/sw/source/filter/html/htmlform.cxx
index c58a8e4620a5..13f33ac57839 100644
--- a/sw/source/filter/html/htmlform.cxx
+++ b/sw/source/filter/html/htmlform.cxx
@@ -103,8 +103,12 @@ static HTMLOptionEnum<FormSubmitEncoding> const aHTMLFormEncTypeTable[] =
     { nullptr,                              FormSubmitEncoding(0)           }
 };
 
+namespace {
+
 enum HTMLWordWrapMode { HTML_WM_OFF, HTML_WM_HARD, HTML_WM_SOFT };
 
+}
+
 static HTMLOptionEnum<HTMLWordWrapMode> const aHTMLTextAreaWrapTable[] =
 {
     { OOO_STRING_SVTOOLS_HTML_WW_off,      HTML_WM_OFF     },
diff --git a/sw/source/filter/html/svxcss1.cxx b/sw/source/filter/html/svxcss1.cxx
index c1a6f7312d30..721a9e4afd59 100644
--- a/sw/source/filter/html/svxcss1.cxx
+++ b/sw/source/filter/html/svxcss1.cxx
@@ -170,8 +170,12 @@ static CSS1PropertyEnum const aBorderWidthTable[] =
     { nullptr,                    0   }
 };
 
+namespace {
+
 enum CSS1BorderStyle { CSS1_BS_NONE, CSS1_BS_SINGLE, CSS1_BS_DOUBLE, CSS1_BS_DOTTED, CSS1_BS_DASHED, CSS1_BS_GROOVE, CSS1_BS_RIDGE, CSS1_BS_INSET, CSS1_BS_OUTSET };
 
+}
+
 static CSS1PropertyEnum const aBorderStyleTable[] =
 {
     { "none",        CSS1_BS_NONE        },
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index 12ce9f9e8db1..1db18cf71acd 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -1626,6 +1626,8 @@ namespace
     }
 }
 
+namespace {
+
 enum wwTableSprm
 {
     sprmNil,
@@ -1637,6 +1639,8 @@ enum wwTableSprm
     sprmTDefTableNewShd, sprmTCellPadding, sprmTCellPaddingDefault
 };
 
+}
+
 static wwTableSprm GetTableSprm(sal_uInt16 nId, ww::WordVersion eVer)
 {
     switch (eVer)
diff --git a/sw/source/filter/xml/xmlbrsh.cxx b/sw/source/filter/xml/xmlbrsh.cxx
index aebefd159b8f..e55e60ea9155 100644
--- a/sw/source/filter/xml/xmlbrsh.cxx
+++ b/sw/source/filter/xml/xmlbrsh.cxx
@@ -40,6 +40,8 @@ using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
 using namespace ::xmloff::token;
 
+namespace {
+
 enum SvXMLTokenMapAttrs
 {
     XML_TOK_BGIMG_HREF,
@@ -51,6 +53,8 @@ enum SvXMLTokenMapAttrs
     XML_TOK_BGIMG_FILTER,
 };
 
+}
+
 static const SvXMLTokenMapEntry aBGImgAttributesAttrTokenMap[] =
 {
     { XML_NAMESPACE_XLINK, XML_HREF,        XML_TOK_BGIMG_HREF      },
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index c198632b2261..ad6427077b88 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -104,6 +104,8 @@ using namespace ::com::sun::star::xforms;
 using namespace ::xmloff::token;
 using namespace ::std;
 
+namespace {
+
 enum SwXMLDocTokens
 {
     XML_TOK_DOC_FONTDECLS,
@@ -117,6 +119,8 @@ enum SwXMLDocTokens
     XML_TOK_DOC_XFORMS,
 };
 
+}
+
 static const SvXMLTokenMapEntry aDocTokenMap[] =
 {
     { XML_NAMESPACE_OFFICE, XML_FONT_FACE_DECLS,     XML_TOK_DOC_FONTDECLS  },
diff --git a/sw/source/filter/xml/xmlmeta.cxx b/sw/source/filter/xml/xmlmeta.cxx
index 35ffb9909a1d..2a95dc8106cb 100644
--- a/sw/source/filter/xml/xmlmeta.cxx
+++ b/sw/source/filter/xml/xmlmeta.cxx
@@ -72,6 +72,8 @@ SvXMLImportContext *SwXMLImport::CreateMetaContext(
     return pContext;
 }
 
+namespace {
+
 enum SvXMLTokenMapAttrs
 {
     XML_TOK_META_STAT_TABLE = 1,
@@ -85,6 +87,8 @@ enum SvXMLTokenMapAttrs
     XML_TOK_META_STAT_END=XML_TOK_UNKNOWN
 };
 
+}
+
 struct statistic {
     SvXMLTokenMapAttrs const token;
     const char* name;
diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx
index b7807e0e87d6..657ac47e6c4f 100644
--- a/sw/source/filter/xml/xmltbli.cxx
+++ b/sw/source/filter/xml/xmltbli.cxx
@@ -77,6 +77,8 @@ using namespace ::com::sun::star::table;
 using namespace ::com::sun::star::xml::sax;
 using namespace ::xmloff::token;
 
+namespace {
+
 enum SwXMLTableElemTokens
 {
     XML_TOK_TABLE_HEADER_COLS,
@@ -105,6 +107,8 @@ enum SwXMLTableCellAttrTokens
     XML_TOK_TABLE_VALUE_TYPE,
 };
 
+}
+
 static const SvXMLTokenMapEntry aTableElemTokenMap[] =
 {
     { XML_NAMESPACE_TABLE, XML_TABLE_HEADER_COLUMNS,
diff --git a/sw/source/filter/xml/xmltexte.cxx b/sw/source/filter/xml/xmltexte.cxx
index 509784e78818..284b48c94c4b 100644
--- a/sw/source/filter/xml/xmltexte.cxx
+++ b/sw/source/filter/xml/xmltexte.cxx
@@ -58,6 +58,8 @@ using namespace ::com::sun::star::document;
 using namespace ::com::sun::star::io;
 using namespace ::xmloff::token;
 
+namespace {
+
 enum SvEmbeddedObjectTypes
 {
     SV_EMBEDDED_OWN,
@@ -67,6 +69,8 @@ enum SvEmbeddedObjectTypes
     SV_EMBEDDED_FRAME
 };
 
+}
+
 SwNoTextNode *SwXMLTextParagraphExport::GetNoTextNode(
     const Reference < XPropertySet >& rPropSet )
 {
diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx
index 4b89a8aca6f5..6791ce55867d 100644
--- a/sw/source/ui/fldui/fldref.cxx
+++ b/sw/source/ui/fldui/fldref.cxx
@@ -730,6 +730,8 @@ bool SwFieldRefPage::MatchSubstring( const OUString& rListString, const OUString
     return aListString.indexOf(aSubstr) >= 0;
 }
 
+namespace {
+
 enum FMT_REF_IDX
 {
     FMT_REF_PAGE_IDX                = 0,
@@ -745,6 +747,8 @@ enum FMT_REF_IDX
     FMT_REF_NUMBER_FULL_CONTEXT_IDX = 10
 };
 
+}
+
 static const char* FMT_REF_ARY[] =
 {
     FMT_REF_PAGE,
diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx
index 3cb80999a5b6..836fde5344f9 100644
--- a/sw/source/ui/frmdlg/frmpage.cxx
+++ b/sw/source/ui/frmdlg/frmpage.cxx
@@ -91,6 +91,8 @@ struct StringIdPair_Impl
 #define MAX_PERCENT_WIDTH   254
 #define MAX_PERCENT_HEIGHT  254
 
+namespace {
+
 enum class LB {
     NONE                = 0x00000000L,
     Frame               = 0x00000001L,  // text region of the paragraph
@@ -119,6 +121,9 @@ enum class LB {
 
     VertLine            = 0x00400000L,  // vertical text line
 };
+
+}
+
 namespace o3tl {
     template<> struct typed_flags<LB> : is_typed_flags<LB, 0x00773fffL> {};
 }
diff --git a/sw/source/uibase/config/modcfg.cxx b/sw/source/uibase/config/modcfg.cxx
index 006ad51069a2..7aefbfcaf799 100644
--- a/sw/source/uibase/config/modcfg.cxx
+++ b/sw/source/uibase/config/modcfg.cxx
@@ -359,6 +359,8 @@ void SwRevisionConfig::Load()
     }
 }
 
+namespace {
+
 enum InsertConfigProp
 {
     INS_PROP_TABLE_HEADER = 0,
@@ -456,6 +458,9 @@ enum InsertConfigProp
     INS_PROP_CAP_OBJECT_OLEMISC_CHARACTERSTYLE,         //92
     INS_PROP_CAP_OBJECT_OLEMISC_APPLYATTRIBUTES        //93
 };
+
+}
+
 const Sequence<OUString>& SwInsertConfig::GetPropertyNames() const
 {
     static Sequence<OUString> aNames
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 8d11292d9e52..c899b6cbd70b 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -169,10 +169,20 @@ void lcl_emitEvent(SfxEventHintId nEventId, sal_Int32 nStrId, SfxObjectShell* pD
 
 std::vector<std::pair<SwDocShell*, OUString>> SwDBManager::m_aUncommittedRegistrations;
 
+namespace {
+
 enum class SwDBNextRecord { NEXT, FIRST };
+
+}
+
 static bool lcl_ToNextRecord( SwDSParam* pParam, const SwDBNextRecord action = SwDBNextRecord::NEXT );
 
+namespace {
+
 enum class WorkingDocType { SOURCE, TARGET, COPY };
+
+}
+
 static SfxObjectShell* lcl_CreateWorkingDocument(
     const WorkingDocType aType, const SwWrtShell &rSourceWrtShell,
     const vcl::Window *pSourceWindow,
diff --git a/sw/source/uibase/sidebar/PageStylesPanel.cxx b/sw/source/uibase/sidebar/PageStylesPanel.cxx
index 025a38f3e6bc..70595db3eb37 100644
--- a/sw/source/uibase/sidebar/PageStylesPanel.cxx
+++ b/sw/source/uibase/sidebar/PageStylesPanel.cxx
@@ -44,6 +44,8 @@ using namespace ::com::sun::star;
 
 namespace sw { namespace sidebar{
 
+namespace {
+
 enum eFillStyle
 {
     NONE,
@@ -54,6 +56,8 @@ enum eFillStyle
     PATTERN
 };
 
+}
+
 const SvxPageUsage aArr[] =
 {
     SvxPageUsage::All,
diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx
index 93dc022cd9be..ebe65c360b2b 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -64,6 +64,8 @@ using namespace ::com::sun::star::beans;
 using namespace ::com::sun::star::lang;
 using namespace ::com::sun::star::i18n;
 
+namespace {
+
 enum SwDocumentSettingsPropertyHandles
 {
     HANDLE_FORBIDDEN_CHARS,
@@ -146,6 +148,8 @@ enum SwDocumentSettingsPropertyHandles
     HANDLE_CONTINUOUS_ENDNOTES,
 };
 
+}
+
 static MasterPropertySetInfo * lcl_createSettingsInfo()
 {
     static PropertyInfo const aWriterSettingsInfoMap[] =
diff --git a/sw/source/uibase/uno/unomailmerge.cxx b/sw/source/uibase/uno/unomailmerge.cxx
index 388d59ce9dd7..83682dbb9b95 100644
--- a/sw/source/uibase/uno/unomailmerge.cxx
+++ b/sw/source/uibase/uno/unomailmerge.cxx
@@ -87,12 +87,17 @@ static osl::Mutex &    GetMailMergeMutex()
     return aMutex;
 }
 
+namespace {
+
 enum CloseResult
 {
     eSuccess,       // successfully closed
     eVetoed,        // vetoed, ownership transferred to the vetoing instance
     eFailed         // failed for some unknown reason
 };
+
+}
+
 static CloseResult CloseModelAndDocSh(
        Reference< frame::XModel > const &rxModel,
        SfxObjectShellRef &rxDocSh )
diff --git a/sw/source/uibase/uno/unomod.cxx b/sw/source/uibase/uno/unomod.cxx
index 5df0c5af9d89..07ce19ea7bcc 100644
--- a/sw/source/uibase/uno/unomod.cxx
+++ b/sw/source/uibase/uno/unomod.cxx
@@ -49,6 +49,8 @@ using namespace ::com::sun::star::beans;
 using namespace ::com::sun::star::lang;
 using namespace ::comphelper;
 
+namespace {
+
 enum SwViewSettingsPropertyHandles
 {
     HANDLE_VIEWSET_ANNOTATIONS,
@@ -119,6 +121,8 @@ enum SwPrintSettingsPropertyHandles
     HANDLE_PRINTSET_HIDDEN_TEXT
 };
 
+}
+
 static ChainablePropertySetInfo * lcl_createViewSettingsInfo()
 {
     static PropertyInfo const aViewSettingsMap_Impl[] =
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index 21b72b3a9bcd..468ba6cbfa16 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -821,6 +821,8 @@ void SwContentType::FillMemberList(bool* pbLevelOrVisibilityChanged)
     m_bDataValid = true;
 }
 
+namespace {
+
 enum STR_CONTEXT_IDX
 {
     IDX_STR_OUTLINE_LEVEL = 0,
@@ -838,6 +840,8 @@ enum STR_CONTEXT_IDX
     IDX_STR_SEND_OUTLINE_TO_CLIPBOARD_ENTRY = 12
 };
 
+}
+
 static const char* STR_CONTEXT_ARY[] =
 {
     STR_OUTLINE_LEVEL,
diff --git a/sw/source/uibase/utlui/glbltree.cxx b/sw/source/uibase/utlui/glbltree.cxx
index 2b056fca6ffe..1859e70579dd 100644
--- a/sw/source/uibase/utlui/glbltree.cxx
+++ b/sw/source/uibase/utlui/glbltree.cxx
@@ -135,6 +135,8 @@ void SwGlobalFrameListener_Impl::Notify( SfxBroadcaster& /*rBC*/, const SfxHint&
         bValid = false;
 }
 
+namespace {
+
 enum GLOBAL_CONTEXT_IDX
 {
     IDX_STR_UPDATE = 0,
@@ -153,6 +155,8 @@ enum GLOBAL_CONTEXT_IDX
     IDX_STR_EDIT_LINK = 13
 };
 
+}
+
 static const char* GLOBAL_CONTEXT_ARY[] =
 {
     STR_UPDATE,
diff --git a/sw/source/uibase/utlui/navipi.cxx b/sw/source/uibase/utlui/navipi.cxx
index e016ab69910f..fa97463ef822 100644
--- a/sw/source/uibase/utlui/navipi.cxx
+++ b/sw/source/uibase/utlui/navipi.cxx
@@ -585,6 +585,8 @@ void SwNavigationPI::ZoomIn()
     m_aContentToolBox->CheckItem(m_aContentToolBox->GetItemId("listbox"), false);
 }
 
+namespace {
+
 enum StatusIndex
 {
     IDX_STR_HIDDEN = 0,
@@ -592,6 +594,8 @@ enum StatusIndex
     IDX_STR_INACTIVE = 2
 };
 
+}
+
 SwNavigationPI::SwNavigationPI(SfxBindings* _pBindings,
                                vcl::Window* pParent)
     : PanelLayout(pParent, "NavigatorPanel", "modules/swriter/ui/navigatorpanel.ui", nullptr)
diff --git a/ucb/source/ucp/ftp/ftpcontent.cxx b/ucb/source/ucp/ftp/ftpcontent.cxx
index 92c3639bebf0..eede2a33b6bd 100644
--- a/ucb/source/ucp/ftp/ftpcontent.cxx
+++ b/ucb/source/ucp/ftp/ftpcontent.cxx
@@ -219,6 +219,8 @@ ResultSetBase* ResultSetFactory::createResultSet()
 
 // XCommandProcessor methods.
 
+namespace {
+
 enum ACTION { NOACTION,
               THROWAUTHENTICATIONREQUEST,
               THROWACCESSDENIED,
@@ -228,6 +230,8 @@ enum ACTION { NOACTION,
               THROWNOFILE,
               THROWGENERAL };
 
+}
+
 // virtual
 Any SAL_CALL FTPContent::execute( const Command& aCommand,
                                   sal_Int32 /*CommandId*/,
diff --git a/ucb/source/ucp/ftp/ftpurl.cxx b/ucb/source/ucp/ftp/ftpurl.cxx
index ecc9fdcc8191..93b7dc331cd9 100644
--- a/ucb/source/ucp/ftp/ftpurl.cxx
+++ b/ucb/source/ucp/ftp/ftpurl.cxx
@@ -354,10 +354,14 @@ OUString FTPURL::child() const
 
 namespace ftp {
 
+    namespace {
+
     enum OS {
         FTP_DOS,FTP_UNIX,FTP_VMS,FTP_UNKNOWN
     };
 
+    }
+
 }
 
 
diff --git a/unotools/source/config/configvaluecontainer.cxx b/unotools/source/config/configvaluecontainer.cxx
index fcdae8faee58..780a59d99926 100644
--- a/unotools/source/config/configvaluecontainer.cxx
+++ b/unotools/source/config/configvaluecontainer.cxx
@@ -34,12 +34,16 @@ namespace utl
 
     //= NodeValueAccessor
 
+    namespace {
+
     enum class LocationType
     {
         SimplyObjectInstance,
         Unbound
     };
 
+    }
+
     struct NodeValueAccessor
     {
     private:
diff --git a/unotools/source/config/fltrcfg.cxx b/unotools/source/config/fltrcfg.cxx
index 5ebfdbf90668..92ec14e0dd14 100644
--- a/unotools/source/config/fltrcfg.cxx
+++ b/unotools/source/config/fltrcfg.cxx
@@ -28,6 +28,8 @@
 using namespace utl;
 using namespace com::sun::star::uno;
 
+namespace {
+
 enum class ConfigFlags {
     NONE                         = 0x0000000,
     WordCode                     = 0x0000001,
@@ -55,6 +57,9 @@ enum class ConfigFlags {
     CreateMSOLockFiles           = 0x2000000,
     VisioLoad                    = 0x4000000,
 };
+
+}
+
 namespace o3tl {
     template<> struct typed_flags<ConfigFlags> : is_typed_flags<ConfigFlags, 0xe7fff3f> {};
 }
diff --git a/unotools/source/misc/fontcvt.cxx b/unotools/source/misc/fontcvt.cxx
index 12c6528498db..d9d80ce2e2de 100644
--- a/unotools/source/misc/fontcvt.cxx
+++ b/unotools/source/misc/fontcvt.cxx
@@ -1011,12 +1011,16 @@ static sal_Unicode ImplStarSymbolToStarBats( sal_Unicode c )
     return c;
 }
 
+namespace {
+
 enum SymbolFont
 {
     Symbol=1, Wingdings=2, MonotypeSorts=4, Webdings=8, Wingdings2=16,
     Wingdings3=32, MTExtra=64, TimesNewRoman=128
 };
 
+}
+
 const char * const aSymbolNames[] =
 {
     "Symbol", "Wingdings", "Monotype Sorts", "Webdings", "Wingdings 2",
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index a621f6c61fd4..18c6f0f536ee 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -2091,8 +2091,12 @@ static BitmapEx readBitmapEx( const OUString& rPath )
     return aGraphic.GetBitmapEx();
 }
 
+namespace {
+
 enum WhichPersona { PERSONA_HEADER, PERSONA_FOOTER };
 
+}
+
 /** Update the setting of the Persona header / footer in ImplStyleData */
 static void setupPersonaHeaderFooter( WhichPersona eWhich, OUString& rHeaderFooter, BitmapEx& rHeaderFooterBitmap, boost::optional<Color>& rMenuBarTextColor )
 {
diff --git a/vcl/source/control/fmtfield.cxx b/vcl/source/control/fmtfield.cxx
index 7ae57b9f62b7..51c21acfa5f2 100644
--- a/vcl/source/control/fmtfield.cxx
+++ b/vcl/source/control/fmtfield.cxx
@@ -43,6 +43,8 @@ using namespace ::com::sun::star::util;
 
 namespace validation
 {
+    namespace {
+
     // the states of our automat.
     enum State
     {
@@ -59,6 +61,8 @@ namespace validation
         END                 // reached the end of the string
     };
 
+    }
+
     // a row in the transition table (means the set of states to be reached from a given state)
     typedef ::std::map< sal_Unicode, State >        StateTransitions;
 
diff --git a/vcl/source/filter/igif/gifread.cxx b/vcl/source/filter/igif/gifread.cxx
index 6bd2290f777f..34e35738bb6b 100644
--- a/vcl/source/filter/igif/gifread.cxx
+++ b/vcl/source/filter/igif/gifread.cxx
@@ -26,6 +26,8 @@
 
 #define NO_PENDING( rStm ) ( ( rStm ).GetError() != ERRCODE_IO_PENDING )
 
+namespace {
+
 enum GIFAction
 {
     GLOBAL_HEADER_READING,
@@ -45,6 +47,8 @@ enum ReadState
     GIFREAD_NEED_MORE
 };
 
+}
+
 class GIFLZWDecompressor;
 
 class SvStream;
diff --git a/vcl/source/filter/ixbm/xbmread.cxx b/vcl/source/filter/ixbm/xbmread.cxx
index 6d88ec57a640..bea2791ea56c 100644
--- a/vcl/source/filter/ixbm/xbmread.cxx
+++ b/vcl/source/filter/ixbm/xbmread.cxx
@@ -26,6 +26,8 @@
 
 #include "xbmread.hxx"
 
+namespace {
+
 enum XBMFormat
 {
     XBM10,
@@ -39,6 +41,8 @@ enum ReadState
     XBMREAD_NEED_MORE
 };
 
+}
+
 class XBMReader : public GraphicReader
 {
     SvStream&           rIStm;
diff --git a/vcl/source/filter/ixpm/xpmread.cxx b/vcl/source/filter/ixpm/xpmread.cxx
index 85a9bfd18a8e..36183e74e327 100644
--- a/vcl/source/filter/ixpm/xpmread.cxx
+++ b/vcl/source/filter/ixpm/xpmread.cxx
@@ -42,6 +42,8 @@
 #define XPMSTRING           0x00000004
 #define XPMFINISHED         0x00000008
 
+namespace {
+
 enum ReadState
 {
     XPMREAD_OK,
@@ -49,6 +51,8 @@ enum ReadState
     XPMREAD_NEED_MORE
 };
 
+}
+
 class BitmapWriteAccess;
 class Graphic;
 
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index fd6e6f96df10..7b905f558051 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -54,6 +54,8 @@ static const char * const modextra = "gelf";
 
 /*- private functions, constants and data types */
 
+namespace {
+
 enum PathSegmentType {
     PS_NOOP      = 0,
     PS_MOVETO    = 1,
@@ -62,6 +64,8 @@ enum PathSegmentType {
     PS_CLOSEPATH = 4
 };
 
+}
+
 struct PSPathElement
 {
     PathSegmentType type;
@@ -1013,6 +1017,8 @@ static void GetNames(TrueTypeFont *t)
     }
 }
 
+namespace {
+
 enum cmapType {
     CMAP_NOT_USABLE           = -1,
     CMAP_MS_Symbol            = 10,
@@ -1024,6 +1030,8 @@ enum cmapType {
     CMAP_MS_Johab             = 16
 };
 
+}
+
 #define MISSING_GLYPH_INDEX 0
 
 static sal_uInt32 getGlyph0(const sal_uInt8* cmap, sal_uInt32, sal_uInt32 c) {
diff --git a/vcl/source/gdi/regionband.cxx b/vcl/source/gdi/regionband.cxx
index adddd264c421..8478ebb1ff68 100644
--- a/vcl/source/gdi/regionband.cxx
+++ b/vcl/source/gdi/regionband.cxx
@@ -190,8 +190,12 @@ bool RegionBand::operator==( const RegionBand& rRegionBand ) const
     return true;
 }
 
+namespace {
+
 enum StreamEntryType { STREAMENTRY_BANDHEADER, STREAMENTRY_SEPARATION, STREAMENTRY_END };
 
+}
+
 bool RegionBand::load(SvStream& rIStrm)
 {
     // clear this instance data
diff --git a/vcl/source/graphic/UnoGraphicDescriptor.cxx b/vcl/source/graphic/UnoGraphicDescriptor.cxx
index 9db06af2a4cb..e27f8c56d928 100644
--- a/vcl/source/graphic/UnoGraphicDescriptor.cxx
+++ b/vcl/source/graphic/UnoGraphicDescriptor.cxx
@@ -32,6 +32,8 @@
 #include <vcl/svapp.hxx>
 #include <memory>
 
+namespace {
+
 enum class UnoGraphicProperty
 {
       GraphicType = 1
@@ -46,6 +48,7 @@ enum class UnoGraphicProperty
     , OriginURL = 10
 };
 
+}
 
 using namespace ::com::sun::star;
 
diff --git a/vcl/unx/gtk3/a11y/gtk3atktextattributes.cxx b/vcl/unx/gtk3/a11y/gtk3atktextattributes.cxx
index 52f0a34cd3a2..fa5ab6030eae 100644
--- a/vcl/unx/gtk3/a11y/gtk3atktextattributes.cxx
+++ b/vcl/unx/gtk3/a11y/gtk3atktextattributes.cxx
@@ -73,6 +73,8 @@ static AtkTextAttribute atk_text_attribute_mm_to_pixel_ratio = ATK_TEXT_ATTR_INV
   *                        and re-arrange the enum values accordingly.
   */
 
+namespace {
+
 enum ExportedAttribute
 {
     TEXT_ATTRIBUTE_BACKGROUND_COLOR = 0,
@@ -109,6 +111,8 @@ enum ExportedAttribute
     TEXT_ATTRIBUTE_LAST
 };
 
+}
+
 static const char * ExportedTextAttributes[TEXT_ATTRIBUTE_LAST] =
 {
     "CharBackColor",        // TEXT_ATTRIBUTE_BACKGROUND_COLOR
diff --git a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
index 5680ddf71bc2..6988f87df0f3 100644
--- a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
@@ -133,6 +133,8 @@ static GtkStateFlags NWConvertVCLStateToGTKState(ControlState nVCLState)
     return nGTKState;
 }
 
+namespace {
+
 enum class RenderType {
     BackgroundAndFrame = 1,
     Check,
@@ -152,6 +154,8 @@ enum class RenderType {
     Focus
 };
 
+}
+
 static void NWCalcArrowRect( const tools::Rectangle& rButton, tools::Rectangle& rArrow )
 {
     // Size the arrow appropriately
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 74dc6fb5671e..42e4c5cda164 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -86,11 +86,15 @@ namespace {
 
 }
 
+namespace {
+
 enum RenderStyle {
     RENDER_THUMB,    // small view <n> to a page
     RENDER_EXPANDED, // expanded view of this renderer
 };
 
+}
+
 class DemoRenderer
 {
     Bitmap   maIntroBW;
diff --git a/xmloff/source/chart/XMLSymbolImageContext.cxx b/xmloff/source/chart/XMLSymbolImageContext.cxx
index 5fce5f613f05..36fd0eafa6e9 100644
--- a/xmloff/source/chart/XMLSymbolImageContext.cxx
+++ b/xmloff/source/chart/XMLSymbolImageContext.cxx
@@ -29,6 +29,8 @@
 
 using namespace css;
 
+namespace {
+
 enum SvXMLTokenMapAttrs
 {
     XML_TOK_SYMBOL_IMAGE_HREF,
@@ -37,6 +39,8 @@ enum SvXMLTokenMapAttrs
     XML_TOK_SYMBOL_IMAGE_SHOW,
 };
 
+}
+
 static const SvXMLTokenMapEntry aSymbolImageAttrTokenMap[] =
 {
     { XML_NAMESPACE_XLINK,  ::xmloff::token::XML_HREF,     XML_TOK_SYMBOL_IMAGE_HREF    },
diff --git a/xmloff/source/draw/XMLImageMapContext.cxx b/xmloff/source/draw/XMLImageMapContext.cxx
index c7126b055865..40d5a8f0d6db 100644
--- a/xmloff/source/draw/XMLImageMapContext.cxx
+++ b/xmloff/source/draw/XMLImageMapContext.cxx
@@ -55,6 +55,7 @@ using ::com::sun::star::uno::XInterface;
 using ::com::sun::star::uno::Any;
 using ::com::sun::star::document::XEventsSupplier;
 
+namespace {
 
 enum XMLImageMapToken: decltype(XML_TOK_UNKNOWN)
 {
@@ -73,6 +74,8 @@ enum XMLImageMapToken: decltype(XML_TOK_UNKNOWN)
     XML_TOK_IMAP_TARGET
 };
 
+}
+
 static const SvXMLTokenMapEntry aImageMapObjectTokenMap[] =
 {
     { XML_NAMESPACE_XLINK,  XML_HREF,           XML_TOK_IMAP_URL            },
diff --git a/xmloff/source/draw/animationimport.cxx b/xmloff/source/draw/animationimport.cxx
index f436035ef56c..082f7ad5153b 100644
--- a/xmloff/source/draw/animationimport.cxx
+++ b/xmloff/source/draw/animationimport.cxx
@@ -164,6 +164,8 @@ const SvXMLTokenMap& AnimationsImportHelperImpl::getAnimationNodeTokenMap()
     return *mpAnimationNodeTokenMap;
 }
 
+namespace {
+
 enum AnimationNodeAttributes
 {
     ANA_Begin,
@@ -217,6 +219,8 @@ enum AnimationNodeAttributes
     ANA_Volume
 };
 
+}
+
 const SvXMLTokenMap& AnimationsImportHelperImpl::getAnimationNodeAttributeTokenMap()
 {
     if( mpAnimationNodeAttributeTokenMap == nullptr )
diff --git a/xmloff/source/draw/animexp.cxx b/xmloff/source/draw/animexp.cxx
index 3036aa97e20d..2b0071cd1b5b 100644
--- a/xmloff/source/draw/animexp.cxx
+++ b/xmloff/source/draw/animexp.cxx
@@ -186,6 +186,8 @@ void SdXMLImplSetEffect( AnimationEffect eEffect, XMLEffect& eKind, XMLEffectDir
     bIn = rEffect.mbIn;
 }
 
+namespace {
+
 enum XMLActionKind
 {
     XMLE_SHOW,
@@ -194,6 +196,8 @@ enum XMLActionKind
     XMLE_PLAY
 };
 
+}
+
 struct XMLEffectHint
 {
     XMLActionKind   meKind;
diff --git a/xmloff/source/draw/animimp.cxx b/xmloff/source/draw/animimp.cxx
index 38d8f5eb0148..f1ad97e5af1f 100644
--- a/xmloff/source/draw/animimp.cxx
+++ b/xmloff/source/draw/animimp.cxx
@@ -335,6 +335,8 @@ public:
     static constexpr OUStringLiteral gsIsAnimation = "IsAnimation";
 };
 
+namespace {
+
 enum XMLActionKind
 {
     XMLE_SHOW,
@@ -343,6 +345,8 @@ enum XMLActionKind
     XMLE_PLAY
 };
 
+}
+
 class XMLAnimationsEffectContext : public SvXMLImportContext
 {
 public:
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index ddd128d1d8b0..affbfd01a779 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -1577,6 +1577,7 @@ void XMLShapeExport::ImpExportText( const uno::Reference< drawing::XShape >& xSh
     }
 }
 
+namespace {
 
 enum class Found {
     NONE              = 0x0000,
@@ -1591,6 +1592,9 @@ enum class Found {
     MACRO             = 0x0100,
     LIBRARY           = 0x0200,
 };
+
+}
+
 namespace o3tl {
     template<> struct typed_flags<Found> : is_typed_flags<Found, 0x03ff> {};
 }
diff --git a/xmloff/source/style/DashStyle.cxx b/xmloff/source/style/DashStyle.cxx
index 85173e11b9f2..5f61a157372f 100644
--- a/xmloff/source/style/DashStyle.cxx
+++ b/xmloff/source/style/DashStyle.cxx
@@ -39,6 +39,8 @@ using namespace ::com::sun::star;
 
 using namespace ::xmloff::token;
 
+namespace {
+
 enum SvXMLTokenMapAttrs
 {
     XML_TOK_DASH_NAME,
@@ -51,6 +53,8 @@ enum SvXMLTokenMapAttrs
     XML_TOK_DASH_DISTANCE,
 };
 
+}
+
 static const SvXMLTokenMapEntry aDashStyleAttrTokenMap[] =
 {
     { XML_NAMESPACE_DRAW, XML_NAME,             XML_TOK_DASH_NAME },
diff --git a/xmloff/source/style/GradientStyle.cxx b/xmloff/source/style/GradientStyle.cxx
index 177c21b80ba5..59495892df44 100644
--- a/xmloff/source/style/GradientStyle.cxx
+++ b/xmloff/source/style/GradientStyle.cxx
@@ -39,6 +39,8 @@ using namespace ::com::sun::star;
 
 using namespace ::xmloff::token;
 
+namespace {
+
 enum SvXMLTokenMapAttrs
 {
     XML_TOK_GRADIENT_NAME,
@@ -55,6 +57,8 @@ enum SvXMLTokenMapAttrs
     XML_TOK_TABSTOP_END=XML_TOK_UNKNOWN
 };
 
+}
+
 SvXMLEnumMapEntry<awt::GradientStyle> const pXML_GradientStyle_Enum[] =
 {
     { XML_GRADIENTSTYLE_LINEAR,         awt::GradientStyle_LINEAR },
diff --git a/xmloff/source/style/HatchStyle.cxx b/xmloff/source/style/HatchStyle.cxx
index 899223754c61..e7f03a817e53 100644
--- a/xmloff/source/style/HatchStyle.cxx
+++ b/xmloff/source/style/HatchStyle.cxx
@@ -39,6 +39,8 @@ using namespace ::com::sun::star;
 
 using namespace ::xmloff::token;
 
+namespace {
+
 enum SvXMLTokenMapAttrs
 {
     XML_TOK_HATCH_NAME,
@@ -50,6 +52,8 @@ enum SvXMLTokenMapAttrs
     XML_TOK_TABSTOP_END=XML_TOK_UNKNOWN
 };
 
+}
+
 SvXMLEnumMapEntry<drawing::HatchStyle> const pXML_HatchStyle_Enum[] =
 {
     { XML_HATCHSTYLE_SINGLE,    drawing::HatchStyle_SINGLE },
diff --git a/xmloff/source/style/ImageStyle.cxx b/xmloff/source/style/ImageStyle.cxx
index 164f155fb02e..6fe12b40b2bc 100644
--- a/xmloff/source/style/ImageStyle.cxx
+++ b/xmloff/source/style/ImageStyle.cxx
@@ -32,6 +32,8 @@
 using namespace css;
 using namespace xmloff::token;
 
+namespace {
+
 enum SvXMLTokenMapAttrs
 {
     XML_TOK_IMAGE_NAME,
@@ -42,6 +44,8 @@ enum SvXMLTokenMapAttrs
     XML_TOK_IMAGE_ACTUATE
 };
 
+}
+
 void XMLImageStyle::exportXML(OUString const & rStrName, uno::Any const & rValue, SvXMLExport& rExport)
 {
     if (rStrName.isEmpty())
diff --git a/xmloff/source/style/TransGradientStyle.cxx b/xmloff/source/style/TransGradientStyle.cxx
index 510713ca1ae8..30e4e56426d5 100644
--- a/xmloff/source/style/TransGradientStyle.cxx
+++ b/xmloff/source/style/TransGradientStyle.cxx
@@ -39,6 +39,8 @@ using namespace ::com::sun::star;
 
 using namespace ::xmloff::token;
 
+namespace {
+
 enum SvXMLTokenMapAttrs
 {
     XML_TOK_GRADIENT_NAME,
@@ -52,6 +54,8 @@ enum SvXMLTokenMapAttrs
     XML_TOK_GRADIENT_BORDER
 };
 
+}
+
 SvXMLEnumMapEntry<awt::GradientStyle> const pXML_GradientStyle_Enum[] =
 {
     { XML_GRADIENTSTYLE_LINEAR,         awt::GradientStyle_LINEAR },
diff --git a/xmloff/source/style/XMLBackgroundImageContext.cxx b/xmloff/source/style/XMLBackgroundImageContext.cxx
index 6bdafccff70e..b9ccb73c9c1a 100644
--- a/xmloff/source/style/XMLBackgroundImageContext.cxx
+++ b/xmloff/source/style/XMLBackgroundImageContext.cxx
@@ -43,6 +43,8 @@ using namespace ::com::sun::star::style;
 using namespace ::com::sun::star::io;
 using namespace ::xmloff::token;
 
+namespace {
+
 enum SvXMLTokenMapAttrs
 {
     XML_TOK_BGIMG_HREF,
@@ -54,6 +56,9 @@ enum SvXMLTokenMapAttrs
     XML_TOK_BGIMG_FILTER,
     XML_TOK_BGIMG_OPACITY
 };
+
+}
+
 static const SvXMLTokenMapEntry aBGImgAttributesAttrTokenMap[] =
 {
     { XML_NAMESPACE_XLINK, XML_HREF,        XML_TOK_BGIMG_HREF      },
diff --git a/xmloff/source/style/XMLFontStylesContext.cxx b/xmloff/source/style/XMLFontStylesContext.cxx
index 0c8e18a66711..cbb364663502 100644
--- a/xmloff/source/style/XMLFontStylesContext.cxx
+++ b/xmloff/source/style/XMLFontStylesContext.cxx
@@ -50,6 +50,8 @@ using namespace ::xmloff::token;
 
 #define XML_STYLE_FAMILY_FONT 1
 
+namespace {
+
 enum XMLFontStyleAttrTokens
 {
     XML_TOK_FONT_STYLE_ATTR_FAMILY,
@@ -59,6 +61,8 @@ enum XMLFontStyleAttrTokens
     XML_TOK_FONT_STYLE_ATTR_CHARSET,
 };
 
+}
+
 static const SvXMLTokenMapEntry* lcl_getFontStyleAttrTokenMap()
 {
     static const SvXMLTokenMapEntry aFontStyleAttrTokenMap[] =
diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx
index c01992740f5e..29f9e1f7527b 100644
--- a/xmloff/source/style/xmlnumfi.cxx
+++ b/xmloff/source/style/xmlnumfi.cxx
@@ -192,6 +192,8 @@ public:
     virtual void EndElement() override;
 };
 
+namespace {
+
 enum SvXMLStyleTokens
 {
     XML_TOK_STYLE_TEXT,
@@ -264,6 +266,7 @@ enum SvXMLStyleElemAttrTokens
     XML_TOK_ELEM_ATTR_CALENDAR
 };
 
+}
 
 //  standard colors
 
diff --git a/xmloff/source/style/xmlnumi.cxx b/xmloff/source/style/xmlnumi.cxx
index 710bb3ede574..09c95178212b 100644
--- a/xmloff/source/style/xmlnumi.cxx
+++ b/xmloff/source/style/xmlnumi.cxx
@@ -99,6 +99,8 @@ public:
             SvxXMLListLevelStyleContext_Impl& rLLevel   );
 };
 
+namespace {
+
 enum SvxXMLTextListLevelStyleAttrTokens
 {
     XML_TOK_TEXT_LEVEL_ATTR_LEVEL,
@@ -116,6 +118,8 @@ enum SvxXMLTextListLevelStyleAttrTokens
     XML_TOK_TEXT_LEVEL_ATTR_DISPLAY_LEVELS
 };
 
+}
+
 static const SvXMLTokenMapEntry* lcl_getLevelAttrTokenMap()
 {
     static const SvXMLTokenMapEntry aLevelAttrTokenMap[] =

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list