summaryrefslogtreecommitdiff
path: root/sw/source/core/txtnode
diff options
context:
space:
mode:
authorMario J. Rugiero <mrugiero@gmail.com>2015-11-10 23:16:03 -0300
committerNoel Grandin <noelgrandin@gmail.com>2015-11-11 06:50:34 +0000
commit2ce9e4be4a438203382cb9cca824ce3e90647f3a (patch)
treee35e8b9401e92515c15a9c4713aa18466260a3a0 /sw/source/core/txtnode
parent591903a1b1b64e68322f7454d3e61b2503028b9a (diff)
Replace several for_each by range based fors and functors by lambdas in sw.
It also corrects one whitespace and an outdated comment. Change-Id: Ife1c45d42b059353d3c98d68518d44a1379a96fa Reviewed-on: https://gerrit.libreoffice.org/19899 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'sw/source/core/txtnode')
-rw-r--r--sw/source/core/txtnode/thints.cxx36
1 files changed, 14 insertions, 22 deletions
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index 63d64f267603..a51afa3c5031 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -96,30 +96,20 @@ SwpHints::SwpHints()
{
}
-struct TextAttrDeleter
+static void TextAttrDelete( SwDoc & rDoc, SwTextAttr * const pAttr )
{
- SwAttrPool & m_rPool;
- explicit TextAttrDeleter( SwDoc & rDoc ) : m_rPool( rDoc.GetAttrPool() ) { }
- void operator() (SwTextAttr * const pAttr)
+ if (RES_TXTATR_META == pAttr->Which() ||
+ RES_TXTATR_METAFIELD == pAttr->Which())
{
- if (RES_TXTATR_META == pAttr->Which() ||
- RES_TXTATR_METAFIELD == pAttr->Which())
- {
- static_txtattr_cast<SwTextMeta *>(pAttr)->ChgTextNode(nullptr); // prevents ASSERT
- }
- SwTextAttr::Destroy( pAttr, m_rPool );
+ static_txtattr_cast<SwTextMeta *>(pAttr)->ChgTextNode(nullptr); // prevents ASSERT
}
-};
+ SwTextAttr::Destroy( pAttr, rDoc.GetAttrPool() );
+}
-struct TextAttrContains
+static bool TextAttrContains(const sal_Int32 nPos, SwTextAttrEnd * const pAttr)
{
- sal_Int32 m_nPos;
- explicit TextAttrContains( const sal_Int32 nPos ) : m_nPos( nPos ) { }
- bool operator() (SwTextAttrEnd * const pAttr)
- {
- return (pAttr->GetStart() < m_nPos) && (m_nPos < *pAttr->End());
- }
-};
+ return (pAttr->GetStart() < nPos) && (nPos < *pAttr->End());
+}
// a: |-----|
// b:
@@ -264,7 +254,9 @@ lcl_DoSplitNew(NestList_t & rSplits, SwTextNode & rNode,
// first find the portion that is split (not necessarily the last one!)
NestList_t::iterator const iter(
::std::find_if( rSplits.begin(), rSplits.end(),
- TextAttrContains(nSplitPos) ) );
+ [nSplitPos](SwTextAttrEnd * const pAttr) {
+ return TextAttrContains(nSplitPos, pAttr);
+ } ) );
if (iter != rSplits.end()) // already split here?
{
const sal_Int32 nStartPos( // skip other's dummy character!
@@ -390,8 +382,8 @@ SwpHints::TryInsertNesting( SwTextNode & rNode, SwTextAttrNesting & rNewHint )
{
case FAIL:
SAL_INFO("sw.core", "cannot insert hint: overlap");
- ::std::for_each(SplitNew.begin(), SplitNew.end(),
- TextAttrDeleter(*rNode.GetDoc()));
+ for (const auto& aSplit : SplitNew)
+ TextAttrDelete(*rNode.GetDoc(), aSplit);
return false;
case SPLIT_NEW:
lcl_DoSplitNew(SplitNew, rNode, nNewStart,