summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-05-19 08:12:04 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-05-19 08:13:37 +0200
commitdd0f844728a53a337233a3c687b792e725803da5 (patch)
treea40f5621a67311363784b51f27fb8d96c1cf91fe
parentfefad3715a9ca8411228d2bf4a56c210e5b598ef (diff)
add COLOR function
This function makes property mapping in charts more user friendly. Change-Id: I01cfb31edd749ee474d5078042fa5c4b4a270f86
-rw-r--r--formula/source/core/resource/core_resource.src6
-rw-r--r--include/formula/compiler.hrc3
-rw-r--r--include/formula/opcode.hxx1
-rw-r--r--sc/inc/helpids.h1
-rw-r--r--sc/qa/unit/ucalc.cxx1
-rw-r--r--sc/source/core/inc/interpre.hxx1
-rw-r--r--sc/source/core/tool/interpr4.cxx1
-rw-r--r--sc/source/core/tool/interpr7.cxx44
-rw-r--r--sc/source/ui/src/scfuncs.src47
9 files changed, 104 insertions, 1 deletions
diff --git a/formula/source/core/resource/core_resource.src b/formula/source/core/resource/core_resource.src
index 1aecc1ae46a2..259eda09ac62 100644
--- a/formula/source/core/resource/core_resource.src
+++ b/formula/source/core/resource/core_resource.src
@@ -423,6 +423,7 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_ODFF
/* END defined ERROR.TYPE() values. */
String SC_OPCODE_FILTERXML { Text = "COM.MICROSOFT.FILTERXML";};
String SC_OPCODE_WEBSERVICE { Text = "COM.MICROSOFT.WEBSERVICE"; };
+ String SC_OPCODE_COLOR { Text = "COLOR"; };
String SC_OPCODE_ERF_MS { Text = "COM.MICROSOFT.ERF.PRECISE" ; };
String SC_OPCODE_ERFC_MS { Text = "COM.MICROSOFT.ERFC.PRECISE" ; };
};
@@ -1237,6 +1238,7 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH
/* END defined ERROR.TYPE() values. */
String SC_OPCODE_FILTERXML { Text = "FILTERXML";};
String SC_OPCODE_WEBSERVICE { Text = "WEBSERVICE"; };
+ String SC_OPCODE_COLOR { Text = "COLOR"; };
String SC_OPCODE_ERF_MS { Text = "ERF.PRECISE" ; };
String SC_OPCODE_ERFC_MS { Text = "ERFC.PRECISE" ; };
};
@@ -2767,6 +2769,10 @@ Resource RID_STRLIST_FUNCTION_NAMES
{
Text [ en-US ] = "FILTERXML";
};
+ String SC_OPCODE_COLOR
+ {
+ Text [ en-US ] = "COLOR";
+ };
String SC_OPCODE_WEBSERVICE
{
Text [ en-US ] = "WEBSERVICE";
diff --git a/include/formula/compiler.hrc b/include/formula/compiler.hrc
index 2ce723011e5b..6d642ae2d190 100644
--- a/include/formula/compiler.hrc
+++ b/include/formula/compiler.hrc
@@ -468,8 +468,9 @@
#define SC_OPCODE_NETWORKDAYS_MS 468
#define SC_OPCODE_WORKDAY_MS 469
#define SC_OPCODE_AGGREGATE 470
+#define SC_OPCODE_COLOR 471
-#define SC_OPCODE_STOP_2_PAR 471 /* last function with two or more parameters' OpCode + 1 */
+#define SC_OPCODE_STOP_2_PAR 472 /* last function with two or more parameters' OpCode + 1 */
#define SC_OPCODE_STOP_FUNCTION SC_OPCODE_STOP_2_PAR /* last function's OpCode + 1 */
#define SC_OPCODE_LAST_OPCODE_ID (SC_OPCODE_STOP_FUNCTION - 1) /* last OpCode */
diff --git a/include/formula/opcode.hxx b/include/formula/opcode.hxx
index 0e9fb708adf7..199d598c5638 100644
--- a/include/formula/opcode.hxx
+++ b/include/formula/opcode.hxx
@@ -461,6 +461,7 @@ enum OpCodeEnum
ocEuroConvert = SC_OPCODE_EUROCONVERT,
ocFilterXML = SC_OPCODE_FILTERXML,
ocWebservice = SC_OPCODE_WEBSERVICE,
+ ocColor = SC_OPCODE_COLOR,
ocErf_MS = SC_OPCODE_ERF_MS,
ocErfc_MS = SC_OPCODE_ERFC_MS,
// internal stuff
diff --git a/sc/inc/helpids.h b/sc/inc/helpids.h
index 26465041bf3a..50df627933da 100644
--- a/sc/inc/helpids.h
+++ b/sc/inc/helpids.h
@@ -646,6 +646,7 @@
#define HID_FUNC_BITRSHIFT "SC_HID_FUNC_BITRSHIFT"
#define HID_FUNC_FILTERXML "SC_HID_FUNC_FILTERXML"
#define HID_FUNC_WEBSERVICE "SC_HID_FUNC_WEBSERVICE"
+#define HID_FUNC_COLOR "SC_HID_FUNC_COLOR"
#define HID_FUNC_COVARIANCE_P "SC_HID_FUNC_COVARIANCE_P"
#define HID_FUNC_COVARIANCE_S "SC_HID_FUNC_COVARIANCE_S"
#define HID_FUNC_ST_DEV_P_MS "SC_HID_FUNC_ST_DEV_P_MS"
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 4dc7b1b97db5..8e65f681fb0d 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -2509,6 +2509,7 @@ void Test::testFunctionLists()
"BITXOR",
"CEILING",
"CEILING.PRECISE",
+ "COLOR",
"COMBIN",
"COMBINA",
"CONVERT",
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 0c14d32d5266..6022c8ea7f6b 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -833,6 +833,7 @@ void ScMidB();
void ScFilterXML();
void ScWebservice();
+void ScColor();
void ScErf();
void ScErfc();
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index e4fb73f7e702..09ea67185b76 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -4088,6 +4088,7 @@ StackVar ScInterpreter::Interpret()
case ocZins : ScZins(); break;
case ocFilterXML : ScFilterXML(); break;
case ocWebservice : ScWebservice(); break;
+ case ocColor : ScColor(); break;
case ocErf_MS : ScErf(); break;
case ocErfc_MS : ScErfc(); break;
case ocZinsZ : ScZinsZ(); break;
diff --git a/sc/source/core/tool/interpr7.cxx b/sc/source/core/tool/interpr7.cxx
index 9ba8cd46f0d3..c0c9bf0715c4 100644
--- a/sc/source/core/tool/interpr7.cxx
+++ b/sc/source/core/tool/interpr7.cxx
@@ -274,4 +274,48 @@ void ScInterpreter::ScErfc()
}
}
+void ScInterpreter::ScColor()
+{
+ sal_uInt8 nParamCount = GetByte();
+ if(MustHaveParamCount(nParamCount, 3, 4))
+ {
+ double nAlpha = 0;
+ if(nParamCount == 4)
+ nAlpha = rtl::math::approxFloor(GetDouble());
+
+ if(nAlpha < 0 || nAlpha > 255)
+ {
+ PushIllegalArgument();
+ return;
+ }
+
+ double nBlue = rtl::math::approxFloor(GetDouble());
+
+ if(nBlue < 0 || nBlue > 255)
+ {
+ PushIllegalArgument();
+ return;
+ }
+
+ double nGreen = rtl::math::approxFloor(GetDouble());
+
+ if(nGreen < 0 || nGreen > 255)
+ {
+ PushIllegalArgument();
+ return;
+ }
+
+ double nRed = rtl::math::approxFloor(GetDouble());
+
+ if(nRed < 0 || nRed > 255)
+ {
+ PushIllegalArgument();
+ return;
+ }
+
+ double nVal = 256*256*256*nAlpha + 256*256*nRed + 256*nGreen + nBlue;
+ PushDouble(nVal);
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/src/scfuncs.src b/sc/source/ui/src/scfuncs.src
index 5887ab0fbbbd..3812f6e37b20 100644
--- a/sc/source/ui/src/scfuncs.src
+++ b/sc/source/ui/src/scfuncs.src
@@ -11999,6 +11999,53 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2
Text [ en-US ] = "String containing a valid XPath expression";
};
};
+ Resource SC_OPCODE_COLOR
+ {
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_COLOR );
+ 4; 0; 0; 0; 1;
+ 0;
+ };
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns an implementation defined value representing a RGBA color";
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Red";
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Value of red";
+ };
+ String 4 // Name of parameter 2
+ {
+ Text [ en-US ] = "Green";
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Value of green";
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Blue";
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Value of blue";
+ };
+ String 8 // Name of parameter 4
+ {
+ Text [ en-US ] = "Alpha";
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "Value of alpha";
+ };
+ };
Resource SC_OPCODE_WEBSERVICE
{
String 1 // Description