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/exchange.hxx>
27 #include <tools/solar.h>
28 #include <tools/link.hxx>
49 typedef ::std::vector
< DdeService
* > DdeServices
;
50 typedef ::std::vector
< long > DdeFormats
;
51 typedef ::std::vector
< Conversation
* > ConvList
;
54 class SVL_DLLPUBLIC DdeData
56 friend class DdeInternal
;
57 friend class DdeService
;
58 friend class DdeConnection
;
59 friend class DdeTransaction
;
60 std::unique_ptr
<DdeDataImp
> xImp
;
62 SVL_DLLPRIVATE
void Lock();
64 void SetFormat( SotClipboardFormatId nFmt
);
68 DdeData(SAL_UNUSED_PARAMETER
const void*, SAL_UNUSED_PARAMETER
long, SAL_UNUSED_PARAMETER SotClipboardFormatId
= SotClipboardFormatId::STRING
);
69 DdeData(SAL_UNUSED_PARAMETER
const OUString
&);
70 DdeData(const DdeData
&);
74 void const * getData() const;
77 SotClipboardFormatId
GetFormat() const;
79 DdeData
& operator=(const DdeData
&);
80 DdeData
& operator=(DdeData
&&);
82 static sal_uLong
GetExternalFormat(SotClipboardFormatId nFmt
);
83 static SotClipboardFormatId
GetInternalFormat(sal_uLong nFmt
);
87 class SVL_DLLPUBLIC DdeTransaction
90 void Data( const DdeData
* );
91 void Done( bool bDataValid
);
99 Link
<const DdeData
*,void> aData
;
100 Link
<bool,void> aDone
;
103 DdeTransaction( DdeConnection
&, SAL_UNUSED_PARAMETER
const OUString
&, SAL_UNUSED_PARAMETER
long = 0 );
106 virtual ~DdeTransaction();
108 bool IsBusy() { return bBusy
; }
109 const OUString
GetName() const;
113 void SetDataHdl( const Link
<const DdeData
*,void>& rLink
) { aData
= rLink
; }
114 const Link
<const DdeData
*,void>& GetDataHdl() const { return aData
; }
116 void SetDoneHdl( const Link
<bool,void>& rLink
) { aDone
= rLink
; }
117 const Link
<bool,void>& GetDoneHdl() const { return aDone
; }
119 void SetFormat( SotClipboardFormatId nFmt
) { aDdeData
.SetFormat( nFmt
); }
120 SotClipboardFormatId
GetFormat() const { return aDdeData
.GetFormat(); }
125 friend class DdeInternal
;
126 friend class DdeConnection
;
128 DdeTransaction( const DdeTransaction
& ) = delete;
129 const DdeTransaction
& operator= ( const DdeTransaction
& ) = delete;
134 class SVL_DLLPUBLIC DdeLink
: public DdeTransaction
136 Link
<void*,void> aNotify
;
139 DdeLink( DdeConnection
&, const OUString
&, long = 0 );
140 virtual ~DdeLink() override
;
142 void SetNotifyHdl( const Link
<void*,void>& rLink
) { aNotify
= rLink
; }
143 const Link
<void*,void>& GetNotifyHdl() const { return aNotify
; }
148 class SVL_DLLPUBLIC DdeHotLink
: public DdeLink
151 DdeHotLink( DdeConnection
&, const OUString
& );
155 class SVL_DLLPUBLIC DdeRequest
: public DdeTransaction
158 DdeRequest( DdeConnection
&, const OUString
&, long = 0 );
162 class SVL_DLLPUBLIC DdePoke
: public DdeTransaction
165 DdePoke( DdeConnection
&, const OUString
&, SAL_UNUSED_PARAMETER
const DdeData
&, long = 0 );
169 class SVL_DLLPUBLIC DdeExecute
: public DdeTransaction
172 DdeExecute( DdeConnection
&, const OUString
&, long = 0 );
176 class SVL_DLLPUBLIC DdeConnection
178 friend class DdeInternal
;
179 friend class DdeTransaction
;
180 std::vector
<DdeTransaction
*> aTransactions
;
186 DdeConnection( SAL_UNUSED_PARAMETER
const OUString
&, SAL_UNUSED_PARAMETER
const OUString
& );
191 static const std::vector
<DdeConnection
*>& GetConnections();
195 const OUString
GetServiceName();
196 const OUString
GetTopicName();
199 DdeConnection( const DdeConnection
& ) = delete;
200 const DdeConnection
& operator= ( const DdeConnection
& ) = delete;
204 class SVL_DLLPUBLIC DdeItem
206 friend class DdeInternal
;
207 friend class DdeTopic
;
210 DdeItemImp
* pImpData
;
216 DdeItem( const sal_Unicode
* );
217 DdeItem( SAL_UNUSED_PARAMETER
const OUString
& );
218 DdeItem( const DdeItem
& );
221 const OUString
GetName() const;
227 class SVL_DLLPUBLIC DdeGetPutItem
: public DdeItem
230 DdeGetPutItem( const sal_Unicode
* p
);
231 DdeGetPutItem( const OUString
& rStr
);
232 DdeGetPutItem( const DdeItem
& rItem
);
234 virtual DdeData
* Get( SotClipboardFormatId
);
235 virtual bool Put( const DdeData
* );
236 virtual void AdviseLoop( bool ); // Start / Stop AdviseLoop
240 class SVL_DLLPUBLIC DdeTopic
244 virtual DdeData
* Get(SotClipboardFormatId
);
245 virtual bool Put( const DdeData
* );
246 virtual bool Execute( const OUString
* );
247 // Eventually create a new item. return 0 -> Item creation failed
248 virtual bool MakeItem( const OUString
& rItem
);
250 // A Warm-/Hot-Link is created. Return true if successful
251 virtual bool StartAdviseLoop();
254 friend class DdeInternal
;
255 friend class DdeService
;
256 friend class DdeItem
;
261 std::vector
<DdeItem
*> aItems
;
264 DdeTopic( SAL_UNUSED_PARAMETER
const OUString
& );
267 const OUString
GetName() const;
269 void NotifyClient( const OUString
& );
270 bool IsSystemTopic();
272 void InsertItem( DdeItem
* ); // For own superclasses
273 DdeItem
* AddItem( const DdeItem
& ); // Will be cloned
274 void RemoveItem( const DdeItem
& );
275 const OUString
& GetCurItem() { return aItem
; }
276 const std::vector
<DdeItem
*>& GetItems() const { return aItems
; }
279 DdeTopic( const DdeTopic
& ) = delete;
280 const DdeTopic
& operator= ( const DdeTopic
& ) = delete;
284 class SVL_DLLPUBLIC DdeService
286 friend class DdeInternal
;
294 const DdeTopic
* GetSysTopic() const { return pSysTopic
; }
296 std::vector
<DdeTopic
*> aTopics
;
303 SVL_DLLPRIVATE
bool HasCbFormat( sal_uInt16
);
306 DdeService( SAL_UNUSED_PARAMETER
const OUString
& );
307 virtual ~DdeService();
309 const OUString
GetName() const;
310 short GetError() { return nStatus
; }
312 static DdeServices
& GetServices();
313 std::vector
<DdeTopic
*>& GetTopics() { return aTopics
; }
315 void AddTopic( const DdeTopic
& );
316 void RemoveTopic( const DdeTopic
& );
318 void AddFormat(SotClipboardFormatId
);
319 void RemoveFormat(SotClipboardFormatId
);
320 bool HasFormat(SotClipboardFormatId
);
324 inline long DdeTransaction::GetError()
326 return rDde
.GetError();
328 #endif // INCLUDED_SVL_SVDDE_HXX
330 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */