sw/qa/extras/layout/data/tdf166210.fodt |   22 ++++++++++++++++++++
 sw/qa/extras/layout/layout5.cxx         |   34 ++++++++++++++++++++++++++++++++
 sw/source/core/layout/sectfrm.cxx       |    1 
 3 files changed, 57 insertions(+)

New commits:
commit 0e9ef8943514a5642c0e11024eebb88bd0d91096
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Mon Apr 28 16:15:04 2025 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Apr 29 13:15:08 2025 +0200

    tdf#166210: invalidate parent's size when hiding section
    
    Regression from commit 0c96119895b347f8eb5bb89f393351bd3c02b9f1
    
    Change-Id: I4469749c9ff3d9fae43f00e01276c241e7c49f61
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184720
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184754

diff --git a/sw/qa/extras/layout/data/tdf166210.fodt 
b/sw/qa/extras/layout/data/tdf166210.fodt
new file mode 100644
index 000000000000..7e53241b76f5
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf166210.fodt
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer"; office:version="1.4" 
office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:body>
+  <office:text>
+   <table:table>
+    <table:table-column/>
+    <table:table-row>
+     <table:table-cell>
+      <text:section text:name="Section1" text:condition="ooow:0" 
text:display="condition">
+       <text:p>Conditional section 1</text:p>
+      </text:section>
+      <text:p>Text between sections</text:p>
+      <text:section text:name="Section2" text:condition="ooow:0" 
text:display="condition">
+       <text:p>Conditional section 2</text:p>
+      </text:section>
+     </table:table-cell>
+    </table:table-row>
+   </table:table>
+  </office:text>
+ </office:body>
+</office:document>
\ No newline at end of file
diff --git a/sw/qa/extras/layout/layout5.cxx b/sw/qa/extras/layout/layout5.cxx
index 80a9a749d557..1480afefc8f5 100644
--- a/sw/qa/extras/layout/layout5.cxx
+++ b/sw/qa/extras/layout/layout5.cxx
@@ -10,6 +10,7 @@
 #include <swmodeltestbase.hxx>
 
 #include <com/sun/star/text/XTextFrame.hpp>
+#include <com/sun/star/text/XTextSectionsSupplier.hpp>
 #include <com/sun/star/text/XTextTable.hpp>
 #include <com/sun/star/text/XTextTablesSupplier.hpp>
 #include <com/sun/star/linguistic2/XHyphenator.hpp>
@@ -18,6 +19,7 @@
 #include <comphelper/scopeguard.hxx>
 #include <unotools/syslocaleoptions.hxx>
 #include <editeng/unolingu.hxx>
+#include <vcl/scheduler.hxx>
 
 #include <scriptinfo.hxx>
 #include <rootfrm.hxx>
@@ -1609,6 +1611,38 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter5, testTdf165089)
     CPPUNIT_ASSERT_LESS(sal_Int32(1450), nTop);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter5, testTdf166210)
+{
+    // Given a document with a table, inside which there are two conditionally 
hidden sections
+    createSwDoc("tdf166210.fodt");
+
+    auto xTextSectionsSupplier = 
mxComponent.queryThrow<css::text::XTextSectionsSupplier>();
+    auto xSections = xTextSectionsSupplier->getTextSections();
+    CPPUNIT_ASSERT(xSections);
+    auto xSection1 = 
xSections->getByName(u"Section1"_ustr).queryThrow<css::beans::XPropertySet>();
+    auto xSection2 = 
xSections->getByName(u"Section2"_ustr).queryThrow<css::beans::XPropertySet>();
+
+    Scheduler::ProcessEventsToIdle();
+    auto pXmlDoc = parseLayoutDump();
+    auto rowHeight1 = getXPath(pXmlDoc, "//body/tab/infos/bounds", 
"height").toInt32();
+
+    // Hide first section
+    xSection1->setPropertyValue(u"Condition"_ustr, css::uno::Any(u"1"_ustr));
+    Scheduler::ProcessEventsToIdle();
+    pXmlDoc = parseLayoutDump();
+    auto rowHeight2 = getXPath(pXmlDoc, "//body/tab/infos/bounds", 
"height").toInt32();
+    // Make sure that the table has shrunk its height
+    CPPUNIT_ASSERT_LESS(rowHeight1, rowHeight2);
+
+    // Hide second section
+    xSection2->setPropertyValue(u"Condition"_ustr, css::uno::Any(u"1"_ustr));
+    Scheduler::ProcessEventsToIdle();
+    pXmlDoc = parseLayoutDump();
+    auto rowHeight3 = getXPath(pXmlDoc, "//body/tab/infos/bounds", 
"height").toInt32();
+    // Make sure that the table has shrunk its height
+    CPPUNIT_ASSERT_LESS(rowHeight2, rowHeight3);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/sectfrm.cxx 
b/sw/source/core/layout/sectfrm.cxx
index 57fb8a04c7ae..dc9858c25418 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -2771,6 +2771,7 @@ void SwSectionFrame::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
             SwFrameAreaDefinition::FrameAreaWriteAccess area(*this);
             SwRectFnSet(this).SetHeight(area, HUGE_POSITIVE);
         }
+        GetUpper()->InvalidateSize();
 
         InvalidateFramesInSection(Lower());
         if (Lower())

Reply via email to