Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <vcl/svapp.hxx>
30 : : #include <vcl/salnativewidgets.hxx>
31 : : #include <vcl/help.hxx>
32 : :
33 : : #include <stack>
34 : :
35 : : #define _SVTREEBX_CXX
36 : : #include <svtools/svtreebx.hxx>
37 : : #include <svtools/svlbox.hxx>
38 : : #include <svimpbox.hxx>
39 : : #include <rtl/instance.hxx>
40 : : #include <svtools/svtresid.hxx>
41 : : #include <tools/wintypes.hxx>
42 : : #include <svtools/svtools.hrc>
43 : : #include <comphelper/processfactory.hxx>
44 : : #include <comphelper/string.hxx>
45 : :
46 : : #define NODE_BMP_TABDIST_NOTVALID -2000000
47 : : #define FIRST_ENTRY_TAB 1
48 : :
49 : : // #i27063# (pl), #i32300# (pb) never access VCL after DeInitVCL - also no destructors
50 : : Image* SvImpLBox::s_pDefCollapsed = NULL;
51 : : Image* SvImpLBox::s_pDefExpanded = NULL;
52 : : sal_Int32 SvImpLBox::s_nImageRefCount = 0;
53 : :
54 : 122 : SvImpLBox::SvImpLBox( SvTreeListBox* pLBView, SvLBoxTreeList* pLBTree, WinBits nWinStyle) :
55 : :
56 : : aVerSBar( pLBView, WB_DRAG | WB_VSCROLL ),
57 : : aHorSBar( pLBView, WB_DRAG | WB_HSCROLL ),
58 : : aScrBarBox( pLBView ),
59 : : aOutputSize( 0, 0 ),
60 : : aSelEng( pLBView, (FunctionSet*)0 ),
61 : : aFctSet( this, &aSelEng, pLBView ),
62 : : nExtendedWinBits( 0 ),
63 : : bAreChildrenTransient( sal_True ),
64 [ + - ][ + - ]: 732 : m_pStringSorter(NULL)
[ + - ][ + - ]
[ + + ][ + - ]
[ + - ][ + - ]
[ + - ][ + -
# # # # ]
65 : : {
66 [ + - ]: 122 : osl_incrementInterlockedCount(&s_nImageRefCount);
67 : 122 : pView = pLBView;
68 : 122 : pTree = pLBTree;
69 : 122 : aSelEng.SetFunctionSet( (FunctionSet*)&aFctSet );
70 : 122 : aSelEng.ExpandSelectionOnMouseMove( sal_False );
71 [ + - ]: 122 : SetStyle( nWinStyle );
72 [ + - ]: 122 : SetSelectionMode( SINGLE_SELECTION );
73 [ + - ]: 122 : SetDragDropMode( 0 );
74 : :
75 [ + - ]: 122 : aVerSBar.SetScrollHdl( LINK( this, SvImpLBox, ScrollUpDownHdl ) );
76 [ + - ]: 122 : aHorSBar.SetScrollHdl( LINK( this, SvImpLBox, ScrollLeftRightHdl ) );
77 [ + - ]: 122 : aHorSBar.SetEndScrollHdl( LINK( this, SvImpLBox, EndScrollHdl ) );
78 [ + - ]: 122 : aVerSBar.SetEndScrollHdl( LINK( this, SvImpLBox, EndScrollHdl ) );
79 [ + - ]: 122 : aVerSBar.SetRange( Range(0,0) );
80 [ + - ]: 122 : aVerSBar.Hide();
81 [ + - ]: 122 : aHorSBar.SetRange( Range(0,0) );
82 : 122 : aHorSBar.SetPageSize( 24 ); // pixels
83 : 122 : aHorSBar.SetLineSize( 8 ); // pixels
84 : :
85 [ + - ]: 122 : nHorSBarHeight = (short)aHorSBar.GetSizePixel().Height();
86 [ + - ]: 122 : nVerSBarWidth = (short)aVerSBar.GetSizePixel().Width();
87 : :
88 : 122 : pStartEntry = 0;
89 : 122 : pCursor = 0;
90 : 122 : pAnchor = 0;
91 : 122 : nVisibleCount = 0; // number of rows of data in control
92 : 122 : nNodeBmpTabDistance = NODE_BMP_TABDIST_NOTVALID;
93 : 122 : nYoffsNodeBmp = 0;
94 : 122 : nNodeBmpWidth = 0;
95 : :
96 : 122 : bAsyncBeginDrag = sal_False;
97 [ + - ]: 122 : aAsyncBeginDragTimer.SetTimeout( 0 );
98 [ + - ]: 122 : aAsyncBeginDragTimer.SetTimeoutHdl( LINK(this,SvImpLBox,BeginDragHdl));
99 : : // button animation in listbox
100 : 122 : pActiveButton = 0;
101 : 122 : pActiveEntry = 0;
102 : 122 : pActiveTab = 0;
103 : :
104 : 122 : nFlags = 0;
105 : 122 : nCurTabPos = FIRST_ENTRY_TAB;
106 : :
107 [ + - ]: 122 : aEditTimer.SetTimeout( 800 );
108 [ + - ]: 122 : aEditTimer.SetTimeoutHdl( LINK(this,SvImpLBox,EditTimerCall) );
109 : :
110 : 122 : nMostRight = -1;
111 : 122 : pMostRightEntry = 0;
112 : 122 : nCurUserEvent = 0xffffffff;
113 : :
114 : 122 : bUpdateMode = sal_True;
115 : 122 : bInVScrollHdl = sal_False;
116 : 122 : nFlags |= F_FILLING;
117 : :
118 : 122 : bSubLstOpRet = bSubLstOpLR = bContextMenuHandling = bIsCellFocusEnabled = sal_False;
119 [ # # # # ]: 122 : }
120 : :
121 [ + - ][ + - ]: 854 : SvImpLBox::~SvImpLBox()
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
122 : : {
123 [ + - ]: 122 : aEditTimer.Stop();
124 [ + - ]: 122 : StopUserEvent();
125 : :
126 [ + + ][ + - ]: 122 : delete m_pStringSorter;
127 [ + - ][ + + ]: 122 : if ( osl_decrementInterlockedCount(&s_nImageRefCount) == 0 )
128 : : {
129 [ + + ][ + - ]: 114 : DELETEZ(s_pDefCollapsed);
130 [ + + ][ + - ]: 114 : DELETEZ(s_pDefExpanded);
131 : : }
132 [ + - ][ + + ]: 854 : }
[ # # # # ]
133 : :
134 : 8232 : void SvImpLBox::UpdateStringSorter()
135 : : {
136 : 8232 : const ::com::sun::star::lang::Locale& rNewLocale = Application::GetSettings().GetLocale();
137 : :
138 [ + + ]: 8232 : if( m_pStringSorter )
139 : : {
140 : : // different Locale from the older one, drop it and force recreate
141 : 8112 : const ::com::sun::star::lang::Locale &aLocale = m_pStringSorter->getLocale();
142 [ - + ][ + - : 24336 : if( aLocale.Language != rNewLocale.Language ||
+ - - + ]
143 : 8112 : aLocale.Country != rNewLocale.Country ||
144 : 8112 : aLocale.Variant != rNewLocale.Variant )
145 : : {
146 [ # # ]: 0 : delete m_pStringSorter;
147 : 0 : m_pStringSorter = NULL;
148 : : }
149 : : }
150 : :
151 [ + + ]: 8232 : if( !m_pStringSorter )
152 : : {
153 : : m_pStringSorter = new comphelper::string::NaturalStringSorter(
154 : : ::comphelper::getProcessComponentContext(),
155 [ + - ][ + - ]: 120 : rNewLocale);
156 : : }
157 : 8232 : }
158 : :
159 : : // #97680# ----------------------
160 : 2402 : short SvImpLBox::UpdateContextBmpWidthVector( SvLBoxEntry* pEntry, short nWidth )
161 : : {
162 : : DBG_ASSERT( pView->pModel, "View and Model aren't valid!" );
163 : :
164 : 2402 : sal_uInt16 nDepth = pView->pModel->GetDepth( pEntry );
165 : : // initialize vector if necessary
166 : 2402 : std::vector< short >::size_type nSize = aContextBmpWidthVector.size();
167 [ - + ]: 2402 : while ( nDepth > nSize )
168 : : {
169 : 0 : aContextBmpWidthVector.resize( nSize + 1 );
170 : 0 : aContextBmpWidthVector.at( nSize ) = nWidth;
171 : 0 : ++nSize;
172 : : }
173 [ + + ]: 2402 : if( aContextBmpWidthVector.size() == nDepth )
174 : : {
175 : 126 : aContextBmpWidthVector.resize( nDepth + 1 );
176 : 126 : aContextBmpWidthVector.at( nDepth ) = 0;
177 : : }
178 : 2402 : short nContextBmpWidth = aContextBmpWidthVector[ nDepth ];
179 [ + + ]: 2402 : if( nContextBmpWidth < nWidth )
180 : : {
181 : 6 : aContextBmpWidthVector.at( nDepth ) = nWidth;
182 : 6 : return nWidth;
183 : : }
184 : : else
185 : 2402 : return nContextBmpWidth;
186 : : }
187 : :
188 : 0 : void SvImpLBox::UpdateContextBmpWidthVectorFromMovedEntry( SvLBoxEntry* pEntry )
189 : : {
190 : : DBG_ASSERT( pEntry, "Moved Entry is invalid!" );
191 : :
192 : 0 : SvLBoxContextBmp* pBmpItem = static_cast< SvLBoxContextBmp* >( pEntry->GetFirstItem( SV_ITEM_ID_LBOXCONTEXTBMP ) );
193 : 0 : short nExpWidth = (short)pBmpItem->GetBitmap1().GetSizePixel().Width();
194 : 0 : short nColWidth = (short)pBmpItem->GetBitmap2().GetSizePixel().Width();
195 : 0 : short nMax = Max(nExpWidth, nColWidth);
196 : 0 : UpdateContextBmpWidthVector( pEntry, nMax );
197 : :
198 [ # # ]: 0 : if( pEntry->HasChildren() ) // recursive call, whether expanded or not
199 : : {
200 : 0 : SvLBoxEntry* pChild = pView->FirstChild( pEntry );
201 : : DBG_ASSERT( pChild, "The first child is invalid!" );
202 [ # # ]: 0 : do
203 : : {
204 : 0 : UpdateContextBmpWidthVectorFromMovedEntry( pChild );
205 : 0 : pChild = pView->Next( pChild );
206 : : } while ( pChild );
207 : : }
208 : 0 : }
209 : :
210 : 3359 : void SvImpLBox::UpdateContextBmpWidthMax( SvLBoxEntry* pEntry )
211 : : {
212 : 3359 : sal_uInt16 nDepth = pView->pModel->GetDepth( pEntry );
213 [ - + ]: 3359 : if( aContextBmpWidthVector.size() < 1 )
214 : 3359 : return;
215 : 3359 : short nWidth = aContextBmpWidthVector[ nDepth ];
216 [ - + ]: 3359 : if( nWidth != pView->nContextBmpWidthMax ) {
217 : 0 : pView->nContextBmpWidthMax = nWidth;
218 : 0 : nFlags |= F_IGNORE_CHANGED_TABS;
219 : 0 : pView->SetTabs();
220 : 0 : nFlags &= ~F_IGNORE_CHANGED_TABS;
221 : : }
222 : : }
223 : :
224 : 6 : void SvImpLBox::CalcCellFocusRect( SvLBoxEntry* pEntry, Rectangle& rRect )
225 : : {
226 [ + - ][ - + ]: 6 : if ( pEntry && bIsCellFocusEnabled )
227 : : {
228 [ # # ]: 0 : if ( nCurTabPos > FIRST_ENTRY_TAB )
229 : : {
230 : 0 : SvLBoxItem* pItem = pCursor->GetItem( nCurTabPos );
231 : 0 : rRect.Left() = pView->GetTab( pCursor, pItem )->GetPos();
232 : : }
233 [ # # ]: 0 : if ( pCursor->ItemCount() > ( nCurTabPos + 1 ) )
234 : : {
235 : 0 : SvLBoxItem* pNextItem = pCursor->GetItem( nCurTabPos + 1 );
236 : 0 : long nRight = pView->GetTab( pCursor, pNextItem )->GetPos() - 1;
237 [ # # ]: 0 : if ( nRight < rRect.Right() )
238 : 0 : rRect.Right() = nRight;
239 : : }
240 : : }
241 : 6 : }
242 : :
243 : 364 : void SvImpLBox::SetStyle( WinBits i_nWinStyle )
244 : : {
245 : 364 : m_nStyle = i_nWinStyle;
246 [ - + ][ # # ]: 364 : if ( ( m_nStyle & WB_SIMPLEMODE) && ( aSelEng.GetSelectionMode() == MULTIPLE_SELECTION ) )
[ - + ]
247 : 0 : aSelEng.AddAlways( sal_True );
248 : 364 : }
249 : :
250 : 0 : void SvImpLBox::SetExtendedWindowBits( ExtendedWinBits _nBits )
251 : : {
252 : 0 : nExtendedWinBits = _nBits;
253 : 0 : }
254 : :
255 : : // don't touch the model any more
256 : 124 : void SvImpLBox::Clear()
257 : : {
258 [ + - ]: 124 : StopUserEvent();
259 : 124 : pStartEntry = 0;
260 : 124 : pAnchor = 0;
261 : :
262 : 124 : pActiveButton = 0;
263 : 124 : pActiveEntry = 0;
264 : 124 : pActiveTab = 0;
265 : :
266 : 124 : nMostRight = -1;
267 : 124 : pMostRightEntry = 0;
268 : :
269 : : // don't touch the cursor any more
270 [ - + ]: 124 : if( pCursor )
271 : : {
272 [ # # ][ # # ]: 0 : if( pView->HasFocus() )
273 [ # # ]: 0 : pView->HideFocus();
274 : 0 : pCursor = 0;
275 : : }
276 [ + - ]: 124 : aVerSBar.Hide();
277 [ + - ]: 124 : aVerSBar.SetThumbPos( 0 );
278 : 124 : Range aRange( 0, 0 );
279 [ + - ]: 124 : aVerSBar.SetRange( aRange );
280 : 124 : aOutputSize = pView->Control::GetOutputSizePixel();
281 : 124 : nFlags &= ~(F_VER_SBARSIZE_WITH_HBAR | F_HOR_SBARSIZE_WITH_VBAR );
282 [ + - ]: 124 : aHorSBar.Hide();
283 [ + - ]: 124 : aHorSBar.SetThumbPos( 0 );
284 [ + - ]: 124 : MapMode aMapMode( pView->GetMapMode());
285 [ + - ]: 124 : aMapMode.SetOrigin( Point(0,0) );
286 [ + - ]: 124 : pView->Control::SetMapMode( aMapMode );
287 [ + - ]: 124 : aHorSBar.SetRange( aRange );
288 [ + - ]: 124 : aHorSBar.SetSizePixel(Size(aOutputSize.Width(),nHorSBarHeight));
289 [ + - ]: 124 : pView->SetClipRegion();
290 [ + + ]: 124 : if( GetUpdateMode() )
291 [ + - ][ + - ]: 4 : pView->Invalidate( GetVisibleArea() );
292 : 124 : nFlags |= F_FILLING;
293 [ + - ][ + - ]: 124 : if( !aHorSBar.IsVisible() && !aVerSBar.IsVisible() )
[ + - ][ + - ]
[ + - ]
294 [ + - ]: 124 : aScrBarBox.Hide();
295 : :
296 [ + - ]: 124 : aContextBmpWidthVector.clear();
297 : 124 : }
298 : :
299 : : // *********************************************************************
300 : : // Paint, navigate, scroll
301 : : // *********************************************************************
302 : :
303 : 0 : IMPL_LINK_NOARG_INLINE_START(SvImpLBox, EndScrollHdl)
304 : : {
305 [ # # ]: 0 : if( nFlags & F_ENDSCROLL_SET_VIS_SIZE )
306 : : {
307 : 0 : aVerSBar.SetVisibleSize( nNextVerVisSize );
308 : 0 : nFlags &= ~F_ENDSCROLL_SET_VIS_SIZE;
309 : : }
310 : 0 : EndScroll();
311 : 0 : return 0;
312 : : }
313 : 0 : IMPL_LINK_NOARG_INLINE_END(SvImpLBox, EndScrollHdl)
314 : :
315 : :
316 : : // handler for vertical scrollbar
317 : :
318 : 0 : IMPL_LINK( SvImpLBox, ScrollUpDownHdl, ScrollBar *, pScrollBar )
319 : : {
320 : : DBG_ASSERT(!bInVScrollHdl,"Scroll handler out-paces itself!");
321 : 0 : long nDelta = pScrollBar->GetDelta();
322 [ # # ]: 0 : if( !nDelta )
323 : 0 : return 0;
324 : :
325 : 0 : nFlags &= (~F_FILLING);
326 : :
327 : 0 : bInVScrollHdl = sal_True;
328 : :
329 [ # # ]: 0 : if( pView->IsEditingActive() )
330 : : {
331 : 0 : pView->EndEditing( sal_True ); // Cancel
332 : 0 : pView->Update();
333 : : }
334 : 0 : BeginScroll();
335 : :
336 [ # # ]: 0 : if( nDelta > 0 )
337 : : {
338 [ # # ]: 0 : if( nDelta == 1 )
339 : 0 : CursorDown();
340 : : else
341 : 0 : PageDown( (sal_uInt16) nDelta );
342 : : }
343 : : else
344 : : {
345 : 0 : nDelta *= (-1);
346 [ # # ]: 0 : if( nDelta == 1 )
347 : 0 : CursorUp();
348 : : else
349 : 0 : PageUp( (sal_uInt16) nDelta );
350 : : }
351 : 0 : bInVScrollHdl = sal_False;
352 : 0 : return 0;
353 : : }
354 : :
355 : :
356 : 0 : void SvImpLBox::CursorDown()
357 : : {
358 : 0 : SvLBoxEntry* pNextFirstToDraw = (SvLBoxEntry*)(pView->NextVisible( pStartEntry));
359 [ # # ]: 0 : if( pNextFirstToDraw )
360 : : {
361 : 0 : nFlags &= (~F_FILLING);
362 [ # # ]: 0 : pView->NotifyScrolling( -1 );
363 [ # # ]: 0 : ShowCursor( sal_False );
364 [ # # ]: 0 : pView->Update();
365 : 0 : pStartEntry = pNextFirstToDraw;
366 [ # # ]: 0 : Rectangle aArea( GetVisibleArea() );
367 [ # # ]: 0 : pView->Scroll( 0, -(pView->GetEntryHeight()), aArea, SCROLL_NOCHILDREN );
368 [ # # ]: 0 : pView->Update();
369 [ # # ]: 0 : ShowCursor( sal_True );
370 [ # # ]: 0 : pView->NotifyScrolled();
371 : : }
372 : 0 : }
373 : :
374 : 0 : void SvImpLBox::CursorUp()
375 : : {
376 : 0 : SvLBoxEntry* pPrevFirstToDraw = (SvLBoxEntry*)(pView->PrevVisible( pStartEntry));
377 [ # # ]: 0 : if( pPrevFirstToDraw )
378 : : {
379 : 0 : nFlags &= (~F_FILLING);
380 : 0 : long nEntryHeight = pView->GetEntryHeight();
381 [ # # ]: 0 : pView->NotifyScrolling( 1 );
382 [ # # ]: 0 : ShowCursor( sal_False );
383 [ # # ]: 0 : pView->Update();
384 : 0 : pStartEntry = pPrevFirstToDraw;
385 [ # # ]: 0 : Rectangle aArea( GetVisibleArea() );
386 : 0 : aArea.Bottom() -= nEntryHeight;
387 [ # # ]: 0 : pView->Scroll( 0, nEntryHeight, aArea, SCROLL_NOCHILDREN );
388 [ # # ]: 0 : pView->Update();
389 [ # # ]: 0 : ShowCursor( sal_True );
390 [ # # ]: 0 : pView->NotifyScrolled();
391 : : }
392 : 0 : }
393 : :
394 : 0 : void SvImpLBox::PageDown( sal_uInt16 nDelta )
395 : : {
396 : 0 : sal_uInt16 nRealDelta = nDelta;
397 : :
398 [ # # ]: 0 : if( !nDelta )
399 : : return;
400 : :
401 : : SvLBoxEntry* pNext;
402 [ # # ]: 0 : pNext = (SvLBoxEntry*)(pView->NextVisible( pStartEntry, nRealDelta ));
403 [ # # ]: 0 : if( (sal_uLong)pNext == (sal_uLong)pStartEntry )
404 : : return;
405 : :
406 [ # # ]: 0 : ShowCursor( sal_False );
407 : :
408 : 0 : nFlags &= (~F_FILLING);
409 [ # # ]: 0 : pView->Update();
410 : 0 : pStartEntry = pNext;
411 : :
412 [ # # ]: 0 : if( nRealDelta >= nVisibleCount )
413 : : {
414 [ # # ][ # # ]: 0 : pView->Invalidate( GetVisibleArea() );
415 [ # # ]: 0 : pView->Update();
416 : : }
417 : : else
418 : : {
419 : 0 : long nScroll = nRealDelta * (-1);
420 [ # # ]: 0 : pView->NotifyScrolling( nScroll );
421 [ # # ]: 0 : Rectangle aArea( GetVisibleArea() );
422 : 0 : nScroll = pView->GetEntryHeight()*nRealDelta;
423 : 0 : nScroll = -nScroll;
424 [ # # ]: 0 : pView->Update();
425 [ # # ]: 0 : pView->Scroll( 0, nScroll, aArea, SCROLL_NOCHILDREN );
426 [ # # ]: 0 : pView->Update();
427 [ # # ]: 0 : pView->NotifyScrolled();
428 : : }
429 : :
430 [ # # ]: 0 : ShowCursor( sal_True );
431 : : }
432 : :
433 : 0 : void SvImpLBox::PageUp( sal_uInt16 nDelta )
434 : : {
435 : 0 : sal_uInt16 nRealDelta = nDelta;
436 [ # # ]: 0 : if( !nDelta )
437 : : return;
438 : :
439 [ # # ]: 0 : SvLBoxEntry* pPrev = (SvLBoxEntry*)(pView->PrevVisible( pStartEntry, nRealDelta ));
440 [ # # ]: 0 : if( (sal_uLong)pPrev == (sal_uLong)pStartEntry )
441 : : return;
442 : :
443 : 0 : nFlags &= (~F_FILLING);
444 [ # # ]: 0 : ShowCursor( sal_False );
445 : :
446 [ # # ]: 0 : pView->Update();
447 : 0 : pStartEntry = pPrev;
448 [ # # ]: 0 : if( nRealDelta >= nVisibleCount )
449 : : {
450 [ # # ][ # # ]: 0 : pView->Invalidate( GetVisibleArea() );
451 [ # # ]: 0 : pView->Update();
452 : : }
453 : : else
454 : : {
455 : 0 : long nEntryHeight = pView->GetEntryHeight();
456 [ # # ]: 0 : pView->NotifyScrolling( (long)nRealDelta );
457 [ # # ]: 0 : Rectangle aArea( GetVisibleArea() );
458 [ # # ]: 0 : pView->Update();
459 [ # # ]: 0 : pView->Scroll( 0, nEntryHeight*nRealDelta, aArea, SCROLL_NOCHILDREN );
460 [ # # ]: 0 : pView->Update();
461 [ # # ]: 0 : pView->NotifyScrolled();
462 : : }
463 : :
464 [ # # ]: 0 : ShowCursor( sal_True );
465 : : }
466 : :
467 : 0 : void SvImpLBox::KeyUp( sal_Bool bPageUp, sal_Bool bNotifyScroll )
468 : : {
469 [ # # ]: 0 : if( !aVerSBar.IsVisible() )
470 : 0 : return;
471 : :
472 : : long nDelta;
473 [ # # ]: 0 : if( bPageUp )
474 : 0 : nDelta = aVerSBar.GetPageSize();
475 : : else
476 : 0 : nDelta = 1;
477 : :
478 : 0 : long nThumbPos = aVerSBar.GetThumbPos();
479 : :
480 [ # # ]: 0 : if( nThumbPos < nDelta )
481 : 0 : nDelta = nThumbPos;
482 : :
483 [ # # ]: 0 : if( nDelta <= 0 )
484 : 0 : return;
485 : :
486 : 0 : nFlags &= (~F_FILLING);
487 [ # # ]: 0 : if( bNotifyScroll )
488 : 0 : BeginScroll();
489 : :
490 : 0 : aVerSBar.SetThumbPos( nThumbPos - nDelta );
491 [ # # ]: 0 : if( bPageUp )
492 : 0 : PageUp( (short)nDelta );
493 : : else
494 : 0 : CursorUp();
495 : :
496 [ # # ]: 0 : if( bNotifyScroll )
497 : 0 : EndScroll();
498 : : }
499 : :
500 : :
501 : 0 : void SvImpLBox::KeyDown( sal_Bool bPageDown, sal_Bool bNotifyScroll )
502 : : {
503 [ # # ]: 0 : if( !aVerSBar.IsVisible() )
504 : 0 : return;
505 : :
506 : : long nDelta;
507 [ # # ]: 0 : if( bPageDown )
508 : 0 : nDelta = aVerSBar.GetPageSize();
509 : : else
510 : 0 : nDelta = 1;
511 : :
512 : 0 : long nThumbPos = aVerSBar.GetThumbPos();
513 : 0 : long nVisibleSize = aVerSBar.GetVisibleSize();
514 : 0 : long nRange = aVerSBar.GetRange().Len();
515 : :
516 : 0 : long nTmp = nThumbPos+nVisibleSize;
517 [ # # ][ # # ]: 0 : while( (nDelta > 0) && (nTmp+nDelta) >= nRange )
[ # # ]
518 : 0 : nDelta--;
519 : :
520 [ # # ]: 0 : if( nDelta <= 0 )
521 : 0 : return;
522 : :
523 : 0 : nFlags &= (~F_FILLING);
524 [ # # ]: 0 : if( bNotifyScroll )
525 : 0 : BeginScroll();
526 : :
527 : 0 : aVerSBar.SetThumbPos( nThumbPos+nDelta );
528 [ # # ]: 0 : if( bPageDown )
529 : 0 : PageDown( (short)nDelta );
530 : : else
531 : 0 : CursorDown();
532 : :
533 [ # # ]: 0 : if( bNotifyScroll )
534 : 0 : EndScroll();
535 : : }
536 : :
537 : :
538 : :
539 : 4 : void SvImpLBox::InvalidateEntriesFrom( long nY ) const
540 : : {
541 [ + - ]: 4 : if( !(nFlags & F_IN_PAINT ))
542 : : {
543 [ + - ]: 4 : Rectangle aRect( GetVisibleArea() );
544 : 4 : aRect.Top() = nY;
545 [ + - ]: 4 : pView->Invalidate( aRect );
546 : : }
547 : 4 : }
548 : :
549 : 16 : void SvImpLBox::InvalidateEntry( long nY ) const
550 : : {
551 [ + - ]: 16 : if( !(nFlags & F_IN_PAINT ))
552 : : {
553 [ + - ]: 16 : Rectangle aRect( GetVisibleArea() );
554 : 16 : long nMaxBottom = aRect.Bottom();
555 : 16 : aRect.Top() = nY;
556 : 16 : aRect.Bottom() = nY; aRect.Bottom() += pView->GetEntryHeight();
557 [ + + ]: 16 : if( aRect.Top() > nMaxBottom )
558 : 16 : return;
559 [ - + ]: 14 : if( aRect.Bottom() > nMaxBottom )
560 : 0 : aRect.Bottom() = nMaxBottom;
561 [ + - ]: 16 : pView->Invalidate( aRect );
562 : : }
563 : : }
564 : :
565 : 16 : void SvImpLBox::InvalidateEntry( SvLBoxEntry* pEntry )
566 : : {
567 [ + - ]: 16 : if( GetUpdateMode() )
568 : : {
569 : 16 : long nPrev = nMostRight;
570 : 16 : SetMostRight( pEntry );
571 [ + + ]: 16 : if( nPrev < nMostRight )
572 : 4 : ShowVerSBar();
573 : : }
574 [ + - ]: 16 : if( !(nFlags & F_IN_PAINT ))
575 : : {
576 : 16 : sal_Bool bHasFocusRect = sal_False;
577 [ + + ][ + + ]: 16 : if( pEntry==pCursor && pView->HasFocus() )
[ + + ]
578 : : {
579 : 2 : bHasFocusRect = sal_True;
580 : 2 : ShowCursor( sal_False );
581 : : }
582 : 16 : InvalidateEntry( GetEntryLine( pEntry ) );
583 [ + + ]: 16 : if( bHasFocusRect )
584 : 2 : ShowCursor( sal_True );
585 : : }
586 : 16 : }
587 : :
588 : :
589 : 390 : void SvImpLBox::RecalcFocusRect()
590 : : {
591 [ + + ][ + - ]: 390 : if( pView->HasFocus() && pCursor )
[ + + ]
592 : : {
593 [ + - ]: 2 : pView->HideFocus();
594 [ + - ]: 2 : long nY = GetEntryLine( pCursor );
595 [ + - ]: 2 : Rectangle aRect = pView->GetFocusRect( pCursor, nY );
596 [ + - ]: 2 : CalcCellFocusRect( pCursor, aRect );
597 [ + - ]: 2 : Region aOldClip( pView->GetClipRegion());
598 [ + - ][ + - ]: 2 : Region aClipRegion( GetClipRegionRect() );
599 [ + - ]: 2 : pView->SetClipRegion( aClipRegion );
600 [ + - ]: 2 : pView->ShowFocus( aRect );
601 [ + - ][ + - ]: 2 : pView->SetClipRegion( aOldClip );
[ + - ]
602 : : }
603 : 390 : }
604 : :
605 : : //
606 : : // Sets cursor. When using SingleSelection, the selection is adjusted.
607 : : //
608 : :
609 : 124 : void SvImpLBox::SetCursor( SvLBoxEntry* pEntry, sal_Bool bForceNoSelect )
610 : : {
611 : 124 : SvViewDataEntry* pViewDataNewCur = 0;
612 [ + - ]: 124 : if( pEntry )
613 : 124 : pViewDataNewCur= pView->GetViewDataEntry(pEntry);
614 [ + - ][ - + : 124 : if( pEntry &&
# # # # ]
[ - + ]
615 : : pEntry == pCursor &&
616 : 0 : pViewDataNewCur->HasFocus() &&
617 : 0 : pViewDataNewCur->IsSelected())
618 : : {
619 : 124 : return;
620 : : }
621 : :
622 : : // if this cursor is not selectable, find first visible that is and use it
623 [ + - ][ + - ]: 124 : while( pEntry && pViewDataNewCur && !pViewDataNewCur->IsSelectable() )
[ - + ][ - + ]
624 : : {
625 : 0 : pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
626 [ # # ]: 0 : pViewDataNewCur = pEntry ? pView->GetViewDataEntry(pEntry) : 0;
627 : : }
628 : :
629 : 124 : SvLBoxEntry* pOldCursor = pCursor;
630 [ + + ][ + - ]: 124 : if( pCursor && pEntry != pCursor )
631 : : {
632 : 2 : pView->SetEntryFocus( pCursor, sal_False );
633 [ + - ]: 2 : if( bSimpleTravel )
634 : 2 : pView->Select( pCursor, sal_False );
635 : 2 : pView->HideFocus();
636 : : }
637 : 124 : pCursor = pEntry;
638 [ + - ]: 124 : if( pCursor )
639 : : {
640 : 124 : pViewDataNewCur->SetFocus( sal_True );
641 [ + - ][ + + ]: 124 : if(!bForceNoSelect && bSimpleTravel && !(nFlags & F_DESEL_ALL) && GetUpdateMode())
[ + - ][ + + ]
[ + - ]
642 : : {
643 : 122 : pView->Select( pCursor, sal_True );
644 : : }
645 : : // multiple selection: select in cursor move if we're not in
646 : : // Add mode (Ctrl-F8)
647 [ + - - + ]: 4 : else if( GetUpdateMode() &&
[ # # # # ]
[ # # ][ - + ]
648 : 2 : pView->GetSelectionMode() == MULTIPLE_SELECTION &&
649 : 0 : !(nFlags & F_DESEL_ALL) && !aSelEng.IsAddMode() &&
650 : : !bForceNoSelect )
651 : : {
652 : 0 : pView->Select( pCursor, sal_True );
653 : : }
654 : : else
655 : : {
656 : 2 : ShowCursor( sal_True );
657 : : }
658 : :
659 [ - + ]: 124 : if( pAnchor )
660 : : {
661 : : DBG_ASSERT(aSelEng.GetSelectionMode() != SINGLE_SELECTION,"Mode?");
662 : 0 : SetAnchorSelection( pOldCursor, pCursor );
663 : : }
664 : : }
665 : 124 : nFlags &= (~F_DESEL_ALL);
666 : :
667 : 124 : pView->OnCurrentEntryChanged();
668 : : }
669 : :
670 : 1269 : void SvImpLBox::ShowCursor( sal_Bool bShow )
671 : : {
672 [ + + ][ + + ]: 1269 : if( !bShow || !pCursor || !pView->HasFocus() )
[ + + ][ + + ]
673 : : {
674 [ + - ]: 1265 : Region aOldClip( pView->GetClipRegion());
675 [ + - ][ + - ]: 1265 : Region aClipRegion( GetClipRegionRect() );
676 [ + - ]: 1265 : pView->SetClipRegion( aClipRegion );
677 [ + - ]: 1265 : pView->HideFocus();
678 [ + - ][ + - ]: 1265 : pView->SetClipRegion( aOldClip );
[ + - ]
679 : : }
680 : : else
681 : : {
682 [ + - ]: 4 : long nY = GetEntryLine( pCursor );
683 [ + - ]: 4 : Rectangle aRect = pView->GetFocusRect( pCursor, nY );
684 [ + - ]: 4 : CalcCellFocusRect( pCursor, aRect );
685 [ + - ]: 4 : Region aOldClip( pView->GetClipRegion());
686 [ + - ][ + - ]: 4 : Region aClipRegion( GetClipRegionRect() );
687 [ + - ]: 4 : pView->SetClipRegion( aClipRegion );
688 [ + - ]: 4 : pView->ShowFocus( aRect );
689 [ + - ][ + - ]: 4 : pView->SetClipRegion( aOldClip );
[ + - ]
690 : : }
691 : 1269 : }
692 : :
693 : :
694 : :
695 : 120 : void SvImpLBox::UpdateAll( sal_Bool bInvalidateCompleteView,
696 : : sal_Bool bUpdateVerScrollBar )
697 : : {
698 [ + - ]: 120 : if( bUpdateVerScrollBar )
699 : 120 : FindMostRight(0);
700 [ + - ]: 120 : aVerSBar.SetRange( Range(0, pView->GetVisibleCount()-1 ) );
701 : 120 : SyncVerThumb();
702 : 120 : FillView();
703 : 120 : ShowVerSBar();
704 [ - + ][ # # ]: 120 : if( bSimpleTravel && pCursor && pView->HasFocus() )
[ - + ][ + - ]
705 : 0 : pView->Select( pCursor, sal_True );
706 : 120 : ShowCursor( sal_True );
707 [ - + ]: 120 : if( bInvalidateCompleteView )
708 : 0 : pView->Invalidate();
709 : : else
710 [ + - ]: 120 : pView->Invalidate( GetVisibleArea() );
711 : 120 : }
712 : :
713 : 0 : IMPL_LINK_INLINE_START( SvImpLBox, ScrollLeftRightHdl, ScrollBar *, pScrollBar )
714 : : {
715 : 0 : long nDelta = pScrollBar->GetDelta();
716 [ # # ]: 0 : if( nDelta )
717 : : {
718 [ # # ]: 0 : if( pView->IsEditingActive() )
719 : : {
720 : 0 : pView->EndEditing( sal_True ); // Cancel
721 : 0 : pView->Update();
722 : : }
723 : 0 : pView->nFocusWidth = -1;
724 : 0 : KeyLeftRight( nDelta );
725 : : }
726 : 0 : return 0;
727 : : }
728 : 0 : IMPL_LINK_INLINE_END( SvImpLBox, ScrollLeftRightHdl, ScrollBar *, pScrollBar )
729 : :
730 : 0 : void SvImpLBox::KeyLeftRight( long nDelta )
731 : : {
732 [ # # ]: 0 : if( !(nFlags & F_IN_RESIZE) )
733 [ # # ]: 0 : pView->Update();
734 [ # # ]: 0 : BeginScroll();
735 : 0 : nFlags &= (~F_FILLING);
736 [ # # ]: 0 : pView->NotifyScrolling( 0 ); // 0 == horizontal scrolling
737 [ # # ]: 0 : ShowCursor( sal_False );
738 : :
739 : : // neuen Origin berechnen
740 : 0 : long nPos = aHorSBar.GetThumbPos();
741 : 0 : Point aOrigin( -nPos, 0 );
742 : :
743 [ # # ]: 0 : MapMode aMapMode( pView->GetMapMode() );
744 [ # # ]: 0 : aMapMode.SetOrigin( aOrigin );
745 [ # # ]: 0 : pView->SetMapMode( aMapMode );
746 : :
747 [ # # ]: 0 : if( !(nFlags & F_IN_RESIZE) )
748 : : {
749 [ # # ]: 0 : Rectangle aRect( GetVisibleArea() );
750 [ # # ]: 0 : pView->Scroll( -nDelta, 0, aRect, SCROLL_NOCHILDREN );
751 : : }
752 : : else
753 [ # # ]: 0 : pView->Invalidate();
754 [ # # ]: 0 : RecalcFocusRect();
755 [ # # ]: 0 : ShowCursor( sal_True );
756 [ # # ][ # # ]: 0 : pView->NotifyScrolled();
757 : 0 : }
758 : :
759 : :
760 : : // returns the last entry if position is just past the last entry
761 : 0 : SvLBoxEntry* SvImpLBox::GetClickedEntry( const Point& rPoint ) const
762 : : {
763 : : DBG_ASSERT( pView->GetModel(), "SvImpLBox::GetClickedEntry: how can this ever happen? Please tell me (frank.schoenheit@sun.com) how to reproduce!" );
764 [ # # ]: 0 : if ( !pView->GetModel() )
765 : : // this is quite impossible. Nevertheless, stack traces from the crash reporter
766 : : // suggest it isn't. Okay, make it safe, and wait for somebody to reproduce it
767 : : // reliably :-\ ....
768 : : // #122359# / 2005-05-23 / frank.schoenheit@sun.com
769 : 0 : return NULL;
770 [ # # ][ # # ]: 0 : if( pView->GetEntryCount() == 0 || !pStartEntry || !pView->GetEntryHeight())
[ # # ][ # # ]
771 : 0 : return 0;
772 : :
773 : 0 : sal_uInt16 nClickedEntry = (sal_uInt16)(rPoint.Y() / pView->GetEntryHeight() );
774 : 0 : sal_uInt16 nTemp = nClickedEntry;
775 [ # # ]: 0 : SvLBoxEntry* pEntry = (SvLBoxEntry*)(pView->NextVisible( pStartEntry, nTemp ));
776 : 0 : return pEntry;
777 : : }
778 : :
779 : : //
780 : : // checks if the entry was hit "the right way"
781 : : // (Focusrect+ ContextBitmap bei TreeListBox)
782 : : //
783 : 0 : sal_Bool SvImpLBox::EntryReallyHit(SvLBoxEntry* pEntry,const Point& rPosPixel,long nLine)
784 : : {
785 : : sal_Bool bRet;
786 : : // we are not too exact when it comes to "special" entries
787 : : // (with CheckButtons etc.)
788 [ # # ]: 0 : if( pEntry->ItemCount() >= 3 )
789 : 0 : return sal_True;
790 : :
791 [ # # ]: 0 : Rectangle aRect( pView->GetFocusRect( pEntry, nLine ));
792 : 0 : aRect.Right() = GetOutputSize().Width() - pView->GetMapMode().GetOrigin().X();
793 [ # # ][ # # ]: 0 : if( pView->IsA() == SV_LISTBOX_ID_TREEBOX )
794 : : {
795 [ # # ]: 0 : SvLBoxContextBmp* pBmp = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
796 [ # # ]: 0 : aRect.Left() -= pBmp->GetSize(pView,pEntry).Width();
797 : 0 : aRect.Left() -= 4; // a little tolerance
798 : : }
799 : 0 : Point aPos( rPosPixel );
800 : 0 : aPos -= pView->GetMapMode().GetOrigin();
801 [ # # ][ # # ]: 0 : if( aRect.IsInside( aPos ) )
802 : 0 : bRet = sal_True;
803 : : else
804 : 0 : bRet = sal_False;
805 : 0 : return bRet;
806 : : }
807 : :
808 : :
809 : : // returns 0 if position is just past the last entry
810 : 0 : SvLBoxEntry* SvImpLBox::GetEntry( const Point& rPoint ) const
811 : : {
812 [ # # ][ # # : 0 : if( (pView->GetEntryCount() == 0) || !pStartEntry ||
# # # # ]
[ # # ]
813 : 0 : (rPoint.Y() > aOutputSize.Height())
814 : 0 : || !pView->GetEntryHeight())
815 : 0 : return 0;
816 : :
817 : 0 : sal_uInt16 nClickedEntry = (sal_uInt16)(rPoint.Y() / pView->GetEntryHeight() );
818 : 0 : sal_uInt16 nTemp = nClickedEntry;
819 [ # # ]: 0 : SvLBoxEntry* pEntry = (SvLBoxEntry*)(pView->NextVisible( pStartEntry, nTemp ));
820 [ # # ]: 0 : if( nTemp != nClickedEntry )
821 : 0 : pEntry = 0;
822 : 0 : return pEntry;
823 : : }
824 : :
825 : :
826 : 0 : SvLBoxEntry* SvImpLBox::MakePointVisible(const Point& rPoint,sal_Bool bNotifyScroll)
827 : : {
828 [ # # ]: 0 : if( !pCursor )
829 : 0 : return 0;
830 : 0 : long nY = rPoint.Y();
831 : 0 : SvLBoxEntry* pEntry = 0;
832 : 0 : long nMax = aOutputSize.Height();
833 [ # # ][ # # ]: 0 : if( nY < 0 || nY >= nMax ) // aOutputSize.Height() )
834 : : {
835 [ # # ]: 0 : if( nY < 0 )
836 : 0 : pEntry = (SvLBoxEntry*)(pView->PrevVisible( pCursor ));
837 : : else
838 : 0 : pEntry = (SvLBoxEntry*)(pView->NextVisible( pCursor ));
839 : :
840 [ # # ][ # # ]: 0 : if( pEntry && pEntry != pCursor )
841 : 0 : pView->SetEntryFocus( pCursor, sal_False );
842 : :
843 [ # # ]: 0 : if( nY < 0 )
844 : 0 : KeyUp( sal_False, bNotifyScroll );
845 : : else
846 : 0 : KeyDown( sal_False, bNotifyScroll );
847 : : }
848 : : else
849 : : {
850 : 0 : pEntry = GetClickedEntry( rPoint );
851 [ # # ]: 0 : if( !pEntry )
852 : : {
853 : 0 : sal_uInt16 nSteps = 0xFFFF;
854 : : // TODO: LastVisible is not yet implemented!
855 [ # # ]: 0 : pEntry = (SvLBoxEntry*)(pView->NextVisible( pStartEntry, nSteps ));
856 : : }
857 [ # # ]: 0 : if( pEntry )
858 : : {
859 [ # # # # ]: 0 : if( pEntry != pCursor &&
[ # # ]
860 : 0 : aSelEng.GetSelectionMode() == SINGLE_SELECTION
861 : : )
862 : 0 : pView->Select( pCursor, sal_False );
863 : : }
864 : : }
865 : 0 : return pEntry;
866 : : }
867 : :
868 : 1450 : Rectangle SvImpLBox::GetClipRegionRect() const
869 : : {
870 : 1450 : Point aOrigin( pView->GetMapMode().GetOrigin() );
871 : 1450 : aOrigin.X() *= -1; // conversion document coordinates
872 [ + - ]: 1450 : Rectangle aClipRect( aOrigin, aOutputSize );
873 : 1450 : aClipRect.Bottom()++;
874 : 1450 : return aClipRect;
875 : : }
876 : :
877 : :
878 : 173 : void SvImpLBox::Paint( const Rectangle& rRect )
879 : : {
880 [ + - ][ + - ]: 173 : if( !pView->GetVisibleCount() )
881 : : return;
882 : :
883 : 173 : nFlags |= F_IN_PAINT;
884 : :
885 [ + - ]: 173 : if( nFlags & F_FILLING )
886 : : {
887 [ + - ]: 173 : SvLBoxEntry* pFirst = pView->First();
888 [ - + ]: 173 : if( pFirst != pStartEntry )
889 : : {
890 [ # # ]: 0 : ShowCursor( sal_False );
891 [ # # ]: 0 : pStartEntry = pView->First();
892 [ # # ]: 0 : aVerSBar.SetThumbPos( 0 );
893 [ # # ]: 0 : StopUserEvent();
894 [ # # ]: 0 : ShowCursor( sal_True );
895 [ # # ][ # # ]: 0 : nCurUserEvent = Application::PostUserEvent(LINK(this,SvImpLBox,MyUserEvent),(void*)1);
896 : : return;
897 : : }
898 : : }
899 : :
900 [ - + ]: 173 : if( !pStartEntry )
901 : : {
902 [ # # ]: 0 : pStartEntry = pView->First();
903 : : }
904 : :
905 [ + + ]: 173 : if( nNodeBmpTabDistance == NODE_BMP_TABDIST_NOTVALID )
906 [ + - ]: 120 : SetNodeBmpTabDistance();
907 : :
908 [ + - ]: 173 : long nRectHeight = rRect.GetHeight();
909 : 173 : long nEntryHeight = pView->GetEntryHeight();
910 : :
911 : : // calculate area for the entries we want to draw
912 : 173 : sal_uInt16 nStartLine = (sal_uInt16)( rRect.Top() / nEntryHeight );
913 : 173 : sal_uInt16 nCount = (sal_uInt16)( nRectHeight / nEntryHeight );
914 : 173 : nCount += 2; // don't miss a row
915 : :
916 : 173 : long nY = nStartLine * nEntryHeight;
917 : 173 : SvLBoxEntry* pEntry = pStartEntry;
918 [ - + ][ # # ]: 173 : while( nStartLine && pEntry )
[ - + ]
919 : : {
920 [ # # ]: 0 : pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
921 : 0 : nStartLine--;
922 : : }
923 : :
924 [ + - ][ + - ]: 173 : Region aClipRegion( GetClipRegionRect() );
925 : :
926 : : // first draw the lines, then clip them!
927 [ + - ]: 173 : pView->SetClipRegion();
928 [ + + ]: 173 : if( m_nStyle & ( WB_HASLINES | WB_HASLINESATROOT ) )
929 [ + - ]: 12 : DrawNet();
930 : :
931 [ + - ]: 173 : pView->SetClipRegion( aClipRegion );
932 : :
933 [ + - ][ + + ]: 3408 : for( sal_uInt16 n=0; n< nCount && pEntry; n++ )
[ + + ]
934 : : {
935 : : /*long nMaxRight=*/
936 [ + - ]: 3235 : pView->PaintEntry1( pEntry, nY, 0xffff, sal_True );
937 : 3235 : nY += nEntryHeight;
938 [ + - ]: 3235 : pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
939 : : }
940 : :
941 [ + + ][ + - ]: 173 : if ( !pCursor && ( ( nExtendedWinBits & EWB_NO_AUTO_CURENTRY ) == 0 ) )
942 : : {
943 : : // do not select if multiselection or explicit set
944 : 4 : sal_Bool bNotSelect = ( aSelEng.GetSelectionMode() == MULTIPLE_SELECTION )
945 [ - + ][ + - ]: 4 : || ( ( m_nStyle & WB_NOINITIALSELECTION ) == WB_NOINITIALSELECTION );
946 [ + - ]: 4 : SetCursor( pStartEntry, bNotSelect );
947 : : }
948 : :
949 : 173 : nFlags &= (~F_DESEL_ALL);
950 [ + - ]: 173 : pView->SetClipRegion();
951 [ + - ]: 173 : Rectangle aRect;
952 [ + + ]: 173 : if( !(nFlags & F_PAINTED) )
953 : : {
954 : 128 : nFlags |= F_PAINTED;
955 : 128 : RepaintScrollBars();
956 : : }
957 [ + - ]: 173 : nFlags &= (~F_IN_PAINT);
958 : : }
959 : :
960 : 551 : void SvImpLBox::MakeVisible( SvLBoxEntry* pEntry, sal_Bool bMoveToTop )
961 : : {
962 [ - + ]: 551 : if( !pEntry )
963 : 0 : return;
964 : :
965 : 551 : sal_Bool bInView = IsEntryInView( pEntry );
966 : :
967 [ - + ][ # # ]: 551 : if( bInView && (!bMoveToTop || pStartEntry == pEntry) )
[ + - ]
968 : 551 : return; // is already visible
969 : :
970 [ # # ][ # # ]: 0 : if( pStartEntry || (m_nStyle & WB_FORCE_MAKEVISIBLE) )
971 : 0 : nFlags &= (~F_FILLING);
972 [ # # ]: 0 : if( !bInView )
973 : : {
974 [ # # ]: 0 : if( !pView->IsEntryVisible(pEntry) ) // Parent(s) collapsed?
975 : : {
976 : 0 : SvLBoxEntry* pParent = pView->GetParent( pEntry );
977 [ # # ]: 0 : while( pParent )
978 : : {
979 [ # # ]: 0 : if( !pView->IsExpanded( pParent ) )
980 : : {
981 : : #ifdef DBG_UTIL
982 : : sal_Bool bRet =
983 : : #endif
984 : 0 : pView->Expand( pParent );
985 : : DBG_ASSERT(bRet,"Not expanded!");
986 : : }
987 : 0 : pParent = pView->GetParent( pParent );
988 : : }
989 : : // do the parent's children fit into the view or do we have to scroll?
990 [ # # ][ # # ]: 0 : if( IsEntryInView( pEntry ) && !bMoveToTop )
[ # # ]
991 : 0 : return; // no need to scroll
992 : : }
993 : : }
994 : :
995 : 0 : pStartEntry = pEntry;
996 : 0 : ShowCursor( sal_False );
997 : 0 : FillView();
998 : 0 : aVerSBar.SetThumbPos( (long)(pView->GetVisiblePos( pStartEntry )) );
999 : 0 : ShowCursor( sal_True );
1000 : 551 : pView->Invalidate();
1001 : : }
1002 : :
1003 : 0 : void SvImpLBox::ScrollToAbsPos( long nPos )
1004 : : {
1005 [ # # ]: 0 : if( pView->GetVisibleCount() == 0 )
1006 : 0 : return;
1007 : 0 : long nLastEntryPos = pView->GetAbsPos( pView->Last() );
1008 : :
1009 [ # # ]: 0 : if( nPos < 0 )
1010 : 0 : nPos = 0;
1011 [ # # ]: 0 : else if( nPos > nLastEntryPos )
1012 : 0 : nPos = nLastEntryPos;
1013 : :
1014 : 0 : SvLBoxEntry* pEntry = (SvLBoxEntry*)pView->GetEntryAtAbsPos( nPos );
1015 [ # # ][ # # ]: 0 : if( !pEntry || pEntry == pStartEntry )
1016 : 0 : return;
1017 : :
1018 [ # # ][ # # ]: 0 : if( pStartEntry || (m_nStyle & WB_FORCE_MAKEVISIBLE) )
1019 : 0 : nFlags &= (~F_FILLING);
1020 : :
1021 [ # # ]: 0 : if( pView->IsEntryVisible(pEntry) )
1022 : : {
1023 : 0 : pStartEntry = pEntry;
1024 : 0 : ShowCursor( sal_False );
1025 : 0 : aVerSBar.SetThumbPos( nPos );
1026 : 0 : ShowCursor( sal_True );
1027 [ # # ]: 0 : if (GetUpdateMode())
1028 : 0 : pView->Invalidate();
1029 : : }
1030 : : }
1031 : :
1032 : 12 : void SvImpLBox::DrawNet()
1033 : : {
1034 [ + - ][ + + ]: 15 : if( pView->GetVisibleCount() < 2 && !pStartEntry->HasChildrenOnDemand() &&
[ + - - + ]
[ + - ]
1035 : 3 : !pStartEntry->HasChildren() )
1036 : : return;
1037 : :
1038 : : // for platforms that don't have nets, DrawNativeControl does nothing and returns true
1039 : : // so that SvImpLBox::DrawNet() doesn't draw anything either
1040 [ + - ][ - + ]: 12 : if(pView->IsNativeControlSupported( CTRL_LISTNET, PART_ENTIRE_CONTROL)) {
1041 : 0 : ImplControlValue aControlValue;
1042 : 0 : Point aTemp(0,0); // temporary needed for g++ 3.3.5
1043 [ # # ]: 0 : Rectangle aCtrlRegion( aTemp, Size( 0, 0 ) );
1044 : 0 : ControlState nState = CTRL_STATE_ENABLED;
1045 [ # # ]: 0 : if( pView->DrawNativeControl( CTRL_LISTNET, PART_ENTIRE_CONTROL,
1046 [ # # ]: 0 : aCtrlRegion, nState, aControlValue, rtl::OUString() ) )
1047 : : {
1048 : : return;
1049 [ # # ][ # # ]: 0 : }
1050 : :
1051 : : }
1052 : :
1053 : 12 : long nEntryHeight = pView->GetEntryHeight();
1054 : 12 : long nEntryHeightDIV2 = nEntryHeight / 2;
1055 [ - + ][ + - ]: 12 : if( nEntryHeightDIV2 && !(nEntryHeight & 0x0001))
1056 : 0 : nEntryHeightDIV2--;
1057 : :
1058 : : SvLBoxEntry* pChild;
1059 : 12 : SvLBoxEntry* pEntry = pStartEntry;
1060 : :
1061 [ + - ]: 12 : SvLBoxTab* pFirstDynamicTab = pView->GetFirstDynamicTab();
1062 [ + - ][ - + ]: 12 : while( pTree->GetDepth( pEntry ) > 0 )
1063 [ # # ]: 0 : pEntry = pView->GetParent( pEntry );
1064 [ + - ]: 12 : sal_uInt16 nOffs = (sal_uInt16)(pView->GetVisiblePos( pStartEntry ) -
1065 [ + - ]: 12 : pView->GetVisiblePos( pEntry ));
1066 : 12 : long nY = 0;
1067 : 12 : nY -= ( nOffs * nEntryHeight );
1068 : :
1069 : : DBG_ASSERT(pFirstDynamicTab,"No Tree!");
1070 : :
1071 : 12 : Color aOldLineColor = pView->GetLineColor();
1072 : 12 : const StyleSettings& rStyleSettings = pView->GetSettings().GetStyleSettings();
1073 : 12 : Color aCol= rStyleSettings.GetFaceColor();
1074 : :
1075 [ + - ][ - + ]: 12 : if( aCol.IsRGBEqual( pView->GetBackground().GetColor()) )
[ + - ]
1076 : 0 : aCol = rStyleSettings.GetShadowColor();
1077 [ + - ]: 12 : pView->SetLineColor( aCol );
1078 : 12 : Point aPos1, aPos2;
1079 : : sal_uInt16 nDistance;
1080 : 12 : sal_uLong nMax = nVisibleCount + nOffs + 1;
1081 : :
1082 : 12 : const Image& rExpandedNodeBitmap = GetExpandedNodeBmp();
1083 : :
1084 [ + - ][ + + ]: 47 : for( sal_uLong n=0; n< nMax && pEntry; n++ )
[ + + ]
1085 : : {
1086 [ + - ][ + + ]: 35 : if( pView->IsExpanded(pEntry) )
1087 : : {
1088 [ + - ]: 14 : aPos1.X() = pView->GetTabPos(pEntry, pFirstDynamicTab);
1089 : : // if it is not a context bitmap, go a little to the right below the
1090 : : // first text (node bitmap, too)
1091 [ - + ]: 14 : if( !pView->nContextBmpWidthMax )
1092 [ # # ]: 0 : aPos1.X() += rExpandedNodeBitmap.GetSizePixel().Width() / 2;
1093 : :
1094 : 14 : aPos1.Y() = nY;
1095 : 14 : aPos1.Y() += nEntryHeightDIV2;
1096 : :
1097 [ + - ]: 14 : pChild = pView->FirstChild( pEntry );
1098 : : DBG_ASSERT(pChild,"Child?");
1099 [ + - ]: 14 : pChild = pTree->LastSibling( pChild );
1100 [ + - ]: 14 : nDistance = (sal_uInt16)(pView->GetVisiblePos(pChild) -
1101 [ + - ]: 14 : pView->GetVisiblePos(pEntry));
1102 : 14 : aPos2 = aPos1;
1103 : 14 : aPos2.Y() += nDistance * nEntryHeight;
1104 [ + - ]: 14 : pView->DrawLine( aPos1, aPos2 );
1105 : : }
1106 : : // visible in control?
1107 [ + - ][ - + ]: 35 : if( n>= nOffs && ((m_nStyle & WB_HASLINESATROOT) || !pTree->IsAtRootDepth(pEntry)))
[ # # ][ + - ]
1108 : : {
1109 : : // can we recycle aPos1?
1110 [ + - ][ + + ]: 35 : if( !pView->IsExpanded(pEntry) )
1111 : : {
1112 : : // nope
1113 [ + - ]: 21 : aPos1.X() = pView->GetTabPos(pEntry, pFirstDynamicTab);
1114 : : // if it is not a context bitmap, go a little to the right below
1115 : : // the first text (node bitmap, too)
1116 [ - + ]: 21 : if( !pView->nContextBmpWidthMax )
1117 [ # # ]: 0 : aPos1.X() += rExpandedNodeBitmap.GetSizePixel().Width() / 2;
1118 : 21 : aPos1.Y() = nY;
1119 : 21 : aPos1.Y() += nEntryHeightDIV2;
1120 : 21 : aPos2.X() = aPos1.X();
1121 : : }
1122 : 35 : aPos2.Y() = aPos1.Y();
1123 : 35 : aPos2.X() -= pView->GetIndent();
1124 [ + - ]: 35 : pView->DrawLine( aPos1, aPos2 );
1125 : : }
1126 : 35 : nY += nEntryHeight;
1127 [ + - ]: 35 : pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
1128 : : }
1129 [ + - ]: 12 : if( m_nStyle & WB_HASLINESATROOT )
1130 : : {
1131 [ + - ]: 12 : pEntry = pView->First();
1132 [ + - ]: 12 : aPos1.X() = pView->GetTabPos( pEntry, pFirstDynamicTab);
1133 : : // if it is not a context bitmap, go a little to the right below the
1134 : : // first text (node bitmap, too)
1135 [ - + ]: 12 : if( !pView->nContextBmpWidthMax )
1136 [ # # ]: 0 : aPos1.X() += rExpandedNodeBitmap.GetSizePixel().Width() / 2;
1137 : 12 : aPos1.X() -= pView->GetIndent();
1138 [ + - ]: 12 : aPos1.Y() = GetEntryLine( pEntry );
1139 : 12 : aPos1.Y() += nEntryHeightDIV2;
1140 [ + - ]: 12 : pChild = pTree->LastSibling( pEntry );
1141 : 12 : aPos2.X() = aPos1.X();
1142 [ + - ]: 12 : aPos2.Y() = GetEntryLine( pChild );
1143 : 12 : aPos2.Y() += nEntryHeightDIV2;
1144 [ + - ]: 12 : pView->DrawLine( aPos1, aPos2 );
1145 : : }
1146 [ + - ]: 12 : pView->SetLineColor( aOldLineColor );
1147 : : }
1148 : :
1149 : 625 : void SvImpLBox::PositionScrollBars( Size& rSize, sal_uInt16 nMask )
1150 : : {
1151 : 625 : long nOverlap = 0;
1152 : :
1153 : 625 : Size aVerSize( nVerSBarWidth, rSize.Height() );
1154 : 625 : Size aHorSize( rSize.Width(), nHorSBarHeight );
1155 : :
1156 [ + + ]: 625 : if( nMask & 0x0001 )
1157 : 2 : aHorSize.Width() -= nVerSBarWidth;
1158 [ + + ]: 625 : if( nMask & 0x0002 )
1159 : 2 : aVerSize.Height() -= nHorSBarHeight;
1160 : :
1161 : 625 : aVerSize.Height() += 2 * nOverlap;
1162 : 625 : Point aVerPos( rSize.Width() - aVerSize.Width() + nOverlap, -nOverlap );
1163 [ + - ]: 625 : aVerSBar.SetPosSizePixel( aVerPos, aVerSize );
1164 : :
1165 : 625 : aHorSize.Width() += 2 * nOverlap;
1166 : 625 : Point aHorPos( -nOverlap, rSize.Height() - aHorSize.Height() + nOverlap );
1167 : :
1168 [ + - ]: 625 : aHorSBar.SetPosSizePixel( aHorPos, aHorSize );
1169 : :
1170 [ + + ]: 625 : if( nMask & 0x0001 )
1171 : 2 : rSize.Width() = aVerPos.X();
1172 [ + + ]: 625 : if( nMask & 0x0002 )
1173 : 2 : rSize.Height() = aHorPos.Y();
1174 : :
1175 [ + + ]: 625 : if( (nMask & (0x0001|0x0002)) == (0x0001|0x0002) )
1176 [ + - ]: 2 : aScrBarBox.Show();
1177 : : else
1178 [ + - ]: 623 : aScrBarBox.Hide();
1179 : 625 : }
1180 : :
1181 : : // nResult: Bit0 == VerSBar Bit1 == HorSBar
1182 : 625 : sal_uInt16 SvImpLBox::AdjustScrollBars( Size& rSize )
1183 : : {
1184 : 625 : long nEntryHeight = pView->GetEntryHeight();
1185 [ - + ]: 625 : if( !nEntryHeight )
1186 : 0 : return 0;
1187 : :
1188 : 625 : sal_uInt16 nResult = 0;
1189 : :
1190 : 625 : Size aOSize( pView->Control::GetOutputSizePixel() );
1191 : :
1192 [ + - ]: 625 : const WinBits nWindowStyle = pView->GetStyle();
1193 : 625 : sal_Bool bVerSBar = ( nWindowStyle & WB_VSCROLL ) != 0;
1194 : 625 : sal_Bool bHorBar = sal_False;
1195 : 625 : long nMaxRight = aOSize.Width(); //GetOutputSize().Width();
1196 : 625 : Point aOrigin( pView->GetMapMode().GetOrigin() );
1197 : 625 : aOrigin.X() *= -1;
1198 : 625 : nMaxRight += aOrigin.X() - 1;
1199 : 625 : long nVis = nMostRight - aOrigin.X();
1200 [ + - ][ + + ]: 625 : if( (nWindowStyle & WB_HSCROLL) &&
[ + + ]
1201 : : (nVis < nMostRight || nMaxRight < nMostRight) )
1202 : : {
1203 : 2 : bHorBar = sal_True;
1204 : : }
1205 : :
1206 : : // number of entries that are not collapsed
1207 [ + - ]: 625 : sal_uLong nTotalCount = pView->GetVisibleCount();
1208 : :
1209 : : // number of entries visible within the view
1210 : 625 : nVisibleCount = aOSize.Height() / nEntryHeight;
1211 : :
1212 : : // do we need a vertical scrollbar?
1213 [ + + ][ + - ]: 625 : if( bVerSBar || nTotalCount > nVisibleCount )
1214 : : {
1215 : 2 : nResult = 1;
1216 : 2 : nFlags |= F_HOR_SBARSIZE_WITH_VBAR;
1217 : 2 : nMaxRight -= nVerSBarWidth;
1218 [ - + ]: 2 : if( !bHorBar )
1219 : : {
1220 [ # # ][ # # ]: 0 : if( (nWindowStyle & WB_HSCROLL) &&
[ # # ]
1221 : : (nVis < nMostRight || nMaxRight < nMostRight) )
1222 : 0 : bHorBar = sal_True;
1223 : : }
1224 : : }
1225 : :
1226 : : // do we need a horizontal scrollbar?
1227 [ + + ]: 625 : if( bHorBar )
1228 : : {
1229 : 2 : nResult |= 0x0002;
1230 : : // the number of entries visible within the view has to be recalculated
1231 : : // because the horizontal scrollbar is now visible.
1232 : 2 : nVisibleCount = (aOSize.Height() - nHorSBarHeight) / nEntryHeight;
1233 : : // we might actually need a vertical scrollbar now
1234 [ # # ][ # # ]: 2 : if( !(nResult & 0x0001) &&
[ - + ]
1235 : : ((nTotalCount > nVisibleCount) || bVerSBar) )
1236 : : {
1237 : 0 : nResult = 3;
1238 : 0 : nFlags |= F_VER_SBARSIZE_WITH_HBAR;
1239 : : }
1240 : : }
1241 : :
1242 [ + - ]: 625 : PositionScrollBars( aOSize, nResult );
1243 : :
1244 : : // adapt Range, VisibleRange etc.
1245 : :
1246 : : // refresh output size, in case we have to scroll
1247 [ + - ]: 625 : Rectangle aRect;
1248 [ + - ]: 625 : aRect.SetSize( aOSize );
1249 : 625 : aSelEng.SetVisibleArea( aRect );
1250 : :
1251 : : // vertical scrollbar
1252 : 625 : long nTemp = (long)nVisibleCount;
1253 : 625 : nTemp--;
1254 [ + + ]: 625 : if( nTemp != aVerSBar.GetVisibleSize() )
1255 : : {
1256 [ + - ]: 375 : if( !bInVScrollHdl )
1257 : : {
1258 : 375 : aVerSBar.SetPageSize( nTemp - 1 );
1259 [ + - ]: 375 : aVerSBar.SetVisibleSize( nTemp );
1260 : : }
1261 : : else
1262 : : {
1263 : 0 : nFlags |= F_ENDSCROLL_SET_VIS_SIZE;
1264 : 0 : nNextVerVisSize = nTemp;
1265 : : }
1266 : : }
1267 : :
1268 : : // horizontal scrollbar
1269 : 625 : nTemp = aHorSBar.GetThumbPos();
1270 [ + - ]: 625 : aHorSBar.SetVisibleSize( aOSize.Width() );
1271 : 625 : long nNewThumbPos = aHorSBar.GetThumbPos();
1272 : 625 : Range aRange( aHorSBar.GetRange() );
1273 [ + + ]: 625 : if( aRange.Max() < nMostRight+25 )
1274 : : {
1275 : 370 : aRange.Max() = nMostRight+25;
1276 [ + - ]: 370 : aHorSBar.SetRange( aRange );
1277 : : }
1278 : :
1279 [ - + ]: 625 : if( nTemp != nNewThumbPos )
1280 : : {
1281 : 0 : nTemp = nNewThumbPos - nTemp;
1282 [ # # ]: 0 : if( pView->IsEditingActive() )
1283 : : {
1284 [ # # ]: 0 : pView->EndEditing( sal_True ); // Cancel
1285 [ # # ]: 0 : pView->Update();
1286 : : }
1287 : 0 : pView->nFocusWidth = -1;
1288 [ # # ]: 0 : KeyLeftRight( nTemp );
1289 : : }
1290 : :
1291 [ + + ]: 625 : if( nResult & 0x0001 )
1292 [ + - ]: 2 : aVerSBar.Show();
1293 : : else
1294 [ + - ]: 623 : aVerSBar.Hide();
1295 : :
1296 [ + + ]: 625 : if( nResult & 0x0002 )
1297 [ + - ]: 2 : aHorSBar.Show();
1298 : : else
1299 : : {
1300 [ + - ]: 623 : aHorSBar.Hide();
1301 : : }
1302 : 625 : rSize = aOSize;
1303 : 625 : return nResult;
1304 : : }
1305 : :
1306 : 253 : void SvImpLBox::InitScrollBarBox()
1307 : : {
1308 [ + - ]: 253 : aScrBarBox.SetSizePixel( Size(nVerSBarWidth, nHorSBarHeight) );
1309 : 253 : Size aSize( pView->Control::GetOutputSizePixel() );
1310 [ + - ]: 253 : aScrBarBox.SetPosPixel( Point(aSize.Width()-nVerSBarWidth, aSize.Height()-nHorSBarHeight));
1311 : 253 : }
1312 : :
1313 : 497 : void SvImpLBox::Resize()
1314 : : {
1315 : 497 : Size aSize( pView->Control::GetOutputSizePixel());
1316 [ - + ][ + + ]: 497 : if( aSize.Width() <= 0 || aSize.Height() <= 0 )
[ + + ]
1317 : 497 : return;
1318 : 253 : nFlags |= F_IN_RESIZE;
1319 [ + - ]: 253 : InitScrollBarBox();
1320 : :
1321 [ + - ]: 253 : if( pView->GetEntryHeight())
1322 : : {
1323 [ + - ]: 253 : AdjustScrollBars( aOutputSize );
1324 [ + - ]: 253 : FillView();
1325 : : }
1326 : : // HACK, as in floating and docked windows the scrollbars might not be drawn
1327 : : // correctly/not be drawn at all after resizing!
1328 [ + - ][ - + ]: 253 : if( aHorSBar.IsVisible())
1329 [ # # ]: 0 : aHorSBar.Invalidate();
1330 [ + - ][ - + ]: 253 : if( aVerSBar.IsVisible())
1331 [ # # ]: 0 : aVerSBar.Invalidate();
1332 : 497 : nFlags &= (~(F_IN_RESIZE | F_PAINTED));
1333 : : }
1334 : :
1335 : 373 : void SvImpLBox::FillView()
1336 : : {
1337 [ + + ]: 373 : if( !pStartEntry )
1338 : : {
1339 : 122 : sal_uInt16 nVisibleViewCount = (sal_uInt16)(pView->GetVisibleCount());
1340 : 122 : sal_uInt16 nTempThumb = (sal_uInt16)aVerSBar.GetThumbPos();
1341 [ - + ]: 122 : if( nTempThumb >= nVisibleViewCount )
1342 : 0 : nTempThumb = nVisibleViewCount - 1;
1343 : 122 : pStartEntry = (SvLBoxEntry*)(pView->GetEntryAtVisPos(nTempThumb));
1344 : : }
1345 [ + - ]: 373 : if( pStartEntry )
1346 : : {
1347 : 373 : sal_uInt16 nLast = (sal_uInt16)(pView->GetVisiblePos( (SvLBoxEntry*)(pView->LastVisible())));
1348 : 373 : sal_uInt16 nThumb = (sal_uInt16)(pView->GetVisiblePos( pStartEntry ));
1349 : 373 : sal_uInt16 nCurDispEntries = nLast-nThumb+1;
1350 [ + - ]: 373 : if( nCurDispEntries < nVisibleCount )
1351 : : {
1352 : 373 : ShowCursor( sal_False );
1353 : : // fill window by moving the thumb up incrementally
1354 : 373 : sal_Bool bFound = sal_False;
1355 : 373 : SvLBoxEntry* pTemp = pStartEntry;
1356 [ + - ][ + + ]: 746 : while( nCurDispEntries < nVisibleCount && pTemp )
[ + + ]
1357 : : {
1358 : 373 : pTemp = (SvLBoxEntry*)(pView->PrevVisible(pStartEntry));
1359 [ - + ]: 373 : if( pTemp )
1360 : : {
1361 : 0 : nThumb--;
1362 : 0 : pStartEntry = pTemp;
1363 : 0 : nCurDispEntries++;
1364 : 0 : bFound = sal_True;
1365 : : }
1366 : : }
1367 [ - + ]: 373 : if( bFound )
1368 : : {
1369 : 0 : aVerSBar.SetThumbPos( nThumb );
1370 : 0 : ShowCursor( sal_True ); // recalculate focus rectangle
1371 : 0 : pView->Invalidate();
1372 : : }
1373 : : }
1374 : : }
1375 : 373 : }
1376 : :
1377 : :
1378 : :
1379 : :
1380 : 130 : void SvImpLBox::ShowVerSBar()
1381 : : {
1382 [ + - ]: 130 : sal_Bool bVerBar = ( pView->GetStyle() & WB_VSCROLL ) != 0;
1383 : 130 : sal_uLong nVis = 0;
1384 [ + - ]: 130 : if( !bVerBar )
1385 [ + - ]: 130 : nVis = pView->GetVisibleCount();
1386 [ + - ][ + + ]: 130 : if( bVerBar || (nVisibleCount && nVis > (sal_uLong)(nVisibleCount-1)) )
[ - + ]
1387 : : {
1388 [ # # ][ # # ]: 0 : if( !aVerSBar.IsVisible() )
1389 : : {
1390 : 0 : pView->nFocusWidth = -1;
1391 [ # # ]: 0 : AdjustScrollBars( aOutputSize );
1392 [ # # ]: 0 : if( GetUpdateMode() )
1393 [ # # ]: 0 : aVerSBar.Update();
1394 : : }
1395 : : }
1396 : : else
1397 : : {
1398 [ + - ][ - + ]: 130 : if( aVerSBar.IsVisible() )
1399 : : {
1400 : 0 : pView->nFocusWidth = -1;
1401 [ # # ]: 0 : AdjustScrollBars( aOutputSize );
1402 : : }
1403 : : }
1404 : :
1405 : 130 : long nMaxRight = GetOutputSize().Width();
1406 : 130 : Point aPos( pView->GetMapMode().GetOrigin() );
1407 : 130 : aPos.X() *= -1; // convert document coordinates
1408 : 130 : nMaxRight = nMaxRight + aPos.X() - 1;
1409 [ + + ]: 130 : if( nMaxRight < nMostRight )
1410 : : {
1411 [ + - ][ + - ]: 2 : if( !aHorSBar.IsVisible() )
1412 : : {
1413 : 2 : pView->nFocusWidth = -1;
1414 [ + - ]: 2 : AdjustScrollBars( aOutputSize );
1415 [ + - ]: 2 : if( GetUpdateMode() )
1416 [ + - ]: 2 : aHorSBar.Update();
1417 : : }
1418 : : else
1419 : : {
1420 : 0 : Range aRange( aHorSBar.GetRange() );
1421 [ # # ]: 0 : if( aRange.Max() < nMostRight+25 )
1422 : : {
1423 : 0 : aRange.Max() = nMostRight+25;
1424 [ # # ]: 0 : aHorSBar.SetRange( aRange );
1425 : : }
1426 : : else
1427 : : {
1428 : 0 : pView->nFocusWidth = -1;
1429 [ # # ]: 0 : AdjustScrollBars( aOutputSize );
1430 : : }
1431 : : }
1432 : : }
1433 : : else
1434 : : {
1435 [ + - ][ - + ]: 128 : if( aHorSBar.IsVisible() )
1436 : : {
1437 : 0 : pView->nFocusWidth = -1;
1438 [ # # ]: 0 : AdjustScrollBars( aOutputSize );
1439 : : }
1440 : : }
1441 : 130 : }
1442 : :
1443 : :
1444 : 126 : void SvImpLBox::SyncVerThumb()
1445 : : {
1446 [ + + ]: 126 : if( pStartEntry )
1447 : : {
1448 : 4 : long nEntryPos = pView->GetVisiblePos( pStartEntry );
1449 : 4 : aVerSBar.SetThumbPos( nEntryPos );
1450 : : }
1451 : : else
1452 : 122 : aVerSBar.SetThumbPos( 0 );
1453 : 126 : }
1454 : :
1455 : 551 : sal_Bool SvImpLBox::IsEntryInView( SvLBoxEntry* pEntry ) const
1456 : : {
1457 : : // parent collapsed
1458 [ - + ]: 551 : if( !pView->IsEntryVisible(pEntry) )
1459 : 0 : return sal_False;
1460 : 551 : long nY = GetEntryLine( pEntry );
1461 [ - + ]: 551 : if( nY < 0 )
1462 : 0 : return sal_False;
1463 : 551 : long nMax = nVisibleCount * pView->GetEntryHeight();
1464 [ - + ]: 551 : if( nY >= nMax )
1465 : 0 : return sal_False;
1466 : 551 : return sal_True;
1467 : : }
1468 : :
1469 : :
1470 : 847 : long SvImpLBox::GetEntryLine( SvLBoxEntry* pEntry ) const
1471 : : {
1472 [ + + ]: 847 : if(!pStartEntry )
1473 : 4 : return -1; // invisible position
1474 : :
1475 : 843 : long nFirstVisPos = pView->GetVisiblePos( pStartEntry );
1476 : 843 : long nEntryVisPos = pView->GetVisiblePos( pEntry );
1477 : 843 : nFirstVisPos = nEntryVisPos - nFirstVisPos;
1478 : 843 : nFirstVisPos *= pView->GetEntryHeight();
1479 : 847 : return nFirstVisPos;
1480 : : }
1481 : :
1482 : 370 : void SvImpLBox::SetEntryHeight( short /* nHeight */ )
1483 : : {
1484 : 370 : SetNodeBmpYOffset( GetExpandedNodeBmp() );
1485 : 370 : SetNodeBmpYOffset( GetCollapsedNodeBmp() );
1486 [ + - ]: 370 : if(!pView->HasViewData()) // are we within the Clear?
1487 : : {
1488 : 370 : Size aSize = pView->Control::GetOutputSizePixel();
1489 [ + - ]: 370 : AdjustScrollBars( aSize );
1490 : : }
1491 : : else
1492 : : {
1493 : 0 : Resize();
1494 [ # # ]: 0 : if( GetUpdateMode() )
1495 : 0 : pView->Invalidate();
1496 : : }
1497 : 370 : }
1498 : :
1499 : :
1500 : :
1501 : : // ***********************************************************************
1502 : : // Callback Functions
1503 : : // ***********************************************************************
1504 : :
1505 : 4 : void SvImpLBox::EntryExpanded( SvLBoxEntry* pEntry )
1506 : : {
1507 : : // SelAllDestrAnch( sal_False, sal_True ); //DeselectAll();
1508 [ + - ]: 4 : if( GetUpdateMode() )
1509 : : {
1510 : 4 : ShowCursor( sal_False );
1511 : 4 : long nY = GetEntryLine( pEntry );
1512 [ + - ]: 4 : if( IsLineVisible(nY) )
1513 : : {
1514 : 4 : InvalidateEntriesFrom( nY );
1515 : 4 : FindMostRight( pEntry, 0 );
1516 : : }
1517 [ + - ]: 4 : aVerSBar.SetRange( Range(0, pView->GetVisibleCount()-1 ) );
1518 : : // if we expanded before the thumb, the thumb's position has to be
1519 : : // corrected
1520 : 4 : SyncVerThumb();
1521 : 4 : ShowVerSBar();
1522 : 4 : ShowCursor( sal_True );
1523 : : }
1524 : 4 : }
1525 : :
1526 : 0 : void SvImpLBox::EntryCollapsed( SvLBoxEntry* pEntry )
1527 : : {
1528 [ # # ]: 0 : if( !pView->IsEntryVisible( pEntry ) )
1529 : 0 : return;
1530 : :
1531 : 0 : ShowCursor( sal_False );
1532 : :
1533 [ # # ][ # # ]: 0 : if( !pMostRightEntry || pTree->IsChild( pEntry,pMostRightEntry ) )
[ # # ]
1534 : : {
1535 : 0 : FindMostRight(0);
1536 : : }
1537 : :
1538 [ # # ]: 0 : if( pStartEntry )
1539 : : {
1540 : 0 : long nOldThumbPos = aVerSBar.GetThumbPos();
1541 : 0 : sal_uLong nVisList = pView->GetVisibleCount();
1542 [ # # ]: 0 : aVerSBar.SetRange( Range(0, nVisList-1) );
1543 : 0 : long nNewThumbPos = aVerSBar.GetThumbPos();
1544 [ # # ]: 0 : if( nNewThumbPos != nOldThumbPos )
1545 : : {
1546 [ # # ]: 0 : pStartEntry = pView->First();
1547 : 0 : sal_uInt16 nDistance = (sal_uInt16)nNewThumbPos;
1548 [ # # ]: 0 : if( nDistance )
1549 : : pStartEntry = (SvLBoxEntry*)(pView->NextVisible( pStartEntry,
1550 [ # # ]: 0 : nDistance));
1551 [ # # ]: 0 : if( GetUpdateMode() )
1552 [ # # ]: 0 : pView->Invalidate();
1553 : : }
1554 : : else
1555 : 0 : SyncVerThumb();
1556 : 0 : ShowVerSBar();
1557 : : }
1558 : : // has the cursor been collapsed?
1559 [ # # ]: 0 : if( pTree->IsChild( pEntry, pCursor ) )
1560 : 0 : SetCursor( pEntry );
1561 [ # # ]: 0 : if( GetUpdateMode() )
1562 : 0 : ShowVerSBar();
1563 : 0 : ShowCursor( sal_True );
1564 [ # # ][ # # ]: 0 : if( GetUpdateMode() && pCursor )
[ # # ]
1565 : 0 : pView->Select( pCursor, sal_True );
1566 : : }
1567 : :
1568 : 0 : void SvImpLBox::CollapsingEntry( SvLBoxEntry* pEntry )
1569 : : {
1570 [ # # ][ # # ]: 0 : if( !pView->IsEntryVisible( pEntry ) || !pStartEntry )
[ # # ]
1571 : 0 : return;
1572 : :
1573 : 0 : SelAllDestrAnch( sal_False, sal_True ); // deselect all
1574 : :
1575 : : // is the collapsed cursor visible?
1576 : 0 : long nY = GetEntryLine( pEntry );
1577 [ # # ]: 0 : if( IsLineVisible(nY) )
1578 : : {
1579 [ # # ]: 0 : if( GetUpdateMode() )
1580 : 0 : InvalidateEntriesFrom( nY );
1581 : : }
1582 : : else
1583 : : {
1584 [ # # ]: 0 : if( pTree->IsChild(pEntry, pStartEntry) )
1585 : : {
1586 : 0 : pStartEntry = pEntry;
1587 [ # # ]: 0 : if( GetUpdateMode() )
1588 : 0 : pView->Invalidate();
1589 : : }
1590 : : }
1591 : : }
1592 : :
1593 : :
1594 : 744 : void SvImpLBox::SetNodeBmpYOffset( const Image& rBmp )
1595 : : {
1596 : 744 : Size aSize;
1597 [ + - ]: 744 : nYoffsNodeBmp = pView->GetHeightOffset( rBmp, aSize );
1598 : 744 : nNodeBmpWidth = aSize.Width();
1599 : 744 : }
1600 : :
1601 : 120 : void SvImpLBox::SetNodeBmpTabDistance()
1602 : : {
1603 : 120 : nNodeBmpTabDistance = -pView->GetIndent();
1604 [ + + ]: 120 : if( pView->nContextBmpWidthMax )
1605 : : {
1606 : : // only if the first dynamic tab is centered (we currently assume that)
1607 [ + - ]: 2 : Size aSize = GetExpandedNodeBmp().GetSizePixel();
1608 : 2 : nNodeBmpTabDistance -= aSize.Width() / 2;
1609 : : }
1610 : 120 : }
1611 : :
1612 : : //
1613 : : // corrects the cursor when using SingleSelection
1614 : : //
1615 : 124 : void SvImpLBox::EntrySelected( SvLBoxEntry* pEntry, sal_Bool bSelect )
1616 : : {
1617 [ - + ]: 124 : if( nFlags & F_IGNORE_SELECT )
1618 : 124 : return;
1619 : :
1620 : 124 : nFlags &= (~F_DESEL_ALL);
1621 [ + + + - ]: 246 : if( bSelect &&
[ + + ][ + + ]
1622 : 122 : aSelEng.GetSelectionMode() == SINGLE_SELECTION &&
1623 : : pEntry != pCursor )
1624 : : {
1625 : 118 : SetCursor( pEntry );
1626 : : DBG_ASSERT(pView->GetSelectionCount()==1,"selection count?");
1627 : : }
1628 : :
1629 [ + - ][ + - ]: 124 : if( GetUpdateMode() && pView->IsEntryVisible(pEntry) )
[ + - ]
1630 : : {
1631 : 124 : long nY = GetEntryLine( pEntry );
1632 [ + - ]: 124 : if( IsLineVisible( nY ) )
1633 : : {
1634 : 124 : ShowCursor( sal_False );
1635 : 124 : pView->PaintEntry1( pEntry, nY, 0xffff ); // because of ItemsetBrowser SV_LBOXTAB_SHOW_SELECTION );
1636 : 124 : ShowCursor( sal_True );
1637 : : }
1638 : : }
1639 : : }
1640 : :
1641 : :
1642 : 0 : void SvImpLBox::RemovingEntry( SvLBoxEntry* pEntry )
1643 : : {
1644 : 0 : DestroyAnchor();
1645 : :
1646 [ # # ]: 0 : if( !pView->IsEntryVisible( pEntry ) )
1647 : : {
1648 : : // if parent is collapsed => bye!
1649 : 0 : nFlags |= F_REMOVED_ENTRY_INVISIBLE;
1650 : 0 : return;
1651 : : }
1652 : :
1653 [ # # # # : 0 : if( pEntry == pMostRightEntry || (
# # # # ]
[ # # ]
1654 : 0 : pEntry->HasChildren() && pView->IsExpanded(pEntry) &&
1655 : 0 : pTree->IsChild(pEntry, pMostRightEntry)))
1656 : : {
1657 : 0 : nFlags |= F_REMOVED_RECALC_MOST_RIGHT;
1658 : : }
1659 : :
1660 : 0 : SvLBoxEntry* pOldStartEntry = pStartEntry;
1661 : :
1662 : 0 : SvLBoxEntry* pParent = (SvLBoxEntry*)(pView->GetModel()->GetParent(pEntry));
1663 : :
1664 [ # # ][ # # ]: 0 : if( pParent && pView->GetModel()->GetChildList(pParent)->size() == 1 )
[ # # ]
1665 : : {
1666 : : DBG_ASSERT( pView->IsExpanded( pParent ), "Parent not expanded");
1667 : 0 : pParent->SetFlags( pParent->GetFlags() | SV_ENTRYFLAG_NO_NODEBMP);
1668 : 0 : InvalidateEntry( pParent );
1669 : : }
1670 : :
1671 [ # # ][ # # ]: 0 : if( pCursor && pTree->IsChild( pEntry, pCursor) )
[ # # ]
1672 : 0 : pCursor = pEntry;
1673 [ # # ][ # # ]: 0 : if( pStartEntry && pTree->IsChild(pEntry,pStartEntry) )
[ # # ]
1674 : 0 : pStartEntry = pEntry;
1675 : :
1676 : : SvLBoxEntry* pTemp;
1677 [ # # ][ # # ]: 0 : if( pCursor && pCursor == pEntry )
1678 : : {
1679 [ # # ]: 0 : if( bSimpleTravel )
1680 : 0 : pView->Select( pCursor, sal_False );
1681 : 0 : ShowCursor( sal_False ); // focus rectangle gone
1682 : : // NextSibling, because we also delete the children of the cursor
1683 : 0 : pTemp = pView->NextSibling( pCursor );
1684 [ # # ]: 0 : if( !pTemp )
1685 : 0 : pTemp = (SvLBoxEntry*)(pView->PrevVisible( pCursor ));
1686 : :
1687 : 0 : SetCursor( pTemp, sal_True );
1688 : : }
1689 [ # # ][ # # ]: 0 : if( pStartEntry && pStartEntry == pEntry )
1690 : : {
1691 : 0 : pTemp = pView->NextSibling( pStartEntry );
1692 [ # # ]: 0 : if( !pTemp )
1693 : 0 : pTemp = (SvLBoxEntry*)(pView->PrevVisible( pStartEntry ));
1694 : 0 : pStartEntry = pTemp;
1695 : : }
1696 [ # # ]: 0 : if( GetUpdateMode())
1697 : : {
1698 : : // if it is the last one, we have to invalidate it, so the lines are
1699 : : // drawn correctly (in this case they're deleted)
1700 [ # # ][ # # ]: 0 : if( pStartEntry && (pStartEntry != pOldStartEntry || pEntry == (SvLBoxEntry*)pView->GetModel()->Last()) )
[ # # ][ # # ]
1701 : : {
1702 : 0 : aVerSBar.SetThumbPos( pView->GetVisiblePos( pStartEntry ));
1703 [ # # ]: 0 : pView->Invalidate( GetVisibleArea() );
1704 : : }
1705 : : else
1706 : 0 : InvalidateEntriesFrom( GetEntryLine( pEntry ) );
1707 : : }
1708 : : }
1709 : :
1710 : 0 : void SvImpLBox::EntryRemoved()
1711 : : {
1712 [ # # ]: 0 : if( nFlags & F_REMOVED_ENTRY_INVISIBLE )
1713 : : {
1714 : 0 : nFlags &= (~F_REMOVED_ENTRY_INVISIBLE);
1715 : 0 : return;
1716 : : }
1717 [ # # ]: 0 : if( !pStartEntry )
1718 : 0 : pStartEntry = pTree->First();
1719 [ # # ]: 0 : if( !pCursor )
1720 : 0 : SetCursor( pStartEntry, sal_True );
1721 : :
1722 [ # # ][ # # ]: 0 : if( pCursor && (bSimpleTravel || !pView->GetSelectionCount() ))
[ # # ][ # # ]
1723 : 0 : pView->Select( pCursor, sal_True );
1724 : :
1725 [ # # ]: 0 : if( GetUpdateMode())
1726 : : {
1727 [ # # ]: 0 : if( nFlags & F_REMOVED_RECALC_MOST_RIGHT )
1728 : 0 : FindMostRight(0);
1729 [ # # ]: 0 : aVerSBar.SetRange( Range(0, pView->GetVisibleCount()-1 ) );
1730 : 0 : FillView();
1731 [ # # ]: 0 : if( pStartEntry )
1732 : : // if something above the thumb was deleted
1733 : 0 : aVerSBar.SetThumbPos( pView->GetVisiblePos( pStartEntry) );
1734 : :
1735 : 0 : ShowVerSBar();
1736 [ # # ][ # # ]: 0 : if( pCursor && pView->HasFocus() && !pView->IsSelected(pCursor) )
[ # # ][ # # ]
1737 : : {
1738 [ # # ]: 0 : if( pView->GetSelectionCount() )
1739 : : {
1740 : : // is a neighboring entry selected?
1741 : 0 : SvLBoxEntry* pNextCursor = (SvLBoxEntry*)pView->PrevVisible( pCursor );
1742 [ # # ][ # # ]: 0 : if( !pNextCursor || !pView->IsSelected( pNextCursor ))
[ # # ]
1743 : 0 : pNextCursor = (SvLBoxEntry*)pView->NextVisible( pCursor );
1744 [ # # ][ # # ]: 0 : if( !pNextCursor || !pView->IsSelected( pNextCursor ))
[ # # ]
1745 : : // no neighbor selected: use first selected
1746 : 0 : pNextCursor = pView->FirstSelected();
1747 : 0 : SetCursor( pNextCursor );
1748 : 0 : MakeVisible( pCursor );
1749 : : }
1750 : : else
1751 : 0 : pView->Select( pCursor, sal_True );
1752 : : }
1753 : 0 : ShowCursor( sal_True );
1754 : : }
1755 : 0 : nFlags &= (~F_REMOVED_RECALC_MOST_RIGHT);
1756 : : }
1757 : :
1758 : :
1759 : 0 : void SvImpLBox::MovingEntry( SvLBoxEntry* pEntry )
1760 : : {
1761 : 0 : int bDeselAll = nFlags & F_DESEL_ALL;
1762 : 0 : SelAllDestrAnch( sal_False, sal_True ); // DeselectAll();
1763 [ # # ]: 0 : if( !bDeselAll )
1764 : 0 : nFlags &= (~F_DESEL_ALL);
1765 : :
1766 [ # # ]: 0 : if( pEntry == pCursor )
1767 : 0 : ShowCursor( sal_False );
1768 [ # # ]: 0 : if( IsEntryInView( pEntry ) )
1769 : 0 : pView->Invalidate();
1770 [ # # ]: 0 : if( pEntry == pStartEntry )
1771 : : {
1772 : 0 : SvLBoxEntry* pNew = 0;
1773 [ # # ]: 0 : if( !pEntry->HasChildren() )
1774 : : {
1775 : 0 : pNew = (SvLBoxEntry*)(pView->NextVisible( pStartEntry ));
1776 [ # # ]: 0 : if( !pNew )
1777 : 0 : pNew = (SvLBoxEntry*)(pView->PrevVisible( pStartEntry ));
1778 : : }
1779 : : else
1780 : : {
1781 : 0 : pNew = pTree->NextSibling( pEntry );
1782 [ # # ]: 0 : if( !pNew )
1783 : 0 : pNew = pTree->PrevSibling( pEntry );
1784 : : }
1785 : 0 : pStartEntry = pNew;
1786 : : }
1787 : 0 : }
1788 : :
1789 : 0 : void SvImpLBox::EntryMoved( SvLBoxEntry* pEntry )
1790 : : {
1791 : 0 : UpdateContextBmpWidthVectorFromMovedEntry( pEntry );
1792 : :
1793 [ # # ]: 0 : if ( !pStartEntry )
1794 : : // this might happen if the only entry in the view is moved to its very same position
1795 : : // #i97346#
1796 : 0 : pStartEntry = pView->First();
1797 : :
1798 [ # # ]: 0 : aVerSBar.SetRange( Range(0, pView->GetVisibleCount()-1));
1799 : 0 : sal_uInt16 nFirstPos = (sal_uInt16)pTree->GetAbsPos( pStartEntry );
1800 : 0 : sal_uInt16 nNewPos = (sal_uInt16)pTree->GetAbsPos( pEntry );
1801 : 0 : FindMostRight(0);
1802 [ # # ]: 0 : if( nNewPos < nFirstPos ) // HACK!
1803 : 0 : pStartEntry = pEntry;
1804 : 0 : SyncVerThumb();
1805 [ # # ]: 0 : if( pEntry == pCursor )
1806 : : {
1807 [ # # ]: 0 : if( pView->IsEntryVisible( pCursor ) )
1808 : 0 : ShowCursor( sal_True );
1809 : : else
1810 : : {
1811 : 0 : SvLBoxEntry* pParent = pEntry;
1812 [ # # ]: 0 : do {
1813 : 0 : pParent = pTree->GetParent( pParent );
1814 : : }
1815 : 0 : while( !pView->IsEntryVisible( pParent ) );
1816 : 0 : SetCursor( pParent );
1817 : : }
1818 : : }
1819 [ # # ]: 0 : if( IsEntryInView( pEntry ) )
1820 : 0 : pView->Invalidate();
1821 : 0 : }
1822 : :
1823 : :
1824 : :
1825 : 2398 : void SvImpLBox::EntryInserted( SvLBoxEntry* pEntry )
1826 : : {
1827 [ + + ]: 2398 : if( GetUpdateMode() )
1828 : : {
1829 : 8 : SvLBoxEntry* pParent = (SvLBoxEntry*)pTree->GetParent(pEntry);
1830 [ + + ][ + + ]: 8 : if( pParent && pTree->GetChildList(pParent)->size() == 1 )
[ + + ]
1831 : : // draw plus sign
1832 : 4 : pTree->InvalidateEntry( pParent );
1833 : :
1834 [ + + ]: 8 : if( !pView->IsEntryVisible( pEntry ) )
1835 : 2398 : return;
1836 : 2 : int bDeselAll = nFlags & F_DESEL_ALL;
1837 [ - + ]: 2 : if( bDeselAll )
1838 : 0 : SelAllDestrAnch( sal_False, sal_True );
1839 : : else
1840 : 2 : DestroyAnchor();
1841 : : // nFlags &= (~F_DESEL_ALL);
1842 : : // ShowCursor( sal_False ); // if cursor is moved lower
1843 : 2 : long nY = GetEntryLine( pEntry );
1844 : 2 : sal_Bool bEntryVisible = IsLineVisible( nY );
1845 [ - + ]: 2 : if( bEntryVisible )
1846 : : {
1847 : 0 : ShowCursor( sal_False ); // if cursor is moved lower
1848 : 0 : nY -= pView->GetEntryHeight(); // because of lines
1849 : 0 : InvalidateEntriesFrom( nY );
1850 : : }
1851 [ - + ][ # # ]: 2 : else if( pStartEntry && nY < GetEntryLine(pStartEntry) )
[ - + ]
1852 : : {
1853 : : // Check if the view is filled completely. If not, then adjust
1854 : : // pStartEntry and the Cursor (automatic scrolling).
1855 : 0 : sal_uInt16 nLast = (sal_uInt16)(pView->GetVisiblePos( (SvLBoxEntry*)(pView->LastVisible())));
1856 : 0 : sal_uInt16 nThumb = (sal_uInt16)(pView->GetVisiblePos( pStartEntry ));
1857 : 0 : sal_uInt16 nCurDispEntries = nLast-nThumb+1;
1858 [ # # ]: 0 : if( nCurDispEntries < nVisibleCount )
1859 : : {
1860 : : // set at the next paint event
1861 : 0 : pStartEntry = 0;
1862 : 0 : SetCursor( 0 );
1863 : 0 : pView->Invalidate();
1864 : : }
1865 : : }
1866 [ + - ]: 2 : else if( !pStartEntry )
1867 : 2 : pView->Invalidate();
1868 : :
1869 : 2 : SetMostRight( pEntry );
1870 [ + - ]: 2 : aVerSBar.SetRange( Range(0, pView->GetVisibleCount()-1));
1871 : 2 : SyncVerThumb(); // if something was inserted before the thumb
1872 : 2 : ShowVerSBar();
1873 : 2 : ShowCursor( sal_True );
1874 [ + - ][ + - ]: 2 : if( pStartEntry != pView->First() && (nFlags & F_FILLING) )
[ + - ]
1875 : 2 : pView->Update();
1876 : : }
1877 : : }
1878 : :
1879 : :
1880 : :
1881 : : // ********************************************************************
1882 : : // Event handler
1883 : : // ********************************************************************
1884 : :
1885 : :
1886 : : // ****** Control the control animation
1887 : :
1888 : 0 : sal_Bool SvImpLBox::ButtonDownCheckCtrl(const MouseEvent& rMEvt, SvLBoxEntry* pEntry,
1889 : : long nY )
1890 : : {
1891 : 0 : SvLBoxItem* pItem = pView->GetItem(pEntry,rMEvt.GetPosPixel().X(),&pActiveTab);
1892 [ # # ][ # # ]: 0 : if( pItem && (pItem->IsA()==SV_ITEM_ID_LBOXBUTTON))
[ # # ]
1893 : : {
1894 : 0 : pActiveButton = (SvLBoxButton*)pItem;
1895 : 0 : pActiveEntry = pEntry;
1896 [ # # ]: 0 : if( pCursor == pActiveEntry )
1897 : 0 : pView->HideFocus();
1898 : 0 : pView->CaptureMouse();
1899 : 0 : pActiveButton->SetStateHilighted( sal_True );
1900 : : pView->PaintEntry1( pActiveEntry, nY,
1901 : : SV_LBOXTAB_PUSHABLE | SV_LBOXTAB_ADJUST_CENTER |
1902 : 0 : SV_LBOXTAB_ADJUST_RIGHT );
1903 : 0 : return sal_True;
1904 : : }
1905 : : else
1906 : 0 : pActiveButton = 0;
1907 : 0 : return sal_False;
1908 : : }
1909 : :
1910 : 0 : sal_Bool SvImpLBox::MouseMoveCheckCtrl( const MouseEvent& rMEvt, SvLBoxEntry* pEntry)
1911 : : {
1912 [ # # ]: 0 : if( pActiveButton )
1913 : : {
1914 : : long nY;
1915 : 0 : long nMouseX = rMEvt.GetPosPixel().X();
1916 [ # # ]: 0 : if( pEntry == pActiveEntry &&
[ # # # # ]
1917 : 0 : pView->GetItem(pActiveEntry, nMouseX) == pActiveButton )
1918 : : {
1919 [ # # ]: 0 : if( !pActiveButton->IsStateHilighted() )
1920 : : {
1921 : 0 : pActiveButton->SetStateHilighted(sal_True );
1922 : 0 : nY = GetEntryLine( pActiveEntry );
1923 : : pView->PaintEntry1( pActiveEntry, nY,
1924 : : SV_LBOXTAB_PUSHABLE | SV_LBOXTAB_ADJUST_CENTER |
1925 : 0 : SV_LBOXTAB_ADJUST_RIGHT );
1926 : : }
1927 : : }
1928 : : else
1929 : : {
1930 [ # # ]: 0 : if( pActiveButton->IsStateHilighted() )
1931 : : {
1932 : 0 : pActiveButton->SetStateHilighted(sal_False );
1933 : 0 : nY = GetEntryLine( pActiveEntry );
1934 : 0 : pView->PaintEntry1( pActiveEntry, nY, SV_LBOXTAB_PUSHABLE );
1935 : : }
1936 : : }
1937 : 0 : return sal_True;
1938 : : }
1939 : 0 : return sal_False;
1940 : : }
1941 : :
1942 : 0 : sal_Bool SvImpLBox::ButtonUpCheckCtrl( const MouseEvent& rMEvt )
1943 : : {
1944 [ # # ]: 0 : if( pActiveButton )
1945 : : {
1946 : 0 : pView->ReleaseMouse();
1947 : 0 : SvLBoxEntry* pEntry = GetClickedEntry( rMEvt.GetPosPixel() );
1948 : 0 : long nY = GetEntryLine( pActiveEntry );
1949 : 0 : pActiveButton->SetStateHilighted( sal_False );
1950 : 0 : long nMouseX = rMEvt.GetPosPixel().X();
1951 [ # # ]: 0 : if( pEntry == pActiveEntry &&
[ # # # # ]
1952 : 0 : pView->GetItem( pActiveEntry, nMouseX ) == pActiveButton )
1953 : 0 : pActiveButton->ClickHdl( pView, pActiveEntry );
1954 : : pView->PaintEntry1( pActiveEntry, nY,
1955 : : SV_LBOXTAB_PUSHABLE | SV_LBOXTAB_ADJUST_CENTER |
1956 : 0 : SV_LBOXTAB_ADJUST_RIGHT );
1957 [ # # ]: 0 : if( pCursor == pActiveEntry )
1958 : 0 : ShowCursor( sal_True );
1959 : 0 : pActiveButton = 0;
1960 : 0 : pActiveEntry = 0;
1961 : 0 : pActiveTab = 0;
1962 : 0 : return sal_True;
1963 : : }
1964 : 0 : return sal_False;
1965 : : }
1966 : :
1967 : : // ******* Control plus/minus button for expanding/collapsing
1968 : :
1969 : : // sal_False == no expand/collapse button hit
1970 : 0 : sal_Bool SvImpLBox::IsNodeButton( const Point& rPosPixel, SvLBoxEntry* pEntry ) const
1971 : : {
1972 [ # # ][ # # ]: 0 : if( !pEntry->HasChildren() && !pEntry->HasChildrenOnDemand() )
[ # # ]
1973 : 0 : return sal_False;
1974 : :
1975 [ # # ]: 0 : SvLBoxTab* pFirstDynamicTab = pView->GetFirstDynamicTab();
1976 [ # # ]: 0 : if( !pFirstDynamicTab )
1977 : 0 : return sal_False;
1978 : :
1979 : 0 : long nMouseX = rPosPixel.X();
1980 : : // convert to document coordinates
1981 : 0 : Point aOrigin( pView->GetMapMode().GetOrigin() );
1982 : 0 : nMouseX -= aOrigin.X();
1983 : :
1984 [ # # ]: 0 : long nX = pView->GetTabPos( pEntry, pFirstDynamicTab);
1985 : 0 : nX += nNodeBmpTabDistance;
1986 [ # # ]: 0 : if( nMouseX < nX )
1987 : 0 : return sal_False;
1988 : 0 : nX += nNodeBmpWidth;
1989 [ # # ]: 0 : if( nMouseX > nX )
1990 : 0 : return sal_False;
1991 : 0 : return sal_True;
1992 : : }
1993 : :
1994 : : // sal_False == hit no node button
1995 : 0 : sal_Bool SvImpLBox::ButtonDownCheckExpand( const MouseEvent& rMEvt, SvLBoxEntry* pEntry, long /* nY */ )
1996 : : {
1997 : 0 : sal_Bool bRet = sal_False;
1998 : :
1999 [ # # ][ # # ]: 0 : if ( pView->IsEditingActive() && pEntry == pView->pEdEntry )
[ # # ]
2000 : : // inplace editing -> nothing to do
2001 : 0 : bRet = sal_True;
2002 [ # # ]: 0 : else if ( IsNodeButton( rMEvt.GetPosPixel(), pEntry ) )
2003 : : {
2004 [ # # ]: 0 : if ( pView->IsExpanded( pEntry ) )
2005 : : {
2006 : 0 : pView->EndEditing( sal_True );
2007 : 0 : pView->Collapse( pEntry );
2008 : : }
2009 : : else
2010 : : {
2011 : : // you can expand an entry, which is in editing
2012 : 0 : pView->Expand( pEntry );
2013 : : }
2014 : 0 : bRet = sal_True;
2015 : : }
2016 : :
2017 : 0 : return bRet;
2018 : : }
2019 : :
2020 : 0 : void SvImpLBox::MouseButtonDown( const MouseEvent& rMEvt )
2021 : : {
2022 [ # # ][ # # ]: 0 : if ( !rMEvt.IsLeft() && !rMEvt.IsRight())
[ # # ]
2023 : : return;
2024 : :
2025 [ # # ]: 0 : aEditTimer.Stop();
2026 : 0 : Point aPos( rMEvt.GetPosPixel());
2027 : :
2028 [ # # ][ # # ]: 0 : if( aPos.X() > aOutputSize.Width() || aPos.Y() > aOutputSize.Height() )
[ # # ]
2029 : : return;
2030 : :
2031 [ # # ]: 0 : SvLBoxEntry* pEntry = GetEntry( aPos );
2032 [ # # ]: 0 : if ( pEntry != pCursor )
2033 : : // new entry selected -> reset current tab position to first tab
2034 : 0 : nCurTabPos = FIRST_ENTRY_TAB;
2035 : 0 : nFlags &= (~F_FILLING);
2036 [ # # ]: 0 : pView->GrabFocus();
2037 : : // the entry can still be invalid!
2038 [ # # ][ # # ]: 0 : if( !pEntry || !pView->GetViewData( pEntry ))
[ # # ][ # # ]
2039 : : return;
2040 : :
2041 [ # # ]: 0 : long nY = GetEntryLine( pEntry );
2042 : : // Node-Button?
2043 [ # # ][ # # ]: 0 : if( ButtonDownCheckExpand( rMEvt, pEntry, nY ) )
2044 : : return;
2045 : :
2046 [ # # ][ # # ]: 0 : if( !EntryReallyHit(pEntry,aPos,nY))
2047 : : return;
2048 : :
2049 [ # # ]: 0 : SvLBoxItem* pXItem = pView->GetItem( pEntry, aPos.X() );
2050 [ # # ]: 0 : if( pXItem )
2051 : : {
2052 [ # # ]: 0 : SvLBoxTab* pXTab = pView->GetTab( pEntry, pXItem );
2053 [ # # ][ # # ]: 0 : if ( !rMEvt.IsMod1() && !rMEvt.IsMod2() && rMEvt.IsLeft() && pXTab->IsEditable()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
2054 [ # # ][ # # ]: 0 : && pEntry == pView->FirstSelected() && NULL == pView->NextSelected( pEntry ) )
2055 : : // #i8234# FirstSelected() and NextSelected() ensures, that inplace editing is only triggered, when only one entry is selected
2056 : 0 : nFlags |= F_START_EDITTIMER;
2057 [ # # ][ # # ]: 0 : if ( !pView->IsSelected( pEntry ) )
2058 : 0 : nFlags &= ~F_START_EDITTIMER;
2059 : : }
2060 : :
2061 : :
2062 [ # # ]: 0 : if( (rMEvt.GetClicks() % 2) == 0 )
2063 : : {
2064 : 0 : nFlags &= (~F_START_EDITTIMER);
2065 : 0 : pView->pHdlEntry = pEntry;
2066 [ # # ][ # # ]: 0 : if( pView->DoubleClickHdl() )
2067 : : {
2068 : : // if the entry was deleted within the handler
2069 [ # # ]: 0 : pEntry = GetClickedEntry( aPos );
2070 [ # # ]: 0 : if( !pEntry )
2071 : : return;
2072 [ # # ]: 0 : if( pEntry != pView->pHdlEntry )
2073 : : {
2074 : : // select anew & bye
2075 [ # # ][ # # ]: 0 : if( !bSimpleTravel && !aSelEng.IsAlwaysAdding())
[ # # ][ # # ]
2076 [ # # ]: 0 : SelAllDestrAnch( sal_False, sal_True ); // DeselectAll();
2077 [ # # ]: 0 : SetCursor( pEntry );
2078 : :
2079 : : return;
2080 : : }
2081 [ # # ][ # # ]: 0 : if( pEntry->HasChildren() || pEntry->HasChildrenOnDemand() )
[ # # ]
2082 : : {
2083 [ # # ][ # # ]: 0 : if( pView->IsExpanded(pEntry) )
2084 [ # # ]: 0 : pView->Collapse( pEntry );
2085 : : else
2086 [ # # ]: 0 : pView->Expand( pEntry );
2087 [ # # ]: 0 : if( pEntry == pCursor ) // only if Entryitem was clicked
2088 : : // (Nodebutton is not an Entryitem!)
2089 [ # # ]: 0 : pView->Select( pCursor, sal_True );
2090 : : return;
2091 : : }
2092 : : }
2093 : : }
2094 : : else
2095 : : {
2096 : : // CheckButton? (TreeListBox: Check + Info)
2097 [ # # ][ # # ]: 0 : if( ButtonDownCheckCtrl(rMEvt, pEntry, nY) == sal_True)
2098 : : return;
2099 : : // Inplace-Editing?
2100 : : }
2101 [ # # ]: 0 : if ( aSelEng.GetSelectionMode() != NO_SELECTION )
2102 [ # # ]: 0 : aSelEng.SelMouseButtonDown( rMEvt );
2103 : : }
2104 : :
2105 : 0 : void SvImpLBox::MouseButtonUp( const MouseEvent& rMEvt)
2106 : : {
2107 [ # # ][ # # ]: 0 : if ( !ButtonUpCheckCtrl( rMEvt ) && ( aSelEng.GetSelectionMode() != NO_SELECTION ) )
[ # # ]
2108 : 0 : aSelEng.SelMouseButtonUp( rMEvt );
2109 : 0 : EndScroll();
2110 [ # # ]: 0 : if( nFlags & F_START_EDITTIMER )
2111 : : {
2112 : 0 : nFlags &= (~F_START_EDITTIMER);
2113 : 0 : aEditClickPos = rMEvt.GetPosPixel();
2114 : 0 : aEditTimer.Start();
2115 : : }
2116 : :
2117 : 0 : return;
2118 : : }
2119 : :
2120 : 0 : void SvImpLBox::MouseMove( const MouseEvent& rMEvt)
2121 : : {
2122 : 0 : SvLBoxEntry* pEntry = GetClickedEntry( rMEvt.GetPosPixel() );
2123 [ # # ][ # # ]: 0 : if ( !MouseMoveCheckCtrl( rMEvt, pEntry ) && ( aSelEng.GetSelectionMode() != NO_SELECTION ) )
[ # # ]
2124 : 0 : aSelEng.SelMouseMove( rMEvt );
2125 : 0 : return;
2126 : : }
2127 : :
2128 : 0 : sal_Bool SvImpLBox::KeyInput( const KeyEvent& rKEvt)
2129 : : {
2130 [ # # ]: 0 : aEditTimer.Stop();
2131 : 0 : const KeyCode& rKeyCode = rKEvt.GetKeyCode();
2132 : :
2133 [ # # ]: 0 : if( rKeyCode.IsMod2() )
2134 : 0 : return sal_False; // don't evaluate Alt key
2135 : :
2136 : 0 : nFlags &= (~F_FILLING);
2137 : :
2138 [ # # ]: 0 : if( !pCursor )
2139 : 0 : pCursor = pStartEntry;
2140 [ # # ]: 0 : if( !pCursor )
2141 : 0 : return sal_False;
2142 : :
2143 : 0 : sal_Bool bKeyUsed = sal_True;
2144 : :
2145 : 0 : sal_uInt16 nDelta = (sal_uInt16)aVerSBar.GetPageSize();
2146 : 0 : sal_uInt16 aCode = rKeyCode.GetCode();
2147 : :
2148 : 0 : sal_Bool bShift = rKeyCode.IsShift();
2149 : 0 : sal_Bool bMod1 = rKeyCode.IsMod1();
2150 : :
2151 : : SvLBoxEntry* pNewCursor;
2152 : :
2153 [ # # ]: 0 : const WinBits nWindowStyle = pView->GetStyle();
2154 [ # # # # : 0 : switch( aCode )
# # # # #
# # # # #
# # # #
# ]
2155 : : {
2156 : : case KEY_UP:
2157 [ # # ][ # # ]: 0 : if( !IsEntryInView( pCursor ) )
2158 [ # # ]: 0 : MakeVisible( pCursor );
2159 : :
2160 : 0 : pNewCursor = pCursor;
2161 [ # # ][ # # ]: 0 : do
[ # # ]
2162 : : {
2163 [ # # ]: 0 : pNewCursor = (SvLBoxEntry*)(pView->PrevVisible( pNewCursor ));
2164 [ # # ]: 0 : } while( pNewCursor && !IsSelectable(pNewCursor) );
2165 : :
2166 [ # # ]: 0 : if ( pNewCursor )
2167 : : // new entry selected -> reset current tab position to first tab
2168 : 0 : nCurTabPos = FIRST_ENTRY_TAB;
2169 : : // if there is no next entry, take the current one
2170 : : // this ensures that in case of _one_ entry in the list, this entry is selected when pressing
2171 : : // the cursor key
2172 [ # # ][ # # ]: 0 : if ( !pNewCursor && pCursor )
2173 : 0 : pNewCursor = pCursor;
2174 : :
2175 [ # # ]: 0 : if( pNewCursor )
2176 : : {
2177 [ # # ]: 0 : aSelEng.CursorPosChanging( bShift, bMod1 );
2178 [ # # ]: 0 : SetCursor( pNewCursor, bMod1 ); // no selection, when Ctrl is on
2179 [ # # ][ # # ]: 0 : if( !IsEntryInView( pNewCursor ) )
2180 [ # # ]: 0 : KeyUp( sal_False );
2181 : : }
2182 : 0 : break;
2183 : :
2184 : : case KEY_DOWN:
2185 [ # # ][ # # ]: 0 : if( !IsEntryInView( pCursor ) )
2186 [ # # ]: 0 : MakeVisible( pCursor );
2187 : :
2188 : 0 : pNewCursor = pCursor;
2189 [ # # ][ # # ]: 0 : do
[ # # ]
2190 : : {
2191 [ # # ]: 0 : pNewCursor = (SvLBoxEntry*)(pView->NextVisible( pNewCursor ));
2192 [ # # ]: 0 : } while( pNewCursor && !IsSelectable(pNewCursor) );
2193 : :
2194 [ # # ]: 0 : if ( pNewCursor )
2195 : : // new entry selected -> reset current tab position to first tab
2196 : 0 : nCurTabPos = FIRST_ENTRY_TAB;
2197 : :
2198 : : // if there is no next entry, take the current one
2199 : : // this ensures that in case of _one_ entry in the list, this entry is selected when pressing
2200 : : // the cursor key
2201 : : // 06.09.20001 - 83416 - frank.schoenheit@sun.com
2202 [ # # ][ # # ]: 0 : if ( !pNewCursor && pCursor )
2203 : 0 : pNewCursor = pCursor;
2204 : :
2205 [ # # ]: 0 : if( pNewCursor )
2206 : : {
2207 [ # # ]: 0 : aSelEng.CursorPosChanging( bShift, bMod1 );
2208 [ # # ][ # # ]: 0 : if( IsEntryInView( pNewCursor ) )
2209 [ # # ]: 0 : SetCursor( pNewCursor, bMod1 ); // no selection, when Ctrl is on
2210 : : else
2211 : : {
2212 [ # # ]: 0 : if( pCursor )
2213 [ # # ]: 0 : pView->Select( pCursor, sal_False );
2214 [ # # ]: 0 : KeyDown( sal_False );
2215 [ # # ]: 0 : SetCursor( pNewCursor, bMod1 ); // no selection, when Ctrl is on
2216 : : }
2217 : : }
2218 : : else
2219 [ # # ]: 0 : KeyDown( sal_False ); // because scrollbar range might still
2220 : : // allow scrolling
2221 : 0 : break;
2222 : :
2223 : : case KEY_RIGHT:
2224 : : {
2225 [ # # ][ # # ]: 0 : if( bSubLstOpLR && IsNowExpandable() )
[ # # ][ # # ]
2226 [ # # ]: 0 : pView->Expand( pCursor );
2227 [ # # ][ # # ]: 0 : else if ( bIsCellFocusEnabled && pCursor )
2228 : : {
2229 [ # # ]: 0 : if ( nCurTabPos < ( pView->TabCount() - 1 /*!2*/ ) )
2230 : : {
2231 : 0 : ++nCurTabPos;
2232 [ # # ]: 0 : ShowCursor( sal_True );
2233 [ # # ]: 0 : CallEventListeners( VCLEVENT_LISTBOX_SELECT, pCursor );
2234 : : }
2235 : : }
2236 [ # # ]: 0 : else if( nWindowStyle & WB_HSCROLL )
2237 : : {
2238 : 0 : long nThumb = aHorSBar.GetThumbPos();
2239 : 0 : nThumb += aHorSBar.GetLineSize();
2240 : 0 : long nOldThumb = aHorSBar.GetThumbPos();
2241 [ # # ]: 0 : aHorSBar.SetThumbPos( nThumb );
2242 : 0 : nThumb = nOldThumb;
2243 : 0 : nThumb -= aHorSBar.GetThumbPos();
2244 : 0 : nThumb *= -1;
2245 [ # # ]: 0 : if( nThumb )
2246 : : {
2247 [ # # ]: 0 : KeyLeftRight( nThumb );
2248 [ # # ]: 0 : EndScroll();
2249 : : }
2250 : : }
2251 : : else
2252 : 0 : bKeyUsed = sal_False;
2253 : 0 : break;
2254 : : }
2255 : :
2256 : : case KEY_LEFT:
2257 : : {
2258 [ # # ]: 0 : if ( bIsCellFocusEnabled )
2259 : : {
2260 [ # # ]: 0 : if ( nCurTabPos > FIRST_ENTRY_TAB )
2261 : : {
2262 : 0 : --nCurTabPos;
2263 [ # # ]: 0 : ShowCursor( sal_True );
2264 [ # # ]: 0 : CallEventListeners( VCLEVENT_LISTBOX_SELECT, pCursor );
2265 : : }
2266 : : }
2267 [ # # ]: 0 : else if ( nWindowStyle & WB_HSCROLL )
2268 : : {
2269 : 0 : long nThumb = aHorSBar.GetThumbPos();
2270 : 0 : nThumb -= aHorSBar.GetLineSize();
2271 : 0 : long nOldThumb = aHorSBar.GetThumbPos();
2272 [ # # ]: 0 : aHorSBar.SetThumbPos( nThumb );
2273 : 0 : nThumb = nOldThumb;
2274 : 0 : nThumb -= aHorSBar.GetThumbPos();
2275 [ # # ]: 0 : if( nThumb )
2276 : : {
2277 [ # # ]: 0 : KeyLeftRight( -nThumb );
2278 [ # # ]: 0 : EndScroll();
2279 : : }
2280 [ # # ]: 0 : else if( bSubLstOpLR )
2281 : : {
2282 [ # # ][ # # ]: 0 : if( IsExpandable() && pView->IsExpanded( pCursor ) )
[ # # ][ # # ]
2283 [ # # ]: 0 : pView->Collapse( pCursor );
2284 : : else
2285 : : {
2286 [ # # ]: 0 : pNewCursor = pView->GetParent( pCursor );
2287 [ # # ]: 0 : if( pNewCursor )
2288 [ # # ]: 0 : SetCursor( pNewCursor );
2289 : : }
2290 : : }
2291 : : }
2292 [ # # ][ # # ]: 0 : else if( bSubLstOpLR && IsExpandable() )
[ # # ]
2293 [ # # ]: 0 : pView->Collapse( pCursor );
2294 : : else
2295 : 0 : bKeyUsed = sal_False;
2296 : 0 : break;
2297 : : }
2298 : :
2299 : : case KEY_PAGEUP:
2300 [ # # ]: 0 : if( !bMod1 )
2301 : : {
2302 [ # # ]: 0 : pNewCursor = (SvLBoxEntry*)(pView->PrevVisible( pCursor, nDelta ));
2303 : :
2304 [ # # ][ # # ]: 0 : while( nDelta && pNewCursor && !IsSelectable(pNewCursor) )
[ # # ][ # # ]
[ # # ]
2305 : : {
2306 [ # # ]: 0 : pNewCursor = (SvLBoxEntry*)(pView->NextVisible( pNewCursor ));
2307 : 0 : nDelta--;
2308 : : }
2309 : :
2310 [ # # ]: 0 : if( nDelta )
2311 : : {
2312 : : DBG_ASSERT(pNewCursor&&(sal_uLong)pNewCursor!=(sal_uLong)pCursor,"Cursor?");
2313 [ # # ]: 0 : aSelEng.CursorPosChanging( bShift, bMod1 );
2314 [ # # ][ # # ]: 0 : if( IsEntryInView( pNewCursor ) )
2315 [ # # ]: 0 : SetCursor( pNewCursor );
2316 : : else
2317 : : {
2318 [ # # ]: 0 : SetCursor( pNewCursor );
2319 [ # # ]: 0 : KeyUp( sal_True );
2320 : : }
2321 : : }
2322 : : }
2323 : : else
2324 : 0 : bKeyUsed = sal_False;
2325 : 0 : break;
2326 : :
2327 : : case KEY_PAGEDOWN:
2328 [ # # ]: 0 : if( !bMod1 )
2329 : : {
2330 [ # # ]: 0 : pNewCursor= (SvLBoxEntry*)(pView->NextVisible( pCursor, nDelta ));
2331 : :
2332 [ # # ][ # # ]: 0 : while( nDelta && pNewCursor && !IsSelectable(pNewCursor) )
[ # # ][ # # ]
[ # # ]
2333 : : {
2334 [ # # ]: 0 : pNewCursor = (SvLBoxEntry*)(pView->PrevVisible( pNewCursor ));
2335 : 0 : nDelta--;
2336 : : }
2337 : :
2338 [ # # ]: 0 : if( nDelta )
2339 : : {
2340 : : DBG_ASSERT(pNewCursor&&(sal_uLong)pNewCursor!=(sal_uLong)pCursor,"Cursor?");
2341 [ # # ]: 0 : aSelEng.CursorPosChanging( bShift, bMod1 );
2342 [ # # ][ # # ]: 0 : if( IsEntryInView( pNewCursor ) )
2343 [ # # ]: 0 : SetCursor( pNewCursor );
2344 : : else
2345 : : {
2346 [ # # ]: 0 : SetCursor( pNewCursor );
2347 [ # # ]: 0 : KeyDown( sal_True );
2348 : : }
2349 : : }
2350 : : else
2351 [ # # ]: 0 : KeyDown( sal_False ); // see also: KEY_DOWN
2352 : : }
2353 : : else
2354 : 0 : bKeyUsed = sal_False;
2355 : 0 : break;
2356 : :
2357 : : case KEY_SPACE:
2358 [ # # ]: 0 : if ( pView->GetSelectionMode() != NO_SELECTION )
2359 : : {
2360 [ # # ]: 0 : if ( bMod1 )
2361 : : {
2362 [ # # ][ # # ]: 0 : if ( pView->GetSelectionMode() == MULTIPLE_SELECTION && !bShift )
[ # # ]
2363 : : // toggle selection
2364 [ # # ][ # # ]: 0 : pView->Select( pCursor, !pView->IsSelected( pCursor ) );
2365 : : }
2366 [ # # ]: 0 : else if ( !bShift /*&& !bMod1*/ )
2367 : : {
2368 [ # # ][ # # ]: 0 : if ( aSelEng.IsAddMode() )
2369 : : {
2370 : : // toggle selection
2371 [ # # ][ # # ]: 0 : pView->Select( pCursor, !pView->IsSelected( pCursor ) );
2372 : : }
2373 [ # # ][ # # ]: 0 : else if ( !pView->IsSelected( pCursor ) )
2374 : : {
2375 [ # # ]: 0 : SelAllDestrAnch( sal_False );
2376 [ # # ]: 0 : pView->Select( pCursor, sal_True );
2377 : : }
2378 : : else
2379 : 0 : bKeyUsed = sal_False;
2380 : : }
2381 : : else
2382 : 0 : bKeyUsed = sal_False;
2383 : : }
2384 : : else
2385 : 0 : bKeyUsed = sal_False;
2386 : 0 : break;
2387 : :
2388 : : case KEY_RETURN:
2389 [ # # ][ # # ]: 0 : if( bSubLstOpRet && IsExpandable() )
[ # # ]
2390 : : {
2391 [ # # ][ # # ]: 0 : if( pView->IsExpanded( pCursor ) )
2392 [ # # ]: 0 : pView->Collapse( pCursor );
2393 : : else
2394 [ # # ]: 0 : pView->Expand( pCursor );
2395 : : }
2396 : : else
2397 : 0 : bKeyUsed = sal_False;
2398 : 0 : break;
2399 : :
2400 : : case KEY_F2:
2401 [ # # ][ # # ]: 0 : if( !bShift && !bMod1 )
2402 : : {
2403 : 0 : aEditClickPos = Point( -1, -1 );
2404 [ # # ]: 0 : EditTimerCall( 0 );
2405 : : }
2406 : : else
2407 : 0 : bKeyUsed = sal_False;
2408 : 0 : break;
2409 : :
2410 : : case KEY_F8:
2411 [ # # ][ # # ]: 0 : if( bShift && pView->GetSelectionMode()==MULTIPLE_SELECTION &&
[ # # ][ # # ]
2412 : 0 : !(m_nStyle & WB_SIMPLEMODE))
2413 : : {
2414 [ # # ][ # # ]: 0 : if( aSelEng.IsAlwaysAdding() )
2415 [ # # ]: 0 : aSelEng.AddAlways( sal_False );
2416 : : else
2417 [ # # ]: 0 : aSelEng.AddAlways( sal_True );
2418 : : }
2419 : : else
2420 : 0 : bKeyUsed = sal_False;
2421 : 0 : break;
2422 : :
2423 : : case KEY_ADD:
2424 [ # # ]: 0 : if( pCursor )
2425 : : {
2426 [ # # ][ # # ]: 0 : if( !pView->IsExpanded(pCursor))
2427 [ # # ]: 0 : pView->Expand( pCursor );
2428 [ # # ]: 0 : if( bMod1 )
2429 : : {
2430 [ # # ]: 0 : sal_uInt16 nRefDepth = pTree->GetDepth( pCursor );
2431 [ # # ]: 0 : SvLBoxEntry* pCur = pTree->Next( pCursor );
2432 [ # # ][ # # ]: 0 : while( pCur && pTree->GetDepth(pCur) > nRefDepth )
[ # # ][ # # ]
2433 : : {
2434 [ # # ][ # # ]: 0 : if( pCur->HasChildren() && !pView->IsExpanded(pCur))
[ # # ][ # # ]
2435 [ # # ]: 0 : pView->Expand( pCur );
2436 [ # # ]: 0 : pCur = pTree->Next( pCur );
2437 : : }
2438 : : }
2439 : : }
2440 : : else
2441 : 0 : bKeyUsed = sal_False;
2442 : 0 : break;
2443 : :
2444 : : case KEY_A:
2445 [ # # ]: 0 : if( bMod1 )
2446 [ # # ]: 0 : SelAllDestrAnch( sal_True );
2447 : : else
2448 : 0 : bKeyUsed = sal_False;
2449 : 0 : break;
2450 : :
2451 : : case KEY_SUBTRACT:
2452 [ # # ]: 0 : if( pCursor )
2453 : : {
2454 [ # # ][ # # ]: 0 : if( pView->IsExpanded(pCursor))
2455 [ # # ]: 0 : pView->Collapse( pCursor );
2456 [ # # ]: 0 : if( bMod1 )
2457 : : {
2458 : : // collapse all parents until we get to the root
2459 [ # # ]: 0 : SvLBoxEntry* pParentToCollapse = (SvLBoxEntry*)pTree->GetRootLevelParent(pCursor);
2460 [ # # ]: 0 : if( pParentToCollapse )
2461 : : {
2462 : : sal_uInt16 nRefDepth;
2463 : : // special case explorer: if the root only has a single
2464 : : // entry, don't collapse the root entry
2465 [ # # ][ # # ]: 0 : if( pTree->GetChildList(0)->size() < 2 )
2466 : : {
2467 : 0 : nRefDepth = 1;
2468 : 0 : pParentToCollapse = pCursor;
2469 [ # # ][ # # ]: 0 : while( pTree->GetParent(pParentToCollapse) &&
[ # # ][ # # ]
2470 [ # # ][ # # ]: 0 : pTree->GetDepth( pTree->GetParent(pParentToCollapse)) > 0)
2471 : : {
2472 [ # # ]: 0 : pParentToCollapse = pTree->GetParent(pParentToCollapse);
2473 : : }
2474 : : }
2475 : : else
2476 : 0 : nRefDepth = 0;
2477 : :
2478 [ # # ][ # # ]: 0 : if( pView->IsExpanded(pParentToCollapse) )
2479 [ # # ]: 0 : pView->Collapse( pParentToCollapse );
2480 [ # # ]: 0 : SvLBoxEntry* pCur = pTree->Next( pParentToCollapse );
2481 [ # # ][ # # ]: 0 : while( pCur && pTree->GetDepth(pCur) > nRefDepth )
[ # # ][ # # ]
2482 : : {
2483 [ # # ][ # # ]: 0 : if( pCur->HasChildren() && pView->IsExpanded(pCur) )
[ # # ][ # # ]
2484 [ # # ]: 0 : pView->Collapse( pCur );
2485 [ # # ]: 0 : pCur = pTree->Next( pCur );
2486 : : }
2487 : : }
2488 : : }
2489 : : }
2490 : : else
2491 : 0 : bKeyUsed = sal_False;
2492 : 0 : break;
2493 : :
2494 : : case KEY_DIVIDE :
2495 [ # # ]: 0 : if( bMod1 )
2496 [ # # ]: 0 : SelAllDestrAnch( sal_True );
2497 : : else
2498 : 0 : bKeyUsed = sal_False;
2499 : 0 : break;
2500 : :
2501 : : case KEY_COMMA :
2502 [ # # ]: 0 : if( bMod1 )
2503 [ # # ]: 0 : SelAllDestrAnch( sal_False );
2504 : : else
2505 : 0 : bKeyUsed = sal_False;
2506 : 0 : break;
2507 : :
2508 : : case KEY_HOME :
2509 [ # # ]: 0 : pNewCursor = pView->GetModel()->First();
2510 : :
2511 [ # # ][ # # ]: 0 : while( pNewCursor && !IsSelectable(pNewCursor) )
[ # # ][ # # ]
2512 : : {
2513 [ # # ]: 0 : pNewCursor = (SvLBoxEntry*)(pView->NextVisible( pNewCursor ));
2514 : : }
2515 : :
2516 [ # # ][ # # ]: 0 : if( pNewCursor && pNewCursor != pCursor )
2517 : : {
2518 : : // SelAllDestrAnch( sal_False );
2519 [ # # ]: 0 : aSelEng.CursorPosChanging( bShift, bMod1 );
2520 [ # # ]: 0 : SetCursor( pNewCursor );
2521 [ # # ][ # # ]: 0 : if( !IsEntryInView( pNewCursor ) )
2522 [ # # ]: 0 : MakeVisible( pNewCursor );
2523 : : }
2524 : : else
2525 : 0 : bKeyUsed = sal_False;
2526 : 0 : break;
2527 : :
2528 : : case KEY_END :
2529 [ # # ]: 0 : pNewCursor = pView->GetModel()->Last();
2530 : :
2531 [ # # ][ # # ]: 0 : while( pNewCursor && !IsSelectable(pNewCursor) )
[ # # ][ # # ]
2532 : : {
2533 [ # # ]: 0 : pNewCursor = (SvLBoxEntry*)(pView->PrevVisible( pNewCursor ));
2534 : : }
2535 : :
2536 [ # # ][ # # ]: 0 : if( pNewCursor && pNewCursor != pCursor)
2537 : : {
2538 : : // SelAllDestrAnch( sal_False );
2539 [ # # ]: 0 : aSelEng.CursorPosChanging( bShift, bMod1 );
2540 [ # # ]: 0 : SetCursor( pNewCursor );
2541 [ # # ][ # # ]: 0 : if( !IsEntryInView( pNewCursor ) )
2542 [ # # ]: 0 : MakeVisible( pNewCursor );
2543 : : }
2544 : : else
2545 : 0 : bKeyUsed = sal_False;
2546 : 0 : break;
2547 : :
2548 : : case KEY_ESCAPE:
2549 : : case KEY_TAB:
2550 : : case KEY_DELETE:
2551 : : case KEY_BACKSPACE:
2552 : : // must not be handled because this quits dialogs and does other magic things...
2553 : : // if there are other single keys which should not be handled, they can be added here
2554 : 0 : bKeyUsed = sal_False;
2555 : 0 : break;
2556 : :
2557 : : default:
2558 : : // is there any reason why we should eat the events here? The only place where this is called
2559 : : // is from SvTreeListBox::KeyInput. If we set bKeyUsed to sal_True here, then the key input
2560 : : // is just silenced. However, we want SvLBox::KeyInput to get a chance, to do the QuickSelection
2561 : : // handling.
2562 : : // (The old code here which intentionally set bKeyUsed to TRUE said this was because of "quick search"
2563 : : // handling, but actually there was no quick search handling anymore. We just re-implemented it.)
2564 : : // #i31275# / 2009-06-16 / frank.schoenheit@sun.com
2565 : 0 : bKeyUsed = sal_False;
2566 : 0 : break;
2567 : : }
2568 : 0 : return bKeyUsed;
2569 : : }
2570 : :
2571 : 2 : void SvImpLBox::GetFocus()
2572 : : {
2573 [ + - ]: 2 : if( pCursor )
2574 : : {
2575 : 2 : pView->SetEntryFocus( pCursor, sal_True );
2576 : 2 : ShowCursor( sal_True );
2577 : : // auskommentiert wg. deselectall
2578 : : // if( bSimpleTravel && !pView->IsSelected(pCursor) )
2579 : : // pView->Select( pCursor, sal_True );
2580 : : }
2581 [ + - ]: 2 : if( m_nStyle & WB_HIDESELECTION )
2582 : : {
2583 : 2 : SvLBoxEntry* pEntry = pView->FirstSelected();
2584 [ + + ]: 4 : while( pEntry )
2585 : : {
2586 : 2 : InvalidateEntry( pEntry );
2587 : 2 : pEntry = pView->NextSelected( pEntry );
2588 : : }
2589 : : }
2590 : 2 : }
2591 : :
2592 : 0 : void SvImpLBox::LoseFocus()
2593 : : {
2594 : 0 : aEditTimer.Stop();
2595 [ # # ]: 0 : if( pCursor )
2596 : 0 : pView->SetEntryFocus( pCursor,sal_False );
2597 : 0 : ShowCursor( sal_False );
2598 : :
2599 [ # # ]: 0 : if( m_nStyle & WB_HIDESELECTION )
2600 : : {
2601 : 0 : SvLBoxEntry* pEntry = pView->FirstSelected();
2602 [ # # ]: 0 : while( pEntry )
2603 : : {
2604 : : //SvViewData* pViewData = pView->GetViewData( pEntry );
2605 : : //pViewData->SetCursored( sal_True );
2606 : 0 : InvalidateEntry( pEntry );
2607 : 0 : pEntry = pView->NextSelected( pEntry );
2608 : : }
2609 : : }
2610 : 0 : }
2611 : :
2612 : :
2613 : : // ********************************************************************
2614 : : // SelectionEngine
2615 : : // ********************************************************************
2616 : :
2617 : 0 : inline void SvImpLBox::SelectEntry( SvLBoxEntry* pEntry, sal_Bool bSelect )
2618 : : {
2619 : 0 : pView->Select( pEntry, bSelect );
2620 : 0 : }
2621 : :
2622 : 122 : ImpLBSelEng::ImpLBSelEng( SvImpLBox* pImpl, SelectionEngine* pSEng,
2623 : 122 : SvTreeListBox* pV )
2624 : : {
2625 : 122 : pImp = pImpl;
2626 : 122 : pSelEng = pSEng;
2627 : 122 : pView = pV;
2628 : 122 : }
2629 : :
2630 : 122 : ImpLBSelEng::~ImpLBSelEng()
2631 : : {
2632 [ - + ]: 122 : }
2633 : :
2634 : 0 : void ImpLBSelEng::BeginDrag()
2635 : : {
2636 : 0 : pImp->BeginDrag();
2637 : 0 : }
2638 : :
2639 : 0 : void ImpLBSelEng::CreateAnchor()
2640 : : {
2641 : 0 : pImp->pAnchor = pImp->pCursor;
2642 : 0 : }
2643 : :
2644 : 0 : void ImpLBSelEng::DestroyAnchor()
2645 : : {
2646 : 0 : pImp->pAnchor = 0;
2647 : 0 : }
2648 : :
2649 : 0 : sal_Bool ImpLBSelEng::SetCursorAtPoint(const Point& rPoint, sal_Bool bDontSelectAtCursor)
2650 : : {
2651 : 0 : SvLBoxEntry* pNewCursor = pImp->MakePointVisible( rPoint );
2652 [ # # ]: 0 : if( pNewCursor != pImp->pCursor )
2653 : 0 : pImp->BeginScroll();
2654 : :
2655 [ # # ]: 0 : if( pNewCursor )
2656 : : {
2657 : : // at SimpleTravel, the SetCursor is selected and the select handler is
2658 : : // called
2659 : : //if( !bDontSelectAtCursor && !pImp->bSimpleTravel )
2660 : : // pImp->SelectEntry( pNewCursor, sal_True );
2661 : 0 : pImp->SetCursor( pNewCursor, bDontSelectAtCursor );
2662 : 0 : return sal_True;
2663 : : }
2664 : 0 : return sal_False;
2665 : : }
2666 : :
2667 : 0 : sal_Bool ImpLBSelEng::IsSelectionAtPoint( const Point& rPoint )
2668 : : {
2669 : 0 : SvLBoxEntry* pEntry = pImp->MakePointVisible( rPoint );
2670 [ # # ]: 0 : if( pEntry )
2671 : 0 : return pView->IsSelected(pEntry);
2672 : 0 : return sal_False;
2673 : : }
2674 : :
2675 : 0 : void ImpLBSelEng::DeselectAtPoint( const Point& rPoint )
2676 : : {
2677 : 0 : SvLBoxEntry* pEntry = pImp->MakePointVisible( rPoint );
2678 [ # # ]: 0 : if( !pEntry )
2679 : 0 : return;
2680 : 0 : pImp->SelectEntry( pEntry, sal_False );
2681 : : }
2682 : :
2683 : 0 : void ImpLBSelEng::DeselectAll()
2684 : : {
2685 : 0 : pImp->SelAllDestrAnch( sal_False, sal_False ); // don't reset SelectionEngine!
2686 : 0 : pImp->nFlags &= (~F_DESEL_ALL);
2687 : 0 : }
2688 : :
2689 : : // ***********************************************************************
2690 : : // Selection
2691 : : // ***********************************************************************
2692 : :
2693 : 0 : void SvImpLBox::SetAnchorSelection(SvLBoxEntry* pOldCursor,SvLBoxEntry* pNewCursor)
2694 : : {
2695 : : SvLBoxEntry* pEntry;
2696 : 0 : sal_uLong nAnchorVisPos = pView->GetVisiblePos( pAnchor );
2697 : 0 : sal_uLong nOldVisPos = pView->GetVisiblePos( pOldCursor );
2698 : 0 : sal_uLong nNewVisPos = pView->GetVisiblePos( pNewCursor );
2699 : :
2700 [ # # ][ # # ]: 0 : if( nOldVisPos > nAnchorVisPos ||
[ # # ]
2701 : : ( nAnchorVisPos==nOldVisPos && nNewVisPos > nAnchorVisPos) )
2702 : : {
2703 [ # # ]: 0 : if( nNewVisPos > nOldVisPos )
2704 : : {
2705 : 0 : pEntry = pOldCursor;
2706 [ # # ][ # # ]: 0 : while( pEntry && pEntry != pNewCursor )
[ # # ]
2707 : : {
2708 : 0 : pView->Select( pEntry, sal_True );
2709 : 0 : pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
2710 : : }
2711 [ # # ]: 0 : if( pEntry )
2712 : 0 : pView->Select( pEntry, sal_True );
2713 : 0 : return;
2714 : : }
2715 : :
2716 [ # # ]: 0 : if( nNewVisPos < nAnchorVisPos )
2717 : : {
2718 : 0 : pEntry = pAnchor;
2719 [ # # ][ # # ]: 0 : while( pEntry && pEntry != pOldCursor )
[ # # ]
2720 : : {
2721 : 0 : pView->Select( pEntry, sal_False );
2722 : 0 : pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
2723 : : }
2724 [ # # ]: 0 : if( pEntry )
2725 : 0 : pView->Select( pEntry, sal_False );
2726 : :
2727 : 0 : pEntry = pNewCursor;
2728 [ # # ][ # # ]: 0 : while( pEntry && pEntry != pAnchor )
[ # # ]
2729 : : {
2730 : 0 : pView->Select( pEntry, sal_True );
2731 : 0 : pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
2732 : : }
2733 [ # # ]: 0 : if( pEntry )
2734 : 0 : pView->Select( pEntry, sal_True );
2735 : 0 : return;
2736 : : }
2737 : :
2738 [ # # ]: 0 : if( nNewVisPos < nOldVisPos )
2739 : : {
2740 : 0 : pEntry = pNewCursor;
2741 : 0 : pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
2742 [ # # ][ # # ]: 0 : while( pEntry && pEntry != pOldCursor )
[ # # ]
2743 : : {
2744 : 0 : pView->Select( pEntry, sal_False );
2745 : 0 : pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
2746 : : }
2747 [ # # ]: 0 : if( pEntry )
2748 : 0 : pView->Select( pEntry, sal_False );
2749 : 0 : return;
2750 : : }
2751 : : }
2752 : : else
2753 : : {
2754 [ # # ]: 0 : if( nNewVisPos < nOldVisPos ) // enlarge selection
2755 : : {
2756 : 0 : pEntry = pNewCursor;
2757 [ # # ][ # # ]: 0 : while( pEntry && pEntry != pOldCursor )
[ # # ]
2758 : : {
2759 : 0 : pView->Select( pEntry, sal_True );
2760 : 0 : pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
2761 : : }
2762 [ # # ]: 0 : if( pEntry )
2763 : 0 : pView->Select( pEntry, sal_True );
2764 : 0 : return;
2765 : : }
2766 : :
2767 [ # # ]: 0 : if( nNewVisPos > nAnchorVisPos )
2768 : : {
2769 : 0 : pEntry = pOldCursor;
2770 [ # # ][ # # ]: 0 : while( pEntry && pEntry != pAnchor )
[ # # ]
2771 : : {
2772 : 0 : pView->Select( pEntry, sal_False );
2773 : 0 : pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
2774 : : }
2775 [ # # ]: 0 : if( pEntry )
2776 : 0 : pView->Select( pEntry, sal_False );
2777 : 0 : pEntry = pAnchor;
2778 [ # # ][ # # ]: 0 : while( pEntry && pEntry != pNewCursor )
[ # # ]
2779 : : {
2780 : 0 : pView->Select( pEntry, sal_True );
2781 : 0 : pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
2782 : : }
2783 [ # # ]: 0 : if( pEntry )
2784 : 0 : pView->Select( pEntry, sal_True );
2785 : 0 : return;
2786 : : }
2787 : :
2788 [ # # ]: 0 : if( nNewVisPos > nOldVisPos )
2789 : : {
2790 : 0 : pEntry = pOldCursor;
2791 [ # # ][ # # ]: 0 : while( pEntry && pEntry != pNewCursor )
[ # # ]
2792 : : {
2793 : 0 : pView->Select( pEntry, sal_False );
2794 : 0 : pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
2795 : : }
2796 : 0 : return;
2797 : : }
2798 : : }
2799 : : }
2800 : :
2801 : 15 : void SvImpLBox::SelAllDestrAnch( sal_Bool bSelect, sal_Bool bDestroyAnchor,
2802 : : sal_Bool bSingleSelToo )
2803 : : {
2804 : : SvLBoxEntry* pEntry;
2805 : 15 : nFlags &= (~F_DESEL_ALL);
2806 [ - + ][ # # ]: 15 : if( bSelect && bSimpleTravel )
2807 : : {
2808 [ # # ][ # # ]: 0 : if( pCursor && !pView->IsSelected( pCursor ))
[ # # ]
2809 : : {
2810 : 0 : pView->Select( pCursor, sal_True );
2811 : : }
2812 : 0 : return;
2813 : : }
2814 [ + - ][ + - ]: 15 : if( !bSelect && pView->GetSelectionCount() == 0 )
[ + - ]
2815 : : {
2816 [ + - ][ + - ]: 15 : if( bSimpleTravel && ( !GetUpdateMode() || !pCursor) )
[ + + ][ + + ]
2817 : 8 : nFlags |= F_DESEL_ALL;
2818 : 15 : return;
2819 : : }
2820 [ # # ][ # # ]: 0 : if( bSelect && pView->GetSelectionCount() == pView->GetEntryCount())
[ # # ]
2821 : 0 : return;
2822 [ # # ][ # # ]: 0 : if( !bSingleSelToo && bSimpleTravel )
2823 : 0 : return;
2824 : :
2825 [ # # ][ # # ]: 0 : if( !bSelect && pView->GetSelectionCount()==1 && pCursor &&
[ # # # # ]
[ # # ]
2826 : 0 : pView->IsSelected( pCursor ))
2827 : : {
2828 : 0 : pView->Select( pCursor, sal_False );
2829 [ # # ]: 0 : if( bDestroyAnchor )
2830 : 0 : DestroyAnchor(); // delete anchor & reset SelectionEngine
2831 : : else
2832 : 0 : pAnchor = 0; // always delete internal anchor
2833 : 0 : return;
2834 : : }
2835 : :
2836 [ # # ][ # # ]: 0 : if( bSimpleTravel && !pCursor && !GetUpdateMode() )
[ # # ][ # # ]
2837 : 0 : nFlags |= F_DESEL_ALL;
2838 : :
2839 : 0 : ShowCursor( sal_False );
2840 : 0 : sal_Bool bUpdate = GetUpdateMode();
2841 : :
2842 : 0 : nFlags |= F_IGNORE_SELECT; // EntryInserted should not do anything
2843 : 0 : pEntry = pTree->First();
2844 [ # # ]: 0 : while( pEntry )
2845 : : {
2846 [ # # ]: 0 : if( pView->Select( pEntry, bSelect ) )
2847 : : {
2848 [ # # ][ # # ]: 0 : if( bUpdate && pView->IsEntryVisible(pEntry) )
[ # # ]
2849 : : {
2850 : 0 : long nY = GetEntryLine( pEntry );
2851 [ # # ]: 0 : if( IsLineVisible( nY ) )
2852 : 0 : pView->PaintEntry1( pEntry, nY, 0xffff ); // because of ItemsetBrowser SV_LBOXTAB_SHOW_SELECTION );
2853 : : }
2854 : : }
2855 : 0 : pEntry = pTree->Next( pEntry );
2856 : : }
2857 : 0 : nFlags &= ~F_IGNORE_SELECT;
2858 : :
2859 [ # # ]: 0 : if( bDestroyAnchor )
2860 : 0 : DestroyAnchor(); // delete anchor & reset SelectionEngine
2861 : : else
2862 : 0 : pAnchor = 0; // always delete internal anchor
2863 : 15 : ShowCursor( sal_True );
2864 : : }
2865 : :
2866 : 122 : void SvImpLBox::SetSelectionMode( SelectionMode eSelMode )
2867 : : {
2868 : 122 : aSelEng.SetSelectionMode( eSelMode);
2869 [ + - ]: 122 : if( eSelMode == SINGLE_SELECTION )
2870 : 122 : bSimpleTravel = sal_True;
2871 : : else
2872 : 0 : bSimpleTravel = sal_False;
2873 [ - + ][ # # ]: 122 : if( (m_nStyle & WB_SIMPLEMODE) && (eSelMode == MULTIPLE_SELECTION) )
2874 : 0 : aSelEng.AddAlways( sal_True );
2875 : 122 : }
2876 : :
2877 : : // ***********************************************************************
2878 : : // Drag & Drop
2879 : : // ***********************************************************************
2880 : :
2881 : 124 : void SvImpLBox::SetDragDropMode( DragDropMode eDDMode )
2882 : : {
2883 [ - + ][ # # ]: 124 : if( eDDMode && eDDMode != SV_DRAGDROP_APP_DROP )
2884 : : {
2885 : 0 : aSelEng.ExpandSelectionOnMouseMove( sal_False );
2886 : 0 : aSelEng.EnableDrag( sal_True );
2887 : : }
2888 : : else
2889 : : {
2890 : 124 : aSelEng.ExpandSelectionOnMouseMove( sal_True );
2891 : 124 : aSelEng.EnableDrag( sal_False );
2892 : : }
2893 : 124 : }
2894 : :
2895 : 0 : void SvImpLBox::BeginDrag()
2896 : : {
2897 : 0 : nFlags &= (~F_FILLING);
2898 [ # # ]: 0 : if( !bAsyncBeginDrag )
2899 : : {
2900 : 0 : BeginScroll();
2901 : 0 : pView->StartDrag( 0, aSelEng.GetMousePosPixel() );
2902 : 0 : EndScroll();
2903 : : }
2904 : : else
2905 : : {
2906 : 0 : aAsyncBeginDragPos = aSelEng.GetMousePosPixel();
2907 : 0 : aAsyncBeginDragTimer.Start();
2908 : : }
2909 : 0 : }
2910 : :
2911 : 0 : IMPL_LINK_NOARG(SvImpLBox, BeginDragHdl)
2912 : : {
2913 : 0 : pView->StartDrag( 0, aAsyncBeginDragPos );
2914 : 0 : return 0;
2915 : : }
2916 : :
2917 : 0 : void SvImpLBox::PaintDDCursor( SvLBoxEntry* pInsertionPos )
2918 : : {
2919 : : long nY;
2920 [ # # ]: 0 : if( pInsertionPos )
2921 : : {
2922 [ # # ]: 0 : nY = GetEntryLine( pInsertionPos );
2923 : 0 : nY += pView->GetEntryHeight();
2924 : : }
2925 : : else
2926 : 0 : nY = 1;
2927 : 0 : RasterOp eOldOp = pView->GetRasterOp();
2928 [ # # ]: 0 : pView->SetRasterOp( ROP_INVERT );
2929 : 0 : Color aOldLineColor = pView->GetLineColor();
2930 [ # # ]: 0 : pView->SetLineColor( Color( COL_BLACK ) );
2931 [ # # ]: 0 : pView->DrawLine( Point( 0, nY ), Point( aOutputSize.Width(), nY ) );
2932 [ # # ]: 0 : pView->SetLineColor( aOldLineColor );
2933 [ # # ]: 0 : pView->SetRasterOp( eOldOp );
2934 : 0 : }
2935 : :
2936 : : // Delete all submenus of a PopupMenu, recursively
2937 : 0 : void lcl_DeleteSubPopups(PopupMenu* pPopup)
2938 : : {
2939 [ # # ]: 0 : for(sal_uInt16 i = 0; i < pPopup->GetItemCount(); i++)
2940 : : {
2941 : 0 : PopupMenu* pSubPopup = pPopup->GetPopupMenu( pPopup->GetItemId( i ));
2942 [ # # ]: 0 : if(pSubPopup)
2943 : : {
2944 : 0 : lcl_DeleteSubPopups(pSubPopup);
2945 [ # # ]: 0 : delete pSubPopup;
2946 : : }
2947 : : }
2948 : 0 : }
2949 : :
2950 : 0 : void SvImpLBox::Command( const CommandEvent& rCEvt )
2951 : : {
2952 : 0 : sal_uInt16 nCommand = rCEvt.GetCommand();
2953 : :
2954 [ # # ]: 0 : if( nCommand == COMMAND_CONTEXTMENU )
2955 : 0 : aEditTimer.Stop();
2956 : :
2957 : : // scroll mouse event?
2958 [ # # ][ # # ]: 0 : if( ( ( nCommand == COMMAND_WHEEL ) || ( nCommand == COMMAND_STARTAUTOSCROLL ) || ( nCommand == COMMAND_AUTOSCROLL ) )
[ # # # # ]
[ # # ]
2959 : 0 : && pView->HandleScrollCommand( rCEvt, &aHorSBar, &aVerSBar ) )
2960 : 0 : return;
2961 : :
2962 [ # # ][ # # ]: 0 : if( bContextMenuHandling && nCommand == COMMAND_CONTEXTMENU )
2963 : : {
2964 : 0 : Point aPopupPos;
2965 : 0 : sal_Bool bClickedIsFreePlace = sal_False;
2966 [ # # ][ # # ]: 0 : std::stack<SvLBoxEntry*> aSelRestore;
2967 : :
2968 [ # # ]: 0 : if( rCEvt.IsMouseEvent() )
2969 : : { // change selection, if mouse position doesn't fit to selection
2970 : :
2971 : 0 : aPopupPos = rCEvt.GetMousePosPixel();
2972 : :
2973 [ # # ]: 0 : SvLBoxEntry* pClickedEntry = GetEntry( aPopupPos );
2974 [ # # ]: 0 : if( pClickedEntry )
2975 : : { // mouse in non empty area
2976 : 0 : sal_Bool bClickedIsSelected = sal_False;
2977 : :
2978 : : // collect the currently selected entries
2979 [ # # ]: 0 : SvLBoxEntry* pSelected = pView->FirstSelected();
2980 [ # # ]: 0 : while( pSelected )
2981 : : {
2982 : 0 : bClickedIsSelected |= ( pClickedEntry == pSelected );
2983 [ # # ]: 0 : pSelected = pView->NextSelected( pSelected );
2984 : : }
2985 : :
2986 : : // if the entry which the user clicked at is not selected
2987 [ # # ]: 0 : if( !bClickedIsSelected )
2988 : : { // deselect all other and select the clicked one
2989 [ # # ]: 0 : pView->SelectAll( sal_False );
2990 [ # # ]: 0 : pView->SetCursor( pClickedEntry );
2991 : : }
2992 : : }
2993 [ # # ]: 0 : else if( aSelEng.GetSelectionMode() == SINGLE_SELECTION )
2994 : : {
2995 : 0 : bClickedIsFreePlace = sal_True;
2996 : 0 : sal_Int32 nSelectedEntries = pView->GetSelectionCount();
2997 [ # # ]: 0 : SvLBoxEntry* pSelected = pView->FirstSelected();
2998 [ # # ]: 0 : for(sal_uInt16 nSel = 0; nSel < nSelectedEntries; nSel++ )
2999 : : {
3000 [ # # ]: 0 : aSelRestore.push(pSelected);
3001 [ # # ]: 0 : pSelected = pView->NextSelected( pSelected );
3002 : : }
3003 [ # # ]: 0 : pView->SelectAll( sal_False );
3004 : : }
3005 : : else
3006 : : { // deselect all
3007 [ # # ]: 0 : pView->SelectAll( sal_False );
3008 : : }
3009 : :
3010 : :
3011 : : }
3012 : : else
3013 : : { // key event (or at least no mouse event)
3014 : 0 : sal_Int32 nSelectionCount = pView->GetSelectionCount();
3015 : :
3016 [ # # ]: 0 : if( nSelectionCount )
3017 : : { // now always take first visible as base for positioning the menu
3018 [ # # ]: 0 : SvLBoxEntry* pSelected = pView->FirstSelected();
3019 [ # # ]: 0 : while( pSelected )
3020 : : {
3021 [ # # ][ # # ]: 0 : if( IsEntryInView( pSelected ) )
3022 : 0 : break;
3023 : :
3024 [ # # ]: 0 : pSelected = pView->NextSelected( pSelected );
3025 : : }
3026 : :
3027 [ # # ]: 0 : if( !pSelected )
3028 : : {
3029 : : // no one was visible
3030 [ # # ]: 0 : pSelected = pView->FirstSelected();
3031 [ # # ]: 0 : pView->MakeVisible( pSelected );
3032 : : }
3033 : :
3034 [ # # ][ # # ]: 0 : aPopupPos = pView->GetFocusRect( pSelected, pView->GetEntryPosition( pSelected ).Y() ).Center();
[ # # ]
3035 : : }
3036 : : else
3037 : 0 : aPopupPos = Point( 0, 0 );
3038 : : }
3039 : :
3040 [ # # ]: 0 : PopupMenu* pPopup = pView->CreateContextMenu();
3041 : :
3042 [ # # ]: 0 : if( pPopup )
3043 : : {
3044 : : // do action for selected entry in popup menu
3045 [ # # ]: 0 : sal_uInt16 nMenuAction = pPopup->Execute( pView, aPopupPos );
3046 [ # # ]: 0 : if ( nMenuAction )
3047 [ # # ]: 0 : pView->ExcecuteContextMenuAction( nMenuAction );
3048 [ # # ]: 0 : lcl_DeleteSubPopups(pPopup);
3049 [ # # ][ # # ]: 0 : delete pPopup;
3050 : : }
3051 : :
3052 [ # # ]: 0 : if( bClickedIsFreePlace )
3053 : : {
3054 [ # # ][ # # ]: 0 : while(!aSelRestore.empty())
3055 : : {
3056 [ # # ]: 0 : SvLBoxEntry* pEntry = aSelRestore.top();
3057 : : //#i19717# the entry is maybe already deleted
3058 : 0 : bool bFound = false;
3059 [ # # ]: 0 : for(sal_uLong nEntry = 0; nEntry < pView->GetEntryCount(); nEntry++)
3060 [ # # ][ # # ]: 0 : if(pEntry == pView->GetEntry(nEntry))
3061 : : {
3062 : 0 : bFound = true;
3063 : 0 : break;
3064 : : }
3065 [ # # ]: 0 : if(bFound)
3066 [ # # ]: 0 : SetCurEntry( pEntry );
3067 [ # # ]: 0 : aSelRestore.pop();
3068 : : }
3069 : 0 : }
3070 : : }
3071 : : #ifndef NOCOMMAND
3072 : : else
3073 : : {
3074 : 0 : const Point& rPos = rCEvt.GetMousePosPixel();
3075 [ # # ][ # # ]: 0 : if( rPos.X() < aOutputSize.Width() && rPos.Y() < aOutputSize.Height() )
[ # # ]
3076 : 0 : aSelEng.Command( rCEvt );
3077 : : }
3078 : : #endif
3079 : : }
3080 : :
3081 : 0 : void SvImpLBox::BeginScroll()
3082 : : {
3083 [ # # ]: 0 : if( !(nFlags & F_IN_SCROLLING))
3084 : : {
3085 : 0 : pView->NotifyBeginScroll();
3086 : 0 : nFlags |= F_IN_SCROLLING;
3087 : : }
3088 : 0 : }
3089 : :
3090 : 0 : void SvImpLBox::EndScroll()
3091 : : {
3092 [ # # ]: 0 : if( nFlags & F_IN_SCROLLING)
3093 : : {
3094 : 0 : pView->NotifyEndScroll();
3095 : 0 : nFlags &= (~F_IN_SCROLLING);
3096 : : }
3097 : 0 : }
3098 : :
3099 : :
3100 : 144 : Rectangle SvImpLBox::GetVisibleArea() const
3101 : : {
3102 : 144 : Point aPos( pView->GetMapMode().GetOrigin() );
3103 : 144 : aPos.X() *= -1;
3104 [ + - ]: 144 : Rectangle aRect( aPos, aOutputSize );
3105 : 144 : return aRect;
3106 : : }
3107 : :
3108 : 248 : void SvImpLBox::Invalidate()
3109 : : {
3110 : 248 : pView->SetClipRegion();
3111 : 248 : }
3112 : :
3113 : 0 : void SvImpLBox::SetCurEntry( SvLBoxEntry* pEntry )
3114 : : {
3115 [ # # # # ]: 0 : if ( ( aSelEng.GetSelectionMode() != SINGLE_SELECTION )
[ # # ]
3116 : 0 : && ( aSelEng.GetSelectionMode() != NO_SELECTION )
3117 : : )
3118 : 0 : SelAllDestrAnch( sal_False, sal_True, sal_False );
3119 [ # # ]: 0 : if ( pEntry )
3120 : 0 : MakeVisible( pEntry );
3121 : 0 : SetCursor( pEntry );
3122 [ # # ][ # # ]: 0 : if ( pEntry && ( aSelEng.GetSelectionMode() != NO_SELECTION ) )
[ # # ]
3123 : 0 : pView->Select( pEntry, sal_True );
3124 : 0 : }
3125 : :
3126 : 0 : IMPL_LINK_NOARG(SvImpLBox, EditTimerCall)
3127 : : {
3128 [ # # ]: 0 : if( pView->IsInplaceEditingEnabled() )
3129 : : {
3130 : 0 : sal_Bool bIsMouseTriggered = aEditClickPos.X() >= 0;
3131 [ # # ]: 0 : if ( bIsMouseTriggered )
3132 : : {
3133 [ # # ]: 0 : Point aCurrentMousePos = pView->GetPointerPosPixel();
3134 [ # # # # ]: 0 : if ( ( abs( aCurrentMousePos.X() - aEditClickPos.X() ) > 5 )
[ # # ]
3135 : 0 : || ( abs( aCurrentMousePos.Y() - aEditClickPos.Y() ) > 5 )
3136 : : )
3137 : : {
3138 : 0 : return 0L;
3139 : : }
3140 : : }
3141 : :
3142 : 0 : SvLBoxEntry* pEntry = GetCurEntry();
3143 [ # # ]: 0 : if( pEntry )
3144 : : {
3145 : 0 : ShowCursor( sal_False );
3146 : 0 : pView->ImplEditEntry( pEntry );
3147 : 0 : ShowCursor( sal_True );
3148 : : }
3149 : : }
3150 : 0 : return 0;
3151 : : }
3152 : :
3153 : 0 : sal_Bool SvImpLBox::RequestHelp( const HelpEvent& rHEvt )
3154 : : {
3155 [ # # ]: 0 : if( rHEvt.GetMode() & HELPMODE_QUICK )
3156 : : {
3157 [ # # ][ # # ]: 0 : Point aPos( pView->ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
3158 [ # # ][ # # ]: 0 : if( !GetVisibleArea().IsInside( aPos ))
[ # # ]
3159 : 0 : return sal_False;
3160 : :
3161 [ # # ]: 0 : SvLBoxEntry* pEntry = GetEntry( aPos );
3162 [ # # ]: 0 : if( pEntry )
3163 : : {
3164 : : // recalculate text rectangle
3165 : : SvLBoxTab* pTab;
3166 [ # # ]: 0 : SvLBoxString* pItem = (SvLBoxString*)(pView->GetItem( pEntry, aPos.X(), &pTab ));
3167 [ # # ][ # # ]: 0 : if( !pItem || pItem->IsA() != SV_ITEM_ID_LBOXSTRING )
[ # # ][ # # ]
3168 : 0 : return sal_False;
3169 : :
3170 [ # # ]: 0 : aPos = GetEntryPosition( pEntry );
3171 [ # # ]: 0 : aPos.X() = pView->GetTabPos( pEntry, pTab ); //pTab->GetPos();
3172 [ # # ]: 0 : Size aSize( pItem->GetSize( pView, pEntry ) );
3173 [ # # ]: 0 : SvLBoxTab* pNextTab = NextTab( pTab );
3174 : 0 : sal_Bool bItemClipped = sal_False;
3175 : : // is the item cut off by its right neighbor?
3176 [ # # ][ # # ]: 0 : if( pNextTab && pView->GetTabPos(pEntry,pNextTab) < aPos.X()+aSize.Width() )
[ # # ][ # # ]
3177 : : {
3178 : 0 : aSize.Width() = pNextTab->GetPos() - pTab->GetPos();
3179 : 0 : bItemClipped = sal_True;
3180 : : }
3181 [ # # ]: 0 : Rectangle aItemRect( aPos, aSize );
3182 : :
3183 [ # # ]: 0 : Rectangle aViewRect( GetVisibleArea() );
3184 : :
3185 [ # # ][ # # ]: 0 : if( bItemClipped || !aViewRect.IsInside( aItemRect ) )
[ # # ][ # # ]
3186 : : {
3187 : : // clip the right edge of the item at the edge of the view
3188 : : //if( aItemRect.Right() > aViewRect.Right() )
3189 : : // aItemRect.Right() = aViewRect.Right();
3190 : :
3191 [ # # ]: 0 : Point aPt = pView->OutputToScreenPixel( aItemRect.TopLeft() );
3192 : 0 : aItemRect.Left() = aPt.X();
3193 : 0 : aItemRect.Top() = aPt.Y();
3194 [ # # ][ # # ]: 0 : aPt = pView->OutputToScreenPixel( aItemRect.BottomRight() );
3195 : 0 : aItemRect.Right() = aPt.X();
3196 : 0 : aItemRect.Bottom() = aPt.Y();
3197 : :
3198 : : Help::ShowQuickHelp( pView, aItemRect,
3199 [ # # ][ # # ]: 0 : pItem->GetText(), QUICKHELP_LEFT | QUICKHELP_VCENTER );
[ # # ]
3200 : 0 : return sal_True;
3201 : : }
3202 : : }
3203 : : }
3204 : 0 : return sal_False;
3205 : : }
3206 : :
3207 : 0 : SvLBoxTab* SvImpLBox::NextTab( SvLBoxTab* pTab )
3208 : : {
3209 : 0 : sal_uInt16 nTabCount = pView->TabCount();
3210 [ # # ]: 0 : if( nTabCount <= 1 )
3211 : 0 : return 0;
3212 [ # # ]: 0 : for( sal_uInt16 nTab=0; nTab < (nTabCount-1); nTab++)
3213 : : {
3214 [ # # ]: 0 : if( pView->aTabs[nTab]==pTab )
3215 : 0 : return (SvLBoxTab*)(pView->aTabs[nTab+1]);
3216 : : }
3217 : 0 : return 0;
3218 : : }
3219 : :
3220 : 0 : void SvImpLBox::EndSelection()
3221 : : {
3222 : 0 : DestroyAnchor();
3223 : 0 : nFlags &= ~F_START_EDITTIMER;
3224 : 0 : }
3225 : :
3226 : 128 : void SvImpLBox::RepaintScrollBars()
3227 : : {
3228 : 128 : }
3229 : :
3230 : 240 : void SvImpLBox::SetUpdateMode( sal_Bool bMode )
3231 : : {
3232 [ + - ]: 240 : if( bUpdateMode != bMode )
3233 : : {
3234 : 240 : bUpdateMode = bMode;
3235 [ + + ]: 240 : if( bUpdateMode )
3236 : 120 : UpdateAll( sal_False );
3237 : : }
3238 : 240 : }
3239 : :
3240 : 2414 : sal_Bool SvImpLBox::SetMostRight( SvLBoxEntry* pEntry )
3241 : : {
3242 [ + + ]: 2414 : if( pView->nTreeFlags & TREEFLAG_RECALCTABS )
3243 : : {
3244 : 2 : nFlags |= F_IGNORE_CHANGED_TABS;
3245 : 2 : pView->SetTabs();
3246 : 2 : nFlags &= ~F_IGNORE_CHANGED_TABS;
3247 : : }
3248 : :
3249 : 2414 : sal_uInt16 nLastTab = pView->aTabs.size() - 1;
3250 : 2414 : sal_uInt16 nLastItem = pEntry->ItemCount() - 1;
3251 [ + - ][ + - ]: 2414 : if( !pView->aTabs.empty() && nLastItem != USHRT_MAX )
[ + - ]
3252 : : {
3253 [ - + ]: 2414 : if( nLastItem < nLastTab )
3254 : 0 : nLastTab = nLastItem;
3255 : :
3256 : 2414 : SvLBoxTab* pTab = pView->aTabs[ nLastTab ];
3257 [ + - ]: 2414 : SvLBoxItem* pItem = pEntry->GetItem( nLastTab );
3258 : :
3259 [ + - ]: 2414 : long nTabPos = pView->GetTabPos( pEntry, pTab );
3260 : :
3261 : 2414 : long nMaxRight = GetOutputSize().Width();
3262 : 2414 : Point aPos( pView->GetMapMode().GetOrigin() );
3263 : 2414 : aPos.X() *= -1; // conversion document coordinates
3264 : 2414 : nMaxRight = nMaxRight + aPos.X() - 1;
3265 : :
3266 [ + + ]: 2414 : long nNextTab = nTabPos < nMaxRight ? nMaxRight : nMaxRight + 50;
3267 : 2414 : long nTabWidth = nNextTab - nTabPos + 1;
3268 [ + - ]: 2414 : long nItemSize = pItem->GetSize(pView,pEntry).Width();
3269 [ + - ]: 2414 : long nOffset = pTab->CalcOffset( nItemSize, nTabWidth );
3270 : :
3271 : 2414 : long nRight = nTabPos + nOffset + nItemSize;
3272 [ + + ]: 2414 : if( nRight > nMostRight )
3273 : : {
3274 : 132 : nMostRight = nRight;
3275 : 132 : pMostRightEntry = pEntry;
3276 : 2414 : return sal_True;
3277 : : }
3278 : : }
3279 : 2414 : return sal_False;
3280 : : }
3281 : :
3282 : 120 : void SvImpLBox::FindMostRight( SvLBoxEntry* pEntryToIgnore )
3283 : : {
3284 : 120 : nMostRight = -1;
3285 : 120 : pMostRightEntry = 0;
3286 [ - + ]: 120 : if( !pView->GetModel() )
3287 : 120 : return;
3288 : :
3289 : 120 : SvLBoxEntry* pEntry = (SvLBoxEntry*)pView->FirstVisible();
3290 [ + + ]: 2510 : while( pEntry )
3291 : : {
3292 [ + - ]: 2390 : if( pEntry != pEntryToIgnore )
3293 : 2390 : SetMostRight( pEntry );
3294 : 2390 : pEntry = (SvLBoxEntry*)pView->NextVisible( pEntry );
3295 : : }
3296 : : }
3297 : :
3298 : 4 : void SvImpLBox::FindMostRight( SvLBoxEntry* pParent, SvLBoxEntry* pEntryToIgnore )
3299 : : {
3300 [ - + ]: 4 : if( !pParent )
3301 : 0 : FindMostRight( pEntryToIgnore );
3302 : : else
3303 : 4 : FindMostRight_Impl( pParent, pEntryToIgnore );
3304 : 4 : }
3305 : :
3306 : 4 : void SvImpLBox::FindMostRight_Impl( SvLBoxEntry* pParent, SvLBoxEntry* pEntryToIgnore )
3307 : : {
3308 : 4 : SvTreeEntryList* pList = pTree->GetChildList( pParent );
3309 : :
3310 [ - + ]: 4 : if( !pList )
3311 : 4 : return;
3312 : :
3313 : 4 : size_t nCount = pList->size();
3314 [ + + ]: 10 : for( size_t nCur = 0; nCur < nCount; nCur++ )
3315 : : {
3316 : 6 : SvLBoxEntry* pChild = (SvLBoxEntry*)(*pList)[ nCur ];
3317 [ + - ]: 6 : if( pChild != pEntryToIgnore )
3318 : : {
3319 : 6 : SetMostRight( pChild );
3320 [ # # ][ - + ]: 6 : if( pChild->HasChildren() && pView->IsExpanded( pChild ))
[ - + ]
3321 : 0 : FindMostRight_Impl( pChild, pEntryToIgnore );
3322 : : }
3323 : : }
3324 : : }
3325 : :
3326 : 376 : void SvImpLBox::NotifyTabsChanged()
3327 : : {
3328 [ + + ][ + + ]: 376 : if( GetUpdateMode() && !(nFlags & F_IGNORE_CHANGED_TABS ) &&
[ + + ][ + + ]
3329 : : nCurUserEvent == 0xffffffff )
3330 : : {
3331 [ + - ]: 126 : nCurUserEvent = Application::PostUserEvent(LINK(this,SvImpLBox,MyUserEvent),(void*)0);
3332 : : }
3333 : 376 : }
3334 : :
3335 : 2 : IMPL_LINK(SvImpLBox,MyUserEvent,void*, pArg )
3336 : : {
3337 : 2 : nCurUserEvent = 0xffffffff;
3338 [ + - ]: 2 : if( !pArg )
3339 : : {
3340 : 2 : pView->Invalidate();
3341 : 2 : pView->Update();
3342 : : }
3343 : : else
3344 : : {
3345 : 0 : FindMostRight( 0 );
3346 : 0 : ShowVerSBar();
3347 [ # # ]: 0 : pView->Invalidate( GetVisibleArea() );
3348 : : }
3349 : 2 : return 0;
3350 : : }
3351 : :
3352 : :
3353 : 246 : void SvImpLBox::StopUserEvent()
3354 : : {
3355 [ + + ]: 246 : if( nCurUserEvent != 0xffffffff )
3356 : : {
3357 : 124 : Application::RemoveUserEvent( nCurUserEvent );
3358 : 124 : nCurUserEvent = 0xffffffff;
3359 : : }
3360 : 246 : }
3361 : :
3362 : 0 : void SvImpLBox::ShowFocusRect( const SvLBoxEntry* pEntry )
3363 : : {
3364 [ # # ]: 0 : if( pEntry )
3365 : : {
3366 [ # # ]: 0 : long nY = GetEntryLine( (SvLBoxEntry*)pEntry );
3367 [ # # ]: 0 : Rectangle aRect = pView->GetFocusRect( (SvLBoxEntry*)pEntry, nY );
3368 [ # # ]: 0 : Region aOldClip( pView->GetClipRegion());
3369 [ # # ][ # # ]: 0 : Region aClipRegion( GetClipRegionRect() );
3370 [ # # ]: 0 : pView->SetClipRegion( aClipRegion );
3371 [ # # ]: 0 : pView->ShowFocus( aRect );
3372 [ # # ][ # # ]: 0 : pView->SetClipRegion( aOldClip );
[ # # ]
3373 : :
3374 : : }
3375 : : else
3376 : : {
3377 : 0 : pView->HideFocus();
3378 : : }
3379 : 0 : }
3380 : :
3381 : : // -----------------------------------------------------------------------
3382 : 4 : void SvImpLBox::implInitDefaultNodeImages()
3383 : : {
3384 [ + + ]: 4 : if ( s_pDefCollapsed )
3385 : : // assume that all or nothing is initialized
3386 : 4 : return;
3387 : :
3388 [ + - ][ + - ]: 2 : s_pDefCollapsed = new Image( SvtResId( RID_IMG_TREENODE_COLLAPSED ) );
3389 [ + - ][ + - ]: 2 : s_pDefExpanded = new Image( SvtResId( RID_IMG_TREENODE_EXPANDED ) );
3390 : : }
3391 : :
3392 : : // -----------------------------------------------------------------------
3393 : 2 : const Image& SvImpLBox::GetDefaultExpandedNodeImage( )
3394 : : {
3395 : 2 : implInitDefaultNodeImages();
3396 : 2 : return *s_pDefExpanded;
3397 : : }
3398 : :
3399 : : // -----------------------------------------------------------------------
3400 : 2 : const Image& SvImpLBox::GetDefaultCollapsedNodeImage( )
3401 : : {
3402 : 2 : implInitDefaultNodeImages();
3403 : 2 : return *s_pDefCollapsed;
3404 : : }
3405 : :
3406 : : // -----------------------------------------------------------------------
3407 : 250 : void SvImpLBox::CallEventListeners( sal_uLong nEvent, void* pData )
3408 : : {
3409 [ + - ]: 250 : if ( pView )
3410 : 250 : pView->CallImplEventListeners( nEvent, pData);
3411 : 250 : }
3412 : :
3413 : : // -----------------------------------------------------------------------
3414 : :
3415 : 0 : bool SvImpLBox::SetCurrentTabPos( sal_uInt16 _nNewPos )
3416 : : {
3417 : 0 : bool bRet = false;
3418 : :
3419 [ # # ][ # # ]: 0 : if ( pView && _nNewPos < ( pView->TabCount() - 2 ) )
[ # # ]
3420 : : {
3421 : 0 : nCurTabPos = _nNewPos;
3422 : 0 : ShowCursor( sal_True );
3423 : 0 : bRet = true;
3424 : : }
3425 : :
3426 : 0 : return bRet;
3427 : : }
3428 : :
3429 : : // -----------------------------------------------------------------------
3430 : :
3431 : 0 : bool SvImpLBox::IsSelectable( const SvLBoxEntry* pEntry )
3432 : : {
3433 [ # # ]: 0 : if( pEntry )
3434 : : {
3435 : 0 : SvViewDataEntry* pViewDataNewCur = pView->GetViewDataEntry(const_cast<SvLBoxEntry*>(pEntry));
3436 [ # # ][ # # ]: 0 : return (pViewDataNewCur == 0) || pViewDataNewCur->IsSelectable();
3437 : : }
3438 : : else
3439 : : {
3440 : 0 : return false;
3441 : : }
3442 : : }
3443 : :
3444 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|