[Libreoffice-commits] core.git: 3 commits - comphelper/source dbaccess/source extensions/source include/comphelper
Noel Grandin
noel.grandin at collabora.co.uk
Fri Jan 20 10:53:17 UTC 2017
comphelper/source/misc/SelectionMultiplex.cxx | 15 --
dbaccess/source/core/api/RowSetCache.cxx | 175 ++++++++++++--------------
dbaccess/source/core/api/RowSetCache.hxx | 3
extensions/source/bibliography/framectr.cxx | 73 +++++-----
extensions/source/bibliography/framectr.hxx | 3
include/comphelper/SelectionMultiplex.hxx | 7 -
6 files changed, 125 insertions(+), 151 deletions(-)
New commits:
commit cd10956cb0a32962840aee20298ad8a97ad914f5
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Fri Jan 20 12:18:13 2017 +0200
use rtl::Reference in ORowSetCache
instead of storing both a raw pointer and a uno::Reference
Change-Id: Ib3a4314a3d05e3c14a674b3d87baad245863ec6e
diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx
index 28009d0..c1863f6 100644
--- a/dbaccess/source/core/api/RowSetCache.cxx
+++ b/dbaccess/source/core/api/RowSetCache.cxx
@@ -91,7 +91,6 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
:m_xSet(_xRs)
,m_xMetaData(Reference< XResultSetMetaDataSupplier >(_xRs,UNO_QUERY)->getMetaData())
,m_aContext( _rContext )
- ,m_pCacheSet(nullptr)
,m_pMatrix(nullptr)
,m_pInsertMatrix(nullptr)
,m_nFetchSize(0)
@@ -123,9 +122,8 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
xUp->cancelRowUpdates();
_xRs->beforeFirst();
m_nPrivileges = Privilege::SELECT|Privilege::DELETE|Privilege::INSERT|Privilege::UPDATE;
- m_pCacheSet = new WrappedResultSet(i_nMaxRows);
- m_xCacheSet = m_pCacheSet;
- m_pCacheSet->construct(_xRs,i_sRowSetFilter);
+ m_xCacheSet = new WrappedResultSet(i_nMaxRows);
+ m_xCacheSet->construct(_xRs,i_sRowSetFilter);
return;
}
}
@@ -176,11 +174,10 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
{// here we have a join or union and nobody told us which table to update, so we update them all
m_nPrivileges = Privilege::SELECT|Privilege::DELETE|Privilege::INSERT|Privilege::UPDATE;
OptimisticSet* pCursor = new OptimisticSet(m_aContext,xConnection,_xAnalyzer,_aParameterValueForCache,i_nMaxRows,m_nRowCount);
- m_pCacheSet = pCursor;
- m_xCacheSet = m_pCacheSet;
+ m_xCacheSet = pCursor;
try
{
- m_pCacheSet->construct(_xRs,i_sRowSetFilter);
+ m_xCacheSet->construct(_xRs,i_sRowSetFilter);
if ( pCursor->isReadOnly() )
m_nPrivileges = Privilege::SELECT;
m_aKeyColumns = pCursor->getJoinedKeyColumns();
@@ -190,7 +187,6 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
{
SAL_WARN("dbaccess.core", "ORowSetCache: exception: " << e.Message);
}
- m_pCacheSet = nullptr;
m_xCacheSet.clear();
}
else
@@ -238,9 +234,8 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
{
try
{
- m_pCacheSet = new OBookmarkSet(i_nMaxRows);
- m_xCacheSet = m_pCacheSet;
- m_pCacheSet->construct(_xRs,i_sRowSetFilter);
+ m_xCacheSet = new OBookmarkSet(i_nMaxRows);
+ m_xCacheSet->construct(_xRs,i_sRowSetFilter);
// check privileges
m_nPrivileges = Privilege::SELECT;
@@ -275,14 +270,12 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
// here I know that we have a read only bookmarkable cursor
_xRs->beforeFirst();
m_nPrivileges = Privilege::SELECT;
- m_pCacheSet = new WrappedResultSet(i_nMaxRows);
- m_xCacheSet = m_pCacheSet;
- m_pCacheSet->construct(_xRs,i_sRowSetFilter);
+ m_xCacheSet = new WrappedResultSet(i_nMaxRows);
+ m_xCacheSet->construct(_xRs,i_sRowSetFilter);
return;
}
- m_pCacheSet = new OStaticSet(i_nMaxRows);
- m_xCacheSet = m_pCacheSet;
- m_pCacheSet->construct(_xRs,i_sRowSetFilter);
+ m_xCacheSet = new OStaticSet(i_nMaxRows);
+ m_xCacheSet->construct(_xRs,i_sRowSetFilter);
m_nPrivileges = Privilege::SELECT;
}
else
@@ -320,8 +313,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
OKeySet* pKeySet = new OKeySet(m_aUpdateTable,xUpdateTableKeys,aUpdateTableName ,_xAnalyzer,_aParameterValueForCache,i_nMaxRows,m_nRowCount);
try
{
- m_pCacheSet = pKeySet;
- m_xCacheSet = m_pCacheSet;
+ m_xCacheSet = pKeySet;
pKeySet->construct(_xRs,i_sRowSetFilter);
if(Reference<XResultSetUpdate>(_xRs,UNO_QUERY).is()) // this interface is optional so we have to check it
@@ -342,12 +334,8 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
{
SAL_WARN("dbaccess.core", "ORowSetCache: exception: " << e.Message);
// we couldn't create a keyset here so we have to create a static cache
- if ( m_pCacheSet )
- m_pCacheSet = nullptr;
- m_xCacheSet = nullptr;
- m_pCacheSet = new OStaticSet(i_nMaxRows);
- m_xCacheSet = m_pCacheSet;
- m_pCacheSet->construct(_xRs,i_sRowSetFilter);
+ m_xCacheSet = new OStaticSet(i_nMaxRows);
+ m_xCacheSet->construct(_xRs,i_sRowSetFilter);
m_nPrivileges = Privilege::SELECT;
}
}
@@ -361,8 +349,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
ORowSetCache::~ORowSetCache()
{
- m_pCacheSet = nullptr;
- m_xCacheSet = nullptr;
+ m_xCacheSet.clear();
if(m_pMatrix)
{
m_pMatrix->clear();
@@ -501,15 +488,15 @@ Any ORowSetCache::getBookmark( )
return Any(); // this is allowed here because the rowset knows what it is doing
}
- return lcl_getBookmark(((*m_aMatrixIter)->get())[0],m_pCacheSet);
+ return lcl_getBookmark(((*m_aMatrixIter)->get())[0],m_xCacheSet.get());
}
bool ORowSetCache::moveToBookmark( const Any& bookmark )
{
- if ( m_pCacheSet->moveToBookmark(bookmark) )
+ if ( m_xCacheSet->moveToBookmark(bookmark) )
{
m_bBeforeFirst = false;
- m_nPosition = m_pCacheSet->getRow();
+ m_nPosition = m_xCacheSet->getRow();
checkPositionFlags();
@@ -539,7 +526,7 @@ bool ORowSetCache::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows )
bool bRet( moveToBookmark( bookmark ) );
if ( bRet )
{
- m_nPosition = m_pCacheSet->getRow() + rows;
+ m_nPosition = m_xCacheSet->getRow() + rows;
absolute(m_nPosition);
bRet = m_aMatrixIter != m_pMatrix->end() && (*m_aMatrixIter).is();
@@ -550,17 +537,17 @@ bool ORowSetCache::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows )
sal_Int32 ORowSetCache::compareBookmarks( const Any& _first, const Any& _second )
{
- return (!_first.hasValue() || !_second.hasValue()) ? CompareBookmark::NOT_COMPARABLE : m_pCacheSet->compareBookmarks(_first,_second);
+ return (!_first.hasValue() || !_second.hasValue()) ? CompareBookmark::NOT_COMPARABLE : m_xCacheSet->compareBookmarks(_first,_second);
}
bool ORowSetCache::hasOrderedBookmarks( )
{
- return m_pCacheSet->hasOrderedBookmarks();
+ return m_xCacheSet->hasOrderedBookmarks();
}
sal_Int32 ORowSetCache::hashBookmark( const Any& bookmark )
{
- return m_pCacheSet->hashBookmark(bookmark);
+ return m_xCacheSet->hashBookmark(bookmark);
}
// XRowUpdate
@@ -578,7 +565,7 @@ void ORowSetCache::updateNull(sal_Int32 columnIndex,ORowSetValueVector::Vector&
rInsert[columnIndex].setModified();
io_aRow[columnIndex].setNull();
- m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns);
+ m_xCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns);
impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns);
}
}
@@ -598,7 +585,7 @@ void ORowSetCache::updateValue(sal_Int32 columnIndex,const ORowSetValue& x
rInsert[columnIndex].setModified();
io_aRow[columnIndex] = rInsert[columnIndex];
- m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns);
+ m_xCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns);
impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns);
}
}
@@ -620,7 +607,7 @@ void ORowSetCache::updateCharacterStream( sal_Int32 columnIndex, const Reference
rInsert[columnIndex].setModified();
io_aRow[columnIndex] = makeAny(x);
- m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns);
+ m_xCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns);
impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns);
}
@@ -641,7 +628,7 @@ void ORowSetCache::updateObject( sal_Int32 columnIndex, const Any& x
rInsert[columnIndex].setModified();
io_aRow[columnIndex] = rInsert[columnIndex];
- m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns);
+ m_xCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns);
impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns);
}
}
@@ -663,7 +650,7 @@ void ORowSetCache::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal
rInsert[columnIndex].setModified();
io_aRow[columnIndex] = rInsert[columnIndex];
- m_pCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns);
+ m_xCacheSet->mergeColumnValues(columnIndex,rInsert,io_aRow,o_ChangedColumns);
impl_updateRowFromCache_throw(io_aRow,o_ChangedColumns);
}
}
@@ -709,7 +696,7 @@ bool ORowSetCache::beforeFirst( )
m_bAfterLast = false;
m_nPosition = 0;
m_bBeforeFirst = true;
- m_pCacheSet->beforeFirst();
+ m_xCacheSet->beforeFirst();
moveWindow();
m_aMatrixIter = m_pMatrix->end();
}
@@ -725,11 +712,11 @@ bool ORowSetCache::afterLast( )
if(!m_bRowCountFinal)
{
- m_pCacheSet->last_checked(false);
+ m_xCacheSet->last_checked(false);
m_bRowCountFinal = true;
- m_nRowCount = m_pCacheSet->getRow();// + 1 removed
+ m_nRowCount = m_xCacheSet->getRow();// + 1 removed
}
- m_pCacheSet->afterLast();
+ m_xCacheSet->afterLast();
m_nPosition = 0;
m_aMatrixIter = m_pMatrix->end();
@@ -762,7 +749,7 @@ bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos, sal_Int32 &_nNewEndPos)
i = _nNewStartPos + 1;
requestedStartPos = _nNewStartPos;
}
- bCheck = m_pCacheSet->absolute(i);
+ bCheck = m_xCacheSet->absolute(i);
for(; i <= _nNewEndPos; ++i,++aIter)
@@ -771,15 +758,15 @@ bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos, sal_Int32 &_nNewEndPos)
{
if(!aIter->is())
*aIter = new ORowSetValueVector(m_xMetaData->getColumnCount());
- m_pCacheSet->fillValueRow(*aIter,i);
+ m_xCacheSet->fillValueRow(*aIter,i);
}
else
{ // there are no more rows found so we can fetch some before start
if(!m_bRowCountFinal)
{
- if(m_pCacheSet->previous_checked(false)) // because we stand after the last row
- m_nRowCount = m_pCacheSet->getRow(); // here we have the row count
+ if(m_xCacheSet->previous_checked(false)) // because we stand after the last row
+ m_nRowCount = m_xCacheSet->getRow(); // here we have the row count
if(!m_nRowCount)
m_nRowCount = i-1; // it can be that getRow return zero
m_bRowCountFinal = true;
@@ -798,29 +785,29 @@ bool ORowSetCache::fillMatrix(sal_Int32& _nNewStartPos, sal_Int32 &_nNewEndPos)
_nNewStartPos = nPos;
_nNewEndPos = m_nRowCount;
++nPos;
- bCheck = m_pCacheSet->absolute(nPos);
+ bCheck = m_xCacheSet->absolute(nPos);
for(;bCheck && nPos <= requestedStartPos && aIter != aRealEnd; ++aIter, ++nPos)
{
if(!aIter->is())
*aIter = new ORowSetValueVector(m_xMetaData->getColumnCount());
- m_pCacheSet->fillValueRow(*aIter, nPos);
- bCheck = m_pCacheSet->next();
+ m_xCacheSet->fillValueRow(*aIter, nPos);
+ bCheck = m_xCacheSet->next();
}
if(aIter != aEnd)
::std::rotate(m_pMatrix->begin(),aEnd,aIter);
break;
}
- bCheck = m_pCacheSet->next();
+ bCheck = m_xCacheSet->next();
}
// we have to read one row forward to ensure that we know when we are on last row
// but only when we don't know it already
if(!m_bRowCountFinal)
{
- if(!m_pCacheSet->next())
+ if(!m_xCacheSet->next())
{
- if(m_pCacheSet->previous_checked(false)) // because we stand after the last row
- m_nRowCount = m_pCacheSet->getRow(); // here we have the row count
+ if(m_xCacheSet->previous_checked(false)) // because we stand after the last row
+ m_nRowCount = m_xCacheSet->getRow(); // here we have the row count
m_bRowCountFinal = true;
}
else
@@ -848,16 +835,16 @@ void ORowSetCache::moveWindow()
OSL_ENSURE(m_aMatrixIter != m_pMatrix->end(), "New m_aMatrixIter is at end(), but should not.");
if(!m_aMatrixIter->is())
{
- bool bOk( m_pCacheSet->absolute( m_nPosition ) );
+ bool bOk( m_xCacheSet->absolute( m_nPosition ) );
if ( bOk )
{
*m_aMatrixIter = new ORowSetValueVector(m_xMetaData->getColumnCount());
- m_pCacheSet->fillValueRow(*m_aMatrixIter,m_nPosition);
+ m_xCacheSet->fillValueRow(*m_aMatrixIter,m_nPosition);
// we have to read one row forward to ensure that we know when we are on last row
// but only when we don't know it already
if ( !m_bRowCountFinal )
{
- bOk = m_pCacheSet->absolute_checked( m_nPosition + 1,false );
+ bOk = m_xCacheSet->absolute_checked( m_nPosition + 1,false );
if ( bOk )
m_nRowCount = std::max(sal_Int32(m_nPosition+1),m_nRowCount);
}
@@ -865,7 +852,7 @@ void ORowSetCache::moveWindow()
if(!bOk && !m_bRowCountFinal)
{
// because we stand after the last row
- m_nRowCount = m_pCacheSet->previous_checked(false) ? m_pCacheSet->getRow() : 0;
+ m_nRowCount = m_xCacheSet->previous_checked(false) ? m_xCacheSet->getRow() : 0;
m_bRowCountFinal = true;
}
}
@@ -894,7 +881,7 @@ void ORowSetCache::moveWindow()
// then we fill in the rows between new and old start pos.
bool bCheck;
- bCheck = m_pCacheSet->absolute(nNewStartPos + 1);
+ bCheck = m_xCacheSet->absolute(nNewStartPos + 1);
// m_nEndPos < nNewEndPos when window not filled (e.g. there are less rows in total than window size)
m_nEndPos = std::min(nNewEndPos, m_nEndPos);
@@ -975,7 +962,7 @@ void ORowSetCache::moveWindow()
// There is some unused space in *m_pMatrix; fill it
CHECK_MATRIX_POS(nRowsInCache);
sal_Int32 nPos = m_nEndPos + 1;
- bool bCheck = m_pCacheSet->absolute(nPos);
+ bool bCheck = m_xCacheSet->absolute(nPos);
ORowSetMatrix::iterator aIter = m_pMatrix->begin() + nRowsInCache;
const sal_Int32 nRowsToFetch = std::min(nNewEndPos-m_nEndPos, m_nFetchSize-nRowsInCache);
const ORowSetMatrix::const_iterator aEnd = aIter + nRowsToFetch;
@@ -998,7 +985,7 @@ void ORowSetCache::moveWindow()
ORowSetMatrix::iterator aDataEnd = m_pMatrix->begin() + (m_nEndPos - m_nStartPos);
sal_Int32 nPos = m_nEndPos + 1;
- bool bCheck = m_pCacheSet->absolute(nPos);
+ bool bCheck = m_xCacheSet->absolute(nPos);
bCheck = fill(aIter, aEnd, nPos, bCheck); // refill the region we don't need anymore
//aIter and nPos are now the position *after* last filled in one!
@@ -1017,12 +1004,12 @@ void ORowSetCache::moveWindow()
// but only when we don't know it already
bool bOk = true;
if(!m_bRowCountFinal)
- bOk = m_pCacheSet->next();
+ bOk = m_xCacheSet->next();
if(!bOk)
{
- m_pCacheSet->previous_checked(false); // because we stand after the last row
+ m_xCacheSet->previous_checked(false); // because we stand after the last row
m_nRowCount = nPos; // here we have the row count
- OSL_ENSURE(nPos == m_pCacheSet->getRow(),"nPos is not valid!");
+ OSL_ENSURE(nPos == m_xCacheSet->getRow(),"nPos is not valid!");
m_bRowCountFinal = true;
}
else if(!m_bRowCountFinal)
@@ -1047,9 +1034,9 @@ void ORowSetCache::moveWindow()
if ( !m_bRowCountFinal )
{
- m_pCacheSet->previous_checked(false); // because we stand after the last row
+ m_xCacheSet->previous_checked(false); // because we stand after the last row
m_nRowCount = std::max(m_nRowCount, nPos); // here we have the row count
- OSL_ENSURE(nPos == m_pCacheSet->getRow(),"nPos isn't valid!");
+ OSL_ENSURE(nPos == m_xCacheSet->getRow(),"nPos isn't valid!");
m_bRowCountFinal = true;
}
@@ -1060,15 +1047,15 @@ void ORowSetCache::moveWindow()
aIter = m_pMatrix->begin();
nPos = m_nStartPos + 1;
- bCheck = m_pCacheSet->absolute_checked(nPos, true);
+ bCheck = m_xCacheSet->absolute_checked(nPos, true);
for(; !aIter->is() && bCheck;++aIter, ++nPos)
{
OSL_ENSURE(aIter != m_pMatrix->end(),"Invalid iterator");
*aIter = new ORowSetValueVector(m_xMetaData->getColumnCount());
- m_pCacheSet->fillValueRow(*aIter, nPos);
+ m_xCacheSet->fillValueRow(*aIter, nPos);
- bCheck = m_pCacheSet->next();
+ bCheck = m_xCacheSet->next();
}
}
}
@@ -1089,7 +1076,7 @@ bool ORowSetCache::first( )
// Then check if the cache window is at the beginning.
// If not, then position the window and fill it with data.
// We move the window smartly, i.e. we clear only the rows that are out of range
- bool bRet = m_pCacheSet->first();
+ bool bRet = m_xCacheSet->first();
if(bRet)
{
m_bBeforeFirst = m_bAfterLast = false;
@@ -1110,19 +1097,19 @@ bool ORowSetCache::first( )
bool ORowSetCache::last( )
{
- bool bRet = m_pCacheSet->last();
+ bool bRet = m_xCacheSet->last();
if(bRet)
{
m_bBeforeFirst = m_bAfterLast = false;
if(!m_bRowCountFinal)
{
m_bRowCountFinal = true;
- m_nRowCount = m_pCacheSet->getRow(); // not + 1
+ m_nRowCount = m_xCacheSet->getRow(); // not + 1
}
- m_nPosition = m_pCacheSet->getRow();
+ m_nPosition = m_xCacheSet->getRow();
moveWindow();
// we have to repositioning because moveWindow can modify the cache
- m_pCacheSet->last();
+ m_xCacheSet->last();
OSL_ENSURE(((m_nPosition - m_nStartPos) - 1) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!");
m_aMatrixIter = calcPosition();
}
@@ -1265,8 +1252,8 @@ void ORowSetCache::refreshRow( )
if(isAfterLast())
throw SQLException(DBACORE_RESSTRING(RID_STR_NO_REFESH_AFTERLAST),nullptr,SQLSTATE_GENERAL,1000,Any() );
OSL_ENSURE(m_aMatrixIter != m_pMatrix->end(),"refreshRow() called for invalid row!");
- m_pCacheSet->refreshRow();
- m_pCacheSet->fillValueRow(*m_aMatrixIter,m_nPosition);
+ m_xCacheSet->refreshRow();
+ m_xCacheSet->fillValueRow(*m_aMatrixIter,m_nPosition);
if ( m_bNew )
{
cancelRowModification();
@@ -1275,12 +1262,12 @@ void ORowSetCache::refreshRow( )
bool ORowSetCache::rowUpdated( )
{
- return m_pCacheSet->rowUpdated();
+ return m_xCacheSet->rowUpdated();
}
bool ORowSetCache::rowInserted( )
{
- return m_pCacheSet->rowInserted();
+ return m_xCacheSet->rowInserted();
}
// XResultSetUpdate
@@ -1289,7 +1276,7 @@ bool ORowSetCache::insertRow(::std::vector< Any >& o_aBookmarks)
if ( !m_bNew || !m_aInsertRow->is() )
throw SQLException(DBACORE_RESSTRING(RID_STR_NO_MOVETOINSERTROW_CALLED),nullptr,SQLSTATE_GENERAL,1000,Any() );
- m_pCacheSet->insertRow(*m_aInsertRow,m_aUpdateTable);
+ m_xCacheSet->insertRow(*m_aInsertRow,m_aUpdateTable);
bool bRet( rowInserted() );
if ( bRet )
@@ -1305,9 +1292,9 @@ bool ORowSetCache::insertRow(::std::vector< Any >& o_aBookmarks)
ORowSetMatrix::const_iterator aIter = m_pMatrix->begin();
for(;aIter != m_pMatrix->end();++aIter)
{
- if ( m_aMatrixIter != aIter && aIter->is() && m_pCacheSet->columnValuesUpdated((*aIter)->get(),rCurrentRow) )
+ if ( m_aMatrixIter != aIter && aIter->is() && m_xCacheSet->columnValuesUpdated((*aIter)->get(),rCurrentRow) )
{
- o_aBookmarks.push_back(lcl_getBookmark((*aIter)->get()[0],m_pCacheSet));
+ o_aBookmarks.push_back(lcl_getBookmark((*aIter)->get()[0], m_xCacheSet.get()));
}
}
}
@@ -1350,7 +1337,7 @@ void ORowSetCache::updateRow( ORowSetMatrix::iterator& _rUpdateRow,::std::vector
// here we don't have to reposition our CacheSet, when we try to update a row,
// the row was already fetched
moveToBookmark(aBookmark);
- m_pCacheSet->updateRow(*_rUpdateRow,*m_aMatrixIter,m_aUpdateTable);
+ m_xCacheSet->updateRow(*_rUpdateRow,*m_aMatrixIter,m_aUpdateTable);
// refetch the whole row
(*m_aMatrixIter) = nullptr;
@@ -1361,9 +1348,9 @@ void ORowSetCache::updateRow( ORowSetMatrix::iterator& _rUpdateRow,::std::vector
ORowSetMatrix::const_iterator aIter = m_pMatrix->begin();
for(;aIter != m_pMatrix->end();++aIter)
{
- if ( m_aMatrixIter != aIter && aIter->is() && m_pCacheSet->columnValuesUpdated((*aIter)->get(),rCurrentRow) )
+ if ( m_aMatrixIter != aIter && aIter->is() && m_xCacheSet->columnValuesUpdated((*aIter)->get(),rCurrentRow) )
{
- o_aBookmarks.push_back(lcl_getBookmark((*aIter)->get()[0],m_pCacheSet));
+ o_aBookmarks.push_back(lcl_getBookmark((*aIter)->get()[0], m_xCacheSet.get()));
}
}
}
@@ -1376,8 +1363,8 @@ bool ORowSetCache::deleteRow( )
if(isAfterLast() || isBeforeFirst())
throw SQLException(DBACORE_RESSTRING(RID_STR_NO_DELETEROW),nullptr,SQLSTATE_GENERAL,1000,Any() );
- m_pCacheSet->deleteRow(*m_aMatrixIter,m_aUpdateTable);
- if ( !m_pCacheSet->rowDeleted() )
+ m_xCacheSet->deleteRow(*m_aMatrixIter,m_aUpdateTable);
+ if ( !m_xCacheSet->rowDeleted() )
return false;
--m_nRowCount;
@@ -1406,8 +1393,8 @@ void ORowSetCache::cancelRowUpdates( )
::dbtools::throwFunctionSequenceException(nullptr);
}
- if(m_pCacheSet->absolute(m_nPosition))
- m_pCacheSet->fillValueRow(*m_aMatrixIter,m_nPosition);
+ if(m_xCacheSet->absolute(m_nPosition))
+ m_xCacheSet->fillValueRow(*m_aMatrixIter,m_nPosition);
else
{
OSL_FAIL("cancelRowUpdates couldn't position right with absolute");
@@ -1709,22 +1696,22 @@ bool ORowSetCache::fill(ORowSetMatrix::iterator& _aIter, const ORowSetMatrix::co
*_aIter = new ORowSetValueVector(nColumnCount);
}
}
- m_pCacheSet->fillValueRow(*_aIter, _nPos);
- _bCheck = m_pCacheSet->next();
+ m_xCacheSet->fillValueRow(*_aIter, _nPos);
+ _bCheck = m_xCacheSet->next();
}
return _bCheck;
}
bool ORowSetCache::isResultSetChanged() const
{
- return m_pCacheSet->isResultSetChanged();
+ return m_xCacheSet->isResultSetChanged();
}
void ORowSetCache::reset(const Reference< XResultSet>& _xDriverSet)
{
m_xSet = _xDriverSet;
m_xMetaData.set(Reference< XResultSetMetaDataSupplier >(_xDriverSet,UNO_QUERY)->getMetaData());
- m_pCacheSet->reset(_xDriverSet);
+ m_xCacheSet->reset(_xDriverSet);
m_bRowCountFinal = false;
m_nRowCount = 0;
@@ -1739,7 +1726,7 @@ void ORowSetCache::impl_updateRowFromCache_throw(ORowSetValueVector::Vector& io_
ORowSetMatrix::const_iterator aIter = m_pMatrix->begin();
for(;aIter != m_pMatrix->end();++aIter)
{
- if ( aIter->is() && m_pCacheSet->updateColumnValues((*aIter)->get(),io_aRow,o_ChangedColumns))
+ if ( aIter->is() && m_xCacheSet->updateColumnValues((*aIter)->get(),io_aRow,o_ChangedColumns))
{
break;
}
@@ -1747,7 +1734,7 @@ void ORowSetCache::impl_updateRowFromCache_throw(ORowSetValueVector::Vector& io_
if ( aIter == m_pMatrix->end() )
{
- m_pCacheSet->fillMissingValues(io_aRow);
+ m_xCacheSet->fillMissingValues(io_aRow);
}
}
}
diff --git a/dbaccess/source/core/api/RowSetCache.hxx b/dbaccess/source/core/api/RowSetCache.hxx
index 3dec5b7..8838254 100644
--- a/dbaccess/source/core/api/RowSetCache.hxx
+++ b/dbaccess/source/core/api/RowSetCache.hxx
@@ -63,9 +63,8 @@ namespace dbaccess
css::uno::Reference< css::sdbc::XResultSetMetaData > m_xMetaData; // must be before m_aInsertRow
css::uno::Reference< css::uno::XComponentContext> m_aContext;
- css::uno::Reference< css::sdbc::XRow> m_xCacheSet;
+ rtl::Reference<OCacheSet> m_xCacheSet; // is a bookmarkable, keyset or static resultset
- OCacheSet* m_pCacheSet; // is a bookmarkable, keyset or static resultset
ORowSetMatrix* m_pMatrix; // represent the table struct
ORowSetMatrix::iterator m_aMatrixIter; // represent a row of the table
ORowSetMatrix::iterator m_aMatrixEnd; // present the row behind the last row of the table
commit 81253afdba52ed27eaf31f15757f7a07590353e8
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Fri Jan 20 12:11:48 2017 +0200
use rtl::Reference in BibFrameCtrl_Impl
instead of storing both a raw pointer and a uno::Reference
Change-Id: I8caa56eade25561178aa6ffd144b00f452517974
diff --git a/extensions/source/bibliography/framectr.cxx b/extensions/source/bibliography/framectr.cxx
index 4dbc7eb..98160bf 100644
--- a/extensions/source/bibliography/framectr.cxx
+++ b/extensions/source/bibliography/framectr.cxx
@@ -164,7 +164,6 @@ BibFrameController_Impl::BibFrameController_Impl( const uno::Reference< awt::XWi
BibDataManager* pDataManager)
:xWindow( xComponent )
,m_xDatMan( pDataManager )
- ,pDatMan( pDataManager )
,pBibMod(nullptr)
{
bDisposing=false;
@@ -176,7 +175,7 @@ BibFrameController_Impl::BibFrameController_Impl( const uno::Reference< awt::XWi
BibFrameController_Impl::~BibFrameController_Impl()
{
mxImpl->pController = nullptr;
- delete pDatMan;
+ m_xDatMan.clear();
if(pBibMod)
CloseBibModul(pBibMod);
}
@@ -244,8 +243,7 @@ void BibFrameController_Impl::dispose() throw (css::uno::RuntimeException, std::
lang::EventObject aObject;
aObject.Source = static_cast<XController*>(this);
mxImpl->aLC.disposeAndClear(aObject);
- m_xDatMan = nullptr;
- pDatMan = nullptr;
+ m_xDatMan.clear();
aStatusListeners.clear();
}
@@ -267,7 +265,7 @@ uno::Reference< frame::XDispatch > BibFrameController_Impl::queryDispatch( cons
CmdToInfoCache::const_iterator pIter = rCmdCache.find( aURL.Complete );
if ( pIter != rCmdCache.end() )
{
- if (( pDatMan->HasActiveConnection() ) ||
+ if (( m_xDatMan->HasActiveConnection() ) ||
( !pIter->second.bActiveConnection ))
return static_cast<frame::XDispatch*>(this);
}
@@ -403,7 +401,7 @@ void BibFrameController_Impl::dispatch(const util::URL& _rURL, const uno::Sequen
OUString aCommand( _rURL.Path);
if(aCommand == "Bib/Mapping")
{
- pDatMan->CreateMappingDialog(pParent);
+ m_xDatMan->CreateMappingDialog(pParent);
}
else if(aCommand == "Bib/source")
{
@@ -411,7 +409,7 @@ void BibFrameController_Impl::dispatch(const util::URL& _rURL, const uno::Sequen
}
else if(aCommand == "Bib/sdbsource")
{
- OUString aURL = pDatMan->CreateDBChangeDialog(pParent);
+ OUString aURL = m_xDatMan->CreateDBChangeDialog(pParent);
if(!aURL.isEmpty())
{
try
@@ -456,7 +454,7 @@ void BibFrameController_Impl::dispatch(const util::URL& _rURL, const uno::Sequen
aValue >>= aQueryField;
BibConfig* pConfig = BibModul::GetConfig();
pConfig->setQueryField(aQueryField);
- pDatMan->startQueryWith(aQuery);
+ m_xDatMan->startQueryWith(aQuery);
}
else if(aCommand == "Bib/standardFilter")
{
@@ -465,15 +463,15 @@ void BibFrameController_Impl::dispatch(const util::URL& _rURL, const uno::Sequen
uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
// create the dialog object
- uno::Reference< ui::dialogs::XExecutableDialog > xDialog = sdb::FilterDialog::createWithQuery(xContext, pDatMan->getParser(),
- Reference<sdbc::XRowSet>(pDatMan->getForm(), uno::UNO_QUERY_THROW), xWindow);
+ uno::Reference< ui::dialogs::XExecutableDialog > xDialog = sdb::FilterDialog::createWithQuery(xContext, m_xDatMan->getParser(),
+ Reference<sdbc::XRowSet>(m_xDatMan->getForm(), uno::UNO_QUERY_THROW), xWindow);
// execute it
if ( xDialog->execute( ) )
{
// the dialog has been executed successfully, and the filter on the query composer
// has been changed
- OUString sNewFilter = pDatMan->getParser()->getFilter();
- pDatMan->setFilter( sNewFilter );
+ OUString sNewFilter = m_xDatMan->getParser()->getFilter();
+ m_xDatMan->setFilter( sNewFilter );
}
}
catch( const uno::Exception& )
@@ -485,11 +483,11 @@ void BibFrameController_Impl::dispatch(const util::URL& _rURL, const uno::Sequen
for ( sal_uInt16 n=0; n<nCount; n++ )
{
BibStatusDispatch *pObj = aStatusListeners[n].get();
- if ( pObj->aURL.Path == "Bib/removeFilter" && pDatMan->getParser().is())
+ if ( pObj->aURL.Path == "Bib/removeFilter" && m_xDatMan->getParser().is())
{
FeatureStateEvent aEvent;
aEvent.FeatureURL = pObj->aURL;
- aEvent.IsEnabled = !pDatMan->getParser()->getFilter().isEmpty();
+ aEvent.IsEnabled = !m_xDatMan->getParser()->getFilter().isEmpty();
aEvent.Requery = false;
aEvent.Source = static_cast<XDispatch *>(this);
pObj->xListener->statusChanged( aEvent );
@@ -508,15 +506,15 @@ void BibFrameController_Impl::dispatch(const util::URL& _rURL, const uno::Sequen
}
else if(aCommand == "Bib/InsertRecord")
{
- Reference<form::runtime::XFormController > xFormCtrl = pDatMan->GetFormController();
+ Reference<form::runtime::XFormController > xFormCtrl = m_xDatMan->GetFormController();
if(SaveModified(xFormCtrl))
{
try
{
- Reference< sdbc::XResultSet > xCursor( pDatMan->getForm(), UNO_QUERY );
+ Reference< sdbc::XResultSet > xCursor( m_xDatMan->getForm(), UNO_QUERY );
xCursor->last();
- Reference< XResultSetUpdate > xUpdateCursor( pDatMan->getForm(), UNO_QUERY );
+ Reference< XResultSetUpdate > xUpdateCursor( m_xDatMan->getForm(), UNO_QUERY );
xUpdateCursor->moveToInsertRow();
}
catch(const Exception&)
@@ -527,9 +525,9 @@ void BibFrameController_Impl::dispatch(const util::URL& _rURL, const uno::Sequen
}
else if(aCommand == "Bib/DeleteRecord")
{
- Reference< css::sdbc::XResultSet > xCursor(pDatMan->getForm(), UNO_QUERY);
+ Reference< css::sdbc::XResultSet > xCursor(m_xDatMan->getForm(), UNO_QUERY);
Reference< XResultSetUpdate > xUpdateCursor(xCursor, UNO_QUERY);
- Reference< beans::XPropertySet > xSet(pDatMan->getForm(), UNO_QUERY);
+ Reference< beans::XPropertySet > xSet(m_xDatMan->getForm(), UNO_QUERY);
bool bIsNew = ::comphelper::getBOOL(xSet->getPropertyValue("IsNew"));
if(!bIsNew)
{
@@ -545,7 +543,7 @@ void BibFrameController_Impl::dispatch(const util::URL& _rURL, const uno::Sequen
bRight= !xCursor->isLast();
// ask for confirmation
Reference< frame::XController > xCtrl = mxImpl->pController;
- Reference< form::XConfirmDeleteListener > xConfirm(pDatMan->GetFormController(),UNO_QUERY);
+ Reference< form::XConfirmDeleteListener > xConfirm(m_xDatMan->GetFormController(),UNO_QUERY);
if (xConfirm.is())
{
sdb::RowChangeEvent aEvent;
@@ -650,17 +648,17 @@ void BibFrameController_Impl::addStatusListener(
else if(aURL.Path == "Bib/MenuFilter")
{
aEvent.IsEnabled = true;
- aEvent.FeatureDescriptor=pDatMan->getQueryField();
+ aEvent.FeatureDescriptor=m_xDatMan->getQueryField();
- aEvent.State <<= pDatMan->getQueryFields();
+ aEvent.State <<= m_xDatMan->getQueryFields();
}
else if ( aURL.Path == "Bib/source")
{
aEvent.IsEnabled = true;
- aEvent.FeatureDescriptor=pDatMan->getActiveDataTable();
+ aEvent.FeatureDescriptor=m_xDatMan->getActiveDataTable();
- aEvent.State <<= pDatMan->getDataSources();
+ aEvent.State <<= m_xDatMan->getDataSources();
}
else if( aURL.Path == "Bib/sdbsource" ||
aURL.Path == "Bib/Mapping" ||
@@ -676,7 +674,7 @@ void BibFrameController_Impl::addStatusListener(
}
else if (aURL.Path == "Bib/removeFilter" )
{
- OUString aFilterStr=pDatMan->getFilter();
+ OUString aFilterStr=m_xDatMan->getFilter();
aEvent.IsEnabled = !aFilterStr.isEmpty();
}
else if(aURL.Path == "Cut")
@@ -734,9 +732,9 @@ void BibFrameController_Impl::addStatusListener(
}
else if(aURL.Path == "Bib/DeleteRecord")
{
- Reference< css::sdbc::XResultSet > xCursor(pDatMan->getForm(), UNO_QUERY);
+ Reference< css::sdbc::XResultSet > xCursor(m_xDatMan->getForm(), UNO_QUERY);
Reference< XResultSetUpdate > xUpdateCursor(xCursor, UNO_QUERY);
- Reference< beans::XPropertySet > xSet(pDatMan->getForm(), UNO_QUERY);
+ Reference< beans::XPropertySet > xSet(m_xDatMan->getForm(), UNO_QUERY);
bool bIsNew = ::comphelper::getBOOL(xSet->getPropertyValue("IsNew"));
if(!bIsNew)
{
@@ -747,7 +745,7 @@ void BibFrameController_Impl::addStatusListener(
}
else if (aURL.Path == "Bib/InsertRecord")
{
- Reference< beans::XPropertySet > xSet(pDatMan->getForm(), UNO_QUERY);
+ Reference< beans::XPropertySet > xSet(m_xDatMan->getForm(), UNO_QUERY);
aEvent.IsEnabled = canInsertRecords(xSet);
}
aListener->statusChanged( aEvent );
@@ -779,7 +777,7 @@ void BibFrameController_Impl::removeStatusListener(
void BibFrameController_Impl::RemoveFilter()
{
OUString aQuery;
- pDatMan->startQueryWith(aQuery);
+ m_xDatMan->startQueryWith(aQuery);
sal_uInt16 nCount = aStatusListeners.size();
@@ -830,15 +828,16 @@ void BibFrameController_Impl::ChangeDataSource(const uno::Sequence< beans::Prope
uno::Any aDB = pPropertyValue[1].Value;
OUString aURL;
aDB >>= aURL;
- pDatMan->setActiveDataSource(aURL);
- aDBTableName = pDatMan->getActiveDataTable();
+ m_xDatMan->setActiveDataSource(aURL);
+ aDBTableName = m_xDatMan->getActiveDataTable();
}
else
{
- m_xDatMan->unload();
- pDatMan->setActiveDataTable(aDBTableName);
- pDatMan->updateGridModel();
- m_xDatMan->load();
+ Reference<css::form::XLoadable> xLoadable(m_xDatMan.get());
+ xLoadable->unload();
+ m_xDatMan->setActiveDataTable(aDBTableName);
+ m_xDatMan->updateGridModel();
+ xLoadable->load();
}
@@ -856,9 +855,9 @@ void BibFrameController_Impl::ChangeDataSource(const uno::Sequence< beans::Prope
aEvent.IsEnabled = true;
aEvent.Requery = false;
aEvent.Source = static_cast<XDispatch *>(this);
- aEvent.FeatureDescriptor=pDatMan->getQueryField();
+ aEvent.FeatureDescriptor=m_xDatMan->getQueryField();
- uno::Sequence<OUString> aStringSeq=pDatMan->getQueryFields();
+ uno::Sequence<OUString> aStringSeq=m_xDatMan->getQueryFields();
aEvent.State = makeAny( aStringSeq );
pObj->xListener->statusChanged( aEvent );
diff --git a/extensions/source/bibliography/framectr.hxx b/extensions/source/bibliography/framectr.hxx
index 6810af9..5a51b04 100644
--- a/extensions/source/bibliography/framectr.hxx
+++ b/extensions/source/bibliography/framectr.hxx
@@ -66,8 +66,7 @@ friend class BibFrameCtrl_Impl;
css::uno::Reference< css::frame::XFrame > xFrame;
bool bDisposing;
bool bHierarchical;
- css::uno::Reference< css::form::XLoadable > m_xDatMan;
- BibDataManager* pDatMan;
+ rtl::Reference<BibDataManager> m_xDatMan;
HdlBibModul pBibMod;
DECL_LINK( DisposeHdl, void*, void );
commit f7db2b5b3ffe7bff84636cdd0017e85a439b8c4f
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Fri Jan 20 12:05:56 2017 +0200
use rtl::Reference in OSelectionChangeListener
instead of manual acquire/release
Change-Id: I33e3018b5deb4240d4aff1d8136ae6f8f538c779
diff --git a/comphelper/source/misc/SelectionMultiplex.cxx b/comphelper/source/misc/SelectionMultiplex.cxx
index f7122d4..15c2c94 100644
--- a/comphelper/source/misc/SelectionMultiplex.cxx
+++ b/comphelper/source/misc/SelectionMultiplex.cxx
@@ -44,19 +44,8 @@ void OSelectionChangeListener::_disposing(const EventObject&)
void OSelectionChangeListener::setAdapter(OSelectionChangeMultiplexer* pAdapter)
{
- if (m_pAdapter)
- {
- ::osl::MutexGuard aGuard(m_rMutex);
- m_pAdapter->release();
- m_pAdapter = nullptr;
- }
-
- if (pAdapter)
- {
- ::osl::MutexGuard aGuard(m_rMutex);
- m_pAdapter = pAdapter;
- m_pAdapter->acquire();
- }
+ ::osl::MutexGuard aGuard(m_rMutex);
+ m_xAdapter = pAdapter;
}
OSelectionChangeMultiplexer::OSelectionChangeMultiplexer(OSelectionChangeListener* _pListener, const Reference< XSelectionSupplier>& _rxSet)
diff --git a/include/comphelper/SelectionMultiplex.hxx b/include/comphelper/SelectionMultiplex.hxx
index c63cd8f..552ce3b 100644
--- a/include/comphelper/SelectionMultiplex.hxx
+++ b/include/comphelper/SelectionMultiplex.hxx
@@ -24,6 +24,7 @@
#include <com/sun/star/view/XSelectionSupplier.hpp>
#include <cppuhelper/implbase.hxx>
#include <comphelper/comphelperdllapi.h>
+#include <rtl/ref.hxx>
//= selection helper classes
@@ -43,12 +44,12 @@ namespace comphelper
{
friend class OSelectionChangeMultiplexer;
- OSelectionChangeMultiplexer* m_pAdapter;
- ::osl::Mutex& m_rMutex;
+ rtl::Reference<OSelectionChangeMultiplexer> m_xAdapter;
+ ::osl::Mutex& m_rMutex;
public:
OSelectionChangeListener(::osl::Mutex& _rMutex)
- : m_pAdapter(nullptr), m_rMutex(_rMutex) { }
+ : m_rMutex(_rMutex) { }
virtual ~OSelectionChangeListener();
/// @throws css::uno::RuntimeException
More information about the Libreoffice-commits
mailing list