summaryrefslogtreecommitdiff
path: root/sw/source/uibase/uiview/viewsrch.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-05-28 17:13:38 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-05-29 09:50:14 +0200
commit6bccdf23fdf755494e840a3a21380a754969df73 (patch)
tree3cfe6b88e1b4a739e05b68c19402e24457c56632 /sw/source/uibase/uiview/viewsrch.cxx
parent7a3d25c5916dc293a8d30e24c41aee4b7154a39a (diff)
SvxSearchItem: add m_nStartPoint{X,Y}
The idea is that if you have your cursor at the begining of a Writer 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". No UI yet to enable this, but available via the UNO API. Change-Id: Ibcf3a5f2eeba1372b1dfe8474081e6591a6e0134 (cherry picked from commit 1dc60bc9e99304c58007bfd5a964ff3f78480106)
Diffstat (limited to 'sw/source/uibase/uiview/viewsrch.cxx')
-rw-r--r--sw/source/uibase/uiview/viewsrch.cxx10
1 files changed, 10 insertions, 0 deletions
diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx
index 3d3dff11cb2f..dbd792b61be8 100644
--- a/sw/source/uibase/uiview/viewsrch.cxx
+++ b/sw/source/uibase/uiview/viewsrch.cxx
@@ -476,6 +476,16 @@ bool SwView::SearchAndWrap(bool bApi)
// selected regions as the cursor doesn't mark the selection in that case.)
m_pWrtShell->GetCrsr()->Normalize( m_pSrchItem->GetBackward() );
+ if (!m_pWrtShell->HasSelection() && (m_pSrchItem->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.
+ SwEditShell& rShell = GetWrtShell();
+ Point aPosition(m_pSrchItem->GetStartPointX(), m_pSrchItem->GetStartPointY());
+ rShell.SetCrsr(aPosition);
+ }
+
// If you want to search in selected areas, they must not be unselected.
if (!m_pSrchItem->GetSelection())
m_pWrtShell->KillSelection(0, false);