merge the formfield patch from ooo-build
[ooovba.git] / svtools / source / svdde / ddemldeb.cxx
blob3329b42a30a9b618a2de0776a802e9db29fa5c15
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: ddemldeb.cxx,v $
10 * $Revision: 1.4 $
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"
36 #ifdef OV_DEBUG
37 #include <svgen.hxx>
38 #endif
40 #if defined(OV_DEBUG)
42 void ImpAddHSZ( HSZ hszString, String& rStr )
44 char aBuf[ 128 ];
45 ImpDdeMgr::DdeQueryString( hszString,aBuf,sizeof(aBuf),850);
46 rStr += " (\""; rStr += aBuf; rStr += "\",";
47 HATOMTBL hAtomTable = WinQuerySystemAtomTable();
48 ULONG nRefCount = 0;
49 if( hszString )
50 nRefCount = WinQueryAtomUsage(hAtomTable, (ATOM)hszString );
51 rStr += nRefCount; rStr += ')';
55 void ImpWriteDdeStatus(char* aFilename, char* pAppContext)
57 char aBuf[ 128 ];
58 USHORT nCtr;
59 HWND* pAppPtr;
60 ImpHCONV* pConvPtr;
61 Transaction* pTransPtr;
63 ImpDdeMgrData* pData = ImpDdeMgr::AccessMgrData();
64 if( !pData )
65 return;
66 SvFileStream aStrm(aFilename, STREAM_READWRITE );
67 String aLine;
68 aStrm.Seek( STREAM_SEEK_TO_END );
69 aStrm << endl;
70 aStrm.WriteLine("********************** DDEML-Log ***********************");
71 aStrm << endl;
72 if( pAppContext )
74 aLine = Application::GetAppName();
75 aLine += ':';
76 aLine += "App-Context:"; aLine += pAppContext;
77 aStrm.WriteLine( aLine ); aStrm << endl;
79 aStrm.WriteLine("----------------- ImpDdeMgrData -------------------");
80 aStrm << endl;
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);
91 aStrm << endl;
92 aStrm.WriteLine("---------- Registered DDEML-Applications -----------");
93 aStrm << endl;
94 pAppPtr = ImpDdeMgr::GetAppTable( pData );
95 for( nCtr = 0; nCtr < pData->nMaxAppCount; nCtr++, pAppPtr++ )
97 if( *pAppPtr )
99 aLine = "App."; aLine += nCtr; aLine += " HWND:";
100 aLine += (ULONG)*pAppPtr; aStrm.WriteLine(aLine);
104 aStrm << endl;
105 aStrm.WriteLine("-------------- Conversation handles ----------------");
106 aStrm << endl;
108 USHORT nCurCount = pData->nCurConvCount;
110 if( nCurCount )
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("----------------------------------------------------");
148 nCurCount--;
149 if( !nCurCount )
150 break;
155 aStrm.WriteLine("----------------- Transaction Ids ------------------");
157 nCurCount = pData->nCurTransCount;
158 if( nCurCount )
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("--------------------------------------------------");
180 nCurCount--;
181 if( !nCurCount )
182 break;
186 aStrm << endl;
187 aStrm.WriteLine("******************* End of DDEML-Log *******************");
190 void ImpWriteDdeData(char* aFilename, DDESTRUCT* pData)
192 char aBuf[ 128 ];
193 USHORT nCtr;
194 SvFileStream aStrm(aFilename, STREAM_READWRITE );
195 aStrm.Seek( STREAM_SEEK_TO_END );
196 String aLine;
197 aStrm << endl;
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;
206 while( nLen )
208 aStrm << *pBuf;
209 nLen--;
210 pBuf++;
212 aStrm << endl;
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() );
224 #else
226 void ImpWriteDdeStatus(char*, char* ) {}
227 void ImpWriteDdeData(char*, DDESTRUCT*) {}
228 void ImpWriteLogFile(char*, char*) {}
230 #endif
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:");
238 aStr += pContextStr;
239 aStr += ": ";
240 aStr += ulObjectSize;
241 aStr += " (";
242 aStr += (ULONG)*((char**)ppBaseAddress);
243 aStr += ')';
244 ImpWriteLogFile("\\ddeml.mem", (char*)aStr.GetStr() );
245 #endif
246 return nRet;
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:");
255 aStr += pContextStr;
256 aStr += ": ";
257 aStr += ulObjectSize;
258 aStr += " (";
259 aStr += (ULONG)*((char**)ppBaseAddress);
260 aStr += ')';
261 ImpWriteLogFile("\\ddeml.mem", (char*)aStr.GetStr() );
262 #endif
263 return nRet;
267 APIRET MyDosFreeMem( void* pBaseAddress, char* pContextStr )
269 APIRET nRet = DosFreeMem( pBaseAddress );
270 #if 0 && defined(OV_DEBUG) && defined(LOGFILE)
271 String aStr("DosFreeMem:");
272 aStr += pContextStr;
273 aStr += ": ";
274 aStr += (ULONG)pBaseAddress;
275 ImpWriteLogFile("\\ddeml.mem", (char*)aStr.GetStr());
276 #endif
277 return nRet;