User: vg      
Date: 05/03/10 08:53:20

Modified:
 /dba/dbaccess/source/ui/querydesign/
  SelectionBrowseBox.cxx

Log:
 INTEGRATION: CWS dba24 (1.60.50); FILE MERGED
 2005/02/21 08:28:20 oj 1.60.50.1: #i42522# check if entry must added when 
order crit behind current position

File Changes:

Directory: /dba/dbaccess/source/ui/querydesign/
===============================================

File [changed]: SelectionBrowseBox.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx?r1=1.60&r2=1.61
Delta lines:  +39 -25
---------------------
--- SelectionBrowseBox.cxx      22 Oct 2004 09:07:06 -0000      1.60
+++ SelectionBrowseBox.cxx      10 Mar 2005 16:53:16 -0000      1.61
@@ -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 );
        }
 }
 




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

Reply via email to