build fix
[LibreOffice.git] / include / svl / svdde.hxx
blob766430f488fc0121437eb8b9e8fca8cf52d7914e
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 <vector>
31 class DdeString;
32 class DdeData;
33 class DdeConnection;
34 class DdeTransaction;
35 class DdeLink;
36 class DdeRequest;
37 class DdeHotLink;
38 class DdePoke;
39 class DdeExecute;
40 class DdeItem;
41 class DdeTopic;
42 class DdeService;
43 struct DdeDataImp;
44 struct DdeImp;
45 class DdeItemImp;
46 struct Conversation;
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;
59 DdeDataImp* pImp;
61 SVL_DLLPRIVATE void Lock();
63 void SetFormat( SotClipboardFormatId nFmt );
65 public:
66 DdeData();
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& );
70 ~DdeData();
72 void const * getData() const;
73 long getSize() 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
86 public:
87 void Data( const DdeData* );
88 void Done( bool bDataValid );
89 protected:
90 DdeConnection& rDde;
91 DdeData aDdeData;
92 DdeString* pName;
93 short nType;
94 sal_IntPtr nId;
95 sal_IntPtr nTime;
96 Link<const DdeData*,void> aData;
97 Link<bool,void> aDone;
98 bool bBusy;
100 DdeTransaction( DdeConnection&, SAL_UNUSED_PARAMETER const OUString&, SAL_UNUSED_PARAMETER long = 0 );
102 public:
103 virtual ~DdeTransaction();
105 bool IsBusy() { return bBusy; }
106 const OUString GetName() const;
108 void Execute();
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(); }
119 long GetError();
121 private:
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;
135 public:
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; }
141 void Notify();
145 class SVL_DLLPUBLIC DdeHotLink : public DdeLink
147 public:
148 DdeHotLink( DdeConnection&, const OUString&, long = 0 );
152 class SVL_DLLPUBLIC DdeRequest : public DdeTransaction
154 public:
155 DdeRequest( DdeConnection&, const OUString&, long = 0 );
159 class SVL_DLLPUBLIC DdePoke : public DdeTransaction
161 public:
162 DdePoke( DdeConnection&, const OUString&, SAL_UNUSED_PARAMETER const DdeData&, long = 0 );
166 class SVL_DLLPUBLIC DdeExecute : public DdeTransaction
168 public:
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;
178 DdeString* pService;
179 DdeString* pTopic;
180 DdeImp* pImp;
182 public:
183 DdeConnection( SAL_UNUSED_PARAMETER const OUString&, SAL_UNUSED_PARAMETER const OUString& );
184 ~DdeConnection();
186 long GetError();
188 static const std::vector<DdeConnection*>& GetConnections();
190 bool IsConnected();
192 const OUString GetServiceName();
193 const OUString GetTopicName();
195 private:
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;
205 DdeString* pName;
206 DdeTopic* pMyTopic;
207 DdeItemImp* pImpData;
209 protected:
210 sal_uInt8 nType;
212 public:
213 DdeItem( const sal_Unicode* );
214 DdeItem( SAL_UNUSED_PARAMETER const OUString& );
215 DdeItem( const DdeItem& );
216 virtual ~DdeItem();
218 const OUString GetName() const;
219 short GetLinks();
220 void NotifyClient();
224 class SVL_DLLPUBLIC DdeGetPutItem : public DdeItem
226 public:
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
240 public:
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();
250 private:
251 friend class DdeInternal;
252 friend class DdeService;
253 friend class DdeItem;
255 private:
256 DdeString* pName;
257 OUString aItem;
258 std::vector<DdeItem*> aItems;
260 public:
261 DdeTopic( SAL_UNUSED_PARAMETER const OUString& );
262 virtual ~DdeTopic();
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; }
275 private:
276 DdeTopic( const DdeTopic& ) = delete;
277 const DdeTopic& operator= ( const DdeTopic& ) = delete;
281 class SVL_DLLPUBLIC DdeService
283 friend class DdeInternal;
285 protected:
286 OUString Topics();
287 OUString Formats();
288 OUString SysItems();
289 OUString Status();
291 const DdeTopic* GetSysTopic() const { return pSysTopic; }
292 private:
293 std::vector<DdeTopic*> aTopics;
294 DdeFormats aFormats;
295 DdeTopic* pSysTopic;
296 DdeString* pName;
297 ConvList* pConv;
298 short nStatus;
300 SVL_DLLPRIVATE bool HasCbFormat( sal_uInt16 );
302 public:
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: */