namespace com::sun::star::awt { class XCheckBox; } namespace com::sun::star::awt { class XListBox; } namespace com::sun::star::awt { class XTextComponent; } namespace com::sun::star::sdb { class XColumn; }
enumclass TransliterationFlags;
/** *structFmSearchProgress-theownerofSearchEnginereceivesthisstructureforstatusupdates *(attheendofthesearch)
*/ struct FmSearchProgress
{ enumclass State { Progress, ProgressCounting, Canceled, Successful, NothingFound, Error }; // (move to new record; progress during counting of records; cancelled; record found; nothing found; // any non-processable error)
State aSearchState;
// current record - always valid (e.g. of interest for continuing search in case of cancellation)
sal_uInt32 nCurrentRecord; // Overflow - only valid in case of STATE_PROGRESS bool bOverflow;
// the position of the search cursor - valid in case of STATE_SUCCESSFUL, STATE_CANCELED and STATE_NOTHING_FOUND
css::uno::Any aBookmark; // the field, in which the text was found - valid in case of STATE_SUCCESSFUL
sal_Int32 nFieldIndex;
};
/** *classFmRecordCountListener-utilityclassforFmSearchEngine,listensatacertaincursorandprovides *thedifferencesinRecordCount
*/ // workaround for incremental linking bugs in MSVC2019 class SAL_DLLPUBLIC_TEMPLATE FmRecordCountListener_Base : public cppu::WeakImplHelper< css::beans::XPropertyChangeListener > {}; class SAL_WARN_UNUSED FmRecordCountListener final : public FmRecordCountListener_Base
{ // attribute
Link<sal_Int32,void> m_lnkWhoWantsToKnow;
css::uno::Reference< css::beans::XPropertySet > m_xListening;
// methods public:
FmRecordCountListener(const css::uno::Reference< css::sdbc::XResultSet >& dbcCursor); // the set has to support the sdb::ResultSet service virtual ~FmRecordCountListener() override;
/** *classFmSearchEngine-ImplclassforFmSearchDialog
*/ namespace svxform { // We have three possible control types we may search in, determined by the supported interfaces : css::awt::XTextComponent, // css::awt::XListBox, css::awt::XCheckBox. // While searching we don't want to do this distinction for every control in every round. So we need some helpers. class SAL_WARN_UNUSED ControlTextWrapper
{ // attributes
css::uno::Reference< css::uno::XInterface > m_xControl; // attribute access public: const css::uno::Reference< css::uno::XInterface >& getControl() const{ return m_xControl; } public:
ControlTextWrapper(const css::uno::Reference< css::uno::XInterface >& _xControl) { m_xControl = _xControl; } virtual ~ControlTextWrapper() { }
virtual OUString getCurrentText() const = 0;
};
class SAL_WARN_UNUSED SimpleTextWrapper final : public ControlTextWrapper
{
css::uno::Reference< css::awt::XTextComponent > m_xText; public:
SimpleTextWrapper(const css::uno::Reference< css::awt::XTextComponent >& _xText); virtual OUString getCurrentText() const override;
};
class SAL_WARN_UNUSED ListBoxWrapper final : public ControlTextWrapper
{
css::uno::Reference< css::awt::XListBox > m_xBox; public:
ListBoxWrapper(const css::uno::Reference< css::awt::XListBox >& _xBox); virtual OUString getCurrentText() const override;
};
class SAL_WARN_UNUSED CheckBoxWrapper final : public ControlTextWrapper
{
css::uno::Reference< css::awt::XCheckBox > m_xBox; public:
CheckBoxWrapper(const css::uno::Reference< css::awt::XCheckBox >& _xBox); virtual OUString getCurrentText() const override;
};
}
CursorWrapper m_xSearchCursor;
std::deque<sal_Int32> m_arrFieldMapping; // Since the iterator could have more columns, as managed here (in this field listbox), // a mapping of this css::form keys on the indices of the respective columns is kept in the iterator
// the collection of all interesting fields (or their css::data::XDatabaseVariant interfaces and FormatKeys) struct FieldInfo
{
css::uno::Reference< css::sdb::XColumn > xContents;
};
typedef std::vector<FieldInfo> FieldCollection;
FieldCollection m_arrUsedFields;
sal_Int32 m_nCurrentFieldIndex; // the last parameter of RebuildUsedFields, it allows checks in FormatField
// Data for the decision in which field a "Found" is accepted
css::uno::Any m_aPreviousLocBookmark; // position of the last finding
FieldCollection::iterator m_iterPreviousLocField; // field of the last finding
// Communication with the thread that does the actual searching
OUString m_strSearchExpression; // forward direction
SearchFor m_eSearchForType; // ditto
SearchResult m_srResult; // backward direction
// The link we broadcast the progress and the result to
Link<const FmSearchProgress*,void> m_aProgressHandler;
std::atomic<bool> m_bCancelAsynchRequest; // should be cancelled?
// parameters for the search bool m_bSearchingCurrently : 1; // is an (asynchronous) search running? bool m_bFormatter : 1; // use field formatting bool m_bForward : 1; // direction bool m_bWildcard : 1; // wildcard search bool m_bRegular : 1; // regular expression bool m_bLevenshtein : 1; // Levenshtein search bool m_bTransliteration : 1; // Levenshtein search
sal_uInt16 m_nPosition; // if not regular or levenshtein, then one of the MATCHING_... values
TransliterationFlags m_nTransliterationFlags;
// member access private:
SVX_DLLPRIVATE bool CancelRequested(); // provides a through m_aCancelAsynchAccess backed interpretation of m_bCancelAsynchRequest
void SetPosition(sal_uInt16 nValue) { m_nPosition = nValue; }
sal_uInt16 GetPosition() const { return m_nPosition; } // position will be ignored in case of m_bWildCard==sal_True
public: /** two constructs, both analogical to FmSearchDialog, therefore look this up for explanations... xCursorhastoimplementcss::data::DatabaseCursorserviceeachtime. IfeMode==SM_USETHREAD,aProgressHandlershouldbeset,becauseinthiscasetheresultforwardingwillbedone bythishandler. IfeMode!=SM_USETHREAD,SearchNextandStarOverwon'treturn,untilthesearchhasfinished(independentlyofits success),onlythentheresultcanberequested.IfadditionallytheProgressHandlerisset,itwillbecalledfor everyrecordaswellasattheendofthesearch.
*/
FmSearchEngine( const css::uno::Reference< css::uno::XComponentContext >& _rxContext, const css::uno::Reference< css::sdbc::XResultSet >& xCursor,
std::u16string_view strVisibleFields, const InterfaceArray& arrFields);
/** the link will be called on every record and after the completion of the search, the parameter is a pointer to aFmSearchProgressstructure thehandlershouldbeinanycasethread-safe
*/ void SetProgressHandler(Link<const FmSearchProgress*,void> aHdl) { m_aProgressHandler = aHdl; }
/// search for the next appearance (for nDirection values check DIRECTION_*-defines) void SearchNext(const OUString& strExpression); /// analogous, search for "NULL" (_bSearchForNull==sal_True) or "not NULL" void SearchNextSpecial(bool _bSearchForNull); /// search for the next appearance, dependent on nDirection from the start or end void StartOver(const OUString& strExpression); /// analogous, search for "NULL" (_bSearchForNull==sal_True) or "not NULL" void StartOverSpecial(bool _bSearchForNull); /// invalidate previous search reference void InvalidatePreviousLoc();
/** rebuilds m_arrUsedFields (nFieldIndex==-1 means all fields, otherwise it specifies the field index) ifbForceisnotset,nothingwillhappenincaseofnFieldIndex==m_nCurrentFieldIndex (callsInvalidatePreviousLoc)
*/ void RebuildUsedFields(sal_Int32 nFieldIndex, bool bForce = false);
OUString FormatField(sal_Int32 nWhich);
/// returns directly; once it was really aborted, ProgressHandler is called with STATE_CANCELED void CancelSearch();
/** only valid, if not an (asynchronous) search is running, the next search will then be executed ontopofthenewiteratorwiththenewparameter
*/ void SwitchToContext(const css::uno::Reference< css::sdbc::XResultSet >& xCursor, std::u16string_view strVisibleFields, const InterfaceArray& arrFields,
sal_Int32 nFieldIndex);
// three methods implementing a complete search loop (null/not null, wildcard, SearchText) // (they all have some code in common, but with this solution we have to do a distinction only once per search (before // starting the loop), not in every loop step
SVX_DLLPRIVATE SearchResult SearchSpecial(bool _bSearchForNull, sal_Int32& nFieldPos, FieldCollection::iterator& iterFieldLoop, const FieldCollection::iterator& iterBegin, const FieldCollection::iterator& iterEnd);
SVX_DLLPRIVATE SearchResult SearchWildcard(std::u16string_view 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); // call the ProgressHandler with STATE_PROGRESS and the current position of the search iterator
// helpers, that are needed several times
SVX_DLLPRIVATE bool MoveCursor(); // moves m_xSearchIterator with respect to direction/overflow cursor
SVX_DLLPRIVATE bool MoveField(sal_Int32& nPos, FieldCollection::iterator& iter, const FieldCollection::iterator& iterBegin, const FieldCollection::iterator& iterEnd); // moves the iterator with respect to the direction/overflow iterator/overflow cursor
SVX_DLLPRIVATE void BuildAndInsertFieldInfo(const css::uno::Reference< css::container::XIndexAccess >& xAllFields, sal_Int32 nField);
void OnSearchTerminated(); // is used by SearchThread, after the return from this handler the thread removes itself
DECL_DLLPRIVATE_LINK(OnNewRecordCount, sal_Int32, void);
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.