[Libreoffice-commits] .: 3 commits - dbaccess/source svtools/inc svtools/source svx/inc svx/source

Lionel Elie Mamane lmamane at kemper.freedesktop.org
Mon Sep 12 07:43:07 PDT 2011


 dbaccess/source/ui/browser/sbagrid.cxx                |    2 
 dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx |   30 ++++++------
 dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx |    6 +-
 svtools/inc/svtools/brwbox.hxx                        |   24 +++++-----
 svtools/source/brwbox/brwbox1.cxx                     |   43 +++++++++++++-----
 svtools/source/brwbox/brwbox2.cxx                     |    2 
 svtools/source/brwbox/editbrowsebox.cxx               |    4 -
 svtools/source/brwbox/editbrowsebox2.cxx              |    2 
 svx/inc/svx/gridctrl.hxx                              |    2 
 svx/source/fmcomp/gridctrl.cxx                        |   41 ++++++++---------
 10 files changed, 90 insertions(+), 66 deletions(-)

New commits:
commit f7ed67f2cf79fd067c1634e8f7c3f8a17792f2e5
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Mon Sep 12 16:37:50 2011 +0200

    cleanup BrowseBox, DbGridControl & friends handle & invalid column handling
    
     - BrowseBox: Check Handle column-related invariants when adding a
       column:
       # only one handle column
       # it is the first
    
     - BrowseBox: Check column id-related invariants when adding a column:
       # Id is not the special "handle column" value
       # Id is not the special "invalid ID" value
       # unicity of the ID among columns
    
     - GetColumnId: return BROWSER_INVALIDID, not 0 (== id of handle
       column) for an invalid column; adapt code calling GetColumnId to
       this change.
    
     - Use the correct const or #define'd symbol instead of magic
       constants; introduce such a symbol if needed
    
     - General other miscellaneous cleanups:
       # Translation of comments
       # typo/spelling in comments, error messages and the like
       # parenthesise #define'd value
       # use SAL_MAX_UINT16 instead of USHRT_MAX where a sal_uInt16 is
         expected
       # BrowseBox::SetColumnTitle: nItemId is checked to be non-zero, so
         don't test if for zeroness again.

diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx
index a796778..901d2a3 100644
--- a/dbaccess/source/ui/browser/sbagrid.cxx
+++ b/dbaccess/source/ui/browser/sbagrid.cxx
@@ -1415,7 +1415,7 @@ sal_Int8 SbaGridControl::AcceptDrop( const BrowserAcceptDropEvent& rEvt )
         if (IsCurrentAppending())
             --nCorrectRowCount; // the current data record doesn't really exist, we are appending a new one
 
-        if ((nCol == BROWSER_INVALIDID) || (nRow >= nCorrectRowCount) || GetColumnId(nCol) == 0 )
+        if ((nCol == BROWSER_INVALIDID) || (nRow >= nCorrectRowCount) || GetColumnId(nCol) == 0  || GetColumnId(nCol) == BROWSER_INVALID_ID )
             // no valid cell under the mouse cursor
             break;
 
diff --git a/svtools/inc/svtools/brwbox.hxx b/svtools/inc/svtools/brwbox.hxx
index 42bf18f..326d660 100644
--- a/svtools/inc/svtools/brwbox.hxx
+++ b/svtools/inc/svtools/brwbox.hxx
@@ -67,8 +67,8 @@ namespace utl {
 // - BrowseBox-Types -
 // -------------------
 
-#define BROWSER_INVALIDID           USHRT_MAX
-#define BROWSER_ENDOFSELECTION      (long)(SFX_ENDOFSELECTION)
+#define BROWSER_INVALIDID           SAL_MAX_UINT16
+#define BROWSER_ENDOFSELECTION      (static_cast<long>(SFX_ENDOFSELECTION))
 
 typedef sal_uLong BrowserMode;
 
@@ -76,15 +76,15 @@ typedef sal_uLong BrowserMode;
 #define BROWSER_MULTISELECTION       0x0002
 #define BROWSER_THUMBDRAGGING        0x0004
 #define BROWSER_KEEPHIGHLIGHT        0x0008
-#define BROWSER_KEEPSELECTION        BROWSER_KEEPHIGHLIGHT  // old, dont use!
+#define BROWSER_KEEPSELECTION        BROWSER_KEEPHIGHLIGHT  // old, don't use!
 #define BROWSER_HLINES               0x0010
 #define BROWSER_VLINES               0x0020
-#define BROWSER_HLINESFULL           BROWSER_HLINES // old, dont use!
-#define BROWSER_VLINESFULL           BROWSER_VLINES // old, dont use!
-#define BROWSER_HLINESDOTS           0x0000 // old => dont use!
-#define BROWSER_VLINESDOTS           0x0000 // old => dont use!
+#define BROWSER_HLINESFULL           BROWSER_HLINES // old, don't use!
+#define BROWSER_VLINESFULL           BROWSER_VLINES // old, don't use!
+#define BROWSER_HLINESDOTS           0x0000 // old => don't use!
+#define BROWSER_VLINESDOTS           0x0000 // old => don't use!
 
-#define BROWSER_HIDESELECT           0x0100 // old => dont use!
+#define BROWSER_HIDESELECT           0x0100 // old => don't use!
 #define BROWSER_HIDECURSOR           0x0200
 
 #define BROWSER_NO_HSCROLL           0x0400
@@ -98,7 +98,7 @@ typedef sal_uLong BrowserMode;
 #define BROWSER_NO_VSCROLL           0x8000
 
 #define BROWSER_HIGHLIGHT_NONE       0x0100 // == BROWSER_HIDESELECT
-#define BROWSER_HIGHLIGHT_TOGGLE 0x00000000 // old default => NULL, dont use!
+#define BROWSER_HIGHLIGHT_TOGGLE 0x00000000 // old default => NULL, don't use!
 
 #define BROWSER_HEADERBAR_NEW    0x00040000
 #define BROWSER_AUTOSIZE_LASTCOL 0x00080000
@@ -246,6 +246,10 @@ class SVT_DLLPUBLIC BrowseBox
     friend const char* BrowseBoxCheckInvariants( const void * pVoid );
 #endif
 
+public:
+    static const sal_uInt16 HandleColumnId = 0;
+
+private:
     Window*         pDataWin;       // window to display data rows
     ScrollBar*      pVScroll;       // vertical scrollbar
     ScrollBar       aHScroll;       // horizontal scrollbar
@@ -569,7 +573,7 @@ public:
     // invalidations
     void            Clear();
     void            RowRemoved( long nRow, long nNumRows = 1, sal_Bool bDoPaint = sal_True );
-    void            RowModified( long nRow, sal_uInt16 nColId = USHRT_MAX );
+    void            RowModified( long nRow, sal_uInt16 nColId = BROWSER_INVALIDID );
     void            RowInserted( long nRow, long nNumRows = 1, sal_Bool bDoPaint = sal_True, sal_Bool bKeepSelection = sal_False );
 
     // miscellanous
diff --git a/svtools/source/brwbox/brwbox1.cxx b/svtools/source/brwbox/brwbox1.cxx
index 3619355..9d4acd9 100644
--- a/svtools/source/brwbox/brwbox1.cxx
+++ b/svtools/source/brwbox/brwbox1.cxx
@@ -250,6 +250,17 @@ void BrowseBox::InsertHandleColumn( sal_uLong nWidth )
 {
     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
 
+#if OSL_DEBUG_LEVEL > 0
+    OSL_ENSURE( ColCount() == 0 || (*pCols)[0]->GetId() != HandleColumnId , "BrowseBox::InsertHandleColumn: there is already a handle column" );
+    {
+        BrowserColumns::iterator iCol = pCols->begin();
+        const BrowserColumns::iterator colsEnd = pCols->end();
+        if ( iCol < colsEnd )
+            for (++iCol; iCol < colsEnd; ++iCol)
+                OSL_ENSURE( (*iCol)->GetId() != HandleColumnId, "BrowseBox::InsertHandleColumn: there is a non-Handle column with handle ID" );
+    }
+#endif
+
     pCols->insert( pCols->begin(), new BrowserColumn( 0, Image(), String(), nWidth, GetZoom(), 0 ) );
     FreezeColumn( 0 );
 
@@ -272,6 +283,17 @@ void BrowseBox::InsertDataColumn( sal_uInt16 nItemId, const XubString& rText,
 {
     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
 
+    OSL_ENSURE( nItemId != HandleColumnId, "BrowseBox::InsertDataColumn: nItemId is HandleColumnId" );
+    OSL_ENSURE( nItemId != BROWSER_INVALIDID, "BrowseBox::InsertDataColumn: nItemId is reserved value BROWSER_INVALID_ID" );
+
+#if OSL_DEBUG_LEVEL > 0
+    {
+        const BrowserColumns::iterator colsEnd = pCols->end();
+        for (BrowserColumns::iterator iCol = pCols->begin(); iCol < colsEnd; ++iCol)
+            OSL_ENSURE( (*iCol)->GetId() != nItemId, "BrowseBox::InsertDataColumn: duplicate column Id" );
+    }
+#endif
+
     if ( nPos < pCols->size() )
     {
         BrowserColumns::iterator it = pCols->begin();
@@ -300,7 +322,7 @@ void BrowseBox::InsertDataColumn( sal_uInt16 nItemId, const XubString& rText,
 //-------------------------------------------------------------------
 sal_uInt16 BrowseBox::ToggleSelectedColumn()
 {
-    sal_uInt16 nSelectedColId = USHRT_MAX;
+    sal_uInt16 nSelectedColId = BROWSER_INVALIDID;
     if ( pColSel && pColSel->GetSelectCount() )
     {
         DoHideCursor( "ToggleSelectedColumn" );
@@ -313,7 +335,7 @@ sal_uInt16 BrowseBox::ToggleSelectedColumn()
 // -----------------------------------------------------------------------------
 void BrowseBox::SetToggledSelectedColumn(sal_uInt16 _nSelectedColumnId)
 {
-    if ( pColSel && _nSelectedColumnId != USHRT_MAX )
+    if ( pColSel && _nSelectedColumnId != BROWSER_INVALIDID )
     {
         pColSel->Select( GetColumnPos( _nSelectedColumnId ) );
         ToggleSelection();
@@ -550,8 +572,7 @@ void BrowseBox::SetColumnTitle( sal_uInt16 nItemId, const String& rTitle )
 
         // Headerbar-Column anpassen
         if ( getDataWindow()->pHeaderBar )
-            getDataWindow()->pHeaderBar->SetItemText(
-                    nItemId ? nItemId : USHRT_MAX - 1, rTitle );
+            getDataWindow()->pHeaderBar->SetItemText( nItemId, rTitle );
         else
         {
             // redraw visible colums
@@ -786,29 +807,29 @@ void BrowseBox::RemoveColumns()
 
     size_t nOldCount = pCols->size();
 
-    // alle Spalten entfernen
+    // remove all columns
     for ( size_t i = 0; i < nOldCount; ++i )
         delete (*pCols)[ i ];
     pCols->clear();
 
-    // Spaltenselektion korrigieren
+    // correct column selection
     if ( pColSel )
     {
         pColSel->SelectAll(sal_False);
         pColSel->SetTotalRange( Range( 0, 0 ) );
     }
 
-    // Spaltencursor korrigieren
+    // correct column cursor
     nCurColId = 0;
     nFirstCol = 0;
 
     if ( getDataWindow()->pHeaderBar )
         getDataWindow()->pHeaderBar->Clear( );
 
-    // vertikalen Scrollbar korrigieren
+    // correct vertical scrollbar
     UpdateScrollbars();
 
-    // ggf. Repaint ausl"osen
+    // trigger repaint if necessary
     if ( GetUpdateMode() )
     {
         getDataWindow()->Invalidate();
@@ -1123,7 +1144,7 @@ void BrowseBox::RowModified( long nRow, sal_uInt16 nColId )
         return;
 
     Rectangle aRect;
-    if ( nColId == USHRT_MAX )
+    if ( nColId == BROWSER_INVALIDID )
         // invalidate the whole row
         aRect = Rectangle( Point( 0, (nRow-nTopRow) * GetDataRowHeight() ),
                     Size( pDataWin->GetSizePixel().Width(), GetDataRowHeight() ) );
@@ -2223,7 +2244,7 @@ void BrowseBox::ReserveControlArea( sal_uInt16 nWidth )
 
     if ( nWidth != nControlAreaWidth )
     {
-        OSL_ENSURE(nWidth,"Control aera of 0 is not allowed, Use USHRT_MAX instead!");
+        OSL_ENSURE(nWidth,"Control area of 0 is not allowed, Use USHRT_MAX instead!");
         nControlAreaWidth = nWidth;
         UpdateScrollbars();
     }
diff --git a/svtools/source/brwbox/brwbox2.cxx b/svtools/source/brwbox/brwbox2.cxx
index f62a951..0883a31 100644
--- a/svtools/source/brwbox/brwbox2.cxx
+++ b/svtools/source/brwbox/brwbox2.cxx
@@ -485,7 +485,7 @@ sal_uInt16 BrowseBox::GetColumnId( sal_uInt16 nPos ) const
     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
 
     if ( nPos >= pCols->size() )
-        return 0;
+        return BROWSER_INVALIDID;
     return (*pCols)[ nPos ]->GetId();
 }
 
diff --git a/svtools/source/brwbox/editbrowsebox.cxx b/svtools/source/brwbox/editbrowsebox.cxx
index dc568cf..8b81e0b 100644
--- a/svtools/source/brwbox/editbrowsebox.cxx
+++ b/svtools/source/brwbox/editbrowsebox.cxx
@@ -1158,7 +1158,7 @@ namespace svt
     //------------------------------------------------------------------------------
     sal_uInt16 EditBrowseBox::AppendColumn(const String& rName, sal_uInt16 nWidth, sal_uInt16 nPos, sal_uInt16 nId)
     {
-        if (nId == (sal_uInt16)-1)
+        if (nId == BROWSER_INVALIDID)
         {
             // look for the next free id
             for (nId = ColCount(); nId > 0 && GetColumnPos(nId) != BROWSER_INVALIDID; nId--)
@@ -1168,7 +1168,7 @@ namespace svt
             {
                 // if there is no handle column
                 // increment the id
-                if (!ColCount() || GetColumnId(0))
+                if ( ColCount() == 0 || GetColumnId(0) != HandleColumnId )
                     nId = ColCount() + 1;
             }
         }
diff --git a/svtools/source/brwbox/editbrowsebox2.cxx b/svtools/source/brwbox/editbrowsebox2.cxx
index 56f33ba..6841636 100644
--- a/svtools/source/brwbox/editbrowsebox2.cxx
+++ b/svtools/source/brwbox/editbrowsebox2.cxx
@@ -170,7 +170,7 @@ void EditBrowseBox::DetermineFocus( const sal_uInt16 _nGetFocusFlags )
                 {
                     if ( _nGetFocusFlags & GETFOCUS_FORWARD )
                     {
-                        if ( GetColumnId( 0 ) != 0 )
+                        if ( GetColumnId( 0 ) != HandleColumnId )
                         {
                             GoToRowColumnId( 0, GetColumnId( 0 ) );
                         }
diff --git a/svx/inc/svx/gridctrl.hxx b/svx/inc/svx/gridctrl.hxx
index e27fa3e..2641f16 100644
--- a/svx/inc/svx/gridctrl.hxx
+++ b/svx/inc/svx/gridctrl.hxx
@@ -412,7 +412,7 @@ public:
     void InsertHandleColumn();
 
     // which position does the column with the id in the ::com::sun::star::sdbcx::View have, the handle column doesn't count
-    sal_uInt16 GetViewColumnPos( sal_uInt16 nId ) const { sal_uInt16 nPos = GetColumnPos(nId); return (nPos==(sal_uInt16)-1) ? GRID_COLUMN_NOT_FOUND : nPos-1; }
+    sal_uInt16 GetViewColumnPos( sal_uInt16 nId ) const { sal_uInt16 nPos = GetColumnPos(nId); return (nPos==BROWSER_INVALIDID) ? GRID_COLUMN_NOT_FOUND : nPos-1; }
 
     // which position does the column with the id in m_aColumns have, that means the ::com::sun::star::sdbcx::Container
     // returned from the GetColumns (may be different from the position returned by GetViewColumnPos
diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx
index 6699ff9..19881fe 100644
--- a/svx/source/fmcomp/gridctrl.cxx
+++ b/svx/source/fmcomp/gridctrl.cxx
@@ -66,8 +66,6 @@
 #include "fmservs.hxx"
 #include "sdbdatacolumn.hxx"
 
-#define HANDLE_ID   0
-
 #include <comphelper/stl_types.hxx>
 #include <comphelper/property.hxx>
 #include "trace.hxx"
@@ -1197,7 +1195,7 @@ void DbGridControl::EnableHandle(sal_Bool bEnable)
 
     // HandleColumn wird nur ausgeblendet,
     // da es sonst etliche Probleme mit dem Zeichnen gibt
-    RemoveColumn(0);
+    RemoveColumn( HandleColumnId );
     m_bHandle = bEnable;
     InsertHandleColumn();
 }
@@ -1664,7 +1662,7 @@ DbGridColumn* DbGridControl::CreateColumn(sal_uInt16 nId) const
 //------------------------------------------------------------------------------
 sal_uInt16 DbGridControl::AppendColumn(const XubString& rName, sal_uInt16 nWidth, sal_uInt16 nModelPos, sal_uInt16 nId)
 {
-    DBG_ASSERT(nId == (sal_uInt16)-1, "DbGridControl::AppendColumn : I want to set the ID myself ...");
+    DBG_ASSERT(nId == BROWSER_INVALIDID, "DbGridControl::AppendColumn : I want to set the ID myself ...");
     sal_uInt16 nRealPos = nModelPos;
     if (nModelPos != HEADERBAR_APPEND)
     {
@@ -1685,7 +1683,7 @@ sal_uInt16 DbGridControl::AppendColumn(const XubString& rName, sal_uInt16 nWidth
     // calculate the new id
     for (nId=1; (GetModelColumnPos(nId) != GRID_COLUMN_NOT_FOUND) && (nId <= m_aColumns.size()); ++nId)
         ;
-    DBG_ASSERT(GetViewColumnPos(nId) == (sal_uInt16)-1, "DbGridControl::AppendColumn : inconsistent internal state !");
+    DBG_ASSERT(GetViewColumnPos(nId) == GRID_COLUMN_NOT_FOUND, "DbGridControl::AppendColumn : inconsistent internal state !");
         // my column's models say "there is no column with id nId", but the view (the base class) says "there is a column ..."
 
     DbGridControl_Base::AppendColumn(rName, nWidth, nRealPos, nId);
@@ -2829,7 +2827,7 @@ void DbGridControl::StartDrag( sal_Int8 /*nAction*/, const Point& rPosPixel )
 
     sal_uInt16 nColId = GetColumnAtXPosPixel(rPosPixel.X());
     long   nRow = GetRowAtYPosPixel(rPosPixel.Y());
-    if (nColId != HANDLE_ID && nRow >= 0)
+    if (nColId != HandleColumnId && nRow >= 0)
     {
         if (GetDataWindow().IsMouseCaptured())
             GetDataWindow().ReleaseMouse();
@@ -2847,7 +2845,7 @@ sal_Bool DbGridControl::canCopyCellText(sal_Int32 _nRow, sal_Int16 _nColId)
 {
     return  (_nRow >= 0)
         &&  (_nRow < GetRowCount())
-        &&  (_nColId > HANDLE_ID)
+        &&  (_nColId != HandleColumnId)
         &&  (_nColId <= ColCount());
 }
 
@@ -2903,7 +2901,7 @@ void DbGridControl::Command(const CommandEvent& rEvt)
             sal_uInt16 nColId = GetColumnAtXPosPixel(rEvt.GetMousePosPixel().X());
             long   nRow = GetRowAtYPosPixel(rEvt.GetMousePosPixel().Y());
 
-            if (nColId == HANDLE_ID)
+            if (nColId == HandleColumnId)
             {
                 executeRowContextMenu( nRow, rEvt.GetMousePosPixel() );
             }
@@ -3497,22 +3495,22 @@ void DbGridControl::HideColumn(sal_uInt16 nId)
 void DbGridControl::ShowColumn(sal_uInt16 nId)
 {
     sal_uInt16 nPos = GetModelColumnPos(nId);
-    DBG_ASSERT(nPos != (sal_uInt16)-1, "DbGridControl::ShowColumn : invalid argument !");
-    if (nPos == (sal_uInt16)-1)
+    DBG_ASSERT(nPos != GRID_COLUMN_NOT_FOUND, "DbGridControl::ShowColumn : invalid argument !");
+    if (nPos == GRID_COLUMN_NOT_FOUND)
         return;
 
     DbGridColumn* pColumn = m_aColumns[ nPos ];
     if (!pColumn->IsHidden())
     {
-        DBG_ASSERT(GetViewColumnPos(nId) != (sal_uInt16)-1, "DbGridControl::ShowColumn : inconsistent internal state !");
+        DBG_ASSERT(GetViewColumnPos(nId) != GRID_COLUMN_NOT_FOUND, "DbGridControl::ShowColumn : inconsistent internal state !");
             // if the column isn't marked as hidden, it should be visible, shouldn't it ?
         return;
     }
-    DBG_ASSERT(GetViewColumnPos(nId) == (sal_uInt16)-1, "DbGridControl::ShowColumn : inconsistent internal state !");
+    DBG_ASSERT(GetViewColumnPos(nId) == GRID_COLUMN_NOT_FOUND, "DbGridControl::ShowColumn : inconsistent internal state !");
         // the opposite situation ...
 
     // to determine the new view position we need an adjacent non-hidden column
-    sal_uInt16 nNextNonHidden = (sal_uInt16)-1;
+    sal_uInt16 nNextNonHidden = BROWSER_INVALIDID;
     // first search the cols to the right
     for ( size_t i = nPos + 1; i < m_aColumns.size(); ++i )
     {
@@ -3523,7 +3521,7 @@ void DbGridControl::ShowColumn(sal_uInt16 nId)
             break;
         }
     }
-    if ((nNextNonHidden == (sal_uInt16)-1) && (nPos > 0))
+    if ((nNextNonHidden == BROWSER_INVALIDID) && (nPos > 0))
     {
         // then to the left
         for ( size_t i = nPos; i > 0; --i )
@@ -3536,15 +3534,15 @@ void DbGridControl::ShowColumn(sal_uInt16 nId)
             }
         }
     }
-    sal_uInt16 nNewViewPos = (nNextNonHidden == (sal_uInt16)-1)
+    sal_uInt16 nNewViewPos = (nNextNonHidden == BROWSER_INVALIDID)
         ? 1 // there is no visible column -> insert behinde the handle col
         : GetViewColumnPos( m_aColumns[ nNextNonHidden ]->GetId() ) + 1;
             // the first non-handle col has "view pos" 0, but the pos arg for InsertDataColumn expects
             // a position 1 for the first non-handle col -> +1
-    DBG_ASSERT(nNewViewPos != (sal_uInt16)-1, "DbGridControl::ShowColumn : inconsistent internal state !");
+    DBG_ASSERT(nNewViewPos != GRID_COLUMN_NOT_FOUND, "DbGridControl::ShowColumn : inconsistent internal state !");
         // we found a col marked as visible but got no view pos for it ...
 
-    if ((nNextNonHidden<nPos) && (nNextNonHidden != (sal_uInt16)-1))
+    if ((nNextNonHidden<nPos) && (nNextNonHidden != BROWSER_INVALIDID))
         // nNextNonHidden is a column to the left, so we want to insert the new col _right_ beside it's pos
         ++nNewViewPos;
 
@@ -3565,7 +3563,7 @@ sal_uInt16 DbGridControl::GetColumnIdFromModelPos( sal_uInt16 nPos ) const
     if (nPos >= m_aColumns.size())
     {
         OSL_FAIL("DbGridControl::GetColumnIdFromModelPos : invalid argument !");
-        return (sal_uInt16)-1;
+        return GRID_COLUMN_NOT_FOUND;
     }
 
     DbGridColumn* pCol = m_aColumns[ nPos ];
@@ -3703,8 +3701,8 @@ void DbGridControl::ConnectToFields()
     for ( size_t i = 0; i < m_aColumns.size(); ++i )
     {
         DbGridColumn* pCurrent = m_aColumns[ i ];
-        sal_uInt16 nViewPos = pCurrent ? GetViewColumnPos(pCurrent->GetId()) : (sal_uInt16)-1;
-        if ((sal_uInt16)-1 == nViewPos)
+        sal_uInt16 nViewPos = pCurrent ? GetViewColumnPos(pCurrent->GetId()) : GRID_COLUMN_NOT_FOUND;
+        if (GRID_COLUMN_NOT_FOUND == nViewPos)
             continue;
 
         Reference< XPropertySet >  xField = pCurrent->GetField();
commit fea84e0041f0dc6c87fc5e2d9c7ff2e70a7dada2
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Mon Sep 12 14:58:12 2011 +0200

    typo in parameter name

diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
index f48ff87..35654a8 100644
--- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
+++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
@@ -1547,11 +1547,11 @@ Rectangle OSelectionBrowseBox::GetInvalidRect( sal_uInt16 nColId )
 }
 
 //------------------------------------------------------------------------------
-void OSelectionBrowseBox::InsertColumn(OTableFieldDescRef pEntry, sal_uInt16& _nColumnPostion)
+void OSelectionBrowseBox::InsertColumn(OTableFieldDescRef pEntry, sal_uInt16& _nColumnPosition)
 {
     DBG_CHKTHIS(OSelectionBrowseBox,NULL);
         // das Control sollte immer genau eine Spalte mehr haben, naemlich die HandleColumn
-    OSL_ENSURE(_nColumnPostion == BROWSER_INVALIDID || (_nColumnPostion <= (long)getFields().size()), "OSelectionBrowseBox::InsertColumn : invalid parameter nColId.");
+    OSL_ENSURE(_nColumnPosition == BROWSER_INVALIDID || (_nColumnPosition <= (long)getFields().size()), "OSelectionBrowseBox::InsertColumn : invalid parameter nColId.");
         // -1 heisst ganz hinten, Count heisst ganz hinten, der Rest bezeichnet eine richtige Position
 
     sal_uInt16 nCurCol = GetCurColumnId();
@@ -1560,21 +1560,21 @@ void OSelectionBrowseBox::InsertColumn(OTableFieldDescRef pEntry, sal_uInt16& _n
     DeactivateCell();
 
     // remember the column id of the current positon
-    sal_uInt16 nColumnId = GetColumnId(_nColumnPostion);
+    sal_uInt16 nColumnId = GetColumnId(_nColumnPosition);
     // Wenn zu klein oder zu gross, auf Ende der Liste setzen
-    if ((_nColumnPostion == BROWSER_INVALIDID) || (_nColumnPostion >= getFields().size()))   // Anhaengen des Feldes
+    if ((_nColumnPosition == BROWSER_INVALIDID) || (_nColumnPosition >= getFields().size()))   // Anhaengen des Feldes
     {
-        if (FindFirstFreeCol(_nColumnPostion) == NULL)  // keine freie Column mehr
+        if (FindFirstFreeCol(_nColumnPosition) == NULL)  // keine freie Column mehr
         {
             AppendNewCol(1);
-            _nColumnPostion = sal::static_int_cast< sal_uInt16 >(
+            _nColumnPosition = sal::static_int_cast< sal_uInt16 >(
                 getFields().size());
         }
         else
-            ++_nColumnPostion; // innerhalb der vorgegebenen Liste
-        nColumnId = GetColumnId(_nColumnPostion);
+            ++_nColumnPosition; // innerhalb der vorgegebenen Liste
+        nColumnId = GetColumnId(_nColumnPosition);
         pEntry->SetColumnId( nColumnId );
-        getFields()[ _nColumnPostion - 1] = pEntry;
+        getFields()[ _nColumnPosition - 1] = pEntry;
     }
 
     // check if the column ids are identical, if not we have to move
@@ -1582,7 +1582,7 @@ void OSelectionBrowseBox::InsertColumn(OTableFieldDescRef pEntry, sal_uInt16& _n
     {
         sal_uInt16 nOldPosition = GetColumnPos(pEntry->GetColumnId());
         OSL_ENSURE( nOldPosition != 0,"Old position was 0. Not possible!");
-        SetColumnPos(pEntry->GetColumnId(),_nColumnPostion);
+        SetColumnPos(pEntry->GetColumnId(),_nColumnPosition);
         // we have to delete an empty field for the fields list, because the columns must have equal length
         if ( nOldPosition > 0 && nOldPosition <= getFields().size() )
             getFields()[nOldPosition - 1] = pEntry;
@@ -1611,7 +1611,7 @@ void OSelectionBrowseBox::InsertColumn(OTableFieldDescRef pEntry, sal_uInt16& _n
 }
 
 //------------------------------------------------------------------------------
-OTableFieldDescRef OSelectionBrowseBox::InsertField(const OJoinExchangeData& jxdSource, sal_uInt16 _nColumnPostion, sal_Bool bVis, sal_Bool bActivate)
+OTableFieldDescRef OSelectionBrowseBox::InsertField(const OJoinExchangeData& jxdSource, sal_uInt16 _nColumnPosition, sal_Bool bVis, sal_Bool bActivate)
 {
     DBG_CHKTHIS(OSelectionBrowseBox,NULL);
     OQueryTableWindow* pSourceWin = static_cast<OQueryTableWindow*>(jxdSource.pListBox->GetTabWin());
@@ -1633,11 +1633,11 @@ OTableFieldDescRef OSelectionBrowseBox::InsertField(const OJoinExchangeData& jxd
     aInfo->SetDataType(pInf->GetDataType());
     aInfo->SetVisible(bVis);
 
-    return InsertField(aInfo, _nColumnPostion, bVis, bActivate);
+    return InsertField(aInfo, _nColumnPosition, bVis, bActivate);
 }
 
 //------------------------------------------------------------------------------
-OTableFieldDescRef OSelectionBrowseBox::InsertField(const OTableFieldDescRef& _rInfo, sal_uInt16 _nColumnPostion, sal_Bool bVis, sal_Bool bActivate)
+OTableFieldDescRef OSelectionBrowseBox::InsertField(const OTableFieldDescRef& _rInfo, sal_uInt16 _nColumnPosition, sal_Bool bVis, sal_Bool bActivate)
 {
     DBG_CHKTHIS(OSelectionBrowseBox,NULL);
 
@@ -1651,14 +1651,14 @@ OTableFieldDescRef OSelectionBrowseBox::InsertField(const OTableFieldDescRef& _r
     pEntry->SetVisible(bVis);
 
     // Spalte einfuegen
-    InsertColumn( pEntry, _nColumnPostion );
+    InsertColumn( pEntry, _nColumnPosition );
 
     if ( !m_bInUndoMode )
     {
         // UndoAction erzeugen
         OTabFieldCreateUndoAct* pUndoAction = new OTabFieldCreateUndoAct( this );
         pUndoAction->SetTabFieldDescr( pEntry );
-        pUndoAction->SetColumnPosition(_nColumnPostion);
+        pUndoAction->SetColumnPosition(_nColumnPosition);
         getDesignView()->getController().addUndoActionAndInvalidate( pUndoAction );
     }
 
diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx
index fc361d5..35b666f 100644
--- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx
+++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx
@@ -99,9 +99,9 @@ namespace dbaui
                                     ~OSelectionBrowseBox();
 
         void                        initialize();
-        OTableFieldDescRef          InsertField( const OJoinExchangeData& jxdSource, sal_uInt16 _nColumnPostion = BROWSER_INVALIDID, sal_Bool bVis=sal_True, sal_Bool bActivate=sal_True );
-        OTableFieldDescRef          InsertField( const OTableFieldDescRef& rInfo, sal_uInt16 _nColumnPostion = BROWSER_INVALIDID, sal_Bool bVis=sal_True, sal_Bool bActivate=sal_True );
-        void                        InsertColumn( OTableFieldDescRef pEntry, sal_uInt16& _nColumnPostion );
+        OTableFieldDescRef          InsertField( const OJoinExchangeData& jxdSource, sal_uInt16 _nColumnPosition = BROWSER_INVALIDID, sal_Bool bVis=sal_True, sal_Bool bActivate=sal_True );
+        OTableFieldDescRef          InsertField( const OTableFieldDescRef& rInfo, sal_uInt16 _nColumnPosition = BROWSER_INVALIDID, sal_Bool bVis=sal_True, sal_Bool bActivate=sal_True );
+        void                        InsertColumn( OTableFieldDescRef pEntry, sal_uInt16& _nColumnPosition );
         void                        RemoveColumn( sal_uInt16 _nColumnId );
         void                        DeleteFields( const String& rAliasName );
 
commit d26b0df3465e449c124231ed7572c8879b2ac772
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Mon Sep 12 14:26:31 2011 +0200

    stylistic
    
    make it clearer that DbGridControl_Base::RemoveColumn
    is meant to be called unconditionally

diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx
index aea82df..6699ff9 100644
--- a/svx/source/fmcomp/gridctrl.cxx
+++ b/svx/source/fmcomp/gridctrl.cxx
@@ -1704,8 +1704,9 @@ sal_uInt16 DbGridControl::AppendColumn(const XubString& rName, sal_uInt16 nWidth
 //------------------------------------------------------------------------------
 void DbGridControl::RemoveColumn(sal_uInt16 nId)
 {
-    const sal_uInt16 nIndex = GetModelColumnPos(nId);
     DbGridControl_Base::RemoveColumn(nId);
+
+    const sal_uInt16 nIndex = GetModelColumnPos(nId);
     if(nIndex != GRID_COLUMN_NOT_FOUND)
     {
         delete m_aColumns[nIndex];


More information about the Libreoffice-commits mailing list