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