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