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