tdf#158556 speedup docx load

Avoid O(n^2) loop in SwXFrame::setPropertyValue, we even have an index
to search for this stuff

Reduces load time from 325s to 172s

Change-Id: I6c6c03206ef81be1d7d7702a4313acd23d75442d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165044
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
(cherry picked from commit 241e2d68664e0e53cf02fe9986462c4a9ecd8d42)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165110
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index ea95cef..99cb33c 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -838,6 +838,7 @@ public:
    std::vector<SwFrameFormat const*> GetFlyFrameFormats(
            FlyCntType eType,
            bool bIgnoreTextBoxes);
    SwFrameFormat* GetFlyFrameFormatByName( const OUString& sFrameFormatName );

    // Copy formats in own arrays and return them.
    SwFrameFormat  *CopyFrameFormat ( const SwFrameFormat& );
diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx
index c492212..2038941 100644
--- a/sw/source/core/doc/docfly.cxx
+++ b/sw/source/core/doc/docfly.cxx
@@ -149,6 +149,25 @@ SwFrameFormat* SwDoc::GetFlyNum( size_t nIdx, FlyCntType eType, bool bIgnoreText
    return pRetFormat;
}

SwFrameFormat* SwDoc::GetFlyFrameFormatByName( const OUString& rFrameFormatName )
{
    auto pFrameFormats = GetSpzFrameFormats();
    auto it = pFrameFormats->findByTypeAndName( RES_FLYFRMFMT, rFrameFormatName );
    auto endIt = pFrameFormats->typeAndNameEnd();
    for ( ; it != endIt; ++it)
    {
        sw::SpzFrameFormat* pFlyFormat = *it;
        const SwNodeIndex* pIdx = pFlyFormat->GetContent().GetContentIdx();
        if( !pIdx || !pIdx->GetNodes().IsDocNodes() )
            continue;

        const SwNode* pNd = GetNodes()[ pIdx->GetIndex() + 1 ];
        if( !pNd->IsNoTextNode())
            return pFlyFormat;
    }
    return nullptr;
}

std::vector<SwFrameFormat const*> SwDoc::GetFlyFrameFormats(
    FlyCntType const eType, bool const bIgnoreTextBoxes)
{
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 7880a74..62c4c76 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -1713,18 +1713,7 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any&
            }
            else
            {
                const size_t nCount = pDoc->GetFlyCount(FLYCNTTYPE_FRM);

                SwFrameFormat* pChain = nullptr;
                for( size_t i = 0; i < nCount; ++i )
                {
                    SwFrameFormat* pFormat2 = pDoc->GetFlyNum(i, FLYCNTTYPE_FRM);
                    if(sChainName == pFormat2->GetName() )
                    {
                        pChain = pFormat2;
                        break;
                    }
                }
                SwFrameFormat* pChain = pDoc->GetFlyFrameFormatByName(sChainName);
                if(pChain)
                {
                    SwFrameFormat* pSource = bNextFrame ? pFormat : pChain;