LibreOffice Module svx (master)  1
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
FmSearchEngine Class Referencefinal

#include <fmsrcimp.hxx>

Collaboration diagram for FmSearchEngine:
[legend]

Classes

struct  FieldInfo
 

Public Member Functions

void SetCaseSensitive (bool bSet)
 
bool GetCaseSensitive () const
 
void SetFormatterUsing (bool bSet)
 
bool GetFormatterUsing () const
 
void SetDirection (bool bForward)
 
bool GetDirection () const
 
void SetWildcard (bool bSet)
 
bool GetWildcard () const
 
void SetRegular (bool bSet)
 
bool GetRegular () const
 
void SetLevenshtein (bool bSet)
 
bool GetLevenshtein () const
 
void SetIgnoreWidthCJK (bool bSet)
 
bool GetIgnoreWidthCJK () const
 
void SetTransliteration (bool bSet)
 
bool GetTransliteration () const
 
void SetLevRelaxed (bool bSet)
 
bool GetLevRelaxed () const
 
void SetLevOther (sal_uInt16 nHowMuch)
 
sal_uInt16 GetLevOther () const
 
void SetLevShorter (sal_uInt16 nHowMuch)
 
sal_uInt16 GetLevShorter () const
 
void SetLevLonger (sal_uInt16 nHowMuch)
 
sal_uInt16 GetLevLonger () const
 
void SetTransliterationFlags (TransliterationFlags _nFlags)
 
TransliterationFlags GetTransliterationFlags () const
 
void SetPosition (sal_uInt16 nValue)
 
sal_uInt16 GetPosition () const
 
 FmSearchEngine (const css::uno::Reference< css::uno::XComponentContext > &_rxContext, const css::uno::Reference< css::sdbc::XResultSet > &xCursor, const OUString &strVisibleFields, const InterfaceArray &arrFields)
 two constructs, both analogical to FmSearchDialog, therefore look this up for explanations... More...
 
void SetProgressHandler (Link< const FmSearchProgress *, void > aHdl)
 the link will be called on every record and after the completion of the search, the parameter is a pointer to a FmSearchProgress structure the handler should be in any case thread-safe More...
 
void SearchNext (const OUString &strExpression)
 search for the next appearance (for nDirection values check DIRECTION_*-defines) More...
 
void SearchNextSpecial (bool _bSearchForNull)
 analogous, search for "NULL" (_bSearchForNull==sal_True) or "not NULL" More...
 
void StartOver (const OUString &strExpression)
 search for the next appearance, dependent on nDirection from the start or end More...
 
void StartOverSpecial (bool _bSearchForNull)
 analogous, search for "NULL" (_bSearchForNull==sal_True) or "not NULL" More...
 
void InvalidatePreviousLoc ()
 invalidate previous search reference More...
 
void RebuildUsedFields (sal_Int32 nFieldIndex, bool bForce=false)
 rebuilds m_arrUsedFields (nFieldIndex==-1 means all fields, otherwise it specifies the field index) if bForce is not set, nothing will happen in case of nFieldIndex == m_nCurrentFieldIndex (calls InvalidatePreviousLoc) More...
 
OUString FormatField (sal_Int32 nWhich)
 
void CancelSearch ()
 returns directly; once it was really aborted, ProgressHandler is called with STATE_CANCELED More...
 
void SwitchToContext (const css::uno::Reference< css::sdbc::XResultSet > &xCursor, const OUString &strVisibleFields, const InterfaceArray &arrFields, sal_Int32 nFieldIndex)
 only valid, if not an (asynchronous) search is running, the next search will then be executed on top of the new iterator with the new parameter More...
 

Private Types

enum  SearchResult {
  SearchResult::Found,
  SearchResult::NotFound,
  SearchResult::Error,
  SearchResult::Cancelled
}
 
enum  SearchFor {
  SearchFor::String,
  SearchFor::Null,
  SearchFor::NotNull
}
 
typedef std::vector< FieldInfoFieldCollection
 

Private Member Functions

SVX_DLLPRIVATE bool CancelRequested ()
 
void Init (const OUString &strVisibleFields)
 
void SearchNextImpl ()
 
void ImplStartNextSearch ()
 
SVX_DLLPRIVATE void clearControlTexts ()
 
SVX_DLLPRIVATE void fillControlTexts (const InterfaceArray &arrFields)
 
SVX_DLLPRIVATE SearchResult SearchSpecial (bool _bSearchForNull, sal_Int32 &nFieldPos, FieldCollection::iterator &iterFieldLoop, const FieldCollection::iterator &iterBegin, const FieldCollection::iterator &iterEnd)
 
SVX_DLLPRIVATE SearchResult SearchWildcard (const OUString &strExpression, sal_Int32 &nFieldPos, FieldCollection::iterator &iterFieldLoop, const FieldCollection::iterator &iterBegin, const FieldCollection::iterator &iterEnd)
 
SVX_DLLPRIVATE SearchResult SearchRegularApprox (const OUString &strExpression, sal_Int32 &nFieldPos, FieldCollection::iterator &iterFieldLoop, const FieldCollection::iterator &iterBegin, const FieldCollection::iterator &iterEnd)
 
SVX_DLLPRIVATE void PropagateProgress (bool _bDontPropagateOverflow)
 
SVX_DLLPRIVATE bool MoveCursor ()
 
SVX_DLLPRIVATE bool MoveField (sal_Int32 &nPos, FieldCollection::iterator &iter, const FieldCollection::iterator &iterBegin, const FieldCollection::iterator &iterEnd)
 
SVX_DLLPRIVATE void BuildAndInsertFieldInfo (const css::uno::Reference< css::container::XIndexAccess > &xAllFields, sal_Int32 nField)
 
void OnSearchTerminated ()
 
 DECL_LINK (OnNewRecordCount, sal_Int32, void)
 

Private Attributes

CursorWrapper m_xSearchCursor
 
std::deque< sal_Int32 > m_arrFieldMapping
 
CharClass const m_aCharacterClassficator
 
CollatorWrapper m_aStringCompare
 
FieldCollection m_arrUsedFields
 
sal_Int32 m_nCurrentFieldIndex
 
std::vector< std::unique_ptr< svxform::ControlTextWrapper > > m_aControlTexts
 
CursorWrapper m_xOriginalIterator
 
CursorWrapper m_xClonedIterator
 
css::uno::Any m_aPreviousLocBookmark
 
FieldCollection::iterator m_iterPreviousLocField
 
OUString m_strSearchExpression
 
SearchFor m_eSearchForType
 
SearchResult m_srResult
 
Link< const FmSearchProgress *, voidm_aProgressHandler
 
bool m_bSearchingCurrently: 1
 
bool m_bCancelAsynchRequest: 1
 
::osl::Mutex m_aCancelAsynchAccess
 
bool m_bFormatter: 1
 
bool m_bForward: 1
 
bool m_bWildcard: 1
 
bool m_bRegular: 1
 
bool m_bLevenshtein: 1
 
bool m_bTransliteration: 1
 
bool m_bLevRelaxed: 1
 
sal_uInt16 m_nLevOther
 
sal_uInt16 m_nLevShorter
 
sal_uInt16 m_nLevLonger
 
sal_uInt16 m_nPosition
 
TransliterationFlags m_nTransliterationFlags
 

Friends

class FmSearchThread
 

Detailed Description

Definition at line 151 of file fmsrcimp.hxx.

Member Typedef Documentation

typedef std::vector<FieldInfo> FmSearchEngine::FieldCollection
private

Definition at line 172 of file fmsrcimp.hxx.

Member Enumeration Documentation

enum FmSearchEngine::SearchFor
strongprivate
Enumerator
String 
Null 
NotNull 

Definition at line 156 of file fmsrcimp.hxx.

enum FmSearchEngine::SearchResult
strongprivate
Enumerator
Found 
NotFound 
Error 
Cancelled 

Definition at line 155 of file fmsrcimp.hxx.

Constructor & Destructor Documentation

FmSearchEngine::FmSearchEngine ( const css::uno::Reference< css::uno::XComponentContext > &  _rxContext,
const css::uno::Reference< css::sdbc::XResultSet > &  xCursor,
const OUString &  strVisibleFields,
const InterfaceArray arrFields 
)

two constructs, both analogical to FmSearchDialog, therefore look this up for explanations...

xCursor has to implement css::data::DatabaseCursor service each time. If eMode == SM_USETHREAD, a ProgressHandler should be set, because in this case the result forwarding will be done by this handler. If eMode != SM_USETHREAD, SearchNext and StarOver won't return, until the search has finished (independently of its success), only then the result can be requested. If additionally the ProgressHandler is set, it will be called for every record as well as at the end of the search.

Definition at line 546 of file fmsrcimp.cxx.

References fillControlTexts(), Init(), NONE, and String.

Member Function Documentation

void FmSearchEngine::BuildAndInsertFieldInfo ( const css::uno::Reference< css::container::XIndexAccess > &  xAllFields,
sal_Int32  nField 
)
private

Definition at line 260 of file fmsrcimp.cxx.

References DBG_ASSERT, and FmSearchEngine::FieldInfo::xContents.

Referenced by RebuildUsedFields().

bool FmSearchEngine::CancelRequested ( )
private

Definition at line 931 of file fmsrcimp.cxx.

References m_aCancelAsynchAccess, and m_bCancelAsynchRequest.

void FmSearchEngine::CancelSearch ( )

returns directly; once it was really aborted, ProgressHandler is called with STATE_CANCELED

Definition at line 940 of file fmsrcimp.cxx.

References m_aCancelAsynchAccess, and m_bCancelAsynchRequest.

void FmSearchEngine::clearControlTexts ( )
private

Definition at line 608 of file fmsrcimp.cxx.

References m_aControlTexts.

Referenced by fillControlTexts().

FmSearchEngine::DECL_LINK ( OnNewRecordCount  ,
sal_Int32  ,
void   
)
private
void FmSearchEngine::fillControlTexts ( const InterfaceArray arrFields)
private

Definition at line 614 of file fmsrcimp.cxx.

References clearControlTexts(), DBG_ASSERT, and m_aControlTexts.

Referenced by FmSearchEngine(), and SwitchToContext().

OUString FmSearchEngine::FormatField ( sal_Int32  nWhich)

Definition at line 282 of file fmsrcimp.cxx.

References DBG_ASSERT.

bool FmSearchEngine::GetCaseSensitive ( ) const

Definition at line 602 of file fmsrcimp.cxx.

References m_nTransliterationFlags.

Referenced by SearchNextImpl().

bool FmSearchEngine::GetDirection ( ) const
inline

Definition at line 228 of file fmsrcimp.hxx.

bool FmSearchEngine::GetFormatterUsing ( ) const
inline

Definition at line 225 of file fmsrcimp.hxx.

bool FmSearchEngine::GetIgnoreWidthCJK ( ) const

Definition at line 587 of file fmsrcimp.cxx.

References m_nTransliterationFlags.

bool FmSearchEngine::GetLevenshtein ( ) const
inline

Definition at line 237 of file fmsrcimp.hxx.

sal_uInt16 FmSearchEngine::GetLevLonger ( ) const
inline

Definition at line 252 of file fmsrcimp.hxx.

sal_uInt16 FmSearchEngine::GetLevOther ( ) const
inline

Definition at line 248 of file fmsrcimp.hxx.

bool FmSearchEngine::GetLevRelaxed ( ) const
inline

Definition at line 246 of file fmsrcimp.hxx.

sal_uInt16 FmSearchEngine::GetLevShorter ( ) const
inline

Definition at line 250 of file fmsrcimp.hxx.

sal_uInt16 FmSearchEngine::GetPosition ( ) const
inline

Definition at line 260 of file fmsrcimp.hxx.

bool FmSearchEngine::GetRegular ( ) const
inline

Definition at line 234 of file fmsrcimp.hxx.

bool FmSearchEngine::GetTransliteration ( ) const
inline

Definition at line 243 of file fmsrcimp.hxx.

TransliterationFlags FmSearchEngine::GetTransliterationFlags ( ) const
inline

Definition at line 257 of file fmsrcimp.hxx.

bool FmSearchEngine::GetWildcard ( ) const
inline

Definition at line 231 of file fmsrcimp.hxx.

void FmSearchEngine::ImplStartNextSearch ( )
private
void FmSearchEngine::Init ( const OUString &  strVisibleFields)
private
void FmSearchEngine::InvalidatePreviousLoc ( )

invalidate previous search reference

Definition at line 1031 of file fmsrcimp.cxx.

References m_aPreviousLocBookmark, m_arrUsedFields, and m_iterPreviousLocField.

Referenced by RebuildUsedFields(), SearchNextImpl(), StartOver(), and StartOverSpecial().

bool FmSearchEngine::MoveCursor ( )
private

Definition at line 194 of file fmsrcimp.cxx.

References Exception, LINK, and TOOLS_WARN_EXCEPTION.

bool FmSearchEngine::MoveField ( sal_Int32 &  nPos,
FieldCollection::iterator &  iter,
const FieldCollection::iterator &  iterBegin,
const FieldCollection::iterator &  iterEnd 
)
private

Definition at line 232 of file fmsrcimp.cxx.

Referenced by SearchNextImpl().

void FmSearchEngine::OnSearchTerminated ( )
private
void FmSearchEngine::PropagateProgress ( bool  _bDontPropagateOverflow)
private
void FmSearchEngine::RebuildUsedFields ( sal_Int32  nFieldIndex,
bool  bForce = false 
)

rebuilds m_arrUsedFields (nFieldIndex==-1 means all fields, otherwise it specifies the field index) if bForce is not set, nothing will happen in case of nFieldIndex == m_nCurrentFieldIndex (calls InvalidatePreviousLoc)

Definition at line 1038 of file fmsrcimp.cxx.

References BuildAndInsertFieldInfo(), DBG_ASSERT, i, IFACECAST, InvalidatePreviousLoc(), m_arrFieldMapping, m_arrUsedFields, m_nCurrentFieldIndex, and m_xSearchCursor.

Referenced by SetFormatterUsing(), and SwitchToContext().

void FmSearchEngine::SearchNext ( const OUString &  strExpression)

search for the next appearance (for nDirection values check DIRECTION_*-defines)

Definition at line 976 of file fmsrcimp.cxx.

References ImplStartNextSearch(), m_eSearchForType, m_strSearchExpression, and String.

Referenced by StartOver().

void FmSearchEngine::SearchNextImpl ( )
private
void FmSearchEngine::SearchNextSpecial ( bool  _bSearchForNull)

analogous, search for "NULL" (_bSearchForNull==sal_True) or "not NULL"

Definition at line 984 of file fmsrcimp.cxx.

References ImplStartNextSearch(), m_eSearchForType, NotNull, and Null.

Referenced by StartOverSpecial().

FmSearchEngine::SearchResult FmSearchEngine::SearchRegularApprox ( const OUString &  strExpression,
sal_Int32 &  nFieldPos,
FieldCollection::iterator &  iterFieldLoop,
const FieldCollection::iterator &  iterBegin,
const FieldCollection::iterator &  iterEnd 
)
private
FmSearchEngine::SearchResult FmSearchEngine::SearchSpecial ( bool  _bSearchForNull,
sal_Int32 &  nFieldPos,
FieldCollection::iterator &  iterFieldLoop,
const FieldCollection::iterator &  iterBegin,
const FieldCollection::iterator &  iterEnd 
)
private

Definition at line 301 of file fmsrcimp.cxx.

References Any, DBG_UNHANDLED_EXCEPTION, EQUAL_BOOKMARKS, Exception, and Application::Reschedule().

Referenced by SearchNextImpl().

FmSearchEngine::SearchResult FmSearchEngine::SearchWildcard ( const OUString &  strExpression,
sal_Int32 &  nFieldPos,
FieldCollection::iterator &  iterFieldLoop,
const FieldCollection::iterator &  iterBegin,
const FieldCollection::iterator &  iterEnd 
)
private
void FmSearchEngine::SetCaseSensitive ( bool  bSet)

Definition at line 593 of file fmsrcimp.cxx.

References m_nTransliterationFlags.

void FmSearchEngine::SetDirection ( bool  bForward)
inline

Definition at line 227 of file fmsrcimp.hxx.

void FmSearchEngine::SetFormatterUsing ( bool  bSet)
void FmSearchEngine::SetIgnoreWidthCJK ( bool  bSet)

Definition at line 578 of file fmsrcimp.cxx.

References m_nTransliterationFlags.

void FmSearchEngine::SetLevenshtein ( bool  bSet)
inline

Definition at line 236 of file fmsrcimp.hxx.

void FmSearchEngine::SetLevLonger ( sal_uInt16  nHowMuch)
inline

Definition at line 251 of file fmsrcimp.hxx.

void FmSearchEngine::SetLevOther ( sal_uInt16  nHowMuch)
inline

Definition at line 247 of file fmsrcimp.hxx.

void FmSearchEngine::SetLevRelaxed ( bool  bSet)
inline

Definition at line 245 of file fmsrcimp.hxx.

void FmSearchEngine::SetLevShorter ( sal_uInt16  nHowMuch)
inline

Definition at line 249 of file fmsrcimp.hxx.

void FmSearchEngine::SetPosition ( sal_uInt16  nValue)
inline

Definition at line 259 of file fmsrcimp.hxx.

void FmSearchEngine::SetProgressHandler ( Link< const FmSearchProgress *, void aHdl)
inline

the link will be called on every record and after the completion of the search, the parameter is a pointer to a FmSearchProgress structure the handler should be in any case thread-safe

Definition at line 282 of file fmsrcimp.hxx.

void FmSearchEngine::SetRegular ( bool  bSet)
inline

Definition at line 233 of file fmsrcimp.hxx.

void FmSearchEngine::SetTransliteration ( bool  bSet)
inline

Definition at line 242 of file fmsrcimp.hxx.

void FmSearchEngine::SetTransliterationFlags ( TransliterationFlags  _nFlags)
inline

Definition at line 255 of file fmsrcimp.hxx.

void FmSearchEngine::SetWildcard ( bool  bSet)
inline

Definition at line 230 of file fmsrcimp.hxx.

void FmSearchEngine::StartOver ( const OUString &  strExpression)

search for the next appearance, dependent on nDirection from the start or end

Definition at line 991 of file fmsrcimp.cxx.

References DBG_UNHANDLED_EXCEPTION, Exception, CursorWrapper::first(), InvalidatePreviousLoc(), CursorWrapper::last(), m_bForward, m_xSearchCursor, and SearchNext().

void FmSearchEngine::StartOverSpecial ( bool  _bSearchForNull)

analogous, search for "NULL" (_bSearchForNull==sal_True) or "not NULL"

Definition at line 1011 of file fmsrcimp.cxx.

References DBG_UNHANDLED_EXCEPTION, Exception, CursorWrapper::first(), InvalidatePreviousLoc(), CursorWrapper::last(), m_bForward, m_xSearchCursor, and SearchNextSpecial().

void FmSearchEngine::SwitchToContext ( const css::uno::Reference< css::sdbc::XResultSet > &  xCursor,
const OUString &  strVisibleFields,
const InterfaceArray arrFields,
sal_Int32  nFieldIndex 
)

only valid, if not an (asynchronous) search is running, the next search will then be executed on top of the new iterator with the new parameter

Definition at line 948 of file fmsrcimp.cxx.

References DBG_ASSERT, fillControlTexts(), Init(), m_bSearchingCurrently, m_xClonedIterator, m_xOriginalIterator, m_xSearchCursor, and RebuildUsedFields().

Friends And Related Function Documentation

friend class FmSearchThread
friend

Definition at line 153 of file fmsrcimp.hxx.

Member Data Documentation

::osl::Mutex FmSearchEngine::m_aCancelAsynchAccess
private

Definition at line 195 of file fmsrcimp.hxx.

Referenced by CancelRequested(), and CancelSearch().

CharClass const FmSearchEngine::m_aCharacterClassficator
private

Definition at line 163 of file fmsrcimp.hxx.

Referenced by SearchNextImpl().

std::vector<std::unique_ptr<svxform::ControlTextWrapper> > FmSearchEngine::m_aControlTexts
private

Definition at line 177 of file fmsrcimp.hxx.

Referenced by clearControlTexts(), and fillControlTexts().

css::uno::Any FmSearchEngine::m_aPreviousLocBookmark
private

Definition at line 183 of file fmsrcimp.hxx.

Referenced by InvalidatePreviousLoc(), OnSearchTerminated(), and SearchNextImpl().

Link<const FmSearchProgress*,void> FmSearchEngine::m_aProgressHandler
private

Definition at line 192 of file fmsrcimp.hxx.

Referenced by OnSearchTerminated(), and PropagateProgress().

std::deque<sal_Int32> FmSearchEngine::m_arrFieldMapping
private

Definition at line 159 of file fmsrcimp.hxx.

Referenced by Init(), and RebuildUsedFields().

FieldCollection FmSearchEngine::m_arrUsedFields
private
CollatorWrapper FmSearchEngine::m_aStringCompare
private

Definition at line 164 of file fmsrcimp.hxx.

Referenced by Init().

bool FmSearchEngine::m_bCancelAsynchRequest
private

Definition at line 194 of file fmsrcimp.hxx.

Referenced by CancelRequested(), CancelSearch(), and ImplStartNextSearch().

bool FmSearchEngine::m_bFormatter
private

Definition at line 199 of file fmsrcimp.hxx.

Referenced by SetFormatterUsing().

bool FmSearchEngine::m_bForward
private

Definition at line 200 of file fmsrcimp.hxx.

Referenced by PropagateProgress(), SearchNextImpl(), StartOver(), and StartOverSpecial().

bool FmSearchEngine::m_bLevenshtein
private

Definition at line 203 of file fmsrcimp.hxx.

Referenced by SearchNextImpl().

bool FmSearchEngine::m_bLevRelaxed
private

Definition at line 206 of file fmsrcimp.hxx.

bool FmSearchEngine::m_bRegular
private

Definition at line 202 of file fmsrcimp.hxx.

Referenced by SearchNextImpl().

bool FmSearchEngine::m_bSearchingCurrently
private

Definition at line 193 of file fmsrcimp.hxx.

Referenced by ImplStartNextSearch(), OnSearchTerminated(), and SwitchToContext().

bool FmSearchEngine::m_bTransliteration
private

Definition at line 204 of file fmsrcimp.hxx.

bool FmSearchEngine::m_bWildcard
private

Definition at line 201 of file fmsrcimp.hxx.

Referenced by SearchNextImpl().

SearchFor FmSearchEngine::m_eSearchForType
private

Definition at line 188 of file fmsrcimp.hxx.

Referenced by SearchNext(), SearchNextImpl(), and SearchNextSpecial().

FieldCollection::iterator FmSearchEngine::m_iterPreviousLocField
private

Definition at line 184 of file fmsrcimp.hxx.

Referenced by InvalidatePreviousLoc(), OnSearchTerminated(), and SearchNextImpl().

sal_Int32 FmSearchEngine::m_nCurrentFieldIndex
private

Definition at line 174 of file fmsrcimp.hxx.

Referenced by RebuildUsedFields(), and SetFormatterUsing().

sal_uInt16 FmSearchEngine::m_nLevLonger
private

Definition at line 209 of file fmsrcimp.hxx.

sal_uInt16 FmSearchEngine::m_nLevOther
private

Definition at line 207 of file fmsrcimp.hxx.

sal_uInt16 FmSearchEngine::m_nLevShorter
private

Definition at line 208 of file fmsrcimp.hxx.

sal_uInt16 FmSearchEngine::m_nPosition
private

Definition at line 211 of file fmsrcimp.hxx.

Referenced by SearchNextImpl().

TransliterationFlags FmSearchEngine::m_nTransliterationFlags
private
SearchResult FmSearchEngine::m_srResult
private

Definition at line 189 of file fmsrcimp.hxx.

Referenced by OnSearchTerminated(), and SearchNextImpl().

OUString FmSearchEngine::m_strSearchExpression
private

Definition at line 187 of file fmsrcimp.hxx.

Referenced by SearchNext(), and SearchNextImpl().

CursorWrapper FmSearchEngine::m_xClonedIterator
private

Definition at line 180 of file fmsrcimp.hxx.

Referenced by SetFormatterUsing(), and SwitchToContext().

CursorWrapper FmSearchEngine::m_xOriginalIterator
private

Definition at line 179 of file fmsrcimp.hxx.

Referenced by SetFormatterUsing(), and SwitchToContext().

CursorWrapper FmSearchEngine::m_xSearchCursor
private

The documentation for this class was generated from the following files: