diff options
author | Wolfgang Pechlaner <libo@pechlaner.at> | 2011-09-04 14:40:25 +0200 |
---|---|---|
committer | Eike Rathke <erack@erack.de> | 2011-09-07 12:27:27 +0200 |
commit | c6b49f9098fb6c9816202e8d465c342788736af5 (patch) | |
tree | d1074becd133921d5dc77cf3afe9f1ac74516c67 /formula | |
parent | 5b80048a1ef119db569f9e9a259e94e773201b1f (diff) |
BITxxx functions according to ODF 1.2 OpenFormula
Implements BITAND, BITOR, BITXOR, BITLSHIFT and BITRSHIFT as specified by
OASIS OpenDocument Format 1.2 OpenFormula / ODFF.
Changes made by the committer:
* Original submission added the new functions to the Logical group, that group
has only functions though that return a logical value 1/0/true/false. ODFF
groups them under "Bit operation functions" that currently is not available
in Calc. Added the functions to the Mathematical group instead.
* Changed descriptions of functions in the Function Wizard.
* One sal_uInt64 constant instead of several identical literal 281474976710655
values.
* Replaced 'or' operators with ||
* Don't push two return values, if PushIllegalArgument() was used don't use
PushDouble() thereafter.
* Treat double values with ::rtl::math::approxFloor() to obtain integer
values.
* For BITLSHIFT and BITRSHIFT implemented a different algorithm following the
ODFF specification that allows larger shift values.
* Use our block braces style, respectively don't use block braces for one-line
if-statements.
* Fixed indentation levels.
* Adapted RTL_LOGFILE_CONTEXT_AUTHOR to say "pechlaner". Credit to whom credit
is due ;-)
Diffstat (limited to 'formula')
-rwxr-xr-x | formula/inc/formula/compiler.hrc | 10 | ||||
-rw-r--r-- | formula/inc/formula/opcode.hxx | 6 | ||||
-rw-r--r-- | formula/source/core/resource/core_resource.src | 32 |
3 files changed, 43 insertions, 5 deletions
diff --git a/formula/inc/formula/compiler.hrc b/formula/inc/formula/compiler.hrc index 5c58d9d3e068..a7b5cd808f88 100755 --- a/formula/inc/formula/compiler.hrc +++ b/formula/inc/formula/compiler.hrc @@ -392,9 +392,13 @@ #define SC_OPCODE_NUMBERVALUE 392 #define SC_OPCODE_CHISQ_DIST 393 #define SC_OPCODE_CHISQ_INV 394 -#define SC_OPCODE_STOP_2_PAR 395 - -#define SC_OPCODE_LAST_OPCODE_ID 394 /* last OpCode */ +#define SC_OPCODE_BITAND 395 +#define SC_OPCODE_BITOR 396 +#define SC_OPCODE_BITXOR 397 +#define SC_OPCODE_BITRSHIFT 398 +#define SC_OPCODE_BITLSHIFT 399 +#define SC_OPCODE_STOP_2_PAR 400 +#define SC_OPCODE_LAST_OPCODE_ID 399 /* last OpCode */ /*** Interna ***/ #define SC_OPCODE_INTERNAL_BEGIN 9999 diff --git a/formula/inc/formula/opcode.hxx b/formula/inc/formula/opcode.hxx index fc9a9b7cf525..571e1b00c247 100644 --- a/formula/inc/formula/opcode.hxx +++ b/formula/inc/formula/opcode.hxx @@ -365,6 +365,12 @@ enum OpCodeEnum ocTableOp = SC_OPCODE_TABLE_OP, ocBetaDist = SC_OPCODE_BETA_DIST, ocBetaInv = SC_OPCODE_BETA_INV, + // Bit functions + ocBitAnd = SC_OPCODE_BITAND, + ocBitOr = SC_OPCODE_BITOR, + ocBitXor = SC_OPCODE_BITXOR, + ocBitRshift = SC_OPCODE_BITRSHIFT, + ocBitLshift = SC_OPCODE_BITLSHIFT, // miscellaneous ocWeek = SC_OPCODE_WEEK, ocGetDayOfWeek = SC_OPCODE_GET_DAY_OF_WEEK, diff --git a/formula/source/core/resource/core_resource.src b/formula/source/core/resource/core_resource.src index b8a5f1250941..e42a06db4f4f 100644 --- a/formula/source/core/resource/core_resource.src +++ b/formula/source/core/resource/core_resource.src @@ -344,7 +344,11 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_ODFF String SC_OPCODE_GAMMA { Text = "GAMMA" ; }; String SC_OPCODE_CHISQ_DIST { Text = "CHISQDIST" ; }; String SC_OPCODE_CHISQ_INV { Text = "CHISQINV" ;}; - + String SC_OPCODE_BITAND { Text = "BITAND" ;}; + String SC_OPCODE_BITOR { Text = "BITOR" ;}; + String SC_OPCODE_BITXOR { Text = "BITXOR" ;}; + String SC_OPCODE_BITRSHIFT { Text = "BITRSHIFT" ;}; + String SC_OPCODE_BITLSHIFT { Text = "BITLSHIFT" ;}; /* BEGIN defined ERROR.TYPE() values. */ String SC_OPCODE_ERROR_NULL { Text = "#NULL!" ; }; String SC_OPCODE_ERROR_DIVZERO { Text = "#DIV/0!" ; }; @@ -672,7 +676,11 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH String SC_OPCODE_GAMMA { Text = "GAMMA" ; }; String SC_OPCODE_CHISQ_DIST { Text = "CHISQDIST" ; }; String SC_OPCODE_CHISQ_INV { Text = "CHISQINV" ;}; - + String SC_OPCODE_BITAND { Text = "BITAND" ;}; + String SC_OPCODE_BITOR { Text = "BITOR" ;}; + String SC_OPCODE_BITXOR { Text = "BITXOR" ;}; + String SC_OPCODE_BITRSHIFT { Text = "BITRSHIFT" ;}; + String SC_OPCODE_BITLSHIFT { Text = "BITLSHIFT" ;}; /* BEGIN defined ERROR.TYPE() values. */ String SC_OPCODE_ERROR_NULL { Text = "#NULL!" ; }; String SC_OPCODE_ERROR_DIVZERO { Text = "#DIV/0!" ; }; @@ -1860,6 +1868,26 @@ Resource RID_STRLIST_FUNCTION_NAMES { Text [ en-US ] = "CHISQINV" ; }; + String SC_OPCODE_BITAND + { + Text [ en-US ] = "BITAND" ; + }; + String SC_OPCODE_BITOR + { + Text [ en-US ] = "BITOR" ; + }; + String SC_OPCODE_BITXOR + { + Text [ en-US ] = "BITXOR" ; + }; + String SC_OPCODE_BITRSHIFT + { + Text [ en-US ] = "BITRSHIFT" ; + }; + String SC_OPCODE_BITLSHIFT + { + Text [ en-US ] = "BITLSHIFT" ; + }; /* BEGIN defined ERROR.TYPE() values. */ /* ERROR.TYPE( #NULL! ) == 1 */ String SC_OPCODE_ERROR_NULL |