summaryrefslogtreecommitdiff
path: root/dbaccess/source/sdbtools
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/sdbtools')
-rw-r--r--dbaccess/source/sdbtools/connection/connectiondependent.hxx156
-rw-r--r--dbaccess/source/sdbtools/connection/connectiontools.cxx197
-rw-r--r--dbaccess/source/sdbtools/connection/connectiontools.hxx125
-rw-r--r--dbaccess/source/sdbtools/connection/datasourcemetadata.cxx93
-rw-r--r--dbaccess/source/sdbtools/connection/datasourcemetadata.hxx97
-rw-r--r--dbaccess/source/sdbtools/connection/makefile.mk49
-rw-r--r--dbaccess/source/sdbtools/connection/objectnames.cxx498
-rw-r--r--dbaccess/source/sdbtools/connection/objectnames.hxx98
-rw-r--r--dbaccess/source/sdbtools/connection/tablename.cxx275
-rw-r--r--dbaccess/source/sdbtools/connection/tablename.hxx109
-rw-r--r--dbaccess/source/sdbtools/inc/module_sdbt.hxx47
-rw-r--r--dbaccess/source/sdbtools/inc/sdbt_resource.hrc48
-rw-r--r--dbaccess/source/sdbtools/misc/makefile.mk47
-rw-r--r--dbaccess/source/sdbtools/misc/module_sdbt.cxx45
-rw-r--r--dbaccess/source/sdbtools/misc/sdbt_services.cxx107
-rw-r--r--dbaccess/source/sdbtools/resource/makefile.mk45
-rw-r--r--dbaccess/source/sdbtools/resource/sdbt_strings.src65
17 files changed, 2101 insertions, 0 deletions
diff --git a/dbaccess/source/sdbtools/connection/connectiondependent.hxx b/dbaccess/source/sdbtools/connection/connectiondependent.hxx
new file mode 100644
index 000000000000..52a418105985
--- /dev/null
+++ b/dbaccess/source/sdbtools/connection/connectiondependent.hxx
@@ -0,0 +1,156 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef DBACCESS_CONNECTION_DEPENDENT_HXX
+#define DBACCESS_CONNECTION_DEPENDENT_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <cppuhelper/weakref.hxx>
+#include <osl/mutex.hxx>
+
+//........................................................................
+namespace sdbtools
+{
+//........................................................................
+
+ //====================================================================
+ //= ConnectionDependentComponent
+ //====================================================================
+ class ConnectionDependentComponent
+ {
+ private:
+ mutable ::osl::Mutex m_aMutex;
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XConnection >
+ m_aConnection;
+ ::comphelper::ComponentContext
+ m_aContext;
+
+ /** a hard reference to the connection we're working for
+
+ This member is only valid as long as a EntryGuard is on the stack.
+ The guard will, in its constructor, set the member, and reset it in its destructor.
+ This ensures that the connection is only held hard when it's needed, and weak otherwise.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
+ m_xConnection;
+
+ protected:
+ ::osl::Mutex& getMutex() const { return m_aMutex; }
+
+ const ::comphelper::ComponentContext&
+ getContext() const { return m_aContext; }
+
+ protected:
+ class EntryGuard;
+
+ protected:
+ ConnectionDependentComponent( const ::comphelper::ComponentContext& _rContext )
+ :m_aContext( _rContext )
+ {
+ }
+
+ /** sets the connection we depend on.
+
+ To be called exactly once.
+
+ @param _rxConnection
+ the connection to set
+ */
+ void setWeakConnection( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection )
+ {
+ m_aConnection = _rxConnection;
+ }
+
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >&
+ getConnection() const { return m_xConnection; }
+
+ public:
+ struct GuardAccess;
+ friend struct GuardAccess;
+ /** helper for granting exclusive access to various other methods
+ */
+ struct GuardAccess { friend class EntryGuard; private: GuardAccess() { } };
+
+ ::osl::Mutex& getMutex( GuardAccess ) const { return m_aMutex; }
+
+ inline bool acquireConnection( GuardAccess )
+ {
+ m_xConnection = (::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >)m_aConnection;
+ return m_xConnection.is();
+ }
+ inline void releaseConnection( GuardAccess )
+ {
+ m_xConnection.clear();
+ }
+ };
+
+ //====================================================================
+ //= ConnectionDependentComponent::EntryGuard
+ //====================================================================
+ /** a class for guarding methods of a connection-dependent component
+
+ This class serves multiple purposes:
+ <ul><li>It ensures multi-threading safety by guarding the component's mutex
+ as long as it lives.</li>
+ <li>It ensures that the component's connection is alive. The constructor
+ throws a DisposedException if no hard reference to the connection can
+ be obtained.</li>
+ </ul>
+ */
+ class ConnectionDependentComponent::EntryGuard
+ {
+ private:
+ ::osl::MutexGuard m_aMutexGuard;
+ ConnectionDependentComponent& m_rComponent;
+
+ public:
+ EntryGuard( ConnectionDependentComponent& _rComponent )
+ :m_aMutexGuard( _rComponent.getMutex( ConnectionDependentComponent::GuardAccess() ) )
+ ,m_rComponent( _rComponent )
+ {
+ if ( !m_rComponent.acquireConnection( ConnectionDependentComponent::GuardAccess() ) )
+ throw ::com::sun::star::lang::DisposedException();
+ }
+
+ ~EntryGuard()
+ {
+ m_rComponent.releaseConnection( ConnectionDependentComponent::GuardAccess() );
+ }
+ };
+
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
+#endif // DBACCESS_CONNECTION_DEPENDENT_HXX
+
diff --git a/dbaccess/source/sdbtools/connection/connectiontools.cxx b/dbaccess/source/sdbtools/connection/connectiontools.cxx
new file mode 100644
index 000000000000..1de93461d106
--- /dev/null
+++ b/dbaccess/source/sdbtools/connection/connectiontools.cxx
@@ -0,0 +1,197 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBACCESS_CONNECTIONTOOLS_HXX
+#include "connectiontools.hxx"
+#endif
+
+#ifndef DBACCESS_SOURCE_SDBTOOLS_CONNECTION_TABLENAME_HXX
+#include "tablename.hxx"
+#endif
+#ifndef DBACCESS_SOURCE_SDBTOOLS_CONNECTION_OBJECTNAMES_HXX
+#include "objectnames.hxx"
+#endif
+#ifndef DBACCESS_DATASOURCEMETADATA_HXX
+#include "datasourcemetadata.hxx"
+#endif
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#ifndef COMPHELPER_NAMEDVALUECOLLECTION_HXX
+#include <comphelper/namedvaluecollection.hxx>
+#endif
+
+#include <connectivity/dbtools.hxx>
+#include <connectivity/statementcomposer.hxx>
+
+#include <algorithm>
+
+extern "C" void SAL_CALL createRegistryInfo_ConnectionTools()
+{
+ ::sdbtools::OAutoRegistration< ::sdbtools::ConnectionTools > aRegistration;
+}
+
+//........................................................................
+namespace sdbtools
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::sdb::tools::XTableName;
+ using ::com::sun::star::sdb::tools::XObjectNames;
+ using ::com::sun::star::sdb::tools::XDataSourceMetaData;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::uno::XComponentContext;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= ConnectionTools
+ //====================================================================
+ //--------------------------------------------------------------------
+ ConnectionTools::ConnectionTools( const ::comphelper::ComponentContext& _rContext )
+ :ConnectionDependentComponent( _rContext )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ConnectionTools::~ConnectionTools()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XTableName > SAL_CALL ConnectionTools::createTableName() throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ return new TableName( getContext(), getConnection() );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XObjectNames > SAL_CALL ConnectionTools::getObjectNames() throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ return new ObjectNames( getContext(), getConnection() );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XDataSourceMetaData > SAL_CALL ConnectionTools::getDataSourceMetaData() throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ return new DataSourceMetaData( getContext(), getConnection() );
+ }
+ //--------------------------------------------------------------------
+ Reference< container::XNameAccess > SAL_CALL ConnectionTools::getFieldsByCommandDescriptor( ::sal_Int32 commandType, const ::rtl::OUString& command, Reference< lang::XComponent >& keepFieldsAlive ) throw (sdbc::SQLException, RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ ::dbtools::SQLExceptionInfo aErrorInfo;
+ Reference< container::XNameAccess > xRet = ::dbtools::getFieldsByCommandDescriptor(getConnection(),commandType,command,keepFieldsAlive,&aErrorInfo);
+ if ( aErrorInfo.isValid() )
+ aErrorInfo.doThrow();
+ return xRet;
+ }
+ //--------------------------------------------------------------------
+ Reference< sdb::XSingleSelectQueryComposer > SAL_CALL ConnectionTools::getComposer( ::sal_Int32 commandType, const ::rtl::OUString& command ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ dbtools::StatementComposer aComposer(getConnection(), command, commandType, sal_True );
+ aComposer.setDisposeComposer(sal_False);
+ return aComposer.getComposer();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ConnectionTools::getImplementationName() throw (RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL ConnectionTools::supportsService(const ::rtl::OUString & _ServiceName) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( getSupportedServiceNames() );
+ const ::rtl::OUString* begin = aSupported.getConstArray();
+ const ::rtl::OUString* end = aSupported.getConstArray() + aSupported.getLength();
+ return ::std::find( begin, end, _ServiceName ) != end;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL ConnectionTools::getSupportedServiceNames() throw (RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ConnectionTools::getImplementationName_static()
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.dbaccess.ConnectionTools" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL ConnectionTools::getSupportedServiceNames_static()
+ {
+ Sequence< ::rtl::OUString > aSupported( 1 );
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.tools.ConnectionTools" ) );
+ return aSupported;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL ConnectionTools::Create(const Reference< XComponentContext >& _rxContext )
+ {
+ return *( new ConnectionTools( ::comphelper::ComponentContext( _rxContext ) ) );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ConnectionTools::initialize(const Sequence< Any > & _rArguments) throw (RuntimeException, Exception)
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ ::comphelper::NamedValueCollection aArguments( _rArguments );
+
+ Reference< XConnection > xConnection;
+ aArguments.get( "Connection" ) >>= xConnection;
+ if ( !xConnection.is() )
+ throw IllegalArgumentException();
+
+ setWeakConnection( xConnection );
+ }
+
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
diff --git a/dbaccess/source/sdbtools/connection/connectiontools.hxx b/dbaccess/source/sdbtools/connection/connectiontools.hxx
new file mode 100644
index 000000000000..c2235e54c526
--- /dev/null
+++ b/dbaccess/source/sdbtools/connection/connectiontools.hxx
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef DBACCESS_CONNECTIONTOOLS_HXX
+#define DBACCESS_CONNECTIONTOOLS_HXX
+
+#ifndef DBACCESS_MODULE_SDBT_HXX
+#include "module_sdbt.hxx"
+#endif
+
+#ifndef DBACCESS_CONNECTION_DEPENDENT_HXX
+#include "connectiondependent.hxx"
+#endif
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_SDB_TOOLS_XCONNECTIONTOOLS_HPP_
+#include <com/sun/star/sdb/tools/XConnectionTools.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_
+#include <com/sun/star/uno/XComponentContext.hpp>
+#endif
+/** === end UNO includes === **/
+
+#ifndef _CPPUHELPER_IMPLBASE3_HXX_
+#include <cppuhelper/implbase3.hxx>
+#endif
+
+#ifndef COMPHELPER_COMPONENTCONTEXT_HXX
+#include <comphelper/componentcontext.hxx>
+#endif
+
+//........................................................................
+namespace sdbtools
+{
+//........................................................................
+
+ //====================================================================
+ //= ConnectionTools
+ //====================================================================
+ typedef ::cppu::WeakImplHelper3 < ::com::sun::star::sdb::tools::XConnectionTools
+ , ::com::sun::star::lang::XServiceInfo
+ , ::com::sun::star::lang::XInitialization
+ > ConnectionTools_Base;
+ /** implements the com::sun::star::sdb::tools::XConnectionTools functionality
+ */
+ class ConnectionTools :public ConnectionTools_Base
+ ,public ConnectionDependentComponent
+ {
+ private:
+ SdbtClient m_aModuleClient;
+
+ public:
+ /** constructs a ConnectionTools instance
+
+ @param _rxContext
+ the context of the component
+ */
+ ConnectionTools( const ::comphelper::ComponentContext& _rContext );
+
+ // XConnectionTools
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XTableName > SAL_CALL createTableName() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XObjectNames > SAL_CALL getObjectNames() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XDataSourceMetaData > SAL_CALL getDataSourceMetaData() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getFieldsByCommandDescriptor( ::sal_Int32 commandType, const ::rtl::OUString& command, ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& keepFieldsAlive ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > SAL_CALL getComposer( ::sal_Int32 commandType, const ::rtl::OUString& command ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService(const ::rtl::OUString & ServiceName) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo - static versions
+ static ::rtl::OUString SAL_CALL getImplementationName_static();
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static();
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
+
+ // XInitialization
+ virtual void SAL_CALL initialize(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > & aArguments) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::uno::Exception);
+
+ protected:
+ ~ConnectionTools();
+
+ private:
+ ConnectionTools(); // never implemented
+ ConnectionTools( const ConnectionTools& ); // never implemented
+ ConnectionTools& operator=( const ConnectionTools& ); // never implemented
+ };
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
+#endif // DBACCESS_CONNECTIONTOOLS_HXX
+
diff --git a/dbaccess/source/sdbtools/connection/datasourcemetadata.cxx b/dbaccess/source/sdbtools/connection/datasourcemetadata.cxx
new file mode 100644
index 000000000000..5d9ba83fe9c3
--- /dev/null
+++ b/dbaccess/source/sdbtools/connection/datasourcemetadata.cxx
@@ -0,0 +1,93 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBACCESS_DATASOURCEMETADATA_HXX
+#include "datasourcemetadata.hxx"
+#endif
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_LANG_NULLPOINTEREXCEPTION_HPP_
+#include <com/sun/star/lang/NullPointerException.hpp>
+#endif
+/** === end UNO includes === **/
+
+#ifndef CONNECTIVITY_INC_CONNECTIVITY_DBMETADATA_HXX
+#include <connectivity/dbmetadata.hxx>
+#endif
+
+//........................................................................
+namespace sdbtools
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::lang::NullPointerException;
+ using ::com::sun::star::uno::RuntimeException;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= DataSourceMetaData_Impl
+ //====================================================================
+ struct DataSourceMetaData_Impl
+ {
+ };
+
+ //====================================================================
+ //= DataSourceMetaData
+ //====================================================================
+ //--------------------------------------------------------------------
+ DataSourceMetaData::DataSourceMetaData( const ::comphelper::ComponentContext& _rContext, const Reference< XConnection >& _rxConnection )
+ :ConnectionDependentComponent( _rContext )
+ ,m_pImpl( new DataSourceMetaData_Impl )
+ {
+ if ( !_rxConnection.is() )
+ throw NullPointerException();
+ setWeakConnection( _rxConnection );
+ }
+
+ //--------------------------------------------------------------------
+ DataSourceMetaData::~DataSourceMetaData()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL DataSourceMetaData::supportsQueriesInFrom( ) throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ ::dbtools::DatabaseMetaData aMeta( getConnection() );
+ return aMeta.supportsSubqueriesInFrom();
+ }
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
diff --git a/dbaccess/source/sdbtools/connection/datasourcemetadata.hxx b/dbaccess/source/sdbtools/connection/datasourcemetadata.hxx
new file mode 100644
index 000000000000..de4a82df1340
--- /dev/null
+++ b/dbaccess/source/sdbtools/connection/datasourcemetadata.hxx
@@ -0,0 +1,97 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef DBACCESS_DATASOURCEMETADATA_HXX
+#define DBACCESS_DATASOURCEMETADATA_HXX
+
+#ifndef DBACCESS_CONNECTION_DEPENDENT_HXX
+#include "connectiondependent.hxx"
+#endif
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_SDB_TOOLS_XDATASOURCEMETADATA_HPP_
+#include <com/sun/star/sdb/tools/XDataSourceMetaData.hpp>
+#endif
+/** === end UNO includes === **/
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+
+#include <memory>
+
+//........................................................................
+namespace sdbtools
+{
+//........................................................................
+
+ //====================================================================
+ //= DataSourceMetaData
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::sdb::tools::XDataSourceMetaData
+ > DataSourceMetaData_Base;
+ struct DataSourceMetaData_Impl;
+ /** default implementation for XDataSourceMetaData
+ */
+ class DataSourceMetaData :public DataSourceMetaData_Base
+ ,public ConnectionDependentComponent
+ {
+ private:
+ ::std::auto_ptr< DataSourceMetaData_Impl > m_pImpl;
+
+ public:
+ /** constructs the instance
+ @param _rContext
+ the component's context
+ @param _rxConnection
+ the connection to work with. Will be held weak. Must not be <NULL/>.
+ @throws ::com::sun::star::lang::NullPointerException
+ if _rxConnection is <NULL/>
+ */
+ DataSourceMetaData(
+ const ::comphelper::ComponentContext& _rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection
+ );
+
+ // XDataSourceMetaData
+ virtual ::sal_Bool SAL_CALL supportsQueriesInFrom( ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ virtual ~DataSourceMetaData();
+
+ private:
+ DataSourceMetaData(); // never implemented
+ DataSourceMetaData( const DataSourceMetaData& ); // never implemented
+ DataSourceMetaData& operator=( const DataSourceMetaData& ); // never implemented
+ };
+
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
+#endif // DBACCESS_DATASOURCEMETADATA_HXX
diff --git a/dbaccess/source/sdbtools/connection/makefile.mk b/dbaccess/source/sdbtools/connection/makefile.mk
new file mode 100644
index 000000000000..f8d43df01426
--- /dev/null
+++ b/dbaccess/source/sdbtools/connection/makefile.mk
@@ -0,0 +1,49 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=$(PRJ)$/source
+PRJNAME=dbaccess
+TARGET=conntools
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files -------------------------------------
+SLOFILES= \
+ $(SLO)$/connectiontools.obj \
+ $(SLO)$/tablename.obj \
+ $(SLO)$/objectnames.obj \
+ $(SLO)$/datasourcemetadata.obj
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/dbaccess/source/sdbtools/connection/objectnames.cxx b/dbaccess/source/sdbtools/connection/objectnames.cxx
new file mode 100644
index 000000000000..01e6931de526
--- /dev/null
+++ b/dbaccess/source/sdbtools/connection/objectnames.cxx
@@ -0,0 +1,498 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBACCESS_SOURCE_SDBTOOLS_CONNECTION_OBJECTNAMES_HXX
+#include "objectnames.hxx"
+#endif
+
+#ifndef DBACCESS_MODULE_SDBT_HXX
+#include "module_sdbt.hxx"
+#endif
+#ifndef DBACCESS_SDBT_RESOURCE_HRC
+#include "sdbt_resource.hrc"
+#endif
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/NullPointerException.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdb/ErrorCondition.hpp>
+/** === end UNO includes === **/
+
+#include <connectivity/dbmetadata.hxx>
+#include <connectivity/dbtools.hxx>
+#include <connectivity/sqlerror.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <tools/string.hxx>
+
+#include <boost/shared_ptr.hpp>
+
+//........................................................................
+namespace sdbtools
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::lang::NullPointerException;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::sdbc::SQLException;
+ using ::com::sun::star::sdbc::XDatabaseMetaData;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::container::XNameAccess;
+ using ::com::sun::star::sdbc::XDatabaseMetaData;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::sdbcx::XTablesSupplier;
+ using ::com::sun::star::sdb::XQueriesSupplier;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Any;
+ /** === end UNO using === **/
+
+ namespace CommandType = ::com::sun::star::sdb::CommandType;
+ namespace ErrorCondition = ::com::sun::star::sdb::ErrorCondition;
+
+ //====================================================================
+ //= INameValidation
+ //====================================================================
+ class INameValidation
+ {
+ public:
+ virtual bool validateName( const ::rtl::OUString& _rName ) = 0;
+ virtual void validateName_throw( const ::rtl::OUString& _rName ) = 0;
+
+ virtual ~INameValidation() { }
+ };
+ typedef ::boost::shared_ptr< INameValidation > PNameValidation;
+
+ //====================================================================
+ //= PlainExistenceCheck
+ //====================================================================
+ class PlainExistenceCheck : public INameValidation
+ {
+ private:
+ const ::comphelper::ComponentContext m_aContext;
+ Reference< XConnection > m_xConnection;
+ Reference< XNameAccess > m_xContainer;
+
+ public:
+ PlainExistenceCheck( const ::comphelper::ComponentContext& _rContext, const Reference< XConnection >& _rxConnection, const Reference< XNameAccess >& _rxContainer )
+ :m_aContext( _rContext )
+ ,m_xConnection( _rxConnection )
+ ,m_xContainer( _rxContainer )
+ {
+ OSL_ENSURE( m_xContainer.is(), "PlainExistenceCheck::PlainExistenceCheck: this will crash!" );
+ }
+
+ // INameValidation
+ virtual bool validateName( const ::rtl::OUString& _rName )
+ {
+ return !m_xContainer->hasByName( _rName );
+ }
+
+ virtual void validateName_throw( const ::rtl::OUString& _rName )
+ {
+ if ( validateName( _rName ) )
+ return;
+
+ ::connectivity::SQLError aErrors( m_aContext );
+ SQLException aError( aErrors.getSQLException( ErrorCondition::DB_OBJECT_NAME_IS_USED, m_xConnection, _rName ) );
+
+ ::dbtools::DatabaseMetaData aMeta( m_xConnection );
+ if ( aMeta.supportsSubqueriesInFrom() )
+ {
+ String sNeedDistinctNames( SdbtRes( STR_QUERY_AND_TABLE_DISTINCT_NAMES ) );
+ aError.NextException <<= SQLException( sNeedDistinctNames, m_xConnection, ::rtl::OUString(), 0, Any() );
+ }
+
+ throw aError;
+ }
+ };
+
+ //====================================================================
+ //= TableValidityCheck
+ //====================================================================
+ class TableValidityCheck : public INameValidation
+ {
+ const ::comphelper::ComponentContext m_aContext;
+ const Reference< XConnection > m_xConnection;
+
+ public:
+ TableValidityCheck( const ::comphelper::ComponentContext& _rContext, const Reference< XConnection >& _rxConnection )
+ :m_aContext( _rContext )
+ ,m_xConnection( _rxConnection )
+ {
+ }
+
+ virtual bool validateName( const ::rtl::OUString& _rName )
+ {
+ ::dbtools::DatabaseMetaData aMeta( m_xConnection );
+ if ( !aMeta.restrictIdentifiersToSQL92() )
+ return true;
+
+ ::rtl::OUString sCatalog, sSchema, sName;
+ ::dbtools::qualifiedNameComponents(
+ m_xConnection->getMetaData(), _rName, sCatalog, sSchema, sName, ::dbtools::eInTableDefinitions );
+
+ ::rtl::OUString sExtraNameCharacters( m_xConnection->getMetaData()->getExtraNameCharacters() );
+ if ( ( sCatalog.getLength() && !::dbtools::isValidSQLName( sCatalog, sExtraNameCharacters ) )
+ || ( sSchema.getLength() && !::dbtools::isValidSQLName( sSchema, sExtraNameCharacters ) )
+ || ( sName.getLength() && !::dbtools::isValidSQLName( sName, sExtraNameCharacters ) )
+ )
+ return false;
+
+ return true;
+ }
+
+ virtual void validateName_throw( const ::rtl::OUString& _rName )
+ {
+ if ( validateName( _rName ) )
+ return;
+
+ ::connectivity::SQLError aErrors( m_aContext );
+ aErrors.raiseException( ErrorCondition::DB_INVALID_SQL_NAME, m_xConnection, _rName );
+ }
+ };
+
+ //====================================================================
+ //= QueryValidityCheck
+ //====================================================================
+ class QueryValidityCheck : public INameValidation
+ {
+ const ::comphelper::ComponentContext m_aContext;
+ const Reference< XConnection > m_xConnection;
+
+ public:
+ QueryValidityCheck( const ::comphelper::ComponentContext& _rContext, const Reference< XConnection >& _rxConnection )
+ :m_aContext( _rContext )
+ ,m_xConnection( _rxConnection )
+ {
+ }
+
+ inline ::connectivity::ErrorCondition validateName_getErrorCondition( const ::rtl::OUString& _rName )
+ {
+ if ( ( _rName.indexOf( (sal_Unicode)34 ) >= 0 ) // "
+ || ( _rName.indexOf( (sal_Unicode)39 ) >= 0 ) // '
+ || ( _rName.indexOf( (sal_Unicode)96 ) >= 0 ) //
+ || ( _rName.indexOf( (sal_Unicode)145 ) >= 0 ) //
+ || ( _rName.indexOf( (sal_Unicode)146 ) >= 0 ) //
+ || ( _rName.indexOf( (sal_Unicode)180 ) >= 0 ) // #86621# removed unparsable chars
+ )
+ return ErrorCondition::DB_QUERY_NAME_WITH_QUOTES;
+
+ if ( _rName.indexOf( '/') >= 0 )
+ return ErrorCondition::DB_OBJECT_NAME_WITH_SLASHES;
+
+ return 0;
+ }
+
+ virtual bool validateName( const ::rtl::OUString& _rName )
+ {
+ if ( validateName_getErrorCondition( _rName ) != 0 )
+ return false;
+ return true;
+ }
+
+ virtual void validateName_throw( const ::rtl::OUString& _rName )
+ {
+ ::connectivity::ErrorCondition nErrorCondition = validateName_getErrorCondition( _rName );
+ if ( nErrorCondition != 0 )
+ {
+ ::connectivity::SQLError aErrors( m_aContext );
+ aErrors.raiseException( nErrorCondition, m_xConnection );
+ }
+ }
+ };
+
+ //====================================================================
+ //= CombinedNameCheck
+ //====================================================================
+ class CombinedNameCheck : public INameValidation
+ {
+ private:
+ PNameValidation m_pPrimary;
+ PNameValidation m_pSecondary;
+
+ public:
+ CombinedNameCheck( PNameValidation _pPrimary, PNameValidation _pSecondary )
+ :m_pPrimary( _pPrimary )
+ ,m_pSecondary( _pSecondary )
+ {
+ OSL_ENSURE( m_pPrimary.get() && m_pSecondary.get(), "CombinedNameCheck::CombinedNameCheck: this will crash!" );
+ }
+
+ // INameValidation
+ virtual bool validateName( const ::rtl::OUString& _rName )
+ {
+ return m_pPrimary->validateName( _rName ) && m_pSecondary->validateName( _rName );
+ }
+
+ virtual void validateName_throw( const ::rtl::OUString& _rName )
+ {
+ m_pPrimary->validateName_throw( _rName );
+ m_pSecondary->validateName_throw( _rName );
+ }
+ };
+
+ //====================================================================
+ //= NameCheckFactory
+ //====================================================================
+ class NameCheckFactory
+ {
+ public:
+ /** creates an INameValidation instance which can be used to check the existence of query or table names
+
+ @param _rContext
+ the component's context
+
+ @param _nCommandType
+ the type of objects (CommandType::TABLE or CommandType::QUERY) of which names shall be checked for existence
+
+ @param _rxConnection
+ the connection relative to which the names are to be checked. Must be an SDB-level connection
+
+ @throws IllegalArgumentException
+ if the given connection is no SDB-level connection
+
+ @throws IllegalArgumentException
+ if the given command type is neither CommandType::TABLE or CommandType::QUERY
+ */
+ static PNameValidation createExistenceCheck(
+ const ::comphelper::ComponentContext& _rContext,
+ sal_Int32 _nCommandType,
+ const Reference< XConnection >& _rxConnection
+ );
+
+ /** creates an INameValidation instance which can be used to check the validity of a query or table name
+
+ @param _rContext
+ the component's context
+
+ @param _nCommandType
+ the type of objects (CommandType::TABLE or CommandType::QUERY) of which names shall be validated
+
+ @param _rxConnection
+ the connection relative to which the names are to be checked. Must be an SDB-level connection
+
+ @throws IllegalArgumentException
+ if the given connection is no SDB-level connection
+
+ @throws IllegalArgumentException
+ if the given command type is neither CommandType::TABLE or CommandType::QUERY
+ */
+ static PNameValidation createValidityCheck(
+ const ::comphelper::ComponentContext& _rContext,
+ const sal_Int32 _nCommandType,
+ const Reference< XConnection >& _rxConnection
+ );
+
+ private:
+ NameCheckFactory(); // never implemented
+
+ private:
+ static void verifyCommandType( sal_Int32 _nCommandType );
+ };
+
+ //--------------------------------------------------------------------
+ void NameCheckFactory::verifyCommandType( sal_Int32 _nCommandType )
+ {
+ if ( ( _nCommandType != CommandType::TABLE )
+ && ( _nCommandType != CommandType::QUERY )
+ )
+ throw IllegalArgumentException(
+ String( SdbtRes( STR_INVALID_COMMAND_TYPE ) ),
+ NULL,
+ 0
+ );
+ }
+
+ //--------------------------------------------------------------------
+ PNameValidation NameCheckFactory::createExistenceCheck( const ::comphelper::ComponentContext& _rContext, sal_Int32 _nCommandType, const Reference< XConnection >& _rxConnection )
+ {
+ verifyCommandType( _nCommandType );
+
+ ::dbtools::DatabaseMetaData aMeta( _rxConnection );
+
+ Reference< XNameAccess > xTables, xQueries;
+ try
+ {
+ Reference< XTablesSupplier > xSuppTables( _rxConnection, UNO_QUERY_THROW );
+ Reference< XQueriesSupplier > xQueriesSupplier( _rxConnection, UNO_QUERY_THROW );
+ xTables.set( xSuppTables->getTables(), UNO_QUERY_THROW );
+ xQueries.set( xQueriesSupplier->getQueries(), UNO_QUERY_THROW );
+ }
+ catch( const Exception& )
+ {
+ throw IllegalArgumentException(
+ String( SdbtRes( STR_CONN_WITHOUT_QUERIES_OR_TABLES ) ),
+ NULL,
+ 0
+ );
+ }
+
+ PNameValidation pTableCheck( new PlainExistenceCheck( _rContext, _rxConnection, xTables ) );
+ PNameValidation pQueryCheck( new PlainExistenceCheck( _rContext, _rxConnection, xQueries ) );
+ PNameValidation pReturn;
+
+ if ( aMeta.supportsSubqueriesInFrom() )
+ pReturn.reset( new CombinedNameCheck( pTableCheck, pQueryCheck ) );
+ else if ( _nCommandType == CommandType::TABLE )
+ pReturn = pTableCheck;
+ else
+ pReturn = pQueryCheck;
+ return pReturn;
+ }
+
+ //--------------------------------------------------------------------
+ PNameValidation NameCheckFactory::createValidityCheck( const ::comphelper::ComponentContext& _rContext, sal_Int32 _nCommandType, const Reference< XConnection >& _rxConnection )
+ {
+ verifyCommandType( _nCommandType );
+
+ Reference< XDatabaseMetaData > xMeta;
+ try
+ {
+ xMeta.set( _rxConnection->getMetaData(), UNO_QUERY_THROW );
+ }
+ catch( const Exception& )
+ {
+ throw IllegalArgumentException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "The connection could not provide its database's meta data." ) ),
+ NULL,
+ 0
+ );
+ }
+
+ if ( _nCommandType == CommandType::TABLE )
+ return PNameValidation( new TableValidityCheck( _rContext, _rxConnection ) );
+ return PNameValidation( new QueryValidityCheck( _rContext, _rxConnection ) );
+ }
+
+ //====================================================================
+ //= ObjectNames_Impl
+ //====================================================================
+ struct ObjectNames_Impl
+ {
+ SdbtClient m_aModuleClient; // keep the module alive as long as this instance lives
+ };
+
+ //====================================================================
+ //= ObjectNames
+ //====================================================================
+ //--------------------------------------------------------------------
+ ObjectNames::ObjectNames( const ::comphelper::ComponentContext& _rContext, const Reference< XConnection >& _rxConnection )
+ :ConnectionDependentComponent( _rContext )
+ ,m_pImpl( new ObjectNames_Impl )
+ {
+ if ( !_rxConnection.is() )
+ throw NullPointerException();
+ setWeakConnection( _rxConnection );
+ }
+
+ //--------------------------------------------------------------------
+ ObjectNames::~ObjectNames()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ObjectNames::suggestName( ::sal_Int32 _CommandType, const ::rtl::OUString& _BaseName ) throw (IllegalArgumentException, RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+
+ PNameValidation pNameCheck( NameCheckFactory::createExistenceCheck( getContext(), _CommandType, getConnection() ) );
+
+ String sBaseName( _BaseName );
+ if ( sBaseName.Len() == 0 )
+ {
+ if ( _CommandType == CommandType::TABLE )
+ sBaseName = String( SdbtRes( STR_BASENAME_TABLE ) );
+ else
+ sBaseName = String( SdbtRes( STR_BASENAME_QUERY ) );
+ }
+
+ ::rtl::OUString sName( sBaseName );
+ sal_Int32 i = 1;
+ while ( !pNameCheck->validateName( sName ) )
+ {
+ ::rtl::OUStringBuffer aNameBuffer;
+ aNameBuffer.append( sBaseName );
+ aNameBuffer.appendAscii( " " );
+ aNameBuffer.append( (sal_Int32)++i );
+ sName = aNameBuffer.makeStringAndClear();
+ }
+
+ return sName;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ObjectNames::convertToSQLName( const ::rtl::OUString& Name ) throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ Reference< XDatabaseMetaData > xMeta( getConnection()->getMetaData(), UNO_QUERY_THROW );
+ return ::dbtools::convertName2SQLName( Name, xMeta->getExtraNameCharacters() );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL ObjectNames::isNameUsed( ::sal_Int32 _CommandType, const ::rtl::OUString& _Name ) throw (IllegalArgumentException, RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+
+ PNameValidation pNameCheck( NameCheckFactory::createExistenceCheck( getContext(), _CommandType, getConnection()) );
+ return !pNameCheck->validateName( _Name );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL ObjectNames::isNameValid( ::sal_Int32 _CommandType, const ::rtl::OUString& _Name ) throw (IllegalArgumentException, RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+
+ PNameValidation pNameCheck( NameCheckFactory::createValidityCheck( getContext(), _CommandType, getConnection()) );
+ return pNameCheck->validateName( _Name );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ObjectNames::checkNameForCreate( ::sal_Int32 _CommandType, const ::rtl::OUString& _Name ) throw (SQLException, RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+
+ PNameValidation pNameCheck( NameCheckFactory::createExistenceCheck( getContext(), _CommandType, getConnection() ) );
+ pNameCheck->validateName_throw( _Name );
+
+ pNameCheck = NameCheckFactory::createValidityCheck( getContext(), _CommandType, getConnection() );
+ pNameCheck->validateName_throw( _Name );
+ }
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
diff --git a/dbaccess/source/sdbtools/connection/objectnames.hxx b/dbaccess/source/sdbtools/connection/objectnames.hxx
new file mode 100644
index 000000000000..0f72896aa118
--- /dev/null
+++ b/dbaccess/source/sdbtools/connection/objectnames.hxx
@@ -0,0 +1,98 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef DBACCESS_SOURCE_SDBTOOLS_INC_OBJECTNAMES_HXX
+#define DBACCESS_SOURCE_SDBTOOLS_INC_OBJECTNAMES_HXX
+
+#include "connectiondependent.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdb/tools/XObjectNames.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <cppuhelper/implbase1.hxx>
+
+#include <memory>
+
+//........................................................................
+namespace sdbtools
+{
+//........................................................................
+
+ //====================================================================
+ //= ObjectNames
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::sdb::tools::XObjectNames
+ > ObjectNames_Base;
+ struct ObjectNames_Impl;
+ /** default implementation for XObjectNames
+ */
+ class ObjectNames :public ObjectNames_Base
+ ,public ConnectionDependentComponent
+ {
+ private:
+ ::std::auto_ptr< ObjectNames_Impl > m_pImpl;
+
+ public:
+ /** constructs the instance
+
+ @param _rContext
+ the component's context
+ @param _rxConnection
+ the connection to work with. Will be held weak. Must not be <NULL/>.
+
+ @throws ::com::sun::star::lang::NullPointerException
+ if _rxConnection is <NULL/>
+ */
+ ObjectNames(
+ const ::comphelper::ComponentContext& _rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection
+ );
+
+ // XObjectNames
+ virtual ::rtl::OUString SAL_CALL suggestName( ::sal_Int32 CommandType, const ::rtl::OUString& BaseName ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL convertToSQLName( const ::rtl::OUString& Name ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isNameUsed( ::sal_Int32 CommandType, const ::rtl::OUString& Name ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isNameValid( ::sal_Int32 CommandType, const ::rtl::OUString& Name ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL checkNameForCreate( ::sal_Int32 CommandType, const ::rtl::OUString& Name ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ protected:
+ virtual ~ObjectNames();
+
+ private:
+ ObjectNames(); // never implemented
+ ObjectNames( const ObjectNames& ); // never implemented
+ ObjectNames& operator=( const ObjectNames& ); // never implemented
+ };
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
+#endif // DBACCESS_SOURCE_SDBTOOLS_INC_OBJECTNAMES_HXX
+
diff --git a/dbaccess/source/sdbtools/connection/tablename.cxx b/dbaccess/source/sdbtools/connection/tablename.cxx
new file mode 100644
index 000000000000..aedc62451300
--- /dev/null
+++ b/dbaccess/source/sdbtools/connection/tablename.cxx
@@ -0,0 +1,275 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "tablename.hxx"
+#include "sdbt_resource.hrc"
+#include "module_sdbt.hxx"
+#include "sdbtstrings.hrc"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/NullPointerException.hpp>
+#include <com/sun/star/sdb/tools/CompositionType.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+/** === end UNO includes === **/
+
+#include <connectivity/dbtools.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/string.hxx>
+
+//........................................................................
+namespace sdbtools
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::lang::NullPointerException;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::container::NoSuchElementException;
+ using ::com::sun::star::sdbcx::XTablesSupplier;
+ using ::com::sun::star::container::XNameAccess;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::lang::WrappedTargetException;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ /** === end UNO using === **/
+
+ namespace CompositionType = ::com::sun::star::sdb::tools::CompositionType;
+
+ using namespace ::dbtools;
+
+ //====================================================================
+ //= TableName
+ //====================================================================
+ struct TableName_Impl
+ {
+ SdbtClient m_aModuleClient; // keep the module alive as long as this instance lives
+
+ ::rtl::OUString sCatalog;
+ ::rtl::OUString sSchema;
+ ::rtl::OUString sName;
+ };
+
+ //====================================================================
+ //= TableName
+ //====================================================================
+ //--------------------------------------------------------------------
+ TableName::TableName( const ::comphelper::ComponentContext& _rContext, const Reference< XConnection >& _rxConnection )
+ :ConnectionDependentComponent( _rContext )
+ ,m_pImpl( new TableName_Impl )
+ {
+ if ( !_rxConnection.is() )
+ throw NullPointerException();
+
+ setWeakConnection( _rxConnection );
+ }
+
+ //--------------------------------------------------------------------
+ TableName::~TableName()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL TableName::getCatalogName() throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ return m_pImpl->sCatalog;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL TableName::setCatalogName( const ::rtl::OUString& _catalogName ) throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ m_pImpl->sCatalog = _catalogName;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL TableName::getSchemaName() throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ return m_pImpl->sSchema;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL TableName::setSchemaName( const ::rtl::OUString& _schemaName ) throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ m_pImpl->sSchema = _schemaName;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL TableName::getTableName() throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ return m_pImpl->sName;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL TableName::setTableName( const ::rtl::OUString& _tableName ) throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ m_pImpl->sName = _tableName;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL TableName::getNameForSelect() throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+ return composeTableNameForSelect( getConnection(), m_pImpl->sCatalog, m_pImpl->sSchema, m_pImpl->sName );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertySet > SAL_CALL TableName::getTable() throw (NoSuchElementException, RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+
+ Reference< XTablesSupplier > xSuppTables( getConnection(), UNO_QUERY_THROW );
+ Reference< XNameAccess > xTables( xSuppTables->getTables(), UNO_QUERY_THROW );
+
+ Reference< XPropertySet > xTable;
+ try
+ {
+ xTable.set( xTables->getByName( getComposedName( CompositionType::Complete, sal_False ) ), UNO_QUERY_THROW );
+ }
+ catch( const WrappedTargetException& )
+ {
+ throw NoSuchElementException();
+ }
+ catch( const RuntimeException& ) { throw; }
+ catch( const NoSuchElementException& ) { throw; }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ throw NoSuchElementException();
+ }
+
+ return xTable;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL TableName::setTable( const Reference< XPropertySet >& _table ) throw (IllegalArgumentException, RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+
+ Reference< XPropertySetInfo > xPSI( _table, UNO_QUERY );
+ if ( !xPSI.is()
+ || !xPSI->hasPropertyByName( PROPERTY_CATALOGNAME )
+ || !xPSI->hasPropertyByName( PROPERTY_SCHEMANAME )
+ || !xPSI->hasPropertyByName( PROPERTY_NAME )
+ )
+ throw IllegalArgumentException(
+ String( SdbtRes( STR_NO_TABLE_OBJECT ) ),
+ *this,
+ 0
+ );
+
+ try
+ {
+ OSL_VERIFY( _table->getPropertyValue( PROPERTY_CATALOGNAME ) >>= m_pImpl->sCatalog );
+ OSL_VERIFY( _table->getPropertyValue( PROPERTY_SCHEMANAME ) >>= m_pImpl->sSchema );
+ OSL_VERIFY( _table->getPropertyValue( PROPERTY_NAME ) >>= m_pImpl->sName );
+ }
+ catch( const RuntimeException& ) { throw; }
+ catch( const Exception& e )
+ {
+ throw IllegalArgumentException( e.Message, e.Context, 0 );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ /** translates a CopmositionType into a EComposeRule
+ @throws IllegalArgumentException
+ if the given value does not denote a valid CompositionType
+ */
+ EComposeRule lcl_translateCompositionType_throw( sal_Int32 _nType )
+ {
+ struct
+ {
+ sal_Int32 nCompositionType;
+ EComposeRule eComposeRule;
+ } TypeTable[] =
+ {
+ { CompositionType::ForTableDefinitions, eInTableDefinitions },
+ { CompositionType::ForIndexDefinitions, eInIndexDefinitions },
+ { CompositionType::ForDataManipulation, eInDataManipulation },
+ { CompositionType::ForProcedureCalls, eInProcedureCalls },
+ { CompositionType::ForPrivilegeDefinitions, eInPrivilegeDefinitions },
+ { CompositionType::ForPrivilegeDefinitions, eComplete }
+ };
+
+ bool found = false;
+ size_t i = 0;
+ for ( ; ( i < sizeof( TypeTable ) / sizeof( TypeTable[0] ) ) && !found; ++i )
+ if ( TypeTable[i].nCompositionType == _nType )
+ found = true;
+ if ( !found )
+ throw IllegalArgumentException(
+ String( SdbtRes( STR_INVALID_COMPOSITION_TYPE ) ),
+ NULL,
+ 0
+ );
+
+ return TypeTable[i].eComposeRule;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL TableName::getComposedName( ::sal_Int32 _Type, ::sal_Bool _Quote ) throw (IllegalArgumentException, RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+
+ return composeTableName(
+ getConnection()->getMetaData(),
+ m_pImpl->sCatalog, m_pImpl->sSchema, m_pImpl->sName, _Quote,
+ lcl_translateCompositionType_throw( _Type ) );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL TableName::setComposedName( const ::rtl::OUString& _ComposedName, ::sal_Int32 _Type ) throw (RuntimeException)
+ {
+ EntryGuard aGuard( *this );
+
+ qualifiedNameComponents(
+ getConnection()->getMetaData(),
+ _ComposedName,
+ m_pImpl->sCatalog, m_pImpl->sSchema, m_pImpl->sName,
+ lcl_translateCompositionType_throw( _Type ) );
+ }
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
diff --git a/dbaccess/source/sdbtools/connection/tablename.hxx b/dbaccess/source/sdbtools/connection/tablename.hxx
new file mode 100644
index 000000000000..fae1b8fae0be
--- /dev/null
+++ b/dbaccess/source/sdbtools/connection/tablename.hxx
@@ -0,0 +1,109 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef DBACCESS_SOURCE_SDBTOOLS_CONNECTION_TABLENAME_HXX
+#define DBACCESS_SOURCE_SDBTOOLS_CONNECTION_TABLENAME_HXX
+
+#ifndef DBACCESS_CONNECTION_DEPENDENT_HXX
+#include "connectiondependent.hxx"
+#endif
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_SDB_TOOLS_XTABLENAME_HPP_
+#include <com/sun/star/sdb/tools/XTableName.hpp>
+#endif
+/** === end UNO includes === **/
+
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+
+#include <memory>
+
+//........................................................................
+namespace sdbtools
+{
+//........................................................................
+
+ //====================================================================
+ //= TableName
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::sdb::tools::XTableName
+ > TableName_Base;
+ struct TableName_Impl;
+ /** default implementation for XTableName
+ */
+ class TableName :public TableName_Base
+ ,public ConnectionDependentComponent
+ {
+ private:
+ ::std::auto_ptr< TableName_Impl > m_pImpl;
+
+ public:
+ /** constructs the instance
+
+ @param _rContext
+ the component's context
+ @param _rxConnection
+ the connection to work with. Will be held weak. Must not be <NULL/>.
+
+ @throws ::com::sun::star::lang::NullPointerException
+ if _rxConnection is <NULL/>
+ */
+ TableName(
+ const ::comphelper::ComponentContext& _rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection
+ );
+
+ // XTableName
+ virtual ::rtl::OUString SAL_CALL getCatalogName() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setCatalogName( const ::rtl::OUString& _catalogname ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSchemaName() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setSchemaName( const ::rtl::OUString& _schemaname ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTableName() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTableName( const ::rtl::OUString& _tablename ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getNameForSelect() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getTable() throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTable( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _table ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getComposedName( ::sal_Int32 Type, ::sal_Bool _Quote ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setComposedName( const ::rtl::OUString& ComposedName, ::sal_Int32 Type ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ virtual ~TableName();
+
+ private:
+ TableName(); // never implemented
+ TableName( const TableName& ); // never implemented
+ TableName& operator=( const TableName& ); // never implemented
+ };
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
+#endif // DBACCESS_SOURCE_SDBTOOLS_CONNECTION_TABLENAME_HXX
+
diff --git a/dbaccess/source/sdbtools/inc/module_sdbt.hxx b/dbaccess/source/sdbtools/inc/module_sdbt.hxx
new file mode 100644
index 000000000000..5b17ff86b4f0
--- /dev/null
+++ b/dbaccess/source/sdbtools/inc/module_sdbt.hxx
@@ -0,0 +1,47 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef DBACCESS_MODULE_SDBT_HXX
+#define DBACCESS_MODULE_SDBT_HXX
+
+#ifndef UNOTOOLS_INC_UNOTOOLS_COMPONENTRESMODULE_HXX
+#include <unotools/componentresmodule.hxx>
+#endif
+
+//........................................................................
+namespace sdbtools
+{
+//........................................................................
+
+ DEFINE_MODULE( SdbtModule, SdbtClient, SdbtRes )
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
+#endif // DBACCESS_MODULE_SDBT_HXX
+
diff --git a/dbaccess/source/sdbtools/inc/sdbt_resource.hrc b/dbaccess/source/sdbtools/inc/sdbt_resource.hrc
new file mode 100644
index 000000000000..1a23ab206fd8
--- /dev/null
+++ b/dbaccess/source/sdbtools/inc/sdbt_resource.hrc
@@ -0,0 +1,48 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef DBACCESS_SDBT_RESOURCE_HRC
+#define DBACCESS_SDBT_RESOURCE_HRC
+
+#ifndef _SOLAR_HRC
+#include <svl/solar.hrc>
+#endif
+
+//------------------------------------------------------------------------------
+#define RID_SDBT_STRINGS_START RID_DBACCESS_START
+
+//------------------------------------------------------------------------------
+//- String-IDs
+#define STR_QUERY_AND_TABLE_DISTINCT_NAMES RID_SDBT_STRINGS_START + 0
+#define STR_BASENAME_TABLE RID_SDBT_STRINGS_START + 1
+#define STR_BASENAME_QUERY RID_SDBT_STRINGS_START + 2
+#define STR_CONN_WITHOUT_QUERIES_OR_TABLES RID_SDBT_STRINGS_START + 3
+#define STR_NO_TABLE_OBJECT RID_SDBT_STRINGS_START + 4
+#define STR_INVALID_COMPOSITION_TYPE RID_SDBT_STRINGS_START + 5
+#define STR_INVALID_COMMAND_TYPE RID_SDBT_STRINGS_START + 6
+
+#endif // DBACCESS_SDBT_RESOURCE_HRC
diff --git a/dbaccess/source/sdbtools/misc/makefile.mk b/dbaccess/source/sdbtools/misc/makefile.mk
new file mode 100644
index 000000000000..8c51fc7a8363
--- /dev/null
+++ b/dbaccess/source/sdbtools/misc/makefile.mk
@@ -0,0 +1,47 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=$(PRJ)$/source
+PRJNAME=dbaccess
+TARGET=sdbtmisc
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files -------------------------------------
+SLOFILES= \
+ $(SLO)$/sdbt_services.obj \
+ $(SLO)$/module_sdbt.obj
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/dbaccess/source/sdbtools/misc/module_sdbt.cxx b/dbaccess/source/sdbtools/misc/module_sdbt.cxx
new file mode 100644
index 000000000000..9c9ee6304168
--- /dev/null
+++ b/dbaccess/source/sdbtools/misc/module_sdbt.cxx
@@ -0,0 +1,45 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBACCESS_MODULE_SDBT_HXX
+#include "module_sdbt.hxx"
+#endif
+
+//........................................................................
+namespace sdbtools
+{
+//........................................................................
+
+ IMPLEMENT_MODULE( SdbtModule, "sdbt" )
+
+//........................................................................
+} // namespace sdbtools
+//........................................................................
+
diff --git a/dbaccess/source/sdbtools/misc/sdbt_services.cxx b/dbaccess/source/sdbtools/misc/sdbt_services.cxx
new file mode 100644
index 000000000000..1c6d746ed99b
--- /dev/null
+++ b/dbaccess/source/sdbtools/misc/sdbt_services.cxx
@@ -0,0 +1,107 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBACCESS_MODULE_SDBT_HXX
+#include "module_sdbt.hxx"
+#endif
+
+/** === begin UNO using === **/
+using ::com::sun::star::lang::XMultiServiceFactory;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::registry::InvalidRegistryException;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::XInterface;
+/** === end UNO using === **/
+
+extern "C" void SAL_CALL createRegistryInfo_ConnectionTools();
+
+//---------------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL sdbt_initializeModule()
+{
+ static sal_Bool s_bInit = sal_False;
+ if (!s_bInit)
+ {
+ createRegistryInfo_ConnectionTools();
+ s_bInit = sal_True;
+ }
+}
+
+//---------------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment **
+ )
+{
+ sdbt_initializeModule();
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" sal_Bool SAL_CALL component_writeInfo(
+ void* pServiceManager,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ return ::sdbtools::SdbtModule::getInstance().writeComponentInfos(
+ static_cast<XMultiServiceFactory*>(pServiceManager),
+ static_cast<XRegistryKey*>(pRegistryKey));
+ }
+ catch (const InvalidRegistryException& )
+ {
+ OSL_ASSERT("sdbt::component_writeInfo: could not create a registry key (InvalidRegistryException) !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ Reference< XInterface > xRet;
+ if (pServiceManager && pImplementationName)
+ {
+ xRet = ::sdbtools::SdbtModule::getInstance().getComponentFactory(
+ ::rtl::OUString::createFromAscii(pImplementationName),
+ static_cast< XMultiServiceFactory* >(pServiceManager));
+ }
+
+ if (xRet.is())
+ xRet->acquire();
+ return xRet.get();
+};
+
diff --git a/dbaccess/source/sdbtools/resource/makefile.mk b/dbaccess/source/sdbtools/resource/makefile.mk
new file mode 100644
index 000000000000..9b55104c983d
--- /dev/null
+++ b/dbaccess/source/sdbtools/resource/makefile.mk
@@ -0,0 +1,45 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=$(PRJ)$/source
+PRJNAME=dbaccess
+TARGET=sdbt_resource
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+SRS1NAME=sdbt_strings
+SRC1FILES= \
+ sdbt_strings.src \
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
diff --git a/dbaccess/source/sdbtools/resource/sdbt_strings.src b/dbaccess/source/sdbtools/resource/sdbt_strings.src
new file mode 100644
index 000000000000..bd6d7d49f5c1
--- /dev/null
+++ b/dbaccess/source/sdbtools/resource/sdbt_strings.src
@@ -0,0 +1,65 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef DBACCESS_SDBT_RESOURCE_HRC
+#include "sdbt_resource.hrc"
+#endif
+
+String STR_QUERY_AND_TABLE_DISTINCT_NAMES
+{
+ Text [ en-US ] = "You cannot give a table and a query the same name. Please use a name which is not yet used by a query or table.";
+};
+
+String STR_BASENAME_TABLE
+{
+ Text [ en-US ] = "Table";
+};
+
+String STR_BASENAME_QUERY
+{
+ Text [ en-US ] = "Query";
+};
+
+String STR_CONN_WITHOUT_QUERIES_OR_TABLES
+{
+ Text [ en-US ] = "The given connection is no valid query and/or tables supplier.";
+};
+
+String STR_NO_TABLE_OBJECT
+{
+ Text [ en-US ] = "The given object is no table object.";
+};
+
+String STR_INVALID_COMPOSITION_TYPE
+{
+ Text [ en-US ] = "Invalid composition type - need a value from com.sun.star.sdb.tools.CompositionType.";
+};
+
+String STR_INVALID_COMMAND_TYPE
+{
+ Text [ en-US ] = "Invalid command type - only TABLE and QUERY from com.sun.star.sdb.CommandType are allowed.";
+};