convert DbGridControl::Option to scoped enum

Change-Id: I160fb53b585bb7eb04348dd208ec5c705d595279
This commit is contained in:
Noel Grandin
2016-08-29 13:39:26 +02:00
parent e27fbbcdf5
commit 15b084f203
4 changed files with 75 additions and 68 deletions

View File

@@ -1577,8 +1577,8 @@ FeatureState SbaXDataBrowserController::GetState(sal_uInt16 nId) const
aReturn.bEnabled = true; aReturn.bEnabled = true;
sal_Int16 nGridMode = getBrowserView()->getVclControl()->GetOptions(); DbGridControlOptions nGridMode = getBrowserView()->getVclControl()->GetOptions();
aReturn.bChecked = nGridMode > DbGridControl::OPT_READONLY; aReturn.bChecked = nGridMode > DbGridControlOptions::Readonly;
} }
break; break;
case ID_BROWSER_FILTERED: case ID_BROWSER_FILTERED:
@@ -1916,9 +1916,9 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId, const Sequence< Property
break; break;
case ID_BROWSER_EDITDOC: case ID_BROWSER_EDITDOC:
{ {
sal_Int16 nGridMode = getBrowserView()->getVclControl()->GetOptions(); DbGridControlOptions nGridMode = getBrowserView()->getVclControl()->GetOptions();
if (nGridMode == DbGridControl::OPT_READONLY) if (nGridMode == DbGridControlOptions::Readonly)
getBrowserView()->getVclControl()->SetOptions(DbGridControl::OPT_UPDATE | DbGridControl::OPT_INSERT | DbGridControl::OPT_DELETE); getBrowserView()->getVclControl()->SetOptions(DbGridControlOptions::Update | DbGridControlOptions::Insert | DbGridControlOptions::Delete);
// the options not supported by the data source will be removed automatically // the options not supported by the data source will be removed automatically
else else
{ {
@@ -1930,7 +1930,7 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId, const Sequence< Property
if (GetState(ID_BROWSER_UNDORECORD).bEnabled) if (GetState(ID_BROWSER_UNDORECORD).bEnabled)
Execute(ID_BROWSER_UNDORECORD,Sequence<PropertyValue>()); Execute(ID_BROWSER_UNDORECORD,Sequence<PropertyValue>());
getBrowserView()->getVclControl()->SetOptions(DbGridControl::OPT_READONLY); getBrowserView()->getVclControl()->SetOptions(DbGridControlOptions::Readonly);
} }
InvalidateFeature(ID_BROWSER_EDITDOC); InvalidateFeature(ID_BROWSER_EDITDOC);
} }

View File

@@ -1065,7 +1065,7 @@ void SbaGridControl::StartDrag( sal_Int8 _nAction, const Point& _rPosPixel )
// so the row contains data which has no counter part within the data source // so the row contains data which has no counter part within the data source
long nCorrectRowCount = GetRowCount(); long nCorrectRowCount = GetRowCount();
if (GetOptions() & OPT_INSERT) if (GetOptions() & DbGridControlOptions::Insert)
--nCorrectRowCount; // there is a empty row for inserting records --nCorrectRowCount; // there is a empty row for inserting records
if (bCurrentRowVirtual) if (bCurrentRowVirtual)
--nCorrectRowCount; --nCorrectRowCount;
@@ -1281,7 +1281,7 @@ sal_Int8 SbaGridControl::AcceptDrop( const BrowserAcceptDropEvent& rEvt )
sal_uInt16 nCol = GetColumnAtXPosPixel(rEvt.maPosPixel.X(), false); sal_uInt16 nCol = GetColumnAtXPosPixel(rEvt.maPosPixel.X(), false);
long nCorrectRowCount = GetRowCount(); long nCorrectRowCount = GetRowCount();
if (GetOptions() & OPT_INSERT) if (GetOptions() & DbGridControlOptions::Insert)
--nCorrectRowCount; // there is a empty row for inserting records --nCorrectRowCount; // there is a empty row for inserting records
if (IsCurrentAppending()) if (IsCurrentAppending())
--nCorrectRowCount; // the current data record doesn't really exist, we are appending a new one --nCorrectRowCount; // the current data record doesn't really exist, we are appending a new one
@@ -1375,7 +1375,7 @@ sal_Int8 SbaGridControl::ExecuteDrop( const BrowserExecuteDropEvent& rEvt )
sal_uInt16 nCol = GetColumnAtXPosPixel(rEvt.maPosPixel.X(), false); sal_uInt16 nCol = GetColumnAtXPosPixel(rEvt.maPosPixel.X(), false);
long nCorrectRowCount = GetRowCount(); long nCorrectRowCount = GetRowCount();
if (GetOptions() & OPT_INSERT) if (GetOptions() & DbGridControlOptions::Insert)
--nCorrectRowCount; // there is a empty row for inserting records --nCorrectRowCount; // there is a empty row for inserting records
if (IsCurrentAppending()) if (IsCurrentAppending())
--nCorrectRowCount; // the current data record doesn't really exist, we are appending a new one --nCorrectRowCount; // the current data record doesn't really exist, we are appending a new one

View File

@@ -129,6 +129,21 @@ namespace o3tl
} }
// these options are or'ed and indicate, which of the single
// features can be released, default is readonly which means 0
enum class DbGridControlOptions
{
Readonly = 0x00,
Insert = 0x01,
Update = 0x02,
Delete = 0x04
};
namespace o3tl
{
template<> struct typed_flags<DbGridControlOptions> : is_typed_flags<DbGridControlOptions, 0x07> {};
}
class FmXGridSourcePropListener; class FmXGridSourcePropListener;
class DisposeListenerGridBridge; class DisposeListenerGridBridge;
typedef ::svt::EditBrowseBox DbGridControl_Base; typedef ::svt::EditBrowseBox DbGridControl_Base;
@@ -210,17 +225,6 @@ public:
friend class DbGridControl::NavigationBar; friend class DbGridControl::NavigationBar;
public:
// these options are or'ed and indicate, which of the single
// features can be released, default is readonly which means 0
enum Option
{
OPT_READONLY = 0x00,
OPT_INSERT = 0x01,
OPT_UPDATE = 0x02,
OPT_DELETE = 0x04
};
private: private:
Link<sal_uInt16,int> m_aMasterStateProvider; Link<sal_uInt16,int> m_aMasterStateProvider;
Link<sal_uInt16,bool> m_aMasterSlotExecutor; Link<sal_uInt16,bool> m_aMasterSlotExecutor;
@@ -277,11 +281,11 @@ private:
BrowserMode m_nMode; BrowserMode m_nMode;
sal_Int32 m_nCurrentPos; // Current position; sal_Int32 m_nCurrentPos; // Current position;
ImplSVEvent * m_nDeleteEvent; // EventId for asychronous deletion of rows ImplSVEvent * m_nDeleteEvent; // EventId for asychronous deletion of rows
sal_uInt16 m_nOptions; // What is the able to do (Insert, Update, Delete) DbGridControlOptions m_nOptions; // What is the able to do (Insert, Update, Delete)
// default readonly // default readonly
sal_uInt16 m_nOptionMask; // the mask of options to be enabled in setDataSource DbGridControlOptions m_nOptionMask; // the mask of options to be enabled in setDataSource
// (with respect to the data source capabilities) // (with respect to the data source capabilities)
// defaults to (insert | update | delete) // defaults to (insert | update | delete)
sal_uInt16 m_nLastColId; sal_uInt16 m_nLastColId;
long m_nLastRowId; long m_nLastRowId;
@@ -395,7 +399,7 @@ public:
// the data source // the data source
// the options can restrict but not extend the update abilities // the options can restrict but not extend the update abilities
void setDataSource(const css::uno::Reference< css::sdbc::XRowSet >& rCursor, void setDataSource(const css::uno::Reference< css::sdbc::XRowSet >& rCursor,
sal_uInt16 nOpts = OPT_INSERT | OPT_UPDATE | OPT_DELETE); DbGridControlOptions nOpts = DbGridControlOptions::Insert | DbGridControlOptions::Update | DbGridControlOptions::Delete);
virtual void Dispatch(sal_uInt16 nId) override; virtual void Dispatch(sal_uInt16 nId) override;
CursorWrapper* getDataSource() const {return m_pDataCursor;} CursorWrapper* getDataSource() const {return m_pDataCursor;}
@@ -431,9 +435,9 @@ public:
void EnableNavigationBar(bool bEnable); void EnableNavigationBar(bool bEnable);
bool HasNavigationBar() const {return m_bNavigationBar;} bool HasNavigationBar() const {return m_bNavigationBar;}
sal_uInt16 GetOptions() const {return m_nOptions;} DbGridControlOptions GetOptions() const {return m_nOptions;}
NavigationBar& GetNavigationBar() {return *m_aBar.get();} NavigationBar& GetNavigationBar() {return *m_aBar.get();}
sal_uInt16 SetOptions(sal_uInt16 nOpt); DbGridControlOptions SetOptions(DbGridControlOptions nOpt);
// The new options are interpreted with respect to the current data source. If it is unable // The new options are interpreted with respect to the current data source. If it is unable
// to update, to insert or to restore, the according options are ignored. If the grid isn't // to update, to insert or to restore, the according options are ignored. If the grid isn't
// connected to a data source, all options except OPT_READONLY are ignored. // connected to a data source, all options except OPT_READONLY are ignored.

View File

@@ -592,7 +592,7 @@ void DbGridControl::NavigationBar::InvalidateAll(sal_Int32 nCurrentPos, bool bAl
{ {
DbGridControl* pParent = static_cast<DbGridControl*>(GetParent()); DbGridControl* pParent = static_cast<DbGridControl*>(GetParent());
sal_Int32 nAdjustedRowCount = pParent->GetRowCount() - ((pParent->GetOptions() & DbGridControl::OPT_INSERT) ? 2 : 1); sal_Int32 nAdjustedRowCount = pParent->GetRowCount() - ((pParent->GetOptions() & DbGridControlOptions::Insert) ? 2 : 1);
// check if everything needs to be invalidated // check if everything needs to be invalidated
bAll = bAll || m_nCurrentPos <= 0; bAll = bAll || m_nCurrentPos <= 0;
@@ -645,14 +645,14 @@ bool DbGridControl::NavigationBar::GetState(sal_uInt16 nWhich) const
if(pParent->m_bRecordCountFinal) if(pParent->m_bRecordCountFinal)
{ {
bAvailable = m_nCurrentPos < pParent->GetRowCount() - 1; bAvailable = m_nCurrentPos < pParent->GetRowCount() - 1;
if (!bAvailable && pParent->GetOptions() & DbGridControl::OPT_INSERT) if (!bAvailable && pParent->GetOptions() & DbGridControlOptions::Insert)
bAvailable = (m_nCurrentPos == pParent->GetRowCount() - 2) && pParent->IsModified(); bAvailable = (m_nCurrentPos == pParent->GetRowCount() - 2) && pParent->IsModified();
} }
break; break;
case NavigationBar::RECORD_LAST: case NavigationBar::RECORD_LAST:
if(pParent->m_bRecordCountFinal) if(pParent->m_bRecordCountFinal)
{ {
if (pParent->GetOptions() & DbGridControl::OPT_INSERT) if (pParent->GetOptions() & DbGridControlOptions::Insert)
bAvailable = pParent->IsCurrentAppending() ? pParent->GetRowCount() > 1 : bAvailable = pParent->IsCurrentAppending() ? pParent->GetRowCount() > 1 :
m_nCurrentPos != pParent->GetRowCount() - 2; m_nCurrentPos != pParent->GetRowCount() - 2;
else else
@@ -660,7 +660,7 @@ bool DbGridControl::NavigationBar::GetState(sal_uInt16 nWhich) const
} }
break; break;
case NavigationBar::RECORD_NEW: case NavigationBar::RECORD_NEW:
bAvailable = (pParent->GetOptions() & DbGridControl::OPT_INSERT) && pParent->GetRowCount() && m_nCurrentPos < pParent->GetRowCount() - 1; bAvailable = (pParent->GetOptions() & DbGridControlOptions::Insert) && pParent->GetRowCount() && m_nCurrentPos < pParent->GetRowCount() - 1;
break; break;
case NavigationBar::RECORD_ABSOLUTE: case NavigationBar::RECORD_ABSOLUTE:
bAvailable = pParent->GetRowCount() > 0; bAvailable = pParent->GetRowCount() > 0;
@@ -723,7 +723,7 @@ void DbGridControl::NavigationBar::SetState(sal_uInt16 nWhich)
OUString aText; OUString aText;
if (bAvailable) if (bAvailable)
{ {
if (pParent->GetOptions() & DbGridControl::OPT_INSERT) if (pParent->GetOptions() & DbGridControlOptions::Insert)
{ {
if (pParent->IsCurrentAppending() && !pParent->IsModified()) if (pParent->IsCurrentAppending() && !pParent->IsModified())
aText = m_aAbsolute->CreateFieldText(pParent->GetRowCount()); aText = m_aAbsolute->CreateFieldText(pParent->GetRowCount());
@@ -955,8 +955,8 @@ DbGridControl::DbGridControl(
,m_nMode(DEFAULT_BROWSE_MODE) ,m_nMode(DEFAULT_BROWSE_MODE)
,m_nCurrentPos(-1) ,m_nCurrentPos(-1)
,m_nDeleteEvent(nullptr) ,m_nDeleteEvent(nullptr)
,m_nOptions(OPT_READONLY) ,m_nOptions(DbGridControlOptions::Readonly)
,m_nOptionMask(OPT_INSERT | OPT_UPDATE | OPT_DELETE) ,m_nOptionMask(DbGridControlOptions::Insert | DbGridControlOptions::Update | DbGridControlOptions::Delete)
,m_nLastColId((sal_uInt16)-1) ,m_nLastColId((sal_uInt16)-1)
,m_nLastRowId(-1) ,m_nLastRowId(-1)
,m_bDesignMode(false) ,m_bDesignMode(false)
@@ -1157,7 +1157,7 @@ void DbGridControl::RemoveRows(bool bNewCursor)
DELETEZ(m_pSeekCursor); DELETEZ(m_pSeekCursor);
m_xPaintRow = m_xDataRow = m_xEmptyRow = m_xCurrentRow = m_xSeekRow = nullptr; m_xPaintRow = m_xDataRow = m_xEmptyRow = m_xCurrentRow = m_xSeekRow = nullptr;
m_nCurrentPos = m_nSeekPos = -1; m_nCurrentPos = m_nSeekPos = -1;
m_nOptions = OPT_READONLY; m_nOptions = DbGridControlOptions::Readonly;
RowRemoved(0, GetRowCount(), false); RowRemoved(0, GetRowCount(), false);
m_nTotalCount = -1; m_nTotalCount = -1;
@@ -1184,7 +1184,7 @@ void DbGridControl::RemoveRows()
m_xPaintRow = m_xDataRow = m_xEmptyRow = m_xCurrentRow = m_xSeekRow = nullptr; m_xPaintRow = m_xDataRow = m_xEmptyRow = m_xCurrentRow = m_xSeekRow = nullptr;
m_nCurrentPos = m_nSeekPos = m_nTotalCount = -1; m_nCurrentPos = m_nSeekPos = m_nTotalCount = -1;
m_nOptions = OPT_READONLY; m_nOptions = DbGridControlOptions::Readonly;
// reset number of sentences to zero in the browser // reset number of sentences to zero in the browser
DbGridControl_Base::RemoveRows(); DbGridControl_Base::RemoveRows();
@@ -1282,7 +1282,7 @@ void DbGridControl::EnableNavigationBar(bool bEnable)
} }
} }
sal_uInt16 DbGridControl::SetOptions(sal_uInt16 nOpt) DbGridControlOptions DbGridControl::SetOptions(DbGridControlOptions nOpt)
{ {
DBG_ASSERT(!m_xCurrentRow || !m_xCurrentRow->IsModified(), DBG_ASSERT(!m_xCurrentRow || !m_xCurrentRow->IsModified(),
"DbGridControl::SetOptions : please do not call when editing a record (things are much easier this way ;) !"); "DbGridControl::SetOptions : please do not call when editing a record (things are much easier this way ;) !");
@@ -1298,14 +1298,14 @@ sal_uInt16 DbGridControl::SetOptions(sal_uInt16 nOpt)
sal_Int32 nPrivileges = 0; sal_Int32 nPrivileges = 0;
xDataSourceSet->getPropertyValue(FM_PROP_PRIVILEGES) >>= nPrivileges; xDataSourceSet->getPropertyValue(FM_PROP_PRIVILEGES) >>= nPrivileges;
if ((nPrivileges & Privilege::INSERT) == 0) if ((nPrivileges & Privilege::INSERT) == 0)
nOpt &= ~OPT_INSERT; nOpt &= ~DbGridControlOptions::Insert;
if ((nPrivileges & Privilege::UPDATE) == 0) if ((nPrivileges & Privilege::UPDATE) == 0)
nOpt &= ~OPT_UPDATE; nOpt &= ~DbGridControlOptions::Update;
if ((nPrivileges & Privilege::DELETE) == 0) if ((nPrivileges & Privilege::DELETE) == 0)
nOpt &= ~OPT_DELETE; nOpt &= ~DbGridControlOptions::Delete;
} }
else else
nOpt = OPT_READONLY; nOpt = DbGridControlOptions::Readonly;
// need to do something after that ? // need to do something after that ?
if (nOpt == m_nOptions) if (nOpt == m_nOptions)
@@ -1315,7 +1315,7 @@ sal_uInt16 DbGridControl::SetOptions(sal_uInt16 nOpt)
BrowserMode nNewMode = m_nMode; BrowserMode nNewMode = m_nMode;
if (!(m_nMode & BrowserMode::CURSOR_WO_FOCUS)) if (!(m_nMode & BrowserMode::CURSOR_WO_FOCUS))
{ {
if (nOpt & OPT_UPDATE) if (nOpt & DbGridControlOptions::Update)
nNewMode |= BrowserMode::HIDECURSOR; nNewMode |= BrowserMode::HIDECURSOR;
else else
nNewMode &= ~BrowserMode::HIDECURSOR; nNewMode &= ~BrowserMode::HIDECURSOR;
@@ -1333,14 +1333,14 @@ sal_uInt16 DbGridControl::SetOptions(sal_uInt16 nOpt)
// _after_ setting the mode because this results in an ActivateCell // _after_ setting the mode because this results in an ActivateCell
DeactivateCell(); DeactivateCell();
bool bInsertChanged = (nOpt & OPT_INSERT) != (m_nOptions & OPT_INSERT); bool bInsertChanged = (nOpt & DbGridControlOptions::Insert) != (m_nOptions & DbGridControlOptions::Insert);
m_nOptions = nOpt; m_nOptions = nOpt;
// we need to set this before the code below because it indirectly uses m_nOptions // we need to set this before the code below because it indirectly uses m_nOptions
// the 'insert' option affects our empty row // the 'insert' option affects our empty row
if (bInsertChanged) if (bInsertChanged)
{ {
if (m_nOptions & OPT_INSERT) if (m_nOptions & DbGridControlOptions::Insert)
{ // the insert option is to be set { // the insert option is to be set
m_xEmptyRow = new DbGridRow(); m_xEmptyRow = new DbGridRow();
RowInserted(GetRowCount()); RowInserted(GetRowCount());
@@ -1384,7 +1384,7 @@ void DbGridControl::EnablePermanentCursor(bool bEnable)
} }
else else
{ {
if (m_nOptions & OPT_UPDATE) if (m_nOptions & DbGridControlOptions::Update)
m_nMode |= BrowserMode::HIDECURSOR; // no cursor at all m_nMode |= BrowserMode::HIDECURSOR; // no cursor at all
else else
m_nMode &= ~BrowserMode::HIDECURSOR; // at least the "non-permanent" cursor m_nMode &= ~BrowserMode::HIDECURSOR; // at least the "non-permanent" cursor
@@ -1413,7 +1413,7 @@ void DbGridControl::refreshController(sal_uInt16 _nColId, GrantControlAccess /*_
} }
} }
void DbGridControl::setDataSource(const Reference< XRowSet >& _xCursor, sal_uInt16 nOpts) void DbGridControl::setDataSource(const Reference< XRowSet >& _xCursor, DbGridControlOptions nOpts)
{ {
if (!_xCursor.is() && !m_pDataCursor) if (!_xCursor.is() && !m_pDataCursor)
return; return;
@@ -1522,12 +1522,15 @@ void DbGridControl::setDataSource(const Reference< XRowSet >& _xCursor, sal_uInt
// Insert Option should be set if insert only otherwise you won't see any rows // Insert Option should be set if insert only otherwise you won't see any rows
// and no insertion is possible // and no insertion is possible
if ((m_nOptionMask & OPT_INSERT) && ((nPrivileges & Privilege::INSERT) == Privilege::INSERT) && (nOpts & OPT_INSERT)) if ((m_nOptionMask & DbGridControlOptions::Insert)
m_nOptions |= OPT_INSERT; && ((nPrivileges & Privilege::INSERT) == Privilege::INSERT) && (nOpts & DbGridControlOptions::Insert))
if ((m_nOptionMask & OPT_UPDATE) && ((nPrivileges & Privilege::UPDATE) == Privilege::UPDATE) && (nOpts & OPT_UPDATE)) m_nOptions |= DbGridControlOptions::Insert;
m_nOptions |= OPT_UPDATE; if ((m_nOptionMask & DbGridControlOptions::Update)
if ((m_nOptionMask & OPT_DELETE) && ((nPrivileges & Privilege::DELETE) == Privilege::DELETE) && (nOpts & OPT_DELETE)) && ((nPrivileges & Privilege::UPDATE) == Privilege::UPDATE) && (nOpts & DbGridControlOptions::Update))
m_nOptions |= OPT_DELETE; m_nOptions |= DbGridControlOptions::Update;
if ((m_nOptionMask & DbGridControlOptions::Delete)
&& ((nPrivileges & Privilege::DELETE) == Privilege::DELETE) && (nOpts & DbGridControlOptions::Delete))
m_nOptions |= DbGridControlOptions::Delete;
} }
} }
} }
@@ -1547,7 +1550,7 @@ void DbGridControl::setDataSource(const Reference< XRowSet >& _xCursor, sal_uInt
else else
{ {
// updates are allowed -> no focus rectangle // updates are allowed -> no focus rectangle
if ( m_nOptions & OPT_UPDATE ) if ( m_nOptions & DbGridControlOptions::Update )
m_nMode |= BrowserMode::HIDECURSOR; m_nMode |= BrowserMode::HIDECURSOR;
} }
@@ -1578,7 +1581,7 @@ void DbGridControl::setDataSource(const Reference< XRowSet >& _xCursor, sal_uInt
// insert the currently known rows // insert the currently known rows
// and one row if we are able to insert rows // and one row if we are able to insert rows
if (m_nOptions & OPT_INSERT) if (m_nOptions & DbGridControlOptions::Insert)
{ {
// insert the empty row for insertion // insert the empty row for insertion
m_xEmptyRow = new DbGridRow(); m_xEmptyRow = new DbGridRow();
@@ -1959,7 +1962,7 @@ void DbGridControl::AdjustRows()
// Here we need to consider that there might be an additional row for adding new data sets // Here we need to consider that there might be an additional row for adding new data sets
// add additional AppendRow for insertion // add additional AppendRow for insertion
if (m_nOptions & OPT_INSERT) if (m_nOptions & DbGridControlOptions::Insert)
++nRecordCount; ++nRecordCount;
// If there is currently an insertion, so do not consider this added row in RecordCount or Appendrow // If there is currently an insertion, so do not consider this added row in RecordCount or Appendrow
@@ -1997,7 +2000,7 @@ void DbGridControl::AdjustRows()
if (m_bRecordCountFinal && m_nTotalCount < 0) if (m_bRecordCountFinal && m_nTotalCount < 0)
{ {
if (m_nOptions & OPT_INSERT) if (m_nOptions & DbGridControlOptions::Insert)
m_nTotalCount = GetRowCount() - 1; m_nTotalCount = GetRowCount() - 1;
else else
m_nTotalCount = GetRowCount(); m_nTotalCount = GetRowCount();
@@ -2359,7 +2362,7 @@ bool DbGridControl::SeekCursor(long nRow, bool bAbsolute)
} }
else if (IsInsertionRow(nRow)) // blank row for data insertion else if (IsInsertionRow(nRow)) // blank row for data insertion
m_nSeekPos = nRow; m_nSeekPos = nRow;
else if ((-1 == nRow) && (GetRowCount() == ((m_nOptions & OPT_INSERT) ? 1 : 0)) && m_pSeekCursor->isAfterLast()) else if ((-1 == nRow) && (GetRowCount() == ((m_nOptions & DbGridControlOptions::Insert) ? 1 : 0)) && m_pSeekCursor->isAfterLast())
m_nSeekPos = nRow; m_nSeekPos = nRow;
else else
{ {
@@ -2485,7 +2488,7 @@ void DbGridControl::MoveToLast()
} }
// position onto the last data set not on a blank row // position onto the last data set not on a blank row
if (m_nOptions & OPT_INSERT) if (m_nOptions & DbGridControlOptions::Insert)
{ {
if ((GetRowCount() - 1) > 0) if ((GetRowCount() - 1) > 0)
MoveToPosition(GetRowCount() - 2); MoveToPosition(GetRowCount() - 2);
@@ -2574,7 +2577,7 @@ void DbGridControl::MoveToPosition(sal_uInt32 nPos)
void DbGridControl::AppendNew() void DbGridControl::AppendNew()
{ {
if (!m_pSeekCursor || !(m_nOptions & OPT_INSERT)) if (!m_pSeekCursor || !(m_nOptions & DbGridControlOptions::Insert))
return; return;
if (m_nTotalCount < 0) // no RecordCount, yet if (m_nTotalCount < 0) // no RecordCount, yet
@@ -2694,9 +2697,9 @@ sal_uInt32 DbGridControl::GetTotalCellWidth(long nRow, sal_uInt16 nColId)
void DbGridControl::PreExecuteRowContextMenu(sal_uInt16 /*nRow*/, PopupMenu& rMenu) void DbGridControl::PreExecuteRowContextMenu(sal_uInt16 /*nRow*/, PopupMenu& rMenu)
{ {
bool bDelete = (m_nOptions & OPT_DELETE) && GetSelectRowCount() && !IsCurrentAppending(); bool bDelete = (m_nOptions & DbGridControlOptions::Delete) && GetSelectRowCount() && !IsCurrentAppending();
// if only a blank row is selected than do not delete // if only a blank row is selected than do not delete
bDelete = bDelete && !((m_nOptions & OPT_INSERT) && GetSelectRowCount() == 1 && IsRowSelected(GetRowCount() - 1)); bDelete = bDelete && !((m_nOptions & DbGridControlOptions::Insert) && GetSelectRowCount() == 1 && IsRowSelected(GetRowCount() - 1));
rMenu.EnableItem(SID_FM_DELETEROWS, bDelete); rMenu.EnableItem(SID_FM_DELETEROWS, bDelete);
rMenu.EnableItem(SID_FM_RECORD_SAVE, IsModified()); rMenu.EnableItem(SID_FM_RECORD_SAVE, IsModified());
@@ -2924,8 +2927,8 @@ CellController* DbGridControl::GetController(long /*nRow*/, sal_uInt16 nColumnId
return nullptr; return nullptr;
} }
bool bInsert = (m_xCurrentRow->IsNew() && (m_nOptions & OPT_INSERT)); bool bInsert = (m_xCurrentRow->IsNew() && (m_nOptions & DbGridControlOptions::Insert));
bool bUpdate = (!m_xCurrentRow->IsNew() && (m_nOptions & OPT_UPDATE)); bool bUpdate = (!m_xCurrentRow->IsNew() && (m_nOptions & DbGridControlOptions::Update));
if ((bInsert && !pColumn->IsAutoValue()) || bUpdate) if ((bInsert && !pColumn->IsAutoValue()) || bUpdate)
{ {
@@ -2988,7 +2991,7 @@ void DbGridControl::Dispatch(sal_uInt16 nId)
{ {
if (nId == BROWSER_CURSORENDOFFILE) if (nId == BROWSER_CURSORENDOFFILE)
{ {
if (m_nOptions & OPT_INSERT) if (m_nOptions & DbGridControlOptions::Insert)
AppendNew(); AppendNew();
else else
MoveToLast(); MoveToLast();
@@ -3119,7 +3122,7 @@ bool DbGridControl::IsCurrentAppending() const
bool DbGridControl::IsInsertionRow(long nRow) const bool DbGridControl::IsInsertionRow(long nRow) const
{ {
return (m_nOptions & OPT_INSERT) && m_nTotalCount >= 0 && (nRow == GetRowCount() - 1); return (m_nOptions & DbGridControlOptions::Insert) && m_nTotalCount >= 0 && (nRow == GetRowCount() - 1);
} }
bool DbGridControl::SaveModified() bool DbGridControl::SaveModified()
@@ -3284,7 +3287,7 @@ bool DbGridControl::PreNotify(NotifyEvent& rEvt)
} }
else if ( ( KEY_DELETE == nCode ) && !bShift && !bCtrl ) // delete rows else if ( ( KEY_DELETE == nCode ) && !bShift && !bCtrl ) // delete rows
{ {
if ((m_nOptions & OPT_DELETE) && GetSelectRowCount()) if ((m_nOptions & DbGridControlOptions::Delete) && GetSelectRowCount())
{ {
// delete asynchronously // delete asynchronously
if (m_nDeleteEvent) if (m_nDeleteEvent)
@@ -3642,7 +3645,7 @@ void DbGridControl::disposing(sal_uInt16 _nId, const EventObject& /*_rEvt*/)
if (_nId == 0) if (_nId == 0)
{ // the seek cursor is being disposed { // the seek cursor is being disposed
::osl::MutexGuard aGuard(m_aAdjustSafety); ::osl::MutexGuard aGuard(m_aAdjustSafety);
setDataSource(nullptr,0); // our clone was disposed so we set our datasource to null to avoid later access to it setDataSource(nullptr, DbGridControlOptions::Readonly); // our clone was disposed so we set our datasource to null to avoid later access to it
if (m_nAsynAdjustEvent) if (m_nAsynAdjustEvent)
{ {
RemoveUserEvent(m_nAsynAdjustEvent); RemoveUserEvent(m_nAsynAdjustEvent);