Tag: cws_src680_dba28 User: fs Date: 05/03/21 04:53:37 Modified: /dba/connectivity/inc/connectivity/ sqlparse.hxx /dba/connectivity/source/commontools/ TIndexes.cxx /dba/connectivity/source/drivers/hsqldb/ HDriver.cxx, HStorageAccess.cxx, HStorageMap.cxx, StorageFileAccess.cxx, StorageNativeInputStream.cxx, StorageNativeOutputStream.cxx /dba/connectivity/source/inc/hsqldb/ HStorageMap.hxx /dba/connectivity/source/parse/ sqlnode.cxx
Log: copying the changes from CWS dba26 herein, since they're needed to fix i45314 File Changes: Directory: /dba/connectivity/inc/connectivity/ ============================================== File [changed]: sqlparse.hxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/inc/connectivity/sqlparse.hxx?r1=1.16&r2=1.16.108.1 Delta lines: +4 -4 ------------------- --- sqlparse.hxx 15 Mar 2004 12:45:34 -0000 1.16 +++ sqlparse.hxx 21 Mar 2005 12:53:30 -0000 1.16.108.1 @@ -2,9 +2,9 @@ * * $RCSfile: sqlparse.hxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.16.108.1 $ * - * last change: $Author: obo $ $Date: 2004/03/15 12:45:34 $ + * last change: $Author: fs $ $Date: 2005/03/21 12:53:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -194,7 +194,7 @@ // convert a string into double trim it to scale of _nscale and than transform it back to string ::rtl::OUString stringToDouble(const ::rtl::OUString& _rValue,sal_Int16 _nScale); - sal_Int16 buildDate(const ::rtl::OUString& _sValue,sal_Int32 _nType,OSQLParseNode*& pAppend,OSQLParseNode* pLiteral,OSQLParseNode*& pCompare); + sal_Int16 buildDate(sal_Int32 _nType,OSQLParseNode*& pAppend,OSQLParseNode* pLiteral,OSQLParseNode*& pCompare); static ::osl::Mutex& getMutex(); Directory: /dba/connectivity/source/commontools/ ================================================ File [changed]: TIndexes.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/commontools/TIndexes.cxx?r1=1.4&r2=1.4.8.1 Delta lines: +24 -7 -------------------- --- TIndexes.cxx 10 Mar 2005 15:17:33 -0000 1.4 +++ TIndexes.cxx 21 Mar 2005 12:53:31 -0000 1.4.8.1 @@ -2,9 +2,9 @@ * * $RCSfile: TIndexes.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.4.8.1 $ * - * last change: $Author: vg $ $Date: 2005/03/10 15:17:33 $ + * last change: $Author: fs $ $Date: 2005/03/21 12:53:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -126,8 +126,8 @@ m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema; m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= aTable; - - Reference< XResultSet > xResult = m_pTable->getMetaData()->getIndexInfo(m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),aSchema,aTable,sal_False,sal_False); + Any aCatalog = m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)); + Reference< XResultSet > xResult = m_pTable->getMetaData()->getIndexInfo(aCatalog,aSchema,aTable,sal_False,sal_False); if ( xResult.is() ) { @@ -137,9 +137,26 @@ sal_Bool bUnique = !xRow->getBoolean(4); if((!aQualifier.getLength() || xRow->getString(5) == aQualifier ) && xRow->getString(6) == aName) { + sal_Int32 nClustered = xRow->getShort(7); + sal_Bool bPrimarKeyIndex = sal_False; + xRow = NULL; + xResult = NULL; + try + { + xResult = m_pTable->getMetaData()->getPrimaryKeys(aCatalog,aSchema,aTable); + xRow.set(xResult,UNO_QUERY); + + if ( xRow.is() && xResult->next() ) // there can be only one primary key + { + bPrimarKeyIndex = xRow->getString(6) == aName; + } + } + catch(Exception) + { + } OIndexHelper* pRet = new OIndexHelper(m_pTable,aName,aQualifier,bUnique, - sal_False, - xRow->getShort(7) == IndexType::CLUSTERED); + bPrimarKeyIndex, + nClustered == IndexType::CLUSTERED); xRet = pRet; break; } Directory: /dba/connectivity/source/drivers/hsqldb/ =================================================== File [changed]: HDriver.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/hsqldb/HDriver.cxx?r1=1.7&r2=1.7.12.1 Delta lines: +6 -4 ------------------- --- HDriver.cxx 10 Mar 2005 15:29:26 -0000 1.7 +++ HDriver.cxx 21 Mar 2005 12:53:32 -0000 1.7.12.1 @@ -2,9 +2,9 @@ * * $RCSfile: HDriver.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.7.12.1 $ * - * last change: $Author: vg $ $Date: 2005/03/10 15:29:26 $ + * last change: $Author: fs $ $Date: 2005/03/21 12:53:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -525,7 +525,9 @@ { Reference< XStatement> xStmt = xConnection->createStatement(); if ( xStmt.is() ) - xStmt->execute(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SET WRITE_DELAY 60"))); + { + xStmt->execute(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SET WRITE_DELAY 2"))); + } } } catch(Exception&) File [changed]: HStorageAccess.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/hsqldb/HStorageAccess.cxx?r1=1.4&r2=1.4.22.1 Delta lines: +95 -123 ---------------------- --- HStorageAccess.cxx 16 Feb 2005 15:51:02 -0000 1.4 +++ HStorageAccess.cxx 21 Mar 2005 12:53:32 -0000 1.4.22.1 @@ -2,9 +2,9 @@ * * $RCSfile: HStorageAccess.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.4.22.1 $ * - * last change: $Author: vg $ $Date: 2005/02/16 15:51:02 $ + * last change: $Author: fs $ $Date: 2005/03/21 12:53:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -177,27 +177,28 @@ OSL_ENSURE(xIn.is(),"Input stream is NULL!"); if ( xIn.is() ) { - sal_Bool bRead = sal_False; - Reference< XSeekable> xSeek = pHelper->getSeek(); - if ( xSeek.is() ) + Sequence< ::sal_Int8 > aData(1); + sal_Int32 nBytesRead = -1; + try { - sal_Int64 nStreamLen = xSeek->getLength(); - sal_Int64 nPos = xSeek->getPosition(); - bRead = (nPos + 1) <= nStreamLen; + nBytesRead = xIn->readBytes(aData,1); } - else - bRead = xIn->available() > 0; - if ( bRead ) + catch(Exception& e) + { + StorageContainer::throwJavaException(e,env); + return -1; + + } + if (nBytesRead <= 0) { - Sequence< ::sal_Int8 > aData(1); - sal_Int32 nBytesRead = xIn->readBytes(aData,1); - if (nBytesRead <= 0) { return (-1); - } else { + } + else + { sal_Int32 tmpInt = aData[0]; - if (tmpInt < 0 ){ + if (tmpInt < 0 ) tmpInt = 256 +tmpInt; - } + #if OSL_DEBUG_LEVEL > 1 ::rtl::OUString sOrgName = StorageContainer::jstring2ustring(env,name); if ( getStreams().find(sOrgName + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".data"))) != getStreams().end() ) @@ -209,7 +210,6 @@ return(tmpInt); } } - } return -1; } // ----------------------------------------------------------------------------- @@ -232,32 +232,24 @@ { ThrowException( env, "java/io/IOException", - "Stream is not valid"); + "len is greater or equal to the buffer size"); return -1; } sal_Int32 nBytesRead = -1; - Reference< XSeekable> xSeek = pHelper->getSeek(); - if ( xSeek.is() ) + + Sequence< ::sal_Int8 > aData(nLen); + try { - sal_Int64 nStreamLen = xSeek->getLength(); - sal_Int64 nPos = xSeek->getPosition(); - nBytesRead = ((nPos + len) <= nStreamLen) ? len : (nStreamLen - nPos); + nBytesRead = xIn->readBytes(aData, len); } - else + catch(Exception& e) { - sal_Int32 av = xIn->available(); - nBytesRead = len <= av ? len : av; + StorageContainer::throwJavaException(e,env); + return -1; } - if ( nBytesRead > 0 ) - { - Sequence< ::sal_Int8 > aData(nBytesRead); - nBytesRead = xIn->readBytes(aData, nBytesRead); - if (nBytesRead <= 0) return -1; - OSL_ENSURE(nLen >= (off + nBytesRead),"Buffer is too small!"); - OSL_ENSURE(aData.getLength() >= nBytesRead,"Buffer is too small!"); env->SetByteArrayRegion(buffer,off,nBytesRead,&aData[0]); #if OSL_DEBUG_LEVEL > 1 @@ -268,9 +260,6 @@ sOrgName += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".input")); fwrite(&aData[0],sizeof(sal_Int8),nBytesRead,getStreams()[sOrgName]); #endif - } - else - return -1; return nBytesRead; } ThrowException( env, @@ -293,25 +282,22 @@ OSL_ENSURE(xIn.is(),"Input stream is NULL!"); if ( xIn.is() ) { - sal_Bool bRead = sal_False; - Reference< XSeekable> xSeek = pHelper->getSeek(); - if ( xSeek.is() ) + Sequence< ::sal_Int8 > aData(4); + sal_Int32 nBytesRead = -1; + try { - sal_Int64 nStreamLen = xSeek->getLength(); - sal_Int64 nPos = xSeek->getPosition(); - bRead = (nPos + 4) <= nStreamLen; + nBytesRead = xIn->readBytes(aData, 4); } - else - bRead = xIn->available() >= 4; - if ( bRead ) + catch(Exception& e) { - Sequence< ::sal_Int8 > aData(4); - sal_Int32 nBytesRead = xIn->readBytes(aData, 4); + StorageContainer::throwJavaException(e,env); + return -1; + } - if (nBytesRead <= 0) { + if ( nBytesRead != 4 ) { ThrowException( env, "java/io/IOException", - "Bytes read < 0"); + "Bytes read != 4"); return -1; } @@ -341,8 +327,6 @@ #endif return nRet; } - return -1; - } ThrowException( env, "java/io/IOException", "No InputStream"); @@ -482,13 +466,7 @@ catch(Exception& e) { OSL_ENSURE(0,"Exception catched! : write [BII)V"); - 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); } } // ----------------------------------------------------------------------------- @@ -535,12 +513,6 @@ catch(Exception& e) { OSL_ENSURE(0,"Exception catched! : writeBytes(aData);"); - 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); } } File [changed]: HStorageMap.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/hsqldb/HStorageMap.cxx?r1=1.4&r2=1.4.22.1 Delta lines: +18 -10 --------------------- --- HStorageMap.cxx 16 Feb 2005 15:51:25 -0000 1.4 +++ HStorageMap.cxx 21 Mar 2005 12:53:33 -0000 1.4.22.1 @@ -2,9 +2,9 @@ * * $RCSfile: HStorageMap.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.4.22.1 $ * - * last change: $Author: vg $ $Date: 2005/02/16 15:51:25 $ + * last change: $Author: fs $ $Date: 2005/03/21 12:53:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -69,6 +69,9 @@ #ifndef _COM_SUN_STAR_EMBED_XTRANSACTEDOBJECT_HPP_ #include <com/sun/star/embed/XTransactedObject.hpp> #endif +#ifndef _COM_SUN_STAR_EMBED_ELEMENTMODES_HPP_ +#include <com/sun/star/embed/ElementModes.hpp> +#endif #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ #include <com/sun/star/lang/DisposedException.hpp> #endif @@ -309,6 +312,9 @@ { try { +/* if ( _nMode == ElementModes::READ ) + _nMode |= ElementModes::SEEKABLE; +*/ pHelper.reset(new StreamHelper(aStoragePair.first.first->openStreamElement(sName,_nMode))); } catch(Exception& ) @@ -321,13 +327,7 @@ catch(Exception& e) { OSL_ENSURE(0,"Exception catched!"); - 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); } } } @@ -360,6 +360,14 @@ return pRet; } // ----------------------------------------------------------------------------- + void StorageContainer::throwJavaException(const Exception& _aException,JNIEnv * env) + { + if (JNI_FALSE != env->ExceptionCheck()) + env->ExceptionClear(); + ::rtl::OString cstr( ::rtl::OUStringToOString(_aException.Message, RTL_TEXTENCODING_JAVA_UTF8 ) ); + OSL_TRACE( __FILE__": forwarding Exception: %s", cstr.getStr() ); + env->ThrowNew(env->FindClass("java/io/IOException"), cstr.getStr()); + } //........................................................................ } // namespace hsqldb //........................................................................ File [changed]: StorageFileAccess.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/hsqldb/StorageFileAccess.cxx?r1=1.3&r2=1.3.22.1 Delta lines: +7 -20 -------------------- --- StorageFileAccess.cxx 16 Feb 2005 15:52:12 -0000 1.3 +++ StorageFileAccess.cxx 21 Mar 2005 12:53:33 -0000 1.3.22.1 @@ -2,9 +2,9 @@ * * $RCSfile: StorageFileAccess.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.3.22.1 $ * - * last change: $Author: vg $ $Date: 2005/02/16 15:52:12 $ + * last change: $Author: fs $ $Date: 2005/03/21 12:53:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -131,9 +131,6 @@ 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()); } } return JNI_FALSE; @@ -157,17 +154,13 @@ } catch(NoSuchElementException&) { + if (JNI_FALSE != env->ExceptionCheck()) + env->ExceptionClear(); } catch(Exception& e) { OSL_ENSURE(0,"Exception catched! : Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_renameElement"); - 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); } } } @@ -194,13 +187,7 @@ catch(Exception& e) { OSL_ENSURE(0,"Exception catched! : Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_renameElement"); - 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); } } } File [changed]: StorageNativeInputStream.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/hsqldb/StorageNativeInputStream.cxx?r1=1.3&r2=1.3.22.1 Delta lines: +39 -41 --------------------- --- StorageNativeInputStream.cxx 16 Feb 2005 15:52:28 -0000 1.3 +++ StorageNativeInputStream.cxx 21 Mar 2005 12:53:33 -0000 1.3.22.1 @@ -2,9 +2,9 @@ * * $RCSfile: StorageNativeInputStream.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.3.22.1 $ * - * last change: $Author: vg $ $Date: 2005/02/16 15:52:28 $ + * last change: $Author: fs $ $Date: 2005/03/21 12:53:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -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 File [changed]: StorageNativeOutputStream.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/hsqldb/StorageNativeOutputStream.cxx?r1=1.3&r2=1.3.22.1 Delta lines: +4 -10 -------------------- --- StorageNativeOutputStream.cxx 16 Feb 2005 15:52:42 -0000 1.3 +++ StorageNativeOutputStream.cxx 21 Mar 2005 12:53:34 -0000 1.3.22.1 @@ -2,9 +2,9 @@ * * $RCSfile: StorageNativeOutputStream.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.3.22.1 $ * - * last change: $Author: vg $ $Date: 2005/02/16 15:52:42 $ + * last change: $Author: fs $ $Date: 2005/03/21 12:53:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -243,13 +243,7 @@ catch(Exception& e) { OSL_ENSURE(0,"Exception catched! : sync();"); - 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); } } } Directory: /dba/connectivity/source/inc/hsqldb/ =============================================== File [changed]: HStorageMap.hxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/inc/hsqldb/HStorageMap.hxx?r1=1.4&r2=1.4.22.1 Delta lines: +3 -2 ------------------- --- HStorageMap.hxx 18 Feb 2005 13:16:52 -0000 1.4 +++ HStorageMap.hxx 21 Mar 2005 12:53:34 -0000 1.4.22.1 @@ -2,9 +2,9 @@ * * $RCSfile: HStorageMap.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.4.22.1 $ * - * last change: $Author: vg $ $Date: 2005/02/18 13:16:52 $ + * last change: $Author: fs $ $Date: 2005/03/21 12:53:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -130,6 +130,7 @@ static ::rtl::OUString jstring2ustring(JNIEnv * env, jstring jstr); static ::rtl::OUString removeURLPrefix(const ::rtl::OUString& _sURL,const ::rtl::OUString& _sFileURL); static ::rtl::OUString removeOldURLPrefix(const ::rtl::OUString& _sURL); + static void throwJavaException(const ::com::sun::star::uno::Exception& _aException,JNIEnv * env); }; //........................................................................ } // namespace hsqldb Directory: /dba/connectivity/source/parse/ ========================================== File [changed]: sqlnode.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/parse/sqlnode.cxx?r1=1.35&r2=1.35.72.1 Delta lines: +57 -83 --------------------- --- sqlnode.cxx 9 Sep 2004 09:04:29 -0000 1.35 +++ sqlnode.cxx 21 Mar 2005 12:53:35 -0000 1.35.72.1 @@ -2,9 +2,9 @@ * * $RCSfile: sqlnode.cxx,v $ * - * $Revision: 1.35 $ + * $Revision: 1.35.72.1 $ * - * last change: $Author: rt $ $Date: 2004/09/09 09:04:29 $ + * last change: $Author: fs $ $Date: 2005/03/21 12:53:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -166,7 +166,7 @@ namespace { - sal_Bool lcl_convertDateFormat(const Reference< XNumberFormatter > & _xFormatter,sal_Int32 _nKey,const ::rtl::OUString& _sValue,double& _nrValue) + sal_Bool lcl_saveConvertToNumber(const Reference< XNumberFormatter > & _xFormatter,sal_Int32 _nKey,const ::rtl::OUString& _sValue,double& _nrValue) { sal_Bool bRet = sal_False; try @@ -638,7 +638,7 @@ case DataType::TIME: case DataType::TIMESTAMP: if (m_xFormatter.is()) - nErg = buildDate(pLiteral->getTokenValue(),nType,pAppend,pLiteral,pCompare); + nErg = buildDate( nType, pAppend, pLiteral, pCompare ); else nErg = buildNode(pAppend,pLiteral,pCompare); @@ -655,57 +655,7 @@ case DataType::TIMESTAMP: nErg = -1; if (m_xFormatter.is()) - { - try - { - // do we have a date - if ( !m_nFormatKey ) - { - Reference< ::com::sun::star::util::XNumberFormatsSupplier > xFormatSup = m_xFormatter->getNumberFormatsSupplier(); - Reference< ::com::sun::star::util::XNumberFormatTypes > xFormatTypes(xFormatSup->getNumberFormats(),UNO_QUERY); - m_nFormatKey = ::dbtools::getDefaultNumberFormat(m_xField,xFormatTypes,*m_pLocale); - } - double fValue = m_xFormatter->convertStringToNumber(m_nFormatKey, pLiteral->getTokenValue().getStr()); - nErg = buildNode_Date(fValue, nType, pAppend,pLiteral,pCompare); - } - catch( Exception& ) - { - Reference< ::com::sun::star::util::XNumberFormatsSupplier > xFormatSup = m_xFormatter->getNumberFormatsSupplier(); - Reference< ::com::sun::star::util::XNumberFormatTypes > xFormatTypes(xFormatSup->getNumberFormats(),UNO_QUERY); - if (xFormatTypes.is()) - { - try - { - - double fValue = m_xFormatter->convertStringToNumber( - xFormatTypes->getStandardFormat(::com::sun::star::util::NumberFormat::DATE, *m_pLocale), - pLiteral->getTokenValue().getStr()); - nErg = buildNode_Date(fValue, nType, pAppend,pLiteral,pCompare); - - } - catch( Exception& ) - { - try - { - double fValue = m_xFormatter->convertStringToNumber( - xFormatTypes->getFormatIndex(::com::sun::star::i18n::NumberFormatIndex::DATE_DIN_YYYYMMDD, *m_pLocale), - pLiteral->getTokenValue()); - nErg = buildNode_Date(fValue, nType, pAppend,pLiteral,pCompare); - } - catch( Exception& ) - { - nErg = -1; - m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_DATE_COMPARE); - } - } - } - else - { - nErg = -1; - m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_DATE_COMPARE); - } - } - } + nErg = buildDate( nType, pAppend, pLiteral, pCompare ); else m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_DATE_COMPARE); break; @@ -1013,8 +963,8 @@ if ( xFormats.is() ) { ::com::sun::star::lang::Locale aLocale; - aLocale.Language = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("en_US")); - aLocale.Country = aLocale.Language; + aLocale.Language = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("en")); + aLocale.Country = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("US")); ::rtl::OUString sFormat(RTL_CONSTASCII_USTRINGPARAM("YYYY-MM-DD")); m_nDateFormatKey = xFormats->queryKey(sFormat,aLocale,sal_False); if ( m_nDateFormatKey == sal_Int32(-1) ) @@ -1165,39 +1115,63 @@ } // ----------------------------------------------------------------------------- -sal_Int16 OSQLParser::buildDate(const ::rtl::OUString& _sValue,sal_Int32 _nType,OSQLParseNode*& pAppend,OSQLParseNode* pLiteral,OSQLParseNode*& pCompare) +sal_Int16 OSQLParser::buildDate(sal_Int32 _nType,OSQLParseNode*& pAppend,OSQLParseNode* pLiteral,OSQLParseNode*& pCompare) { - sal_Int16 nErg = 0; + sal_Int16 nErg = -1; double fValue = 0.0; + ::rtl::OUString sValue = pLiteral->getTokenValue(); - sal_Bool bBuildDate = lcl_convertDateFormat(m_xFormatter,m_nFormatKey,_sValue,fValue); - if ( !bBuildDate ) - { + Reference< XNumberFormatsSupplier > xFormatSup = m_xFormatter->getNumberFormatsSupplier(); + Reference< XNumberFormatTypes > xFormatTypes; + if ( xFormatSup.is() ) + xFormatTypes = xFormatTypes.query( xFormatSup->getNumberFormats() ); + + // if there is no format key, yet, make sure we have a feasible one for our locale try { - Reference< ::com::sun::star::util::XNumberFormatsSupplier > xFormatSup = m_xFormatter->getNumberFormatsSupplier(); - Reference< ::com::sun::star::util::XNumberFormatTypes > xFormatTypes(xFormatSup->getNumberFormats(),UNO_QUERY); - sal_Int32 nStandardFormat = 0; - if ( xFormatTypes.is() ) + if ( !m_nFormatKey && xFormatTypes.is() ) + m_nFormatKey = ::dbtools::getDefaultNumberFormat( m_xField, xFormatTypes, *m_pLocale ); + } + catch( Exception& ) { } + + // try converting the string into a date, according to our format key + sal_Int32 nTryFormat = m_nFormatKey; + bool bSuccess = lcl_saveConvertToNumber( m_xFormatter, nTryFormat, sValue, fValue ); + + // If our format key didn't do, try the default date format for our locale. + if ( !bSuccess && xFormatTypes.is() ) + { + try { - nStandardFormat = xFormatTypes->getStandardFormat(::com::sun::star::util::NumberFormat::DATE, *m_pLocale); - bBuildDate = lcl_convertDateFormat(m_xFormatter,nStandardFormat,_sValue,fValue); + nTryFormat = xFormatTypes->getStandardFormat( NumberFormat::DATE, *m_pLocale ); } + catch( Exception& ) { } + bSuccess = lcl_saveConvertToNumber( m_xFormatter, nTryFormat, sValue, fValue ); } - catch(Exception&) + + // if this also didn't do, try ISO format + if ( !bSuccess && xFormatTypes.is() ) + { + try { + nTryFormat = xFormatTypes->getFormatIndex( NumberFormatIndex::DATE_DIN_YYYYMMDD, *m_pLocale ); } - if ( !bBuildDate ) - bBuildDate = lcl_convertDateFormat(m_xFormatter,m_nDateFormatKey,_sValue,fValue); + catch( Exception& ) { } + bSuccess = lcl_saveConvertToNumber( m_xFormatter, nTryFormat, sValue, fValue ); } - if ( bBuildDate ) - nErg = buildNode_Date(fValue, _nType, pAppend,pLiteral,pCompare); - else + // if this also didn't do, try fallback date format (en-US) + if ( !bSuccess ) { - nErg = -1; - m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_DATE_COMPARE); + nTryFormat = m_nDateFormatKey; + bSuccess = lcl_saveConvertToNumber( m_xFormatter, nTryFormat, sValue, fValue ); } + + if ( bSuccess ) + nErg = buildNode_Date( fValue, _nType, pAppend, pLiteral, pCompare ); + else + m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_DATE_COMPARE); + return nErg; } // ----------------------------------------------------------------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
