sw/inc/doc.hxx                     |    3 ++
 sw/inc/fesh.hxx                    |    3 ++
 sw/source/core/doc/docfly.cxx      |   54 +++++++++++++++++++++++++++++++++++++
 sw/source/core/frmedt/feshview.cxx |    6 ++++
 sw/source/uibase/utlui/content.cxx |    9 +++---
 5 files changed, 71 insertions(+), 4 deletions(-)

New commits:
commit 459e240eb4d64bd005e7afd84f3c4cfcf9460582
Author: Michael Stahl <mst...@redhat.com>
Date:   Thu Jun 16 22:04:26 2016 +0200

    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/26428
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Tested-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 44d8f1e..9bcae12 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -858,6 +858,9 @@ public:
     Iterate over Flys - for Basic-Collections. */
     size_t GetFlyCount( FlyCntType eType = FLYCNTTYPE_ALL, bool 
bIgnoreTextBoxes = false ) const;
     SwFrameFormat* GetFlyNum(size_t nIdx, FlyCntType eType = FLYCNTTYPE_ALL, 
bool bIgnoreTextBoxes = false );
+    std::vector<SwFrameFormat const*> GetFlyFrameFormats(
+            FlyCntType eType = FLYCNTTYPE_ALL,
+            bool bIgnoreTextBoxes = false);
 
     // Copy formats in own arrays and return them.
     SwFrameFormat  *CopyFrameFormat ( const SwFrameFormat& );
diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx
index 19d2f7c..16e7594 100644
--- a/sw/inc/fesh.hxx
+++ b/sw/inc/fesh.hxx
@@ -418,6 +418,9 @@ public:
     size_t GetFlyCount( FlyCntType eType = FLYCNTTYPE_ALL, bool 
bIgnoreTextBoxes = false ) const;
     const SwFrameFormat* GetFlyNum(size_t nIdx, FlyCntType eType = 
FLYCNTTYPE_ALL, bool bIgnoreTextBoxes = false) const;
 
+    std::vector<SwFrameFormat const*> GetFlyFrameFormats(
+            FlyCntType eType = FLYCNTTYPE_ALL, bool bIgnoreTextBoxes = false);
+
     /// If a fly is selected, it draws cursor into the first ContentFrame.
     const SwFrameFormat* SelFlyGrabCursor();
 
diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx
index c2ae5a0..517933b 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 6e2917e..2dbe0e3f 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -2333,6 +2333,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()
 {
diff --git a/sw/source/uibase/utlui/content.cxx 
b/sw/source/uibase/utlui/content.cxx
index 3feb1f9..dc3c671 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -563,13 +563,14 @@ void    SwContentType::FillMemberList(bool* 
pbLevelOrVisibilityChanged)
                 eType = FLYCNTTYPE_OLE;
             else if(nContentType == ContentTypeId::GRAPHIC)
                 eType = FLYCNTTYPE_GRF;
-            OSL_ENSURE(nMemberCount ==  pWrtShell->GetFlyCount(eType, 
/*bIgnoreTextBoxes=*/true),
-                    "MemberCount differs");
             Point aNullPt;
             nMemberCount = pWrtShell->GetFlyCount(eType, 
/*bIgnoreTextBoxes=*/true);
-            for(size_t i = 0; i < nMemberCount; ++i)
+            std::vector<SwFrameFormat const*> 
formats(pWrtShell->GetFlyFrameFormats(eType, /*bIgnoreTextBoxes=*/true));
+            SAL_WARN_IF(nMemberCount != formats.size(), "sw.ui", "MemberCount 
differs");
+            nMemberCount = formats.size();
+            for (size_t i = 0; i < nMemberCount; ++i)
             {
-                const SwFrameFormat* pFrameFormat = 
pWrtShell->GetFlyNum(i,eType,/*bIgnoreTextBoxes=*/true);
+                SwFrameFormat const*const pFrameFormat = formats[i];
                 const OUString sFrameName = pFrameFormat->GetName();
 
                 SwContent* pCnt;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to