diff options
Diffstat (limited to 'dbaccess/source')
102 files changed, 3083 insertions, 3662 deletions
diff --git a/dbaccess/source/core/api/BookmarkSet.cxx b/dbaccess/source/core/api/BookmarkSet.cxx index f04638724957..63d287df08bd 100644 --- a/dbaccess/source/core/api/BookmarkSet.cxx +++ b/dbaccess/source/core/api/BookmarkSet.cxx @@ -129,7 +129,8 @@ void SAL_CALL OBookmarkSet::insertRow( const ORowSetRow& _rInsertRow,const conne { xUpd->moveToInsertRow(); sal_Int32 i = 1; - for(connectivity::ORowVector< ORowSetValue > ::Vector::iterator aIter = _rInsertRow->get().begin()+1;aIter != _rInsertRow->get().end();++aIter,++i) + connectivity::ORowVector< ORowSetValue > ::Vector::iterator aEnd = _rInsertRow->get().end(); + for(connectivity::ORowVector< ORowSetValue > ::Vector::iterator aIter = _rInsertRow->get().begin()+1;aIter != aEnd;++aIter,++i) { aIter->setSigned(m_aSignedFlags[i-1]); updateColumn(i,xUpdRow,*aIter); @@ -151,7 +152,8 @@ void SAL_CALL OBookmarkSet::updateRow(const ORowSetRow& _rInsertRow ,const ORowS sal_Int32 i = 1; connectivity::ORowVector< ORowSetValue > ::Vector::const_iterator aOrgIter = _rOrginalRow->get().begin()+1; - for(connectivity::ORowVector< ORowSetValue > ::Vector::iterator aIter = _rInsertRow->get().begin()+1;aIter != _rInsertRow->get().end();++aIter,++i,++aOrgIter) + connectivity::ORowVector< ORowSetValue > ::Vector::iterator aEnd = _rInsertRow->get().end(); + for(connectivity::ORowVector< ORowSetValue > ::Vector::iterator aIter = _rInsertRow->get().begin()+1;aIter != aEnd;++aIter,++i,++aOrgIter) { aIter->setSigned(aOrgIter->isSigned()); updateColumn(i,xUpdRow,*aIter); diff --git a/dbaccess/source/core/api/CacheSet.cxx b/dbaccess/source/core/api/CacheSet.cxx index ce21ca9402df..bbb080a52238 100644 --- a/dbaccess/source/core/api/CacheSet.cxx +++ b/dbaccess/source/core/api/CacheSet.cxx @@ -88,6 +88,7 @@ #ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> #endif +#include <rtl/ustrbuf.hxx> #include <rtl/logfile.hxx> using namespace comphelper; @@ -205,36 +206,37 @@ void OCacheSet::fillTableName(const Reference<XPropertySet>& _xTable) throw(SQL void SAL_CALL OCacheSet::insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::insertRow" ); - ::rtl::OUString aSql(::rtl::OUString::createFromAscii("INSERT INTO ")); + ::rtl::OUStringBuffer aSql(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INSERT INTO "))); Reference<XPropertySet> xSet(_xTable,UNO_QUERY); fillTableName(xSet); - aSql += m_aComposedTableName; - aSql += ::rtl::OUString::createFromAscii(" ( "); + aSql.append(m_aComposedTableName); + aSql.append(::rtl::OUString::createFromAscii(" ( ")); // set values and column names - ::rtl::OUString aValues = ::rtl::OUString::createFromAscii(" VALUES ( "); - static ::rtl::OUString aPara = ::rtl::OUString::createFromAscii("?,"); + ::rtl::OUStringBuffer aValues = ::rtl::OUString::createFromAscii(" VALUES ( "); + static ::rtl::OUString aPara(RTL_CONSTASCII_USTRINGPARAM("?,")); ::rtl::OUString aQuote = getIdentifierQuoteString(); - static ::rtl::OUString aComma = ::rtl::OUString::createFromAscii(","); + static ::rtl::OUString aComma(RTL_CONSTASCII_USTRINGPARAM(",")); sal_Int32 i = 1; ORowVector< ORowSetValue >::Vector::const_iterator aIter = _rInsertRow->get().begin()+1; - for(; aIter != _rInsertRow->get().end();++aIter) + connectivity::ORowVector< ORowSetValue > ::Vector::iterator aEnd = _rInsertRow->get().end(); + for(; aIter != aEnd;++aIter) { - aSql += ::dbtools::quoteName( aQuote,m_xSetMetaData->getColumnName(i++)); - aSql += aComma; - aValues += aPara; + aSql.append(::dbtools::quoteName( aQuote,m_xSetMetaData->getColumnName(i++))); + aSql.append(aComma); + aValues.append(aPara); } - aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); - aValues = aValues.replaceAt(aValues.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + aSql.setCharAt(aSql.getLength()-1,')'); + aValues.setCharAt(aValues.getLength()-1,')'); - aSql += aValues; + aSql.append(aValues.makeStringAndClear()); // now create end execute the prepared statement { - Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql)); + Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear())); Reference< XParameters > xParameter(xPrep,UNO_QUERY); i = 1; - for(aIter = _rInsertRow->get().begin()+1; aIter != _rInsertRow->get().end();++aIter,++i) + for(aIter = _rInsertRow->get().begin()+1; aIter != aEnd;++aIter,++i) { if(aIter->isNull()) xParameter->setNull(i,aIter->getTypeKind()); @@ -265,8 +267,8 @@ void SAL_CALL OCacheSet::insertRow( const ORowSetRow& _rInsertRow,const connecti // ------------------------------------------------------------------------- void OCacheSet::fillParameters( const ORowSetRow& _rRow ,const connectivity::OSQLTable& _xTable - ,::rtl::OUString& _sCondition - ,::rtl::OUString& _sParameter + ,::rtl::OUStringBuffer& _sCondition + ,::rtl::OUStringBuffer& _sParameter ,::std::list< sal_Int32>& _rOrgValues) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::fillParameters" ); @@ -330,6 +332,9 @@ void OCacheSet::fillParameters( const ORowSetRow& _rRow sal_Int32 nCheckCount = 1; // index for the orginal values sal_Int32 i = 1; + + ::rtl::OUString sIsNull(RTL_CONSTASCII_USTRINGPARAM(" IS NULL")); + ::rtl::OUString sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?")); ORowVector< ORowSetValue >::Vector::const_iterator aIter = _rRow->get().begin()+1; ORowVector< ORowSetValue >::Vector::const_iterator aEnd = _rRow->get().end()+1; for(; aIter != aEnd;++aIter,++nCheckCount,++i) @@ -337,34 +342,35 @@ void OCacheSet::fillParameters( const ORowSetRow& _rRow aColumnName = m_xSetMetaData->getColumnName(i); if(xKeyColumns.is() && xKeyColumns->hasByName(aColumnName)) { - _sCondition += ::dbtools::quoteName( aQuote,aColumnName); + _sCondition.append(::dbtools::quoteName( aQuote,aColumnName)); if(aIter->isNull()) - _sCondition += ::rtl::OUString::createFromAscii(" IS NULL"); + _sCondition.append(sIsNull); else - _sCondition += ::rtl::OUString::createFromAscii(" = ?"); - _sCondition += aAnd; + _sCondition.append(sParam); + _sCondition.append(aAnd); _rOrgValues.push_back(nCheckCount); - } + } // if(xKeyColumns.is() && xKeyColumns->hasByName(aColumnName)) + ::std::vector< Reference<XNameAccess> >::const_iterator aIndexEnd = aAllIndexColumns.end(); for( ::std::vector< Reference<XNameAccess> >::const_iterator aIndexIter = aAllIndexColumns.begin(); - aIndexIter != aAllIndexColumns.end();++aIndexIter) + aIndexIter != aIndexEnd;++aIndexIter) { if((*aIndexIter)->hasByName(aColumnName)) { - _sCondition += ::dbtools::quoteName( aQuote,aColumnName); + _sCondition.append(::dbtools::quoteName( aQuote,aColumnName)); if(aIter->isNull()) - _sCondition += ::rtl::OUString::createFromAscii(" IS NULL"); + _sCondition.append(sIsNull); else - _sCondition += ::rtl::OUString::createFromAscii(" = ?"); - _sCondition += aAnd; + _sCondition.append(sParam); + _sCondition.append(aAnd); _rOrgValues.push_back(nCheckCount); break; } } if(aIter->isModified()) { - _sParameter += ::dbtools::quoteName( aQuote,aColumnName); - _sParameter += aPara; + _sParameter.append(::dbtools::quoteName( aQuote,aColumnName)); + _sParameter.append(aPara); } } } @@ -375,39 +381,41 @@ void SAL_CALL OCacheSet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetR Reference<XPropertySet> xSet(_xTable,UNO_QUERY); fillTableName(xSet); - ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("UPDATE "); - aSql += m_aComposedTableName; - aSql += ::rtl::OUString::createFromAscii(" SET "); + ::rtl::OUStringBuffer aSql = ::rtl::OUString::createFromAscii("UPDATE "); + aSql.append(m_aComposedTableName); + aSql.append(::rtl::OUString::createFromAscii(" SET ")); // list all cloumns that should be set - ::rtl::OUString aCondition; + ::rtl::OUStringBuffer aCondition; ::std::list< sal_Int32> aOrgValues; fillParameters(_rInsertRow,_xTable,aCondition,aSql,aOrgValues); - aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(" ")); + aSql.setCharAt(aSql.getLength()-1,' '); if ( aCondition.getLength() ) { - aCondition = aCondition.replaceAt(aCondition.getLength()-5,5,::rtl::OUString::createFromAscii(" ")); + aCondition.setLength(aCondition.getLength()-5); - aSql += ::rtl::OUString::createFromAscii(" WHERE "); - aSql += aCondition; + aSql.append(::rtl::OUString::createFromAscii(" WHERE ")); + aSql.append(aCondition.makeStringAndClear()); } else ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_UPDATE_MISSING_CONDITION ), SQL_GENERAL_ERROR, *this ); // now create end execute the prepared statement - Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql)); + Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear())); Reference< XParameters > xParameter(xPrep,UNO_QUERY); sal_Int32 i = 1; - for(ORowVector< ORowSetValue >::Vector::const_iterator aIter = _rInsertRow->get().begin()+1; aIter != _rInsertRow->get().end();++aIter) + connectivity::ORowVector< ORowSetValue > ::Vector::iterator aEnd = _rInsertRow->get().end(); + for(ORowVector< ORowSetValue >::Vector::const_iterator aIter = _rInsertRow->get().begin()+1; aIter != aEnd;++aIter) { if(aIter->isModified()) { setParameter(i,xParameter,*aIter,m_xSetMetaData->getColumnType(i),m_xSetMetaData->getScale(i)); ++i; } - } - for(::std::list< sal_Int32>::const_iterator aOrgValue = aOrgValues.begin(); aOrgValue != aOrgValues.end();++aOrgValue,++i) + } // for(ORowVector< ORowSetValue >::Vector::const_iterator aIter = _rInsertRow->get().begin()+1; aIter != aEnd;++aIter) + ::std::list< sal_Int32>::const_iterator aOrgValueEnd = aOrgValues.end(); + for(::std::list< sal_Int32>::const_iterator aOrgValue = aOrgValues.begin(); aOrgValue != aOrgValueEnd;++aOrgValue,++i) { setParameter(i,xParameter,(_rOrginalRow->get())[*aOrgValue],m_xSetMetaData->getColumnType(i),m_xSetMetaData->getScale(i)); } @@ -421,9 +429,9 @@ void SAL_CALL OCacheSet::deleteRow(const ORowSetRow& _rDeleteRow ,const connecti Reference<XPropertySet> xSet(_xTable,UNO_QUERY); fillTableName(xSet); - ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DELETE FROM "); - aSql += m_aComposedTableName; - aSql += ::rtl::OUString::createFromAscii(" WHERE "); + ::rtl::OUStringBuffer aSql = ::rtl::OUString::createFromAscii("DELETE FROM "); + aSql.append(m_aComposedTableName); + aSql.append(::rtl::OUString::createFromAscii(" WHERE ")); // list all cloumns that should be set ::rtl::OUString aQuote = getIdentifierQuoteString(); @@ -480,17 +488,18 @@ void SAL_CALL OCacheSet::deleteRow(const ORowSetRow& _rDeleteRow ,const connecti } } - ::rtl::OUString aColumnName; + ::rtl::OUStringBuffer aColumnName; ::std::list< sal_Int32> aOrgValues; fillParameters(_rDeleteRow,_xTable,aSql,aColumnName,aOrgValues); - aSql = aSql.replaceAt(aSql.getLength()-5,5,::rtl::OUString::createFromAscii(" ")); + aSql.setLength(aSql.getLength()-5); // now create end execute the prepared statement - Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql)); + Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear())); Reference< XParameters > xParameter(xPrep,UNO_QUERY); sal_Int32 i = 1; - for(::std::list< sal_Int32>::const_iterator j = aOrgValues.begin(); j != aOrgValues.end();++j,++i) + ::std::list< sal_Int32>::const_iterator aOrgValueEnd = aOrgValues.end(); + for(::std::list< sal_Int32>::const_iterator j = aOrgValues.begin(); j != aOrgValueEnd;++j,++i) { setParameter(i,xParameter,(_rDeleteRow->get())[*j],m_xSetMetaData->getColumnType(i),m_xSetMetaData->getScale(i)); } diff --git a/dbaccess/source/core/api/CacheSet.hxx b/dbaccess/source/core/api/CacheSet.hxx index 6299c0fe2dad..057c843fe871 100644 --- a/dbaccess/source/core/api/CacheSet.hxx +++ b/dbaccess/source/core/api/CacheSet.hxx @@ -65,7 +65,10 @@ #endif #include <list> - +namespace rtl +{ + class OUStringBuffer; +} namespace com{ namespace sun { namespace star{namespace sdbc{ class XParameters; } } } } namespace dbaccess @@ -98,8 +101,8 @@ namespace dbaccess ); void fillParameters( const ORowSetRow& _rRow ,const connectivity::OSQLTable& _xTable - ,::rtl::OUString& _sCondition - ,::rtl::OUString& _sParameter + ,::rtl::OUStringBuffer& _sCondition + ,::rtl::OUStringBuffer& _sParameter ,::std::list< sal_Int32>& _rOrgValues); void fillTableName(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xTable) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx index 105443902b45..fa2bde353d29 100644 --- a/dbaccess/source/core/api/KeySet.cxx +++ b/dbaccess/source/core/api/KeySet.cxx @@ -213,7 +213,8 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) ::dbaccess::getColumnPositions(xSup->getColumns(),xSourceColumns,m_sUpdateTableName,(*m_pColumnNames)); SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin(); - for(;aPosIter != (*m_pKeyColumnNames).end();++aPosIter) + SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end(); + for(;aPosIter != aPosEnd;++aPosIter) { if(xSourceColumns->hasByName(aPosIter->first)) { @@ -234,7 +235,7 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) Reference<XDatabaseMetaData> xMetaData = m_xConnection->getMetaData(); ::rtl::OUString aQuote = getIdentifierQuoteString(); - ::rtl::OUString aFilter; + ::rtl::OUStringBuffer aFilter; ::rtl::OUString sCatalog,sSchema,sTable; Reference<XPropertySet> xTableProp(m_xTable,UNO_QUERY); @@ -252,16 +253,16 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) static ::rtl::OUString s_sDot(RTL_CONSTASCII_USTRINGPARAM(".")); static ::rtl::OUString s_sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?")); // create the where clause - SelectColumnsMetaData::const_iterator aIter; - for(aIter = (*m_pKeyColumnNames).begin();aIter != (*m_pKeyColumnNames).end();) + aPosEnd = (*m_pKeyColumnNames).end(); + for(aPosIter = (*m_pKeyColumnNames).begin();aPosIter != aPosEnd;) { - aFilter += sComposedName; - aFilter += s_sDot; - aFilter += ::dbtools::quoteName( aQuote,aIter->first); - aFilter += s_sParam; - ++aIter; - if(aIter != (*m_pKeyColumnNames).end()) - aFilter += aAnd; + aFilter.append(sComposedName); + aFilter.append(s_sDot); + aFilter.append(::dbtools::quoteName( aQuote,aPosIter->first)); + aFilter.append(s_sParam); + ++aPosIter; + if(aPosIter != aPosEnd) + aFilter.append(aAnd); } Reference< XMultiServiceFactory > xFactory(m_xConnection, UNO_QUERY_THROW); @@ -293,18 +294,18 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) // look for columns not in the source columns to use them as filter as well if ( !xSourceColumns->hasByName(*pSelectColumnName) ) { - aFilter += s_sDot; - aFilter += ::dbtools::quoteName( aQuote,*pSelectColumnName); - aFilter += s_sParam; + aFilter.append(s_sDot); + aFilter.append(::dbtools::quoteName( aQuote,*pSelectColumnName)); + aFilter.append(s_sParam); if ( (pSelectColumnName+1) != pSelectColumnEnd ) - aFilter += aAnd; + aFilter.append(aAnd); } } break; } } } - xAnalyzer->setFilter(aFilter); + xAnalyzer->setFilter(aFilter.makeStringAndClear()); m_xStatement = m_xConnection->prepareStatement(xAnalyzer->getQueryWithSubstitution()); ::comphelper::disposeComponent(xAnalyzer); } @@ -368,12 +369,12 @@ Sequence< sal_Int32 > SAL_CALL OKeySet::deleteRows( const Sequence< Any >& rows Reference<XPropertySet> xSet(_xTable,UNO_QUERY); fillTableName(xSet); - ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DELETE FROM "); - aSql += m_aComposedTableName; - aSql += ::rtl::OUString::createFromAscii(" WHERE "); + ::rtl::OUStringBuffer aSql = ::rtl::OUString::createFromAscii("DELETE FROM "); + aSql.append(m_aComposedTableName); + aSql.append(::rtl::OUString::createFromAscii(" WHERE ")); // list all cloumns that should be set - ::rtl::OUString aQuote = getIdentifierQuoteString(); + const ::rtl::OUString aQuote = getIdentifierQuoteString(); static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND "); static ::rtl::OUString aOr = ::rtl::OUString::createFromAscii(" OR "); static ::rtl::OUString aEqual = ::rtl::OUString::createFromAscii(" = ?"); @@ -383,16 +384,18 @@ Sequence< sal_Int32 > SAL_CALL OKeySet::deleteRows( const Sequence< Any >& rows // first the keys Reference<XNameAccess> xKeyColumns = getKeyColumns(); - ::rtl::OUString aCondition = ::rtl::OUString::createFromAscii("( "); + ::rtl::OUStringBuffer aCondition = ::rtl::OUString::createFromAscii("( "); SelectColumnsMetaData::const_iterator aIter = (*m_pKeyColumnNames).begin(); - for(;aIter != (*m_pKeyColumnNames).end();++aIter) + SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end(); + for(;aIter != aPosEnd;++aIter) { - aCondition += ::dbtools::quoteName( aQuote,aIter->first); - aCondition += aEqual; - aCondition += aAnd; + aCondition.append(::dbtools::quoteName( aQuote,aIter->first)); + aCondition.append(aEqual); + aCondition.append(aAnd); } - aCondition = aCondition.replaceAt(aCondition.getLength()-5,5,::rtl::OUString::createFromAscii(" )")); + aCondition.setLength(aCondition.getLength()-5); + const ::rtl::OUString sCon( aCondition.makeStringAndClear() ); const Any* pBegin = rows.getConstArray(); const Any* pEnd = pBegin + rows.getLength(); @@ -400,14 +403,14 @@ Sequence< sal_Int32 > SAL_CALL OKeySet::deleteRows( const Sequence< Any >& rows Sequence< Any > aKeys; for(;pBegin != pEnd;++pBegin) { - aSql += aCondition; - aSql += aOr; + aSql.append(sCon); + aSql.append(aOr); } - aSql = aSql.replaceAt(aSql.getLength()-3,3,::rtl::OUString::createFromAscii(" ")); + aSql.setLength(aSql.getLength()-3); // now create end execute the prepared statement - Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql)); + Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear())); Reference< XParameters > xParameter(xPrep,UNO_QUERY); pBegin = rows.getConstArray(); @@ -418,8 +421,9 @@ Sequence< sal_Int32 > SAL_CALL OKeySet::deleteRows( const Sequence< Any >& rows if(m_aKeyIter != m_aKeyMap.end()) { connectivity::ORowVector< ORowSetValue >::Vector::iterator aKeyIter = m_aKeyIter->second.first->get().begin(); + connectivity::ORowVector< ORowSetValue >::Vector::iterator aKeyEnd = m_aKeyIter->second.first->get().end(); SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin(); - for(sal_uInt16 j = 0;aKeyIter != m_aKeyIter->second.first->get().end();++aKeyIter,++j,++aPosIter) + for(sal_uInt16 j = 0;aKeyIter != aKeyEnd;++aKeyIter,++j,++aPosIter) { setParameter(i++,xParameter,*aKeyIter,aPosIter->second.nType,aPosIter->second.nScale); } @@ -453,13 +457,15 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow Reference<XPropertySet> xSet(_xTable,UNO_QUERY); fillTableName(xSet); - ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("UPDATE "); - aSql += m_aComposedTableName; - aSql += ::rtl::OUString::createFromAscii(" SET "); + ::rtl::OUStringBuffer aSql = ::rtl::OUString::createFromAscii("UPDATE "); + aSql.append(m_aComposedTableName); + aSql.append(::rtl::OUString::createFromAscii(" SET ")); // list all cloumns that should be set static ::rtl::OUString aPara = ::rtl::OUString::createFromAscii(" = ?,"); ::rtl::OUString aQuote = getIdentifierQuoteString(); static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND "); + ::rtl::OUString sIsNull(RTL_CONSTASCII_USTRINGPARAM(" IS NULL")); + ::rtl::OUString sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?")); // use keys and indexes for excat postioning // first the keys @@ -476,91 +482,90 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow lcl_fillIndexColumns(xIndexes,aAllIndexColumns); ::rtl::OUString aColumnName; - ::rtl::OUString aCondition,sKeyCondition,sIndexCondition,sSetValues; + ::rtl::OUStringBuffer sKeyCondition,sIndexCondition; ::std::vector<sal_Int32> aIndexColumnPositions; + const sal_Int32 nOldLength = aSql.getLength(); sal_Int32 i = 1; // here we build the condition part for the update statement SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin(); - for(;aIter != m_pColumnNames->end();++aIter,++i) + SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end(); + for(;aIter != aEnd;++aIter,++i) { if(xKeyColumns.is() && xKeyColumns->hasByName(aIter->first)) { - sKeyCondition += ::dbtools::quoteName( aQuote,aIter->first); + sKeyCondition.append(::dbtools::quoteName( aQuote,aIter->first)); if((_rOrginalRow->get())[aIter->second.nPosition].isNull()) - sKeyCondition += ::rtl::OUString::createFromAscii(" IS NULL"); + sKeyCondition.append(sIsNull); else - sKeyCondition += ::rtl::OUString::createFromAscii(" = ?"); - sKeyCondition += aAnd; + sKeyCondition.append(sParam); + sKeyCondition.append(aAnd); } else { + ::std::vector< Reference<XNameAccess> >::const_iterator aIndexEnd = aAllIndexColumns.end(); for( ::std::vector< Reference<XNameAccess> >::const_iterator aIndexIter = aAllIndexColumns.begin(); - aIndexIter != aAllIndexColumns.end();++aIndexIter) + aIndexIter != aIndexEnd;++aIndexIter) { if((*aIndexIter)->hasByName(aIter->first)) { - sIndexCondition += ::dbtools::quoteName( aQuote,aIter->first); + sIndexCondition.append(::dbtools::quoteName( aQuote,aIter->first)); if((_rOrginalRow->get())[aIter->second.nPosition].isNull()) - sIndexCondition += ::rtl::OUString::createFromAscii(" IS NULL"); + sIndexCondition.append(sIsNull); else { - sIndexCondition += ::rtl::OUString::createFromAscii(" = ?"); + sIndexCondition.append(sParam); aIndexColumnPositions.push_back(aIter->second.nPosition); } - sIndexCondition += aAnd; + sIndexCondition.append(aAnd); break; } } } if((_rInsertRow->get())[aIter->second.nPosition].isModified()) { - sSetValues += ::dbtools::quoteName( aQuote,aIter->first); - sSetValues += aPara; + aSql.append(::dbtools::quoteName( aQuote,aIter->first)); + aSql.append(aPara); } } - if(sSetValues.getLength()) + if( aSql.getLength() != nOldLength ) { - sSetValues = sSetValues.replaceAt(sSetValues.getLength()-1,1,::rtl::OUString::createFromAscii(" ")); - aSql += sSetValues; + aSql.setLength(aSql.getLength()-1); } else ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_VALUE_CHANGED ), SQL_GENERAL_ERROR, m_xConnection ); if(sKeyCondition.getLength() || sIndexCondition.getLength()) { + aSql.append(::rtl::OUString::createFromAscii(" WHERE ")); if(sKeyCondition.getLength() && sIndexCondition.getLength()) { - aCondition = sKeyCondition; - aCondition += sIndexCondition; + aSql.append(sKeyCondition.makeStringAndClear()); + aSql.append(sIndexCondition.makeStringAndClear()); } else if(sKeyCondition.getLength()) { - aCondition = sKeyCondition; + aSql.append(sKeyCondition.makeStringAndClear()); } else if(sIndexCondition.getLength()) { - aCondition = sIndexCondition; + aSql.append(sIndexCondition.makeStringAndClear()); } - - aCondition = aCondition.replaceAt(aCondition.getLength()-5,5,::rtl::OUString::createFromAscii(" ")); - - aSql += ::rtl::OUString::createFromAscii(" WHERE "); - aSql += aCondition; + aSql.setLength(aSql.getLength()-5); // remove the last AND } else ::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)); + Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear())); Reference< XParameters > xParameter(xPrep,UNO_QUERY); i = 1; // first the set values aIter = m_pColumnNames->begin(); sal_uInt16 j = 0; - for(;aIter != m_pColumnNames->end();++aIter,++j) + for(;aIter != aEnd;++aIter,++j) { sal_Int32 nPos = aIter->second.nPosition; if((_rInsertRow->get())[nPos].isModified()) @@ -571,16 +576,18 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow } // and then the values of the where condition aIter = (*m_pKeyColumnNames).begin(); + aEnd = (*m_pKeyColumnNames).end(); j = 0; - for(;aIter != (*m_pKeyColumnNames).end();++aIter,++i,++j) + for(;aIter != aEnd;++aIter,++i,++j) { 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; - for(;aIdxColIter != aIndexColumnPositions.end();++aIdxColIter,++i,++j) + for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i,++j) { setParameter(i,xParameter,(_rOrginalRow->get())[*aIdxColIter],(_rOrginalRow->get())[*aIdxColIter].getTypeKind(),aIter->second.nScale); } @@ -600,46 +607,46 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::insertRow" ); - ::rtl::OUString aSql(::rtl::OUString::createFromAscii("INSERT INTO ")); + ::rtl::OUStringBuffer aSql(::rtl::OUString::createFromAscii("INSERT INTO ")); Reference<XPropertySet> xSet(_xTable,UNO_QUERY); fillTableName(xSet); - aSql += m_aComposedTableName; - aSql += ::rtl::OUString::createFromAscii(" ( "); + aSql.append(m_aComposedTableName); + aSql.append(::rtl::OUString::createFromAscii(" ( ")); // set values and column names - ::rtl::OUString aValues(RTL_CONSTASCII_USTRINGPARAM(" VALUES ( ")); + ::rtl::OUStringBuffer aValues(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" VALUES ( "))); static ::rtl::OUString aPara(RTL_CONSTASCII_USTRINGPARAM("?,")); ::rtl::OUString aQuote = getIdentifierQuoteString(); static ::rtl::OUString aComma(RTL_CONSTASCII_USTRINGPARAM(",")); SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin(); + SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end(); sal_Int32 j = 1; sal_Bool bModified = sal_False; - for(;aIter != m_pColumnNames->end();++aIter,++j) + for(;aIter != aEnd;++aIter,++j) { if((_rInsertRow->get())[aIter->second.nPosition].isModified()) { - aSql += ::dbtools::quoteName( aQuote,aIter->first); - aSql += aComma; - aValues += aPara; + aSql.append(::dbtools::quoteName( aQuote,aIter->first)); + aSql.append(aComma); + aValues.append(aPara); bModified = sal_True; } } if ( !bModified ) ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_VALUE_CHANGED ), SQL_GENERAL_ERROR, m_xConnection ); - aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); - aValues = aValues.replaceAt(aValues.getLength()-1,1,::rtl::OUString::createFromAscii(")")); - - aSql += aValues; + aSql.setCharAt(aSql.getLength()-1,')'); + aValues.setCharAt(aValues.getLength()-1,')'); + aSql.append(aValues.makeStringAndClear()); // now create,fill and execute the prepared statement - Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql)); + Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear())); Reference< XParameters > xParameter(xPrep,UNO_QUERY); - SelectColumnsMetaData::const_iterator aPosIter = m_pColumnNames->begin(); - for(sal_Int32 i = 1;aPosIter != m_pColumnNames->end();++aPosIter) + aIter = m_pColumnNames->begin(); + for(sal_Int32 i = 1;aIter != aEnd;++aIter) { - sal_Int32 nPos = aPosIter->second.nPosition; + const sal_Int32 nPos = aIter->second.nPosition; if((_rInsertRow->get())[nPos].isModified()) { if((_rInsertRow->get())[nPos].isNull()) @@ -647,7 +654,7 @@ void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivi else { (_rInsertRow->get())[nPos].setSigned(m_aSignedFlags[nPos-1]); - setParameter(i++,xParameter,(_rInsertRow->get())[nPos],aPosIter->second.nType,aPosIter->second.nScale); + setParameter(i++,xParameter,(_rInsertRow->get())[nPos],aIter->second.nType,aIter->second.nScale); } } } @@ -657,11 +664,11 @@ void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivi if ( m_bInserted ) { // first insert the default values into the insertrow - SelectColumnsMetaData::const_iterator defaultIter = m_pColumnNames->begin(); - for(;defaultIter != m_pColumnNames->end();++defaultIter) + aIter = m_pColumnNames->begin(); + for(;aIter != aEnd;++aIter) { - if ( !(_rInsertRow->get())[defaultIter->second.nPosition].isModified() ) - (_rInsertRow->get())[defaultIter->second.nPosition] = defaultIter->second.sDefaultValue; + if ( !(_rInsertRow->get())[aIter->second.nPosition].isModified() ) + (_rInsertRow->get())[aIter->second.nPosition] = aIter->second.sDefaultValue; } try { @@ -701,17 +708,21 @@ void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivi if ( !bAutoValuesFetched && m_bInserted ) { // first check if all key column values were set - ::rtl::OUString sQuote = getIdentifierQuoteString(); + 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(); - for (;aAutoIter != m_aAutoColumns.end(); ++aAutoIter) + ::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) != m_pKeyColumnNames->end() ) + if ( m_pKeyColumnNames->find(*aAutoIter) != aEnd ) { - sMaxStmt += ::rtl::OUString::createFromAscii(" MAX("); + sMaxStmt += sMax; sMaxStmt += ::dbtools::quoteName( sQuote,*aAutoIter); - sMaxStmt += ::rtl::OUString::createFromAscii("),"); + sMaxStmt += sMaxEnd; } } @@ -731,12 +742,11 @@ void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivi if(xRow.is() && xRes->next()) { aAutoIter = m_aAutoColumns.begin(); - ::std::vector< ::rtl::OUString >::iterator aAutoEnd = m_aAutoColumns.end(); 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 != m_pKeyColumnNames->end()) + if ( aFind != aEnd ) (_rInsertRow->get())[aFind->second.nPosition].fill(i,aFind->second.nType,aFind->second.bNullable,xRow); } } @@ -780,9 +790,9 @@ void SAL_CALL OKeySet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivit Reference<XPropertySet> xSet(_xTable,UNO_QUERY); fillTableName(xSet); - ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DELETE FROM "); - aSql += m_aComposedTableName; - aSql += ::rtl::OUString::createFromAscii(" WHERE "); + ::rtl::OUStringBuffer aSql = ::rtl::OUString::createFromAscii("DELETE FROM "); + aSql.append(m_aComposedTableName); + aSql.append(::rtl::OUString::createFromAscii(" WHERE ")); // list all cloumns that should be set ::rtl::OUString aQuote = getIdentifierQuoteString(); @@ -800,64 +810,69 @@ void SAL_CALL OKeySet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivit ::std::vector< Reference<XNameAccess> > aAllIndexColumns; lcl_fillIndexColumns(xIndexes,aAllIndexColumns); - ::rtl::OUString aColumnName,sIndexCondition; + ::rtl::OUString aColumnName; + ::rtl::OUStringBuffer sIndexCondition; ::std::vector<sal_Int32> aIndexColumnPositions; SelectColumnsMetaData::const_iterator aIter = m_pColumnNames->begin(); + SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end(); sal_Int32 i = 1; - for(i = 1;aIter != m_pColumnNames->end();++aIter,++i) + for(i = 1;aIter != aEnd;++aIter,++i) { if(xKeyColumns.is() && xKeyColumns->hasByName(aIter->first)) { - aSql += ::dbtools::quoteName( aQuote,aIter->first); + aSql.append(::dbtools::quoteName( aQuote,aIter->first)); if((_rDeleteRow->get())[aIter->second.nPosition].isNull()) { OSL_ENSURE(0,"can a primary key be null"); - aSql += ::rtl::OUString::createFromAscii(" IS NULL"); + aSql.append(::rtl::OUString::createFromAscii(" IS NULL")); } else - aSql += ::rtl::OUString::createFromAscii(" = ?"); - aSql += aAnd; + aSql.append(::rtl::OUString::createFromAscii(" = ?")); + aSql.append(aAnd); } else { + ::std::vector< Reference<XNameAccess> >::const_iterator aIndexEnd = aAllIndexColumns.end(); for( ::std::vector< Reference<XNameAccess> >::const_iterator aIndexIter = aAllIndexColumns.begin(); - aIndexIter != aAllIndexColumns.end();++aIndexIter) + aIndexIter != aIndexEnd;++aIndexIter) { if((*aIndexIter)->hasByName(aIter->first)) { - sIndexCondition += ::dbtools::quoteName( aQuote,aIter->first); + sIndexCondition.append(::dbtools::quoteName( aQuote,aIter->first)); if((_rDeleteRow->get())[aIter->second.nPosition].isNull()) - sIndexCondition += ::rtl::OUString::createFromAscii(" IS NULL"); + sIndexCondition.append(::rtl::OUString::createFromAscii(" IS NULL")); else { - sIndexCondition += ::rtl::OUString::createFromAscii(" = ?"); + sIndexCondition.append(::rtl::OUString::createFromAscii(" = ?")); aIndexColumnPositions.push_back(aIter->second.nPosition); } - sIndexCondition += aAnd; + sIndexCondition.append(aAnd); break; } } } } - aSql += sIndexCondition; - aSql = aSql.replaceAt(aSql.getLength()-5,5,::rtl::OUString::createFromAscii(" ")); + aSql.append(sIndexCondition.makeStringAndClear()); + aSql.setLength(aSql.getLength()-5); // now create end execute the prepared statement - Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql)); + Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear())); Reference< XParameters > xParameter(xPrep,UNO_QUERY); aIter = (*m_pKeyColumnNames).begin(); + aEnd = (*m_pKeyColumnNames).end(); i = 1; - for(;aIter != (*m_pKeyColumnNames).end();++aIter,++i) + for(;aIter != aEnd;++aIter,++i) { setParameter(i,xParameter,(_rDeleteRow->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(); - for(;aIdxColIter != aIndexColumnPositions.end();++aIdxColIter,++i) + ::std::vector<sal_Int32>::iterator aIdxColEnd = aIndexColumnPositions.end(); + for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i) { setParameter(i,xParameter,(_rDeleteRow->get())[*aIdxColIter],(_rDeleteRow->get())[*aIdxColIter].getTypeKind(),aIter->second.nScale); } @@ -1111,10 +1126,12 @@ void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException) sal_Int32 nPos=1; connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aIter = m_aKeyIter->second.first->get().begin(); SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin(); - for(;aPosIter != (*m_pKeyColumnNames).end();++aPosIter,++aIter,++nPos) + SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end(); + for(;aPosIter != aPosEnd;++aPosIter,++aIter,++nPos) setParameter(nPos,xParameter,*aIter,aPosIter->second.nType,aPosIter->second.nScale); aPosIter = (*m_pForeignColumnNames).begin(); - for(;aPosIter != (*m_pForeignColumnNames).end();++aPosIter,++aIter,++nPos) + aPosEnd = (*m_pForeignColumnNames).end(); + for(;aPosIter != aPosEnd;++aPosIter,++aIter,++nPos) setParameter(nPos,xParameter,*aIter,aPosIter->second.nType,aPosIter->second.nScale); m_xSet = m_xStatement->executeQuery(); @@ -1146,7 +1163,7 @@ sal_Bool OKeySet::fetchRow() } // now fetch the values from the missing columns from other tables aPosIter = (*m_pForeignColumnNames).begin(); - aPosEnd = (*m_pForeignColumnNames).end(); + aPosEnd = (*m_pForeignColumnNames).end(); for(;aPosIter != aPosEnd;++aPosIter,++aIter) { const SelectColumnDescription& rColDesc = aPosIter->second; diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index 1ec43f2dd5c0..f49d074ff3fc 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -657,7 +657,8 @@ void ORowSet::freeResources( bool _bComplete ) MutexGuard aGuard(m_aMutex); // free all clones - for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); m_aClones.end() != i; i++) + connectivity::OWeakRefArray::iterator aEnd = m_aClones.end(); + for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); aEnd != i; i++) { Reference< XComponent > xComp(i->get(), UNO_QUERY); if (xComp.is()) @@ -2152,7 +2153,8 @@ void ORowSet::notifyRowSetAndClonesRowDelete( const Any& _rBookmark ) // notify ourself onDeleteRow( _rBookmark ); // notify the clones - for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); m_aClones.end() != i; i++) + connectivity::OWeakRefArray::iterator aEnd = m_aClones.end(); + for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); aEnd != i; i++) { Reference< XUnoTunnel > xTunnel(i->get(),UNO_QUERY); if(xTunnel.is()) @@ -2169,7 +2171,8 @@ void ORowSet::notifyRowSetAndClonesRowDeleted( const Any& _rBookmark, sal_Int32 // notify ourself onDeletedRow( _rBookmark, _nPos ); // notify the clones - for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); m_aClones.end() != i; i++) + connectivity::OWeakRefArray::iterator aEnd = m_aClones.end(); + for (connectivity::OWeakRefArray::iterator i = m_aClones.begin(); aEnd != i; i++) { Reference< XUnoTunnel > xTunnel(i->get(),UNO_QUERY); if(xTunnel.is()) @@ -2822,7 +2825,6 @@ ORowSetClone::ORowSetClone( const ::comphelper::ComponentContext& _rContext, ORo rParent.m_pColumns->getByName(*pIter) >>= xColumn; if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_DESCRIPTION)) aDescription = comphelper::getString(xColumn->getPropertyValue(PROPERTY_DESCRIPTION)); - ORowSetColumn* pColumn = new ORowSetColumn( rParent.getMetaData(), this, i, diff --git a/dbaccess/source/core/api/RowSetBase.cxx b/dbaccess/source/core/api/RowSetBase.cxx index ebcb8ca38d8e..da50983d72ad 100644 --- a/dbaccess/source/core/api/RowSetBase.cxx +++ b/dbaccess/source/core/api/RowSetBase.cxx @@ -1322,7 +1322,8 @@ void ORowSetBase::firePropertyChange(const ORowSetRow& _rOldRow) sal_Int32 i=0; try { - for(TDataColumns::iterator aIter = m_aDataColumns.begin();aIter != m_aDataColumns.end();++aIter,++i) // #104278# OJ ++i inserted + TDataColumns::iterator aEnd = m_aDataColumns.end(); + for(TDataColumns::iterator aIter = m_aDataColumns.begin();aIter != aEnd;++aIter,++i) // #104278# OJ ++i inserted (*aIter)->fireValueChange(_rOldRow.isValid() ? (_rOldRow->get())[i+1] : ::connectivity::ORowSetValue()); } catch(Exception&) diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx index 46f80a6ab372..38f075493f89 100644 --- a/dbaccess/source/core/api/RowSetCache.cxx +++ b/dbaccess/source/core/api/RowSetCache.cxx @@ -31,36 +31,89 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" +#ifndef _COMPHELPER_SEQSTREAM_HXX #include <comphelper/seqstream.hxx> +#endif +#ifndef _COMPHELPER_UNO3_HXX_ #include <comphelper/uno3.hxx> +#endif +#ifndef _COMPHELPER_EXTRACT_HXX_ #include <comphelper/extract.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XKeysSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_ #include <com/sun/star/sdbcx/KeyType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_ #include <com/sun/star/sdbc/ResultSetConcurrency.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ #include <com/sun/star/sdbc/ColumnValue.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_ #include <com/sun/star/sdbcx/Privilege.hpp> +#endif +#ifndef _DBACORE_DATACOLUMN_HXX_ #include "CRowSetDataColumn.hxx" +#endif +#ifndef DBACCESS_CORE_API_CROWSETCOLUMN_HXX #include "CRowSetColumn.hxx" +#endif +#ifndef DBACCESS_CORE_API_ROWSETBASE_HXX #include "RowSetBase.hxx" +#endif +#ifndef _DBHELPER_DBEXCEPTION_HXX_ #include <connectivity/dbexception.hxx> +#endif +#ifndef _CONNECTIVITY_SQLPARSE_HXX #include <connectivity/sqlparse.hxx> +#endif +#ifndef _CONNECTIVITY_SQLNODE_HXX #include <connectivity/sqlnode.hxx> +#endif +#ifndef _CONNECTIVITY_PARSE_SQLITERATOR_HXX_ #include <connectivity/sqliterator.hxx> +#endif +#ifndef _COMPHELPER_PROPERTY_HXX_ #include <comphelper/property.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBCX_COMPAREBOOKMARK_HPP_ #include <com/sun/star/sdbcx/CompareBookmark.hpp> +#endif +#ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> +#endif #include <algorithm> +#ifndef DBACCESS_CORE_API_ROWSETCACHE_HXX #include "RowSetCache.hxx" +#endif +#ifndef _DBA_CORE_RESOURCE_HXX_ #include "core_resource.hxx" +#endif +#ifndef _DBA_CORE_RESOURCE_HRC_ #include "core_resource.hrc" +#endif +#ifndef DBACCESS_CORE_API_BOOKMARKSET_HXX #include "BookmarkSet.hxx" +#endif +#ifndef DBACCESS_CORE_API_STATICSET_HXX #include "StaticSet.hxx" +#endif +#ifndef DBACCESS_CORE_API_KEYSET_HXX #include "KeySet.hxx" +#endif +#ifndef DBACCESS_SHARED_DBASTRINGS_HRC #include "dbastrings.hrc" -#include <rtl/logfile.hxx> +#endif using namespace dbaccess; using namespace dbtools; @@ -105,7 +158,6 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, ,m_bModified(_bModified) ,m_bNew(_bNew) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::ORowSetCache" ); DBG_CTOR(ORowSetCache,NULL); // check if all keys of the updateable table are fetched @@ -194,18 +246,41 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, } Reference< XPropertySet> xProp(_xRs,UNO_QUERY); - sal_Bool bBookmarkable = xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_ISBOOKMARKABLE) && - any2bool(xProp->getPropertyValue(PROPERTY_ISBOOKMARKABLE)) && Reference< XRowLocate >(_xRs, UNO_QUERY).is(); - sal_Bool bNeedKeySet = !bBookmarkable; + sal_Bool bNeedKeySet = !(xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_ISBOOKMARKABLE) && + any2bool(xProp->getPropertyValue(PROPERTY_ISBOOKMARKABLE)) && Reference< XRowLocate >(_xRs, UNO_QUERY).is() ); bNeedKeySet = bNeedKeySet || (xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_RESULTSETCONCURRENCY) && ::comphelper::getINT32(xProp->getPropertyValue(PROPERTY_RESULTSETCONCURRENCY)) == ResultSetConcurrency::READ_ONLY); // first check if resultset is bookmarkable - if ( !bNeedKeySet ) + if(!bNeedKeySet) { - bNeedKeySet = impl_createBookmarkSet_nothrow(_xRs); + try + { + m_pCacheSet = new OBookmarkSet(); + m_xCacheSet = m_pCacheSet; + m_pCacheSet->construct(_xRs); + + // check privileges + m_nPrivileges = Privilege::SELECT; + if(Reference<XResultSetUpdate>(_xRs,UNO_QUERY).is()) // this interface is optional so we have to check it + { + Reference<XPropertySet> xTable(m_aUpdateTable,UNO_QUERY); + if(xTable.is() && xTable->getPropertySetInfo()->hasPropertyByName(PROPERTY_PRIVILEGES)) + { + m_nPrivileges = 0; + xTable->getPropertyValue(PROPERTY_PRIVILEGES) >>= m_nPrivileges; + if(!m_nPrivileges) + m_nPrivileges = Privilege::SELECT; + } + } + } + catch(const SQLException&) + { + bNeedKeySet = sal_True; + } + } - if ( bNeedKeySet ) + if(bNeedKeySet) { // need to check if we could handle this select clause bAllKeysFound = bAllKeysFound && (nTablesCount == 1 || checkJoin(xConnection,_xAnalyzer,aUpdateTableName)); @@ -213,16 +288,11 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, // || !(comphelper::hasProperty(PROPERTY_CANUPDATEINSERTEDROWS,xProp) && any2bool(xProp->getPropertyValue(PROPERTY_CANUPDATEINSERTEDROWS))) // oj removed because keyset uses only the next// || (xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_RESULTSETTYPE) && comphelper::getINT32(xProp->getPropertyValue(PROPERTY_RESULTSETTYPE)) == ResultSetType::FORWARD_ONLY) - if ( !bAllKeysFound ) + if(!bAllKeysFound ) { - if ( bBookmarkable ) - impl_createBookmarkSet_nothrow(_xRs); - else - { - m_pCacheSet = new OStaticSet(); - m_xCacheSet = m_pCacheSet; - m_pCacheSet->construct(_xRs); - } + m_pCacheSet = new OStaticSet(); + m_xCacheSet = m_pCacheSet; + m_pCacheSet->construct(_xRs); m_nPrivileges = Privilege::SELECT; } else @@ -298,6 +368,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, ::comphelper::getINT32(xProp->getPropertyValue(PROPERTY_RESULTSETCONCURRENCY)) == ResultSetConcurrency::READ_ONLY) m_nPrivileges = Privilege::SELECT; } + // ------------------------------------------------------------------------- ORowSetCache::~ORowSetCache() { @@ -320,40 +391,10 @@ ORowSetCache::~ORowSetCache() DBG_DTOR(ORowSetCache,NULL); } -// ----------------------------------------------------------------------------- -sal_Bool ORowSetCache::impl_createBookmarkSet_nothrow(const Reference< XResultSet >& _xRs) -{ - sal_Bool bRet = sal_False; - try - { - m_pCacheSet = new OBookmarkSet(); - m_xCacheSet = m_pCacheSet; - m_pCacheSet->construct(_xRs); - // check privileges - m_nPrivileges = Privilege::SELECT; - if(Reference<XResultSetUpdate>(_xRs,UNO_QUERY).is()) // this interface is optional so we have to check it - { - Reference<XPropertySet> xTable(m_aUpdateTable,UNO_QUERY); - if(xTable.is() && xTable->getPropertySetInfo()->hasPropertyByName(PROPERTY_PRIVILEGES)) - { - m_nPrivileges = 0; - xTable->getPropertyValue(PROPERTY_PRIVILEGES) >>= m_nPrivileges; - if(!m_nPrivileges) - m_nPrivileges = Privilege::SELECT; - } - } - } - catch(const SQLException&) - { - bRet = sal_True; - } - return bRet; -} // ------------------------------------------------------------------------- void ORowSetCache::setMaxRowSize(sal_Int32 _nSize) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::setMaxRowSize" ); if(_nSize == m_nFetchSize) return; @@ -375,7 +416,8 @@ void ORowSetCache::setMaxRowSize(sal_Int32 _nSize) ::std::map<sal_Int32,sal_Bool> aCacheIterToChange; // first get the positions where they stand now ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin(); - for(;aCacheIter != m_aCacheIterators.end();++aCacheIter) + ORowSetCacheMap::iterator aCacheEnd = m_aCacheIterators.end(); + for(;aCacheIter != aCacheEnd;++aCacheIter) { aCacheIterToChange[aCacheIter->first] = sal_False; if ( !aCacheIter->second.pRowSet->isInsertRow() @@ -425,14 +467,12 @@ void ORowSetCache::setMaxRowSize(sal_Int32 _nSize) // XResultSetMetaDataSupplier Reference< XResultSetMetaData > ORowSetCache::getMetaData( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::getMetaData" ); return m_xMetaData; } // ------------------------------------------------------------------------- // ::com::sun::star::sdbcx::XRowLocate Any ORowSetCache::getBookmark( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::getBookmark" ); if(m_bAfterLast) throwFunctionSequenceException(m_xSet.get()); @@ -457,7 +497,6 @@ Any ORowSetCache::getBookmark( ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::moveToBookmark( const Any& bookmark ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::moveToBookmark" ); if ( m_pCacheSet->moveToBookmark(bookmark) ) { m_bBeforeFirst = sal_False; @@ -488,7 +527,6 @@ sal_Bool ORowSetCache::moveToBookmark( const Any& bookmark ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::moveRelativeToBookmark" ); sal_Bool bRet( moveToBookmark( bookmark ) ); if ( bRet ) { @@ -504,20 +542,17 @@ sal_Bool ORowSetCache::moveRelativeToBookmark( const Any& bookmark, sal_Int32 ro // ------------------------------------------------------------------------- sal_Int32 ORowSetCache::compareBookmarks( const Any& _first, const Any& _second ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::compareBookmarks" ); return (!_first.hasValue() || !_second.hasValue()) ? CompareBookmark::NOT_COMPARABLE : m_pCacheSet->compareBookmarks(_first,_second); } // ------------------------------------------------------------------------- sal_Bool ORowSetCache::hasOrderedBookmarks( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::hasOrderedBookmarks" ); return m_pCacheSet->hasOrderedBookmarks(); } // ------------------------------------------------------------------------- sal_Int32 ORowSetCache::hashBookmark( const Any& bookmark ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::hashBookmark" ); return m_pCacheSet->hashBookmark(bookmark); } @@ -526,7 +561,6 @@ sal_Int32 ORowSetCache::hashBookmark( const Any& bookmark ) // ----------------------------------------------------------------------------- void ORowSetCache::updateValue(sal_Int32 columnIndex,const ORowSetValue& x) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::updateValue" ); checkUpdateConditions(columnIndex); @@ -537,7 +571,6 @@ void ORowSetCache::updateValue(sal_Int32 columnIndex,const ORowSetValue& x) // ------------------------------------------------------------------------- void ORowSetCache::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::updateBinaryStream" ); checkUpdateConditions(columnIndex); @@ -549,7 +582,6 @@ void ORowSetCache::updateBinaryStream( sal_Int32 columnIndex, const Reference< : // ------------------------------------------------------------------------- void ORowSetCache::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::updateCharacterStream" ); checkUpdateConditions(columnIndex); @@ -562,7 +594,6 @@ void ORowSetCache::updateCharacterStream( sal_Int32 columnIndex, const Reference // ------------------------------------------------------------------------- void ORowSetCache::updateObject( sal_Int32 columnIndex, const Any& x ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::updateObject" ); checkUpdateConditions(columnIndex); @@ -573,7 +604,6 @@ void ORowSetCache::updateObject( sal_Int32 columnIndex, const Any& x ) // ------------------------------------------------------------------------- void ORowSetCache::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 /*scale*/ ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::updateNumericObject" ); checkUpdateConditions(columnIndex); @@ -585,7 +615,6 @@ void ORowSetCache::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal // XResultSet sal_Bool ORowSetCache::next( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::next" ); if(!isAfterLast()) @@ -610,7 +639,6 @@ sal_Bool ORowSetCache::next( ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::isBeforeFirst( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::isBeforeFirst" ); // return !m_nPosition; return m_bBeforeFirst; @@ -618,21 +646,18 @@ sal_Bool ORowSetCache::isBeforeFirst( ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::isAfterLast( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::isAfterLast" ); return m_bAfterLast; } // ------------------------------------------------------------------------- sal_Bool ORowSetCache::isFirst( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::isFirst" ); return m_nPosition == 1; // ask resultset for } // ------------------------------------------------------------------------- sal_Bool ORowSetCache::isLast( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::isLast" ); // return m_bRowCountFinal ? (m_nPosition==m_nRowCount) : m_pCacheSet->isLast(); return m_nPosition == m_nRowCount; @@ -640,7 +665,6 @@ sal_Bool ORowSetCache::isLast( ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::beforeFirst( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::beforeFirst" ); if(!m_bBeforeFirst) @@ -657,7 +681,6 @@ sal_Bool ORowSetCache::beforeFirst( ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::afterLast( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::afterLast" ); if(!m_bAfterLast) @@ -681,12 +704,10 @@ sal_Bool ORowSetCache::afterLast( ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos,sal_Int32 _nNewEndPos) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::fillMatrix" ); OSL_ENSURE(_nNewStartPos != _nNewEndPos,"ORowSetCache::fillMatrix: StartPos and EndPos can not be equal!"); // fill the whole window with new data ORowSetMatrix::iterator aIter = m_pMatrix->begin(); sal_Bool bCheck = m_pCacheSet->absolute(_nNewStartPos); // -1 no need to - const sal_Int32 nColumnCount = m_xMetaData->getColumnCount(); sal_Int32 i=_nNewStartPos; for(;i<_nNewEndPos;++i,++aIter) @@ -694,7 +715,7 @@ sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos,sal_Int32 _nNewEndPos if(bCheck) { if(!aIter->isValid()) - *aIter = new ORowSetValueVector(nColumnCount); + *aIter = new ORowSetValueVector(m_xMetaData->getColumnCount()); m_pCacheSet->fillValueRow(*aIter,i); } else @@ -711,22 +732,23 @@ sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos,sal_Int32 _nNewEndPos if(m_nRowCount > m_nFetchSize) { ORowSetMatrix::iterator aEnd = aIter; + ORowSetMatrix::iterator aRealEnd = m_pMatrix->end(); sal_Int32 nPos = m_nRowCount - m_nFetchSize + 1; _nNewStartPos = nPos; bCheck = m_pCacheSet->absolute(_nNewStartPos); - for(;bCheck && aIter != m_pMatrix->end();++aIter) + for(;bCheck && aIter != aRealEnd;++aIter) { if(bCheck) { if(!aIter->isValid()) - *aIter = new ORowSetValueVector(nColumnCount); + *aIter = new ORowSetValueVector(m_xMetaData->getColumnCount()); m_pCacheSet->fillValueRow(*aIter,nPos++); } bCheck = m_pCacheSet->next(); } if(aIter != aEnd) - ::std::rotate(m_pMatrix->begin(),aEnd,m_pMatrix->end()); + ::std::rotate(m_pMatrix->begin(),aEnd,aRealEnd); } break; } @@ -752,7 +774,6 @@ sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos,sal_Int32 _nNewEndPos // ------------------------------------------------------------------------- sal_Bool ORowSetCache::moveWindow() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::moveWindow" ); sal_Bool bRet = sal_True; @@ -803,7 +824,8 @@ sal_Bool ORowSetCache::moveWindow() ptrdiff_t nNewDist = aEnd - m_pMatrix->begin(); ptrdiff_t nOffSet = m_pMatrix->end() - aEnd; ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin(); - for(;aCacheIter != m_aCacheIterators.end();++aCacheIter) + ORowSetCacheMap::iterator aCacheEnd = m_aCacheIterators.end(); + for(;aCacheIter != aCacheEnd;++aCacheIter) { if ( !aCacheIter->second.pRowSet->isInsertRow() && aCacheIter->second.aIterator != m_pMatrix->end() && !m_bModified ) @@ -990,7 +1012,6 @@ sal_Bool ORowSetCache::moveWindow() // ------------------------------------------------------------------------- sal_Bool ORowSetCache::first( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::first" ); // first move to the first row // then check if the cache window is at the begining // when not postionize the window and fill it with data @@ -1016,7 +1037,6 @@ sal_Bool ORowSetCache::first( ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::last( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::last" ); sal_Bool bRet = m_pCacheSet->last(); if(bRet) { @@ -1056,13 +1076,11 @@ sal_Bool ORowSetCache::last( ) // ------------------------------------------------------------------------- sal_Int32 ORowSetCache::getRow( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::getRow" ); return (isBeforeFirst() || isAfterLast()) ? 0 : m_nPosition; } // ------------------------------------------------------------------------- sal_Bool ORowSetCache::absolute( sal_Int32 row ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::absolute" ); if(!row ) throw SQLException(DBACORE_RESSTRING(RID_STR_NO_ABS_ZERO),NULL,SQLSTATE_GENERAL,1000,Any() ); @@ -1116,7 +1134,6 @@ sal_Bool ORowSetCache::absolute( sal_Int32 row ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::relative( sal_Int32 rows ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::relative" ); sal_Bool bErg = sal_True; if(rows) { @@ -1145,7 +1162,6 @@ sal_Bool ORowSetCache::relative( sal_Int32 rows ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::previous( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::previous" ); sal_Bool bRet = sal_False; if(!isBeforeFirst()) { @@ -1177,7 +1193,6 @@ sal_Bool ORowSetCache::previous( ) // ------------------------------------------------------------------------- void ORowSetCache::refreshRow( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::refreshRow" ); if(isAfterLast()) throw SQLException(DBACORE_RESSTRING(RID_STR_NO_REFESH_AFTERLAST),NULL,SQLSTATE_GENERAL,1000,Any() ); OSL_ENSURE(m_aMatrixIter != m_pMatrix->end(),"refreshRow() called for invalid row!"); @@ -1191,20 +1206,17 @@ void ORowSetCache::refreshRow( ) // ------------------------------------------------------------------------- sal_Bool ORowSetCache::rowUpdated( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::rowUpdated" ); return m_pCacheSet->rowUpdated(); } // ------------------------------------------------------------------------- sal_Bool ORowSetCache::rowInserted( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::rowInserted" ); return m_pCacheSet->rowInserted(); } // ------------------------------------------------------------------------- // XResultSetUpdate sal_Bool ORowSetCache::insertRow( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::insertRow" ); if ( !m_bNew || !m_aInsertRow->isValid() ) throw SQLException(DBACORE_RESSTRING(RID_STR_NO_MOVETOINSERTROW_CALLED),NULL,SQLSTATE_GENERAL,1000,Any() ); @@ -1228,7 +1240,6 @@ sal_Bool ORowSetCache::insertRow( ) // ------------------------------------------------------------------------- void ORowSetCache::resetInsertRow(sal_Bool _bClearInsertRow) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::resetInsertRow" ); if ( _bClearInsertRow ) clearInsertRow(); m_bNew = sal_False; @@ -1237,7 +1248,6 @@ void ORowSetCache::resetInsertRow(sal_Bool _bClearInsertRow) // ------------------------------------------------------------------------- void ORowSetCache::cancelRowModification() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::cancelRowModification" ); // clear the insertrow references -> implies that the current row of the rowset changes as well ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin(); ORowSetCacheMap::iterator aCacheEnd = m_aCacheIterators.end(); @@ -1251,7 +1261,6 @@ void ORowSetCache::cancelRowModification() // ------------------------------------------------------------------------- void ORowSetCache::updateRow( ORowSetMatrix::iterator& _rUpdateRow ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::updateRow" ); if(isAfterLast() || isBeforeFirst()) throw SQLException(DBACORE_RESSTRING(RID_STR_NO_UPDATEROW),NULL,SQLSTATE_GENERAL,1000,Any() ); @@ -1275,7 +1284,6 @@ void ORowSetCache::updateRow( ORowSetMatrix::iterator& _rUpdateRow ) // ------------------------------------------------------------------------- bool ORowSetCache::deleteRow( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::deleteRow" ); if(isAfterLast() || isBeforeFirst()) throw SQLException(DBACORE_RESSTRING(RID_STR_NO_DELETEROW),NULL,SQLSTATE_GENERAL,1000,Any() ); @@ -1291,7 +1299,8 @@ bool ORowSetCache::deleteRow( ) // (*m_pMatrix)[(m_nPosition - m_nStartPos)] = NULL; // set the deleted row to NULL - for(++aPos;aPos != m_pMatrix->end() && aPos->isValid();++aPos) + ORowSetMatrix::iterator aEnd = m_pMatrix->end(); + for(++aPos;aPos != aEnd && aPos->isValid();++aPos) { *(aPos-1) = *aPos; (*aPos) = NULL; @@ -1304,7 +1313,6 @@ bool ORowSetCache::deleteRow( ) // ------------------------------------------------------------------------- void ORowSetCache::cancelRowUpdates( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::cancelRowUpdates" ); m_bNew = m_bModified = sal_False; if(!m_nPosition) { @@ -1323,7 +1331,6 @@ void ORowSetCache::cancelRowUpdates( ) // ------------------------------------------------------------------------- void ORowSetCache::moveToInsertRow( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::moveToInsertRow" ); m_bNew = sal_True; m_bUpdated = m_bAfterLast = sal_False; @@ -1333,7 +1340,8 @@ void ORowSetCache::moveToInsertRow( ) // we don't unbound the bookmark column ORowSetValueVector::Vector::iterator aIter = (*m_aInsertRow)->get().begin()+1; - for(;aIter != (*m_aInsertRow)->get().end();++aIter) + ORowSetValueVector::Vector::iterator aEnd = (*m_aInsertRow)->get().end(); + for(;aIter != aEnd;++aIter) { aIter->setBound(sal_False); aIter->setModified(sal_False); @@ -1343,7 +1351,6 @@ void ORowSetCache::moveToInsertRow( ) // ------------------------------------------------------------------------- ORowSetCacheIterator ORowSetCache::createIterator(ORowSetBase* _pRowSet) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::createIterator" ); ORowSetCacheIterator_Helper aHelper; aHelper.aIterator = m_pMatrix->end(); @@ -1353,12 +1360,12 @@ ORowSetCacheIterator ORowSetCache::createIterator(ORowSetBase* _pRowSet) // ----------------------------------------------------------------------------- void ORowSetCache::rotateCacheIterator(ORowSetMatrix::difference_type _nDist) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::rotateCacheIterator" ); if(_nDist) { // now correct the iterator in our iterator vector ORowSetCacheMap::iterator aCacheIter = m_aCacheIterators.begin(); - for(;aCacheIter != m_aCacheIterators.end();++aCacheIter) + ORowSetCacheMap::iterator aCacheEnd = m_aCacheIterators.end(); + for(;aCacheIter != aCacheEnd;++aCacheIter) { if ( !aCacheIter->second.pRowSet->isInsertRow() && aCacheIter->second.aIterator != m_pMatrix->end() && !m_bModified ) @@ -1382,7 +1389,6 @@ void ORowSetCache::rotateCacheIterator(ORowSetMatrix::difference_type _nDist) // ------------------------------------------------------------------------- void ORowSetCache::setUpdateIterator(const ORowSetMatrix::iterator& _rOriginalRow) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::setUpdateIterator" ); m_aInsertRow = m_pInsertMatrix->begin(); if(!m_aInsertRow->isValid()) *m_aInsertRow = new ORowSetValueVector(m_xMetaData->getColumnCount()); @@ -1390,13 +1396,13 @@ void ORowSetCache::setUpdateIterator(const ORowSetMatrix::iterator& _rOriginalRo (*(*m_aInsertRow)) = (*(*_rOriginalRow)); // we don't unbound the bookmark column ORowSetValueVector::Vector::iterator aIter = (*m_aInsertRow)->get().begin(); - for(;aIter != (*m_aInsertRow)->get().end();++aIter) + ORowSetValueVector::Vector::iterator aEnd = (*m_aInsertRow)->get().end(); + for(;aIter != aEnd;++aIter) aIter->setModified(sal_False); } // ----------------------------------------------------------------------------- void ORowSetCache::checkPositionFlags() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::checkPositionFlags" ); if(m_bRowCountFinal) { m_bAfterLast = m_nPosition > m_nRowCount; @@ -1407,14 +1413,12 @@ void ORowSetCache::checkPositionFlags() // ----------------------------------------------------------------------------- void ORowSetCache::checkUpdateConditions(sal_Int32 columnIndex) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::checkUpdateConditions" ); if(m_bAfterLast || columnIndex >= (sal_Int32)(*m_aInsertRow)->get().size()) throwFunctionSequenceException(m_xSet.get()); } //------------------------------------------------------------------------------ sal_Bool ORowSetCache::checkInnerJoin(const ::connectivity::OSQLParseNode *pNode,const Reference< XConnection>& _xConnection,const ::rtl::OUString& _sUpdateTableName) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::checkInnerJoin" ); sal_Bool bOk = sal_False; if (pNode->count() == 3 && // Ausdruck is geklammert SQL_ISPUNCTUATION(pNode->getChild(0),"(") && @@ -1456,7 +1460,6 @@ sal_Bool ORowSetCache::checkJoin(const Reference< XConnection>& _xConnection, const Reference< XSingleSelectQueryAnalyzer >& _xAnalyzer, const ::rtl::OUString& _sUpdateTableName ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::checkJoin" ); sal_Bool bOk = sal_False; ::rtl::OUString sSql = _xAnalyzer->getQuery(); ::rtl::OUString sErrorMsg; @@ -1515,7 +1518,6 @@ sal_Bool ORowSetCache::checkJoin(const Reference< XConnection>& _xConnection, // ----------------------------------------------------------------------------- void ORowSetCache::clearInsertRow() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::clearInsertRow" ); // we don't unbound the bookmark column if ( m_aInsertRow != m_pInsertMatrix->end() && m_aInsertRow->isValid() ) { @@ -1532,7 +1534,6 @@ void ORowSetCache::clearInsertRow() // ----------------------------------------------------------------------------- ORowSetMatrix::iterator ORowSetCache::calcPosition() const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::calcPosition" ); sal_Int32 nValue = (m_nPosition - m_nStartPos) - 1; CHECK_MATRIX_POS(nValue); return ( nValue < 0 || nValue >= static_cast<sal_Int32>(m_pMatrix->size()) ) ? m_pMatrix->end() : (m_pMatrix->begin() + nValue); @@ -1541,7 +1542,6 @@ ORowSetMatrix::iterator ORowSetCache::calcPosition() const TORowSetOldRowHelperRef ORowSetCache::registerOldRow() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::registerOldRow" ); TORowSetOldRowHelperRef pRef = new ORowSetOldRowHelper(ORowSetRow()); m_aOldRows.push_back(pRef); return pRef; @@ -1549,8 +1549,8 @@ TORowSetOldRowHelperRef ORowSetCache::registerOldRow() // ----------------------------------------------------------------------------- void ORowSetCache::deregisterOldRow(const TORowSetOldRowHelperRef& _rRow) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::deregisterOldRow" ); - for (TOldRowSetRows::iterator aOldRowIter = m_aOldRows.begin(); aOldRowIter != m_aOldRows.end(); ++aOldRowIter) + TOldRowSetRows::iterator aOldRowEnd = m_aOldRows.end(); + for (TOldRowSetRows::iterator aOldRowIter = m_aOldRows.begin(); aOldRowIter != aOldRowEnd; ++aOldRowIter) { if ( aOldRowIter->getBodyPtr() == _rRow.getBodyPtr() ) { @@ -1563,8 +1563,8 @@ void ORowSetCache::deregisterOldRow(const TORowSetOldRowHelperRef& _rRow) // ----------------------------------------------------------------------------- sal_Bool ORowSetCache::reFillMatrix(sal_Int32 _nNewStartPos,sal_Int32 _nNewEndPos) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::reFillMatrix" ); - for (TOldRowSetRows::iterator aOldRowIter = m_aOldRows.begin(); aOldRowIter != m_aOldRows.end(); ++aOldRowIter) + TOldRowSetRows::iterator aOldRowEnd = m_aOldRows.end(); + for (TOldRowSetRows::iterator aOldRowIter = m_aOldRows.begin(); aOldRowIter != aOldRowEnd; ++aOldRowIter) { if ( aOldRowIter->isValid() && aOldRowIter->getBody().getRow().isValid() ) aOldRowIter->getBody().setRow(new ORowSetValueVector(aOldRowIter->getBody().getRow().getBody()) ); @@ -1578,7 +1578,6 @@ sal_Bool ORowSetCache::reFillMatrix(sal_Int32 _nNewStartPos,sal_Int32 _nNewEndPo // ----------------------------------------------------------------------------- sal_Bool ORowSetCache::fill(ORowSetMatrix::iterator& _aIter,const ORowSetMatrix::iterator& _aEnd,sal_Int32& _nPos,sal_Bool _bCheck) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCache::fill" ); sal_Int32 nColumnCount = m_xMetaData->getColumnCount(); for(; _bCheck && _aIter != _aEnd;) { @@ -1586,7 +1585,8 @@ sal_Bool ORowSetCache::fill(ORowSetMatrix::iterator& _aIter,const ORowSetMatrix: *_aIter = new ORowSetValueVector(nColumnCount); else { - for (TOldRowSetRows::iterator aOldRowIter = m_aOldRows.begin(); aOldRowIter != m_aOldRows.end(); ++aOldRowIter) + TOldRowSetRows::iterator aOldRowEnd = m_aOldRows.end(); + for (TOldRowSetRows::iterator aOldRowIter = m_aOldRows.begin(); aOldRowIter != aOldRowEnd; ++aOldRowIter) { if ( aOldRowIter->getBody().getRow().isEqualBody(*_aIter) ) *_aIter = new ORowSetValueVector(nColumnCount); diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index 4583dd3dfabf..15bbed1b5936 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -262,7 +262,8 @@ OSingleSelectQueryComposer::~OSingleSelectQueryComposer() delete *aColIter; ::std::vector<OPrivateTables*>::iterator aTabIter = m_aTablesCollection.begin(); - for(;aTabIter != m_aTablesCollection.end();++aTabIter) + ::std::vector<OPrivateTables*>::iterator aTabEnd = m_aTablesCollection.end(); + for(;aTabIter != aTabEnd;++aTabIter) delete *aTabIter; } // ------------------------------------------------------------------------- @@ -572,12 +573,12 @@ void OSingleSelectQueryComposer::setSingleAdditiveClause( SQLPart _ePart, const *pComposer, getKeyword( _ePart ) ); // construct the complete statement - ::rtl::OUString aSql(m_aPureSelectSQL); + ::rtl::OUStringBuffer aSql(m_aPureSelectSQL); for ( SQLPart eLoopParts = Where; eLoopParts != SQLPartCount; incSQLPart( eLoopParts ) ) - aSql += aClauses[ eLoopParts ]; + aSql.append(aClauses[ eLoopParts ]); // set the query - setQuery_Impl(aSql); + setQuery_Impl(aSql.makeStringAndClear()); // parameters may also have changed clearParametersCollection(); @@ -590,10 +591,10 @@ void OSingleSelectQueryComposer::setSingleAdditiveClause( SQLPart _ePart, const aClauses[ _ePart ] = getComposedClause( ::rtl::OUString(), _rClause, *pComposer, getKeyword( _ePart ) ); // and parse it, so that m_aAdditiveIterator is up to date for ( SQLPart eLoopParts = Where; eLoopParts != SQLPartCount; incSQLPart( eLoopParts ) ) - aSql += aClauses[ eLoopParts ]; + aSql.append(aClauses[ eLoopParts ]); try { - parseAndCheck_throwError( m_aSqlParser, aSql, m_aAdditiveIterator, *this ); + parseAndCheck_throwError( m_aSqlParser, aSql.makeStringAndClear(), m_aAdditiveIterator, *this ); } catch( const Exception& e ) { @@ -642,7 +643,8 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getTables( ) thro { const OSQLTables& aTables = m_aSqlIterator.getTables(); ::std::vector< ::rtl::OUString> aNames; - for(OSQLTables::const_iterator aIter = aTables.begin(); aIter != aTables.end();++aIter) + OSQLTables::const_iterator aEnd = aTables.end(); + for(OSQLTables::const_iterator aIter = aTables.begin(); aIter != aEnd;++aIter) aNames.push_back(aIter->first); m_pTables = new OPrivateTables(aTables,m_xMetaData->supportsMixedCaseQuotedIdentifiers(),*this,m_aMutex,aNames); @@ -1232,7 +1234,8 @@ Reference< XIndexAccess > SAL_CALL OSingleSelectQueryComposer::getParameters( ) { ::vos::ORef< OSQLColumns> aCols = m_aSqlIterator.getParameters(); ::std::vector< ::rtl::OUString> aNames; - for(OSQLColumns::Vector::const_iterator aIter = aCols->get().begin(); aIter != aCols->get().end();++aIter) + OSQLColumns::Vector::const_iterator aEnd = aCols->get().end(); + for(OSQLColumns::Vector::const_iterator aIter = aCols->get().begin(); aIter != aEnd;++aIter) aNames.push_back(getString((*aIter)->getPropertyValue(PROPERTY_NAME))); m_aCurrentColumns[ParameterColumns] = new OPrivateColumns(aCols,m_xMetaData->supportsMixedCaseQuotedIdentifiers(),*this,m_aMutex,aNames,sal_True); } @@ -1285,7 +1288,8 @@ Reference< XIndexAccess > OSingleSelectQueryComposer::setCurrentColumns( EColumn if ( !m_aCurrentColumns[_eType] ) { ::std::vector< ::rtl::OUString> aNames; - for(OSQLColumns::Vector::const_iterator aIter = _rCols->get().begin(); aIter != _rCols->get().end();++aIter) + OSQLColumns::Vector::const_iterator aEnd = _rCols->get().end(); + for(OSQLColumns::Vector::const_iterator aIter = _rCols->get().begin(); aIter != aEnd;++aIter) aNames.push_back(getString((*aIter)->getPropertyValue(PROPERTY_NAME))); m_aCurrentColumns[_eType] = new OPrivateColumns(_rCols,m_xMetaData->supportsMixedCaseQuotedIdentifiers(),*this,m_aMutex,aNames,sal_True); } @@ -1340,75 +1344,75 @@ namespace { ::rtl::OUString lcl_getCondition(const Sequence< Sequence< PropertyValue > >& filter ) { - ::rtl::OUString sRet; + ::rtl::OUStringBuffer sRet; const Sequence< PropertyValue >* pOrIter = filter.getConstArray(); const Sequence< PropertyValue >* pOrEnd = pOrIter + filter.getLength(); while ( pOrIter != pOrEnd ) { if ( pOrIter->getLength() ) { - sRet += L_BRACKET; + sRet.append(L_BRACKET); const PropertyValue* pAndIter = pOrIter->getConstArray(); const PropertyValue* pAndEnd = pAndIter + pOrIter->getLength(); while ( pAndIter != pAndEnd ) { - sRet += pAndIter->Name; + sRet.append(pAndIter->Name); ::rtl::OUString sValue; pAndIter->Value >>= sValue; switch( pAndIter->Handle ) { case SQLFilterOperator::EQUAL: - sRet += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" = ")); - sRet += sValue; + sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" = "))); + sRet.append(sValue); break; case SQLFilterOperator::NOT_EQUAL: - sRet += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" <> ")); - sRet += sValue; + sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" <> "))); + sRet.append(sValue); break; case SQLFilterOperator::LESS: - sRet += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" < ")); - sRet += sValue; + sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" < "))); + sRet.append(sValue); break; case SQLFilterOperator::GREATER: - sRet += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" > ")); - sRet += sValue; + sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" > "))); + sRet.append(sValue); break; case SQLFilterOperator::LESS_EQUAL: - sRet += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" <= ")); - sRet += sValue; + sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" <= "))); + sRet.append(sValue); break; case SQLFilterOperator::GREATER_EQUAL: - sRet += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" >= ")); - sRet += sValue; + sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" >= "))); + sRet.append(sValue); break; case SQLFilterOperator::LIKE: - sRet += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" LIKE ")); - sRet += sValue; + sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" LIKE "))); + sRet.append(sValue); break; case SQLFilterOperator::NOT_LIKE: - sRet += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" NOT LIKE ")); - sRet += sValue; + sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" NOT LIKE "))); + sRet.append(sValue); break; case SQLFilterOperator::SQLNULL: - sRet += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" IS NULL")) ; + sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" IS NULL")) ); break; case SQLFilterOperator::NOT_SQLNULL: - sRet += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" IS NOT NULL")) ; + sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" IS NOT NULL")) ); break; default: throw IllegalArgumentException(); } ++pAndIter; if ( pAndIter != pAndEnd ) - sRet += STR_AND; + sRet.append(STR_AND); } - sRet += R_BRACKET; + sRet.append(R_BRACKET); } ++pOrIter; if ( pOrIter != pOrEnd && sRet.getLength() ) - sRet += STR_OR; + sRet.append(STR_OR); } - return sRet; + return sRet.makeStringAndClear(); } } // ----------------------------------------------------------------------------- diff --git a/dbaccess/source/core/api/resultset.cxx b/dbaccess/source/core/api/resultset.cxx index d924f5faf738..a5f5c3b84bba 100644 --- a/dbaccess/source/core/api/resultset.cxx +++ b/dbaccess/source/core/api/resultset.cxx @@ -1,1211 +1,1211 @@ -/*************************************************************************
- *
- * 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: resultset.cxx,v $
- * $Revision: 1.21 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_dbaccess.hxx"
-#ifndef _DBA_COREAPI_RESULTSET_HXX_
-#include <resultset.hxx>
-#endif
-#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
-#include "dbastrings.hrc"
-#endif
-#ifndef _DBASHARED_APITOOLS_HXX_
-#include "apitools.hxx"
-#endif
-#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
-#include <com/sun/star/lang/DisposedException.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_
-#include <com/sun/star/sdbc/ResultSetType.hpp>
-#endif
-#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
-#include <cppuhelper/typeprovider.hxx>
-#endif
-#ifndef _COMPHELPER_PROPERTY_HXX_
-#include <comphelper/property.hxx>
-#endif
-#ifndef _COMPHELPER_SEQUENCE_HXX_
-#include <comphelper/sequence.hxx>
-#endif
-#ifndef _COMPHELPER_TYPES_HXX_
-#include <comphelper/types.hxx>
-#endif
-#ifndef _TOOLS_DEBUG_HXX //autogen
-#include <tools/debug.hxx>
-#endif
-#ifndef TOOLS_DIAGNOSE_EX_H
-#include <tools/diagnose_ex.h>
-#endif
-#ifndef _DBA_COREAPI_DATACOLUMN_HXX_
-#include <datacolumn.hxx>
-#endif
-#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
-#include <com/sun/star/beans/PropertyAttribute.hpp>
-#endif
-#ifndef _DBHELPER_DBEXCEPTION_HXX_
-#include <connectivity/dbexception.hxx>
-#endif
-#ifndef _CONNECTIVITY_DBTOOLS_HXX_
-#include <connectivity/dbtools.hxx>
-#endif
-#ifndef _CPPUHELPER_EXC_HLP_HXX_
-#include <cppuhelper/exc_hlp.hxx>
-#endif
-#ifndef _OSL_THREAD_H_
-#include <osl/thread.h>
-#endif
-#include <rtl/logfile.hxx>
-
-
-using namespace ::com::sun::star::sdbc;
-using namespace ::com::sun::star::sdbcx;
-//using namespace ::com::sun::star::sdb;
-using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::container;
-using namespace ::cppu;
-using namespace ::osl;
-using namespace dbaccess;
-using namespace dbtools;
-
-DBG_NAME(OResultSet)
-
-//--------------------------------------------------------------------------
-OResultSet::OResultSet(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& _xResultSet,
- const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xStatement,
- sal_Bool _bCaseSensitive)
- :OResultSetBase(m_aMutex)
- ,OPropertySetHelper(OResultSetBase::rBHelper)
- ,m_xDelegatorResultSet(_xResultSet)
- ,m_aWarnings( Reference< XWarningsSupplier >( _xResultSet, UNO_QUERY ) )
- ,m_bIsBookmarkable(sal_False)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::OResultSet" );
- DBG_CTOR(OResultSet, NULL);
-
- m_pColumns = new OColumns(*this, m_aMutex, _bCaseSensitive, ::std::vector< ::rtl::OUString>(), NULL,NULL);
-
- try
- {
- m_aStatement = _xStatement;
- m_xDelegatorResultSetUpdate = m_xDelegatorResultSetUpdate.query( m_xDelegatorResultSet );
- m_xDelegatorRow = m_xDelegatorRow.query( m_xDelegatorResultSet );
- m_xDelegatorRowUpdate = m_xDelegatorRowUpdate.query( m_xDelegatorResultSet );
-
- Reference< XPropertySet > xSet(m_xDelegatorResultSet, UNO_QUERY);
- xSet->getPropertyValue(PROPERTY_RESULTSETTYPE) >>= m_nResultSetType;
- xSet->getPropertyValue(PROPERTY_RESULTSETCONCURRENCY) >>= m_nResultSetConcurrency;
-
- // test for Bookmarks
- if (ResultSetType::FORWARD_ONLY != m_nResultSetType)
- {
- Reference <XPropertySetInfo > xInfo(xSet->getPropertySetInfo());
- if (xInfo->hasPropertyByName(PROPERTY_ISBOOKMARKABLE))
- {
- m_bIsBookmarkable = ::comphelper::getBOOL(xSet->getPropertyValue(PROPERTY_ISBOOKMARKABLE));
- OSL_ENSURE( !m_bIsBookmarkable || Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY).is(),
- "OResultSet::OResultSet: aggregate is inconsistent in it's bookmarkable attribute!" );
- m_bIsBookmarkable = m_bIsBookmarkable && Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY).is();
- }
- }
- }
- catch(Exception&)
- {
- }
-}
-
-//--------------------------------------------------------------------------
-OResultSet::~OResultSet()
-{
- m_pColumns->acquire();
- m_pColumns->disposing();
- delete m_pColumns;
-
- DBG_DTOR(OResultSet, NULL);
-}
-
-// com::sun::star::lang::XTypeProvider
-//--------------------------------------------------------------------------
-Sequence< Type > OResultSet::getTypes() throw (RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getTypes" );
- OTypeCollection aTypes(::getCppuType( (const Reference< XPropertySet > *)0 ),
- OResultSetBase::getTypes());
-
- return aTypes.getTypes();
-}
-
-//--------------------------------------------------------------------------
-Sequence< sal_Int8 > OResultSet::getImplementationId() throw (RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getImplementationId" );
- static OImplementationId * pId = 0;
- if (! pId)
- {
- MutexGuard aGuard( Mutex::getGlobalMutex() );
- if (! pId)
- {
- static OImplementationId aId;
- pId = &aId;
- }
- }
- return pId->getImplementationId();
-}
-
-// com::sun::star::uno::XInterface
-//--------------------------------------------------------------------------
-Any OResultSet::queryInterface( const Type & rType ) throw (RuntimeException)
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::queryInterface" );
- Any aIface = OResultSetBase::queryInterface( rType );
- if (!aIface.hasValue())
- aIface = ::cppu::queryInterface(
- rType,
- static_cast< XPropertySet * >( this ));
-
- return aIface;
-}
-
-//--------------------------------------------------------------------------
-void OResultSet::acquire() throw ()
-{
- OResultSetBase::acquire();
-}
-
-//--------------------------------------------------------------------------
-void OResultSet::release() throw ()
-{
- OResultSetBase::release();
-}
-
-
-// OResultSetBase
-//------------------------------------------------------------------------------
-void OResultSet::disposing()
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::disposing" );
- OPropertySetHelper::disposing();
-
- MutexGuard aGuard(m_aMutex);
-
- // free the columns
- m_pColumns->disposing();
-
- // close the pending result set
- Reference< XCloseable > (m_xDelegatorResultSet, UNO_QUERY)->close();
-
- m_xDelegatorResultSet = NULL;
- m_xDelegatorRow = NULL;
- m_xDelegatorRowUpdate = NULL;
-
- m_aStatement = Reference< XInterface >();
-}
-
-// XCloseable
-//------------------------------------------------------------------------------
-void OResultSet::close(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::close" );
- {
- MutexGuard aGuard( m_aMutex );
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
- }
- dispose();
-}
-
-// XServiceInfo
-//------------------------------------------------------------------------------
-rtl::OUString OResultSet::getImplementationName( ) throw(RuntimeException)
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getImplementationName" );
- return rtl::OUString::createFromAscii("com.sun.star.sdb.OResultSet");
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::supportsService" );
- return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
-}
-
-//------------------------------------------------------------------------------
-Sequence< ::rtl::OUString > OResultSet::getSupportedServiceNames( ) throw (RuntimeException)
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getSupportedServiceNames" );
- Sequence< ::rtl::OUString > aSNS( 2 );
- aSNS[0] = SERVICE_SDBC_RESULTSET;
- aSNS[1] = SERVICE_SDB_RESULTSET;
- return aSNS;
-}
-
-// com::sun::star::beans::XPropertySet
-//------------------------------------------------------------------------------
-Reference< XPropertySetInfo > OResultSet::getPropertySetInfo() throw (RuntimeException)
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getPropertySetInfo" );
- return createPropertySetInfo( getInfoHelper() ) ;
-}
-
-// comphelper::OPropertyArrayUsageHelper
-//------------------------------------------------------------------------------
-::cppu::IPropertyArrayHelper* OResultSet::createArrayHelper( ) const
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::createArrayHelper" );
- BEGIN_PROPERTY_HELPER(6)
- DECL_PROP1(CURSORNAME, ::rtl::OUString, READONLY);
- DECL_PROP0(FETCHDIRECTION, sal_Int32);
- DECL_PROP0(FETCHSIZE, sal_Int32);
- DECL_PROP1_BOOL(ISBOOKMARKABLE, READONLY);
- DECL_PROP1(RESULTSETCONCURRENCY, sal_Int32, READONLY);
- DECL_PROP1(RESULTSETTYPE, sal_Int32, READONLY);
- END_PROPERTY_HELPER();
-}
-
-// cppu::OPropertySetHelper
-//------------------------------------------------------------------------------
-::cppu::IPropertyArrayHelper& OResultSet::getInfoHelper()
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getInfoHelper" );
- return *getArrayHelper();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::convertFastPropertyValue(Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue ) throw( IllegalArgumentException )
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::convertFastPropertyValue" );
- // be lazy ...
- rConvertedValue = rValue;
- getFastPropertyValue( rOldValue, nHandle );
- return sal_True;
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception)
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::setFastPropertyValue_NoBroadcast" );
- // set it for the driver result set
- Reference< XPropertySet > xSet(m_xDelegatorResultSet, UNO_QUERY);
- switch (nHandle)
- {
- case PROPERTY_ID_FETCHDIRECTION:
- xSet->setPropertyValue(PROPERTY_FETCHDIRECTION, rValue);
- break;
- case PROPERTY_ID_FETCHSIZE:
- xSet->setPropertyValue(PROPERTY_FETCHSIZE, rValue);
- break;
- default:
- DBG_ERROR("unknown Property");
- }
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getFastPropertyValue" );
- switch (nHandle)
- {
- case PROPERTY_ID_ISBOOKMARKABLE:
- {
- sal_Bool bVal = m_bIsBookmarkable;
- rValue.setValue(&bVal, getBooleanCppuType());
- } break;
- default:
- {
- // get the property name
- ::rtl::OUString aPropName;
- sal_Int16 nAttributes;
- const_cast<OResultSet*>(this)->getInfoHelper().
- fillPropertyMembersByHandle(&aPropName, &nAttributes, nHandle);
- OSL_ENSURE(aPropName.getLength(), "property not found?");
-
- // now read the value
- rValue = Reference< XPropertySet >(m_xDelegatorResultSet, UNO_QUERY)->getPropertyValue(aPropName);
- }
- }
-}
-
-// XWarningsSupplier
-//------------------------------------------------------------------------------
-Any OResultSet::getWarnings(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getWarnings" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
- return m_aWarnings.getWarnings();
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::clearWarnings(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::clearWarnings" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
- m_aWarnings.clearWarnings();
-}
-
-// ::com::sun::star::sdbc::XResultSetMetaDataSupplier
-//------------------------------------------------------------------------------
-Reference< XResultSetMetaData > OResultSet::getMetaData(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getMetaData" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return Reference< XResultSetMetaDataSupplier >(m_xDelegatorResultSet, UNO_QUERY)->getMetaData();
-}
-
-// ::com::sun::star::sdbc::XColumnLocate
-//------------------------------------------------------------------------------
-sal_Int32 OResultSet::findColumn(const rtl::OUString& columnName) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::findColumn" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return Reference< XColumnLocate >(m_xDelegatorResultSet, UNO_QUERY)->findColumn(columnName);
-}
-
-//------------------------------------------------------------------------------
-namespace
-{
- static Reference< XDatabaseMetaData > lcl_getDBMetaDataFromStatement_nothrow( const Reference< XInterface >& _rxStatement )
- {
- Reference< XDatabaseMetaData > xDBMetaData;
- try
- {
- Reference< XStatement > xStatement( _rxStatement, UNO_QUERY );
- Reference< XPreparedStatement > xPreparedStatement( _rxStatement, UNO_QUERY );
- Reference< XConnection > xConn;
- if ( xStatement.is() )
- xConn = xStatement->getConnection();
- else if ( xPreparedStatement.is() )
- xConn = xPreparedStatement->getConnection();
- if ( xConn.is() )
- xDBMetaData = xConn->getMetaData();
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- return xDBMetaData;
- }
-}
-// ::com::sun::star::sdbcx::XColumnsSupplier
-//------------------------------------------------------------------------------
-Reference< ::com::sun::star::container::XNameAccess > OResultSet::getColumns(void) throw( RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getColumns" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- // do we have to populate the columns
- if (!m_pColumns->isInitialized())
- {
- // get the metadata
- Reference< XResultSetMetaData > xMetaData = Reference< XResultSetMetaDataSupplier >(m_xDelegatorResultSet, UNO_QUERY)->getMetaData();
-
- sal_Int32 nColCount = 0;
- // do we have columns
- try
- {
- Reference< XDatabaseMetaData > xDBMetaData( lcl_getDBMetaDataFromStatement_nothrow( getStatement() ) );
- nColCount = xMetaData->getColumnCount();
-
- for ( sal_Int32 i = 0; i < nColCount; ++i)
- {
- // retrieve the name of the column
- rtl::OUString sName = xMetaData->getColumnName(i + 1);
- ODataColumn* pColumn = new ODataColumn(xMetaData, m_xDelegatorRow, m_xDelegatorRowUpdate, i + 1, xDBMetaData);
-
- // don't silently assume that the name is unique - result set implementations
- // are allowed to return duplicate names, but we are required to have
- // unique column names
- if ( m_pColumns->hasByName( sName ) )
- sName = ::dbtools::createUniqueName( m_pColumns, sName );
-
- m_pColumns->append( sName, pColumn );
- }
- }
- catch ( const SQLException& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- m_pColumns->setInitialized();
-
- #if OSL_DEBUG_LEVEL > 0
- // some sanity checks. Especially in case we auto-adjusted the column names above,
- // this might be reasonable
- try
- {
- const Reference< XNameAccess > xColNames( static_cast< XNameAccess* >( m_pColumns ), UNO_SET_THROW );
- const Sequence< ::rtl::OUString > aNames( xColNames->getElementNames() );
- OSL_POSTCOND( aNames.getLength() == nColCount,
- "OResultSet::getColumns: invalid column count!" );
- for ( const ::rtl::OUString* pName = aNames.getConstArray();
- pName != aNames.getConstArray() + aNames.getLength();
- ++pName
- )
- {
- Reference< XPropertySet > xColProps( xColNames->getByName( *pName ), UNO_QUERY_THROW );
- ::rtl::OUString sName;
- OSL_VERIFY( xColProps->getPropertyValue( PROPERTY_NAME ) >>= sName );
- OSL_POSTCOND( sName == *pName, "OResultSet::getColumns: invalid column name!" );
- }
-
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- #endif
- }
- return m_pColumns;
-}
-
-// ::com::sun::star::sdbc::XRow
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::wasNull(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::wasNull" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->wasNull();
-}
-//------------------------------------------------------------------------------
-rtl::OUString OResultSet::getString(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getString" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getString(columnIndex);
-}
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::getBoolean(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBoolean" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getBoolean(columnIndex);
-}
-//------------------------------------------------------------------------------
-sal_Int8 OResultSet::getByte(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getByte" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getByte(columnIndex);
-}
-//------------------------------------------------------------------------------
-sal_Int16 OResultSet::getShort(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getShort" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getShort(columnIndex);
-}
-//------------------------------------------------------------------------------
-sal_Int32 OResultSet::getInt(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getInt" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getInt(columnIndex);
-}
-//------------------------------------------------------------------------------
-sal_Int64 OResultSet::getLong(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getLong" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getLong(columnIndex);
-}
-//------------------------------------------------------------------------------
-float OResultSet::getFloat(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getFloat" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getFloat(columnIndex);
-}
-//------------------------------------------------------------------------------
-double OResultSet::getDouble(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getDouble" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getDouble(columnIndex);
-}
-//------------------------------------------------------------------------------
-Sequence< sal_Int8 > OResultSet::getBytes(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBytes" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getBytes(columnIndex);
-}
-//------------------------------------------------------------------------------
-::com::sun::star::util::Date OResultSet::getDate(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getDate" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getDate(columnIndex);
-}
-//------------------------------------------------------------------------------
-::com::sun::star::util::Time OResultSet::getTime(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getTime" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getTime(columnIndex);
-}
-//------------------------------------------------------------------------------
-::com::sun::star::util::DateTime OResultSet::getTimestamp(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getTimestamp" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getTimestamp(columnIndex);
-}
-//------------------------------------------------------------------------------
-Reference< ::com::sun::star::io::XInputStream > OResultSet::getBinaryStream(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBinaryStream" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getBinaryStream(columnIndex);
-}
-//------------------------------------------------------------------------------
-Reference< ::com::sun::star::io::XInputStream > OResultSet::getCharacterStream(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getCharacterStream" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getCharacterStream(columnIndex);
-}
-//------------------------------------------------------------------------------
-Any OResultSet::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", "OResultSet::getObject" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getObject(columnIndex, typeMap);
-}
-//------------------------------------------------------------------------------
-Reference< XRef > OResultSet::getRef(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getRef" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getRef(columnIndex);
-}
-//------------------------------------------------------------------------------
-Reference< XBlob > OResultSet::getBlob(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBlob" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getBlob(columnIndex);
-}
-//------------------------------------------------------------------------------
-Reference< XClob > OResultSet::getClob(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getClob" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getClob(columnIndex);
-}
-//------------------------------------------------------------------------------
-Reference< XArray > OResultSet::getArray(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getArray" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorRow->getArray(columnIndex);
-}
-
-// ::com::sun::star::sdbc::XRowUpdate
-//------------------------------------------------------------------------------
-void OResultSet::updateNull(sal_Int32 columnIndex) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateNull" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateNull(columnIndex);
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::updateBoolean(sal_Int32 columnIndex, sal_Bool x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateBoolean" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateBoolean(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateByte(sal_Int32 columnIndex, sal_Int8 x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateByte" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateByte(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateShort(sal_Int32 columnIndex, sal_Int16 x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateShort" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateShort(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateInt(sal_Int32 columnIndex, sal_Int32 x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateInt" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateInt(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateLong(sal_Int32 columnIndex, sal_Int64 x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateLong" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateLong(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateFloat(sal_Int32 columnIndex, float x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateFloat" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateFloat(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateDouble(sal_Int32 columnIndex, double x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateDouble" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateDouble(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateString(sal_Int32 columnIndex, const rtl::OUString& x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateString" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateString(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateBytes(sal_Int32 columnIndex, const Sequence< sal_Int8 >& x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateBytes" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateBytes(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateDate(sal_Int32 columnIndex, const ::com::sun::star::util::Date& x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateDate" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateDate(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateTime(sal_Int32 columnIndex, const ::com::sun::star::util::Time& x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateTime" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateTime(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateTimestamp(sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateTimestamp" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateTimestamp(columnIndex, x);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateBinaryStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateBinaryStream" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateBinaryStream(columnIndex, x, length);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateCharacterStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateCharacterStream" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateCharacterStream(columnIndex, x, length);
-}
-//------------------------------------------------------------------------------
-void OResultSet::updateNumericObject(sal_Int32 columnIndex, const Any& x, sal_Int32 scale) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateNumericObject" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateNumericObject(columnIndex, x, scale);
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::updateObject(sal_Int32 columnIndex, const Any& x) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateObject" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorRowUpdate->updateObject(columnIndex, x);
-}
-
-// ::com::sun::star::sdbc::XResultSet
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::next(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::next" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->next();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::isBeforeFirst(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::isBeforeFirst" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->isBeforeFirst();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::isAfterLast(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::isAfterLast" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->isAfterLast();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::isFirst(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::isFirst" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->isFirst();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::isLast(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::isLast" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->isLast();
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::beforeFirst(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::beforeFirst" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- m_xDelegatorResultSet->beforeFirst();
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::afterLast(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::afterLast" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- m_xDelegatorResultSet->afterLast();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::first(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::first" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->first();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::last(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::last" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->last();
-}
-
-//------------------------------------------------------------------------------
-sal_Int32 OResultSet::getRow(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getRow" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->getRow();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::absolute(sal_Int32 row) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::absolute" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->absolute(row);
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::relative(sal_Int32 rows) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::relative" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->relative(rows);
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::previous(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::previous" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->previous();
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::refreshRow(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::refreshRow" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- m_xDelegatorResultSet->refreshRow();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::rowUpdated(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::rowUpdated" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->rowUpdated();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::rowInserted(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::rowInserted" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->rowInserted();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::rowDeleted(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::rowDeleted" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_xDelegatorResultSet->rowDeleted();
-}
-
-//------------------------------------------------------------------------------
-Reference< XInterface > OResultSet::getStatement(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getStatement" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- return m_aStatement;
-}
-
-// ::com::sun::star::sdbcx::XRowLocate
-//------------------------------------------------------------------------------
-Any OResultSet::getBookmark(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBookmark" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkBookmarkable();
-
- return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->getBookmark();
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::moveToBookmark(const Any& bookmark) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::moveToBookmark" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkBookmarkable();
-
- return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->moveToBookmark(bookmark);
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::moveRelativeToBookmark" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkBookmarkable();
-
- return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->moveRelativeToBookmark(bookmark, rows);
-}
-
-//------------------------------------------------------------------------------
-sal_Int32 OResultSet::compareBookmarks(const Any& _first, const Any& _second) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::compareBookmarks" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkBookmarkable();
-
- return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->compareBookmarks(_first, _second);
-}
-
-//------------------------------------------------------------------------------
-sal_Bool OResultSet::hasOrderedBookmarks(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::hasOrderedBookmarks" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkBookmarkable();
-
- return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->hasOrderedBookmarks();
-}
-
-//------------------------------------------------------------------------------
-sal_Int32 OResultSet::hashBookmark(const Any& bookmark) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::hashBookmark" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkBookmarkable();
-
- return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->hashBookmark(bookmark);
-}
-
-// ::com::sun::star::sdbc::XResultSetUpdate
-//------------------------------------------------------------------------------
-void OResultSet::insertRow(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::insertRow" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorResultSetUpdate->insertRow();
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::updateRow(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateRow" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorResultSetUpdate->updateRow();
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::deleteRow(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::deleteRow" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorResultSetUpdate->deleteRow();
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::cancelRowUpdates(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::cancelRowUpdates" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorResultSetUpdate->cancelRowUpdates();
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::moveToInsertRow(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::moveToInsertRow" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorResultSetUpdate->moveToInsertRow();
-}
-
-//------------------------------------------------------------------------------
-void OResultSet::moveToCurrentRow(void) throw( SQLException, RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::moveToCurrentRow" );
- MutexGuard aGuard(m_aMutex);
- ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
-
- checkReadOnly();
-
- m_xDelegatorResultSetUpdate->moveToCurrentRow();
-}
-
-// -----------------------------------------------------------------------------
-void OResultSet::checkReadOnly() const
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::checkReadOnly" );
- if ( ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY )
- || !m_xDelegatorResultSetUpdate.is()
- )
- throwSQLException( "The result set is read-only.", SQL_GENERAL_ERROR, *const_cast< OResultSet* >( this ) );
-}
-
-// -----------------------------------------------------------------------------
-void OResultSet::checkBookmarkable() const
-{
- //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::checkBookmarkable" );
- if ( !m_bIsBookmarkable )
- throwSQLException( "The result set does not have bookmark support.", SQL_GENERAL_ERROR, *const_cast< OResultSet* >( this ) );
-}
-// -----------------------------------------------------------------------------
-
+/************************************************************************* + * + * 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: resultset.cxx,v $ + * $Revision: 1.21 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" +#ifndef _DBA_COREAPI_RESULTSET_HXX_ +#include <resultset.hxx> +#endif +#ifndef DBACCESS_SHARED_DBASTRINGS_HRC +#include "dbastrings.hrc" +#endif +#ifndef _DBASHARED_APITOOLS_HXX_ +#include "apitools.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_RESULTSETTYPE_HPP_ +#include <com/sun/star/sdbc/ResultSetType.hpp> +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _COMPHELPER_PROPERTY_HXX_ +#include <comphelper/property.hxx> +#endif +#ifndef _COMPHELPER_SEQUENCE_HXX_ +#include <comphelper/sequence.hxx> +#endif +#ifndef _COMPHELPER_TYPES_HXX_ +#include <comphelper/types.hxx> +#endif +#ifndef _TOOLS_DEBUG_HXX //autogen +#include <tools/debug.hxx> +#endif +#ifndef TOOLS_DIAGNOSE_EX_H +#include <tools/diagnose_ex.h> +#endif +#ifndef _DBA_COREAPI_DATACOLUMN_HXX_ +#include <datacolumn.hxx> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +#include <com/sun/star/beans/PropertyAttribute.hpp> +#endif +#ifndef _DBHELPER_DBEXCEPTION_HXX_ +#include <connectivity/dbexception.hxx> +#endif +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include <connectivity/dbtools.hxx> +#endif +#ifndef _CPPUHELPER_EXC_HLP_HXX_ +#include <cppuhelper/exc_hlp.hxx> +#endif +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif +#include <rtl/logfile.hxx> + + +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdbcx; +//using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::container; +using namespace ::cppu; +using namespace ::osl; +using namespace dbaccess; +using namespace dbtools; + +DBG_NAME(OResultSet) + +//-------------------------------------------------------------------------- +OResultSet::OResultSet(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& _xResultSet, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xStatement, + sal_Bool _bCaseSensitive) + :OResultSetBase(m_aMutex) + ,OPropertySetHelper(OResultSetBase::rBHelper) + ,m_xDelegatorResultSet(_xResultSet) + ,m_aWarnings( Reference< XWarningsSupplier >( _xResultSet, UNO_QUERY ) ) + ,m_bIsBookmarkable(sal_False) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::OResultSet" ); + DBG_CTOR(OResultSet, NULL); + + m_pColumns = new OColumns(*this, m_aMutex, _bCaseSensitive, ::std::vector< ::rtl::OUString>(), NULL,NULL); + + try + { + m_aStatement = _xStatement; + m_xDelegatorResultSetUpdate = m_xDelegatorResultSetUpdate.query( m_xDelegatorResultSet ); + m_xDelegatorRow = m_xDelegatorRow.query( m_xDelegatorResultSet ); + m_xDelegatorRowUpdate = m_xDelegatorRowUpdate.query( m_xDelegatorResultSet ); + + Reference< XPropertySet > xSet(m_xDelegatorResultSet, UNO_QUERY); + xSet->getPropertyValue(PROPERTY_RESULTSETTYPE) >>= m_nResultSetType; + xSet->getPropertyValue(PROPERTY_RESULTSETCONCURRENCY) >>= m_nResultSetConcurrency; + + // test for Bookmarks + if (ResultSetType::FORWARD_ONLY != m_nResultSetType) + { + Reference <XPropertySetInfo > xInfo(xSet->getPropertySetInfo()); + if (xInfo->hasPropertyByName(PROPERTY_ISBOOKMARKABLE)) + { + m_bIsBookmarkable = ::comphelper::getBOOL(xSet->getPropertyValue(PROPERTY_ISBOOKMARKABLE)); + OSL_ENSURE( !m_bIsBookmarkable || Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY).is(), + "OResultSet::OResultSet: aggregate is inconsistent in it's bookmarkable attribute!" ); + m_bIsBookmarkable = m_bIsBookmarkable && Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY).is(); + } + } + } + catch(Exception&) + { + } +} + +//-------------------------------------------------------------------------- +OResultSet::~OResultSet() +{ + m_pColumns->acquire(); + m_pColumns->disposing(); + delete m_pColumns; + + DBG_DTOR(OResultSet, NULL); +} + +// com::sun::star::lang::XTypeProvider +//-------------------------------------------------------------------------- +Sequence< Type > OResultSet::getTypes() throw (RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getTypes" ); + OTypeCollection aTypes(::getCppuType( (const Reference< XPropertySet > *)0 ), + OResultSetBase::getTypes()); + + return aTypes.getTypes(); +} + +//-------------------------------------------------------------------------- +Sequence< sal_Int8 > OResultSet::getImplementationId() throw (RuntimeException) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getImplementationId" ); + static OImplementationId * pId = 0; + if (! pId) + { + MutexGuard aGuard( Mutex::getGlobalMutex() ); + if (! pId) + { + static OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +// com::sun::star::uno::XInterface +//-------------------------------------------------------------------------- +Any OResultSet::queryInterface( const Type & rType ) throw (RuntimeException) +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::queryInterface" ); + Any aIface = OResultSetBase::queryInterface( rType ); + if (!aIface.hasValue()) + aIface = ::cppu::queryInterface( + rType, + static_cast< XPropertySet * >( this )); + + return aIface; +} + +//-------------------------------------------------------------------------- +void OResultSet::acquire() throw () +{ + OResultSetBase::acquire(); +} + +//-------------------------------------------------------------------------- +void OResultSet::release() throw () +{ + OResultSetBase::release(); +} + + +// OResultSetBase +//------------------------------------------------------------------------------ +void OResultSet::disposing() +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::disposing" ); + OPropertySetHelper::disposing(); + + MutexGuard aGuard(m_aMutex); + + // free the columns + m_pColumns->disposing(); + + // close the pending result set + Reference< XCloseable > (m_xDelegatorResultSet, UNO_QUERY)->close(); + + m_xDelegatorResultSet = NULL; + m_xDelegatorRow = NULL; + m_xDelegatorRowUpdate = NULL; + + m_aStatement = Reference< XInterface >(); +} + +// XCloseable +//------------------------------------------------------------------------------ +void OResultSet::close(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::close" ); + { + MutexGuard aGuard( m_aMutex ); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + } + dispose(); +} + +// XServiceInfo +//------------------------------------------------------------------------------ +rtl::OUString OResultSet::getImplementationName( ) throw(RuntimeException) +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getImplementationName" ); + return rtl::OUString::createFromAscii("com.sun.star.sdb.OResultSet"); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException) +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::supportsService" ); + return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0; +} + +//------------------------------------------------------------------------------ +Sequence< ::rtl::OUString > OResultSet::getSupportedServiceNames( ) throw (RuntimeException) +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getSupportedServiceNames" ); + Sequence< ::rtl::OUString > aSNS( 2 ); + aSNS[0] = SERVICE_SDBC_RESULTSET; + aSNS[1] = SERVICE_SDB_RESULTSET; + return aSNS; +} + +// com::sun::star::beans::XPropertySet +//------------------------------------------------------------------------------ +Reference< XPropertySetInfo > OResultSet::getPropertySetInfo() throw (RuntimeException) +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getPropertySetInfo" ); + return createPropertySetInfo( getInfoHelper() ) ; +} + +// comphelper::OPropertyArrayUsageHelper +//------------------------------------------------------------------------------ +::cppu::IPropertyArrayHelper* OResultSet::createArrayHelper( ) const +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::createArrayHelper" ); + BEGIN_PROPERTY_HELPER(6) + DECL_PROP1(CURSORNAME, ::rtl::OUString, READONLY); + DECL_PROP0(FETCHDIRECTION, sal_Int32); + DECL_PROP0(FETCHSIZE, sal_Int32); + DECL_PROP1_BOOL(ISBOOKMARKABLE, READONLY); + DECL_PROP1(RESULTSETCONCURRENCY, sal_Int32, READONLY); + DECL_PROP1(RESULTSETTYPE, sal_Int32, READONLY); + END_PROPERTY_HELPER(); +} + +// cppu::OPropertySetHelper +//------------------------------------------------------------------------------ +::cppu::IPropertyArrayHelper& OResultSet::getInfoHelper() +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getInfoHelper" ); + return *getArrayHelper(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::convertFastPropertyValue(Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue ) throw( IllegalArgumentException ) +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::convertFastPropertyValue" ); + // be lazy ... + rConvertedValue = rValue; + getFastPropertyValue( rOldValue, nHandle ); + return sal_True; +} + +//------------------------------------------------------------------------------ +void OResultSet::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception) +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::setFastPropertyValue_NoBroadcast" ); + // set it for the driver result set + Reference< XPropertySet > xSet(m_xDelegatorResultSet, UNO_QUERY); + switch (nHandle) + { + case PROPERTY_ID_FETCHDIRECTION: + xSet->setPropertyValue(PROPERTY_FETCHDIRECTION, rValue); + break; + case PROPERTY_ID_FETCHSIZE: + xSet->setPropertyValue(PROPERTY_FETCHSIZE, rValue); + break; + default: + DBG_ERROR("unknown Property"); + } +} + +//------------------------------------------------------------------------------ +void OResultSet::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getFastPropertyValue" ); + switch (nHandle) + { + case PROPERTY_ID_ISBOOKMARKABLE: + { + sal_Bool bVal = m_bIsBookmarkable; + rValue.setValue(&bVal, getBooleanCppuType()); + } break; + default: + { + // get the property name + ::rtl::OUString aPropName; + sal_Int16 nAttributes; + const_cast<OResultSet*>(this)->getInfoHelper(). + fillPropertyMembersByHandle(&aPropName, &nAttributes, nHandle); + OSL_ENSURE(aPropName.getLength(), "property not found?"); + + // now read the value + rValue = Reference< XPropertySet >(m_xDelegatorResultSet, UNO_QUERY)->getPropertyValue(aPropName); + } + } +} + +// XWarningsSupplier +//------------------------------------------------------------------------------ +Any OResultSet::getWarnings(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getWarnings" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + return m_aWarnings.getWarnings(); +} + +//------------------------------------------------------------------------------ +void OResultSet::clearWarnings(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::clearWarnings" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + m_aWarnings.clearWarnings(); +} + +// ::com::sun::star::sdbc::XResultSetMetaDataSupplier +//------------------------------------------------------------------------------ +Reference< XResultSetMetaData > OResultSet::getMetaData(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getMetaData" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return Reference< XResultSetMetaDataSupplier >(m_xDelegatorResultSet, UNO_QUERY)->getMetaData(); +} + +// ::com::sun::star::sdbc::XColumnLocate +//------------------------------------------------------------------------------ +sal_Int32 OResultSet::findColumn(const rtl::OUString& columnName) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::findColumn" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return Reference< XColumnLocate >(m_xDelegatorResultSet, UNO_QUERY)->findColumn(columnName); +} + +//------------------------------------------------------------------------------ +namespace +{ + static Reference< XDatabaseMetaData > lcl_getDBMetaDataFromStatement_nothrow( const Reference< XInterface >& _rxStatement ) + { + Reference< XDatabaseMetaData > xDBMetaData; + try + { + Reference< XStatement > xStatement( _rxStatement, UNO_QUERY ); + Reference< XPreparedStatement > xPreparedStatement( _rxStatement, UNO_QUERY ); + Reference< XConnection > xConn; + if ( xStatement.is() ) + xConn = xStatement->getConnection(); + else if ( xPreparedStatement.is() ) + xConn = xPreparedStatement->getConnection(); + if ( xConn.is() ) + xDBMetaData = xConn->getMetaData(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return xDBMetaData; + } +} +// ::com::sun::star::sdbcx::XColumnsSupplier +//------------------------------------------------------------------------------ +Reference< ::com::sun::star::container::XNameAccess > OResultSet::getColumns(void) throw( RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getColumns" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + // do we have to populate the columns + if (!m_pColumns->isInitialized()) + { + // get the metadata + Reference< XResultSetMetaData > xMetaData = Reference< XResultSetMetaDataSupplier >(m_xDelegatorResultSet, UNO_QUERY)->getMetaData(); + + sal_Int32 nColCount = 0; + // do we have columns + try + { + Reference< XDatabaseMetaData > xDBMetaData( lcl_getDBMetaDataFromStatement_nothrow( getStatement() ) ); + nColCount = xMetaData->getColumnCount(); + + for ( sal_Int32 i = 0; i < nColCount; ++i) + { + // retrieve the name of the column + rtl::OUString sName = xMetaData->getColumnName(i + 1); + ODataColumn* pColumn = new ODataColumn(xMetaData, m_xDelegatorRow, m_xDelegatorRowUpdate, i + 1, xDBMetaData); + + // don't silently assume that the name is unique - result set implementations + // are allowed to return duplicate names, but we are required to have + // unique column names + if ( m_pColumns->hasByName( sName ) ) + sName = ::dbtools::createUniqueName( m_pColumns, sName ); + + m_pColumns->append( sName, pColumn ); + } + } + catch ( const SQLException& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + m_pColumns->setInitialized(); + + #if OSL_DEBUG_LEVEL > 0 + // some sanity checks. Especially in case we auto-adjusted the column names above, + // this might be reasonable + try + { + const Reference< XNameAccess > xColNames( static_cast< XNameAccess* >( m_pColumns ), UNO_SET_THROW ); + const Sequence< ::rtl::OUString > aNames( xColNames->getElementNames() ); + OSL_POSTCOND( aNames.getLength() == nColCount, + "OResultSet::getColumns: invalid column count!" ); + for ( const ::rtl::OUString* pName = aNames.getConstArray(); + pName != aNames.getConstArray() + aNames.getLength(); + ++pName + ) + { + Reference< XPropertySet > xColProps( xColNames->getByName( *pName ), UNO_QUERY_THROW ); + ::rtl::OUString sName; + OSL_VERIFY( xColProps->getPropertyValue( PROPERTY_NAME ) >>= sName ); + OSL_POSTCOND( sName == *pName, "OResultSet::getColumns: invalid column name!" ); + } + + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + #endif + } + return m_pColumns; +} + +// ::com::sun::star::sdbc::XRow +//------------------------------------------------------------------------------ +sal_Bool OResultSet::wasNull(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::wasNull" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->wasNull(); +} +//------------------------------------------------------------------------------ +rtl::OUString OResultSet::getString(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getString" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getString(columnIndex); +} +//------------------------------------------------------------------------------ +sal_Bool OResultSet::getBoolean(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBoolean" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getBoolean(columnIndex); +} +//------------------------------------------------------------------------------ +sal_Int8 OResultSet::getByte(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getByte" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getByte(columnIndex); +} +//------------------------------------------------------------------------------ +sal_Int16 OResultSet::getShort(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getShort" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getShort(columnIndex); +} +//------------------------------------------------------------------------------ +sal_Int32 OResultSet::getInt(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getInt" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getInt(columnIndex); +} +//------------------------------------------------------------------------------ +sal_Int64 OResultSet::getLong(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getLong" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getLong(columnIndex); +} +//------------------------------------------------------------------------------ +float OResultSet::getFloat(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getFloat" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getFloat(columnIndex); +} +//------------------------------------------------------------------------------ +double OResultSet::getDouble(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getDouble" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getDouble(columnIndex); +} +//------------------------------------------------------------------------------ +Sequence< sal_Int8 > OResultSet::getBytes(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBytes" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getBytes(columnIndex); +} +//------------------------------------------------------------------------------ +::com::sun::star::util::Date OResultSet::getDate(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getDate" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getDate(columnIndex); +} +//------------------------------------------------------------------------------ +::com::sun::star::util::Time OResultSet::getTime(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getTime" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getTime(columnIndex); +} +//------------------------------------------------------------------------------ +::com::sun::star::util::DateTime OResultSet::getTimestamp(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getTimestamp" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getTimestamp(columnIndex); +} +//------------------------------------------------------------------------------ +Reference< ::com::sun::star::io::XInputStream > OResultSet::getBinaryStream(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBinaryStream" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getBinaryStream(columnIndex); +} +//------------------------------------------------------------------------------ +Reference< ::com::sun::star::io::XInputStream > OResultSet::getCharacterStream(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getCharacterStream" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getCharacterStream(columnIndex); +} +//------------------------------------------------------------------------------ +Any OResultSet::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", "OResultSet::getObject" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getObject(columnIndex, typeMap); +} +//------------------------------------------------------------------------------ +Reference< XRef > OResultSet::getRef(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getRef" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getRef(columnIndex); +} +//------------------------------------------------------------------------------ +Reference< XBlob > OResultSet::getBlob(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBlob" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getBlob(columnIndex); +} +//------------------------------------------------------------------------------ +Reference< XClob > OResultSet::getClob(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getClob" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getClob(columnIndex); +} +//------------------------------------------------------------------------------ +Reference< XArray > OResultSet::getArray(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getArray" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorRow->getArray(columnIndex); +} + +// ::com::sun::star::sdbc::XRowUpdate +//------------------------------------------------------------------------------ +void OResultSet::updateNull(sal_Int32 columnIndex) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateNull" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateNull(columnIndex); +} + +//------------------------------------------------------------------------------ +void OResultSet::updateBoolean(sal_Int32 columnIndex, sal_Bool x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateBoolean" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateBoolean(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateByte(sal_Int32 columnIndex, sal_Int8 x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateByte" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateByte(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateShort(sal_Int32 columnIndex, sal_Int16 x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateShort" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateShort(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateInt(sal_Int32 columnIndex, sal_Int32 x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateInt" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateInt(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateLong(sal_Int32 columnIndex, sal_Int64 x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateLong" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateLong(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateFloat(sal_Int32 columnIndex, float x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateFloat" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateFloat(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateDouble(sal_Int32 columnIndex, double x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateDouble" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateDouble(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateString(sal_Int32 columnIndex, const rtl::OUString& x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateString" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateString(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateBytes(sal_Int32 columnIndex, const Sequence< sal_Int8 >& x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateBytes" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateBytes(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateDate(sal_Int32 columnIndex, const ::com::sun::star::util::Date& x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateDate" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateDate(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateTime(sal_Int32 columnIndex, const ::com::sun::star::util::Time& x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateTime" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateTime(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateTimestamp(sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateTimestamp" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateTimestamp(columnIndex, x); +} +//------------------------------------------------------------------------------ +void OResultSet::updateBinaryStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateBinaryStream" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateBinaryStream(columnIndex, x, length); +} +//------------------------------------------------------------------------------ +void OResultSet::updateCharacterStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateCharacterStream" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateCharacterStream(columnIndex, x, length); +} +//------------------------------------------------------------------------------ +void OResultSet::updateNumericObject(sal_Int32 columnIndex, const Any& x, sal_Int32 scale) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateNumericObject" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateNumericObject(columnIndex, x, scale); +} + +//------------------------------------------------------------------------------ +void OResultSet::updateObject(sal_Int32 columnIndex, const Any& x) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateObject" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorRowUpdate->updateObject(columnIndex, x); +} + +// ::com::sun::star::sdbc::XResultSet +//------------------------------------------------------------------------------ +sal_Bool OResultSet::next(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::next" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->next(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::isBeforeFirst(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::isBeforeFirst" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->isBeforeFirst(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::isAfterLast(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::isAfterLast" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->isAfterLast(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::isFirst(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::isFirst" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->isFirst(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::isLast(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::isLast" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->isLast(); +} + +//------------------------------------------------------------------------------ +void OResultSet::beforeFirst(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::beforeFirst" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + m_xDelegatorResultSet->beforeFirst(); +} + +//------------------------------------------------------------------------------ +void OResultSet::afterLast(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::afterLast" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + m_xDelegatorResultSet->afterLast(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::first(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::first" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->first(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::last(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::last" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->last(); +} + +//------------------------------------------------------------------------------ +sal_Int32 OResultSet::getRow(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getRow" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->getRow(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::absolute(sal_Int32 row) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::absolute" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->absolute(row); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::relative(sal_Int32 rows) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::relative" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->relative(rows); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::previous(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::previous" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->previous(); +} + +//------------------------------------------------------------------------------ +void OResultSet::refreshRow(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::refreshRow" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + m_xDelegatorResultSet->refreshRow(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::rowUpdated(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::rowUpdated" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->rowUpdated(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::rowInserted(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::rowInserted" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->rowInserted(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::rowDeleted(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::rowDeleted" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_xDelegatorResultSet->rowDeleted(); +} + +//------------------------------------------------------------------------------ +Reference< XInterface > OResultSet::getStatement(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getStatement" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + return m_aStatement; +} + +// ::com::sun::star::sdbcx::XRowLocate +//------------------------------------------------------------------------------ +Any OResultSet::getBookmark(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::getBookmark" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkBookmarkable(); + + return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->getBookmark(); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::moveToBookmark(const Any& bookmark) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::moveToBookmark" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkBookmarkable(); + + return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->moveToBookmark(bookmark); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::moveRelativeToBookmark" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkBookmarkable(); + + return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->moveRelativeToBookmark(bookmark, rows); +} + +//------------------------------------------------------------------------------ +sal_Int32 OResultSet::compareBookmarks(const Any& _first, const Any& _second) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::compareBookmarks" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkBookmarkable(); + + return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->compareBookmarks(_first, _second); +} + +//------------------------------------------------------------------------------ +sal_Bool OResultSet::hasOrderedBookmarks(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::hasOrderedBookmarks" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkBookmarkable(); + + return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->hasOrderedBookmarks(); +} + +//------------------------------------------------------------------------------ +sal_Int32 OResultSet::hashBookmark(const Any& bookmark) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::hashBookmark" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkBookmarkable(); + + return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->hashBookmark(bookmark); +} + +// ::com::sun::star::sdbc::XResultSetUpdate +//------------------------------------------------------------------------------ +void OResultSet::insertRow(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::insertRow" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorResultSetUpdate->insertRow(); +} + +//------------------------------------------------------------------------------ +void OResultSet::updateRow(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::updateRow" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorResultSetUpdate->updateRow(); +} + +//------------------------------------------------------------------------------ +void OResultSet::deleteRow(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::deleteRow" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorResultSetUpdate->deleteRow(); +} + +//------------------------------------------------------------------------------ +void OResultSet::cancelRowUpdates(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::cancelRowUpdates" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorResultSetUpdate->cancelRowUpdates(); +} + +//------------------------------------------------------------------------------ +void OResultSet::moveToInsertRow(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::moveToInsertRow" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorResultSetUpdate->moveToInsertRow(); +} + +//------------------------------------------------------------------------------ +void OResultSet::moveToCurrentRow(void) throw( SQLException, RuntimeException ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::moveToCurrentRow" ); + MutexGuard aGuard(m_aMutex); + ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed); + + checkReadOnly(); + + m_xDelegatorResultSetUpdate->moveToCurrentRow(); +} + +// ----------------------------------------------------------------------------- +void OResultSet::checkReadOnly() const +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::checkReadOnly" ); + if ( ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY ) + || !m_xDelegatorResultSetUpdate.is() + ) + throwSQLException( "The result set is read-only.", SQL_GENERAL_ERROR, *const_cast< OResultSet* >( this ) ); +} + +// ----------------------------------------------------------------------------- +void OResultSet::checkBookmarkable() const +{ + //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OResultSet::checkBookmarkable" ); + if ( !m_bIsBookmarkable ) + throwSQLException( "The result set does not have bookmark support.", SQL_GENERAL_ERROR, *const_cast< OResultSet* >( this ) ); +} +// ----------------------------------------------------------------------------- + diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx index 17848caac41e..23c6a34d7808 100644 --- a/dbaccess/source/core/dataaccess/ModelImpl.cxx +++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx @@ -608,7 +608,8 @@ void ODatabaseModelImpl::clearConnections() aConnections.swap( m_aConnections ); Reference< XConnection > xConn; - for ( OWeakConnectionArray::iterator i = aConnections.begin(); aConnections.end() != i; ++i ) + OWeakConnectionArray::iterator aEnd = aConnections.end(); + for ( OWeakConnectionArray::iterator i = aConnections.begin(); aEnd != i; ++i ) { xConn = *i; if ( xConn.is() ) diff --git a/dbaccess/source/core/dataaccess/connection.cxx b/dbaccess/source/core/dataaccess/connection.cxx index 654fe9696280..8fb40fc63b1f 100644 --- a/dbaccess/source/core/dataaccess/connection.cxx +++ b/dbaccess/source/core/dataaccess/connection.cxx @@ -534,7 +534,8 @@ void OConnection::disposing() OSubComponent::disposing(); OConnectionWrapper::disposing(); - for (OWeakRefArrayIterator i = m_aStatements.begin(); m_aStatements.end() != i; ++i) + OWeakRefArrayIterator aEnd = m_aStatements.end(); + for (OWeakRefArrayIterator i = m_aStatements.begin(); aEnd != i; ++i) { Reference<XComponent> xComp(i->get(),UNO_QUERY); ::comphelper::disposeComponent(xComp); @@ -549,7 +550,8 @@ void OConnection::disposing() ::comphelper::disposeComponent(m_xQueries); - for (OWeakRefArrayIterator j = m_aComposers.begin(); m_aComposers.end() != j; ++j) + OWeakRefArrayIterator aComposerEnd = m_aComposers.end(); + for (OWeakRefArrayIterator j = m_aComposers.begin(); aComposerEnd != j; ++j) { Reference<XComponent> xComp(j->get(),UNO_QUERY); ::comphelper::disposeComponent(xComp); diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx index 9535228b7591..896edc257f1c 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.cxx +++ b/dbaccess/source/core/dataaccess/databasedocument.cxx @@ -1102,7 +1102,8 @@ void ODatabaseDocument::impl_closeControllerFrames_nolck_throw( sal_Bool _bDeliv { Controllers aCopy = m_aControllers; - for ( Controllers::iterator aIter = aCopy.begin(); aIter != aCopy.end() ; ++aIter ) + Controllers::iterator aEnd = aCopy.end(); + for ( Controllers::iterator aIter = aCopy.begin(); aIter != aEnd ; ++aIter ) { if ( !aIter->is() ) continue; diff --git a/dbaccess/source/core/inc/core_resource.hrc b/dbaccess/source/core/inc/core_resource.hrc index e129dc1a66d2..245b90b985b3 100644 --- a/dbaccess/source/core/inc/core_resource.hrc +++ b/dbaccess/source/core/inc/core_resource.hrc @@ -89,8 +89,5 @@ #define RID_STR_NAME_NOT_FOUND ( RID_CORE_STRINGS_START + 45 ) #define RID_STR_QUERY_DOES_NOT_EXIST ( RID_CORE_STRINGS_START + 46 ) -#define RSC_DATASOURCE_TYPES ( RID_CORE_OTHER_START + 1 ) -#define RSC_DATASOURCE_TYPE_UINAMES ( RID_CORE_OTHER_START + 2 ) - #endif // _DBA_CORE_RESOURCE_HRC_ diff --git a/dbaccess/source/core/misc/dsntypes.cxx b/dbaccess/source/core/misc/dsntypes.cxx index 30ec32935cd5..321943a8c1ef 100644 --- a/dbaccess/source/core/misc/dsntypes.cxx +++ b/dbaccess/source/core/misc/dsntypes.cxx @@ -34,18 +34,20 @@ #include "dsntypes.hxx" #include "dbamiscres.hrc" #include <unotools/confignode.hxx> -#include <tools/rc.hxx> #include <tools/debug.hxx> +#include <tools/wldcrd.hxx> #include <osl/file.hxx> #include "dbastrings.hrc" #include "core_resource.hxx" #include "core_resource.hrc" #include <comphelper/documentconstants.hxx> +#include <connectivity/DriversConfig.hxx> //......................................................................... namespace dbaccess { //......................................................................... + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::lang; @@ -61,84 +63,31 @@ namespace dbaccess _nPortNumber = _sUrl.GetToken(1,':').ToInt32(); } } - class ODataSourceTypeStringListResource : public Resource - { - ::std::vector<String> m_aStrings; - public: - ODataSourceTypeStringListResource(USHORT _nResId ) : Resource(ResId(_nResId,*ResourceManager::getResManager())) - { - m_aStrings.reserve(STR_END); - for (int i = STR_MYSQL_ODBC; i < STR_END ; ++i) - { - m_aStrings.push_back(String(DBA_RES(sal::static_int_cast<USHORT>(i)))); - } - - } - ~ODataSourceTypeStringListResource() - { - FreeResource(); - } - /** fill the vector with our readed strings - @param _rToFill - Vector to fill. - */ - inline void fill( ::std::vector<String>& _rToFill ) - { - _rToFill = m_aStrings; - } - }; - - ::rtl::OUString lcl_getUserDefinedDriverNodeName() - { - static ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.DataAccess/UserDefinedDriverSettings")); - return s_sNodeName; - } - // ----------------------------------------------------------------------------- - ::rtl::OUString lcl_getDriverTypeDisplayNodeName() - { - static ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("DriverTypeDisplayName")); - return s_sNodeName; - } - // ----------------------------------------------------------------------------- - ::rtl::OUString lcl_getDriverDsnPrefixNodeName() - { - static ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("DriverDsnPrefix")); - return s_sNodeName; - } - // ----------------------------------------------------------------------------- - ::rtl::OUString lcl_getDriverExtensionNodeName() - { - static ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("Extension")); - return s_sNodeName; - } - } //========================================================================= //= ODsnTypeCollection //========================================================================= DBG_NAME(ODsnTypeCollection) //------------------------------------------------------------------------- -ODsnTypeCollection::ODsnTypeCollection() +ODsnTypeCollection::ODsnTypeCollection(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory) +:m_xFactory(_xFactory) #ifdef DBG_UTIL -:m_nLivingIterators(0) +,m_nLivingIterators(0) #endif { DBG_CTOR(ODsnTypeCollection,NULL); - ODataSourceTypeStringListResource aTypes(RSC_DATASOURCE_TYPES); - aTypes.fill(m_aDsnPrefixes); - - ODataSourceTypeStringListResource aDisplayNames(RSC_DATASOURCE_TYPE_UINAMES); - aDisplayNames.fill(m_aDsnTypesDisplayNames); - + ::connectivity::DriversConfig aDriverConfig(m_xFactory); + const uno::Sequence< ::rtl::OUString > aURLs = aDriverConfig.getURLs(); + const ::rtl::OUString* pIter = aURLs.getConstArray(); + const ::rtl::OUString* pEnd = pIter + aURLs.getLength(); + for(;pIter != pEnd;++pIter ) + { + m_aDsnPrefixes.push_back(*pIter); + m_aDsnTypesDisplayNames.push_back(aDriverConfig.getDriverTypeDisplayName(*pIter)); + } DBG_ASSERT(m_aDsnTypesDisplayNames.size() == m_aDsnPrefixes.size(), "ODsnTypeCollection::ODsnTypeCollection : invalid resources !"); - String sCurrentType; - - for (StringVector::iterator aIter = m_aDsnPrefixes.begin();aIter != m_aDsnPrefixes.end();++aIter) - { - m_aDsnTypes.push_back(implDetermineType(*aIter)); - } } //------------------------------------------------------------------------- @@ -147,302 +96,258 @@ ODsnTypeCollection::~ODsnTypeCollection() DBG_DTOR(ODsnTypeCollection,NULL); DBG_ASSERT(0 == m_nLivingIterators, "ODsnTypeCollection::~ODsnTypeCollection : there are still living iterator objects!"); } -// ----------------------------------------------------------------------------- -void ODsnTypeCollection::initUserDriverTypes(const Reference< XMultiServiceFactory >& _rxORB) +//------------------------------------------------------------------------- +String ODsnTypeCollection::getTypeDisplayName(const ::rtl::OUString& _sURL) const { - // read the user driver out of the configuration - // the config node where all pooling relevant info are stored under - ::utl::OConfigurationTreeRoot aUserDefinedDriverRoot = ::utl::OConfigurationTreeRoot::createWithServiceFactory( - _rxORB, lcl_getUserDefinedDriverNodeName(), -1, ::utl::OConfigurationTreeRoot::CM_READONLY); - - if ( aUserDefinedDriverRoot.isValid() ) + ::connectivity::DriversConfig aDriverConfig(m_xFactory); + return aDriverConfig.getDriverTypeDisplayName(_sURL); +} +//------------------------------------------------------------------------- +String ODsnTypeCollection::cutPrefix(const ::rtl::OUString& _sURL) const +{ + String sURL( _sURL); + String sRet; + String sOldPattern; + StringVector::const_iterator aIter = m_aDsnPrefixes.begin(); + StringVector::const_iterator aEnd = m_aDsnPrefixes.end(); + for(;aIter != aEnd;++aIter) { - Sequence< ::rtl::OUString > aDriverKeys = aUserDefinedDriverRoot.getNodeNames(); - const ::rtl::OUString* pDriverKeys = aDriverKeys.getConstArray(); - const ::rtl::OUString* pDriverKeysEnd = pDriverKeys + aDriverKeys.getLength(); - for (sal_Int32 i=0;pDriverKeys != pDriverKeysEnd && i <= DST_USERDEFINE10; ++pDriverKeys) + WildCard aWildCard(*aIter); + if ( sOldPattern.Len() < aIter->Len() && aWildCard.Matches(_sURL) ) { - ::utl::OConfigurationNode aThisDriverSettings = aUserDefinedDriverRoot.openNode(*pDriverKeys); - if ( aThisDriverSettings.isValid() ) - { - // read the needed information - ::rtl::OUString sDsnPrefix,sDsnTypeDisplayName,sExtension; - aThisDriverSettings.getNodeValue(lcl_getDriverTypeDisplayNodeName()) >>= sDsnTypeDisplayName; - aThisDriverSettings.getNodeValue(lcl_getDriverDsnPrefixNodeName()) >>= sDsnPrefix; - aThisDriverSettings.getNodeValue(lcl_getDriverExtensionNodeName()) >>= sExtension; - - m_aDsnTypesDisplayNames.push_back(sDsnTypeDisplayName); - m_aDsnPrefixes.push_back(sDsnPrefix); - m_aDsnTypes.push_back(static_cast<DATASOURCE_TYPE>(DST_USERDEFINE1 + i++)); - m_aUserExtensions.push_back(sExtension); - } + if ( aIter->Len() < sURL.Len() ) + sRet = sURL.Copy(sURL.Match(*aIter)); + else + sRet = sURL.Copy(aIter->Match(sURL)); + sOldPattern = *aIter; } } -} + return sRet; +} //------------------------------------------------------------------------- -DATASOURCE_TYPE ODsnTypeCollection::getType(const String& _rDsn) const +String ODsnTypeCollection::getPrefix(const ::rtl::OUString& _sURL) const { - DATASOURCE_TYPE eType = DST_UNKNOWN; - // look for user defined driver types + String sURL( _sURL); + String sRet; + String sOldPattern; StringVector::const_iterator aIter = m_aDsnPrefixes.begin(); StringVector::const_iterator aEnd = m_aDsnPrefixes.end(); - for (; aIter != aEnd; ++aIter) + for(;aIter != aEnd;++aIter) { - if ( _rDsn.Len() >= aIter->Len() && aIter->EqualsIgnoreCaseAscii(_rDsn,0, aIter->Len()) ) + WildCard aWildCard(*aIter); + if ( sOldPattern.Len() < aIter->Len() && aWildCard.Matches(sURL) ) { - size_t nPos = (aIter - m_aDsnPrefixes.begin()); - if ( nPos < m_aDsnTypes.size() ) - { - eType = m_aDsnTypes[nPos]; - break; - } + if ( aIter->Len() < sURL.Len() ) + sRet = aIter->Copy(0,sURL.Match(*aIter)); + else + sRet = sURL.Copy(0,aIter->Match(sURL)); + sRet.EraseTrailingChars('*'); + sOldPattern = *aIter; } } - return eType; -} - -//------------------------------------------------------------------------- -String ODsnTypeCollection::getTypeDisplayName(DATASOURCE_TYPE _eType) const -{ - String sDisplayName; - - sal_Int32 nIndex = implDetermineTypeIndex(_eType); - if ((nIndex >= 0) && (nIndex < (sal_Int32)m_aDsnTypesDisplayNames.size())) - sDisplayName = m_aDsnTypesDisplayNames[nIndex]; - return sDisplayName; + return sRet; } - -//------------------------------------------------------------------------- -String ODsnTypeCollection::getDatasourcePrefix(DATASOURCE_TYPE _eType) const +// ----------------------------------------------------------------------------- +bool ODsnTypeCollection::isConnectionUrlRequired(const ::rtl::OUString& _sURL) const { - String sPrefix; - sal_Int32 nIndex = implDetermineTypeIndex(_eType); - if ((nIndex >= 0) && (nIndex < (sal_Int32)m_aDsnPrefixes.size())) - sPrefix = m_aDsnPrefixes[nIndex]; - - return sPrefix; + String sURL( _sURL); + String sRet; + String sOldPattern; + StringVector::const_iterator aIter = m_aDsnPrefixes.begin(); + StringVector::const_iterator aEnd = m_aDsnPrefixes.end(); + for(;aIter != aEnd;++aIter) + { + WildCard aWildCard(*aIter); + if ( sOldPattern.Len() < aIter->Len() && aWildCard.Matches(sURL) ) + { + sRet = *aIter; + sOldPattern = *aIter; + } + } // for(;aIter != aEnd;++aIter) + return sRet.GetChar(sRet.Len()-1) == '*'; } - -//------------------------------------------------------------------------- -String ODsnTypeCollection::cutPrefix(const String& _rDsn) const +// ----------------------------------------------------------------------------- +String ODsnTypeCollection::getMediaType(const ::rtl::OUString& _sURL) const { - DATASOURCE_TYPE eType = getType(_rDsn); - String sPrefix = getDatasourcePrefix(eType); - return _rDsn.Copy(sPrefix.Len()); + ::connectivity::DriversConfig aDriverConfig(m_xFactory); + const ::comphelper::NamedValueCollection& aFeatures = aDriverConfig.getMetaData(_sURL); + return aFeatures.getOrDefault("MediaType",::rtl::OUString()); } // ----------------------------------------------------------------------------- -String ODsnTypeCollection::getMediaType(DATASOURCE_TYPE _eType) const +String ODsnTypeCollection::getDatasourcePrefixFromMediaType(const ::rtl::OUString& _sMediaType,const ::rtl::OUString& _sExtension) { - String sRet; - switch (_eType) + String sURL; + ::connectivity::DriversConfig aDriverConfig(m_xFactory); + const uno::Sequence< ::rtl::OUString > aURLs = aDriverConfig.getURLs(); + const ::rtl::OUString* pIter = aURLs.getConstArray(); + const ::rtl::OUString* pEnd = pIter + aURLs.getLength(); + for(;pIter != pEnd;++pIter ) { - case DST_DBASE: - sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("application/dbase")); - break; - case DST_FLAT: - sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("text/csv")); - break; - case DST_CALC: - sRet = MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET; - break; - case DST_MSACCESS: - case DST_MSACCESS_2007: - sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("application/msaccess")); - break; - default: - break; - } - return sRet; + const ::comphelper::NamedValueCollection& aFeatures = aDriverConfig.getMetaData(*pIter); + if ( aFeatures.getOrDefault("MediaType",::rtl::OUString()) == _sMediaType ) + { + const ::rtl::OUString sFileExtension = aFeatures.getOrDefault("Extension",::rtl::OUString()); + if ( (sFileExtension.getLength() && _sExtension == sFileExtension ) || !sFileExtension.getLength() || !_sExtension.getLength() ) + { + sURL = *pIter; + break; + } + } + } // for(;pIter != pEnd;++pIter ) + sURL.EraseTrailingChars('*'); + return sURL; +} +// ----------------------------------------------------------------------------- +bool ODsnTypeCollection::isShowPropertiesEnabled( const ::rtl::OUString& _sURL ) const +{ + return !( _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:embedded:hsqldb",sizeof("sdbc:embedded:hsqldb")-1) + || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:outlook",sizeof("sdbc:address:outlook")-1) + || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:outlookexp",sizeof("sdbc:address:outlookexp")-1) + || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:mozilla:",sizeof("sdbc:address:mozilla:")-1) + || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:kab",sizeof("sdbc:address:kab")-1) + || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:evolution:local",sizeof("sdbc:address:evolution:local")-1) + || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:evolution:groupwise",sizeof("sdbc:address:evolution:groupwise")-1) + || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:evolution:ldap",sizeof("sdbc:address:evolution:ldap")-1) + || _sURL.matchIgnoreAsciiCaseAsciiL("sdbc:address:macab",sizeof("sdbc:address:macab")-1) ); } // ----------------------------------------------------------------------------- -String ODsnTypeCollection::getDatasourcePrefixFromMediaType(const String& _sMediaType,const String& _sExtension) +void ODsnTypeCollection::extractHostNamePort(const ::rtl::OUString& _rDsn,String& _sDatabaseName,String& _rsHostname,sal_Int32& _nPortNumber) const { - ::rtl::OUString sURL(RTL_CONSTASCII_USTRINGPARAM("sdbc:")); - if ( _sMediaType.EqualsIgnoreCaseAscii( "text/csv" ) ) + String sUrl = cutPrefix(_rDsn); + if ( _rDsn.matchIgnoreAsciiCaseAsciiL("jdbc:oracle:thin:",sizeof("jdbc:oracle:thin:")-1) ) + { + lcl_extractHostAndPort(sUrl,_rsHostname,_nPortNumber); + if ( !_rsHostname.Len() && sUrl.GetTokenCount(':') == 2 ) + { + _nPortNumber = -1; + _rsHostname = sUrl.GetToken(0,':'); + } + if ( _rsHostname.Len() ) + _rsHostname = _rsHostname.GetToken(_rsHostname.GetTokenCount('@') - 1,'@'); + _sDatabaseName = sUrl.GetToken(sUrl.GetTokenCount(':') - 1,':'); + } // if ( _rDsn.matchIgnoreAsciiCaseAsciiL("jdbc:oracle:thin:",sizeof("jdbc:oracle:thin:")-1) ) + else if ( _rDsn.matchIgnoreAsciiCaseAsciiL("sdbc:address:ldap:",sizeof("sdbc:address:ldap:")-1) ) { - sURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("flat:")); + lcl_extractHostAndPort(sUrl,_sDatabaseName,_nPortNumber); } - else if ( _sMediaType.EqualsIgnoreCaseAscii( "application/dbase" ) ) + else if ( _rDsn.matchIgnoreAsciiCaseAsciiL("sdbc:adabas:",sizeof("sdbc:adabas:")-1) ) { - sURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("dbase:")); + if ( sUrl.GetTokenCount(':') == 2 ) + _rsHostname = sUrl.GetToken(0,':'); + _sDatabaseName = sUrl.GetToken(sUrl.GetTokenCount(':') - 1,':'); } - else if ( _sMediaType.EqualsIgnoreCaseAscii( MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET_ASCII ) ) + else if ( _rDsn.matchIgnoreAsciiCaseAsciiL("sdbc:mysql:mysqlc:",sizeof("sdbc:mysql:mysqlc:")-1) || _rDsn.matchIgnoreAsciiCaseAsciiL("sdbc:mysql:jdbc:",sizeof("sdbc:mysql:jdbc:")-1) ) { - sURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("calc:")); + lcl_extractHostAndPort(sUrl,_rsHostname,_nPortNumber); + + if ( _nPortNumber == -1 && !_rsHostname.Len() && sUrl.GetTokenCount('/') == 2 ) + _rsHostname = sUrl.GetToken(0,'/'); + _sDatabaseName = sUrl.GetToken(sUrl.GetTokenCount('/') - 1,'/'); } - else if ( _sMediaType.EqualsIgnoreCaseAscii( "application/msaccess" ) ) + else if ( _rDsn.matchIgnoreAsciiCaseAsciiL("sdbc:ado:access:Provider=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=",sizeof("sdbc:ado:access:Provider=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=")-1) + || _rDsn.matchIgnoreAsciiCaseAsciiL("sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=",sizeof("sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=")-1)) { - if ( _sExtension.EqualsIgnoreCaseAscii( "mdb" ) ) - sURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=")); - else - sURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ado:access:Provider=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=")); + ::rtl::OUString sNewFileName; + if ( ::osl::FileBase::getFileURLFromSystemPath( sUrl, sNewFileName ) == ::osl::FileBase::E_None ) + { + _sDatabaseName = sNewFileName; + } } - return sURL; } // ----------------------------------------------------------------------------- -void ODsnTypeCollection::extractHostNamePort(const String& _rDsn,String& _sDatabaseName,String& _rsHostname,sal_Int32& _nPortNumber) const +String ODsnTypeCollection::getJavaDriverClass(const ::rtl::OUString& _sURL) const { - DATASOURCE_TYPE eType = getType(_rDsn); - String sUrl = cutPrefix(_rDsn); - switch( eType ) - { - case DST_ORACLE_JDBC: - lcl_extractHostAndPort(sUrl,_rsHostname,_nPortNumber); - if ( !_rsHostname.Len() && sUrl.GetTokenCount(':') == 2 ) - { - _nPortNumber = -1; - _rsHostname = sUrl.GetToken(0,':'); - } - if ( _rsHostname.Len() ) - _rsHostname = _rsHostname.GetToken(_rsHostname.GetTokenCount('@') - 1,'@'); - _sDatabaseName = sUrl.GetToken(sUrl.GetTokenCount(':') - 1,':'); - break; - case DST_LDAP: - lcl_extractHostAndPort(sUrl,_sDatabaseName,_nPortNumber); - break; - case DST_ADABAS: - if ( sUrl.GetTokenCount(':') == 2 ) - _rsHostname = sUrl.GetToken(0,':'); - _sDatabaseName = sUrl.GetToken(sUrl.GetTokenCount(':') - 1,':'); - break; - case DST_MYSQL_NATIVE: - case DST_MYSQL_JDBC: - { - lcl_extractHostAndPort(sUrl,_rsHostname,_nPortNumber); - - if ( _nPortNumber == -1 && !_rsHostname.Len() && sUrl.GetTokenCount('/') == 2 ) - _rsHostname = sUrl.GetToken(0,'/'); - _sDatabaseName = sUrl.GetToken(sUrl.GetTokenCount('/') - 1,'/'); - } - break; - case DST_MSACCESS: - case DST_MSACCESS_2007: - { - ::rtl::OUString sNewFileName; - if ( ::osl::FileBase::getFileURLFromSystemPath( sUrl, sNewFileName ) == ::osl::FileBase::E_None ) - { - _sDatabaseName = sNewFileName; - } - } - break; - default: - break; - } + ::connectivity::DriversConfig aDriverConfig(m_xFactory); + const ::comphelper::NamedValueCollection& aFeatures = aDriverConfig.getProperties(_sURL); + return aFeatures.getOrDefault("JavaDriverClass",::rtl::OUString()); } - //------------------------------------------------------------------------- -sal_Bool ODsnTypeCollection::isFileSystemBased(DATASOURCE_TYPE _eType) const +sal_Bool ODsnTypeCollection::isFileSystemBased(const ::rtl::OUString& _sURL) const { - switch (_eType) - { - case DST_DBASE: - case DST_FLAT: - case DST_CALC: - case DST_MSACCESS: - case DST_MSACCESS_2007: - return sal_True; - - case DST_USERDEFINE1: - case DST_USERDEFINE2: - case DST_USERDEFINE3: - case DST_USERDEFINE4: - case DST_USERDEFINE5: - case DST_USERDEFINE6: - case DST_USERDEFINE7: - case DST_USERDEFINE8: - case DST_USERDEFINE9: - case DST_USERDEFINE10: - { - StringVector::size_type nPos = static_cast<sal_Int16>(_eType-DST_USERDEFINE1); - return nPos < m_aUserExtensions.size() && m_aUserExtensions[nPos].Len() != 0; - } - default: - return sal_False; - } + ::connectivity::DriversConfig aDriverConfig(m_xFactory); + const ::comphelper::NamedValueCollection& aFeatures = aDriverConfig.getMetaData(_sURL); + return aFeatures.getOrDefault("FileSystemBased",sal_False); +} +// ----------------------------------------------------------------------------- +sal_Bool ODsnTypeCollection::supportsTableCreation(const ::rtl::OUString& _sURL) const +{ + ::connectivity::DriversConfig aDriverConfig(m_xFactory); + const ::comphelper::NamedValueCollection& aFeatures = aDriverConfig.getMetaData(_sURL); + return aFeatures.getOrDefault("SupportsTableCreation",sal_False); +} +// ----------------------------------------------------------------------------- +sal_Bool ODsnTypeCollection::supportsBrowsing(const ::rtl::OUString& _sURL) const +{ + ::connectivity::DriversConfig aDriverConfig(m_xFactory); + const ::comphelper::NamedValueCollection& aFeatures = aDriverConfig.getMetaData(_sURL); + return aFeatures.getOrDefault("SupportsBrowsing",sal_False); +} +// ----------------------------------------------------------------------------- +bool ODsnTypeCollection::needsJVM(const String& _sURL) const +{ + ::connectivity::DriversConfig aDriverConfig(m_xFactory); + const ::comphelper::NamedValueCollection& aFeatures = aDriverConfig.getMetaData(_sURL); + return aFeatures.getOrDefault("UseJava",sal_False); +} +// ----------------------------------------------------------------------------- +Sequence<PropertyValue> ODsnTypeCollection::getDefaultDBSettings( const ::rtl::OUString& _sURL ) const +{ + ::connectivity::DriversConfig aDriverConfig(m_xFactory); + const ::comphelper::NamedValueCollection& aProperties = aDriverConfig.getProperties(_sURL); + return aProperties.getPropertyValues(); } - -sal_Bool ODsnTypeCollection::supportsTableCreation(DATASOURCE_TYPE _eType) +// ----------------------------------------------------------------------------- +String ODsnTypeCollection::getTypeExtension(const ::rtl::OUString& _sURL) const { - BOOL bSupportsTableCreation; - switch( _eType ) - { - case DST_MOZILLA: - case DST_OUTLOOK: - case DST_OUTLOOKEXP: - case DST_FLAT: - case DST_EVOLUTION: - case DST_EVOLUTION_GROUPWISE: - case DST_EVOLUTION_LDAP: - case DST_KAB: - case DST_THUNDERBIRD: - case DST_CALC: - bSupportsTableCreation = FALSE; - break; - case DST_DBASE: - case DST_ADABAS: - case DST_ADO: - case DST_MSACCESS: - case DST_MSACCESS_2007: - case DST_MYSQL_ODBC: - case DST_ODBC: - case DST_MYSQL_JDBC: - case DST_MYSQL_NATIVE: - case DST_ORACLE_JDBC: - case DST_LDAP: - case DST_JDBC: - default: - bSupportsTableCreation = TRUE; - break; - } - return bSupportsTableCreation; + ::connectivity::DriversConfig aDriverConfig(m_xFactory); + const ::comphelper::NamedValueCollection& aFeatures = aDriverConfig.getMetaData(_sURL); + return aFeatures.getOrDefault("Extension",::rtl::OUString()); +} +//------------------------------------------------------------------------- +bool ODsnTypeCollection::isEmbeddedDatabase( const ::rtl::OUString& _sURL ) const +{ + const ::rtl::OUString sEmbeddedDatabaseURL = getEmbeddedDatabase(); + WildCard aWildCard(sEmbeddedDatabaseURL); + return aWildCard.Matches(_sURL); } // ----------------------------------------------------------------------------- -sal_Bool ODsnTypeCollection::supportsBrowsing(DATASOURCE_TYPE _eType) +::rtl::OUString ODsnTypeCollection::getEmbeddedDatabase() const { - sal_Bool bEnableBrowseButton = sal_False; - switch( _eType ) + ::rtl::OUString sEmbeddedDatabaseURL; + static const ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.DataAccess/EmbeddedDatabases")); ///Installed + const ::utl::OConfigurationTreeRoot aInstalled = ::utl::OConfigurationTreeRoot::createWithServiceFactory(m_xFactory, s_sNodeName, -1, ::utl::OConfigurationTreeRoot::CM_READONLY); + if ( aInstalled.isValid() ) { - case DST_DBASE: - case DST_FLAT: - case DST_CALC: - case DST_ADABAS: - case DST_ADO: - case DST_MSACCESS: - case DST_MSACCESS_2007: - case DST_MYSQL_ODBC: - case DST_ODBC: - case DST_MOZILLA: - case DST_THUNDERBIRD: - bEnableBrowseButton = TRUE; - break; - case DST_MYSQL_NATIVE: - case DST_MYSQL_JDBC: - case DST_ORACLE_JDBC: - case DST_LDAP: - case DST_OUTLOOK: - case DST_OUTLOOKEXP: - case DST_JDBC: - case DST_EVOLUTION: - case DST_EVOLUTION_GROUPWISE: - case DST_EVOLUTION_LDAP: - case DST_KAB: - bEnableBrowseButton = FALSE; - break; - default: - bEnableBrowseButton = getTypeExtension(_eType).Len() != 0; - break; - } - return bEnableBrowseButton; + static const ::rtl::OUString s_sValue(RTL_CONSTASCII_USTRINGPARAM("DefaultEmbeddedDatabase/Value")); + + aInstalled.getNodeValue(s_sValue) >>= sEmbeddedDatabaseURL; + if ( sEmbeddedDatabaseURL.getLength() ) + aInstalled.getNodeValue(s_sValue + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sEmbeddedDatabaseURL + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/URL"))) >>= sEmbeddedDatabaseURL; + } // if ( aInstalled.isValid() ) + if ( !sEmbeddedDatabaseURL.getLength() ) + sEmbeddedDatabaseURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:embedded:hsqldb")); + return sEmbeddedDatabaseURL; +} +//------------------------------------------------------------------------- +ODsnTypeCollection::TypeIterator ODsnTypeCollection::begin() const +{ + return TypeIterator(this, 0); } - //------------------------------------------------------------------------- -DATASOURCE_TYPE ODsnTypeCollection::implDetermineType(const String& _rDsn) const +ODsnTypeCollection::TypeIterator ODsnTypeCollection::end() const +{ + return TypeIterator(this, m_aDsnTypesDisplayNames.size()); +} +//------------------------------------------------------------------------- +DATASOURCE_TYPE ODsnTypeCollection::determineType(const String& _rDsn) const { - sal_uInt16 nSeparator = _rDsn.Search((sal_Unicode)':'); + String sDsn(_rDsn); + sDsn.EraseTrailingChars('*'); + sal_uInt16 nSeparator = sDsn.Search((sal_Unicode)':'); if (STRING_NOTFOUND == nSeparator) { // there should be at least one such separator @@ -450,19 +355,19 @@ DATASOURCE_TYPE ODsnTypeCollection::implDetermineType(const String& _rDsn) const return DST_UNKNOWN; } // find first : - sal_uInt16 nOracleSeparator = _rDsn.Search((sal_Unicode)':', nSeparator + 1); + sal_uInt16 nOracleSeparator = sDsn.Search((sal_Unicode)':', nSeparator + 1); if ( nOracleSeparator != STRING_NOTFOUND ) { - nOracleSeparator = _rDsn.Search((sal_Unicode)':', nOracleSeparator + 1); - if (nOracleSeparator != STRING_NOTFOUND && _rDsn.EqualsIgnoreCaseAscii("jdbc:oracle:thin", 0, nOracleSeparator)) + nOracleSeparator = sDsn.Search((sal_Unicode)':', nOracleSeparator + 1); + if (nOracleSeparator != STRING_NOTFOUND && sDsn.EqualsIgnoreCaseAscii("jdbc:oracle:thin", 0, nOracleSeparator)) return DST_ORACLE_JDBC; } - if (_rDsn.EqualsIgnoreCaseAscii("jdbc", 0, nSeparator)) + if (sDsn.EqualsIgnoreCaseAscii("jdbc", 0, nSeparator)) return DST_JDBC; // find second : - nSeparator = _rDsn.Search((sal_Unicode)':', nSeparator + 1); + nSeparator = sDsn.Search((sal_Unicode)':', nSeparator + 1); if (STRING_NOTFOUND == nSeparator) { // at the moment only jdbc is allowed to have just one separator @@ -470,156 +375,185 @@ DATASOURCE_TYPE ODsnTypeCollection::implDetermineType(const String& _rDsn) const return DST_UNKNOWN; } - if (_rDsn.EqualsIgnoreCaseAscii("sdbc:adabas", 0, nSeparator)) + if (sDsn.EqualsIgnoreCaseAscii("sdbc:adabas", 0, nSeparator)) return DST_ADABAS; - if (_rDsn.EqualsIgnoreCaseAscii("sdbc:odbc", 0, nSeparator)) + if (sDsn.EqualsIgnoreCaseAscii("sdbc:odbc", 0, nSeparator)) return DST_ODBC; - if (_rDsn.EqualsIgnoreCaseAscii("sdbc:dbase", 0, nSeparator)) + if (sDsn.EqualsIgnoreCaseAscii("sdbc:dbase", 0, nSeparator)) return DST_DBASE; - if (_rDsn.EqualsIgnoreCaseAscii("sdbc:ado:", 0, nSeparator)) + if (sDsn.EqualsIgnoreCaseAscii("sdbc:ado:", 0, nSeparator)) { - nSeparator = _rDsn.Search((sal_Unicode)':', nSeparator + 1); - if (STRING_NOTFOUND != nSeparator && _rDsn.EqualsIgnoreCaseAscii("sdbc:ado:access",0, nSeparator) ) + nSeparator = sDsn.Search((sal_Unicode)':', nSeparator + 1); + if (STRING_NOTFOUND != nSeparator && sDsn.EqualsIgnoreCaseAscii("sdbc:ado:access",0, nSeparator) ) { - nSeparator = _rDsn.Search((sal_Unicode)';', nSeparator + 1); - if (STRING_NOTFOUND != nSeparator && _rDsn.EqualsIgnoreCaseAscii("sdbc:ado:access:Provider=Microsoft.ACE.OLEDB.12.0",0, nSeparator) ) + nSeparator = sDsn.Search((sal_Unicode)';', nSeparator + 1); + if (STRING_NOTFOUND != nSeparator && sDsn.EqualsIgnoreCaseAscii("sdbc:ado:access:Provider=Microsoft.ACE.OLEDB.12.0",0, nSeparator) ) return DST_MSACCESS_2007; return DST_MSACCESS; } return DST_ADO; } - if (_rDsn.EqualsIgnoreCaseAscii("sdbc:flat:", 0, nSeparator)) + if (sDsn.EqualsIgnoreCaseAscii("sdbc:flat:", 0, nSeparator)) return DST_FLAT; - if (_rDsn.EqualsIgnoreCaseAscii("sdbc:calc:", 0, nSeparator)) + if (sDsn.EqualsIgnoreCaseAscii("sdbc:calc:", 0, nSeparator)) return DST_CALC; - //if ( ( 11 <= nSeparator) && _rDsn.EqualsIgnoreCaseAscii("sdbc:mysqlc:", 0, nSeparator)) + //if ( ( 11 <= nSeparator) && sDsn.EqualsIgnoreCaseAscii("sdbc:mysqlc:", 0, nSeparator)) // return DST_MYSQL_NATIVE; - if (_rDsn.EqualsIgnoreCaseAscii("sdbc:embedded:hsqldb", 0, _rDsn.Len())) + if (sDsn.EqualsIgnoreCaseAscii("sdbc:embedded:hsqldb", 0, sDsn.Len())) return DST_EMBEDDED_HSQLDB; - if (_rDsn.EqualsIgnoreCaseAscii("sdbc:address:", 0, nSeparator)) + if (sDsn.EqualsIgnoreCaseAscii("sdbc:address:", 0, nSeparator)) { ++nSeparator; - if (_rDsn.EqualsIgnoreCaseAscii("mozilla:", nSeparator,_rDsn.Len() - nSeparator)) + if (sDsn.EqualsIgnoreCaseAscii("mozilla:", nSeparator,sDsn.Len() - nSeparator)) return DST_MOZILLA; - if (_rDsn.EqualsIgnoreCaseAscii("thunderbird:", nSeparator,_rDsn.Len() - nSeparator)) + if (sDsn.EqualsIgnoreCaseAscii("thunderbird:", nSeparator,sDsn.Len() - nSeparator)) return DST_THUNDERBIRD; - if (_rDsn.EqualsIgnoreCaseAscii("ldap:", nSeparator,_rDsn.Len() - nSeparator)) + if (sDsn.EqualsIgnoreCaseAscii("ldap:", nSeparator,sDsn.Len() - nSeparator)) return DST_LDAP; - if (_rDsn.EqualsIgnoreCaseAscii("outlook", nSeparator,_rDsn.Len() - nSeparator)) + if (sDsn.EqualsIgnoreCaseAscii("outlook", nSeparator,sDsn.Len() - nSeparator)) return DST_OUTLOOK; - if (_rDsn.EqualsIgnoreCaseAscii("outlookexp", nSeparator,_rDsn.Len() - nSeparator)) + if (sDsn.EqualsIgnoreCaseAscii("outlookexp", nSeparator,sDsn.Len() - nSeparator)) return DST_OUTLOOKEXP; - if (_rDsn.EqualsIgnoreCaseAscii("evolution:ldap", nSeparator,_rDsn.Len() - nSeparator)) + if (sDsn.EqualsIgnoreCaseAscii("evolution:ldap", nSeparator,sDsn.Len() - nSeparator)) return DST_EVOLUTION_LDAP; - if (_rDsn.EqualsIgnoreCaseAscii("evolution:groupwise", nSeparator,_rDsn.Len() - nSeparator)) + if (sDsn.EqualsIgnoreCaseAscii("evolution:groupwise", nSeparator,sDsn.Len() - nSeparator)) return DST_EVOLUTION_GROUPWISE; - if (_rDsn.EqualsIgnoreCaseAscii("evolution:local", nSeparator,_rDsn.Len() - nSeparator)) + if (sDsn.EqualsIgnoreCaseAscii("evolution:local", nSeparator,sDsn.Len() - nSeparator)) return DST_EVOLUTION; - if (_rDsn.EqualsIgnoreCaseAscii("kab", nSeparator,_rDsn.Len() - nSeparator)) + if (sDsn.EqualsIgnoreCaseAscii("kab", nSeparator,sDsn.Len() - nSeparator)) return DST_KAB; - if (_rDsn.EqualsIgnoreCaseAscii("macab", nSeparator,_rDsn.Len() - nSeparator)) + if (sDsn.EqualsIgnoreCaseAscii("macab", nSeparator,sDsn.Len() - nSeparator)) return DST_MACAB; } // find third : - nSeparator = _rDsn.Search((sal_Unicode)':', nSeparator + 1); + nSeparator = sDsn.Search((sal_Unicode)':', nSeparator + 1); if (STRING_NOTFOUND == nSeparator) { DBG_ERROR("ODsnTypeCollection::implDetermineType : missing the third colon !"); return DST_UNKNOWN; } - if (_rDsn.EqualsIgnoreCaseAscii("sdbc:mysql:odbc", 0, nSeparator)) + if (sDsn.EqualsIgnoreCaseAscii("sdbc:mysql:odbc", 0, nSeparator)) return DST_MYSQL_ODBC; - if (_rDsn.EqualsIgnoreCaseAscii("sdbc:mysql:jdbc", 0, nSeparator)) + if (sDsn.EqualsIgnoreCaseAscii("sdbc:mysql:jdbc", 0, nSeparator)) return DST_MYSQL_JDBC; - if (_rDsn.EqualsIgnoreCaseAscii("sdbc:mysql:mysqlc", 0, nSeparator)) + if (sDsn.EqualsIgnoreCaseAscii("sdbc:mysql:mysqlc", 0, nSeparator)) return DST_MYSQL_NATIVE; DBG_ERROR("ODsnTypeCollection::implDetermineType : unrecognized data source type !"); return DST_UNKNOWN; } // ----------------------------------------------------------------------------- -sal_Int32 ODsnTypeCollection::implDetermineTypeIndex(DATASOURCE_TYPE _eType) const +void ODsnTypeCollection::fillPageIds(const ::rtl::OUString& _sURL,::std::vector<sal_Int16>& _rOutPathIds) const { - DBG_ASSERT( - (m_aDsnTypesDisplayNames.size() == m_aDsnPrefixes.size()) - && (m_aDsnTypesDisplayNames.size() == m_aDsnTypes.size()), - "ODsnTypeCollection::implDetermineTypeIndex : inconsistent structures !"); - - // the type of the datasource described by the DSN string - if (DST_UNKNOWN == _eType) + DATASOURCE_TYPE eType = determineType(_sURL); + switch(eType) { - return -1; + case DST_ADO: + _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_ADO); + break; + case DST_DBASE: + _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_DBASE); + break; + case DST_FLAT: + _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_TEXT); + break; + case DST_CALC: + _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_SPREADSHEET); + break; + case DST_ODBC: + _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_ODBC); + break; + case DST_JDBC: + _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_JDBC); + break; + case DST_MYSQL_ODBC: + _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_INTRO); + _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_ODBC); + break; + case DST_MYSQL_JDBC: + _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_INTRO); + _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_JDBC); + break; + case DST_MYSQL_NATIVE: + _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_INTRO); + _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MYSQL_NATIVE); + break; + case DST_ORACLE_JDBC: + _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_ORACLE); + break; + case DST_ADABAS: + _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_ADABAS); + break; + case DST_LDAP: + _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_LDAP); + break; + case DST_MSACCESS: + case DST_MSACCESS_2007: + _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_MSACCESS); + break; + case DST_OUTLOOKEXP: + case DST_OUTLOOK: + case DST_MOZILLA: + case DST_THUNDERBIRD: + case DST_EVOLUTION: + case DST_EVOLUTION_GROUPWISE: + case DST_EVOLUTION_LDAP: + case DST_KAB: + case DST_MACAB: + case DST_EMBEDDED_HSQLDB: + break; + default: + _rOutPathIds.push_back(PAGE_DBSETUPWIZARD_USERDEFINED); + break; } - - // search this type in our arrays - sal_Int32 nIndex = 0; - ConstTypeVectorIterator aSearch = m_aDsnTypes.begin(); - - for (; aSearch != m_aDsnTypes.end(); ++nIndex, ++aSearch) - if (*aSearch == _eType) - return nIndex; - - DBG_ERROR("ODsnTypeCollection::implDetermineTypeIndex : recognized the DSN schema, but did not find the type!"); - return -1; } // ----------------------------------------------------------------------------- -Sequence<PropertyValue> ODsnTypeCollection::getDefaultDBSettings( DATASOURCE_TYPE _eType ) const +::rtl::OUString ODsnTypeCollection::getType(const ::rtl::OUString& _sURL) const { - Sequence< PropertyValue > aSettings; - - switch ( _eType ) + ::rtl::OUString sOldPattern; + StringVector::const_iterator aIter = m_aDsnPrefixes.begin(); + StringVector::const_iterator aEnd = m_aDsnPrefixes.end(); + for(;aIter != aEnd;++aIter) { - case DST_EMBEDDED_HSQLDB: - aSettings.realloc( 3 ); - - aSettings[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AutoIncrementCreation" ) ); - aSettings[0].Value <<= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IDENTITY" ) ); - - aSettings[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AutoRetrievingStatement" ) ); - aSettings[1].Value <<= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CALL IDENTITY()" ) ); - - aSettings[2].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsAutoRetrievingEnabled" ) ); - aSettings[2].Value <<= (sal_Bool)sal_True; - break; - - default: - DBG_ERROR( "ODsnTypeCollection::getDefaultDBSettings: type is unsupported by this method!" ); - break; - } - - return aSettings; + WildCard aWildCard(*aIter); + if ( sOldPattern.getLength() < aIter->Len() && aWildCard.Matches(_sURL) ) + { + sOldPattern = *aIter; + } + } // for(sal_Int32 i = 0;aIter != aEnd;++aIter,++i) + return sOldPattern; } - // ----------------------------------------------------------------------------- -String ODsnTypeCollection::getTypeExtension(DATASOURCE_TYPE _eType) const +sal_Int32 ODsnTypeCollection::getIndexOf(const ::rtl::OUString& _sURL) const { - StringVector::size_type nPos = static_cast<sal_uInt16>(_eType-DST_USERDEFINE1); - return nPos < m_aUserExtensions.size() ? m_aUserExtensions[nPos] : String(); -} -//------------------------------------------------------------------------- -bool ODsnTypeCollection::isEmbeddedDatabase( DATASOURCE_TYPE _eType ) const -{ - // the only known embedded type so far is DST_EMBEDDED_HSQLDB - return ( _eType == DST_EMBEDDED_HSQLDB ); -} -//------------------------------------------------------------------------- -ODsnTypeCollection::TypeIterator ODsnTypeCollection::begin() const -{ - return TypeIterator(this, 0); -} + sal_Int32 nRet = -1; + String sURL( _sURL); + String sOldPattern; + StringVector::const_iterator aIter = m_aDsnPrefixes.begin(); + StringVector::const_iterator aEnd = m_aDsnPrefixes.end(); + for(sal_Int32 i = 0;aIter != aEnd;++aIter,++i) + { + WildCard aWildCard(*aIter); + if ( sOldPattern.Len() < aIter->Len() && aWildCard.Matches(sURL) ) + { + nRet = i; + sOldPattern = *aIter; + } + } -//------------------------------------------------------------------------- -ODsnTypeCollection::TypeIterator ODsnTypeCollection::end() const + return nRet; +} +// ----------------------------------------------------------------------------- +sal_Int32 ODsnTypeCollection::size() const { - return TypeIterator(this, m_aDsnTypes.size()); + return m_aDsnPrefixes.size(); } - //========================================================================= //= ODsnTypeCollection::TypeIterator //========================================================================= @@ -653,24 +587,22 @@ ODsnTypeCollection::TypeIterator::~TypeIterator() } //------------------------------------------------------------------------- -DATASOURCE_TYPE ODsnTypeCollection::TypeIterator::getType() const -{ - DBG_ASSERT(m_nPosition < (sal_Int32)m_pContainer->m_aDsnTypes.size(), "ODsnTypeCollection::TypeIterator::getType : invalid position!"); - return m_pContainer->m_aDsnTypes[m_nPosition]; -} - -//------------------------------------------------------------------------- String ODsnTypeCollection::TypeIterator::getDisplayName() const { DBG_ASSERT(m_nPosition < (sal_Int32)m_pContainer->m_aDsnTypesDisplayNames.size(), "ODsnTypeCollection::TypeIterator::getDisplayName : invalid position!"); return m_pContainer->m_aDsnTypesDisplayNames[m_nPosition]; } - +// ----------------------------------------------------------------------------- +::rtl::OUString ODsnTypeCollection::TypeIterator::getURLPrefix() const +{ + DBG_ASSERT(m_nPosition < (sal_Int32)m_pContainer->m_aDsnPrefixes.size(), "ODsnTypeCollection::TypeIterator::getDisplayName : invalid position!"); + return m_pContainer->m_aDsnPrefixes[m_nPosition]; +} //------------------------------------------------------------------------- const ODsnTypeCollection::TypeIterator& ODsnTypeCollection::TypeIterator::operator++() { DBG_ASSERT(m_nPosition < (sal_Int32)m_pContainer->m_aDsnTypes.size(), "ODsnTypeCollection::TypeIterator::operator++ : invalid position!"); - if (m_nPosition < (sal_Int32)m_pContainer->m_aDsnTypes.size()) + if (m_nPosition < (sal_Int32)m_pContainer->m_aDsnTypesDisplayNames.size()) ++m_nPosition; return *this; } diff --git a/dbaccess/source/core/resource/strings.src b/dbaccess/source/core/resource/strings.src index 23ad6023cbbc..4cf5b457c9fe 100644 --- a/dbaccess/source/core/resource/strings.src +++ b/dbaccess/source/core/resource/strings.src @@ -241,203 +241,3 @@ String RID_STR_NAME_NOT_FOUND }; //------------------------------------------------------------------------- -Resource RSC_DATASOURCE_TYPES -{ - String STR_MYSQL_ODBC - { - Text ="sdbc:mysql:odbc:"; - }; - String STR_MYSQL_JDBC - { - Text ="sdbc:mysql:jdbc:"; - }; - String STR_ADABAS - { - Text ="sdbc:adabas:"; - }; - String STR_ORACLE_JDBC - { - Text ="jdbc:oracle:thin:"; - }; - String STR_JDBC - { - Text ="jdbc:"; - }; - String STR_ODBC - { - Text ="sdbc:odbc:"; - }; - String STR_DBASE - { - Text ="sdbc:dbase:"; - }; - String STR_MSACCESS - { - Text ="sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="; - }; - String STR_MSACCESS2007 - { - Text ="sdbc:ado:access:Provider=Microsoft.ACE.OLEDB.12.0;DATA SOURCE="; - }; - String STR_ADO - { - Text ="sdbc:ado:"; - }; - String STR_FLAT - { - Text ="sdbc:flat:"; - }; - String STR_CALC - { - Text ="sdbc:calc:"; - }; - String STR_MOZILLA - { - Text ="sdbc:address:mozilla:"; - }; - String STR_LDAP - { - Text ="sdbc:address:ldap:"; - }; - String STR_OUTLOOK - { - Text ="sdbc:address:outlook"; - }; - String STR_OUTLOOKEXP - { - Text ="sdbc:address:outlookexp"; - }; - String STR_EVOLUTION - { - Text ="sdbc:address:evolution:local"; - }; - String STR_EVOLUTION_GROUPWISE - { - Text ="sdbc:address:evolution:groupwise"; - }; - String STR_EVOLUTION_LDAP - { - Text ="sdbc:address:evolution:ldap"; - }; - String STR_KAB - { - Text ="sdbc:address:kab"; - }; - String STR_EMBEDDED_HSQLDB - { - Text = "sdbc:embedded:hsqldb"; - }; - String STR_MACAB - { - Text ="sdbc:address:macab"; - }; - String STR_THUNDERBIRD - { - Text ="sdbc:address:thunderbird:"; - }; - String STR_MYSQL_NATIVE - { - Text ="sdbc:mysql:mysqlc:"; - }; -}; - -Resource RSC_DATASOURCE_TYPE_UINAMES -{ - String STR_MYSQL_ODBC - { - Text[ en-US ] = "MySQL (ODBC)"; - }; - String STR_MYSQL_JDBC - { - Text[ en-US ] = "MySQL (JDBC)"; - }; - String STR_ADABAS - { - Text[ en-US ] = "Adabas D"; - }; - String STR_ORACLE_JDBC - { - Text[ en-US ] = "Oracle JDBC"; - }; - - String STR_JDBC - { - Text[ en-US ] = "JDBC"; - }; - String STR_ODBC - { - Text[ en-US ] = "ODBC"; - }; - String STR_DBASE - { - Text[ en-US ] = "dBASE"; - }; - String STR_MSACCESS - { - Text[ en-US ] = "Microsoft Access"; - }; - String STR_MSACCESS2007 - { - Text[ en-US ] = "Microsoft Access 2007"; - }; - String STR_ADO - { - Text[ en-US ] = "ADO"; - }; - String STR_FLAT - { - Text[ en-US ] = "Text"; - }; - String STR_CALC - { - Text[ en-US ] = "Spreadsheet"; - }; - String STR_MOZILLA - { - Text[ en-US ] = "Mozilla Address Book"; - }; - String STR_LDAP - { - Text[ en-US ] = "LDAP Address Book"; - }; - String STR_OUTLOOK - { - Text[ en-US ] = "Microsoft Outlook Address Book"; - }; - String STR_OUTLOOKEXP - { - Text[ en-US ] = "Microsoft Windows Address Book"; - }; - String STR_EVOLUTION - { - Text[ en-US ] = "Evolution Local"; - }; - String STR_EVOLUTION_GROUPWISE - { - Text[ en-US ] = "Groupwise"; - }; - String STR_EVOLUTION_LDAP - { - Text[ en-US ] = "Evolution LDAP"; - }; - String STR_KAB - { - Text[ en-US ] = "KDE Address Book"; - }; - String STR_MACAB - { - Text[ en-US ] = "Mac OS X Address Book"; - }; - String STR_EMBEDDED_HSQLDB - { - Text[ en-US ] = "HSQL database engine"; - }; - String STR_THUNDERBIRD - { - Text[ en-US ] = "Thunderbird Address Book"; - }; - String STR_MYSQL_NATIVE - { - Text[ en-US ] = "MySQL (Native)"; - }; -}; diff --git a/dbaccess/source/filter/xml/makefile.mk b/dbaccess/source/filter/xml/makefile.mk index 8a7554ed4af3..41388880a30f 100644 --- a/dbaccess/source/filter/xml/makefile.mk +++ b/dbaccess/source/filter/xml/makefile.mk @@ -88,6 +88,8 @@ SHL1STDLIBS=\ $(CPPULIB) \ $(SFXLIB) \ $(SVLLIB) \ + $(DBTOOLSLIB) \ + $(UNOTOOLSLIB) \ $(SO2LIB) \ $(SALLIB) diff --git a/dbaccess/source/filter/xml/xmlExport.cxx b/dbaccess/source/filter/xml/xmlExport.cxx index efd744df1428..28997c16d31f 100644 --- a/dbaccess/source/filter/xml/xmlExport.cxx +++ b/dbaccess/source/filter/xml/xmlExport.cxx @@ -106,6 +106,7 @@ #include <svtools/filenotation.hxx> #include <svtools/pathoptions.hxx> #include <tools/diagnose_ex.h> +#include <connectivity/DriversConfig.hxx> #include <boost/optional.hpp> @@ -251,6 +252,7 @@ namespace dbaxml // ----------------------------------------------------------------------------- ODBExport::ODBExport(const Reference< XMultiServiceFactory >& _rxMSF,sal_uInt16 nExportFlag) : SvXMLExport( _rxMSF,MAP_10TH_MM,XML_DATABASE, EXPORT_OASIS | nExportFlag) +,m_aTypeCollection(_rxMSF) ,m_bAllreadyFilled(sal_False) { GetMM100UnitConverter().setCoreMeasureUnit(MAP_10TH_MM); @@ -339,6 +341,11 @@ void ODBExport::exportDataSource() xSettingsState->getPropertyDefault( INFO_DECIMALDELIMITER ) >>= aDelimiter.sDecimal; xSettingsState->getPropertyDefault( INFO_THOUSANDSDELIMITER ) >>= aDelimiter.sThousand; + ::connectivity::DriversConfig aDriverConfig(getServiceFactory()); + const ::rtl::OUString sURL = ::comphelper::getString(xProp->getPropertyValue(PROPERTY_URL)); + ::comphelper::NamedValueCollection aMetaData = aDriverConfig.getMetaData(sURL); + aMetaData.merge( aDriverConfig.getProperties(sURL),true ) ; + static ::rtl::OUString s_sTrue(::xmloff::token::GetXMLToken( XML_TRUE )); static ::rtl::OUString s_sFalse(::xmloff::token::GetXMLToken( XML_FALSE )); // loop through the properties, and export only those which are not defaulted @@ -507,8 +514,11 @@ void ODBExport::exportDataSource() } else { - m_aDataSourceSettings.push_back( TypedPropertyValue( - pProperties->Name, pProperties->Type, aValue ) ); + if ( !aMetaData.has(pProperties->Name) || aMetaData.get(pProperties->Name) != aValue ) + { + m_aDataSourceSettings.push_back( TypedPropertyValue( + pProperties->Name, pProperties->Type, aValue ) ); + } continue; } } @@ -609,8 +619,7 @@ void ODBExport::exportConnectionData() ::rtl::OUString sValue; Reference<XPropertySet> xProp(getDataSource()); xProp->getPropertyValue(PROPERTY_URL) >>= sValue; - const ::dbaccess::DATASOURCE_TYPE eType = m_aTypeCollection.getType(sValue); - if ( m_aTypeCollection.isFileSystemBased(eType) ) + if ( m_aTypeCollection.isFileSystemBased(sValue) ) { SvXMLElementExport aDatabaseDescription(*this,XML_NAMESPACE_DB, XML_DATABASE_DESCRIPTION, sal_True, sal_True); { @@ -624,7 +633,8 @@ void ODBExport::exportConnectionData() } // if ( sOrigUrl == sFileName ) else AddAttribute(XML_NAMESPACE_XLINK,XML_HREF,sOrigUrl); - AddAttribute(XML_NAMESPACE_DB,XML_MEDIA_TYPE,m_aTypeCollection.getMediaType(eType)); + AddAttribute(XML_NAMESPACE_DB,XML_MEDIA_TYPE,m_aTypeCollection.getMediaType(sValue)); + const ::dbaccess::DATASOURCE_TYPE eType = m_aTypeCollection.determineType(sValue); try { ::rtl::OUString sExtension; @@ -655,7 +665,7 @@ void ODBExport::exportConnectionData() { SvXMLElementExport aDatabaseDescription(*this,XML_NAMESPACE_DB, XML_DATABASE_DESCRIPTION, sal_True, sal_True); { - String sType = m_aTypeCollection.getDatasourcePrefix(eType); + String sType = m_aTypeCollection.getPrefix(sValue); sType.EraseTrailingChars(':'); AddAttribute(XML_NAMESPACE_DB,XML_TYPE,sType); AddAttribute(XML_NAMESPACE_DB,XML_HOSTNAME,sHostName); diff --git a/dbaccess/source/filter/xml/xmlFileBasedDatabase.cxx b/dbaccess/source/filter/xml/xmlFileBasedDatabase.cxx index b3a7d22fedf0..4cc82ad5e772 100644 --- a/dbaccess/source/filter/xml/xmlFileBasedDatabase.cxx +++ b/dbaccess/source/filter/xml/xmlFileBasedDatabase.cxx @@ -126,7 +126,8 @@ OXMLFileBasedDatabase::OXMLFileBasedDatabase( ODBFilter& rImport, } if ( sLocation.getLength() && sMediaType.getLength() ) { - ::rtl::OUString sURL(dbaccess::ODsnTypeCollection::getDatasourcePrefixFromMediaType(sMediaType,sFileTypeExtension)); + ::dbaccess::ODsnTypeCollection aTypeCollection(rImport.getORB()); + ::rtl::OUString sURL(aTypeCollection.getDatasourcePrefixFromMediaType(sMediaType,sFileTypeExtension)); sURL += sLocation; try { diff --git a/dbaccess/source/filter/xml/xmlfilter.cxx b/dbaccess/source/filter/xml/xmlfilter.cxx index 5e9374dcce77..a02b26b9d209 100644 --- a/dbaccess/source/filter/xml/xmlfilter.cxx +++ b/dbaccess/source/filter/xml/xmlfilter.cxx @@ -115,20 +115,28 @@ #ifndef _COM_SUN_STAR_UTIL_XMODIFIABLE_HPP_ #include <com/sun/star/util/XModifiable.hpp> #endif +#include <com/sun/star/frame/XComponentLoader.hpp> +#include <com/sun/star/frame/FrameSearchFlag.hpp> #ifndef _SV_SVAPP_HXX //autogen #include <vcl/svapp.hxx> #endif #ifndef _VOS_MUTEX_HXX_ #include <vos/mutex.hxx> #endif -#ifndef _SFXECODE_HXX #include <svtools/sfxecode.hxx> -#endif +#include <svtools/moduleoptions.hxx> #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ #include <toolkit/helper/vclunohelper.hxx> #endif #include <tools/diagnose_ex.h> #include <comphelper/namedvaluecollection.hxx> +#include <comphelper/mimeconfighelper.hxx> +#include <comphelper/documentconstants.hxx> +#include <comphelper/uno3.hxx> +#include <osl/thread.hxx> +#include <connectivity/CommonTools.hxx> +#include <connectivity/DriversConfig.hxx> +#include "dsntypes.hxx" using namespace ::com::sun::star; @@ -139,6 +147,138 @@ extern "C" void SAL_CALL createRegistryInfo_ODBFilter( ) //-------------------------------------------------------------------------- namespace dbaxml { + namespace + { + class FastLoader : public ::osl::Thread + { + public: + typedef enum { E_JAVA, E_CALC } StartType; + FastLoader(uno::Reference< lang::XMultiServiceFactory > const & _xFactory,StartType _eType) + :m_xFactory(_xFactory) + ,m_eWhat(_eType) + {} + + protected: + virtual ~FastLoader(){} + + /// Working method which should be overridden. + virtual void SAL_CALL run(); + virtual void SAL_CALL onTerminated(); + private: + uno::Reference< lang::XMultiServiceFactory > m_xFactory; + StartType m_eWhat; + }; + + void SAL_CALL FastLoader::run() + { + if ( m_eWhat == E_JAVA ) + { + static bool s_bFirstTime = true; + if ( s_bFirstTime ) + { + s_bFirstTime = false; + try + { + ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM(m_xFactory); + } + catch(uno::Exception& ex) + { + (void)ex; + OSL_ASSERT(0); + } + } // if ( s_bFirstTime ) + } // if ( m_eWhat == E_JAVA ) + else if ( m_eWhat == E_CALC ) + { + static bool s_bFirstTime = true; + if ( s_bFirstTime ) + { + s_bFirstTime = false; + try + { + uno::Reference<frame::XComponentLoader> xFrameLoad( m_xFactory->createInstance( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop"))) + ,uno::UNO_QUERY); + const ::rtl::OUString sTarget(RTL_CONSTASCII_USTRINGPARAM("_blank")); + sal_Int32 nFrameSearchFlag = frame::FrameSearchFlag::TASKS | frame::FrameSearchFlag::CREATE; + uno::Reference< frame::XFrame> xFrame = uno::Reference< frame::XFrame>(xFrameLoad,uno::UNO_QUERY_THROW)->findFrame(sTarget,nFrameSearchFlag); + xFrameLoad.set( xFrame,uno::UNO_QUERY); + + if ( xFrameLoad.is() ) + { + uno::Sequence < beans::PropertyValue > aArgs( 3); + sal_Int32 nLen = 0; + aArgs[nLen].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AsTemplate")); + aArgs[nLen++].Value <<= sal_False; + + aArgs[nLen].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ReadOnly")); + aArgs[nLen++].Value <<= sal_True; + + aArgs[nLen].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Hidden")); + aArgs[nLen++].Value <<= sal_True; + + ::comphelper::MimeConfigurationHelper aHelper(m_xFactory); + SvtModuleOptions aModuleOptions; + uno::Reference< frame::XModel > xModel(xFrameLoad->loadComponentFromURL( + aModuleOptions.GetFactoryEmptyDocumentURL( aModuleOptions.ClassifyFactoryByServiceName( aHelper.GetDocServiceNameFromMediaType(MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET) )), + ::rtl::OUString(), // empty frame name + 0, + aArgs + ),uno::UNO_QUERY); + ::comphelper::disposeComponent(xModel); + } + } + catch(uno::Exception& ex) + { + (void)ex; + OSL_ASSERT(0); + } + } + } + } + void SAL_CALL FastLoader::onTerminated() + { + delete this; + } + + class DatasourceURLListener : public ::cppu::WeakImplHelper1< beans::XPropertyChangeListener > + { + uno::Reference< lang::XMultiServiceFactory > m_xFactory; + ::dbaccess::ODsnTypeCollection m_aTypeCollection; + DatasourceURLListener(const DatasourceURLListener&); + void operator =(const DatasourceURLListener&); + protected: + virtual ~DatasourceURLListener(){} + public: + DatasourceURLListener(uno::Reference< lang::XMultiServiceFactory > const & _xFactory) : m_xFactory(_xFactory),m_aTypeCollection(_xFactory){} + // XPropertyChangeListener + virtual void SAL_CALL propertyChange( const beans::PropertyChangeEvent& _rEvent ) throw (uno::RuntimeException) + { + ::rtl::OUString sURL; + _rEvent.NewValue >>= sURL; + FastLoader* pCreatorThread = NULL; + + if ( m_aTypeCollection.needsJVM(sURL) ) + { + pCreatorThread = new FastLoader(m_xFactory,FastLoader::E_JAVA); + } // if ( m_aTypeCollection.needsJVM(sURL) ) + else if ( sURL.matchIgnoreAsciiCaseAsciiL("sdbc:calc:",10,0) ) + { + pCreatorThread = new FastLoader(m_xFactory,FastLoader::E_CALC); + } + if ( pCreatorThread ) + { + pCreatorThread->createSuspended(); + pCreatorThread->setPriority(osl_Thread_PriorityBelowNormal); + pCreatorThread->resume(); + } + } + // XEventListener + virtual void SAL_CALL disposing( const lang::EventObject& /*_rSource*/ ) throw (uno::RuntimeException) + { + } + }; + } sal_Char __READONLY_DATA sXML_np__db[] = "_db"; sal_Char __READONLY_DATA sXML_np___db[] = "__db"; @@ -391,11 +531,11 @@ sal_Bool ODBFilter::implImport( const Sequence< PropertyValue >& rDescriptor ) { uno::Reference<sdb::XOfficeDatabaseDocument> xOfficeDoc(GetModel(),UNO_QUERY_THROW); m_xDataSource.set(xOfficeDoc->getDataSource(),UNO_QUERY_THROW); - OSL_ENSURE(m_xDataSource.is(),"DataSource is NULL!"); + uno::Reference<beans::XPropertyChangeListener> xListener = new DatasourceURLListener(getServiceFactory()); + m_xDataSource->addPropertyChangeListener(PROPERTY_URL,xListener); uno::Reference< XNumberFormatsSupplier > xNum(m_xDataSource->getPropertyValue(PROPERTY_NUMBERFORMATSSUPPLIER),UNO_QUERY); SetNumberFormatsSupplier(xNum); - uno::Reference<XComponent> xModel(GetModel(),UNO_QUERY); sal_Int32 nRet = ReadThroughComponent( xStorage ,xModel @@ -820,16 +960,30 @@ UniReference < XMLPropertySetMapper > ODBFilter::GetCellStylesPropertySetMapper( void ODBFilter::setPropertyInfo() { Reference<XPropertySet> xDataSource(getDataSource()); - if ( !m_aInfoSequence.empty() && xDataSource.is() ) + if ( xDataSource.is() ) { - try + ::connectivity::DriversConfig aDriverConfig(getServiceFactory()); + const ::rtl::OUString sURL = ::comphelper::getString(xDataSource->getPropertyValue(PROPERTY_URL)); + ::comphelper::NamedValueCollection aMetaData = aDriverConfig.getMetaData(sURL); + aMetaData.merge( aDriverConfig.getProperties(sURL),true ) ; + Sequence<PropertyValue> aInfo; + if ( !m_aInfoSequence.empty() ) { - xDataSource->setPropertyValue(PROPERTY_INFO,makeAny(Sequence<PropertyValue>(&(*m_aInfoSequence.begin()),m_aInfoSequence.size()))); + aInfo = Sequence<PropertyValue>(&(*m_aInfoSequence.begin()),m_aInfoSequence.size()); } - catch(Exception) + aMetaData.merge(::comphelper::NamedValueCollection(aInfo),true); + aMetaData >>= aInfo; + if ( aInfo.getLength() ) { - DBG_UNHANDLED_EXCEPTION(); - } + try + { + xDataSource->setPropertyValue(PROPERTY_INFO,makeAny(aInfo)); + } + catch(Exception) + { + DBG_UNHANDLED_EXCEPTION(); + } + } // if ( !m_aInfoSequence.empty() && xDataSource.is() ) } } // ----------------------------------------------------------------------------- diff --git a/dbaccess/source/inc/dsntypes.hxx b/dbaccess/source/inc/dsntypes.hxx index d523d5a62012..575202a4fc43 100644 --- a/dbaccess/source/inc/dsntypes.hxx +++ b/dbaccess/source/inc/dsntypes.hxx @@ -89,6 +89,27 @@ enum DATASOURCE_TYPE DST_UNKNOWN /// unrecognized type }; +#define PAGE_DBSETUPWIZARD_INTRO 0 +#define PAGE_DBSETUPWIZARD_DBASE 1 +#define PAGE_DBSETUPWIZARD_TEXT 2 +#define PAGE_DBSETUPWIZARD_MSACCESS 3 +#define PAGE_DBSETUPWIZARD_LDAP 4 +#define PAGE_DBSETUPWIZARD_ADABAS 5 +#define PAGE_DBSETUPWIZARD_MYSQL_INTRO 6 +#define PAGE_DBSETUPWIZARD_MYSQL_JDBC 7 +#define PAGE_DBSETUPWIZARD_MYSQL_ODBC 8 +#define PAGE_DBSETUPWIZARD_ORACLE 9 +#define PAGE_DBSETUPWIZARD_JDBC 10 +#define PAGE_DBSETUPWIZARD_ADO 11 +#define PAGE_DBSETUPWIZARD_ODBC 12 +#define PAGE_DBSETUPWIZARD_SPREADSHEET 13 +#define PAGE_DBSETUPWIZARD_AUTHENTIFICATION 14 +#define PAGE_DBSETUPWIZARD_MOZILLA 15 +#define PAGE_DBSETUPWIZARD_FINAL 16 +#define PAGE_DBSETUPWIZARD_USERDEFINED 17 +#define PAGE_DBSETUPWIZARD_MYSQL_NATIVE 18 + + //========================================================================= //= ODsnTypeCollection //========================================================================= @@ -96,13 +117,10 @@ class OOO_DLLPUBLIC_DBA ODsnTypeCollection { protected: DECLARE_STL_VECTOR(String, StringVector); - DECLARE_STL_VECTOR(DATASOURCE_TYPE, TypeVector); - typedef ::std::map<DATASOURCE_TYPE,DATASOURCE_TYPE> TRelatedTypes; StringVector m_aDsnTypesDisplayNames; /// user readable names for the datasource types StringVector m_aDsnPrefixes; /// DSN prefixes which determine the type of a datasource - TypeVector m_aDsnTypes; /// types of datasources we know - StringVector m_aUserExtensions; /// extensions of user defined types + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory; #ifdef DBG_UTIL sal_Int32 m_nLivingIterators; /// just for debugging reasons, counts the living iterators @@ -112,68 +130,70 @@ public: class TypeIterator; friend class ODsnTypeCollection::TypeIterator; - ODsnTypeCollection(); + ODsnTypeCollection(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory); ~ODsnTypeCollection(); - /// get the datasource type from a DSN string - DATASOURCE_TYPE getType(const String& _rDsn) const; - /// get the datasource type display name from a DSN string - String getTypeDisplayName(DATASOURCE_TYPE _eType) const; - - /// the the DSN prefix associated with a given type - String getDatasourcePrefix(DATASOURCE_TYPE _eType) const; + String getTypeDisplayName(const ::rtl::OUString& _sURL) const; /// returns the extension of the user defined type - String getTypeExtension(DATASOURCE_TYPE _eType) const; + String getTypeExtension(const ::rtl::OUString& _sURL) const; /// on a given string, cut the type prefix and return the result - String cutPrefix(const String& _rDsn) const; + String cutPrefix(const ::rtl::OUString& _sURL) const; + + /// on a given string, return the type prefix + String getPrefix(const ::rtl::OUString& _sURL) const; + + /// on a given string, return the Java Driver Class + String getJavaDriverClass(const ::rtl::OUString& _sURL) const; /// returns the media type of a file based database - String getMediaType(DATASOURCE_TYPE _eType) const; + String getMediaType(const ::rtl::OUString& _sURL) const; /// returns the dsn prefix for a given media type - static String getDatasourcePrefixFromMediaType(const String& _sMediaType,const String& _sExtension = String() ); + String getDatasourcePrefixFromMediaType(const ::rtl::OUString& _sMediaType,const ::rtl::OUString& _sExtension = ::rtl::OUString() ); - void extractHostNamePort(const String& _rDsn,String& _sDatabaseName,String& _rHostname,sal_Int32& _nPortNumber) const; + void extractHostNamePort(const ::rtl::OUString& _rDsn,String& _sDatabaseName,String& _rHostname,sal_Int32& _nPortNumber) const; /// check if the given data source allows creation of tables - sal_Bool supportsTableCreation(DATASOURCE_TYPE _eType); + sal_Bool supportsTableCreation(const ::rtl::OUString& _sURL) const; // check if a Browse button may be shown to insert connection url - sal_Bool supportsBrowsing(DATASOURCE_TYPE _eType); + sal_Bool supportsBrowsing(const ::rtl::OUString& _sURL) const; /// check if the given data source tyoe is based on the file system - i.e. the URL is a prefix plus a file URL - sal_Bool isFileSystemBased(DATASOURCE_TYPE _eType) const; + sal_Bool isFileSystemBased(const ::rtl::OUString& _sURL) const; + + bool isConnectionUrlRequired(const ::rtl::OUString& _sURL) const; /// checks if the given data source type embeds its data into the database document - bool isEmbeddedDatabase( DATASOURCE_TYPE _eType ) const; + bool isEmbeddedDatabase( const ::rtl::OUString& _sURL ) const; - /** returns default settings for newly created databases of the given type. + ::rtl::OUString getEmbeddedDatabase() const; + + // returns true when the properties dialog can be shown, otherwise false. + bool isShowPropertiesEnabled( const ::rtl::OUString& _sURL ) const; - Currently implemented (and used) for DST_EMBEDDED_HSQLDB only + /** returns default settings for newly created databases of the given type. */ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> - getDefaultDBSettings( DATASOURCE_TYPE _eType ) const; + getDefaultDBSettings( const ::rtl::OUString& _sURL ) const; /// get access to the first element of the types collection TypeIterator begin() const; /// get access to the (last + 1st) element of the types collection TypeIterator end() const; - /** read all user defined driver types. - @param _rxORB - The service factory - */ - void initUserDriverTypes(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB); + void fillPageIds(const ::rtl::OUString& _sURL,::std::vector<sal_Int16>& _rOutPathIds) const; -protected: - /// return the connection type a DSN string represents - DATASOURCE_TYPE implDetermineType(const String& _rDsn) const; + DATASOURCE_TYPE determineType(const String& _rDsn) const; + + bool needsJVM(const String& _rDsn) const; - /// return the index within the internal structures for the connection type given - sal_Int32 implDetermineTypeIndex(DATASOURCE_TYPE _eType) const; + sal_Int32 getIndexOf(const ::rtl::OUString& _sURL) const; + sal_Int32 size() const; + ::rtl::OUString getType(const ::rtl::OUString& _sURL) const; }; //------------------------------------------------------------------------- @@ -194,7 +214,7 @@ public: TypeIterator(const TypeIterator& _rSource); ~TypeIterator(); - DATASOURCE_TYPE getType() const; + ::rtl::OUString getURLPrefix() const; String getDisplayName() const; /// prefix increment diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx index fb6c7e254e7c..99c29398fc33 100644 --- a/dbaccess/source/ui/app/AppController.cxx +++ b/dbaccess/source/ui/app/AppController.cxx @@ -410,6 +410,7 @@ OApplicationController::OApplicationController(const Reference< XMultiServiceFac :OApplicationController_CBASE( _rxORB ) ,m_aContextMenuInterceptors( getMutex() ) ,m_pSubComponentManager( new SubComponentManager( *this, getSharedMutex() ) ) + ,m_aTypeCollection(_rxORB) ,m_aTableCopyHelper(this) ,m_pClipbordNotifier(NULL) ,m_nAsyncDrop(0) @@ -422,8 +423,6 @@ OApplicationController::OApplicationController(const Reference< XMultiServiceFac ,m_pSelectionNotifier( new SelectionNotifier( getMutex(), *this ) ) { DBG_CTOR(OApplicationController,NULL); - - m_aTypeCollection.initUserDriverTypes(_rxORB); } //------------------------------------------------------------------------------ OApplicationController::~OApplicationController() @@ -940,11 +939,8 @@ FeatureState OApplicationController::GetState(sal_uInt16 _nId) const aReturn.bEnabled = getContainer()->getSelectionCount() > 0 && getContainer()->isALeafSelected(); break; case SID_DB_APP_DSUSERADMIN: - { - ::dbaccess::DATASOURCE_TYPE eType = m_aTypeCollection.getType(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL))); - aReturn.bEnabled = ( ::dbaccess::DST_EMBEDDED_HSQLDB != eType ); - } - break; + aReturn.bEnabled = !m_aTypeCollection.isEmbeddedDatabase(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL))); + break; case SID_DB_APP_DSRELDESIGN: aReturn.bEnabled = sal_True; break; @@ -955,36 +951,13 @@ FeatureState OApplicationController::GetState(sal_uInt16 _nId) const aReturn.bEnabled = getContainer()->getElementType() == E_TABLE && isConnected(); break; case SID_DB_APP_DSPROPS: - aReturn.bEnabled = m_xDataSource.is(); - if ( aReturn.bEnabled ) - { - ::dbaccess::DATASOURCE_TYPE eType = m_aTypeCollection.getType(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL))); - aReturn.bEnabled = ::dbaccess::DST_EMBEDDED_HSQLDB != eType - && ::dbaccess::DST_MOZILLA != eType - && ::dbaccess::DST_EVOLUTION != eType - && ::dbaccess::DST_EVOLUTION_GROUPWISE != eType - && ::dbaccess::DST_EVOLUTION_LDAP != eType - && ::dbaccess::DST_KAB != eType - && ::dbaccess::DST_MACAB != eType - && ::dbaccess::DST_OUTLOOK != eType - && ::dbaccess::DST_OUTLOOKEXP != eType; - } + aReturn.bEnabled = m_xDataSource.is() && m_aTypeCollection.isShowPropertiesEnabled(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL))); break; case SID_DB_APP_DSCONNECTION_TYPE: - aReturn.bEnabled = !isDataSourceReadOnly() && m_xDataSource.is(); - if ( aReturn.bEnabled ) - { - ::dbaccess::DATASOURCE_TYPE eType = m_aTypeCollection.getType(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL))); - aReturn.bEnabled = ::dbaccess::DST_EMBEDDED_HSQLDB != eType; - } + aReturn.bEnabled = !isDataSourceReadOnly() && m_xDataSource.is() && !m_aTypeCollection.isEmbeddedDatabase(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL))); break; case SID_DB_APP_DSADVANCED_SETTINGS: - aReturn.bEnabled = m_xDataSource.is(); - if ( aReturn.bEnabled ) - { - ::dbaccess::DATASOURCE_TYPE eType = m_aTypeCollection.getType( ::comphelper::getString( m_xDataSource->getPropertyValue( PROPERTY_URL ) ) ); - aReturn.bEnabled = AdvancedSettingsDialog::doesHaveAnyAdvancedSettings( eType ); - } + aReturn.bEnabled = m_xDataSource.is() && AdvancedSettingsDialog::doesHaveAnyAdvancedSettings( m_aTypeCollection.getType(::comphelper::getString( m_xDataSource->getPropertyValue( PROPERTY_URL ) )) ); break; case SID_DB_APP_CONVERTTOVIEW: aReturn.bEnabled = !isDataSourceReadOnly(); @@ -1034,15 +1007,16 @@ FeatureState OApplicationController::GetState(sal_uInt16 _nId) const aReturn.bEnabled = m_xDataSource.is(); if ( aReturn.bEnabled ) { - ::dbaccess::DATASOURCE_TYPE eType = m_aTypeCollection.getType(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL))); + ::rtl::OUString sURL; + m_xDataSource->getPropertyValue(PROPERTY_URL) >>= sURL; ::rtl::OUString sDSTypeName; - if ( m_aTypeCollection.isEmbeddedDatabase( eType ) ) + if ( m_aTypeCollection.isEmbeddedDatabase( sURL ) ) { sDSTypeName = String( ModuleRes( RID_STR_EMBEDDED_DATABASE ) ); } else { - sDSTypeName = m_aTypeCollection.getTypeDisplayName(eType); + sDSTypeName = m_aTypeCollection.getTypeDisplayName(sURL); } aReturn.sTitle = sDSTypeName; } @@ -1053,8 +1027,6 @@ FeatureState OApplicationController::GetState(sal_uInt16 _nId) const { ::rtl::OUString sURL; m_xDataSource->getPropertyValue(PROPERTY_URL) >>= sURL; - ::dbaccess::DATASOURCE_TYPE eType = m_aTypeCollection.getType( sURL ); - String sDatabaseName; String sHostName; sal_Int32 nPortNumber( -1 ); @@ -1063,7 +1035,7 @@ FeatureState OApplicationController::GetState(sal_uInt16 _nId) const if ( !sDatabaseName.Len() ) sDatabaseName = m_aTypeCollection.cutPrefix( sURL ); - if ( m_aTypeCollection.isFileSystemBased(eType) ) + if ( m_aTypeCollection.isFileSystemBased(sURL) ) { sDatabaseName = SvtPathOptions().SubstituteVariable( sDatabaseName ); if ( sDatabaseName.Len() ) @@ -1075,7 +1047,7 @@ FeatureState OApplicationController::GetState(sal_uInt16 _nId) const } if ( sDatabaseName.Len() == 0 ) - sDatabaseName = m_aTypeCollection.getTypeDisplayName( eType ); + sDatabaseName = m_aTypeCollection.getTypeDisplayName( sURL ); aReturn.sTitle = sDatabaseName; } diff --git a/dbaccess/source/ui/control/FieldDescControl.cxx b/dbaccess/source/ui/control/FieldDescControl.cxx index a9c757a3cf70..4d9e81bc1f83 100644 --- a/dbaccess/source/ui/control/FieldDescControl.cxx +++ b/dbaccess/source/ui/control/FieldDescControl.cxx @@ -963,7 +963,8 @@ void OFieldDescControl::ActivateAggregate( EControlType eType ) { const OTypeInfoMap* pTypeInfo = getTypeInfo(); OTypeInfoMap::const_iterator aIter = pTypeInfo->begin(); - for(;aIter != pTypeInfo->end();++aIter) + OTypeInfoMap::const_iterator aEnd = pTypeInfo->end(); + for(;aIter != aEnd;++aIter) m_pType->InsertEntry( aIter->second->aUIName ); } m_pType->SelectEntryPos(0); diff --git a/dbaccess/source/ui/control/RelationControl.cxx b/dbaccess/source/ui/control/RelationControl.cxx index 08416eb7496e..49d493ad8806 100644 --- a/dbaccess/source/ui/control/RelationControl.cxx +++ b/dbaccess/source/ui/control/RelationControl.cxx @@ -538,7 +538,8 @@ OTableListBoxControl::OTableListBoxControl( Window* _pParent // die Namen aller TabWins einsammeln OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableMap->begin(); - for(;aIter != m_pTableMap->end();++aIter) + OJoinTableView::OTableWindowMap::const_iterator aEnd = m_pTableMap->end(); + for(;aIter != aEnd;++aIter) { m_lmbLeftTable.InsertEntry(aIter->first); m_lmbRightTable.InsertEntry(aIter->first); diff --git a/dbaccess/source/ui/control/curledit.cxx b/dbaccess/source/ui/control/curledit.cxx index 8dc6cd76abb8..02bddf81ac67 100644 --- a/dbaccess/source/ui/control/curledit.cxx +++ b/dbaccess/source/ui/control/curledit.cxx @@ -48,6 +48,7 @@ namespace dbaui //========================================================================= OConnectionURLEdit::OConnectionURLEdit(Window* _pParent, const ResId& _rResId,BOOL _bShowPrefix) :Edit(_pParent, _rResId) + ,m_pTypeCollection(NULL) ,m_pForcedPrefix(NULL) ,m_bShowPrefix(_bShowPrefix) { @@ -111,13 +112,7 @@ void OConnectionURLEdit::SetText(const String& _rStr, const Selection& /*_rNewSe if (!bIsEmpty) { // determine the type of the new URL described by the new text - ::dbaccess::DATASOURCE_TYPE eType = m_aTypeCollection.getType(_rStr); - // and the prefix belonging to this type - if ( ::dbaccess::DST_UNKNOWN != eType) - sPrefix = m_aTypeCollection.getDatasourcePrefix(eType); - else { - DBG_ERROR("OConnectionURLEdit::SetText : the new text is no valid connection URL!"); - } + sPrefix = m_pTypeCollection->getPrefix(_rStr); } // the fixed text gets the prefix @@ -139,10 +134,10 @@ void OConnectionURLEdit::SetText(const String& _rStr, const Selection& /*_rNewSe GetSubEdit()->Show(); // do the real SetTex -// Edit::SetText(bIsEmpty ? _rStr : m_aTypeCollection.cutPrefix(_rStr), _rNewSelection); +// Edit::SetText(bIsEmpty ? _rStr : m_pTypeCollection->cutPrefix(_rStr), _rNewSelection); String sNewText( _rStr ); if ( !bIsEmpty ) - sNewText =m_aTypeCollection.cutPrefix( _rStr ); + sNewText = m_pTypeCollection->cutPrefix( _rStr ); Edit::SetText( sNewText ); } diff --git a/dbaccess/source/ui/control/toolboxcontroller.cxx b/dbaccess/source/ui/control/toolboxcontroller.cxx index a3608f49828a..86f5d02f5054 100644 --- a/dbaccess/source/ui/control/toolboxcontroller.cxx +++ b/dbaccess/source/ui/control/toolboxcontroller.cxx @@ -175,7 +175,8 @@ namespace dbaui } TCommandState::iterator aIter = m_aStates.begin(); - for (; aIter != m_aStates.end(); ++aIter) + TCommandState::iterator aEnd = m_aStates.end(); + for (; aIter != aEnd; ++aIter) addStatusListener(aIter->first); ToolBox* pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent())); diff --git a/dbaccess/source/ui/dlg/AdabasStatDlg.cxx b/dbaccess/source/ui/dlg/AdabasStatDlg.cxx deleted file mode 100644 index 459d8ac1ba4d..000000000000 --- a/dbaccess/source/ui/dlg/AdabasStatDlg.cxx +++ /dev/null @@ -1,208 +0,0 @@ -/************************************************************************* - * - * 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: AdabasStatDlg.cxx,v $ - * $Revision: 1.15.68.1 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_dbaccess.hxx" - -#ifndef DBAUI_ADABASSTATDLG_HXX -#include "AdabasStatDlg.hxx" -#endif -#ifndef DBAUI_ADABASSTATDLG_HRC -#include "AdabasStatDlg.hrc" -#endif -#ifndef _DBU_DLG_HRC_ -#include "dbu_dlg.hrc" -#endif -#ifndef _DBAUI_DATASOURCEITEMS_HXX_ -#include "dsitems.hxx" -#endif -#ifndef _SFXSTRITEM_HXX -#include <svtools/stritem.hxx> -#endif -#ifndef _SFXENUMITEM_HXX -#include <svtools/eitem.hxx> -#endif -#ifndef _SFXINTITEM_HXX -#include <svtools/intitem.hxx> -#endif -#ifndef _VCL_STDTEXT_HXX -#include <vcl/stdtext.hxx> -#endif -#ifndef _SV_MSGBOX_HXX -#include <vcl/msgbox.hxx> -#endif -#ifndef _DBAUI_DATASOURCEITEMS_HXX_ -#include "dsitems.hxx" -#endif -#ifndef DBAUI_DRIVERSETTINGS_HXX -#include "DriverSettings.hxx" -#endif -#ifndef _DBAUI_DBADMINIMPL_HXX_ -#include "DbAdminImpl.hxx" -#endif -#ifndef _DBAUI_PROPERTYSETITEM_HXX_ -#include "propertysetitem.hxx" -#endif -#ifndef _DBAUI_ADMINPAGES_HXX_ -#include "adminpages.hxx" -#endif -//......................................................................... -namespace dbaui -{ -//......................................................................... - using namespace ::com::sun::star::uno; - using namespace ::com::sun::star::beans; - using namespace ::com::sun::star::lang; - using namespace ::com::sun::star::sdbc; - - //======================================================================== - //= OAdabasStatPageDlg -DBG_NAME(OAdabasStatPageDlg) -//======================================================================== - OAdabasStatPageDlg::OAdabasStatPageDlg(Window* _pParent - , SfxItemSet* _pItems - ,const Reference< XMultiServiceFactory >& _rxORB - ,const ::com::sun::star::uno::Any& _aDataSourceName) - :SfxTabDialog(_pParent, ModuleRes(DLG_DATABASE_ADABASADMIN), _pItems) - { - DBG_CTOR(OAdabasStatPageDlg,NULL); - - m_pImpl = ::std::auto_ptr<ODbDataSourceAdministrationHelper>(new ODbDataSourceAdministrationHelper(_rxORB,_pParent,this)); - m_pImpl->setDataSourceOrName(_aDataSourceName); - Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource(); - m_pImpl->translateProperties(xDatasource, *GetInputSetImpl()); - SetInputSet(GetInputSetImpl()); - // propagate this set as our new input set and reset the example set - delete pExampleSet; - pExampleSet = new SfxItemSet(*GetInputSetImpl()); - - ::dbaccess::DATASOURCE_TYPE eType = m_pImpl->getDatasourceType(*GetInputSetImpl()); - - switch ( eType ) - { - case ::dbaccess::DST_ADABAS: - AddTabPage(TAB_PAG_ADABAS_SETTINGS, String(ModuleRes(STR_PAGETITLE_ADABAS_STATISTIC)), ODriversSettings::CreateAdabas,0, sal_False, 1); - break; - default: - OSL_ENSURE(0,"Not supported for other types thasn adabas!"); - break; - } - - // remove the reset button - it's meaning is much too ambiguous in this dialog - RemoveResetButton(); - FreeResource(); - } - - // ----------------------------------------------------------------------- - OAdabasStatPageDlg::~OAdabasStatPageDlg() - { - SetInputSet(NULL); - DELETEZ(pExampleSet); - - DBG_DTOR(OAdabasStatPageDlg,NULL); - } - // ----------------------------------------------------------------------- - short OAdabasStatPageDlg::Execute() - { - short nRet = SfxTabDialog::Execute(); - if ( nRet == RET_OK ) - { - pExampleSet->Put(*GetOutputItemSet()); - m_pImpl->saveChanges(*pExampleSet); - } - return nRet; - } - //------------------------------------------------------------------------- - void OAdabasStatPageDlg::PageCreated(USHORT _nId, SfxTabPage& _rPage) - { - // register ourself as modified listener - static_cast<OGenericAdministrationPage&>(_rPage).SetServiceFactory(m_pImpl->getORB()); - static_cast<OGenericAdministrationPage&>(_rPage).SetAdminDialog(this,this); - - AdjustLayout(); - Window *pWin = GetViewWindow(); - if(pWin) - pWin->Invalidate(); - - SfxTabDialog::PageCreated(_nId, _rPage); - } - // ----------------------------------------------------------------------------- - const SfxItemSet* OAdabasStatPageDlg::getOutputSet() const - { - return GetExampleSet(); - } - // ----------------------------------------------------------------------------- - SfxItemSet* OAdabasStatPageDlg::getWriteOutputSet() - { - return pExampleSet; - } - // ----------------------------------------------------------------------------- - ::std::pair< Reference<XConnection>,sal_Bool> OAdabasStatPageDlg::createConnection() - { - return m_pImpl->createConnection(); - } - // ----------------------------------------------------------------------------- - Reference< XMultiServiceFactory > OAdabasStatPageDlg::getORB() const - { - return m_pImpl->getORB(); - } - // ----------------------------------------------------------------------------- - Reference< XDriver > OAdabasStatPageDlg::getDriver() - { - return m_pImpl->getDriver(); - } - // ----------------------------------------------------------------------------- - ::dbaccess::DATASOURCE_TYPE OAdabasStatPageDlg::getDatasourceType(const SfxItemSet& _rSet) const - { - return m_pImpl->getDatasourceType(_rSet); - } - // ----------------------------------------------------------------------------- - void OAdabasStatPageDlg::clearPassword() - { - m_pImpl->clearPassword(); - } - // ----------------------------------------------------------------------------- - void OAdabasStatPageDlg::setTitle(const ::rtl::OUString& _sTitle) - { - SetText(_sTitle); - } - //------------------------------------------------------------------------- - void OAdabasStatPageDlg::enableConfirmSettings( bool _bEnable ) - { - (void)_bEnable; - } - //------------------------------------------------------------------------- - sal_Bool OAdabasStatPageDlg::saveDatasource() - { - return PrepareLeaveCurrentPage(); - } -//......................................................................... -} // namespace dbaui -//......................................................................... diff --git a/dbaccess/source/ui/dlg/AdabasStatDlg.hrc b/dbaccess/source/ui/dlg/AdabasStatDlg.hrc deleted file mode 100644 index 07151f981ab5..000000000000 --- a/dbaccess/source/ui/dlg/AdabasStatDlg.hrc +++ /dev/null @@ -1,36 +0,0 @@ -/************************************************************************* - * - * 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: AdabasStatDlg.hrc,v $ - * $Revision: 1.4 $ - * - * 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 DBAUI_ADABASSTATDLG_HRC -#define DBAUI_ADABASSTATDLG_HRC - -#define STR_PAGETITLE_ADABAS_STATISTIC 1 - - -#endif // DBAUI_ADABASSTATDLG_HRC diff --git a/dbaccess/source/ui/dlg/AdabasStatDlg.src b/dbaccess/source/ui/dlg/AdabasStatDlg.src deleted file mode 100644 index 5e5407e9b9c6..000000000000 --- a/dbaccess/source/ui/dlg/AdabasStatDlg.src +++ /dev/null @@ -1,64 +0,0 @@ -/************************************************************************* - * - * 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: AdabasStatDlg.src,v $ - * $Revision: 1.5 $ - * - * 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 _DBA_DBACCESS_HELPID_HRC_ -#include "dbaccess_helpid.hrc" -#endif -#ifndef DBAUI_ADABASSTATDLG_HRC -#include "AdabasStatDlg.hrc" -#endif -#ifndef _DBU_DLG_HRC_ -#include "dbu_dlg.hrc" -#endif - - -TabDialog DLG_DATABASE_ADABASADMIN -{ - OutputSize = TRUE ; - SVLook = TRUE ; - Moveable = TRUE ; - Closeable = TRUE ; - Hide = TRUE; - HelpId = HID_DSADMIN_ADABASADMIN; - - TabControl 1 - { - OutputSize = TRUE ; - HelpId = HID_DSADMIN_TABCONTROL; - SingleLine=TRUE; - }; - String STR_PAGETITLE_ADABAS_STATISTIC - { - Text [ en-US ] = "Adabas D Statistics"; - }; - - Text [ en-US ] = "Advanced Properties" ; -}; - diff --git a/dbaccess/source/ui/dlg/ConnectionHelper.cxx b/dbaccess/source/ui/dlg/ConnectionHelper.cxx index 16e4b51da212..ba0925d224ad 100644 --- a/dbaccess/source/ui/dlg/ConnectionHelper.cxx +++ b/dbaccess/source/ui/dlg/ConnectionHelper.cxx @@ -207,6 +207,7 @@ DBG_NAME(OConnectionHelper) m_pCollection = pCollectionItem->getCollection(); m_aPB_Connection.SetClickHdl(LINK(this, OConnectionHelper, OnBrowseConnections)); DBG_ASSERT(m_pCollection, "OConnectionHelper::OConnectionHelper : really need a DSN type collection !"); + m_aConnectionURL.SetTypeCollection(m_pCollection); } @@ -226,7 +227,7 @@ DBG_NAME(OConnectionHelper) m_aFT_Connection.Show(); m_aConnectionURL.Show(); - m_aConnectionURL.ShowPrefix( ::dbaccess::DST_JDBC == m_eType ); + m_aConnectionURL.ShowPrefix( ::dbaccess::DST_JDBC == m_pCollection->determineType(m_eType) ); BOOL bEnableBrowseButton = m_pCollection->supportsBrowsing( m_eType ); m_aPB_Connection.Show( bEnableBrowseButton ); @@ -253,21 +254,16 @@ DBG_NAME(OConnectionHelper) if ( !m_pAdminDialog ) return; - switch ( m_eType ) - { - case ::dbaccess::DST_CALC: + if ( m_pCollection->isFileSystemBased(m_eType) ) m_pAdminDialog->enableConfirmSettings( getURLNoPrefix().Len() > 0 ); - break; - default: - break; - } } // ----------------------------------------------------------------------- IMPL_LINK(OConnectionHelper, OnBrowseConnections, PushButton*, /*_pButton*/) { OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF"); - switch ( m_eType ) + const ::dbaccess::DATASOURCE_TYPE eType = m_pCollection->determineType(m_eType); + switch ( eType ) { case ::dbaccess::DST_DBASE: case ::dbaccess::DST_FLAT: @@ -324,15 +320,16 @@ DBG_NAME(OConnectionHelper) break; case ::dbaccess::DST_CALC: { + SvtModuleOptions aModule; ::sfx2::FileDialogHelper aFileDlg(WB_3DLOOK | WB_STDMODAL | WB_OPEN - ,SvtModuleOptions().GetFactoryEmptyDocumentURL(SvtModuleOptions::E_CALC) + ,aModule.GetFactoryEmptyDocumentURL(SvtModuleOptions::E_CALC) ,SFX_FILTER_IMPORT); askForFileName(aFileDlg); } break; case ::dbaccess::DST_MSACCESS: { - ::rtl::OUString sExt(RTL_CONSTASCII_USTRINGPARAM("*.mdb")); + const ::rtl::OUString sExt(RTL_CONSTASCII_USTRINGPARAM("*.mdb")); String sFilterName(ModuleRes (STR_MSACCESS_FILTERNAME)); ::sfx2::FileDialogHelper aFileDlg(WB_3DLOOK | WB_STDMODAL | WB_OPEN); aFileDlg.AddFilter(sFilterName,sExt); @@ -342,7 +339,7 @@ DBG_NAME(OConnectionHelper) break; case ::dbaccess::DST_MSACCESS_2007: { - ::rtl::OUString sAccdb(RTL_CONSTASCII_USTRINGPARAM("*.accdb")); + const ::rtl::OUString sAccdb(RTL_CONSTASCII_USTRINGPARAM("*.accdb")); String sFilterName2(ModuleRes (STR_MSACCESS_2007_FILTERNAME)); ::sfx2::FileDialogHelper aFileDlg(WB_3DLOOK | WB_STDMODAL | WB_OPEN); aFileDlg.AddFilter(sFilterName2,sAccdb); @@ -413,7 +410,7 @@ DBG_NAME(OConnectionHelper) aInstalledDBs = getInstalledAdabasDBs(sAdabasConfigDir,sAdabasWorkDir); } - ODatasourceSelectDialog aSelector(GetParent(), aInstalledDBs, m_eType,m_pItemSetHelper->getWriteOutputSet()); + ODatasourceSelectDialog aSelector(GetParent(), aInstalledDBs, true,m_pItemSetHelper->getWriteOutputSet()); if (RET_OK == aSelector.Execute()) { setURLNoPrefix(aSelector.GetSelected()); @@ -435,9 +432,9 @@ DBG_NAME(OConnectionHelper) case ::dbaccess::DST_ODBC: { // collect all ODBC data source names - ::rtl::OUString sCurrDatasource=getURLNoPrefix(); + ::rtl::OUString sCurrDatasource = getURLNoPrefix(); ::rtl::OUString sDataSource; - if ( getSelectedDataSource(m_eType,sDataSource,sCurrDatasource) && sDataSource.getLength() ) + if ( getSelectedDataSource(sDataSource,sCurrDatasource) && sDataSource.getLength() ) { setURLNoPrefix(sDataSource); SetRoadmapStateValue(sal_True); @@ -469,7 +466,7 @@ DBG_NAME(OConnectionHelper) case ::dbaccess::DST_THUNDERBIRD: { MozillaProductType profileType = MozillaProductType_Mozilla; - if (m_eType == ::dbaccess::DST_THUNDERBIRD) + if (eType == ::dbaccess::DST_THUNDERBIRD) profileType = MozillaProductType_Thunderbird; Reference<XMultiServiceFactory> xFactory = ::comphelper::getProcessServiceFactory(); @@ -496,7 +493,7 @@ DBG_NAME(OConnectionHelper) // excute the select dialog - ODatasourceSelectDialog aSelector(GetParent(), aProfiles, m_eType); + ODatasourceSelectDialog aSelector(GetParent(), aProfiles, eType); ::rtl::OUString sOldProfile=getURLNoPrefix(); if (sOldProfile.getLength()) @@ -539,7 +536,7 @@ DBG_NAME(OConnectionHelper) String sTypePrefix, sFileURLEncoded; if ( _bPrefix ) { - sTypePrefix = m_pCollection->getDatasourcePrefix( m_eType ); + sTypePrefix = m_pCollection->getPrefix( m_eType ); sFileURLEncoded = m_pCollection->cutPrefix( sURL ); } else @@ -585,7 +582,7 @@ DBG_NAME(OConnectionHelper) String sTypePrefix, sFileURLDecoded; if ( _bPrefix ) { - sTypePrefix = m_pCollection->getDatasourcePrefix( m_eType ); + sTypePrefix = m_pCollection->getPrefix( m_eType ); sFileURLDecoded = m_pCollection->cutPrefix( sURL ); } else @@ -770,10 +767,12 @@ DBG_NAME(OConnectionHelper) aConfigDBs = getInstalledAdabasDBDirs(sAdabasConfigDir,::ucbhelper::INCLUDE_DOCUMENTS_ONLY); aWrkDBs = getInstalledAdabasDBDirs(sAdabasWorkDir,::ucbhelper::INCLUDE_FOLDERS_ONLY); ConstStringBagIterator aOuter = aConfigDBs.begin(); - for(;aOuter != aConfigDBs.end();++aOuter) + ConstStringBagIterator aOuterEnd = aConfigDBs.end(); + for(;aOuter != aOuterEnd;++aOuter) { ConstStringBagIterator aInner = aWrkDBs.begin(); - for (;aInner != aWrkDBs.end(); ++aInner) + ConstStringBagIterator aInnerEnd = aWrkDBs.end(); + for (;aInner != aInnerEnd; ++aInner) { if (aInner->equalsIgnoreAsciiCase(*aOuter)) { @@ -811,11 +810,8 @@ DBG_NAME(OConnectionHelper) //------------------------------------------------------------------------- long OConnectionHelper::PreNotify( NotifyEvent& _rNEvt ) { - if ( ( ::dbaccess::DST_DBASE == m_eType) - || ( ::dbaccess::DST_FLAT == m_eType) - || ( ::dbaccess::DST_MSACCESS == m_eType) - || ( ::dbaccess::DST_MSACCESS_2007 == m_eType) - || ( ::dbaccess::DST_CALC == m_eType) ) + if ( m_pCollection->isFileSystemBased(m_eType) ) + { switch (_rNEvt.GetType()) { case EVENT_GETFOCUS: @@ -832,7 +828,8 @@ DBG_NAME(OConnectionHelper) return 1L; // handled } break; - } + } // switch (_rNEvt.GetType()) + } return OGenericAdministrationPage::PreNotify( _rNEvt ); } @@ -933,13 +930,7 @@ DBG_NAME(OConnectionHelper) sOldPath = m_aConnectionURL.GetSavedValueNoPrefix(); sURL = m_aConnectionURL.GetTextNoPrefix(); - switch ( m_eType ) - { - case ::dbaccess::DST_DBASE: - case ::dbaccess::DST_FLAT: - case ::dbaccess::DST_MSACCESS: - case ::dbaccess::DST_MSACCESS_2007: - case ::dbaccess::DST_CALC: + if ( m_pCollection->isFileSystemBased(m_eType) ) { if ( ( sURL != sOldPath ) && ( 0 != sURL.Len() ) ) { // the text changed since entering the control @@ -948,7 +939,9 @@ DBG_NAME(OConnectionHelper) OFileNotation aTransformer(sURL); sURL = aTransformer.get(OFileNotation::N_URL); - if ( ( ::dbaccess::DST_CALC == m_eType) || ( ::dbaccess::DST_MSACCESS == m_eType) || ( ::dbaccess::DST_MSACCESS_2007 == m_eType) ) + const ::dbaccess::DATASOURCE_TYPE eType = m_pCollection->determineType(m_eType); + + if ( ( ::dbaccess::DST_CALC == eType) || ( ::dbaccess::DST_MSACCESS == eType) || ( ::dbaccess::DST_MSACCESS_2007 == eType) ) { // #106016# -------------------------- if( pathExists(sURL, sal_True) == PATH_NOT_EXIST ) { @@ -978,10 +971,6 @@ DBG_NAME(OConnectionHelper) } } } - break; - default: - break; - } setURLNoPrefix(sURL); m_aConnectionURL.SaveValueNoPrefix(); diff --git a/dbaccess/source/ui/dlg/ConnectionHelper.hxx b/dbaccess/source/ui/dlg/ConnectionHelper.hxx index cb9e4ff19816..4839bae4f364 100644 --- a/dbaccess/source/ui/dlg/ConnectionHelper.hxx +++ b/dbaccess/source/ui/dlg/ConnectionHelper.hxx @@ -77,8 +77,7 @@ namespace dbaui FixedText m_aFT_Connection; OConnectionURLEdit m_aConnectionURL; PushButton m_aPB_Connection; - ::dbaccess::DATASOURCE_TYPE - m_eType; // the type can't be changed in this class, so we hold it as member. + ::rtl::OUString m_eType; // the type can't be changed in this class, so we hold it as member. public: @@ -122,7 +121,6 @@ namespace dbaui virtual void SetServiceFactory(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB) { OGenericAdministrationPage::SetServiceFactory(_rxORB); - m_aConnectionURL.initializeTypeCollection(m_xORB); } protected: diff --git a/dbaccess/source/ui/dlg/ConnectionPage.cxx b/dbaccess/source/ui/dlg/ConnectionPage.cxx index a032b6a47908..db21de4d9a76 100644 --- a/dbaccess/source/ui/dlg/ConnectionPage.cxx +++ b/dbaccess/source/ui/dlg/ConnectionPage.cxx @@ -200,7 +200,6 @@ namespace dbaui DBG_NAME(OConnectionTabPage) OConnectionTabPage::OConnectionTabPage(Window* pParent, const SfxItemSet& _rCoreAttrs) :OConnectionHelper(pParent, ModuleRes(PAGE_CONNECTION), _rCoreAttrs) - ,m_pCollection(NULL) ,m_bUserGrabFocus(sal_True) ,m_aFL1(this, ModuleRes(FL_SEPARATOR1)) ,m_aFL2(this, ModuleRes(FL_SEPARATOR2)) @@ -223,12 +222,6 @@ namespace dbaui m_aTestConnection.SetClickHdl(LINK(this,OGenericAdministrationPage,OnTestConnectionClickHdl)); m_aTestJavaDriver.SetClickHdl(LINK(this,OConnectionTabPage,OnTestJavaClickHdl)); - // extract the datasource type collection from the item set - DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _rCoreAttrs.GetItem(DSID_TYPECOLLECTION)); - if (pCollectionItem) - m_pCollection = pCollectionItem->getCollection(); - DBG_ASSERT(m_pCollection, "OConnectionTabPage::OConnectionTabPage : really need a DSN type collection !"); - FreeResource(); } @@ -249,7 +242,8 @@ namespace dbaui OConnectionHelper::implInitControls( _rSet, _bSaveValue); LocalResourceAccess aLocRes( PAGE_CONNECTION, RSC_TABPAGE ); - switch( m_eType ) + ::dbaccess::DATASOURCE_TYPE eType = m_pCollection->determineType(m_eType); + switch( eType ) { case ::dbaccess::DST_DBASE: m_aFT_Connection.SetText(String(ModuleRes(STR_DBASE_PATH_OR_FILE))); @@ -287,7 +281,7 @@ namespace dbaui case ::dbaccess::DST_MYSQL_ODBC: case ::dbaccess::DST_ODBC: m_aFT_Connection.SetText(String(ModuleRes(STR_NAME_OF_ODBC_DATASOURCE))); - m_aConnectionURL.SetHelpId( m_eType == ::dbaccess::DST_MYSQL_ODBC ? HID_DSADMIN_MYSQL_ODBC_DATASOURCE : HID_DSADMIN_ODBC_DATASOURCE); + m_aConnectionURL.SetHelpId( eType == ::dbaccess::DST_MYSQL_ODBC ? HID_DSADMIN_MYSQL_ODBC_DATASOURCE : HID_DSADMIN_ODBC_DATASOURCE); break; case ::dbaccess::DST_LDAP: m_aFT_Connection.SetText(String(ModuleRes(STR_HOSTNAME))); @@ -319,8 +313,6 @@ namespace dbaui m_aConnectionURL.Hide(); break; case ::dbaccess::DST_JDBC: - m_aFT_Connection.SetText(String(ModuleRes(STR_COMMONURL))); - // run through default: m_aFT_Connection.SetText(String(ModuleRes(STR_COMMONURL))); break; @@ -355,8 +347,18 @@ namespace dbaui String sUrl = pUrlItem->GetValue(); setURL( sUrl ); - BOOL bEnableJDBC = m_eType == ::dbaccess::DST_JDBC; - m_aJavaDriver.SetText(pJdbcDrvItem->GetValue()); + const BOOL bEnableJDBC = m_pCollection->determineType(m_eType) == ::dbaccess::DST_JDBC; + if ( !pJdbcDrvItem->GetValue().Len() ) + { + String sDefaultJdbcDriverName = m_pCollection->getJavaDriverClass(m_eType); + if ( sDefaultJdbcDriverName.Len() ) + { + m_aJavaDriver.SetText(sDefaultJdbcDriverName); + m_aJavaDriver.SetModifyFlag(); + } + } // if ( !pJdbcDrvItem->GetValue().Len() ) + else + m_aJavaDriver.SetText(pJdbcDrvItem->GetValue()); m_aJavaDriverLabel.Show(bEnableJDBC); m_aJavaDriver.Show(bEnableJDBC); @@ -409,7 +411,7 @@ namespace dbaui fillBool(_rSet,&m_aPasswordRequired,DSID_PASSWORDREQUIRED,bChangedSomething); - if ( m_eType == ::dbaccess::DST_JDBC ) + if ( m_pCollection->determineType(m_eType) == ::dbaccess::DST_JDBC ) { fillString(_rSet,&m_aJavaDriver, DSID_JDBCDRIVERCLASS, bChangedSomething); } @@ -445,7 +447,7 @@ namespace dbaui { OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF"); BOOL bEnableTestConnection = !m_aConnectionURL.IsVisible() || (m_aConnectionURL.GetTextNoPrefix().Len() != 0); - if ( m_eType == ::dbaccess::DST_JDBC ) + if ( m_pCollection->determineType(m_eType) == ::dbaccess::DST_JDBC ) bEnableTestConnection = bEnableTestConnection && (m_aJavaDriver.GetText().Len() != 0); m_aTestConnection.Enable(bEnableTestConnection); return true; diff --git a/dbaccess/source/ui/dlg/ConnectionPage.hxx b/dbaccess/source/ui/dlg/ConnectionPage.hxx index 90a120a32ef8..8109d3a550f5 100644 --- a/dbaccess/source/ui/dlg/ConnectionPage.hxx +++ b/dbaccess/source/ui/dlg/ConnectionPage.hxx @@ -58,8 +58,6 @@ namespace dbaui */ class OConnectionTabPage : public OConnectionHelper { - ::dbaccess::ODsnTypeCollection* - m_pCollection; /// the DSN type collection instance sal_Bool m_bUserGrabFocus : 1; protected: // connection diff --git a/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx b/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx index 4af66d7581a0..6b22d79e4b18 100644 --- a/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx +++ b/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx @@ -272,20 +272,22 @@ namespace dbaui m_eType = m_pAdminDialog->getDatasourceType(_rSet); // special handling for oracle, this can only happen // if the user enters the same url as used for Oracle and we are on the JDBC path - if ( ::dbaccess::DST_ORACLE_JDBC == m_eType ) - m_eType = ::dbaccess::DST_JDBC; + //! TODO + //if ( ::dbaccess::DST_ORACLE_JDBC == m_eType ) + // m_eType = ::dbaccess::DST_JDBC; OConnectionHelper::implInitControls(_rSet, _bSaveValue); - if ( m_eType >= ::dbaccess::DST_USERDEFINE1 ) - { - String sDisplayName = m_pCollection->getTypeDisplayName(m_eType); - FixedText* ppTextControls[] ={&m_aFT_Connection}; - for (size_t i = 0; i < sizeof(ppTextControls)/sizeof(ppTextControls[0]); ++i) - { - ppTextControls[i]->SetText(sDisplayName); - } - } + //! TODO + //if ( m_eType >= ::dbaccess::DST_USERDEFINE1 ) + //{ + // String sDisplayName = m_pCollection->getTypeDisplayName(m_eType); + // FixedText* ppTextControls[] ={&m_aFT_Connection}; + // for (size_t i = 0; i < sizeof(ppTextControls)/sizeof(ppTextControls[0]); ++i) + // { + // ppTextControls[i]->SetText(sDisplayName); + // } + //} callModifiedHdl(); } diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx index aa3ad63f4377..cf472eae45f4 100644 --- a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx +++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx @@ -103,37 +103,16 @@ #include <svtools/filenotation.hxx> #endif -#ifndef _UNOTOOLS_LOCALFILEHELPER_HXX #include <unotools/localfilehelper.hxx> -#endif -#ifndef _UNOTOOLS_UCBHELPER_HXX #include <unotools/ucbhelper.hxx> -#endif -#ifndef _UCBHELPER_COMMANDENVIRONMENT_HXX #include <ucbhelper/commandenvironment.hxx> -#endif -#ifndef DBAUI_FILEPICKER_INTERACTION_HXX #include "finteraction.hxx" -#endif -#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ #include <connectivity/CommonTools.hxx> -#endif - -#ifndef _DBA_DBACCESS_HELPID_HRC_ +#include <connectivity/DriversConfig.hxx> #include "dbaccess_helpid.hrc" -#endif - -#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX #include <svtools/pathoptions.hxx> -#endif - -#ifndef SVTOOLS_INC_ROADMAPWIZARD_HXX #include <svtools/roadmapwizard.hxx> -#endif - -#ifndef DBAUI_TEXTCONNECTIONHELPER_HXX #include "TextConnectionHelper.hxx" -#endif //......................................................................... @@ -288,7 +267,7 @@ DBG_NAME(OTextConnectionPageSetup) pCollection = pCollectionItem->getCollection(); DBG_ASSERT(pCollection, "OLDAPConnectionPageSetup::FillItemSet : really need a DSN type collection !"); - String sUrl = pCollection->getDatasourcePrefix( ::dbaccess::DST_LDAP); + String sUrl = pCollection->getPrefix( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:address:ldap:"))); sUrl += m_aETHostServer.GetText(); _rSet.Put(SfxStringItem(DSID_CONNECTURL, sUrl)); bChangedSomething = sal_True; @@ -389,13 +368,10 @@ DBG_NAME(OMySQLIntroPageSetup) void OMySQLIntroPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool /*_bSaveValue*/) { DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _rSet.GetItem(DSID_TYPECOLLECTION)); - ::dbaccess::ODsnTypeCollection* pCollection = NULL; if (pCollectionItem) { - pCollection = pCollectionItem->getCollection(); - String sUrl = pCollection->getDatasourcePrefix( ::dbaccess::DST_MYSQL_NATIVE); - uno::Reference< sdbc::XDriverAccess > xDriverManager( m_xORB->createInstance( SERVICE_SDBC_DRIVERMANAGER ), uno::UNO_QUERY ); - if ( xDriverManager.is() && xDriverManager->getDriverByURL( sUrl ).is() ) + ::dbaccess::ODsnTypeCollection* pCollection = pCollectionItem->getCollection(); + if ( pCollection->getPrefix(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:mysqlc:"))).Len() ) { m_aRB_NATIVEDatabase.Show(); m_aRB_JDBCDatabase.SetState(sal_False); @@ -443,7 +419,6 @@ DBG_NAME(OMySQLIntroPageSetup) _rAttrSet, DSID_MYSQL_PORTNUMBER , STR_MYSQL_DEFAULT, - "com.mysql.jdbc.Driver", STR_MYSQLJDBC_HELPTEXT, STR_MYSQLJDBC_HEADERTEXT, STR_MYSQL_DRIVERCLASSTEXT) ); @@ -457,7 +432,6 @@ DBG_NAME(OMySQLIntroPageSetup) _rAttrSet, DSID_MYSQL_PORTNUMBER , STR_MYSQL_DEFAULT, - NULL, STR_MYSQLJDBC_HELPTEXT, STR_MYSQLJDBC_HEADERTEXT, 0) ); @@ -472,7 +446,6 @@ DBG_NAME(OMySQLIntroPageSetup) _rAttrSet, DSID_ORACLE_PORTNUMBER, STR_ORACLE_DEFAULT, - "oracle.jdbc.driver.OracleDriver", STR_ORACLE_HELPTEXT, STR_ORACLE_HEADERTEXT, STR_ORACLE_DRIVERCLASSTEXT) ); @@ -482,7 +455,7 @@ DBG_NAME(OMySQLIntroPageSetup) //======================================================================== //= OMySQLJDBCConnectionPageSetup //======================================================================== - OGeneralSpecialJDBCConnectionPageSetup::OGeneralSpecialJDBCConnectionPageSetup( Window* pParent,USHORT _nResId, const SfxItemSet& _rCoreAttrs ,USHORT _nPortId, USHORT _nDefaultPortResId, const sal_Char* _pDriverName, USHORT _nHelpTextResId, USHORT _nHeaderTextResId, USHORT _nDriverClassId) + OGeneralSpecialJDBCConnectionPageSetup::OGeneralSpecialJDBCConnectionPageSetup( Window* pParent,USHORT _nResId, const SfxItemSet& _rCoreAttrs ,USHORT _nPortId, USHORT _nDefaultPortResId, USHORT _nHelpTextResId, USHORT _nHeaderTextResId, USHORT _nDriverClassId) :OGenericAdministrationPage(pParent, ModuleRes(_nResId), _rCoreAttrs) ,m_pFTHeaderText (NULL) ,m_aFTHelpText (this, ModuleRes(FT_AUTOWIZARDHELPTEXT)) @@ -533,7 +506,15 @@ DBG_NAME(OMySQLIntroPageSetup) m_aNFPortNumber.SetUseThousandSep(sal_False); if ( m_bUseClass ) - m_sDefaultJdbcDriverName = String::CreateFromAscii(_pDriverName); + { + SFX_ITEMSET_GET(_rCoreAttrs, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True); + SFX_ITEMSET_GET(_rCoreAttrs, pTypesItem, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True); + ::dbaccess::ODsnTypeCollection* pTypeCollection = pTypesItem ? pTypesItem->getCollection() : NULL; + if (pTypeCollection && pUrlItem && pUrlItem->GetValue().Len() ) + { + m_sDefaultJdbcDriverName = pTypeCollection->getJavaDriverClass(pUrlItem->GetValue()); + } + } SetRoadmapStateValue(sal_False); FreeResource(); } @@ -710,8 +691,20 @@ DBG_NAME(OMySQLIntroPageSetup) if ( bValid ) { - m_aETDriverClass.SetText(pDrvItem->GetValue()); - m_aETDriverClass.ClearModifyFlag(); + if ( !pDrvItem->GetValue().Len() ) + { + String sDefaultJdbcDriverName = m_pCollection->getJavaDriverClass(m_eType); + if ( sDefaultJdbcDriverName.Len() ) + { + m_aETDriverClass.SetText(sDefaultJdbcDriverName); + m_aETDriverClass.SetModifyFlag(); + } // if ( sDefaultJdbcDriverName.Len() ) + } // if ( !pJdbcDrvItem->GetValue().Len() ) + else + { + m_aETDriverClass.SetText(pDrvItem->GetValue()); + m_aETDriverClass.ClearModifyFlag(); + } } sal_Bool bEnable = pDrvItem->GetValue().Len() != 0; m_aPBTestJavaDriver.Enable(bEnable); diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx b/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx index d2f1bac78057..0bbd3cbf729c 100644 --- a/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx +++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx @@ -152,7 +152,6 @@ namespace dbaui , const SfxItemSet& _rCoreAttrs , USHORT _nPortId , USHORT _nDefaultPortResId - , const sal_Char* _pDriverName , USHORT _nHelpTextResId , USHORT _nHeaderTextResId , USHORT _nDriverClassId ); diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.cxx b/dbaccess/source/ui/dlg/DbAdminImpl.cxx index 8018b424ee95..4390cc6b8dc4 100644 --- a/dbaccess/source/ui/dlg/DbAdminImpl.cxx +++ b/dbaccess/source/ui/dlg/DbAdminImpl.cxx @@ -61,6 +61,7 @@ #ifndef _DBHELPER_DBEXCEPTION_HXX_ #include <connectivity/dbexception.hxx> #endif +#include <connectivity/DriversConfig.hxx> #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ #include <com/sun/star/beans/PropertyAttribute.hpp> #endif @@ -472,21 +473,14 @@ Reference< XPropertySet > ODbDataSourceAdministrationHelper::getCurrentDataSourc return m_xDatasource; } //------------------------------------------------------------------------- -::dbaccess::DATASOURCE_TYPE ODbDataSourceAdministrationHelper::getDatasourceType( const SfxItemSet& _rSet ) +::rtl::OUString ODbDataSourceAdministrationHelper::getDatasourceType( const SfxItemSet& _rSet ) { SFX_ITEMSET_GET( _rSet, pConnectURL, SfxStringItem, DSID_CONNECTURL, sal_True ); - SFX_ITEMSET_GET( _rSet, pTypeCollection, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True ); - DBG_ASSERT( pConnectURL && pTypeCollection, "ODbDataSourceAdministrationHelper::getDatasourceType: invalid items in the source set!" ); - if ( !pConnectURL || !pTypeCollection ) - return ::dbaccess::DST_UNKNOWN; - - String sConnectURL = pConnectURL->GetValue(); + DBG_ASSERT( pConnectURL , "ODbDataSourceAdministrationHelper::getDatasourceType: invalid items in the source set!" ); + SFX_ITEMSET_GET(_rSet, pTypeCollection, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True); + DBG_ASSERT(pTypeCollection, "ODbDataSourceAdministrationHelper::getDatasourceType: invalid items in the source set!"); ::dbaccess::ODsnTypeCollection* pCollection = pTypeCollection->getCollection(); - DBG_ASSERT( pCollection, "ODbDataSourceAdministrationHelper::getDatasourceType: invalid type collection!" ); - if ( !pCollection ) - return ::dbaccess::DST_UNKNOWN; - - return pCollection->getType( sConnectURL ); + return pCollection->getType(pConnectURL->GetValue()); } //------------------------------------------------------------------------- @@ -499,7 +493,7 @@ String ODbDataSourceAdministrationHelper::getConnectionURL() const { String sNewUrl; - ::dbaccess::DATASOURCE_TYPE eType = getDatasourceType(*m_pItemSetHelper->getOutputSet()); + ::rtl::OUString eType = getDatasourceType(*m_pItemSetHelper->getOutputSet()); SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True); SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pTypeCollection, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True); @@ -509,9 +503,7 @@ String ODbDataSourceAdministrationHelper::getConnectionURL() const ::dbaccess::ODsnTypeCollection* pCollection = pTypeCollection->getCollection(); DBG_ASSERT(pCollection, "ODbDataSourceAdministrationHelper::getDatasourceType: invalid type collection!"); - - - switch( eType ) + switch( pCollection->determineType(eType) ) { case ::dbaccess::DST_DBASE: case ::dbaccess::DST_FLAT: @@ -599,7 +591,7 @@ String ODbDataSourceAdministrationHelper::getConnectionURL() const } if ( sNewUrl.Len() ) { - String sUrl = pCollection->getDatasourcePrefix(eType); + String sUrl = pCollection->getPrefix(eType); sUrl += sNewUrl; sNewUrl = sUrl; } @@ -672,18 +664,21 @@ void ODbDataSourceAdministrationHelper::translateProperties(const Reference< XPr } // go through all known translations and check if we have such a setting - PropertyValue aSearchFor; - for ( ConstMapInt2StringIterator aIndirect = m_aIndirectPropTranslator.begin(); - aIndirect != m_aIndirectPropTranslator.end(); - ++aIndirect - ) + if ( !aInfos.empty() ) { - aSearchFor.Name = aIndirect->second; - ConstPropertyValueSetIterator aInfoPos = aInfos.find(aSearchFor); - if (aInfos.end() != aInfoPos) - // the property is contained in the info sequence - // -> transfer it into an item - implTranslateProperty(_rDest, aIndirect->first, aInfoPos->Value); + PropertyValue aSearchFor; + ConstMapInt2StringIterator aEnd = m_aIndirectPropTranslator.end(); + for ( ConstMapInt2StringIterator aIndirect = m_aIndirectPropTranslator.begin(); + aIndirect != aEnd; + ++aIndirect) + { + aSearchFor.Name = aIndirect->second; + ConstPropertyValueSetIterator aInfoPos = aInfos.find(aSearchFor); + if (aInfos.end() != aInfoPos) + // the property is contained in the info sequence + // -> transfer it into an item + implTranslateProperty(_rDest, aIndirect->first, aInfoPos->Value); + } } convertUrl(_rDest); @@ -770,9 +765,9 @@ void ODbDataSourceAdministrationHelper::fillDatasourceInfo(const SfxItemSet& _rS // us) // first determine which of all the items are relevant for the data source (depends on the connection url) - ::dbaccess::DATASOURCE_TYPE eType = getDatasourceType(_rSource); + ::rtl::OUString eType = getDatasourceType(_rSource); ::std::vector< sal_Int32> aDetailIds; - ODriversSettings::getSupportedIndirectSettings(eType,aDetailIds); + ODriversSettings::getSupportedIndirectSettings(eType,getORB(),aDetailIds); // collect the translated property values for the relevant items PropertyValueSet aRelevantSettings; @@ -874,22 +869,13 @@ void ODbDataSourceAdministrationHelper::fillDatasourceInfo(const SfxItemSet& _rS #endif } + ::connectivity::DriversConfig aDriverConfig(getORB()); + const ::comphelper::NamedValueCollection& aProperties = aDriverConfig.getProperties(eType); + Sequence< Any> aTypeSettings; + aTypeSettings = aProperties.getOrDefault("TypeInfoSettings",aTypeSettings); // here we have a special entry for types from oracle - if ( eType == ::dbaccess::DST_ORACLE_JDBC ) + if ( aTypeSettings.getLength() ) { - Sequence< Any > aTypeSettings; - static const ::rtl::OUString s_sCondition(RTL_CONSTASCII_USTRINGPARAM("Column(2) = ")); - static const ::rtl::OUString s_sValue(RTL_CONSTASCII_USTRINGPARAM("Column(6) = PRECISION")); - static const sal_Int32 pTypes[] = { -5, -4, -3, -2, -1, 1, 2, 12}; - aTypeSettings.realloc((sizeof(pTypes)/sizeof(pTypes[0])) * 2); - Any* pCondIter = aTypeSettings.getArray(); - const Any* pCondEnd = pCondIter + aTypeSettings.getLength(); - for(const sal_Int32* pType = pTypes;pCondIter != pCondEnd;++pCondIter,++pType) - { - *pCondIter <<= (s_sCondition + ::rtl::OUString::valueOf(*pType)); - ++pCondIter; - *pCondIter <<= s_sValue; - } aRelevantSettings.insert(PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TypeInfoSettings")), 0, makeAny(aTypeSettings), PropertyState_DIRECT_VALUE)); } @@ -1078,7 +1064,7 @@ String ODbDataSourceAdministrationHelper::getDocumentUrl(SfxItemSet& _rDest) // ----------------------------------------------------------------------------- void ODbDataSourceAdministrationHelper::convertUrl(SfxItemSet& _rDest) { - ::dbaccess::DATASOURCE_TYPE eType = getDatasourceType(_rDest); + ::rtl::OUString eType = getDatasourceType(_rDest); SFX_ITEMSET_GET(_rDest, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True); SFX_ITEMSET_GET(_rDest, pTypeCollection, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True); @@ -1091,12 +1077,13 @@ void ODbDataSourceAdministrationHelper::convertUrl(SfxItemSet& _rDest) USHORT nPortNumberId = 0; sal_Int32 nPortNumber = -1; String sNewHostName; - String sUrl = pCollection->cutPrefix(pUrlItem->GetValue()); + //String sUrl = pCollection->cutPrefix(pUrlItem->GetValue()); String sUrlPart; pCollection->extractHostNamePort(pUrlItem->GetValue(),sUrlPart,sNewHostName,nPortNumber); + const ::dbaccess::DATASOURCE_TYPE eTy = pCollection->determineType(eType); - switch( eType ) + switch( eTy ) { case ::dbaccess::DST_MYSQL_NATIVE: case ::dbaccess::DST_MYSQL_JDBC: @@ -1114,13 +1101,13 @@ void ODbDataSourceAdministrationHelper::convertUrl(SfxItemSet& _rDest) if ( sUrlPart.Len() ) { - if ( eType == ::dbaccess::DST_MYSQL_NATIVE ) + if ( eTy == ::dbaccess::DST_MYSQL_NATIVE ) { _rDest.Put( SfxStringItem( DSID_DATABASENAME, sUrlPart ) ); } else { - String sNewUrl = pCollection->getDatasourcePrefix(eType); + String sNewUrl = pCollection->getPrefix(eType); sNewUrl += sUrlPart; _rDest.Put( SfxStringItem( DSID_CONNECTURL, sNewUrl ) ); } diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.hxx b/dbaccess/source/ui/dlg/DbAdminImpl.hxx index 70a0c07a6722..a194ebc7b23c 100644 --- a/dbaccess/source/ui/dlg/DbAdminImpl.hxx +++ b/dbaccess/source/ui/dlg/DbAdminImpl.hxx @@ -71,6 +71,16 @@ class Window; namespace dbaui { //......................................................................... + class DataSourceInfoConverter + { + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory; + public: + DataSourceInfoConverter(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory) + :m_xFactory(_xFactory) + { + } + void convert(const ::dbaccess::ODsnTypeCollection* _pCollection,const ::rtl::OUString& _sOldURLPrefix,const ::rtl::OUString& _sNewURLPrefix,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDatasource); + }; class IItemSetHelper; //======================================================================== //= ODbDataSourceAdministrationHelper @@ -142,7 +152,7 @@ namespace dbaui /** extracts the connection type from the given set<p/> The connection type is determined by the value of the DSN item, analyzed by the TypeCollection item. */ - static ::dbaccess::DATASOURCE_TYPE getDatasourceType( const SfxItemSet& _rSet ); + static ::rtl::OUString getDatasourceType( const SfxItemSet& _rSet ); /** returns the connection URL @return diff --git a/dbaccess/source/ui/dlg/DriverSettings.cxx b/dbaccess/source/ui/dlg/DriverSettings.cxx index 15c40b3e40c5..4c66109d50e2 100644 --- a/dbaccess/source/ui/dlg/DriverSettings.cxx +++ b/dbaccess/source/ui/dlg/DriverSettings.cxx @@ -34,14 +34,15 @@ #include "DriverSettings.hxx" #include "dsitems.hxx" #include "datasourceui.hxx" - +#include <connectivity/DriversConfig.hxx> using namespace dbaui; -void ODriversSettings::getSupportedIndirectSettings( ::dbaccess::DATASOURCE_TYPE _eType, ::std::vector< sal_Int32>& _out_rDetailsIds ) +void ODriversSettings::getSupportedIndirectSettings( const ::rtl::OUString& _sURLPrefix,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory, ::std::vector< sal_Int32>& _out_rDetailsIds ) { // for a number of settings, we do not need to use hard-coded here, but can ask a // central DataSourceUI instance. - DataSourceUI aDSUI( _eType ); + DataSourceMetaData aMeta(_sURLPrefix); + DataSourceUI aDSUI( aMeta ); const USHORT nGenericKnownSettings[] = { DSID_SQL92CHECK, @@ -67,71 +68,35 @@ void ODriversSettings::getSupportedIndirectSettings( ::dbaccess::DATASOURCE_TYPE _out_rDetailsIds.push_back( *pGenericKnowSetting ); // the rest is hard-coded. On the long run, all of this should be done via DataSourceUI::hasSetting - switch ( _eType ) + ::connectivity::DriversConfig aDriverConfig(_xFactory); + const ::comphelper::NamedValueCollection& aProperties = aDriverConfig.getProperties(_sURLPrefix); + typedef ::std::pair<USHORT, ::rtl::OUString> TProperties; + TProperties aProps[] = { TProperties(DSID_SHOWDELETEDROWS,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowDeleted"))) + ,TProperties(DSID_CHARSET,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharSet"))) + ,TProperties(DSID_FIELDDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FieldDelimiter"))) + ,TProperties(DSID_TEXTDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StringDelimiter"))) + ,TProperties(DSID_DECIMALDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DecimalDelimiter"))) + ,TProperties(DSID_THOUSANDSDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ThousandDelimiter"))) + ,TProperties(DSID_TEXTFILEEXTENSION,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Extension"))) + ,TProperties(DSID_TEXTFILEHEADER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HeaderLine"))) + ,TProperties(DSID_ADDITIONALOPTIONS,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SystemDriverSettings"))) + ,TProperties(DSID_CONN_SHUTSERVICE,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShutdownDatabase"))) + ,TProperties(DSID_CONN_DATAINC,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCacheSizeIncrement"))) + ,TProperties(DSID_CONN_CACHESIZE,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCacheSize"))) + ,TProperties(DSID_CONN_CTRLUSER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlUser"))) + ,TProperties(DSID_CONN_CTRLPWD,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlPassword"))) + ,TProperties(DSID_USECATALOG,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseCatalog"))) + ,TProperties(DSID_CONN_SOCKET,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LocalSocket"))) + ,TProperties(DSID_JDBCDRIVERCLASS,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JavaDriverClass"))) + ,TProperties(DSID_CONN_LDAP_BASEDN,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BaseDN"))) + ,TProperties(DSID_CONN_LDAP_ROWCOUNT,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MaxRowCount"))) + ,TProperties(DSID_CONN_LDAP_USESSL,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseSSL"))) + ,TProperties(DSID_IGNORECURRENCY,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IgnoreCurrency"))) + ,TProperties(0,::rtl::OUString()) + }; + for ( TProperties* pProps = aProps; pProps->first; ++pProps ) { - case ::dbaccess::DST_DBASE: - _out_rDetailsIds.push_back(DSID_SHOWDELETEDROWS); - _out_rDetailsIds.push_back(DSID_CHARSET); - break; - - case ::dbaccess::DST_FLAT: - _out_rDetailsIds.push_back(DSID_FIELDDELIMITER); - _out_rDetailsIds.push_back(DSID_TEXTDELIMITER); - _out_rDetailsIds.push_back(DSID_DECIMALDELIMITER); - _out_rDetailsIds.push_back(DSID_THOUSANDSDELIMITER); - _out_rDetailsIds.push_back(DSID_TEXTFILEEXTENSION); - _out_rDetailsIds.push_back(DSID_TEXTFILEHEADER); - _out_rDetailsIds.push_back(DSID_CHARSET); - break; - - case ::dbaccess::DST_ADABAS: - _out_rDetailsIds.push_back(DSID_CHARSET); - _out_rDetailsIds.push_back(DSID_CONN_SHUTSERVICE); - _out_rDetailsIds.push_back(DSID_CONN_DATAINC); - _out_rDetailsIds.push_back(DSID_CONN_CACHESIZE); - _out_rDetailsIds.push_back(DSID_CONN_CTRLUSER); - _out_rDetailsIds.push_back(DSID_CONN_CTRLPWD); - break; - - case ::dbaccess::DST_ADO: - _out_rDetailsIds.push_back(DSID_CHARSET); - break; - - case ::dbaccess::DST_ODBC: - _out_rDetailsIds.push_back(DSID_ADDITIONALOPTIONS); - _out_rDetailsIds.push_back(DSID_CHARSET); - _out_rDetailsIds.push_back(DSID_USECATALOG); - break; - - case ::dbaccess::DST_MYSQL_NATIVE: - _out_rDetailsIds.push_back(DSID_CHARSET); - _out_rDetailsIds.push_back(DSID_CONN_SOCKET); - break; - case ::dbaccess::DST_MYSQL_JDBC: - _out_rDetailsIds.push_back(DSID_CHARSET); - _out_rDetailsIds.push_back(DSID_JDBCDRIVERCLASS); - break; - - case ::dbaccess::DST_MYSQL_ODBC: - _out_rDetailsIds.push_back(DSID_CHARSET); - break; - - case ::dbaccess::DST_LDAP: - _out_rDetailsIds.push_back(DSID_CONN_LDAP_BASEDN); - _out_rDetailsIds.push_back(DSID_CONN_LDAP_ROWCOUNT); - _out_rDetailsIds.push_back(DSID_CONN_LDAP_USESSL); - break; - - case ::dbaccess::DST_JDBC: - _out_rDetailsIds.push_back(DSID_JDBCDRIVERCLASS); - break; - - case ::dbaccess::DST_ORACLE_JDBC: - _out_rDetailsIds.push_back(DSID_JDBCDRIVERCLASS); - _out_rDetailsIds.push_back(DSID_IGNORECURRENCY); - break; - - default: - break; + if ( aProperties.has(pProps->second) ) + _out_rDetailsIds.push_back(pProps->first); } } diff --git a/dbaccess/source/ui/dlg/DriverSettings.hxx b/dbaccess/source/ui/dlg/DriverSettings.hxx index 29a68d35a5a5..154013a11bda 100644 --- a/dbaccess/source/ui/dlg/DriverSettings.hxx +++ b/dbaccess/source/ui/dlg/DriverSettings.hxx @@ -53,7 +53,7 @@ namespace dbaui @param _out_rDetailsIds Will be filled. */ - static void getSupportedIndirectSettings( ::dbaccess::DATASOURCE_TYPE _eType,::std::vector< sal_Int32>& _out_rDetailsIds ); + static void getSupportedIndirectSettings( const ::rtl::OUString& _sURLPrefix,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory,::std::vector< sal_Int32>& _out_rDetailsIds ); /** Creates the detail page for Dbase */ diff --git a/dbaccess/source/ui/dlg/UserAdminDlg.cxx b/dbaccess/source/ui/dlg/UserAdminDlg.cxx index 63312762c7b8..204a57dc8758 100644 --- a/dbaccess/source/ui/dlg/UserAdminDlg.cxx +++ b/dbaccess/source/ui/dlg/UserAdminDlg.cxx @@ -180,7 +180,7 @@ DBG_NAME(OUserAdminDlg) return m_pImpl->getDriver(); } // ----------------------------------------------------------------------------- - ::dbaccess::DATASOURCE_TYPE OUserAdminDlg::getDatasourceType(const SfxItemSet& _rSet) const + ::rtl::OUString OUserAdminDlg::getDatasourceType(const SfxItemSet& _rSet) const { return m_pImpl->getDatasourceType(_rSet); } diff --git a/dbaccess/source/ui/dlg/adminpages.cxx b/dbaccess/source/ui/dlg/adminpages.cxx index ff43481b847d..5b4d38dee215 100644 --- a/dbaccess/source/ui/dlg/adminpages.cxx +++ b/dbaccess/source/ui/dlg/adminpages.cxx @@ -183,7 +183,7 @@ namespace dbaui return 0L; } // ----------------------------------------------------------------------- - sal_Bool OGenericAdministrationPage::getSelectedDataSource(::dbaccess::DATASOURCE_TYPE _eType,::rtl::OUString& _sReturn,::rtl::OUString& _sCurr) + sal_Bool OGenericAdministrationPage::getSelectedDataSource(::rtl::OUString& _sReturn,::rtl::OUString& _sCurr) { // collect all ODBC data source names StringBag aOdbcDatasources; @@ -202,7 +202,7 @@ namespace dbaui { aEnumeration.getDatasourceNames(aOdbcDatasources); // excute the select dialog - ODatasourceSelectDialog aSelector(GetParent(), aOdbcDatasources, _eType); + ODatasourceSelectDialog aSelector(GetParent(), aOdbcDatasources, false); if (_sCurr.getLength()) aSelector.Select(_sCurr); if ( RET_OK == aSelector.Execute() ) diff --git a/dbaccess/source/ui/dlg/adminpages.hxx b/dbaccess/source/ui/dlg/adminpages.hxx index d1ef46a37cf1..d59ae3af8052 100644 --- a/dbaccess/source/ui/dlg/adminpages.hxx +++ b/dbaccess/source/ui/dlg/adminpages.hxx @@ -166,7 +166,7 @@ namespace dbaui @return <FALSE/> if an error occured, otherwise <TRUE/> */ - sal_Bool getSelectedDataSource(::dbaccess::DATASOURCE_TYPE _eType,::rtl::OUString& _sReturn,::rtl::OUString& _sCurr); + sal_Bool getSelectedDataSource(::rtl::OUString& _sReturn,::rtl::OUString& _sCurr); // svt::IWizardPage virtual void initializePage(); diff --git a/dbaccess/source/ui/dlg/advancedsettings.cxx b/dbaccess/source/ui/dlg/advancedsettings.cxx index 7b930b81e4ab..7f0b5ee16515 100644 --- a/dbaccess/source/ui/dlg/advancedsettings.cxx +++ b/dbaccess/source/ui/dlg/advancedsettings.cxx @@ -417,7 +417,7 @@ namespace dbaui delete pExampleSet; pExampleSet = new SfxItemSet(*GetInputSetImpl()); - ::dbaccess::DATASOURCE_TYPE eType = m_pImpl->getDatasourceType(*_pItems); + const ::rtl::OUString eType = m_pImpl->getDatasourceType(*_pItems); DataSourceMetaData aMeta( eType ); const AdvancedSettingsSupport& rAdvancedSupport( aMeta.getAdvancedSettingsSupport() ); @@ -443,9 +443,9 @@ namespace dbaui } // ----------------------------------------------------------------------- - bool AdvancedSettingsDialog::doesHaveAnyAdvancedSettings( ::dbaccess::DATASOURCE_TYPE _eType ) + bool AdvancedSettingsDialog::doesHaveAnyAdvancedSettings( const ::rtl::OUString& _sURL ) { - DataSourceMetaData aMeta( _eType ); + DataSourceMetaData aMeta( _sURL ); const AdvancedSettingsSupport& rSupport( aMeta.getAdvancedSettingsSupport() ); if ( rSupport.bGeneratedValues || rSupport.supportsAnySpecialSetting() ) return true; @@ -510,7 +510,7 @@ namespace dbaui } // ----------------------------------------------------------------------------- - ::dbaccess::DATASOURCE_TYPE AdvancedSettingsDialog::getDatasourceType(const SfxItemSet& _rSet) const + ::rtl::OUString AdvancedSettingsDialog::getDatasourceType(const SfxItemSet& _rSet) const { return m_pImpl->getDatasourceType(_rSet); } diff --git a/dbaccess/source/ui/dlg/datasourceui.cxx b/dbaccess/source/ui/dlg/datasourceui.cxx index aa4c0e7f8444..f0a56e8dec83 100644 --- a/dbaccess/source/ui/dlg/datasourceui.cxx +++ b/dbaccess/source/ui/dlg/datasourceui.cxx @@ -52,12 +52,6 @@ namespace dbaui //= DataSourceUI //==================================================================== //-------------------------------------------------------------------- - DataSourceUI::DataSourceUI( ::dbaccess::DATASOURCE_TYPE _eType ) - :m_aDSMeta( DataSourceMetaData( _eType ) ) - { - } - - //-------------------------------------------------------------------- DataSourceUI::DataSourceUI( const DataSourceMetaData& _rDSMeta ) :m_aDSMeta( _rDSMeta ) { diff --git a/dbaccess/source/ui/dlg/datasourceui.hxx b/dbaccess/source/ui/dlg/datasourceui.hxx index 9fa356503ed4..4ea63439c0d5 100644 --- a/dbaccess/source/ui/dlg/datasourceui.hxx +++ b/dbaccess/source/ui/dlg/datasourceui.hxx @@ -52,7 +52,6 @@ namespace dbaui class DataSourceUI { public: - DataSourceUI( ::dbaccess::DATASOURCE_TYPE _eType ); DataSourceUI( const DataSourceMetaData& _rDSMeta ); ~DataSourceUI(); diff --git a/dbaccess/source/ui/dlg/dbadmin.cxx b/dbaccess/source/ui/dlg/dbadmin.cxx index a28567c6b0af..4eefb05b7f89 100644 --- a/dbaccess/source/ui/dlg/dbadmin.cxx +++ b/dbaccess/source/ui/dlg/dbadmin.cxx @@ -181,7 +181,9 @@ void ODbAdminDialog::impl_selectDataSource(const ::com::sun::star::uno::Any& _aD Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource(); impl_resetPages( xDatasource ); - ::dbaccess::DATASOURCE_TYPE eType = getDatasourceType(*getOutputSet()); + DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, getOutputSet()->GetItem(DSID_TYPECOLLECTION)); + ::dbaccess::ODsnTypeCollection* pCollection = pCollectionItem->getCollection(); + ::dbaccess::DATASOURCE_TYPE eType = pCollection->determineType(getDatasourceType(*getOutputSet())); // and insert the new ones switch ( eType ) @@ -282,8 +284,10 @@ void ODbAdminDialog::impl_resetPages(const Reference< XPropertySet >& _rxDatasou pExampleSet = new SfxItemSet(*GetInputSetImpl()); // special case: MySQL Native does not have the generic PAGE_CONNECTION page - ::dbaccess::DATASOURCE_TYPE eType = getDatasourceType( *pExampleSet ); - if ( eType == ::dbaccess::DST_MYSQL_NATIVE ) + + DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, getOutputSet()->GetItem(DSID_TYPECOLLECTION)); + ::dbaccess::ODsnTypeCollection* pCollection = pCollectionItem->getCollection(); + if ( pCollection->determineType(getDatasourceType( *pExampleSet )) == ::dbaccess::DST_MYSQL_NATIVE ) { LocalResourceAccess aDummy(DLG_DATABASE_ADMINISTRATION, RSC_TABDIALOG); AddTabPage( PAGE_MYSQL_NATIVE, String( ModuleRes( STR_PAGETITLE_CONNECTION ) ), ODriversSettings::CreateMySQLNATIVE, NULL ); @@ -368,7 +372,7 @@ Reference< XDriver > ODbAdminDialog::getDriver() return m_pImpl->getDriver(); } // ----------------------------------------------------------------------------- -::dbaccess::DATASOURCE_TYPE ODbAdminDialog::getDatasourceType(const SfxItemSet& _rSet) const +::rtl::OUString ODbAdminDialog::getDatasourceType(const SfxItemSet& _rSet) const { return m_pImpl->getDatasourceType(_rSet); } @@ -391,7 +395,7 @@ SfxItemSet* ODbAdminDialog::createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rp SfxPoolItem** pCounter = _rppDefaults; // want to modify this without affecting the out param _rppDefaults *pCounter++ = new SfxStringItem(DSID_NAME, String()); *pCounter++ = new SfxStringItem(DSID_ORIGINALNAME, String()); - *pCounter++ = new SfxStringItem(DSID_CONNECTURL, _pTypeCollection ? _pTypeCollection->getDatasourcePrefix( ::dbaccess::DST_ADABAS ) : String()); + *pCounter++ = new SfxStringItem(DSID_CONNECTURL, String()); *pCounter++ = new OStringListItem(DSID_TABLEFILTER, Sequence< ::rtl::OUString >(&sFilterAll, 1)); *pCounter++ = new DbuTypeCollectionItem(DSID_TYPECOLLECTION, _pTypeCollection); *pCounter++ = new SfxBoolItem(DSID_INVALID_SELECTION, sal_False); diff --git a/dbaccess/source/ui/dlg/dbwiz.cxx b/dbaccess/source/ui/dlg/dbwiz.cxx index ff986cbcbd6f..c0b460cbb329 100644 --- a/dbaccess/source/ui/dlg/dbwiz.cxx +++ b/dbaccess/source/ui/dlg/dbwiz.cxx @@ -43,6 +43,7 @@ #ifndef _DBAUI_DATASOURCEITEMS_HXX_ #include "dsitems.hxx" #endif +#include "dsnItem.hxx" #ifndef _SFXSTRITEM_HXX #include <svtools/stritem.hxx> #endif @@ -153,6 +154,10 @@ ODbTypeWizDialog::ODbTypeWizDialog(Window* _pParent m_pFinish->SetHelpId(HID_DBWIZ_FINISH); m_pHelp->SetUniqueId(UID_DBWIZ_HELP); // no local resources needed anymore + + DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _pItems->GetItem(DSID_TYPECOLLECTION)); + m_pCollection = pCollectionItem->getCollection(); + FreeResource(); ActivatePage(); } @@ -167,24 +172,9 @@ ODbTypeWizDialog::~ODbTypeWizDialog() IMPL_LINK(ODbTypeWizDialog, OnTypeSelected, OGeneralPage*, _pTabPage) { m_eType = _pTabPage->GetSelectedType(); - switch(m_eType) - { - case ::dbaccess::DST_MOZILLA: - case ::dbaccess::DST_OUTLOOK: - case ::dbaccess::DST_OUTLOOKEXP: - case ::dbaccess::DST_EVOLUTION: - case ::dbaccess::DST_EVOLUTION_GROUPWISE: - case ::dbaccess::DST_EVOLUTION_LDAP: - case ::dbaccess::DST_KAB: - case ::dbaccess::DST_MACAB: - enableButtons(WZB_NEXT,sal_False); - enableButtons(WZB_FINISH,sal_True); - break; - default: - enableButtons(WZB_NEXT,sal_True); - enableButtons(WZB_FINISH,sal_False); - break; - } + const bool bURLRequired = m_pCollection->isConnectionUrlRequired(m_eType); + enableButtons(WZB_NEXT,bURLRequired); + enableButtons(WZB_FINISH,!bURLRequired); return 1L; } //------------------------------------------------------------------------- @@ -194,7 +184,7 @@ WizardTypes::WizardState ODbTypeWizDialog::determineNextState( WizardState _nCur switch(_nCurrentState) { case START_PAGE: - switch(m_eType) + switch(m_pCollection->determineType(m_eType)) { case ::dbaccess::DST_MOZILLA: case ::dbaccess::DST_OUTLOOK: @@ -215,7 +205,7 @@ WizardTypes::WizardState ODbTypeWizDialog::determineNextState( WizardState _nCur } break; case CONNECTION_PAGE: - switch(m_eType) + switch(m_pCollection->determineType(m_eType)) { case ::dbaccess::DST_MOZILLA: case ::dbaccess::DST_THUNDERBIRD: @@ -295,7 +285,7 @@ Reference< XDriver > ODbTypeWizDialog::getDriver() return m_pImpl->getDriver(); } // ----------------------------------------------------------------------------- -::dbaccess::DATASOURCE_TYPE ODbTypeWizDialog::getDatasourceType(const SfxItemSet& _rSet) const +::rtl::OUString ODbTypeWizDialog::getDatasourceType(const SfxItemSet& _rSet) const { return m_pImpl->getDatasourceType(_rSet); } @@ -409,6 +399,12 @@ sal_Bool ODbTypeWizDialog::saveDatasource() SfxTabPage* pPage = static_cast<SfxTabPage*>(WizardDialog::GetPage(getCurrentState())); if ( pPage ) pPage->FillItemSet(*m_pOutSet); + + DataSourceInfoConverter aConverter(getORB()); + ::rtl::OUString sOldURL; + if ( m_pImpl->getCurrentDataSource().is() ) + m_pImpl->getCurrentDataSource()->getPropertyValue(PROPERTY_URL) >>= sOldURL; + aConverter.convert(m_pCollection,sOldURL,m_eType,m_pImpl->getCurrentDataSource()); return sal_True; } // ----------------------------------------------------------------------------- diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx index 6df5537544a4..caa8657d5276 100644 --- a/dbaccess/source/ui/dlg/dbwizsetup.cxx +++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx @@ -161,32 +161,19 @@ #ifndef _COM_SUN_STAR_DOCUMENT_MACROEXECMODE_HPP_ #include <com/sun/star/document/MacroExecMode.hpp> #endif +#include <com/sun/star/ucb/IOErrorCode.hpp> +#include <com/sun/star/task/XInteractionHandler.hpp> +#include "com/sun/star/ui/dialogs/TemplateDescription.hpp" + + /** === end UNO includes === **/ -#ifndef SVTOOLS_FILENOTATION_HXX_ #include <svtools/filenotation.hxx> -#endif -#ifndef _COMPHELPER_INTERACTION_HXX_ #include <comphelper/interaction.hxx> -#endif -#ifndef COMPHELPER_NAMEDVALUECOLLECTION_HXX #include <comphelper/namedvaluecollection.hxx> -#endif -#ifndef _COMPHELPER_SEQUENCEASHASHMAP_HXX_ #include <comphelper/sequenceashashmap.hxx> -#endif -#ifndef TOOLS_DIAGNOSE_EX_H #include <tools/diagnose_ex.h> -#endif - -#ifndef _COM_SUN_STAR_UCB_IOERRORCODE_HPP_ -#include <com/sun/star/ucb/IOErrorCode.hpp> -#endif -#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_ -#include <com/sun/star/task/XInteractionHandler.hpp> -#endif -#include "com/sun/star/ui/dialogs/TemplateDescription.hpp" - +#include <connectivity/DriversConfig.hxx> #include <memory> @@ -197,6 +184,7 @@ namespace dbaui //......................................................................... using namespace dbtools; using namespace svt; +using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::sdbc; using namespace com::sun::star::sdbcx; @@ -217,53 +205,34 @@ using namespace ::cppu; #define CONNECTION_PAGE 1 -#define PAGE_DBSETUPWIZARD_INTRO 0 -#define PAGE_DBSETUPWIZARD_DBASE 1 -#define PAGE_DBSETUPWIZARD_TEXT 2 -#define PAGE_DBSETUPWIZARD_MSACCESS 3 -#define PAGE_DBSETUPWIZARD_LDAP 4 -#define PAGE_DBSETUPWIZARD_ADABAS 5 -#define PAGE_DBSETUPWIZARD_MYSQL_INTRO 6 -#define PAGE_DBSETUPWIZARD_MYSQL_JDBC 7 -#define PAGE_DBSETUPWIZARD_MYSQL_ODBC 8 -#define PAGE_DBSETUPWIZARD_ORACLE 9 -#define PAGE_DBSETUPWIZARD_JDBC 10 -#define PAGE_DBSETUPWIZARD_ADO 11 -#define PAGE_DBSETUPWIZARD_ODBC 12 -#define PAGE_DBSETUPWIZARD_SPREADSHEET 13 -#define PAGE_DBSETUPWIZARD_AUTHENTIFICATION 14 -#define PAGE_DBSETUPWIZARD_MOZILLA 15 -#define PAGE_DBSETUPWIZARD_FINAL 16 -#define PAGE_DBSETUPWIZARD_USERDEFINED 17 -#define PAGE_DBSETUPWIZARD_MYSQL_NATIVE 18 - - -#define DBASE_PATH 1 -#define TEXT_PATH 2 -#define MSACCESS_PATH 3 -#define LDAP_PATH 4 -#define ADABAS_PATH 5 -#define ADO_PATH 6 -#define JDBC_PATH 7 -#define ORACLE_PATH 8 -#define MYSQL_JDBC_PATH 9 -#define MYSQL_ODBC_PATH 10 -#define ODBC_PATH 11 -#define SPREADSHEET_PATH 12 -#define OUTLOOKEXP_PATH 13 -#define OUTLOOK_PATH 14 -#define MOZILLA_PATH 15 -#define EVOLUTION_PATH 16 -#define EVOLUTION_PATH_GROUPWISE 17 -#define EVOLUTION_PATH_LDAP 18 -#define KAB_PATH 19 -#define MACAB_PATH 20 -#define THUNDERBIRD_PATH 21 -#define CREATENEW_PATH 22 -#define USERDEFINED_PATH 23 -#define OPEN_DOC_PATH 24 -#define MSACCESS2007_PATH 25 -#define MYSQL_NATIVE_PATH 26 + + +//#define DBASE_PATH 1 +//#define TEXT_PATH 2 +//#define MSACCESS_PATH 3 +//#define LDAP_PATH 4 +//#define ADABAS_PATH 5 +//#define ADO_PATH 6 +//#define JDBC_PATH 7 +//#define ORACLE_PATH 8 +//#define MYSQL_JDBC_PATH 9 +//#define MYSQL_ODBC_PATH 10 +//#define ODBC_PATH 11 +//#define SPREADSHEET_PATH 12 +//#define OUTLOOKEXP_PATH 13 +//#define OUTLOOK_PATH 14 +//#define MOZILLA_PATH 15 +//#define EVOLUTION_PATH 16 +//#define EVOLUTION_PATH_GROUPWISE 17 +//#define EVOLUTION_PATH_LDAP 18 +//#define KAB_PATH 19 +//#define MACAB_PATH 20 +//#define THUNDERBIRD_PATH 21 +//#define CREATENEW_PATH 22 +//#define USERDEFINED_PATH 23 +//#define OPEN_DOC_PATH 24 +//#define MSACCESS2007_PATH 25 +//#define MYSQL_NATIVE_PATH 26 OFinalDBPageSetup* pFinalPage; @@ -283,8 +252,6 @@ ODbTypeWizDialogSetup::ODbTypeWizDialogSetup(Window* _pParent WZB_NEXT | WZB_PREVIOUS | WZB_FINISH | WZB_CANCEL | WZB_HELP ) , m_pOutSet(NULL) - , m_eType( ::dbaccess::DST_UNKNOWN ) - , m_eOldType( ::dbaccess::DST_UNKNOWN ) , m_bResetting(sal_False) , m_bApplied(sal_False) , m_bUIEnabled( sal_True ) @@ -326,7 +293,7 @@ ODbTypeWizDialogSetup::ODbTypeWizDialogSetup(Window* _pParent m_pOutSet = new SfxItemSet( *_pItems->GetPool(), _pItems->GetRanges() ); m_pImpl->translateProperties(xDatasource, *m_pOutSet); - m_eType = m_pImpl->getDatasourceType(*m_pOutSet); +// eType = m_pImpl->getDatasourceType(*m_pOutSet); SetPageSizePixel(LogicToPixel(::Size(WIZARD_PAGE_X, WIZARD_PAGE_Y), MAP_APPFONT)); ShowButtonFixedLine(sal_True); @@ -334,32 +301,23 @@ ODbTypeWizDialogSetup::ODbTypeWizDialogSetup(Window* _pParent enableButtons(WZB_FINISH, sal_True); enableAutomaticNextButtonState(); - declareAuthDepPath( ::dbaccess::DST_ADO, ADO_PATH, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_ADO, PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declareAuthDepPath( ::dbaccess::DST_DBASE, DBASE_PATH, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_DBASE, PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declareAuthDepPath( ::dbaccess::DST_FLAT, TEXT_PATH, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_TEXT, PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declarePath ( SPREADSHEET_PATH, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_SPREADSHEET, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declareAuthDepPath( ::dbaccess::DST_ODBC, ODBC_PATH, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_ODBC, PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declareAuthDepPath( ::dbaccess::DST_JDBC, JDBC_PATH, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_JDBC, PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declareAuthDepPath( ::dbaccess::DST_MYSQL_ODBC, MYSQL_ODBC_PATH, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_MYSQL_INTRO, PAGE_DBSETUPWIZARD_MYSQL_ODBC, PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declareAuthDepPath( ::dbaccess::DST_MYSQL_JDBC, MYSQL_JDBC_PATH, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_MYSQL_INTRO, PAGE_DBSETUPWIZARD_MYSQL_JDBC, PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declareAuthDepPath( ::dbaccess::DST_MYSQL_NATIVE, MYSQL_NATIVE_PATH, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_MYSQL_INTRO, PAGE_DBSETUPWIZARD_MYSQL_NATIVE, PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declareAuthDepPath( ::dbaccess::DST_ORACLE_JDBC, ORACLE_PATH, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_ORACLE, PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declareAuthDepPath( ::dbaccess::DST_ADABAS, ADABAS_PATH, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_ADABAS, PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declareAuthDepPath( ::dbaccess::DST_LDAP, LDAP_PATH, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_LDAP, PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declareAuthDepPath( ::dbaccess::DST_MSACCESS, MSACCESS_PATH, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_MSACCESS, PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declareAuthDepPath( ::dbaccess::DST_MSACCESS_2007, MSACCESS2007_PATH, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_MSACCESS, PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declareAuthDepPath( ::dbaccess::DST_OUTLOOKEXP, OUTLOOKEXP_PATH, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declareAuthDepPath( ::dbaccess::DST_OUTLOOK, OUTLOOK_PATH, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declareAuthDepPath( ::dbaccess::DST_MOZILLA, MOZILLA_PATH, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declareAuthDepPath( ::dbaccess::DST_THUNDERBIRD, THUNDERBIRD_PATH, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declareAuthDepPath( ::dbaccess::DST_EVOLUTION, EVOLUTION_PATH, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declareAuthDepPath( ::dbaccess::DST_EVOLUTION_GROUPWISE,EVOLUTION_PATH_GROUPWISE, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declareAuthDepPath( ::dbaccess::DST_EVOLUTION_LDAP, EVOLUTION_PATH_LDAP, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declareAuthDepPath( ::dbaccess::DST_KAB, KAB_PATH, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declareAuthDepPath( ::dbaccess::DST_MACAB, MACAB_PATH, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1); - declareAuthDepPath( getDefaultDatabaseType(),CREATENEW_PATH, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declareAuthDepPath( ::dbaccess::DST_USERDEFINE1, USERDEFINED_PATH, PAGE_DBSETUPWIZARD_INTRO, PAGE_DBSETUPWIZARD_USERDEFINED,PAGE_DBSETUPWIZARD_AUTHENTIFICATION, PAGE_DBSETUPWIZARD_FINAL, -1 ); - declarePath ( OPEN_DOC_PATH, PAGE_DBSETUPWIZARD_INTRO, -1 ); + ::dbaccess::ODsnTypeCollection::TypeIterator aIter = m_pCollection->begin(); + ::dbaccess::ODsnTypeCollection::TypeIterator aEnd = m_pCollection->end(); + for(PathId i = 1;aIter != aEnd;++aIter,++i) + { + const ::rtl::OUString sURLPrefix = aIter.getURLPrefix(); + svt::RoadmapWizardTypes::WizardPath aPath; + aPath.push_back(PAGE_DBSETUPWIZARD_INTRO); + m_pCollection->fillPageIds(sURLPrefix,aPath); + aPath.push_back(PAGE_DBSETUPWIZARD_AUTHENTIFICATION); + aPath.push_back(PAGE_DBSETUPWIZARD_FINAL); + + declareAuthDepPath(sURLPrefix,i,aPath); + } + + svt::RoadmapWizardTypes::WizardPath aPath; + aPath.push_back(PAGE_DBSETUPWIZARD_INTRO); + declarePath( static_cast<PathId>(m_pCollection->size()+1), aPath); m_pPrevPage->SetHelpId(HID_DBWIZ_PREVIOUS); m_pNextPage->SetHelpId(HID_DBWIZ_NEXT); @@ -370,25 +328,20 @@ ODbTypeWizDialogSetup::ODbTypeWizDialogSetup(Window* _pParent ActivatePage(); } -void ODbTypeWizDialogSetup::declareAuthDepPath( ::dbaccess::DATASOURCE_TYPE _eType, PathId _nPathId, WizardState _nFirstState, ... ) +void ODbTypeWizDialogSetup::declareAuthDepPath( const ::rtl::OUString& _sURL, PathId _nPathId, const svt::RoadmapWizardTypes::WizardPath& _rPaths) { - bool bHasAuthentication = DataSourceMetaData::getAuthentication( _eType ) != AuthNone; + bool bHasAuthentication = DataSourceMetaData::getAuthentication( _sURL ) != AuthNone; // collect the elements of the path WizardPath aPath; - va_list aStateList; - va_start( aStateList, _nFirstState ); - - WizardState nState = _nFirstState; - while ( nState != WZS_INVALID_STATE ) + svt::RoadmapWizardTypes::WizardPath::const_iterator aIter = _rPaths.begin(); + svt::RoadmapWizardTypes::WizardPath::const_iterator aEnd = _rPaths.end(); + for(;aIter != aEnd;++aIter) { - if ( bHasAuthentication || ( nState != PAGE_DBSETUPWIZARD_AUTHENTIFICATION ) ) - aPath.push_back( nState ); - - nState = ::sal::static_int_cast< WizardState >( va_arg( aStateList, int ) ); - } - va_end( aStateList ); + if ( bHasAuthentication || ( *aIter != PAGE_DBSETUPWIZARD_AUTHENTIFICATION ) ) + aPath.push_back( *aIter ); + } // for(;aIter != aEnd;++aIter) // call base method ::svt::RoadmapWizard::declarePath( _nPathId, aPath ); @@ -477,6 +430,41 @@ IMPL_LINK(ODbTypeWizDialogSetup, OnTypeSelected, OGeneralPage*, /*_pTabPage*/) return 1L; } +void lcl_removeUnused(const ::comphelper::NamedValueCollection& _aOld,const ::comphelper::NamedValueCollection& _aNew,::comphelper::NamedValueCollection& _rDSInfo) +{ + _rDSInfo.merge(_aNew,true); + uno::Sequence< beans::NamedValue > aOldValues = _aOld.getNamedValues(); + const beans::NamedValue* pIter = aOldValues.getConstArray(); + const beans::NamedValue* pEnd = pIter + aOldValues.getLength(); + for(;pIter != pEnd;++pIter) + { + if ( !_aNew.has(pIter->Name) ) + { + _rDSInfo.remove(pIter->Name); + } + } +} +// ----------------------------------------------------------------------------- +void DataSourceInfoConverter::convert(const ::dbaccess::ODsnTypeCollection* _pCollection,const ::rtl::OUString& _sOldURLPrefix,const ::rtl::OUString& _sNewURLPrefix,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDatasource) +{ + if ( _pCollection->getPrefix(_sOldURLPrefix) == _pCollection->getPrefix(_sNewURLPrefix) ) + return ; + uno::Sequence< beans::PropertyValue> aInfo; + _xDatasource->getPropertyValue(PROPERTY_INFO) >>= aInfo; + ::comphelper::NamedValueCollection aDS(aInfo); + + ::connectivity::DriversConfig aDriverConfig(m_xFactory); + const ::comphelper::NamedValueCollection& aOldMetaData = aDriverConfig.getMetaData(_sOldURLPrefix); + const ::comphelper::NamedValueCollection& aOldProperties = aDriverConfig.getProperties(_sOldURLPrefix); + + const ::comphelper::NamedValueCollection& aNewMetaData = aDriverConfig.getMetaData(_sNewURLPrefix); + const ::comphelper::NamedValueCollection& aNewProperties = aDriverConfig.getProperties(_sNewURLPrefix); + + lcl_removeUnused(aOldMetaData,aNewMetaData,aDS); + lcl_removeUnused(aOldProperties,aNewProperties,aDS); + aDS >>= aInfo; + _xDatasource->setPropertyValue(PROPERTY_INFO,uno::makeAny(aInfo)); +} //------------------------------------------------------------------------- void ODbTypeWizDialogSetup::activateDatabasePath() { @@ -484,74 +472,28 @@ void ODbTypeWizDialogSetup::activateDatabasePath() { case OGeneralPage::eCreateNew: { - activatePath( CREATENEW_PATH, sal_True); + activatePath( static_cast<PathId>(m_pCollection->getIndexOf(m_pCollection->getEmbeddedDatabase()) + 1), sal_True); enableState(PAGE_DBSETUPWIZARD_FINAL, sal_True ); enableButtons( WZB_FINISH, sal_True); } break; case OGeneralPage::eConnectExternal: { - m_eType = VerifyDataSourceType(m_pGeneralPage->GetSelectedType()); - if (m_eType == ::dbaccess::DST_UNKNOWN) - m_eType = m_eOldType; - - struct _map_type_to_path - { - ::dbaccess::DATASOURCE_TYPE eType; - RoadmapWizardTypes::PathId nPathId; - } aKnownTypesAndPaths[] = { - { ::dbaccess::DST_DBASE, DBASE_PATH }, - { ::dbaccess::DST_ADO, ADO_PATH }, - { ::dbaccess::DST_FLAT, TEXT_PATH }, - { ::dbaccess::DST_CALC, SPREADSHEET_PATH }, - { ::dbaccess::DST_ODBC, ODBC_PATH }, - { ::dbaccess::DST_JDBC, JDBC_PATH }, - { ::dbaccess::DST_MYSQL_JDBC, MYSQL_JDBC_PATH }, - { ::dbaccess::DST_MYSQL_NATIVE, MYSQL_NATIVE_PATH }, - { ::dbaccess::DST_MYSQL_ODBC, MYSQL_ODBC_PATH }, - { ::dbaccess::DST_ORACLE_JDBC, ORACLE_PATH }, - { ::dbaccess::DST_ADABAS, ADABAS_PATH }, - { ::dbaccess::DST_LDAP, LDAP_PATH }, - { ::dbaccess::DST_MSACCESS, MSACCESS_PATH }, - { ::dbaccess::DST_MSACCESS_2007,MSACCESS2007_PATH }, - { ::dbaccess::DST_OUTLOOKEXP, OUTLOOKEXP_PATH }, - { ::dbaccess::DST_OUTLOOK, OUTLOOK_PATH }, - { ::dbaccess::DST_MOZILLA, MOZILLA_PATH }, - { ::dbaccess::DST_THUNDERBIRD, THUNDERBIRD_PATH }, - { ::dbaccess::DST_EVOLUTION, EVOLUTION_PATH }, - { ::dbaccess::DST_EVOLUTION_GROUPWISE, EVOLUTION_PATH_GROUPWISE }, - { ::dbaccess::DST_EVOLUTION_LDAP, EVOLUTION_PATH_LDAP }, - { ::dbaccess::DST_KAB, KAB_PATH }, - { ::dbaccess::DST_MACAB, MACAB_PATH }, - { ::dbaccess::DST_USERDEFINE1, USERDEFINED_PATH }, - { ::dbaccess::DST_USERDEFINE2, USERDEFINED_PATH }, - { ::dbaccess::DST_USERDEFINE3, USERDEFINED_PATH }, - { ::dbaccess::DST_USERDEFINE4, USERDEFINED_PATH }, - { ::dbaccess::DST_USERDEFINE5, USERDEFINED_PATH }, - { ::dbaccess::DST_USERDEFINE6, USERDEFINED_PATH }, - { ::dbaccess::DST_USERDEFINE7, USERDEFINED_PATH }, - { ::dbaccess::DST_USERDEFINE8, USERDEFINED_PATH }, - { ::dbaccess::DST_USERDEFINE9, USERDEFINED_PATH }, - { ::dbaccess::DST_USERDEFINE10, USERDEFINED_PATH } - }; - - size_t i = 0; - for ( ; i < sizeof( aKnownTypesAndPaths ) / sizeof( aKnownTypesAndPaths[0] ); ++i ) - { - if ( aKnownTypesAndPaths[i].eType == m_eType ) - { - activatePath( aKnownTypesAndPaths[i].nPathId, sal_True); - break; - } - } - DBG_ASSERT( i < sizeof( aKnownTypesAndPaths ) / sizeof( aKnownTypesAndPaths[0] ), - "ODbTypeWizDialogSetup::activateDatabasePath: unknown database type!" ); + ::rtl::OUString sOld = m_sURL; + DataSourceInfoConverter aConverter(getORB()); + m_sURL = m_pGeneralPage->GetSelectedType(); + aConverter.convert(m_pCollection,sOld,m_sURL,m_pImpl->getCurrentDataSource()); + ::dbaccess::DATASOURCE_TYPE eType = VerifyDataSourceType(m_pCollection->determineType(m_sURL)); + if (eType == ::dbaccess::DST_UNKNOWN) + eType = m_pCollection->determineType(m_sOldURL); + + activatePath( static_cast<PathId>(m_pCollection->getIndexOf(m_sURL) + 1), sal_True); updateTypeDependentStates(); } break; case OGeneralPage::eOpenExisting: { - activatePath( OPEN_DOC_PATH, sal_True ); + activatePath( static_cast<PathId>(m_pCollection->size() + 1), sal_True ); enableButtons( WZB_FINISH, m_pGeneralPage->GetSelectedDocument().sURL.Len() != 0 ); } break; @@ -574,12 +516,9 @@ void ODbTypeWizDialogSetup::updateTypeDependentStates() { bDoEnable = sal_True; } - else + else if ( m_sURL == m_sOldURL ) { - if (m_eType == m_eOldType) - { - bDoEnable = m_bIsConnectable; //(sConnectURL.Len() != 0); - } + bDoEnable = m_bIsConnectable; } enableState(PAGE_DBSETUPWIZARD_AUTHENTIFICATION, bDoEnable); enableState(PAGE_DBSETUPWIZARD_FINAL, bDoEnable ); @@ -590,21 +529,7 @@ void ODbTypeWizDialogSetup::updateTypeDependentStates() //------------------------------------------------------------------------- sal_Bool ODbTypeWizDialogSetup::IsConnectionUrlRequired() { - switch ( m_eType ) - { - case ::dbaccess::DST_KAB: - case ::dbaccess::DST_MACAB: - case ::dbaccess::DST_EVOLUTION: - case ::dbaccess::DST_EVOLUTION_GROUPWISE: - case ::dbaccess::DST_EVOLUTION_LDAP: - case ::dbaccess::DST_OUTLOOK: - case ::dbaccess::DST_OUTLOOKEXP: - case ::dbaccess::DST_MOZILLA: - case ::dbaccess::DST_THUNDERBIRD: - return sal_False; - default: - return sal_True; - } + return m_pCollection->isConnectionUrlRequired(m_sURL); } //------------------------------------------------------------------------- @@ -675,10 +600,25 @@ Reference< XDriver > ODbTypeWizDialogSetup::getDriver() // ----------------------------------------------------------------------------- -::dbaccess::DATASOURCE_TYPE ODbTypeWizDialogSetup::getDatasourceType(const SfxItemSet& _rSet) const +::rtl::OUString ODbTypeWizDialogSetup::getDatasourceType(const SfxItemSet& _rSet) const { - ::dbaccess::DATASOURCE_TYPE LocDatabaseType = m_pImpl->getDatasourceType(_rSet); - return VerifyDataSourceType(LocDatabaseType); + ::rtl::OUString sRet = m_pImpl->getDatasourceType(_rSet); + if (m_pMySQLIntroPage != NULL && m_pMySQLIntroPage->IsVisible() ) + { + switch( m_pMySQLIntroPage->getMySQLMode() ) + { + case OMySQLIntroPageSetup::VIA_JDBC: + sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:jdbc:")); + break; + case OMySQLIntroPageSetup::VIA_NATIVE: + sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:mysqlc:")); + break; + case OMySQLIntroPageSetup::VIA_ODBC: + sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:odbc:")); + break; + } + } + return sRet; } // ----------------------------------------------------------------------------- @@ -725,16 +665,16 @@ TabPage* ODbTypeWizDialogSetup::createPage(WizardState _nState) break; case PAGE_DBSETUPWIZARD_MYSQL_ODBC: - m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getDatasourcePrefix( ::dbaccess::DST_MYSQL_ODBC))); + m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:odbc:"))))); pPage = OConnectionTabPageSetup::CreateODBCTabPage( this, *m_pOutSet); break; case PAGE_DBSETUPWIZARD_MYSQL_JDBC: - m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getDatasourcePrefix( ::dbaccess::DST_MYSQL_JDBC))); + m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:jdbc:"))))); pPage = OGeneralSpecialJDBCConnectionPageSetup::CreateMySQLJDBCTabPage( this, *m_pOutSet); break; case PAGE_DBSETUPWIZARD_MYSQL_NATIVE: - m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getDatasourcePrefix( ::dbaccess::DST_MYSQL_NATIVE))); + m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:mysqlc:"))))); pPage = OGeneralSpecialJDBCConnectionPageSetup::CreateMySQLNATIVETabPage( this, *m_pOutSet); break; @@ -788,7 +728,7 @@ TabPage* ODbTypeWizDialogSetup::createPage(WizardState _nState) pPage->SetAdminDialog(this, this); defaultButton( _nState == PAGE_DBSETUPWIZARD_FINAL ? WZB_FINISH : WZB_NEXT ); - enableButtons( WZB_FINISH, _nState == START_PAGE ? sal_False : sal_True); + enableButtons( WZB_FINISH, _nState == PAGE_DBSETUPWIZARD_FINAL ); enableButtons( WZB_NEXT, _nState == PAGE_DBSETUPWIZARD_FINAL ? sal_False : sal_True); pPage->Show(); } @@ -811,23 +751,22 @@ IMPL_LINK(ODbTypeWizDialogSetup, ImplModifiedHdl, OGenericAdministrationPage*, _ // ----------------------------------------------------------------------------- -IMPL_LINK(ODbTypeWizDialogSetup, ImplClickHdl, OMySQLIntroPageSetup*, /*_pMySQLIntroPageSetup*/) +IMPL_LINK(ODbTypeWizDialogSetup, ImplClickHdl, OMySQLIntroPageSetup*, _pMySQLIntroPageSetup) { - const ::dbaccess::DATASOURCE_TYPE eType = getDatasourceType(*m_pOutSet); - switch( eType ) + ::rtl::OUString sURLPrefix; + switch( _pMySQLIntroPageSetup->getMySQLMode() ) { - case ::dbaccess::DST_MYSQL_ODBC: - activatePath( MYSQL_ODBC_PATH, sal_True); + case OMySQLIntroPageSetup::VIA_ODBC: + sURLPrefix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:odbc:")); break; - case ::dbaccess::DST_MYSQL_JDBC: - activatePath( MYSQL_JDBC_PATH, sal_True); + case OMySQLIntroPageSetup::VIA_JDBC: + sURLPrefix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:jdbc:")); break; - case ::dbaccess::DST_MYSQL_NATIVE: - activatePath( MYSQL_NATIVE_PATH, sal_True); + case OMySQLIntroPageSetup::VIA_NATIVE: + sURLPrefix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:mysqlc:")); break; - default: - ; - } + } // switch( _pMySQLIntroPageSetup->getMySQLMode() ) + activatePath( static_cast<PathId>(m_pCollection->getIndexOf(sURLPrefix) + 1), sal_True); return sal_True; } @@ -856,17 +795,17 @@ IMPL_LINK(ODbTypeWizDialogSetup, OnSingleDocumentChosen, OGeneralPage*, /*_pGene // ----------------------------------------------------------------------------- void ODbTypeWizDialogSetup::enterState(WizardState _nState) { - m_eType = m_pImpl->getDatasourceType(*m_pOutSet); + m_sURL = m_pImpl->getDatasourceType(*m_pOutSet); RoadmapWizard::enterState(_nState); switch(_nState) { case PAGE_DBSETUPWIZARD_INTRO: - m_eOldType = m_eType; + m_sOldURL = m_sURL; break; case PAGE_DBSETUPWIZARD_FINAL: enableButtons( WZB_FINISH, sal_True); if ( pFinalPage ) - pFinalPage->enableTableWizardCheckBox(m_pCollection->supportsTableCreation(m_eType)); + pFinalPage->enableTableWizardCheckBox(m_pCollection->supportsTableCreation(m_sURL)); break; } } @@ -886,17 +825,12 @@ sal_Bool ODbTypeWizDialogSetup::leaveState(WizardState _nState) { if (_nState == PAGE_DBSETUPWIZARD_MYSQL_INTRO) return sal_True; - if ( _nState == PAGE_DBSETUPWIZARD_INTRO ) + if ( _nState == PAGE_DBSETUPWIZARD_INTRO && m_sURL != m_sOldURL ) { - OSL_ENSURE(m_eType != ::dbaccess::DST_UNKNOWN && m_eOldType != ::dbaccess::DST_UNKNOWN,"Type unknown"); - if ( m_eType != m_eOldType ) - resetPages(m_pImpl->getCurrentDataSource()); + resetPages(m_pImpl->getCurrentDataSource()); } SfxTabPage* pPage = static_cast<SfxTabPage*>(WizardDialog::GetPage(_nState)); - if ( pPage ) - return pPage->DeactivatePage(m_pOutSet) != 0; - else - return sal_False; + return pPage && pPage->DeactivatePage(m_pOutSet) != 0; } // ----------------------------------------------------------------------------- @@ -980,39 +914,37 @@ sal_Bool ODbTypeWizDialogSetup::SaveDatabaseDocument() } //------------------------------------------------------------------------- - ::dbaccess::DATASOURCE_TYPE ODbTypeWizDialogSetup::getDefaultDatabaseType() const + ::rtl::OUString ODbTypeWizDialogSetup::getDefaultDatabaseType() const { - ::dbaccess::DATASOURCE_TYPE eRet = ::dbaccess::DST_DBASE; - - ::rtl::OUString sURL = m_pCollection->getDatasourcePrefix( ::dbaccess::DST_EMBEDDED_HSQLDB ); - Reference< XDriverAccess > xDriverManager( getORB()->createInstance( SERVICE_SDBC_DRIVERMANAGER ), UNO_QUERY ); - if ( xDriverManager.is() && xDriverManager->getDriverByURL( sURL ).is() ) - eRet = ::dbaccess::DST_EMBEDDED_HSQLDB; + ::rtl::OUString sEmbeddedURL = m_pCollection->getEmbeddedDatabase(); + ::connectivity::DriversConfig aDriverConfig(getORB()); + if ( !aDriverConfig.getDriverFactoryName(sEmbeddedURL).getLength() ) + sEmbeddedURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:")); - return eRet; + return sEmbeddedURL; } //------------------------------------------------------------------------- void ODbTypeWizDialogSetup::CreateDatabase() { ::rtl::OUString sUrl; - ::dbaccess::DATASOURCE_TYPE eType = getDefaultDatabaseType(); - if ( eType == ::dbaccess::DST_EMBEDDED_HSQLDB ) + ::rtl::OUString eType = getDefaultDatabaseType(); + if ( m_pCollection->isEmbeddedDatabase(eType) ) { - sUrl = m_pCollection->getDatasourcePrefix( ::dbaccess::DST_EMBEDDED_HSQLDB ); + sUrl = eType; Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource(); OSL_ENSURE(xDatasource.is(),"DataSource is null!"); if ( xDatasource.is() ) - xDatasource->setPropertyValue( PROPERTY_INFO, makeAny( m_pCollection->getDefaultDBSettings( ::dbaccess::DST_EMBEDDED_HSQLDB ) ) ); + xDatasource->setPropertyValue( PROPERTY_INFO, makeAny( m_pCollection->getDefaultDBSettings( eType ) ) ); m_pImpl->translateProperties(xDatasource,*m_pOutSet); } - if ( eType == ::dbaccess::DST_DBASE ) + else if ( m_pCollection->isFileSystemBased(eType) ) { Reference< XSimpleFileAccess > xSimpleFileAccess(getORB()->createInstance(::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" )), UNO_QUERY); INetURLObject aDBPathURL(m_sWorkPath); aDBPathURL.Append(m_aDocURL.getBase()); createUniqueFolderName(&aDBPathURL); - ::rtl::OUString sPrefix = m_pCollection->getDatasourcePrefix( ::dbaccess::DST_DBASE); + ::rtl::OUString sPrefix = eType; sUrl = aDBPathURL.GetMainURL( INetURLObject::NO_DECODE); xSimpleFileAccess->createFolder(sUrl); //OFileNotation aFileNotation(sUrl); diff --git a/dbaccess/source/ui/dlg/detailpages.cxx b/dbaccess/source/ui/dlg/detailpages.cxx index 6e65fbe5d253..c264e760a2f7 100644 --- a/dbaccess/source/ui/dlg/detailpages.cxx +++ b/dbaccess/source/ui/dlg/detailpages.cxx @@ -528,7 +528,7 @@ namespace dbaui //======================================================================== //= OMySQLJDBCDetailsPage //======================================================================== - OGeneralSpecialJDBCDetailsPage::OGeneralSpecialJDBCDetailsPage( Window* pParent,USHORT _nResId, const SfxItemSet& _rCoreAttrs ,USHORT _nPortId, const char* _pDriverName) + OGeneralSpecialJDBCDetailsPage::OGeneralSpecialJDBCDetailsPage( Window* pParent,USHORT _nResId, const SfxItemSet& _rCoreAttrs ,USHORT _nPortId) :OCommonBehaviourTabPage(pParent, _nResId, _rCoreAttrs, CBTP_USE_CHARSET ,false) ,m_aFL_1 (this, ModuleRes( FL_SEPARATOR1) ) ,m_aFTHostname (this, ModuleRes(FT_HOSTNAME)) @@ -543,12 +543,18 @@ namespace dbaui ,m_nPortId(_nPortId) ,m_bUseClass(true) { - if ( _pDriverName != NULL ) + SFX_ITEMSET_GET(_rCoreAttrs, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True); + SFX_ITEMSET_GET(_rCoreAttrs, pTypesItem, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True); + ::dbaccess::ODsnTypeCollection* pTypeCollection = pTypesItem ? pTypesItem->getCollection() : NULL; + if (pTypeCollection && pUrlItem && pUrlItem->GetValue().Len() ) + { + m_sDefaultJdbcDriverName = pTypeCollection->getJavaDriverClass(pUrlItem->GetValue()); + } + if ( m_sDefaultJdbcDriverName.Len() ) { m_aEDDriverClass.SetModifyHdl(getControlModifiedLink()); m_aEDDriverClass.SetModifyHdl(LINK(this, OGeneralSpecialJDBCDetailsPage, OnEditModified)); m_aTestJavaDriver.SetClickHdl(LINK(this,OGeneralSpecialJDBCDetailsPage,OnTestJavaClickHdl)); - m_sDefaultJdbcDriverName = String::CreateFromAscii(_pDriverName); } else { @@ -814,7 +820,7 @@ namespace dbaui // ----------------------------------------------------------------------- SfxTabPage* ODriversSettings::CreateMySQLJDBC( Window* pParent, const SfxItemSet& _rAttrSet ) { - return ( new OGeneralSpecialJDBCDetailsPage( pParent,PAGE_MYSQL_JDBC, _rAttrSet,DSID_MYSQL_PORTNUMBER ,"com.mysql.jdbc.Driver") ); + return ( new OGeneralSpecialJDBCDetailsPage( pParent,PAGE_MYSQL_JDBC, _rAttrSet,DSID_MYSQL_PORTNUMBER ) ); } // ----------------------------------------------------------------------- SfxTabPage* ODriversSettings::CreateMySQLNATIVE( Window* pParent, const SfxItemSet& _rAttrSet ) @@ -825,7 +831,7 @@ namespace dbaui // ----------------------------------------------------------------------- SfxTabPage* ODriversSettings::CreateOracleJDBC( Window* pParent, const SfxItemSet& _rAttrSet ) { - return ( new OGeneralSpecialJDBCDetailsPage( pParent,PAGE_ORACLE_JDBC, _rAttrSet,DSID_ORACLE_PORTNUMBER,"oracle.jdbc.driver.OracleDriver" ) ); + return ( new OGeneralSpecialJDBCDetailsPage( pParent,PAGE_ORACLE_JDBC, _rAttrSet,DSID_ORACLE_PORTNUMBER) ); } @@ -1181,7 +1187,7 @@ namespace dbaui //------------------------------------------------------------------------ SfxTabPage* ODriversSettings::CreateSpecialSettingsPage( Window* _pParent, const SfxItemSet& _rAttrSet ) { - ::dbaccess::DATASOURCE_TYPE eType = ODbDataSourceAdministrationHelper::getDatasourceType( _rAttrSet ); + ::rtl::OUString eType = ODbDataSourceAdministrationHelper::getDatasourceType( _rAttrSet ); DataSourceMetaData aMetaData( eType ); return new SpecialSettingsPage( _pParent, _rAttrSet, aMetaData ); } diff --git a/dbaccess/source/ui/dlg/detailpages.hxx b/dbaccess/source/ui/dlg/detailpages.hxx index 6d42f163a57b..7eeefd90e9c0 100644 --- a/dbaccess/source/ui/dlg/detailpages.hxx +++ b/dbaccess/source/ui/dlg/detailpages.hxx @@ -220,7 +220,7 @@ namespace dbaui , USHORT _nResId , const SfxItemSet& _rCoreAttrs , USHORT _nPortId - , const char* _pDriverName); + ); protected: diff --git a/dbaccess/source/ui/dlg/dsselect.cxx b/dbaccess/source/ui/dlg/dsselect.cxx index 7c67ebda24bf..e21417ffdb0c 100644 --- a/dbaccess/source/ui/dlg/dsselect.cxx +++ b/dbaccess/source/ui/dlg/dsselect.cxx @@ -107,7 +107,7 @@ using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::ui::dialogs; using namespace ::comphelper; //================================================================== -ODatasourceSelectDialog::ODatasourceSelectDialog(Window* _pParent, const StringBag& _rDatasources, ::dbaccess::DATASOURCE_TYPE _eType,SfxItemSet* _pOutputSet) +ODatasourceSelectDialog::ODatasourceSelectDialog(Window* _pParent, const StringBag& _rDatasources, bool _bAdabas,SfxItemSet* _pOutputSet) :ModalDialog(_pParent, ModuleRes(DLG_DATASOURCE_SELECTION)) ,m_aDescription (this, ModuleRes(FT_DESCRIPTION)) ,m_aDatasource (this, ModuleRes(LB_DATASOURCE)) @@ -120,7 +120,7 @@ ODatasourceSelectDialog::ODatasourceSelectDialog(Window* _pParent, const StringB ,m_aCreateAdabasDB (this, ModuleRes(PB_CREATE)) ,m_pOutputSet(_pOutputSet) { - if ( ::dbaccess::DST_ADABAS == _eType) + if ( _bAdabas ) { // set a new title (indicating that we're browsing local data sources only) SetText(ModuleRes(STR_LOCAL_DATASOURCES)); m_aDescription.SetText(ModuleRes(STR_DESCRIPTION2)); @@ -158,7 +158,7 @@ ODatasourceSelectDialog::ODatasourceSelectDialog(Window* _pParent, const StringB fillListBox(_rDatasources); #ifdef HAVE_ODBC_ADMINISTRATION // allow ODBC datasource managenment - if ( ::dbaccess::DST_ODBC == _eType || ::dbaccess::DST_MYSQL_ODBC == _eType ) + if ( !_bAdabas ) { m_aManageDatasources.Show(); m_aManageDatasources.Enable(); diff --git a/dbaccess/source/ui/dlg/dsselect.hxx b/dbaccess/source/ui/dlg/dsselect.hxx index 0a2bb0e7fe0a..c37121a170fe 100644 --- a/dbaccess/source/ui/dlg/dsselect.hxx +++ b/dbaccess/source/ui/dlg/dsselect.hxx @@ -72,7 +72,7 @@ protected: #endif public: - ODatasourceSelectDialog( Window* _pParent, const StringBag& _rDatasources, ::dbaccess::DATASOURCE_TYPE _eType,SfxItemSet* _pOutputSet = NULL ); + ODatasourceSelectDialog( Window* _pParent, const StringBag& _rDatasources, bool _bAdabas,SfxItemSet* _pOutputSet = NULL ); ~ODatasourceSelectDialog(); inline String GetSelected() const { return m_aDatasource.GetSelectEntry();} diff --git a/dbaccess/source/ui/dlg/generalpage.cxx b/dbaccess/source/ui/dlg/generalpage.cxx index 63a914b8b3c7..71708e6e87f3 100644 --- a/dbaccess/source/ui/dlg/generalpage.cxx +++ b/dbaccess/source/ui/dlg/generalpage.cxx @@ -32,59 +32,26 @@ #include "precompiled_dbaccess.hxx" #include "dsnItem.hxx" -#ifndef _DBAUI_GENERALPAGE_HXX_ #include "generalpage.hxx" -#endif -#ifndef _DBHELPER_DBEXCEPTION_HXX_ #include <connectivity/dbexception.hxx> -#endif -#ifndef _DBU_DLG_HRC_ #include "dbu_dlg.hrc" -#endif -#ifndef _DBAUI_DBADMIN_HRC_ #include "dbadmin.hrc" -#endif -#ifndef _DBAUI_DATASOURCEITEMS_HXX_ #include "dsitems.hxx" -#endif -#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC #include "dbustrings.hrc" -#endif -#ifndef _DBAUI_DBADMIN_HXX_ #include "dbadmin.hxx" -#endif #include <sfx2/filedlghelper.hxx> #include <sfx2/docfilt.hxx> -#ifndef _VCL_STDTEXT_HXX #include <vcl/stdtext.hxx> -#endif -#ifndef _DBAUI_LOCALRESACCESS_HXX_ #include "localresaccess.hxx" -#endif -#ifndef _SV_MSGBOX_HXX #include <vcl/msgbox.hxx> -#endif -#ifndef _SFXSTRITEM_HXX #include <svtools/stritem.hxx> -#endif -#ifndef _SV_WAITOBJ_HXX +#include <connectivity/DriversConfig.hxx> #include <vcl/waitobj.hxx> -#endif -#ifndef _COM_SUN_STAR_SDBC_XDRIVERACCESS_HPP_ #include <com/sun/star/sdbc/XDriverAccess.hpp> -#endif -#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ #include <com/sun/star/beans/PropertyValue.hpp> -#endif -#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ #include <com/sun/star/uno/Sequence.hxx> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ #include <com/sun/star/container/XNameAccess.hpp> -#endif -#ifndef DBAUI_DRIVERSETTINGS_HXX #include "DriverSettings.hxx" -#endif #include "UITools.hxx" //......................................................................... namespace dbaui @@ -120,11 +87,11 @@ namespace dbaui ,m_sMySQLEntry (ModuleRes(STR_MYSQLENTRY)) ,m_eOriginalCreationMode (eCreateNew) ,m_pCollection (NULL) - ,m_eCurrentSelection ( ::dbaccess::DST_UNKNOWN) ,m_eNotSupportedKnownType ( ::dbaccess::DST_UNKNOWN) ,m_eLastMessage (smNone) ,m_bDisplayingInvalid (sal_False) ,m_bUserGrabFocus (sal_True) + ,m_bInitTypeList (true) { // fill the listbox with the UI descriptions for the possible types // and remember the respective DSN prefixes @@ -159,10 +126,10 @@ namespace dbaui { struct DisplayedType { - ::dbaccess::DATASOURCE_TYPE eType; + ::rtl::OUString eType; String sDisplayName; - DisplayedType( ::dbaccess::DATASOURCE_TYPE _eType, const String& _rDisplayName ) : eType( _eType ), sDisplayName( _rDisplayName ) { } + DisplayedType( const ::rtl::OUString& _eType, const String& _rDisplayName ) : eType( _eType ), sDisplayName( _rDisplayName ) { } }; typedef ::std::vector< DisplayedType > DisplayedTypes; @@ -178,69 +145,51 @@ namespace dbaui //------------------------------------------------------------------------- void OGeneralPage::initializeTypeList() { - m_pDatasourceType->Clear(); - - Reference< XDriverAccess > xDriverManager; - - // get the driver manager, to ask it for all known URL prefixes - DBG_ASSERT(m_xORB.is(), "OGeneralPage::initializeTypeList: have no service factory!"); - if (m_xORB.is()) - { - { - // if the connection pool (resp. driver manager) may be expensive to load if it is accessed the first time, - // so display a wait cursor - WaitObject aWaitCursor(GetParent()); - xDriverManager = Reference< XDriverAccess >(m_xORB->createInstance(SERVICE_SDBC_CONNECTIONPOOL), UNO_QUERY); - if (!xDriverManager.is()) - xDriverManager = Reference< XDriverAccess >(m_xORB->createInstance(SERVICE_SDBC_DRIVERMANAGER), UNO_QUERY); - } - if (!xDriverManager.is()) - ShowServiceNotAvailableError(GetParent(), String(SERVICE_SDBC_DRIVERMANAGER), sal_True); - } - - if ( m_pCollection ) + if ( m_bInitTypeList ) { - DisplayedTypes aDisplayedTypes; + m_bInitTypeList = false; + m_pDatasourceType->Clear(); - for ( ::dbaccess::ODsnTypeCollection::TypeIterator aTypeLoop = m_pCollection->begin(); - aTypeLoop != m_pCollection->end(); - ++aTypeLoop - ) + if ( m_pCollection ) { - ::dbaccess::DATASOURCE_TYPE eType = aTypeLoop.getType(); - - if ( xDriverManager.is() ) - { // we have a driver manager to check - ::rtl::OUString sURLPrefix = m_pCollection->getDatasourcePrefix(eType); - if (!xDriverManager->getDriverByURL(sURLPrefix).is()) - // we have no driver for this prefix - // -> omit it - continue; - } - String sDisplayName = aTypeLoop.getDisplayName(); - if ( m_pDatasourceType->GetEntryPos( sDisplayName ) == LISTBOX_ENTRY_NOTFOUND ) + DisplayedTypes aDisplayedTypes; + + ::dbaccess::ODsnTypeCollection::TypeIterator aEnd = m_pCollection->end(); + for ( ::dbaccess::ODsnTypeCollection::TypeIterator aTypeLoop = m_pCollection->begin(); + aTypeLoop != aEnd; + ++aTypeLoop + ) { - if ( approveDataSourceType( eType, sDisplayName ) ) - aDisplayedTypes.push_back( DisplayedTypes::value_type( eType, sDisplayName ) ); + const ::rtl::OUString sURLPrefix = aTypeLoop.getURLPrefix(); + if ( sURLPrefix.getLength() ) + { + String sDisplayName = aTypeLoop.getDisplayName(); + if ( m_pDatasourceType->GetEntryPos( sDisplayName ) == LISTBOX_ENTRY_NOTFOUND + && approveDataSourceType( sURLPrefix, sDisplayName ) ) + { + aDisplayedTypes.push_back( DisplayedTypes::value_type( sURLPrefix, sDisplayName ) ); + } + } } - } - ::std::sort( aDisplayedTypes.begin(), aDisplayedTypes.end(), DisplayedTypeLess() ); - for ( DisplayedTypes::const_iterator loop = aDisplayedTypes.begin(); - loop != aDisplayedTypes.end(); - ++loop - ) - insertDatasourceTypeEntryData( loop->eType, loop->sDisplayName ); + ::std::sort( aDisplayedTypes.begin(), aDisplayedTypes.end(), DisplayedTypeLess() ); + DisplayedTypes::const_iterator aDisplayEnd = aDisplayedTypes.end(); + for ( DisplayedTypes::const_iterator loop = aDisplayedTypes.begin(); + loop != aDisplayEnd; + ++loop + ) + insertDatasourceTypeEntryData( loop->eType, loop->sDisplayName ); + } // if ( m_pCollection ) } } //------------------------------------------------------------------------- - void OGeneralPage::setParentTitle(::dbaccess::DATASOURCE_TYPE _eSelectedType) + void OGeneralPage::setParentTitle(const ::rtl::OUString& _sURLPrefix) { if (!m_DBWizardMode) { - String sName = m_pCollection->getTypeDisplayName(_eSelectedType); + const String sName = m_pCollection->getTypeDisplayName(_sURLPrefix); if ( m_pAdminDialog ) { LocalResourceAccess aStringResAccess( PAGE_GENERAL, RSC_TABPAGE ); @@ -272,10 +221,10 @@ namespace dbaui } //------------------------------------------------------------------------- - void OGeneralPage::switchMessage(const ::dbaccess::DATASOURCE_TYPE _eType) + void OGeneralPage::switchMessage(const ::rtl::OUString& _sURLPrefix) { SPECIAL_MESSAGE eMessage = smNone; - if ( _eType == m_eNotSupportedKnownType ) + if ( !_sURLPrefix.getLength()/*_eType == m_eNotSupportedKnownType*/ ) { eMessage = smUnsupportedType; } @@ -299,12 +248,12 @@ namespace dbaui } //------------------------------------------------------------------------- - void OGeneralPage::onTypeSelected(const ::dbaccess::DATASOURCE_TYPE _eType) + void OGeneralPage::onTypeSelected(const ::rtl::OUString& _sURLPrefix) { // the the new URL text as indicated by the selection history - implSetCurrentType( _eType ); + implSetCurrentType( _sURLPrefix ); - switchMessage(_eType); + switchMessage(_sURLPrefix); if ( m_aTypeSelectHandler.IsSet() ) m_aTypeSelectHandler.Call(this); @@ -382,16 +331,16 @@ namespace dbaui sConnectURL = pUrlItem->GetValue(); } - ::dbaccess::DATASOURCE_TYPE eOldSelection = m_eCurrentSelection; + ::rtl::OUString eOldSelection = m_eCurrentSelection; m_eNotSupportedKnownType = ::dbaccess::DST_UNKNOWN; - implSetCurrentType( ::dbaccess::DST_UNKNOWN ); + implSetCurrentType( ::rtl::OUString() ); // compare the DSN prefix with the registered ones String sDisplayName; if (m_pCollection && bValid) { - implSetCurrentType( m_pCollection->getType(sConnectURL) ); + implSetCurrentType( m_pCollection->getPrefix(sConnectURL) ); sDisplayName = m_pCollection->getTypeDisplayName(m_eCurrentSelection); } @@ -405,11 +354,11 @@ namespace dbaui insertDatasourceTypeEntryData(m_eCurrentSelection, sDisplayName); // remember this type so we can show the special message again if the user selects this // type again (without changing the data source) - m_eNotSupportedKnownType = m_eCurrentSelection; + m_eNotSupportedKnownType = m_pCollection->determineType(m_eCurrentSelection); } if (m_aRB_CreateDatabase.IsChecked() && m_DBWizardMode) - sDisplayName = m_pCollection->getTypeDisplayName( ::dbaccess::DST_JDBC); + sDisplayName = m_pCollection->getTypeDisplayName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("jdbc:"))); m_pDatasourceType->SelectEntry(sDisplayName); // notify our listener that our type selection has changed (if so) @@ -432,8 +381,9 @@ namespace dbaui // representative for all MySQl databases) // Also, embedded databases (embedded HSQL, at the moment), are not to appear in the list of // databases to connect to. - bool OGeneralPage::approveDataSourceType( ::dbaccess::DATASOURCE_TYPE eType, String& _inout_rDisplayName ) + bool OGeneralPage::approveDataSourceType( const ::rtl::OUString& _sURLPrefix, String& _inout_rDisplayName ) { + const ::dbaccess::DATASOURCE_TYPE eType = m_pCollection->determineType(_sURLPrefix); if ( m_DBWizardMode && ( eType == ::dbaccess::DST_MYSQL_JDBC ) ) _inout_rDisplayName = m_sMySQLEntry; @@ -451,11 +401,13 @@ namespace dbaui // ----------------------------------------------------------------------- - void OGeneralPage::insertDatasourceTypeEntryData(::dbaccess::DATASOURCE_TYPE _eType, String sDisplayName) + void OGeneralPage::insertDatasourceTypeEntryData(const ::rtl::OUString& _sType, String sDisplayName) { // insert a (temporary) entry sal_uInt16 nPos = m_pDatasourceType->InsertEntry(sDisplayName); - m_pDatasourceType->SetEntryData(nPos, reinterpret_cast<void*>(_eType)); + if ( nPos >= m_aURLPrefixes.size() ) + m_aURLPrefixes.resize(nPos+1); + m_aURLPrefixes[nPos] = _sType; } // ----------------------------------------------------------------------- @@ -480,7 +432,7 @@ namespace dbaui } //------------------------------------------------------------------------- - void OGeneralPage::implSetCurrentType( const ::dbaccess::DATASOURCE_TYPE _eType ) + void OGeneralPage::implSetCurrentType( const ::rtl::OUString& _eType ) { if ( _eType == m_eCurrentSelection ) return; @@ -492,7 +444,7 @@ namespace dbaui void OGeneralPage::Reset(const SfxItemSet& _rCoreAttrs) { // reset all locale data - implSetCurrentType( ::dbaccess::DST_UNKNOWN ); + implSetCurrentType( ::rtl::OUString() ); // this ensures that our type selection link will be called, even if the new is is the same as the // current one OGenericAdministrationPage::Reset(_rCoreAttrs); @@ -508,7 +460,7 @@ namespace dbaui { if ( m_aRB_CreateDatabase.IsChecked() ) { - _rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getDatasourcePrefix( ::dbaccess::DST_DBASE))); + _rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:")))); bChangedSomething = sal_True; bCommitTypeSelection = false; } @@ -525,24 +477,24 @@ namespace dbaui if ( bCommitTypeSelection ) { USHORT nEntry = m_pDatasourceType->GetSelectEntryPos(); - ::dbaccess::DATASOURCE_TYPE eSelectedType = static_cast< ::dbaccess::DATASOURCE_TYPE>(reinterpret_cast<sal_IntPtr>(m_pDatasourceType->GetEntryData(nEntry))); + ::rtl::OUString sURLPrefix = m_aURLPrefixes[nEntry]; if (m_DBWizardMode) { if ( ( m_pDatasourceType->GetSavedValue() != nEntry ) || ( GetDatabaseCreationMode() != m_eOriginalCreationMode ) ) { - _rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getDatasourcePrefix(eSelectedType))); + _rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL,sURLPrefix )); bChangedSomething = sal_True; } else - implSetCurrentType(eSelectedType); + implSetCurrentType(sURLPrefix); } else { if ( m_pDatasourceType->GetSavedValue() != nEntry) { - _rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getDatasourcePrefix(eSelectedType))); + _rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL, sURLPrefix)); bChangedSomething = sal_True; } } @@ -555,11 +507,11 @@ namespace dbaui { // get the type from the entry data sal_Int16 nSelected = _pBox->GetSelectEntryPos(); - ::dbaccess::DATASOURCE_TYPE eSelectedType = static_cast< ::dbaccess::DATASOURCE_TYPE>(reinterpret_cast<sal_IntPtr>(_pBox->GetEntryData(nSelected))); + const ::rtl::OUString sURLPrefix = m_aURLPrefixes[nSelected]; - setParentTitle(eSelectedType); + setParentTitle(sURLPrefix); // let the impl method do all the stuff - onTypeSelected(eSelectedType); + onTypeSelected(sURLPrefix); // tell the listener we were modified callModifiedHdl(); // outta here diff --git a/dbaccess/source/ui/dlg/generalpage.hxx b/dbaccess/source/ui/dlg/generalpage.hxx index 24f89ff3569f..973447460b14 100644 --- a/dbaccess/source/ui/dlg/generalpage.hxx +++ b/dbaccess/source/ui/dlg/generalpage.hxx @@ -102,11 +102,12 @@ namespace dbaui ::svt::ControlDependencyManager m_aControlDependencies; + ::std::vector< ::rtl::OUString> m_aURLPrefixes; ::dbaccess::ODsnTypeCollection* m_pCollection; /// the DSN type collection instance - ::dbaccess::DATASOURCE_TYPE m_eCurrentSelection; /// currently selected type + ::rtl::OUString m_eCurrentSelection; /// currently selected type ::dbaccess::DATASOURCE_TYPE m_eNotSupportedKnownType; /// if a data source of an unsupported, but known type is encountered .... enum SPECIAL_MESSAGE @@ -122,8 +123,9 @@ namespace dbaui Link m_aChooseDocumentHandler; /// to be called when a recent document has been definately chosen sal_Bool m_bDisplayingInvalid : 1; // the currently displayed data source is deleted sal_Bool m_bUserGrabFocus : 1; - bool approveDataSourceType( ::dbaccess::DATASOURCE_TYPE eType, String& _inout_rDisplayName ); - void insertDatasourceTypeEntryData(::dbaccess::DATASOURCE_TYPE eType, String sDisplayName); + bool m_bInitTypeList : 1; + bool approveDataSourceType( const ::rtl::OUString& _sURLPrefix, String& _inout_rDisplayName ); + void insertDatasourceTypeEntryData(const ::rtl::OUString& _sType, String sDisplayName); public: static SfxTabPage* Create(Window* pParent, const SfxItemSet& _rAttrSet, sal_Bool _bDBWizardMode = sal_False); @@ -138,7 +140,7 @@ namespace dbaui DocumentDescriptor GetSelectedDocument() const; /// get the currently selected datasource type - ::dbaccess::DATASOURCE_TYPE GetSelectedType() const { return m_eCurrentSelection; } + ::rtl::OUString GetSelectedType() const { return m_eCurrentSelection; } protected: // SfxTabPage overridables @@ -156,15 +158,15 @@ namespace dbaui protected: - void onTypeSelected(const ::dbaccess::DATASOURCE_TYPE _eType); + void onTypeSelected(const ::rtl::OUString& _sURLPrefix); void initializeTypeList(); - void implSetCurrentType( const ::dbaccess::DATASOURCE_TYPE _eType ); + void implSetCurrentType( const ::rtl::OUString& _eType ); - void switchMessage(const ::dbaccess::DATASOURCE_TYPE _eType); + void switchMessage(const ::rtl::OUString& _sURLPrefix); /// sets the the title of the parent dialog - void setParentTitle(::dbaccess::DATASOURCE_TYPE _eSelectedType); + void setParentTitle(const ::rtl::OUString& _sURLPrefix); DECL_LINK(OnDatasourceTypeSelected, ListBox*); DECL_LINK(OnSetupModeSelected, RadioButton*); diff --git a/dbaccess/source/ui/dlg/indexdialog.cxx b/dbaccess/source/ui/dlg/indexdialog.cxx index 75a2ae2a1cde..ea082491e85b 100644 --- a/dbaccess/source/ui/dlg/indexdialog.cxx +++ b/dbaccess/source/ui/dlg/indexdialog.cxx @@ -102,8 +102,9 @@ namespace dbaui return sal_False; ConstIndexFieldsIterator aLeft = _rLHS.begin(); + ConstIndexFieldsIterator aLeftEnd = _rLHS.end(); ConstIndexFieldsIterator aRight = _rRHS.begin(); - for (; aLeft != _rLHS.end(); ++aLeft, ++aRight) + for (; aLeft != aLeftEnd; ++aLeft, ++aRight) { if (*aLeft != *aRight) return sal_False; diff --git a/dbaccess/source/ui/dlg/makefile.mk b/dbaccess/source/ui/dlg/makefile.mk index 0502de1c2880..b0c991b176be 100644 --- a/dbaccess/source/ui/dlg/makefile.mk +++ b/dbaccess/source/ui/dlg/makefile.mk @@ -78,7 +78,6 @@ SRC1FILES = \ CollectionView.src \ dlgattr.src \ advancedsettings.src\ - AdabasStatDlg.src \ UserAdminDlg.src \ sqlmessage.src \ ExtensionNotPresent.src \ @@ -109,7 +108,6 @@ EXCEPTIONSFILES= \ $(SLO)$/TextConnectionHelper.obj \ $(SLO)$/ConnectionPageSetup.obj \ $(SLO)$/DBSetupConnectionPages.obj \ - $(SLO)$/AdabasStatDlg.obj \ $(SLO)$/UserAdminDlg.obj \ $(SLO)$/UserAdmin.obj \ $(SLO)$/AdabasStat.obj \ diff --git a/dbaccess/source/ui/inc/AdabasStatDlg.hxx b/dbaccess/source/ui/inc/AdabasStatDlg.hxx deleted file mode 100644 index 68c95b3500f0..000000000000 --- a/dbaccess/source/ui/inc/AdabasStatDlg.hxx +++ /dev/null @@ -1,99 +0,0 @@ -/************************************************************************* - * - * 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: AdabasStatDlg.hxx,v $ - * $Revision: 1.8.68.1 $ - * - * 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 DBAUI_ADABASSTATDLG_HXX -#define DBAUI_ADABASSTATDLG_HXX - -#ifndef _SFXTABDLG_HXX -#include <sfx2/tabdlg.hxx> -#endif -#ifndef _DBAUI_DSNTYPES_HXX_ -#include "dsntypes.hxx" -#endif -#ifndef DBAUI_ITEMSETHELPER_HXX -#include "IItemSetHelper.hxx" -#endif -#ifndef _COMPHELPER_UNO3_HXX_ -#include <comphelper/uno3.hxx> -#endif -#ifndef _DBAUI_MODULE_DBU_HXX_ -#include "moduledbu.hxx" -#endif -#include <memory> - -FORWARD_DECLARE_INTERFACE(beans,XPropertySet) -FORWARD_DECLARE_INTERFACE(sdbc,XConnection) -FORWARD_DECLARE_INTERFACE(lang,XMultiServiceFactory) - -//......................................................................... -namespace dbaui -{ -//......................................................................... - class ODbDataSourceAdministrationHelper; - //========================================================================= - //= OAdabasStatPageDlg - //========================================================================= - - /** implements the adabas admin dialog - */ - class OAdabasStatPageDlg : public SfxTabDialog, public IItemSetHelper, public IDatabaseSettingsDialog,public dbaui::OModuleClient - { - OModuleClient m_aModuleClient; - ::std::auto_ptr<ODbDataSourceAdministrationHelper> m_pImpl; - protected: - virtual void PageCreated(USHORT _nId, SfxTabPage& _rPage); - public: - OAdabasStatPageDlg( Window* _pParent - ,SfxItemSet* _pItems - ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB - ,const ::com::sun::star::uno::Any& _aDataSourceName); - - virtual ~OAdabasStatPageDlg(); - - virtual const SfxItemSet* getOutputSet() const; - virtual SfxItemSet* getWriteOutputSet(); - - virtual short Execute(); - - // forwards to ODbDataSourceAdministrationHelper - virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const; - virtual ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >,sal_Bool> createConnection(); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver(); - virtual ::dbaccess::DATASOURCE_TYPE getDatasourceType(const SfxItemSet& _rSet) const; - virtual void clearPassword(); - virtual sal_Bool saveDatasource(); - virtual void setTitle(const ::rtl::OUString& _sTitle); - virtual void enableConfirmSettings( bool _bEnable ); - }; -//......................................................................... -} // namespace dbaui -//......................................................................... - -#endif // DBAUI_ADABASSTATDLG_HXX diff --git a/dbaccess/source/ui/inc/IItemSetHelper.hxx b/dbaccess/source/ui/inc/IItemSetHelper.hxx index c4c2904487fe..4b040576d126 100644 --- a/dbaccess/source/ui/inc/IItemSetHelper.hxx +++ b/dbaccess/source/ui/inc/IItemSetHelper.hxx @@ -62,7 +62,7 @@ namespace dbaui virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const = 0; virtual ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >,sal_Bool> createConnection() = 0; virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver() = 0; - virtual ::dbaccess::DATASOURCE_TYPE getDatasourceType(const SfxItemSet& _rSet) const = 0; + virtual ::rtl::OUString getDatasourceType(const SfxItemSet& _rSet) const = 0; virtual void clearPassword() = 0; virtual sal_Bool saveDatasource() = 0; virtual void setTitle(const ::rtl::OUString& _sTitle) = 0; diff --git a/dbaccess/source/ui/inc/TableController.hxx b/dbaccess/source/ui/inc/TableController.hxx index 7f9d3bc5eb7e..736fd7bdf6a8 100644 --- a/dbaccess/source/ui/inc/TableController.hxx +++ b/dbaccess/source/ui/inc/TableController.hxx @@ -60,7 +60,6 @@ #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ #include <com/sun/star/container/XNameAccess.hpp> #endif -#include "dsntypes.hxx" class FixedText; namespace dbaui @@ -75,7 +74,6 @@ namespace dbaui ::std::vector< ::boost::shared_ptr<OTableRow> > m_vRowList; OTypeInfoMap m_aTypeInfo; ::std::vector<OTypeInfoMap::iterator> m_aTypeInfoIndex; - ::dbaccess::ODsnTypeCollection m_aTypeCollection; ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xTable; diff --git a/dbaccess/source/ui/inc/TableFieldDescription.hxx b/dbaccess/source/ui/inc/TableFieldDescription.hxx index a217f9af3eb5..80eeeff20dfa 100644 --- a/dbaccess/source/ui/inc/TableFieldDescription.hxx +++ b/dbaccess/source/ui/inc/TableFieldDescription.hxx @@ -131,10 +131,11 @@ namespace dbaui sal_Bool HasCriteria() const { ::std::vector< ::rtl::OUString>::const_iterator aIter = m_vecCriteria.begin(); - for(;aIter != m_vecCriteria.end();++aIter) + ::std::vector< ::rtl::OUString>::const_iterator aEnd = m_vecCriteria.end(); + for(;aIter != aEnd;++aIter) if(aIter->getLength()) break; - return aIter != m_vecCriteria.end(); + return aIter != aEnd; } const ::std::vector< ::rtl::OUString>& GetCriteria() const { return m_vecCriteria;} diff --git a/dbaccess/source/ui/inc/UserAdminDlg.hxx b/dbaccess/source/ui/inc/UserAdminDlg.hxx index 0f482be4baf8..cf748240bb71 100644 --- a/dbaccess/source/ui/inc/UserAdminDlg.hxx +++ b/dbaccess/source/ui/inc/UserAdminDlg.hxx @@ -90,7 +90,7 @@ namespace dbaui virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const; virtual ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >,sal_Bool> createConnection(); virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver(); - virtual ::dbaccess::DATASOURCE_TYPE getDatasourceType(const SfxItemSet& _rSet) const; + virtual ::rtl::OUString getDatasourceType(const SfxItemSet& _rSet) const; virtual void clearPassword(); virtual sal_Bool saveDatasource(); virtual void setTitle(const ::rtl::OUString& _sTitle); diff --git a/dbaccess/source/ui/inc/advancedsettingsdlg.hxx b/dbaccess/source/ui/inc/advancedsettingsdlg.hxx index 5f690f96893b..9e53c72c8614 100644 --- a/dbaccess/source/ui/inc/advancedsettingsdlg.hxx +++ b/dbaccess/source/ui/inc/advancedsettingsdlg.hxx @@ -72,7 +72,7 @@ namespace dbaui virtual ~AdvancedSettingsDialog(); /// determines whether or not the given data source type has any advanced setting - static bool doesHaveAnyAdvancedSettings( ::dbaccess::DATASOURCE_TYPE _eType ); + static bool doesHaveAnyAdvancedSettings( const ::rtl::OUString& _sURL ); virtual const SfxItemSet* getOutputSet() const; virtual SfxItemSet* getWriteOutputSet(); @@ -83,7 +83,7 @@ namespace dbaui virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const; virtual ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >,sal_Bool> createConnection(); virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver(); - virtual ::dbaccess::DATASOURCE_TYPE getDatasourceType(const SfxItemSet& _rSet) const; + virtual ::rtl::OUString getDatasourceType(const SfxItemSet& _rSet) const; virtual void clearPassword(); virtual sal_Bool saveDatasource(); virtual void setTitle(const ::rtl::OUString& _sTitle); diff --git a/dbaccess/source/ui/inc/curledit.hxx b/dbaccess/source/ui/inc/curledit.hxx index 1a4570512ec0..3bc7fa2b328f 100644 --- a/dbaccess/source/ui/inc/curledit.hxx +++ b/dbaccess/source/ui/inc/curledit.hxx @@ -40,6 +40,7 @@ #ifndef _DBAUI_DSNTYPES_HXX_ #include "dsntypes.hxx" #endif +#include <memory> //......................................................................... namespace dbaui @@ -55,8 +56,8 @@ namespace dbaui */ class OConnectionURLEdit : public Edit { - ::dbaccess::ODsnTypeCollection - m_aTypeCollection; + ::dbaccess::ODsnTypeCollection* + m_pTypeCollection; FixedText* m_pForcedPrefix; String m_sSaveValueNoPrefix; BOOL m_bShowPrefix; // when <TRUE> the prefix will be visible, otherwise not @@ -84,7 +85,7 @@ public: inline void SaveValueNoPrefix() { m_sSaveValueNoPrefix = GetTextNoPrefix(); } inline String GetSavedValueNoPrefix() const { return m_sSaveValueNoPrefix; } - inline void initializeTypeCollection(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB) { m_aTypeCollection.initUserDriverTypes(_rxORB); } + inline void SetTypeCollection(::dbaccess::ODsnTypeCollection* _pTypeCollection) { m_pTypeCollection = _pTypeCollection; } }; //......................................................................... diff --git a/dbaccess/source/ui/inc/dbadmin.hxx b/dbaccess/source/ui/inc/dbadmin.hxx index aae2b0af95f1..5c002747a1cc 100644 --- a/dbaccess/source/ui/inc/dbadmin.hxx +++ b/dbaccess/source/ui/inc/dbadmin.hxx @@ -105,7 +105,7 @@ public: virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const; virtual ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >,sal_Bool> createConnection(); virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver(); - virtual ::dbaccess::DATASOURCE_TYPE getDatasourceType(const SfxItemSet& _rSet) const; + virtual ::rtl::OUString getDatasourceType(const SfxItemSet& _rSet) const; virtual void clearPassword(); virtual sal_Bool saveDatasource(); virtual void setTitle(const ::rtl::OUString& _sTitle); diff --git a/dbaccess/source/ui/inc/dbu_resource.hrc b/dbaccess/source/ui/inc/dbu_resource.hrc index 41ed7e0a7fe6..28917c91396a 100644 --- a/dbaccess/source/ui/inc/dbu_resource.hrc +++ b/dbaccess/source/ui/inc/dbu_resource.hrc @@ -392,7 +392,7 @@ // free #define RSC_CHARSETS RID_UNTYPED_START + 2 -#define RSC_DATASOURCE_TYPE_UINAMES RID_UNTYPED_START + 3 +// free #define RSC_QUERY_OBJECT_TYPE RID_UNTYPED_START + 4 #define IMG_TABLESUBCRIPTION_SC RID_UNTYPED_START + 5 #define IMG_TABLESUBCRIPTION_SCH RID_UNTYPED_START + 6 diff --git a/dbaccess/source/ui/inc/dbwiz.hxx b/dbaccess/source/ui/inc/dbwiz.hxx index c0526a0d7533..dccb5109de83 100644 --- a/dbaccess/source/ui/inc/dbwiz.hxx +++ b/dbaccess/source/ui/inc/dbwiz.hxx @@ -77,7 +77,9 @@ private: OModuleClient m_aModuleClient; ::std::auto_ptr<ODbDataSourceAdministrationHelper> m_pImpl; SfxItemSet* m_pOutSet; - ::dbaccess::DATASOURCE_TYPE m_eType; + ::dbaccess::ODsnTypeCollection* + m_pCollection; /// the DSN type collection instance + ::rtl::OUString m_eType; sal_Bool m_bResetting : 1; /// sal_True while we're resetting the pages sal_Bool m_bApplied : 1; /// sal_True if any changes have been applied while the dialog was executing @@ -101,7 +103,7 @@ public: virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const; virtual ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >,sal_Bool> createConnection(); virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver(); - virtual ::dbaccess::DATASOURCE_TYPE getDatasourceType(const SfxItemSet& _rSet) const; + virtual ::rtl::OUString getDatasourceType(const SfxItemSet& _rSet) const; virtual void clearPassword(); virtual sal_Bool saveDatasource(); virtual void setTitle(const ::rtl::OUString& _sTitle); diff --git a/dbaccess/source/ui/inc/dbwizsetup.hxx b/dbaccess/source/ui/inc/dbwizsetup.hxx index b25bbad01a8e..2cf3577ba1c6 100644 --- a/dbaccess/source/ui/inc/dbwizsetup.hxx +++ b/dbaccess/source/ui/inc/dbwizsetup.hxx @@ -84,8 +84,8 @@ private: OModuleClient m_aModuleClient; ::std::auto_ptr<ODbDataSourceAdministrationHelper> m_pImpl; SfxItemSet* m_pOutSet; - ::dbaccess::DATASOURCE_TYPE m_eType; - ::dbaccess::DATASOURCE_TYPE m_eOldType; + ::rtl::OUString m_sURL; + ::rtl::OUString m_sOldURL; sal_Bool m_bResetting : 1; /// sal_True while we're resetting the pages sal_Bool m_bApplied : 1; /// sal_True if any changes have been applied while the dialog was executing sal_Bool m_bUIEnabled : 1; /// <TRUE/> if the UI is enabled, false otherwise. Cannot be switched back to <TRUE/>, once it is <FALSE/> @@ -131,7 +131,7 @@ public: virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const; virtual ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >,sal_Bool> createConnection(); virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver(); - virtual ::dbaccess::DATASOURCE_TYPE getDatasourceType(const SfxItemSet& _rSet) const; + virtual ::rtl::OUString getDatasourceType(const SfxItemSet& _rSet) const; virtual void clearPassword(); virtual void setTitle(const ::rtl::OUString& _sTitle); virtual void enableConfirmSettings( bool _bEnable ); @@ -172,7 +172,7 @@ protected: private: /** declares a path with or without authentication, as indicated by the database type - @param _eType + @param _sURL the data source type for which the path is declared. If this data source type does not support authentication, the PAGE_DBSETUPWIZARD_AUTHENTIFICATION state will be stripped from the sequence of states. @@ -182,7 +182,7 @@ private: the first state in this path, following by an arbitrary number of others, as in RoadmapWizard::declarePath. */ - void declareAuthDepPath( ::dbaccess::DATASOURCE_TYPE _eType, PathId _nPathId, WizardState _nFirstState, ... ); + void declareAuthDepPath( const ::rtl::OUString& _sURL, PathId _nPathId, const svt::RoadmapWizardTypes::WizardPath& _rPaths); void RegisterDataSourceByLocation(const ::rtl::OUString& sPath); sal_Bool SaveDatabaseDocument(); @@ -192,7 +192,7 @@ private: void createUniqueFolderName(INetURLObject* pURL); ::dbaccess::DATASOURCE_TYPE VerifyDataSourceType(const ::dbaccess::DATASOURCE_TYPE _DatabaseType) const; - ::dbaccess::DATASOURCE_TYPE getDefaultDatabaseType() const; + ::rtl::OUString getDefaultDatabaseType() const; void updateTypeDependentStates(); sal_Bool callSaveAsDialog(); diff --git a/dbaccess/source/ui/inc/dsmeta.hxx b/dbaccess/source/ui/inc/dsmeta.hxx index 88053668a4ed..62ad79e80a67 100644 --- a/dbaccess/source/ui/inc/dsmeta.hxx +++ b/dbaccess/source/ui/inc/dsmeta.hxx @@ -70,7 +70,7 @@ namespace dbaui class DataSourceMetaData { public: - DataSourceMetaData( ::dbaccess::DATASOURCE_TYPE _eType ); + DataSourceMetaData( const ::rtl::OUString& _sURL ); ~DataSourceMetaData(); /// returns a struct describing this data source type's support for our known advanced settings @@ -79,7 +79,7 @@ namespace dbaui /// determines whether or not the data source requires authentication AuthenticationMode getAuthentication() const; - static AuthenticationMode getAuthentication( ::dbaccess::DATASOURCE_TYPE _eType ); + static AuthenticationMode getAuthentication( const ::rtl::OUString& _sURL ); private: ::boost::shared_ptr< DataSourceMetaData_Impl > m_pImpl; @@ -108,7 +108,6 @@ namespace dbaui bool bBooleanComparisonMode; bool bFormsCheckRequiredFields; bool bIgnoreCurrency; - bool bAutoIncrementIsPrimaryKey; bool bEscapeDateTime; // Note: If you extend this list, you need to adjust the ctor (of course) @@ -130,7 +129,6 @@ namespace dbaui ,bBooleanComparisonMode ( true ) ,bFormsCheckRequiredFields ( true ) ,bIgnoreCurrency ( false ) - ,bAutoIncrementIsPrimaryKey ( false ) ,bEscapeDateTime ( false ) { } @@ -158,7 +156,6 @@ namespace dbaui || ( bBooleanComparisonMode == true ) || ( bFormsCheckRequiredFields == true ) || ( bIgnoreCurrency == true ) - || ( bAutoIncrementIsPrimaryKey == true ) || ( bEscapeDateTime == true ) ; } diff --git a/dbaccess/source/ui/misc/DExport.cxx b/dbaccess/source/ui/misc/DExport.cxx index 880bb91b3727..629f431c39a5 100644 --- a/dbaccess/source/ui/misc/DExport.cxx +++ b/dbaccess/source/ui/misc/DExport.cxx @@ -686,35 +686,7 @@ sal_Bool ODatabaseExport::createRowSet() { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::createRowSet" ); DBG_CHKTHIS(ODatabaseExport,NULL); - //Reference<XResultSet> xDestSet(m_xFactory->createInstance(::rtl::OUString::createFromAscii("com.sun.star.sdb.RowSet")),UNO_QUERY); - //Reference<XPropertySet > xProp(xDestSet,UNO_QUERY); - //if(xProp.is()) - //{ - // ::rtl::OUString sDestName = ::dbtools::composeTableName( - // m_xConnection->getMetaData(), m_xTable, ::dbtools::eInDataManipulation, false, false, false ); - - // xProp->setPropertyValue(PROPERTY_ACTIVE_CONNECTION,makeAny(m_xConnection.getTyped())); - // xProp->setPropertyValue(PROPERTY_COMMAND_TYPE,makeAny(CommandType::TABLE)); - // xProp->setPropertyValue(PROPERTY_COMMAND,makeAny(sDestName)); - // xProp->setPropertyValue(PROPERTY_IGNORERESULT,::cppu::bool2any(sal_True)); - // xProp->setPropertyValue(PROPERTY_FETCHSIZE,sal_Int32(1)); - // Reference<XRowSet> xRowSet(xProp,UNO_QUERY); - // xRowSet->execute(); - - // Reference< XResultSetMetaDataSupplier> xSrcMetaSup(xRowSet,UNO_QUERY_THROW); - // m_xResultSetMetaData = xSrcMetaSup->getMetaData(); - - // if ( ::dbtools::canInsert(xProp) ) - // { - // m_pUpdateHelper.reset(new ORowUpdateHelper(xRowSet)); - // OSL_ENSURE(m_xResultSetMetaData.is(),"No ResultSetMetaData!"); - // TPositions::iterator aIter = m_vColumns.begin(); - // for (;aIter != m_vColumns.end() ; ++aIter) - // aIter->first = aIter->second; - // } - // else - m_pUpdateHelper.reset(new OParameterUpdateHelper(createPreparedStatment(m_xConnection->getMetaData(),m_xTable,m_vColumns))); - //} + m_pUpdateHelper.reset(new OParameterUpdateHelper(createPreparedStatment(m_xConnection->getMetaData(),m_xTable,m_vColumns))); return m_pUpdateHelper.get() != NULL; } @@ -891,7 +863,8 @@ Reference< XPreparedStatement > ODatabaseExport::createPreparedStatment( const R i = 1; // create the sql string - for (::std::vector< ::rtl::OUString>::iterator aInsertIter = aInsertList.begin(); aInsertIter != aInsertList.end(); ++aInsertIter) + ::std::vector< ::rtl::OUString>::iterator aInsertEnd = aInsertList.end(); + for (::std::vector< ::rtl::OUString>::iterator aInsertIter = aInsertList.begin(); aInsertIter != aInsertEnd; ++aInsertIter) { if ( aInsertIter->getLength() ) { diff --git a/dbaccess/source/ui/misc/RowSetDrop.cxx b/dbaccess/source/ui/misc/RowSetDrop.cxx index 54b7c4cf36a6..53b1105c6aba 100644 --- a/dbaccess/source/ui/misc/RowSetDrop.cxx +++ b/dbaccess/source/ui/misc/RowSetDrop.cxx @@ -177,7 +177,8 @@ sal_Bool ORowSetImportExport::insertNewRow() { m_xTargetResultSetUpdate->moveToInsertRow(); sal_Int32 i = 1; - for (::std::vector<sal_Int32>::iterator aIter = m_aColumnMapping.begin(); aIter != m_aColumnMapping.end() ;++aIter,++i ) + ::std::vector<sal_Int32>::iterator aEnd = m_aColumnMapping.end(); + for (::std::vector<sal_Int32>::iterator aIter = m_aColumnMapping.begin(); aIter != aEnd ;++aIter,++i ) { if(*aIter > 0) { diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx index 809f9c407e51..25a6299bae12 100644 --- a/dbaccess/source/ui/misc/UITools.cxx +++ b/dbaccess/source/ui/misc/UITools.cxx @@ -867,7 +867,8 @@ void fillTypeInfo( const Reference< ::com::sun::star::sdbc::XConnection>& _rxCo _rTypeInfoIters.reserve(_rTypeInfoMap.size()); OTypeInfoMap::iterator aIter = _rTypeInfoMap.begin(); - for(;aIter != _rTypeInfoMap.end();++aIter) + OTypeInfoMap::iterator aEnd = _rTypeInfoMap.end(); + for(;aIter != aEnd;++aIter) _rTypeInfoIters.push_back(aIter); // Close the result set/statement. diff --git a/dbaccess/source/ui/misc/WCPage.cxx b/dbaccess/source/ui/misc/WCPage.cxx index a6788ac1926f..f4b71e145349 100644 --- a/dbaccess/source/ui/misc/WCPage.cxx +++ b/dbaccess/source/ui/misc/WCPage.cxx @@ -336,10 +336,11 @@ sal_Bool OCopyTable::checkAppendData() // #90027# const ODatabaseExport::TColumnVector* pDestColumns = m_pParent->getDestVector(); ODatabaseExport::TColumnVector::const_iterator aDestIter = pDestColumns->begin(); + ODatabaseExport::TColumnVector::const_iterator aDestEnd = pDestColumns->end(); const sal_uInt32 nDestSize = pDestColumns->size(); sal_Bool bNotConvert; sal_uInt32 i = 0; - for(sal_Int32 nPos = 1;aDestIter != pDestColumns->end() && i < nDestSize && i < nSrcSize;++aDestIter,++nPos,++i) + for(sal_Int32 nPos = 1;aDestIter != aDestEnd && i < nDestSize && i < nSrcSize;++aDestIter,++nPos,++i) { bNotConvert = sal_True; m_pParent->m_vColumnPos[i] = ODatabaseExport::TPositions::value_type(nPos,nPos); diff --git a/dbaccess/source/ui/misc/WColumnSelect.cxx b/dbaccess/source/ui/misc/WColumnSelect.cxx index 9b4ad13d8dc7..69d5c3bad4fd 100644 --- a/dbaccess/source/ui/misc/WColumnSelect.cxx +++ b/dbaccess/source/ui/misc/WColumnSelect.cxx @@ -144,8 +144,9 @@ void OWizColumnSelect::Reset() // insert the source columns in the left listbox const ODatabaseExport::TColumnVector* pSrcColumns = m_pParent->getSrcVector(); ODatabaseExport::TColumnVector::const_iterator aIter = pSrcColumns->begin(); + ODatabaseExport::TColumnVector::const_iterator aEnd = pSrcColumns->end(); - for(;aIter != pSrcColumns->end();++aIter) + for(;aIter != aEnd;++aIter) { sal_uInt16 nPos = m_lbOrgColumnNames.InsertEntry((*aIter)->first); m_lbOrgColumnNames.SetEntryData(nPos,(*aIter)->second); diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx index ca9aeacf73e4..7b5181e8fe4b 100644 --- a/dbaccess/source/ui/misc/WCopyTable.cxx +++ b/dbaccess/source/ui/misc/WCopyTable.cxx @@ -831,7 +831,8 @@ sal_Bool OCopyTableWizard::CheckColumns(sal_Int32& _rnBreakPos) if ( bContainsColumns ) { // we have dest columns so look for the matching column ODatabaseExport::TColumnVector::const_iterator aSrcIter = m_vSourceVec.begin(); - for(;aSrcIter != m_vSourceVec.end();++aSrcIter) + ODatabaseExport::TColumnVector::const_iterator aSrcEnd = m_vSourceVec.end(); + for(;aSrcIter != aSrcEnd;++aSrcIter) { ODatabaseExport::TColumns::iterator aDestIter = m_vDestColumns.find(m_mNameMapping[(*aSrcIter)->first]); @@ -856,7 +857,8 @@ sal_Bool OCopyTableWizard::CheckColumns(sal_Int32& _rnBreakPos) sal_Int32 nMaxNameLen = getMaxColumnNameLength(); ODatabaseExport::TColumnVector::const_iterator aSrcIter = m_vSourceVec.begin(); - for(_rnBreakPos=0;aSrcIter != m_vSourceVec.end() && bRet ;++aSrcIter,++_rnBreakPos) + ODatabaseExport::TColumnVector::const_iterator aSrcEnd = m_vSourceVec.end(); + for(_rnBreakPos=0;aSrcIter != aSrcEnd && bRet ;++aSrcIter,++_rnBreakPos) { OFieldDescription* pField = new OFieldDescription(*(*aSrcIter)->second); pField->SetName(convertColumnName(TExportColumnFindFunctor(&m_vDestColumns),(*aSrcIter)->first,sExtraChars,nMaxNameLen)); @@ -1096,7 +1098,8 @@ void OCopyTableWizard::impl_loadSourceData() void OCopyTableWizard::loadData( const ICopyTableSourceObject& _rSourceObject, ODatabaseExport::TColumns& _rColumns, ODatabaseExport::TColumnVector& _rColVector ) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::loadData" ); - for ( ODatabaseExport::TColumns::iterator col = _rColumns.begin(); col != _rColumns.end(); ++col ) + ODatabaseExport::TColumns::iterator colEnd = _rColumns.end(); + for ( ODatabaseExport::TColumns::iterator col = _rColumns.begin(); col != colEnd; ++col ) delete col->second; _rColVector.clear(); @@ -1176,7 +1179,8 @@ void OCopyTableWizard::appendColumns( Reference<XColumnsSupplier>& _rxColSup, co OSL_ENSURE(xAppend.is(),"No XAppend Interface!"); ODatabaseExport::TColumnVector::const_iterator aIter = _pVec->begin(); - for(;aIter != _pVec->end();++aIter) + ODatabaseExport::TColumnVector::const_iterator aEnd = _pVec->end(); + for(;aIter != aEnd;++aIter) { OFieldDescription* pField = (*aIter)->second; if(!pField) diff --git a/dbaccess/source/ui/misc/WNameMatch.cxx b/dbaccess/source/ui/misc/WNameMatch.cxx index 5325f0388cfc..5b50a7e553cd 100644 --- a/dbaccess/source/ui/misc/WNameMatch.cxx +++ b/dbaccess/source/ui/misc/WNameMatch.cxx @@ -187,9 +187,10 @@ sal_Bool OWizNameMatching::LeavePage() DBG_ASSERT(pSrcField,"OWizNameMatching: OColumn can not be null!"); ODatabaseExport::TColumnVector::const_iterator aSrcIter = pSrcColumns->begin(); - for(;aSrcIter != pSrcColumns->end() && (*aSrcIter)->second != pSrcField;++aSrcIter) + ODatabaseExport::TColumnVector::const_iterator aSrcEnd = pSrcColumns->end(); + for(;aSrcIter != aSrcEnd && (*aSrcIter)->second != pSrcField;++aSrcIter) ; - sal_Int32 nPos = ::std::distance(pSrcColumns->begin(),aSrcIter); + const sal_Int32 nPos = ::std::distance(pSrcColumns->begin(),aSrcIter); // sal_Int32 nPos = m_CTRL_LEFT.GetModel()->GetAbsPos(pLeftEntry); if(m_CTRL_LEFT.GetCheckButtonState(pLeftEntry) == SV_BUTTON_CHECKED) @@ -198,8 +199,9 @@ sal_Bool OWizNameMatching::LeavePage() DBG_ASSERT(pDestField,"OWizNameMatching: OColumn can not be null!"); const ODatabaseExport::TColumnVector* pDestColumns = m_pParent->getDestVector(); ODatabaseExport::TColumnVector::const_iterator aDestIter = pDestColumns->begin(); + ODatabaseExport::TColumnVector::const_iterator aDestEnd = pDestColumns->end(); - for(;aDestIter != pDestColumns->end() && (*aDestIter)->second != pDestField;++aDestIter) + for(;aDestIter != aDestEnd && (*aDestIter)->second != pDestField;++aDestIter) ; OSL_ENSURE((nPos) < static_cast<sal_Int32>(m_pParent->m_vColumnPos.size()),"m_pParent->m_vColumnPos: Illegal index for vector"); @@ -435,7 +437,8 @@ void OColumnTreeBox::FillListBox( const ODatabaseExport::TColumnVector& _rList) { Clear(); ODatabaseExport::TColumnVector::const_iterator aIter = _rList.begin(); - for(;aIter != _rList.end();++aIter) + ODatabaseExport::TColumnVector::const_iterator aEnd = _rList.end(); + for(;aIter != aEnd;++aIter) { SvLBoxEntry* pEntry = InsertEntry((*aIter)->first,0,sal_False,LIST_APPEND,(*aIter)->second); SvButtonState eState = !(m_bReadOnly && (*aIter)->second->IsAutoIncrement()) ? SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED; diff --git a/dbaccess/source/ui/misc/WTypeSelect.cxx b/dbaccess/source/ui/misc/WTypeSelect.cxx index fa6e91142fc9..ceeb058528df 100644 --- a/dbaccess/source/ui/misc/WTypeSelect.cxx +++ b/dbaccess/source/ui/misc/WTypeSelect.cxx @@ -339,7 +339,8 @@ void OWizTypeSelect::Reset() const ODatabaseExport::TColumnVector* pDestColumns = m_pParent->getDestVector(); ODatabaseExport::TColumnVector::const_iterator aIter = pDestColumns->begin(); - for(;aIter != pDestColumns->end();++aIter) + ODatabaseExport::TColumnVector::const_iterator aEnd = pDestColumns->end(); + for(;aIter != aEnd;++aIter) { sal_uInt16 nPos; if((*aIter)->second->IsPrimaryKey()) diff --git a/dbaccess/source/ui/misc/dsmeta.cxx b/dbaccess/source/ui/misc/dsmeta.cxx index aa50736ba6b7..f758f529f66f 100644 --- a/dbaccess/source/ui/misc/dsmeta.cxx +++ b/dbaccess/source/ui/misc/dsmeta.cxx @@ -29,7 +29,9 @@ ************************************************************************/ #include "dsmeta.hxx" - +#include <connectivity/DriversConfig.hxx> +#include "dsntypes.hxx" +#include <comphelper/processfactory.hxx> /** === begin UNO includes === **/ /** === end UNO includes === **/ @@ -41,34 +43,12 @@ namespace dbaui //........................................................................ /** === begin UNO using === **/ + using namespace dbaccess; + using namespace ::com::sun::star; /** === end UNO using === **/ struct InitAdvanced : public AdvancedSettingsSupport { - // strange ctor, but makes instantiating this class more readable (see below) - InitAdvanced( short _Generated, short _SQL, short _Append, short _As, short _Outer, short _Priv, short _Param, - short _Version, short _Catalog, short _Schema, short _Index, short _DOS, short _Required, short _Bool,short _IgnoreCur,short _AutoPKey, short _EscapeDT ) - :AdvancedSettingsSupport() - { - bGeneratedValues = ( _Generated != 0 ); - bUseSQL92NamingConstraints = ( _SQL != 0 ); - bAppendTableAliasInSelect = ( _Append != 0 ); - bUseKeywordAsBeforeAlias = ( _As != 0 ); - bUseBracketedOuterJoinSyntax = ( _Outer != 0 ); - bIgnoreDriverPrivileges = ( _Priv != 0 ); - bParameterNameSubstitution = ( _Param != 0 ); - bDisplayVersionColumns = ( _Version != 0 ); - bUseCatalogInSelect = ( _Catalog != 0 ); - bUseSchemaInSelect = ( _Schema != 0 ); - bUseIndexDirectionKeyword = ( _Index != 0 ); - bUseDOSLineEnds = ( _DOS != 0 ); - bBooleanComparisonMode = ( _Bool != 0 ); - bFormsCheckRequiredFields = ( _Required != 0 ); - bIgnoreCurrency = ( _IgnoreCur != 0 ); - bAutoIncrementIsPrimaryKey = ( _AutoPKey != 0 ); - bEscapeDateTime = ( _EscapeDT != 0 ); - } - enum Special { All, AllButIgnoreCurrency, None }; InitAdvanced( Special _eType ) @@ -89,7 +69,6 @@ namespace dbaui bBooleanComparisonMode = ( _eType == All ) || ( _eType == AllButIgnoreCurrency ); bFormsCheckRequiredFields = ( _eType == All ) || ( _eType == AllButIgnoreCurrency ); bIgnoreCurrency = ( _eType == All ); - bAutoIncrementIsPrimaryKey = false; // hsqldb special bEscapeDateTime = ( _eType == All ) || ( _eType == AllButIgnoreCurrency ); } }; @@ -114,95 +93,125 @@ namespace dbaui //= global tables //==================================================================== //-------------------------------------------------------------------- - static const AdvancedSettingsSupport& getAdvancedSettingsSupport( ::dbaccess::DATASOURCE_TYPE _eType ) + static const AdvancedSettingsSupport& getAdvancedSettingsSupport( const ::rtl::OUString& _sURL ) { - typedef ::std::map< ::dbaccess::DATASOURCE_TYPE, AdvancedSettingsSupport > AdvancedSupport; - + DECLARE_STL_USTRINGACCESS_MAP( AdvancedSettingsSupport, AdvancedSupport); static AdvancedSupport s_aSupport; if ( s_aSupport.empty() ) { - s_aSupport[ ::dbaccess::DST_MSACCESS ] = InitAdvanced( 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0 ); - s_aSupport[ ::dbaccess::DST_MYSQL_ODBC ] = InitAdvanced( 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0 ); - s_aSupport[ ::dbaccess::DST_MYSQL_JDBC ] = InitAdvanced( 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1 ); - s_aSupport[ ::dbaccess::DST_MYSQL_NATIVE ] = InitAdvanced( 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0 ); - s_aSupport[ ::dbaccess::DST_ORACLE_JDBC ] = InitAdvanced( InitAdvanced::All ); - s_aSupport[ ::dbaccess::DST_ADABAS ] = InitAdvanced( 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0 ); - s_aSupport[ ::dbaccess::DST_CALC ] = InitAdvanced( InitAdvanced::None ); - s_aSupport[ ::dbaccess::DST_DBASE ] = InitAdvanced( 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ); - s_aSupport[ ::dbaccess::DST_FLAT ] = InitAdvanced( 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ); - s_aSupport[ ::dbaccess::DST_JDBC ] = InitAdvanced( InitAdvanced::AllButIgnoreCurrency ); - s_aSupport[ ::dbaccess::DST_ODBC ] = InitAdvanced( InitAdvanced::AllButIgnoreCurrency ); - s_aSupport[ ::dbaccess::DST_ADO ] = InitAdvanced( 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 ); - s_aSupport[ ::dbaccess::DST_MOZILLA ] = InitAdvanced( InitAdvanced::None ); - s_aSupport[ ::dbaccess::DST_THUNDERBIRD ] = InitAdvanced( InitAdvanced::None ); - s_aSupport[ ::dbaccess::DST_LDAP ] = InitAdvanced( InitAdvanced::None ); - s_aSupport[ ::dbaccess::DST_OUTLOOK ] = InitAdvanced( InitAdvanced::None ); - s_aSupport[ ::dbaccess::DST_OUTLOOKEXP ] = InitAdvanced( InitAdvanced::None ); - s_aSupport[ ::dbaccess::DST_EVOLUTION ] = InitAdvanced( InitAdvanced::None ); - s_aSupport[ ::dbaccess::DST_EVOLUTION_GROUPWISE ] = InitAdvanced( InitAdvanced::None ); - s_aSupport[ ::dbaccess::DST_EVOLUTION_LDAP ] = InitAdvanced( InitAdvanced::None ); - s_aSupport[ ::dbaccess::DST_KAB ] = InitAdvanced( InitAdvanced::None ); - s_aSupport[ ::dbaccess::DST_MACAB ] = InitAdvanced( InitAdvanced::None ); - s_aSupport[ ::dbaccess::DST_MSACCESS_2007 ] = InitAdvanced( 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0 ); - s_aSupport[ ::dbaccess::DST_EMBEDDED_HSQLDB ] = InitAdvanced( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0 ); - s_aSupport[ ::dbaccess::DST_USERDEFINE1 ] = InitAdvanced( InitAdvanced::AllButIgnoreCurrency ); - s_aSupport[ ::dbaccess::DST_USERDEFINE2 ] = InitAdvanced( InitAdvanced::AllButIgnoreCurrency ); - s_aSupport[ ::dbaccess::DST_USERDEFINE3 ] = InitAdvanced( InitAdvanced::AllButIgnoreCurrency ); - s_aSupport[ ::dbaccess::DST_USERDEFINE4 ] = InitAdvanced( InitAdvanced::AllButIgnoreCurrency ); - s_aSupport[ ::dbaccess::DST_USERDEFINE5 ] = InitAdvanced( InitAdvanced::AllButIgnoreCurrency ); - s_aSupport[ ::dbaccess::DST_USERDEFINE6 ] = InitAdvanced( InitAdvanced::AllButIgnoreCurrency ); - s_aSupport[ ::dbaccess::DST_USERDEFINE7 ] = InitAdvanced( InitAdvanced::AllButIgnoreCurrency ); - s_aSupport[ ::dbaccess::DST_USERDEFINE8 ] = InitAdvanced( InitAdvanced::AllButIgnoreCurrency ); - s_aSupport[ ::dbaccess::DST_USERDEFINE9 ] = InitAdvanced( InitAdvanced::AllButIgnoreCurrency ); - s_aSupport[ ::dbaccess::DST_USERDEFINE10 ] = InitAdvanced( InitAdvanced::AllButIgnoreCurrency ); - } - return s_aSupport[ _eType ]; + ::connectivity::DriversConfig aDriverConfig(::comphelper::getProcessServiceFactory()); + const uno::Sequence< ::rtl::OUString > aURLs = aDriverConfig.getURLs(); + const ::rtl::OUString* pIter = aURLs.getConstArray(); + const ::rtl::OUString* pEnd = pIter + aURLs.getLength(); + for(;pIter != pEnd;++pIter) + { + InitAdvanced aInit(InitAdvanced::None); + const uno::Sequence< beans::NamedValue> aProperties = aDriverConfig.getFeatures(*pIter).getNamedValues(); + const beans::NamedValue* pPropertiesIter = aProperties.getConstArray(); + const beans::NamedValue* pPropertiesEnd = pPropertiesIter + aProperties.getLength(); + for (;pPropertiesIter != pPropertiesEnd ; ++pPropertiesIter) + { + if ( pPropertiesIter->Name.equalsAscii("GeneratedValues") ) + { + pPropertiesIter->Value >>= aInit.bGeneratedValues; + } + else if ( pPropertiesIter->Name.equalsAscii("UseSQL92NamingConstraints") ) + { + pPropertiesIter->Value >>= aInit.bUseSQL92NamingConstraints; + } + else if ( pPropertiesIter->Name.equalsAscii("AppendTableAliasInSelect") ) + { + pPropertiesIter->Value >>= aInit.bAppendTableAliasInSelect; + } + else if ( pPropertiesIter->Name.equalsAscii("UseKeywordAsBeforeAlias") ) + { + pPropertiesIter->Value >>= aInit.bUseKeywordAsBeforeAlias; + } + else if ( pPropertiesIter->Name.equalsAscii("UseBracketedOuterJoinSyntax") ) + { + pPropertiesIter->Value >>= aInit.bUseBracketedOuterJoinSyntax; + } + else if ( pPropertiesIter->Name.equalsAscii("IgnoreDriverPrivileges") ) + { + pPropertiesIter->Value >>= aInit.bIgnoreDriverPrivileges; + } + else if ( pPropertiesIter->Name.equalsAscii("ParameterNameSubstitution") ) + { + pPropertiesIter->Value >>= aInit.bParameterNameSubstitution; + } + else if ( pPropertiesIter->Name.equalsAscii("DisplayVersionColumns") ) + { + pPropertiesIter->Value >>= aInit.bDisplayVersionColumns; + } + else if ( pPropertiesIter->Name.equalsAscii("UseCatalogInSelect") ) + { + pPropertiesIter->Value >>= aInit.bUseCatalogInSelect; + } + else if ( pPropertiesIter->Name.equalsAscii("UseSchemaInSelect") ) + { + pPropertiesIter->Value >>= aInit.bUseSchemaInSelect; + } + else if ( pPropertiesIter->Name.equalsAscii("UseIndexDirectionKeyword") ) + { + pPropertiesIter->Value >>= aInit.bUseIndexDirectionKeyword; + } + else if ( pPropertiesIter->Name.equalsAscii("UseDOSLineEnds") ) + { + pPropertiesIter->Value >>= aInit.bUseDOSLineEnds; + } + else if ( pPropertiesIter->Name.equalsAscii("BooleanComparisonMode") ) + { + pPropertiesIter->Value >>= aInit.bBooleanComparisonMode; + } + else if ( pPropertiesIter->Name.equalsAscii("FormsCheckRequiredFields") ) + { + pPropertiesIter->Value >>= aInit.bFormsCheckRequiredFields; + } + else if ( pPropertiesIter->Name.equalsAscii("IgnoreCurrency") ) + { + pPropertiesIter->Value >>= aInit.bIgnoreCurrency; + } + else if ( pPropertiesIter->Name.equalsAscii("EscapeDateTime") ) + { + pPropertiesIter->Value >>= aInit.bEscapeDateTime; + } + } // for (;pPropertiesIter != pPropertiesEnd ; ++pPropertiesIter) + s_aSupport.insert(AdvancedSupport::value_type(*pIter,aInit)); + } + } // if ( s_aSupport.empty() ) + OSL_ENSURE(s_aSupport.find(_sURL) != s_aSupport.end(),"Illegal URL!"); + return s_aSupport[ _sURL ]; } //-------------------------------------------------------------------- - static AuthenticationMode getAuthenticationMode( ::dbaccess::DATASOURCE_TYPE _eType ) + static AuthenticationMode getAuthenticationMode( const ::rtl::OUString& _sURL ) { - typedef ::std::map< ::dbaccess::DATASOURCE_TYPE, FeatureSupport > Supported; - + DECLARE_STL_USTRINGACCESS_MAP( FeatureSupport, Supported); static Supported s_aSupport; if ( s_aSupport.empty() ) { - s_aSupport[ ::dbaccess::DST_MSACCESS ] = FeatureSupport( AuthNone ); - s_aSupport[ ::dbaccess::DST_MYSQL_NATIVE ] = FeatureSupport( AuthUserPwd ); - s_aSupport[ ::dbaccess::DST_MYSQL_ODBC ] = FeatureSupport( AuthUserPwd ); - s_aSupport[ ::dbaccess::DST_MYSQL_JDBC ] = FeatureSupport( AuthUserPwd ); - s_aSupport[ ::dbaccess::DST_ORACLE_JDBC ] = FeatureSupport( AuthUserPwd ); - s_aSupport[ ::dbaccess::DST_ADABAS ] = FeatureSupport( AuthUserPwd ); - s_aSupport[ ::dbaccess::DST_CALC ] = FeatureSupport( AuthPwd ); - s_aSupport[ ::dbaccess::DST_DBASE ] = FeatureSupport( AuthNone ); - s_aSupport[ ::dbaccess::DST_FLAT ] = FeatureSupport( AuthNone ); - s_aSupport[ ::dbaccess::DST_JDBC ] = FeatureSupport( AuthUserPwd ); - s_aSupport[ ::dbaccess::DST_ODBC ] = FeatureSupport( AuthUserPwd ); - s_aSupport[ ::dbaccess::DST_ADO ] = FeatureSupport( AuthUserPwd ); - s_aSupport[ ::dbaccess::DST_MOZILLA ] = FeatureSupport( AuthNone ); - s_aSupport[ ::dbaccess::DST_THUNDERBIRD ] = FeatureSupport( AuthNone ); - s_aSupport[ ::dbaccess::DST_LDAP ] = FeatureSupport( AuthUserPwd ); - s_aSupport[ ::dbaccess::DST_OUTLOOK ] = FeatureSupport( AuthNone ); - s_aSupport[ ::dbaccess::DST_OUTLOOKEXP ] = FeatureSupport( AuthNone ); - s_aSupport[ ::dbaccess::DST_EVOLUTION ] = FeatureSupport( AuthNone ); - s_aSupport[ ::dbaccess::DST_EVOLUTION_GROUPWISE ] = FeatureSupport( AuthNone ); - s_aSupport[ ::dbaccess::DST_EVOLUTION_LDAP ] = FeatureSupport( AuthNone ); - s_aSupport[ ::dbaccess::DST_KAB ] = FeatureSupport( AuthNone ); - s_aSupport[ ::dbaccess::DST_MACAB ] = FeatureSupport( AuthNone ); - s_aSupport[ ::dbaccess::DST_MSACCESS_2007 ] = FeatureSupport( AuthNone ); - s_aSupport[ ::dbaccess::DST_EMBEDDED_HSQLDB ] = FeatureSupport( AuthNone ); - s_aSupport[ ::dbaccess::DST_USERDEFINE1 ] = FeatureSupport( AuthUserPwd ); - s_aSupport[ ::dbaccess::DST_USERDEFINE2 ] = FeatureSupport( AuthUserPwd ); - s_aSupport[ ::dbaccess::DST_USERDEFINE3 ] = FeatureSupport( AuthUserPwd ); - s_aSupport[ ::dbaccess::DST_USERDEFINE4 ] = FeatureSupport( AuthUserPwd ); - s_aSupport[ ::dbaccess::DST_USERDEFINE5 ] = FeatureSupport( AuthUserPwd ); - s_aSupport[ ::dbaccess::DST_USERDEFINE6 ] = FeatureSupport( AuthUserPwd ); - s_aSupport[ ::dbaccess::DST_USERDEFINE7 ] = FeatureSupport( AuthUserPwd ); - s_aSupport[ ::dbaccess::DST_USERDEFINE8 ] = FeatureSupport( AuthUserPwd ); - s_aSupport[ ::dbaccess::DST_USERDEFINE9 ] = FeatureSupport( AuthUserPwd ); - s_aSupport[ ::dbaccess::DST_USERDEFINE10 ] = FeatureSupport( AuthUserPwd ); - } - return s_aSupport[ _eType ].eAuthentication; + ::connectivity::DriversConfig aDriverConfig(::comphelper::getProcessServiceFactory()); + const uno::Sequence< ::rtl::OUString > aURLs = aDriverConfig.getURLs(); + const ::rtl::OUString* pIter = aURLs.getConstArray(); + const ::rtl::OUString* pEnd = pIter + aURLs.getLength(); + for(;pIter != pEnd;++pIter) + { + FeatureSupport aInit( AuthNone ); + const ::comphelper::NamedValueCollection& aMetaData = aDriverConfig.getMetaData(*pIter); + if ( aMetaData.has("Authentication") ) + { + ::rtl::OUString sAuth; + aMetaData.get("Authentication") >>= sAuth; + if ( sAuth.equalsAscii("UserPassword") ) + aInit = AuthUserPwd; + else if ( sAuth.equalsAscii("Password") ) + aInit = AuthPwd; + } + s_aSupport.insert(Supported::value_type(*pIter,aInit)); + } // for(;pIter != pEnd;++pIter) + } // if ( s_aSupport.empty() ) + OSL_ENSURE(s_aSupport.find(_sURL) != s_aSupport.end(),"Illegal URL!"); + return s_aSupport[ _sURL ].eAuthentication; } //==================================================================== @@ -211,17 +220,17 @@ namespace dbaui class DataSourceMetaData_Impl { public: - DataSourceMetaData_Impl( ::dbaccess::DATASOURCE_TYPE _eType ); + DataSourceMetaData_Impl( const ::rtl::OUString& _sURL ); - inline ::dbaccess::DATASOURCE_TYPE getType() const { return m_eType; } + inline ::rtl::OUString getType() const { return m_sURL; } private: - ::dbaccess::DATASOURCE_TYPE m_eType; + const ::rtl::OUString m_sURL; }; //-------------------------------------------------------------------- - DataSourceMetaData_Impl::DataSourceMetaData_Impl( ::dbaccess::DATASOURCE_TYPE _eType ) - :m_eType( _eType ) + DataSourceMetaData_Impl::DataSourceMetaData_Impl( const ::rtl::OUString& _sURL ) + :m_sURL( _sURL ) { } @@ -229,8 +238,8 @@ namespace dbaui //= DataSourceMetaData //==================================================================== //-------------------------------------------------------------------- - DataSourceMetaData::DataSourceMetaData( ::dbaccess::DATASOURCE_TYPE _eType ) - :m_pImpl( new DataSourceMetaData_Impl( _eType ) ) + DataSourceMetaData::DataSourceMetaData( const ::rtl::OUString& _sURL ) + :m_pImpl( new DataSourceMetaData_Impl( _sURL ) ) { } @@ -252,9 +261,9 @@ namespace dbaui } //-------------------------------------------------------------------- - AuthenticationMode DataSourceMetaData::getAuthentication( ::dbaccess::DATASOURCE_TYPE _eType ) + AuthenticationMode DataSourceMetaData::getAuthentication( const ::rtl::OUString& _sURL ) { - return getAuthenticationMode( _eType ); + return getAuthenticationMode( _sURL ); } //........................................................................ diff --git a/dbaccess/source/ui/misc/indexcollection.cxx b/dbaccess/source/ui/misc/indexcollection.cxx index 9f485067d4a4..681675f2003c 100644 --- a/dbaccess/source/ui/misc/indexcollection.cxx +++ b/dbaccess/source/ui/misc/indexcollection.cxx @@ -119,7 +119,8 @@ namespace dbaui // loop'n'compare Indexes::const_iterator aSearch = m_aIndexes.begin(); - for (; aSearch != m_aIndexes.end(); ++aSearch) + Indexes::const_iterator aEnd = m_aIndexes.end(); + for (; aSearch != aEnd; ++aSearch) if (aSearch->sName == sNameCompare) break; @@ -133,7 +134,8 @@ namespace dbaui // loop'n'compare Indexes::iterator aSearch = m_aIndexes.begin(); - for (; aSearch != m_aIndexes.end(); ++aSearch) + Indexes::iterator aEnd = m_aIndexes.end(); + for (; aSearch != aEnd; ++aSearch) if (aSearch->sName == sNameCompare) break; @@ -147,7 +149,8 @@ namespace dbaui // loop'n'compare Indexes::const_iterator aSearch = m_aIndexes.begin(); - for (; aSearch != m_aIndexes.end(); ++aSearch) + Indexes::const_iterator aEnd = m_aIndexes.end(); + for (; aSearch != aEnd; ++aSearch) if (aSearch->getOriginalName() == sNameCompare) break; @@ -161,7 +164,8 @@ namespace dbaui // loop'n'compare Indexes::iterator aSearch = m_aIndexes.begin(); - for (; aSearch != m_aIndexes.end(); ++aSearch) + Indexes::iterator aEnd = m_aIndexes.end(); + for (; aSearch != aEnd; ++aSearch) if (aSearch->getOriginalName() == sNameCompare) break; diff --git a/dbaccess/source/ui/misc/uiservices.cxx b/dbaccess/source/ui/misc/uiservices.cxx index 3de9c2c1d015..9cca58ff853a 100644 --- a/dbaccess/source/ui/misc/uiservices.cxx +++ b/dbaccess/source/ui/misc/uiservices.cxx @@ -74,7 +74,6 @@ extern "C" void SAL_CALL createRegistryInfo_OAdvancedSettingsDialog(); extern "C" void SAL_CALL createRegistryInfo_ODBTypeWizDialog(); extern "C" void SAL_CALL createRegistryInfo_OUserSettingsDialog(); extern "C" void SAL_CALL createRegistryInfo_ODBTypeWizDialogSetup(); -extern "C" void SAL_CALL createRegistryInfo_OAdabasSettingsDialog(); extern "C" void SAL_CALL createRegistryInfo_OColumnControlModel(); extern "C" void SAL_CALL createRegistryInfo_OColumnControl(); extern "C" void SAL_CALL createRegistryInfo_OToolboxController(); @@ -107,7 +106,6 @@ extern "C" void SAL_CALL createRegistryInfo_DBU() createRegistryInfo_ODBTypeWizDialog(); createRegistryInfo_ODBTypeWizDialogSetup(); createRegistryInfo_OUserSettingsDialog(); - createRegistryInfo_OAdabasSettingsDialog(); createRegistryInfo_OColumnControlModel(); createRegistryInfo_OColumnControl(); createRegistryInfo_OToolboxController(); diff --git a/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx b/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx index ecabea880895..bfe3213f2291 100644 --- a/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx +++ b/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx @@ -129,9 +129,10 @@ namespace dbaui nIndex = m_pLine->GetParent()->GetTabWinMap()->size(); const ::std::vector<OTableConnection*>* pVec = m_pLine->GetParent()->getTableConnections(); ::std::vector<OTableConnection*>::const_iterator aIter = pVec->begin(); - for (; aIter != pVec->end() && (*aIter) != m_pLine; ++nIndex,++aIter) + ::std::vector<OTableConnection*>::const_iterator aEnd = pVec->end(); + for (; aIter != aEnd && (*aIter) != m_pLine; ++nIndex,++aIter) ; - nIndex = ( aIter != pVec->end() ) ? nIndex : -1; + nIndex = ( aIter != aEnd ) ? nIndex : -1; } return nIndex; } diff --git a/dbaccess/source/ui/querydesign/JoinController.cxx b/dbaccess/source/ui/querydesign/JoinController.cxx index d3f81d34d1d7..95531ed3bbaa 100644 --- a/dbaccess/source/ui/querydesign/JoinController.cxx +++ b/dbaccess/source/ui/querydesign/JoinController.cxx @@ -419,7 +419,8 @@ void OJoinController::SaveTabWinsPosSize( OJoinTableView::OTableWindowMap* pTabW "OJoinController::SaveTabWinsPosSize : inkonsistenter Zustand : sollte genausviel TabWinDatas haben wie TabWins !"); OJoinTableView::OTableWindowMap::iterator aIter = pTabWinList->begin(); - for(;aIter != pTabWinList->end();++aIter) + OJoinTableView::OTableWindowMap::iterator aEnd = pTabWinList->end(); + for(;aIter != aEnd;++aIter) SaveTabWinPosSize(aIter->second, nOffsetX, nOffsetY); } // ----------------------------------------------------------------------------- diff --git a/dbaccess/source/ui/querydesign/JoinExchange.cxx b/dbaccess/source/ui/querydesign/JoinExchange.cxx index 21edc112be38..4f80fdefab9c 100644 --- a/dbaccess/source/ui/querydesign/JoinExchange.cxx +++ b/dbaccess/source/ui/querydesign/JoinExchange.cxx @@ -92,8 +92,9 @@ namespace dbaui //------------------------------------------------------------------------ sal_Bool OJoinExchObj::isFormatAvailable( const DataFlavorExVector& _rFormats ,SotFormatStringId _nSlotID) { + DataFlavorExVector::const_iterator aCheckEnd = _rFormats.end(); for ( DataFlavorExVector::const_iterator aCheck = _rFormats.begin(); - aCheck != _rFormats.end(); + aCheck != aCheckEnd; ++aCheck ) { diff --git a/dbaccess/source/ui/querydesign/JoinTableView.cxx b/dbaccess/source/ui/querydesign/JoinTableView.cxx index 150e39f9545d..16f4990cb5b5 100644 --- a/dbaccess/source/ui/querydesign/JoinTableView.cxx +++ b/dbaccess/source/ui/querydesign/JoinTableView.cxx @@ -102,6 +102,7 @@ #endif #include <cppuhelper/exc_hlp.hxx> #include <tools/diagnose_ex.h> +#include <boost/bind.hpp> #include <algorithm> #include <functional> @@ -291,7 +292,8 @@ void OJoinTableView::Resize() return; OTableWindowMapIterator aIter = m_aTableMap.begin(); - for(;aIter != m_aTableMap.end();++aIter) + OTableWindowMapIterator aEnd = m_aTableMap.end(); + for(;aIter != aEnd;++aIter) { OTableWindow* pCurrent = aIter->second; Point aPos(pCurrent->GetData()->GetPosition() - GetScrollOffset()); @@ -631,7 +633,8 @@ void OJoinTableView::SetDefaultTabWinPosSize( OTableWindow* pTabWin ) // Belegte Bereiche dieser Zeile pruefen OTableWindow* pOtherTabWin;// = GetTabWinMap()->First(); OTableWindowMapIterator aIter = m_aTableMap.begin(); - for(;aIter != m_aTableMap.end();++aIter) + OTableWindowMapIterator aEnd = m_aTableMap.end(); + for(;aIter != aEnd;++aIter) { pOtherTabWin = aIter->second; Rectangle aOtherTabWinRect( pOtherTabWin->GetPosPixel(), pOtherTabWin->GetSizePixel() ); @@ -814,7 +817,8 @@ BOOL OJoinTableView::ScrollPane( long nDelta, BOOL bHoriz, BOOL bPaintScrollBars Point aPos; OTableWindowMapIterator aIter = m_aTableMap.begin(); - for(;aIter != m_aTableMap.end();++aIter) + OTableWindowMapIterator aEnd = m_aTableMap.end(); + for(;aIter != aEnd;++aIter) { pTabWin = aIter->second; aPos = pTabWin->GetPosPixel(); @@ -954,7 +958,8 @@ void OJoinTableView::MouseButtonUp( const MouseEvent& rEvt ) DeselectConn(GetSelectedConn()); ::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin(); - for(;aIter != m_vTableConnection.end();++aIter) + ::std::vector<OTableConnection*>::iterator aEnd = m_vTableConnection.end(); + for(;aIter != aEnd;++aIter) { if( (*aIter)->CheckHit(rEvt.GetPosPixel()) ) { @@ -1085,9 +1090,7 @@ void OJoinTableView::DrawConnections( const Rectangle& rRect ) DBG_CHKTHIS(OJoinTableView,NULL); ////////////////////////////////////////////////////////////////////// // Die Joins zeichnen - ::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin(); - for(;aIter != m_vTableConnection.end();++aIter) - (*aIter)->Draw( rRect ); + ::std::for_each(m_vTableConnection.begin(),m_vTableConnection.end(),boost::bind( &OTableConnection::Draw, _1, boost::cref( rRect ))); // zum Schluss noch mal die selektierte ueber alle anderen drueber if (GetSelectedConn()) GetSelectedConn()->Draw( rRect ); @@ -1124,7 +1127,8 @@ void OJoinTableView::ClearAll() // und das selbe mit den Connections ::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin(); - for(;aIter != m_vTableConnection.end();++aIter) + ::std::vector<OTableConnection*>::iterator aEnd = m_vTableConnection.end(); + for(;aIter != aEnd;++aIter) RemoveConnection( *aIter ,sal_True); m_vTableConnection.clear(); @@ -1325,7 +1329,8 @@ void OJoinTableView::Command(const CommandEvent& rEvt) const Point& aMousePos = rEvt.GetMousePosPixel(); ::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin(); - for(;aIter != m_vTableConnection.end();++aIter) + ::std::vector<OTableConnection*>::iterator aEnd = m_vTableConnection.end(); + for(;aIter != aEnd;++aIter) { if( (*aIter)->CheckHit(aMousePos) ) { @@ -1355,7 +1360,8 @@ OTableConnection* OJoinTableView::GetTabConn(const OTableWindow* pLhs,const OTab BOOL bFoundStart = _rpFirstAfter ? FALSE : TRUE; ::std::vector<OTableConnection*>::const_iterator aIter = m_vTableConnection.begin(); - for(;aIter != m_vTableConnection.end();++aIter) + ::std::vector<OTableConnection*>::const_iterator aEnd = m_vTableConnection.end(); + for(;aIter != aEnd;++aIter) { OTableConnection* pData = *aIter; @@ -1437,7 +1443,8 @@ long OJoinTableView::PreNotify(NotifyEvent& rNEvt) BOOL bForward = !pKeyEvent->GetKeyCode().IsShift(); // is there an active tab win ? OTableWindowMapIterator aIter = m_aTableMap.begin(); - for(;aIter != m_aTableMap.end();++aIter) + OTableWindowMapIterator aEnd = m_aTableMap.end(); + for(;aIter != aEnd;++aIter) if (aIter->second && aIter->second->HasChildPathFocus()) break; @@ -1569,7 +1576,8 @@ long OJoinTableView::PreNotify(NotifyEvent& rNEvt) if (pSearchFor) { OTableWindowMapIterator aIter = m_aTableMap.begin(); - for(;aIter != m_aTableMap.end();++aIter) + OTableWindowMapIterator aEnd = m_aTableMap.end(); + for(;aIter != aEnd;++aIter) { if (aIter->second == pSearchFor) { @@ -1622,7 +1630,8 @@ void OJoinTableView::StateChanged( StateChangedType nType ) SetZoomedPointFont( aFont ); OTableWindowMapIterator aIter = m_aTableMap.begin(); - for(;aIter != m_aTableMap.end();++aIter) + OTableWindowMapIterator aEnd = m_aTableMap.end(); + for(;aIter != aEnd;++aIter) { aIter->second->SetZoom(GetZoom()); Size aSize(CalcZoom(aIter->second->GetSizePixel().Width()),CalcZoom(aIter->second->GetSizePixel().Height())); @@ -1643,7 +1652,8 @@ void OJoinTableView::HideTabWins() // working on a copy because the real list will be cleared in inner calls OTableWindowMap aCopy(*pTabWins); OTableWindowMap::iterator aIter = aCopy.begin(); - for(;aIter != aCopy.end();++aIter) + OTableWindowMap::iterator aEnd = aCopy.end(); + for(;aIter != aEnd;++aIter) RemoveTabWin(aIter->second); } @@ -1690,7 +1700,8 @@ void OJoinTableView::clearLayoutInformation() m_aTableMap.clear(); ::std::vector<OTableConnection*>::const_iterator aIter2 = m_vTableConnection.begin(); - for(;aIter2 != m_vTableConnection.end();++aIter2) + ::std::vector<OTableConnection*>::const_iterator aEnd2 = m_vTableConnection.end(); + for(;aIter2 != aEnd2;++aIter2) delete *aIter2; m_vTableConnection.clear(); diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index 30e3bd5cc5b8..d02fb11fe54c 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -464,34 +464,36 @@ namespace OConnectionLineDataVec* pLineDataList, OQueryTableConnectionData* pData) { - ::rtl::OUString aCondition; - if ( !_xConnection.is() ) - return aCondition; - - OConnectionLineDataVec::iterator aIter = pLineDataList->begin(); - try + ::rtl::OUStringBuffer aCondition; + if ( _xConnection.is() ) { - Reference< XDatabaseMetaData > xMetaData = _xConnection->getMetaData(); - ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString(); + OConnectionLineDataVec::iterator aIter = pLineDataList->begin(); + OConnectionLineDataVec::iterator aEnd = pLineDataList->end(); + try + { + const Reference< XDatabaseMetaData > xMetaData = _xConnection->getMetaData(); + const ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString(); + const ::rtl::OUString sEqual(RTL_CONSTASCII_USTRINGPARAM(" = ")); - for(;aIter != pLineDataList->end();++aIter) + for(;aIter != aEnd;++aIter) + { + OConnectionLineDataRef pLineData = *aIter; + if(aCondition.getLength()) + aCondition.append(C_AND); + aCondition.append(quoteTableAlias(sal_True,pData->GetAliasName(JTCS_FROM),aQuote)); + aCondition.append(::dbtools::quoteName(aQuote, pLineData->GetFieldName(JTCS_FROM) )); + aCondition.append(sEqual); + aCondition.append(quoteTableAlias(sal_True,pData->GetAliasName(JTCS_TO),aQuote)); + aCondition.append(::dbtools::quoteName(aQuote, pLineData->GetFieldName(JTCS_TO) )); + } + } + catch(SQLException&) { - OConnectionLineDataRef pLineData = *aIter; - if(aCondition.getLength()) - aCondition += C_AND; - aCondition += quoteTableAlias(sal_True,pData->GetAliasName(JTCS_FROM),aQuote); - aCondition += ::dbtools::quoteName(aQuote, pLineData->GetFieldName(JTCS_FROM) ); - aCondition += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" = ")); - aCondition += quoteTableAlias(sal_True,pData->GetAliasName(JTCS_TO),aQuote); - aCondition += ::dbtools::quoteName(aQuote, pLineData->GetFieldName(JTCS_TO) ); + OSL_ASSERT(!"Failure while building Join criteria!"); } } - catch(SQLException&) - { - OSL_ASSERT(!"Failure while building Join criteria!"); - } - return aCondition; + return aCondition.makeStringAndClear(); } //------------------------------------------------------------------------------ /** JoinCycle looks for a join cycle and append it to the string @@ -657,7 +659,8 @@ namespace // first search for the "to" window const ::std::vector<OTableConnection*>* pConnections = pEntryConn->GetParent()->getTableConnections(); ::std::vector<OTableConnection*>::const_iterator aIter = pConnections->begin(); - for(;aIter != pConnections->end();++aIter) + ::std::vector<OTableConnection*>::const_iterator aEnd = pConnections->end(); + for(;aIter != aEnd;++aIter) { OQueryTableConnection* pNext = static_cast<OQueryTableConnection*>(*aIter); if(!pNext->IsVisited() && (pNext->GetSourceWin() == pEntryTabTo || pNext->GetDestWin() == pEntryTabTo)) @@ -671,11 +674,11 @@ namespace } // when nothing found found look for the "from" window - if(aIter == pConnections->end()) + if(aIter == aEnd) { OQueryTableWindow* pEntryTabFrom = static_cast<OQueryTableWindow*>(pEntryConn->GetSourceWin()); aIter = pConnections->begin(); - for(;aIter != pConnections->end();++aIter) + for(;aIter != aEnd;++aIter) { OQueryTableConnection* pNext = static_cast<OQueryTableConnection*>(*aIter); if(!pNext->IsVisited() && (pNext->GetSourceWin() == pEntryTabFrom || pNext->GetDestWin() == pEntryTabFrom)) @@ -746,12 +749,17 @@ namespace OTableFields& _rFieldList, sal_Bool bAlias) { - ::rtl::OUString aTmpStr,aFieldListStr; + Reference< XConnection> xConnection = static_cast<OQueryController&>(_pView->getController()).getConnection(); + if ( !xConnection.is() ) + return ::rtl::OUString(); + + ::rtl::OUStringBuffer aTmpStr,aFieldListStr; sal_Bool bAsterix = sal_False; int nVis = 0; OTableFields::iterator aIter = _rFieldList.begin(); - for(;aIter != _rFieldList.end();++aIter) + OTableFields::iterator aEnd = _rFieldList.end(); + for(;aIter != aEnd;++aIter) { OTableFieldDescRef pEntryField = *aIter; if ( pEntryField->IsVisible() ) @@ -764,31 +772,28 @@ namespace if(nVis == 1) bAsterix = sal_False; - Reference< XConnection> xConnection = static_cast<OQueryController&>(_pView->getController()).getConnection(); - if(!xConnection.is()) - return aFieldListStr; - try { - Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData(); - ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString(); + const Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData(); + const ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString(); OJoinTableView::OTableWindowMap* pTabList = _pView->getTableView()->GetTabWinMap(); const static ::rtl::OUString sFieldSeparator(RTL_CONSTASCII_USTRINGPARAM(", ")); + const static ::rtl::OUString s_sAs(RTL_CONSTASCII_USTRINGPARAM(" AS ")); aIter = _rFieldList.begin(); - for(;aIter != _rFieldList.end();++aIter) + for(;aIter != aEnd;++aIter) { OTableFieldDescRef pEntryField = *aIter; ::rtl::OUString rFieldName = pEntryField->GetField(); if ( rFieldName.getLength() && pEntryField->IsVisible() ) { aTmpStr = ::rtl::OUString(); - ::rtl::OUString rAlias = pEntryField->GetAlias(); - ::rtl::OUString rFieldAlias = pEntryField->GetFieldAlias(); + const ::rtl::OUString rAlias = pEntryField->GetAlias(); + const ::rtl::OUString rFieldAlias = pEntryField->GetFieldAlias(); - aTmpStr += quoteTableAlias((bAlias || bAsterix),rAlias,aQuote); + aTmpStr.append(quoteTableAlias((bAlias || bAsterix),rAlias,aQuote)); // if we have a none numeric field, the table alias could be in the name // otherwise we are not allowed to do this (e.g. 0.1 * PRICE ) @@ -798,8 +803,9 @@ namespace String sTemp = rFieldName; OTableFieldDescRef aInfo = new OTableFieldDesc(); OJoinTableView::OTableWindowMap::iterator tableIter = pTabList->begin(); + OJoinTableView::OTableWindowMap::iterator tableEnd = pTabList->end(); sal_Bool bFound = sal_False; - for(;!bFound && tableIter != pTabList->end() ;++tableIter) + for(;!bFound && tableIter != tableEnd ;++tableIter) { OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(tableIter->second); @@ -810,21 +816,21 @@ namespace if ( ( rFieldName.toChar() != '*' ) && ( rFieldName.indexOf( aQuote ) == -1 ) ) { OSL_ENSURE(pEntryField->GetTable().getLength(),"No table field name!"); - aTmpStr += ::dbtools::quoteName(aQuote, rFieldName); + aTmpStr.append(::dbtools::quoteName(aQuote, rFieldName)); } else - aTmpStr += rFieldName; + aTmpStr.append(rFieldName); } else - aTmpStr += rFieldName; + aTmpStr.append(rFieldName); if ( pEntryField->isAggreateFunction() ) { DBG_ASSERT(pEntryField->GetFunction().getLength(),"Functionname darf hier nicht leer sein! ;-("); - ::rtl::OUString aTmpStr2( pEntryField->GetFunction()); - aTmpStr2 += ::rtl::OUString('('); - aTmpStr2 += aTmpStr; - aTmpStr2 += ::rtl::OUString(')'); + ::rtl::OUStringBuffer aTmpStr2( pEntryField->GetFunction()); + aTmpStr2.appendAscii("("); + aTmpStr2.append(aTmpStr.makeStringAndClear()); + aTmpStr2.appendAscii(")"); aTmpStr = aTmpStr2; } @@ -833,26 +839,26 @@ namespace pEntryField->isNumericOrAggreateFunction() || pEntryField->isOtherFunction())) { - aTmpStr += ::rtl::OUString::createFromAscii(" AS "); - aTmpStr += ::dbtools::quoteName(aQuote, rFieldAlias); + aTmpStr.append(s_sAs); + aTmpStr.append(::dbtools::quoteName(aQuote, rFieldAlias)); } - aFieldListStr += aTmpStr; - aFieldListStr += sFieldSeparator; + aFieldListStr.append(aTmpStr.makeStringAndClear()); + aFieldListStr.append(sFieldSeparator); } } if(aFieldListStr.getLength()) - aFieldListStr = aFieldListStr.replaceAt(aFieldListStr.getLength()-2,2, ::rtl::OUString() ); + aFieldListStr.setLength(aFieldListStr.getLength()-2); } catch(SQLException&) { OSL_ASSERT(!"Failure while building select list!"); } - return aFieldListStr; + return aFieldListStr.makeStringAndClear(); } //------------------------------------------------------------------------------ sal_Bool GenerateCriterias( OQueryDesignView* _pView, - ::rtl::OUString& rRetStr, - ::rtl::OUString& rHavingStr, + ::rtl::OUStringBuffer& rRetStr, + ::rtl::OUStringBuffer& rHavingStr, OTableFields& _rFieldList, sal_Bool bMulti ) { @@ -863,7 +869,8 @@ namespace // Zeilenweise werden die Ausdr"ucke mit AND verknuepft sal_uInt16 nMaxCriteria = 0; OTableFields::iterator aIter = _rFieldList.begin(); - for(;aIter != _rFieldList.end();++aIter) + OTableFields::iterator aEnd = _rFieldList.end(); + for(;aIter != aEnd;++aIter) { nMaxCriteria = ::std::max<sal_uInt16>(nMaxCriteria,(sal_uInt16)(*aIter)->GetCriteria().size()); } @@ -872,15 +879,15 @@ namespace return FALSE; try { - Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData(); - ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString(); + const Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData(); + const ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString(); const IParseContext& rContext = static_cast<OQueryController&>(_pView->getController()).getParser().getContext(); for (sal_uInt16 i=0 ; i < nMaxCriteria ; i++) { aHavingStr = aWhereStr = ::rtl::OUString(); - for(aIter = _rFieldList.begin();aIter != _rFieldList.end();++aIter) + for(aIter = _rFieldList.begin();aIter != aEnd;++aIter) { OTableFieldDescRef pEntryField = *aIter; aFieldName = pEntryField->GetField(); @@ -996,26 +1003,26 @@ namespace { aWhereStr += ::rtl::OUString(')'); // Klammern zu fuer 'AND' Zweig if (rRetStr.getLength()) // schon Feldbedingungen ? - rRetStr += C_OR; + rRetStr.append(C_OR); else // Klammern auf fuer 'OR' Zweig - rRetStr += ::rtl::OUString('('); - rRetStr += aWhereStr; + rRetStr.append(sal_Unicode('(')); + rRetStr.append(aWhereStr); } if (aHavingStr.getLength()) { aHavingStr += ::rtl::OUString(')'); // Klammern zu fuer 'AND' Zweig if (rHavingStr.getLength()) // schon Feldbedingungen ? - rHavingStr += C_OR; + rHavingStr.append(C_OR); else // Klammern auf fuer 'OR' Zweig - rHavingStr += ::rtl::OUString('('); - rHavingStr += aHavingStr; + rHavingStr.append(sal_Unicode('(')); + rHavingStr.append(aHavingStr); } } if (rRetStr.getLength()) - rRetStr += ::rtl::OUString(')'); // Klammern zu fuer 'OR' Zweig + rRetStr.append(sal_Unicode(')')); // Klammern zu fuer 'OR' Zweig if (rHavingStr.getLength()) - rHavingStr += ::rtl::OUString(')'); // Klammern zu fuer 'OR' Zweig + rHavingStr.append(sal_Unicode(')')); // Klammern zu fuer 'OR' Zweig } catch(SQLException&) { @@ -1046,8 +1053,8 @@ namespace // * darf keine Filter enthalten : habe ich die entsprechende Warnung schon angezeigt ? sal_Bool bCritsOnAsterikWarning = sal_False; // ** TMFS ** OTableFields::iterator aIter = _rFieldList.begin(); - - for(;aIter != _rFieldList.end();++aIter) + OTableFields::iterator aEnd = _rFieldList.end(); + for(;aIter != aEnd;++aIter) { OTableFieldDescRef pEntryField = *aIter; EOrderDir eOrder = pEntryField->GetOrderDir(); @@ -1132,7 +1139,8 @@ namespace const ::std::vector<OTableConnection*>* _pConnList) { ::std::vector<OTableConnection*>::const_iterator aIter = _pConnList->begin(); - for(;aIter != _pConnList->end();++aIter) + ::std::vector<OTableConnection*>::const_iterator aEnd = _pConnList->end(); + for(;aIter != aEnd;++aIter) { const OQueryTableConnection* pEntryConn = static_cast<const OQueryTableConnection*>(*aIter); OQueryTableConnectionData* pEntryConnData = static_cast<OQueryTableConnectionData*>(pEntryConn->GetData().get()); @@ -1175,12 +1183,13 @@ namespace if(!pConnList->empty()) { ::std::vector<OTableConnection*>::const_iterator aIter = pConnList->begin(); - for(;aIter != pConnList->end();++aIter) + ::std::vector<OTableConnection*>::const_iterator aEnd = pConnList->end(); + for(;aIter != aEnd;++aIter) static_cast<OQueryTableConnection*>(*aIter)->SetVisited(sal_False); aIter = pConnList->begin(); - sal_Bool bUseEscape = ::dbtools::getBooleanDataSourceSetting( _xConnection, PROPERTY_OUTERJOINESCAPE ); - for(;aIter != pConnList->end();++aIter) + const sal_Bool bUseEscape = ::dbtools::getBooleanDataSourceSetting( _xConnection, PROPERTY_OUTERJOINESCAPE ); + for(;aIter != aEnd;++aIter) { OQueryTableConnection* pEntryConn = static_cast<OQueryTableConnection*>(*aIter); if(!pEntryConn->IsVisited()) @@ -1228,7 +1237,7 @@ namespace // and now all inner joins aIter = pConnList->begin(); - for(;aIter != pConnList->end();++aIter) + for(;aIter != aEnd;++aIter) { OQueryTableConnection* pEntryConn = static_cast<OQueryTableConnection*>(*aIter); if(!pEntryConn->IsVisited()) @@ -1247,7 +1256,8 @@ namespace } // all tables that haven't a connection to anyone OQueryTableView::OTableWindowMap::const_iterator aTabIter = pTabList->begin(); - for(;aTabIter != pTabList->end();++aTabIter) + OQueryTableView::OTableWindowMap::const_iterator aTabEnd = pTabList->end(); + for(;aTabIter != aTabEnd;++aTabIter) { const OQueryTableWindow* pEntryTab = static_cast<const OQueryTableWindow*>(aTabIter->second); if(!pEntryTab->ExistsAConn()) @@ -1278,7 +1288,8 @@ namespace const ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString(); OTableFields::iterator aIter = _rFieldList.begin(); - for(;aIter != _rFieldList.end();++aIter) + OTableFields::iterator aEnd = _rFieldList.end(); + for(;aIter != aEnd;++aIter) { OTableFieldDescRef pEntryField = *aIter; if ( pEntryField->IsGroupBy() ) @@ -1644,7 +1655,8 @@ namespace { OJoinTableView::OTableWindowMap* pTabList = _pView->getTableView()->GetTabWinMap(); OJoinTableView::OTableWindowMap::iterator aIter = pTabList->begin(); - for(;aIter != pTabList->end();++aIter) + OJoinTableView::OTableWindowMap::iterator aTabEnd = pTabList->end(); + for(;aIter != aTabEnd;++aIter) { OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(aIter->second); if (pTabWin->ExistsField( ::rtl::OUString::createFromAscii("*"), aDragLeft )) @@ -1718,13 +1730,14 @@ namespace { OConnectionLineDataVec* pLineDataList = pConn->GetData()->GetConnLineDataList(); OConnectionLineDataVec::iterator aIter = pLineDataList->begin(); - for(;aIter != pLineDataList->end();++aIter) + OConnectionLineDataVec::iterator aEnd = pLineDataList->end(); + for(;aIter != aEnd;++aIter) { if((*aIter)->GetSourceFieldName() == aDragLeft->GetField() || (*aIter)->GetDestFieldName() == aDragLeft->GetField() ) break; } - if(aIter != pLineDataList->end()) + if(aIter != aEnd) return eOk; } } @@ -1853,7 +1866,8 @@ namespace OQueryTableWindow* lcl_findColumnInTables( const ::rtl::OUString& _rColumName, const OJoinTableView::OTableWindowMap& _rTabList, OTableFieldDescRef& _rInfo ) { OJoinTableView::OTableWindowMap::const_iterator aIter = _rTabList.begin(); - for ( ; aIter != _rTabList.end(); ++aIter ) + OJoinTableView::OTableWindowMap::const_iterator aEnd = _rTabList.end(); + for ( ; aIter != aEnd; ++aIter ) { OQueryTableWindow* pTabWin = static_cast< OQueryTableWindow* >( aIter->second ); if ( pTabWin && pTabWin->ExistsField( _rColumName, _rInfo ) ) @@ -2019,7 +2033,8 @@ namespace // now we have to insert the fields which aren't in the statement OQueryController& rController = static_cast<OQueryController&>(_pView->getController()); OTableFields& rUnUsedFields = rController.getUnUsedFields(); - for(OTableFields::iterator aIter = rUnUsedFields.begin();aIter != rUnUsedFields.end();++aIter) + OTableFields::iterator aEnd = rUnUsedFields.end(); + for(OTableFields::iterator aIter = rUnUsedFields.begin();aIter != aEnd;++aIter) if(_pSelectionBrw->InsertField(*aIter,BROWSER_INVALIDID,sal_False,sal_False).isValid()) (*aIter) = NULL; OTableFields().swap( rUnUsedFields ); @@ -2088,7 +2103,8 @@ namespace OQueryTableView* pTableView = static_cast<OQueryTableView*>(_pView->getTableView()); pTableView->clearLayoutInformation(); OSQLTables::const_iterator aIter = aMap.begin(); - for(;aIter != aMap.end();++aIter) + OSQLTables::const_iterator aEnd = aMap.end(); + for(;aIter != aEnd;++aIter) { OSQLTable xTable = aIter->second; Reference< XPropertySet > xTableProps( xTable, UNO_QUERY_THROW ); @@ -2132,7 +2148,8 @@ namespace // now delete the data for which we haven't any tablewindow OJoinTableView::OTableWindowMap aTableMap(*pTableView->GetTabWinMap()); OJoinTableView::OTableWindowMap::iterator aIterTableMap = aTableMap.begin(); - for(;aIterTableMap != aTableMap.end();++aIterTableMap) + OJoinTableView::OTableWindowMap::iterator aIterTableEnd = aTableMap.end(); + for(;aIterTableMap != aIterTableEnd;++aIterTableMap) { if(aMap.find(aIterTableMap->second->GetComposedName()) == aMap.end() && aMap.find(aIterTableMap->first) == aMap.end()) @@ -2191,7 +2208,8 @@ namespace sal_Bool bFirstField = sal_True; ::rtl::OUString sAsterix(RTL_CONSTASCII_USTRINGPARAM("*")); OJoinTableView::OTableWindowMap::iterator aIter = _pTabList->begin(); - for(;aIter != _pTabList->end() && eOk == eErrorCode ;++aIter) + OJoinTableView::OTableWindowMap::iterator aEnd = _pTabList->end(); + for(;aIter != aEnd && eOk == eErrorCode ;++aIter) { OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(aIter->second); OTableFieldDescRef aInfo = new OTableFieldDesc(); @@ -2319,7 +2337,8 @@ namespace if ( pParamRef && pParamRef->getTokenValue().toChar() == '*' ) { OJoinTableView::OTableWindowMap::iterator aIter = pTabList->begin(); - for(;aIter != pTabList->end();++aIter) + OJoinTableView::OTableWindowMap::iterator aEnd = pTabList->end(); + for(;aIter != aEnd;++aIter) { OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(aIter->second); if (pTabWin->ExistsField( ::rtl::OUString::createFromAscii("*"), aInfo )) @@ -2448,7 +2467,8 @@ namespace OTableFields& aList = rController.getTableFieldDesc(); OTableFields::iterator aIter = aList.begin(); - for(;aIter != aList.end();++aIter) + OTableFields::iterator aEnd = aList.end(); + for(;aIter != aEnd;++aIter) { OTableFieldDescRef pEntry = *aIter; if(pEntry.isValid() && pEntry->GetFieldAlias() == aColumnName) @@ -2869,7 +2889,8 @@ void OQueryDesignView::fillValidFields(const ::rtl::OUString& sAliasName, ComboB ::rtl::OUString strCurrentPrefix; ::std::vector< ::rtl::OUString> aFields; OJoinTableView::OTableWindowMap::iterator aIter = pTabWins->begin(); - for(;aIter != pTabWins->end();++aIter) + OJoinTableView::OTableWindowMap::iterator aEnd = pTabWins->end(); + for(;aIter != aEnd;++aIter) { OQueryTableWindow* pCurrentWin = static_cast<OQueryTableWindow*>(aIter->second); if (bAllTables || (pCurrentWin->GetAliasName() == sAliasName)) @@ -2880,7 +2901,8 @@ void OQueryDesignView::fillValidFields(const ::rtl::OUString& sAliasName, ComboB pCurrentWin->EnumValidFields(aFields); ::std::vector< ::rtl::OUString>::iterator aStrIter = aFields.begin(); - for(;aStrIter != aFields.end();++aStrIter) + ::std::vector< ::rtl::OUString>::iterator aStrEnd = aFields.end(); + for(;aStrIter != aStrEnd;++aStrIter) { if (bAllTables || aStrIter->toChar() == '*') pFieldList->InsertEntry(::rtl::OUString(strCurrentPrefix) += *aStrIter); @@ -2942,7 +2964,8 @@ sal_Bool OQueryDesignView::checkStatement() sal_uInt32 nFieldcount = 0; OTableFields& rFieldList = rController.getTableFieldDesc(); OTableFields::iterator aIter = rFieldList.begin(); - for(;aIter != rFieldList.end();++aIter) + OTableFields::iterator aEnd = rFieldList.end(); + for(;aIter != aEnd;++aIter) { OTableFieldDescRef pEntryField = *aIter; if ( pEntryField->GetField().getLength() && pEntryField->IsVisible() ) @@ -2979,7 +3002,7 @@ sal_Bool OQueryDesignView::checkStatement() // wenn es Felder gibt, koennen die nur durch Einfuegen aus einer schon existenten Tabelle entstanden sein; wenn andererseits // eine Tabelle geloescht wird, verschwinden auch die zugehoerigen Felder -> ergo KANN es das nicht geben, dass Felder // existieren, aber keine Tabellen (und aFieldListStr hat schon eine Laenge, das stelle ich oben sicher) - ::rtl::OUString aHavingStr,aCriteriaListStr; + ::rtl::OUStringBuffer aHavingStr,aCriteriaListStr; // ----------------- Kriterien aufbauen ---------------------- if (!GenerateCriterias(this,aCriteriaListStr,aHavingStr,rFieldList, nTabcount > 1)) return ::rtl::OUString(); @@ -2994,22 +3017,22 @@ sal_Bool OQueryDesignView::checkStatement() if(aCriteriaListStr.getLength()) { aTmp += C_AND; - aTmp += aCriteriaListStr; + aTmp += aCriteriaListStr.makeStringAndClear(); } aCriteriaListStr = aTmp; } // ----------------- Statement aufbauen ---------------------- - ::rtl::OUString aSqlCmd(::rtl::OUString::createFromAscii("SELECT ")); + ::rtl::OUStringBuffer aSqlCmd(::rtl::OUString::createFromAscii("SELECT ")); if(static_cast<OQueryController&>(getController()).isDistinct()) - aSqlCmd += ::rtl::OUString::createFromAscii(" DISTINCT "); - aSqlCmd += aFieldListStr; - aSqlCmd += ::rtl::OUString::createFromAscii(" FROM "); - aSqlCmd += aTableListStr; + aSqlCmd.append(::rtl::OUString::createFromAscii(" DISTINCT ")); + aSqlCmd.append(aFieldListStr); + aSqlCmd.append(::rtl::OUString::createFromAscii(" FROM ")); + aSqlCmd.append(aTableListStr); if (aCriteriaListStr.getLength()) { - aSqlCmd += ::rtl::OUString::createFromAscii(" WHERE "); - aSqlCmd += aCriteriaListStr; + aSqlCmd.append(::rtl::OUString::createFromAscii(" WHERE ")); + aSqlCmd.append(aCriteriaListStr.makeStringAndClear()); } // ----------------- GroupBy aufbauen und Anh"angen ------------ Reference<XDatabaseMetaData> xMeta; @@ -3019,18 +3042,18 @@ sal_Bool OQueryDesignView::checkStatement() if ( xMeta.is() ) bUseAlias = bUseAlias || !xMeta->supportsGroupByUnrelated(); - aSqlCmd += GenerateGroupBy(this,rFieldList,bUseAlias); + aSqlCmd.append(GenerateGroupBy(this,rFieldList,bUseAlias)); // ----------------- having Anh"angen ------------ if(aHavingStr.getLength()) { - aSqlCmd += ::rtl::OUString::createFromAscii(" HAVING "); - aSqlCmd += aHavingStr; + aSqlCmd.append(::rtl::OUString::createFromAscii(" HAVING ")); + aSqlCmd.append(aHavingStr.makeStringAndClear()); } // ----------------- Sortierung aufbauen und Anh"angen ------------ ::rtl::OUString sOrder; SqlParseError eErrorCode = eOk; if ( (eErrorCode = GenerateOrder(this,rFieldList,nTabcount > 1,sOrder)) == eOk) - aSqlCmd += sOrder; + aSqlCmd.append(sOrder); else { if ( !m_rController.hasError() ) @@ -3039,11 +3062,12 @@ sal_Bool OQueryDesignView::checkStatement() m_rController.displayError(); } + ::rtl::OUString sSQL = aSqlCmd.makeStringAndClear(); if ( xConnection.is() ) { ::connectivity::OSQLParser& rParser( rController.getParser() ); ::rtl::OUString sErrorMessage; - ::std::auto_ptr<OSQLParseNode> pParseNode( rParser.parseTree( sErrorMessage, aSqlCmd, sal_True ) ); + ::std::auto_ptr<OSQLParseNode> pParseNode( rParser.parseTree( sErrorMessage, sSQL, sal_True ) ); if ( pParseNode.get() ) { OSQLParseNode* pNode = pParseNode->getChild(3)->getChild(1); @@ -3055,12 +3079,12 @@ sal_Bool OQueryDesignView::checkStatement() OSQLParseNode::compress(pCondition); ::rtl::OUString sTemp; pParseNode->parseNodeToStr(sTemp,xConnection); - aSqlCmd = sTemp; + sSQL = sTemp; } } } } - return aSqlCmd; + return sSQL; } // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- diff --git a/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx index edcd46f09ae4..0bab915045cb 100644 --- a/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx +++ b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx @@ -96,7 +96,8 @@ OQueryTabWinUndoAct::~OQueryTabWinUndoAct() // und natuerlich auch die entsprechenden Connections ::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin(); - for(;aIter != m_vTableConnection.end();++aIter) + ::std::vector<OTableConnection*>::iterator aEnd = m_vTableConnection.end(); + for(;aIter != aEnd;++aIter) { m_pOwner->DeselectConn(*aIter); delete (*aIter); diff --git a/dbaccess/source/ui/querydesign/QueryTableView.cxx b/dbaccess/source/ui/querydesign/QueryTableView.cxx index 2d2623e4b246..a936178c0fab 100644 --- a/dbaccess/source/ui/querydesign/QueryTableView.cxx +++ b/dbaccess/source/ui/querydesign/QueryTableView.cxx @@ -434,14 +434,15 @@ void OQueryTableView::NotifyTabConnection(const OQueryTableConnection& rNewConn, // erst mal schauen, ob ich diese Connection schon habe OQueryTableConnection* pTabConn = NULL; const ::std::vector<OTableConnection*>* pConnections = getTableConnections(); + ::std::vector<OTableConnection*>::const_iterator aEnd = pConnections->end(); ::std::vector<OTableConnection*>::const_iterator aIter = ::std::find( pConnections->begin(), - pConnections->end(), + aEnd, static_cast<const OTableConnection*>(&rNewConn) ); - if(aIter == pConnections->end()) + if(aIter == aEnd ) { aIter = pConnections->begin(); - for(;aIter != pConnections->end();++aIter) + for(;aIter != aEnd;++aIter) { if(*static_cast<OQueryTableConnection*>(*aIter) == rNewConn) { @@ -549,14 +550,15 @@ void OQueryTableView::AddTabWin(const ::rtl::OUString& _rComposedName, const ::r TTableWindowData::value_type pNewTabWinData; TTableWindowData* pWindowData = getDesignView()->getController().getTableWindowData(); TTableWindowData::iterator aWinIter = pWindowData->begin(); - for(;aWinIter != pWindowData->end();++aWinIter) + TTableWindowData::iterator aWinEnd = pWindowData->end(); + for(;aWinIter != aWinEnd;++aWinIter) { pNewTabWinData = *aWinIter; if (pNewTabWinData && pNewTabWinData->GetWinName() == strAlias && pNewTabWinData->GetComposedName() == _rComposedName && pNewTabWinData->GetTableName() == _rTableName) break; } if ( !bAppend ) - bAppend = ( aWinIter == pWindowData->end() ); + bAppend = ( aWinIter == aWinEnd ); if ( bAppend ) pNewTabWinData = createTableWindowData(_rComposedName, _rTableName, strAlias); // die TabWinData brauche ich nicht in die entsprechende Liste der DocShell eintragen, das macht ShowTabWin @@ -626,9 +628,10 @@ void OQueryTableView::AddTabWin(const ::rtl::OUString& _rComposedName, const ::r OSL_ENSURE(aReferencedTable.getLength(),"Foreign key without referencedTableName"); OTableWindowMap::const_iterator aIter = pTabWins->find(aReferencedTable); - if(aIter == pTabWins->end()) + OTableWindowMap::const_iterator aEnd = pTabWins->end(); + if(aIter == aEnd) { - for(aIter = pTabWins->begin();aIter != pTabWins->end();++aIter) + for(aIter = pTabWins->begin();aIter != aEnd;++aIter) { OQueryTableWindow* pTabWinTmp = static_cast<OQueryTableWindow*>(aIter->second); OSL_ENSURE( pTabWinTmp,"TableWindow is null!" ); @@ -636,7 +639,7 @@ void OQueryTableView::AddTabWin(const ::rtl::OUString& _rComposedName, const ::r break; } } - if ( aIter != pTabWins->end() && pNewTabWin != aIter->second ) + if ( aIter != aEnd && pNewTabWin != aIter->second ) addConnections( this, *pNewTabWin, *static_cast<OQueryTableWindow*>(aIter->second), xFKeyColumns ); } break; @@ -645,7 +648,8 @@ void OQueryTableView::AddTabWin(const ::rtl::OUString& _rComposedName, const ::r { // we have a primary key so look in our list if there exsits a key which this is refered to OTableWindowMap::const_iterator aIter = pTabWins->begin(); - for(;aIter != pTabWins->end();++aIter) + OTableWindowMap::const_iterator aEnd = pTabWins->end(); + for(;aIter != aEnd;++aIter) { OQueryTableWindow* pTabWinTmp = static_cast<OQueryTableWindow*>(aIter->second); if ( pTabWinTmp == pNewTabWin ) @@ -827,7 +831,8 @@ sal_Bool OQueryTableView::FindTableFromField(const String& rFieldName, OTableFie DBG_CHKTHIS(OQueryTableView,NULL); rCnt = 0; OTableWindowMap::const_iterator aIter = GetTabWinMap()->begin(); - for(;aIter != GetTabWinMap()->end();++aIter) + OTableWindowMap::const_iterator aEnd = GetTabWinMap()->end(); + for(;aIter != aEnd;++aIter) { if(static_cast<OQueryTableWindow*>(aIter->second)->ExistsField(rFieldName, rInfo)) ++rCnt; @@ -919,7 +924,8 @@ void OQueryTableView::HideTabWin( OQueryTableWindow* pTabWin, OQueryTabWinUndoAc // (ich muss ueber das Parent gehen, da nur das die Position der Scrollbars kennt) // dann aus der Liste der TabWins raus und verstecken OTableWindowMap::iterator aIter = pTabWins->begin(); - for ( ;aIter != pTabWins->end(); ++aIter ) + OTableWindowMap::iterator aEnd = pTabWins->end(); + for ( ;aIter != aEnd ; ++aIter ) if ( aIter->second == pTabWin ) { pTabWins->erase( aIter ); @@ -943,7 +949,7 @@ void OQueryTableView::HideTabWin( OQueryTableWindow* pTabWin, OQueryTabWinUndoAc sal_Int16 nCnt = 0; const ::std::vector<OTableConnection*>* pTabConList = getTableConnections(); ::std::vector<OTableConnection*>::const_iterator aIter2 = pTabConList->begin(); - for(;aIter2 != pTabConList->end();) + for(;aIter2 != pTabConList->end();)// the end may change { OQueryTableConnection* pTmpEntry = static_cast<OQueryTableConnection*>(*aIter2); OSL_ENSURE(pTmpEntry,"OQueryTableConnection is null!"); @@ -1016,8 +1022,9 @@ sal_Bool OQueryTableView::ShowTabWin( OQueryTableWindow* pTabWin, OQueryTabWinUn // die Connections ::std::vector<OTableConnection*>* pTableCon = pUndoAction->GetTabConnList(); ::std::vector<OTableConnection*>::iterator aIter = pTableCon->begin(); + ::std::vector<OTableConnection*>::iterator aEnd = pTableCon->end(); - for(;aIter != pTableCon->end();++aIter) + for(;aIter != aEnd;++aIter) addConnection(*aIter); // add all connections from the undo action // each connection should invalidated inside addConnection so we don't need this here any longer @@ -1069,7 +1076,8 @@ sal_Bool OQueryTableView::ExistsAVisitedConn(const OQueryTableWindow* pFrom) con if (pList) { ::std::vector<OTableConnection*>::const_iterator aIter = pList->begin(); - for(;aIter != pList->end();++aIter) + ::std::vector<OTableConnection*>::const_iterator aEnd = pList->end(); + for(;aIter != aEnd;++aIter) { OQueryTableConnection* pTemp = static_cast<OQueryTableConnection*>(*aIter); if (pTemp->IsVisited() && diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index 440be631a3ae..fa1b1e82fbd8 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -573,7 +573,9 @@ void OSelectionBrowseBox::InitController(CellControllerRef& /*rController*/, lon if (pTabWinList) { OJoinTableView::OTableWindowMap::iterator aIter = pTabWinList->begin(); - for(;aIter != pTabWinList->end();++aIter) + OJoinTableView::OTableWindowMap::iterator aEnd = pTabWinList->end(); + + for(;aIter != aEnd;++aIter) m_pTableCell->InsertEntry(static_cast<OQueryTableWindow*>(aIter->second)->GetAliasName()); m_pTableCell->InsertEntry(String(ModuleRes(STR_QUERY_NOTABLE)), 0); @@ -1790,7 +1792,8 @@ void OSelectionBrowseBox::AddGroupBy( const OTableFieldDescRef& rInfo , sal_uInt OTableFields& rFields = getFields(); OTableFields::iterator aIter = rFields.begin(); - for(;aIter != rFields.end();++aIter) + OTableFields::iterator aEnd = rFields.end(); + for(;aIter != aEnd;++aIter) { pEntry = *aIter; OSL_ENSURE(pEntry.isValid(),"OTableFieldDescRef was null!"); @@ -1845,8 +1848,10 @@ void OSelectionBrowseBox::AddCondition( const OTableFieldDescRef& rInfo, const S Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData(); ::comphelper::UStringMixEqual bCase(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers()); - OTableFields::iterator aIter = getFields().begin(); - for(;aIter != getFields().end();++aIter) + OTableFields& rFields = getFields(); + OTableFields::iterator aIter = rFields.begin(); + OTableFields::iterator aEnd = rFields.end(); + for(;aIter != aEnd;++aIter) { pEntry = *aIter; const ::rtl::OUString aField = pEntry->GetField(); @@ -1926,7 +1931,8 @@ void OSelectionBrowseBox::AddOrder( const OTableFieldDescRef& rInfo, const EOrde sal_Bool bAppend = sal_False; OTableFields& rFields = getFields(); OTableFields::iterator aIter = rFields.begin(); - for(;aIter != rFields.end();++aIter) + OTableFields::iterator aEnd = rFields.end(); + for(;aIter != aEnd;++aIter) { pEntry = *aIter; ::rtl::OUString aField = pEntry->GetField(); diff --git a/dbaccess/source/ui/querydesign/TableConnection.cxx b/dbaccess/source/ui/querydesign/TableConnection.cxx index 11e9da016f0d..38b2507da98a 100644 --- a/dbaccess/source/ui/querydesign/TableConnection.cxx +++ b/dbaccess/source/ui/querydesign/TableConnection.cxx @@ -89,8 +89,9 @@ namespace dbaui // Linienliste mit Defaults initialisieren OConnectionLineDataVec* pLineData = GetData()->GetConnLineDataList(); OConnectionLineDataVec::const_iterator aIter = pLineData->begin(); + OConnectionLineDataVec::const_iterator aEnd = pLineData->end(); m_vConnLine.reserve(pLineData->size()); - for(;aIter != pLineData->end();++aIter) + for(;aIter != aEnd;++aIter) m_vConnLine.push_back( new OConnectionLine(this, *aIter) ); } @@ -102,7 +103,8 @@ namespace dbaui // ----------------------------------------------------------------------------- void OTableConnection::clearLineData() { - for(::std::vector<OConnectionLine*>::iterator aLineIter = m_vConnLine.begin();aLineIter != m_vConnLine.end();++aLineIter) + ::std::vector<OConnectionLine*>::iterator aLineEnd = m_vConnLine.end(); + for(::std::vector<OConnectionLine*>::iterator aLineIter = m_vConnLine.begin();aLineIter != aLineEnd;++aLineIter) delete *aLineIter; m_vConnLine.clear(); } @@ -130,8 +132,9 @@ namespace dbaui { const ::std::vector<OConnectionLine*>* pLine = rConn.GetConnLineList(); ::std::vector<OConnectionLine*>::const_iterator aIter = pLine->begin(); + ::std::vector<OConnectionLine*>::const_iterator aEnd = pLine->end(); m_vConnLine.reserve(pLine->size()); - for(;aIter != pLine->end();++aIter) + for(;aIter != aEnd;++aIter) m_vConnLine.push_back( CreateConnLine( **aIter )); } @@ -223,7 +226,8 @@ namespace dbaui // Aus allen Linien das umgebende Rechteck bestimmen Rectangle aBoundingRect( Point(0,0), Point(0,0) ); Rectangle aTempRect; - for(::std::vector<OConnectionLine*>::const_iterator aIter = m_vConnLine.begin();aIter != m_vConnLine.end();++aIter) + ::std::vector<OConnectionLine*>::const_iterator aEnd = m_vConnLine.end(); + for(::std::vector<OConnectionLine*>::const_iterator aIter = m_vConnLine.begin();aIter != aEnd;++aIter) { aTempRect = (*aIter)->GetBoundingRect(); diff --git a/dbaccess/source/ui/querydesign/TableConnectionData.cxx b/dbaccess/source/ui/querydesign/TableConnectionData.cxx index 3ef73f61dbdb..c1d55cfb4793 100644 --- a/dbaccess/source/ui/querydesign/TableConnectionData.cxx +++ b/dbaccess/source/ui/querydesign/TableConnectionData.cxx @@ -111,7 +111,8 @@ OTableConnectionData& OTableConnectionData::operator=( const OTableConnectionDat OConnectionLineDataVec* pLineData = const_cast<OTableConnectionData*>(&rConnData)->GetConnLineDataList(); OConnectionLineDataVec::const_iterator aIter = pLineData->begin(); - for(;aIter != pLineData->end();++aIter) + OConnectionLineDataVec::const_iterator aEnd = pLineData->end(); + for(;aIter != aEnd;++aIter) m_vConnLineData.push_back(new OConnectionLineData(**aIter)); return *this; @@ -140,12 +141,13 @@ BOOL OTableConnectionData::SetConnLine( USHORT nIndex, const String& rSourceFiel BOOL OTableConnectionData::AppendConnLine( const ::rtl::OUString& rSourceFieldName, const ::rtl::OUString& rDestFieldName ) { OConnectionLineDataVec::iterator aIter = m_vConnLineData.begin(); - for(;aIter != m_vConnLineData.end();++aIter) + OConnectionLineDataVec::iterator aEnd = m_vConnLineData.end(); + for(;aIter != aEnd;++aIter) { if((*aIter)->GetDestFieldName() == rDestFieldName && (*aIter)->GetSourceFieldName() == rSourceFieldName) break; } - if(aIter == m_vConnLineData.end()) + if(aIter == aEnd) { OConnectionLineDataRef pNew = new OConnectionLineData(rSourceFieldName, rDestFieldName); if (!pNew.isValid()) diff --git a/dbaccess/source/ui/querydesign/TableWindowAccess.cxx b/dbaccess/source/ui/querydesign/TableWindowAccess.cxx index 9db1be38959f..fe419a957e7e 100644 --- a/dbaccess/source/ui/querydesign/TableWindowAccess.cxx +++ b/dbaccess/source/ui/querydesign/TableWindowAccess.cxx @@ -187,9 +187,10 @@ namespace dbaui // search the postion of our table window in the table window map OJoinTableView::OTableWindowMap* pMap = m_pTable->getTableView()->GetTabWinMap(); OJoinTableView::OTableWindowMap::iterator aIter = pMap->begin(); - for (nIndex = 0; aIter != pMap->end() && aIter->second != m_pTable; ++nIndex,++aIter) + OJoinTableView::OTableWindowMap::iterator aEnd = pMap->end(); + for (nIndex = 0; aIter != aEnd && aIter->second != m_pTable; ++nIndex,++aIter) ; - nIndex = aIter != pMap->end() ? nIndex : -1; + nIndex = aIter != aEnd ? nIndex : -1; } return nIndex; } @@ -278,9 +279,10 @@ namespace dbaui const ::std::vector<OTableConnection*>* pConnectionList = pView->getTableConnections(); ::std::vector<OTableConnection*>::const_iterator aIter = pView->getTableConnections(m_pTable); + ::std::vector<OTableConnection*>::const_iterator aEnd = pConnectionList->end(); ::std::vector< Reference<XInterface> > aRelations; aRelations.reserve(5); // just guessing - for (; aIter != pConnectionList->end() ; ++aIter ) + for (; aIter != aEnd ; ++aIter ) aRelations.push_back(getParentChild(aIter - pConnectionList->begin())); Reference<XInterface> *pRelations = aRelations.empty() ? 0 : &aRelations[0]; diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx index 5b6be38be4a9..d29fa9b3ab5a 100644 --- a/dbaccess/source/ui/querydesign/querycontroller.cxx +++ b/dbaccess/source/ui/querydesign/querycontroller.cxx @@ -1098,8 +1098,9 @@ void OQueryController::reconnect(sal_Bool _bUI) void OQueryController::saveViewSettings(Sequence<PropertyValue>& _rViewProps) { OTableFields::const_iterator aFieldIter = m_vTableFieldDesc.begin(); + OTableFields::const_iterator aFieldEnd = m_vTableFieldDesc.end(); sal_Int32 nCount = 0; - for(;aFieldIter != m_vTableFieldDesc.end();++aFieldIter) + for(;aFieldIter != aFieldEnd;++aFieldIter) { if(!(*aFieldIter)->IsEmpty()) ++nCount; @@ -1118,7 +1119,7 @@ void OQueryController::saveViewSettings(Sequence<PropertyValue>& _rViewProps) PropertyValue *pFieldsIter = aFields.getArray(); // the fielddata aFieldIter = m_vTableFieldDesc.begin(); - for(sal_Int32 i = 1;aFieldIter != m_vTableFieldDesc.end();++aFieldIter,++i) + for(sal_Int32 i = 1;aFieldIter !=aFieldEnd;++aFieldIter,++i) { if ( !(*aFieldIter)->IsEmpty() ) { diff --git a/dbaccess/source/ui/relationdesign/RTableConnection.cxx b/dbaccess/source/ui/relationdesign/RTableConnection.cxx index 7d83a2fc8cc4..6c10df064a18 100644 --- a/dbaccess/source/ui/relationdesign/RTableConnection.cxx +++ b/dbaccess/source/ui/relationdesign/RTableConnection.cxx @@ -104,7 +104,8 @@ void ORelationTableConnection::Draw( const Rectangle& rRect ) const OConnectionLine* pTopLine = NULL; const ::std::vector<OConnectionLine*>* pConnLineList = GetConnLineList(); ::std::vector<OConnectionLine*>::const_iterator aIter = pConnLineList->begin(); - for(;aIter != pConnLineList->end();++aIter) + ::std::vector<OConnectionLine*>::const_iterator aEnd = pConnLineList->end(); + for(;aIter != aEnd;++aIter) { if( (*aIter)->IsValid() ) { diff --git a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx index f052003c2c58..ad0bc1a26ea5 100644 --- a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx +++ b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx @@ -138,7 +138,8 @@ void ORelationTableConnectionData::ChangeOrientation() // Source- und DestFieldName der Linien austauschen ::rtl::OUString sTempString; OConnectionLineDataVec::iterator aIter = m_vConnLineData.begin(); - for(;aIter != m_vConnLineData.end();++aIter) + OConnectionLineDataVec::iterator aEnd = m_vConnLineData.end(); + for(;aIter != aEnd;++aIter) { sTempString = (*aIter)->GetSourceFieldName(); (*aIter)->SetSourceFieldName( (*aIter)->GetDestFieldName() ); @@ -195,7 +196,8 @@ BOOL ORelationTableConnectionData::checkPrimaryKey(const Reference< XIndexAccess for(;pKeyIter != pKeyEnd;++pKeyIter) { OConnectionLineDataVec::const_iterator aIter = m_vConnLineData.begin(); - for(;aIter != m_vConnLineData.end();++aIter) + OConnectionLineDataVec::const_iterator aEnd = m_vConnLineData.end(); + for(;aIter != aEnd;++aIter) { ++nValidLinesCount; if ( (*aIter)->GetFieldName(_eEConnectionSide) == *pKeyIter ) @@ -338,7 +340,8 @@ BOOL ORelationTableConnectionData::Update() if ( xColumnFactory.is() ) { OConnectionLineDataVec::iterator aIter = m_vConnLineData.begin(); - for(;aIter != m_vConnLineData.end();++aIter) + OConnectionLineDataVec::iterator aEnd = m_vConnLineData.end(); + for(;aIter != aEnd;++aIter) { if((*aIter)->GetSourceFieldName().getLength() && (*aIter)->GetDestFieldName().getLength()) { @@ -392,7 +395,8 @@ BOOL ORelationTableConnectionData::Update() xColumn->getPropertyValue(PROPERTY_RELATEDCOLUMN) >>= sRelatedColumn; OConnectionLineDataVec::iterator aIter = m_vConnLineData.begin(); - for(;aIter != m_vConnLineData.end();++aIter) + OConnectionLineDataVec::iterator aEnd = m_vConnLineData.end(); + for(;aIter != aEnd;++aIter) { if( (*aIter)->GetSourceFieldName() == sName && (*aIter)->GetDestFieldName() == sRelatedColumn ) diff --git a/dbaccess/source/ui/relationdesign/RelationController.cxx b/dbaccess/source/ui/relationdesign/RelationController.cxx index b9b599c1c8cc..3997cb656799 100644 --- a/dbaccess/source/ui/relationdesign/RelationController.cxx +++ b/dbaccess/source/ui/relationdesign/RelationController.cxx @@ -515,12 +515,13 @@ TTableWindowData::value_type ORelationController::existsTable(const ::rtl::OUStr Reference<XDatabaseMetaData> xMeta = getConnection()->getMetaData(); ::comphelper::UStringMixEqual bCase(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers()); TTableWindowData::const_iterator aIter = m_vTableData.begin(); - for(;aIter != m_vTableData.end();++aIter) + TTableWindowData::const_iterator aEnd = m_vTableData.end(); + for(;aIter != aEnd;++aIter) { if(bCase((*aIter)->GetComposedName(),_rComposedTableName)) break; } - return ( aIter != m_vTableData.end()) ? *aIter : TTableWindowData::value_type(); + return ( aIter != aEnd) ? *aIter : TTableWindowData::value_type(); } // ----------------------------------------------------------------------------- void ORelationController::loadLayoutInformation() diff --git a/dbaccess/source/ui/relationdesign/RelationTableView.cxx b/dbaccess/source/ui/relationdesign/RelationTableView.cxx index 82d42ccc87de..ffbff7cf2e3e 100644 --- a/dbaccess/source/ui/relationdesign/RelationTableView.cxx +++ b/dbaccess/source/ui/relationdesign/RelationTableView.cxx @@ -207,7 +207,8 @@ void ORelationTableView::AddConnection(const OJoinExchangeData& jxdSource, const OTableWindow* pDestWin = jxdDest.pListBox->GetTabWin(); ::std::vector<OTableConnection*>::const_iterator aIter = getTableConnections()->begin(); - for(;aIter != getTableConnections()->end();++aIter) + ::std::vector<OTableConnection*>::const_iterator aEnd = getTableConnections()->end(); + for(;aIter != aEnd;++aIter) { OTableConnection* pFirst = *aIter; if((pFirst->GetSourceWin() == pSourceWin && pFirst->GetDestWin() == pDestWin) || diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx index 353ff0ea11d5..1c8bf569ea19 100644 --- a/dbaccess/source/ui/tabledesign/TEditControl.cxx +++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx @@ -512,7 +512,8 @@ void OTableEditorCtrl::InitController(CellControllerRef&, long nRow, sal_uInt16 const OTypeInfoMap* pTypeInfo = GetView()->getController().getTypeInfo(); OTypeInfoMap::const_iterator aIter = pTypeInfo->begin(); - for(;aIter != pTypeInfo->end();++aIter) + OTypeInfoMap::const_iterator aEnd = pTypeInfo->end(); + for(;aIter != aEnd;++aIter) pTypeCell->InsertEntry( aIter->second->aUIName ); pTypeCell->SelectEntry( aInitString ); } @@ -620,9 +621,10 @@ sal_Int32 OTableEditorCtrl::HasFieldName( const String& rFieldName ) ::comphelper::UStringMixEqual bCase(xMetaData.is() ? xMetaData->supportsMixedCaseQuotedIdentifiers() : sal_True); ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_pRowList->begin(); + ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aEnd = m_pRowList->end(); OFieldDescription* pFieldDescr; sal_Int32 nCount(0); - for(;aIter != m_pRowList->end();++aIter) + for(;aIter != aEnd;++aIter) { pFieldDescr = (*aIter)->GetActFieldDescr(); if( pFieldDescr && bCase(rFieldName,pFieldDescr->GetName())) @@ -1806,7 +1808,8 @@ void OTableEditorCtrl::SetPrimaryKey( sal_Bool bSet ) long nIndex = 0; ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = m_pRowList->begin(); - for(sal_Int32 nRow = 0;aIter != m_pRowList->end();++aIter,++nRow) + ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aEnd = m_pRowList->end(); + for(sal_Int32 nRow = 0;aIter != aEnd;++aIter,++nRow) { OFieldDescription* pFieldDescr = (*aIter)->GetActFieldDescr(); if( pFieldDescr && (*aIter)->IsPrimaryKey() && (!bSet || !IsRowSelected(nRow)) ) @@ -1856,7 +1859,8 @@ sal_Bool OTableEditorCtrl::IsPrimaryKey() // Gehoeren alle markierten Felder zu einem Primary Key ? long nPrimaryKeys = 0; ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = m_pRowList->begin(); - for(sal_Int32 nRow=0;aIter != m_pRowList->end();++aIter,++nRow) + ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aEnd = m_pRowList->end(); + for(sal_Int32 nRow=0;aIter != aEnd;++aIter,++nRow) { if( IsRowSelected(nRow) && !(*aIter)->IsPrimaryKey() ) return sal_False; @@ -1890,7 +1894,7 @@ void OTableEditorCtrl::SwitchType( const TOTypeInfoSP& _pType ) pRow->SetFieldType( _pType, sal_True ); if ( _pType.get() ) { - sal_uInt16 nCurrentlySelected = pTypeCell->GetSelectEntryPos(); + const sal_uInt16 nCurrentlySelected = pTypeCell->GetSelectEntryPos(); if ( ( LISTBOX_ENTRY_NOTFOUND == nCurrentlySelected ) || ( GetView()->getController().getTypeInfo( nCurrentlySelected ) != _pType ) @@ -1899,7 +1903,8 @@ void OTableEditorCtrl::SwitchType( const TOTypeInfoSP& _pType ) USHORT nEntryPos = 0; const OTypeInfoMap* pTypeInfo = GetView()->getController().getTypeInfo(); OTypeInfoMap::const_iterator aIter = pTypeInfo->begin(); - for(;aIter != pTypeInfo->end();++aIter,++nEntryPos) + OTypeInfoMap::const_iterator aEnd = pTypeInfo->end(); + for(;aIter != aEnd;++aIter,++nEntryPos) { if(aIter->second == _pType) break; diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx index f54c5104c955..87077ef9b766 100644 --- a/dbaccess/source/ui/tabledesign/TableController.cxx +++ b/dbaccess/source/ui/tabledesign/TableController.cxx @@ -166,6 +166,9 @@ #include <cppuhelper/exc_hlp.hxx> #endif #include "dsmeta.hxx" +#include <boost/bind.hpp> +#include <algorithm> +#include <functional> extern "C" void SAL_CALL createRegistryInfo_OTableControl() { @@ -255,7 +258,6 @@ OTableController::OTableController(const Reference< XMultiServiceFactory >& _rM) InvalidateAll(); m_pTypeInfo = TOTypeInfoSP(new OTypeInfo()); m_pTypeInfo->aUIName = m_sTypeNames.GetToken(TYPE_OTHER); - m_aTypeCollection.initUserDriverTypes(_rM); } // ----------------------------------------------------------------------------- OTableController::~OTableController() @@ -1015,7 +1017,8 @@ void OTableController::loadData() for(;pKeyBegin != pKeyEnd;++pKeyBegin) { ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator rowIter = m_vRowList.begin(); - for(;rowIter != m_vRowList.end();++rowIter) + ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator rowEnd = m_vRowList.end(); + for(;rowIter != rowEnd;++rowIter) { if((*rowIter)->GetActFieldDescr()->GetName() == *pKeyBegin) { @@ -1399,7 +1402,7 @@ void OTableController::alterColumns() // third append the new columns aIter = m_vRowList.begin(); - for(;aIter != m_vRowList.end();++aIter) + for(;aIter != aEnd;++aIter) { OSL_ENSURE(*aIter,"OTableRow is null!"); OFieldDescription* pField = (*aIter)->GetActFieldDescr(); @@ -1437,7 +1440,7 @@ void OTableController::alterColumns() if ( xKeyColumns.is() ) { aIter = m_vRowList.begin(); - for(;aIter != m_vRowList.end();++aIter) + for(;aIter != aEnd;++aIter) { OSL_ENSURE(*aIter,"OTableRow is null!"); OFieldDescription* pField = (*aIter)->GetActFieldDescr(); @@ -1551,9 +1554,7 @@ void OTableController::assignTable() setEditable( xMeta.is() && !xMeta->isReadOnly() && (isAlterAllowed() || isDropAllowed() || isAddAllowed()) ); if(!isEditable()) { - ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_vRowList.begin(); - for(; aIter != m_vRowList.end(); ++aIter) - (*aIter)->SetReadOnly(sal_True); + ::std::for_each(m_vRowList.begin(),m_vRowList.end(),boost::bind( &OTableRow::SetReadOnly, _1, boost::cref( sal_True ))); } m_bNew = sal_False; // be notified when the table is in disposing @@ -1612,7 +1613,8 @@ void OTableController::reSyncRows() sal_Bool bAlterAllowed = isAlterAllowed(); sal_Bool bAddAllowed = isAddAllowed(); ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_vRowList.begin(); - for(;aIter != m_vRowList.end();++aIter) + ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aEnd = m_vRowList.end(); + for(;aIter != aEnd;++aIter) { OSL_ENSURE(*aIter,"OTableRow is null!"); OFieldDescription* pField = (*aIter)->GetActFieldDescr(); @@ -1636,7 +1638,8 @@ void OTableController::reSyncRows() ::comphelper::UStringMixEqual bCase(xMetaData.is() ? xMetaData->supportsMixedCaseQuotedIdentifiers() : sal_True); ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = m_vRowList.begin(); - for(sal_Int32 i=0;aIter != m_vRowList.end();++aIter) + ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aEnd = m_vRowList.end(); + for(sal_Int32 i=0;aIter != aEnd;++aIter) { OFieldDescription* pFieldDesc = (*aIter)->GetActFieldDescr(); if (pFieldDesc && pFieldDesc->GetName().getLength() && bCase(sName,pFieldDesc->GetName())) @@ -1702,8 +1705,6 @@ sal_Int32 OTableController::getFirstEmptyRowPosition() const // ----------------------------------------------------------------------------- bool OTableController::isAutoIncrementPrimaryKey() const { - ::dbaccess::DATASOURCE_TYPE eType = m_aTypeCollection.getType(::comphelper::getString(getDataSource()->getPropertyValue(PROPERTY_URL))); - DataSourceMetaData aMeta(eType); - return aMeta.getAdvancedSettingsSupport().bAutoIncrementIsPrimaryKey; + return getSdbMetaData().isAutoIncrementPrimaryKey(); } // ----------------------------------------------------------------------------- diff --git a/dbaccess/source/ui/tabledesign/TableRowExchange.cxx b/dbaccess/source/ui/tabledesign/TableRowExchange.cxx index a0aebcbc7b72..910b912d75b5 100644 --- a/dbaccess/source/ui/tabledesign/TableRowExchange.cxx +++ b/dbaccess/source/ui/tabledesign/TableRowExchange.cxx @@ -61,7 +61,8 @@ namespace dbaui { (*rxOStm) << (sal_Int32)pRows->size(); // first stream the size ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = pRows->begin(); - for(;aIter != pRows->end();++aIter) + ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aEnd = pRows->end(); + for(;aIter != aEnd;++aIter) (*rxOStm) << *(*aIter); return sal_True; } diff --git a/dbaccess/source/ui/tabledesign/TableUndo.cxx b/dbaccess/source/ui/tabledesign/TableUndo.cxx index 2d8ec4d49994..e4a801c41396 100644 --- a/dbaccess/source/ui/tabledesign/TableUndo.cxx +++ b/dbaccess/source/ui/tabledesign/TableUndo.cxx @@ -271,11 +271,12 @@ void OTableEditorDelUndoAct::Undo() // Geloeschte Zeilen wieder einfuegen ULONG nPos; ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_aDeletedRows.begin(); + ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aEnd = m_aDeletedRows.end(); ::boost::shared_ptr<OTableRow> pNewOrigRow; ::std::vector< ::boost::shared_ptr<OTableRow> >* pOriginalRows = pTabEdCtrl->GetRowList(); - for(;aIter != m_aDeletedRows.end();++aIter) + for(;aIter != aEnd;++aIter) { pNewOrigRow.reset(new OTableRow( **aIter )); nPos = (*aIter)->GetPos(); @@ -294,9 +295,10 @@ void OTableEditorDelUndoAct::Redo() // Zeilen wieder loeschen ULONG nPos; ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_aDeletedRows.begin(); + ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aEnd = m_aDeletedRows.end(); ::std::vector< ::boost::shared_ptr<OTableRow> >* pOriginalRows = pTabEdCtrl->GetRowList(); - for(;aIter != m_aDeletedRows.end();++aIter) + for(;aIter != aEnd;++aIter) { nPos = (*aIter)->GetPos(); pOriginalRows->erase( pOriginalRows->begin()+nPos ); @@ -354,8 +356,9 @@ void OTableEditorInsUndoAct::Redo() long nInsertRow = m_nInsPos; ::boost::shared_ptr<OTableRow> pRow; ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_vInsertedRows.begin(); + ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aEnd = m_vInsertedRows.end(); ::std::vector< ::boost::shared_ptr<OTableRow> >* pRowList = pTabEdCtrl->GetRowList(); - for(;aIter != m_vInsertedRows.end();++aIter) + for(;aIter != aEnd;++aIter) { pRow.reset(new OTableRow( **aIter )); pRowList->insert( pRowList->begin()+nInsertRow ,pRow ); diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx index 511edcd4bb07..9fa9d828d755 100644 --- a/dbaccess/source/ui/uno/copytablewizard.cxx +++ b/dbaccess/source/ui/uno/copytablewizard.cxx @@ -1198,6 +1198,7 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou ++nRowCount; sal_Bool bInsertAutoIncrement = sal_True; ODatabaseExport::TPositions::const_iterator aPosIter = aColumnMapping.begin(); + ODatabaseExport::TPositions::const_iterator aPosEnd = aColumnMapping.end(); aCopyEvent.Error.clear(); try @@ -1209,7 +1210,7 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou sal_Int32 nSourceColumn( 1 ); ValueTransfer aTransfer( nSourceColumn, nDestColumn, aSourceColTypes, xRow, xStatementParams ); - for ( ; aPosIter != aColumnMapping.end(); ++aPosIter ) + for ( ; aPosIter != aPosEnd; ++aPosIter ) { nDestColumn = aPosIter->first; if ( nDestColumn == COLUMN_POSITION_NOT_FOUND ) diff --git a/dbaccess/source/ui/uno/makefile.mk b/dbaccess/source/ui/uno/makefile.mk index 8651a83fd33a..d29d881d7a26 100644 --- a/dbaccess/source/ui/uno/makefile.mk +++ b/dbaccess/source/ui/uno/makefile.mk @@ -62,7 +62,6 @@ SLOFILES= \ $(SLO)$/unoDirectSql.obj \ $(SLO)$/DBTypeWizDlg.obj \ $(SLO)$/DBTypeWizDlgSetup.obj \ - $(SLO)$/AdabasSettingsDlg.obj \ $(SLO)$/UserSettingsDlg.obj \ $(SLO)$/ColumnModel.obj \ $(SLO)$/ColumnControl.obj \ diff --git a/dbaccess/source/ui/uno/unoadmin.cxx b/dbaccess/source/ui/uno/unoadmin.cxx index 547bad4cee07..d41675c0c051 100644 --- a/dbaccess/source/ui/uno/unoadmin.cxx +++ b/dbaccess/source/ui/uno/unoadmin.cxx @@ -94,8 +94,7 @@ ODatabaseAdministrationDialog::ODatabaseAdministrationDialog(const Reference< XM { DBG_CTOR(ODatabaseAdministrationDialog,NULL); - m_pCollection = new ::dbaccess::ODsnTypeCollection(); - m_pCollection->initUserDriverTypes(m_aContext.getLegacyServiceFactory()); + m_pCollection = new ::dbaccess::ODsnTypeCollection(_rxORB); ODbAdminDialog::createItemSet(m_pDatasourceItems, m_pItemPool, m_pItemPoolDefaults, m_pCollection); } |