xref: /AOO41X/main/cui/source/dialogs/linkdlg.cxx (revision 2ee96f1cdb99d49425d866b1ec4c5567f37285e6)
1*2ee96f1cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2ee96f1cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2ee96f1cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2ee96f1cSAndrew Rist  * distributed with this work for additional information
6*2ee96f1cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2ee96f1cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2ee96f1cSAndrew Rist  * "License"); you may not use this file except in compliance
9*2ee96f1cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*2ee96f1cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*2ee96f1cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2ee96f1cSAndrew Rist  * software distributed under the License is distributed on an
15*2ee96f1cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2ee96f1cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*2ee96f1cSAndrew Rist  * specific language governing permissions and limitations
18*2ee96f1cSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*2ee96f1cSAndrew Rist  *************************************************************/
21*2ee96f1cSAndrew Rist 
22*2ee96f1cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_cui.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <linkdlg.hxx>
28cdf0e10cSrcweir #include <vcl/svapp.hxx>
29cdf0e10cSrcweir #include "helpid.hrc"
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <tools/urlobj.hxx>
32cdf0e10cSrcweir #include <svtools/svmedit.hxx>
33cdf0e10cSrcweir #include <svtools/filedlg.hxx>
34cdf0e10cSrcweir #include <vcl/dialog.hxx>
35cdf0e10cSrcweir #include <vcl/button.hxx>
36cdf0e10cSrcweir #include <vcl/fixed.hxx>
37cdf0e10cSrcweir #include <vcl/group.hxx>
38cdf0e10cSrcweir #include <vcl/lstbox.hxx>
39cdf0e10cSrcweir #include <vcl/msgbox.hxx>
40cdf0e10cSrcweir #include <vcl/timer.hxx>
41cdf0e10cSrcweir #include <svtools/svtabbx.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include <svuidlg.hrc>
44cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>
45cdf0e10cSrcweir #include <sfx2/linksrc.hxx>
46cdf0e10cSrcweir #include <svtools/soerr.hxx>
47cdf0e10cSrcweir #include <sfx2/lnkbase.hxx>
48cdf0e10cSrcweir #include <sfx2/objsh.hxx>
49cdf0e10cSrcweir 
50cdf0e10cSrcweir #include <dialmgr.hxx>
51cdf0e10cSrcweir 
52cdf0e10cSrcweir #define _SVSTDARR_USHORTS
53cdf0e10cSrcweir #include <svl/svstdarr.hxx>
54cdf0e10cSrcweir 
55cdf0e10cSrcweir #define MAX_FILENAME	18
56cdf0e10cSrcweir #define MAX_LINKNAME	18
57cdf0e10cSrcweir #define MAX_TYPENAME	15
58cdf0e10cSrcweir #define MAX_UPDATENAME	10
59cdf0e10cSrcweir 
60cdf0e10cSrcweir #define FILEOBJECT ( OBJECT_CLIENT_FILE & ~OBJECT_CLIENT_SO )
61cdf0e10cSrcweir 
62cdf0e10cSrcweir using namespace sfx2;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir SV_DECL_IMPL_REF_LIST(SvBaseLink,SvBaseLink*)
65cdf0e10cSrcweir 
66cdf0e10cSrcweir // Achtung im Code wird dieses Array direkt (0, 1, ...) indiziert
67cdf0e10cSrcweir static long nTabs[] =
68cdf0e10cSrcweir 	{	4, // Number of Tabs
69cdf0e10cSrcweir 		0, 77, 144, 209
70cdf0e10cSrcweir 	};
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 
73cdf0e10cSrcweir SvBaseLinksDlg::SvBaseLinksDlg( Window * pParent, LinkManager* pMgr, sal_Bool bHtml )
74cdf0e10cSrcweir     : ModalDialog( pParent, CUI_RES( MD_UPDATE_BASELINKS ) ),
75cdf0e10cSrcweir     aFtFiles( this, CUI_RES( FT_FILES ) ),
76cdf0e10cSrcweir     aFtLinks( this, CUI_RES( FT_LINKS ) ),
77cdf0e10cSrcweir     aFtType( this, CUI_RES( FT_TYPE ) ),
78cdf0e10cSrcweir     aFtStatus( this, CUI_RES( FT_STATUS ) ),
79cdf0e10cSrcweir     aTbLinks( this, CUI_RES(TB_LINKS ) ),
80cdf0e10cSrcweir     aFtFiles2( this, CUI_RES( FT_FILES2 ) ),
81cdf0e10cSrcweir     aFtFullFileName( this, CUI_RES( FT_FULL_FILE_NAME ) ),
82cdf0e10cSrcweir     aFtSource2( this, CUI_RES( FT_SOURCE2 ) ),
83cdf0e10cSrcweir     aFtFullSourceName( this, CUI_RES( FT_FULL_SOURCE_NAME ) ),
84cdf0e10cSrcweir     aFtType2( this, CUI_RES( FT_TYPE2 ) ),
85cdf0e10cSrcweir     aFtFullTypeName( this, CUI_RES( FT_FULL_TYPE_NAME ) ),
86cdf0e10cSrcweir     aFtUpdate( this, CUI_RES( FT_UPDATE ) ),
87cdf0e10cSrcweir     aRbAutomatic( this, CUI_RES( RB_AUTOMATIC ) ),
88cdf0e10cSrcweir     aRbManual( this, CUI_RES( RB_MANUAL ) ),
89cdf0e10cSrcweir     aCancelButton1( this, CUI_RES( 1 ) ),
90cdf0e10cSrcweir     aHelpButton1( this, CUI_RES( 1 ) ),
91cdf0e10cSrcweir     aPbUpdateNow( this, CUI_RES( PB_UPDATE_NOW ) ),
92cdf0e10cSrcweir     aPbOpenSource( this, CUI_RES( PB_OPEN_SOURCE ) ),
93cdf0e10cSrcweir     aPbChangeSource( this, CUI_RES( PB_CHANGE_SOURCE ) ),
94cdf0e10cSrcweir     aPbBreakLink( this, CUI_RES( PB_BREAK_LINK ) ),
95cdf0e10cSrcweir     aStrAutolink( CUI_RES( STR_AUTOLINK ) ),
96cdf0e10cSrcweir     aStrManuallink( CUI_RES( STR_MANUALLINK ) ),
97cdf0e10cSrcweir     aStrBrokenlink( CUI_RES( STR_BROKENLINK ) ),
98cdf0e10cSrcweir     aStrGraphiclink( CUI_RES( STR_GRAPHICLINK ) ),
99cdf0e10cSrcweir     aStrButtonclose( CUI_RES( STR_BUTTONCLOSE ) ),
100cdf0e10cSrcweir     aStrCloselinkmsg( CUI_RES( STR_CLOSELINKMSG ) ),
101cdf0e10cSrcweir     aStrCloselinkmsgMulti( CUI_RES( STR_CLOSELINKMSG_MULTI ) ),
102cdf0e10cSrcweir     aStrWaitinglink( CUI_RES( STR_WAITINGLINK ) ),
103cdf0e10cSrcweir     pLinkMgr( NULL ),
104cdf0e10cSrcweir 	bHtmlMode(bHtml)
105cdf0e10cSrcweir {
106cdf0e10cSrcweir     FreeResource();
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     aTbLinks.SetHelpId(HID_LINKDLG_TABLB);
109cdf0e10cSrcweir     aTbLinks.SetSelectionMode( MULTIPLE_SELECTION );
110cdf0e10cSrcweir     aTbLinks.SetTabs( &nTabs[0], MAP_APPFONT );
111cdf0e10cSrcweir     aTbLinks.Resize();  // OS: Hack fuer richtige Selektion
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     //JP 24.02.99: UpdateTimer fuer DDE-/Grf-Links, auf die gewarted wird
114cdf0e10cSrcweir     aUpdateTimer.SetTimeoutHdl( LINK( this, SvBaseLinksDlg, UpdateWaitingHdl ) );
115cdf0e10cSrcweir     aUpdateTimer.SetTimeout( 1000 );
116cdf0e10cSrcweir 	//IAccessibility2 Implementation 2009-----
117cdf0e10cSrcweir 	// Set the ZOrder, and accessible name to the dialog's title
118cdf0e10cSrcweir 	aTbLinks.SetZOrder(0, WINDOW_ZORDER_FIRST);
119cdf0e10cSrcweir 	aTbLinks.SetAccessibleName(this->GetText());
120cdf0e10cSrcweir 	aTbLinks.SetAccessibleRelationLabeledBy(&aFtFiles);
121cdf0e10cSrcweir 	//-----IAccessibility2 Implementation 2009
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     OpenSource().Hide();
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     Links().SetSelectHdl( LINK( this, SvBaseLinksDlg, LinksSelectHdl ) );
126cdf0e10cSrcweir     Links().SetDoubleClickHdl( LINK( this, SvBaseLinksDlg, LinksDoubleClickHdl ) );
127cdf0e10cSrcweir     Automatic().SetClickHdl( LINK( this, SvBaseLinksDlg, AutomaticClickHdl ) );
128cdf0e10cSrcweir     Manual().SetClickHdl( LINK( this, SvBaseLinksDlg, ManualClickHdl ) );
129cdf0e10cSrcweir     UpdateNow().SetClickHdl( LINK( this, SvBaseLinksDlg, UpdateNowClickHdl ) );
130cdf0e10cSrcweir //  OpenSource().SetClickHdl( LINK( this, SvBaseLinksDlg, OpenSourceClickHdl ) );
131cdf0e10cSrcweir     ChangeSource().SetClickHdl( LINK( this, SvBaseLinksDlg, ChangeSourceClickHdl ) );
132cdf0e10cSrcweir 	if(!bHtmlMode)
133cdf0e10cSrcweir         BreakLink().SetClickHdl( LINK( this, SvBaseLinksDlg, BreakLinkClickHdl ) );
134cdf0e10cSrcweir 	else
135cdf0e10cSrcweir         BreakLink().Hide();
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 	SetManager( pMgr );
138cdf0e10cSrcweir }
139cdf0e10cSrcweir 
140cdf0e10cSrcweir SvBaseLinksDlg::~SvBaseLinksDlg()
141cdf0e10cSrcweir {
142cdf0e10cSrcweir }
143cdf0e10cSrcweir 
144cdf0e10cSrcweir /*************************************************************************
145cdf0e10cSrcweir |*    SvBaseLinksDlg::Handler()
146cdf0e10cSrcweir |*
147cdf0e10cSrcweir |*	  Beschreibung
148cdf0e10cSrcweir |*	  Ersterstellung	MM 14.06.94
149cdf0e10cSrcweir |*	  Letzte Aenderung	JP 30.05.95
150cdf0e10cSrcweir *************************************************************************/
151cdf0e10cSrcweir IMPL_LINK( SvBaseLinksDlg, LinksSelectHdl, SvTabListBox *, pSvTabListBox )
152cdf0e10cSrcweir {
153cdf0e10cSrcweir 	sal_uInt16 nSelectionCount = pSvTabListBox ?
154cdf0e10cSrcweir 		(sal_uInt16)pSvTabListBox->GetSelectionCount() : 0;
155cdf0e10cSrcweir 	if(nSelectionCount > 1)
156cdf0e10cSrcweir 	{
157cdf0e10cSrcweir 		//bei Mehrfachselektion ggf. alte Eintraege deselektieren
158cdf0e10cSrcweir 		SvLBoxEntry* pEntry = 0;
159cdf0e10cSrcweir 		SvBaseLink* pLink = 0;
160cdf0e10cSrcweir 		pEntry = pSvTabListBox->GetHdlEntry();
161cdf0e10cSrcweir 		pLink = (SvBaseLink*)pEntry->GetUserData();
162cdf0e10cSrcweir 		sal_uInt16 nObjectType = pLink->GetObjType();
163cdf0e10cSrcweir 		if((OBJECT_CLIENT_FILE & nObjectType) != OBJECT_CLIENT_FILE)
164cdf0e10cSrcweir 		{
165cdf0e10cSrcweir 			pSvTabListBox->SelectAll(sal_False);
166cdf0e10cSrcweir 			pSvTabListBox->Select(pEntry);
167cdf0e10cSrcweir 			nSelectionCount = 1;
168cdf0e10cSrcweir 		}
169cdf0e10cSrcweir 		else
170cdf0e10cSrcweir 		{
171cdf0e10cSrcweir 			for( sal_uInt16 i = 0; i < nSelectionCount; i++)
172cdf0e10cSrcweir 			{
173cdf0e10cSrcweir 				pEntry = i == 0 ? pSvTabListBox->FirstSelected() :
174cdf0e10cSrcweir 									pSvTabListBox->NextSelected(pEntry);
175cdf0e10cSrcweir 				DBG_ASSERT(pEntry, "Wo ist der Entry?");
176cdf0e10cSrcweir 				pLink = (SvBaseLink*)pEntry->GetUserData();
177cdf0e10cSrcweir 				DBG_ASSERT(pLink, "Wo ist der Link?");
178cdf0e10cSrcweir 				if( (OBJECT_CLIENT_FILE & pLink->GetObjType()) != OBJECT_CLIENT_FILE )
179cdf0e10cSrcweir 					pSvTabListBox->Select( pEntry, sal_False );
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 			}
182cdf0e10cSrcweir 		}
183cdf0e10cSrcweir 
184cdf0e10cSrcweir         UpdateNow().Enable();
185cdf0e10cSrcweir 
186cdf0e10cSrcweir         Automatic().Disable();
187cdf0e10cSrcweir         Manual().Check();
188cdf0e10cSrcweir         Manual().Disable();
189cdf0e10cSrcweir 	}
190cdf0e10cSrcweir 	else
191cdf0e10cSrcweir 	{
192cdf0e10cSrcweir 		sal_uInt16 nPos;
193cdf0e10cSrcweir 		SvBaseLink* pLink = GetSelEntry( &nPos );
194cdf0e10cSrcweir 		if( !pLink )
195cdf0e10cSrcweir 			return 0;
196cdf0e10cSrcweir 
197cdf0e10cSrcweir         UpdateNow().Enable();
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 		String sType, sLink;
200cdf0e10cSrcweir 		String *pLinkNm = &sLink, *pFilter = 0;
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 		if( FILEOBJECT & pLink->GetObjType() )
203cdf0e10cSrcweir 		{
204cdf0e10cSrcweir             Automatic().Disable();
205cdf0e10cSrcweir             Manual().Check();
206cdf0e10cSrcweir             Manual().Disable();
207cdf0e10cSrcweir 			if( OBJECT_CLIENT_GRF == pLink->GetObjType() )
208cdf0e10cSrcweir 				pLinkNm = 0, pFilter = &sLink;
209cdf0e10cSrcweir 		}
210cdf0e10cSrcweir 		else
211cdf0e10cSrcweir 		{
212cdf0e10cSrcweir             Automatic().Enable();
213cdf0e10cSrcweir             Manual().Enable();
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 			if( LINKUPDATE_ALWAYS == pLink->GetUpdateMode() )
216cdf0e10cSrcweir                 Automatic().Check();
217cdf0e10cSrcweir 			else
218cdf0e10cSrcweir                 Manual().Check();
219cdf0e10cSrcweir 		}
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 		String aFileName;
222cdf0e10cSrcweir 		pLinkMgr->GetDisplayNames( pLink, &sType, &aFileName, pLinkNm, pFilter );
223cdf0e10cSrcweir         aFileName = INetURLObject::decode(aFileName, INET_HEX_ESCAPE, INetURLObject::DECODE_UNAMBIGUOUS);
224cdf0e10cSrcweir         FileName().SetText( aFileName );
225cdf0e10cSrcweir         SourceName().SetText( sLink );
226cdf0e10cSrcweir         TypeName().SetText( sType );
227cdf0e10cSrcweir 	}
228cdf0e10cSrcweir 	return 0;
229cdf0e10cSrcweir }
230cdf0e10cSrcweir 
231cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvBaseLinksDlg, LinksDoubleClickHdl, SvTabListBox *, pSvTabListBox )
232cdf0e10cSrcweir {
233cdf0e10cSrcweir 	(void)pSvTabListBox;
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 	ChangeSourceClickHdl( 0 );
236cdf0e10cSrcweir 	return 0;
237cdf0e10cSrcweir }
238cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvBaseLinksDlg, LinksDoubleClickHdl, SvTabListBox *, pSvTabListBox )
239cdf0e10cSrcweir 
240cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvBaseLinksDlg, AutomaticClickHdl, RadioButton *, pRadioButton )
241cdf0e10cSrcweir {
242cdf0e10cSrcweir 	(void)pRadioButton;
243cdf0e10cSrcweir 
244cdf0e10cSrcweir 	sal_uInt16 nPos;
245cdf0e10cSrcweir 	SvBaseLink* pLink = GetSelEntry( &nPos );
246cdf0e10cSrcweir 	if( pLink && !( FILEOBJECT & pLink->GetObjType() ) &&
247cdf0e10cSrcweir 		LINKUPDATE_ALWAYS != pLink->GetUpdateMode() )
248cdf0e10cSrcweir 		SetType( *pLink, nPos, LINKUPDATE_ALWAYS );
249cdf0e10cSrcweir 	return 0;
250cdf0e10cSrcweir }
251cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvBaseLinksDlg, AutomaticClickHdl, RadioButton *, pRadioButton )
252cdf0e10cSrcweir 
253cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvBaseLinksDlg, ManualClickHdl, RadioButton *, pRadioButton )
254cdf0e10cSrcweir {
255cdf0e10cSrcweir 	(void)pRadioButton;
256cdf0e10cSrcweir 
257cdf0e10cSrcweir 	sal_uInt16 nPos;
258cdf0e10cSrcweir 	SvBaseLink* pLink = GetSelEntry( &nPos );
259cdf0e10cSrcweir 	if( pLink && !( FILEOBJECT & pLink->GetObjType() ) &&
260cdf0e10cSrcweir 		LINKUPDATE_ONCALL != pLink->GetUpdateMode())
261cdf0e10cSrcweir 		SetType( *pLink, nPos, LINKUPDATE_ONCALL );
262cdf0e10cSrcweir 	return 0;
263cdf0e10cSrcweir }
264cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvBaseLinksDlg, ManualClickHdl, RadioButton *, pRadioButton )
265cdf0e10cSrcweir 
266cdf0e10cSrcweir IMPL_LINK( SvBaseLinksDlg, UpdateNowClickHdl, PushButton *, EMPTYARG )
267cdf0e10cSrcweir {
268cdf0e10cSrcweir     SvTabListBox& rListBox = Links();
269cdf0e10cSrcweir 	sal_uInt16 nSelCnt = (sal_uInt16)rListBox.GetSelectionCount();
270cdf0e10cSrcweir 	if( 255 < nSelCnt )
271cdf0e10cSrcweir 		nSelCnt = 255;
272cdf0e10cSrcweir 
273cdf0e10cSrcweir 	std::vector< SvBaseLink* > aLnkArr;
274cdf0e10cSrcweir 	std::vector< sal_uInt16 > aPosArr;
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 	SvLBoxEntry* pE = rListBox.FirstSelected();
277cdf0e10cSrcweir 	while( pE )
278cdf0e10cSrcweir 	{
279cdf0e10cSrcweir 		sal_uInt16 nFndPos = (sal_uInt16)rListBox.GetModel()->GetAbsPos( pE );
280cdf0e10cSrcweir 		if( LISTBOX_ENTRY_NOTFOUND != nFndPos )
281cdf0e10cSrcweir 		{
282cdf0e10cSrcweir 			aLnkArr.push_back( static_cast< SvBaseLink* >( pE->GetUserData() ) );
283cdf0e10cSrcweir 			aPosArr.push_back( nFndPos );
284cdf0e10cSrcweir 		}
285cdf0e10cSrcweir 		pE = rListBox.NextSelected( pE );
286cdf0e10cSrcweir 	}
287cdf0e10cSrcweir 
288cdf0e10cSrcweir 	if( !aLnkArr.empty() )
289cdf0e10cSrcweir 	{
290cdf0e10cSrcweir 		for( sal_uInt16 n = 0; n < aLnkArr.size(); ++n )
291cdf0e10cSrcweir 		{
292cdf0e10cSrcweir 			SvBaseLinkRef xLink = aLnkArr[ n ];
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 			// suche erstmal im Array nach dem Eintrag
295cdf0e10cSrcweir 			for( sal_uInt16 i = 0; i < pLinkMgr->GetLinks().Count(); ++i )
296cdf0e10cSrcweir 				if( &xLink == *pLinkMgr->GetLinks()[ i ] )
297cdf0e10cSrcweir 				{
298cdf0e10cSrcweir 					xLink->SetUseCache( sal_False );
299cdf0e10cSrcweir 					SetType( *xLink, aPosArr[ n ], xLink->GetUpdateMode() );
300cdf0e10cSrcweir 					xLink->SetUseCache( sal_True );
301cdf0e10cSrcweir 					break;
302cdf0e10cSrcweir 				}
303cdf0e10cSrcweir 		}
304cdf0e10cSrcweir 
305cdf0e10cSrcweir 		// falls jemand der Meinung ist, seine Links auszutauschen (SD)
306cdf0e10cSrcweir 		LinkManager* pNewMgr = pLinkMgr;
307cdf0e10cSrcweir 		pLinkMgr = 0;
308cdf0e10cSrcweir 		SetManager( pNewMgr );
309cdf0e10cSrcweir 
310cdf0e10cSrcweir 
311cdf0e10cSrcweir 		if( 0 == (pE = rListBox.GetEntry( aPosArr[ 0 ] )) ||
312cdf0e10cSrcweir 			pE->GetUserData() != aLnkArr[ 0 ] )
313cdf0e10cSrcweir 		{
314cdf0e10cSrcweir 			// suche mal den Link
315cdf0e10cSrcweir 			pE = rListBox.First();
316cdf0e10cSrcweir 			while( pE )
317cdf0e10cSrcweir 			{
318cdf0e10cSrcweir 				if( pE->GetUserData() == aLnkArr[ 0 ] )
319cdf0e10cSrcweir 					break;
320cdf0e10cSrcweir 				pE = rListBox.Next( pE );
321cdf0e10cSrcweir 			}
322cdf0e10cSrcweir 
323cdf0e10cSrcweir 			if( !pE )
324cdf0e10cSrcweir 				pE = rListBox.FirstSelected();
325cdf0e10cSrcweir 		}
326cdf0e10cSrcweir 
327cdf0e10cSrcweir 		if( pE )
328cdf0e10cSrcweir 		{
329cdf0e10cSrcweir 			SvLBoxEntry* pSelEntry = rListBox.FirstSelected();
330cdf0e10cSrcweir 			if( pE != pSelEntry )
331cdf0e10cSrcweir 				rListBox.Select( pSelEntry, sal_False );
332cdf0e10cSrcweir 			rListBox.Select( pE );
333cdf0e10cSrcweir 			rListBox.MakeVisible( pE );
334cdf0e10cSrcweir 		}
335cdf0e10cSrcweir 	}
336cdf0e10cSrcweir 	return 0;
337cdf0e10cSrcweir }
338cdf0e10cSrcweir 
339cdf0e10cSrcweir /*
340cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvBaseLinksDlg, OpenSourceClickHdl, PushButton *, pPushButton )
341cdf0e10cSrcweir {
342cdf0e10cSrcweir 	DBG_ASSERT( !this, "Open noch nicht impl." );
343cdf0e10cSrcweir 	return 0;
344cdf0e10cSrcweir }
345cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvBaseLinksDlg, OpenSourceClickHdl, PushButton *, pPushButton )
346cdf0e10cSrcweir */
347cdf0e10cSrcweir 
348cdf0e10cSrcweir IMPL_LINK( SvBaseLinksDlg, ChangeSourceClickHdl, PushButton *, pPushButton )
349cdf0e10cSrcweir {
350cdf0e10cSrcweir 	(void)pPushButton;
351cdf0e10cSrcweir 
352cdf0e10cSrcweir     sal_uInt16 nSelectionCount = (sal_uInt16)Links().GetSelectionCount();
353cdf0e10cSrcweir 	if(nSelectionCount > 1)
354cdf0e10cSrcweir 	{
355cdf0e10cSrcweir         PathDialog aPathDlg( this );
356cdf0e10cSrcweir 		String sType, sFile, sLinkName;
357cdf0e10cSrcweir 		String  sFilter;
358cdf0e10cSrcweir         SvLBoxEntry* pEntry = Links().FirstSelected();
359cdf0e10cSrcweir 		SvBaseLink* pLink = (SvBaseLink*)pEntry->GetUserData();
360cdf0e10cSrcweir 		pLinkMgr->GetDisplayNames( pLink, &sType, &sFile, 0, 0 );
361cdf0e10cSrcweir 		INetURLObject aUrl(sFile);
362cdf0e10cSrcweir 		if(aUrl.GetProtocol() == INET_PROT_FILE)
363cdf0e10cSrcweir 		{
364cdf0e10cSrcweir 			rtl::OUString sOldPath(aUrl.PathToFileName());
365cdf0e10cSrcweir 			sal_Int32 nLen = aUrl.GetName().getLength();
366cdf0e10cSrcweir 			sOldPath = sOldPath.copy(0, sOldPath.getLength() - nLen);
367cdf0e10cSrcweir 			aPathDlg.SetPath(sOldPath);
368cdf0e10cSrcweir 		}
369cdf0e10cSrcweir 		if(aPathDlg.Execute() == RET_OK)
370cdf0e10cSrcweir 		{
371cdf0e10cSrcweir 			String aPath = aPathDlg.GetPath();
372cdf0e10cSrcweir 
373cdf0e10cSrcweir 			for( sal_uInt16 i = 0; i < nSelectionCount; i++)
374cdf0e10cSrcweir 			{
375cdf0e10cSrcweir 				pEntry = i==0 ?
376cdf0e10cSrcweir                         Links().FirstSelected() :
377cdf0e10cSrcweir                             Links().NextSelected( pEntry );
378cdf0e10cSrcweir 				DBG_ASSERT(pEntry,"Wo ist der Entry");
379cdf0e10cSrcweir 				pLink = (SvBaseLink*)pEntry->GetUserData();
380cdf0e10cSrcweir 				DBG_ASSERT(pLink,"Wo ist der Link");
381cdf0e10cSrcweir 				pLinkMgr->GetDisplayNames( pLink, &sType, &sFile, &sLinkName, &sFilter );
382cdf0e10cSrcweir 				INetURLObject aUrl_(sFile);
383cdf0e10cSrcweir 				INetURLObject aUrl2(aPath, INET_PROT_FILE);
384cdf0e10cSrcweir 				aUrl2.insertName( aUrl_.getName() );
385cdf0e10cSrcweir 				String sNewLinkName;
386cdf0e10cSrcweir                 MakeLnkName( sNewLinkName, 0 ,
387cdf0e10cSrcweir 						aUrl2.GetMainURL(INetURLObject::DECODE_TO_IURI), sLinkName, &sFilter);
388cdf0e10cSrcweir 				pLink->SetLinkSourceName( sNewLinkName );
389cdf0e10cSrcweir 				pLink->Update();
390cdf0e10cSrcweir 			}
391cdf0e10cSrcweir 			if( pLinkMgr->GetPersist() )
392cdf0e10cSrcweir 				pLinkMgr->GetPersist()->SetModified();
393cdf0e10cSrcweir 			LinkManager* pNewMgr = pLinkMgr;
394cdf0e10cSrcweir 			pLinkMgr = 0;
395cdf0e10cSrcweir 			SetManager( pNewMgr );
396cdf0e10cSrcweir 		}
397cdf0e10cSrcweir 	}
398cdf0e10cSrcweir 	else
399cdf0e10cSrcweir 	{
400cdf0e10cSrcweir 		sal_uInt16 nPos;
401cdf0e10cSrcweir 		SvBaseLink* pLink = GetSelEntry( &nPos );
402cdf0e10cSrcweir         if ( pLink && (pLink->GetLinkSourceName().Len() != 0) )
403cdf0e10cSrcweir             pLink->Edit( this, LINK( this, SvBaseLinksDlg, EndEditHdl ) );
404cdf0e10cSrcweir 	}
405cdf0e10cSrcweir 	return 0;
406cdf0e10cSrcweir }
407cdf0e10cSrcweir 
408cdf0e10cSrcweir IMPL_LINK( SvBaseLinksDlg, BreakLinkClickHdl, PushButton *, pPushButton )
409cdf0e10cSrcweir {
410cdf0e10cSrcweir 	(void)pPushButton;
411cdf0e10cSrcweir 
412cdf0e10cSrcweir 	sal_Bool bModified = sal_False;
413cdf0e10cSrcweir     if(Links().GetSelectionCount() <= 1)
414cdf0e10cSrcweir 	{
415cdf0e10cSrcweir 		sal_uInt16 nPos;
416cdf0e10cSrcweir 		SvBaseLinkRef xLink = GetSelEntry( &nPos );
417cdf0e10cSrcweir 		if( !xLink.Is() )
418cdf0e10cSrcweir 			return 0;
419cdf0e10cSrcweir 
420cdf0e10cSrcweir         QueryBox aBox( this, WB_YES_NO | WB_DEF_YES, Closelinkmsg() );
421cdf0e10cSrcweir 
422cdf0e10cSrcweir 		if( RET_YES == aBox.Execute() )
423cdf0e10cSrcweir 		{
424cdf0e10cSrcweir             Links().GetModel()->Remove( Links().GetEntry( nPos ) );
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 			// falls Object noch vorhanden, dann das schliessen
427cdf0e10cSrcweir 			sal_Bool bNewLnkMgr = OBJECT_CLIENT_FILE == xLink->GetObjType();
428cdf0e10cSrcweir 
429cdf0e10cSrcweir 			// dem Link sagen, das er aufgeloest wird!
430cdf0e10cSrcweir 			xLink->Closed();
431cdf0e10cSrcweir 
432cdf0e10cSrcweir 			// falls einer vergessen hat sich auszutragen
433cdf0e10cSrcweir 			if( xLink.Is() )
434cdf0e10cSrcweir 				pLinkMgr->Remove( &xLink );
435cdf0e10cSrcweir 
436cdf0e10cSrcweir 			if( bNewLnkMgr )
437cdf0e10cSrcweir 			{
438cdf0e10cSrcweir 				LinkManager* pNewMgr = pLinkMgr;
439cdf0e10cSrcweir 				pLinkMgr = 0;
440cdf0e10cSrcweir 				SetManager( pNewMgr );
441cdf0e10cSrcweir 
442cdf0e10cSrcweir                 SvLBoxEntry* pEntry = Links().GetEntry( nPos ? --nPos : 0 );
443cdf0e10cSrcweir 				if( pEntry )
444cdf0e10cSrcweir                     Links().SetCurEntry( pEntry );
445cdf0e10cSrcweir 			}
446cdf0e10cSrcweir 			bModified = sal_True;
447cdf0e10cSrcweir 		}
448cdf0e10cSrcweir 	}
449cdf0e10cSrcweir 	else
450cdf0e10cSrcweir 	{
451cdf0e10cSrcweir         QueryBox aBox( this, WB_YES_NO | WB_DEF_YES, CloselinkmsgMulti() );
452cdf0e10cSrcweir 
453cdf0e10cSrcweir 		if( RET_YES == aBox.Execute() )
454cdf0e10cSrcweir 		{
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 			SvBaseLinkMemberList aLinkList;
457cdf0e10cSrcweir             SvLBoxEntry* pEntry = Links().FirstSelected();
458cdf0e10cSrcweir 			while ( pEntry )
459cdf0e10cSrcweir 			{
460cdf0e10cSrcweir 				void * pUD = pEntry->GetUserData();
461cdf0e10cSrcweir 				if( pUD )
462cdf0e10cSrcweir 					aLinkList.Append( (SvBaseLink*)pUD );
463cdf0e10cSrcweir                 pEntry = Links().NextSelected(pEntry);
464cdf0e10cSrcweir 			}
465cdf0e10cSrcweir             Links().RemoveSelection();
466cdf0e10cSrcweir 			for( sal_uLong i = 0; i < aLinkList.Count(); i++ )
467cdf0e10cSrcweir 			{
468cdf0e10cSrcweir 				SvBaseLinkRef xLink = aLinkList.GetObject( i );
469cdf0e10cSrcweir 				// dem Link sagen, das er aufgeloest wird!
470cdf0e10cSrcweir 				xLink->Closed();
471cdf0e10cSrcweir 
472cdf0e10cSrcweir 				// falls einer vergessen hat sich auszutragen
473cdf0e10cSrcweir 				pLinkMgr->Remove( &xLink );
474cdf0e10cSrcweir 				bModified = sal_True;
475cdf0e10cSrcweir 			}
476cdf0e10cSrcweir 			//Danach alle selektierten Eintraege entfernen
477cdf0e10cSrcweir 		}
478cdf0e10cSrcweir 	}
479cdf0e10cSrcweir 	if(bModified)
480cdf0e10cSrcweir 	{
481cdf0e10cSrcweir         if( !Links().GetEntryCount() )
482cdf0e10cSrcweir 		{
483cdf0e10cSrcweir 			// Der letzte macht das Licht aus
484cdf0e10cSrcweir             Automatic().Disable();
485cdf0e10cSrcweir             Manual().Disable();
486cdf0e10cSrcweir             UpdateNow().Disable();
487cdf0e10cSrcweir //            OpenSource().Disable();
488cdf0e10cSrcweir             ChangeSource().Disable();
489cdf0e10cSrcweir             BreakLink().Disable();
490cdf0e10cSrcweir 
491cdf0e10cSrcweir 			String aEmpty;
492cdf0e10cSrcweir             SourceName().SetText( aEmpty );
493cdf0e10cSrcweir             TypeName().SetText( aEmpty );
494cdf0e10cSrcweir 		}
495cdf0e10cSrcweir 		if( pLinkMgr->GetPersist() )
496cdf0e10cSrcweir 			pLinkMgr->GetPersist()->SetModified();
497cdf0e10cSrcweir 	}
498cdf0e10cSrcweir 	return 0;
499cdf0e10cSrcweir }
500cdf0e10cSrcweir 
501cdf0e10cSrcweir IMPL_LINK( SvBaseLinksDlg, UpdateWaitingHdl, Timer*, pTimer )
502cdf0e10cSrcweir {
503cdf0e10cSrcweir 	(void)pTimer;
504cdf0e10cSrcweir //    for( SvLBoxEntry* pBox = Links().First(); pBox;
505cdf0e10cSrcweir //          pBox = Links().Next( pBox ))
506cdf0e10cSrcweir 
507cdf0e10cSrcweir     Links().SetUpdateMode(sal_False);
508cdf0e10cSrcweir     for( sal_uLong nPos = Links().GetEntryCount(); nPos; )
509cdf0e10cSrcweir 	{
510cdf0e10cSrcweir         SvLBoxEntry* pBox = Links().GetEntry( --nPos );
511cdf0e10cSrcweir 		SvBaseLinkRef xLink( (SvBaseLink*)pBox->GetUserData() );
512cdf0e10cSrcweir 		if( xLink.Is() )
513cdf0e10cSrcweir 		{
514cdf0e10cSrcweir 			String sCur( ImplGetStateStr( *xLink ) ),
515cdf0e10cSrcweir                     sOld( Links().GetEntryText( pBox, 3 ) );
516cdf0e10cSrcweir 			if( sCur != sOld )
517cdf0e10cSrcweir                 Links().SetEntryText( sCur, pBox, 3 );
518cdf0e10cSrcweir 		}
519cdf0e10cSrcweir 	}
520cdf0e10cSrcweir     Links().SetUpdateMode(sal_True);
521cdf0e10cSrcweir 	return 0;
522cdf0e10cSrcweir }
523cdf0e10cSrcweir 
524cdf0e10cSrcweir IMPL_LINK( SvBaseLinksDlg, EndEditHdl, sfx2::SvBaseLink*, _pLink )
525cdf0e10cSrcweir {
526cdf0e10cSrcweir     sal_uInt16 nPos;
527cdf0e10cSrcweir     GetSelEntry( &nPos );
528cdf0e10cSrcweir 
529cdf0e10cSrcweir     if( _pLink && _pLink->WasLastEditOK() )
530cdf0e10cSrcweir     {
531cdf0e10cSrcweir         // JP 09.01.98:
532cdf0e10cSrcweir         // StarImpress/Draw tauschen die LinkObjecte selbst aus!
533cdf0e10cSrcweir         // also suche den Link im Manager, wenn der nicht mehr existiert,
534cdf0e10cSrcweir         // dann setze fuelle die Liste komplett neu. Ansonsten braucht
535cdf0e10cSrcweir         // nur der editierte Linkt aktualisiert werden.
536cdf0e10cSrcweir         sal_Bool bLinkFnd = sal_False;
537cdf0e10cSrcweir         for( sal_uInt16 n = pLinkMgr->GetLinks().Count(); n;  )
538cdf0e10cSrcweir             if( _pLink == &(*pLinkMgr->GetLinks()[ --n ]) )
539cdf0e10cSrcweir             {
540cdf0e10cSrcweir                 bLinkFnd = sal_True;
541cdf0e10cSrcweir                 break;
542cdf0e10cSrcweir             }
543cdf0e10cSrcweir 
544cdf0e10cSrcweir         if( bLinkFnd )
545cdf0e10cSrcweir         {
546cdf0e10cSrcweir             Links().SetUpdateMode(sal_False);
547cdf0e10cSrcweir             Links().GetModel()->Remove( Links().GetEntry( nPos ) );
548cdf0e10cSrcweir             SvLBoxEntry* pToUnselect = Links().FirstSelected();
549cdf0e10cSrcweir             InsertEntry( *_pLink, nPos, sal_True );
550cdf0e10cSrcweir             if(pToUnselect)
551cdf0e10cSrcweir                 Links().Select(pToUnselect, sal_False);
552cdf0e10cSrcweir             Links().SetUpdateMode(sal_True);
553cdf0e10cSrcweir         }
554cdf0e10cSrcweir         else
555cdf0e10cSrcweir         {
556cdf0e10cSrcweir             LinkManager* pNewMgr = pLinkMgr;
557cdf0e10cSrcweir             pLinkMgr = 0;
558cdf0e10cSrcweir             SetManager( pNewMgr );
559cdf0e10cSrcweir         }
560cdf0e10cSrcweir         if( pLinkMgr->GetPersist() )
561cdf0e10cSrcweir             pLinkMgr->GetPersist()->SetModified();
562cdf0e10cSrcweir     }
563cdf0e10cSrcweir     return 0;
564cdf0e10cSrcweir }
565cdf0e10cSrcweir 
566cdf0e10cSrcweir String SvBaseLinksDlg::ImplGetStateStr( const SvBaseLink& rLnk )
567cdf0e10cSrcweir {
568cdf0e10cSrcweir 	String sRet;
569cdf0e10cSrcweir 	if( !rLnk.GetObj() )
570cdf0e10cSrcweir         sRet = Brokenlink();
571cdf0e10cSrcweir 	else if( rLnk.GetObj()->IsPending() )
572cdf0e10cSrcweir 	{
573cdf0e10cSrcweir         sRet = Waitinglink();
574cdf0e10cSrcweir         StartUpdateTimer();
575cdf0e10cSrcweir 	}
576cdf0e10cSrcweir 	else if( LINKUPDATE_ALWAYS == rLnk.GetUpdateMode() )
577cdf0e10cSrcweir         sRet = Autolink();
578cdf0e10cSrcweir 	else
579cdf0e10cSrcweir         sRet = Manuallink();
580cdf0e10cSrcweir 
581cdf0e10cSrcweir 	return sRet;
582cdf0e10cSrcweir }
583cdf0e10cSrcweir 
584cdf0e10cSrcweir void SvBaseLinksDlg::SetManager( LinkManager* pNewMgr )
585cdf0e10cSrcweir {
586cdf0e10cSrcweir 	if( pLinkMgr == pNewMgr )
587cdf0e10cSrcweir 		return;
588cdf0e10cSrcweir 
589cdf0e10cSrcweir 	if( pNewMgr )
590cdf0e10cSrcweir 		// Update muss vor Clear gestoppt werden
591cdf0e10cSrcweir         Links().SetUpdateMode( sal_False );
592cdf0e10cSrcweir 
593cdf0e10cSrcweir     Links().Clear();
594cdf0e10cSrcweir 	pLinkMgr = pNewMgr;
595cdf0e10cSrcweir 
596cdf0e10cSrcweir 	if( pLinkMgr )
597cdf0e10cSrcweir 	{
598cdf0e10cSrcweir 		SvBaseLinks& rLnks = (SvBaseLinks&)pLinkMgr->GetLinks();
599cdf0e10cSrcweir 		for( sal_uInt16 n = 0; n < rLnks.Count(); ++n )
600cdf0e10cSrcweir 		{
601cdf0e10cSrcweir 			SvBaseLinkRef* pLinkRef = rLnks[ n ];
602cdf0e10cSrcweir 			if( !pLinkRef->Is() )
603cdf0e10cSrcweir 			{
604cdf0e10cSrcweir 				rLnks.Remove( n, 1 );
605cdf0e10cSrcweir 				--n;
606cdf0e10cSrcweir 				continue;
607cdf0e10cSrcweir 			}
608cdf0e10cSrcweir 			if( (*pLinkRef)->IsVisible() )
609cdf0e10cSrcweir 				InsertEntry( **pLinkRef );
610cdf0e10cSrcweir 		}
611cdf0e10cSrcweir 
612cdf0e10cSrcweir 		if( rLnks.Count() )
613cdf0e10cSrcweir 		{
614cdf0e10cSrcweir             SvLBoxEntry* pEntry = Links().GetEntry( 0 );
615cdf0e10cSrcweir             Links().SetCurEntry( pEntry );
616cdf0e10cSrcweir             Links().Select( pEntry );
617cdf0e10cSrcweir 			LinksSelectHdl( 0 );
618cdf0e10cSrcweir 		}
619cdf0e10cSrcweir         Links().SetUpdateMode( sal_True );
620cdf0e10cSrcweir         Links().Invalidate();
621cdf0e10cSrcweir 	}
622cdf0e10cSrcweir }
623cdf0e10cSrcweir 
624cdf0e10cSrcweir 
625cdf0e10cSrcweir void SvBaseLinksDlg::InsertEntry( const SvBaseLink& rLink, sal_uInt16 nPos, sal_Bool bSelect )
626cdf0e10cSrcweir {
627cdf0e10cSrcweir 	String aEntry, sFileNm, sLinkNm, sTypeNm, sFilter;
628cdf0e10cSrcweir 
629cdf0e10cSrcweir 	pLinkMgr->GetDisplayNames( (SvBaseLink*)&rLink, &sTypeNm, &sFileNm, &sLinkNm, &sFilter );
630cdf0e10cSrcweir 
631cdf0e10cSrcweir 	// GetTab(0) gibt die Position der von der TabListBox automatisch eingefuegten
632cdf0e10cSrcweir 	// Bitmap. Die Breite der ersten Textspalte ergibt sich deshalb aus Tab(2)-Tab(1)
633cdf0e10cSrcweir     long nWidthPixel = Links().GetLogicTab( 2 ) - Links().GetLogicTab( 1 );
634cdf0e10cSrcweir 	nWidthPixel -= SV_TAB_BORDER;
635cdf0e10cSrcweir     XubString aTxt = Links().GetEllipsisString( sFileNm, nWidthPixel, TEXT_DRAW_PATHELLIPSIS );
636cdf0e10cSrcweir 	INetURLObject aPath( sFileNm, INET_PROT_FILE );
637cdf0e10cSrcweir 	String aFileName = aPath.getName();
638cdf0e10cSrcweir     aFileName = INetURLObject::decode(aFileName, INET_HEX_ESCAPE, INetURLObject::DECODE_UNAMBIGUOUS);
639cdf0e10cSrcweir 
640cdf0e10cSrcweir     if( aFileName.Len() > aTxt.Len() )
641cdf0e10cSrcweir 		aTxt = aFileName;
642cdf0e10cSrcweir 	else if( aTxt.Search( aFileName, aTxt.Len() - aFileName.Len() ) == STRING_NOTFOUND )
643cdf0e10cSrcweir 		// filename not in string
644cdf0e10cSrcweir 		aTxt = aFileName;
645cdf0e10cSrcweir 
646cdf0e10cSrcweir 	aEntry = aTxt;
647cdf0e10cSrcweir 	aEntry += '\t';
648cdf0e10cSrcweir 	if( OBJECT_CLIENT_GRF == rLink.GetObjType() )
649cdf0e10cSrcweir 		aEntry += sFilter;
650cdf0e10cSrcweir 	else
651cdf0e10cSrcweir 		aEntry += sLinkNm;
652cdf0e10cSrcweir 	aEntry += '\t';
653cdf0e10cSrcweir 	aEntry += sTypeNm;
654cdf0e10cSrcweir 	aEntry += '\t';
655cdf0e10cSrcweir 	aEntry += ImplGetStateStr( rLink );
656cdf0e10cSrcweir 
657cdf0e10cSrcweir     SvLBoxEntry * pE = Links().InsertEntryToColumn( aEntry, nPos );
658cdf0e10cSrcweir 	pE->SetUserData( (void*)&rLink );
659cdf0e10cSrcweir     if(bSelect)
660cdf0e10cSrcweir         Links().Select(pE);
661cdf0e10cSrcweir }
662cdf0e10cSrcweir 
663cdf0e10cSrcweir SvBaseLink* SvBaseLinksDlg::GetSelEntry( sal_uInt16* pPos )
664cdf0e10cSrcweir {
665cdf0e10cSrcweir     SvLBoxEntry* pE = Links().FirstSelected();
666cdf0e10cSrcweir 	sal_uInt16 nPos;
667cdf0e10cSrcweir 	if( pE && LISTBOX_ENTRY_NOTFOUND !=
668cdf0e10cSrcweir         ( nPos = (sal_uInt16)Links().GetModel()->GetAbsPos( pE ) ) )
669cdf0e10cSrcweir 	{
670cdf0e10cSrcweir 		DBG_ASSERT( pE, "wo kommt der leere Eintrag her?" );
671cdf0e10cSrcweir 
672cdf0e10cSrcweir 		if( pPos )
673cdf0e10cSrcweir 			*pPos = nPos;
674cdf0e10cSrcweir 		return (SvBaseLink*)pE->GetUserData();
675cdf0e10cSrcweir 	}
676cdf0e10cSrcweir 	return 0;
677cdf0e10cSrcweir }
678cdf0e10cSrcweir 
679cdf0e10cSrcweir void SvBaseLinksDlg::SetType( SvBaseLink& rLink,
680cdf0e10cSrcweir 									sal_uInt16 nSelPos,
681cdf0e10cSrcweir 									sal_uInt16 nType )
682cdf0e10cSrcweir {
683cdf0e10cSrcweir 	rLink.SetUpdateMode( nType );
684cdf0e10cSrcweir 	rLink.Update();
685cdf0e10cSrcweir     SvLBoxEntry* pBox = Links().GetEntry( nSelPos );
686cdf0e10cSrcweir     Links().SetEntryText( ImplGetStateStr( rLink ), pBox, 3 );
687cdf0e10cSrcweir 	if( pLinkMgr->GetPersist() )
688cdf0e10cSrcweir 		pLinkMgr->GetPersist()->SetModified();
689cdf0e10cSrcweir }
690cdf0e10cSrcweir 
691cdf0e10cSrcweir void SvBaseLinksDlg::SetActLink( SvBaseLink * pLink )
692cdf0e10cSrcweir {
693cdf0e10cSrcweir 	if( pLinkMgr )
694cdf0e10cSrcweir 	{
695cdf0e10cSrcweir 		const SvBaseLinks& rLnks = pLinkMgr->GetLinks();
696cdf0e10cSrcweir         sal_uInt16 nSelect = 0;
697cdf0e10cSrcweir         for( sal_uInt16 n = 0; n < rLnks.Count(); ++n )
698cdf0e10cSrcweir         {
699cdf0e10cSrcweir             SvBaseLinkRef* pLinkRef = rLnks[ n ];
700cdf0e10cSrcweir             // #109573# only visible links have been inserted into the TreeListBox,
701cdf0e10cSrcweir             // invisible ones have to be skipped here
702cdf0e10cSrcweir             if( (*pLinkRef)->IsVisible() )
703cdf0e10cSrcweir             {
704cdf0e10cSrcweir                 if( pLink == *pLinkRef )
705cdf0e10cSrcweir                 {
706cdf0e10cSrcweir                     Links().Select( Links().GetEntry( nSelect ) );
707cdf0e10cSrcweir                     LinksSelectHdl( 0 );
708cdf0e10cSrcweir                     return ;
709cdf0e10cSrcweir                 }
710cdf0e10cSrcweir                 nSelect++;
711cdf0e10cSrcweir             }
712cdf0e10cSrcweir         }
713cdf0e10cSrcweir 	}
714cdf0e10cSrcweir }
715cdf0e10cSrcweir 
716