Kaydet (Commit) a3261b16 authored tarafından Lionel Elie Mamane's avatar Lionel Elie Mamane

fdo#44283: finish 8a17792f2e5 (Handle/invalid column ID cleanup)

üst 34219bd5
...@@ -307,9 +307,9 @@ void BrowseBox::InsertDataColumn( sal_uInt16 nItemId, const XubString& rText, ...@@ -307,9 +307,9 @@ void BrowseBox::InsertDataColumn( sal_uInt16 nItemId, const XubString& rText,
if ( getDataWindow()->pHeaderBar ) if ( getDataWindow()->pHeaderBar )
{ {
// Handlecolumn nicht in der Headerbar // Handle column not in the header bar
sal_uInt16 nHeaderPos = nPos; sal_uInt16 nHeaderPos = nPos;
if (nHeaderPos != HEADERBAR_APPEND && !GetColumnId(0)) if (nHeaderPos != HEADERBAR_APPEND && GetColumnId(0) == HandleColumnId )
nHeaderPos--; nHeaderPos--;
getDataWindow()->pHeaderBar->InsertItem( getDataWindow()->pHeaderBar->InsertItem(
nItemId, rText, nWidth, nBits, nHeaderPos ); nItemId, rText, nWidth, nBits, nHeaderPos );
...@@ -347,7 +347,7 @@ void BrowseBox::FreezeColumn( sal_uInt16 nItemId, sal_Bool bFreeze ) ...@@ -347,7 +347,7 @@ void BrowseBox::FreezeColumn( sal_uInt16 nItemId, sal_Bool bFreeze )
DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
// never unfreeze the handle-column // never unfreeze the handle-column
if ( nItemId == 0 && !bFreeze ) if ( nItemId == HandleColumnId && !bFreeze )
return; return;
// get the position in the current array // get the position in the current array
...@@ -424,12 +424,8 @@ void BrowseBox::FreezeColumn( sal_uInt16 nItemId, sal_Bool bFreeze ) ...@@ -424,12 +424,8 @@ void BrowseBox::FreezeColumn( sal_uInt16 nItemId, sal_Bool bFreeze )
void BrowseBox::SetColumnPos( sal_uInt16 nColumnId, sal_uInt16 nPos ) void BrowseBox::SetColumnPos( sal_uInt16 nColumnId, sal_uInt16 nPos )
{ {
// never set pos of the handle-column // never set pos of the handle column
if ( nColumnId == 0 ) if ( nColumnId == HandleColumnId )
return;
// do not move handle column
if (nPos == 0 && !(*pCols)[ 0 ]->GetId())
return; return;
// get the position in the current array // get the position in the current array
...@@ -504,7 +500,7 @@ void BrowseBox::SetColumnPos( sal_uInt16 nColumnId, sal_uInt16 nPos ) ...@@ -504,7 +500,7 @@ void BrowseBox::SetColumnPos( sal_uInt16 nColumnId, sal_uInt16 nPos )
if ( getDataWindow()->pHeaderBar ) if ( getDataWindow()->pHeaderBar )
{ {
sal_uInt16 nNewPos = nPos; sal_uInt16 nNewPos = nPos;
if ( !GetColumnId(0) ) if ( GetColumnId(0) == HandleColumnId )
--nNewPos; --nNewPos;
getDataWindow()->pHeaderBar->MoveItem(nColumnId,nNewPos); getDataWindow()->pHeaderBar->MoveItem(nColumnId,nNewPos);
} }
...@@ -550,7 +546,7 @@ void BrowseBox::SetColumnTitle( sal_uInt16 nItemId, const String& rTitle ) ...@@ -550,7 +546,7 @@ void BrowseBox::SetColumnTitle( sal_uInt16 nItemId, const String& rTitle )
DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
// never set title of the handle-column // never set title of the handle-column
if ( nItemId == 0 ) if ( nItemId == HandleColumnId )
return; return;
// get the position in the current array // get the position in the current array
...@@ -2383,8 +2379,8 @@ void BrowseBox::SetMode( BrowserMode nMode ) ...@@ -2383,8 +2379,8 @@ void BrowseBox::SetMode( BrowserMode nMode )
if ( pDataWin ) if ( pDataWin )
pDataWin->Invalidate(); pDataWin->Invalidate();
// kein Cursor auf Handle-Column // no cursor on handle column
if ( nCurColId == 0 ) if ( nCurColId == HandleColumnId )
nCurColId = GetColumnId( 1 ); nCurColId = GetColumnId( 1 );
m_nCurrentMode = nMode; m_nCurrentMode = nMode;
......
...@@ -416,8 +416,8 @@ void BrowseBox::DrawCursor() ...@@ -416,8 +416,8 @@ void BrowseBox::DrawCursor()
else else
bReallyHide |= ( GetCursorHideCount() > 0 ); bReallyHide |= ( GetCursorHideCount() > 0 );
// keine Cursor auf Handle-Column // no cursor on handle column
if ( nCurColId == 0 ) if ( nCurColId == HandleColumnId )
nCurColId = GetColumnId(1); nCurColId = GetColumnId(1);
// Cursor-Rechteck berechnen // Cursor-Rechteck berechnen
...@@ -1682,8 +1682,8 @@ void BrowseBox::MouseButtonDown( const BrowserMouseEvent& rEvt ) ...@@ -1682,8 +1682,8 @@ void BrowseBox::MouseButtonDown( const BrowserMouseEvent& rEvt )
// DataRow? // DataRow?
if ( rEvt.GetRow() >= 0 ) if ( rEvt.GetRow() >= 0 )
{ {
// Zeilenselektion? // line selection?
if ( rEvt.GetColumnId() == 0 || !bColumnCursor ) if ( rEvt.GetColumnId() == HandleColumnId || !bColumnCursor )
{ {
if ( bMultiSelection ) if ( bMultiSelection )
{ {
...@@ -1757,7 +1757,7 @@ void BrowseBox::MouseButtonDown( const BrowserMouseEvent& rEvt ) ...@@ -1757,7 +1757,7 @@ void BrowseBox::MouseButtonDown( const BrowserMouseEvent& rEvt )
} }
else else
{ {
if ( bMultiSelection && rEvt.GetColumnId() == 0 ) if ( bMultiSelection && rEvt.GetColumnId() == HandleColumnId )
{ {
// toggle all-selection // toggle all-selection
if ( uRow.pSel->GetSelectCount() > ( GetRowCount() / 2 ) ) if ( uRow.pSel->GetSelectCount() > ( GetRowCount() / 2 ) )
...@@ -1990,7 +1990,7 @@ void BrowseBox::Dispatch( sal_uInt16 nId ) ...@@ -1990,7 +1990,7 @@ void BrowseBox::Dispatch( sal_uInt16 nId )
if ( bColumnCursor ) if ( bColumnCursor )
{ {
sal_uInt16 nNewId = GetColumnId(ColCount() -1); sal_uInt16 nNewId = GetColumnId(ColCount() -1);
bDone = (nNewId != 0) && GoToColumnId( nNewId ); bDone = nNewId != HandleColumnId && GoToColumnId( nNewId );
break; break;
} }
case BROWSER_CURSORENDOFFILE: case BROWSER_CURSORENDOFFILE:
...@@ -2001,11 +2001,13 @@ void BrowseBox::Dispatch( sal_uInt16 nId ) ...@@ -2001,11 +2001,13 @@ void BrowseBox::Dispatch( sal_uInt16 nId )
{ {
sal_uInt16 nNewPos = GetColumnPos( GetCurColumnId() ) + 1; sal_uInt16 nNewPos = GetColumnPos( GetCurColumnId() ) + 1;
sal_uInt16 nNewId = GetColumnId( nNewPos ); sal_uInt16 nNewId = GetColumnId( nNewPos );
if (nNewId != 0) // Am Zeilenende ? if (nNewId != BROWSER_INVALIDID) // At end of row ?
bDone = GoToColumnId( nNewId ); bDone = GoToColumnId( nNewId );
else else
{ {
sal_uInt16 nColId = ( GetColumnId(0) == 0 ) ? GetColumnId(1) : GetColumnId(0); sal_uInt16 nColId = GetColumnId(0);
if ( nColId == BROWSER_INVALIDID || nColId == HandleColumnId )
nColId = GetColumnId(1);
if ( GetRowCount() ) if ( GetRowCount() )
bDone = ( nCurRow < GetRowCount() - 1 ) && GoToRowColumnId( nCurRow + 1, nColId ); bDone = ( nCurRow < GetRowCount() - 1 ) && GoToRowColumnId( nCurRow + 1, nColId );
else if ( ColCount() ) else if ( ColCount() )
...@@ -2019,7 +2021,7 @@ void BrowseBox::Dispatch( sal_uInt16 nId ) ...@@ -2019,7 +2021,7 @@ void BrowseBox::Dispatch( sal_uInt16 nId )
if ( bColumnCursor ) if ( bColumnCursor )
{ {
sal_uInt16 nNewId = GetColumnId(1); sal_uInt16 nNewId = GetColumnId(1);
bDone = (nNewId != 0) && GoToColumnId( nNewId ); bDone = (nNewId != HandleColumnId) && GoToColumnId( nNewId );
break; break;
} }
case BROWSER_CURSORTOPOFFILE: case BROWSER_CURSORTOPOFFILE:
...@@ -2030,7 +2032,7 @@ void BrowseBox::Dispatch( sal_uInt16 nId ) ...@@ -2030,7 +2032,7 @@ void BrowseBox::Dispatch( sal_uInt16 nId )
{ {
sal_uInt16 nNewPos = GetColumnPos( GetCurColumnId() ) - 1; sal_uInt16 nNewPos = GetColumnPos( GetCurColumnId() ) - 1;
sal_uInt16 nNewId = GetColumnId( nNewPos ); sal_uInt16 nNewId = GetColumnId( nNewPos );
if (nNewId != 0) if (nNewId != HandleColumnId)
bDone = GoToColumnId( nNewId ); bDone = GoToColumnId( nNewId );
else else
{ {
......
...@@ -450,7 +450,7 @@ sal_uInt16 BrowseBox::GetCurrColumn() const ...@@ -450,7 +450,7 @@ sal_uInt16 BrowseBox::GetCurrColumn() const
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
sal_Bool BrowseBox::HasRowHeader() const sal_Bool BrowseBox::HasRowHeader() const
{ {
return ( GetColumnId( 0 ) == 0 ); // HandleColumn == RowHeader return ( GetColumnId( 0 ) == HandleColumnId ); // HandleColumn == RowHeader
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
sal_Bool BrowseBox::IsCellFocusable() const sal_Bool BrowseBox::IsCellFocusable() const
......
...@@ -97,7 +97,7 @@ void BrowserHeader::EndDrag() ...@@ -97,7 +97,7 @@ void BrowserHeader::EndDrag()
sal_uInt16 nOldPos = _pBrowseBox->GetColumnPos(nId), sal_uInt16 nOldPos = _pBrowseBox->GetColumnPos(nId),
nNewPos = GetItemPos( nId ); nNewPos = GetItemPos( nId );
if (!_pBrowseBox->GetColumnId(0)) // Handle if (_pBrowseBox->GetColumnId(0) == BrowseBox::HandleColumnId)
nNewPos++; nNewPos++;
if (nOldPos != nNewPos) if (nOldPos != nNewPos)
......
...@@ -459,7 +459,7 @@ sal_Bool BrowserDataWin::ImplRowDividerHitTest( const BrowserMouseEvent& _rEvent ...@@ -459,7 +459,7 @@ sal_Bool BrowserDataWin::ImplRowDividerHitTest( const BrowserMouseEvent& _rEvent
if ( ! ( GetParent()->IsInteractiveRowHeightEnabled() if ( ! ( GetParent()->IsInteractiveRowHeightEnabled()
&& ( _rEvent.GetRow() >= 0 ) && ( _rEvent.GetRow() >= 0 )
&& ( _rEvent.GetRow() < GetParent()->GetRowCount() ) && ( _rEvent.GetRow() < GetParent()->GetRowCount() )
&& ( _rEvent.GetColumnId() == 0 ) && ( _rEvent.GetColumnId() == BrowseBox::HandleColumnId )
) )
) )
return sal_False; return sal_False;
......
...@@ -72,8 +72,6 @@ namespace svt ...@@ -72,8 +72,6 @@ namespace svt
using com::sun::star::accessibility::XAccessible; using com::sun::star::accessibility::XAccessible;
//================================================================== //==================================================================
#define HANDLE_ID 0
//================================================================== //==================================================================
//= EditBrowserHeader //= EditBrowserHeader
//================================================================== //==================================================================
...@@ -270,7 +268,7 @@ namespace svt ...@@ -270,7 +268,7 @@ namespace svt
void EditBrowseBox::PaintField( OutputDevice& rDev, const Rectangle& rRect, void EditBrowseBox::PaintField( OutputDevice& rDev, const Rectangle& rRect,
sal_uInt16 nColumnId ) const sal_uInt16 nColumnId ) const
{ {
if (nColumnId == HANDLE_ID) if (nColumnId == HandleColumnId)
{ {
if (bPaintStatus) if (bPaintStatus)
PaintStatusCell(rDev, rRect); PaintStatusCell(rDev, rRect);
...@@ -506,7 +504,7 @@ namespace svt ...@@ -506,7 +504,7 @@ namespace svt
LINK( this, EditBrowseBox, CellModifiedHdl ).Call( NULL ); LINK( this, EditBrowseBox, CellModifiedHdl ).Call( NULL );
} }
if (0 == rEvt.GetColumnId()) if (rEvt.GetColumnId() == HandleColumnId)
{ // it was the handle column. save the current cell content if necessary { // it was the handle column. save the current cell content if necessary
// (clicking on the handle column results in selecting the current row) // (clicking on the handle column results in selecting the current row)
if (IsEditing() && aController->IsModified()) if (IsEditing() && aController->IsModified())
...@@ -877,7 +875,7 @@ namespace svt ...@@ -877,7 +875,7 @@ namespace svt
if (GetSelectColumnCount() || (aMouseEvent.Is() && aMouseEvent->GetRow() < 0)) if (GetSelectColumnCount() || (aMouseEvent.Is() && aMouseEvent->GetRow() < 0))
nInfo |= COLSELECT; nInfo |= COLSELECT;
if ((GetSelection() != NULL && GetSelectRowCount()) || if ((GetSelection() != NULL && GetSelectRowCount()) ||
(aMouseEvent.Is() && aMouseEvent->GetColumnId() == HANDLE_ID)) (aMouseEvent.Is() && aMouseEvent->GetColumnId() == HandleColumnId))
nInfo |= ROWSELECT; nInfo |= ROWSELECT;
if (!nInfo && nNewRow != nEditRow) if (!nInfo && nNewRow != nEditRow)
nInfo |= ROWCHANGE; nInfo |= ROWCHANGE;
...@@ -1027,7 +1025,7 @@ namespace svt ...@@ -1027,7 +1025,7 @@ namespace svt
return; return;
} }
if (nEditRow >= 0 && nEditCol > HANDLE_ID) if (nEditRow >= 0 && nEditCol > HandleColumnId)
{ {
aController = GetController(nRow, nCol); aController = GetController(nRow, nCol);
if (aController.Is()) if (aController.Is())
...@@ -1247,7 +1245,7 @@ namespace svt ...@@ -1247,7 +1245,7 @@ namespace svt
{ {
// when double clicking on the column, the optimum size will be calculated // when double clicking on the column, the optimum size will be calculated
sal_uInt16 nColId = rEvt.GetColumnId(); sal_uInt16 nColId = rEvt.GetColumnId();
if (nColId != HANDLE_ID) if (nColId != HandleColumnId)
SetColumnWidth(nColId, GetAutoColumnWidth(nColId)); SetColumnWidth(nColId, GetAutoColumnWidth(nColId));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment