diff options
author | Kay Schenk <kschenk@apache.org> | 2014-09-18 22:49:12 +0000 |
---|---|---|
committer | Kay Schenk <kschenk@apache.org> | 2014-09-18 22:49:12 +0000 |
commit | 79ff7fc76c74a012933230d6f3c37977eccc6398 (patch) | |
tree | 1185fb7b55ee6ac731752635cc4bfe8dba8ad9ed | |
parent | 638e87e8d09a5f08a925b395710ad1e2cd310ef4 (diff) |
#i121492
Patch by: hanya
Fixed date filter problems in table view. Now processes old style date format and "normal" for database as expected.
Notes
merged as: 32b46b74f2c45e1dff3530162ddb207527574026
-rw-r--r-- | dbaccess/source/core/api/SingleSelectQueryComposer.cxx | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index 1c3849f76c85..30170f8775e0 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -1507,7 +1507,44 @@ Reference< XIndexAccess > SAL_CALL OSingleSelectQueryComposer::getOrderColumns( // ----------------------------------------------------------------------------- namespace { - ::rtl::OUString lcl_getCondition(const Sequence< Sequence< PropertyValue > >& filter,const OPredicateInputController& i_aPredicateInputController,const Reference< XNameAccess >& i_xSelectColumns) + ::rtl::OUString lcl_getDecomposedColumnName( const ::rtl::OUString& rComposedName, const ::rtl::OUString& rQuoteString ) + { + const sal_Int32 nQuoteLength = rQuoteString.getLength(); + ::rtl::OUString sName = rComposedName.trim(); + ::rtl::OUString sColumnName; + sal_Int32 nPos, nRPos = 0; + + for (;;) + { + nPos = sName.indexOf( rQuoteString, nRPos ); + if ( nPos >= 0 ) + { + nRPos = sName.indexOf( rQuoteString, nPos + nQuoteLength ); + if ( nRPos > nPos ) + { + if ( nRPos + nQuoteLength < sName.getLength() ) + { + nRPos += nQuoteLength; // -1 + 1 skip dot + } + else + { + sColumnName = sName.copy( nPos + nQuoteLength, nRPos - nPos - nQuoteLength ); + break; + } + } + else + break; + } + else + break; + } + return sColumnName.isEmpty() ? rComposedName : sColumnName; + } + + ::rtl::OUString lcl_getCondition(const Sequence< Sequence< PropertyValue > >& filter, + const OPredicateInputController& i_aPredicateInputController, + const Reference< XNameAccess >& i_xSelectColumns, + const ::rtl::OUString& rQuoteString ) { ::rtl::OUStringBuffer sRet; const Sequence< PropertyValue >* pOrIter = filter.getConstArray(); @@ -1524,9 +1561,10 @@ namespace sRet.append(pAndIter->Name); ::rtl::OUString sValue; pAndIter->Value >>= sValue; - if ( i_xSelectColumns.is() && i_xSelectColumns->hasByName(pAndIter->Name) ) + const ::rtl::OUString sColumnName = lcl_getDecomposedColumnName( pAndIter->Name, rQuoteString ); + if ( i_xSelectColumns.is() && i_xSelectColumns->hasByName(sColumnName) ) { - Reference<XPropertySet> xColumn(i_xSelectColumns->getByName(pAndIter->Name),UNO_QUERY); + Reference<XPropertySet> xColumn(i_xSelectColumns->getByName(sColumnName),UNO_QUERY); sValue = i_aPredicateInputController.getPredicateValue(sValue,xColumn,sal_True); } else @@ -1552,14 +1590,14 @@ void SAL_CALL OSingleSelectQueryComposer::setStructuredFilter( const Sequence< S { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::setStructuredFilter" ); OPredicateInputController aPredicateInput(m_aContext.getLegacyServiceFactory(),m_xConnection); - setFilter(lcl_getCondition(filter,aPredicateInput,getColumns())); + setFilter(lcl_getCondition(filter,aPredicateInput,getColumns(), m_xMetaData->getIdentifierQuoteString())); } // ----------------------------------------------------------------------------- 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" ); OPredicateInputController aPredicateInput(m_aContext.getLegacyServiceFactory(),m_xConnection); - setHavingClause(lcl_getCondition(filter,aPredicateInput,getColumns())); + setHavingClause(lcl_getCondition(filter,aPredicateInput,getColumns(), m_xMetaData->getIdentifierQuoteString())); } // ----------------------------------------------------------------------------- void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropertySet >& column, sal_Bool andCriteria ,::std::mem_fun1_t<bool,OSingleSelectQueryComposer,::rtl::OUString>& _aSetFunctor,sal_Int32 filterOperator) |