xref: /trunk/main/svtools/source/brwbox/editbrowsebox.cxx (revision ca62e2c2083b5d0995f1245bad6c2edfb455fbec)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svtools.hxx"
26 #include <svtools/editbrowsebox.hxx>
27 
28 #ifndef _SVTOOLS_EDITBROWSEBOX_HRC_
29 #include "editbrowsebox.hrc"
30 #endif
31 
32 #ifndef _APP_HXX //autogen
33 #include <vcl/svapp.hxx>
34 #endif
35 #include <tools/debug.hxx>
36 #include <vcl/window.hxx>
37 
38 #ifndef _EDIT_HXX //autogen
39 #include <vcl/edit.hxx>
40 #endif
41 #include <tools/resid.hxx>
42 #include <vcl/spinfld.hxx>
43 #include <svtools/svtdata.hxx>
44 
45 #ifndef _SVTOOLS_HRC
46 #include <svtools/svtools.hrc>
47 #endif
48 
49 #include <algorithm>
50 #include <tools/multisel.hxx>
51 #include "editbrowseboximpl.hxx"
52 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
53 #include <com/sun/star/accessibility/XAccessible.hpp>
54 #include <comphelper/types.hxx>
55 
56 // .......................................................................
57 namespace svt
58 {
59 // .......................................................................
60     namespace
61     {
62         //..............................................................
63         sal_Bool isHiContrast(Window* _pWindow)
64         {
65             OSL_ENSURE(_pWindow,"Window must be not null!");
66             return _pWindow && _pWindow->GetSettings().GetStyleSettings().GetHighContrastMode();
67         }
68 
69         //..............................................................
70         sal_uInt16 getRealGetFocusFlags( Window* _pWindow )
71         {
72             sal_uInt16 nFlags = 0;
73             while ( _pWindow && !nFlags )
74             {
75                 nFlags = _pWindow->GetGetFocusFlags( );
76                 _pWindow = _pWindow->GetParent();
77             }
78             return nFlags;
79         }
80     }
81 
82     using namespace ::com::sun::star::uno;
83     using namespace com::sun::star::accessibility::AccessibleEventId;
84     using  com::sun::star::accessibility::XAccessible;
85     //==================================================================
86 
87     #define HANDLE_ID   0
88 
89     //==================================================================
90     //= EditBrowserHeader
91     //==================================================================
92     //------------------------------------------------------------------------------
93     void EditBrowserHeader::DoubleClick()
94     {
95         sal_uInt16 nColId = GetCurItemId();
96         if (nColId)
97         {
98             sal_uInt32 nAutoWidth = ((EditBrowseBox*)GetParent())->GetAutoColumnWidth(nColId);
99             if (nAutoWidth != ((EditBrowseBox*)GetParent())->GetColumnWidth(nColId))
100             {
101                 ((EditBrowseBox*)GetParent())->SetColumnWidth(nColId, nAutoWidth);
102                 ((EditBrowseBox*)GetParent())->ColumnResized(nColId);
103             }
104         }
105     }
106 
107 
108     //==================================================================
109     //= EditBrowseBox
110     //==================================================================
111     //------------------------------------------------------------------------------
112     void EditBrowseBox::BrowserMouseEventPtr::Clear()
113     {
114         DELETEZ(pEvent);
115     }
116 
117     //------------------------------------------------------------------------------
118     void EditBrowseBox::BrowserMouseEventPtr::Set(const BrowserMouseEvent* pEvt, sal_Bool bIsDown)
119     {
120         if (pEvt == pEvent)
121         {
122             bDown = bIsDown;
123             return;
124         }
125         Clear();
126         if (pEvt)
127         {
128             pEvent = new BrowserMouseEvent(pEvt->GetWindow(),
129                                            *pEvt,
130                                            pEvt->GetRow(),
131                                            pEvt->GetColumn(),
132                                            pEvt->GetColumnId(),
133                                            pEvt->GetRect());
134             bDown = bIsDown;
135         }
136     }
137 
138     //------------------------------------------------------------------------------
139     DBG_NAME(EditBrowseBox);
140     void EditBrowseBox::impl_construct()
141     {
142         m_aImpl = ::std::auto_ptr<EditBrowseBoxImpl>(new EditBrowseBoxImpl());
143         m_aImpl->m_bHiContrast = isHiContrast(&GetDataWindow());
144 
145         SetCompoundControl(sal_True);
146         SetGridLineColor( Color( COL_LIGHTGRAY ) );
147 
148         ImplInitSettings(sal_True, sal_True, sal_True);
149 
150         pCheckBoxPaint = new CheckBoxControl(&GetDataWindow());
151         pCheckBoxPaint->SetPaintTransparent( sal_True );
152         pCheckBoxPaint->SetBackground();
153     }
154 
155     //------------------------------------------------------------------------------
156     EditBrowseBox::EditBrowseBox(Window* pParent, const ResId& rId, sal_Int32 nBrowserFlags, BrowserMode _nMode )
157                   :BrowseBox( pParent, rId, _nMode )
158                   ,nStartEvent(0)
159                   ,nEndEvent(0)
160                   ,nCellModifiedEvent(0)
161                   ,nPaintRow(-1)
162                   ,nEditRow(-1)
163                   ,nOldEditRow(-1)
164                   ,nEditCol(0)
165                   ,nOldEditCol(0)
166                   ,bHasFocus(sal_False)
167                   ,bPaintStatus(sal_True)
168                   ,bActiveBeforeTracking( sal_False )
169                   ,m_nBrowserFlags(nBrowserFlags)
170     {
171         DBG_CTOR(EditBrowseBox,NULL);
172 
173         impl_construct();
174     }
175 
176     //==================================================================
177     EditBrowseBox::EditBrowseBox( Window* pParent, sal_Int32 nBrowserFlags, WinBits nBits, BrowserMode _nMode )
178                   :BrowseBox( pParent, nBits, _nMode )
179                   ,nStartEvent(0)
180                   ,nEndEvent(0)
181                   ,nCellModifiedEvent(0)
182                   ,nPaintRow(-1)
183                   ,nEditRow(-1)
184                   ,nOldEditRow(-1)
185                   ,nEditCol(0)
186                   ,nOldEditCol(0)
187                   ,bHasFocus(sal_False)
188                   ,bPaintStatus(sal_True)
189                   ,bActiveBeforeTracking( sal_False )
190                   ,m_nBrowserFlags(nBrowserFlags)
191                   ,pHeader(NULL)
192     {
193         DBG_CTOR(EditBrowseBox,NULL);
194 
195         impl_construct();
196     }
197 
198     //------------------------------------------------------------------------------
199     void EditBrowseBox::Init()
200     {
201         // spaetes Construieren,
202     }
203 
204     //------------------------------------------------------------------------------
205     EditBrowseBox::~EditBrowseBox()
206     {
207         if (nStartEvent)
208             Application::RemoveUserEvent(nStartEvent);
209         if (nEndEvent)
210             Application::RemoveUserEvent(nEndEvent);
211         if (nCellModifiedEvent)
212             Application::RemoveUserEvent(nCellModifiedEvent);
213 
214         delete pCheckBoxPaint;
215 
216         DBG_DTOR(EditBrowseBox,NULL);
217     }
218 
219     //------------------------------------------------------------------------------
220     void EditBrowseBox::RemoveRows()
221     {
222         BrowseBox::Clear();
223         nOldEditRow = nEditRow = nPaintRow = -1;
224         nEditCol = nOldEditCol = 0;
225     }
226 
227     //------------------------------------------------------------------------------
228     BrowserHeader* EditBrowseBox::CreateHeaderBar(BrowseBox* pParent)
229     {
230         pHeader = imp_CreateHeaderBar(pParent);
231         if (!IsUpdateMode())
232             pHeader->SetUpdateMode(sal_False);
233         return pHeader;
234     }
235 
236     //------------------------------------------------------------------------------
237     BrowserHeader* EditBrowseBox::imp_CreateHeaderBar(BrowseBox* pParent)
238     {
239         return new EditBrowserHeader(pParent);
240     }
241 
242     //------------------------------------------------------------------------------
243     void EditBrowseBox::LoseFocus()
244     {
245         BrowseBox::LoseFocus();
246         DetermineFocus( 0 );
247     }
248 
249     //------------------------------------------------------------------------------
250     void EditBrowseBox::GetFocus()
251     {
252         BrowseBox::GetFocus();
253 
254         // This should handle the case that the BrowseBox (or one of it's children)
255         // gets the focus from outside by pressing Tab
256         if (IsEditing() && Controller()->GetWindow().IsVisible())
257             Controller()->GetWindow().GrabFocus();
258 
259         DetermineFocus( getRealGetFocusFlags( this ) );
260     }
261 
262     //------------------------------------------------------------------------------
263     sal_Bool EditBrowseBox::SeekRow(long nRow)
264     {
265         nPaintRow = nRow;
266         return sal_True;
267     }
268 
269     //------------------------------------------------------------------------------
270     IMPL_LINK(EditBrowseBox, StartEditHdl, void*, EMPTYARG)
271     {
272         nStartEvent = 0;
273         if (IsEditing())
274         {
275             EnableAndShow();
276             if (!aController->GetWindow().HasFocus() && (m_pFocusWhileRequest == Application::GetFocusWindow()))
277                 aController->GetWindow().GrabFocus();
278         }
279         return 0;
280     }
281 
282     //------------------------------------------------------------------------------
283     void EditBrowseBox::PaintField( OutputDevice& rDev, const Rectangle& rRect,
284                                     sal_uInt16 nColumnId ) const
285     {
286         if (nColumnId == HANDLE_ID)
287         {
288             if (bPaintStatus)
289                 PaintStatusCell(rDev, rRect);
290         }
291         else
292         {
293             // don't paint the current cell
294             if (&rDev == &GetDataWindow())
295                 // but only if we're painting onto our data win (which is the usual painting)
296                 if (nPaintRow == nEditRow)
297                 {
298                     if (IsEditing() && nEditCol == nColumnId && aController->GetWindow().IsVisible())
299                         return;
300                 }
301             PaintCell(rDev, rRect, nColumnId);
302         }
303     }
304 
305     //------------------------------------------------------------------------------
306     Image EditBrowseBox::GetImage(RowStatus eStatus) const
307     {
308         sal_Bool bHiContrast = isHiContrast(&GetDataWindow());
309         if ( !m_aStatusImages.GetImageCount() || (bHiContrast != m_aImpl->m_bHiContrast) )
310         {
311             m_aImpl->m_bHiContrast = bHiContrast;
312             const_cast<EditBrowseBox*>(this)->m_aStatusImages = ImageList(SvtResId(bHiContrast ? RID_SVTOOLS_IMAGELIST_EDITBWSEBOX_H : RID_SVTOOLS_IMAGELIST_EDITBROWSEBOX));
313         }
314 
315         Image aImage;
316         bool bNeedMirror = IsRTLEnabled();
317         switch (eStatus)
318         {
319             case CURRENT:
320                 aImage = m_aStatusImages.GetImage(IMG_EBB_CURRENT);
321                 break;
322             case CURRENTNEW:
323                 aImage = m_aStatusImages.GetImage(IMG_EBB_CURRENTNEW);
324                 break;
325             case MODIFIED:
326                 aImage = m_aStatusImages.GetImage(IMG_EBB_MODIFIED);
327                 bNeedMirror = false;    // the pen is not mirrored
328                 break;
329             case NEW:
330                 aImage = m_aStatusImages.GetImage(IMG_EBB_NEW);
331                 break;
332             case DELETED:
333                 aImage = m_aStatusImages.GetImage(IMG_EBB_DELETED);
334                 break;
335             case PRIMARYKEY:
336                 aImage = m_aStatusImages.GetImage(IMG_EBB_PRIMARYKEY);
337                 break;
338             case CURRENT_PRIMARYKEY:
339                 aImage = m_aStatusImages.GetImage(IMG_EBB_CURRENT_PRIMARYKEY);
340                 break;
341             case FILTER:
342                 aImage = m_aStatusImages.GetImage(IMG_EBB_FILTER);
343                 break;
344             case HEADERFOOTER:
345                 aImage = m_aStatusImages.GetImage(IMG_EBB_HEADERFOOTER);
346                 break;
347             case CLEAN:
348                 break;
349         }
350         if ( bNeedMirror )
351         {
352             BitmapEx aBitmap( aImage.GetBitmapEx() );
353             aBitmap.Mirror( BMP_MIRROR_HORZ );
354             aImage = Image( aBitmap );
355         }
356         return aImage;
357     }
358 
359     //------------------------------------------------------------------------------
360     void EditBrowseBox::PaintStatusCell(OutputDevice& rDev, const Rectangle& rRect) const
361     {
362         if (nPaintRow < 0)
363             return;
364 
365         RowStatus eStatus = GetRowStatus( nPaintRow );
366         sal_Int32 nBrowserFlags = GetBrowserFlags();
367 
368         if (nBrowserFlags & EBBF_NO_HANDLE_COLUMN_CONTENT)
369             return;
370 
371         // draw the text of the header column
372         if (nBrowserFlags & EBBF_HANDLE_COLUMN_TEXT )
373         {
374             rDev.DrawText( rRect, GetCellText( nPaintRow, 0 ),
375                            TEXT_DRAW_CENTER | TEXT_DRAW_VCENTER | TEXT_DRAW_CLIP );
376         }
377         // draw an image
378         else if (eStatus != CLEAN && rDev.GetOutDevType() == OUTDEV_WINDOW)
379         {
380             Image aImage(GetImage(eStatus));
381             // calc the image position
382             Size aImageSize(aImage.GetSizePixel());
383             aImageSize.Width() = CalcZoom(aImageSize.Width());
384             aImageSize.Height() = CalcZoom(aImageSize.Height());
385             Point aPos( rRect.TopLeft() );
386 
387             if ( ( aImageSize.Width() > rRect.GetWidth() ) || ( aImageSize.Height() > rRect.GetHeight() ) )
388                 rDev.SetClipRegion(rRect);
389 
390             if ( aImageSize.Width() < rRect.GetWidth() )
391                 aPos.X() += ( rRect.GetWidth() - aImageSize.Width() ) / 2;
392 
393             if ( aImageSize.Height() < rRect.GetHeight() )
394                 aPos.Y() += ( rRect.GetHeight() - aImageSize.Height() ) / 2;
395 
396             if ( IsZoom() )
397                 rDev.DrawImage( aPos, aImageSize, aImage, 0 );
398             else
399                 rDev.DrawImage( aPos, aImage, 0 );
400 
401             if (rDev.IsClipRegion())
402                 rDev.SetClipRegion();
403         }
404     }
405 
406     //------------------------------------------------------------------------------
407     void EditBrowseBox::ImplStartTracking()
408     {
409         bActiveBeforeTracking = IsEditing();
410         if ( bActiveBeforeTracking )
411         {
412             DeactivateCell();
413             Update();
414         }
415 
416         BrowseBox::ImplStartTracking();
417     }
418 
419     //------------------------------------------------------------------------------
420     void EditBrowseBox::ImplTracking()
421     {
422         BrowseBox::ImplTracking();
423     }
424 
425     //------------------------------------------------------------------------------
426     void EditBrowseBox::ImplEndTracking()
427     {
428         if ( bActiveBeforeTracking )
429             ActivateCell();
430         bActiveBeforeTracking = sal_False;
431 
432         BrowseBox::ImplEndTracking();
433     }
434 
435     //------------------------------------------------------------------------------
436     void EditBrowseBox::RowHeightChanged()
437     {
438         if ( IsEditing() )
439         {
440             Rectangle aRect( GetCellRect( nEditRow, nEditCol, sal_False ) );
441             CellControllerRef aCellController( Controller() );
442             ResizeController( aCellController, aRect );
443             aCellController->GetWindow().GrabFocus();
444         }
445 
446         BrowseBox::RowHeightChanged();
447     }
448 
449     //------------------------------------------------------------------------------
450     EditBrowseBox::RowStatus EditBrowseBox::GetRowStatus(long) const
451     {
452         return CLEAN;
453     }
454 
455     //------------------------------------------------------------------------------
456     void EditBrowseBox::KeyInput( const KeyEvent& rEvt )
457     {
458         sal_uInt16 nCode = rEvt.GetKeyCode().GetCode();
459         sal_Bool   bShift = rEvt.GetKeyCode().IsShift();
460         sal_Bool   bCtrl = rEvt.GetKeyCode().IsMod1();
461 
462         switch (nCode)
463         {
464             case KEY_RETURN:
465                 if (!bCtrl && !bShift && IsTabAllowed(sal_True))
466                 {
467                     Dispatch(BROWSER_CURSORRIGHT);
468                 }
469                 else
470                     BrowseBox::KeyInput(rEvt);
471                 return;
472             case KEY_TAB:
473                 if (!bCtrl && !bShift)
474                 {
475                     if (IsTabAllowed(sal_True))
476                         Dispatch(BROWSER_CURSORRIGHT);
477                     else
478                         // do NOT call BrowseBox::KeyInput : this would handle the tab, but we already now
479                         // that tab isn't allowed here. So give the Control class a chance
480                         Control::KeyInput(rEvt);
481                     return;
482                 }
483                 else if (!bCtrl && bShift)
484                 {
485                     if (IsTabAllowed(sal_False))
486                         Dispatch(BROWSER_CURSORLEFT);
487                     else
488                         // do NOT call BrowseBox::KeyInput : this would handle the tab, but we already now
489                         // that tab isn't allowed here. So give the Control class a chance
490                         Control::KeyInput(rEvt);
491                     return;
492                 }
493             default:
494                 BrowseBox::KeyInput(rEvt);
495         }
496     }
497 
498     //------------------------------------------------------------------------------
499     void EditBrowseBox::MouseButtonDown(const BrowserMouseEvent& rEvt)
500     {
501         sal_uInt16  nColPos = GetColumnPos( rEvt.GetColumnId() );
502         long    nRow    = rEvt.GetRow();
503 
504         // absorb double clicks
505         if (rEvt.GetClicks() > 1 && rEvt.GetRow() >= 0)
506             return;
507 
508         // change to a new position
509         if (IsEditing() && (nColPos != nEditCol || nRow != nEditRow) && (nColPos != BROWSER_INVALIDID) && (nRow < GetRowCount()))
510         {
511             CellControllerRef aCellController(Controller());
512             HideAndDisable(aCellController);
513         }
514 
515         // we are about to leave the current cell. If there is a "this cell has been modified" notification
516         // pending (asynchronously), this may be deadly -> do it synchronously
517         // 95826 - 2002-10-14 - fs@openoffice.org
518         if ( nCellModifiedEvent )
519         {
520             Application::RemoveUserEvent( nCellModifiedEvent );
521             nCellModifiedEvent = 0;
522             LINK( this, EditBrowseBox, CellModifiedHdl ).Call( NULL );
523         }
524 
525         if (0 == rEvt.GetColumnId())
526         {   // it was the handle column. save the current cell content if necessary
527             // (clicking on the handle column results in selecting the current row)
528             // 23.01.2001 - 82797 - FS
529             if (IsEditing() && aController->IsModified())
530                 SaveModified();
531         }
532 
533         aMouseEvent.Set(&rEvt,sal_True);
534         BrowseBox::MouseButtonDown(rEvt);
535         aMouseEvent.Clear();
536 
537         if (0 != (m_nBrowserFlags & EBBF_ACTIVATE_ON_BUTTONDOWN))
538         {
539             // the base class does not travel upon MouseButtonDown, but implActivateCellOnMouseEvent assumes we traveled ...
540             GoToRowColumnId( rEvt.GetRow(), rEvt.GetColumnId() );
541             if (rEvt.GetRow() >= 0)
542                 implActivateCellOnMouseEvent(rEvt, sal_False);
543         }
544     }
545 
546     //------------------------------------------------------------------------------
547     void EditBrowseBox::MouseButtonUp( const BrowserMouseEvent& rEvt )
548     {
549         // absorb double clicks
550         if (rEvt.GetClicks() > 1 && rEvt.GetRow() >= 0)
551             return;
552 
553         aMouseEvent.Set(&rEvt,sal_False);
554         BrowseBox::MouseButtonUp(rEvt);
555         aMouseEvent.Clear();
556 
557         if (0 == (m_nBrowserFlags & EBBF_ACTIVATE_ON_BUTTONDOWN))
558             if (rEvt.GetRow() >= 0)
559                 implActivateCellOnMouseEvent(rEvt, sal_True);
560     }
561 
562     //------------------------------------------------------------------------------
563     void EditBrowseBox::implActivateCellOnMouseEvent(const BrowserMouseEvent& _rEvt, sal_Bool _bUp)
564     {
565         if (!IsEditing())
566             ActivateCell();
567         else if (IsEditing() && !aController->GetWindow().IsEnabled())
568             DeactivateCell();
569         else if (IsEditing() && !aController->GetWindow().HasChildPathFocus())
570             AsynchGetFocus();
571 
572         if (IsEditing() && aController->GetWindow().IsEnabled() && aController->WantMouseEvent())
573         {   // forwards the event to the control
574 
575             // If the field has been moved previously, we have to adjust the position
576 
577             aController->GetWindow().GrabFocus();
578 
579             // the position of the event relative to the controller's window
580             Point aPos = _rEvt.GetPosPixel() - _rEvt.GetRect().TopLeft();
581             // the (child) window which should really get the event
582             Window* pRealHandler = aController->GetWindow().FindWindow(aPos);
583             if (pRealHandler)
584                 // the coords relative to this real handler
585                 aPos -= pRealHandler->GetPosPixel();
586             else
587                 pRealHandler = &aController->GetWindow();
588 
589             // the faked event
590             MouseEvent aEvent(aPos, _rEvt.GetClicks(), _rEvt.GetMode(),
591                               _rEvt.GetButtons(),
592                               _rEvt.GetModifier());
593 
594             pRealHandler->MouseButtonDown(aEvent);
595             if (_bUp)
596                 pRealHandler->MouseButtonUp(aEvent);
597 
598             Window *pWin = &aController->GetWindow();
599             if (!pWin->IsTracking())
600             {
601                 for (pWin = pWin->GetWindow(WINDOW_FIRSTCHILD);
602                      pWin && !pWin->IsTracking();
603                      pWin = pWin->GetWindow(WINDOW_NEXT))
604                 {
605                 }
606             }
607             if (pWin && pWin->IsTracking())
608                 pWin->EndTracking();
609         }
610     }
611 
612     //------------------------------------------------------------------------------
613     void EditBrowseBox::Dispatch( sal_uInt16 _nId )
614     {
615         if ( _nId == BROWSER_ENHANCESELECTION )
616         {   // this is a workaround for the bug in the base class:
617             // if the row selection is to be extended (which is what BROWSER_ENHANCESELECTION tells us)
618             // then the base class does not revert any column selections, while, for doing a "simple"
619             // selection (BROWSER_SELECT), it does. In fact, it does not only revert the col selection then,
620             // but also any current row selections.
621             // This clearly tells me that the both ids are for row selection only - there this behaviour does
622             // make sense.
623             // But here, where we have column selection, too, we take care of this ourself.
624             if ( GetSelectColumnCount( ) )
625             {
626                 while ( GetSelectColumnCount( ) )
627                     SelectColumnPos(
628                         sal::static_int_cast< sal_uInt16 >(FirstSelectedColumn()),
629                         sal_False );
630                 Select();
631             }
632         }
633         BrowseBox::Dispatch( _nId );
634     }
635 
636     //------------------------------------------------------------------------------
637     long EditBrowseBox::PreNotify(NotifyEvent& rEvt)
638     {
639         switch (rEvt.GetType())
640         {
641             case EVENT_KEYINPUT:
642                 if  (   (IsEditing() && Controller()->GetWindow().HasChildPathFocus())
643                     ||  rEvt.GetWindow() == &GetDataWindow()
644                     ||  (!IsEditing() && HasChildPathFocus())
645                     )
646                 {
647                     const KeyEvent* pKeyEvent = rEvt.GetKeyEvent();
648                     sal_uInt16 nCode  = pKeyEvent->GetKeyCode().GetCode();
649                     sal_Bool   bShift = pKeyEvent->GetKeyCode().IsShift();
650                     sal_Bool   bCtrl  = pKeyEvent->GetKeyCode().IsMod1();
651                     sal_Bool   bAlt =   pKeyEvent->GetKeyCode().IsMod2();
652                     sal_Bool   bLocalSelect=    sal_False;
653                     sal_Bool   bNonEditOnly =   sal_False;
654                     sal_uInt16 nId = BROWSER_NONE;
655 
656                     if (!bAlt && !bCtrl && !bShift )
657                         switch ( nCode )
658                         {
659                             case KEY_DOWN:          nId = BROWSER_CURSORDOWN; break;
660                             case KEY_UP:            nId = BROWSER_CURSORUP; break;
661                             case KEY_PAGEDOWN:      nId = BROWSER_CURSORPAGEDOWN; break;
662                             case KEY_PAGEUP:        nId = BROWSER_CURSORPAGEUP; break;
663                             case KEY_HOME:          nId = BROWSER_CURSORHOME; break;
664                             case KEY_END:           nId = BROWSER_CURSOREND; break;
665 
666                             case KEY_TAB:
667                                 // ask if traveling to the next cell is allowed
668                                 if (IsTabAllowed(sal_True))
669                                     nId = BROWSER_CURSORRIGHT;
670                                 break;
671 
672                             case KEY_RETURN:
673                                 // save the cell content (if necessary)
674                                 if (IsEditing() && aController->IsModified() && !((EditBrowseBox *) this)->SaveModified())
675                                 {
676                                     // maybe we're not visible ...
677                                     EnableAndShow();
678                                     aController->GetWindow().GrabFocus();
679                                     return 1;
680                                 }
681                                 // ask if traveling to the next cell is allowed
682                                 if (IsTabAllowed(sal_True))
683                                     nId = BROWSER_CURSORRIGHT;
684 
685                                 break;
686                             case KEY_RIGHT:         nId = BROWSER_CURSORRIGHT; break;
687                             case KEY_LEFT:          nId = BROWSER_CURSORLEFT; break;
688                             case KEY_SPACE:         nId = BROWSER_SELECT; bNonEditOnly = bLocalSelect = sal_True;break;
689                         }
690 
691                     if ( !bAlt && !bCtrl && bShift )
692                         switch ( nCode )
693                         {
694                             case KEY_DOWN:          nId = BROWSER_SELECTDOWN; bLocalSelect = sal_True;break;
695                             case KEY_UP:            nId = BROWSER_SELECTUP; bLocalSelect = sal_True;break;
696                             case KEY_HOME:          nId = BROWSER_SELECTHOME; bLocalSelect = sal_True;break;
697                             case KEY_END:           nId = BROWSER_SELECTEND; bLocalSelect = sal_True;break;
698                             case KEY_TAB:
699                                 if (IsTabAllowed(sal_False))
700                                     nId = BROWSER_CURSORLEFT;
701                                 break;
702                         }
703 
704                     if ( !bAlt && bCtrl && bShift )
705                         switch ( nCode )
706                         {
707                             case KEY_SPACE:         nId = BROWSER_SELECTCOLUMN; bLocalSelect = sal_True; break;
708                         }
709 
710 
711                     if ( !bAlt && bCtrl && !bShift )
712                         switch ( nCode )
713                         {
714                             case KEY_DOWN:          nId = BROWSER_SCROLLUP; break;
715                             case KEY_UP:            nId = BROWSER_SCROLLDOWN; break;
716                             case KEY_PAGEDOWN:      nId = BROWSER_CURSORENDOFFILE; break;
717                             case KEY_PAGEUP:        nId = BROWSER_CURSORTOPOFFILE; break;
718                             case KEY_HOME:          nId = BROWSER_CURSORTOPOFSCREEN; break;
719                             case KEY_END:           nId = BROWSER_CURSORENDOFSCREEN; break;
720                             case KEY_SPACE:         nId = BROWSER_ENHANCESELECTION; bLocalSelect = sal_True;break;
721                         }
722 
723 
724                     if  (   ( nId != BROWSER_NONE )
725                         &&  (   !IsEditing()
726                             ||  (   !bNonEditOnly
727                                 &&  aController->MoveAllowed( *pKeyEvent )
728                                 )
729                             )
730                         )
731                     {
732                         if (nId == BROWSER_SELECT || BROWSER_SELECTCOLUMN == nId )
733                         {
734                             // save the cell content (if necessary)
735                             if (IsEditing() && aController->IsModified() && !((EditBrowseBox *) this)->SaveModified())
736                             {
737                                 // maybe we're not visible ...
738                                 EnableAndShow();
739                                 aController->GetWindow().GrabFocus();
740                                 return 1;
741                             }
742                         }
743 
744                         Dispatch(nId);
745 
746                         if (bLocalSelect && (GetSelectRowCount() || GetSelection() != NULL))
747                             DeactivateCell();
748                         return 1;
749                     }
750                 }
751         }
752         return BrowseBox::PreNotify(rEvt);
753     }
754 
755     //------------------------------------------------------------------------------
756     sal_Bool EditBrowseBox::IsTabAllowed(sal_Bool) const
757     {
758         return sal_True;
759     }
760 
761     //------------------------------------------------------------------------------
762     long EditBrowseBox::Notify(NotifyEvent& rEvt)
763     {
764         switch (rEvt.GetType())
765         {
766             case EVENT_GETFOCUS:
767                 DetermineFocus( getRealGetFocusFlags( this ) );
768                 break;
769 
770             case EVENT_LOSEFOCUS:
771                 DetermineFocus( 0 );
772                 break;
773         }
774         return BrowseBox::Notify(rEvt);
775     }
776 
777     //------------------------------------------------------------------------------
778     void EditBrowseBox::StateChanged( StateChangedType nType )
779     {
780         BrowseBox::StateChanged( nType );
781 
782         bool bNeedCellReActivation = false;
783         if ( nType == STATE_CHANGE_MIRRORING )
784         {
785             bNeedCellReActivation = true;
786         }
787         else if ( nType == STATE_CHANGE_ZOOM )
788         {
789             ImplInitSettings( sal_True, sal_False, sal_False );
790             bNeedCellReActivation = true;
791         }
792         else if ( nType == STATE_CHANGE_CONTROLFONT )
793         {
794             ImplInitSettings( sal_True, sal_False, sal_False );
795             Invalidate();
796         }
797         else if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
798         {
799             ImplInitSettings( sal_False, sal_True, sal_False );
800             Invalidate();
801         }
802         else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
803         {
804             ImplInitSettings( sal_False, sal_False, sal_True );
805             Invalidate();
806         }
807         else if (nType == STATE_CHANGE_STYLE)
808         {
809             WinBits nStyle = GetStyle();
810             if (!(nStyle & WB_NOTABSTOP) )
811                 nStyle |= WB_TABSTOP;
812 
813             SetStyle(nStyle);
814         }
815         if ( bNeedCellReActivation )
816         {
817             if ( IsEditing() )
818             {
819                 DeactivateCell();
820                 ActivateCell();
821             }
822         }
823     }
824 
825     //------------------------------------------------------------------------------
826     void EditBrowseBox::DataChanged( const DataChangedEvent& rDCEvt )
827     {
828         BrowseBox::DataChanged( rDCEvt );
829 
830         if ((( rDCEvt.GetType() == DATACHANGED_SETTINGS )   ||
831             ( rDCEvt.GetType() == DATACHANGED_DISPLAY   ))  &&
832             ( rDCEvt.GetFlags() & SETTINGS_STYLE        ))
833         {
834             ImplInitSettings( sal_True, sal_True, sal_True );
835             Invalidate();
836         }
837     }
838 
839     //------------------------------------------------------------------------------
840     void EditBrowseBox::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
841     {
842         const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
843 
844         if (bFont)
845         {
846             Font aFont = rStyleSettings.GetFieldFont();
847             if (IsControlFont())
848             {
849                 GetDataWindow().SetControlFont(GetControlFont());
850                 aFont.Merge(GetControlFont());
851             }
852             else
853                 GetDataWindow().SetControlFont();
854 
855             GetDataWindow().SetZoomedPointFont(aFont);
856         }
857 
858         if ( bFont || bForeground )
859         {
860             Color aTextColor = rStyleSettings.GetFieldTextColor();
861             if (IsControlForeground())
862             {
863                 aTextColor = GetControlForeground();
864                 GetDataWindow().SetControlForeground(aTextColor);
865             }
866             else
867                 GetDataWindow().SetControlForeground();
868 
869             GetDataWindow().SetTextColor( aTextColor );
870         }
871 
872         if ( bBackground )
873         {
874             if (GetDataWindow().IsControlBackground())
875             {
876                 GetDataWindow().SetControlBackground(GetControlBackground());
877                 GetDataWindow().SetBackground(GetDataWindow().GetControlBackground());
878                 GetDataWindow().SetFillColor(GetDataWindow().GetControlBackground());
879             }
880             else
881             {
882                 GetDataWindow().SetControlBackground();
883                 GetDataWindow().SetBackground( rStyleSettings.GetFieldColor() );
884                 GetDataWindow().SetFillColor( rStyleSettings.GetFieldColor() );
885             }
886         }
887     }
888 
889     //------------------------------------------------------------------------------
890     sal_Bool EditBrowseBox::IsCursorMoveAllowed(long nNewRow, sal_uInt16 nNewColId) const
891     {
892         sal_uInt16 nInfo = 0;
893 
894         if (GetSelectColumnCount() || (aMouseEvent.Is() && aMouseEvent->GetRow() < 0))
895             nInfo |= COLSELECT;
896         if ((GetSelection() != NULL && GetSelectRowCount()) ||
897             (aMouseEvent.Is() && aMouseEvent->GetColumnId() == HANDLE_ID))
898             nInfo |= ROWSELECT;
899         if (!nInfo && nNewRow != nEditRow)
900             nInfo |= ROWCHANGE;
901         if (!nInfo && nNewColId != nEditCol)
902             nInfo |= COLCHANGE;
903 
904         if (nInfo == 0)   // nothing happened
905             return sal_True;
906 
907         // save the cell content
908         if (IsEditing() && aController->IsModified() && !((EditBrowseBox *) this)->SaveModified())
909         {
910             // maybe we're not visible ...
911             EnableAndShow();
912             aController->GetWindow().GrabFocus();
913             return sal_False;
914         }
915 
916         EditBrowseBox * pTHIS = (EditBrowseBox *) this;
917 
918         // save the cell content if
919         // a) a selection is beeing made
920         // b) the row is changing
921         if (IsModified() && (nInfo & (ROWCHANGE | COLSELECT | ROWSELECT)) &&
922             !pTHIS->SaveRow())
923         {
924             if (nInfo & COLSELECT ||
925                 nInfo & ROWSELECT)
926             {
927                 // cancel selected
928                 pTHIS->SetNoSelection();
929             }
930 
931             if (IsEditing())
932             {
933                 if (!Controller()->GetWindow().IsVisible())
934                 {
935                     EnableAndShow();
936                 }
937                 aController->GetWindow().GrabFocus();
938             }
939             return sal_False;
940         }
941 
942         if (nNewRow != nEditRow)
943         {
944             Window& rWindow = GetDataWindow();
945             // don't paint too much
946             // update the status immediatly if possible
947             if ((nEditRow >= 0) && (GetBrowserFlags() & EBBF_NO_HANDLE_COLUMN_CONTENT) == 0)
948             {
949                 Rectangle aRect = GetFieldRectPixel(nEditRow, 0, sal_False );
950                 // status cell should be painted if and only if text is displayed
951                 // note: bPaintStatus is mutable, but Solaris has problems with assigning
952                 // probably because it is part of a bitfield
953                 pTHIS->bPaintStatus = static_cast< sal_Bool >
954                     (( GetBrowserFlags() & EBBF_HANDLE_COLUMN_TEXT ) == EBBF_HANDLE_COLUMN_TEXT );
955                 rWindow.Paint(aRect);
956                 pTHIS->bPaintStatus = sal_True;
957             }
958 
959             // don't paint during row change
960             rWindow.EnablePaint(sal_False);
961 
962             // the last veto chance for derived classes
963             if (!pTHIS->CursorMoving(nNewRow, nNewColId))
964             {
965                 pTHIS->InvalidateStatusCell(nEditRow);
966                 rWindow.EnablePaint(sal_True);
967                 return sal_False;
968             }
969             else
970             {
971                 rWindow.EnablePaint(sal_True);
972                 return sal_True;
973             }
974         }
975         else
976             return pTHIS->CursorMoving(nNewRow, nNewColId);
977     }
978 
979     //------------------------------------------------------------------------------
980     void EditBrowseBox::ColumnMoved(sal_uInt16 nId)
981     {
982         BrowseBox::ColumnMoved(nId);
983         if (IsEditing())
984         {
985             Rectangle aRect( GetCellRect(nEditRow, nEditCol, sal_False));
986             CellControllerRef aControllerRef = Controller();
987             ResizeController(aControllerRef, aRect);
988             Controller()->GetWindow().GrabFocus();
989         }
990     }
991 
992     //------------------------------------------------------------------------------
993     sal_Bool EditBrowseBox::SaveRow()
994     {
995         return sal_True;
996     }
997 
998     //------------------------------------------------------------------------------
999     sal_Bool EditBrowseBox::CursorMoving(long, sal_uInt16)
1000     {
1001         ((EditBrowseBox *) this)->DeactivateCell(sal_False);
1002         return sal_True;
1003     }
1004 
1005     //------------------------------------------------------------------------------
1006     void EditBrowseBox::CursorMoved()
1007     {
1008         long nNewRow = GetCurRow();
1009         if (nEditRow != nNewRow)
1010         {
1011             if ((GetBrowserFlags() & EBBF_NO_HANDLE_COLUMN_CONTENT) == 0)
1012                 InvalidateStatusCell(nNewRow);
1013             nEditRow = nNewRow;
1014         }
1015         ActivateCell();
1016         GetDataWindow().EnablePaint(sal_True);
1017         // should not be called here because the descant event is not needed here
1018         //BrowseBox::CursorMoved();
1019     }
1020 
1021     //------------------------------------------------------------------------------
1022     void EditBrowseBox::EndScroll()
1023     {
1024         if (IsEditing())
1025         {
1026             Rectangle aRect = GetCellRect(nEditRow, nEditCol, sal_False);
1027             ResizeController(aController,aRect);
1028             AsynchGetFocus();
1029         }
1030         BrowseBox::EndScroll();
1031     }
1032 
1033     //------------------------------------------------------------------------------
1034     void EditBrowseBox::ActivateCell(long nRow, sal_uInt16 nCol, sal_Bool bCellFocus)
1035     {
1036         if (IsEditing())
1037             return;
1038 
1039         nEditCol = nCol;
1040 
1041         if ((GetSelectRowCount() && GetSelection() != NULL) || GetSelectColumnCount() ||
1042             (aMouseEvent.Is() && (aMouseEvent.IsDown() || aMouseEvent->GetClicks() > 1))) // bei MouseDown passiert noch nichts
1043         {
1044             return;
1045         }
1046 
1047         if (nEditRow >= 0 && nEditCol > HANDLE_ID)
1048         {
1049             aController = GetController(nRow, nCol);
1050             if (aController.Is())
1051             {
1052                 Rectangle aRect( GetCellRect(nEditRow, nEditCol, sal_False));
1053                 ResizeController(aController, aRect);
1054 
1055                 InitController(aController, nEditRow, nEditCol);
1056 
1057                 aController->ClearModified();
1058                 aController->SetModifyHdl(LINK(this,EditBrowseBox,ModifyHdl));
1059                 EnableAndShow();
1060 
1061                 if ( isAccessibleAlive() )
1062                     implCreateActiveAccessible();
1063 
1064                 // activate the cell only of the browser has the focus
1065                 if ( bHasFocus && bCellFocus )
1066                     AsynchGetFocus();
1067             }
1068             else
1069             {
1070                 // no controller -> we have a new "active descendant"
1071                 if ( isAccessibleAlive() && HasFocus() )
1072                 {
1073                     commitTableEvent(
1074                         ACTIVE_DESCENDANT_CHANGED,
1075 //IAccessibility2 Implementation 2009-----
1076                         //makeAny( CreateAccessibleCell( nRow, GetColumnPos( nCol ) ) ),
1077                         makeAny( CreateAccessibleCell( nRow, GetColumnPos( nCol -1) ) ),
1078 //-----IAccessibility2 Implementation 2009
1079                         Any()
1080                     );
1081                 }
1082             }
1083         }
1084     }
1085 
1086     //------------------------------------------------------------------------------
1087     void EditBrowseBox::DeactivateCell(sal_Bool bUpdate)
1088     {
1089         if (IsEditing())
1090         {
1091             if ( isAccessibleAlive() )
1092             {
1093                 commitBrowseBoxEvent( CHILD, Any(), makeAny( m_aImpl->m_xActiveCell ) );
1094                 m_aImpl->clearActiveCell();
1095             }
1096 
1097             aOldController = aController;
1098             aController.Clear();
1099 
1100             // reset the modify handler
1101             aOldController->SetModifyHdl(Link());
1102 
1103             if (bHasFocus)
1104                 GrabFocus(); // ensure that we have (and keep) the focus
1105 
1106             HideAndDisable(aOldController);
1107 
1108             // update if requested
1109             if (bUpdate)
1110                 Update();
1111 
1112             nOldEditCol = nEditCol;
1113             nOldEditRow = nEditRow;
1114 
1115             // release the controller (asynchronously)
1116             if (nEndEvent)
1117                 Application::RemoveUserEvent(nEndEvent);
1118             nEndEvent = Application::PostUserEvent(LINK(this,EditBrowseBox,EndEditHdl));
1119         }
1120     }
1121 
1122     //------------------------------------------------------------------------------
1123     Rectangle EditBrowseBox::GetCellRect(long nRow, sal_uInt16 nColId, sal_Bool bRel) const
1124     {
1125         Rectangle aRect( GetFieldRectPixel(nRow, nColId, bRel));
1126         if ((GetMode()  & BROWSER_CURSOR_WO_FOCUS) == BROWSER_CURSOR_WO_FOCUS)
1127         {
1128             aRect.Top() += 1;
1129             aRect.Bottom() -= 1;
1130         }
1131         return aRect;
1132     }
1133 
1134     //------------------------------------------------------------------------------
1135     IMPL_LINK(EditBrowseBox, EndEditHdl, void*, EMPTYARG)
1136     {
1137         nEndEvent = 0;
1138         ReleaseController(aOldController, nOldEditRow, nOldEditCol);
1139 
1140         aOldController  = CellControllerRef();
1141         nOldEditRow     = -1;
1142         nOldEditCol     =  0;
1143 
1144         return 0;
1145     }
1146 
1147     //------------------------------------------------------------------------------
1148     IMPL_LINK(EditBrowseBox, ModifyHdl, void*, EMPTYARG)
1149     {
1150         if (nCellModifiedEvent)
1151             Application::RemoveUserEvent(nCellModifiedEvent);
1152         nCellModifiedEvent = Application::PostUserEvent(LINK(this,EditBrowseBox,CellModifiedHdl));
1153         return 0;
1154     }
1155 
1156     //------------------------------------------------------------------------------
1157     IMPL_LINK(EditBrowseBox, CellModifiedHdl, void*, EMPTYARG)
1158     {
1159         nCellModifiedEvent = 0;
1160         CellModified();
1161         return 0;
1162     }
1163 
1164     //------------------------------------------------------------------------------
1165     void EditBrowseBox::ColumnResized( sal_uInt16 )
1166     {
1167         if (IsEditing())
1168         {
1169             Rectangle aRect( GetCellRect(nEditRow, nEditCol, sal_False));
1170             CellControllerRef aControllerRef = Controller();
1171             ResizeController(aControllerRef, aRect);
1172             Controller()->GetWindow().GrabFocus();
1173         }
1174     }
1175 
1176     //------------------------------------------------------------------------------
1177     sal_uInt16 EditBrowseBox::AppendColumn(const String& rName, sal_uInt16 nWidth, sal_uInt16 nPos, sal_uInt16 nId)
1178     {
1179         if (nId == (sal_uInt16)-1)
1180         {
1181             // look for the next free id
1182             for (nId = ColCount(); nId > 0 && GetColumnPos(nId) != BROWSER_INVALIDID; nId--)
1183                 ;
1184 
1185             if (!nId)
1186             {
1187                 // if there is no handle column
1188                 // increment the id
1189                 if (!ColCount() || GetColumnId(0))
1190                     nId = ColCount() + 1;
1191             }
1192         }
1193 
1194         DBG_ASSERT(nId, "EditBrowseBox::AppendColumn: invalid id!");
1195 
1196         long w = nWidth;
1197         if (!w)
1198             w = GetDefaultColumnWidth(rName);
1199 
1200         InsertDataColumn(nId, rName, w, (HIB_CENTER | HIB_VCENTER | HIB_CLICKABLE), nPos);
1201         return nId;
1202     }
1203 
1204     //------------------------------------------------------------------------------
1205     void EditBrowseBox::Resize()
1206     {
1207         BrowseBox::Resize();
1208 
1209         // if the window is smaller than "title line height" + "control area",
1210         // do nothing
1211         if (GetOutputSizePixel().Height() <
1212            (GetControlArea().GetHeight() + GetDataWindow().GetPosPixel().Y()))
1213             return;
1214 
1215         // the size of the control area
1216         Point aPoint(GetControlArea().TopLeft());
1217         sal_uInt16 nX = (sal_uInt16)aPoint.X();
1218 
1219         ArrangeControls(nX, (sal_uInt16)aPoint.Y());
1220 
1221         if (!nX)
1222             nX = USHRT_MAX;
1223         ReserveControlArea((sal_uInt16)nX);
1224     }
1225 
1226     //------------------------------------------------------------------------------
1227     void EditBrowseBox::ArrangeControls(sal_uInt16&, sal_uInt16)
1228     {
1229     }
1230 
1231     //------------------------------------------------------------------------------
1232     CellController* EditBrowseBox::GetController(long, sal_uInt16)
1233     {
1234         return NULL;
1235     }
1236 
1237     //-----------------------------------------------------------------------------
1238     void EditBrowseBox::ResizeController(CellControllerRef& rController, const Rectangle& rRect)
1239     {
1240         rController->GetWindow().SetPosSizePixel(rRect.TopLeft(), rRect.GetSize());
1241     }
1242 
1243     //------------------------------------------------------------------------------
1244     void EditBrowseBox::InitController(CellControllerRef&, long, sal_uInt16)
1245     {
1246     }
1247 
1248     //------------------------------------------------------------------------------
1249     void EditBrowseBox::ReleaseController(CellControllerRef&, long, sal_uInt16)
1250     {
1251     }
1252 
1253     //------------------------------------------------------------------------------
1254     void EditBrowseBox::CellModified()
1255     {
1256     }
1257 
1258 
1259     //------------------------------------------------------------------------------
1260     sal_Bool EditBrowseBox::SaveModified()
1261     {
1262         return sal_True;
1263     }
1264 
1265     //------------------------------------------------------------------------------
1266     void EditBrowseBox::DoubleClick(const BrowserMouseEvent& rEvt)
1267     {
1268         // when double clicking on the column, the optimum size will be calculated
1269         sal_uInt16 nColId = rEvt.GetColumnId();
1270         if (nColId != HANDLE_ID)
1271             SetColumnWidth(nColId, GetAutoColumnWidth(nColId));
1272     }
1273 
1274     //------------------------------------------------------------------------------
1275     sal_uInt32 EditBrowseBox::GetAutoColumnWidth(sal_uInt16 nColId)
1276     {
1277         sal_uInt32 nCurColWidth  = GetColumnWidth(nColId);
1278         sal_uInt32 nMinColWidth = CalcZoom(20); // minimum
1279         sal_uInt32 nNewColWidth = nMinColWidth;
1280         long nMaxRows      = Min(long(GetVisibleRows()), GetRowCount());
1281         long nLastVisRow   = GetTopRow() + nMaxRows - 1;
1282 
1283         if (GetTopRow() <= nLastVisRow) // calc the column with using the cell contents
1284         {
1285             for (long i = GetTopRow(); i <= nLastVisRow; ++i)
1286                 nNewColWidth = std::max(nNewColWidth,GetTotalCellWidth(i,nColId) + 12);
1287 
1288             if (nNewColWidth == nCurColWidth)   // size has not changed
1289                 nNewColWidth = GetDefaultColumnWidth(GetColumnTitle(nColId));
1290         }
1291         else
1292             nNewColWidth = GetDefaultColumnWidth(GetColumnTitle(nColId));
1293         return nNewColWidth;
1294     }
1295 
1296     //------------------------------------------------------------------------------
1297     sal_uInt32 EditBrowseBox::GetTotalCellWidth(long, sal_uInt16)
1298     {
1299         return 0;
1300     }
1301 
1302     //------------------------------------------------------------------------------
1303     void EditBrowseBox::InvalidateHandleColumn()
1304     {
1305         Rectangle aHdlFieldRect( GetFieldRectPixel( 0, 0 ));
1306         Rectangle aInvalidRect( Point(0,0), GetOutputSizePixel() );
1307         aInvalidRect.Right() = aHdlFieldRect.Right();
1308         Invalidate( aInvalidRect );
1309     }
1310 
1311     //------------------------------------------------------------------------------
1312     void EditBrowseBox::PaintTristate(OutputDevice&, const Rectangle& rRect,const TriState& eState,sal_Bool _bEnabled) const
1313     {
1314         pCheckBoxPaint->GetBox().SetState(eState);
1315         pCheckBoxPaint->SetPosSizePixel(rRect.TopLeft(), rRect.GetSize());
1316 
1317         // First update the parent, preventing that while painting this window
1318         // an update for the parent is done (because it's in the queue already)
1319         // which may lead to hiding this window immediately
1320 // #95598# comment out OJ
1321 /*      if (pCheckBoxPaint->GetParent())
1322             pCheckBoxPaint->GetParent()->Update();
1323 */
1324         pCheckBoxPaint->GetBox().Enable(_bEnabled);
1325         pCheckBoxPaint->Show();
1326         pCheckBoxPaint->SetParentUpdateMode( sal_False );
1327         pCheckBoxPaint->Update();
1328         pCheckBoxPaint->Hide();
1329         pCheckBoxPaint->SetParentUpdateMode( sal_True );
1330     }
1331 
1332     //------------------------------------------------------------------------------
1333     void EditBrowseBox::AsynchGetFocus()
1334     {
1335         if (nStartEvent)
1336             Application::RemoveUserEvent(nStartEvent);
1337 
1338         m_pFocusWhileRequest = Application::GetFocusWindow();
1339         nStartEvent = Application::PostUserEvent(LINK(this,EditBrowseBox,StartEditHdl));
1340     }
1341 
1342     //------------------------------------------------------------------------------
1343     void EditBrowseBox::SetBrowserFlags(sal_Int32 nFlags)
1344     {
1345         if (m_nBrowserFlags == nFlags)
1346             return;
1347 
1348         sal_Bool RowPicturesChanges = ((m_nBrowserFlags & EBBF_NO_HANDLE_COLUMN_CONTENT) !=
1349                                        (nFlags & EBBF_NO_HANDLE_COLUMN_CONTENT));
1350         m_nBrowserFlags = nFlags;
1351 
1352         if (RowPicturesChanges)
1353             InvalidateStatusCell(GetCurRow());
1354     }
1355     //------------------------------------------------------------------------------
1356     inline void EditBrowseBox::HideAndDisable(CellControllerRef& rController)
1357     {
1358         rController->suspend();
1359     }
1360     //------------------------------------------------------------------------------
1361     inline void EditBrowseBox::EnableAndShow() const
1362     {
1363         Controller()->resume();
1364     }
1365     //===============================================================================
1366 
1367     DBG_NAME(CellController);
1368     //------------------------------------------------------------------------------
1369     CellController::CellController(Control* pW)
1370                    :pWindow( pW )
1371                    ,bSuspended( sal_True )
1372     {
1373         DBG_CTOR(CellController,NULL);
1374 
1375         DBG_ASSERT(pWindow, "CellController::CellController: missing the window!");
1376         DBG_ASSERT(!pWindow->IsVisible(), "CellController::CellController: window should not be visible!");
1377     }
1378 
1379     //-----------------------------------------------------------------------------
1380     CellController::~CellController()
1381     {
1382 
1383         DBG_DTOR(CellController,NULL);
1384     }
1385 
1386     //-----------------------------------------------------------------------------
1387     void CellController::suspend( )
1388     {
1389         DBG_ASSERT( bSuspended == !GetWindow().IsVisible(), "CellController::suspend: inconsistence!" );
1390         if ( !isSuspended( ) )
1391         {
1392             CommitModifications();
1393             GetWindow().Hide( );
1394             GetWindow().Disable( );
1395             bSuspended = sal_True;
1396         }
1397     }
1398 
1399     //-----------------------------------------------------------------------------
1400     void CellController::resume( )
1401     {
1402         DBG_ASSERT( bSuspended == !GetWindow().IsVisible(), "CellController::resume: inconsistence!" );
1403         if ( isSuspended( ) )
1404         {
1405             GetWindow().Enable( );
1406             GetWindow().Show( );
1407             bSuspended = sal_False;
1408         }
1409     }
1410 
1411     //-----------------------------------------------------------------------------
1412     void CellController::CommitModifications()
1413     {
1414         // nothing to do in this base class
1415     }
1416 
1417     //-----------------------------------------------------------------------------
1418     sal_Bool CellController::WantMouseEvent() const
1419     {
1420         return sal_False;
1421     }
1422 
1423     //-----------------------------------------------------------------------------
1424     void CellController::SetModified()
1425     {
1426     }
1427 
1428     //-----------------------------------------------------------------------------
1429     sal_Bool CellController::MoveAllowed(const KeyEvent&) const
1430     {
1431         return sal_True;
1432     }
1433 // .......................................................................
1434 }   // namespace svt
1435 // .......................................................................
1436 
1437