summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-11-04 02:22:48 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-11-04 16:33:15 +0100
commitbca1f6b9cae0aacf4b49b237a913510c91ca10d1 (patch)
tree47038157815a533ba3559079a02e2982d3379e24
parent13deb4cd8fca3f222003e0ace9875b80fda433d2 (diff)
implement text conditional formats
Change-Id: I29e837c3495264b04c25a8d6977e3f8dd1efd73b
-rw-r--r--sc/inc/conditio.hxx4
-rw-r--r--sc/source/core/data/conditio.cxx68
2 files changed, 69 insertions, 3 deletions
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index 935f33e96cb0..2f2eb491cc56 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -78,6 +78,10 @@ enum ScConditionMode
SC_COND_BELOW_AVERAGE,
SC_COND_ERROR,
SC_COND_NOERROR,
+ SC_COND_BEGINS_WITH,
+ SC_COND_ENDS_WITH,
+ SC_COND_CONTAINS_TEXT,
+ SC_COND_NOT_CONTAINS_TEXT,
SC_COND_NONE
};
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 4e3ffcb7f73d..f164cc48aa40 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -1000,9 +1000,18 @@ bool ScConditionEntry::IsValid( double nArg, const ScAddress& rPos ) const
if ( bIsStr1 )
{
- // wenn auf String getestet wird, bei Zahlen immer sal_False, ausser bei "ungleich"
-
- return ( eOp == SC_COND_NOTEQUAL );
+ switch( eOp )
+ {
+ case SC_COND_BEGINS_WITH:
+ case SC_COND_ENDS_WITH:
+ case SC_COND_CONTAINS_TEXT:
+ case SC_COND_NOT_CONTAINS_TEXT:
+ break;
+ case SC_COND_NOTEQUAL:
+ return true;
+ default:
+ return false;
+ }
}
if ( eOp == SC_COND_BETWEEN || eOp == SC_COND_NOTBETWEEN )
@@ -1088,6 +1097,47 @@ bool ScConditionEntry::IsValid( double nArg, const ScAddress& rPos ) const
if( eOp == SC_COND_NOERROR )
bValid = !bValid;
break;
+ case SC_COND_BEGINS_WITH:
+ if(!aStrVal1.Len())
+ {
+ rtl::OUString aStr = rtl::OUString::valueOf(nVal1);
+ rtl::OUString aStr2 = rtl::OUString::valueOf(nArg);
+ bValid = aStr2.indexOf(aStr) == 0;
+ }
+ else
+ {
+ rtl::OUString aStr2 = rtl::OUString::valueOf(nArg);
+ bValid = aStr2.indexOf(aStrVal1) == 0;
+ }
+ case SC_COND_ENDS_WITH:
+ if(!aStrVal1.Len())
+ {
+ rtl::OUString aStr = rtl::OUString::valueOf(nVal1);
+ rtl::OUString aStr2 = rtl::OUString::valueOf(nArg);
+ bValid = aStr2.endsWith(aStr) == 0;
+ }
+ else
+ {
+ rtl::OUString aStr2 = rtl::OUString::valueOf(nArg);
+ bValid = aStr2.endsWith(aStrVal1) == 0;
+ }
+ case SC_COND_CONTAINS_TEXT:
+ case SC_COND_NOT_CONTAINS_TEXT:
+ if(!aStrVal1.Len())
+ {
+ rtl::OUString aStr = rtl::OUString::valueOf(nVal1);
+ rtl::OUString aStr2 = rtl::OUString::valueOf(nArg);
+ bValid = aStr2.indexOf(aStr) != -1;
+ }
+ else
+ {
+ rtl::OUString aStr2 = rtl::OUString::valueOf(nArg);
+ bValid = aStr2.indexOf(aStrVal1) != -1;
+ }
+
+ if( eOp == SC_COND_NOT_CONTAINS_TEXT )
+ bValid = !bValid;
+ break;
default:
OSL_FAIL("unbekannte Operation bei ScConditionEntry");
break;
@@ -1156,6 +1206,18 @@ bool ScConditionEntry::IsValidStr( const rtl::OUString& rArg, const ScAddress& r
if(eOp == SC_COND_NOERROR)
bValid = !bValid;
break;
+ case SC_COND_BEGINS_WITH:
+ bValid = rArg.indexOf(aUpVal1) == 0;
+ break;
+ case SC_COND_ENDS_WITH:
+ bValid = rArg.endsWith(aUpVal1);
+ break;
+ case SC_COND_CONTAINS_TEXT:
+ case SC_COND_NOT_CONTAINS_TEXT:
+ bValid = rArg.indexOf(aUpVal1) != -1;
+ if(eOp == SC_COND_NOT_CONTAINS_TEXT)
+ bValid = !bValid;
+ break;
default:
{
sal_Int32 nCompare = ScGlobal::GetCollator()->compareString(