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

Generated by: LCOV version 1.10