formula/inc/formula/compiler.hrc | 6 +- formula/inc/formula/opcode.hxx | 2 formula/source/core/resource/core_resource.src | 12 ++++ sc/inc/helpids.h | 2 sc/source/core/inc/interpre.hxx | 9 +++ sc/source/core/tool/interpr1.cxx | 42 ++++++++++++++++ sc/source/core/tool/interpr4.cxx | 2 sc/source/ui/src/scfuncs.src | 64 +++++++++++++++++++++++++ sc/util/hidother.src | 2 sdext/source/pdfimport/pdfparse/pdfentries.cxx | 2 10 files changed, 140 insertions(+), 3 deletions(-)
New commits: commit 38baabd16edab43e4c2ea60036a762837fee0880 Author: Pedro Giffuni <[email protected]> Date: Sun Dec 6 18:56:29 2015 +0000 Unnecessary semicolon diff --git a/sdext/source/pdfimport/pdfparse/pdfentries.cxx b/sdext/source/pdfimport/pdfparse/pdfentries.cxx index 147324d..65af7f0 100644 --- a/sdext/source/pdfimport/pdfparse/pdfentries.cxx +++ b/sdext/source/pdfimport/pdfparse/pdfentries.cxx @@ -773,7 +773,7 @@ static void unzipToBuffer( const char* pBegin, unsigned int nLen, if( err == Z_STREAM_END ) { if( aZStr.avail_out > 0 ) - *pOutLen -= aZStr.avail_out;; + *pOutLen -= aZStr.avail_out; } inflateEnd(&aZStr); if( err < Z_OK ) commit 6fc5d5e8812de2983973198dabbb6ae911f9fabe Author: Damjan Jovanovic <[email protected]> Date: Sun Dec 6 18:17:33 2015 +0000 #i126701# Patch for adding bit shift functions to calc Patch by: Pathangi Janardhanan Jatinshravan <JATINSHR001 at e dot ntu dot edu dot sg> Review by: me diff --git a/formula/inc/formula/compiler.hrc b/formula/inc/formula/compiler.hrc index 49f6f7f..a1b3674 100644 --- a/formula/inc/formula/compiler.hrc +++ b/formula/inc/formula/compiler.hrc @@ -400,10 +400,12 @@ #define SC_OPCODE_BITAND 404 #define SC_OPCODE_BITOR 405 #define SC_OPCODE_BITXOR 406 +#define SC_OPCODE_BITLSHIFT 407 +#define SC_OPCODE_BITRSHIFT 408 -#define SC_OPCODE_STOP_2_PAR 407 +#define SC_OPCODE_STOP_2_PAR 409 -#define SC_OPCODE_LAST_OPCODE_ID 406 /* last OpCode */ +#define SC_OPCODE_LAST_OPCODE_ID 408 /* last OpCode */ /*** Interna ***/ #define SC_OPCODE_INTERNAL_BEGIN 9999 diff --git a/formula/inc/formula/opcode.hxx b/formula/inc/formula/opcode.hxx index 0cd908e..90de255 100644 --- a/formula/inc/formula/opcode.hxx +++ b/formula/inc/formula/opcode.hxx @@ -397,6 +397,8 @@ enum OpCodeEnum ocBitAnd = SC_OPCODE_BITAND, ocBitOr = SC_OPCODE_BITOR, ocBitXor = SC_OPCODE_BITXOR, + ocBitLShift = SC_OPCODE_BITLSHIFT, + ocBitRShift = SC_OPCODE_BITRSHIFT, // internal stuff ocInternalBegin = SC_OPCODE_INTERNAL_BEGIN, ocTTT = SC_OPCODE_TTT, diff --git a/formula/source/core/resource/core_resource.src b/formula/source/core/resource/core_resource.src index a29acd0..c8799d4 100644 --- a/formula/source/core/resource/core_resource.src +++ b/formula/source/core/resource/core_resource.src @@ -352,6 +352,8 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_ODFF String SC_OPCODE_BITAND { Text= "BITAND" ; }; String SC_OPCODE_BITOR { Text= "BITOR" ; }; String SC_OPCODE_BITXOR { Text= "BITXOR" ; }; + String SC_OPCODE_BITLSHIFT { Text= "BITLSHIFT" ; }; + String SC_OPCODE_BITRSHIFT { Text= "BITRSHIFT" ; }; /* BEGIN defined ERROR.TYPE() values. */ String SC_OPCODE_ERROR_NULL { Text = "#NULL!" ; }; @@ -692,6 +694,8 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH String SC_OPCODE_BITAND { Text = "BITAND" ; }; String SC_OPCODE_BITOR { Text = "BITOR" ; }; String SC_OPCODE_BITXOR { Text = "BITXOR" ; }; + String SC_OPCODE_BITLSHIFT { Text= "BITLSHIFT" ; }; + String SC_OPCODE_BITRSHIFT { Text= "BITRSHIFT" ; }; /* BEGIN defined ERROR.TYPE() values. */ String SC_OPCODE_ERROR_NULL { Text = "#NULL!" ; }; @@ -1928,6 +1932,14 @@ Resource RID_STRLIST_FUNCTION_NAMES { Text [ en-US ] = "BITXOR"; }; + String SC_OPCODE_BITLSHIFT + { + Text [ en-US ] = "BITLSHIFT"; + }; + String SC_OPCODE_BITRSHIFT + { + Text [ en-US ] = "BITRSHIFT"; + }; /* BEGIN defined ERROR.TYPE() values. */ /* ERROR.TYPE( #NULL! ) == 1 */ String SC_OPCODE_ERROR_NULL diff --git a/sc/inc/helpids.h b/sc/inc/helpids.h index ae09a53..f355433 100644 --- a/sc/inc/helpids.h +++ b/sc/inc/helpids.h @@ -777,3 +777,5 @@ #define HID_FUNC_BITAND "SC_HID_FUNC_BITAND" #define HID_FUNC_BITOR "SC_HID_FUNC_BITOR" #define HID_FUNC_BITXOR "SC_HID_FUNC_BITXOR" +#define HID_FUNC_BITLSHIFT "SC_HID_FUNC_BITLSHIFT" +#define HID_FUNC_BITRSHIFT "SC_HID_FUNC_BITRSHIFT" \ No newline at end of file diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index 2e1aede..36a2c3b 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -149,6 +149,12 @@ public: BITOR, BITXOR }; + + enum bitShift + { + BITLSHIFT, + BITRSHIFT + }; }; DECL_FIXEDMEMPOOL_NEWDEL( ScInterpreter ) @@ -526,6 +532,9 @@ void ScBitAnd(); void ScBitOr(); void ScBitXor(); void ScBitArithmeticOps( bitOperations::bitArithmetic ); +void ScBitLShift(); +void ScBitRShift(); +void ScBitShiftOps(bitOperations::bitShift); // If upon call rMissingField==sal_True then the database field parameter may be // missing (Xcl DCOUNT() syntax), or may be faked as missing by having the diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 864cb86..4cfb963 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -1207,6 +1207,48 @@ void ScInterpreter::ScBitArithmeticOps(bitOperations::bitArithmetic bitOp) } } +void ScInterpreter::ScBitRShift() { + ScBitShiftOps(bitOperations::BITRSHIFT); +} + +void ScInterpreter::ScBitLShift() { + ScBitShiftOps(bitOperations::BITLSHIFT); +} + +void ScInterpreter::ScBitShiftOps(bitOperations::bitShift bitOp) { + if ( MustHaveParamCount( GetByte(), 2 ) ) + { + double n = ::rtl::math::approxFloor( GetDouble() ); + double val = ::rtl::math::approxFloor( GetDouble() ); + + if ( val < 0 ) + { + PushIllegalArgument(); + } + else + { + double result; + if (n < 0) + { + if (bitOp == bitOperations::BITLSHIFT) + result = (sal_uInt64) val >> (sal_uInt64) -n; + else + result = (sal_uInt64) val << (sal_uInt64) -n; + } + else if( n == 0) + result = val; + else + { + if (bitOp == bitOperations::BITLSHIFT) + result = (sal_uInt64) val << (sal_uInt64) n; + else + result = (sal_uInt64) val >> (sal_uInt64) n; + + } + PushDouble( result ); + } + } +} void ScInterpreter::ScAnd() { diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 2232717..83161bf 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -3769,6 +3769,8 @@ StackVar ScInterpreter::Interpret() case ocBitAnd : ScBitAnd(); break; case ocBitOr : ScBitOr(); break; case ocBitXor : ScBitXor(); break; + case ocBitLShift : ScBitLShift(); break; + case ocBitRShift : ScBitRShift(); break; case ocNone : nFuncFmtType = NUMBERFORMAT_UNDEFINED; break; default : PushError( errUnknownOpCode); break; } diff --git a/sc/source/ui/src/scfuncs.src b/sc/source/ui/src/scfuncs.src index 81274c7..d00fa9b 100644 --- a/sc/source/ui/src/scfuncs.src +++ b/sc/source/ui/src/scfuncs.src @@ -9533,6 +9533,70 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2 }; }; + Resource SC_OPCODE_BITLSHIFT + { + String 1 // Description + { + Text [ en-US ] = "Bitwise left shift of an integer value."; + }; + ExtraData = + { + 0; + ID_FUNCTION_GRP_MATH; + U2S( HID_FUNC_BITLSHIFT ); + 2; 0; 0; + 0; + }; + String 2 // Name of Parameter 1 + { + Text [ en-US ] = "Number" ; + }; + String 3 // Description of Parameter 1 + { + Text [ en-US ] = "The value to be shifted. Positive integer." ; + }; + String 4 // Name of Parameter 2 + { + Text [ en-US ] = "Shift" ; + }; + String 5 // Description of Parameter 2 + { + Text [ en-US ] = "The number of bits the first argument is to be shifted by." ; + }; + }; + + Resource SC_OPCODE_BITRSHIFT + { + String 1 // Description + { + Text [ en-US ] = "Bitwise right shift of an integer value."; + }; + ExtraData = + { + 0; + ID_FUNCTION_GRP_MATH; + U2S( HID_FUNC_BITRSHIFT ); + 2; 0; 0; + 0; + }; + String 2 // Name of Parameter 1 + { + Text [ en-US ] = "Number" ; + }; + String 3 // Description of Parameter 1 + { + Text [ en-US ] = "The value to be shifted. Positive integer." ; + }; + String 4 // Name of Parameter 2 + { + Text [ en-US ] = "Shift" ; + }; + String 5 // Description of Parameter 2 + { + Text [ en-US ] = "The number of bits the first argument is to be shifted by." ; + }; + }; + }; #if defined(U2S) diff --git a/sc/util/hidother.src b/sc/util/hidother.src index b3dc678..c1a5818 100644 --- a/sc/util/hidother.src +++ b/sc/util/hidother.src @@ -489,3 +489,5 @@ hidspecial HID_DAI_FUNC_ROT13 { HelpID = HID_DAI_FUNC_ROT13; }; hidspecial HID_FUNC_BITAND { HelpID = HID_FUNC_BITAND; }; hidspecial HID_FUNC_BITOR { HelpID = HID_FUNC_BITOR; }; hidspecial HID_FUNC_BITXOR { HelpID = HID_FUNC_BITXOR; }; +hidspecial HID_FUNC_BITLSHIFT { HelpID = HID_FUNC_BITLSHIFT; }; +hidspecial HID_FUNC_BITRSHIFT { HelpID = HID_FUNC_BITRSHIFT; }; _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
