workaround segfault in compiler on macos-clang-intel
[LibreOffice.git] / include / svl / svdde.hxx
blobc54f88059fa87889cf5c70860cb6004e959698e3
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/formats.hxx>
27 #include <rtl/ustring.hxx>
28 #include <tools/solar.h>
29 #include <tools/link.hxx>
30 #include <tools/long.hxx>
31 #include <memory>
32 #include <vector>
34 class DdeString;
35 class DdeConnection;
36 class DdeTopic;
37 class DdeService;
38 struct DdeDataImp;
39 struct DdeImp;
40 struct DdeItemImpData;
41 struct Conversation;
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 );
58 public:
59 DdeData();
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;
64 ~DdeData();
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
81 public:
82 void Data( const DdeData* );
83 void Done( bool bDataValid );
84 protected:
85 DdeConnection& rDde;
86 DdeData aDdeData;
87 DdeString* pName;
88 short nType;
89 sal_IntPtr nId;
90 sal_IntPtr nTime;
91 Link<const DdeData*,void> aData;
92 Link<bool,void> aDone;
93 bool bBusy;
95 DdeTransaction( DdeConnection&, SAL_UNUSED_PARAMETER const OUString&, SAL_UNUSED_PARAMETER tools::Long = 0 );
97 public:
98 virtual ~DdeTransaction();
100 bool IsBusy() const { return bBusy; }
101 OUString GetName() const;
103 void Execute();
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;
116 private:
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;
130 public:
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; }
136 void Notify();
140 class SVL_DLLPUBLIC DdeHotLink : public DdeLink
142 public:
143 DdeHotLink( DdeConnection&, const OUString& );
147 class SVL_DLLPUBLIC DdeRequest : public DdeTransaction
149 public:
150 DdeRequest( DdeConnection&, const OUString&, tools::Long = 0 );
154 class SVL_DLLPUBLIC DdePoke : public DdeTransaction
156 public:
157 DdePoke( DdeConnection&, const OUString&, SAL_UNUSED_PARAMETER const DdeData&, tools::Long = 0 );
161 class SVL_DLLPUBLIC DdeExecute : public DdeTransaction
163 public:
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;
173 DdeString* pService;
174 DdeString* pTopic;
175 std::unique_ptr<DdeImp> pImp;
177 public:
178 DdeConnection( SAL_UNUSED_PARAMETER const OUString&, SAL_UNUSED_PARAMETER const OUString& );
179 ~DdeConnection();
181 tools::Long GetError() const;
183 static const std::vector<DdeConnection*>& GetConnections();
185 bool IsConnected();
187 OUString GetServiceName() const;
188 OUString GetTopicName() const;
190 private:
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;
200 DdeString* pName;
201 DdeTopic* pMyTopic;
202 std::vector<DdeItemImpData>* pImpData;
204 protected:
205 sal_uInt8 nType;
207 public:
208 DdeItem( const sal_Unicode* );
209 DdeItem( SAL_UNUSED_PARAMETER const OUString& );
210 DdeItem( const DdeItem& );
211 virtual ~DdeItem();
213 OUString GetName() const;
214 short GetLinks();
215 void NotifyClient();
219 class SVL_DLLPUBLIC DdeGetPutItem : public DdeItem
221 public:
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
235 public:
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();
245 private:
246 friend class DdeInternal;
247 friend class DdeService;
248 friend class DdeItem;
250 private:
251 DdeString* pName;
252 OUString aItem;
253 std::vector<DdeItem*> aItems;
255 public:
256 DdeTopic( SAL_UNUSED_PARAMETER const OUString& );
257 virtual ~DdeTopic();
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; }
270 private:
271 DdeTopic( const DdeTopic& ) = delete;
272 const DdeTopic& operator= ( const DdeTopic& ) = delete;
276 class SVL_DLLPUBLIC DdeService
278 friend class DdeInternal;
280 protected:
281 OUString Topics();
282 OUString Formats();
283 OUString SysItems();
284 OUString Status();
286 const DdeTopic* GetSysTopic() const { return pSysTopic; }
287 private:
288 std::vector<DdeTopic*> aTopics;
289 std::vector< sal_uInt32 > aFormats;
290 DdeTopic* pSysTopic;
291 DdeString* pName;
292 std::vector<std::unique_ptr<Conversation>>
293 m_vConv;
294 short nStatus;
296 SVL_DLLPRIVATE bool HasCbFormat( sal_uInt32 );
298 public:
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: */