summaryrefslogtreecommitdiff
path: root/sfx2/source/appl/appdde.cxx
blob: 3cc38c9411609e09f5fb9a8293bb19ac311cec52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sfx2.hxx"
#include <vcl/wrkwin.hxx>
#include <svtools/rectitem.hxx>
#include <svtools/eitem.hxx>
#include <svtools/intitem.hxx>
#include <basic/sbstar.hxx>
#include <svtools/stritem.hxx>
#include <svtools/svdde.hxx>
#include <sfx2/lnkbase.hxx>
#include <sfx2/linkmgr.hxx>

#include <tools/urlobj.hxx>
#include <svtools/pathoptions.hxx>
#ifndef GCC
#endif

#include <sfx2/app.hxx>
#include "appdata.hxx"
#include <sfx2/objsh.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/topfrm.hxx>
#include <sfx2/dispatch.hxx>
#include "sfxtypes.hxx"
#include <sfx2/sfxsids.hrc>
#include "helper.hxx"
#include <sfx2/docfile.hxx>

//========================================================================

String SfxDdeServiceName_Impl( const String& sIn )
{
    ByteString sTemp = U2S( sIn );
    ByteString sReturn;

    for ( sal_uInt16 n = sTemp.Len(); n; --n )
        if ( sTemp.Copy( n-1, 1 ).IsAlphaNumericAscii() )
            sReturn += sTemp.GetChar(n-1);

    return S2U( sReturn );
}


class ImplDdeService : public DdeService
{
public:
    ImplDdeService( const String& rNm )
        : DdeService( rNm )
    {}
    virtual BOOL MakeTopic( const String& );

    virtual String	Topics();
//	virtual String	Formats();
//	virtual String	SysItems();
//	virtual String	Status();

    virtual BOOL SysTopicExecute( const String* pStr );
};

class SfxDdeTriggerTopic_Impl : public DdeTopic
{
public:
    SfxDdeTriggerTopic_Impl()
    : DdeTopic( DEFINE_CONST_UNICODE("TRIGGER") )
    {}

    virtual BOOL Execute( const String* );
};

class SfxDdeDocTopic_Impl : public DdeTopic
{
public:
    SfxObjectShell* pSh;
    DdeData aData;
    ::com::sun::star::uno::Sequence< sal_Int8 > aSeq;

    SfxDdeDocTopic_Impl( SfxObjectShell* pShell )
        : DdeTopic( pShell->GetTitle(SFX_TITLE_FULLNAME) ), pSh( pShell )
    {}

    virtual DdeData* Get( ULONG );
    virtual BOOL Put( const DdeData* );
    virtual BOOL Execute( const String* );
    virtual BOOL StartAdviseLoop();
    virtual BOOL MakeItem( const String& rItem );

// wird benoetigt?
//	virtual void Connect( long n );
//	virtual void Disconnect( long n );
//	virtual void StopAdviseLoop();

};


SV_DECL_PTRARR( SfxDdeDocTopics_Impl, SfxDdeDocTopic_Impl *, 4, 4 )
SV_IMPL_PTRARR( SfxDdeDocTopics_Impl, SfxDdeDocTopic_Impl *)

//========================================================================

BOOL SfxAppEvent_Impl( ApplicationEvent &rAppEvent,
                       const String &rCmd, const String &rEvent )

/*	[Beschreibung]

    Pr"uft, ob 'rCmd' das Event 'rEvent' ist (ohne '(') und baut
    aus diesem dann ein <ApplicationEvent> zusammen, das per
    <Application::AppEvent()> ausgef"uhrt werden kann. Ist 'rCmd' das
    angegegeben Event 'rEvent', dann wird TRUE zur"uckgegeben, sonst FALSE.


    [Beispiel]

    rCmd = "Open(\"d:\doc\doc.sdw\")"
    rEvent = "Open"
*/

{
    String aEvent( rEvent );
    aEvent += '(';
    if ( rCmd.CompareIgnoreCaseToAscii( aEvent, aEvent.Len() ) == COMPARE_EQUAL )
    {
        String aData( rCmd );
        aData.Erase( 0, aEvent.Len() );
        if ( aData.Len() > 2 )
        {
            // in das ApplicationEvent-Format wandeln
            aData.Erase( aData.Len()-1, 1 );
            for ( USHORT n = 0; n < aData.Len(); ++n )
            {
                if ( aData.GetChar(n) == 0x0022 ) // " = 22h
                    for ( ; aData.GetChar(++n) != 0x0022 ; )
                        /* empty loop */ ;
                else if ( aData.GetChar(n) == 0x0020 ) // SPACE = 20h
                    aData.SetChar(n, '\n');
            }
            aData.EraseAllChars( 0x0022 );
            ApplicationAddress aAddr;
            rAppEvent = ApplicationEvent( String(), aAddr, U2S(rEvent), aData );
            return TRUE;
        }
    }

    return FALSE;
}

//-------------------------------------------------------------------------

long SfxApplication::DdeExecute
(
    const String&	rCmd		// in unserer BASIC-Syntax formuliert
)

/*	[Beschreibung]

    Diese Methode kann vom Applikationsentwickler "uberladen werden,
    um an seine SfxApplication-Subklasse gerichtete DDE-Kommandos
    zu empfangen.

    Die Basisimplementierung versteht die API-Funktionalit"at der
    betreffenden SfxApplication-Subklasse in BASIC-Syntax. R"uckgabewerte
    k"onnen dabei leider nicht "ubertragen werden.
*/

{
    // Print oder Open-Event?
    ApplicationEvent aAppEvent;
    if ( SfxAppEvent_Impl( aAppEvent, rCmd, DEFINE_CONST_UNICODE("Print") ) ||
         SfxAppEvent_Impl( aAppEvent, rCmd, DEFINE_CONST_UNICODE("Open") ) )
        GetpApp()->AppEvent( aAppEvent );
    else
    {
        // alle anderen per BASIC
        EnterBasicCall();
        StarBASIC* pBasic = GetBasic();
        DBG_ASSERT( pBasic, "Wo ist mein Basic???" );
        SbxVariable* pRet = pBasic->Execute( rCmd );
        LeaveBasicCall();
        if( !pRet )
        {
            SbxBase::ResetError();
            return 0;
        }
    }
    return 1;
}

//--------------------------------------------------------------------

long SfxApplication::DdeGetData
(
    const String&,				// das anzusprechende Item
    const String&,				// in: Format
    ::com::sun::star::uno::Any& // out: angeforderte Daten
)

/*	[Beschreibung]

    Diese Methode kann vom Applikationsentwickler "uberladen werden,
    um an seine SfxApplication-Subklasse gerichtete DDE-Daten-Anforderungen
    zu empfangen.

    Die Basisimplementierung liefert keine Daten und gibt 0 zur"uck.
*/

{
    return 0;
}

//--------------------------------------------------------------------

long SfxApplication::DdeSetData
(
    const String&,                    // das anzusprechende Item
    const String&,				      // in: Format
    const ::com::sun::star::uno::Any& // out: angeforderte Daten
)

/*	[Beschreibung]

    Diese Methode kann vom Applikationsentwickler "uberladen werden,
    um an seine SfxApplication-Subklasse gerichtete DDE-Daten
    zu empfangen.

    Die Basisimplementierung nimmt keine Daten entgegen und liefert 0 zur"uck.
*/

{
    return 0;
}

//--------------------------------------------------------------------

::sfx2::SvLinkSource* SfxApplication::DdeCreateLinkSource
(
    const String&	   // das zu erzeugende Item
)

/*	[Beschreibung]

    Diese Methode kann vom Applikationsentwickler "uberladen werden,
    um an seiner SfxApplication-Subklasse einen DDE-Hotlink einzurichten

    Die Basisimplementierung erzeugt keinen und liefert 0 zur"uck.
*/

{
    return 0;
}

//========================================================================

long SfxObjectShell::DdeExecute
(
    const String&	rCmd		// in unserer BASIC-Syntax formuliert
)

/*	[Beschreibung]

    Diese Methode kann vom Applikationsentwickler "uberladen werden,
    um an seine SfxObjectShell-Subklasse gerichtete DDE-Kommandos
    zu empfangen.

    Die Basisimplementierung f"uhrt nichts aus und liefert 0 zur"uck.
*/

{
    StarBASIC* pBasic = GetBasic();
    DBG_ASSERT( pBasic, "Wo ist mein Basic???" ) ;
    SbxVariable* pRet = pBasic->Execute( rCmd );
    if( !pRet )
    {
        SbxBase::ResetError();
        return 0;
    }

    return 1;
}

//--------------------------------------------------------------------

long SfxObjectShell::DdeGetData
(
    const String&,				// das anzusprechende Item
    const String&,				// in: Format
    ::com::sun::star::uno::Any& // out: angeforderte Daten
)

/*	[Beschreibung]

    Diese Methode kann vom Applikationsentwickler "uberladen werden,
    um an seine SfxObjectShell-Subklasse gerichtete DDE-Daten-Anforderungen
    zu empfangen.

    Die Basisimplementierung liefert keine Daten und gibt 0 zur"uck.
*/

{
    return 0;
}

//--------------------------------------------------------------------

long SfxObjectShell::DdeSetData
(
    const String&,					  // das anzusprechende Item
    const String&,					  // in: Format
    const ::com::sun::star::uno::Any& // out: angeforderte Daten
)

/*	[Beschreibung]

    Diese Methode kann vom Applikationsentwickler "uberladen werden,
    um an seine SfxObjectShell-Subklasse gerichtete DDE-Daten
    zu empfangen.

    Die Basisimplementierung nimmt keine Daten entgegen und liefert 0 zur"uck.
*/

{
    return 0;
}

//--------------------------------------------------------------------
::sfx2::SvLinkSource* SfxObjectShell::DdeCreateLinkSource
(
    const String&	   // das zu erzeugende Item
)

/*	[Beschreibung]

    Diese Methode kann vom Applikationsentwickler "uberladen werden,
    um an seiner SfxObjectShell-Subklasse einen DDE-Hotlink einzurichten

    Die Basisimplementierung erzeugt keinen und liefert 0 zur"uck.
*/

{
    return 0;
}

//========================================================================

long SfxViewFrame::DdeExecute
(
    const String&	rCmd		// in unserer BASIC-Syntax formuliert
)

/*	[Beschreibung]

    Diese Methode kann vom Applikationsentwickler "uberladen werden,
    um an seine SfxViewFrame-Subklasse gerichtete DDE-Kommandos
    zu empfangen.

    Die Basisimplementierung versteht die API-Funktionalit"at des
    betreffenden SfxViewFrame, der darin dargestellten SfxViewShell und
    der betreffenden SfxObjectShell-Subklasse in BASIC-Syntax.
    R"uckgabewerte k"onnen dabei leider nicht "ubertragen werden.
*/

{
    if ( GetObjectShell() )
        return GetObjectShell()->DdeExecute( rCmd );

    return 0;
}

//--------------------------------------------------------------------

long SfxViewFrame::DdeGetData
(
    const String&,				// das anzusprechende Item
    const String&,				// in: Format
    ::com::sun::star::uno::Any& // out: angeforderte Daten
)

/*	[Beschreibung]

    Diese Methode kann vom Applikationsentwickler "uberladen werden,
    um an seine SfxViewFrame-Subklasse gerichtete DDE-Daten-Anforderungen
    zu empfangen.

    Die Basisimplementierung liefert keine Daten und gibt 0 zur"uck.
*/

{
    return 0;
}

//--------------------------------------------------------------------

long SfxViewFrame::DdeSetData
(
    const String& ,						// das anzusprechende Item
    const String& ,					    // in: Format
    const ::com::sun::star::uno::Any&   // out: angeforderte Daten
)

/*	[Beschreibung]

    Diese Methode kann vom Applikationsentwickler "uberladen werden,
    um an seine SfxViewFrame-Subklasse gerichtete DDE-Daten
    zu empfangen.

    Die Basisimplementierung nimmt keine Daten entgegen und liefert 0 zur"uck.
*/

{
    return 0;
}

//--------------------------------------------------------------------

::sfx2::SvLinkSource* SfxViewFrame::DdeCreateLinkSource
(
    const String& // das zu erzeugende Item
)

/*	[Beschreibung]

    Diese Methode kann vom Applikationsentwickler "uberladen werden,
    um an seiner SfxViewFrame-Subklasse einen DDE-Hotlink einzurichten

    Die Basisimplementierung erzeugt keinen und liefert 0 zur"uck.
*/

{
    return 0;
}

//========================================================================

BOOL SfxApplication::InitializeDde()
{
    DBG_ASSERT( !pAppData_Impl->pDdeService,
                "Dde kann nicht mehrfach initialisiert werden" );

    pAppData_Impl->pDdeService = new ImplDdeService( Application::GetAppName() );
    int nError = pAppData_Impl->pDdeService->GetError();
    if( !nError )
    {
        pAppData_Impl->pDocTopics = new SfxDdeDocTopics_Impl;

        // wir wollen auf jedenfall RTF unterstuetzen!
        pAppData_Impl->pDdeService->AddFormat( FORMAT_RTF );

        // Config-Pfad als Topic wegen Mehrfachstart
        INetURLObject aOfficeLockFile( SvtPathOptions().GetUserConfigPath() );
        aOfficeLockFile.insertName( DEFINE_CONST_UNICODE( "soffice.lck" ) );
        String aService( SfxDdeServiceName_Impl(
                    aOfficeLockFile.GetMainURL(INetURLObject::DECODE_TO_IURI) ) );
        aService.ToUpperAscii();
        pAppData_Impl->pDdeService2 = new ImplDdeService( aService );
        pAppData_Impl->pTriggerTopic = new SfxDdeTriggerTopic_Impl;
        pAppData_Impl->pDdeService2->AddTopic( *pAppData_Impl->pTriggerTopic );
    }
    return !nError;
}

void SfxAppData_Impl::DeInitDDE()
{
    DELETEZ( pTriggerTopic );
    DELETEZ( pDdeService2 );
    DELETEZ( pDocTopics );
    DELETEZ( pDdeService );
}

//--------------------------------------------------------------------

void SfxApplication::AddDdeTopic( SfxObjectShell* pSh )
{
    DBG_ASSERT( pAppData_Impl->pDocTopics, "es gibt gar keinen Dde-Service" );
    //OV: Im Serverbetrieb ist DDE abgeklemmt!
    if( !pAppData_Impl->pDocTopics )
        return;

    // doppeltes Eintragen verhindern
    String sShellNm;
    BOOL bFnd = FALSE;
    for( USHORT n = pAppData_Impl->pDocTopics->Count(); n; )
        if( (*pAppData_Impl->pDocTopics)[ --n ]->pSh == pSh )
        {
            // JP 18.03.96 - Bug 26470
            //	falls das Document unbenannt wurde, ist trotzdem ein
            //	neues Topics anzulegen!
            if( !bFnd )
            {
                bFnd = TRUE;
                (sShellNm = pSh->GetTitle(SFX_TITLE_FULLNAME)).ToLowerAscii();
            }
            String sNm( (*pAppData_Impl->pDocTopics)[ n ]->GetName() );
            if( sShellNm == sNm.ToLowerAscii() )
                return ;
        }

    const SfxDdeDocTopic_Impl* pTopic = new SfxDdeDocTopic_Impl( pSh );
    pAppData_Impl->pDocTopics->Insert( pTopic,
                                       pAppData_Impl->pDocTopics->Count() );
    pAppData_Impl->pDdeService->AddTopic( *pTopic );
}

void SfxApplication::RemoveDdeTopic( SfxObjectShell* pSh )
{
    DBG_ASSERT( pAppData_Impl->pDocTopics, "es gibt gar keinen Dde-Service" );
    //OV: Im Serverbetrieb ist DDE abgeklemmt!
    if( !pAppData_Impl->pDocTopics )
        return;

    SfxDdeDocTopic_Impl* pTopic;
    for( USHORT n = pAppData_Impl->pDocTopics->Count(); n; )
        if( ( pTopic = (*pAppData_Impl->pDocTopics)[ --n ])->pSh == pSh )
        {
            pAppData_Impl->pDdeService->RemoveTopic( *pTopic );
            pAppData_Impl->pDocTopics->DeleteAndDestroy( n );
        }
}

const DdeService* SfxApplication::GetDdeService() const
{
    return pAppData_Impl->pDdeService;
}

DdeService* SfxApplication::GetDdeService()
{
    return pAppData_Impl->pDdeService;
}

//--------------------------------------------------------------------

BOOL ImplDdeService::MakeTopic( const String& rNm )
{
    // Workaround gegen Event nach unserem Main() unter OS/2
    // passierte wenn man beim Beenden aus dem OffMgr die App neu startet
    if ( !Application::IsInExecute() )
        return FALSE;

    // das Topic rNm wird gesucht, haben wir es ?
    // erstmal nur ueber die ObjectShells laufen und die mit dem
    // Namen heraussuchen:
    BOOL bRet = FALSE;
    String sNm( rNm );
    sNm.ToLowerAscii();
    TypeId aType( TYPE(SfxObjectShell) );
    SfxObjectShell* pShell = SfxObjectShell::GetFirst( &aType );
    while( pShell )
    {
        String sTmp( pShell->GetTitle(SFX_TITLE_FULLNAME) );
        sTmp.ToLowerAscii();
        if( sTmp == sNm )		// die wollen wir haben
        {
            SFX_APP()->AddDdeTopic( pShell );
            bRet = TRUE;
            break;
        }
        pShell = SfxObjectShell::GetNext( *pShell, &aType );
    }

    if( !bRet )
    {
        INetURLObject aWorkPath( SvtPathOptions().GetWorkPath() );
        INetURLObject aFile;
        if ( aWorkPath.GetNewAbsURL( rNm, &aFile ) &&
             SfxContentHelper::IsDocument( aFile.GetMainURL( INetURLObject::NO_DECODE ) ) )
        {
            // File vorhanden

            // dann versuche die Datei zu laden:
            SfxStringItem aName( SID_FILE_NAME, aFile.GetMainURL( INetURLObject::NO_DECODE ) );
            SfxBoolItem aNewView(SID_OPEN_NEW_VIEW, TRUE);
//			SfxBoolItem aHidden(SID_HIDDEN, TRUE);
            // minimiert!
            SfxUInt16Item aViewStat( SID_VIEW_ZOOM_MODE, 0 );
            SfxRectangleItem aRectItem( SID_VIEW_POS_SIZE, Rectangle() );

            SfxBoolItem aSilent(SID_SILENT, TRUE);
            SfxDispatcher* pDispatcher = SFX_APP()->GetDispatcher_Impl();
            const SfxPoolItem* pRet = pDispatcher->Execute( SID_OPENDOC,
                    SFX_CALLMODE_SYNCHRON,
                    &aName, &aNewView,
                    &aViewStat,&aRectItem/*aHidden*/,
                    &aSilent, 0L );

            if( pRet && pRet->ISA( SfxViewFrameItem ) &&
                ((SfxViewFrameItem*)pRet)->GetFrame() &&
                0 != ( pShell = ((SfxViewFrameItem*)pRet)
                    ->GetFrame()->GetObjectShell() ) )
            {
                SFX_APP()->AddDdeTopic( pShell );
                bRet = TRUE;
            }
        }
    }
    return bRet;
}

String ImplDdeService::Topics()
{
    String sRet;
    if( GetSysTopic() )
        sRet += GetSysTopic()->GetName();

    TypeId aType( TYPE(SfxObjectShell) );
    SfxObjectShell* pShell = SfxObjectShell::GetFirst( &aType );
    while( pShell )
    {
        if( SfxViewFrame::GetFirst( pShell, TYPE(SfxTopViewFrame) ))
        {
            if( sRet.Len() )
                sRet += '\t';
            sRet += pShell->GetTitle(SFX_TITLE_FULLNAME);
        }
        pShell = SfxObjectShell::GetNext( *pShell, &aType );
    }
    if( sRet.Len() )
        sRet += DEFINE_CONST_UNICODE("\r\n");
    return sRet;
}

BOOL ImplDdeService::SysTopicExecute( const String* pStr )
{
    return (BOOL)SFX_APP()->DdeExecute( *pStr );
}

//--------------------------------------------------------------------

BOOL SfxDdeTriggerTopic_Impl::Execute( const String* )
{
    return TRUE;
}

//--------------------------------------------------------------------
DdeData* SfxDdeDocTopic_Impl::Get( ULONG nFormat )
{
    String sMimeType( SotExchange::GetFormatMimeType( nFormat ));
    ::com::sun::star::uno::Any aValue;
    long nRet = pSh->DdeGetData( GetCurItem(), sMimeType, aValue );
    if( nRet && aValue.hasValue() && ( aValue >>= aSeq ) )
    {
        aData = DdeData( aSeq.getConstArray(), aSeq.getLength(), nFormat );
        return &aData;
    }
    aSeq.realloc( 0 );
    return 0;
}

BOOL SfxDdeDocTopic_Impl::Put( const DdeData* pData )
{
    aSeq = ::com::sun::star::uno::Sequence< sal_Int8 >(
                            (sal_Int8*)(const void*)*pData, (long)*pData );
    BOOL bRet;
    if( aSeq.getLength() )
    {
        ::com::sun::star::uno::Any aValue;
        aValue <<= aSeq;
        String sMimeType( SotExchange::GetFormatMimeType( pData->GetFormat() ));
        bRet = 0 != pSh->DdeSetData( GetCurItem(), sMimeType, aValue );
    }
    else
        bRet = FALSE;
    return bRet;
}

BOOL SfxDdeDocTopic_Impl::Execute( const String* pStr )
{
    long nRet = pStr ? pSh->DdeExecute( *pStr ) : 0;
    return 0 != nRet;
}

BOOL SfxDdeDocTopic_Impl::MakeItem( const String& rItem )
{
    AddItem( DdeItem( rItem ) );
    return TRUE;
}

BOOL SfxDdeDocTopic_Impl::StartAdviseLoop()
{
    BOOL bRet = FALSE;
    ::sfx2::SvLinkSource* pNewObj = pSh->DdeCreateLinkSource( GetCurItem() );
    if( pNewObj )
    {
        // dann richten wir auch einen entsprechenden SvBaseLink ein
        String sNm, sTmp( Application::GetAppName() );
        ::sfx2::MakeLnkName( sNm, &sTmp, pSh->GetTitle(SFX_TITLE_FULLNAME), GetCurItem() );
        new ::sfx2::SvBaseLink( sNm, OBJECT_DDE_EXTERN, pNewObj );
        bRet = TRUE;
    }
    return bRet;
}