/************************************************************** * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * *************************************************************/ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_cui.hxx" #include "cuihyperdlg.hxx" #include #include #include "com/sun/star/ui/dialogs/TemplateDescription.hpp" #include "hldoctp.hxx" #include "hyperdlg.hrc" #include "hlmarkwn_def.hxx" //ADD CHINA001 sal_Char __READONLY_DATA sHash[] = "#"; sal_Char __READONLY_DATA sFileScheme[] = INET_FILE_SCHEME; sal_Char __READONLY_DATA sNewsSRVScheme[] = "news://"; // TODO news:// is nonsense sal_Char __READONLY_DATA sHTTPScheme[] = INET_HTTP_SCHEME; /************************************************************************* |* |* Constructor / Destructor |* |************************************************************************/ SvxHyperlinkDocTp::SvxHyperlinkDocTp ( Window *pParent, const SfxItemSet& rItemSet) : SvxHyperlinkTabPageBase ( pParent, CUI_RES( RID_SVXPAGE_HYPERLINK_DOCUMENT ), rItemSet ), maGrpDocument ( this, CUI_RES (GRP_DOCUMENT) ), maFtPath ( this, CUI_RES (FT_PATH_DOC) ), maCbbPath ( this, INET_PROT_FILE ), maBtFileopen ( this, CUI_RES (BTN_FILEOPEN) ), maGrpTarget ( this, CUI_RES (GRP_TARGET) ), maFtTarget ( this, CUI_RES (FT_TARGET_DOC) ), maEdTarget ( this, CUI_RES (ED_TARGET_DOC) ), maFtURL ( this, CUI_RES (FT_URL) ), maFtFullURL ( this, CUI_RES (FT_FULL_URL) ), maBtBrowse ( this, CUI_RES (BTN_BROWSE) ), mbMarkWndOpen ( sal_False ) { // Set HC bitmaps and disable display of bitmap names. maBtBrowse.SetModeImage( Image( CUI_RES( IMG_BROWSE_HC ) ), BMP_COLOR_HIGHCONTRAST ); maBtBrowse.EnableTextDisplay (sal_False); maBtFileopen.SetModeImage( Image( CUI_RES( IMG_FILEOPEN_HC ) ), BMP_COLOR_HIGHCONTRAST ); maBtFileopen.EnableTextDisplay (sal_False); InitStdControls(); FreeResource(); // Init URL-Box (pos&size, Open-Handler) maCbbPath.SetPosSizePixel ( LogicToPixel( Point( COL_2, 15 ), MAP_APPFONT ), LogicToPixel( Size ( 176 - COL_DIFF, 60), MAP_APPFONT ) ); maCbbPath.Show(); String aFileScheme( INET_FILE_SCHEME, RTL_TEXTENCODING_ASCII_US ); maCbbPath.SetBaseURL(aFileScheme); maCbbPath.SetHelpId( HID_HYPERDLG_DOC_PATH ); SetExchangeSupport (); // overload handlers maBtFileopen.SetClickHdl ( LINK ( this, SvxHyperlinkDocTp, ClickFileopenHdl_Impl ) ); maBtBrowse.SetClickHdl ( LINK ( this, SvxHyperlinkDocTp, ClickTargetHdl_Impl ) ); maCbbPath.SetModifyHdl ( LINK ( this, SvxHyperlinkDocTp, ModifiedPathHdl_Impl ) ); maEdTarget.SetModifyHdl ( LINK ( this, SvxHyperlinkDocTp, ModifiedTargetHdl_Impl ) ); maCbbPath.SetLoseFocusHdl( LINK ( this, SvxHyperlinkDocTp, LostFocusPathHdl_Impl ) ); maBtBrowse.SetAccessibleRelationMemberOf( &maGrpTarget ); maBtBrowse.SetAccessibleRelationLabeledBy( &maFtTarget ); maBtFileopen.SetAccessibleRelationMemberOf( &maGrpDocument ); maBtFileopen.SetAccessibleRelationLabeledBy( &maFtPath ); maTimer.SetTimeoutHdl ( LINK ( this, SvxHyperlinkDocTp, TimeoutHdl_Impl ) ); } SvxHyperlinkDocTp::~SvxHyperlinkDocTp () { } /************************************************************************* |* |* Fill all dialog-controls except controls in groupbox "more..." |* |************************************************************************/ void SvxHyperlinkDocTp::FillDlgFields ( String& aStrURL ) { INetURLObject aURL ( aStrURL ); String aStrMark; xub_StrLen nPos = aStrURL.SearchAscii( sHash ); // path maCbbPath.SetText ( aStrURL.Copy( 0, ( nPos == STRING_NOTFOUND ? aStrURL.Len() : nPos ) ) ); // set target in document at editfield if ( nPos != STRING_NOTFOUND && nPosSetError( LERR_NOERROR ); EnterWait(); if ( maStrURL.EqualsIgnoreCaseAscii( sFileScheme ) ) mpMarkWnd->RefreshTree ( aEmptyStr ); else mpMarkWnd->RefreshTree ( maStrURL ); LeaveWait(); } else mpMarkWnd->SetError( LERR_DOCNOTOPEN ); ShowMarkWnd (); return( 0L ); } /************************************************************************* |* |* Contens of combobox "Path" modified |* |************************************************************************/ IMPL_LINK ( SvxHyperlinkDocTp, ModifiedPathHdl_Impl, void *, EMPTYARG ) { maStrURL = GetCurrentURL(); maTimer.SetTimeout( 2500 ); maTimer.Start(); maFtFullURL.SetText( maStrURL ); return( 0L ); } /************************************************************************* |* |* If path-field was modify, to browse the new doc after timeout |* |************************************************************************/ IMPL_LINK ( SvxHyperlinkDocTp, TimeoutHdl_Impl, Timer *, EMPTYARG ) { if ( IsMarkWndVisible() && ( GetPathType( maStrURL )==Type_ExistsFile || maStrURL == aEmptyStr || maStrURL.EqualsIgnoreCaseAscii( sFileScheme ) ) ) { EnterWait(); if ( maStrURL.EqualsIgnoreCaseAscii( sFileScheme ) ) mpMarkWnd->RefreshTree ( aEmptyStr ); else mpMarkWnd->RefreshTree ( maStrURL ); LeaveWait(); } return( 0L ); } /************************************************************************* |* |* Contens of editfield "Target" modified |* |************************************************************************/ IMPL_LINK ( SvxHyperlinkDocTp, ModifiedTargetHdl_Impl, void *, EMPTYARG ) { maStrURL = GetCurrentURL(); if ( IsMarkWndVisible() ) mpMarkWnd->SelectEntry ( maEdTarget.GetText() ); maFtFullURL.SetText( maStrURL ); return( 0L ); } /************************************************************************* |* |* editfield "Target" lost focus |* |************************************************************************/ IMPL_LINK ( SvxHyperlinkDocTp, LostFocusPathHdl_Impl, void *, EMPTYARG ) { maStrURL = GetCurrentURL(); maFtFullURL.SetText( maStrURL ); return (0L); } /************************************************************************* |* |* Get String from Bookmark-Wnd |* |************************************************************************/ void SvxHyperlinkDocTp::SetMarkStr ( String& aStrMark ) { maEdTarget.SetText ( aStrMark ); ModifiedTargetHdl_Impl ( NULL ); } /************************************************************************* |* |* retrieve kind of pathstr |* |************************************************************************/ SvxHyperlinkDocTp::EPathType SvxHyperlinkDocTp::GetPathType ( String& aStrPath ) { INetURLObject aURL( aStrPath, INET_PROT_FILE ); if( aURL.HasError() ) return Type_Invalid; else return Type_ExistsFile; }