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