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: ddeinf.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"
38 #include <svtools/svdde.hxx>
40 // --- DdeInternal::InfCallback() ----------------------------------
43 HDDEDATA CALLBACK
DdeInternal::InfCallback(
44 WORD
, WORD
, HCONV
, HSZ
, HSZ
, HDDEDATA
, DWORD
, DWORD
)
46 #if defined ( MTW ) || ( defined ( GCC ) && defined ( OS2 )) || defined( ICC )
47 HDDEDATA CALLBACK __EXPORT
DdeInternal::InfCallback(
48 WORD
, WORD
, HCONV
, HSZ
, HSZ
, HDDEDATA
, DWORD
, DWORD
)
50 HDDEDATA CALLBACK _export
DdeInternal::InfCallback(
51 WORD
, WORD
, HCONV
, HSZ
, HSZ
, HDDEDATA
, DWORD
, DWORD
)
55 return (HDDEDATA
)DDE_FNOTPROCESSED
;
58 // --- DdeServiceList::DdeServiceList() ----------------------------
60 DdeServiceList::DdeServiceList( const String
* pTopic
)
62 DWORD hDdeInst
= NULL
;
63 HCONVLIST hConvList
= NULL
;
65 UINT nStatus
= DMLERR_NO_ERROR
;
68 #ifndef OS2 // YD FIXME
70 nStatus
= DdeInitialize( &hDdeInst
, (PFNCALLBACK
) DdeInternal::InfCallback
,
71 APPCLASS_STANDARD
| APPCMD_CLIENTONLY
|
72 CBF_FAIL_ALLSVRXACTIONS
|
73 CBF_SKIP_ALLNOTIFICATIONS
, 0L );
75 if ( nStatus
== DMLERR_NO_ERROR
)
79 LPCTSTR p
= reinterpret_cast<LPCTSTR
>(pTopic
->GetBuffer());
81 hTopic
= DdeCreateStringHandle( hDdeInst
, const_cast<LPTSTR
>(p
), CP_WINUNICODE
);
83 hTopic
= DdeCreateStringHandle( hDdeInst
, p
, CP_WINUNICODE
);
87 hConvList
= DdeConnectList( hDdeInst
, NULL
, hTopic
, NULL
, NULL
);
88 nStatus
= DdeGetLastError( hDdeInst
);
91 if ( nStatus
== DMLERR_NO_ERROR
)
93 while ( ( hConv
= DdeQueryNextServer( hConvList
, hConv
) ) != NULL
)
99 aInf
.nSize
= sizeof( aInf
);
101 aInf
.cb
= sizeof( aInf
);
103 if( DdeQueryConvInfo( hConv
, QID_SYNC
, &aInf
))
105 h
= aInf
.hszServiceReq
;
108 h
= aInf
.hszSvcPartner
;
112 DdeQueryString( hDdeInst
, h
, buf
, sizeof(buf
) / sizeof(TCHAR
), CP_WINUNICODE
);
113 p
= buf
+ lstrlen( buf
);
115 DdeQueryString( hDdeInst
, aInf
.hszTopic
, p
, sizeof(buf
)/sizeof(TCHAR
)-lstrlen( buf
),
117 aServices
.Insert( new String( reinterpret_cast<const sal_Unicode
*>(buf
) ) );
120 DdeDisconnectList( hConvList
);
124 DdeFreeStringHandle( hDdeInst
, hTopic
);
126 DdeUninitialize( hDdeInst
);
132 // --- DdeServiceList::~DdeServiceList() ---------------------------
134 DdeServiceList::~DdeServiceList()
137 while ( ( s
= aServices
.First() ) != NULL
)
139 aServices
.Remove( s
);
144 // --- DdeTopicList::DdeTopicList() --------------------------------
146 DdeTopicList::DdeTopicList( const String
& rService
)
148 DdeConnection
aSys( rService
, String( reinterpret_cast<const sal_Unicode
*>(SZDDESYS_TOPIC
) ) );
150 if ( !aSys
.GetError() )
152 DdeRequest
aReq( aSys
, String( reinterpret_cast<const sal_Unicode
*>(SZDDESYS_ITEM_TOPICS
) ), 500 );
153 aReq
.SetDataHdl( LINK( this, DdeTopicList
, Data
) );
158 // --- DdeTopicList::~DdeTopicList() -------------------------------
160 DdeTopicList::~DdeTopicList()
163 while ( ( s
= aTopics
.First() ) != NULL
)
170 // --- DdeTopicList::Data() --------------------------------------------
172 IMPL_LINK( DdeTopicList
, Data
, DdeData
*, pData
)
174 char* p
= (char*) (const void *) *pData
;
179 while ( *p
&& *p
!= '\r' && *p
!= '\n' )
182 while ( i
< 255 && *p
&& *p
!= '\r' && *p
!= '\n' && *p
!= '\t' )
185 while ( *p
&& *p
!= '\r' && *p
!= '\n' && *p
!= '\t' )
187 aTopics
.Insert( new String( String::CreateFromAscii(buf
) ) );