Kaydet (Commit) 7d8b0325 authored tarafından Takeshi Abe's avatar Takeshi Abe Kaydeden (comit) David Tardon

dbaccess: simplify code by using std::any_of/std::none_of

Change-Id: I03ed512ba20206ed38428efe324f54f79abe1933
Reviewed-on: https://gerrit.libreoffice.org/15616Tested-by: 's avatarJenkins <ci@libreoffice.org>
Tested-by: 's avatarDavid Tardon <dtardon@redhat.com>
Reviewed-by: 's avatarDavid Tardon <dtardon@redhat.com>
üst f1097c86
...@@ -2412,7 +2412,7 @@ sal_Int8 OApplicationController::queryDrop( const AcceptDropEvent& _rEvt, const ...@@ -2412,7 +2412,7 @@ sal_Int8 OApplicationController::queryDrop( const AcceptDropEvent& _rEvt, const
if ( eType != E_NONE && (eType != E_TABLE || !isConnectionReadOnly()) ) if ( eType != E_NONE && (eType != E_TABLE || !isConnectionReadOnly()) )
{ {
// check for the concrete type // check for the concrete type
if(::std::find_if(_rFlavors.begin(),_rFlavors.end(),TAppSupportedSotFunctor(eType,true)) != _rFlavors.end()) if(::std::any_of(_rFlavors.begin(),_rFlavors.end(),TAppSupportedSotFunctor(eType,true)))
return DND_ACTION_COPY; return DND_ACTION_COPY;
if ( eType == E_FORM || eType == E_REPORT ) if ( eType == E_FORM || eType == E_REPORT )
{ {
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <osl/diagnose.h> #include <osl/diagnose.h>
#include "svtools/treelistentry.hxx" #include "svtools/treelistentry.hxx"
#include <algorithm>
#include <functional> #include <functional>
namespace dbaui namespace dbaui
{ {
...@@ -107,7 +108,7 @@ namespace dbaui ...@@ -107,7 +108,7 @@ namespace dbaui
Reference<XStorable> xStore; Reference<XStorable> xStore;
xStore = Reference<XStorable>( xChild.is() ? getDataSourceOrModel(xChild->getParent()) : Reference<XInterface>(),UNO_QUERY ); xStore = Reference<XStorable>( xChild.is() ? getDataSourceOrModel(xChild->getParent()) : Reference<XInterface>(),UNO_QUERY );
// check for the concrete type // check for the concrete type
if ( xStore.is() && !xStore->isReadonly() && ::std::find_if(_rFlavors.begin(),_rFlavors.end(),TAppSupportedSotFunctor(E_TABLE,true)) != _rFlavors.end()) if ( xStore.is() && !xStore->isReadonly() && ::std::any_of(_rFlavors.begin(),_rFlavors.end(),TAppSupportedSotFunctor(E_TABLE,true)) )
return DND_ACTION_COPY; return DND_ACTION_COPY;
} }
} }
......
...@@ -81,6 +81,7 @@ ...@@ -81,6 +81,7 @@
#include "UITools.hxx" #include "UITools.hxx"
#include "TokenWriter.hxx" #include "TokenWriter.hxx"
#include <osl/diagnose.h> #include <osl/diagnose.h>
#include <algorithm>
using namespace ::com::sun::star::ui::dialogs; using namespace ::com::sun::star::ui::dialogs;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
...@@ -1355,7 +1356,7 @@ sal_Int8 SbaGridControl::AcceptDrop( const BrowserAcceptDropEvent& rEvt ) ...@@ -1355,7 +1356,7 @@ sal_Int8 SbaGridControl::AcceptDrop( const BrowserAcceptDropEvent& rEvt )
if(nAction != DND_ACTION_COPY && GetEmptyRow().Is()) if(nAction != DND_ACTION_COPY && GetEmptyRow().Is())
{ {
const DataFlavorExVector& _rFlavors = GetDataFlavors(); const DataFlavorExVector& _rFlavors = GetDataFlavors();
if(::std::find_if(_rFlavors.begin(),_rFlavors.end(),SbaGridControlPrec(true)) != _rFlavors.end()) if(::std::any_of(_rFlavors.begin(),_rFlavors.end(),SbaGridControlPrec(true)))
nAction = DND_ACTION_COPY; nAction = DND_ACTION_COPY;
} }
...@@ -1416,8 +1417,7 @@ sal_Int8 SbaGridControl::ExecuteDrop( const BrowserExecuteDropEvent& rEvt ) ...@@ -1416,8 +1417,7 @@ sal_Int8 SbaGridControl::ExecuteDrop( const BrowserExecuteDropEvent& rEvt )
if(GetEmptyRow().Is()) if(GetEmptyRow().Is())
{ {
const DataFlavorExVector& _rFlavors = GetDataFlavors(); const DataFlavorExVector& _rFlavors = GetDataFlavors();
DataFlavorExVector::const_iterator aFind = ::std::find_if(_rFlavors.begin(),_rFlavors.end(),SbaGridControlPrec(true)); if( ::std::any_of(_rFlavors.begin(),_rFlavors.end(),SbaGridControlPrec(true)) )
if( aFind != _rFlavors.end())
{ {
TransferableDataHelper aDropped( rEvt.maDropEvent.Transferable ); TransferableDataHelper aDropped( rEvt.maDropEvent.Transferable );
m_aDataDescriptor = ODataAccessObjectTransferable::extractObjectDescriptor(aDropped); m_aDataDescriptor = ODataAccessObjectTransferable::extractObjectDescriptor(aDropped);
......
...@@ -199,7 +199,7 @@ namespace ...@@ -199,7 +199,7 @@ namespace
aRet.first = lhs; aRet.first = lhs;
const OUString* pIter = m_aViews.getConstArray(); const OUString* pIter = m_aViews.getConstArray();
const OUString* pEnd = m_aViews.getConstArray() + m_aViews.getLength(); const OUString* pEnd = m_aViews.getConstArray() + m_aViews.getLength();
aRet.second = (::std::find_if(pIter,pEnd,::std::bind2nd(m_aEqualFunctor,lhs)) != pEnd); aRet.second = ::std::any_of(pIter,pEnd,::std::bind2nd(m_aEqualFunctor,lhs));
return aRet; return aRet;
} }
...@@ -260,14 +260,11 @@ void OTableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConn ...@@ -260,14 +260,11 @@ void OTableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConn
if (haveVirtualRoot()) if (haveVirtualRoot())
{ {
OUString sRootEntryText; OUString sRootEntryText;
TNames::const_iterator aViews = ::std::find_if(_rTables.begin(),_rTables.end(), if ( ::std::none_of(_rTables.begin(),_rTables.end(),
::o3tl::compose1(::std::bind2nd(::std::equal_to<sal_Bool>(),sal_False),::o3tl::select2nd<TNames::value_type>())); ::o3tl::compose1(::std::bind2nd(::std::equal_to<sal_Bool>(),sal_False),::o3tl::select2nd<TNames::value_type>())) )
TNames::const_iterator aTables = ::std::find_if(_rTables.begin(),_rTables.end(),
::o3tl::compose1(::std::bind2nd(::std::equal_to<sal_Bool>(),sal_True),::o3tl::select2nd<TNames::value_type>()));
if ( aViews == _rTables.end() )
sRootEntryText = ModuleRes(STR_ALL_TABLES); sRootEntryText = ModuleRes(STR_ALL_TABLES);
else if ( aTables == _rTables.end() ) else if ( ::std::none_of(_rTables.begin(),_rTables.end(),
::o3tl::compose1(::std::bind2nd(::std::equal_to<sal_Bool>(),sal_True),::o3tl::select2nd<TNames::value_type>())) )
sRootEntryText = ModuleRes(STR_ALL_VIEWS); sRootEntryText = ModuleRes(STR_ALL_VIEWS);
else else
sRootEntryText = ModuleRes(STR_ALL_TABLES_AND_VIEWS); sRootEntryText = ModuleRes(STR_ALL_TABLES_AND_VIEWS);
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <vcl/lstbox.hxx> #include <vcl/lstbox.hxx>
#include <functional> #include <functional>
#include <map> #include <map>
#include <algorithm>
namespace dbaui namespace dbaui
{ {
...@@ -87,8 +88,8 @@ namespace dbaui ...@@ -87,8 +88,8 @@ namespace dbaui
bool operator()(const OUString& _sColumnName) const SAL_OVERRIDE bool operator()(const OUString& _sColumnName) const SAL_OVERRIDE
{ {
return ::std::find_if(m_pVector->begin(),m_pVector->end(), return ::std::any_of(m_pVector->begin(),m_pVector->end(),
::std::bind2nd(m_aCase, _sColumnName)) != m_pVector->end(); ::std::bind2nd(m_aCase, _sColumnName));
} }
}; };
......
...@@ -151,10 +151,9 @@ namespace dbaui ...@@ -151,10 +151,9 @@ namespace dbaui
bool OTableConnection::CheckHit( const Point& rMousePos ) const bool OTableConnection::CheckHit( const Point& rMousePos ) const
{ {
// check if the point hit our line // check if the point hit our line
::std::vector<OConnectionLine*>::const_iterator aIter = ::std::find_if(m_vConnLine.begin(), return ::std::any_of(m_vConnLine.begin(),
m_vConnLine.end(), m_vConnLine.end(),
::std::bind2nd(TConnectionLineCheckHitFunctor(),rMousePos)); ::std::bind2nd(TConnectionLineCheckHitFunctor(),rMousePos));
return aIter != m_vConnLine.end();
} }
bool OTableConnection::InvalidateConnection() bool OTableConnection::InvalidateConnection()
......
...@@ -197,18 +197,16 @@ FeatureState OTableController::GetState(sal_uInt16 _nId) const ...@@ -197,18 +197,16 @@ FeatureState OTableController::GetState(sal_uInt16 _nId) const
aReturn.bEnabled = impl_isModified(); aReturn.bEnabled = impl_isModified();
if ( aReturn.bEnabled ) if ( aReturn.bEnabled )
{ {
::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = ::std::find_if(m_vRowList.begin(),m_vRowList.end(), aReturn.bEnabled = ::std::any_of(m_vRowList.begin(),m_vRowList.end(),
::boost::mem_fn(&OTableRow::isValid)); ::boost::mem_fn(&OTableRow::isValid));
aReturn.bEnabled = aIter != m_vRowList.end();
} }
break; break;
case ID_BROWSER_SAVEASDOC: case ID_BROWSER_SAVEASDOC:
aReturn.bEnabled = isConnected() && isEditable(); aReturn.bEnabled = isConnected() && isEditable();
if ( aReturn.bEnabled ) if ( aReturn.bEnabled )
{ {
::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = ::std::find_if(m_vRowList.begin(),m_vRowList.end(), aReturn.bEnabled = ::std::any_of(m_vRowList.begin(),m_vRowList.end(),
::boost::mem_fn(&OTableRow::isValid)); ::boost::mem_fn(&OTableRow::isValid));
aReturn.bEnabled = aIter != m_vRowList.end();
} }
break; break;
...@@ -230,9 +228,8 @@ FeatureState OTableController::GetState(sal_uInt16 _nId) const ...@@ -230,9 +228,8 @@ FeatureState OTableController::GetState(sal_uInt16 _nId) const
); );
if ( aReturn.bEnabled ) if ( aReturn.bEnabled )
{ {
::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = ::std::find_if(m_vRowList.begin(),m_vRowList.end(), aReturn.bEnabled = ::std::any_of(m_vRowList.begin(),m_vRowList.end(),
::boost::mem_fn(&OTableRow::isValid)); ::boost::mem_fn(&OTableRow::isValid));
aReturn.bEnabled = aIter != m_vRowList.end();
} }
break; break;
default: default:
...@@ -559,9 +556,8 @@ sal_Bool SAL_CALL OTableController::suspend(sal_Bool /*_bSuspend*/) throw( Runti ...@@ -559,9 +556,8 @@ sal_Bool SAL_CALL OTableController::suspend(sal_Bool /*_bSuspend*/) throw( Runti
bool bCheck = true; bool bCheck = true;
if ( isModified() ) if ( isModified() )
{ {
::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = ::std::find_if(m_vRowList.begin(),m_vRowList.end(), if ( ::std::any_of(m_vRowList.begin(),m_vRowList.end(),
::boost::mem_fn(&OTableRow::isValid)); ::boost::mem_fn(&OTableRow::isValid)) )
if ( aIter != m_vRowList.end() )
{ {
ScopedVclPtrInstance<MessageDialog> aQry(getView(), "TableDesignSaveModifiedDialog", ScopedVclPtrInstance<MessageDialog> aQry(getView(), "TableDesignSaveModifiedDialog",
"dbaccess/ui/tabledesignsavemodifieddialog.ui"); "dbaccess/ui/tabledesignsavemodifieddialog.ui");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment