[Libreoffice-commits] core.git: 2 commits - include/unotools sc/inc sc/source
Eike Rathke
erack at redhat.com
Sat Feb 20 19:05:41 UTC 2016
include/unotools/textsearch.hxx | 15 ++++++++++++---
sc/inc/docoptio.hxx | 36 +++++++++++++++++++++++++++++-------
sc/source/core/tool/docoptio.cxx | 2 ++
3 files changed, 43 insertions(+), 10 deletions(-)
New commits:
commit 49d289475167ab21682bc8dbf26a7f67d5902ded
Author: Eike Rathke <erack at redhat.com>
Date: Sat Feb 20 18:41:11 2016 +0100
let ConvertToSearchType() also adapt the regex bool, tdf#72196
Change-Id: I6d9c438873f3f26418e6b27884207106ccaea148
diff --git a/include/unotools/textsearch.hxx b/include/unotools/textsearch.hxx
index 67c440a..07d2527 100644
--- a/include/unotools/textsearch.hxx
+++ b/include/unotools/textsearch.hxx
@@ -50,11 +50,20 @@ public:
enum SearchType{ SRCH_NORMAL, SRCH_REGEXP, SRCH_LEVDIST, SRCH_WILDCARD };
/** Convert configuration and document boolean settings to SearchType.
- If bWildcard is true it takes precedence over bRegExp.
+ If bWildcard is true it takes precedence over rbRegExp.
+ @param rbRegExp
+ If true and bWildcard is also true, rbRegExp is set to false to
+ adapt the caller's settings.
*/
- static SearchType ConvertToSearchType( bool bWildcard, bool bRegExp )
+ static SearchType ConvertToSearchType( bool bWildcard, bool & rbRegExp )
{
- return bWildcard ? SRCH_WILDCARD : (bRegExp ? SRCH_REGEXP : SRCH_NORMAL);
+ if (bWildcard)
+ {
+ if (rbRegExp)
+ rbRegExp = false;
+ return SRCH_WILDCARD;
+ }
+ return rbRegExp ? SRCH_REGEXP : SRCH_NORMAL;
}
/** Convert SearchType to configuration and document boolean settings.
diff --git a/sc/inc/docoptio.hxx b/sc/inc/docoptio.hxx
index 9335394..a5f3bbf 100644
--- a/sc/inc/docoptio.hxx
+++ b/sc/inc/docoptio.hxx
@@ -98,12 +98,7 @@ public:
utl::SearchParam::SearchType GetFormulaSearchType() const
{
if (eFormulaSearchType == eSearchTypeUnknown)
- {
eFormulaSearchType = utl::SearchParam::ConvertToSearchType( bFormulaWildcardsEnabled, bFormulaRegexEnabled);
- if (bFormulaWildcardsEnabled && bFormulaRegexEnabled)
- // Mutually exclusive, straighten out.
- bFormulaRegexEnabled = false;
- }
return eFormulaSearchType;
}
commit 1b6b4ffbd9608eff245deb87da5f193f5d955e51
Author: Eike Rathke <erack at redhat.com>
Date: Sat Feb 20 18:34:44 2016 +0100
implement wildcards precedence at ScDocOptions, tdf#72196
Change-Id: I3a8f880479ee2d0621e10b3c9d405948cadabeaf
diff --git a/sc/inc/docoptio.hxx b/sc/inc/docoptio.hxx
index cd7effa..9335394 100644
--- a/sc/inc/docoptio.hxx
+++ b/sc/inc/docoptio.hxx
@@ -21,6 +21,7 @@
#define INCLUDED_SC_INC_DOCOPTIO_HXX
#include <unotools/configitem.hxx>
+#include <unotools/textsearch.hxx>
#include <svl/poolitem.hxx>
#include <svl/itemprop.hxx>
#include "scdllapi.h"
@@ -39,15 +40,19 @@ class SC_DLLPUBLIC ScDocOptions
sal_uInt16 nYear;
sal_uInt16 nYear2000; ///< earlier 19YY is assumed, 20YY otherwise (if only YY of year is given)
sal_uInt16 nTabDistance; ///< distance of standard tabs
+ mutable utl::SearchParam::SearchType eFormulaSearchType; ///< wildcards or regular expressions or normal search
bool bIsIgnoreCase; ///< ignore case for comparisons?
bool bIsIter; ///< iterations for circular refs
bool bCalcAsShown; ///< calculate as shown (wrt precision)
bool bMatchWholeCell; ///< search criteria must match the whole cell
bool bDoAutoSpell; ///< auto-spelling
bool bLookUpColRowNames; ///< determine column-/row titles automagically
- bool bFormulaRegexEnabled; ///< regular expressions in formulas enabled
- bool bFormulaWildcardsEnabled;///< wildcards in formulas enabled
+ mutable bool bFormulaRegexEnabled; ///< regular expressions in formulas enabled, only when reading settings
+ mutable bool bFormulaWildcardsEnabled;///< wildcards in formulas enabled, only when reading settings
bool bWriteCalcConfig; ///< (subset of) Calc config will be written to user's profile
+
+ const utl::SearchParam::SearchType eSearchTypeUnknown = static_cast<utl::SearchParam::SearchType>(-1);
+
public:
ScDocOptions();
ScDocOptions( const ScDocOptions& rCpy );
@@ -90,11 +95,31 @@ public:
void SetYear2000( sal_uInt16 nVal ) { nYear2000 = nVal; }
sal_uInt16 GetYear2000() const { return nYear2000; }
- void SetFormulaRegexEnabled( bool bVal ) { bFormulaRegexEnabled = bVal; }
- bool IsFormulaRegexEnabled() const { return bFormulaRegexEnabled; }
-
- void SetFormulaWildcardsEnabled( bool bVal ) { bFormulaWildcardsEnabled = bVal; }
- bool IsFormulaWildcardsEnabled() const { return bFormulaWildcardsEnabled; }
+ utl::SearchParam::SearchType GetFormulaSearchType() const
+ {
+ if (eFormulaSearchType == eSearchTypeUnknown)
+ {
+ eFormulaSearchType = utl::SearchParam::ConvertToSearchType( bFormulaWildcardsEnabled, bFormulaRegexEnabled);
+ if (bFormulaWildcardsEnabled && bFormulaRegexEnabled)
+ // Mutually exclusive, straighten out.
+ bFormulaRegexEnabled = false;
+ }
+ return eFormulaSearchType;
+ }
+
+ void SetFormulaRegexEnabled( bool bVal )
+ {
+ bFormulaRegexEnabled = bVal;
+ eFormulaSearchType = eSearchTypeUnknown;
+ }
+ bool IsFormulaRegexEnabled() const { return GetFormulaSearchType() == utl::SearchParam::SRCH_REGEXP; }
+
+ void SetFormulaWildcardsEnabled( bool bVal )
+ {
+ bFormulaWildcardsEnabled = bVal;
+ eFormulaSearchType = eSearchTypeUnknown;
+ }
+ bool IsFormulaWildcardsEnabled() const { return GetFormulaSearchType() == utl::SearchParam::SRCH_WILDCARD; }
void SetWriteCalcConfig( bool bVal ) { bWriteCalcConfig = bVal; }
bool IsWriteCalcConfig() const { return bWriteCalcConfig; }
@@ -118,6 +143,7 @@ inline const ScDocOptions& ScDocOptions::operator=( const ScDocOptions& rCpy )
bLookUpColRowNames = rCpy.bLookUpColRowNames;
bFormulaRegexEnabled= rCpy.bFormulaRegexEnabled;
bFormulaWildcardsEnabled = rCpy.bFormulaWildcardsEnabled;
+ eFormulaSearchType = rCpy.eFormulaSearchType;
bWriteCalcConfig = rCpy.bWriteCalcConfig;
return *this;
@@ -142,6 +168,7 @@ inline bool ScDocOptions::operator==( const ScDocOptions& rOpt ) const
&& rOpt.bLookUpColRowNames == bLookUpColRowNames
&& rOpt.bFormulaRegexEnabled == bFormulaRegexEnabled
&& rOpt.bFormulaWildcardsEnabled == bFormulaWildcardsEnabled
+ && rOpt.eFormulaSearchType == eFormulaSearchType
&& rOpt.bWriteCalcConfig == bWriteCalcConfig
);
}
diff --git a/sc/source/core/tool/docoptio.cxx b/sc/source/core/tool/docoptio.cxx
index 8b9bcaa..77c6389 100644
--- a/sc/source/core/tool/docoptio.cxx
+++ b/sc/source/core/tool/docoptio.cxx
@@ -64,6 +64,7 @@ ScDocOptions::ScDocOptions( const ScDocOptions& rCpy )
nYear( rCpy.nYear ),
nYear2000( rCpy.nYear2000 ),
nTabDistance( rCpy.nTabDistance ),
+ eFormulaSearchType( rCpy.eFormulaSearchType ),
bIsIgnoreCase( rCpy.bIsIgnoreCase ),
bIsIter( rCpy.bIsIter ),
bCalcAsShown( rCpy.bCalcAsShown ),
@@ -98,6 +99,7 @@ void ScDocOptions::ResetDocOptions()
bLookUpColRowNames = true;
bFormulaRegexEnabled= true;
bFormulaWildcardsEnabled= false;
+ eFormulaSearchType = eSearchTypeUnknown;
bWriteCalcConfig = true;
}
More information about the Libreoffice-commits
mailing list