update credits
[LibreOffice.git] / include / svl / svdde.hxx
blob598aa3d7c384ed91dcbbe6c2e9ed73ac3b0c4d2f
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 INCLUDED_SVL_SVDDE_HXX
21 #define INCLUDED_SVL_SVDDE_HXX
23 #include <svl/svldllapi.h>
24 #include <sot/exchange.hxx>
25 #include <tools/solar.h>
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;
52 // - DdeData -
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( SotClipboardFormatId nFmt );
67 public:
68 DdeData();
69 DdeData( SAL_UNUSED_PARAMETER const void*, SAL_UNUSED_PARAMETER long, SAL_UNUSED_PARAMETER SotClipboardFormatId = SotClipboardFormatId::STRING );
70 DdeData( SAL_UNUSED_PARAMETER const OUString& );
71 DdeData( const DdeData& );
72 ~DdeData();
74 operator const void*() const;
75 operator long() const;
77 SotClipboardFormatId GetFormat() const;
79 DdeData& operator = ( const DdeData& );
81 static sal_uLong GetExternalFormat(SotClipboardFormatId nFmt);
82 static SotClipboardFormatId GetInternalFormat(sal_uLong nFmt);
86 // - DdeTransaction -
89 class SVL_DLLPUBLIC DdeTransaction
91 public:
92 virtual void Data( const DdeData* );
93 virtual void Done( bool bDataValid );
94 protected:
95 DdeConnection& rDde;
96 DdeData aDdeData;
97 DdeString* pName;
98 short nType;
99 sal_IntPtr nId;
100 sal_IntPtr nTime;
101 Link<> aData;
102 Link<> aDone;
103 bool bBusy;
105 DdeTransaction( DdeConnection&, SAL_UNUSED_PARAMETER const OUString&, 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( SotClipboardFormatId nFmt ) { aDdeData.SetFormat( nFmt ); }
122 SotClipboardFormatId GetFormat() const { return aDdeData.GetFormat(); }
124 long GetError();
126 private:
127 friend class DdeInternal;
128 friend class DdeConnection;
130 DdeTransaction( const DdeTransaction& ) SAL_DELETED_FUNCTION;
131 const DdeTransaction& operator= ( const DdeTransaction& ) SAL_DELETED_FUNCTION;
136 // - DdeLink -
139 class SVL_DLLPUBLIC DdeLink : public DdeTransaction
141 Link<> aNotify;
143 public:
144 DdeLink( DdeConnection&, const OUString&, long = 0 );
145 virtual ~DdeLink();
147 void SetNotifyHdl( const Link<>& rLink ) { aNotify = rLink; }
148 const Link<>& GetNotifyHdl() const { return aNotify; }
149 virtual void Notify();
153 // - DdeWarmLink -
156 class SVL_DLLPUBLIC DdeWarmLink : public DdeLink
158 public:
159 DdeWarmLink( DdeConnection&, const OUString&, long = 0 );
163 // - DdeHotLink -
166 class SVL_DLLPUBLIC DdeHotLink : public DdeLink
168 public:
169 DdeHotLink( DdeConnection&, const OUString&, long = 0 );
173 // - DdeRequest -
176 class SVL_DLLPUBLIC DdeRequest : public DdeTransaction
178 public:
179 DdeRequest( DdeConnection&, const OUString&, long = 0 );
183 // - DdePoke -
186 class SVL_DLLPUBLIC DdePoke : public DdeTransaction
188 public:
189 DdePoke( DdeConnection&, const OUString&, const char*, long,
190 SotClipboardFormatId = SotClipboardFormatId::STRING, long = 0 );
191 DdePoke( DdeConnection&, const OUString&, SAL_UNUSED_PARAMETER const DdeData&, long = 0 );
192 DdePoke( DdeConnection&, const OUString&, const OUString&, long = 0 );
196 // - DdeExecute -
199 class SVL_DLLPUBLIC DdeExecute : public DdeTransaction
201 public:
202 DdeExecute( DdeConnection&, const OUString&, long = 0 );
206 // - DdeConnection -
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 OUString&, SAL_UNUSED_PARAMETER const OUString& );
220 ~DdeConnection();
222 long GetError();
223 sal_IntPtr GetConvId();
225 static const std::vector<DdeConnection*>& GetConnections();
227 bool IsConnected();
229 const OUString GetServiceName();
230 const OUString GetTopicName();
232 private:
233 DdeConnection( const DdeConnection& ) SAL_DELETED_FUNCTION;
234 const DdeConnection& operator= ( const DdeConnection& ) SAL_DELETED_FUNCTION;
238 // - DdeItem -
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 OUString& );
258 DdeItem( const DdeItem& );
259 virtual ~DdeItem();
261 const OUString GetName() const;
262 short GetLinks();
263 void NotifyClient();
267 // - DdeItem -
270 class SVL_DLLPUBLIC DdeGetPutItem : public DdeItem
272 public:
273 DdeGetPutItem( const sal_Unicode* p );
274 DdeGetPutItem( const OUString& rStr );
275 DdeGetPutItem( const DdeItem& rItem );
277 virtual DdeData* Get( SotClipboardFormatId );
278 virtual bool Put( const DdeData* );
279 virtual void AdviseLoop( bool ); // Start / Stop AdviseLoop
283 // - DdeTopic -
286 class SVL_DLLPUBLIC DdeTopic
288 SVL_DLLPRIVATE void _Disconnect( sal_IntPtr );
290 public:
291 virtual void Connect( sal_IntPtr );
292 virtual void Disconnect( sal_IntPtr );
293 virtual DdeData* Get(SotClipboardFormatId);
294 virtual bool Put( const DdeData* );
295 virtual bool Execute( const OUString* );
296 // Eventually create a new item. return 0 -> Item creation failed
297 virtual bool MakeItem( const OUString& rItem );
300 // A Warm-/Hot-Link is created. Return true if successful
301 virtual bool StartAdviseLoop();
302 virtual 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 OUString& );
338 bool IsSystemTopic();
340 void InsertItem( DdeItem* ); // For own superclasses
341 DdeItem* AddItem( const DdeItem& ); // Will be cloned
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& ) SAL_DELETED_FUNCTION;
348 const DdeTopic& operator= ( const DdeTopic& ) SAL_DELETED_FUNCTION;
352 // - DdeService -
355 class SVL_DLLPUBLIC DdeService
357 friend class DdeInternal;
359 public:
360 virtual bool IsBusy();
361 virtual OUString GetHelp();
362 // Eventually creating a new item. return 0 -> Topic creation failed
363 virtual bool MakeTopic( const OUString& rItem );
365 protected:
366 virtual OUString Topics();
367 virtual OUString Formats();
368 virtual OUString SysItems();
369 virtual OUString Status();
370 virtual OUString SysTopicGet( const OUString& );
371 virtual bool SysTopicExecute( const OUString* );
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 bool HasCbFormat( sal_uInt16 );
384 public:
385 DdeService( SAL_UNUSED_PARAMETER const OUString& );
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(SotClipboardFormatId);
398 void RemoveFormat(SotClipboardFormatId);
399 bool HasFormat(SotClipboardFormatId);
401 private:
402 // DdeService( const DdeService& );
403 //int operator= ( const DdeService& );
407 // - DdeTransaction -
410 inline long DdeTransaction::GetError()
412 return rDde.GetError();
414 #endif // INCLUDED_SVL_SVDDE_HXX
416 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */