diff options
author | Michael Stahl <mstahl@redhat.com> | 2016-06-16 22:04:26 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2016-06-17 18:40:22 +0000 |
commit | 8389616baa8c03f878be5dfeb0a9f2db546bb66f (patch) | |
tree | c530c40b713649e247ff977f03d1d4de5c0b8bae /sw/source/core | |
parent | 6a10ad7145c0d77a8e9cf2481f2527a5c4d32173 (diff) |
sw: speed up the navigator
The call to SwTextBoxHelper::findTextBoxes() in SwDoc::GetFlyNum() made
this so unbelievably slow that in a dbgutil build opening the navigator
on the bugdoc of tdf#94212 the UI freezes because getting all the fly
frames takes longer than the 1 second timeout.
Lets's not retrieve the flys one by one but instead all at once, which
makes it usable again.
Change-Id: Ic41c1648a82dcc3f758ae1b08bac6058f541f25e
(cherry picked from commit 5593d9e1422cbf8a122fa612713a832274d30559)
Reviewed-on: https://gerrit.libreoffice.org/26425
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'sw/source/core')
-rw-r--r-- | sw/source/core/doc/docfly.cxx | 54 | ||||
-rw-r--r-- | sw/source/core/frmedt/feshview.cxx | 6 |
2 files changed, 60 insertions, 0 deletions
diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index e749759f6286..e1291b6673ba 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -171,6 +171,60 @@ SwFrameFormat* SwDoc::GetFlyNum( size_t nIdx, FlyCntType eType, bool bIgnoreText return pRetFormat; } +std::vector<SwFrameFormat const*> SwDoc::GetFlyFrameFormats( + FlyCntType const eType, bool const bIgnoreTextBoxes) +{ + SwFrameFormats& rFormats = *GetSpzFrameFormats(); + const size_t nSize = rFormats.size(); + + std::set<const SwFrameFormat*> aTextBoxes; + if (bIgnoreTextBoxes) + aTextBoxes = SwTextBoxHelper::findTextBoxes(this); + + std::vector<SwFrameFormat const*> ret; + ret.reserve(nSize); + + for (size_t i = 0; i < nSize; ++i) + { + SwFrameFormat const*const pFlyFormat = rFormats[ i ]; + + if (bIgnoreTextBoxes && aTextBoxes.find(pFlyFormat) != aTextBoxes.end()) + { + continue; + } + + if (RES_FLYFRMFMT != pFlyFormat->Which()) + { + continue; + } + + SwNodeIndex const*const pIdx(pFlyFormat->GetContent().GetContentIdx()); + if (pIdx && pIdx->GetNodes().IsDocNodes()) + { + SwNode const*const pNd = GetNodes()[ pIdx->GetIndex() + 1 ]; + switch (eType) + { + case FLYCNTTYPE_FRM: + if (!pNd->IsNoTextNode()) + ret.push_back(pFlyFormat); + break; + case FLYCNTTYPE_GRF: + if (pNd->IsGrfNode()) + ret.push_back(pFlyFormat); + break; + case FLYCNTTYPE_OLE: + if (pNd->IsOLENode()) + ret.push_back(pFlyFormat); + break; + default: + ret.push_back(pFlyFormat); + } + } + } + + return ret; +} + static Point lcl_FindAnchorLayPos( SwDoc& rDoc, const SwFormatAnchor& rAnch, const SwFrameFormat* pFlyFormat ) { diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index c921e7fd8fc5..6c8f7c158155 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -2332,6 +2332,12 @@ const SwFrameFormat* SwFEShell::GetFlyNum(size_t nIdx, FlyCntType eType, bool b return GetDoc()->GetFlyNum(nIdx, eType, bIgnoreTextBoxes); } +std::vector<SwFrameFormat const*> SwFEShell::GetFlyFrameFormats( + FlyCntType const eType, bool const bIgnoreTextBoxes) +{ + return GetDoc()->GetFlyFrameFormats(eType, bIgnoreTextBoxes); +} + // show the current selected object void SwFEShell::MakeSelVisible() { |