1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hltpbase.cxx,v $
10 * $Revision: 1.37.216.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #ifdef SVX_DLLIMPLEMENTATION
35 #undef SVX_DLLIMPLEMENTATION
37 #include <sfx2/frame.hxx>
38 #include <sfx2/viewfrm.hxx>
39 #include <sot/formats.hxx>
40 #include <sfx2/sfxsids.hrc>
41 #include <svtools/macitem.hxx>
42 #include <ucbhelper/content.hxx>
43 #include <unotools/localfilehelper.hxx>
44 #include "hyperdlg.hrc"
45 //CHINA001 #ifndef _SVX_TAB_HYPERLINK_HXX
46 //CHINA001 #include "hyperdlg.hxx"
48 #include "cuihyperdlg.hxx" //CHINA001
49 #include "hltpbase.hxx"
50 #include "macroass.hxx"
52 #include <svx/svxdlg.hxx> //CHINA001
53 #include <svx/dialogs.hrc> //CHINA001
55 using namespace ::ucbhelper
;
57 //########################################################################
59 //# ComboBox-Control, wich is filled with all current framenames #
61 //########################################################################
63 /*************************************************************************
65 |* Contructor / Destructor
67 |************************************************************************/
69 SvxFramesComboBox::SvxFramesComboBox ( Window
* pParent
, const ResId
& rResId
,
70 SfxDispatcher
* pDispatch
)
71 : ComboBox (pParent
, rResId
)
73 TargetList
* pList
= new TargetList
;
74 SfxViewFrame
* pViewFrame
= pDispatch
? pDispatch
->GetFrame() : 0;
75 SfxFrame
* pFrame
= pViewFrame
? pViewFrame
->GetTopFrame() : 0;
78 pFrame
->GetTargetList(*pList
);
79 USHORT nCount
= (USHORT
)pList
->Count();
83 for ( i
= 0; i
< nCount
; i
++ )
85 InsertEntry(*pList
->GetObject(i
));
87 for ( i
= nCount
; i
; i
-- )
89 delete pList
->GetObject( i
- 1 );
96 SvxFramesComboBox::~SvxFramesComboBox ()
99 //########################################################################
101 //# ComboBox-Control for URL's with History and Autocompletion #
103 //########################################################################
105 /*************************************************************************
107 |* Contructor / Destructor
109 |************************************************************************/
111 SvxHyperURLBox::SvxHyperURLBox( Window
* pParent
, INetProtocol eSmart
, BOOL bAddresses
)
112 : SvtURLBox ( pParent
, eSmart
),
113 DropTargetHelper ( this ),
114 mbAccessAddress (bAddresses
)
118 sal_Int8
SvxHyperURLBox::AcceptDrop( const AcceptDropEvent
& /* rEvt */ )
120 return( IsDropFormatSupported( FORMAT_STRING
) ? DND_ACTION_COPY
: DND_ACTION_NONE
);
123 sal_Int8
SvxHyperURLBox::ExecuteDrop( const ExecuteDropEvent
& rEvt
)
125 TransferableDataHelper
aDataHelper( rEvt
.maDropEvent
.Transferable
);
127 sal_Int8 nRet
= DND_ACTION_NONE
;
129 if( aDataHelper
.GetString( FORMAT_STRING
, aString
) )
132 nRet
= DND_ACTION_COPY
;
139 Diese Methode parsed eine EMailadresse aus einem D&D-DataObjekt aus der Adre�datenbank heraus
141 #ifndef _OFF_OFADBMGR_HXX
142 #include <offmgr/ofadbmgr.hxx>
145 #include <offmgr/app.hxx>
147 #ifndef _SDB_SDBCURS_HXX
148 #include <sdb/sdbcurs.hxx>
151 #define DB_DD_DELIM ((char)11)
153 String SvxHyperURLBox::GetAllEmailNamesFromDragItem( USHORT nItem )
155 #if !defined( ICC ) && !defined( SOLARIS )
158 if ( DragServer::HasFormat( nItem, SOT_FORMATSTR_ID_SBA_DATAEXCHANGE ) )
160 ULONG nLen = DragServer::GetDataLen( nItem, SOT_FORMATSTR_ID_SBA_DATAEXCHANGE ) - 1;
163 char *pTxt = aTxt.AllocStrBuf( (USHORT)nLen );
164 DragServer::PasteData( nItem, pTxt, nLen, SOT_FORMATSTR_ID_SBA_DATAEXCHANGE );
165 String aDBName = aTxt.GetToken( i++, DB_DD_DELIM );
166 String aTableName = aTxt.GetToken( i++, DB_DD_DELIM );
167 i++; // Format"anderung
168 String aStatement = aTxt.GetToken( i++, DB_DD_DELIM );
172 aDBName += aTableName;
176 // use here another delimiter, because the OfaDBMgr uses two
177 // delimiters ( (char)11 and ; )
179 aDBName += aStatement;
181 SbaSelectionListRef pSelectionList;
182 pSelectionList.Clear();
183 pSelectionList = new SbaSelectionList;
184 USHORT nTokCnt = aTxt.GetTokenCount( DB_DD_DELIM );
186 for ( ; i < nTokCnt; ++i )
187 pSelectionList->Insert(
188 (void*)(USHORT)aTxt.GetToken( i, DB_DD_DELIM ), LIST_APPEND );
190 OfaDBMgr* pDBMgr = SFX_APP()->GetOfaDBMgr();
191 BOOL bBasic = DBMGR_STD;
193 if ( !pDBMgr->OpenDB( bBasic, aDBName ) )
196 OfaDBParam& rParam = pDBMgr->GetDBData( bBasic );
197 pDBMgr->ChangeStatement( bBasic, aStatement );
198 rParam.pSelectionList->Clear();
200 if ( pSelectionList.Is() &&
201 (long)pSelectionList->GetObject(0) != -1L )
202 *rParam.pSelectionList = *pSelectionList;
204 if ( !pDBMgr->ToFirstSelectedRecord( bBasic ) )
210 if ( pDBMgr->IsSuccessful( bBasic ) )
213 SbaDBDataDefRef aDBDef = pDBMgr->OpenColumnNames( bBasic );
217 SbaColumn* pCol = aDBDef->GetColumn("EMAIL");
221 nPos = aDBDef->GetOriginalColumns().GetPos( pCol ) + 1;
222 for ( i = 0 ; nPos && i < pSelectionList->Count(); ++i )
224 ULONG nIndex = (ULONG)pSelectionList->GetObject(i);
226 // N"achsten zu lesenden Datensatz ansteuern
228 BOOL bEnd = rParam.GetCursor()->IsOffRange();
232 const ODbRowRef aRow =
233 pDBMgr->GetSelectedRecord( bBasic, i );
238 ImportDBField( (USHORT)nPos, &aDBDef, aRow.getBodyPtr() );
254 aAddress.EraseTrailingChars( ',' );
262 void SvxHyperURLBox::Select()
266 void SvxHyperURLBox::Modify()
270 long SvxHyperURLBox::Notify( NotifyEvent
& rNEvt
)
272 return SvtURLBox::Notify( rNEvt
);
274 long SvxHyperURLBox::PreNotify( NotifyEvent
& rNEvt
)
276 return SvtURLBox::PreNotify( rNEvt
);
279 //########################################################################
281 //# Hyperlink-Dialog: Tabpages-Baseclass #
283 //########################################################################
285 /*************************************************************************
287 |* Con/Destructor, Initialize
289 \************************************************************************/
291 SvxHyperlinkTabPageBase::SvxHyperlinkTabPageBase ( Window
*pParent
,
293 const SfxItemSet
& rItemSet
)
294 : IconChoicePage ( pParent
, rResId
, rItemSet
),
300 mpFtIndication ( NULL
),
301 mpEdIndication ( NULL
),
305 mbIsCloseDisabled ( sal_False
),
306 mpDialog ( pParent
),
307 mbStdControlsInit ( FALSE
),
310 // create bookmark-window
311 mpMarkWnd
= new SvxHlinkDlgMarkWnd ( this );
314 SvxHyperlinkTabPageBase::~SvxHyperlinkTabPageBase ()
318 if ( mbStdControlsInit
)
325 delete mpFtIndication
;
326 delete mpEdIndication
;
335 void SvxHyperlinkTabPageBase::ActivatePage()
337 TabPage::ActivatePage();
340 void SvxHyperlinkTabPageBase::DeactivatePage()
342 TabPage::DeactivatePage();
345 sal_Bool
SvxHyperlinkTabPageBase::QueryClose()
347 return !mbIsCloseDisabled
;
350 void SvxHyperlinkTabPageBase::InitStdControls ()
352 if ( !mbStdControlsInit
)
354 mpGrpMore
= new FixedLine ( this, ResId (GRP_MORE
, *m_pResMgr
) );
355 mpFtFrame
= new FixedText ( this, ResId (FT_FRAME
, *m_pResMgr
) );
356 mpCbbFrame
= new SvxFramesComboBox ( this, ResId (CB_FRAME
, *m_pResMgr
), GetDispatcher() );
357 mpFtForm
= new FixedText ( this, ResId (FT_FORM
, *m_pResMgr
) );
358 mpLbForm
= new ListBox ( this, ResId (LB_FORM
, *m_pResMgr
) );
359 mpFtIndication
= new FixedText ( this, ResId (FT_INDICATION
, *m_pResMgr
) );
360 mpEdIndication
= new Edit ( this, ResId (ED_INDICATION
, *m_pResMgr
) );
361 mpFtText
= new FixedText ( this, ResId (FT_TEXT
, *m_pResMgr
) );
362 mpEdText
= new Edit ( this, ResId (ED_TEXT
, *m_pResMgr
) );
363 mpBtScript
= new ImageButton ( this, ResId (BTN_SCRIPT
, *m_pResMgr
) );
365 mpBtScript
->SetClickHdl ( LINK ( this, SvxHyperlinkTabPageBase
, ClickScriptHdl_Impl
) );
367 mpBtScript
->SetModeImage( Image( ResId( IMG_SCRIPT_HC
, *m_pResMgr
) ), BMP_COLOR_HIGHCONTRAST
);
368 mpBtScript
->EnableTextDisplay (FALSE
);
371 mbStdControlsInit
= TRUE
;
374 /*************************************************************************
378 \************************************************************************/
380 BOOL
SvxHyperlinkTabPageBase::MoveToExtraWnd( Point aNewPos
, BOOL bDisConnectDlg
)
382 BOOL bReturn
= mpMarkWnd
->MoveTo ( aNewPos
);
385 mpMarkWnd
->ConnectToDialog( FALSE
);
387 return ( !bReturn
&& IsMarkWndVisible() );
390 /*************************************************************************
394 \************************************************************************/
396 void SvxHyperlinkTabPageBase::ShowMarkWnd ()
398 ( ( Window
* ) mpMarkWnd
)->Show();
400 // Size of dialog-window in screen pixels
401 Rectangle
aDlgRect( mpDialog
->GetWindowExtentsRelative( NULL
) );
402 Point
aDlgPos ( aDlgRect
.TopLeft() );
403 Size
aDlgSize ( mpDialog
->GetSizePixel () );
405 // Absolute size of the screen
406 Rectangle
aScreen( mpDialog
->GetDesktopRectPixel() );
408 // Size of Extrawindow
409 Size
aExtraWndSize( mpMarkWnd
->GetSizePixel () );
411 // mpMarkWnd is a child of mpDialog, so coordinates for positioning must be relative to mpDialog
412 if( aDlgPos
.X()+(1.05*aDlgSize
.Width())+aExtraWndSize
.Width() > aScreen
.Right() )
414 if( aDlgPos
.X() - ( 0.05*aDlgSize
.Width() ) - aExtraWndSize
.Width() < 0 )
416 // Pos Extrawindow anywhere
417 MoveToExtraWnd( Point(10,10) ); // very unlikely
418 mpMarkWnd
->ConnectToDialog( FALSE
);
422 // Pos Extrawindow on the left side of Dialog
423 MoveToExtraWnd( Point(0,0) - Point( long(0.05*aDlgSize
.Width()), 0 ) - Point( aExtraWndSize
.Width(), 0 ) );
428 // Pos Extrawindow on the right side of Dialog
429 MoveToExtraWnd ( Point( long(1.05*aDlgSize
.getWidth()), 0 ) );
432 // Set size of Extra-Window
433 mpMarkWnd
->SetSizePixel( Size( aExtraWndSize
.Width(), aDlgSize
.Height() ) );
436 /*************************************************************************
440 \************************************************************************/
442 void SvxHyperlinkTabPageBase::FillStandardDlgFields ( SvxHyperlinkItem
* pHyperlinkItem
)
445 USHORT nPos
= mpCbbFrame
->GetEntryPos ( pHyperlinkItem
->GetTargetFrame() );
446 if ( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
447 mpCbbFrame
->SetText ( pHyperlinkItem
->GetTargetFrame() );
450 String aStrFormText
= SVX_RESSTR( RID_SVXSTR_HYPERDLG_FROM_TEXT
);
451 String aStrFormButton
= SVX_RESSTR( RID_SVXSTR_HYPERDLG_FORM_BUTTON
);
453 if( pHyperlinkItem
->GetInsertMode() & HLINK_HTMLMODE
)
456 mpLbForm
->InsertEntry( aStrFormText
);
457 mpLbForm
->SelectEntryPos ( 0 );
462 mpLbForm
->InsertEntry( aStrFormText
);
463 mpLbForm
->InsertEntry( aStrFormButton
);
464 mpLbForm
->SelectEntryPos ( pHyperlinkItem
->GetInsertMode() == HLINK_BUTTON
? 1 : 0 );
468 mpEdIndication
->SetText ( pHyperlinkItem
->GetName() );
471 mpEdText
->SetText ( pHyperlinkItem
->GetIntName() );
474 if ( !pHyperlinkItem
->GetMacroEvents() )
475 mpBtScript
->Disable();
477 mpBtScript
->Enable();
480 /*************************************************************************
482 |* Any action to do after apply-button is pressed
484 \************************************************************************/
486 void SvxHyperlinkTabPageBase::DoApply ()
488 // default-implemtation : do nothing
491 /*************************************************************************
493 |* Ask page whether an insert is possible
495 \************************************************************************/
497 BOOL
SvxHyperlinkTabPageBase::AskApply ()
499 // default-implementation
503 /*************************************************************************
505 |* This method would be called from bookmark-window to set new mark-string
507 \************************************************************************/
509 void SvxHyperlinkTabPageBase::SetMarkStr ( String
& /*aStrMark*/ )
511 // default-implemtation : do nothing
514 /*************************************************************************
516 |* This method will be called from the dialog-class if the state off
517 |* the online-mode has changed.
519 \************************************************************************/
521 void SvxHyperlinkTabPageBase::SetOnlineMode( BOOL
/*bEnable*/ )
523 // default-implemtation : do nothing
526 /*************************************************************************
530 |************************************************************************/
532 void SvxHyperlinkTabPageBase::SetInitFocus()
537 /*************************************************************************
539 |* Ask dialog whether the curretn doc is a HTML-doc
541 |************************************************************************/
543 BOOL
SvxHyperlinkTabPageBase::IsHTMLDoc() const
545 return ((SvxHpLinkDlg
*)mpDialog
)->IsHTMLDoc();
548 /*************************************************************************
550 |* retrieve dispatcher
552 |************************************************************************/
554 SfxDispatcher
* SvxHyperlinkTabPageBase::GetDispatcher() const
556 return ((SvxHpLinkDlg
*)mpDialog
)->GetDispatcher();
559 /*************************************************************************
561 |* Click on imagebutton : Script
563 |************************************************************************/
565 IMPL_LINK ( SvxHyperlinkTabPageBase
, ClickScriptHdl_Impl
, void *, EMPTYARG
)
567 SvxHyperlinkItem
*pHyperlinkItem
= (SvxHyperlinkItem
*)
568 GetItemSet().GetItem (SID_HYPERLINK_GETLINK
);
570 if ( pHyperlinkItem
->GetMacroEvents() )
572 // get macros from itemset
573 const SvxMacroTableDtor
* pMacroTbl
= pHyperlinkItem
->GetMacroTbl();
574 SvxMacroItem
aItem ( GetWhich(SID_ATTR_MACROITEM
) );
576 aItem
.SetMacroTable( *pMacroTbl
);
578 // create empty itemset for macro-dlg
579 SfxItemSet
* pItemSet
= new SfxItemSet(SFX_APP()->GetPool(),
581 SID_ATTR_MACROITEM
);
582 pItemSet
->Put ( aItem
, SID_ATTR_MACROITEM
);
584 // --> PB 2006-01-13 #123474#
585 /* disable HyperLinkDlg for input while the MacroAssignDlg is working
586 because if no JAVA is installed an error box occurs and then it is possible
587 to close the HyperLinkDlg before its child (MacroAssignDlg) -> GPF
589 BOOL bIsInputEnabled
= GetParent()->IsInputEnabled();
590 if ( bIsInputEnabled
)
591 GetParent()->EnableInput( FALSE
);
593 SfxMacroAssignDlg
aDlg( this, mxDocumentFrame
, *pItemSet
);
596 SfxMacroTabPage
*pMacroPage
= (SfxMacroTabPage
*) aDlg
.GetTabPage();
598 if ( pHyperlinkItem
->GetMacroEvents() & HYPERDLG_EVENT_MOUSEOVER_OBJECT
)
599 pMacroPage
->AddEvent( String( SVX_RESSTR(RID_SVXSTR_HYPDLG_MACROACT1
) ),
600 SFX_EVENT_MOUSEOVER_OBJECT
);
601 if ( pHyperlinkItem
->GetMacroEvents() & HYPERDLG_EVENT_MOUSECLICK_OBJECT
)
602 pMacroPage
->AddEvent( String( SVX_RESSTR(RID_SVXSTR_HYPDLG_MACROACT2
) ),
603 SFX_EVENT_MOUSECLICK_OBJECT
);
604 if ( pHyperlinkItem
->GetMacroEvents() & HYPERDLG_EVENT_MOUSEOUT_OBJECT
)
605 pMacroPage
->AddEvent( String( SVX_RESSTR(RID_SVXSTR_HYPDLG_MACROACT3
) ),
606 SFX_EVENT_MOUSEOUT_OBJECT
);
608 // --> PB 2006-01-13 #123474#
609 if ( bIsInputEnabled
)
610 GetParent()->EnableInput( TRUE
);
613 DisableClose( sal_True
);
614 short nRet
= aDlg
.Execute();
615 DisableClose( sal_False
);
616 if ( RET_OK
== nRet
)
618 const SfxItemSet
* pOutSet
= aDlg
.GetOutputItemSet();
619 const SfxPoolItem
* pItem
;
620 if( SFX_ITEM_SET
== pOutSet
->GetItemState( SID_ATTR_MACROITEM
, FALSE
, &pItem
))
622 pHyperlinkItem
->SetMacroTable( ((SvxMacroItem
*)pItem
)->GetMacroTable() );
631 /*************************************************************************
635 |************************************************************************/
637 USHORT
SvxHyperlinkTabPageBase::GetMacroEvents()
639 SvxHyperlinkItem
*pHyperlinkItem
= (SvxHyperlinkItem
*)
640 GetItemSet().GetItem (SID_HYPERLINK_GETLINK
);
642 return pHyperlinkItem
->GetMacroEvents();
645 SvxMacroTableDtor
* SvxHyperlinkTabPageBase::GetMacroTable()
647 SvxHyperlinkItem
*pHyperlinkItem
= (SvxHyperlinkItem
*)
648 GetItemSet().GetItem (SID_HYPERLINK_GETLINK
);
650 return ( (SvxMacroTableDtor
*)pHyperlinkItem
->GetMacroTbl() );
653 /*************************************************************************
655 |* Does the given file exists ?
657 |************************************************************************/
659 BOOL
SvxHyperlinkTabPageBase::FileExists( const INetURLObject
& rURL
)
663 if( rURL
.GetFull().getLength() > 0 )
667 Content
aCnt( rURL
.GetMainURL( INetURLObject::NO_DECODE
), ::com::sun::star::uno::Reference
< ::com::sun::star::ucb::XCommandEnvironment
>() );
668 ::rtl::OUString aTitle
;
670 aCnt
.getPropertyValue( ::rtl::OUString::createFromAscii( "Title" ) ) >>= aTitle
;
671 bRet
= ( aTitle
.getLength() > 0 );
675 DBG_ERROR( "FileExists: ucb error" );
682 /*************************************************************************
684 |* try to detect the current protocol that is used in aStrURL
686 |************************************************************************/
688 String
SvxHyperlinkTabPageBase::GetSchemeFromURL( String aStrURL
)
692 INetURLObject
aURL( aStrURL
);
693 INetProtocol aProtocol
= aURL
.GetProtocol();
696 // our new INetUrlObject now has the ability
697 // to detect if an Url is valid or not :-(
698 if ( aProtocol
== INET_PROT_NOT_VALID
)
700 if ( aStrURL
.EqualsIgnoreCaseAscii( INET_HTTP_SCHEME
, 0, 7 ) )
702 aStrScheme
= String::CreateFromAscii( INET_HTTP_SCHEME
);
704 else if ( aStrURL
.EqualsIgnoreCaseAscii( INET_HTTPS_SCHEME
, 0, 8 ) )
706 aStrScheme
= String::CreateFromAscii( INET_HTTPS_SCHEME
);
708 else if ( aStrURL
.EqualsIgnoreCaseAscii( INET_FTP_SCHEME
, 0, 6 ) )
710 aStrScheme
= String::CreateFromAscii( INET_FTP_SCHEME
);
712 else if ( aStrURL
.EqualsIgnoreCaseAscii( INET_MAILTO_SCHEME
, 0, 7 ) )
714 aStrScheme
= String::CreateFromAscii( INET_MAILTO_SCHEME
);
716 else if ( aStrURL
.EqualsIgnoreCaseAscii( INET_NEWS_SCHEME
, 0, 5 ) )
718 aStrScheme
= String::CreateFromAscii( INET_NEWS_SCHEME
);
720 else if ( aStrURL
.EqualsIgnoreCaseAscii( INET_TELNET_SCHEME
, 0, 9 ) )
722 aStrScheme
= String::CreateFromAscii( INET_TELNET_SCHEME
);
726 aStrScheme
= INetURLObject::GetScheme( aProtocol
);
731 void SvxHyperlinkTabPageBase::GetDataFromCommonFields( String
& aStrName
,
732 String
& aStrIntName
, String
& aStrFrame
,
733 SvxLinkInsertMode
& eMode
)
735 aStrIntName
= mpEdText
->GetText();
736 aStrName
= mpEdIndication
->GetText();
737 aStrFrame
= mpCbbFrame
->GetText();
738 eMode
= (SvxLinkInsertMode
) (mpLbForm
->GetSelectEntryPos()+1);
740 eMode
= (SvxLinkInsertMode
) ( UINT16(eMode
) | HLINK_HTMLMODE
);
743 /*************************************************************************
745 |* reset dialog-fields
747 |************************************************************************/
749 void SvxHyperlinkTabPageBase::Reset( const SfxItemSet
& rItemSet
)
751 ///////////////////////////////////////
752 // Set dialog-fields from create-itemset
753 maStrInitURL
= aEmptyStr
;
755 SvxHyperlinkItem
*pHyperlinkItem
= (SvxHyperlinkItem
*)
756 rItemSet
.GetItem (SID_HYPERLINK_GETLINK
);
758 if ( pHyperlinkItem
)
761 FillStandardDlgFields (pHyperlinkItem
);
763 // set all other fields
764 FillDlgFields ( (String
&)pHyperlinkItem
->GetURL() );
767 maStrInitURL
= pHyperlinkItem
->GetURL();
771 /*************************************************************************
773 |* Fill output-ItemSet
775 |************************************************************************/
777 BOOL
SvxHyperlinkTabPageBase::FillItemSet( SfxItemSet
& rOut
)
779 String aStrURL
, aStrName
, aStrIntName
, aStrFrame
;
780 SvxLinkInsertMode eMode
;
782 GetCurentItemData ( aStrURL
, aStrName
, aStrIntName
, aStrFrame
, eMode
);
783 if ( !aStrName
.Len() ) //automatically create a visible name if the link is created without name
784 aStrName
= CreateUiNameFromURL(aStrURL
);
786 USHORT nEvents
= GetMacroEvents();
787 SvxMacroTableDtor
* pTable
= GetMacroTable();
789 SvxHyperlinkItem
aItem( SID_HYPERLINK_SETLINK
, aStrName
, aStrURL
, aStrFrame
,
790 aStrIntName
, eMode
, nEvents
, pTable
);
796 String
SvxHyperlinkTabPageBase::CreateUiNameFromURL( const String
& aStrURL
)
799 INetURLObject
aURLObj( aStrURL
);
801 switch(aURLObj
.GetProtocol())
804 utl::LocalFileHelper::ConvertURLToSystemPath( aURLObj
.GetMainURL(INetURLObject::NO_DECODE
), aStrUiURL
);
808 //remove password from name
809 INetURLObject
aTmpURL(aURLObj
);
810 aTmpURL
.SetPass(aEmptyStr
);
811 aStrUiURL
= aTmpURL
.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS
);
816 aStrUiURL
= aURLObj
.GetMainURL(INetURLObject::DECODE_UNAMBIGUOUS
);
824 /*************************************************************************
826 |* Activate / Deactivate Tabpage
828 |************************************************************************/
830 void SvxHyperlinkTabPageBase::ActivatePage( const SfxItemSet
& rItemSet
)
832 ///////////////////////////////////////
833 // Set dialog-fields from input-itemset
834 SvxHyperlinkItem
*pHyperlinkItem
= (SvxHyperlinkItem
*)
835 rItemSet
.GetItem (SID_HYPERLINK_GETLINK
);
837 if ( pHyperlinkItem
)
840 FillStandardDlgFields (pHyperlinkItem
);
843 // show mark-window if it was open before
844 if ( ShouldOpenMarkWnd () )
848 int SvxHyperlinkTabPageBase::DeactivatePage( SfxItemSet
* _pSet
)
851 SetMarkWndShouldOpen( IsMarkWndVisible () );
854 // retrieve data of dialog
855 String aStrURL
, aStrName
, aStrIntName
, aStrFrame
;
856 SvxLinkInsertMode eMode
;
858 GetCurentItemData ( aStrURL
, aStrName
, aStrIntName
, aStrFrame
, eMode
);
860 USHORT nEvents
= GetMacroEvents();
861 SvxMacroTableDtor
* pTable
= GetMacroTable();
865 SvxHyperlinkItem
aItem( SID_HYPERLINK_GETLINK
, aStrName
, aStrURL
, aStrFrame
,
866 aStrIntName
, eMode
, nEvents
, pTable
);
870 return( LEAVE_PAGE
);
873 BOOL
SvxHyperlinkTabPageBase::ShouldOpenMarkWnd()
878 void SvxHyperlinkTabPageBase::SetMarkWndShouldOpen(BOOL
)