[Libreoffice-commits] core.git: dbaccess/source
Takeshi Abe
tabe at fixedpoint.jp
Wed May 6 07:41:51 PDT 2015
dbaccess/source/ui/app/AppController.cxx | 2 +-
dbaccess/source/ui/browser/dsbrowserDnD.cxx | 3 ++-
dbaccess/source/ui/browser/sbagrid.cxx | 6 +++---
dbaccess/source/ui/control/tabletree.cxx | 13 +++++--------
dbaccess/source/ui/inc/WCopyTable.hxx | 5 +++--
dbaccess/source/ui/querydesign/TableConnection.cxx | 7 +++----
dbaccess/source/ui/tabledesign/TableController.cxx | 20 ++++++++------------
7 files changed, 25 insertions(+), 31 deletions(-)
New commits:
commit 7d8b03256e851f2436c05a56df5f3f61c957ff70
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date: Mon May 4 10:47:12 2015 +0900
dbaccess: simplify code by using std::any_of/std::none_of
Change-Id: I03ed512ba20206ed38428efe324f54f79abe1933
Reviewed-on: https://gerrit.libreoffice.org/15616
Tested-by: Jenkins <ci at libreoffice.org>
Tested-by: David Tardon <dtardon at redhat.com>
Reviewed-by: David Tardon <dtardon at redhat.com>
diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx
index ea2a6e7..c07b651 100644
--- a/dbaccess/source/ui/app/AppController.cxx
+++ b/dbaccess/source/ui/app/AppController.cxx
@@ -2412,7 +2412,7 @@ sal_Int8 OApplicationController::queryDrop( const AcceptDropEvent& _rEvt, const
if ( eType != E_NONE && (eType != E_TABLE || !isConnectionReadOnly()) )
{
// 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;
if ( eType == E_FORM || eType == E_REPORT )
{
diff --git a/dbaccess/source/ui/browser/dsbrowserDnD.cxx b/dbaccess/source/ui/browser/dsbrowserDnD.cxx
index 53bd5b4..5aadaaf 100644
--- a/dbaccess/source/ui/browser/dsbrowserDnD.cxx
+++ b/dbaccess/source/ui/browser/dsbrowserDnD.cxx
@@ -39,6 +39,7 @@
#include <osl/diagnose.h>
#include "svtools/treelistentry.hxx"
+#include <algorithm>
#include <functional>
namespace dbaui
{
@@ -107,7 +108,7 @@ namespace dbaui
Reference<XStorable> xStore;
xStore = Reference<XStorable>( xChild.is() ? getDataSourceOrModel(xChild->getParent()) : Reference<XInterface>(),UNO_QUERY );
// 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;
}
}
diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx
index e8c728f..17b4592 100644
--- a/dbaccess/source/ui/browser/sbagrid.cxx
+++ b/dbaccess/source/ui/browser/sbagrid.cxx
@@ -81,6 +81,7 @@
#include "UITools.hxx"
#include "TokenWriter.hxx"
#include <osl/diagnose.h>
+#include <algorithm>
using namespace ::com::sun::star::ui::dialogs;
using namespace ::com::sun::star::uno;
@@ -1355,7 +1356,7 @@ sal_Int8 SbaGridControl::AcceptDrop( const BrowserAcceptDropEvent& rEvt )
if(nAction != DND_ACTION_COPY && GetEmptyRow().Is())
{
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;
}
@@ -1416,8 +1417,7 @@ sal_Int8 SbaGridControl::ExecuteDrop( const BrowserExecuteDropEvent& rEvt )
if(GetEmptyRow().Is())
{
const DataFlavorExVector& _rFlavors = GetDataFlavors();
- DataFlavorExVector::const_iterator aFind = ::std::find_if(_rFlavors.begin(),_rFlavors.end(),SbaGridControlPrec(true));
- if( aFind != _rFlavors.end())
+ if( ::std::any_of(_rFlavors.begin(),_rFlavors.end(),SbaGridControlPrec(true)) )
{
TransferableDataHelper aDropped( rEvt.maDropEvent.Transferable );
m_aDataDescriptor = ODataAccessObjectTransferable::extractObjectDescriptor(aDropped);
diff --git a/dbaccess/source/ui/control/tabletree.cxx b/dbaccess/source/ui/control/tabletree.cxx
index 6db98c9..1d0eddb 100644
--- a/dbaccess/source/ui/control/tabletree.cxx
+++ b/dbaccess/source/ui/control/tabletree.cxx
@@ -199,7 +199,7 @@ namespace
aRet.first = lhs;
const OUString* pIter = m_aViews.getConstArray();
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;
}
@@ -260,14 +260,11 @@ void OTableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConn
if (haveVirtualRoot())
{
OUString sRootEntryText;
- TNames::const_iterator aViews = ::std::find_if(_rTables.begin(),_rTables.end(),
- ::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() )
+ if ( ::std::none_of(_rTables.begin(),_rTables.end(),
+ ::o3tl::compose1(::std::bind2nd(::std::equal_to<sal_Bool>(),sal_False),::o3tl::select2nd<TNames::value_type>())) )
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);
else
sRootEntryText = ModuleRes(STR_ALL_TABLES_AND_VIEWS);
diff --git a/dbaccess/source/ui/inc/WCopyTable.hxx b/dbaccess/source/ui/inc/WCopyTable.hxx
index dfdaa60..6ce0038 100644
--- a/dbaccess/source/ui/inc/WCopyTable.hxx
+++ b/dbaccess/source/ui/inc/WCopyTable.hxx
@@ -40,6 +40,7 @@
#include <vcl/lstbox.hxx>
#include <functional>
#include <map>
+#include <algorithm>
namespace dbaui
{
@@ -87,8 +88,8 @@ namespace dbaui
bool operator()(const OUString& _sColumnName) const SAL_OVERRIDE
{
- return ::std::find_if(m_pVector->begin(),m_pVector->end(),
- ::std::bind2nd(m_aCase, _sColumnName)) != m_pVector->end();
+ return ::std::any_of(m_pVector->begin(),m_pVector->end(),
+ ::std::bind2nd(m_aCase, _sColumnName));
}
};
diff --git a/dbaccess/source/ui/querydesign/TableConnection.cxx b/dbaccess/source/ui/querydesign/TableConnection.cxx
index 457a584..b0967c4 100644
--- a/dbaccess/source/ui/querydesign/TableConnection.cxx
+++ b/dbaccess/source/ui/querydesign/TableConnection.cxx
@@ -151,10 +151,9 @@ namespace dbaui
bool OTableConnection::CheckHit( const Point& rMousePos ) const
{
// check if the point hit our line
- ::std::vector<OConnectionLine*>::const_iterator aIter = ::std::find_if(m_vConnLine.begin(),
- m_vConnLine.end(),
- ::std::bind2nd(TConnectionLineCheckHitFunctor(),rMousePos));
- return aIter != m_vConnLine.end();
+ return ::std::any_of(m_vConnLine.begin(),
+ m_vConnLine.end(),
+ ::std::bind2nd(TConnectionLineCheckHitFunctor(),rMousePos));
}
bool OTableConnection::InvalidateConnection()
diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx
index bb7df8c..8c7bb1f 100644
--- a/dbaccess/source/ui/tabledesign/TableController.cxx
+++ b/dbaccess/source/ui/tabledesign/TableController.cxx
@@ -197,18 +197,16 @@ FeatureState OTableController::GetState(sal_uInt16 _nId) const
aReturn.bEnabled = impl_isModified();
if ( aReturn.bEnabled )
{
- ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = ::std::find_if(m_vRowList.begin(),m_vRowList.end(),
- ::boost::mem_fn(&OTableRow::isValid));
- aReturn.bEnabled = aIter != m_vRowList.end();
+ aReturn.bEnabled = ::std::any_of(m_vRowList.begin(),m_vRowList.end(),
+ ::boost::mem_fn(&OTableRow::isValid));
}
break;
case ID_BROWSER_SAVEASDOC:
aReturn.bEnabled = isConnected() && isEditable();
if ( aReturn.bEnabled )
{
- ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = ::std::find_if(m_vRowList.begin(),m_vRowList.end(),
- ::boost::mem_fn(&OTableRow::isValid));
- aReturn.bEnabled = aIter != m_vRowList.end();
+ aReturn.bEnabled = ::std::any_of(m_vRowList.begin(),m_vRowList.end(),
+ ::boost::mem_fn(&OTableRow::isValid));
}
break;
@@ -230,9 +228,8 @@ FeatureState OTableController::GetState(sal_uInt16 _nId) const
);
if ( aReturn.bEnabled )
{
- ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = ::std::find_if(m_vRowList.begin(),m_vRowList.end(),
- ::boost::mem_fn(&OTableRow::isValid));
- aReturn.bEnabled = aIter != m_vRowList.end();
+ aReturn.bEnabled = ::std::any_of(m_vRowList.begin(),m_vRowList.end(),
+ ::boost::mem_fn(&OTableRow::isValid));
}
break;
default:
@@ -559,9 +556,8 @@ sal_Bool SAL_CALL OTableController::suspend(sal_Bool /*_bSuspend*/) throw( Runti
bool bCheck = true;
if ( isModified() )
{
- ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = ::std::find_if(m_vRowList.begin(),m_vRowList.end(),
- ::boost::mem_fn(&OTableRow::isValid));
- if ( aIter != m_vRowList.end() )
+ if ( ::std::any_of(m_vRowList.begin(),m_vRowList.end(),
+ ::boost::mem_fn(&OTableRow::isValid)) )
{
ScopedVclPtrInstance<MessageDialog> aQry(getView(), "TableDesignSaveModifiedDialog",
"dbaccess/ui/tabledesignsavemodifieddialog.ui");
More information about the Libreoffice-commits
mailing list