diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-12-05 09:55:56 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-12-05 13:31:39 +0100 |
commit | 55e596956e56b175ab17b682e7c8ac7daeb9289a (patch) | |
tree | 3691e2f43d50019b5e0f0e0145714afb13bcc685 | |
parent | 6a10149c5fef13721e3f83727a828556f8e1ec9a (diff) |
loplugin:external (clang-cl)
...plus loplugin:consttobool and loplugin:fakebool fallout
Change-Id: Ie3d8121815c080b13bea6d9deca1eb138ca56138
Reviewed-on: https://gerrit.libreoffice.org/84515
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
48 files changed, 243 insertions, 28 deletions
diff --git a/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx b/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx index e483d47c27b9..c725bca543c8 100644 --- a/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx +++ b/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx @@ -306,6 +306,9 @@ static OUString toRTTIname( //RTTI simulation typedef std::unordered_map< OUString, void * > t_string2PtrMap; + +namespace { + class type_info_descriptor; class RTTInfos @@ -323,7 +326,7 @@ public: class type_info_ { friend type_info * RTTInfos::getRTTI( OUString const & ) throw (); - friend int mscx_filterCppException( + friend int mscx::mscx_filterCppException( EXCEPTION_POINTERS *, uno_Any *, uno_Mapping * ); public: @@ -338,11 +341,15 @@ private: char _m_d_name[1]; }; +} + type_info_::~type_info_() throw () { (void)_m_data; } +namespace { + class type_info_descriptor { private: @@ -367,6 +374,8 @@ public: } }; +} + type_info_descriptor * RTTInfos::insert_new_type_info_descriptor(OUString const & rUNOname) { // insert new type_info @@ -484,6 +493,8 @@ static void GenerateDestructorTrampoline( assert( p < code + codeSnippetSize ); } +namespace { + // This looks like it is the struct catchabletype above struct ExceptionType @@ -538,10 +549,14 @@ public: ExceptionInfos() throw (); }; +} + DWORD ExceptionInfos::allocationGranularity = 0; // This corresponds to the struct throwinfo described above. +namespace { + struct RaiseInfo { sal_Int32 _n0; @@ -557,6 +572,8 @@ struct RaiseInfo explicit RaiseInfo(typelib_TypeDescription * pTD) throw (); }; +} + /* Rewrite of 32-Bit-Code to work under 64 Bit: * To use the 32 Bit offset values in the ExceptionType we have to * allocate a single allocation block and use it for all code and date diff --git a/canvas/source/directx/dx_canvas.cxx b/canvas/source/directx/dx_canvas.cxx index eb00ec6591fc..28c73ed50e3c 100644 --- a/canvas/source/directx/dx_canvas.cxx +++ b/canvas/source/directx/dx_canvas.cxx @@ -57,6 +57,8 @@ namespace sdecl = comphelper::service_decl; namespace dxcanvas { + namespace { + /// Actual canonical implementation of the GraphicsProvider interface class GraphicsProviderImpl : public GraphicsProvider { @@ -66,6 +68,8 @@ namespace dxcanvas virtual GraphicsSharedPtr getGraphics() override { return mpGraphics; } }; + } + Canvas::Canvas( const uno::Sequence< uno::Any >& aArguments, const uno::Reference< uno::XComponentContext >& rxContext ) : maArguments(aArguments), diff --git a/canvas/source/directx/dx_canvasbitmap.cxx b/canvas/source/directx/dx_canvasbitmap.cxx index f3d99a1e3ac4..b02ff2796813 100644 --- a/canvas/source/directx/dx_canvasbitmap.cxx +++ b/canvas/source/directx/dx_canvasbitmap.cxx @@ -56,6 +56,8 @@ namespace dxcanvas CanvasBitmap_Base::disposeThis(); } + namespace { + struct AlphaDIB { BITMAPINFOHEADER bmiHeader; @@ -73,6 +75,8 @@ namespace dxcanvas } }; + } + uno::Any SAL_CALL CanvasBitmap::getFastPropertyValue( sal_Int32 nHandle ) { uno::Any aRes; diff --git a/connectivity/source/drivers/ado/Aservices.cxx b/connectivity/source/drivers/ado/Aservices.cxx index 8b5ce37d5a89..d3228d3ffafc 100644 --- a/connectivity/source/drivers/ado/Aservices.cxx +++ b/connectivity/source/drivers/ado/Aservices.cxx @@ -36,6 +36,7 @@ typedef Reference< XSingleServiceFactory > (*createFactoryFunc) rtl_ModuleCount* ); +namespace { struct ProviderRequest { @@ -73,6 +74,7 @@ struct ProviderRequest void* getProvider() const { return xRet.get(); } }; +} extern "C" SAL_DLLPUBLIC_EXPORT void* ado_component_getFactory( const sal_Char* pImplementationName, diff --git a/dtrans/source/win32/clipb/MtaOleClipb.cxx b/dtrans/source/win32/clipb/MtaOleClipb.cxx index fc8a16d86d0c..de966c3978c3 100644 --- a/dtrans/source/win32/clipb/MtaOleClipb.cxx +++ b/dtrans/source/win32/clipb/MtaOleClipb.cxx @@ -173,6 +173,8 @@ static HRESULT UnmarshalIDataObjectAndReleaseStream( LPSTREAM lpStream, IDataObj // helper class to ensure that the calling thread has com initialized +namespace { + class CAutoComInit { public: @@ -214,6 +216,8 @@ private: HRESULT m_hResult; }; +} + // ctor CMtaOleClipboard::CMtaOleClipboard( ) : diff --git a/dtrans/source/win32/dtobj/FmtFilter.cxx b/dtrans/source/win32/dtobj/FmtFilter.cxx index 2130c42ba578..6b0d9c0ba30f 100644 --- a/dtrans/source/win32/dtobj/FmtFilter.cxx +++ b/dtrans/source/win32/dtobj/FmtFilter.cxx @@ -36,6 +36,8 @@ using namespace com::sun::star::uno; +namespace { + #pragma pack(2) struct METAFILEHEADER { @@ -48,6 +50,8 @@ struct METAFILEHEADER }; #pragma pack() +} + // convert a windows metafile picture to a LibreOffice metafile picture Sequence< sal_Int8 > WinMFPictToOOMFPict( Sequence< sal_Int8 >& aMetaFilePict ) diff --git a/dtrans/source/win32/ftransl/ftransl.cxx b/dtrans/source/win32/ftransl/ftransl.cxx index 4cc1897059a3..bd189b890f99 100644 --- a/dtrans/source/win32/ftransl/ftransl.cxx +++ b/dtrans/source/win32/ftransl/ftransl.cxx @@ -56,7 +56,6 @@ namespace Sequence< OUString > aRet { "com.sun.star.datatransfer.DataFormatTranslator" }; return aRet; } -} struct FormatEntry { @@ -73,6 +72,8 @@ struct FormatEntry sal_Int32 aStandardFormatId; }; +} + FormatEntry::FormatEntry( const char *mime_content_type, const char *human_presentable_name, diff --git a/embeddedobj/source/msole/xdialogcreator.cxx b/embeddedobj/source/msole/xdialogcreator.cxx index 8eba66953a5d..819168567a6f 100644 --- a/embeddedobj/source/msole/xdialogcreator.cxx +++ b/embeddedobj/source/msole/xdialogcreator.cxx @@ -45,6 +45,8 @@ #include <oledlg.h> #include <vcl/winscheduler.hxx> +namespace { + class InitializedOleGuard { public: @@ -60,6 +62,8 @@ public: } }; +} + extern "C" { typedef UINT STDAPICALLTYPE OleUIInsertObjectA_Type(LPOLEUIINSERTOBJECTA); } diff --git a/embedserv/source/embed/servprov.cxx b/embedserv/source/embed/servprov.cxx index 3557fa33257c..ec7628bd3453 100644 --- a/embedserv/source/embed/servprov.cxx +++ b/embedserv/source/embed/servprov.cxx @@ -42,6 +42,8 @@ const GUID* const guidList[ SUPPORTED_FACTORIES_NUM ] = { &OID_MathOASISServer }; +namespace { + class CurThreadData { public: @@ -56,6 +58,8 @@ class CurThreadData oslThreadKey m_hKey; }; +} + CurThreadData::CurThreadData() : m_hKey(osl_createThreadKey( nullptr )) { } diff --git a/embedserv/source/embed/tracker.cxx b/embedserv/source/embed/tracker.cxx index a4cd899b6de1..00260481c0a8 100644 --- a/embedserv/source/embed/tracker.cxx +++ b/embedserv/source/embed/tracker.cxx @@ -31,6 +31,7 @@ static HCURSOR afxCursors[10] = { nullptr, }; static HBRUSH afxHalftoneBrush = nullptr; +namespace { // the struct below is used to determine the qualities of a particular handle struct AFX_HANDLEINFO @@ -45,6 +46,8 @@ struct AFX_HANDLEINFO int nInvertY; // handle converts to this when Y inverted }; +} + // this array describes all 8 handles (clock-wise) const AFX_HANDLEINFO afxHandleInfo[] = { @@ -61,6 +64,8 @@ const AFX_HANDLEINFO afxHandleInfo[] = { offsetof(RECT, left), offsetof(RECT, top), 0, 1, 0, 0, 5, 7 } }; +namespace { + // the struct below gives us information on the layout of a RECT struct and // the relationship between its members struct AFX_RECTINFO @@ -69,6 +74,8 @@ struct AFX_RECTINFO int nSignAcross; // sign relative to that point (ie. add/subtract) }; +} + // this array is indexed by the offset of the RECT member / sizeof(int) const AFX_RECTINFO afxRectInfo[] = { diff --git a/embedserv/source/inprocserv/dllentry.cxx b/embedserv/source/inprocserv/dllentry.cxx index f5e46e12fbe2..78b7d18edf0a 100644 --- a/embedserv/source/inprocserv/dllentry.cxx +++ b/embedserv/source/inprocserv/dllentry.cxx @@ -132,6 +132,8 @@ namespace { namespace inprocserv { +namespace { + class InprocEmbedProvider_Impl : public IClassFactory, public InprocCountedObject_Impl { public: @@ -153,6 +155,9 @@ protected: ULONG m_refCount; GUID m_guid; }; + +} + }; // namespace inprocserv diff --git a/extensions/source/activex/SOActiveX.cxx b/extensions/source/activex/SOActiveX.cxx index 2c6c4365a339..489fd6b363b1 100644 --- a/extensions/source/activex/SOActiveX.cxx +++ b/extensions/source/activex/SOActiveX.cxx @@ -151,7 +151,7 @@ CSOActiveX::CSOActiveX() , mpDispatchInterceptor( nullptr ) , mnVersion( SO_NOT_DETECTED ) , mbReadyForActivation( FALSE ) -, mbDrawLocked( FALSE ) +, mbDrawLocked( false ) { CLSID const clsFactory = {0x82154420,0x0FBF,0x11d4,{0x83, 0x13,0x00,0x50,0x04,0x52,0x6A,0xB4}}; HRESULT hr = CoCreateInstance( clsFactory, nullptr, CLSCTX_ALL, __uuidof(IDispatch), reinterpret_cast<void**>(&mpDispFactory)); @@ -948,22 +948,26 @@ SOVersion CSOActiveX::GetVersionConnected() return bResult; } +namespace { + class LockingGuard { - BOOL& mbLocked; + bool& mbLocked; public: - explicit LockingGuard( BOOL& bLocked ) + explicit LockingGuard( bool& bLocked ) : mbLocked( bLocked ) { - mbLocked = TRUE; + mbLocked = true; } ~LockingGuard() { - mbLocked = FALSE; + mbLocked = false; } }; +} + HRESULT CSOActiveX::OnDrawAdvanced( ATL_DRAWINFO& di ) { // This method is called only in main thread, no need to lock it diff --git a/extensions/source/activex/SOActiveX.h b/extensions/source/activex/SOActiveX.h index d55820be163b..719bce5d4271 100644 --- a/extensions/source/activex/SOActiveX.h +++ b/extensions/source/activex/SOActiveX.h @@ -95,7 +95,7 @@ protected: BOOL mbReadyForActivation; CComPtr<IDispatch> mpDispTempFile; - BOOL mbDrawLocked; + bool mbDrawLocked; public: CSOActiveX(); diff --git a/extensions/source/ole/ole2uno.cxx b/extensions/source/ole/ole2uno.cxx index 4899a2df11d4..f9eef5125e69 100644 --- a/extensions/source/ole/ole2uno.cxx +++ b/extensions/source/ole/ole2uno.cxx @@ -24,6 +24,8 @@ using namespace osl; +namespace { + struct MutexInit { Mutex * operator () () @@ -33,6 +35,7 @@ struct MutexInit } }; +} Mutex * getBridgeMutex() { diff --git a/extensions/source/ole/unoobjw.cxx b/extensions/source/ole/unoobjw.cxx index 436feb3097e9..5a10e03dcbea 100644 --- a/extensions/source/ole/unoobjw.cxx +++ b/extensions/source/ole/unoobjw.cxx @@ -116,6 +116,8 @@ static bool writeBackOutParameter(VARIANTARG* pDest, VARIANT* pSource); static bool writeBackOutParameter2( VARIANTARG* pDest, VARIANT* pSource); static HRESULT mapCannotConvertException(const CannotConvertException &e, unsigned int * puArgErr); +namespace { + class TerminationVetoer : public WeakImplHelper<css::frame::XTerminateListener> { public: @@ -171,6 +173,8 @@ public: } }; +} + /* Does not throw any exceptions. Param pInfo can be NULL. */ @@ -316,6 +320,8 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP InterfaceOleWrapper::GetTypeInfoCount( UINT *p return S_OK; } +namespace { + class CXTypeInfo : public ITypeInfo, public CComObjectRoot { @@ -592,6 +598,8 @@ private: Reference<XMultiServiceFactory> mxMSF; }; +} + void CXTypeInfo::InitForCoclass(Reference<XInterface> xOrigin, const OUString& sImplementationName, const IID& rIID, @@ -2204,6 +2212,8 @@ HRESULT InterfaceOleWrapper::doSetProperty( DISPPARAMS * /*pdispparams*/, VARIAN return ret; } +namespace { + class CXEnumVariant : public IEnumVARIANT, public CComObjectRoot { @@ -2353,6 +2363,8 @@ private: InterfaceOleWrapper* mpInterfaceOleWrapper; }; +} + Sink::Sink(IUnknown* pUnkSink, Reference<XMultiServiceFactory> xMSF, ooo::vba::TypeAndIID aTypeAndIID, @@ -2535,6 +2547,8 @@ Sink::Call( const OUString& Method, Sequence< Any >& Arguments ) SAL_WARN("extensions.olebridge", "Sink::Call: Unknown method '" << Method << "'"); } +namespace { + class CXEnumConnections : public IEnumConnections, public CComObjectRoot { @@ -2794,6 +2808,8 @@ public: ooo::vba::TypeAndIID maTypeAndIID; }; +} + HRESULT InterfaceOleWrapper::InvokeGeneral( DISPID dispidMember, unsigned short wFlags, DISPPARAMS * pdispparams, VARIANT * pvarResult, EXCEPINFO * pexcepinfo, unsigned int * /*puArgErr*/, bool& bHandled) diff --git a/extensions/source/update/check/download.cxx b/extensions/source/update/check/download.cxx index 73e79bcf851d..a40b7b1c5367 100644 --- a/extensions/source/update/check/download.cxx +++ b/extensions/source/update/check/download.cxx @@ -33,6 +33,7 @@ namespace container = com::sun::star::container ; namespace lang = com::sun::star::lang ; namespace uno = com::sun::star::uno ; +namespace { struct OutData { @@ -47,6 +48,7 @@ struct OutData explicit OutData(osl::Condition& rCondition) : FileHandle(nullptr), Offset(0), StopCondition(rCondition), curl(nullptr) {}; }; +} static void openFile( OutData& out ) { diff --git a/fpicker/source/win32/VistaFilePickerEventHandler.cxx b/fpicker/source/win32/VistaFilePickerEventHandler.cxx index b9ac5a3d28b8..66b12fd015de 100644 --- a/fpicker/source/win32/VistaFilePickerEventHandler.cxx +++ b/fpicker/source/win32/VistaFilePickerEventHandler.cxx @@ -233,6 +233,7 @@ void VistaFilePickerEventHandler::stopListening() static const char PROP_CONTROL_ID[] = "control_id"; static const char PROP_PICKER_LISTENER[] = "picker_listener"; +namespace { class AsyncPickerEvents : public RequestHandler { @@ -286,6 +287,7 @@ public: {} }; +} void VistaFilePickerEventHandler::impl_sendEvent( EEventType eEventType, ::sal_Int16 nControlID) diff --git a/fpicker/source/win32/resourceprovider.cxx b/fpicker/source/win32/resourceprovider.cxx index cab15018ca84..883edf36dff2 100644 --- a/fpicker/source/win32/resourceprovider.cxx +++ b/fpicker/source/win32/resourceprovider.cxx @@ -41,12 +41,16 @@ using namespace ::com::sun::star::ui::dialogs::CommonFilePickerElementIds; // we have to translate control ids to resource ids +namespace { + struct Entry { sal_Int32 ctrlId; const char* resId; }; +} + Entry const CtrlIdToResIdTable[] = { { CHECKBOX_AUTOEXTENSION, STR_SVT_FILEPICKER_AUTO_EXTENSION }, { CHECKBOX_PASSWORD, STR_SVT_FILEPICKER_PASSWORD }, diff --git a/sal/osl/w32/file.cxx b/sal/osl/w32/file.cxx index c39c2f16c860..3492ce874550 100644 --- a/sal/osl/w32/file.cxx +++ b/sal/osl/w32/file.cxx @@ -41,6 +41,8 @@ #undef min #endif +namespace { + /** File handle implementation. */ struct FileHandle_Impl @@ -132,6 +134,8 @@ struct FileHandle_Impl }; }; +} + FileHandle_Impl::Guard::Guard(LPCRITICAL_SECTION pMutex) : m_mutex (pMutex) { diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx index 773b18679f01..d581e1536595 100644 --- a/sal/osl/w32/file_dirvol.cxx +++ b/sal/osl/w32/file_dirvol.cxx @@ -221,6 +221,8 @@ oslFileError SAL_CALL osl_getVolumeDeviceMountPath( oslVolumeDeviceHandle Handle #define DIRECTORYITEM_FILE 1 #define DIRECTORYITEM_SERVER 2 +namespace { + struct DirectoryItem_Impl { UINT uType; @@ -229,14 +231,18 @@ struct DirectoryItem_Impl WCHAR cDriveString[MAX_PATH]; }; rtl_uString* m_pFullPath; - BOOL bFullPathNormalized; + bool bFullPathNormalized; int nRefCount; }; +} + #define DIRECTORYTYPE_LOCALROOT 0 #define DIRECTORYTYPE_NETROOT 1 #define DIRECTORYTYPE_FILESYSTEM 3 +namespace { + struct Directory_Impl { UINT uType; @@ -254,6 +260,8 @@ typedef struct tagDRIVEENUM LPCWSTR lpCurrent; } DRIVEENUM, * PDRIVEENUM, FAR * LPDRIVEENUM; +} + static HANDLE WINAPI OpenLogicalDrivesEnum() { LPDRIVEENUM pEnum = static_cast<LPDRIVEENUM>(HeapAlloc( GetProcessHeap(), 0, sizeof(DRIVEENUM) )); @@ -315,12 +323,16 @@ static bool WINAPI CloseLogicalDrivesEnum(HANDLE hEnum) return fSuccess; } +namespace { + typedef struct tagDIRECTORY { HANDLE hFind; WIN32_FIND_DATAW aFirstData; } DIRECTORY, *PDIRECTORY, FAR *LPDIRECTORY; +} + static HANDLE WINAPI OpenDirectory( rtl_uString* pPath) { LPDIRECTORY pDirectory = nullptr; @@ -878,7 +890,7 @@ static oslFileError osl_getNextFileItem( rtl_uString_newConcat( &pItemImpl->m_pFullPath, pDirImpl->m_pDirectoryPath, pTmpFileName ); rtl_uString_release( pTmpFileName ); - pItemImpl->bFullPathNormalized = FALSE; + pItemImpl->bFullPathNormalized = false; *pItem = static_cast<oslDirectoryItem>(pItemImpl); return osl_File_E_None; } @@ -1677,7 +1689,7 @@ oslFileError SAL_CALL osl_getFileStatus( { rtl_uString_newFromStr( &pItemImpl->m_pFullPath, aBuffer ); sFullPath = OUString( pItemImpl->m_pFullPath ); - pItemImpl->bFullPathNormalized = TRUE; + pItemImpl->bFullPathNormalized = true; } } diff --git a/sal/osl/w32/file_error.cxx b/sal/osl/w32/file_error.cxx index 27b0f90cbd2d..c9f8b8a3cc3e 100644 --- a/sal/osl/w32/file_error.cxx +++ b/sal/osl/w32/file_error.cxx @@ -20,6 +20,8 @@ #include "file_error.hxx" #include <winerror.h> +namespace { + /* OS error to oslFileError values mapping table */ struct osl_file_error_entry { @@ -27,6 +29,8 @@ struct osl_file_error_entry int errnocode; /* oslFileError code */ }; +} + static const struct osl_file_error_entry errtable[] = { { ERROR_SUCCESS, osl_File_E_None }, /* 0 */ { ERROR_INVALID_FUNCTION, osl_File_E_INVAL }, /* 1 */ diff --git a/sal/osl/w32/nlsupport.cxx b/sal/osl/w32/nlsupport.cxx index 10888b9d6915..e253cc0cb7e8 100644 --- a/sal/osl/w32/nlsupport.cxx +++ b/sal/osl/w32/nlsupport.cxx @@ -41,6 +41,8 @@ #define ELP_LANGUAGE_FIELD_LENGTH 4 #define ELP_COUNTRY_FIELD_LENGTH 3 +namespace { + /** Struct used in EnumLocalesProcW() called via EnumSystemLocalesW() to obtain available locales. */ @@ -51,6 +53,8 @@ struct EnumLocalesParams LCID Locale; }; +} + static DWORD g_dwTLSLocaleEncId = DWORD(-1); /***************************************************************************** diff --git a/sal/osl/w32/pipe.cxx b/sal/osl/w32/pipe.cxx index 89463b899d72..7eef4a99d021 100644 --- a/sal/osl/w32/pipe.cxx +++ b/sal/osl/w32/pipe.cxx @@ -36,6 +36,8 @@ #define PIPESYSTEM "\\\\.\\pipe\\" #define PIPEPREFIX "OSL_PIPE_" +namespace { + typedef struct { sal_uInt32 m_Size; @@ -45,6 +47,8 @@ typedef struct } oslPipeBuffer; +} + struct oslPipeImpl { oslInterlockedCount m_Reference; diff --git a/sal/osl/w32/process.cxx b/sal/osl/w32/process.cxx index f235fc5a572c..d052aa15e72e 100644 --- a/sal/osl/w32/process.cxx +++ b/sal/osl/w32/process.cxx @@ -302,14 +302,14 @@ oslProcessError bootstrap_getExecutableFile(rtl_uString ** ppFileURL) return result; } -} - struct CommandArgs_Impl { sal_uInt32 m_nCount; rtl_uString ** m_ppArgs; }; +} + static struct CommandArgs_Impl g_command_args = { 0, diff --git a/sal/osl/w32/profile.cxx b/sal/osl/w32/profile.cxx index e35f48c2dfee..e095da62ccad 100644 --- a/sal/osl/w32/profile.cxx +++ b/sal/osl/w32/profile.cxx @@ -81,8 +81,6 @@ enum osl_TLockMode un_lock, read_lock, write_lock }; -} - struct osl_TFile { HANDLE m_Handle; @@ -127,6 +125,8 @@ struct osl_TProfileImpl osl_TProfileSection* m_Sections; }; +} + static osl_TFile* openFileImpl(rtl_uString * strFileName, oslProfileOption ProfileFlags ); static osl_TStamp closeFileImpl(osl_TFile* pFile); static bool lockFile(const osl_TFile* pFile, osl_TLockMode eMode); diff --git a/sal/osl/w32/socket.cxx b/sal/osl/w32/socket.cxx index 3bee3ecde178..e37910f5fd14 100644 --- a/sal/osl/w32/socket.cxx +++ b/sal/osl/w32/socket.cxx @@ -219,6 +219,9 @@ static oslSocketError osl_SocketErrorFromNative(int nativeType) #if OSL_DEBUG_LEVEL > 0 static sal_uInt32 g_nSocketAddr = 0; + +namespace { + struct LeakWarning { ~LeakWarning() @@ -226,6 +229,9 @@ struct LeakWarning SAL_WARN_IF( g_nSocketAddr, "sal.osl", "sal_socket: " << g_nSocketAddr << " socket address instances leak" ); } }; + +} + static LeakWarning socketWarning; #endif diff --git a/sal/osl/w32/thread.cxx b/sal/osl/w32/thread.cxx index b9eccf3b8bab..19479de033cd 100644 --- a/sal/osl/w32/thread.cxx +++ b/sal/osl/w32/thread.cxx @@ -28,6 +28,8 @@ #include <rtl/tencinfo.h> #include <errno.h> +namespace { + /** Thread-data structure hidden behind oslThread: */ @@ -41,6 +43,8 @@ typedef struct } osl_TThreadImpl; +} + static unsigned __stdcall oslWorkerWrapperFunction(void* pData); static oslThread oslCreateThread(oslWorkerFunction pWorker, void* pThreadData, sal_uInt32 nFlags); @@ -378,6 +382,8 @@ void SAL_CALL osl_setThreadName(char const * name) { #endif } +namespace { + typedef struct TLS_ { DWORD dwIndex; @@ -385,6 +391,8 @@ typedef struct TLS_ struct TLS_ *pNext, *pPrev; } TLS, *PTLS; +} + static PTLS g_pThreadKeyList = nullptr; CRITICAL_SECTION g_ThreadKeyListCS; diff --git a/sal/qa/systools/test_comtools.cxx b/sal/qa/systools/test_comtools.cxx index 096851c9e989..694a4a665b09 100644 --- a/sal/qa/systools/test_comtools.cxx +++ b/sal/qa/systools/test_comtools.cxx @@ -21,6 +21,8 @@ #include <cppunit/plugin/TestPlugIn.h> #include <systools/win32/comtools.hxx> +namespace { + class COMObject : public IUnknown { public: @@ -66,6 +68,8 @@ private: ULONG ref_count_; }; +} + static sal::systools::COMReference<IUnknown> comObjectSource() { return sal::systools::COMReference<IUnknown>(new COMObject); diff --git a/sal/rtl/uri.cxx b/sal/rtl/uri.cxx index 592b92c88525..d7da7d48d43d 100644 --- a/sal/rtl/uri.cxx +++ b/sal/rtl/uri.cxx @@ -1,3 +1,4 @@ +#include<optional> /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. diff --git a/sfx2/source/appl/appdde.cxx b/sfx2/source/appl/appdde.cxx index a65f087d9e26..e3cfa2494adf 100644 --- a/sfx2/source/appl/appdde.cxx +++ b/sfx2/source/appl/appdde.cxx @@ -61,6 +61,8 @@ static OUString SfxDdeServiceName_Impl( const OUString& sIn ) return sReturn.makeStringAndClear(); } +namespace { + class ImplDdeService : public DdeService { public: @@ -74,9 +76,6 @@ public: virtual bool SysTopicExecute( const OUString* pStr ); }; - -namespace -{ bool lcl_IsDocument( const OUString& rContent ) { using namespace com::sun::star; diff --git a/sfx2/source/appl/shutdowniconw32.cxx b/sfx2/source/appl/shutdowniconw32.cxx index c056db166f51..2540b2c79eb5 100644 --- a/sfx2/source/appl/shutdowniconw32.cxx +++ b/sfx2/source/appl/shutdowniconw32.cxx @@ -80,6 +80,8 @@ static HMENU popupMenu = nullptr; static void OnMeasureItem(HWND hwnd, LPMEASUREITEMSTRUCT lpmis); static void OnDrawItem(HWND hwnd, LPDRAWITEMSTRUCT lpdis); +namespace { + typedef struct tagMYITEM { OUString text; @@ -87,6 +89,7 @@ typedef struct tagMYITEM UINT iconId; } MYITEM; +} static void addMenuItem( HMENU hMenu, UINT id, UINT iconId, const OUString& text, int& pos, bool bOwnerdraw, const OUString& module ) { diff --git a/shell/source/backends/wininetbe/wininetbackend.cxx b/shell/source/backends/wininetbe/wininetbackend.cxx index 7bc211747ec2..0a89b18507d7 100644 --- a/shell/source/backends/wininetbe/wininetbackend.cxx +++ b/shell/source/backends/wininetbe/wininetbackend.cxx @@ -46,17 +46,12 @@ struct Library { ~Library() { if (module) FreeLibrary(module); } }; -} - struct ProxyEntry { OUString Server; OUString Port; }; - -namespace -{ ProxyEntry ReadProxyEntry(const OUString& aProxy, sal_Int32& i) { ProxyEntry aProxyEntry; diff --git a/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx b/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx index 80f1d3bc2555..ae547afd2973 100644 --- a/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx +++ b/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx @@ -39,6 +39,8 @@ long g_DllRefCnt = 0; static HINSTANCE g_hModule = nullptr; +namespace { + // Map of property keys to the locations of their value(s) in the .??? XML schema struct PROPERTYMAP { @@ -47,6 +49,8 @@ struct PROPERTYMAP PCWSTR pszValueNodeName; }; +} + const PROPERTYMAP g_rgPROPERTYMAP[] = { { PKEY_Title, L"LibreOffice", L"Title" }, diff --git a/shell/source/win32/shlxthandler/thumbviewer/thumbviewer.cxx b/shell/source/win32/shlxthandler/thumbviewer/thumbviewer.cxx index 4ea6f7e06577..484b7236f3e0 100644 --- a/shell/source/win32/shlxthandler/thumbviewer/thumbviewer.cxx +++ b/shell/source/win32/shlxthandler/thumbviewer/thumbviewer.cxx @@ -95,8 +95,6 @@ Gdiplus::Rect CalcScaledAspectRatio(const Gdiplus::Rect& src, const Gdiplus::Rec return result; } -} - class StreamOnZipBuffer final : public IStream { public: @@ -126,6 +124,8 @@ private: size_t pos_; }; +} + StreamOnZipBuffer::StreamOnZipBuffer(const ZipFile::ZipContentBuffer_t& zip_buffer) : ref_count_(1), ref_zip_buffer_(zip_buffer), diff --git a/shell/source/win32/zipfile/zipfile.cxx b/shell/source/win32/zipfile/zipfile.cxx index 13f79a041018..1462c161a900 100644 --- a/shell/source/win32/zipfile/zipfile.cxx +++ b/shell/source/win32/zipfile/zipfile.cxx @@ -323,6 +323,9 @@ bool isZipStream(StreamInterface *stream) namespace internal { + +namespace { + /* for case in-sensitive string comparison */ struct stricmp { @@ -336,6 +339,9 @@ struct stricmp std::string str_; }; + +} + } // namespace internal /** Checks whether a file is a zip file or not diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx index c47de25b19f3..d736cfc08972 100644 --- a/vcl/opengl/win/gdiimpl.cxx +++ b/vcl/opengl/win/gdiimpl.cxx @@ -25,6 +25,8 @@ static std::vector<HGLRC> g_vShareList; static bool g_bAnyCurrent; +namespace { + class GLWinWindow : public GLWindow { public: @@ -34,6 +36,8 @@ public: GLWinWindow(); }; +} + GLWinWindow::GLWinWindow() : hWnd(nullptr) , hDC(nullptr) @@ -41,6 +45,8 @@ GLWinWindow::GLWinWindow() { } +namespace { + class WinOpenGLContext : public OpenGLContext { public: @@ -59,6 +65,8 @@ private: virtual void swapBuffers() override; }; +} + void WinOpenGLContext::swapBuffers() { OpenGLZone aZone; diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx index 1915fb6f6b97..43cc8e8e6a85 100644 --- a/vcl/win/app/salinst.cxx +++ b/vcl/win/app/salinst.cxx @@ -665,12 +665,16 @@ LRESULT CALLBACK SalComWndProcW( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lPa return nRet; } +namespace { + struct MsgRange { UINT nStart; UINT nEnd; }; +} + static std::vector<MsgRange> GetOtherRanges( VclInputFlags nType ) { assert( nType != VCL_INPUT_ANY ); diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx index 9b7c8bdaebd4..05c1037bcbe1 100644 --- a/vcl/win/gdi/gdiimpl.cxx +++ b/vcl/win/gdi/gdiimpl.cxx @@ -1972,6 +1972,8 @@ static void impAddB2DPolygonToGDIPlusGraphicsPathReal( } } +namespace { + class SystemDependentData_GraphicsPath : public basegfx::SystemDependentData { private: @@ -1997,6 +1999,8 @@ public: virtual sal_Int64 estimateUsageInBytes() const override; }; +} + SystemDependentData_GraphicsPath::SystemDependentData_GraphicsPath( basegfx::SystemDependentDataManager& rSystemDependentDataManager, std::shared_ptr<Gdiplus::GraphicsPath>& rpGraphicsPath, diff --git a/vcl/win/gdi/salbmp.cxx b/vcl/win/gdi/salbmp.cxx index 128f786381e0..d891965e57ee 100644 --- a/vcl/win/gdi/salbmp.cxx +++ b/vcl/win/gdi/salbmp.cxx @@ -95,6 +95,8 @@ void WinSalBitmap::Destroy() mnBitCount = 0; } +namespace { + class SystemDependentData_GdiPlusBitmap : public basegfx::SystemDependentData { private: @@ -113,6 +115,8 @@ public: virtual sal_Int64 estimateUsageInBytes() const override; }; +} + SystemDependentData_GdiPlusBitmap::SystemDependentData_GdiPlusBitmap( basegfx::SystemDependentDataManager& rSystemDependentDataManager, const std::shared_ptr<Gdiplus::Bitmap>& rGdiPlusBitmap, diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index ec122f48e41a..323b6af952e9 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -79,6 +79,8 @@ static int IntTimes256FromFixed(FIXED f) return nFixedTimes256; } +namespace { + // raw font data with a scoped lifetime class RawFontData { @@ -93,6 +95,8 @@ private: unsigned mnByteCount; }; +} + RawFontData::RawFontData( HDC hDC, DWORD nTableTag ) : mnByteCount( 0 ) { @@ -145,6 +149,8 @@ RawFontData::RawFontData( HDC hDC, DWORD nTableTag ) // platform specific font substitution hooks for glyph fallback enhancement +namespace { + class WinPreMatchFontSubstititution : public ImplPreMatchFontSubstitution { @@ -172,6 +178,8 @@ private: bool HasMissingChars(PhysicalFontFace*, OUString& rMissingChars) const; }; +} + // does a font face hold the given missing characters? bool WinGlyphFallbackSubstititution::HasMissingChars(PhysicalFontFace* pFace, OUString& rMissingChars) const { @@ -338,6 +346,8 @@ bool WinGlyphFallbackSubstititution::FindFontSubstitute(FontSelectPattern& rFont return bFound; } +namespace { + struct ImplEnumInfo { HDC mhDC; @@ -348,6 +358,8 @@ struct ImplEnumInfo int mnFontCount; }; +} + static rtl_TextEncoding ImplCharSetToSal( BYTE nCharSet ) { rtl_TextEncoding eTextEncoding; @@ -1513,6 +1525,8 @@ ScopedFont::~ScopedFont() } } +namespace { + class ScopedTrueTypeFont { public: @@ -1528,6 +1542,8 @@ private: TrueTypeFont * m_pFont; }; +} + ScopedTrueTypeFont::~ScopedTrueTypeFont() { if (m_pFont != nullptr) diff --git a/vcl/win/gdi/salnativewidgets-luna.cxx b/vcl/win/gdi/salnativewidgets-luna.cxx index d0d0a07b8105..4b4cd9cf3cd6 100644 --- a/vcl/win/gdi/salnativewidgets-luna.cxx +++ b/vcl/win/gdi/salnativewidgets-luna.cxx @@ -64,6 +64,8 @@ static ThemeMap aThemeMap; it is not available on all Windows platforms *****************************************************/ +namespace { + class VisualStylesAPI { private: @@ -95,9 +97,11 @@ public: HRESULT DrawThemeBackground( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect ); HRESULT DrawThemeText( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect ); HRESULT GetThemePartSize( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, RECT *prc, THEMESIZE eSize, SIZE *psz ); - BOOL IsThemeActive(); + bool IsThemeActive(); }; +} + static VisualStylesAPI vsAPI; VisualStylesAPI::VisualStylesAPI() @@ -178,12 +182,12 @@ HRESULT VisualStylesAPI::GetThemePartSize( HTHEME hTheme, HDC hdc, int iPartId, return S_FALSE; } -BOOL VisualStylesAPI::IsThemeActive() +bool VisualStylesAPI::IsThemeActive() { if(lpfnIsThemeActive) return (*lpfnIsThemeActive) (); else - return FALSE; + return false; } /********************************************************* diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx index 7b8f5df30180..935aeb84d2a4 100644 --- a/vcl/win/gdi/winlayout.cxx +++ b/vcl/win/gdi/winlayout.cxx @@ -345,6 +345,8 @@ float WinFontInstance::getHScale() const return nWidth / nHeight; } +namespace { + struct BlobReference { hb_blob_t* mpBlob; @@ -359,7 +361,13 @@ struct BlobReference } ~BlobReference() { hb_blob_destroy(mpBlob); } }; + +} + using BlobCacheKey = std::pair<rtl::Reference<PhysicalFontFace>, hb_tag_t>; + +namespace { + struct BlobCacheKeyHash { std::size_t operator()(BlobCacheKey const& rKey) const @@ -371,6 +379,8 @@ struct BlobCacheKeyHash } }; +} + static hb_blob_t* getFontTable(hb_face_t* /*face*/, hb_tag_t nTableTag, void* pUserData) { static o3tl::lru_map<BlobCacheKey, BlobReference, BlobCacheKeyHash> gCache(50); diff --git a/vcl/win/window/keynames.cxx b/vcl/win/window/keynames.cxx index 6ca192ba7d5c..0d4f12f82cb8 100644 --- a/vcl/win/window/keynames.cxx +++ b/vcl/win/window/keynames.cxx @@ -51,6 +51,8 @@ namespace vcl_sal { + namespace { + struct KeysNameReplacement { LONG aSymbol; @@ -64,6 +66,8 @@ namespace vcl_sal { int nReplacements; }; + } + // CAUTION CAUTION CAUTION // Every string value in the replacements tables must be in UTF-8 // but with the UTF-8 bytes encoded, not as such! Be careful! diff --git a/winaccessibility/source/UAccCOM/MAccessible.cxx b/winaccessibility/source/UAccCOM/MAccessible.cxx index 6a3b32849f73..dde93ec9f18d 100644 --- a/winaccessibility/source/UAccCOM/MAccessible.cxx +++ b/winaccessibility/source/UAccCOM/MAccessible.cxx @@ -2560,6 +2560,8 @@ createAggInstance(CMAccessible &rOuter, void ** ppvObject) typedef HRESULT (AggCreatorFunc)(CMAccessible &, void **); +namespace { + struct AggMapEntry { const IID* piid; @@ -2567,6 +2569,8 @@ struct AggMapEntry int XIFIndex; }; +} + static AggMapEntry g_CMAccessible_AggMap[] = { { &IID_IAccessibleComponent, &createAggInstance<CAccComponent>, XI_COMPONENT }, { &IID_IAccessibleText, &createAggInstance<CAccText>, XI_TEXT }, diff --git a/winaccessibility/source/service/msaaservice_impl.cxx b/winaccessibility/source/service/msaaservice_impl.cxx index 15959e2b4c83..02ac891f5d4b 100644 --- a/winaccessibility/source/service/msaaservice_impl.cxx +++ b/winaccessibility/source/service/msaaservice_impl.cxx @@ -57,6 +57,8 @@ static OUString getImplementationName_MSAAServiceImpl() return "com.sun.star.accessibility.my_sc_implementation.MSAAService"; } +namespace { + class MSAAServiceImpl : public ::cppu::WeakImplHelper< XMSAAService, lang::XServiceInfo > { @@ -84,6 +86,8 @@ public: virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() override; }; +} + /** * Implementation of getAccObjectPtr. * @param diff --git a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx index a0c47b9c443c..e1e7b8d12760 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx @@ -58,11 +58,15 @@ using ::com::sun::star::security::XCertificate ; static X509Certificate_MSCryptImpl* MswcryCertContextToXCert( PCCERT_CONTEXT cert ) ; +namespace { + struct CertErrorToString{ DWORD error; char const * name; }; +} + CertErrorToString const arErrStrings[] = { { 0x00000000, "CERT_TRUST_NO_ERROR"}, diff --git a/xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.cxx index 91dbbc32b6c5..4aefafa30a32 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.cxx @@ -34,6 +34,8 @@ using ::com::sun::star::lang::XSingleServiceFactory ; using ::com::sun::star::xml::crypto::XSecurityEnvironment ; using ::com::sun::star::xml::crypto::XXMLSecurityContext ; +namespace { + class XMLSecurityContext_MSCryptImpl : public ::cppu::WeakImplHelper< css::xml::crypto::XXMLSecurityContext , css::lang::XServiceInfo > @@ -75,6 +77,8 @@ class XMLSecurityContext_MSCryptImpl : public ::cppu::WeakImplHelper< virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; }; +} + XMLSecurityContext_MSCryptImpl::XMLSecurityContext_MSCryptImpl() { } diff --git a/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx index a0acd81786d7..43f294ba5a10 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx @@ -46,6 +46,8 @@ using ::com::sun::star::xml::crypto::XXMLSignatureTemplate ; using ::com::sun::star::xml::crypto::XXMLSecurityContext ; using ::com::sun::star::xml::crypto::XUriBinding ; +namespace { + class XMLSignature_MSCryptImpl : public ::cppu::WeakImplHelper< css::xml::crypto::XXMLSignature , css::lang::XServiceInfo > @@ -74,6 +76,8 @@ class XMLSignature_MSCryptImpl : public ::cppu::WeakImplHelper< virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; } ; +} + XMLSignature_MSCryptImpl::XMLSignature_MSCryptImpl() { } |