diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-05-04 16:29:43 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-05-07 08:34:03 +0200 |
commit | dbba08c7d430948775d47164c760ea1100442beb (patch) | |
tree | f3dfa5c735f7cef7aa826ed1cf13524f79c26181 /svx | |
parent | f7a0627c9a5ebd5827fc793ae023fb28e99a6525 (diff) |
loplugin:useuniqueptr in FmGridControl
Change-Id: I2fc39692bfb42bfff667908d73b3074d5cc04a28
Reviewed-on: https://gerrit.libreoffice.org/53881
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/fmcomp/fmgridcl.cxx | 8 | ||||
-rw-r--r-- | svx/source/fmcomp/gridctrl.cxx | 38 |
2 files changed, 22 insertions, 24 deletions
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; } } |