From 6bccdf23fdf755494e840a3a21380a754969df73 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 28 May 2015 17:13:38 +0200 Subject: 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) --- desktop/source/lib/init.cxx | 2 ++ include/sfx2/msg.hxx | 2 +- include/svl/memberid.hrc | 2 ++ include/svl/srchitem.hxx | 9 +++++++++ sfx2/sdi/sfxitems.sdi | 2 ++ svl/source/items/srchitem.cxx | 32 ++++++++++++++++++++++++++++++-- sw/source/uibase/uiview/viewsrch.cxx | 10 ++++++++++ 7 files changed, 56 insertions(+), 3 deletions(-) diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 00d0976f0485..71e943185744 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -742,6 +742,8 @@ static void jsonToPropertyValues(const char* pJSON, uno::Sequence>= m_nStartPointX); + break; + } + case MID_SEARCH_STARTPOINTY: + { + bRet = (rVal >>= m_nStartPointY); + break; + } default: OSL_FAIL( "Unknown MemberId" ); } @@ -611,5 +625,19 @@ bool SvxSearchItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nM return bRet; } +sal_Int32 SvxSearchItem::GetStartPointX() const +{ + return m_nStartPointX; +} + +sal_Int32 SvxSearchItem::GetStartPointY() const +{ + return m_nStartPointY; +} + +bool SvxSearchItem::HasStartPoint() const +{ + return m_nStartPointX > 0 || m_nStartPointY > 0; +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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); -- cgit v1.2.3