What are the Enumeration Names for SearchDescriptor.SearchType

I have a Basic macro that searches a spreadsheet cell range for a string:

cu = sheet.createCursorByRange(sheet.getCellRangeByName("A1"))' Cursor object comprising the
cu.gotoEndOfUsedArea(True)			' Entire used area of the sheet
so = cu.createSearchDescriptor()	' Create the SearchObject
so.SearchString = "SomeString"	 	' Specify the string to find
so.SearchType=1						' Search Values  
sr = cu.findAll(so)					' Execute the search

It works just fine.

After some trial and error, I discovered that setting SearchType=0 searches Formulas rather than Values. I’d much prefer to write so.SearchType=VALUES and so.SearchType=FORMULAS, but try as I might, I cannot find any documentation that lists the valid Enumeration Names for SearchType. Can anyone provide a reference?

1 Like

include/svl/srchitem.hxx#43

There are no published constants for these values. So you may only create the constants in your module yourself, with a reference to the source, which could help you later to find out where these values come from.

1 Like

By the way, you can use createCursor() instead of createCursorByRange (cell A1) - this creates a cell cursor including the whole spreadsheet. And the next .gotoEndOfUsedArea(True) will also select the “UsedArea” in the same way.

Just a minor remark: cu.gotoStartOfUsedArea(False) will only go to A1 if it is used.
Used cells are cells having content, or any hard attrubute, or an annotation, or a named CellStyle differing in some detail from ‘Default Cell Style’.
A validity setting or a conditional format including it with its range don’t make the cell “used”.
(This is not from a specification known to me, but from own “research”.)

It is here

Thanks @JohnSun. I was about to update my post to ask if anyone could even just confirm that there were no defined enumerations, but you did so. Thanks for the reference too. In my search prior to posting my question, I had found the the Cursors documentation in your link by entering ‘SearchType’ in the search box at the top of the Apache OpenOffice WiKi. But abandoned that result after not seeing anything during a cursory (no pun intended!) read. I should have used ‘find in page’ to search the Cursors page itself for SearchType, which immediately provides the answer, which I’ll now include in my code comments. Thanks again.

Thanks too for pointing out the use of CreateCursor(). It’s simpler and cleaner for my purposes.

By The Way, thanks also to @MikeKaganski for a link to the source code itself. I’m not qualified in C++, but what I gather from perusing the code is that the enumeration names in the code for class SvxSearchCellType are not public?