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