writerfilter/source/dmapper/DomainMapper_Impl.cxx |   22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

New commits:
commit 6e7906406a8e004774c5baf0f347573aacf63603
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Tue Jul 9 21:38:05 2024 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Wed Jul 10 10:48:09 2024 +0200

    Revert "tdf#158556 speedup docx load"
    
    This reverts commit ab29c857c669bcca3d8eea8a5a9e6ad5eae622d7.
    
    As jluth points out, my logic here is wrong.
    
    Change-Id: I8887526a0a96070ad615aa07ef0e77e36214d0d5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170252
    Reviewed-by: Justin Luth <jl...@mail.com>
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins
    (cherry picked from commit 6f96e7720f765d4e5e8fdef6a2a2b8cbb75c81ef)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170285
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Tested-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index bc1eae82a01e..86c91db63bbd 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -3791,14 +3791,26 @@ 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)
+bool isContentEmpty(uno::Reference<text::XText> const& xText, 
uno::Reference<text::XTextDocument> const& xTextDocument)
 {
     if (!xText.is())
         return true; // no XText means it's empty
 
-    uno::Reference<css::lang::XServiceInfo> xTextServiceInfo(xText, 
uno::UNO_QUERY);
-    if (xTextServiceInfo && xTextServiceInfo->getImplementationName() == 
"SwXHeadFootText")
-        return false;
+    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<container::XEnumerationAccess> 
xEnumAccess(xText->getText(), uno::UNO_QUERY);
     uno::Reference<container::XEnumeration> xEnum = 
xEnumAccess->createEnumeration();
@@ -3945,7 +3957,7 @@ void 
DomainMapper_Impl::checkIfHeaderFooterIsEmpty(PagePartType ePagePartType, P
     if (!xPageStyle.is())
         return;
 
-    bool bEmpty = isContentEmpty(m_aTextAppendStack.top().xTextAppend);
+    bool bEmpty = isContentEmpty(m_aTextAppendStack.top().xTextAppend, 
GetTextDocument());
 
     if (eType == PageType::FIRST && bEmpty)
     {

Reply via email to