summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-02-20 18:34:44 +0100
committerEike Rathke <erack@redhat.com>2016-02-20 20:04:44 +0100
commit1b6b4ffbd9608eff245deb87da5f193f5d955e51 (patch)
tree94fb1f26f11bdd396655c7f5df323e29cca3a7b0
parent286adeb032df8ab30930b6f76f75b342a3fa314b (diff)
implement wildcards precedence at ScDocOptions, tdf#72196
Change-Id: I3a8f880479ee2d0621e10b3c9d405948cadabeaf
-rw-r--r--sc/inc/docoptio.hxx41
-rw-r--r--sc/source/core/tool/docoptio.cxx2
2 files changed, 36 insertions, 7 deletions
diff --git a/sc/inc/docoptio.hxx b/sc/inc/docoptio.hxx
index cd7effa2fab1..9335394c9b58 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 8b9bcaa57df5..77c6389fbe91 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;
}