2000-10-05 07:50:51 +00:00
|
|
|
|
/*************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* $RCSfile: dbtools.cxx,v $
|
|
|
|
|
*
|
2001-05-11 16:25:49 +00:00
|
|
|
|
* $Revision: 1.24 $
|
2000-10-05 07:50:51 +00:00
|
|
|
|
*
|
2001-05-11 16:25:49 +00:00
|
|
|
|
* last change: $Author: pl $ $Date: 2001-05-11 17:25:49 $
|
2000-10-05 07:50:51 +00:00
|
|
|
|
*
|
|
|
|
|
* The Contents of this file are made available subject to the terms of
|
|
|
|
|
* either of the following licenses
|
|
|
|
|
*
|
|
|
|
|
* - GNU Lesser General Public License Version 2.1
|
|
|
|
|
* - Sun Industry Standards Source License Version 1.1
|
|
|
|
|
*
|
|
|
|
|
* Sun Microsystems Inc., October, 2000
|
|
|
|
|
*
|
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
|
* =============================================
|
|
|
|
|
* Copyright 2000 by Sun Microsystems, Inc.
|
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* Sun Industry Standards Source License Version 1.1
|
|
|
|
|
* =================================================
|
|
|
|
|
* The contents of this file are subject to the Sun Industry Standards
|
|
|
|
|
* Source License Version 1.1 (the "License"); You may not use this file
|
|
|
|
|
* except in compliance with the License. You may obtain a copy of the
|
|
|
|
|
* License at http://www.openoffice.org/license.html.
|
|
|
|
|
*
|
|
|
|
|
* Software provided under this License is provided on an "AS IS" basis,
|
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
|
|
|
|
|
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
|
|
|
|
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
|
|
|
|
* See the License for the specific provisions governing your rights and
|
|
|
|
|
* obligations concerning the Software.
|
|
|
|
|
*
|
|
|
|
|
* The Initial Developer of the Original Code is: Sun Microsystems, Inc..
|
|
|
|
|
*
|
|
|
|
|
* Copyright: 2000 by Sun Microsystems, Inc.
|
|
|
|
|
*
|
|
|
|
|
* All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): _______________________________________
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
#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 _COMPHELPER_PROPERTY_HXX_
|
|
|
|
|
#include <comphelper/property.hxx>
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef _COMPHELPER_DATETIME_HXX_
|
|
|
|
|
#include <comphelper/datetime.hxx>
|
|
|
|
|
#endif
|
2001-04-12 08:49:49 +00:00
|
|
|
|
#ifndef _CONNECTIVITY_CONNCLEANUP_HXX_
|
|
|
|
|
#include <connectivity/conncleanup.hxx>
|
|
|
|
|
#endif
|
2000-10-05 07:50:51 +00:00
|
|
|
|
|
|
|
|
|
#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_
|
|
|
|
|
#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/form/FormComponentType.hpp>
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSER_HPP_
|
|
|
|
|
#include <com/sun/star/sdb/XSQLQueryComposer.hpp>
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_
|
|
|
|
|
#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_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/XQueriesSupplier.hpp>
|
|
|
|
|
#endif
|
2000-10-24 14:00:32 +00:00
|
|
|
|
#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
|
|
|
|
|
#include <com/sun/star/sdbc/XConnection.hpp>
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
|
|
|
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
|
|
|
|
#endif
|
2000-10-05 07:50:51 +00:00
|
|
|
|
#ifndef _OSL_DIAGNOSE_H_
|
|
|
|
|
#include <osl/diagnose.h>
|
|
|
|
|
#endif
|
2000-10-24 14:00:32 +00:00
|
|
|
|
#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_
|
|
|
|
|
#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
|
|
|
|
|
#endif
|
2000-10-27 14:56:00 +00:00
|
|
|
|
#ifndef _COM_SUN_STAR_SDBC_XDRIVERMANAGER_HPP_
|
|
|
|
|
#include <com/sun/star/sdbc/XDriverManager.hpp>
|
|
|
|
|
#endif
|
2000-10-24 14:00:32 +00:00
|
|
|
|
#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
|
|
|
|
|
#include <com/sun/star/sdb/SQLContext.hpp>
|
|
|
|
|
#endif
|
2000-11-10 12:39:59 +00:00
|
|
|
|
#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
|
2000-10-24 14:00:32 +00:00
|
|
|
|
#ifndef _COM_SUN_STAR_SDBC_XROWSET_HPP_
|
|
|
|
|
#include <com/sun/star/sdbc/XRowSet.hpp>
|
|
|
|
|
#endif
|
2000-11-09 07:46:09 +00:00
|
|
|
|
#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
|
|
|
|
|
#include <com/sun/star/sdbc/XRow.hpp>
|
|
|
|
|
#endif
|
2001-03-15 07:47:25 +00:00
|
|
|
|
#ifndef _COMPHELPER_EXTRACT_HXX_
|
|
|
|
|
#include <comphelper/extract.hxx>
|
2000-11-10 12:39:59 +00:00
|
|
|
|
#endif
|
2001-03-19 08:36:07 +00:00
|
|
|
|
#ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_
|
|
|
|
|
#include <com/sun/star/awt/XWindow.hpp>
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef _COM_SUN_STAR_UI_XEXECUTABLEDIALOG_HPP_
|
|
|
|
|
#include <com/sun/star/ui/XExecutableDialog.hpp>
|
|
|
|
|
#endif
|
2000-11-14 12:41:29 +00:00
|
|
|
|
#define CONNECTIVITY_PROPERTY_NAME_SPACE dbtools
|
|
|
|
|
#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_
|
|
|
|
|
#include "propertyids.hxx"
|
|
|
|
|
#endif
|
2000-10-05 07:50:51 +00:00
|
|
|
|
|
|
|
|
|
using namespace ::comphelper;
|
2000-10-27 14:56:00 +00:00
|
|
|
|
using namespace ::com::sun::star::uno;
|
2001-03-19 08:36:07 +00:00
|
|
|
|
using namespace ::com::sun::star::awt;
|
|
|
|
|
using namespace ::com::sun::star::ui;
|
2000-10-27 14:56:00 +00:00
|
|
|
|
using namespace ::com::sun::star::util;
|
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
|
using namespace ::com::sun::star::sdb;
|
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
|
using namespace ::com::sun::star::sdbcx;
|
|
|
|
|
using namespace ::com::sun::star::form;
|
2000-11-14 12:41:29 +00:00
|
|
|
|
using namespace connectivity::dbtools;
|
2000-10-27 14:56:00 +00:00
|
|
|
|
|
2000-10-05 07:50:51 +00:00
|
|
|
|
//.........................................................................
|
|
|
|
|
namespace dbtools
|
|
|
|
|
{
|
|
|
|
|
//.........................................................................
|
|
|
|
|
|
2000-10-30 06:47:10 +00:00
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
|
using namespace ::com::sun::star::util;
|
2000-11-10 12:39:59 +00:00
|
|
|
|
using namespace ::com::sun::star::task;
|
2001-04-12 05:28:34 +00:00
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
|
// using namespace cppu;
|
|
|
|
|
// using namespace osl;
|
|
|
|
|
|
2000-10-05 07:50:51 +00:00
|
|
|
|
//==============================================================================
|
|
|
|
|
//==============================================================================
|
2000-10-27 14:56:00 +00:00
|
|
|
|
sal_Int32 getDefaultNumberFormat(const Reference< XPropertySet >& _xColumn,
|
|
|
|
|
const Reference< XNumberFormatTypes >& _xTypes,
|
|
|
|
|
const Locale& _rLocale)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
2001-02-14 09:31:47 +00:00
|
|
|
|
OSL_ENSURE(_xTypes.is() && _xColumn.is(), "dbtools::getDefaultNumberFormat: invalid arg !");
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (!_xTypes.is() || !_xColumn.is())
|
2000-10-27 14:56:00 +00:00
|
|
|
|
return NumberFormat::UNDEFINED;
|
2000-10-05 07:50:51 +00:00
|
|
|
|
|
|
|
|
|
sal_Int32 nDataType;
|
2001-02-14 09:31:47 +00:00
|
|
|
|
sal_Int32 nScale = 0;
|
2000-10-05 07:50:51 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// determine the datatype of the column
|
|
|
|
|
_xColumn->getPropertyValue(::rtl::OUString::createFromAscii("Type")) >>= nDataType;
|
2001-02-14 09:31:47 +00:00
|
|
|
|
|
|
|
|
|
if (DataType::NUMERIC == nDataType || DataType::DECIMAL == nDataType)
|
|
|
|
|
_xColumn->getPropertyValue(::rtl::OUString::createFromAscii("Scale")) >>= nScale;
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
2001-02-14 09:31:47 +00:00
|
|
|
|
catch (Exception&)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
2000-10-27 14:56:00 +00:00
|
|
|
|
return NumberFormat::UNDEFINED;
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
2001-02-14 09:31:47 +00:00
|
|
|
|
return getDefaultNumberFormat(nDataType,
|
|
|
|
|
nScale,
|
|
|
|
|
::cppu::any2bool(_xColumn->getPropertyValue(::rtl::OUString::createFromAscii("IsCurrency"))),
|
|
|
|
|
_xTypes,
|
|
|
|
|
_rLocale);
|
|
|
|
|
}
|
2000-10-05 07:50:51 +00:00
|
|
|
|
|
2001-02-14 09:31:47 +00:00
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
sal_Int32 getDefaultNumberFormat(sal_Int32 _nDataType,
|
|
|
|
|
sal_Int32 _nScale,
|
|
|
|
|
sal_Bool _bIsCurrency,
|
|
|
|
|
const Reference< XNumberFormatTypes >& _xTypes,
|
|
|
|
|
const Locale& _rLocale)
|
|
|
|
|
{
|
|
|
|
|
OSL_ENSURE(_xTypes.is() , "dbtools::getDefaultNumberFormat: invalid arg !");
|
|
|
|
|
if (!_xTypes.is())
|
|
|
|
|
return NumberFormat::UNDEFINED;
|
|
|
|
|
|
|
|
|
|
sal_Int32 nFormat = 0;
|
|
|
|
|
sal_Int32 nNumberType = _bIsCurrency ? NumberFormat::CURRENCY : NumberFormat::NUMBER;
|
|
|
|
|
switch (_nDataType)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
2000-10-27 14:56:00 +00:00
|
|
|
|
case DataType::BIT:
|
|
|
|
|
nFormat = _xTypes->getStandardFormat(NumberFormat::LOGICAL, _rLocale);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
break;
|
2000-10-27 14:56:00 +00:00
|
|
|
|
case DataType::TINYINT:
|
|
|
|
|
case DataType::SMALLINT:
|
|
|
|
|
case DataType::INTEGER:
|
|
|
|
|
case DataType::BIGINT:
|
|
|
|
|
case DataType::FLOAT:
|
|
|
|
|
case DataType::REAL:
|
|
|
|
|
case DataType::DOUBLE:
|
|
|
|
|
case DataType::NUMERIC:
|
|
|
|
|
case DataType::DECIMAL:
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2001-02-14 09:31:47 +00:00
|
|
|
|
nFormat = _xTypes->getStandardFormat(nNumberType, _rLocale);
|
|
|
|
|
if(_nScale)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
|
|
|
|
// generate a new format if necessary
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XNumberFormats > xFormats(_xTypes, UNO_QUERY);
|
2001-02-14 09:31:47 +00:00
|
|
|
|
::rtl::OUString sNewFormat = xFormats->generateFormat( 0L, _rLocale, sal_False, sal_False, _nScale, sal_True);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
|
|
|
|
|
// and add it to the formatter if necessary
|
|
|
|
|
nFormat = xFormats->queryKey(sNewFormat, _rLocale, sal_False);
|
|
|
|
|
if (nFormat == (sal_Int32)-1)
|
|
|
|
|
nFormat = xFormats->addNew(sNewFormat, _rLocale);
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-02-14 09:31:47 +00:00
|
|
|
|
catch (Exception&)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
2001-02-14 09:31:47 +00:00
|
|
|
|
nFormat = _xTypes->getStandardFormat(nNumberType, _rLocale);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
} break;
|
2000-10-27 14:56:00 +00:00
|
|
|
|
case DataType::CHAR:
|
|
|
|
|
case DataType::VARCHAR:
|
|
|
|
|
case DataType::LONGVARCHAR:
|
|
|
|
|
nFormat = _xTypes->getStandardFormat(NumberFormat::TEXT, _rLocale);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
break;
|
2000-10-27 14:56:00 +00:00
|
|
|
|
case DataType::DATE:
|
|
|
|
|
nFormat = _xTypes->getStandardFormat(NumberFormat::DATE, _rLocale);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
break;
|
2000-10-27 14:56:00 +00:00
|
|
|
|
case DataType::TIME:
|
|
|
|
|
nFormat = _xTypes->getStandardFormat(NumberFormat::TIME, _rLocale);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
break;
|
2000-10-27 14:56:00 +00:00
|
|
|
|
case DataType::TIMESTAMP:
|
|
|
|
|
nFormat = _xTypes->getStandardFormat(NumberFormat::DATETIME, _rLocale);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
break;
|
2000-10-27 14:56:00 +00:00
|
|
|
|
case DataType::BINARY:
|
|
|
|
|
case DataType::VARBINARY:
|
|
|
|
|
case DataType::LONGVARBINARY:
|
|
|
|
|
case DataType::SQLNULL:
|
|
|
|
|
case DataType::OTHER:
|
|
|
|
|
case DataType::OBJECT:
|
|
|
|
|
case DataType::DISTINCT:
|
|
|
|
|
case DataType::STRUCT:
|
|
|
|
|
case DataType::ARRAY:
|
|
|
|
|
case DataType::BLOB:
|
|
|
|
|
case DataType::CLOB:
|
|
|
|
|
case DataType::REF:
|
2000-10-05 07:50:51 +00:00
|
|
|
|
default:
|
2000-10-27 14:56:00 +00:00
|
|
|
|
nFormat = NumberFormat::UNDEFINED;
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
return nFormat;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XConnection> findConnection(const Reference< XInterface >& xParent)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XConnection> xConnection(xParent, UNO_QUERY);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (!xConnection.is())
|
|
|
|
|
{
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XChild> xChild(xParent, UNO_QUERY);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (xChild.is())
|
|
|
|
|
return findConnection(xChild->getParent());
|
|
|
|
|
}
|
|
|
|
|
return xConnection;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XDataSource> getDataSource(
|
2000-10-05 07:50:51 +00:00
|
|
|
|
const ::rtl::OUString& _rsTitleOrPath,
|
2000-10-27 14:56:00 +00:00
|
|
|
|
const Reference< XMultiServiceFactory>& _rxFactory)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
2001-02-14 09:31:47 +00:00
|
|
|
|
OSL_ENSURE(_rsTitleOrPath.getLength(), "::getDataSource : invalid arg !");
|
2000-10-05 07:50:51 +00:00
|
|
|
|
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XDataSource> xReturn;
|
2000-10-05 07:50:51 +00:00
|
|
|
|
|
2000-10-27 14:56:00 +00:00
|
|
|
|
// is it a favorite title ?
|
|
|
|
|
Reference< XNameAccess> xNamingContext(
|
2000-10-05 07:50:51 +00:00
|
|
|
|
_rxFactory->createInstance(
|
2000-10-30 06:47:10 +00:00
|
|
|
|
::rtl::OUString::createFromAscii("com.sun.star.sdb.DatabaseContext")),UNO_QUERY);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
|
|
|
|
|
if (xNamingContext.is() && xNamingContext->hasByName(_rsTitleOrPath))
|
|
|
|
|
{
|
2001-02-14 09:31:47 +00:00
|
|
|
|
OSL_ENSURE(Reference< XNamingService>(xNamingContext, UNO_QUERY).is(), "::getDataSource : no NamingService interface on the DatabaseAccessContext !");
|
2000-10-27 14:56:00 +00:00
|
|
|
|
xReturn = Reference< XDataSource>(
|
|
|
|
|
Reference< XNamingService>(xNamingContext, UNO_QUERY)->getRegisteredObject(_rsTitleOrPath),
|
|
|
|
|
UNO_QUERY);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
return xReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2001-04-12 05:28:34 +00:00
|
|
|
|
Reference< XConnection > getConnection_allowException(
|
2000-10-05 07:50:51 +00:00
|
|
|
|
const ::rtl::OUString& _rsTitleOrPath,
|
|
|
|
|
const ::rtl::OUString& _rsUser,
|
|
|
|
|
const ::rtl::OUString& _rsPwd,
|
2000-10-27 14:56:00 +00:00
|
|
|
|
const Reference< XMultiServiceFactory>& _rxFactory)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
2001-04-12 05:28:34 +00:00
|
|
|
|
Reference< XDataSource> xDataSource( getDataSource(_rsTitleOrPath, _rxFactory) );
|
|
|
|
|
Reference<XConnection> xConnection;
|
|
|
|
|
if (xDataSource.is())
|
2000-11-10 12:39:59 +00:00
|
|
|
|
{
|
2001-04-12 05:28:34 +00:00
|
|
|
|
// do it with interaction handler
|
|
|
|
|
if(!_rsUser.getLength() || !_rsPwd.getLength())
|
2000-11-10 12:39:59 +00:00
|
|
|
|
{
|
2001-04-12 05:28:34 +00:00
|
|
|
|
Reference<XPropertySet> xProp(xDataSource,UNO_QUERY);
|
|
|
|
|
::rtl::OUString sPwd, sUser;
|
|
|
|
|
sal_Bool bPwdReq = sal_False;
|
|
|
|
|
try
|
2000-11-10 12:39:59 +00:00
|
|
|
|
{
|
2001-04-12 05:28:34 +00:00
|
|
|
|
xProp->getPropertyValue(PROPERTY_PASSWORD) >>= sPwd;
|
|
|
|
|
bPwdReq = ::cppu::any2bool(xProp->getPropertyValue(::rtl::OUString::createFromAscii("IsPasswordRequired")));
|
|
|
|
|
xProp->getPropertyValue(::rtl::OUString::createFromAscii("User")) >>= sUser;
|
|
|
|
|
}
|
|
|
|
|
catch(Exception&)
|
|
|
|
|
{
|
|
|
|
|
OSL_ENSURE(sal_False, "dbtools::getConnection: error while retrieving data source properties!");
|
|
|
|
|
}
|
|
|
|
|
if(bPwdReq && !sPwd.getLength())
|
|
|
|
|
{ // password required, but empty -> connect using an interaction handler
|
|
|
|
|
Reference<XCompletedConnection> xConnectionCompletion(xProp, UNO_QUERY);
|
|
|
|
|
if (xConnectionCompletion.is())
|
|
|
|
|
{ // instantiate the default SDB interaction handler
|
|
|
|
|
Reference< XInteractionHandler > xHandler(_rxFactory->createInstance(::rtl::OUString::createFromAscii("com.sun.star.sdb.InteractionHandler")), UNO_QUERY);
|
|
|
|
|
OSL_ENSURE(xHandler.is(), "dbtools::getConnection service com.sun.star.sdb.InteractionHandler not available!");
|
|
|
|
|
if (xHandler.is())
|
|
|
|
|
{
|
|
|
|
|
xConnection = xConnectionCompletion->connectWithCompletion(xHandler);
|
2000-11-10 12:39:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-04-12 05:28:34 +00:00
|
|
|
|
else
|
|
|
|
|
xConnection = xDataSource->getConnection(sUser, sPwd);
|
2000-11-10 12:39:59 +00:00
|
|
|
|
}
|
2001-04-12 05:28:34 +00:00
|
|
|
|
if(!xConnection.is()) // try to get one if not already have one, just to make sure
|
|
|
|
|
xConnection = xDataSource->getConnection(_rsUser, _rsPwd);
|
|
|
|
|
}
|
|
|
|
|
return xConnection;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
Reference< XConnection> getConnection(
|
|
|
|
|
const ::rtl::OUString& _rsTitleOrPath,
|
|
|
|
|
const ::rtl::OUString& _rsUser,
|
|
|
|
|
const ::rtl::OUString& _rsPwd,
|
|
|
|
|
const Reference< XMultiServiceFactory>& _rxFactory)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2001-04-17 12:56:26 +00:00
|
|
|
|
return getConnection_allowException(_rsTitleOrPath, _rsUser, _rsPwd, _rxFactory);
|
2000-11-10 12:39:59 +00:00
|
|
|
|
}
|
|
|
|
|
catch(Exception&)
|
|
|
|
|
{
|
|
|
|
|
}
|
2000-10-05 07:50:51 +00:00
|
|
|
|
|
2001-04-12 05:28:34 +00:00
|
|
|
|
// TODO: if there were not dozens of places which rely on getConnection not throwing an exception ....
|
|
|
|
|
// I would change this ...
|
|
|
|
|
|
2000-10-27 14:56:00 +00:00
|
|
|
|
return Reference< XConnection>();
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XConnection> getConnection(const Reference< XRowSet>& _rxRowSet) throw (RuntimeException)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XConnection> xReturn;
|
|
|
|
|
Reference< XPropertySet> xRowSetProps(_rxRowSet, UNO_QUERY);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (xRowSetProps.is())
|
2000-11-14 12:41:29 +00:00
|
|
|
|
xRowSetProps->getPropertyValue(::rtl::OUString::createFromAscii("ActiveConnection")) >>= xReturn;
|
2000-10-05 07:50:51 +00:00
|
|
|
|
return xReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XConnection> calcConnection(
|
|
|
|
|
const Reference< XRowSet>& _rxRowSet,
|
|
|
|
|
const Reference< XMultiServiceFactory>& _rxFactory)
|
|
|
|
|
throw (SQLException, RuntimeException)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XConnection> xReturn;
|
|
|
|
|
Reference< XPropertySet> xRowSetProps(_rxRowSet, UNO_QUERY);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (xRowSetProps.is())
|
|
|
|
|
{
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Any aConn( xRowSetProps->getPropertyValue(::rtl::OUString::createFromAscii("ActiveConnection")) );
|
2000-11-03 12:30:31 +00:00
|
|
|
|
aConn >>= xReturn;
|
|
|
|
|
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (!xReturn.is())
|
|
|
|
|
{
|
|
|
|
|
// first look if there is a connection in the parent hierarchy
|
|
|
|
|
xReturn = findConnection(_rxRowSet);
|
|
|
|
|
if (!xReturn.is())
|
|
|
|
|
{
|
|
|
|
|
static const ::rtl::OUString s_sUserProp = ::rtl::OUString::createFromAscii("User");
|
|
|
|
|
// the row set didn't supply a connection -> build one with it's current settings
|
|
|
|
|
::rtl::OUString sDataSourceName;
|
|
|
|
|
xRowSetProps->getPropertyValue(::rtl::OUString::createFromAscii("DataSourceName")) >>= sDataSourceName;
|
|
|
|
|
::rtl::OUString sURL;
|
|
|
|
|
xRowSetProps->getPropertyValue(::rtl::OUString::createFromAscii("URL")) >>= sURL;
|
|
|
|
|
if (sDataSourceName.getLength())
|
|
|
|
|
{ // the row set's data source property is set
|
|
|
|
|
// -> try to connect, get user and pwd setting for that
|
|
|
|
|
::rtl::OUString sUser, sPwd;
|
|
|
|
|
|
|
|
|
|
if (hasProperty(s_sUserProp, xRowSetProps))
|
|
|
|
|
xRowSetProps->getPropertyValue(s_sUserProp) >>= sUser;
|
2000-11-14 12:41:29 +00:00
|
|
|
|
if (hasProperty(PROPERTY_PASSWORD, xRowSetProps))
|
|
|
|
|
xRowSetProps->getPropertyValue(PROPERTY_PASSWORD) >>= sPwd;
|
2001-04-12 05:28:34 +00:00
|
|
|
|
xReturn = getConnection_allowException(sDataSourceName, sUser, sPwd, _rxFactory);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
else if (sURL.getLength())
|
|
|
|
|
{ // the row set has no data source, but a connection url set
|
|
|
|
|
// -> try to connection with that url
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XDriverManager > xDriverManager(
|
|
|
|
|
_rxFactory->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.sdbc.DriverManager")), UNO_QUERY);
|
|
|
|
|
if (xDriverManager.is())
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
|
|
|
|
::rtl::OUString sUser, sPwd;
|
|
|
|
|
if (hasProperty(s_sUserProp, xRowSetProps))
|
|
|
|
|
xRowSetProps->getPropertyValue(s_sUserProp) >>= sUser;
|
2000-11-14 12:41:29 +00:00
|
|
|
|
if (hasProperty(PROPERTY_PASSWORD, xRowSetProps))
|
|
|
|
|
xRowSetProps->getPropertyValue(PROPERTY_PASSWORD) >>= sPwd;
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (sUser.getLength())
|
|
|
|
|
{ // use user and pwd together with the url
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Sequence< PropertyValue> aInfo(2);
|
|
|
|
|
aInfo.getArray()[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user"));
|
2000-10-05 07:50:51 +00:00
|
|
|
|
aInfo.getArray()[0].Value <<= sUser;
|
2000-10-27 14:56:00 +00:00
|
|
|
|
aInfo.getArray()[1].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("password"));
|
2000-10-05 07:50:51 +00:00
|
|
|
|
aInfo.getArray()[1].Value <<= sPwd;
|
2000-10-27 14:56:00 +00:00
|
|
|
|
xReturn = xDriverManager->getConnectionWithInfo(sURL, aInfo);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
// just use the url
|
2000-10-27 14:56:00 +00:00
|
|
|
|
xReturn = xDriverManager->getConnection(sURL);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// now if we got a connection, forward it to the row set
|
|
|
|
|
// (The row set will take ownership of that conn and use it for the next execute.
|
|
|
|
|
// If one of the properties affecting the connection (DataSource, URL) is set afterwards,
|
|
|
|
|
// it will free our connection and build a new one with the new parameters on the next execute.
|
|
|
|
|
// At least the service descriptions says so :)
|
|
|
|
|
if (xReturn.is())
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2001-04-12 08:49:49 +00:00
|
|
|
|
OAutoConnectionDisposer* pAutoDispose = new OAutoConnectionDisposer(_rxRowSet, xReturn);
|
|
|
|
|
Reference< XPropertyChangeListener > xEnsureDelete(pAutoDispose);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
2000-11-22 13:27:17 +00:00
|
|
|
|
catch(Exception&)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
2001-02-14 09:31:47 +00:00
|
|
|
|
OSL_ENSURE(0,"EXception when we set the new active connection!");
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return xReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-14 12:41:29 +00:00
|
|
|
|
Reference< XNameAccess> getTableFields(const Reference< XConnection>& _rxConn,const ::rtl::OUString& _rName)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XTablesSupplier> xSupplyTables(_rxConn, UNO_QUERY);
|
2001-02-14 09:31:47 +00:00
|
|
|
|
OSL_ENSURE(xSupplyTables.is(), "::getTableFields : invalid connection !");
|
2000-10-05 07:50:51 +00:00
|
|
|
|
// the conn already said it would support the service sdb::Connection
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XNameAccess> xTables( xSupplyTables->getTables());
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (xTables.is() && xTables->hasByName(_rName))
|
|
|
|
|
{
|
2000-11-14 12:41:29 +00:00
|
|
|
|
Reference< XColumnsSupplier> xTableCols;
|
|
|
|
|
xTables->getByName(_rName) >>= xTableCols;
|
2001-02-14 09:31:47 +00:00
|
|
|
|
OSL_ENSURE(xTableCols.is(), "::getTableFields : invalid table !");
|
2000-10-05 07:50:51 +00:00
|
|
|
|
// the table is expected to support the service sddb::Table, which requires an XColumnsSupplier interface
|
|
|
|
|
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XNameAccess> xFieldNames(xTableCols->getColumns(), UNO_QUERY);
|
2001-02-14 09:31:47 +00:00
|
|
|
|
OSL_ENSURE(xFieldNames.is(), "::getTableFields : TableCols->getColumns doesn't export a NameAccess !");
|
2000-10-05 07:50:51 +00:00
|
|
|
|
return xFieldNames;
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-27 14:56:00 +00:00
|
|
|
|
return Reference< XNameAccess>();
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-10-27 14:56:00 +00:00
|
|
|
|
SQLContext prependContextInfo(SQLException& _rException, const Reference< XInterface >& _rxContext, const ::rtl::OUString& _rContextDescription, const ::rtl::OUString& _rContextDetails)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
|
|
|
|
// determine the type of the exception
|
|
|
|
|
SQLExceptionInfo aInfo(_rException);
|
|
|
|
|
|
|
|
|
|
// the new first chain element
|
2000-10-27 14:56:00 +00:00
|
|
|
|
SQLContext aContextDescription(_rContextDescription, _rxContext, ::rtl::OUString(), 0, aInfo.get(), _rContextDetails);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
return aContextDescription;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
::rtl::OUString quoteName(const ::rtl::OUString& _rQuote, const ::rtl::OUString& _rName)
|
|
|
|
|
{
|
2001-01-30 14:35:56 +00:00
|
|
|
|
if(_rQuote.getLength() && _rQuote.toChar() != ' ')
|
|
|
|
|
return _rQuote + _rName + _rQuote;
|
|
|
|
|
return _rName;
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-10-27 14:56:00 +00:00
|
|
|
|
::rtl::OUString quoteTableName(const Reference< XDatabaseMetaData>& _rxMeta, const ::rtl::OUString& _rName)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
|
|
|
|
::rtl::OUString sQuote = _rxMeta->getIdentifierQuoteString();
|
|
|
|
|
::rtl::OUString sQuotedName;
|
|
|
|
|
::rtl::OUString aTableName(_rName);
|
|
|
|
|
|
|
|
|
|
static ::rtl::OUString s_sEmptyString;
|
|
|
|
|
|
|
|
|
|
sal_Unicode aGenericSep = '.';
|
|
|
|
|
|
|
|
|
|
if (_rxMeta->supportsCatalogsInDataManipulation())
|
|
|
|
|
{
|
|
|
|
|
sal_Unicode aSeparator = aGenericSep;
|
|
|
|
|
::rtl::OUString sCatalogSep = _rxMeta->getCatalogSeparator();
|
|
|
|
|
if (sCatalogSep.getLength())
|
|
|
|
|
aSeparator = sCatalogSep[0];
|
|
|
|
|
|
2001-05-11 16:25:49 +00:00
|
|
|
|
sal_Int32 nIndex = 0;
|
|
|
|
|
::rtl::OUString aFirstToken = aTableName.getToken(0, aSeparator, nIndex);
|
|
|
|
|
if( nIndex != -1 ) // one or more tokens follow
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
2001-05-11 16:25:49 +00:00
|
|
|
|
::rtl::OUString aDatabaseName( aFirstToken );
|
2000-10-05 07:50:51 +00:00
|
|
|
|
sQuotedName += quoteName(sQuote, aDatabaseName);
|
2000-11-08 14:34:01 +00:00
|
|
|
|
sQuotedName = sQuotedName.concat(::rtl::OUString(&aSeparator, 1));
|
2000-11-13 06:13:52 +00:00
|
|
|
|
aTableName = aTableName.replaceAt(0, aDatabaseName.getLength() + 1, s_sEmptyString);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
2001-05-11 16:25:49 +00:00
|
|
|
|
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
if (_rxMeta->supportsSchemasInDataManipulation())
|
|
|
|
|
{
|
2001-05-11 16:25:49 +00:00
|
|
|
|
sal_Int32 nIndex = 0;
|
|
|
|
|
::rtl::OUString aFirstToken( aTableName.getToken( 0, aGenericSep, nIndex ) );
|
|
|
|
|
::rtl::OUString aSecondToken( nIndex != -1 ? aTableName.getToken( 1, aGenericSep, nIndex ) : ::rtl::OUString() );
|
|
|
|
|
if (nIndex == -1 && aSecondToken.getLength())
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
|
|
|
|
static ::rtl::OUString s_aGenericSep(&aGenericSep, 1);
|
2001-05-11 16:25:49 +00:00
|
|
|
|
// need a method on the OUString to cancat a single unicode character ....
|
|
|
|
|
sQuotedName += quoteName(sQuote, aFirstToken);
|
2000-11-08 14:34:01 +00:00
|
|
|
|
sQuotedName = sQuotedName.concat(s_aGenericSep);
|
2001-05-11 16:25:49 +00:00
|
|
|
|
sQuotedName += quoteName(sQuote, aSecondToken);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
sQuotedName += quoteName(sQuote, aTableName);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
sQuotedName += quoteName(sQuote, aTableName);
|
|
|
|
|
|
|
|
|
|
return sQuotedName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-10-27 14:56:00 +00:00
|
|
|
|
void qualifiedNameComponents(const Reference< XDatabaseMetaData >& _rxConnMetaData, const ::rtl::OUString& _rQualifiedName, ::rtl::OUString& _rCatalog, ::rtl::OUString& _rSchema, ::rtl::OUString& _rName)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
2001-02-14 09:31:47 +00:00
|
|
|
|
OSL_ENSURE(_rxConnMetaData.is(), "QualifiedNameComponents : invalid meta data!");
|
2000-10-05 07:50:51 +00:00
|
|
|
|
::rtl::OUString sSeparator = _rxConnMetaData->getCatalogSeparator();
|
|
|
|
|
|
|
|
|
|
::rtl::OUString sName(_rQualifiedName);
|
|
|
|
|
// do we have catalogs ?
|
|
|
|
|
if (_rxConnMetaData->supportsCatalogsInDataManipulation())
|
|
|
|
|
{
|
|
|
|
|
if (_rxConnMetaData->isCatalogAtStart())
|
|
|
|
|
{
|
|
|
|
|
// search for the catalog name at the beginning
|
|
|
|
|
sal_Int32 nIndex = sName.indexOf(sSeparator);
|
|
|
|
|
if (-1 != nIndex)
|
|
|
|
|
{
|
|
|
|
|
_rCatalog = sName.copy(0, nIndex);
|
|
|
|
|
sName = sName.copy(nIndex + 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Katalogname am Ende
|
|
|
|
|
sal_Int32 nIndex = sName.lastIndexOf(sSeparator);
|
|
|
|
|
if (-1 != nIndex)
|
|
|
|
|
{
|
|
|
|
|
_rCatalog = sName.copy(nIndex + 1);
|
|
|
|
|
sName = sName.copy(0, nIndex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_rxConnMetaData->supportsSchemasInDataManipulation())
|
|
|
|
|
{
|
|
|
|
|
sal_Int32 nIndex = sName.indexOf((sal_Unicode)'.');
|
2001-04-27 09:09:14 +00:00
|
|
|
|
// OSL_ENSURE(-1 != nIndex, "QualifiedNameComponents : no schema separator!");
|
2000-10-05 07:50:51 +00:00
|
|
|
|
_rSchema = sName.copy(0, nIndex);
|
|
|
|
|
sName = sName.copy(nIndex + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_rName = sName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XNumberFormatsSupplier> getNumberFormats(
|
|
|
|
|
const Reference< XConnection>& _rxConn,
|
2000-10-05 07:50:51 +00:00
|
|
|
|
sal_Bool _bAlloweDefault,
|
2000-10-27 14:56:00 +00:00
|
|
|
|
const Reference< XMultiServiceFactory>& _rxFactory)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
|
|
|
|
// ask the parent of the connection (should be an DatabaseAccess)
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XNumberFormatsSupplier> xReturn;
|
|
|
|
|
Reference< XChild> xConnAsChild(_rxConn, UNO_QUERY);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
::rtl::OUString sPropFormatsSupplier = ::rtl::OUString::createFromAscii("NumberFormatsSupplier");
|
|
|
|
|
if (xConnAsChild.is())
|
|
|
|
|
{
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XPropertySet> xConnParentProps(xConnAsChild->getParent(), UNO_QUERY);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (xConnParentProps.is() && hasProperty(sPropFormatsSupplier, xConnParentProps))
|
2000-11-09 07:46:09 +00:00
|
|
|
|
xConnParentProps->getPropertyValue(sPropFormatsSupplier) >>= xReturn;
|
|
|
|
|
}
|
|
|
|
|
else if(_bAlloweDefault && _rxFactory.is())
|
|
|
|
|
{
|
|
|
|
|
xReturn = Reference< XNumberFormatsSupplier>(_rxFactory->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatsSupplier")),UNO_QUERY);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
return xReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
void TransferFormComponentProperties(
|
2000-10-27 14:56:00 +00:00
|
|
|
|
const Reference< XPropertySet>& xOldProps,
|
|
|
|
|
const Reference< XPropertySet>& xNewProps,
|
|
|
|
|
const Locale& _rLocale)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
|
|
|
|
// kopieren wir erst mal alle Props, die in Quelle und Ziel vorhanden sind und identische Beschreibungen haben
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XPropertySetInfo> xOldInfo( xOldProps->getPropertySetInfo());
|
|
|
|
|
Reference< XPropertySetInfo> xNewInfo( xNewProps->getPropertySetInfo());
|
2000-10-05 07:50:51 +00:00
|
|
|
|
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Sequence< Property> aOldProperties = xOldInfo->getProperties();
|
|
|
|
|
Sequence< Property> aNewProperties = xNewInfo->getProperties();
|
2000-10-05 07:50:51 +00:00
|
|
|
|
int nNewLen = aNewProperties.getLength();
|
|
|
|
|
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Property* pOldProps = aOldProperties.getArray();
|
|
|
|
|
Property* pNewProps = aNewProperties.getArray();
|
2000-10-05 07:50:51 +00:00
|
|
|
|
|
|
|
|
|
::rtl::OUString sPropDefaultControl(::rtl::OUString::createFromAscii("DefaultControl"));
|
|
|
|
|
::rtl::OUString sPropLabelControl(::rtl::OUString::createFromAscii("LabelControl"));
|
|
|
|
|
::rtl::OUString sPropFormatsSupplier(::rtl::OUString::createFromAscii("FormatsSupplier"));
|
|
|
|
|
::rtl::OUString sPropFormatKey(::rtl::OUString::createFromAscii("FormatKey"));
|
|
|
|
|
::rtl::OUString sPropCurrencySymbol(::rtl::OUString::createFromAscii("CurrencySymbol"));
|
|
|
|
|
::rtl::OUString sPropDecimals(::rtl::OUString::createFromAscii("Decimals"));
|
|
|
|
|
::rtl::OUString sPropEffectiveMin(::rtl::OUString::createFromAscii("EffectiveMin"));
|
|
|
|
|
::rtl::OUString sPropEffectiveMax(::rtl::OUString::createFromAscii("EffectiveMax"));
|
|
|
|
|
::rtl::OUString sPropEffectiveDefault(::rtl::OUString::createFromAscii("EffectiveDefault"));
|
|
|
|
|
::rtl::OUString sPropDefaultValue(::rtl::OUString::createFromAscii("DefaultValue"));
|
|
|
|
|
::rtl::OUString sPropDefaultText(::rtl::OUString::createFromAscii("DefaultText"));
|
|
|
|
|
::rtl::OUString sPropDefaultDate(::rtl::OUString::createFromAscii("DefaultDate"));
|
|
|
|
|
::rtl::OUString sPropDefaultTime(::rtl::OUString::createFromAscii("DefaultTime"));
|
|
|
|
|
::rtl::OUString sPropValueMin(::rtl::OUString::createFromAscii("ValueMin"));
|
|
|
|
|
::rtl::OUString sPropValueMax(::rtl::OUString::createFromAscii("ValueMax"));
|
|
|
|
|
::rtl::OUString sPropDecimalAccuracy(::rtl::OUString::createFromAscii("DecimalAccuracy"));
|
|
|
|
|
::rtl::OUString sPropClassId(::rtl::OUString::createFromAscii("ClassId"));
|
|
|
|
|
|
|
|
|
|
for (sal_Int16 i=0; i<aOldProperties.getLength(); ++i)
|
|
|
|
|
{
|
|
|
|
|
if ( (!pOldProps[i].Name.equals(sPropDefaultControl))
|
|
|
|
|
&& (!pOldProps[i].Name.equals(sPropLabelControl))
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
// binaere Suche
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Property* pResult = (Property*) bsearch(pOldProps + i, (void*)pNewProps, nNewLen, sizeof(Property),
|
2000-10-05 07:50:51 +00:00
|
|
|
|
&PropertyCompare);
|
|
|
|
|
if (pResult && (pResult->Attributes == pOldProps[i].Attributes)
|
2000-10-27 14:56:00 +00:00
|
|
|
|
&& ((pResult->Attributes & PropertyAttribute::READONLY) == 0)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
&& (pResult->Type.equals(pOldProps[i].Type)))
|
|
|
|
|
{ // Attribute stimmen ueberein und Property ist nicht read-only
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
xNewProps->setPropertyValue(pResult->Name, xOldProps->getPropertyValue(pResult->Name));
|
|
|
|
|
}
|
2000-10-27 14:56:00 +00:00
|
|
|
|
catch(IllegalArgumentException& e)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
|
|
|
|
e;
|
|
|
|
|
#ifdef DBG_UTIL
|
|
|
|
|
::rtl::OUString sMessage = ::rtl::OUString::createFromAscii("TransferFormComponentProperties : could not transfer the value for property \"");
|
|
|
|
|
sMessage += pResult->Name;
|
|
|
|
|
sMessage += ::rtl::OUString::createFromAscii("\"");;
|
2001-02-14 09:31:47 +00:00
|
|
|
|
OSL_ENSURE(sal_False, ::rtl::OUStringToOString(sMessage, RTL_TEXTENCODING_ASCII_US));
|
2000-10-05 07:50:51 +00:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// fuer formatierte Felder (entweder alt oder neu) haben wir ein paar Sonderbehandlungen
|
|
|
|
|
sal_Bool bOldIsFormatted = hasProperty(sPropFormatsSupplier, xOldProps) && hasProperty(sPropFormatKey, xOldProps);
|
|
|
|
|
sal_Bool bNewIsFormatted = hasProperty(sPropFormatsSupplier, xNewProps) && hasProperty(sPropFormatKey, xNewProps);
|
|
|
|
|
|
|
|
|
|
if (!bOldIsFormatted && !bNewIsFormatted)
|
|
|
|
|
return; // nothing to do
|
|
|
|
|
|
|
|
|
|
if (bOldIsFormatted && bNewIsFormatted)
|
|
|
|
|
// nein, wenn beide formatierte Felder sind, dann machen wir keinerlei Konvertierungen
|
|
|
|
|
// Das geht zu weit ;)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (bOldIsFormatted)
|
|
|
|
|
{
|
|
|
|
|
// aus dem eingestellten Format ein paar Properties rausziehen und zum neuen Set durchschleifen
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Any aFormatKey( xOldProps->getPropertyValue(sPropFormatKey) );
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (aFormatKey.hasValue())
|
|
|
|
|
{
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XNumberFormatsSupplier> xSupplier;
|
2000-11-14 12:41:29 +00:00
|
|
|
|
xOldProps->getPropertyValue(sPropFormatsSupplier) >>= xSupplier;
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (xSupplier.is())
|
|
|
|
|
{
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XNumberFormats> xFormats(xSupplier->getNumberFormats());
|
|
|
|
|
Reference< XPropertySet> xFormat(xFormats->getByKey(getINT32(aFormatKey)));
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (hasProperty(sPropCurrencySymbol, xFormat))
|
|
|
|
|
{
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Any aVal( xFormat->getPropertyValue(sPropCurrencySymbol) );
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (aVal.hasValue() && hasProperty(sPropCurrencySymbol, xNewProps))
|
|
|
|
|
// (wenn die Quelle das nicht gesetzt hat, dann auch nicht kopieren, um den
|
|
|
|
|
// Default-Wert nicht zu ueberschreiben
|
|
|
|
|
xNewProps->setPropertyValue(sPropCurrencySymbol, aVal);
|
|
|
|
|
}
|
|
|
|
|
if (hasProperty(sPropDecimals, xFormat) && hasProperty(sPropDecimals, xNewProps))
|
|
|
|
|
xNewProps->setPropertyValue(sPropDecimals, xFormat->getPropertyValue(sPropDecimals));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// eine eventuelle-Min-Max-Konvertierung
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Any aEffectiveMin( xOldProps->getPropertyValue(sPropEffectiveMin) );
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (aEffectiveMin.hasValue())
|
|
|
|
|
{ // im Gegensatz zu ValueMin kann EffectiveMin void sein
|
|
|
|
|
if (hasProperty(sPropValueMin, xNewProps))
|
|
|
|
|
{
|
2001-02-14 09:31:47 +00:00
|
|
|
|
OSL_ENSURE(aEffectiveMin.getValueType().getTypeClass() == TypeClass_DOUBLE,
|
2000-10-05 07:50:51 +00:00
|
|
|
|
"TransferFormComponentProperties : invalid property type !");
|
|
|
|
|
xNewProps->setPropertyValue(sPropValueMin, aEffectiveMin);
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Any aEffectiveMax( xOldProps->getPropertyValue(sPropEffectiveMax) );
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (aEffectiveMax.hasValue())
|
|
|
|
|
{ // analog
|
|
|
|
|
if (hasProperty(sPropValueMax, xNewProps))
|
|
|
|
|
{
|
2001-02-14 09:31:47 +00:00
|
|
|
|
OSL_ENSURE(aEffectiveMax.getValueType().getTypeClass() == TypeClass_DOUBLE,
|
2000-10-05 07:50:51 +00:00
|
|
|
|
"TransferFormComponentProperties : invalid property type !");
|
|
|
|
|
xNewProps->setPropertyValue(sPropValueMax, aEffectiveMax);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// dann koennen wir noch Default-Werte konvertieren und uebernehmen
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Any aEffectiveDefault( xOldProps->getPropertyValue(sPropEffectiveDefault) );
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (aEffectiveDefault.hasValue())
|
|
|
|
|
{
|
2000-10-27 14:56:00 +00:00
|
|
|
|
sal_Bool bIsString = aEffectiveDefault.getValueType().getTypeClass() == TypeClass_STRING;
|
2001-02-14 09:31:47 +00:00
|
|
|
|
OSL_ENSURE(bIsString || aEffectiveDefault.getValueType().getTypeClass() == TypeClass_DOUBLE,
|
2000-10-05 07:50:51 +00:00
|
|
|
|
"TransferFormComponentProperties : invalid property type !");
|
|
|
|
|
// die Effective-Properties sollten immer void oder string oder double sein ....
|
|
|
|
|
|
|
|
|
|
if (hasProperty(sPropDefaultDate, xNewProps) && !bIsString)
|
2001-02-16 15:02:06 +00:00
|
|
|
|
{ // (einen ::rtl::OUString in ein Datum zu konvertieren muss nicht immer klappen, denn das ganze kann ja an
|
2000-10-05 07:50:51 +00:00
|
|
|
|
// eine Textspalte gebunden gewesen sein, aber mit einem double koennen wir was anfangen)
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Date aDate = DBTypeConversion::toDate(getDouble(aEffectiveDefault));
|
|
|
|
|
xNewProps->setPropertyValue(sPropDefaultDate, makeAny(aDate));
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hasProperty(sPropDefaultTime, xNewProps) && !bIsString)
|
|
|
|
|
{ // voellig analog mit Zeit
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Time aTime = DBTypeConversion::toTime(getDouble(aEffectiveDefault));
|
|
|
|
|
xNewProps->setPropertyValue(sPropDefaultTime, makeAny(aTime));
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hasProperty(sPropDefaultValue, xNewProps) && !bIsString)
|
|
|
|
|
{ // hier koennen wir einfach das double durchreichen
|
|
|
|
|
xNewProps->setPropertyValue(sPropDefaultValue, aEffectiveDefault);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hasProperty(sPropDefaultText, xNewProps) && bIsString)
|
2001-02-16 15:02:06 +00:00
|
|
|
|
{ // und hier den ::rtl::OUString
|
2000-10-05 07:50:51 +00:00
|
|
|
|
xNewProps->setPropertyValue(sPropDefaultText, aEffectiveDefault);
|
|
|
|
|
}
|
|
|
|
|
|
2001-02-16 15:02:06 +00:00
|
|
|
|
// nyi: die Uebersetzung zwischen doubles und ::rtl::OUString wuerde noch mehr Moeglichkeien eroeffnen
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// die andere Richtung : das neu Control soll formatiert sein
|
|
|
|
|
if (bNewIsFormatted)
|
|
|
|
|
{
|
|
|
|
|
// zuerst die Formatierung
|
|
|
|
|
// einen Supplier koennen wir nicht setzen, also muss das neue Set schon einen mitbringen
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XNumberFormatsSupplier> xSupplier;
|
2000-11-14 12:41:29 +00:00
|
|
|
|
xNewProps->getPropertyValue(sPropFormatsSupplier) >>= xSupplier;
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (xSupplier.is())
|
|
|
|
|
{
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XNumberFormats> xFormats(xSupplier->getNumberFormats());
|
2000-10-05 07:50:51 +00:00
|
|
|
|
|
|
|
|
|
// Sprache des neuen Formats
|
|
|
|
|
// ::rtl::OString sLanguage, sCountry;
|
2001-02-16 15:02:06 +00:00
|
|
|
|
// ConvertLanguageToIsoNames(Application::GetAppInternational().GetLanguage(), ::rtl::OUString(sLanguage.getStr()), ::rtl::OUString(sCountry.getStr()));
|
2000-10-27 14:56:00 +00:00
|
|
|
|
// Locale aNewLanguage(
|
2000-10-05 07:50:51 +00:00
|
|
|
|
// ::rtl::OStringToOUString(sLanguage, RTL_TEXTENCODING_ASCII_US),
|
|
|
|
|
// ::rtl::OStringToOUString(sCountry, RTL_TEXTENCODING_ASCII_US),
|
|
|
|
|
// ::rtl::OUString());
|
|
|
|
|
|
|
|
|
|
// Dezimal-Stellen
|
|
|
|
|
sal_Int16 nDecimals = 2;
|
|
|
|
|
if (hasProperty(sPropDecimalAccuracy, xOldProps))
|
|
|
|
|
xOldProps->getPropertyValue(sPropDecimalAccuracy) >>= nDecimals;
|
|
|
|
|
|
|
|
|
|
// Grund-Format (je nach ClassId des alten Sets)
|
|
|
|
|
sal_Int32 nBaseKey = 0;
|
|
|
|
|
if (hasProperty(sPropClassId, xOldProps))
|
|
|
|
|
{
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XNumberFormatTypes> xTypeList(xFormats, UNO_QUERY);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (xTypeList.is())
|
|
|
|
|
{
|
|
|
|
|
sal_Int16 nClassId;
|
|
|
|
|
xOldProps->getPropertyValue(sPropClassId) >>= nClassId;
|
|
|
|
|
switch (nClassId)
|
|
|
|
|
{
|
2000-10-27 14:56:00 +00:00
|
|
|
|
case FormComponentType::DATEFIELD :
|
|
|
|
|
nBaseKey = xTypeList->getStandardFormat(NumberFormat::DATE, _rLocale);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2000-10-27 14:56:00 +00:00
|
|
|
|
case FormComponentType::TIMEFIELD :
|
|
|
|
|
nBaseKey = xTypeList->getStandardFormat(NumberFormat::TIME, _rLocale);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2000-10-27 14:56:00 +00:00
|
|
|
|
case FormComponentType::CURRENCYFIELD :
|
|
|
|
|
nBaseKey = xTypeList->getStandardFormat(NumberFormat::CURRENCY, _rLocale);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// damit koennen wir ein neues Format basteln ...
|
|
|
|
|
::rtl::OUString sNewFormat = xFormats->generateFormat(nBaseKey, _rLocale, sal_False, sal_False, nDecimals, 0);
|
|
|
|
|
// kein Tausender-Trennzeichen, negative Zahlen nicht in Rot, keine fuehrenden Nullen
|
|
|
|
|
|
|
|
|
|
// ... und zum FormatsSupplier hinzufuegen (wenn noetig)
|
|
|
|
|
sal_Int32 nKey = xFormats->queryKey(sNewFormat, _rLocale, sal_False);
|
|
|
|
|
if (nKey == (sal_Int32)-1)
|
|
|
|
|
{ // noch nicht vorhanden in meinem Formatter ...
|
|
|
|
|
nKey = xFormats->addNew(sNewFormat, _rLocale);
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-27 14:56:00 +00:00
|
|
|
|
xNewProps->setPropertyValue(sPropFormatKey, makeAny((sal_Int32)nKey));
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// min-/max-Werte
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Any aNewMin, aNewMax;
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (hasProperty(sPropValueMin, xOldProps))
|
|
|
|
|
aNewMin = xOldProps->getPropertyValue(sPropValueMin);
|
|
|
|
|
if (hasProperty(sPropValueMax, xOldProps))
|
|
|
|
|
aNewMax = xOldProps->getPropertyValue(sPropValueMax);
|
|
|
|
|
xNewProps->setPropertyValue(sPropEffectiveMin, aNewMin);
|
|
|
|
|
xNewProps->setPropertyValue(sPropEffectiveMax, aNewMax);
|
|
|
|
|
|
|
|
|
|
// Default-Wert
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Any aNewDefault;
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (hasProperty(sPropDefaultDate, xOldProps))
|
|
|
|
|
{
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Any aDate( xOldProps->getPropertyValue(sPropDefaultDate) );
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (aDate.hasValue())
|
2000-10-27 14:56:00 +00:00
|
|
|
|
aNewDefault <<= DBTypeConversion::toDouble(*(Date*)aDate.getValue());
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hasProperty(sPropDefaultTime, xOldProps))
|
|
|
|
|
{
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Any aTime( xOldProps->getPropertyValue(sPropDefaultTime) );
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (aTime.hasValue())
|
2000-10-27 14:56:00 +00:00
|
|
|
|
aNewDefault <<= DBTypeConversion::toDouble(*(Time*)aTime.getValue());
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-02-16 15:02:06 +00:00
|
|
|
|
// double oder ::rtl::OUString werden direkt uebernommen
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (hasProperty(sPropDefaultValue, xOldProps))
|
|
|
|
|
aNewDefault = xOldProps->getPropertyValue(sPropDefaultValue);
|
|
|
|
|
if (hasProperty(sPropDefaultText, xOldProps))
|
|
|
|
|
aNewDefault = xOldProps->getPropertyValue(sPropDefaultText);
|
|
|
|
|
|
|
|
|
|
if (aNewDefault.hasValue())
|
|
|
|
|
xNewProps->setPropertyValue(sPropEffectiveDefault, aNewDefault);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-10-27 14:56:00 +00:00
|
|
|
|
sal_Bool canInsert(const Reference< XPropertySet>& _rxCursorSet)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
2000-10-27 14:56:00 +00:00
|
|
|
|
return ((_rxCursorSet.is() && (getINT32(_rxCursorSet->getPropertyValue(::rtl::OUString::createFromAscii("Privileges"))) & Privilege::INSERT) != 0));
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-10-27 14:56:00 +00:00
|
|
|
|
sal_Bool canUpdate(const Reference< XPropertySet>& _rxCursorSet)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
2000-10-27 14:56:00 +00:00
|
|
|
|
return ((_rxCursorSet.is() && (getINT32(_rxCursorSet->getPropertyValue(::rtl::OUString::createFromAscii("Privileges"))) & Privilege::UPDATE) != 0));
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-10-27 14:56:00 +00:00
|
|
|
|
sal_Bool canDelete(const Reference< XPropertySet>& _rxCursorSet)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
2000-10-27 14:56:00 +00:00
|
|
|
|
return ((_rxCursorSet.is() && (getINT32(_rxCursorSet->getPropertyValue(::rtl::OUString::createFromAscii("Privileges"))) & Privilege::DELETE) != 0));
|
2000-10-05 07:50:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XSQLQueryComposer> getCurrentSettingsComposer(
|
|
|
|
|
const Reference< XPropertySet>& _rxRowSetProps,
|
|
|
|
|
const Reference< XMultiServiceFactory>& _rxFactory)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XSQLQueryComposer> xReturn;
|
|
|
|
|
Reference< XRowSet> xRowSet(_rxRowSetProps, UNO_QUERY);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
2001-04-12 05:28:34 +00:00
|
|
|
|
Reference< XConnection> xConn( calcConnection(xRowSet, _rxFactory));
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (xConn.is()) // implies xRowSet.is() implies _rxRowSetProps.is()
|
|
|
|
|
{
|
|
|
|
|
// build the statement the row set is based on (can't use the ActiveCommand property of the set
|
|
|
|
|
// as this reflects the status after the last execute, not the currently set properties
|
|
|
|
|
|
|
|
|
|
::rtl::OUString sStatement;
|
|
|
|
|
const ::rtl::OUString sPropCommandType = ::rtl::OUString::createFromAscii("CommandType");
|
|
|
|
|
const ::rtl::OUString sPropFilter = ::rtl::OUString::createFromAscii("Filter");
|
|
|
|
|
const ::rtl::OUString sPropOrder = ::rtl::OUString::createFromAscii("Order");
|
|
|
|
|
const ::rtl::OUString sPropApplyFilter = ::rtl::OUString::createFromAscii("ApplyFilter");
|
|
|
|
|
|
|
|
|
|
// first ensure we have all properties needed
|
2000-11-14 12:41:29 +00:00
|
|
|
|
if (hasProperty(PROPERTY_COMMAND, _rxRowSetProps) && hasProperty(sPropCommandType, _rxRowSetProps)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
&& hasProperty(sPropFilter, _rxRowSetProps) && hasProperty(sPropOrder, _rxRowSetProps)
|
2000-11-14 12:41:29 +00:00
|
|
|
|
&& hasProperty(PROPERTY_ESCAPEPROCESSING, _rxRowSetProps) && hasProperty(sPropApplyFilter, _rxRowSetProps))
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
|
|
|
|
sal_Int32 nCommandType = getINT32(_rxRowSetProps->getPropertyValue(sPropCommandType));
|
2000-11-14 12:41:29 +00:00
|
|
|
|
::rtl::OUString sCommand = getString(_rxRowSetProps->getPropertyValue(PROPERTY_COMMAND));
|
|
|
|
|
sal_Bool bEscapeProcessing = getBOOL(_rxRowSetProps->getPropertyValue(PROPERTY_ESCAPEPROCESSING));
|
2000-10-05 07:50:51 +00:00
|
|
|
|
switch (nCommandType)
|
|
|
|
|
{
|
2000-10-27 14:56:00 +00:00
|
|
|
|
case CommandType::COMMAND:
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (!bEscapeProcessing)
|
|
|
|
|
{ // native sql -> no parsable statement
|
|
|
|
|
sStatement = ::rtl::OUString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sStatement = sCommand;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2000-10-27 14:56:00 +00:00
|
|
|
|
case CommandType::TABLE:
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
|
|
|
|
if (!sCommand.getLength())
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
::rtl::OUString sTableName = quoteTableName(xConn->getMetaData(), sCommand);
|
|
|
|
|
sStatement = ::rtl::OUString::createFromAscii("SELECT * FROM ");
|
|
|
|
|
sStatement += sTableName;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2000-10-27 14:56:00 +00:00
|
|
|
|
case CommandType::QUERY:
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
|
|
|
|
// ask the connection for the query
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XQueriesSupplier> xSupplyQueries(xConn, UNO_QUERY);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (!xSupplyQueries.is())
|
|
|
|
|
break;
|
|
|
|
|
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XNameAccess> xQueries(xSupplyQueries->getQueries(), UNO_QUERY);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (!xQueries.is() || !xQueries->hasByName(sCommand))
|
|
|
|
|
break;
|
|
|
|
|
|
2000-11-14 12:41:29 +00:00
|
|
|
|
Reference< XPropertySet> xQueryProps;
|
|
|
|
|
xQueries->getByName(sCommand) >>= xQueryProps;
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (!xQueryProps.is())
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// a native query ?
|
2000-11-14 12:41:29 +00:00
|
|
|
|
if (!hasProperty(PROPERTY_ESCAPEPROCESSING, xQueryProps))
|
2000-10-05 07:50:51 +00:00
|
|
|
|
break;
|
2000-11-14 12:41:29 +00:00
|
|
|
|
if (!getBOOL(xQueryProps->getPropertyValue(PROPERTY_ESCAPEPROCESSING)))
|
2000-10-05 07:50:51 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2000-11-14 12:41:29 +00:00
|
|
|
|
if (!hasProperty(PROPERTY_COMMAND, xQueryProps))
|
2000-10-05 07:50:51 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// the command used by the query
|
2000-11-14 12:41:29 +00:00
|
|
|
|
sStatement = getString(xQueryProps->getPropertyValue(PROPERTY_COMMAND));
|
2001-02-05 09:32:31 +00:00
|
|
|
|
OSL_ENSURE(sStatement.getLength(),"Statement is empty!");
|
2000-10-05 07:50:51 +00:00
|
|
|
|
|
|
|
|
|
// use an additional composer to build a statement from the query filter/order props
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XSQLQueryComposerFactory> xFactory(xConn, UNO_QUERY);
|
|
|
|
|
Reference< XSQLQueryComposer> xLocalComposer;
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (xFactory.is())
|
|
|
|
|
xLocalComposer = xFactory->createQueryComposer();
|
2001-02-05 09:32:31 +00:00
|
|
|
|
if (!xLocalComposer.is() || !sStatement.getLength())
|
2000-10-05 07:50:51 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
xLocalComposer->setQuery(sStatement);
|
|
|
|
|
// the sort order
|
|
|
|
|
if (hasProperty(sPropOrder, xQueryProps))
|
|
|
|
|
xLocalComposer->setOrder(getString(xQueryProps->getPropertyValue(sPropOrder)));
|
|
|
|
|
|
|
|
|
|
sal_Bool bApplyFilter = sal_False;
|
|
|
|
|
if (hasProperty(sPropApplyFilter, xQueryProps))
|
|
|
|
|
bApplyFilter = getBOOL(xQueryProps->getPropertyValue(sPropApplyFilter));
|
|
|
|
|
|
|
|
|
|
if (bApplyFilter)
|
|
|
|
|
{
|
|
|
|
|
if (hasProperty(sPropFilter, xQueryProps))
|
|
|
|
|
xLocalComposer->setFilter(getString(xQueryProps->getPropertyValue(sPropFilter)));
|
|
|
|
|
}
|
|
|
|
|
sStatement = xLocalComposer->getComposedQuery();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2001-02-14 09:31:47 +00:00
|
|
|
|
OSL_ENSURE(sal_False, "::getCurrentSettingsComposer : no table, no query, no statement - what else ?!");
|
2000-10-05 07:50:51 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sStatement.getLength())
|
|
|
|
|
{
|
|
|
|
|
// create an composer
|
2000-10-27 14:56:00 +00:00
|
|
|
|
Reference< XSQLQueryComposerFactory> xFactory(xConn, UNO_QUERY);
|
2000-10-05 07:50:51 +00:00
|
|
|
|
if (xFactory.is())
|
|
|
|
|
xReturn = xFactory->createQueryComposer();
|
|
|
|
|
if (xReturn.is())
|
|
|
|
|
{
|
|
|
|
|
xReturn->setQuery(sStatement);
|
|
|
|
|
// append filter/sort
|
|
|
|
|
xReturn->setOrder(getString(_rxRowSetProps->getPropertyValue(sPropOrder)));
|
|
|
|
|
sal_Bool bApplyFilter = getBOOL(_rxRowSetProps->getPropertyValue(sPropApplyFilter));
|
|
|
|
|
if (bApplyFilter)
|
|
|
|
|
xReturn->setFilter(getString(_rxRowSetProps->getPropertyValue(sPropFilter)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-01-09 12:09:21 +00:00
|
|
|
|
catch(SQLException&)
|
|
|
|
|
{
|
|
|
|
|
xReturn = NULL;
|
|
|
|
|
}
|
2000-11-22 13:27:17 +00:00
|
|
|
|
catch(Exception&)
|
2000-10-05 07:50:51 +00:00
|
|
|
|
{
|
2001-02-14 09:31:47 +00:00
|
|
|
|
OSL_ENSURE(sal_False, "::getCurrentSettingsComposer : catched an exception !");
|
2000-10-05 07:50:51 +00:00
|
|
|
|
xReturn = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return xReturn;
|
|
|
|
|
}
|
2000-10-24 14:00:32 +00:00
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
|
void composeTableName( const Reference< XDatabaseMetaData >& _rxMetaData,
|
|
|
|
|
const ::rtl::OUString& _rCatalog,
|
|
|
|
|
const ::rtl::OUString& _rSchema,
|
|
|
|
|
const ::rtl::OUString& _rName,
|
|
|
|
|
::rtl::OUString& _rComposedName,
|
|
|
|
|
sal_Bool _bQuote)
|
|
|
|
|
{
|
2001-02-14 09:31:47 +00:00
|
|
|
|
OSL_ENSURE(_rxMetaData.is(), "composeTableName : invalid meta data !");
|
|
|
|
|
OSL_ENSURE(_rName.getLength(), "composeTableName : at least the name should be non-empty !");
|
2000-10-24 14:00:32 +00:00
|
|
|
|
|
|
|
|
|
::rtl::OUString sQuoteString = _rxMetaData->getIdentifierQuoteString();
|
2001-01-30 14:35:56 +00:00
|
|
|
|
#define QUOTE(s,s2) if (_bQuote) s += quoteName(sQuoteString,s2); else s += s2
|
2000-10-24 14:00:32 +00:00
|
|
|
|
|
|
|
|
|
static ::rtl::OUString sEmpty;
|
|
|
|
|
static ::rtl::OUString sSeparator = ::rtl::OUString::createFromAscii(".");
|
|
|
|
|
_rComposedName = sEmpty;
|
2001-04-20 12:33:25 +00:00
|
|
|
|
::rtl::OUString sCatalogSep = _rxMetaData->getCatalogSeparator();
|
2000-10-24 14:00:32 +00:00
|
|
|
|
|
2001-04-20 12:33:25 +00:00
|
|
|
|
if (_rCatalog.getLength() && _rxMetaData->isCatalogAtStart() && sCatalogSep.getLength())
|
2000-10-24 14:00:32 +00:00
|
|
|
|
{
|
2001-01-30 14:35:56 +00:00
|
|
|
|
QUOTE(_rComposedName,_rCatalog);
|
2000-10-24 14:00:32 +00:00
|
|
|
|
_rComposedName += _rxMetaData->getCatalogSeparator();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_rSchema.getLength())
|
|
|
|
|
{
|
2001-01-30 14:35:56 +00:00
|
|
|
|
QUOTE(_rComposedName,_rSchema);
|
2000-10-24 14:00:32 +00:00
|
|
|
|
_rComposedName += sSeparator;
|
2001-01-30 14:35:56 +00:00
|
|
|
|
QUOTE(_rComposedName,_rName);
|
2000-10-24 14:00:32 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2001-01-30 14:35:56 +00:00
|
|
|
|
QUOTE(_rComposedName,_rName);
|
2000-10-24 14:00:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-04-20 12:33:25 +00:00
|
|
|
|
if (_rCatalog.getLength() && !_rxMetaData->isCatalogAtStart() && sCatalogSep.getLength())
|
2000-10-24 14:00:32 +00:00
|
|
|
|
{
|
|
|
|
|
_rComposedName += _rxMetaData->getCatalogSeparator();
|
2001-01-30 14:35:56 +00:00
|
|
|
|
QUOTE(_rComposedName,_rCatalog);
|
2000-10-24 14:00:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2000-11-09 07:46:09 +00:00
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
sal_Int32 getSearchColumnFlag( const Reference< XConnection>& _rxConn,sal_Int32 _nDataType)
|
|
|
|
|
{
|
|
|
|
|
sal_Int32 nSearchFlag = 0;
|
|
|
|
|
Reference<XResultSet> xSet = _rxConn->getMetaData()->getTypeInfo();
|
|
|
|
|
if(xSet.is())
|
|
|
|
|
{
|
|
|
|
|
Reference<XRow> xRow(xSet,UNO_QUERY);
|
|
|
|
|
while(xSet->next())
|
|
|
|
|
{
|
|
|
|
|
if(xRow->getInt(2) == _nDataType)
|
|
|
|
|
{
|
|
|
|
|
nSearchFlag = xRow->getInt(9);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return nSearchFlag;
|
|
|
|
|
}
|
2001-02-16 15:02:06 +00:00
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
::rtl::OUString createUniqueName(const Reference<XNameAccess>& _rxContainer,const ::rtl::OUString& _rBaseName)
|
|
|
|
|
{
|
|
|
|
|
::rtl::OUString sName(_rBaseName);
|
|
|
|
|
sal_Int32 nPos = 1;
|
|
|
|
|
sName += ::rtl::OUString::valueOf(nPos);
|
|
|
|
|
|
|
|
|
|
while(_rxContainer->hasByName(sName))
|
|
|
|
|
{
|
|
|
|
|
sName = _rBaseName;
|
|
|
|
|
sName += ::rtl::OUString::valueOf(++nPos);
|
|
|
|
|
}
|
|
|
|
|
return sName;
|
|
|
|
|
}
|
|
|
|
|
sal_Bool isCharOk(char c,const ::rtl::OUString& _rSpecials);
|
|
|
|
|
#include <ctype.h> //isdigit
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
sal_Bool isValidSQLName(const ::rtl::OUString& rName,const ::rtl::OUString& _rSpecials)
|
|
|
|
|
{
|
|
|
|
|
// <20>berpr<70>fung auf korrekte Namensgebung im SQL Sinne
|
|
|
|
|
// Dieses ist wichtig f<>r Tabellennamen beispielsweise
|
|
|
|
|
::rtl::OString aName(rName,rName.getLength(),RTL_TEXTENCODING_ASCII_US);
|
|
|
|
|
const char* pStr = aName.getStr();
|
|
|
|
|
if (isdigit(*pStr))
|
|
|
|
|
return sal_False;
|
|
|
|
|
|
|
|
|
|
for (; *pStr; ++pStr )
|
|
|
|
|
if(!isCharOk(*pStr,_rSpecials))
|
|
|
|
|
return sal_False;
|
|
|
|
|
|
|
|
|
|
if ( rName.getLength()
|
|
|
|
|
&& ( (rName.toChar() == '_')
|
|
|
|
|
|| ( (rName.toChar() >= '0')
|
|
|
|
|
&& (rName.toChar() <= '9')
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
return sal_False;
|
|
|
|
|
// the SQL-Standard requires the first character to be an alphabetic character, which
|
|
|
|
|
// isn't easy to decide in UniCode ...
|
|
|
|
|
// So we just prohibit the characters which already lead to problems ....
|
|
|
|
|
// 11.04.00 - 74902 - FS
|
|
|
|
|
|
|
|
|
|
return sal_True;
|
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
sal_Bool isCharOk(char c,const ::rtl::OUString& _rSpecials)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if ( ((c >= 97) && (c <= 122)) || ((c >= 65) && (c <= 90)) || ((c >= 48) && (c <= 57)) ||
|
|
|
|
|
c == '_' || _rSpecials.indexOf(c) != -1)
|
|
|
|
|
return sal_True;
|
|
|
|
|
else
|
|
|
|
|
return sal_False;
|
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
// Erzeugt einen neuen Namen falls noetig
|
|
|
|
|
::rtl::OUString convertName2SQLName(const ::rtl::OUString& rName,const ::rtl::OUString& _rSpecials)
|
|
|
|
|
{
|
|
|
|
|
if(isValidSQLName(rName,_rSpecials))
|
|
|
|
|
return rName;
|
|
|
|
|
::rtl::OUString aNewName(rName);
|
|
|
|
|
const sal_Unicode* pStr = rName.getStr();
|
|
|
|
|
sal_Bool bValid(!isdigit(*pStr));
|
|
|
|
|
for (; bValid && *pStr; pStr++ )
|
|
|
|
|
if(!isCharOk(*pStr,_rSpecials))
|
|
|
|
|
aNewName.replace(*pStr,'_');
|
|
|
|
|
|
|
|
|
|
return aNewName;
|
|
|
|
|
}
|
2000-10-05 07:50:51 +00:00
|
|
|
|
|
2001-03-19 08:36:07 +00:00
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
void showError(const SQLExceptionInfo& _rInfo,
|
|
|
|
|
const Reference< XWindow>& _xParent,
|
|
|
|
|
const Reference< XMultiServiceFactory >& _xFactory)
|
|
|
|
|
{
|
|
|
|
|
if (_rInfo.isValid())
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Sequence< Any > aArgs(2);
|
|
|
|
|
aArgs[0] <<= PropertyValue(::rtl::OUString::createFromAscii("SQLException"), 0, _rInfo.get(), PropertyState_DIRECT_VALUE);
|
|
|
|
|
aArgs[1] <<= PropertyValue(::rtl::OUString::createFromAscii("ParentWindow"), 0, makeAny(_xParent), PropertyState_DIRECT_VALUE);
|
|
|
|
|
|
|
|
|
|
static ::rtl::OUString s_sDialogServiceName = ::rtl::OUString::createFromAscii("com.sun.star.sdb.ErrorMessageDialog");
|
|
|
|
|
Reference< XExecutableDialog > xErrorDialog(
|
|
|
|
|
_xFactory->createInstanceWithArguments(s_sDialogServiceName, aArgs), UNO_QUERY);
|
|
|
|
|
if (xErrorDialog.is())
|
|
|
|
|
xErrorDialog->execute();
|
|
|
|
|
}
|
|
|
|
|
catch(Exception&)
|
|
|
|
|
{
|
|
|
|
|
OSL_ENSURE(0,"showError: could not display the error message!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-11-10 12:39:59 +00:00
|
|
|
|
|
2000-10-05 07:50:51 +00:00
|
|
|
|
//.........................................................................
|
|
|
|
|
} // namespace dbtools
|
|
|
|
|
//.........................................................................
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|
* history:
|
|
|
|
|
* $Log: not supported by cvs2svn $
|
2001-05-11 16:25:49 +00:00
|
|
|
|
* Revision 1.23 2001/04/27 10:09:14 oj
|
|
|
|
|
* comment out the OSL_ESNURE in QualifiedNameComponents
|
|
|
|
|
*
|
2001-04-27 09:09:14 +00:00
|
|
|
|
* Revision 1.22 2001/04/20 13:33:25 oj
|
|
|
|
|
* #85736# if catalogseparator is empty don't append catalog
|
|
|
|
|
*
|
2001-04-20 12:33:25 +00:00
|
|
|
|
* Revision 1.21 2001/04/17 13:56:26 fs
|
|
|
|
|
* corrected getConnection
|
|
|
|
|
*
|
2001-04-17 12:56:26 +00:00
|
|
|
|
* Revision 1.20 2001/04/12 09:49:49 fs
|
|
|
|
|
* #84852# calcConnection: use a OAutoConnectionDisposer when setting the rowsets connection
|
|
|
|
|
*
|
2001-04-12 08:49:49 +00:00
|
|
|
|
* Revision 1.19 2001/04/12 06:28:34 fs
|
|
|
|
|
* #84694# allow calcConnection to throw an SQLexception when using getConnection
|
|
|
|
|
*
|
2001-04-12 05:28:34 +00:00
|
|
|
|
* Revision 1.18 2001/03/19 09:35:26 oj
|
|
|
|
|
* new dir for unotypes
|
|
|
|
|
*
|
2001-03-19 08:36:07 +00:00
|
|
|
|
* Revision 1.17 2001/03/15 08:45:56 fs
|
|
|
|
|
* cppuhelper/extract -> comphelper/extract
|
|
|
|
|
*
|
2001-03-15 07:47:25 +00:00
|
|
|
|
* Revision 1.16 2001/02/16 16:01:29 oj
|
|
|
|
|
* some new functions
|
|
|
|
|
*
|
2001-02-16 15:02:06 +00:00
|
|
|
|
* Revision 1.15 2001/02/14 10:31:47 oj
|
|
|
|
|
* neew method
|
|
|
|
|
*
|
2001-02-14 09:31:47 +00:00
|
|
|
|
* Revision 1.14 2001/02/05 10:32:31 oj
|
|
|
|
|
* check statement length
|
|
|
|
|
*
|
2001-02-05 09:32:31 +00:00
|
|
|
|
* Revision 1.13 2001/01/30 15:35:56 oj
|
|
|
|
|
* check if qoute char is space
|
|
|
|
|
*
|
2001-01-30 14:35:56 +00:00
|
|
|
|
* Revision 1.12 2001/01/09 13:09:21 oj
|
|
|
|
|
* catch SQLException separated
|
|
|
|
|
*
|
2001-01-09 12:09:21 +00:00
|
|
|
|
* Revision 1.11 2000/11/22 14:27:17 oj
|
|
|
|
|
* dispose old connection when new is set
|
|
|
|
|
*
|
2000-11-22 13:27:17 +00:00
|
|
|
|
* Revision 1.10 2000/11/14 13:41:29 oj
|
|
|
|
|
* use of statis strings
|
|
|
|
|
*
|
2000-11-14 12:41:29 +00:00
|
|
|
|
* Revision 1.9 2000/11/13 07:13:52 oj
|
|
|
|
|
* wrong use of replaceAt
|
|
|
|
|
*
|
2000-11-13 06:13:52 +00:00
|
|
|
|
* Revision 1.8 2000/11/10 13:39:59 oj
|
|
|
|
|
* #80159# use of XInteractionHandler when no user nor password is given
|
|
|
|
|
*
|
2000-11-10 12:39:59 +00:00
|
|
|
|
* Revision 1.7 2000/11/09 08:46:09 oj
|
|
|
|
|
* some new methods for db's
|
|
|
|
|
*
|
2000-11-09 07:46:09 +00:00
|
|
|
|
* Revision 1.6 2000/11/08 15:34:01 fs
|
|
|
|
|
* composeTableName corrected
|
|
|
|
|
*
|
2000-11-08 14:34:01 +00:00
|
|
|
|
* Revision 1.5 2000/11/03 13:30:31 oj
|
|
|
|
|
* use stream for any
|
|
|
|
|
*
|
2000-11-03 12:30:31 +00:00
|
|
|
|
* Revision 1.4 2000/10/30 07:46:12 oj
|
|
|
|
|
* descriptors inserted
|
|
|
|
|
*
|
2000-10-30 06:47:10 +00:00
|
|
|
|
* Revision 1.3 2000/10/27 15:56:00 fs
|
|
|
|
|
* modified some implementations, so that they work with the new sdb interfaces (DatabaseContext instead of DatabaseAccessContext, no DatabaseEnvironment anymore, ....)
|
|
|
|
|
*
|
2000-10-27 14:56:00 +00:00
|
|
|
|
* Revision 1.2 2000/10/24 15:00:32 oj
|
|
|
|
|
* make strings unique for lib's
|
|
|
|
|
*
|
2000-10-24 14:00:32 +00:00
|
|
|
|
* Revision 1.1 2000/10/05 08:50:51 fs
|
|
|
|
|
* moved the files from unotools to here
|
|
|
|
|
*
|
2000-10-05 07:50:51 +00:00
|
|
|
|
* Revision 1.0 29.09.00 08:16:59 fs
|
|
|
|
|
************************************************************************/
|
|
|
|
|
|