[Libreoffice-commits] core.git: bridges/source

Stephan Bergmann sbergman at redhat.com
Tue Apr 10 11:16:47 UTC 2018


 bridges/source/cpp_uno/gcc3_aix_powerpc/uno2cpp.cxx     |   24 ++++++++--
 bridges/source/cpp_uno/gcc3_ios/uno2cpp.cxx             |   31 ++++++++++---
 bridges/source/cpp_uno/gcc3_linux_alpha/uno2cpp.cxx     |   28 +++++++++---
 bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx       |   28 +++++++++---
 bridges/source/cpp_uno/gcc3_linux_hppa/uno2cpp.cxx      |   24 ++++++++--
 bridges/source/cpp_uno/gcc3_linux_ia64/uno2cpp.cxx      |   16 +++++++
 bridges/source/cpp_uno/gcc3_linux_intel/uno2cpp.cxx     |   24 ++++++++--
 bridges/source/cpp_uno/gcc3_linux_m68k/uno2cpp.cxx      |   24 ++++++++--
 bridges/source/cpp_uno/gcc3_linux_mips/uno2cpp.cxx      |   25 +++++++++--
 bridges/source/cpp_uno/gcc3_linux_mips64/uno2cpp.cxx    |   27 +++++++++---
 bridges/source/cpp_uno/gcc3_linux_powerpc/uno2cpp.cxx   |   24 ++++++++--
 bridges/source/cpp_uno/gcc3_linux_powerpc64/uno2cpp.cxx |   16 +++++++
 bridges/source/cpp_uno/gcc3_linux_s390/uno2cpp.cxx      |   24 ++++++++--
 bridges/source/cpp_uno/gcc3_linux_s390x/uno2cpp.cxx     |   28 +++++++++---
 bridges/source/cpp_uno/gcc3_linux_sparc/uno2cpp.cxx     |   32 +++++++++++---
 bridges/source/cpp_uno/gcc3_linux_sparc64/uno2cpp.cxx   |   36 ++++++++++++----
 bridges/source/cpp_uno/gcc3_solaris_intel/uno2cpp.cxx   |   24 ++++++++--
 bridges/source/cpp_uno/gcc3_solaris_sparc/uno2cpp.cxx   |   32 +++++++++++---
 18 files changed, 379 insertions(+), 88 deletions(-)

New commits:
commit 4544713d3ae7a83d45047b65bf7ba520b3e8762e
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Apr 10 10:06:23 2018 +0200

    Adapt remaining cpp_uno bridges to #i114635#
    
    ..."C++ UNO bridge should convert non-UNO exceptions into RuntimeException"
    (<https://bz.apache.org/ooo/show_bug.cgi?id=114635>), see
    <https://lists.freedesktop.org/archives/libreoffice/2018-April/079985.html>
    "Re: CppunitTest_sw_filters_test failing on x86 Linux, std::exception ->
    uno::RuntimeException".
    
    (The msvc_win32_{intel,x86-64} versions already handle non-UNO exceptions in
    their msc{i,x}_filterCppException functions, in a different way.)
    
    Change-Id: Ie359affed6831d16be0de3e3ff065484e28bd9c3
    Reviewed-on: https://gerrit.libreoffice.org/52665
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/bridges/source/cpp_uno/gcc3_aix_powerpc/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_aix_powerpc/uno2cpp.cxx
index 6024ceed5cae..1c8045fafe26 100644
--- a/bridges/source/cpp_uno/gcc3_aix_powerpc/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_aix_powerpc/uno2cpp.cxx
@@ -20,7 +20,10 @@
 #include <sys/types.h>
 #include <sys/malloc.h>
 
+#include <com/sun/star/uno/Exception.hxx>
+#include <com/sun/star/uno/RuntimeException.hxx>
 #include <com/sun/star/uno/genfunc.hxx>
+#include <o3tl/runtimetooustring.hxx>
 #include <uno/data.h>
 
 #include "bridge.hxx"
@@ -29,8 +32,11 @@
 #include "vtables.hxx"
 
 #include "share.hxx"
+
+#include <exception>
 #include <stdio.h>
 #include <string.h>
+#include <typeinfo>
 
 using namespace ::com::sun::star::uno;
 
@@ -294,10 +300,20 @@ static void cpp_call(
         try
         {
                 assert( !( (pCppStack - pCppStackStart ) & 3) && "UNALIGNED STACK !!! (Please DO panic)" );
-                callVirtualMethod(
-                        pAdjustedThisPtr, aVtableSlot.index,
-                        pCppReturn, pReturnTypeDescr->eTypeClass,
-                        pStackStart, (pStack - pStackStart), pFPR, nFPR );
+                try {
+                    callVirtualMethod(
+                            pAdjustedThisPtr, aVtableSlot.index,
+                            pCppReturn, pReturnTypeDescr->eTypeClass,
+                            pStackStart, (pStack - pStackStart), pFPR, nFPR );
+                } catch (css::uno::Exception &) {
+                    throw;
+                } catch (std::exception & e) {
+                    throw css::uno::RuntimeException(
+                        "C++ code threw " + o3tl::runtimeToOUString(typeid(e).name()) + ": "
+                        + o3tl::runtimeToOUString(e.what()));
+                } catch (...) {
+                    throw css::uno::RuntimeException("C++ code threw unknown exception");
+                }
                 // NO exception occurred...
                 *ppUnoExc = 0;
 
diff --git a/bridges/source/cpp_uno/gcc3_ios/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_ios/uno2cpp.cxx
index 7915fa7a9513..9287bb4ea224 100644
--- a/bridges/source/cpp_uno/gcc3_ios/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_ios/uno2cpp.cxx
@@ -19,7 +19,14 @@
 
 #ifdef __arm64
 
+#include <sal/config.h>
+
+#include <exception>
+#include <typeinfo>
+
+#include <com/sun/star/uno/Exception.hpp>
 #include <com/sun/star/uno/RuntimeException.hpp>
+#include <o3tl/runtimetooustring.hxx>
 
 #include "bridge.hxx"
 #include "types.hxx"
@@ -348,13 +355,23 @@ static void cpp_call(
 
     try
     {
-        callVirtualMethod(
-            pAdjustedThisPtr, aVtableSlot.index,
-            pCppReturn, pReturnTypeRef,
-            pStackStart,
-            (pStack - pStackStart),
-            pGPR,
-            pFPR);
+        try {
+            callVirtualMethod(
+                pAdjustedThisPtr, aVtableSlot.index,
+                pCppReturn, pReturnTypeRef,
+                pStackStart,
+                (pStack - pStackStart),
+                pGPR,
+                pFPR);
+        } catch (css::uno::Exception &) {
+            throw;
+        } catch (std::exception & e) {
+            throw css::uno::RuntimeException(
+                "C++ code threw " + o3tl::runtimeToOUString(typeid(e).name()) + ": "
+                + o3tl::runtimeToOUString(e.what()));
+        } catch (...) {
+            throw css::uno::RuntimeException("C++ code threw unknown exception");
+        }
 
         // NO exception occurred...
         *ppUnoExc = 0;
diff --git a/bridges/source/cpp_uno/gcc3_linux_alpha/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_alpha/uno2cpp.cxx
index acc945468958..143b1533479c 100644
--- a/bridges/source/cpp_uno/gcc3_linux_alpha/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_alpha/uno2cpp.cxx
@@ -17,10 +17,16 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
 
+#include <exception>
 #include <malloc.h>
+#include <typeinfo>
 
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
 #include <com/sun/star/uno/genfunc.hxx>
+#include <o3tl/runtimetooustring.hxx>
 #include <uno/data.h>
 
 #include "bridge.hxx"
@@ -323,12 +329,22 @@ static void cpp_call(
 
     try
     {
-        callVirtualMethod(
-            pAdjustedThisPtr, aVtableSlot.index,
-            pCppReturn, pReturnTypeDescr,
-            pStackStart, (pStack - pStackStart),
-            pGPR, nRegs,
-            pFPR, nRegs );
+        try {
+            callVirtualMethod(
+                pAdjustedThisPtr, aVtableSlot.index,
+                pCppReturn, pReturnTypeDescr,
+                pStackStart, (pStack - pStackStart),
+                pGPR, nRegs,
+                pFPR, nRegs );
+        } catch (css::uno::Exception &) {
+            throw;
+        } catch (std::exception & e) {
+            throw css::uno::RuntimeException(
+                "C++ code threw " + o3tl::runtimeToOUString(typeid(e).name()) + ": "
+                + o3tl::runtimeToOUString(e.what()));
+        } catch (...) {
+            throw css::uno::RuntimeException("C++ code threw unknown exception");
+        }
         // NO exception occurred...
         *ppUnoExc = 0;
 
diff --git a/bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx
index 3fc2602a602b..b8deb4ba7439 100644
--- a/bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_arm/uno2cpp.cxx
@@ -21,7 +21,9 @@
 #include <rtl/alloc.h>
 
 #include <com/sun/star/uno/genfunc.hxx>
+#include <com/sun/star/uno/Exception.hpp>
 #include "com/sun/star/uno/RuntimeException.hpp"
+#include <o3tl/runtimetooustring.hxx>
 #include <uno/data.h>
 
 #include <bridge.hxx>
@@ -31,8 +33,10 @@
 
 #include "share.hxx"
 
+#include <exception>
 #include <stdio.h>
 #include <string.h>
+#include <typeinfo>
 
 /*
  * Based on http://gcc.gnu.org/PR41443
@@ -524,13 +528,23 @@ static void cpp_call(
 
     try
     {
-        callVirtualMethod(
-            pAdjustedThisPtr, aVtableSlot.index,
-            pCppReturn, pReturnTypeRef,
-            pStackStart,
-            (pStack - pStackStart),
-            pGPR, nGPR,
-            pFPR);
+        try {
+            callVirtualMethod(
+                pAdjustedThisPtr, aVtableSlot.index,
+                pCppReturn, pReturnTypeRef,
+                pStackStart,
+                (pStack - pStackStart),
+                pGPR, nGPR,
+                pFPR);
+        } catch (css::uno::Exception &) {
+            throw;
+        } catch (std::exception & e) {
+            throw css::uno::RuntimeException(
+                "C++ code threw " + o3tl::runtimeToOUString(typeid(e).name()) + ": "
+                + o3tl::runtimeToOUString(e.what()));
+        } catch (...) {
+            throw css::uno::RuntimeException("C++ code threw unknown exception");
+        }
 
         // NO exception occurred...
         *ppUnoExc = 0;
diff --git a/bridges/source/cpp_uno/gcc3_linux_hppa/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_hppa/uno2cpp.cxx
index 2c81c707253a..656f55c6b29e 100644
--- a/bridges/source/cpp_uno/gcc3_linux_hppa/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_hppa/uno2cpp.cxx
@@ -21,7 +21,9 @@
 #include <rtl/alloc.h>
 
 #include <com/sun/star/uno/genfunc.hxx>
+#include <com/sun/star/uno/Exception.hpp>
 #include "com/sun/star/uno/RuntimeException.hpp"
+#include <o3tl/runtimetooustring.hxx>
 #include <uno/data.h>
 
 #include <bridge.hxx>
@@ -31,8 +33,10 @@
 
 #include "share.hxx"
 
+#include <exception>
 #include <stdio.h>
 #include <string.h>
+#include <typeinfo>
 
 using namespace ::com::sun::star::uno;
 
@@ -307,11 +311,21 @@ static void cpp_call(
 
     try
     {
-        callVirtualMethod(
-            pAdjustedThisPtr, aVtableSlot.index,
-            pCppReturn, pReturnTypeDescr, bRegisterReturn,
-            pStackStart,
-            (pStack - pStackStart), pGPR, pFPR);
+        try {
+            callVirtualMethod(
+                pAdjustedThisPtr, aVtableSlot.index,
+                pCppReturn, pReturnTypeDescr, bRegisterReturn,
+                pStackStart,
+                (pStack - pStackStart), pGPR, pFPR);
+        } catch (css::uno::Exception &) {
+            throw;
+        } catch (std::exception & e) {
+            throw css::uno::RuntimeException(
+                "C++ code threw " + o3tl::runtimeToOUString(typeid(e).name()) + ": "
+                + o3tl::runtimeToOUString(e.what()));
+        } catch (...) {
+            throw css::uno::RuntimeException("C++ code threw unknown exception");
+        }
 
         // NO exception occurred...
         *ppUnoExc = 0;
diff --git a/bridges/source/cpp_uno/gcc3_linux_ia64/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_ia64/uno2cpp.cxx
index ef5a73fe45e1..bf9b06bc2952 100644
--- a/bridges/source/cpp_uno/gcc3_linux_ia64/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_ia64/uno2cpp.cxx
@@ -17,10 +17,16 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
 
+#include <exception>
 #include <malloc.h>
+#include <typeinfo>
 
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
 #include <com/sun/star/uno/genfunc.hxx>
+#include <o3tl/runtimetooustring.hxx>
 #include <uno/data.h>
 
 #include "bridge.hxx"
@@ -486,12 +492,22 @@ static void cpp_call(
 
     try
     {
+        try {
                callVirtualMethod(
                         pAdjustedThisPtr, aVtableSlot.index,
                         pCppReturn, pReturnTypeDescr, bSimpleReturn,
                         pStackStart, ( pStack - pStackStart ),
                         pGPR, nGPR,
                         pFPR, nFPR );
+        } catch (css::uno::Exception &) {
+            throw;
+        } catch (std::exception & e) {
+            throw css::uno::RuntimeException(
+                "C++ code threw " + o3tl::runtimeToOUString(typeid(e).name()) + ": "
+                + o3tl::runtimeToOUString(e.what()));
+        } catch (...) {
+            throw css::uno::RuntimeException("C++ code threw unknown exception");
+        }
         // NO exception occurred...
         *ppUnoExc = 0;
 
diff --git a/bridges/source/cpp_uno/gcc3_linux_intel/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_intel/uno2cpp.cxx
index d9ead282e42a..ff8618cf8171 100644
--- a/bridges/source/cpp_uno/gcc3_linux_intel/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_intel/uno2cpp.cxx
@@ -17,11 +17,17 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <exception>
+#include <typeinfo>
 
 #include <sal/alloca.h>
 
 #include <com/sun/star/uno/genfunc.hxx>
+#include <com/sun/star/uno/Exception.hpp>
 #include <com/sun/star/uno/RuntimeException.hpp>
+#include <o3tl/runtimetooustring.hxx>
 #include <uno/data.h>
 
 #include <bridge.hxx>
@@ -155,10 +161,20 @@ void cpp_call(
     try
     {
         assert( !( (pCppStack - pCppStackStart ) & 3) && "UNALIGNED STACK !!! (Please DO panic)" );
-        CPPU_CURRENT_NAMESPACE::callVirtualMethod(
-            pAdjustedThisPtr, aVtableSlot.index,
-            pCppReturn, pReturnTypeDescr, bSimpleReturn,
-            reinterpret_cast<sal_Int32 *>(pCppStackStart), (pCppStack - pCppStackStart) / sizeof(sal_Int32) );
+        try {
+            CPPU_CURRENT_NAMESPACE::callVirtualMethod(
+                pAdjustedThisPtr, aVtableSlot.index,
+                pCppReturn, pReturnTypeDescr, bSimpleReturn,
+                reinterpret_cast<sal_Int32 *>(pCppStackStart), (pCppStack - pCppStackStart) / sizeof(sal_Int32) );
+        } catch (css::uno::Exception &) {
+            throw;
+        } catch (std::exception & e) {
+            throw css::uno::RuntimeException(
+                "C++ code threw " + o3tl::runtimeToOUString(typeid(e).name()) + ": "
+                + o3tl::runtimeToOUString(e.what()));
+        } catch (...) {
+            throw css::uno::RuntimeException("C++ code threw unknown exception");
+        }
         // NO exception occurred...
         *ppUnoExc = nullptr;
 
diff --git a/bridges/source/cpp_uno/gcc3_linux_m68k/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_m68k/uno2cpp.cxx
index d8da50873fd2..ca3a2477ebc5 100644
--- a/bridges/source/cpp_uno/gcc3_linux_m68k/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_m68k/uno2cpp.cxx
@@ -21,7 +21,9 @@
 #include <rtl/alloc.h>
 
 #include <com/sun/star/uno/genfunc.hxx>
+#include <com/sun/star/uno/Exception.hpp>
 #include "com/sun/star/uno/RuntimeException.hpp"
+#include <o3tl/runtimetooustring.hxx>
 #include <uno/data.h>
 
 #include <bridge.hxx>
@@ -31,8 +33,10 @@
 
 #include "share.hxx"
 
+#include <exception>
 #include <stdio.h>
 #include <string.h>
+#include <typeinfo>
 
 using namespace ::com::sun::star::uno;
 
@@ -285,11 +289,21 @@ static void cpp_call(
 
     try
     {
-        callVirtualMethod(
-            pAdjustedThisPtr, aVtableSlot.index,
-            pCppReturn, pReturnTypeDescr->eTypeClass,
-            pStackStart,
-            (pStack - pStackStart));
+        try {
+            callVirtualMethod(
+                pAdjustedThisPtr, aVtableSlot.index,
+                pCppReturn, pReturnTypeDescr->eTypeClass,
+                pStackStart,
+                (pStack - pStackStart));
+        } catch (css::uno::Exception &) {
+            throw;
+        } catch (std::exception & e) {
+            throw css::uno::RuntimeException(
+                "C++ code threw " + o3tl::runtimeToOUString(typeid(e).name()) + ": "
+                + o3tl::runtimeToOUString(e.what()));
+        } catch (...) {
+            throw css::uno::RuntimeException("C++ code threw unknown exception");
+        }
 
         // NO exception occurred...
         *ppUnoExc = 0;
diff --git a/bridges/source/cpp_uno/gcc3_linux_mips/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_mips/uno2cpp.cxx
index 75a55c4ee030..259775f25708 100644
--- a/bridges/source/cpp_uno/gcc3_linux_mips/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_mips/uno2cpp.cxx
@@ -17,9 +17,16 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <exception>
 #include <malloc.h>
+#include <typeinfo>
 
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
 #include <com/sun/star/uno/genfunc.hxx>
+#include <o3tl/runtimetooustring.hxx>
 #include <uno/data.h>
 
 #include "bridge.hxx"
@@ -389,10 +396,20 @@ namespace
     try
     {
       assert( !( (pCppStack - pCppStackStart ) & 3) && "UNALIGNED STACK !!! (Please DO panic)" );
-      callVirtualMethod(
-          pAdjustedThisPtr, aVtableSlot.index,
-          pCppReturn, pReturnTypeDescr->eTypeClass, pParamType,
-          (sal_Int32 *)pCppStackStart, (pCppStack - pCppStackStart) / sizeof(sal_Int32) );
+      try {
+          callVirtualMethod(
+              pAdjustedThisPtr, aVtableSlot.index,
+              pCppReturn, pReturnTypeDescr->eTypeClass, pParamType,
+              (sal_Int32 *)pCppStackStart, (pCppStack - pCppStackStart) / sizeof(sal_Int32) );
+      } catch (css::uno::Exception &) {
+          throw;
+      } catch (std::exception & e) {
+          throw css::uno::RuntimeException(
+              "C++ code threw " + o3tl::runtimeToOUString(typeid(e).name()) + ": "
+              + o3tl::runtimeToOUString(e.what()));
+      } catch (...) {
+          throw css::uno::RuntimeException("C++ code threw unknown exception");
+      }
       // NO exception occurred...
       *ppUnoExc = 0;
 
diff --git a/bridges/source/cpp_uno/gcc3_linux_mips64/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_mips64/uno2cpp.cxx
index 387b12eacdfe..b65a7819a405 100644
--- a/bridges/source/cpp_uno/gcc3_linux_mips64/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_mips64/uno2cpp.cxx
@@ -17,10 +17,17 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <exception>
 #include <malloc.h>
 #include <cstring>
+#include <typeinfo>
 
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
 #include <com/sun/star/uno/genfunc.hxx>
+#include <o3tl/runtimetooustring.hxx>
 #include <uno/data.h>
 
 #include "bridge.hxx"
@@ -379,11 +386,21 @@ namespace
 
     try
     {
-      callVirtualMethod(
-          pAdjustedThisPtr, aVtableSlot.index,
-          pCppReturn, pReturnTypeRef, bSimpleReturn,
-          pStackStart, ( pStack - pStackStart ),
-          pGPR, pFPR, nREG);
+      try {
+          callVirtualMethod(
+              pAdjustedThisPtr, aVtableSlot.index,
+              pCppReturn, pReturnTypeRef, bSimpleReturn,
+              pStackStart, ( pStack - pStackStart ),
+              pGPR, pFPR, nREG);
+      } catch (css::uno::Exception &) {
+          throw;
+      } catch (std::exception & e) {
+          throw css::uno::RuntimeException(
+              "C++ code threw " + o3tl::runtimeToOUString(typeid(e).name()) + ": "
+              + o3tl::runtimeToOUString(e.what()));
+      } catch (...) {
+          throw css::uno::RuntimeException("C++ code threw unknown exception");
+      }
       // NO exception occurred...
       *ppUnoExc = 0;
 
diff --git a/bridges/source/cpp_uno/gcc3_linux_powerpc/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_powerpc/uno2cpp.cxx
index 6b2ac3dd9ec4..7fdd362906ce 100644
--- a/bridges/source/cpp_uno/gcc3_linux_powerpc/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_powerpc/uno2cpp.cxx
@@ -17,10 +17,16 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
 
+#include <exception>
 #include <malloc.h>
+#include <typeinfo>
 
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
 #include <com/sun/star/uno/genfunc.hxx>
+#include <o3tl/runtimetooustring.hxx>
 #include <uno/data.h>
 
 #include "bridge.hxx"
@@ -480,10 +486,20 @@ static void cpp_call(
     try
     {
         assert( !( (pCppStack - pCppStackStart ) & 3) && "UNALIGNED STACK !!! (Please DO panic)");
-        callVirtualMethod(
-            pAdjustedThisPtr, aVtableSlot.index,
-            pCppReturn, pReturnTypeDescr->eTypeClass, pParamType,
-            (sal_Int32 *)pCppStackStart, (pCppStack - pCppStackStart) / sizeof(sal_Int32) );
+        try {
+            callVirtualMethod(
+                pAdjustedThisPtr, aVtableSlot.index,
+                pCppReturn, pReturnTypeDescr->eTypeClass, pParamType,
+                (sal_Int32 *)pCppStackStart, (pCppStack - pCppStackStart) / sizeof(sal_Int32) );
+        } catch (css::uno::Exception &) {
+            throw;
+        } catch (std::exception & e) {
+            throw css::uno::RuntimeException(
+                "C++ code threw " + o3tl::runtimeToOUString(typeid(e).name()) + ": "
+                + o3tl::runtimeToOUString(e.what()));
+        } catch (...) {
+            throw css::uno::RuntimeException("C++ code threw unknown exception");
+        }
         // NO exception occurred...
         *ppUnoExc = 0;
 
diff --git a/bridges/source/cpp_uno/gcc3_linux_powerpc64/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_powerpc64/uno2cpp.cxx
index a77c4022be66..b58a515121f2 100644
--- a/bridges/source/cpp_uno/gcc3_linux_powerpc64/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_powerpc64/uno2cpp.cxx
@@ -17,10 +17,16 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
 
+#include <exception>
 #include <malloc.h>
+#include <typeinfo>
 
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
 #include <com/sun/star/uno/genfunc.hxx>
+#include <o3tl/runtimetooustring.hxx>
 #include <uno/data.h>
 
 #include "bridge.hxx"
@@ -454,12 +460,22 @@ static void cpp_call(
 
     try
     {
+        try {
                callVirtualMethod(
                         pAdjustedThisPtr, aVtableSlot.index,
                         pCppReturn, pReturnTypeDescr,
                         pStackStart, ( pStack - pStackStart ),
                         pGPR, nGPR,
                         pFPR, nFPR );
+        } catch (css::uno::Exception &) {
+            throw;
+        } catch (std::exception & e) {
+            throw css::uno::RuntimeException(
+                "C++ code threw " + o3tl::runtimeToOUString(typeid(e).name()) + ": "
+                + o3tl::runtimeToOUString(e.what()));
+        } catch (...) {
+            throw css::uno::RuntimeException("C++ code threw unknown exception");
+        }
         // NO exception occurred...
         *ppUnoExc = 0;
 
diff --git a/bridges/source/cpp_uno/gcc3_linux_s390/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_s390/uno2cpp.cxx
index 51e331f5d428..fda52d056ebc 100644
--- a/bridges/source/cpp_uno/gcc3_linux_s390/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_s390/uno2cpp.cxx
@@ -17,10 +17,16 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
 
+#include <exception>
 #include <malloc.h>
+#include <typeinfo>
 
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
 #include <com/sun/star/uno/genfunc.hxx>
+#include <o3tl/runtimetooustring.hxx>
 #include <uno/data.h>
 
 #include "bridge.hxx"
@@ -426,10 +432,20 @@ static void cpp_call(
     try
     {
         assert( !( (pCppStack - pCppStackStart ) & 3) && "UNALIGNED STACK !!! (Please DO panic)" );
-        callVirtualMethod(
-            pAdjustedThisPtr, aVtableSlot.index,
-            pCppReturn, pReturnTypeDescr->eTypeClass, pParamType,
-            (sal_Int32 *)pCppStackStart, (pCppStack - pCppStackStart) / sizeof(sal_Int32) );
+        try {
+            callVirtualMethod(
+                pAdjustedThisPtr, aVtableSlot.index,
+                pCppReturn, pReturnTypeDescr->eTypeClass, pParamType,
+                (sal_Int32 *)pCppStackStart, (pCppStack - pCppStackStart) / sizeof(sal_Int32) );
+        } catch (css::uno::Exception &) {
+            throw;
+        } catch (std::exception & e) {
+            throw css::uno::RuntimeException(
+                "C++ code threw " + o3tl::runtimeToOUString(typeid(e).name()) + ": "
+                + o3tl::runtimeToOUString(e.what()));
+        } catch (...) {
+            throw css::uno::RuntimeException("C++ code threw unknown exception");
+        }
         // NO exception occurred...
         *ppUnoExc = 0;
 
diff --git a/bridges/source/cpp_uno/gcc3_linux_s390x/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_s390x/uno2cpp.cxx
index 8e40d003f03c..e7354a4ba8c5 100644
--- a/bridges/source/cpp_uno/gcc3_linux_s390x/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_s390x/uno2cpp.cxx
@@ -17,10 +17,16 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
 
+#include <exception>
 #include <malloc.h>
+#include <typeinfo>
 
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
 #include <com/sun/star/uno/genfunc.hxx>
+#include <o3tl/runtimetooustring.hxx>
 #include <uno/data.h>
 
 #include "bridge.hxx"
@@ -328,12 +334,22 @@ static void cpp_call(
 
     try
     {
-        callVirtualMethod(
-            pAdjustedThisPtr, aVtableSlot.index,
-            pCppReturn, pReturnTypeDescr,
-            pStackStart, (pStack - pStackStart),
-            pGPR, nGPR,
-            pFPR, nFPR );
+        try {
+            callVirtualMethod(
+                pAdjustedThisPtr, aVtableSlot.index,
+                pCppReturn, pReturnTypeDescr,
+                pStackStart, (pStack - pStackStart),
+                pGPR, nGPR,
+                pFPR, nFPR );
+        } catch (css::uno::Exception &) {
+            throw;
+        } catch (std::exception & e) {
+            throw css::uno::RuntimeException(
+                "C++ code threw " + o3tl::runtimeToOUString(typeid(e).name()) + ": "
+                + o3tl::runtimeToOUString(e.what()));
+        } catch (...) {
+            throw css::uno::RuntimeException("C++ code threw unknown exception");
+        }
         // NO exception occurred...
         *ppUnoExc = 0;
 
diff --git a/bridges/source/cpp_uno/gcc3_linux_sparc/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_sparc/uno2cpp.cxx
index 99d60d17f351..39b625fb35c2 100644
--- a/bridges/source/cpp_uno/gcc3_linux_sparc/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_sparc/uno2cpp.cxx
@@ -17,8 +17,16 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <exception>
 #include <malloc.h>
+#include <typeinfo>
+
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
 #include <com/sun/star/uno/genfunc.hxx>
+#include <o3tl/runtimetooustring.hxx>
 #include <uno/data.h>
 
 #include "bridge.hxx"
@@ -395,13 +403,23 @@ static void cpp_call(
         if( nStackLongs & 1 )
             // stack has to be 8 byte aligned
             nStackLongs++;
-        callVirtualMethod(
-            pAdjustedThisPtr,
-            aVtableSlot.index,
-            pCppReturn,
-            pReturnTypeDescr->eTypeClass,
-            (sal_Int32 *)pCppStackStart,
-             nStackLongs);
+        try {
+            callVirtualMethod(
+                pAdjustedThisPtr,
+                aVtableSlot.index,
+                pCppReturn,
+                pReturnTypeDescr->eTypeClass,
+                (sal_Int32 *)pCppStackStart,
+                 nStackLongs);
+        } catch (css::uno::Exception &) {
+            throw;
+        } catch (std::exception & e) {
+            throw css::uno::RuntimeException(
+                "C++ code threw " + o3tl::runtimeToOUString(typeid(e).name()) + ": "
+                + o3tl::runtimeToOUString(e.what()));
+        } catch (...) {
+            throw css::uno::RuntimeException("C++ code threw unknown exception");
+        }
         // NO exception occurred...
         *ppUnoExc = 0;
 
diff --git a/bridges/source/cpp_uno/gcc3_linux_sparc64/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_sparc64/uno2cpp.cxx
index 939f1b1ee2f3..81012dfdcda3 100644
--- a/bridges/source/cpp_uno/gcc3_linux_sparc64/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_sparc64/uno2cpp.cxx
@@ -17,8 +17,16 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <exception>
 #include <malloc.h>
+#include <typeinfo>
+
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
 #include <com/sun/star/uno/genfunc.hxx>
+#include <o3tl/runtimetooustring.hxx>
 #include <uno/data.h>
 
 #include "bridge.hxx"
@@ -637,15 +645,25 @@ static void cpp_call(
         //    pReturnTypeRef,
         //    pCppStackStart,
         //    (long long)nStackHypers);
-        callVirtualMethod(
-            pAdjustedThisPtr,
-            aVtableSlot.index,
-            pCppReturn,
-            pReturnTypeRef,
-            (sal_Int64 *)pCppStackStart,
-            nStackHypers,
-            pParams,
-            nParams);
+        try {
+            callVirtualMethod(
+                pAdjustedThisPtr,
+                aVtableSlot.index,
+                pCppReturn,
+                pReturnTypeRef,
+                (sal_Int64 *)pCppStackStart,
+                nStackHypers,
+                pParams,
+                nParams);
+        } catch (css::uno::Exception &) {
+            throw;
+        } catch (std::exception & e) {
+            throw css::uno::RuntimeException(
+                "C++ code threw " + o3tl::runtimeToOUString(typeid(e).name()) + ": "
+                + o3tl::runtimeToOUString(e.what()));
+        } catch (...) {
+            throw css::uno::RuntimeException("C++ code threw unknown exception");
+        }
         // NO exception occurred...
         *ppUnoExc = 0;
 
diff --git a/bridges/source/cpp_uno/gcc3_solaris_intel/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_solaris_intel/uno2cpp.cxx
index a94e339d632a..7ad7d1955a44 100644
--- a/bridges/source/cpp_uno/gcc3_solaris_intel/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_solaris_intel/uno2cpp.cxx
@@ -17,12 +17,18 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <exception>
+#include <typeinfo>
 
 #include <malloc.h>
 #include <sal/alloca.h>
 
 #include <com/sun/star/uno/genfunc.hxx>
+#include <com/sun/star/uno/Exception.hpp>
 #include "com/sun/star/uno/RuntimeException.hpp"
+#include <o3tl/runtimetooustring.hxx>
 #include <uno/data.h>
 
 #include "bridge.hxx"
@@ -152,10 +158,20 @@ static void cpp_call(
     try
     {
         assert( !( (pCppStack - pCppStackStart ) & 3) && "UNALIGNED STACK !!! (Please DO panic)");
-        CPPU_CURRENT_NAMESPACE::callVirtualMethod(
-            pAdjustedThisPtr, aVtableSlot.index,
-            pCppReturn, pReturnTypeDescr->eTypeClass,
-            (sal_Int32 *)pCppStackStart, (pCppStack - pCppStackStart) / sizeof(sal_Int32) );
+        try {
+            CPPU_CURRENT_NAMESPACE::callVirtualMethod(
+                pAdjustedThisPtr, aVtableSlot.index,
+                pCppReturn, pReturnTypeDescr->eTypeClass,
+                (sal_Int32 *)pCppStackStart, (pCppStack - pCppStackStart) / sizeof(sal_Int32) );
+        } catch (css::uno::Exception &) {
+            throw;
+        } catch (std::exception & e) {
+            throw css::uno::RuntimeException(
+                "C++ code threw " + o3tl::runtimeToOUString(typeid(e).name()) + ": "
+                + o3tl::runtimeToOUString(e.what()));
+        } catch (...) {
+            throw css::uno::RuntimeException("C++ code threw unknown exception");
+        }
         // NO exception occurred...
         *ppUnoExc = 0;
 
diff --git a/bridges/source/cpp_uno/gcc3_solaris_sparc/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_solaris_sparc/uno2cpp.cxx
index 40932f1f46f8..dbfcc1c66b2b 100644
--- a/bridges/source/cpp_uno/gcc3_solaris_sparc/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_solaris_sparc/uno2cpp.cxx
@@ -17,8 +17,16 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <exception>
 #include <malloc.h>
+#include <typeinfo>
+
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
 #include <com/sun/star/uno/genfunc.hxx>
+#include <o3tl/runtimetooustring.hxx>
 #include <uno/data.h>
 
 #include "bridge.hxx"
@@ -390,13 +398,23 @@ static void cpp_call(
         if( nStackLongs & 1 )
             // stack has to be 8 byte aligned
             nStackLongs++;
-        callVirtualMethod(
-            pAdjustedThisPtr,
-            aVtableSlot.index,
-            pCppReturn,
-            pReturnTypeDescr->eTypeClass,
-            (sal_Int32 *)pCppStackStart,
-             nStackLongs);
+        try {
+            callVirtualMethod(
+                pAdjustedThisPtr,
+                aVtableSlot.index,
+                pCppReturn,
+                pReturnTypeDescr->eTypeClass,
+                (sal_Int32 *)pCppStackStart,
+                 nStackLongs);
+        } catch (css::uno::Exception &) {
+            throw;
+        } catch (std::exception & e) {
+            throw css::uno::RuntimeException(
+                "C++ code threw " + o3tl::runtimeToOUString(typeid(e).name()) + ": "
+                + o3tl::runtimeToOUString(e.what()));
+        } catch (...) {
+            throw css::uno::RuntimeException("C++ code threw unknown exception");
+        }
         // NO exception occurred...
         *ppUnoExc = 0;
 


More information about the Libreoffice-commits mailing list