xref: /aoo41x/main/sw/inc/dbgoutsw.hxx (revision 1d2dbeb0)
1*1d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*1d2dbeb0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1d2dbeb0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1d2dbeb0SAndrew Rist  * distributed with this work for additional information
6*1d2dbeb0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1d2dbeb0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1d2dbeb0SAndrew Rist  * "License"); you may not use this file except in compliance
9*1d2dbeb0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1d2dbeb0SAndrew Rist  *
11*1d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*1d2dbeb0SAndrew Rist  *
13*1d2dbeb0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1d2dbeb0SAndrew Rist  * software distributed under the License is distributed on an
15*1d2dbeb0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1d2dbeb0SAndrew Rist  * KIND, either express or implied.  See the License for the
17*1d2dbeb0SAndrew Rist  * specific language governing permissions and limitations
18*1d2dbeb0SAndrew Rist  * under the License.
19*1d2dbeb0SAndrew Rist  *
20*1d2dbeb0SAndrew Rist  *************************************************************/
21*1d2dbeb0SAndrew Rist 
22*1d2dbeb0SAndrew Rist 
23cdf0e10cSrcweir #ifndef __DBGOUTSW_HXX
24cdf0e10cSrcweir #define __DBGOUTSW_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #ifdef DEBUG
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <hash_map>
29cdf0e10cSrcweir #include <tox.hxx>
30cdf0e10cSrcweir class String;
31cdf0e10cSrcweir 
32cdf0e10cSrcweir namespace rtl
33cdf0e10cSrcweir {
34cdf0e10cSrcweir class OUString;
35cdf0e10cSrcweir }
36cdf0e10cSrcweir class SwNode;
37cdf0e10cSrcweir class SwTxtAttr;
38cdf0e10cSrcweir class SwpHints;
39cdf0e10cSrcweir class SfxPoolItem;
40cdf0e10cSrcweir class SfxItemSet;
41cdf0e10cSrcweir struct SwPosition;
42cdf0e10cSrcweir class SwPaM;
43cdf0e10cSrcweir class SwNodeNum;
44cdf0e10cSrcweir class SwUndo;
45cdf0e10cSrcweir class SwRect;
46cdf0e10cSrcweir class SwFrmFmt;
47cdf0e10cSrcweir class SwFrmFmts;
48cdf0e10cSrcweir class SwNodes;
49cdf0e10cSrcweir class SwRewriter;
50cdf0e10cSrcweir class SwNumRuleTbl;
51cdf0e10cSrcweir class SwNumRule;
52cdf0e10cSrcweir class SwOutlineNodes;
53cdf0e10cSrcweir class SwTxtFmtColl;
54cdf0e10cSrcweir class SwNodeRange;
55cdf0e10cSrcweir 
56cdf0e10cSrcweir #define DBG_OUT_HERE printf("%s(%d):", __FILE__, __LINE__)
57cdf0e10cSrcweir #define DBG_OUT_HERE_FN printf("%s(%d) %s:", __FILE__, __LINE__, __FUNCTION__)
58cdf0e10cSrcweir #define DBG_OUT_HERE_LN printf("%s(%d)\n", __FILE__, __LINE__)
59cdf0e10cSrcweir #define DBG_OUT_HERE_FN_LN printf("%s(%d) %s\n", __FILE__, __LINE__, __FUNCTION__)
60cdf0e10cSrcweir #define DBG_OUT(x) printf("%s\n", dbg_out(x))
61cdf0e10cSrcweir #define DBG_OUT_LN(x) printf("%s(%d): %s\n", __FILE__, __LINE__, dbg_out(x))
62cdf0e10cSrcweir #define DBG_OUT_FN_LN(x) printf("%s: %s\n", __FUNCTION__, dbg_out(x))
63cdf0e10cSrcweir 
64cdf0e10cSrcweir extern bool bDbgOutStdErr;
65cdf0e10cSrcweir extern bool bDbgOutPrintAttrSet;
66cdf0e10cSrcweir 
67cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(const void * pVoid);
68cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(const String & aStr);
69cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(const ::rtl::OUString & aStr);
70cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(const SwRect & rRect);
71cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(const SwFrmFmt & rFrmFmt);
72cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(const SwNode & rNode);
73cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(const SwTxtAttr & rAttr);
74cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(const SwpHints &rHints);
75cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(const SfxPoolItem & rItem);
76cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(const SfxPoolItem * pItem);
77cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(const SfxItemSet & rSet);
78cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(SwNodes & rNodes);
79cdf0e10cSrcweir // const char * dbg_out(SwOutlineNodes & rNodes);
80cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(const SwPosition & rPos);
81cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(const SwPaM & rPam);
82cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(const SwNodeNum & rNum);
83cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(const SwUndo & rUndo);
84cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(const SwRewriter & rRewriter);
85cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(const SwNumRule & rRule);
86cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(const SwTxtFmtColl & rFmt);
87cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(const SwFrmFmts & rFrmFmts);
88cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(const SwNumRuleTbl & rTbl);
89cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(const SwNodeRange & rRange);
90cdf0e10cSrcweir 
91cdf0e10cSrcweir template<typename tKey, typename tMember, typename fHashFunction>
lcl_dbg_out(const std::hash_map<tKey,tMember,fHashFunction> & rMap)92cdf0e10cSrcweir String lcl_dbg_out(const std::hash_map<tKey, tMember, fHashFunction> & rMap)
93cdf0e10cSrcweir {
94cdf0e10cSrcweir     String aResult("[", RTL_TEXTENCODING_ASCII_US);
95cdf0e10cSrcweir 
96cdf0e10cSrcweir     typename std::hash_map<tKey, tMember, fHashFunction>::const_iterator aIt;
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     for (aIt = rMap.begin(); aIt != rMap.end(); aIt++)
99cdf0e10cSrcweir     {
100cdf0e10cSrcweir         if (aIt != rMap.begin())
101cdf0e10cSrcweir             aResult += String(", ", RTL_TEXTENCODING_ASCII_US);
102cdf0e10cSrcweir 
103cdf0e10cSrcweir         aResult += aIt->first;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir         char sBuffer[256];
106cdf0e10cSrcweir         sprintf(sBuffer, "(%p)", aIt->second);
107cdf0e10cSrcweir         aResult += String(sBuffer, RTL_TEXTENCODING_ASCII_US);
108cdf0e10cSrcweir     }
109cdf0e10cSrcweir 
110cdf0e10cSrcweir     aResult += String("]", RTL_TEXTENCODING_ASCII_US);
111cdf0e10cSrcweir 
112cdf0e10cSrcweir     return aResult;
113cdf0e10cSrcweir }
114cdf0e10cSrcweir 
115cdf0e10cSrcweir template<typename tKey, typename tMember, typename fHashFunction>
dbg_out(const std::hash_map<tKey,tMember,fHashFunction> & rMap)116cdf0e10cSrcweir const char * dbg_out(const std::hash_map<tKey, tMember, fHashFunction> & rMap)
117cdf0e10cSrcweir {
118cdf0e10cSrcweir     return dbg_out(lcl_dbg_out(rMap));
119cdf0e10cSrcweir }
120cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(const SwFormToken & rToken);
121cdf0e10cSrcweir SW_DLLPUBLIC const char * dbg_out(const SwFormTokens & rTokens);
122cdf0e10cSrcweir #endif // DEBUG
123cdf0e10cSrcweir #endif // __DBGOUTSW_HXX
124