1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <linkdlg.hxx>
21 #include <vcl/svapp.hxx>
24 #include <tools/urlobj.hxx>
25 #include <svtools/svmedit.hxx>
26 #include <vcl/dialog.hxx>
27 #include <vcl/button.hxx>
28 #include <vcl/fixed.hxx>
29 #include <vcl/group.hxx>
30 #include <vcl/lstbox.hxx>
31 #include <vcl/msgbox.hxx>
32 #include <vcl/timer.hxx>
33 #include <vcl/idle.hxx>
34 #include <svtools/svtabbx.hxx>
35 #include "svtools/treelistentry.hxx"
37 #include <svuidlg.hrc>
38 #include <sfx2/linkmgr.hxx>
39 #include <sfx2/linksrc.hxx>
40 #include <svtools/soerr.hxx>
41 #include <sfx2/lnkbase.hxx>
42 #include <sfx2/objsh.hxx>
44 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
45 #include <com/sun/star/ui/dialogs/FolderPicker.hpp>
46 #include <comphelper/processfactory.hxx>
48 #include <dialmgr.hxx>
51 #define FILEOBJECT ( OBJECT_CLIENT_FILE & ~OBJECT_CLIENT_SO )
54 using namespace ::com::sun::star
;
56 class SvBaseLinkMemberList
{
58 std::vector
<SvBaseLink
*> mLinks
;
61 ~SvBaseLinkMemberList()
63 for( std::vector
<SvBaseLink
*>::const_iterator it
= mLinks
.begin(); it
!= mLinks
.end(); ++it
)
71 size_t size() const { return mLinks
.size(); }
73 SvBaseLink
*operator[](size_t i
) const { return mLinks
[i
]; }
75 void push_back(SvBaseLink
* p
)
82 // attention, this array is indexed directly (0, 1, ...) in the code
84 { 4, // Number of Tabs
89 SvBaseLinksDlg::SvBaseLinksDlg( vcl::Window
* pParent
, LinkManager
* pMgr
, bool bHtml
)
90 : ModalDialog( pParent
, "BaseLinksDialog", "cui/ui/baselinksdialog.ui"),
91 aStrAutolink( CUI_RES( STR_AUTOLINK
) ),
92 aStrManuallink( CUI_RES( STR_MANUALLINK
) ),
93 aStrBrokenlink( CUI_RES( STR_BROKENLINK
) ),
94 aStrGraphiclink( CUI_RES( STR_GRAPHICLINK
) ),
95 aStrButtonclose( CUI_RES( STR_BUTTONCLOSE
) ),
96 aStrCloselinkmsg( CUI_RES( STR_CLOSELINKMSG
) ),
97 aStrCloselinkmsgMulti( CUI_RES( STR_CLOSELINKMSG_MULTI
) ),
98 aStrWaitinglink( CUI_RES( STR_WAITINGLINK
) ),
102 get(m_pTbLinks
, "TB_LINKS");
103 Size
aSize(LogicToPixel(Size(257, 87), MAP_APPFONT
));
104 m_pTbLinks
->set_width_request(aSize
.Width());
105 m_pTbLinks
->set_height_request(aSize
.Height());
106 get(m_pFtFullFileName
, "FULL_FILE_NAME");
107 get(m_pFtFullSourceName
, "FULL_SOURCE_NAME");
108 get(m_pFtFullTypeName
, "FULL_TYPE_NAME");
109 get(m_pRbAutomatic
, "AUTOMATIC");
110 get(m_pRbManual
, "MANUAL");
111 get(m_pPbUpdateNow
, "UPDATE_NOW");
112 get(m_pPbOpenSource
, "OPEN");
113 get(m_pPbChangeSource
, "CHANGE_SOURCE");
114 get(m_pPbBreakLink
, "BREAK_LINK");
116 m_pTbLinks
->SetSelectionMode( MULTIPLE_SELECTION
);
117 m_pTbLinks
->SetTabs( &nTabs
[0], MAP_APPFONT
);
118 FixedText
*pFtFiles
= get
<FixedText
>("FILES");
119 pFtFiles
->set_width_request(LogicToPixel(Size(nTabs
[2] - nTabs
[1] - 2, 0), MAP_APPFONT
).Width());
120 FixedText
*pFtLinks
= get
<FixedText
>("LINKS");
121 pFtLinks
->set_width_request(LogicToPixel(Size(nTabs
[3] - nTabs
[2] - 2, 0), MAP_APPFONT
).Width());
122 FixedText
*pFtTypes
= get
<FixedText
>("TYPE");
123 pFtTypes
->set_width_request(LogicToPixel(Size(nTabs
[4] - nTabs
[3] - 2, 0), MAP_APPFONT
).Width());
124 m_pTbLinks
->Resize(); // OS: hack for correct selection
126 // UpdateTimer for DDE-/Grf-links, which are waited for
127 aUpdateIdle
.SetIdleHdl( LINK( this, SvBaseLinksDlg
, UpdateWaitingHdl
) );
128 aUpdateIdle
.SetPriority( SchedulerPriority::LOWEST
);
130 m_pPbOpenSource
->Hide();
132 m_pTbLinks
->SetSelectHdl( LINK( this, SvBaseLinksDlg
, LinksSelectHdl
) );
133 m_pTbLinks
->SetDoubleClickHdl( LINK( this, SvBaseLinksDlg
, LinksDoubleClickHdl
) );
134 m_pRbAutomatic
->SetClickHdl( LINK( this, SvBaseLinksDlg
, AutomaticClickHdl
) );
135 m_pRbManual
->SetClickHdl( LINK( this, SvBaseLinksDlg
, ManualClickHdl
) );
136 m_pPbUpdateNow
->SetClickHdl( LINK( this, SvBaseLinksDlg
, UpdateNowClickHdl
) );
137 m_pPbChangeSource
->SetClickHdl( LINK( this, SvBaseLinksDlg
, ChangeSourceClickHdl
) );
139 m_pPbBreakLink
->SetClickHdl( LINK( this, SvBaseLinksDlg
, BreakLinkClickHdl
) );
141 m_pPbBreakLink
->Hide();
146 SvBaseLinksDlg::~SvBaseLinksDlg()
151 void SvBaseLinksDlg::dispose()
154 m_pFtFullFileName
.clear();
155 m_pFtFullSourceName
.clear();
156 m_pFtFullTypeName
.clear();
157 m_pRbAutomatic
.clear();
159 m_pPbUpdateNow
.clear();
160 m_pPbOpenSource
.clear();
161 m_pPbChangeSource
.clear();
162 m_pPbBreakLink
.clear();
163 ModalDialog::dispose();
166 /*************************************************************************
167 |* SvBaseLinksDlg::Handler()
168 *************************************************************************/
169 IMPL_LINK( SvBaseLinksDlg
, LinksSelectHdl
, SvTabListBox
*, pSvTabListBox
)
171 sal_uLong nSelectionCount
= pSvTabListBox
?
172 pSvTabListBox
->GetSelectionCount() : 0;
173 if(nSelectionCount
> 1)
175 // possibly deselect old entries in case of multi-selection
176 SvTreeListEntry
* pEntry
= 0;
177 SvBaseLink
* pLink
= 0;
178 pEntry
= pSvTabListBox
->GetHdlEntry();
179 pLink
= static_cast<SvBaseLink
*>(pEntry
->GetUserData());
180 sal_uInt16 nObjectType
= pLink
->GetObjType();
181 if((OBJECT_CLIENT_FILE
& nObjectType
) != OBJECT_CLIENT_FILE
)
183 pSvTabListBox
->SelectAll(false);
184 pSvTabListBox
->Select(pEntry
);
189 for( sal_uLong i
= 0; i
< nSelectionCount
; i
++)
191 pEntry
= i
== 0 ? pSvTabListBox
->FirstSelected() :
192 pSvTabListBox
->NextSelected(pEntry
);
193 DBG_ASSERT(pEntry
, "Wo ist der Entry?");
196 pLink
= static_cast<SvBaseLink
*>(pEntry
->GetUserData());
197 DBG_ASSERT(pLink
, "Wo ist der Link?");
200 if( (OBJECT_CLIENT_FILE
& pLink
->GetObjType()) != OBJECT_CLIENT_FILE
)
201 pSvTabListBox
->Select( pEntry
, false );
206 m_pPbUpdateNow
->Enable();
208 m_pRbAutomatic
->Disable();
209 m_pRbManual
->Check();
210 m_pRbManual
->Disable();
215 SvBaseLink
* pLink
= GetSelEntry( &nPos
);
219 m_pPbUpdateNow
->Enable();
221 OUString sType
, sLink
;
222 OUString
*pLinkNm
= &sLink
, *pFilter
= 0;
224 if( FILEOBJECT
& pLink
->GetObjType() )
226 m_pRbAutomatic
->Disable();
227 m_pRbManual
->Check();
228 m_pRbManual
->Disable();
229 if( OBJECT_CLIENT_GRF
== pLink
->GetObjType() )
230 pLinkNm
= 0, pFilter
= &sLink
;
234 m_pRbAutomatic
->Enable();
235 m_pRbManual
->Enable();
237 if( SfxLinkUpdateMode::ALWAYS
== pLink
->GetUpdateMode() )
238 m_pRbAutomatic
->Check();
240 m_pRbManual
->Check();
244 sfx2::LinkManager::GetDisplayNames( pLink
, &sType
, &aFileName
, pLinkNm
, pFilter
);
245 aFileName
= INetURLObject::decode(aFileName
, INetURLObject::DECODE_UNAMBIGUOUS
);
246 m_pFtFullFileName
->SetText( aFileName
);
247 m_pFtFullSourceName
->SetText( sLink
);
248 m_pFtFullTypeName
->SetText( sType
);
253 IMPL_LINK( SvBaseLinksDlg
, LinksDoubleClickHdl
, SvTabListBox
*, pSvTabListBox
)
257 ChangeSourceClickHdl( 0 );
261 IMPL_LINK( SvBaseLinksDlg
, AutomaticClickHdl
, RadioButton
*, pRadioButton
)
266 SvBaseLink
* pLink
= GetSelEntry( &nPos
);
267 if( pLink
&& !( FILEOBJECT
& pLink
->GetObjType() ) &&
268 SfxLinkUpdateMode::ALWAYS
!= pLink
->GetUpdateMode() )
269 SetType( *pLink
, nPos
, SfxLinkUpdateMode::ALWAYS
);
273 IMPL_LINK( SvBaseLinksDlg
, ManualClickHdl
, RadioButton
*, pRadioButton
)
278 SvBaseLink
* pLink
= GetSelEntry( &nPos
);
279 if( pLink
&& !( FILEOBJECT
& pLink
->GetObjType() ) &&
280 SfxLinkUpdateMode::ONCALL
!= pLink
->GetUpdateMode())
281 SetType( *pLink
, nPos
, SfxLinkUpdateMode::ONCALL
);
285 IMPL_LINK_NOARG(SvBaseLinksDlg
, UpdateNowClickHdl
)
287 SvTabListBox
& rListBox
= *m_pTbLinks
;
288 sal_uLong nSelCnt
= rListBox
.GetSelectionCount();
292 std::vector
< SvBaseLink
* > aLnkArr
;
293 std::vector
< sal_Int16
> aPosArr
;
295 SvTreeListEntry
* pE
= rListBox
.FirstSelected();
298 sal_uLong nFndPos
= rListBox
.GetModel()->GetAbsPos( pE
);
299 if( TREELIST_ENTRY_NOTFOUND
!= nFndPos
)
301 aLnkArr
.push_back( static_cast< SvBaseLink
* >( pE
->GetUserData() ) );
302 aPosArr
.push_back( nFndPos
);
304 pE
= rListBox
.NextSelected( pE
);
307 if( !aLnkArr
.empty() )
309 for( size_t n
= 0; n
< aLnkArr
.size(); ++n
)
311 SvBaseLinkRef xLink
= aLnkArr
[ n
];
313 // first look for the entry in the array
314 for( size_t i
= 0; i
< pLinkMgr
->GetLinks().size(); ++i
)
315 if( &xLink
== *pLinkMgr
->GetLinks()[ i
] )
317 xLink
->SetUseCache( false );
318 SetType( *xLink
, aPosArr
[ n
], xLink
->GetUpdateMode() );
319 xLink
->SetUseCache( true );
324 // if somebody is of the opinion to swap his links (SD)
325 LinkManager
* pNewMgr
= pLinkMgr
;
327 SetManager( pNewMgr
);
330 if( 0 == (pE
= rListBox
.GetEntry( aPosArr
[ 0 ] )) ||
331 pE
->GetUserData() != aLnkArr
[ 0 ] )
334 pE
= rListBox
.First();
337 if( pE
->GetUserData() == aLnkArr
[ 0 ] )
339 pE
= rListBox
.Next( pE
);
343 pE
= rListBox
.FirstSelected();
348 SvTreeListEntry
* pSelEntry
= rListBox
.FirstSelected();
349 if( pE
!= pSelEntry
)
350 rListBox
.Select( pSelEntry
, false );
351 rListBox
.Select( pE
);
352 rListBox
.MakeVisible( pE
);
355 pNewMgr
->CloseCachedComps();
360 IMPL_LINK( SvBaseLinksDlg
, ChangeSourceClickHdl
, PushButton
*, pPushButton
)
364 sal_uLong nSelectionCount
= m_pTbLinks
->GetSelectionCount();
365 if(nSelectionCount
> 1)
369 uno::Reference
<ui::dialogs::XFolderPicker2
> xFolderPicker
= ui::dialogs::FolderPicker::create(comphelper::getProcessComponentContext());
371 OUString sType
, sFile
, sLinkName
;
373 SvTreeListEntry
* pEntry
= m_pTbLinks
->FirstSelected();
374 SvBaseLink
* pLink
= static_cast<SvBaseLink
*>(pEntry
->GetUserData());
375 sfx2::LinkManager::GetDisplayNames( pLink
, &sType
, &sFile
, 0, 0 );
376 INetURLObject
aUrl(sFile
);
377 if(aUrl
.GetProtocol() == INetProtocol::File
)
379 OUString
sOldPath(aUrl
.PathToFileName());
380 sal_Int32 nLen
= aUrl
.GetName().getLength();
381 sOldPath
= sOldPath
.copy(0, sOldPath
.getLength() - nLen
);
382 xFolderPicker
->setDisplayDirectory(sOldPath
);
384 if (xFolderPicker
->execute() == ui::dialogs::ExecutableDialogResults::OK
)
386 OUString aPath
= xFolderPicker
->getDirectory();
388 for( sal_uLong i
= 0; i
< nSelectionCount
; i
++)
391 m_pTbLinks
->FirstSelected() :
392 m_pTbLinks
->NextSelected( pEntry
);
393 DBG_ASSERT(pEntry
,"Where is the entry?");
396 pLink
= static_cast<SvBaseLink
*>(pEntry
->GetUserData());
397 DBG_ASSERT(pLink
,"Where is the link?");
400 sfx2::LinkManager::GetDisplayNames( pLink
, &sType
, &sFile
, &sLinkName
, &sFilter
);
401 INetURLObject
aUrl_(sFile
);
402 INetURLObject
aUrl2(aPath
, INetProtocol::File
);
403 aUrl2
.insertName( aUrl_
.getName() );
404 OUString sNewLinkName
;
405 MakeLnkName( sNewLinkName
, 0 ,
406 aUrl2
.GetMainURL(INetURLObject::DECODE_TO_IURI
), sLinkName
, &sFilter
);
407 pLink
->SetLinkSourceName( sNewLinkName
);
410 if( pLinkMgr
->GetPersist() )
411 pLinkMgr
->GetPersist()->SetModified();
412 LinkManager
* pNewMgr
= pLinkMgr
;
414 SetManager( pNewMgr
);
417 catch (uno::Exception
& e
)
419 SAL_WARN("cui.dialogs", "SvBaseLinksDlg: caught UNO exception: " << e
.Message
);
425 SvBaseLink
* pLink
= GetSelEntry( &nPos
);
426 if ( pLink
&& !pLink
->GetLinkSourceName().isEmpty() )
427 pLink
->Edit( this, LINK( this, SvBaseLinksDlg
, EndEditHdl
) );
432 IMPL_LINK( SvBaseLinksDlg
, BreakLinkClickHdl
, PushButton
*, pPushButton
)
436 bool bModified
= false;
437 if(m_pTbLinks
->GetSelectionCount() <= 1)
440 SvBaseLinkRef xLink
= GetSelEntry( &nPos
);
444 ScopedVclPtrInstance
< QueryBox
> aBox( this, WB_YES_NO
| WB_DEF_YES
, Closelinkmsg() );
446 if( RET_YES
== aBox
->Execute() )
448 m_pTbLinks
->GetModel()->Remove( m_pTbLinks
->GetEntry( nPos
) );
450 // close object, if it's still existing
451 bool bNewLnkMgr
= OBJECT_CLIENT_FILE
== xLink
->GetObjType();
453 // tell the link that it will be resolved!
456 // if somebody has forgotten to deregister himself
458 pLinkMgr
->Remove( &xLink
);
462 LinkManager
* pNewMgr
= pLinkMgr
;
464 SetManager( pNewMgr
);
466 SvTreeListEntry
* pEntry
= m_pTbLinks
->GetEntry( nPos
? --nPos
: 0 );
468 m_pTbLinks
->SetCurEntry( pEntry
);
475 ScopedVclPtrInstance
< QueryBox
> aBox( this, WB_YES_NO
| WB_DEF_YES
, CloselinkmsgMulti() );
477 if( RET_YES
== aBox
->Execute() )
480 SvBaseLinkMemberList aLinkList
;
481 SvTreeListEntry
* pEntry
= m_pTbLinks
->FirstSelected();
484 void * pUD
= pEntry
->GetUserData();
486 aLinkList
.push_back( static_cast<SvBaseLink
*>(pUD
) );
487 pEntry
= m_pTbLinks
->NextSelected(pEntry
);
489 m_pTbLinks
->RemoveSelection();
490 for( sal_uLong i
= 0; i
< aLinkList
.size(); i
++ )
492 SvBaseLinkRef xLink
= aLinkList
[i
];
493 // tell the link that it will be resolved!
496 // if somebody has forgotten to deregister himself
497 pLinkMgr
->Remove( &xLink
);
500 // then remove all selected entries
505 if( !m_pTbLinks
->GetEntryCount() )
507 m_pRbAutomatic
->Disable();
508 m_pRbManual
->Disable();
509 m_pPbUpdateNow
->Disable();
510 m_pPbChangeSource
->Disable();
511 m_pPbBreakLink
->Disable();
514 m_pFtFullSourceName
->SetText( aEmpty
);
515 m_pFtFullTypeName
->SetText( aEmpty
);
517 if( pLinkMgr
&& pLinkMgr
->GetPersist() )
518 pLinkMgr
->GetPersist()->SetModified();
523 IMPL_LINK_NOARG_TYPED( SvBaseLinksDlg
, UpdateWaitingHdl
, Idle
*, void )
525 m_pTbLinks
->SetUpdateMode(false);
526 for( sal_uLong nPos
= m_pTbLinks
->GetEntryCount(); nPos
; )
528 SvTreeListEntry
* pBox
= m_pTbLinks
->GetEntry( --nPos
);
529 SvBaseLinkRef
xLink( static_cast<SvBaseLink
*>(pBox
->GetUserData()) );
532 OUString
sCur( ImplGetStateStr( *xLink
) ),
533 sOld( SvTabListBox::GetEntryText( pBox
, 3 ) );
535 m_pTbLinks
->SetEntryText( sCur
, pBox
, 3 );
538 m_pTbLinks
->SetUpdateMode(true);
541 IMPL_LINK( SvBaseLinksDlg
, EndEditHdl
, sfx2::SvBaseLink
*, _pLink
)
544 GetSelEntry( &nPos
);
546 if( _pLink
&& _pLink
->WasLastEditOK() )
548 // StarImpress/Draw swap the LinkObjects themselves!
549 // So search for the link in the manager; if it does not exist
550 // anymore, fill the list completely new. Otherwise only the
551 // edited link needs to be refreshed.
552 bool bLinkFnd
= false;
553 for( size_t n
= pLinkMgr
->GetLinks().size(); n
; )
554 if( _pLink
== &(*pLinkMgr
->GetLinks()[ --n
]) )
562 m_pTbLinks
->SetUpdateMode(false);
563 m_pTbLinks
->GetModel()->Remove( m_pTbLinks
->GetEntry( nPos
) );
564 SvTreeListEntry
* pToUnselect
= m_pTbLinks
->FirstSelected();
565 InsertEntry( *_pLink
, nPos
, true );
567 m_pTbLinks
->Select(pToUnselect
, false);
568 m_pTbLinks
->SetUpdateMode(true);
572 LinkManager
* pNewMgr
= pLinkMgr
;
574 SetManager( pNewMgr
);
576 if (pLinkMgr
&& pLinkMgr
->GetPersist())
577 pLinkMgr
->GetPersist()->SetModified();
582 OUString
SvBaseLinksDlg::ImplGetStateStr( const SvBaseLink
& rLnk
)
587 else if( rLnk
.GetObj()->IsPending() )
589 sRet
= Waitinglink();
592 else if( SfxLinkUpdateMode::ALWAYS
== rLnk
.GetUpdateMode() )
600 void SvBaseLinksDlg::SetManager( LinkManager
* pNewMgr
)
602 if( pLinkMgr
== pNewMgr
)
606 // update has to be stopped before clear
607 m_pTbLinks
->SetUpdateMode( false );
614 SvBaseLinks
& rLnks
= (SvBaseLinks
&)pLinkMgr
->GetLinks();
615 for( size_t n
= 0; n
< rLnks
.size(); ++n
)
617 SvBaseLinkRef
* pLinkRef
= rLnks
[ n
];
618 if( !pLinkRef
->Is() )
620 rLnks
.erase( rLnks
.begin() + n
);
624 if( (*pLinkRef
)->IsVisible() )
625 InsertEntry( **pLinkRef
);
630 SvTreeListEntry
* pEntry
= m_pTbLinks
->GetEntry( 0 );
631 m_pTbLinks
->SetCurEntry( pEntry
);
632 m_pTbLinks
->Select( pEntry
);
635 m_pTbLinks
->SetUpdateMode( true );
636 m_pTbLinks
->Invalidate();
641 void SvBaseLinksDlg::InsertEntry( const SvBaseLink
& rLink
, sal_uLong nPos
, bool bSelect
)
643 OUString aEntry
, sFileNm
, sLinkNm
, sTypeNm
, sFilter
;
645 sfx2::LinkManager::GetDisplayNames( &rLink
, &sTypeNm
, &sFileNm
, &sLinkNm
, &sFilter
);
647 // GetTab(0) gives the position of the bitmap which is automatically inserted by the TabListBox.
648 // So the first text column's width is Tab(2)-Tab(1).
649 long nWidthPixel
= m_pTbLinks
->GetLogicTab( 2 ) - m_pTbLinks
->GetLogicTab( 1 );
650 nWidthPixel
-= SV_TAB_BORDER
;
651 OUString aTxt
= m_pTbLinks
->GetEllipsisString( sFileNm
, nWidthPixel
, DrawTextFlags::PathEllipsis
);
652 INetURLObject
aPath( sFileNm
, INetProtocol::File
);
653 OUString aFileName
= aPath
.getName();
654 aFileName
= INetURLObject::decode(aFileName
, INetURLObject::DECODE_UNAMBIGUOUS
);
656 if( aFileName
.getLength() > aTxt
.getLength() )
658 else if( aTxt
.indexOf( aFileName
, aTxt
.getLength() - aFileName
.getLength() ) == -1 )
659 // filename not in string
664 if( OBJECT_CLIENT_GRF
== rLink
.GetObjType() )
671 aEntry
+= ImplGetStateStr( rLink
);
673 SvTreeListEntry
* pE
= m_pTbLinks
->InsertEntryToColumn( aEntry
, nPos
);
674 pE
->SetUserData( (void*)&rLink
);
676 m_pTbLinks
->Select(pE
);
679 SvBaseLink
* SvBaseLinksDlg::GetSelEntry( sal_uLong
* pPos
)
681 SvTreeListEntry
* pE
= m_pTbLinks
->FirstSelected();
683 if( pE
&& TREELIST_ENTRY_NOTFOUND
!=
684 ( nPos
= m_pTbLinks
->GetModel()->GetAbsPos( pE
) ) )
686 DBG_ASSERT( pE
, "wo kommt der leere Eintrag her?" );
690 return static_cast<SvBaseLink
*>(pE
->GetUserData());
695 void SvBaseLinksDlg::SetType( SvBaseLink
& rLink
,
697 SfxLinkUpdateMode nType
)
699 rLink
.SetUpdateMode( nType
);
701 SvTreeListEntry
* pBox
= m_pTbLinks
->GetEntry( nSelPos
);
702 m_pTbLinks
->SetEntryText( ImplGetStateStr( rLink
), pBox
, 3 );
703 if( pLinkMgr
->GetPersist() )
704 pLinkMgr
->GetPersist()->SetModified();
707 void SvBaseLinksDlg::SetActLink( SvBaseLink
* pLink
)
711 const SvBaseLinks
& rLnks
= pLinkMgr
->GetLinks();
712 sal_uLong nSelect
= 0;
713 for( size_t n
= 0; n
< rLnks
.size(); ++n
)
715 SvBaseLinkRef
* pLinkRef
= rLnks
[ n
];
716 // #109573# only visible links have been inserted into the TreeListBox,
717 // invisible ones have to be skipped here
718 if( (*pLinkRef
)->IsVisible() )
720 if( pLink
== *pLinkRef
)
722 m_pTbLinks
->Select( m_pTbLinks
->GetEntry( nSelect
) );
732 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */