Tag: cws_src680_dba24b
User: oj      
Date: 2007-08-24 08:21:40+0000
Modified:
   dba/dbaccess/source/ui/querydesign/QueryDesignView.cxx

Log:
 #i69678# allow functions in group by

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.86.46.3&r2=1.86.46.4
Delta lines:  +56 -8
--------------------
--- QueryDesignView.cxx 2007-08-22 14:28:20+0000        1.86.46.3
+++ QueryDesignView.cxx 2007-08-24 08:21:37+0000        1.86.46.4
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: QueryDesignView.cxx,v $
  *
- *  $Revision: 1.86.46.3 $
+ *  $Revision: 1.86.46.4 $
  *
- *  last change: $Author: oj $ $Date: 2007/08/22 14:28:20 $
+ *  last change: $Author: oj $ $Date: 2007/08/24 08:21:37 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -1291,7 +1291,8 @@
        ::rtl::OUString GenerateGroupBy(const OQueryDesignView* 
_pView,OTableFields& _rFieldList, sal_Bool bMulti )
        {
 
-               Reference< XConnection> xConnection = 
static_cast<OQueryController*>(_pView->getController())->getConnection();
+        OQueryController* pController = 
static_cast<OQueryController*>(_pView->getController());
+               Reference< XConnection> xConnection = 
pController->getConnection();
                if(!xConnection.is())
                        return ::rtl::OUString();
 
@@ -1314,7 +1315,25 @@
                                        if ( pEntryField->isNoneFunction() )
                                                aGroupByStr += 
::dbtools::quoteName(aQuote, pEntryField->GetField());
                                        else
+                    {
+                        ::rtl::OUString aTmp = pEntryField->GetField();
+                                               ::rtl::OUString aErrorMsg;
+                                               Reference<XPropertySet> xColumn;
+                                               ::connectivity::OSQLParseNode* 
pParseNode = 
_pView->getPredicateTreeFromEntry(pEntryField,aTmp,aErrorMsg,xColumn);
+                                               if (pParseNode)
+                                               {
+                                                       ::rtl::OUString 
sGroupBy;
+                                                       
pParseNode->parseNodeToStr(     sGroupBy,
+                                                                               
                                xConnection,
+                                                                               
                                &pController->getParser().getContext(),
+                                                                               
                                sal_False,
+                                                                               
                                !pEntryField->isOtherFunction());
+                                                       aGroupByStr += sGroupBy;
+                                                       delete pParseNode;
+                                               }
+                                               else
                                                aGroupByStr += 
pEntryField->GetField();
+                    }
                                        aGroupByStr += ::rtl::OUString(',');
                                }
                        }
@@ -2439,19 +2458,48 @@
                SqlParseError eErrorCode = eOk;
                if (!pSelectRoot->getChild(3)->getChild(2)->isLeaf())
                {
+            OQueryController* pController = 
static_cast<OQueryController*>(_pView->getController());
                        ::connectivity::OSQLParseNode* pGroupBy = 
pSelectRoot->getChild(3)->getChild(2)->getChild(2);
                        OTableFieldDescRef aDragInfo = new OTableFieldDesc();
                        for( sal_uInt32 i=0 ; i < pGroupBy->count() && eOk == 
eErrorCode; ++i )
                        {
-                               ::connectivity::OSQLParseNode* pColumnRef = 
pGroupBy->getChild( i );
-                               if(SQL_ISRULE(pColumnRef,column_ref))
+                ::connectivity::OSQLParseNode* pParamRef = NULL;
+                               ::connectivity::OSQLParseNode* pArgument = 
pGroupBy->getChild( i );
+                               if(SQL_ISRULE(pArgument,column_ref))
                                {
-                                       if ( eOk == (eErrorCode = 
FillDragInfo(_pView,pColumnRef,aDragInfo)) )
+                                       if ( eOk == (eErrorCode = 
FillDragInfo(_pView,pArgument,aDragInfo)) )
                                        {
                                                aDragInfo->SetGroupBy(sal_True);
                                                
_pSelectionBrw->AddGroupBy(aDragInfo,i);
                                        }
                                }
+                else if(SQL_ISRULE(pArgument, general_set_fct ) &&
+                                               SQL_ISRULE(pParamRef = 
pArgument->getChild(pArgument->count()-2),column_ref) &&
+                                               eOk == 
FillDragInfo(_pView,pParamRef,aDragInfo))
+                {
+                    aDragInfo->SetGroupBy(sal_True);
+                                       _pSelectionBrw->AddGroupBy( aDragInfo, 
i );
+                }
+                else if( SQL_ISRULE(pArgument, set_fct_spec ) )
+                {                    
+                           Reference< XConnection> xConnection = 
pController->getConnection();
+                           if(xConnection.is())
+                           {
+                        ::rtl::OUString sGroupByExpression;
+                                   pArgument->parseNodeToStr(  
sGroupByExpression,
+                                                                               
                        xConnection,
+                                                                               
                        &pController->getParser().getContext(),
+                                                                               
                        sal_True,
+                                                                               
                        sal_True); // quote is to true because we need quoted 
elements inside the function
+                        
fillFunctionInfo(_pView,pArgument,sGroupByExpression,aDragInfo);
+                        aDragInfo->SetFunctionType(FKT_OTHER);
+                        aDragInfo->SetGroupBy(sal_True);
+                        aDragInfo->SetVisible(sal_False);
+                        _pSelectionBrw->AddGroupBy( aDragInfo, i );
+                    }
+                    else
+                        eErrorCode = eColumnNotFound;
+                }
                        }
                }
                return eErrorCode;
@@ -3013,7 +3061,7 @@
 OSQLParseNode* OQueryDesignView::getPredicateTreeFromEntry(OTableFieldDescRef 
pEntry,
                                                                                
                                   const String& _sCriteria,
                                                                                
                                   ::rtl::OUString& _rsErrorMessage,
-                                                                               
                                   Reference<XPropertySet>& _rxColumn)
+                                                                               
                                   Reference<XPropertySet>& _rxColumn) const
 {
        OSL_ENSURE(pEntry.isValid(),"Entry is null!");
        if(!pEntry.isValid())




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to