merge the formfield patch from ooo-build
[ooovba.git] / svx / source / cui / linkdlg.cxx
blobfe67a8de99754fd3fcd8ae0e9c55cb61f4777cdf
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: linkdlg.cxx,v $
10 * $Revision: 1.14 $
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
36 #endif
38 #include <linkdlg.hxx>
39 #include <vcl/svapp.hxx>
41 #include <tools/urlobj.hxx>
42 #include <svtools/svmedit.hxx>
43 #include <svtools/filedlg.hxx>
44 #include <vcl/dialog.hxx>
45 #include <vcl/button.hxx>
46 #include <vcl/fixed.hxx>
47 #include <vcl/group.hxx>
48 #include <vcl/lstbox.hxx>
49 #include <vcl/msgbox.hxx>
50 #include <vcl/timer.hxx>
51 #include <svtools/svtabbx.hxx>
53 #include <svuidlg.hrc>
54 #include <sfx2/linkmgr.hxx>
55 #include <sfx2/linksrc.hxx>
56 #include <svtools/soerr.hxx>
57 #include <sfx2/lnkbase.hxx>
58 #include <sfx2/objsh.hxx>
60 #include <svx/dialmgr.hxx>
62 #define _SVSTDARR_USHORTS
63 #include <svtools/svstdarr.hxx>
65 #define MAX_FILENAME 18
66 #define MAX_LINKNAME 18
67 #define MAX_TYPENAME 15
68 #define MAX_UPDATENAME 10
70 #define FILEOBJECT ( OBJECT_CLIENT_FILE & ~OBJECT_CLIENT_SO )
72 using namespace sfx2;
74 SV_DECL_IMPL_REF_LIST(SvBaseLink,SvBaseLink*)
76 // Achtung im Code wird dieses Array direkt (0, 1, ...) indiziert
77 static long nTabs[] =
78 { 4, // Number of Tabs
79 0, 77, 144, 209
83 SvBaseLinksDlg::SvBaseLinksDlg( Window * pParent, SvLinkManager* pMgr, BOOL bHtml )
84 : ModalDialog( pParent, SVX_RES( MD_UPDATE_BASELINKS ) ),
85 aFtFiles( this, SVX_RES( FT_FILES ) ),
86 aFtLinks( this, SVX_RES( FT_LINKS ) ),
87 aFtType( this, SVX_RES( FT_TYPE ) ),
88 aFtStatus( this, SVX_RES( FT_STATUS ) ),
89 aCancelButton1( this, SVX_RES( 1 ) ),
90 aHelpButton1( this, SVX_RES( 1 ) ),
91 aPbUpdateNow( this, SVX_RES( PB_UPDATE_NOW ) ),
92 aPbOpenSource( this, SVX_RES( PB_OPEN_SOURCE ) ),
93 aPbChangeSource( this, SVX_RES( PB_CHANGE_SOURCE ) ),
94 aPbBreakLink( this, SVX_RES( PB_BREAK_LINK ) ),
95 aFtFiles2( this, SVX_RES( FT_FILES2 ) ),
96 aFtSource2( this, SVX_RES( FT_SOURCE2 ) ),
97 aFtType2( this, SVX_RES( FT_TYPE2 ) ),
98 aFtUpdate( this, SVX_RES( FT_UPDATE ) ),
99 aRbAutomatic( this, SVX_RES( RB_AUTOMATIC ) ),
100 aRbManual( this, SVX_RES( RB_MANUAL ) ),
101 aFtFullFileName( this, SVX_RES( FT_FULL_FILE_NAME ) ),
102 aFtFullSourceName( this, SVX_RES( FT_FULL_SOURCE_NAME ) ),
103 aFtFullTypeName( this, SVX_RES( FT_FULL_TYPE_NAME ) ),
104 aStrAutolink( SVX_RES( STR_AUTOLINK ) ),
105 aStrManuallink( SVX_RES( STR_MANUALLINK ) ),
106 aStrBrokenlink( SVX_RES( STR_BROKENLINK ) ),
107 aStrGraphiclink( SVX_RES( STR_GRAPHICLINK ) ),
108 aStrButtonclose( SVX_RES( STR_BUTTONCLOSE ) ),
109 aStrCloselinkmsg( SVX_RES( STR_CLOSELINKMSG ) ),
110 aStrCloselinkmsgMulti( SVX_RES( STR_CLOSELINKMSG_MULTI ) ),
111 aStrWaitinglink( SVX_RES( STR_WAITINGLINK ) ),
112 pLinkMgr( NULL ),
113 bHtmlMode(bHtml),
114 aTbLinks( this, SVX_RES(TB_LINKS ) )
116 FreeResource();
118 aTbLinks.SetHelpId(HID_LINKDLG_TABLB);
119 aTbLinks.SetSelectionMode( MULTIPLE_SELECTION );
120 aTbLinks.SetTabs( &nTabs[0], MAP_APPFONT );
121 aTbLinks.Resize(); // OS: Hack fuer richtige Selektion
123 //JP 24.02.99: UpdateTimer fuer DDE-/Grf-Links, auf die gewarted wird
124 aUpdateTimer.SetTimeoutHdl( LINK( this, SvBaseLinksDlg, UpdateWaitingHdl ) );
125 aUpdateTimer.SetTimeout( 1000 );
127 OpenSource().Hide();
129 Links().SetSelectHdl( LINK( this, SvBaseLinksDlg, LinksSelectHdl ) );
130 Links().SetDoubleClickHdl( LINK( this, SvBaseLinksDlg, LinksDoubleClickHdl ) );
131 Automatic().SetClickHdl( LINK( this, SvBaseLinksDlg, AutomaticClickHdl ) );
132 Manual().SetClickHdl( LINK( this, SvBaseLinksDlg, ManualClickHdl ) );
133 UpdateNow().SetClickHdl( LINK( this, SvBaseLinksDlg, UpdateNowClickHdl ) );
134 // OpenSource().SetClickHdl( LINK( this, SvBaseLinksDlg, OpenSourceClickHdl ) );
135 ChangeSource().SetClickHdl( LINK( this, SvBaseLinksDlg, ChangeSourceClickHdl ) );
136 if(!bHtmlMode)
137 BreakLink().SetClickHdl( LINK( this, SvBaseLinksDlg, BreakLinkClickHdl ) );
138 else
139 BreakLink().Hide();
141 SetManager( pMgr );
144 SvBaseLinksDlg::~SvBaseLinksDlg()
148 /*************************************************************************
149 |* SvBaseLinksDlg::Handler()
151 |* Beschreibung
152 |* Ersterstellung MM 14.06.94
153 |* Letzte Aenderung JP 30.05.95
154 *************************************************************************/
155 IMPL_LINK( SvBaseLinksDlg, LinksSelectHdl, SvTabListBox *, pSvTabListBox )
157 USHORT nSelectionCount = pSvTabListBox ?
158 (USHORT)pSvTabListBox->GetSelectionCount() : 0;
159 if(nSelectionCount > 1)
161 //bei Mehrfachselektion ggf. alte Eintraege deselektieren
162 SvLBoxEntry* pEntry = 0;
163 SvBaseLink* pLink = 0;
164 pEntry = pSvTabListBox->GetHdlEntry();
165 pLink = (SvBaseLink*)pEntry->GetUserData();
166 USHORT nObjectType = pLink->GetObjType();
167 if((OBJECT_CLIENT_FILE & nObjectType) != OBJECT_CLIENT_FILE)
169 pSvTabListBox->SelectAll(FALSE);
170 pSvTabListBox->Select(pEntry);
171 nSelectionCount = 1;
173 else
175 for( USHORT i = 0; i < nSelectionCount; i++)
177 pEntry = i == 0 ? pSvTabListBox->FirstSelected() :
178 pSvTabListBox->NextSelected(pEntry);
179 DBG_ASSERT(pEntry, "Wo ist der Entry?");
180 pLink = (SvBaseLink*)pEntry->GetUserData();
181 DBG_ASSERT(pLink, "Wo ist der Link?");
182 if( (OBJECT_CLIENT_FILE & pLink->GetObjType()) != OBJECT_CLIENT_FILE )
183 pSvTabListBox->Select( pEntry, FALSE );
188 UpdateNow().Enable();
190 Automatic().Disable();
191 Manual().Check();
192 Manual().Disable();
194 else
196 USHORT nPos;
197 SvBaseLink* pLink = GetSelEntry( &nPos );
198 if( !pLink )
199 return 0;
201 UpdateNow().Enable();
203 String sType, sLink;
204 String *pLinkNm = &sLink, *pFilter = 0;
206 if( FILEOBJECT & pLink->GetObjType() )
208 Automatic().Disable();
209 Manual().Check();
210 Manual().Disable();
211 if( OBJECT_CLIENT_GRF == pLink->GetObjType() )
212 pLinkNm = 0, pFilter = &sLink;
214 else
216 Automatic().Enable();
217 Manual().Enable();
219 if( LINKUPDATE_ALWAYS == pLink->GetUpdateMode() )
220 Automatic().Check();
221 else
222 Manual().Check();
225 String aFileName;
226 pLinkMgr->GetDisplayNames( pLink, &sType, &aFileName, pLinkNm, pFilter );
227 aFileName = INetURLObject::decode(aFileName, INET_HEX_ESCAPE, INetURLObject::DECODE_UNAMBIGUOUS);
228 FileName().SetText( aFileName );
229 SourceName().SetText( sLink );
230 TypeName().SetText( sType );
232 return 0;
235 IMPL_LINK_INLINE_START( SvBaseLinksDlg, LinksDoubleClickHdl, SvTabListBox *, pSvTabListBox )
237 (void)pSvTabListBox;
239 ChangeSourceClickHdl( 0 );
240 return 0;
242 IMPL_LINK_INLINE_END( SvBaseLinksDlg, LinksDoubleClickHdl, SvTabListBox *, pSvTabListBox )
244 IMPL_LINK_INLINE_START( SvBaseLinksDlg, AutomaticClickHdl, RadioButton *, pRadioButton )
246 (void)pRadioButton;
248 USHORT nPos;
249 SvBaseLink* pLink = GetSelEntry( &nPos );
250 if( pLink && !( FILEOBJECT & pLink->GetObjType() ) &&
251 LINKUPDATE_ALWAYS != pLink->GetUpdateMode() )
252 SetType( *pLink, nPos, LINKUPDATE_ALWAYS );
253 return 0;
255 IMPL_LINK_INLINE_END( SvBaseLinksDlg, AutomaticClickHdl, RadioButton *, pRadioButton )
257 IMPL_LINK_INLINE_START( SvBaseLinksDlg, ManualClickHdl, RadioButton *, pRadioButton )
259 (void)pRadioButton;
261 USHORT nPos;
262 SvBaseLink* pLink = GetSelEntry( &nPos );
263 if( pLink && !( FILEOBJECT & pLink->GetObjType() ) &&
264 LINKUPDATE_ONCALL != pLink->GetUpdateMode())
265 SetType( *pLink, nPos, LINKUPDATE_ONCALL );
266 return 0;
268 IMPL_LINK_INLINE_END( SvBaseLinksDlg, ManualClickHdl, RadioButton *, pRadioButton )
270 IMPL_LINK( SvBaseLinksDlg, UpdateNowClickHdl, PushButton *, EMPTYARG )
272 SvTabListBox& rListBox = Links();
273 USHORT nSelCnt = (USHORT)rListBox.GetSelectionCount();
274 if( 255 < nSelCnt )
275 nSelCnt = 255;
277 std::vector< SvBaseLink* > aLnkArr;
278 std::vector< USHORT > aPosArr;
280 SvLBoxEntry* pE = rListBox.FirstSelected();
281 while( pE )
283 USHORT nFndPos = (USHORT)rListBox.GetModel()->GetAbsPos( pE );
284 if( LISTBOX_ENTRY_NOTFOUND != nFndPos )
286 aLnkArr.push_back( static_cast< SvBaseLink* >( pE->GetUserData() ) );
287 aPosArr.push_back( nFndPos );
289 pE = rListBox.NextSelected( pE );
292 if( !aLnkArr.empty() )
294 for( USHORT n = 0; n < aLnkArr.size(); ++n )
296 SvBaseLinkRef xLink = aLnkArr[ n ];
298 // suche erstmal im Array nach dem Eintrag
299 for( USHORT i = 0; i < pLinkMgr->GetLinks().Count(); ++i )
300 if( &xLink == *pLinkMgr->GetLinks()[ i ] )
302 xLink->SetUseCache( FALSE );
303 SetType( *xLink, aPosArr[ n ], xLink->GetUpdateMode() );
304 xLink->SetUseCache( TRUE );
305 break;
309 // falls jemand der Meinung ist, seine Links auszutauschen (SD)
310 SvLinkManager* pNewMgr = pLinkMgr;
311 pLinkMgr = 0;
312 SetManager( pNewMgr );
315 if( 0 == (pE = rListBox.GetEntry( aPosArr[ 0 ] )) ||
316 pE->GetUserData() != aLnkArr[ 0 ] )
318 // suche mal den Link
319 pE = rListBox.First();
320 while( pE )
322 if( pE->GetUserData() == aLnkArr[ 0 ] )
323 break;
324 pE = rListBox.Next( pE );
327 if( !pE )
328 pE = rListBox.FirstSelected();
331 if( pE )
333 SvLBoxEntry* pSelEntry = rListBox.FirstSelected();
334 if( pE != pSelEntry )
335 rListBox.Select( pSelEntry, FALSE );
336 rListBox.Select( pE );
337 rListBox.MakeVisible( pE );
340 return 0;
344 IMPL_LINK_INLINE_START( SvBaseLinksDlg, OpenSourceClickHdl, PushButton *, pPushButton )
346 DBG_ASSERT( !this, "Open noch nicht impl." );
347 return 0;
349 IMPL_LINK_INLINE_END( SvBaseLinksDlg, OpenSourceClickHdl, PushButton *, pPushButton )
352 IMPL_LINK( SvBaseLinksDlg, ChangeSourceClickHdl, PushButton *, pPushButton )
354 (void)pPushButton;
356 USHORT nSelectionCount = (USHORT)Links().GetSelectionCount();
357 if(nSelectionCount > 1)
359 PathDialog aPathDlg( this );
360 String sType, sFile, sLinkName;
361 String sFilter;
362 SvLBoxEntry* pEntry = Links().FirstSelected();
363 SvBaseLink* pLink = (SvBaseLink*)pEntry->GetUserData();
364 pLinkMgr->GetDisplayNames( pLink, &sType, &sFile, 0, 0 );
365 INetURLObject aUrl(sFile);
366 if(aUrl.GetProtocol() == INET_PROT_FILE)
368 rtl::OUString sOldPath(aUrl.PathToFileName());
369 sal_Int32 nLen = aUrl.GetName().getLength();
370 sOldPath = sOldPath.copy(0, sOldPath.getLength() - nLen);
371 aPathDlg.SetPath(sOldPath);
373 if(aPathDlg.Execute() == RET_OK)
375 String aPath = aPathDlg.GetPath();
377 for( USHORT i = 0; i < nSelectionCount; i++)
379 pEntry = i==0 ?
380 Links().FirstSelected() :
381 Links().NextSelected( pEntry );
382 DBG_ASSERT(pEntry,"Wo ist der Entry");
383 pLink = (SvBaseLink*)pEntry->GetUserData();
384 DBG_ASSERT(pLink,"Wo ist der Link");
385 pLinkMgr->GetDisplayNames( pLink, &sType, &sFile, &sLinkName, &sFilter );
386 INetURLObject aUrl_(sFile);
387 INetURLObject aUrl2(aPath, INET_PROT_FILE);
388 aUrl2.insertName( aUrl_.getName() );
389 String sNewLinkName;
390 MakeLnkName( sNewLinkName, 0 ,
391 aUrl2.GetMainURL(INetURLObject::DECODE_TO_IURI), sLinkName, &sFilter);
392 pLink->SetLinkSourceName( sNewLinkName );
393 pLink->Update();
395 if( pLinkMgr->GetPersist() )
396 pLinkMgr->GetPersist()->SetModified();
397 SvLinkManager* pNewMgr = pLinkMgr;
398 pLinkMgr = 0;
399 SetManager( pNewMgr );
402 else
404 USHORT nPos;
405 SvBaseLink* pLink = GetSelEntry( &nPos );
406 if ( pLink && (pLink->GetLinkSourceName().Len() != 0) )
407 pLink->Edit( this, LINK( this, SvBaseLinksDlg, EndEditHdl ) );
409 return 0;
412 IMPL_LINK( SvBaseLinksDlg, BreakLinkClickHdl, PushButton *, pPushButton )
414 (void)pPushButton;
416 BOOL bModified = FALSE;
417 if(Links().GetSelectionCount() <= 1)
419 USHORT nPos;
420 SvBaseLinkRef xLink = GetSelEntry( &nPos );
421 if( !xLink.Is() )
422 return 0;
424 QueryBox aBox( this, WB_YES_NO | WB_DEF_YES, Closelinkmsg() );
426 if( RET_YES == aBox.Execute() )
428 Links().GetModel()->Remove( Links().GetEntry( nPos ) );
430 // falls Object noch vorhanden, dann das schliessen
431 BOOL bNewLnkMgr = OBJECT_CLIENT_FILE == xLink->GetObjType();
433 // dem Link sagen, das er aufgeloest wird!
434 xLink->Closed();
436 // falls einer vergessen hat sich auszutragen
437 if( xLink.Is() )
438 pLinkMgr->Remove( &xLink );
440 if( bNewLnkMgr )
442 SvLinkManager* pNewMgr = pLinkMgr;
443 pLinkMgr = 0;
444 SetManager( pNewMgr );
446 SvLBoxEntry* pEntry = Links().GetEntry( nPos ? --nPos : 0 );
447 if( pEntry )
448 Links().SetCurEntry( pEntry );
450 bModified = TRUE;
453 else
455 QueryBox aBox( this, WB_YES_NO | WB_DEF_YES, CloselinkmsgMulti() );
457 if( RET_YES == aBox.Execute() )
460 SvBaseLinkMemberList aLinkList;
461 SvLBoxEntry* pEntry = Links().FirstSelected();
462 while ( pEntry )
464 void * pUD = pEntry->GetUserData();
465 if( pUD )
466 aLinkList.Append( (SvBaseLink*)pUD );
467 pEntry = Links().NextSelected(pEntry);
469 Links().RemoveSelection();
470 for( ULONG i = 0; i < aLinkList.Count(); i++ )
472 SvBaseLinkRef xLink = aLinkList.GetObject( i );
473 // dem Link sagen, das er aufgeloest wird!
474 xLink->Closed();
476 // falls einer vergessen hat sich auszutragen
477 pLinkMgr->Remove( &xLink );
478 bModified = TRUE;
480 //Danach alle selektierten Eintraege entfernen
483 if(bModified)
485 if( !Links().GetEntryCount() )
487 // Der letzte macht das Licht aus
488 Automatic().Disable();
489 Manual().Disable();
490 UpdateNow().Disable();
491 // OpenSource().Disable();
492 ChangeSource().Disable();
493 BreakLink().Disable();
495 String aEmpty;
496 SourceName().SetText( aEmpty );
497 TypeName().SetText( aEmpty );
499 if( pLinkMgr->GetPersist() )
500 pLinkMgr->GetPersist()->SetModified();
502 return 0;
505 IMPL_LINK( SvBaseLinksDlg, UpdateWaitingHdl, Timer*, pTimer )
507 (void)pTimer;
508 // for( SvLBoxEntry* pBox = Links().First(); pBox;
509 // pBox = Links().Next( pBox ))
511 Links().SetUpdateMode(FALSE);
512 for( ULONG nPos = Links().GetEntryCount(); nPos; )
514 SvLBoxEntry* pBox = Links().GetEntry( --nPos );
515 SvBaseLinkRef xLink( (SvBaseLink*)pBox->GetUserData() );
516 if( xLink.Is() )
518 String sCur( ImplGetStateStr( *xLink ) ),
519 sOld( Links().GetEntryText( pBox, 3 ) );
520 if( sCur != sOld )
521 Links().SetEntryText( sCur, pBox, 3 );
524 Links().SetUpdateMode(TRUE);
525 return 0;
528 IMPL_LINK( SvBaseLinksDlg, EndEditHdl, sfx2::SvBaseLink*, _pLink )
530 USHORT nPos;
531 SvBaseLink* pLink = GetSelEntry( &nPos );
533 if ( pLink != _pLink && _pLink && _pLink->WasLastEditOK() )
535 // JP 09.01.98:
536 // StarImpress/Draw tauschen die LinkObjecte selbst aus!
537 // also suche den Link im Manager, wenn der nicht mehr existiert,
538 // dann setze fuelle die Liste komplett neu. Ansonsten braucht
539 // nur der editierte Linkt aktualisiert werden.
540 BOOL bLinkFnd = FALSE;
541 for( USHORT n = pLinkMgr->GetLinks().Count(); n; )
542 if( _pLink == &(*pLinkMgr->GetLinks()[ --n ]) )
544 bLinkFnd = TRUE;
545 break;
548 if( bLinkFnd )
550 Links().SetUpdateMode(FALSE);
551 Links().GetModel()->Remove( Links().GetEntry( nPos ) );
552 SvLBoxEntry* pToUnselect = Links().FirstSelected();
553 InsertEntry( *_pLink, nPos, sal_True );
554 if(pToUnselect)
555 Links().Select(pToUnselect, FALSE);
556 Links().SetUpdateMode(TRUE);
558 else
560 SvLinkManager* pNewMgr = pLinkMgr;
561 pLinkMgr = 0;
562 SetManager( pNewMgr );
564 if( pLinkMgr->GetPersist() )
565 pLinkMgr->GetPersist()->SetModified();
567 else if ( pLink == _pLink )
569 DBG_ERRORFILE( "SvBaseLinksDlg::EndEditHdl(): wrong link" );
571 return 0;
574 String SvBaseLinksDlg::ImplGetStateStr( const SvBaseLink& rLnk )
576 String sRet;
577 if( !rLnk.GetObj() )
578 sRet = Brokenlink();
579 else if( rLnk.GetObj()->IsPending() )
581 sRet = Waitinglink();
582 StartUpdateTimer();
584 else if( LINKUPDATE_ALWAYS == rLnk.GetUpdateMode() )
585 sRet = Autolink();
586 else
587 sRet = Manuallink();
589 return sRet;
592 void SvBaseLinksDlg::SetManager( SvLinkManager* pNewMgr )
594 if( pLinkMgr == pNewMgr )
595 return;
597 if( pNewMgr )
598 // Update muss vor Clear gestoppt werden
599 Links().SetUpdateMode( FALSE );
601 Links().Clear();
602 pLinkMgr = pNewMgr;
604 if( pLinkMgr )
606 SvBaseLinks& rLnks = (SvBaseLinks&)pLinkMgr->GetLinks();
607 for( USHORT n = 0; n < rLnks.Count(); ++n )
609 SvBaseLinkRef* pLinkRef = rLnks[ n ];
610 if( !pLinkRef->Is() )
612 rLnks.Remove( n, 1 );
613 --n;
614 continue;
616 if( (*pLinkRef)->IsVisible() )
617 InsertEntry( **pLinkRef );
620 if( rLnks.Count() )
622 SvLBoxEntry* pEntry = Links().GetEntry( 0 );
623 Links().SetCurEntry( pEntry );
624 Links().Select( pEntry );
625 LinksSelectHdl( 0 );
627 Links().SetUpdateMode( TRUE );
628 Links().Invalidate();
633 void SvBaseLinksDlg::InsertEntry( const SvBaseLink& rLink, USHORT nPos, sal_Bool bSelect )
635 String aEntry, sFileNm, sLinkNm, sTypeNm, sFilter;
637 pLinkMgr->GetDisplayNames( (SvBaseLink*)&rLink, &sTypeNm, &sFileNm, &sLinkNm, &sFilter );
639 // GetTab(0) gibt die Position der von der TabListBox automatisch eingefuegten
640 // Bitmap. Die Breite der ersten Textspalte ergibt sich deshalb aus Tab(2)-Tab(1)
641 long nWidthPixel = Links().GetLogicTab( 2 ) - Links().GetLogicTab( 1 );
642 nWidthPixel -= SV_TAB_BORDER;
643 XubString aTxt = Links().GetEllipsisString( sFileNm, nWidthPixel, TEXT_DRAW_PATHELLIPSIS );
644 INetURLObject aPath( sFileNm, INET_PROT_FILE );
645 String aFileName = aPath.getName();
646 if( aFileName.Len() > aTxt.Len() )
647 aTxt = aFileName;
648 else if( aTxt.Search( aFileName, aTxt.Len() - aFileName.Len() ) == STRING_NOTFOUND )
649 // filename not in string
650 aTxt = aFileName;
652 aEntry = aTxt;
653 aEntry += '\t';
654 if( OBJECT_CLIENT_GRF == rLink.GetObjType() )
655 aEntry += sFilter;
656 else
657 aEntry += sLinkNm;
658 aEntry += '\t';
659 aEntry += sTypeNm;
660 aEntry += '\t';
661 aEntry += ImplGetStateStr( rLink );
663 SvLBoxEntry * pE = Links().InsertEntryToColumn( aEntry, nPos );
664 pE->SetUserData( (void*)&rLink );
665 if(bSelect)
666 Links().Select(pE);
669 SvBaseLink* SvBaseLinksDlg::GetSelEntry( USHORT* pPos )
671 SvLBoxEntry* pE = Links().FirstSelected();
672 USHORT nPos;
673 if( pE && LISTBOX_ENTRY_NOTFOUND !=
674 ( nPos = (USHORT)Links().GetModel()->GetAbsPos( pE ) ) )
676 DBG_ASSERT( pE, "wo kommt der leere Eintrag her?" );
678 if( pPos )
679 *pPos = nPos;
680 return (SvBaseLink*)pE->GetUserData();
682 return 0;
685 void SvBaseLinksDlg::SetType( SvBaseLink& rLink,
686 USHORT nSelPos,
687 USHORT nType )
689 rLink.SetUpdateMode( nType );
690 rLink.Update();
691 SvLBoxEntry* pBox = Links().GetEntry( nSelPos );
692 Links().SetEntryText( ImplGetStateStr( rLink ), pBox, 3 );
693 if( pLinkMgr->GetPersist() )
694 pLinkMgr->GetPersist()->SetModified();
697 void SvBaseLinksDlg::SetActLink( SvBaseLink * pLink )
699 if( pLinkMgr )
701 const SvBaseLinks& rLnks = pLinkMgr->GetLinks();
702 USHORT nSelect = 0;
703 for( USHORT n = 0; n < rLnks.Count(); ++n )
705 SvBaseLinkRef* pLinkRef = rLnks[ n ];
706 // #109573# only visible links have been inserted into the TreeListBox,
707 // invisible ones have to be skipped here
708 if( (*pLinkRef)->IsVisible() )
710 if( pLink == *pLinkRef )
712 Links().Select( Links().GetEntry( nSelect ) );
713 LinksSelectHdl( 0 );
714 return ;
716 nSelect++;