[Libreoffice-commits] .: Branch 'libreoffice-4-0' - 6 commits - dbaccess/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Dec 12 07:35:53 PST 2012


 dbaccess/source/ui/control/RelationControl.cxx         |   71 ++++++++++++++---
 dbaccess/source/ui/inc/RelationControl.hxx             |    2 
 dbaccess/source/ui/inc/TableConnectionData.hxx         |   14 ++-
 dbaccess/source/ui/querydesign/TableConnectionData.cxx |   21 ++---
 4 files changed, 82 insertions(+), 26 deletions(-)

New commits:
commit 8735769e6ab926efff117abf731fa769b90bc563
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Dec 12 16:33:31 2012 +0100

    fdo#32958 join editor: remove empty lines
    
    Change-Id: If150261bae55cf91c8a344f34c79194ad29db903

diff --git a/dbaccess/source/ui/control/RelationControl.cxx b/dbaccess/source/ui/control/RelationControl.cxx
index 316e8a7..5a810f5 100644
--- a/dbaccess/source/ui/control/RelationControl.cxx
+++ b/dbaccess/source/ui/control/RelationControl.cxx
@@ -36,6 +36,11 @@
 #include <osl/diagnose.h>
 
 #include <algorithm>
+#include <list>
+using std::list;
+#include <utility>
+using std::pair;
+using std::make_pair;
 
 #define SOURCE_COLUMN   1
 #define DEST_COLUMN     2
@@ -60,6 +65,9 @@ namespace dbaui
         long                                    m_nDataPos;
         Reference< XPropertySet>                m_xSourceDef;
         Reference< XPropertySet>                m_xDestDef;
+        enum opcode { DELETE, INSERT, MODIFY };
+        typedef list< pair < opcode, pair < OConnectionLineDataVec::size_type, OConnectionLineDataVec::size_type> > > ops_type;
+        ops_type                                m_ops;
 
 
         void fillListBox(const Reference< XPropertySet>& _xDest,long nRow,sal_uInt16 nColumnId);
@@ -230,15 +238,17 @@ namespace dbaui
     sal_Bool ORelationControl::SaveModified()
     {
         DBG_CHKTHIS(ORelationControl,NULL);
-        sal_Int32 nRow = GetCurRow();
+        long nRow = GetCurRow();
         if ( nRow != BROWSER_ENDOFSELECTION )
         {
             String sFieldName(m_pListCell->GetSelectEntry());
             OConnectionLineDataVec* pLines = m_pConnData->GetConnLineDataList();
-            if ( pLines->size() <= static_cast<sal_uInt32>(nRow) )
+            if ( pLines->size() <= static_cast<OConnectionLineDataVec::size_type>(nRow) )
             {
                 pLines->push_back(new OConnectionLineData());
                 nRow = pLines->size() - 1;
+                // add new past-pLines row
+                m_ops.push_back(make_pair(INSERT, make_pair(nRow+1, nRow+2)));
             }
 
             OConnectionLineDataRef pConnLineData = (*pLines)[nRow];
@@ -252,8 +262,18 @@ namespace dbaui
                 pConnLineData->SetDestFieldName( sFieldName );
                 break;
             }
+            // the modification we just did does *not* need to be registered in m_ops;
+            // it is already taken into account (by the codepath that called us)
+            //m_ops.push_back(make_pair(MODIFY, make_pair(nRow, nRow+1)));
         }
 
+        const OConnectionLineDataVec::size_type oldSize = m_pConnData->GetConnLineDataList()->size();
+        OConnectionLineDataVec::size_type line = m_pConnData->normalizeLines();
+        const OConnectionLineDataVec::size_type newSize = m_pConnData->GetConnLineDataList()->size();
+        assert(newSize <= oldSize);
+        m_ops.push_back(make_pair(MODIFY, make_pair(line, newSize)));
+        m_ops.push_back(make_pair(DELETE, make_pair(newSize, oldSize)));
+
         return sal_True;
     }
     //------------------------------------------------------------------------------
@@ -636,12 +656,27 @@ OTableListBoxControl::OTableListBoxControl(  Window* _pParent
         }
         m_pParentDialog->setValid(bValid);
 
-        if ( pLines->size() >= static_cast<sal_uInt32>(m_pRC_Tables->GetRowCount()) )
+        ORelationControl::ops_type::iterator i (m_pRC_Tables->m_ops.begin());
+        const ORelationControl::ops_type::const_iterator e (m_pRC_Tables->m_ops.end());
+        m_pRC_Tables->DeactivateCell();
+        for(; i != e; ++i)
         {
-            m_pRC_Tables->DeactivateCell();
-            m_pRC_Tables->RowInserted(m_pRC_Tables->GetRowCount(), pLines->size() - static_cast<sal_uInt32>(m_pRC_Tables->GetRowCount()) + 1, sal_True);
-            m_pRC_Tables->ActivateCell();
+            switch(i->first)
+            {
+            case ORelationControl::DELETE:
+                m_pRC_Tables->RowRemoved(i->second.first, i->second.second - i->second.first);
+                break;
+            case ORelationControl::INSERT:
+                m_pRC_Tables->RowInserted(i->second.first, i->second.second - i->second.first);
+                break;
+            case ORelationControl::MODIFY:
+                for(OConnectionLineDataVec::size_type j = i->second.first; j < i->second.second; ++j)
+                    m_pRC_Tables->RowModified(j);
+                break;
+            }
         }
+        m_pRC_Tables->ActivateCell();
+        m_pRC_Tables->m_ops.clear();
     }
     // -----------------------------------------------------------------------------
     void fillEntryAndDisable(ListBox& _rListBox,const String& _sEntry)
@@ -696,9 +731,7 @@ OTableListBoxControl::OTableListBoxControl(  Window* _pParent
     // -----------------------------------------------------------------------------
     sal_Bool OTableListBoxControl::SaveModified()
     {
-        sal_Bool bRet = m_pRC_Tables->SaveModified();
-        m_pRC_Tables->getData()->normalizeLines();
-        return bRet;
+        return m_pRC_Tables->SaveModified();
     }
     // -----------------------------------------------------------------------------
     TTableWindowData::value_type OTableListBoxControl::getReferencingTable()    const
diff --git a/dbaccess/source/ui/inc/TableConnectionData.hxx b/dbaccess/source/ui/inc/TableConnectionData.hxx
index 4af28d8..400a8a7 100644
--- a/dbaccess/source/ui/inc/TableConnectionData.hxx
+++ b/dbaccess/source/ui/inc/TableConnectionData.hxx
@@ -77,8 +77,13 @@ namespace dbaui
         void ResetConnLines();
 
         /** moves the empty lines to the back
+            removes duplicated empty lines
+
+            caller is responsible for repainting them
+
+            @return infex of first changed line, or one-past-the-end if no change
          */
-        void normalizeLines();
+        OConnectionLineDataVec::size_type normalizeLines();
 
         const OConnectionLineDataVec* GetConnLineDataList() const { return &m_vConnLineData; }
         OConnectionLineDataVec* GetConnLineDataList() { return &m_vConnLineData; }
diff --git a/dbaccess/source/ui/querydesign/TableConnectionData.cxx b/dbaccess/source/ui/querydesign/TableConnectionData.cxx
index e813cd5..bf38ab7 100644
--- a/dbaccess/source/ui/querydesign/TableConnectionData.cxx
+++ b/dbaccess/source/ui/querydesign/TableConnectionData.cxx
@@ -162,22 +162,25 @@ OTableConnectionData* OTableConnectionData::NewInstance() const
     return new OTableConnectionData();
 }
 // -----------------------------------------------------------------------------
-void OTableConnectionData::normalizeLines()
+OConnectionLineDataVec::size_type OTableConnectionData::normalizeLines()
 {
-    // noch ein wenig Normalisierung auf den LineDatas : leere Lines vom Anfang an das Ende verschieben
-    sal_Int32 nCount = m_vConnLineData.size();
-    for(sal_Int32 i=0;i<nCount;)
+    // remove empty lines
+    OConnectionLineDataVec::size_type nCount = m_vConnLineData.size();
+    OConnectionLineDataVec::size_type nRet = nCount;
+    for(OConnectionLineDataVec::size_type i = 0; i < nCount;)
     {
-        if(m_vConnLineData[i]->GetSourceFieldName().isEmpty() || m_vConnLineData[i]->GetDestFieldName().isEmpty())
+        if(m_vConnLineData[i]->GetSourceFieldName().isEmpty() && m_vConnLineData[i]->GetDestFieldName().isEmpty())
         {
             OConnectionLineDataRef pData = m_vConnLineData[i];
             m_vConnLineData.erase(m_vConnLineData.begin()+i);
-            m_vConnLineData.push_back(pData);
             --nCount;
+            if (i < nRet)
+                nRet=i;
         }
         else
             ++i;
     }
+    return nRet;
 }
 // -----------------------------------------------------------------------------
 
commit 79e5fdf5284a35b3f3fe23882d641deb9592275b
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Dec 12 16:27:08 2012 +0100

    typo in comment
    
    Change-Id: I0e6dd24e2cd65a35886f75cde9197c5b957c6d57

diff --git a/dbaccess/source/ui/inc/RelationControl.hxx b/dbaccess/source/ui/inc/RelationControl.hxx
index 2369df4..5926d48 100644
--- a/dbaccess/source/ui/inc/RelationControl.hxx
+++ b/dbaccess/source/ui/inc/RelationControl.hxx
@@ -67,7 +67,7 @@ namespace dbaui
         */
         void enableRelation(bool _bEnable);
 
-        /** NotifyCellChange notifies the browse control that the conenction data has changed
+        /** NotifyCellChange notifies the browse control that the connection data has changed
         */
         void NotifyCellChange();
 
commit e6734050e9c6f67827fdd28a84df1fe7f0cc7de9
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Dec 12 16:24:45 2012 +0100

    query design / edit join: valid only iif column names everywhere
    
    Change-Id: Idfb0e16c4cc2581a46e26fe97948897dc4b11dc0

diff --git a/dbaccess/source/ui/control/RelationControl.cxx b/dbaccess/source/ui/control/RelationControl.cxx
index 771e1b2..316e8a7 100644
--- a/dbaccess/source/ui/control/RelationControl.cxx
+++ b/dbaccess/source/ui/control/RelationControl.cxx
@@ -624,7 +624,17 @@ OTableListBoxControl::OTableListBoxControl(  Window* _pParent
         // Enable/disable the OK button, depending on having a valid situation
         TTableConnectionData::value_type pConnData = m_pRC_Tables->getData();
         const OConnectionLineDataVec* pLines = pConnData->GetConnLineDataList();
-        m_pParentDialog->setValid(!pLines->empty());
+        bool bValid = !pLines->empty();
+        if (bValid)
+        {
+            OConnectionLineDataVec::const_iterator l(pLines->begin());
+            const OConnectionLineDataVec::const_iterator le(pLines->end());
+            for (; bValid && l!=le; ++l)
+            {
+                bValid = ! ((*l)->GetSourceFieldName().isEmpty() || (*l)->GetDestFieldName().isEmpty());
+            }
+        }
+        m_pParentDialog->setValid(bValid);
 
         if ( pLines->size() >= static_cast<sal_uInt32>(m_pRC_Tables->GetRowCount()) )
         {
commit b46be146a4e18cfef197e236084202b6281c8191
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Dec 12 16:12:02 2012 +0100

    be more cautious in debug mode
    
    Change-Id: I46b89b10287ac755e2b727b46d6fdd19f44bcdd3

diff --git a/dbaccess/source/ui/control/RelationControl.cxx b/dbaccess/source/ui/control/RelationControl.cxx
index 47c0155..771e1b2 100644
--- a/dbaccess/source/ui/control/RelationControl.cxx
+++ b/dbaccess/source/ui/control/RelationControl.cxx
@@ -437,7 +437,13 @@ namespace dbaui
         DBG_CHKTHIS(ORelationControl,NULL);
         EditBrowseBox::CellModified();
         SaveModified();
-        static_cast<OTableListBoxControl*>(GetParent())->NotifyCellChange();
+#if OSL_DEBUG_LEVEL > 0
+        OTableListBoxControl *parent = dynamic_cast<OTableListBoxControl*>(GetParent());
+#else
+        OTableListBoxControl *parent = static_cast<OTableListBoxControl*>(GetParent());
+#endif
+        assert(parent);
+        parent->NotifyCellChange();
     }
     //========================================================================
     // class OTableListBoxControl
commit 2ee4b892ef50825365a829697efb22679f7e7a28
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Dec 12 09:11:12 2012 +0100

    argument has no effect anymore -> remove
    
    Change-Id: I91f8f552b1324b57ce75e96b858b7a3379decb20

diff --git a/dbaccess/source/ui/inc/TableConnectionData.hxx b/dbaccess/source/ui/inc/TableConnectionData.hxx
index e3e45db..4af28d8 100644
--- a/dbaccess/source/ui/inc/TableConnectionData.hxx
+++ b/dbaccess/source/ui/inc/TableConnectionData.hxx
@@ -72,10 +72,9 @@ namespace dbaui
 
         sal_Bool SetConnLine( sal_uInt16 nIndex, const String& rSourceFieldName, const String& rDestFieldName );
         sal_Bool AppendConnLine( const ::rtl::OUString& rSourceFieldName, const ::rtl::OUString& rDestFieldName );
-        /** Deletes list of ConnLines; if bUseDefaults == true
-            MAX_CONN_COUNT new dummy lines will be inserted.
+        /** Deletes list of ConnLines
         */
-        void ResetConnLines( sal_Bool bUseDefaults = sal_True );
+        void ResetConnLines();
 
         /** moves the empty lines to the back
          */
diff --git a/dbaccess/source/ui/querydesign/TableConnectionData.cxx b/dbaccess/source/ui/querydesign/TableConnectionData.cxx
index b64da5f..e813cd5 100644
--- a/dbaccess/source/ui/querydesign/TableConnectionData.cxx
+++ b/dbaccess/source/ui/querydesign/TableConnectionData.cxx
@@ -51,7 +51,7 @@ void OTableConnectionData::Init()
     //////////////////////////////////////////////////////////////////////
     // LineDataList mit Defaults initialisieren
     OSL_ENSURE(m_vConnLineData.empty(), "OTableConnectionData::Init() : nur mit leere Linienliste aufzurufen !");
-    ResetConnLines(sal_True);
+    ResetConnLines();
         // das legt Defaults an
 }
 //------------------------------------------------------------------------
@@ -86,7 +86,7 @@ OTableConnectionData& OTableConnectionData::operator=( const OTableConnectionDat
     m_aConnName = rConnData.GetConnName();
 
     // clear line list
-    ResetConnLines(sal_False);
+    ResetConnLines();
 
     // und kopieren
     OConnectionLineDataVec* pLineData = const_cast<OTableConnectionData*>(&rConnData)->GetConnLineDataList();
@@ -140,7 +140,7 @@ sal_Bool OTableConnectionData::AppendConnLine( const ::rtl::OUString& rSourceFie
 }
 
 //------------------------------------------------------------------------
-void OTableConnectionData::ResetConnLines( sal_Bool /*bUseDefaults*/ )
+void OTableConnectionData::ResetConnLines()
 {
     OConnectionLineDataVec().swap(m_vConnLineData);
 }
commit 85d46bdbd0e59a219742b9cbd8a92b19b22e4068
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Dec 12 09:06:01 2012 +0100

    Move comment to its rightful place
    
    Change-Id: I72803b26a79804cdc1b590a7fb4bc99ff831963e

diff --git a/dbaccess/source/ui/inc/TableConnectionData.hxx b/dbaccess/source/ui/inc/TableConnectionData.hxx
index 728978d..e3e45db 100644
--- a/dbaccess/source/ui/inc/TableConnectionData.hxx
+++ b/dbaccess/source/ui/inc/TableConnectionData.hxx
@@ -72,13 +72,13 @@ namespace dbaui
 
         sal_Bool SetConnLine( sal_uInt16 nIndex, const String& rSourceFieldName, const String& rDestFieldName );
         sal_Bool AppendConnLine( const ::rtl::OUString& rSourceFieldName, const ::rtl::OUString& rDestFieldName );
+        /** Deletes list of ConnLines; if bUseDefaults == true
+            MAX_CONN_COUNT new dummy lines will be inserted.
+        */
         void ResetConnLines( sal_Bool bUseDefaults = sal_True );
 
         /** moves the empty lines to the back
-
-            Deletes list of ConnLines; if bUseDefaults == true
-            MAX_CONN_COUNT new dummy lines will be inserted.
-        */
+         */
         void normalizeLines();
 
         const OConnectionLineDataVec* GetConnLineDataList() const { return &m_vConnLineData; }


More information about the Libreoffice-commits mailing list