sync master with lastest vba changes
[ooovba.git] / binfilter / inc / bf_svtools / svdde.hxx
bloba5321d0f36f66e28a70d3353554f1425e37db79b
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: svdde.hxx,v $
10 * $Revision: 1.3 $
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 #ifndef _SVDDE_HXX
32 #define _SVDDE_HXX
34 #ifndef INCLUDED_SVTDLLAPI_H
35 #include "bf_svtools/svtdllapi.h"
36 #endif
38 #ifndef _SOT_EXCHANGE_HXX
39 #include <sot/exchange.hxx>
40 #endif
42 #ifndef _STRING_HXX //autogen
43 #include <tools/string.hxx>
44 #endif
45 #ifndef _LIST_HXX //autogen
46 #include <tools/list.hxx>
47 #endif
48 #ifndef _LINK_HXX //autogen
49 #include <tools/link.hxx>
50 #endif
52 namespace binfilter
55 class DdeString;
56 class DdeData;
57 class DdeConnection;
58 class DdeTransaction;
59 class DdeLink;
60 class DdeRequest;
61 class DdeWarmLink;
62 class DdeHotLink;
63 class DdePoke;
64 class DdeExecute;
65 class DdeItem;
66 class DdeTopic;
67 class DdeService;
68 class ConvList;
69 struct DdeDataImp;
70 struct DdeImp;
71 class DdeItemImp;
73 #ifndef _SVDDE_NOLISTS
74 DECLARE_LIST( DdeConnections, DdeConnection* )
75 DECLARE_LIST( DdeServices, DdeService* )
76 DECLARE_LIST( DdeTopics, DdeTopic* )
77 DECLARE_LIST( DdeItems, DdeItem* )
78 #else
79 typedef List DdeConnections;
80 typedef List DdeServices;
81 typedef List DdeTopics;
82 typedef List DdeItems;
83 #endif
85 //#if 0 // _SOLAR__PRIVATE
86 DECLARE_LIST( DdeTransactions, DdeTransaction* )
87 DECLARE_LIST( DdeFormats, long )
88 //#else
89 //typedef List DdeTransactions;
90 //typedef List DdeFormats;
91 //#endif
93 #ifndef STRING_LIST
94 #define STRING_LIST
95 DECLARE_LIST( StringList, String * )
96 #endif
98 // -----------
99 // - DdeData -
100 // -----------
102 class DdeData
104 friend class DdeInternal;
105 friend class DdeService;
106 friend class DdeConnection;
107 friend class DdeTransaction;
108 DdeDataImp* pImp;
110 void Lock();
111 void SetFormat( ULONG nFmt );
113 public:
114 DdeData();
115 DdeData( const void*, long, ULONG = FORMAT_STRING );
116 DdeData( const String& );
117 DdeData( const DdeData& );
118 ~DdeData();
120 operator const void*() const;
121 operator long() const;
123 ULONG GetFormat() const;
125 DdeData& operator = ( const DdeData& );
127 static ULONG GetExternalFormat( ULONG nFmt );
128 static ULONG GetInternalFormat( ULONG nFmt );
130 // ------------------
131 // - DdeServiceList -
132 // ------------------
134 class DdeServiceList
136 StringList aServices;
138 public:
139 DdeServiceList( const String* = NULL );
140 ~DdeServiceList();
142 StringList& GetServices() { return aServices; }
144 private:
145 DdeServiceList( const DdeServiceList& );
146 const DdeServiceList& operator= ( const DdeServiceList& );
149 // ----------------
150 // - DdeTopicList -
151 // ----------------
153 class DdeTopicList
155 StringList aTopics;
157 //#if 0 // _SOLAR__PRIVATE
158 DECL_LINK( Data, DdeData* );
159 //#endif
160 public:
161 DdeTopicList( const String& );
162 ~DdeTopicList();
164 StringList& GetTopics() { return aTopics; }
167 // ------------------
168 // - DdeTransaction -
169 // ------------------
171 class DdeTransaction
173 public:
174 virtual void Data( const DdeData* );
175 virtual void Done( BOOL bDataValid );
176 protected:
177 DdeConnection& rDde;
178 DdeData aDdeData;
179 DdeString* pName;
180 short nType;
181 long nId;
182 long nTime;
183 Link aData;
184 Link aDone;
185 BOOL bBusy;
187 DdeTransaction( DdeConnection&, const String&, long = 0 );
189 public:
190 virtual ~DdeTransaction();
192 BOOL IsBusy() { return bBusy; }
193 const String& GetName() const;
195 void Execute();
197 void SetDataHdl( const Link& rLink ) { aData = rLink; }
198 const Link& GetDataHdl() const { return aData; }
200 void SetDoneHdl( const Link& rLink ) { aDone = rLink; }
201 const Link& GetDoneHdl() const { return aDone; }
203 void SetFormat( ULONG nFmt ) { aDdeData.SetFormat( nFmt ); }
204 ULONG GetFormat() const { return aDdeData.GetFormat(); }
206 long GetError();
208 private:
209 friend class DdeInternal;
210 friend class DdeConnection;
212 DdeTransaction( const DdeTransaction& );
213 const DdeTransaction& operator= ( const DdeTransaction& );
217 // -----------
218 // - DdeLink -
219 // -----------
221 class DdeLink : public DdeTransaction
223 Link aNotify;
225 public:
226 DdeLink( DdeConnection&, const String&, long = 0 );
227 virtual ~DdeLink();
229 void SetNotifyHdl( const Link& rLink ) { aNotify = rLink; }
230 const Link& GetNotifyHdl() const { return aNotify; }
231 virtual void Notify();
234 // ---------------
235 // - DdeWarmLink -
236 // ---------------
238 class DdeWarmLink : public DdeLink
240 public:
241 DdeWarmLink( DdeConnection&, const String&, long = 0 );
244 // --------------
245 // - DdeHotLink -
246 // --------------
248 class DdeHotLink : public DdeLink
250 public:
251 DdeHotLink( DdeConnection&, const String&, long = 0 );
254 // --------------
255 // - DdeRequest -
256 // --------------
258 class DdeRequest : public DdeTransaction
260 public:
261 DdeRequest( DdeConnection&, const String&, long = 0 );
264 // -----------
265 // - DdePoke -
266 // -----------
268 class DdePoke : public DdeTransaction
270 public:
271 DdePoke( DdeConnection&, const String&, const char*, long,
272 ULONG = FORMAT_STRING, long = 0 );
273 DdePoke( DdeConnection&, const String&, const DdeData&, long = 0 );
274 DdePoke( DdeConnection&, const String&, const String&, long = 0 );
277 // --------------
278 // - DdeExecute -
279 // --------------
281 class DdeExecute : public DdeTransaction
283 public:
284 DdeExecute( DdeConnection&, const String&, long = 0 );
287 // -----------------
288 // - DdeConnection -
289 // -----------------
291 class DdeConnection
293 friend class DdeInternal;
294 friend class DdeTransaction;
295 DdeTransactions aTransactions;
296 DdeString* pService;
297 DdeString* pTopic;
298 DdeImp* pImp;
300 public:
301 DdeConnection( const String&, const String& );
302 ~DdeConnection();
304 long GetError();
305 long GetConvId();
307 static const DdeConnections& GetConnections();
309 BOOL IsConnected();
311 const String& GetServiceName();
312 const String& GetTopicName();
314 private:
315 DdeConnection( const DdeConnection& );
316 const DdeConnection& operator= ( const DdeConnection& );
319 // -----------
320 // - DdeItem -
321 // -----------
323 class DdeItem
325 friend class DdeInternal;
326 friend class DdeTopic;
327 DdeString* pName;
328 DdeTopic* pMyTopic;
329 DdeItemImp* pImpData;
331 void IncMonitor( ULONG );
332 void DecMonitor( ULONG );
334 protected:
335 BYTE nType;
337 public:
338 DdeItem( const sal_Unicode* );
339 DdeItem( const String& );
340 DdeItem( const DdeItem& );
341 virtual ~DdeItem();
343 const String& GetName() const;
344 short GetLinks();
345 void NotifyClient();
348 // -----------
349 // - DdeItem -
350 // -----------
352 class DdeGetPutItem : public DdeItem
354 public:
355 DdeGetPutItem( const sal_Unicode* p );
356 DdeGetPutItem( const String& rStr );
357 DdeGetPutItem( const DdeItem& rItem );
359 virtual DdeData* Get( ULONG );
360 virtual BOOL Put( const DdeData* );
361 virtual void AdviseLoop( BOOL ); // AdviseLoop starten/stoppen
364 // ------------
365 // - DdeTopic -
366 // ------------
368 class DdeTopic
370 void _Disconnect( long );
372 public:
373 virtual void Connect( long );
374 virtual void Disconnect( long );
375 virtual DdeData* Get( ULONG );
376 virtual BOOL Put( const DdeData* );
377 virtual BOOL Execute( const String* );
378 // evt. ein neues anlegen; return 0 -> es konnte nicht angelegt werden
379 virtual BOOL MakeItem( const String& rItem );
381 // es wird ein Warm-/Hot-Link eingerichtet. Return-Wert
382 // besagt ob es geklappt hat
383 virtual BOOL StartAdviseLoop();
384 virtual BOOL StopAdviseLoop();
386 private:
387 friend class DdeInternal;
388 friend class DdeService;
389 friend class DdeItem;
391 private:
392 DdeString* pName;
393 String aItem;
394 DdeItems aItems;
395 Link aConnectLink;
396 Link aDisconnectLink;
397 Link aGetLink;
398 Link aPutLink;
399 Link aExecLink;
401 public:
402 DdeTopic( const String& );
403 virtual ~DdeTopic();
405 const String& GetName() const;
406 long GetConvId();
408 void SetConnectHdl( const Link& rLink ) { aConnectLink = rLink; }
409 const Link& GetConnectHdl() const { return aConnectLink; }
410 void SetDisconnectHdl( const Link& rLink ) { aDisconnectLink = rLink; }
411 const Link& GetDisconnectHdl() const { return aDisconnectLink; }
412 void SetGetHdl( const Link& rLink ) { aGetLink = rLink; }
413 const Link& GetGetHdl() const { return aGetLink; }
414 void SetPutHdl( const Link& rLink ) { aPutLink = rLink; }
415 const Link& GetPutHdl() const { return aPutLink; }
416 void SetExecuteHdl( const Link& rLink ) { aExecLink = rLink; }
417 const Link& GetExecuteHdl() const { return aExecLink; }
419 void NotifyClient( const String& );
420 BOOL IsSystemTopic();
422 void InsertItem( DdeItem* ); // fuer eigene Ableitungen!
423 DdeItem* AddItem( const DdeItem& ); // werden kopiert !
424 void RemoveItem( const DdeItem& );
425 const String& GetCurItem() { return aItem; }
426 const DdeItems& GetItems() { return aItems; }
428 private:
429 DdeTopic( const DdeTopic& );
430 const DdeTopic& operator= ( const DdeTopic& );
433 // --------------
434 // - DdeService -
435 // --------------
437 class DdeService
439 friend class DdeInternal;
441 public:
442 virtual BOOL IsBusy();
443 virtual String GetHelp();
444 // evt. ein neues anlegen; return 0 -> es konnte nicht angelegt werden
445 virtual BOOL MakeTopic( const String& rItem );
447 protected:
448 virtual String Topics();
449 virtual String Formats();
450 virtual String SysItems();
451 virtual String Status();
452 virtual String SysTopicGet( const String& );
453 virtual BOOL SysTopicExecute( const String* );
455 const DdeTopic* GetSysTopic() const { return pSysTopic; }
456 private:
457 DdeTopics aTopics;
458 DdeFormats aFormats;
459 DdeTopic* pSysTopic;
460 DdeString* pName;
461 ConvList* pConv;
462 short nStatus;
464 BOOL HasCbFormat( USHORT );
466 public:
467 DdeService( const String& );
468 virtual ~DdeService();
470 const String& GetName() const;
471 short GetError() { return nStatus; }
473 static DdeServices& GetServices();
474 DdeTopics& GetTopics() { return aTopics; }
476 void AddTopic( const DdeTopic& );
477 void RemoveTopic( const DdeTopic& );
479 void AddFormat( ULONG );
480 void RemoveFormat( ULONG );
481 BOOL HasFormat( ULONG );
483 private:
484 // DdeService( const DdeService& );
485 //int operator= ( const DdeService& );
488 // ------------------
489 // - DdeTransaction -
490 // ------------------
492 inline long DdeTransaction::GetError()
494 return rDde.GetError();
499 #endif // _SVDDE_HXX