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>
30 #include <tools/long.hxx>
40 struct DdeItemImpData
;
43 typedef ::std::vector
< DdeService
* > DdeServices
;
46 class SVL_DLLPUBLIC DdeData
48 friend class DdeInternal
;
49 friend class DdeService
;
50 friend class DdeConnection
;
51 friend class DdeTransaction
;
52 std::unique_ptr
<DdeDataImp
> xImp
;
54 SVL_DLLPRIVATE
void Lock();
56 void SetFormat( SotClipboardFormatId nFmt
);
60 DdeData(SAL_UNUSED_PARAMETER
const void*, SAL_UNUSED_PARAMETER
tools::Long
, SAL_UNUSED_PARAMETER SotClipboardFormatId
= SotClipboardFormatId::STRING
);
61 DdeData(SAL_UNUSED_PARAMETER
const OUString
&);
62 DdeData(const DdeData
&);
63 DdeData(DdeData
&&) noexcept
;
66 void const * getData() const;
67 tools::Long
getSize() const;
69 SotClipboardFormatId
GetFormat() const;
71 DdeData
& operator=(const DdeData
&);
72 DdeData
& operator=(DdeData
&&) noexcept
;
74 static sal_uInt32
GetExternalFormat(SotClipboardFormatId nFmt
);
75 static SotClipboardFormatId
GetInternalFormat(sal_uInt32 nFmt
);
79 class SVL_DLLPUBLIC DdeTransaction
82 void Data( const DdeData
* );
83 void Done( bool bDataValid
);
91 Link
<const DdeData
*,void> aData
;
92 Link
<bool,void> aDone
;
95 DdeTransaction( DdeConnection
&, SAL_UNUSED_PARAMETER
const OUString
&, SAL_UNUSED_PARAMETER
tools::Long
= 0 );
98 virtual ~DdeTransaction();
100 bool IsBusy() const { return bBusy
; }
101 OUString
GetName() const;
105 void SetDataHdl( const Link
<const DdeData
*,void>& rLink
) { aData
= rLink
; }
106 const Link
<const DdeData
*,void>& GetDataHdl() const { return aData
; }
108 void SetDoneHdl( const Link
<bool,void>& rLink
) { aDone
= rLink
; }
109 const Link
<bool,void>& GetDoneHdl() const { return aDone
; }
111 void SetFormat( SotClipboardFormatId nFmt
) { aDdeData
.SetFormat( nFmt
); }
112 SotClipboardFormatId
GetFormat() const { return aDdeData
.GetFormat(); }
114 tools::Long
GetError() const;
117 friend class DdeInternal
;
118 friend class DdeConnection
;
120 DdeTransaction( const DdeTransaction
& ) = delete;
121 const DdeTransaction
& operator= ( const DdeTransaction
& ) = delete;
126 class SVL_DLLPUBLIC DdeLink
: public DdeTransaction
128 Link
<void*,void> aNotify
;
131 DdeLink( DdeConnection
&, const OUString
&, tools::Long
= 0 );
132 virtual ~DdeLink() override
;
134 void SetNotifyHdl( const Link
<void*,void>& rLink
) { aNotify
= rLink
; }
135 const Link
<void*,void>& GetNotifyHdl() const { return aNotify
; }
140 class SVL_DLLPUBLIC DdeHotLink
: public DdeLink
143 DdeHotLink( DdeConnection
&, const OUString
& );
147 class SVL_DLLPUBLIC DdeRequest
: public DdeTransaction
150 DdeRequest( DdeConnection
&, const OUString
&, tools::Long
= 0 );
154 class SVL_DLLPUBLIC DdePoke
: public DdeTransaction
157 DdePoke( DdeConnection
&, const OUString
&, SAL_UNUSED_PARAMETER
const DdeData
&, tools::Long
= 0 );
161 class SVL_DLLPUBLIC DdeExecute
: public DdeTransaction
164 DdeExecute( DdeConnection
&, const OUString
&, tools::Long
= 0 );
168 class SVL_DLLPUBLIC DdeConnection
170 friend class DdeInternal
;
171 friend class DdeTransaction
;
172 std::vector
<DdeTransaction
*> aTransactions
;
175 std::unique_ptr
<DdeImp
> pImp
;
178 DdeConnection( SAL_UNUSED_PARAMETER
const OUString
&, SAL_UNUSED_PARAMETER
const OUString
& );
181 tools::Long
GetError() const;
183 static const std::vector
<DdeConnection
*>& GetConnections();
187 OUString
GetServiceName() const;
188 OUString
GetTopicName() const;
191 DdeConnection( const DdeConnection
& ) = delete;
192 const DdeConnection
& operator= ( const DdeConnection
& ) = delete;
196 class SVL_DLLPUBLIC DdeItem
198 friend class DdeInternal
;
199 friend class DdeTopic
;
202 std::vector
<DdeItemImpData
>* pImpData
;
208 DdeItem( const sal_Unicode
* );
209 DdeItem( SAL_UNUSED_PARAMETER
const OUString
& );
210 DdeItem( const DdeItem
& );
213 OUString
GetName() const;
219 class SVL_DLLPUBLIC DdeGetPutItem
: public DdeItem
222 DdeGetPutItem( const sal_Unicode
* p
);
223 DdeGetPutItem( const OUString
& rStr
);
224 DdeGetPutItem( const DdeItem
& rItem
);
226 virtual DdeData
* Get( SotClipboardFormatId
);
227 virtual bool Put( const DdeData
* );
228 virtual void AdviseLoop( bool ); // Start / Stop AdviseLoop
232 class SVL_DLLPUBLIC DdeTopic
236 virtual DdeData
* Get(SotClipboardFormatId
);
237 virtual bool Put( const DdeData
* );
238 virtual bool Execute( const OUString
* );
239 // Eventually create a new item. return 0 -> Item creation failed
240 virtual bool MakeItem( const OUString
& rItem
);
242 // A Warm-/Hot-Link is created. Return true if successful
243 virtual bool StartAdviseLoop();
246 friend class DdeInternal
;
247 friend class DdeService
;
248 friend class DdeItem
;
253 std::vector
<DdeItem
*> aItems
;
256 DdeTopic( SAL_UNUSED_PARAMETER
const OUString
& );
259 OUString
GetName() const;
261 void NotifyClient( const OUString
& );
262 bool IsSystemTopic();
264 void InsertItem( DdeItem
* ); // For own superclasses
265 DdeItem
* AddItem( const DdeItem
& ); // Will be cloned
266 void RemoveItem( const DdeItem
& );
267 const OUString
& GetCurItem() const { return aItem
; }
268 const std::vector
<DdeItem
*>& GetItems() const { return aItems
; }
271 DdeTopic( const DdeTopic
& ) = delete;
272 const DdeTopic
& operator= ( const DdeTopic
& ) = delete;
276 class SVL_DLLPUBLIC DdeService
278 friend class DdeInternal
;
286 const DdeTopic
* GetSysTopic() const { return pSysTopic
; }
288 std::vector
<DdeTopic
*> aTopics
;
289 std::vector
< sal_uInt32
> aFormats
;
292 std::vector
<std::unique_ptr
<Conversation
>>
296 SVL_DLLPRIVATE
bool HasCbFormat( sal_uInt32
);
299 DdeService( SAL_UNUSED_PARAMETER
const OUString
& );
300 virtual ~DdeService();
302 DdeService( const DdeService
& ) = delete;
303 DdeService
& operator= ( const DdeService
& ) = delete;
305 OUString
GetName() const;
306 short GetError() const { 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 tools::Long
DdeTransaction::GetError() const
322 return rDde
.GetError();
324 #endif // INCLUDED_SVL_SVDDE_HXX
326 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */