summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java2
-rw-r--r--dbaccess/source/core/api/BookmarkSet.cxx4
-rw-r--r--dbaccess/source/core/api/BookmarkSet.hxx2
-rw-r--r--dbaccess/source/core/api/CacheSet.cxx2
-rw-r--r--dbaccess/source/core/api/CacheSet.hxx2
-rw-r--r--dbaccess/source/core/api/KeySet.cxx118
-rw-r--r--dbaccess/source/core/api/KeySet.hxx10
-rw-r--r--dbaccess/source/core/api/RowSet.cxx83
-rw-r--r--dbaccess/source/core/api/RowSetCache.cxx15
-rw-r--r--dbaccess/source/core/api/RowSetCache.hxx3
-rw-r--r--dbaccess/source/core/api/SingleSelectQueryComposer.cxx225
-rw-r--r--dbaccess/source/core/api/definitioncolumn.cxx14
-rw-r--r--dbaccess/source/core/api/query.cxx24
-rw-r--r--dbaccess/source/core/api/querycomposer.cxx19
-rw-r--r--dbaccess/source/core/inc/SingleSelectQueryComposer.hxx12
-rw-r--r--dbaccess/source/core/inc/definitioncolumn.hxx3
-rw-r--r--dbaccess/source/inc/stringconstants.hrc2
-rw-r--r--dbaccess/source/inc/stringconstants.inc1
-rw-r--r--dbaccess/source/ui/browser/brwctrlr.cxx148
-rw-r--r--dbaccess/source/ui/inc/brwctrlr.hxx5
-rw-r--r--reportdesign/source/filter/xml/xmlGroup.cxx8
21 files changed, 493 insertions, 209 deletions
diff --git a/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java b/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java
index 7b0aed460dc8..40ce60699c05 100755
--- a/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java
+++ b/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java
@@ -263,7 +263,7 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
filter.addProperty("Type", PropertyAttribute.MAYBEVOID, Integer.valueOf(DataType.LONGVARCHAR));
final XPropertySet column = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,filter);
- m_composer.appendFilterByColumn(column, true);
+ m_composer.appendFilterByColumn(column, true,SQLFilterOperator.LIKE);
assure("At least one row should exist",m_database.getConnection().createStatement().executeQuery(m_composer.getQuery()).next());
}
diff --git a/dbaccess/source/core/api/BookmarkSet.cxx b/dbaccess/source/core/api/BookmarkSet.cxx
index 127ee83aaf2c..4f8a97604e57 100644
--- a/dbaccess/source/core/api/BookmarkSet.cxx
+++ b/dbaccess/source/core/api/BookmarkSet.cxx
@@ -62,10 +62,10 @@ using namespace ::com::sun::star::lang;
// using namespace ::cppu;
using namespace ::osl;
-void OBookmarkSet::construct(const Reference< XResultSet>& _xDriverSet)
+void OBookmarkSet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OBookmarkSet::construct" );
- OCacheSet::construct(_xDriverSet);
+ OCacheSet::construct(_xDriverSet,i_sRowSetFilter);
m_xRowLocate.set(_xDriverSet,UNO_QUERY);
}
// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/core/api/BookmarkSet.hxx b/dbaccess/source/core/api/BookmarkSet.hxx
index 4204afd59827..3433e0a5ea6b 100644
--- a/dbaccess/source/core/api/BookmarkSet.hxx
+++ b/dbaccess/source/core/api/BookmarkSet.hxx
@@ -54,7 +54,7 @@ namespace dbaccess
m_xRowLocate = NULL;
}
- virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet);
+ virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter);
virtual void fillValueRow(ORowSetRow& _rRow,sal_Int32 _nPosition);
// ::com::sun::star::sdbcx::XRowLocate
virtual ::com::sun::star::uno::Any SAL_CALL getBookmark() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
diff --git a/dbaccess/source/core/api/CacheSet.cxx b/dbaccess/source/core/api/CacheSet.cxx
index f7be322caa1a..cdff43ca52af 100644
--- a/dbaccess/source/core/api/CacheSet.cxx
+++ b/dbaccess/source/core/api/CacheSet.cxx
@@ -129,7 +129,7 @@ OCacheSet::OCacheSet()
return sQuote;
}
// -------------------------------------------------------------------------
-void OCacheSet::construct( const Reference< XResultSet>& _xDriverSet)
+void OCacheSet::construct( const Reference< XResultSet>& _xDriverSet,const ::rtl::OUString& /*i_sRowSetFilter*/)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::construct" );
OSL_ENSURE(_xDriverSet.is(),"Invalid resultSet");
diff --git a/dbaccess/source/core/api/CacheSet.hxx b/dbaccess/source/core/api/CacheSet.hxx
index 057c843fe871..e0fcf981f2ba 100644
--- a/dbaccess/source/core/api/CacheSet.hxx
+++ b/dbaccess/source/core/api/CacheSet.hxx
@@ -110,7 +110,7 @@ namespace dbaccess
public:
// late constructor
- virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet);
+ virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter);
virtual void fillValueRow(ORowSetRow& _rRow,sal_Int32 _nPosition);
// ::com::sun::star::sdbc::XRow
diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx
index c265944d293a..193aef7e8e77 100644
--- a/dbaccess/source/core/api/KeySet.cxx
+++ b/dbaccess/source/core/api/KeySet.cxx
@@ -162,6 +162,7 @@ OKeySet::OKeySet(const connectivity::OSQLTable& _xTable,
:m_aParameterValueForCache(_aParameterValueForCache)
,m_pKeyColumnNames(NULL)
,m_pColumnNames(NULL)
+ ,m_pParameterNames(NULL)
,m_pForeignColumnNames(NULL)
,m_xTable(_xTable)
,m_xTableKeys(_xTableKeys)
@@ -191,26 +192,40 @@ OKeySet::~OKeySet()
m_xComposer = NULL;
delete m_pKeyColumnNames;
delete m_pColumnNames;
+ delete m_pParameterNames;
delete m_pForeignColumnNames;
DBG_DTOR(OKeySet,NULL);
}
// -----------------------------------------------------------------------------
-void OKeySet::construct(const Reference< XResultSet>& _xDriverSet)
+void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::construct" );
- OCacheSet::construct(_xDriverSet);
+ OCacheSet::construct(_xDriverSet,i_sRowSetFilter);
Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
bool bCase = (xMeta.is() && xMeta->storesMixedCaseQuotedIdentifiers()) ? true : false;
- m_pKeyColumnNames = new SelectColumnsMetaData(bCase);
- m_pColumnNames = new SelectColumnsMetaData(bCase);
- m_pForeignColumnNames = new SelectColumnsMetaData(bCase);
+ m_pKeyColumnNames = new SelectColumnsMetaData(bCase);
+ m_pColumnNames = new SelectColumnsMetaData(bCase);
+ m_pParameterNames = new SelectColumnsMetaData(bCase);
+ m_pForeignColumnNames = new SelectColumnsMetaData(bCase);
Reference<XNameAccess> xKeyColumns = getKeyColumns();
Reference<XColumnsSupplier> xSup(m_xComposer,UNO_QUERY);
Reference<XNameAccess> xSourceColumns = m_xTable->getColumns();
+ // locate parameter in select columns
+ Reference<XParametersSupplier> xParaSup(m_xComposer,UNO_QUERY);
+ Reference<XIndexAccess> xQueryParameters = xParaSup->getParameters();
+ const sal_Int32 nParaCount = xQueryParameters->getCount();
+ Sequence< ::rtl::OUString> aParameterColumns(nParaCount);
+ for(sal_Int32 i = 0; i< nParaCount;++i)
+ {
+ Reference<XPropertySet> xPara(xQueryParameters->getByIndex(i),UNO_QUERY_THROW);
+ xPara->getPropertyValue(PROPERTY_REALNAME) >>= aParameterColumns[i];
+ }
+
+
::rtl::OUString sCatalog,sSchema,sTable;
Reference<XPropertySet> xTableProp(m_xTable,UNO_QUERY);
@@ -238,6 +253,8 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet)
::dbaccess::getColumnPositions(xSup->getColumns(),aBestColumnNames,m_sUpdateTableName,(*m_pKeyColumnNames));
::dbaccess::getColumnPositions(xSup->getColumns(),xSourceColumns->getElementNames(),m_sUpdateTableName,(*m_pColumnNames));
+ ::dbaccess::getColumnPositions(xSup->getColumns(),aParameterColumns,m_sUpdateTableName,(*m_pParameterNames));
+
SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin();
SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end();
@@ -284,9 +301,10 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet)
aFilter.append(aAnd);
}
+ Reference< XSingleSelectQueryComposer> xSourceComposer(m_xComposer,UNO_QUERY);
Reference< XMultiServiceFactory > xFactory(m_xConnection, UNO_QUERY_THROW);
Reference<XSingleSelectQueryComposer> xAnalyzer(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY);
- xAnalyzer->setQuery(m_xComposer->getQuery());
+ xAnalyzer->setElementaryQuery(xSourceComposer->getElementaryQuery());
Reference<XTablesSupplier> xTabSup(xAnalyzer,uno::UNO_QUERY);
Reference<XNameAccess> xSelectTables(xTabSup->getTables(),uno::UNO_QUERY);
const Sequence< ::rtl::OUString> aSeq = xSelectTables->getElementNames();
@@ -323,12 +341,12 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet)
}
}
} // if ( aSeq.getLength() > 1 ) // special handling for join
- const ::rtl::OUString sOldFilter = xAnalyzer->getFilter();
- if ( sOldFilter.getLength() )
+ //const ::rtl::OUString sOldFilter = xAnalyzer->getFilter();
+ if ( i_sRowSetFilter.getLength() )
{
FilterCreator aFilterCreator;
+ aFilterCreator.append( i_sRowSetFilter );
aFilterCreator.append( aFilter.makeStringAndClear() );
- aFilterCreator.append( sOldFilter );
aFilter = aFilterCreator.getComposedAndClear();
}
xAnalyzer->setFilter(aFilter.makeStringAndClear());
@@ -597,6 +615,7 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow
sal_Int32 nPos = aIter->second.nPosition;
if((_rInsertRow->get())[nPos].isModified())
{
+ impl_convertValue_throw(_rInsertRow,aIter->second);
(_rInsertRow->get())[nPos].setSigned((_rOrginalRow->get())[nPos].isSigned());
setParameter(i++,xParameter,(_rInsertRow->get())[nPos],aIter->second.nType,aIter->second.nScale);
}
@@ -623,10 +642,10 @@ 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()));
- OSL_ENSURE(m_aKeyIter != m_aKeyMap.end(),"New inserted row not found!");
+ const sal_Int32 nBookmark = ::comphelper::getINT32((_rInsertRow->get())[0].getAny());
+ m_aKeyIter = m_aKeyMap.find(nBookmark);
m_aKeyIter->second.second = 2;
- copyRowValue(_rInsertRow,m_aKeyIter->second.first);
+ copyRowValue(_rInsertRow,m_aKeyIter->second.first,nBookmark);
}
}
// -------------------------------------------------------------------------
@@ -679,6 +698,7 @@ void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivi
xParameter->setNull(i++,(_rInsertRow->get())[nPos].getTypeKind());
else
{
+ impl_convertValue_throw(_rInsertRow,aIter->second);
(_rInsertRow->get())[nPos].setSigned(m_aSignedFlags[nPos-1]);
setParameter(i++,xParameter,(_rInsertRow->get())[nPos],aIter->second.nType,aIter->second.nScale);
}
@@ -786,21 +806,47 @@ void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivi
}
if ( m_bInserted )
{
- ORowSetRow aKeyRow = new connectivity::ORowVector< ORowSetValue >((*m_pKeyColumnNames).size());
- copyRowValue(_rInsertRow,aKeyRow);
-
OKeySetMatrix::iterator aKeyIter = m_aKeyMap.end();
--aKeyIter;
+ ORowSetRow aKeyRow = new connectivity::ORowVector< ORowSetValue >((*m_pKeyColumnNames).size());
+ copyRowValue(_rInsertRow,aKeyRow,aKeyIter->first + 1);
+
m_aKeyIter = m_aKeyMap.insert(OKeySetMatrix::value_type(aKeyIter->first + 1,OKeySetValue(aKeyRow,1))).first;
// now we set the bookmark for this row
(_rInsertRow->get())[0] = makeAny((sal_Int32)m_aKeyIter->first);
}
}
// -----------------------------------------------------------------------------
-void OKeySet::copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow)
+void OKeySet::copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow,sal_Int32 i_nBookmark)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::copyRowValue" );
connectivity::ORowVector< ORowSetValue >::Vector::iterator aIter = _rKeyRow->get().begin();
+
+ // check the if the parameter values have been changed
+ OSL_ENSURE((m_aParameterValueForCache.get().size()-1) == m_pParameterNames->size(),"OKeySet::copyRowValue: Parameter values and names differ!");
+ connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaValuesIter = m_aParameterValueForCache.get().begin() +1;
+
+ bool bChanged = false;
+ SelectColumnsMetaData::const_iterator aParaIter = (*m_pParameterNames).begin();
+ SelectColumnsMetaData::const_iterator aParaEnd = (*m_pParameterNames).end();
+ for(sal_Int32 i = 1;aParaIter != aParaEnd;++aParaIter,++aParaValuesIter,++i)
+ {
+ ORowSetValue aValue(*aParaValuesIter);
+ aValue.setSigned(m_aSignedFlags[aParaIter->second.nPosition]);
+ if ( (_rInsertRow->get())[aParaIter->second.nPosition] != aValue )
+ {
+ ORowSetValueVector aCopy(m_aParameterValueForCache);
+ (aCopy.get())[i] = (_rInsertRow->get())[aParaIter->second.nPosition];
+ m_aUpdatedParameter[i_nBookmark] = aCopy;
+ bChanged = true;
+ }
+ }
+ if ( !bChanged )
+ {
+ m_aUpdatedParameter.erase(i_nBookmark);
+ }
+
+ // update the key values
SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin();
SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end();
for(;aPosIter != aPosEnd;++aPosIter,++aIter)
@@ -1150,9 +1196,23 @@ void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException)
Reference< XParameters > xParameter(m_xStatement,UNO_QUERY);
OSL_ENSURE(xParameter.is(),"No Parameter interface!");
xParameter->clearParameters();
+
sal_Int32 nPos=1;
- connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaIter = m_aParameterValueForCache.get().begin();
- connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaEnd = m_aParameterValueForCache.get().end();
+ connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaIter;
+ connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaEnd;
+ OUpdatedParameter::iterator aUpdateFind = m_aUpdatedParameter.find(m_aKeyIter->first);
+ if ( aUpdateFind == m_aUpdatedParameter.end() )
+ {
+
+ aParaIter = m_aParameterValueForCache.get().begin();
+ aParaEnd = m_aParameterValueForCache.get().end();
+ }
+ else
+ {
+ aParaIter = aUpdateFind->second.get().begin();
+ aParaEnd = aUpdateFind->second.get().end();
+ }
+
for(++aParaIter;aParaIter != aParaEnd;++aParaIter,++nPos)
{
::dbtools::setObjectWithInfo( xParameter, nPos, aParaIter->makeAny(), aParaIter->getTypeKind() );
@@ -1463,3 +1523,25 @@ namespace dbaccess
}
}
}
+// -----------------------------------------------------------------------------
+void OKeySet::impl_convertValue_throw(const ORowSetRow& _rInsertRow,const SelectColumnDescription& i_aMetaData)
+{
+ ORowSetValue& aValue((_rInsertRow->get())[i_aMetaData.nPosition]);
+ switch(i_aMetaData.nType)
+ {
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ {
+ ::rtl::OUString sValue = aValue.getString();
+ sal_Int32 nIndex = sValue.indexOf('.');
+ if ( nIndex != -1 )
+ {
+ aValue = sValue.copy(0,nIndex + (i_aMetaData.nScale > 0 ? i_aMetaData.nScale + 1 : 0));
+ }
+ }
+ break;
+ default:
+ break;
+ }
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/core/api/KeySet.hxx b/dbaccess/source/core/api/KeySet.hxx
index 7a213d05b466..7db5c176e9ff 100644
--- a/dbaccess/source/core/api/KeySet.hxx
+++ b/dbaccess/source/core/api/KeySet.hxx
@@ -89,6 +89,7 @@ namespace dbaccess
typedef ::std::pair<ORowSetRow,sal_Int32> OKeySetValue;
typedef ::std::map<sal_Int32,OKeySetValue > OKeySetMatrix;
+ typedef ::std::map<sal_Int32,ORowSetValueVector > OUpdatedParameter;
// is used when the source supports keys
class OKeySet : public OCacheSet
{
@@ -97,9 +98,11 @@ namespace dbaccess
::std::vector< ::rtl::OUString > m_aAutoColumns; // contains all columns which are autoincrement ones
+ OUpdatedParameter m_aUpdatedParameter; // contains all parameter which have been updated and are needed for refetching
ORowSetValueVector m_aParameterValueForCache;
SelectColumnsMetaData* m_pKeyColumnNames; // contains all key column names
SelectColumnsMetaData* m_pColumnNames; // contains all column names
+ SelectColumnsMetaData* m_pParameterNames; // contains all parameter names
SelectColumnsMetaData* m_pForeignColumnNames; // contains all column names of the rest
connectivity::OSQLTable m_xTable; // reference to our table
::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess> m_xTableKeys;
@@ -128,12 +131,15 @@ namespace dbaccess
*
* \param _rInsertRow the row which was inserted
* \param _rKeyRow The current key row of the row set.
+ + \param i_nBookmark The bookmark is used to update the parameter
*/
- void copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow);
+ void copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow,sal_Int32 i_nBookmark);
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > getKeyColumns() const;
void fillAllRows();
sal_Bool fetchRow();
+
+ void impl_convertValue_throw(const ORowSetRow& _rInsertRow,const SelectColumnDescription& i_aMetaData);
protected:
virtual ~OKeySet();
public:
@@ -144,7 +150,7 @@ namespace dbaccess
const ORowSetValueVector& _aParameterValueForCache);
// late ctor which can throw exceptions
- virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet);
+ virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter);
// ::com::sun::star::sdbc::XRow
virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx
index cd7d907372ab..01f6d7d3259b 100644
--- a/dbaccess/source/core/api/RowSet.cxx
+++ b/dbaccess/source/core/api/RowSet.cxx
@@ -201,6 +201,7 @@ ORowSet::ORowSet( const Reference< ::com::sun::star::lang::XMultiServiceFactory
registerProperty(PROPERTY_PRIVILEGES, PROPERTY_ID_PRIVILEGES, nRT, &m_nPrivileges, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
registerProperty(PROPERTY_ISMODIFIED, PROPERTY_ID_ISMODIFIED, nBT, &m_bModified, ::getBooleanCppuType());
registerProperty(PROPERTY_ISNEW, PROPERTY_ID_ISNEW, nRBT, &m_bNew, ::getBooleanCppuType());
+ registerProperty(PROPERTY_SINGLESELECTQUERYCOMPOSER,PROPERTY_ID_SINGLESELECTQUERYCOMPOSER, nRT, &m_xComposer, ::getCppuType(reinterpret_cast< Reference< XSingleSelectQueryComposer >* >(NULL)));
// sdbcx.ResultSet Properties
registerProperty(PROPERTY_ISBOOKMARKABLE, PROPERTY_ID_ISBOOKMARKABLE, nRT, &m_bIsBookmarable, ::getBooleanCppuType());
@@ -993,7 +994,7 @@ void SAL_CALL ORowSet::updateRow( ) throw(SQLException, RuntimeException)
fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True);
OSL_ENSURE( !m_bModified, "ORowSet::updateRow: just updated, but _still_ modified?" );
}
- else // the update went rong
+ else if ( !m_bAfterLast ) // the update went rong
{
::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_UPDATE_FAILED ), SQL_INVALID_CURSOR_POSITION, *this );
}
@@ -1778,7 +1779,7 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "frank.schoenheit@sun.com", "ORowSet::execute_NoApprove_NoNewConn: creating cache" );
- m_pCache = new ORowSetCache( xResultSet, m_xComposer.get(), m_aContext, aComposedUpdateTableName, m_bModified, m_bNew,m_aParameterValueForCache );
+ m_pCache = new ORowSetCache( xResultSet, m_xComposer.get(), m_aContext, aComposedUpdateTableName, m_bModified, m_bNew,m_aParameterValueForCache,m_aFilter );
if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY )
{
m_nPrivileges = Privilege::SELECT;
@@ -2226,7 +2227,8 @@ sal_Bool ORowSet::impl_initComposer_throw( ::rtl::OUString& _out_rCommandToExecu
if ( !m_xComposer.is() )
m_xComposer = new OSingleSelectQueryComposer( impl_getTables_throw(), m_xActiveConnection, m_aContext );
- m_xComposer->setElementaryQuery( m_aActiveCommand );
+ m_xComposer->setCommand( m_aCommand,m_nCommandType );
+ m_aActiveCommand = m_xComposer->getQuery();
m_xComposer->setFilter( m_bApplyFilter ? m_aFilter : ::rtl::OUString() );
m_xComposer->setHavingClause( m_bApplyFilter ? m_aHavingClause : ::rtl::OUString() );
@@ -2252,6 +2254,7 @@ sal_Bool ORowSet::impl_initComposer_throw( ::rtl::OUString& _out_rCommandToExecu
impl_initParametersContainer_nothrow();
_out_rCommandToExecute = m_xComposer->getQueryWithSubstitution();
+
return bUseEscapeProcessing;
}
@@ -2274,41 +2277,52 @@ sal_Bool ORowSet::impl_buildActiveCommand_throw()
case CommandType::TABLE:
{
impl_resetTables_nothrow();
-
- Reference< XNameAccess > xTables( impl_getTables_throw() );
- if ( xTables->hasByName(m_aCommand) )
+ if ( bDoEscapeProcessing )
{
- Reference< XPropertySet > xTable;
- try
- {
- xTables->getByName( m_aCommand ) >>= xTable;
- }
- catch(const WrappedTargetException& e)
+ Reference< XNameAccess > xTables( impl_getTables_throw() );
+ if ( xTables->hasByName(m_aCommand) )
{
- SQLException e2;
- if ( e.TargetException >>= e2 )
- throw e2;
+/*
+ Reference< XPropertySet > xTable;
+ try
+ {
+ xTables->getByName( m_aCommand ) >>= xTable;
+ }
+ catch(const WrappedTargetException& e)
+ {
+ SQLException e2;
+ if ( e.TargetException >>= e2 )
+ throw e2;
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ Reference<XColumnsSupplier> xSup(xTable,UNO_QUERY);
+ if ( xSup.is() )
+ m_xColumns = xSup->getColumns();
+
+ sCommand = rtl::OUString::createFromAscii("SELECT * FROM ");
+ ::rtl::OUString sCatalog, sSchema, sTable;
+ ::dbtools::qualifiedNameComponents( m_xActiveConnection->getMetaData(), m_aCommand, sCatalog, sSchema, sTable, ::dbtools::eInDataManipulation );
+ sCommand += ::dbtools::composeTableNameForSelect( m_xActiveConnection, sCatalog, sSchema, sTable );
+*/
}
- catch(Exception&)
+ else
{
- DBG_UNHANDLED_EXCEPTION();
+ String sMessage( DBACORE_RESSTRING( RID_STR_TABLE_DOES_NOT_EXIST ) );
+ sMessage.SearchAndReplaceAscii( "$table$", m_aCommand );
+ throwGenericSQLException(sMessage,*this);
}
-
- Reference<XColumnsSupplier> xSup(xTable,UNO_QUERY);
- if ( xSup.is() )
- m_xColumns = xSup->getColumns();
-
+ }
+ else
+ {
sCommand = rtl::OUString::createFromAscii("SELECT * FROM ");
::rtl::OUString sCatalog, sSchema, sTable;
::dbtools::qualifiedNameComponents( m_xActiveConnection->getMetaData(), m_aCommand, sCatalog, sSchema, sTable, ::dbtools::eInDataManipulation );
sCommand += ::dbtools::composeTableNameForSelect( m_xActiveConnection, sCatalog, sSchema, sTable );
}
- else
- {
- String sMessage( DBACORE_RESSTRING( RID_STR_TABLE_DOES_NOT_EXIST ) );
- sMessage.SearchAndReplaceAscii( "$table$", m_aCommand );
- throwGenericSQLException(sMessage,*this);
- }
}
break;
@@ -2339,10 +2353,11 @@ sal_Bool ORowSet::impl_buildActiveCommand_throw()
xQuery->getPropertyValue(PROPERTY_UPDATE_TABLENAME) >>= aTable;
if(aTable.getLength())
m_aUpdateTableName = composeTableName( m_xActiveConnection->getMetaData(), aCatalog, aSchema, aTable, sal_False, ::dbtools::eInDataManipulation );
-
+/*
Reference<XColumnsSupplier> xSup(xQuery,UNO_QUERY);
if(xSup.is())
m_xColumns = xSup->getColumns();
+*/
}
}
else
@@ -2364,7 +2379,7 @@ sal_Bool ORowSet::impl_buildActiveCommand_throw()
m_aActiveCommand = sCommand;
- if ( !m_aActiveCommand.getLength() )
+ if ( !m_aActiveCommand.getLength() && !bDoEscapeProcessing )
::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_SQL_COMMAND ), SQL_FUNCTION_SEQUENCE_ERROR, *this );
return bDoEscapeProcessing;
@@ -2667,8 +2682,8 @@ void ORowSet::checkUpdateIterator()
void ORowSet::checkUpdateConditions(sal_Int32 columnIndex)
{
checkCache();
- if ( columnIndex <= 0 || sal_Int32((*m_aCurrentRow)->get().size()) <= columnIndex )
- ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_INVALID_INDEX ), SQL_INVALID_DESCRIPTOR_INDEX, *this );
+ if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY)
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_RESULT_IS_READONLY ), SQL_GENERAL_ERROR, *this );
if ( rowDeleted() )
::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_ROW_ALREADY_DELETED ), SQL_INVALID_CURSOR_POSITION, *this );
@@ -2676,8 +2691,8 @@ void ORowSet::checkUpdateConditions(sal_Int32 columnIndex)
if ( m_aCurrentRow.isNull() )
::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_INVALID_CURSOR_STATE ), SQL_INVALID_CURSOR_STATE, *this );
- if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY)
- ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_RESULT_IS_READONLY ), SQL_GENERAL_ERROR, *this );
+ if ( columnIndex <= 0 || sal_Int32((*m_aCurrentRow)->get().size()) <= columnIndex )
+ ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_INVALID_INDEX ), SQL_INVALID_DESCRIPTOR_INDEX, *this );
}
// -----------------------------------------------------------------------------
void SAL_CALL ORowSet::refreshRow( ) throw(SQLException, RuntimeException)
diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx
index 3dd4dad67441..924fd881346e 100644
--- a/dbaccess/source/core/api/RowSetCache.cxx
+++ b/dbaccess/source/core/api/RowSetCache.cxx
@@ -138,7 +138,8 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
const ::rtl::OUString& _rUpdateTableName,
sal_Bool& _bModified,
sal_Bool& _bNew,
- const ORowSetValueVector& _aParameterValueForCache)
+ const ORowSetValueVector& _aParameterValueForCache,
+ const ::rtl::OUString& i_sRowSetFilter)
:m_xSet(_xRs)
,m_xMetaData(Reference< XResultSetMetaDataSupplier >(_xRs,UNO_QUERY)->getMetaData())
,m_aContext( _rContext )
@@ -260,7 +261,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
{
m_pCacheSet = new OBookmarkSet();
m_xCacheSet = m_pCacheSet;
- m_pCacheSet->construct(_xRs);
+ m_pCacheSet->construct(_xRs,i_sRowSetFilter);
// check privileges
m_nPrivileges = Privilege::SELECT;
@@ -294,7 +295,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
{
m_pCacheSet = new OStaticSet();
m_xCacheSet = m_pCacheSet;
- m_pCacheSet->construct(_xRs);
+ m_pCacheSet->construct(_xRs,i_sRowSetFilter);
m_nPrivileges = Privilege::SELECT;
}
else
@@ -335,7 +336,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
{
m_pCacheSet = pKeySet;
m_xCacheSet = m_pCacheSet;
- pKeySet->construct(_xRs);
+ pKeySet->construct(_xRs,i_sRowSetFilter);
if(Reference<XResultSetUpdate>(_xRs,UNO_QUERY).is()) // this interface is optional so we have to check it
{
@@ -359,7 +360,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
m_xCacheSet = NULL;
m_pCacheSet = new OStaticSet();
m_xCacheSet = m_pCacheSet;
- m_pCacheSet->construct(_xRs);
+ m_pCacheSet->construct(_xRs,i_sRowSetFilter);
m_nPrivileges = Privilege::SELECT;
}
}
@@ -1284,9 +1285,7 @@ void ORowSetCache::updateRow( ORowSetMatrix::iterator& _rUpdateRow )
// refetch the whole row
(*m_aMatrixIter) = NULL;
- if ( !moveToBookmark(aBookmark) )
- m_aMatrixIter = m_pMatrix->end();
-
+ moveToBookmark(aBookmark);
// moveToBookmark((*(*m_aInsertRow))[0].makeAny());
// if(m_pCacheSet->rowUpdated())
// *m_aMatrixIter = m_aInsertRow;
diff --git a/dbaccess/source/core/api/RowSetCache.hxx b/dbaccess/source/core/api/RowSetCache.hxx
index 1f5be3113f8b..268c32294824 100644
--- a/dbaccess/source/core/api/RowSetCache.hxx
+++ b/dbaccess/source/core/api/RowSetCache.hxx
@@ -195,7 +195,8 @@ namespace dbaccess
const ::rtl::OUString& _rUpdateTableName,
sal_Bool& _bModified,
sal_Bool& _bNew,
- const ORowSetValueVector& _aParameterValueForCache);
+ const ORowSetValueVector& _aParameterValueForCache,
+ const ::rtl::OUString& i_sRowSetFilter);
~ORowSetCache();
diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
index e76f31e09cdb..c7dd2c130f44 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -46,6 +46,8 @@
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/sdb/BooleanComparisonMode.hpp>
#include <com/sun/star/sdb/SQLFilterOperator.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
#include <com/sun/star/sdbc/ColumnSearch.hpp>
#include <com/sun/star/sdbc/DataType.hpp>
#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
@@ -190,6 +192,53 @@ namespace
if ( _bDispose )
_rIterator.dispose();
}
+ void lcl_addFilterCriteria_throw(sal_Int32 i_nFilterOperator,const ::rtl::OUString& i_sValue,::rtl::OUStringBuffer& o_sRet)
+ {
+ switch( i_nFilterOperator )
+ {
+ case SQLFilterOperator::EQUAL:
+ o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" = ")));
+ o_sRet.append(i_sValue);
+ break;
+ case SQLFilterOperator::NOT_EQUAL:
+ o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" <> ")));
+ o_sRet.append(i_sValue);
+ break;
+ case SQLFilterOperator::LESS:
+ o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" < ")));
+ o_sRet.append(i_sValue);
+ break;
+ case SQLFilterOperator::GREATER:
+ o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" > ")));
+ o_sRet.append(i_sValue);
+ break;
+ case SQLFilterOperator::LESS_EQUAL:
+ o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" <= ")));
+ o_sRet.append(i_sValue);
+ break;
+ case SQLFilterOperator::GREATER_EQUAL:
+ o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" >= ")));
+ o_sRet.append(i_sValue);
+ break;
+ case SQLFilterOperator::LIKE:
+ o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" LIKE ")));
+ o_sRet.append(i_sValue);
+ break;
+ case SQLFilterOperator::NOT_LIKE:
+ o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" NOT LIKE ")));
+ o_sRet.append(i_sValue);
+ break;
+ case SQLFilterOperator::SQLNULL:
+ o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" IS NULL")) );
+ break;
+ case SQLFilterOperator::NOT_SQLNULL:
+ o_sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" IS NOT NULL")) );
+ break;
+ default:
+ throw SQLException();
+ }
+ }
+
}
DBG_NAME(OSingleSelectQueryComposer)
@@ -209,6 +258,7 @@ OSingleSelectQueryComposer::OSingleSelectQueryComposer(const Reference< XNameAcc
,m_aContext( _rContext )
,m_pTables(NULL)
,m_nBoolCompareMode( BooleanComparisonMode::EQUAL_INTEGER )
+ ,m_nCommandType(CommandType::COMMAND)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::OSingleSelectQueryComposer" );
DBG_CTOR(OSingleSelectQueryComposer,NULL);
@@ -235,6 +285,9 @@ OSingleSelectQueryComposer::OSingleSelectQueryComposer(const Reference< XNameAcc
{
OSL_VERIFY( aValue >>= m_nBoolCompareMode );
}
+ Reference< XQueriesSupplier > xQueriesAccess(m_xConnection, UNO_QUERY);
+ if (xQueriesAccess.is())
+ m_xConnectionQueries = xQueriesAccess->getQueries();
}
catch(Exception&)
{
@@ -306,6 +359,7 @@ void SAL_CALL OSingleSelectQueryComposer::setQuery( const ::rtl::OUString& comma
::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
::osl::MutexGuard aGuard( m_aMutex );
+ m_nCommandType = CommandType::COMMAND;
// first clear the tables and columns
clearCurrentCollections();
// now set the new one
@@ -319,6 +373,85 @@ void SAL_CALL OSingleSelectQueryComposer::setQuery( const ::rtl::OUString& comma
for ( SQLPart eLoopParts = Where; eLoopParts != SQLPartCount; incSQLPart( eLoopParts ) )
m_aElementaryParts[ eLoopParts ] = ::rtl::OUString();
}
+// -------------------------------------------------------------------------
+void SAL_CALL OSingleSelectQueryComposer::setCommand( const ::rtl::OUString& Command,sal_Int32 _nCommandType ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUStringBuffer sSQL;
+ switch(_nCommandType)
+ {
+ case CommandType::COMMAND:
+ setElementaryQuery(Command);
+ return;
+ break;
+ case CommandType::TABLE:
+ if ( m_xConnectionTables->hasByName(Command) )
+ {
+ sSQL.appendAscii("SELECT * FROM ");
+ Reference< XPropertySet > xTable;
+ try
+ {
+ m_xConnectionTables->getByName( Command ) >>= xTable;
+ }
+ catch(const WrappedTargetException& e)
+ {
+ SQLException e2;
+ if ( e.TargetException >>= e2 )
+ throw e2;
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ sSQL.append(dbtools::composeTableNameForSelect(m_xConnection,xTable));
+ }
+ else
+ {
+ String sMessage( DBACORE_RESSTRING( RID_STR_TABLE_DOES_NOT_EXIST ) );
+ sMessage.SearchAndReplaceAscii( "$table$", Command );
+ throwGenericSQLException(sMessage,*this);
+ }
+ break;
+ case CommandType::QUERY:
+ if ( m_xConnectionQueries->hasByName(Command) )
+ {
+
+ Reference<XPropertySet> xQuery(m_xConnectionQueries->getByName(Command),UNO_QUERY);
+ ::rtl::OUString sCommand;
+ xQuery->getPropertyValue(PROPERTY_COMMAND) >>= sCommand;
+ sSQL.append(sCommand);
+ }
+ else
+ {
+ String sMessage( DBACORE_RESSTRING( RID_STR_QUERY_DOES_NOT_EXIST ) );
+ sMessage.SearchAndReplaceAscii( "$table$", Command );
+ throwGenericSQLException(sMessage,*this);
+ }
+
+ break;
+ default:
+ break;
+ }
+ ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_nCommandType = _nCommandType;
+ m_sCommand = Command;
+ // first clear the tables and columns
+ clearCurrentCollections();
+ // now set the new one
+ ::rtl::OUString sCommand = sSQL.makeStringAndClear();
+ setElementaryQuery(sCommand);
+ m_sOrignal = sCommand;
+/*
+ // reset the additive iterator to the same statement
+ parseAndCheck_throwError( m_aSqlParser, m_sOrignal, m_aAdditiveIterator, *this );
+
+ // we have no "elementary" parts anymore (means filter/groupby/having/order clauses)
+ for ( SQLPart eLoopParts = Where; eLoopParts != SQLPartCount; incSQLPart( eLoopParts ) )
+ m_aElementaryParts[ eLoopParts ] = ::rtl::OUString();
+*/
+}
// -----------------------------------------------------------------------------
void OSingleSelectQueryComposer::setQuery_Impl( const ::rtl::OUString& command )
{
@@ -350,18 +483,18 @@ Sequence< Sequence< PropertyValue > > SAL_CALL OSingleSelectQueryComposer::getSt
return getStructuredCondition(F_tmp);
}
// -----------------------------------------------------------------------------
-void SAL_CALL OSingleSelectQueryComposer::appendHavingClauseByColumn( const Reference< XPropertySet >& column, sal_Bool andCriteria ) throw (SQLException, RuntimeException)
+void SAL_CALL OSingleSelectQueryComposer::appendHavingClauseByColumn( const Reference< XPropertySet >& column, sal_Bool andCriteria,sal_Int32 filterOperator ) throw (SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::appendHavingClauseByColumn" );
::std::mem_fun1_t<bool,OSingleSelectQueryComposer,::rtl::OUString> F_tmp(&OSingleSelectQueryComposer::implSetHavingClause);
- setConditionByColumn(column,andCriteria,F_tmp);
+ setConditionByColumn(column,andCriteria,F_tmp,filterOperator);
}
// -----------------------------------------------------------------------------
-void SAL_CALL OSingleSelectQueryComposer::appendFilterByColumn( const Reference< XPropertySet >& column, sal_Bool andCriteria ) throw(SQLException, RuntimeException)
+void SAL_CALL OSingleSelectQueryComposer::appendFilterByColumn( const Reference< XPropertySet >& column, sal_Bool andCriteria,sal_Int32 filterOperator ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::appendFilterByColumn" );
::std::mem_fun1_t<bool,OSingleSelectQueryComposer,::rtl::OUString> F_tmp(&OSingleSelectQueryComposer::implSetFilter);
- setConditionByColumn(column,andCriteria,F_tmp);
+ setConditionByColumn(column,andCriteria,F_tmp,filterOperator);
}
// -----------------------------------------------------------------------------
::rtl::OUString OSingleSelectQueryComposer::impl_getColumnName_throw(const Reference< XPropertySet >& column)
@@ -659,6 +792,13 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getColumns( ) thr
::std::vector< ::rtl::OUString> aNames;
::vos::ORef< OSQLColumns> aSelectColumns;
sal_Bool bCase = sal_True;
+ Reference< XNameAccess> xQueryColumns;
+ if ( m_nCommandType == CommandType::QUERY )
+ {
+ Reference<XColumnsSupplier> xSup(m_xConnectionQueries->getByName(m_sCommand),UNO_QUERY);
+ if(xSup.is())
+ xQueryColumns = xSup->getColumns();
+ }
do {
@@ -740,7 +880,14 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getColumns( ) thr
for(sal_Int32 i=1;i<=nCount;++i)
{
::rtl::OUString sColumnName = xResultSetMeta->getColumnName(i);
- ::rtl::OUString sColumnLabel = xResultSetMeta->getColumnLabel(i);
+ ::rtl::OUString sColumnLabel;
+ if ( xQueryColumns.is() && xQueryColumns->hasByName(sColumnName) )
+ {
+ Reference<XPropertySet> xQueryColumn(xQueryColumns->getByName(sColumnName),UNO_QUERY_THROW);
+ xQueryColumn->getPropertyValue(PROPERTY_LABEL) >>= sColumnLabel;
+ }
+ else
+ sColumnLabel = xResultSetMeta->getColumnLabel(i);
sal_Bool bFound = sal_False;
OSQLColumns::Vector::const_iterator aFind = ::connectivity::find(aSelectColumns->get().begin(),aSelectColumns->get().end(),sColumnLabel,aCaseCompare);
size_t nFoundSelectColumnPos = aFind - aSelectColumns->get().begin();
@@ -1372,49 +1519,7 @@ namespace
sRet.append(pAndIter->Name);
::rtl::OUString sValue;
pAndIter->Value >>= sValue;
- switch( pAndIter->Handle )
- {
- case SQLFilterOperator::EQUAL:
- sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" = ")));
- sRet.append(sValue);
- break;
- case SQLFilterOperator::NOT_EQUAL:
- sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" <> ")));
- sRet.append(sValue);
- break;
- case SQLFilterOperator::LESS:
- sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" < ")));
- sRet.append(sValue);
- break;
- case SQLFilterOperator::GREATER:
- sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" > ")));
- sRet.append(sValue);
- break;
- case SQLFilterOperator::LESS_EQUAL:
- sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" <= ")));
- sRet.append(sValue);
- break;
- case SQLFilterOperator::GREATER_EQUAL:
- sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" >= ")));
- sRet.append(sValue);
- break;
- case SQLFilterOperator::LIKE:
- sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" LIKE ")));
- sRet.append(sValue);
- break;
- case SQLFilterOperator::NOT_LIKE:
- sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" NOT LIKE ")));
- sRet.append(sValue);
- break;
- case SQLFilterOperator::SQLNULL:
- sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" IS NULL")) );
- break;
- case SQLFilterOperator::NOT_SQLNULL:
- sRet.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" IS NOT NULL")) );
- break;
- default:
- throw IllegalArgumentException();
- }
+ lcl_addFilterCriteria_throw(pAndIter->Handle,sValue,sRet);
++pAndIter;
if ( pAndIter != pAndEnd )
sRet.append(STR_AND);
@@ -1441,7 +1546,7 @@ void SAL_CALL OSingleSelectQueryComposer::setStructuredHavingClause( const Seque
setHavingClause(lcl_getCondition(filter));
}
// -----------------------------------------------------------------------------
-void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropertySet >& column, sal_Bool andCriteria ,::std::mem_fun1_t<bool,OSingleSelectQueryComposer,::rtl::OUString>& _aSetFunctor)
+void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropertySet >& column, sal_Bool andCriteria ,::std::mem_fun1_t<bool,OSingleSelectQueryComposer,::rtl::OUString>& _aSetFunctor,sal_Int32 filterOperator)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::setConditionByColumn" );
::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
@@ -1506,18 +1611,24 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert
aSQL.append( ::dbtools::quoteName( aQuote, aName ) );
}
+
if ( aValue.hasValue() )
{
if( !m_xTypeConverter.is() )
m_aContext.createComponent( "com.sun.star.script.Converter", m_xTypeConverter );
OSL_ENSURE(m_xTypeConverter.is(),"NO typeconverter!");
+ if ( nType != DataType::BOOLEAN && DataType::BIT != nType )
+ {
+ ::rtl::OUString sEmpty;
+ lcl_addFilterCriteria_throw(filterOperator,sEmpty,aSQL);
+ }
+
switch(nType)
{
case DataType::VARCHAR:
case DataType::CHAR:
case DataType::LONGVARCHAR:
- aSQL.append( STR_LIKE );
aSQL.append( DBTypeConversion::toSQLString( nType, aValue, sal_True, m_xTypeConverter ) );
break;
case DataType::CLOB:
@@ -1528,7 +1639,6 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert
const ::sal_Int64 nLength = xClob->length();
if ( sal_Int64(nLength + aSQL.getLength() + STR_LIKE.getLength() ) < sal_Int64(SAL_MAX_INT32) )
{
- aSQL.append( STR_LIKE );
aSQL.appendAscii("'");
aSQL.append( xClob->getSubString(1,(sal_Int32)nLength) );
aSQL.appendAscii("'");
@@ -1536,7 +1646,6 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert
}
else
{
- aSQL.append( STR_LIKE );
aSQL.append( DBTypeConversion::toSQLString( nType, aValue, sal_True, m_xTypeConverter ) );
}
}
@@ -1550,11 +1659,8 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert
{
if(nSearchable == ColumnSearch::CHAR)
{
- aSQL.append( STR_LIKE );
aSQL.appendAscii( "\'" );
}
- else
- aSQL.append( STR_EQUAL );
aSQL.appendAscii( "0x" );
const sal_Int8* pBegin = aSeq.getConstArray();
const sal_Int8* pEnd = pBegin + aSeq.getLength();
@@ -1580,13 +1686,18 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert
}
break;
default:
- aSQL.append( STR_EQUAL );
aSQL.append( DBTypeConversion::toSQLString( nType, aValue, sal_True, m_xTypeConverter ) );
break;
}
}
else
- aSQL.appendAscii( " IS NULL" ) ;
+ {
+ sal_Int32 nFilterOp = filterOperator;
+ if ( filterOperator != SQLFilterOperator::SQLNULL && filterOperator != SQLFilterOperator::NOT_SQLNULL )
+ nFilterOp = SQLFilterOperator::SQLNULL;
+ ::rtl::OUString sEmpty;
+ lcl_addFilterCriteria_throw(nFilterOp,sEmpty,aSQL);
+ }
// filter anhaengen
// select ohne where und order by aufbauen
diff --git a/dbaccess/source/core/api/definitioncolumn.cxx b/dbaccess/source/core/api/definitioncolumn.cxx
index 77a29812b105..af40ac5667d2 100644
--- a/dbaccess/source/core/api/definitioncolumn.cxx
+++ b/dbaccess/source/core/api/definitioncolumn.cxx
@@ -192,14 +192,16 @@ rtl::OUString OTableColumn::getImplementationName( ) throw (RuntimeException)
DBG_NAME( OQueryColumn );
// -------------------------------------------------------------------------
-OQueryColumn::OQueryColumn( const Reference< XPropertySet >& _rxParserColumn, const Reference< XConnection >& _rxConnection,const ::rtl::OUString& _sNewName )
+OQueryColumn::OQueryColumn( const Reference< XPropertySet >& _rxParserColumn, const Reference< XConnection >& _rxConnection,const ::rtl::OUString i_sLabel )
:OTableColumnDescriptor( false /* do not act as descriptor */ )
+ ,m_sLabel(i_sLabel)
{
const sal_Int32 nPropAttr = PropertyAttribute::READONLY;
registerProperty( PROPERTY_CATALOGNAME, PROPERTY_ID_CATALOGNAME, nPropAttr, &m_sCatalogName, ::getCppuType( &m_sCatalogName ) );
registerProperty( PROPERTY_SCHEMANAME, PROPERTY_ID_SCHEMANAME, nPropAttr, &m_sSchemaName, ::getCppuType( &m_sSchemaName ) );
registerProperty( PROPERTY_TABLENAME, PROPERTY_ID_TABLENAME, nPropAttr, &m_sTableName, ::getCppuType( &m_sTableName ) );
registerProperty( PROPERTY_REALNAME, PROPERTY_ID_REALNAME, nPropAttr, &m_sRealName, ::getCppuType( &m_sRealName ) );
+ registerProperty( PROPERTY_LABEL, PROPERTY_ID_LABEL, nPropAttr, &m_sLabel, ::getCppuType( &m_sLabel ) );
DBG_CTOR( OQueryColumn, NULL );
@@ -210,14 +212,8 @@ 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 );
- if ( _sNewName.getLength() )
- {
- m_sName = _sNewName;
- }
- else
- {
- OSL_VERIFY( _rxParserColumn->getPropertyValue( PROPERTY_NAME ) >>= m_sName );
- }
+ 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/query.cxx b/dbaccess/source/core/api/query.cxx
index 3f3ccc57db2e..4f7e9b60547c 100644
--- a/dbaccess/source/core/api/query.cxx
+++ b/dbaccess/source/core/api/query.cxx
@@ -237,29 +237,25 @@ void OQuery::rebuildColumns()
}
Sequence< ::rtl::OUString> aNames = xColumns->getElementNames();
- 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();
+ const ::rtl::OUString* pEnd = pIter + aNames.getLength();
for ( sal_Int32 i = 0;pIter != pEnd; ++pIter,++i)
{
Reference<XPropertySet> xSource(xColumns->getByName( *pIter ),UNO_QUERY);
- OQueryColumn* pColumn = new OQueryColumn( xSource, m_xConnection, bApplyDefinitionNames ? aDefintionNames[i] : sEmpty);
+ ::rtl::OUString sLabel = *pIter;
+ if ( xColumnDefinitions.is() && xColumnDefinitions->hasByName(*pIter) )
+ {
+ Reference<XPropertySet> xCommandColumn(xColumnDefinitions->getByName( *pIter ),UNO_QUERY);
+ xCommandColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel;
+ }
+ OQueryColumn* pColumn = new OQueryColumn( xSource, m_xConnection, sLabel);
Reference< XChild > xChild( *pColumn, UNO_QUERY_THROW );
xChild->setParent( *this );
- ::rtl::OUString sNewName = bApplyDefinitionNames ? aDefintionNames[i] : *pIter;
- implAppendColumn( sNewName, pColumn );
+ implAppendColumn( *pIter, pColumn );
Reference< XPropertySet > xDest( *pColumn, UNO_QUERY_THROW );
if ( m_pColumnMediator.is() )
- m_pColumnMediator->notifyElementCreated( sNewName, xDest );
+ m_pColumnMediator->notifyElementCreated( *pIter, xDest );
}
}
catch( const SQLContext& e )
diff --git a/dbaccess/source/core/api/querycomposer.cxx b/dbaccess/source/core/api/querycomposer.cxx
index 6b17ad97e12a..ce0a389407aa 100644
--- a/dbaccess/source/core/api/querycomposer.cxx
+++ b/dbaccess/source/core/api/querycomposer.cxx
@@ -91,6 +91,7 @@
#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
#include <com/sun/star/container/XChild.hpp>
#endif
+#include <com/sun/star/sdb/SQLFilterOperator.hpp>
#ifndef DBACCESS_CORE_API_QUERYCOMPOSER_HXX
#include "querycomposer.hxx"
#endif
@@ -285,7 +286,23 @@ void SAL_CALL OQueryComposer::appendFilterByColumn( const Reference< XPropertySe
m_xComposerHelper->setQuery(getQuery());
m_xComposerHelper->setFilter(::rtl::OUString());
- m_xComposerHelper->appendFilterByColumn(column,sal_True);
+ sal_Int32 nOp = SQLFilterOperator::EQUAL;
+ if ( column.is() )
+ {
+ sal_Int32 nType = 0;
+ column->getPropertyValue(PROPERTY_TYPE) >>= nType;
+ switch(nType)
+ {
+ case DataType::VARCHAR:
+ case DataType::CHAR:
+ case DataType::LONGVARCHAR:
+ nOp = SQLFilterOperator::LIKE;
+ break;
+ default:
+ nOp = SQLFilterOperator::EQUAL;
+ }
+ }
+ m_xComposerHelper->appendFilterByColumn(column,sal_True,nOp);
FilterCreator aFilterCreator;
aFilterCreator.append(getFilter());
diff --git a/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx
index 88be29d9240d..3240a269bd53 100644
--- a/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx
+++ b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx
@@ -130,6 +130,7 @@ namespace dbaccess
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection;
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> m_xMetaData;
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xConnectionTables;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xConnectionQueries;
::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > m_xNumberFormatsSupplier;
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xColumns;
::comphelper::ComponentContext m_aContext;
@@ -140,8 +141,10 @@ namespace dbaccess
::rtl::OUString m_aPureSelectSQL; // the pure select statement, without filter/order/groupby/having
::rtl::OUString m_sDecimalSep;
+ ::rtl::OUString m_sCommand;
::com::sun::star::lang::Locale m_aLocale;
sal_Int32 m_nBoolCompareMode; // how to compare bool values
+ sal_Int32 m_nCommandType;
// <properties>
::rtl::OUString m_sOrignal;
@@ -172,8 +175,8 @@ namespace dbaccess
void setConditionByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column
, sal_Bool andCriteria
- ,::std::mem_fun1_t<bool,OSingleSelectQueryComposer,::rtl::OUString>& _aSetFunctor);
-
+ ,::std::mem_fun1_t<bool,OSingleSelectQueryComposer,::rtl::OUString>& _aSetFunctor
+ ,sal_Int32 filterOperator);
/** getStructuredCondition returns the structured condition for the where or having clause
@param _aGetFunctor
@@ -249,18 +252,19 @@ namespace dbaccess
virtual void SAL_CALL setElementaryQuery( const ::rtl::OUString& _rElementary ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setFilter( const ::rtl::OUString& filter ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setStructuredFilter( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& filter ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL appendFilterByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column, sal_Bool andCriteria ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL appendFilterByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column, sal_Bool andCriteria,sal_Int32 filterOperator ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL appendGroupByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setGroup( const ::rtl::OUString& group ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setHavingClause( const ::rtl::OUString& filter ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setStructuredHavingClause( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& filter ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL appendHavingClauseByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column, sal_Bool andCriteria ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL appendHavingClauseByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column, sal_Bool andCriteria,sal_Int32 filterOperator ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL appendOrderByColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& column, sal_Bool ascending ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setOrder( const ::rtl::OUString& order ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
// XSingleSelectQueryAnalyzer
virtual ::rtl::OUString SAL_CALL getQuery( ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setQuery( const ::rtl::OUString& command ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setCommand( const ::rtl::OUString& command,sal_Int32 CommandType ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getFilter( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > SAL_CALL getStructuredFilter( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getGroup( ) throw (::com::sun::star::uno::RuntimeException);
diff --git a/dbaccess/source/core/inc/definitioncolumn.hxx b/dbaccess/source/core/inc/definitioncolumn.hxx
index b67b0de70c59..8d5f0d4b3f04 100644
--- a/dbaccess/source/core/inc/definitioncolumn.hxx
+++ b/dbaccess/source/core/inc/definitioncolumn.hxx
@@ -157,6 +157,7 @@ namespace dbaccess
::rtl::OUString m_sSchemaName;
::rtl::OUString m_sTableName;
::rtl::OUString m_sRealName;
+ ::rtl::OUString m_sLabel;
// </properties>
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xOriginalTableColumn;
@@ -168,7 +169,7 @@ namespace dbaccess
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 ::rtl::OUString& _sNewName
+ const ::rtl::OUString i_sLabel
);
// XTypeProvider
diff --git a/dbaccess/source/inc/stringconstants.hrc b/dbaccess/source/inc/stringconstants.hrc
index 6a58ba1ddd0d..2b00a4c5af14 100644
--- a/dbaccess/source/inc/stringconstants.hrc
+++ b/dbaccess/source/inc/stringconstants.hrc
@@ -183,6 +183,7 @@
#define PROPERTY_ID_THOUSAND_DELIMITER 140
#define PROPERTY_ID_ENCODING 141
#define PROPERTY_ID_HELP_URL 142
+#define PROPERTY_ID_SINGLESELECTQUERYCOMPOSER 143
//============================================================
//= property names
@@ -339,6 +340,7 @@ DECLARE_CONSTASCII_USTRING(PROPERTY_AS_TEMPLATE);
DECLARE_CONSTASCII_USTRING(PROPERTY_HAVING_CLAUSE);
DECLARE_CONSTASCII_USTRING(PROPERTY_GROUP_BY);
DECLARE_CONSTASCII_USTRING(PROPERTY_EDIT_WIDTH);
+DECLARE_CONSTASCII_USTRING(PROPERTY_SINGLESELECTQUERYCOMPOSER);
//============================================================
//= service names
diff --git a/dbaccess/source/inc/stringconstants.inc b/dbaccess/source/inc/stringconstants.inc
index 8803d0e0edc7..08168f859870 100644
--- a/dbaccess/source/inc/stringconstants.inc
+++ b/dbaccess/source/inc/stringconstants.inc
@@ -185,6 +185,7 @@ IMPLEMENT_CONSTASCII_USTRING(PROPERTY_AS_TEMPLATE, "AsTemplate");
IMPLEMENT_CONSTASCII_USTRING(PROPERTY_HAVING_CLAUSE, "HavingClause");
IMPLEMENT_CONSTASCII_USTRING(PROPERTY_GROUP_BY, "GroupBy");
IMPLEMENT_CONSTASCII_USTRING(PROPERTY_EDIT_WIDTH, "EditWidth");
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_SINGLESELECTQUERYCOMPOSER,"SingleSelectQueryComposer");
//============================================================
//= service names
diff --git a/dbaccess/source/ui/browser/brwctrlr.cxx b/dbaccess/source/ui/browser/brwctrlr.cxx
index 1caae8c6bf11..0be12a01c49b 100644
--- a/dbaccess/source/ui/browser/brwctrlr.cxx
+++ b/dbaccess/source/ui/browser/brwctrlr.cxx
@@ -67,6 +67,7 @@
#include <com/sun/star/sdb/XInteractionSupplyParameters.hpp>
#include <com/sun/star/sdb/XSQLErrorBroadcaster.hpp>
#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#include <com/sun/star/sdb/SQLFilterOperator.hpp>
#include <com/sun/star/sdbc/XConnection.hpp>
#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
#include <com/sun/star/sdbc/XRowSetListener.hpp>
@@ -734,6 +735,11 @@ sal_Bool SbaXDataBrowserController::reloadForm( const Reference< XLoadable >& _r
else
_rxLoadable->load();
+ m_xParser.clear();
+ const Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
+ if (::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ESCAPE_PROCESSING)))
+ xFormSet->getPropertyValue(PROPERTY_SINGLESELECTQUERYCOMPOSER) >>= m_xParser;
+
Reference< XWarningsSupplier > xWarnings( _rxLoadable, UNO_QUERY );
if ( xWarnings.is() )
{
@@ -1205,31 +1211,31 @@ void SbaXDataBrowserController::propertyChange(const PropertyChangeEvent& evt) t
// the filter or the sort criterias have changed ? -> update our parser
if (evt.PropertyName.equals(PROPERTY_ACTIVECOMMAND))
{
- if (m_xParser.is())
- DO_SAFE( m_xParser->setElementaryQuery(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new query to my parser !" );
+ // if (m_xParser.is())
+ //DO_SAFE( m_xParser->setElementaryQuery(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new query to my parser !" );
}
else if (evt.PropertyName.equals(PROPERTY_FILTER))
{
- if ( m_xParser.is() && m_xParser->getFilter() != ::comphelper::getString(evt.NewValue))
- {
- DO_SAFE( m_xParser->setFilter(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new filter to my parser !" );
- }
+ // if ( m_xParser.is() && m_xParser->getFilter() != ::comphelper::getString(evt.NewValue))
+ //{
+ // DO_SAFE( m_xParser->setFilter(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new filter to my parser !" );
+ //}
InvalidateFeature(ID_BROWSER_REMOVEFILTER);
}
else if (evt.PropertyName.equals(PROPERTY_HAVING_CLAUSE))
{
- if ( m_xParser.is() && m_xParser->getHavingClause() != ::comphelper::getString(evt.NewValue))
- {
- DO_SAFE( m_xParser->setHavingClause(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new filter to my parser !" );
- }
+ //if ( m_xParser.is() && m_xParser->getHavingClause() != ::comphelper::getString(evt.NewValue))
+ //{
+ // DO_SAFE( m_xParser->setHavingClause(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new filter to my parser !" );
+ //}
InvalidateFeature(ID_BROWSER_REMOVEFILTER);
}
else if (evt.PropertyName.equals(PROPERTY_ORDER))
{
- if ( m_xParser.is() && m_xParser->getOrder() != ::comphelper::getString(evt.NewValue))
- {
- DO_SAFE( m_xParser->setOrder(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new order to my parser !" );
- }
+ //if ( m_xParser.is() && m_xParser->getOrder() != ::comphelper::getString(evt.NewValue))
+ //{
+ // DO_SAFE( m_xParser->setOrder(::comphelper::getString(evt.NewValue)), "SbaXDataBrowserController::propertyChange : could not forward the new order to my parser !" );
+ //}
InvalidateFeature(ID_BROWSER_REMOVEFILTER);
}
@@ -1421,14 +1427,15 @@ void SbaXDataBrowserController::disposing()
OSL_ENSURE(0,"Exception thrown by dispose");
}
}
- try
- {
- ::comphelper::disposeComponent(m_xParser);
- }
- catch(Exception&)
- {
- OSL_ENSURE(0,"Exception thrown by dispose");
- }
+ m_xParser.clear();
+ //try
+ //{
+ // ::comphelper::disposeComponent(m_xParser);
+ //}
+ //catch(Exception&)
+ //{
+ // OSL_ENSURE(0,"Exception thrown by dispose");
+ //}
}
//------------------------------------------------------------------------------
void SbaXDataBrowserController::frameAction(const ::com::sun::star::frame::FrameActionEvent& aEvent) throw( RuntimeException )
@@ -1825,7 +1832,7 @@ FeatureState SbaXDataBrowserController::GetState(sal_uInt16 nId) const
}
//------------------------------------------------------------------------------
-void SbaXDataBrowserController::applyParserOrder(const ::rtl::OUString& _rOldOrder)
+void SbaXDataBrowserController::applyParserOrder(const ::rtl::OUString& _rOldOrder,const Reference< XSingleSelectQueryComposer >& _xParser)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::applyParserOrder" );
Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
@@ -1839,7 +1846,7 @@ void SbaXDataBrowserController::applyParserOrder(const ::rtl::OUString& _rOldOrd
sal_Bool bSuccess = sal_False;
try
{
- xFormSet->setPropertyValue(PROPERTY_ORDER, makeAny(m_xParser->getOrder()));
+ xFormSet->setPropertyValue(PROPERTY_ORDER, makeAny(_xParser->getOrder()));
bSuccess = reloadForm(m_xLoadable);
}
catch(Exception&)
@@ -1849,7 +1856,7 @@ void SbaXDataBrowserController::applyParserOrder(const ::rtl::OUString& _rOldOrd
if (!bSuccess)
{
xFormSet->setPropertyValue(PROPERTY_ORDER, makeAny(_rOldOrder));
- DO_SAFE( m_xParser->setOrder(_rOldOrder), "SbaXDataBrowserController::applyParserOrder: could not restore the old order of my parser !" );
+ //DO_SAFE( _xParser->setOrder(_rOldOrder), "SbaXDataBrowserController::applyParserOrder: could not restore the old order of my parser !" );
try
{
@@ -1868,7 +1875,7 @@ void SbaXDataBrowserController::applyParserOrder(const ::rtl::OUString& _rOldOrd
}
//------------------------------------------------------------------------------
-void SbaXDataBrowserController::applyParserFilter(const ::rtl::OUString& _rOldFilter, sal_Bool _bOldFilterApplied,const ::rtl::OUString& _sOldHaving)
+void SbaXDataBrowserController::applyParserFilter(const ::rtl::OUString& _rOldFilter, sal_Bool _bOldFilterApplied,const ::rtl::OUString& _sOldHaving,const Reference< XSingleSelectQueryComposer >& _xParser)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::applyParserFilter" );
Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
@@ -1884,8 +1891,8 @@ void SbaXDataBrowserController::applyParserFilter(const ::rtl::OUString& _rOldFi
try
{
FormErrorHelper aError(this);
- xFormSet->setPropertyValue(PROPERTY_FILTER, makeAny(m_xParser->getFilter()));
- xFormSet->setPropertyValue(PROPERTY_HAVING_CLAUSE, makeAny(m_xParser->getHavingClause()));
+ xFormSet->setPropertyValue(PROPERTY_FILTER, makeAny(_xParser->getFilter()));
+ xFormSet->setPropertyValue(PROPERTY_HAVING_CLAUSE, makeAny(_xParser->getHavingClause()));
xFormSet->setPropertyValue(PROPERTY_APPLYFILTER, ::comphelper::makeBoolAny(sal_Bool(sal_True)));
bSuccess = reloadForm(m_xLoadable);
@@ -1915,7 +1922,26 @@ void SbaXDataBrowserController::applyParserFilter(const ::rtl::OUString& _rOldFi
setCurrentColumnPosition(nPos);
}
-
+//------------------------------------------------------------------------------
+Reference< XSingleSelectQueryComposer > SbaXDataBrowserController::createParser_nothrow()
+{
+ Reference< XSingleSelectQueryComposer > xRet;
+ try
+ {
+ Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY_THROW);
+ const Reference<XMultiServiceFactory> xFactory(::dbtools::getConnection(getRowSet()),UNO_QUERY_THROW);
+ xRet.set(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY_THROW);
+ xRet->setElementaryQuery(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_ACTIVECOMMAND)));
+ xRet->setFilter(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_FILTER)));
+ xRet->setHavingClause(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_HAVING_CLAUSE)));
+ xRet->setOrder(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_ORDER)));
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xRet;
+}
//------------------------------------------------------------------------------
void SbaXDataBrowserController::ExecuteFilterSortCrit(sal_Bool bFilter)
{
@@ -1927,29 +1953,30 @@ void SbaXDataBrowserController::ExecuteFilterSortCrit(sal_Bool bFilter)
const ::rtl::OUString sOldVal = bFilter ? m_xParser->getFilter() : m_xParser->getOrder();
const ::rtl::OUString sOldHaving = m_xParser->getHavingClause();
+ Reference< XSingleSelectQueryComposer > xParser = createParser_nothrow();
try
{
Reference< ::com::sun::star::sdbcx::XColumnsSupplier> xSup = getColumnsSupplier();
Reference< XConnection> xCon(xFormSet->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY);
if(bFilter)
{
- DlgFilterCrit aDlg( getBrowserView(), getORB(), xCon, m_xParser, xSup->getColumns() );
+ DlgFilterCrit aDlg( getBrowserView(), getORB(), xCon, xParser, xSup->getColumns() );
String aFilter;
if(!aDlg.Execute())
{
- m_xParser->setFilter(sOldVal);
- m_xParser->setHavingClause(sOldHaving);
+ //m_xParser->setFilter(sOldVal);
+ //m_xParser->setHavingClause(sOldHaving);
return; // if so we don't need to actualize the grid
}
aDlg.BuildWherePart();
}
else
{
- DlgOrderCrit aDlg( getBrowserView(),xCon,m_xParser,xSup->getColumns() );
+ DlgOrderCrit aDlg( getBrowserView(),xCon,xParser,xSup->getColumns() );
String aOrder;
if(!aDlg.Execute())
{
- m_xParser->setOrder(sOldVal);
+ //m_xParser->setOrder(sOldVal);
return; // if so we don't need to actualize the grid
}
aDlg.BuildOrderPart();
@@ -1966,23 +1993,24 @@ void SbaXDataBrowserController::ExecuteFilterSortCrit(sal_Bool bFilter)
return;
}
- ::rtl::OUString sNewVal = bFilter ? m_xParser->getFilter() : m_xParser->getOrder();
+ ::rtl::OUString sNewVal = bFilter ? xParser->getFilter() : xParser->getOrder();
sal_Bool bOldFilterApplied(sal_False);
if (bFilter)
{
try { bOldFilterApplied = ::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_APPLYFILTER)); } catch(Exception&) { } ;
}
- ::rtl::OUString sNewHaving = m_xParser->getHavingClause();
+ ::rtl::OUString sNewHaving = xParser->getHavingClause();
if ( sOldVal.equals(sNewVal) && (!bFilter || sOldHaving.equals(sNewHaving)) )
// nothing to be done
return;
if (bFilter)
- applyParserFilter(sOldVal, bOldFilterApplied,sOldHaving);
+ applyParserFilter(sOldVal, bOldFilterApplied,sOldHaving,xParser);
else
- applyParserOrder(sOldVal);
+ applyParserOrder(sOldVal,xParser);
+ ::comphelper::disposeComponent(xParser);
}
//------------------------------------------------------------------------------
@@ -2175,17 +2203,18 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId, const Sequence< Property
if (!xField.is())
break;
- const ::rtl::OUString sOldSort = m_xParser->getOrder();
+ Reference< XSingleSelectQueryComposer > xParser = createParser_nothrow();
+ const ::rtl::OUString sOldSort = xParser->getOrder();
sal_Bool bParserSuccess = sal_False;
HANDLE_SQL_ERRORS(
- m_xParser->setOrder(::rtl::OUString()); m_xParser->appendOrderByColumn(xField, bSortUp),
+ xParser->setOrder(::rtl::OUString()); xParser->appendOrderByColumn(xField, bSortUp),
bParserSuccess,
UniString(ModuleRes(SBA_BROWSER_SETTING_ORDER)),
"SbaXDataBrowserController::Execute : caught an exception while composing the new filter !"
)
if (bParserSuccess)
- applyParserOrder(sOldSort);
+ applyParserOrder(sOldSort,xParser);
}
break;
@@ -2215,8 +2244,9 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId, const Sequence< Property
xProp->getPropertyValue(sAgg) >>= bHaving;
}
- const ::rtl::OUString sOldFilter = m_xParser->getFilter();
- const ::rtl::OUString sOldHaving = m_xParser->getHavingClause();
+ Reference< XSingleSelectQueryComposer > xParser = createParser_nothrow();
+ const ::rtl::OUString sOldFilter = xParser->getFilter();
+ const ::rtl::OUString sOldHaving = xParser->getHavingClause();
Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
sal_Bool bApplied = ::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_APPLYFILTER));
@@ -2224,16 +2254,32 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId, const Sequence< Property
// -> completely overwrite it, else append one
if (!bApplied)
{
- DO_SAFE( (bHaving ? m_xParser->setHavingClause(::rtl::OUString()) : m_xParser->setFilter(::rtl::OUString())), "SbaXDataBrowserController::Execute : caught an exception while resetting the new filter !" );
+ DO_SAFE( (bHaving ? xParser->setHavingClause(::rtl::OUString()) : xParser->setFilter(::rtl::OUString())), "SbaXDataBrowserController::Execute : caught an exception while resetting the new filter !" );
}
sal_Bool bParserSuccess = sal_False;
+ sal_Int32 nOp = SQLFilterOperator::EQUAL;
+ if ( xField.is() )
+ {
+ sal_Int32 nType = 0;
+ xField->getPropertyValue(PROPERTY_TYPE) >>= nType;
+ switch(nType)
+ {
+ case DataType::VARCHAR:
+ case DataType::CHAR:
+ case DataType::LONGVARCHAR:
+ nOp = SQLFilterOperator::LIKE;
+ break;
+ default:
+ nOp = SQLFilterOperator::EQUAL;
+ }
+ }
if ( bHaving )
{
HANDLE_SQL_ERRORS(
- m_xParser->appendHavingClauseByColumn(xField,sal_True),
+ xParser->appendHavingClauseByColumn(xField,sal_True,nOp),
bParserSuccess,
UniString(ModuleRes(SBA_BROWSER_SETTING_FILTER)),
"SbaXDataBrowserController::Execute : caught an exception while composing the new filter !"
@@ -2242,7 +2288,7 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId, const Sequence< Property
else
{
HANDLE_SQL_ERRORS(
- m_xParser->appendFilterByColumn(xField,sal_True),
+ xParser->appendFilterByColumn(xField,sal_True,nOp),
bParserSuccess,
UniString(ModuleRes(SBA_BROWSER_SETTING_FILTER)),
"SbaXDataBrowserController::Execute : caught an exception while composing the new filter !"
@@ -2250,7 +2296,7 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId, const Sequence< Property
}
if (bParserSuccess)
- applyParserFilter(sOldFilter, bApplied,sOldHaving);
+ applyParserFilter(sOldFilter, bApplied,sOldHaving,xParser);
InvalidateFeature(ID_BROWSER_REMOVEFILTER);
InvalidateFeature(ID_BROWSER_FILTERED);
@@ -2736,11 +2782,14 @@ void SbaXDataBrowserController::initializeParser() const
if (::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ESCAPE_PROCESSING)))
{ // (only if the statement isn't native)
// (it is allowed to use the PROPERTY_ISPASSTHROUGH : _after_ loading a form it is valid)
+ xFormSet->getPropertyValue(PROPERTY_SINGLESELECTQUERYCOMPOSER) >>= m_xParser;
+/*
const Reference<XMultiServiceFactory> xFactory(::dbtools::getConnection(getRowSet()),UNO_QUERY);
if ( xFactory.is() )
m_xParser.set(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY);
+*/
}
-
+/*
// initialize the parser with the current sql-statement of the form
if ( m_xParser.is() )
{
@@ -2749,6 +2798,7 @@ void SbaXDataBrowserController::initializeParser() const
m_xParser->setHavingClause(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_HAVING_CLAUSE)));
m_xParser->setOrder(::comphelper::getString(xFormSet->getPropertyValue(PROPERTY_ORDER)));
}
+*/
}
catch(Exception&)
{
@@ -2783,6 +2833,7 @@ void SbaXDataBrowserController::unloaded(const EventObject& /*aEvent*/) throw( R
// change as a reaction on that event. as we have no chance to be notified of this change (which is
// the one we're interested in) we give them time to do what they want to before invalidating our
// bound-field-dependent slots ....
+ /*
try
{
::comphelper::disposeComponent(m_xParser);
@@ -2791,6 +2842,7 @@ void SbaXDataBrowserController::unloaded(const EventObject& /*aEvent*/) throw( R
{
OSL_ENSURE(0,"Exception thrown by dispose");
}
+ */
}
//------------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/inc/brwctrlr.hxx b/dbaccess/source/ui/inc/brwctrlr.hxx
index d94f76b8dcc9..eab8e3ad82b0 100644
--- a/dbaccess/source/ui/inc/brwctrlr.hxx
+++ b/dbaccess/source/ui/inc/brwctrlr.hxx
@@ -344,14 +344,15 @@ namespace dbaui
void ExecuteSearch();
void initializeParser() const; // changes the mutable member m_xParser
- void applyParserFilter(const ::rtl::OUString& _rOldFilter, sal_Bool _bOldFilterApplied,const ::rtl::OUString& _sOldHaving = ::rtl::OUString());
- void applyParserOrder(const ::rtl::OUString& _rOldOrder);
+ void applyParserFilter(const ::rtl::OUString& _rOldFilter, sal_Bool _bOldFilterApplied,const ::rtl::OUString& _sOldHaving,const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer >& _xParser);
+ void applyParserOrder(const ::rtl::OUString& _rOldOrder,const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer >& _xParser);
sal_Int16 getCurrentColumnPosition();
void setCurrentColumnPosition( sal_Int16 _nPos );
void addColumnListeners(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > & _xGridControlModel);
void impl_checkForCannotSelectUnfiltered( const ::dbtools::SQLExceptionInfo& _rError );
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > createParser_nothrow();
// time to check the CUT/COPY/PASTE-slot-states
DECL_LINK( OnInvalidateClipboard, AutoTimer* );
diff --git a/reportdesign/source/filter/xml/xmlGroup.cxx b/reportdesign/source/filter/xml/xmlGroup.cxx
index b49f6b0e7b9c..48c5d8fe6255 100644
--- a/reportdesign/source/filter/xml/xmlGroup.cxx
+++ b/reportdesign/source/filter/xml/xmlGroup.cxx
@@ -145,14 +145,14 @@ OXMLGroup::OXMLGroup( ORptFilter& _rImport
sInterval = sInterval.getToken(0,')',nIndex);
m_xGroup->setGroupInterval(sInterval.toInt32());
}
- else if ( sFormula ==::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:YEAR")))
+ else if ( sFormula == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:YEAR")))
nGroupOn = report::GroupOn::YEAR;
- else if ( sFormula ==::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:MONTH")))
+ else if ( sFormula == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt: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")) )
+ else if ( sCompleteFormula.matchIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:INT((MONTH")),0)
+ && sCompleteFormula.endsWithIgnoreAsciiCaseAsciiL("-1)/3)+1",8) )
{
nGroupOn = report::GroupOn::QUARTAL;
}