[Libreoffice-commits] core.git: include/svx svx/source
Noel Grandin
noel.grandin at collabora.co.uk
Mon May 7 06:34:14 UTC 2018
include/svx/gridctrl.hxx | 8 ++++----
svx/source/fmcomp/fmgridcl.cxx | 8 ++++----
svx/source/fmcomp/gridctrl.cxx | 38 ++++++++++++++++++--------------------
3 files changed, 26 insertions(+), 28 deletions(-)
New commits:
commit dbba08c7d430948775d47164c760ea1100442beb
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Fri May 4 16:29:43 2018 +0200
loplugin:useuniqueptr in FmGridControl
Change-Id: I2fc39692bfb42bfff667908d73b3074d5cc04a28
Reviewed-on: https://gerrit.libreoffice.org/53881
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/svx/gridctrl.hxx b/include/svx/gridctrl.hxx
index 32bbd965b579..432a3a463134 100644
--- a/include/svx/gridctrl.hxx
+++ b/include/svx/gridctrl.hxx
@@ -263,8 +263,8 @@ private:
FmGridListener* m_pGridListener;
protected:
- CursorWrapper* m_pDataCursor; // Cursor for Updates
- CursorWrapper* m_pSeekCursor; // Cursor for Seeking
+ std::unique_ptr<CursorWrapper> m_pDataCursor; // Cursor for Updates
+ std::unique_ptr<CursorWrapper> m_pSeekCursor; // Cursor for Seeking
private:
// iteration variables
@@ -402,7 +402,7 @@ public:
DbGridControlOptions nOpts = DbGridControlOptions::Insert | DbGridControlOptions::Update | DbGridControlOptions::Delete);
virtual void Dispatch(sal_uInt16 nId) override;
- CursorWrapper* getDataSource() const {return m_pDataCursor;}
+ CursorWrapper* getDataSource() const {return m_pDataCursor.get();}
const DbGridColumns& GetColumns() const {return m_aColumns;}
void EnableHandle(bool bEnable);
@@ -523,7 +523,7 @@ public:
/// called when a controller needs to be re-initialized
void refreshController(sal_uInt16 _nColId, GrantControlAccess _aAccess);
- CursorWrapper* GetSeekCursor(GrantControlAccess /*_aAccess*/) const { return m_pSeekCursor; }
+ CursorWrapper* GetSeekCursor(GrantControlAccess /*_aAccess*/) const { return m_pSeekCursor.get(); }
const DbGridRowRef& GetSeekRow(GrantControlAccess /*_aAccess*/) const { return m_xSeekRow; }
void SetSeekPos(sal_Int32 nPos,GrantControlAccess /*_aAccess*/) {m_nSeekPos = nPos;}
diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx
index 0f982f884e2d..972a66c94666 100644
--- a/svx/source/fmcomp/fmgridcl.cxx
+++ b/svx/source/fmcomp/fmgridcl.cxx
@@ -1232,7 +1232,7 @@ void FmGridControl::DeleteSelectedRows()
// there is a next row to position on
if (SeekCursor(nIdx))
{
- GetSeekRow()->SetState(m_pSeekCursor, true);
+ GetSeekRow()->SetState(m_pSeekCursor.get(), true);
bNewPos = true;
// if it's not the row for inserting we keep the bookmark
@@ -1246,7 +1246,7 @@ void FmGridControl::DeleteSelectedRows()
nIdx = FirstSelectedRow() - 1;
if (nIdx >= 0 && SeekCursor(nIdx))
{
- GetSeekRow()->SetState(m_pSeekCursor, true);
+ GetSeekRow()->SetState(m_pSeekCursor.get(), true);
bNewPos = true;
aBookmark = m_pSeekCursor->getBookmark();
@@ -1438,7 +1438,7 @@ void FmGridControl::inserted()
return;
// line has been inserted, then reset the status and mode
- xRow->SetState(m_pDataCursor, false);
+ xRow->SetState(m_pDataCursor.get(), false);
xRow->SetNew(false);
}
@@ -1862,7 +1862,7 @@ Sequence< Any> FmGridControl::getSelectionBookmarks()
// first, position the data cursor on the selected block
if (SeekCursor(nIdx))
{
- GetSeekRow()->SetState(m_pSeekCursor, true);
+ GetSeekRow()->SetState(m_pSeekCursor.get(), true);
pBookmarks[i] = m_pSeekCursor->getBookmark();
}
diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx
index 97d156337440..9f706812a1db 100644
--- a/svx/source/fmcomp/gridctrl.cxx
+++ b/svx/source/fmcomp/gridctrl.cxx
@@ -1028,10 +1028,8 @@ void DbGridControl::dispose()
}
m_xRowSetListener.clear();
- delete m_pDataCursor;
- m_pDataCursor = nullptr;
- delete m_pSeekCursor;
- m_pSeekCursor = nullptr;
+ m_pDataCursor.reset();
+ m_pSeekCursor.reset();
m_aBar.disposeAndClear();
@@ -1149,7 +1147,7 @@ void DbGridControl::RemoveRows(bool bNewCursor)
// Did the data cursor change?
if (!bNewCursor)
{
- DELETEZ(m_pSeekCursor);
+ m_pSeekCursor.reset();
m_xPaintRow = m_xDataRow = m_xEmptyRow = m_xCurrentRow = m_xSeekRow = nullptr;
m_nCurrentPos = m_nSeekPos = -1;
m_nOptions = DbGridControlOptions::Readonly;
@@ -1174,8 +1172,8 @@ void DbGridControl::RemoveRows()
for (DbGridColumn* pColumn : m_aColumns)
pColumn->Clear();
- DELETEZ(m_pSeekCursor);
- DELETEZ(m_pDataCursor);
+ m_pSeekCursor.reset();
+ m_pDataCursor.reset();
m_xPaintRow = m_xDataRow = m_xEmptyRow = m_xCurrentRow = m_xSeekRow = nullptr;
m_nCurrentPos = m_nSeekPos = m_nTotalCount = -1;
@@ -1469,7 +1467,7 @@ void DbGridControl::setDataSource(const Reference< XRowSet >& _xCursor, DbGridCo
}
}
- m_pDataCursor = new CursorWrapper(_xCursor);
+ m_pDataCursor.reset(new CursorWrapper(_xCursor));
// now create a cursor for painting rows
// we need that cursor only if we are not in insert only mode
@@ -1483,7 +1481,7 @@ void DbGridControl::setDataSource(const Reference< XRowSet >& _xCursor, DbGridCo
{
}
if (xClone.is())
- m_pSeekCursor = new CursorWrapper(xClone);
+ m_pSeekCursor.reset(new CursorWrapper(xClone));
// property listening on the data source
// (Normally one class would be sufficient : the multiplexer which could forward the property change to us.
@@ -1584,8 +1582,8 @@ void DbGridControl::setDataSource(const Reference< XRowSet >& _xCursor, DbGridCo
}
if (nRecordCount)
{
- m_xPaintRow = m_xSeekRow = new DbGridRow(m_pSeekCursor, true);
- m_xDataRow = new DbGridRow(m_pDataCursor, false);
+ m_xPaintRow = m_xSeekRow = new DbGridRow(m_pSeekCursor.get(), true);
+ m_xDataRow = new DbGridRow(m_pDataCursor.get(), false);
RowInserted(0, nRecordCount, false);
if (m_xSeekRow->IsValid())
@@ -1602,7 +1600,7 @@ void DbGridControl::setDataSource(const Reference< XRowSet >& _xCursor, DbGridCo
else
{
// no rows so we don't need a seekcursor
- DELETEZ(m_pSeekCursor);
+ m_pSeekCursor.reset();
}
}
@@ -1829,7 +1827,7 @@ bool DbGridControl::SeekRow(long nRow)
m_xPaintRow = m_xEmptyRow;
else
{
- m_xSeekRow->SetState( m_pSeekCursor, true );
+ m_xSeekRow->SetState( m_pSeekCursor.get(), true );
m_xPaintRow = m_xSeekRow;
}
}
@@ -2113,7 +2111,7 @@ bool DbGridControl::SetCurrent(long nNewRow)
}
}
}
- m_xDataRow->SetState(m_pDataCursor, false);
+ m_xDataRow->SetState(m_pDataCursor.get(), false);
m_xCurrentRow = m_xDataRow;
long nPaintPos = -1;
@@ -2950,7 +2948,7 @@ void DbGridControl::CellModified()
}
else if (m_xCurrentRow->GetStatus() != GridRowStatus::Modified)
{
- m_xCurrentRow->SetState(m_pDataCursor, false);
+ m_xCurrentRow->SetState(m_pDataCursor.get(), false);
SAL_INFO("svx.fmcomp", "current row is not new, after SetState, new state: " << ROWSTATUS(m_xCurrentRow));
m_xCurrentRow->SetStatus(GridRowStatus::Modified);
SAL_INFO("svx.fmcomp", "current row is not new, new state: MODIFIED");
@@ -3017,7 +3015,7 @@ void DbGridControl::Undo()
EndCursorAction();
- m_xDataRow->SetState(m_pDataCursor, false);
+ m_xDataRow->SetState(m_pDataCursor.get(), false);
if (m_xPaintRow == m_xCurrentRow)
m_xPaintRow = m_xCurrentRow = m_xDataRow;
else
@@ -3061,7 +3059,7 @@ void DbGridControl::resetCurrentRow()
}
// update the rows
- m_xDataRow->SetState(m_pDataCursor, false);
+ m_xDataRow->SetState(m_pDataCursor.get(), false);
if (m_xPaintRow == m_xCurrentRow)
m_xPaintRow = m_xCurrentRow = m_xDataRow;
else
@@ -3128,7 +3126,7 @@ bool DbGridControl::SaveModified()
if ( IsValid(m_xCurrentRow) )
{
- m_xCurrentRow->SetState(m_pDataCursor, false);
+ m_xCurrentRow->SetState(m_pDataCursor.get(), false);
SAL_INFO("svx.fmcomp", "explicit SetState, new state: " << ROWSTATUS(m_xCurrentRow));
InvalidateStatusCell( m_nCurrentPos );
}
@@ -3185,7 +3183,7 @@ bool DbGridControl::SaveRow()
{
// if we are appending we still sit on the insert row
// we don't move just clear the flags not to move on the current row
- m_xCurrentRow->SetState(m_pDataCursor, false);
+ m_xCurrentRow->SetState(m_pDataCursor.get(), false);
SAL_INFO("svx.fmcomp", "explicit SetState after a successful update, new state: " << ROWSTATUS(m_xCurrentRow));
m_xCurrentRow->SetNew(false);
@@ -3197,7 +3195,7 @@ bool DbGridControl::SaveRow()
Any aBookmark = bAppending ? m_pDataCursor->getBookmark() : m_pSeekCursor->getBookmark();
m_pSeekCursor->moveToBookmark(aBookmark);
// get the data
- m_xSeekRow->SetState(m_pSeekCursor, true);
+ m_xSeekRow->SetState(m_pSeekCursor.get(), true);
m_nSeekPos = m_pSeekCursor->getRow() - 1;
}
}
More information about the Libreoffice-commits
mailing list