include/svtools/brwbox.hxx | 24 ++++++++++++++++++++++++ svtools/source/brwbox/brwbox1.cxx | 19 +++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-)
New commits: commit 827ae65e8577e285b8ad30f4a81af087658e42fa Author: Caolán McNamara <caol...@redhat.com> Date: Fri Sep 26 12:51:07 2014 +0100 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 diff --git a/include/svtools/brwbox.hxx b/include/svtools/brwbox.hxx index 34eb593..e16e0de 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 4416b23..3fedada 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;
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits