1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ddemldeb.cxx,v $
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 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
34 #include "ddemlimp.hxx"
42 void ImpAddHSZ( HSZ hszString
, String
& rStr
)
45 ImpDdeMgr::DdeQueryString( hszString
,aBuf
,sizeof(aBuf
),850);
46 rStr
+= " (\""; rStr
+= aBuf
; rStr
+= "\",";
47 HATOMTBL hAtomTable
= WinQuerySystemAtomTable();
50 nRefCount
= WinQueryAtomUsage(hAtomTable
, (ATOM
)hszString
);
51 rStr
+= nRefCount
; rStr
+= ')';
55 void ImpWriteDdeStatus(char* aFilename
, char* pAppContext
)
61 Transaction
* pTransPtr
;
63 ImpDdeMgrData
* pData
= ImpDdeMgr::AccessMgrData();
66 SvFileStream
aStrm(aFilename
, STREAM_READWRITE
);
68 aStrm
.Seek( STREAM_SEEK_TO_END
);
70 aStrm
.WriteLine("********************** DDEML-Log ***********************");
74 aLine
= Application::GetAppName();
76 aLine
+= "App-Context:"; aLine
+= pAppContext
;
77 aStrm
.WriteLine( aLine
); aStrm
<< endl
;
79 aStrm
.WriteLine("----------------- ImpDdeMgrData -------------------");
81 aLine
= "TotalSize :"; aLine
+= pData
->nTotalSize
; aStrm
.WriteLine(aLine
);
82 aLine
= "nOffsAppTable :"; aLine
+= pData
->nOffsAppTable
; aStrm
.WriteLine(aLine
);
83 aLine
= "nOffsConvTable :"; aLine
+= pData
->nOffsConvTable
; aStrm
.WriteLine(aLine
);
84 aLine
= "nOffsTransTable:"; aLine
+= pData
->nOffsTransTable
; aStrm
.WriteLine(aLine
);
85 aLine
= "nMaxAppCount :"; aLine
+= pData
->nMaxAppCount
; aStrm
.WriteLine(aLine
);
86 aLine
= "nMaxConvCount :"; aLine
+= pData
->nMaxConvCount
; aStrm
.WriteLine(aLine
);
87 aLine
= "nMaxTransCount :"; aLine
+= pData
->nMaxTransCount
; aStrm
.WriteLine(aLine
);
88 aLine
= "nLastErr :"; aLine
+= pData
->nLastErr
; aStrm
.WriteLine(aLine
);
89 aLine
= "nCurConvCount :"; aLine
+= pData
->nCurConvCount
; aStrm
.WriteLine(aLine
);
90 aLine
= "nCurTransCount :"; aLine
+= pData
->nCurTransCount
; aStrm
.WriteLine(aLine
);
92 aStrm
.WriteLine("---------- Registered DDEML-Applications -----------");
94 pAppPtr
= ImpDdeMgr::GetAppTable( pData
);
95 for( nCtr
= 0; nCtr
< pData
->nMaxAppCount
; nCtr
++, pAppPtr
++ )
99 aLine
= "App."; aLine
+= nCtr
; aLine
+= " HWND:";
100 aLine
+= (ULONG
)*pAppPtr
; aStrm
.WriteLine(aLine
);
105 aStrm
.WriteLine("-------------- Conversation handles ----------------");
108 USHORT nCurCount
= pData
->nCurConvCount
;
112 pConvPtr
= ImpDdeMgr::GetConvTable( pData
);
113 for( nCtr
= 0; nCtr
< pData
->nMaxConvCount
; nCtr
++, pConvPtr
++ )
115 if( pConvPtr
->hWndThis
)
117 aLine
= "HCONV:"; aLine
+= nCtr
;
118 aLine
+= " HCONVpartner: "; aLine
+= (USHORT
)pConvPtr
->hConvPartner
;
119 if( !pConvPtr
->hConvPartner
) aLine
+= "(Non-DDEML-App)";
120 aLine
+= " hszPartner: "; aLine
+= (USHORT
)pConvPtr
->hszPartner
;
121 ImpAddHSZ( pConvPtr
->hszPartner
, aLine
);
122 aStrm
.WriteLine( aLine
);
124 aLine
= "hszService: "; aLine
+= (USHORT
)pConvPtr
->hszServiceReq
;
125 ImpAddHSZ( pConvPtr
->hszServiceReq
, aLine
);
126 aLine
+= " hszTopic: "; aLine
+= (USHORT
)pConvPtr
->hszTopic
;
127 ImpAddHSZ( pConvPtr
->hszTopic
, aLine
);
128 aStrm
.WriteLine( aLine
);
130 aLine
= "Status: "; aLine
+= pConvPtr
->nStatus
;
131 if( pConvPtr
->nStatus
& ST_CLIENT
) aLine
+= " (Client)";
132 if( pConvPtr
->nStatus
& ST_INLIST
) aLine
+= " (Inlist)";
133 aStrm
.WriteLine(aLine
);
135 aLine
= "pidOwner: "; aLine
+= (ULONG
)pConvPtr
->pidOwner
;
136 aStrm
.WriteLine( aLine
);
137 aLine
= "hWndThis: "; aLine
+= (ULONG
)pConvPtr
->hWndThis
;
138 aStrm
.WriteLine( aLine
);
139 aLine
= "hWndPartner: "; aLine
+= (ULONG
)pConvPtr
->hWndPartner
;
140 aStrm
.WriteLine( aLine
);
142 aLine
= "hConvList: "; aLine
+= (ULONG
)pConvPtr
->hConvList
;
143 aLine
+= " Prev: "; aLine
+= pConvPtr
->nPrevHCONV
;
144 aLine
+= " Next: "; aLine
+= pConvPtr
->nNextHCONV
;
145 aStrm
.WriteLine( aLine
);
146 aStrm
.WriteLine("----------------------------------------------------");
155 aStrm
.WriteLine("----------------- Transaction Ids ------------------");
157 nCurCount
= pData
->nCurTransCount
;
160 pTransPtr
= ImpDdeMgr::GetTransTable( pData
);
161 for( nCtr
= 0; nCtr
< pData
->nMaxTransCount
; nCtr
++, pTransPtr
++ )
164 if( pTransPtr
->hConvOwner
)
166 aLine
= "TransactionId:"; aLine
+= nCtr
;
167 aLine
+= " hConvOwner: "; aLine
+= (USHORT
)pTransPtr
->hConvOwner
;
168 aStrm
.WriteLine( aLine
);
169 aLine
= "Item: "; aLine
+= (USHORT
)pTransPtr
->hszItem
;
170 ImpAddHSZ( pTransPtr
->hszItem
, aLine
);
171 aLine
+= " Format: "; aLine
+= pTransPtr
->nFormat
;
172 aStrm
.WriteLine( aLine
);
173 aLine
= "TransactionType: "; aLine
+= pTransPtr
->nType
;
174 aLine
+= " Convst: "; aLine
+= pTransPtr
->nConvst
;
175 aLine
+= " LastErr: "; aLine
+= pTransPtr
->nLastError
;
176 aLine
+= " Userhandle: "; aLine
+= pTransPtr
->nUser
;
177 aStrm
.WriteLine( aLine
);
178 aStrm
.WriteLine("--------------------------------------------------");
187 aStrm
.WriteLine("******************* End of DDEML-Log *******************");
190 void ImpWriteDdeData(char* aFilename
, DDESTRUCT
* pData
)
194 SvFileStream
aStrm(aFilename
, STREAM_READWRITE
);
195 aStrm
.Seek( STREAM_SEEK_TO_END
);
198 aLine
= "cbData:"; aLine
+= pData
->cbData
; aStrm
.WriteLine( aLine
);
199 aLine
= "fsStatus:"; aLine
+= pData
->fsStatus
; aStrm
.WriteLine( aLine
);
200 aLine
= "usFormat:"; aLine
+= pData
->usFormat
; aStrm
.WriteLine( aLine
);
201 aLine
= "ItemName:"; aLine
+= (char*)((char*)pData
+pData
->offszItemName
);
202 aStrm
.WriteLine( aLine
);
203 aLine
= "offabData:"; aLine
+= pData
->offabData
; aStrm
.WriteLine(aLine
);
204 char* pBuf
= (char*)pData
+pData
->offabData
;
205 USHORT nLen
= pData
->cbData
; // - pData->offabData;
215 void ImpWriteLogFile(char* pFilename
, char* pStr
)
217 SvFileStream
aStrm(pFilename
, STREAM_READWRITE
);
218 aStrm
.Seek( STREAM_SEEK_TO_END
);
219 String
aStr( Application::GetAppName() );
220 aStr
+= ':'; aStr
+= pStr
;
221 aStrm
.WriteLine( (char*)aStr
.GetStr() );
226 void ImpWriteDdeStatus(char*, char* ) {}
227 void ImpWriteDdeData(char*, DDESTRUCT
*) {}
228 void ImpWriteLogFile(char*, char*) {}
232 APIRET
MyDosAllocSharedMem(void** ppBaseAddress
, char* pszName
, unsigned long ulObjectSize
,
233 unsigned long ulFlags
, char* pContextStr
)
235 APIRET nRet
= DosAllocSharedMem(ppBaseAddress
,pszName
,ulObjectSize
,ulFlags
);
236 #if 0 && defined(OV_DEBUG) && defined(LOGFILE)
237 String
aStr("DosAllocSharedMem:");
240 aStr
+= ulObjectSize
;
242 aStr
+= (ULONG
)*((char**)ppBaseAddress
);
244 ImpWriteLogFile("\\ddeml.mem", (char*)aStr
.GetStr() );
249 APIRET
MyDosAllocMem(void** ppBaseAddress
, unsigned long ulObjectSize
,
250 unsigned long ulFlags
, char* pContextStr
)
252 APIRET nRet
= DosAllocMem(ppBaseAddress
, ulObjectSize
,ulFlags
);
253 #if 0 && defined(OV_DEBUG) && defined(LOGFILE)
254 String
aStr("DosAllocMem:");
257 aStr
+= ulObjectSize
;
259 aStr
+= (ULONG
)*((char**)ppBaseAddress
);
261 ImpWriteLogFile("\\ddeml.mem", (char*)aStr
.GetStr() );
267 APIRET
MyDosFreeMem( void* pBaseAddress
, char* pContextStr
)
269 APIRET nRet
= DosFreeMem( pBaseAddress
);
270 #if 0 && defined(OV_DEBUG) && defined(LOGFILE)
271 String
aStr("DosFreeMem:");
274 aStr
+= (ULONG
)pBaseAddress
;
275 ImpWriteLogFile("\\ddeml.mem", (char*)aStr
.GetStr());