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