12ee96f1cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 32ee96f1cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 42ee96f1cSAndrew Rist * or more contributor license agreements. See the NOTICE file 52ee96f1cSAndrew Rist * distributed with this work for additional information 62ee96f1cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 72ee96f1cSAndrew Rist * to you under the Apache License, Version 2.0 (the 82ee96f1cSAndrew Rist * "License"); you may not use this file except in compliance 92ee96f1cSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 112ee96f1cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 132ee96f1cSAndrew Rist * Unless required by applicable law or agreed to in writing, 142ee96f1cSAndrew Rist * software distributed under the License is distributed on an 152ee96f1cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 162ee96f1cSAndrew Rist * KIND, either express or implied. See the License for the 172ee96f1cSAndrew Rist * specific language governing permissions and limitations 182ee96f1cSAndrew Rist * under the License. 19cdf0e10cSrcweir * 202ee96f1cSAndrew Rist *************************************************************/ 212ee96f1cSAndrew Rist 222ee96f1cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_cui.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 28cdf0e10cSrcweir #include <unotools/useroptions.hxx> 29cdf0e10cSrcweir #include <svl/adrparse.hxx> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include "hlinettp.hxx" 32cdf0e10cSrcweir #include "hyperdlg.hrc" 33cdf0e10cSrcweir #include "hlmarkwn_def.hxx" //ADD CHINA001 34cdf0e10cSrcweir 35cdf0e10cSrcweir #define STD_DOC_SUBPATH "internal" 36cdf0e10cSrcweir #define STD_DOC_NAME "url_transfer.htm" 37cdf0e10cSrcweir 38cdf0e10cSrcweir sal_Char __READONLY_DATA sAnonymous[] = "anonymous"; 39cdf0e10cSrcweir sal_Char __READONLY_DATA sHTTPScheme[] = INET_HTTP_SCHEME; 40cdf0e10cSrcweir sal_Char __READONLY_DATA sHTTPSScheme[] = INET_HTTPS_SCHEME; 41cdf0e10cSrcweir sal_Char __READONLY_DATA sFTPScheme[] = INET_FTP_SCHEME; 42cdf0e10cSrcweir sal_Char __READONLY_DATA sTelnetScheme[] = INET_TELNET_SCHEME; 43cdf0e10cSrcweir 44cdf0e10cSrcweir /************************************************************************* 45cdf0e10cSrcweir |* 46*a8f4084dSMatthias Seidel |* Constructor / Destructor 47cdf0e10cSrcweir |* 48cdf0e10cSrcweir |************************************************************************/ 49cdf0e10cSrcweir 50cdf0e10cSrcweir SvxHyperlinkInternetTp::SvxHyperlinkInternetTp ( Window *pParent, 51cdf0e10cSrcweir const SfxItemSet& rItemSet) 52cdf0e10cSrcweir : SvxHyperlinkTabPageBase ( pParent, CUI_RES( RID_SVXPAGE_HYPERLINK_INTERNET ), 53cdf0e10cSrcweir rItemSet ) , 54cdf0e10cSrcweir maGrpLinkTyp ( this, CUI_RES (GRP_LINKTYPE) ), 55cdf0e10cSrcweir maRbtLinktypInternet ( this, CUI_RES (RB_LINKTYP_INTERNET) ), 56cdf0e10cSrcweir maRbtLinktypFTP ( this, CUI_RES (RB_LINKTYP_FTP) ), 57cdf0e10cSrcweir maRbtLinktypTelnet ( this, CUI_RES (RB_LINKTYP_TELNET) ), 58cdf0e10cSrcweir maFtTarget ( this, CUI_RES (FT_TARGET_HTML) ), 59cdf0e10cSrcweir maCbbTarget ( this, INET_PROT_HTTP ), 60cdf0e10cSrcweir maBtBrowse ( this, CUI_RES (BTN_BROWSE) ), 61cdf0e10cSrcweir maFtLogin ( this, CUI_RES (FT_LOGIN) ), 62cdf0e10cSrcweir maEdLogin ( this, CUI_RES (ED_LOGIN) ), 63cdf0e10cSrcweir maBtTarget ( this, CUI_RES (BTN_TARGET) ), 64cdf0e10cSrcweir maFtPassword ( this, CUI_RES (FT_PASSWD) ), 65cdf0e10cSrcweir maEdPassword ( this, CUI_RES (ED_PASSWD) ), 66cdf0e10cSrcweir maCbAnonymous ( this, CUI_RES (CBX_ANONYMOUS) ), 67cdf0e10cSrcweir mbMarkWndOpen ( sal_False ) 68cdf0e10cSrcweir { 69cdf0e10cSrcweir // Set HC bitmaps and display display of bitmap names. 70cdf0e10cSrcweir maBtBrowse.SetModeImage( Image( CUI_RES( IMG_BROWSE_HC ) ), BMP_COLOR_HIGHCONTRAST ); 71cdf0e10cSrcweir maBtBrowse.EnableTextDisplay (sal_False); 72cdf0e10cSrcweir maBtTarget.SetModeImage( Image( CUI_RES( IMG_TARGET_HC ) ), BMP_COLOR_HIGHCONTRAST ); 73cdf0e10cSrcweir maBtTarget.EnableTextDisplay (sal_False); 74cdf0e10cSrcweir 75cdf0e10cSrcweir InitStdControls(); 76cdf0e10cSrcweir FreeResource(); 77cdf0e10cSrcweir 78cdf0e10cSrcweir // Init URL-Box (pos&size, Open-Handler) 79cdf0e10cSrcweir maCbbTarget.SetPosSizePixel ( LogicToPixel( Point( COL_2, 25 ), MAP_APPFONT ), 80cdf0e10cSrcweir LogicToPixel( Size ( 176 - COL_DIFF, 60), MAP_APPFONT ) ); 81cdf0e10cSrcweir maCbbTarget.Show(); 82cdf0e10cSrcweir maCbbTarget.SetHelpId( HID_HYPERDLG_INET_PATH ); 83cdf0e10cSrcweir 84cdf0e10cSrcweir // Find Path to Std-Doc 85cdf0e10cSrcweir String aStrBasePaths( SvtPathOptions().GetTemplatePath() ); 86cdf0e10cSrcweir for( xub_StrLen n = 0; n < aStrBasePaths.GetTokenCount(); n++ ) 87cdf0e10cSrcweir { 88cdf0e10cSrcweir INetURLObject aURL( aStrBasePaths.GetToken( n ) ); 89cdf0e10cSrcweir aURL.Append( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( STD_DOC_SUBPATH ) ) ); 90cdf0e10cSrcweir aURL.Append( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( STD_DOC_NAME ) ) ); 91cdf0e10cSrcweir if ( FileExists( aURL ) ) 92cdf0e10cSrcweir { 93cdf0e10cSrcweir maStrStdDocURL = aURL.GetMainURL( INetURLObject::NO_DECODE ); 94cdf0e10cSrcweir break; 95cdf0e10cSrcweir } 96cdf0e10cSrcweir } 97cdf0e10cSrcweir SetExchangeSupport (); 98cdf0e10cSrcweir 99cdf0e10cSrcweir /////////////////////////////////////// 100cdf0e10cSrcweir // set defaults 101cdf0e10cSrcweir maRbtLinktypInternet.Check (); 102cdf0e10cSrcweir maFtLogin.Show( sal_False ); 103cdf0e10cSrcweir maFtPassword.Show( sal_False ); 104cdf0e10cSrcweir maEdLogin.Show( sal_False ); 105cdf0e10cSrcweir maEdPassword.Show( sal_False ); 106cdf0e10cSrcweir maCbAnonymous.Show( sal_False ); 107cdf0e10cSrcweir maBtTarget.Enable( sal_False ); 108cdf0e10cSrcweir maBtBrowse.Enable( maStrStdDocURL != aEmptyStr ); 109cdf0e10cSrcweir 110cdf0e10cSrcweir /////////////////////////////////////// 111cdf0e10cSrcweir // overload handlers 112cdf0e10cSrcweir Link aLink( LINK ( this, SvxHyperlinkInternetTp, Click_SmartProtocol_Impl ) ); 113cdf0e10cSrcweir maRbtLinktypInternet.SetClickHdl( aLink ); 114cdf0e10cSrcweir maRbtLinktypFTP.SetClickHdl ( aLink ); 115cdf0e10cSrcweir maRbtLinktypTelnet.SetClickHdl ( aLink ); 116cdf0e10cSrcweir maCbAnonymous.SetClickHdl ( LINK ( this, SvxHyperlinkInternetTp, ClickAnonymousHdl_Impl ) ); 117cdf0e10cSrcweir maBtBrowse.SetClickHdl ( LINK ( this, SvxHyperlinkInternetTp, ClickBrowseHdl_Impl ) ); 118cdf0e10cSrcweir maBtTarget.SetClickHdl ( LINK ( this, SvxHyperlinkInternetTp, ClickTargetHdl_Impl ) ); 119cdf0e10cSrcweir maEdLogin.SetModifyHdl ( LINK ( this, SvxHyperlinkInternetTp, ModifiedLoginHdl_Impl ) ); 120cdf0e10cSrcweir maCbbTarget.SetLoseFocusHdl ( LINK ( this, SvxHyperlinkInternetTp, LostFocusTargetHdl_Impl ) ); 121cdf0e10cSrcweir maCbbTarget.SetModifyHdl ( LINK ( this, SvxHyperlinkInternetTp, ModifiedTargetHdl_Impl ) ); 122cdf0e10cSrcweir maTimer.SetTimeoutHdl ( LINK ( this, SvxHyperlinkInternetTp, TimeoutHdl_Impl ) ); 123cdf0e10cSrcweir 124cdf0e10cSrcweir maFtTarget.SetAccessibleRelationMemberOf( &maGrpLinkTyp ); 125cdf0e10cSrcweir maCbbTarget.SetAccessibleRelationMemberOf( &maGrpLinkTyp ); 126cdf0e10cSrcweir maBtTarget.SetAccessibleRelationMemberOf( &maGrpLinkTyp ); 127cdf0e10cSrcweir maBtTarget.SetAccessibleRelationLabeledBy( &maFtTarget ); 128cdf0e10cSrcweir maBtBrowse.SetAccessibleRelationMemberOf( &maGrpLinkTyp ); 129cdf0e10cSrcweir maBtBrowse.SetAccessibleRelationLabeledBy( &maFtTarget ); 130cdf0e10cSrcweir } 131cdf0e10cSrcweir 132cdf0e10cSrcweir SvxHyperlinkInternetTp::~SvxHyperlinkInternetTp () 133cdf0e10cSrcweir { 134cdf0e10cSrcweir } 135cdf0e10cSrcweir 136cdf0e10cSrcweir /************************************************************************* 137cdf0e10cSrcweir |* 138cdf0e10cSrcweir |* Fill the all dialog-controls except controls in groupbox "more..." 139cdf0e10cSrcweir |* 140cdf0e10cSrcweir |************************************************************************/ 141cdf0e10cSrcweir 142cdf0e10cSrcweir void SvxHyperlinkInternetTp::FillDlgFields ( String& aStrURL ) 143cdf0e10cSrcweir { 144cdf0e10cSrcweir INetURLObject aURL( aStrURL ); 145cdf0e10cSrcweir String aStrScheme = GetSchemeFromURL( aStrURL ); 146cdf0e10cSrcweir 147cdf0e10cSrcweir // set additional controls for FTP: Username / Password 148cdf0e10cSrcweir if ( aStrScheme.SearchAscii( sFTPScheme ) == 0 ) 149cdf0e10cSrcweir { 150cdf0e10cSrcweir if ( String(aURL.GetUser()).ToLowerAscii().SearchAscii ( sAnonymous ) == 0 ) 151cdf0e10cSrcweir setAnonymousFTPUser(); 152cdf0e10cSrcweir else 153cdf0e10cSrcweir setFTPUser(aURL.GetUser(), aURL.GetPass()); 154cdf0e10cSrcweir 155cdf0e10cSrcweir //do not show password and user in url 156cdf0e10cSrcweir if(aURL.GetUser().getLength()!=0 || aURL.GetPass().getLength()!=0 ) 157cdf0e10cSrcweir aURL.SetUserAndPass(aEmptyStr,aEmptyStr); 158cdf0e10cSrcweir } 159cdf0e10cSrcweir 160cdf0e10cSrcweir // set URL-field 161cdf0e10cSrcweir // Show the scheme, #72740 162cdf0e10cSrcweir if ( aURL.GetProtocol() != INET_PROT_NOT_VALID ) 163cdf0e10cSrcweir maCbbTarget.SetText( aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) ); 164cdf0e10cSrcweir else 165cdf0e10cSrcweir maCbbTarget.SetText( aStrURL ); // #77696# 166cdf0e10cSrcweir 167cdf0e10cSrcweir SetScheme( aStrScheme ); 168cdf0e10cSrcweir } 169cdf0e10cSrcweir 170cdf0e10cSrcweir void SvxHyperlinkInternetTp::setAnonymousFTPUser() 171cdf0e10cSrcweir { 172cdf0e10cSrcweir maEdLogin.SetText( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM ( sAnonymous ) ) ); 173cdf0e10cSrcweir SvAddressParser aAddress( SvtUserOptions().GetEmail() ); 174cdf0e10cSrcweir maEdPassword.SetText( aAddress.Count() ? aAddress.GetEmailAddress(0) : String() ); 175cdf0e10cSrcweir 176cdf0e10cSrcweir maFtLogin.Disable (); 177cdf0e10cSrcweir maFtPassword.Disable (); 178cdf0e10cSrcweir maEdLogin.Disable (); 179cdf0e10cSrcweir maEdPassword.Disable (); 180cdf0e10cSrcweir maCbAnonymous.Check(); 181cdf0e10cSrcweir } 182cdf0e10cSrcweir 183cdf0e10cSrcweir void SvxHyperlinkInternetTp::setFTPUser(const String& rUser, const String& rPassword) 184cdf0e10cSrcweir { 185cdf0e10cSrcweir maEdLogin.SetText ( rUser ); 186cdf0e10cSrcweir maEdPassword.SetText ( rPassword ); 187cdf0e10cSrcweir 188cdf0e10cSrcweir maFtLogin.Enable (); 189cdf0e10cSrcweir maFtPassword.Enable (); 190cdf0e10cSrcweir maEdLogin.Enable (); 191cdf0e10cSrcweir maEdPassword.Enable (); 192cdf0e10cSrcweir maCbAnonymous.Check(sal_False); 193cdf0e10cSrcweir } 194cdf0e10cSrcweir 195cdf0e10cSrcweir /************************************************************************* 196cdf0e10cSrcweir |* 197cdf0e10cSrcweir |* retrieve and prepare data from dialog-fields 198cdf0e10cSrcweir |* 199cdf0e10cSrcweir |************************************************************************/ 200cdf0e10cSrcweir 201cdf0e10cSrcweir void SvxHyperlinkInternetTp::GetCurentItemData ( String& aStrURL, String& aStrName, 202cdf0e10cSrcweir String& aStrIntName, String& aStrFrame, 203cdf0e10cSrcweir SvxLinkInsertMode& eMode ) 204cdf0e10cSrcweir { 205cdf0e10cSrcweir aStrURL = CreateAbsoluteURL(); 206cdf0e10cSrcweir GetDataFromCommonFields( aStrName, aStrIntName, aStrFrame, eMode ); 207cdf0e10cSrcweir } 208cdf0e10cSrcweir 209cdf0e10cSrcweir String SvxHyperlinkInternetTp::CreateAbsoluteURL() const 210cdf0e10cSrcweir { 211cdf0e10cSrcweir String aStrURL = maCbbTarget.GetText(); 212cdf0e10cSrcweir String aScheme = GetSchemeFromURL(aStrURL); 213cdf0e10cSrcweir 214cdf0e10cSrcweir INetURLObject aURL(aStrURL); 215cdf0e10cSrcweir 216cdf0e10cSrcweir if( aURL.GetProtocol() == INET_PROT_NOT_VALID ) 217cdf0e10cSrcweir { 218cdf0e10cSrcweir aURL.SetSmartProtocol( GetSmartProtocolFromButtons() ); 219cdf0e10cSrcweir aURL.SetSmartURL(aStrURL); 220cdf0e10cSrcweir } 221cdf0e10cSrcweir 222cdf0e10cSrcweir // username and password for ftp-url 223cdf0e10cSrcweir if( aURL.GetProtocol() == INET_PROT_FTP && maEdLogin.GetText().Len()!=0 ) 224cdf0e10cSrcweir aURL.SetUserAndPass ( maEdLogin.GetText(), maEdPassword.GetText() ); 225cdf0e10cSrcweir 226cdf0e10cSrcweir if ( aURL.GetProtocol() != INET_PROT_NOT_VALID ) 227cdf0e10cSrcweir return aURL.GetMainURL( INetURLObject::DECODE_WITH_CHARSET ); 228cdf0e10cSrcweir else //#105788# always create a URL even if it is not valid 229cdf0e10cSrcweir return aStrURL; 230cdf0e10cSrcweir } 231cdf0e10cSrcweir 232cdf0e10cSrcweir /************************************************************************* 233cdf0e10cSrcweir |* 234cdf0e10cSrcweir |* static method to create Tabpage 235cdf0e10cSrcweir |* 236cdf0e10cSrcweir |************************************************************************/ 237cdf0e10cSrcweir 238cdf0e10cSrcweir IconChoicePage* SvxHyperlinkInternetTp::Create( Window* pWindow, const SfxItemSet& rItemSet ) 239cdf0e10cSrcweir { 240cdf0e10cSrcweir return( new SvxHyperlinkInternetTp( pWindow, rItemSet ) ); 241cdf0e10cSrcweir } 242cdf0e10cSrcweir 243cdf0e10cSrcweir /************************************************************************* 244cdf0e10cSrcweir |* 245cdf0e10cSrcweir |* Set initial focus 246cdf0e10cSrcweir |* 247cdf0e10cSrcweir |************************************************************************/ 248cdf0e10cSrcweir 249cdf0e10cSrcweir void SvxHyperlinkInternetTp::SetInitFocus() 250cdf0e10cSrcweir { 251cdf0e10cSrcweir maCbbTarget.GrabFocus(); 252cdf0e10cSrcweir } 253cdf0e10cSrcweir 254cdf0e10cSrcweir /************************************************************************* 255cdf0e10cSrcweir |* 256cdf0e10cSrcweir |* Contens of editfield "Taregt" modified 257cdf0e10cSrcweir |* 258cdf0e10cSrcweir |************************************************************************/ 259cdf0e10cSrcweir 260cdf0e10cSrcweir IMPL_LINK ( SvxHyperlinkInternetTp, ModifiedTargetHdl_Impl, void *, EMPTYARG ) 261cdf0e10cSrcweir { 262cdf0e10cSrcweir String aScheme = GetSchemeFromURL( maCbbTarget.GetText() ); 263cdf0e10cSrcweir if(aScheme.Len()!=0) 264cdf0e10cSrcweir SetScheme( aScheme ); 265cdf0e10cSrcweir 266cdf0e10cSrcweir // start timer 267cdf0e10cSrcweir maTimer.SetTimeout( 2500 ); 268cdf0e10cSrcweir maTimer.Start(); 269cdf0e10cSrcweir 270cdf0e10cSrcweir return( 0L ); 271cdf0e10cSrcweir } 272cdf0e10cSrcweir 273cdf0e10cSrcweir /************************************************************************* 274cdf0e10cSrcweir |* 275cdf0e10cSrcweir |* If target-field was modify, to browse the new doc afeter timeout 276cdf0e10cSrcweir |* 277cdf0e10cSrcweir |************************************************************************/ 278cdf0e10cSrcweir 279cdf0e10cSrcweir IMPL_LINK ( SvxHyperlinkInternetTp, TimeoutHdl_Impl, Timer *, EMPTYARG ) 280cdf0e10cSrcweir { 281cdf0e10cSrcweir RefreshMarkWindow(); 282cdf0e10cSrcweir return( 0L ); 283cdf0e10cSrcweir } 284cdf0e10cSrcweir 285cdf0e10cSrcweir /************************************************************************* 286cdf0e10cSrcweir |* 287cdf0e10cSrcweir |* Contens of editfield "Login" modified 288cdf0e10cSrcweir |* 289cdf0e10cSrcweir |************************************************************************/ 290cdf0e10cSrcweir 291cdf0e10cSrcweir IMPL_LINK ( SvxHyperlinkInternetTp, ModifiedLoginHdl_Impl, void *, EMPTYARG ) 292cdf0e10cSrcweir { 293cdf0e10cSrcweir String aStrLogin ( maEdLogin.GetText() ); 294cdf0e10cSrcweir if ( aStrLogin.EqualsIgnoreCaseAscii( sAnonymous ) ) 295cdf0e10cSrcweir { 296cdf0e10cSrcweir maCbAnonymous.Check(); 297cdf0e10cSrcweir ClickAnonymousHdl_Impl(NULL); 298cdf0e10cSrcweir } 299cdf0e10cSrcweir 300cdf0e10cSrcweir return( 0L ); 301cdf0e10cSrcweir } 302cdf0e10cSrcweir 303cdf0e10cSrcweir /************************************************************************* 304cdf0e10cSrcweir |************************************************************************/ 305cdf0e10cSrcweir 306cdf0e10cSrcweir void SvxHyperlinkInternetTp::SetScheme( const String& aScheme ) 307cdf0e10cSrcweir { 308cdf0e10cSrcweir //if aScheme is empty or unknown the default beaviour is like it where HTTP 309cdf0e10cSrcweir 310cdf0e10cSrcweir sal_Bool bFTP = aScheme.SearchAscii( sFTPScheme ) == 0; 311cdf0e10cSrcweir sal_Bool bTelnet = sal_False; 312cdf0e10cSrcweir if( !bFTP ) 313cdf0e10cSrcweir bTelnet = aScheme.SearchAscii( sTelnetScheme ) == 0; 314cdf0e10cSrcweir sal_Bool bInternet = !(bFTP || bTelnet); 315cdf0e10cSrcweir 316cdf0e10cSrcweir //update protocol button selection: 317cdf0e10cSrcweir maRbtLinktypFTP.Check(bFTP); 318cdf0e10cSrcweir maRbtLinktypTelnet.Check(bTelnet); 319cdf0e10cSrcweir maRbtLinktypInternet.Check(bInternet); 320cdf0e10cSrcweir 321cdf0e10cSrcweir //update target: 322cdf0e10cSrcweir RemoveImproperProtocol(aScheme); 323cdf0e10cSrcweir maCbbTarget.SetSmartProtocol( GetSmartProtocolFromButtons() ); 324cdf0e10cSrcweir 325cdf0e10cSrcweir //show/hide special fields for FTP: 326cdf0e10cSrcweir maFtLogin.Show( bFTP ); 327cdf0e10cSrcweir maFtPassword.Show( bFTP ); 328cdf0e10cSrcweir maEdLogin.Show( bFTP ); 329cdf0e10cSrcweir maEdPassword.Show( bFTP ); 330cdf0e10cSrcweir maCbAnonymous.Show( bFTP ); 331cdf0e10cSrcweir 332cdf0e10cSrcweir //update 'link target in document'-window and opening-button 333cdf0e10cSrcweir if( aScheme.SearchAscii( sHTTPScheme ) == 0 || aScheme.Len() == 0 ) 334cdf0e10cSrcweir { 335cdf0e10cSrcweir maBtTarget.Enable(); 336cdf0e10cSrcweir if ( mbMarkWndOpen ) 337cdf0e10cSrcweir ShowMarkWnd (); 338cdf0e10cSrcweir } 339cdf0e10cSrcweir else 340cdf0e10cSrcweir { 341cdf0e10cSrcweir //disable for https, ftp and telnet 342cdf0e10cSrcweir maBtTarget.Disable(); 343cdf0e10cSrcweir if ( mbMarkWndOpen ) 344cdf0e10cSrcweir HideMarkWnd (); 345cdf0e10cSrcweir } 346cdf0e10cSrcweir } 347cdf0e10cSrcweir 348cdf0e10cSrcweir /************************************************************************* 349cdf0e10cSrcweir |* 350cdf0e10cSrcweir |* Remove protocol if it does not fit to the current button selection 351cdf0e10cSrcweir |* 352cdf0e10cSrcweir |************************************************************************/ 353cdf0e10cSrcweir 354cdf0e10cSrcweir void SvxHyperlinkInternetTp::RemoveImproperProtocol(const String& aProperScheme) 355cdf0e10cSrcweir { 356cdf0e10cSrcweir String aStrURL ( maCbbTarget.GetText() ); 357cdf0e10cSrcweir if ( aStrURL != aEmptyStr ) 358cdf0e10cSrcweir { 359cdf0e10cSrcweir String aStrScheme = GetSchemeFromURL( aStrURL ); 360cdf0e10cSrcweir if ( aStrScheme != aEmptyStr && aStrScheme != aProperScheme ) 361cdf0e10cSrcweir { 362cdf0e10cSrcweir aStrURL.Erase ( 0, aStrScheme.Len() ); 363cdf0e10cSrcweir maCbbTarget.SetText ( aStrURL ); 364cdf0e10cSrcweir } 365cdf0e10cSrcweir } 366cdf0e10cSrcweir } 367cdf0e10cSrcweir 368cdf0e10cSrcweir String SvxHyperlinkInternetTp::GetSchemeFromButtons() const 369cdf0e10cSrcweir { 370cdf0e10cSrcweir if( maRbtLinktypFTP.IsChecked() ) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir return String::CreateFromAscii( INET_FTP_SCHEME ); 373cdf0e10cSrcweir } 374cdf0e10cSrcweir else if( maRbtLinktypTelnet.IsChecked() ) 375cdf0e10cSrcweir { 376cdf0e10cSrcweir return String::CreateFromAscii( INET_TELNET_SCHEME ); 377cdf0e10cSrcweir } 378cdf0e10cSrcweir return String::CreateFromAscii( INET_HTTP_SCHEME ); 379cdf0e10cSrcweir } 380cdf0e10cSrcweir 381cdf0e10cSrcweir INetProtocol SvxHyperlinkInternetTp::GetSmartProtocolFromButtons() const 382cdf0e10cSrcweir { 383cdf0e10cSrcweir if( maRbtLinktypFTP.IsChecked() ) 384cdf0e10cSrcweir { 385cdf0e10cSrcweir return INET_PROT_FTP; 386cdf0e10cSrcweir } 387cdf0e10cSrcweir else if( maRbtLinktypTelnet.IsChecked() ) 388cdf0e10cSrcweir { 389cdf0e10cSrcweir return INET_PROT_TELNET; 390cdf0e10cSrcweir } 391cdf0e10cSrcweir return INET_PROT_HTTP; 392cdf0e10cSrcweir } 393cdf0e10cSrcweir 394cdf0e10cSrcweir /************************************************************************* 395cdf0e10cSrcweir |* 396cdf0e10cSrcweir |* Click on Radiobutton : Internet, FTP or Telnet 397cdf0e10cSrcweir |* 398cdf0e10cSrcweir |************************************************************************/ 399cdf0e10cSrcweir 400cdf0e10cSrcweir IMPL_LINK ( SvxHyperlinkInternetTp, Click_SmartProtocol_Impl, void*, EMPTYARG ) 401cdf0e10cSrcweir { 402cdf0e10cSrcweir String aScheme = GetSchemeFromButtons(); 403cdf0e10cSrcweir SetScheme( aScheme ); 404cdf0e10cSrcweir return( 0L ); 405cdf0e10cSrcweir } 406cdf0e10cSrcweir 407cdf0e10cSrcweir /************************************************************************* 408cdf0e10cSrcweir |* 409cdf0e10cSrcweir |* Click on Checkbox : Anonymous user 410cdf0e10cSrcweir |* 411cdf0e10cSrcweir |************************************************************************/ 412cdf0e10cSrcweir 413cdf0e10cSrcweir IMPL_LINK ( SvxHyperlinkInternetTp, ClickAnonymousHdl_Impl, void *, EMPTYARG ) 414cdf0e10cSrcweir { 415cdf0e10cSrcweir // disable login-editfields if checked 416cdf0e10cSrcweir if ( maCbAnonymous.IsChecked() ) 417cdf0e10cSrcweir { 418cdf0e10cSrcweir if ( maEdLogin.GetText().ToLowerAscii().SearchAscii ( sAnonymous ) == 0 ) 419cdf0e10cSrcweir { 420cdf0e10cSrcweir maStrOldUser = aEmptyStr; 421cdf0e10cSrcweir maStrOldPassword = aEmptyStr; 422cdf0e10cSrcweir } 423cdf0e10cSrcweir else 424cdf0e10cSrcweir { 425cdf0e10cSrcweir maStrOldUser = maEdLogin.GetText(); 426cdf0e10cSrcweir maStrOldPassword = maEdPassword.GetText(); 427cdf0e10cSrcweir } 428cdf0e10cSrcweir 429cdf0e10cSrcweir setAnonymousFTPUser(); 430cdf0e10cSrcweir } 431cdf0e10cSrcweir else 432cdf0e10cSrcweir setFTPUser(maStrOldUser, maStrOldPassword); 433cdf0e10cSrcweir 434cdf0e10cSrcweir return( 0L ); 435cdf0e10cSrcweir } 436cdf0e10cSrcweir 437cdf0e10cSrcweir /************************************************************************* 438cdf0e10cSrcweir |* 439cdf0e10cSrcweir |* Combobox Target lost the focus 440cdf0e10cSrcweir |* 441cdf0e10cSrcweir |************************************************************************/ 442cdf0e10cSrcweir 443cdf0e10cSrcweir IMPL_LINK ( SvxHyperlinkInternetTp, LostFocusTargetHdl_Impl, void *, EMPTYARG ) 444cdf0e10cSrcweir { 445cdf0e10cSrcweir RefreshMarkWindow(); 446cdf0e10cSrcweir return (0L); 447cdf0e10cSrcweir } 448cdf0e10cSrcweir 449cdf0e10cSrcweir /************************************************************************* 450cdf0e10cSrcweir |* 451cdf0e10cSrcweir |* Click on imagebutton : Browse 452cdf0e10cSrcweir |* 453cdf0e10cSrcweir |************************************************************************/ 454cdf0e10cSrcweir 455cdf0e10cSrcweir IMPL_LINK ( SvxHyperlinkInternetTp, ClickBrowseHdl_Impl, void *, EMPTYARG ) 456cdf0e10cSrcweir { 457cdf0e10cSrcweir ///////////////////////////////////////////////// 458cdf0e10cSrcweir // Open URL if available 459cdf0e10cSrcweir 460cdf0e10cSrcweir SfxStringItem aName( SID_FILE_NAME, maStrStdDocURL ); 461cdf0e10cSrcweir SfxStringItem aRefererItem( SID_REFERER, UniString::CreateFromAscii( 462cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "private:user" ) ) ); 463cdf0e10cSrcweir SfxBoolItem aNewView( SID_OPEN_NEW_VIEW, sal_True ); 464cdf0e10cSrcweir SfxBoolItem aSilent( SID_SILENT, sal_True ); 465cdf0e10cSrcweir SfxBoolItem aReadOnly( SID_DOC_READONLY, sal_True ); 466cdf0e10cSrcweir 467cdf0e10cSrcweir SfxBoolItem aBrowse( SID_BROWSE, sal_True ); 468cdf0e10cSrcweir 469cdf0e10cSrcweir const SfxPoolItem *ppItems[] = { &aName, &aNewView, &aSilent, &aReadOnly, &aRefererItem, &aBrowse, NULL }; 470cdf0e10cSrcweir (((SvxHpLinkDlg*)mpDialog)->GetBindings())->Execute( SID_OPENDOC, ppItems, 0, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD ); 471cdf0e10cSrcweir 472cdf0e10cSrcweir return( 0L ); 473cdf0e10cSrcweir } 474cdf0e10cSrcweir 475cdf0e10cSrcweir /************************************************************************* 476cdf0e10cSrcweir |* 477cdf0e10cSrcweir |* Click on imagebutton : Target 478cdf0e10cSrcweir |* 479cdf0e10cSrcweir |************************************************************************/ 480cdf0e10cSrcweir 481cdf0e10cSrcweir IMPL_LINK ( SvxHyperlinkInternetTp, ClickTargetHdl_Impl, void *, EMPTYARG ) 482cdf0e10cSrcweir { 483cdf0e10cSrcweir RefreshMarkWindow(); 484cdf0e10cSrcweir ShowMarkWnd (); 485cdf0e10cSrcweir mbMarkWndOpen = IsMarkWndVisible (); 486cdf0e10cSrcweir 487cdf0e10cSrcweir return( 0L ); 488cdf0e10cSrcweir } 489cdf0e10cSrcweir 490cdf0e10cSrcweir void SvxHyperlinkInternetTp::RefreshMarkWindow() 491cdf0e10cSrcweir { 492cdf0e10cSrcweir if ( maRbtLinktypInternet.IsChecked() && IsMarkWndVisible() ) 493cdf0e10cSrcweir { 494cdf0e10cSrcweir EnterWait(); 495cdf0e10cSrcweir String aStrURL( CreateAbsoluteURL() ); 496cdf0e10cSrcweir if ( aStrURL != aEmptyStr ) 497cdf0e10cSrcweir mpMarkWnd->RefreshTree ( aStrURL ); 498cdf0e10cSrcweir else 499cdf0e10cSrcweir mpMarkWnd->SetError( LERR_DOCNOTOPEN ); 500cdf0e10cSrcweir LeaveWait(); 501cdf0e10cSrcweir } 502cdf0e10cSrcweir 503cdf0e10cSrcweir } 504cdf0e10cSrcweir 505cdf0e10cSrcweir /************************************************************************* 506cdf0e10cSrcweir |* 507cdf0e10cSrcweir |* Get String from Bookmark-Wnd 508cdf0e10cSrcweir |* 509cdf0e10cSrcweir |************************************************************************/ 510cdf0e10cSrcweir 511cdf0e10cSrcweir void SvxHyperlinkInternetTp::SetMarkStr ( String& aStrMark ) 512cdf0e10cSrcweir { 513cdf0e10cSrcweir String aStrURL ( maCbbTarget.GetText() ); 514cdf0e10cSrcweir 515cdf0e10cSrcweir const sal_Unicode sUHash = '#'; 516cdf0e10cSrcweir xub_StrLen nPos = aStrURL.SearchBackward( sUHash ); 517cdf0e10cSrcweir 518cdf0e10cSrcweir if( nPos != STRING_NOTFOUND ) 519cdf0e10cSrcweir aStrURL.Erase ( nPos ); 520cdf0e10cSrcweir 521cdf0e10cSrcweir aStrURL += sUHash; 522cdf0e10cSrcweir aStrURL += aStrMark; 523cdf0e10cSrcweir 524cdf0e10cSrcweir maCbbTarget.SetText ( aStrURL ); 525cdf0e10cSrcweir } 526cdf0e10cSrcweir 527cdf0e10cSrcweir /************************************************************************* 528cdf0e10cSrcweir |* 529cdf0e10cSrcweir |* Enable Browse-Button in subject to the office is in onlinemode 530cdf0e10cSrcweir |* 531cdf0e10cSrcweir |************************************************************************/ 532cdf0e10cSrcweir 533cdf0e10cSrcweir void SvxHyperlinkInternetTp::SetOnlineMode( sal_Bool /*bEnable*/ ) 534cdf0e10cSrcweir { 535cdf0e10cSrcweir // State of target-button in subject to the current url-string 536cdf0e10cSrcweir // ( Can't display any targets in an document, if there is no 537cdf0e10cSrcweir // valid url to a document ) 538cdf0e10cSrcweir String aStrCurrentTarget( maCbbTarget.GetText() ); 539cdf0e10cSrcweir aStrCurrentTarget.EraseTrailingChars(); 540cdf0e10cSrcweir 541cdf0e10cSrcweir if( aStrCurrentTarget == aEmptyStr || 542cdf0e10cSrcweir aStrCurrentTarget.EqualsIgnoreCaseAscii( sHTTPScheme ) || 543cdf0e10cSrcweir aStrCurrentTarget.EqualsIgnoreCaseAscii( sHTTPSScheme ) ) 544cdf0e10cSrcweir maBtTarget.Enable( sal_False ); 545cdf0e10cSrcweir else 546cdf0e10cSrcweir maBtTarget.Enable( sal_True ); 547cdf0e10cSrcweir } 548