Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <comphelper/string.hxx>
30 : : #include <unotools/pathoptions.hxx>
31 : : #include <unotools/useroptions.hxx>
32 : : #include <svl/adrparse.hxx>
33 : :
34 : : #include "hlinettp.hxx"
35 : : #include "hyperdlg.hrc"
36 : : #include "hlmarkwn_def.hxx"
37 : :
38 : : sal_Char const sAnonymous[] = "anonymous";
39 : : sal_Char const sHTTPScheme[] = INET_HTTP_SCHEME;
40 : : sal_Char const sHTTPSScheme[] = INET_HTTPS_SCHEME;
41 : : sal_Char const sFTPScheme[] = INET_FTP_SCHEME;
42 : :
43 : : /*************************************************************************
44 : : |*
45 : : |* Constructor / Destructor
46 : : |*
47 : : |************************************************************************/
48 : :
49 : 0 : SvxHyperlinkInternetTp::SvxHyperlinkInternetTp ( Window *pParent,
50 : : const SfxItemSet& rItemSet)
51 : 0 : : SvxHyperlinkTabPageBase ( pParent, CUI_RES( RID_SVXPAGE_HYPERLINK_INTERNET ),
52 : : rItemSet ) ,
53 [ # # ]: 0 : maGrpLinkTyp ( this, CUI_RES (GRP_LINKTYPE) ),
54 [ # # ]: 0 : maRbtLinktypInternet ( this, CUI_RES (RB_LINKTYP_INTERNET) ),
55 [ # # ]: 0 : maRbtLinktypFTP ( this, CUI_RES (RB_LINKTYP_FTP) ),
56 [ # # ]: 0 : maFtTarget ( this, CUI_RES (FT_TARGET_HTML) ),
57 : : maCbbTarget ( this, INET_PROT_HTTP ),
58 [ # # ]: 0 : maBtBrowse ( this, CUI_RES (BTN_BROWSE) ),
59 [ # # ]: 0 : maFtLogin ( this, CUI_RES (FT_LOGIN) ),
60 [ # # ]: 0 : maEdLogin ( this, CUI_RES (ED_LOGIN) ),
61 [ # # ]: 0 : maBtTarget ( this, CUI_RES (BTN_TARGET) ),
62 [ # # ]: 0 : maFtPassword ( this, CUI_RES (FT_PASSWD) ),
63 [ # # ]: 0 : maEdPassword ( this, CUI_RES (ED_PASSWD) ),
64 [ # # ]: 0 : maCbAnonymous ( this, CUI_RES (CBX_ANONYMOUS) ),
65 [ # # ][ # # ]: 0 : mbMarkWndOpen ( sal_False )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
66 : : {
67 : : // Disable display of bitmap names.
68 [ # # ]: 0 : maBtBrowse.EnableTextDisplay (sal_False);
69 [ # # ]: 0 : maBtTarget.EnableTextDisplay (sal_False);
70 : :
71 [ # # ]: 0 : InitStdControls();
72 [ # # ]: 0 : FreeResource();
73 : :
74 : : // Init URL-Box (pos&size, Open-Handler)
75 [ # # ][ # # ]: 0 : maCbbTarget.SetPosSizePixel ( LogicToPixel( Point( COL_2, 25 ), MAP_APPFONT ),
76 [ # # ]: 0 : LogicToPixel( Size ( 176 - COL_DIFF, 60), MAP_APPFONT ) );
[ # # # # ]
[ # # ][ # # ]
77 [ # # ]: 0 : maCbbTarget.Show();
78 [ # # ]: 0 : maCbbTarget.SetHelpId( HID_HYPERDLG_INET_PATH );
79 : :
80 : 0 : SetExchangeSupport ();
81 : :
82 : : ///////////////////////////////////////
83 : : // set defaults
84 [ # # ]: 0 : maRbtLinktypInternet.Check ();
85 [ # # ]: 0 : maFtLogin.Show( sal_False );
86 [ # # ]: 0 : maFtPassword.Show( sal_False );
87 [ # # ]: 0 : maEdLogin.Show( sal_False );
88 [ # # ]: 0 : maEdPassword.Show( sal_False );
89 [ # # ]: 0 : maCbAnonymous.Show( sal_False );
90 [ # # ]: 0 : maBtTarget.Enable( sal_False );
91 [ # # ]: 0 : maBtBrowse.Enable( sal_True );
92 : :
93 : : ///////////////////////////////////////
94 : : // overload handlers
95 [ # # ]: 0 : Link aLink( LINK ( this, SvxHyperlinkInternetTp, Click_SmartProtocol_Impl ) );
96 : 0 : maRbtLinktypInternet.SetClickHdl( aLink );
97 : 0 : maRbtLinktypFTP.SetClickHdl ( aLink );
98 [ # # ]: 0 : maCbAnonymous.SetClickHdl ( LINK ( this, SvxHyperlinkInternetTp, ClickAnonymousHdl_Impl ) );
99 [ # # ]: 0 : maBtBrowse.SetClickHdl ( LINK ( this, SvxHyperlinkInternetTp, ClickBrowseHdl_Impl ) );
100 [ # # ]: 0 : maBtTarget.SetClickHdl ( LINK ( this, SvxHyperlinkInternetTp, ClickTargetHdl_Impl ) );
101 [ # # ]: 0 : maEdLogin.SetModifyHdl ( LINK ( this, SvxHyperlinkInternetTp, ModifiedLoginHdl_Impl ) );
102 [ # # ]: 0 : maCbbTarget.SetLoseFocusHdl ( LINK ( this, SvxHyperlinkInternetTp, LostFocusTargetHdl_Impl ) );
103 [ # # ]: 0 : maCbbTarget.SetModifyHdl ( LINK ( this, SvxHyperlinkInternetTp, ModifiedTargetHdl_Impl ) );
104 [ # # ]: 0 : maTimer.SetTimeoutHdl ( LINK ( this, SvxHyperlinkInternetTp, TimeoutHdl_Impl ) );
105 : :
106 [ # # ]: 0 : maFtTarget.SetAccessibleRelationMemberOf( &maGrpLinkTyp );
107 [ # # ]: 0 : maCbbTarget.SetAccessibleRelationMemberOf( &maGrpLinkTyp );
108 [ # # ]: 0 : maBtTarget.SetAccessibleRelationMemberOf( &maGrpLinkTyp );
109 [ # # ]: 0 : maBtTarget.SetAccessibleRelationLabeledBy( &maFtTarget );
110 [ # # ]: 0 : maBtBrowse.SetAccessibleRelationMemberOf( &maGrpLinkTyp );
111 [ # # ]: 0 : maBtBrowse.SetAccessibleRelationLabeledBy( &maFtTarget );
112 : 0 : }
113 : :
114 [ # # ][ # # ]: 0 : SvxHyperlinkInternetTp::~SvxHyperlinkInternetTp ()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
115 : : {
116 [ # # ]: 0 : }
117 : :
118 : : /*************************************************************************
119 : : |*
120 : : |* Fill the all dialog-controls except controls in groupbox "more..."
121 : : |*
122 : : |************************************************************************/
123 : :
124 : 0 : void SvxHyperlinkInternetTp::FillDlgFields ( String& aStrURL )
125 : : {
126 [ # # ][ # # ]: 0 : INetURLObject aURL( aStrURL );
127 [ # # ][ # # ]: 0 : String aStrScheme = GetSchemeFromURL( aStrURL );
[ # # ]
128 : :
129 : : // set additional controls for FTP: Username / Password
130 [ # # ][ # # ]: 0 : if ( aStrScheme.SearchAscii( sFTPScheme ) == 0 )
131 : : {
132 [ # # ][ # # ]: 0 : if ( String(aURL.GetUser()).ToLowerAscii().SearchAscii ( sAnonymous ) == 0 )
[ # # ][ # # ]
[ # # ][ # # ]
133 [ # # ]: 0 : setAnonymousFTPUser();
134 : : else
135 [ # # ][ # # ]: 0 : setFTPUser(aURL.GetUser(), aURL.GetPass());
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
136 : :
137 : : //do not show password and user in url
138 [ # # ][ # # ]: 0 : if(!aURL.GetUser().isEmpty() || !aURL.GetPass().isEmpty() )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # ]
139 [ # # ][ # # ]: 0 : aURL.SetUserAndPass(aEmptyStr,aEmptyStr);
[ # # ]
140 : : }
141 : :
142 : : // set URL-field
143 : : // Show the scheme, #72740
144 [ # # ]: 0 : if ( aURL.GetProtocol() != INET_PROT_NOT_VALID )
145 [ # # ][ # # ]: 0 : maCbbTarget.SetText( aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) );
[ # # ][ # # ]
146 : : else
147 [ # # ]: 0 : maCbbTarget.SetText( aStrURL ); // #77696#
148 : :
149 [ # # ][ # # ]: 0 : SetScheme( aStrScheme );
[ # # ]
150 : 0 : }
151 : :
152 : 0 : void SvxHyperlinkInternetTp::setAnonymousFTPUser()
153 : : {
154 [ # # ][ # # ]: 0 : maEdLogin.SetText(rtl::OUString(sAnonymous));
[ # # ]
155 [ # # ][ # # ]: 0 : SvAddressParser aAddress( SvtUserOptions().GetEmail() );
[ # # ][ # # ]
156 [ # # ][ # # ]: 0 : maEdPassword.SetText( aAddress.Count() ? aAddress.GetEmailAddress(0) : rtl::OUString() );
[ # # ][ # # ]
[ # # ]
157 : :
158 [ # # ]: 0 : maFtLogin.Disable ();
159 [ # # ]: 0 : maFtPassword.Disable ();
160 [ # # ]: 0 : maEdLogin.Disable ();
161 [ # # ]: 0 : maEdPassword.Disable ();
162 [ # # ][ # # ]: 0 : maCbAnonymous.Check();
163 : 0 : }
164 : :
165 : 0 : void SvxHyperlinkInternetTp::setFTPUser(const String& rUser, const String& rPassword)
166 : : {
167 : 0 : maEdLogin.SetText ( rUser );
168 : 0 : maEdPassword.SetText ( rPassword );
169 : :
170 : 0 : maFtLogin.Enable ();
171 : 0 : maFtPassword.Enable ();
172 : 0 : maEdLogin.Enable ();
173 : 0 : maEdPassword.Enable ();
174 : 0 : maCbAnonymous.Check(sal_False);
175 : 0 : }
176 : :
177 : : /*************************************************************************
178 : : |*
179 : : |* retrieve and prepare data from dialog-fields
180 : : |*
181 : : |************************************************************************/
182 : :
183 : 0 : void SvxHyperlinkInternetTp::GetCurentItemData ( String& aStrURL, String& aStrName,
184 : : String& aStrIntName, String& aStrFrame,
185 : : SvxLinkInsertMode& eMode )
186 : : {
187 [ # # ]: 0 : aStrURL = CreateAbsoluteURL();
188 : 0 : GetDataFromCommonFields( aStrName, aStrIntName, aStrFrame, eMode );
189 : 0 : }
190 : :
191 : 0 : String SvxHyperlinkInternetTp::CreateAbsoluteURL() const
192 : : {
193 [ # # ]: 0 : String aStrURL = maCbbTarget.GetText();
194 [ # # ][ # # ]: 0 : String aScheme = GetSchemeFromURL(aStrURL);
[ # # ]
195 : :
196 [ # # ][ # # ]: 0 : INetURLObject aURL(aStrURL);
197 : :
198 [ # # ]: 0 : if( aURL.GetProtocol() == INET_PROT_NOT_VALID )
199 : : {
200 : 0 : aURL.SetSmartProtocol( GetSmartProtocolFromButtons() );
201 [ # # ][ # # ]: 0 : aURL.SetSmartURL(aStrURL);
202 : : }
203 : :
204 : : // username and password for ftp-url
205 [ # # ][ # # ]: 0 : if( aURL.GetProtocol() == INET_PROT_FTP && maEdLogin.GetText().Len()!=0 )
[ # # ][ # # ]
[ # # ]
[ # # # # ]
206 [ # # ][ # # ]: 0 : aURL.SetUserAndPass ( maEdLogin.GetText(), maEdPassword.GetText() );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
207 : :
208 [ # # ]: 0 : if ( aURL.GetProtocol() != INET_PROT_NOT_VALID )
209 [ # # ][ # # ]: 0 : return aURL.GetMainURL( INetURLObject::DECODE_WITH_CHARSET );
210 : : else //#105788# always create a URL even if it is not valid
211 [ # # ][ # # ]: 0 : return aStrURL;
[ # # ][ # # ]
212 : : }
213 : :
214 : : /*************************************************************************
215 : : |*
216 : : |* static method to create Tabpage
217 : : |*
218 : : |************************************************************************/
219 : :
220 : 0 : IconChoicePage* SvxHyperlinkInternetTp::Create( Window* pWindow, const SfxItemSet& rItemSet )
221 : : {
222 [ # # ]: 0 : return( new SvxHyperlinkInternetTp( pWindow, rItemSet ) );
223 : : }
224 : :
225 : : /*************************************************************************
226 : : |*
227 : : |* Set initial focus
228 : : |*
229 : : |************************************************************************/
230 : :
231 : 0 : void SvxHyperlinkInternetTp::SetInitFocus()
232 : : {
233 : 0 : maCbbTarget.GrabFocus();
234 : 0 : }
235 : :
236 : : /*************************************************************************
237 : : |*
238 : : |* Contents of editfield "Target" modified
239 : : |*
240 : : |************************************************************************/
241 : :
242 : 0 : IMPL_LINK_NOARG(SvxHyperlinkInternetTp, ModifiedTargetHdl_Impl)
243 : : {
244 [ # # ][ # # ]: 0 : String aScheme = GetSchemeFromURL( maCbbTarget.GetText() );
[ # # ]
245 [ # # ]: 0 : if(aScheme.Len()!=0)
246 [ # # ]: 0 : SetScheme( aScheme );
247 : :
248 : : // start timer
249 [ # # ]: 0 : maTimer.SetTimeout( 2500 );
250 [ # # ]: 0 : maTimer.Start();
251 : :
252 [ # # ]: 0 : return( 0L );
253 : : }
254 : :
255 : : /*************************************************************************
256 : : |*
257 : : |* If target-field was modify, to browse the new doc after timeout
258 : : |*
259 : : |************************************************************************/
260 : :
261 : 0 : IMPL_LINK_NOARG(SvxHyperlinkInternetTp, TimeoutHdl_Impl)
262 : : {
263 : 0 : RefreshMarkWindow();
264 : 0 : return( 0L );
265 : : }
266 : :
267 : : /*************************************************************************
268 : : |*
269 : : |* Contents of editfield "Login" modified
270 : : |*
271 : : |************************************************************************/
272 : :
273 : 0 : IMPL_LINK_NOARG(SvxHyperlinkInternetTp, ModifiedLoginHdl_Impl)
274 : : {
275 [ # # ]: 0 : String aStrLogin ( maEdLogin.GetText() );
276 [ # # ][ # # ]: 0 : if ( aStrLogin.EqualsIgnoreCaseAscii( sAnonymous ) )
277 : : {
278 [ # # ]: 0 : maCbAnonymous.Check();
279 [ # # ]: 0 : ClickAnonymousHdl_Impl(NULL);
280 : : }
281 : :
282 [ # # ]: 0 : return( 0L );
283 : : }
284 : :
285 : : /*************************************************************************
286 : : |************************************************************************/
287 : :
288 : 0 : void SvxHyperlinkInternetTp::SetScheme( const String& aScheme )
289 : : {
290 : : //if aScheme is empty or unknown the default beaviour is like it where HTTP
291 : :
292 : 0 : sal_Bool bFTP = aScheme.SearchAscii( sFTPScheme ) == 0;
293 : 0 : sal_Bool bInternet = !(bFTP);
294 : :
295 : : //update protocol button selection:
296 : 0 : maRbtLinktypFTP.Check(bFTP);
297 : 0 : maRbtLinktypInternet.Check(bInternet);
298 : :
299 : : //update target:
300 : 0 : RemoveImproperProtocol(aScheme);
301 : 0 : maCbbTarget.SetSmartProtocol( GetSmartProtocolFromButtons() );
302 : :
303 : : //show/hide special fields for FTP:
304 : 0 : maFtLogin.Show( bFTP );
305 : 0 : maFtPassword.Show( bFTP );
306 : 0 : maEdLogin.Show( bFTP );
307 : 0 : maEdPassword.Show( bFTP );
308 : 0 : maCbAnonymous.Show( bFTP );
309 : :
310 : : //update 'link target in document'-window and opening-button
311 [ # # ][ # # ]: 0 : if( aScheme.SearchAscii( sHTTPScheme ) == 0 || aScheme.Len() == 0 )
[ # # ]
312 : : {
313 : 0 : maBtTarget.Enable();
314 [ # # ]: 0 : if ( mbMarkWndOpen )
315 : 0 : ShowMarkWnd ();
316 : : }
317 : : else
318 : : {
319 : : //disable for https and ftp
320 : 0 : maBtTarget.Disable();
321 [ # # ]: 0 : if ( mbMarkWndOpen )
322 : 0 : HideMarkWnd ();
323 : : }
324 : 0 : }
325 : :
326 : : /*************************************************************************
327 : : |*
328 : : |* Remove protocol if it does not fit to the current button selection
329 : : |*
330 : : |************************************************************************/
331 : :
332 : 0 : void SvxHyperlinkInternetTp::RemoveImproperProtocol(const String& aProperScheme)
333 : : {
334 [ # # ]: 0 : String aStrURL ( maCbbTarget.GetText() );
335 [ # # ][ # # ]: 0 : if ( aStrURL != aEmptyStr )
336 : : {
337 [ # # ][ # # ]: 0 : String aStrScheme = GetSchemeFromURL( aStrURL );
[ # # ]
338 [ # # ][ # # ]: 0 : if ( aStrScheme != aEmptyStr && aStrScheme != aProperScheme )
[ # # ][ # # ]
[ # # ]
339 : : {
340 [ # # ]: 0 : aStrURL.Erase ( 0, aStrScheme.Len() );
341 [ # # ]: 0 : maCbbTarget.SetText ( aStrURL );
342 [ # # ]: 0 : }
343 [ # # ]: 0 : }
344 : 0 : }
345 : :
346 : 0 : String SvxHyperlinkInternetTp::GetSchemeFromButtons() const
347 : : {
348 [ # # ]: 0 : if( maRbtLinktypFTP.IsChecked() )
349 [ # # ]: 0 : return rtl::OUString(INET_FTP_SCHEME);
350 [ # # ]: 0 : return rtl::OUString(INET_HTTP_SCHEME);
351 : : }
352 : :
353 : 0 : INetProtocol SvxHyperlinkInternetTp::GetSmartProtocolFromButtons() const
354 : : {
355 [ # # ]: 0 : if( maRbtLinktypFTP.IsChecked() )
356 : : {
357 : 0 : return INET_PROT_FTP;
358 : : }
359 : 0 : return INET_PROT_HTTP;
360 : : }
361 : :
362 : : /*************************************************************************
363 : : |*
364 : : |* Click on Radiobutton : Internet or FTP
365 : : |*
366 : : |************************************************************************/
367 : :
368 : 0 : IMPL_LINK_NOARG(SvxHyperlinkInternetTp, Click_SmartProtocol_Impl)
369 : : {
370 [ # # ]: 0 : String aScheme = GetSchemeFromButtons();
371 [ # # ]: 0 : SetScheme( aScheme );
372 [ # # ]: 0 : return( 0L );
373 : : }
374 : :
375 : : /*************************************************************************
376 : : |*
377 : : |* Click on Checkbox : Anonymous user
378 : : |*
379 : : |************************************************************************/
380 : :
381 : 0 : IMPL_LINK_NOARG(SvxHyperlinkInternetTp, ClickAnonymousHdl_Impl)
382 : : {
383 : : // disable login-editfields if checked
384 [ # # ]: 0 : if ( maCbAnonymous.IsChecked() )
385 : : {
386 [ # # ][ # # ]: 0 : if ( maEdLogin.GetText().ToLowerAscii().SearchAscii ( sAnonymous ) == 0 )
[ # # ]
387 : : {
388 : 0 : maStrOldUser = aEmptyStr;
389 : 0 : maStrOldPassword = aEmptyStr;
390 : : }
391 : : else
392 : : {
393 [ # # ]: 0 : maStrOldUser = maEdLogin.GetText();
394 [ # # ]: 0 : maStrOldPassword = maEdPassword.GetText();
395 : : }
396 : :
397 : 0 : setAnonymousFTPUser();
398 : : }
399 : : else
400 : 0 : setFTPUser(maStrOldUser, maStrOldPassword);
401 : :
402 : 0 : return( 0L );
403 : : }
404 : :
405 : : /*************************************************************************
406 : : |*
407 : : |* Combobox Target lost the focus
408 : : |*
409 : : |************************************************************************/
410 : :
411 : 0 : IMPL_LINK_NOARG(SvxHyperlinkInternetTp, LostFocusTargetHdl_Impl)
412 : : {
413 : 0 : RefreshMarkWindow();
414 : 0 : return (0L);
415 : : }
416 : :
417 : : /*************************************************************************
418 : : |*
419 : : |* Click on imagebutton : Browse
420 : : |*
421 : : |************************************************************************/
422 : :
423 : 0 : IMPL_LINK_NOARG(SvxHyperlinkInternetTp, ClickBrowseHdl_Impl)
424 : : {
425 : : /////////////////////////////////////////////////
426 : : // Open URL if available
427 : :
428 [ # # ][ # # ]: 0 : SfxStringItem aName( SID_FILE_NAME, rtl::OUString("http://") );
[ # # ]
429 [ # # ][ # # ]: 0 : SfxStringItem aRefererItem( SID_REFERER, rtl::OUString("private:user") );
[ # # ]
430 [ # # ]: 0 : SfxBoolItem aNewView( SID_OPEN_NEW_VIEW, sal_True );
431 [ # # ]: 0 : SfxBoolItem aSilent( SID_SILENT, sal_True );
432 [ # # ]: 0 : SfxBoolItem aReadOnly( SID_DOC_READONLY, sal_True );
433 : :
434 [ # # ]: 0 : SfxBoolItem aBrowse( SID_BROWSE, sal_True );
435 : :
436 : 0 : const SfxPoolItem *ppItems[] = { &aName, &aNewView, &aSilent, &aReadOnly, &aRefererItem, &aBrowse, NULL };
437 [ # # ]: 0 : (((SvxHpLinkDlg*)mpDialog)->GetBindings())->Execute( SID_OPENDOC, ppItems, 0, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
438 : :
439 [ # # ][ # # ]: 0 : return( 0L );
[ # # ][ # # ]
[ # # ][ # # ]
440 : : }
441 : :
442 : : /*************************************************************************
443 : : |*
444 : : |* Click on imagebutton : Target
445 : : |*
446 : : |************************************************************************/
447 : :
448 : 0 : IMPL_LINK_NOARG(SvxHyperlinkInternetTp, ClickTargetHdl_Impl)
449 : : {
450 : 0 : RefreshMarkWindow();
451 : 0 : ShowMarkWnd ();
452 : 0 : mbMarkWndOpen = IsMarkWndVisible ();
453 : :
454 : 0 : return( 0L );
455 : : }
456 : :
457 : 0 : void SvxHyperlinkInternetTp::RefreshMarkWindow()
458 : : {
459 [ # # ][ # # ]: 0 : if ( maRbtLinktypInternet.IsChecked() && IsMarkWndVisible() )
[ # # ]
460 : : {
461 [ # # ]: 0 : EnterWait();
462 [ # # ]: 0 : String aStrURL( CreateAbsoluteURL() );
463 [ # # ][ # # ]: 0 : if ( aStrURL != aEmptyStr )
464 [ # # ][ # # ]: 0 : mpMarkWnd->RefreshTree ( aStrURL );
[ # # ]
465 : : else
466 [ # # ]: 0 : mpMarkWnd->SetError( LERR_DOCNOTOPEN );
467 [ # # ][ # # ]: 0 : LeaveWait();
468 : : }
469 : :
470 : 0 : }
471 : :
472 : : /*************************************************************************
473 : : |*
474 : : |* Get String from Bookmark-Wnd
475 : : |*
476 : : |************************************************************************/
477 : :
478 : 0 : void SvxHyperlinkInternetTp::SetMarkStr ( String& aStrMark )
479 : : {
480 [ # # ]: 0 : String aStrURL ( maCbbTarget.GetText() );
481 : :
482 : 0 : const sal_Unicode sUHash = '#';
483 [ # # ]: 0 : xub_StrLen nPos = aStrURL.SearchBackward( sUHash );
484 : :
485 [ # # ]: 0 : if( nPos != STRING_NOTFOUND )
486 [ # # ]: 0 : aStrURL.Erase ( nPos );
487 : :
488 [ # # ]: 0 : aStrURL += sUHash;
489 [ # # ]: 0 : aStrURL += aStrMark;
490 : :
491 [ # # ][ # # ]: 0 : maCbbTarget.SetText ( aStrURL );
492 : 0 : }
493 : :
494 : : /*************************************************************************
495 : : |*
496 : : |* Enable Browse-Button in subject to the office is in onlinemode
497 : : |*
498 : : |************************************************************************/
499 : :
500 : 0 : void SvxHyperlinkInternetTp::SetOnlineMode( sal_Bool /*bEnable*/ )
501 : : {
502 : : // State of target-button in subject to the current url-string
503 : : // ( Can't display any targets in an document, if there is no
504 : : // valid url to a document )
505 [ # # ][ # # ]: 0 : String aStrCurrentTarget(comphelper::string::stripEnd(maCbbTarget.GetText(), ' '));
[ # # ][ # # ]
[ # # ]
506 : :
507 [ # # ][ # # ]: 0 : if( aStrCurrentTarget == aEmptyStr ||
[ # # ][ # # ]
[ # # ]
508 [ # # ]: 0 : aStrCurrentTarget.EqualsIgnoreCaseAscii( sHTTPScheme ) ||
509 [ # # ]: 0 : aStrCurrentTarget.EqualsIgnoreCaseAscii( sHTTPSScheme ) )
510 [ # # ]: 0 : maBtTarget.Enable( sal_False );
511 : : else
512 [ # # ][ # # ]: 0 : maBtTarget.Enable( sal_True );
513 : 0 : }
514 : :
515 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|