diff options
author | Kurt Zenker <kz@openoffice.org> | 2010-04-12 17:31:12 +0200 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2010-04-12 17:31:12 +0200 |
commit | 21ae32549e5640e23e289ee3269d3f8d312838b0 (patch) | |
tree | 7f8dbbfcfdfc4c4e35223e259ecfa4649c935e80 | |
parent | ba3d27f384332437ace5d314c85cf15ae399aaaa (diff) | |
parent | 06571ad7e8c2df5fdfe3d4401d3144db5faa09ec (diff) |
CWS-TOOLING: integrate CWS dba321aooo/OOO320_m15
-rw-r--r-- | dbaccess/qa/complex/dbaccess/RowSet.java | 2 | ||||
-rw-r--r-- | dbaccess/source/core/api/BookmarkSet.cxx | 4 | ||||
-rw-r--r-- | dbaccess/source/core/api/BookmarkSet.hxx | 2 | ||||
-rw-r--r-- | dbaccess/source/core/api/CacheSet.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/core/api/CacheSet.hxx | 2 | ||||
-rw-r--r-- | dbaccess/source/core/api/KeySet.cxx | 351 | ||||
-rw-r--r-- | dbaccess/source/core/api/KeySet.hxx | 17 | ||||
-rw-r--r-- | dbaccess/source/core/api/RowSet.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/core/api/RowSetCache.cxx | 11 | ||||
-rw-r--r-- | dbaccess/source/core/api/RowSetCache.hxx | 3 | ||||
-rw-r--r-- | dbaccess/source/core/api/SingleSelectQueryComposer.cxx | 28 | ||||
-rw-r--r-- | dbaccess/source/ui/control/tabletree.cxx | 56 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/WCopyTable.cxx | 3 |
13 files changed, 389 insertions, 94 deletions
diff --git a/dbaccess/qa/complex/dbaccess/RowSet.java b/dbaccess/qa/complex/dbaccess/RowSet.java index 20403b422..8a18a5e66 100644 --- a/dbaccess/qa/complex/dbaccess/RowSet.java +++ b/dbaccess/qa/complex/dbaccess/RowSet.java @@ -983,7 +983,7 @@ public class RowSet extends ComplexTestCase } catch (Exception e) { - assure("could not text the relationship between XParameters and XParametersSupplier" + e.getMessage(), false); + assure("could not test the relationship between XParameters and XParametersSupplier" + e.getMessage(), false); } } diff --git a/dbaccess/source/core/api/BookmarkSet.cxx b/dbaccess/source/core/api/BookmarkSet.cxx index 348d7cf01..5eaee7bbf 100644 --- a/dbaccess/source/core/api/BookmarkSet.cxx +++ b/dbaccess/source/core/api/BookmarkSet.cxx @@ -59,10 +59,10 @@ using namespace ::com::sun::star::lang; // using namespace ::cppu; using namespace ::osl; -void OBookmarkSet::construct(const Reference< XResultSet>& _xDriverSet) +void OBookmarkSet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OBookmarkSet::construct" ); - OCacheSet::construct(_xDriverSet); + OCacheSet::construct(_xDriverSet,i_sRowSetFilter); m_xRowLocate.set(_xDriverSet,UNO_QUERY); } // ----------------------------------------------------------------------------- diff --git a/dbaccess/source/core/api/BookmarkSet.hxx b/dbaccess/source/core/api/BookmarkSet.hxx index c7beff64d..36d3c90c7 100644 --- a/dbaccess/source/core/api/BookmarkSet.hxx +++ b/dbaccess/source/core/api/BookmarkSet.hxx @@ -51,7 +51,7 @@ namespace dbaccess m_xRowLocate = NULL; } - virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet); + virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter); virtual void fillValueRow(ORowSetRow& _rRow,sal_Int32 _nPosition); // ::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); diff --git a/dbaccess/source/core/api/CacheSet.cxx b/dbaccess/source/core/api/CacheSet.cxx index 38886b7f9..7d958faf5 100644 --- a/dbaccess/source/core/api/CacheSet.cxx +++ b/dbaccess/source/core/api/CacheSet.cxx @@ -126,7 +126,7 @@ OCacheSet::OCacheSet() return sQuote; } // ------------------------------------------------------------------------- -void OCacheSet::construct( const Reference< XResultSet>& _xDriverSet) +void OCacheSet::construct( const Reference< XResultSet>& _xDriverSet,const ::rtl::OUString& /*i_sRowSetFilter*/) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::construct" ); OSL_ENSURE(_xDriverSet.is(),"Invalid resultSet"); diff --git a/dbaccess/source/core/api/CacheSet.hxx b/dbaccess/source/core/api/CacheSet.hxx index f439594a2..8b19cc81b 100644 --- a/dbaccess/source/core/api/CacheSet.hxx +++ b/dbaccess/source/core/api/CacheSet.hxx @@ -107,7 +107,7 @@ namespace dbaccess public: // late constructor - virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet); + virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter); virtual void fillValueRow(ORowSetRow& _rRow,sal_Int32 _nPosition); // ::com::sun::star::sdbc::XRow diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx index 844627482..581af61c8 100644 --- a/dbaccess/source/core/api/KeySet.cxx +++ b/dbaccess/source/core/api/KeySet.cxx @@ -148,6 +148,134 @@ 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) // ------------------------------------------------------------------------- @@ -159,6 +287,7 @@ OKeySet::OKeySet(const connectivity::OSQLTable& _xTable, :m_aParameterValueForCache(_aParameterValueForCache) ,m_pKeyColumnNames(NULL) ,m_pColumnNames(NULL) + ,m_pParameterNames(NULL) ,m_pForeignColumnNames(NULL) ,m_xTable(_xTable) ,m_xTableKeys(_xTableKeys) @@ -188,28 +317,67 @@ OKeySet::~OKeySet() 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) +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); + 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_pForeignColumnNames = new SelectColumnsMetaData(bCase); + m_pKeyColumnNames = new SelectColumnsMetaData(bCase); + m_pColumnNames = new SelectColumnsMetaData(bCase); + m_pParameterNames = new SelectColumnsMetaData(bCase); + m_pForeignColumnNames = new SelectColumnsMetaData(bCase); Reference<XNameAccess> xKeyColumns = getKeyColumns(); Reference<XColumnsSupplier> xSup(m_xComposer,UNO_QUERY); Reference<XNameAccess> xSourceColumns = m_xTable->getColumns(); - ::dbaccess::getColumnPositions(xSup->getColumns(),xKeyColumns,m_sUpdateTableName,(*m_pKeyColumnNames)); - ::dbaccess::getColumnPositions(xSup->getColumns(),xSourceColumns,m_sUpdateTableName,(*m_pColumnNames)); + // 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]; + } + + ::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)); + } + + Sequence< ::rtl::OUString> aBestColumnNames; + if ( aBestRowColumnNames.empty() ) + { + if ( xKeyColumns.is() ) + aBestColumnNames = xKeyColumns->getElementNames(); + } + else + aBestColumnNames = Sequence< ::rtl::OUString>(&aBestRowColumnNames[0],aBestRowColumnNames.size()); + + ::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(); @@ -226,7 +394,7 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) // 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,0))); + m_aKeyMap.insert(OKeySetMatrix::value_type(0,OKeySetValue(NULL,::std::pair<sal_Int32,Reference<XRow> >(0,NULL)))); m_aKeyIter = m_aKeyMap.begin(); @@ -235,12 +403,6 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) ::rtl::OUString aQuote = getIdentifierQuoteString(); ::rtl::OUStringBuffer aFilter; - ::rtl::OUString sCatalog,sSchema,sTable; - - Reference<XPropertySet> xTableProp(m_xTable,UNO_QUERY); - xTableProp->getPropertyValue(PROPERTY_CATALOGNAME) >>= sCatalog; - xTableProp->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema; - xTableProp->getPropertyValue(PROPERTY_NAME) >>= sTable; m_aSelectComposedTableName = getComposedTableName(sCatalog,sSchema,sTable); @@ -264,9 +426,10 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) aFilter.append(aAnd); } + 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); - xAnalyzer->setQuery(m_xComposer->getQuery()); + xAnalyzer->setElementaryQuery(xSourceComposer->getElementaryQuery()); Reference<XTablesSupplier> xTabSup(xAnalyzer,uno::UNO_QUERY); Reference<XNameAccess> xSelectTables(xTabSup->getTables(),uno::UNO_QUERY); const Sequence< ::rtl::OUString> aSeq = xSelectTables->getElementNames(); @@ -304,15 +467,34 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) } } } // if ( aSeq.getLength() > 1 ) // special handling for join - const ::rtl::OUString sOldFilter = xAnalyzer->getFilter(); - if ( sOldFilter.getLength() ) + bool bFilterSet = i_sRowSetFilter.getLength() != 0; + if ( bFilterSet ) { FilterCreator aFilterCreator; - aFilterCreator.append( sOldFilter ); + aFilterCreator.append( i_sRowSetFilter ); aFilterCreator.append( aFilter.makeStringAndClear() ); aFilter = aFilterCreator.getComposedAndClear(); } xAnalyzer->setFilter(aFilter.makeStringAndClear()); + if ( bFilterSet ) + { + Sequence< Sequence< PropertyValue > > aFilter2 = 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); + } + } + } + } m_xStatement = m_xConnection->prepareStatement(xAnalyzer->getQueryWithSubstitution()); ::comphelper::disposeComponent(xAnalyzer); } @@ -571,12 +753,22 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow i = 1; // first the set values aIter = m_pColumnNames->begin(); + bool bRefetch = true; sal_uInt16 j = 0; + Reference<XRow> xRow; for(;aIter != aEnd;++aIter,++j) { sal_Int32 nPos = aIter->second.nPosition; if((_rInsertRow->get())[nPos].isModified()) { + if ( bRefetch ) + { + bRefetch = ::std::find(m_aFilterColumns.begin(),m_aFilterColumns.end(),aIter->first) == m_aFilterColumns.end(); + if ( !bRefetch ) + { + xRow = new OPrivateRow(_rInsertRow->get()); + } + } (_rInsertRow->get())[nPos].setSigned((_rOrginalRow->get())[nPos].isSigned()); setParameter(i++,xParameter,(_rInsertRow->get())[nPos],aIter->second.nType,aIter->second.nScale); } @@ -604,10 +796,11 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow if(m_bUpdated) { - m_aKeyIter = m_aKeyMap.find(::comphelper::getINT32((_rInsertRow->get())[0].getAny())); - OSL_ENSURE(m_aKeyIter != m_aKeyMap.end(),"New inserted row not found!"); - m_aKeyIter->second.second = 2; - copyRowValue(_rInsertRow,m_aKeyIter->second.first); + 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); } } // ------------------------------------------------------------------------- @@ -630,10 +823,15 @@ void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivi SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end(); sal_Int32 j = 1; sal_Bool bModified = sal_False; + bool bRefetch = true; for(;aIter != aEnd;++aIter,++j) { if((_rInsertRow->get())[aIter->second.nPosition].isModified()) { + if ( bRefetch ) + { + bRefetch = ::std::find(m_aFilterColumns.begin(),m_aFilterColumns.end(),aIter->first) == m_aFilterColumns.end(); + } aSql.append(::dbtools::quoteName( aQuote,aIter->first)); aSql.append(aComma); aValues.append(aPara); @@ -767,21 +965,52 @@ void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivi } if ( m_bInserted ) { - ORowSetRow aKeyRow = new connectivity::ORowVector< ORowSetValue >((*m_pKeyColumnNames).size()); - copyRowValue(_rInsertRow,aKeyRow); - OKeySetMatrix::iterator aKeyIter = m_aKeyMap.end(); --aKeyIter; - m_aKeyIter = m_aKeyMap.insert(OKeySetMatrix::value_type(aKeyIter->first + 1,OKeySetValue(aKeyRow,1))).first; + 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; + if ( !bRefetch ) + { + m_aKeyIter->second.second.second = new OPrivateRow(_rInsertRow->get()); + } + // now we set the bookmark for this row (_rInsertRow->get())[0] = makeAny((sal_Int32)m_aKeyIter->first); } } // ----------------------------------------------------------------------------- -void OKeySet::copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow) +void OKeySet::copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow,sal_Int32 i_nBookmark) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::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(),"OKeySet::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) @@ -1009,8 +1238,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) @@ -1019,8 +1248,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) @@ -1121,18 +1350,39 @@ sal_Bool SAL_CALL OKeySet::previous( ) throw(SQLException, RuntimeException) void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::refreshRow" ); - if(isBeforeFirst() || isAfterLast() || !m_xStatement.is()) + 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!"); xParameter->clearParameters(); + sal_Int32 nPos=1; - connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaIter = m_aParameterValueForCache.get().begin(); - connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaEnd = m_aParameterValueForCache.get().end(); + 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() ); @@ -1182,7 +1432,7 @@ sal_Bool OKeySet::fetchRow() 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,0))).first; + 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; @@ -1341,13 +1591,13 @@ Reference< XArray > SAL_CALL OKeySet::getArray( sal_Int32 columnIndex ) throw(SQ sal_Bool SAL_CALL OKeySet::rowUpdated( ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::rowUpdated" ); - return m_aKeyIter != m_aKeyMap.begin() && m_aKeyIter != m_aKeyMap.end() && m_aKeyIter->second.second == 2; + return m_aKeyIter != m_aKeyMap.begin() && m_aKeyIter != m_aKeyMap.end() && m_aKeyIter->second.second.first == 2; } // ------------------------------------------------------------------------- sal_Bool SAL_CALL OKeySet::rowInserted( ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::rowInserted" ); - return m_aKeyIter != m_aKeyMap.begin() && m_aKeyIter != m_aKeyMap.end() && m_aKeyIter->second.second == 1; + return m_aKeyIter != m_aKeyMap.begin() && m_aKeyIter != m_aKeyMap.end() && m_aKeyIter->second.second.first == 1; } // ------------------------------------------------------------------------- sal_Bool SAL_CALL OKeySet::rowDeleted( ) throw(SQLException, RuntimeException) @@ -1396,18 +1646,25 @@ namespace dbaccess void getColumnPositions(const Reference<XNameAccess>& _rxQueryColumns, const Reference<XNameAccess>& _rxColumns, const ::rtl::OUString& _rsUpdateTableName, - SelectColumnsMetaData& _rColumnNames) + SelectColumnsMetaData& _rColumnAssignments) + { + getColumnPositions( _rxQueryColumns, _rxColumns->getElementNames(), _rsUpdateTableName, _rColumnAssignments ); + } + + void getColumnPositions(const Reference<XNameAccess>& _rxQueryColumns, + const Sequence< ::rtl::OUString >& _rColumnNames, + const ::rtl::OUString& _rsUpdateTableName, + SelectColumnsMetaData& _rColumnAssignments) { // 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(); - Sequence< ::rtl::OUString> aColumnNames(_rxColumns->getElementNames()); - const ::rtl::OUString* pColumnIter = aColumnNames.getConstArray(); - const ::rtl::OUString* pColumnEnd = pColumnIter + aColumnNames.getLength(); + const ::rtl::OUString* pColumnIter = _rColumnNames.getConstArray(); + const ::rtl::OUString* pColumnEnd = pColumnIter + _rColumnNames.getLength(); - ::comphelper::UStringMixLess aTmp(_rColumnNames.key_comp()); + ::comphelper::UStringMixLess aTmp(_rColumnAssignments.key_comp()); ::comphelper::UStringMixEqual bCase(static_cast< ::comphelper::UStringMixLess*>(&aTmp)->isCaseSensitive()); for(sal_Int32 nPos = 1;pSelBegin != pSelEnd;++pSelBegin,++nPos) @@ -1421,7 +1678,7 @@ namespace dbaccess for(;pColumnIter != pColumnEnd;++pColumnIter) { - if(bCase(sRealName,*pColumnIter) && bCase(_rsUpdateTableName,sTableName) && _rColumnNames.find(*pColumnIter) == _rColumnNames.end()) + if(bCase(sRealName,*pColumnIter) && bCase(_rsUpdateTableName,sTableName) && _rColumnAssignments.find(*pColumnIter) == _rColumnAssignments.end()) { sal_Int32 nType = 0; xColumnProp->getPropertyValue(PROPERTY_TYPE) >>= nType; @@ -1435,11 +1692,11 @@ namespace dbaccess xColumnProp->getPropertyValue(PROPERTY_ISNULLABLE) >>= bNullable; - _rColumnNames[sRealName] = SelectColumnDescription( nPos, nType,nScale,bNullable != sdbc::ColumnValue::NO_NULLS, sColumnDefault ); + _rColumnAssignments[sRealName] = SelectColumnDescription( nPos, nType,nScale,bNullable != sdbc::ColumnValue::NO_NULLS, sColumnDefault ); break; } } - pColumnIter = aColumnNames.getConstArray(); + pColumnIter = _rColumnNames.getConstArray(); } } } diff --git a/dbaccess/source/core/api/KeySet.hxx b/dbaccess/source/core/api/KeySet.hxx index 2466a61c1..259c4be88 100644 --- a/dbaccess/source/core/api/KeySet.hxx +++ b/dbaccess/source/core/api/KeySet.hxx @@ -82,10 +82,15 @@ namespace dbaccess void getColumnPositions(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxQueryColumns, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxColumns, const ::rtl::OUString& _rsUpdateTableName, - SelectColumnsMetaData& _rColumnNames /* out */); + SelectColumnsMetaData& _rColumnAssignments /* out */); + void getColumnPositions(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxQueryColumns, + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rColumnNames, + const ::rtl::OUString& _rsUpdateTableName, + SelectColumnsMetaData& _rColumnAssignments /* out */); - typedef ::std::pair<ORowSetRow,sal_Int32> OKeySetValue; + typedef ::std::pair<ORowSetRow,::std::pair<sal_Int32,::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow> > > OKeySetValue; typedef ::std::map<sal_Int32,OKeySetValue > OKeySetMatrix; + typedef ::std::map<sal_Int32,ORowSetValueVector > OUpdatedParameter; // is used when the source supports keys class OKeySet : public OCacheSet { @@ -94,9 +99,11 @@ namespace dbaccess ::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 connectivity::OSQLTable m_xTable; // reference to our table ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess> m_xTableKeys; @@ -106,6 +113,7 @@ namespace dbaccess ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer > m_xComposer; ::rtl::OUString m_sUpdateTableName; ::rtl::OUString m_aSelectComposedTableName; + ::std::vector< ::rtl::OUString > m_aFilterColumns; sal_Bool m_bRowCountFinal; @@ -125,8 +133,9 @@ namespace dbaccess * * \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); + void copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow,sal_Int32 i_nBookmark); ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > getKeyColumns() const; void fillAllRows(); @@ -141,7 +150,7 @@ namespace dbaccess const ORowSetValueVector& _aParameterValueForCache); // late ctor which can throw exceptions - virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet); + 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); diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index c6dc8079a..91a1f4106 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -1862,7 +1862,7 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "frank.schoenheit@sun.com", "ORowSet::execute_NoApprove_NoNewConn: creating cache" ); - m_pCache = new ORowSetCache( xResultSet, m_xComposer.get(), m_aContext, aComposedUpdateTableName, m_bModified, m_bNew,m_aParameterValueForCache ); + m_pCache = new ORowSetCache( xResultSet, m_xComposer.get(), m_aContext, aComposedUpdateTableName, m_bModified, m_bNew,m_aParameterValueForCache,m_aFilter ); if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY ) { m_nPrivileges = Privilege::SELECT; diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx index f09227856..f2975eec8 100644 --- a/dbaccess/source/core/api/RowSetCache.cxx +++ b/dbaccess/source/core/api/RowSetCache.cxx @@ -135,7 +135,8 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, const ::rtl::OUString& _rUpdateTableName, sal_Bool& _bModified, sal_Bool& _bNew, - const ORowSetValueVector& _aParameterValueForCache) + const ORowSetValueVector& _aParameterValueForCache, + const ::rtl::OUString& i_sRowSetFilter) :m_xSet(_xRs) ,m_xMetaData(Reference< XResultSetMetaDataSupplier >(_xRs,UNO_QUERY)->getMetaData()) ,m_aContext( _rContext ) @@ -256,7 +257,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, { m_pCacheSet = new OBookmarkSet(); m_xCacheSet = m_pCacheSet; - m_pCacheSet->construct(_xRs); + m_pCacheSet->construct(_xRs,i_sRowSetFilter); // check privileges m_nPrivileges = Privilege::SELECT; @@ -290,7 +291,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, { m_pCacheSet = new OStaticSet(); m_xCacheSet = m_pCacheSet; - m_pCacheSet->construct(_xRs); + m_pCacheSet->construct(_xRs,i_sRowSetFilter); m_nPrivileges = Privilege::SELECT; } else @@ -331,7 +332,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, { m_pCacheSet = pKeySet; m_xCacheSet = m_pCacheSet; - pKeySet->construct(_xRs); + pKeySet->construct(_xRs,i_sRowSetFilter); if(Reference<XResultSetUpdate>(_xRs,UNO_QUERY).is()) // this interface is optional so we have to check it { @@ -355,7 +356,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, m_xCacheSet = NULL; m_pCacheSet = new OStaticSet(); m_xCacheSet = m_pCacheSet; - m_pCacheSet->construct(_xRs); + m_pCacheSet->construct(_xRs,i_sRowSetFilter); m_nPrivileges = Privilege::SELECT; } } diff --git a/dbaccess/source/core/api/RowSetCache.hxx b/dbaccess/source/core/api/RowSetCache.hxx index f483c77ed..6f3ed2d87 100644 --- a/dbaccess/source/core/api/RowSetCache.hxx +++ b/dbaccess/source/core/api/RowSetCache.hxx @@ -192,7 +192,8 @@ namespace dbaccess const ::rtl::OUString& _rUpdateTableName, sal_Bool& _bModified, sal_Bool& _bNew, - const ORowSetValueVector& _aParameterValueForCache); + const ORowSetValueVector& _aParameterValueForCache, + const ::rtl::OUString& i_sRowSetFilter); ~ORowSetCache(); diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index 3f5875c37..781551b43 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -46,6 +46,7 @@ #include <com/sun/star/sdbc/DataType.hpp> #include <com/sun/star/sdbc/XResultSetMetaData.hpp> #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +#include <com/sun/star/sdbc/XParameters.hpp> #include <com/sun/star/uno/XAggregation.hpp> #include <com/sun/star/util/XNumberFormatter.hpp> /** === end UNO includes === **/ @@ -720,13 +721,28 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getColumns( ) thr } catch( const Exception& ) { } - if ( !xResultSetMeta.is() ) + try { - xStatement.reset( Reference< XStatement >( m_xConnection->createStatement(), UNO_QUERY_THROW ) ); - Reference< XPropertySet > xStatementProps( xStatement, UNO_QUERY_THROW ); - try { xStatementProps->setPropertyValue( PROPERTY_ESCAPE_PROCESSING, makeAny( sal_False ) ); } - catch ( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } - xResMetaDataSup.set( xStatement->executeQuery( sSQL ), UNO_QUERY_THROW ); + if ( !xResultSetMeta.is() ) + { + xStatement.reset( Reference< XStatement >( m_xConnection->createStatement(), UNO_QUERY_THROW ) ); + Reference< XPropertySet > xStatementProps( xStatement, UNO_QUERY_THROW ); + try { xStatementProps->setPropertyValue( PROPERTY_ESCAPE_PROCESSING, makeAny( sal_False ) ); } + catch ( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } + xResMetaDataSup.set( xStatement->executeQuery( sSQL ), UNO_QUERY_THROW ); + xResultSetMeta.set( xResMetaDataSup->getMetaData(), UNO_QUERY_THROW ); + } + } + catch( const Exception& ) + { + //@see issue http://qa.openoffice.org/issues/show_bug.cgi?id=110111 + // access returns a different order of column names when executing select * from + // and asking the columns from the metadata. + Reference< XParameters > xParameters( xPreparedStatement, UNO_QUERY_THROW ); + Reference< XIndexAccess > xPara = getParameters(); + for(sal_Int32 i = 1;i <= xPara->getCount();++i) + xParameters->setNull(i,DataType::VARCHAR); + xResMetaDataSup.set(xPreparedStatement->executeQuery(), UNO_QUERY_THROW ); xResultSetMeta.set( xResMetaDataSup->getMetaData(), UNO_QUERY_THROW ); } diff --git a/dbaccess/source/ui/control/tabletree.cxx b/dbaccess/source/ui/control/tabletree.cxx index 53d1cac79..84cb8f7aa 100644 --- a/dbaccess/source/ui/control/tabletree.cxx +++ b/dbaccess/source/ui/control/tabletree.cxx @@ -638,37 +638,45 @@ String OTableTreeListBox::getQualifiedTableName( SvLBoxEntry* _pEntry ) const { OSL_PRECOND( !isFolderEntry( _pEntry ), "OTableTreeListBox::getQualifiedTableName: folder entries not allowed here!" ); - Reference< XDatabaseMetaData > xMeta; - if ( !impl_getAndAssertMetaData( xMeta ) ) - return String(); + try + { + Reference< XDatabaseMetaData > xMeta; + if ( !impl_getAndAssertMetaData( xMeta ) ) + return String(); - ::rtl::OUString sCatalog; - ::rtl::OUString sSchema; - ::rtl::OUString sTable; + ::rtl::OUString sCatalog; + ::rtl::OUString sSchema; + ::rtl::OUString sTable; - SvLBoxEntry* pSchema = GetParent( _pEntry ); - if ( pSchema ) - { - SvLBoxEntry* pCatalog = GetParent( pSchema ); - if ( pCatalog - || ( xMeta->supportsCatalogsInDataManipulation() - && !xMeta->supportsSchemasInDataManipulation() - ) // here we support catalog but no schema - ) + SvLBoxEntry* pSchema = GetParent( _pEntry ); + if ( pSchema ) { - if ( pCatalog == NULL ) + SvLBoxEntry* pCatalog = GetParent( pSchema ); + if ( pCatalog + || ( xMeta->supportsCatalogsInDataManipulation() + && !xMeta->supportsSchemasInDataManipulation() + ) // here we support catalog but no schema + ) { - pCatalog = pSchema; - pSchema = NULL; + if ( pCatalog == NULL ) + { + pCatalog = pSchema; + pSchema = NULL; + } + sCatalog = GetEntryText( pCatalog ); } - sCatalog = GetEntryText( pCatalog ); + if ( pSchema ) + sSchema = GetEntryText(pSchema); } - if ( pSchema ) - sSchema = GetEntryText(pSchema); - } - sTable = GetEntryText( _pEntry ); + sTable = GetEntryText( _pEntry ); - return ::dbtools::composeTableName( xMeta, sCatalog, sSchema, sTable, sal_False, ::dbtools::eInDataManipulation ); + return ::dbtools::composeTableName( xMeta, sCatalog, sSchema, sTable, sal_False, ::dbtools::eInDataManipulation ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return String(); } //------------------------------------------------------------------------ diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx index 7b7ff4922..d77b3fbf4 100644 --- a/dbaccess/source/ui/misc/WCopyTable.cxx +++ b/dbaccess/source/ui/misc/WCopyTable.cxx @@ -1069,6 +1069,7 @@ void OCopyTableWizard::insertColumn(sal_Int32 _nPos,OFieldDescription* _pField) m_aDestVec.insert(m_aDestVec.begin() + _nPos, m_vDestColumns.insert(ODatabaseExport::TColumns::value_type(_pField->GetName(),_pField)).first); + m_mNameMapping[_pField->GetName()] = _pField->GetName(); } } // ----------------------------------------------------------------------------- @@ -1159,6 +1160,8 @@ void OCopyTableWizard::clearDestColumns() { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::clearDestColumns" ); clearColumns(m_vDestColumns,m_aDestVec); + m_bAddPKFirstTime = sal_True; + m_mNameMapping.clear(); } // ----------------------------------------------------------------------------- |