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>
48 typedef ::std::vector
< DdeService
* > DdeServices
;
49 typedef ::std::vector
< long > DdeFormats
;
50 typedef ::std::vector
< Conversation
* > ConvList
;
53 class SVL_DLLPUBLIC DdeData
55 friend class DdeInternal
;
56 friend class DdeService
;
57 friend class DdeConnection
;
58 friend class DdeTransaction
;
61 SVL_DLLPRIVATE
void Lock();
63 void SetFormat( SotClipboardFormatId nFmt
);
67 DdeData( SAL_UNUSED_PARAMETER
const void*, SAL_UNUSED_PARAMETER
long, SAL_UNUSED_PARAMETER SotClipboardFormatId
= SotClipboardFormatId::STRING
);
68 DdeData( SAL_UNUSED_PARAMETER
const OUString
& );
69 DdeData( const DdeData
& );
72 void const * getData() const;
75 SotClipboardFormatId
GetFormat() const;
77 DdeData
& operator = ( const DdeData
& );
79 static sal_uLong
GetExternalFormat(SotClipboardFormatId nFmt
);
80 static SotClipboardFormatId
GetInternalFormat(sal_uLong nFmt
);
84 class SVL_DLLPUBLIC DdeTransaction
87 void Data( const DdeData
* );
88 void Done( bool bDataValid
);
96 Link
<const DdeData
*,void> aData
;
97 Link
<bool,void> aDone
;
100 DdeTransaction( DdeConnection
&, SAL_UNUSED_PARAMETER
const OUString
&, SAL_UNUSED_PARAMETER
long = 0 );
103 virtual ~DdeTransaction();
105 bool IsBusy() { return bBusy
; }
106 const OUString
GetName() const;
110 void SetDataHdl( const Link
<const DdeData
*,void>& rLink
) { aData
= rLink
; }
111 const Link
<const DdeData
*,void>& GetDataHdl() const { return aData
; }
113 void SetDoneHdl( const Link
<bool,void>& rLink
) { aDone
= rLink
; }
114 const Link
<bool,void>& GetDoneHdl() const { return aDone
; }
116 void SetFormat( SotClipboardFormatId nFmt
) { aDdeData
.SetFormat( nFmt
); }
117 SotClipboardFormatId
GetFormat() const { return aDdeData
.GetFormat(); }
122 friend class DdeInternal
;
123 friend class DdeConnection
;
125 DdeTransaction( const DdeTransaction
& ) = delete;
126 const DdeTransaction
& operator= ( const DdeTransaction
& ) = delete;
131 class SVL_DLLPUBLIC DdeLink
: public DdeTransaction
133 Link
<void*,void> aNotify
;
136 DdeLink( DdeConnection
&, const OUString
&, long = 0 );
137 virtual ~DdeLink() override
;
139 void SetNotifyHdl( const Link
<void*,void>& rLink
) { aNotify
= rLink
; }
140 const Link
<void*,void>& GetNotifyHdl() const { return aNotify
; }
145 class SVL_DLLPUBLIC DdeHotLink
: public DdeLink
148 DdeHotLink( DdeConnection
&, const OUString
&, long = 0 );
152 class SVL_DLLPUBLIC DdeRequest
: public DdeTransaction
155 DdeRequest( DdeConnection
&, const OUString
&, long = 0 );
159 class SVL_DLLPUBLIC DdePoke
: public DdeTransaction
162 DdePoke( DdeConnection
&, const OUString
&, SAL_UNUSED_PARAMETER
const DdeData
&, long = 0 );
166 class SVL_DLLPUBLIC DdeExecute
: public DdeTransaction
169 DdeExecute( DdeConnection
&, const OUString
&, long = 0 );
173 class SVL_DLLPUBLIC DdeConnection
175 friend class DdeInternal
;
176 friend class DdeTransaction
;
177 std::vector
<DdeTransaction
*> aTransactions
;
183 DdeConnection( SAL_UNUSED_PARAMETER
const OUString
&, SAL_UNUSED_PARAMETER
const OUString
& );
188 static const std::vector
<DdeConnection
*>& GetConnections();
192 const OUString
GetServiceName();
193 const OUString
GetTopicName();
196 DdeConnection( const DdeConnection
& ) = delete;
197 const DdeConnection
& operator= ( const DdeConnection
& ) = delete;
201 class SVL_DLLPUBLIC DdeItem
203 friend class DdeInternal
;
204 friend class DdeTopic
;
207 DdeItemImp
* pImpData
;
213 DdeItem( const sal_Unicode
* );
214 DdeItem( SAL_UNUSED_PARAMETER
const OUString
& );
215 DdeItem( const DdeItem
& );
218 const OUString
GetName() const;
224 class SVL_DLLPUBLIC DdeGetPutItem
: public DdeItem
227 DdeGetPutItem( const sal_Unicode
* p
);
228 DdeGetPutItem( const OUString
& rStr
);
229 DdeGetPutItem( const DdeItem
& rItem
);
231 virtual DdeData
* Get( SotClipboardFormatId
);
232 virtual bool Put( const DdeData
* );
233 virtual void AdviseLoop( bool ); // Start / Stop AdviseLoop
237 class SVL_DLLPUBLIC DdeTopic
241 virtual DdeData
* Get(SotClipboardFormatId
);
242 virtual bool Put( const DdeData
* );
243 virtual bool Execute( const OUString
* );
244 // Eventually create a new item. return 0 -> Item creation failed
245 virtual bool MakeItem( const OUString
& rItem
);
247 // A Warm-/Hot-Link is created. Return true if successful
248 virtual bool StartAdviseLoop();
251 friend class DdeInternal
;
252 friend class DdeService
;
253 friend class DdeItem
;
258 std::vector
<DdeItem
*> aItems
;
261 DdeTopic( SAL_UNUSED_PARAMETER
const OUString
& );
264 const OUString
GetName() const;
266 void NotifyClient( const OUString
& );
267 bool IsSystemTopic();
269 void InsertItem( DdeItem
* ); // For own superclasses
270 DdeItem
* AddItem( const DdeItem
& ); // Will be cloned
271 void RemoveItem( const DdeItem
& );
272 const OUString
& GetCurItem() { return aItem
; }
273 const std::vector
<DdeItem
*>& GetItems() const { return aItems
; }
276 DdeTopic( const DdeTopic
& ) = delete;
277 const DdeTopic
& operator= ( const DdeTopic
& ) = delete;
281 class SVL_DLLPUBLIC DdeService
283 friend class DdeInternal
;
291 const DdeTopic
* GetSysTopic() const { return pSysTopic
; }
293 std::vector
<DdeTopic
*> aTopics
;
300 SVL_DLLPRIVATE
bool HasCbFormat( sal_uInt16
);
303 DdeService( SAL_UNUSED_PARAMETER
const OUString
& );
304 virtual ~DdeService();
306 const OUString
GetName() const;
307 short GetError() { return nStatus
; }
309 static DdeServices
& GetServices();
310 std::vector
<DdeTopic
*>& GetTopics() { return aTopics
; }
312 void AddTopic( const DdeTopic
& );
313 void RemoveTopic( const DdeTopic
& );
315 void AddFormat(SotClipboardFormatId
);
316 void RemoveFormat(SotClipboardFormatId
);
317 bool HasFormat(SotClipboardFormatId
);
321 inline long DdeTransaction::GetError()
323 return rDde
.GetError();
325 #endif // INCLUDED_SVL_SVDDE_HXX
327 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */