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