lok: calc - send other views our selection in their co-ordinates.
[LibreOffice.git] / include / svl / svdde.hxx
blob546b20710e88913fa633483f1f2997ecd612af74
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 <memory>
31 #include <vector>
33 class DdeString;
34 class DdeConnection;
35 class DdeTopic;
36 class DdeService;
37 struct DdeDataImp;
38 struct DdeImp;
39 struct DdeItemImpData;
40 struct Conversation;
42 typedef ::std::vector< DdeService* > DdeServices;
43 typedef ::std::vector< long > DdeFormats;
44 typedef std::vector<std::unique_ptr<Conversation>> ConvList;
47 class SVL_DLLPUBLIC DdeData
49 friend class DdeInternal;
50 friend class DdeService;
51 friend class DdeConnection;
52 friend class DdeTransaction;
53 std::unique_ptr<DdeDataImp> xImp;
55 SVL_DLLPRIVATE void Lock();
57 void SetFormat( SotClipboardFormatId nFmt );
59 public:
60 DdeData();
61 DdeData(SAL_UNUSED_PARAMETER const void*, SAL_UNUSED_PARAMETER long, SAL_UNUSED_PARAMETER SotClipboardFormatId = SotClipboardFormatId::STRING);
62 DdeData(SAL_UNUSED_PARAMETER const OUString&);
63 DdeData(const DdeData&);
64 DdeData(DdeData&&) noexcept;
65 ~DdeData();
67 void const * getData() const;
68 long getSize() const;
70 SotClipboardFormatId GetFormat() const;
72 DdeData& operator=(const DdeData&);
73 DdeData& operator=(DdeData&&) noexcept;
75 static sal_uLong GetExternalFormat(SotClipboardFormatId nFmt);
76 static SotClipboardFormatId GetInternalFormat(sal_uLong nFmt);
80 class SVL_DLLPUBLIC DdeTransaction
82 public:
83 void Data( const DdeData* );
84 void Done( bool bDataValid );
85 protected:
86 DdeConnection& rDde;
87 DdeData aDdeData;
88 DdeString* pName;
89 short nType;
90 sal_IntPtr nId;
91 sal_IntPtr nTime;
92 Link<const DdeData*,void> aData;
93 Link<bool,void> aDone;
94 bool bBusy;
96 DdeTransaction( DdeConnection&, SAL_UNUSED_PARAMETER const OUString&, SAL_UNUSED_PARAMETER long = 0 );
98 public:
99 virtual ~DdeTransaction();
101 bool IsBusy() const { return bBusy; }
102 OUString GetName() const;
104 void Execute();
106 void SetDataHdl( const Link<const DdeData*,void>& rLink ) { aData = rLink; }
107 const Link<const DdeData*,void>& GetDataHdl() const { return aData; }
109 void SetDoneHdl( const Link<bool,void>& rLink ) { aDone = rLink; }
110 const Link<bool,void>& GetDoneHdl() const { return aDone; }
112 void SetFormat( SotClipboardFormatId nFmt ) { aDdeData.SetFormat( nFmt ); }
113 SotClipboardFormatId GetFormat() const { return aDdeData.GetFormat(); }
115 long GetError() const;
117 private:
118 friend class DdeInternal;
119 friend class DdeConnection;
121 DdeTransaction( const DdeTransaction& ) = delete;
122 const DdeTransaction& operator= ( const DdeTransaction& ) = delete;
127 class SVL_DLLPUBLIC DdeLink : public DdeTransaction
129 Link<void*,void> aNotify;
131 public:
132 DdeLink( DdeConnection&, const OUString&, long = 0 );
133 virtual ~DdeLink() override;
135 void SetNotifyHdl( const Link<void*,void>& rLink ) { aNotify = rLink; }
136 const Link<void*,void>& GetNotifyHdl() const { return aNotify; }
137 void Notify();
141 class SVL_DLLPUBLIC DdeHotLink : public DdeLink
143 public:
144 DdeHotLink( DdeConnection&, const OUString& );
148 class SVL_DLLPUBLIC DdeRequest : public DdeTransaction
150 public:
151 DdeRequest( DdeConnection&, const OUString&, long = 0 );
155 class SVL_DLLPUBLIC DdePoke : public DdeTransaction
157 public:
158 DdePoke( DdeConnection&, const OUString&, SAL_UNUSED_PARAMETER const DdeData&, long = 0 );
162 class SVL_DLLPUBLIC DdeExecute : public DdeTransaction
164 public:
165 DdeExecute( DdeConnection&, const OUString&, long = 0 );
169 class SVL_DLLPUBLIC DdeConnection
171 friend class DdeInternal;
172 friend class DdeTransaction;
173 std::vector<DdeTransaction*> aTransactions;
174 DdeString* pService;
175 DdeString* pTopic;
176 std::unique_ptr<DdeImp> pImp;
178 public:
179 DdeConnection( SAL_UNUSED_PARAMETER const OUString&, SAL_UNUSED_PARAMETER const OUString& );
180 ~DdeConnection();
182 long GetError() const;
184 static const std::vector<DdeConnection*>& GetConnections();
186 bool IsConnected();
188 OUString GetServiceName() const;
189 OUString GetTopicName() const;
191 private:
192 DdeConnection( const DdeConnection& ) = delete;
193 const DdeConnection& operator= ( const DdeConnection& ) = delete;
197 class SVL_DLLPUBLIC DdeItem
199 friend class DdeInternal;
200 friend class DdeTopic;
201 DdeString* pName;
202 DdeTopic* pMyTopic;
203 std::vector<DdeItemImpData>* pImpData;
205 protected:
206 sal_uInt8 nType;
208 public:
209 DdeItem( const sal_Unicode* );
210 DdeItem( SAL_UNUSED_PARAMETER const OUString& );
211 DdeItem( const DdeItem& );
212 virtual ~DdeItem();
214 OUString GetName() const;
215 short GetLinks();
216 void NotifyClient();
220 class SVL_DLLPUBLIC DdeGetPutItem : public DdeItem
222 public:
223 DdeGetPutItem( const sal_Unicode* p );
224 DdeGetPutItem( const OUString& rStr );
225 DdeGetPutItem( const DdeItem& rItem );
227 virtual DdeData* Get( SotClipboardFormatId );
228 virtual bool Put( const DdeData* );
229 virtual void AdviseLoop( bool ); // Start / Stop AdviseLoop
233 class SVL_DLLPUBLIC DdeTopic
236 public:
237 virtual DdeData* Get(SotClipboardFormatId);
238 virtual bool Put( const DdeData* );
239 virtual bool Execute( const OUString* );
240 // Eventually create a new item. return 0 -> Item creation failed
241 virtual bool MakeItem( const OUString& rItem );
243 // A Warm-/Hot-Link is created. Return true if successful
244 virtual bool StartAdviseLoop();
246 private:
247 friend class DdeInternal;
248 friend class DdeService;
249 friend class DdeItem;
251 private:
252 DdeString* pName;
253 OUString aItem;
254 std::vector<DdeItem*> aItems;
256 public:
257 DdeTopic( SAL_UNUSED_PARAMETER const OUString& );
258 virtual ~DdeTopic();
260 OUString GetName() const;
262 void NotifyClient( const OUString& );
263 bool IsSystemTopic();
265 void InsertItem( DdeItem* ); // For own superclasses
266 DdeItem* AddItem( const DdeItem& ); // Will be cloned
267 void RemoveItem( const DdeItem& );
268 const OUString& GetCurItem() const { return aItem; }
269 const std::vector<DdeItem*>& GetItems() const { return aItems; }
271 private:
272 DdeTopic( const DdeTopic& ) = delete;
273 const DdeTopic& operator= ( const DdeTopic& ) = delete;
277 class SVL_DLLPUBLIC DdeService
279 friend class DdeInternal;
281 protected:
282 OUString Topics();
283 OUString Formats();
284 OUString SysItems();
285 OUString Status();
287 const DdeTopic* GetSysTopic() const { return pSysTopic; }
288 private:
289 std::vector<DdeTopic*> aTopics;
290 DdeFormats aFormats;
291 DdeTopic* pSysTopic;
292 DdeString* pName;
293 ConvList m_vConv;
294 short nStatus;
296 SVL_DLLPRIVATE bool HasCbFormat( sal_uInt16 );
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 long DdeTransaction::GetError() const
322 return rDde.GetError();
324 #endif // INCLUDED_SVL_SVDDE_HXX
326 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */