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 : : #define _SVTREEBX_CXX
30 : : #include <vcl/svapp.hxx>
31 : :
32 : : #include <svtools/svlbox.hxx>
33 : : #include <svtools/svlbitm.hxx>
34 : : #include <svtools/svtreebx.hxx>
35 : : #include <comphelper/string.hxx>
36 : : #include <svimpbox.hxx>
37 : : #include <unotools/accessiblestatesethelper.hxx>
38 : : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
39 : : #include <com/sun/star/awt/XWindowPeer.hpp>
40 : :
41 : :
42 : : using namespace ::com::sun::star::accessibility;
43 : :
44 : : /*
45 : : Bugs/TODO
46 : :
47 : : - calculate rectangle when editing in-place (bug with some fonts)
48 : : - SetSpaceBetweenEntries: offset is not taken into account in SetEntryHeight
49 : : */
50 : :
51 : : #define TREEFLAG_FIXEDHEIGHT 0x0010
52 : :
53 : :
54 : : DBG_NAME(SvTreeListBox)
55 : :
56 : : #define SV_LBOX_DEFAULT_INDENT_PIXEL 20
57 : :
58 : 122 : SvTreeListBox::SvTreeListBox( Window* pParent, WinBits nWinStyle )
59 [ + - ][ + - ]: 122 : : SvLBox( pParent, nWinStyle )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
60 : : {
61 : : DBG_CTOR(SvTreeListBox,0);
62 [ + - ]: 122 : InitTreeView();
63 : :
64 [ + - ]: 122 : SetSublistOpenWithLeftRight();
65 : 122 : }
66 : :
67 : 0 : SvTreeListBox::SvTreeListBox( Window* pParent , const ResId& rResId )
68 [ # # ][ # # ]: 0 : : SvLBox( pParent,rResId )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
69 : : {
70 : : DBG_CTOR(SvTreeListBox,0);
71 : :
72 [ # # ]: 0 : InitTreeView();
73 [ # # ]: 0 : Resize();
74 : :
75 [ # # ]: 0 : SetSublistOpenWithLeftRight();
76 : 0 : }
77 : :
78 : 122 : void SvTreeListBox::InitTreeView()
79 : : {
80 : : DBG_CHKTHIS(SvTreeListBox,0);
81 : 122 : pCheckButtonData = NULL;
82 : 122 : pEdEntry = NULL;
83 : 122 : pEdItem = NULL;
84 : 122 : nEntryHeight = 0;
85 : 122 : pEdCtrl = NULL;
86 : 122 : nFirstSelTab = 0;
87 : 122 : nLastSelTab = 0;
88 : 122 : nFocusWidth = -1;
89 : 122 : mnCheckboxItemWidth = 0;
90 : :
91 [ + - ]: 122 : Link* pLink = new Link( LINK(this,SvTreeListBox, DefaultCompare) );
92 : 122 : pLBoxImpl->m_pLink = pLink;
93 : :
94 : 122 : nTreeFlags = TREEFLAG_RECALCTABS;
95 : 122 : nIndent = SV_LBOX_DEFAULT_INDENT_PIXEL;
96 : 122 : nEntryHeightOffs = SV_ENTRYHEIGHTOFFS_PIXEL;
97 [ + - ]: 122 : pImp = new SvImpLBox( this, GetModel(), GetStyle() );
98 : :
99 : 122 : aContextBmpMode = SVLISTENTRYFLAG_EXPANDED;
100 : 122 : nContextBmpWidthMax = 0;
101 : 122 : SetFont( GetFont() );
102 : 122 : SetSpaceBetweenEntries( 0 );
103 : 122 : SetLineColor();
104 : 122 : InitSettings( sal_True, sal_True, sal_True );
105 : 122 : ImplInitStyle();
106 : 122 : SetTabs();
107 : 122 : }
108 : :
109 : :
110 [ + - ][ + - ]: 122 : SvTreeListBox::~SvTreeListBox()
[ + - ][ + - ]
[ + - ]
111 : : {
112 : : DBG_DTOR(SvTreeListBox,0);
113 [ + - ]: 122 : pImp->CallEventListeners( VCLEVENT_OBJECT_DYING );
114 [ + - ][ + - ]: 122 : delete pImp;
115 : 122 : delete pLBoxImpl->m_pLink;
116 [ + - ]: 122 : ClearTabList();
117 [ - + ]: 122 : }
118 : :
119 : 0 : void SvTreeListBox::SetExtendedWinBits( ExtendedWinBits _nBits )
120 : : {
121 : 0 : pImp->SetExtendedWindowBits( _nBits );
122 : 0 : }
123 : :
124 : 2 : void SvTreeListBox::SetModel( SvLBoxTreeList* pNewModel )
125 : : {
126 : : DBG_CHKTHIS(SvTreeListBox,0);
127 : 2 : pImp->SetModel( pNewModel );
128 : 2 : SvLBox::SetModel( pNewModel );
129 : 2 : }
130 : :
131 : 2 : void SvTreeListBox::DisconnectFromModel()
132 : : {
133 : : DBG_CHKTHIS(SvTreeListBox,0);
134 : 2 : SvLBox::DisconnectFromModel();
135 : 2 : pImp->SetModel( GetModel() );
136 : 2 : }
137 : :
138 : :
139 : 0 : sal_uInt16 SvTreeListBox::IsA()
140 : : {
141 : : DBG_CHKTHIS(SvTreeListBox,0);
142 : 0 : return SV_LISTBOX_ID_TREEBOX;
143 : : }
144 : :
145 : 0 : void SvTreeListBox::SetSublistOpenWithReturn( sal_Bool b )
146 : : {
147 : 0 : pImp->bSubLstOpRet = b;
148 : 0 : }
149 : :
150 : 122 : void SvTreeListBox::SetSublistOpenWithLeftRight( sal_Bool b )
151 : : {
152 : 122 : pImp->bSubLstOpLR = b;
153 : 122 : }
154 : :
155 : 255 : void SvTreeListBox::Resize()
156 : : {
157 : : DBG_CHKTHIS(SvTreeListBox,0);
158 [ - + ]: 255 : if( IsEditingActive() )
159 : 0 : EndEditing( sal_True );
160 : 255 : SvLBox::Resize();
161 : 255 : pImp->Resize();
162 : 255 : nFocusWidth = -1;
163 : 255 : pImp->ShowCursor( sal_False );
164 : 255 : pImp->ShowCursor( sal_True );
165 : 255 : }
166 : :
167 : : /* Cases:
168 : :
169 : : A) entries have bitmaps
170 : : 0. no buttons
171 : : 1. node buttons (can optionally also be on root items)
172 : : 2. node buttons (can optionally also be on root items) + CheckButton
173 : : 3. CheckButton
174 : : B) entries don't have bitmaps (=>via WindowBits because of D&D!)
175 : : 0. no buttons
176 : : 1. node buttons (can optionally also be on root items)
177 : : 2. node buttons (can optionally also be on root items) + CheckButton
178 : : 3. CheckButton
179 : : */
180 : :
181 : : #define NO_BUTTONS 0
182 : : #define NODE_BUTTONS 1
183 : : #define NODE_AND_CHECK_BUTTONS 2
184 : : #define CHECK_BUTTONS 3
185 : :
186 : : #define TABFLAGS_TEXT (SV_LBOXTAB_DYNAMIC | \
187 : : SV_LBOXTAB_ADJUST_LEFT | \
188 : : SV_LBOXTAB_EDITABLE | \
189 : : SV_LBOXTAB_SHOW_SELECTION)
190 : :
191 : : #define TABFLAGS_CONTEXTBMP (SV_LBOXTAB_DYNAMIC | SV_LBOXTAB_ADJUST_CENTER)
192 : :
193 : : #define TABFLAGS_CHECKBTN (SV_LBOXTAB_DYNAMIC | \
194 : : SV_LBOXTAB_ADJUST_CENTER | \
195 : : SV_LBOXTAB_PUSHABLE)
196 : :
197 : : #define TAB_STARTPOS 2
198 : :
199 : : // take care of GetTextOffset when doing changes
200 : 376 : void SvTreeListBox::SetTabs()
201 : : {
202 : : DBG_CHKTHIS(SvTreeListBox,0);
203 [ - + ]: 376 : if( IsEditingActive() )
204 : 0 : EndEditing( sal_True );
205 : 376 : nTreeFlags &= (~TREEFLAG_RECALCTABS);
206 : 376 : nFocusWidth = -1;
207 : 376 : const WinBits nStyle( GetStyle() );
208 : 376 : sal_Bool bHasButtons = (nStyle & WB_HASBUTTONS)!=0;
209 : : sal_Bool bHasButtonsAtRoot = (nStyle & (WB_HASLINESATROOT |
210 : 376 : WB_HASBUTTONSATROOT))!=0;
211 : 376 : long nStartPos = TAB_STARTPOS;
212 [ + - ]: 376 : long nNodeWidthPixel = GetExpandedNodeBmp().GetSizePixel().Width();
213 : :
214 : : // pCheckButtonData->Width() knows nothing about the native checkbox width,
215 : : // so we have mnCheckboxItemWidth which becomes valid when something is added.
216 : 376 : long nCheckWidth = 0;
217 [ - + ]: 376 : if( nTreeFlags & TREEFLAG_CHKBTN )
218 : 0 : nCheckWidth = mnCheckboxItemWidth;
219 : 376 : long nCheckWidthDIV2 = nCheckWidth / 2;
220 : :
221 : 376 : long nContextWidth = nContextBmpWidthMax;
222 : 376 : long nContextWidthDIV2 = nContextWidth / 2;
223 : :
224 : 376 : ClearTabList();
225 : :
226 : 376 : int nCase = NO_BUTTONS;
227 [ + - ]: 376 : if( !(nTreeFlags & TREEFLAG_CHKBTN) )
228 : : {
229 [ + + ]: 376 : if( bHasButtons )
230 : 16 : nCase = NODE_BUTTONS;
231 : : }
232 : : else
233 : : {
234 [ # # ]: 0 : if( bHasButtons )
235 : 0 : nCase = NODE_AND_CHECK_BUTTONS;
236 : : else
237 : 0 : nCase = CHECK_BUTTONS;
238 : : }
239 : :
240 [ + + - - : 376 : switch( nCase )
- ]
241 : : {
242 : : case NO_BUTTONS :
243 : 360 : nStartPos += nContextWidthDIV2; // because of centering
244 : 360 : AddTab( nStartPos, TABFLAGS_CONTEXTBMP );
245 : 360 : nStartPos += nContextWidthDIV2; // right edge of context bitmap
246 : : // only set a distance if there are bitmaps
247 [ - + ]: 360 : if( nContextBmpWidthMax )
248 : 0 : nStartPos += 5; // distance context bitmap to text
249 : 360 : AddTab( nStartPos, TABFLAGS_TEXT );
250 : 360 : break;
251 : :
252 : : case NODE_BUTTONS :
253 [ + - ]: 16 : if( bHasButtonsAtRoot )
254 : 16 : nStartPos += ( nIndent + (nNodeWidthPixel/2) );
255 : : else
256 : 0 : nStartPos += nContextWidthDIV2;
257 : 16 : AddTab( nStartPos, TABFLAGS_CONTEXTBMP );
258 : 16 : nStartPos += nContextWidthDIV2; // right edge of context bitmap
259 : : // only set a distance if there are bitmaps
260 [ + + ]: 16 : if( nContextBmpWidthMax )
261 : 2 : nStartPos += 5; // distance context bitmap to text
262 : 16 : AddTab( nStartPos, TABFLAGS_TEXT );
263 : 16 : break;
264 : :
265 : : case NODE_AND_CHECK_BUTTONS :
266 [ # # ]: 0 : if( bHasButtonsAtRoot )
267 : 0 : nStartPos += ( nIndent + nNodeWidthPixel );
268 : : else
269 : 0 : nStartPos += nCheckWidthDIV2;
270 : 0 : AddTab( nStartPos, TABFLAGS_CHECKBTN );
271 : 0 : nStartPos += nCheckWidthDIV2; // right edge of CheckButton
272 : 0 : nStartPos += 3; // distance CheckButton to context bitmap
273 : 0 : nStartPos += nContextWidthDIV2; // center of context bitmap
274 : 0 : AddTab( nStartPos, TABFLAGS_CONTEXTBMP );
275 : 0 : nStartPos += nContextWidthDIV2; // right edge of context bitmap
276 : : // only set a distance if there are bitmaps
277 [ # # ]: 0 : if( nContextBmpWidthMax )
278 : 0 : nStartPos += 5; // distance context bitmap to text
279 : 0 : AddTab( nStartPos, TABFLAGS_TEXT );
280 : 0 : break;
281 : :
282 : : case CHECK_BUTTONS :
283 : 0 : nStartPos += nCheckWidthDIV2;
284 : 0 : AddTab( nStartPos, TABFLAGS_CHECKBTN );
285 : 0 : nStartPos += nCheckWidthDIV2; // right edge of CheckButton
286 : 0 : nStartPos += 3; // distance CheckButton to context bitmap
287 : 0 : nStartPos += nContextWidthDIV2; // center of context bitmap
288 : 0 : AddTab( nStartPos, TABFLAGS_CONTEXTBMP );
289 : 0 : nStartPos += nContextWidthDIV2; // right edge of context bitmap
290 : : // only set a distance if there are bitmaps
291 [ # # ]: 0 : if( nContextBmpWidthMax )
292 : 0 : nStartPos += 5; // distance context bitmap to text
293 : 0 : AddTab( nStartPos, TABFLAGS_TEXT );
294 : 0 : break;
295 : : }
296 : 376 : pImp->NotifyTabsChanged();
297 : 376 : }
298 : :
299 : 2398 : void SvTreeListBox::InitEntry( SvLBoxEntry* pEntry,
300 : : const XubString& aStr, const Image& aCollEntryBmp, const Image& aExpEntryBmp,
301 : : SvLBoxButtonKind eButtonKind)
302 : : {
303 : : DBG_CHKTHIS(SvTreeListBox,0);
304 : : SvLBoxButton* pButton;
305 : : SvLBoxString* pString;
306 : : SvLBoxContextBmp* pContextBmp;
307 : :
308 [ - + ]: 2398 : if( nTreeFlags & TREEFLAG_CHKBTN )
309 : : {
310 [ # # ]: 0 : pButton= new SvLBoxButton( pEntry,eButtonKind,0,pCheckButtonData );
311 : 0 : pEntry->AddItem( pButton );
312 : : }
313 : :
314 : : pContextBmp= new SvLBoxContextBmp( pEntry,0, aCollEntryBmp,aExpEntryBmp,
315 [ + - ][ + - ]: 2398 : aContextBmpMode );
[ + - ][ + - ]
316 : 2398 : pEntry->AddItem( pContextBmp );
317 : :
318 [ + - ][ + - ]: 2398 : pString = new SvLBoxString( pEntry, 0, aStr );
319 : 2398 : pEntry->AddItem( pString );
320 : 2398 : }
321 : :
322 : 7144 : String SvTreeListBox::GetEntryText(SvLBoxEntry* pEntry) const
323 : : {
324 : : DBG_CHKTHIS(SvTreeListBox,0);
325 : : DBG_ASSERT( pEntry, "SvTreeListBox::GetEntryText(): no entry" );
326 : 7144 : SvLBoxString* pItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
327 : : DBG_ASSERT( pEntry, "SvTreeListBox::GetEntryText(): item not found" );
328 [ + - ]: 7144 : return pItem->GetText();
329 : : }
330 : :
331 : 0 : String SvTreeListBox::SearchEntryText( SvLBoxEntry* pEntry ) const
332 : : {
333 : : DBG_CHKTHIS(SvTreeListBox,0);
334 : : DBG_ASSERT( pEntry, "SvTreeListBox::SearchEntryText(): no entry" );
335 : 0 : String sRet;
336 : 0 : sal_uInt16 nCount = pEntry->ItemCount();
337 : 0 : sal_uInt16 nCur = 0;
338 : : SvLBoxItem* pItem;
339 [ # # ]: 0 : while( nCur < nCount )
340 : : {
341 [ # # ]: 0 : pItem = pEntry->GetItem( nCur );
342 [ # # ][ # # ]: 0 : if ( pItem->IsA() == SV_ITEM_ID_LBOXSTRING && !static_cast<SvLBoxString*>( pItem )->GetText().isEmpty() )
[ # # ][ # # ]
[ # # # # ]
343 : : {
344 [ # # ]: 0 : sRet = static_cast<SvLBoxString*>( pItem )->GetText();
345 : 0 : break;
346 : : }
347 : 0 : nCur++;
348 : : }
349 : 0 : return sRet;
350 : : }
351 : :
352 : 8 : const Image& SvTreeListBox::GetExpandedEntryBmp(SvLBoxEntry* pEntry) const
353 : : {
354 : : DBG_CHKTHIS(SvTreeListBox,0);
355 : : DBG_ASSERT(pEntry,"Entry?");
356 : 8 : SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
357 : : DBG_ASSERT(pItem,"GetContextBmp:Item not found");
358 : 8 : return pItem->GetBitmap2( );
359 : : }
360 : :
361 : 8 : const Image& SvTreeListBox::GetCollapsedEntryBmp( SvLBoxEntry* pEntry ) const
362 : : {
363 : : DBG_CHKTHIS(SvTreeListBox,0);
364 : : DBG_ASSERT(pEntry,"Entry?");
365 : 8 : SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
366 : : DBG_ASSERT(pItem,"GetContextBmp:Item not found");
367 : 8 : return pItem->GetBitmap1( );
368 : : }
369 : :
370 : 0 : IMPL_LINK_INLINE_START( SvTreeListBox, CheckButtonClick, SvLBoxButtonData *, pData )
371 : : {
372 : : DBG_CHKTHIS(SvTreeListBox,0);
373 : 0 : pHdlEntry = pData->GetActEntry();
374 : 0 : CheckButtonHdl();
375 : 0 : return 0;
376 : : }
377 : 0 : IMPL_LINK_INLINE_END( SvTreeListBox, CheckButtonClick, SvLBoxButtonData *, pData )
378 : :
379 : 2392 : SvLBoxEntry* SvTreeListBox::InsertEntry(
380 : : const XubString& aText,
381 : : SvLBoxEntry* pParent,
382 : : sal_Bool bChildrenOnDemand, sal_uLong nPos,
383 : : void* pUser,
384 : : SvLBoxButtonKind eButtonKind
385 : : )
386 : : {
387 : : DBG_CHKTHIS(SvTreeListBox,0);
388 : 2392 : nTreeFlags |= TREEFLAG_MANINS;
389 : :
390 : 2392 : const Image& rDefExpBmp = pImp->GetDefaultEntryExpBmp( );
391 : 2392 : const Image& rDefColBmp = pImp->GetDefaultEntryColBmp( );
392 : :
393 : 2392 : aCurInsertedExpBmp = rDefExpBmp;
394 : 2392 : aCurInsertedColBmp = rDefColBmp;
395 : :
396 : 2392 : SvLBoxEntry* pEntry = CreateEntry();
397 : 2392 : pEntry->SetUserData( pUser );
398 : 2392 : InitEntry( pEntry, aText, rDefColBmp, rDefExpBmp, eButtonKind );
399 : 2392 : pEntry->EnableChildrenOnDemand( bChildrenOnDemand );
400 : :
401 [ + + ]: 2392 : if( !pParent )
402 : 2390 : SvLBox::Insert( pEntry, nPos );
403 : : else
404 : 2 : SvLBox::Insert( pEntry, pParent, nPos );
405 : :
406 : 2392 : aPrevInsertedExpBmp = rDefExpBmp;
407 : 2392 : aPrevInsertedColBmp = rDefColBmp;
408 : :
409 : 2392 : nTreeFlags &= (~TREEFLAG_MANINS);
410 : :
411 : 2392 : return pEntry;
412 : : }
413 : :
414 : 6 : SvLBoxEntry* SvTreeListBox::InsertEntry( const XubString& aText,
415 : : const Image& aExpEntryBmp, const Image& aCollEntryBmp,
416 : : SvLBoxEntry* pParent, sal_Bool bChildrenOnDemand, sal_uLong nPos, void* pUser,
417 : : SvLBoxButtonKind eButtonKind )
418 : : {
419 : : DBG_CHKTHIS(SvTreeListBox,0);
420 : 6 : nTreeFlags |= TREEFLAG_MANINS;
421 : :
422 : 6 : aCurInsertedExpBmp = aExpEntryBmp;
423 : 6 : aCurInsertedColBmp = aCollEntryBmp;
424 : :
425 : 6 : SvLBoxEntry* pEntry = CreateEntry();
426 : 6 : pEntry->SetUserData( pUser );
427 : 6 : InitEntry( pEntry, aText, aCollEntryBmp, aExpEntryBmp, eButtonKind );
428 : :
429 : 6 : pEntry->EnableChildrenOnDemand( bChildrenOnDemand );
430 : :
431 [ + + ]: 6 : if( !pParent )
432 : 2 : SvLBox::Insert( pEntry, nPos );
433 : : else
434 : 4 : SvLBox::Insert( pEntry, pParent, nPos );
435 : :
436 : 6 : aPrevInsertedExpBmp = aExpEntryBmp;
437 : 6 : aPrevInsertedColBmp = aCollEntryBmp;
438 : :
439 : 6 : nTreeFlags &= (~TREEFLAG_MANINS);
440 : :
441 : 6 : return pEntry;
442 : : }
443 : :
444 : 0 : void SvTreeListBox::SetEntryText( SvLBoxEntry* pEntry, const XubString& aStr)
445 : : {
446 : : DBG_CHKTHIS(SvTreeListBox,0);
447 : 0 : SvLBoxString* pItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
448 : : DBG_ASSERT(pItem,"SetText:Item not found");
449 : 0 : pItem->SetText( aStr );
450 : 0 : pItem->InitViewData( this, pEntry, 0 );
451 : 0 : GetModel()->InvalidateEntry( pEntry );
452 : 0 : }
453 : :
454 : 2 : void SvTreeListBox::SetExpandedEntryBmp( SvLBoxEntry* pEntry, const Image& aBmp )
455 : : {
456 : : DBG_CHKTHIS(SvTreeListBox,0);
457 [ + - ]: 2 : SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
458 : :
459 : : DBG_ASSERT(pItem,"SetExpBmp:Item not found");
460 [ + - ]: 2 : pItem->SetBitmap2( aBmp );
461 : :
462 [ + - ]: 2 : GetModel()->InvalidateEntry( pEntry );
463 [ + - ]: 2 : SetEntryHeight( pEntry );
464 [ + - ]: 2 : Size aSize = aBmp.GetSizePixel();
465 [ + - ]: 2 : short nWidth = pImp->UpdateContextBmpWidthVector( pEntry, (short)aSize.Width() );
466 [ - + ]: 2 : if( nWidth > nContextBmpWidthMax )
467 : : {
468 : 0 : nContextBmpWidthMax = nWidth;
469 [ # # ]: 0 : SetTabs();
470 : : }
471 : 2 : }
472 : :
473 : 2 : void SvTreeListBox::SetCollapsedEntryBmp(SvLBoxEntry* pEntry,const Image& aBmp )
474 : : {
475 : : DBG_CHKTHIS(SvTreeListBox,0);
476 [ + - ]: 2 : SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
477 : :
478 : : DBG_ASSERT(pItem,"SetExpBmp:Item not found");
479 [ + - ]: 2 : pItem->SetBitmap1( aBmp );
480 : :
481 [ + - ]: 2 : GetModel()->InvalidateEntry( pEntry );
482 [ + - ]: 2 : SetEntryHeight( pEntry );
483 [ + - ]: 2 : Size aSize = aBmp.GetSizePixel();
484 [ + - ]: 2 : short nWidth = pImp->UpdateContextBmpWidthVector( pEntry, (short)aSize.Width() );
485 [ - + ]: 2 : if( nWidth > nContextBmpWidthMax )
486 : : {
487 : 0 : nContextBmpWidthMax = nWidth;
488 [ # # ]: 0 : SetTabs();
489 : : }
490 : 2 : }
491 : :
492 : 2398 : void SvTreeListBox::ImpEntryInserted( SvLBoxEntry* pEntry )
493 : : {
494 : : DBG_CHKTHIS(SvTreeListBox,0);
495 : :
496 : 2398 : SvLBoxEntry* pParent = (SvLBoxEntry*)pModel->GetParent( pEntry );
497 [ + + ]: 2398 : if( pParent )
498 : : {
499 : 6 : sal_uInt16 nFlags = pParent->GetFlags();
500 : 6 : nFlags &= ~SV_ENTRYFLAG_NO_NODEBMP;
501 : 6 : pParent->SetFlags( nFlags );
502 : : }
503 : :
504 [ + + ]: 2398 : if(!((nTreeFlags & TREEFLAG_MANINS) &&
505 : 2398 : (aPrevInsertedExpBmp == aCurInsertedExpBmp) &&
506 [ + - + + ]: 4796 : (aPrevInsertedColBmp == aCurInsertedColBmp) ))
[ - + ]
507 : : {
508 [ + - ][ + - ]: 8 : Size aSize = GetCollapsedEntryBmp( pEntry ).GetSizePixel();
509 [ + + ]: 8 : if( aSize.Width() > nContextBmpWidthMax )
510 : : {
511 : 2 : nContextBmpWidthMax = (short)aSize.Width();
512 : 2 : nTreeFlags |= TREEFLAG_RECALCTABS;
513 : : }
514 [ + - ][ + - ]: 8 : aSize = GetExpandedEntryBmp( pEntry ).GetSizePixel();
515 [ - + ]: 8 : if( aSize.Width() > nContextBmpWidthMax )
516 : : {
517 : 0 : nContextBmpWidthMax = (short)aSize.Width();
518 : 8 : nTreeFlags |= TREEFLAG_RECALCTABS;
519 : : }
520 : : }
521 : 2398 : SetEntryHeight( (SvLBoxEntry*)pEntry );
522 : :
523 [ - + ]: 2398 : if( nTreeFlags & TREEFLAG_CHKBTN )
524 : : {
525 : 0 : SvLBoxButton* pItem = (SvLBoxButton*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXBUTTON));
526 [ # # ]: 0 : if( pItem )
527 : : {
528 : 0 : long nWidth = pItem->GetSize(this, pEntry).Width();
529 [ # # ]: 0 : if( mnCheckboxItemWidth < nWidth )
530 : : {
531 : 0 : mnCheckboxItemWidth = nWidth;
532 : 0 : nTreeFlags |= TREEFLAG_RECALCTABS;
533 : : }
534 : : }
535 : : }
536 : 2398 : }
537 : :
538 : :
539 : :
540 : 0 : void SvTreeListBox::SetCheckButtonState( SvLBoxEntry* pEntry, SvButtonState eState)
541 : : {
542 : : DBG_CHKTHIS(SvTreeListBox,0);
543 [ # # ]: 0 : if( nTreeFlags & TREEFLAG_CHKBTN )
544 : : {
545 : 0 : SvLBoxButton* pItem = (SvLBoxButton*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXBUTTON));
546 [ # # ][ # # ]: 0 : if(!(pItem && pItem->CheckModification()))
[ # # ]
547 : 0 : return ;
548 [ # # # # ]: 0 : switch( eState )
549 : : {
550 : : case SV_BUTTON_CHECKED:
551 : 0 : pItem->SetStateChecked();
552 : 0 : break;
553 : :
554 : : case SV_BUTTON_UNCHECKED:
555 : 0 : pItem->SetStateUnchecked();
556 : 0 : break;
557 : :
558 : : case SV_BUTTON_TRISTATE:
559 : 0 : pItem->SetStateTristate();
560 : 0 : break;
561 : : }
562 : 0 : InvalidateEntry( pEntry );
563 : : }
564 : : }
565 : :
566 : 120 : SvButtonState SvTreeListBox::GetCheckButtonState( SvLBoxEntry* pEntry ) const
567 : : {
568 : : DBG_CHKTHIS(SvTreeListBox,0);
569 : 120 : SvButtonState eState = SV_BUTTON_UNCHECKED;
570 [ - + ]: 120 : if( nTreeFlags & TREEFLAG_CHKBTN )
571 : : {
572 : 0 : SvLBoxButton* pItem = (SvLBoxButton*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXBUTTON));
573 [ # # ]: 0 : if(!pItem)
574 : 0 : return SV_BUTTON_TRISTATE;
575 : 0 : sal_uInt16 nButtonFlags = pItem->GetButtonFlags();
576 : 0 : eState = pCheckButtonData->ConvertToButtonState( nButtonFlags );
577 : : }
578 : 120 : return eState;
579 : : }
580 : :
581 : 0 : void SvTreeListBox::CheckButtonHdl()
582 : : {
583 : : DBG_CHKTHIS(SvTreeListBox,0);
584 : 0 : aCheckButtonHdl.Call( this );
585 [ # # ]: 0 : if ( pCheckButtonData )
586 : 0 : pImp->CallEventListeners( VCLEVENT_CHECKBOX_TOGGLE, (void*)pCheckButtonData->GetActEntry() );
587 : 0 : }
588 : :
589 : : //
590 : : // TODO: Currently all data is cloned so that they conform to the default tree
591 : : // view format. Actually, the model should be used as a reference here. This
592 : : // leads to us _not_ calling SvLBoxEntry::Clone, but only its base class
593 : : // SvListEntry.
594 : : //
595 : :
596 : 0 : SvLBoxEntry* SvTreeListBox::CloneEntry( SvLBoxEntry* pSource )
597 : : {
598 : : DBG_CHKTHIS(SvTreeListBox,0);
599 [ # # ]: 0 : XubString aStr;
600 [ # # ]: 0 : Image aCollEntryBmp;
601 [ # # ]: 0 : Image aExpEntryBmp;
602 : 0 : SvLBoxButtonKind eButtonKind = SvLBoxButtonKind_enabledCheckbox;
603 : :
604 [ # # ]: 0 : SvLBoxString* pStringItem = (SvLBoxString*)(pSource->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
605 [ # # ]: 0 : if( pStringItem )
606 [ # # ]: 0 : aStr = pStringItem->GetText();
607 [ # # ]: 0 : SvLBoxContextBmp* pBmpItem = (SvLBoxContextBmp*)(pSource->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
608 [ # # ]: 0 : if( pBmpItem )
609 : : {
610 [ # # ][ # # ]: 0 : aCollEntryBmp = pBmpItem->GetBitmap1( );
611 [ # # ][ # # ]: 0 : aExpEntryBmp = pBmpItem->GetBitmap2( );
612 : : }
613 [ # # ]: 0 : SvLBoxButton* pButtonItem = (SvLBoxButton*)(pSource->GetFirstItem(SV_ITEM_ID_LBOXBUTTON));
614 [ # # ]: 0 : if( pButtonItem )
615 : 0 : eButtonKind = pButtonItem->GetKind();
616 [ # # ]: 0 : SvLBoxEntry* pClone = CreateEntry();
617 [ # # ]: 0 : InitEntry( pClone, aStr, aCollEntryBmp, aExpEntryBmp, eButtonKind );
618 [ # # ]: 0 : pClone->SvListEntry::Clone( pSource );
619 [ # # ]: 0 : pClone->EnableChildrenOnDemand( pSource->HasChildrenOnDemand() );
620 : 0 : pClone->SetUserData( pSource->GetUserData() );
621 : :
622 [ # # ][ # # ]: 0 : return pClone;
[ # # ]
623 : : }
624 : :
625 : 0 : void SvTreeListBox::SetIndent( short nNewIndent )
626 : : {
627 : : DBG_CHKTHIS(SvTreeListBox,0);
628 : 0 : nIndent = nNewIndent;
629 : 0 : SetTabs();
630 [ # # ]: 0 : if( IsUpdateMode() )
631 : 0 : Invalidate();
632 : 0 : }
633 : :
634 : 248 : const Image& SvTreeListBox::GetDefaultExpandedEntryBmp( ) const
635 : : {
636 : 248 : return pImp->GetDefaultEntryExpBmp( );
637 : : }
638 : :
639 : 248 : const Image& SvTreeListBox::GetDefaultCollapsedEntryBmp( ) const
640 : : {
641 : 248 : return pImp->GetDefaultEntryColBmp( );
642 : : }
643 : :
644 : 124 : void SvTreeListBox::SetDefaultExpandedEntryBmp( const Image& aBmp )
645 : : {
646 : : DBG_CHKTHIS(SvTreeListBox,0);
647 [ + - ]: 124 : Size aSize = aBmp.GetSizePixel();
648 [ - + ]: 124 : if( aSize.Width() > nContextBmpWidthMax )
649 : 0 : nContextBmpWidthMax = (short)aSize.Width();
650 [ + - ]: 124 : SetTabs();
651 : :
652 [ + - ]: 124 : pImp->SetDefaultEntryExpBmp( aBmp );
653 : 124 : }
654 : :
655 : 124 : void SvTreeListBox::SetDefaultCollapsedEntryBmp( const Image& aBmp )
656 : : {
657 : : DBG_CHKTHIS(SvTreeListBox,0);
658 [ + - ]: 124 : Size aSize = aBmp.GetSizePixel();
659 [ - + ]: 124 : if( aSize.Width() > nContextBmpWidthMax )
660 : 0 : nContextBmpWidthMax = (short)aSize.Width();
661 [ + - ]: 124 : SetTabs();
662 : :
663 [ + - ]: 124 : pImp->SetDefaultEntryColBmp( aBmp );
664 : 124 : }
665 : :
666 : 2 : void SvTreeListBox::EnableCheckButton( SvLBoxButtonData* pData )
667 : : {
668 : : DBG_CHKTHIS(SvTreeListBox,0);
669 : : DBG_ASSERT(!GetEntryCount(),"EnableCheckButton: Entry count != 0");
670 [ + - ]: 2 : if( !pData )
671 : 2 : nTreeFlags &= (~TREEFLAG_CHKBTN);
672 : : else
673 : : {
674 : 0 : SetCheckButtonData( pData );
675 : 0 : nTreeFlags |= TREEFLAG_CHKBTN;
676 : 0 : pData->SetLink( LINK(this, SvTreeListBox, CheckButtonClick));
677 : : }
678 : :
679 : 2 : SetTabs();
680 [ + - ]: 2 : if( IsUpdateMode() )
681 : 2 : Invalidate();
682 : 2 : }
683 : :
684 : 0 : void SvTreeListBox::SetCheckButtonData( SvLBoxButtonData* pData )
685 : : {
686 : : DBG_CHKTHIS(SvTreeListBox,0);
687 [ # # ]: 0 : if ( pData )
688 : 0 : pCheckButtonData = pData;
689 : 0 : }
690 : :
691 : 2 : const Image& SvTreeListBox::GetDefaultExpandedNodeImage( )
692 : : {
693 : 2 : return SvImpLBox::GetDefaultExpandedNodeImage( );
694 : : }
695 : :
696 : 2 : const Image& SvTreeListBox::GetDefaultCollapsedNodeImage( )
697 : : {
698 : 2 : return SvImpLBox::GetDefaultCollapsedNodeImage( );
699 : : }
700 : :
701 : 2 : void SvTreeListBox::SetNodeBitmaps( const Image& rCollapsedNodeBmp, const Image& rExpandedNodeBmp )
702 : : {
703 : : DBG_CHKTHIS(SvTreeListBox,0);
704 : 2 : SetExpandedNodeBmp( rExpandedNodeBmp );
705 : 2 : SetCollapsedNodeBmp( rCollapsedNodeBmp );
706 : 2 : SetTabs();
707 : 2 : }
708 : :
709 : 0 : sal_Bool SvTreeListBox::EditingEntry( SvLBoxEntry*, Selection& )
710 : : {
711 : : DBG_CHKTHIS(SvTreeListBox,0);
712 : 0 : return sal_True;
713 : : }
714 : :
715 : 0 : sal_Bool SvTreeListBox::EditedEntry( SvLBoxEntry* /*pEntry*/,const rtl::OUString& /*rNewText*/)
716 : : {
717 : : DBG_CHKTHIS(SvTreeListBox,0);
718 : 0 : return sal_True;
719 : : }
720 : :
721 : 2 : void SvTreeListBox::EnableInplaceEditing( sal_Bool bOn )
722 : : {
723 : : DBG_CHKTHIS(SvTreeListBox,0);
724 : 2 : SvLBox::EnableInplaceEditing( bOn );
725 : 2 : }
726 : :
727 : 0 : void SvTreeListBox::KeyInput( const KeyEvent& rKEvt )
728 : : {
729 : : DBG_CHKTHIS(SvTreeListBox,0);
730 : : // under OS/2, we get key up/down even while editing
731 [ # # ]: 0 : if( IsEditingActive() )
732 : 0 : return;
733 : :
734 : 0 : nImpFlags |= SVLBOX_IS_TRAVELSELECT;
735 : :
736 : : #ifdef OVDEBUG
737 : : sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
738 : : switch ( nCode )
739 : : {
740 : : case KEY_F1:
741 : : {
742 : : SvLBoxEntry* pEntry = First();
743 : : pEntry = NextVisible( pEntry );
744 : : SetEntryText( pEntry, "SetEntryText" );
745 : : }
746 : : break;
747 : : }
748 : : #endif
749 : :
750 [ # # ]: 0 : if( !pImp->KeyInput( rKEvt ) )
751 : 0 : SvLBox::KeyInput( rKEvt );
752 : :
753 : 0 : nImpFlags &= ~SVLBOX_IS_TRAVELSELECT;
754 : : }
755 : :
756 : 0 : void SvTreeListBox::RequestingChildren( SvLBoxEntry* pParent )
757 : : {
758 : : DBG_CHKTHIS(SvTreeListBox,0);
759 [ # # ]: 0 : if( !pParent->HasChildren() )
760 [ # # ][ # # ]: 0 : InsertEntry( rtl::OUString("<dummy>"), pParent, sal_False, LIST_APPEND );
[ # # ]
761 : 0 : }
762 : :
763 : 2 : void SvTreeListBox::GetFocus()
764 : : {
765 : : DBG_CHKTHIS(SvTreeListBox,0);
766 : 2 : pImp->GetFocus();
767 : 2 : SvLBox::GetFocus();
768 : :
769 : 2 : SvLBoxEntry* pEntry = FirstSelected();
770 [ + - ]: 2 : if ( pEntry )
771 : 2 : pImp->CallEventListeners( VCLEVENT_LISTBOX_SELECT, pEntry );
772 : :
773 : 2 : }
774 : :
775 : 0 : void SvTreeListBox::LoseFocus()
776 : : {
777 : : DBG_CHKTHIS(SvTreeListBox,0);
778 : 0 : pImp->LoseFocus();
779 : 0 : SvLBox::LoseFocus();
780 : 0 : }
781 : :
782 : 124 : void SvTreeListBox::ModelHasCleared()
783 : : {
784 : : DBG_CHKTHIS(SvTreeListBox,0);
785 : 124 : pImp->pCursor = 0; // else we crash in GetFocus when editing in-place
786 [ - + ]: 124 : delete pEdCtrl;
787 : 124 : pEdCtrl = NULL;
788 : 124 : pImp->Clear();
789 : 124 : nFocusWidth = -1;
790 : :
791 : 124 : nContextBmpWidthMax = 0;
792 : 124 : SetDefaultExpandedEntryBmp( GetDefaultExpandedEntryBmp() );
793 : 124 : SetDefaultCollapsedEntryBmp( GetDefaultCollapsedEntryBmp() );
794 : :
795 [ + - ]: 124 : if( !(nTreeFlags & TREEFLAG_FIXEDHEIGHT ))
796 : 124 : nEntryHeight = 0;
797 : 124 : AdjustEntryHeight( GetFont() );
798 : 124 : AdjustEntryHeight( GetDefaultExpandedEntryBmp() );
799 : 124 : AdjustEntryHeight( GetDefaultCollapsedEntryBmp() );
800 : :
801 : 124 : SvLBox::ModelHasCleared();
802 : 124 : }
803 : :
804 : 0 : void SvTreeListBox::ShowTargetEmphasis( SvLBoxEntry* pEntry, sal_Bool /* bShow */ )
805 : : {
806 : : DBG_CHKTHIS(SvTreeListBox,0);
807 : 0 : pImp->PaintDDCursor( pEntry );
808 : 0 : }
809 : :
810 : 0 : void SvTreeListBox::ScrollOutputArea( short nDeltaEntries )
811 : : {
812 : : DBG_CHKTHIS(SvTreeListBox,0);
813 [ # # ][ # # ]: 0 : if( !nDeltaEntries || !pImp->aVerSBar.IsVisible() )
[ # # ]
814 : 0 : return;
815 : :
816 : 0 : long nThumb = pImp->aVerSBar.GetThumbPos();
817 : 0 : long nMax = pImp->aVerSBar.GetRange().Max();
818 : :
819 : 0 : NotifyBeginScroll();
820 [ # # ]: 0 : if( nDeltaEntries < 0 )
821 : : {
822 : : // move window up
823 : 0 : nDeltaEntries *= -1;
824 : 0 : long nVis = pImp->aVerSBar.GetVisibleSize();
825 : 0 : long nTemp = nThumb + nVis;
826 [ # # ]: 0 : if( nDeltaEntries > (nMax - nTemp) )
827 : 0 : nDeltaEntries = (short)(nMax - nTemp);
828 : 0 : pImp->PageDown( (sal_uInt16)nDeltaEntries );
829 : : }
830 : : else
831 : : {
832 [ # # ]: 0 : if( nDeltaEntries > nThumb )
833 : 0 : nDeltaEntries = (short)nThumb;
834 : 0 : pImp->PageUp( (sal_uInt16)nDeltaEntries );
835 : : }
836 : 0 : pImp->SyncVerThumb();
837 : 0 : NotifyEndScroll();
838 : : }
839 : :
840 : 0 : void SvTreeListBox::ScrollToAbsPos( long nPos )
841 : : {
842 : 0 : pImp->ScrollToAbsPos( nPos );
843 : 0 : }
844 : :
845 : 0 : void SvTreeListBox::SetSelectionMode( SelectionMode eSelectMode )
846 : : {
847 : : DBG_CHKTHIS(SvTreeListBox,0);
848 : 0 : SvLBox::SetSelectionMode( eSelectMode );
849 : 0 : pImp->SetSelectionMode( eSelectMode );
850 : 0 : }
851 : :
852 : 2 : void SvTreeListBox::SetDragDropMode( DragDropMode nDDMode )
853 : : {
854 : : DBG_CHKTHIS(SvTreeListBox,0);
855 : 2 : SvLBox::SetDragDropMode( nDDMode );
856 : 2 : pImp->SetDragDropMode( nDDMode );
857 : 2 : }
858 : :
859 : 996 : short SvTreeListBox::GetHeightOffset(const Image& rBmp, Size& aSizeLogic )
860 : : {
861 : : DBG_CHKTHIS(SvTreeListBox,0);
862 : 996 : short nOffset = 0;
863 : 996 : aSizeLogic = rBmp.GetSizePixel();
864 [ + - ]: 996 : if( GetEntryHeight() > aSizeLogic.Height() )
865 : 996 : nOffset = ( GetEntryHeight() - (short)aSizeLogic.Height()) / 2;
866 : 996 : return nOffset;
867 : : }
868 : :
869 : 1190 : short SvTreeListBox::GetHeightOffset(const Font& /* rFont */, Size& aSizeLogic )
870 : : {
871 : : DBG_CHKTHIS(SvTreeListBox,0);
872 : 1190 : short nOffset = 0;
873 [ + - ][ + - ]: 1190 : aSizeLogic = Size(GetTextWidth(rtl::OUString('X')), GetTextHeight());
[ + - ]
874 [ + + ]: 1190 : if( GetEntryHeight() > aSizeLogic.Height() )
875 : 30 : nOffset = ( GetEntryHeight() - (short)aSizeLogic.Height()) / 2;
876 : 1190 : return nOffset;
877 : : }
878 : :
879 : 2402 : void SvTreeListBox::SetEntryHeight( SvLBoxEntry* pEntry )
880 : : {
881 : : DBG_CHKTHIS(SvTreeListBox,0);
882 : 2402 : short nHeight, nHeightMax=0;
883 : 2402 : sal_uInt16 nCount = pEntry->ItemCount();
884 : 2402 : sal_uInt16 nCur = 0;
885 : 2402 : SvViewDataEntry* pViewData = GetViewDataEntry( pEntry );
886 [ + + ]: 7206 : while( nCur < nCount )
887 : : {
888 : 4804 : SvLBoxItem* pItem = pEntry->GetItem( nCur );
889 : 4804 : nHeight = (short)(pItem->GetSize( pViewData, nCur ).Height());
890 [ + + ]: 4804 : if( nHeight > nHeightMax )
891 : 2402 : nHeightMax = nHeight;
892 : 4804 : nCur++;
893 : : }
894 : :
895 [ - + ]: 2402 : if( nHeightMax > nEntryHeight )
896 : : {
897 : 0 : nEntryHeight = nHeightMax;
898 : 0 : SvLBox::SetFont( GetFont() );
899 : 0 : pImp->SetEntryHeight( nHeightMax );
900 : : }
901 : 2402 : }
902 : :
903 : 0 : void SvTreeListBox::SetEntryHeight( short nHeight, sal_Bool bAlways )
904 : : {
905 : : DBG_CHKTHIS(SvTreeListBox,0);
906 : :
907 [ # # ][ # # ]: 0 : if( bAlways || nHeight > nEntryHeight )
908 : : {
909 : 0 : nEntryHeight = nHeight;
910 [ # # ]: 0 : if( nEntryHeight )
911 : 0 : nTreeFlags |= TREEFLAG_FIXEDHEIGHT;
912 : : else
913 : 0 : nTreeFlags &= ~TREEFLAG_FIXEDHEIGHT;
914 : 0 : SvLBox::SetFont( GetFont() );
915 : 0 : pImp->SetEntryHeight( nHeight );
916 : : }
917 : 0 : }
918 : :
919 : :
920 : 252 : void SvTreeListBox::AdjustEntryHeight( const Image& rBmp )
921 : : {
922 : : DBG_CHKTHIS(SvTreeListBox,0);
923 : 252 : Size aSize;
924 [ + - ]: 252 : GetHeightOffset( rBmp, aSize );
925 [ - + ]: 252 : if( aSize.Height() > nEntryHeight )
926 : : {
927 : 0 : nEntryHeight = (short)aSize.Height() + nEntryHeightOffs;
928 [ # # ]: 0 : pImp->SetEntryHeight( nEntryHeight );
929 : : }
930 : 252 : }
931 : :
932 : 1190 : void SvTreeListBox::AdjustEntryHeight( const Font& rFont )
933 : : {
934 : : DBG_CHKTHIS(SvTreeListBox,0);
935 : 1190 : Size aSize;
936 [ + - ]: 1190 : GetHeightOffset( rFont, aSize );
937 [ + + ]: 1190 : if( aSize.Height() > nEntryHeight )
938 : : {
939 : 246 : nEntryHeight = (short)aSize.Height() + nEntryHeightOffs;
940 [ + - ]: 246 : pImp->SetEntryHeight( nEntryHeight );
941 : : }
942 : 1190 : }
943 : :
944 : 4 : sal_Bool SvTreeListBox::Expand( SvLBoxEntry* pParent )
945 : : {
946 : : DBG_CHKTHIS(SvTreeListBox,0);
947 : 4 : pHdlEntry = pParent;
948 : 4 : sal_Bool bExpanded = sal_False;
949 : : sal_uInt16 nFlags;
950 : :
951 [ + + ]: 4 : if( pParent->HasChildrenOnDemand() )
952 : 2 : RequestingChildren( pParent );
953 [ + - ]: 4 : if( pParent->HasChildren() )
954 : : {
955 : 4 : nImpFlags |= SVLBOX_IS_EXPANDING;
956 [ + - ]: 4 : if( ExpandingHdl() )
957 : : {
958 : 4 : bExpanded = sal_True;
959 : 4 : SvListView::Expand( pParent );
960 : 4 : pImp->EntryExpanded( pParent );
961 : 4 : pHdlEntry = pParent;
962 : 4 : ExpandedHdl();
963 : : }
964 : 4 : nFlags = pParent->GetFlags();
965 : 4 : nFlags &= ~SV_ENTRYFLAG_NO_NODEBMP;
966 : 4 : nFlags |= SV_ENTRYFLAG_HAD_CHILDREN;
967 : 4 : pParent->SetFlags( nFlags );
968 : : }
969 : : else
970 : : {
971 : 0 : nFlags = pParent->GetFlags();
972 : 0 : nFlags |= SV_ENTRYFLAG_NO_NODEBMP;
973 : 0 : pParent->SetFlags( nFlags );
974 : 0 : GetModel()->InvalidateEntry( pParent ); // repaint
975 : : }
976 : :
977 : : // #i92103#
978 [ + - ]: 4 : if ( bExpanded )
979 : : {
980 : 4 : pImp->CallEventListeners( VCLEVENT_ITEM_EXPANDED, pParent );
981 : : }
982 : :
983 : 4 : return bExpanded;
984 : : }
985 : :
986 : 0 : sal_Bool SvTreeListBox::Collapse( SvLBoxEntry* pParent )
987 : : {
988 : : DBG_CHKTHIS(SvTreeListBox,0);
989 : 0 : nImpFlags &= ~SVLBOX_IS_EXPANDING;
990 : 0 : pHdlEntry = pParent;
991 : 0 : sal_Bool bCollapsed = sal_False;
992 : :
993 [ # # ]: 0 : if( ExpandingHdl() )
994 : : {
995 : 0 : bCollapsed = sal_True;
996 : 0 : pImp->CollapsingEntry( pParent );
997 : 0 : SvListView::Collapse( pParent );
998 : 0 : pImp->EntryCollapsed( pParent );
999 : 0 : pHdlEntry = pParent;
1000 : 0 : ExpandedHdl();
1001 : : }
1002 : :
1003 : : // #i92103#
1004 [ # # ]: 0 : if ( bCollapsed )
1005 : : {
1006 : 0 : pImp->CallEventListeners( VCLEVENT_ITEM_COLLAPSED, pParent );
1007 : : }
1008 : :
1009 : 0 : return bCollapsed;
1010 : : }
1011 : :
1012 : 673 : sal_Bool SvTreeListBox::Select( SvLBoxEntry* pEntry, sal_Bool bSelect )
1013 : : {
1014 : : DBG_CHKTHIS(SvTreeListBox,0);
1015 : : DBG_ASSERT(pEntry,"Select: Null-Ptr");
1016 : 673 : sal_Bool bRetVal = SvListView::Select( pEntry, bSelect );
1017 : : DBG_ASSERT(IsSelected(pEntry)==bSelect,"Select failed");
1018 [ + + ]: 673 : if( bRetVal )
1019 : : {
1020 : 124 : pImp->EntrySelected( pEntry, bSelect );
1021 : 124 : pHdlEntry = pEntry;
1022 [ + + ]: 124 : if( bSelect )
1023 : : {
1024 : 122 : SelectHdl();
1025 : 122 : pImp->CallEventListeners( VCLEVENT_LISTBOX_SELECT, pEntry );
1026 : : }
1027 : : else
1028 : 2 : DeselectHdl();
1029 : : }
1030 : 673 : return bRetVal;
1031 : : }
1032 : :
1033 : 0 : sal_uLong SvTreeListBox::SelectChildren( SvLBoxEntry* pParent, sal_Bool bSelect )
1034 : : {
1035 : : DBG_CHKTHIS(SvTreeListBox,0);
1036 : 0 : pImp->DestroyAnchor();
1037 : 0 : sal_uLong nRet = 0;
1038 [ # # ]: 0 : if( !pParent->HasChildren() )
1039 : 0 : return 0;
1040 : 0 : sal_uInt16 nRefDepth = pModel->GetDepth( pParent );
1041 : 0 : SvLBoxEntry* pChild = FirstChild( pParent );
1042 [ # # ]: 0 : do {
[ # # # # ]
1043 : 0 : nRet++;
1044 : 0 : Select( pChild, bSelect );
1045 : 0 : pChild = Next( pChild );
1046 : 0 : } while( pChild && pModel->GetDepth( pChild ) > nRefDepth );
1047 : 0 : return nRet;
1048 : : }
1049 : :
1050 : 15 : void SvTreeListBox::SelectAll( sal_Bool bSelect, sal_Bool )
1051 : : {
1052 : : DBG_CHKTHIS(SvTreeListBox,0);
1053 : : pImp->SelAllDestrAnch(
1054 : : bSelect,
1055 : : sal_True, // delete anchor,
1056 : 15 : sal_True ); // even when using SINGLE_SELECTION, deselect the cursor
1057 : 15 : }
1058 : :
1059 : 0 : void SvTreeListBox::ModelHasInsertedTree( SvListEntry* pEntry )
1060 : : {
1061 : : DBG_CHKTHIS(SvTreeListBox,0);
1062 : 0 : sal_uInt16 nRefDepth = pModel->GetDepth( (SvLBoxEntry*)pEntry );
1063 : 0 : SvLBoxEntry* pTmp = (SvLBoxEntry*)pEntry;
1064 [ # # ]: 0 : do
[ # # # # ]
1065 : : {
1066 : 0 : ImpEntryInserted( pTmp );
1067 : 0 : pTmp = Next( pTmp );
1068 : 0 : } while( pTmp && nRefDepth < pModel->GetDepth( pTmp ) );
1069 : 0 : pImp->TreeInserted( (SvLBoxEntry*)pEntry );
1070 : 0 : }
1071 : :
1072 : 2398 : void SvTreeListBox::ModelHasInserted( SvListEntry* pEntry )
1073 : : {
1074 : : DBG_CHKTHIS(SvTreeListBox,0);
1075 : 2398 : ImpEntryInserted( (SvLBoxEntry*)pEntry );
1076 : 2398 : pImp->EntryInserted( (SvLBoxEntry*)pEntry );
1077 : 2398 : }
1078 : :
1079 : 0 : void SvTreeListBox::ModelIsMoving(SvListEntry* pSource,
1080 : : SvListEntry* /* pTargetParent */,
1081 : : sal_uLong /* nChildPos */ )
1082 : : {
1083 : : DBG_CHKTHIS(SvTreeListBox,0);
1084 : 0 : pImp->MovingEntry( (SvLBoxEntry*)pSource );
1085 : 0 : }
1086 : :
1087 : 0 : void SvTreeListBox::ModelHasMoved( SvListEntry* pSource )
1088 : : {
1089 : : DBG_CHKTHIS(SvTreeListBox,0);
1090 : 0 : pImp->EntryMoved( (SvLBoxEntry*)pSource );
1091 : 0 : }
1092 : :
1093 : 0 : void SvTreeListBox::ModelIsRemoving( SvListEntry* pEntry )
1094 : : {
1095 : : DBG_CHKTHIS(SvTreeListBox,0);
1096 [ # # ]: 0 : if(pEdEntry == pEntry)
1097 : 0 : pEdEntry = NULL;
1098 : :
1099 : 0 : pImp->RemovingEntry( (SvLBoxEntry*)pEntry );
1100 : 0 : NotifyRemoving( (SvLBoxEntry*)pEntry );
1101 : 0 : }
1102 : :
1103 : 0 : void SvTreeListBox::ModelHasRemoved( SvListEntry* pEntry )
1104 : : {
1105 : : DBG_CHKTHIS(SvTreeListBox,0);
1106 [ # # ]: 0 : if ( pEntry == pHdlEntry)
1107 : 0 : pHdlEntry = NULL;
1108 : 0 : pImp->EntryRemoved();
1109 : 0 : }
1110 : :
1111 : 2 : void SvTreeListBox::SetCollapsedNodeBmp( const Image& rBmp)
1112 : : {
1113 : : DBG_CHKTHIS(SvTreeListBox,0);
1114 : 2 : AdjustEntryHeight( rBmp );
1115 : 2 : pImp->SetCollapsedNodeBmp( rBmp );
1116 : 2 : }
1117 : :
1118 : 2 : void SvTreeListBox::SetExpandedNodeBmp( const Image& rBmp )
1119 : : {
1120 : : DBG_CHKTHIS(SvTreeListBox,0);
1121 : 2 : AdjustEntryHeight( rBmp );
1122 : 2 : pImp->SetExpandedNodeBmp( rBmp );
1123 : 2 : }
1124 : :
1125 : :
1126 : 820 : void SvTreeListBox::SetFont( const Font& rFont )
1127 : : {
1128 : : DBG_CHKTHIS(SvTreeListBox,0);
1129 [ + - ]: 820 : Font aTempFont( rFont );
1130 [ + - ]: 820 : aTempFont.SetTransparent( sal_True );
1131 [ + - ]: 820 : Control::SetFont( aTempFont );
1132 [ + - ]: 820 : AdjustEntryHeight( aTempFont );
1133 : : // always invalidate, else things go wrong in SetEntryHeight
1134 [ + - ][ + - ]: 820 : RecalcViewData();
1135 : 820 : }
1136 : :
1137 : :
1138 : 173 : void SvTreeListBox::Paint( const Rectangle& rRect )
1139 : : {
1140 : : DBG_CHKTHIS(SvTreeListBox,0);
1141 : 173 : SvLBox::Paint( rRect );
1142 [ - + ]: 173 : if( nTreeFlags & TREEFLAG_RECALCTABS )
1143 : 0 : SetTabs();
1144 : 173 : pImp->Paint( rRect );
1145 : 173 : }
1146 : :
1147 : 0 : void SvTreeListBox::MouseButtonDown( const MouseEvent& rMEvt )
1148 : : {
1149 : : DBG_CHKTHIS(SvTreeListBox,0);
1150 : 0 : pImp->MouseButtonDown( rMEvt );
1151 : 0 : }
1152 : :
1153 : 0 : void SvTreeListBox::MouseButtonUp( const MouseEvent& rMEvt )
1154 : : {
1155 : : DBG_CHKTHIS(SvTreeListBox,0);
1156 : 0 : pImp->MouseButtonUp( rMEvt );
1157 : 0 : }
1158 : :
1159 : 0 : void SvTreeListBox::MouseMove( const MouseEvent& rMEvt )
1160 : : {
1161 : : DBG_CHKTHIS(SvTreeListBox,0);
1162 : 0 : pImp->MouseMove( rMEvt );
1163 : 0 : }
1164 : :
1165 : :
1166 : 240 : void SvTreeListBox::SetUpdateMode( sal_Bool bUpdate )
1167 : : {
1168 : : DBG_CHKTHIS(SvTreeListBox,0);
1169 : 240 : pImp->SetUpdateMode( bUpdate );
1170 : 240 : }
1171 : :
1172 : 124 : void SvTreeListBox::SetSpaceBetweenEntries( short nOffsLogic )
1173 : : {
1174 : : DBG_CHKTHIS(SvTreeListBox,0);
1175 [ + - ]: 124 : if( nOffsLogic != nEntryHeightOffs )
1176 : : {
1177 : 124 : nEntryHeight = nEntryHeight - nEntryHeightOffs;
1178 : 124 : nEntryHeightOffs = (short)nOffsLogic;
1179 : 124 : nEntryHeight = nEntryHeight + nOffsLogic;
1180 : 124 : AdjustEntryHeight( GetFont() );
1181 : 124 : RecalcViewData();
1182 : 124 : pImp->SetEntryHeight( nEntryHeight );
1183 : : }
1184 : 124 : }
1185 : :
1186 : 2 : void SvTreeListBox::SetCursor( SvLBoxEntry* pEntry, sal_Bool bForceNoSelect )
1187 : : {
1188 : : DBG_CHKTHIS(SvTreeListBox,0);
1189 : 2 : pImp->SetCursor(pEntry, bForceNoSelect);
1190 : 2 : }
1191 : :
1192 : 0 : void SvTreeListBox::SetCurEntry( SvLBoxEntry* pEntry )
1193 : : {
1194 : : DBG_CHKTHIS(SvTreeListBox,0);
1195 : 0 : pImp->SetCurEntry( pEntry );
1196 : 0 : }
1197 : :
1198 : 376 : Image SvTreeListBox::GetExpandedNodeBmp( ) const
1199 : : {
1200 : 376 : return pImp->GetExpandedNodeBmp( );
1201 : : }
1202 : :
1203 : 120 : Point SvTreeListBox::GetEntryPosition( SvLBoxEntry* pEntry ) const
1204 : : {
1205 : 120 : return pImp->GetEntryPosition( pEntry );
1206 : : }
1207 : :
1208 : 0 : void SvTreeListBox::ShowEntry( SvLBoxEntry* pEntry )
1209 : : {
1210 : 0 : MakeVisible( pEntry );
1211 : 0 : }
1212 : :
1213 : 551 : void SvTreeListBox::MakeVisible( SvLBoxEntry* pEntry )
1214 : : {
1215 : 551 : pImp->MakeVisible(pEntry);
1216 : 551 : }
1217 : :
1218 : 0 : void SvTreeListBox::MakeVisible( SvLBoxEntry* pEntry, sal_Bool bMoveToTop )
1219 : : {
1220 : 0 : pImp->MakeVisible( pEntry, bMoveToTop );
1221 : 0 : }
1222 : :
1223 : 14 : void SvTreeListBox::ModelHasEntryInvalidated( SvListEntry* pEntry )
1224 : : {
1225 : : DBG_CHKTHIS(SvTreeListBox,0);
1226 : : // reinitialize the separate items of the entries
1227 : 14 : SvLBox::ModelHasEntryInvalidated( pEntry );
1228 : : // repaint
1229 : 14 : pImp->InvalidateEntry( (SvLBoxEntry*)pEntry );
1230 : 14 : }
1231 : :
1232 : 0 : void SvTreeListBox::EditItemText( SvLBoxEntry* pEntry, SvLBoxString* pItem,
1233 : : const Selection& rSelection )
1234 : : {
1235 : : DBG_CHKTHIS(SvTreeListBox,0);
1236 : : DBG_ASSERT(pEntry&&pItem,"EditItemText: Bad params");
1237 [ # # ][ # # ]: 0 : if( IsSelected( pEntry ))
1238 : : {
1239 [ # # ]: 0 : pImp->ShowCursor( sal_False );
1240 [ # # ]: 0 : SvListView::Select( pEntry, sal_False );
1241 [ # # ]: 0 : PaintEntry( pEntry );
1242 [ # # ]: 0 : SvListView::Select( pEntry, sal_True );
1243 [ # # ]: 0 : pImp->ShowCursor( sal_True );
1244 : : }
1245 : 0 : pEdEntry = pEntry;
1246 : 0 : pEdItem = pItem;
1247 [ # # ]: 0 : SvLBoxTab* pTab = GetTab( pEntry, pItem );
1248 : : DBG_ASSERT(pTab,"EditItemText:Tab not found");
1249 : :
1250 [ # # ]: 0 : Size aItemSize( pItem->GetSize(this, pEntry) );
1251 [ # # ]: 0 : Point aPos = GetEntryPosition( pEntry );
1252 : 0 : aPos.Y() += ( nEntryHeight - aItemSize.Height() ) / 2;
1253 [ # # ]: 0 : aPos.X() = GetTabPos( pEntry, pTab );
1254 : 0 : long nOutputWidth = pImp->GetOutputSize().Width();
1255 : 0 : Size aSize( nOutputWidth - aPos.X(), aItemSize.Height() );
1256 [ # # ][ # # ]: 0 : sal_uInt16 nPos = std::find( aTabs.begin(), aTabs.end(), pTab ) - aTabs.begin();
1257 [ # # ]: 0 : if( nPos+1 < (sal_uInt16)aTabs.size() )
1258 : : {
1259 : 0 : SvLBoxTab* pRightTab = aTabs[ nPos + 1 ];
1260 [ # # ]: 0 : long nRight = GetTabPos( pEntry, pRightTab );
1261 [ # # ]: 0 : if( nRight <= nOutputWidth )
1262 : 0 : aSize.Width() = nRight - aPos.X();
1263 : : }
1264 : 0 : Point aOrigin( GetMapMode().GetOrigin() );
1265 : 0 : aPos += aOrigin; // convert to win coordinates
1266 : 0 : aSize.Width() -= aOrigin.X();
1267 [ # # ]: 0 : Rectangle aRect( aPos, aSize );
1268 [ # # ][ # # ]: 0 : EditText( pItem->GetText(), aRect, rSelection );
[ # # ]
1269 : 0 : }
1270 : :
1271 : 0 : void SvTreeListBox::EditEntry( SvLBoxEntry* pEntry )
1272 : : {
1273 : 0 : pImp->aEditClickPos = Point( -1, -1 );
1274 : 0 : ImplEditEntry( pEntry );
1275 : 0 : }
1276 : :
1277 : 0 : void SvTreeListBox::ImplEditEntry( SvLBoxEntry* pEntry )
1278 : : {
1279 : : DBG_CHKTHIS(SvTreeListBox,0);
1280 [ # # ]: 0 : if( IsEditingActive() )
1281 : 0 : EndEditing();
1282 [ # # ]: 0 : if( !pEntry )
1283 : 0 : pEntry = GetCurEntry();
1284 [ # # ]: 0 : if( pEntry )
1285 : : {
1286 : 0 : long nClickX = pImp->aEditClickPos.X();
1287 : 0 : bool bIsMouseTriggered = nClickX >= 0;
1288 : :
1289 : 0 : SvLBoxString* pItem = NULL;
1290 : 0 : sal_uInt16 nCount = pEntry->ItemCount();
1291 : 0 : long nTabPos, nNextTabPos = 0;
1292 [ # # ]: 0 : for( sal_uInt16 i = 0 ; i < nCount ; i++ )
1293 : : {
1294 [ # # ]: 0 : SvLBoxItem* pTmpItem = pEntry->GetItem( i );
1295 [ # # ][ # # ]: 0 : if( pTmpItem->IsA() != SV_ITEM_ID_LBOXSTRING )
1296 : 0 : continue;
1297 : :
1298 [ # # ]: 0 : SvLBoxTab* pTab = GetTab( pEntry, pTmpItem );
1299 : 0 : nNextTabPos = -1;
1300 [ # # ]: 0 : if( i < nCount - 1 )
1301 : : {
1302 [ # # ]: 0 : SvLBoxItem* pNextItem = pEntry->GetItem( i + 1 );
1303 [ # # ]: 0 : SvLBoxTab* pNextTab = GetTab( pEntry, pNextItem );
1304 : 0 : nNextTabPos = pNextTab->GetPos();
1305 : : }
1306 : :
1307 [ # # ][ # # ]: 0 : if( pTab && pTab->IsEditable() )
[ # # ]
1308 : : {
1309 : 0 : nTabPos = pTab->GetPos();
1310 [ # # ][ # # ]: 0 : if( !bIsMouseTriggered || (nClickX > nTabPos && (nNextTabPos == -1 || nClickX < nNextTabPos ) ) )
[ # # ][ # # ]
1311 : : {
1312 : 0 : pItem = static_cast<SvLBoxString*>( pTmpItem );
1313 : 0 : break;
1314 : : }
1315 : : }
1316 : : }
1317 : :
1318 : 0 : Selection aSel( SELECTION_MIN, SELECTION_MAX );
1319 [ # # ][ # # ]: 0 : if( pItem && EditingEntry( pEntry, aSel ) )
[ # # ][ # # ]
1320 : : {
1321 [ # # ]: 0 : SelectAll( sal_False );
1322 [ # # ]: 0 : MakeVisible( pEntry );
1323 [ # # ]: 0 : EditItemText( pEntry, pItem, aSel );
1324 : : }
1325 : : }
1326 : 0 : }
1327 : :
1328 : 0 : sal_Bool SvTreeListBox::AreChildrenTransient() const
1329 : : {
1330 : 0 : return pImp->AreChildrenTransient();
1331 : : }
1332 : :
1333 : 0 : void SvTreeListBox::SetChildrenNotTransient()
1334 : : {
1335 : 0 : pImp->SetChildrenNotTransient();
1336 : 0 : }
1337 : :
1338 : 0 : void SvTreeListBox::EditedText( const XubString& rStr )
1339 : :
1340 : : {
1341 : : DBG_CHKTHIS(SvTreeListBox,0);
1342 [ # # ]: 0 : if(pEdEntry) // we have to check if this entry is null that means that it is removed while editing
1343 : : {
1344 [ # # ][ # # ]: 0 : if( EditedEntry( pEdEntry, rStr ) )
1345 : : {
1346 : 0 : ((SvLBoxString*)pEdItem)->SetText( rStr );
1347 : 0 : pModel->InvalidateEntry( pEdEntry );
1348 : : }
1349 [ # # ]: 0 : if( GetSelectionCount() == 0 )
1350 : 0 : Select( pEdEntry );
1351 [ # # ][ # # ]: 0 : if( GetSelectionMode() == MULTIPLE_SELECTION && !GetCurEntry() )
[ # # ]
1352 : 0 : SetCurEntry( pEdEntry );
1353 : : }
1354 : 0 : }
1355 : :
1356 : 0 : void SvTreeListBox::EditingRequest( SvLBoxEntry* pEntry, SvLBoxItem* pItem,
1357 : : const Point& )
1358 : : {
1359 : : DBG_CHKTHIS(SvTreeListBox,0);
1360 [ # # ]: 0 : if( IsEditingActive() )
1361 : 0 : EndEditing();
1362 [ # # ]: 0 : if( pItem->IsA() == SV_ITEM_ID_LBOXSTRING )
1363 : : {
1364 : 0 : Selection aSel( SELECTION_MIN, SELECTION_MAX );
1365 [ # # ][ # # ]: 0 : if( EditingEntry( pEntry, aSel ) )
1366 : : {
1367 [ # # ]: 0 : SelectAll( sal_False );
1368 [ # # ]: 0 : EditItemText( pEntry, (SvLBoxString*)pItem, aSel );
1369 : : }
1370 : : }
1371 : 0 : }
1372 : :
1373 : :
1374 : :
1375 : 0 : SvLBoxEntry* SvTreeListBox::GetDropTarget( const Point& rPos )
1376 : : {
1377 : : DBG_CHKTHIS(SvTreeListBox,0);
1378 : : // scroll
1379 [ # # ]: 0 : if( rPos.Y() < 12 )
1380 : : {
1381 : 0 : SvLBox::ImplShowTargetEmphasis( SvLBox::pTargetEntry, sal_False );
1382 : 0 : ScrollOutputArea( +1 );
1383 : : }
1384 : : else
1385 : : {
1386 : 0 : Size aSize( pImp->GetOutputSize() );
1387 [ # # ]: 0 : if( rPos.Y() > aSize.Height() - 12 )
1388 : : {
1389 [ # # ]: 0 : SvLBox::ImplShowTargetEmphasis( SvLBox::pTargetEntry, sal_False );
1390 [ # # ]: 0 : ScrollOutputArea( -1 );
1391 : : }
1392 : : }
1393 : :
1394 : 0 : SvLBoxEntry* pTarget = pImp->GetEntry( rPos );
1395 : : // when dropping in a vacant space, use the last entry
1396 [ # # ]: 0 : if( !pTarget )
1397 : 0 : return (SvLBoxEntry*)LastVisible();
1398 [ # # # # : 0 : else if( (GetDragDropMode() & SV_DRAGDROP_ENABLE_TOP) &&
# # ][ # # ]
1399 : 0 : pTarget == First() && rPos.Y() < 6 )
1400 : 0 : return 0;
1401 : :
1402 : 0 : return pTarget;
1403 : : }
1404 : :
1405 : :
1406 : 0 : SvLBoxEntry* SvTreeListBox::GetEntry( const Point& rPos, sal_Bool bHit ) const
1407 : : {
1408 : : DBG_CHKTHIS(SvTreeListBox,0);
1409 : 0 : SvLBoxEntry* pEntry = pImp->GetEntry( rPos );
1410 [ # # ][ # # ]: 0 : if( pEntry && bHit )
1411 : : {
1412 : 0 : long nLine = pImp->GetEntryLine( pEntry );
1413 [ # # ]: 0 : if( !(pImp->EntryReallyHit( pEntry, rPos, nLine)) )
1414 : 0 : return 0;
1415 : : }
1416 : 0 : return pEntry;
1417 : : }
1418 : :
1419 : 0 : SvLBoxEntry* SvTreeListBox::GetCurEntry() const
1420 : : {
1421 : : DBG_CHKTHIS(SvTreeListBox,0);
1422 : 0 : return pImp->GetCurEntry();
1423 : : }
1424 : :
1425 : 242 : void SvTreeListBox::ImplInitStyle()
1426 : : {
1427 : : DBG_CHKTHIS(SvTreeListBox,0);
1428 : :
1429 : 242 : const WinBits nWindowStyle = GetStyle();
1430 : :
1431 : 242 : nTreeFlags |= TREEFLAG_RECALCTABS;
1432 [ + + ]: 242 : if( nWindowStyle & WB_SORT )
1433 : : {
1434 : 240 : GetModel()->SetSortMode( SortAscending );
1435 : 240 : GetModel()->SetCompareHdl( LINK(this,SvTreeListBox,DefaultCompare));
1436 : : }
1437 : : else
1438 : : {
1439 : 2 : GetModel()->SetSortMode( SortNone );
1440 : 2 : GetModel()->SetCompareHdl( Link() );
1441 : : }
1442 : 242 : pImp->SetStyle( nWindowStyle );
1443 : 242 : pImp->Resize();
1444 : 242 : Invalidate();
1445 : 242 : }
1446 : :
1447 : 0 : void SvTreeListBox::PaintEntry( SvLBoxEntry* pEntry )
1448 : : {
1449 : : DBG_CHKTHIS(SvTreeListBox,0);
1450 : : DBG_ASSERT(pEntry,"PaintEntry:No Entry");
1451 [ # # ]: 0 : if( pEntry )
1452 : 0 : pImp->PaintEntry( pEntry );
1453 : 0 : }
1454 : :
1455 : 0 : void SvTreeListBox::InvalidateEntry( SvLBoxEntry* pEntry )
1456 : : {
1457 : : DBG_CHKTHIS(SvTreeListBox,0);
1458 : : DBG_ASSERT(pEntry,"InvalidateEntry:No Entry");
1459 [ # # ]: 0 : if( pEntry )
1460 : : {
1461 : 0 : GetModel()->InvalidateEntry( pEntry );
1462 : : }
1463 : 0 : }
1464 : :
1465 : :
1466 : 0 : long SvTreeListBox::PaintEntry(SvLBoxEntry* pEntry,long nLine,sal_uInt16 nTabFlags)
1467 : : {
1468 : 0 : return PaintEntry1(pEntry,nLine,nTabFlags);
1469 : : }
1470 : :
1471 : : #define SV_TAB_BORDER 8
1472 : :
1473 : 3359 : long SvTreeListBox::PaintEntry1(SvLBoxEntry* pEntry,long nLine,sal_uInt16 nTabFlags,
1474 : : sal_Bool bHasClipRegion )
1475 : : {
1476 : : DBG_CHKTHIS(SvTreeListBox,0);
1477 : :
1478 [ + - ]: 3359 : Rectangle aRect; // multi purpose
1479 : :
1480 [ + - ]: 3359 : sal_Bool bHorSBar = pImp->HasHorScrollBar();
1481 [ + - ]: 3359 : PreparePaint( pEntry );
1482 : :
1483 [ + - ]: 3359 : pImp->UpdateContextBmpWidthMax( pEntry );
1484 : :
1485 [ - + ]: 3359 : if( nTreeFlags & TREEFLAG_RECALCTABS )
1486 [ # # ]: 0 : SetTabs();
1487 : :
1488 : 3359 : short nTempEntryHeight = GetEntryHeight();
1489 : 3359 : long nWidth = pImp->GetOutputSize().Width();
1490 : :
1491 : : // Did we turn on the scrollbar within PreparePaints? If yes, we have to set
1492 : : // the ClipRegion anew.
1493 [ + - ][ - + ]: 3359 : if( !bHorSBar && pImp->HasHorScrollBar() )
[ - + ][ + - ]
1494 [ # # ][ # # ]: 0 : SetClipRegion( Region(pImp->GetClipRegionRect()) );
[ # # ][ # # ]
1495 : :
1496 : 3359 : Point aEntryPos( GetMapMode().GetOrigin() );
1497 : 3359 : aEntryPos.X() *= -1; // conversion document coordinates
1498 : 3359 : long nMaxRight = nWidth + aEntryPos.X() - 1;
1499 : :
1500 : 3359 : Color aBackupTextColor( GetTextColor() );
1501 [ + - ]: 3359 : Font aBackupFont( GetFont() );
1502 : 3359 : Color aBackupColor = GetFillColor();
1503 : :
1504 : 3359 : bool bCurFontIsSel = false;
1505 : 3359 : sal_Bool bInUse = pEntry->HasInUseEmphasis();
1506 : : // if a ClipRegion was set from outside, we don't have to reset it
1507 [ + - ]: 3359 : const WinBits nWindowStyle = GetStyle();
1508 : 3359 : const sal_Bool bResetClipRegion = !bHasClipRegion;
1509 [ + + ][ + - ]: 3359 : const sal_Bool bHideSelection = ((nWindowStyle & WB_HIDESELECTION) && !HasFocus())!=0;
[ + - ]
1510 : 3359 : const StyleSettings& rSettings = GetSettings().GetStyleSettings();
1511 : :
1512 [ + - ]: 3359 : Font aHighlightFont( GetFont() );
1513 : 3359 : const Color aHighlightTextColor( rSettings.GetHighlightTextColor() );
1514 [ + - ]: 3359 : aHighlightFont.SetColor( aHighlightTextColor );
1515 : :
1516 : 3359 : Size aRectSize( 0, nTempEntryHeight );
1517 : :
1518 [ + + ][ + + ]: 3359 : if( !bHasClipRegion && nWindowStyle & WB_HSCROLL )
1519 : : {
1520 [ + - ][ + - ]: 6 : SetClipRegion( Region(pImp->GetClipRegionRect()) );
[ + - ][ + - ]
1521 : 6 : bHasClipRegion = sal_True;
1522 : : }
1523 : :
1524 [ + - ]: 3359 : SvViewDataEntry* pViewDataEntry = GetViewDataEntry( pEntry );
1525 : :
1526 : 3359 : sal_uInt16 nTabCount = aTabs.size();
1527 : 3359 : sal_uInt16 nItemCount = pEntry->ItemCount();
1528 : 3359 : sal_uInt16 nCurTab = 0;
1529 : 3359 : sal_uInt16 nCurItem = 0;
1530 : :
1531 [ + + ][ + - ]: 10077 : while( nCurTab < nTabCount && nCurItem < nItemCount )
[ + + ]
1532 : : {
1533 : 6718 : SvLBoxTab* pTab = aTabs[ nCurTab ];
1534 : 6718 : sal_uInt16 nNextTab = nCurTab + 1;
1535 [ + + ]: 6718 : SvLBoxTab* pNextTab = nNextTab < nTabCount ? aTabs[nNextTab] : 0;
1536 [ + - ][ + - ]: 6718 : SvLBoxItem* pItem = nCurItem < nItemCount ? pEntry->GetItem(nCurItem) : 0;
1537 : :
1538 : 6718 : sal_uInt16 nFlags = pTab->nFlags;
1539 : 6718 : Size aSize( pItem->GetSize( pViewDataEntry, nCurItem ));
1540 [ + - ]: 6718 : long nTabPos = GetTabPos( pEntry, pTab );
1541 : :
1542 : : long nNextTabPos;
1543 [ + + ]: 6718 : if( pNextTab )
1544 [ + - ]: 3359 : nNextTabPos = GetTabPos( pEntry, pNextTab );
1545 : : else
1546 : : {
1547 : 3359 : nNextTabPos = nMaxRight;
1548 [ - + ]: 3359 : if( nTabPos > nMaxRight )
1549 : 0 : nNextTabPos += 50;
1550 : : }
1551 : :
1552 : : long nX;
1553 [ - + ]: 6718 : if( pTab->nFlags & SV_LBOXTAB_ADJUST_RIGHT )
1554 : : // avoid cutting the right edge off the tab separation
1555 [ # # ]: 0 : nX = nTabPos + pTab->CalcOffset(aSize.Width(), (nNextTabPos-SV_TAB_BORDER-1) -nTabPos);
1556 : : else
1557 [ + - ]: 6718 : nX = nTabPos + pTab->CalcOffset(aSize.Width(), nNextTabPos-nTabPos);
1558 : :
1559 [ + - ]: 6718 : if( nFlags & nTabFlags )
1560 : : {
1561 [ + + ][ - + ]: 6718 : if( !bHasClipRegion && nX + aSize.Width() >= nMaxRight )
[ - + ]
1562 : : {
1563 [ # # ][ # # ]: 0 : SetClipRegion( Region(pImp->GetClipRegionRect()) );
[ # # ][ # # ]
1564 : 0 : bHasClipRegion = sal_True;
1565 : : }
1566 : 6718 : aEntryPos.X() = nX;
1567 : 6718 : aEntryPos.Y() = nLine;
1568 : :
1569 : : // set background pattern/color
1570 : :
1571 [ + - ]: 6718 : Wallpaper aWallpaper = GetBackground();
1572 : :
1573 : 6718 : int bSelTab = nFlags & SV_LBOXTAB_SHOW_SELECTION;
1574 [ + - ]: 6718 : sal_uInt16 nItemType = pItem->IsA();
1575 : :
1576 [ + + ][ + + ]: 6718 : if ( pViewDataEntry->IsSelected() && bSelTab && !pViewDataEntry->IsCursored() )
[ + - ][ + + ]
1577 : : {
1578 : 289 : Color aNewWallColor = rSettings.GetHighlightColor();
1579 [ # # ][ - + ]: 289 : if ( !bInUse || nItemType != SV_ITEM_ID_LBOXCONTEXTBMP )
1580 : : {
1581 : : // if the face color is bright then the deactive color is also bright
1582 : : // -> so you can't see any deactive selection
1583 [ + + ][ + - ]: 564 : if ( bHideSelection && !rSettings.GetFaceColor().IsBright() &&
[ + - ][ + - ]
[ + + ]
1584 [ + - ][ + - ]: 275 : aWallpaper.GetColor().IsBright() != rSettings.GetDeactiveColor().IsBright() )
[ + - ]
1585 : 275 : aNewWallColor = rSettings.GetDeactiveColor();
1586 : : // set font color to highlight
1587 [ + - ]: 289 : if ( !bCurFontIsSel )
1588 : : {
1589 [ + - ]: 289 : SetTextColor( aHighlightTextColor );
1590 [ + - ]: 289 : SetFont( aHighlightFont );
1591 : 289 : bCurFontIsSel = true;
1592 : : }
1593 : : }
1594 [ + - ]: 289 : aWallpaper.SetColor( aNewWallColor );
1595 : : }
1596 : : else // no selection
1597 : : {
1598 [ - + ][ # # ]: 6429 : if( bInUse && nItemType == SV_ITEM_ID_LBOXCONTEXTBMP )
1599 [ # # ]: 0 : aWallpaper.SetColor( rSettings.GetFieldColor() );
1600 [ - + ]: 6429 : else if( bCurFontIsSel )
1601 : : {
1602 : 0 : bCurFontIsSel = false;
1603 [ # # ]: 0 : SetTextColor( aBackupTextColor );
1604 [ # # ]: 0 : SetFont( aBackupFont );
1605 : : }
1606 : : }
1607 : :
1608 : : // draw background
1609 [ + - ]: 6718 : if( !(nTreeFlags & TREEFLAG_USESEL))
1610 : : {
1611 : : // only draw the area that is used by the item
1612 : 6718 : aRectSize.Width() = aSize.Width();
1613 : 6718 : aRect.SetPos( aEntryPos );
1614 [ + - ]: 6718 : aRect.SetSize( aRectSize );
1615 : : }
1616 : : else
1617 : : {
1618 : : // draw from the current to the next tab
1619 [ # # ]: 0 : if( nCurTab != 0 )
1620 : 0 : aRect.Left() = nTabPos;
1621 : : else
1622 : : // if we're in the 0th tab, always draw from column 0 --
1623 : : // else we get problems with centered tabs
1624 : 0 : aRect.Left() = 0;
1625 : 0 : aRect.Top() = nLine;
1626 : 0 : aRect.Bottom() = nLine + nTempEntryHeight - 1;
1627 [ # # ]: 0 : if( pNextTab )
1628 : : {
1629 : : long nRight;
1630 [ # # ]: 0 : nRight = GetTabPos(pEntry,pNextTab)-1;
1631 [ # # ]: 0 : if( nRight > nMaxRight )
1632 : 0 : nRight = nMaxRight;
1633 : 0 : aRect.Right() = nRight;
1634 : : }
1635 : : else
1636 : 0 : aRect.Right() = nMaxRight;
1637 : : }
1638 : : // A custom selection that starts at a tab position > 0, do not fill
1639 : : // the background of the 0th item, else e.g. we might not be able to
1640 : : // realize tab listboxes with lines.
1641 [ + + ][ - + ]: 6718 : if( !(nCurTab==0 && (nTreeFlags & TREEFLAG_USESEL) && nFirstSelTab) )
[ # # ]
1642 : : {
1643 [ + - ][ + - ]: 6718 : SetFillColor( aWallpaper.GetColor() );
1644 : : // this case may occur for smaller horizontal resizes
1645 [ + + ]: 6718 : if( aRect.Left() < aRect.Right() )
1646 [ + - ]: 3400 : DrawRect( aRect );
1647 : : }
1648 : : // draw item
1649 : : // center vertically
1650 : 6718 : aEntryPos.Y() += ( nTempEntryHeight - aSize.Height() ) / 2;
1651 [ + - ]: 6718 : pItem->Paint( aEntryPos, *this, pViewDataEntry->GetFlags(), pEntry );
1652 : :
1653 : : // division line between tabs
1654 [ + + ][ + - ]: 6718 : if( pNextTab && pItem->IsA() == SV_ITEM_ID_LBOXSTRING &&
[ - + # # ]
[ - + ]
1655 : : // not at the right edge of the window!
1656 : 0 : aRect.Right() < nMaxRight )
1657 : : {
1658 : 0 : aRect.Left() = aRect.Right() - SV_TAB_BORDER;
1659 [ # # ]: 0 : DrawRect( aRect );
1660 : : }
1661 : :
1662 [ + - ][ + - ]: 6718 : SetFillColor( aBackupColor );
1663 : : }
1664 : 6718 : nCurItem++;
1665 : 6718 : nCurTab++;
1666 : : }
1667 [ - + ][ # # ]: 3359 : if( pViewDataEntry->IsCursored() && !HasFocus() )
[ # # ][ - + ]
1668 : : {
1669 : : // cursor emphasis
1670 [ # # ]: 0 : SetFillColor();
1671 : 0 : Color aOldLineColor = GetLineColor();
1672 [ # # ]: 0 : SetLineColor( Color( COL_BLACK ) );
1673 [ # # ]: 0 : aRect = GetFocusRect( pEntry, nLine );
1674 : 0 : aRect.Top()++;
1675 : 0 : aRect.Bottom()--;
1676 [ # # ]: 0 : DrawRect( aRect );
1677 [ # # ]: 0 : SetLineColor( aOldLineColor );
1678 [ # # ]: 0 : SetFillColor( aBackupColor );
1679 : : }
1680 : :
1681 [ + + ]: 3359 : if( bCurFontIsSel )
1682 : : {
1683 [ + - ]: 289 : SetTextColor( aBackupTextColor );
1684 [ + - ]: 289 : SetFont( aBackupFont );
1685 : : }
1686 : :
1687 : : sal_uInt16 nFirstDynTabPos;
1688 [ + - ]: 3359 : SvLBoxTab* pFirstDynamicTab = GetFirstDynamicTab( nFirstDynTabPos );
1689 [ + - ]: 3359 : long nDynTabPos = GetTabPos( pEntry, pFirstDynamicTab );
1690 : 3359 : nDynTabPos += pImp->nNodeBmpTabDistance;
1691 : 3359 : nDynTabPos += pImp->nNodeBmpWidth / 2;
1692 : 3359 : nDynTabPos += 4; // 4 pixels of buffer, so the node bitmap is not too close
1693 : : // to the next tab
1694 : :
1695 [ + - ][ + + ]: 3420 : if( (!(pEntry->GetFlags() & SV_ENTRYFLAG_NO_NODEBMP)) &&
[ + - + +
+ + ][ + + ]
1696 : : (nWindowStyle & WB_HASBUTTONS) && pFirstDynamicTab &&
1697 : 61 : ( pEntry->HasChildren() || pEntry->HasChildrenOnDemand() ) )
1698 : : {
1699 : : // find first tab and check if the node bitmap extends into it
1700 : 34 : sal_uInt16 nNextTab = nFirstDynTabPos;
1701 : : SvLBoxTab* pNextTab;
1702 [ + + + - ]: 102 : do
[ + + ]
1703 : : {
1704 : 68 : nNextTab++;
1705 [ + + ]: 68 : pNextTab = nNextTab < nTabCount ? aTabs[nNextTab] : 0;
1706 : 34 : } while( pNextTab && pNextTab->IsDynamic() );
1707 : :
1708 [ - + ][ # # ]: 34 : if( !pNextTab || (GetTabPos( pEntry, pNextTab ) > nDynTabPos) )
[ # # ][ + - ]
1709 : : {
1710 [ - + ][ # # ]: 34 : if((nWindowStyle & WB_HASBUTTONSATROOT) || pModel->GetDepth(pEntry) > 0)
[ # # ][ + - ]
1711 : : {
1712 [ + - ]: 34 : Point aPos( GetTabPos(pEntry,pFirstDynamicTab), nLine );
1713 : 34 : aPos.X() += pImp->nNodeBmpTabDistance;
1714 : :
1715 : 34 : const Image* pImg = 0;
1716 : :
1717 [ + + ][ + - ]: 34 : if( IsExpanded(pEntry) )
1718 : 16 : pImg = &pImp->GetExpandedNodeBmp( );
1719 : : else
1720 : : {
1721 [ + + ][ + - : 62 : if( (!pEntry->HasChildren()) && pEntry->HasChildrenOnDemand() &&
+ - - + ]
[ - + ]
1722 : 13 : (!(pEntry->GetFlags() & SV_ENTRYFLAG_HAD_CHILDREN)) &&
1723 [ + - ][ + + ]: 31 : pImp->GetDontKnowNodeBmp().GetSizePixel().Width() )
[ # # ]
1724 : 0 : pImg = &pImp->GetDontKnowNodeBmp( );
1725 : : else
1726 : 18 : pImg = &pImp->GetCollapsedNodeBmp( );
1727 : : }
1728 [ + - ]: 34 : aPos.Y() += (nTempEntryHeight - pImg->GetSizePixel().Height()) / 2;
1729 : :
1730 : 34 : sal_uInt16 nStyle = 0;
1731 [ - + ][ + - ]: 34 : if ( !IsEnabled() )
1732 : 0 : nStyle |= IMAGE_DRAW_DISABLE;
1733 : :
1734 : : //native
1735 : 34 : sal_Bool bNativeOK = sal_False;
1736 [ + - ][ - + ]: 34 : if ( IsNativeControlSupported( CTRL_LISTNODE, PART_ENTIRE_CONTROL) )
1737 : : {
1738 : 0 : ImplControlValue aControlValue;
1739 [ # # ][ # # ]: 0 : Rectangle aCtrlRegion( aPos, pImg->GetSizePixel() );
1740 : 0 : ControlState nState = 0;
1741 : :
1742 [ # # ][ # # ]: 0 : if ( IsEnabled() ) nState |= CTRL_STATE_ENABLED;
1743 : :
1744 [ # # ][ # # ]: 0 : if ( IsExpanded(pEntry) )
1745 : 0 : aControlValue.setTristateVal( BUTTONVALUE_ON );//expanded node
1746 : : else
1747 : : {
1748 [ # # # # : 0 : if( (!pEntry->HasChildren() ) &&
# # # # ]
[ # # ]
1749 : 0 : pEntry->HasChildrenOnDemand() &&
1750 : 0 : (!(pEntry->GetFlags() & SV_ENTRYFLAG_HAD_CHILDREN)) &&
1751 [ # # ][ # # ]: 0 : pImp->GetDontKnowNodeBmp().GetSizePixel().Width()
[ # # ]
1752 : : )
1753 : 0 : aControlValue.setTristateVal( BUTTONVALUE_DONTKNOW ); //dont know
1754 : : else
1755 : 0 : aControlValue.setTristateVal( BUTTONVALUE_OFF ); //collapsed node
1756 : : }
1757 : :
1758 : : bNativeOK = DrawNativeControl( CTRL_LISTNODE, PART_ENTIRE_CONTROL,
1759 [ # # ][ # # ]: 0 : aCtrlRegion, nState, aControlValue, rtl::OUString() );
1760 : : }
1761 : :
1762 [ + - ]: 34 : if( !bNativeOK) {
1763 [ + - ]: 34 : DrawImage( aPos, *pImg ,nStyle);
1764 : : }
1765 : : }
1766 : : }
1767 : : }
1768 : :
1769 : :
1770 [ + + ][ + + ]: 3359 : if( bHasClipRegion && bResetClipRegion )
1771 [ + - ]: 6 : SetClipRegion();
1772 [ + - ][ + - ]: 3359 : return 0; // nRowLen;
1773 : : }
1774 : :
1775 : 3359 : void SvTreeListBox::PreparePaint( SvLBoxEntry* )
1776 : : {
1777 : 3359 : }
1778 : :
1779 : 126 : Rectangle SvTreeListBox::GetFocusRect( SvLBoxEntry* pEntry, long nLine )
1780 : : {
1781 : : DBG_CHKTHIS(SvTreeListBox,0);
1782 : 126 : Size aSize;
1783 [ + - ]: 126 : Rectangle aRect;
1784 : 126 : aRect.Top() = nLine;
1785 : 126 : aSize.Height() = GetEntryHeight();
1786 : :
1787 : 126 : long nRealWidth = pImp->GetOutputSize().Width();
1788 : 126 : nRealWidth -= GetMapMode().GetOrigin().X();
1789 : :
1790 : : sal_uInt16 nCurTab;
1791 [ + - ]: 126 : SvLBoxTab* pTab = GetFirstTab( SV_LBOXTAB_SHOW_SELECTION, nCurTab );
1792 : 126 : long nTabPos = 0;
1793 [ + - ]: 126 : if( pTab )
1794 [ + - ]: 126 : nTabPos = GetTabPos( pEntry, pTab );
1795 : : long nNextTabPos;
1796 [ + - ][ - + ]: 126 : if( pTab && nCurTab < aTabs.size() - 1 )
[ - + ]
1797 : : {
1798 : 0 : SvLBoxTab* pNextTab = aTabs[ nCurTab + 1 ];
1799 [ # # ]: 0 : nNextTabPos = GetTabPos( pEntry, pNextTab );
1800 : : }
1801 : : else
1802 : : {
1803 : 126 : nNextTabPos = nRealWidth;
1804 [ - + ]: 126 : if( nTabPos > nRealWidth )
1805 : 0 : nNextTabPos += 50;
1806 : : }
1807 : :
1808 : 126 : sal_Bool bUserSelection = (sal_Bool)( nTreeFlags & TREEFLAG_USESEL ) != 0;
1809 [ + - ]: 126 : if( !bUserSelection )
1810 : : {
1811 [ + - ][ + - ]: 126 : if( pTab && nCurTab < pEntry->ItemCount() )
[ + - ]
1812 : : {
1813 [ + - ]: 126 : SvLBoxItem* pItem = pEntry->GetItem( nCurTab );
1814 [ + - ]: 126 : aSize.Width() = pItem->GetSize( this, pEntry ).Width();
1815 [ - + ]: 126 : if( !aSize.Width() )
1816 : 0 : aSize.Width() = 15;
1817 : 126 : long nX = nTabPos; //GetTabPos( pEntry, pTab );
1818 : : // alignment
1819 [ + - ]: 126 : nX += pTab->CalcOffset( aSize.Width(), nNextTabPos - nTabPos );
1820 : 126 : aRect.Left() = nX;
1821 : : // make sure that first and last letter aren't cut off slightly
1822 [ + - ]: 126 : aRect.SetSize( aSize );
1823 [ + - ]: 126 : if( aRect.Left() > 0 )
1824 : 126 : aRect.Left()--;
1825 : 126 : aRect.Right()++;
1826 : : }
1827 : : }
1828 : : else
1829 : : {
1830 : : // if SelTab != 0, we have to calculate also
1831 [ # # ][ # # ]: 0 : if( nFocusWidth == -1 || nFirstSelTab )
1832 : : {
1833 : : sal_uInt16 nLastTab;
1834 [ # # ]: 0 : SvLBoxTab* pLastTab = GetLastTab(SV_LBOXTAB_SHOW_SELECTION,nLastTab);
1835 : 0 : nLastTab++;
1836 [ # # ]: 0 : if( nLastTab < aTabs.size() ) // is there another one?
1837 : 0 : pLastTab = aTabs[ nLastTab ];
1838 : : else
1839 : 0 : pLastTab = 0; // select whole width
1840 [ # # ]: 0 : aSize.Width() = pLastTab ? pLastTab->GetPos() : 0x0fffffff;
1841 : 0 : nFocusWidth = (short)aSize.Width();
1842 [ # # ]: 0 : if( pTab )
1843 : 0 : nFocusWidth = nFocusWidth - (short)nTabPos; //pTab->GetPos();
1844 : : }
1845 : : else
1846 : : {
1847 : 0 : aSize.Width() = nFocusWidth;
1848 [ # # ]: 0 : if( pTab )
1849 : : {
1850 [ # # ]: 0 : if( nCurTab )
1851 : 0 : aSize.Width() += nTabPos;
1852 : : else
1853 : 0 : aSize.Width() += pTab->GetPos(); // Tab0 always from the leftmost position
1854 : : }
1855 : : }
1856 : : // if selection starts with 0th tab, draw from column 0 on
1857 [ # # ]: 0 : if( nCurTab != 0 )
1858 : : {
1859 : 0 : aRect.Left() = nTabPos;
1860 : 0 : aSize.Width() -= nTabPos;
1861 : : }
1862 [ # # ]: 0 : aRect.SetSize( aSize );
1863 : : }
1864 : : // adjust right edge because of clipping
1865 [ - + ]: 126 : if( aRect.Right() >= nRealWidth )
1866 : : {
1867 : 0 : aRect.Right() = nRealWidth-1;
1868 [ # # ]: 126 : nFocusWidth = (short)aRect.GetWidth();
1869 : : }
1870 : 126 : return aRect;
1871 : : }
1872 : :
1873 : :
1874 : 16057 : long SvTreeListBox::GetTabPos( SvLBoxEntry* pEntry, SvLBoxTab* pTab)
1875 : : {
1876 : : DBG_CHKTHIS(SvTreeListBox,0);
1877 : : DBG_ASSERT(pTab,"No Tab");
1878 : 16057 : long nPos = pTab->GetPos();
1879 [ + - ]: 16057 : if( pTab->IsDynamic() )
1880 : : {
1881 : 16057 : sal_uInt16 nDepth = pModel->GetDepth( pEntry );
1882 : 16057 : nDepth = nDepth * (sal_uInt16)nIndent;
1883 : 16057 : nPos += (long)nDepth;
1884 : : }
1885 : 16057 : return nPos;
1886 : : }
1887 : :
1888 : 0 : SvLBoxItem* SvTreeListBox::GetItem_Impl( SvLBoxEntry* pEntry, long nX,
1889 : : SvLBoxTab** ppTab, sal_uInt16 nEmptyWidth )
1890 : : {
1891 : : DBG_CHKTHIS(SvTreeListBox,0);
1892 : 0 : SvLBoxItem* pItemClicked = 0;
1893 : 0 : sal_uInt16 nTabCount = aTabs.size();
1894 : 0 : sal_uInt16 nItemCount = pEntry->ItemCount();
1895 : 0 : SvLBoxTab* pTab = aTabs.front();
1896 : 0 : SvLBoxItem* pItem = pEntry->GetItem(0);
1897 : 0 : sal_uInt16 nNextItem = 1;
1898 : 0 : nX -= GetMapMode().GetOrigin().X();
1899 : 0 : long nRealWidth = pImp->GetOutputSize().Width();
1900 : 0 : nRealWidth -= GetMapMode().GetOrigin().X();
1901 : :
1902 : 0 : while( 1 )
1903 : : {
1904 [ # # ]: 0 : SvLBoxTab* pNextTab=nNextItem<nTabCount ? aTabs[nNextItem] : 0;
1905 [ # # ]: 0 : long nStart = GetTabPos( pEntry, pTab );
1906 : :
1907 : : long nNextTabPos;
1908 [ # # ]: 0 : if( pNextTab )
1909 [ # # ]: 0 : nNextTabPos = GetTabPos( pEntry, pNextTab );
1910 : : else
1911 : : {
1912 : 0 : nNextTabPos = nRealWidth;
1913 [ # # ]: 0 : if( nStart > nRealWidth )
1914 : 0 : nNextTabPos += 50;
1915 : : }
1916 : :
1917 [ # # ]: 0 : Size aItemSize( pItem->GetSize(this, pEntry));
1918 [ # # ]: 0 : nStart += pTab->CalcOffset( aItemSize.Width(), nNextTabPos - nStart );
1919 : 0 : long nLen = aItemSize.Width();
1920 [ # # ]: 0 : if( pNextTab )
1921 : : {
1922 [ # # ]: 0 : long nTabWidth = GetTabPos( pEntry, pNextTab ) - nStart;
1923 [ # # ]: 0 : if( nTabWidth < nLen )
1924 : 0 : nLen = nTabWidth;
1925 : : }
1926 : :
1927 [ # # ]: 0 : if( !nLen )
1928 : 0 : nLen = nEmptyWidth;
1929 : :
1930 [ # # ][ # # ]: 0 : if( nX >= nStart && nX < (nStart+nLen ) )
1931 : : {
1932 : 0 : pItemClicked = pItem;
1933 [ # # ]: 0 : if( ppTab )
1934 : : {
1935 : 0 : *ppTab = pTab;
1936 : : break;
1937 : : }
1938 : : }
1939 [ # # ][ # # ]: 0 : if( nNextItem >= nItemCount || nNextItem >= nTabCount)
1940 : : break;
1941 : 0 : pTab = aTabs[ nNextItem ];
1942 [ # # ]: 0 : pItem = pEntry->GetItem( nNextItem );
1943 : 0 : nNextItem++;
1944 : : }
1945 : 0 : return pItemClicked;
1946 : : }
1947 : :
1948 : 0 : SvLBoxItem* SvTreeListBox::GetItem(SvLBoxEntry* pEntry,long nX,SvLBoxTab** ppTab)
1949 : : {
1950 : 0 : return GetItem_Impl( pEntry, nX, ppTab, 0 );
1951 : : }
1952 : :
1953 : 0 : SvLBoxItem* SvTreeListBox::GetItem(SvLBoxEntry* pEntry,long nX )
1954 : : {
1955 : : DBG_CHKTHIS(SvTreeListBox,0);
1956 : : SvLBoxTab* pDummyTab;
1957 [ # # ]: 0 : return GetItem_Impl( pEntry, nX, &pDummyTab, 0 );
1958 : : }
1959 : :
1960 : 752 : void SvTreeListBox::AddTab(long nTabPos,sal_uInt16 nFlags,void* pUserData )
1961 : : {
1962 : : DBG_CHKTHIS(SvTreeListBox,0);
1963 : 752 : nFocusWidth = -1;
1964 [ + - ][ + - ]: 752 : SvLBoxTab* pTab = new SvLBoxTab( nTabPos, nFlags );
1965 : 752 : pTab->SetUserData( pUserData );
1966 [ + - ]: 752 : aTabs.push_back( pTab );
1967 [ - + ]: 752 : if( nTreeFlags & TREEFLAG_USESEL )
1968 : : {
1969 : 0 : sal_uInt16 nPos = aTabs.size() - 1;
1970 [ # # ][ # # ]: 0 : if( nPos >= nFirstSelTab && nPos <= nLastSelTab )
1971 : 0 : pTab->nFlags |= SV_LBOXTAB_SHOW_SELECTION;
1972 : : else
1973 : : // string items usually have to be selected -- turn this off
1974 : : // explicitly
1975 : 0 : pTab->nFlags &= ~SV_LBOXTAB_SHOW_SELECTION;
1976 : : }
1977 : 752 : }
1978 : :
1979 : :
1980 : :
1981 : 3371 : SvLBoxTab* SvTreeListBox::GetFirstDynamicTab( sal_uInt16& rPos ) const
1982 : : {
1983 : : DBG_CHKTHIS(SvTreeListBox,0);
1984 : 3371 : sal_uInt16 nCurTab = 0;
1985 : 3371 : sal_uInt16 nTabCount = aTabs.size();
1986 [ + - ]: 3371 : while( nCurTab < nTabCount )
1987 : : {
1988 : 3371 : SvLBoxTab* pTab = aTabs[nCurTab];
1989 [ + - ]: 3371 : if( pTab->nFlags & SV_LBOXTAB_DYNAMIC )
1990 : : {
1991 : 3371 : rPos = nCurTab;
1992 : 3371 : return pTab;
1993 : : }
1994 : 0 : nCurTab++;
1995 : : }
1996 : 3371 : return 0;
1997 : : }
1998 : :
1999 : 12 : SvLBoxTab* SvTreeListBox::GetFirstDynamicTab() const
2000 : : {
2001 : : sal_uInt16 nDummy;
2002 [ + - ]: 12 : return GetFirstDynamicTab( nDummy );
2003 : : }
2004 : :
2005 : 0 : SvLBoxTab* SvTreeListBox::GetTab( SvLBoxEntry* pEntry, SvLBoxItem* pItem) const
2006 : : {
2007 : : DBG_CHKTHIS(SvTreeListBox,0);
2008 : 0 : sal_uInt16 nPos = pEntry->GetPos( pItem );
2009 : 0 : return aTabs[ nPos ];
2010 : : }
2011 : :
2012 : 498 : void SvTreeListBox::ClearTabList()
2013 : : {
2014 : : DBG_CHKTHIS(SvTreeListBox,0);
2015 : 498 : sal_uInt16 nTabCount = aTabs.size();
2016 [ + + ]: 1250 : while( nTabCount )
2017 : : {
2018 : 752 : nTabCount--;
2019 : 752 : SvLBoxTab* pDelTab = aTabs[ nTabCount ];
2020 [ + - ]: 752 : delete pDelTab;
2021 : : }
2022 : 498 : aTabs.clear();
2023 : 498 : }
2024 : :
2025 : :
2026 : 0 : Size SvTreeListBox::GetOutputSizePixel() const
2027 : : {
2028 : : DBG_CHKTHIS(SvTreeListBox,0);
2029 : 0 : Size aSize = pImp->GetOutputSize();
2030 : 0 : return aSize;
2031 : : }
2032 : :
2033 : 0 : void SvTreeListBox::NotifyBeginScroll()
2034 : : {
2035 : : DBG_CHKTHIS(SvTreeListBox,0);
2036 : 0 : }
2037 : :
2038 : 0 : void SvTreeListBox::NotifyEndScroll()
2039 : : {
2040 : : DBG_CHKTHIS(SvTreeListBox,0);
2041 : 0 : }
2042 : :
2043 : 0 : void SvTreeListBox::NotifyScrolling( long )
2044 : : {
2045 : : DBG_CHKTHIS(SvTreeListBox,0);
2046 : 0 : }
2047 : :
2048 : 0 : void SvTreeListBox::NotifyScrolled()
2049 : : {
2050 : : DBG_CHKTHIS(SvTreeListBox,0);
2051 : 0 : aScrolledHdl.Call( this );
2052 : 0 : }
2053 : :
2054 : 390 : void SvTreeListBox::NotifyInvalidating()
2055 : : {
2056 : : DBG_CHKTHIS(SvTreeListBox,0);
2057 : 390 : }
2058 : :
2059 : 248 : void SvTreeListBox::Invalidate( sal_uInt16 nInvalidateFlags )
2060 : : {
2061 : : DBG_CHKTHIS(SvTreeListBox,0);
2062 [ + - ]: 248 : if( nFocusWidth == -1 )
2063 : : // to make sure that the control doesn't show the wrong focus rectangle
2064 : : // after painting
2065 : 248 : pImp->RecalcFocusRect();
2066 : 248 : NotifyInvalidating();
2067 : 248 : SvLBox::Invalidate( nInvalidateFlags );
2068 : 248 : pImp->Invalidate();
2069 : 248 : }
2070 : :
2071 : 142 : void SvTreeListBox::Invalidate( const Rectangle& rRect, sal_uInt16 nInvalidateFlags )
2072 : : {
2073 : : DBG_CHKTHIS(SvTreeListBox,0);
2074 [ + - ]: 142 : if( nFocusWidth == -1 )
2075 : : // to make sure that the control doesn't show the wrong focus rectangle
2076 : : // after painting
2077 : 142 : pImp->RecalcFocusRect();
2078 : 142 : NotifyInvalidating();
2079 : 142 : SvLBox::Invalidate( rRect, nInvalidateFlags );
2080 : 142 : }
2081 : :
2082 : :
2083 : 0 : void SvTreeListBox::SetHighlightRange( sal_uInt16 nStart, sal_uInt16 nEnd)
2084 : : {
2085 : : DBG_CHKTHIS(SvTreeListBox,0);
2086 : :
2087 : : sal_uInt16 nTemp;
2088 : 0 : nTreeFlags |= TREEFLAG_USESEL;
2089 [ # # ]: 0 : if( nStart > nEnd )
2090 : : {
2091 : 0 : nTemp = nStart;
2092 : 0 : nStart = nEnd;
2093 : 0 : nEnd = nTemp;
2094 : : }
2095 : : // select all tabs that lie within the area
2096 : 0 : nTreeFlags |= TREEFLAG_RECALCTABS;
2097 : 0 : nFirstSelTab = nStart;
2098 : 0 : nLastSelTab = nEnd;
2099 : 0 : pImp->RecalcFocusRect();
2100 : 0 : }
2101 : :
2102 : 0 : sal_uLong SvTreeListBox::GetAscInsertionPos(SvLBoxEntry*,SvLBoxEntry*)
2103 : : {
2104 : 0 : return LIST_APPEND;
2105 : : }
2106 : :
2107 : 0 : sal_uLong SvTreeListBox::GetDescInsertionPos(SvLBoxEntry*,SvLBoxEntry*)
2108 : : {
2109 : : DBG_CHKTHIS(SvTreeListBox,0);
2110 : 0 : return LIST_APPEND;
2111 : : }
2112 : :
2113 : 0 : Region SvTreeListBox::GetDragRegion() const
2114 : : {
2115 : : DBG_CHKTHIS(SvTreeListBox,0);
2116 [ # # ]: 0 : Rectangle aRect;
2117 [ # # ]: 0 : SvLBoxEntry* pEntry = GetCurEntry();
2118 [ # # ]: 0 : if( pEntry )
2119 : : {
2120 [ # # ]: 0 : Point aPos = GetEntryPosition( pEntry );
2121 [ # # ]: 0 : aRect = ((SvTreeListBox*)this)->GetFocusRect( pEntry, aPos.Y() );
2122 : : }
2123 [ # # ]: 0 : Region aRegion( aRect );
2124 : 0 : return aRegion;
2125 : : }
2126 : :
2127 : :
2128 : 0 : void SvTreeListBox::Command( const CommandEvent& rCEvt )
2129 : : {
2130 : : DBG_CHKTHIS(SvTreeListBox,0);
2131 : : // FIXME gnumake2 resync to DEV300_m84
2132 : 0 : pImp->Command( rCEvt );
2133 : 0 : }
2134 : :
2135 : :
2136 : 0 : void SvTreeListBox::RemoveParentKeepChildren( SvLBoxEntry* pParent )
2137 : : {
2138 : : DBG_CHKTHIS(SvTreeListBox,0);
2139 : : DBG_ASSERT(pParent,"RemoveParentKeepChildren:No Parent");
2140 : 0 : SvLBoxEntry* pNewParent = GetParent( pParent );
2141 [ # # ]: 0 : if( pParent->HasChildren())
2142 : : {
2143 : 0 : SvLBoxEntry* pChild = FirstChild( pParent );
2144 [ # # ]: 0 : while( pChild )
2145 : : {
2146 : 0 : pModel->Move( pChild, pNewParent, LIST_APPEND );
2147 : 0 : pChild = FirstChild( pParent );
2148 : : }
2149 : : }
2150 : 0 : pModel->Remove( pParent );
2151 : 0 : }
2152 : :
2153 : 126 : SvLBoxTab* SvTreeListBox::GetFirstTab( sal_uInt16 nFlagMask, sal_uInt16& rPos )
2154 : : {
2155 : 126 : sal_uInt16 nTabCount = aTabs.size();
2156 [ + - ]: 252 : for( sal_uInt16 nPos = 0; nPos < nTabCount; nPos++ )
2157 : : {
2158 : 252 : SvLBoxTab* pTab = aTabs[ nPos ];
2159 [ + + ]: 252 : if( (pTab->nFlags & nFlagMask) )
2160 : : {
2161 : 126 : rPos = nPos;
2162 : 126 : return pTab;
2163 : : }
2164 : : }
2165 : 0 : rPos = 0xffff;
2166 : 126 : return 0;
2167 : : }
2168 : :
2169 : 0 : SvLBoxTab* SvTreeListBox::GetLastTab( sal_uInt16 nFlagMask, sal_uInt16& rTabPos )
2170 : : {
2171 : 0 : sal_uInt16 nPos = (sal_uInt16)aTabs.size();
2172 [ # # ]: 0 : while( nPos )
2173 : : {
2174 : 0 : --nPos;
2175 : 0 : SvLBoxTab* pTab = aTabs[ nPos ];
2176 [ # # ]: 0 : if( (pTab->nFlags & nFlagMask) )
2177 : : {
2178 : 0 : rTabPos = nPos;
2179 : 0 : return pTab;
2180 : : }
2181 : : }
2182 : 0 : rTabPos = 0xffff;
2183 : 0 : return 0;
2184 : : }
2185 : :
2186 : 0 : void SvTreeListBox::RequestHelp( const HelpEvent& rHEvt )
2187 : : {
2188 [ # # ]: 0 : if( !pImp->RequestHelp( rHEvt ) )
2189 : 0 : SvLBox::RequestHelp( rHEvt );
2190 : 0 : }
2191 : :
2192 : 0 : void SvTreeListBox::CursorMoved( SvLBoxEntry* )
2193 : : {
2194 : 0 : }
2195 : :
2196 : 8232 : IMPL_LINK( SvTreeListBox, DefaultCompare, SvSortData*, pData )
2197 : : {
2198 : 8232 : SvLBoxEntry* pLeft = (SvLBoxEntry*)(pData->pLeft );
2199 : 8232 : SvLBoxEntry* pRight = (SvLBoxEntry*)(pData->pRight );
2200 [ + - ][ + - ]: 8232 : String aLeft( ((SvLBoxString*)(pLeft->GetFirstItem(SV_ITEM_ID_LBOXSTRING)))->GetText());
2201 [ + - ][ + - ]: 8232 : String aRight( ((SvLBoxString*)(pRight->GetFirstItem(SV_ITEM_ID_LBOXSTRING)))->GetText());
2202 [ + - ]: 8232 : pImp->UpdateStringSorter();
2203 [ + - ][ + - ]: 8232 : return pImp->m_pStringSorter->compare(aLeft, aRight);
[ + - ][ + - ]
[ + - ]
2204 : : }
2205 : :
2206 : 2660 : void SvTreeListBox::ModelNotification( sal_uInt16 nActionId, SvListEntry* pEntry1,
2207 : : SvListEntry* pEntry2, sal_uLong nPos )
2208 : : {
2209 [ + + ]: 2660 : if( nActionId == LISTACTION_CLEARING )
2210 : 124 : CancelTextEditing();
2211 : :
2212 : 2660 : SvLBox::ModelNotification( nActionId, pEntry1, pEntry2, nPos );
2213 [ + - - + : 2660 : switch( nActionId )
+ ]
2214 : : {
2215 : : case LISTACTION_INSERTED:
2216 : : {
2217 [ - + ]: 2398 : SvLBoxEntry* pEntry( dynamic_cast< SvLBoxEntry* >( pEntry1 ) );
2218 [ - + ]: 2398 : if ( !pEntry )
2219 : : {
2220 : : SAL_WARN( "svtools.contnr", "SvTreeListBox::ModelNotification: invalid entry!" );
2221 : 0 : break;
2222 : : }
2223 : :
2224 : 2398 : SvLBoxContextBmp* pBmpItem = static_cast< SvLBoxContextBmp* >( pEntry->GetFirstItem( SV_ITEM_ID_LBOXCONTEXTBMP ) );
2225 [ - + ]: 2398 : if ( !pBmpItem )
2226 : 0 : break;
2227 : 2398 : const Image& rBitmap1( pBmpItem->GetBitmap1() );
2228 : 2398 : const Image& rBitmap2( pBmpItem->GetBitmap2() );
2229 [ + - ]: 2398 : short nMaxWidth = short( Max( rBitmap1.GetSizePixel().Width(), rBitmap2.GetSizePixel().Width() ) );
2230 : 2398 : nMaxWidth = pImp->UpdateContextBmpWidthVector( pEntry, nMaxWidth );
2231 [ - + ]: 2398 : if( nMaxWidth > nContextBmpWidthMax )
2232 : : {
2233 : 0 : nContextBmpWidthMax = nMaxWidth;
2234 : 0 : SetTabs();
2235 : : }
2236 : : }
2237 : 2398 : break;
2238 : :
2239 : : case LISTACTION_RESORTING:
2240 : 0 : SetUpdateMode( sal_False );
2241 : 0 : break;
2242 : :
2243 : : case LISTACTION_RESORTED:
2244 : : // after a selection: show first entry and also keep the selection
2245 : 0 : MakeVisible( (SvLBoxEntry*)pModel->First(), sal_True );
2246 : 0 : SetUpdateMode( sal_True );
2247 : 0 : break;
2248 : :
2249 : : case LISTACTION_CLEARED:
2250 [ + - ]: 124 : if( IsUpdateMode() )
2251 : 124 : Update();
2252 : 124 : break;
2253 : : }
2254 : 2660 : }
2255 : :
2256 : 0 : void SvTreeListBox::EndSelection()
2257 : : {
2258 : 0 : pImp->EndSelection();
2259 : 0 : }
2260 : :
2261 : 0 : void SvTreeListBox::RepaintScrollBars() const
2262 : : {
2263 : 0 : ((SvTreeListBox*)this)->pImp->RepaintScrollBars();
2264 : 0 : }
2265 : :
2266 : 0 : ScrollBar *SvTreeListBox::GetVScroll()
2267 : : {
2268 : 0 : return &((SvTreeListBox*)this)->pImp->aVerSBar;
2269 : : }
2270 : :
2271 : 0 : ScrollBar *SvTreeListBox::GetHScroll()
2272 : : {
2273 : 0 : return &((SvTreeListBox*)this)->pImp->aHorSBar;
2274 : : }
2275 : :
2276 : 0 : void SvTreeListBox::EnableAsyncDrag( sal_Bool b )
2277 : : {
2278 : 0 : pImp->EnableAsyncDrag( b );
2279 : 0 : }
2280 : :
2281 : 0 : SvLBoxEntry* SvTreeListBox::GetFirstEntryInView() const
2282 : : {
2283 : 0 : Point aPos;
2284 [ # # ]: 0 : return GetEntry( aPos );
2285 : : }
2286 : :
2287 : 0 : SvLBoxEntry* SvTreeListBox::GetNextEntryInView(SvLBoxEntry* pEntry ) const
2288 : : {
2289 : 0 : SvLBoxEntry* pNext = (SvLBoxEntry*)NextVisible( pEntry );
2290 [ # # ]: 0 : if( pNext )
2291 : : {
2292 [ # # ]: 0 : Point aPos( GetEntryPosition(pNext) );
2293 : 0 : const Size& rSize = pImp->GetOutputSize();
2294 [ # # ][ # # ]: 0 : if( aPos.Y() < 0 || aPos.Y() >= rSize.Height() )
[ # # ]
2295 : 0 : return 0;
2296 : : }
2297 : 0 : return pNext;
2298 : : }
2299 : :
2300 : 0 : SvLBoxEntry* SvTreeListBox::GetLastEntryInView() const
2301 : : {
2302 : 0 : SvLBoxEntry* pEntry = GetFirstEntryInView();
2303 : 0 : SvLBoxEntry* pNext = 0;
2304 [ # # ]: 0 : while( pEntry )
2305 : : {
2306 : 0 : pNext = (SvLBoxEntry*)NextVisible( pEntry );
2307 [ # # ]: 0 : if( pNext )
2308 : : {
2309 [ # # ]: 0 : Point aPos( GetEntryPosition(pNext) );
2310 : 0 : const Size& rSize = pImp->GetOutputSize();
2311 [ # # ][ # # ]: 0 : if( aPos.Y() < 0 || aPos.Y() + GetEntryHeight() >= rSize.Height() )
[ # # ]
2312 : : break;
2313 : : else
2314 : 0 : pEntry = pNext;
2315 : : }
2316 : : else
2317 : 0 : break;
2318 : : }
2319 : 0 : return pEntry;
2320 : : }
2321 : :
2322 : 0 : void SvTreeListBox::ShowFocusRect( const SvLBoxEntry* pEntry )
2323 : : {
2324 : 0 : pImp->ShowFocusRect( pEntry );
2325 : 0 : }
2326 : :
2327 : 0 : void SvTreeListBox::DataChanged( const DataChangedEvent& rDCEvt )
2328 : : {
2329 [ # # ][ # # ]: 0 : if( (rDCEvt.GetType()==DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
[ # # ]
2330 : : {
2331 : 0 : nEntryHeight = 0; // _together_ with sal_True of 1. par (bFont) of InitSettings() a zero-height
2332 : : // forces complete recalc of heights!
2333 : 0 : InitSettings( sal_True, sal_True, sal_True );
2334 : 0 : Invalidate();
2335 : : }
2336 : : else
2337 : 0 : Control::DataChanged( rDCEvt );
2338 : 0 : }
2339 : :
2340 : 360 : void SvTreeListBox::StateChanged( StateChangedType i_nStateChange )
2341 : : {
2342 : 360 : SvLBox::StateChanged( i_nStateChange );
2343 [ + + ]: 360 : if ( i_nStateChange == STATE_CHANGE_STYLE )
2344 : 120 : ImplInitStyle();
2345 : 360 : }
2346 : :
2347 : 122 : void SvTreeListBox::InitSettings(sal_Bool bFont,sal_Bool bForeground,sal_Bool bBackground)
2348 : : {
2349 : 122 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
2350 [ + - ]: 122 : if( bFont )
2351 : : {
2352 [ + - ]: 122 : Font aFont;
2353 [ + - ]: 122 : aFont = rStyleSettings.GetFieldFont();
2354 [ + - ]: 122 : aFont.SetColor( rStyleSettings.GetWindowTextColor() );
2355 [ + - ]: 122 : SetPointFont( aFont );
2356 [ + - ]: 122 : AdjustEntryHeight( aFont );
2357 [ + - ][ + - ]: 122 : RecalcViewData();
2358 : : }
2359 : :
2360 [ - + ][ # # ]: 122 : if( bForeground || bFont )
2361 : : {
2362 : 122 : SetTextColor( rStyleSettings.GetFieldTextColor() );
2363 : 122 : SetTextFillColor();
2364 : : }
2365 : :
2366 [ + - ]: 122 : if( bBackground )
2367 [ + - ]: 122 : SetBackground( rStyleSettings.GetFieldColor() );
2368 : :
2369 : : // always try to re-create default-SvLBoxButtonData
2370 [ - + ][ # # ]: 122 : if( pCheckButtonData && pCheckButtonData->HasDefaultImages() )
[ - + ]
2371 : 0 : pCheckButtonData->SetDefaultImages( this );
2372 : 122 : }
2373 : :
2374 : 0 : sal_Bool SvTreeListBox::IsCellFocusEnabled() const
2375 : : {
2376 : 0 : return pImp->IsCellFocusEnabled();
2377 : : }
2378 : :
2379 : 0 : bool SvTreeListBox::SetCurrentTabPos( sal_uInt16 _nNewPos )
2380 : : {
2381 : 0 : return pImp->SetCurrentTabPos( _nNewPos );
2382 : : }
2383 : :
2384 : 0 : sal_uInt16 SvTreeListBox::GetCurrentTabPos() const
2385 : : {
2386 : 0 : return pImp->GetCurrentTabPos();
2387 : : }
2388 : :
2389 : 0 : void SvTreeListBox::InitStartEntry()
2390 : : {
2391 [ # # ]: 0 : if( !pImp->pStartEntry )
2392 : 0 : pImp->pStartEntry = GetModel()->First();
2393 : 0 : }
2394 : :
2395 : 0 : PopupMenu* SvTreeListBox::CreateContextMenu( void )
2396 : : {
2397 : 0 : return NULL;
2398 : : }
2399 : :
2400 : 0 : void SvTreeListBox::ExcecuteContextMenuAction( sal_uInt16 )
2401 : : {
2402 : : DBG_WARNING( "SvTreeListBox::ExcecuteContextMenuAction(): now there's happening nothing!" );
2403 : 0 : }
2404 : :
2405 : 122 : void SvTreeListBox::EnableContextMenuHandling( void )
2406 : : {
2407 : : DBG_ASSERT( pImp, "-SvTreeListBox::EnableContextMenuHandling(): No implementation!" );
2408 : :
2409 : 122 : pImp->bContextMenuHandling = sal_True;
2410 : 122 : }
2411 : :
2412 : 0 : void SvTreeListBox::EnableContextMenuHandling( sal_Bool b )
2413 : : {
2414 : : DBG_ASSERT( pImp, "-SvTreeListBox::EnableContextMenuHandling(): No implementation!" );
2415 : :
2416 : 0 : pImp->bContextMenuHandling = b;
2417 : 0 : }
2418 : :
2419 : 0 : sal_Bool SvTreeListBox::IsContextMenuHandlingEnabled( void ) const
2420 : : {
2421 : : DBG_ASSERT( pImp, "-SvTreeListBox::IsContextMenuHandlingEnabled(): No implementation!" );
2422 : :
2423 : 0 : return pImp->bContextMenuHandling;
2424 : : }
2425 : :
2426 : 0 : void SvTreeListBox::EnableList( bool _bEnable )
2427 : : {
2428 : : // call base class method
2429 : 0 : Window::Enable( _bEnable != false );
2430 : : // then paint immediately
2431 [ # # ][ # # ]: 0 : Paint( Rectangle( Point(), GetSizePixel() ) );
2432 : 0 : }
2433 : :
2434 : 6 : ::com::sun::star::uno::Reference< XAccessible > SvTreeListBox::CreateAccessible()
2435 : : {
2436 : 6 : Window* pParent = GetAccessibleParentWindow();
2437 : : DBG_ASSERT( pParent, "SvTreeListBox::CreateAccessible - accessible parent not found" );
2438 : :
2439 : 6 : ::com::sun::star::uno::Reference< XAccessible > xAccessible;
2440 [ + - ]: 6 : if ( pParent )
2441 : : {
2442 [ + - ]: 6 : ::com::sun::star::uno::Reference< XAccessible > xAccParent = pParent->GetAccessible();
2443 [ + - ]: 6 : if ( xAccParent.is() )
2444 : : {
2445 : : // need to be done here to get the vclxwindow later on in the accessbile
2446 [ + - ]: 6 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xTemp(GetComponentInterface());
2447 [ + - ][ + - ]: 6 : xAccessible = pImp->m_aFactoryAccess.getFactory().createAccessibleTreeListBox( *this, xAccParent );
[ + - ]
2448 : 6 : }
2449 : : }
2450 : 6 : return xAccessible;
2451 : : }
2452 : :
2453 : 120 : void SvTreeListBox::FillAccessibleEntryStateSet( SvLBoxEntry* pEntry, ::utl::AccessibleStateSetHelper& rStateSet ) const
2454 : : {
2455 : : DBG_ASSERT( pEntry, "SvTreeListBox::FillAccessibleEntryStateSet: invalid entry" );
2456 : :
2457 [ + - ][ - + ]: 120 : if ( pEntry->HasChildrenOnDemand() || pEntry->HasChildren() )
[ - + ]
2458 : : {
2459 : 0 : rStateSet.AddState( AccessibleStateType::EXPANDABLE );
2460 [ # # ]: 0 : if ( IsExpanded( pEntry ) )
2461 : 0 : rStateSet.AddState( (sal_Int16)AccessibleStateType::EXPANDED );
2462 : : }
2463 : :
2464 [ - + ]: 120 : if ( GetCheckButtonState( pEntry ) == SV_BUTTON_CHECKED )
2465 : 0 : rStateSet.AddState( AccessibleStateType::CHECKED );
2466 [ + - ]: 120 : if ( IsEntryVisible( pEntry ) )
2467 : 120 : rStateSet.AddState( AccessibleStateType::VISIBLE );
2468 [ + + ]: 120 : if ( IsSelected( pEntry ) )
2469 : 6 : rStateSet.AddState( AccessibleStateType::SELECTED );
2470 : 120 : }
2471 : :
2472 : 120 : Rectangle SvTreeListBox::GetBoundingRect( SvLBoxEntry* pEntry )
2473 : : {
2474 [ + - ]: 120 : Point aPos = GetEntryPosition( pEntry );
2475 [ + - ]: 120 : Rectangle aRect = GetFocusRect( pEntry, aPos.Y() );
2476 : 120 : return aRect;
2477 : : }
2478 : :
2479 : 0 : void SvTreeListBox::EnableCellFocus()
2480 : : {
2481 : 0 : pImp->EnableCellFocus();
2482 : 0 : }
2483 : :
2484 : 250 : void SvTreeListBox::CallImplEventListeners(sal_uLong nEvent, void* pData)
2485 : : {
2486 : 250 : CallEventListeners(nEvent, pData);
2487 : 250 : }
2488 : :
2489 : 0 : void SvTreeListBox::FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& rStateSet ) const
2490 : : {
2491 : 0 : SvLBox::FillAccessibleStateSet( rStateSet );
2492 : 0 : }
2493 : :
2494 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|