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 <sal/config.h>
25 #include <svl/svldllapi.h>
26 #include <sot/formats.hxx>
27 #include <rtl/ustring.hxx>
28 #include <tools/solar.h>
29 #include <tools/link.hxx>
39 struct DdeItemImpData
;
42 typedef ::std::vector
< DdeService
* > DdeServices
;
43 typedef ::std::vector
< long > DdeFormats
;
44 typedef std::vector
<std::unique_ptr
<Conversation
>> ConvList
;
47 class SVL_DLLPUBLIC DdeData
49 friend class DdeInternal
;
50 friend class DdeService
;
51 friend class DdeConnection
;
52 friend class DdeTransaction
;
53 std::unique_ptr
<DdeDataImp
> xImp
;
55 SVL_DLLPRIVATE
void Lock();
57 void SetFormat( SotClipboardFormatId nFmt
);
61 DdeData(SAL_UNUSED_PARAMETER
const void*, SAL_UNUSED_PARAMETER
long, SAL_UNUSED_PARAMETER SotClipboardFormatId
= SotClipboardFormatId::STRING
);
62 DdeData(SAL_UNUSED_PARAMETER
const OUString
&);
63 DdeData(const DdeData
&);
67 void const * getData() const;
70 SotClipboardFormatId
GetFormat() const;
72 DdeData
& operator=(const DdeData
&);
73 DdeData
& operator=(DdeData
&&);
75 static sal_uLong
GetExternalFormat(SotClipboardFormatId nFmt
);
76 static SotClipboardFormatId
GetInternalFormat(sal_uLong nFmt
);
80 class SVL_DLLPUBLIC DdeTransaction
83 void Data( const DdeData
* );
84 void Done( bool bDataValid
);
92 Link
<const DdeData
*,void> aData
;
93 Link
<bool,void> aDone
;
96 DdeTransaction( DdeConnection
&, SAL_UNUSED_PARAMETER
const OUString
&, SAL_UNUSED_PARAMETER
long = 0 );
99 virtual ~DdeTransaction();
101 bool IsBusy() { return bBusy
; }
102 const OUString
GetName() const;
106 void SetDataHdl( const Link
<const DdeData
*,void>& rLink
) { aData
= rLink
; }
107 const Link
<const DdeData
*,void>& GetDataHdl() const { return aData
; }
109 void SetDoneHdl( const Link
<bool,void>& rLink
) { aDone
= rLink
; }
110 const Link
<bool,void>& GetDoneHdl() const { return aDone
; }
112 void SetFormat( SotClipboardFormatId nFmt
) { aDdeData
.SetFormat( nFmt
); }
113 SotClipboardFormatId
GetFormat() const { return aDdeData
.GetFormat(); }
118 friend class DdeInternal
;
119 friend class DdeConnection
;
121 DdeTransaction( const DdeTransaction
& ) = delete;
122 const DdeTransaction
& operator= ( const DdeTransaction
& ) = delete;
127 class SVL_DLLPUBLIC DdeLink
: public DdeTransaction
129 Link
<void*,void> aNotify
;
132 DdeLink( DdeConnection
&, const OUString
&, long = 0 );
133 virtual ~DdeLink() override
;
135 void SetNotifyHdl( const Link
<void*,void>& rLink
) { aNotify
= rLink
; }
136 const Link
<void*,void>& GetNotifyHdl() const { return aNotify
; }
141 class SVL_DLLPUBLIC DdeHotLink
: public DdeLink
144 DdeHotLink( DdeConnection
&, const OUString
& );
148 class SVL_DLLPUBLIC DdeRequest
: public DdeTransaction
151 DdeRequest( DdeConnection
&, const OUString
&, long = 0 );
155 class SVL_DLLPUBLIC DdePoke
: public DdeTransaction
158 DdePoke( DdeConnection
&, const OUString
&, SAL_UNUSED_PARAMETER
const DdeData
&, long = 0 );
162 class SVL_DLLPUBLIC DdeExecute
: public DdeTransaction
165 DdeExecute( DdeConnection
&, const OUString
&, long = 0 );
169 class SVL_DLLPUBLIC DdeConnection
171 friend class DdeInternal
;
172 friend class DdeTransaction
;
173 std::vector
<DdeTransaction
*> aTransactions
;
176 std::unique_ptr
<DdeImp
> pImp
;
179 DdeConnection( SAL_UNUSED_PARAMETER
const OUString
&, SAL_UNUSED_PARAMETER
const OUString
& );
184 static const std::vector
<DdeConnection
*>& GetConnections();
188 const OUString
GetServiceName();
189 const OUString
GetTopicName();
192 DdeConnection( const DdeConnection
& ) = delete;
193 const DdeConnection
& operator= ( const DdeConnection
& ) = delete;
197 class SVL_DLLPUBLIC DdeItem
199 friend class DdeInternal
;
200 friend class DdeTopic
;
203 std::vector
<DdeItemImpData
>* pImpData
;
209 DdeItem( const sal_Unicode
* );
210 DdeItem( SAL_UNUSED_PARAMETER
const OUString
& );
211 DdeItem( const DdeItem
& );
214 const OUString
GetName() const;
220 class SVL_DLLPUBLIC DdeGetPutItem
: public DdeItem
223 DdeGetPutItem( const sal_Unicode
* p
);
224 DdeGetPutItem( const OUString
& rStr
);
225 DdeGetPutItem( const DdeItem
& rItem
);
227 virtual DdeData
* Get( SotClipboardFormatId
);
228 virtual bool Put( const DdeData
* );
229 virtual void AdviseLoop( bool ); // Start / Stop AdviseLoop
233 class SVL_DLLPUBLIC DdeTopic
237 virtual DdeData
* Get(SotClipboardFormatId
);
238 virtual bool Put( const DdeData
* );
239 virtual bool Execute( const OUString
* );
240 // Eventually create a new item. return 0 -> Item creation failed
241 virtual bool MakeItem( const OUString
& rItem
);
243 // A Warm-/Hot-Link is created. Return true if successful
244 virtual bool StartAdviseLoop();
247 friend class DdeInternal
;
248 friend class DdeService
;
249 friend class DdeItem
;
254 std::vector
<DdeItem
*> aItems
;
257 DdeTopic( SAL_UNUSED_PARAMETER
const OUString
& );
260 const OUString
GetName() const;
262 void NotifyClient( const OUString
& );
263 bool IsSystemTopic();
265 void InsertItem( DdeItem
* ); // For own superclasses
266 DdeItem
* AddItem( const DdeItem
& ); // Will be cloned
267 void RemoveItem( const DdeItem
& );
268 const OUString
& GetCurItem() { return aItem
; }
269 const std::vector
<DdeItem
*>& GetItems() const { return aItems
; }
272 DdeTopic( const DdeTopic
& ) = delete;
273 const DdeTopic
& operator= ( const DdeTopic
& ) = delete;
277 class SVL_DLLPUBLIC DdeService
279 friend class DdeInternal
;
287 const DdeTopic
* GetSysTopic() const { return pSysTopic
; }
289 std::vector
<DdeTopic
*> aTopics
;
296 SVL_DLLPRIVATE
bool HasCbFormat( sal_uInt16
);
299 DdeService( SAL_UNUSED_PARAMETER
const OUString
& );
300 virtual ~DdeService();
302 DdeService( const DdeService
& ) = delete;
303 DdeService
& operator= ( const DdeService
& ) = delete;
305 const OUString
GetName() const;
306 short GetError() { return nStatus
; }
308 static DdeServices
& GetServices();
309 std::vector
<DdeTopic
*>& GetTopics() { return aTopics
; }
311 void AddTopic( const DdeTopic
& );
312 void RemoveTopic( const DdeTopic
& );
314 void AddFormat(SotClipboardFormatId
);
315 void RemoveFormat(SotClipboardFormatId
);
316 bool HasFormat(SotClipboardFormatId
);
320 inline long DdeTransaction::GetError()
322 return rDde
.GetError();
324 #endif // INCLUDED_SVL_SVDDE_HXX
326 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */