bump product version to 4.1.6.2
[LibreOffice.git] / include / svl / svdde.hxx
blobc8a08beffbb94dc516dcbc8ae61e30abd6989d12
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _SVDDE_HXX
21 #define _SVDDE_HXX
23 #include "svl/svldllapi.h"
24 #include <sot/exchange.hxx>
25 #include <tools/string.hxx>
26 #include <tools/link.hxx>
27 #include <vector>
29 class DdeString;
30 class DdeData;
31 class DdeConnection;
32 class DdeTransaction;
33 class DdeLink;
34 class DdeRequest;
35 class DdeWarmLink;
36 class DdeHotLink;
37 class DdePoke;
38 class DdeExecute;
39 class DdeItem;
40 class DdeTopic;
41 class DdeService;
42 struct DdeDataImp;
43 struct DdeImp;
44 class DdeItemImp;
45 struct Conversation;
47 typedef ::std::vector< DdeService* > DdeServices;
48 typedef ::std::vector< long > DdeFormats;
49 typedef ::std::vector< Conversation* > ConvList;
51 // -----------
52 // - DdeData -
53 // -----------
55 class SVL_DLLPUBLIC DdeData
57 friend class DdeInternal;
58 friend class DdeService;
59 friend class DdeConnection;
60 friend class DdeTransaction;
61 DdeDataImp* pImp;
63 SVL_DLLPRIVATE void Lock();
65 void SetFormat( sal_uLong nFmt );
67 public:
68 DdeData();
69 DdeData( SAL_UNUSED_PARAMETER const void*, SAL_UNUSED_PARAMETER long, SAL_UNUSED_PARAMETER sal_uLong = FORMAT_STRING );
70 DdeData( SAL_UNUSED_PARAMETER const String& );
71 DdeData( const DdeData& );
72 ~DdeData();
74 operator const void*() const;
75 operator long() const;
77 sal_uLong GetFormat() const;
79 DdeData& operator = ( const DdeData& );
81 static sal_uLong GetExternalFormat( sal_uLong nFmt );
82 static sal_uLong GetInternalFormat( sal_uLong nFmt );
85 // ------------------
86 // - DdeTransaction -
87 // ------------------
89 class SVL_DLLPUBLIC DdeTransaction
91 public:
92 virtual void Data( const DdeData* );
93 virtual void Done( sal_Bool bDataValid );
94 protected:
95 DdeConnection& rDde;
96 DdeData aDdeData;
97 DdeString* pName;
98 short nType;
99 long nId;
100 long nTime;
101 Link aData;
102 Link aDone;
103 bool bBusy;
105 DdeTransaction( DdeConnection&, SAL_UNUSED_PARAMETER const String&, SAL_UNUSED_PARAMETER long = 0 );
107 public:
108 virtual ~DdeTransaction();
110 bool IsBusy() { return bBusy; }
111 const OUString GetName() const;
113 void Execute();
115 void SetDataHdl( const Link& rLink ) { aData = rLink; }
116 const Link& GetDataHdl() const { return aData; }
118 void SetDoneHdl( const Link& rLink ) { aDone = rLink; }
119 const Link& GetDoneHdl() const { return aDone; }
121 void SetFormat( sal_uLong nFmt ) { aDdeData.SetFormat( nFmt ); }
122 sal_uLong GetFormat() const { return aDdeData.GetFormat(); }
124 long GetError();
126 private:
127 friend class DdeInternal;
128 friend class DdeConnection;
130 DdeTransaction( const DdeTransaction& );
131 const DdeTransaction& operator= ( const DdeTransaction& );
135 // -----------
136 // - DdeLink -
137 // -----------
139 class SVL_DLLPUBLIC DdeLink : public DdeTransaction
141 Link aNotify;
143 public:
144 DdeLink( DdeConnection&, const String&, long = 0 );
145 virtual ~DdeLink();
147 void SetNotifyHdl( const Link& rLink ) { aNotify = rLink; }
148 const Link& GetNotifyHdl() const { return aNotify; }
149 virtual void Notify();
152 // ---------------
153 // - DdeWarmLink -
154 // ---------------
156 class SVL_DLLPUBLIC DdeWarmLink : public DdeLink
158 public:
159 DdeWarmLink( DdeConnection&, const String&, long = 0 );
162 // --------------
163 // - DdeHotLink -
164 // --------------
166 class SVL_DLLPUBLIC DdeHotLink : public DdeLink
168 public:
169 DdeHotLink( DdeConnection&, const String&, long = 0 );
172 // --------------
173 // - DdeRequest -
174 // --------------
176 class SVL_DLLPUBLIC DdeRequest : public DdeTransaction
178 public:
179 DdeRequest( DdeConnection&, const String&, long = 0 );
182 // -----------
183 // - DdePoke -
184 // -----------
186 class SVL_DLLPUBLIC DdePoke : public DdeTransaction
188 public:
189 DdePoke( DdeConnection&, const String&, const char*, long,
190 sal_uLong = FORMAT_STRING, long = 0 );
191 DdePoke( DdeConnection&, const String&, SAL_UNUSED_PARAMETER const DdeData&, long = 0 );
192 DdePoke( DdeConnection&, const String&, const String&, long = 0 );
195 // --------------
196 // - DdeExecute -
197 // --------------
199 class SVL_DLLPUBLIC DdeExecute : public DdeTransaction
201 public:
202 DdeExecute( DdeConnection&, const String&, long = 0 );
205 // -----------------
206 // - DdeConnection -
207 // -----------------
209 class SVL_DLLPUBLIC DdeConnection
211 friend class DdeInternal;
212 friend class DdeTransaction;
213 std::vector<DdeTransaction*> aTransactions;
214 DdeString* pService;
215 DdeString* pTopic;
216 DdeImp* pImp;
218 public:
219 DdeConnection( SAL_UNUSED_PARAMETER const String&, SAL_UNUSED_PARAMETER const String& );
220 ~DdeConnection();
222 long GetError();
223 long GetConvId();
225 static const std::vector<DdeConnection*>& GetConnections();
227 sal_Bool IsConnected();
229 const String& GetServiceName();
230 const String& GetTopicName();
232 private:
233 DdeConnection( const DdeConnection& );
234 const DdeConnection& operator= ( const DdeConnection& );
237 // -----------
238 // - DdeItem -
239 // -----------
241 class SVL_DLLPUBLIC DdeItem
243 friend class DdeInternal;
244 friend class DdeTopic;
245 DdeString* pName;
246 DdeTopic* pMyTopic;
247 DdeItemImp* pImpData;
249 void IncMonitor( sal_uLong );
250 void DecMonitor( sal_uLong );
252 protected:
253 sal_uInt8 nType;
255 public:
256 DdeItem( const sal_Unicode* );
257 DdeItem( SAL_UNUSED_PARAMETER const String& );
258 DdeItem( const DdeItem& );
259 virtual ~DdeItem();
261 const OUString GetName() const;
262 short GetLinks();
263 void NotifyClient();
266 // -----------
267 // - DdeItem -
268 // -----------
270 class SVL_DLLPUBLIC DdeGetPutItem : public DdeItem
272 public:
273 DdeGetPutItem( const sal_Unicode* p );
274 DdeGetPutItem( const String& rStr );
275 DdeGetPutItem( const DdeItem& rItem );
277 virtual DdeData* Get( sal_uLong );
278 virtual sal_Bool Put( const DdeData* );
279 virtual void AdviseLoop( sal_Bool ); // AdviseLoop starten/stoppen
282 // ------------
283 // - DdeTopic -
284 // ------------
286 class SVL_DLLPUBLIC DdeTopic
288 SVL_DLLPRIVATE void _Disconnect( long );
290 public:
291 virtual void Connect( long );
292 virtual void Disconnect( long );
293 virtual DdeData* Get( sal_uLong );
294 virtual sal_Bool Put( const DdeData* );
295 virtual sal_Bool Execute( const String* );
296 // evt. ein neues anlegen; return 0 -> es konnte nicht angelegt werden
297 virtual sal_Bool MakeItem( const OUString& rItem );
299 // es wird ein Warm-/Hot-Link eingerichtet. Return-Wert
300 // besagt ob es geklappt hat
301 virtual sal_Bool StartAdviseLoop();
302 virtual sal_Bool StopAdviseLoop();
304 private:
305 friend class DdeInternal;
306 friend class DdeService;
307 friend class DdeItem;
309 private:
310 DdeString* pName;
311 OUString aItem;
312 std::vector<DdeItem*> aItems;
313 Link aConnectLink;
314 Link aDisconnectLink;
315 Link aGetLink;
316 Link aPutLink;
317 Link aExecLink;
319 public:
320 DdeTopic( SAL_UNUSED_PARAMETER const OUString& );
321 virtual ~DdeTopic();
323 const OUString GetName() const;
324 long GetConvId();
326 void SetConnectHdl( const Link& rLink ) { aConnectLink = rLink; }
327 const Link& GetConnectHdl() const { return aConnectLink; }
328 void SetDisconnectHdl( const Link& rLink ) { aDisconnectLink = rLink; }
329 const Link& GetDisconnectHdl() const { return aDisconnectLink; }
330 void SetGetHdl( const Link& rLink ) { aGetLink = rLink; }
331 const Link& GetGetHdl() const { return aGetLink; }
332 void SetPutHdl( const Link& rLink ) { aPutLink = rLink; }
333 const Link& GetPutHdl() const { return aPutLink; }
334 void SetExecuteHdl( const Link& rLink ) { aExecLink = rLink; }
335 const Link& GetExecuteHdl() const { return aExecLink; }
337 void NotifyClient( const String& );
338 sal_Bool IsSystemTopic();
340 void InsertItem( DdeItem* ); // fuer eigene Ableitungen!
341 DdeItem* AddItem( const DdeItem& ); // werden kopiert !
342 void RemoveItem( const DdeItem& );
343 const OUString& GetCurItem() { return aItem; }
344 const std::vector<DdeItem*>& GetItems() const { return aItems; }
346 private:
347 DdeTopic( const DdeTopic& );
348 const DdeTopic& operator= ( const DdeTopic& );
351 // --------------
352 // - DdeService -
353 // --------------
355 class SVL_DLLPUBLIC DdeService
357 friend class DdeInternal;
359 public:
360 virtual sal_Bool IsBusy();
361 virtual String GetHelp();
362 // evt. ein neues anlegen; return 0 -> es konnte nicht angelegt werden
363 virtual sal_Bool MakeTopic( const OUString& rItem );
365 protected:
366 virtual String Topics();
367 virtual String Formats();
368 virtual String SysItems();
369 virtual String Status();
370 virtual String SysTopicGet( const String& );
371 virtual sal_Bool SysTopicExecute( const String* );
373 const DdeTopic* GetSysTopic() const { return pSysTopic; }
374 private:
375 std::vector<DdeTopic*> aTopics;
376 DdeFormats aFormats;
377 DdeTopic* pSysTopic;
378 DdeString* pName;
379 ConvList* pConv;
380 short nStatus;
382 SVL_DLLPRIVATE sal_Bool HasCbFormat( sal_uInt16 );
384 public:
385 DdeService( SAL_UNUSED_PARAMETER const String& );
386 virtual ~DdeService();
388 const OUString GetName() const;
389 short GetError() { return nStatus; }
391 static DdeServices& GetServices();
392 std::vector<DdeTopic*>& GetTopics() { return aTopics; }
394 void AddTopic( const DdeTopic& );
395 void RemoveTopic( const DdeTopic& );
397 void AddFormat( sal_uLong );
398 void RemoveFormat( sal_uLong );
399 sal_Bool HasFormat( sal_uLong );
401 private:
402 // DdeService( const DdeService& );
403 //int operator= ( const DdeService& );
406 // ------------------
407 // - DdeTransaction -
408 // ------------------
410 inline long DdeTransaction::GetError()
412 return rDde.GetError();
414 #endif // _SVDDE_HXX
416 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */