User: vg      
Date: 05/03/23 01:41:41

Modified:
 /dba/connectivity/source/drivers/hsqldb/
  StorageNativeInputStream.cxx

Log:
 INTEGRATION: CWS dba26 (1.3.14); FILE MERGED
 2005/03/15 15:05:03 fs 1.3.14.1: #i44582# (patch provided by OJ) refined 
storage handling

File Changes:

Directory: /dba/connectivity/source/drivers/hsqldb/
===================================================

File [changed]: StorageNativeInputStream.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/hsqldb/StorageNativeInputStream.cxx?r1=1.3&r2=1.4
Delta lines:  +36 -38
---------------------
--- StorageNativeInputStream.cxx        16 Feb 2005 15:52:28 -0000      1.3
+++ StorageNativeInputStream.cxx        23 Mar 2005 09:41:37 -0000      1.4
@@ -181,6 +181,11 @@
 JNIEXPORT jlong JNICALL 
Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_skip
   (JNIEnv * env, jobject obj_this,jstring key, jstring name, jlong n)
 {
+    if ( n < 0 )
+        ThrowException(        env,
+                                               "java/io/IOException",
+                                               "n < 0");
+
        ::boost::shared_ptr<StreamHelper> pHelper = 
StorageContainer::getRegisteredStream(env,name,key);
        OSL_ENSURE(pHelper.get(),"No stream helper!");
        if ( pHelper.get() )
@@ -190,9 +195,12 @@
                {
                        try 
                        {
-                               sal_Int32 avail = xIn->available();
+                sal_Int64 nBytesSkipped = 0;
                                sal_Int64 tmpLongVal = n;
                                sal_Int32 tmpIntVal;
+
+                try
+                {
                                do {
                                        if (tmpLongVal >= 
::std::numeric_limits<sal_Int64>::max() ) 
                                                tmpIntVal = 
::std::numeric_limits<sal_Int32>::max();
@@ -202,24 +210,19 @@
                                        tmpLongVal -= tmpIntVal;
                 
                                        xIn->skipBytes(tmpIntVal);
-                               } while (tmpLongVal > 0);
 
-                               if ( avail != 0 && avail < n) {
-                                       return(avail);
-                               } else {
-                                       return(n);
+                                   } while (tmpLongVal > 0);
                                }
+                catch(Exception& e )
+                {
+                }
+
+                return n - tmpLongVal;
                        }
                        catch(Exception& e)
                        {
                                OSL_ENSURE(0,"Exception catched! : skip();");
-                               if (JNI_FALSE != env->ExceptionCheck())
-                                       env->ExceptionClear();
-                               ::rtl::OString cstr( 
::rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_JAVA_UTF8 ) );
-                               OSL_TRACE( __FILE__": forwarding Exception: 
%s", cstr.getStr() );
-                               ThrowException( env,
-                                                               
"java/io/IOException",
-                                                               cstr.getStr());
+                StorageContainer::throwJavaException(e,env);
                        }
                }
        }
@@ -253,13 +256,7 @@
                catch(Exception& e)
                {
                        OSL_ENSURE(0,"Exception catched! : available();");
-                       if (JNI_FALSE != env->ExceptionCheck())
-                               env->ExceptionClear();
-                       ::rtl::OString cstr( 
::rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_JAVA_UTF8 ) );
-                       OSL_TRACE( __FILE__": forwarding Exception: %s", 
cstr.getStr() );
-                       ThrowException( env,
-                                                       "java/io/IOException",
-                                                       cstr.getStr());
+                       StorageContainer::throwJavaException(e,env);
                }
        }
        else
@@ -289,14 +286,15 @@
                jsize nLen = env->GetArrayLength(buffer);
                Sequence< ::sal_Int8 > aData(nLen);
                
-               sal_Int32 av = xIn->available();
-               if ( av > 0 )
+        try
         {
-            if (nLen > av)
-                           nBytesRead = xIn->readBytes(aData, av);
-                   else
                            nBytesRead = xIn->readBytes(aData,nLen);
         }
+        catch(Exception& e)
+               {
+                       OSL_ENSURE(0,"Exception catched! : skip();");
+            StorageContainer::throwJavaException(e,env);
+               }
            
                // Casting bytesRead to an int is okay, since the user can
                // only pass in an integer length to read, so the bytesRead 




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to