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