Tag: cws_src680_dba24d User: oj Date: 2007-11-22 13:20:26+0000 Modified: dba/dbaccess/source/ui/querydesign/QueryDesignView.cxx
Log: #i83769# check for the same column in the search_condition File Changes: Directory: /dba/dbaccess/source/ui/querydesign/ =============================================== File [changed]: QueryDesignView.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/querydesign/QueryDesignView.cxx?r1=1.88&r2=1.88.2.1 Delta lines: +32 -7 -------------------- --- QueryDesignView.cxx 2007-11-01 15:31:21+0000 1.88 +++ QueryDesignView.cxx 2007-11-22 13:20:23+0000 1.88.2.1 @@ -4,9 +4,9 @@ * * $RCSfile: QueryDesignView.cxx,v $ * - * $Revision: 1.88 $ + * $Revision: 1.88.2.1 $ * - * last change: $Author: hr $ $Date: 2007/11/01 15:31:21 $ + * last change: $Author: oj $ $Date: 2007/11/22 13:20:23 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -1434,10 +1434,11 @@ { for (int i = 0; i < 3 && eErrorCode == eOk ; i+=2) { - if ( SQL_ISRULE(pCondition->getChild(i),search_condition) ) - eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pCondition->getChild(i),nLevel,bHaving,bAddOrOnOneLine); + const ::connectivity::OSQLParseNode* pChild = pCondition->getChild(i); + if ( SQL_ISRULE(pChild,search_condition) ) + eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pChild,nLevel,bHaving,bAddOrOnOneLine); else - eErrorCode = GetANDCriteria(_pView,_pSelectionBrw,pCondition->getChild(i), bAddOrOnOneLine ? nLevel : nLevel++,bHaving,bAddOrOnOneLine); + eErrorCode = GetANDCriteria(_pView,_pSelectionBrw,pChild, bAddOrOnOneLine ? nLevel : nLevel++,bHaving,bAddOrOnOneLine); } } else @@ -1446,6 +1447,28 @@ return eErrorCode; } //-------------------------------------------------------------------------------------------------- + bool CheckOrCriteria(const ::connectivity::OSQLParseNode* _pCondition,::connectivity::OSQLParseNode* _pFirstColumnRef) + { + bool bRet = true; + ::connectivity::OSQLParseNode* pFirstColumnRef = _pFirstColumnRef; + for (int i = 0; i < 3 && bRet; i+=2) + { + const ::connectivity::OSQLParseNode* pChild = _pCondition->getChild(i); + if ( SQL_ISRULE(pChild,search_condition) ) + bRet = CheckOrCriteria(pChild,pFirstColumnRef); + else + { + // this is a simple way to test columns are the same, may be we have to adjust this algo a little bit in future. :-) + ::connectivity::OSQLParseNode* pSecondColumnRef = pChild->getByRule(::connectivity::OSQLParseNode::column_ref); + if ( pFirstColumnRef && pSecondColumnRef ) + bRet = *pFirstColumnRef == *pSecondColumnRef; + else if ( !pFirstColumnRef ) + pFirstColumnRef = pSecondColumnRef; + } + } + return bRet; + } + //-------------------------------------------------------------------------------------------------- SqlParseError GetANDCriteria( OQueryDesignView* _pView, OSelectionBrowseBox* _pSelectionBrw, const ::connectivity::OSQLParseNode * pCondition, @@ -1464,7 +1487,9 @@ if (SQL_ISRULE(pCondition,boolean_primary)) { sal_uInt16 nLevel2 = nLevel; - eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pCondition->getChild(1), nLevel2,bHaving,true ); + // check if we have to put the or criteria on one line. + bool bMustAddOrOnOneLine = CheckOrCriteria(pCondition->getChild(1),NULL); + eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pCondition->getChild(1), nLevel2,bHaving,bMustAddOrOnOneLine ); } // Das erste Element ist (wieder) eine AND-Verknuepfung else if ( SQL_ISRULE(pCondition,boolean_term) && pCondition->count() == 3 ) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
