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_svtools.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir /* 32*cdf0e10cSrcweir Todo: 33*cdf0e10cSrcweir - Anker loeschen in SelectionEngine bei manuellem Selektieren 34*cdf0e10cSrcweir - SelectAll( sal_False ), nur die deselektierten Entries repainten 35*cdf0e10cSrcweir */ 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <string.h> 38*cdf0e10cSrcweir #include <svtools/svlbox.hxx> 39*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 40*cdf0e10cSrcweir #include <vcl/svapp.hxx> 41*cdf0e10cSrcweir #include <vcl/accel.hxx> 42*cdf0e10cSrcweir #include <vcl/i18nhelp.hxx> 43*cdf0e10cSrcweir #include <sot/formats.hxx> 44*cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 45*cdf0e10cSrcweir #include <rtl/instance.hxx> 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir #define _SVSTDARR_ULONGSSORT 48*cdf0e10cSrcweir #include <svl/svstdarr.hxx> 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir #ifndef _SVEDI_HXX 51*cdf0e10cSrcweir #include <svtools/svmedit.hxx> 52*cdf0e10cSrcweir #endif 53*cdf0e10cSrcweir #include <svtools/svlbitm.hxx> 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir // Drag&Drop 58*cdf0e10cSrcweir static SvLBox* pDDSource = NULL; 59*cdf0e10cSrcweir static SvLBox* pDDTarget = NULL; 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir DBG_NAME(SvInplaceEdit) 62*cdf0e10cSrcweir DBG_NAME(SvInplaceEdit2) 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir #define SVLBOX_ACC_RETURN 1 65*cdf0e10cSrcweir #define SVLBOX_ACC_ESCAPE 2 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir SvInplaceEdit::SvInplaceEdit 68*cdf0e10cSrcweir ( 69*cdf0e10cSrcweir Window* pParent, 70*cdf0e10cSrcweir const Point& rPos, 71*cdf0e10cSrcweir const Size& rSize, 72*cdf0e10cSrcweir const String& rData, 73*cdf0e10cSrcweir const Link& rNotifyEditEnd, 74*cdf0e10cSrcweir const Selection& rSelection 75*cdf0e10cSrcweir ) : 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir Edit( pParent, WB_LEFT ), 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir aCallBackHdl ( rNotifyEditEnd ), 80*cdf0e10cSrcweir bCanceled ( sal_False ), 81*cdf0e10cSrcweir bAlreadyInCallBack ( sal_False ) 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir DBG_CTOR(SvInplaceEdit,0); 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir Font aFont( pParent->GetFont() ); 87*cdf0e10cSrcweir aFont.SetTransparent( sal_False ); 88*cdf0e10cSrcweir Color aColor( pParent->GetBackground().GetColor() ); 89*cdf0e10cSrcweir aFont.SetFillColor(aColor ); 90*cdf0e10cSrcweir SetFont( aFont ); 91*cdf0e10cSrcweir SetBackground( pParent->GetBackground() ); 92*cdf0e10cSrcweir SetPosPixel( rPos ); 93*cdf0e10cSrcweir SetSizePixel( rSize ); 94*cdf0e10cSrcweir SetText( rData ); 95*cdf0e10cSrcweir SetSelection( rSelection ); 96*cdf0e10cSrcweir SaveValue(); 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir aAccReturn.InsertItem( SVLBOX_ACC_RETURN, KeyCode(KEY_RETURN) ); 99*cdf0e10cSrcweir aAccEscape.InsertItem( SVLBOX_ACC_ESCAPE, KeyCode(KEY_ESCAPE) ); 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir aAccReturn.SetActivateHdl( LINK( this, SvInplaceEdit, ReturnHdl_Impl) ); 102*cdf0e10cSrcweir aAccEscape.SetActivateHdl( LINK( this, SvInplaceEdit, EscapeHdl_Impl) ); 103*cdf0e10cSrcweir GetpApp()->InsertAccel( &aAccReturn ); 104*cdf0e10cSrcweir GetpApp()->InsertAccel( &aAccEscape ); 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir Show(); 107*cdf0e10cSrcweir GrabFocus(); 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir SvInplaceEdit::~SvInplaceEdit() 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir DBG_DTOR(SvInplaceEdit,0); 113*cdf0e10cSrcweir if( !bAlreadyInCallBack ) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir GetpApp()->RemoveAccel( &aAccReturn ); 116*cdf0e10cSrcweir GetpApp()->RemoveAccel( &aAccEscape ); 117*cdf0e10cSrcweir } 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvInplaceEdit, ReturnHdl_Impl, Accelerator *, EMPTYARG ) 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir DBG_CHKTHIS(SvInplaceEdit,0); 123*cdf0e10cSrcweir bCanceled = sal_False; 124*cdf0e10cSrcweir CallCallBackHdl_Impl(); 125*cdf0e10cSrcweir return 1; 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvInplaceEdit, ReturnHdl_Impl, Accelerator *, EMPTYARG ) 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvInplaceEdit, EscapeHdl_Impl, Accelerator *, EMPTYARG ) 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir DBG_CHKTHIS(SvInplaceEdit,0); 132*cdf0e10cSrcweir bCanceled = sal_True; 133*cdf0e10cSrcweir CallCallBackHdl_Impl(); 134*cdf0e10cSrcweir return 1; 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvInplaceEdit, EscapeHdl_Impl, Accelerator *, EMPTYARG ) 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir void SvInplaceEdit::KeyInput( const KeyEvent& rKEvt ) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir DBG_CHKTHIS(SvInplaceEdit,0); 141*cdf0e10cSrcweir sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode(); 142*cdf0e10cSrcweir switch ( nCode ) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir case KEY_ESCAPE: 145*cdf0e10cSrcweir bCanceled = sal_True; 146*cdf0e10cSrcweir CallCallBackHdl_Impl(); 147*cdf0e10cSrcweir break; 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir case KEY_RETURN: 150*cdf0e10cSrcweir bCanceled = sal_False; 151*cdf0e10cSrcweir CallCallBackHdl_Impl(); 152*cdf0e10cSrcweir break; 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir default: 155*cdf0e10cSrcweir Edit::KeyInput( rKEvt ); 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir void SvInplaceEdit::StopEditing( sal_Bool bCancel ) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir DBG_CHKTHIS(SvInplaceEdit,0); 162*cdf0e10cSrcweir if ( !bAlreadyInCallBack ) 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir bCanceled = bCancel; 165*cdf0e10cSrcweir CallCallBackHdl_Impl(); 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir void SvInplaceEdit::LoseFocus() 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir DBG_CHKTHIS(SvInplaceEdit,0); 172*cdf0e10cSrcweir if ( !bAlreadyInCallBack ) 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir bCanceled = sal_False; 175*cdf0e10cSrcweir aTimer.SetTimeout(10); 176*cdf0e10cSrcweir aTimer.SetTimeoutHdl(LINK(this,SvInplaceEdit,Timeout_Impl)); 177*cdf0e10cSrcweir aTimer.Start(); 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvInplaceEdit, Timeout_Impl, Timer *, EMPTYARG ) 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir DBG_CHKTHIS(SvInplaceEdit,0); 184*cdf0e10cSrcweir CallCallBackHdl_Impl(); 185*cdf0e10cSrcweir return 0; 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvInplaceEdit, Timeout_Impl, Timer *, EMPTYARG ) 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir void SvInplaceEdit::CallCallBackHdl_Impl() 190*cdf0e10cSrcweir { 191*cdf0e10cSrcweir DBG_CHKTHIS(SvInplaceEdit,0); 192*cdf0e10cSrcweir aTimer.Stop(); 193*cdf0e10cSrcweir if ( !bAlreadyInCallBack ) 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir bAlreadyInCallBack = sal_True; 196*cdf0e10cSrcweir GetpApp()->RemoveAccel( &aAccReturn ); 197*cdf0e10cSrcweir GetpApp()->RemoveAccel( &aAccEscape ); 198*cdf0e10cSrcweir Hide(); 199*cdf0e10cSrcweir aCallBackHdl.Call( this ); 200*cdf0e10cSrcweir // bAlreadyInCallBack = sal_False; 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir // *************************************************************** 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir class MyEdit_Impl : public Edit 208*cdf0e10cSrcweir { 209*cdf0e10cSrcweir SvInplaceEdit2* pOwner; 210*cdf0e10cSrcweir public: 211*cdf0e10cSrcweir MyEdit_Impl( Window* pParent, SvInplaceEdit2* pOwner ); 212*cdf0e10cSrcweir virtual void KeyInput( const KeyEvent& rKEvt ); 213*cdf0e10cSrcweir virtual void LoseFocus(); 214*cdf0e10cSrcweir }; 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir class MyMultiEdit_Impl : public MultiLineEdit 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir SvInplaceEdit2* pOwner; 219*cdf0e10cSrcweir public: 220*cdf0e10cSrcweir MyMultiEdit_Impl( Window* pParent, SvInplaceEdit2* pOwner ); 221*cdf0e10cSrcweir virtual void KeyInput( const KeyEvent& rKEvt ); 222*cdf0e10cSrcweir virtual void LoseFocus(); 223*cdf0e10cSrcweir }; 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir MyEdit_Impl::MyEdit_Impl( Window* pParent, SvInplaceEdit2* _pOwner ) : 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir Edit( pParent, WB_LEFT ), 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir pOwner( _pOwner ) 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir void MyEdit_Impl::KeyInput( const KeyEvent& rKEvt ) 235*cdf0e10cSrcweir { 236*cdf0e10cSrcweir if( !pOwner->KeyInput( rKEvt )) 237*cdf0e10cSrcweir Edit::KeyInput( rKEvt ); 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir void MyEdit_Impl::LoseFocus() 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir pOwner->LoseFocus(); 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir MyMultiEdit_Impl::MyMultiEdit_Impl( Window* pParent, SvInplaceEdit2* _pOwner ) 246*cdf0e10cSrcweir : MultiLineEdit( pParent, 247*cdf0e10cSrcweir WB_CENTER 248*cdf0e10cSrcweir ), pOwner(_pOwner) 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir } 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir void MyMultiEdit_Impl::KeyInput( const KeyEvent& rKEvt ) 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir if( !pOwner->KeyInput( rKEvt )) 255*cdf0e10cSrcweir MultiLineEdit::KeyInput( rKEvt ); 256*cdf0e10cSrcweir } 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir void MyMultiEdit_Impl::LoseFocus() 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir pOwner->LoseFocus(); 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir SvInplaceEdit2::SvInplaceEdit2 265*cdf0e10cSrcweir ( 266*cdf0e10cSrcweir Window* pParent, const Point& rPos, 267*cdf0e10cSrcweir const Size& rSize, 268*cdf0e10cSrcweir const String& rData, 269*cdf0e10cSrcweir const Link& rNotifyEditEnd, 270*cdf0e10cSrcweir const Selection& rSelection, 271*cdf0e10cSrcweir sal_Bool bMulti 272*cdf0e10cSrcweir ) : 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir aCallBackHdl ( rNotifyEditEnd ), 275*cdf0e10cSrcweir bCanceled ( sal_False ), 276*cdf0e10cSrcweir bAlreadyInCallBack ( sal_False ), 277*cdf0e10cSrcweir bMultiLine ( bMulti ) 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir DBG_CTOR(SvInplaceEdit2,0); 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir if( bMulti ) 283*cdf0e10cSrcweir pEdit = new MyMultiEdit_Impl( pParent, this ); 284*cdf0e10cSrcweir else 285*cdf0e10cSrcweir pEdit = new MyEdit_Impl( pParent, this ); 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir Font aFont( pParent->GetFont() ); 288*cdf0e10cSrcweir aFont.SetTransparent( sal_False ); 289*cdf0e10cSrcweir Color aColor( pParent->GetBackground().GetColor() ); 290*cdf0e10cSrcweir aFont.SetFillColor(aColor ); 291*cdf0e10cSrcweir pEdit->SetFont( aFont ); 292*cdf0e10cSrcweir pEdit->SetBackground( pParent->GetBackground() ); 293*cdf0e10cSrcweir pEdit->SetPosPixel( rPos ); 294*cdf0e10cSrcweir pEdit->SetSizePixel( rSize ); 295*cdf0e10cSrcweir pEdit->SetText( rData ); 296*cdf0e10cSrcweir pEdit->SetSelection( rSelection ); 297*cdf0e10cSrcweir pEdit->SaveValue(); 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir aAccReturn.InsertItem( SVLBOX_ACC_RETURN, KeyCode(KEY_RETURN) ); 300*cdf0e10cSrcweir aAccEscape.InsertItem( SVLBOX_ACC_ESCAPE, KeyCode(KEY_ESCAPE) ); 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir aAccReturn.SetActivateHdl( LINK( this, SvInplaceEdit2, ReturnHdl_Impl) ); 303*cdf0e10cSrcweir aAccEscape.SetActivateHdl( LINK( this, SvInplaceEdit2, EscapeHdl_Impl) ); 304*cdf0e10cSrcweir GetpApp()->InsertAccel( &aAccReturn ); 305*cdf0e10cSrcweir GetpApp()->InsertAccel( &aAccEscape ); 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir pEdit->Show(); 308*cdf0e10cSrcweir pEdit->GrabFocus(); 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir SvInplaceEdit2::~SvInplaceEdit2() 312*cdf0e10cSrcweir { 313*cdf0e10cSrcweir DBG_DTOR(SvInplaceEdit2,0); 314*cdf0e10cSrcweir if( !bAlreadyInCallBack ) 315*cdf0e10cSrcweir { 316*cdf0e10cSrcweir GetpApp()->RemoveAccel( &aAccReturn ); 317*cdf0e10cSrcweir GetpApp()->RemoveAccel( &aAccEscape ); 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir delete pEdit; 320*cdf0e10cSrcweir } 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir String SvInplaceEdit2::GetSavedValue() const 323*cdf0e10cSrcweir { 324*cdf0e10cSrcweir return pEdit->GetSavedValue(); 325*cdf0e10cSrcweir } 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir void SvInplaceEdit2::Hide() 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir pEdit->Hide(); 330*cdf0e10cSrcweir } 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvInplaceEdit2, ReturnHdl_Impl, Accelerator *, EMPTYARG ) 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir DBG_CHKTHIS(SvInplaceEdit2,0); 336*cdf0e10cSrcweir bCanceled = sal_False; 337*cdf0e10cSrcweir CallCallBackHdl_Impl(); 338*cdf0e10cSrcweir return 1; 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvInplaceEdit2, ReturnHdl_Impl, Accelerator *, EMPTYARG ) 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvInplaceEdit2, EscapeHdl_Impl, Accelerator *, EMPTYARG ) 343*cdf0e10cSrcweir { 344*cdf0e10cSrcweir DBG_CHKTHIS(SvInplaceEdit2,0); 345*cdf0e10cSrcweir bCanceled = sal_True; 346*cdf0e10cSrcweir CallCallBackHdl_Impl(); 347*cdf0e10cSrcweir return 1; 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvInplaceEdit2, EscapeHdl_Impl, Accelerator *, EMPTYARG ) 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir sal_Bool SvInplaceEdit2::KeyInput( const KeyEvent& rKEvt ) 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir DBG_CHKTHIS(SvInplaceEdit2,0); 355*cdf0e10cSrcweir KeyCode aCode = rKEvt.GetKeyCode(); 356*cdf0e10cSrcweir sal_uInt16 nCode = aCode.GetCode(); 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir switch ( nCode ) 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir case KEY_ESCAPE: 361*cdf0e10cSrcweir bCanceled = sal_True; 362*cdf0e10cSrcweir CallCallBackHdl_Impl(); 363*cdf0e10cSrcweir return sal_True; 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir case KEY_RETURN: 366*cdf0e10cSrcweir bCanceled = sal_False; 367*cdf0e10cSrcweir CallCallBackHdl_Impl(); 368*cdf0e10cSrcweir return sal_True; 369*cdf0e10cSrcweir } 370*cdf0e10cSrcweir return sal_False; 371*cdf0e10cSrcweir } 372*cdf0e10cSrcweir 373*cdf0e10cSrcweir void SvInplaceEdit2::StopEditing( sal_Bool bCancel ) 374*cdf0e10cSrcweir { 375*cdf0e10cSrcweir DBG_CHKTHIS(SvInplaceEdit2,0); 376*cdf0e10cSrcweir if ( !bAlreadyInCallBack ) 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir bCanceled = bCancel; 379*cdf0e10cSrcweir CallCallBackHdl_Impl(); 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir } 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir void SvInplaceEdit2::LoseFocus() 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir DBG_CHKTHIS(SvInplaceEdit2,0); 386*cdf0e10cSrcweir if ( !bAlreadyInCallBack 387*cdf0e10cSrcweir && ((!Application::GetFocusWindow()) || !pEdit->IsChild( Application::GetFocusWindow()) ) 388*cdf0e10cSrcweir ) 389*cdf0e10cSrcweir { 390*cdf0e10cSrcweir bCanceled = sal_False; 391*cdf0e10cSrcweir aTimer.SetTimeout(10); 392*cdf0e10cSrcweir aTimer.SetTimeoutHdl(LINK(this,SvInplaceEdit2,Timeout_Impl)); 393*cdf0e10cSrcweir aTimer.Start(); 394*cdf0e10cSrcweir } 395*cdf0e10cSrcweir } 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvInplaceEdit2, Timeout_Impl, Timer *, EMPTYARG ) 398*cdf0e10cSrcweir { 399*cdf0e10cSrcweir DBG_CHKTHIS(SvInplaceEdit2,0); 400*cdf0e10cSrcweir CallCallBackHdl_Impl(); 401*cdf0e10cSrcweir return 0; 402*cdf0e10cSrcweir } 403*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvInplaceEdit2, Timeout_Impl, Timer *, EMPTYARG ) 404*cdf0e10cSrcweir 405*cdf0e10cSrcweir void SvInplaceEdit2::CallCallBackHdl_Impl() 406*cdf0e10cSrcweir { 407*cdf0e10cSrcweir DBG_CHKTHIS(SvInplaceEdit2,0); 408*cdf0e10cSrcweir aTimer.Stop(); 409*cdf0e10cSrcweir if ( !bAlreadyInCallBack ) 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir bAlreadyInCallBack = sal_True; 412*cdf0e10cSrcweir GetpApp()->RemoveAccel( &aAccReturn ); 413*cdf0e10cSrcweir GetpApp()->RemoveAccel( &aAccEscape ); 414*cdf0e10cSrcweir pEdit->Hide(); 415*cdf0e10cSrcweir aCallBackHdl.Call( this ); 416*cdf0e10cSrcweir } 417*cdf0e10cSrcweir } 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir String SvInplaceEdit2::GetText() const 420*cdf0e10cSrcweir { 421*cdf0e10cSrcweir return pEdit->GetText(); 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir // *************************************************************** 425*cdf0e10cSrcweir // class SvLBoxTab 426*cdf0e10cSrcweir // *************************************************************** 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir DBG_NAME(SvLBoxTab); 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir SvLBoxTab::SvLBoxTab() 431*cdf0e10cSrcweir { 432*cdf0e10cSrcweir DBG_CTOR(SvLBoxTab,0); 433*cdf0e10cSrcweir nPos = 0; 434*cdf0e10cSrcweir pUserData = 0; 435*cdf0e10cSrcweir nFlags = 0; 436*cdf0e10cSrcweir } 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir SvLBoxTab::SvLBoxTab( long nPosition, sal_uInt16 nTabFlags ) 439*cdf0e10cSrcweir { 440*cdf0e10cSrcweir DBG_CTOR(SvLBoxTab,0); 441*cdf0e10cSrcweir nPos = nPosition; 442*cdf0e10cSrcweir pUserData = 0; 443*cdf0e10cSrcweir nFlags = nTabFlags; 444*cdf0e10cSrcweir } 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir SvLBoxTab::SvLBoxTab( const SvLBoxTab& rTab ) 447*cdf0e10cSrcweir { 448*cdf0e10cSrcweir DBG_CTOR(SvLBoxTab,0); 449*cdf0e10cSrcweir nPos = rTab.nPos; 450*cdf0e10cSrcweir pUserData = rTab.pUserData; 451*cdf0e10cSrcweir nFlags = rTab.nFlags; 452*cdf0e10cSrcweir } 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir SvLBoxTab::~SvLBoxTab() 455*cdf0e10cSrcweir { 456*cdf0e10cSrcweir DBG_DTOR(SvLBoxTab,0); 457*cdf0e10cSrcweir } 458*cdf0e10cSrcweir 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir long SvLBoxTab::CalcOffset( long nItemWidth, long nTabWidth ) 461*cdf0e10cSrcweir { 462*cdf0e10cSrcweir DBG_CHKTHIS(SvLBoxTab,0); 463*cdf0e10cSrcweir long nOffset = 0; 464*cdf0e10cSrcweir if ( nFlags & SV_LBOXTAB_ADJUST_RIGHT ) 465*cdf0e10cSrcweir { 466*cdf0e10cSrcweir nOffset = nTabWidth - nItemWidth; 467*cdf0e10cSrcweir if( nOffset < 0 ) 468*cdf0e10cSrcweir nOffset = 0; 469*cdf0e10cSrcweir } 470*cdf0e10cSrcweir else if ( nFlags & SV_LBOXTAB_ADJUST_CENTER ) 471*cdf0e10cSrcweir { 472*cdf0e10cSrcweir if( nFlags & SV_LBOXTAB_FORCE ) 473*cdf0e10cSrcweir { 474*cdf0e10cSrcweir //richtige Implementierung der Zentrierung 475*cdf0e10cSrcweir nOffset = ( nTabWidth - nItemWidth ) / 2; 476*cdf0e10cSrcweir if( nOffset < 0 ) 477*cdf0e10cSrcweir nOffset = 0; 478*cdf0e10cSrcweir } 479*cdf0e10cSrcweir else 480*cdf0e10cSrcweir { 481*cdf0e10cSrcweir // historisch gewachsene falsche Berechnung des Tabs, auf die sich 482*cdf0e10cSrcweir // Abo-Tabbox, Extras/Optionen/Anpassen etc. verlassen 483*cdf0e10cSrcweir nItemWidth++; 484*cdf0e10cSrcweir nOffset = -( nItemWidth / 2 ); 485*cdf0e10cSrcweir } 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir return nOffset; 488*cdf0e10cSrcweir } 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir /* 491*cdf0e10cSrcweir long SvLBoxTab::CalcOffset( const String& rStr, const OutputDevice& rOutDev ) 492*cdf0e10cSrcweir { 493*cdf0e10cSrcweir DBG_CHKTHIS(SvLBoxTab,0); 494*cdf0e10cSrcweir long nWidth; 495*cdf0e10cSrcweir if ( nFlags & SV_LBOXTAB_ADJUST_NUMERIC ) 496*cdf0e10cSrcweir { 497*cdf0e10cSrcweir sal_uInt16 nPos = rStr.Search( '.' ); 498*cdf0e10cSrcweir if ( nPos == STRING_NOTFOUND ) 499*cdf0e10cSrcweir nPos = rStr.Search( ',' ); 500*cdf0e10cSrcweir if ( nPos == STRING_NOTFOUND ) 501*cdf0e10cSrcweir nPos = STRING_LEN; 502*cdf0e10cSrcweir 503*cdf0e10cSrcweir nWidth = rOutDev.GetTextSize( rStr, 0, nPos ).Width(); 504*cdf0e10cSrcweir nWidth *= -1; 505*cdf0e10cSrcweir } 506*cdf0e10cSrcweir else 507*cdf0e10cSrcweir { 508*cdf0e10cSrcweir nWidth = rOutDev.GetTextSize( rStr ).Width(); 509*cdf0e10cSrcweir nWidth = CalcOffset( nWidth ); 510*cdf0e10cSrcweir } 511*cdf0e10cSrcweir return nWidth; 512*cdf0e10cSrcweir } 513*cdf0e10cSrcweir */ 514*cdf0e10cSrcweir 515*cdf0e10cSrcweir // *************************************************************** 516*cdf0e10cSrcweir // class SvLBoxItem 517*cdf0e10cSrcweir // *************************************************************** 518*cdf0e10cSrcweir 519*cdf0e10cSrcweir DBG_NAME(SvLBoxItem); 520*cdf0e10cSrcweir 521*cdf0e10cSrcweir SvLBoxItem::SvLBoxItem( SvLBoxEntry*, sal_uInt16 ) 522*cdf0e10cSrcweir { 523*cdf0e10cSrcweir DBG_CTOR(SvLBoxItem,0); 524*cdf0e10cSrcweir } 525*cdf0e10cSrcweir 526*cdf0e10cSrcweir SvLBoxItem::SvLBoxItem() 527*cdf0e10cSrcweir { 528*cdf0e10cSrcweir DBG_CTOR(SvLBoxItem,0); 529*cdf0e10cSrcweir } 530*cdf0e10cSrcweir 531*cdf0e10cSrcweir SvLBoxItem::~SvLBoxItem() 532*cdf0e10cSrcweir { 533*cdf0e10cSrcweir DBG_DTOR(SvLBoxItem,0); 534*cdf0e10cSrcweir } 535*cdf0e10cSrcweir 536*cdf0e10cSrcweir const Size& SvLBoxItem::GetSize( SvLBox* pView,SvLBoxEntry* pEntry ) 537*cdf0e10cSrcweir { 538*cdf0e10cSrcweir DBG_CHKTHIS(SvLBoxItem,0); 539*cdf0e10cSrcweir SvViewDataItem* pViewData = pView->GetViewDataItem( pEntry, this ); 540*cdf0e10cSrcweir return pViewData->aSize; 541*cdf0e10cSrcweir } 542*cdf0e10cSrcweir 543*cdf0e10cSrcweir const Size& SvLBoxItem::GetSize( SvLBoxEntry* pEntry, SvViewDataEntry* pViewData) 544*cdf0e10cSrcweir { 545*cdf0e10cSrcweir DBG_CHKTHIS(SvLBoxItem,0); 546*cdf0e10cSrcweir sal_uInt16 nItemPos = pEntry->GetPos( this ); 547*cdf0e10cSrcweir SvViewDataItem* pItemData = pViewData->pItemData+nItemPos; 548*cdf0e10cSrcweir return pItemData->aSize; 549*cdf0e10cSrcweir } 550*cdf0e10cSrcweir 551*cdf0e10cSrcweir DBG_NAME(SvViewDataItem); 552*cdf0e10cSrcweir 553*cdf0e10cSrcweir SvViewDataItem::SvViewDataItem() 554*cdf0e10cSrcweir { 555*cdf0e10cSrcweir DBG_CTOR(SvViewDataItem,0); 556*cdf0e10cSrcweir } 557*cdf0e10cSrcweir 558*cdf0e10cSrcweir SvViewDataItem::~SvViewDataItem() 559*cdf0e10cSrcweir { 560*cdf0e10cSrcweir DBG_DTOR(SvViewDataItem,0); 561*cdf0e10cSrcweir } 562*cdf0e10cSrcweir 563*cdf0e10cSrcweir 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir // *************************************************************** 566*cdf0e10cSrcweir // class SvLBoxEntry 567*cdf0e10cSrcweir // *************************************************************** 568*cdf0e10cSrcweir 569*cdf0e10cSrcweir DBG_NAME(SvLBoxEntry); 570*cdf0e10cSrcweir 571*cdf0e10cSrcweir SvLBoxEntry::SvLBoxEntry() : aItems() 572*cdf0e10cSrcweir { 573*cdf0e10cSrcweir DBG_CTOR(SvLBoxEntry,0); 574*cdf0e10cSrcweir nEntryFlags = 0; 575*cdf0e10cSrcweir pUserData = 0; 576*cdf0e10cSrcweir } 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir SvLBoxEntry::~SvLBoxEntry() 579*cdf0e10cSrcweir { 580*cdf0e10cSrcweir DBG_DTOR(SvLBoxEntry,0); 581*cdf0e10cSrcweir DeleteItems_Impl(); 582*cdf0e10cSrcweir } 583*cdf0e10cSrcweir 584*cdf0e10cSrcweir void SvLBoxEntry::DeleteItems_Impl() 585*cdf0e10cSrcweir { 586*cdf0e10cSrcweir DBG_CHKTHIS(SvLBoxEntry,0); 587*cdf0e10cSrcweir sal_uInt16 nCount = aItems.Count(); 588*cdf0e10cSrcweir while( nCount ) 589*cdf0e10cSrcweir { 590*cdf0e10cSrcweir nCount--; 591*cdf0e10cSrcweir SvLBoxItem* pItem = (SvLBoxItem*)aItems.GetObject( nCount ); 592*cdf0e10cSrcweir delete pItem; 593*cdf0e10cSrcweir } 594*cdf0e10cSrcweir aItems.Remove(0, aItems.Count() ); 595*cdf0e10cSrcweir } 596*cdf0e10cSrcweir 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir void SvLBoxEntry::AddItem( SvLBoxItem* pItem ) 599*cdf0e10cSrcweir { 600*cdf0e10cSrcweir DBG_CHKTHIS(SvLBoxEntry,0); 601*cdf0e10cSrcweir aItems.Insert( pItem, aItems.Count() ); 602*cdf0e10cSrcweir } 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir void SvLBoxEntry::Clone( SvListEntry* pSource ) 605*cdf0e10cSrcweir { 606*cdf0e10cSrcweir DBG_CHKTHIS(SvLBoxEntry,0); 607*cdf0e10cSrcweir SvListEntry::Clone( pSource ); 608*cdf0e10cSrcweir SvLBoxItem* pNewItem; 609*cdf0e10cSrcweir DeleteItems_Impl(); 610*cdf0e10cSrcweir sal_uInt16 nCount = ((SvLBoxEntry*)pSource)->ItemCount(); 611*cdf0e10cSrcweir sal_uInt16 nCurPos = 0; 612*cdf0e10cSrcweir while( nCurPos < nCount ) 613*cdf0e10cSrcweir { 614*cdf0e10cSrcweir SvLBoxItem* pItem = ((SvLBoxEntry*)pSource)->GetItem( nCurPos ); 615*cdf0e10cSrcweir pNewItem = pItem->Create(); 616*cdf0e10cSrcweir pNewItem->Clone( pItem ); 617*cdf0e10cSrcweir AddItem( pNewItem ); 618*cdf0e10cSrcweir nCurPos++; 619*cdf0e10cSrcweir } 620*cdf0e10cSrcweir pUserData = ((SvLBoxEntry*)pSource)->GetUserData(); 621*cdf0e10cSrcweir nEntryFlags = ((SvLBoxEntry*)pSource)->nEntryFlags; 622*cdf0e10cSrcweir } 623*cdf0e10cSrcweir 624*cdf0e10cSrcweir void SvLBoxEntry::EnableChildsOnDemand( sal_Bool bEnable ) 625*cdf0e10cSrcweir { 626*cdf0e10cSrcweir DBG_CHKTHIS(SvLBoxEntry,0); 627*cdf0e10cSrcweir if ( bEnable ) 628*cdf0e10cSrcweir nEntryFlags |= SV_ENTRYFLAG_CHILDS_ON_DEMAND; 629*cdf0e10cSrcweir else 630*cdf0e10cSrcweir nEntryFlags &= (~SV_ENTRYFLAG_CHILDS_ON_DEMAND); 631*cdf0e10cSrcweir } 632*cdf0e10cSrcweir 633*cdf0e10cSrcweir void SvLBoxEntry::ReplaceItem( SvLBoxItem* pNewItem, sal_uInt16 nPos ) 634*cdf0e10cSrcweir { 635*cdf0e10cSrcweir DBG_CHKTHIS(SvLBoxEntry,0); 636*cdf0e10cSrcweir DBG_ASSERT(pNewItem,"ReplaceItem:No Item"); 637*cdf0e10cSrcweir SvLBoxItem* pOld = GetItem( nPos ); 638*cdf0e10cSrcweir if ( pOld ) 639*cdf0e10cSrcweir { 640*cdf0e10cSrcweir aItems.Remove( nPos ); 641*cdf0e10cSrcweir aItems.Insert( pNewItem, nPos ); 642*cdf0e10cSrcweir delete pOld; 643*cdf0e10cSrcweir } 644*cdf0e10cSrcweir } 645*cdf0e10cSrcweir 646*cdf0e10cSrcweir SvLBoxItem* SvLBoxEntry::GetFirstItem( sal_uInt16 nId ) 647*cdf0e10cSrcweir { 648*cdf0e10cSrcweir sal_uInt16 nCount = aItems.Count(); 649*cdf0e10cSrcweir sal_uInt16 nCur = 0; 650*cdf0e10cSrcweir SvLBoxItem* pItem; 651*cdf0e10cSrcweir while( nCur < nCount ) 652*cdf0e10cSrcweir { 653*cdf0e10cSrcweir pItem = GetItem( nCur ); 654*cdf0e10cSrcweir if( pItem->IsA() == nId ) 655*cdf0e10cSrcweir return pItem; 656*cdf0e10cSrcweir nCur++; 657*cdf0e10cSrcweir } 658*cdf0e10cSrcweir return 0; 659*cdf0e10cSrcweir } 660*cdf0e10cSrcweir 661*cdf0e10cSrcweir // *************************************************************** 662*cdf0e10cSrcweir // class SvLBoxViewData 663*cdf0e10cSrcweir // *************************************************************** 664*cdf0e10cSrcweir 665*cdf0e10cSrcweir DBG_NAME(SvViewDataEntry); 666*cdf0e10cSrcweir 667*cdf0e10cSrcweir SvViewDataEntry::SvViewDataEntry() 668*cdf0e10cSrcweir : SvViewData() 669*cdf0e10cSrcweir { 670*cdf0e10cSrcweir DBG_CTOR(SvViewDataEntry,0); 671*cdf0e10cSrcweir pItemData = 0; 672*cdf0e10cSrcweir } 673*cdf0e10cSrcweir 674*cdf0e10cSrcweir SvViewDataEntry::~SvViewDataEntry() 675*cdf0e10cSrcweir { 676*cdf0e10cSrcweir DBG_DTOR(SvViewDataEntry,0); 677*cdf0e10cSrcweir delete [] pItemData; 678*cdf0e10cSrcweir } 679*cdf0e10cSrcweir 680*cdf0e10cSrcweir // *************************************************************** 681*cdf0e10cSrcweir // struct SvLBox_Impl 682*cdf0e10cSrcweir // *************************************************************** 683*cdf0e10cSrcweir SvLBox_Impl::SvLBox_Impl( SvLBox& _rBox ) 684*cdf0e10cSrcweir :m_bIsEmptyTextAllowed( true ) 685*cdf0e10cSrcweir ,m_bEntryMnemonicsEnabled( false ) 686*cdf0e10cSrcweir ,m_bDoingQuickSelection( false ) 687*cdf0e10cSrcweir ,m_pLink( NULL ) 688*cdf0e10cSrcweir ,m_aMnemonicEngine( _rBox ) 689*cdf0e10cSrcweir ,m_aQuickSelectionEngine( _rBox ) 690*cdf0e10cSrcweir { 691*cdf0e10cSrcweir } 692*cdf0e10cSrcweir 693*cdf0e10cSrcweir // *************************************************************** 694*cdf0e10cSrcweir // class SvLBox 695*cdf0e10cSrcweir // *************************************************************** 696*cdf0e10cSrcweir 697*cdf0e10cSrcweir DBG_NAME(SvLBox); 698*cdf0e10cSrcweir 699*cdf0e10cSrcweir SvLBox::SvLBox( Window* pParent, WinBits nWinStyle ) : 700*cdf0e10cSrcweir Control( pParent, nWinStyle | WB_CLIPCHILDREN ), 701*cdf0e10cSrcweir DropTargetHelper( this ), DragSourceHelper( this ), eSelMode( NO_SELECTION ) 702*cdf0e10cSrcweir { 703*cdf0e10cSrcweir DBG_CTOR(SvLBox,0); 704*cdf0e10cSrcweir nDragOptions = DND_ACTION_COPYMOVE | DND_ACTION_LINK; 705*cdf0e10cSrcweir nImpFlags = 0; 706*cdf0e10cSrcweir pTargetEntry = 0; 707*cdf0e10cSrcweir nDragDropMode = 0; 708*cdf0e10cSrcweir pLBoxImpl = new SvLBox_Impl( *this ); 709*cdf0e10cSrcweir SvLBoxTreeList* pTempModel = new SvLBoxTreeList; 710*cdf0e10cSrcweir pTempModel->SetRefCount( 0 ); 711*cdf0e10cSrcweir SetModel( pTempModel ); 712*cdf0e10cSrcweir pModel->SetCloneLink( LINK(this, SvLBox, CloneHdl_Impl )); 713*cdf0e10cSrcweir pModel->InsertView( this ); 714*cdf0e10cSrcweir pHdlEntry = 0; 715*cdf0e10cSrcweir pEdCtrl = 0; 716*cdf0e10cSrcweir SetSelectionMode( SINGLE_SELECTION ); // pruefen ob TreeListBox gecallt wird 717*cdf0e10cSrcweir SetDragDropMode( SV_DRAGDROP_NONE ); 718*cdf0e10cSrcweir SetType(WINDOW_TREELISTBOX); 719*cdf0e10cSrcweir } 720*cdf0e10cSrcweir 721*cdf0e10cSrcweir SvLBox::SvLBox( Window* pParent, const ResId& rResId ) : 722*cdf0e10cSrcweir Control( pParent, rResId ), 723*cdf0e10cSrcweir DropTargetHelper( this ), DragSourceHelper( this ), eSelMode( NO_SELECTION ) 724*cdf0e10cSrcweir { 725*cdf0e10cSrcweir DBG_CTOR(SvLBox,0); 726*cdf0e10cSrcweir pTargetEntry = 0; 727*cdf0e10cSrcweir nImpFlags = 0; 728*cdf0e10cSrcweir pLBoxImpl = new SvLBox_Impl( *this ); 729*cdf0e10cSrcweir nDragOptions = DND_ACTION_COPYMOVE | DND_ACTION_LINK; 730*cdf0e10cSrcweir nDragDropMode = 0; 731*cdf0e10cSrcweir SvLBoxTreeList* pTempModel = new SvLBoxTreeList; 732*cdf0e10cSrcweir pTempModel->SetRefCount( 0 ); 733*cdf0e10cSrcweir SetModel( pTempModel ); 734*cdf0e10cSrcweir pModel->InsertView( this ); 735*cdf0e10cSrcweir pHdlEntry = 0; 736*cdf0e10cSrcweir pEdCtrl = 0; 737*cdf0e10cSrcweir pModel->SetCloneLink( LINK(this, SvLBox, CloneHdl_Impl )); 738*cdf0e10cSrcweir SetType(WINDOW_TREELISTBOX); 739*cdf0e10cSrcweir } 740*cdf0e10cSrcweir 741*cdf0e10cSrcweir __EXPORT SvLBox::~SvLBox() 742*cdf0e10cSrcweir { 743*cdf0e10cSrcweir DBG_DTOR(SvLBox,0); 744*cdf0e10cSrcweir delete pEdCtrl; 745*cdf0e10cSrcweir pEdCtrl = 0; 746*cdf0e10cSrcweir pModel->RemoveView( this ); 747*cdf0e10cSrcweir if ( pModel->GetRefCount() == 0 ) 748*cdf0e10cSrcweir { 749*cdf0e10cSrcweir pModel->Clear(); 750*cdf0e10cSrcweir delete pModel; 751*cdf0e10cSrcweir pModel = NULL; 752*cdf0e10cSrcweir } 753*cdf0e10cSrcweir 754*cdf0e10cSrcweir SvLBox::RemoveBoxFromDDList_Impl( *this ); 755*cdf0e10cSrcweir 756*cdf0e10cSrcweir if( this == pDDSource ) 757*cdf0e10cSrcweir pDDSource = 0; 758*cdf0e10cSrcweir if( this == pDDTarget ) 759*cdf0e10cSrcweir pDDTarget = 0; 760*cdf0e10cSrcweir delete pLBoxImpl; 761*cdf0e10cSrcweir } 762*cdf0e10cSrcweir 763*cdf0e10cSrcweir void SvLBox::SetModel( SvLBoxTreeList* pNewModel ) 764*cdf0e10cSrcweir { 765*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 766*cdf0e10cSrcweir // erledigt das ganz CleanUp 767*cdf0e10cSrcweir SvListView::SetModel( pNewModel ); 768*cdf0e10cSrcweir pModel->SetCloneLink( LINK(this, SvLBox, CloneHdl_Impl )); 769*cdf0e10cSrcweir SvLBoxEntry* pEntry = First(); 770*cdf0e10cSrcweir while( pEntry ) 771*cdf0e10cSrcweir { 772*cdf0e10cSrcweir ModelHasInserted( pEntry ); 773*cdf0e10cSrcweir pEntry = Next( pEntry ); 774*cdf0e10cSrcweir } 775*cdf0e10cSrcweir } 776*cdf0e10cSrcweir 777*cdf0e10cSrcweir void SvLBox::DisconnectFromModel() 778*cdf0e10cSrcweir { 779*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 780*cdf0e10cSrcweir SvLBoxTreeList* pNewModel = new SvLBoxTreeList; 781*cdf0e10cSrcweir pNewModel->SetRefCount( 0 ); // else this will never be deleted 782*cdf0e10cSrcweir SvListView::SetModel( pNewModel ); 783*cdf0e10cSrcweir } 784*cdf0e10cSrcweir 785*cdf0e10cSrcweir void SvLBox::Clear() 786*cdf0e10cSrcweir { 787*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 788*cdf0e10cSrcweir pModel->Clear(); // Model ruft SvLBox::ModelHasCleared() auf 789*cdf0e10cSrcweir } 790*cdf0e10cSrcweir 791*cdf0e10cSrcweir void SvLBox::EnableEntryMnemonics( bool _bEnable ) 792*cdf0e10cSrcweir { 793*cdf0e10cSrcweir if ( _bEnable == IsEntryMnemonicsEnabled() ) 794*cdf0e10cSrcweir return; 795*cdf0e10cSrcweir 796*cdf0e10cSrcweir pLBoxImpl->m_bEntryMnemonicsEnabled = _bEnable; 797*cdf0e10cSrcweir Invalidate(); 798*cdf0e10cSrcweir } 799*cdf0e10cSrcweir 800*cdf0e10cSrcweir bool SvLBox::IsEntryMnemonicsEnabled() const 801*cdf0e10cSrcweir { 802*cdf0e10cSrcweir return pLBoxImpl->m_bEntryMnemonicsEnabled; 803*cdf0e10cSrcweir } 804*cdf0e10cSrcweir 805*cdf0e10cSrcweir sal_uInt16 SvLBox::IsA() 806*cdf0e10cSrcweir { 807*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 808*cdf0e10cSrcweir return SVLISTBOX_ID_LBOX; 809*cdf0e10cSrcweir } 810*cdf0e10cSrcweir 811*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvLBox, CloneHdl_Impl, SvListEntry*, pEntry ) 812*cdf0e10cSrcweir { 813*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 814*cdf0e10cSrcweir return (long)(CloneEntry((SvLBoxEntry*)pEntry)); 815*cdf0e10cSrcweir } 816*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvLBox, CloneHdl_Impl, SvListEntry*, pEntry ) 817*cdf0e10cSrcweir 818*cdf0e10cSrcweir sal_uLong SvLBox::Insert( SvLBoxEntry* pEntry, SvLBoxEntry* pParent, sal_uLong nPos ) 819*cdf0e10cSrcweir { 820*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 821*cdf0e10cSrcweir sal_uLong nInsPos = pModel->Insert( pEntry, pParent, nPos ); 822*cdf0e10cSrcweir return nInsPos; 823*cdf0e10cSrcweir } 824*cdf0e10cSrcweir 825*cdf0e10cSrcweir sal_uLong SvLBox::Insert( SvLBoxEntry* pEntry,sal_uLong nRootPos ) 826*cdf0e10cSrcweir { 827*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 828*cdf0e10cSrcweir sal_uLong nInsPos = pModel->Insert( pEntry, nRootPos ); 829*cdf0e10cSrcweir return nInsPos; 830*cdf0e10cSrcweir } 831*cdf0e10cSrcweir 832*cdf0e10cSrcweir long SvLBox::ExpandingHdl() 833*cdf0e10cSrcweir { 834*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 835*cdf0e10cSrcweir return aExpandingHdl.IsSet() ? aExpandingHdl.Call( this ) : 1; 836*cdf0e10cSrcweir } 837*cdf0e10cSrcweir 838*cdf0e10cSrcweir void SvLBox::ExpandedHdl() 839*cdf0e10cSrcweir { 840*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 841*cdf0e10cSrcweir aExpandedHdl.Call( this ); 842*cdf0e10cSrcweir } 843*cdf0e10cSrcweir 844*cdf0e10cSrcweir void SvLBox::SelectHdl() 845*cdf0e10cSrcweir { 846*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 847*cdf0e10cSrcweir aSelectHdl.Call( this ); 848*cdf0e10cSrcweir } 849*cdf0e10cSrcweir 850*cdf0e10cSrcweir void SvLBox::DeselectHdl() 851*cdf0e10cSrcweir { 852*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 853*cdf0e10cSrcweir aDeselectHdl.Call( this ); 854*cdf0e10cSrcweir } 855*cdf0e10cSrcweir 856*cdf0e10cSrcweir sal_Bool SvLBox::DoubleClickHdl() 857*cdf0e10cSrcweir { 858*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 859*cdf0e10cSrcweir aDoubleClickHdl.Call( this ); 860*cdf0e10cSrcweir return sal_True; 861*cdf0e10cSrcweir } 862*cdf0e10cSrcweir 863*cdf0e10cSrcweir 864*cdf0e10cSrcweir sal_Bool SvLBox::CheckDragAndDropMode( SvLBox* pSource, sal_Int8 nAction ) 865*cdf0e10cSrcweir { 866*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 867*cdf0e10cSrcweir if ( pSource == this ) 868*cdf0e10cSrcweir { 869*cdf0e10cSrcweir if ( !(nDragDropMode & (SV_DRAGDROP_CTRL_MOVE | SV_DRAGDROP_CTRL_COPY) ) ) 870*cdf0e10cSrcweir return sal_False; // D&D innerhalb der Liste gesperrt 871*cdf0e10cSrcweir if( DND_ACTION_MOVE == nAction ) 872*cdf0e10cSrcweir { 873*cdf0e10cSrcweir if ( !(nDragDropMode & SV_DRAGDROP_CTRL_MOVE) ) 874*cdf0e10cSrcweir return sal_False; // kein lokales Move 875*cdf0e10cSrcweir } 876*cdf0e10cSrcweir else 877*cdf0e10cSrcweir { 878*cdf0e10cSrcweir if ( !(nDragDropMode & SV_DRAGDROP_CTRL_COPY)) 879*cdf0e10cSrcweir return sal_False; // kein lokales Copy 880*cdf0e10cSrcweir } 881*cdf0e10cSrcweir } 882*cdf0e10cSrcweir else 883*cdf0e10cSrcweir { 884*cdf0e10cSrcweir if ( !(nDragDropMode & SV_DRAGDROP_APP_DROP ) ) 885*cdf0e10cSrcweir return sal_False; // kein Drop 886*cdf0e10cSrcweir if ( DND_ACTION_MOVE == nAction ) 887*cdf0e10cSrcweir { 888*cdf0e10cSrcweir if ( !(nDragDropMode & SV_DRAGDROP_APP_MOVE) ) 889*cdf0e10cSrcweir return sal_False; // kein globales Move 890*cdf0e10cSrcweir } 891*cdf0e10cSrcweir else 892*cdf0e10cSrcweir { 893*cdf0e10cSrcweir if ( !(nDragDropMode & SV_DRAGDROP_APP_COPY)) 894*cdf0e10cSrcweir return sal_False; // kein globales Copy 895*cdf0e10cSrcweir } 896*cdf0e10cSrcweir } 897*cdf0e10cSrcweir return sal_True; 898*cdf0e10cSrcweir } 899*cdf0e10cSrcweir 900*cdf0e10cSrcweir 901*cdf0e10cSrcweir 902*cdf0e10cSrcweir 903*cdf0e10cSrcweir void SvLBox::NotifyRemoving( SvLBoxEntry* ) 904*cdf0e10cSrcweir { 905*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 906*cdf0e10cSrcweir } 907*cdf0e10cSrcweir 908*cdf0e10cSrcweir /* 909*cdf0e10cSrcweir NotifyMoving/Copying 910*cdf0e10cSrcweir ==================== 911*cdf0e10cSrcweir 912*cdf0e10cSrcweir Standard-Verhalten: 913*cdf0e10cSrcweir 914*cdf0e10cSrcweir 1. Target hat keine Childs 915*cdf0e10cSrcweir - Entry wird Sibling des Targets. Entry steht hinter dem 916*cdf0e10cSrcweir Target (->Fenster: Unter dem Target) 917*cdf0e10cSrcweir 2. Target ist ein aufgeklappter Parent 918*cdf0e10cSrcweir - Entry wird an den Anfang der Target-Childlist gehaengt 919*cdf0e10cSrcweir 3. Target ist ein zugeklappter Parent 920*cdf0e10cSrcweir - Entry wird an das Ende der Target-Childlist gehaengt 921*cdf0e10cSrcweir */ 922*cdf0e10cSrcweir #ifdef DBG_UTIL 923*cdf0e10cSrcweir sal_Bool SvLBox::NotifyMoving( 924*cdf0e10cSrcweir SvLBoxEntry* pTarget, // D&D-Drop-Position in this->GetModel() 925*cdf0e10cSrcweir SvLBoxEntry* pEntry, // Zu verschiebender Entry aus 926*cdf0e10cSrcweir // GetSourceListBox()->GetModel() 927*cdf0e10cSrcweir SvLBoxEntry*& rpNewParent, // Neuer Target-Parent 928*cdf0e10cSrcweir sal_uLong& rNewChildPos) // Position in Childlist des Target-Parents 929*cdf0e10cSrcweir #else 930*cdf0e10cSrcweir sal_Bool SvLBox::NotifyMoving( 931*cdf0e10cSrcweir SvLBoxEntry* pTarget, // D&D-Drop-Position in this->GetModel() 932*cdf0e10cSrcweir SvLBoxEntry*, // Zu verschiebender Entry aus 933*cdf0e10cSrcweir // GetSourceListBox()->GetModel() 934*cdf0e10cSrcweir SvLBoxEntry*& rpNewParent, // Neuer Target-Parent 935*cdf0e10cSrcweir sal_uLong& rNewChildPos) // Position in Childlist des Target-Parents 936*cdf0e10cSrcweir #endif 937*cdf0e10cSrcweir { 938*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 939*cdf0e10cSrcweir DBG_ASSERT(pEntry,"NotifyMoving:SoureEntry?"); 940*cdf0e10cSrcweir if( !pTarget ) 941*cdf0e10cSrcweir { 942*cdf0e10cSrcweir rpNewParent = 0; 943*cdf0e10cSrcweir rNewChildPos = 0; 944*cdf0e10cSrcweir return sal_True; 945*cdf0e10cSrcweir } 946*cdf0e10cSrcweir if ( !pTarget->HasChilds() && !pTarget->HasChildsOnDemand() ) 947*cdf0e10cSrcweir { 948*cdf0e10cSrcweir // Fall 1 949*cdf0e10cSrcweir rpNewParent = GetParent( pTarget ); 950*cdf0e10cSrcweir rNewChildPos = pModel->GetRelPos( pTarget ) + 1; 951*cdf0e10cSrcweir rNewChildPos += nCurEntrySelPos; 952*cdf0e10cSrcweir nCurEntrySelPos++; 953*cdf0e10cSrcweir } 954*cdf0e10cSrcweir else 955*cdf0e10cSrcweir { 956*cdf0e10cSrcweir // Faelle 2 & 3 957*cdf0e10cSrcweir rpNewParent = pTarget; 958*cdf0e10cSrcweir if( IsExpanded(pTarget)) 959*cdf0e10cSrcweir rNewChildPos = 0; 960*cdf0e10cSrcweir else 961*cdf0e10cSrcweir rNewChildPos = LIST_APPEND; 962*cdf0e10cSrcweir } 963*cdf0e10cSrcweir return sal_True; 964*cdf0e10cSrcweir } 965*cdf0e10cSrcweir 966*cdf0e10cSrcweir sal_Bool SvLBox::NotifyCopying( 967*cdf0e10cSrcweir SvLBoxEntry* pTarget, // D&D-Drop-Position in this->GetModel() 968*cdf0e10cSrcweir SvLBoxEntry* pEntry, // Zu kopierender Entry aus 969*cdf0e10cSrcweir // GetSourceListBox()->GetModel() 970*cdf0e10cSrcweir SvLBoxEntry*& rpNewParent, // Neuer Target-Parent 971*cdf0e10cSrcweir sal_uLong& rNewChildPos) // Position in Childlist des Target-Parents 972*cdf0e10cSrcweir { 973*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 974*cdf0e10cSrcweir return NotifyMoving(pTarget,pEntry,rpNewParent,rNewChildPos); 975*cdf0e10cSrcweir /* 976*cdf0e10cSrcweir DBG_ASSERT(pEntry,"NotifyCopying:SourceEntry?"); 977*cdf0e10cSrcweir if( !pTarget ) 978*cdf0e10cSrcweir { 979*cdf0e10cSrcweir rpNewParent = 0; 980*cdf0e10cSrcweir rNewChildPos = 0; 981*cdf0e10cSrcweir return sal_True; 982*cdf0e10cSrcweir } 983*cdf0e10cSrcweir if ( !pTarget->HasChilds() && !pTarget->HasChildsOnDemand() ) 984*cdf0e10cSrcweir { 985*cdf0e10cSrcweir // Fall 1 986*cdf0e10cSrcweir rpNewParent = GetParent( pTarget ); 987*cdf0e10cSrcweir rNewChildPos = GetRelPos( pTarget ) + 1; 988*cdf0e10cSrcweir } 989*cdf0e10cSrcweir else 990*cdf0e10cSrcweir { 991*cdf0e10cSrcweir // Faelle 2 & 3 992*cdf0e10cSrcweir rpNewParent = pTarget; 993*cdf0e10cSrcweir if( IsExpanded(pTarget)) 994*cdf0e10cSrcweir rNewChildPos = 0; 995*cdf0e10cSrcweir else 996*cdf0e10cSrcweir rNewChildPos = LIST_APPEND; 997*cdf0e10cSrcweir } 998*cdf0e10cSrcweir return sal_True; 999*cdf0e10cSrcweir */ 1000*cdf0e10cSrcweir } 1001*cdf0e10cSrcweir 1002*cdf0e10cSrcweir SvLBoxEntry* SvLBox::CloneEntry( SvLBoxEntry* pSource ) 1003*cdf0e10cSrcweir { 1004*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1005*cdf0e10cSrcweir SvLBoxEntry* pEntry = (SvLBoxEntry*)CreateEntry(); // new SvLBoxEntry; 1006*cdf0e10cSrcweir pEntry->Clone( (SvListEntry*)pSource ); 1007*cdf0e10cSrcweir return pEntry; 1008*cdf0e10cSrcweir } 1009*cdf0e10cSrcweir 1010*cdf0e10cSrcweir 1011*cdf0e10cSrcweir // Rueckgabe: Alle Entries wurden kopiert 1012*cdf0e10cSrcweir sal_Bool SvLBox::CopySelection( SvLBox* pSource, SvLBoxEntry* pTarget ) 1013*cdf0e10cSrcweir { 1014*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1015*cdf0e10cSrcweir nCurEntrySelPos = 0; // Selektionszaehler fuer NotifyMoving/Copying 1016*cdf0e10cSrcweir sal_Bool bSuccess = sal_True; 1017*cdf0e10cSrcweir SvTreeEntryList aList; 1018*cdf0e10cSrcweir sal_Bool bClone = (sal_Bool)( (sal_uLong)(pSource->GetModel()) != (sal_uLong)GetModel() ); 1019*cdf0e10cSrcweir Link aCloneLink( pModel->GetCloneLink() ); 1020*cdf0e10cSrcweir pModel->SetCloneLink( LINK(this, SvLBox, CloneHdl_Impl )); 1021*cdf0e10cSrcweir 1022*cdf0e10cSrcweir // Selektion zwischenspeichern, um bei D&D-Austausch 1023*cdf0e10cSrcweir // innerhalb der gleichen Listbox das Iterieren ueber 1024*cdf0e10cSrcweir // die Selektion zu vereinfachen 1025*cdf0e10cSrcweir SvLBoxEntry* pSourceEntry = pSource->FirstSelected(); 1026*cdf0e10cSrcweir while ( pSourceEntry ) 1027*cdf0e10cSrcweir { 1028*cdf0e10cSrcweir // Childs werden automatisch mitkopiert 1029*cdf0e10cSrcweir pSource->SelectChilds( pSourceEntry, sal_False ); 1030*cdf0e10cSrcweir aList.Insert( pSourceEntry, LIST_APPEND ); 1031*cdf0e10cSrcweir pSourceEntry = pSource->NextSelected( pSourceEntry ); 1032*cdf0e10cSrcweir } 1033*cdf0e10cSrcweir 1034*cdf0e10cSrcweir pSourceEntry = (SvLBoxEntry*)aList.First(); 1035*cdf0e10cSrcweir while ( pSourceEntry ) 1036*cdf0e10cSrcweir { 1037*cdf0e10cSrcweir SvLBoxEntry* pNewParent = 0; 1038*cdf0e10cSrcweir sal_uLong nInsertionPos = LIST_APPEND; 1039*cdf0e10cSrcweir sal_Bool bOk=NotifyCopying(pTarget,pSourceEntry,pNewParent,nInsertionPos); 1040*cdf0e10cSrcweir if ( bOk ) 1041*cdf0e10cSrcweir { 1042*cdf0e10cSrcweir if ( bClone ) 1043*cdf0e10cSrcweir { 1044*cdf0e10cSrcweir sal_uLong nCloneCount = 0; 1045*cdf0e10cSrcweir pSourceEntry = (SvLBoxEntry*) 1046*cdf0e10cSrcweir pModel->Clone( (SvListEntry*)pSourceEntry, nCloneCount ); 1047*cdf0e10cSrcweir pModel->InsertTree( (SvListEntry*)pSourceEntry, 1048*cdf0e10cSrcweir (SvListEntry*)pNewParent, nInsertionPos ); 1049*cdf0e10cSrcweir } 1050*cdf0e10cSrcweir else 1051*cdf0e10cSrcweir { 1052*cdf0e10cSrcweir sal_uLong nListPos = pModel->Copy( (SvListEntry*)pSourceEntry, 1053*cdf0e10cSrcweir (SvListEntry*)pNewParent, nInsertionPos ); 1054*cdf0e10cSrcweir pSourceEntry = GetEntry( pNewParent, nListPos ); 1055*cdf0e10cSrcweir } 1056*cdf0e10cSrcweir } 1057*cdf0e10cSrcweir else 1058*cdf0e10cSrcweir bSuccess = sal_False; 1059*cdf0e10cSrcweir 1060*cdf0e10cSrcweir if( bOk == (sal_Bool)2 ) // !!!HACK verschobenen Entry sichtbar machen? 1061*cdf0e10cSrcweir MakeVisible( pSourceEntry ); 1062*cdf0e10cSrcweir 1063*cdf0e10cSrcweir pSourceEntry = (SvLBoxEntry*)aList.Next(); 1064*cdf0e10cSrcweir } 1065*cdf0e10cSrcweir pModel->SetCloneLink( aCloneLink ); 1066*cdf0e10cSrcweir return bSuccess; 1067*cdf0e10cSrcweir } 1068*cdf0e10cSrcweir 1069*cdf0e10cSrcweir // Rueckgabe: Alle Entries wurden verschoben 1070*cdf0e10cSrcweir sal_Bool SvLBox::MoveSelection( SvLBox* pSource, SvLBoxEntry* pTarget ) 1071*cdf0e10cSrcweir { 1072*cdf0e10cSrcweir return MoveSelectionCopyFallbackPossible( pSource, pTarget, sal_False ); 1073*cdf0e10cSrcweir } 1074*cdf0e10cSrcweir 1075*cdf0e10cSrcweir sal_Bool SvLBox::MoveSelectionCopyFallbackPossible( SvLBox* pSource, SvLBoxEntry* pTarget, sal_Bool bAllowCopyFallback ) 1076*cdf0e10cSrcweir { 1077*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1078*cdf0e10cSrcweir nCurEntrySelPos = 0; // Selektionszaehler fuer NotifyMoving/Copying 1079*cdf0e10cSrcweir sal_Bool bSuccess = sal_True; 1080*cdf0e10cSrcweir SvTreeEntryList aList; 1081*cdf0e10cSrcweir sal_Bool bClone = (sal_Bool)( (sal_uLong)(pSource->GetModel()) != (sal_uLong)GetModel() ); 1082*cdf0e10cSrcweir Link aCloneLink( pModel->GetCloneLink() ); 1083*cdf0e10cSrcweir if ( bClone ) 1084*cdf0e10cSrcweir pModel->SetCloneLink( LINK(this, SvLBox, CloneHdl_Impl )); 1085*cdf0e10cSrcweir 1086*cdf0e10cSrcweir SvLBoxEntry* pSourceEntry = pSource->FirstSelected(); 1087*cdf0e10cSrcweir while ( pSourceEntry ) 1088*cdf0e10cSrcweir { 1089*cdf0e10cSrcweir // Childs werden automatisch mitbewegt 1090*cdf0e10cSrcweir pSource->SelectChilds( pSourceEntry, sal_False ); 1091*cdf0e10cSrcweir aList.Insert( pSourceEntry, LIST_APPEND ); 1092*cdf0e10cSrcweir pSourceEntry = pSource->NextSelected( pSourceEntry ); 1093*cdf0e10cSrcweir } 1094*cdf0e10cSrcweir 1095*cdf0e10cSrcweir pSourceEntry = (SvLBoxEntry*)aList.First(); 1096*cdf0e10cSrcweir while ( pSourceEntry ) 1097*cdf0e10cSrcweir { 1098*cdf0e10cSrcweir SvLBoxEntry* pNewParent = 0; 1099*cdf0e10cSrcweir sal_uLong nInsertionPos = LIST_APPEND; 1100*cdf0e10cSrcweir sal_Bool bOk = NotifyMoving(pTarget,pSourceEntry,pNewParent,nInsertionPos); 1101*cdf0e10cSrcweir sal_Bool bCopyOk = bOk; 1102*cdf0e10cSrcweir if ( !bOk && bAllowCopyFallback ) 1103*cdf0e10cSrcweir { 1104*cdf0e10cSrcweir nInsertionPos = LIST_APPEND; 1105*cdf0e10cSrcweir bCopyOk = NotifyCopying(pTarget,pSourceEntry,pNewParent,nInsertionPos); 1106*cdf0e10cSrcweir } 1107*cdf0e10cSrcweir 1108*cdf0e10cSrcweir if ( bOk || bCopyOk ) 1109*cdf0e10cSrcweir { 1110*cdf0e10cSrcweir if ( bClone ) 1111*cdf0e10cSrcweir { 1112*cdf0e10cSrcweir sal_uLong nCloneCount = 0; 1113*cdf0e10cSrcweir pSourceEntry = (SvLBoxEntry*) 1114*cdf0e10cSrcweir pModel->Clone( (SvListEntry*)pSourceEntry, nCloneCount ); 1115*cdf0e10cSrcweir pModel->InsertTree( (SvListEntry*)pSourceEntry, 1116*cdf0e10cSrcweir (SvListEntry*)pNewParent, nInsertionPos ); 1117*cdf0e10cSrcweir } 1118*cdf0e10cSrcweir else 1119*cdf0e10cSrcweir { 1120*cdf0e10cSrcweir if ( bOk ) 1121*cdf0e10cSrcweir pModel->Move( (SvListEntry*)pSourceEntry, 1122*cdf0e10cSrcweir (SvListEntry*)pNewParent, nInsertionPos ); 1123*cdf0e10cSrcweir else 1124*cdf0e10cSrcweir pModel->Copy( (SvListEntry*)pSourceEntry, 1125*cdf0e10cSrcweir (SvListEntry*)pNewParent, nInsertionPos ); 1126*cdf0e10cSrcweir } 1127*cdf0e10cSrcweir } 1128*cdf0e10cSrcweir else 1129*cdf0e10cSrcweir bSuccess = sal_False; 1130*cdf0e10cSrcweir 1131*cdf0e10cSrcweir if( bOk == (sal_Bool)2 ) // !!!HACK verschobenen Entry sichtbar machen? 1132*cdf0e10cSrcweir MakeVisible( pSourceEntry ); 1133*cdf0e10cSrcweir 1134*cdf0e10cSrcweir pSourceEntry = (SvLBoxEntry*)aList.Next(); 1135*cdf0e10cSrcweir } 1136*cdf0e10cSrcweir pModel->SetCloneLink( aCloneLink ); 1137*cdf0e10cSrcweir return bSuccess; 1138*cdf0e10cSrcweir } 1139*cdf0e10cSrcweir 1140*cdf0e10cSrcweir void SvLBox::RemoveSelection() 1141*cdf0e10cSrcweir { 1142*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1143*cdf0e10cSrcweir SvTreeEntryList aList; 1144*cdf0e10cSrcweir // Selektion zwischenspeichern, da die Impl bei 1145*cdf0e10cSrcweir // dem ersten Remove alles deselektiert! 1146*cdf0e10cSrcweir SvLBoxEntry* pEntry = FirstSelected(); 1147*cdf0e10cSrcweir while ( pEntry ) 1148*cdf0e10cSrcweir { 1149*cdf0e10cSrcweir aList.Insert( pEntry ); 1150*cdf0e10cSrcweir if ( pEntry->HasChilds() ) 1151*cdf0e10cSrcweir // Remove loescht Childs automatisch 1152*cdf0e10cSrcweir SelectChilds( pEntry, sal_False ); 1153*cdf0e10cSrcweir pEntry = NextSelected( pEntry ); 1154*cdf0e10cSrcweir } 1155*cdf0e10cSrcweir pEntry = (SvLBoxEntry*)aList.First(); 1156*cdf0e10cSrcweir while ( pEntry ) 1157*cdf0e10cSrcweir { 1158*cdf0e10cSrcweir pModel->Remove( pEntry ); 1159*cdf0e10cSrcweir pEntry = (SvLBoxEntry*)aList.Next(); 1160*cdf0e10cSrcweir } 1161*cdf0e10cSrcweir } 1162*cdf0e10cSrcweir 1163*cdf0e10cSrcweir SvLBox* SvLBox::GetSourceView() const 1164*cdf0e10cSrcweir { 1165*cdf0e10cSrcweir return pDDSource; 1166*cdf0e10cSrcweir } 1167*cdf0e10cSrcweir 1168*cdf0e10cSrcweir SvLBox* SvLBox::GetTargetView() const 1169*cdf0e10cSrcweir { 1170*cdf0e10cSrcweir return pDDTarget; 1171*cdf0e10cSrcweir } 1172*cdf0e10cSrcweir 1173*cdf0e10cSrcweir void SvLBox::RequestingChilds( SvLBoxEntry* ) 1174*cdf0e10cSrcweir { 1175*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1176*cdf0e10cSrcweir DBG_ERROR("Child-Request-Hdl not implemented!"); 1177*cdf0e10cSrcweir } 1178*cdf0e10cSrcweir 1179*cdf0e10cSrcweir void SvLBox::RecalcViewData() 1180*cdf0e10cSrcweir { 1181*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1182*cdf0e10cSrcweir SvLBoxEntry* pEntry = First(); 1183*cdf0e10cSrcweir while( pEntry ) 1184*cdf0e10cSrcweir { 1185*cdf0e10cSrcweir sal_uInt16 nCount = pEntry->ItemCount(); 1186*cdf0e10cSrcweir sal_uInt16 nCurPos = 0; 1187*cdf0e10cSrcweir while ( nCurPos < nCount ) 1188*cdf0e10cSrcweir { 1189*cdf0e10cSrcweir SvLBoxItem* pItem = pEntry->GetItem( nCurPos ); 1190*cdf0e10cSrcweir pItem->InitViewData( this, pEntry ); 1191*cdf0e10cSrcweir nCurPos++; 1192*cdf0e10cSrcweir } 1193*cdf0e10cSrcweir ViewDataInitialized( pEntry ); 1194*cdf0e10cSrcweir pEntry = Next( pEntry ); 1195*cdf0e10cSrcweir } 1196*cdf0e10cSrcweir } 1197*cdf0e10cSrcweir 1198*cdf0e10cSrcweir void SvLBox::ViewDataInitialized( SvLBoxEntry* ) 1199*cdf0e10cSrcweir { 1200*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1201*cdf0e10cSrcweir } 1202*cdf0e10cSrcweir 1203*cdf0e10cSrcweir void SvLBox::StateChanged( StateChangedType eType ) 1204*cdf0e10cSrcweir { 1205*cdf0e10cSrcweir if( eType == STATE_CHANGE_ENABLE ) 1206*cdf0e10cSrcweir Invalidate( INVALIDATE_CHILDREN ); 1207*cdf0e10cSrcweir Control::StateChanged( eType ); 1208*cdf0e10cSrcweir } 1209*cdf0e10cSrcweir 1210*cdf0e10cSrcweir void SvLBox::ImplShowTargetEmphasis( SvLBoxEntry* pEntry, sal_Bool bShow) 1211*cdf0e10cSrcweir { 1212*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1213*cdf0e10cSrcweir if ( bShow && (nImpFlags & SVLBOX_TARGEMPH_VIS) ) 1214*cdf0e10cSrcweir return; 1215*cdf0e10cSrcweir if ( !bShow && !(nImpFlags & SVLBOX_TARGEMPH_VIS) ) 1216*cdf0e10cSrcweir return; 1217*cdf0e10cSrcweir ShowTargetEmphasis( pEntry, bShow ); 1218*cdf0e10cSrcweir if( bShow ) 1219*cdf0e10cSrcweir nImpFlags |= SVLBOX_TARGEMPH_VIS; 1220*cdf0e10cSrcweir else 1221*cdf0e10cSrcweir nImpFlags &= ~SVLBOX_TARGEMPH_VIS; 1222*cdf0e10cSrcweir } 1223*cdf0e10cSrcweir 1224*cdf0e10cSrcweir void SvLBox::ShowTargetEmphasis( SvLBoxEntry*, sal_Bool /* bShow */ ) 1225*cdf0e10cSrcweir { 1226*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1227*cdf0e10cSrcweir } 1228*cdf0e10cSrcweir 1229*cdf0e10cSrcweir 1230*cdf0e10cSrcweir sal_Bool SvLBox::Expand( SvLBoxEntry* ) 1231*cdf0e10cSrcweir { 1232*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1233*cdf0e10cSrcweir return sal_True; 1234*cdf0e10cSrcweir } 1235*cdf0e10cSrcweir 1236*cdf0e10cSrcweir sal_Bool SvLBox::Collapse( SvLBoxEntry* ) 1237*cdf0e10cSrcweir { 1238*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1239*cdf0e10cSrcweir return sal_True; 1240*cdf0e10cSrcweir } 1241*cdf0e10cSrcweir 1242*cdf0e10cSrcweir sal_Bool SvLBox::Select( SvLBoxEntry*, sal_Bool ) 1243*cdf0e10cSrcweir { 1244*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1245*cdf0e10cSrcweir return sal_False; 1246*cdf0e10cSrcweir } 1247*cdf0e10cSrcweir 1248*cdf0e10cSrcweir sal_uLong SvLBox::SelectChilds( SvLBoxEntry* , sal_Bool ) 1249*cdf0e10cSrcweir { 1250*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1251*cdf0e10cSrcweir return 0; 1252*cdf0e10cSrcweir } 1253*cdf0e10cSrcweir 1254*cdf0e10cSrcweir void SvLBox::OnCurrentEntryChanged() 1255*cdf0e10cSrcweir { 1256*cdf0e10cSrcweir if ( !pLBoxImpl->m_bDoingQuickSelection ) 1257*cdf0e10cSrcweir pLBoxImpl->m_aQuickSelectionEngine.Reset(); 1258*cdf0e10cSrcweir } 1259*cdf0e10cSrcweir 1260*cdf0e10cSrcweir void SvLBox::SelectAll( sal_Bool /* bSelect */ , sal_Bool /* bPaint */ ) 1261*cdf0e10cSrcweir { 1262*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1263*cdf0e10cSrcweir } 1264*cdf0e10cSrcweir 1265*cdf0e10cSrcweir SvLBoxEntry* SvLBox::GetEntryFromPath( const ::std::deque< sal_Int32 >& _rPath ) const 1266*cdf0e10cSrcweir { 1267*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1268*cdf0e10cSrcweir 1269*cdf0e10cSrcweir SvLBoxEntry* pEntry = NULL; 1270*cdf0e10cSrcweir SvLBoxEntry* pParent = NULL; 1271*cdf0e10cSrcweir for( ::std::deque< sal_Int32 >::const_iterator pItem = _rPath.begin(); pItem != _rPath.end(); ++pItem ) 1272*cdf0e10cSrcweir { 1273*cdf0e10cSrcweir pEntry = GetEntry( pParent, *pItem ); 1274*cdf0e10cSrcweir if ( !pEntry ) 1275*cdf0e10cSrcweir break; 1276*cdf0e10cSrcweir pParent = pEntry; 1277*cdf0e10cSrcweir } 1278*cdf0e10cSrcweir 1279*cdf0e10cSrcweir return pEntry; 1280*cdf0e10cSrcweir } 1281*cdf0e10cSrcweir 1282*cdf0e10cSrcweir void SvLBox::FillEntryPath( SvLBoxEntry* pEntry, ::std::deque< sal_Int32 >& _rPath ) const 1283*cdf0e10cSrcweir { 1284*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1285*cdf0e10cSrcweir 1286*cdf0e10cSrcweir if ( pEntry ) 1287*cdf0e10cSrcweir { 1288*cdf0e10cSrcweir SvLBoxEntry* pParentEntry = GetParent( pEntry ); 1289*cdf0e10cSrcweir while ( sal_True ) 1290*cdf0e10cSrcweir { 1291*cdf0e10cSrcweir sal_uLong i, nCount = GetLevelChildCount( pParentEntry ); 1292*cdf0e10cSrcweir for ( i = 0; i < nCount; ++i ) 1293*cdf0e10cSrcweir { 1294*cdf0e10cSrcweir SvLBoxEntry* pTemp = GetEntry( pParentEntry, i ); 1295*cdf0e10cSrcweir DBG_ASSERT( pEntry, "invalid entry" ); 1296*cdf0e10cSrcweir if ( pEntry == pTemp ) 1297*cdf0e10cSrcweir { 1298*cdf0e10cSrcweir _rPath.push_front( (sal_Int32)i ); 1299*cdf0e10cSrcweir break; 1300*cdf0e10cSrcweir } 1301*cdf0e10cSrcweir } 1302*cdf0e10cSrcweir 1303*cdf0e10cSrcweir if ( pParentEntry ) 1304*cdf0e10cSrcweir { 1305*cdf0e10cSrcweir pEntry = pParentEntry; 1306*cdf0e10cSrcweir pParentEntry = GetParent( pParentEntry ); 1307*cdf0e10cSrcweir } 1308*cdf0e10cSrcweir else 1309*cdf0e10cSrcweir break; 1310*cdf0e10cSrcweir } 1311*cdf0e10cSrcweir } 1312*cdf0e10cSrcweir } 1313*cdf0e10cSrcweir 1314*cdf0e10cSrcweir String SvLBox::GetEntryText( SvLBoxEntry* ) const 1315*cdf0e10cSrcweir { 1316*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1317*cdf0e10cSrcweir 1318*cdf0e10cSrcweir return String(); 1319*cdf0e10cSrcweir } 1320*cdf0e10cSrcweir 1321*cdf0e10cSrcweir sal_uLong SvLBox::GetLevelChildCount( SvLBoxEntry* _pParent ) const 1322*cdf0e10cSrcweir { 1323*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1324*cdf0e10cSrcweir 1325*cdf0e10cSrcweir sal_uLong nCount = 0; 1326*cdf0e10cSrcweir SvLBoxEntry* pEntry = FirstChild( _pParent ); 1327*cdf0e10cSrcweir while ( pEntry ) 1328*cdf0e10cSrcweir { 1329*cdf0e10cSrcweir ++nCount; 1330*cdf0e10cSrcweir pEntry = NextSibling( pEntry ); 1331*cdf0e10cSrcweir } 1332*cdf0e10cSrcweir 1333*cdf0e10cSrcweir return nCount; 1334*cdf0e10cSrcweir } 1335*cdf0e10cSrcweir 1336*cdf0e10cSrcweir void SvLBox::SetSelectionMode( SelectionMode eSelectMode ) 1337*cdf0e10cSrcweir { 1338*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1339*cdf0e10cSrcweir eSelMode = eSelectMode; 1340*cdf0e10cSrcweir } 1341*cdf0e10cSrcweir 1342*cdf0e10cSrcweir void SvLBox::SetDragDropMode( DragDropMode nDDMode ) 1343*cdf0e10cSrcweir { 1344*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1345*cdf0e10cSrcweir nDragDropMode = nDDMode; 1346*cdf0e10cSrcweir } 1347*cdf0e10cSrcweir 1348*cdf0e10cSrcweir SvViewData* SvLBox::CreateViewData( SvListEntry* ) 1349*cdf0e10cSrcweir { 1350*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1351*cdf0e10cSrcweir SvViewDataEntry* pEntryData = new SvViewDataEntry; 1352*cdf0e10cSrcweir return (SvViewData*)pEntryData; 1353*cdf0e10cSrcweir } 1354*cdf0e10cSrcweir 1355*cdf0e10cSrcweir void SvLBox::InitViewData( SvViewData* pData, SvListEntry* pEntry ) 1356*cdf0e10cSrcweir { 1357*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1358*cdf0e10cSrcweir SvLBoxEntry* pInhEntry = (SvLBoxEntry*)pEntry; 1359*cdf0e10cSrcweir SvViewDataEntry* pEntryData = (SvViewDataEntry*)pData; 1360*cdf0e10cSrcweir 1361*cdf0e10cSrcweir pEntryData->pItemData = new SvViewDataItem[ pInhEntry->ItemCount() ]; 1362*cdf0e10cSrcweir SvViewDataItem* pItemData = pEntryData->pItemData; 1363*cdf0e10cSrcweir pEntryData->nItmCnt = pInhEntry->ItemCount(); // Anzahl Items fuer delete 1364*cdf0e10cSrcweir sal_uInt16 nCount = pInhEntry->ItemCount(); 1365*cdf0e10cSrcweir sal_uInt16 nCurPos = 0; 1366*cdf0e10cSrcweir while( nCurPos < nCount ) 1367*cdf0e10cSrcweir { 1368*cdf0e10cSrcweir SvLBoxItem* pItem = pInhEntry->GetItem( nCurPos ); 1369*cdf0e10cSrcweir pItem->InitViewData( this, pInhEntry, pItemData ); 1370*cdf0e10cSrcweir pItemData++; 1371*cdf0e10cSrcweir nCurPos++; 1372*cdf0e10cSrcweir } 1373*cdf0e10cSrcweir } 1374*cdf0e10cSrcweir 1375*cdf0e10cSrcweir 1376*cdf0e10cSrcweir 1377*cdf0e10cSrcweir void SvLBox::EnableSelectionAsDropTarget( sal_Bool bEnable, sal_Bool bWithChilds ) 1378*cdf0e10cSrcweir { 1379*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1380*cdf0e10cSrcweir sal_uInt16 nRefDepth; 1381*cdf0e10cSrcweir SvLBoxEntry* pTemp; 1382*cdf0e10cSrcweir 1383*cdf0e10cSrcweir SvLBoxEntry* pSelEntry = FirstSelected(); 1384*cdf0e10cSrcweir while( pSelEntry ) 1385*cdf0e10cSrcweir { 1386*cdf0e10cSrcweir if ( !bEnable ) 1387*cdf0e10cSrcweir { 1388*cdf0e10cSrcweir pSelEntry->nEntryFlags |= SV_ENTRYFLAG_DISABLE_DROP; 1389*cdf0e10cSrcweir if ( bWithChilds ) 1390*cdf0e10cSrcweir { 1391*cdf0e10cSrcweir nRefDepth = pModel->GetDepth( pSelEntry ); 1392*cdf0e10cSrcweir pTemp = Next( pSelEntry ); 1393*cdf0e10cSrcweir while( pTemp && pModel->GetDepth( pTemp ) > nRefDepth ) 1394*cdf0e10cSrcweir { 1395*cdf0e10cSrcweir pTemp->nEntryFlags |= SV_ENTRYFLAG_DISABLE_DROP; 1396*cdf0e10cSrcweir pTemp = Next( pTemp ); 1397*cdf0e10cSrcweir } 1398*cdf0e10cSrcweir } 1399*cdf0e10cSrcweir } 1400*cdf0e10cSrcweir else 1401*cdf0e10cSrcweir { 1402*cdf0e10cSrcweir pSelEntry->nEntryFlags &= (~SV_ENTRYFLAG_DISABLE_DROP); 1403*cdf0e10cSrcweir if ( bWithChilds ) 1404*cdf0e10cSrcweir { 1405*cdf0e10cSrcweir nRefDepth = pModel->GetDepth( pSelEntry ); 1406*cdf0e10cSrcweir pTemp = Next( pSelEntry ); 1407*cdf0e10cSrcweir while( pTemp && pModel->GetDepth( pTemp ) > nRefDepth ) 1408*cdf0e10cSrcweir { 1409*cdf0e10cSrcweir pTemp->nEntryFlags &= (~SV_ENTRYFLAG_DISABLE_DROP); 1410*cdf0e10cSrcweir pTemp = Next( pTemp ); 1411*cdf0e10cSrcweir } 1412*cdf0e10cSrcweir } 1413*cdf0e10cSrcweir } 1414*cdf0e10cSrcweir pSelEntry = NextSelected( pSelEntry ); 1415*cdf0e10cSrcweir } 1416*cdf0e10cSrcweir } 1417*cdf0e10cSrcweir 1418*cdf0e10cSrcweir SvLBoxEntry* SvLBox::GetDropTarget( const Point& ) 1419*cdf0e10cSrcweir { 1420*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1421*cdf0e10cSrcweir return 0; 1422*cdf0e10cSrcweir } 1423*cdf0e10cSrcweir 1424*cdf0e10cSrcweir // ****************************************************************** 1425*cdf0e10cSrcweir // InplaceEditing 1426*cdf0e10cSrcweir // ****************************************************************** 1427*cdf0e10cSrcweir 1428*cdf0e10cSrcweir void SvLBox::EditText( const String& rStr, const Rectangle& rRect, 1429*cdf0e10cSrcweir const Selection& rSel ) 1430*cdf0e10cSrcweir { 1431*cdf0e10cSrcweir EditText( rStr, rRect, rSel, sal_False ); 1432*cdf0e10cSrcweir } 1433*cdf0e10cSrcweir 1434*cdf0e10cSrcweir void SvLBox::EditText( const String& rStr, const Rectangle& rRect, 1435*cdf0e10cSrcweir const Selection& rSel, sal_Bool bMulti ) 1436*cdf0e10cSrcweir { 1437*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1438*cdf0e10cSrcweir if( pEdCtrl ) 1439*cdf0e10cSrcweir delete pEdCtrl; 1440*cdf0e10cSrcweir nImpFlags |= SVLBOX_IN_EDT; 1441*cdf0e10cSrcweir nImpFlags &= ~SVLBOX_EDTEND_CALLED; 1442*cdf0e10cSrcweir HideFocus(); 1443*cdf0e10cSrcweir pEdCtrl = new SvInplaceEdit2( 1444*cdf0e10cSrcweir this, rRect.TopLeft(), rRect.GetSize(), rStr, 1445*cdf0e10cSrcweir LINK( this, SvLBox, TextEditEndedHdl_Impl ), 1446*cdf0e10cSrcweir rSel, bMulti ); 1447*cdf0e10cSrcweir } 1448*cdf0e10cSrcweir 1449*cdf0e10cSrcweir IMPL_LINK( SvLBox, TextEditEndedHdl_Impl, SvInplaceEdit2 *, EMPTYARG ) 1450*cdf0e10cSrcweir { 1451*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1452*cdf0e10cSrcweir if ( nImpFlags & SVLBOX_EDTEND_CALLED ) // Nesting verhindern 1453*cdf0e10cSrcweir return 0; 1454*cdf0e10cSrcweir nImpFlags |= SVLBOX_EDTEND_CALLED; 1455*cdf0e10cSrcweir String aStr; 1456*cdf0e10cSrcweir if ( !pEdCtrl->EditingCanceled() ) 1457*cdf0e10cSrcweir aStr = pEdCtrl->GetText(); 1458*cdf0e10cSrcweir else 1459*cdf0e10cSrcweir aStr = pEdCtrl->GetSavedValue(); 1460*cdf0e10cSrcweir if ( IsEmptyTextAllowed() || aStr.Len() > 0 ) 1461*cdf0e10cSrcweir EditedText( aStr ); 1462*cdf0e10cSrcweir // Hide darf erst gerufen werden, nachdem der neue Text in den 1463*cdf0e10cSrcweir // Entry gesetzt wurde, damit im GetFocus der ListBox nicht 1464*cdf0e10cSrcweir // der Selecthandler mit dem alten EntryText gerufen wird. 1465*cdf0e10cSrcweir pEdCtrl->Hide(); 1466*cdf0e10cSrcweir // delete pEdCtrl; 1467*cdf0e10cSrcweir // pEdCtrl = 0; 1468*cdf0e10cSrcweir nImpFlags &= (~SVLBOX_IN_EDT); 1469*cdf0e10cSrcweir GrabFocus(); 1470*cdf0e10cSrcweir return 0; 1471*cdf0e10cSrcweir } 1472*cdf0e10cSrcweir 1473*cdf0e10cSrcweir void SvLBox::CancelTextEditing() 1474*cdf0e10cSrcweir { 1475*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1476*cdf0e10cSrcweir if ( pEdCtrl ) 1477*cdf0e10cSrcweir pEdCtrl->StopEditing( sal_True ); 1478*cdf0e10cSrcweir nImpFlags &= (~SVLBOX_IN_EDT); 1479*cdf0e10cSrcweir } 1480*cdf0e10cSrcweir 1481*cdf0e10cSrcweir void SvLBox::EndEditing( sal_Bool bCancel ) 1482*cdf0e10cSrcweir { 1483*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1484*cdf0e10cSrcweir if( pEdCtrl ) 1485*cdf0e10cSrcweir pEdCtrl->StopEditing( bCancel ); 1486*cdf0e10cSrcweir nImpFlags &= (~SVLBOX_IN_EDT); 1487*cdf0e10cSrcweir } 1488*cdf0e10cSrcweir 1489*cdf0e10cSrcweir 1490*cdf0e10cSrcweir bool SvLBox::IsEmptyTextAllowed() const 1491*cdf0e10cSrcweir { 1492*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1493*cdf0e10cSrcweir return pLBoxImpl->m_bIsEmptyTextAllowed; 1494*cdf0e10cSrcweir } 1495*cdf0e10cSrcweir 1496*cdf0e10cSrcweir void SvLBox::ForbidEmptyText() 1497*cdf0e10cSrcweir { 1498*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1499*cdf0e10cSrcweir pLBoxImpl->m_bIsEmptyTextAllowed = false; 1500*cdf0e10cSrcweir } 1501*cdf0e10cSrcweir 1502*cdf0e10cSrcweir void SvLBox::EditedText( const String& ) 1503*cdf0e10cSrcweir { 1504*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1505*cdf0e10cSrcweir } 1506*cdf0e10cSrcweir 1507*cdf0e10cSrcweir void SvLBox::EditingRequest( SvLBoxEntry*, SvLBoxItem*,const Point& ) 1508*cdf0e10cSrcweir { 1509*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1510*cdf0e10cSrcweir } 1511*cdf0e10cSrcweir 1512*cdf0e10cSrcweir 1513*cdf0e10cSrcweir SvLBoxEntry* SvLBox::CreateEntry() const 1514*cdf0e10cSrcweir { 1515*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1516*cdf0e10cSrcweir return new SvLBoxEntry; 1517*cdf0e10cSrcweir } 1518*cdf0e10cSrcweir 1519*cdf0e10cSrcweir void SvLBox::MakeVisible( SvLBoxEntry* ) 1520*cdf0e10cSrcweir { 1521*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1522*cdf0e10cSrcweir } 1523*cdf0e10cSrcweir 1524*cdf0e10cSrcweir void SvLBox::Command( const CommandEvent& i_rCommandEvent ) 1525*cdf0e10cSrcweir { 1526*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1527*cdf0e10cSrcweir 1528*cdf0e10cSrcweir if ( COMMAND_STARTDRAG == i_rCommandEvent.GetCommand() ) 1529*cdf0e10cSrcweir { 1530*cdf0e10cSrcweir Point aEventPos( i_rCommandEvent.GetMousePosPixel() ); 1531*cdf0e10cSrcweir MouseEvent aMouseEvt( aEventPos, 1, MOUSE_SELECT, MOUSE_LEFT ); 1532*cdf0e10cSrcweir MouseButtonUp( aMouseEvt ); 1533*cdf0e10cSrcweir } 1534*cdf0e10cSrcweir Control::Command( i_rCommandEvent ); 1535*cdf0e10cSrcweir } 1536*cdf0e10cSrcweir 1537*cdf0e10cSrcweir void SvLBox::KeyInput( const KeyEvent& rKEvt ) 1538*cdf0e10cSrcweir { 1539*cdf0e10cSrcweir bool bHandled = HandleKeyInput( rKEvt ); 1540*cdf0e10cSrcweir if ( !bHandled ) 1541*cdf0e10cSrcweir Control::KeyInput( rKEvt ); 1542*cdf0e10cSrcweir } 1543*cdf0e10cSrcweir 1544*cdf0e10cSrcweir const void* SvLBox::FirstSearchEntry( String& _rEntryText ) const 1545*cdf0e10cSrcweir { 1546*cdf0e10cSrcweir SvLBoxEntry* pEntry = GetCurEntry(); 1547*cdf0e10cSrcweir if ( pEntry ) 1548*cdf0e10cSrcweir pEntry = const_cast< SvLBoxEntry* >( static_cast< const SvLBoxEntry* >( NextSearchEntry( pEntry, _rEntryText ) ) ); 1549*cdf0e10cSrcweir else 1550*cdf0e10cSrcweir { 1551*cdf0e10cSrcweir pEntry = FirstSelected(); 1552*cdf0e10cSrcweir if ( !pEntry ) 1553*cdf0e10cSrcweir pEntry = First(); 1554*cdf0e10cSrcweir } 1555*cdf0e10cSrcweir 1556*cdf0e10cSrcweir if ( pEntry ) 1557*cdf0e10cSrcweir _rEntryText = GetEntryText( pEntry ); 1558*cdf0e10cSrcweir 1559*cdf0e10cSrcweir return pEntry; 1560*cdf0e10cSrcweir } 1561*cdf0e10cSrcweir 1562*cdf0e10cSrcweir const void* SvLBox::NextSearchEntry( const void* _pCurrentSearchEntry, String& _rEntryText ) const 1563*cdf0e10cSrcweir { 1564*cdf0e10cSrcweir SvLBoxEntry* pEntry = const_cast< SvLBoxEntry* >( static_cast< const SvLBoxEntry* >( _pCurrentSearchEntry ) ); 1565*cdf0e10cSrcweir 1566*cdf0e10cSrcweir if ( ( ( GetChildCount( pEntry ) > 0 ) 1567*cdf0e10cSrcweir || ( pEntry->HasChildsOnDemand() ) 1568*cdf0e10cSrcweir ) 1569*cdf0e10cSrcweir && !IsExpanded( pEntry ) 1570*cdf0e10cSrcweir ) 1571*cdf0e10cSrcweir { 1572*cdf0e10cSrcweir pEntry = NextSibling( pEntry ); 1573*cdf0e10cSrcweir } 1574*cdf0e10cSrcweir else 1575*cdf0e10cSrcweir { 1576*cdf0e10cSrcweir pEntry = Next( pEntry ); 1577*cdf0e10cSrcweir } 1578*cdf0e10cSrcweir 1579*cdf0e10cSrcweir if ( !pEntry ) 1580*cdf0e10cSrcweir pEntry = First(); 1581*cdf0e10cSrcweir 1582*cdf0e10cSrcweir if ( pEntry ) 1583*cdf0e10cSrcweir _rEntryText = GetEntryText( pEntry ); 1584*cdf0e10cSrcweir 1585*cdf0e10cSrcweir return pEntry; 1586*cdf0e10cSrcweir } 1587*cdf0e10cSrcweir 1588*cdf0e10cSrcweir void SvLBox::SelectSearchEntry( const void* _pEntry ) 1589*cdf0e10cSrcweir { 1590*cdf0e10cSrcweir SvLBoxEntry* pEntry = const_cast< SvLBoxEntry* >( static_cast< const SvLBoxEntry* >( _pEntry ) ); 1591*cdf0e10cSrcweir DBG_ASSERT( pEntry, "SvLBox::SelectSearchEntry: invalid entry!" ); 1592*cdf0e10cSrcweir if ( !pEntry ) 1593*cdf0e10cSrcweir return; 1594*cdf0e10cSrcweir 1595*cdf0e10cSrcweir SelectAll( sal_False ); 1596*cdf0e10cSrcweir SetCurEntry( pEntry ); 1597*cdf0e10cSrcweir Select( pEntry ); 1598*cdf0e10cSrcweir } 1599*cdf0e10cSrcweir 1600*cdf0e10cSrcweir void SvLBox::ExecuteSearchEntry( const void* /*_pEntry*/ ) const 1601*cdf0e10cSrcweir { 1602*cdf0e10cSrcweir // nothing to do here, we have no "execution" 1603*cdf0e10cSrcweir } 1604*cdf0e10cSrcweir 1605*cdf0e10cSrcweir ::vcl::StringEntryIdentifier SvLBox::CurrentEntry( String& _out_entryText ) const 1606*cdf0e10cSrcweir { 1607*cdf0e10cSrcweir // always accept the current entry if there is one 1608*cdf0e10cSrcweir SvLBoxEntry* pCurrentEntry( GetCurEntry() ); 1609*cdf0e10cSrcweir if ( pCurrentEntry ) 1610*cdf0e10cSrcweir { 1611*cdf0e10cSrcweir _out_entryText = GetEntryText( pCurrentEntry ); 1612*cdf0e10cSrcweir return pCurrentEntry; 1613*cdf0e10cSrcweir } 1614*cdf0e10cSrcweir return FirstSearchEntry( _out_entryText ); 1615*cdf0e10cSrcweir } 1616*cdf0e10cSrcweir 1617*cdf0e10cSrcweir ::vcl::StringEntryIdentifier SvLBox::NextEntry( ::vcl::StringEntryIdentifier _currentEntry, String& _out_entryText ) const 1618*cdf0e10cSrcweir { 1619*cdf0e10cSrcweir return NextSearchEntry( _currentEntry, _out_entryText ); 1620*cdf0e10cSrcweir } 1621*cdf0e10cSrcweir 1622*cdf0e10cSrcweir void SvLBox::SelectEntry( ::vcl::StringEntryIdentifier _entry ) 1623*cdf0e10cSrcweir { 1624*cdf0e10cSrcweir SelectSearchEntry( _entry ); 1625*cdf0e10cSrcweir } 1626*cdf0e10cSrcweir 1627*cdf0e10cSrcweir bool SvLBox::HandleKeyInput( const KeyEvent& _rKEvt ) 1628*cdf0e10cSrcweir { 1629*cdf0e10cSrcweir if ( IsEntryMnemonicsEnabled() 1630*cdf0e10cSrcweir && pLBoxImpl->m_aMnemonicEngine.HandleKeyEvent( _rKEvt ) 1631*cdf0e10cSrcweir ) 1632*cdf0e10cSrcweir return true; 1633*cdf0e10cSrcweir 1634*cdf0e10cSrcweir if ( ( GetStyle() & WB_QUICK_SEARCH ) != 0 ) 1635*cdf0e10cSrcweir { 1636*cdf0e10cSrcweir pLBoxImpl->m_bDoingQuickSelection = true; 1637*cdf0e10cSrcweir const bool bHandled = pLBoxImpl->m_aQuickSelectionEngine.HandleKeyEvent( _rKEvt ); 1638*cdf0e10cSrcweir pLBoxImpl->m_bDoingQuickSelection = false; 1639*cdf0e10cSrcweir if ( bHandled ) 1640*cdf0e10cSrcweir return true; 1641*cdf0e10cSrcweir } 1642*cdf0e10cSrcweir 1643*cdf0e10cSrcweir return false; 1644*cdf0e10cSrcweir } 1645*cdf0e10cSrcweir 1646*cdf0e10cSrcweir SvLBoxEntry* SvLBox::GetEntry( const Point&, sal_Bool ) const 1647*cdf0e10cSrcweir { 1648*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1649*cdf0e10cSrcweir return 0; 1650*cdf0e10cSrcweir } 1651*cdf0e10cSrcweir 1652*cdf0e10cSrcweir void SvLBox::ModelHasEntryInvalidated( SvListEntry* pEntry ) 1653*cdf0e10cSrcweir { 1654*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1655*cdf0e10cSrcweir sal_uInt16 nCount = ((SvLBoxEntry*)pEntry)->ItemCount(); 1656*cdf0e10cSrcweir for( sal_uInt16 nIdx = 0; nIdx < nCount; nIdx++ ) 1657*cdf0e10cSrcweir { 1658*cdf0e10cSrcweir SvLBoxItem* pItem = ((SvLBoxEntry*)pEntry)->GetItem( nIdx ); 1659*cdf0e10cSrcweir pItem->InitViewData( this, (SvLBoxEntry*)pEntry, 0 ); 1660*cdf0e10cSrcweir } 1661*cdf0e10cSrcweir } 1662*cdf0e10cSrcweir 1663*cdf0e10cSrcweir void SvLBox::SetInUseEmphasis( SvLBoxEntry* pEntry, sal_Bool bInUse ) 1664*cdf0e10cSrcweir { 1665*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1666*cdf0e10cSrcweir DBG_ASSERT(pEntry,"SetInUseEmphasis:No Entry"); 1667*cdf0e10cSrcweir if( bInUse ) 1668*cdf0e10cSrcweir { 1669*cdf0e10cSrcweir if( !pEntry->HasInUseEmphasis() ) 1670*cdf0e10cSrcweir { 1671*cdf0e10cSrcweir pEntry->nEntryFlags |= SV_ENTRYFLAG_IN_USE; 1672*cdf0e10cSrcweir pModel->InvalidateEntry( pEntry ); 1673*cdf0e10cSrcweir } 1674*cdf0e10cSrcweir } 1675*cdf0e10cSrcweir else 1676*cdf0e10cSrcweir { 1677*cdf0e10cSrcweir if( pEntry->HasInUseEmphasis() ) 1678*cdf0e10cSrcweir { 1679*cdf0e10cSrcweir pEntry->nEntryFlags &= (~SV_ENTRYFLAG_IN_USE); 1680*cdf0e10cSrcweir pModel->InvalidateEntry( pEntry ); 1681*cdf0e10cSrcweir } 1682*cdf0e10cSrcweir } 1683*cdf0e10cSrcweir } 1684*cdf0e10cSrcweir 1685*cdf0e10cSrcweir void SvLBox::SetCursorEmphasis( SvLBoxEntry* pEntry, sal_Bool bCursored ) 1686*cdf0e10cSrcweir { 1687*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1688*cdf0e10cSrcweir DBG_ASSERT(pEntry,"SetInUseEmphasis:No Entry"); 1689*cdf0e10cSrcweir SvViewDataEntry* pViewData = GetViewDataEntry( pEntry ); 1690*cdf0e10cSrcweir if( pViewData && (bCursored != pViewData->IsCursored()) ) 1691*cdf0e10cSrcweir { 1692*cdf0e10cSrcweir pViewData->SetCursored( bCursored ); 1693*cdf0e10cSrcweir // paintet in allen Views 1694*cdf0e10cSrcweir // pModel->InvalidateEntry( pEntry ); 1695*cdf0e10cSrcweir // invalidiert nur in dieser View 1696*cdf0e10cSrcweir ModelHasEntryInvalidated( pEntry ); 1697*cdf0e10cSrcweir } 1698*cdf0e10cSrcweir } 1699*cdf0e10cSrcweir 1700*cdf0e10cSrcweir sal_Bool SvLBox::HasCursorEmphasis( SvLBoxEntry* pEntry ) const 1701*cdf0e10cSrcweir { 1702*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1703*cdf0e10cSrcweir DBG_ASSERT(pEntry,"SetInUseEmphasis:No Entry"); 1704*cdf0e10cSrcweir SvViewDataEntry* pViewData = GetViewDataEntry( pEntry ); 1705*cdf0e10cSrcweir DBG_ASSERT(pViewData,"Entry not in View"); 1706*cdf0e10cSrcweir return pViewData->IsCursored(); 1707*cdf0e10cSrcweir } 1708*cdf0e10cSrcweir 1709*cdf0e10cSrcweir void SvLBox::WriteDragServerInfo( const Point&, SvLBoxDDInfo* ) 1710*cdf0e10cSrcweir { 1711*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1712*cdf0e10cSrcweir } 1713*cdf0e10cSrcweir 1714*cdf0e10cSrcweir void SvLBox::ReadDragServerInfo(const Point&, SvLBoxDDInfo* ) 1715*cdf0e10cSrcweir { 1716*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1717*cdf0e10cSrcweir } 1718*cdf0e10cSrcweir 1719*cdf0e10cSrcweir sal_Bool SvLBox::EditingCanceled() const 1720*cdf0e10cSrcweir { 1721*cdf0e10cSrcweir if( pEdCtrl && pEdCtrl->EditingCanceled() ) 1722*cdf0e10cSrcweir return sal_True; 1723*cdf0e10cSrcweir return sal_False; 1724*cdf0e10cSrcweir } 1725*cdf0e10cSrcweir 1726*cdf0e10cSrcweir 1727*cdf0e10cSrcweir //JP 28.3.2001: new Drag & Drop API 1728*cdf0e10cSrcweir sal_Int8 SvLBox::AcceptDrop( const AcceptDropEvent& rEvt ) 1729*cdf0e10cSrcweir { 1730*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1731*cdf0e10cSrcweir sal_Int8 nRet = DND_ACTION_NONE; 1732*cdf0e10cSrcweir 1733*cdf0e10cSrcweir if( rEvt.mbLeaving || !CheckDragAndDropMode( pDDSource, rEvt.mnAction ) ) 1734*cdf0e10cSrcweir { 1735*cdf0e10cSrcweir ImplShowTargetEmphasis( pTargetEntry, sal_False ); 1736*cdf0e10cSrcweir } 1737*cdf0e10cSrcweir else if( !nDragDropMode ) 1738*cdf0e10cSrcweir { 1739*cdf0e10cSrcweir DBG_ERRORFILE( "SvLBox::QueryDrop(): no target" ); 1740*cdf0e10cSrcweir } 1741*cdf0e10cSrcweir else 1742*cdf0e10cSrcweir { 1743*cdf0e10cSrcweir SvLBoxEntry* pEntry = GetDropTarget( rEvt.maPosPixel ); 1744*cdf0e10cSrcweir if( !IsDropFormatSupported( SOT_FORMATSTR_ID_TREELISTBOX ) ) 1745*cdf0e10cSrcweir { 1746*cdf0e10cSrcweir DBG_ERRORFILE( "SvLBox::QueryDrop(): no format" ); 1747*cdf0e10cSrcweir } 1748*cdf0e10cSrcweir else 1749*cdf0e10cSrcweir { 1750*cdf0e10cSrcweir DBG_ASSERT( pDDSource, "SvLBox::QueryDrop(): SourceBox == 0 (__EXPORT?)" ); 1751*cdf0e10cSrcweir if( !( pEntry && pDDSource->GetModel() == this->GetModel() 1752*cdf0e10cSrcweir && DND_ACTION_MOVE == rEvt.mnAction 1753*cdf0e10cSrcweir && ( pEntry->nEntryFlags & SV_ENTRYFLAG_DISABLE_DROP ) )) 1754*cdf0e10cSrcweir { 1755*cdf0e10cSrcweir if( NotifyAcceptDrop( pEntry )) 1756*cdf0e10cSrcweir nRet = rEvt.mnAction; 1757*cdf0e10cSrcweir } 1758*cdf0e10cSrcweir } 1759*cdf0e10cSrcweir 1760*cdf0e10cSrcweir // **** Emphasis zeichnen **** 1761*cdf0e10cSrcweir if( DND_ACTION_NONE == nRet ) 1762*cdf0e10cSrcweir ImplShowTargetEmphasis( pTargetEntry, sal_False ); 1763*cdf0e10cSrcweir else if( pEntry != pTargetEntry || !(nImpFlags & SVLBOX_TARGEMPH_VIS) ) 1764*cdf0e10cSrcweir { 1765*cdf0e10cSrcweir ImplShowTargetEmphasis( pTargetEntry, sal_False ); 1766*cdf0e10cSrcweir pTargetEntry = pEntry; 1767*cdf0e10cSrcweir ImplShowTargetEmphasis( pTargetEntry, sal_True ); 1768*cdf0e10cSrcweir } 1769*cdf0e10cSrcweir } 1770*cdf0e10cSrcweir return nRet; 1771*cdf0e10cSrcweir } 1772*cdf0e10cSrcweir 1773*cdf0e10cSrcweir sal_Int8 SvLBox::ExecuteDrop( const ExecuteDropEvent& rEvt, SvLBox* pSourceView ) 1774*cdf0e10cSrcweir { 1775*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1776*cdf0e10cSrcweir sal_Int8 nRet = DND_ACTION_NONE; 1777*cdf0e10cSrcweir 1778*cdf0e10cSrcweir DBG_ASSERT( pSourceView, "SvLBox::ExecuteDrop(): no source view" ); 1779*cdf0e10cSrcweir pSourceView->EnableSelectionAsDropTarget( sal_True, sal_True ); 1780*cdf0e10cSrcweir 1781*cdf0e10cSrcweir ImplShowTargetEmphasis( pTargetEntry, sal_False ); 1782*cdf0e10cSrcweir pDDTarget = this; 1783*cdf0e10cSrcweir 1784*cdf0e10cSrcweir SvLBoxDDInfo aDDInfo; 1785*cdf0e10cSrcweir 1786*cdf0e10cSrcweir TransferableDataHelper aData( rEvt.maDropEvent.Transferable ); 1787*cdf0e10cSrcweir if( aData.HasFormat( SOT_FORMATSTR_ID_TREELISTBOX )) 1788*cdf0e10cSrcweir { 1789*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< sal_Int8 > aSeq; 1790*cdf0e10cSrcweir if( aData.GetSequence( SOT_FORMATSTR_ID_TREELISTBOX, aSeq ) && 1791*cdf0e10cSrcweir sizeof(SvLBoxDDInfo) == aSeq.getLength() ) 1792*cdf0e10cSrcweir { 1793*cdf0e10cSrcweir memcpy( &aDDInfo, aSeq.getConstArray(), sizeof(SvLBoxDDInfo) ); 1794*cdf0e10cSrcweir nRet = rEvt.mnAction; 1795*cdf0e10cSrcweir } 1796*cdf0e10cSrcweir } 1797*cdf0e10cSrcweir 1798*cdf0e10cSrcweir if( DND_ACTION_NONE != nRet ) 1799*cdf0e10cSrcweir { 1800*cdf0e10cSrcweir nRet = DND_ACTION_NONE; 1801*cdf0e10cSrcweir 1802*cdf0e10cSrcweir ReadDragServerInfo( rEvt.maPosPixel, &aDDInfo ); 1803*cdf0e10cSrcweir 1804*cdf0e10cSrcweir SvLBoxEntry* pTarget = pTargetEntry; // !!! kann 0 sein !!! 1805*cdf0e10cSrcweir 1806*cdf0e10cSrcweir if( DND_ACTION_COPY == rEvt.mnAction ) 1807*cdf0e10cSrcweir { 1808*cdf0e10cSrcweir if ( CopySelection( aDDInfo.pSource, pTarget ) ) 1809*cdf0e10cSrcweir nRet = rEvt.mnAction; 1810*cdf0e10cSrcweir } 1811*cdf0e10cSrcweir else if( DND_ACTION_MOVE == rEvt.mnAction ) 1812*cdf0e10cSrcweir { 1813*cdf0e10cSrcweir if ( MoveSelection( aDDInfo.pSource, pTarget ) ) 1814*cdf0e10cSrcweir nRet = rEvt.mnAction; 1815*cdf0e10cSrcweir } 1816*cdf0e10cSrcweir else if( DND_ACTION_COPYMOVE == rEvt.mnAction ) 1817*cdf0e10cSrcweir { 1818*cdf0e10cSrcweir if ( MoveSelectionCopyFallbackPossible( aDDInfo.pSource, pTarget, sal_True ) ) 1819*cdf0e10cSrcweir nRet = rEvt.mnAction; 1820*cdf0e10cSrcweir } 1821*cdf0e10cSrcweir } 1822*cdf0e10cSrcweir return nRet; 1823*cdf0e10cSrcweir } 1824*cdf0e10cSrcweir 1825*cdf0e10cSrcweir sal_Int8 SvLBox::ExecuteDrop( const ExecuteDropEvent& rEvt ) 1826*cdf0e10cSrcweir { 1827*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1828*cdf0e10cSrcweir return ExecuteDrop( rEvt, GetSourceView() ); 1829*cdf0e10cSrcweir } 1830*cdf0e10cSrcweir 1831*cdf0e10cSrcweir void SvLBox::StartDrag( sal_Int8, const Point& rPosPixel ) 1832*cdf0e10cSrcweir { 1833*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1834*cdf0e10cSrcweir 1835*cdf0e10cSrcweir Point aEventPos( rPosPixel ); 1836*cdf0e10cSrcweir MouseEvent aMouseEvt( aEventPos, 1, MOUSE_SELECT, MOUSE_LEFT ); 1837*cdf0e10cSrcweir MouseButtonUp( aMouseEvt ); 1838*cdf0e10cSrcweir 1839*cdf0e10cSrcweir nOldDragMode = GetDragDropMode(); 1840*cdf0e10cSrcweir if ( !nOldDragMode ) 1841*cdf0e10cSrcweir return; 1842*cdf0e10cSrcweir 1843*cdf0e10cSrcweir ReleaseMouse(); 1844*cdf0e10cSrcweir 1845*cdf0e10cSrcweir SvLBoxEntry* pEntry = GetEntry( rPosPixel ); // GetDropTarget( rPos ); 1846*cdf0e10cSrcweir if( !pEntry ) 1847*cdf0e10cSrcweir { 1848*cdf0e10cSrcweir DragFinished( DND_ACTION_NONE ); 1849*cdf0e10cSrcweir return; 1850*cdf0e10cSrcweir } 1851*cdf0e10cSrcweir 1852*cdf0e10cSrcweir TransferDataContainer* pContainer = new TransferDataContainer; 1853*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 1854*cdf0e10cSrcweir ::com::sun::star::datatransfer::XTransferable > xRef( pContainer ); 1855*cdf0e10cSrcweir 1856*cdf0e10cSrcweir nDragDropMode = NotifyStartDrag( *pContainer, pEntry ); 1857*cdf0e10cSrcweir if( !nDragDropMode || 0 == GetSelectionCount() ) 1858*cdf0e10cSrcweir { 1859*cdf0e10cSrcweir nDragDropMode = nOldDragMode; 1860*cdf0e10cSrcweir DragFinished( DND_ACTION_NONE ); 1861*cdf0e10cSrcweir return; 1862*cdf0e10cSrcweir } 1863*cdf0e10cSrcweir 1864*cdf0e10cSrcweir SvLBoxDDInfo aDDInfo; 1865*cdf0e10cSrcweir memset(&aDDInfo,0,sizeof(SvLBoxDDInfo)); 1866*cdf0e10cSrcweir aDDInfo.pApp = GetpApp(); 1867*cdf0e10cSrcweir aDDInfo.pSource = this; 1868*cdf0e10cSrcweir aDDInfo.pDDStartEntry = pEntry; 1869*cdf0e10cSrcweir // abgeleitete Views zum Zuge kommen lassen 1870*cdf0e10cSrcweir WriteDragServerInfo( rPosPixel, &aDDInfo ); 1871*cdf0e10cSrcweir 1872*cdf0e10cSrcweir pContainer->CopyAnyData( SOT_FORMATSTR_ID_TREELISTBOX, 1873*cdf0e10cSrcweir (sal_Char*)&aDDInfo, sizeof(SvLBoxDDInfo) ); 1874*cdf0e10cSrcweir pDDSource = this; 1875*cdf0e10cSrcweir pDDTarget = 0; 1876*cdf0e10cSrcweir 1877*cdf0e10cSrcweir sal_Bool bOldUpdateMode = Control::IsUpdateMode(); 1878*cdf0e10cSrcweir Control::SetUpdateMode( sal_True ); 1879*cdf0e10cSrcweir Update(); 1880*cdf0e10cSrcweir Control::SetUpdateMode( bOldUpdateMode ); 1881*cdf0e10cSrcweir 1882*cdf0e10cSrcweir // Selektion & deren Childs im Model als DropTargets sperren 1883*cdf0e10cSrcweir // Wichtig: Wenn im DropHandler die Selektion der 1884*cdf0e10cSrcweir // SourceListBox veraendert wird, muessen vorher die Eintraege 1885*cdf0e10cSrcweir // als DropTargets wieder freigeschaltet werden: 1886*cdf0e10cSrcweir // (GetSourceListBox()->EnableSelectionAsDropTarget( sal_True, sal_True );) 1887*cdf0e10cSrcweir EnableSelectionAsDropTarget( sal_False, sal_True /* with Childs */ ); 1888*cdf0e10cSrcweir 1889*cdf0e10cSrcweir pContainer->StartDrag( this, nDragOptions, GetDragFinishedHdl() ); 1890*cdf0e10cSrcweir } 1891*cdf0e10cSrcweir 1892*cdf0e10cSrcweir void SvLBox::DragFinished( sal_Int8 1893*cdf0e10cSrcweir #ifndef UNX 1894*cdf0e10cSrcweir nAction 1895*cdf0e10cSrcweir #endif 1896*cdf0e10cSrcweir ) 1897*cdf0e10cSrcweir { 1898*cdf0e10cSrcweir EnableSelectionAsDropTarget( sal_True, sal_True ); 1899*cdf0e10cSrcweir 1900*cdf0e10cSrcweir #ifndef UNX 1901*cdf0e10cSrcweir if( (nAction == DND_ACTION_MOVE) && ( (pDDTarget && 1902*cdf0e10cSrcweir ((sal_uLong)(pDDTarget->GetModel())!=(sal_uLong)(this->GetModel()))) || 1903*cdf0e10cSrcweir !pDDTarget )) 1904*cdf0e10cSrcweir { 1905*cdf0e10cSrcweir RemoveSelection(); 1906*cdf0e10cSrcweir } 1907*cdf0e10cSrcweir #endif 1908*cdf0e10cSrcweir 1909*cdf0e10cSrcweir ImplShowTargetEmphasis( pTargetEntry, sal_False ); 1910*cdf0e10cSrcweir pDDSource = 0; 1911*cdf0e10cSrcweir pDDTarget = 0; 1912*cdf0e10cSrcweir pTargetEntry = 0; 1913*cdf0e10cSrcweir nDragDropMode = nOldDragMode; 1914*cdf0e10cSrcweir } 1915*cdf0e10cSrcweir 1916*cdf0e10cSrcweir DragDropMode SvLBox::NotifyStartDrag( TransferDataContainer&, SvLBoxEntry* ) 1917*cdf0e10cSrcweir { 1918*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1919*cdf0e10cSrcweir return (DragDropMode)0xffff; 1920*cdf0e10cSrcweir } 1921*cdf0e10cSrcweir 1922*cdf0e10cSrcweir sal_Bool SvLBox::NotifyAcceptDrop( SvLBoxEntry* ) 1923*cdf0e10cSrcweir { 1924*cdf0e10cSrcweir DBG_CHKTHIS(SvLBox,0); 1925*cdf0e10cSrcweir return sal_True; 1926*cdf0e10cSrcweir } 1927*cdf0e10cSrcweir 1928*cdf0e10cSrcweir // handler and methods for Drag - finished handler. 1929*cdf0e10cSrcweir // The with get GetDragFinishedHdl() get link can set on the 1930*cdf0e10cSrcweir // TransferDataContainer. This link is a callback for the DragFinished 1931*cdf0e10cSrcweir // call. AddBox method is called from the GetDragFinishedHdl() and the 1932*cdf0e10cSrcweir // remove is called in link callback and in the destructor. So it can't 1933*cdf0e10cSrcweir // called to a deleted object. 1934*cdf0e10cSrcweir 1935*cdf0e10cSrcweir namespace 1936*cdf0e10cSrcweir { 1937*cdf0e10cSrcweir struct SortLBoxes : public rtl::Static<SvULongsSort, SortLBoxes> {}; 1938*cdf0e10cSrcweir } 1939*cdf0e10cSrcweir 1940*cdf0e10cSrcweir void SvLBox::AddBoxToDDList_Impl( const SvLBox& rB ) 1941*cdf0e10cSrcweir { 1942*cdf0e10cSrcweir sal_uLong nVal = (sal_uLong)&rB; 1943*cdf0e10cSrcweir SortLBoxes::get().Insert( nVal ); 1944*cdf0e10cSrcweir } 1945*cdf0e10cSrcweir 1946*cdf0e10cSrcweir void SvLBox::RemoveBoxFromDDList_Impl( const SvLBox& rB ) 1947*cdf0e10cSrcweir { 1948*cdf0e10cSrcweir sal_uLong nVal = (sal_uLong)&rB; 1949*cdf0e10cSrcweir SortLBoxes::get().Remove( nVal ); 1950*cdf0e10cSrcweir } 1951*cdf0e10cSrcweir 1952*cdf0e10cSrcweir IMPL_STATIC_LINK( SvLBox, DragFinishHdl_Impl, sal_Int8*, pAction ) 1953*cdf0e10cSrcweir { 1954*cdf0e10cSrcweir sal_uLong nVal = (sal_uLong)pThis; 1955*cdf0e10cSrcweir sal_uInt16 nFnd; 1956*cdf0e10cSrcweir SvULongsSort &rSortLBoxes = SortLBoxes::get(); 1957*cdf0e10cSrcweir if( rSortLBoxes.Seek_Entry( nVal, &nFnd ) ) 1958*cdf0e10cSrcweir { 1959*cdf0e10cSrcweir pThis->DragFinished( *pAction ); 1960*cdf0e10cSrcweir rSortLBoxes.Remove( nFnd, 1 ); 1961*cdf0e10cSrcweir } 1962*cdf0e10cSrcweir return 0; 1963*cdf0e10cSrcweir } 1964*cdf0e10cSrcweir 1965*cdf0e10cSrcweir Link SvLBox::GetDragFinishedHdl() const 1966*cdf0e10cSrcweir { 1967*cdf0e10cSrcweir AddBoxToDDList_Impl( *this ); 1968*cdf0e10cSrcweir return STATIC_LINK( this, SvLBox, DragFinishHdl_Impl ); 1969*cdf0e10cSrcweir } 1970*cdf0e10cSrcweir 1971*cdf0e10cSrcweir void SvLBox::FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& ) const 1972*cdf0e10cSrcweir { 1973*cdf0e10cSrcweir } 1974*cdf0e10cSrcweir 1975*cdf0e10cSrcweir ::com::sun::star::uno::Reference< XAccessible > SvLBox::CreateAccessible() 1976*cdf0e10cSrcweir { 1977*cdf0e10cSrcweir return ::com::sun::star::uno::Reference< XAccessible >(); 1978*cdf0e10cSrcweir } 1979*cdf0e10cSrcweir 1980*cdf0e10cSrcweir Rectangle SvLBox::GetBoundingRect( SvLBoxEntry* ) 1981*cdf0e10cSrcweir { 1982*cdf0e10cSrcweir return Rectangle(); 1983*cdf0e10cSrcweir } 1984*cdf0e10cSrcweir 1985