LCOV - code coverage report
Current view: top level - connectivity/source/inc/java/lang - Object.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 16 0.0 %
Date: 2012-08-25 Functions: 0 16 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : #ifndef _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_
      20                 :            : #define _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_
      21                 :            : 
      22                 :            : #include <cstdarg>
      23                 :            : #include <osl/thread.h>
      24                 :            : #include <com/sun/star/sdbc/SQLException.hpp>
      25                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      26                 :            : #include <osl/diagnose.h>
      27                 :            : #include <jvmaccess/virtualmachine.hxx>
      28                 :            : #include <memory>
      29                 :            : #include <functional>
      30                 :            : #include <boost/shared_ptr.hpp>
      31                 :            : 
      32                 :            : //=====================================================================
      33                 :            : 
      34                 :            : #ifdef HAVE_64BIT_POINTERS
      35                 :            : #error "no 64 bit pointer"
      36                 :            : #endif //HAVE_64BIT_POINTERS
      37                 :            : 
      38                 :            : namespace comphelper
      39                 :            : {
      40                 :            :     class ResourceBasedEventLogger;
      41                 :            : }
      42                 :            : 
      43                 :            : namespace connectivity
      44                 :            : {
      45                 :            :     typedef ::boost::shared_ptr< jvmaccess::VirtualMachine::AttachGuard> TGuard;
      46                 :            :     class SDBThreadAttach
      47                 :            :     {
      48                 :            :         jvmaccess::VirtualMachine::AttachGuard m_aGuard;
      49                 :            :         SDBThreadAttach(SDBThreadAttach&);
      50                 :            :         SDBThreadAttach& operator= (SDBThreadAttach&);
      51                 :            :     public:
      52                 :            :         SDBThreadAttach();
      53                 :            :         ~SDBThreadAttach();
      54                 :            : 
      55                 :            :         JNIEnv* pEnv;
      56                 :            :         static void addRef();
      57                 :            :         static void releaseRef();
      58                 :            : 
      59                 :            :     public:
      60                 :          0 :         JNIEnv& env() const
      61                 :            :         {
      62                 :            :             // according to the documentation of jvmaccess::VirtualMachine::AttachGuard, our env is never
      63                 :            :             // NULL, so why bothering with pointer checks?
      64                 :          0 :             return *pEnv;
      65                 :            :         }
      66                 :            :     };
      67                 :            :     //=====================================================================
      68                 :            :     //=====================================================================
      69                 :            :     class  java_lang_Object
      70                 :            :     {
      71                 :            :         // operator= and the copy ctor are forbidden
      72                 :            :         java_lang_Object& operator= (java_lang_Object&);
      73                 :            :         java_lang_Object(java_lang_Object&);
      74                 :            : 
      75                 :            :         // Only to destroy the C++ pointer of Java objects derived from JSbxObject
      76                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
      77                 :            : 
      78                 :            :     protected:
      79                 :            :         // The Java handle to this class
      80                 :            :         jobject object;
      81                 :            : 
      82                 :            :         // Class definiton
      83                 :            :         // New in SJ2:
      84                 :            :         static jclass theClass; // The class needs to be requested only once!
      85                 :            : 
      86                 :            :         virtual jclass getMyClass() const;
      87                 :            : 
      88                 :            :     public:
      89                 :            :         // Ctor that should be used for the derived classes
      90                 :            :         java_lang_Object( JNIEnv * pEnv, jobject myObj );
      91                 :            : 
      92                 :            :         // The actual ctor
      93                 :            :         java_lang_Object(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory=NULL);
      94                 :            : 
      95                 :            :         virtual ~java_lang_Object();
      96                 :            : 
      97                 :            :         void                saveRef( JNIEnv * pEnv, jobject myObj );
      98                 :          0 :         jobject             getJavaObject() const { return object; }
      99                 :            :         java_lang_Object *  GetWrapper() { return this; }
     100                 :            :         void clearObject(JNIEnv& rEnv);
     101                 :            :         void clearObject();
     102                 :            : 
     103                 :            :         virtual ::rtl::OUString toString() const;
     104                 :          0 :         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() { return m_xFactory; }
     105                 :            : 
     106                 :            :         static void ThrowSQLException(JNIEnv * pEnv,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> & _rContext);
     107                 :            :         static void ThrowLoggedSQLException(
     108                 :            :             const ::comphelper::ResourceBasedEventLogger& _rLogger,
     109                 :            :             JNIEnv* pEnvironment,
     110                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext
     111                 :            :         );
     112                 :            : 
     113                 :            :         static ::rtl::Reference< jvmaccess::VirtualMachine > getVM(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory=NULL);
     114                 :            : 
     115                 :            :         static jclass   findMyClass(const char* _pClassName);
     116                 :            :         void            obtainMethodId(JNIEnv* _pEnv, const char* _pMethodName, const char* _pSignature, jmethodID& _inout_MethodID) const;
     117                 :            : 
     118                 :            :         sal_Bool        callBooleanMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) const;
     119                 :            :         sal_Bool        callBooleanMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const;
     120                 :            :         jobject         callResultSetMethod( JNIEnv& _rEnv, const char* _pMethodName, jmethodID& _inout_MethodID ) const;
     121                 :            :         sal_Int32       callIntMethod( const char* _pMethodName, jmethodID& _inout_MethodID,bool _bIgnoreException = false ) const;
     122                 :            :         sal_Int32       callIntMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const;
     123                 :            :         sal_Int32       callIntMethodWithStringArg( const char* _pMethodName, jmethodID& _inout_MethodID,const ::rtl::OUString& _nArgument ) const;
     124                 :            :         ::rtl::OUString callStringMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) const;
     125                 :            :         ::rtl::OUString callStringMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID , sal_Int32 _nArgument) const;
     126                 :            :         void            callVoidMethod( const char* _pMethodName, jmethodID& _inout_MethodID) const;
     127                 :            :         void            callVoidMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument,bool _bIgnoreException = false ) const;
     128                 :            :         void            callVoidMethodWithBoolArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument,bool _bIgnoreException = false ) const;
     129                 :            :         void            callVoidMethodWithStringArg( const char* _pMethodName, jmethodID& _inout_MethodID, const ::rtl::OUString& _nArgument ) const;
     130                 :            :         jobject         callObjectMethod( JNIEnv * pEnv, const char* _pMethodName, const char* _pSignature, jmethodID& _inout_MethodID ) const;
     131                 :            :         jobject         callObjectMethodWithIntArg( JNIEnv * pEnv, const char* _pMethodName, const char* _pSignature, jmethodID& _inout_MethodID , sal_Int32 _nArgument) const;
     132                 :            : 
     133                 :            :         template< typename T >
     134                 :          0 :                         T callMethodWithIntArg(T (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) ,const char* _pMethodName, const char* _pSignature, jmethodID& _inout_MethodID , sal_Int32 _nArgument) const
     135                 :            :         {
     136                 :          0 :             SDBThreadAttach t;
     137                 :          0 :             obtainMethodId(t.pEnv, _pMethodName,_pSignature, _inout_MethodID);
     138                 :          0 :             T out = (t.pEnv->*pCallMethod)( object, _inout_MethodID,_nArgument);
     139                 :          0 :             ThrowSQLException( t.pEnv, NULL );
     140                 :          0 :             return out;
     141                 :            :         }
     142                 :            : 
     143                 :            :         template< typename T >
     144                 :          0 :                         void callVoidMethod(const char* _pMethodName, const char* _pSignature, jmethodID& _inout_MethodID,sal_Int32 _nArgument, const T& _aValue) const
     145                 :            :         {
     146                 :          0 :             SDBThreadAttach t;
     147                 :          0 :             obtainMethodId(t.pEnv, _pMethodName,_pSignature, _inout_MethodID);
     148                 :          0 :             t.pEnv->CallVoidMethod( object, _inout_MethodID,_nArgument,_aValue);
     149                 :          0 :             ThrowSQLException( t.pEnv, NULL );
     150                 :          0 :         }
     151                 :            : 
     152                 :            : 
     153                 :            :     };
     154                 :            : }
     155                 :            : #endif //_CONNECTIVITY_JAVA_LANG_OBJJECT_HXX_
     156                 :            : 
     157                 :            : 
     158                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10