diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-04-17 15:19:25 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-04-20 08:02:25 +0200 |
commit | ec7ba61a6164c805f5a71b077715b7e1521a2d62 (patch) | |
tree | 4d4f3fb1ad960465897754601b0842c78db564bf /sw/source/core/view | |
parent | 7d58f26bf4dbeb4e138c2a91f039d8bc7fa00f0c (diff) |
simplify SfxPoolItemArray_Impl (tdf#81765 related)
Since we want to look up items by pointer, just store them in a
std::unordered_set, which allows fast find().
This dramatically simplifies most operations on this data structure.
Fix a dodgy sd test that was relying on items with the same whichid
being in the pool being in a certain order.
Change-Id: I4d79fc718f95e3083a20788be1050fbe9fca7263
Reviewed-on: https://gerrit.libreoffice.org/70881
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/core/view')
-rw-r--r-- | sw/source/core/view/vprint.cxx | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 4cff1e47f00a..8f0600d59a1d 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -632,13 +632,11 @@ void SwViewShell::PrtOle2( SwDoc *pDoc, const SwViewOption *pOpt, const SwPrintD /// Check if the DocNodesArray contains fields. bool SwViewShell::IsAnyFieldInDoc() const { - const SfxPoolItem* pItem; - sal_uInt32 nMaxItems = mxDoc->GetAttrPool().GetItemCount2( RES_TXTATR_FIELD ); - for( sal_uInt32 n = 0; n < nMaxItems; ++n ) + for (const SfxPoolItem* pItem : mxDoc->GetAttrPool().GetItemSurrogates(RES_TXTATR_FIELD)) { - if( nullptr != (pItem = mxDoc->GetAttrPool().GetItem2( RES_TXTATR_FIELD, n ))) + auto pFormatField = dynamic_cast<const SwFormatField*>(pItem); + if(pFormatField) { - const SwFormatField* pFormatField = static_cast<const SwFormatField*>(pItem); const SwTextField* pTextField = pFormatField->GetTextField(); if( pTextField && pTextField->GetTextNode().GetNodes().IsDocNodes() ) { @@ -647,12 +645,11 @@ bool SwViewShell::IsAnyFieldInDoc() const } } - nMaxItems = mxDoc->GetAttrPool().GetItemCount2( RES_TXTATR_INPUTFIELD ); - for( sal_uInt32 n = 0; n < nMaxItems; ++n ) + for (const SfxPoolItem* pItem : mxDoc->GetAttrPool().GetItemSurrogates(RES_TXTATR_INPUTFIELD)) { - if( nullptr != (pItem = mxDoc->GetAttrPool().GetItem2( RES_TXTATR_INPUTFIELD, n ))) + const SwFormatField* pFormatField = dynamic_cast<const SwFormatField*>(pItem); + if(pFormatField) { - const SwFormatField* pFormatField = static_cast<const SwFormatField*>(pItem); const SwTextField* pTextField = pFormatField->GetTextField(); if( pTextField && pTextField->GetTextNode().GetNodes().IsDocNodes() ) { |