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