xref: /aoo41x/main/sw/inc/dbgoutsw.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef __DBGOUTSW_HXX
28 #define __DBGOUTSW_HXX
29 
30 #ifdef DEBUG
31 
32 #include <hash_map>
33 #include <tox.hxx>
34 class String;
35 
36 namespace rtl
37 {
38 class OUString;
39 }
40 class SwNode;
41 class SwTxtAttr;
42 class SwpHints;
43 class SfxPoolItem;
44 class SfxItemSet;
45 struct SwPosition;
46 class SwPaM;
47 class SwNodeNum;
48 class SwUndo;
49 class SwRect;
50 class SwFrmFmt;
51 class SwFrmFmts;
52 class SwNodes;
53 class SwRewriter;
54 class SwNumRuleTbl;
55 class SwNumRule;
56 class SwOutlineNodes;
57 class SwTxtFmtColl;
58 class SwNodeRange;
59 
60 #define DBG_OUT_HERE printf("%s(%d):", __FILE__, __LINE__)
61 #define DBG_OUT_HERE_FN printf("%s(%d) %s:", __FILE__, __LINE__, __FUNCTION__)
62 #define DBG_OUT_HERE_LN printf("%s(%d)\n", __FILE__, __LINE__)
63 #define DBG_OUT_HERE_FN_LN printf("%s(%d) %s\n", __FILE__, __LINE__, __FUNCTION__)
64 #define DBG_OUT(x) printf("%s\n", dbg_out(x))
65 #define DBG_OUT_LN(x) printf("%s(%d): %s\n", __FILE__, __LINE__, dbg_out(x))
66 #define DBG_OUT_FN_LN(x) printf("%s: %s\n", __FUNCTION__, dbg_out(x))
67 
68 extern bool bDbgOutStdErr;
69 extern bool bDbgOutPrintAttrSet;
70 
71 SW_DLLPUBLIC const char * dbg_out(const void * pVoid);
72 SW_DLLPUBLIC const char * dbg_out(const String & aStr);
73 SW_DLLPUBLIC const char * dbg_out(const ::rtl::OUString & aStr);
74 SW_DLLPUBLIC const char * dbg_out(const SwRect & rRect);
75 SW_DLLPUBLIC const char * dbg_out(const SwFrmFmt & rFrmFmt);
76 SW_DLLPUBLIC const char * dbg_out(const SwNode & rNode);
77 SW_DLLPUBLIC const char * dbg_out(const SwTxtAttr & rAttr);
78 SW_DLLPUBLIC const char * dbg_out(const SwpHints &rHints);
79 SW_DLLPUBLIC const char * dbg_out(const SfxPoolItem & rItem);
80 SW_DLLPUBLIC const char * dbg_out(const SfxPoolItem * pItem);
81 SW_DLLPUBLIC const char * dbg_out(const SfxItemSet & rSet);
82 SW_DLLPUBLIC const char * dbg_out(SwNodes & rNodes);
83 // const char * dbg_out(SwOutlineNodes & rNodes);
84 SW_DLLPUBLIC const char * dbg_out(const SwPosition & rPos);
85 SW_DLLPUBLIC const char * dbg_out(const SwPaM & rPam);
86 SW_DLLPUBLIC const char * dbg_out(const SwNodeNum & rNum);
87 SW_DLLPUBLIC const char * dbg_out(const SwUndo & rUndo);
88 SW_DLLPUBLIC const char * dbg_out(const SwRewriter & rRewriter);
89 SW_DLLPUBLIC const char * dbg_out(const SwNumRule & rRule);
90 SW_DLLPUBLIC const char * dbg_out(const SwTxtFmtColl & rFmt);
91 SW_DLLPUBLIC const char * dbg_out(const SwFrmFmts & rFrmFmts);
92 SW_DLLPUBLIC const char * dbg_out(const SwNumRuleTbl & rTbl);
93 SW_DLLPUBLIC const char * dbg_out(const SwNodeRange & rRange);
94 
95 template<typename tKey, typename tMember, typename fHashFunction>
96 String lcl_dbg_out(const std::hash_map<tKey, tMember, fHashFunction> & rMap)
97 {
98     String aResult("[", RTL_TEXTENCODING_ASCII_US);
99 
100     typename std::hash_map<tKey, tMember, fHashFunction>::const_iterator aIt;
101 
102     for (aIt = rMap.begin(); aIt != rMap.end(); aIt++)
103     {
104         if (aIt != rMap.begin())
105             aResult += String(", ", RTL_TEXTENCODING_ASCII_US);
106 
107         aResult += aIt->first;
108 
109         char sBuffer[256];
110         sprintf(sBuffer, "(%p)", aIt->second);
111         aResult += String(sBuffer, RTL_TEXTENCODING_ASCII_US);
112     }
113 
114     aResult += String("]", RTL_TEXTENCODING_ASCII_US);
115 
116     return aResult;
117 }
118 
119 template<typename tKey, typename tMember, typename fHashFunction>
120 const char * dbg_out(const std::hash_map<tKey, tMember, fHashFunction> & rMap)
121 {
122     return dbg_out(lcl_dbg_out(rMap));
123 }
124 SW_DLLPUBLIC const char * dbg_out(const SwFormToken & rToken);
125 SW_DLLPUBLIC const char * dbg_out(const SwFormTokens & rTokens);
126 #endif // DEBUG
127 #endif // __DBGOUTSW_HXX
128