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 .
23 #include "svl/svldllapi.h"
24 #include <sot/exchange.hxx>
25 #include <tools/string.hxx>
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( sal_uLong nFmt
);
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
& );
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
);
89 class SVL_DLLPUBLIC DdeTransaction
92 virtual void Data( const DdeData
* );
93 virtual void Done( sal_Bool bDataValid
);
105 DdeTransaction( DdeConnection
&, SAL_UNUSED_PARAMETER
const String
&, 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( sal_uLong nFmt
) { aDdeData
.SetFormat( nFmt
); }
122 sal_uLong
GetFormat() const { return aDdeData
.GetFormat(); }
127 friend class DdeInternal
;
128 friend class DdeConnection
;
130 DdeTransaction( const DdeTransaction
& );
131 const DdeTransaction
& operator= ( const DdeTransaction
& );
139 class SVL_DLLPUBLIC DdeLink
: public DdeTransaction
144 DdeLink( DdeConnection
&, const String
&, 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 String
&, long = 0 );
166 class SVL_DLLPUBLIC DdeHotLink
: public DdeLink
169 DdeHotLink( DdeConnection
&, const String
&, long = 0 );
176 class SVL_DLLPUBLIC DdeRequest
: public DdeTransaction
179 DdeRequest( DdeConnection
&, const String
&, long = 0 );
186 class SVL_DLLPUBLIC DdePoke
: public DdeTransaction
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 );
199 class SVL_DLLPUBLIC DdeExecute
: public DdeTransaction
202 DdeExecute( DdeConnection
&, const String
&, 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 String
&, SAL_UNUSED_PARAMETER
const String
& );
225 static const std::vector
<DdeConnection
*>& GetConnections();
227 sal_Bool
IsConnected();
229 const String
& GetServiceName();
230 const String
& GetTopicName();
233 DdeConnection( const DdeConnection
& );
234 const DdeConnection
& operator= ( const DdeConnection
& );
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 String
& );
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 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
286 class SVL_DLLPUBLIC DdeTopic
288 SVL_DLLPRIVATE
void _Disconnect( long );
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();
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 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
; }
347 DdeTopic( const DdeTopic
& );
348 const DdeTopic
& operator= ( const DdeTopic
& );
355 class SVL_DLLPUBLIC DdeService
357 friend class DdeInternal
;
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
);
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
; }
375 std::vector
<DdeTopic
*> aTopics
;
382 SVL_DLLPRIVATE sal_Bool
HasCbFormat( sal_uInt16
);
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
);
402 // DdeService( const DdeService& );
403 //int operator= ( const DdeService& );
406 // ------------------
407 // - DdeTransaction -
408 // ------------------
410 inline long DdeTransaction::GetError()
412 return rDde
.GetError();
416 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */