sw/source/core/docnode/nodes.cxx                  |    5 +++--
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   22 +++++-----------------
 2 files changed, 8 insertions(+), 19 deletions(-)

New commits:
commit 77224aaec6ba89194a404805d7190f88e92fcc9f
Author:     Noel Grandin <[email protected]>
AuthorDate: Mon Mar 25 10:41:10 2024 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Mon Mar 25 12:24:24 2024 +0100

    tdf#158556 speedup docx load
    
    move the vector outside the loop, avoid repeated allocations
    
    Change-Id: Ic6ef95a966ffd5c4115ea56e63af1494e7937928
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165270
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index 5f059f94c519..76f9362a1442 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -2320,6 +2320,7 @@ void SwNodes::RemoveNode( SwNodeOffset nDelPos, 
SwNodeOffset nSz, bool bDel )
 #ifndef NDEBUG
     SwNode *const pFirst((*this)[nDelPos]);
 #endif
+    std::vector<SwTextAttr*> flys;
     for (SwNodeOffset nCnt(0); nCnt < nSz; nCnt++)
     {
         SwNode* pNode = (*this)[ nDelPos + nCnt ];
@@ -2332,11 +2333,11 @@ void SwNodes::RemoveNode( SwNodeOffset nDelPos, 
SwNodeOffset nSz, bool bDel )
             // so their anchor still points to correct node when deleted!
             // NOTE: this will call RemoveNode() recursively!
             // so adjust our indexes to account for removed nodes
-            SwNodeOffset const nPos = pTextNd->GetIndex();
             SwpHints *const pHints(pTextNd->GetpSwpHints());
             if (pHints)
             {
-                std::vector<SwTextAttr*> flys;
+                SwNodeOffset const nPos = pTextNd->GetIndex();
+                flys.clear();
                 for (size_t i = 0; i < pHints->Count(); ++i)
                 {
                     SwTextAttr *const pHint(pHints->Get(i));
commit ab29c857c669bcca3d8eea8a5a9e6ad5eae622d7
Author:     Noel Grandin <[email protected]>
AuthorDate: Mon Mar 25 10:39:41 2024 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Mon Mar 25 12:24:17 2024 +0100

    tdf#158556 speedup docx load
    
    If we want to know if an XText is a header/footer object, no need to
    loop over the draw objects, we can just query its service name.
    
    Reduces load time from 167s to 97s
    
    Change-Id: I10158c11dd24c4945b3ea6cfed4916717bd4f2f8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165269
    Tested-by: Noel Grandin <[email protected]>
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index f4943c60c88c..4fdacfb2f944 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -3783,26 +3783,14 @@ void 
DomainMapper_Impl::ConvertHeaderFooterToTextFrame(bool bDynamicHeightTop, b
 namespace
 {
 // Determines if the XText content is empty (no text, no shapes, no tables)
-bool isContentEmpty(uno::Reference<text::XText> const& xText, 
uno::Reference<text::XTextDocument> const& xTextDocument)
+bool isContentEmpty(uno::Reference<text::XText> const& xText)
 {
     if (!xText.is())
         return true; // no XText means it's empty
 
-    uno::Reference<drawing::XDrawPageSupplier> 
xDrawPageSupplier(xTextDocument, uno::UNO_QUERY);
-    auto xDrawPage = xDrawPageSupplier->getDrawPage();
-    if (xDrawPage && xDrawPage->hasElements())
-    {
-        for (sal_Int32 i = 0; i < xDrawPage->getCount(); ++i)
-        {
-            uno::Reference<text::XTextContent> 
xShape(xDrawPage->getByIndex(i), uno::UNO_QUERY);
-            if (xShape.is())
-            {
-                uno::Reference<text::XTextRange> xAnchor = xShape->getAnchor();
-                if (xAnchor.is() && xAnchor->getText() == xText)
-                    return false;
-            }
-        }
-    }
+    uno::Reference<css::lang::XServiceInfo> xTextServiceInfo(xText, 
uno::UNO_QUERY);
+    if (xTextServiceInfo && xTextServiceInfo->getImplementationName() == 
"SwXHeadFootText")
+        return false;
 
     uno::Reference<container::XEnumerationAccess> 
xEnumAccess(xText->getText(), uno::UNO_QUERY);
     uno::Reference<container::XEnumeration> xEnum = 
xEnumAccess->createEnumeration();
@@ -3949,7 +3937,7 @@ void 
DomainMapper_Impl::checkIfHeaderFooterIsEmpty(PagePartType ePagePartType, P
     if (!xPageStyle.is())
         return;
 
-    bool bEmpty = isContentEmpty(m_aTextAppendStack.top().xTextAppend, 
GetTextDocument());
+    bool bEmpty = isContentEmpty(m_aTextAppendStack.top().xTextAppend);
 
     if (eType == PageType::FIRST && bEmpty)
     {

Reply via email to