summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dbaccess/source/ui/browser/sbagrid.cxx2
-rw-r--r--svtools/inc/svtools/brwbox.hxx24
-rw-r--r--svtools/source/brwbox/brwbox1.cxx43
-rw-r--r--svtools/source/brwbox/brwbox2.cxx2
-rw-r--r--svtools/source/brwbox/editbrowsebox.cxx4
-rw-r--r--svtools/source/brwbox/editbrowsebox2.cxx2
-rw-r--r--svx/inc/svx/gridctrl.hxx2
-rw-r--r--svx/source/fmcomp/gridctrl.cxx38
8 files changed, 70 insertions, 47 deletions
diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx
index a796778822da..901d2a38824d 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 42bf18ff62db..326d660a18d0 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 3619355ce355..9d4acd92648b 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 f62a95170c6a..0883a31a4543 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 dc568cfec7e9..8b81e0bc3ef2 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 56f33bac499b..6841636d1f1d 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 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();