LCOV - code coverage report
Current view: top level - connectivity/source/drivers/hsqldb - StorageNativeOutputStream.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 22 30 73.3 %
Date: 2014-11-03 Functions: 5 7 71.4 %
Legend: Lines: hit not hit

          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             : 
      20             : #if defined(HAVE_CONFIG_H) && HAVE_CONFIG_H
      21             : #include <config.h>
      22             : #endif
      23             : 
      24             : #include <uno/mapping.hxx>
      25             : #include <uno/environment.hxx>
      26             : #include <cppuhelper/bootstrap.hxx>
      27             : #include <cppuhelper/compbase1.hxx>
      28             : #include <cppuhelper/component_context.hxx>
      29             : #include "accesslog.hxx"
      30             : #include <com/sun/star/embed/XTransactedObject.hpp>
      31             : #include <comphelper/processfactory.hxx>
      32             : #include <com/sun/star/io/XStream.hpp>
      33             : #include <com/sun/star/container/XNameAccess.hpp>
      34             : #include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
      35             : #include <com/sun/star/embed/XStorage.hpp>
      36             : #include <com/sun/star/embed/ElementModes.hpp>
      37             : #include <comphelper/types.hxx>
      38             : #include "hsqldb/HStorageAccess.hxx"
      39             : #include "hsqldb/HStorageMap.hxx"
      40             : 
      41             : #include <jvmaccess/virtualmachine.hxx>
      42             : #include <com/sun/star/lang/XSingleComponentFactory.hpp>
      43             : #include "diagnose_ex.h"
      44             : 
      45             : using namespace ::com::sun::star::container;
      46             : using namespace ::com::sun::star::uno;
      47             : using namespace ::com::sun::star::document;
      48             : using namespace ::com::sun::star::embed;
      49             : using namespace ::com::sun::star::io;
      50             : using namespace ::com::sun::star::lang;
      51             : using namespace ::connectivity::hsqldb;
      52             : 
      53             : 
      54             : /*
      55             :  * Class:     com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
      56             :  * Method:    openStream
      57             :  * Signature: (Ljava/lang/String;Ljava/lang/String;I)V
      58             :  */
      59          20 : extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_openStream
      60             :   (JNIEnv * env, jobject /*obj_this*/, jstring name, jstring key, jint mode)
      61             : {
      62             : #ifdef HSQLDB_DBG
      63             :     {
      64             :         OperationLogFile( env, name, "output" ).logOperation( "openStream" );
      65             :         LogFile( env, name, "output" ).create();
      66             :     }
      67             : #endif
      68          20 :     StorageContainer::registerStream(env,name,key,mode);
      69          20 : }
      70             : /*
      71             :  * Class:     com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
      72             :  * Method:    write
      73             :  * Signature: (Ljava/lang/String;Ljava/lang/String;[BII)V
      74             :  */
      75          20 : extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2_3BII
      76             :   (JNIEnv * env, jobject obj_this, jstring key, jstring name, jbyteArray buffer, jint off, jint len)
      77             : {
      78             : #ifdef HSQLDB_DBG
      79             :     OperationLogFile( env, name, "output" ).logOperation( "write( byte[], int, int )" );
      80             : 
      81             :     DataLogFile aDataLog( env, name, "output" );
      82             :     write_to_storage_stream_from_buffer( env, obj_this, name, key, buffer, off, len, &aDataLog );
      83             : #else
      84          20 :     write_to_storage_stream_from_buffer( env, obj_this, name, key, buffer, off, len );
      85             : #endif
      86          20 : }
      87             : 
      88             : /*
      89             :  * Class:     com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
      90             :  * Method:    write
      91             :  * Signature: (Ljava/lang/String;Ljava/lang/String;[B)V
      92             :  */
      93           0 : extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2_3B
      94             :   (JNIEnv * env, jobject obj_this, jstring key, jstring name, jbyteArray buffer)
      95             : {
      96             : #ifdef HSQLDB_DBG
      97             :     OperationLogFile( env, name, "output" ).logOperation( "write( byte[] )" );
      98             : 
      99             :     DataLogFile aDataLog( env, name, "output" );
     100             :     write_to_storage_stream_from_buffer( env, obj_this, name, key, buffer, 0, env->GetArrayLength( buffer ), &aDataLog );
     101             : #else
     102           0 :     write_to_storage_stream_from_buffer( env, obj_this, name, key, buffer, 0, env->GetArrayLength( buffer ) );
     103             : #endif
     104           0 : }
     105             : 
     106             : /*
     107             :  * Class:     com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
     108             :  * Method:    close
     109             :  * Signature: (Ljava/lang/String;Ljava/lang/String;)V
     110             :  */
     111          16 : extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_close
     112             :   (JNIEnv * env, jobject /*obj_this*/, jstring key, jstring name)
     113             : {
     114             : #ifdef HSQLDB_DBG
     115             :     OperationLogFile aOpLog( env, name, "output" );
     116             :     aOpLog.logOperation( "close" );
     117             : 
     118             :     LogFile aDataLog( env, name, "output" );
     119             : #endif
     120             : 
     121          16 :     ::boost::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key);
     122          32 :     Reference< XOutputStream> xFlush = pHelper.get() ? pHelper->getOutputStream() : Reference< XOutputStream>();
     123          16 :     if ( xFlush.is() )
     124             :         try
     125             :         {
     126          16 :             xFlush->flush();
     127             :         }
     128           0 :         catch(Exception&)
     129             :         {}
     130             : 
     131             : #ifdef HSQLDB_DBG
     132             :     aDataLog.close();
     133             :     aOpLog.close();
     134             : #endif
     135          32 :     StorageContainer::revokeStream(env,name,key);
     136          16 : }
     137             : 
     138             : /*
     139             :  * Class:     com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
     140             :  * Method:    write
     141             :  * Signature: (Ljava/lang/String;Ljava/lang/String;I)V
     142             :  */
     143           0 : extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2I
     144             :   (JNIEnv * env, jobject obj_this, jstring key, jstring name,jint b)
     145             : {
     146             : #ifdef HSQLDB_DBG
     147             :     OperationLogFile( env, name, "output" ).logOperation( "write( int )" );
     148             : 
     149             :     DataLogFile aDataLog( env, name, "output" );
     150             :     write_to_storage_stream( env, obj_this, name, key, b, &aDataLog );
     151             : #else
     152           0 :     write_to_storage_stream( env, obj_this, name, key, b );
     153             : #endif
     154           0 : }
     155             : 
     156             : /*
     157             :  * Class:     com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
     158             :  * Method:    flush
     159             :  * Signature: (Ljava/lang/String;Ljava/lang/String;)V
     160             :  */
     161          28 : extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_flush
     162             :   (JNIEnv * env, jobject /*obj_this*/, jstring key, jstring name)
     163             : {
     164             :     OSL_UNUSED( env );
     165             :     OSL_UNUSED( key );
     166             :     OSL_UNUSED( name );
     167             : #ifdef HSQLDB_DBG
     168             :     OperationLogFile( env, name, "output" ).logOperation( "flush" );
     169             : 
     170             :     OUString sKey = StorageContainer::jstring2ustring(env,key);
     171             :     OUString sName = StorageContainer::jstring2ustring(env,name);
     172             : #endif
     173          28 : }
     174             : 
     175             : /*
     176             :  * Class:     com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
     177             :  * Method:    sync
     178             :  * Signature: (Ljava/lang/String;Ljava/lang/String;)V
     179             :  */
     180          14 : extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_sync
     181             :   (JNIEnv * env, jobject /*obj_this*/, jstring key, jstring name)
     182             : {
     183             : #ifdef HSQLDB_DBG
     184             :     OperationLogFile( env, name, "output" ).logOperation( "sync" );
     185             : #endif
     186          14 :     ::boost::shared_ptr< StreamHelper > pStream = StorageContainer::getRegisteredStream( env, name, key );
     187          28 :     Reference< XOutputStream > xFlush = pStream.get() ? pStream->getOutputStream() : Reference< XOutputStream>();
     188             :     OSL_ENSURE( xFlush.is(), "StorageNativeOutputStream::sync: could not retrieve an output stream!" );
     189          14 :     if ( xFlush.is() )
     190             :     {
     191             :         try
     192             :         {
     193          14 :             xFlush->flush();
     194             :         }
     195           0 :         catch(Exception&)
     196             :         {
     197             :             OSL_FAIL( "StorageNativeOutputStream::sync: could not flush output stream!" );
     198             :         }
     199          14 :     }
     200          14 : }
     201             : 
     202             : 
     203             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10