summaryrefslogtreecommitdiff
path: root/svtools/source/brwbox
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-11-22 11:26:08 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-11-22 11:54:12 +0100
commit1ae61b0ac4187b2938647f3ca0289a070a5dc7d2 (patch)
tree9461c0532919f4fe61f3e0e3fa8556e954244fbd /svtools/source/brwbox
parent04bb9549e0a0ee567f3bd48a7707286c5abd631a (diff)
loplugin:flatten in svtools
almost completely automatically rewritten, only had to tweak the indentation on a couple of lines. Change-Id: Ieec92e5b602d180d7ec556e3421ce3c835c1f646 Reviewed-on: https://gerrit.libreoffice.org/45072 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svtools/source/brwbox')
-rw-r--r--svtools/source/brwbox/brwbox1.cxx603
-rw-r--r--svtools/source/brwbox/brwbox2.cxx86
-rw-r--r--svtools/source/brwbox/brwbox3.cxx30
-rw-r--r--svtools/source/brwbox/brwhead.cxx52
-rw-r--r--svtools/source/brwbox/editbrowsebox.cxx183
-rw-r--r--svtools/source/brwbox/editbrowsebox2.cxx94
6 files changed, 524 insertions, 524 deletions
diff --git a/svtools/source/brwbox/brwbox1.cxx b/svtools/source/brwbox/brwbox1.cxx
index fe7d5a8d58e2..275e8c9e5fa7 100644
--- a/svtools/source/brwbox/brwbox1.cxx
+++ b/svtools/source/brwbox/brwbox1.cxx
@@ -372,107 +372,107 @@ void BrowseBox::SetColumnPos( sal_uInt16 nColumnId, sal_uInt16 nPos )
return;
// does the state change?
- if (nOldPos != nPos)
- {
- // remark the column selection
- sal_uInt16 nSelectedColId = ToggleSelectedColumn();
-
- // determine old column area
- Size aDataWinSize( pDataWin->GetSizePixel() );
- if ( pDataWin->pHeaderBar )
- aDataWinSize.Height() += pDataWin->pHeaderBar->GetSizePixel().Height();
+ if (nOldPos == nPos)
+ return;
- tools::Rectangle aFromRect( GetFieldRect( nColumnId) );
- aFromRect.Right() += 2*MIN_COLUMNWIDTH;
+ // remark the column selection
+ sal_uInt16 nSelectedColId = ToggleSelectedColumn();
- sal_uInt16 nNextPos = nOldPos + 1;
- if ( nOldPos > nPos )
- nNextPos = nOldPos - 1;
+ // determine old column area
+ Size aDataWinSize( pDataWin->GetSizePixel() );
+ if ( pDataWin->pHeaderBar )
+ aDataWinSize.Height() += pDataWin->pHeaderBar->GetSizePixel().Height();
- BrowserColumn *pNextCol = pCols[ nNextPos ];
- tools::Rectangle aNextRect(GetFieldRect( pNextCol->GetId() ));
+ tools::Rectangle aFromRect( GetFieldRect( nColumnId) );
+ aFromRect.Right() += 2*MIN_COLUMNWIDTH;
- // move column internally
- {
- BrowserColumns::iterator it = pCols.begin();
- ::std::advance( it, nOldPos );
- BrowserColumn* pTemp = *it;
- pCols.erase( it );
- it = pCols.begin();
- ::std::advance( it, nPos );
- pCols.insert( it, pTemp );
- }
+ sal_uInt16 nNextPos = nOldPos + 1;
+ if ( nOldPos > nPos )
+ nNextPos = nOldPos - 1;
- // determine new column area
- tools::Rectangle aToRect( GetFieldRect( nColumnId ) );
- aToRect.Right() += 2*MIN_COLUMNWIDTH;
+ BrowserColumn *pNextCol = pCols[ nNextPos ];
+ tools::Rectangle aNextRect(GetFieldRect( pNextCol->GetId() ));
- // do scroll, let redraw
- if( pDataWin->GetBackground().IsScrollable() )
- {
- long nScroll = -aFromRect.GetWidth();
- tools::Rectangle aScrollArea;
- if ( nOldPos > nPos )
- {
- long nFrozenWidth = GetFrozenWidth();
- if ( aToRect.Left() < nFrozenWidth )
- aToRect.Left() = nFrozenWidth;
- aScrollArea = tools::Rectangle(Point(aToRect.Left(),0),
- Point(aNextRect.Right(),aDataWinSize.Height()));
- nScroll *= -1; // reverse direction
- }
- else
- aScrollArea = tools::Rectangle(Point(aNextRect.Left(),0),
- Point(aToRect.Right(),aDataWinSize.Height()));
+ // move column internally
+ {
+ BrowserColumns::iterator it = pCols.begin();
+ ::std::advance( it, nOldPos );
+ BrowserColumn* pTemp = *it;
+ pCols.erase( it );
+ it = pCols.begin();
+ ::std::advance( it, nPos );
+ pCols.insert( it, pTemp );
+ }
- pDataWin->Scroll( nScroll, 0, aScrollArea );
- aToRect.Top() = 0;
- aToRect.Bottom() = aScrollArea.Bottom();
- Invalidate( aToRect );
- }
- else
- pDataWin->Window::Invalidate( InvalidateFlags::NoChildren );
+ // determine new column area
+ tools::Rectangle aToRect( GetFieldRect( nColumnId ) );
+ aToRect.Right() += 2*MIN_COLUMNWIDTH;
- // adjust header bar positions
- if ( pDataWin->pHeaderBar )
+ // do scroll, let redraw
+ if( pDataWin->GetBackground().IsScrollable() )
+ {
+ long nScroll = -aFromRect.GetWidth();
+ tools::Rectangle aScrollArea;
+ if ( nOldPos > nPos )
{
- sal_uInt16 nNewPos = nPos;
- if ( GetColumnId(0) == HandleColumnId )
- --nNewPos;
- pDataWin->pHeaderBar->MoveItem(nColumnId,nNewPos);
+ long nFrozenWidth = GetFrozenWidth();
+ if ( aToRect.Left() < nFrozenWidth )
+ aToRect.Left() = nFrozenWidth;
+ aScrollArea = tools::Rectangle(Point(aToRect.Left(),0),
+ Point(aNextRect.Right(),aDataWinSize.Height()));
+ nScroll *= -1; // reverse direction
}
- // remember the column selection
- SetToggledSelectedColumn(nSelectedColId);
+ else
+ aScrollArea = tools::Rectangle(Point(aNextRect.Left(),0),
+ Point(aToRect.Right(),aDataWinSize.Height()));
- if ( isAccessibleAlive() )
- {
- commitTableEvent(
- TABLE_MODEL_CHANGED,
- makeAny( AccessibleTableModelChange(
- DELETE,
- 0,
- GetRowCount(),
- nOldPos,
- nOldPos
- )
- ),
- Any()
- );
+ pDataWin->Scroll( nScroll, 0, aScrollArea );
+ aToRect.Top() = 0;
+ aToRect.Bottom() = aScrollArea.Bottom();
+ Invalidate( aToRect );
+ }
+ else
+ pDataWin->Window::Invalidate( InvalidateFlags::NoChildren );
- commitTableEvent(
- TABLE_MODEL_CHANGED,
- makeAny( AccessibleTableModelChange(
- INSERT,
- 0,
- GetRowCount(),
- nPos,
- nPos
- )
- ),
- Any()
- );
- }
+ // adjust header bar positions
+ if ( pDataWin->pHeaderBar )
+ {
+ sal_uInt16 nNewPos = nPos;
+ if ( GetColumnId(0) == HandleColumnId )
+ --nNewPos;
+ pDataWin->pHeaderBar->MoveItem(nColumnId,nNewPos);
}
+ // remember the column selection
+ SetToggledSelectedColumn(nSelectedColId);
+
+ if ( !isAccessibleAlive() )
+ return;
+
+ commitTableEvent(
+ TABLE_MODEL_CHANGED,
+ makeAny( AccessibleTableModelChange(
+ DELETE,
+ 0,
+ GetRowCount(),
+ nOldPos,
+ nOldPos
+ )
+ ),
+ Any()
+ );
+
+ commitTableEvent(
+ TABLE_MODEL_CHANGED,
+ makeAny( AccessibleTableModelChange(
+ INSERT,
+ 0,
+ GetRowCount(),
+ nPos,
+ nPos
+ )
+ ),
+ Any()
+ );
}
@@ -492,30 +492,30 @@ void BrowseBox::SetColumnTitle( sal_uInt16 nItemId, const OUString& rTitle )
// does the state change?
BrowserColumn *pCol = pCols[ nItemPos ];
- if ( pCol->Title() != rTitle )
- {
- OUString sOld(pCol->Title());
+ if ( pCol->Title() == rTitle )
+ return;
- pCol->Title() = rTitle;
+ OUString sOld(pCol->Title());
- // adjust headerbar column
- if ( pDataWin->pHeaderBar )
- pDataWin->pHeaderBar->SetItemText( nItemId, rTitle );
- else
- {
- // redraw visible columns
- if ( GetUpdateMode() && ( pCol->IsFrozen() || nItemPos > nFirstCol ) )
- Invalidate( tools::Rectangle( Point(0,0),
- Size( GetOutputSizePixel().Width(), GetTitleHeight() ) ) );
- }
+ pCol->Title() = rTitle;
- if ( isAccessibleAlive() )
- {
- commitTableEvent( TABLE_COLUMN_DESCRIPTION_CHANGED,
- makeAny( rTitle ),
- makeAny( sOld )
- );
- }
+ // adjust headerbar column
+ if ( pDataWin->pHeaderBar )
+ pDataWin->pHeaderBar->SetItemText( nItemId, rTitle );
+ else
+ {
+ // redraw visible columns
+ if ( GetUpdateMode() && ( pCol->IsFrozen() || nItemPos > nFirstCol ) )
+ Invalidate( tools::Rectangle( Point(0,0),
+ Size( GetOutputSizePixel().Width(), GetTitleHeight() ) ) );
+ }
+
+ if ( isAccessibleAlive() )
+ {
+ commitTableEvent( TABLE_COLUMN_DESCRIPTION_CHANGED,
+ makeAny( rTitle ),
+ makeAny( sOld )
+ );
}
}
@@ -529,99 +529,98 @@ void BrowseBox::SetColumnWidth( sal_uInt16 nItemId, sal_uLong nWidth )
return;
// does the state change?
- if ( nWidth >= LONG_MAX || pCols[ nItemPos ]->Width() != nWidth )
- {
- long nOldWidth = pCols[ nItemPos ]->Width();
+ if ( !(nWidth >= LONG_MAX || pCols[ nItemPos ]->Width() != nWidth) )
+ return;
- // adjust last column, if necessary
- if ( IsVisible() && nItemPos == pCols.size() - 1 )
+ long nOldWidth = pCols[ nItemPos ]->Width();
+
+ // adjust last column, if necessary
+ if ( IsVisible() && nItemPos == pCols.size() - 1 )
+ {
+ long nMaxWidth = pDataWin->GetSizePixel().Width();
+ nMaxWidth -= pDataWin->bAutoSizeLastCol
+ ? GetFieldRect(nItemId).Left()
+ : GetFrozenWidth();
+ if ( pDataWin->bAutoSizeLastCol || nWidth > (sal_uLong)nMaxWidth )
{
- long nMaxWidth = pDataWin->GetSizePixel().Width();
- nMaxWidth -= pDataWin->bAutoSizeLastCol
- ? GetFieldRect(nItemId).Left()
- : GetFrozenWidth();
- if ( pDataWin->bAutoSizeLastCol || nWidth > (sal_uLong)nMaxWidth )
- {
- nWidth = nMaxWidth > 16 ? nMaxWidth : nOldWidth;
- }
+ nWidth = nMaxWidth > 16 ? nMaxWidth : nOldWidth;
}
+ }
- // OV
- // In AutoSizeLastColumn(), we call SetColumnWidth with nWidth==0xffff.
- // Thus, check here, if the width has actually changed.
- if( (sal_uLong)nOldWidth == nWidth )
- return;
+ // OV
+ // In AutoSizeLastColumn(), we call SetColumnWidth with nWidth==0xffff.
+ // Thus, check here, if the width has actually changed.
+ if( (sal_uLong)nOldWidth == nWidth )
+ return;
- // do we want to display the change immediately?
- bool bUpdate = GetUpdateMode() &&
- ( pCols[ nItemPos ]->IsFrozen() || nItemPos >= nFirstCol );
+ // do we want to display the change immediately?
+ bool bUpdate = GetUpdateMode() &&
+ ( pCols[ nItemPos ]->IsFrozen() || nItemPos >= nFirstCol );
- if ( bUpdate )
- {
- // Selection hidden
- DoHideCursor( "SetColumnWidth" );
- ToggleSelection();
- //!pDataWin->Update();
- //!Control::Update();
- }
+ if ( bUpdate )
+ {
+ // Selection hidden
+ DoHideCursor( "SetColumnWidth" );
+ ToggleSelection();
+ //!pDataWin->Update();
+ //!Control::Update();
+ }
- // set width
- pCols[ nItemPos ]->SetWidth(nWidth, GetZoom());
+ // set width
+ pCols[ nItemPos ]->SetWidth(nWidth, GetZoom());
- // scroll and invalidate
- if ( bUpdate )
+ // scroll and invalidate
+ if ( bUpdate )
+ {
+ // get X-Pos of the column changed
+ long nX = 0;
+ for ( size_t nCol = 0; nCol < nItemPos; ++nCol )
{
- // get X-Pos of the column changed
- long nX = 0;
- for ( size_t nCol = 0; nCol < nItemPos; ++nCol )
- {
- BrowserColumn *pCol = pCols[ nCol ];
- if ( pCol->IsFrozen() || nCol >= nFirstCol )
- nX += pCol->Width();
- }
-
- // actually scroll+invalidate
- pDataWin->SetClipRegion();
- bool bSelVis = bSelectionIsVisible;
- bSelectionIsVisible = false;
- if( GetBackground().IsScrollable() )
- {
-
- tools::Rectangle aScrRect( nX + std::min( (sal_uLong)nOldWidth, nWidth ), 0,
- GetSizePixel().Width() , // the header is longer than the datawin
- pDataWin->GetPosPixel().Y() - 1 );
- Control::Scroll( nWidth-nOldWidth, 0, aScrRect, SCROLL_FLAGS );
- aScrRect.Bottom() = pDataWin->GetSizePixel().Height();
- pDataWin->Scroll( nWidth-nOldWidth, 0, aScrRect, SCROLL_FLAGS );
- tools::Rectangle aInvRect( nX, 0, nX + std::max( nWidth, (sal_uLong)nOldWidth ), USHRT_MAX );
- Control::Invalidate( aInvRect, InvalidateFlags::NoChildren );
- pDataWin->Invalidate( aInvRect );
- }
- else
- {
- Control::Invalidate( InvalidateFlags::NoChildren );
- pDataWin->Window::Invalidate( InvalidateFlags::NoChildren );
- }
+ BrowserColumn *pCol = pCols[ nCol ];
+ if ( pCol->IsFrozen() || nCol >= nFirstCol )
+ nX += pCol->Width();
+ }
+ // actually scroll+invalidate
+ pDataWin->SetClipRegion();
+ bool bSelVis = bSelectionIsVisible;
+ bSelectionIsVisible = false;
+ if( GetBackground().IsScrollable() )
+ {
- //!pDataWin->Update();
- //!Control::Update();
- bSelectionIsVisible = bSelVis;
- ToggleSelection();
- DoShowCursor( "SetColumnWidth" );
+ tools::Rectangle aScrRect( nX + std::min( (sal_uLong)nOldWidth, nWidth ), 0,
+ GetSizePixel().Width() , // the header is longer than the datawin
+ pDataWin->GetPosPixel().Y() - 1 );
+ Control::Scroll( nWidth-nOldWidth, 0, aScrRect, SCROLL_FLAGS );
+ aScrRect.Bottom() = pDataWin->GetSizePixel().Height();
+ pDataWin->Scroll( nWidth-nOldWidth, 0, aScrRect, SCROLL_FLAGS );
+ tools::Rectangle aInvRect( nX, 0, nX + std::max( nWidth, (sal_uLong)nOldWidth ), USHRT_MAX );
+ Control::Invalidate( aInvRect, InvalidateFlags::NoChildren );
+ pDataWin->Invalidate( aInvRect );
+ }
+ else
+ {
+ Control::Invalidate( InvalidateFlags::NoChildren );
+ pDataWin->Window::Invalidate( InvalidateFlags::NoChildren );
}
- UpdateScrollbars();
-
- // adjust headerbar column
- if ( pDataWin->pHeaderBar )
- pDataWin->pHeaderBar->SetItemSize(
- nItemId ? nItemId : USHRT_MAX - 1, nWidth );
- // adjust last column
- if ( nItemPos != pCols.size() - 1 )
- AutoSizeLastColumn();
+ //!pDataWin->Update();
+ //!Control::Update();
+ bSelectionIsVisible = bSelVis;
+ ToggleSelection();
+ DoShowCursor( "SetColumnWidth" );
}
+ UpdateScrollbars();
+
+ // adjust headerbar column
+ if ( pDataWin->pHeaderBar )
+ pDataWin->pHeaderBar->SetItemSize(
+ nItemId ? nItemId : USHRT_MAX - 1, nWidth );
+
+ // adjust last column
+ if ( nItemPos != pCols.size() - 1 )
+ AutoSizeLastColumn();
}
@@ -695,27 +694,27 @@ void BrowseBox::RemoveColumn( sal_uInt16 nItemId )
SetColumnWidth( GetColumnId( nPos - 1 ), LONG_MAX );
}
- if ( isAccessibleAlive() )
- {
- commitTableEvent(
- TABLE_MODEL_CHANGED,
- makeAny( AccessibleTableModelChange( DELETE,
- 0,
- GetRowCount(),
- nPos,
- nPos
- )
- ),
- Any()
- );
+ if ( !isAccessibleAlive() )
+ return;
- commitHeaderBarEvent(
- CHILD,
- Any(),
- makeAny( CreateAccessibleColumnHeader( nPos ) ),
- true
- );
- }
+ commitTableEvent(
+ TABLE_MODEL_CHANGED,
+ makeAny( AccessibleTableModelChange( DELETE,
+ 0,
+ GetRowCount(),
+ nPos,
+ nPos
+ )
+ ),
+ Any()
+ );
+
+ commitHeaderBarEvent(
+ CHILD,
+ Any(),
+ makeAny( CreateAccessibleColumnHeader( nPos ) ),
+ true
+ );
}
@@ -752,39 +751,39 @@ void BrowseBox::RemoveColumns()
Control::Invalidate();
}
- if ( isAccessibleAlive() )
- {
- if ( pCols.size() != nOldCount )
- {
- // all columns should be removed, so we remove the column header bar and append it again
- // to avoid to notify every column remove
- commitBrowseBoxEvent(
- CHILD,
- Any(),
- makeAny(m_pImpl->getAccessibleHeaderBar(BBTYPE_COLUMNHEADERBAR))
- );
+ if ( !isAccessibleAlive() )
+ return;
- // and now append it again
- commitBrowseBoxEvent(
- CHILD,
- makeAny(m_pImpl->getAccessibleHeaderBar(BBTYPE_COLUMNHEADERBAR)),
- Any()
- );
+ if ( pCols.size() == nOldCount )
+ return;
- // notify a table model change
- commitTableEvent(
- TABLE_MODEL_CHANGED,
- makeAny ( AccessibleTableModelChange( DELETE,
- 0,
- GetRowCount(),
- 0,
- nOldCount
- )
- ),
- Any()
- );
- }
- }
+ // all columns should be removed, so we remove the column header bar and append it again
+ // to avoid to notify every column remove
+ commitBrowseBoxEvent(
+ CHILD,
+ Any(),
+ makeAny(m_pImpl->getAccessibleHeaderBar(BBTYPE_COLUMNHEADERBAR))
+ );
+
+ // and now append it again
+ commitBrowseBoxEvent(
+ CHILD,
+ makeAny(m_pImpl->getAccessibleHeaderBar(BBTYPE_COLUMNHEADERBAR)),
+ Any()
+ );
+
+ // notify a table model change
+ commitTableEvent(
+ TABLE_MODEL_CHANGED,
+ makeAny ( AccessibleTableModelChange( DELETE,
+ 0,
+ GetRowCount(),
+ 0,
+ nOldCount
+ )
+ ),
+ Any()
+ );
}
@@ -1086,38 +1085,38 @@ void BrowseBox::Clear()
DoShowCursor( "Clear" );
CursorMoved();
- if ( isAccessibleAlive() )
- {
- // all rows should be removed, so we remove the row header bar and append it again
- // to avoid to notify every row remove
- if ( nOldRowCount != nRowCount )
- {
- commitBrowseBoxEvent(
- CHILD,
- Any(),
- makeAny( m_pImpl->getAccessibleHeaderBar( BBTYPE_ROWHEADERBAR ) )
- );
+ if ( !isAccessibleAlive() )
+ return;
- // and now append it again
- commitBrowseBoxEvent(
- CHILD,
- makeAny( m_pImpl->getAccessibleHeaderBar( BBTYPE_ROWHEADERBAR ) ),
- Any()
- );
+ // all rows should be removed, so we remove the row header bar and append it again
+ // to avoid to notify every row remove
+ if ( nOldRowCount == nRowCount )
+ return;
- // notify a table model change
- commitTableEvent(
- TABLE_MODEL_CHANGED,
- makeAny( AccessibleTableModelChange( DELETE,
- 0,
- nOldRowCount,
- 0,
- GetColumnCount())
- ),
- Any()
- );
- }
- }
+ commitBrowseBoxEvent(
+ CHILD,
+ Any(),
+ makeAny( m_pImpl->getAccessibleHeaderBar( BBTYPE_ROWHEADERBAR ) )
+ );
+
+ // and now append it again
+ commitBrowseBoxEvent(
+ CHILD,
+ makeAny( m_pImpl->getAccessibleHeaderBar( BBTYPE_ROWHEADERBAR ) ),
+ Any()
+ );
+
+ // notify a table model change
+ commitTableEvent(
+ TABLE_MODEL_CHANGED,
+ makeAny( AccessibleTableModelChange( DELETE,
+ 0,
+ nOldRowCount,
+ 0,
+ GetColumnCount())
+ ),
+ Any()
+ );
}
void BrowseBox::RowInserted( long nRow, long nNumRows, bool bDoPaint, bool bKeepSelection )
@@ -1662,27 +1661,27 @@ void BrowseBox::SelectAll()
// restore screen
SAL_INFO("svtools", "BrowseBox::ShowCursor " << this );
- if ( isAccessibleAlive() )
- {
- commitTableEvent(
- SELECTION_CHANGED,
- Any(),
- Any()
- );
- commitHeaderBarEvent(
- SELECTION_CHANGED,
- Any(),
- Any(),
- true
- ); // column header event
+ if ( !isAccessibleAlive() )
+ return;
- commitHeaderBarEvent(
- SELECTION_CHANGED,
- Any(),
- Any(),
- false
- ); // row header event
- }
+ commitTableEvent(
+ SELECTION_CHANGED,
+ Any(),
+ Any()
+ );
+ commitHeaderBarEvent(
+ SELECTION_CHANGED,
+ Any(),
+ Any(),
+ true
+ ); // column header event
+
+ commitHeaderBarEvent(
+ SELECTION_CHANGED,
+ Any(),
+ Any(),
+ false
+ ); // row header event
}
@@ -1741,20 +1740,20 @@ void BrowseBox::SelectRow( long nRow, bool _bSelect, bool bExpand )
// restore screen
SAL_INFO("svtools", "BrowseBox::ShowCursor " << this );
- if ( isAccessibleAlive() )
- {
- commitTableEvent(
- SELECTION_CHANGED,
- Any(),
- Any()
- );
- commitHeaderBarEvent(
- SELECTION_CHANGED,
- Any(),
- Any(),
- false
- ); // row header event
- }
+ if ( !isAccessibleAlive() )
+ return;
+
+ commitTableEvent(
+ SELECTION_CHANGED,
+ Any(),
+ Any()
+ );
+ commitHeaderBarEvent(
+ SELECTION_CHANGED,
+ Any(),
+ Any(),
+ false
+ ); // row header event
}
diff --git a/svtools/source/brwbox/brwbox2.cxx b/svtools/source/brwbox/brwbox2.cxx
index 4e341b72dbf4..f1030cd9ec31 100644
--- a/svtools/source/brwbox/brwbox2.cxx
+++ b/svtools/source/brwbox/brwbox2.cxx
@@ -576,57 +576,57 @@ void BrowseBox::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle
// Title Bar
// If there is a handle column and if the header bar is available, only
// take the HandleColumn into account
- if (nTitleLines && (!bHeaderBar || bHandleCol))
+ if (!(nTitleLines && (!bHeaderBar || bHandleCol)))
+ return;
+
+ // iterate through columns to redraw
+ long nX = 0;
+ size_t nCol;
+ for (nCol = 0; nCol < pCols.size() && nX < rRect.Right(); ++nCol)
{
- // iterate through columns to redraw
- long nX = 0;
- size_t nCol;
- for (nCol = 0; nCol < pCols.size() && nX < rRect.Right(); ++nCol)
- {
- // skip invisible columns between frozen and scrollable area
- if (nCol < nFirstCol && !pCols[nCol]->IsFrozen())
- nCol = nFirstCol;
+ // skip invisible columns between frozen and scrollable area
+ if (nCol < nFirstCol && !pCols[nCol]->IsFrozen())
+ nCol = nFirstCol;
- // only the handle column?
- if (bHeaderBar && bHandleCol && nCol > 0)
- break;
+ // only the handle column?
+ if (bHeaderBar && bHandleCol && nCol > 0)
+ break;
- BrowserColumn* pCol = pCols[nCol];
+ BrowserColumn* pCol = pCols[nCol];
- // draw the column and increment position
- if ( pCol->Width() > 4 )
- {
- ButtonFrame aButtonFrame( Point( nX, 0 ),
- Size( pCol->Width()-1, GetTitleHeight()-1 ),
- pCol->Title(), !IsEnabled());
- aButtonFrame.Draw(rRenderContext);
- rRenderContext.DrawLine(Point(nX + pCol->Width() - 1, 0),
- Point(nX + pCol->Width() - 1, GetTitleHeight() - 1));
- }
- else
- {
- rRenderContext.Push(PushFlags::FILLCOLOR);
- rRenderContext.SetFillColor(Color(COL_BLACK));
- rRenderContext.DrawRect(tools::Rectangle(Point(nX, 0), Size(pCol->Width(), GetTitleHeight() - 1)));
- rRenderContext.Pop();
- }
-
- // skip column
- nX += pCol->Width();
+ // draw the column and increment position
+ if ( pCol->Width() > 4 )
+ {
+ ButtonFrame aButtonFrame( Point( nX, 0 ),
+ Size( pCol->Width()-1, GetTitleHeight()-1 ),
+ pCol->Title(), !IsEnabled());
+ aButtonFrame.Draw(rRenderContext);
+ rRenderContext.DrawLine(Point(nX + pCol->Width() - 1, 0),
+ Point(nX + pCol->Width() - 1, GetTitleHeight() - 1));
}
-
- // retouching
- if ( !bHeaderBar && nCol == pCols.size() )
+ else
{
- const StyleSettings &rSettings = rRenderContext.GetSettings().GetStyleSettings();
- Color aColFace(rSettings.GetFaceColor());
- rRenderContext.Push(PushFlags::FILLCOLOR | PushFlags::LINECOLOR);
- rRenderContext.SetFillColor(aColFace);
- rRenderContext.SetLineColor(aColFace);
- rRenderContext.DrawRect(tools::Rectangle(Point(nX, 0),
- Point(rRect.Right(), GetTitleHeight() - 2 )));
+ rRenderContext.Push(PushFlags::FILLCOLOR);
+ rRenderContext.SetFillColor(Color(COL_BLACK));
+ rRenderContext.DrawRect(tools::Rectangle(Point(nX, 0), Size(pCol->Width(), GetTitleHeight() - 1)));
rRenderContext.Pop();
}
+
+ // skip column
+ nX += pCol->Width();
+ }
+
+ // retouching
+ if ( !bHeaderBar && nCol == pCols.size() )
+ {
+ const StyleSettings &rSettings = rRenderContext.GetSettings().GetStyleSettings();
+ Color aColFace(rSettings.GetFaceColor());
+ rRenderContext.Push(PushFlags::FILLCOLOR | PushFlags::LINECOLOR);
+ rRenderContext.SetFillColor(aColFace);
+ rRenderContext.SetLineColor(aColFace);
+ rRenderContext.DrawRect(tools::Rectangle(Point(nX, 0),
+ Point(rRect.Right(), GetTitleHeight() - 2 )));
+ rRenderContext.Pop();
}
}
diff --git a/svtools/source/brwbox/brwbox3.cxx b/svtools/source/brwbox/brwbox3.cxx
index 8eff53f03fe0..073277734c89 100644
--- a/svtools/source/brwbox/brwbox3.cxx
+++ b/svtools/source/brwbox/brwbox3.cxx
@@ -497,23 +497,23 @@ void BrowseBox::GetAllSelectedColumns( css::uno::Sequence< sal_Int32 >& _rColumn
{
const MultiSelection* pColumnSel = GetColumnSelection();
sal_Int32 nCount = GetSelectedColumnCount();
- if( pColumnSel && nCount )
- {
- _rColumns.realloc( nCount );
+ if( !(pColumnSel && nCount) )
+ return;
+
+ _rColumns.realloc( nCount );
- sal_Int32 nIndex = 0;
- const size_t nRangeCount = pColumnSel->GetRangeCount();
- for( size_t nRange = 0; nRange < nRangeCount; ++nRange )
+ sal_Int32 nIndex = 0;
+ const size_t nRangeCount = pColumnSel->GetRangeCount();
+ for( size_t nRange = 0; nRange < nRangeCount; ++nRange )
+ {
+ const Range& rRange = pColumnSel->GetRange( nRange );
+ // loop has to include aRange.Max()
+ for( sal_Int32 nCol = rRange.Min(); nCol <= (sal_Int32)rRange.Max(); ++nCol )
{
- const Range& rRange = pColumnSel->GetRange( nRange );
- // loop has to include aRange.Max()
- for( sal_Int32 nCol = rRange.Min(); nCol <= (sal_Int32)rRange.Max(); ++nCol )
- {
- DBG_ASSERT( nIndex < nCount,
- "GetAllSelectedColumns - range overflow" );
- _rColumns[ nIndex ] = nCol;
- ++nIndex;
- }
+ DBG_ASSERT( nIndex < nCount,
+ "GetAllSelectedColumns - range overflow" );
+ _rColumns[ nIndex ] = nCol;
+ ++nIndex;
}
}
}
diff --git a/svtools/source/brwbox/brwhead.cxx b/svtools/source/brwbox/brwhead.cxx
index 9db299802b1d..f8ffa0e834e3 100644
--- a/svtools/source/brwbox/brwhead.cxx
+++ b/svtools/source/brwbox/brwhead.cxx
@@ -69,35 +69,35 @@ void BrowserHeader::EndDrag()
// not aborted?
sal_uInt16 nId = GetCurItemId();
- if ( nId )
+ if ( !nId )
+ return;
+
+ // handle column?
+ if ( nId == USHRT_MAX-1 )
+ nId = 0;
+
+ if ( !IsItemMode() )
+ {
+ // column resize
+ _pBrowseBox->SetColumnWidth( nId, GetItemSize( nId ) );
+ _pBrowseBox->ColumnResized( nId );
+ SetItemSize( nId, _pBrowseBox->GetColumnWidth( nId ) );
+ }
+ else
{
- // handle column?
- if ( nId == USHRT_MAX-1 )
- nId = 0;
+ // column drag
+ // did the position actually change?
+ // take the handle column into account
+ sal_uInt16 nOldPos = _pBrowseBox->GetColumnPos(nId),
+ nNewPos = GetItemPos( nId );
- if ( !IsItemMode() )
- {
- // column resize
- _pBrowseBox->SetColumnWidth( nId, GetItemSize( nId ) );
- _pBrowseBox->ColumnResized( nId );
- SetItemSize( nId, _pBrowseBox->GetColumnWidth( nId ) );
- }
- else
+ if (_pBrowseBox->GetColumnId(0) == BrowseBox::HandleColumnId)
+ nNewPos++;
+
+ if (nOldPos != nNewPos)
{
- // column drag
- // did the position actually change?
- // take the handle column into account
- sal_uInt16 nOldPos = _pBrowseBox->GetColumnPos(nId),
- nNewPos = GetItemPos( nId );
-
- if (_pBrowseBox->GetColumnId(0) == BrowseBox::HandleColumnId)
- nNewPos++;
-
- if (nOldPos != nNewPos)
- {
- _pBrowseBox->SetColumnPos( nId, nNewPos );
- _pBrowseBox->ColumnMoved( nId );
- }
+ _pBrowseBox->SetColumnPos( nId, nNewPos );
+ _pBrowseBox->ColumnMoved( nId );
}
}
}
diff --git a/svtools/source/brwbox/editbrowsebox.cxx b/svtools/source/brwbox/editbrowsebox.cxx
index 2df958fd2ef5..eb092d16c51f 100644
--- a/svtools/source/brwbox/editbrowsebox.cxx
+++ b/svtools/source/brwbox/editbrowsebox.cxx
@@ -489,44 +489,45 @@ namespace svt
else if (IsEditing() && !aController->GetWindow().HasChildPathFocus())
AsynchGetFocus();
- if (IsEditing() && aController->GetWindow().IsEnabled() && aController->WantMouseEvent())
- { // forwards the event to the control
+ if (!(IsEditing() && aController->GetWindow().IsEnabled() && aController->WantMouseEvent()))
+return;
- // If the field has been moved previously, we have to adjust the position
+// forwards the event to the control
- aController->GetWindow().GrabFocus();
+ // If the field has been moved previously, we have to adjust the position
- // the position of the event relative to the controller's window
- Point aPos = _rEvt.GetPosPixel() - _rEvt.GetRect().TopLeft();
- // the (child) window which should really get the event
- vcl::Window* pRealHandler = aController->GetWindow().FindWindow(aPos);
- if (pRealHandler)
- // the coords relative to this real handler
- aPos -= pRealHandler->GetPosPixel();
- else
- pRealHandler = &aController->GetWindow();
+ aController->GetWindow().GrabFocus();
+
+ // the position of the event relative to the controller's window
+ Point aPos = _rEvt.GetPosPixel() - _rEvt.GetRect().TopLeft();
+ // the (child) window which should really get the event
+ vcl::Window* pRealHandler = aController->GetWindow().FindWindow(aPos);
+ if (pRealHandler)
+ // the coords relative to this real handler
+ aPos -= pRealHandler->GetPosPixel();
+ else
+ pRealHandler = &aController->GetWindow();
- // the faked event
- MouseEvent aEvent(aPos, _rEvt.GetClicks(), _rEvt.GetMode(),
- _rEvt.GetButtons(),
- _rEvt.GetModifier());
+ // the faked event
+ MouseEvent aEvent(aPos, _rEvt.GetClicks(), _rEvt.GetMode(),
+ _rEvt.GetButtons(),
+ _rEvt.GetModifier());
- pRealHandler->MouseButtonDown(aEvent);
- if (_bUp)
- pRealHandler->MouseButtonUp(aEvent);
+ pRealHandler->MouseButtonDown(aEvent);
+ if (_bUp)
+ pRealHandler->MouseButtonUp(aEvent);
- vcl::Window *pWin = &aController->GetWindow();
- if (!pWin->IsTracking())
+ vcl::Window *pWin = &aController->GetWindow();
+ if (!pWin->IsTracking())
+ {
+ for (pWin = pWin->GetWindow(GetWindowType::FirstChild);
+ pWin && !pWin->IsTracking();
+ pWin = pWin->GetWindow(GetWindowType::Next))
{
- for (pWin = pWin->GetWindow(GetWindowType::FirstChild);
- pWin && !pWin->IsTracking();
- pWin = pWin->GetWindow(GetWindowType::Next))
- {
- }
}
- if (pWin && pWin->IsTracking())
- pWin->EndTracking();
}
+ if (pWin && pWin->IsTracking())
+ pWin->EndTracking();
}
@@ -770,20 +771,20 @@ namespace svt
GetDataWindow().ApplyControlForeground(GetDataWindow(), rStyleSettings.GetFieldTextColor());
}
- if (bBackground) // FIXME: Outside of Paint Hierarchy
+ if (!bBackground) // FIXME: Outside of Paint Hierarchy
+ return;
+
+ if (GetDataWindow().IsControlBackground())
{
- if (GetDataWindow().IsControlBackground())
- {
- GetDataWindow().SetControlBackground(GetControlBackground());
- GetDataWindow().SetBackground(GetDataWindow().GetControlBackground());
- GetDataWindow().SetFillColor(GetDataWindow().GetControlBackground());
- }
- else
- {
- GetDataWindow().SetControlBackground();
- GetDataWindow().SetBackground(rStyleSettings.GetFieldColor());
- GetDataWindow().SetFillColor(rStyleSettings.GetFieldColor());
- }
+ GetDataWindow().SetControlBackground(GetControlBackground());
+ GetDataWindow().SetBackground(GetDataWindow().GetControlBackground());
+ GetDataWindow().SetFillColor(GetDataWindow().GetControlBackground());
+ }
+ else
+ {
+ GetDataWindow().SetControlBackground();
+ GetDataWindow().SetBackground(rStyleSettings.GetFieldColor());
+ GetDataWindow().SetFillColor(rStyleSettings.GetFieldColor());
}
}
@@ -940,38 +941,38 @@ namespace svt
return;
}
- if (nEditRow >= 0 && nEditCol > HandleColumnId)
+ if (!(nEditRow >= 0 && nEditCol > HandleColumnId))
+ return;
+
+ aController = GetController(nRow, nCol);
+ if (aController.is())
{
- aController = GetController(nRow, nCol);
- if (aController.is())
- {
- tools::Rectangle aRect( GetCellRect(nEditRow, nEditCol, false));
- ResizeController(aController, aRect);
+ tools::Rectangle aRect( GetCellRect(nEditRow, nEditCol, false));
+ ResizeController(aController, aRect);
- InitController(aController, nEditRow, nEditCol);
+ InitController(aController, nEditRow, nEditCol);
- aController->ClearModified();
- aController->SetModifyHdl(LINK(this,EditBrowseBox,ModifyHdl));
- EnableAndShow();
+ aController->ClearModified();
+ aController->SetModifyHdl(LINK(this,EditBrowseBox,ModifyHdl));
+ EnableAndShow();
- if ( isAccessibleAlive() )
- implCreateActiveAccessible();
+ if ( isAccessibleAlive() )
+ implCreateActiveAccessible();
- // activate the cell only of the browser has the focus
- if ( bHasFocus && bCellFocus )
- AsynchGetFocus();
- }
- else
+ // activate the cell only of the browser has the focus
+ if ( bHasFocus && bCellFocus )
+ AsynchGetFocus();
+ }
+ else
+ {
+ // no controller -> we have a new "active descendant"
+ if ( isAccessibleAlive() && HasFocus() )
{
- // no controller -> we have a new "active descendant"
- if ( isAccessibleAlive() && HasFocus() )
- {
- commitTableEvent(
- ACTIVE_DESCENDANT_CHANGED,
- makeAny( CreateAccessibleCell( nRow, GetColumnPos( nCol -1) ) ),
- Any()
- );
- }
+ commitTableEvent(
+ ACTIVE_DESCENDANT_CHANGED,
+ makeAny( CreateAccessibleCell( nRow, GetColumnPos( nCol -1) ) ),
+ Any()
+ );
}
}
}
@@ -979,37 +980,37 @@ namespace svt
void EditBrowseBox::DeactivateCell(bool bUpdate)
{
- if (IsEditing())
+ if (!IsEditing())
+ return;
+
+ if ( isAccessibleAlive() )
{
- if ( isAccessibleAlive() )
- {
- commitBrowseBoxEvent( CHILD, Any(), makeAny( m_aImpl->m_xActiveCell ) );
- m_aImpl->clearActiveCell();
- }
+ commitBrowseBoxEvent( CHILD, Any(), makeAny( m_aImpl->m_xActiveCell ) );
+ m_aImpl->clearActiveCell();
+ }
- aOldController = aController;
- aController.clear();
+ aOldController = aController;
+ aController.clear();
- // reset the modify handler
- aOldController->SetModifyHdl(Link<LinkParamNone*,void>());
+ // reset the modify handler
+ aOldController->SetModifyHdl(Link<LinkParamNone*,void>());
- if (bHasFocus)
- GrabFocus(); // ensure that we have (and keep) the focus
+ if (bHasFocus)
+ GrabFocus(); // ensure that we have (and keep) the focus
- aOldController->suspend();
+ aOldController->suspend();
- // update if requested
- if (bUpdate)
- Update();
+ // update if requested
+ if (bUpdate)
+ Update();
- nOldEditCol = nEditCol;
- nOldEditRow = nEditRow;
+ nOldEditCol = nEditCol;
+ nOldEditRow = nEditRow;
- // release the controller (asynchronously)
- if (nEndEvent)
- Application::RemoveUserEvent(nEndEvent);
- nEndEvent = Application::PostUserEvent(LINK(this,EditBrowseBox,EndEditHdl), nullptr, true);
- }
+ // release the controller (asynchronously)
+ if (nEndEvent)
+ Application::RemoveUserEvent(nEndEvent);
+ nEndEvent = Application::PostUserEvent(LINK(this,EditBrowseBox,EndEditHdl), nullptr, true);
}
diff --git a/svtools/source/brwbox/editbrowsebox2.cxx b/svtools/source/brwbox/editbrowsebox2.cxx
index d705b99d063a..3d962b425501 100644
--- a/svtools/source/brwbox/editbrowsebox2.cxx
+++ b/svtools/source/brwbox/editbrowsebox2.cxx
@@ -65,24 +65,24 @@ void EditBrowseBox::implCreateActiveAccessible( )
DBG_ASSERT( IsEditing(), "EditBrowseBox::implCreateActiveAccessible: not to be called if we're not editing currently!" );
DBG_ASSERT( !m_aImpl->m_xActiveCell.is(), "EditBrowseBox::implCreateActiveAccessible: not to be called if the old one is still alive!" );
- if ( !m_aImpl->m_xActiveCell.is() && IsEditing() )
- {
- Reference< XAccessible > xCont = aController->GetWindow().GetAccessible();
- Reference< XAccessible > xMy = GetAccessible();
- if ( xMy.is() && xCont.is() )
- {
- m_aImpl->m_xActiveCell = getAccessibleFactory().createEditBrowseBoxTableCellAccess(
- xMy, // parent accessible
- xCont, // control accessible
- VCLUnoHelper::GetInterface( &aController->GetWindow() ), // focus window (for notifications)
- *this, // the browse box
- GetCurRow(),
- GetColumnPos( GetCurColumnId() )
- );
-
- commitBrowseBoxEvent( CHILD, makeAny( m_aImpl->m_xActiveCell ), Any() );
- }
- }
+ if ( !(!m_aImpl->m_xActiveCell.is() && IsEditing()) )
+ return;
+
+ Reference< XAccessible > xCont = aController->GetWindow().GetAccessible();
+ Reference< XAccessible > xMy = GetAccessible();
+ if ( !(xMy.is() && xCont.is()) )
+ return;
+
+ m_aImpl->m_xActiveCell = getAccessibleFactory().createEditBrowseBoxTableCellAccess(
+ xMy, // parent accessible
+ xCont, // control accessible
+ VCLUnoHelper::GetInterface( &aController->GetWindow() ), // focus window (for notifications)
+ *this, // the browse box
+ GetCurRow(),
+ GetColumnPos( GetCurColumnId() )
+ );
+
+ commitBrowseBoxEvent( CHILD, makeAny( m_aImpl->m_xActiveCell ), Any() );
}
@@ -127,40 +127,40 @@ void EditBrowseBox::DetermineFocus( const GetFocusFlags _nGetFocusFlags )
pWindow = pWindow->GetParent())
bFocus = pWindow == this;
- if (bFocus != bHasFocus)
- {
- bHasFocus = bFocus;
+ if (bFocus == bHasFocus)
+ return;
+
+ bHasFocus = bFocus;
+
+ if ( !(GetBrowserFlags( ) & EditBrowseBoxFlags::SMART_TAB_TRAVEL) )
+ return;
+
+ if ( !(bHasFocus // we got the focus
+ && ( _nGetFocusFlags & GetFocusFlags::Tab )) // using the TAB key
+ )
+ return;
- if ( GetBrowserFlags( ) & EditBrowseBoxFlags::SMART_TAB_TRAVEL )
+ long nRows = GetRowCount();
+ sal_uInt16 nCols = ColCount();
+
+ if ( ( nRows > 0 ) && ( nCols > 0 ) )
+ {
+ if ( _nGetFocusFlags & GetFocusFlags::Forward )
{
- if ( bHasFocus // we got the focus
- && ( _nGetFocusFlags & GetFocusFlags::Tab ) // using the TAB key
- )
+ if ( GetColumnId( 0 ) != HandleColumnId )
{
- long nRows = GetRowCount();
- sal_uInt16 nCols = ColCount();
-
- if ( ( nRows > 0 ) && ( nCols > 0 ) )
- {
- if ( _nGetFocusFlags & GetFocusFlags::Forward )
- {
- if ( GetColumnId( 0 ) != HandleColumnId )
- {
- GoToRowColumnId( 0, GetColumnId( 0 ) );
- }
- else
- { // the first column is the handle column -> not focussable
- if ( nCols > 1 )
- GoToRowColumnId( 0, GetColumnId( 1 ) );
- }
- }
- else if ( _nGetFocusFlags & GetFocusFlags::Backward )
- {
- GoToRowColumnId( nRows - 1, GetColumnId( nCols -1 ) );
- }
- }
+ GoToRowColumnId( 0, GetColumnId( 0 ) );
+ }
+ else
+ { // the first column is the handle column -> not focussable
+ if ( nCols > 1 )
+ GoToRowColumnId( 0, GetColumnId( 1 ) );
}
}
+ else if ( _nGetFocusFlags & GetFocusFlags::Backward )
+ {
+ GoToRowColumnId( nRows - 1, GetColumnId( nCols -1 ) );
+ }
}
}