merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / dlg / tpaction.cxx
blob3e4788cb30c59d0e2fc8e6035bc4d77a8ee5b2f8
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tpaction.cxx,v $
10 * $Revision: 1.41 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #ifdef SD_DLLIMPLEMENTATION
35 #undef SD_DLLIMPLEMENTATION
36 #endif
39 #include <com/sun/star/presentation/AnimationEffect.hpp>
40 #include <com/sun/star/presentation/ClickAction.hpp>
41 #include <com/sun/star/presentation/AnimationSpeed.hpp>
42 #ifndef _COM_SUN_STAR_EMBED_VERBDESCR_HPP_
43 #include <com/sun/star/embed/VerbDescriptor.hpp>
44 #endif
45 #include <com/sun/star/embed/EmbedStates.hpp>
46 #include <com/sun/star/uri/XUriReferenceFactory.hpp>
47 #include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
48 #include <comphelper/processfactory.hxx>
49 #include <com/sun/star/embed/VerbAttributes.hpp>
51 #include "sdattr.hxx"
54 #include <vcl/waitobj.hxx>
55 #include <osl/file.hxx>
56 #include <sfx2/app.hxx>
57 #include <svtools/pathoptions.hxx>
58 #include <svx/svdpagv.hxx>
59 #include <unotools/localfilehelper.hxx>
60 #include <svtools/aeitem.hxx>
61 #include <svx/colritem.hxx>
62 #include <svx/svdoole2.hxx>
63 #include <sfx2/docfile.hxx>
64 #include <sot/storage.hxx>
65 #include <basic/sbmeth.hxx>
66 #include <basic/sbmod.hxx>
67 #include <basic/sbstar.hxx>
68 #include <svx/xtable.hxx>
69 #include <vcl/svapp.hxx>
70 #include <vcl/mnemonic.hxx>
71 #include <svtools/urihelper.hxx>
72 #include <sfx2/filedlghelper.hxx>
73 #include <svx/drawitem.hxx>
74 #include "View.hxx"
75 #include "sdresid.hxx"
76 #include "tpaction.hxx"
77 #include "tpaction.hrc"
78 #include "strmname.h"
79 #include "ViewShell.hxx"
80 #include "drawdoc.hxx"
81 #include "DrawDocShell.hxx"
82 #include "strings.hrc"
83 #include "res_bmp.hrc"
84 #include "filedlg.hxx"
86 #include <algorithm>
88 using namespace ::com::sun::star;
89 using namespace com::sun::star::uno;
90 using namespace com::sun::star::lang;
92 static USHORT pActionRanges[] =
94 ATTR_ANIMATION_TRANSPCOLOR,
95 ATTR_ANIMATION_TRANSPCOLOR,
96 ATTR_ACTION_START,
97 ATTR_ACTION_END,
101 #define DOCUMENT_TOKEN (sal_Unicode('#'))
103 /*************************************************************************
105 |* Konstruktor des Tab-Dialogs: Fuegt die Seiten zum Dialog hinzu
107 \************************************************************************/
109 SdActionDlg::SdActionDlg (
110 ::Window* pParent, const SfxItemSet* pAttr, ::sd::View* pView ) :
111 SfxSingleTabDialog ( pParent, *pAttr, TP_ANIMATION_ACTION ),
112 rOutAttrs ( *pAttr )
114 // FreeResource();
115 SfxTabPage* pNewPage = SdTPAction::Create( this, rOutAttrs );
116 DBG_ASSERT( pNewPage, "Seite konnte nicht erzeugt werden");
118 // Ehemals in PageCreated
119 ( (SdTPAction*) pNewPage )->SetView( pView );
120 ( (SdTPAction*) pNewPage )->Construct();
122 SetTabPage( pNewPage );
124 String aStr( pNewPage->GetText() );
125 if( aStr.Len() )
126 SetText( aStr );
130 /*************************************************************************
132 |* Action-TabPage
134 \************************************************************************/
136 SdTPAction::SdTPAction( Window* pWindow, const SfxItemSet& rInAttrs ) :
137 SfxTabPage ( pWindow, SdResId( TP_ANIMATION ), rInAttrs ),
139 aFtAction ( this, SdResId( FT_ACTION ) ),
140 aLbAction ( this, SdResId( LB_ACTION ) ),
141 aFtTree ( this, SdResId( FT_TREE ) ),
142 aLbTree ( this, SdResId( LB_TREE ) ),
143 aLbTreeDocument ( this, SdResId( LB_TREE_DOCUMENT ) ),
144 aLbOLEAction ( this, SdResId( LB_OLE_ACTION ) ),
145 aFlSeparator ( this, SdResId( FL_SEPARATOR ) ),
146 aEdtSound ( this, SdResId( EDT_SOUND ) ),
147 aEdtBookmark ( this, SdResId( EDT_BOOKMARK ) ),
148 aEdtDocument ( this, SdResId( EDT_DOCUMENT ) ),
149 aEdtProgram ( this, SdResId( EDT_PROGRAM ) ),
150 aEdtMacro ( this, SdResId( EDT_MACRO ) ),
151 aBtnSearch ( this, SdResId( BTN_SEARCH ) ),
152 aBtnSeek ( this, SdResId( BTN_SEEK ) ),
154 rOutAttrs ( rInAttrs ),
155 mpView ( NULL ),
156 mpDoc ( NULL ),
157 bTreeUpdated ( FALSE )
159 FreeResource();
161 aBtnSearch.SetClickHdl( LINK( this, SdTPAction, ClickSearchHdl ) );
162 aBtnSeek.SetClickHdl( LINK( this, SdTPAction, ClickSearchHdl ) );
164 // diese Page braucht ExchangeSupport
165 SetExchangeSupport();
167 aLbAction.SetSelectHdl( LINK( this, SdTPAction, ClickActionHdl ) );
168 aLbTree.SetSelectHdl( LINK( this, SdTPAction, SelectTreeHdl ) );
169 aEdtDocument.SetLoseFocusHdl( LINK( this, SdTPAction, CheckFileHdl ) );
170 aEdtMacro.SetLoseFocusHdl( LINK( this, SdTPAction, CheckFileHdl ) );
172 // Controls enablen
173 aFtAction.Show();
174 aLbAction.Show();
176 ClickActionHdl( this );
179 // -----------------------------------------------------------------------
181 SdTPAction::~SdTPAction()
183 delete pCurrentActions;
186 // -----------------------------------------------------------------------
188 void SdTPAction::SetView( const ::sd::View* pSdView )
190 mpView = pSdView;
192 // Holen der ColorTable und Fuellen der ListBox
193 ::sd::DrawDocShell* pDocSh = static_cast<const ::sd::View*>(mpView)->GetDocSh();
194 if( pDocSh && pDocSh->GetViewShell() )
196 mpDoc = pDocSh->GetDoc();
197 SfxViewFrame* pFrame = pDocSh->GetViewShell()->GetViewFrame();
198 aLbTree.SetViewFrame( pFrame );
199 aLbTreeDocument.SetViewFrame( pFrame );
201 SvxColorTableItem aItem( *(const SvxColorTableItem*)( pDocSh->GetItem( SID_COLOR_TABLE ) ) );
202 pColTab = aItem.GetColorTable();
203 DBG_ASSERT( pColTab, "Keine Farbtabelle vorhanden!" );
205 else
207 DBG_ERROR("sd::SdTPAction::SetView(), no docshell or viewshell?");
211 // -----------------------------------------------------------------------
213 void SdTPAction::Construct()
215 // OLE-Actionlistbox auffuellen
216 SdrOle2Obj* pOleObj = NULL;
217 SdrGrafObj* pGrafObj = NULL;
218 BOOL bOLEAction = FALSE;
220 if ( mpView->AreObjectsMarked() )
222 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
223 SdrObject* pObj;
225 if (rMarkList.GetMarkCount() == 1)
227 SdrMark* pMark = rMarkList.GetMark(0);
228 pObj = pMark->GetMarkedSdrObj();
230 UINT32 nInv = pObj->GetObjInventor();
231 UINT16 nSdrObjKind = pObj->GetObjIdentifier();
233 if (nInv == SdrInventor && nSdrObjKind == OBJ_OLE2)
235 pOleObj = (SdrOle2Obj*) pObj;
237 else if (nInv == SdrInventor && nSdrObjKind == OBJ_GRAF)
239 pGrafObj = (SdrGrafObj*) pObj;
241 // // VCXControl ?
242 // else if( pObj->IsA( TYPE( VCSbxDrawObject ) ) )
243 // {
244 // bDisableAll = TRUE;
245 // }
248 if( pGrafObj )
250 bOLEAction = TRUE;
252 aVerbVector.push_back( 0 );
253 aLbOLEAction.InsertEntry( MnemonicGenerator::EraseAllMnemonicChars( String( SdResId( STR_EDIT_OBJ ) ) ) );
255 else if( pOleObj )
257 uno::Reference < embed::XEmbeddedObject > xObj = pOleObj->GetObjRef();
258 if ( xObj.is() )
260 bOLEAction = TRUE;
261 uno::Sequence < embed::VerbDescriptor > aVerbs;
264 aVerbs = xObj->getSupportedVerbs();
266 catch ( embed::NeedsRunningStateException& )
268 xObj->changeState( embed::EmbedStates::RUNNING );
269 aVerbs = xObj->getSupportedVerbs();
272 for( sal_Int32 i=0; i<aVerbs.getLength(); i++ )
274 embed::VerbDescriptor aVerb = aVerbs[i];
275 if( aVerb.VerbAttributes & embed::VerbAttributes::MS_VERBATTR_ONCONTAINERMENU )
277 String aTmp( aVerb.VerbName );
278 aVerbVector.push_back( aVerb.VerbID );
279 aLbOLEAction.InsertEntry( MnemonicGenerator::EraseAllMnemonicChars( aTmp ) );
285 pCurrentActions = new List;
286 pCurrentActions->Insert((void*)(ULONG)presentation::ClickAction_NONE, LIST_APPEND);
287 pCurrentActions->Insert((void*)(ULONG)presentation::ClickAction_PREVPAGE, LIST_APPEND);
288 pCurrentActions->Insert((void*)(ULONG)presentation::ClickAction_NEXTPAGE, LIST_APPEND);
289 pCurrentActions->Insert((void*)(ULONG)presentation::ClickAction_FIRSTPAGE, LIST_APPEND);
290 pCurrentActions->Insert((void*)(ULONG)presentation::ClickAction_LASTPAGE, LIST_APPEND);
291 pCurrentActions->Insert((void*)(ULONG)presentation::ClickAction_BOOKMARK, LIST_APPEND);
292 pCurrentActions->Insert((void*)(ULONG)presentation::ClickAction_DOCUMENT, LIST_APPEND);
293 pCurrentActions->Insert((void*)(ULONG)presentation::ClickAction_SOUND, LIST_APPEND);
294 if( bOLEAction && aLbOLEAction.GetEntryCount() )
295 pCurrentActions->Insert((void*)(ULONG)presentation::ClickAction_VERB, LIST_APPEND );
296 pCurrentActions->Insert((void*)(ULONG)presentation::ClickAction_PROGRAM, LIST_APPEND);
297 pCurrentActions->Insert((void*)(ULONG)presentation::ClickAction_MACRO, LIST_APPEND);
298 pCurrentActions->Insert((void*)(ULONG)presentation::ClickAction_STOPPRESENTATION, LIST_APPEND);
300 // Action-Listbox fuellen
301 for (ULONG nAction = 0; nAction < pCurrentActions->Count(); nAction++)
303 USHORT nRId = GetClickActionSdResId((presentation::ClickAction)(ULONG)pCurrentActions->GetObject(nAction));
304 aLbAction.InsertEntry( String( SdResId( nRId ) ) );
309 // -----------------------------------------------------------------------
311 BOOL SdTPAction::FillItemSet( SfxItemSet& rAttrs )
313 BOOL bModified = FALSE;
314 presentation::ClickAction eCA = presentation::ClickAction_NONE;
316 if( aLbAction.GetSelectEntryCount() )
317 eCA = GetActualClickAction();
319 if( aLbAction.GetSavedValue() != aLbAction.GetSelectEntryPos() )
321 rAttrs.Put( SfxAllEnumItem( ATTR_ACTION, (USHORT)eCA ) );
322 bModified = TRUE;
324 else
325 rAttrs.InvalidateItem( ATTR_ACTION );
327 String aFileName = GetEditText( TRUE );
328 if( aFileName.Len() == 0 )
329 rAttrs.InvalidateItem( ATTR_ACTION_FILENAME );
330 else
332 if( mpDoc && mpDoc->GetDocSh() && mpDoc->GetDocSh()->GetMedium() )
334 String aBaseURL = mpDoc->GetDocSh()->GetMedium()->GetBaseURL();
335 if( eCA == presentation::ClickAction_SOUND ||
336 eCA == presentation::ClickAction_DOCUMENT ||
337 eCA == presentation::ClickAction_PROGRAM )
338 aFileName = ::URIHelper::SmartRel2Abs( INetURLObject(aBaseURL), aFileName, URIHelper::GetMaybeFileHdl(), true, false,
339 INetURLObject::WAS_ENCODED,
340 INetURLObject::DECODE_UNAMBIGUOUS );
342 rAttrs.Put( SfxStringItem( ATTR_ACTION_FILENAME, aFileName ) );
343 bModified = TRUE;
345 else
347 DBG_ERROR("sd::SdTPAction::FillItemSet(), I need a medium!");
351 return( bModified );
354 //------------------------------------------------------------------------
356 void SdTPAction::Reset( const SfxItemSet& rAttrs )
358 presentation::ClickAction eCA = presentation::ClickAction_NONE;
359 String aFileName;
361 // aLbAction
362 if( rAttrs.GetItemState( ATTR_ACTION ) != SFX_ITEM_DONTCARE )
364 eCA = (presentation::ClickAction) ( ( const SfxAllEnumItem& ) rAttrs.
365 Get( ATTR_ACTION ) ).GetValue();
366 SetActualClickAction( eCA );
368 else
369 aLbAction.SetNoSelection();
371 // aEdtSound
372 if( rAttrs.GetItemState( ATTR_ACTION_FILENAME ) != SFX_ITEM_DONTCARE )
374 aFileName = ( ( const SfxStringItem& ) rAttrs.Get( ATTR_ACTION_FILENAME ) ).GetValue();
375 SetEditText( aFileName );
378 switch( eCA )
380 case presentation::ClickAction_BOOKMARK:
382 if( !aLbTree.SelectEntry( aFileName ) )
383 aLbTree.SelectAll( FALSE );
385 break;
387 case presentation::ClickAction_DOCUMENT:
389 if( aFileName.GetTokenCount( DOCUMENT_TOKEN ) == 2 )
390 aLbTreeDocument.SelectEntry( aFileName.GetToken( 1, DOCUMENT_TOKEN ) );
392 break;
394 default:
395 break;
397 ClickActionHdl( this );
399 aLbAction.SaveValue();
400 aEdtSound.SaveValue();
403 // -----------------------------------------------------------------------
405 void SdTPAction::ActivatePage( const SfxItemSet& )
409 // -----------------------------------------------------------------------
411 int SdTPAction::DeactivatePage( SfxItemSet* pPageSet )
413 if( pPageSet )
414 FillItemSet( *pPageSet );
416 return( LEAVE_PAGE );
419 // -----------------------------------------------------------------------
421 SfxTabPage* SdTPAction::Create( Window* pWindow,
422 const SfxItemSet& rAttrs )
424 return( new SdTPAction( pWindow, rAttrs ) );
427 //------------------------------------------------------------------------
429 USHORT* SdTPAction::GetRanges()
431 return( pActionRanges );
434 //------------------------------------------------------------------------
436 void SdTPAction::UpdateTree()
438 if( !bTreeUpdated && mpDoc && mpDoc->GetDocSh() && mpDoc->GetDocSh()->GetMedium() )
440 //aLbTree.Clear();
441 aLbTree.Fill( mpDoc, TRUE, mpDoc->GetDocSh()->GetMedium()->GetName() );
442 bTreeUpdated = TRUE;
446 //------------------------------------------------------------------------
448 void SdTPAction::OpenFileDialog()
450 // Soundpreview nur fuer Interaktionen mit Sound
451 presentation::ClickAction eCA = GetActualClickAction();
452 BOOL bSound = ( eCA == presentation::ClickAction_SOUND );
453 BOOL bPage = ( eCA == presentation::ClickAction_BOOKMARK );
454 BOOL bDocument = ( eCA == presentation::ClickAction_DOCUMENT ||
455 eCA == presentation::ClickAction_PROGRAM );
456 BOOL bMacro = ( eCA == presentation::ClickAction_MACRO );
458 if( bPage )
460 // Es wird in der TreeLB nach dem eingegebenen Objekt gesucht
461 aLbTree.SelectEntry( GetEditText() );
463 else
465 String aFile( GetEditText() );
467 if (bSound)
469 SdOpenSoundFileDialog aFileDialog;
471 if( !aFile.Len() )
472 aFile = SvtPathOptions().GetGraphicPath();
474 aFileDialog.SetPath( aFile );
476 if( aFileDialog.Execute() == ERRCODE_NONE )
478 aFile = aFileDialog.GetPath();
479 SetEditText( aFile );
482 else if (bMacro)
484 Window* pOldWin = Application::GetDefDialogParent();
485 Application::SetDefDialogParent( this );
487 // choose macro dialog
488 ::rtl::OUString aScriptURL = SfxApplication::ChooseScript();
490 if ( aScriptURL.getLength() != 0 )
492 SetEditText( aScriptURL );
495 Application::SetDefDialogParent( pOldWin );
497 else
499 sfx2::FileDialogHelper aFileDialog(WB_OPEN | WB_3DLOOK | WB_STDMODAL );
501 if (bDocument && !aFile.Len())
502 aFile = SvtPathOptions().GetWorkPath();
504 aFileDialog.SetDisplayDirectory( aFile );
506 // The following is a fix for #1008001# and a workarround for
507 // #i4306#: The addition of the implicitely existing "all files"
508 // filter makes the (Windows system) open file dialog follow
509 // links on the desktop to directories.
510 aFileDialog.AddFilter (
511 String (SdResId (STR_SFX_FILTERNAME_ALL)),
512 String (RTL_CONSTASCII_USTRINGPARAM("*.*")));
515 if( aFileDialog.Execute() == ERRCODE_NONE )
517 aFile = aFileDialog.GetPath();
518 SetEditText( aFile );
520 if( bDocument )
521 CheckFileHdl( NULL );
526 //------------------------------------------------------------------------
528 IMPL_LINK( SdTPAction, ClickSearchHdl, void *, EMPTYARG )
530 OpenFileDialog();
532 return( 0L );
535 //------------------------------------------------------------------------
537 IMPL_LINK( SdTPAction, ClickActionHdl, void *, EMPTYARG )
539 presentation::ClickAction eCA = GetActualClickAction();
541 // hide controls we don't need
542 switch( eCA )
544 case presentation::ClickAction_NONE:
545 case presentation::ClickAction_INVISIBLE:
546 case presentation::ClickAction_PREVPAGE:
547 case presentation::ClickAction_NEXTPAGE:
548 case presentation::ClickAction_FIRSTPAGE:
549 case presentation::ClickAction_LASTPAGE:
550 case presentation::ClickAction_STOPPRESENTATION:
551 default:
552 aFtTree.Hide();
553 aLbTree.Hide();
554 aLbTreeDocument.Hide();
555 aLbOLEAction.Hide();
557 aFlSeparator.Hide();
558 aEdtSound.Hide();
559 aEdtBookmark.Hide();
560 aEdtDocument.Hide();
561 aEdtProgram.Hide();
562 aEdtMacro.Hide();
563 aBtnSearch.Hide();
564 aBtnSeek.Hide();
565 break;
567 case presentation::ClickAction_SOUND:
568 case presentation::ClickAction_PROGRAM:
569 case presentation::ClickAction_MACRO:
570 aFtTree.Hide();
571 aLbTree.Hide();
572 aLbTreeDocument.Hide();
573 aLbOLEAction.Hide();
575 aEdtDocument.Hide();
577 if( eCA == presentation::ClickAction_MACRO )
579 aEdtSound.Hide();
580 aEdtProgram.Hide();
582 else if( eCA == presentation::ClickAction_PROGRAM )
584 aEdtSound.Hide();
585 aEdtMacro.Hide();
587 else if( eCA == presentation::ClickAction_SOUND )
589 aEdtProgram.Hide();
590 aEdtMacro.Hide();
593 aBtnSeek.Hide();
594 break;
597 case presentation::ClickAction_DOCUMENT:
598 aLbTree.Hide();
599 aLbOLEAction.Hide();
601 aEdtSound.Hide();
602 aEdtProgram.Hide();
603 aEdtMacro.Hide();
604 aEdtBookmark.Hide();
605 aBtnSeek.Hide();
606 break;
608 case presentation::ClickAction_BOOKMARK:
609 aLbTreeDocument.Hide();
610 aLbOLEAction.Hide();
611 aEdtSound.Hide();
612 aEdtDocument.Hide();
613 aEdtProgram.Hide();
614 aEdtMacro.Hide();
615 aBtnSearch.Hide();
616 break;
618 case presentation::ClickAction_VERB:
619 aLbTree.Hide();
620 aEdtDocument.Hide();
621 aEdtProgram.Hide();
622 aEdtBookmark.Hide();
623 aEdtMacro.Hide();
624 aBtnSearch.Hide();
625 aFlSeparator.Hide();
626 aEdtSound.Hide();
627 aBtnSeek.Hide();
628 break;
631 // show controls we do need
632 switch( eCA )
634 case presentation::ClickAction_NONE:
635 case presentation::ClickAction_INVISIBLE:
636 case presentation::ClickAction_PREVPAGE:
637 case presentation::ClickAction_NEXTPAGE:
638 case presentation::ClickAction_FIRSTPAGE:
639 case presentation::ClickAction_LASTPAGE:
640 case presentation::ClickAction_STOPPRESENTATION:
641 // none
642 break;
644 case presentation::ClickAction_SOUND:
645 aFlSeparator.Show();
646 aEdtSound.Show();
647 aEdtSound.Enable();
648 aBtnSearch.Show();
649 aBtnSearch.Enable();
650 aFlSeparator.SetText( String( SdResId( STR_EFFECTDLG_SOUND ) ) );
651 break;
653 case presentation::ClickAction_PROGRAM:
654 case presentation::ClickAction_MACRO:
655 aFlSeparator.Show();
656 aBtnSearch.Show();
657 aBtnSearch.Enable();
658 if( eCA == presentation::ClickAction_MACRO )
660 aEdtMacro.Show();
661 aFlSeparator.SetText( String( SdResId( STR_EFFECTDLG_MACRO ) ) );
663 else
665 aEdtProgram.Show();
666 aFlSeparator.SetText( String( SdResId( STR_EFFECTDLG_PROGRAM ) ) );
668 break;
670 case presentation::ClickAction_DOCUMENT:
671 aFtTree.Show();
672 aLbTreeDocument.Show();
674 aFlSeparator.Show();
675 aEdtDocument.Show();
676 aBtnSearch.Show();
677 aBtnSearch.Enable();
679 aFtTree.SetText( String( SdResId( STR_EFFECTDLG_JUMP ) ) );
680 aFlSeparator.SetText( String( SdResId( STR_EFFECTDLG_DOCUMENT ) ) );
682 CheckFileHdl( NULL );
683 break;
685 case presentation::ClickAction_VERB:
686 aFtTree.Show();
687 aLbOLEAction.Show();
689 aFtTree.SetText( String( SdResId( STR_EFFECTDLG_ACTION ) ) );
690 break;
692 case presentation::ClickAction_BOOKMARK:
693 UpdateTree();
695 aFtTree.Show();
696 aLbTree.Show();
698 aFlSeparator.Show();
699 aEdtBookmark.Show();
700 aBtnSeek.Show();
702 aFtTree.SetText( String( SdResId( STR_EFFECTDLG_JUMP ) ) );
703 aFlSeparator.SetText( String( SdResId( STR_EFFECTDLG_PAGE_OBJECT ) ) );
704 break;
705 default:
706 break;
709 return( 0L );
712 //------------------------------------------------------------------------
714 IMPL_LINK( SdTPAction, SelectTreeHdl, void *, EMPTYARG )
716 aEdtBookmark.SetText( aLbTree.GetSelectEntry() );
717 return( 0L );
720 //------------------------------------------------------------------------
722 IMPL_LINK( SdTPAction, CheckFileHdl, void *, EMPTYARG )
724 String aFile( GetEditText() );
726 if( aFile != aLastFile )
728 // Ueberpruefen, ob es eine gueltige Draw-Datei ist
729 SfxMedium aMedium( aFile,
730 STREAM_READ | STREAM_NOCREATE,
731 TRUE ); // Download
733 if( aMedium.IsStorage() )
735 WaitObject aWait( GetParent()->GetParent() );
737 // ist es eine Draw-Datei?
738 // mit READ oeffnen, sonst schreiben die Storages evtl. in die Datei!
739 uno::Reference < embed::XStorage > xStorage = aMedium.GetStorage();
740 DBG_ASSERT( xStorage.is(), "Kein Storage!" );
742 uno::Reference < container::XNameAccess > xAccess( xStorage, uno::UNO_QUERY );
743 if( xAccess.is() &&
744 ( xAccess->hasByName( pStarDrawXMLContent ) ||
745 xAccess->hasByName( pStarDrawOldXMLContent ) ) )
747 SdDrawDocument* pBookmarkDoc = mpDoc->OpenBookmarkDoc( aFile );
748 if( pBookmarkDoc )
750 aLastFile = aFile;
752 aLbTreeDocument.Clear();
753 aLbTreeDocument.Fill( pBookmarkDoc, TRUE, aFile );
754 mpDoc->CloseBookmarkDoc();
755 aLbTreeDocument.Show();
757 else
758 aLbTreeDocument.Hide();
760 else
761 aLbTreeDocument.Hide();
764 else
765 aLbTreeDocument.Hide();
768 return( 0L );
771 //------------------------------------------------------------------------
773 presentation::ClickAction SdTPAction::GetActualClickAction()
775 presentation::ClickAction eCA = presentation::ClickAction_NONE;
776 USHORT nPos = aLbAction.GetSelectEntryPos();
778 if (nPos != LISTBOX_ENTRY_NOTFOUND)
779 eCA = (presentation::ClickAction)(ULONG)pCurrentActions->GetObject((ULONG)nPos);
780 return( eCA );
783 //------------------------------------------------------------------------
785 void SdTPAction::SetActualClickAction( presentation::ClickAction eCA )
787 USHORT nPos = (USHORT)pCurrentActions->GetPos((void*)(ULONG)eCA);
788 DBG_ASSERT(nPos != 0xffff, "unbekannte Interaktion");
789 aLbAction.SelectEntryPos(nPos);
792 //------------------------------------------------------------------------
794 void SdTPAction::SetEditText( String const & rStr )
796 presentation::ClickAction eCA = GetActualClickAction();
797 String aText(rStr);
799 // possibly convert URI back to system path
800 switch( eCA )
802 case presentation::ClickAction_DOCUMENT:
803 if( rStr.GetTokenCount( DOCUMENT_TOKEN ) == 2 )
804 aText = rStr.GetToken( 0, DOCUMENT_TOKEN );
806 // fallthrough inteded
807 case presentation::ClickAction_SOUND:
808 case presentation::ClickAction_PROGRAM:
810 INetURLObject aURL( aText );
812 // try to convert to system path
813 String aTmpStr(aURL.getFSysPath(INetURLObject::FSYS_DETECT));
815 if( aTmpStr.Len() )
816 aText = aTmpStr; // was a system path
818 break;
819 default:
820 break;
823 // set the string to the corresponding control
824 switch( eCA )
826 case presentation::ClickAction_SOUND:
827 aEdtSound.SetText(aText );
828 break;
829 case presentation::ClickAction_VERB:
831 ::std::vector< long >::iterator aFound( ::std::find( aVerbVector.begin(), aVerbVector.end(), rStr.ToInt32() ) );
832 if( aFound != aVerbVector.end() )
833 aLbOLEAction.SelectEntryPos( static_cast< short >( aFound - aVerbVector.begin() ) );
835 break;
836 case presentation::ClickAction_PROGRAM:
837 aEdtProgram.SetText( aText );
838 break;
839 case presentation::ClickAction_MACRO:
841 aEdtMacro.SetText( aText );
843 break;
844 case presentation::ClickAction_DOCUMENT:
845 aEdtDocument.SetText( aText );
846 break;
847 case presentation::ClickAction_BOOKMARK:
848 aEdtBookmark.SetText( aText );
849 break;
850 default:
851 break;
855 String SdTPAction::GetMacroName( const String& rMacroPath )
857 String result = rMacroPath;
859 // try to get name by parsing the macro path
860 // using the new URI parsing services
862 Reference< XMultiServiceFactory > xSMgr =
863 ::comphelper::getProcessServiceFactory();
865 Reference< com::sun::star::uri::XUriReferenceFactory >
866 xFactory( xSMgr->createInstance(
867 ::rtl::OUString::createFromAscii(
868 "com.sun.star.uri.UriReferenceFactory" ) ), UNO_QUERY );
870 if ( xFactory.is() )
872 Reference< com::sun::star::uri::XVndSunStarScriptUrl >
873 xUrl( xFactory->parse( rMacroPath ), UNO_QUERY );
875 if ( xUrl.is() )
877 result = xUrl->getName();
881 return result;
884 //------------------------------------------------------------------------
886 String SdTPAction::GetEditText( BOOL bFullDocDestination )
888 String aStr;
889 presentation::ClickAction eCA = GetActualClickAction();
891 switch( eCA )
893 case presentation::ClickAction_SOUND:
894 aStr = aEdtSound.GetText();
895 break;
896 case presentation::ClickAction_VERB:
898 const USHORT nPos = aLbOLEAction.GetSelectEntryPos();
899 if( nPos < aVerbVector.size() )
900 aStr = UniString::CreateFromInt32( aVerbVector[ nPos ] );
901 return aStr;
903 case presentation::ClickAction_DOCUMENT:
904 aStr = aEdtDocument.GetText();
905 break;
907 case presentation::ClickAction_PROGRAM:
908 aStr = aEdtProgram.GetText();
909 break;
911 case presentation::ClickAction_MACRO:
913 return aEdtMacro.GetText();
916 case presentation::ClickAction_BOOKMARK:
917 return( aEdtBookmark.GetText() );
919 default:
920 break;
923 // validate file URI
924 INetURLObject aURL( aStr );
925 String aBaseURL;
926 if( mpDoc && mpDoc->GetDocSh() && mpDoc->GetDocSh()->GetMedium() )
927 aBaseURL = mpDoc->GetDocSh()->GetMedium()->GetBaseURL();
929 if( aStr.Len() && aURL.GetProtocol() == INET_PROT_NOT_VALID )
930 aURL = INetURLObject( ::URIHelper::SmartRel2Abs( INetURLObject(aBaseURL), aStr, URIHelper::GetMaybeFileHdl(), true, false ) );
932 // get adjusted file name
933 aStr = aURL.GetMainURL( INetURLObject::NO_DECODE );
935 if( bFullDocDestination &&
936 eCA == presentation::ClickAction_DOCUMENT &&
937 aLbTreeDocument.Control::IsVisible() &&
938 aLbTreeDocument.GetSelectionCount() > 0 )
940 String aTmpStr( aLbTreeDocument.GetSelectEntry() );
941 if( aTmpStr.Len() )
943 aStr.Append( DOCUMENT_TOKEN );
944 aStr.Append( aTmpStr );
948 return( aStr );
951 //------------------------------------------------------------------------
953 USHORT SdTPAction::GetClickActionSdResId( presentation::ClickAction eCA )
955 switch( eCA )
957 case presentation::ClickAction_NONE: return STR_CLICK_ACTION_NONE;
958 case presentation::ClickAction_PREVPAGE: return STR_CLICK_ACTION_PREVPAGE;
959 case presentation::ClickAction_NEXTPAGE: return STR_CLICK_ACTION_NEXTPAGE;
960 case presentation::ClickAction_FIRSTPAGE: return STR_CLICK_ACTION_FIRSTPAGE;
961 case presentation::ClickAction_LASTPAGE: return STR_CLICK_ACTION_LASTPAGE;
962 case presentation::ClickAction_BOOKMARK: return STR_CLICK_ACTION_BOOKMARK;
963 case presentation::ClickAction_DOCUMENT: return STR_CLICK_ACTION_DOCUMENT;
964 case presentation::ClickAction_PROGRAM: return STR_CLICK_ACTION_PROGRAM;
965 case presentation::ClickAction_MACRO: return STR_CLICK_ACTION_MACRO;
966 case presentation::ClickAction_SOUND: return STR_CLICK_ACTION_SOUND;
967 case presentation::ClickAction_VERB: return STR_CLICK_ACTION_VERB;
968 case presentation::ClickAction_STOPPRESENTATION: return STR_CLICK_ACTION_STOPPRESENTATION;
969 default: DBG_ERROR( "Keine StringResource fuer ClickAction vorhanden!" );
971 return( 0 );