summaryrefslogtreecommitdiff
path: root/dbaccess/source/sdbtools/connection
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/sdbtools/connection')
-rw-r--r--dbaccess/source/sdbtools/connection/connectiondependent.hxx158
-rw-r--r--dbaccess/source/sdbtools/connection/connectiontools.cxx189
-rw-r--r--dbaccess/source/sdbtools/connection/connectiontools.hxx111
-rw-r--r--dbaccess/source/sdbtools/connection/datasourcemetadata.cxx89
-rw-r--r--dbaccess/source/sdbtools/connection/datasourcemetadata.hxx94
-rw-r--r--dbaccess/source/sdbtools/connection/objectnames.cxx494
-rw-r--r--dbaccess/source/sdbtools/connection/objectnames.hxx100
-rw-r--r--dbaccess/source/sdbtools/connection/tablename.cxx278
-rw-r--r--dbaccess/source/sdbtools/connection/tablename.hxx105
9 files changed, 0 insertions, 1618 deletions
diff --git a/dbaccess/source/sdbtools/connection/connectiondependent.hxx b/dbaccess/source/sdbtools/connection/connectiondependent.hxx
deleted file mode 100644
index 12aa55645..000000000
--- a/dbaccess/source/sdbtools/connection/connectiondependent.hxx
+++ /dev/null
@@ -1,158 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * 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
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/sdbtools/connection/connectiontools.cxx b/dbaccess/source/sdbtools/connection/connectiontools.cxx
deleted file mode 100644
index cba20331f..000000000
--- a/dbaccess/source/sdbtools/connection/connectiontools.cxx
+++ /dev/null
@@ -1,189 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * 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 "connectiontools.hxx"
-
-#include "tablename.hxx"
-#include "objectnames.hxx"
-#include "datasourcemetadata.hxx"
-
-/** === begin UNO includes === **/
-/** === end UNO includes === **/
-
-#include <comphelper/namedvaluecollection.hxx>
-
-#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
-//........................................................................
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/sdbtools/connection/connectiontools.hxx b/dbaccess/source/sdbtools/connection/connectiontools.hxx
deleted file mode 100644
index a85ade702..000000000
--- a/dbaccess/source/sdbtools/connection/connectiontools.hxx
+++ /dev/null
@@ -1,111 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * 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
-
-#include "module_sdbt.hxx"
-
-#include "connectiondependent.hxx"
-
-/** === begin UNO includes === **/
-#include <com/sun/star/sdb/tools/XConnectionTools.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-/** === end UNO includes === **/
-
-#include <cppuhelper/implbase3.hxx>
-
-#include <comphelper/componentcontext.hxx>
-
-//........................................................................
-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
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/sdbtools/connection/datasourcemetadata.cxx b/dbaccess/source/sdbtools/connection/datasourcemetadata.cxx
deleted file mode 100644
index 169230063..000000000
--- a/dbaccess/source/sdbtools/connection/datasourcemetadata.cxx
+++ /dev/null
@@ -1,89 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * 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 "datasourcemetadata.hxx"
-
-/** === begin UNO includes === **/
-#include <com/sun/star/lang/NullPointerException.hpp>
-/** === end UNO includes === **/
-
-#include <connectivity/dbmetadata.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;
- /** === 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
-//........................................................................
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/sdbtools/connection/datasourcemetadata.hxx b/dbaccess/source/sdbtools/connection/datasourcemetadata.hxx
deleted file mode 100644
index 41f19047b..000000000
--- a/dbaccess/source/sdbtools/connection/datasourcemetadata.hxx
+++ /dev/null
@@ -1,94 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * 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
-
-#include "connectiondependent.hxx"
-
-/** === begin UNO includes === **/
-#include <com/sun/star/sdb/tools/XDataSourceMetaData.hpp>
-/** === end UNO includes === **/
-
-#include <cppuhelper/implbase1.hxx>
-
-#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
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/sdbtools/connection/objectnames.cxx b/dbaccess/source/sdbtools/connection/objectnames.cxx
deleted file mode 100644
index d8aadca8c..000000000
--- a/dbaccess/source/sdbtools/connection/objectnames.cxx
+++ /dev/null
@@ -1,494 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * 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 "objectnames.hxx"
-
-#include "module_sdbt.hxx"
-#include "sdbt_resource.hrc"
-
-/** === 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 ) // 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
-//........................................................................
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/sdbtools/connection/objectnames.hxx b/dbaccess/source/sdbtools/connection/objectnames.hxx
deleted file mode 100644
index 4a9609a0d..000000000
--- a/dbaccess/source/sdbtools/connection/objectnames.hxx
+++ /dev/null
@@ -1,100 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * 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
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/sdbtools/connection/tablename.cxx b/dbaccess/source/sdbtools/connection/tablename.cxx
deleted file mode 100644
index 6faada417..000000000
--- a/dbaccess/source/sdbtools/connection/tablename.cxx
+++ /dev/null
@@ -1,278 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * 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>
-#include <sal/macros.h>
-
-//........................................................................
-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 CompositionType 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 < SAL_N_ELEMENTS( TypeTable ) ) && !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
-//........................................................................
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/sdbtools/connection/tablename.hxx b/dbaccess/source/sdbtools/connection/tablename.hxx
deleted file mode 100644
index 073a6ed34..000000000
--- a/dbaccess/source/sdbtools/connection/tablename.hxx
+++ /dev/null
@@ -1,105 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * 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
-
-#include "connectiondependent.hxx"
-
-/** === begin UNO includes === **/
-#include <com/sun/star/sdb/tools/XTableName.hpp>
-/** === end UNO includes === **/
-
-#include <cppuhelper/implbase1.hxx>
-
-#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
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */