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

Generated by: LCOV version 1.10