Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : :
20 : : #ifndef _SVDDE_HXX
21 : : #define _SVDDE_HXX
22 : :
23 : : #include "svl/svldllapi.h"
24 : : #include <sot/exchange.hxx>
25 : : #include <tools/string.hxx>
26 : : #include <tools/link.hxx>
27 : : #include <vector>
28 : :
29 : : class DdeString;
30 : : class DdeData;
31 : : class DdeConnection;
32 : : class DdeTransaction;
33 : : class DdeLink;
34 : : class DdeRequest;
35 : : class DdeWarmLink;
36 : : class DdeHotLink;
37 : : class DdePoke;
38 : : class DdeExecute;
39 : : class DdeItem;
40 : : class DdeTopic;
41 : : class DdeService;
42 : : struct DdeDataImp;
43 : : struct DdeImp;
44 : : class DdeItemImp;
45 : : struct Conversation;
46 : :
47 : : typedef ::std::vector< DdeService* > DdeServices;
48 : : typedef ::std::vector< long > DdeFormats;
49 : : typedef ::std::vector< Conversation* > ConvList;
50 : :
51 : : // -----------
52 : : // - DdeData -
53 : : // -----------
54 : :
55 : : class SVL_DLLPUBLIC DdeData
56 : : {
57 : : friend class DdeInternal;
58 : : friend class DdeService;
59 : : friend class DdeConnection;
60 : : friend class DdeTransaction;
61 : : DdeDataImp* pImp;
62 : :
63 : : SVL_DLLPRIVATE void Lock();
64 : :
65 : : void SetFormat( sal_uLong nFmt );
66 : :
67 : : public:
68 : : DdeData();
69 : : DdeData( SAL_UNUSED_PARAMETER const void*, SAL_UNUSED_PARAMETER long, SAL_UNUSED_PARAMETER sal_uLong = FORMAT_STRING );
70 : : DdeData( SAL_UNUSED_PARAMETER const String& );
71 : : DdeData( const DdeData& );
72 : : ~DdeData();
73 : :
74 : : operator const void*() const;
75 : : operator long() const;
76 : :
77 : : sal_uLong GetFormat() const;
78 : :
79 : : DdeData& operator = ( const DdeData& );
80 : :
81 : : static sal_uLong GetExternalFormat( sal_uLong nFmt );
82 : : static sal_uLong GetInternalFormat( sal_uLong nFmt );
83 : : };
84 : :
85 : : // ------------------
86 : : // - DdeTransaction -
87 : : // ------------------
88 : :
89 : : class SVL_DLLPUBLIC DdeTransaction
90 : : {
91 : : public:
92 : : virtual void Data( const DdeData* );
93 : : virtual void Done( sal_Bool bDataValid );
94 : : protected:
95 : : DdeConnection& rDde;
96 : : DdeData aDdeData;
97 : : DdeString* pName;
98 : : short nType;
99 : : long nId;
100 : : long nTime;
101 : : Link aData;
102 : : Link aDone;
103 : : sal_Bool bBusy;
104 : :
105 : : DdeTransaction( DdeConnection&, SAL_UNUSED_PARAMETER const String&, SAL_UNUSED_PARAMETER long = 0 );
106 : :
107 : : public:
108 : : virtual ~DdeTransaction();
109 : :
110 : 0 : sal_Bool IsBusy() { return bBusy; }
111 : : const rtl::OUString GetName() const;
112 : :
113 : : void Execute();
114 : :
115 : 0 : void SetDataHdl( const Link& rLink ) { aData = rLink; }
116 : : const Link& GetDataHdl() const { return aData; }
117 : :
118 : 0 : void SetDoneHdl( const Link& rLink ) { aDone = rLink; }
119 : : const Link& GetDoneHdl() const { return aDone; }
120 : :
121 : 0 : void SetFormat( sal_uLong nFmt ) { aDdeData.SetFormat( nFmt ); }
122 : 0 : sal_uLong GetFormat() const { return aDdeData.GetFormat(); }
123 : :
124 : : long GetError();
125 : :
126 : : private:
127 : : friend class DdeInternal;
128 : : friend class DdeConnection;
129 : :
130 : : DdeTransaction( const DdeTransaction& );
131 : : const DdeTransaction& operator= ( const DdeTransaction& );
132 : :
133 : : };
134 : :
135 : : // -----------
136 : : // - DdeLink -
137 : : // -----------
138 : :
139 : : class SVL_DLLPUBLIC DdeLink : public DdeTransaction
140 : : {
141 : : Link aNotify;
142 : :
143 : : public:
144 : : DdeLink( DdeConnection&, const String&, long = 0 );
145 : : virtual ~DdeLink();
146 : :
147 : : void SetNotifyHdl( const Link& rLink ) { aNotify = rLink; }
148 : : const Link& GetNotifyHdl() const { return aNotify; }
149 : : virtual void Notify();
150 : : };
151 : :
152 : : // ---------------
153 : : // - DdeWarmLink -
154 : : // ---------------
155 : :
156 : : class SVL_DLLPUBLIC DdeWarmLink : public DdeLink
157 : : {
158 : : public:
159 : : DdeWarmLink( DdeConnection&, const String&, long = 0 );
160 : : };
161 : :
162 : : // --------------
163 : : // - DdeHotLink -
164 : : // --------------
165 : :
166 [ # # ]: 0 : class SVL_DLLPUBLIC DdeHotLink : public DdeLink
167 : : {
168 : : public:
169 : : DdeHotLink( DdeConnection&, const String&, long = 0 );
170 : : };
171 : :
172 : : // --------------
173 : : // - DdeRequest -
174 : : // --------------
175 : :
176 [ # # ]: 0 : class SVL_DLLPUBLIC DdeRequest : public DdeTransaction
177 : : {
178 : : public:
179 : : DdeRequest( DdeConnection&, const String&, long = 0 );
180 : : };
181 : :
182 : : // -----------
183 : : // - DdePoke -
184 : : // -----------
185 : :
186 [ # # ]: 0 : class SVL_DLLPUBLIC DdePoke : public DdeTransaction
187 : : {
188 : : public:
189 : : DdePoke( DdeConnection&, const String&, const char*, long,
190 : : sal_uLong = FORMAT_STRING, long = 0 );
191 : : DdePoke( DdeConnection&, const String&, SAL_UNUSED_PARAMETER const DdeData&, long = 0 );
192 : : DdePoke( DdeConnection&, const String&, const String&, long = 0 );
193 : : };
194 : :
195 : : // --------------
196 : : // - DdeExecute -
197 : : // --------------
198 : :
199 [ # # ]: 0 : class SVL_DLLPUBLIC DdeExecute : public DdeTransaction
200 : : {
201 : : public:
202 : : DdeExecute( DdeConnection&, const String&, long = 0 );
203 : : };
204 : :
205 : : // -----------------
206 : : // - DdeConnection -
207 : : // -----------------
208 : :
209 : : class SVL_DLLPUBLIC DdeConnection
210 : : {
211 : : friend class DdeInternal;
212 : : friend class DdeTransaction;
213 : : std::vector<DdeTransaction*> aTransactions;
214 : : DdeString* pService;
215 : : DdeString* pTopic;
216 : : DdeImp* pImp;
217 : :
218 : : public:
219 : : DdeConnection( SAL_UNUSED_PARAMETER const String&, SAL_UNUSED_PARAMETER const String& );
220 : : ~DdeConnection();
221 : :
222 : : long GetError();
223 : : long GetConvId();
224 : :
225 : : static const std::vector<DdeConnection*>& GetConnections();
226 : :
227 : : sal_Bool IsConnected();
228 : :
229 : : const String& GetServiceName();
230 : : const String& GetTopicName();
231 : :
232 : : private:
233 : : DdeConnection( const DdeConnection& );
234 : : const DdeConnection& operator= ( const DdeConnection& );
235 : : };
236 : :
237 : : // -----------
238 : : // - DdeItem -
239 : : // -----------
240 : :
241 : : class SVL_DLLPUBLIC DdeItem
242 : : {
243 : : friend class DdeInternal;
244 : : friend class DdeTopic;
245 : : DdeString* pName;
246 : : DdeTopic* pMyTopic;
247 : : DdeItemImp* pImpData;
248 : :
249 : : void IncMonitor( sal_uLong );
250 : : void DecMonitor( sal_uLong );
251 : :
252 : : protected:
253 : : sal_uInt8 nType;
254 : :
255 : : public:
256 : : DdeItem( const sal_Unicode* );
257 : : DdeItem( SAL_UNUSED_PARAMETER const String& );
258 : : DdeItem( const DdeItem& );
259 : : virtual ~DdeItem();
260 : :
261 : : const rtl::OUString GetName() const;
262 : : short GetLinks();
263 : : void NotifyClient();
264 : : };
265 : :
266 : : // -----------
267 : : // - DdeItem -
268 : : // -----------
269 : :
270 [ # # ]: 0 : class SVL_DLLPUBLIC DdeGetPutItem : public DdeItem
271 : : {
272 : : public:
273 : : DdeGetPutItem( const sal_Unicode* p );
274 : : DdeGetPutItem( const String& rStr );
275 : : DdeGetPutItem( const DdeItem& rItem );
276 : :
277 : : virtual DdeData* Get( sal_uLong );
278 : : virtual sal_Bool Put( const DdeData* );
279 : : virtual void AdviseLoop( sal_Bool ); // AdviseLoop starten/stoppen
280 : : };
281 : :
282 : : // ------------
283 : : // - DdeTopic -
284 : : // ------------
285 : :
286 : : class SVL_DLLPUBLIC DdeTopic
287 : : {
288 : : SVL_DLLPRIVATE void _Disconnect( long );
289 : :
290 : : public:
291 : : virtual void Connect( long );
292 : : virtual void Disconnect( long );
293 : : virtual DdeData* Get( sal_uLong );
294 : : virtual sal_Bool Put( const DdeData* );
295 : : virtual sal_Bool Execute( const String* );
296 : : // evt. ein neues anlegen; return 0 -> es konnte nicht angelegt werden
297 : : virtual sal_Bool MakeItem( const rtl::OUString& rItem );
298 : :
299 : : // es wird ein Warm-/Hot-Link eingerichtet. Return-Wert
300 : : // besagt ob es geklappt hat
301 : : virtual sal_Bool StartAdviseLoop();
302 : : virtual sal_Bool StopAdviseLoop();
303 : :
304 : : private:
305 : : friend class DdeInternal;
306 : : friend class DdeService;
307 : : friend class DdeItem;
308 : :
309 : : private:
310 : : DdeString* pName;
311 : : rtl::OUString aItem;
312 : : std::vector<DdeItem*> aItems;
313 : : Link aConnectLink;
314 : : Link aDisconnectLink;
315 : : Link aGetLink;
316 : : Link aPutLink;
317 : : Link aExecLink;
318 : :
319 : : public:
320 : : DdeTopic( SAL_UNUSED_PARAMETER const rtl::OUString& );
321 : : virtual ~DdeTopic();
322 : :
323 : : const rtl::OUString GetName() const;
324 : : long GetConvId();
325 : :
326 : : void SetConnectHdl( const Link& rLink ) { aConnectLink = rLink; }
327 : : const Link& GetConnectHdl() const { return aConnectLink; }
328 : : void SetDisconnectHdl( const Link& rLink ) { aDisconnectLink = rLink; }
329 : : const Link& GetDisconnectHdl() const { return aDisconnectLink; }
330 : : void SetGetHdl( const Link& rLink ) { aGetLink = rLink; }
331 : : const Link& GetGetHdl() const { return aGetLink; }
332 : : void SetPutHdl( const Link& rLink ) { aPutLink = rLink; }
333 : : const Link& GetPutHdl() const { return aPutLink; }
334 : : void SetExecuteHdl( const Link& rLink ) { aExecLink = rLink; }
335 : : const Link& GetExecuteHdl() const { return aExecLink; }
336 : :
337 : : void NotifyClient( const String& );
338 : : sal_Bool IsSystemTopic();
339 : :
340 : : void InsertItem( DdeItem* ); // fuer eigene Ableitungen!
341 : : DdeItem* AddItem( const DdeItem& ); // werden kopiert !
342 : : void RemoveItem( const DdeItem& );
343 : 0 : const rtl::OUString& GetCurItem() { return aItem; }
344 : : const std::vector<DdeItem*>& GetItems() const { return aItems; }
345 : :
346 : : private:
347 : : DdeTopic( const DdeTopic& );
348 : : const DdeTopic& operator= ( const DdeTopic& );
349 : : };
350 : :
351 : : // --------------
352 : : // - DdeService -
353 : : // --------------
354 : :
355 : : class SVL_DLLPUBLIC DdeService
356 : : {
357 : : friend class DdeInternal;
358 : :
359 : : public:
360 : : virtual sal_Bool IsBusy();
361 : : virtual String GetHelp();
362 : : // evt. ein neues anlegen; return 0 -> es konnte nicht angelegt werden
363 : : virtual sal_Bool MakeTopic( const rtl::OUString& rItem );
364 : :
365 : : protected:
366 : : virtual String Topics();
367 : : virtual String Formats();
368 : : virtual String SysItems();
369 : : virtual String Status();
370 : : virtual String SysTopicGet( const String& );
371 : : virtual sal_Bool SysTopicExecute( const String* );
372 : :
373 : : const DdeTopic* GetSysTopic() const { return pSysTopic; }
374 : : private:
375 : : std::vector<DdeTopic*> aTopics;
376 : : DdeFormats aFormats;
377 : : DdeTopic* pSysTopic;
378 : : DdeString* pName;
379 : : ConvList* pConv;
380 : : short nStatus;
381 : :
382 : : SVL_DLLPRIVATE sal_Bool HasCbFormat( sal_uInt16 );
383 : :
384 : : public:
385 : : DdeService( SAL_UNUSED_PARAMETER const String& );
386 : : virtual ~DdeService();
387 : :
388 : : const rtl::OUString GetName() const;
389 : : short GetError() { return nStatus; }
390 : :
391 : : static DdeServices& GetServices();
392 : 0 : std::vector<DdeTopic*>& GetTopics() { return aTopics; }
393 : :
394 : : void AddTopic( const DdeTopic& );
395 : : void RemoveTopic( const DdeTopic& );
396 : :
397 : : void AddFormat( sal_uLong );
398 : : void RemoveFormat( sal_uLong );
399 : : sal_Bool HasFormat( sal_uLong );
400 : :
401 : : private:
402 : : // DdeService( const DdeService& );
403 : : //int operator= ( const DdeService& );
404 : : };
405 : :
406 : : // ------------------
407 : : // - DdeTransaction -
408 : : // ------------------
409 : :
410 : 0 : inline long DdeTransaction::GetError()
411 : : {
412 : 0 : return rDde.GetError();
413 : : }
414 : : #endif // _SVDDE_HXX
415 : :
416 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|