1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tpaction.cxx,v $
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
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>
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>
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>
75 #include "sdresid.hxx"
76 #include "tpaction.hxx"
77 #include "tpaction.hrc"
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"
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
,
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
),
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() );
130 /*************************************************************************
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
),
157 bTreeUpdated ( FALSE
)
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
) );
176 ClickActionHdl( this );
179 // -----------------------------------------------------------------------
181 SdTPAction::~SdTPAction()
183 delete pCurrentActions
;
186 // -----------------------------------------------------------------------
188 void SdTPAction::SetView( const ::sd::View
* 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!" );
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();
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
;
242 // else if( pObj->IsA( TYPE( VCSbxDrawObject ) ) )
244 // bDisableAll = TRUE;
252 aVerbVector
.push_back( 0 );
253 aLbOLEAction
.InsertEntry( MnemonicGenerator::EraseAllMnemonicChars( String( SdResId( STR_EDIT_OBJ
) ) ) );
257 uno::Reference
< embed::XEmbeddedObject
> xObj
= pOleObj
->GetObjRef();
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
) );
325 rAttrs
.InvalidateItem( ATTR_ACTION
);
327 String aFileName
= GetEditText( TRUE
);
328 if( aFileName
.Len() == 0 )
329 rAttrs
.InvalidateItem( ATTR_ACTION_FILENAME
);
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
) );
347 DBG_ERROR("sd::SdTPAction::FillItemSet(), I need a medium!");
354 //------------------------------------------------------------------------
356 void SdTPAction::Reset( const SfxItemSet
& rAttrs
)
358 presentation::ClickAction eCA
= presentation::ClickAction_NONE
;
362 if( rAttrs
.GetItemState( ATTR_ACTION
) != SFX_ITEM_DONTCARE
)
364 eCA
= (presentation::ClickAction
) ( ( const SfxAllEnumItem
& ) rAttrs
.
365 Get( ATTR_ACTION
) ).GetValue();
366 SetActualClickAction( eCA
);
369 aLbAction
.SetNoSelection();
372 if( rAttrs
.GetItemState( ATTR_ACTION_FILENAME
) != SFX_ITEM_DONTCARE
)
374 aFileName
= ( ( const SfxStringItem
& ) rAttrs
.Get( ATTR_ACTION_FILENAME
) ).GetValue();
375 SetEditText( aFileName
);
380 case presentation::ClickAction_BOOKMARK
:
382 if( !aLbTree
.SelectEntry( aFileName
) )
383 aLbTree
.SelectAll( FALSE
);
387 case presentation::ClickAction_DOCUMENT
:
389 if( aFileName
.GetTokenCount( DOCUMENT_TOKEN
) == 2 )
390 aLbTreeDocument
.SelectEntry( aFileName
.GetToken( 1, DOCUMENT_TOKEN
) );
397 ClickActionHdl( this );
399 aLbAction
.SaveValue();
400 aEdtSound
.SaveValue();
403 // -----------------------------------------------------------------------
405 void SdTPAction::ActivatePage( const SfxItemSet
& )
409 // -----------------------------------------------------------------------
411 int SdTPAction::DeactivatePage( SfxItemSet
* 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() )
441 aLbTree
.Fill( mpDoc
, TRUE
, mpDoc
->GetDocSh()->GetMedium()->GetName() );
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
);
460 // Es wird in der TreeLB nach dem eingegebenen Objekt gesucht
461 aLbTree
.SelectEntry( GetEditText() );
465 String
aFile( GetEditText() );
469 SdOpenSoundFileDialog aFileDialog
;
472 aFile
= SvtPathOptions().GetGraphicPath();
474 aFileDialog
.SetPath( aFile
);
476 if( aFileDialog
.Execute() == ERRCODE_NONE
)
478 aFile
= aFileDialog
.GetPath();
479 SetEditText( aFile
);
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
);
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
);
521 CheckFileHdl( NULL
);
526 //------------------------------------------------------------------------
528 IMPL_LINK( SdTPAction
, ClickSearchHdl
, void *, EMPTYARG
)
535 //------------------------------------------------------------------------
537 IMPL_LINK( SdTPAction
, ClickActionHdl
, void *, EMPTYARG
)
539 presentation::ClickAction eCA
= GetActualClickAction();
541 // hide controls we don't need
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
:
554 aLbTreeDocument
.Hide();
567 case presentation::ClickAction_SOUND
:
568 case presentation::ClickAction_PROGRAM
:
569 case presentation::ClickAction_MACRO
:
572 aLbTreeDocument
.Hide();
577 if( eCA
== presentation::ClickAction_MACRO
)
582 else if( eCA
== presentation::ClickAction_PROGRAM
)
587 else if( eCA
== presentation::ClickAction_SOUND
)
597 case presentation::ClickAction_DOCUMENT
:
608 case presentation::ClickAction_BOOKMARK
:
609 aLbTreeDocument
.Hide();
618 case presentation::ClickAction_VERB
:
631 // show controls we do need
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
:
644 case presentation::ClickAction_SOUND
:
650 aFlSeparator
.SetText( String( SdResId( STR_EFFECTDLG_SOUND
) ) );
653 case presentation::ClickAction_PROGRAM
:
654 case presentation::ClickAction_MACRO
:
658 if( eCA
== presentation::ClickAction_MACRO
)
661 aFlSeparator
.SetText( String( SdResId( STR_EFFECTDLG_MACRO
) ) );
666 aFlSeparator
.SetText( String( SdResId( STR_EFFECTDLG_PROGRAM
) ) );
670 case presentation::ClickAction_DOCUMENT
:
672 aLbTreeDocument
.Show();
679 aFtTree
.SetText( String( SdResId( STR_EFFECTDLG_JUMP
) ) );
680 aFlSeparator
.SetText( String( SdResId( STR_EFFECTDLG_DOCUMENT
) ) );
682 CheckFileHdl( NULL
);
685 case presentation::ClickAction_VERB
:
689 aFtTree
.SetText( String( SdResId( STR_EFFECTDLG_ACTION
) ) );
692 case presentation::ClickAction_BOOKMARK
:
702 aFtTree
.SetText( String( SdResId( STR_EFFECTDLG_JUMP
) ) );
703 aFlSeparator
.SetText( String( SdResId( STR_EFFECTDLG_PAGE_OBJECT
) ) );
712 //------------------------------------------------------------------------
714 IMPL_LINK( SdTPAction
, SelectTreeHdl
, void *, EMPTYARG
)
716 aEdtBookmark
.SetText( aLbTree
.GetSelectEntry() );
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
,
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
);
744 ( xAccess
->hasByName( pStarDrawXMLContent
) ||
745 xAccess
->hasByName( pStarDrawOldXMLContent
) ) )
747 SdDrawDocument
* pBookmarkDoc
= mpDoc
->OpenBookmarkDoc( aFile
);
752 aLbTreeDocument
.Clear();
753 aLbTreeDocument
.Fill( pBookmarkDoc
, TRUE
, aFile
);
754 mpDoc
->CloseBookmarkDoc();
755 aLbTreeDocument
.Show();
758 aLbTreeDocument
.Hide();
761 aLbTreeDocument
.Hide();
765 aLbTreeDocument
.Hide();
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
);
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();
799 // possibly convert URI back to system path
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
));
816 aText
= aTmpStr
; // was a system path
823 // set the string to the corresponding control
826 case presentation::ClickAction_SOUND
:
827 aEdtSound
.SetText(aText
);
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() ) );
836 case presentation::ClickAction_PROGRAM
:
837 aEdtProgram
.SetText( aText
);
839 case presentation::ClickAction_MACRO
:
841 aEdtMacro
.SetText( aText
);
844 case presentation::ClickAction_DOCUMENT
:
845 aEdtDocument
.SetText( aText
);
847 case presentation::ClickAction_BOOKMARK
:
848 aEdtBookmark
.SetText( aText
);
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
);
872 Reference
< com::sun::star::uri::XVndSunStarScriptUrl
>
873 xUrl( xFactory
->parse( rMacroPath
), UNO_QUERY
);
877 result
= xUrl
->getName();
884 //------------------------------------------------------------------------
886 String
SdTPAction::GetEditText( BOOL bFullDocDestination
)
889 presentation::ClickAction eCA
= GetActualClickAction();
893 case presentation::ClickAction_SOUND
:
894 aStr
= aEdtSound
.GetText();
896 case presentation::ClickAction_VERB
:
898 const USHORT nPos
= aLbOLEAction
.GetSelectEntryPos();
899 if( nPos
< aVerbVector
.size() )
900 aStr
= UniString::CreateFromInt32( aVerbVector
[ nPos
] );
903 case presentation::ClickAction_DOCUMENT
:
904 aStr
= aEdtDocument
.GetText();
907 case presentation::ClickAction_PROGRAM
:
908 aStr
= aEdtProgram
.GetText();
911 case presentation::ClickAction_MACRO
:
913 return aEdtMacro
.GetText();
916 case presentation::ClickAction_BOOKMARK
:
917 return( aEdtBookmark
.GetText() );
924 INetURLObject
aURL( aStr
);
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() );
943 aStr
.Append( DOCUMENT_TOKEN
);
944 aStr
.Append( aTmpStr
);
951 //------------------------------------------------------------------------
953 USHORT
SdTPAction::GetClickActionSdResId( presentation::ClickAction 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!" );