Tag: cws_src680_dba24
User: oj      
Date: 05/02/21 00:28:23

Modified:
 /dba/dbaccess/source/ui/querydesign/
  QueryDesignView.cxx, SelectionBrowseBox.cxx, SelectionBrowseBox.hxx

Log:
 #i42522# check if entry must added when order crit behind current position

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.70.50.1&r2=1.70.50.2
Delta lines:  +4 -6
-------------------
--- QueryDesignView.cxx 10 Feb 2005 10:38:51 -0000      1.70.50.1
+++ QueryDesignView.cxx 21 Feb 2005 08:28:19 -0000      1.70.50.2
@@ -1026,7 +1026,7 @@
 
                                // nur wenn eine Sortierung und ein 
Tabellenname vorhanden ist-> erzeugen
                                // sonst werden die Expressions vom Order By im 
GenerateCriteria mit erzeugt
-                               if (eOrder != ORDER_NONE && 
pEntryField->GetTable().getLength())
+                               if ( eOrder != ORDER_NONE )
                                {
                                        aColumnName = pEntryField->GetField();
                                        if(aColumnName.toChar() == '*')
@@ -2215,8 +2215,6 @@
                {
                        ::connectivity::OSQLParseNode* pNode = 
pParseRoot->getChild(3)->getChild(4)->getChild(2);
                        ::connectivity::OSQLParseNode* pParamRef = NULL;
-                       ::rtl::OUString aField, aAlias;
-                       sal_uInt16 nPos = 0;
 
                        EOrderDir eOrderDir;
                        OTableFieldDescRef aDragLeft = new OTableFieldDesc();
@@ -2231,7 +2229,7 @@
                                if(SQL_ISRULE(pChild->getChild(0),column_ref))
                                {
                                        if( eOk == 
FillDragInfo(_pView,pChild->getChild(0),aDragLeft))
-                                               _pSelectionBrw->AddOrder( 
aDragLeft, eOrderDir, nPos);
+                                               _pSelectionBrw->AddOrder( 
aDragLeft, eOrderDir, i);
                                        else // it could be a alias name for a 
field
                                        {
                                                ::rtl::OUString 
aTableRange,aColumnName;
@@ -2253,7 +2251,7 @@
                                else 
if(SQL_ISRULE(pChild->getChild(0),general_set_fct) &&
                                                SQL_ISRULE(pParamRef = 
pChild->getChild(0)->getChild(pChild->getChild(0)->count()-2),column_ref) &&
                                                eOk == 
FillDragInfo(_pView,pParamRef,aDragLeft))
-                                       _pSelectionBrw->AddOrder( aDragLeft, 
eOrderDir, nPos);
+                                       _pSelectionBrw->AddOrder( aDragLeft, 
eOrderDir, i );
                                else
                                        eErrorCode = eColumnNotFound;
                        }
@@ -2289,7 +2287,7 @@
                                        if ( eOk == (eErrorCode = 
FillDragInfo(_pView,pColumnRef,aDragInfo)) )
                                        {
                                                aDragInfo->SetGroupBy(sal_True);
-                                               
_pSelectionBrw->AddGroupBy(aDragInfo);
+                                               
_pSelectionBrw->AddGroupBy(aDragInfo,i);
                                        }
                                }
                        }

File [changed]: SelectionBrowseBox.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx?r1=1.60&r2=1.60.50.1
Delta lines:  +39 -25
---------------------
--- SelectionBrowseBox.cxx      22 Oct 2004 09:07:06 -0000      1.60
+++ SelectionBrowseBox.cxx      21 Feb 2005 08:28:20 -0000      1.60.50.1
@@ -1767,7 +1767,7 @@
        }
 }
 
//------------------------------------------------------------------------------
-void OSelectionBrowseBox::AddGroupBy( const OTableFieldDescRef& rInfo )
+void OSelectionBrowseBox::AddGroupBy( const OTableFieldDescRef& rInfo , 
sal_uInt32 _nCurrentPos)
 {
        Reference< XConnection> xConnection = 
static_cast<OQueryController*>(getDesignView()->getController())->getConnection();
        if(!xConnection.is())
@@ -1777,8 +1777,11 @@
        OTableFieldDescRef pEntry;
        Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
        ::comphelper::UStringMixEqual bCase(xMeta.is() && 
xMeta->storesMixedCaseQuotedIdentifiers());
-       OTableFields::iterator aIter = getFields().begin();
-       for(;aIter != getFields().end();++aIter)
+    sal_Bool bAppend = sal_False;
+    
+    OTableFields& rFields = getFields();
+    OTableFields::iterator aIter = rFields.begin();
+       for(;aIter != rFields.end();++aIter)
        {
                pEntry = *aIter;
                OSL_ENSURE(pEntry.isValid(),"OTableFieldDescRef was null!");
@@ -1790,6 +1793,12 @@
                        bCase(aAlias,rInfo->GetAlias()) && 
                        pEntry->GetFunctionType() == rInfo->GetFunctionType())
                {
+            sal_uInt32 nPos = aIter - rFields.begin();
+            bAppend = _nCurrentPos > nPos;
+            if ( bAppend )
+                aIter = rFields.end();
+            else
+            {
                        if ( pEntry->isNumericOrAggreateFunction() && 
rInfo->IsGroupBy() )
                                pEntry->SetGroupBy(sal_False);
                        else
@@ -1798,11 +1807,12 @@
                                if(!m_bGroupByUnRelated && pEntry->IsGroupBy())
                                        pEntry->SetVisible(sal_True);
                        }
+            }
                        break;
                }
        }
 
-       if (aIter == getFields().end())
+       if (aIter == rFields.end())
        {
                OTableFieldDescRef pTmp = InsertField(rInfo, BROWSER_INVALIDID, 
sal_False, sal_False );
                if ( (pTmp->isNumericOrAggreateFunction() && 
rInfo->IsGroupBy()) ) // das GroupBy wird bereits von rInfo "ubernommen
@@ -1874,21 +1884,21 @@
 }
 
 
//------------------------------------------------------------------------------
-void OSelectionBrowseBox::AddOrder( const OTableFieldDescRef& rInfo, const 
EOrderDir eDir, sal_uInt16& nPos )
+void OSelectionBrowseBox::AddOrder( const OTableFieldDescRef& rInfo, const 
EOrderDir eDir, sal_uInt32 _nCurrentPos)
 {
        Reference< XConnection> xConnection = 
static_cast<OQueryController*>(getDesignView()->getController())->getConnection();
        if(!xConnection.is())
                return;
        DBG_CHKTHIS(OSelectionBrowseBox,NULL);
        DBG_ASSERT(!rInfo->IsEmpty(),"AddOrder:: OTableFieldDescRef sollte 
nicht Empty sein!");
-       // nPos merkt sich die Spalte in die Sortierung eingetragen wird,
-       // da weitere Sortierungen nur dahinter abgelegt werden duerfen
        OTableFieldDescRef pEntry;
        Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
        ::comphelper::UStringMixEqual bCase(xMeta.is() && 
xMeta->storesMixedCaseQuotedIdentifiers());
 
-       OTableFields::iterator aIter = getFields().begin();
-       for(;aIter != getFields().end();++aIter)
+    sal_Bool bAppend = sal_False;
+    OTableFields& rFields = getFields();
+    OTableFields::iterator aIter = rFields.begin();
+       for(;aIter != rFields.end();++aIter)
        {
                pEntry = *aIter;
                ::rtl::OUString aField = pEntry->GetField();
@@ -1897,25 +1907,29 @@
                if (bCase(aField,rInfo->GetField()) && 
                        bCase(aAlias,rInfo->GetAlias()))
                {
-                       if(!m_bOrderByUnRelated)
+            sal_uInt32 nPos = aIter - rFields.begin();
+            bAppend = _nCurrentPos > nPos;
+            if ( bAppend )
+                aIter = rFields.end();
+            else
+            {
+                           if ( !m_bOrderByUnRelated )
                                pEntry->SetVisible(sal_True);
                        pEntry->SetOrderDir( eDir );
-                       nPos = aIter - getFields().begin();
+            }
                        break;
                }
        }
 
-       if (aIter == getFields().end())
+       if (aIter == rFields.end())
        {
                OTableFieldDescRef pTmp = InsertField(rInfo, BROWSER_INVALIDID, 
sal_False, sal_False );
                if(pTmp.isValid())
                {
-                       if(!m_bOrderByUnRelated)
+                       if ( !m_bOrderByUnRelated && !bAppend )
                                pTmp->SetVisible(sal_True);
                        pTmp->SetOrderDir( eDir );
                }
-
-               nPos = (sal_uInt16)( getFields().size()-1 );
        }
 }
 

File [changed]: SelectionBrowseBox.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx?r1=1.20&r2=1.20.136.1
Delta lines:  +2 -2
-------------------
--- SelectionBrowseBox.hxx      15 Mar 2004 12:44:12 -0000      1.20
+++ SelectionBrowseBox.hxx      21 Feb 2005 08:28:20 -0000      1.20.136.1
@@ -155,11 +155,11 @@
                void                                            DeleteFields( 
const String& rAliasName );
                // AddGroupBy:: F"ugt ein Feld mit Funktion == Grupierung. 
Falls das Feld schon vorhanden ist und ein Aggregate Funktion
                // benutzt, wird das Flag nicht gesetzt
-               void                                            AddGroupBy( 
const OTableFieldDescRef& rInfo );
+               void                                            AddGroupBy( 
const OTableFieldDescRef& rInfo,sal_uInt32 _nCurrentPos);
                void                                            AddCondition( 
const OTableFieldDescRef& rInfo,
                                                                                
                  const String& rValue,
                                                                                
                  const sal_uInt16 nLevel, const char* pOp=0 );
-               void                                            AddOrder(const 
OTableFieldDescRef& rInfo, const EOrderDir eDir, sal_uInt16& nPos);
+               void                                            AddOrder(const 
OTableFieldDescRef& rInfo, const EOrderDir eDir, sal_uInt32 _nCurrentPos);
                void                                            ClearAll();
                OTableFieldDescRef                      AppendNewCol( 
sal_uInt16 nCnt=1 );
                sal_Bool                                        Save();




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

Reply via email to