LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/dlg - tpaction.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 407 0.0 %
Date: 2013-07-09 Functions: 0 28 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10