summaryrefslogtreecommitdiff
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
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)
-rw-r--r--desktop/source/lib/init.cxx2
-rw-r--r--include/sfx2/msg.hxx2
-rw-r--r--include/svl/memberid.hrc2
-rw-r--r--include/svl/srchitem.hxx9
-rw-r--r--sfx2/sdi/sfxitems.sdi2
-rw-r--r--svl/source/items/srchitem.cxx32
-rw-r--r--sw/source/uibase/uiview/viewsrch.cxx10
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<beans::Propert
aValue.Value <<= OUString::fromUtf8(rValue.c_str());
else if (rType == "boolean")
aValue.Value <<= OString(rValue.c_str()).toBoolean();
+ else if (rType == "long")
+ aValue.Value <<= OString(rValue.c_str()).toInt32();
else
SAL_WARN("desktop.lib", "jsonToPropertyValues: unhandled type '"<<rType<<"'");
aArguments.push_back(aValue);
diff --git a/include/sfx2/msg.hxx b/include/sfx2/msg.hxx
index 58785ff82d5d..89faffd09c06 100644
--- a/include/sfx2/msg.hxx
+++ b/include/sfx2/msg.hxx
@@ -155,7 +155,7 @@ SFX_DECL_TYPE(13); // for SwAddPrinterItem, Sd...
SFX_DECL_TYPE(14);
SFX_DECL_TYPE(16); // for SwDocDisplayItem
SFX_DECL_TYPE(17); // for SvxAddressItem
-SFX_DECL_TYPE(18); // for SvxSearchItem
+SFX_DECL_TYPE(20); // for SvxSearchItem
// all SfxTypes must be in this header
#undef SFX_DECL_TYPE
diff --git a/include/svl/memberid.hrc b/include/svl/memberid.hrc
index ef5639523e8e..1593e2379aec 100644
--- a/include/svl/memberid.hrc
+++ b/include/svl/memberid.hrc
@@ -53,6 +53,8 @@
#define MID_SEARCH_INSERTEDCHARS 17
#define MID_SEARCH_TRANSLITERATEFLAGS 18
#define MID_SEARCH_COMMAND 19
+#define MID_SEARCH_STARTPOINTX 20
+#define MID_SEARCH_STARTPOINTY 21
#endif
diff --git a/include/svl/srchitem.hxx b/include/svl/srchitem.hxx
index 7ce0f77c8922..9a298585e43a 100644
--- a/include/svl/srchitem.hxx
+++ b/include/svl/srchitem.hxx
@@ -84,6 +84,10 @@ class SVL_DLLPUBLIC SvxSearchItem :
bool bContent; // search in content
bool bAsianOptions; // use asian options?
+ // Start search at this point (absolute twips).
+ sal_Int32 m_nStartPointX;
+ sal_Int32 m_nStartPointY;
+
virtual void ImplCommit() SAL_OVERRIDE;
public:
@@ -184,6 +188,11 @@ public:
inline bool IsUseAsianOptions() const { return bAsianOptions; }
inline void SetUseAsianOptions( bool bVal ) { bAsianOptions = bVal; }
+
+ sal_Int32 GetStartPointX() const;
+ sal_Int32 GetStartPointY() const;
+ /// Either x or y start point is set.
+ bool HasStartPoint() const;
};
const OUString SvxSearchItem::GetSearchString() const
diff --git a/sfx2/sdi/sfxitems.sdi b/sfx2/sdi/sfxitems.sdi
index 1d7649e1d98d..f293e5c90a6f 100644
--- a/sfx2/sdi/sfxitems.sdi
+++ b/sfx2/sdi/sfxitems.sdi
@@ -89,6 +89,8 @@
INT32 InsertedChars MID_SEARCH_INSERTEDCHARS;
INT32 TransliterateFlags MID_SEARCH_TRANSLITERATEFLAGS;
INT16 Command MID_SEARCH_COMMAND;
+ INT32 SearchStartPointX MID_SEARCH_STARTPOINTX;
+ INT32 SearchStartPointY MID_SEARCH_STARTPOINTY;
};
item SvxSearch SvxSearchItem;
diff --git a/svl/source/items/srchitem.cxx b/svl/source/items/srchitem.cxx
index e46d2557e7d9..986463e1d489 100644
--- a/svl/source/items/srchitem.cxx
+++ b/svl/source/items/srchitem.cxx
@@ -125,7 +125,9 @@ SvxSearchItem::SvxSearchItem( const sal_uInt16 nId ) :
bBackward ( false ),
bPattern ( false ),
bContent ( false ),
- bAsianOptions ( false )
+ bAsianOptions ( false ),
+ m_nStartPointX(0),
+ m_nStartPointY(0)
{
EnableNotification( lcl_GetNotifyNames() );
@@ -211,7 +213,9 @@ SvxSearchItem::SvxSearchItem( const SvxSearchItem& rItem ) :
bBackward ( rItem.bBackward ),
bPattern ( rItem.bPattern ),
bContent ( rItem.bContent ),
- bAsianOptions ( rItem.bAsianOptions )
+ bAsianOptions ( rItem.bAsianOptions ),
+ m_nStartPointX(rItem.m_nStartPointX),
+ m_nStartPointY(rItem.m_nStartPointY)
{
EnableNotification( lcl_GetNotifyNames() );
}
@@ -604,6 +608,16 @@ bool SvxSearchItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nM
}
break;
}
+ case MID_SEARCH_STARTPOINTX:
+ {
+ bRet = (rVal >>= 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);