LCOV - code coverage report
Current view: top level - cui/source/dialogs - hltpbase.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 256 0.0 %
Date: 2014-04-11 Functions: 0 41 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 <sfx2/frame.hxx>
      21             : #include <sfx2/viewfrm.hxx>
      22             : #include <sot/formats.hxx>
      23             : #include <sfx2/sfxsids.hrc>
      24             : #include <svl/macitem.hxx>
      25             : #include <ucbhelper/content.hxx>
      26             : #include <unotools/localfilehelper.hxx>
      27             : #include "hyperdlg.hrc"
      28             : #include "cuihyperdlg.hxx"
      29             : #include "hltpbase.hxx"
      30             : #include "macroass.hxx"
      31             : #include <svx/svxdlg.hxx>
      32             : #include <cuires.hrc>
      33             : #include <boost/scoped_ptr.hpp>
      34             : 
      35             : using namespace ::ucbhelper;
      36             : 
      37             : //# ComboBox-Control, which is filled with all current framenames        #
      38             : 
      39             : /*************************************************************************
      40             : |*
      41             : |* Contructor / Destructor
      42             : |*
      43             : |************************************************************************/
      44             : 
      45           0 : SvxFramesComboBox::SvxFramesComboBox ( Window* pParent, const ResId& rResId,
      46             :                                         SfxDispatcher* pDispatch )
      47           0 : :   ComboBox (pParent, rResId)
      48             : {
      49           0 :     SfxViewFrame* pViewFrame = pDispatch ? pDispatch->GetFrame() : 0;
      50           0 :     SfxFrame* pFrame = pViewFrame ? &pViewFrame->GetTopFrame() : 0;
      51           0 :     if ( pFrame )
      52             :     {
      53           0 :         boost::scoped_ptr<TargetList> pList(new TargetList);
      54           0 :         pFrame->GetTargetList(*pList);
      55           0 :         if( !pList->empty() )
      56             :         {
      57           0 :             size_t nCount = pList->size();
      58             :             size_t i;
      59           0 :             for ( i = 0; i < nCount; i++ )
      60             :             {
      61           0 :                 InsertEntry( pList->at( i ) );
      62             :             }
      63           0 :         }
      64             :     }
      65           0 : }
      66             : 
      67           0 : SvxFramesComboBox::~SvxFramesComboBox ()
      68             : {
      69           0 : }
      70             : 
      71             : //# ComboBox-Control for URL's with History and Autocompletion           #
      72             : 
      73           0 : SvxHyperURLBox::SvxHyperURLBox( Window* pParent, INetProtocol eSmart )
      74             : : SvtURLBox         ( pParent, eSmart ),
      75           0 :   DropTargetHelper  ( this )
      76             : {
      77           0 : }
      78             : 
      79           0 : sal_Int8 SvxHyperURLBox::AcceptDrop( const AcceptDropEvent& /* rEvt */ )
      80             : {
      81           0 :     return( IsDropFormatSupported( FORMAT_STRING ) ? DND_ACTION_COPY : DND_ACTION_NONE );
      82             : }
      83             : 
      84           0 : sal_Int8 SvxHyperURLBox::ExecuteDrop( const ExecuteDropEvent& rEvt )
      85             : {
      86           0 :     TransferableDataHelper  aDataHelper( rEvt.maDropEvent.Transferable );
      87           0 :     OUString                aString;
      88           0 :     sal_Int8                nRet = DND_ACTION_NONE;
      89             : 
      90           0 :     if( aDataHelper.GetString( FORMAT_STRING, aString ) )
      91             :     {
      92           0 :         SetText( aString );
      93           0 :         nRet = DND_ACTION_COPY;
      94             :     }
      95             : 
      96           0 :     return nRet;
      97             : }
      98             : 
      99           0 : void SvxHyperURLBox::Select()
     100             : {
     101           0 :     SvtURLBox::Select();
     102           0 : }
     103           0 : void SvxHyperURLBox::Modify()
     104             : {
     105           0 :     SvtURLBox::Modify();
     106           0 : }
     107           0 : bool SvxHyperURLBox::Notify( NotifyEvent& rNEvt )
     108             : {
     109           0 :     return SvtURLBox::Notify( rNEvt );
     110             : }
     111           0 : bool SvxHyperURLBox::PreNotify( NotifyEvent& rNEvt )
     112             : {
     113           0 :     return SvtURLBox::PreNotify( rNEvt );
     114             : }
     115             : 
     116             : //# Hyperlink-Dialog: Tabpages-Baseclass                                 #
     117             : 
     118           0 : SvxHyperlinkTabPageBase::SvxHyperlinkTabPageBase ( Window *pParent,
     119             :                                                    const ResId &rResId,
     120             :                                                    const SfxItemSet& rItemSet )
     121             : :   IconChoicePage          ( pParent, rResId, rItemSet ),
     122             :     mpGrpMore               ( NULL ),
     123             :     mpFtFrame               ( NULL ),
     124             :     mpCbbFrame              ( NULL ),
     125             :     mpFtForm                ( NULL ),
     126             :     mpLbForm                ( NULL ),
     127             :     mpFtIndication          ( NULL ),
     128             :     mpEdIndication          ( NULL ),
     129             :     mpFtText                ( NULL ),
     130             :     mpEdText                ( NULL ),
     131             :     mpBtScript              ( NULL ),
     132             :     mbIsCloseDisabled       ( sal_False ),
     133             :     mpDialog                ( pParent ),
     134             :     mbStdControlsInit       ( sal_False ),
     135           0 :     aEmptyStr()
     136             : {
     137             :     // create bookmark-window
     138           0 :     mpMarkWnd = new SvxHlinkDlgMarkWnd ( this );
     139           0 : }
     140             : 
     141           0 : SvxHyperlinkTabPageBase::~SvxHyperlinkTabPageBase ()
     142             : {
     143           0 :     maTimer.Stop();
     144             : 
     145           0 :     if ( mbStdControlsInit )
     146             :     {
     147           0 :         delete mpGrpMore;
     148           0 :         delete mpFtFrame;
     149           0 :         delete mpCbbFrame;
     150           0 :         delete mpFtForm;
     151           0 :         delete mpLbForm;
     152           0 :         delete mpFtIndication;
     153           0 :         delete mpEdIndication;
     154           0 :         delete mpFtText;
     155           0 :         delete mpEdText ;
     156           0 :         delete mpBtScript;
     157             :     }
     158             : 
     159           0 :     delete mpMarkWnd;
     160           0 : }
     161             : 
     162           0 : void SvxHyperlinkTabPageBase::ActivatePage()
     163             : {
     164           0 :     TabPage::ActivatePage();
     165           0 : }
     166             : 
     167           0 : void SvxHyperlinkTabPageBase::DeactivatePage()
     168             : {
     169           0 :     TabPage::DeactivatePage();
     170           0 : }
     171             : 
     172           0 : sal_Bool SvxHyperlinkTabPageBase::QueryClose()
     173             : {
     174           0 :     return !mbIsCloseDisabled;
     175             : }
     176             : 
     177           0 : void SvxHyperlinkTabPageBase::InitStdControls ()
     178             : {
     179           0 :     if ( !mbStdControlsInit )
     180             :     {
     181           0 :         mpGrpMore     = new FixedLine           ( this, ResId (GRP_MORE, *m_pResMgr) );
     182           0 :         mpFtFrame     = new FixedText           ( this, ResId (FT_FRAME, *m_pResMgr) );
     183           0 :         mpCbbFrame    = new SvxFramesComboBox   ( this, ResId (CB_FRAME, *m_pResMgr), GetDispatcher() );
     184           0 :         mpFtForm      = new FixedText           ( this, ResId (FT_FORM, *m_pResMgr) );
     185           0 :         mpLbForm      = new ListBox             ( this, ResId (LB_FORM, *m_pResMgr) );
     186           0 :         mpFtIndication= new FixedText           ( this, ResId (FT_INDICATION, *m_pResMgr) );
     187           0 :         mpEdIndication= new Edit                ( this, ResId (ED_INDICATION, *m_pResMgr) );
     188           0 :         mpFtText      = new FixedText           ( this, ResId (FT_TEXT, *m_pResMgr) );
     189           0 :         mpEdText      = new Edit                ( this, ResId (ED_TEXT, *m_pResMgr) );
     190           0 :         mpBtScript    = new ImageButton         ( this, ResId (BTN_SCRIPT, *m_pResMgr) );
     191             : 
     192           0 :         mpBtScript->SetClickHdl ( LINK ( this, SvxHyperlinkTabPageBase, ClickScriptHdl_Impl ) );
     193           0 :         mpBtScript->EnableTextDisplay (false);
     194             : 
     195           0 :         mpBtScript->SetAccessibleRelationMemberOf( mpGrpMore );
     196           0 :         mpBtScript->SetAccessibleRelationLabeledBy( mpFtForm );
     197             :     }
     198             : 
     199           0 :     mbStdControlsInit = sal_True;
     200           0 : }
     201             : 
     202             : // Move Extra-Window
     203           0 : sal_Bool SvxHyperlinkTabPageBase::MoveToExtraWnd( Point aNewPos, sal_Bool bDisConnectDlg )
     204             : {
     205           0 :     sal_Bool bReturn =  mpMarkWnd->MoveTo ( aNewPos );
     206             : 
     207           0 :     if( bDisConnectDlg )
     208           0 :         mpMarkWnd->ConnectToDialog( sal_False );
     209             : 
     210           0 :     return ( !bReturn && IsMarkWndVisible() );
     211             : }
     212             : 
     213             : // Show Extra-Window
     214           0 : void SvxHyperlinkTabPageBase::ShowMarkWnd ()
     215             : {
     216           0 :     ( ( Window* ) mpMarkWnd )->Show();
     217             : 
     218             :     // Size of dialog-window in screen pixels
     219           0 :     Rectangle aDlgRect( mpDialog->GetWindowExtentsRelative( NULL ) );
     220           0 :     Point aDlgPos ( aDlgRect.TopLeft() );
     221           0 :     Size aDlgSize ( mpDialog->GetSizePixel () );
     222             : 
     223             :     // Absolute size of the screen
     224           0 :     Rectangle aScreen( mpDialog->GetDesktopRectPixel() );
     225             : 
     226             :     // Size of Extrawindow
     227           0 :     Size aExtraWndSize( mpMarkWnd->GetSizePixel () );
     228             : 
     229             :     // mpMarkWnd is a child of mpDialog, so coordinates for positioning must be relative to mpDialog
     230           0 :     if( aDlgPos.X()+(1.05*aDlgSize.Width())+aExtraWndSize.Width() > aScreen.Right() )
     231             :     {
     232           0 :         if( aDlgPos.X() - ( 0.05*aDlgSize.Width() ) - aExtraWndSize.Width() < 0 )
     233             :         {
     234             :             // Pos Extrawindow anywhere
     235           0 :             MoveToExtraWnd( Point(10,10) );  // very unlikely
     236           0 :             mpMarkWnd->ConnectToDialog( sal_False );
     237             :         }
     238             :         else
     239             :         {
     240             :             // Pos Extrawindow on the left side of Dialog
     241           0 :             MoveToExtraWnd( Point(0,0) - Point( long(0.05*aDlgSize.Width()), 0 ) - Point( aExtraWndSize.Width(), 0 ) );
     242             :         }
     243             :     }
     244             :     else
     245             :     {
     246             :         // Pos Extrawindow on the right side of Dialog
     247           0 :         MoveToExtraWnd ( Point( long(1.05*aDlgSize.getWidth()), 0 ) );
     248             :     }
     249             : 
     250             :     // Set size of Extra-Window
     251           0 :     mpMarkWnd->SetSizePixel( Size( aExtraWndSize.Width(), aDlgSize.Height() ) );
     252           0 : }
     253             : 
     254             : // Fill Dialogfields
     255           0 : void SvxHyperlinkTabPageBase::FillStandardDlgFields ( SvxHyperlinkItem* pHyperlinkItem )
     256             : {
     257             :     // Frame
     258           0 :     sal_Int32 nPos = mpCbbFrame->GetEntryPos ( pHyperlinkItem->GetTargetFrame() );
     259           0 :     if ( nPos != COMBOBOX_ENTRY_NOTFOUND)
     260           0 :         mpCbbFrame->SetText ( pHyperlinkItem->GetTargetFrame() );
     261             : 
     262             :     // Form
     263           0 :     OUString aStrFormText = CUI_RESSTR( RID_SVXSTR_HYPERDLG_FROM_TEXT );
     264           0 :     OUString aStrFormButton = CUI_RESSTR( RID_SVXSTR_HYPERDLG_FORM_BUTTON );
     265             : 
     266           0 :     if( pHyperlinkItem->GetInsertMode() & HLINK_HTMLMODE )
     267             :     {
     268           0 :         mpLbForm->Clear();
     269           0 :         mpLbForm->InsertEntry( aStrFormText );
     270           0 :         mpLbForm->SelectEntryPos ( 0 );
     271             :     }
     272             :     else
     273             :     {
     274           0 :         mpLbForm->Clear();
     275           0 :         mpLbForm->InsertEntry( aStrFormText );
     276           0 :         mpLbForm->InsertEntry( aStrFormButton );
     277           0 :         mpLbForm->SelectEntryPos ( pHyperlinkItem->GetInsertMode() == HLINK_BUTTON ? 1 : 0 );
     278             :     }
     279             : 
     280             :     // URL
     281           0 :     mpEdIndication->SetText ( pHyperlinkItem->GetName() );
     282             : 
     283             :     // Name
     284           0 :     mpEdText->SetText ( pHyperlinkItem->GetIntName() );
     285             : 
     286             :     // Script-button
     287           0 :     if ( !pHyperlinkItem->GetMacroEvents() )
     288           0 :         mpBtScript->Disable();
     289             :     else
     290           0 :         mpBtScript->Enable();
     291           0 : }
     292             : 
     293             : // Any action to do after apply-button is pressed
     294           0 : void SvxHyperlinkTabPageBase::DoApply ()
     295             : {
     296             :     // default-implemtation : do nothing
     297           0 : }
     298             : 
     299             : // Ask page whether an insert is possible
     300           0 : sal_Bool SvxHyperlinkTabPageBase::AskApply ()
     301             : {
     302             :     // default-implementation
     303           0 :     return sal_True;
     304             : }
     305             : 
     306             : // This method would be called from bookmark-window to set new mark-string
     307           0 : void SvxHyperlinkTabPageBase::SetMarkStr ( const OUString& /*aStrMark*/ )
     308             : {
     309             :     // default-implemtation : do nothing
     310           0 : }
     311             : 
     312             : // Set initial focus
     313           0 : void SvxHyperlinkTabPageBase::SetInitFocus()
     314             : {
     315           0 :     GrabFocus();
     316           0 : }
     317             : 
     318             : // Ask dialog whether the curretn doc is a HTML-doc
     319           0 : sal_Bool SvxHyperlinkTabPageBase::IsHTMLDoc() const
     320             : {
     321           0 :     return ((SvxHpLinkDlg*)mpDialog)->IsHTMLDoc();
     322             : }
     323             : 
     324             : // retrieve dispatcher
     325           0 : SfxDispatcher* SvxHyperlinkTabPageBase::GetDispatcher() const
     326             : {
     327           0 :     return ((SvxHpLinkDlg*)mpDialog)->GetDispatcher();
     328             : }
     329             : 
     330             : // Click on imagebutton : Script
     331           0 : IMPL_LINK_NOARG(SvxHyperlinkTabPageBase, ClickScriptHdl_Impl)
     332             : {
     333             :     SvxHyperlinkItem *pHyperlinkItem = (SvxHyperlinkItem *)
     334           0 :                                        GetItemSet().GetItem (SID_HYPERLINK_GETLINK);
     335             : 
     336           0 :     if ( pHyperlinkItem->GetMacroEvents() )
     337             :     {
     338             :         // get macros from itemset
     339           0 :         const SvxMacroTableDtor* pMacroTbl = pHyperlinkItem->GetMacroTbl();
     340           0 :         SvxMacroItem aItem ( GetWhich(SID_ATTR_MACROITEM) );
     341           0 :         if( pMacroTbl )
     342           0 :             aItem.SetMacroTable( *pMacroTbl );
     343             : 
     344             :         // create empty itemset for macro-dlg
     345           0 :         SfxItemSet* pItemSet = new SfxItemSet(SFX_APP()->GetPool(),
     346             :                                               SID_ATTR_MACROITEM,
     347           0 :                                               SID_ATTR_MACROITEM );
     348           0 :         pItemSet->Put ( aItem, SID_ATTR_MACROITEM );
     349             : 
     350             :         /*  disable HyperLinkDlg for input while the MacroAssignDlg is working
     351             :             because if no JAVA is installed an error box occurs and then it is possible
     352             :             to close the HyperLinkDlg before its child (MacroAssignDlg) -> GPF
     353             :          */
     354           0 :         sal_Bool bIsInputEnabled = GetParent()->IsInputEnabled();
     355           0 :         if ( bIsInputEnabled )
     356           0 :             GetParent()->EnableInput( false );
     357           0 :         SfxMacroAssignDlg aDlg( this, mxDocumentFrame, *pItemSet );
     358             : 
     359             :         // add events
     360           0 :         SfxMacroTabPage *pMacroPage = (SfxMacroTabPage*) aDlg.GetTabPage();
     361             : 
     362           0 :         if ( pHyperlinkItem->GetMacroEvents() & HYPERDLG_EVENT_MOUSEOVER_OBJECT )
     363           0 :             pMacroPage->AddEvent( OUString( CUI_RESSTR(RID_SVXSTR_HYPDLG_MACROACT1) ),
     364           0 :                                   SFX_EVENT_MOUSEOVER_OBJECT );
     365           0 :         if ( pHyperlinkItem->GetMacroEvents() & HYPERDLG_EVENT_MOUSECLICK_OBJECT )
     366           0 :             pMacroPage->AddEvent( OUString( CUI_RESSTR(RID_SVXSTR_HYPDLG_MACROACT2) ),
     367           0 :                                   SFX_EVENT_MOUSECLICK_OBJECT);
     368           0 :         if ( pHyperlinkItem->GetMacroEvents() & HYPERDLG_EVENT_MOUSEOUT_OBJECT )
     369           0 :             pMacroPage->AddEvent( OUString( CUI_RESSTR(RID_SVXSTR_HYPDLG_MACROACT3) ),
     370           0 :                                   SFX_EVENT_MOUSEOUT_OBJECT);
     371             : 
     372           0 :         if ( bIsInputEnabled )
     373           0 :             GetParent()->EnableInput( true );
     374             :         // execute dlg
     375           0 :         DisableClose( sal_True );
     376           0 :         short nRet = aDlg.Execute();
     377           0 :         DisableClose( sal_False );
     378           0 :         if ( RET_OK == nRet )
     379             :         {
     380           0 :             const SfxItemSet* pOutSet = aDlg.GetOutputItemSet();
     381             :             const SfxPoolItem* pItem;
     382           0 :             if( SFX_ITEM_SET == pOutSet->GetItemState( SID_ATTR_MACROITEM, false, &pItem ))
     383             :             {
     384           0 :                 pHyperlinkItem->SetMacroTable( ((SvxMacroItem*)pItem)->GetMacroTable() );
     385             :             }
     386             :         }
     387           0 :         delete pItemSet;
     388             :     }
     389             : 
     390           0 :     return( 0L );
     391             : }
     392             : 
     393             : // Get Macro-Infos
     394           0 : sal_uInt16 SvxHyperlinkTabPageBase::GetMacroEvents()
     395             : {
     396             :     SvxHyperlinkItem *pHyperlinkItem = (SvxHyperlinkItem *)
     397           0 :                                        GetItemSet().GetItem (SID_HYPERLINK_GETLINK);
     398             : 
     399           0 :     return pHyperlinkItem->GetMacroEvents();
     400             : }
     401             : 
     402           0 : SvxMacroTableDtor* SvxHyperlinkTabPageBase::GetMacroTable()
     403             : {
     404             :     SvxHyperlinkItem *pHyperlinkItem = (SvxHyperlinkItem *)
     405           0 :                                        GetItemSet().GetItem (SID_HYPERLINK_GETLINK);
     406             : 
     407           0 :     return ( (SvxMacroTableDtor*)pHyperlinkItem->GetMacroTbl() );
     408             : }
     409             : 
     410             : // try to detect the current protocol that is used in rStrURL
     411           0 : OUString SvxHyperlinkTabPageBase::GetSchemeFromURL( const OUString& rStrURL )
     412             : {
     413           0 :     OUString aStrScheme;
     414             : 
     415           0 :     INetURLObject aURL( rStrURL );
     416           0 :     INetProtocol aProtocol = aURL.GetProtocol();
     417             : 
     418             :     // #77696#
     419             :     // our new INetUrlObject now has the ability
     420             :     // to detect if an Url is valid or not :-(
     421           0 :     if ( aProtocol == INET_PROT_NOT_VALID )
     422             :     {
     423           0 :         if ( rStrURL.startsWithIgnoreAsciiCase( INET_HTTP_SCHEME ) )
     424             :         {
     425           0 :             aStrScheme = OUString( INET_HTTP_SCHEME );
     426             :         }
     427           0 :         else if ( rStrURL.startsWithIgnoreAsciiCase( INET_HTTPS_SCHEME ) )
     428             :         {
     429           0 :             aStrScheme = OUString( INET_HTTPS_SCHEME );
     430             :         }
     431           0 :         else if ( rStrURL.startsWithIgnoreAsciiCase( INET_FTP_SCHEME ) )
     432             :         {
     433           0 :             aStrScheme = OUString( INET_FTP_SCHEME );
     434             :         }
     435           0 :         else if ( rStrURL.startsWithIgnoreAsciiCase( INET_MAILTO_SCHEME ) )
     436             :         {
     437           0 :             aStrScheme = OUString( INET_MAILTO_SCHEME );
     438             :         }
     439           0 :         else if ( rStrURL.startsWithIgnoreAsciiCase( INET_NEWS_SCHEME ) )
     440             :         {
     441           0 :             aStrScheme = OUString( INET_NEWS_SCHEME );
     442             :         }
     443             :     }
     444             :     else
     445           0 :         aStrScheme = INetURLObject::GetScheme( aProtocol );
     446           0 :     return aStrScheme;
     447             : }
     448             : 
     449             : 
     450           0 : void SvxHyperlinkTabPageBase::GetDataFromCommonFields( OUString& aStrName,
     451             :                                              OUString& aStrIntName, OUString& aStrFrame,
     452             :                                              SvxLinkInsertMode& eMode )
     453             : {
     454           0 :     aStrIntName = mpEdText->GetText();
     455           0 :     aStrName    = mpEdIndication->GetText();
     456           0 :     aStrFrame   = mpCbbFrame->GetText();
     457           0 :     eMode       = (SvxLinkInsertMode) (mpLbForm->GetSelectEntryPos()+1);
     458           0 :     if( IsHTMLDoc() )
     459           0 :         eMode = (SvxLinkInsertMode) ( sal_uInt16(eMode) | HLINK_HTMLMODE );
     460           0 : }
     461             : 
     462             : // reset dialog-fields
     463           0 : void SvxHyperlinkTabPageBase::Reset( const SfxItemSet& rItemSet)
     464             : {
     465             : 
     466             :     // Set dialog-fields from create-itemset
     467           0 :     maStrInitURL = aEmptyStr;
     468             : 
     469             :     SvxHyperlinkItem *pHyperlinkItem = (SvxHyperlinkItem *)
     470           0 :                                        rItemSet.GetItem (SID_HYPERLINK_GETLINK);
     471             : 
     472           0 :     if ( pHyperlinkItem )
     473             :     {
     474             :         // set dialog-fields
     475           0 :         FillStandardDlgFields (pHyperlinkItem);
     476             : 
     477             :         // set all other fields
     478           0 :         FillDlgFields ( (OUString&)pHyperlinkItem->GetURL() );
     479             : 
     480             :         // Store initial URL
     481           0 :         maStrInitURL = pHyperlinkItem->GetURL();
     482             :     }
     483           0 : }
     484             : 
     485             : // Fill output-ItemSet
     486           0 : bool SvxHyperlinkTabPageBase::FillItemSet( SfxItemSet& rOut)
     487             : {
     488           0 :     OUString aStrURL, aStrName, aStrIntName, aStrFrame;
     489             :     SvxLinkInsertMode eMode;
     490             : 
     491           0 :     GetCurentItemData ( aStrURL, aStrName, aStrIntName, aStrFrame, eMode);
     492           0 :     if ( aStrName.isEmpty() ) //automatically create a visible name if the link is created without name
     493           0 :         aStrName = CreateUiNameFromURL(aStrURL);
     494             : 
     495           0 :     sal_uInt16 nEvents = GetMacroEvents();
     496           0 :     SvxMacroTableDtor* pTable = GetMacroTable();
     497             : 
     498             :     SvxHyperlinkItem aItem( SID_HYPERLINK_SETLINK, aStrName, aStrURL, aStrFrame,
     499           0 :                             aStrIntName, eMode, nEvents, pTable );
     500           0 :     rOut.Put (aItem);
     501             : 
     502           0 :     return true;
     503             : }
     504             : 
     505           0 : OUString SvxHyperlinkTabPageBase::CreateUiNameFromURL( const OUString& aStrURL )
     506             : {
     507           0 :     OUString          aStrUiURL;
     508           0 :     INetURLObject   aURLObj( aStrURL );
     509             : 
     510           0 :     switch(aURLObj.GetProtocol())
     511             :     {
     512             :         case INET_PROT_FILE:
     513           0 :             utl::LocalFileHelper::ConvertURLToSystemPath( aURLObj.GetMainURL(INetURLObject::NO_DECODE), aStrUiURL );
     514           0 :             break;
     515             :         case INET_PROT_FTP :
     516             :             {
     517             :                 //remove password from name
     518           0 :                 INetURLObject   aTmpURL(aURLObj);
     519           0 :                 aTmpURL.SetPass(aEmptyStr);
     520           0 :                 aStrUiURL = aTmpURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
     521             :             }
     522           0 :             break;
     523             :         default :
     524             :             {
     525           0 :                 aStrUiURL = aURLObj.GetMainURL(INetURLObject::DECODE_UNAMBIGUOUS);
     526             :             }
     527             :     }
     528           0 :     if(aStrUiURL.isEmpty())
     529           0 :         return aStrURL;
     530           0 :     return aStrUiURL;
     531             : }
     532             : 
     533             : // Activate / Deactivate Tabpage
     534           0 : void SvxHyperlinkTabPageBase::ActivatePage( const SfxItemSet& rItemSet )
     535             : {
     536             : 
     537             :     // Set dialog-fields from input-itemset
     538             :     SvxHyperlinkItem *pHyperlinkItem = (SvxHyperlinkItem *)
     539           0 :                                        rItemSet.GetItem (SID_HYPERLINK_GETLINK);
     540             : 
     541           0 :     if ( pHyperlinkItem )
     542             :     {
     543             :         // standard-fields
     544           0 :         FillStandardDlgFields (pHyperlinkItem);
     545             :     }
     546             : 
     547             :     // show mark-window if it was open before
     548           0 :     if ( ShouldOpenMarkWnd () )
     549           0 :         ShowMarkWnd ();
     550           0 : }
     551             : 
     552           0 : int SvxHyperlinkTabPageBase::DeactivatePage( SfxItemSet* _pSet)
     553             : {
     554             :     // hide mark-wnd
     555           0 :     SetMarkWndShouldOpen( IsMarkWndVisible () );
     556           0 :     HideMarkWnd ();
     557             : 
     558             :     // retrieve data of dialog
     559           0 :     OUString aStrURL, aStrName, aStrIntName, aStrFrame;
     560             :     SvxLinkInsertMode eMode;
     561             : 
     562           0 :     GetCurentItemData ( aStrURL, aStrName, aStrIntName, aStrFrame, eMode);
     563             : 
     564           0 :     sal_uInt16 nEvents = GetMacroEvents();
     565           0 :     SvxMacroTableDtor* pTable = GetMacroTable();
     566             : 
     567           0 :     if( _pSet )
     568             :     {
     569             :         SvxHyperlinkItem aItem( SID_HYPERLINK_GETLINK, aStrName, aStrURL, aStrFrame,
     570           0 :                                 aStrIntName, eMode, nEvents, pTable );
     571           0 :         _pSet->Put( aItem );
     572             :     }
     573             : 
     574           0 :     return( LEAVE_PAGE );
     575             : }
     576             : 
     577           0 : sal_Bool SvxHyperlinkTabPageBase::ShouldOpenMarkWnd()
     578             : {
     579           0 :     return sal_False;
     580             : }
     581             : 
     582           0 : void SvxHyperlinkTabPageBase::SetMarkWndShouldOpen(sal_Bool)
     583             : {
     584           0 : }
     585             : 
     586             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10