diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-09-26 12:51:07 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-09-26 13:12:47 +0100 |
commit | 827ae65e8577e285b8ad30f4a81af087658e42fa (patch) | |
tree | 14456f13d1d7efdf77661fe6cf818f02b8ef38fa | |
parent | 0014648fee6c2b499cbd20682b7f27cdc78e1123 (diff) |
Resolves: fdo#83943 avoid infinite recursion
when attempting to make a cell visible when
the parent simply isn't large enough to show
any part of the cell
Change-Id: I987c9b3be30a66a5e1e27ad9e452f2ca65330d9e
-rw-r--r-- | include/svtools/brwbox.hxx | 24 | ||||
-rw-r--r-- | svtools/source/brwbox/brwbox1.cxx | 19 |
2 files changed, 41 insertions, 2 deletions
diff --git a/include/svtools/brwbox.hxx b/include/svtools/brwbox.hxx index 34eb59335a88..e16e0de43401 100644 --- a/include/svtools/brwbox.hxx +++ b/include/svtools/brwbox.hxx @@ -271,6 +271,30 @@ private: } uRow; MultiSelection* pColSel; // selected column-ids + //fdo#83943, detect if making the cursor position + //visible is impossible to achieve + struct CursorMoveAttempt + { + long m_nCol; + long m_nRow; + bool m_bScrolledToReachCell; + CursorMoveAttempt(long nCol, long nRow, bool bScrolledToReachCell) + : m_nCol(nCol) + , m_nRow(nRow) + , m_bScrolledToReachCell(bScrolledToReachCell) + { + } + bool operator==(const CursorMoveAttempt& r) const + { + return m_nCol == r.m_nCol && + m_nRow == r.m_nRow && + m_bScrolledToReachCell == r.m_bScrolledToReachCell; + } + bool operator!=(const CursorMoveAttempt& r) const { return !(*this == r); } + }; + typedef std::stack<CursorMoveAttempt> GotoStack; + GotoStack m_aGotoStack; + ::std::auto_ptr< ::svt::BrowseBoxImpl > m_pImpl; // impl structure of the BrowseBox object bool m_bFocusOnlyCursor; // hide cursor if we don't have the focus diff --git a/svtools/source/brwbox/brwbox1.cxx b/svtools/source/brwbox/brwbox1.cxx index 4416b2347537..3fedada33ca0 100644 --- a/svtools/source/brwbox/brwbox1.cxx +++ b/svtools/source/brwbox/brwbox1.cxx @@ -1560,7 +1560,6 @@ bool BrowseBox::GoToColumnId( sal_uInt16 nColId) bool BrowseBox::GoToColumnId( sal_uInt16 nColId, bool bMakeVisible, bool bRowColMove) { - if (!bColumnCursor) return false; @@ -1579,6 +1578,8 @@ bool BrowseBox::GoToColumnId( sal_uInt16 nColId, bool bMakeVisible, bool bRowCol DoHideCursor( "GoToColumnId" ); nCurColId = nColId; + bool bScrolled = false; + sal_uInt16 nFirstPos = nFirstCol; sal_uInt16 nWidth = (sal_uInt16)pColumn->Width(); sal_uInt16 nLastPos = GetColumnAtXPosPixel( @@ -1591,11 +1592,25 @@ bool BrowseBox::GoToColumnId( sal_uInt16 nColId, bool bMakeVisible, bool bRowCol ScrollColumns( nNewPos-nFirstPos ); else if ( nNewPos > nLastPos ) ScrollColumns( nNewPos-nLastPos ); + bScrolled = true; } DoShowCursor( "GoToColumnId" ); if (!bRowColMove) - CursorMoved(); + { + //try to move to nCurRow, nColId + CursorMoveAttempt aAttempt(nCurRow, nColId, bScrolled); + //Detect if we are already in a call to BrowseBox::GoToColumnId + //but the the attempt is impossible and we are simply recursing + //into BrowseBox::GoToColumnId with the same impossible to + //fulfill conditions + if (m_aGotoStack.empty() || aAttempt != m_aGotoStack.top()) + { + m_aGotoStack.push(aAttempt); + CursorMoved(); + m_aGotoStack.pop(); + } + } return true; } return true; |