diff options
author | Jan Holesovsky <kendy@suse.cz> | 2011-04-22 15:07:40 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2011-04-22 15:07:40 +0200 |
commit | e88a4fb61318f2282e21f4f55bf6e67075200fd4 (patch) | |
tree | 263707c9f24ee81aa9485267fa9ad80a1ede2052 /dbaccess/source/core/api | |
parent | 7e8a4888be548390148cc932a5d0b899e4fdd318 (diff) | |
parent | a446d943bae5ca14030ca2ea18f8a8ff895fbcaf (diff) |
Merge commit 'ooo/DEV300_m106' into libreoffice-3-4
Conflicts:
dbaccess/source/core/api/CacheSet.cxx
dbaccess/source/core/api/KeySet.cxx
dbaccess/source/core/api/KeySet.hxx
dbaccess/source/core/api/OptimisticSet.hxx
dbaccess/source/core/api/RowSet.cxx
dbaccess/source/core/api/RowSetCache.cxx
dbaccess/source/core/api/query.cxx
dbaccess/source/core/dataaccess/SharedConnection.cxx
dbaccess/source/ui/app/AppController.cxx
dbaccess/source/ui/app/makefile.mk
dbaccess/source/ui/control/FieldDescControl.cxx
dbaccess/source/ui/querydesign/query.src
dbaccess/source/ui/tabledesign/TEditControl.cxx
reportdesign/source/ui/report/ReportController.cxx
reportdesign/source/ui/report/ReportSection.cxx
reportdesign/source/ui/report/SectionWindow.cxx
reportdesign/source/ui/report/StartMarker.cxx
reportdesign/source/ui/report/ViewsWindow.cxx
Diffstat (limited to 'dbaccess/source/core/api')
-rw-r--r-- | dbaccess/source/core/api/CacheSet.cxx | 15 | ||||
-rw-r--r-- | dbaccess/source/core/api/CacheSet.hxx | 3 | ||||
-rw-r--r-- | dbaccess/source/core/api/KeySet.cxx | 61 | ||||
-rw-r--r-- | dbaccess/source/core/api/KeySet.hxx | 9 | ||||
-rw-r--r-- | dbaccess/source/core/api/OptimisticSet.cxx | 5 | ||||
-rw-r--r-- | dbaccess/source/core/api/OptimisticSet.hxx | 3 | ||||
-rw-r--r-- | dbaccess/source/core/api/RowSet.cxx | 87 | ||||
-rw-r--r-- | dbaccess/source/core/api/RowSetBase.cxx | 9 | ||||
-rw-r--r-- | dbaccess/source/core/api/RowSetBase.hxx | 3 | ||||
-rw-r--r-- | dbaccess/source/core/api/RowSetCache.cxx | 163 | ||||
-rw-r--r-- | dbaccess/source/core/api/SingleSelectQueryComposer.cxx | 28 |
11 files changed, 262 insertions, 124 deletions
diff --git a/dbaccess/source/core/api/CacheSet.cxx b/dbaccess/source/core/api/CacheSet.cxx index ca3c4d13b..39121e0c2 100644 --- a/dbaccess/source/core/api/CacheSet.cxx +++ b/dbaccess/source/core/api/CacheSet.cxx @@ -640,6 +640,21 @@ sal_Bool SAL_CALL OCacheSet::previous( ) throw(SQLException, RuntimeException) return m_xDriverSet->previous(); } +sal_Bool OCacheSet::last_checked( sal_Bool /*i_bFetchRow*/) +{ + return last(); +} + +sal_Bool OCacheSet::previous_checked( sal_Bool /*i_bFetchRow*/ ) +{ + return previous(); +} + +sal_Bool OCacheSet::absolute_checked( sal_Int32 row,sal_Bool /*i_bFetchRow*/ ) +{ + return absolute(row); +} + void SAL_CALL OCacheSet::refreshRow( ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::refreshRow" ); diff --git a/dbaccess/source/core/api/CacheSet.hxx b/dbaccess/source/core/api/CacheSet.hxx index 5e2138aa6..9fab5c212 100644 --- a/dbaccess/source/core/api/CacheSet.hxx +++ b/dbaccess/source/core/api/CacheSet.hxx @@ -153,6 +153,9 @@ namespace dbaccess virtual bool columnValuesUpdated(ORowSetValueVector::Vector& o_aCachedRow,const ORowSetValueVector::Vector& i_aRow); virtual bool updateColumnValues(const ORowSetValueVector::Vector& io_aCachedRow,ORowSetValueVector::Vector& io_aRow,const ::std::vector<sal_Int32>& i_aChangedColumns); virtual void fillMissingValues(ORowSetValueVector::Vector& io_aRow) const; + virtual sal_Bool previous_checked( sal_Bool i_bFetchRow ); + virtual sal_Bool absolute_checked( sal_Int32 row,sal_Bool i_bFetchRow ); + virtual sal_Bool last_checked( sal_Bool i_bFetchRow); }; } #endif //DBACCESS_CORE_API_CACHESET_HXX diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx index 5ae33859a..a1a97b8ad 100644 --- a/dbaccess/source/core/api/KeySet.cxx +++ b/dbaccess/source/core/api/KeySet.cxx @@ -105,7 +105,8 @@ OKeySet::OKeySet(const connectivity::OSQLTable& _xTable, const ::rtl::OUString& _rUpdateTableName, // this can be the alias or the full qualified name const Reference< XSingleSelectQueryAnalyzer >& _xComposer, const ORowSetValueVector& _aParameterValueForCache, - sal_Int32 i_nMaxRows) + sal_Int32 i_nMaxRows, + sal_Int32& o_nRowCount) :OCacheSet(i_nMaxRows) ,m_aParameterValueForCache(_aParameterValueForCache) ,m_pKeyColumnNames(NULL) @@ -116,6 +117,7 @@ OKeySet::OKeySet(const connectivity::OSQLTable& _xTable, ,m_xTableKeys(_xTableKeys) ,m_xComposer(_xComposer) ,m_sUpdateTableName(_rUpdateTableName) + ,m_rRowCount(o_nRowCount) ,m_bRowCountFinal(sal_False) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::OKeySet" ); @@ -1112,6 +1114,12 @@ sal_Bool SAL_CALL OKeySet::next( ) throw(SQLException, RuntimeException) ++m_aKeyIter; // this is possible because we stand on begin() and this is the "beforefirst" row if(m_aKeyIter == m_aKeyMap.end() && !fetchRow()) m_aKeyIter = m_aKeyMap.end(); + else + { + //m_aKeyIter->second.second.second = new OPrivateRow(_rInsertRow->get()); + m_xRow.set(m_xDriverRow,UNO_QUERY_THROW); + return !isAfterLast(); + } } else if(!isAfterLast()) ++m_aKeyIter; @@ -1178,20 +1186,26 @@ sal_Bool SAL_CALL OKeySet::first( ) throw(SQLException, RuntimeException) ++m_aKeyIter; if(m_aKeyIter == m_aKeyMap.end() && !fetchRow()) m_aKeyIter = m_aKeyMap.end(); - - refreshRow(); + else + refreshRow(); return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin(); } sal_Bool SAL_CALL OKeySet::last( ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::last" ); + return last_checked(sal_True); +} + +sal_Bool OKeySet::last_checked( sal_Bool i_bFetchRow) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::last_checked" ); m_bInserted = m_bUpdated = m_bDeleted = sal_False; fillAllRows(); m_aKeyIter = m_aKeyMap.end(); --m_aKeyIter; - refreshRow(); + if ( i_bFetchRow ) + refreshRow(); return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin(); } @@ -1206,6 +1220,10 @@ sal_Int32 SAL_CALL OKeySet::getRow( ) throw(SQLException, RuntimeException) sal_Bool SAL_CALL OKeySet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException) { + return absolute_checked(row,sal_True); +} +sal_Bool OKeySet::absolute_checked( sal_Int32 row,sal_Bool i_bFetchRow ) +{ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::absolute" ); m_bInserted = m_bUpdated = m_bDeleted = sal_False; OSL_ENSURE(row,"absolute(0) isn't allowed!"); @@ -1226,6 +1244,11 @@ sal_Bool SAL_CALL OKeySet::absolute( sal_Int32 row ) throw(SQLException, Runtime sal_Bool bNext = sal_True; for(sal_Int32 i=m_aKeyMap.size()-1;i < row && bNext;++i) bNext = fetchRow(); + if ( bNext ) + { + m_xRow.set(m_xDriverRow,UNO_QUERY_THROW); + return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin(); + } } else m_aKeyIter = m_aKeyMap.end(); @@ -1237,7 +1260,8 @@ sal_Bool SAL_CALL OKeySet::absolute( sal_Int32 row ) throw(SQLException, Runtime ++m_aKeyIter; } } - refreshRow(); + if ( i_bFetchRow ) + refreshRow(); return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin(); } @@ -1253,18 +1277,24 @@ sal_Bool SAL_CALL OKeySet::relative( sal_Int32 rows ) throw(SQLException, Runtim return absolute(getRow()+rows); } -sal_Bool SAL_CALL OKeySet::previous( ) throw(SQLException, RuntimeException) +sal_Bool OKeySet::previous_checked( sal_Bool i_bFetchRow ) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::previous" ); m_bInserted = m_bUpdated = m_bDeleted = sal_False; if(m_aKeyIter != m_aKeyMap.begin()) { --m_aKeyIter; - refreshRow(); + if ( i_bFetchRow ) + refreshRow(); } return m_aKeyIter != m_aKeyMap.begin(); } +sal_Bool SAL_CALL OKeySet::previous( ) throw(SQLException, RuntimeException) +{ + return previous_checked(sal_True); +} +// ----------------------------------------------------------------------------- void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::refreshRow" ); @@ -1319,9 +1349,18 @@ void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException) OSL_ENSURE(m_xSet.is(),"No resultset form statement!"); sal_Bool bOK = m_xSet->next(); if ( !bOK ) - m_aKeyIter = m_aKeyMap.end(); - m_xRow.set(m_xSet,UNO_QUERY); - OSL_ENSURE(m_xRow.is(),"No row form statement!"); + { + OKeySetMatrix::iterator aTemp = m_aKeyIter; + ++m_aKeyIter; + m_aKeyMap.erase(aTemp); + --m_rRowCount; + refreshRow(); + } + else + { + m_xRow.set(m_xSet,UNO_QUERY); + OSL_ENSURE(m_xRow.is(),"No row form statement!"); + } } sal_Bool OKeySet::fetchRow() diff --git a/dbaccess/source/core/api/KeySet.hxx b/dbaccess/source/core/api/KeySet.hxx index 826ec1ab7..99326960c 100644 --- a/dbaccess/source/core/api/KeySet.hxx +++ b/dbaccess/source/core/api/KeySet.hxx @@ -104,6 +104,7 @@ namespace dbaccess ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer > m_xComposer; ::rtl::OUString m_sUpdateTableName; ::std::vector< ::rtl::OUString > m_aFilterColumns; + sal_Int32& m_rRowCount; sal_Bool m_bRowCountFinal; @@ -151,7 +152,8 @@ namespace dbaccess const ::rtl::OUString& _rUpdateTableName, const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer >& _xComposer, const ORowSetValueVector& _aParameterValueForCache, - sal_Int32 i_nMaxRows); + sal_Int32 i_nMaxRows, + sal_Int32& o_nRowCount); // late ctor which can throw exceptions virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter); @@ -219,6 +221,11 @@ namespace dbaccess virtual void SAL_CALL cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + + + virtual sal_Bool previous_checked( sal_Bool i_bFetchRow ); + virtual sal_Bool absolute_checked( sal_Int32 row,sal_Bool i_bFetchRow ); + virtual sal_Bool last_checked( sal_Bool i_bFetchRow); }; } #endif // DBACCESS_CORE_API_KEYSET_HXX diff --git a/dbaccess/source/core/api/OptimisticSet.cxx b/dbaccess/source/core/api/OptimisticSet.cxx index 38dba0ece..8e8fc2386 100644 --- a/dbaccess/source/core/api/OptimisticSet.cxx +++ b/dbaccess/source/core/api/OptimisticSet.cxx @@ -102,8 +102,9 @@ OptimisticSet::OptimisticSet(const ::comphelper::ComponentContext& _rContext, const Reference< XConnection>& i_xConnection, const Reference< XSingleSelectQueryAnalyzer >& _xComposer, const ORowSetValueVector& _aParameterValueForCache, - sal_Int32 i_nMaxRows) - :OKeySet(NULL,NULL,::rtl::OUString(),_xComposer,_aParameterValueForCache,i_nMaxRows) + sal_Int32 i_nMaxRows, + sal_Int32& o_nRowCount) + :OKeySet(NULL,NULL,::rtl::OUString(),_xComposer,_aParameterValueForCache,i_nMaxRows,o_nRowCount) ,m_aSqlParser( _rContext.getLegacyServiceFactory() ) ,m_aSqlIterator( i_xConnection, Reference<XTablesSupplier>(_xComposer,UNO_QUERY)->getTables(), m_aSqlParser, NULL ) ,m_bResultSetChanged(false) diff --git a/dbaccess/source/core/api/OptimisticSet.hxx b/dbaccess/source/core/api/OptimisticSet.hxx index bcada376a..b9b8fbe11 100644 --- a/dbaccess/source/core/api/OptimisticSet.hxx +++ b/dbaccess/source/core/api/OptimisticSet.hxx @@ -77,7 +77,8 @@ namespace dbaccess const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& i_xConnection, const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer >& _xComposer, const ORowSetValueVector& _aParameterValueForCache, - sal_Int32 i_nMaxRows); + sal_Int32 i_nMaxRows, + sal_Int32& o_nRowCount); // late ctor which can throw exceptions virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter); diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index 724df9f4a..3825516e4 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -599,6 +599,7 @@ void ORowSet::freeResources( bool _bComplete ) m_bAfterLast = sal_False; m_bNew = sal_False; m_bModified = sal_False; + m_bIsInsertRow = sal_False; m_bLastKnownRowCountFinal = sal_False; m_nLastKnownRowCount = 0; if ( m_aOldRow.is() ) @@ -708,6 +709,7 @@ void ORowSet::updateValue(sal_Int32 columnIndex,const ORowSetValue& x) ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get()); ORowSetNotifier aNotify(this,rRow); m_pCache->updateValue(columnIndex,x,rRow,aNotify.getChangedColumns()); + m_bModified = m_bModified || !aNotify.getChangedColumns().empty(); aNotify.firePropertyChange(); } @@ -723,6 +725,7 @@ void SAL_CALL ORowSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, R ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get()); ORowSetNotifier aNotify(this,rRow); m_pCache->updateNull(columnIndex,rRow,aNotify.getChangedColumns()); + m_bModified = m_bModified || !aNotify.getChangedColumns().empty(); aNotify.firePropertyChange(); } @@ -810,6 +813,7 @@ void SAL_CALL ORowSet::updateCharacterStream( sal_Int32 columnIndex, const Refer ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get()); ORowSetNotifier aNotify(this,rRow); m_pCache->updateCharacterStream(columnIndex,x,length,rRow,aNotify.getChangedColumns()); + m_bModified = m_bModified || !aNotify.getChangedColumns().empty(); aNotify.firePropertyChange(); } @@ -853,6 +857,7 @@ void SAL_CALL ORowSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get()); ORowSetNotifier aNotify(this,rRow); m_pCache->updateObject(columnIndex,aNewValue,rRow,aNotify.getChangedColumns()); + m_bModified = m_bModified || !aNotify.getChangedColumns().empty(); aNotify.firePropertyChange(); } } @@ -866,6 +871,7 @@ void SAL_CALL ORowSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, ORowSetValueVector::Vector& rRow = ((*m_aCurrentRow)->get()); ORowSetNotifier aNotify(this,rRow); m_pCache->updateNumericObject(columnIndex,x,scale,rRow,aNotify.getChangedColumns()); + m_bModified = m_bModified || !aNotify.getChangedColumns().empty(); aNotify.firePropertyChange(); } @@ -882,52 +888,49 @@ void SAL_CALL ORowSet::insertRow( ) throw(SQLException, RuntimeException) if(!m_pCache || !m_bNew || !m_bModified || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY) throwFunctionSequenceException(*this); - if(m_bModified) - { - // remember old value for fire - sal_Bool bOld = m_bNew; + // remember old value for fire + sal_Bool bOld = m_bNew; - ORowSetRow aOldValues; - if ( !m_aCurrentRow.isNull() ) - aOldValues = new ORowSetValueVector( *(*m_aCurrentRow)); - Sequence<Any> aChangedBookmarks; - RowsChangeEvent aEvt(*this,RowChangeAction::INSERT,1,aChangedBookmarks); - notifyAllListenersRowBeforeChange(aGuard,aEvt); + ORowSetRow aOldValues; + if ( !m_aCurrentRow.isNull() ) + aOldValues = new ORowSetValueVector( *(*m_aCurrentRow)); + Sequence<Any> aChangedBookmarks; + RowsChangeEvent aEvt(*this,RowChangeAction::INSERT,1,aChangedBookmarks); + notifyAllListenersRowBeforeChange(aGuard,aEvt); - ::std::vector< Any > aBookmarks; - sal_Bool bInserted = m_pCache->insertRow(aBookmarks); + ::std::vector< Any > aBookmarks; + sal_Bool bInserted = m_pCache->insertRow(aBookmarks); - // make sure that our row is set to the new inserted row before clearing the insert flags in the cache - m_pCache->resetInsertRow(bInserted); + // make sure that our row is set to the new inserted row before clearing the insert flags in the cache + m_pCache->resetInsertRow(bInserted); - // notification order - // - column values - setCurrentRow( sal_False, sal_True, aOldValues, aGuard ); // we don't move here + // notification order + // - column values + setCurrentRow( sal_False, sal_True, aOldValues, aGuard ); // we don't move here - // read-only flag restored - impl_restoreDataColumnsWriteable_throw(); + // read-only flag restored + impl_restoreDataColumnsWriteable_throw(); - // - rowChanged - notifyAllListenersRowChanged(aGuard,aEvt); + // - rowChanged + notifyAllListenersRowChanged(aGuard,aEvt); - if ( !aBookmarks.empty() ) - { - RowsChangeEvent aUpEvt(*this,RowChangeAction::UPDATE,aBookmarks.size(),Sequence<Any>(&(*aBookmarks.begin()),aBookmarks.size())); - notifyAllListenersRowChanged(aGuard,aUpEvt); - } + if ( !aBookmarks.empty() ) + { + RowsChangeEvent aUpEvt(*this,RowChangeAction::UPDATE,aBookmarks.size(),Sequence<Any>(&(*aBookmarks.begin()),aBookmarks.size())); + notifyAllListenersRowChanged(aGuard,aUpEvt); + } - // - IsModified - if(!m_bModified) - fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True); - OSL_ENSURE( !m_bModified, "ORowSet::insertRow: just updated, but _still_ modified?" ); + // - IsModified + if(!m_bModified) + fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True); + OSL_ENSURE( !m_bModified, "ORowSet::insertRow: just updated, but _still_ modified?" ); - // - IsNew - if(m_bNew != bOld) - fireProperty(PROPERTY_ID_ISNEW,m_bNew,bOld); + // - IsNew + if(m_bNew != bOld) + fireProperty(PROPERTY_ID_ISNEW,m_bNew,bOld); - // - RowCount/IsRowCountFinal - fireRowcount(); - } + // - RowCount/IsRowCountFinal + fireRowcount(); } sal_Int32 SAL_CALL ORowSet::getRow( ) throw(SQLException, RuntimeException) @@ -936,7 +939,7 @@ sal_Int32 SAL_CALL ORowSet::getRow( ) throw(SQLException, RuntimeException) checkCache(); // check if we are inserting a row - return (m_pCache && ( m_pCache->m_bNew || m_bModified )) ? 0 : ORowSetBase::getRow(); + return (m_pCache && isInsertRow()) ? 0 : ORowSetBase::getRow(); } void SAL_CALL ORowSet::updateRow( ) throw(SQLException, RuntimeException) @@ -1074,6 +1077,7 @@ void ORowSet::implCancelRowUpdates( sal_Bool _bNotifyModified ) SAL_THROW( ( SQL m_aBookmark = m_pCache->getBookmark(); m_aCurrentRow = m_pCache->m_aMatrixIter; + m_bIsInsertRow = sal_False; m_aCurrentRow.setBookmark(m_aBookmark); // notification order @@ -1206,6 +1210,7 @@ void SAL_CALL ORowSet::moveToInsertRow( ) throw(SQLException, RuntimeException) m_pCache->moveToInsertRow(); m_aCurrentRow = m_pCache->m_aInsertRow; + m_bIsInsertRow = sal_True; // set read-only flag to false impl_setDataColumnsWriteable_throw(); @@ -1809,6 +1814,7 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi } m_pCache->setFetchSize(m_nFetchSize); m_aCurrentRow = m_pCache->createIterator(this); + m_bIsInsertRow = sal_False; m_aOldRow = m_pCache->registerOldRow(); } @@ -2646,6 +2652,7 @@ void ORowSet::doCancelModification( ) m_pCache->cancelRowModification(); } m_bModified = sal_False; + m_bIsInsertRow = sal_False; } sal_Bool ORowSet::isModification( ) @@ -2670,14 +2677,12 @@ sal_Bool ORowSet::isPropertyChangeNotificationEnabled() const void ORowSet::checkUpdateIterator() { - if(!m_bModified && !m_bNew) + if(!m_bIsInsertRow) { m_pCache->setUpdateIterator(m_aCurrentRow); m_aCurrentRow = m_pCache->m_aInsertRow; - m_bModified = sal_True; + m_bIsInsertRow = sal_True; } - else if ( m_bNew ) // here we are modifying a value - m_bModified = sal_True; } void ORowSet::checkUpdateConditions(sal_Int32 columnIndex) diff --git a/dbaccess/source/core/api/RowSetBase.cxx b/dbaccess/source/core/api/RowSetBase.cxx index 0011e231b..81fbd93ea 100644 --- a/dbaccess/source/core/api/RowSetBase.cxx +++ b/dbaccess/source/core/api/RowSetBase.cxx @@ -111,6 +111,7 @@ ORowSetBase::ORowSetBase( const ::comphelper::ComponentContext& _rContext, ::cpp ,m_bIgnoreResult(sal_False) ,m_bBeforeFirst(sal_True) // changed from sal_False ,m_bAfterLast(sal_False) + ,m_bIsInsertRow(sal_False) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetBase::ORowSetBase" ); DBG_CTOR(ORowSetBase,NULL); @@ -255,6 +256,7 @@ const ORowSetValue& ORowSetBase::impl_getValue(sal_Int32 columnIndex) // currentrow is null when the clone moves the window positionCache( MOVE_NONE_REFRESH_ONLY ); m_aCurrentRow = m_pCache->m_aMatrixIter; + m_bIsInsertRow = sal_False; OSL_ENSURE(!m_aCurrentRow.isNull(),"ORowSetBase::getValue: we don't stand on a valid row! Row is null."); bValidCurrentRow = ( !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->is() ); @@ -396,6 +398,7 @@ Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSetBase::getBinaryS { positionCache( MOVE_NONE_REFRESH_ONLY ); m_aCurrentRow = m_pCache->m_aMatrixIter; + m_bIsInsertRow = sal_False; OSL_ENSURE(!m_aCurrentRow.isNull(),"ORowSetBase::getBinaryStream: we don't stand on a valid row! Row is null."); bValidCurrentRow = ( !m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd() && m_aCurrentRow->is() ); @@ -1114,6 +1117,7 @@ void ORowSetBase::setCurrentRow( sal_Bool _bMoved, sal_Bool _bDoNotify, const OR m_aBookmark = m_pCache->getBookmark(); OSL_ENSURE(m_aBookmark.hasValue(),"Bookmark has no value!"); m_aCurrentRow = m_pCache->m_aMatrixIter; + m_bIsInsertRow = sal_False; OSL_ENSURE(!m_aCurrentRow.isNull(),"CurrentRow is null!"); m_aCurrentRow.setBookmark(m_aBookmark); OSL_ENSURE(!m_aCurrentRow.isNull() && m_aCurrentRow != m_pCache->getEnd(),"Position of matrix iterator isn't valid!"); @@ -1129,6 +1133,7 @@ void ORowSetBase::setCurrentRow( sal_Bool _bMoved, sal_Bool _bDoNotify, const OR #endif OSL_ENSURE(nOldRow == nNewRow,"Old position is not equal to new postion"); m_aCurrentRow = m_pCache->m_aMatrixIter; + m_bIsInsertRow = sal_False; OSL_ENSURE(!m_aCurrentRow.isNull(),"CurrentRow is nul after positionCache!"); #if OSL_DEBUG_LEVEL > 0 ORowSetRow rRow = (*m_aCurrentRow); @@ -1139,6 +1144,7 @@ void ORowSetBase::setCurrentRow( sal_Bool _bMoved, sal_Bool _bDoNotify, const OR { positionCache( MOVE_NONE_REFRESH_ONLY ); m_aCurrentRow = m_pCache->m_aMatrixIter; + m_bIsInsertRow = sal_False; OSL_ENSURE(!m_aCurrentRow.isNull(),"CurrentRow is nul after positionCache!"); } } @@ -1569,7 +1575,8 @@ void ORowSetNotifier::firePropertyChange() { m_pRowSet->firePropertyChange((*aIter)-1 ,m_pImpl->aRow[(*aIter)-1], ORowSetBase::GrantNotifierAccess()); } - m_pRowSet->fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False, ORowSetBase::GrantNotifierAccess()); + if ( !m_pImpl->aChangedColumns.empty() ) + m_pRowSet->fireProperty(PROPERTY_ID_ISMODIFIED,sal_True,sal_False, ORowSetBase::GrantNotifierAccess()); } } } // namespace dbaccess diff --git a/dbaccess/source/core/api/RowSetBase.hxx b/dbaccess/source/core/api/RowSetBase.hxx index 516d46112..5b1f0d08e 100644 --- a/dbaccess/source/core/api/RowSetBase.hxx +++ b/dbaccess/source/core/api/RowSetBase.hxx @@ -117,6 +117,7 @@ namespace dbaccess sal_Bool m_bIgnoreResult ; sal_Bool m_bBeforeFirst : 1; sal_Bool m_bAfterLast : 1; + sal_Bool m_bIsInsertRow : 1; protected: ORowSetBase( @@ -345,7 +346,7 @@ namespace dbaccess inline sal_Bool isModification( const GrantNotifierAccess& ) { return isModification(); } inline sal_Bool isModified( const GrantNotifierAccess& ) { return isModified(); } inline sal_Bool isNew( const GrantNotifierAccess& ) { return isNew(); } - inline sal_Bool isInsertRow() { return isNew() || isModified(); } + inline sal_Bool isInsertRow() { return m_bIsInsertRow; } // isNew() || isModified(); } inline void fireProperty( sal_Int32 _nProperty, sal_Bool _bNew, sal_Bool _bOld, const GrantNotifierAccess& ) { fireProperty( _nProperty, _bNew, _bOld ); diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx index 4fba5f490..403afc493 100644 --- a/dbaccess/source/core/api/RowSetCache.cxx +++ b/dbaccess/source/core/api/RowSetCache.cxx @@ -115,12 +115,13 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, DBG_CTOR(ORowSetCache,NULL); // first try if the result can be used to do inserts and updates + Reference< XPropertySet> xProp(_xRs,UNO_QUERY); + Reference< XPropertySetInfo > xPropInfo = xProp->getPropertySetInfo(); + sal_Bool bBookmarkable = sal_False; try { Reference< XResultSetUpdate> xUp(_xRs,UNO_QUERY_THROW); - Reference< XPropertySet> xProp(_xRs,UNO_QUERY); - Reference< XPropertySetInfo > xPropInfo = xProp->getPropertySetInfo(); - sal_Bool bBookmarkable = xPropInfo->hasPropertyByName(PROPERTY_ISBOOKMARKABLE) && + bBookmarkable = xPropInfo->hasPropertyByName(PROPERTY_ISBOOKMARKABLE) && any2bool(xProp->getPropertyValue(PROPERTY_ISBOOKMARKABLE)) && Reference< XRowLocate >(_xRs, UNO_QUERY).is(); if ( bBookmarkable ) { @@ -138,17 +139,22 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, { (void)ex; } - _xRs->beforeFirst(); + try + { + if ( xPropInfo->hasPropertyByName(PROPERTY_RESULTSETTYPE) && + ::comphelper::getINT32(xProp->getPropertyValue(PROPERTY_RESULTSETTYPE)) != ResultSetType::FORWARD_ONLY) + _xRs->beforeFirst(); + } + catch(const SQLException& e) + { + (void)e; + } // check if all keys of the updateable table are fetched sal_Bool bAllKeysFound = sal_False; sal_Int32 nTablesCount = 0; - Reference< XPropertySet> xProp(_xRs,UNO_QUERY); - Reference< XPropertySetInfo > xPropInfo = xProp->getPropertySetInfo(); - sal_Bool bNeedKeySet = !(xPropInfo->hasPropertyByName(PROPERTY_ISBOOKMARKABLE) && - any2bool(xProp->getPropertyValue(PROPERTY_ISBOOKMARKABLE)) && Reference< XRowLocate >(_xRs, UNO_QUERY).is() ); - bNeedKeySet = bNeedKeySet || (xPropInfo->hasPropertyByName(PROPERTY_RESULTSETCONCURRENCY) && + sal_Bool bNeedKeySet = !bBookmarkable || (xPropInfo->hasPropertyByName(PROPERTY_RESULTSETCONCURRENCY) && ::comphelper::getINT32(xProp->getPropertyValue(PROPERTY_RESULTSETCONCURRENCY)) == ResultSetConcurrency::READ_ONLY); Reference< XIndexAccess> xUpdateTableKeys; @@ -175,7 +181,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, if ( aTableNames.getLength() > 1 && !_rUpdateTableName.getLength() && bNeedKeySet ) {// here we have a join or union and nobody told us which table to update, so we update them all m_nPrivileges = Privilege::SELECT|Privilege::DELETE|Privilege::INSERT|Privilege::UPDATE; - OptimisticSet* pCursor = new OptimisticSet(m_aContext,xConnection,_xAnalyzer,_aParameterValueForCache,i_nMaxRows); + OptimisticSet* pCursor = new OptimisticSet(m_aContext,xConnection,_xAnalyzer,_aParameterValueForCache,i_nMaxRows,m_nRowCount); m_pCacheSet = pCursor; m_xCacheSet = m_pCacheSet; try @@ -267,6 +273,16 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, if(!bAllKeysFound ) { + if ( bBookmarkable ) + { + // here I know that we have a read only bookmarable cursor + _xRs->beforeFirst(); + m_nPrivileges = Privilege::SELECT; + m_pCacheSet = new WrappedResultSet(i_nMaxRows); + m_xCacheSet = m_pCacheSet; + m_pCacheSet->construct(_xRs,i_sRowSetFilter); + return; + } m_pCacheSet = new OStaticSet(i_nMaxRows); m_xCacheSet = m_pCacheSet; m_pCacheSet->construct(_xRs,i_sRowSetFilter); @@ -304,7 +320,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, } } - OKeySet* pKeySet = new OKeySet(m_aUpdateTable,xUpdateTableKeys,aUpdateTableName ,_xAnalyzer,_aParameterValueForCache,i_nMaxRows); + OKeySet* pKeySet = new OKeySet(m_aUpdateTable,xUpdateTableKeys,aUpdateTableName ,_xAnalyzer,_aParameterValueForCache,i_nMaxRows,m_nRowCount); try { m_pCacheSet = pKeySet; @@ -434,6 +450,13 @@ void ORowSetCache::setFetchSize(sal_Int32 _nSize) m_nStartPos = 0; m_nEndPos = _nSize; } + else if (m_nStartPos < m_nPosition && m_nPosition < m_nEndPos) + { + sal_Int32 nNewSt = -1; + fillMatrix(nNewSt,_nSize+1); + m_nStartPos = 0; + m_nEndPos = _nSize; + } } // XResultSetMetaDataSupplier @@ -538,13 +561,16 @@ void ORowSetCache::updateNull(sal_Int32 columnIndex,ORowSetValueVector::Vector& checkUpdateConditions(columnIndex); ORowSetValueVector::Vector& rInsert = ((*m_aInsertRow)->get()); - rInsert[columnIndex].setBound(sal_True); - rInsert[columnIndex].setNull(); - rInsert[columnIndex].setModified(); - io_aRow[columnIndex].setNull(); + if ( !rInsert[columnIndex].isNull() ) + { + rInsert[columnIndex].setBound(sal_True); + rInsert[columnIndex].setNull(); + rInsert[columnIndex].setModified(); + io_aRow[columnIndex].setNull(); - m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns); - impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns); + m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns); + impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns); + } } void ORowSetCache::updateValue(sal_Int32 columnIndex,const ORowSetValue& x @@ -555,13 +581,16 @@ void ORowSetCache::updateValue(sal_Int32 columnIndex,const ORowSetValue& x checkUpdateConditions(columnIndex); ORowSetValueVector::Vector& rInsert = ((*m_aInsertRow)->get()); - rInsert[columnIndex].setBound(sal_True); - rInsert[columnIndex] = x; - rInsert[columnIndex].setModified(); - io_aRow[columnIndex] = rInsert[columnIndex]; + if ( rInsert[columnIndex] != x ) + { + rInsert[columnIndex].setBound(sal_True); + rInsert[columnIndex] = x; + rInsert[columnIndex].setModified(); + io_aRow[columnIndex] = rInsert[columnIndex]; - m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns); - impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns); + m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns); + impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns); + } } void ORowSetCache::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x @@ -593,13 +622,18 @@ void ORowSetCache::updateObject( sal_Int32 columnIndex, const Any& x checkUpdateConditions(columnIndex); ORowSetValueVector::Vector& rInsert = ((*m_aInsertRow)->get()); - rInsert[columnIndex].setBound(sal_True); - rInsert[columnIndex] = x; - rInsert[columnIndex].setModified(); - io_aRow[columnIndex] = rInsert[columnIndex]; + ORowSetValue aTemp; + aTemp.fill(x); + if ( rInsert[columnIndex] != aTemp ) + { + rInsert[columnIndex].setBound(sal_True); + rInsert[columnIndex] = aTemp; + rInsert[columnIndex].setModified(); + io_aRow[columnIndex] = rInsert[columnIndex]; - m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns); - impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns); + m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns); + impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns); + } } void ORowSetCache::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 /*scale*/ @@ -610,13 +644,18 @@ void ORowSetCache::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal checkUpdateConditions(columnIndex); ORowSetValueVector::Vector& rInsert = ((*m_aInsertRow)->get()); - rInsert[columnIndex].setBound(sal_True); - rInsert[columnIndex] = x; - rInsert[columnIndex].setModified(); - io_aRow[columnIndex] = rInsert[columnIndex]; + ORowSetValue aTemp; + aTemp.fill(x); + if ( rInsert[columnIndex] != aTemp ) + { + rInsert[columnIndex].setBound(sal_True); + rInsert[columnIndex] = aTemp; + rInsert[columnIndex].setModified(); + io_aRow[columnIndex] = rInsert[columnIndex]; - m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns); - impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns); + m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns); + impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns); + } } // XResultSet @@ -644,8 +683,6 @@ sal_Bool ORowSetCache::next( ) sal_Bool ORowSetCache::isBeforeFirst( ) { - // return !m_nPosition; - return m_bBeforeFirst; } @@ -687,7 +724,7 @@ sal_Bool ORowSetCache::afterLast( ) if(!m_bRowCountFinal) { - m_pCacheSet->last(); + m_pCacheSet->last_checked(sal_False); m_bRowCountFinal = sal_True; m_nRowCount = m_pCacheSet->getRow();// + 1 removed } @@ -703,10 +740,22 @@ sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos,sal_Int32 _nNewEndPos { OSL_ENSURE(_nNewStartPos != _nNewEndPos,"ORowSetCache::fillMatrix: StartPos and EndPos can not be equal!"); // fill the whole window with new data - ORowSetMatrix::iterator aIter = m_pMatrix->begin(); - sal_Bool bCheck = m_pCacheSet->absolute(_nNewStartPos); // -1 no need to + ORowSetMatrix::iterator aIter; + sal_Int32 i; + sal_Bool bCheck; + if ( _nNewStartPos == -1 ) + { + aIter = m_pMatrix->begin() + m_nEndPos; + i = m_nEndPos+1; + } + else + { + aIter = m_pMatrix->begin(); + i = _nNewStartPos; + } + bCheck = m_pCacheSet->absolute(i); // -1 no need to - sal_Int32 i=_nNewStartPos; + for(;i<_nNewEndPos;++i,++aIter) { if(bCheck) @@ -714,13 +763,15 @@ sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos,sal_Int32 _nNewEndPos if(!aIter->is()) *aIter = new ORowSetValueVector(m_xMetaData->getColumnCount()); m_pCacheSet->fillValueRow(*aIter,i); + if(!m_bRowCountFinal) + ++m_nRowCount; } else { // there are no more rows found so we can fetch some before start if(!m_bRowCountFinal) { - if(m_pCacheSet->previous()) // because we stand after the last row + if(m_pCacheSet->previous_checked(sal_False)) // because we stand after the last row m_nRowCount = m_pCacheSet->getRow(); // here we have the row count if(!m_nRowCount) m_nRowCount = i-1; // it can be that getRow return zero @@ -749,15 +800,17 @@ sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos,sal_Int32 _nNewEndPos } break; } - bCheck = m_pCacheSet->next(); + if ( i < (_nNewEndPos-1) ) + bCheck = m_pCacheSet->next(); } - // 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) { if(!m_pCacheSet->next()) { - if(m_pCacheSet->previous()) // because we stand after the last row + if(m_pCacheSet->previous_checked(sal_False)) // because we stand after the last row m_nRowCount = m_pCacheSet->getRow(); // here we have the row count m_bRowCountFinal = sal_True; } @@ -765,6 +818,7 @@ sal_Bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos,sal_Int32 _nNewEndPos m_nRowCount = std::max(i,m_nRowCount); } + */ return bCheck; } @@ -899,19 +953,16 @@ sal_Bool ORowSetCache::moveWindow() // but only when we don't know it already if ( !m_bRowCountFinal ) { - bOk = m_pCacheSet->absolute( m_nPosition + 1 ); + bOk = m_pCacheSet->absolute_checked( m_nPosition + 1,sal_False ); if ( bOk ) m_nRowCount = std::max(sal_Int32(m_nPosition+1),m_nRowCount); } } - if(!bOk) + if(!bOk && !m_bRowCountFinal) { - if(!m_bRowCountFinal) - { - // because we stand after the last row - m_nRowCount = m_pCacheSet->previous() ? m_pCacheSet->getRow() : 0;// + 1 removed - m_bRowCountFinal = sal_True; - } + // because we stand after the last row + m_nRowCount = m_pCacheSet->previous_checked(sal_False) ? m_pCacheSet->getRow() : 0;// + 1 removed + m_bRowCountFinal = sal_True; } } } @@ -942,7 +993,7 @@ sal_Bool ORowSetCache::moveWindow() // now I can say how many rows we have if(!bOk) { - m_pCacheSet->previous(); // because we stand after the last row + m_pCacheSet->previous_checked(sal_False); // because we stand after the last row m_nRowCount = nPos; // here we have the row count m_bRowCountFinal = sal_True; } @@ -959,7 +1010,7 @@ sal_Bool ORowSetCache::moveWindow() if ( !m_bRowCountFinal ) { - m_pCacheSet->previous(); // because we stand after the last row + m_pCacheSet->previous_checked(sal_False); // because we stand after the last row m_nRowCount = std::max(m_nRowCount,--nPos); // here we have the row count OSL_ENSURE(nPos == m_pCacheSet->getRow(),"nPos isn't valid!"); m_bRowCountFinal = sal_True; @@ -975,7 +1026,7 @@ sal_Bool ORowSetCache::moveWindow() aIter = m_pMatrix->begin(); nPos = m_nStartPos; - bCheck = m_pCacheSet->absolute(m_nStartPos); + bCheck = m_pCacheSet->absolute_checked(m_nStartPos,sal_False); for(; !aIter->is() && bCheck;++aIter) { OSL_ENSURE(aIter != m_pMatrix->end(),"Invalid iterator"); diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index 16a01c9f0..518a41912 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -59,6 +59,7 @@ #include <comphelper/sequence.hxx> #include <comphelper/types.hxx> #include <cppuhelper/typeprovider.hxx> +#include <connectivity/predicateinput.hxx> #include <rtl/logfile.hxx> #include <unotools/syslocale.hxx> #include <tools/debug.hxx> @@ -1216,16 +1217,12 @@ sal_Bool OSingleSelectQueryComposer::setComparsionPredicate(OSQLParseNode * pCon ::rtl::OUString aValue; ::rtl::OUString aColumnName; - pCondition->parseNodeToPredicateStr(aValue, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep.toChar() ) ); + pCondition->getChild(2)->parseNodeToPredicateStr(aValue, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep.toChar() ) ); pCondition->getChild(0)->parseNodeToPredicateStr( aColumnName, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep .toChar() ) ); - // don't display the column name - aValue = aValue.copy(aColumnName.getLength()); - aValue.trim(); - aItem.Name = getColumnName(pCondition->getChild(0),_rIterator); aItem.Value <<= aValue; - aItem.Handle = pCondition->getNodeType(); + aItem.Handle = getPredicateType(pCondition->getChild(1)); rFilter.push_back(aItem); } else // kann sich nur um einen Expr. Ausdruck handeln @@ -1242,7 +1239,7 @@ sal_Bool OSingleSelectQueryComposer::setComparsionPredicate(OSQLParseNode * pCon pLhs->getChild(i)->parseNodeToPredicateStr( aName, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep.toChar() ) ); // Kriterium - aItem.Handle = pCondition->getChild(1)->getNodeType(); + aItem.Handle = getPredicateType(pCondition->getChild(1)); aValue = pCondition->getChild(1)->getTokenValue(); for(i=0;i< pRhs->count();i++) pRhs->getChild(i)->parseNodeToPredicateStr(aValue, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep.toChar() ) ); @@ -1483,7 +1480,7 @@ Reference< XIndexAccess > SAL_CALL OSingleSelectQueryComposer::getOrderColumns( namespace { - ::rtl::OUString lcl_getCondition(const Sequence< Sequence< PropertyValue > >& filter ) + ::rtl::OUString lcl_getCondition(const Sequence< Sequence< PropertyValue > >& filter,const OPredicateInputController& i_aPredicateInputController,const Reference< XNameAccess >& i_xSelectColumns) { ::rtl::OUStringBuffer sRet; const Sequence< PropertyValue >* pOrIter = filter.getConstArray(); @@ -1500,6 +1497,15 @@ namespace sRet.append(pAndIter->Name); ::rtl::OUString sValue; pAndIter->Value >>= sValue; + if ( i_xSelectColumns.is() && i_xSelectColumns->hasByName(pAndIter->Name) ) + { + Reference<XPropertySet> xColumn(i_xSelectColumns->getByName(pAndIter->Name),UNO_QUERY); + sValue = i_aPredicateInputController.getPredicateValue(sValue,xColumn,sal_True); + } + else + { + sValue = i_aPredicateInputController.getPredicateValue(pAndIter->Name,sValue,sal_True); + } lcl_addFilterCriteria_throw(pAndIter->Handle,sValue,sRet); ++pAndIter; if ( pAndIter != pAndEnd ) @@ -1518,13 +1524,15 @@ namespace void SAL_CALL OSingleSelectQueryComposer::setStructuredFilter( const Sequence< Sequence< PropertyValue > >& filter ) throw (SQLException, ::com::sun::star::lang::IllegalArgumentException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::setStructuredFilter" ); - setFilter(lcl_getCondition(filter)); + OPredicateInputController aPredicateInput(m_aContext.getLegacyServiceFactory(),m_xConnection); + setFilter(lcl_getCondition(filter,aPredicateInput,getColumns())); } void SAL_CALL OSingleSelectQueryComposer::setStructuredHavingClause( const Sequence< Sequence< PropertyValue > >& filter ) throw (SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::setStructuredHavingClause" ); - setHavingClause(lcl_getCondition(filter)); + OPredicateInputController aPredicateInput(m_aContext.getLegacyServiceFactory(),m_xConnection); + setHavingClause(lcl_getCondition(filter,aPredicateInput,getColumns())); } void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropertySet >& column, sal_Bool andCriteria ,::std::mem_fun1_t<bool,OSingleSelectQueryComposer,::rtl::OUString>& _aSetFunctor,sal_Int32 filterOperator) |