xref: /trunk/main/sd/source/ui/dlg/tpaction.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
30 
31 #ifdef SD_DLLIMPLEMENTATION
32 #undef SD_DLLIMPLEMENTATION
33 #endif
34 
35 #include <svx/svxids.hrc>
36 #include <com/sun/star/presentation/AnimationEffect.hpp>
37 #include <com/sun/star/presentation/ClickAction.hpp>
38 #include <com/sun/star/presentation/AnimationSpeed.hpp>
39 #ifndef _COM_SUN_STAR_EMBED_VERBDESCR_HPP_
40 #include <com/sun/star/embed/VerbDescriptor.hpp>
41 #endif
42 #include <com/sun/star/embed/EmbedStates.hpp>
43 #include <com/sun/star/uri/XUriReferenceFactory.hpp>
44 #include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
45 #include <comphelper/processfactory.hxx>
46 #include <com/sun/star/embed/VerbAttributes.hpp>
47 
48 #include "sdattr.hxx"
49 #include <sfx2/sfxresid.hxx>
50 
51 #include <vcl/waitobj.hxx>
52 #include <osl/file.hxx>
53 #include <sfx2/app.hxx>
54 #include <unotools/pathoptions.hxx>
55 #include <svx/svdpagv.hxx>
56 #include <unotools/localfilehelper.hxx>
57 #include <svl/aeitem.hxx>
58 #include <editeng/colritem.hxx>
59 #include <svx/svdoole2.hxx>
60 #include <sfx2/docfile.hxx>
61 #include <sot/storage.hxx>
62 #include <basic/sbmeth.hxx>
63 #include <basic/sbmod.hxx>
64 #include <basic/sbstar.hxx>
65 #include <svx/xtable.hxx>
66 #include <vcl/svapp.hxx>
67 #include <vcl/mnemonic.hxx>
68 #include <svl/urihelper.hxx>
69 #include <sfx2/filedlghelper.hxx>
70 #include <svx/drawitem.hxx>
71 #include "View.hxx"
72 #include "sdresid.hxx"
73 #include "tpaction.hxx"
74 #include "tpaction.hrc"
75 #include "strmname.h"
76 #include "ViewShell.hxx"
77 #include "drawdoc.hxx"
78 #include "DrawDocShell.hxx"
79 #include "strings.hrc"
80 #include "res_bmp.hrc"
81 #include "filedlg.hxx"
82 
83 #include <algorithm>
84 
85 using namespace ::com::sun::star;
86 using namespace com::sun::star::uno;
87 using namespace com::sun::star::lang;
88 
89 #define DOCUMENT_TOKEN (sal_Unicode('#'))
90 
91 /*************************************************************************
92 |*
93 |* Konstruktor des Tab-Dialogs: Fuegt die Seiten zum Dialog hinzu
94 |*
95 \************************************************************************/
96 
97 SdActionDlg::SdActionDlg (
98     ::Window* pParent, const SfxItemSet* pAttr, ::sd::View* pView ) :
99         SfxSingleTabDialog  ( pParent, *pAttr, TP_ANIMATION_ACTION ),
100         rOutAttrs           ( *pAttr )
101 {
102     // FreeResource();
103     SfxTabPage* pNewPage = SdTPAction::Create( this, rOutAttrs );
104     DBG_ASSERT( pNewPage, "Seite konnte nicht erzeugt werden");
105 
106     // Ehemals in PageCreated
107     ( (SdTPAction*) pNewPage )->SetView( pView );
108     ( (SdTPAction*) pNewPage )->Construct();
109 
110     SetTabPage( pNewPage );
111 
112     String aStr( pNewPage->GetText() );
113     if( aStr.Len() )
114         SetText( aStr );
115 }
116 
117 
118 /*************************************************************************
119 |*
120 |*  Action-TabPage
121 |*
122 \************************************************************************/
123 
124 SdTPAction::SdTPAction( Window* pWindow, const SfxItemSet& rInAttrs ) :
125         SfxTabPage      ( pWindow, SdResId( TP_ANIMATION ), rInAttrs ),
126 
127         aFtAction       ( this, SdResId( FT_ACTION ) ),
128         aLbAction       ( this, SdResId( LB_ACTION ) ),
129         aFtTree         ( this, SdResId( FT_TREE ) ),
130         aLbTree         ( this, SdResId( LB_TREE ) ),
131         aLbTreeDocument ( this, SdResId( LB_TREE_DOCUMENT ) ),
132         aLbOLEAction    ( this, SdResId( LB_OLE_ACTION ) ),
133         aFlSeparator    ( this, SdResId( FL_SEPARATOR ) ),
134         aEdtSound       ( this, SdResId( EDT_SOUND ) ),
135         aEdtBookmark    ( this, SdResId( EDT_BOOKMARK ) ),
136         aEdtDocument    ( this, SdResId( EDT_DOCUMENT ) ),
137         aEdtProgram     ( this, SdResId( EDT_PROGRAM ) ),
138         aEdtMacro       ( this, SdResId( EDT_MACRO ) ),
139         aBtnSearch      ( this, SdResId( BTN_SEARCH ) ),
140         aBtnSeek        ( this, SdResId( BTN_SEEK ) ),
141 
142         rOutAttrs       ( rInAttrs ),
143         mpView          ( NULL ),
144         mpDoc           ( NULL ),
145         bTreeUpdated    ( sal_False )
146 {
147     aEdtSound.SetAccessibleName(String(SdResId(STR_PATHNAME)));
148     aBtnSeek.SetAccessibleRelationMemberOf( &aFlSeparator );
149 
150     FreeResource();
151 
152     aBtnSearch.SetClickHdl( LINK( this, SdTPAction, ClickSearchHdl ) );
153     aBtnSeek.SetClickHdl( LINK( this, SdTPAction, ClickSearchHdl ) );
154 
155     // diese Page braucht ExchangeSupport
156     SetExchangeSupport();
157 
158     aLbAction.SetSelectHdl( LINK( this, SdTPAction, ClickActionHdl ) );
159     aLbTree.SetSelectHdl( LINK( this, SdTPAction, SelectTreeHdl ) );
160     aEdtDocument.SetLoseFocusHdl( LINK( this, SdTPAction, CheckFileHdl ) );
161     aEdtMacro.SetLoseFocusHdl( LINK( this, SdTPAction, CheckFileHdl ) );
162 
163     // Controls enablen
164     aFtAction.Show();
165     aLbAction.Show();
166 
167     ClickActionHdl( this );
168 }
169 
170 // -----------------------------------------------------------------------
171 
172 SdTPAction::~SdTPAction()
173 {
174     delete pCurrentActions;
175 }
176 
177 // -----------------------------------------------------------------------
178 
179 void SdTPAction::SetView( const ::sd::View* pSdView )
180 {
181     mpView = pSdView;
182 
183     // Holen der ColorTable und Fuellen der ListBox
184     ::sd::DrawDocShell* pDocSh = static_cast<const ::sd::View*>(mpView)->GetDocSh();
185     if( pDocSh && pDocSh->GetViewShell() )
186     {
187         mpDoc = pDocSh->GetDoc();
188         SfxViewFrame* pFrame = pDocSh->GetViewShell()->GetViewFrame();
189         aLbTree.SetViewFrame( pFrame );
190         aLbTreeDocument.SetViewFrame( pFrame );
191 
192         SvxColorTableItem aItem( *(const SvxColorTableItem*)( pDocSh->GetItem( SID_COLOR_TABLE ) ) );
193         pColTab = aItem.GetColorTable();
194         DBG_ASSERT( pColTab, "Keine Farbtabelle vorhanden!" );
195     }
196     else
197     {
198         DBG_ERROR("sd::SdTPAction::SetView(), no docshell or viewshell?");
199     }
200 }
201 
202 // -----------------------------------------------------------------------
203 
204 void SdTPAction::Construct()
205 {
206     // OLE-Actionlistbox auffuellen
207     SdrOle2Obj* pOleObj = NULL;
208     SdrGrafObj* pGrafObj = NULL;
209     sal_Bool        bOLEAction = sal_False;
210 
211     if ( mpView->AreObjectsMarked() )
212     {
213         const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
214         SdrObject* pObj;
215 
216         if (rMarkList.GetMarkCount() == 1)
217         {
218             SdrMark* pMark = rMarkList.GetMark(0);
219             pObj = pMark->GetMarkedSdrObj();
220 
221             sal_uInt32 nInv = pObj->GetObjInventor();
222             sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
223 
224             if (nInv == SdrInventor && nSdrObjKind == OBJ_OLE2)
225             {
226                 pOleObj = (SdrOle2Obj*) pObj;
227             }
228             else if (nInv == SdrInventor && nSdrObjKind == OBJ_GRAF)
229             {
230                 pGrafObj = (SdrGrafObj*) pObj;
231             }
232 //          // VCXControl ?
233 //          else if( pObj->IsA( TYPE( VCSbxDrawObject ) ) )
234 //          {
235 //              bDisableAll = sal_True;
236 //          }
237         }
238     }
239     if( pGrafObj )
240     {
241         bOLEAction = sal_True;
242 
243         aVerbVector.push_back( 0 );
244         aLbOLEAction.InsertEntry( MnemonicGenerator::EraseAllMnemonicChars( String( SdResId( STR_EDIT_OBJ ) ) ) );
245     }
246     else if( pOleObj )
247     {
248         uno::Reference < embed::XEmbeddedObject > xObj = pOleObj->GetObjRef();
249         if ( xObj.is() )
250         {
251             bOLEAction = sal_True;
252             uno::Sequence < embed::VerbDescriptor > aVerbs;
253             try
254             {
255                 aVerbs = xObj->getSupportedVerbs();
256             }
257             catch ( embed::NeedsRunningStateException& )
258             {
259                 xObj->changeState( embed::EmbedStates::RUNNING );
260                 aVerbs = xObj->getSupportedVerbs();
261             }
262 
263             for( sal_Int32 i=0; i<aVerbs.getLength(); i++ )
264             {
265                 embed::VerbDescriptor aVerb = aVerbs[i];
266                 if( aVerb.VerbAttributes & embed::VerbAttributes::MS_VERBATTR_ONCONTAINERMENU )
267                 {
268                     String aTmp( aVerb.VerbName );
269                     aVerbVector.push_back( aVerb.VerbID );
270                     aLbOLEAction.InsertEntry( MnemonicGenerator::EraseAllMnemonicChars( aTmp ) );
271                 }
272             }
273         }
274     }
275 
276     pCurrentActions = new List;
277     pCurrentActions->Insert((void*)(sal_uIntPtr)presentation::ClickAction_NONE, LIST_APPEND);
278     pCurrentActions->Insert((void*)(sal_uIntPtr)presentation::ClickAction_PREVPAGE, LIST_APPEND);
279     pCurrentActions->Insert((void*)(sal_uIntPtr)presentation::ClickAction_NEXTPAGE, LIST_APPEND);
280     pCurrentActions->Insert((void*)(sal_uIntPtr)presentation::ClickAction_FIRSTPAGE, LIST_APPEND);
281     pCurrentActions->Insert((void*)(sal_uIntPtr)presentation::ClickAction_LASTPAGE, LIST_APPEND);
282     pCurrentActions->Insert((void*)(sal_uIntPtr)presentation::ClickAction_BOOKMARK, LIST_APPEND);
283     pCurrentActions->Insert((void*)(sal_uIntPtr)presentation::ClickAction_DOCUMENT, LIST_APPEND);
284     pCurrentActions->Insert((void*)(sal_uIntPtr)presentation::ClickAction_SOUND, LIST_APPEND);
285     if( bOLEAction && aLbOLEAction.GetEntryCount() )
286         pCurrentActions->Insert((void*)(sal_uIntPtr)presentation::ClickAction_VERB, LIST_APPEND );
287     pCurrentActions->Insert((void*)(sal_uIntPtr)presentation::ClickAction_PROGRAM, LIST_APPEND);
288     pCurrentActions->Insert((void*)(sal_uIntPtr)presentation::ClickAction_MACRO, LIST_APPEND);
289     pCurrentActions->Insert((void*)(sal_uIntPtr)presentation::ClickAction_STOPPRESENTATION, LIST_APPEND);
290 
291     // Action-Listbox fuellen
292     for (sal_uLong nAction = 0; nAction < pCurrentActions->Count(); nAction++)
293     {
294         sal_uInt16 nRId = GetClickActionSdResId((presentation::ClickAction)(sal_uLong)pCurrentActions->GetObject(nAction));
295         aLbAction.InsertEntry( String( SdResId( nRId ) ) );
296     }
297 
298 }
299 
300 // -----------------------------------------------------------------------
301 
302 sal_Bool SdTPAction::FillItemSet( SfxItemSet& rAttrs )
303 {
304     sal_Bool bModified = sal_False;
305     presentation::ClickAction eCA = presentation::ClickAction_NONE;
306 
307     if( aLbAction.GetSelectEntryCount() )
308         eCA = GetActualClickAction();
309 
310     if( aLbAction.GetSavedValue() != aLbAction.GetSelectEntryPos() )
311     {
312         rAttrs.Put( SfxAllEnumItem( ATTR_ACTION, (sal_uInt16)eCA ) );
313         bModified = sal_True;
314     }
315     else
316         rAttrs.InvalidateItem( ATTR_ACTION );
317 
318     String aFileName = GetEditText( sal_True );
319     if( aFileName.Len() == 0 )
320         rAttrs.InvalidateItem( ATTR_ACTION_FILENAME );
321     else
322     {
323         if( mpDoc && mpDoc->GetDocSh() && mpDoc->GetDocSh()->GetMedium() )
324         {
325             String aBaseURL = mpDoc->GetDocSh()->GetMedium()->GetBaseURL();
326             if( eCA == presentation::ClickAction_SOUND ||
327                 eCA == presentation::ClickAction_DOCUMENT ||
328                 eCA == presentation::ClickAction_PROGRAM )
329                 aFileName = ::URIHelper::SmartRel2Abs( INetURLObject(aBaseURL), aFileName, URIHelper::GetMaybeFileHdl(), true, false,
330                                                         INetURLObject::WAS_ENCODED,
331                                                         INetURLObject::DECODE_UNAMBIGUOUS );
332 
333             rAttrs.Put( SfxStringItem( ATTR_ACTION_FILENAME, aFileName ) );
334             bModified = sal_True;
335         }
336         else
337         {
338             DBG_ERROR("sd::SdTPAction::FillItemSet(), I need a medium!");
339         }
340     }
341 
342     return( bModified );
343 }
344 
345 //------------------------------------------------------------------------
346 
347 void SdTPAction::Reset( const SfxItemSet& rAttrs )
348 {
349     presentation::ClickAction eCA = presentation::ClickAction_NONE;
350     String      aFileName;
351 
352     // aLbAction
353     if( rAttrs.GetItemState( ATTR_ACTION ) != SFX_ITEM_DONTCARE )
354     {
355         eCA = (presentation::ClickAction) ( ( const SfxAllEnumItem& ) rAttrs.
356                     Get( ATTR_ACTION ) ).GetValue();
357         SetActualClickAction( eCA );
358     }
359     else
360         aLbAction.SetNoSelection();
361 
362     // aEdtSound
363     if( rAttrs.GetItemState( ATTR_ACTION_FILENAME ) != SFX_ITEM_DONTCARE )
364     {
365             aFileName = ( ( const SfxStringItem& ) rAttrs.Get( ATTR_ACTION_FILENAME ) ).GetValue();
366             SetEditText( aFileName );
367     }
368 
369     switch( eCA )
370     {
371         case presentation::ClickAction_BOOKMARK:
372         {
373             if( !aLbTree.SelectEntry( aFileName ) )
374                 aLbTree.SelectAll( sal_False );
375         }
376         break;
377 
378         case presentation::ClickAction_DOCUMENT:
379         {
380             if( aFileName.GetTokenCount( DOCUMENT_TOKEN ) == 2 )
381                 aLbTreeDocument.SelectEntry( aFileName.GetToken( 1, DOCUMENT_TOKEN ) );
382         }
383         break;
384 
385         default:
386         break;
387     }
388     ClickActionHdl( this );
389 
390     aLbAction.SaveValue();
391     aEdtSound.SaveValue();
392 }
393 
394 // -----------------------------------------------------------------------
395 
396 void SdTPAction::ActivatePage( const SfxItemSet& )
397 {
398 }
399 
400 // -----------------------------------------------------------------------
401 
402 int SdTPAction::DeactivatePage( SfxItemSet* pPageSet )
403 {
404     if( pPageSet )
405         FillItemSet( *pPageSet );
406 
407     return( LEAVE_PAGE );
408 }
409 
410 // -----------------------------------------------------------------------
411 
412 SfxTabPage* SdTPAction::Create( Window* pWindow,
413                 const SfxItemSet& rAttrs )
414 {
415     return( new SdTPAction( pWindow, rAttrs ) );
416 }
417 
418 //------------------------------------------------------------------------
419 
420 void SdTPAction::UpdateTree()
421 {
422     if( !bTreeUpdated && mpDoc && mpDoc->GetDocSh() && mpDoc->GetDocSh()->GetMedium() )
423     {
424         //aLbTree.Clear();
425         aLbTree.Fill( mpDoc, sal_True, mpDoc->GetDocSh()->GetMedium()->GetName() );
426         bTreeUpdated = sal_True;
427     }
428 }
429 
430 //------------------------------------------------------------------------
431 
432 void SdTPAction::OpenFileDialog()
433 {
434     // Soundpreview nur fuer Interaktionen mit Sound
435     presentation::ClickAction eCA = GetActualClickAction();
436     sal_Bool bSound = ( eCA == presentation::ClickAction_SOUND );
437     sal_Bool bPage = ( eCA == presentation::ClickAction_BOOKMARK );
438     sal_Bool bDocument = ( eCA == presentation::ClickAction_DOCUMENT ||
439                        eCA == presentation::ClickAction_PROGRAM );
440     sal_Bool bMacro = ( eCA == presentation::ClickAction_MACRO );
441 
442     if( bPage )
443     {
444         // Es wird in der TreeLB nach dem eingegebenen Objekt gesucht
445         aLbTree.SelectEntry( GetEditText() );
446     }
447     else
448     {
449         String aFile( GetEditText() );
450 
451         if (bSound)
452         {
453             SdOpenSoundFileDialog   aFileDialog;
454 
455             if( !aFile.Len() )
456                 aFile = SvtPathOptions().GetGraphicPath();
457 
458             aFileDialog.SetPath( aFile );
459 
460             if( aFileDialog.Execute() == ERRCODE_NONE )
461             {
462                 aFile = aFileDialog.GetPath();
463                 SetEditText( aFile );
464             }
465         }
466         else if (bMacro)
467         {
468             Window* pOldWin = Application::GetDefDialogParent();
469             Application::SetDefDialogParent( this );
470 
471             // choose macro dialog
472             ::rtl::OUString aScriptURL = SfxApplication::ChooseScript();
473 
474             if ( aScriptURL.getLength() != 0 )
475             {
476                 SetEditText( aScriptURL );
477             }
478 
479             Application::SetDefDialogParent( pOldWin );
480         }
481         else
482         {
483             sfx2::FileDialogHelper aFileDialog(WB_OPEN | WB_3DLOOK | WB_STDMODAL );
484 
485             if (bDocument && !aFile.Len())
486                 aFile = SvtPathOptions().GetWorkPath();
487 
488             aFileDialog.SetDisplayDirectory( aFile );
489 
490             // The following is a fix for #1008001# and a workarround for
491             // #i4306#: The addition of the implicitely existing "all files"
492             // filter makes the (Windows system) open file dialog follow
493             // links on the desktop to directories.
494             aFileDialog.AddFilter (
495                 String (SfxResId (STR_SFX_FILTERNAME_ALL)),
496                 String (RTL_CONSTASCII_USTRINGPARAM("*.*")));
497 
498 
499             if( aFileDialog.Execute() == ERRCODE_NONE )
500             {
501                 aFile = aFileDialog.GetPath();
502                 SetEditText( aFile );
503             }
504             if( bDocument )
505                 CheckFileHdl( NULL );
506         }
507     }
508 }
509 
510 //------------------------------------------------------------------------
511 
512 IMPL_LINK( SdTPAction, ClickSearchHdl, void *, EMPTYARG )
513 {
514     OpenFileDialog();
515 
516     return( 0L );
517 }
518 
519 //------------------------------------------------------------------------
520 
521 IMPL_LINK( SdTPAction, ClickActionHdl, void *, EMPTYARG )
522 {
523     presentation::ClickAction eCA = GetActualClickAction();
524 
525     // hide controls we don't need
526     switch( eCA )
527     {
528         case presentation::ClickAction_NONE:
529         case presentation::ClickAction_INVISIBLE:
530         case presentation::ClickAction_PREVPAGE:
531         case presentation::ClickAction_NEXTPAGE:
532         case presentation::ClickAction_FIRSTPAGE:
533         case presentation::ClickAction_LASTPAGE:
534         case presentation::ClickAction_STOPPRESENTATION:
535         default:
536             aFtTree.Hide();
537             aLbTree.Hide();
538             aLbTreeDocument.Hide();
539             aLbOLEAction.Hide();
540 
541             aFlSeparator.Hide();
542             aEdtSound.Hide();
543             aEdtBookmark.Hide();
544             aEdtDocument.Hide();
545             aEdtProgram.Hide();
546             aEdtMacro.Hide();
547             aBtnSearch.Hide();
548             aBtnSeek.Hide();
549             break;
550 
551         case presentation::ClickAction_SOUND:
552         case presentation::ClickAction_PROGRAM:
553         case presentation::ClickAction_MACRO:
554             aFtTree.Hide();
555             aLbTree.Hide();
556             aLbTreeDocument.Hide();
557             aLbOLEAction.Hide();
558 
559             aEdtDocument.Hide();
560 
561             if( eCA == presentation::ClickAction_MACRO )
562             {
563                 aEdtSound.Hide();
564                 aEdtProgram.Hide();
565             }
566             else if( eCA == presentation::ClickAction_PROGRAM )
567             {
568                 aEdtSound.Hide();
569                 aEdtMacro.Hide();
570             }
571             else if( eCA == presentation::ClickAction_SOUND )
572             {
573                 aEdtProgram.Hide();
574                 aEdtMacro.Hide();
575             }
576 
577             aBtnSeek.Hide();
578             break;
579 
580 
581         case presentation::ClickAction_DOCUMENT:
582             aLbTree.Hide();
583             aLbOLEAction.Hide();
584 
585             aEdtSound.Hide();
586             aEdtProgram.Hide();
587             aEdtMacro.Hide();
588             aEdtBookmark.Hide();
589             aBtnSeek.Hide();
590             break;
591 
592         case presentation::ClickAction_BOOKMARK:
593             aLbTreeDocument.Hide();
594             aLbOLEAction.Hide();
595             aEdtSound.Hide();
596             aEdtDocument.Hide();
597             aEdtProgram.Hide();
598             aEdtMacro.Hide();
599             aBtnSearch.Hide();
600             break;
601 
602         case presentation::ClickAction_VERB:
603             aLbTree.Hide();
604             aEdtDocument.Hide();
605             aEdtProgram.Hide();
606             aEdtBookmark.Hide();
607             aEdtMacro.Hide();
608             aBtnSearch.Hide();
609             aFlSeparator.Hide();
610             aEdtSound.Hide();
611             aBtnSeek.Hide();
612             break;
613     }
614 
615     // show controls we do need
616     switch( eCA )
617     {
618         case presentation::ClickAction_NONE:
619         case presentation::ClickAction_INVISIBLE:
620         case presentation::ClickAction_PREVPAGE:
621         case presentation::ClickAction_NEXTPAGE:
622         case presentation::ClickAction_FIRSTPAGE:
623         case presentation::ClickAction_LASTPAGE:
624         case presentation::ClickAction_STOPPRESENTATION:
625             // none
626             break;
627 
628         case presentation::ClickAction_SOUND:
629             aFlSeparator.Show();
630             aEdtSound.Show();
631             aEdtSound.Enable();
632             aBtnSearch.Show();
633             aBtnSearch.Enable();
634             aFlSeparator.SetText( String( SdResId( STR_EFFECTDLG_SOUND ) ) );
635             break;
636 
637         case presentation::ClickAction_PROGRAM:
638         case presentation::ClickAction_MACRO:
639             aFlSeparator.Show();
640             aBtnSearch.Show();
641             aBtnSearch.Enable();
642             if( eCA == presentation::ClickAction_MACRO )
643             {
644                 aEdtMacro.Show();
645                 aFlSeparator.SetText( String( SdResId( STR_EFFECTDLG_MACRO ) ) );
646             }
647             else
648             {
649                 aEdtProgram.Show();
650                 aFlSeparator.SetText( String( SdResId( STR_EFFECTDLG_PROGRAM ) ) );
651             }
652             break;
653 
654         case presentation::ClickAction_DOCUMENT:
655             aFtTree.Show();
656             aLbTreeDocument.Show();
657 
658             aFlSeparator.Show();
659             aEdtDocument.Show();
660             aBtnSearch.Show();
661             aBtnSearch.Enable();
662 
663             aFtTree.SetText( String( SdResId( STR_EFFECTDLG_JUMP ) ) );
664             aFlSeparator.SetText( String( SdResId( STR_EFFECTDLG_DOCUMENT ) ) );
665 
666             CheckFileHdl( NULL );
667             break;
668 
669         case presentation::ClickAction_VERB:
670             aFtTree.Show();
671             aLbOLEAction.Show();
672 
673             aFtTree.SetText( String( SdResId( STR_EFFECTDLG_ACTION ) ) );
674             break;
675 
676         case presentation::ClickAction_BOOKMARK:
677             UpdateTree();
678 
679             aFtTree.Show();
680             aLbTree.Show();
681 
682             aFlSeparator.Show();
683             aEdtBookmark.Show();
684             aBtnSeek.Show();
685 
686             aFtTree.SetText( String( SdResId( STR_EFFECTDLG_JUMP ) ) );
687             aFlSeparator.SetText( String( SdResId( STR_EFFECTDLG_PAGE_OBJECT ) ) );
688             break;
689         default:
690             break;
691     }
692 
693     return( 0L );
694 }
695 
696 //------------------------------------------------------------------------
697 
698 IMPL_LINK( SdTPAction, SelectTreeHdl, void *, EMPTYARG )
699 {
700     aEdtBookmark.SetText( aLbTree.GetSelectEntry() );
701     return( 0L );
702 }
703 
704 //------------------------------------------------------------------------
705 
706 IMPL_LINK( SdTPAction, CheckFileHdl, void *, EMPTYARG )
707 {
708     String aFile( GetEditText() );
709 
710     if( aFile != aLastFile )
711     {
712         // Ueberpruefen, ob es eine gueltige Draw-Datei ist
713         SfxMedium aMedium( aFile,
714                     STREAM_READ | STREAM_NOCREATE,
715                     sal_True );               // Download
716 
717         if( aMedium.IsStorage() )
718         {
719             WaitObject aWait( GetParent()->GetParent() );
720 
721             // ist es eine Draw-Datei?
722             // mit READ oeffnen, sonst schreiben die Storages evtl. in die Datei!
723             uno::Reference < embed::XStorage > xStorage = aMedium.GetStorage();
724             DBG_ASSERT( xStorage.is(), "Kein Storage!" );
725 
726             uno::Reference < container::XNameAccess > xAccess( xStorage, uno::UNO_QUERY );
727             if( xAccess.is() &&
728                 ( xAccess->hasByName( pStarDrawXMLContent ) ||
729                 xAccess->hasByName( pStarDrawOldXMLContent ) ) )
730             {
731                 SdDrawDocument* pBookmarkDoc = mpDoc->OpenBookmarkDoc( aFile );
732                 if( pBookmarkDoc )
733                 {
734                     aLastFile = aFile;
735 
736                     aLbTreeDocument.Clear();
737                     aLbTreeDocument.Fill( pBookmarkDoc, sal_True, aFile );
738                     mpDoc->CloseBookmarkDoc();
739                     aLbTreeDocument.Show();
740                 }
741                 else
742                     aLbTreeDocument.Hide();
743             }
744             else
745                 aLbTreeDocument.Hide();
746 
747         }
748         else
749             aLbTreeDocument.Hide();
750     }
751 
752     return( 0L );
753 }
754 
755 //------------------------------------------------------------------------
756 
757 presentation::ClickAction SdTPAction::GetActualClickAction()
758 {
759     presentation::ClickAction eCA = presentation::ClickAction_NONE;
760     sal_uInt16 nPos = aLbAction.GetSelectEntryPos();
761 
762     if (nPos != LISTBOX_ENTRY_NOTFOUND)
763         eCA = (presentation::ClickAction)(sal_uLong)pCurrentActions->GetObject((sal_uLong)nPos);
764     return( eCA );
765 }
766 
767 //------------------------------------------------------------------------
768 
769 void SdTPAction::SetActualClickAction( presentation::ClickAction eCA )
770 {
771     sal_uInt16 nPos = (sal_uInt16)pCurrentActions->GetPos((void*)(sal_uLong)eCA);
772     DBG_ASSERT(nPos != 0xffff, "unbekannte Interaktion");
773     aLbAction.SelectEntryPos(nPos);
774 }
775 
776 //------------------------------------------------------------------------
777 
778 void SdTPAction::SetEditText( String const & rStr )
779 {
780     presentation::ClickAction   eCA = GetActualClickAction();
781     String                      aText(rStr);
782 
783     // possibly convert URI back to system path
784     switch( eCA )
785     {
786         case presentation::ClickAction_DOCUMENT:
787             if( rStr.GetTokenCount( DOCUMENT_TOKEN ) == 2 )
788                 aText = rStr.GetToken( 0, DOCUMENT_TOKEN );
789 
790             // fallthrough inteded
791         case presentation::ClickAction_SOUND:
792         case presentation::ClickAction_PROGRAM:
793             {
794                 INetURLObject aURL( aText );
795 
796                 // try to convert to system path
797                 String aTmpStr(aURL.getFSysPath(INetURLObject::FSYS_DETECT));
798 
799                 if( aTmpStr.Len() )
800                     aText = aTmpStr;    // was a system path
801             }
802             break;
803         default:
804             break;
805     }
806 
807     // set the string to the corresponding control
808     switch( eCA )
809     {
810         case presentation::ClickAction_SOUND:
811             aEdtSound.SetText(aText );
812             break;
813         case presentation::ClickAction_VERB:
814             {
815                 ::std::vector< long >::iterator aFound( ::std::find( aVerbVector.begin(), aVerbVector.end(), rStr.ToInt32() ) );
816                 if( aFound != aVerbVector.end() )
817                     aLbOLEAction.SelectEntryPos( static_cast< short >( aFound - aVerbVector.begin() ) );
818             }
819             break;
820         case presentation::ClickAction_PROGRAM:
821             aEdtProgram.SetText( aText );
822             break;
823         case presentation::ClickAction_MACRO:
824         {
825             aEdtMacro.SetText( aText );
826         }
827             break;
828         case presentation::ClickAction_DOCUMENT:
829             aEdtDocument.SetText( aText );
830             break;
831         case presentation::ClickAction_BOOKMARK:
832             aEdtBookmark.SetText( aText );
833             break;
834         default:
835             break;
836     }
837 }
838 
839 //------------------------------------------------------------------------
840 
841 String SdTPAction::GetEditText( sal_Bool bFullDocDestination )
842 {
843     String aStr;
844     presentation::ClickAction eCA = GetActualClickAction();
845 
846     switch( eCA )
847     {
848         case presentation::ClickAction_SOUND:
849             aStr = aEdtSound.GetText();
850             break;
851         case presentation::ClickAction_VERB:
852             {
853                 const sal_uInt16 nPos = aLbOLEAction.GetSelectEntryPos();
854                 if( nPos < aVerbVector.size() )
855                     aStr = UniString::CreateFromInt32( aVerbVector[ nPos ] );
856                 return aStr;
857             }
858         case presentation::ClickAction_DOCUMENT:
859             aStr = aEdtDocument.GetText();
860             break;
861 
862         case presentation::ClickAction_PROGRAM:
863             aStr = aEdtProgram.GetText();
864             break;
865 
866         case presentation::ClickAction_MACRO:
867         {
868             return aEdtMacro.GetText();
869         }
870 
871         case presentation::ClickAction_BOOKMARK:
872             return( aEdtBookmark.GetText() );
873 
874         default:
875             break;
876     }
877 
878     // validate file URI
879     INetURLObject aURL( aStr );
880     String aBaseURL;
881     if( mpDoc && mpDoc->GetDocSh() && mpDoc->GetDocSh()->GetMedium() )
882         aBaseURL = mpDoc->GetDocSh()->GetMedium()->GetBaseURL();
883 
884     if( aStr.Len() && aURL.GetProtocol() == INET_PROT_NOT_VALID )
885         aURL = INetURLObject( ::URIHelper::SmartRel2Abs( INetURLObject(aBaseURL), aStr, URIHelper::GetMaybeFileHdl(), true, false ) );
886 
887     // get adjusted file name
888     aStr = aURL.GetMainURL( INetURLObject::NO_DECODE );
889 
890     if( bFullDocDestination &&
891         eCA == presentation::ClickAction_DOCUMENT &&
892         aLbTreeDocument.Control::IsVisible() &&
893         aLbTreeDocument.GetSelectionCount() > 0 )
894     {
895         String aTmpStr( aLbTreeDocument.GetSelectEntry() );
896         if( aTmpStr.Len() )
897         {
898             aStr.Append( DOCUMENT_TOKEN );
899             aStr.Append( aTmpStr );
900         }
901     }
902 
903     return( aStr );
904 }
905 
906 //------------------------------------------------------------------------
907 
908 sal_uInt16 SdTPAction::GetClickActionSdResId( presentation::ClickAction eCA )
909 {
910     switch( eCA )
911     {
912         case presentation::ClickAction_NONE:             return STR_CLICK_ACTION_NONE;
913         case presentation::ClickAction_PREVPAGE:         return STR_CLICK_ACTION_PREVPAGE;
914         case presentation::ClickAction_NEXTPAGE:         return STR_CLICK_ACTION_NEXTPAGE;
915         case presentation::ClickAction_FIRSTPAGE:        return STR_CLICK_ACTION_FIRSTPAGE;
916         case presentation::ClickAction_LASTPAGE:         return STR_CLICK_ACTION_LASTPAGE;
917         case presentation::ClickAction_BOOKMARK:         return STR_CLICK_ACTION_BOOKMARK;
918         case presentation::ClickAction_DOCUMENT:         return STR_CLICK_ACTION_DOCUMENT;
919         case presentation::ClickAction_PROGRAM:          return STR_CLICK_ACTION_PROGRAM;
920         case presentation::ClickAction_MACRO:            return STR_CLICK_ACTION_MACRO;
921         case presentation::ClickAction_SOUND:            return STR_CLICK_ACTION_SOUND;
922         case presentation::ClickAction_VERB:             return STR_CLICK_ACTION_VERB;
923         case presentation::ClickAction_STOPPRESENTATION: return STR_CLICK_ACTION_STOPPRESENTATION;
924         default: DBG_ERROR( "Keine StringResource fuer ClickAction vorhanden!" );
925     }
926     return( 0 );
927 }
928 
929