diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-12-12 09:17:17 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-12-12 10:01:41 +0000 |
commit | 09400837349f3f42d47ff570abb3c2d5f50b3e50 (patch) | |
tree | 11921f823fa1f382fd299aed15ec16a583579be0 | |
parent | 9b7a7ba72880fe90a0139ddca4bfc9ad180a6d4d (diff) |
Resolves: fdo#42694 crash inserting table control
(cherry picked from commit 4521fc855b319bd8aa6583900d97c026bcc5f32f)
Signed-off-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | svtools/source/brwbox/brwbox2.cxx | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/svtools/source/brwbox/brwbox2.cxx b/svtools/source/brwbox/brwbox2.cxx index 30937db70ea2..92c29de12bd6 100644 --- a/svtools/source/brwbox/brwbox2.cxx +++ b/svtools/source/brwbox/brwbox2.cxx @@ -599,8 +599,10 @@ void BrowseBox::Resize() nSBSize = (sal_uLong)(nSBSize * (double)GetZoom()); DoHideCursor( "Resize" ); - sal_uInt16 nOldVisibleRows = - (sal_uInt16)(pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight() + 1); + sal_uInt16 nOldVisibleRows = 0; + //fdo#42694, post #i111125# GetDataRowHeight() can be 0 + if (GetDataRowHeight()) + nOldVisibleRows = (sal_uInt16)(pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight() + 1); // did we need a horiz. scroll bar oder gibt es eine Control Area? if ( !getDataWindow()->bNoHScroll && @@ -623,8 +625,10 @@ void BrowseBox::Resize() Point( 0, GetTitleHeight() ), Size( nDataWidth, nDataHeight ) ); - sal_uInt16 nVisibleRows = - (sal_uInt16)(pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight() + 1); + sal_uInt16 nVisibleRows = 0; + + if (GetDataRowHeight()) + nVisibleRows = (sal_uInt16)(pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight() + 1); // TopRow ist unveraendert, aber die Anzahl sichtbarer Zeilen hat sich // geaendert @@ -911,8 +915,13 @@ void BrowseBox::ImplPaintData(OutputDevice& _rOut, const Rectangle& _rRect, sal_ long nDataRowHeigt = GetDataRowHeight(); // compute relative rows to redraw - sal_uLong nRelTopRow = _bForeignDevice ? 0 : ((sal_uLong)_rRect.Top() / nDataRowHeigt); - sal_uLong nRelBottomRow = (sal_uLong)(_bForeignDevice ? aOverallAreaSize.Height() : _rRect.Bottom()) / nDataRowHeigt; + sal_uLong nRelTopRow = 0; + sal_uLong nRelBottomRow = aOverallAreaSize.Height(); + if (!_bForeignDevice && nDataRowHeigt) + { + nRelTopRow = ((sal_uLong)_rRect.Top() / nDataRowHeigt); + nRelBottomRow = (sal_uLong)(_rRect.Bottom()) / nDataRowHeigt; + } // cache frequently used values Point aPos( aOverallAreaPos.X(), nRelTopRow * nDataRowHeigt + aOverallAreaPos.Y() ); @@ -1182,11 +1191,16 @@ void BrowseBox::UpdateScrollbars() if (IsZoom()) nCornerSize = (sal_uLong)(nCornerSize * (double)GetZoom()); - // needs VScroll? - long nMaxRows = (pDataWin->GetSizePixel().Height()) / GetDataRowHeight(); - sal_Bool bNeedsVScroll = getDataWindow()->bAutoVScroll - ? nTopRow || ( nRowCount > nMaxRows ) - : !getDataWindow()->bNoVScroll; + sal_Bool bNeedsVScroll = sal_False; + long nMaxRows = 0; + if (GetDataRowHeight()) + { + // needs VScroll? + nMaxRows = (pDataWin->GetSizePixel().Height()) / GetDataRowHeight(); + bNeedsVScroll = getDataWindow()->bAutoVScroll + ? nTopRow || ( nRowCount > nMaxRows ) + : !getDataWindow()->bNoVScroll; + } Size aDataWinSize = pDataWin->GetSizePixel(); if ( !bNeedsVScroll ) { @@ -1269,8 +1283,8 @@ void BrowseBox::UpdateScrollbars() pVScroll->SetPosSizePixel( Point( aDataWinSize.Width(), GetTitleHeight() ), Size( nCornerSize, aDataWinSize.Height()) ); - if ( nRowCount < - long( aDataWinSize.Height() / GetDataRowHeight() ) ) + long nLclDataRowHeight = GetDataRowHeight(); + if ( nLclDataRowHeight > 0 && nRowCount < long( aDataWinSize.Height() / nLclDataRowHeight ) ) ScrollRows( -nTopRow ); if ( bNeedsVScroll && !pVScroll->IsVisible() ) pVScroll->Show(); |