Tag: cws_src680_dba205b User: oj Date: 2006/08/02 08:52:57 Modified: dba/dbaccess/source/ui/querydesign/QueryDesignView.cxx
Log: #i64650# handle functions also in order by stmt 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.80&r2=1.80.18.1 Delta lines: +73 -32 --------------------- --- QueryDesignView.cxx 10 Jul 2006 15:41:12 -0000 1.80 +++ QueryDesignView.cxx 2 Aug 2006 15:52:54 -0000 1.80.18.1 @@ -4,9 +4,9 @@ * * $RCSfile: QueryDesignView.cxx,v $ * - * $Revision: 1.80 $ + * $Revision: 1.80.18.1 $ * - * last change: $Author: obo $ $Date: 2006/07/10 15:41:12 $ + * last change: $Author: oj $ $Date: 2006/08/02 15:52:54 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -187,6 +187,11 @@ const sal_uInt16 nLevel, sal_Bool bHaving); + void fillFunctionInfo( OQueryDesignView* _pView + ,const ::connectivity::OSQLParseNode* pNode + ,const ::rtl::OUString& sFunctionTerm + ,OTableFieldDescRef& aInfo); + //------------------------------------------------------------------------------ ::rtl::OUString quoteTableAlias(sal_Bool _bQuote, const ::rtl::OUString& _sAliasName, const ::rtl::OUString& _sQuote) { @@ -1031,6 +1036,10 @@ aWorkStr += ::rtl::OUString(')'); } + else if ( pEntryField->isOtherFunction() ) + { + aWorkStr += aColumnName; + } else { aWorkStr += quoteTableAlias(bMulti,pEntryField->GetAlias(),aQuote); @@ -1997,6 +2006,35 @@ return eErrorCode; } //------------------------------------------------------------------------------ + void fillFunctionInfo( OQueryDesignView* _pView + ,const ::connectivity::OSQLParseNode* pNode + ,const ::rtl::OUString& sFunctionTerm + ,OTableFieldDescRef& aInfo) + { + // get the type out of the funtion name + OQueryController* pController = static_cast<OQueryController*>(_pView->getController()); + sal_Int32 nDataType = DataType::DOUBLE; + ::rtl::OUString sFieldName = sFunctionTerm; + OSQLParseNode* pFunctionName = pNode->getChild(0); + if ( !SQL_ISPUNCTUATION(pFunctionName,"{") ) + { + if ( SQL_ISRULEOR2(pNode,length_exp,char_value_fct) ) + pFunctionName = pFunctionName->getChild(0); + + ::rtl::OUString sFunctionName = pFunctionName->getTokenValue(); + if ( !sFunctionName.getLength() ) + sFunctionName = ::rtl::OStringToOUString(OSQLParser::TokenIDToStr(pFunctionName->getTokenID()),RTL_TEXTENCODING_UTF8); + + nDataType = OSQLParser::getFunctionReturnType( + sFunctionName + ,&pController->getParser().getContext()); + } + aInfo->SetDataType(nDataType); + aInfo->SetFieldType(TAB_NORMAL_FIELD); + aInfo->SetField(sFieldName); + aInfo->SetTabWindow(NULL); + } + //------------------------------------------------------------------------------ SqlParseError InstallFields(OQueryDesignView* _pView, const ::connectivity::OSQLParseNode* pNode, OJoinTableView::OTableWindowMap* pTabList ) @@ -2118,28 +2156,7 @@ } else { - // get the type out of the funtion name - nFunctionType |= FKT_NUMERIC; - sal_Int32 nDataType = DataType::DOUBLE; - ::rtl::OUString sFieldName = aColumns; - OSQLParseNode* pFunctionName = pColumnRef->getChild(0); - if ( !SQL_ISPUNCTUATION(pFunctionName,"{") ) - { - if ( SQL_ISRULEOR2(pColumnRef,length_exp,char_value_fct) ) - pFunctionName = pFunctionName->getChild(0); - - ::rtl::OUString sFunctionName = pFunctionName->getTokenValue(); - if ( !sFunctionName.getLength() ) - sFunctionName = ::rtl::OStringToOUString(OSQLParser::TokenIDToStr(pFunctionName->getTokenID()),RTL_TEXTENCODING_UTF8); - - nDataType = OSQLParser::getFunctionReturnType( - sFunctionName - ,&pController->getParser().getContext()); - } - aInfo->SetDataType(nDataType); - aInfo->SetFieldType(TAB_NORMAL_FIELD); - aInfo->SetField(sFieldName); - aInfo->SetTabWindow(NULL); + fillFunctionInfo(_pView,pColumnRef,aColumns,aInfo); aInfo->SetFieldAlias(aColumnAlias); } @@ -2216,6 +2233,7 @@ ::connectivity::OSQLParseNode* pNode = pParseRoot->getChild(3)->getChild(4)->getChild(2); ::connectivity::OSQLParseNode* pParamRef = NULL; + OQueryController* pController = static_cast<OQueryController*>(_pView->getController()); EOrderDir eOrderDir; OTableFieldDescRef aDragLeft = new OTableFieldDesc(); for( sal_uInt32 i=0 ; i<pNode->count() ; i++ ) @@ -2226,17 +2244,17 @@ if (SQL_ISTOKEN( pChild->getChild(1), DESC ) ) eOrderDir = ORDER_DESC; - if(SQL_ISRULE(pChild->getChild(0),column_ref)) + ::connectivity::OSQLParseNode* pArgument = pChild->getChild(0); + + if(SQL_ISRULE(pArgument,column_ref)) { - if( eOk == FillDragInfo(_pView,pChild->getChild(0),aDragLeft)) + if( eOk == FillDragInfo(_pView,pArgument,aDragLeft)) _pSelectionBrw->AddOrder( aDragLeft, eOrderDir, i); else // it could be a alias name for a field { ::rtl::OUString aTableRange,aColumnName; - OQueryController* pController = static_cast<OQueryController*>(_pView->getController()); - ::connectivity::OSQLParseTreeIterator& rParseIter = pController->getParseIterator(); - rParseIter.getColumnRange( pChild->getChild(0), aColumnName, aTableRange ); + rParseIter.getColumnRange( pArgument, aColumnName, aTableRange ); OTableFields& aList = pController->getTableFieldDesc(); OTableFields::iterator aIter = aList.begin(); @@ -2248,10 +2266,33 @@ } } } - else if(SQL_ISRULE(pChild->getChild(0),general_set_fct) && - SQL_ISRULE(pParamRef = pChild->getChild(0)->getChild(pChild->getChild(0)->count()-2),column_ref) && + else if(SQL_ISRULE(pArgument, general_set_fct ) && + SQL_ISRULE(pParamRef = pArgument->getChild(pArgument->count()-2),column_ref) && eOk == FillDragInfo(_pView,pParamRef,aDragLeft)) _pSelectionBrw->AddOrder( aDragLeft, eOrderDir, i ); + else if( SQL_ISRULE(pArgument, set_fct_spec ) ) + { + + Reference< XConnection> xConnection = pController->getConnection(); + if(xConnection.is()) + { + Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData(); + ::rtl::OUString sCondition; + pArgument->parseNodeToPredicateStr(sCondition, + xMetaData, + pController->getNumberFormatter(), + _pView->getLocale(), + static_cast<sal_Char>(_pView->getDecimalSeparator().toChar()), + &pController->getParser().getContext()); + fillFunctionInfo(_pView,pArgument,sCondition,aDragLeft); + aDragLeft->SetFunctionType(FKT_OTHER); + aDragLeft->SetOrderDir(eOrderDir); + aDragLeft->SetVisible(sal_False); + _pSelectionBrw->AddOrder( aDragLeft, eOrderDir, i ); + } + else + eErrorCode = eColumnNotFound; + } else eErrorCode = eColumnNotFound; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
