xref: /AOO41X/main/cui/source/dialogs/hlmarkwn.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 <vcl/wrkwin.hxx>
28cdf0e10cSrcweir #include <dialmgr.hxx>
29cdf0e10cSrcweir #include <sfx2/docfile.hxx>
30cdf0e10cSrcweir #include <vcl/svapp.hxx>
31cdf0e10cSrcweir #include <vcl/settings.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir // UNO-Stuff
34cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
35cdf0e10cSrcweir #include <com/sun/star/awt/XBitmap.hpp>
36cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp>
37cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp>
38cdf0e10cSrcweir #include <com/sun/star/frame/XComponentLoader.hpp>
39cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
40cdf0e10cSrcweir #include <com/sun/star/document/XLinkTargetSupplier.hpp>
41cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include <toolkit/unohlp.hxx>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include <cuires.hrc>
46cdf0e10cSrcweir #include "hlmarkwn.hrc"
47cdf0e10cSrcweir #include "hlmarkwn.hxx"
48cdf0e10cSrcweir #include "hltpbase.hxx"
49cdf0e10cSrcweir 
50cdf0e10cSrcweir using namespace ::com::sun::star;
51cdf0e10cSrcweir using namespace ::rtl;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir /*************************************************************************
54cdf0e10cSrcweir |*
55cdf0e10cSrcweir |* Userdata-struct for tree-entries
56cdf0e10cSrcweir |*
57cdf0e10cSrcweir |************************************************************************/
58cdf0e10cSrcweir 
59cdf0e10cSrcweir struct TargetData
60cdf0e10cSrcweir {
61cdf0e10cSrcweir 	OUString		aUStrLinkname;
62cdf0e10cSrcweir 	sal_Bool		bIsTarget;
63cdf0e10cSrcweir 
TargetDataTargetData64cdf0e10cSrcweir 	TargetData ( OUString aUStrLName, sal_Bool bTarget )
65cdf0e10cSrcweir 		:	bIsTarget ( bTarget )
66cdf0e10cSrcweir 	{
67cdf0e10cSrcweir 		if ( bIsTarget )
68cdf0e10cSrcweir 			aUStrLinkname = aUStrLName;
69cdf0e10cSrcweir 	}
70cdf0e10cSrcweir };
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 
73cdf0e10cSrcweir //########################################################################
74cdf0e10cSrcweir //#                                                                      #
75cdf0e10cSrcweir //# Tree-Window 														 #
76cdf0e10cSrcweir //#                                                                      #
77cdf0e10cSrcweir //########################################################################
78cdf0e10cSrcweir 
SvxHlmarkTreeLBox(Window * pParent,const ResId & rResId)79cdf0e10cSrcweir SvxHlmarkTreeLBox::SvxHlmarkTreeLBox( Window* pParent, const ResId& rResId )
80cdf0e10cSrcweir : SvTreeListBox	( pParent, rResId ),
81cdf0e10cSrcweir   mpParentWnd	( (SvxHlinkDlgMarkWnd*) pParent )
82cdf0e10cSrcweir {
83cdf0e10cSrcweir 	SetNodeDefaultImages();
84cdf0e10cSrcweir }
85cdf0e10cSrcweir 
Paint(const Rectangle & rRect)86cdf0e10cSrcweir void SvxHlmarkTreeLBox::Paint( const Rectangle& rRect )
87cdf0e10cSrcweir {
88cdf0e10cSrcweir 	if( mpParentWnd->mnError == LERR_NOERROR )
89cdf0e10cSrcweir 	{
90cdf0e10cSrcweir 		SvTreeListBox::Paint(rRect);
91cdf0e10cSrcweir 	}
92cdf0e10cSrcweir 	else
93cdf0e10cSrcweir 	{
94cdf0e10cSrcweir 		Erase();
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 		Rectangle aDrawRect( Point( 0, 0 ), GetSizePixel() );
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 		String aStrMessage;
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 		switch( mpParentWnd->mnError )
101cdf0e10cSrcweir 		{
102cdf0e10cSrcweir 		case LERR_NOENTRIES :
103cdf0e10cSrcweir 			aStrMessage = CUI_RESSTR( RID_SVXSTR_HYPDLG_ERR_LERR_NOENTRIES );
104cdf0e10cSrcweir 			break;
105cdf0e10cSrcweir 		case LERR_DOCNOTOPEN :
106cdf0e10cSrcweir 			aStrMessage = CUI_RESSTR( RID_SVXSTR_HYPDLG_ERR_LERR_DOCNOTOPEN );
107cdf0e10cSrcweir 			break;
108cdf0e10cSrcweir 		}
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 		DrawText( aDrawRect, aStrMessage, TEXT_DRAW_LEFT | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK );
111cdf0e10cSrcweir 	}
112cdf0e10cSrcweir 
113cdf0e10cSrcweir }
114cdf0e10cSrcweir 
115cdf0e10cSrcweir //########################################################################
116cdf0e10cSrcweir //#                                                                      #
117cdf0e10cSrcweir //# Window-Class														 #
118cdf0e10cSrcweir //#                                                                      #
119cdf0e10cSrcweir //########################################################################
120cdf0e10cSrcweir 
121cdf0e10cSrcweir /*************************************************************************
122cdf0e10cSrcweir |*
123cdf0e10cSrcweir |* Contructor / Destructor
124cdf0e10cSrcweir |*
125cdf0e10cSrcweir |************************************************************************/
126cdf0e10cSrcweir 
SvxHlinkDlgMarkWnd(SvxHyperlinkTabPageBase * pParent)127cdf0e10cSrcweir SvxHlinkDlgMarkWnd::SvxHlinkDlgMarkWnd( SvxHyperlinkTabPageBase *pParent )
128cdf0e10cSrcweir :	ModalDialog( (Window*)pParent, CUI_RES ( RID_SVXFLOAT_HYPERLINK_MARKWND ) ),
129cdf0e10cSrcweir 	maBtApply( this, CUI_RES (BT_APPLY) ),
130cdf0e10cSrcweir 	maBtClose( this, CUI_RES (BT_CLOSE) ),
131cdf0e10cSrcweir 	maLbTree ( this, CUI_RES (TLB_MARK) ),
132cdf0e10cSrcweir 	mbUserMoved ( sal_False ),
133cdf0e10cSrcweir 	mbFirst	    ( sal_True ),
134cdf0e10cSrcweir 	mpParent	( pParent ),
135cdf0e10cSrcweir 	mnError		( LERR_NOERROR )
136cdf0e10cSrcweir {
137cdf0e10cSrcweir 	FreeResource();
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 	maBtApply.SetClickHdl		( LINK ( this, SvxHlinkDlgMarkWnd, ClickApplyHdl_Impl ) );
140cdf0e10cSrcweir 	maBtClose.SetClickHdl		( LINK ( this, SvxHlinkDlgMarkWnd, ClickCloseHdl_Impl ) );
141cdf0e10cSrcweir 	maLbTree.SetDoubleClickHdl	( LINK ( this, SvxHlinkDlgMarkWnd, ClickApplyHdl_Impl ) );
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 	// Tree-ListBox mit Linien versehen
144cdf0e10cSrcweir 	maLbTree.SetStyle( maLbTree.GetStyle() | WB_TABSTOP | WB_BORDER | WB_HASLINES |
145cdf0e10cSrcweir 							WB_HASBUTTONS |  //WB_HASLINESATROOT |
146cdf0e10cSrcweir 							WB_HSCROLL | WB_HASBUTTONSATROOT );
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     maLbTree.SetAccessibleName(String(CUI_RES(STR_MARK_TREE)));
149cdf0e10cSrcweir 
150cdf0e10cSrcweir }
151cdf0e10cSrcweir 
~SvxHlinkDlgMarkWnd()152cdf0e10cSrcweir SvxHlinkDlgMarkWnd::~SvxHlinkDlgMarkWnd()
153cdf0e10cSrcweir {
154cdf0e10cSrcweir 	ClearTree();
155cdf0e10cSrcweir }
156cdf0e10cSrcweir 
157cdf0e10cSrcweir /*************************************************************************
158cdf0e10cSrcweir |*
159cdf0e10cSrcweir |* Set an errorstatus
160cdf0e10cSrcweir |*
161cdf0e10cSrcweir |************************************************************************/
162cdf0e10cSrcweir 
SetError(sal_uInt16 nError)163cdf0e10cSrcweir sal_uInt16 SvxHlinkDlgMarkWnd::SetError( sal_uInt16 nError)
164cdf0e10cSrcweir {
165cdf0e10cSrcweir 	sal_uInt16 nOldError = mnError;
166cdf0e10cSrcweir 	mnError = nError;
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 	if( mnError != LERR_NOERROR )
169cdf0e10cSrcweir 		ClearTree();
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 	maLbTree.Invalidate();
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 	return nOldError;
174cdf0e10cSrcweir }
175cdf0e10cSrcweir 
176cdf0e10cSrcweir /*************************************************************************
177cdf0e10cSrcweir |*
178cdf0e10cSrcweir |* Move window
179cdf0e10cSrcweir |*
180cdf0e10cSrcweir |************************************************************************/
181cdf0e10cSrcweir 
MoveTo(Point aNewPos)182cdf0e10cSrcweir sal_Bool SvxHlinkDlgMarkWnd::MoveTo ( Point aNewPos )
183cdf0e10cSrcweir {
184cdf0e10cSrcweir 	if ( !mbUserMoved )
185cdf0e10cSrcweir 	{
186cdf0e10cSrcweir 		sal_Bool bOldStatus = mbUserMoved;
187cdf0e10cSrcweir 		SetPosPixel ( aNewPos );
188cdf0e10cSrcweir 		mbUserMoved = bOldStatus;
189cdf0e10cSrcweir 	}
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 	return mbUserMoved;
192cdf0e10cSrcweir }
193cdf0e10cSrcweir 
Move()194cdf0e10cSrcweir void SvxHlinkDlgMarkWnd::Move ()
195cdf0e10cSrcweir {
196cdf0e10cSrcweir 	Window::Move();
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 	if ( IsReallyVisible() )
199cdf0e10cSrcweir 		mbUserMoved = sal_True;
200cdf0e10cSrcweir }
201cdf0e10cSrcweir 
ConnectToDialog(sal_Bool bDoit)202cdf0e10cSrcweir sal_Bool SvxHlinkDlgMarkWnd::ConnectToDialog( sal_Bool bDoit )
203cdf0e10cSrcweir {
204cdf0e10cSrcweir 	sal_Bool bOldStatus = mbUserMoved;
205cdf0e10cSrcweir 
206cdf0e10cSrcweir 	mbUserMoved = !bDoit;
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 	return bOldStatus;
209cdf0e10cSrcweir }
210cdf0e10cSrcweir 
211cdf0e10cSrcweir /*************************************************************************
212cdf0e10cSrcweir |*
213cdf0e10cSrcweir |* Interface to refresh tree
214cdf0e10cSrcweir |*
215cdf0e10cSrcweir |************************************************************************/
216cdf0e10cSrcweir 
RefreshTree(String aStrURL)217cdf0e10cSrcweir void SvxHlinkDlgMarkWnd::RefreshTree ( String aStrURL )
218cdf0e10cSrcweir {
219cdf0e10cSrcweir     String aEmptyStr;
220cdf0e10cSrcweir 	OUString aUStrURL;
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 	EnterWait();
223cdf0e10cSrcweir 
224cdf0e10cSrcweir 	ClearTree();
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 	xub_StrLen nPos = aStrURL.Search ( sal_Unicode('#') );
227cdf0e10cSrcweir 
228cdf0e10cSrcweir 	if( nPos != 0 )
229cdf0e10cSrcweir 		aUStrURL = ::rtl::OUString( aStrURL );
230cdf0e10cSrcweir 
231cdf0e10cSrcweir 	if( !RefreshFromDoc ( aUStrURL ) )
232cdf0e10cSrcweir 		maLbTree.Invalidate();
233cdf0e10cSrcweir 
234cdf0e10cSrcweir 	if ( nPos != STRING_NOTFOUND )
235cdf0e10cSrcweir 	{
236cdf0e10cSrcweir 		String aStrMark = aStrURL.Copy ( nPos+1 );
237cdf0e10cSrcweir 		SelectEntry ( aStrMark );
238cdf0e10cSrcweir 	}
239cdf0e10cSrcweir 
240cdf0e10cSrcweir 	LeaveWait();
241cdf0e10cSrcweir 
242cdf0e10cSrcweir 	maStrLastURL = aStrURL;
243cdf0e10cSrcweir }
244cdf0e10cSrcweir 
245cdf0e10cSrcweir /*************************************************************************
246cdf0e10cSrcweir |*
247cdf0e10cSrcweir |* get links from document
248cdf0e10cSrcweir |*
249cdf0e10cSrcweir |************************************************************************/
250cdf0e10cSrcweir 
RefreshFromDoc(OUString aURL)251cdf0e10cSrcweir sal_Bool SvxHlinkDlgMarkWnd::RefreshFromDoc( OUString aURL )
252cdf0e10cSrcweir {
253cdf0e10cSrcweir 	mnError = LERR_NOERROR;
254cdf0e10cSrcweir 
255cdf0e10cSrcweir 	uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
256cdf0e10cSrcweir 	if( xFactory.is() )
257cdf0e10cSrcweir 	{
258cdf0e10cSrcweir 		uno::Reference< frame::XDesktop > xDesktop( xFactory->createInstance( OUString::createFromAscii( "com.sun.star.frame.Desktop" ) ),
259cdf0e10cSrcweir 					uno::UNO_QUERY );
260cdf0e10cSrcweir 		if( xDesktop.is() )
261cdf0e10cSrcweir 		{
262cdf0e10cSrcweir 			uno::Reference< lang::XComponent > xComp;
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 			if( aURL.getLength() )
265cdf0e10cSrcweir 			{
266cdf0e10cSrcweir 				// load from url
267cdf0e10cSrcweir 				uno::Reference< frame::XComponentLoader > xLoader( xDesktop, uno::UNO_QUERY );
268cdf0e10cSrcweir 				if( xLoader.is() )
269cdf0e10cSrcweir 				{
270cdf0e10cSrcweir 					try
271cdf0e10cSrcweir 					{
272cdf0e10cSrcweir 						uno::Sequence< beans::PropertyValue > aArg(1);
273cdf0e10cSrcweir 						aArg.getArray()[0].Name = OUString::createFromAscii( "Hidden" );
274cdf0e10cSrcweir 						aArg.getArray()[0].Value <<= (sal_Bool) sal_True;
275cdf0e10cSrcweir 						xComp = xLoader->loadComponentFromURL( aURL, OUString::createFromAscii( "_blank" ), 0, aArg );
276cdf0e10cSrcweir 					}
277cdf0e10cSrcweir 					catch( const io::IOException& )
278cdf0e10cSrcweir 					{
279cdf0e10cSrcweir 
280cdf0e10cSrcweir 					}
281cdf0e10cSrcweir 					catch( const lang::IllegalArgumentException& )
282cdf0e10cSrcweir 					{
283cdf0e10cSrcweir 
284cdf0e10cSrcweir 					}
285cdf0e10cSrcweir 				}
286cdf0e10cSrcweir 			}
287cdf0e10cSrcweir 			else
288cdf0e10cSrcweir 			{
289cdf0e10cSrcweir 				// the component with user focus ( current document )
290cdf0e10cSrcweir 				xComp = xDesktop->getCurrentComponent();
291cdf0e10cSrcweir 			}
292cdf0e10cSrcweir 
293cdf0e10cSrcweir 			if( xComp.is() )
294cdf0e10cSrcweir 			{
295cdf0e10cSrcweir 				uno::Reference< document::XLinkTargetSupplier > xLTS( xComp, uno::UNO_QUERY );
296cdf0e10cSrcweir 
297cdf0e10cSrcweir 				if( xLTS.is() )
298cdf0e10cSrcweir 				{
299cdf0e10cSrcweir 					if( FillTree( xLTS->getLinks() ) == 0 )
300cdf0e10cSrcweir 						mnError = LERR_NOENTRIES;
301cdf0e10cSrcweir 				}
302cdf0e10cSrcweir 				else
303cdf0e10cSrcweir 					mnError = LERR_DOCNOTOPEN;
304cdf0e10cSrcweir 
305cdf0e10cSrcweir 				if ( aURL.getLength() )
306cdf0e10cSrcweir 					xComp->dispose();
307cdf0e10cSrcweir 			}
308cdf0e10cSrcweir 			else
309cdf0e10cSrcweir 			{
310cdf0e10cSrcweir 				if( aURL.getLength() )
311cdf0e10cSrcweir 					mnError=LERR_DOCNOTOPEN;
312cdf0e10cSrcweir 			}
313cdf0e10cSrcweir 		}
314cdf0e10cSrcweir 	}
315cdf0e10cSrcweir 	return (mnError==0);
316cdf0e10cSrcweir }
317cdf0e10cSrcweir /*
318cdf0e10cSrcweir void SvxHlinkDlgMarkWnd::Error(int nNr)
319cdf0e10cSrcweir {
320cdf0e10cSrcweir 	switch(nNr)
321cdf0e10cSrcweir 	{
322cdf0e10cSrcweir 		case 0:
323cdf0e10cSrcweir 		{
324cdf0e10cSrcweir 			Rectangle aDrawRect( Point( 0, 0 ), maLbTree.GetSizePixel() );
325cdf0e10cSrcweir 			//maLbTree.SetTextColor( Color(COL_BLACK) );
326cdf0e10cSrcweir 			//maLbTree.DrawText( aDrawRect, "Keine Ziele im Dokument vorhanden.", TEXT_DRAW_LEFT);// | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK );
327cdf0e10cSrcweir 			maLbTree.DrawText( Point(0,0), "Keine Ziele im Dokument vorhanden.");
328cdf0e10cSrcweir 			maLbTree.DrawLine(aDrawRect.TopLeft(), aDrawRect.BottomRight() );
329cdf0e10cSrcweir 		}
330cdf0e10cSrcweir 		break;
331cdf0e10cSrcweir 		case 1:
332cdf0e10cSrcweir 			Rectangle aDrawRect( Point( 0, 0 ), maLbTree.GetSizePixel() );
333cdf0e10cSrcweir 			maLbTree.DrawText( aDrawRect, "Das Dokument konnte nicht ge�ffnet werden.", TEXT_DRAW_LEFT | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK );
334cdf0e10cSrcweir 			break;
335cdf0e10cSrcweir 	}
336cdf0e10cSrcweir }
337cdf0e10cSrcweir */
338cdf0e10cSrcweir /*************************************************************************
339cdf0e10cSrcweir |*
340cdf0e10cSrcweir |* Fill Tree-Control
341cdf0e10cSrcweir |*
342cdf0e10cSrcweir |************************************************************************/
343cdf0e10cSrcweir 
FillTree(uno::Reference<container::XNameAccess> xLinks,SvLBoxEntry * pParentEntry)344cdf0e10cSrcweir int SvxHlinkDlgMarkWnd::FillTree( uno::Reference< container::XNameAccess > xLinks, SvLBoxEntry* pParentEntry )
345cdf0e10cSrcweir {
346cdf0e10cSrcweir 	int nEntries=0;
347cdf0e10cSrcweir 	const uno::Sequence< OUString > aNames( xLinks->getElementNames() );
348cdf0e10cSrcweir 	const sal_uLong nLinks = aNames.getLength();
349cdf0e10cSrcweir 	const OUString* pNames = aNames.getConstArray();
350cdf0e10cSrcweir 
351cdf0e10cSrcweir     Color aMaskColor( COL_LIGHTMAGENTA );
352cdf0e10cSrcweir 	const OUString aProp_LinkDisplayName( RTL_CONSTASCII_USTRINGPARAM( "LinkDisplayName" ) );
353cdf0e10cSrcweir 	const OUString aProp_LinkTarget( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.LinkTarget" ) );
354cdf0e10cSrcweir 	const OUString aProp_LinkDisplayBitmap( RTL_CONSTASCII_USTRINGPARAM( "LinkDisplayBitmap" ) );
355cdf0e10cSrcweir 	for( sal_uLong i = 0; i < nLinks; i++ )
356cdf0e10cSrcweir 	{
357cdf0e10cSrcweir 		uno::Any aAny;
358cdf0e10cSrcweir 		OUString aLink( *pNames++ );
359cdf0e10cSrcweir 
360cdf0e10cSrcweir 		sal_Bool bError = sal_False;
361cdf0e10cSrcweir 		try
362cdf0e10cSrcweir 		{
363cdf0e10cSrcweir 			aAny = xLinks->getByName( aLink );
364cdf0e10cSrcweir 		}
365cdf0e10cSrcweir 		catch(const uno::Exception&)
366cdf0e10cSrcweir 		{
367cdf0e10cSrcweir 			// if the name of the target was invalid (like empty headings)
368cdf0e10cSrcweir 			// no object can be provided
369cdf0e10cSrcweir 			bError = sal_True;
370cdf0e10cSrcweir 		}
371cdf0e10cSrcweir 		if(bError)
372cdf0e10cSrcweir 			continue;
373cdf0e10cSrcweir 
374cdf0e10cSrcweir 		uno::Reference< beans::XPropertySet > xTarget;
375cdf0e10cSrcweir 
376cdf0e10cSrcweir 		if( aAny >>= xTarget )
377cdf0e10cSrcweir 		{
378cdf0e10cSrcweir 			try
379cdf0e10cSrcweir 			{
380cdf0e10cSrcweir 				// get name to display
381cdf0e10cSrcweir 				aAny = xTarget->getPropertyValue( aProp_LinkDisplayName );
382cdf0e10cSrcweir 				OUString aDisplayName;
383cdf0e10cSrcweir 				aAny >>= aDisplayName;
384cdf0e10cSrcweir 				String aStrDisplayname ( aDisplayName );
385cdf0e10cSrcweir 
386cdf0e10cSrcweir 				// is it a target ?
387cdf0e10cSrcweir 				uno::Reference< lang::XServiceInfo > xSI( xTarget, uno::UNO_QUERY );
388cdf0e10cSrcweir 				sal_Bool bIsTarget = xSI->supportsService( aProp_LinkTarget );
389cdf0e10cSrcweir 
390cdf0e10cSrcweir 				// create userdata
391cdf0e10cSrcweir 				TargetData *pData = new TargetData ( aLink, bIsTarget );
392cdf0e10cSrcweir 
393cdf0e10cSrcweir 				SvLBoxEntry* pEntry;
394cdf0e10cSrcweir 
395cdf0e10cSrcweir 				try
396cdf0e10cSrcweir 				{
397cdf0e10cSrcweir 					// get bitmap for the tree-entry
398cdf0e10cSrcweir 					uno::Reference< awt::XBitmap > aXBitmap( xTarget->getPropertyValue( aProp_LinkDisplayBitmap ), uno::UNO_QUERY );
399cdf0e10cSrcweir 					if( aXBitmap.is() )
400cdf0e10cSrcweir 					{
401cdf0e10cSrcweir                         Image aBmp( VCLUnoHelper::GetBitmap( aXBitmap ).GetBitmap(), aMaskColor );
402cdf0e10cSrcweir                         // insert Displayname into treelist with bitmaps
403cdf0e10cSrcweir 						pEntry = maLbTree.InsertEntry ( aStrDisplayname,
404cdf0e10cSrcweir                                                         aBmp, aBmp,
405cdf0e10cSrcweir 														pParentEntry,
406cdf0e10cSrcweir 														sal_False, LIST_APPEND,
407cdf0e10cSrcweir 														(void*)pData );
408cdf0e10cSrcweir                         maLbTree.SetExpandedEntryBmp( pEntry, aBmp, BMP_COLOR_HIGHCONTRAST );
409cdf0e10cSrcweir                         maLbTree.SetCollapsedEntryBmp( pEntry, aBmp, BMP_COLOR_HIGHCONTRAST );
410cdf0e10cSrcweir                         nEntries++;
411cdf0e10cSrcweir 					}
412cdf0e10cSrcweir 					else
413cdf0e10cSrcweir 					{
414cdf0e10cSrcweir 						// insert Displayname into treelist without bitmaps
415cdf0e10cSrcweir 						pEntry = maLbTree.InsertEntry ( aStrDisplayname,
416cdf0e10cSrcweir 														pParentEntry,
417cdf0e10cSrcweir 														sal_False, LIST_APPEND,
418cdf0e10cSrcweir 														(void*)pData );
419cdf0e10cSrcweir 						nEntries++;
420cdf0e10cSrcweir 					}
421cdf0e10cSrcweir 				}
422cdf0e10cSrcweir 				catch(const com::sun::star::uno::Exception&)
423cdf0e10cSrcweir 				{
424cdf0e10cSrcweir 					// insert Displayname into treelist without bitmaps
425cdf0e10cSrcweir 					pEntry = maLbTree.InsertEntry ( aStrDisplayname,
426cdf0e10cSrcweir 													pParentEntry,
427cdf0e10cSrcweir 													sal_False, LIST_APPEND,
428cdf0e10cSrcweir 													(void*)pData );
429cdf0e10cSrcweir 					nEntries++;
430cdf0e10cSrcweir 				}
431cdf0e10cSrcweir 
432cdf0e10cSrcweir 				uno::Reference< document::XLinkTargetSupplier > xLTS( xTarget, uno::UNO_QUERY );
433cdf0e10cSrcweir 				if( xLTS.is() )
434cdf0e10cSrcweir 					nEntries += FillTree( xLTS->getLinks(), pEntry );
435cdf0e10cSrcweir 			}
436cdf0e10cSrcweir 			catch(const com::sun::star::uno::Exception&)
437cdf0e10cSrcweir 			{
438cdf0e10cSrcweir 			}
439cdf0e10cSrcweir 		}
440cdf0e10cSrcweir 	}
441cdf0e10cSrcweir 
442cdf0e10cSrcweir 	return nEntries;
443cdf0e10cSrcweir }
444cdf0e10cSrcweir 
445cdf0e10cSrcweir /*************************************************************************
446cdf0e10cSrcweir |*
447cdf0e10cSrcweir |* Clear Tree
448cdf0e10cSrcweir |*
449cdf0e10cSrcweir |************************************************************************/
450cdf0e10cSrcweir 
ClearTree()451cdf0e10cSrcweir void SvxHlinkDlgMarkWnd::ClearTree()
452cdf0e10cSrcweir {
453cdf0e10cSrcweir 	SvLBoxEntry* pEntry = maLbTree.First();
454cdf0e10cSrcweir 
455cdf0e10cSrcweir 	while ( pEntry )
456cdf0e10cSrcweir 	{
457cdf0e10cSrcweir 		TargetData* pUserData = ( TargetData * ) pEntry->GetUserData();
458cdf0e10cSrcweir 		delete pUserData;
459cdf0e10cSrcweir 
460cdf0e10cSrcweir 		pEntry = maLbTree.Next( pEntry );
461cdf0e10cSrcweir 	}
462cdf0e10cSrcweir 
463cdf0e10cSrcweir 	maLbTree.Clear();
464cdf0e10cSrcweir }
465cdf0e10cSrcweir 
466cdf0e10cSrcweir /*************************************************************************
467cdf0e10cSrcweir |*
468cdf0e10cSrcweir |* Find Entry for Strng
469cdf0e10cSrcweir |*
470cdf0e10cSrcweir |************************************************************************/
471cdf0e10cSrcweir 
FindEntry(String aStrName)472cdf0e10cSrcweir SvLBoxEntry* SvxHlinkDlgMarkWnd::FindEntry ( String aStrName )
473cdf0e10cSrcweir {
474cdf0e10cSrcweir 	sal_Bool bFound=sal_False;
475cdf0e10cSrcweir 	SvLBoxEntry* pEntry = maLbTree.First();
476cdf0e10cSrcweir 
477cdf0e10cSrcweir 	while ( pEntry && !bFound )
478cdf0e10cSrcweir 	{
479cdf0e10cSrcweir 		TargetData* pUserData = ( TargetData * ) pEntry->GetUserData ();
480cdf0e10cSrcweir 		if ( aStrName == String( pUserData->aUStrLinkname ) )
481cdf0e10cSrcweir 			bFound = sal_True;
482cdf0e10cSrcweir 		else
483cdf0e10cSrcweir 			pEntry = maLbTree.Next( pEntry );
484cdf0e10cSrcweir 	}
485cdf0e10cSrcweir 
486cdf0e10cSrcweir 	return pEntry;
487cdf0e10cSrcweir }
488cdf0e10cSrcweir 
489cdf0e10cSrcweir /*************************************************************************
490cdf0e10cSrcweir |*
491cdf0e10cSrcweir |* Select Entry
492cdf0e10cSrcweir |*
493cdf0e10cSrcweir |************************************************************************/
494cdf0e10cSrcweir 
SelectEntry(String aStrMark)495cdf0e10cSrcweir void SvxHlinkDlgMarkWnd::SelectEntry ( String aStrMark )
496cdf0e10cSrcweir {
497cdf0e10cSrcweir 	SvLBoxEntry* pEntry = FindEntry ( aStrMark );
498cdf0e10cSrcweir 	if ( pEntry )
499cdf0e10cSrcweir 	{
500cdf0e10cSrcweir 		maLbTree.Select ( pEntry );
501cdf0e10cSrcweir 		maLbTree.MakeVisible ( pEntry );
502cdf0e10cSrcweir 	}
503cdf0e10cSrcweir }
504cdf0e10cSrcweir 
505cdf0e10cSrcweir /*************************************************************************
506cdf0e10cSrcweir |*
507cdf0e10cSrcweir |* Click on Apply-Button / Doubleclick on item in tree
508cdf0e10cSrcweir |*
509cdf0e10cSrcweir |************************************************************************/
510cdf0e10cSrcweir 
IMPL_LINK(SvxHlinkDlgMarkWnd,ClickApplyHdl_Impl,void *,EMPTYARG)511cdf0e10cSrcweir IMPL_LINK ( SvxHlinkDlgMarkWnd, ClickApplyHdl_Impl, void *, EMPTYARG )
512cdf0e10cSrcweir {
513cdf0e10cSrcweir 	SvLBoxEntry* pEntry = maLbTree.GetCurEntry();
514cdf0e10cSrcweir 
515cdf0e10cSrcweir 	if ( pEntry )
516cdf0e10cSrcweir 	{
517cdf0e10cSrcweir 		TargetData *pData = ( TargetData * )pEntry->GetUserData();
518cdf0e10cSrcweir 
519cdf0e10cSrcweir 		if ( pData->bIsTarget )
520cdf0e10cSrcweir 		{
521cdf0e10cSrcweir 			String aStrMark ( pData->aUStrLinkname );
522cdf0e10cSrcweir 			mpParent->SetMarkStr ( aStrMark );
523cdf0e10cSrcweir 		}
524cdf0e10cSrcweir 	}
525cdf0e10cSrcweir 
526cdf0e10cSrcweir 	return( 0L );
527cdf0e10cSrcweir }
528cdf0e10cSrcweir 
529cdf0e10cSrcweir /*************************************************************************
530cdf0e10cSrcweir |*
531cdf0e10cSrcweir |* Click on Close-Button
532cdf0e10cSrcweir |*
533cdf0e10cSrcweir |************************************************************************/
534cdf0e10cSrcweir 
IMPL_LINK(SvxHlinkDlgMarkWnd,ClickCloseHdl_Impl,void *,EMPTYARG)535cdf0e10cSrcweir IMPL_LINK ( SvxHlinkDlgMarkWnd, ClickCloseHdl_Impl, void *, EMPTYARG )
536cdf0e10cSrcweir {
537cdf0e10cSrcweir     Close();
538cdf0e10cSrcweir 
539cdf0e10cSrcweir 	return( 0L );
540cdf0e10cSrcweir }
541cdf0e10cSrcweir 
542cdf0e10cSrcweir 
543