diff options
Diffstat (limited to 'svx')
-rw-r--r-- | svx/inc/svx/gridctrl.hxx | 2 | ||||
-rw-r--r-- | svx/source/fmcomp/gridctrl.cxx | 38 |
2 files changed, 19 insertions, 21 deletions
diff --git a/svx/inc/svx/gridctrl.hxx b/svx/inc/svx/gridctrl.hxx index e27fa3e6d4d8..2641f16eb124 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 6699ff944563..19881fe2f4b5 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(); |