Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hi

Wonderful, great stuff - I have to apologize, the many whitespace
changes in the calc part of the patch are because of my substandard
mentoring - cleaned-up version of the first patch attached.

I was in the belief that we shall use spaces instead of tabs.

Corrected patches attached.

--
RN
From 9536eed6be175243f9e55f5715d1fb784a6f5f4f Mon Sep 17 00:00:00 2001
From: Wolfgang Pechlaner <libo@pechlaner.at>
Date: Sun, 4 Sep 2011 14:40:25 +0200
Subject: [PATCH] BITxxx functions for ODF 1.2

---
 sc/inc/helpids.h                 |    5 +
 sc/qa/unit/ucalc.cxx             |    5 +
 sc/source/core/inc/interpre.hxx  |    5 +
 sc/source/core/tool/interpr1.cxx |  101 ++++++++++++++++++++++++
 sc/source/core/tool/interpr4.cxx |    5 +
 sc/source/ui/src/scfuncs.src     |  156 ++++++++++++++++++++++++++++++++++++++
 sc/util/hidother.src             |    5 +
 7 files changed, 282 insertions(+), 0 deletions(-)

diff --git a/sc/inc/helpids.h b/sc/inc/helpids.h
index c80dd1b..b04aa77 100644
--- a/sc/inc/helpids.h
+++ b/sc/inc/helpids.h
@@ -692,3 +692,8 @@
 #define HID_FUNC_UNICODE                                        "SC_HID_FUNC_UNICODE"
 #define HID_FUNC_UNICHAR                                        "SC_HID_FUNC_UNICHAR"
 #define HID_FUNC_NUMBERVALUE                                    "SC_HID_FUNC_NUMBERVALUE"
+#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"
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 7430a60..533fbe2 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1742,6 +1742,11 @@ void Test::testFunctionLists()
 
     const char* aLogical[] = {
         "AND",
+        "BITAND",
+        "BITLSHIFT",
+        "BITOR",
+        "BITRSHIFT",
+        "BITXOR",
         "FALSE",
         "IF",
         "NOT",
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 27027d5..50881d6 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -412,6 +412,11 @@ void ScAnd();
 void ScOr();
 void ScNot();
 void ScNeg();
+void ScBitAnd();
+void ScBitOr();
+void ScBitXor();
+void ScBitRshift();
+void ScBitLshift();
 void ScPercentSign();
 void ScIntersect();
 void ScRangeFunc();
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index f581ac7..3921e0e 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -1391,6 +1391,107 @@ void ScInterpreter::ScNeg()
 }
 
 
+void ScInterpreter::ScBitAnd()
+{
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScBitAnd" );
+
+    if ( !MustHaveParamCount( GetByte(), 2 ) )
+      return;
+
+     double num1, num2;
+     num1 = GetDouble();
+     num2 = GetDouble();
+     if ((num1 > 281474976710655) or (num1 < 0) or
+         (num2 > 281474976710655) or (num2 < 0)) {
+        PushIllegalArgument();
+     }
+
+      PushDouble ((sal_uInt64) num1 & (sal_uInt64) num2);
+}
+
+
+void ScInterpreter::ScBitOr()
+{
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScBitOr" );
+
+      if ( !MustHaveParamCount( GetByte(), 2 ) )
+      return;
+
+    double num1, num2;
+    num1 = GetDouble();
+    num2 = GetDouble();
+    if ((num1 > 281474976710655) or (num1 < 0) or
+        (num2 > 281474976710655) or (num2 < 0)) {
+          PushIllegalArgument();
+    }
+
+    PushDouble ((sal_uInt64) num1 | (sal_uInt64) num2);
+}
+
+
+void ScInterpreter::ScBitXor()
+{
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScBitXor" );
+
+    if ( !MustHaveParamCount( GetByte(), 2 ) )
+      return;
+
+    double num1, num2;
+    num1 = GetDouble();
+    num2 = GetDouble();
+    if ((num1 > 281474976710655) or (num1 < 0) or
+        (num2 > 281474976710655) or (num2 < 0)) {
+         PushIllegalArgument();
+    }
+
+    PushDouble ((sal_uInt64) num1 ^ (sal_uInt64) num2);
+}
+
+
+void ScInterpreter::ScBitLshift()
+{
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScBitLshift" );
+
+    if ( !MustHaveParamCount( GetByte(), 2 ) )
+      return;
+
+    sal_uInt64 erg;
+    sal_Int32 ishift = GetDouble();
+    double num = GetDouble();
+        if ((num > 281474976710655) or (num < 0))  {
+            PushIllegalArgument();
+    }
+    if (ishift < 0) {
+      erg = (sal_uInt64) num >> -ishift;
+    } else {
+      erg = (sal_uInt64) num << ishift;
+    }
+    PushDouble (erg);
+}
+
+void ScInterpreter::ScBitRshift()
+{
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScBitRshift" );
+
+    if ( !MustHaveParamCount( GetByte(), 2 ) )
+      return;
+    sal_uInt64 erg;
+    sal_Int32 ishift = GetDouble();
+    double num = GetDouble();
+        if ((num > 281474976710655) or (num < 0))  {
+          PushIllegalArgument();
+    }
+    if (ishift < 0) {
+      erg = (sal_uInt64) num << -ishift;
+    } else {
+      erg = (sal_uInt64) num >> ishift;
+    }
+    PushDouble (erg);
+}
+
+
+
+
 void ScInterpreter::ScPercentSign()
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScPercentSign" );
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 05ff646..8e0eb5f 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -4064,6 +4064,11 @@ StackVar ScInterpreter::Interpret()
                 case ocUnicode          : ScUnicode();                  break;
                 case ocUnichar          : ScUnichar();                  break;
                 case ocTTT              : ScTTT();                      break;
+                case ocBitAnd           : ScBitAnd();                   break;
+                case ocBitOr            : ScBitOr();                    break;
+                case ocBitXor           : ScBitXor();                   break;
+                case ocBitRshift        : ScBitRshift();                break;
+                case ocBitLshift        : ScBitLshift();                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 4f99f90..e67b76b 100644
--- a/sc/source/ui/src/scfuncs.src
+++ b/sc/source/ui/src/scfuncs.src
@@ -9037,6 +9037,162 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2
             Text [ en-US ] = "Defines the character used as the decimal point." ;
         };
     };
+
+    Resource SC_OPCODE_BITAND
+    {
+    String 1 // Description
+    {
+        Text [ en-US ] = "Logical and of 2 integers.";
+    };
+    ExtraData =
+    {
+        0;
+        ID_FUNCTION_GRP_LOGIC;
+        U2S( HID_FUNC_BITAND );
+        2;  0;  0;
+        0;
+    };
+       String 2 // Name of Parameter 1
+        {
+            Text [ en-US ] = "number" ;
+        };
+        String 3 // Description of Parameter 1
+        {
+            Text [ en-US ] = "positive interger less then 2^48-1." ;
+        };
+        String 4 // Name of Parameter 2
+        {
+                Text [ en-US ] = "number" ;
+        };
+        String 5 // Description of Parameter 2
+        {
+            Text [ en-US ] = "positive interger less then 2^48-1." ;
+        };
+    };
+    Resource SC_OPCODE_BITOR
+    {
+    String 1 // Description
+    {
+        Text [ en-US ] = "Logical or of 2 integers.";
+    };
+    ExtraData =
+    {
+        0;
+        ID_FUNCTION_GRP_LOGIC;
+        U2S( HID_FUNC_BITOR );
+        2;  0;  0;
+        0;
+    };
+       String 2 // Name of Parameter 1
+        {
+            Text [ en-US ] = "number" ;
+        };
+        String 3 // Description of Parameter 1
+        {
+            Text [ en-US ] = "positive interger less then 2^48-1." ;
+        };
+        String 4 // Name of Parameter 2
+        {
+                Text [ en-US ] = "number" ;
+        };
+        String 5 // Description of Parameter 2
+        {
+            Text [ en-US ] = "positive interger less then 2^48-1." ;
+        };
+    };
+    Resource SC_OPCODE_BITXOR
+    {
+    String 1 // Description
+    {
+        Text [ en-US ] = "Logical exclusive or of 2 integers.";
+    };
+    ExtraData =
+    {
+        0;
+        ID_FUNCTION_GRP_LOGIC;
+        U2S( HID_FUNC_BITXOR );
+        2;  0;  0;
+        0;
+    };
+       String 2 // Name of Parameter 1
+        {
+            Text [ en-US ] = "number" ;
+        };
+        String 3 // Description of Parameter 1
+        {
+            Text [ en-US ] = "positive interger less then 2^48-1." ;
+        };
+        String 4 // Name of Parameter 2
+        {
+                Text [ en-US ] = "number" ;
+        };
+        String 5 // Description of Parameter 2
+        {
+            Text [ en-US ] = "positive interger less then 2^48-1." ;
+        };
+    };
+    Resource SC_OPCODE_BITRSHIFT
+    {
+    String 1 // Description
+    {
+        Text [ en-US ] = "Logical right shift.";
+    };
+    ExtraData =
+    {
+        0;
+        ID_FUNCTION_GRP_LOGIC;
+        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 ] = "positive interger less then 2^48-1." ;
+        };
+        String 4 // Name of Parameter 2
+        {
+                Text [ en-US ] = "number" ;
+        };
+        String 5 // Description of Parameter 2
+        {
+            Text [ en-US ] = "number between - 48 and 48" ;
+        };
+    };
+    Resource SC_OPCODE_BITLSHIFT
+    {
+    String 1 // Description
+    {
+        Text [ en-US ] = "Logical left shift.";
+    };
+    ExtraData =
+    {
+        0;
+        ID_FUNCTION_GRP_LOGIC;
+        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 ] = "positive interger less then 2^48-1." ;
+        };
+        String 4 // Name of Parameter 2
+        {
+                Text [ en-US ] = "number" ;
+        };
+        String 5 // Description of Parameter 2
+        {
+            Text [ en-US ] = "number between - 48 and 48" ;
+        };
+    };
 };
 
 #if defined(U2S)
diff --git a/sc/util/hidother.src b/sc/util/hidother.src
index d575580..37798c3 100644
--- a/sc/util/hidother.src
+++ b/sc/util/hidother.src
@@ -363,6 +363,11 @@ hidspecial HID_FUNC_NUMBERVALUE     { HelpID = HID_FUNC_NUMBERVALUE; };
 hidspecial HID_FUNC_GAMMA           { HelpID = HID_FUNC_GAMMA; };
 hidspecial HID_FUNC_CHISQDIST       { HelpID = HID_FUNC_CHISQDIST; };
 hidspecial HID_FUNC_CHISQINV        { HelpID = HID_FUNC_CHISQINV; };
+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_BITRSHIFT       { HelpID = HID_FUNC_BITRSHIFT; };
+hidspecial HID_FUNC_BITLSHIFT       { HelpID = HID_FUNC_BITLSHIFT; };
 
 // ... and from Analysis Addin
 
-- 
1.7.3.4

From c5c887d972b3bde5104e6f39bf84cdc7931b1676 Mon Sep 17 00:00:00 2001
From: Wolfgang Pechlaner <libo@pechlaner.at>
Date: Sun, 4 Sep 2011 01:19:54 +0200
Subject: [PATCH] new BITxxx_functions

---
 formula/inc/formula/compiler.hrc               |   10 +++++--
 formula/inc/formula/opcode.hxx                 |    6 ++++
 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 e071b3a..5b770f2 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 068e99d..c6b92d1 100644
--- a/formula/inc/formula/opcode.hxx
+++ b/formula/inc/formula/opcode.hxx
@@ -389,6 +389,12 @@ enum OpCodeEnum
         ocGetPivotData      = SC_OPCODE_GET_PIVOT_DATA,
         ocEuroConvert       = SC_OPCODE_EUROCONVERT,
         ocNumberValue          = SC_OPCODE_NUMBERVALUE,
+    // logical functions
+        ocBitAnd            = SC_OPCODE_BITAND,
+        ocBitOr             = SC_OPCODE_BITOR,
+        ocBitXor            = SC_OPCODE_BITXOR,
+        ocBitRshift         = SC_OPCODE_BITRSHIFT,
+        ocBitLshift         = SC_OPCODE_BITLSHIFT,
     // 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 1724ea4..9b03294 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
-- 
1.7.3.4


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.