1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
47 typedef ::std::vector
< DdeService
* > DdeServices
;
48 typedef ::std::vector
< long > DdeFormats
;
49 typedef ::std::vector
< Conversation
* > ConvList
;
55 class SVL_DLLPUBLIC DdeData
57 friend class DdeInternal
;
58 friend class DdeService
;
59 friend class DdeConnection
;
60 friend class DdeTransaction
;
63 SVL_DLLPRIVATE
void Lock();
65 void SetFormat( SotClipboardFormatId nFmt
);
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
& );
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
);
89 class SVL_DLLPUBLIC DdeTransaction
92 virtual void Data( const DdeData
* );
93 virtual void Done( bool bDataValid
);
105 DdeTransaction( DdeConnection
&, SAL_UNUSED_PARAMETER
const OUString
&, SAL_UNUSED_PARAMETER
long = 0 );
108 virtual ~DdeTransaction();
110 bool IsBusy() { return bBusy
; }
111 const OUString
GetName() const;
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(); }
127 friend class DdeInternal
;
128 friend class DdeConnection
;
130 DdeTransaction( const DdeTransaction
& ) SAL_DELETED_FUNCTION
;
131 const DdeTransaction
& operator= ( const DdeTransaction
& ) SAL_DELETED_FUNCTION
;
139 class SVL_DLLPUBLIC DdeLink
: public DdeTransaction
144 DdeLink( DdeConnection
&, const OUString
&, long = 0 );
147 void SetNotifyHdl( const Link
<>& rLink
) { aNotify
= rLink
; }
148 const Link
<>& GetNotifyHdl() const { return aNotify
; }
149 virtual void Notify();
156 class SVL_DLLPUBLIC DdeWarmLink
: public DdeLink
159 DdeWarmLink( DdeConnection
&, const OUString
&, long = 0 );
166 class SVL_DLLPUBLIC DdeHotLink
: public DdeLink
169 DdeHotLink( DdeConnection
&, const OUString
&, long = 0 );
176 class SVL_DLLPUBLIC DdeRequest
: public DdeTransaction
179 DdeRequest( DdeConnection
&, const OUString
&, long = 0 );
186 class SVL_DLLPUBLIC DdePoke
: public DdeTransaction
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 );
199 class SVL_DLLPUBLIC DdeExecute
: public DdeTransaction
202 DdeExecute( DdeConnection
&, const OUString
&, long = 0 );
209 class SVL_DLLPUBLIC DdeConnection
211 friend class DdeInternal
;
212 friend class DdeTransaction
;
213 std::vector
<DdeTransaction
*> aTransactions
;
219 DdeConnection( SAL_UNUSED_PARAMETER
const OUString
&, SAL_UNUSED_PARAMETER
const OUString
& );
223 sal_IntPtr
GetConvId();
225 static const std::vector
<DdeConnection
*>& GetConnections();
229 const OUString
GetServiceName();
230 const OUString
GetTopicName();
233 DdeConnection( const DdeConnection
& ) SAL_DELETED_FUNCTION
;
234 const DdeConnection
& operator= ( const DdeConnection
& ) SAL_DELETED_FUNCTION
;
241 class SVL_DLLPUBLIC DdeItem
243 friend class DdeInternal
;
244 friend class DdeTopic
;
247 DdeItemImp
* pImpData
;
249 void IncMonitor( sal_uLong
);
250 void DecMonitor( sal_uLong
);
256 DdeItem( const sal_Unicode
* );
257 DdeItem( SAL_UNUSED_PARAMETER
const OUString
& );
258 DdeItem( const DdeItem
& );
261 const OUString
GetName() const;
270 class SVL_DLLPUBLIC DdeGetPutItem
: public DdeItem
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
286 class SVL_DLLPUBLIC DdeTopic
288 SVL_DLLPRIVATE
void _Disconnect( sal_IntPtr
);
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();
305 friend class DdeInternal
;
306 friend class DdeService
;
307 friend class DdeItem
;
312 std::vector
<DdeItem
*> aItems
;
314 Link
<> aDisconnectLink
;
320 DdeTopic( SAL_UNUSED_PARAMETER
const OUString
& );
323 const OUString
GetName() const;
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
; }
347 DdeTopic( const DdeTopic
& ) SAL_DELETED_FUNCTION
;
348 const DdeTopic
& operator= ( const DdeTopic
& ) SAL_DELETED_FUNCTION
;
355 class SVL_DLLPUBLIC DdeService
357 friend class DdeInternal
;
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
);
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
; }
375 std::vector
<DdeTopic
*> aTopics
;
382 SVL_DLLPRIVATE
bool HasCbFormat( sal_uInt16
);
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
);
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: */