sc/source/ui/view/viewfun2.cxx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
New commits: commit cd2e7b7e4e46cb298c50fe8d8b512b1b36b3e197 Author: Henry Castro <hcas...@collabora.com> Date: Fri May 29 11:53:50 2015 -0400 sc: SvxSearchItem, m_nStartPoint{X,Y} The idea is that if you have your cursor at the begining of a Calc document, and you scroll down a lot, then search, then it's annoying that search jumps back to the start of the document for the first hit. Add an optional way to provide what is the starting point of such a search, so we can have "when nothing is selected, then search from the top left corner of the visible area". Change-Id: I22624dd52a093759d46541e003d838aeb0db943f diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index 49d70d8..47b0ace 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -1640,6 +1640,23 @@ bool ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem, if (bAddUndo && !rDoc.IsUndoEnabled()) bAddUndo = false; + if ( !rMark.IsMarked() && !rMark.IsMultiMarked() && (pSearchItem->HasStartPoint()) ) + { + // No selection -> but we have a start point (top left corner of the + // current view), start searching from there, not from the current + // cursor position. + SCsCOL nPosX; + SCsROW nPosY; + + int nPixelX = pSearchItem->GetStartPointX() * GetViewData().GetPPTX(); + int nPixelY = pSearchItem->GetStartPointY() * GetViewData().GetPPTY(); + + GetViewData().GetPosFromPixel(nPixelX, nPixelY, GetViewData().GetActivePart(), nPosX, nPosY); + + AlignToCursor( nPosX, nPosY, SC_FOLLOW_JUMP ); + SetCursor( nPosX, nPosY, true ); + } + SCCOL nCol, nOldCol; SCROW nRow, nOldRow; SCTAB nTab, nOldTab; @@ -1829,9 +1846,9 @@ bool ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem, if (pGridWindow) { // move the cell selection handles + pGridWindow->SetCellSelectionPixel(LOK_SETTEXTSELECTION_RESET, aCurPos.X(), aCurPos.Y()); pGridWindow->SetCellSelectionPixel(LOK_SETTEXTSELECTION_START, aCurPos.X(), aCurPos.Y()); pGridWindow->SetCellSelectionPixel(LOK_SETTEXTSELECTION_END, aCurPos.X(), aCurPos.Y()); - pGridWindow->SetCellSelectionPixel(LOK_SETTEXTSELECTION_RESET, aCurPos.X(), aCurPos.Y()); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits