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 <svtools/brwbox.hxx>
30 : : #include <svtools/brwhead.hxx>
31 : : #include "datwin.hxx"
32 : : #include <tools/debug.hxx>
33 : : #include <tools/stream.hxx>
34 : :
35 : : #include <functional>
36 : : #include <algorithm>
37 : : #include <com/sun/star/accessibility/AccessibleTableModelChange.hpp>
38 : : #include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp>
39 : : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
40 : : #include <com/sun/star/accessibility/XAccessible.hpp>
41 : : #include <tools/multisel.hxx>
42 : : #include "brwimpl.hxx"
43 : :
44 : : DBG_NAME(BrowseBox)
45 : :
46 : : extern const char* BrowseBoxCheckInvariants( const void* pVoid );
47 : :
48 : : #define SCROLL_FLAGS (SCROLL_CLIP | SCROLL_NOCHILDREN)
49 : : #define getDataWindow() ((BrowserDataWin*)pDataWin)
50 : :
51 : : using namespace com::sun::star::accessibility::AccessibleEventId;
52 : : using namespace com::sun::star::accessibility::AccessibleTableModelChangeType;
53 : : using com::sun::star::accessibility::AccessibleTableModelChange;
54 : : using com::sun::star::lang::XComponent;
55 : : using namespace ::com::sun::star::uno;
56 : : using namespace svt;
57 : :
58 : : //-------------------------------------------------------------------
59 : :
60 : : namespace
61 : : {
62 : 0 : void disposeAndClearHeaderCell(::svt::BrowseBoxImpl::THeaderCellMap& _rHeaderCell)
63 : : {
64 : : ::std::for_each(
65 : : _rHeaderCell.begin(),
66 : : _rHeaderCell.end(),
67 : : ::svt::BrowseBoxImpl::THeaderCellMapFunctorDispose()
68 [ # # ]: 0 : );
69 : 0 : _rHeaderCell.clear();
70 : 0 : }
71 : : }
72 : :
73 : : //===================================================================
74 : :
75 : 40 : void BrowseBox::ConstructImpl( BrowserMode nMode )
76 : : {
77 : : OSL_TRACE( "BrowseBox: %p->ConstructImpl", this );
78 : 40 : bMultiSelection = sal_False;
79 : 40 : pColSel = 0;
80 : 40 : pDataWin = 0;
81 : 40 : pVScroll = 0;
82 : :
83 [ + - ]: 40 : pDataWin = new BrowserDataWin( this );
84 [ + - ]: 40 : pCols = new BrowserColumns;
85 [ + - ]: 40 : m_pImpl.reset( new ::svt::BrowseBoxImpl() );
86 : :
87 : 40 : aGridLineColor = Color( COL_LIGHTGRAY );
88 : 40 : InitSettings_Impl( this );
89 : 40 : InitSettings_Impl( pDataWin );
90 : :
91 : 40 : bBootstrapped = sal_False;
92 : 40 : nDataRowHeight = 0;
93 : 40 : nTitleLines = 1;
94 : 40 : nFirstCol = 0;
95 : 40 : nTopRow = 0;
96 : 40 : nCurRow = BROWSER_ENDOFSELECTION;
97 : 40 : nCurColId = 0;
98 : 40 : bResizing = sal_False;
99 : 40 : bSelect = sal_False;
100 : 40 : bSelecting = sal_False;
101 : 40 : bScrolling = sal_False;
102 : 40 : bSelectionIsVisible = sal_False;
103 : 40 : bNotToggleSel = sal_False;
104 : 40 : bRowDividerDrag = sal_False;
105 : 40 : bHit = sal_False;
106 : 40 : mbInteractiveRowHeight = sal_False;
107 : 40 : bHideSelect = sal_False;
108 : 40 : bHideCursor = NO_CURSOR_HIDE;
109 : 40 : nRowCount = 0;
110 : 40 : m_bFocusOnlyCursor = sal_True;
111 : 40 : m_aCursorColor = COL_TRANSPARENT;
112 : 40 : m_nCurrentMode = 0;
113 : 40 : nControlAreaWidth = USHRT_MAX;
114 : 40 : uRow.nSel = BROWSER_ENDOFSELECTION;
115 : :
116 : 40 : aHScroll.SetLineSize(1);
117 : 40 : aHScroll.SetScrollHdl( LINK( this, BrowseBox, ScrollHdl ) );
118 : 40 : aHScroll.SetEndScrollHdl( LINK( this, BrowseBox, EndScrollHdl ) );
119 : 40 : pDataWin->Show();
120 : :
121 : 40 : SetMode( nMode );
122 : 40 : bSelectionIsVisible = bKeepHighlight;
123 : 40 : bHasFocus = HasChildPathFocus();
124 : : getDataWindow()->nCursorHidden =
125 : 40 : ( bHasFocus ? 0 : 1 ) + ( GetUpdateMode() ? 0 : 1 );
126 : 40 : }
127 : :
128 : : //-------------------------------------------------------------------
129 : :
130 : 40 : BrowseBox::BrowseBox( Window* pParent, WinBits nBits, BrowserMode nMode )
131 : : :Control( pParent, nBits | WB_3DLOOK )
132 : : ,DragSourceHelper( this )
133 : : ,DropTargetHelper( this )
134 [ + - ][ + - ]: 40 : ,aHScroll( this, WinBits( WB_HSCROLL ) )
[ + - ]
135 : : {
136 : : DBG_CTOR( BrowseBox, NULL );
137 [ + - ]: 40 : ConstructImpl( nMode );
138 : 40 : }
139 : :
140 : : //-------------------------------------------------------------------
141 : :
142 : 0 : BrowseBox::BrowseBox( Window* pParent, const ResId& rId, BrowserMode nMode )
143 : : :Control( pParent, rId )
144 : : ,DragSourceHelper( this )
145 : : ,DropTargetHelper( this )
146 [ # # ][ # # ]: 0 : ,aHScroll( this, WinBits(WB_HSCROLL) )
[ # # ]
147 : : {
148 : : DBG_CTOR( BrowseBox, NULL );
149 [ # # ]: 0 : ConstructImpl(nMode);
150 : 0 : }
151 : : //-------------------------------------------------------------------
152 : :
153 [ + - ][ + - ]: 40 : BrowseBox::~BrowseBox()
[ + - ][ + - ]
154 : : {
155 : : DBG_DTOR(BrowseBox,BrowseBoxCheckInvariants);
156 : : OSL_TRACE( "BrowseBox: %p~", this );
157 : :
158 [ - + ]: 40 : if ( m_pImpl->m_pAccessible )
159 : : {
160 [ # # ]: 0 : disposeAndClearHeaderCell(m_pImpl->m_aColHeaderCellMap);
161 [ # # ]: 0 : disposeAndClearHeaderCell(m_pImpl->m_aRowHeaderCellMap);
162 [ # # ]: 0 : m_pImpl->m_pAccessible->dispose();
163 : : }
164 : :
165 [ + - ]: 40 : Hide();
166 [ + - ][ + - ]: 40 : delete getDataWindow()->pHeaderBar;
167 [ + + ][ + - ]: 40 : delete getDataWindow()->pCornerWin;
168 [ + - ][ + - ]: 40 : delete pDataWin;
169 [ + - ][ + - ]: 40 : delete pVScroll;
170 : :
171 : : // free columns-space
172 [ - + ]: 40 : for ( size_t i = 0, n = pCols->size(); i < n; ++i )
173 [ # # ][ # # ]: 0 : delete (*pCols)[ i ];
174 : 40 : pCols->clear();
175 [ + - ]: 40 : delete pCols;
176 [ + - ][ + - ]: 40 : delete pColSel;
177 [ + - ]: 40 : if ( bMultiSelection )
178 [ + - ][ + - ]: 40 : delete uRow.pSel;
179 [ - + ]: 40 : }
180 : :
181 : : //-------------------------------------------------------------------
182 : :
183 : 264 : short BrowseBox::GetCursorHideCount() const
184 : : {
185 : 264 : return getDataWindow()->nCursorHidden;
186 : : }
187 : :
188 : : //-------------------------------------------------------------------
189 : :
190 : 635 : void BrowseBox::DoShowCursor( const char * )
191 : : {
192 : 635 : short nHiddenCount = --getDataWindow()->nCursorHidden;
193 [ + + ]: 635 : if (PaintCursorIfHiddenOnce())
194 : : {
195 [ + + ]: 180 : if (1 == nHiddenCount)
196 : 132 : DrawCursor();
197 : : }
198 : : else
199 : : {
200 [ - + ]: 455 : if (0 == nHiddenCount)
201 : 0 : DrawCursor();
202 : : }
203 : 635 : }
204 : :
205 : : //-------------------------------------------------------------------
206 : :
207 : 635 : void BrowseBox::DoHideCursor( const char * )
208 : : {
209 : 635 : short nHiddenCount = ++getDataWindow()->nCursorHidden;
210 [ + + ]: 635 : if (PaintCursorIfHiddenOnce())
211 : : {
212 [ + + ]: 180 : if (2 == nHiddenCount)
213 : 132 : DrawCursor();
214 : : }
215 : : else
216 : : {
217 [ - + ]: 455 : if (1 == nHiddenCount)
218 : 0 : DrawCursor();
219 : : }
220 : 635 : }
221 : :
222 : : //-------------------------------------------------------------------
223 : :
224 : 131 : void BrowseBox::SetRealRowCount( const String &rRealRowCount )
225 : : {
226 : 131 : getDataWindow()->aRealRowCount = rRealRowCount;
227 : 131 : }
228 : :
229 : : //-------------------------------------------------------------------
230 : :
231 : 0 : void BrowseBox::SetFont( const Font& rNewFont )
232 : : {
233 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
234 : 0 : pDataWin->SetFont( rNewFont );
235 : 0 : ImpGetDataRowHeight();
236 : 0 : }
237 : :
238 : : //-------------------------------------------------------------------
239 : :
240 : 168 : sal_uLong BrowseBox::GetDefaultColumnWidth( const String& _rText ) const
241 : : {
242 [ + - ][ + - ]: 168 : return GetDataWindow().GetTextWidth( _rText ) + GetDataWindow().GetTextWidth(rtl::OUString('0')) * 4;
[ + - ]
243 : : }
244 : :
245 : : //-------------------------------------------------------------------
246 : :
247 : 66 : void BrowseBox::InsertHandleColumn( sal_uLong nWidth )
248 : : {
249 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
250 : :
251 : : #if OSL_DEBUG_LEVEL > 0
252 : : OSL_ENSURE( ColCount() == 0 || (*pCols)[0]->GetId() != HandleColumnId , "BrowseBox::InsertHandleColumn: there is already a handle column" );
253 : : {
254 : : BrowserColumns::iterator iCol = pCols->begin();
255 : : const BrowserColumns::iterator colsEnd = pCols->end();
256 : : if ( iCol < colsEnd )
257 : : for (++iCol; iCol < colsEnd; ++iCol)
258 : : OSL_ENSURE( (*iCol)->GetId() != HandleColumnId, "BrowseBox::InsertHandleColumn: there is a non-Handle column with handle ID" );
259 : : }
260 : : #endif
261 : :
262 [ + - ][ + - ]: 66 : pCols->insert( pCols->begin(), new BrowserColumn( 0, Image(), String(), nWidth, GetZoom() ) );
[ + - ][ + - ]
[ + - ][ + - ]
263 : 66 : FreezeColumn( 0 );
264 : :
265 : : // adjust headerbar
266 [ + - ]: 66 : if ( getDataWindow()->pHeaderBar )
267 : : {
268 : : getDataWindow()->pHeaderBar->SetPosSizePixel(
269 : : Point(nWidth, 0),
270 : 132 : Size( GetOutputSizePixel().Width() - nWidth, GetTitleHeight() )
271 [ + - ]: 132 : );
272 : : }
273 : :
274 : 66 : ColumnInserted( 0 );
275 : 66 : }
276 : :
277 : : //-------------------------------------------------------------------
278 : :
279 : 138 : void BrowseBox::InsertDataColumn( sal_uInt16 nItemId, const XubString& rText,
280 : : long nWidth, HeaderBarItemBits nBits, sal_uInt16 nPos )
281 : : {
282 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
283 : :
284 : : OSL_ENSURE( nItemId != HandleColumnId, "BrowseBox::InsertDataColumn: nItemId is HandleColumnId" );
285 : : OSL_ENSURE( nItemId != BROWSER_INVALIDID, "BrowseBox::InsertDataColumn: nItemId is reserved value BROWSER_INVALIDID" );
286 : :
287 : : #if OSL_DEBUG_LEVEL > 0
288 : : {
289 : : const BrowserColumns::iterator colsEnd = pCols->end();
290 : : for (BrowserColumns::iterator iCol = pCols->begin(); iCol < colsEnd; ++iCol)
291 : : OSL_ENSURE( (*iCol)->GetId() != nItemId, "BrowseBox::InsertDataColumn: duplicate column Id" );
292 : : }
293 : : #endif
294 : :
295 [ + + ]: 138 : if ( nPos < pCols->size() )
296 : : {
297 : 6 : BrowserColumns::iterator it = pCols->begin();
298 [ + - ]: 6 : ::std::advance( it, nPos );
299 [ + - ][ + - ]: 6 : pCols->insert( it, new BrowserColumn( nItemId, Image(), rText, nWidth, GetZoom() ) );
[ + - ][ + - ]
[ + - ][ + - ]
300 : : }
301 : : else
302 : : {
303 [ + - ][ + - ]: 132 : pCols->push_back( new BrowserColumn( nItemId, Image(), rText, nWidth, GetZoom() ) );
[ + - ][ + - ]
304 : : }
305 [ - + ]: 138 : if ( nCurColId == 0 )
306 : 0 : nCurColId = nItemId;
307 : :
308 [ + - ]: 138 : if ( getDataWindow()->pHeaderBar )
309 : : {
310 : : // Handle column not in the header bar
311 : 138 : sal_uInt16 nHeaderPos = nPos;
312 [ + + ][ + - ]: 138 : if (nHeaderPos != HEADERBAR_APPEND && GetColumnId(0) == HandleColumnId )
[ + + ]
313 : 102 : nHeaderPos--;
314 : : getDataWindow()->pHeaderBar->InsertItem(
315 : 138 : nItemId, rText, nWidth, nBits, nHeaderPos );
316 : : }
317 : 138 : ColumnInserted( nPos );
318 : 138 : }
319 : :
320 : : //-------------------------------------------------------------------
321 : 66 : sal_uInt16 BrowseBox::ToggleSelectedColumn()
322 : : {
323 : 66 : sal_uInt16 nSelectedColId = BROWSER_INVALIDID;
324 [ + - ][ - + ]: 66 : if ( pColSel && pColSel->GetSelectCount() )
[ - + ]
325 : : {
326 : 0 : DoHideCursor( "ToggleSelectedColumn" );
327 : 0 : ToggleSelection();
328 : 0 : nSelectedColId = (*pCols)[ pColSel->FirstSelected() ]->GetId();
329 : 0 : pColSel->SelectAll(sal_False);
330 : : }
331 : 66 : return nSelectedColId;
332 : : }
333 : : // -----------------------------------------------------------------------------
334 : 66 : void BrowseBox::SetToggledSelectedColumn(sal_uInt16 _nSelectedColumnId)
335 : : {
336 [ + - ][ - + ]: 66 : if ( pColSel && _nSelectedColumnId != BROWSER_INVALIDID )
337 : : {
338 : 0 : pColSel->Select( GetColumnPos( _nSelectedColumnId ) );
339 : 0 : ToggleSelection();
340 : : OSL_TRACE( "BrowseBox: %p->SetToggledSelectedColumn", this );
341 : 0 : DoShowCursor( "SetToggledSelectedColumn" );
342 : : }
343 : 66 : }
344 : : // -----------------------------------------------------------------------------
345 : 66 : void BrowseBox::FreezeColumn( sal_uInt16 nItemId, sal_Bool bFreeze )
346 : : {
347 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
348 : :
349 : : // never unfreeze the handle-column
350 [ + - ][ - + ]: 66 : if ( nItemId == HandleColumnId && !bFreeze )
351 : 0 : return;
352 : :
353 : : // get the position in the current array
354 : 66 : size_t nItemPos = GetColumnPos( nItemId );
355 [ - + ]: 66 : if ( nItemPos >= pCols->size() )
356 : : // not available!
357 : 0 : return;
358 : :
359 : : // doesn't the state change?
360 [ - + ]: 66 : if ( (*pCols)[ nItemPos ]->IsFrozen() == bFreeze )
361 : 0 : return;
362 : :
363 : : // remark the column selection
364 : 66 : sal_uInt16 nSelectedColId = ToggleSelectedColumn();
365 : :
366 : : // freeze or unfreeze?
367 [ + - ]: 66 : if ( bFreeze )
368 : : {
369 : : // to be moved?
370 [ - + ][ # # ]: 66 : if ( nItemPos != 0 && !(*pCols)[ nItemPos-1 ]->IsFrozen() )
[ - + ]
371 : : {
372 : : // move to the right of the last frozen column
373 [ # # ]: 0 : sal_uInt16 nFirstScrollable = FrozenColCount();
374 : 0 : BrowserColumn *pColumn = (*pCols)[ nItemPos ];
375 : 0 : BrowserColumns::iterator it = pCols->begin();
376 [ # # ]: 0 : ::std::advance( it, nItemPos );
377 [ # # ]: 0 : pCols->erase( it );
378 : 0 : nItemPos = nFirstScrollable;
379 : 0 : it = pCols->begin();
380 [ # # ]: 0 : ::std::advance( it, nItemPos );
381 [ # # ]: 0 : pCols->insert( it, pColumn );
382 : : }
383 : :
384 : : // adjust the number of the first scrollable and visible column
385 [ + - ]: 66 : if ( nFirstCol <= nItemPos )
386 : 66 : nFirstCol = nItemPos + 1;
387 : : }
388 : : else
389 : : {
390 : : // to be moved?
391 [ # # ]: 0 : if ( (sal_Int32)nItemPos != FrozenColCount()-1 )
392 : : {
393 : : // move to the leftmost scrollable colum
394 [ # # ]: 0 : sal_uInt16 nFirstScrollable = FrozenColCount();
395 : 0 : BrowserColumn *pColumn = (*pCols)[ nItemPos ];
396 : 0 : BrowserColumns::iterator it = pCols->begin();
397 [ # # ]: 0 : ::std::advance( it, nItemPos );
398 [ # # ]: 0 : pCols->erase( it );
399 : 0 : nItemPos = nFirstScrollable;
400 : 0 : it = pCols->begin();
401 [ # # ]: 0 : ::std::advance( it, nItemPos );
402 [ # # ]: 0 : pCols->insert( it, pColumn );
403 : : }
404 : :
405 : : // adjust the number of the first scrollable and visible column
406 : 0 : nFirstCol = nItemPos;
407 : : }
408 : :
409 : : // toggle the freeze-state of the column
410 : 66 : (*pCols)[ nItemPos ]->Freeze( bFreeze );
411 : :
412 : : // align the scrollbar-range
413 : 66 : UpdateScrollbars();
414 : :
415 : : // repaint
416 : 66 : Control::Invalidate();
417 : 66 : getDataWindow()->Invalidate();
418 : :
419 : : // remember the column selection
420 : 66 : SetToggledSelectedColumn(nSelectedColId);
421 : : }
422 : :
423 : : //-------------------------------------------------------------------
424 : :
425 : 0 : void BrowseBox::SetColumnPos( sal_uInt16 nColumnId, sal_uInt16 nPos )
426 : : {
427 : : // never set pos of the handle column
428 [ # # ]: 0 : if ( nColumnId == HandleColumnId )
429 : 0 : return;
430 : :
431 : : // get the position in the current array
432 : 0 : sal_uInt16 nOldPos = GetColumnPos( nColumnId );
433 [ # # ]: 0 : if ( nOldPos >= pCols->size() )
434 : : // not available!
435 : 0 : return;
436 : :
437 : : // does the state change?
438 [ # # ]: 0 : if (nOldPos != nPos)
439 : : {
440 : : // remark the column selection
441 [ # # ]: 0 : sal_uInt16 nSelectedColId = ToggleSelectedColumn();
442 : :
443 : : // determine old column area
444 [ # # ]: 0 : Size aDataWinSize( pDataWin->GetSizePixel() );
445 [ # # ]: 0 : if ( getDataWindow()->pHeaderBar )
446 [ # # ]: 0 : aDataWinSize.Height() += getDataWindow()->pHeaderBar->GetSizePixel().Height();
447 : :
448 [ # # ]: 0 : Rectangle aFromRect( GetFieldRect( nColumnId) );
449 : 0 : aFromRect.Right() += 2*MIN_COLUMNWIDTH;
450 : :
451 : 0 : sal_uInt16 nNextPos = nOldPos + 1;
452 [ # # ]: 0 : if ( nOldPos > nPos )
453 : 0 : nNextPos = nOldPos - 1;
454 : :
455 : 0 : BrowserColumn *pNextCol = (*pCols)[ nNextPos ];
456 [ # # ]: 0 : Rectangle aNextRect(GetFieldRect( pNextCol->GetId() ));
457 : :
458 : : // move column internally
459 : : {
460 : 0 : BrowserColumns::iterator it = pCols->begin();
461 [ # # ]: 0 : ::std::advance( it, nOldPos );
462 : 0 : BrowserColumn* pTemp = *it;
463 [ # # ]: 0 : pCols->erase( it );
464 : 0 : it = pCols->begin();
465 [ # # ]: 0 : ::std::advance( it, nPos );
466 [ # # ]: 0 : pCols->insert( it, pTemp );
467 : : }
468 : :
469 : : // determine new column area
470 [ # # ]: 0 : Rectangle aToRect( GetFieldRect( nColumnId ) );
471 : 0 : aToRect.Right() += 2*MIN_COLUMNWIDTH;
472 : :
473 : : // do scroll, let redraw
474 [ # # ][ # # ]: 0 : if( pDataWin->GetBackground().IsScrollable() )
475 : : {
476 [ # # ]: 0 : long nScroll = -aFromRect.GetWidth();
477 [ # # ]: 0 : Rectangle aScrollArea;
478 [ # # ]: 0 : if ( nOldPos > nPos )
479 : : {
480 [ # # ]: 0 : long nFrozenWidth = GetFrozenWidth();
481 [ # # ]: 0 : if ( aToRect.Left() < nFrozenWidth )
482 : 0 : aToRect.Left() = nFrozenWidth;
483 : 0 : aScrollArea = Rectangle(Point(aToRect.Left(),0),
484 [ # # ]: 0 : Point(aNextRect.Right(),aDataWinSize.Height()));
485 : 0 : nScroll *= -1; // reverse direction
486 : : }
487 : : else
488 : 0 : aScrollArea = Rectangle(Point(aNextRect.Left(),0),
489 [ # # ]: 0 : Point(aToRect.Right(),aDataWinSize.Height()));
490 : :
491 [ # # ]: 0 : pDataWin->Scroll( nScroll, 0, aScrollArea );
492 : 0 : aToRect.Top() = 0;
493 : 0 : aToRect.Bottom() = aScrollArea.Bottom();
494 [ # # ]: 0 : Invalidate( aToRect );
495 : : }
496 : : else
497 [ # # ]: 0 : pDataWin->Window::Invalidate( INVALIDATE_NOCHILDREN );
498 : :
499 : : // adjust header bar positions
500 [ # # ]: 0 : if ( getDataWindow()->pHeaderBar )
501 : : {
502 : 0 : sal_uInt16 nNewPos = nPos;
503 [ # # ][ # # ]: 0 : if ( GetColumnId(0) == HandleColumnId )
504 : 0 : --nNewPos;
505 [ # # ]: 0 : getDataWindow()->pHeaderBar->MoveItem(nColumnId,nNewPos);
506 : : }
507 : : // remember the column selection
508 [ # # ]: 0 : SetToggledSelectedColumn(nSelectedColId);
509 : :
510 [ # # ][ # # ]: 0 : if ( isAccessibleAlive() )
511 : : {
512 : : commitTableEvent(
513 : : TABLE_MODEL_CHANGED,
514 : : makeAny( AccessibleTableModelChange(
515 : : DELETE,
516 : : 0,
517 [ # # ]: 0 : GetRowCount(),
518 : : nOldPos,
519 : : nOldPos
520 : : )
521 : : ),
522 : : Any()
523 [ # # ][ # # ]: 0 : );
524 : :
525 : : commitTableEvent(
526 : : TABLE_MODEL_CHANGED,
527 : : makeAny( AccessibleTableModelChange(
528 : : INSERT,
529 : : 0,
530 [ # # ]: 0 : GetRowCount(),
531 : : nPos,
532 : : nPos
533 : : )
534 : : ),
535 : : Any()
536 [ # # ][ # # ]: 0 : );
537 : : }
538 : : }
539 : :
540 : : }
541 : :
542 : : //-------------------------------------------------------------------
543 : :
544 : 0 : void BrowseBox::SetColumnTitle( sal_uInt16 nItemId, const String& rTitle )
545 : : {
546 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
547 : :
548 : : // never set title of the handle-column
549 [ # # ]: 0 : if ( nItemId == HandleColumnId )
550 : 0 : return;
551 : :
552 : : // get the position in the current array
553 : 0 : sal_uInt16 nItemPos = GetColumnPos( nItemId );
554 [ # # ]: 0 : if ( nItemPos >= pCols->size() )
555 : : // not available!
556 : 0 : return;
557 : :
558 : : // does the state change?
559 : 0 : BrowserColumn *pCol = (*pCols)[ nItemPos ];
560 [ # # ]: 0 : if ( pCol->Title() != rTitle )
561 : : {
562 [ # # ]: 0 : ::rtl::OUString sNew(rTitle);
563 [ # # ]: 0 : ::rtl::OUString sOld(pCol->Title());
564 : :
565 [ # # ]: 0 : pCol->Title() = rTitle;
566 : :
567 : : // adjust headerbar column
568 [ # # ]: 0 : if ( getDataWindow()->pHeaderBar )
569 [ # # ]: 0 : getDataWindow()->pHeaderBar->SetItemText( nItemId, rTitle );
570 : : else
571 : : {
572 : : // redraw visible columns
573 [ # # ][ # # ]: 0 : if ( GetUpdateMode() && ( pCol->IsFrozen() || nItemPos > nFirstCol ) )
[ # # ][ # # ]
[ # # ]
574 : : Invalidate( Rectangle( Point(0,0),
575 [ # # ][ # # ]: 0 : Size( GetOutputSizePixel().Width(), GetTitleHeight() ) ) );
[ # # ]
576 : : }
577 : :
578 [ # # ][ # # ]: 0 : if ( isAccessibleAlive() )
579 : : {
580 : : commitTableEvent( TABLE_COLUMN_DESCRIPTION_CHANGED,
581 : : makeAny( sNew ),
582 : : makeAny( sOld )
583 [ # # ][ # # ]: 0 : );
[ # # ]
584 : 0 : }
585 : : }
586 : : }
587 : :
588 : : //-------------------------------------------------------------------
589 : :
590 : 0 : void BrowseBox::SetColumnWidth( sal_uInt16 nItemId, sal_uLong nWidth )
591 : : {
592 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
593 : :
594 : : // get the position in the current array
595 : 0 : size_t nItemPos = GetColumnPos( nItemId );
596 [ # # ]: 0 : if ( nItemPos >= pCols->size() )
597 : 0 : return;
598 : :
599 : : // does the state change?
600 : 0 : nWidth = QueryColumnResize( nItemId, nWidth );
601 [ # # ][ # # ]: 0 : if ( nWidth >= LONG_MAX || (*pCols)[ nItemPos ]->Width() != nWidth )
[ # # ]
602 : : {
603 : 0 : long nOldWidth = (*pCols)[ nItemPos ]->Width();
604 : :
605 : : // adjust last column, if necessary
606 [ # # ][ # # ]: 0 : if ( IsVisible() && nItemPos == pCols->size() - 1 )
[ # # ]
607 : : {
608 : 0 : long nMaxWidth = pDataWin->GetSizePixel().Width();
609 : : nMaxWidth -= getDataWindow()->bAutoSizeLastCol
610 [ # # ][ # # ]: 0 : ? GetFieldRect(nItemId).Left()
[ # # ]
611 [ # # ][ # # ]: 0 : : GetFrozenWidth();
612 [ # # ][ # # ]: 0 : if ( ( (BrowserDataWin*)pDataWin )->bAutoSizeLastCol || nWidth > (sal_uLong)nMaxWidth )
613 : : {
614 [ # # ]: 0 : nWidth = nMaxWidth > 16 ? nMaxWidth : nOldWidth;
615 : 0 : nWidth = QueryColumnResize( nItemId, nWidth );
616 : : }
617 : : }
618 : :
619 : : // OV
620 : : // In AutoSizeLastColumn(), we call SetColumnWidth with nWidth==0xffff.
621 : : // Thus, check here, if the width has actually changed.
622 [ # # ]: 0 : if( (sal_uLong)nOldWidth == nWidth )
623 : 0 : return;
624 : :
625 : : // do we want to display the change immediately?
626 : 0 : sal_Bool bUpdate = GetUpdateMode() &&
627 [ # # ][ # # ]: 0 : ( (*pCols)[ nItemPos ]->IsFrozen() || nItemPos >= nFirstCol );
[ # # ]
628 : :
629 [ # # ]: 0 : if ( bUpdate )
630 : : {
631 : : // Selection hidden
632 : 0 : DoHideCursor( "SetColumnWidth" );
633 : 0 : ToggleSelection();
634 : : //!getDataWindow()->Update();
635 : : //!Control::Update();
636 : : }
637 : :
638 : : // set width
639 : 0 : (*pCols)[ nItemPos ]->SetWidth(nWidth, GetZoom());
640 : :
641 : : // scroll and invalidate
642 [ # # ]: 0 : if ( bUpdate )
643 : : {
644 : : // get X-Pos of the column changed
645 : 0 : long nX = 0;
646 [ # # ]: 0 : for ( sal_uInt16 nCol = 0; nCol < nItemPos; ++nCol )
647 : : {
648 : 0 : BrowserColumn *pCol = (*pCols)[ nCol ];
649 [ # # ][ # # ]: 0 : if ( pCol->IsFrozen() || nCol >= nFirstCol )
[ # # ]
650 : 0 : nX += pCol->Width();
651 : : }
652 : :
653 : : // actually scroll+invalidate
654 : 0 : pDataWin->SetClipRegion();
655 : 0 : sal_Bool bSelVis = bSelectionIsVisible;
656 : 0 : bSelectionIsVisible = sal_False;
657 [ # # ]: 0 : if( GetBackground().IsScrollable() )
658 : : {
659 : :
660 [ # # ]: 0 : Rectangle aScrRect( nX + std::min( (sal_uLong)nOldWidth, nWidth ), 0,
661 [ # # ]: 0 : GetSizePixel().Width() , // the header is longer than the datawin
662 [ # # ][ # # ]: 0 : pDataWin->GetPosPixel().Y() - 1 );
663 [ # # ]: 0 : Control::Scroll( nWidth-nOldWidth, 0, aScrRect, SCROLL_FLAGS );
664 [ # # ]: 0 : aScrRect.Bottom() = pDataWin->GetSizePixel().Height();
665 [ # # ]: 0 : getDataWindow()->Scroll( nWidth-nOldWidth, 0, aScrRect, SCROLL_FLAGS );
666 [ # # ][ # # ]: 0 : Rectangle aInvRect( nX, 0, nX + std::max( nWidth, (sal_uLong)nOldWidth ), USHRT_MAX );
667 [ # # ]: 0 : Control::Invalidate( aInvRect, INVALIDATE_NOCHILDREN );
668 [ # # ]: 0 : ( (BrowserDataWin*)pDataWin )->Invalidate( aInvRect );
669 : : }
670 : : else
671 : : {
672 : 0 : Control::Invalidate( INVALIDATE_NOCHILDREN );
673 : 0 : getDataWindow()->Window::Invalidate( INVALIDATE_NOCHILDREN );
674 : : }
675 : :
676 : :
677 : : //!getDataWindow()->Update();
678 : : //!Control::Update();
679 : 0 : bSelectionIsVisible = bSelVis;
680 : 0 : ToggleSelection();
681 : 0 : DoShowCursor( "SetColumnWidth" );
682 : : }
683 : 0 : UpdateScrollbars();
684 : :
685 : : // adjust headerbar column
686 [ # # ]: 0 : if ( getDataWindow()->pHeaderBar )
687 : : getDataWindow()->pHeaderBar->SetItemSize(
688 [ # # ]: 0 : nItemId ? nItemId : USHRT_MAX - 1, nWidth );
689 : :
690 : : // adjust last column
691 [ # # ]: 0 : if ( nItemPos != pCols->size() - 1 )
692 : 0 : AutoSizeLastColumn();
693 : :
694 : : }
695 : : }
696 : :
697 : : //-------------------------------------------------------------------
698 : :
699 : 566 : void BrowseBox::AutoSizeLastColumn()
700 : : {
701 [ - + # # ]: 566 : if ( getDataWindow()->bAutoSizeLastCol &&
[ - + ]
702 : 0 : getDataWindow()->GetUpdateMode() )
703 : : {
704 : 0 : sal_uInt16 nId = GetColumnId( (sal_uInt16)pCols->size() - 1 );
705 : 0 : SetColumnWidth( nId, LONG_MAX );
706 : 0 : ColumnResized( nId );
707 : : }
708 : 566 : }
709 : :
710 : : //-------------------------------------------------------------------
711 : :
712 : 44 : void BrowseBox::RemoveColumn( sal_uInt16 nItemId )
713 : : {
714 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
715 : :
716 : : // get column position
717 [ + - ]: 44 : sal_uInt16 nPos = GetColumnPos(nItemId);
718 [ + - ][ + - ]: 44 : if ( nPos >= ColCount() )
719 : : // not available
720 : 44 : return;
721 : :
722 : : // correct column selection
723 [ + - ]: 44 : if ( pColSel )
724 [ + - ]: 44 : pColSel->Remove( nPos );
725 : :
726 : : // correct column cursor
727 [ - + ]: 44 : if ( nCurColId == nItemId )
728 : 0 : nCurColId = 0;
729 : :
730 : : // delete column
731 : 44 : BrowserColumns::iterator it = pCols->begin();
732 [ + - ]: 44 : ::std::advance( it, nPos );
733 [ + - ][ + - ]: 44 : delete *it;
734 [ + - ]: 44 : pCols->erase( it );
735 [ + + ][ + - ]: 44 : if ( nFirstCol >= nPos && nFirstCol > FrozenColCount() )
[ + + ][ + + ]
736 : : {
737 : : OSL_ENSURE(nFirstCol > 0,"FirstCol must be greater zero!");
738 : 24 : --nFirstCol;
739 : : }
740 : :
741 : : // handlecolumn not in headerbar
742 [ + + ]: 44 : if (nItemId)
743 : : {
744 [ + - ]: 20 : if ( getDataWindow()->pHeaderBar )
745 [ + - ]: 20 : getDataWindow()->pHeaderBar->RemoveItem( nItemId );
746 : : }
747 : : else
748 : : {
749 : : // adjust headerbar
750 [ + - ]: 24 : if ( getDataWindow()->pHeaderBar )
751 : : {
752 : : getDataWindow()->pHeaderBar->SetPosSizePixel(
753 : : Point(0, 0),
754 : 48 : Size( GetOutputSizePixel().Width(), GetTitleHeight() )
755 [ + - + - ]: 48 : );
756 : : }
757 : : }
758 : :
759 : : // correct vertical scrollbar
760 [ + - ]: 44 : UpdateScrollbars();
761 : :
762 : : // trigger repaint, if necessary
763 [ + - ][ + - ]: 44 : if ( GetUpdateMode() )
764 : : {
765 [ + - ]: 44 : getDataWindow()->Invalidate();
766 [ + - ]: 44 : Control::Invalidate();
767 [ - + ][ # # ]: 44 : if ( getDataWindow()->bAutoSizeLastCol && nPos ==ColCount() )
[ # # ][ - + ]
768 [ # # ][ # # ]: 0 : SetColumnWidth( GetColumnId( nPos - 1 ), LONG_MAX );
769 : : }
770 : :
771 [ + - ][ - + ]: 44 : if ( isAccessibleAlive() )
772 : : {
773 : : commitTableEvent(
774 : : TABLE_MODEL_CHANGED,
775 : : makeAny( AccessibleTableModelChange( DELETE,
776 : : 0,
777 [ # # ]: 0 : GetRowCount(),
778 : : nPos,
779 : : nPos
780 : : )
781 : : ),
782 : : Any()
783 [ # # ][ # # ]: 0 : );
784 : :
785 : : commitHeaderBarEvent(
786 : : CHILD,
787 : : Any(),
788 : 0 : makeAny( CreateAccessibleColumnHeader( nPos ) ),
789 : : sal_True
790 [ # # ][ # # ]: 44 : );
[ # # ]
791 : : }
792 : : }
793 : :
794 : : //-------------------------------------------------------------------
795 : :
796 : 42 : void BrowseBox::RemoveColumns()
797 : : {
798 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
799 : :
800 : 42 : size_t nOldCount = pCols->size();
801 : :
802 : : // remove all columns
803 [ + + ]: 202 : for ( size_t i = 0; i < nOldCount; ++i )
804 [ + - ]: 160 : delete (*pCols)[ i ];
805 : 42 : pCols->clear();
806 : :
807 : : // correct column selection
808 [ + - ]: 42 : if ( pColSel )
809 : : {
810 : 42 : pColSel->SelectAll(sal_False);
811 [ + - ]: 42 : pColSel->SetTotalRange( Range( 0, 0 ) );
812 : : }
813 : :
814 : : // correct column cursor
815 : 42 : nCurColId = 0;
816 : 42 : nFirstCol = 0;
817 : :
818 [ + - ]: 42 : if ( getDataWindow()->pHeaderBar )
819 : 42 : getDataWindow()->pHeaderBar->Clear( );
820 : :
821 : : // correct vertical scrollbar
822 : 42 : UpdateScrollbars();
823 : :
824 : : // trigger repaint if necessary
825 [ + - ]: 42 : if ( GetUpdateMode() )
826 : : {
827 : 42 : getDataWindow()->Invalidate();
828 : 42 : Control::Invalidate();
829 : : }
830 : :
831 [ - + ]: 42 : if ( isAccessibleAlive() )
832 : : {
833 [ # # ]: 0 : if ( pCols->size() != nOldCount )
834 : : {
835 : : // all columns should be removed, so we remove the column header bar and append it again
836 : : // to avoid to notify every column remove
837 : : commitBrowseBoxEvent(
838 : : CHILD,
839 : : Any(),
840 : : makeAny(m_pImpl->getAccessibleHeaderBar(BBTYPE_COLUMNHEADERBAR))
841 [ # # ][ # # ]: 0 : );
842 : :
843 : : // and now append it again
844 : : commitBrowseBoxEvent(
845 : : CHILD,
846 : : makeAny(m_pImpl->getAccessibleHeaderBar(BBTYPE_COLUMNHEADERBAR)),
847 : : Any()
848 [ # # ][ # # ]: 0 : );
[ # # ]
849 : :
850 : : // notify a table model change
851 : : commitTableEvent(
852 : : TABLE_MODEL_CHANGED,
853 : : makeAny ( AccessibleTableModelChange( DELETE,
854 : : 0,
855 [ # # ]: 0 : GetRowCount(),
856 : : 0,
857 : : nOldCount
858 : : )
859 : : ),
860 : : Any()
861 [ # # ][ # # ]: 0 : );
862 : : }
863 : : }
864 : 42 : }
865 : :
866 : : //-------------------------------------------------------------------
867 : :
868 : 0 : String BrowseBox::GetColumnTitle( sal_uInt16 nId ) const
869 : : {
870 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
871 : :
872 : 0 : sal_uInt16 nItemPos = GetColumnPos( nId );
873 [ # # ]: 0 : if ( nItemPos >= pCols->size() )
874 : 0 : return String();
875 : 0 : return (*pCols)[ nItemPos ]->Title();
876 : : }
877 : :
878 : : //-------------------------------------------------------------------
879 : :
880 : 208 : long BrowseBox::GetRowCount() const
881 : : {
882 : 208 : return nRowCount;
883 : : }
884 : :
885 : : //-------------------------------------------------------------------
886 : :
887 : 57 : sal_uInt16 BrowseBox::ColCount() const
888 : : {
889 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
890 : :
891 : 57 : return (sal_uInt16) pCols->size();
892 : : }
893 : :
894 : : //-------------------------------------------------------------------
895 : :
896 : 132 : long BrowseBox::ImpGetDataRowHeight() const
897 : : {
898 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
899 : :
900 : 132 : BrowseBox *pThis = (BrowseBox*)this;
901 : 132 : pThis->nDataRowHeight = pThis->CalcReverseZoom(pDataWin->GetTextHeight() + 2);
902 : 132 : pThis->Resize();
903 : 132 : getDataWindow()->Invalidate();
904 : 132 : return nDataRowHeight;
905 : : }
906 : :
907 : : //-------------------------------------------------------------------
908 : :
909 : 92 : void BrowseBox::SetDataRowHeight( long nPixel )
910 : : {
911 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
912 : :
913 : 92 : nDataRowHeight = CalcReverseZoom(nPixel);
914 : 92 : Resize();
915 : 92 : getDataWindow()->Invalidate();
916 : 92 : }
917 : :
918 : : //-------------------------------------------------------------------
919 : :
920 : 0 : void BrowseBox::SetTitleLines( sal_uInt16 nLines )
921 : : {
922 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
923 : :
924 : 0 : nTitleLines = nLines;
925 : 0 : }
926 : :
927 : : //-------------------------------------------------------------------
928 : :
929 : 0 : long BrowseBox::ScrollColumns( long nCols )
930 : : {
931 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
932 : :
933 [ # # # # ]: 0 : if ( nFirstCol + nCols < 0 ||
[ # # ]
934 : 0 : nFirstCol + nCols >= (long)pCols->size() )
935 : 0 : return 0;
936 : :
937 : : // implicitly hides cursor while scrolling
938 : 0 : StartScroll();
939 : 0 : bScrolling = sal_True;
940 : 0 : sal_Bool bScrollable = pDataWin->GetBackground().IsScrollable();
941 : 0 : sal_Bool bInvalidateView = sal_False;
942 : :
943 : : // scrolling one column to the right?
944 [ # # ]: 0 : if ( nCols == 1 )
945 : : {
946 : : // update internal value and scrollbar
947 : 0 : ++nFirstCol;
948 : 0 : aHScroll.SetThumbPos( nFirstCol - FrozenColCount() );
949 : :
950 [ # # ]: 0 : if ( !bScrollable )
951 : : {
952 : 0 : bInvalidateView = sal_True;
953 : : }
954 : : else
955 : : {
956 : 0 : long nDelta = (*pCols)[ nFirstCol-1 ]->Width();
957 [ # # ]: 0 : long nFrozenWidth = GetFrozenWidth();
958 : :
959 : : Rectangle aScrollRect( Point( nFrozenWidth + nDelta, 0 ),
960 : 0 : Size ( GetOutputSizePixel().Width() - nFrozenWidth - nDelta,
961 [ # # ]: 0 : GetTitleHeight() - 1
962 [ # # ]: 0 : ) );
963 : :
964 : : // scroll the header bar area (if there is no dedicated HeaderBar control)
965 [ # # ][ # # ]: 0 : if ( !getDataWindow()->pHeaderBar && nTitleLines )
966 : : {
967 : : // actually scroll
968 [ # # ]: 0 : Scroll( -nDelta, 0, aScrollRect, SCROLL_FLAGS );
969 : :
970 : : // invalidate the area of the column which was scrolled out to the left hand side
971 : 0 : Rectangle aInvalidateRect( aScrollRect );
972 : 0 : aInvalidateRect.Left() = nFrozenWidth;
973 : 0 : aInvalidateRect.Right() = nFrozenWidth + nDelta - 1;
974 [ # # ]: 0 : Invalidate( aInvalidateRect );
975 : : }
976 : :
977 : : // scroll the data-area
978 : 0 : aScrollRect.Bottom() = pDataWin->GetOutputSizePixel().Height();
979 : :
980 : : // actually scroll
981 [ # # ]: 0 : pDataWin->Scroll( -nDelta, 0, aScrollRect, SCROLL_FLAGS );
982 : :
983 : : // invalidate the area of the column which was scrolled out to the left hand side
984 : 0 : aScrollRect.Left() = nFrozenWidth;
985 : 0 : aScrollRect.Right() = nFrozenWidth + nDelta - 1;
986 [ # # ]: 0 : getDataWindow()->Invalidate( aScrollRect );
987 : : }
988 : : }
989 : :
990 : : // scrolling one column to the left?
991 [ # # ]: 0 : else if ( nCols == -1 )
992 : : {
993 : 0 : --nFirstCol;
994 : 0 : aHScroll.SetThumbPos( nFirstCol - FrozenColCount() );
995 : :
996 [ # # ]: 0 : if ( !bScrollable )
997 : : {
998 : 0 : bInvalidateView = sal_True;
999 : : }
1000 : : else
1001 : : {
1002 : 0 : long nDelta = (*pCols)[ nFirstCol ]->Width();
1003 [ # # ]: 0 : long nFrozenWidth = GetFrozenWidth();
1004 : :
1005 : : Rectangle aScrollRect( Point( nFrozenWidth, 0 ),
1006 : 0 : Size ( GetOutputSizePixel().Width() - nFrozenWidth,
1007 [ # # ]: 0 : GetTitleHeight() - 1
1008 [ # # ]: 0 : ) );
1009 : :
1010 : : // scroll the header bar area (if there is no dedicated HeaderBar control)
1011 [ # # ][ # # ]: 0 : if ( !getDataWindow()->pHeaderBar && nTitleLines )
1012 : : {
1013 [ # # ]: 0 : Scroll( nDelta, 0, aScrollRect, SCROLL_FLAGS );
1014 : : }
1015 : :
1016 : : // scroll the data-area
1017 : 0 : aScrollRect.Bottom() = pDataWin->GetOutputSizePixel().Height();
1018 [ # # ]: 0 : pDataWin->Scroll( nDelta, 0, aScrollRect, SCROLL_FLAGS );
1019 : : }
1020 : : }
1021 : : else
1022 : : {
1023 [ # # ]: 0 : if ( GetUpdateMode() )
1024 : : {
1025 : : Invalidate( Rectangle(
1026 : : Point( GetFrozenWidth(), 0 ),
1027 [ # # ][ # # ]: 0 : Size( GetOutputSizePixel().Width(), GetTitleHeight() ) ) );
[ # # ]
1028 : : getDataWindow()->Invalidate( Rectangle(
1029 : : Point( GetFrozenWidth(), 0 ),
1030 [ # # ][ # # ]: 0 : pDataWin->GetSizePixel() ) );
[ # # ]
1031 : : }
1032 : :
1033 : 0 : nFirstCol = nFirstCol + (sal_uInt16)nCols;
1034 : 0 : aHScroll.SetThumbPos( nFirstCol - FrozenColCount() );
1035 : : }
1036 : :
1037 : : // adjust external headerbar, if necessary
1038 [ # # ]: 0 : if ( getDataWindow()->pHeaderBar )
1039 : : {
1040 : 0 : long nWidth = 0;
1041 [ # # ][ # # ]: 0 : for ( size_t nCol = 0;
[ # # ]
1042 : 0 : nCol < pCols->size() && nCol < nFirstCol;
1043 : : ++nCol )
1044 : : {
1045 : : // not the handle column
1046 [ # # ]: 0 : if ( (*pCols)[ nCol ]->GetId() )
1047 : 0 : nWidth += (*pCols)[ nCol ]->Width();
1048 : : }
1049 : :
1050 : 0 : getDataWindow()->pHeaderBar->SetOffset( nWidth );
1051 : : }
1052 : :
1053 [ # # ]: 0 : if( bInvalidateView )
1054 : : {
1055 : 0 : Control::Invalidate( INVALIDATE_NOCHILDREN );
1056 : 0 : pDataWin->Window::Invalidate( INVALIDATE_NOCHILDREN );
1057 : : }
1058 : :
1059 : : // implicitly show cursor after scrolling
1060 [ # # ]: 0 : if ( nCols )
1061 : : {
1062 : 0 : getDataWindow()->Update();
1063 : 0 : Update();
1064 : : }
1065 : 0 : bScrolling = sal_False;
1066 : 0 : EndScroll();
1067 : :
1068 : 0 : return nCols;
1069 : : }
1070 : :
1071 : : //-------------------------------------------------------------------
1072 : :
1073 : 514 : long BrowseBox::ScrollRows( long nRows )
1074 : : {
1075 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1076 : :
1077 : : // out of range?
1078 [ - + ][ # # ]: 514 : if ( getDataWindow()->bNoScrollBack && nRows < 0 )
1079 : 0 : return 0;
1080 : :
1081 : : // compute new top row
1082 : 514 : long nTmpMin = Min( (long)(nTopRow + nRows), (long)(nRowCount - 1) );
1083 : :
1084 : 514 : long nNewTopRow = Max( (long)nTmpMin, (long)0 );
1085 : :
1086 [ + - ]: 514 : if ( nNewTopRow == nTopRow )
1087 : 514 : return 0;
1088 : :
1089 : : sal_uInt16 nVisibleRows =
1090 [ # # ]: 0 : (sal_uInt16)(pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight() + 1);
1091 : :
1092 : 0 : VisibleRowsChanged(nNewTopRow, nVisibleRows);
1093 : :
1094 : : // compute new top row again (nTopRow might have changed!)
1095 : 0 : nTmpMin = Min( (long)(nTopRow + nRows), (long)(nRowCount - 1) );
1096 : :
1097 : 0 : nNewTopRow = Max( (long)nTmpMin, (long)0 );
1098 : :
1099 : 0 : StartScroll();
1100 : :
1101 : : // scroll area on screen and/or repaint
1102 : 0 : long nDeltaY = GetDataRowHeight() * ( nNewTopRow - nTopRow );
1103 : 0 : long nOldTopRow = nTopRow;
1104 : 0 : nTopRow = nNewTopRow;
1105 : :
1106 [ # # ]: 0 : if ( GetUpdateMode() )
1107 : : {
1108 [ # # ]: 0 : pVScroll->SetRange( Range( 0L, nRowCount ) );
1109 : 0 : pVScroll->SetThumbPos( nTopRow );
1110 : :
1111 [ # # # # : 0 : if( pDataWin->GetBackground().IsScrollable() &&
# # ][ # # ]
[ # # ]
1112 : 0 : Abs( nDeltaY ) > 0 &&
1113 [ # # ][ # # ]: 0 : Abs( nDeltaY ) < pDataWin->GetSizePixel().Height() )
[ # # ]
1114 : : {
1115 : 0 : pDataWin->Scroll( 0, (short)-nDeltaY, SCROLL_FLAGS );
1116 : : }
1117 : : else
1118 : 0 : getDataWindow()->Invalidate();
1119 : :
1120 [ # # ]: 0 : if ( nTopRow - nOldTopRow )
1121 : 0 : getDataWindow()->Update();
1122 : : }
1123 : :
1124 : 0 : EndScroll();
1125 : :
1126 : 514 : return nTopRow - nOldTopRow;
1127 : : }
1128 : :
1129 : : //-------------------------------------------------------------------
1130 : :
1131 : 72 : void BrowseBox::RowModified( long nRow, sal_uInt16 nColId )
1132 : : {
1133 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1134 : :
1135 [ + - ][ + - ]: 72 : if ( !GetUpdateMode() )
1136 : 72 : return;
1137 : :
1138 [ + - ]: 72 : Rectangle aRect;
1139 [ + + ]: 72 : if ( nColId == BROWSER_INVALIDID )
1140 : : // invalidate the whole row
1141 [ + - ]: 4 : aRect = Rectangle( Point( 0, (nRow-nTopRow) * GetDataRowHeight() ),
1142 [ + - ][ + - ]: 8 : Size( pDataWin->GetSizePixel().Width(), GetDataRowHeight() ) );
[ + - ]
1143 : : else
1144 : : {
1145 : : // invalidate the specific field
1146 [ + - ]: 68 : aRect = GetFieldRectPixel( nRow, nColId, sal_False );
1147 : : }
1148 [ + - ]: 72 : getDataWindow()->Invalidate( aRect );
1149 : : }
1150 : :
1151 : : //-------------------------------------------------------------------
1152 : :
1153 : 4 : void BrowseBox::Clear()
1154 : : {
1155 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1156 : :
1157 : : // adjust the total number of rows
1158 [ + - ]: 4 : DoHideCursor( "Clear" );
1159 : 4 : long nOldRowCount = nRowCount;
1160 : 4 : nRowCount = 0;
1161 : 4 : nCurRow = BROWSER_ENDOFSELECTION;
1162 : 4 : nTopRow = 0;
1163 : 4 : nCurColId = 0;
1164 : :
1165 : : // nFirstCol may not be reset, else the scrolling code will become confused.
1166 : : // nFirstCol may only be changed when adding or deleting columns
1167 : : // nFirstCol = 0; -> wrong!
1168 [ + - ]: 4 : aHScroll.SetThumbPos( 0 );
1169 [ + - ]: 4 : pVScroll->SetThumbPos( 0 );
1170 : :
1171 [ + - ]: 4 : Invalidate();
1172 [ + - ]: 4 : UpdateScrollbars();
1173 [ + - ]: 4 : SetNoSelection();
1174 [ + - ]: 4 : DoShowCursor( "Clear" );
1175 [ + - ]: 4 : CursorMoved();
1176 : :
1177 [ + - ][ - + ]: 4 : if ( isAccessibleAlive() )
1178 : : {
1179 : : // all rows should be removed, so we remove the row header bar and append it again
1180 : : // to avoid to notify every row remove
1181 [ # # ]: 0 : if ( nOldRowCount != nRowCount )
1182 : : {
1183 : : commitBrowseBoxEvent(
1184 : : CHILD,
1185 : : Any(),
1186 : : makeAny( m_pImpl->getAccessibleHeaderBar( BBTYPE_ROWHEADERBAR ) )
1187 [ # # ][ # # ]: 0 : );
[ # # ]
1188 : :
1189 : : // and now append it again
1190 : : commitBrowseBoxEvent(
1191 : : CHILD,
1192 : : makeAny( m_pImpl->getAccessibleHeaderBar( BBTYPE_ROWHEADERBAR ) ),
1193 : : Any()
1194 [ # # ][ # # ]: 0 : );
[ # # ]
1195 : :
1196 : : // notify a table model change
1197 : : commitTableEvent(
1198 : : TABLE_MODEL_CHANGED,
1199 : : makeAny( AccessibleTableModelChange( DELETE,
1200 : : 0,
1201 : : nOldRowCount,
1202 : : 0,
1203 [ # # ]: 0 : GetColumnCount())
1204 : : ),
1205 : : Any()
1206 [ # # ][ # # ]: 0 : );
1207 : : }
1208 : : }
1209 : 4 : }
1210 : : // -----------------------------------------------------------------------------
1211 : 2 : void BrowseBox::RowInserted( long nRow, long nNumRows, sal_Bool bDoPaint, sal_Bool bKeepSelection )
1212 : : {
1213 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1214 : :
1215 [ - + ]: 2 : if (nRow < 0)
1216 : 0 : nRow = 0;
1217 [ - + ]: 2 : else if (nRow > nRowCount) // maximal = nRowCount
1218 : 0 : nRow = nRowCount;
1219 : :
1220 [ + - ]: 2 : if ( nNumRows <= 0 )
1221 : 2 : return;
1222 : :
1223 : : // adjust total row count
1224 : 2 : sal_Bool bLastRow = nRow >= nRowCount;
1225 : 2 : nRowCount += nNumRows;
1226 : :
1227 [ + - ]: 2 : DoHideCursor( "RowInserted" );
1228 : :
1229 : : // must we paint the new rows?
1230 : 2 : long nOldCurRow = nCurRow;
1231 : 2 : Size aSz = pDataWin->GetOutputSizePixel();
1232 [ # # ][ # # ]: 2 : if ( bDoPaint && nRow >= nTopRow &&
[ - + ][ - + ]
1233 [ # # ]: 0 : nRow <= nTopRow + aSz.Height() / GetDataRowHeight() )
1234 : : {
1235 [ # # ]: 0 : long nY = (nRow-nTopRow) * GetDataRowHeight();
1236 [ # # ]: 0 : if ( !bLastRow )
1237 : : {
1238 : : // scroll down the rows behind the new row
1239 [ # # ]: 0 : pDataWin->SetClipRegion();
1240 [ # # ][ # # ]: 0 : if( pDataWin->GetBackground().IsScrollable() )
1241 : : {
1242 [ # # ]: 0 : pDataWin->Scroll( 0, GetDataRowHeight() * nNumRows,
1243 : : Rectangle( Point( 0, nY ),
1244 : 0 : Size( aSz.Width(), aSz.Height() - nY ) ),
1245 [ # # ][ # # ]: 0 : SCROLL_FLAGS );
1246 : : }
1247 : : else
1248 [ # # ]: 0 : pDataWin->Window::Invalidate( INVALIDATE_NOCHILDREN );
1249 : : }
1250 : : else
1251 : : // scroll would cause a repaint, so we must explicitly invalidate
1252 : : pDataWin->Invalidate( Rectangle( Point( 0, nY ),
1253 [ # # ][ # # ]: 0 : Size( aSz.Width(), nNumRows * GetDataRowHeight() ) ) );
[ # # ]
1254 : : }
1255 : :
1256 : : // correct top row if necessary
1257 [ - + ]: 2 : if ( nRow < nTopRow )
1258 : 0 : nTopRow += nNumRows;
1259 : :
1260 : : // adjust the selection
1261 [ + - ]: 2 : if ( bMultiSelection )
1262 [ + - ]: 2 : uRow.pSel->Insert( nRow, nNumRows );
1263 [ # # ][ # # ]: 0 : else if ( uRow.nSel != BROWSER_ENDOFSELECTION && nRow <= uRow.nSel )
1264 : 0 : uRow.nSel += nNumRows;
1265 : :
1266 : : // adjust the cursor
1267 [ + - ]: 2 : if ( nCurRow == BROWSER_ENDOFSELECTION )
1268 [ + - ]: 2 : GoToRow( 0, sal_False, bKeepSelection );
1269 [ # # ]: 0 : else if ( nRow <= nCurRow )
1270 [ # # ]: 0 : GoToRow( nCurRow += nNumRows, sal_False, bKeepSelection );
1271 : :
1272 : : // adjust the vertical scrollbar
1273 [ - + ]: 2 : if ( bDoPaint )
1274 : : {
1275 [ # # ]: 0 : UpdateScrollbars();
1276 [ # # ]: 0 : AutoSizeLastColumn();
1277 : : }
1278 : :
1279 [ + - ]: 2 : DoShowCursor( "RowInserted" );
1280 : : // notify accessible that rows were inserted
1281 [ + - ][ - + ]: 2 : if ( isAccessibleAlive() )
1282 : : {
1283 : : commitTableEvent(
1284 : : TABLE_MODEL_CHANGED,
1285 : : makeAny( AccessibleTableModelChange(
1286 : : INSERT,
1287 : : nRow,
1288 : : nRow + nNumRows,
1289 : : 0,
1290 [ # # ]: 0 : GetColumnCount()
1291 : : )
1292 : : ),
1293 : : Any()
1294 [ # # ][ # # ]: 0 : );
1295 : :
1296 [ # # ]: 0 : for (sal_Int32 i = nRow+1 ; i <= nRowCount ; ++i)
1297 : : {
1298 : : commitHeaderBarEvent(
1299 : : CHILD,
1300 : 0 : makeAny( CreateAccessibleRowHeader( i ) ),
1301 : : Any(),
1302 : : sal_False
1303 [ # # ][ # # ]: 0 : );
[ # # ]
1304 : : }
1305 : : }
1306 : :
1307 [ + - ]: 2 : if ( nCurRow != nOldCurRow )
1308 [ + - ]: 2 : CursorMoved();
1309 : :
1310 : : DBG_ASSERT(nRowCount > 0,"BrowseBox: nRowCount <= 0");
1311 : : DBG_ASSERT(nCurRow >= 0,"BrowseBox: nCurRow < 0");
1312 : : DBG_ASSERT(nCurRow < nRowCount,"nCurRow >= nRowCount");
1313 : : }
1314 : :
1315 : : //-------------------------------------------------------------------
1316 : :
1317 : 0 : void BrowseBox::RowRemoved( long nRow, long nNumRows, sal_Bool bDoPaint )
1318 : : {
1319 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1320 : :
1321 [ # # ]: 0 : if ( nRow < 0 )
1322 : 0 : nRow = 0;
1323 [ # # ]: 0 : else if ( nRow >= nRowCount )
1324 : 0 : nRow = nRowCount - 1;
1325 : :
1326 [ # # ]: 0 : if ( nNumRows <= 0 )
1327 : : return;
1328 : :
1329 [ # # ]: 0 : if ( nRowCount <= 0 )
1330 : : return;
1331 : :
1332 [ # # ]: 0 : if ( bDoPaint )
1333 : : {
1334 : : // hide cursor and selection
1335 : : OSL_TRACE( "BrowseBox: %p->HideCursor", this );
1336 [ # # ]: 0 : ToggleSelection();
1337 [ # # ]: 0 : DoHideCursor( "RowRemoved" );
1338 : : }
1339 : :
1340 : : // adjust total row count
1341 : 0 : nRowCount -= nNumRows;
1342 [ # # ]: 0 : if (nRowCount < 0) nRowCount = 0;
1343 : 0 : long nOldCurRow = nCurRow;
1344 : :
1345 : : // adjust the selection
1346 [ # # ]: 0 : if ( bMultiSelection )
1347 : : // uRow.pSel->Remove( nRow, nNumRows );
1348 [ # # ]: 0 : for ( long i = 0; i < nNumRows; i++ )
1349 [ # # ]: 0 : uRow.pSel->Remove( nRow );
1350 [ # # ][ # # ]: 0 : else if ( nRow < uRow.nSel && uRow.nSel >= nNumRows )
1351 : 0 : uRow.nSel -= nNumRows;
1352 [ # # ]: 0 : else if ( nRow <= uRow.nSel )
1353 : 0 : uRow.nSel = BROWSER_ENDOFSELECTION;
1354 : :
1355 : : // adjust the cursor
1356 [ # # ]: 0 : if ( nRowCount == 0 ) // don't compare nRowCount with nNumRows as nNumRows already was subtracted from nRowCount
1357 : 0 : nCurRow = BROWSER_ENDOFSELECTION;
1358 [ # # ]: 0 : else if ( nRow < nCurRow )
1359 : : {
1360 : 0 : nCurRow -= Min( nCurRow - nRow, nNumRows );
1361 : : // with the above nCurRow points a) to the first row after the removed block or b) to the same line
1362 : : // as before, but moved up nNumRows
1363 : : // case a) needs an additional correction if the last n lines were deleted, as 'the first row after the
1364 : : // removed block' is an invalid position then
1365 : : // FS - 09/28/99 - 68429
1366 [ # # ]: 0 : if (nCurRow == nRowCount)
1367 : 0 : --nCurRow;
1368 : : }
1369 [ # # ][ # # ]: 0 : else if( nRow == nCurRow && nCurRow == nRowCount )
1370 : 0 : nCurRow = nRowCount-1;
1371 : :
1372 : : // is the deleted row visible?
1373 : 0 : Size aSz = pDataWin->GetOutputSizePixel();
1374 [ # # ][ # # ]: 0 : if ( nRow >= nTopRow &&
[ # # ]
1375 [ # # ]: 0 : nRow <= nTopRow + aSz.Height() / GetDataRowHeight() )
1376 : : {
1377 [ # # ]: 0 : if ( bDoPaint )
1378 : : {
1379 : : // scroll up the rows behind the deleted row
1380 : : // if there are Rows behind
1381 [ # # ]: 0 : if (nRow < nRowCount)
1382 : : {
1383 [ # # ]: 0 : long nY = (nRow-nTopRow) * GetDataRowHeight();
1384 [ # # ]: 0 : pDataWin->SetClipRegion();
1385 [ # # ][ # # ]: 0 : if( pDataWin->GetBackground().IsScrollable() )
1386 : : {
1387 [ # # ]: 0 : pDataWin->Scroll( 0, - (short) GetDataRowHeight() * nNumRows,
1388 : 0 : Rectangle( Point( 0, nY ), Size( aSz.Width(),
1389 [ # # ]: 0 : aSz.Height() - nY + nNumRows*GetDataRowHeight() ) ),
1390 [ # # ][ # # ]: 0 : SCROLL_FLAGS );
1391 : : }
1392 : : else
1393 [ # # ]: 0 : pDataWin->Window::Invalidate( INVALIDATE_NOCHILDREN );
1394 : : }
1395 : : else
1396 : : {
1397 : : // Repaint the Rect of the deleted row
1398 : : Rectangle aRect(
1399 [ # # ]: 0 : Point( 0, (nRow-nTopRow)*GetDataRowHeight() ),
1400 [ # # ]: 0 : Size( pDataWin->GetSizePixel().Width(),
1401 [ # # ][ # # ]: 0 : nNumRows * GetDataRowHeight() ) );
1402 [ # # ]: 0 : pDataWin->Invalidate( aRect );
1403 : : }
1404 : : }
1405 : : }
1406 : : // is the deleted row above of the visible area?
1407 [ # # ]: 0 : else if ( nRow < nTopRow )
1408 [ # # ]: 0 : nTopRow = nTopRow >= nNumRows ? nTopRow-nNumRows : 0;
1409 : :
1410 [ # # ]: 0 : if ( bDoPaint )
1411 : : {
1412 : : // reshow cursor and selection
1413 [ # # ]: 0 : ToggleSelection();
1414 : : OSL_TRACE( "BrowseBox: %p->ShowCursor", this );
1415 [ # # ]: 0 : DoShowCursor( "RowRemoved" );
1416 : :
1417 : : // adjust the vertical scrollbar
1418 [ # # ]: 0 : UpdateScrollbars();
1419 [ # # ]: 0 : AutoSizeLastColumn();
1420 : : }
1421 : :
1422 [ # # ][ # # ]: 0 : if ( isAccessibleAlive() )
1423 : : {
1424 [ # # ]: 0 : if ( nRowCount == 0 )
1425 : : {
1426 : : // all columns should be removed, so we remove the column header bar and append it again
1427 : : // to avoid to notify every column remove
1428 : : commitBrowseBoxEvent(
1429 : : CHILD,
1430 : : Any(),
1431 : : makeAny( m_pImpl->getAccessibleHeaderBar( BBTYPE_ROWHEADERBAR ) )
1432 [ # # ][ # # ]: 0 : );
[ # # ]
1433 : :
1434 : : // and now append it again
1435 : : commitBrowseBoxEvent(
1436 : : CHILD,
1437 : : makeAny(m_pImpl->getAccessibleHeaderBar(BBTYPE_ROWHEADERBAR)),
1438 : : Any()
1439 [ # # ][ # # ]: 0 : );
[ # # ]
1440 : : commitBrowseBoxEvent(
1441 : : CHILD,
1442 : : Any(),
1443 : : makeAny( m_pImpl->getAccessibleTable() )
1444 [ # # ][ # # ]: 0 : );
[ # # ]
1445 : :
1446 : : // and now append it again
1447 : : commitBrowseBoxEvent(
1448 : : CHILD,
1449 : : makeAny( m_pImpl->getAccessibleTable() ),
1450 : : Any()
1451 [ # # ][ # # ]: 0 : );
[ # # ]
1452 : : }
1453 : : else
1454 : : {
1455 : : commitTableEvent(
1456 : : TABLE_MODEL_CHANGED,
1457 : : makeAny( AccessibleTableModelChange(
1458 : : DELETE,
1459 : : nRow,
1460 : : nRow + nNumRows,
1461 : : 0,
1462 [ # # ]: 0 : GetColumnCount()
1463 : : )
1464 : : ),
1465 : : Any()
1466 [ # # ][ # # ]: 0 : );
1467 : :
1468 [ # # ]: 0 : for (sal_Int32 i = nRow+1 ; i <= (nRow+nNumRows) ; ++i)
1469 : : {
1470 : : commitHeaderBarEvent(
1471 : : CHILD,
1472 : : Any(),
1473 : 0 : makeAny( CreateAccessibleRowHeader( i ) ),
1474 : : sal_False
1475 [ # # ][ # # ]: 0 : );
[ # # ]
1476 : : }
1477 : : }
1478 : : }
1479 : :
1480 [ # # ]: 0 : if ( nOldCurRow != nCurRow )
1481 [ # # ]: 0 : CursorMoved();
1482 : :
1483 : : DBG_ASSERT(nRowCount >= 0,"BrowseBox: nRowCount < 0");
1484 : : DBG_ASSERT(nCurRow >= 0 || nRowCount == 0,"BrowseBox: nCurRow < 0 && nRowCount != 0");
1485 : : DBG_ASSERT(nCurRow < nRowCount,"nCurRow >= nRowCount");
1486 : : }
1487 : :
1488 : : //-------------------------------------------------------------------
1489 : :
1490 : 0 : sal_Bool BrowseBox::GoToRow( long nRow)
1491 : : {
1492 : 0 : return GoToRow(nRow, sal_False, sal_False);
1493 : : }
1494 : :
1495 : : //-------------------------------------------------------------------
1496 : :
1497 : 2 : sal_Bool BrowseBox::GoToRow( long nRow, sal_Bool bRowColMove, sal_Bool bKeepSelection )
1498 : : {
1499 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1500 : :
1501 : 2 : long nOldCurRow = nCurRow;
1502 : :
1503 : : // nothing to do?
1504 [ - + ][ # # ]: 2 : if ( nRow == nCurRow && ( bMultiSelection || uRow.nSel == nRow ) )
[ # # ]
1505 : 0 : return sal_True;
1506 : :
1507 : : // out of range?
1508 [ + - ][ - + ]: 2 : if ( nRow < 0 || nRow >= nRowCount )
1509 : 0 : return sal_False;
1510 : :
1511 : : // not allowed?
1512 [ + - ][ + - ]: 2 : if ( ( !bRowColMove && !IsCursorMoveAllowed( nRow, nCurColId ) ) )
[ - + ][ - + ]
1513 : 0 : return sal_False;
1514 : :
1515 [ - + ][ # # ]: 2 : if ( getDataWindow()->bNoScrollBack && nRow < nTopRow )
1516 : 0 : nRow = nTopRow;
1517 : :
1518 : : // compute the last visible row
1519 [ + - ]: 2 : Size aSz( pDataWin->GetSizePixel() );
1520 [ + - ]: 2 : sal_uInt16 nVisibleRows = sal_uInt16( aSz.Height() / GetDataRowHeight() - 1 );
1521 : 2 : long nLastRow = nTopRow + nVisibleRows;
1522 : :
1523 : : // suspend Updates
1524 : 2 : getDataWindow()->EnterUpdateLock();
1525 : :
1526 : : // remove old highlight, if necessary
1527 [ # # ][ - + ]: 2 : if ( !bMultiSelection && !bKeepSelection )
1528 [ # # ]: 0 : ToggleSelection();
1529 [ + - ]: 2 : DoHideCursor( "GoToRow" );
1530 : :
1531 : : // must we scroll?
1532 : 2 : sal_Bool bWasVisible = bSelectionIsVisible;
1533 [ - + ]: 2 : if (! bMultiSelection)
1534 : : {
1535 [ # # ]: 0 : if( !bKeepSelection )
1536 : 0 : bSelectionIsVisible = sal_False;
1537 : : }
1538 [ - + ]: 2 : if ( nRow < nTopRow )
1539 [ # # ]: 0 : ScrollRows( nRow - nTopRow );
1540 [ - + ]: 2 : else if ( nRow > nLastRow )
1541 [ # # ]: 0 : ScrollRows( nRow - nLastRow );
1542 : 2 : bSelectionIsVisible = bWasVisible;
1543 : :
1544 : : // adjust cursor (selection) and thumb
1545 [ + - ][ + - ]: 2 : if ( GetUpdateMode() )
1546 [ + - ]: 2 : pVScroll->SetThumbPos( nTopRow );
1547 : :
1548 : : // relative positioning (because nCurRow might have changed in the meantime)!
1549 [ - + ]: 2 : if (nCurRow != BROWSER_ENDOFSELECTION )
1550 : 0 : nCurRow = nCurRow + (nRow - nOldCurRow);
1551 : :
1552 : : // make sure that the current position is valid
1553 [ + - ][ + - ]: 2 : if (nCurRow == BROWSER_ENDOFSELECTION && nRowCount > 0)
1554 : 2 : nCurRow = 0;
1555 [ # # ]: 0 : else if ( nCurRow >= nRowCount )
1556 : 0 : nCurRow = nRowCount - 1;
1557 : 2 : aSelRange = Range( nCurRow, nCurRow );
1558 : :
1559 : : // display new highlight if necessary
1560 [ # # ][ - + ]: 2 : if ( !bMultiSelection && !bKeepSelection )
1561 : 0 : uRow.nSel = nRow;
1562 : :
1563 : : // resume Updates
1564 [ + - ]: 2 : getDataWindow()->LeaveUpdateLock();
1565 : :
1566 : : // Cursor+Highlight
1567 [ - + ][ # # ]: 2 : if ( !bMultiSelection && !bKeepSelection)
1568 [ # # ]: 0 : ToggleSelection();
1569 [ + - ]: 2 : DoShowCursor( "GoToRow" );
1570 [ + - ][ + - ]: 2 : if ( !bRowColMove && nOldCurRow != nCurRow )
1571 [ + - ]: 2 : CursorMoved();
1572 : :
1573 [ - + ][ # # ]: 2 : if ( !bMultiSelection && !bKeepSelection )
1574 : : {
1575 [ # # ]: 0 : if ( !bSelecting )
1576 [ # # ]: 0 : Select();
1577 : : else
1578 : 0 : bSelect = sal_True;
1579 : : }
1580 : 2 : return sal_True;
1581 : : }
1582 : :
1583 : : //-------------------------------------------------------------------
1584 : :
1585 : 0 : sal_Bool BrowseBox::GoToColumnId( sal_uInt16 nColId)
1586 : : {
1587 : 0 : return GoToColumnId(nColId,sal_True,sal_False);
1588 : : }
1589 : :
1590 : :
1591 : 0 : sal_Bool BrowseBox::GoToColumnId( sal_uInt16 nColId, sal_Bool bMakeVisible, sal_Bool bRowColMove)
1592 : : {
1593 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1594 : :
1595 [ # # ]: 0 : if (!bColumnCursor)
1596 : 0 : return sal_False;
1597 : :
1598 : : // allowed?
1599 [ # # ][ # # ]: 0 : if (!bRowColMove && !IsCursorMoveAllowed( nCurRow, nColId ) )
[ # # ]
1600 : 0 : return sal_False;
1601 : :
1602 [ # # ][ # # ]: 0 : if ( nColId != nCurColId || (bMakeVisible && !IsFieldVisible(nCurRow, nColId, sal_True)))
[ # # ][ # # ]
1603 : : {
1604 : 0 : sal_uInt16 nNewPos = GetColumnPos(nColId);
1605 [ # # ]: 0 : BrowserColumn* pColumn = (nNewPos < pCols->size()) ? (*pCols)[ nNewPos ] : NULL;
1606 : : DBG_ASSERT( pColumn, "no column object - invalid id?" );
1607 [ # # ]: 0 : if ( !pColumn )
1608 : 0 : return sal_False;
1609 : :
1610 : 0 : DoHideCursor( "GoToColumnId" );
1611 : 0 : nCurColId = nColId;
1612 : :
1613 : 0 : sal_uInt16 nFirstPos = nFirstCol;
1614 : 0 : sal_uInt16 nWidth = (sal_uInt16)pColumn->Width();
1615 : : sal_uInt16 nLastPos = GetColumnAtXPosPixel(
1616 [ # # ]: 0 : pDataWin->GetSizePixel().Width()-nWidth, sal_False );
1617 : 0 : sal_uInt16 nFrozen = FrozenColCount();
1618 [ # # ][ # # ]: 0 : if ( bMakeVisible && nLastPos &&
[ # # ][ # # ]
[ # # ]
1619 : : nNewPos >= nFrozen && ( nNewPos < nFirstPos || nNewPos > nLastPos ) )
1620 : : {
1621 [ # # ]: 0 : if ( nNewPos < nFirstPos )
1622 : 0 : ScrollColumns( nNewPos-nFirstPos );
1623 [ # # ]: 0 : else if ( nNewPos > nLastPos )
1624 : 0 : ScrollColumns( nNewPos-nLastPos );
1625 : : }
1626 : :
1627 : 0 : DoShowCursor( "GoToColumnId" );
1628 [ # # ]: 0 : if (!bRowColMove)
1629 : 0 : CursorMoved();
1630 : 0 : return sal_True;
1631 : : }
1632 : 0 : return sal_True;
1633 : : }
1634 : :
1635 : : //-------------------------------------------------------------------
1636 : :
1637 : 2 : sal_Bool BrowseBox::GoToRowColumnId( long nRow, sal_uInt16 nColId )
1638 : : {
1639 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1640 : :
1641 : : // out of range?
1642 [ + - ][ - + ]: 2 : if ( nRow < 0 || nRow >= nRowCount )
1643 : 0 : return sal_False;
1644 : :
1645 [ - + ]: 2 : if (!bColumnCursor)
1646 : 0 : return sal_False;
1647 : :
1648 : : // nothing to do ?
1649 [ + - ][ - + ]: 4 : if ( nRow == nCurRow && ( bMultiSelection || uRow.nSel == nRow ) &&
[ # # ]
[ + - + - ]
[ + - ]
1650 : 2 : nColId == nCurColId && IsFieldVisible(nCurRow, nColId, sal_True))
1651 : 2 : return sal_True;
1652 : :
1653 : : // allowed?
1654 [ # # ]: 0 : if (!IsCursorMoveAllowed(nRow, nColId))
1655 : 0 : return sal_False;
1656 : :
1657 : 0 : DoHideCursor( "GoToRowColumnId" );
1658 [ # # ][ # # ]: 0 : sal_Bool bMoved = GoToRow(nRow, sal_True) && GoToColumnId(nColId, sal_True, sal_True);
1659 : 0 : DoShowCursor( "GoToRowColumnId" );
1660 : :
1661 [ # # ]: 0 : if (bMoved)
1662 : 0 : CursorMoved();
1663 : :
1664 : 2 : return bMoved;
1665 : : }
1666 : :
1667 : : //-------------------------------------------------------------------
1668 : :
1669 : 4 : void BrowseBox::SetNoSelection()
1670 : : {
1671 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1672 : :
1673 : : // is there no selection
1674 [ + - ][ + - ]: 8 : if ( ( !pColSel || !pColSel->GetSelectCount() ) &&
[ - + ][ # # ]
[ + - + - ]
[ + - ]
1675 : 4 : ( ( !bMultiSelection && uRow.nSel == BROWSER_ENDOFSELECTION ) ||
1676 : 4 : ( bMultiSelection && !uRow.pSel->GetSelectCount() ) ) )
1677 : : // nothing to do
1678 : 4 : return;
1679 : :
1680 : : OSL_TRACE( "BrowseBox: %p->HideCursor", this );
1681 : 0 : ToggleSelection();
1682 : :
1683 : : // unselect all
1684 [ # # ]: 0 : if ( bMultiSelection )
1685 : 0 : uRow.pSel->SelectAll(sal_False);
1686 : : else
1687 : 0 : uRow.nSel = BROWSER_ENDOFSELECTION;
1688 [ # # ]: 0 : if ( pColSel )
1689 : 0 : pColSel->SelectAll(sal_False);
1690 [ # # ]: 0 : if ( !bSelecting )
1691 : 0 : Select();
1692 : : else
1693 : 0 : bSelect = sal_True;
1694 : :
1695 : : // restore screen
1696 : : OSL_TRACE( "BrowseBox: %p->ShowCursor", this );
1697 : :
1698 [ # # ]: 0 : if ( isAccessibleAlive() )
1699 : : {
1700 : : commitTableEvent(
1701 : : SELECTION_CHANGED,
1702 : : Any(),
1703 : : Any()
1704 [ # # ]: 0 : );
1705 : : }
1706 : : }
1707 : :
1708 : : //-------------------------------------------------------------------
1709 : :
1710 : 0 : void BrowseBox::SelectAll()
1711 : : {
1712 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1713 : :
1714 [ # # ]: 0 : if ( !bMultiSelection )
1715 : 0 : return;
1716 : :
1717 : : OSL_TRACE( "BrowseBox: %p->HideCursor", this );
1718 : 0 : ToggleSelection();
1719 : :
1720 : : // select all rows
1721 [ # # ]: 0 : if ( pColSel )
1722 : 0 : pColSel->SelectAll(sal_False);
1723 : 0 : uRow.pSel->SelectAll(sal_True);
1724 : :
1725 : : // don't highlight handle column
1726 : 0 : BrowserColumn *pFirstCol = (*pCols)[ 0 ];
1727 [ # # ]: 0 : long nOfsX = pFirstCol->GetId() ? 0 : pFirstCol->Width();
1728 : :
1729 : : // highlight the row selection
1730 [ # # ]: 0 : if ( !bHideSelect )
1731 : : {
1732 [ # # ]: 0 : Rectangle aHighlightRect;
1733 : : sal_uInt16 nVisibleRows =
1734 [ # # ]: 0 : (sal_uInt16)(pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight() + 1);
1735 [ # # ][ # # ]: 0 : for ( long nRow = Max( nTopRow, uRow.pSel->FirstSelected() );
[ # # ][ # # ]
[ # # ]
1736 : : nRow != BROWSER_ENDOFSELECTION && nRow < nTopRow + nVisibleRows;
1737 : 0 : nRow = uRow.pSel->NextSelected() )
1738 : : aHighlightRect.Union( Rectangle(
1739 [ # # ]: 0 : Point( nOfsX, (nRow-nTopRow)*GetDataRowHeight() ),
1740 [ # # ][ # # ]: 0 : Size( pDataWin->GetSizePixel().Width(), GetDataRowHeight() ) ) );
[ # # ][ # # ]
1741 [ # # ]: 0 : pDataWin->Invalidate( aHighlightRect );
1742 : : }
1743 : :
1744 [ # # ]: 0 : if ( !bSelecting )
1745 : 0 : Select();
1746 : : else
1747 : 0 : bSelect = sal_True;
1748 : :
1749 : : // restore screen
1750 : : OSL_TRACE( "BrowseBox: %p->ShowCursor", this );
1751 : :
1752 [ # # ]: 0 : if ( isAccessibleAlive() )
1753 : : {
1754 : : commitTableEvent(
1755 : : SELECTION_CHANGED,
1756 : : Any(),
1757 : : Any()
1758 [ # # ]: 0 : );
1759 : : commitHeaderBarEvent(
1760 : : SELECTION_CHANGED,
1761 : : Any(),
1762 : : Any(),
1763 : : sal_True
1764 [ # # ]: 0 : ); // column header event
1765 : :
1766 : : commitHeaderBarEvent(
1767 : : SELECTION_CHANGED,
1768 : : Any(),
1769 : : Any(),
1770 : : sal_False
1771 [ # # ]: 0 : ); // row header event
1772 : : }
1773 : : }
1774 : :
1775 : : //-------------------------------------------------------------------
1776 : :
1777 : 0 : void BrowseBox::SelectRow( long nRow, sal_Bool _bSelect, sal_Bool bExpand )
1778 : : {
1779 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1780 : :
1781 [ # # ]: 0 : if ( !bMultiSelection )
1782 : : {
1783 : : // deselecting is impossible, selecting via cursor
1784 [ # # ]: 0 : if ( _bSelect )
1785 : 0 : GoToRow(nRow, sal_False);
1786 : 0 : return;
1787 : : }
1788 : :
1789 : : OSL_TRACE( "BrowseBox: %p->HideCursor", this );
1790 : :
1791 : : // remove old selection?
1792 [ # # ][ # # ]: 0 : if ( !bExpand || !bMultiSelection )
1793 : : {
1794 : 0 : ToggleSelection();
1795 [ # # ]: 0 : if ( bMultiSelection )
1796 : 0 : uRow.pSel->SelectAll(sal_False);
1797 : : else
1798 : 0 : uRow.nSel = BROWSER_ENDOFSELECTION;
1799 [ # # ]: 0 : if ( pColSel )
1800 : 0 : pColSel->SelectAll(sal_False);
1801 : : }
1802 : :
1803 : : // set new selection
1804 [ # # ][ # # : 0 : if ( !bHideSelect
# # # # ]
[ # # ][ # # ]
[ # # ]
1805 : : && ( ( bMultiSelection
1806 : 0 : && uRow.pSel->GetTotalRange().Max() >= nRow
1807 : 0 : && uRow.pSel->Select( nRow, _bSelect )
1808 : : )
1809 : 0 : || ( !bMultiSelection
1810 : : && ( uRow.nSel = nRow ) != BROWSER_ENDOFSELECTION )
1811 : : )
1812 : : )
1813 : : {
1814 : : // don't highlight handle column
1815 : 0 : BrowserColumn *pFirstCol = (*pCols)[ 0 ];
1816 [ # # ]: 0 : long nOfsX = pFirstCol->GetId() ? 0 : pFirstCol->Width();
1817 : :
1818 : : // highlight only newly selected part
1819 : : Rectangle aRect(
1820 [ # # ]: 0 : Point( nOfsX, (nRow-nTopRow)*GetDataRowHeight() ),
1821 [ # # ][ # # ]: 0 : Size( pDataWin->GetSizePixel().Width(), GetDataRowHeight() ) );
[ # # ]
1822 [ # # ]: 0 : pDataWin->Invalidate( aRect );
1823 : : }
1824 : :
1825 [ # # ]: 0 : if ( !bSelecting )
1826 : 0 : Select();
1827 : : else
1828 : 0 : bSelect = sal_True;
1829 : :
1830 : : // restore screen
1831 : : OSL_TRACE( "BrowseBox: %p->ShowCursor", this );
1832 : :
1833 [ # # ]: 0 : if ( isAccessibleAlive() )
1834 : : {
1835 : : commitTableEvent(
1836 : : SELECTION_CHANGED,
1837 : : Any(),
1838 : : Any()
1839 [ # # ]: 0 : );
1840 : : commitHeaderBarEvent(
1841 : : SELECTION_CHANGED,
1842 : : Any(),
1843 : : Any(),
1844 : : sal_False
1845 [ # # ]: 0 : ); // row header event
1846 : : }
1847 : : }
1848 : :
1849 : : //-------------------------------------------------------------------
1850 : :
1851 : 233 : long BrowseBox::GetSelectRowCount() const
1852 : : {
1853 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1854 : :
1855 : 233 : return bMultiSelection ? uRow.pSel->GetSelectCount() :
1856 [ + - ]: 233 : uRow.nSel == BROWSER_ENDOFSELECTION ? 0 : 1;
1857 : : }
1858 : :
1859 : : //-------------------------------------------------------------------
1860 : :
1861 : 0 : void BrowseBox::SelectColumnPos( sal_uInt16 nNewColPos, sal_Bool _bSelect, sal_Bool bMakeVisible )
1862 : : {
1863 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1864 : :
1865 [ # # ][ # # ]: 0 : if ( !bColumnCursor || nNewColPos == BROWSER_INVALIDID )
1866 : 0 : return;
1867 : :
1868 [ # # ]: 0 : if ( !bMultiSelection )
1869 : : {
1870 [ # # ]: 0 : if ( _bSelect )
1871 : 0 : GoToColumnId( (*pCols)[ nNewColPos ]->GetId(), bMakeVisible );
1872 : 0 : return;
1873 : : }
1874 : : else
1875 : : {
1876 [ # # ]: 0 : if ( !GoToColumnId( (*pCols)[ nNewColPos ]->GetId(), bMakeVisible ) )
1877 : 0 : return;
1878 : : }
1879 : :
1880 : : OSL_TRACE( "BrowseBox: %p->HideCursor", this );
1881 : 0 : ToggleSelection();
1882 [ # # ]: 0 : if ( bMultiSelection )
1883 : 0 : uRow.pSel->SelectAll(sal_False);
1884 : : else
1885 : 0 : uRow.nSel = BROWSER_ENDOFSELECTION;
1886 : 0 : pColSel->SelectAll(sal_False);
1887 : :
1888 [ # # ]: 0 : if ( pColSel->Select( nNewColPos, _bSelect ) )
1889 : : {
1890 : : // GoToColumnId( pCols->GetObject(nNewColPos)->GetId(), bMakeVisible );
1891 : :
1892 : : // only highlight painted areas
1893 [ # # ]: 0 : pDataWin->Update();
1894 [ # # ]: 0 : Rectangle aFieldRectPix( GetFieldRectPixel( nCurRow, nCurColId, sal_False ) );
1895 : : Rectangle aRect(
1896 : 0 : Point( aFieldRectPix.Left() - MIN_COLUMNWIDTH, 0 ),
1897 : 0 : Size( (*pCols)[ nNewColPos ]->Width(),
1898 [ # # ]: 0 : pDataWin->GetOutputSizePixel().Height() ) );
1899 [ # # ]: 0 : pDataWin->Invalidate( aRect );
1900 [ # # ]: 0 : if ( !bSelecting )
1901 [ # # ]: 0 : Select();
1902 : : else
1903 : 0 : bSelect = sal_True;
1904 : :
1905 [ # # ][ # # ]: 0 : if ( isAccessibleAlive() )
1906 : : {
1907 : : commitTableEvent(
1908 : : SELECTION_CHANGED,
1909 : : Any(),
1910 : : Any()
1911 [ # # ]: 0 : );
1912 : : commitHeaderBarEvent(
1913 : : SELECTION_CHANGED,
1914 : : Any(),
1915 : : Any(),
1916 : : sal_True
1917 [ # # ]: 0 : ); // column header event
1918 : : }
1919 : : }
1920 : :
1921 : : // restore screen
1922 : : OSL_TRACE( "BrowseBox: %p->ShowCursor", this );
1923 : : }
1924 : :
1925 : : //-------------------------------------------------------------------
1926 : :
1927 : 77 : sal_uInt16 BrowseBox::GetSelectColumnCount() const
1928 : : {
1929 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1930 : :
1931 : : // while bAutoSelect (==!pColSel), 1 if any rows (yes rows!) else none
1932 : 77 : return pColSel ? (sal_uInt16) pColSel->GetSelectCount() :
1933 [ + - ][ # # ]: 154 : nCurRow >= 0 ? 1 : 0;
1934 : : }
1935 : :
1936 : : //-------------------------------------------------------------------
1937 : 0 : long BrowseBox::FirstSelectedColumn( ) const
1938 : : {
1939 [ # # ]: 0 : return pColSel ? pColSel->FirstSelected() : BROWSER_ENDOFSELECTION;
1940 : : }
1941 : :
1942 : : //-------------------------------------------------------------------
1943 : :
1944 : 0 : long BrowseBox::FirstSelectedRow( sal_Bool bInverse )
1945 : : {
1946 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1947 : :
1948 [ # # ]: 0 : return bMultiSelection ? uRow.pSel->FirstSelected(bInverse) : uRow.nSel;
1949 : : }
1950 : :
1951 : : //-------------------------------------------------------------------
1952 : :
1953 : 0 : long BrowseBox::NextSelectedRow()
1954 : : {
1955 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1956 : :
1957 [ # # ]: 0 : return bMultiSelection ? uRow.pSel->NextSelected() : BROWSER_ENDOFSELECTION;
1958 : : }
1959 : :
1960 : : //-------------------------------------------------------------------
1961 : :
1962 : 0 : long BrowseBox::LastSelectedRow()
1963 : : {
1964 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1965 : :
1966 [ # # ]: 0 : return bMultiSelection ? uRow.pSel->LastSelected() : uRow.nSel;
1967 : : }
1968 : :
1969 : : //-------------------------------------------------------------------
1970 : :
1971 : 16 : bool BrowseBox::IsRowSelected( long nRow ) const
1972 : : {
1973 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1974 : :
1975 [ + - ]: 16 : return bMultiSelection ? uRow.pSel->IsSelected(nRow) : nRow == uRow.nSel;
1976 : : }
1977 : :
1978 : : //-------------------------------------------------------------------
1979 : :
1980 : 128 : bool BrowseBox::IsColumnSelected( sal_uInt16 nColumnId ) const
1981 : : {
1982 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1983 : :
1984 : 128 : return pColSel ? pColSel->IsSelected( GetColumnPos(nColumnId) ) :
1985 [ + - ]: 256 : nCurColId == nColumnId;
1986 : : }
1987 : :
1988 : : //-------------------------------------------------------------------
1989 : :
1990 : 0 : sal_Bool BrowseBox::MakeFieldVisible
1991 : : (
1992 : : long nRow, // line number of the field (starting with 0)
1993 : : sal_uInt16 nColId, // column ID of the field
1994 : : sal_Bool bComplete // (== sal_False), sal_True => make visible in its entirety
1995 : : )
1996 : :
1997 : : /* [Description]
1998 : :
1999 : : Makes visible the field described in 'nRow' and 'nColId' by scrolling
2000 : : accordingly. If 'bComplete' is set, the field should become visible in its
2001 : : entirety.
2002 : :
2003 : : [Returned Value]
2004 : :
2005 : : sal_Bool sal_True
2006 : : The given field is already visible or was already visible.
2007 : :
2008 : : sal_False
2009 : : The given field could not be made visible or in the case of
2010 : : 'bComplete' could not be made visible in its entirety.
2011 : : */
2012 : :
2013 : : {
2014 [ # # ]: 0 : Size aTestSize = pDataWin->GetSizePixel();
2015 : :
2016 [ # # # # : 0 : if ( !bBootstrapped ||
# # ][ # # ]
2017 : 0 : ( aTestSize.Width() == 0 && aTestSize.Height() == 0 ) )
2018 : 0 : return sal_False;
2019 : :
2020 : : // is it visible already?
2021 [ # # ]: 0 : sal_Bool bVisible = IsFieldVisible( nRow, nColId, bComplete );
2022 [ # # ]: 0 : if ( bVisible )
2023 : 0 : return sal_True;
2024 : :
2025 : : // calculate column position, field rectangle and painting area
2026 [ # # ]: 0 : sal_uInt16 nColPos = GetColumnPos( nColId );
2027 [ # # ]: 0 : Rectangle aFieldRect = GetFieldRectPixel( nRow, nColId, sal_False );
2028 [ # # ][ # # ]: 0 : Rectangle aDataRect = Rectangle( Point(0, 0), pDataWin->GetSizePixel() );
2029 : :
2030 : : // positioned outside on the left?
2031 [ # # ][ # # ]: 0 : if ( nColPos >= FrozenColCount() && nColPos < nFirstCol )
[ # # ][ # # ]
2032 : : // => scroll to the right
2033 [ # # ]: 0 : ScrollColumns( nColPos - nFirstCol );
2034 : :
2035 : : // while outside on the right
2036 [ # # ][ # # ]: 0 : while ( aDataRect.Right() < ( bComplete
2037 : 0 : ? aFieldRect.Right()
2038 [ # # ]: 0 : : aFieldRect.Left()+aFieldRect.GetWidth()/2 ) )
2039 : : {
2040 : : // => scroll to the left
2041 [ # # ][ # # ]: 0 : if ( ScrollColumns( 1 ) != 1 )
2042 : : // no more need to scroll
2043 : 0 : break;
2044 [ # # ]: 0 : aFieldRect = GetFieldRectPixel( nRow, nColId, sal_False );
2045 : : }
2046 : :
2047 : : // positioned outside above?
2048 [ # # ]: 0 : if ( nRow < nTopRow )
2049 : : // scroll further to the bottom
2050 [ # # ]: 0 : ScrollRows( nRow - nTopRow );
2051 : :
2052 : : // positioned outside below?
2053 [ # # ]: 0 : long nBottomRow = nTopRow + GetVisibleRows();
2054 : : // decrement nBottomRow to make it the number of the last visible line
2055 : : // (count starts with 0!).
2056 : : // Example: BrowseBox contains exactly one entry. nBottomRow := 0 + 1 - 1
2057 [ # # ]: 0 : if( nBottomRow )
2058 : 0 : nBottomRow--;
2059 : :
2060 [ # # ]: 0 : if ( nRow > nBottomRow )
2061 : : // scroll further to the top
2062 [ # # ]: 0 : ScrollRows( nRow - nBottomRow );
2063 : :
2064 : : // it might still not actually fit, e.g. if the window is too small
2065 [ # # ]: 0 : return IsFieldVisible( nRow, nColId, bComplete );
2066 : : }
2067 : :
2068 : : //-------------------------------------------------------------------
2069 : :
2070 : 2 : sal_Bool BrowseBox::IsFieldVisible( long nRow, sal_uInt16 nColumnId,
2071 : : sal_Bool bCompletely ) const
2072 : : {
2073 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2074 : :
2075 : : // hidden by frozen column?
2076 [ + - ]: 2 : sal_uInt16 nColPos = GetColumnPos( nColumnId );
2077 [ + - ][ - + ]: 2 : if ( nColPos >= FrozenColCount() && nColPos < nFirstCol )
[ # # ][ - + ]
2078 : 0 : return sal_False;
2079 : :
2080 [ + - ]: 2 : Rectangle aRect( ImplFieldRectPixel( nRow, nColumnId ) );
2081 [ + - ][ - + ]: 2 : if ( aRect.IsEmpty() )
2082 : 0 : return sal_False;
2083 : :
2084 : : // get the visible area
2085 [ + - ]: 2 : Rectangle aOutRect( Point(0, 0), pDataWin->GetOutputSizePixel() );
2086 : :
2087 [ + - ]: 2 : if ( bCompletely )
2088 : : // test if the field is completely visible
2089 [ + - ]: 2 : return aOutRect.IsInside( aRect );
2090 : : else
2091 : : // test if the field is partly of completely visible
2092 [ # # ][ # # ]: 2 : return !aOutRect.Intersection( aRect ).IsEmpty();
2093 : : }
2094 : :
2095 : : //-------------------------------------------------------------------
2096 : :
2097 : 332 : Rectangle BrowseBox::GetFieldRectPixel( long nRow, sal_uInt16 nColumnId,
2098 : : sal_Bool bRelToBrowser) const
2099 : : {
2100 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2101 : :
2102 : : // get the rectangle relative to DataWin
2103 [ + - ]: 332 : Rectangle aRect( ImplFieldRectPixel( nRow, nColumnId ) );
2104 [ + - ][ + + ]: 332 : if ( aRect.IsEmpty() )
2105 : 264 : return aRect;
2106 : :
2107 : : // adjust relative to BrowseBox's output area
2108 : 68 : Point aTopLeft( aRect.TopLeft() );
2109 [ - + ]: 68 : if ( bRelToBrowser )
2110 : : {
2111 [ # # ]: 0 : aTopLeft = pDataWin->OutputToScreenPixel( aTopLeft );
2112 [ # # ]: 0 : aTopLeft = ScreenToOutputPixel( aTopLeft );
2113 : : }
2114 : :
2115 [ + - ][ + - ]: 332 : return Rectangle( aTopLeft, aRect.GetSize() );
2116 : : }
2117 : :
2118 : : //-------------------------------------------------------------------
2119 : :
2120 : 0 : Rectangle BrowseBox::GetRowRectPixel( long nRow, sal_Bool bRelToBrowser ) const
2121 : : {
2122 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2123 : :
2124 : : // get the rectangle relative to DataWin
2125 [ # # ]: 0 : Rectangle aRect;
2126 [ # # ]: 0 : if ( nTopRow > nRow )
2127 : : // row is above visible area
2128 : 0 : return aRect;
2129 : : aRect = Rectangle(
2130 [ # # ]: 0 : Point( 0, GetDataRowHeight() * (nRow-nTopRow) ),
2131 [ # # ][ # # ]: 0 : Size( pDataWin->GetOutputSizePixel().Width(), GetDataRowHeight() ) );
2132 [ # # ]: 0 : if ( aRect.TopLeft().Y() > pDataWin->GetOutputSizePixel().Height() )
2133 : : // row is below visible area
2134 : 0 : return aRect;
2135 : :
2136 : : // adjust relative to BrowseBox's output area
2137 : 0 : Point aTopLeft( aRect.TopLeft() );
2138 [ # # ]: 0 : if ( bRelToBrowser )
2139 : : {
2140 [ # # ]: 0 : aTopLeft = pDataWin->OutputToScreenPixel( aTopLeft );
2141 [ # # ]: 0 : aTopLeft = ScreenToOutputPixel( aTopLeft );
2142 : : }
2143 : :
2144 [ # # ][ # # ]: 0 : return Rectangle( aTopLeft, aRect.GetSize() );
2145 : : }
2146 : :
2147 : : //-------------------------------------------------------------------
2148 : :
2149 : 334 : Rectangle BrowseBox::ImplFieldRectPixel( long nRow, sal_uInt16 nColumnId ) const
2150 : : {
2151 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2152 : :
2153 : : // compute the X-coordinate relative to DataWin by accumulation
2154 : 334 : long nColX = 0;
2155 : 334 : sal_uInt16 nFrozenCols = FrozenColCount();
2156 : : size_t nCol;
2157 [ + + + + ]: 2682 : for ( nCol = 0;
[ + + ]
2158 : 1700 : nCol < pCols->size() && (*pCols)[ nCol ]->GetId() != nColumnId;
2159 : : ++nCol )
2160 [ + + ][ + - ]: 648 : if ( (*pCols)[ nCol ]->IsFrozen() || nCol >= nFirstCol )
[ + - ]
2161 : 648 : nColX += (*pCols)[ nCol ]->Width();
2162 : :
2163 [ + + ][ - + ]: 334 : if ( nCol >= pCols->size() || ( nCol >= nFrozenCols && nCol < nFirstCol ) )
[ # # ][ + + ]
2164 : 264 : return Rectangle();
2165 : :
2166 : : // compute the Y-coordinate relative to DataWin
2167 : 70 : long nRowY = GetDataRowHeight();
2168 [ + + ]: 70 : if ( nRow != BROWSER_ENDOFSELECTION ) // #105497# OJ
2169 : 4 : nRowY = ( nRow - nTopRow ) * GetDataRowHeight();
2170 : :
2171 : : // assemble the Rectangle relative to DataWin
2172 : : return Rectangle(
2173 : : Point( nColX + MIN_COLUMNWIDTH, nRowY ),
2174 : 70 : Size( (*pCols)[ nCol ]->Width() - 2*MIN_COLUMNWIDTH,
2175 [ + - ]: 404 : GetDataRowHeight() - 1 ) );
2176 : : }
2177 : :
2178 : : //-------------------------------------------------------------------
2179 : :
2180 : 0 : long BrowseBox::GetRowAtYPosPixel( long nY, sal_Bool bRelToBrowser ) const
2181 : : {
2182 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2183 : :
2184 : : // compute the Y-coordinate
2185 [ # # ]: 0 : if ( bRelToBrowser )
2186 : : {
2187 [ # # ]: 0 : Point aDataTopLeft = pDataWin->OutputToScreenPixel( Point(0, 0) );
2188 [ # # ]: 0 : Point aTopLeft = OutputToScreenPixel( Point(0, 0) );
2189 : 0 : nY -= aDataTopLeft.Y() - aTopLeft.Y();
2190 : : }
2191 : :
2192 : : // no row there (e.g. in the header)
2193 [ # # ][ # # ]: 0 : if ( nY < 0 || nY >= pDataWin->GetOutputSizePixel().Height() )
[ # # ][ # # ]
2194 : 0 : return -1;
2195 : :
2196 : 0 : return nY / GetDataRowHeight() + nTopRow;
2197 : : }
2198 : :
2199 : : //-------------------------------------------------------------------
2200 : :
2201 : 0 : Rectangle BrowseBox::GetFieldRect( sal_uInt16 nColumnId ) const
2202 : : {
2203 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2204 : :
2205 : 0 : return GetFieldRectPixel( nCurRow, nColumnId );
2206 : : }
2207 : :
2208 : : //-------------------------------------------------------------------
2209 : :
2210 : 542 : sal_uInt16 BrowseBox::GetColumnAtXPosPixel( long nX, sal_Bool ) const
2211 : : {
2212 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2213 : :
2214 : : // accumulate the widths of the visible columns
2215 : 542 : long nColX = 0;
2216 [ + + ]: 2136 : for ( size_t nCol = 0; nCol < pCols->size(); ++nCol )
2217 : : {
2218 : 1652 : BrowserColumn *pCol = (*pCols)[ nCol ];
2219 [ + - ][ + - ]: 1652 : if ( pCol->IsFrozen() || nCol >= nFirstCol )
[ + + ]
2220 : 1652 : nColX += pCol->Width();
2221 : :
2222 [ + + ]: 1652 : if ( nColX > nX )
2223 : 58 : return nCol;
2224 : : }
2225 : :
2226 : 542 : return BROWSER_INVALIDID;
2227 : : }
2228 : :
2229 : : //-------------------------------------------------------------------
2230 : :
2231 : 317 : void BrowseBox::ReserveControlArea( sal_uInt16 nWidth )
2232 : : {
2233 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2234 : :
2235 [ + + ]: 317 : if ( nWidth != nControlAreaWidth )
2236 : : {
2237 : : OSL_ENSURE(nWidth,"Control area of 0 is not allowed, Use USHRT_MAX instead!");
2238 : 46 : nControlAreaWidth = nWidth;
2239 : 46 : UpdateScrollbars();
2240 : : }
2241 : 317 : }
2242 : :
2243 : : //-------------------------------------------------------------------
2244 : :
2245 : 1567 : Rectangle BrowseBox::GetControlArea() const
2246 : : {
2247 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2248 : :
2249 : : return Rectangle(
2250 [ + - ]: 1567 : Point( 0, GetOutputSizePixel().Height() - aHScroll.GetSizePixel().Height() ),
2251 [ + - ]: 1567 : Size( GetOutputSizePixel().Width() - aHScroll.GetSizePixel().Width(),
2252 [ + - ]: 4701 : aHScroll.GetSizePixel().Height() ) );
2253 : : }
2254 : :
2255 : : //-------------------------------------------------------------------
2256 : :
2257 : 120 : void BrowseBox::SetMode( BrowserMode nMode )
2258 : : {
2259 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2260 : :
2261 : 120 : getDataWindow()->bAutoHScroll = BROWSER_AUTO_HSCROLL == ( nMode & BROWSER_AUTO_HSCROLL );
2262 : 120 : getDataWindow()->bAutoVScroll = BROWSER_AUTO_VSCROLL == ( nMode & BROWSER_AUTO_VSCROLL );
2263 : 120 : getDataWindow()->bNoHScroll = BROWSER_NO_HSCROLL == ( nMode & BROWSER_NO_HSCROLL );
2264 : 120 : getDataWindow()->bNoVScroll = BROWSER_NO_VSCROLL == ( nMode & BROWSER_NO_VSCROLL );
2265 : :
2266 : : DBG_ASSERT( !( getDataWindow()->bAutoHScroll && getDataWindow()->bNoHScroll ),
2267 : : "BrowseBox::SetMode: AutoHScroll *and* NoHScroll?" );
2268 : : DBG_ASSERT( !( getDataWindow()->bAutoVScroll && getDataWindow()->bNoVScroll ),
2269 : : "BrowseBox::SetMode: AutoVScroll *and* NoVScroll?" );
2270 [ + + ]: 120 : if ( getDataWindow()->bAutoHScroll )
2271 : 28 : getDataWindow()->bNoHScroll = sal_False;
2272 [ + + ]: 120 : if ( getDataWindow()->bAutoVScroll )
2273 : 28 : getDataWindow()->bNoVScroll = sal_False;
2274 : :
2275 [ - + ]: 120 : if ( getDataWindow()->bNoHScroll )
2276 : 0 : aHScroll.Hide();
2277 : :
2278 : 120 : nControlAreaWidth = USHRT_MAX;
2279 : :
2280 : : getDataWindow()->bNoScrollBack =
2281 : 120 : BROWSER_NO_SCROLLBACK == ( nMode & BROWSER_NO_SCROLLBACK);
2282 : :
2283 [ + + ]: 120 : long nOldRowSel = bMultiSelection ? uRow.pSel->FirstSelected() : uRow.nSel;
2284 [ + + ]: 120 : MultiSelection *pOldRowSel = bMultiSelection ? uRow.pSel : 0;
2285 : 120 : MultiSelection *pOldColSel = pColSel;
2286 : :
2287 [ + + ]: 120 : delete pVScroll;
2288 : :
2289 : 120 : bThumbDragging = ( nMode & BROWSER_THUMBDRAGGING ) == BROWSER_THUMBDRAGGING;
2290 : 120 : bMultiSelection = ( nMode & BROWSER_MULTISELECTION ) == BROWSER_MULTISELECTION;
2291 : 120 : bColumnCursor = ( nMode & BROWSER_COLUMNSELECTION ) == BROWSER_COLUMNSELECTION;
2292 : 120 : bKeepHighlight = ( nMode & BROWSER_KEEPSELECTION ) == BROWSER_KEEPSELECTION;
2293 : :
2294 : 120 : bHideSelect = ((nMode & BROWSER_HIDESELECT) == BROWSER_HIDESELECT);
2295 : : // default: do not hide the cursor at all (untaken scrolling and such)
2296 : 120 : bHideCursor = NO_CURSOR_HIDE;
2297 : :
2298 [ - + ]: 120 : if ( BROWSER_SMART_HIDECURSOR == ( nMode & BROWSER_SMART_HIDECURSOR ) )
2299 : : { // smart cursor hide overrules hard cursor hide
2300 : 0 : bHideCursor = SMART_CURSOR_HIDE;
2301 : : }
2302 [ + + ]: 120 : else if ( BROWSER_HIDECURSOR == ( nMode & BROWSER_HIDECURSOR ) )
2303 : : {
2304 : 2 : bHideCursor = HARD_CURSOR_HIDE;
2305 : : }
2306 : :
2307 : 120 : m_bFocusOnlyCursor = ((nMode & BROWSER_CURSOR_WO_FOCUS) == 0);
2308 : :
2309 : 120 : bHLines = ( nMode & BROWSER_HLINESFULL ) == BROWSER_HLINESFULL;
2310 : 120 : bVLines = ( nMode & BROWSER_VLINESFULL ) == BROWSER_VLINESFULL;
2311 : 120 : bHDots = ( nMode & BROWSER_HLINESDOTS ) == BROWSER_HLINESDOTS;
2312 : 120 : bVDots = ( nMode & BROWSER_VLINESDOTS ) == BROWSER_VLINESDOTS;
2313 : :
2314 : : WinBits nVScrollWinBits =
2315 [ - + ]: 120 : WB_VSCROLL | ( ( nMode & BROWSER_THUMBDRAGGING ) ? WB_DRAG : 0 );
2316 : : pVScroll = ( nMode & BROWSER_TRACKING_TIPS ) == BROWSER_TRACKING_TIPS
2317 : : ? new BrowserScrollBar( this, nVScrollWinBits,
2318 [ + - ]: 120 : (BrowserDataWin*) pDataWin )
2319 [ + - ][ # # ]: 240 : : new ScrollBar( this, nVScrollWinBits );
2320 : 120 : pVScroll->SetLineSize( 1 );
2321 : 120 : pVScroll->SetPageSize(1);
2322 : 120 : pVScroll->SetScrollHdl( LINK( this, BrowseBox, ScrollHdl ) );
2323 : 120 : pVScroll->SetEndScrollHdl( LINK( this, BrowseBox, EndScrollHdl ) );
2324 : :
2325 : : getDataWindow()->bAutoSizeLastCol =
2326 : 120 : BROWSER_AUTOSIZE_LASTCOL == ( nMode & BROWSER_AUTOSIZE_LASTCOL );
2327 : : getDataWindow()->bOwnDataChangedHdl =
2328 : 120 : BROWSER_OWN_DATACHANGED == ( nMode & BROWSER_OWN_DATACHANGED );
2329 : :
2330 : : // create a headerbar. what happens, if a headerbar has to be created and
2331 : : // there already are columns?
2332 [ + - ]: 120 : if ( BROWSER_HEADERBAR_NEW == ( nMode & BROWSER_HEADERBAR_NEW ) )
2333 : : {
2334 [ + + ]: 120 : if (!getDataWindow()->pHeaderBar)
2335 : 40 : getDataWindow()->pHeaderBar = CreateHeaderBar( this );
2336 : : }
2337 : : else
2338 : : {
2339 [ # # ]: 0 : DELETEZ(getDataWindow()->pHeaderBar);
2340 : : }
2341 : :
2342 : :
2343 : :
2344 [ + - ]: 120 : if ( bColumnCursor )
2345 : : {
2346 [ + + ][ + - ]: 120 : pColSel = pOldColSel ? pOldColSel : new MultiSelection;
2347 [ + - ]: 120 : pColSel->SetTotalRange( Range( 0, pCols->size()-1 ) );
2348 : : }
2349 : : else
2350 : : {
2351 : 0 : pColSel = 0;
2352 [ # # ]: 0 : delete pColSel;
2353 : : }
2354 : :
2355 [ + - ]: 120 : if ( bMultiSelection )
2356 : : {
2357 [ + + ]: 120 : if ( pOldRowSel )
2358 : 80 : uRow.pSel = pOldRowSel;
2359 : : else
2360 [ + - ]: 40 : uRow.pSel = new MultiSelection;
2361 : : }
2362 : : else
2363 : : {
2364 : 0 : uRow.nSel = nOldRowSel;
2365 [ # # ]: 0 : delete pOldRowSel;
2366 : : }
2367 : :
2368 [ + + ]: 120 : if ( bBootstrapped )
2369 : : {
2370 : 21 : StateChanged( STATE_CHANGE_INITSHOW );
2371 [ - + ][ # # ]: 21 : if ( bMultiSelection && !pOldRowSel &&
[ + - ]
2372 : : nOldRowSel != BROWSER_ENDOFSELECTION )
2373 : 0 : uRow.pSel->Select( nOldRowSel );
2374 : : }
2375 : :
2376 [ + - ]: 120 : if ( pDataWin )
2377 : 120 : pDataWin->Invalidate();
2378 : :
2379 : : // no cursor on handle column
2380 [ + + ]: 120 : if ( nCurColId == HandleColumnId )
2381 : 42 : nCurColId = GetColumnId( 1 );
2382 : :
2383 : 120 : m_nCurrentMode = nMode;
2384 : 120 : }
2385 : :
2386 : : //-------------------------------------------------------------------
2387 : :
2388 : 0 : void BrowseBox::VisibleRowsChanged( long, sal_uInt16 )
2389 : : {
2390 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2391 : :
2392 : : // old behavior: automatically correct NumRows:
2393 [ # # ]: 0 : if ( nRowCount < GetRowCount() )
2394 : : {
2395 : 0 : RowInserted(nRowCount,GetRowCount() - nRowCount,sal_False);
2396 : : }
2397 [ # # ]: 0 : else if ( nRowCount > GetRowCount() )
2398 : : {
2399 : 0 : RowRemoved(nRowCount-(nRowCount - GetRowCount()),nRowCount - GetRowCount(),sal_False);
2400 : : }
2401 : 0 : }
2402 : :
2403 : : //-------------------------------------------------------------------
2404 : :
2405 : 0 : sal_Bool BrowseBox::IsCursorMoveAllowed( long, sal_uInt16 ) const
2406 : :
2407 : : /* [Description]
2408 : :
2409 : : This virtual method is always called before the cursor is moved directly.
2410 : : By means of 'return sal_False', we avoid doing this if e.g. a record
2411 : : contradicts any rules.
2412 : :
2413 : : This method is not called, if the cursor movement results from removing or
2414 : : deleting a row/column (thus, in cases where only a "cursor correction" happens).
2415 : :
2416 : : The base implementation currently always returns sal_True.
2417 : : */
2418 : :
2419 : : {
2420 : 0 : return sal_True;
2421 : : }
2422 : :
2423 : : //-------------------------------------------------------------------
2424 : :
2425 : 4080 : long BrowseBox::GetDataRowHeight() const
2426 : : {
2427 [ + + ]: 4080 : return CalcZoom(nDataRowHeight ? nDataRowHeight : ImpGetDataRowHeight());
2428 : : }
2429 : :
2430 : : //-------------------------------------------------------------------
2431 : :
2432 : 40 : BrowserHeader* BrowseBox::CreateHeaderBar( BrowseBox* pParent )
2433 : : {
2434 [ + - ]: 40 : BrowserHeader* pNewBar = new BrowserHeader( pParent );
2435 : 40 : pNewBar->SetStartDragHdl( LINK( this, BrowseBox, StartDragHdl ) );
2436 : 40 : return pNewBar;
2437 : : }
2438 : :
2439 : 40 : void BrowseBox::SetHeaderBar( BrowserHeader* pHeaderBar )
2440 : : {
2441 [ + - ]: 40 : delete ( (BrowserDataWin*)pDataWin )->pHeaderBar;
2442 : 40 : ( (BrowserDataWin*)pDataWin )->pHeaderBar = pHeaderBar;
2443 : 40 : ( (BrowserDataWin*)pDataWin )->pHeaderBar->SetStartDragHdl( LINK( this, BrowseBox, StartDragHdl ) );
2444 : 40 : }
2445 : : //-------------------------------------------------------------------
2446 : :
2447 : : #ifdef DBG_UTIL
2448 : : const char* BrowseBoxCheckInvariants( const void * pVoid )
2449 : : {
2450 : : const BrowseBox * p = (const BrowseBox *)pVoid;
2451 : :
2452 : : if (p->nRowCount < 0) return "BrowseBox: nRowCount < 0";
2453 : : if (p->nTopRow < 0) return "BrowseBox: nTopRow < 0";
2454 : : if (p->nTopRow >= p->nRowCount && p->nRowCount != 0) return "BrowseBox: nTopRow >= nRowCount && nRowCount != 0";
2455 : : if (p->nCurRow < -1) return "BrowseBox: nCurRow < -1";
2456 : : if (p->nCurRow > p->nRowCount) return "BrowseBox: nCurRow > nRowCount";
2457 : :
2458 : : // Sadly not always the case when editing:
2459 : : //if (p->nCurRow < 0 && p->nRowCount != 0) return "nCurRow < 0 && nRowCount != 0";
2460 : : //if (p->nCurRow >= p->nRowCount && p->nRowCount != 0) return "nCurRow >= nRowCount && nRowCount != 0";
2461 : :
2462 : : return NULL;
2463 : : }
2464 : : #endif
2465 : :
2466 : : //-------------------------------------------------------------------
2467 : 3465 : long BrowseBox::GetTitleHeight() const
2468 : : {
2469 : : long nHeight;
2470 : : // ask the header bar for the text height (if possible), as the header bar's font is adjusted with
2471 : : // our (and the header's) zoom factor
2472 : 3465 : HeaderBar* pHeaderBar = ( (BrowserDataWin*)pDataWin )->pHeaderBar;
2473 [ + + ]: 3465 : if ( pHeaderBar )
2474 : 3425 : nHeight = pHeaderBar->GetTextHeight();
2475 : : else
2476 : 40 : nHeight = GetTextHeight();
2477 : :
2478 [ + - ]: 3465 : return nTitleLines ? nTitleLines * nHeight + 4 : 0;
2479 : : }
2480 : :
2481 : : //-------------------------------------------------------------------
2482 : 224 : long BrowseBox::CalcReverseZoom(long nVal)
2483 : : {
2484 [ - + ]: 224 : if (IsZoom())
2485 : : {
2486 : 0 : const Fraction& rZoom = GetZoom();
2487 : 0 : double n = (double)nVal;
2488 : 0 : n *= (double)rZoom.GetDenominator();
2489 : 0 : n /= (double)rZoom.GetNumerator();
2490 [ # # ]: 0 : nVal = n>0 ? (long)(n + 0.5) : -(long)(-n + 0.5);
2491 : : }
2492 : :
2493 : 224 : return nVal;
2494 : : }
2495 : :
2496 : 0 : void BrowseBox::CursorMoved()
2497 : : {
2498 : : // before implementing more here, please adjust the EditBrowseBox
2499 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2500 : :
2501 [ # # ][ # # ]: 0 : if ( isAccessibleAlive() && HasFocus() )
[ # # ]
2502 : : commitTableEvent(
2503 : : ACTIVE_DESCENDANT_CHANGED,
2504 [ # # ]: 0 : makeAny( CreateAccessibleCell( GetCurRow(),GetColumnPos( GetCurColumnId() ) ) ),
2505 : : Any()
2506 [ # # ][ # # ]: 0 : );
[ # # ]
2507 : 0 : }
2508 : :
2509 : : //-------------------------------------------------------------------
2510 : :
2511 : 0 : void BrowseBox::LoseFocus()
2512 : : {
2513 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2514 : : OSL_TRACE( "BrowseBox: %p->LoseFocus", this );
2515 : :
2516 [ # # ]: 0 : if ( bHasFocus )
2517 : : {
2518 : : OSL_TRACE( "BrowseBox: %p->HideCursor", this );
2519 : 0 : DoHideCursor( "LoseFocus" );
2520 : :
2521 [ # # ]: 0 : if ( !bKeepHighlight )
2522 : : {
2523 : 0 : ToggleSelection();
2524 : 0 : bSelectionIsVisible = sal_False;
2525 : : }
2526 : :
2527 : 0 : bHasFocus = sal_False;
2528 : : }
2529 : 0 : Control::LoseFocus();
2530 : 0 : }
2531 : :
2532 : : //-------------------------------------------------------------------
2533 : :
2534 : 0 : void BrowseBox::GetFocus()
2535 : : {
2536 : : DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
2537 : : OSL_TRACE( "BrowseBox: %p->GetFocus", this );
2538 : :
2539 [ # # ]: 0 : if ( !bHasFocus )
2540 : : {
2541 [ # # ]: 0 : if ( !bSelectionIsVisible )
2542 : : {
2543 : 0 : bSelectionIsVisible = sal_True;
2544 [ # # ]: 0 : if ( bBootstrapped )
2545 : 0 : ToggleSelection();
2546 : : }
2547 : :
2548 : 0 : bHasFocus = sal_True;
2549 : 0 : DoShowCursor( "GetFocus" );
2550 : : }
2551 : 0 : Control::GetFocus();
2552 : 0 : }
2553 : :
2554 : :
2555 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|