User: ihi Date: 2007-11-21 14:59:16+0000 Modified: dba/connectivity/source/commontools/dbtools.cxx
Log: INTEGRATION: CWS dba24c (1.68.34); FILE MERGED 2007/10/25 08:41:04 fs 1.68.34.1: #i81658# +getBooleanComparisonPredicated File Changes: Directory: /dba/connectivity/source/commontools/ ================================================ File [changed]: dbtools.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/commontools/dbtools.cxx?r1=1.69&r2=1.70 Delta lines: +88 -146 ---------------------- --- dbtools.cxx 2007-11-20 19:14:55+0000 1.69 +++ dbtools.cxx 2007-11-21 14:59:13+0000 1.70 @@ -36,164 +36,61 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_connectivity.hxx" -#ifndef _DBHELPER_DBEXCEPTION_HXX_ -#include <connectivity/dbexception.hxx> -#endif -#ifndef _CONNECTIVITY_DBTOOLS_HXX_ -#include <connectivity/dbtools.hxx> -#endif -#ifndef _DBHELPER_DBCONVERSION_HXX_ -#include <connectivity/dbconversion.hxx> -#endif -#ifndef CONNECTIVITY_STATEMENTCOMPOSER_HXX -#include <connectivity/statementcomposer.hxx> -#endif -#ifndef CONNECTIVITY_DIAGNOSE_EX_H +#include "connectivity/CommonTools.hxx" #include "diagnose_ex.h" -#endif - -#ifndef _COMPHELPER_PROPERTY_HXX_ -#include <comphelper/property.hxx> -#endif -#ifndef _CONNECTIVITY_CONNCLEANUP_HXX_ -#include <connectivity/conncleanup.hxx> -#endif +#include "TConnection.hxx" -#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_ -#include <com/sun/star/io/XInputStream.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XROWUPDATE_HPP_ -#include <com/sun/star/sdbc/XRowUpdate.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ -#include <com/sun/star/container/XChild.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_ -#include <com/sun/star/sdbc/XDataSource.hpp> -#endif -#ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_ -#include <com/sun/star/uno/XNamingService.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ -#include <com/sun/star/sdbcx/XTablesSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ -#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_ -#include <com/sun/star/sdbcx/Privilege.hpp> -#endif -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +/** === begin UNO includes === **/ +#include <com/sun/star/awt/XWindow.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> -#endif -#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTYPES_HPP_ -#include <com/sun/star/util/XNumberFormatTypes.hpp> -#endif -#ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_ -#include <com/sun/star/util/NumberFormat.hpp> -#endif -#ifndef _COM_SUN_STAR_FORM_FORMCOMPONENTTYPE_HPP_ +#include <com/sun/star/container/XChild.hpp> #include <com/sun/star/form/FormComponentType.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_ -#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XOFFICEDATABASEDOCUMENT_HPP_ -#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/sdb/BooleanComparisonMode.hpp> #include <com/sun/star/sdb/CommandType.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ -#include <com/sun/star/sdbc/DataType.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_ +#include <com/sun/star/sdb/ParametersRequest.hpp> +#include <com/sun/star/sdb/RowSetVetoException.hpp> +#include <com/sun/star/sdb/SQLContext.hpp> +#include <com/sun/star/sdb/XCompletedConnection.hpp> +#include <com/sun/star/sdb/XInteractionSupplyParameters.hpp> +#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp> +#include <com/sun/star/sdb/XParametersSupplier.hpp> #include <com/sun/star/sdb/XQueriesSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ +#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> +#include <com/sun/star/sdbc/DataType.hpp> #include <com/sun/star/sdbc/XConnection.hpp> -#endif -#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#endif -#ifndef _OSL_DIAGNOSE_H_ -#include <osl/diagnose.h> -#endif -#ifndef TOOLS_DIAGNOSE_EX_H -#include <tools/diagnose_ex.h> -#endif -#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_ -#include <com/sun/star/util/XNumberFormatsSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XDRIVERMANAGER_HPP_ +#include <com/sun/star/sdbc/XDataSource.hpp> #include <com/sun/star/sdbc/XDriverManager.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_ -#include <com/sun/star/sdb/SQLContext.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XCOMPLETEDCONNECTION_HPP_ -#include <com/sun/star/sdb/XCompletedConnection.hpp> -#endif -#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_ -#include <com/sun/star/task/XInteractionHandler.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XROWSET_HPP_ -#include <com/sun/star/sdbc/XRowSet.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XParameters.hpp> #include <com/sun/star/sdbc/XRow.hpp> -#endif -#ifndef _COMPHELPER_EXTRACT_HXX_ -#include <comphelper/extract.hxx> -#endif -#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_ -#include <com/sun/star/awt/XWindow.hpp> -#endif -#ifndef _COM_SUN_STAR_UI_DIALOGS_XEXECUTABLEDIALOG_HPP_ +#include <com/sun/star/sdbc/XRowSet.hpp> +#include <com/sun/star/sdbc/XRowUpdate.hpp> +#include <com/sun/star/sdbcx/Privilege.hpp> +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#include <com/sun/star/task/XInteractionHandler.hpp> +#include <com/sun/star/task/XInteractionRequest.hpp> #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> -#endif -#ifndef CONNECTIVITY_CONNECTION_HXX -#include "TConnection.hxx" -#endif -#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ -#include "connectivity/CommonTools.hxx" -#endif -#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ -#include <com/sun/star/lang/DisposedException.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XPARAMETERSSUPPLIER_HPP_ -#include <com/sun/star/sdb/XParametersSupplier.hpp> -#endif -#ifndef _COMPHELPER_INTERACTION_HXX_ -#include <comphelper/interaction.hxx> -#endif -#ifndef _COM_SUN_STAR_SDB_PARAMETERSREQUEST_HPP_ -#include <com/sun/star/sdb/ParametersRequest.hpp> -#endif -#ifndef _COMPHELPER_INTERACTION_HXX_ +#include <com/sun/star/uno/XNamingService.hpp> +#include <com/sun/star/util/NumberFormat.hpp> +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> +#include <com/sun/star/util/XNumberFormatTypes.hpp> +/** === end UNO includes === **/ + +#include <comphelper/extract.hxx> #include <comphelper/interaction.hxx> -#endif -#ifndef _COMPHELPER_PROPERTY_HXX_ #include <comphelper/property.hxx> -#endif -#ifndef _COM_SUN_STAR_TASK_XINTERACTIONREQUEST_HPP_ -#include <com/sun/star/task/XInteractionRequest.hpp> -#endif -#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_ -#include <com/sun/star/task/XInteractionHandler.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XINTERACTIONSUPPLYPARAMETERS_HPP_ -#include <com/sun/star/sdb/XInteractionSupplyParameters.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_ROWSETVETOEXCEPTION_HPP_ -#include <com/sun/star/sdb/RowSetVetoException.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XPARAMETERS_HPP_ -#include <com/sun/star/sdbc/XParameters.hpp> -#endif -#ifndef CONNECTIVITY_DIAGNOSE_EX_H -#include "diagnose_ex.h" -#endif +#include <connectivity/conncleanup.hxx> +#include <connectivity/dbconversion.hxx> +#include <connectivity/dbexception.hxx> +#include <connectivity/dbtools.hxx> +#include <connectivity/statementcomposer.hxx> +#include <osl/diagnose.h> +#include <rtl/ustrbuf.hxx> +#include <tools/diagnose_ex.h> + #include <algorithm> using namespace ::comphelper; @@ -1984,6 +1881,51 @@ } } } + +// -------------------------------------------------------------------- +void getBoleanComparisonPredicate( const ::rtl::OUString& _rExpression, const sal_Bool _bValue, const sal_Int32 _nBooleanComparisonMode, + ::rtl::OUStringBuffer& _out_rSQLPredicate ) +{ + switch ( _nBooleanComparisonMode ) + { + case BooleanComparisonMode::IS_LITERAL: + _out_rSQLPredicate.append( _rExpression ); + if ( _bValue ) + _out_rSQLPredicate.appendAscii( " IS TRUE" ); + else + _out_rSQLPredicate.appendAscii( " IS FALSE" ); + break; + + case BooleanComparisonMode::EQUAL_LITERAL: + _out_rSQLPredicate.append( _rExpression ); + _out_rSQLPredicate.appendAscii( _bValue ? " = TRUE" : " = FALSE" ); + break; + + case BooleanComparisonMode::ACCESS_COMPAT: + if ( _bValue ) + { + _out_rSQLPredicate.appendAscii( " NOT ( ( " ); + _out_rSQLPredicate.append( _rExpression ); + _out_rSQLPredicate.appendAscii( " = 0 ) OR ( " ); + _out_rSQLPredicate.append( _rExpression ); + _out_rSQLPredicate.appendAscii( " IS NULL ) )" ); + } + else + { + _out_rSQLPredicate.append( _rExpression ); + _out_rSQLPredicate.appendAscii( " = 0" ); + } + break; + + case BooleanComparisonMode::EQUAL_INTEGER: + // fall through + default: + _out_rSQLPredicate.append( _rExpression ); + _out_rSQLPredicate.appendAscii( _bValue ? " = 1" : " = 0" ); + break; + } +} + //......................................................................... } // namespace dbtools //......................................................................... --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
