Tag: cws_dev300_dba31a User: oj Date: 2008-07-04 11:43:07+0000 Modified: dba/connectivity/source/parse/sqliterator.cxx
Log: #i91208# handle parameters File Changes: Directory: /dba/connectivity/source/parse/ ========================================== File [changed]: sqliterator.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/parse/sqliterator.cxx?r1=1.58&r2=1.58.8.1 Delta lines: +61 -12 --------------------- --- sqliterator.cxx 2008-06-16 12:11:56+0000 1.58 +++ sqliterator.cxx 2008-07-04 11:43:04+0000 1.58.8.1 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: sqliterator.cxx,v $ - * $Revision: 1.58 $ + * $Revision: 1.58.8.1 $ * * This file is part of OpenOffice.org. * @@ -43,9 +43,7 @@ #ifdef SQL_TEST_PARSETREEITERATOR #include <iostream> #endif -#ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_ #include "connectivity/PColumn.hxx" -#endif #include "connectivity/dbtools.hxx" #include <tools/diagnose_ex.h> #include "TConnection.hxx" @@ -67,8 +65,6 @@ using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdb; -static ::rtl::OUString aEmptyString; - namespace connectivity { struct OSQLParseTreeIteratorImpl @@ -849,6 +845,7 @@ /*&& traverseSelectColumnNames( pSelectNode->getChild( 3 ) )*/; } + static ::rtl::OUString aEmptyString; // nyi: mehr Pruefung auf korrekte Struktur! if (pSelectNode->getChild(2)->isRule() && SQL_ISPUNCTUATION(pSelectNode->getChild(2)->getChild(0),"*")) { @@ -906,7 +903,6 @@ ::rtl::OUString sTableRange; // check if the column is also a parameter traverseORCriteria(pColumnRef); // num_value_exp - traverseParameter( pColumnRef, NULL, sColumnName, sTableRange, aColumnAlias ); // gehoeren alle beteiligten Spalten der Funktion zu einer Tabelle if (m_pImpl->m_pTables->size() == 1) @@ -1055,6 +1051,58 @@ traverseByColumnNames( pSelectNode, sal_False ); return !hasErrors(); } +// ----------------------------------------------------------------------------- +void OSQLParseTreeIterator::traverseParameters(const OSQLParseNode* _pNode) +{ + if ( _pNode == NULL ) + return; + + ::rtl::OUString sColumnName, sTableRange, aColumnAlias; + const OSQLParseNode* pParent = _pNode->getParent(); + if ( pParent != NULL ) + { + if ( SQL_ISRULE(pParent,comparison_predicate) ) // x = X + { + sal_uInt32 nPos = 0; + if ( pParent->getChild(nPos) == _pNode ) + nPos = 2; + pParent->getChild(nPos)->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); + } // if ( SQL_ISRULE(pParent,comparison_predicate) ) // x = X + else if ( SQL_ISRULE(pParent,like_predicate) ) + { + pParent->getChild(0)->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); + } + else if ( SQL_ISRULE(pParent,between_predicate) ) + { + sal_Int32 nPos = 2; + if ( pParent->getChild(3) == _pNode ) + nPos = 1; + pParent->getChild(0)->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); + sColumnName += ::rtl::OUString::valueOf(nPos); + } + else if ( pParent->getNodeType() == SQL_NODE_COMMALISTRULE ) + { + const sal_Int32 nParamCount = (sal_Int32)pParent->count(); + for (sal_Int32 i = 0; i < nParamCount; ++i) + { + if ( pParent->getChild(i) == _pNode ) + { + static const ::rtl::OUString s_sParam(RTL_CONSTASCII_USTRINGPARAM("param")); + sColumnName = s_sParam; + sColumnName += ::rtl::OUString::valueOf(i+1); + break; + } + } + } + } + traverseParameter( _pNode, pParent, sColumnName, sTableRange, aColumnAlias ); + const sal_uInt32 nCount = _pNode->count(); + for (sal_uInt32 i = 0; i < nCount; ++i) + { + const OSQLParseNode* pChild = _pNode->getChild(i); + traverseParameters( pChild ); + } +} //----------------------------------------------------------------------------- bool OSQLParseTreeIterator::traverseSelectionCriteria(const OSQLParseNode* pSelectNode) { @@ -1288,8 +1336,8 @@ // Fehler einfach weiterreichen. } //----------------------------------------------------------------------------- -void OSQLParseTreeIterator::traverseParameter(OSQLParseNode* _pParseNode - ,OSQLParseNode* _pColumnRef +void OSQLParseTreeIterator::traverseParameter(const OSQLParseNode* _pParseNode + ,const OSQLParseNode* _pColumnRef ,const ::rtl::OUString& _aColumnName ,const ::rtl::OUString& _aTableRange ,const ::rtl::OUString& _rColumnAlias) @@ -1413,9 +1461,9 @@ ::rtl::OUString aName; - if (SQL_ISRULE(pParseNode,parameter)) + /*if (SQL_ISRULE(pParseNode,parameter)) traverseParameter( pParseNode, pColumnRef, aColumnName, aTableRange, sColumnAlias ); - else if (SQL_ISRULE(pParseNode,column_ref))// Column-Name (und TableRange): + else */if (SQL_ISRULE(pParseNode,column_ref))// Column-Name (und TableRange): getColumnRange(pParseNode,aName,rValue); else { @@ -1450,6 +1498,7 @@ case SQL_STATEMENT_SELECT: { const OSQLParseNode* pSelectNode = m_pParseTree; + traverseParameters( pSelectNode ); if ( !traverseSelectColumnNames( pSelectNode ) || !traverseOrderByColumnNames( pSelectNode ) || !traverseGroupByColumnNames( pSelectNode ) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
