diff options
author | Ingrid Halama <iha@openoffice.org> | 2002-10-15 10:54:23 +0000 |
---|---|---|
committer | Ingrid Halama <iha@openoffice.org> | 2002-10-15 10:54:23 +0000 |
commit | d426a0fc0a3619e70e32c4571e949b92368cc07d (patch) | |
tree | 54f7c52c56cceaeea5565ae0e7c6790fe1b51d9d | |
parent | b75084b1ba4e8544d1326672a012c7d312f5744c (diff) |
#90407# less automatic protocol insertion; + centralized better automatic name creation
-rw-r--r-- | svx/source/dialog/hldocntp.cxx | 21 | ||||
-rw-r--r-- | svx/source/dialog/hldoctp.cxx | 22 | ||||
-rw-r--r-- | svx/source/dialog/hlinettp.cxx | 579 | ||||
-rw-r--r-- | svx/source/dialog/hlmailtp.cxx | 251 | ||||
-rw-r--r-- | svx/source/dialog/hltpbase.cxx | 41 |
5 files changed, 330 insertions, 584 deletions
diff --git a/svx/source/dialog/hldocntp.cxx b/svx/source/dialog/hldocntp.cxx index 9a2dc6b7f93f..03e5c5a4c494 100644 --- a/svx/source/dialog/hldocntp.cxx +++ b/svx/source/dialog/hldocntp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: hldocntp.cxx,v $ * - * $Revision: 1.21 $ + * $Revision: 1.22 $ * - * last change: $Author: iha $ $Date: 2002-10-08 16:46:17 $ + * last change: $Author: iha $ $Date: 2002-10-15 11:54:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -577,20 +577,3 @@ IMPL_LINK ( SvxHyperlinkNewDocTp, ClickNewHdl_Impl, void *, EMPTYARG ) } return( 0L ); } - -String SvxHyperlinkNewDocTp::CreateUiNameFromURL( const String& aStrURL ) -{ - String aStrUiURL; - INetURLObject aURLObj( aStrURL ); - - if( aURLObj.GetProtocol() == INET_PROT_FILE ) - { - utl::LocalFileHelper::ConvertURLToSystemPath( aURLObj.GetMainURL(INetURLObject::NO_DECODE), aStrUiURL ); - } - else - { - aStrUiURL = aURLObj.GetMainURL(INetURLObject::DECODE_UNAMBIGUOUS); - } - - return aStrUiURL; -} diff --git a/svx/source/dialog/hldoctp.cxx b/svx/source/dialog/hldoctp.cxx index 209fa0553752..b6ec1b439490 100644 --- a/svx/source/dialog/hldoctp.cxx +++ b/svx/source/dialog/hldoctp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: hldoctp.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: iha $ $Date: 2002-10-08 16:42:27 $ + * last change: $Author: iha $ $Date: 2002-10-15 11:53:26 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -456,21 +456,3 @@ SvxHyperlinkDocTp::EPathType SvxHyperlinkDocTp::GetPathType ( String& aStrPath ) return Type_Unknown; } - - -String SvxHyperlinkDocTp::CreateUiNameFromURL( const String& aStrURL ) -{ - String aStrUiURL; - INetURLObject aURLObj( aStrURL ); - - if( aURLObj.GetProtocol() == INET_PROT_FILE ) - { - utl::LocalFileHelper::ConvertURLToSystemPath( aURLObj.GetMainURL(INetURLObject::NO_DECODE), aStrUiURL ); - } - else - { - aStrUiURL = aURLObj.GetMainURL(INetURLObject::DECODE_UNAMBIGUOUS); - } - - return aStrUiURL; -} diff --git a/svx/source/dialog/hlinettp.cxx b/svx/source/dialog/hlinettp.cxx index 8c76338a4426..aea29e7784fd 100644 --- a/svx/source/dialog/hlinettp.cxx +++ b/svx/source/dialog/hlinettp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: hlinettp.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: iha $ $Date: 2002-10-08 16:39:49 $ + * last change: $Author: iha $ $Date: 2002-10-15 11:52:00 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -76,7 +76,6 @@ #define STD_DOC_NAME "url_transfer.htm" sal_Char __READONLY_DATA sAnonymous[] = "anonymous"; -sal_Char __READONLY_DATA sTelnet[] = "telnet"; sal_Char __READONLY_DATA sHTTPScheme[] = INET_HTTP_SCHEME; sal_Char __READONLY_DATA sHTTPSScheme[] = INET_HTTPS_SCHEME; sal_Char __READONLY_DATA sFTPScheme[] = INET_FTP_SCHEME; @@ -151,9 +150,9 @@ SvxHyperlinkInternetTp::SvxHyperlinkInternetTp ( Window *pParent, /////////////////////////////////////// // overload handlers - maRbtLinktypInternet.SetClickHdl( LINK ( this, SvxHyperlinkInternetTp, ClickTypeInternetHdl_Impl ) ); - maRbtLinktypFTP.SetClickHdl ( LINK ( this, SvxHyperlinkInternetTp, ClickTypeFTPHdl_Impl ) ); - maRbtLinktypTelnet.SetClickHdl ( LINK ( this, SvxHyperlinkInternetTp, ClickTypeTelnetHdl_Impl ) ); + maRbtLinktypInternet.SetClickHdl( LINK ( this, SvxHyperlinkInternetTp, Click_SmartProtocol_Impl ) ); + maRbtLinktypFTP.SetClickHdl ( LINK ( this, SvxHyperlinkInternetTp, Click_SmartProtocol_Impl ) ); + maRbtLinktypTelnet.SetClickHdl ( LINK ( this, SvxHyperlinkInternetTp, Click_SmartProtocol_Impl ) ); maCbAnonymous.SetClickHdl ( LINK ( this, SvxHyperlinkInternetTp, ClickAnonymousHdl_Impl ) ); maBtBrowse.SetClickHdl ( LINK ( this, SvxHyperlinkInternetTp, ClickBrowseHdl_Impl ) ); maBtTarget.SetClickHdl ( LINK ( this, SvxHyperlinkInternetTp, ClickTargetHdl_Impl ) ); @@ -178,130 +177,18 @@ SvxHyperlinkInternetTp::~SvxHyperlinkInternetTp () void SvxHyperlinkInternetTp::FillDlgFields ( String& aStrURL ) { INetURLObject aURL( aStrURL ); - String aStrScheme; - - // set protocoll-radiobuttons - - INetProtocol aProtocol = ImplGetProtocol( aStrURL, aStrScheme ); - switch ( aProtocol ) - { - case INET_PROT_HTTP : - { - maRbtLinktypInternet.Check (); - maRbtLinktypFTP.Check (FALSE); - maRbtLinktypTelnet.Check (FALSE); - - maFtLogin.Show( FALSE ); - maFtPassword.Show( FALSE ); - maEdLogin.Show( FALSE ); - maEdPassword.Show( FALSE ); - maCbAnonymous.Show( FALSE ); - - maBtTarget.Enable(); - - if ( mbMarkWndOpen ) - ShowMarkWnd (); - maCbbTarget.SetSmartProtocol( INET_PROT_HTTP ); - } - break; - - case INET_PROT_HTTPS : - { - maRbtLinktypInternet.Check (); - maRbtLinktypFTP.Check (FALSE); - maRbtLinktypTelnet.Check (FALSE); - - maFtLogin.Show( FALSE ); - maFtPassword.Show( FALSE ); - maEdLogin.Show( FALSE ); - maEdPassword.Show( FALSE ); - maCbAnonymous.Show( FALSE ); - - maBtTarget.Enable(); - - if ( mbMarkWndOpen ) - HideMarkWnd (); - maCbbTarget.SetSmartProtocol( INET_PROT_HTTP ); - } - break; - - case INET_PROT_FTP : - { - maRbtLinktypInternet.Check (FALSE); - maRbtLinktypFTP.Check (); - maRbtLinktypTelnet.Check (FALSE); - - maFtLogin.Show( TRUE ); - maFtPassword.Show( TRUE ); - maEdLogin.Show( TRUE ); - maEdPassword.Show( TRUE ); - maCbAnonymous.Show( TRUE ); - - maBtTarget.Disable(); - - if ( mbMarkWndOpen ) - HideMarkWnd (); - maCbbTarget.SetSmartProtocol( INET_PROT_FTP ); - } - break; - - default : - String aStrTmp ( aStrURL ); - if ( aStrTmp.ToLowerAscii().SearchAscii( sTelnet ) == 0 ) - { - maRbtLinktypInternet.Check (FALSE); - maRbtLinktypFTP.Check (FALSE); - maRbtLinktypTelnet.Check (); - - maBtTarget.Disable(); - - if ( mbMarkWndOpen ) - HideMarkWnd (); - - aStrScheme.AssignAscii( RTL_CONSTASCII_STRINGPARAM( sTelnetScheme ) ); - - maCbbTarget.SetSmartProtocol( INET_PROT_FILE ); - } - else - { // as default : HTTP-Protocoll - maRbtLinktypInternet.Check (); - maRbtLinktypFTP.Check (FALSE); - maRbtLinktypTelnet.Check (FALSE); - } - - maFtLogin.Show( FALSE ); - maFtPassword.Show( FALSE ); - maEdLogin.Show( FALSE ); - maEdPassword.Show( FALSE ); - maCbAnonymous.Show( FALSE ); - break; - } + String aStrScheme = GetSchemeFromURL( aStrURL ); - // Username / Password - if ( aProtocol == INET_PROT_FTP ) + // set additional controls for FTP: Username / Password + if ( aStrScheme.SearchAscii( sFTPScheme ) == 0 ) { - String aUserName ( aURL.GetUser() ); - - if ( aUserName.ToLowerAscii().SearchAscii ( sAnonymous ) == 0 ) - { - maCbAnonymous.Check(); - maFtLogin.Disable (); - maFtPassword.Disable (); - - maEdLogin.SetText ( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( sAnonymous ) ) ); - SvAddressParser aAddress( SvtUserOptions().GetEmail() ); - maEdPassword.SetText( aAddress.Count() ? aAddress.GetEmailAddress(0) : String() ); - } + if ( aURL.GetUser().ToLowerAscii().SearchAscii ( sAnonymous ) == 0 ) + setAnonymousFTPUser(); else - { - maEdLogin.SetText ( aURL.GetUser() ); - maEdPassword.SetText ( aURL.GetPass() ); - maFtLogin.Enable (); - maFtPassword.Enable (); + setFTPUser(aURL.GetUser(), aURL.GetPass()); - maStrOldUser = maEdLogin.GetText(); - maStrOldPassword = maEdPassword.GetText(); - } + //do not show password and user in url + aURL.SetUserAndPass(aEmptyStr,aEmptyStr); } // set URL-field @@ -316,16 +203,32 @@ void SvxHyperlinkInternetTp::FillDlgFields ( String& aStrURL ) else maCbbTarget.SetText ( aEmptyStr ); - // State of target-button - String aStrCurrentTarget( maCbbTarget.GetText() ); - aStrCurrentTarget.EraseTrailingChars(); + SetScheme( aStrScheme ); +} - if( aStrCurrentTarget == aEmptyStr || - aStrCurrentTarget.EqualsIgnoreCaseAscii( sHTTPScheme ) || - aStrCurrentTarget.EqualsIgnoreCaseAscii( sHTTPSScheme ) ) - maBtTarget.Enable( FALSE ); - else - maBtTarget.Enable( TRUE ); +void SvxHyperlinkInternetTp::setAnonymousFTPUser() +{ + maEdLogin.SetText( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM ( sAnonymous ) ) ); + SvAddressParser aAddress( SvtUserOptions().GetEmail() ); + maEdPassword.SetText( aAddress.Count() ? aAddress.GetEmailAddress(0) : String() ); + + maFtLogin.Disable (); + maFtPassword.Disable (); + maEdLogin.Disable (); + maEdPassword.Disable (); + maCbAnonymous.Check(); +} + +void SvxHyperlinkInternetTp::setFTPUser(const String& rUser, const String& rPassword) +{ + maEdLogin.SetText ( rUser ); + maEdPassword.SetText ( rPassword ); + + maFtLogin.Enable (); + maFtPassword.Enable (); + maEdLogin.Enable (); + maEdPassword.Enable (); + maCbAnonymous.Check(FALSE); } /************************************************************************* @@ -338,38 +241,55 @@ void SvxHyperlinkInternetTp::GetCurentItemData ( String& aStrURL, String& aStrNa String& aStrIntName, String& aStrFrame, SvxLinkInsertMode& eMode ) { - String aStrScheme; + aStrURL = CreateAbsoluteURL(); + GetDataFromCommonFields( aStrName, aStrIntName, aStrFrame, eMode ); +} - // get data from dialog-controls - aStrURL = maCbbTarget.GetText(); +String SvxHyperlinkInternetTp::CreateAbsoluteURL() const +{ + String aStrURL = maCbbTarget.GetText(); + String aScheme = GetSchemeFromURL(aStrURL); - if ( maRbtLinktypInternet.IsChecked() && aStrURL.SearchAscii( sHTTPScheme ) != 0 ) - { - if ( aStrURL.SearchAscii( sHTTPSScheme ) != 0 ) - aStrScheme.AssignAscii( RTL_CONSTASCII_STRINGPARAM ( sHTTPScheme ) ); + //special handling for telnet (as it is not known as valid INetProtocol ) + if( aScheme.SearchAscii( sTelnetScheme ) == 0 ) + return aStrURL; - } else if ( maRbtLinktypFTP.IsChecked() && aStrURL.SearchAscii( sFTPScheme ) != 0 ) - { - aStrScheme.AssignAscii( RTL_CONSTASCII_STRINGPARAM ( sFTPScheme ) ); - } else if ( maRbtLinktypTelnet.IsChecked() && aStrURL.SearchAscii( sTelnetScheme ) != 0 ) + INetURLObject aURL(aStrURL); + + if( aURL.GetProtocol() == INET_PROT_NOT_VALID ) { - aStrScheme.AssignAscii( RTL_CONSTASCII_STRINGPARAM( sTelnetScheme ) ); - } + aURL.SetSmartProtocol( GetSmartProtocolFromButtons() ); + aURL.SetSmartURL(aStrURL); + + if( aURL.GetProtocol() == INET_PROT_NOT_VALID + && aScheme.Len() == 0 ) + { + //first check wether it should be telnet: + if( maRbtLinktypTelnet.IsChecked() ) //add 'telnet:' + { + String aTelnet; + aTelnet.AssignAscii( RTL_CONSTASCII_STRINGPARAM( sTelnetScheme ) ); + aTelnet += aStrURL; + return aTelnet; + } - String aStrTmp( aStrScheme ); - aStrTmp += aStrURL; - INetURLObject aURL ( aStrTmp ); + //try wether this might be a relative link to the local fileystem + aURL.SetSmartURL( SvtPathOptions().GetWorkPath() ); + if( !aURL.hasFinalSlash() ) + aURL.setFinalSlash(); + aURL.Append( aStrURL ); + } + } // username and password for ftp-url - if ( maRbtLinktypFTP.IsChecked() ) - { + if( aURL.GetProtocol() == INET_PROT_FTP ) aURL.SetUserAndPass ( maEdLogin.GetText(), maEdPassword.GetText() ); - } + if ( aURL.GetProtocol() != INET_PROT_NOT_VALID ) - aStrURL = aURL.GetMainURL( INetURLObject::DECODE_WITH_CHARSET ); + return aURL.GetMainURL( INetURLObject::DECODE_WITH_CHARSET ); - GetDataFromCommonFields( aStrName, aStrIntName, aStrFrame, eMode ); + return aEmptyStr; } /************************************************************************* @@ -402,73 +322,9 @@ void SvxHyperlinkInternetTp::SetInitFocus() IMPL_LINK ( SvxHyperlinkInternetTp, ModifiedTargetHdl_Impl, void *, EMPTYARG ) { - String aStrCurrentTarget( maCbbTarget.GetText() ); - aStrCurrentTarget.EraseTrailingChars(); - - if( aStrCurrentTarget == aEmptyStr || - aStrCurrentTarget.EqualsIgnoreCaseAscii( sHTTPScheme ) || - aStrCurrentTarget.EqualsIgnoreCaseAscii( sHTTPSScheme ) ) - maBtTarget.Enable( FALSE ); - else - maBtTarget.Enable( TRUE ); - - // changed scheme ? - Then change radiobutton-settings - if( ( aStrCurrentTarget.SearchAscii( sHTTPScheme ) == 0 && - !maRbtLinktypInternet.IsChecked() ) || - ( aStrCurrentTarget.SearchAscii( sHTTPSScheme ) == 0 && - !maRbtLinktypInternet.IsChecked() ) ) - { - maRbtLinktypInternet.Check(); - maRbtLinktypFTP.Check(FALSE); - maRbtLinktypTelnet.Check(FALSE); - - maFtLogin.Show( FALSE ); - maFtPassword.Show( FALSE ); - maEdLogin.Show( FALSE ); - maEdPassword.Show( FALSE ); - maCbAnonymous.Show( FALSE ); - - maBtTarget.Enable(); - - if ( mbMarkWndOpen ) - ShowMarkWnd (); - } - else if( aStrCurrentTarget.SearchAscii( sFTPScheme ) == 0 && - !maRbtLinktypFTP.IsChecked() ) - { - maRbtLinktypInternet.Check(FALSE); - maRbtLinktypFTP.Check(); - maRbtLinktypTelnet.Check(FALSE); - - maFtLogin.Show( TRUE ); - maFtPassword.Show( TRUE ); - maEdLogin.Show( TRUE ); - maEdPassword.Show( TRUE ); - maCbAnonymous.Show( TRUE ); - - maBtTarget.Disable(); - - if ( mbMarkWndOpen ) - HideMarkWnd (); - } - else if( aStrCurrentTarget.SearchAscii( sTelnetScheme ) == 0 && - !maRbtLinktypTelnet.IsChecked() ) - { - maRbtLinktypInternet.Check(FALSE); - maRbtLinktypFTP.Check(FALSE); - maRbtLinktypTelnet.Check(); - - maFtLogin.Show( FALSE ); - maFtPassword.Show( FALSE ); - maEdLogin.Show( FALSE ); - maEdPassword.Show( FALSE ); - maCbAnonymous.Show( FALSE ); - - maBtTarget.Disable(); - - if ( mbMarkWndOpen ) - HideMarkWnd (); - } + String aScheme = GetSchemeFromURL( maCbbTarget.GetText() ); + if(aScheme.Len()!=0) + SetScheme( aScheme ); // start timer maTimer.SetTimeout( 2500 ); @@ -485,19 +341,7 @@ IMPL_LINK ( SvxHyperlinkInternetTp, ModifiedTargetHdl_Impl, void *, EMPTYARG ) IMPL_LINK ( SvxHyperlinkInternetTp, TimeoutHdl_Impl, Timer *, EMPTYARG ) { - if ( maRbtLinktypInternet.IsChecked() && IsMarkWndVisible() ) - { - String aStrURL( maCbbTarget.GetText() ); - - if ( !aStrURL.EqualsIgnoreCaseAscii( sHTTPScheme ) && - !aStrURL.EqualsIgnoreCaseAscii( sHTTPSScheme ) ) - { - EnterWait(); - mpMarkWnd->RefreshTree ( aStrURL ); - LeaveWait(); - } - } - + RefreshMarkWindow(); return( 0L ); } @@ -516,24 +360,79 @@ IMPL_LINK ( SvxHyperlinkInternetTp, ModifiedLoginHdl_Impl, void *, EMPTYARG ) ClickAnonymousHdl_Impl(NULL); } - ModifiedTargetHdl_Impl (NULL); - return( 0L ); } /************************************************************************* +|************************************************************************/ + +void SvxHyperlinkInternetTp::SetScheme( const String& aScheme ) +{ + //if aScheme is empty or unknown the default beaviour is like it where HTTP + + BOOL bFTP = aScheme.SearchAscii( sFTPScheme ) == 0; + BOOL bTelnet = FALSE; + if( !bFTP ) + bTelnet = aScheme.SearchAscii( sTelnetScheme ) == 0; + BOOL bInternet = !(bFTP || bTelnet); + + //update protocol button selection: + maRbtLinktypFTP.Check(bFTP); + maRbtLinktypTelnet.Check(bTelnet); + maRbtLinktypInternet.Check(bInternet); + + //update target: + RemoveImproperProtocol(aScheme); + maCbbTarget.SetSmartProtocol( GetSmartProtocolFromButtons() ); + + //show/hide special fields for FTP: + maFtLogin.Show( bFTP ); + maFtPassword.Show( bFTP ); + maEdLogin.Show( bFTP ); + maEdPassword.Show( bFTP ); + maCbAnonymous.Show( bFTP ); + + //update 'link target in document'-window and opening-button + if( aScheme.SearchAscii( sHTTPScheme ) == 0 ) + { + maBtTarget.Enable(); + if ( mbMarkWndOpen ) + ShowMarkWnd (); + } + else + { + //disable for https, ftp and telnet + maBtTarget.Disable(); + if ( mbMarkWndOpen ) + HideMarkWnd (); + } +} + +/************************************************************************* |* -|* Change Scheme-String +|* Remove protocol if it does not fit to the current button selection |* |************************************************************************/ -void SvxHyperlinkInternetTp::ChangeScheme ( String& aStrURL, String aStrNewScheme ) +void SvxHyperlinkInternetTp::RemoveImproperProtocol(const String& aProperScheme) { + String aStrURL ( maCbbTarget.GetText() ); if ( aStrURL != aEmptyStr ) { - String aStrScheme; + String aStrScheme = GetSchemeFromURL( aStrURL ); + if ( aStrScheme != aEmptyStr && aStrScheme != aProperScheme ) + { + aStrURL.Erase ( 0, aStrScheme.Len() ); + maCbbTarget.SetText ( aStrURL ); + } + } +} - // set protocoll-radiobuttons +String SvxHyperlinkInternetTp::GetSchemeFromURL( String aStrURL ) const +{ + String aStrScheme; + if ( aStrURL != aEmptyStr ) + { INetProtocol aProtocol = ImplGetProtocol( aStrURL, aStrScheme ); switch ( aProtocol ) { @@ -543,117 +442,50 @@ void SvxHyperlinkInternetTp::ChangeScheme ( String& aStrURL, String aStrNewSchem break; default : { - String aStrTmp ( aStrURL ); - if ( aStrTmp.ToLowerAscii().SearchAscii( sTelnet ) == 0 ) - { - aStrScheme.AssignAscii( RTL_CONSTASCII_STRINGPARAM ( sTelnetScheme ) ); - } + if ( aStrURL.EqualsIgnoreCaseAscii( INET_TELNET_SCHEME, 0, 9 ) ) + aStrScheme = String::CreateFromAscii( INET_TELNET_SCHEME ); } } - if ( aStrScheme != aEmptyStr ) - { - String aStrTmp( aStrURL.Erase ( 0, aStrScheme.Len() ) ); - aStrURL = aStrNewScheme; - aStrURL += aStrTmp; - } } + return aStrScheme; } -/************************************************************************* -|* -|* Click on Radiobutton : Type Internet -|* -|************************************************************************/ - -IMPL_LINK ( SvxHyperlinkInternetTp, ClickTypeInternetHdl_Impl, void *, EMPTYARG ) +String SvxHyperlinkInternetTp::GetSchemeFromButtons() const { - if ( maRbtLinktypInternet.IsChecked() ) + if( maRbtLinktypFTP.IsChecked() ) { - maFtLogin.Show( FALSE ); - maFtPassword.Show( FALSE ); - maEdLogin.Show( FALSE ); - maEdPassword.Show( FALSE ); - maCbAnonymous.Show( FALSE ); - - maBtTarget.Enable(); - - if ( mbMarkWndOpen ) - ShowMarkWnd (); - - String aStrURL ( maCbbTarget.GetText() ); - ChangeScheme ( aStrURL, UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM ( sHTTPScheme ) ) ); - maCbbTarget.SetText ( aStrURL ); + return String::CreateFromAscii( INET_FTP_SCHEME ); } - - maCbbTarget.SetSmartProtocol( INET_PROT_HTTP ); - ModifiedTargetHdl_Impl (NULL); - - return( 0L ); + else if( maRbtLinktypTelnet.IsChecked() ) + { + return String::CreateFromAscii( INET_TELNET_SCHEME ); + } + return String::CreateFromAscii( INET_HTTP_SCHEME ); } -/************************************************************************* -|* -|* Click on Radiobutton : Type FTP -|* -|************************************************************************/ - -IMPL_LINK ( SvxHyperlinkInternetTp, ClickTypeFTPHdl_Impl, void *, EMPTYARG ) +INetProtocol SvxHyperlinkInternetTp::GetSmartProtocolFromButtons() const { - if ( maRbtLinktypFTP.IsChecked() ) + if( maRbtLinktypFTP.IsChecked() ) { - maFtLogin.Show( TRUE ); - maFtPassword.Show( TRUE ); - maEdLogin.Show( TRUE ); - maEdPassword.Show( TRUE ); - maCbAnonymous.Show( TRUE ); - - maBtTarget.Disable(); - - if ( mbMarkWndOpen ) - HideMarkWnd (); - - ClickAnonymousHdl_Impl(NULL); - - String aStrURL ( maCbbTarget.GetText() ); - ChangeScheme ( aStrURL, UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM ( sFTPScheme ) ) ); - maCbbTarget.SetText ( aStrURL ); + return INET_PROT_FTP; } - - maCbbTarget.SetSmartProtocol( INET_PROT_FTP ); - ModifiedTargetHdl_Impl (NULL); - - return( 0L ); + else if( maRbtLinktypTelnet.IsChecked() ) + { + return INET_PROT_NOT_VALID; //there is no INET_PROT_XXX known for telnet; to return invalid here is necessary for a correct detection in method 'CreateAbsoluteURL' + } + return INET_PROT_HTTP; } /************************************************************************* |* -|* Click on Radiobutton : Type Telnet +|* Click on Radiobutton : Internet, FTP or Telnet |* |************************************************************************/ -IMPL_LINK ( SvxHyperlinkInternetTp, ClickTypeTelnetHdl_Impl, void *, EMPTYARG ) +IMPL_LINK ( SvxHyperlinkInternetTp, Click_SmartProtocol_Impl, void*, EMPTYARG ) { - if ( maRbtLinktypTelnet.IsChecked() ) - { - maFtLogin.Show( FALSE ); - maFtPassword.Show( FALSE ); - maEdLogin.Show( FALSE ); - maEdPassword.Show( FALSE ); - maCbAnonymous.Show( FALSE ); - - maBtTarget.Disable(); - - if ( mbMarkWndOpen ) - HideMarkWnd (); - - String aStrURL ( maCbbTarget.GetText() ); - ChangeScheme ( aStrURL, UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM ( sTelnetScheme ) ) ); - maCbbTarget.SetText ( aStrURL ); - } - - maCbbTarget.SetSmartProtocol( INET_PROT_FILE ); - ModifiedTargetHdl_Impl(NULL); - + String aScheme = GetSchemeFromButtons(); + SetScheme( aScheme ); return( 0L ); } @@ -679,27 +511,10 @@ IMPL_LINK ( SvxHyperlinkInternetTp, ClickAnonymousHdl_Impl, void *, EMPTYARG ) maStrOldPassword = maEdPassword.GetText(); } - SvAddressParser aAddress( SvtUserOptions().GetEmail() ); - maEdLogin.SetText( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM ( sAnonymous ) ) ); - maEdPassword.SetText( aAddress.Count() ? aAddress.GetEmailAddress(0) : String() ); - - maFtLogin.Disable (); - maFtPassword.Disable (); - maEdLogin.Disable (); - maEdPassword.Disable (); + setAnonymousFTPUser(); } else - { - maEdLogin.SetText ( maStrOldUser ); - maEdPassword.SetText ( maStrOldPassword ); - - maFtLogin.Enable (); - maFtPassword.Enable (); - maEdLogin.Enable (); - maEdPassword.Enable (); - } - - ModifiedTargetHdl_Impl(NULL); + setFTPUser(maStrOldUser, maStrOldPassword); return( 0L ); } @@ -712,43 +527,7 @@ IMPL_LINK ( SvxHyperlinkInternetTp, ClickAnonymousHdl_Impl, void *, EMPTYARG ) IMPL_LINK ( SvxHyperlinkInternetTp, LostFocusTargetHdl_Impl, void *, EMPTYARG ) { - String aStrURL ( maCbbTarget.GetText() ); - String aStrScheme; - - if( maRbtLinktypInternet.IsChecked() && - aStrURL.SearchAscii( sHTTPScheme ) != 0 ) - { - if( aStrURL.SearchAscii( sHTTPSScheme ) != 0 ) - aStrScheme.AssignAscii( RTL_CONSTASCII_STRINGPARAM ( sHTTPScheme ) ); - } else if( maRbtLinktypFTP.IsChecked() && - aStrURL.SearchAscii( sFTPScheme ) != 0 ) - { - aStrScheme.AssignAscii( RTL_CONSTASCII_STRINGPARAM ( sFTPScheme ) ); - } else if( maRbtLinktypTelnet.IsChecked() && - aStrURL.SearchAscii( sTelnetScheme ) != 0 ) - { - aStrScheme.AssignAscii( RTL_CONSTASCII_STRINGPARAM ( sTelnetScheme ) ); - } - - if( aStrURL != aEmptyStr ) - { - String aStrTarget ( aStrScheme ); - aStrTarget += aStrURL; - maCbbTarget.SetText ( aStrTarget ); - - // #95306# setting cursor to end of string - maCbbTarget.SetSelection ( Selection( aStrTarget.Len() ) ); - } - - if ( maRbtLinktypInternet.IsChecked() && aStrURL.Len()!=0 && IsMarkWndVisible() ) - { - EnterWait(); - mpMarkWnd->RefreshTree ( maCbbTarget.GetText() ); - LeaveWait(); - } - - ModifiedTargetHdl_Impl ( NULL ); - + RefreshMarkWindow(); return (0L); } @@ -786,24 +565,26 @@ IMPL_LINK ( SvxHyperlinkInternetTp, ClickBrowseHdl_Impl, void *, EMPTYARG ) IMPL_LINK ( SvxHyperlinkInternetTp, ClickTargetHdl_Impl, void *, EMPTYARG ) { - if ( maRbtLinktypInternet.IsChecked() ) + RefreshMarkWindow(); + ShowMarkWnd (); + mbMarkWndOpen = IsMarkWndVisible (); + + return( 0L ); +} + +void SvxHyperlinkInternetTp::RefreshMarkWindow() +{ + if ( maRbtLinktypInternet.IsChecked() && IsMarkWndVisible() ) { - String aStrURL( maCbbTarget.GetText() ); EnterWait(); - if ( !aStrURL.EqualsIgnoreCaseAscii( sHTTPScheme ) && - !aStrURL.EqualsIgnoreCaseAscii(sHTTPSScheme ) && - aStrURL != aEmptyStr ) + String aStrURL( CreateAbsoluteURL() ); + if ( aStrURL != aEmptyStr ) mpMarkWnd->RefreshTree ( aStrURL ); else mpMarkWnd->SetError( LERR_DOCNOTOPEN ); LeaveWait(); } - ShowMarkWnd (); - - mbMarkWndOpen = IsMarkWndVisible (); - - return( 0L ); } /************************************************************************* @@ -849,5 +630,3 @@ void SvxHyperlinkInternetTp::SetOnlineMode( BOOL bEnable ) else maBtTarget.Enable( TRUE ); } - - diff --git a/svx/source/dialog/hlmailtp.cxx b/svx/source/dialog/hlmailtp.cxx index fe31a9c32575..e7ce80c17ceb 100644 --- a/svx/source/dialog/hlmailtp.cxx +++ b/svx/source/dialog/hlmailtp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: hlmailtp.cxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: iha $ $Date: 2002-10-08 16:37:57 $ + * last change: $Author: iha $ $Date: 2002-10-15 11:51:03 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -79,6 +79,10 @@ #include <sfx2/viewfrm.hxx> #endif +#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX +#include <svtools/pathoptions.hxx> +#endif + #include "hlmailtp.hxx" #include "hyperdlg.hrc" @@ -123,11 +127,9 @@ SvxHyperlinkMailTp::SvxHyperlinkMailTp ( Window *pParent, const SfxItemSet& rIte maRbtMail.Check (); // overload handlers - maRbtMail.SetClickHdl ( LINK ( this, SvxHyperlinkMailTp, ClickTypeEMailHdl_Impl ) ); - maRbtNews.SetClickHdl ( LINK ( this, SvxHyperlinkMailTp, ClickTypeNewsHdl_Impl ) ); + maRbtMail.SetClickHdl ( LINK ( this, SvxHyperlinkMailTp, Click_SmartProtocol_Impl ) ); + maRbtNews.SetClickHdl ( LINK ( this, SvxHyperlinkMailTp, Click_SmartProtocol_Impl ) ); maBtAdrBook.SetClickHdl ( LINK ( this, SvxHyperlinkMailTp, ClickAdrBookHdl_Impl ) ); - - maCbbReceiver.SetLoseFocusHdl( LINK ( this, SvxHyperlinkMailTp, LostFocusReceiverHdl_Impl ) ); maCbbReceiver.SetModifyHdl ( LINK ( this, SvxHyperlinkMailTp, ModifiedReceiverHdl_Impl) ); } @@ -143,41 +145,17 @@ SvxHyperlinkMailTp::~SvxHyperlinkMailTp () void SvxHyperlinkMailTp::FillDlgFields ( String& aStrURL ) { - String aStrScheme; - INetProtocol eProtocol = ImplGetProtocol( aStrURL, aStrScheme ); - switch ( eProtocol ) - { - case INET_PROT_MAILTO : - maRbtMail.Check (); - maRbtNews.Check (FALSE); - - maFtSubject.Enable(); - maEdSubject.Enable(); - - aStrScheme.AssignAscii( RTL_CONSTASCII_STRINGPARAM( INET_MAILTO_SCHEME ) ); - - break; - case INET_PROT_NEWS : - maRbtMail.Check (FALSE); - maRbtNews.Check (); - - maFtSubject.Disable(); - maEdSubject.Disable(); - - aStrScheme.AssignAscii( RTL_CONSTASCII_STRINGPARAM( INET_NEWS_SCHEME ) ); - - break; - default: - maRbtMail.Check (); - maRbtNews.Check (FALSE); + const sal_Char sMailtoScheme[] = INET_MAILTO_SCHEME; - break; - } + INetURLObject aURL( aStrURL ); + String aStrScheme = GetSchemeFromURL( aStrURL ); + // set URL-field and additional controls if ( aStrScheme != aEmptyStr ) { String aStrURLc ( aStrURL ); - if ( eProtocol == INET_PROT_MAILTO ) + // set additional controls for EMail: + if ( aStrScheme.SearchAscii( sMailtoScheme ) == 0 ) { // Find mail-subject String aStrSubject, aStrTmp ( aStrURLc ); @@ -199,7 +177,6 @@ void SvxHyperlinkMailTp::FillDlgFields ( String& aStrURL ) else { maEdSubject.SetText (aEmptyStr); - maEdSubject.SetText ( aEmptyStr ); } maCbbReceiver.SetText ( aStrURLc ); @@ -209,6 +186,8 @@ void SvxHyperlinkMailTp::FillDlgFields ( String& aStrURL ) maCbbReceiver.SetText ( aEmptyStr ); maEdSubject.SetText ( aEmptyStr ); } + + SetScheme( aStrScheme ); } /************************************************************************* @@ -221,31 +200,48 @@ void SvxHyperlinkMailTp::GetCurentItemData ( String& aStrURL, String& aStrName, String& aStrIntName, String& aStrFrame, SvxLinkInsertMode& eMode ) { - const sal_Char sMailtoScheme[] = INET_MAILTO_SCHEME; - const sal_Char sNewsScheme[] = INET_NEWS_SCHEME; + aStrURL = CreateAbsoluteURL(); + GetDataFromCommonFields( aStrName, aStrIntName, aStrFrame, eMode ); +} + +String SvxHyperlinkMailTp::CreateAbsoluteURL() const +{ + String aStrURL = maCbbReceiver.GetText(); + String aScheme = GetSchemeFromURL(aStrURL); + + INetURLObject aURL(aStrURL); - // fill aStrURL - String aStrScheme, aText = maCbbReceiver.GetText(); - if(aText.Len()!=0) //do not create a nonsense URL if no receiver is given + if( aURL.GetProtocol() == INET_PROT_NOT_VALID ) { - if ( maRbtMail.IsChecked() && aText.SearchAscii( sMailtoScheme ) != 0 ) - aStrScheme.AssignAscii( RTL_CONSTASCII_STRINGPARAM( INET_MAILTO_SCHEME ) ); - else if ( maRbtNews.IsChecked() && aText.SearchAscii( sNewsScheme ) != 0 ) - aStrScheme.AssignAscii( RTL_CONSTASCII_STRINGPARAM( INET_NEWS_SCHEME ) ); - aStrURL = aStrScheme; - aStrURL.Append( aText ); - if ( maRbtMail.IsChecked() ) + aURL.SetSmartProtocol( GetSmartProtocolFromButtons() ); + aURL.SetSmartURL(aStrURL); + + if( aURL.GetProtocol() == INET_PROT_NOT_VALID + && aScheme.Len() == 0 ) { - if ( maEdSubject.GetText() != aEmptyStr ) - { - aStrURL.Append( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "?subject=" ) ) ); - aStrURL.Append( maEdSubject.GetText() ); - } + //try wether this might be a relative link to the local fileystem + aURL.SetSmartURL( SvtPathOptions().GetWorkPath() ); + if( !aURL.hasFinalSlash() ) + aURL.setFinalSlash(); + aURL.Append( aStrURL ); } } - // fill the other parameters - GetDataFromCommonFields( aStrName, aStrIntName, aStrFrame, eMode ); + // subject for EMail-url + if( aURL.GetProtocol() == INET_PROT_MAILTO ) + { + if ( maEdSubject.GetText() != aEmptyStr ) + { + String aQuery = UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "subject=" ) ); + aQuery.Append( maEdSubject.GetText() ); + aURL.SetParam(aQuery); + } + } + + if ( aURL.GetProtocol() != INET_PROT_NOT_VALID ) + return aURL.GetMainURL( INetURLObject::DECODE_WITH_CHARSET ); + + return aEmptyStr; } /************************************************************************* @@ -271,128 +267,99 @@ void SvxHyperlinkMailTp::SetInitFocus() } /************************************************************************* -|* -|* Change Scheme-String -|* |************************************************************************/ -void SvxHyperlinkMailTp::ChangeScheme ( String& aStrURL, String aStrNewScheme ) +void SvxHyperlinkMailTp::SetScheme( const String& aScheme ) { - INetURLObject aURL ( aStrURL ); - String aStrScheme; - INetProtocol aProtocol = ImplGetProtocol( aStrURL, aStrScheme ); - if ( aStrScheme != aEmptyStr ) - { - String aStrTmp( aStrURL.Erase ( 0, aStrScheme.Len() ) ); - aStrURL = aStrNewScheme; - aStrURL += aStrTmp; - } -} - -/************************************************************************* -|* -|* Click on radiobutton : Type EMail -|* -|************************************************************************/ + //if aScheme is empty or unknown the default beaviour is like it where MAIL + const sal_Char sNewsScheme[] = INET_NEWS_SCHEME; -IMPL_LINK ( SvxHyperlinkMailTp, ClickTypeEMailHdl_Impl, void *, EMPTYARG ) -{ - maFtSubject.Enable(); - maEdSubject.Enable(); + BOOL bMail = aScheme.SearchAscii( sNewsScheme ) != 0; - String aStrURL ( maCbbReceiver.GetText() ); - ChangeScheme ( aStrURL, UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM ( INET_MAILTO_SCHEME ) ) ); - maCbbReceiver.SetText ( aStrURL ); + //update protocol button selection: + maRbtMail.Check(bMail); + maRbtNews.Check(!bMail); - ModifiedReceiverHdl_Impl (NULL); + //update target: + RemoveImproperProtocol(aScheme); + maCbbReceiver.SetSmartProtocol( GetSmartProtocolFromButtons() ); - return( 0L ); + //show/hide special fields for MAIL: + maFtSubject.Enable(bMail); + maEdSubject.Enable(bMail); } /************************************************************************* |* -|* Click on radiobutton : Type News +|* Remove protocol if it does not fit to the current button selection |* |************************************************************************/ -IMPL_LINK ( SvxHyperlinkMailTp, ClickTypeNewsHdl_Impl, void *, EMPTYARG ) +void SvxHyperlinkMailTp::RemoveImproperProtocol(const String& aProperScheme) { - maFtSubject.Disable(); - maEdSubject.Disable(); - String aStrURL ( maCbbReceiver.GetText() ); - ChangeScheme ( aStrURL, UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM ( INET_NEWS_SCHEME ) ) ); - maCbbReceiver.SetText ( aStrURL ); + if ( aStrURL != aEmptyStr ) + { + String aStrScheme = GetSchemeFromURL( aStrURL ); + if ( aStrScheme != aEmptyStr && aStrScheme != aProperScheme ) + { + aStrURL.Erase ( 0, aStrScheme.Len() ); + maCbbReceiver.SetText ( aStrURL ); + } + } +} - ModifiedReceiverHdl_Impl (NULL); +String SvxHyperlinkMailTp::GetSchemeFromURL( String aStrURL ) const +{ + String aStrScheme; + INetProtocol aProtocol = ImplGetProtocol( aStrURL, aStrScheme ); + return aStrScheme; +} - return( 0L ); +String SvxHyperlinkMailTp::GetSchemeFromButtons() const +{ + if( maRbtNews.IsChecked() ) + { + return String::CreateFromAscii( INET_NEWS_SCHEME ); + } + return String::CreateFromAscii( INET_MAILTO_SCHEME ); +} + +INetProtocol SvxHyperlinkMailTp::GetSmartProtocolFromButtons() const +{ + if( maRbtNews.IsChecked() ) + { + return INET_PROT_NEWS; + } + return INET_PROT_MAILTO; } /************************************************************************* |* -|* Contens of editfield "receiver" modified +|* Click on radiobutton : Type EMail |* |************************************************************************/ -IMPL_LINK ( SvxHyperlinkMailTp, ModifiedReceiverHdl_Impl, void *, EMPTYARG ) +IMPL_LINK ( SvxHyperlinkMailTp, Click_SmartProtocol_Impl, void *, EMPTYARG ) { - const sal_Char sMailtoScheme[] = INET_MAILTO_SCHEME; - const sal_Char sNewsScheme[] = INET_NEWS_SCHEME; - - String aStrCurrentReceiver( maCbbReceiver.GetText() ); - - // changed scheme ? - Then change radiobutton-settings - if( aStrCurrentReceiver.SearchAscii( sMailtoScheme ) == 0 && !maRbtMail.IsChecked() ) - { - maRbtMail.Check(); - maRbtNews.Check(FALSE); - maFtSubject.Enable(); - maEdSubject.Enable(); - } - else if( aStrCurrentReceiver.SearchAscii( sNewsScheme ) == 0 && !maRbtNews.IsChecked() ) - { - maRbtMail.Check(FALSE); - maRbtNews.Check(); - maFtSubject.Disable(); - maEdSubject.Disable(); - } - + String aScheme = GetSchemeFromButtons(); + SetScheme( aScheme ); return( 0L ); } /************************************************************************* |* -|* Combobox Receiver lost the focus +|* Contens of editfield "receiver" modified |* |************************************************************************/ -IMPL_LINK ( SvxHyperlinkMailTp, LostFocusReceiverHdl_Impl, void *, EMPTYARG ) +IMPL_LINK ( SvxHyperlinkMailTp, ModifiedReceiverHdl_Impl, void *, EMPTYARG ) { - const sal_Char sMailtoScheme[] = INET_MAILTO_SCHEME; - const sal_Char sNewsScheme[] = INET_NEWS_SCHEME; - - String aStrURL ( maCbbReceiver.GetText() ); - String aStrScheme; - - if ( maRbtMail.IsChecked() && aStrURL.SearchAscii( sMailtoScheme ) != 0 ) - { - aStrScheme.AssignAscii( RTL_CONSTASCII_STRINGPARAM( INET_MAILTO_SCHEME ) ); - } else if ( maRbtNews.IsChecked() && aStrURL.SearchAscii( sNewsScheme ) != 0 ) - { - aStrScheme.AssignAscii( RTL_CONSTASCII_STRINGPARAM( INET_NEWS_SCHEME ) ); - } + String aScheme = GetSchemeFromURL( maCbbReceiver.GetText() ); + if(aScheme.Len()!=0) + SetScheme( aScheme ); - if ( aStrURL != aEmptyStr ) - { - String aStrTarget ( aStrScheme ); - aStrTarget += aStrURL; - maCbbReceiver.SetText ( aStrTarget ); - } - - ModifiedReceiverHdl_Impl (NULL); - - return (0L); + return( 0L ); } /************************************************************************* diff --git a/svx/source/dialog/hltpbase.cxx b/svx/source/dialog/hltpbase.cxx index efd4a1f5f3ac..fce34cd193be 100644 --- a/svx/source/dialog/hltpbase.cxx +++ b/svx/source/dialog/hltpbase.cxx @@ -2,9 +2,9 @@ * * $RCSfile: hltpbase.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: iha $ $Date: 2002-10-08 16:36:09 $ + * last change: $Author: iha $ $Date: 2002-10-15 11:50:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -76,6 +76,9 @@ #ifndef _UCBHELPER_CONTENT_HXX #include <ucbhelper/content.hxx> #endif +#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX +#include <unotools/localfilehelper.hxx> +#endif #include "hyperdlg.hrc" #ifndef _SVX_TAB_HYPERLINK_HXX #include "hyperdlg.hxx" @@ -810,7 +813,39 @@ BOOL SvxHyperlinkTabPageBase::FillItemSet( SfxItemSet& rOut) String SvxHyperlinkTabPageBase::CreateUiNameFromURL( const String& aStrURL ) { - return aStrURL; + String aStrUiURL; + INetURLObject aURLObj( aStrURL ); + + switch(aURLObj.GetProtocol()) + { + case INET_PROT_FILE: + utl::LocalFileHelper::ConvertURLToSystemPath( aURLObj.GetMainURL(INetURLObject::NO_DECODE), aStrUiURL ); + break; + case INET_PROT_FTP : + { + //remove password from name + INetURLObject aTmpURL(aURLObj); + aTmpURL.SetPass(aEmptyStr); + aStrUiURL = aTmpURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ); + } + break; + case INET_PROT_HTTP : + case INET_PROT_HTTPS : + case INET_PROT_MAILTO : + case INET_PROT_NEWS : + aStrUiURL = aURLObj.GetMainURL(INetURLObject::DECODE_UNAMBIGUOUS); + break; + default : + { + if ( aStrURL.EqualsIgnoreCaseAscii( INET_TELNET_SCHEME, 0, 9 ) ) + aStrUiURL = aStrURL; + else + { + aStrUiURL = aURLObj.GetMainURL(INetURLObject::DECODE_UNAMBIGUOUS); + } + } + } + return aStrUiURL; } /************************************************************************* |