1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_TOOLS_DEBUG_HXX
20 #define INCLUDED_TOOLS_DEBUG_HXX
22 #include <tools/toolsdllapi.h>
24 #include <sal/detail/log.h>
25 #include <sal/types.h>
27 /** The facilities provided by this header are deprecated. True assertions
28 (that detect broken program logic) should use standard assert (which aborts
29 if an assertion fails, and is controlled by the standard NDEBUG macro).
30 Logging of warnings (e.g., about malformed input) should use the facilities
31 provided by sal/log.hxx.
33 Because the assertion macro (DBG_ASSERT) has been used for
34 true assertions as well as to log warnings, it maps to SAL_WARN instead of
35 standard assert. The warning and error macros (DBG_ASSERTWARNING,
36 DBG_WARNING) all map to
42 typedef void (*DbgTestSolarMutexProc
)();
44 #define DBG_TEST_RESOURCE (0x02000000)
45 #define DBG_TEST_DIALOG (0x04000000)
46 #define DBG_TEST_BOLDAPPFONT (0x08000000)
50 sal_uIntPtr nTestFlags
;
51 sal_Char aDbgWinState
[50]; // DbgGUIData for VCL
55 #define DBG_FUNC_GETDATA 0
56 #define DBG_FUNC_SAVEDATA 1
57 #define DBG_FUNC_SETTESTSOLARMUTEX 2
58 #define DBG_FUNC_TESTSOLARMUTEX 3
60 TOOLS_DLLPUBLIC
void* DbgFunc( sal_uInt16 nAction
, void* pData
= NULL
);
62 inline DbgData
* DbgGetData()
64 return static_cast<DbgData
*>(DbgFunc( DBG_FUNC_GETDATA
));
67 inline void DbgSaveData( const DbgData
& rData
)
69 DbgFunc( DBG_FUNC_SAVEDATA
, (void*)&rData
);
72 inline bool DbgIsResource()
74 DbgData
* pData
= DbgGetData();
76 return pData
->nTestFlags
& DBG_TEST_RESOURCE
;
81 inline bool DbgIsDialog()
83 DbgData
* pData
= DbgGetData();
85 return pData
->nTestFlags
& DBG_TEST_DIALOG
;
90 inline bool DbgIsBoldAppFont()
92 DbgData
* pData
= DbgGetData();
94 return pData
->nTestFlags
& DBG_TEST_BOLDAPPFONT
;
99 inline void DbgSetTestSolarMutex( DbgTestSolarMutexProc pProc
)
101 DbgFunc( DBG_FUNC_SETTESTSOLARMUTEX
, reinterpret_cast<void*>(reinterpret_cast<sal_uIntPtr
>(pProc
)) );
104 #define DBG_ASSERTWARNING( sCon, aWarning ) \
105 SAL_DETAIL_INFO_IF_FORMAT(!(sCon), "legacy.tools", "%s", aWarning)
107 #define DBG_ASSERT( sCon, aError ) \
108 SAL_DETAIL_WARN_IF_FORMAT(!(sCon), "legacy.tools", "%s", aError)
110 #define DBG_WARNING( aWarning ) \
111 SAL_DETAIL_INFO_IF_FORMAT(true, "legacy.tools", "%s", aWarning)
113 #define DBG_TESTSOLARMUTEX() \
116 DbgFunc(DBG_FUNC_TESTSOLARMUTEX); \
122 #define DBG_ASSERTWARNING( sCon, aWarning ) ((void)0)
123 #define DBG_ASSERT( sCon, aError ) ((void)0)
124 #define DBG_WARNING( aWarning ) ((void)0)
126 #define DBG_TESTSOLARMUTEX() ((void)0)
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */