Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / svl / svdde.hxx
blobd90dbed606e7eaab47f82fc0950026a2d64832f5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
29 #include <memory>
30 #include <vector>
32 class DdeString;
33 class DdeData;
34 class DdeConnection;
35 class DdeTransaction;
36 class DdeLink;
37 class DdeRequest;
38 class DdeHotLink;
39 class DdePoke;
40 class DdeExecute;
41 class DdeItem;
42 class DdeTopic;
43 class DdeService;
44 struct DdeDataImp;
45 struct DdeImp;
46 class DdeItemImp;
47 struct Conversation;
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 );
66 public:
67 DdeData();
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&);
71 DdeData(DdeData&&);
72 ~DdeData();
74 void const * getData() const;
75 long getSize() 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
89 public:
90 void Data( const DdeData* );
91 void Done( bool bDataValid );
92 protected:
93 DdeConnection& rDde;
94 DdeData aDdeData;
95 DdeString* pName;
96 short nType;
97 sal_IntPtr nId;
98 sal_IntPtr nTime;
99 Link<const DdeData*,void> aData;
100 Link<bool,void> aDone;
101 bool bBusy;
103 DdeTransaction( DdeConnection&, SAL_UNUSED_PARAMETER const OUString&, SAL_UNUSED_PARAMETER long = 0 );
105 public:
106 virtual ~DdeTransaction();
108 bool IsBusy() { return bBusy; }
109 const OUString GetName() const;
111 void Execute();
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(); }
122 long GetError();
124 private:
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;
138 public:
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; }
144 void Notify();
148 class SVL_DLLPUBLIC DdeHotLink : public DdeLink
150 public:
151 DdeHotLink( DdeConnection&, const OUString& );
155 class SVL_DLLPUBLIC DdeRequest : public DdeTransaction
157 public:
158 DdeRequest( DdeConnection&, const OUString&, long = 0 );
162 class SVL_DLLPUBLIC DdePoke : public DdeTransaction
164 public:
165 DdePoke( DdeConnection&, const OUString&, SAL_UNUSED_PARAMETER const DdeData&, long = 0 );
169 class SVL_DLLPUBLIC DdeExecute : public DdeTransaction
171 public:
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;
181 DdeString* pService;
182 DdeString* pTopic;
183 DdeImp* pImp;
185 public:
186 DdeConnection( SAL_UNUSED_PARAMETER const OUString&, SAL_UNUSED_PARAMETER const OUString& );
187 ~DdeConnection();
189 long GetError();
191 static const std::vector<DdeConnection*>& GetConnections();
193 bool IsConnected();
195 const OUString GetServiceName();
196 const OUString GetTopicName();
198 private:
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;
208 DdeString* pName;
209 DdeTopic* pMyTopic;
210 DdeItemImp* pImpData;
212 protected:
213 sal_uInt8 nType;
215 public:
216 DdeItem( const sal_Unicode* );
217 DdeItem( SAL_UNUSED_PARAMETER const OUString& );
218 DdeItem( const DdeItem& );
219 virtual ~DdeItem();
221 const OUString GetName() const;
222 short GetLinks();
223 void NotifyClient();
227 class SVL_DLLPUBLIC DdeGetPutItem : public DdeItem
229 public:
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
243 public:
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();
253 private:
254 friend class DdeInternal;
255 friend class DdeService;
256 friend class DdeItem;
258 private:
259 DdeString* pName;
260 OUString aItem;
261 std::vector<DdeItem*> aItems;
263 public:
264 DdeTopic( SAL_UNUSED_PARAMETER const OUString& );
265 virtual ~DdeTopic();
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; }
278 private:
279 DdeTopic( const DdeTopic& ) = delete;
280 const DdeTopic& operator= ( const DdeTopic& ) = delete;
284 class SVL_DLLPUBLIC DdeService
286 friend class DdeInternal;
288 protected:
289 OUString Topics();
290 OUString Formats();
291 OUString SysItems();
292 OUString Status();
294 const DdeTopic* GetSysTopic() const { return pSysTopic; }
295 private:
296 std::vector<DdeTopic*> aTopics;
297 DdeFormats aFormats;
298 DdeTopic* pSysTopic;
299 DdeString* pName;
300 ConvList* pConv;
301 short nStatus;
303 SVL_DLLPRIVATE bool HasCbFormat( sal_uInt16 );
305 public:
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: */