summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2010-08-10 14:53:21 +0200
committerFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2010-08-10 14:53:21 +0200
commitadaa62d63307602bfb940d42a8ad7d960d3fc0b2 (patch)
treef951b731e8c633680252acbb898534a4badb166b /dbaccess
parent2fbec17c655c59232ba4b9f3ea3665507ba99d53 (diff)
parent4022fd7a19b70988893bab117d83fde3919cc3a0 (diff)
merging in latest changes from OOO330(m3)
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/source/core/api/KeySet.cxx524
-rw-r--r--dbaccess/source/core/api/KeySet.hxx26
-rw-r--r--dbaccess/source/core/api/OptimisticSet.cxx939
-rw-r--r--dbaccess/source/core/api/OptimisticSet.hxx99
-rw-r--r--dbaccess/source/core/api/PrivateRow.cxx142
-rw-r--r--dbaccess/source/core/api/PrivateRow.hxx69
-rw-r--r--dbaccess/source/core/api/RowSet.cxx3
-rw-r--r--dbaccess/source/core/api/RowSetCache.cxx26
-rw-r--r--dbaccess/source/core/api/WrappedResultSet.cxx23
-rw-r--r--dbaccess/source/core/api/makefile.mk1
-rw-r--r--dbaccess/source/core/dataaccess/datasource.cxx37
-rw-r--r--dbaccess/source/core/inc/DatabaseDataProvider.hxx2
-rw-r--r--dbaccess/source/core/misc/DatabaseDataProvider.cxx31
-rw-r--r--dbaccess/source/inc/OAuthenticationContinuation.hxx82
-rw-r--r--dbaccess/source/ui/browser/brwctrlr.cxx1
-rw-r--r--dbaccess/source/ui/browser/unodatbr.cxx4
-rw-r--r--dbaccess/source/ui/dlg/DbAdminImpl.cxx84
-rw-r--r--dbaccess/source/ui/inc/TableController.hxx2
-rw-r--r--dbaccess/source/ui/inc/unodatbr.hxx2
-rw-r--r--dbaccess/source/ui/misc/TokenWriter.cxx4
-rw-r--r--dbaccess/source/ui/tabledesign/TEditControl.cxx3
-rw-r--r--dbaccess/source/ui/tabledesign/TableController.cxx15
-rw-r--r--dbaccess/source/ui/uno/dbinteraction.cxx3
23 files changed, 724 insertions, 1398 deletions
diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx
index 3db4acdbc..3de3133bc 100644
--- a/dbaccess/source/core/api/KeySet.cxx
+++ b/dbaccess/source/core/api/KeySet.cxx
@@ -53,9 +53,6 @@
#ifndef _COM_SUN_STAR_SDBC_XGENERATEDRESULTSET_HPP_
#include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
#endif
-#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_
-#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
-#endif
#ifndef _COM_SUN_STAR_SDBC_XCOLUMNLOCATE_HPP_
#include <com/sun/star/sdbc/XColumnLocate.hpp>
#endif
@@ -112,6 +109,7 @@
#endif
#include <string.h>
#include <rtl/logfile.hxx>
+#include "PrivateRow.hxx"
using namespace dbaccess;
using namespace ::connectivity;
@@ -148,134 +146,6 @@ namespace
}
}
}
- class OPrivateRow : public ::cppu::WeakImplHelper1<XRow>
- {
- ORowSetValueVector::Vector m_aRow;
- sal_Int32 m_nPos;
- public:
- OPrivateRow(const ORowSetValueVector::Vector& i_aRow) : m_aRow(i_aRow),m_nPos(0)
- {
- }
- virtual ::sal_Bool SAL_CALL wasNull( ) throw (SQLException, RuntimeException);
- virtual ::rtl::OUString SAL_CALL getString( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException);
- virtual ::sal_Bool SAL_CALL getBoolean( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException);
- virtual ::sal_Int8 SAL_CALL getByte( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException);
- virtual ::sal_Int16 SAL_CALL getShort( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException);
- virtual ::sal_Int32 SAL_CALL getInt( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException);
- virtual ::sal_Int64 SAL_CALL getLong( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException);
- virtual float SAL_CALL getFloat( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException);
- virtual double SAL_CALL getDouble( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException);
- virtual Sequence< ::sal_Int8 > SAL_CALL getBytes( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException);
- virtual ::com::sun::star::util::Date SAL_CALL getDate( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException);
- virtual ::com::sun::star::util::Time SAL_CALL getTime( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException);
- virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException);
- virtual Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException);
- virtual Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException);
- virtual Any SAL_CALL getObject( ::sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw (SQLException, RuntimeException);
- virtual Reference< XRef > SAL_CALL getRef( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException);
- virtual Reference< XBlob > SAL_CALL getBlob( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException);
- virtual Reference< XClob > SAL_CALL getClob( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException);
- virtual Reference< XArray > SAL_CALL getArray( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException);
- };
- ::sal_Bool SAL_CALL OPrivateRow::wasNull( ) throw (SQLException, RuntimeException)
- {
- return m_aRow[m_nPos].isNull();
- }
- ::rtl::OUString SAL_CALL OPrivateRow::getString( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
- {
- m_nPos = columnIndex;
- return m_aRow[m_nPos];
- }
- ::sal_Bool SAL_CALL OPrivateRow::getBoolean( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
- {
- m_nPos = columnIndex;
- return m_aRow[m_nPos];
- }
- ::sal_Int8 SAL_CALL OPrivateRow::getByte( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
- {
- m_nPos = columnIndex;
- return m_aRow[m_nPos];
- }
- ::sal_Int16 SAL_CALL OPrivateRow::getShort( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
- {
- m_nPos = columnIndex;
- return m_aRow[m_nPos];
- }
- ::sal_Int32 SAL_CALL OPrivateRow::getInt( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
- {
- m_nPos = columnIndex;
- return m_aRow[m_nPos];
- }
- ::sal_Int64 SAL_CALL OPrivateRow::getLong( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
- {
- m_nPos = columnIndex;
- return m_aRow[m_nPos];
- }
- float SAL_CALL OPrivateRow::getFloat( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
- {
- m_nPos = columnIndex;
- return m_aRow[m_nPos];
- }
- double SAL_CALL OPrivateRow::getDouble( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
- {
- m_nPos = columnIndex;
- return m_aRow[m_nPos];
- }
- Sequence< ::sal_Int8 > SAL_CALL OPrivateRow::getBytes( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
- {
- m_nPos = columnIndex;
- return m_aRow[m_nPos];
- }
- ::com::sun::star::util::Date SAL_CALL OPrivateRow::getDate( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
- {
- m_nPos = columnIndex;
- return m_aRow[m_nPos];
- }
- ::com::sun::star::util::Time SAL_CALL OPrivateRow::getTime( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
- {
- m_nPos = columnIndex;
- return m_aRow[m_nPos];
- }
- ::com::sun::star::util::DateTime SAL_CALL OPrivateRow::getTimestamp( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
- {
- m_nPos = columnIndex;
- return m_aRow[m_nPos];
- }
- Reference< ::com::sun::star::io::XInputStream > SAL_CALL OPrivateRow::getBinaryStream( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
- {
- m_nPos = columnIndex;
- return Reference< ::com::sun::star::io::XInputStream >(m_aRow[m_nPos].makeAny(),UNO_QUERY);
- }
- Reference< ::com::sun::star::io::XInputStream > SAL_CALL OPrivateRow::getCharacterStream( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
- {
- m_nPos = columnIndex;
- return Reference< ::com::sun::star::io::XInputStream >(m_aRow[m_nPos].makeAny(),UNO_QUERY);
- }
- Any SAL_CALL OPrivateRow::getObject( ::sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& ) throw (SQLException, RuntimeException)
- {
- m_nPos = columnIndex;
- return m_aRow[m_nPos].makeAny();
- }
- Reference< XRef > SAL_CALL OPrivateRow::getRef( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
- {
- m_nPos = columnIndex;
- return Reference< XRef >(m_aRow[m_nPos].makeAny(),UNO_QUERY);
- }
- Reference< XBlob > SAL_CALL OPrivateRow::getBlob( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
- {
- m_nPos = columnIndex;
- return Reference< XBlob >(m_aRow[m_nPos].makeAny(),UNO_QUERY);
- }
- Reference< XClob > SAL_CALL OPrivateRow::getClob( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
- {
- m_nPos = columnIndex;
- return Reference< XClob >(m_aRow[m_nPos].makeAny(),UNO_QUERY);
- }
- Reference< XArray > SAL_CALL OPrivateRow::getArray( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
- {
- m_nPos = columnIndex;
- return Reference< XArray >(m_aRow[m_nPos].makeAny(),UNO_QUERY);
- }
}
DBG_NAME(OKeySet)
// -------------------------------------------------------------------------
@@ -315,29 +185,41 @@ OKeySet::~OKeySet()
OSL_ENSURE(0,"Unknown Exception occured");
}
m_xComposer = NULL;
- delete m_pKeyColumnNames;
- delete m_pColumnNames;
- delete m_pParameterNames;
- delete m_pForeignColumnNames;
DBG_DTOR(OKeySet,NULL);
}
-// -----------------------------------------------------------------------------
-void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter)
+void OKeySet::initColumns()
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::construct" );
- OCacheSet::construct(_xDriverSet,i_sRowSetFilter);
-
Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
bool bCase = (xMeta.is() && xMeta->storesMixedCaseQuotedIdentifiers()) ? true : false;
- m_pKeyColumnNames = new SelectColumnsMetaData(bCase);
- m_pColumnNames = new SelectColumnsMetaData(bCase);
- m_pParameterNames = new SelectColumnsMetaData(bCase);
- m_pForeignColumnNames = new SelectColumnsMetaData(bCase);
+ m_pKeyColumnNames.reset( new SelectColumnsMetaData(bCase) );
+ m_pColumnNames.reset( new SelectColumnsMetaData(bCase) );
+ m_pParameterNames.reset( new SelectColumnsMetaData(bCase) );
+ m_pForeignColumnNames.reset( new SelectColumnsMetaData(bCase) );
+}
+void OKeySet::findTableColumnsMatching_throw(const Any& i_aTable
+ ,const Reference<XDatabaseMetaData>& i_xMeta
+ ,const Reference<XNameAccess>& i_xQueryColumns)
+{
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ Reference<XPropertySet> xTableProp(i_aTable,UNO_QUERY);
+ Any aCatalog = xTableProp->getPropertyValue(PROPERTY_CATALOGNAME);
+ aCatalog >>= sCatalog;
+ xTableProp->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema;
+ xTableProp->getPropertyValue(PROPERTY_NAME) >>= sTable;
+
+ // first ask the database itself for the best columns which can be used
+ Sequence< ::rtl::OUString> aBestColumnNames;
+ Reference<XNameAccess> xKeyColumns = getPrimaryKeyColumns_throw(i_aTable);
+ if ( xKeyColumns.is() )
+ aBestColumnNames = xKeyColumns->getElementNames();
+
+ const Reference<XColumnsSupplier> xTblColSup(i_aTable,UNO_QUERY_THROW);
+ const Reference<XNameAccess> xTblColumns = xTblColSup->getColumns();
+ const ::rtl::OUString sComposedUpdateTableName = dbtools::composeTableName( i_xMeta, sCatalog, sSchema, sTable, sal_False, ::dbtools::eInDataManipulation );
+ ::dbaccess::getColumnPositions(i_xQueryColumns,aBestColumnNames,sComposedUpdateTableName,(*m_pKeyColumnNames),true);
+ ::dbaccess::getColumnPositions(i_xQueryColumns,xTblColumns->getElementNames(),sComposedUpdateTableName,(*m_pColumnNames),true);
- Reference<XNameAccess> xKeyColumns = getKeyColumns();
- Reference<XColumnsSupplier> xSup(m_xComposer,UNO_QUERY);
- Reference<XNameAccess> xSourceColumns = m_xTable->getColumns();
// locate parameter in select columns
Reference<XParametersSupplier> xParaSup(m_xComposer,UNO_QUERY);
Reference<XIndexAccess> xQueryParameters = xParaSup->getParameters();
@@ -347,83 +229,63 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::O
{
Reference<XPropertySet> xPara(xQueryParameters->getByIndex(i),UNO_QUERY_THROW);
xPara->getPropertyValue(PROPERTY_REALNAME) >>= aParameterColumns[i];
- }
-
- ::rtl::OUString sCatalog,sSchema,sTable;
-
- Reference<XPropertySet> xTableProp(m_xTable,UNO_QUERY);
- Any aCatalog = xTableProp->getPropertyValue(PROPERTY_CATALOGNAME);
- aCatalog >>= sCatalog;
- xTableProp->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema;
- xTableProp->getPropertyValue(PROPERTY_NAME) >>= sTable;
-
- ::std::vector< ::rtl::OUString> aBestRowColumnNames;
- Reference<XResultSet> xBestRes(xMeta->getBestRowIdentifier(aCatalog,sSchema,sTable,0,sal_False));
- Reference<XRow> xBestRow(xBestRes,uno::UNO_QUERY);
- while ( xBestRes->next() )
- {
- aBestRowColumnNames.push_back(xBestRow->getString(2));
}
+ ::dbaccess::getColumnPositions(i_xQueryColumns,aParameterColumns,sComposedUpdateTableName,(*m_pParameterNames),true);
- Sequence< ::rtl::OUString> aBestColumnNames;
- if ( !aBestRowColumnNames.empty() )
- {
- aBestColumnNames = Sequence< ::rtl::OUString>(&aBestRowColumnNames[0],aBestRowColumnNames.size());
- ::dbaccess::getColumnPositions(xSup->getColumns(),aBestColumnNames,m_sUpdateTableName,(*m_pKeyColumnNames));
- }
-
- if (m_pKeyColumnNames->empty() && xKeyColumns.is())
- {
- aBestColumnNames = xKeyColumns->getElementNames();
- ::dbaccess::getColumnPositions(xSup->getColumns(),aBestColumnNames,m_sUpdateTableName,(*m_pKeyColumnNames));
- }
- ::dbaccess::getColumnPositions(xSup->getColumns(),xSourceColumns->getElementNames(),m_sUpdateTableName,(*m_pColumnNames));
- ::dbaccess::getColumnPositions(xSup->getColumns(),aParameterColumns,m_sUpdateTableName,(*m_pParameterNames));
-
- SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin();
- SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end();
+ SelectColumnsMetaData::const_iterator aPosIter = m_pKeyColumnNames->begin();
+ SelectColumnsMetaData::const_iterator aPosEnd = m_pKeyColumnNames->end();
for(;aPosIter != aPosEnd;++aPosIter)
{
- if(xSourceColumns->hasByName(aPosIter->first))
+ if ( xTblColumns->hasByName(aPosIter->second.sRealName) )
{
- Reference<XPropertySet> xProp(xSourceColumns->getByName(aPosIter->first),UNO_QUERY);
- sal_Bool bAuto = sal_Bool();
+ Reference<XPropertySet> xProp(xTblColumns->getByName(aPosIter->second.sRealName),UNO_QUERY);
+ sal_Bool bAuto = sal_False;
if( (xProp->getPropertyValue(PROPERTY_ISAUTOINCREMENT) >>= bAuto) && bAuto)
m_aAutoColumns.push_back(aPosIter->first);
}
}
-
- // the first row is empty because it's now easier for us to distinguish when we are beforefirst or first
- // without extra varaible to be set
- m_aKeyMap.insert(OKeySetMatrix::value_type(0,OKeySetValue(NULL,::std::pair<sal_Int32,Reference<XRow> >(0,NULL))));
-
- m_aKeyIter = m_aKeyMap.begin();
-
+}
+::rtl::OUStringBuffer OKeySet::createKeyFilter()
+{
static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND ");
- Reference<XDatabaseMetaData> xMetaData = m_xConnection->getMetaData();
const ::rtl::OUString aQuote = getIdentifierQuoteString();
- m_aSelectComposedTableName = getComposedTableName(sCatalog,sSchema,sTable);
-
- ::rtl::OUString sComposedName;
- sCatalog = sSchema = sTable = ::rtl::OUString();
- ::dbtools::qualifiedNameComponents(xMetaData,m_sUpdateTableName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
- sComposedName = ::dbtools::composeTableName( xMetaData, sCatalog, sSchema, sTable, sal_True, ::dbtools::eInDataManipulation );
-
::rtl::OUStringBuffer aFilter;
static ::rtl::OUString s_sDot(RTL_CONSTASCII_USTRINGPARAM("."));
static ::rtl::OUString s_sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?"));
// create the where clause
- aPosEnd = (*m_pKeyColumnNames).end();
- for(aPosIter = (*m_pKeyColumnNames).begin();aPosIter != aPosEnd;)
+ Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
+ SelectColumnsMetaData::iterator aPosEnd = m_pKeyColumnNames->end();
+ for(SelectColumnsMetaData::iterator aPosIter = m_pKeyColumnNames->begin();aPosIter != aPosEnd;)
{
- aFilter.append(sComposedName);
+ aFilter.append(::dbtools::quoteTableName( xMeta,aPosIter->second.sTableName,::dbtools::eInDataManipulation));
aFilter.append(s_sDot);
- aFilter.append(::dbtools::quoteName( aQuote,aPosIter->first));
+ aFilter.append(::dbtools::quoteName( aQuote,aPosIter->second.sRealName));
aFilter.append(s_sParam);
++aPosIter;
if(aPosIter != aPosEnd)
aFilter.append(aAnd);
}
+ return aFilter;
+}
+// -----------------------------------------------------------------------------
+void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::construct" );
+ OCacheSet::construct(_xDriverSet,i_sRowSetFilter);
+ initColumns();
+
+ Reference<XNameAccess> xKeyColumns = getKeyColumns();
+ Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
+ Reference<XColumnsSupplier> xQueryColSup(m_xComposer,UNO_QUERY);
+ const Reference<XNameAccess> xQueryColumns = xQueryColSup->getColumns();
+ findTableColumnsMatching_throw(makeAny(m_xTable),xMeta,xQueryColumns);
+
+ // the first row is empty because it's now easier for us to distinguish when we are beforefirst or first
+ // without extra varaible to be set
+ m_aKeyMap.insert(OKeySetMatrix::value_type(0,OKeySetValue(NULL,::std::pair<sal_Int32,Reference<XRow> >(0,NULL))));
+ m_aKeyIter = m_aKeyMap.begin();
+
+ ::rtl::OUStringBuffer aFilter = createKeyFilter();
Reference< XSingleSelectQueryComposer> xSourceComposer(m_xComposer,UNO_QUERY);
Reference< XMultiServiceFactory > xFactory(m_xConnection, UNO_QUERY_THROW);
@@ -434,6 +296,10 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::O
const Sequence< ::rtl::OUString> aSeq = xSelectTables->getElementNames();
if ( aSeq.getLength() > 1 ) // special handling for join
{
+ static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND ");
+ const ::rtl::OUString aQuote = getIdentifierQuoteString();
+ static ::rtl::OUString s_sDot(RTL_CONSTASCII_USTRINGPARAM("."));
+ static ::rtl::OUString s_sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?"));
const ::rtl::OUString* pIter = aSeq.getConstArray();
const ::rtl::OUString* pEnd = pIter + aSeq.getLength();
for(;pIter != pEnd;++pIter)
@@ -442,13 +308,12 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::O
{
connectivity::OSQLTable xSelColSup(xSelectTables->getByName(*pIter),uno::UNO_QUERY);
Reference<XPropertySet> xProp(xSelColSup,uno::UNO_QUERY);
- ::rtl::OUString sSelectTableName = ::dbtools::composeTableName( xMetaData, xProp, ::dbtools::eInDataManipulation, false, false, false );
- Reference<XNameAccess > xSelectColumns = xSup->getColumns();
+ ::rtl::OUString sSelectTableName = ::dbtools::composeTableName( xMeta, xProp, ::dbtools::eInDataManipulation, false, false, false );
- ::dbaccess::getColumnPositions(xSelectColumns,xSelColSup->getColumns()->getElementNames(),sSelectTableName,(*m_pForeignColumnNames));
+ ::dbaccess::getColumnPositions(xQueryColumns,xSelColSup->getColumns()->getElementNames(),sSelectTableName,(*m_pForeignColumnNames));
- aPosEnd = (*m_pForeignColumnNames).end();
- for(aPosIter = (*m_pForeignColumnNames).begin();aPosIter != aPosEnd;++aPosIter)
+ SelectColumnsMetaData::iterator aPosEnd = (*m_pForeignColumnNames).end();
+ for(SelectColumnsMetaData::iterator aPosIter = (*m_pForeignColumnNames).begin();aPosIter != aPosEnd;++aPosIter)
{
// look for columns not in the source columns to use them as filter as well
// if ( !xSourceColumns->hasByName(aPosIter->first) )
@@ -457,7 +322,7 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::O
aFilter.append(aAnd);
aFilter.append(::dbtools::quoteName( aQuote,sSelectTableName));
aFilter.append(s_sDot);
- aFilter.append(::dbtools::quoteName( aQuote,aPosIter->first));
+ aFilter.append(::dbtools::quoteName( aQuote,aPosIter->second.sRealName));
aFilter.append(s_sParam);
}
}
@@ -465,17 +330,40 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::O
}
}
} // if ( aSeq.getLength() > 1 ) // special handling for join
-
- if ( i_sRowSetFilter.getLength() )
+ executeStatement(aFilter,i_sRowSetFilter,xAnalyzer);
+}
+void OKeySet::executeStatement(::rtl::OUStringBuffer& io_aFilter,const ::rtl::OUString& i_sRowSetFilter,Reference<XSingleSelectQueryComposer>& io_xAnalyzer)
+{
+ bool bFilterSet = i_sRowSetFilter.getLength() != 0;
+ if ( bFilterSet )
{
FilterCreator aFilterCreator;
aFilterCreator.append( i_sRowSetFilter );
- aFilterCreator.append( aFilter.makeStringAndClear() );
- aFilter = aFilterCreator.getComposedAndClear();
+ aFilterCreator.append( io_aFilter.makeStringAndClear() );
+ io_aFilter = aFilterCreator.getComposedAndClear();
+ }
+ io_xAnalyzer->setFilter(io_aFilter.makeStringAndClear());
+ if ( bFilterSet )
+ {
+ Sequence< Sequence< PropertyValue > > aFilter2 = io_xAnalyzer->getStructuredFilter();
+ const Sequence< PropertyValue >* pOr = aFilter2.getConstArray();
+ const Sequence< PropertyValue >* pOrEnd = pOr + aFilter2.getLength();
+ for(;pOr != pOrEnd;++pOr)
+ {
+ const PropertyValue* pAnd = pOr->getConstArray();
+ const PropertyValue* pAndEnd = pAnd + pOr->getLength();
+ for(;pAnd != pAndEnd;++pAnd)
+ {
+ ::rtl::OUString sValue;
+ if ( !(pAnd->Value >>= sValue) || !(sValue.equalsAscii("?") || sValue.matchAsciiL(":",1,0)) )
+ { // we have a criteria which has to be taken into account for updates
+ m_aFilterColumns.push_back(pAnd->Name);
+ }
+ }
+ }
}
- xAnalyzer->setFilter(aFilter.makeStringAndClear());
- m_xStatement = m_xConnection->prepareStatement(xAnalyzer->getQueryWithSubstitution());
- ::comphelper::disposeComponent(xAnalyzer);
+ m_xStatement = m_xConnection->prepareStatement(io_xAnalyzer->getQueryWithSubstitution());
+ ::comphelper::disposeComponent(io_xAnalyzer);
}
// -------------------------------------------------------------------------
Any SAL_CALL OKeySet::getBookmark() throw(SQLException, RuntimeException)
@@ -558,7 +446,7 @@ Sequence< sal_Int32 > SAL_CALL OKeySet::deleteRows( const Sequence< Any >& rows
SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end();
for(;aIter != aPosEnd;++aIter)
{
- aCondition.append(::dbtools::quoteName( aQuote,aIter->first));
+ aCondition.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
aCondition.append(aEqual);
aCondition.append(aAnd);
}
@@ -663,7 +551,7 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow
//if(xKeyColumns.is() && xKeyColumns->hasByName(aIter->first))
if ( m_pKeyColumnNames->find(aIter->first) != m_pKeyColumnNames->end() )
{
- sKeyCondition.append(::dbtools::quoteName( aQuote,aIter->first));
+ sKeyCondition.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
if((_rOrginalRow->get())[aIter->second.nPosition].isNull())
sKeyCondition.append(sIsNull);
else
@@ -678,7 +566,7 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow
{
if((*aIndexIter)->hasByName(aIter->first))
{
- sIndexCondition.append(::dbtools::quoteName( aQuote,aIter->first));
+ sIndexCondition.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
if((_rOrginalRow->get())[aIter->second.nPosition].isNull())
sIndexCondition.append(sIsNull);
else
@@ -693,7 +581,7 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow
}
if((_rInsertRow->get())[aIter->second.nPosition].isModified())
{
- aSql.append(::dbtools::quoteName( aQuote,aIter->first));
+ aSql.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
aSql.append(aPara);
}
}
@@ -727,62 +615,74 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow
::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_CONDITION_FOR_PK ), SQL_GENERAL_ERROR, m_xConnection );
// now create end execute the prepared statement
- Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear()));
+
+ ::rtl::OUString sEmpty;
+ executeUpdate(_rInsertRow ,_rOrginalRow,aSql.makeStringAndClear(),sEmpty,aIndexColumnPositions);
+}
+// -----------------------------------------------------------------------------
+void OKeySet::executeUpdate(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName,const ::std::vector<sal_Int32>& _aIndexColumnPositions)
+{
+ // now create end execute the prepared statement
+ Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(i_sSQL));
Reference< XParameters > xParameter(xPrep,UNO_QUERY);
- i = 1;
- // first the set values
bool bRefetch = true;
- aIter = m_pColumnNames->begin();
- sal_uInt16 j = 0;
Reference<XRow> xRow;
+ sal_Int32 i = 1;
+ // first the set values
+ SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
+ SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
+ sal_uInt16 j = 0;
for(;aIter != aEnd;++aIter,++j)
{
- sal_Int32 nPos = aIter->second.nPosition;
- if((_rInsertRow->get())[nPos].isModified())
+ if ( !i_sTableName.getLength() || aIter->second.sTableName == i_sTableName )
{
- if ( bRefetch )
+ sal_Int32 nPos = aIter->second.nPosition;
+ if((_rInsertRow->get())[nPos].isModified())
{
- bRefetch = ::std::find(m_aFilterColumns.begin(),m_aFilterColumns.end(),aIter->first) == m_aFilterColumns.end();
- if ( !bRefetch )
+ if ( bRefetch )
{
- xRow = new OPrivateRow(_rInsertRow->get());
+ bRefetch = ::std::find(m_aFilterColumns.begin(),m_aFilterColumns.end(),aIter->second.sRealName) == m_aFilterColumns.end();
}
+ impl_convertValue_throw(_rInsertRow,aIter->second);
+ (_rInsertRow->get())[nPos].setSigned((_rOrginalRow->get())[nPos].isSigned());
+ setParameter(i++,xParameter,(_rInsertRow->get())[nPos],aIter->second.nType,aIter->second.nScale);
}
-
- impl_convertValue_throw(_rInsertRow,aIter->second);
- (_rInsertRow->get())[nPos].setSigned((_rOrginalRow->get())[nPos].isSigned());
- setParameter(i++,xParameter,(_rInsertRow->get())[nPos],aIter->second.nType,aIter->second.nScale);
}
}
// and then the values of the where condition
- aIter = (*m_pKeyColumnNames).begin();
- aEnd = (*m_pKeyColumnNames).end();
+ aIter = m_pKeyColumnNames->begin();
+ aEnd = m_pKeyColumnNames->end();
j = 0;
- for(;aIter != aEnd;++aIter,++i,++j)
+ for(;aIter != aEnd;++aIter,++j)
{
- setParameter(i,xParameter,(_rOrginalRow->get())[aIter->second.nPosition],aIter->second.nType,aIter->second.nScale);
+ if ( !i_sTableName.getLength() || aIter->second.sTableName == i_sTableName )
+ {
+ setParameter(i++,xParameter,(_rOrginalRow->get())[aIter->second.nPosition],aIter->second.nType,aIter->second.nScale);
+ }
}
-
- // now we have to set the index values
- ::std::vector<sal_Int32>::iterator aIdxColIter = aIndexColumnPositions.begin();
- ::std::vector<sal_Int32>::iterator aIdxColEnd = aIndexColumnPositions.end();
- j = 0;
- aIter = m_pColumnNames->begin();
- for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i,++j,++aIter)
+ if ( !_aIndexColumnPositions.empty() )
{
- setParameter(i,xParameter,(_rOrginalRow->get())[*aIdxColIter],(_rOrginalRow->get())[*aIdxColIter].getTypeKind(),aIter->second.nScale);
+ // now we have to set the index values
+ ::std::vector<sal_Int32>::const_iterator aIdxColIter = _aIndexColumnPositions.begin();
+ ::std::vector<sal_Int32>::const_iterator aIdxColEnd = _aIndexColumnPositions.end();
+ j = 0;
+ aIter = m_pColumnNames->begin();
+ for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i,++j,++aIter)
+ {
+ setParameter(i,xParameter,(_rOrginalRow->get())[*aIdxColIter],(_rOrginalRow->get())[*aIdxColIter].getTypeKind(),aIter->second.nScale);
+ }
}
-
- m_bUpdated = xPrep->executeUpdate() > 0;
+ const sal_Int32 nRowsUpdated = xPrep->executeUpdate();
+ m_bUpdated = nRowsUpdated > 0;
if(m_bUpdated)
{
const sal_Int32 nBookmark = ::comphelper::getINT32((_rInsertRow->get())[0].getAny());
m_aKeyIter = m_aKeyMap.find(nBookmark);
m_aKeyIter->second.second.first = 2;
m_aKeyIter->second.second.second = xRow;
-
copyRowValue(_rInsertRow,m_aKeyIter->second.first,nBookmark);
+ tryRefetch(_rInsertRow,bRefetch);
}
}
// -------------------------------------------------------------------------
@@ -804,12 +704,17 @@ void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivi
SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
sal_Int32 j = 1;
+ bool bRefetch = true;
sal_Bool bModified = sal_False;
for(;aIter != aEnd;++aIter,++j)
{
if((_rInsertRow->get())[aIter->second.nPosition].isModified())
{
- aSql.append(::dbtools::quoteName( aQuote,aIter->first));
+ if ( bRefetch )
+ {
+ bRefetch = ::std::find(m_aFilterColumns.begin(),m_aFilterColumns.end(),aIter->second.sRealName) == m_aFilterColumns.end();
+ }
+ aSql.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
aSql.append(aComma);
aValues.append(aPara);
bModified = sal_True;
@@ -822,22 +727,33 @@ void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivi
aValues.setCharAt(aValues.getLength()-1,')');
aSql.append(aValues.makeStringAndClear());
// now create,fill and execute the prepared statement
- Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear()));
+ ::rtl::OUString sEmpty;
+ executeInsert(_rInsertRow,aSql.makeStringAndClear(),sEmpty,bRefetch);
+}
+// -------------------------------------------------------------------------
+void OKeySet::executeInsert( const ORowSetRow& _rInsertRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName,bool bRefetch )
+{
+ // now create,fill and execute the prepared statement
+ Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(i_sSQL));
Reference< XParameters > xParameter(xPrep,UNO_QUERY);
- aIter = m_pColumnNames->begin();
+ SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
+ SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
for(sal_Int32 i = 1;aIter != aEnd;++aIter)
{
- const sal_Int32 nPos = aIter->second.nPosition;
- if((_rInsertRow->get())[nPos].isModified())
+ if ( !i_sTableName.getLength() || aIter->second.sTableName == i_sTableName )
{
- if((_rInsertRow->get())[nPos].isNull())
- xParameter->setNull(i++,(_rInsertRow->get())[nPos].getTypeKind());
- else
+ const sal_Int32 nPos = aIter->second.nPosition;
+ if((_rInsertRow->get())[nPos].isModified())
{
- impl_convertValue_throw(_rInsertRow,aIter->second);
- (_rInsertRow->get())[nPos].setSigned(m_aSignedFlags[nPos-1]);
- setParameter(i++,xParameter,(_rInsertRow->get())[nPos],aIter->second.nType,aIter->second.nScale);
+ if((_rInsertRow->get())[nPos].isNull())
+ xParameter->setNull(i++,(_rInsertRow->get())[nPos].getTypeKind());
+ else
+ {
+ impl_convertValue_throw(_rInsertRow,aIter->second);
+ (_rInsertRow->get())[nPos].setSigned(m_aSignedFlags[nPos-1]);
+ setParameter(i++,xParameter,(_rInsertRow->get())[nPos],aIter->second.nType,aIter->second.nScale);
+ }
}
}
}
@@ -888,7 +804,7 @@ void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivi
::comphelper::disposeComponent(xPrep);
- if ( !bAutoValuesFetched && m_bInserted )
+ if ( !i_sTableName.getLength() && !bAutoValuesFetched && m_bInserted )
{
// first check if all key column values were set
const ::rtl::OUString sMax(RTL_CONSTASCII_USTRINGPARAM(" MAX("));
@@ -945,13 +861,67 @@ void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivi
{
OKeySetMatrix::iterator aKeyIter = m_aKeyMap.end();
--aKeyIter;
- ORowSetRow aKeyRow = new connectivity::ORowVector< ORowSetValue >((*m_pKeyColumnNames).size());
+ ORowSetRow aKeyRow = new connectivity::ORowVector< ORowSetValue >(m_pKeyColumnNames->size());
copyRowValue(_rInsertRow,aKeyRow,aKeyIter->first + 1);
-
m_aKeyIter = m_aKeyMap.insert(OKeySetMatrix::value_type(aKeyIter->first + 1,OKeySetValue(aKeyRow,::std::pair<sal_Int32,Reference<XRow> >(1,NULL)))).first;
// now we set the bookmark for this row
(_rInsertRow->get())[0] = makeAny((sal_Int32)m_aKeyIter->first);
+ tryRefetch(_rInsertRow,bRefetch);
+ }
+}
+void OKeySet::tryRefetch(const ORowSetRow& _rInsertRow,bool bRefetch)
+{
+ if ( bRefetch )
+ {
+ // we just areassign the base members
+ try
+ {
+ Reference< XParameters > xParameter(m_xStatement,UNO_QUERY);
+ OSL_ENSURE(xParameter.is(),"No Parameter interface!");
+ xParameter->clearParameters();
+
+ sal_Int32 nPos=1;
+ connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaIter;
+ connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaEnd;
+ OUpdatedParameter::iterator aUpdateFind = m_aUpdatedParameter.find(m_aKeyIter->first);
+ if ( aUpdateFind == m_aUpdatedParameter.end() )
+ {
+ aParaIter = m_aParameterValueForCache.get().begin();
+ aParaEnd = m_aParameterValueForCache.get().end();
+ }
+ else
+ {
+ aParaIter = aUpdateFind->second.get().begin();
+ aParaEnd = aUpdateFind->second.get().end();
+ }
+
+ for(++aParaIter;aParaIter != aParaEnd;++aParaIter,++nPos)
+ {
+ ::dbtools::setObjectWithInfo( xParameter, nPos, aParaIter->makeAny(), aParaIter->getTypeKind() );
+ }
+ connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aIter2 = m_aKeyIter->second.first->get().begin();
+ SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin();
+ SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end();
+ for(;aPosIter != aPosEnd;++aPosIter,++aIter2,++nPos)
+ setParameter(nPos,xParameter,*aIter2,aPosIter->second.nType,aPosIter->second.nScale);
+ aPosIter = (*m_pForeignColumnNames).begin();
+ aPosEnd = (*m_pForeignColumnNames).end();
+ for(;aPosIter != aPosEnd;++aPosIter,++aIter2,++nPos)
+ setParameter(nPos,xParameter,*aIter2,aPosIter->second.nType,aPosIter->second.nScale);
+
+ m_xSet = m_xStatement->executeQuery();
+ OSL_ENSURE(m_xSet.is(),"No resultset form statement!");
+ bRefetch = m_xSet->next();
+ }
+ catch(Exception)
+ {
+ bRefetch = false;
+ }
+ }
+ if ( !bRefetch )
+ {
+ m_aKeyIter->second.second.second = new OPrivateRow(_rInsertRow->get());
}
}
// -----------------------------------------------------------------------------
@@ -990,6 +960,7 @@ void OKeySet::copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow,sa
for(;aPosIter != aPosEnd;++aPosIter,++aIter)
{
*aIter = (_rInsertRow->get())[aPosIter->second.nPosition];
+ impl_convertValue_throw(_rKeyRow,aPosIter->second);
aIter->setTypeKind(aPosIter->second.nType);
}
}
@@ -1031,7 +1002,7 @@ void SAL_CALL OKeySet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivit
{
if ( m_pKeyColumnNames->find(aIter->first) != m_pKeyColumnNames->end() )
{
- aSql.append(::dbtools::quoteName( aQuote,aIter->first));
+ aSql.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
if((_rDeleteRow->get())[aIter->second.nPosition].isNull())
{
OSL_ENSURE(0,"can a primary key be null");
@@ -1049,7 +1020,7 @@ void SAL_CALL OKeySet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivit
{
if((*aIndexIter)->hasByName(aIter->first))
{
- sIndexCondition.append(::dbtools::quoteName( aQuote,aIter->first));
+ sIndexCondition.append(::dbtools::quoteName( aQuote,aIter->second.sRealName));
if((_rDeleteRow->get())[aIter->second.nPosition].isNull())
sIndexCondition.append(::rtl::OUString::createFromAscii(" IS NULL"));
else
@@ -1213,8 +1184,8 @@ void SAL_CALL OKeySet::beforeFirst( ) throw(SQLException, RuntimeException)
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::beforeFirst" );
m_bInserted = m_bUpdated = m_bDeleted = sal_False;
m_aKeyIter = m_aKeyMap.begin();
- m_xSet = NULL;
- ::comphelper::disposeComponent(m_xRow);
+ m_xRow = NULL;
+ ::comphelper::disposeComponent(m_xSet);
}
// -----------------------------------------------------------------------------
void SAL_CALL OKeySet::afterLast( ) throw(SQLException, RuntimeException)
@@ -1223,8 +1194,8 @@ void SAL_CALL OKeySet::afterLast( ) throw(SQLException, RuntimeException)
m_bInserted = m_bUpdated = m_bDeleted = sal_False;
fillAllRows();
m_aKeyIter = m_aKeyMap.end();
- m_xSet = NULL;
- ::comphelper::disposeComponent(m_xRow);
+ m_xRow = NULL;
+ ::comphelper::disposeComponent(m_xSet);
}
// -----------------------------------------------------------------------------
sal_Bool SAL_CALL OKeySet::first( ) throw(SQLException, RuntimeException)
@@ -1328,8 +1299,14 @@ void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException)
if(isBeforeFirst() || isAfterLast() || !m_xStatement.is())
return;
- m_xSet = NULL;
- ::comphelper::disposeComponent(m_xRow);
+ m_xRow = NULL;
+ ::comphelper::disposeComponent(m_xSet);
+
+ if ( m_aKeyIter->second.second.second.is() )
+ {
+ m_xRow = m_aKeyIter->second.second.second;
+ return;
+ }
// we just areassign the base members
Reference< XParameters > xParameter(m_xStatement,UNO_QUERY);
OSL_ENSURE(xParameter.is(),"No Parameter interface!");
@@ -1340,8 +1317,7 @@ void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException)
connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaEnd;
OUpdatedParameter::iterator aUpdateFind = m_aUpdatedParameter.find(m_aKeyIter->first);
if ( aUpdateFind == m_aUpdatedParameter.end() )
- {
-
+ {
aParaIter = m_aParameterValueForCache.get().begin();
aParaEnd = m_aParameterValueForCache.get().end();
}
@@ -1355,6 +1331,8 @@ void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException)
{
::dbtools::setObjectWithInfo( xParameter, nPos, aParaIter->makeAny(), aParaIter->getTypeKind() );
}
+
+ // now set the primary key column values
connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aIter = m_aKeyIter->second.first->get().begin();
SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin();
SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end();
diff --git a/dbaccess/source/core/api/KeySet.hxx b/dbaccess/source/core/api/KeySet.hxx
index 947f8e161..ccd5cf0e6 100644
--- a/dbaccess/source/core/api/KeySet.hxx
+++ b/dbaccess/source/core/api/KeySet.hxx
@@ -35,14 +35,14 @@
#ifndef _CPPUHELPER_IMPLBASE1_HXX_
#include <cppuhelper/implbase1.hxx>
#endif
+#include <memory>
#include <map>
#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_
#include <com/sun/star/lang/XUnoTunnel.hpp>
#endif
-#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYANALYZER_HPP_
#include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.hpp>
-#endif
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
#ifndef _COMPHELPER_STLTYPES_HXX_
#include <comphelper/stl_types.hxx>
#endif
@@ -93,17 +93,18 @@ namespace dbaccess
// is used when the source supports keys
class OKeySet : public OCacheSet
{
+ protected:
OKeySetMatrix m_aKeyMap;
OKeySetMatrix::iterator m_aKeyIter;
-
+
::std::vector< ::rtl::OUString > m_aAutoColumns; // contains all columns which are autoincrement ones
OUpdatedParameter m_aUpdatedParameter; // contains all parameter which have been updated and are needed for refetching
ORowSetValueVector m_aParameterValueForCache;
- SelectColumnsMetaData* m_pKeyColumnNames; // contains all key column names
- SelectColumnsMetaData* m_pColumnNames; // contains all column names
- SelectColumnsMetaData* m_pParameterNames; // contains all parameter names
- SelectColumnsMetaData* m_pForeignColumnNames; // contains all column names of the rest
+ ::std::auto_ptr<SelectColumnsMetaData> m_pKeyColumnNames; // contains all key column names
+ ::std::auto_ptr<SelectColumnsMetaData> m_pColumnNames; // contains all column names
+ ::std::auto_ptr<SelectColumnsMetaData> m_pParameterNames; // contains all parameter names
+ ::std::auto_ptr<SelectColumnsMetaData> m_pForeignColumnNames; // contains all column names of the rest
connectivity::OSQLTable m_xTable; // reference to our table
::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess> m_xTableKeys;
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement> m_xStatement;
@@ -141,7 +142,16 @@ namespace dbaccess
sal_Bool fetchRow();
void impl_convertValue_throw(const ORowSetRow& _rInsertRow,const SelectColumnDescription& i_aMetaData);
- protected:
+ void initColumns();
+ void findTableColumnsMatching_throw( const ::com::sun::star::uno::Any& i_aTable
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& i_xMeta
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& i_xQueryColumns);
+ ::rtl::OUStringBuffer createKeyFilter();
+ void tryRefetch(const ORowSetRow& _rInsertRow,bool bRefetch);
+ void executeUpdate(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName,const ::std::vector<sal_Int32>& _aIndexColumnPositions = ::std::vector<sal_Int32>());
+ void executeInsert( const ORowSetRow& _rInsertRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName = ::rtl::OUString(),bool bRefetch = false);
+ void executeStatement(::rtl::OUStringBuffer& io_aFilter,const ::rtl::OUString& i_sRowSetFilter,::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer>& io_xAnalyzer);
+
virtual ~OKeySet();
public:
OKeySet(const connectivity::OSQLTable& _xTable,
diff --git a/dbaccess/source/core/api/OptimisticSet.cxx b/dbaccess/source/core/api/OptimisticSet.cxx
index 1dc198140..b68910d0f 100644
--- a/dbaccess/source/core/api/OptimisticSet.cxx
+++ b/dbaccess/source/core/api/OptimisticSet.cxx
@@ -84,23 +84,6 @@ using namespace ::osl;
DECLARE_STL_USTRINGACCESS_MAP(::rtl::OUStringBuffer,TSQLStatements);
namespace
{
- void lcl_fillIndexColumns(const Reference<XIndexAccess>& _xIndexes, ::std::vector< Reference<XNameAccess> >& _rAllIndexColumns)
- {
- if ( _xIndexes.is() )
- {
- Reference<XPropertySet> xIndexColsSup;
- sal_Int32 nCount = _xIndexes->getCount();
- for(sal_Int32 j = 0 ; j < nCount ; ++j)
- {
- xIndexColsSup.set(_xIndexes->getByIndex(j),UNO_QUERY);
- if( xIndexColsSup.is()
- && comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISUNIQUE))
- && !comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISPRIMARYKEYINDEX))
- )
- _rAllIndexColumns.push_back(Reference<XColumnsSupplier>(xIndexColsSup,UNO_QUERY)->getColumns());
- }
- }
- }
void lcl_fillKeyCondition(const ::rtl::OUString& i_sTableName,const ::rtl::OUString& i_sQuotedColumnName,const ORowSetValue& i_aValue,TSQLStatements& io_aKeyConditions)
{
::rtl::OUStringBuffer& rKeyCondition = io_aKeyConditions[i_sTableName];
@@ -120,14 +103,9 @@ OptimisticSet::OptimisticSet(const ::comphelper::ComponentContext& _rContext,
const Reference< XConnection>& i_xConnection,
const Reference< XSingleSelectQueryAnalyzer >& _xComposer,
const ORowSetValueVector& _aParameterValueForCache)
- :m_aSqlParser( _rContext.getLegacyServiceFactory() )
+ :OKeySet(NULL,NULL,::rtl::OUString(),_xComposer,_aParameterValueForCache)
+ ,m_aSqlParser( _rContext.getLegacyServiceFactory() )
,m_aSqlIterator( i_xConnection, Reference<XTablesSupplier>(_xComposer,UNO_QUERY)->getTables(), m_aSqlParser, NULL )
- ,m_aParameterValueForCache(_aParameterValueForCache)
- ,m_pKeyColumnNames(NULL)
- ,m_pColumnNames(NULL)
- ,m_pParameterNames(NULL)
- ,m_xComposer(_xComposer)
- ,m_bRowCountFinal(sal_False)
,m_bResultSetChanged(false)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::OptimisticSet" );
@@ -136,20 +114,6 @@ OptimisticSet::OptimisticSet(const ::comphelper::ComponentContext& _rContext,
// -----------------------------------------------------------------------------
OptimisticSet::~OptimisticSet()
{
- try
- {
- ::comphelper::disposeComponent(m_xStatement);
- }
- catch(Exception&)
- {
- m_xStatement.clear();
- }
- catch(...)
- {
- OSL_ENSURE(0,"Unknown Exception occured");
- }
- m_xComposer.clear();
-
DBG_DTOR(OptimisticSet,NULL);
}
// -----------------------------------------------------------------------------
@@ -157,14 +121,9 @@ void OptimisticSet::construct(const Reference< XResultSet>& _xDriverSet,const ::
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::construct" );
OCacheSet::construct(_xDriverSet,i_sRowSetFilter);
+ initColumns();
Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
- bool bCase = (xMeta.is() && xMeta->storesMixedCaseQuotedIdentifiers()) ? true : false;
-
- m_pKeyColumnNames.reset( new SelectColumnsMetaData(bCase) );
- m_pColumnNames.reset( new SelectColumnsMetaData(bCase) );
- m_pParameterNames.reset( new SelectColumnsMetaData(bCase) );
-
Reference<XColumnsSupplier> xQueryColSup(m_xComposer,UNO_QUERY);
const Reference<XNameAccess> xQueryColumns = xQueryColSup->getColumns();
const Reference<XTablesSupplier> xTabSup(m_xComposer,UNO_QUERY);
@@ -182,29 +141,13 @@ void OptimisticSet::construct(const Reference< XResultSet>& _xDriverSet,const ::
m_aKeyMap.insert(OKeySetMatrix::value_type(0,OKeySetValue(NULL,::std::pair<sal_Int32,Reference<XRow> >(0,NULL))));
m_aKeyIter = m_aKeyMap.begin();
- static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND ");
- const ::rtl::OUString aQuote = getIdentifierQuoteString();
- ::rtl::OUStringBuffer aFilter;
- static ::rtl::OUString s_sDot(RTL_CONSTASCII_USTRINGPARAM("."));
- static ::rtl::OUString s_sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?"));
- // create the where clause
- SelectColumnsMetaData::iterator aPosEnd = m_pKeyColumnNames->end();
- for(SelectColumnsMetaData::iterator aPosIter = m_pKeyColumnNames->begin();aPosIter != aPosEnd;)
- {
- aFilter.append(::dbtools::quoteName( aQuote,aPosIter->second.sTableName));
- aFilter.append(s_sDot);
- aFilter.append(::dbtools::quoteName( aQuote,aPosIter->second.sRealName));
- aFilter.append(s_sParam);
- ++aPosIter;
- if(aPosIter != aPosEnd)
- aFilter.append(aAnd);
- }
+ ::rtl::OUStringBuffer aFilter = createKeyFilter();
+ Reference< XSingleSelectQueryComposer> xSourceComposer(m_xComposer,UNO_QUERY);
Reference< XMultiServiceFactory > xFactory(m_xConnection, UNO_QUERY_THROW);
Reference<XSingleSelectQueryComposer> xAnalyzer(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY);
- Reference<XSingleSelectQueryComposer> xComp2(m_xComposer,UNO_QUERY_THROW);
- ::rtl::OUString sQuery = xComp2->getQuery();
- xAnalyzer->setQuery(sQuery);
+ ::rtl::OUString sQuery = xSourceComposer->getQuery();
+ xAnalyzer->setElementaryQuery(xSourceComposer->getElementaryQuery());
// check for joins
::rtl::OUString aErrorMsg;
::std::auto_ptr<OSQLParseNode> pStatementNode( m_aSqlParser.parseTree( aErrorMsg, sQuery ) );
@@ -227,58 +170,6 @@ void OptimisticSet::construct(const Reference< XResultSet>& _xDriverSet,const ::
::comphelper::disposeComponent(xAnalyzer);
}
// -------------------------------------------------------------------------
-Any SAL_CALL OptimisticSet::getBookmark() throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getBookmark" );
- OSL_ENSURE(m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin(),
- "getBookmark is only possible when we stand on a valid row!");
- return makeAny(m_aKeyIter->first);
-}
-
-// -------------------------------------------------------------------------
-sal_Bool SAL_CALL OptimisticSet::moveToBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::moveToBookmark" );
- m_bInserted = m_bUpdated = m_bDeleted = sal_False;
- m_aKeyIter = m_aKeyMap.find(::comphelper::getINT32(bookmark));
- return m_aKeyIter != m_aKeyMap.end();
-}
-// -------------------------------------------------------------------------
-sal_Bool SAL_CALL OptimisticSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::moveRelativeToBookmark" );
- m_bInserted = m_bUpdated = m_bDeleted = sal_False;
- m_aKeyIter = m_aKeyMap.find(::comphelper::getINT32(bookmark));
- if(m_aKeyIter != m_aKeyMap.end())
- {
- relative(rows);
- }
-
- return !isBeforeFirst() && !isAfterLast();
-}
-// -------------------------------------------------------------------------
-sal_Int32 SAL_CALL OptimisticSet::compareBookmarks( const Any& _first, const Any& _second ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::compareBookmarks" );
- sal_Int32 nFirst = 0, nSecond = 0;
- _first >>= nFirst;
- _second >>= nSecond;
-
- return (nFirst != nSecond) ? CompareBookmark::NOT_EQUAL : CompareBookmark::EQUAL;
-}
-// -------------------------------------------------------------------------
-sal_Bool SAL_CALL OptimisticSet::hasOrderedBookmarks( ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::hasOrderedBookmarks" );
- return sal_True;
-}
-// -------------------------------------------------------------------------
-sal_Int32 SAL_CALL OptimisticSet::hashBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::hashBookmark" );
- return ::comphelper::getINT32(bookmark);
-}
-// -------------------------------------------------------------------------
// ::com::sun::star::sdbcx::XDeleteRows
Sequence< sal_Int32 > SAL_CALL OptimisticSet::deleteRows( const Sequence< Any >& /*rows*/ ,const connectivity::OSQLTable& /*_xTable*/) throw(SQLException, RuntimeException)
{
@@ -485,202 +376,6 @@ void SAL_CALL OptimisticSet::insertRow( const ORowSetRow& _rInsertRow,const conn
}
}
// -------------------------------------------------------------------------
-void OptimisticSet::executeInsert( const ORowSetRow& _rInsertRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName )
-{
- // now create,fill and execute the prepared statement
- Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(i_sSQL));
- Reference< XParameters > xParameter(xPrep,UNO_QUERY);
-
- SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
- SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
- for(sal_Int32 i = 1;aIter != aEnd;++aIter)
- {
- if ( aIter->second.sTableName == i_sTableName )
- {
- const sal_Int32 nPos = aIter->second.nPosition;
- if((_rInsertRow->get())[nPos].isModified())
- {
- if((_rInsertRow->get())[nPos].isNull())
- xParameter->setNull(i++,(_rInsertRow->get())[nPos].getTypeKind());
- else
- {
- impl_convertValue_throw(_rInsertRow,aIter->second);
- (_rInsertRow->get())[nPos].setSigned(m_aSignedFlags[nPos-1]);
- setParameter(i++,xParameter,(_rInsertRow->get())[nPos],aIter->second.nType,aIter->second.nScale);
- }
- }
- }
- }
-
- m_bInserted = xPrep->executeUpdate() > 0;
- sal_Bool bAutoValuesFetched = sal_False;
- if ( m_bInserted )
- {
- // first insert the default values into the insertrow
- aIter = m_pColumnNames->begin();
- for(;aIter != aEnd;++aIter)
- {
- if ( !(_rInsertRow->get())[aIter->second.nPosition].isModified() )
- (_rInsertRow->get())[aIter->second.nPosition] = aIter->second.sDefaultValue;
- }
- try
- {
- Reference< XGeneratedResultSet > xGRes(xPrep, UNO_QUERY);
- if ( xGRes.is() )
- {
- Reference< XResultSet > xRes = xGRes->getGeneratedValues();
- Reference< XRow > xRow(xRes,UNO_QUERY);
- if ( xRow.is() && xRes->next() )
- {
- Reference< XResultSetMetaDataSupplier > xMdSup(xRes,UNO_QUERY);
- Reference< XResultSetMetaData > xMd = xMdSup->getMetaData();
- sal_Int32 nColumnCount = xMd->getColumnCount();
- ::std::vector< ::rtl::OUString >::iterator aAutoIter = m_aAutoColumns.begin();
- ::std::vector< ::rtl::OUString >::iterator aAutoEnd = m_aAutoColumns.end();
- for (sal_Int32 i = 1;aAutoIter != aAutoEnd && i <= nColumnCount; ++aAutoIter,++i)
- {
-#if OSL_DEBUG_LEVEL > 1
- ::rtl::OUString sColumnName( xMd->getColumnName(i) );
-#endif
- SelectColumnsMetaData::iterator aFind = m_pKeyColumnNames->find(*aAutoIter);
- if ( aFind != m_pKeyColumnNames->end() )
- (_rInsertRow->get())[aFind->second.nPosition].fill(i,aFind->second.nType,aFind->second.bNullable,xRow);
- }
- bAutoValuesFetched = sal_True;
- }
- }
- }
- catch(Exception&)
- {
- OSL_ENSURE(0,"Could not execute GeneratedKeys() stmt");
- }
- }
-
- ::comphelper::disposeComponent(xPrep);
-/*
- if ( !bAutoValuesFetched && m_bInserted )
- {
- // first check if all key column values were set
- const ::rtl::OUString sMax(RTL_CONSTASCII_USTRINGPARAM(" MAX("));
- const ::rtl::OUString sMaxEnd(RTL_CONSTASCII_USTRINGPARAM("),"));
- const ::rtl::OUString sQuote = getIdentifierQuoteString();
- ::rtl::OUString sMaxStmt;
- aEnd = m_pKeyColumnNames->end();
- ::std::vector< ::rtl::OUString >::iterator aAutoIter = m_aAutoColumns.begin();
- ::std::vector< ::rtl::OUString >::iterator aAutoEnd = m_aAutoColumns.end();
- for (;aAutoIter != aAutoEnd; ++aAutoIter)
- {
- // we will only fetch values which are keycolumns
- if ( m_pKeyColumnNames->find(*aAutoIter) != aEnd )
- {
- sMaxStmt += sMax;
- sMaxStmt += ::dbtools::quoteName( sQuote,*aAutoIter);
- sMaxStmt += sMaxEnd;
- }
- }
-
- if(sMaxStmt.getLength())
- {
- sMaxStmt = sMaxStmt.replaceAt(sMaxStmt.getLength()-1,1,::rtl::OUString::createFromAscii(" "));
- ::rtl::OUString sStmt = ::rtl::OUString::createFromAscii("SELECT ");
- sStmt += sMaxStmt;
- sStmt += ::rtl::OUString::createFromAscii("FROM ");
- sStmt += m_aSelectComposedTableName;
- try
- {
- // now fetch the autoincrement values
- Reference<XStatement> xStatement = m_xConnection->createStatement();
- Reference<XResultSet> xRes = xStatement->executeQuery(sStmt);
- Reference<XRow> xRow(xRes,UNO_QUERY);
- if(xRow.is() && xRes->next())
- {
- aAutoIter = m_aAutoColumns.begin();
- for (sal_Int32 i=1;aAutoIter != aAutoEnd; ++aAutoIter,++i)
- {
- // we will only fetch values which are keycolumns
- SelectColumnsMetaData::iterator aFind = m_pKeyColumnNames->find(*aAutoIter);
- if ( aFind != aEnd )
- (_rInsertRow->get())[aFind->second.nPosition].fill(i,aFind->second.nType,aFind->second.bNullable,xRow);
- }
- }
- ::comphelper::disposeComponent(xStatement);
- }
- catch(SQLException&)
- {
- OSL_ENSURE(0,"Could not fetch with MAX() ");
- }
- }
- }
- */
- if ( m_bInserted )
- {
- OKeySetMatrix::iterator aKeyIter = m_aKeyMap.end();
- --aKeyIter;
- ORowSetRow aKeyRow = new connectivity::ORowVector< ORowSetValue >(m_pKeyColumnNames->size());
- copyRowValue(_rInsertRow,aKeyRow,aKeyIter->first + 1);
-
- m_aKeyIter = m_aKeyMap.insert(OKeySetMatrix::value_type(aKeyIter->first + 1,OKeySetValue(aKeyRow,::std::pair<sal_Int32,Reference<XRow> >(1,NULL)))).first;
- // now we set the bookmark for this row
- (_rInsertRow->get())[0] = makeAny((sal_Int32)m_aKeyIter->first);
- }
-}
-// -----------------------------------------------------------------------------
-void OptimisticSet::copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow,sal_Int32 i_nBookmark)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::copyRowValue" );
- connectivity::ORowVector< ORowSetValue >::Vector::iterator aIter = _rKeyRow->get().begin();
-
- // check the if the parameter values have been changed
- OSL_ENSURE((m_aParameterValueForCache.get().size()-1) == m_pParameterNames->size(),"OptimisticSet::copyRowValue: Parameter values and names differ!");
- connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaValuesIter = m_aParameterValueForCache.get().begin() +1;
-
- bool bChanged = false;
- SelectColumnsMetaData::const_iterator aParaIter = (*m_pParameterNames).begin();
- SelectColumnsMetaData::const_iterator aParaEnd = (*m_pParameterNames).end();
- for(sal_Int32 i = 1;aParaIter != aParaEnd;++aParaIter,++aParaValuesIter,++i)
- {
- ORowSetValue aValue(*aParaValuesIter);
- aValue.setSigned(m_aSignedFlags[aParaIter->second.nPosition]);
- if ( (_rInsertRow->get())[aParaIter->second.nPosition] != aValue )
- {
- ORowSetValueVector aCopy(m_aParameterValueForCache);
- (aCopy.get())[i] = (_rInsertRow->get())[aParaIter->second.nPosition];
- m_aUpdatedParameter[i_nBookmark] = aCopy;
- bChanged = true;
- }
- }
- if ( !bChanged )
- {
- m_aUpdatedParameter.erase(i_nBookmark);
- }
-
- // update the key values
- SelectColumnsMetaData::const_iterator aPosIter = m_pKeyColumnNames->begin();
- SelectColumnsMetaData::const_iterator aPosEnd = m_pKeyColumnNames->end();
- for(;aPosIter != aPosEnd;++aPosIter,++aIter)
- {
- ORowSetValue aValue((_rInsertRow->get())[aPosIter->second.nPosition]);
- switch(aPosIter->second.nType)
- {
- case DataType::DECIMAL:
- case DataType::NUMERIC:
- {
- ::rtl::OUString sValue = aValue.getString();
- sal_Int32 nIndex = sValue.indexOf('.');
- if ( nIndex != -1 )
- {
- aValue = sValue.copy(0,nIndex + (aPosIter->second.nScale > 0 ? aPosIter->second.nScale + 1 : 0));
- }
- }
- break;
- default:
- break;
- }
- *aIter = aValue;
- aIter->setTypeKind(aPosIter->second.nType);
- }
-}
-// -------------------------------------------------------------------------
void SAL_CALL OptimisticSet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivity::OSQLTable& /*_xTable*/ ) throw(SQLException, RuntimeException)
{
::rtl::OUString sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?"));
@@ -754,432 +449,6 @@ void OptimisticSet::executeDelete(const ORowSetRow& _rDeleteRow,const ::rtl::OUS
m_bDeleted = sal_True;
}
}
-// -------------------------------------------------------------------------
-void SAL_CALL OptimisticSet::cancelRowUpdates( ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::cancelRowUpdates" );
- m_bInserted = m_bUpdated = m_bDeleted = sal_False;
-}
-// -------------------------------------------------------------------------
-void SAL_CALL OptimisticSet::moveToInsertRow( ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::moveToInsertRow" );
-}
-// -------------------------------------------------------------------------
-void SAL_CALL OptimisticSet::moveToCurrentRow( ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::moveToCurrentRow" );
-}
-// -----------------------------------------------------------------------------
-sal_Bool SAL_CALL OptimisticSet::next( ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::next" );
- m_bInserted = m_bUpdated = m_bDeleted = sal_False;
-
- if(isAfterLast())
- return sal_False;
- if(!m_bRowCountFinal) // not yet all records fetched
- {
- ++m_aKeyIter; // this is possible because we stand on begin() and this is the "beforefirst" row
- if(m_aKeyIter == m_aKeyMap.end() && !fetchRow())
- m_aKeyIter = m_aKeyMap.end();
- }
- else if(!isAfterLast())
- ++m_aKeyIter;
-
- refreshRow();
- return !isAfterLast();
-}
-// -----------------------------------------------------------------------------
-sal_Bool SAL_CALL OptimisticSet::isBeforeFirst( ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::isBeforeFirst" );
- return m_aKeyIter == m_aKeyMap.begin();
-}
-// -----------------------------------------------------------------------------
-sal_Bool SAL_CALL OptimisticSet::isAfterLast( ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::isAfterLast" );
- return m_bRowCountFinal && m_aKeyIter == m_aKeyMap.end();
-}
-// -----------------------------------------------------------------------------
-sal_Bool SAL_CALL OptimisticSet::isFirst( ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::isFirst" );
- OKeySetMatrix::iterator aTemp = m_aKeyMap.begin();
- ++aTemp;
- return m_aKeyIter == aTemp && m_aKeyIter != m_aKeyMap.end();
-}
-// -----------------------------------------------------------------------------
-sal_Bool SAL_CALL OptimisticSet::isLast( ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::isLast" );
- if(!m_bRowCountFinal)
- return sal_False;
-
- OKeySetMatrix::iterator aTemp = m_aKeyMap.end();
- --aTemp;
- return m_aKeyIter == aTemp;
-}
-// -----------------------------------------------------------------------------
-void SAL_CALL OptimisticSet::beforeFirst( ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::beforeFirst" );
- m_bInserted = m_bUpdated = m_bDeleted = sal_False;
- m_aKeyIter = m_aKeyMap.begin();
- m_xSet = NULL;
- ::comphelper::disposeComponent(m_xRow);
-}
-// -----------------------------------------------------------------------------
-void SAL_CALL OptimisticSet::afterLast( ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::afterLast" );
- m_bInserted = m_bUpdated = m_bDeleted = sal_False;
- fillAllRows();
- m_aKeyIter = m_aKeyMap.end();
- m_xSet = NULL;
- ::comphelper::disposeComponent(m_xRow);
-}
-// -----------------------------------------------------------------------------
-sal_Bool SAL_CALL OptimisticSet::first( ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::first" );
- m_bInserted = m_bUpdated = m_bDeleted = sal_False;
- m_aKeyIter = m_aKeyMap.begin();
- ++m_aKeyIter;
- if(m_aKeyIter == m_aKeyMap.end() && !fetchRow())
- m_aKeyIter = m_aKeyMap.end();
-
- refreshRow();
- return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin();
-}
-// -----------------------------------------------------------------------------
-sal_Bool SAL_CALL OptimisticSet::last( ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::last" );
- m_bInserted = m_bUpdated = m_bDeleted = sal_False;
- fillAllRows();
-
- m_aKeyIter = m_aKeyMap.end();
- --m_aKeyIter;
- refreshRow();
- return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin();
-}
-// -----------------------------------------------------------------------------
-sal_Int32 SAL_CALL OptimisticSet::getRow( ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getRow" );
- OSL_ENSURE(!isAfterLast(),"getRow is not allowed when afterlast record!");
- OSL_ENSURE(!isBeforeFirst(),"getRow is not allowed when beforefirst record!");
-
- return ::std::distance(m_aKeyMap.begin(),m_aKeyIter);
-}
-// -----------------------------------------------------------------------------
-sal_Bool SAL_CALL OptimisticSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::absolute" );
- m_bInserted = m_bUpdated = m_bDeleted = sal_False;
- OSL_ENSURE(row,"absolute(0) isn't allowed!");
- if(row < 0)
- {
- if(!m_bRowCountFinal)
- fillAllRows();
-
- for(;row < 0 && m_aKeyIter != m_aKeyMap.begin();++row)
- m_aKeyIter--;
- }
- else
- {
- if(row >= (sal_Int32)m_aKeyMap.size())
- {
- if(!m_bRowCountFinal)
- {
- sal_Bool bNext = sal_True;
- for(sal_Int32 i=m_aKeyMap.size()-1;i < row && bNext;++i)
- bNext = fetchRow();
- }
- else
- m_aKeyIter = m_aKeyMap.end();
- }
- else
- {
- m_aKeyIter = m_aKeyMap.begin();
- for(;row > 0 && m_aKeyIter != m_aKeyMap.end();--row)
- ++m_aKeyIter;
- }
- }
- refreshRow();
-
- return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin();
-}
-// -----------------------------------------------------------------------------
-sal_Bool SAL_CALL OptimisticSet::relative( sal_Int32 rows ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::relative" );
- if(!rows)
- {
- refreshRow();
- return sal_True;
- }
- return absolute(getRow()+rows);
-}
-// -----------------------------------------------------------------------------
-sal_Bool SAL_CALL OptimisticSet::previous( ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::previous" );
- m_bInserted = m_bUpdated = m_bDeleted = sal_False;
- if(m_aKeyIter != m_aKeyMap.begin())
- {
- --m_aKeyIter;
- refreshRow();
- }
- return m_aKeyIter != m_aKeyMap.begin();
-}
-// -----------------------------------------------------------------------------
-void SAL_CALL OptimisticSet::refreshRow() throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::refreshRow" );
- if(isBeforeFirst() || isAfterLast() || !m_xStatement.is())
- return;
-
- m_xSet.clear();
- ::comphelper::disposeComponent(m_xRow);
- // we just reassign the base members
- Reference< XParameters > xParameter(m_xStatement,UNO_QUERY);
- OSL_ENSURE(xParameter.is(),"No Parameter interface!");
- xParameter->clearParameters();
-
- sal_Int32 nPos=1;
- connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaIter;
- connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaEnd;
- OUpdatedParameter::iterator aUpdateFind = m_aUpdatedParameter.find(m_aKeyIter->first);
- if ( aUpdateFind == m_aUpdatedParameter.end() )
- {
- aParaIter = m_aParameterValueForCache.get().begin();
- aParaEnd = m_aParameterValueForCache.get().end();
- }
- else
- {
- aParaIter = aUpdateFind->second.get().begin();
- aParaEnd = aUpdateFind->second.get().end();
- }
-
- // first put the parameters set by the outer rowset
- for(++aParaIter;aParaIter != aParaEnd;++aParaIter,++nPos)
- {
- ::dbtools::setObjectWithInfo( xParameter, nPos, aParaIter->makeAny(), aParaIter->getTypeKind() );
- }
-
- // now set the primary key column values
- connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aIter = m_aKeyIter->second.first->get().begin();
- SelectColumnsMetaData::const_iterator aPosIter = m_pKeyColumnNames->begin();
- SelectColumnsMetaData::const_iterator aPosEnd = m_pKeyColumnNames->end();
- for(;aPosIter != aPosEnd;++aPosIter,++aIter,++nPos)
- setParameter(nPos,xParameter,*aIter,aPosIter->second.nType,aPosIter->second.nScale);
-
- m_xSet = m_xStatement->executeQuery();
- OSL_ENSURE(m_xSet.is(),"No resultset form statement!");
- sal_Bool bOK = m_xSet->next();
- if ( !bOK )
- m_aKeyIter = m_aKeyMap.end();
- m_xRow.set(m_xSet,UNO_QUERY);
- OSL_ENSURE(m_xRow.is(),"No row form statement!");
-}
-// -----------------------------------------------------------------------------
-sal_Bool OptimisticSet::fetchRow()
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::fetchRow" );
- // fetch the next row and append on the OptimisticSet
- sal_Bool bRet = sal_False;
- if ( !m_bRowCountFinal )
- bRet = m_xDriverSet->next();
- if ( bRet )
- {
- ORowSetRow aKeyRow = new connectivity::ORowVector< ORowSetValue >(m_pKeyColumnNames->size());
- connectivity::ORowVector< ORowSetValue >::Vector::iterator aIter = aKeyRow->get().begin();
- // first fetch the values needed for the key column
- SelectColumnsMetaData::const_iterator aPosIter = m_pKeyColumnNames->begin();
- SelectColumnsMetaData::const_iterator aPosEnd = m_pKeyColumnNames->end();
- for(;aPosIter != aPosEnd;++aPosIter,++aIter)
- {
- const SelectColumnDescription& rColDesc = aPosIter->second;
- aIter->fill(rColDesc.nPosition,rColDesc.nType,rColDesc.bNullable,m_xDriverRow);
- }
- m_aKeyIter = m_aKeyMap.insert(OKeySetMatrix::value_type(m_aKeyMap.rbegin()->first+1,OKeySetValue(aKeyRow,::std::pair<sal_Int32,Reference<XRow> >(0,NULL)))).first;
- }
- else
- m_bRowCountFinal = sal_True;
- return bRet;
-}
-// -------------------------------------------------------------------------
-void OptimisticSet::fillAllRows()
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::fillAllRows" );
- if(!m_bRowCountFinal)
- {
- while(fetchRow())
- ;
- }
-}
-// XRow
-sal_Bool SAL_CALL OptimisticSet::wasNull( ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::wasNull" );
- return m_xRow->wasNull();
-}
-// -------------------------------------------------------------------------
-::rtl::OUString SAL_CALL OptimisticSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getString" );
- OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
- return m_xRow->getString(columnIndex);
-}
-// -------------------------------------------------------------------------
-sal_Bool SAL_CALL OptimisticSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getBoolean" );
- OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
- return m_xRow->getBoolean(columnIndex);
-}
-// -------------------------------------------------------------------------
-sal_Int8 SAL_CALL OptimisticSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getByte" );
- OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
- return m_xRow->getByte(columnIndex);
-}
-// -------------------------------------------------------------------------
-sal_Int16 SAL_CALL OptimisticSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getShort" );
- OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
- return m_xRow->getShort(columnIndex);
-}
-// -------------------------------------------------------------------------
-sal_Int32 SAL_CALL OptimisticSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getInt" );
- OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
- return m_xRow->getInt(columnIndex);
-}
-// -------------------------------------------------------------------------
-sal_Int64 SAL_CALL OptimisticSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getLong" );
- OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
- return m_xRow->getLong(columnIndex);
-}
-// -------------------------------------------------------------------------
-float SAL_CALL OptimisticSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getFloat" );
- OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
- return m_xRow->getFloat(columnIndex);
-}
-// -------------------------------------------------------------------------
-double SAL_CALL OptimisticSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getDouble" );
- OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
- return m_xRow->getDouble(columnIndex);
-}
-// -------------------------------------------------------------------------
-Sequence< sal_Int8 > SAL_CALL OptimisticSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getBytes" );
- OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
- return m_xRow->getBytes(columnIndex);
-}
-// -------------------------------------------------------------------------
-::com::sun::star::util::Date SAL_CALL OptimisticSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getDate" );
- OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
- return m_xRow->getDate(columnIndex);
-}
-// -------------------------------------------------------------------------
-::com::sun::star::util::Time SAL_CALL OptimisticSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getTime" );
- OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
- return m_xRow->getTime(columnIndex);
-}
-// -------------------------------------------------------------------------
-::com::sun::star::util::DateTime SAL_CALL OptimisticSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getTimestamp" );
- OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
- return m_xRow->getTimestamp(columnIndex);
-}
-// -------------------------------------------------------------------------
-Reference< ::com::sun::star::io::XInputStream > SAL_CALL OptimisticSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getBinaryStream" );
- OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
- return m_xRow->getBinaryStream(columnIndex);
-}
-// -------------------------------------------------------------------------
-Reference< ::com::sun::star::io::XInputStream > SAL_CALL OptimisticSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getCharacterStream" );
- OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
- return m_xRow->getCharacterStream(columnIndex);
-}
-// -------------------------------------------------------------------------
-Any SAL_CALL OptimisticSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getObject" );
- OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
- return m_xRow->getObject(columnIndex,typeMap);
-}
-// -------------------------------------------------------------------------
-Reference< XRef > SAL_CALL OptimisticSet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getRef" );
- OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
- return m_xRow->getRef(columnIndex);
-}
-// -------------------------------------------------------------------------
-Reference< XBlob > SAL_CALL OptimisticSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getBlob" );
- OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
- return m_xRow->getBlob(columnIndex);
-}
-// -------------------------------------------------------------------------
-Reference< XClob > SAL_CALL OptimisticSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getClob" );
- OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
- return m_xRow->getClob(columnIndex);
-}
-// -------------------------------------------------------------------------
-Reference< XArray > SAL_CALL OptimisticSet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::getArray" );
- OSL_ENSURE(m_xRow.is(),"m_xRow is null!");
- return m_xRow->getArray(columnIndex);
-}
-// -------------------------------------------------------------------------
-sal_Bool SAL_CALL OptimisticSet::rowUpdated( ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::rowUpdated" );
- return m_aKeyIter != m_aKeyMap.begin() && m_aKeyIter != m_aKeyMap.end() && m_aKeyIter->second.second.first == 2;
-}
-// -------------------------------------------------------------------------
-sal_Bool SAL_CALL OptimisticSet::rowInserted( ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::rowInserted" );
- return m_aKeyIter != m_aKeyMap.begin() && m_aKeyIter != m_aKeyMap.end() && m_aKeyIter->second.second.first == 1;
-}
-// -------------------------------------------------------------------------
-sal_Bool SAL_CALL OptimisticSet::rowDeleted( ) throw(SQLException, RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OptimisticSet::rowDeleted" );
- sal_Bool bDeleted = m_bDeleted;
- m_bDeleted = sal_False;
- return bDeleted;
-}
// -----------------------------------------------------------------------------
::rtl::OUString OptimisticSet::getComposedTableName(const ::rtl::OUString& /*_sCatalog*/,
const ::rtl::OUString& /*_sSchema*/,
@@ -1215,200 +484,6 @@ sal_Bool SAL_CALL OptimisticSet::rowDeleted( ) throw(SQLException, RuntimeExcep
return aComposedName;
}
// -----------------------------------------------------------------------------
-/*
-namespace dbaccess
-{
- void getColumnPositions(const Reference<XNameAccess>& _rxQueryColumns,
- const Sequence< ::rtl::OUString>& _aColumnNames,
- const ::rtl::OUString& _rsUpdateTableName,
- SelectColumnsMetaData& _rColumnNames)
- {
- // get the real name of the columns
- Sequence< ::rtl::OUString> aSelNames(_rxQueryColumns->getElementNames());
- const ::rtl::OUString* pSelBegin = aSelNames.getConstArray();
- const ::rtl::OUString* pSelEnd = pSelBegin + aSelNames.getLength();
-
- const ::rtl::OUString* pColumnIter = _aColumnNames.getConstArray();
- const ::rtl::OUString* pColumnEnd = pColumnIter + _aColumnNames.getLength();
-
- ::comphelper::UStringMixLess aTmp(_rColumnNames.key_comp());
- ::comphelper::UStringMixEqual bCase(static_cast< ::comphelper::UStringMixLess*>(&aTmp)->isCaseSensitive());
-
- for(sal_Int32 nPos = 1;pSelBegin != pSelEnd;++pSelBegin,++nPos)
- {
- Reference<XPropertySet> xColumnProp(_rxQueryColumns->getByName(*pSelBegin),UNO_QUERY);
- ::rtl::OUString sRealName,sTableName;
- OSL_ENSURE(xColumnProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_REALNAME),"Property REALNAME not available!");
- OSL_ENSURE(xColumnProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_TABLENAME),"Property TABLENAME not available!");
- xColumnProp->getPropertyValue(PROPERTY_REALNAME) >>= sRealName;
- xColumnProp->getPropertyValue(PROPERTY_TABLENAME) >>= sTableName;
-
- for(;pColumnIter != pColumnEnd;++pColumnIter)
- {
- if(bCase(sRealName,*pColumnIter) && bCase(_rsUpdateTableName,sTableName) && _rColumnNames.find(*pColumnIter) == _rColumnNames.end())
- {
- sal_Int32 nType = 0;
- xColumnProp->getPropertyValue(PROPERTY_TYPE) >>= nType;
- sal_Int32 nScale = 0;
- xColumnProp->getPropertyValue(PROPERTY_SCALE) >>= nScale;
- ::rtl::OUString sColumnDefault;
- if ( xColumnProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_DEFAULTVALUE) )
- xColumnProp->getPropertyValue(PROPERTY_DEFAULTVALUE) >>= sColumnDefault;
-
- sal_Int32 bNullable = sal_False;
- xColumnProp->getPropertyValue(PROPERTY_ISNULLABLE) >>= bNullable;
-
-
- _rColumnNames[sRealName] = SelectColumnDescription( nPos, nType,nScale,bNullable != sdbc::ColumnValue::NO_NULLS, sColumnDefault );
- break;
- }
- }
- pColumnIter = _aColumnNames.getConstArray();
- }
- }
-}
-*/
-// -----------------------------------------------------------------------------
-void OptimisticSet::impl_convertValue_throw(const ORowSetRow& _rInsertRow,const SelectColumnDescription& i_aMetaData)
-{
- ORowSetValue& aValue((_rInsertRow->get())[i_aMetaData.nPosition]);
- switch(i_aMetaData.nType)
- {
- case DataType::DECIMAL:
- case DataType::NUMERIC:
- {
- ::rtl::OUString sValue = aValue.getString();
- sal_Int32 nIndex = sValue.indexOf('.');
- if ( nIndex != -1 )
- {
- aValue = sValue.copy(0,nIndex + (i_aMetaData.nScale > 0 ? i_aMetaData.nScale + 1 : 0));
- }
- }
- break;
- default:
- break;
- }
-}
-// -----------------------------------------------------------------------------
-void OptimisticSet::findTableColumnsMatching_throw(const Any& i_aTable
- ,const Reference<XDatabaseMetaData>& i_xMeta
- ,const Reference<XNameAccess>& i_xQueryColumns)
-{
- ::rtl::OUString sCatalog,sSchema,sTable;
- Reference<XPropertySet> xTableProp(i_aTable,UNO_QUERY);
- Any aCatalog = xTableProp->getPropertyValue(PROPERTY_CATALOGNAME);
- aCatalog >>= sCatalog;
- xTableProp->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema;
- xTableProp->getPropertyValue(PROPERTY_NAME) >>= sTable;
-
- // first ask the database itself for the best columns which can be used
- ::std::vector< ::rtl::OUString> aBestRowColumnNames;
- Reference<XResultSet> xBestRes(i_xMeta->getBestRowIdentifier(aCatalog,sSchema,sTable,0,sal_False));
- Reference<XRow> xBestRow(xBestRes,uno::UNO_QUERY);
- while ( xBestRes->next() )
- {
- aBestRowColumnNames.push_back(xBestRow->getString(2));
- }
-
- Sequence< ::rtl::OUString> aBestColumnNames;
- if ( aBestRowColumnNames.empty() )
- {
- Reference<XNameAccess> xKeyColumns = getPrimaryKeyColumns_throw(i_aTable);
- if ( xKeyColumns.is() )
- aBestColumnNames = xKeyColumns->getElementNames();
- }
- else
- aBestColumnNames = Sequence< ::rtl::OUString>(&aBestRowColumnNames[0],aBestRowColumnNames.size());
-
- const Reference<XColumnsSupplier> xTblColSup(i_aTable,UNO_QUERY_THROW);
- const Reference<XNameAccess> xTblColumns = xTblColSup->getColumns();
- const ::rtl::OUString sComposedUpdateTableName = dbtools::composeTableName( i_xMeta, sCatalog, sSchema, sTable, sal_False, ::dbtools::eInDataManipulation );
- ::dbaccess::getColumnPositions(i_xQueryColumns,aBestColumnNames,sComposedUpdateTableName,(*m_pKeyColumnNames),true);
- ::dbaccess::getColumnPositions(i_xQueryColumns,xTblColumns->getElementNames(),sComposedUpdateTableName,(*m_pColumnNames),true);
-
- // locate parameter in select columns
- Reference<XParametersSupplier> xParaSup(m_xComposer,UNO_QUERY);
- Reference<XIndexAccess> xQueryParameters = xParaSup->getParameters();
- const sal_Int32 nParaCount = xQueryParameters->getCount();
- Sequence< ::rtl::OUString> aParameterColumns(nParaCount);
- for(sal_Int32 i = 0; i< nParaCount;++i)
- {
- Reference<XPropertySet> xPara(xQueryParameters->getByIndex(i),UNO_QUERY_THROW);
- xPara->getPropertyValue(PROPERTY_REALNAME) >>= aParameterColumns[i];
- }
- ::dbaccess::getColumnPositions(i_xQueryColumns,aParameterColumns,sComposedUpdateTableName,(*m_pParameterNames),true);
-
- SelectColumnsMetaData::const_iterator aPosIter = m_pKeyColumnNames->begin();
- SelectColumnsMetaData::const_iterator aPosEnd = m_pKeyColumnNames->end();
- for(;aPosIter != aPosEnd;++aPosIter)
- {
- if ( xTblColumns->hasByName(aPosIter->second.sRealName) )
- {
- Reference<XPropertySet> xProp(xTblColumns->getByName(aPosIter->second.sRealName),UNO_QUERY);
- sal_Bool bAuto = sal_False;
- if( (xProp->getPropertyValue(PROPERTY_ISAUTOINCREMENT) >>= bAuto) && bAuto)
- m_aAutoColumns.push_back(aPosIter->first);
- }
- }
-}
-// -----------------------------------------------------------------------------
-void OptimisticSet::executeUpdate(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName)
-{
- // now create end execute the prepared statement
- Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(i_sSQL));
- Reference< XParameters > xParameter(xPrep,UNO_QUERY);
-
- sal_Int32 i = 1;
- // first the set values
- SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin();
- SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end();
- sal_uInt16 j = 0;
- for(;aIter != aEnd;++aIter,++j)
- {
- if ( aIter->second.sTableName == i_sTableName )
- {
- sal_Int32 nPos = aIter->second.nPosition;
- if((_rInsertRow->get())[nPos].isModified())
- {
- impl_convertValue_throw(_rInsertRow,aIter->second);
- (_rInsertRow->get())[nPos].setSigned((_rOrginalRow->get())[nPos].isSigned());
- setParameter(i++,xParameter,(_rInsertRow->get())[nPos],aIter->second.nType,aIter->second.nScale);
- }
- }
- }
- // and then the values of the where condition
- aIter = m_pKeyColumnNames->begin();
- aEnd = m_pKeyColumnNames->end();
- j = 0;
- for(;aIter != aEnd;++aIter,++j)
- {
- if ( aIter->second.sTableName == i_sTableName )
- {
- setParameter(i++,xParameter,(_rOrginalRow->get())[aIter->second.nPosition],aIter->second.nType,aIter->second.nScale);
- }
- }
-/*
- // now we have to set the index values
- ::std::vector<sal_Int32>::iterator aIdxColIter = aIndexColumnPositions.begin();
- ::std::vector<sal_Int32>::iterator aIdxColEnd = aIndexColumnPositions.end();
- j = 0;
- aIter = m_pColumnNames->begin();
- for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i,++j,++aIter)
- {
- setParameter(i,xParameter,(_rOrginalRow->get())[*aIdxColIter],(_rOrginalRow->get())[*aIdxColIter].getTypeKind(),aIter->second.nScale);
- }
-*/
- const sal_Int32 nRowsUpdated = xPrep->executeUpdate();
- m_bUpdated = nRowsUpdated > 0;
- if(m_bUpdated)
- {
- const sal_Int32 nBookmark = ::comphelper::getINT32((_rInsertRow->get())[0].getAny());
- m_aKeyIter = m_aKeyMap.find(nBookmark);
- m_aKeyIter->second.second.first = 2;
- copyRowValue(_rInsertRow,m_aKeyIter->second.first,nBookmark);
- }
-}
-// -----------------------------------------------------------------------------
void OptimisticSet::fillJoinedColumns_throw(const ::std::vector< TNodePair >& i_aJoinColumns)
{
::std::vector< TNodePair >::const_iterator aIter = i_aJoinColumns.begin();
diff --git a/dbaccess/source/core/api/OptimisticSet.hxx b/dbaccess/source/core/api/OptimisticSet.hxx
index 1f42bebdf..fd1b304a7 100644
--- a/dbaccess/source/core/api/OptimisticSet.hxx
+++ b/dbaccess/source/core/api/OptimisticSet.hxx
@@ -31,11 +31,9 @@
#ifndef DBACCESS_CORE_API_OPTIMISTICSET_HXX
#define DBACCESS_CORE_API_OPTIMISTICSET_HXX
-#include "CacheSet.hxx"
#include "KeySet.hxx"
#include <cppuhelper/implbase1.hxx>
-#include <map>
-#include <memory>
+
#include <connectivity/sqlparse.hxx>
#include <connectivity/sqliterator.hxx>
@@ -47,29 +45,15 @@
namespace dbaccess
{
// is used when the source supports keys
- class OptimisticSet : public OCacheSet
+ class OptimisticSet : public OKeySet
{
::connectivity::OSQLParser m_aSqlParser;
::connectivity::OSQLParseTreeIterator m_aSqlIterator;
- OKeySetMatrix m_aKeyMap;
- OKeySetMatrix::iterator m_aKeyIter;
- ::std::vector< ::rtl::OUString > m_aAutoColumns; // contains all columns which are autoincrement ones
::std::map<sal_Int32,sal_Int32> m_aJoinedColumns;
- ::std::map<sal_Int32,sal_Int32> m_aJoinedKeyColumns;
-
- OUpdatedParameter m_aUpdatedParameter; // contains all parameter which have been updated and are needed for refetching
- ORowSetValueVector m_aParameterValueForCache;
- ::std::auto_ptr<SelectColumnsMetaData> m_pKeyColumnNames; // contains all key column names
- ::std::auto_ptr<SelectColumnsMetaData> m_pColumnNames; // contains all column names
- ::std::auto_ptr<SelectColumnsMetaData> m_pParameterNames; // contains all parameter names
- connectivity::OSQLTable m_xTable; // reference to our table
- ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement> m_xStatement;
- ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> m_xSet;
- ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow> m_xRow;
- ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer > m_xComposer;
+ ::std::map<sal_Int32,sal_Int32> m_aJoinedKeyColumns;
+
- sal_Bool m_bRowCountFinal;
mutable bool m_bResultSetChanged;
/**
@@ -83,24 +67,9 @@ namespace dbaccess
::rtl::OUString getComposedTableName( const ::rtl::OUString& _sCatalog,
const ::rtl::OUString& _sSchema,
const ::rtl::OUString& _sTable);
-
- /** copies the values from the insert row into the key row
- *
- * \param _rInsertRow the row which was inserted
- * \param _rKeyRow The current key row of the row set.
- + \param i_nBookmark The bookmark is used to update the parameter
- */
- void copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow,sal_Int32 i_nBookmark);
-
- void fillAllRows();
- sal_Bool fetchRow();
-
+
void impl_convertValue_throw(const ORowSetRow& _rInsertRow,const SelectColumnDescription& i_aMetaData);
- void findTableColumnsMatching_throw( const ::com::sun::star::uno::Any& i_aTable
- ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& i_xMeta
- ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& i_xQueryColumns);
- void executeUpdate(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName);
- void executeInsert( const ORowSetRow& _rInsertRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName);
+
void executeDelete(const ORowSetRow& _rDeleteRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName);
void fillJoinedColumns_throw(const ::std::vector< ::connectivity::TNodePair>& i_aJoinColumns);
void fillJoinedColumns_throw(const ::rtl::OUString& i_sLeftColumn,const ::rtl::OUString& i_sRightColumn);
@@ -115,59 +84,6 @@ namespace dbaccess
// late ctor which can throw exceptions
virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter);
- // ::com::sun::star::sdbc::XRow
- virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
-
-
- virtual sal_Bool SAL_CALL rowUpdated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL rowInserted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL rowDeleted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- // ::com::sun::star::sdbc::XResultSet
- virtual sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL isBeforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL isAfterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL isFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL isLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL beforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL afterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL last( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL previous( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL refreshRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- // ::com::sun::star::sdbcx::XRowLocate
- virtual ::com::sun::star::uno::Any SAL_CALL getBookmark() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- // -------------------------------------------------------------------------
- virtual sal_Bool SAL_CALL moveToBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- // -------------------------------------------------------------------------
- virtual sal_Bool SAL_CALL moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- // -------------------------------------------------------------------------
- virtual sal_Int32 SAL_CALL compareBookmarks( const ::com::sun::star::uno::Any& first, const ::com::sun::star::uno::Any& second ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- // -------------------------------------------------------------------------
- virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- // -------------------------------------------------------------------------
- virtual sal_Int32 SAL_CALL hashBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
// -------------------------------------------------------------------------
// ::com::sun::star::sdbcx::XDeleteRows
virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL deleteRows( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rows ,const connectivity::OSQLTable& _xTable) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
@@ -175,9 +91,6 @@ namespace dbaccess
virtual void SAL_CALL updateRow(const ORowSetRow& _rInsertRow,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL deleteRow(const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
// CacheSet
virtual bool isResultSetChanged() const;
diff --git a/dbaccess/source/core/api/PrivateRow.cxx b/dbaccess/source/core/api/PrivateRow.cxx
new file mode 100644
index 000000000..2d3baedc4
--- /dev/null
+++ b/dbaccess/source/core/api/PrivateRow.cxx
@@ -0,0 +1,142 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle andor 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 "PrivateRow.hxx"
+
+using namespace dbaccess;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star;
+
+::sal_Bool SAL_CALL OPrivateRow::wasNull( ) throw (SQLException, RuntimeException)
+ {
+ return m_aRow[m_nPos].isNull();
+ }
+ ::rtl::OUString SAL_CALL OPrivateRow::getString( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ ::sal_Bool SAL_CALL OPrivateRow::getBoolean( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ ::sal_Int8 SAL_CALL OPrivateRow::getByte( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ ::sal_Int16 SAL_CALL OPrivateRow::getShort( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ ::sal_Int32 SAL_CALL OPrivateRow::getInt( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ ::sal_Int64 SAL_CALL OPrivateRow::getLong( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ float SAL_CALL OPrivateRow::getFloat( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ double SAL_CALL OPrivateRow::getDouble( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ Sequence< ::sal_Int8 > SAL_CALL OPrivateRow::getBytes( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ ::com::sun::star::util::Date SAL_CALL OPrivateRow::getDate( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ ::com::sun::star::util::Time SAL_CALL OPrivateRow::getTime( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ ::com::sun::star::util::DateTime SAL_CALL OPrivateRow::getTimestamp( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos];
+ }
+ Reference< ::com::sun::star::io::XInputStream > SAL_CALL OPrivateRow::getBinaryStream( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return Reference< ::com::sun::star::io::XInputStream >(m_aRow[m_nPos].makeAny(),UNO_QUERY);
+ }
+ Reference< ::com::sun::star::io::XInputStream > SAL_CALL OPrivateRow::getCharacterStream( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return Reference< ::com::sun::star::io::XInputStream >(m_aRow[m_nPos].makeAny(),UNO_QUERY);
+ }
+ Any SAL_CALL OPrivateRow::getObject( ::sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return m_aRow[m_nPos].makeAny();
+ }
+ Reference< XRef > SAL_CALL OPrivateRow::getRef( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return Reference< XRef >(m_aRow[m_nPos].makeAny(),UNO_QUERY);
+ }
+ Reference< XBlob > SAL_CALL OPrivateRow::getBlob( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return Reference< XBlob >(m_aRow[m_nPos].makeAny(),UNO_QUERY);
+ }
+ Reference< XClob > SAL_CALL OPrivateRow::getClob( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return Reference< XClob >(m_aRow[m_nPos].makeAny(),UNO_QUERY);
+ }
+ Reference< XArray > SAL_CALL OPrivateRow::getArray( ::sal_Int32 columnIndex ) throw (SQLException, RuntimeException)
+ {
+ m_nPos = columnIndex;
+ return Reference< XArray >(m_aRow[m_nPos].makeAny(),UNO_QUERY);
+ }
+
diff --git a/dbaccess/source/core/api/PrivateRow.hxx b/dbaccess/source/core/api/PrivateRow.hxx
new file mode 100644
index 000000000..aabcb0d4a
--- /dev/null
+++ b/dbaccess/source/core/api/PrivateRow.hxx
@@ -0,0 +1,69 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: OptimisticSet.cxx,v $
+ * $Revision: 1.73 $
+ *
+ * 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 PRIVATE_ROW_HXX
+#define PRIVATE_ROW_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include "RowSetRow.hxx"
+
+namespace dbaccess
+{
+ class OPrivateRow : public ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XRow>
+ {
+ ORowSetValueVector::Vector m_aRow;
+ sal_Int32 m_nPos;
+ public:
+ OPrivateRow(const ORowSetValueVector::Vector& i_aRow) : m_aRow(i_aRow),m_nPos(0)
+ {
+ }
+ virtual ::sal_Bool SAL_CALL wasNull( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getString( ::sal_Int32 columnIndex ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getBoolean( ::sal_Int32 columnIndex ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int8 SAL_CALL getByte( ::sal_Int32 columnIndex ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int16 SAL_CALL getShort( ::sal_Int32 columnIndex ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getInt( ::sal_Int32 columnIndex ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int64 SAL_CALL getLong( ::sal_Int32 columnIndex ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual float SAL_CALL getFloat( ::sal_Int32 columnIndex ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual double SAL_CALL getDouble( ::sal_Int32 columnIndex ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL getBytes( ::sal_Int32 columnIndex ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::Date SAL_CALL getDate( ::sal_Int32 columnIndex ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::Time SAL_CALL getTime( ::sal_Int32 columnIndex ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( ::sal_Int32 columnIndex ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( ::sal_Int32 columnIndex ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( ::sal_Int32 columnIndex ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getObject( ::sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( ::sal_Int32 columnIndex ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( ::sal_Int32 columnIndex ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( ::sal_Int32 columnIndex ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( ::sal_Int32 columnIndex ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+} // dbaccess
+#endif // PRIVATE_ROW_HXX
diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx
index 20483cff0..1f7c0294f 100644
--- a/dbaccess/source/core/api/RowSet.cxx
+++ b/dbaccess/source/core/api/RowSet.cxx
@@ -580,6 +580,9 @@ void ORowSet::freeResources( bool _bComplete )
m_xComposer = NULL;
}
+ // let our warnings container forget the reference to the (possibly disposed) old result set
+ m_aWarnings.setExternalWarnings( NULL );
+
DELETEZ(m_pCache);
impl_resetTables_nothrow();
diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx
index 295e29ebe..d42c8d20f 100644
--- a/dbaccess/source/core/api/RowSetCache.cxx
+++ b/dbaccess/source/core/api/RowSetCache.cxx
@@ -158,17 +158,25 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
try
{
Reference< XResultSetUpdate> xUp(_xRs,UNO_QUERY_THROW);
- xUp->moveToInsertRow();
- xUp->cancelRowUpdates();
- _xRs->beforeFirst();
- m_nPrivileges = Privilege::SELECT|Privilege::DELETE|Privilege::INSERT|Privilege::UPDATE;
- m_pCacheSet = new WrappedResultSet();
- m_xCacheSet = m_pCacheSet;
- m_pCacheSet->construct(_xRs,i_sRowSetFilter);
- return;
+ Reference< XPropertySet> xProp(_xRs,UNO_QUERY);
+ Reference< XPropertySetInfo > xPropInfo = xProp->getPropertySetInfo();
+ sal_Bool bBookmarkable = xPropInfo->hasPropertyByName(PROPERTY_ISBOOKMARKABLE) &&
+ any2bool(xProp->getPropertyValue(PROPERTY_ISBOOKMARKABLE)) && Reference< XRowLocate >(_xRs, UNO_QUERY).is();
+ if ( bBookmarkable )
+ {
+ xUp->moveToInsertRow();
+ xUp->cancelRowUpdates();
+ _xRs->beforeFirst();
+ m_nPrivileges = Privilege::SELECT|Privilege::DELETE|Privilege::INSERT|Privilege::UPDATE;
+ m_pCacheSet = new WrappedResultSet();
+ m_xCacheSet = m_pCacheSet;
+ m_pCacheSet->construct(_xRs,i_sRowSetFilter);
+ return;
+ }
}
- catch(const Exception&)
+ catch(const Exception& ex)
{
+ (void)ex;
}
_xRs->beforeFirst();
diff --git a/dbaccess/source/core/api/WrappedResultSet.cxx b/dbaccess/source/core/api/WrappedResultSet.cxx
index 6e8175b2e..0b9c6b6c2 100644
--- a/dbaccess/source/core/api/WrappedResultSet.cxx
+++ b/dbaccess/source/core/api/WrappedResultSet.cxx
@@ -64,43 +64,41 @@ void WrappedResultSet::construct(const Reference< XResultSet>& _xDriverSet,const
Any SAL_CALL WrappedResultSet::getBookmark() throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::getBookmark" );
+ if ( m_xRowLocate.is() )
+ {
+ return m_xRowLocate->getBookmark( );
+ }
return makeAny(m_xDriverSet->getRow());
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL WrappedResultSet::moveToBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::moveToBookmark" );
- sal_Int32 nPos = 1;
- bookmark >>= nPos;
- return m_xDriverSet->absolute(nPos);
+ return m_xRowLocate->moveToBookmark( bookmark );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL WrappedResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::moveRelativeToBookmark" );
- sal_Int32 nPos = 1;
- bookmark >>= nPos;
- return m_xDriverSet->absolute(nPos + rows);
+ return m_xRowLocate->moveRelativeToBookmark( bookmark,rows );
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL WrappedResultSet::compareBookmarks( const Any& _first, const Any& _second ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::compareBookmarks" );
- return _first != _second;
+ return m_xRowLocate->compareBookmarks( _first,_second );
}
// -------------------------------------------------------------------------
sal_Bool SAL_CALL WrappedResultSet::hasOrderedBookmarks( ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::hasOrderedBookmarks" );
- return sal_True;
+ return m_xRowLocate->hasOrderedBookmarks();
}
// -------------------------------------------------------------------------
sal_Int32 SAL_CALL WrappedResultSet::hashBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::hashBookmark" );
- sal_Int32 nPos = 1;
- bookmark >>= nPos;
- return nPos;
+ return m_xRowLocate->hashBookmark(bookmark);
}
// -------------------------------------------------------------------------
// ::com::sun::star::sdbcx::XDeleteRows
@@ -128,7 +126,7 @@ void SAL_CALL WrappedResultSet::insertRow( const ORowSetRow& _rInsertRow,const c
updateColumn(i,m_xUpdRow,*aIter);
}
m_xUpd->insertRow();
- (*_rInsertRow->get().begin()) = m_xDriverSet->getRow();
+ (*_rInsertRow->get().begin()) = getBookmark();
}
// -------------------------------------------------------------------------
void SAL_CALL WrappedResultSet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& /*_xTable*/ ) throw(SQLException, RuntimeException)
@@ -166,6 +164,7 @@ void SAL_CALL WrappedResultSet::moveToInsertRow( ) throw(SQLException, RuntimeE
void SAL_CALL WrappedResultSet::moveToCurrentRow( ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "WrappedResultSet::moveToCurrentRow" );
+ m_xUpd->moveToCurrentRow();
}
// -------------------------------------------------------------------------
void WrappedResultSet::fillValueRow(ORowSetRow& _rRow,sal_Int32 _nPosition)
diff --git a/dbaccess/source/core/api/makefile.mk b/dbaccess/source/core/api/makefile.mk
index 7af260080..9a4dc9d8e 100644
--- a/dbaccess/source/core/api/makefile.mk
+++ b/dbaccess/source/core/api/makefile.mk
@@ -73,6 +73,7 @@ SLOFILES= \
$(SLO)$/View.obj \
$(SLO)$/WrappedResultSet.obj \
$(SLO)$/OptimisticSet.obj \
+ $(SLO)$/PrivateRow.obj \
$(SLO)$/columnsettings.obj
# --- Targets ----------------------------------
diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx
index e3f75ef69..6a1151580 100644
--- a/dbaccess/source/core/dataaccess/datasource.cxx
+++ b/dbaccess/source/core/dataaccess/datasource.cxx
@@ -38,6 +38,7 @@
#include "connection.hxx"
#include "SharedConnection.hxx"
#include "databasedocument.hxx"
+#include "OAuthenticationContinuation.hxx"
/** === begin UNO includes === **/
@@ -206,40 +207,10 @@ void SAL_CALL FlushNotificationAdapter::disposing( const EventObject& Source ) t
impl_dispose( false );
}
-//============================================================
-//= OAuthenticationContinuation
-//============================================================
-class OAuthenticationContinuation : public OInteraction< XInteractionSupplyAuthentication >
-{
- sal_Bool m_bRemberPassword : 1; // remember the password for this session ?
-
- ::rtl::OUString m_sUser; // the user
- ::rtl::OUString m_sPassword; // the user's password
-
-public:
- OAuthenticationContinuation();
-
- sal_Bool SAL_CALL canSetRealm( ) throw(RuntimeException);
- void SAL_CALL setRealm( const ::rtl::OUString& Realm ) throw(RuntimeException);
- sal_Bool SAL_CALL canSetUserName( ) throw(RuntimeException);
- void SAL_CALL setUserName( const ::rtl::OUString& UserName ) throw(RuntimeException);
- sal_Bool SAL_CALL canSetPassword( ) throw(RuntimeException);
- void SAL_CALL setPassword( const ::rtl::OUString& Password ) throw(RuntimeException);
- Sequence< RememberAuthentication > SAL_CALL getRememberPasswordModes( RememberAuthentication& Default ) throw(RuntimeException);
- void SAL_CALL setRememberPassword( RememberAuthentication Remember ) throw(RuntimeException);
- sal_Bool SAL_CALL canSetAccount( ) throw(RuntimeException);
- void SAL_CALL setAccount( const ::rtl::OUString& Account ) throw(RuntimeException);
- Sequence< RememberAuthentication > SAL_CALL getRememberAccountModes( RememberAuthentication& Default ) throw(RuntimeException);
- void SAL_CALL setRememberAccount( RememberAuthentication Remember ) throw(RuntimeException);
-
- ::rtl::OUString getUser() const { return m_sUser; }
- ::rtl::OUString getPassword() const { return m_sPassword; }
- sal_Bool getRememberPassword() const { return m_bRemberPassword; }
-};
-
//--------------------------------------------------------------------------
OAuthenticationContinuation::OAuthenticationContinuation()
- :m_bRemberPassword(sal_True) // TODO: a meaningfull default
+ :m_bRemberPassword(sal_True), // TODO: a meaningfull default
+ m_bCanSetUserName(sal_True)
{
}
@@ -260,7 +231,7 @@ sal_Bool SAL_CALL OAuthenticationContinuation::canSetUserName( ) throw(RuntimeE
{
// we alwas allow this, even if the database document is read-only. In this case,
// it's simply that the user cannot store the new user name.
- return sal_True;
+ return m_bCanSetUserName;
}
//--------------------------------------------------------------------------
diff --git a/dbaccess/source/core/inc/DatabaseDataProvider.hxx b/dbaccess/source/core/inc/DatabaseDataProvider.hxx
index c29b487f2..ade231e50 100644
--- a/dbaccess/source/core/inc/DatabaseDataProvider.hxx
+++ b/dbaccess/source/core/inc/DatabaseDataProvider.hxx
@@ -201,7 +201,7 @@ private:
void impl_fillRowSet_throw();
void impl_executeRowSet_throw(::osl::ResettableMutexGuard& _rClearForNotifies);
bool impl_fillParameters_nothrow( ::osl::ResettableMutexGuard& _rClearForNotifies);
- void impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories);
+ void impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories,const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > >& i_aColumnNames);
void impl_invalidateParameter_nothrow();
::com::sun::star::uno::Any impl_getNumberFormatKey_nothrow(const ::rtl::OUString & _sRangeRepresentation) const;
diff --git a/dbaccess/source/core/misc/DatabaseDataProvider.cxx b/dbaccess/source/core/misc/DatabaseDataProvider.cxx
index ec6f6cbb9..1b4ea8f4d 100644
--- a/dbaccess/source/core/misc/DatabaseDataProvider.cxx
+++ b/dbaccess/source/core/misc/DatabaseDataProvider.cxx
@@ -204,6 +204,7 @@ uno::Reference< chart2::data::XDataSource > SAL_CALL DatabaseDataProvider::creat
if ( createDataSourcePossible(_aArguments) )
{
sal_Bool bHasCategories = sal_True;
+ uno::Sequence< uno::Sequence< ::rtl::OUString > > aColumnNames;
const beans::PropertyValue* pArgIter = _aArguments.getConstArray();
const beans::PropertyValue* pArgEnd = pArgIter + _aArguments.getLength();
for(;pArgIter != pArgEnd;++pArgIter)
@@ -211,7 +212,11 @@ uno::Reference< chart2::data::XDataSource > SAL_CALL DatabaseDataProvider::creat
if ( pArgIter->Name.equalsAscii("HasCategories") )
{
pArgIter->Value >>= bHasCategories;
- break;
+
+ }
+ else if ( pArgIter->Name.equalsAscii("ComplexColumnDescriptions") )
+ {
+ pArgIter->Value >>= aColumnNames;
}
}
bool bRet = false;
@@ -221,7 +226,7 @@ uno::Reference< chart2::data::XDataSource > SAL_CALL DatabaseDataProvider::creat
{
impl_fillRowSet_throw();
impl_executeRowSet_throw(aClearForNotifies);
- impl_fillInternalDataProvider_throw(bHasCategories);
+ impl_fillInternalDataProvider_throw(bHasCategories,aColumnNames);
bRet = true;
}
catch(const uno::Exception& /*e*/)
@@ -574,7 +579,7 @@ void DatabaseDataProvider::impl_executeRowSet_throw(::osl::ResettableMutexGuard&
m_xRowSet->execute();
}
// -----------------------------------------------------------------------------
-void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories)
+void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories,const uno::Sequence< uno::Sequence< ::rtl::OUString > >& i_aColumnNames)
{
// clear the data before fill the new one
uno::Reference< chart::XChartDataArray> xChartData(m_xInternal,uno::UNO_QUERY);
@@ -586,11 +591,27 @@ void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCat
m_xInternal->deleteSequence(0);
}
- uno::Sequence< ::rtl::OUString > aColumns;
uno::Reference< sdbcx::XColumnsSupplier> xColSup(m_xRowSet,uno::UNO_QUERY_THROW);
uno::Reference< container::XNameAccess > xColumns = xColSup->getColumns();
- if ( xColumns.is() )
+ uno::Sequence< ::rtl::OUString > aColumns;
+ if ( i_aColumnNames.getLength() )
+ {
+ aColumns.realloc(1);
+ aColumns[0] = xColumns->getElementNames()[0];
+ for(sal_Int32 i = 0 ; i < i_aColumnNames.getLength();++i)
+ {
+ if ( i_aColumnNames[i].getLength() )
+ {
+ sal_Int32 nCount = aColumns.getLength();
+ aColumns.realloc(nCount+1);
+ aColumns[nCount] = i_aColumnNames[i][0];
+ }
+ }
+ }
+ else
+ {
aColumns = xColumns->getElementNames();
+ }
// fill the data
uno::Reference< sdbc::XResultSet> xRes(m_xRowSet,uno::UNO_QUERY_THROW);
uno::Reference< sdbc::XRow> xRow(m_xRowSet,uno::UNO_QUERY_THROW);
diff --git a/dbaccess/source/inc/OAuthenticationContinuation.hxx b/dbaccess/source/inc/OAuthenticationContinuation.hxx
new file mode 100644
index 000000000..8f44097e4
--- /dev/null
+++ b/dbaccess/source/inc/OAuthenticationContinuation.hxx
@@ -0,0 +1,82 @@
+/*************************************************************************
+ *
+ * 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_OAUTHENTICATIONCONTINUATION_HXX_
+#define _DBACCESS_OAUTHENTICATIONCONTINUATION_HXX_
+
+#include "dbadllapi.hxx"
+
+#include <com/sun/star/ucb/XInteractionSupplyAuthentication.hpp>
+#include <com/sun/star/ucb/RememberAuthentication.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <tools/string.hxx>
+#include <comphelper/interaction.hxx>
+
+
+//........................................................................
+namespace dbaccess
+{
+//........................................................................
+
+class OOO_DLLPUBLIC_DBA OAuthenticationContinuation :
+ public comphelper::OInteraction< com::sun::star::ucb::XInteractionSupplyAuthentication >
+{
+ sal_Bool m_bRemberPassword : 1; // remember the password for this session ?
+
+ sal_Bool m_bCanSetUserName;
+ ::rtl::OUString m_sUser; // the user
+ ::rtl::OUString m_sPassword; // the user's password
+
+public:
+ OAuthenticationContinuation();
+
+ sal_Bool SAL_CALL canSetRealm( ) throw(com::sun::star::uno::RuntimeException);
+ void SAL_CALL setRealm( const ::rtl::OUString& Realm ) throw(com::sun::star::uno::RuntimeException);
+ sal_Bool SAL_CALL canSetUserName( ) throw(com::sun::star::uno::RuntimeException);
+ void SAL_CALL setUserName( const ::rtl::OUString& UserName ) throw(com::sun::star::uno::RuntimeException);
+ sal_Bool SAL_CALL canSetPassword( ) throw(com::sun::star::uno::RuntimeException);
+ void SAL_CALL setPassword( const ::rtl::OUString& Password ) throw(com::sun::star::uno::RuntimeException);
+ com::sun::star::uno::Sequence< com::sun::star::ucb::RememberAuthentication > SAL_CALL getRememberPasswordModes( com::sun::star::ucb::RememberAuthentication& Default ) throw(com::sun::star::uno::RuntimeException);
+ void SAL_CALL setRememberPassword( com::sun::star::ucb::RememberAuthentication Remember ) throw(com::sun::star::uno::RuntimeException);
+ sal_Bool SAL_CALL canSetAccount( ) throw(com::sun::star::uno::RuntimeException);
+ void SAL_CALL setAccount( const ::rtl::OUString& Account ) throw(com::sun::star::uno::RuntimeException);
+ com::sun::star::uno::Sequence< com::sun::star::ucb::RememberAuthentication > SAL_CALL getRememberAccountModes( com::sun::star::ucb::RememberAuthentication& Default ) throw(com::sun::star::uno::RuntimeException);
+ void SAL_CALL setRememberAccount( com::sun::star::ucb::RememberAuthentication Remember ) throw(com::sun::star::uno::RuntimeException);
+
+ void setCanChangeUserName( sal_Bool bVal ) { m_bCanSetUserName = bVal; }
+ ::rtl::OUString getUser() const { return m_sUser; }
+ ::rtl::OUString getPassword() const { return m_sPassword; }
+ sal_Bool getRememberPassword() const { return m_bRemberPassword; }
+};
+
+//........................................................................
+} // namespace dbaccess
+//........................................................................
+
+#endif // _DBACCESS_OAUTHENTICATIONCONTINUATION_HXX_
+
diff --git a/dbaccess/source/ui/browser/brwctrlr.cxx b/dbaccess/source/ui/browser/brwctrlr.cxx
index 41bb28651..23bd7bd99 100644
--- a/dbaccess/source/ui/browser/brwctrlr.cxx
+++ b/dbaccess/source/ui/browser/brwctrlr.cxx
@@ -2751,6 +2751,7 @@ void SbaXDataBrowserController::unloading(const EventObject& /*aEvent*/) throw(
void SbaXDataBrowserController::unloaded(const EventObject& /*aEvent*/) throw( RuntimeException )
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::unloaded" );
+ m_xParser.clear();
InvalidateAll();
// do this asynchron, there are other listeners reacting on this message ...
// (it's a little hack : the grid columns are listening to this event, too, and their bound field may
diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx
index bdd31895a..451840e9a 100644
--- a/dbaccess/source/ui/browser/unodatbr.cxx
+++ b/dbaccess/source/ui/browser/unodatbr.cxx
@@ -1106,9 +1106,7 @@ SvLBoxEntry* SbaTableQueryBrowser::getObjectEntry(const ::rtl::OUString& _rDataS
// expand if required so
if (_bExpandAncestors)
{
- m_sToBeLoaded = _rCommand;
m_pTreeView->getListBox().Expand(pCommandType);
- m_sToBeLoaded = ::rtl::OUString();
}
// look for the object
@@ -2054,7 +2052,7 @@ void SbaTableQueryBrowser::populateTree(const Reference<XNameAccess>& _xNameAcce
const ::rtl::OUString* pEnd = pIter + aNames.getLength();
for (; pIter != pEnd; ++pIter)
{
- if( (!m_sToBeLoaded.getLength() || m_sToBeLoaded == *pIter) && !m_pTreeView->getListBox().GetEntryPosByName(*pIter,_pParent))
+ if( !m_pTreeView->getListBox().GetEntryPosByName(*pIter,_pParent))
{
Reference<XNameAccess> xChild(_xNameAccess->getByName(*pIter),UNO_QUERY);
DBTreeListUserData* pEntryData = new DBTreeListUserData;
diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.cxx b/dbaccess/source/ui/dlg/DbAdminImpl.cxx
index 04640808b..816d3d5e9 100644
--- a/dbaccess/source/ui/dlg/DbAdminImpl.cxx
+++ b/dbaccess/source/ui/dlg/DbAdminImpl.cxx
@@ -47,6 +47,7 @@
#include "optionalboolitem.hxx"
#include "propertysetitem.hxx"
#include "stringlistitem.hxx"
+#include "OAuthenticationContinuation.hxx"
/** === begin UNO includes === **/
#include <com/sun/star/beans/PropertyAttribute.hpp>
@@ -54,23 +55,32 @@
#include <com/sun/star/sdb/SQLContext.hpp>
#include <com/sun/star/sdbc/XDriver.hpp>
#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/task/XInteractionRequest.hpp>
+#include <com/sun/star/ucb/XInteractionSupplyAuthentication2.hpp>
+#include <com/sun/star/ucb/AuthenticationRequest.hpp>
/** === end UNO includes === **/
+#include <comphelper/interaction.hxx>
#include <comphelper/property.hxx>
#include <comphelper/sequence.hxx>
+#include <comphelper/guarding.hxx>
#include <connectivity/DriversConfig.hxx>
#include <connectivity/dbexception.hxx>
#include <osl/file.hxx>
#include <svl/eitem.hxx>
#include <svl/intitem.hxx>
#include <svl/itempool.hxx>
-#include <svtools/logindlg.hxx>
#include <svl/poolitem.hxx>
#include <svl/stritem.hxx>
+#include <tools/urlobj.hxx>
+#include <tools/diagnose_ex.h>
#include <typelib/typedescription.hxx>
+#include <vcl/svapp.hxx>
#include <vcl/msgbox.hxx>
#include <vcl/stdtext.hxx>
#include <vcl/waitobj.hxx>
+#include <vos/mutex.hxx>
#include <algorithm>
#include <functional>
@@ -81,6 +91,8 @@ namespace dbaui
using namespace ::dbtools;
using namespace com::sun::star::uno;
using namespace com::sun::star;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::task;
using namespace com::sun::star::sdbc;
using namespace com::sun::star::sdb;
using namespace com::sun::star::lang;
@@ -256,35 +268,73 @@ sal_Bool ODbDataSourceAdministrationHelper::getCurrentSettings(Sequence< Propert
{
SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pName, SfxStringItem, DSID_NAME, sal_True);
- ::svt::LoginDialog aDlg(m_pParent,
- LF_NO_PATH | LF_NO_ACCOUNT | LF_NO_ERRORTEXT | LF_USERNAME_READONLY,
- String(), NULL);
-
- aDlg.SetName(pUser ? pUser->GetValue() : String());
- aDlg.ClearPassword(); // this will give the password field the focus
+ Reference< XModel > xModel( getDataSourceOrModel( m_xDatasource ), UNO_QUERY_THROW );
+ ::comphelper::NamedValueCollection aArgs( xModel->getArgs() );
+ Reference< XInteractionHandler > xHandler( aArgs.getOrDefault( "InteractionHandler", Reference< XInteractionHandler >() ) );
+ if ( !xHandler.is() )
+ {
+ // instantiate the default SDB interaction handler
+ xHandler = Reference< XInteractionHandler >( m_xORB->createInstance( SERVICE_TASK_INTERACTION_HANDLER ), UNO_QUERY );
+ if ( !xHandler.is() )
+ ShowServiceNotAvailableError(m_pParent->GetParent(), String(SERVICE_TASK_INTERACTION_HANDLER), sal_True);
+ }
+
String sName = pName ? pName->GetValue() : String();
String sLoginRequest(ModuleRes(STR_ENTER_CONNECTION_PASSWORD));
::rtl::OUString sTemp = sName;
sName = ::dbaui::getStrippedDatabaseName(NULL,sTemp);
if ( sName.Len() )
- sLoginRequest.SearchAndReplaceAscii("$name$", sName);
+ sLoginRequest.SearchAndReplaceAscii("$name$", sName);
else
{
sLoginRequest.SearchAndReplaceAscii("\"$name$\"", String());
sLoginRequest.SearchAndReplaceAscii("$name$", String()); // just to be sure that in other languages the string will be deleted
}
- aDlg.SetLoginRequestText(sLoginRequest);
-
- aDlg.SetSavePasswordText(ModuleRes(STR_REMEMBERPASSWORD_SESSION));
- aDlg.SetSavePassword(sal_True);
- sal_Int32 nResult = aDlg.Execute();
- if (nResult != RET_OK)
+ // the request
+ AuthenticationRequest aRequest;
+ aRequest.ServerName = sName;
+ aRequest.Diagnostic = sLoginRequest;
+ aRequest.HasRealm = aRequest.HasAccount = sal_False;
+ // aRequest.Realm
+ aRequest.HasUserName = pUser != 0;
+ aRequest.UserName = pUser ? rtl::OUString(pUser->GetValue()) : ::rtl::OUString();
+ aRequest.HasPassword = sal_True;
+ //aRequest.Password
+ aRequest.HasAccount = sal_False;
+ // aRequest.Account
+
+ comphelper::OInteractionRequest* pRequest = new comphelper::OInteractionRequest(makeAny(aRequest));
+ uno::Reference< XInteractionRequest > xRequest(pRequest);
+
+ // build an interaction request
+ // two continuations (Ok and Cancel)
+ ::rtl::Reference< comphelper::OInteractionAbort > pAbort = new comphelper::OInteractionAbort;
+ ::rtl::Reference< dbaccess::OAuthenticationContinuation > pAuthenticate = new dbaccess::OAuthenticationContinuation;
+ pAuthenticate->setCanChangeUserName( sal_False );
+ pAuthenticate->setRememberPassword( RememberAuthentication_SESSION );
+
+ // some knittings
+ pRequest->addContinuation(pAbort.get());
+ pRequest->addContinuation(pAuthenticate.get());
+
+ // handle the request
+ try
+ {
+ ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
+ // release the mutex when calling the handler, it may need to lock the SolarMutex
+ xHandler->handle(xRequest);
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ if (!pAuthenticate->wasSelected())
return sal_False;
-
- sPassword = aDlg.GetPassword();
- if (aDlg.IsSavePassword())
+
+ sPassword = pAuthenticate->getPassword();
+ if (pAuthenticate->getRememberPassword())
m_pItemSetHelper->getWriteOutputSet()->Put(SfxStringItem(DSID_PASSWORD, sPassword));
}
diff --git a/dbaccess/source/ui/inc/TableController.hxx b/dbaccess/source/ui/inc/TableController.hxx
index 19e6a07dd..6aeb1415e 100644
--- a/dbaccess/source/ui/inc/TableController.hxx
+++ b/dbaccess/source/ui/inc/TableController.hxx
@@ -135,7 +135,7 @@ namespace dbaui
inline ::std::vector< ::boost::shared_ptr<OTableRow> >* getRows() { return &m_vRowList; }
/// returns the postion of the the first empty row
- sal_Int32 getFirstEmptyRowPosition() const;
+ sal_Int32 getFirstEmptyRowPosition();
inline const OTypeInfoMap* getTypeInfo() const { return &m_aTypeInfo; }
diff --git a/dbaccess/source/ui/inc/unodatbr.hxx b/dbaccess/source/ui/inc/unodatbr.hxx
index 0fb37b65d..e87f1caf1 100644
--- a/dbaccess/source/ui/inc/unodatbr.hxx
+++ b/dbaccess/source/ui/inc/unodatbr.hxx
@@ -157,7 +157,7 @@ namespace dbaui
OTableCopyHelper m_aTableCopyHelper;
::rtl::OUString m_sQueryCommand; // the command of the query currently loaded (if any)
- ::rtl::OUString m_sToBeLoaded; // contains the element name which should be loaded if any
+ //::rtl::OUString m_sToBeLoaded; // contains the element name which should be loaded if any
DBTreeView* m_pTreeView;
Splitter* m_pSplitter;
diff --git a/dbaccess/source/ui/misc/TokenWriter.cxx b/dbaccess/source/ui/misc/TokenWriter.cxx
index b97321980..6de15f1ce 100644
--- a/dbaccess/source/ui/misc/TokenWriter.cxx
+++ b/dbaccess/source/ui/misc/TokenWriter.cxx
@@ -100,7 +100,7 @@ ODatabaseImportExport::ODatabaseImportExport(const ::svx::ODataAccessDescriptor&
const Reference< XMultiServiceFactory >& _rM,
const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
const String& rExchange)
- :m_bBookmarkSelection( NULL )
+ :m_bBookmarkSelection( sal_False )
,m_xFormatter(_rxNumberF)
,m_xFactory(_rM)
,m_nCommandType(CommandType::TABLE)
@@ -131,7 +131,7 @@ ODatabaseImportExport::ODatabaseImportExport(const ::svx::ODataAccessDescriptor&
// import data
ODatabaseImportExport::ODatabaseImportExport( const ::dbtools::SharedConnection& _rxConnection,
const Reference< XNumberFormatter >& _rxNumberF, const Reference< XMultiServiceFactory >& _rM )
- :m_bBookmarkSelection( NULL )
+ :m_bBookmarkSelection( sal_False )
,m_xConnection(_rxConnection)
,m_xFormatter(_rxNumberF)
,m_xFactory(_rM)
diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx
index 9169bf643..69fe58bd4 100644
--- a/dbaccess/source/ui/tabledesign/TEditControl.cxx
+++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx
@@ -134,9 +134,6 @@ DBG_NAME(OTableEditorCtrl)
#define HANDLE_ID 0
-// Anzahl Spalten beim Neuanlegen
-#define NEWCOLS 128
-
// default Spaltenbreiten
#define FIELDNAME_WIDTH 100
#define FIELDTYPE_WIDTH 150
diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx
index 05b72dc89..180019a8e 100644
--- a/dbaccess/source/ui/tabledesign/TableController.cxx
+++ b/dbaccess/source/ui/tabledesign/TableController.cxx
@@ -108,6 +108,9 @@ using namespace ::dbtools;
using namespace ::dbaui;
using namespace ::comphelper;
+// Anzahl Spalten beim Neuanlegen
+#define NEWCOLS 128
+
namespace
{
void dropTable(const Reference<XNameAccess>& _rxTable,const ::rtl::OUString& _sTableName)
@@ -958,7 +961,7 @@ void OTableController::loadData()
OSL_ENSURE(aTypeIter != m_aTypeInfo.end(),"We have no type infomation!");
bool bReadRow = !isAddAllowed();
- for(sal_Int32 i=m_vRowList.size(); i<128; i++ )
+ for(sal_Int32 i=m_vRowList.size(); i < NEWCOLS; i++ )
{
pTabEdRow.reset(new OTableRow());
pTabEdRow->SetReadOnly(bReadRow);
@@ -1579,7 +1582,7 @@ void OTableController::reload()
static_cast<OTableDesignView*>(getView())->Invalidate();
}
// -----------------------------------------------------------------------------
-sal_Int32 OTableController::getFirstEmptyRowPosition() const
+sal_Int32 OTableController::getFirstEmptyRowPosition()
{
sal_Int32 nRet = -1;
::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = m_vRowList.begin();
@@ -1592,6 +1595,14 @@ sal_Int32 OTableController::getFirstEmptyRowPosition() const
break;
}
}
+ if ( nRet == -1 )
+ {
+ bool bReadRow = !isAddAllowed();
+ ::boost::shared_ptr<OTableRow> pTabEdRow(new OTableRow());
+ pTabEdRow->SetReadOnly(bReadRow);
+ nRet = m_vRowList.size();
+ m_vRowList.push_back( pTabEdRow);
+ }
return nRet;
}
// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/uno/dbinteraction.cxx b/dbaccess/source/ui/uno/dbinteraction.cxx
index 135838d79..e735c0331 100644
--- a/dbaccess/source/ui/uno/dbinteraction.cxx
+++ b/dbaccess/source/ui/uno/dbinteraction.cxx
@@ -67,9 +67,6 @@
#ifndef _COM_SUN_STAR_SDB_XINTERACTIONDOCUMENTSAVE_HPP_
#include <com/sun/star/sdb/XInteractionDocumentSave.hpp>
#endif
-#ifndef _SVTOOLS_LOGINDLG_HXX_
-#include <svtools/logindlg.hxx>
-#endif
#ifndef SFX_QUERYSAVEDOCUMENT_HXX
#include <sfx2/QuerySaveDocument.hxx>
#endif