[Libreoffice-commits] core.git: sw/source
Bjoern Michaelsen (via logerrit)
logerrit at kemper.freedesktop.org
Sun Mar 15 21:33:24 UTC 2020
sw/source/core/fields/fldlst.cxx | 92 +++++++++++++++------------------------
1 file changed, 36 insertions(+), 56 deletions(-)
New commits:
commit 11cf8e08a1c7647d0f4111c46ae9e2141c26baf4
Author: Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
AuthorDate: Sun Mar 15 14:24:56 2020 +0100
Commit: Björn Michaelsen <bjoern.michaelsen at libreoffice.org>
CommitDate: Sun Mar 15 22:32:50 2020 +0100
fldlst.cxx: SwIterator no more ...
Change-Id: If63de8b981592539112af5f15076d6d5c7122d00
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90523
Tested-by: Jenkins
Reviewed-by: Björn Michaelsen <bjoern.michaelsen at libreoffice.org>
diff --git a/sw/source/core/fields/fldlst.cxx b/sw/source/core/fields/fldlst.cxx
index 15937825fdde..aa937cb22140 100644
--- a/sw/source/core/fields/fldlst.cxx
+++ b/sw/source/core/fields/fldlst.cxx
@@ -43,38 +43,27 @@ SwInputFieldList::SwInputFieldList( SwEditShell* pShell, bool bBuildTmpLst )
const size_t nSize = rFieldTypes.size();
// iterate over all types
- for(size_t i=0; i < nSize; ++i)
+ std::vector<SwFormatField*> vFields;
+ for(size_t i = 0; i < nSize; ++i)
{
SwFieldType* pFieldType = rFieldTypes[ i ].get();
const SwFieldIds nType = pFieldType->Which();
-
- if( SwFieldIds::SetExp == nType || SwFieldIds::Input == nType || SwFieldIds::Dropdown == nType )
+ if(SwFieldIds::SetExp == nType || SwFieldIds::Input == nType || SwFieldIds::Dropdown == nType)
+ pFieldType->GatherFields(vFields);
+ }
+ for(auto pFormatField: vFields)
+ {
+ auto pSetExpField = dynamic_cast<SwSetExpField*>(pFormatField->GetField());
+ if(pSetExpField && !pSetExpField->GetInputFlag())
+ continue;
+ const SwTextField* pTextField = pFormatField->GetTextField();
+ if(bBuildTmpLst)
+ maTmpLst.insert(pTextField);
+ else
{
- SwIterator<SwFormatField,SwFieldType> aIter( *pFieldType );
- for( SwFormatField* pFormatField = aIter.First(); pFormatField; pFormatField = aIter.Next() )
- {
- const SwTextField* pTextField = pFormatField->GetTextField();
-
- // only process InputFields, interactive SetExpFields and DropDown fields
- if( !pTextField || ( SwFieldIds::SetExp == nType &&
- !static_cast<SwSetExpField*>(pFormatField->GetField())->GetInputFlag()))
- continue;
-
- const SwTextNode& rTextNode = pTextField->GetTextNode();
- if( rTextNode.GetNodes().IsDocNodes() )
- {
- if( bBuildTmpLst )
- {
- maTmpLst.insert( pTextField );
- }
- else
- {
- SwNodeIndex aIdx( rTextNode );
- std::unique_ptr<SetGetExpField> pNew(new SetGetExpField(aIdx, pTextField ));
- mpSrtLst->insert( std::move(pNew) );
- }
- }
- }
+ SwNodeIndex aIdx(pTextField->GetTextNode());
+ std::unique_ptr<SetGetExpField> pNew(new SetGetExpField(aIdx, pTextField));
+ mpSrtLst->insert(std::move(pNew));
}
}
}
@@ -130,39 +119,30 @@ bool SwInputFieldList::BuildSortLst()
const size_t nSize = rFieldTypes.size();
// iterate over all types
- for( size_t i = 0; i < nSize; ++i )
+ std::vector<SwFormatField*> vFields;
+ for(size_t i = 0; i < nSize; ++i)
{
SwFieldType* pFieldType = rFieldTypes[ i ].get();
const SwFieldIds nType = pFieldType->Which();
-
- if( SwFieldIds::SetExp == nType || SwFieldIds::Input == nType )
+ if(SwFieldIds::SetExp == nType || SwFieldIds::Input == nType)
+ pFieldType->GatherFields(vFields);
+ }
+ for(auto pFormatField: vFields)
+ {
+ auto pSetExpField = dynamic_cast<SwSetExpField*>(pFormatField->GetField());
+ if(pSetExpField && !pSetExpField->GetInputFlag())
+ continue;
+ const SwTextField* pTextField = pFormatField->GetTextField();
+ // not in TempList, thus add to SortList
+ auto it = maTmpLst.find(pTextField);
+ if(maTmpLst.end() == it)
{
- SwIterator<SwFormatField,SwFieldType> aIter( *pFieldType );
- for( SwFormatField* pFormatField = aIter.First(); pFormatField; pFormatField = aIter.Next() )
- {
- const SwTextField* pTextField = pFormatField->GetTextField();
-
- // process only InputFields and interactive SetExpFields
- if( !pTextField || ( SwFieldIds::SetExp == nType &&
- !static_cast<SwSetExpField*>(pFormatField->GetField())->GetInputFlag()))
- continue;
-
- const SwTextNode& rTextNode = pTextField->GetTextNode();
- if( rTextNode.GetNodes().IsDocNodes() )
- {
- // not in TempList, thus add to SortList
- auto it = maTmpLst.find( pTextField );
- if( maTmpLst.end() == it )
- {
- SwNodeIndex aIdx( rTextNode );
- std::unique_ptr<SetGetExpField> pNew(new SetGetExpField(aIdx, pTextField ));
- mpSrtLst->insert( std::move(pNew) );
- }
- else
- maTmpLst.erase( it );
- }
- }
+ SwNodeIndex aIdx(pTextField->GetTextNode());
+ std::unique_ptr<SetGetExpField> pNew(new SetGetExpField(aIdx, pTextField ));
+ mpSrtLst->insert(std::move(pNew));
}
+ else
+ maTmpLst.erase(it);
}
// the pointers are not needed anymore
More information about the Libreoffice-commits
mailing list