summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dbaccess/source/core/api/TableDeco.cxx619
-rw-r--r--dbaccess/source/core/api/column.cxx15
-rw-r--r--dbaccess/source/core/api/makefile.mk5
-rw-r--r--dbaccess/source/core/api/querydescriptor.hxx8
-rw-r--r--dbaccess/source/core/api/table.cxx215
-rw-r--r--dbaccess/source/core/api/tablecontainer.cxx24
-rw-r--r--dbaccess/source/core/inc/TableDeco.hxx239
-rw-r--r--dbaccess/source/core/inc/column.hxx5
-rw-r--r--dbaccess/source/core/inc/table.hxx17
9 files changed, 951 insertions, 196 deletions
diff --git a/dbaccess/source/core/api/TableDeco.cxx b/dbaccess/source/core/api/TableDeco.cxx
new file mode 100644
index 000000000..6eaa67017
--- /dev/null
+++ b/dbaccess/source/core/api/TableDeco.cxx
@@ -0,0 +1,619 @@
+/*************************************************************************
+ *
+ * $RCSfile: TableDeco.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: oj $ $Date: 2001-04-20 13:09:46 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the License); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an AS IS basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _DBA_CORE_TABLEDECORATOR_HXX_
+#include "TableDeco.hxx"
+#endif
+#ifndef _DBACORE_DEFINITIONCOLUMN_HXX_
+#include <definitioncolumn.hxx>
+#endif
+#ifndef _DBA_SHARED_STUBS_HXX_
+#include "stubs.hxx"
+#endif
+#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
+#include "dbastrings.hrc"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
+#include <cppuhelper/typeprovider.hxx>
+#endif
+#ifndef _COMPHELPER_ENUMHELPER_HXX_
+#include <comphelper/enumhelper.hxx>
+#endif
+#ifndef _COMPHELPER_CONTAINER_HXX_
+#include <comphelper/container.hxx>
+#endif
+#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <comphelper/sequence.hxx>
+#endif
+#ifndef _COMPHELPER_PROPERTY_HXX_
+#include <comphelper/property.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XREFRESHLISTENER_HPP_
+#include <com/sun/star/util/XRefreshListener.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _DBHELPER_DBEXCEPTION_HXX_
+#include <connectivity/dbexception.hxx>
+#endif
+#ifndef _COMPHELPER_EXTRACT_HXX_
+#include <comphelper/extract.hxx>
+#endif
+
+using namespace dbaccess;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace ::osl;
+using namespace ::comphelper;
+using namespace ::cppu;
+
+//==========================================================================
+//= ODBTableDecorator
+//==========================================================================
+DBG_NAME(ODBTableDecorator)
+//--------------------------------------------------------------------------
+ODBTableDecorator::ODBTableDecorator(const OConfigurationNode& _rTableConfig,
+ const Reference< XDatabaseMetaData >& _rxMetaData,
+ const Reference< XColumnsSupplier >& _rxTable) throw(SQLException)
+ : OTableDescriptor_BASE(m_aMutex)
+ ,ODataSettings(OTableDescriptor_BASE::rBHelper)
+ ,OConfigurationFlushable(m_aMutex,_rTableConfig.cloneAsRoot())
+ ,m_nPrivileges(0)
+ ,m_xTable(_rxTable)
+ ,m_xMetaData(_rxMetaData)
+{
+ DBG_CTOR(ODBTableDecorator, NULL);
+ osl_incrementInterlockedCount( &m_refCount );
+
+ DBG_ASSERT(_rxMetaData.is(), "ODBTableDecorator::ODBTableDecorator : invalid conn !");
+ // register our properties
+ construct();
+
+ // load the settings from the configuration
+ if(m_aConfigurationNode.isValid())
+ loadFrom(m_aConfigurationNode.openNode(CONFIGKEY_SETTINGS));
+ // we don't collect the privileges here, this is potentially expensive. Instead we determine them on request.
+ // (see getFastPropertyValue)
+ m_nPrivileges = -1;
+ osl_decrementInterlockedCount( &m_refCount );
+
+ // TODO : think about collecting the privileges here, as we can't ensure that in getFastPropertyValue, where
+ // we do this at the moment, the statement needed can be supplied by the connection (for example the SQL-Server
+ // ODBC driver does not allow more than one statement per connection, and in getFastPropertyValue it's more
+ // likely that it's already used up than it's here.)
+}
+// -----------------------------------------------------------------------------
+ODBTableDecorator::ODBTableDecorator( const Reference< XDatabaseMetaData >& _rxMetaData,
+ const Reference< XColumnsSupplier >& _rxNewTable) throw(SQLException)
+ : OTableDescriptor_BASE(m_aMutex)
+ ,ODataSettings(OTableDescriptor_BASE::rBHelper)
+ ,OConfigurationFlushable(m_aMutex)
+ ,m_nPrivileges(-1)
+ ,m_xMetaData(_rxMetaData)
+ ,m_xTable(_rxNewTable)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+ODBTableDecorator::~ODBTableDecorator()
+{
+ DBG_DTOR(ODBTableDecorator, NULL);
+}
+
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > ODBTableDecorator::getImplementationId() throw (RuntimeException)
+{
+ static OImplementationId * pId = 0;
+ if (! pId)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// OComponentHelper
+//------------------------------------------------------------------------------
+void SAL_CALL ODBTableDecorator::disposing()
+{
+ OTableDescriptor_BASE::disposing();
+ OConfigurationFlushable::disposing();
+
+ MutexGuard aGuard(m_aMutex);
+ m_xTable = NULL;
+ m_xMetaData = NULL;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL ODBTableDecorator::convertFastPropertyValue(
+ Any & rConvertedValue,
+ Any & rOldValue,
+ sal_Int32 nHandle,
+ const Any& rValue )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ sal_Bool bRet = sal_True;
+ switch(nHandle)
+ {
+ case PROPERTY_ID_PRIVILEGES:
+ case PROPERTY_ID_FILTER:
+ case PROPERTY_ID_ORDER:
+ case PROPERTY_ID_APPLYFILTER:
+ case PROPERTY_ID_FONT:
+ case PROPERTY_ID_ROW_HEIGHT:
+ case PROPERTY_ID_TEXTCOLOR:
+ bRet = ODataSettings::convertFastPropertyValue(rConvertedValue, rOldValue,nHandle,rValue);
+ break;
+
+ default:
+ {
+ Any aValue;
+ getFastPropertyValue(aValue,nHandle);
+ bRet = ::comphelper::tryPropertyValue(rConvertedValue,rOldValue,rValue,aValue,::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ }
+ break; // we assume that it works
+ }
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+void ODBTableDecorator::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue) throw (Exception)
+{
+ switch(_nHandle)
+ {
+ case PROPERTY_ID_PRIVILEGES:
+ OSL_ENSURE(0,"Property is readonly!");
+ case PROPERTY_ID_FILTER:
+ case PROPERTY_ID_ORDER:
+ case PROPERTY_ID_APPLYFILTER:
+ case PROPERTY_ID_FONT:
+ case PROPERTY_ID_ROW_HEIGHT:
+ case PROPERTY_ID_TEXTCOLOR:
+ ODataSettings::setFastPropertyValue_NoBroadcast(_nHandle, _rValue);
+ break;
+ case PROPERTY_ID_CATALOGNAME:
+ {
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ xProp->setPropertyValue(PROPERTY_CATALOGNAME,_rValue);
+ }
+ break;
+ case PROPERTY_ID_SCHEMANAME:
+ {
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ xProp->setPropertyValue(PROPERTY_SCHEMANAME,_rValue);
+ }
+ break;
+ case PROPERTY_ID_NAME:
+ {
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ xProp->setPropertyValue(PROPERTY_NAME,_rValue);
+ }
+ break;
+ case PROPERTY_ID_DESCRIPTION:
+ {
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ xProp->setPropertyValue(PROPERTY_DESCRIPTION,_rValue);
+ }
+ break;
+ case PROPERTY_ID_TYPE:
+ {
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ xProp->setPropertyValue(PROPERTY_TYPE,_rValue);
+ }
+ break;
+ }
+}
+//------------------------------------------------------------------------------
+void ODBTableDecorator::getFastPropertyValue(Any& _rValue, sal_Int32 _nHandle) const
+{
+ switch(_nHandle)
+ {
+ case PROPERTY_ID_PRIVILEGES:
+ if(-1 == m_nPrivileges)
+ fillPrivileges();
+
+ case PROPERTY_ID_FILTER:
+ case PROPERTY_ID_ORDER:
+ case PROPERTY_ID_APPLYFILTER:
+ case PROPERTY_ID_FONT:
+ case PROPERTY_ID_ROW_HEIGHT:
+ case PROPERTY_ID_TEXTCOLOR:
+ ODataSettings::getFastPropertyValue(_rValue, _nHandle);
+ break;
+ case PROPERTY_ID_CATALOGNAME:
+ {
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ _rValue = xProp->getPropertyValue(PROPERTY_CATALOGNAME);
+ }
+ break;
+ case PROPERTY_ID_SCHEMANAME:
+ {
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ _rValue = xProp->getPropertyValue(PROPERTY_SCHEMANAME);
+ }
+ break;
+ case PROPERTY_ID_NAME:
+ {
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ _rValue = xProp->getPropertyValue(PROPERTY_NAME);
+ }
+ break;
+ case PROPERTY_ID_DESCRIPTION:
+ {
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ _rValue = xProp->getPropertyValue(PROPERTY_DESCRIPTION);
+ }
+ break;
+ case PROPERTY_ID_TYPE:
+ {
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ _rValue = xProp->getPropertyValue(PROPERTY_TYPE);
+ }
+ break;
+ }
+}
+// -------------------------------------------------------------------------
+void ODBTableDecorator::construct()
+{
+ registerProperty(PROPERTY_PRIVILEGES, PROPERTY_ID_PRIVILEGES, PropertyAttribute::BOUND | PropertyAttribute::READONLY,
+ &m_nPrivileges, ::getCppuType(static_cast<sal_Int32*>(NULL)));
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* ODBTableDecorator::createArrayHelper() const
+{
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ Reference<XPropertySetInfo> xInfo = xProp->getPropertySetInfo();
+
+ Sequence< Property > aTableProps = xInfo->getProperties();
+ Property* pBegin = aTableProps.getArray();
+ Property* pEnd = pBegin + aTableProps.getLength();
+ for (;pBegin != pEnd ; ++pBegin)
+ {
+ if(PROPERTY_CATALOGNAME == pBegin->Name)
+ pBegin->Handle = PROPERTY_ID_CATALOGNAME;
+ else if(PROPERTY_SCHEMANAME == pBegin->Name)
+ pBegin->Handle = PROPERTY_ID_SCHEMANAME;
+ else if(PROPERTY_NAME == pBegin->Name)
+ pBegin->Handle = PROPERTY_ID_NAME;
+ else if(PROPERTY_DESCRIPTION == pBegin->Name)
+ pBegin->Handle = PROPERTY_ID_DESCRIPTION;
+ else if(PROPERTY_TYPE == pBegin->Name)
+ pBegin->Handle = PROPERTY_ID_TYPE;
+ }
+
+ describeProperties(aTableProps);
+
+ return new ::cppu::OPropertyArrayHelper(aTableProps);
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & SAL_CALL ODBTableDecorator::getInfoHelper()
+{
+ return *ODBTableDecorator_PROP::getArrayHelper();
+}
+// -------------------------------------------------------------------------
+// XServiceInfo
+IMPLEMENT_SERVICE_INFO1(ODBTableDecorator, "com.sun.star.sdb.dbaccess.ODBTableDecorator", SERVICE_SDBCX_TABLE)
+// -------------------------------------------------------------------------
+Any SAL_CALL ODBTableDecorator::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet;
+ if(m_xTable.is())
+ aRet = m_xTable->queryInterface(rType);
+ if(!aRet.hasValue())
+ aRet = OConfigurationFlushable::queryInterface( rType);
+
+ return aRet;
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL ODBTableDecorator::getTypes( ) throw(RuntimeException)
+{
+ Reference<XTypeProvider> xTypes(m_xTable,UNO_QUERY);
+ OSL_ENSURE(xTypes.is(),"Table must be a TypePropvider!");
+ return ::comphelper::concatSequences(xTypes->getTypes(),OConfigurationFlushable::getTypes());
+}
+
+// -----------------------------------------------------------------------------
+void ODBTableDecorator::flush_NoBroadcast_NoCommit()
+{
+ if(m_aConfigurationNode.isValid())
+ {
+ storeTo(m_aConfigurationNode.openNode(CONFIGKEY_SETTINGS));
+ OColumns* pColumns = static_cast<OColumns*>(m_pColumns);
+ if(pColumns)
+ {
+ pColumns->storeSettings(m_aConfigurationNode.openNode(CONFIGKEY_QRYDESCR_COLUMNS));
+ }
+ }
+}
+// XRename,
+//------------------------------------------------------------------------------
+void SAL_CALL ODBTableDecorator::rename( const ::rtl::OUString& _rNewName ) throw(SQLException, ElementExistException, RuntimeException)
+{
+ Reference<XRename> xRename(m_xTable,UNO_QUERY);
+ if(xRename.is())
+ {
+ xRename->rename(_rNewName);
+ }
+ else // not supported
+ throw SQLException(::rtl::OUString::createFromAscii("Driver does not support this function!"),*this,::rtl::OUString::createFromAscii("IM001"),0,Any());
+}
+
+// XAlterTable,
+//------------------------------------------------------------------------------
+void SAL_CALL ODBTableDecorator::alterColumnByName( const ::rtl::OUString& _rName, const Reference< XPropertySet >& _rxDescriptor ) throw(SQLException, NoSuchElementException, RuntimeException)
+{
+ Reference<XAlterTable> xAlter(m_xTable,UNO_QUERY);
+ if(xAlter.is())
+ {
+ xAlter->alterColumnByName(_rName,_rxDescriptor);
+ }
+ else
+ // not supported
+ throw SQLException(::rtl::OUString::createFromAscii("Driver does not support this function!"),*this,::rtl::OUString::createFromAscii("IM001"),0,Any());
+ m_pColumns->refresh();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ODBTableDecorator::alterColumnByIndex( sal_Int32 _nIndex, const Reference< XPropertySet >& _rxDescriptor ) throw(SQLException, IndexOutOfBoundsException, RuntimeException)
+{
+ Reference<XAlterTable> xAlter(m_xTable,UNO_QUERY);
+ if(xAlter.is())
+ {
+ xAlter->alterColumnByIndex(_nIndex,_rxDescriptor);
+ m_pColumns->refresh();
+ }
+ else // not supported
+ throw SQLException(::rtl::OUString::createFromAscii("Driver does not support this function!"),*this,::rtl::OUString::createFromAscii("IM001"),0,Any());
+}
+// -----------------------------------------------------------------------------
+Reference< XNameAccess> ODBTableDecorator::getIndexes() throw (RuntimeException)
+{
+ return Reference< XIndexesSupplier>(m_xTable,UNO_QUERY)->getIndexes();
+}
+// -------------------------------------------------------------------------
+Reference< XIndexAccess> ODBTableDecorator::getKeys() throw (RuntimeException)
+{
+ return Reference< XKeysSupplier>(m_xTable,UNO_QUERY)->getKeys();
+}
+// -------------------------------------------------------------------------
+Reference< XNameAccess> ODBTableDecorator::getColumns() throw (RuntimeException)
+{
+ ::std::vector< ::rtl::OUString> aVector;
+
+ Reference<XNameAccess> xNames;
+ if(m_xTable.is())
+ {
+ xNames = m_xTable->getColumns();
+ if(xNames.is())
+ {
+ Sequence< ::rtl::OUString> aNames = xNames->getElementNames();
+ const ::rtl::OUString* pBegin = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + aNames.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ aVector.push_back(*pBegin);
+ }
+ }
+ OColumns* pCol = new OColumns(*this,m_aMutex,xNames,m_xMetaData->storesMixedCaseQuotedIdentifiers(),aVector,this,
+ m_xMetaData->supportsAlterTableWithAddColumn(),
+ m_xMetaData->supportsAlterTableWithDropColumn());
+ // pCol->setParent(this);
+
+ if(m_pColumns)
+ delete m_pColumns;
+
+ m_pColumns = pCol;
+ return m_pColumns;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODBTableDecorator::getName() throw(RuntimeException)
+{
+ Reference<XNamed> xName(m_xTable,UNO_QUERY);
+ OSL_ENSURE(xName.is(),"Table should support the XNamed interface");
+ return xName->getName();
+}
+// -----------------------------------------------------------------------------
+sal_Int64 SAL_CALL ODBTableDecorator::getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw(RuntimeException)
+{
+ sal_Int64 nRet = 0;
+ Reference<XUnoTunnel> xTunnel(m_xTable,UNO_QUERY);
+ if(xTunnel.is())
+ nRet = xTunnel->getSomething(aIdentifier);
+ return nRet;
+}
+// -----------------------------------------------------------------------------
+void ODBTableDecorator::fillPrivileges() const
+{
+ // somebody is asking for the privileges an we do not know them, yet
+ const_cast<ODBTableDecorator*>(this)->m_nPrivileges = 0; // don't allow anything if something goes wrong
+ try
+ {
+ Reference<XPropertySet> xProp(m_xTable,UNO_QUERY);
+ Any aVal = xProp->getPropertyValue(PROPERTY_CATALOGNAME);
+ ::rtl::OUString sSchema,sName;
+ xProp->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema;
+ xProp->getPropertyValue(PROPERTY_NAME) >>= sName;
+ Reference< XResultSet > xPrivileges = m_xMetaData->getTablePrivileges(aVal,sSchema,sName);
+ Reference< XRow > xCurrentRow(xPrivileges, UNO_QUERY);
+
+ if (xCurrentRow.is())
+ {
+ ::rtl::OUString sUserWorkingFor = m_xMetaData->getUserName();
+ // after creation the set is positioned before the first record, per definitionem
+
+ ::rtl::OUString sPrivilege, sGrantee;
+ while (xPrivileges->next())
+ {
+#ifdef DBG_UTIL
+ ::rtl::OUString sCat, sSchema, sName, sGrantor, sGrantable;
+ sCat = xCurrentRow->getString(1);
+ sSchema = xCurrentRow->getString(2);
+ sName = xCurrentRow->getString(3);
+ sGrantor = xCurrentRow->getString(4);
+#endif
+ sGrantee = xCurrentRow->getString(5);
+ sPrivilege = xCurrentRow->getString(6);
+#ifdef DBG_UTIL
+ sGrantable = xCurrentRow->getString(7);
+#endif
+
+ if (sUserWorkingFor != sGrantee)
+ continue;
+
+ if (sPrivilege.compareToAscii("SELECT") == 0)
+ const_cast<ODBTableDecorator*>(this)->m_nPrivileges |= Privilege::SELECT;
+ else if (sPrivilege.compareToAscii("INSERT") == 0)
+ const_cast<ODBTableDecorator*>(this)->m_nPrivileges |= Privilege::INSERT;
+ else if (sPrivilege.compareToAscii("UPDATE") == 0)
+ const_cast<ODBTableDecorator*>(this)->m_nPrivileges |= Privilege::UPDATE;
+ else if (sPrivilege.compareToAscii("DELETE") == 0)
+ const_cast<ODBTableDecorator*>(this)->m_nPrivileges |= Privilege::DELETE;
+ else if (sPrivilege.compareToAscii("READ") == 0)
+ const_cast<ODBTableDecorator*>(this)->m_nPrivileges |= Privilege::READ;
+ else if (sPrivilege.compareToAscii("CREATE") == 0)
+ const_cast<ODBTableDecorator*>(this)->m_nPrivileges |= Privilege::CREATE;
+ else if (sPrivilege.compareToAscii("ALTER") == 0)
+ const_cast<ODBTableDecorator*>(this)->m_nPrivileges |= Privilege::ALTER;
+ else if (sPrivilege.compareToAscii("REFERENCE") == 0)
+ const_cast<ODBTableDecorator*>(this)->m_nPrivileges |= Privilege::REFERENCE;
+ else if (sPrivilege.compareToAscii("DROP") == 0)
+ const_cast<ODBTableDecorator*>(this)->m_nPrivileges |= Privilege::DROP;
+ }
+ }
+ disposeComponent(xPrivileges);
+ }
+ catch(SQLException& e)
+ {
+ UNUSED(e);
+ DBG_ERROR("ODBTableDecorator::ODBTableDecorator : could not collect the privileges !");
+ }
+}
+// -----------------------------------------------------------------------------
+Reference< XPropertySet > SAL_CALL ODBTableDecorator::createDataDescriptor( ) throw (RuntimeException)
+{
+ Reference<XDataDescriptorFactory> xFactory(m_xTable,UNO_QUERY);
+ Reference< XPropertySet > xProp = xFactory->createDataDescriptor();
+ return new ODBTableDecorator(m_aConfigurationNode.cloneAsRoot(),m_xMetaData,Reference<XColumnsSupplier>(xProp,UNO_QUERY));
+}
+// -----------------------------------------------------------------------------
+Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL ODBTableDecorator::getPropertySetInfo( ) throw(RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+OColumn* ODBTableDecorator::createColumn(const ::rtl::OUString& _rName) const
+{
+ OColumn* pReturn = NULL;
+
+ Reference< XNamed > xRet = NULL;
+ Reference<XNameAccess> xNames;
+ if(m_xTable.is())
+ xNames = m_xTable->getColumns();
+ if(xNames.is() && xNames->hasByName(_rName))
+ {
+ Reference<XPropertySet> xProp;
+ xNames->getByName(_rName) >>= xProp;
+
+ pReturn = new OTableColumnWrapper(xProp);
+ }
+ return pReturn;
+}
+// -----------------------------------------------------------------------------
+Reference< XPropertySet > ODBTableDecorator::createEmptyObject()
+{
+ Reference<XDataDescriptorFactory> xNames;
+ if(m_xTable.is())
+ xNames = Reference<XDataDescriptorFactory>(m_xTable->getColumns(),UNO_QUERY);
+ Reference< XPropertySet > xRet;
+ if(xNames.is())
+ xRet = xNames->createDataDescriptor();
+ return xRet;
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/dbaccess/source/core/api/column.cxx b/dbaccess/source/core/api/column.cxx
index 2c7514498..5a1dabab5 100644
--- a/dbaccess/source/core/api/column.cxx
+++ b/dbaccess/source/core/api/column.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: column.cxx,v $
*
- * $Revision: 1.19 $
+ * $Revision: 1.20 $
*
- * last change: $Author: fs $ $Date: 2001-04-06 08:58:10 $
+ * last change: $Author: oj $ $Date: 2001-04-20 13:09:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -694,14 +694,12 @@ Reference< XNamed > OColumns::createObject(const ::rtl::OUString& _rName)
// -------------------------------------------------------------------------
Reference< XPropertySet > OColumns::createEmptyObject()
{
- OSL_ENSURE(sal_False, "Are not filled this way!");
- // connectivity::sdbcx::OColumn* pRet = new OTableColumnDescriptor(isCaseSensitive());
- OTableColumnDescriptor* pRet = new OTableColumnDescriptor();
- Reference< XPropertySet > xRet = pRet;
- return xRet;
+ if (m_pColFactoryImpl)
+ return m_pColFactoryImpl->createEmptyObject();
+ else
+ return Reference< XPropertySet >();
}
// -------------------------------------------------------------------------
-// -------------------------------------------------------------------------
Any SAL_CALL OColumns::queryInterface( const Type & rType ) throw(RuntimeException)
{
if(!m_pTable || (m_pTable && !m_pTable->isNew()))
@@ -873,6 +871,7 @@ void SAL_CALL OColumns::dropByIndex( sal_Int32 index ) throw(SQLException, Index
dropByName(m_aElements[index]->first);
}
+
/*
//============================================================
diff --git a/dbaccess/source/core/api/makefile.mk b/dbaccess/source/core/api/makefile.mk
index 396dfeab6..ea5b7358d 100644
--- a/dbaccess/source/core/api/makefile.mk
+++ b/dbaccess/source/core/api/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.6 $
+# $Revision: 1.7 $
#
-# last change: $Author: oj $ $Date: 2001-03-29 07:07:13 $
+# last change: $Author: oj $ $Date: 2001-04-20 13:09:11 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -74,6 +74,7 @@ ENABLE_EXCEPTIONS=TRUE
# --- Files -------------------------------------
SLOFILES= \
+ $(SLO)$/TableDeco.obj \
$(SLO)$/RowSetCacheIterator.obj \
$(SLO)$/RowSet.obj \
$(SLO)$/column.obj \
diff --git a/dbaccess/source/core/api/querydescriptor.hxx b/dbaccess/source/core/api/querydescriptor.hxx
index 7cd830007..bdb1487f0 100644
--- a/dbaccess/source/core/api/querydescriptor.hxx
+++ b/dbaccess/source/core/api/querydescriptor.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: querydescriptor.hxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: oj $ $Date: 2001-02-23 15:22:32 $
+ * last change: $Author: oj $ $Date: 2001-04-20 13:09:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -217,6 +217,10 @@ protected:
// IColumnFactory
virtual OColumn* createColumn(const ::rtl::OUString& _rName) const;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject()
+ {
+ return NULL;
+ }
virtual void readColumnSettings(const OConfigurationNode& _rConfigLocation);
protected:
diff --git a/dbaccess/source/core/api/table.cxx b/dbaccess/source/core/api/table.cxx
index 7150f6686..c9011abea 100644
--- a/dbaccess/source/core/api/table.cxx
+++ b/dbaccess/source/core/api/table.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: table.cxx,v $
*
- * $Revision: 1.20 $
+ * $Revision: 1.21 $
*
- * last change: $Author: fs $ $Date: 2001-04-19 07:13:59 $
+ * last change: $Author: oj $ $Date: 2001-04-20 13:09:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -142,8 +142,7 @@ typedef ::std::map <sal_Int32, OTableColumn*, std::less <sal_Int32> > OColMap;
DBG_NAME(ODBTable)
//--------------------------------------------------------------------------
ODBTable::ODBTable(const OConfigurationNode& _rTableConfig,
- const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxMetaData,
- const Reference< ::com::sun::star::sdbcx::XColumnsSupplier >& _rxTable,
+ const Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxMetaData,
const ::rtl::OUString& _rCatalog,
const ::rtl::OUString& _rSchema,
const ::rtl::OUString& _rName,
@@ -152,7 +151,6 @@ ODBTable::ODBTable(const OConfigurationNode& _rTableConfig,
: connectivity::sdbcx::OTable(_rxMetaData->storesMixedCaseQuotedIdentifiers(),_rName,_rType,_rDesc,_rSchema,_rCatalog)
,OConfigurationFlushable(m_aMutex,_rTableConfig.cloneAsRoot())
,m_nPrivileges(0)
- ,m_xTable(_rxTable)
,m_xMetaData(_rxMetaData)
{
DBG_CTOR(ODBTable, NULL);
@@ -188,13 +186,12 @@ ODBTable::ODBTable(const OConfigurationNode& _rTableConfig,
// likely that it's already used up than it's here.)
}
// -----------------------------------------------------------------------------
-ODBTable::ODBTable( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxMetaData,
- const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier >& _rxNewTable)
- throw(::com::sun::star::sdbc::SQLException) : connectivity::sdbcx::OTable(_rxMetaData->storesMixedCaseQuotedIdentifiers())
+ODBTable::ODBTable( const Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxMetaData)
+ throw(::com::sun::star::sdbc::SQLException)
+ : connectivity::sdbcx::OTable(_rxMetaData->storesMixedCaseQuotedIdentifiers())
,OConfigurationFlushable(m_aMutex)
,m_nPrivileges(-1)
,m_xMetaData(_rxMetaData)
- ,m_xTable(_rxNewTable)
{
construct();
}
@@ -285,7 +282,6 @@ void SAL_CALL ODBTable::disposing()
OConfigurationFlushable::disposing();
MutexGuard aGuard(m_aMutex);
- m_xTable = NULL;
m_xMetaData = NULL;
}
@@ -381,7 +377,7 @@ void ODBTable::construct()
registerMayBeVoidProperty(PROPERTY_TEXTCOLOR, PROPERTY_ID_TEXTCOLOR, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID,
&m_aTextColor, ::getCppuType(static_cast<sal_Int32*>(NULL)));
- registerProperty(PROPERTY_PRIVILEGES, PROPERTY_ID_PRIVILEGES, PropertyAttribute::BOUND ,
+ registerProperty(PROPERTY_PRIVILEGES, PROPERTY_ID_PRIVILEGES, PropertyAttribute::BOUND | PropertyAttribute::READONLY,
&m_nPrivileges, ::getCppuType(static_cast<sal_Int32*>(NULL)));
}
// -----------------------------------------------------------------------------
@@ -391,8 +387,8 @@ void ODBTable::construct()
describeProperties(aProps);
if(!_nId)
{
- ::com::sun::star::beans::Property* pBegin = aProps.getArray();
- ::com::sun::star::beans::Property* pEnd = pBegin + aProps.getLength();
+ Property* pBegin = aProps.getArray();
+ Property* pEnd = pBegin + aProps.getLength();
for(;pBegin != pEnd;++pBegin)
{
if(pBegin->Name == PROPERTY_CATALOGNAME)
@@ -420,20 +416,12 @@ IMPLEMENT_SERVICE_INFO1(ODBTable, "com.sun.star.sdb.dbaccess.ODBTable", SERVICE_
Any SAL_CALL ODBTable::queryInterface( const Type & rType ) throw(RuntimeException)
{
Any aRet;
- if(m_xTable.is())
- {
- aRet = m_xTable->queryInterface(rType);
- if(aRet.hasValue())
- aRet = OTable_Base::queryInterface( rType);
- }
- else
- {
- if(rType == getCppuType( (Reference<XRename>*)0))
- return Any();
- if(rType == getCppuType( (Reference<XAlterTable>*)0))
- return Any();
- aRet = OTable_Base::queryInterface( rType);
- }
+ if(rType == getCppuType( (Reference<XRename>*)0))
+ return Any();
+ if(rType == getCppuType( (Reference<XAlterTable>*)0))
+ return Any();
+ aRet = OTable_Base::queryInterface( rType);
+
if(!aRet.hasValue())
aRet = OConfigurationFlushable::queryInterface( rType);
@@ -442,53 +430,23 @@ Any SAL_CALL ODBTable::queryInterface( const Type & rType ) throw(RuntimeExcepti
// -------------------------------------------------------------------------
Sequence< Type > SAL_CALL ODBTable::getTypes( ) throw(RuntimeException)
{
- if(m_xTable.is())
- {
- Reference<XTypeProvider> xTypes(m_xTable,UNO_QUERY);
- OSL_ENSURE(xTypes.is(),"Table must be a TypePropvider!");
- return ::comphelper::concatSequences(xTypes->getTypes(),OConfigurationFlushable::getTypes());
- }
- else
- {
- Type aRenameType = getCppuType( (Reference<XRename>*)0);
- Type aAlterType = getCppuType( (Reference<XAlterTable>*)0);
+ Type aRenameType = getCppuType( (Reference<XRename>*)0);
+ Type aAlterType = getCppuType( (Reference<XAlterTable>*)0);
- Sequence< Type > aTypes(OTable_Base::getTypes());
- Sequence< Type > aRet(aTypes.getLength()-2);
+ Sequence< Type > aTypes(OTable_Base::getTypes());
+ Sequence< Type > aRet(aTypes.getLength()-2);
- const Type* pBegin = aTypes.getConstArray();
- const Type* pEnd = pBegin + aTypes.getLength();
- for(sal_Int32 i=0;pBegin != pEnd ;++pBegin)
+ const Type* pBegin = aTypes.getConstArray();
+ const Type* pEnd = pBegin + aTypes.getLength();
+ for(sal_Int32 i=0;pBegin != pEnd ;++pBegin)
+ {
+ if(*pBegin != aRenameType && *pBegin != aAlterType)
{
- if(*pBegin != aRenameType && *pBegin != aAlterType)
- {
- aRet.getArray()[i++] = *pBegin;
- }
+ aRet.getArray()[i++] = *pBegin;
}
- return ::comphelper::concatSequences(aRet,OConfigurationFlushable::getTypes());
}
+ return ::comphelper::concatSequences(aRet,OConfigurationFlushable::getTypes());
}
-
-// -----------------------------------------------------------------------------
-void ODBTable::setNew(sal_Bool _bNew)
-{
- if (getNew() == _bNew)
- // nothing to do
- return;
-
- OTable_Base::setNew(_bNew);
-
- // forward the new flag to our "aggregate"
- ::connectivity::sdbcx::ODescriptor* pAggDescriptor = NULL;
-
- Reference< XUnoTunnel > xAggTunnel(m_xTable,UNO_QUERY);
- if (xAggTunnel.is())
- pAggDescriptor = reinterpret_cast< ::connectivity::sdbcx::ODescriptor* >(xAggTunnel->getSomething(::connectivity::sdbcx::ODescriptor::getUnoTunnelImplementationId()));
-
- if (pAggDescriptor)
- pAggDescriptor->setNew(_bNew);
-}
-
// -----------------------------------------------------------------------------
void ODBTable::flush_NoBroadcast_NoCommit()
{
@@ -506,25 +464,14 @@ void ODBTable::flush_NoBroadcast_NoCommit()
//------------------------------------------------------------------------------
void SAL_CALL ODBTable::rename( const ::rtl::OUString& _rNewName ) throw(SQLException, ElementExistException, RuntimeException)
{
- Reference<XRename> xRename(m_xTable,UNO_QUERY);
- if(xRename.is())
- {
- xRename->rename(_rNewName);
- }
- else // not supported
- throw SQLException(::rtl::OUString::createFromAscii("Driver does not support this function!"),*this,::rtl::OUString::createFromAscii("IM001"),0,Any());
+ throw SQLException(::rtl::OUString::createFromAscii("Driver does not support this function!"),*this,::rtl::OUString::createFromAscii("IM001"),0,Any());
}
// XAlterTable,
//------------------------------------------------------------------------------
void SAL_CALL ODBTable::alterColumnByName( const ::rtl::OUString& _rName, const Reference< XPropertySet >& _rxDescriptor ) throw(SQLException, NoSuchElementException, RuntimeException)
{
- Reference<XAlterTable> xAlter(m_xTable,UNO_QUERY);
- if(xAlter.is())
- {
- xAlter->alterColumnByName(_rName,_rxDescriptor);
- }
- else if(m_pColumns->hasByName(_rName))
+ if(m_pColumns->hasByName(_rName))
{
::rtl::OUString sSql = ::rtl::OUString::createFromAscii("ALTER TABLE ");
::rtl::OUString aQuote = m_xMetaData->getIdentifierQuoteString( );
@@ -579,13 +526,7 @@ void SAL_CALL ODBTable::alterColumnByName( const ::rtl::OUString& _rName, const
//------------------------------------------------------------------------------
void SAL_CALL ODBTable::alterColumnByIndex( sal_Int32 _nIndex, const Reference< XPropertySet >& _rxDescriptor ) throw(SQLException, IndexOutOfBoundsException, RuntimeException)
{
- Reference<XAlterTable> xAlter(m_xTable,UNO_QUERY);
- if(xAlter.is())
- {
- xAlter->alterColumnByIndex(_nIndex,_rxDescriptor);
- m_pColumns->refresh();
- }
- else if(_nIndex < m_pColumns->getCount())
+ if(_nIndex < m_pColumns->getCount())
{
Reference<XPropertySet> xColumn;
m_pColumns->getByIndex(_nIndex) >>= xColumn;
@@ -599,19 +540,8 @@ void ODBTable::refreshColumns()
{
::std::vector< ::rtl::OUString> aVector;
- if(m_xTable.is())
- {
- m_xDriverColumns = m_xTable->getColumns();
- if(m_xDriverColumns.is())
- {
- Sequence< ::rtl::OUString> aNames = m_xDriverColumns->getElementNames();
- const ::rtl::OUString* pBegin = aNames.getConstArray();
- const ::rtl::OUString* pEnd = pBegin + aNames.getLength();
- for(;pBegin != pEnd;++pBegin)
- aVector.push_back(*pBegin);
- }
- }
- else if(!isNew())
+ Reference<XNameAccess> xNames;
+ if(!isNew())
{
Any aVal;
if(m_CatalogName.getLength())
@@ -628,7 +558,7 @@ void ODBTable::refreshColumns()
}
- OColumns* pCol = new OColumns(*this, m_aMutex, m_xDriverColumns, isCaseSensitive(), aVector, this,
+ OColumns* pCol = new OColumns(*this, m_aMutex, xNames, isCaseSensitive(), aVector, this,
m_xMetaData->supportsAlterTableWithAddColumn(),
m_xMetaData->supportsAlterTableWithDropColumn());
pCol->setParent(this);
@@ -678,23 +608,7 @@ void ODBTable::refreshKeys()
{
::std::vector< ::rtl::OUString> aVector;
Reference<XIndexAccess> xKeys;
- Reference<XKeysSupplier> xKeysSup(m_xTable,UNO_QUERY);
- if(xKeysSup.is())
- {
- xKeys = xKeysSup->getKeys();
- if(xKeys.is())
- {
- sal_Int32 nCount = xKeys->getCount();
- for(sal_Int32 i=0;i<nCount;++i)
- {
- Reference<XPropertySet> xKey;
- ::cppu::extractInterface(xKey,xKeys->getByIndex(i));
- if(xKey.is())
- aVector.push_back(::comphelper::getString(xKey->getPropertyValue(PROPERTY_NAME)));
- }
- }
- }
- else if(!isNew())
+ if(!isNew())
{
try { refreshPrimaryKeys(aVector); }
catch(SQLException&)
@@ -719,38 +633,25 @@ void ODBTable::refreshIndexes()
{
::std::vector< ::rtl::OUString> aVector;
Reference<XNameAccess> xNames;
- Reference<XIndexesSupplier> xIndexSup(m_xTable,UNO_QUERY);
- if(m_xTable.is() && xIndexSup.is())
- {
- xNames = xIndexSup->getIndexes();
- Sequence< ::rtl::OUString> aNames = xNames->getElementNames();
- const ::rtl::OUString* pBegin = aNames.getConstArray();
- const ::rtl::OUString* pEnd = pBegin + aNames.getLength();
- for(;pBegin != pEnd;++pBegin)
- aVector.push_back(*pBegin);
- }
- else
- {
- Any aVal;
- if(m_CatalogName.getLength())
- aVal <<= m_CatalogName;
+ Any aVal;
+ if(m_CatalogName.getLength())
+ aVal <<= m_CatalogName;
- // fill indexes
- Reference< XResultSet > xResult = m_xMetaData->getIndexInfo(aVal,m_SchemaName,m_Name,sal_False,sal_False);
+ // fill indexes
+ Reference< XResultSet > xResult = m_xMetaData->getIndexInfo(aVal,m_SchemaName,m_Name,sal_False,sal_False);
- if(xResult.is())
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ ::rtl::OUString aName,aDot = ::rtl::OUString::createFromAscii(".");
+ while(xResult->next())
{
- Reference< XRow > xRow(xResult,UNO_QUERY);
- ::rtl::OUString aName,aDot = ::rtl::OUString::createFromAscii(".");
- while(xResult->next())
- {
- aName = xRow->getString(5);
- if(aName.getLength())
- aName += aDot;
- aName += xRow->getString(6);
- if(aName.getLength())
- aVector.push_back(aName);
- }
+ aName = xRow->getString(5);
+ if(aName.getLength())
+ aName += aDot;
+ aName += xRow->getString(6);
+ if(aName.getLength())
+ aVector.push_back(aName);
}
}
@@ -767,16 +668,16 @@ void ODBTable::refreshIndexes()
return aVal;
}
// -----------------------------------------------------------------------------
-sal_Int64 SAL_CALL ODBTable::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException)
+sal_Int64 SAL_CALL ODBTable::getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw(RuntimeException)
{
- sal_Int64 nRet = OTable_Base::getSomething(aIdentifier);
- if(nRet == 0)
- {
- Reference<XUnoTunnel> xTunnel(m_xTable,UNO_QUERY);
- if(xTunnel.is())
- nRet = xTunnel->getSomething(aIdentifier);
- }
- return nRet;
+ return OTable_Base::getSomething(aIdentifier);
+}
+// -----------------------------------------------------------------------------
+Reference< XPropertySet > ODBTable::createEmptyObject()
+{
+ OTableColumnDescriptor* pRet = new OTableColumnDescriptor();
+ Reference< XPropertySet > xRet = pRet;
+ return xRet;
}
// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/core/api/tablecontainer.cxx b/dbaccess/source/core/api/tablecontainer.cxx
index 73e504b92..093745208 100644
--- a/dbaccess/source/core/api/tablecontainer.cxx
+++ b/dbaccess/source/core/api/tablecontainer.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: tablecontainer.cxx,v $
*
- * $Revision: 1.17 $
+ * $Revision: 1.18 $
*
- * last change: $Author: fs $ $Date: 2001-04-19 07:14:49 $
+ * last change: $Author: oj $ $Date: 2001-04-20 13:09:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -124,6 +124,9 @@
#ifndef _DBHELPER_DBEXCEPTION_HXX_
#include <connectivity/dbexception.hxx>
#endif
+#ifndef _DBA_CORE_TABLEDECORATOR_HXX_
+#include "TableDeco.hxx"
+#endif
using namespace dbaccess;
using namespace dbtools;
@@ -468,14 +471,7 @@ Reference< XNamed > OTableContainer::createObject(const ::rtl::OUString& _rName)
}
if(xProp.is())
- return new ODBTable(aTableConfig,
- m_xMetaData,
- xSup,
- sCatalog,
- sSchema,
- sTable,
- ::comphelper::getString(xProp->getPropertyValue(PROPERTY_TYPE)),
- ::comphelper::getString(xProp->getPropertyValue(PROPERTY_DESCRIPTION)));
+ return new ODBTableDecorator(aTableConfig,m_xMetaData,xSup);
else
{
Any aCatalog;
@@ -495,7 +491,6 @@ Reference< XNamed > OTableContainer::createObject(const ::rtl::OUString& _rName)
::comphelper::disposeComponent(xRes);
return new ODBTable(aTableConfig,
m_xMetaData,
- xSup,
sCatalog,
sSchema,
sTable,
@@ -512,9 +507,12 @@ Reference< XPropertySet > OTableContainer::createEmptyObject()
Reference<XColumnsSupplier > xMasterColumnsSup;
Reference<XDataDescriptorFactory> xDataFactory(m_xMasterTables,UNO_QUERY);
if(xDataFactory.is())
+ {
xMasterColumnsSup = Reference<XColumnsSupplier >(xDataFactory->createDataDescriptor(),UNO_QUERY);
-
- xRet = new ODBTable(m_xMetaData,xMasterColumnsSup);
+ xRet = new ODBTableDecorator(m_xMetaData,xMasterColumnsSup);
+ }
+ else
+ xRet = new ODBTable(m_xMetaData);
return xRet;
}
// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/core/inc/TableDeco.hxx b/dbaccess/source/core/inc/TableDeco.hxx
new file mode 100644
index 000000000..66dcc1e72
--- /dev/null
+++ b/dbaccess/source/core/inc/TableDeco.hxx
@@ -0,0 +1,239 @@
+/*************************************************************************
+ *
+ * $RCSfile: TableDeco.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: oj $ $Date: 2001-04-20 13:09:53 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _DBA_CORE_TABLEDECORATOR_HXX_
+#define _DBA_CORE_TABLEDECORATOR_HXX_
+
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XINDEXESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XRENAME_HPP_
+#include <com/sun/star/sdbcx/XRename.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XALTERTABLE_HPP_
+#include <com/sun/star/sdbcx/XAlterTable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
+#include <com/sun/star/sdbc/XConnection.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#endif
+#ifndef _CPPUHELPER_COMPBASE4_HXX_
+#include <cppuhelper/compbase4.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE5_HXX_
+#include <cppuhelper/implbase5.hxx>
+#endif
+#ifndef _DBASHARED_APITOOLS_HXX_
+#include "apitools.hxx"
+#endif
+#ifndef _DBA_CORE_DATASETTINGS_HXX_
+#include "datasettings.hxx"
+#endif
+#ifndef _DBA_COREAPI_COLUMN_HXX_
+#include <column.hxx>
+#endif
+#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
+#include <connectivity/CommonTools.hxx>
+#endif
+#ifndef _DBA_CORE_CONFIGURATIONFLUSHABLE_HXX_
+#include "configurationflushable.hxx"
+#endif
+
+namespace dbaccess
+{
+ typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::sdbcx::XColumnsSupplier,
+ ::com::sun::star::sdbcx::XKeysSupplier,
+ ::com::sun::star::container::XNamed,
+ ::com::sun::star::lang::XServiceInfo> OTableDescriptor_BASE;
+
+ typedef ::cppu::ImplHelper5< ::com::sun::star::sdbcx::XDataDescriptorFactory,
+ ::com::sun::star::sdbcx::XIndexesSupplier,
+ ::com::sun::star::sdbcx::XRename,
+ ::com::sun::star::sdbcx::XAlterTable,
+ ::com::sun::star::lang::XUnoTunnel> OTable_BASE;
+ //==========================================================================
+ //= OTables
+ //==========================================================================
+ class ODBTableDecorator;
+ typedef ::comphelper::OPropertyArrayUsageHelper< ODBTableDecorator > ODBTableDecorator_PROP;
+
+ class ODBTableDecorator :public comphelper::OBaseMutex
+ ,public ODataSettings //ODataSettings_Base
+ ,public OConfigurationFlushable
+ ,public OTable_BASE
+ ,public OTableDescriptor_BASE
+ ,public IColumnFactory
+ ,public ODBTableDecorator_PROP
+ {
+ void fillPrivileges() const;
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier > m_xTable;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+ // <properties>
+ sal_Int32 m_nPrivileges;
+ // </properties>
+ ::connectivity::sdbcx::OCollection* m_pColumns;
+
+ // IColumnFactory
+ virtual OColumn* createColumn(const ::rtl::OUString& _rName) const;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject();
+
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+ // OConfigurationFlushable
+ virtual void flush_NoBroadcast_NoCommit();
+
+ // OPropertySetHelper
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(
+ ::com::sun::star::uno::Any & rConvertedValue,
+ ::com::sun::star::uno::Any & rOldValue,
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue )
+ throw (::com::sun::star::lang::IllegalArgumentException);
+ virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle) const;
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue
+ )
+ throw (::com::sun::star::uno::Exception);
+ public:
+ /** constructs a wrapper supporting the com.sun.star.sdb.Table service.<BR>
+ @param _rxConn the connection the table belongs to
+ @param _rxTable the table from the driver can be null
+ */
+ ODBTableDecorator(const OConfigurationNode& _rTableConfig,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxConn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier >& _rxTable)
+ throw(::com::sun::star::sdbc::SQLException);
+
+ ODBTableDecorator( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxConn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier >& _rxNewTable)
+ throw(::com::sun::star::sdbc::SQLException);
+ virtual ~ODBTableDecorator();
+
+ // ODescriptor
+ virtual void construct();
+
+ //XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ //XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ // ::com::sun::star::lang::XServiceInfo
+ DECLARE_SERVICE_INFO();
+ // XInterface
+ DECLARE_CTY_DEFAULTS(OTableDescriptor_BASE);
+
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+ // ::com::sun::star::sdbcx::XRename,
+ virtual void SAL_CALL rename( const ::rtl::OUString& _rNewName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::sdbcx::XAlterTable,
+ virtual void SAL_CALL alterColumnByName( const ::rtl::OUString& _rName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDescriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL alterColumnByIndex( sal_Int32 _nIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDescriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+
+ // XNamed
+ virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ }
+ // com::sun::star::lang::XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() const { return m_xMetaData; }
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection() const { return m_xMetaData->getConnection(); }
+
+ // XColumnsSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ) throw (::com::sun::star::uno::RuntimeException);
+ // XKeysSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getKeys( ) throw (::com::sun::star::uno::RuntimeException);
+ // XIndexesSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getIndexes( ) throw (::com::sun::star::uno::RuntimeException);
+ // XDataDescriptorFactory
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( ) throw (::com::sun::star::uno::RuntimeException);
+ };
+}
+#endif // _DBA_CORE_TABLEDECORATOR_HXX_
+
+
diff --git a/dbaccess/source/core/inc/column.hxx b/dbaccess/source/core/inc/column.hxx
index 0799a5ec0..b80c5ef64 100644
--- a/dbaccess/source/core/inc/column.hxx
+++ b/dbaccess/source/core/inc/column.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: column.hxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: fs $ $Date: 2001-04-06 08:56:46 $
+ * last change: $Author: oj $ $Date: 2001-04-20 13:09:12 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -272,6 +272,7 @@ namespace dbaccess
{
public:
virtual OColumn* createColumn(const ::rtl::OUString& _rName) const = 0;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject() = 0;
};
//============================================================
diff --git a/dbaccess/source/core/inc/table.hxx b/dbaccess/source/core/inc/table.hxx
index 8285dde73..0121236d4 100644
--- a/dbaccess/source/core/inc/table.hxx
+++ b/dbaccess/source/core/inc/table.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: table.hxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: fs $ $Date: 2001-04-06 08:56:23 $
+ * last change: $Author: oj $ $Date: 2001-04-20 13:09:12 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -130,8 +130,6 @@ namespace dbaccess
,public IColumnFactory
{
protected:
- // OWeakConnection m_aConnection;
- ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier > m_xTable;
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xDriverColumns;
@@ -147,12 +145,9 @@ namespace dbaccess
// OConfigurationFlushable
virtual void flush_NoBroadcast_NoCommit();
- // ODescriptor
- virtual void setNew(sal_Bool _bNew);
-
// IColumnFactory
virtual OColumn* createColumn(const ::rtl::OUString& _rName) const;
-
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject();
public:
/** constructs a wrapper supporting the com.sun.star.sdb.Table service.<BR>
@param _rxConn the connection the table belongs to
@@ -165,14 +160,12 @@ namespace dbaccess
*/
ODBTable(const OConfigurationNode& _rTableConfig,
const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxConn,
- const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier >& _rxTable,
const ::rtl::OUString& _rCatalog, const ::rtl::OUString& _rSchema, const ::rtl::OUString& _rName,
const ::rtl::OUString& _rType, const ::rtl::OUString& _rDesc)
throw(::com::sun::star::sdbc::SQLException);
- ODBTable( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxConn,
- const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier >& _rxNewTable)
- throw(::com::sun::star::sdbc::SQLException);
+ ODBTable(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxConn)
+ throw(::com::sun::star::sdbc::SQLException);
virtual ~ODBTable();
// ODescriptor