diff options
85 files changed, 1322 insertions, 1193 deletions
diff --git a/dbaccess/qa/complex/dbaccess/dbaccess.sce b/dbaccess/qa/complex/dbaccess/dbaccess.sce index 47387e459ae9..c5fa408ff273 100644 --- a/dbaccess/qa/complex/dbaccess/dbaccess.sce +++ b/dbaccess/qa/complex/dbaccess/dbaccess.sce @@ -7,6 +7,6 @@ -o complex.dbaccess.DataSource -o complex.dbaccess.Parser -o complex.dbaccess.ApplicationController -#-o complex.dbaccess.CopyTableWizard +-o complex.dbaccess.CopyTableWizard -o complex.dbaccess.UISettings -o complex.dbaccess.Beamer diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx index f028dba66ae0..3df7ce655bfa 100644 --- a/dbaccess/source/core/api/KeySet.cxx +++ b/dbaccess/source/core/api/KeySet.cxx @@ -621,8 +621,6 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow } m_bUpdated = xPrep->executeUpdate() > 0; - - if(m_bUpdated) { m_aKeyIter = m_aKeyMap.find(::comphelper::getINT32((_rInsertRow->get())[0].getAny())); @@ -1171,8 +1169,9 @@ void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException) m_xSet = m_xStatement->executeQuery(); OSL_ENSURE(m_xSet.is(),"No resultset form statement!"); - sal_Bool bOK = m_xSet->next(); (void)bOK; - OSL_ENSURE(bOK,"No rows!"); + sal_Bool bOK = m_xSet->next(); + if ( !bOK ) + m_aKeyIter = m_aKeyMap.end(); m_xRow.set(m_xSet,UNO_QUERY); OSL_ENSURE(m_xRow.is(),"No row form statement!"); } diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index 18d8398c8233..c51949e1e650 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -977,19 +977,26 @@ void SAL_CALL ORowSet::updateRow( ) throw(SQLException, RuntimeException) m_pCache->updateRow(m_aCurrentRow.operator ->()); m_aBookmark = m_pCache->getBookmark(); m_aCurrentRow = m_pCache->m_aMatrixIter; - m_aOldRow->setRow(new ORowSetValueVector(m_aCurrentRow->getBody())); + if ( m_pCache->m_aMatrixIter != m_pCache->getEnd() ) + { + m_aOldRow->setRow(new ORowSetValueVector(m_aCurrentRow->getBody())); - // notification order - // - column values - ORowSetBase::firePropertyChange(aOldValues); + // notification order + // - column values + ORowSetBase::firePropertyChange(aOldValues); - // - rowChanged - notifyAllListenersRowChanged(aGuard,aEvt); + // - rowChanged + notifyAllListenersRowChanged(aGuard,aEvt); - // - IsModified - if(!m_bModified) - fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True); - OSL_ENSURE( !m_bModified, "ORowSet::updateRow: just updated, but _still_ modified?" ); + // - IsModified + if(!m_bModified) + fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True); + OSL_ENSURE( !m_bModified, "ORowSet::updateRow: just updated, but _still_ modified?" ); + } + else // the update went rong + { + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_UPDATE_FAILED ), SQL_INVALID_CURSOR_POSITION, *this ); + } } } // ------------------------------------------------------------------------- @@ -1001,20 +1008,15 @@ void SAL_CALL ORowSet::deleteRow( ) throw(SQLException, RuntimeException) checkCache(); if ( m_bBeforeFirst || m_bAfterLast ) - throwSQLException( "Cannot delete the before-first or after-last row.", SQL_INVALID_CURSOR_POSITION, *this ); - // TODO: resource + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_DELETE_BEFORE_AFTER ), SQL_INVALID_CURSOR_POSITION, *this ); if ( m_bNew ) - throwSQLException( "Cannot delete the insert-row.", SQL_INVALID_CURSOR_POSITION, *this ); - // TODO: resource + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_DELETE_INSERT_ROW ), SQL_INVALID_CURSOR_POSITION, *this ); if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY ) - throwSQLException( "Result set is read only.", SQL_FUNCTION_SEQUENCE_ERROR, *this ); - // TODO: resource + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_RESULT_IS_READONLY ), SQL_FUNCTION_SEQUENCE_ERROR, *this ); if ( ( m_pCache->m_nPrivileges & Privilege::DELETE ) != Privilege::DELETE ) - throwSQLException( "DELETE privilege not available.", SQL_FUNCTION_SEQUENCE_ERROR, *this ); - // TODO: resource + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_DELETE_PRIVILEGE ), SQL_FUNCTION_SEQUENCE_ERROR, *this ); if ( rowDeleted() ) - throwSQLException( "Current row already deleted.", SQL_FUNCTION_SEQUENCE_ERROR, *this ); - // TODO: resource + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_ROW_ALREADY_DELETED ), SQL_FUNCTION_SEQUENCE_ERROR, *this ); // this call position the cache indirect Any aBookmarkToDelete( m_aBookmark ); @@ -1178,8 +1180,7 @@ void SAL_CALL ORowSet::moveToInsertRow( ) throw(SQLException, RuntimeException) ::osl::ResettableMutexGuard aGuard( *m_pMutex ); checkPositioningAllowed(); if ( ( m_pCache->m_nPrivileges & Privilege::INSERT ) != Privilege::INSERT ) - throwSQLException( "No insert privileges", SQL_GENERAL_ERROR, *this ); - // TODO: resource + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_INSERT_PRIVILEGE ), SQL_GENERAL_ERROR, *this ); if ( notifyAllListenersCursorBeforeMove( aGuard ) ) { @@ -1245,8 +1246,7 @@ void SAL_CALL ORowSet::moveToCurrentRow( ) throw(SQLException, RuntimeException // m_bModified should be true. Also, as soon as somebody calls moveToInsertRow, // our current row should not be deleted anymore. So, we should not have survived the above // check "if ( !m_pCache->m_bNew && !m_bModified )" - throwSQLException( "The current row is deleted.", SQL_FUNCTION_SEQUENCE_ERROR, *this ); - // TODO: resource + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_ROW_ALREADY_DELETED ), SQL_FUNCTION_SEQUENCE_ERROR, *this ); if ( notifyAllListenersCursorBeforeMove( aGuard ) ) { @@ -1578,7 +1578,11 @@ void ORowSet::setStatementResultSetType( const Reference< XPropertySet >& _rxSta { ResultSetType::SCROLL_INSENSITIVE, ResultSetConcurrency::READ_ONLY }, { ResultSetType::FORWARD_ONLY, ResultSetConcurrency::READ_ONLY } }; - for ( sal_Int32 i=0; i<5; ++i ) + sal_Int32 i=0; + if ( m_xActiveConnection->getMetaData()->isReadOnly() ) + i = 2; // if the database is read-only we only should use read-only concurrency + + for ( ; i<5; ++i ) { nResultSetType = nCharacteristics[i][0]; nResultSetConcurrency = nCharacteristics[i][1]; @@ -1610,12 +1614,7 @@ Reference< XResultSet > ORowSet::impl_prepareAndExecute_throw() m_xStatement = m_xActiveConnection->prepareStatement( sCommandToExecute ); if ( !m_xStatement.is() ) { - SQLException aError; - aError.Context = *this; - aError.SQLState = getStandardSQLState( SQL_GENERAL_ERROR ); - aError.Message = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Internal error: no statement object provided by the database driver." ) ); - // TODO: resource - throw aError; + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_INTERNAL_ERROR ), SQL_GENERAL_ERROR, *this ); } Reference< XPropertySet > xStatementProps( m_xStatement, UNO_QUERY_THROW ); @@ -1885,15 +1884,17 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi for(sal_Int32 i=1; i <= nCount ;++i) { ::rtl::OUString sName = xMeta->getColumnName(i); + ::rtl::OUString sColumnLabel = xMeta->getColumnLabel(i); // retrieve the column number |i| Reference<XPropertySet> xColumn; { sal_Bool bReFetchName = sal_False; - if (m_xColumns->hasByName(sName)) + if (m_xColumns->hasByName(sColumnLabel)) + m_xColumns->getByName(sColumnLabel) >>= xColumn; + if (!xColumn.is() && m_xColumns->hasByName(sName)) m_xColumns->getByName(sName) >>= xColumn; - if (!xColumn.is() && m_xColumns->hasByName(xMeta->getColumnLabel(i))) - m_xColumns->getByName(xMeta->getColumnLabel(i)) >>= xColumn; + // check if column already in the list we need another if ( aAllColumns.find( xColumn ) != aAllColumns.end() ) { @@ -1903,6 +1904,8 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi if(!xColumn.is()) { // no column found so we could look at the position i + //bReFetchName = sal_True; + //sColumnLabel = ::rtl::OUString(); Reference<XIndexAccess> xIndexAccess(m_xColumns,UNO_QUERY); if(xIndexAccess.is() && i <= xIndexAccess->getCount()) { @@ -1912,7 +1915,9 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi { Sequence< ::rtl::OUString> aSeq = m_xColumns->getElementNames(); if( i <= aSeq.getLength()) + { m_xColumns->getByName(aSeq.getConstArray()[i-1]) >>= xColumn; + } } } if(bReFetchName && xColumn.is()) @@ -1934,16 +1939,15 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi aDescription, m_aCurrentRow); aColumns->get().push_back(pColumn); - if(!sName.getLength()) + if(!sColumnLabel.getLength()) { if(xColumn.is()) - xColumn->getPropertyValue(PROPERTY_NAME) >>= sName; + xColumn->getPropertyValue(PROPERTY_NAME) >>= sColumnLabel; else - sName = ::rtl::OUString::createFromAscii("Expression1"); - // TODO: resource + sColumnLabel = DBACORE_RESSTRING( RID_STR_EXPRESSION1 ); } - pColumn->setName(sName); - aNames.push_back(sName); + pColumn->setName(sColumnLabel); + aNames.push_back(sColumnLabel); m_aDataColumns.push_back(pColumn); if ( xColumn.is() ) @@ -2321,6 +2325,12 @@ sal_Bool ORowSet::impl_buildActiveCommand_throw() { xQuery->getPropertyValue(PROPERTY_COMMAND) >>= sCommand; xQuery->getPropertyValue(PROPERTY_ESCAPE_PROCESSING) >>= bDoEscapeProcessing; + if ( bDoEscapeProcessing != m_bUseEscapeProcessing ) + { + sal_Bool bOldValue = m_bUseEscapeProcessing; + m_bUseEscapeProcessing = bDoEscapeProcessing; + fireProperty(PROPERTY_ID_ESCAPE_PROCESSING,bOldValue,bDoEscapeProcessing); + } ::rtl::OUString aCatalog,aSchema,aTable; xQuery->getPropertyValue(PROPERTY_UPDATE_CATALOGNAME) >>= aCatalog; @@ -2354,8 +2364,7 @@ sal_Bool ORowSet::impl_buildActiveCommand_throw() m_aActiveCommand = sCommand; if ( !m_aActiveCommand.getLength() ) - throwSQLException( "No SQL command was provided.", SQL_FUNCTION_SEQUENCE_ERROR, *this ); - // TODO: resource + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_SQL_COMMAND ), SQL_FUNCTION_SEQUENCE_ERROR, *this ); return bDoEscapeProcessing; } @@ -2657,21 +2666,17 @@ void ORowSet::checkUpdateIterator() void ORowSet::checkUpdateConditions(sal_Int32 columnIndex) { checkCache(); - if ( columnIndex <= 0 ) - throwSQLException( "Invalid column index", SQL_INVALID_DESCRIPTOR_INDEX, *this ); - // TODO: resource + if ( columnIndex <= 0 || sal_Int32((*m_aCurrentRow)->get().size()) <= columnIndex ) + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_INVALID_INDEX ), SQL_INVALID_DESCRIPTOR_INDEX, *this ); + if ( rowDeleted() ) - throwSQLException( "Current row is deleted", SQL_INVALID_CURSOR_POSITION, *this ); - // TODO: resource + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_ROW_ALREADY_DELETED ), SQL_INVALID_CURSOR_POSITION, *this ); + if ( m_aCurrentRow.isNull() ) - throwSQLException( "Invalid cursor state", SQL_INVALID_CURSOR_STATE, *this ); + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_INVALID_CURSOR_STATE ), SQL_INVALID_CURSOR_STATE, *this ); - if ( sal_Int32((*m_aCurrentRow)->get().size()) <= columnIndex ) - throwSQLException( "Invalid column index", SQL_INVALID_DESCRIPTOR_INDEX, *this ); - // TODO: resource if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY) - throwSQLException( "Result set is not writeable", SQL_GENERAL_ERROR, *this ); - // TODO: resource + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_RESULT_IS_READONLY ), SQL_GENERAL_ERROR, *this ); } // ----------------------------------------------------------------------------- void SAL_CALL ORowSet::refreshRow( ) throw(SQLException, RuntimeException) diff --git a/dbaccess/source/core/api/RowSetBase.cxx b/dbaccess/source/core/api/RowSetBase.cxx index d8449094fa85..c5811705570d 100644 --- a/dbaccess/source/core/api/RowSetBase.cxx +++ b/dbaccess/source/core/api/RowSetBase.cxx @@ -30,57 +30,25 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef DBACCESS_CORE_API_ROWSETBASE_HXX + #include "RowSetBase.hxx" -#endif -#ifndef DBACCESS_CORE_API_CROWSETDATACOLUMN_HXX #include "CRowSetDataColumn.hxx" -#endif -#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_ #include <connectivity/sdbcx/VCollection.hxx> -#endif -#ifndef DBACCESS_CORE_API_ROWSETCACHE_HXX #include "RowSetCache.hxx" -#endif -#ifndef DBACCESS_SHARED_DBASTRINGS_HRC #include "dbastrings.hrc" -#endif -#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include "core_resource.hrc" #include <com/sun/star/lang/DisposedException.hpp> -#endif -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ #include <com/sun/star/beans/PropertyAttribute.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_COMPAREBOOKMARK_HPP_ #include <com/sun/star/sdbcx/CompareBookmark.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_ #include <com/sun/star/sdbc/ResultSetConcurrency.hpp> -#endif -#ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_ #include <com/sun/star/lang/Locale.hpp> -#endif -#ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_ #include <com/sun/star/util/NumberFormat.hpp> -#endif -#ifndef _COMPHELPER_SEQUENCE_HXX_ #include <comphelper/sequence.hxx> -#endif -#ifndef _COMPHELPER_EXTRACT_HXX_ #include <comphelper/extract.hxx> -#endif -#ifndef _COMPHELPER_SEQSTREAM_HXX #include <comphelper/seqstream.hxx> -#endif -#ifndef _DBHELPER_DBEXCEPTION_HXX_ #include <connectivity/dbexception.hxx> -#endif -#ifndef _OSL_THREAD_H_ #include <osl/thread.h> -#endif -#ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> -#endif #include <rtl/logfile.hxx> using namespace dbaccess; @@ -278,8 +246,7 @@ const ORowSetValue& ORowSetBase::impl_getValue(sal_Int32 columnIndex) if ( m_bBeforeFirst || m_bAfterLast ) { OSL_ENSURE(0,"ORowSetBase::getValue: Illegal call here (we're before first or after last)!"); - throwSQLException( "The cursor points to before the first or after the last row.", SQL_INVALID_CURSOR_POSITION, *m_pMySelf ); - // TODO: resource + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_CURSOR_BEFORE_OR_AFTER ), SQL_INVALID_CURSOR_POSITION, *m_pMySelf ); } if ( impl_rowDeleted() ) @@ -421,8 +388,7 @@ Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSetBase::getBinaryS if ( m_bBeforeFirst || m_bAfterLast ) { OSL_ENSURE(0,"ORowSetBase::getBinaryStream: Illegal call here (we're before first or after last)!"); - throwSQLException( "The cursor points to before the first or after the last row.", SQL_INVALID_CURSOR_POSITION, *m_pMySelf ); - // TODO: resource + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_CURSOR_BEFORE_OR_AFTER ), SQL_INVALID_CURSOR_POSITION, *m_pMySelf ); } if ( impl_rowDeleted() ) @@ -498,12 +464,10 @@ Any SAL_CALL ORowSetBase::getBookmark( ) throw(SQLException, RuntimeException) checkCache(); if ( m_bBeforeFirst || m_bAfterLast ) - throwSQLException( "The rows before the first and after the last row don't have a bookmark.", SQL_INVALID_CURSOR_POSITION, *m_pMySelf ); - // TODO: resource + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_BOOKMARK_BEFORE_OR_AFTER ), SQL_INVALID_CURSOR_POSITION, *m_pMySelf ); if ( impl_rowDeleted() ) - throwSQLException( "The current row is deleted, and thus doesn't have a bookmark.", SQL_INVALID_CURSOR_POSITION, *m_pMySelf ); - // TODO: resource + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_BOOKMARK_DELETED ), SQL_INVALID_CURSOR_POSITION, *m_pMySelf ); OSL_ENSURE( m_aBookmark.hasValue(), "ORowSetBase::getBookmark: bookmark has no value!" ); return m_aBookmark; diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx index 4156c32635a2..3dd4dad67441 100644 --- a/dbaccess/source/core/api/RowSetCache.cxx +++ b/dbaccess/source/core/api/RowSetCache.cxx @@ -912,7 +912,7 @@ sal_Bool ORowSetCache::moveWindow() { *m_aMatrixIter = new ORowSetValueVector(m_xMetaData->getColumnCount()); m_pCacheSet->fillValueRow(*m_aMatrixIter,m_nPosition); - // we have to read one row forward to enshure that we know when we are on last row + // we have to read one row forward to ensure that we know when we are on last row // but only when we don't know it already if ( !m_bRowCountFinal ) { @@ -1283,7 +1283,9 @@ void ORowSetCache::updateRow( ORowSetMatrix::iterator& _rUpdateRow ) // *(*m_aMatrixIter) = *(*_rUpdateRow); // refetch the whole row (*m_aMatrixIter) = NULL; - moveToBookmark(aBookmark); + + if ( !moveToBookmark(aBookmark) ) + m_aMatrixIter = m_pMatrix->end(); // moveToBookmark((*(*m_aInsertRow))[0].makeAny()); // if(m_pCacheSet->rowUpdated()) diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index 9b8bae551cf1..e302e38fe588 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -37,6 +37,7 @@ #include "dbastrings.hrc" #include "HelperCollections.hxx" #include "SingleSelectQueryComposer.hxx" +#include "sdbcoretools.hxx" /** === begin UNO includes === **/ #include <com/sun/star/beans/PropertyAttribute.hpp> @@ -228,24 +229,11 @@ OSingleSelectQueryComposer::OSingleSelectQueryComposer(const Reference< XNameAcc OSL_ENSURE(m_sDecimalSep.getLength() == 1,"OSingleSelectQueryComposer::OSingleSelectQueryComposer decimal separator is not 1 length"); try { - Reference< XChild> xChild(_xConnection, UNO_QUERY); - if(xChild.is()) + Any aValue; + Reference<XInterface> xDs = dbaccess::getDataSource(_xConnection); + if ( dbtools::getDataSourceSetting(xDs,static_cast <rtl::OUString> (PROPERTY_BOOLEANCOMPARISONMODE),aValue) ) { - Reference< XPropertySet> xProp(xChild->getParent(),UNO_QUERY); - if ( xProp.is() ) - { - Sequence< PropertyValue > aInfo; - xProp->getPropertyValue(PROPERTY_INFO) >>= aInfo; - const PropertyValue* pBegin = aInfo.getConstArray(); - const PropertyValue* pEnd = pBegin + aInfo.getLength(); - for (; pBegin != pEnd; ++pBegin) - { - if ( pBegin->Name == static_cast <rtl::OUString> (PROPERTY_BOOLEANCOMPARISONMODE) ) - { - OSL_VERIFY( pBegin->Value >>= m_nBoolCompareMode ); - } - } - } + OSL_VERIFY( aValue >>= m_nBoolCompareMode ); } } catch(Exception&) @@ -750,9 +738,10 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getColumns( ) thr OSL_ENSURE( (size_t) nCount == aSelectColumns->get().size(), "OSingleSelectQueryComposer::getColumns: inconsistent column counts, this might result in wrong columns!" ); for(sal_Int32 i=1;i<=nCount;++i) { - ::rtl::OUString sName = xResultSetMeta->getColumnName(i); + ::rtl::OUString sColumnName = xResultSetMeta->getColumnName(i); + ::rtl::OUString sColumnLabel = xResultSetMeta->getColumnLabel(i); sal_Bool bFound = sal_False; - OSQLColumns::Vector::const_iterator aFind = ::connectivity::find(aSelectColumns->get().begin(),aSelectColumns->get().end(),sName,aCaseCompare); + OSQLColumns::Vector::const_iterator aFind = ::connectivity::find(aSelectColumns->get().begin(),aSelectColumns->get().end(),sColumnLabel,aCaseCompare); size_t nFoundSelectColumnPos = aFind - aSelectColumns->get().begin(); if ( aFind != aSelectColumns->get().end() ) { @@ -761,7 +750,7 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getColumns( ) thr // so we start after the first found do { - aFind = ::connectivity::findRealName(++aFind,aSelectColumns->get().end(),sName,aCaseCompare); + aFind = ::connectivity::findRealName(++aFind,aSelectColumns->get().end(),sColumnName,aCaseCompare); nFoundSelectColumnPos = aFind - aSelectColumns->get().begin(); } while ( ( aUsedSelectColumns.find( nFoundSelectColumnPos ) != aUsedSelectColumns.end() ) @@ -770,9 +759,9 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getColumns( ) thr } if ( aFind != aSelectColumns->get().end() ) { - (*aFind)->getPropertyValue(PROPERTY_NAME) >>= sName; + (*aFind)->getPropertyValue(PROPERTY_NAME) >>= sColumnName; aUsedSelectColumns.insert( nFoundSelectColumnPos ); - aNames.push_back(sName); + aNames.push_back(sColumnName); bFound = sal_True; } } @@ -781,7 +770,7 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getColumns( ) thr continue; OSQLColumns::Vector::const_iterator aRealFind = ::connectivity::findRealName( - aSelectColumns->get().begin(), aSelectColumns->get().end(), sName, aCaseCompare ); + aSelectColumns->get().begin(), aSelectColumns->get().end(), sColumnName, aCaseCompare ); if ( i > static_cast< sal_Int32>( aSelectColumns->get().size() ) ) { @@ -806,19 +795,19 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getColumns( ) thr ::rtl::OUString sRealName; xProp->getPropertyValue(PROPERTY_REALNAME) >>= sRealName; ::std::vector< ::rtl::OUString>::iterator aFindName; - if ( !sName.getLength() ) - xProp->getPropertyValue(PROPERTY_NAME) >>= sName; + if ( !sColumnName.getLength() ) + xProp->getPropertyValue(PROPERTY_NAME) >>= sColumnName; - aFindName = ::std::find_if(aNames.begin(),aNames.end(),::std::bind2nd(aCaseCompareFunctor,sName)); + aFindName = ::std::find_if(aNames.begin(),aNames.end(),::std::bind2nd(aCaseCompareFunctor,sColumnName)); sal_Int32 j = 0; while ( aFindName != aNames.end() ) { - sName += ::rtl::OUString::valueOf(++j); - aFindName = ::std::find_if(aNames.begin(),aNames.end(),::std::bind2nd(aCaseCompareFunctor,sName)); + sColumnName += ::rtl::OUString::valueOf(++j); + aFindName = ::std::find_if(aNames.begin(),aNames.end(),::std::bind2nd(aCaseCompareFunctor,sColumnName)); } - pColumn->setName(sName); + pColumn->setName(sColumnName); pColumn->setRealName(sRealName); pColumn->setTableName(::comphelper::getString(xProp->getPropertyValue(PROPERTY_TABLENAME))); @@ -828,7 +817,7 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getColumns( ) thr continue; aUsedSelectColumns.insert( (size_t)(i - 1) ); - aNames.push_back( sName ); + aNames.push_back( sColumnName ); } } catch(const Exception&) diff --git a/dbaccess/source/core/api/View.cxx b/dbaccess/source/core/api/View.cxx new file mode 100644 index 000000000000..d7e5221446b0 --- /dev/null +++ b/dbaccess/source/core/api/View.cxx @@ -0,0 +1,151 @@ +/************************************************************************* + * + * 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: View.cxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_dbaccess.hxx" + +#include "View.hxx" +#include "dbastrings.hrc" + +#include "connectivity/dbexception.hxx" +#include "connectivity/dbtools.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/lang/WrappedTargetException.hpp> +#include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/sdbc/XRow.hpp> +/** === end UNO includes === **/ + +#include <cppuhelper/exc_hlp.hxx> +#include <tools/diagnose_ex.h> +#include <unotools/sharedunocomponent.hxx> + +//........................................................................ +namespace dbaccess +{ +//........................................................................ + + /** === begin UNO using === **/ + using namespace ::com::sun::star::uno; + using ::com::sun::star::sdbc::XDatabaseMetaData; + using ::com::sun::star::sdbc::SQLException; + using ::com::sun::star::sdbc::XConnection; + using ::com::sun::star::lang::WrappedTargetException; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::sdbc::XResultSet; + using ::com::sun::star::sdbc::XStatement; + using ::com::sun::star::lang::DisposedException; + using ::com::sun::star::sdbc::XRow; + /** === end UNO using === **/ + + //==================================================================== + //= View + //==================================================================== + //-------------------------------------------------------------------- + View::View( const Reference< XConnection >& _rxConnection, sal_Bool _bCaseSensitive, + const ::rtl::OUString& _rCatalogName,const ::rtl::OUString& _rSchemaName, const ::rtl::OUString& _rName ) + :View_Base( _bCaseSensitive, _rName, _rxConnection->getMetaData(), 0, ::rtl::OUString(), _rSchemaName, _rCatalogName ) + { + m_nCommandHandle = getProperty(PROPERTY_COMMAND).Handle; + try + { + Reference<XMultiServiceFactory> xFac(_rxConnection,UNO_QUERY_THROW); + static const ::rtl::OUString s_sViewSupport(RTL_CONSTASCII_USTRINGPARAM("ViewSupportServiceName")); + m_xViewSupport.set(xFac->createInstance(s_sViewSupport),UNO_QUERY); + } + catch(const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + //-------------------------------------------------------------------- + View::~View() + { + } + + //-------------------------------------------------------------------- + IMPLEMENT_FORWARD_REFCOUNT( View, View_Base ) + IMPLEMENT_GET_IMPLEMENTATION_ID( View ) + // ------------------------------------------------------------------------- + Any SAL_CALL View::queryInterface( const Type & _rType ) throw(RuntimeException) + { + if(_rType == getCppuType( (Reference<XAlterView>*)0) && !m_xViewSupport.is() ) + return Any(); + Any aReturn = View_Base::queryInterface( _rType ); + if ( !aReturn.hasValue() ) + aReturn = View_IBASE::queryInterface( _rType ); + return aReturn; + } + // ------------------------------------------------------------------------- + Sequence< Type > SAL_CALL View::getTypes( ) throw(RuntimeException) + { + Type aAlterType = getCppuType( (Reference<XAlterView>*)0); + + Sequence< Type > aTypes( ::comphelper::concatSequences(View_Base::getTypes(),View_IBASE::getTypes()) ); + ::std::vector<Type> aOwnTypes; + aOwnTypes.reserve(aTypes.getLength()); + + const Type* pIter = aTypes.getConstArray(); + const Type* pEnd = pIter + aTypes.getLength(); + for(;pIter != pEnd ;++pIter) + { + if( (*pIter != aAlterType || m_xViewSupport.is()) ) + aOwnTypes.push_back(*pIter); + } + + Type* pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0]; + return Sequence< Type >(pTypes, aOwnTypes.size()); + } + + //-------------------------------------------------------------------- + void SAL_CALL View::alterCommand( const ::rtl::OUString& _rNewCommand ) throw (SQLException, RuntimeException) + { + OSL_ENSURE(m_xViewSupport.is(),"Illegal call to AlterView!"); + m_xViewSupport->alterCommand(this,_rNewCommand); + } + + //-------------------------------------------------------------------- + void SAL_CALL View::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const + { + if ( _nHandle == m_nCommandHandle && m_xViewSupport.is() ) + { + // retrieve the very current command, don't rely on the base classes cached value + // (which we initialized empty, anyway) + _rValue <<= m_xViewSupport->getCommand(const_cast<View*>(this)); + return; + } + + View_Base::getFastPropertyValue( _rValue, _nHandle ); + } + // ----------------------------------------------------------------------------- +//........................................................................ +} // namespace dbaccess +//........................................................................ diff --git a/dbaccess/source/core/api/column.cxx b/dbaccess/source/core/api/column.cxx index f789394d23f9..89e17d0e3ce4 100644 --- a/dbaccess/source/core/api/column.cxx +++ b/dbaccess/source/core/api/column.cxx @@ -417,7 +417,16 @@ sdbcx::ObjectType OColumns::appendObject( const ::rtl::OUString& _rForName, cons else if ( m_pTable && !m_pTable->isNew() ) { if ( m_bAddColumn ) - xReturn = OColumns_BASE::appendObject( _rForName, descriptor ); + { + Reference< ::com::sun::star::sdb::tools::XTableAlteration> xAlterService = m_pTable->getAlterService(); + if ( xAlterService.is() ) + { + xAlterService->addColumn(m_pTable,descriptor); + xReturn = createObject( _rForName ); + } + else + xReturn = OColumns_BASE::appendObject( _rForName, descriptor ); + } else ::dbtools::throwGenericSQLException( DBA_RES( RID_STR_NO_COLUMN_ADD ), static_cast<XChild*>(static_cast<TXChild*>(this)) ); } @@ -443,7 +452,13 @@ void OColumns::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName) else if ( m_pTable && !m_pTable->isNew() ) { if ( m_bDropColumn ) - OColumns_BASE::dropObject(_nPos,_sElementName); + { + Reference< ::com::sun::star::sdb::tools::XTableAlteration> xAlterService = m_pTable->getAlterService(); + if ( xAlterService.is() ) + xAlterService->dropColumn(m_pTable,_sElementName); + else + OColumns_BASE::dropObject(_nPos,_sElementName); + } else ::dbtools::throwGenericSQLException( DBA_RES( RID_STR_NO_COLUMN_DROP ), static_cast<XChild*>(static_cast<TXChild*>(this)) ); } diff --git a/dbaccess/source/core/api/definitioncolumn.cxx b/dbaccess/source/core/api/definitioncolumn.cxx index 9f9e511fc9b4..77a29812b105 100644 --- a/dbaccess/source/core/api/definitioncolumn.cxx +++ b/dbaccess/source/core/api/definitioncolumn.cxx @@ -192,7 +192,7 @@ rtl::OUString OTableColumn::getImplementationName( ) throw (RuntimeException) DBG_NAME( OQueryColumn ); // ------------------------------------------------------------------------- -OQueryColumn::OQueryColumn( const Reference< XPropertySet >& _rxParserColumn, const Reference< XConnection >& _rxConnection ) +OQueryColumn::OQueryColumn( const Reference< XPropertySet >& _rxParserColumn, const Reference< XConnection >& _rxConnection,const ::rtl::OUString& _sNewName ) :OTableColumnDescriptor( false /* do not act as descriptor */ ) { const sal_Int32 nPropAttr = PropertyAttribute::READONLY; @@ -210,7 +210,14 @@ OQueryColumn::OQueryColumn( const Reference< XPropertySet >& _rxParserColumn, co OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_TYPE ) >>= m_nType ); OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_ISAUTOINCREMENT ) >>= m_bAutoIncrement ); OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_ISCURRENCY ) >>= m_bCurrency ); - OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_NAME ) >>= m_sName ); + if ( _sNewName.getLength() ) + { + m_sName = _sNewName; + } + else + { + OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_NAME ) >>= m_sName ); + } m_bRowVersion = sal_False; Reference< XPropertySetInfo > xPSI( _rxParserColumn->getPropertySetInfo(), UNO_SET_THROW ); diff --git a/dbaccess/source/core/api/makefile.mk b/dbaccess/source/core/api/makefile.mk index f983db38b640..df80f0423e14 100644 --- a/dbaccess/source/core/api/makefile.mk +++ b/dbaccess/source/core/api/makefile.mk @@ -74,6 +74,7 @@ SLOFILES= \ $(SLO)$/SingleSelectQueryComposer.obj \ $(SLO)$/HelperCollections.obj \ $(SLO)$/datasettings.obj \ + $(SLO)$/View.obj \ $(SLO)$/columnsettings.obj # --- Targets ---------------------------------- diff --git a/dbaccess/source/core/api/query.cxx b/dbaccess/source/core/api/query.cxx index 7468e88f4fff..3f3ccc57db2e 100644 --- a/dbaccess/source/core/api/query.cxx +++ b/dbaccess/source/core/api/query.cxx @@ -191,9 +191,10 @@ void OQuery::rebuildColumns() m_pColumnMediator = NULL; Reference<XColumnsSupplier> xColSup(m_xCommandDefinition,UNO_QUERY); + Reference< XNameAccess > xColumnDefinitions; if ( xColSup.is() ) { - Reference< XNameAccess > xColumnDefinitions = xColSup->getColumns(); + xColumnDefinitions = xColSup->getColumns(); if ( xColumnDefinitions.is() ) m_pColumnMediator = new OContainerMediator( m_pColumns, xColumnDefinitions, m_xConnection, OContainerMediator::eColumns ); } @@ -236,19 +237,29 @@ void OQuery::rebuildColumns() } Sequence< ::rtl::OUString> aNames = xColumns->getElementNames(); - const ::rtl::OUString* pBegin = aNames.getConstArray(); - const ::rtl::OUString* pEnd = pBegin + aNames.getLength(); - for ( ;pBegin != pEnd; ++pBegin) + Sequence< ::rtl::OUString> aDefintionNames; + bool bApplyDefinitionNames = false; + //if ( xColumnDefinitions.is() ) + //{ + // aDefintionNames = xColumnDefinitions->getElementNames(); + // bApplyDefinitionNames = aDefintionNames.getLength() == aNames.getLength(); + //} + + ::rtl::OUString sEmpty; + const ::rtl::OUString* pIter = aNames.getConstArray(); + const ::rtl::OUString* pEnd = pIter + aNames.getLength(); + for ( sal_Int32 i = 0;pIter != pEnd; ++pIter,++i) { - Reference<XPropertySet> xSource(xColumns->getByName( *pBegin ),UNO_QUERY); - OQueryColumn* pColumn = new OQueryColumn( xSource, m_xConnection ); + Reference<XPropertySet> xSource(xColumns->getByName( *pIter ),UNO_QUERY); + OQueryColumn* pColumn = new OQueryColumn( xSource, m_xConnection, bApplyDefinitionNames ? aDefintionNames[i] : sEmpty); Reference< XChild > xChild( *pColumn, UNO_QUERY_THROW ); xChild->setParent( *this ); - implAppendColumn( *pBegin, pColumn ); + ::rtl::OUString sNewName = bApplyDefinitionNames ? aDefintionNames[i] : *pIter; + implAppendColumn( sNewName, pColumn ); Reference< XPropertySet > xDest( *pColumn, UNO_QUERY_THROW ); if ( m_pColumnMediator.is() ) - m_pColumnMediator->notifyElementCreated( *pBegin, xDest ); + m_pColumnMediator->notifyElementCreated( sNewName, xDest ); } } catch( const SQLContext& e ) diff --git a/dbaccess/source/core/api/resultcolumn.cxx b/dbaccess/source/core/api/resultcolumn.cxx index 33cc93b02994..1f9d1938caf8 100644 --- a/dbaccess/source/core/api/resultcolumn.cxx +++ b/dbaccess/source/core/api/resultcolumn.cxx @@ -110,20 +110,26 @@ void OResultColumn::impl_determineIsRowVersion_nothrow() getPropertyValue( PROPERTY_TABLENAME ) >>= sTable; getPropertyValue( PROPERTY_NAME ) >>= sColumnName; - Reference< XResultSet > xVersionColumns = m_xDBMetaData->getVersionColumns( - makeAny( sCatalog ), sSchema, sTable ); - if ( xVersionColumns.is() ) // allowed to be NULL + try { - Reference< XRow > xResultRow( xVersionColumns, UNO_QUERY_THROW ); - while ( xVersionColumns->next() ) + Reference< XResultSet > xVersionColumns = m_xDBMetaData->getVersionColumns( + makeAny( sCatalog ), sSchema, sTable ); + if ( xVersionColumns.is() ) // allowed to be NULL { - if ( xResultRow->getString( 2 ) == sColumnName ) + Reference< XRow > xResultRow( xVersionColumns, UNO_QUERY_THROW ); + while ( xVersionColumns->next() ) { - m_aIsRowVersion <<= (sal_Bool)(sal_True); - break; + if ( xResultRow->getString( 2 ) == sColumnName ) + { + m_aIsRowVersion <<= (sal_Bool)(sal_True); + break; + } } } } + catch(const SQLException&) + { + } } catch( const Exception& ) { diff --git a/dbaccess/source/core/api/table.cxx b/dbaccess/source/core/api/table.cxx index 301038903b97..d88537fb72f8 100644 --- a/dbaccess/source/core/api/table.cxx +++ b/dbaccess/source/core/api/table.cxx @@ -31,77 +31,33 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef _DBA_CORE_TABLE_HXX_ #include "table.hxx" -#endif -#ifndef _DBACORE_DEFINITIONCOLUMN_HXX_ #include <definitioncolumn.hxx> -#endif -#ifndef DBACCESS_SHARED_DBASTRINGS_HRC #include "dbastrings.hrc" -#endif -#ifndef _DBA_CORE_RESOURCE_HXX_ #include "core_resource.hxx" -#endif -#ifndef _DBA_CORE_RESOURCE_HRC_ #include "core_resource.hrc" -#endif -#ifndef _TOOLS_DEBUG_HXX -#include <tools/debug.hxx> -#endif +#include "CIndexes.hxx" -#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <tools/debug.hxx> #include <cppuhelper/typeprovider.hxx> -#endif -#ifndef _COMPHELPER_ENUMHELPER_HXX_ #include <comphelper/enumhelper.hxx> -#endif -#ifndef _COMPHELPER_CONTAINER_HXX_ #include <comphelper/container.hxx> -#endif -#ifndef _COMPHELPER_SEQUENCE_HXX_ #include <comphelper/sequence.hxx> -#endif -#ifndef _COMPHELPER_TYPES_HXX_ #include <comphelper/types.hxx> -#endif -#ifndef _COM_SUN_STAR_UTIL_XREFRESHLISTENER_HPP_ +//#include <comphelper/extract.hxx> #include <com/sun/star/util/XRefreshListener.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ #include <com/sun/star/sdbc/XConnection.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ #include <com/sun/star/sdbc/XRow.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_ #include <com/sun/star/sdbcx/Privilege.hpp> -#endif +#include <com/sun/star/sdbc/XResultSetMetaData.hpp> +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> + #include <connectivity/TKeys.hxx> -#ifndef DBACCESS_INDEXES_HXX_ -#include "CIndexes.hxx" -#endif -#ifndef _CONNECTIVITY_DBTOOLS_HXX_ #include <connectivity/dbtools.hxx> -#endif -#ifndef _DBHELPER_DBEXCEPTION_HXX_ #include <connectivity/dbexception.hxx> -#endif -#ifndef _COMPHELPER_EXTRACT_HXX_ -#include <comphelper/extract.hxx> -#endif -#ifndef DBACORE_SDBCORETOOLS_HXX + #include "sdbcoretools.hxx" -#endif -#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATA_HPP_ -#include <com/sun/star/sdbc/XResultSetMetaData.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_ -#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> -#endif -#ifndef DBA_CONTAINERMEDIATOR_HXX #include "ContainerMediator.hxx" -#endif #include <rtl/logfile.hxx> using namespace dbaccess; @@ -152,6 +108,7 @@ ODBTable::ODBTable(connectivity::sdbcx::OCollection* _pTables :OTable_Base(_pTables,_rxConn, _rxConn->getMetaData().is() && _rxConn->getMetaData()->supportsMixedCaseQuotedIdentifiers()) ,m_nPrivileges(-1) { + DBG_CTOR(ODBTable, NULL); RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::ODBTable" ); } // ------------------------------------------------------------------------- @@ -311,18 +268,18 @@ void ODBTable::construct() describeProperties(aProps); if(!_nId) { - Property* pBegin = aProps.getArray(); - Property* pEnd = pBegin + aProps.getLength(); - for(;pBegin != pEnd;++pBegin) + Property* pIter = aProps.getArray(); + Property* pEnd = pIter + aProps.getLength(); + for(;pIter != pEnd;++pIter) { - if (0 == pBegin->Name.compareToAscii(PROPERTY_CATALOGNAME)) - pBegin->Attributes = PropertyAttribute::READONLY; - else if (0 == pBegin->Name.compareToAscii(PROPERTY_SCHEMANAME)) - pBegin->Attributes = PropertyAttribute::READONLY; - else if (0 == pBegin->Name.compareToAscii(PROPERTY_DESCRIPTION)) - pBegin->Attributes = PropertyAttribute::READONLY; - else if (0 == pBegin->Name.compareToAscii(PROPERTY_NAME)) - pBegin->Attributes = PropertyAttribute::READONLY; + if (0 == pIter->Name.compareToAscii(PROPERTY_CATALOGNAME)) + pIter->Attributes = PropertyAttribute::READONLY; + else if (0 == pIter->Name.compareToAscii(PROPERTY_SCHEMANAME)) + pIter->Attributes = PropertyAttribute::READONLY; + else if (0 == pIter->Name.compareToAscii(PROPERTY_DESCRIPTION)) + pIter->Attributes = PropertyAttribute::READONLY; + else if (0 == pIter->Name.compareToAscii(PROPERTY_NAME)) + pIter->Attributes = PropertyAttribute::READONLY; } } @@ -340,14 +297,11 @@ IMPLEMENT_SERVICE_INFO1(ODBTable, "com.sun.star.sdb.dbaccess.ODBTable", SERVICE_ Any SAL_CALL ODBTable::queryInterface( const Type & rType ) throw(RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::getInfoHelper" ); - Any aRet; - if(rType == getCppuType( (Reference<XRename>*)0)) + if(rType == getCppuType( (Reference<XRename>*)0) && !getRenameService().is() ) return Any(); - if(rType == getCppuType( (Reference<XAlterTable>*)0)) + if(rType == getCppuType( (Reference<XAlterTable>*)0) && !getAlterService().is() ) return Any(); - aRet = OTable_Base::queryInterface( rType); - - return aRet; + return OTable_Base::queryInterface( rType); } // ------------------------------------------------------------------------- Sequence< Type > SAL_CALL ODBTable::getTypes( ) throw(RuntimeException) @@ -360,12 +314,12 @@ Sequence< Type > SAL_CALL ODBTable::getTypes( ) throw(RuntimeException) ::std::vector<Type> aOwnTypes; aOwnTypes.reserve(aTypes.getLength()); - const Type* pBegin = aTypes.getConstArray(); - const Type* pEnd = pBegin + aTypes.getLength(); - for(;pBegin != pEnd ;++pBegin) + const Type* pIter = aTypes.getConstArray(); + const Type* pEnd = pIter + aTypes.getLength(); + for(;pIter != pEnd ;++pIter) { - if(*pBegin != aRenameType && *pBegin != aAlterType) - aOwnTypes.push_back(*pBegin); + if( (*pIter != aRenameType || getRenameService().is()) && (*pIter != aAlterType || getAlterService().is())) + aOwnTypes.push_back(*pIter); } Type* pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0]; @@ -373,10 +327,17 @@ Sequence< Type > SAL_CALL ODBTable::getTypes( ) throw(RuntimeException) } // XRename, //------------------------------------------------------------------------------ -void SAL_CALL ODBTable::rename( const ::rtl::OUString& /*_rNewName*/ ) throw(SQLException, ElementExistException, RuntimeException) +void SAL_CALL ODBTable::rename( const ::rtl::OUString& _rNewName ) throw(SQLException, ElementExistException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::rename" ); - throw SQLException(DBACORE_RESSTRING(RID_STR_NO_TABLE_RENAME),*this,SQLSTATE_GENERAL,1000,Any() ); + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed(connectivity::sdbcx::OTableDescriptor_BASE::rBHelper.bDisposed); + if ( !getRenameService().is() ) + throw SQLException(DBACORE_RESSTRING(RID_STR_NO_TABLE_RENAME),*this,SQLSTATE_GENERAL,1000,Any() ); + + Reference<XPropertySet> xTable(this); + getRenameService()->rename(xTable,_rNewName); + ::connectivity::OTable_TYPEDEF::rename(_rNewName); } // XAlterTable, @@ -385,55 +346,15 @@ void SAL_CALL ODBTable::alterColumnByName( const ::rtl::OUString& _rName, const { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::alterColumnByName" ); ::osl::MutexGuard aGuard(m_aMutex); - checkDisposed( - connectivity::sdbcx::OTableDescriptor_BASE::rBHelper.bDisposed); - if(m_pColumns->hasByName(_rName)) - { - ::rtl::OUString sSql = ::rtl::OUString::createFromAscii("ALTER TABLE "); - ::rtl::OUString aQuote; - Reference<XDatabaseMetaData> xMeta = getMetaData(); - if ( xMeta.is() ) - aQuote = xMeta->getIdentifierQuoteString( ); - ::rtl::OUString sComposedName; - - sComposedName = ::dbtools::composeTableName( xMeta, m_CatalogName, m_SchemaName, m_Name, sal_True, ::dbtools::eInTableDefinitions ); - if(!sComposedName.getLength()) - ::dbtools::throwFunctionSequenceException(*this); - - sSql += sComposedName; - sSql += ::rtl::OUString::createFromAscii(" ALTER "); - sSql += ::dbtools::quoteName(aQuote,_rName); - - ::rtl::OUString sNewDefaultValue,sDefaultValue; - - Reference<XPropertySet> xColumn; - m_pColumns->getByName(_rName) >>= xColumn; - if(_rxDescriptor->getPropertySetInfo()->hasPropertyByName(PROPERTY_DEFAULTVALUE)) - _rxDescriptor->getPropertyValue(PROPERTY_DEFAULTVALUE) >>= sNewDefaultValue; - if(xColumn.is() && xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_DEFAULTVALUE)) - xColumn->getPropertyValue(PROPERTY_DEFAULTVALUE) >>= sDefaultValue; - - if(sNewDefaultValue != sDefaultValue && getMetaData().is() ) - { - if(sNewDefaultValue.getLength()) - { - sSql += ::rtl::OUString::createFromAscii(" SET DEFAULT "); - sSql += sNewDefaultValue; - } - else - sSql += ::rtl::OUString::createFromAscii(" DROP DEFAULT"); - OSL_ENSURE(getMetaData()->getConnection().is(),"Connection is null!"); - Reference< XStatement > xStmt = getMetaData()->getConnection()->createStatement( ); - if(xStmt.is()) - xStmt->execute(sSql); - } - else - // not supported - throw SQLException(DBACORE_RESSTRING(RID_STR_NO_ALTER_COLUMN_DEF),*this,SQLSTATE_GENERAL,1000,Any() ); - } - else - // not supported - throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_ALTER_BY_NAME),*this,SQLSTATE_GENERAL,1000,Any() ); + checkDisposed(connectivity::sdbcx::OTableDescriptor_BASE::rBHelper.bDisposed); + if ( !getAlterService().is() ) + throw SQLException(DBACORE_RESSTRING(RID_STR_NO_TABLE_RENAME),*this,SQLSTATE_GENERAL,1000,Any() ); + + if ( !m_pColumns->hasByName(_rName) ) + throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_NOT_VALID),*this,SQLSTATE_GENERAL,1000,Any() ); + + Reference<XPropertySet> xTable(this); + getAlterService()->alterColumnByName(xTable,_rName,_rxDescriptor); m_pColumns->refresh(); } // ----------------------------------------------------------------------------- @@ -476,8 +397,8 @@ sdbcx::OCollection* ODBTable::createColumns(const TStringVector& _rNames) RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::createColumns" ); Reference<XDatabaseMetaData> xMeta = getMetaData(); OColumns* pCol = new OColumns(*this, m_aMutex, NULL, isCaseSensitive(), _rNames, this,this, - xMeta.is() && xMeta->supportsAlterTableWithAddColumn(), - xMeta.is() && xMeta->supportsAlterTableWithDropColumn()); + getAlterService().is() || (xMeta.is() && xMeta->supportsAlterTableWithAddColumn()), + getAlterService().is() || (xMeta.is() && xMeta->supportsAlterTableWithDropColumn())); static_cast<OColumnsHelper*>(pCol)->setParent(this); pCol->setParent(*this); m_pColumnMediator = new OContainerMediator( pCol, m_xColumnDefinitions, getConnection(), OContainerMediator::eColumns ); @@ -497,7 +418,3 @@ sdbcx::OCollection* ODBTable::createIndexes(const TStringVector& _rNames) return new OIndexes(this,m_aMutex,_rNames,NULL); } // ----------------------------------------------------------------------------- - - - - diff --git a/dbaccess/source/core/api/viewcontainer.cxx b/dbaccess/source/core/api/viewcontainer.cxx index 342d68eea0ba..4f57aa29b4ec 100644 --- a/dbaccess/source/core/api/viewcontainer.cxx +++ b/dbaccess/source/core/api/viewcontainer.cxx @@ -31,74 +31,30 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef _DBA_CORE_VIEWCONTAINER_HXX_ #include "viewcontainer.hxx" -#endif -#ifndef DBACCESS_SHARED_DBASTRINGS_HRC #include "dbastrings.hrc" -#endif -#ifndef _TOOLS_DEBUG_HXX +#include "core_resource.hxx" +#include "core_resource.hrc" +#include "View.hxx" + #include <tools/debug.hxx> -#endif -#ifndef _WLDCRD_HXX #include <tools/wldcrd.hxx> -#endif -#ifndef _COMPHELPER_ENUMHELPER_HXX_ #include <comphelper/enumhelper.hxx> -#endif -#ifndef _DBA_CORE_RESOURCE_HXX_ -#include "core_resource.hxx" -#endif -#ifndef _DBA_CORE_RESOURCE_HRC_ -#include "core_resource.hrc" -#endif +#include <comphelper/types.hxx> +#include <connectivity/dbtools.hxx> +#include <comphelper/extract.hxx> +#include <connectivity/dbexception.hxx> +#include <rtl/ustrbuf.hxx> -#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ #include <com/sun/star/beans/XPropertySet.hpp> -#endif - -#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ #include <com/sun/star/sdbc/XConnection.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ #include <com/sun/star/sdbc/XDatabaseMetaData.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ -#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ -#include <com/sun/star/sdbcx/XTablesSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_KEYRULE_HPP_ #include <com/sun/star/sdbc/KeyRule.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_ -#include <com/sun/star/sdbcx/KeyType.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ #include <com/sun/star/sdbc/ColumnValue.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ #include <com/sun/star/sdbc/XRow.hpp> -#endif -#ifndef _COMPHELPER_TYPES_HXX_ -#include <comphelper/types.hxx> -#endif -#ifndef _CONNECTIVITY_DBTOOLS_HXX_ -#include <connectivity/dbtools.hxx> -#endif -#ifndef _COMPHELPER_EXTRACT_HXX_ -#include <comphelper/extract.hxx> -#endif -#ifndef _DBHELPER_DBEXCEPTION_HXX_ -#include <connectivity/dbexception.hxx> -#endif -#ifndef _CONNECTIVITY_SDBCX_VIEW_HXX_ -#include <connectivity/sdbcx/VView.hxx> -#endif -#ifndef _RTL_USTRBUF_HXX_ -#include <rtl/ustrbuf.hxx> -#endif +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#include <com/sun/star/sdbcx/KeyType.hpp> using namespace dbaccess; using namespace dbtools; @@ -159,14 +115,12 @@ ObjectType OViewContainer::createObject(const ::rtl::OUString& _rName) sSchema, sTable, ::dbtools::eInDataManipulation); - return new ::connectivity::sdbcx::OView(isCaseSensitive(), - sTable, - m_xMetaData, - 0, - ::rtl::OUString(), - sSchema, - sCatalog - ); + return new View(m_xConnection, + isCaseSensitive(), + sCatalog, + sSchema, + sTable + ); } return xProp; diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx index fef47f68145a..5abf774e1d92 100644 --- a/dbaccess/source/core/dataaccess/ModelImpl.cxx +++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx @@ -1183,6 +1183,17 @@ const AsciiPropertyValue* ODatabaseModelImpl::getDefaultDataSourceSettings() AsciiPropertyValue( "FormsCheckRequiredFields", makeAny( (sal_Bool)sal_True ) ), AsciiPropertyValue( "EscapeDateTime", makeAny( (sal_Bool)sal_True ) ), + // known services to handle database tasks + AsciiPropertyValue( "TableAlterationServiceName", makeAny( ::rtl::OUString() ) ), + AsciiPropertyValue( "TableRenameServiceName", makeAny( ::rtl::OUString() ) ), + AsciiPropertyValue( "ViewAlterationServiceName", makeAny( ::rtl::OUString() ) ), + AsciiPropertyValue( "ViewSupportServiceName", makeAny( ::rtl::OUString() ) ), + AsciiPropertyValue( "CommandDefinitionSupplier", makeAny( ::rtl::OUString() ) ), + AsciiPropertyValue( "FormSupplier", makeAny( ::rtl::OUString() ) ), + AsciiPropertyValue( "ReportSupplier", makeAny( ::rtl::OUString() ) ), + AsciiPropertyValue( "KeyAlterationServiceName", makeAny( ::rtl::OUString() ) ), + AsciiPropertyValue( "IndexAlterationServiceName", makeAny( ::rtl::OUString() ) ), + AsciiPropertyValue() }; return aKnownSettings; diff --git a/dbaccess/source/core/dataaccess/connection.cxx b/dbaccess/source/core/dataaccess/connection.cxx index 8fb40fc63b1f..41ae7e0e0b25 100644 --- a/dbaccess/source/core/dataaccess/connection.cxx +++ b/dbaccess/source/core/dataaccess/connection.cxx @@ -42,6 +42,7 @@ #include "ContainerMediator.hxx" #include "SingleSelectQueryComposer.hxx" #include "querycomposer.hxx" +#include "sdbcoretools.hxx" /** === begin UNO includes === **/ #include <com/sun/star/sdb/CommandType.hpp> @@ -601,13 +602,25 @@ Reference< XSQLQueryComposer > OConnection::createQueryComposer(void) throw( Ru return xComposer; } // ----------------------------------------------------------------------------- +void OConnection::impl_fillTableFilter() +{ + Reference<XPropertySet> xProp(getParent(),UNO_QUERY); + if ( xProp.is() ) + { + xProp->getPropertyValue(PROPERTY_TABLEFILTER) >>= m_aTableFilter; + xProp->getPropertyValue(PROPERTY_TABLETYPEFILTER) >>= m_aTableTypeFilter; + } +} + +// ----------------------------------------------------------------------------- void OConnection::refresh(const Reference< XNameAccess >& _rToBeRefreshed) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "OConnection::refresh" ); if ( _rToBeRefreshed == Reference< XNameAccess >(m_pTables) ) { - if (!m_pTables->isInitialized()) + if (m_pTables && !m_pTables->isInitialized()) { + impl_fillTableFilter(); // check if our "master connection" can supply tables getMasterTables(); @@ -623,8 +636,9 @@ void OConnection::refresh(const Reference< XNameAccess >& _rToBeRefreshed) } else if ( _rToBeRefreshed == Reference< XNameAccess >(m_pViews) ) { - if (!m_pViews->isInitialized()) + if (m_pViews && !m_pViews->isInitialized()) { + impl_fillTableFilter(); // check if our "master connection" can supply tables Reference< XViewsSupplier > xMaster(getMasterTables(),UNO_QUERY); @@ -716,6 +730,28 @@ Reference< XInterface > SAL_CALL OConnection::createInstance( const ::rtl::OUStr xRet = new OSingleSelectQueryComposer( getTables(),this, m_aContext ); m_aComposers.push_back(WeakReferenceHelper(xRet)); } + else + { + Reference<XInterface> xDs = dbaccess::getDataSource(*this); + Any aValue; + if ( dbtools::getDataSourceSetting(xDs,_sServiceSpecifier,aValue) ) + { + ::rtl::OUString sSupportService; + aValue >>= sSupportService; + if ( sSupportService.getLength() ) + { + TSupportServices::iterator aFind = m_aSupportServices.find(sSupportService); + if ( aFind == m_aSupportServices.end()) + { + Sequence<Any> aArgs(1); + Reference<XConnection> xMy(this); + aArgs[0] <<= NamedValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ActiveConnection")),makeAny(xMy)); + aFind = m_aSupportServices.insert(TSupportServices::value_type(sSupportService,m_aContext.createComponentWithArguments(sSupportService,aArgs))).first; + } + return aFind->second; + } + } + } return Reference< XInterface >(xRet,UNO_QUERY); } // ----------------------------------------------------------------------------- diff --git a/dbaccess/source/core/dataaccess/connection.hxx b/dbaccess/source/core/dataaccess/connection.hxx index e8a8a2ca9135..98b8535953db 100644 --- a/dbaccess/source/core/dataaccess/connection.hxx +++ b/dbaccess/source/core/dataaccess/connection.hxx @@ -30,62 +30,25 @@ #ifndef _DBA_CORE_CONNECTION_HXX_ #define _DBA_CORE_CONNECTION_HXX_ -#ifndef _DBASHARED_APITOOLS_HXX_ #include "apitools.hxx" -#endif -#ifndef _DBA_CORE_QUERYCONTAINER_HXX_ #include "querycontainer.hxx" -#endif -#ifndef _DBA_CORE_TABLECONTAINER_HXX_ #include "tablecontainer.hxx" -#endif -#ifndef _DBA_CORE_VIEWCONTAINER_HXX_ #include "viewcontainer.hxx" -#endif -#ifndef DBA_CORE_REFRESHLISTENER_HXX #include "RefreshListener.hxx" -#endif -#ifndef DBTOOLS_WARNINGSCONTAINER_HXX -#include <connectivity/warningscontainer.hxx> -#endif /** === begin UNO includes === **/ -#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ #include <com/sun/star/container/XChild.hpp> -#endif -#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ #include <com/sun/star/lang/DisposedException.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_ #include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XCOMMANDPREPARATION_HPP_ #include <com/sun/star/sdb/XCommandPreparation.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XTablesSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XViewsSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XUSERSSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XUsersSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XGROUPSSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XGroupsSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_ #include <com/sun/star/sdb/XQueriesSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ #include <com/sun/star/lang/XMultiServiceFactory.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_TOOLS_XCONNECTIONTOOLS_HPP_ #include <com/sun/star/sdb/tools/XConnectionTools.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_APPLICATION_XTABLEUIPROVIDER_HPP_ #include <com/sun/star/sdb/application/XTableUIProvider.hpp> -#endif /** === end UNO includes === **/ #if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_14) @@ -93,14 +56,10 @@ #define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 14 #include <comphelper/implbase_var.hxx> #endif - -#ifndef COMPHELPER_COMPONENTCONTEXT_HXX #include <comphelper/componentcontext.hxx> -#endif - -#ifndef _CONNECTIVITY_CONNECTIONWRAPPER_HXX_ +#include <comphelper/stl_types.hxx> #include <connectivity/ConnectionWrapper.hxx> -#endif +#include <connectivity/warningscontainer.hxx> //........................................................................ namespace dbaccess @@ -151,6 +110,11 @@ protected: ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XConnectionTools > m_xConnectionTools; ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XTableUIProvider > m_xTableUIProvider; + // defines the helper services for example to query the command of a view + // @ see com.sun.star.sdb.tools.XViewSupport + DECLARE_STL_USTRINGACCESS_MAP( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>, TSupportServices); + TSupportServices m_aSupportServices; + OTableContainer* m_pTables; OViewContainer* m_pViews; @@ -276,6 +240,10 @@ private: m_xConnectionTools is nol <NULL/> */ void impl_loadConnectionTools_throw(); + + /** reads the table filter and table type filter from the datasourfce + */ + void impl_fillTableFilter(); }; //........................................................................ diff --git a/dbaccess/source/core/dataaccess/databasecontext.cxx b/dbaccess/source/core/dataaccess/databasecontext.cxx index 8a7ff1b1595c..141c8cdc2448 100644 --- a/dbaccess/source/core/dataaccess/databasecontext.cxx +++ b/dbaccess/source/core/dataaccess/databasecontext.cxx @@ -553,8 +553,6 @@ void ODatabaseContext::revokeObject(const rtl::OUString& _rName) throw( Exceptio if ( m_aDatabaseObjects.find( _rName ) != m_aDatabaseObjects.end() ) { - OSL_ENSURE( false, "ODatabaseContext::revokeObject: a database document register by name? This shouldn't happen anymore!" ); - // all the code should have been changed so that registration is by URL only m_aDatasourceProperties[ sURL ] = m_aDatasourceProperties[ _rName ]; } diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx index 37a68f058e3a..ff57b3a82b06 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.cxx +++ b/dbaccess/source/core/dataaccess/databasedocument.cxx @@ -74,6 +74,13 @@ #include <comphelper/numberedcollection.hxx> #include <comphelper/property.hxx> #include <comphelper/storagehelper.hxx> +#include <comphelper/genericpropertyset.hxx> +#include <comphelper/property.hxx> + +#include <connectivity/dbtools.hxx> + +#include <svtools/saveopt.hxx> + #include <cppuhelper/exc_hlp.hxx> #include <framework/titlehelper.hxx> #include <unotools/saveopt.hxx> @@ -1148,8 +1155,25 @@ Reference< XNameAccess > ODatabaseDocument::impl_getDocumentContainer_throw( ODa Reference< XNameAccess > xContainer = rContainerRef; if ( !xContainer.is() ) { - TContentPtr& rContainerData( m_pImpl->getObjectContainer( _eType ) ); - rContainerRef = xContainer = new ODocumentContainer( m_pImpl->m_aContext.getLegacyServiceFactory(), *this, rContainerData, bFormsContainer ); + Any aValue; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xMy(*this); + if ( dbtools::getDataSourceSetting(xMy,bFormsContainer ? "FormSupplier" : "ReportSupplier",aValue) ) + { + ::rtl::OUString sSupportService; + aValue >>= sSupportService; + if ( sSupportService.getLength() ) + { + Sequence<Any> aArgs(1); + aArgs[0] <<= NamedValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataSource")),makeAny(xMy)); + xContainer.set(m_pImpl->m_aContext.createComponentWithArguments(sSupportService,aArgs),UNO_QUERY); + rContainerRef = xContainer; + } + } + if ( !xContainer.is() ) + { + TContentPtr& rContainerData( m_pImpl->getObjectContainer( _eType ) ); + rContainerRef = xContainer = new ODocumentContainer( m_pImpl->m_aContext.getLegacyServiceFactory(), *this, rContainerData, bFormsContainer ); + } impl_reparent_nothrow( xContainer ); } return xContainer; @@ -1613,8 +1637,7 @@ void SAL_CALL ODatabaseDocument::loadFromStorage( const Reference< XStorage >& / DocumentGuard aGuard( *this ); throw Exception( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Embedding of database documents is not supported." ) ), - // TODO: resource + DBACORE_RESSTRING( RID_STR_NO_EMBEDDING ), *this ); } diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx index e0d3f10aed8d..f0cca707fc3b 100644 --- a/dbaccess/source/core/dataaccess/datasource.cxx +++ b/dbaccess/source/core/dataaccess/datasource.cxx @@ -42,6 +42,7 @@ #include "SharedConnection.hxx" #include "databasedocument.hxx" + /** === begin UNO includes === **/ #include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> @@ -68,9 +69,10 @@ #include <comphelper/property.hxx> #include <comphelper/seqstream.hxx> #include <comphelper/sequence.hxx> +#include <comphelper/string.hxx> #include <connectivity/dbexception.hxx> +#include <connectivity/dbtools.hxx> #include <cppuhelper/typeprovider.hxx> -#include <rtl/digest.h> #include <tools/debug.hxx> #include <tools/diagnose_ex.h> #include <tools/urlobj.hxx> @@ -78,6 +80,7 @@ #include <unotools/confignode.hxx> #include <unotools/sharedunocomponent.hxx> #include <rtl/logfile.hxx> +#include <rtl/digest.h> #include <algorithm> using namespace ::com::sun::star::sdbc; @@ -815,9 +818,8 @@ Reference< XConnection > ODatabaseSource::buildLowLevelConnection(const ::rtl::O ::rtl::OUString sMessage = DBACORE_RESSTRING( nExceptionMessageId ); SQLContext aContext; - aContext.Message = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "A connection for the following URL was requested: " ) ); - // TODO: resource - aContext.Message += m_pImpl->m_sConnectURL; + aContext.Message = DBACORE_RESSTRING( RID_STR_CONNECTION_REQUEST ); + ::comphelper::string::searchAndReplaceAsciiI( aContext.Message, "$name$", m_pImpl->m_sConnectURL ); throwGenericSQLException( sMessage, static_cast< XDataSource* >( this ), makeAny( aContext ) ); } @@ -1340,8 +1342,24 @@ Reference< XNameAccess > SAL_CALL ODatabaseSource::getQueryDefinitions( ) throw( Reference< XNameAccess > xContainer = m_pImpl->m_xCommandDefinitions; if ( !xContainer.is() ) { - TContentPtr& rContainerData( m_pImpl->getObjectContainer( ODatabaseModelImpl::E_QUERY ) ); - xContainer = new OCommandContainer( m_pImpl->m_aContext.getLegacyServiceFactory(), *this, rContainerData, sal_False ); + Any aValue; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xMy(*this); + if ( dbtools::getDataSourceSetting(xMy,"CommandDefinitionSupplier",aValue) ) + { + ::rtl::OUString sSupportService; + aValue >>= sSupportService; + if ( sSupportService.getLength() ) + { + Sequence<Any> aArgs(1); + aArgs[0] <<= NamedValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataSource")),makeAny(xMy)); + xContainer.set(m_pImpl->m_aContext.createComponentWithArguments(sSupportService,aArgs),UNO_QUERY); + } + } + if ( !xContainer.is() ) + { + TContentPtr& rContainerData( m_pImpl->getObjectContainer( ODatabaseModelImpl::E_QUERY ) ); + xContainer = new OCommandContainer( m_pImpl->m_aContext.getLegacyServiceFactory(), *this, rContainerData, sal_False ); + } m_pImpl->m_xCommandDefinitions = xContainer; } return xContainer; diff --git a/dbaccess/source/core/dataaccess/documentcontainer.cxx b/dbaccess/source/core/dataaccess/documentcontainer.cxx index 7334e72a1ffc..c8fe0c49ec4a 100644 --- a/dbaccess/source/core/dataaccess/documentcontainer.cxx +++ b/dbaccess/source/core/dataaccess/documentcontainer.cxx @@ -380,9 +380,12 @@ Reference< XInterface > SAL_CALL ODocumentContainer::createInstanceWithArguments ::rtl::OUString sServiceName; if ( Reference< XNameAccess >( xObjectToCopy, UNO_QUERY ).is() ) + { if ( m_bFormsContainer ) sServiceName = SERVICE_NAME_FORM_COLLECTION; - else sServiceName = SERVICE_NAME_REPORT_COLLECTION; + else + sServiceName = SERVICE_NAME_REPORT_COLLECTION; + } else sServiceName = SERVICE_SDB_DOCUMENTDEFINITION; @@ -503,7 +506,7 @@ namespace if ( bRet ) { _rRet = _xNameContainer->getByName(_sSimpleName = sName); - while ( nIndex != -1 ) + while ( nIndex != -1 && bRet ) { sName = _sName.getToken(0,'/',nIndex); _xNameContainer.set(_rRet,UNO_QUERY); @@ -517,8 +520,10 @@ namespace } } } - else if ( nIndex == -1 ) - _sSimpleName = sName; // a content on the root content + if ( nIndex == -1 ) + _sSimpleName = sName; // a content + else + _xNameContainer.clear(); // a sub folder doesn't exist return bRet; } } @@ -540,7 +545,6 @@ Reference< XComponent > SAL_CALL ODocumentContainer::loadComponentFromURL( const if ( !lcl_queryContent(_sURL,xNameContainer,aContent,sName) ) { ::rtl::OUString sMessage( DBA_RES( RID_STR_NAME_NOT_FOUND ) ); - // TODO: resource ::comphelper::string::searchAndReplaceAsciiI( sMessage, "$name$", _sURL ); throw IllegalArgumentException( sMessage, *this, 1 ); } @@ -610,15 +614,24 @@ sal_Bool SAL_CALL ODocumentContainer::hasByHierarchicalName( const ::rtl::OUStri // XHierarchicalNameContainer void SAL_CALL ODocumentContainer::insertByHierarchicalName( const ::rtl::OUString& _sName, const Any& _aElement ) throw (IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException) { + Reference< XContent > xContent(_aElement,UNO_QUERY); + if ( !xContent.is() ) + throw IllegalArgumentException(); + ClearableMutexGuard aGuard(m_aMutex); Any aContent; Reference< XNameContainer > xNameContainer(this); ::rtl::OUString sName; if ( lcl_queryContent(_sName,xNameContainer,aContent,sName) ) throw ElementExistException(_sName,*this); - Reference< XContent > xContent(_aElement,UNO_QUERY); - if ( !xContent.is() ) - throw IllegalArgumentException(); + + if ( !xNameContainer.is() ) + { + ::rtl::OUString sMessage( DBA_RES( RID_STR_NO_SUB_FOLDER ) ); + sal_Int32 index = sName.getLength(); + ::comphelper::string::searchAndReplaceAsciiI( sMessage, "$folder$", _sName.getToken(0,'/',index) ); + throw IllegalArgumentException( sMessage, *this, 1 ); + } xNameContainer->insertByName(sName,_aElement); } diff --git a/dbaccess/source/core/dataaccess/documentdefinition.cxx b/dbaccess/source/core/dataaccess/documentdefinition.cxx index e1c12034b49a..f4426025c6fa 100644 --- a/dbaccess/source/core/dataaccess/documentdefinition.cxx +++ b/dbaccess/source/core/dataaccess/documentdefinition.cxx @@ -721,7 +721,7 @@ void ODocumentDefinition::impl_onActivateEmbeddedObject_nothrow() // ensure that we ourself are kept alive as long as the embedded object's frame is // opened - LifetimeCoupler::couple( *this, Reference< XComponent >( xFrame, UNO_QUERY_THROW ) ); + LifetimeCoupler::couple( *this, xFrame.get() ); // init the edit view if ( m_bForm && m_bOpenInDesign ) @@ -1036,6 +1036,11 @@ Any ODocumentDefinition::onCommandOpenSomething( const Any& _rOpenArgument, cons m_xEmbeddedObject->changeState( EmbedStates::ACTIVE ); ODocumentDefinition::impl_onActivateEmbeddedObject_nothrow(); } + else + { + // ensure that we ourself are kept alive as long as the document is open + LifetimeCoupler::couple( *this, xModel.get() ); + } if ( !m_bForm && m_pImpl->m_aProps.bAsTemplate && !m_bOpenInDesign ) ODocumentDefinition::fillReportData( m_aContext, getComponent(), xConnection ); @@ -1694,8 +1699,7 @@ void ODocumentDefinition::loadEmbeddedObject( const Reference< XConnection >& _x if ( !xEnumDrivers.is() || !xEnumDrivers->hasMoreElements() ) { com::sun::star::io::WrongFormatException aWFE; - aWFE.Message = ::rtl::OUString::createFromAscii("Extension not present."); - // TODO: resource + aWFE.Message = DBACORE_RESSTRING( RID_STR_MISSING_EXTENSION ); throw aWFE; } } diff --git a/dbaccess/source/core/inc/View.hxx b/dbaccess/source/core/inc/View.hxx new file mode 100644 index 000000000000..0cda27afcf82 --- /dev/null +++ b/dbaccess/source/core/inc/View.hxx @@ -0,0 +1,91 @@ +/************************************************************************* + * + * 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: View.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef DBACCESS_VIEW_HXX +#define DBACCESS_VIEW_HXX + +#include "connectivity/sdbcx/VView.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/sdbcx/XAlterView.hpp> +#include <com/sun/star/sdb/tools/XViewSupport.hpp> +/** === end UNO includes === **/ + +#include <comphelper/uno3.hxx> +#include <cppuhelper/implbase1.hxx> + +//........................................................................ +namespace dbaccess +{ +//........................................................................ + + //==================================================================== + //= View + //==================================================================== + typedef ::connectivity::sdbcx::OView View_Base; + typedef ::cppu::ImplHelper1< ::com::sun::star::sdbcx::XAlterView > View_IBASE; + class View :public View_Base + ,public View_IBASE + { + public: + View( + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, + sal_Bool _bCaseSensitive, + const ::rtl::OUString& _rCatalogName, + const ::rtl::OUString& _rSchemaName, + const ::rtl::OUString& _rName + ); + + // UNO + DECLARE_XINTERFACE() + DECLARE_XTYPEPROVIDER() + + // XAlterView + virtual void SAL_CALL alterCommand( const ::rtl::OUString& NewCommand ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + protected: + virtual ~View(); + + protected: + // OPropertyContainer + virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& _rValue, sal_Int32 _nHandle ) const; + + private: + ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XViewSupport> m_xViewSupport; + sal_Int32 m_nCommandHandle; + private: + using View_Base::getFastPropertyValue; + }; + +//........................................................................ +} // namespace dbaccess +//........................................................................ + +#endif // DBACCESS_VIEW_HXX diff --git a/dbaccess/source/core/inc/core_resource.hrc b/dbaccess/source/core/inc/core_resource.hrc index 20e0eb280233..8bfa73bbde48 100644 --- a/dbaccess/source/core/inc/core_resource.hrc +++ b/dbaccess/source/core/inc/core_resource.hrc @@ -88,7 +88,29 @@ #define RID_STR_NAME_NOT_FOUND ( RID_CORE_STRINGS_START + 45 ) #define RID_STR_QUERY_DOES_NOT_EXIST ( RID_CORE_STRINGS_START + 46 ) #define RID_STR_ERROR_WHILE_SAVING ( RID_CORE_STRINGS_START + 47 ) -#define RID_NO_SUCH_DATA_SOURCE ( RID_CORE_STRINGS_START + 48 ) +#define RID_STR_NO_SUB_FOLDER ( RID_CORE_STRINGS_START + 48 ) + +#define RID_STR_NO_DELETE_BEFORE_AFTER ( RID_CORE_STRINGS_START + 49 ) +#define RID_STR_NO_DELETE_INSERT_ROW ( RID_CORE_STRINGS_START + 50 ) +#define RID_STR_RESULT_IS_READONLY ( RID_CORE_STRINGS_START + 51 ) +#define RID_STR_NO_DELETE_PRIVILEGE ( RID_CORE_STRINGS_START + 52 ) +#define RID_STR_ROW_ALREADY_DELETED ( RID_CORE_STRINGS_START + 53 ) +#define RID_STR_UPDATE_FAILED ( RID_CORE_STRINGS_START + 54 ) + +#define RID_STR_INVALID_INDEX ( RID_CORE_STRINGS_START + 55 ) +#define RID_STR_NO_INSERT_PRIVILEGE ( RID_CORE_STRINGS_START + 56 ) +#define RID_STR_INTERNAL_ERROR ( RID_CORE_STRINGS_START + 57 ) +#define RID_STR_EXPRESSION1 ( RID_CORE_STRINGS_START + 58 ) +#define RID_STR_NO_SQL_COMMAND ( RID_CORE_STRINGS_START + 59 ) +#define RID_STR_INVALID_CURSOR_STATE ( RID_CORE_STRINGS_START + 60 ) +#define RID_STR_CURSOR_BEFORE_OR_AFTER ( RID_CORE_STRINGS_START + 61 ) +#define RID_STR_NO_BOOKMARK_BEFORE_OR_AFTER ( RID_CORE_STRINGS_START + 62 ) +#define RID_STR_NO_BOOKMARK_DELETED ( RID_CORE_STRINGS_START + 63 ) +#define RID_STR_NO_EMBEDDING ( RID_CORE_STRINGS_START + 64 ) +#define RID_STR_CONNECTION_REQUEST ( RID_CORE_STRINGS_START + 65 ) +#define RID_STR_MISSING_EXTENSION ( RID_CORE_STRINGS_START + 66 ) + +#define RID_NO_SUCH_DATA_SOURCE ( RID_CORE_STRINGS_START + 67 ) #endif // _DBA_CORE_RESOURCE_HRC_ diff --git a/dbaccess/source/core/inc/definitioncolumn.hxx b/dbaccess/source/core/inc/definitioncolumn.hxx index c5151e6bffd5..b67b0de70c59 100644 --- a/dbaccess/source/core/inc/definitioncolumn.hxx +++ b/dbaccess/source/core/inc/definitioncolumn.hxx @@ -167,7 +167,8 @@ namespace dbaccess public: OQueryColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxParserColumn, - const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection, + const ::rtl::OUString& _sNewName ); // XTypeProvider diff --git a/dbaccess/source/core/inc/sdbcoretools.hxx b/dbaccess/source/core/inc/sdbcoretools.hxx index 92a163b3d24e..5f3e967e79a4 100644 --- a/dbaccess/source/core/inc/sdbcoretools.hxx +++ b/dbaccess/source/core/inc/sdbcoretools.hxx @@ -52,31 +52,11 @@ namespace dbaccess getDataSource( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxDependentObject ); // ----------------------------------------------------------------------------- - /** retrieves a particular indirect data source setting - - @param _rxDataSource - a data source component - @param _pAsciiSettingsName - the ASCII name of the setting to obtain - @param _rSettingsValue - the value of the setting, upon successfull return - - @return - <FALSE/> if the setting is not present in the <member scope="com::sun::star::sdb">DataSource::Info</member> - member of the data source - <TRUE/> otherwise - */ - bool getDataSourceSetting( - const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxDataSource, - const sal_Char* _pAsciiSettingsName, - ::com::sun::star::uno::Any& /* [out] */ _rSettingsValue - ); // ----------------------------------------------------------------------------- /** retrieves a to-be-displayed string for a given caught exception; */ ::rtl::OUString extractExceptionMessage( const ::comphelper::ComponentContext& _rContext, const ::com::sun::star::uno::Any& _rError ); - //......................................................................... } // namespace dbaccess //......................................................................... diff --git a/dbaccess/source/core/inc/table.hxx b/dbaccess/source/core/inc/table.hxx index 9573f03ba40c..1f34dfd5dd9b 100644 --- a/dbaccess/source/core/inc/table.hxx +++ b/dbaccess/source/core/inc/table.hxx @@ -31,58 +31,24 @@ #ifndef _DBA_CORE_TABLE_HXX_ #define _DBA_CORE_TABLE_HXX_ -#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_ #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XINDEXESSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XIndexesSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XKeysSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XRENAME_HPP_ #include <com/sun/star/sdbcx/XRename.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XALTERTABLE_HPP_ #include <com/sun/star/sdbcx/XAlterTable.hpp> -#endif -#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ #include <com/sun/star/lang/XServiceInfo.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ #include <com/sun/star/sdbc/XRow.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ #include <com/sun/star/sdbc/XConnection.hpp> -#endif -#ifndef _CPPUHELPER_COMPBASE2_HXX_ #include <cppuhelper/compbase7.hxx> -#endif -#ifndef _DBASHARED_APITOOLS_HXX_ #include "apitools.hxx" -#endif -#ifndef _DBA_CORE_DATASETTINGS_HXX_ #include "datasettings.hxx" -#endif -#ifndef _DBA_COREAPI_COLUMN_HXX_ #include <column.hxx> -#endif -#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ #include <connectivity/CommonTools.hxx> -#endif -#ifndef CONNECTIVITY_TABLEHELPER_HXX #include <connectivity/TTableHelper.hxx> -#endif -#ifndef _COMPHELPER_UNO3_HXX_ #include <comphelper/uno3.hxx> -#endif -#ifndef COMPHELPER_IDPROPERTYARRAYUSAGEHELPER_HXX #include <comphelper/IdPropArrayHelper.hxx> -#endif namespace dbaccess { diff --git a/dbaccess/source/core/misc/DatabaseDataProvider.cxx b/dbaccess/source/core/misc/DatabaseDataProvider.cxx index b6aff3db3240..2cb2b29f8e87 100644 --- a/dbaccess/source/core/misc/DatabaseDataProvider.cxx +++ b/dbaccess/source/core/misc/DatabaseDataProvider.cxx @@ -37,6 +37,7 @@ #include <connectivity/FValue.hxx> #include <connectivity/dbtools.hxx> #include <rtl/ustrbuf.hxx> +#include <rtl/math.hxx> #include <com/sun/star/task/XInteractionHandler.hpp> #include <com/sun/star/sdb/XCompletedExecution.hpp> @@ -633,7 +634,14 @@ void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCat for (sal_Int32 j = _bHasCategories ? 2 : 1,i = 0; j <= nCount; ++j,++i) { aValue.fill(j,aColumnTypes[j-1],xRow); - aRow.push_back(aValue.getDouble()); + if ( aValue.isNull() ) + { + double nValue; + ::rtl::math::setNan( &nValue ); + aRow.push_back(nValue); + } + else + aRow.push_back(aValue.getDouble()); } // for (sal_Int32 j = 2,i = 0; j <= nCount; ++j,++i) aDataValues.push_back(aRow); } // while( xRes->next() && (!m_RowLimit || nRowCount < m_RowLimit) ) diff --git a/dbaccess/source/core/misc/dsntypes.cxx b/dbaccess/source/core/misc/dsntypes.cxx index 90294dd59869..23eda6049d24 100644 --- a/dbaccess/source/core/misc/dsntypes.cxx +++ b/dbaccess/source/core/misc/dsntypes.cxx @@ -444,7 +444,6 @@ DATASOURCE_TYPE ODsnTypeCollection::determineType(const String& _rDsn) const return aKnowPrefixes[i].eType; } - DBG_ERROR("ODsnTypeCollection::implDetermineType : unrecognized data source type !"); return DST_UNKNOWN; } // ----------------------------------------------------------------------------- diff --git a/dbaccess/source/core/misc/sdbcoretools.cxx b/dbaccess/source/core/misc/sdbcoretools.cxx index 48e08b7ff7e4..9858e1935626 100644 --- a/dbaccess/source/core/misc/sdbcoretools.cxx +++ b/dbaccess/source/core/misc/sdbcoretools.cxx @@ -91,39 +91,6 @@ namespace dbaccess return xReturn; } - // ------------------------------------------------------------------------- - bool getDataSourceSetting( const Reference< XInterface >& _rxDataSource, const sal_Char* _pAsciiSettingsName, - Any& /* [out] */ _rSettingsValue ) - { - bool bIsPresent = false; - try - { - Reference< XPropertySet > xDataSource( _rxDataSource, UNO_QUERY ); - OSL_ENSURE( xDataSource.is(), "getDataSourceSetting: invalid data source object!" ); - if ( !xDataSource.is() ) - return false; - - Sequence< PropertyValue > aSettings; - OSL_VERIFY( xDataSource->getPropertyValue( PROPERTY_INFO ) >>= aSettings ); - const PropertyValue* pSetting = aSettings.getConstArray(); - const PropertyValue* pSettingEnd = aSettings.getConstArray() + aSettings.getLength(); - for ( ; pSetting != pSettingEnd; ++pSetting ) - { - if ( pSetting->Name.equalsAscii( _pAsciiSettingsName ) ) - { - _rSettingsValue = pSetting->Value; - bIsPresent = true; - break; - } - } - } - catch( const Exception& ) - { - OSL_ENSURE( sal_False, "getDataSourceSetting: caught an exception!" ); - } - return bIsPresent; - } - // ----------------------------------------------------------------------------- ::rtl::OUString extractExceptionMessage( const ::comphelper::ComponentContext& _rContext, const Any& _rError ) { diff --git a/dbaccess/source/core/resource/strings.src b/dbaccess/source/core/resource/strings.src index 3fc3806963a5..33243e199330 100644 --- a/dbaccess/source/core/resource/strings.src +++ b/dbaccess/source/core/resource/strings.src @@ -250,5 +250,80 @@ String RID_NO_SUCH_DATA_SOURCE { Text [ en-US ] = "Error accessing data source '$name$':\n$error$"; }; - +String RID_STR_NO_SUB_FOLDER +{ + Text [ en-US ] = "There exists no folder named \"$folder$\"."; +}; +String RID_STR_NO_DELETE_BEFORE_AFTER +{ + Text [ en-US ] = "Cannot delete the before-first or after-last row."; +}; +String RID_STR_NO_DELETE_INSERT_ROW +{ + Text [ en-US ] = "Cannot delete the insert-row."; +}; +String RID_STR_RESULT_IS_READONLY +{ + Text [ en-US ] = "Result set is read only."; +}; +String RID_STR_NO_DELETE_PRIVILEGE +{ + Text [ en-US ] = "DELETE privilege not available."; +}; +String RID_STR_ROW_ALREADY_DELETED +{ + Text [ en-US ] = "Current row is already deleted."; +}; +String RID_STR_UPDATE_FAILED +{ + Text [ en-US ] = "Current row could be updated."; +}; //------------------------------------------------------------------------- +String RID_STR_NO_INSERT_PRIVILEGE +{ + Text [ en-US ] = "INSERT privilege not available."; +}; +String RID_STR_INTERNAL_ERROR +{ + Text [ en-US ] = "Internal error: no statement object provided by the database driver."; +}; +String RID_STR_EXPRESSION1 +{ + Text [ en-US ] = "Expression1"; +}; +String RID_STR_NO_SQL_COMMAND +{ + Text [ en-US ] = "No SQL command was provided."; +}; +String RID_STR_INVALID_INDEX +{ + Text [ en-US ] = "Invalid column index."; +}; +String RID_STR_INVALID_CURSOR_STATE +{ + Text [ en-US ] = "Invalid cursor state."; +}; +String RID_STR_CURSOR_BEFORE_OR_AFTER +{ + Text [ en-US ] = "The cursor points to before the first or after the last row."; +}; +String RID_STR_NO_BOOKMARK_BEFORE_OR_AFTER +{ + Text [ en-US ] = "The rows before the first and after the last row don't have a bookmark."; +}; +String RID_STR_NO_BOOKMARK_DELETED +{ + Text [ en-US ] = "The current row is deleted, and thus doesn't have a bookmark."; +}; +String RID_STR_NO_EMBEDDING +{ + Text [ en-US ] = "Embedding of database documents is not supported."; +}; +String RID_STR_CONNECTION_REQUEST +{ + Text [ en-US ] = "A connection for the following URL was requested \"$name$\"."; +}; +String RID_STR_MISSING_EXTENSION +{ + Text [ en-US ] = "The extension is not installed."; +}; diff --git a/dbaccess/source/ext/macromigration/dbmm_global.hrc b/dbaccess/source/ext/macromigration/dbmm_global.hrc index 8afb08b919e2..853e00058d2a 100644 --- a/dbaccess/source/ext/macromigration/dbmm_global.hrc +++ b/dbaccess/source/ext/macromigration/dbmm_global.hrc @@ -82,5 +82,8 @@ #define STR_WARNINGS ( RID_DBMM_STRING_START + 14 ) #define STR_EXCEPTION ( RID_DBMM_STRING_START + 15 ) #define STR_LIBRARY_TYPE_AND_NAME ( RID_DBMM_STRING_START + 16 ) +#define STR_INVALID_NUMBER_ARGS ( RID_DBMM_STRING_START + 17 ) +#define STR_NO_DATABASE ( RID_DBMM_STRING_START + 18 ) +#define STR_NOT_READONLY ( RID_DBMM_STRING_START + 19 ) #endif // DBACCESS_DBMM_GLOBAL_HRC diff --git a/dbaccess/source/ext/macromigration/macromigration.src b/dbaccess/source/ext/macromigration/macromigration.src index bb49ac7ad287..fa973be93d00 100644 --- a/dbaccess/source/ext/macromigration/macromigration.src +++ b/dbaccess/source/ext/macromigration/macromigration.src @@ -441,3 +441,16 @@ ErrorBox ERR_INVALID_BACKUP_LOCATION Buttons = WB_OK; Message [ en-US ] = "You need to choose a backup location other than the document location itself."; }; + +String STR_INVALID_NUMBER_ARGS +{ + Text [ en-US ] = "Invalid number of initialization arguments. Expected 1."; +}; +String STR_NO_DATABASE +{ + Text [ en-US ] = "No database document found in the initializatin arguments."; +}; +String STR_NOT_READONLY +{ + Text [ en-US ] = "Not applicable to read-only documents."; +}; diff --git a/dbaccess/source/ext/macromigration/macromigrationwizard.cxx b/dbaccess/source/ext/macromigration/macromigrationwizard.cxx index 732fa9906119..72eef7e1583b 100644 --- a/dbaccess/source/ext/macromigration/macromigrationwizard.cxx +++ b/dbaccess/source/ext/macromigration/macromigrationwizard.cxx @@ -32,6 +32,7 @@ #include "precompiled_dbaccess.hxx" #include "dbmm_module.hxx" +#include "dbmm_global.hrc" #include "macromigrationdialog.hxx" /** === begin UNO includes === **/ @@ -210,8 +211,7 @@ namespace dbmm if ( _rArguments.getLength() != 1 ) throw IllegalArgumentException( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid number of initialization arguments. Expected 1." ) ), - // TODO: resource + String(MacroMigrationResId(STR_INVALID_NUMBER_ARGS)), *this, 1 ); @@ -219,8 +219,7 @@ namespace dbmm m_xDocument.set( _rArguments[0], UNO_QUERY ); if ( !m_xDocument.is() ) throw IllegalArgumentException( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No database document found in the initializatin arguments." ) ), - // TODO: resource + String(MacroMigrationResId(STR_NO_DATABASE)), *this, 1 ); @@ -228,8 +227,7 @@ namespace dbmm Reference< XStorable > xDocStor( m_xDocument, UNO_QUERY_THROW ); if ( xDocStor->isReadonly() ) throw IllegalArgumentException( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Not applicable to read-only documents." ) ), - // TODO: resource + String(MacroMigrationResId(STR_NOT_READONLY)), *this, 1 ); diff --git a/dbaccess/source/filter/xml/xmlDatabase.cxx b/dbaccess/source/filter/xml/xmlDatabase.cxx index 3f3f183ba038..89111c6e6e48 100644 --- a/dbaccess/source/filter/xml/xmlDatabase.cxx +++ b/dbaccess/source/filter/xml/xmlDatabase.cxx @@ -30,45 +30,20 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef DBA_XMLDATABASE_HXX #include "xmlDatabase.hxx" -#endif -#ifndef DBA_XMLFILTER_HXX #include "xmlfilter.hxx" -#endif -#ifndef _XMLOFF_XMLTOKEN_HXX #include <xmloff/xmltoken.hxx> -#endif -#ifndef _XMLOFF_XMLNMSPE_HXX #include <xmloff/xmlnmspe.hxx> -#endif -#ifndef DBA_XMLDATASOURCE_HXX #include "xmlDataSource.hxx" -#endif -#ifndef DBA_XMLDOCUMENTS_HXX #include "xmlDocuments.hxx" -#endif -#ifndef DBA_XMLENUMS_HXX #include "xmlEnums.hxx" -#endif -#ifndef _COM_SUN_STAR_SDB_XREPORTDOCUMENTSSUPPLIER_HPP_ #include <com/sun/star/sdb/XReportDocumentsSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XFORMDOCUMENTSSUPPLIER_HPP_ #include <com/sun/star/sdb/XFormDocumentsSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XTablesSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XQUERYDEFINITIONSSUPPLIER_HPP_ #include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp> -#endif -#ifndef DBACCESS_SHARED_XMLSTRINGS_HRC #include "xmlstrings.hrc" -#endif -#ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> -#endif +#include <connectivity/dbtools.hxx> namespace dbaxml { @@ -111,25 +86,46 @@ SvXMLImportContext* OXMLDatabase::CreateChildContext( case XML_TOK_FORMS: { GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - Reference<XFormDocumentsSupplier> xSup(GetOwnImport().GetModel(),UNO_QUERY); - if ( xSup.is() ) - pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getFormDocuments(),SERVICE_NAME_FORM_COLLECTION,SERVICE_SDB_DOCUMENTDEFINITION); + Any aValue; + ::rtl::OUString sService; + dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"FormSupplier",aValue); + aValue >>= sService; + if ( !sService.getLength() ) + { + Reference<XFormDocumentsSupplier> xSup(GetOwnImport().GetModel(),UNO_QUERY); + if ( xSup.is() ) + pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getFormDocuments(),SERVICE_NAME_FORM_COLLECTION,SERVICE_SDB_DOCUMENTDEFINITION); + } } break; case XML_TOK_REPORTS: { GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - Reference<XReportDocumentsSupplier> xSup(GetOwnImport().GetModel(),UNO_QUERY); - if ( xSup.is() ) - pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getReportDocuments(),SERVICE_NAME_REPORT_COLLECTION,SERVICE_SDB_DOCUMENTDEFINITION); + Any aValue; + ::rtl::OUString sService; + dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"ReportSupplier",aValue); + aValue >>= sService; + if ( !sService.getLength() ) + { + Reference<XReportDocumentsSupplier> xSup(GetOwnImport().GetModel(),UNO_QUERY); + if ( xSup.is() ) + pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getReportDocuments(),SERVICE_NAME_REPORT_COLLECTION,SERVICE_SDB_DOCUMENTDEFINITION); + } } break; case XML_TOK_QUERIES: { GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP ); - Reference<XQueryDefinitionsSupplier> xSup(GetOwnImport().getDataSource(),UNO_QUERY); - if ( xSup.is() ) - pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getQueryDefinitions(),SERVICE_NAME_QUERY_COLLECTION); + Any aValue; + ::rtl::OUString sService; + dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"CommandDefinitionSupplier",aValue); + aValue >>= sService; + if ( !sService.getLength() ) + { + Reference<XQueryDefinitionsSupplier> xSup(GetOwnImport().getDataSource(),UNO_QUERY); + if ( xSup.is() ) + pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getQueryDefinitions(),SERVICE_NAME_QUERY_COLLECTION); + } } break; case XML_TOK_TABLES: diff --git a/dbaccess/source/filter/xml/xmlExport.cxx b/dbaccess/source/filter/xml/xmlExport.cxx index 489b0af7d718..28c85bcb5043 100644 --- a/dbaccess/source/filter/xml/xmlExport.cxx +++ b/dbaccess/source/filter/xml/xmlExport.cxx @@ -31,82 +31,37 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef DBA_XMLEXPORT_HXX #include "xmlExport.hxx" -#endif -#ifndef DBA_XMLAUTOSTYLE_HXX #include "xmlAutoStyle.hxx" -#endif -#ifndef _FLT_REGHELPER_HXX_ #include "flt_reghelper.hxx" -#endif -#ifndef _XMLOFF_PROGRESSBARHELPER_HXX #include <xmloff/ProgressBarHelper.hxx> -#endif -#ifndef _XMLOFF_XMLTOKEN_HXX #include <xmloff/xmltoken.hxx> -#endif -#ifndef _XMLOFF_TEXTIMP_HXX_ #include <xmloff/txtimp.hxx> -#endif -#ifndef _XMLOFF_XMLNMSPE_HXX #include <xmloff/xmlnmspe.hxx> -#endif -#ifndef _XMLOFF_XMLUCONV_HXX #include <xmloff/xmluconv.hxx> -#endif -#ifndef _XMLOFF_NMSPMAP_HXX #include <xmloff/nmspmap.hxx> -#endif -#ifndef _COMPHELPER_TYPES_HXX_ #include <comphelper/types.hxx> -#endif -#ifndef DBACCESS_SHARED_XMLSTRINGS_HRC #include "xmlstrings.hrc" -#endif -#ifndef DBA_XMLENUMS_HXX #include "xmlEnums.hxx" -#endif -#ifndef _XMLOFF_NMSPMAP_HXX #include <xmloff/nmspmap.hxx> -#endif -#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSTATE_HPP_ #include <com/sun/star/beans/XPropertyState.hpp> -#endif -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ #include <com/sun/star/beans/PropertyAttribute.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XFORMDOCUMENTSSUPPLIER_HPP_ #include <com/sun/star/sdb/XFormDocumentsSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XOFFICEDATABASEDOCUMENT_HPP_ #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XREPORTDOCUMENTSSUPPLIER_HPP_ #include <com/sun/star/sdb/XReportDocumentsSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XQUERYDEFINITIONSSUPPLIER_HPP_ #include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp> -#endif #include <com/sun/star/sdbcx/XTablesSupplier.hpp> #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp> -#ifndef _COM_SUN_STAR_AWT_TEXTALIGN_HPP_ #include <com/sun/star/awt/TextAlign.hpp> -#endif -#ifndef _XMLOFF_XMLUCONV_HXX #include <xmloff/xmluconv.hxx> -#endif -#ifndef DBA_XMLHELPER_HXX #include "xmlHelper.hxx" -#endif -#ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_ #include <com/sun/star/awt/FontDescriptor.hpp> -#endif #include <svl/filenotation.hxx> #include <unotools/pathoptions.hxx> #include <tools/diagnose_ex.h> #include <connectivity/DriversConfig.hxx> +#include <connectivity/dbtools.hxx> #include <boost/optional.hpp> @@ -1110,47 +1065,68 @@ void ODBExport::exportColumns(const Reference<XColumnsSupplier>& _xColSup) // ----------------------------------------------------------------------------- void ODBExport::exportForms() { - Reference<XFormDocumentsSupplier> xSup(GetModel(),UNO_QUERY); - if ( xSup.is() ) + Any aValue; + ::rtl::OUString sService; + dbtools::getDataSourceSetting(getDataSource(),"ReportSupplier",aValue); + aValue >>= sService; + if ( !sService.getLength() ) { - Reference< XNameAccess > xCollection = xSup->getFormDocuments(); - if ( xCollection.is() && xCollection->hasElements() ) + Reference<XFormDocumentsSupplier> xSup(GetModel(),UNO_QUERY); + if ( xSup.is() ) { - ::comphelper::mem_fun1_t<ODBExport,XPropertySet* > aMemFunc(&ODBExport::exportComponent); - exportCollection(xCollection,XML_FORMS,XML_COMPONENT_COLLECTION,sal_True,aMemFunc); + Reference< XNameAccess > xCollection = xSup->getFormDocuments(); + if ( xCollection.is() && xCollection->hasElements() ) + { + ::comphelper::mem_fun1_t<ODBExport,XPropertySet* > aMemFunc(&ODBExport::exportComponent); + exportCollection(xCollection,XML_FORMS,XML_COMPONENT_COLLECTION,sal_True,aMemFunc); + } } } } // ----------------------------------------------------------------------------- void ODBExport::exportReports() { - Reference<XReportDocumentsSupplier> xSup(GetModel(),UNO_QUERY); - if ( xSup.is() ) + Any aValue; + ::rtl::OUString sService; + dbtools::getDataSourceSetting(getDataSource(),"ReportSupplier",aValue); + aValue >>= sService; + if ( !sService.getLength() ) { - Reference< XNameAccess > xCollection = xSup->getReportDocuments(); - if ( xCollection.is() && xCollection->hasElements() ) + Reference<XReportDocumentsSupplier> xSup(GetModel(),UNO_QUERY); + if ( xSup.is() ) { - ::comphelper::mem_fun1_t<ODBExport,XPropertySet* > aMemFunc(&ODBExport::exportComponent); - exportCollection(xCollection,XML_REPORTS,XML_COMPONENT_COLLECTION,sal_True,aMemFunc); + Reference< XNameAccess > xCollection = xSup->getReportDocuments(); + if ( xCollection.is() && xCollection->hasElements() ) + { + ::comphelper::mem_fun1_t<ODBExport,XPropertySet* > aMemFunc(&ODBExport::exportComponent); + exportCollection(xCollection,XML_REPORTS,XML_COMPONENT_COLLECTION,sal_True,aMemFunc); + } } } } // ----------------------------------------------------------------------------- void ODBExport::exportQueries(sal_Bool _bExportContext) { - Reference<XQueryDefinitionsSupplier> xSup(getDataSource(),UNO_QUERY); - if ( xSup.is() ) + Any aValue; + ::rtl::OUString sService; + dbtools::getDataSourceSetting(getDataSource(),"CommandDefinitionSupplier",aValue); + aValue >>= sService; + if ( !sService.getLength() ) { - Reference< XNameAccess > xCollection = xSup->getQueryDefinitions(); - if ( xCollection.is() && xCollection->hasElements() ) + Reference<XQueryDefinitionsSupplier> xSup(getDataSource(),UNO_QUERY); + if ( xSup.is() ) { - ::std::auto_ptr< ::comphelper::mem_fun1_t<ODBExport,XPropertySet* > > pMemFunc; - if ( _bExportContext ) - pMemFunc.reset( new ::comphelper::mem_fun1_t<ODBExport,XPropertySet* >(&ODBExport::exportQuery) ); - else - pMemFunc.reset( new ::comphelper::mem_fun1_t<ODBExport,XPropertySet* >(&ODBExport::exportAutoStyle) ); + Reference< XNameAccess > xCollection = xSup->getQueryDefinitions(); + if ( xCollection.is() && xCollection->hasElements() ) + { + ::std::auto_ptr< ::comphelper::mem_fun1_t<ODBExport,XPropertySet* > > pMemFunc; + if ( _bExportContext ) + pMemFunc.reset( new ::comphelper::mem_fun1_t<ODBExport,XPropertySet* >(&ODBExport::exportQuery) ); + else + pMemFunc.reset( new ::comphelper::mem_fun1_t<ODBExport,XPropertySet* >(&ODBExport::exportAutoStyle) ); - exportCollection(xCollection,XML_QUERIES,XML_QUERY_COLLECTION,_bExportContext,*pMemFunc); + exportCollection(xCollection,XML_QUERIES,XML_QUERY_COLLECTION,_bExportContext,*pMemFunc); + } } } } diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx index 57f38d324b5c..5b9c4311b9be 100644 --- a/dbaccess/source/ui/app/AppController.cxx +++ b/dbaccess/source/ui/app/AppController.cxx @@ -79,160 +79,68 @@ #include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp> #include <com/sun/star/document/XDocumentEventBroadcaster.hpp> /** === end UNO includes === **/ - -#ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> -#endif -#ifndef TOOLS_DIAGNOSE_EX_H #include <tools/diagnose_ex.h> -#endif -#ifndef SVTOOLS_URIHELPER_HXX +#include <tools/string.hxx> + #include <svl/urihelper.hxx> -#endif -#ifndef _COMPHELPER_TYPES_HXX_ +#include <unotools/pathoptions.hxx> +#include <unotools/internaloptions.hxx> +#include <unotools/moduleoptions.hxx> +#include <svtools/svtreebx.hxx> +#include <svtools/transfer.hxx> +#include <svtools/cliplistener.hxx> +#include <svtools/svlbitm.hxx> +#include <svl/historyoptions.hxx> +#include <svl/filenotation.hxx> +#include <svtools/insdlg.hxx> + +#include <unotools/tempfile.hxx> + +#include <comphelper/sequence.hxx> +#include <comphelper/uno3.hxx> +#include <comphelper/string.hxx> #include <comphelper/types.hxx> -#endif -#ifndef _COMPHELPER_INTERACTION_HXX_ #include <comphelper/interaction.hxx> -#endif -#ifndef COMPHELPER_COMPONENTCONTEXT_HXX #include <comphelper/componentcontext.hxx> -#endif -#ifndef _SV_MSGBOX_HXX + #include <vcl/msgbox.hxx> -#endif -#ifndef _VCL_STDTEXT_HXX #include <vcl/stdtext.hxx> -#endif -#ifndef _FILEDLGHELPER_HXX +#include <vcl/svapp.hxx> +#include <vcl/menu.hxx> +#include <vcl/lstbox.hxx> + +#include <sfx2/mailmodelapi.hxx> #include <sfx2/filedlghelper.hxx> -#endif -#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <sfx2/docfilt.hxx> +#include <sfx2/QuerySaveDocument.hxx> + #include <cppuhelper/typeprovider.hxx> -#endif -#ifndef _CPPUHELPER_EXC_HLP_HXX_ #include <cppuhelper/exc_hlp.hxx> -#endif -#ifndef _CONNECTIVITY_DBTOOLS_HXX_ + #include <connectivity/dbtools.hxx> -#endif -#ifndef DBAUI_APPVIEW_HXX +#include <connectivity/dbexception.hxx> + +#include <svx/dbaexchange.hxx> +#include <svx/dbaobjectex.hxx> +#include <svx/svxdlg.hxx> + #include "AppView.hxx" -#endif -#ifndef DBACCESS_UI_BROWSER_ID_HXX #include "browserids.hxx" -#endif -#ifndef _DBAU_REGHELPER_HXX_ #include "dbu_reghelper.hxx" -#endif -#ifndef _DBU_APP_HRC_ #include "dbu_app.hrc" -#endif -#ifndef DBACCESS_SOURCE_UI_MISC_DEFAULTOBJECTNAMECHECK_HXX #include "defaultobjectnamecheck.hxx" -#endif -#ifndef _SV_MENU_HXX -#include <vcl/menu.hxx> -#endif -#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX -#include <unotools/pathoptions.hxx> -#endif -#ifndef INCLUDED_SVTOOLS_INTERNALOPTIONS_HXX -#include <unotools/internaloptions.hxx> -#endif -#ifndef _COMPHELPER_UNO3_HXX_ -#include <comphelper/uno3.hxx> -#endif -#ifndef DBACCESS_DATABASE_OBJECT_VIEW_HXX #include "databaseobjectview.hxx" -#endif -#ifndef _SV_SVAPP_HXX //autogen -#include <vcl/svapp.hxx> -#endif -#ifndef _SVLBOXITM_HXX -#include <svtools/svlbitm.hxx> -#endif -#ifndef _DBAUI_LISTVIEWITEMS_HXX_ #include "listviewitems.hxx" -#endif - -#ifndef DBAUI_APPDETAILVIEW_HXX #include "AppDetailView.hxx" -#endif -#ifndef _DBAUI_LINKEDDOCUMENTS_HXX_ #include "linkeddocuments.hxx" -#endif -#ifndef _SV_LSTBOX_HXX -#include <vcl/lstbox.hxx> -#endif -#ifndef _DBHELPER_DBEXCEPTION_HXX_ -#include <connectivity/dbexception.hxx> -#endif -#ifndef _DBAUI_SQLMESSAGE_HXX_ #include "sqlmessage.hxx" -#endif -#ifndef _STRING_HXX -#include <tools/string.hxx> -#endif -#ifndef INCLUDED_SFX_MAILMODELAPI_HXX -#include <sfx2/mailmodelapi.hxx> -#endif -#ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX -#include <unotools/moduleoptions.hxx> -#endif -#ifndef _SVTREEBOX_HXX -#include <svtools/svtreebx.hxx> -#endif -#ifndef _TRANSFER_HXX -#include <svtools/transfer.hxx> -#endif -#ifndef _CLIPLISTENER_HXX -#include <svtools/cliplistener.hxx> -#endif -#ifndef _SVX_DBAEXCHANGE_HXX_ -#include <svx/dbaexchange.hxx> -#endif -#ifndef SVX_DBAOBJECTEX_HXX -#include <svx/dbaobjectex.hxx> -#endif -#ifndef DBAUI_TOOLS_HXX #include "UITools.hxx" -#endif -#ifndef _DBAUI_DSNTYPES_HXX_ #include "dsntypes.hxx" -#endif -#include <svx/svxdlg.hxx> -#include <svtools/insdlg.hxx> -#ifndef _UNOTOOLS_TEMPFILE_HXX -#include <unotools/tempfile.hxx> -#endif -#ifndef _DBA_DBACCESS_HELPID_HRC_ #include "dbaccess_helpid.hrc" -#endif -#ifndef DBAUI_DLGSAVE_HXX #include "dlgsave.hxx" -#endif -#ifndef _SFX_DOCFILT_HACK_HXX -#include <sfx2/docfilt.hxx> -#endif -#ifndef SFX_QUERYSAVEDOCUMENT_HXX -#include <sfx2/QuerySaveDocument.hxx> -#endif -#ifndef INCLUDED_SVTOOLS_HISTORYOPTIONS_HXX -#include <unotools/historyoptions.hxx> -#endif -#ifndef SVTOOLS_FILENOTATION_HXX_ -#include <svl/filenotation.hxx> -#endif -#ifndef _COMPHELPER_SEQUENCE_HXX_ -#include <comphelper/sequence.hxx> -#endif -#ifndef _VOS_MUTEX_HXX_ #include <vos/mutex.hxx> -#endif -#ifndef _DBACCESS_SLOTID_HRC_ #include "dbaccess_slotid.hrc" -#endif #include <algorithm> #include <functional> @@ -2955,8 +2863,7 @@ void SAL_CALL OApplicationController::removeSelectionChangeListener( const Refer case DatabaseObjectContainer::REPORTS: if ( eSelectedCategory != E_NONE ) throw IllegalArgumentException( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "You cannot select different categories." ) ), - // TODO: resource + String(ModuleRes(RID_STR_NO_DIFF_CAT)), *this, sal_Int16( pObject - aSelectedObjects.getConstArray() ) ); eSelectedCategory = ( pObject->Type == DatabaseObjectContainer::TABLES ) ? E_TABLE @@ -2969,13 +2876,9 @@ void SAL_CALL OApplicationController::removeSelectionChangeListener( const Refer default: case DatabaseObjectContainer::DATA_SOURCE: { - ::rtl::OUStringBuffer aMessage; - aMessage.appendAscii( "Unsupported object type found (" ); - aMessage.append ( sal_Int32( pObject->Type ) ); - aMessage.appendAscii( ")." ); - // TODO: resource - throw IllegalArgumentException( - aMessage.makeStringAndClear(), *this, sal_Int16( pObject - aSelectedObjects.getConstArray() ) ); + ::rtl::OUString sMessage = String(ModuleRes( RID_STR_UNSUPPORTED_OBJECT_TYPE )); + ::comphelper::string::searchAndReplaceAsciiI( sMessage, "$type$", ::rtl::OUString::valueOf(sal_Int32( pObject->Type )) ); + throw IllegalArgumentException(sMessage, *this, sal_Int16( pObject - aSelectedObjects.getConstArray() )); } } } diff --git a/dbaccess/source/ui/app/AppDetailPageHelper.cxx b/dbaccess/source/ui/app/AppDetailPageHelper.cxx index 50e357b687b8..72b34a339e45 100644 --- a/dbaccess/source/ui/app/AppDetailPageHelper.cxx +++ b/dbaccess/source/ui/app/AppDetailPageHelper.cxx @@ -658,6 +658,8 @@ void OAppDetailPageHelper::paste() // ----------------------------------------------------------------------------- bool OAppDetailPageHelper::isLeaf(SvLBoxEntry* _pEntry) const { + if ( !_pEntry ) + return false; sal_Int32 nEntryType = reinterpret_cast< sal_IntPtr >( _pEntry->GetUserData() ); if ( ( nEntryType == DatabaseObjectContainer::TABLES ) || ( nEntryType == DatabaseObjectContainer::CATALOG ) diff --git a/dbaccess/source/ui/app/app.src b/dbaccess/source/ui/app/app.src index c913d16ebd2d..9aff7f73d992 100644 --- a/dbaccess/source/ui/app/app.src +++ b/dbaccess/source/ui/app/app.src @@ -469,3 +469,11 @@ String RID_STR_EMBEDDED_DATABASE { Text [ en-US ] = "Embedded database"; }; +String RID_STR_NO_DIFF_CAT +{ + Text [ en-US ] = "You cannot select different categories."; +}; +String RID_STR_UNSUPPORTED_OBJECT_TYPE +{ + Text [ en-US ] = "Unsupported object type found ($type$)."; +}; diff --git a/dbaccess/source/ui/app/dbu_app.hrc b/dbaccess/source/ui/app/dbu_app.hrc index 63aa923ce30f..5b4aee52304e 100644 --- a/dbaccess/source/ui/app/dbu_app.hrc +++ b/dbaccess/source/ui/app/dbu_app.hrc @@ -68,11 +68,12 @@ #define RID_STR_FORMS_HELP_TEXT_WIZARD RID_STR_APP_START + 29 #define RID_STR_REPORT_HELP_TEXT RID_STR_APP_START + 30 #define RID_STR_EMBEDDED_DATABASE RID_STR_APP_START + 31 - +#define RID_STR_NO_DIFF_CAT RID_STR_APP_START + 32 +#define RID_STR_UNSUPPORTED_OBJECT_TYPE RID_STR_APP_START + 33 // please adjust checking before insert new strings -#if RID_STR_EMBEDDED_DATABASE > RID_STR_APP_END +#if RID_STR_UNSUPPORTED_OBJECT_TYPE > RID_STR_APP_END #error Resource-Id Ueberlauf in #file, #line #endif diff --git a/dbaccess/source/ui/browser/brwctrlr.cxx b/dbaccess/source/ui/browser/brwctrlr.cxx index 8db327fb8b85..1caae8c6bf11 100644 --- a/dbaccess/source/ui/browser/brwctrlr.cxx +++ b/dbaccess/source/ui/browser/brwctrlr.cxx @@ -1712,7 +1712,7 @@ FeatureState SbaXDataBrowserController::GetState(sal_uInt16 nId) const { // a native statement can't be filtered or sorted const Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); - if ( !::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ESCAPE_PROCESSING))) + if ( !::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ESCAPE_PROCESSING)) || !m_xParser.is() ) break; Reference< XPropertySet > xCurrentField = getBoundField(); @@ -1731,7 +1731,7 @@ FeatureState SbaXDataBrowserController::GetState(sal_uInt16 nId) const break; case ID_BROWSER_FILTERCRIT: - if ( m_bCannotSelectUnfiltered ) + if ( m_bCannotSelectUnfiltered && m_xParser.is() ) { aReturn.bEnabled = sal_True; break; @@ -1740,7 +1740,7 @@ FeatureState SbaXDataBrowserController::GetState(sal_uInt16 nId) const case ID_BROWSER_ORDERCRIT: { const Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY); - if ( !::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ESCAPE_PROCESSING))) + if ( !::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ESCAPE_PROCESSING)) || !m_xParser.is() ) break; aReturn.bEnabled = getRowSet().is() diff --git a/dbaccess/source/ui/browser/dsEntriesNoExp.cxx b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx index 16859283c9b7..6e522dd293f0 100644 --- a/dbaccess/source/ui/browser/dsEntriesNoExp.cxx +++ b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx @@ -119,9 +119,21 @@ SbaTableQueryBrowser::EntryType SbaTableQueryBrowser::getEntryType( SvLBoxEntry* return etTableOrView; if (pQueries == pEntryParent) + { + DBTreeListUserData* pEntryData = static_cast<DBTreeListUserData*>(_pEntry->GetUserData()); + if ( pEntryData ) + return pEntryData->eType; + return etQuery; + } + while( pEntryParent != pQueries ) + { + pEntryParent = m_pTreeView->getListBox().GetParent(pEntryParent); + if ( !pEntryParent ) + return etUnknown; + } - return etUnknown; + return etQueryContainer; } //------------------------------------------------------------------------------ void SbaTableQueryBrowser::select(SvLBoxEntry* _pEntry, sal_Bool _bSelect) @@ -166,7 +178,7 @@ void SbaTableQueryBrowser::SelectionChanged() InvalidateFeature(ID_BROWSER_INSERTCONTENT); InvalidateFeature(ID_BROWSER_FORMLETTER); } // if ( !m_bShowMenu ) - InvalidateFeature(ID_BROWSER_COPY);
+ InvalidateFeature(ID_BROWSER_COPY); InvalidateFeature(ID_BROWSER_CUT); } //------------------------------------------------------------------------------ diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index b63383e47c0e..1e10e9421047 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -519,6 +519,8 @@ sal_Bool SbaTableQueryBrowser::InitializeGridModel(const Reference< ::com::sun:: DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData()); OSL_ENSURE( pData->xObjectProperties.is(), "SbaTableQueryBrowser::InitializeGridModel: No table available!" ); + if ( !pData->xObjectProperties.is() ) + return sal_False; ::rtl::OUString* pStringIter = aProperties.getArray(); Any* pValueIter = aValues.getArray(); @@ -732,7 +734,7 @@ Reference<XPropertySet> getColumnHelper(SvLBoxEntry* _pCurrentlyDisplayed,const ::rtl::OUString aName; _rxSource->getPropertyValue(PROPERTY_NAME) >>= aName; if(xNames.is() && xNames->hasByName(aName)) - ::cppu::extractInterface(xRet,xNames->getByName(aName)); + xRet.set(xNames->getByName(aName),UNO_QUERY); } return xRet; } @@ -1100,7 +1102,47 @@ SvLBoxEntry* SbaTableQueryBrowser::getObjectEntry(const ::rtl::OUString& _rDataS m_pTreeView->getListBox().Expand(pCommandType); // look for the object - pObject = m_pTreeView->getListBox().GetEntryPosByName(_rCommand, pCommandType); + ::rtl::OUString sCommand = _rCommand; + sal_Int32 nIndex = 0; + do + { + ::rtl::OUString sPath = sCommand.getToken( 0, '/', nIndex ); + pObject = m_pTreeView->getListBox().GetEntryPosByName(sPath, pCommandType); + pCommandType = pObject; + if ( nIndex >= 0 ) + { + if (ensureEntryObject(pObject)) + { + DBTreeListUserData* pParentData = static_cast< DBTreeListUserData* >( pObject->GetUserData() ); + Reference< XNameAccess > xCollection( pParentData->xContainer, UNO_QUERY ); + sal_Int32 nIndex2 = nIndex; + sPath = sCommand.getToken( 0, '/', nIndex2 ); + try + { + if ( xCollection->hasByName(sPath) ) + { + if(!m_pTreeView->getListBox().GetEntryPosByName(sPath,pObject)) + { + Reference<XNameAccess> xChild(xCollection->getByName(sPath),UNO_QUERY); + DBTreeListUserData* pEntryData = new DBTreeListUserData; + pEntryData->eType = etQuery; + if ( xChild.is() ) + { + pEntryData->eType = etQueryContainer; + } + implAppendEntry( pObject, sPath, pEntryData, pEntryData->eType ); + } + } + } + catch(Exception&) + { + DBG_ERROR("SbaTableQueryBrowser::populateTree: could not fill the tree"); + } + } + } + // m_pTreeView->getListBox().Expand(pCommandType); + } + while ( nIndex >= 0 ); } } } @@ -1991,7 +2033,7 @@ void SbaTableQueryBrowser::initializeTreeModel() } } // ------------------------------------------------------------------------- -sal_Bool SbaTableQueryBrowser::populateTree(const Reference<XNameAccess>& _xNameAccess, +void SbaTableQueryBrowser::populateTree(const Reference<XNameAccess>& _xNameAccess, SvLBoxEntry* _pParent, EntryType _eEntryType) { @@ -2008,34 +2050,39 @@ sal_Bool SbaTableQueryBrowser::populateTree(const Reference<XNameAccess>& _xName { if(!m_pTreeView->getListBox().GetEntryPosByName(*pIter,_pParent)) { + Reference<XNameAccess> xChild(_xNameAccess->getByName(*pIter),UNO_QUERY); DBTreeListUserData* pEntryData = new DBTreeListUserData; pEntryData->eType = _eEntryType; - implAppendEntry( _pParent, *pIter, pEntryData, _eEntryType ); + if ( _eEntryType == etQuery && xChild.is() ) + { + pEntryData->eType = etQueryContainer; + } + implAppendEntry( _pParent, *pIter, pEntryData, pEntryData->eType ); } } } catch(Exception&) { DBG_ERROR("SbaTableQueryBrowser::populateTree: could not fill the tree"); - return sal_False; } - return sal_True; } //------------------------------------------------------------------------------ -void SbaTableQueryBrowser::implAppendEntry( SvLBoxEntry* _pParent, const String& _rName, void* _pUserData, EntryType _eEntryType ) +SvLBoxEntry* SbaTableQueryBrowser::implAppendEntry( SvLBoxEntry* _pParent, const String& _rName, void* _pUserData, EntryType _eEntryType ) { ::std::auto_ptr< ImageProvider > pImageProvider( getImageProviderFor( _pParent ) ); Image aImage, aImageHC; pImageProvider->getImages( _rName, getDatabaseObjectType( _eEntryType ), aImage, aImageHC ); - SvLBoxEntry* pNewEntry = m_pTreeView->getListBox().InsertEntry( _rName, _pParent, sal_False, LIST_APPEND, _pUserData ); + SvLBoxEntry* pNewEntry = m_pTreeView->getListBox().InsertEntry( _rName, _pParent, _eEntryType == etQueryContainer , LIST_APPEND, _pUserData ); m_pTreeView->getListBox().SetExpandedEntryBmp( pNewEntry, aImage, BMP_COLOR_NORMAL ); m_pTreeView->getListBox().SetCollapsedEntryBmp( pNewEntry, aImage, BMP_COLOR_NORMAL ); m_pTreeView->getListBox().SetExpandedEntryBmp( pNewEntry, aImageHC, BMP_COLOR_HIGHCONTRAST ); m_pTreeView->getListBox().SetCollapsedEntryBmp( pNewEntry, aImageHC, BMP_COLOR_HIGHCONTRAST ); + + return pNewEntry; } //------------------------------------------------------------------------------ @@ -2166,29 +2213,54 @@ sal_Bool SbaTableQueryBrowser::ensureEntryObject( SvLBoxEntry* _pEntry ) break; } - try { - Reference< XQueryDefinitionsSupplier > xQuerySup; - m_xDatabaseContext->getByName( getDataSourceAcessor( pDataSourceEntry ) ) >>= xQuerySup; - if (xQuerySup.is()) + SvLBoxEntry* pParent = m_pTreeView->getListBox().GetParent(_pEntry); + if ( pParent != pDataSourceEntry ) { - Reference< XNameAccess > xQueryDefs = xQuerySup->getQueryDefinitions(); - Reference< XContainer > xCont(xQueryDefs, UNO_QUERY); - if (xCont.is()) - // add as listener to get notified if elements are inserted or removed - xCont->addContainerListener(this); + SvLBoxString* pString = (SvLBoxString*)_pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING); + OSL_ENSURE(pString,"There must be a string item!"); + ::rtl::OUString aName(pString->GetText()); + DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pParent->GetUserData()); + try + { + Reference< XNameAccess > xNameAccess(pData->xContainer,UNO_QUERY); + if ( xNameAccess.is() ) + pEntryData->xContainer.set(xNameAccess->getByName(aName),UNO_QUERY); + } + catch(const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } - pEntryData->xContainer = xQueryDefs; bSuccess = pEntryData->xContainer.is(); } - else { - DBG_ERROR("SbaTableQueryBrowser::ensureEntryObject: no XQueryDefinitionsSupplier interface!"); + else + { + try + { + Reference< XQueryDefinitionsSupplier > xQuerySup; + m_xDatabaseContext->getByName( getDataSourceAcessor( pDataSourceEntry ) ) >>= xQuerySup; + if (xQuerySup.is()) + { + Reference< XNameAccess > xQueryDefs = xQuerySup->getQueryDefinitions(); + Reference< XContainer > xCont(xQueryDefs, UNO_QUERY); + if (xCont.is()) + // add as listener to get notified if elements are inserted or removed + xCont->addContainerListener(this); + + pEntryData->xContainer = xQueryDefs; + bSuccess = pEntryData->xContainer.is(); + } + else { + DBG_ERROR("SbaTableQueryBrowser::ensureEntryObject: no XQueryDefinitionsSupplier interface!"); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } break; default: @@ -2343,7 +2415,18 @@ IMPL_LINK(SbaTableQueryBrowser, OnSelectionChange, void*, /*NOINTERESTEDIN*/) { return implSelect( m_pTreeView->getListBox().FirstSelected() ) ? 1L : 0L; } - +//------------------------------------------------------------------------------ +SvLBoxEntry* SbaTableQueryBrowser::implGetConnectionEntry(SvLBoxEntry* _pEntry) const +{ + SvLBoxEntry* pCurrentEntry = _pEntry; + DBTreeListUserData* pEntryData = static_cast< DBTreeListUserData* >( pCurrentEntry->GetUserData() ); + while(pEntryData->eType != etDatasource ) + { + pCurrentEntry = m_pTreeModel->GetParent(pCurrentEntry); + pEntryData = static_cast< DBTreeListUserData* >( pCurrentEntry->GetUserData() ); + } + return pCurrentEntry; +} //------------------------------------------------------------------------------ bool SbaTableQueryBrowser::implSelect( SvLBoxEntry* _pEntry ) { @@ -2369,7 +2452,7 @@ bool SbaTableQueryBrowser::implSelect( SvLBoxEntry* _pEntry ) DBTreeListUserData* pContainerData = static_cast<DBTreeListUserData*>(pContainer->GetUserData()); // get the entry for the datasource - SvLBoxEntry* pConnection = m_pTreeModel->GetParent(pContainer); + SvLBoxEntry* pConnection = implGetConnectionEntry(pContainer); DBTreeListUserData* pConData = static_cast<DBTreeListUserData*>(pConnection->GetUserData()); // reinitialize the rowset @@ -2380,12 +2463,26 @@ bool SbaTableQueryBrowser::implSelect( SvLBoxEntry* _pEntry ) xRowSetProps->getPropertyValue(PROPERTY_COMMAND) >>= aOldName; sal_Int32 nOldType = 0; xRowSetProps->getPropertyValue(PROPERTY_COMMAND_TYPE) >>= nOldType; - Reference<XConnection> xOldConnection; - ::cppu::extractInterface(xOldConnection,xRowSetProps->getPropertyValue(PROPERTY_ACTIVE_CONNECTION)); + Reference<XConnection> xOldConnection(xRowSetProps->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY); + // the name of the table or query SvLBoxString* pString = (SvLBoxString*)_pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING); OSL_ENSURE(pString,"There must be a string item!"); - ::rtl::OUString aName(pString->GetText().GetBuffer()); + const ::rtl::OUString sSimpleName = pString->GetText(); + ::rtl::OUStringBuffer sNameBuffer(sSimpleName); + if ( etQueryContainer == pContainerData->eType ) + { + SvLBoxEntry* pTemp = pContainer; + while( m_pTreeModel->GetParent(pTemp) != pConnection ) + { + sNameBuffer.insert(0,sal_Unicode('/')); + pString = (SvLBoxString*)pTemp->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING); + OSL_ENSURE(pString,"There must be a string item!"); + sNameBuffer.insert(0,pString->GetText()); + pTemp = m_pTreeModel->GetParent(pTemp); + } + } + ::rtl::OUString aName = sNameBuffer.makeStringAndClear(); sal_Int32 nCommandType = ( etTableContainer == pContainerData->eType) ? CommandType::TABLE @@ -2443,9 +2540,14 @@ bool SbaTableQueryBrowser::implSelect( SvLBoxEntry* _pEntry ) break; case CommandType::QUERY: { - Reference<XQueriesSupplier> xSup( pConData->xConnection, UNO_QUERY ); - if(xSup.is()) - xNameAccess = xSup->getQueries(); + if ( pContainerData->xContainer.is() ) + xNameAccess.set( pContainerData->xContainer, UNO_QUERY ); + else + { + Reference<XQueriesSupplier> xSup( pConData->xConnection, UNO_QUERY ); + if(xSup.is()) + xNameAccess = xSup->getQueries(); + } } break; } @@ -2453,13 +2555,13 @@ bool SbaTableQueryBrowser::implSelect( SvLBoxEntry* _pEntry ) sStatus.SearchAndReplaceAscii("$name$", aName); BrowserViewStatusDisplay aShowStatus(static_cast<UnoDataBrowserView*>(getView()), sStatus); - if(xNameAccess.is() && xNameAccess->hasByName(aName)) + if(xNameAccess.is() && xNameAccess->hasByName(sSimpleName)) { DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(_pEntry->GetUserData()); if ( !pData->xObjectProperties.is() ) { Reference<XInterface> xObject; - if(xNameAccess->getByName(aName) >>= xObject) // remember the table or query object + if(xNameAccess->getByName(sSimpleName) >>= xObject) // remember the table or query object { pData->xObjectProperties = pData->xObjectProperties.query( xObject ); // if the query contains a parameterized statement and preview is enabled we won't get any data. @@ -3499,7 +3601,7 @@ void SbaTableQueryBrowser::loadMenu(const Reference< XFrame >& _xFrame) { SvLBoxEntry* pContainer = m_pTreeModel->GetParent(m_pCurrentlyDisplayed); // get the entry for the datasource - SvLBoxEntry* pConnection = m_pTreeModel->GetParent(pContainer); + SvLBoxEntry* pConnection = implGetConnectionEntry(pContainer); ::rtl::OUString sName = m_pTreeView->getListBox().GetEntryText(m_pCurrentlyDisplayed); sTitle = GetEntryText( pConnection ); INetURLObject aURL(sTitle); diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.cxx b/dbaccess/source/ui/dlg/DbAdminImpl.cxx index 8b86519fa812..2449b1dc072a 100644 --- a/dbaccess/source/ui/dlg/DbAdminImpl.cxx +++ b/dbaccess/source/ui/dlg/DbAdminImpl.cxx @@ -356,6 +356,11 @@ void ODbDataSourceAdministrationHelper::clearPassword() // ----------------------------------------------------------------------------- Reference< XDriver > ODbDataSourceAdministrationHelper::getDriver() { + return getDriver(getConnectionURL()); +} +// ----------------------------------------------------------------------------- +Reference< XDriver > ODbDataSourceAdministrationHelper::getDriver(const ::rtl::OUString& _sURL) +{ // get the global DriverManager Reference< XDriverAccess > xDriverManager; String sCurrentActionError = String(ModuleRes(STR_COULDNOTCREATE_DRIVERMANAGER)); @@ -376,11 +381,11 @@ Reference< XDriver > ODbDataSourceAdministrationHelper::getDriver() throw SQLException(sCurrentActionError, getORB(), ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")), 0, Any()); - Reference< XDriver > xDriver = xDriverManager->getDriverByURL(getConnectionURL()); + Reference< XDriver > xDriver = xDriverManager->getDriverByURL(_sURL); if (!xDriver.is()) { sCurrentActionError = String(ModuleRes(STR_NOREGISTEREDDRIVER)); - sCurrentActionError.SearchAndReplaceAscii("#connurl#", getConnectionURL()); + sCurrentActionError.SearchAndReplaceAscii("#connurl#", _sURL); // will be caught and translated into an SQLContext exception throw SQLException(sCurrentActionError, getORB(), ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")), 0, Any()); } diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.hxx b/dbaccess/source/ui/dlg/DbAdminImpl.hxx index 9794e6e21bfb..445b84fd3245 100644 --- a/dbaccess/source/ui/dlg/DbAdminImpl.hxx +++ b/dbaccess/source/ui/dlg/DbAdminImpl.hxx @@ -140,6 +140,7 @@ namespace dbaui /** return the corresponding driver for the selected URL */ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver(); + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver(const ::rtl::OUString& _sURL); /** returns the data source the dialog is currently working with */ diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx index 149d0c2d2f7a..9c14bfabd17a 100644 --- a/dbaccess/source/ui/dlg/dbwizsetup.cxx +++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx @@ -945,7 +945,7 @@ sal_Bool ODbTypeWizDialogSetup::SaveDatabaseDocument() { ::rtl::OUString sEmbeddedURL = m_pCollection->getEmbeddedDatabase(); ::connectivity::DriversConfig aDriverConfig(getORB()); - if ( !aDriverConfig.getDriverFactoryName(sEmbeddedURL).getLength() ) + if ( !aDriverConfig.getDriverFactoryName(sEmbeddedURL).getLength() || m_pImpl->getDriver(sEmbeddedURL).is() ) sEmbeddedURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:")); return sEmbeddedURL; diff --git a/dbaccess/source/ui/inc/QueryDesignView.hxx b/dbaccess/source/ui/inc/QueryDesignView.hxx index 60dfb7bdec79..6a97719e0c27 100644 --- a/dbaccess/source/ui/inc/QueryDesignView.hxx +++ b/dbaccess/source/ui/inc/QueryDesignView.hxx @@ -171,6 +171,10 @@ namespace dbaui const String& _sCriteria, ::rtl::OUString& _rsErrorMessage, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxColumn) const; + + void fillFunctionInfo( const ::connectivity::OSQLParseNode* pNode + ,const ::rtl::OUString& sFunctionTerm + ,OTableFieldDescRef& aInfo); protected: // return the Rectangle where I can paint myself virtual void resizeDocumentView(Rectangle& rRect); diff --git a/dbaccess/source/ui/inc/TableFieldDescription.hxx b/dbaccess/source/ui/inc/TableFieldDescription.hxx index 80eeeff20dfa..9230bef621c3 100644 --- a/dbaccess/source/ui/inc/TableFieldDescription.hxx +++ b/dbaccess/source/ui/inc/TableFieldDescription.hxx @@ -83,6 +83,7 @@ namespace dbaui inline sal_Bool IsEmpty() const; + OTableFieldDesc& operator=( const OTableFieldDesc& _aField ); sal_Bool operator==( const OTableFieldDesc& rDesc ); sal_Bool IsVisible() const { return m_bVisible;} diff --git a/dbaccess/source/ui/inc/WCopyTable.hxx b/dbaccess/source/ui/inc/WCopyTable.hxx index 37d0d870f538..741e6f67e590 100644 --- a/dbaccess/source/ui/inc/WCopyTable.hxx +++ b/dbaccess/source/ui/inc/WCopyTable.hxx @@ -31,55 +31,23 @@ #ifndef DBAUI_WIZ_COPYTABLEDIALOG_HXX #define DBAUI_WIZ_COPYTABLEDIALOG_HXX -#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ #include <com/sun/star/container/XNameAccess.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ #include <com/sun/star/sdbc/XConnection.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ #include <com/sun/star/sdbc/XResultSet.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATA_HPP_ #include <com/sun/star/sdbc/XResultSetMetaData.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ #include <com/sun/star/sdbc/XDatabaseMetaData.hpp> -#endif -#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ #include <com/sun/star/beans/XPropertySet.hpp> -#endif -#ifndef _COMPHELPER_STLTYPES_HXX_ #include <comphelper/stl_types.hxx> -#endif -#ifndef DBAUI_TYPEINFO_HXX #include "TypeInfo.hxx" -#endif -#ifndef _SV_BUTTON_HXX #include <vcl/button.hxx> -#endif -#ifndef _SVT_WIZDLG_HXX #include <svtools/wizdlg.hxx> -#endif -#ifndef DBAUI_DATABASEEXPORT_HXX #include "DExport.hxx" -#endif -#ifndef DBAUI_WIZ_TABBPAGE_HXX #include "WTabPage.hxx" -#endif -#ifndef DBAUI_FIELDDESCRIPTIONS_HXX #include "FieldDescriptions.hxx" -#endif -#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XKeysSupplier.hpp> -#endif -#ifndef _SV_LSTBOX_HXX +#include <com/sun/star/task/XInteractionHandler.hpp> #include <vcl/lstbox.hxx> -#endif - #include <functional> namespace dbaui @@ -299,6 +267,7 @@ namespace dbaui ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xFormatter; ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xFactory; + ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler> m_xInteractionHandler; String m_sTypeNames; // these type names are the ones out of the resource file sal_uInt32 m_nPageCount; @@ -343,7 +312,8 @@ namespace dbaui const ICopyTableSourceObject& _rSourceObject, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xSourceConnection, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB, + const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler>& _xInteractionHandler ); // used for importing rtf/html sources @@ -445,6 +415,8 @@ namespace dbaui void showColumnTypeNotSupported(const ::rtl::OUString& _rColumnName); void removeColumnNameFromNameMap(const ::rtl::OUString& _sName); + void showError(const ::rtl::OUString& _sErrorMesage); + void showError(const ::com::sun::star::uno::Any& _aError); }; } diff --git a/dbaccess/source/ui/inc/dbu_misc.hrc b/dbaccess/source/ui/inc/dbu_misc.hrc index 0ee803edec10..6aeb5b1331ab 100644 --- a/dbaccess/source/ui/inc/dbu_misc.hrc +++ b/dbaccess/source/ui/inc/dbu_misc.hrc @@ -50,10 +50,12 @@ #define STR_FILE_DOES_NOT_EXIST RID_STR_MISC_START + 13 #define STR_WARNINGS_DURING_CONNECT RID_STR_MISC_START + 14 #define STR_NAMED_OBJECT_ALREADY_EXISTS RID_STR_MISC_START + 15 +#define STR_INVALID_TABLE_NAME RID_STR_MISC_START + 16 +#define STR_INVALID_TABLE_NAME_LENGTH RID_STR_MISC_START + 17 // please adjust checking before insert new strings -#if STR_NAMED_OBJECT_ALREADY_EXISTS > RID_STR_MISC_END +#if STR_INVALID_TABLE_NAME_LENGTH > RID_STR_MISC_END #error Resource-Id Ueberlauf in #file, #line #endif diff --git a/dbaccess/source/ui/inc/dbu_resource.hrc b/dbaccess/source/ui/inc/dbu_resource.hrc index e537f51df6bb..7d72e16f0f2f 100644 --- a/dbaccess/source/ui/inc/dbu_resource.hrc +++ b/dbaccess/source/ui/inc/dbu_resource.hrc @@ -182,13 +182,13 @@ // error boxes #define ERR_NOREGISTEREDDATASOURCES RID_ERRORBOX_START + 0 -#define ERROR_INVALID_TABLE_NAME_LENGTH RID_ERRORBOX_START + 1 +// free #define ERR_QRY_CRITERIA_ON_ASTERISK RID_ERRORBOX_START + 2 #define ERR_QRY_ORDERBY_ON_ASTERISK RID_ERRORBOX_START + 3 #define ERR_QRY_AMB_FIELD RID_ERRORBOX_START + 4 // FREE #define ERR_INVALID_LISTBOX_ENTRY RID_ERRORBOX_START + 6 -#define ERROR_INVALID_TABLE_NAME RID_ERRORBOX_START + 7 +// FREE #define ERR_NEED_INDEX_FIELDS RID_ERRORBOX_START + 8 #define ERR_QRY_NOSTATEMENT RID_ERRORBOX_START + 9 #define ERR_QRY_NOCRITERIA RID_ERRORBOX_START + 10 diff --git a/dbaccess/source/ui/inc/dbu_uno.hrc b/dbaccess/source/ui/inc/dbu_uno.hrc index acd15c94c7ef..6aec13955ac0 100644 --- a/dbaccess/source/ui/inc/dbu_uno.hrc +++ b/dbaccess/source/ui/inc/dbu_uno.hrc @@ -43,9 +43,12 @@ #define STR_CTW_UNSUPPORTED_COLUMN_TYPE ( RID_STR_UNO_START + 6 ) #define STR_CTW_ILLEGAL_PARAMETER_COUNT ( RID_STR_UNO_START + 7 ) #define STR_CTW_ERROR_DURING_INITIALIZATION ( RID_STR_UNO_START + 8 ) +#define STR_CTW_ERROR_UNSUPPORTED_SETTING ( RID_STR_UNO_START + 9 ) +#define STR_CTW_ERROR_NO_QUERY ( RID_STR_UNO_START + 10 ) +#define STR_CTW_ERROR_INVALID_INTERACTIONHANDLER ( RID_STR_UNO_START + 11 ) // please adjust when inserting new strings: -#define RID_STR_UNO_LAST_USED STR_CTW_ERROR_DURING_INITIALIZATION +#define RID_STR_UNO_LAST_USED STR_CTW_ERROR_INVALID_INTERACTIONHANDLER #if RID_STR_UNO_LAST_USED >= RID_STR_UNO_END #error too many resources in uno .... diff --git a/dbaccess/source/ui/inc/unodatbr.hxx b/dbaccess/source/ui/inc/unodatbr.hxx index 23d9cfd5b542..3436d565367f 100644 --- a/dbaccess/source/ui/inc/unodatbr.hxx +++ b/dbaccess/source/ui/inc/unodatbr.hxx @@ -374,7 +374,7 @@ namespace dbaui */ void closeConnection(SvLBoxEntry* _pEntry,sal_Bool _bDisposeConnection = sal_True); - sal_Bool populateTree(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xNameAccess, SvLBoxEntry* _pParent, EntryType _eEntryType); + void populateTree(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xNameAccess, SvLBoxEntry* _pParent, EntryType _eEntryType); void initializeTreeModel(); /** search in the tree for query- or tablecontainer equal to this interface and return @@ -433,8 +433,9 @@ namespace dbaui sal_Bool _bSelectDirect = sal_False ); + SvLBoxEntry* implGetConnectionEntry(SvLBoxEntry* _pEntry) const; /// inserts an entry into the tree - void implAppendEntry( + SvLBoxEntry* implAppendEntry( SvLBoxEntry* _pParent, const String& _rName, void* _pUserData, diff --git a/dbaccess/source/ui/misc/DExport.cxx b/dbaccess/source/ui/misc/DExport.cxx index 6c750f40ee61..a1b29faf1afa 100644 --- a/dbaccess/source/ui/misc/DExport.cxx +++ b/dbaccess/source/ui/misc/DExport.cxx @@ -479,6 +479,7 @@ sal_Int16 ODatabaseExport::CheckString(const String& aCheckToken, sal_Int16 _nOl case NumberFormat::DATETIME: case NumberFormat::TEXT: case NumberFormat::DATE: + nNumberFormat = _nOldNumberFormat; break; case NumberFormat::ALL: nNumberFormat = NumberFormat::DATE; @@ -494,6 +495,7 @@ sal_Int16 ODatabaseExport::CheckString(const String& aCheckToken, sal_Int16 _nOl case NumberFormat::DATETIME: case NumberFormat::TEXT: case NumberFormat::TIME: + nNumberFormat = _nOldNumberFormat; break; case NumberFormat::ALL: nNumberFormat = NumberFormat::TIME; @@ -510,6 +512,7 @@ sal_Int16 ODatabaseExport::CheckString(const String& aCheckToken, sal_Int16 _nOl nNumberFormat = NumberFormat::CURRENCY; break; case NumberFormat::CURRENCY: + nNumberFormat = _nOldNumberFormat; break; case NumberFormat::ALL: nNumberFormat = NumberFormat::CURRENCY; @@ -526,6 +529,7 @@ sal_Int16 ODatabaseExport::CheckString(const String& aCheckToken, sal_Int16 _nOl switch(_nOldNumberFormat) { case NumberFormat::NUMBER: + nNumberFormat = _nOldNumberFormat; break; case NumberFormat::CURRENCY: nNumberFormat = NumberFormat::CURRENCY; @@ -549,6 +553,7 @@ sal_Int16 ODatabaseExport::CheckString(const String& aCheckToken, sal_Int16 _nOl case NumberFormat::DATETIME: case NumberFormat::TEXT: case NumberFormat::TIME: + nNumberFormat = _nOldNumberFormat; break; case NumberFormat::ALL: nNumberFormat = NumberFormat::DATETIME; diff --git a/dbaccess/source/ui/misc/HtmlReader.cxx b/dbaccess/source/ui/misc/HtmlReader.cxx index 4c9fb3ded1bb..18fc9d528b57 100644 --- a/dbaccess/source/ui/misc/HtmlReader.cxx +++ b/dbaccess/source/ui/misc/HtmlReader.cxx @@ -509,6 +509,8 @@ sal_Bool OHTMLReader::CreateTable(int nToken) else if ( m_sCurrent.Len() ) aColumnName = m_sCurrent; + aColumnName.EraseLeadingChars(); + aColumnName.EraseTrailingChars(); CreateDefaultColumn(aColumnName); aColumnName.Erase(); m_sCurrent.Erase(); @@ -553,6 +555,8 @@ sal_Bool OHTMLReader::CreateTable(int nToken) if ( m_sCurrent.Len() ) aColumnName = m_sCurrent; + aColumnName.EraseLeadingChars(); + aColumnName.EraseTrailingChars(); if(aColumnName.Len()) CreateDefaultColumn(aColumnName); diff --git a/dbaccess/source/ui/misc/WCPage.cxx b/dbaccess/source/ui/misc/WCPage.cxx index 63a910929836..85804dec9d0c 100644 --- a/dbaccess/source/ui/misc/WCPage.cxx +++ b/dbaccess/source/ui/misc/WCPage.cxx @@ -227,7 +227,8 @@ sal_Bool OCopyTable::LeavePage() if ( !aNameCheck.isNameValid( m_edTableName.GetText(), aErrorInfo ) ) { aErrorInfo.append( SQLExceptionInfo::SQL_CONTEXT, String( ModuleRes( STR_SUGGEST_APPEND_TABLE_DATA ) ) ); - ::dbaui::showError( aErrorInfo, m_pParent, m_pParent->m_xFactory ); + m_pParent->showError(aErrorInfo.get()); + return sal_False; } @@ -245,7 +246,8 @@ sal_Bool OCopyTable::LeavePage() sal_Int32 nMaxLength = xMeta->getMaxTableNameLength(); if ( nMaxLength && sTable.getLength() > nMaxLength ) { - ErrorBox(this, ModuleRes(ERROR_INVALID_TABLE_NAME_LENGTH)).Execute(); + String sError(ModuleRes(STR_INVALID_TABLE_NAME_LENGTH)); + m_pParent->showError(sError); return sal_False; } @@ -256,8 +258,7 @@ sal_Bool OCopyTable::LeavePage() String aInfoString( ModuleRes(STR_WIZ_PKEY_ALREADY_DEFINED) ); aInfoString += String(' '); aInfoString += String(m_pParent->m_aKeyName); - InfoBox aNameInfoBox( this, aInfoString ); - aNameInfoBox.Execute(); + m_pParent->showError(aInfoString); return sal_False; } } @@ -288,7 +289,8 @@ sal_Bool OCopyTable::LeavePage() if(!m_pParent->m_sName.getLength()) { - ErrorBox(this, ModuleRes(ERROR_INVALID_TABLE_NAME)).Execute(); + String sError(ModuleRes(STR_INVALID_TABLE_NAME)); + m_pParent->showError(sError); return sal_False; } @@ -367,9 +369,8 @@ sal_Bool OCopyTable::checkAppendData() if ( !xTable.is() ) { - ErrorBox( this, ModuleRes( ERROR_INVALID_TABLE_NAME ) ).Execute(); - // TODO: shouldn't this be some kind of showError? In case of the UNO service for this wizard, - // shouldn't this even be a usage of the service's interaction handler? + String sError(ModuleRes(STR_INVALID_TABLE_NAME)); + m_pParent->showError(sError); return sal_False; } return sal_True; diff --git a/dbaccess/source/ui/misc/WColumnSelect.cxx b/dbaccess/source/ui/misc/WColumnSelect.cxx index 69d5c3bad4fd..12173965f739 100644 --- a/dbaccess/source/ui/misc/WColumnSelect.cxx +++ b/dbaccess/source/ui/misc/WColumnSelect.cxx @@ -140,6 +140,7 @@ void OWizColumnSelect::Reset() clearListBox(m_lbOrgColumnNames); clearListBox(m_lbNewColumnNames); + m_pParent->m_mNameMapping.clear(); // insert the source columns in the left listbox const ODatabaseExport::TColumnVector* pSrcColumns = m_pParent->getSrcVector(); diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx index 2b664c02f7e2..1cdf6156a789 100644 --- a/dbaccess/source/ui/misc/WCopyTable.cxx +++ b/dbaccess/source/ui/misc/WCopyTable.cxx @@ -46,6 +46,7 @@ /** === begin UNO includes === **/ #include <com/sun/star/sdb/application/CopyTableOperation.hpp> +#include <com/sun/star/sdb/SQLContext.hpp> #include <com/sun/star/sdbc/ColumnValue.hpp> #include <com/sun/star/sdbc/DataType.hpp> #include <com/sun/star/sdbc/XResultSet.hpp> @@ -62,8 +63,10 @@ #include <comphelper/extract.hxx> #include <comphelper/types.hxx> +#include <comphelper/interaction.hxx> #include <connectivity/dbtools.hxx> #include <connectivity/dbmetadata.hxx> +#include <connectivity/dbexception.hxx> #include <rtl/logfile.hxx> #include <rtl/ustrbuf.hxx> @@ -80,9 +83,12 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; using namespace ::com::sun::star::util; +using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::task; +using namespace dbtools; namespace CopyTableOperation = ::com::sun::star::sdb::application::CopyTableOperation; @@ -566,7 +572,8 @@ namespace //------------------------------------------------------------------------ OCopyTableWizard::OCopyTableWizard( Window * pParent, const ::rtl::OUString& _rDefaultName, sal_Int16 _nOperation, const ICopyTableSourceObject& _rSourceObject, const Reference< XConnection >& _xSourceConnection, - const Reference< XConnection >& _xConnection, const Reference< XMultiServiceFactory >& _rxORB ) + const Reference< XConnection >& _xConnection, const Reference< XMultiServiceFactory >& _rxORB, + const Reference< XInteractionHandler>& _xInteractionHandler) : WizardDialog( pParent, ModuleRes(WIZ_RTFCOPYTABLE)) ,m_pbHelp( this , ModuleRes(PB_HELP)) ,m_pbCancel( this , ModuleRes(PB_CANCEL)) @@ -578,6 +585,7 @@ OCopyTableWizard::OCopyTableWizard( Window * pParent, const ::rtl::OUString& _rD ,m_rSourceObject( _rSourceObject ) ,m_xFormatter( getNumberFormatter( _xConnection, _rxORB ) ) ,m_xFactory(_rxORB) + ,m_xInteractionHandler(_xInteractionHandler) ,m_sTypeNames(ModuleRes(STR_TABLEDESIGN_DBFIELDTYPES)) ,m_nPageCount(0) ,m_bDeleteSourceColumns(sal_True) @@ -924,6 +932,7 @@ IMPL_LINK( OCopyTableWizard, ImplOKHdl, OKButton*, EMPTYARG ) OWizTypeSelect* pPage = static_cast<OWizTypeSelect*>(GetPage(3)); if ( pPage ) { + m_mNameMapping.clear(); pPage->setDisplayRow(nBreakPos); ShowPage(3); return 0; @@ -935,33 +944,37 @@ IMPL_LINK( OCopyTableWizard, ImplOKHdl, OKButton*, EMPTYARG ) { ODatabaseExport::TColumns::iterator aFind = ::std::find_if(m_vDestColumns.begin(),m_vDestColumns.end() ,::std::compose1(::std::mem_fun(&OFieldDescription::IsPrimaryKey),::std::select2nd<ODatabaseExport::TColumns::value_type>())); - if ( aFind == m_vDestColumns.end() ) + if ( aFind == m_vDestColumns.end() && m_xInteractionHandler.is() ) { + String sTitle(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY_HEAD)); String sMsg(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY)); - OSQLMessageBox aBox(this, sTitle,sMsg, WB_YES_NO_CANCEL | WB_DEF_YES); - - INT16 nReturn = aBox.Execute(); - - switch(nReturn ) + SQLContext aError; + aError.Message = sMsg; + ::rtl::Reference< ::comphelper::OInteractionRequest > xRequest( new ::comphelper::OInteractionRequest( makeAny( aError ) ) ); + ::rtl::Reference< ::comphelper::OInteractionApprove > xYes = new ::comphelper::OInteractionApprove; + xRequest->addContinuation( xYes.get() ); + xRequest->addContinuation( new ::comphelper::OInteractionDisapprove ); + ::rtl::Reference< ::comphelper::OInteractionAbort > xAbort = new ::comphelper::OInteractionAbort; + xRequest->addContinuation( xAbort.get() ); + + m_xInteractionHandler->handle( xRequest.get() ); + + if ( xYes->wasSelected() ) + { + OCopyTable* pPage = static_cast<OCopyTable*>(GetPage(0)); + m_bCreatePrimaryKeyColumn = sal_True; + m_aKeyName = pPage->GetKeyName(); + if ( !m_aKeyName.getLength() ) + m_aKeyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ID" ) ); + m_aKeyName = createUniqueName( m_aKeyName ); + sal_Int32 nBreakPos2 = 0; + CheckColumns(nBreakPos2); + } + else if ( xAbort->wasSelected() ) { - case RET_YES: - { - OCopyTable* pPage = static_cast<OCopyTable*>(GetPage(0)); - m_bCreatePrimaryKeyColumn = sal_True; - m_aKeyName = pPage->GetKeyName(); - if ( !m_aKeyName.getLength() ) - m_aKeyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ID" ) ); - m_aKeyName = createUniqueName( m_aKeyName ); - sal_Int32 nBreakPos2 = 0; - CheckColumns(nBreakPos2); - break; - } - case RET_CANCEL: - ShowPage(3); - return 0; - default: - ; + ShowPage(3); + return 0; } } } @@ -1601,6 +1614,22 @@ TOTypeInfoSP OCopyTableWizard::convertType(const TOTypeInfoSP& _pType,sal_Bool& if ( supportsType(DataType::CLOB,nDefaultType) ) break; break; + case DataType::BINARY: + if ( supportsType(DataType::VARBINARY,nDefaultType) ) + break; + break; + case DataType::VARBINARY: + if ( supportsType(DataType::LONGVARBINARY,nDefaultType) ) + break; + break; + case DataType::LONGVARBINARY: + if ( supportsType(DataType::BLOB,nDefaultType) ) + break; + if ( supportsType(DataType::LONGVARCHAR,nDefaultType) ) + break; + if ( supportsType(DataType::CLOB,nDefaultType) ) + break; + break; default: nDefaultType = DataType::VARCHAR; } @@ -1646,7 +1675,28 @@ void OCopyTableWizard::showColumnTypeNotSupported(const ::rtl::OUString& _rColum RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::showColumnTypeNotSupported" ); String sMessage( ModuleRes( STR_UNKNOWN_TYPE_FOUND ) ); sMessage.SearchAndReplaceAscii("#1",_rColumnName); - - OSQLWarningBox( this, sMessage ).Execute(); + showError(sMessage); +} +//------------------------------------------------------------------------------- +void OCopyTableWizard::showError(const ::rtl::OUString& _sErrorMesage) +{ + SQLExceptionInfo aInfo(_sErrorMesage); + showError(aInfo.get()); } //------------------------------------------------------------------------------- +void OCopyTableWizard::showError(const Any& _aError) +{ + if ( _aError.hasValue() && m_xInteractionHandler.is() ) + { + try + { + ::rtl::Reference< ::comphelper::OInteractionRequest > xRequest( new ::comphelper::OInteractionRequest( _aError ) ); + m_xInteractionHandler->handle( xRequest.get() ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } +} + diff --git a/dbaccess/source/ui/misc/WTypeSelect.cxx b/dbaccess/source/ui/misc/WTypeSelect.cxx index ceeb058528df..2d2d6e5ed241 100644 --- a/dbaccess/source/ui/misc/WTypeSelect.cxx +++ b/dbaccess/source/ui/misc/WTypeSelect.cxx @@ -178,7 +178,7 @@ void OWizTypeSelectControl::CellModified(long nRow, sal_uInt16 nColId ) { String strMessage = String(ModuleRes(STR_TABLEDESIGN_DUPLICATE_NAME)); strMessage.SearchAndReplaceAscii("$column$", sNewName); - OSQLWarningBox( this, strMessage ).Execute(); + pWiz->showError(strMessage); pCurFieldDescr->SetName(sName); DisplayData(pCurFieldDescr); static_cast<OWizTypeSelect*>(GetParent())->setDuplicateName(sal_True); @@ -323,6 +323,8 @@ IMPL_LINK( OWizTypeSelect, ColumnSelectHdl, MultiListBox *, /*pListBox*/ ) OFieldDescription* pField = static_cast<OFieldDescription*>(m_lbColumnNames.GetEntryData(m_lbColumnNames.GetEntryPos(aColumnName))); if(pField) m_aTypeControl.DisplayData(pField); + + m_aTypeControl.Enable(m_lbColumnNames.GetSelectEntryCount() == 1 ); return 0; } // ----------------------------------------------------------------------- diff --git a/dbaccess/source/ui/misc/WizardPages.src b/dbaccess/source/ui/misc/WizardPages.src index 638feb92e54c..329f08b222d9 100644 --- a/dbaccess/source/ui/misc/WizardPages.src +++ b/dbaccess/source/ui/misc/WizardPages.src @@ -552,20 +552,18 @@ String STR_COPYTABLE_TITLE_COPY Text [ en-US ] = "Copy table" ; }; -ErrorBox ERROR_INVALID_TABLE_NAME +String STR_INVALID_TABLE_NAME { - Buttons = WB_OK; - Message [ en-US ] = "This table name is not valid in the current database."; + Text [ en-US ] = "This table name is not valid in the current database."; }; String STR_SUGGEST_APPEND_TABLE_DATA { Text [ en-US ] = "Choose the option 'Append data' on the first page to append data to an existing table."; }; -ErrorBox ERROR_INVALID_TABLE_NAME_LENGTH +String STR_INVALID_TABLE_NAME_LENGTH { - Buttons = WB_OK; - Message [ en-US ] = "Please change the table name. It is too long."; + Text [ en-US ] = "Please change the table name. It is too long."; }; Image IMG_SORTUP_H diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index b8fd1f5f972f..83ed283a4836 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -186,11 +186,6 @@ namespace sal_Bool bHaving, bool _bAddOrOnOneLine); - void fillFunctionInfo( OQueryDesignView* _pView - ,const ::connectivity::OSQLParseNode* pNode - ,const ::rtl::OUString& sFunctionTerm - ,OTableFieldDescRef& aInfo); - //------------------------------------------------------------------------------ ::rtl::OUString quoteTableAlias(sal_Bool _bQuote, const ::rtl::OUString& _sAliasName, const ::rtl::OUString& _sQuote) { @@ -2180,35 +2175,6 @@ namespace return eErrorCode; } //------------------------------------------------------------------------------ - void fillFunctionInfo( OQueryDesignView* _pView - ,const ::connectivity::OSQLParseNode* pNode - ,const ::rtl::OUString& sFunctionTerm - ,OTableFieldDescRef& aInfo) - { - // get the type out of the funtion name - OQueryController& rController = static_cast<OQueryController&>(_pView->getController()); - sal_Int32 nDataType = DataType::DOUBLE; - ::rtl::OUString sFieldName = sFunctionTerm; - OSQLParseNode* pFunctionName = pNode->getChild(0); - if ( !SQL_ISPUNCTUATION(pFunctionName,"{") ) - { - if ( SQL_ISRULEOR2(pNode,length_exp,char_value_fct) ) - pFunctionName = pFunctionName->getChild(0); - - ::rtl::OUString sFunctionName = pFunctionName->getTokenValue(); - if ( !sFunctionName.getLength() ) - sFunctionName = ::rtl::OStringToOUString(OSQLParser::TokenIDToStr(pFunctionName->getTokenID()),RTL_TEXTENCODING_UTF8); - - nDataType = OSQLParser::getFunctionReturnType( - sFunctionName - ,&rController.getParser().getContext()); - } - aInfo->SetDataType(nDataType); - aInfo->SetFieldType(TAB_NORMAL_FIELD); - aInfo->SetField(sFieldName); - aInfo->SetTabWindow(NULL); - } - //------------------------------------------------------------------------------ SqlParseError InstallFields(OQueryDesignView* _pView, const ::connectivity::OSQLParseNode* pNode, OJoinTableView::OTableWindowMap* pTabList ) @@ -2216,7 +2182,7 @@ namespace if( pNode==0 || !SQL_ISRULE(pNode,select_statement)) return eNoSelectStatement; - ::connectivity::OSQLParseNode* pParseTree = pNode->getChild(2); + ::connectivity::OSQLParseNode* pParseTree = pNode->getChild(2); // selection sal_Bool bFirstField = sal_True; // bei der Initialisierung mu auf alle Faelle das erste Feld neu aktiviert werden SqlParseError eErrorCode = eOk; @@ -2247,9 +2213,6 @@ namespace if ( SQL_ISRULE(pColumnRef,derived_column) ) { - if ( !xConnection.is() ) - break; - ::rtl::OUString aColumnAlias(rController.getParseIterator().getColumnAlias(pColumnRef)); // kann leer sein pColumnRef = pColumnRef->getChild(0); OTableFieldDescRef aInfo = new OTableFieldDesc(); @@ -2330,7 +2293,7 @@ namespace } else { - fillFunctionInfo(_pView,pColumnRef,aColumns,aInfo); + _pView->fillFunctionInfo(pColumnRef,aColumns,aInfo); aInfo->SetFieldAlias(aColumnAlias); } @@ -2451,7 +2414,7 @@ namespace _pView->getLocale(), static_cast<sal_Char>(_pView->getDecimalSeparator().toChar()), &rController.getParser().getContext()); - fillFunctionInfo(_pView,pArgument,sCondition,aDragLeft); + _pView->fillFunctionInfo(pArgument,sCondition,aDragLeft); aDragLeft->SetFunctionType(FKT_OTHER); aDragLeft->SetOrderDir(eOrderDir); aDragLeft->SetVisible(sal_False); @@ -2483,7 +2446,7 @@ namespace const ::connectivity::OSQLParseNode* pSelectRoot ) { SqlParseError eErrorCode = eOk; - if (!pSelectRoot->getChild(3)->getChild(2)->isLeaf()) + if (!pSelectRoot->getChild(3)->getChild(2)->isLeaf()) // opt_group_by_clause { OQueryController& rController = static_cast<OQueryController&>(_pView->getController()); ::connectivity::OSQLParseNode* pGroupBy = pSelectRoot->getChild(3)->getChild(2)->getChild(2); @@ -2518,7 +2481,7 @@ namespace &rController.getParser().getContext(), sal_True, sal_True); // quote is to true because we need quoted elements inside the function - fillFunctionInfo(_pView,pArgument,sGroupByExpression,aDragInfo); + _pView->fillFunctionInfo(pArgument,sGroupByExpression,aDragInfo); aDragInfo->SetFunctionType(FKT_OTHER); aDragInfo->SetGroupBy(sal_True); aDragInfo->SetVisible(sal_False); @@ -3242,4 +3205,32 @@ bool OQueryDesignView::initByParseIterator( ::dbtools::SQLExceptionInfo* _pError } return eErrorCode == eOk; } +//------------------------------------------------------------------------------ +void OQueryDesignView::fillFunctionInfo( const ::connectivity::OSQLParseNode* pNode + ,const ::rtl::OUString& sFunctionTerm + ,OTableFieldDescRef& aInfo) +{ + // get the type out of the funtion name + OQueryController& rController = static_cast<OQueryController&>(getController()); + sal_Int32 nDataType = DataType::DOUBLE; + ::rtl::OUString sFieldName = sFunctionTerm; + OSQLParseNode* pFunctionName = pNode->getChild(0); + if ( !SQL_ISPUNCTUATION(pFunctionName,"{") ) + { + if ( SQL_ISRULEOR2(pNode,length_exp,char_value_fct) ) + pFunctionName = pFunctionName->getChild(0); + + ::rtl::OUString sFunctionName = pFunctionName->getTokenValue(); + if ( !sFunctionName.getLength() ) + sFunctionName = ::rtl::OStringToOUString(OSQLParser::TokenIDToStr(pFunctionName->getTokenID()),RTL_TEXTENCODING_UTF8); + + nDataType = OSQLParser::getFunctionReturnType( + sFunctionName + ,&rController.getParser().getContext()); + } + aInfo->SetDataType(nDataType); + aInfo->SetFieldType(TAB_NORMAL_FIELD); + aInfo->SetField(sFieldName); + aInfo->SetTabWindow(NULL); +} // ----------------------------------------------------------------------------- diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index 27ad175c071c..16fd0a9211ef 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -757,11 +757,22 @@ sal_Bool OSelectionBrowseBox::saveField(const String& _sFieldName,OTableFieldDes bool bInternational = ( nPass % 2 ) == 0; ::rtl::OUString sSql; - sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT ")); if ( bQuote ) sSql += ::dbtools::quoteName( xMetaData->getIdentifierQuoteString(), _sFieldName ); else sSql += _sFieldName; + + if ( _pEntry->isAggreateFunction() ) + { + DBG_ASSERT(_pEntry->GetFunction().getLength(),"Functionname darf hier nicht leer sein! ;-("); + ::rtl::OUStringBuffer aTmpStr2( _pEntry->GetFunction()); + aTmpStr2.appendAscii("("); + aTmpStr2.append(sSql); + aTmpStr2.appendAscii(")"); + sSql = aTmpStr2.makeStringAndClear(); + } + + sSql = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT ")) + sSql; if ( sFieldAlias.getLength() ) { // always quote the alias name there canbe no function in it sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ")); @@ -890,78 +901,56 @@ sal_Bool OSelectionBrowseBox::saveField(const String& _sFieldName,OTableFieldDes OSL_ENSURE(0,"Unsupported function inserted!"); } - else if( SQL_ISRULEOR2(pColumnRef,position_exp,extract_exp) || - SQL_ISRULEOR2(pColumnRef,fold,char_substring_fct) || - SQL_ISRULEOR2(pColumnRef,length_exp,char_value_fct) ) - // a calculation has been found ( can be calc and function ) + else { - // append the whole text as field name // so we first clear the function field clearEntryFunctionField(_sFieldName,aSelEntry,_bListAction,nColumnId); - sal_Bool bQuote = sal_True; - sal_Int32 nDataType = DataType::DOUBLE; - OSQLParseNode* pFunctionName = pColumnRef->getChild(0); - if ( !SQL_ISPUNCTUATION(pFunctionName,"{") ) + ::rtl::OUString sFunction; + pColumnRef->parseNodeToStr( sFunction, + xConnection, + &rController.getParser().getContext(), + sal_True, + sal_True); // quote is to true because we need quoted elements inside the function + + getDesignView()->fillFunctionInfo(pColumnRef,sFunction,aSelEntry); + + if( SQL_ISRULEOR2(pColumnRef,position_exp,extract_exp) || + SQL_ISRULEOR2(pColumnRef,fold,char_substring_fct) || + SQL_ISRULEOR2(pColumnRef,length_exp,char_value_fct) ) + // a calculation has been found ( can be calc and function ) { - if ( SQL_ISRULEOR2(pColumnRef,length_exp,char_value_fct) ) - pFunctionName = pFunctionName->getChild(0); + // now parse the whole statement + sal_uInt32 nFunCount = pColumnRef->count(); + ::rtl::OUString sParameters; + for(sal_uInt32 function = 0; function < nFunCount; ++function) + pColumnRef->getChild(function)->parseNodeToStr( sParameters, xConnection, &rParser.getContext(), sal_True, sal_True ); - if ( pFunctionName ) + sOldAlias = aSelEntry->GetAlias(); + sal_Int32 nNewFunctionType = aSelEntry->GetFunctionType() | FKT_NUMERIC | FKT_OTHER; + aSelEntry->SetFunctionType(nNewFunctionType); + aSelEntry->SetField(sParameters); + } + else + { + aSelEntry->SetFieldAlias(sColumnAlias); + if ( SQL_ISRULE(pColumnRef,set_fct_spec) ) + aSelEntry->SetFunctionType(/*FKT_NUMERIC | */FKT_OTHER); + else { - ::rtl::OUString sFunctionName = pFunctionName->getTokenValue(); - if ( !sFunctionName.getLength() ) - sFunctionName = ::rtl::OStringToOUString(OSQLParser::TokenIDToStr(pFunctionName->getTokenID()),RTL_TEXTENCODING_MS_1252); - - nDataType = OSQLParser::getFunctionReturnType( - sFunctionName - ,&rController.getParser().getContext()); - aSelEntry->SetDataType(nDataType); + if ( SQL_ISRULEOR2(pColumnRef,num_value_exp,term) || SQL_ISRULE(pColumnRef,factor) ) + aSelEntry->SetDataType(DataType::DOUBLE); + else if ( SQL_ISRULE(pColumnRef,value_exp) ) + aSelEntry->SetDataType(DataType::TIMESTAMP); + else + aSelEntry->SetDataType(DataType::VARCHAR); + aSelEntry->SetFunctionType(FKT_NUMERIC | FKT_OTHER); } } - - // now parse the whole statement - sal_uInt32 nFunCount = pColumnRef->count(); - ::rtl::OUString sParameters; - for(sal_uInt32 function = 0; function < nFunCount; ++function) - pColumnRef->getChild(function)->parseNodeToStr( sParameters, xConnection, &rParser.getContext(), sal_True, bQuote ); - - ::rtl::OUString aSelectionAlias = aSelEntry->GetAlias(); aSelEntry->SetAlias(::rtl::OUString()); - - sal_Int32 nNewFunctionType = aSelEntry->GetFunctionType() | FKT_NUMERIC | FKT_OTHER; - aSelEntry->SetFunctionType(nNewFunctionType); - - - aSelEntry->SetFieldType(TAB_NORMAL_FIELD); - - aSelEntry->SetTabWindow(NULL); - - aSelEntry->SetField(sParameters); - notifyTableFieldChanged(aSelectionAlias,aSelEntry->GetAlias(),_bListAction, nColumnId); - } - else - { - clearEntryFunctionField(_sFieldName,aSelEntry,_bListAction,nColumnId); - - ::rtl::OUString aColumns; - pColumnRef->parseNodeToStr( aColumns, - xConnection, - &rController.getParser().getContext(), - sal_True, - sal_True); - // get the type out of the funtion name - sal_Int32 nDataType = DataType::DOUBLE; - aSelEntry->SetDataType(nDataType); - aSelEntry->SetField(aColumns); - aSelEntry->SetFieldType(TAB_NORMAL_FIELD); - aSelEntry->SetTabWindow(NULL); - aSelEntry->SetAlias(::rtl::OUString()); - aSelEntry->SetFieldAlias(sColumnAlias); - aSelEntry->SetFunctionType(FKT_NUMERIC | FKT_OTHER); - notifyTableFieldChanged(sOldAlias,aSelEntry->GetAlias(),_bListAction, nColumnId); } + } if ( i > 0 && InsertField(aSelEntry,BROWSER_INVALIDID,sal_True,sal_False).isEmpty() ) // may we have to append more than one field { // the field could not be isnerted @@ -1807,25 +1796,23 @@ void OSelectionBrowseBox::AddGroupBy( const OTableFieldDescRef& rInfo , sal_uInt pEntry->GetFunctionType() == rInfo->GetFunctionType() && pEntry->GetFunction() == rInfo->GetFunction()) { - /*sal_uInt32 nPos = aIter - rFields.begin(); - bAppend = _nCurrentPos > nPos && (rInfo->IsGroupBy() != pEntry->IsGroupBy()); - if ( bAppend ) + if ( pEntry->isNumericOrAggreateFunction() && rInfo->IsGroupBy() ) + { + pEntry->SetGroupBy(sal_False); aIter = rFields.end(); - else*/ + break; + } + else { - if ( pEntry->isNumericOrAggreateFunction() && rInfo->IsGroupBy() ) - { - pEntry->SetGroupBy(sal_False); - aIter = rFields.end(); - } - else + if ( !pEntry->IsGroupBy() && !pEntry->HasCriteria() ) // here we have a where condition which is no having clause { pEntry->SetGroupBy(rInfo->IsGroupBy()); if(!m_bGroupByUnRelated && pEntry->IsGroupBy()) pEntry->SetVisible(sal_True); + break; } } - break; + } } @@ -1887,13 +1874,14 @@ void OSelectionBrowseBox::AddCondition( const OTableFieldDescRef& rInfo, const S if (bCase(aField,rInfo->GetField()) && bCase(aAlias,rInfo->GetAlias()) && pEntry->GetFunctionType() == rInfo->GetFunctionType() && - pEntry->GetFunction() == rInfo->GetFunction()) + pEntry->GetFunction() == rInfo->GetFunction() && + pEntry->IsGroupBy() == rInfo->IsGroupBy() ) { if ( pEntry->isNumericOrAggreateFunction() && rInfo->IsGroupBy() ) pEntry->SetGroupBy(sal_False); else { - pEntry->SetGroupBy(rInfo->IsGroupBy()); +// pEntry->SetGroupBy(rInfo->IsGroupBy()); if(!m_bGroupByUnRelated && pEntry->IsGroupBy()) pEntry->SetVisible(sal_True); } @@ -2890,7 +2878,7 @@ bool OSelectionBrowseBox::HasFieldByAliasName(const ::rtl::OUString& rFieldName, { if ( (*aIter)->GetFieldAlias() == rFieldName ) { - rInfo = *aIter; + rInfo.getBody() = (*aIter).getBody(); break; } } diff --git a/dbaccess/source/ui/querydesign/TableFieldDescription.cxx b/dbaccess/source/ui/querydesign/TableFieldDescription.cxx index 0949c8f5dc11..a00bc3dbd54c 100644 --- a/dbaccess/source/ui/querydesign/TableFieldDescription.cxx +++ b/dbaccess/source/ui/querydesign/TableFieldDescription.cxx @@ -69,24 +69,10 @@ OTableFieldDesc::OTableFieldDesc() //------------------------------------------------------------------------------ OTableFieldDesc::OTableFieldDesc(const OTableFieldDesc& rRS) : ::vos::OReference() - ,m_vecCriteria( rRS.m_vecCriteria) - ,m_aTableName(rRS.GetTable()) - ,m_aAliasName(rRS.GetAlias()) // table range - ,m_aFieldName(rRS.GetField()) // column - ,m_aFieldAlias(rRS.GetFieldAlias()) // column alias - ,m_aFunctionName(rRS.GetFunction()) // Funktionsname - ,m_pTabWindow(rRS.GetTabWindow()) - ,m_eDataType(rRS.GetDataType()) - ,m_eFunctionType( rRS.GetFunctionType() ) - ,m_eFieldType(rRS.GetFieldType()) - ,m_eOrderDir(rRS.GetOrderDir()) - ,m_nIndex(rRS.GetFieldIndex()) - ,m_nColWidth(rRS.GetColWidth()) - ,m_nColumnId( rRS.m_nColumnId) - ,m_bGroupBy(rRS.IsGroupBy()) - ,m_bVisible(rRS.IsVisible()) + { DBG_CTOR(OTableFieldDesc,NULL); + *this = rRS; } //------------------------------------------------------------------------------ @@ -107,7 +93,31 @@ OTableFieldDesc::~OTableFieldDesc() { DBG_DTOR(OTableFieldDesc,NULL); } - +//------------------------------------------------------------------------------ +OTableFieldDesc& OTableFieldDesc::operator=( const OTableFieldDesc& rRS ) +{ + if (&rRS == this) + return *this; + + m_vecCriteria = rRS.m_vecCriteria; + m_aTableName = rRS.GetTable(); + m_aAliasName = rRS.GetAlias(); // table range + m_aFieldName = rRS.GetField(); // column + m_aFieldAlias = rRS.GetFieldAlias(); // column alias + m_aFunctionName = rRS.GetFunction(); // Funktionsname + m_pTabWindow = rRS.GetTabWindow(); + m_eDataType = rRS.GetDataType(); + m_eFunctionType = rRS.GetFunctionType(); + m_eFieldType = rRS.GetFieldType(); + m_eOrderDir = rRS.GetOrderDir(); + m_nIndex = rRS.GetFieldIndex(); + m_nColWidth = rRS.GetColWidth(); + m_nColumnId = rRS.m_nColumnId; + m_bGroupBy = rRS.IsGroupBy(); + m_bVisible = rRS.IsVisible(); + + return *this; +} //------------------------------------------------------------------------------ sal_Bool OTableFieldDesc::operator==( const OTableFieldDesc& rDesc ) { diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx index ce79281f0cac..aa2b87fca329 100644 --- a/dbaccess/source/ui/uno/copytablewizard.cxx +++ b/dbaccess/source/ui/uno/copytablewizard.cxx @@ -70,6 +70,7 @@ #include <comphelper/interaction.hxx> #include <comphelper/namedvaluecollection.hxx> #include <comphelper/proparrhlp.hxx> +#include <comphelper/string.hxx> #include <connectivity/dbexception.hxx> #include <connectivity/dbtools.hxx> #include <cppuhelper/exc_hlp.hxx> @@ -775,9 +776,8 @@ void CopyTableWizard::impl_checkForUnsupportedSettings_throw( const Reference< X if ( sUnsupportedSetting.getLength() != 0 ) { - ::rtl::OUString sMessage( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Unsupported setting in the copy source descriptor: $name$." ) ) ); - // TODO: resource - sMessage = sMessage.replaceAt( sMessage.indexOfAsciiL( "$name$", 6 ), 6, sUnsupportedSetting ); + ::rtl::OUString sMessage( String(ModuleRes( STR_CTW_ERROR_UNSUPPORTED_SETTING )) ); + ::comphelper::string::searchAndReplaceAsciiI( sMessage, "$name$", sUnsupportedSetting ); throw IllegalArgumentException( sMessage, *const_cast< CopyTableWizard* >( this ), @@ -849,8 +849,7 @@ void CopyTableWizard::impl_checkForUnsupportedSettings_throw( const Reference< X if ( _out_rCommandType == CommandType::QUERY ) // we cannot copy a query if the connection cannot provide it ... throw IllegalArgumentException( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "To copy a query, your connection must be able to provide queries." ) ), - // TODO: resource + String(ModuleRes( STR_CTW_ERROR_NO_QUERY )), *const_cast< CopyTableWizard* >( this ), 1 ); @@ -1516,8 +1515,7 @@ void SAL_CALL CopyTableWizard::initialize( const Sequence< Any >& _rArguments ) { // ->createWithInteractionHandler if ( !( _rArguments[2] >>= m_xInteractionHandler ) ) throw IllegalArgumentException( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "The given interaction handler is invalid." ) ), - // TODO: resource + String(ModuleRes( STR_CTW_ERROR_INVALID_INTERACTIONHANDLER )), *this, 3 ); @@ -1578,7 +1576,8 @@ Dialog* CopyTableWizard::createDialog( Window* _pParent ) *m_pSourceObject, m_xSourceConnection.getTyped(), m_xDestConnection.getTyped(), - m_aContext.getLegacyServiceFactory() + m_aContext.getLegacyServiceFactory(), + m_xInteractionHandler ); impl_attributesToDialog_nothrow( *pWizard ); diff --git a/dbaccess/source/ui/uno/copytablewizard.src b/dbaccess/source/ui/uno/copytablewizard.src index 07db51196ce2..4bb6efc839cc 100644 --- a/dbaccess/source/ui/uno/copytablewizard.src +++ b/dbaccess/source/ui/uno/copytablewizard.src @@ -69,3 +69,15 @@ String STR_CTW_ERROR_DURING_INITIALIZATION { Text [ en-US ] = "An error occurred during initialization."; }; +String STR_CTW_ERROR_UNSUPPORTED_SETTING +{ + Text [ en-US ] = "Unsupported setting in the copy source descriptor: $name$."; +}; +String STR_CTW_ERROR_NO_QUERY +{ + Text [ en-US ] = "To copy a query, your connection must be able to provide queries."; +}; +String STR_CTW_ERROR_INVALID_INTERACTIONHANDLER +{ + Text [ en-US ] = "The given interaction handler is invalid."; +}; diff --git a/reportdesign/inc/RptObject.hxx b/reportdesign/inc/RptObject.hxx index 00fe6d5a357f..5d2397fffa08 100644 --- a/reportdesign/inc/RptObject.hxx +++ b/reportdesign/inc/RptObject.hxx @@ -109,7 +109,6 @@ protected: virtual void SetSnapRectImpl(const Rectangle& _rRect) = 0; virtual SdrPage* GetImplPage() const = 0; virtual void SetObjectItemHelper(const SfxPoolItem& rItem); - sal_Bool IsInside(const Rectangle& _rRect,const Point& rPnt,USHORT nTol) const; /** called by instances of derived classes to implement their overloading of getUnoShape */ diff --git a/reportdesign/inc/reportformula.hxx b/reportdesign/inc/reportformula.hxx index 18d70930edc6..01e45f3b348a 100644 --- a/reportdesign/inc/reportformula.hxx +++ b/reportdesign/inc/reportformula.hxx @@ -64,9 +64,6 @@ namespace rptui ::rtl::OUString m_sUndecoratedContent; public: - // constructs a ReportFormula instance which is initially invalid. - ReportFormula(); - /// constructs a ReportFormula object from a string ReportFormula( const ::rtl::OUString& _rFormula ); diff --git a/reportdesign/source/core/api/ReportControlModel.cxx b/reportdesign/source/core/api/ReportControlModel.cxx index 6e0869d7e789..c0f5a90a446a 100644 --- a/reportdesign/source/core/api/ReportControlModel.cxx +++ b/reportdesign/source/core/api/ReportControlModel.cxx @@ -152,14 +152,6 @@ void OReportControlModel::checkIndex(sal_Int32 _nIndex) throw lang::IndexOutOfBoundsException(); } // ----------------------------------------------------------------------------- -void OReportControlModel::dispose() -{ - m_aFormatConditions.clear(); - lang::EventObject aDisposeEvent( m_pOwner ); - aContainerListeners.disposeAndClear( aDisposeEvent ); - m_aFormatConditions.clear(); -} -// ----------------------------------------------------------------------------- bool OReportControlModel::isInterfaceForbidden(const uno::Type& _rType) { return (_rType == ::getCppuType((const uno::Reference< beans::XPropertyState>* )0) || _rType == ::getCppuType((const uno::Reference< beans::XMultiPropertySet>* )0)); diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx index 754f97bf0b4a..b505f16ff751 100644 --- a/reportdesign/source/core/api/ReportDefinition.cxx +++ b/reportdesign/source/core/api/ReportDefinition.cxx @@ -563,8 +563,7 @@ namespace } catch(uno::Exception& ex) { - (void)ex; - OSL_ASSERT(0); + DBG_UNHANDLED_EXCEPTION(); } } void SAL_CALL FactoryLoader::onTerminated() diff --git a/reportdesign/source/core/inc/ReportControlModel.hxx b/reportdesign/source/core/inc/ReportControlModel.hxx index a11dd61e8ed6..29f3a9d7ef9c 100644 --- a/reportdesign/source/core/inc/ReportControlModel.hxx +++ b/reportdesign/source/core/inc/ReportControlModel.hxx @@ -115,8 +115,6 @@ namespace reportdesign ,bPrintWhenGroupChange(sal_False) {} - void dispose(); - // XContainer void addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); void removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); diff --git a/reportdesign/source/core/misc/reportformula.cxx b/reportdesign/source/core/misc/reportformula.cxx index 7bbd76f31796..23a0bb86e412 100644 --- a/reportdesign/source/core/misc/reportformula.cxx +++ b/reportdesign/source/core/misc/reportformula.cxx @@ -69,12 +69,6 @@ namespace rptui //= ReportFormula //==================================================================== //-------------------------------------------------------------------- - ReportFormula::ReportFormula() - :m_eType( Invalid ) - { - } - - //-------------------------------------------------------------------- ReportFormula::ReportFormula( const ::rtl::OUString& _rFormula ) :m_eType( Invalid ) { diff --git a/reportdesign/source/core/sdr/RptObject.cxx b/reportdesign/source/core/sdr/RptObject.cxx index 2d9d3d225673..73fa05e81620 100644 --- a/reportdesign/source/core/sdr/RptObject.cxx +++ b/reportdesign/source/core/sdr/RptObject.cxx @@ -363,22 +363,6 @@ uno::Reference< beans::XPropertySet> OObjectBase::getAwtComponent() { return uno::Reference< beans::XPropertySet>(); } -// ----------------------------------------------------------------------------- -sal_Bool OObjectBase::IsInside(const Rectangle& _rRect,const Point& rPnt,USHORT nTol) const -{ - sal_Bool bRet = sal_False; - Rectangle aRect( _rRect ); - if ( !aRect.IsEmpty() ) - { - aRect.Left() -= nTol; - aRect.Top() -= nTol; - aRect.Right() = ( aRect.Right() == RECT_EMPTY ? _rRect.Left() + nTol : aRect.Right() + nTol ); - aRect.Bottom() = ( aRect.Bottom() == RECT_EMPTY ? _rRect.Top() + nTol : aRect.Bottom() + nTol ); - - bRet = aRect.IsInside( rPnt ); - } - return bRet; -} //---------------------------------------------------------------------------- void OObjectBase::StartListening() { diff --git a/reportdesign/source/filter/xml/xmlExport.cxx b/reportdesign/source/filter/xml/xmlExport.cxx index b0012e731c81..33da532c99c6 100644 --- a/reportdesign/source/filter/xml/xmlExport.cxx +++ b/reportdesign/source/filter/xml/xmlExport.cxx @@ -172,40 +172,6 @@ namespace rptxml } //--------------------------------------------------------------------- - ::rtl::OUString lcl_implGetPropertyXMLType(const Type& _rType) - { - // possible types we can write (either because we recognize them directly or because we convert _rValue - // into one of these types) - static const ::rtl::OUString s_sTypeBoolean (RTL_CONSTASCII_USTRINGPARAM("boolean")); - static const ::rtl::OUString s_sTypeShort (RTL_CONSTASCII_USTRINGPARAM("short")); - static const ::rtl::OUString s_sTypeInteger (RTL_CONSTASCII_USTRINGPARAM("int")); - static const ::rtl::OUString s_sTypeLong (RTL_CONSTASCII_USTRINGPARAM("long")); - static const ::rtl::OUString s_sTypeDouble (RTL_CONSTASCII_USTRINGPARAM("double")); - static const ::rtl::OUString s_sTypeString (RTL_CONSTASCII_USTRINGPARAM("string")); - - // handle the type description - switch (_rType.getTypeClass()) - { - case TypeClass_STRING: - return s_sTypeString; - case TypeClass_DOUBLE: - return s_sTypeDouble; - case TypeClass_BOOLEAN: - return s_sTypeBoolean; - case TypeClass_BYTE: - case TypeClass_SHORT: - return s_sTypeShort; - case TypeClass_LONG: - return s_sTypeInteger; - case TypeClass_HYPER: - return s_sTypeLong; - case TypeClass_ENUM: - return s_sTypeInteger; - - default: - return s_sTypeDouble; - } - } class OSpecialHanldeXMLExportPropertyMapper : public SvXMLExportPropertyMapper { @@ -1151,6 +1117,13 @@ sal_Bool ORptExport::exportGroup(const Reference<XReportDefinition>& _xReportDef ::rtl::OUString sExpression = xGroup->getExpression(); if ( sExpression.getLength() ) { + static ::rtl::OUString s_sQuote(RTL_CONSTASCII_USTRINGPARAM("\"\"")); + sal_Int32 nIndex = sExpression.indexOf('"'); + while ( nIndex > -1 ) + { + sExpression = sExpression.replaceAt(nIndex,1,s_sQuote); + nIndex = sExpression.indexOf('"',nIndex+2); + } ::rtl::OUString sFormula(RTL_CONSTASCII_USTRINGPARAM("rpt:HASCHANGED(\"")); TGroupFunctionMap::iterator aGroupFind = m_aGroupFunctionMap.find(xGroup); @@ -1486,45 +1459,6 @@ sal_uInt32 ORptExport::exportDoc(enum ::xmloff::token::XMLTokenEnum eClass) return aBuffer.makeStringAndClear(); } // ----------------------------------------------------------------------------- -::rtl::OUString ORptExport::implConvertMeasure(sal_Int32 _nValue) -{ - ::rtl::OUStringBuffer aBuffer; - GetMM100UnitConverter().convertMeasure(aBuffer, _nValue); - return aBuffer.makeStringAndClear(); -} -// ----------------------------------------------------------------------------- -::rtl::OUString ORptExport::implConvertAny(const Any& _rValue) -{ - ::rtl::OUStringBuffer aBuffer; - switch (_rValue.getValueTypeClass()) - { - case TypeClass_STRING: - { // extract the string - ::rtl::OUString sCurrentValue; - _rValue >>= sCurrentValue; - aBuffer.append(sCurrentValue); - } - break; - case TypeClass_DOUBLE: - // let the unit converter format is as string - GetMM100UnitConverter().convertDouble(aBuffer, getDouble(_rValue)); - break; - case TypeClass_BOOLEAN: - aBuffer = getBOOL(_rValue) ? ::xmloff::token::GetXMLToken(XML_TRUE) : ::xmloff::token::GetXMLToken(XML_FALSE); - break; - case TypeClass_BYTE: - case TypeClass_SHORT: - case TypeClass_LONG: - // let the unit converter format is as string - GetMM100UnitConverter().convertNumber(aBuffer, getINT32(_rValue)); - break; - default: - OSL_ENSURE(0,"ORptExport::implConvertAny: Invalid type"); - } - - return aBuffer.makeStringAndClear(); -} -// ----------------------------------------------------------------------------- UniReference < XMLPropertySetMapper > ORptExport::GetCellStylePropertyMapper() const { return m_xCellStylesPropertySetMapper; @@ -1660,6 +1594,7 @@ void ORptExport::exportGroupsExpressionAsFunction(const Reference< XGroups>& _xG uno::Reference< XFunction> xFunction = xFunctions->createFunction(); ::rtl::OUString sFunction,sPrefix,sPostfix; ::rtl::OUString sExpression = xGroup->getExpression(); + ::rtl::OUString sFunctionName; switch(nGroupOn) { case report::GroupOn::PREFIX_CHARACTERS: @@ -1670,8 +1605,9 @@ void ORptExport::exportGroupsExpressionAsFunction(const Reference< XGroups>& _xG sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("YEAR")); break; case report::GroupOn::QUARTAL: - sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MONTH")); - sPostfix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/4")); + sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INT((MONTH")); + sPostfix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-1)/3)+1")); + sFunctionName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("QUARTAL_")) + sExpression; break; case report::GroupOn::MONTH: sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MONTH")); @@ -1699,15 +1635,21 @@ void ORptExport::exportGroupsExpressionAsFunction(const Reference< XGroups>& _xG exportFunction(xCountFunction); sExpression = sCountName; sPrefix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" / ")) + ::rtl::OUString::valueOf(xGroup->getGroupInterval()); + sFunctionName = sFunction + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_")) + sExpression; } break; default: ; } + if ( !sFunctionName.getLength() ) + sFunctionName = sFunction + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_")) + sExpression; if ( sFunction.getLength() ) { + sal_Unicode pReplaceChars[] = { '(',')',';',',','+','-','[',']','/','*'}; + for(sal_uInt32 j= 0; j < sizeof(pReplaceChars)/sizeof(pReplaceChars[0]);++j) + sFunctionName = sFunctionName.replace(pReplaceChars[j],'_'); - xFunction->setName(sFunction + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_")) + sExpression); + xFunction->setName(sFunctionName); sFunction = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:")) + sFunction; sFunction += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("([")); sFunction += sExpression; diff --git a/reportdesign/source/filter/xml/xmlExport.hxx b/reportdesign/source/filter/xml/xmlExport.hxx index 3b8e621b52ae..3bd478b60ba8 100644 --- a/reportdesign/source/filter/xml/xmlExport.hxx +++ b/reportdesign/source/filter/xml/xmlExport.hxx @@ -177,9 +177,7 @@ private: void exportGroupsExpressionAsFunction(const Reference< XGroups>& _xGroups); ::rtl::OUString convertFormula(const ::rtl::OUString& _sFormula); - ::rtl::OUString implConvertAny(const Any& _rValue); ::rtl::OUString implConvertNumber(sal_Int32 _nValue); - ::rtl::OUString implConvertMeasure(sal_Int32 _nValue); private: ORptExport(); diff --git a/reportdesign/source/filter/xml/xmlGroup.cxx b/reportdesign/source/filter/xml/xmlGroup.cxx index 383cc88336ca..b49f6b0e7b9c 100644 --- a/reportdesign/source/filter/xml/xmlGroup.cxx +++ b/reportdesign/source/filter/xml/xmlGroup.cxx @@ -105,6 +105,7 @@ OXMLGroup::OXMLGroup( ORptFilter& _rImport sal_Int32 nLen = sValue.getLength(); if ( nLen ) { + const static ::rtl::OUString s_sChanged(RTL_CONSTASCII_USTRINGPARAM("rpt:HASCHANGED(\"")); sal_Int32 nPos = sValue.indexOf(s_sChanged); if ( nPos == -1 ) @@ -112,7 +113,15 @@ OXMLGroup::OXMLGroup( ORptFilter& _rImport else { nPos = s_sChanged.getLength(); - --nLen; + static ::rtl::OUString s_sQuote(RTL_CONSTASCII_USTRINGPARAM("\"\"")); + static ::rtl::OUString s_sSingleQuote(RTL_CONSTASCII_USTRINGPARAM("\"")); + sal_Int32 nIndex = sValue.indexOf(s_sQuote,nPos); + while ( nIndex > -1 ) + { + sValue = sValue.replaceAt(nIndex,2,s_sSingleQuote); + nIndex = sValue.indexOf(s_sQuote,nIndex+2); + } + nLen = sValue.getLength() - 1; } sValue = sValue.copy(nPos,nLen-nPos-1); const ORptFilter::TGroupFunctionMap& aFunctions = _rImport.getFunctions(); @@ -140,10 +149,12 @@ OXMLGroup::OXMLGroup( ORptFilter& _rImport nGroupOn = report::GroupOn::YEAR; else if ( sFormula ==::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:MONTH"))) { - if ( sCompleteFormula.endsWithIgnoreAsciiCaseAsciiL("\4",2) ) - nGroupOn = report::GroupOn::QUARTAL; - else - nGroupOn = report::GroupOn::MONTH; + nGroupOn = report::GroupOn::MONTH; + } + else if ( sCompleteFormula.matchAsciiL("rpt:INT((MONTH",sizeof("rpt:INT((MONTH"),0) + && sCompleteFormula.endsWithIgnoreAsciiCaseAsciiL("-1)/3)+1",sizeof("-1)/3)+1")) ) + { + nGroupOn = report::GroupOn::QUARTAL; } else if ( sFormula ==::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:WEEK"))) nGroupOn = report::GroupOn::WEEK; diff --git a/reportdesign/source/ui/inc/DesignView.hxx b/reportdesign/source/ui/inc/DesignView.hxx index 1378056fe0e9..07167df69ae4 100644 --- a/reportdesign/source/ui/inc/DesignView.hxx +++ b/reportdesign/source/ui/inc/DesignView.hxx @@ -160,9 +160,11 @@ namespace rptui */ void alignMarkedObjects(sal_Int32 _nControlModification, bool _bAlignAtSection, bool bBoundRects = false); +#if 0 /** checks if alignment is possible in the current section */ sal_Bool isAlignPossible() const; +#endif /** All objects will be marked. */ diff --git a/reportdesign/source/ui/inc/ReportWindow.hxx b/reportdesign/source/ui/inc/ReportWindow.hxx index e406bcf7ccb9..fcf274d314e4 100644 --- a/reportdesign/source/ui/inc/ReportWindow.hxx +++ b/reportdesign/source/ui/inc/ReportWindow.hxx @@ -93,7 +93,6 @@ namespace rptui rtl::OUString GetInsertObjString() const; void setGridSnap(BOOL bOn); void setDragStripes(BOOL bOn); - BOOL isDragStripes() const; /** copies the current selection in this section */ diff --git a/reportdesign/source/ui/inc/ScrollHelper.hxx b/reportdesign/source/ui/inc/ScrollHelper.hxx index 4eaf9720abda..6098c7bbb2e1 100644 --- a/reportdesign/source/ui/inc/ScrollHelper.hxx +++ b/reportdesign/source/ui/inc/ScrollHelper.hxx @@ -106,7 +106,6 @@ namespace rptui rtl::OUString GetInsertObjString() const; void setGridSnap(BOOL bOn); void setDragStripes(BOOL bOn); - BOOL isDragStripes() const; /** copies the current selection in this section */ void Copy(); diff --git a/reportdesign/source/ui/inc/StartMarker.hxx b/reportdesign/source/ui/inc/StartMarker.hxx index d14abd076fc5..a9d532bb95dc 100644 --- a/reportdesign/source/ui/inc/StartMarker.hxx +++ b/reportdesign/source/ui/inc/StartMarker.hxx @@ -76,10 +76,6 @@ namespace rptui void setTitle(const String& _sTitle); sal_Int32 getMinHeight() const; - /** returns the offset where the horizontal ruler must start - */ - sal_Int32 getRulerOffset() const; - /** shows or hides the ruler. */ void showRuler(sal_Bool _bShow); diff --git a/reportdesign/source/ui/inc/ViewsWindow.hxx b/reportdesign/source/ui/inc/ViewsWindow.hxx index 806bd857fae3..b9fd640b307e 100644 --- a/reportdesign/source/ui/inc/ViewsWindow.hxx +++ b/reportdesign/source/ui/inc/ViewsWindow.hxx @@ -202,8 +202,6 @@ namespace rptui */ ::boost::shared_ptr<OSectionWindow> getSectionWindow(const USHORT _nPos) const; - void showView(USHORT _nPos,BOOL _bShow); - /** turns the grid on or off * * \param _bVisible @@ -211,7 +209,6 @@ namespace rptui void toggleGrid(sal_Bool _bVisible); void setGridSnap(BOOL bOn); void setDragStripes(BOOL bOn); - BOOL isDragStripes() const; /** returns the total accumulated height of all sections until _pSection is reached */ @@ -248,8 +245,6 @@ namespace rptui */ BOOL HasSelection(); - void SectionHasFocus(OReportSection* _pSection,BOOL _bHasFocus); - /** unmark all objects on the views without the given one. * * @param _pSectionView The view where the objects should not be unmarked. diff --git a/reportdesign/source/ui/report/DesignView.cxx b/reportdesign/source/ui/report/DesignView.cxx index ef1730f13843..3709d8f6cf16 100644 --- a/reportdesign/source/ui/report/DesignView.cxx +++ b/reportdesign/source/ui/report/DesignView.cxx @@ -680,12 +680,14 @@ void ODesignView::alignMarkedObjects(sal_Int32 _nControlModification,bool _bAlig { m_aScrollWindow.alignMarkedObjects(_nControlModification, _bAlignAtSection,bBoundRects); } +#if 0 // ----------------------------------------------------------------------------- sal_Bool ODesignView::isAlignPossible() const { ::boost::shared_ptr<OSectionWindow> pMarkedSection = getMarkedSection(); return pMarkedSection.get() && pMarkedSection->getReportSection().getSectionView().IsAlignPossible(); } +#endif //------------------------------------------------------------------------------ sal_Bool ODesignView::handleKeyEvent(const KeyEvent& _rEvent) { diff --git a/reportdesign/source/ui/report/ReportWindow.cxx b/reportdesign/source/ui/report/ReportWindow.cxx index 281a5650b681..6668e192ceff 100644 --- a/reportdesign/source/ui/report/ReportWindow.cxx +++ b/reportdesign/source/ui/report/ReportWindow.cxx @@ -378,11 +378,6 @@ void OReportWindow::setDragStripes(BOOL bOn) m_aViewsWindow.setDragStripes(bOn); } // ----------------------------------------------------------------------------- -BOOL OReportWindow::isDragStripes() const -{ - return m_aViewsWindow.isDragStripes(); -} -// ----------------------------------------------------------------------------- sal_uInt32 OReportWindow::getMarkedObjectCount() const { return m_aViewsWindow.getMarkedObjectCount(); diff --git a/reportdesign/source/ui/report/ScrollHelper.cxx b/reportdesign/source/ui/report/ScrollHelper.cxx index 5d13f78f3755..b39824d5e8ea 100644 --- a/reportdesign/source/ui/report/ScrollHelper.cxx +++ b/reportdesign/source/ui/report/ScrollHelper.cxx @@ -393,11 +393,6 @@ void OScrollWindowHelper::setDragStripes(BOOL bOn) m_aReportWindow.setDragStripes(bOn); } // ----------------------------------------------------------------------------- -BOOL OScrollWindowHelper::isDragStripes() const -{ - return m_aReportWindow.isDragStripes(); -} -// ----------------------------------------------------------------------------- sal_uInt32 OScrollWindowHelper::getMarkedObjectCount() const { return m_aReportWindow.getMarkedObjectCount(); diff --git a/reportdesign/source/ui/report/StartMarker.cxx b/reportdesign/source/ui/report/StartMarker.cxx index 3ba4f43ac905..7661b60a4bb0 100644 --- a/reportdesign/source/ui/report/StartMarker.cxx +++ b/reportdesign/source/ui/report/StartMarker.cxx @@ -286,12 +286,6 @@ void OStartMarker::showRuler(sal_Bool _bShow) m_aVRuler.Show(!m_bCollapsed && m_bShowRuler); } //------------------------------------------------------------------------------ -sal_Int32 OStartMarker::getRulerOffset() const -{ - return m_aVRuler.GetSizePixel().Width(); -} - -//------------------------------------------------------------------------------ void OStartMarker::RequestHelp( const HelpEvent& rHEvt ) { if( m_aText.GetText().Len()) diff --git a/reportdesign/source/ui/report/ViewsWindow.cxx b/reportdesign/source/ui/report/ViewsWindow.cxx index 5cc1ff689490..e3838968de84 100644 --- a/reportdesign/source/ui/report/ViewsWindow.cxx +++ b/reportdesign/source/ui/report/ViewsWindow.cxx @@ -337,12 +337,6 @@ void OViewsWindow::removeSection(USHORT _nPosition) Resize(); } // if ( _nPosition < m_aSections.size() ) } -//---------------------------------------------------------------------------- -void OViewsWindow::showView(USHORT _nPos,BOOL _bShow) -{ - if ( _nPos < m_aSections.size() ) - m_aSections[_nPos]->setCollapsed(_bShow); -} //------------------------------------------------------------------------------ void OViewsWindow::toggleGrid(BOOL _bVisible) { @@ -534,21 +528,6 @@ void OViewsWindow::SelectAll(const sal_uInt16 _nObjectType) ::std::compose1(::boost::bind(::boost::mem_fn(&OReportSection::SelectAll),_1,_nObjectType),TReportPairHelper())); m_bInUnmark = sal_False; } -//---------------------------------------------------------------------------- -void OViewsWindow::SectionHasFocus(OReportSection* /*_pSection*/,BOOL /*_bHasFocus*/) -{ -/* LLA!: this function does nothing! -TSectionsMap::iterator aIter = m_aSections.begin(); - TSectionsMap::iterator aEnd = m_aSections.end(); - for (USHORT i = 0 ; aIter != aEnd ; ++aIter,++i) - { - if ( (*aIter).first.get() == _pSection ) - { - - } - } -*/ -} //----------------------------------------------------------------------------- void OViewsWindow::unmarkAllObjects(OSectionView* _pSectionView) { @@ -982,12 +961,6 @@ void OViewsWindow::setDragStripes(BOOL bOn) (*aIter)->getReportSection().getSectionView().SetDragStripes(bOn); } // ----------------------------------------------------------------------------- -BOOL OViewsWindow::isDragStripes() const -{ - return !m_aSections.empty() && (*m_aSections.begin())->getReportSection().getSectionView().IsDragStripes(); -} -// ----------------------------------------------------------------------------- - USHORT OViewsWindow::getPosition(const OSectionWindow* _pSectionWindow) const { TSectionsMap::const_iterator aIter = m_aSections.begin(); |