diff options
author | Eike Rathke <erack@redhat.com> | 2016-02-25 18:02:25 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-02-26 01:41:49 +0100 |
commit | 3a0abd3019ec3ca29b8f1378cdb32ebf741e6306 (patch) | |
tree | 7c64c5886b9f28e30732176fee6205a2084cf334 | |
parent | 26be25f27d2f67bdee0d2a4ad95d9d252e470780 (diff) |
add SvxSearchItem::GetWildcard() SetWildcard()
Change-Id: I0aeb7fbcedad381a385ffe6649ac51e8c961ca11
-rw-r--r-- | include/svl/srchitem.hxx | 17 | ||||
-rw-r--r-- | svl/source/items/srchitem.cxx | 24 |
2 files changed, 37 insertions, 4 deletions
diff --git a/include/svl/srchitem.hxx b/include/svl/srchitem.hxx index dd7afac19f2b..6c997d5ade6c 100644 --- a/include/svl/srchitem.hxx +++ b/include/svl/srchitem.hxx @@ -135,6 +135,9 @@ public: inline bool GetRegExp() const; void SetRegExp( bool bVal ); + inline bool GetWildcard() const; + void SetWildcard( bool bVal ); + bool GetPattern() const { return m_bPattern; } void SetPattern(bool bNewPattern) { m_bPattern = bNewPattern; } @@ -239,7 +242,17 @@ bool SvxSearchItem::GetRegExp() const // adapted to use only new types. assert( (m_aSearchOpt.algorithmType == css::util::SearchAlgorithms_REGEXP) == (m_aSearchOpt.AlgorithmType2 == css::util::SearchAlgorithms2::REGEXP)); - return m_aSearchOpt.algorithmType == css::util::SearchAlgorithms_REGEXP ; + return m_aSearchOpt.AlgorithmType2 == css::util::SearchAlgorithms2::REGEXP ; +} + +bool SvxSearchItem::GetWildcard() const +{ + // Ensure old and new algorithm types are in sync, in this case old is not + // REGEXP or APPROXIMATE. + assert( (m_aSearchOpt.AlgorithmType2 == css::util::SearchAlgorithms2::WILDCARD) ? + (m_aSearchOpt.algorithmType != css::util::SearchAlgorithms_REGEXP && + m_aSearchOpt.algorithmType != css::util::SearchAlgorithms_APPROXIMATE) : true ); + return m_aSearchOpt.AlgorithmType2 == css::util::SearchAlgorithms2::WILDCARD ; } bool SvxSearchItem::IsLEVRelaxed() const @@ -283,7 +296,7 @@ bool SvxSearchItem::IsLevenshtein() const // adapted to use only new types. assert( (m_aSearchOpt.algorithmType == css::util::SearchAlgorithms_APPROXIMATE) == (m_aSearchOpt.AlgorithmType2 == css::util::SearchAlgorithms2::APPROXIMATE)); - return m_aSearchOpt.algorithmType == css::util::SearchAlgorithms_APPROXIMATE; + return m_aSearchOpt.AlgorithmType2 == css::util::SearchAlgorithms2::APPROXIMATE; } const css::util::SearchOptions2 & SvxSearchItem::GetSearchOptions() const diff --git a/svl/source/items/srchitem.cxx b/svl/source/items/srchitem.cxx index 99d1a565fd0a..881c464ee1f4 100644 --- a/svl/source/items/srchitem.cxx +++ b/svl/source/items/srchitem.cxx @@ -137,6 +137,11 @@ SvxSearchItem::SvxSearchItem( const sal_uInt16 nId ) : m_bAsianOptions = aOpt.IsUseAsianOptions(); m_bNotes = aOpt.IsNotes(); + if (aOpt.IsUseWildcard()) + { + m_aSearchOpt.AlgorithmType2 = SearchAlgorithms2::WILDCARD; + m_aSearchOpt.algorithmType = SearchAlgorithms_ABSOLUTE; // something valid + } if (aOpt.IsUseRegularExpression()) { m_aSearchOpt.AlgorithmType2 = SearchAlgorithms2::REGEXP; @@ -348,7 +353,22 @@ void SvxSearchItem::SetRegExp( bool bVal ) m_aSearchOpt.AlgorithmType2 = SearchAlgorithms2::REGEXP; m_aSearchOpt.algorithmType = SearchAlgorithms_REGEXP; } - else if ( SearchAlgorithms_REGEXP == m_aSearchOpt.algorithmType ) + else if ( SearchAlgorithms2::REGEXP == m_aSearchOpt.AlgorithmType2 ) + { + m_aSearchOpt.AlgorithmType2 = SearchAlgorithms2::ABSOLUTE; + m_aSearchOpt.algorithmType = SearchAlgorithms_ABSOLUTE; + } +} + + +void SvxSearchItem::SetWildcard( bool bVal ) +{ + if ( bVal ) + { + m_aSearchOpt.AlgorithmType2 = SearchAlgorithms2::WILDCARD; + m_aSearchOpt.algorithmType = SearchAlgorithms_ABSOLUTE; // something valid + } + else if ( SearchAlgorithms2::REGEXP == m_aSearchOpt.AlgorithmType2 ) { m_aSearchOpt.AlgorithmType2 = SearchAlgorithms2::ABSOLUTE; m_aSearchOpt.algorithmType = SearchAlgorithms_ABSOLUTE; @@ -372,7 +392,7 @@ void SvxSearchItem::SetLevenshtein( bool bVal ) m_aSearchOpt.AlgorithmType2 = SearchAlgorithms2::APPROXIMATE; m_aSearchOpt.algorithmType = SearchAlgorithms_APPROXIMATE; } - else if ( SearchAlgorithms_APPROXIMATE == m_aSearchOpt.algorithmType ) + else if ( SearchAlgorithms2::APPROXIMATE == m_aSearchOpt.AlgorithmType2 ) { m_aSearchOpt.AlgorithmType2 = SearchAlgorithms2::ABSOLUTE; m_aSearchOpt.algorithmType = SearchAlgorithms_ABSOLUTE; |