compilerplugins/clang/ostr.cxx                                                 
   |   26 
 drawinglayer/source/processor2d/vclprocessor2d.cxx                             
   |   20 
 external/libcmis/UnpackedTarball_libcmis.mk                                    
   |    2 
 external/libcmis/factory-no-retry-ssl.patch.1                                  
   |   17 
 external/libcmis/sharepoint-auth.patch.1                                       
   |   13 
 external/libpng/0001-ACES-AP0-adjusted-fixes.patch.1                           
   |  246 ++++++++
 
external/libpng/0001-fix-Avoid-integer-overflows-in-function-png_xy_from_.patch.1
 |   99 +++
 
external/libpng/0001-libpng16-fix-Correct-the-function-png_fp_sub-in-png.patch.1
  |   35 +
 external/libpng/UnpackedTarball_libpng.mk                                      
   |    6 
 external/more_fonts/ExternalPackage_noto_sans_arabic.mk                        
   |    4 
 g                                                                              
   |  104 +--
 include/unotest/macros_test.hxx                                                
   |    6 
 sc/source/core/tool/address.cxx                                                
   |   15 
 sc/source/filter/html/htmlpars.cxx                                             
   |   38 -
 sc/source/filter/xml/xmlcelli.cxx                                              
   |    7 
 sc/source/filter/xml/xmlexprt.cxx                                              
   |   13 
 svgio/source/svgreader/svgstyleattributes.cxx                                  
   |    8 
 sw/qa/extras/layout/data/hidden-para-as-char-fly.fodt                          
   |  279 ++++++++++
 sw/qa/extras/layout/data/hidden-para-follow-frame.fodt                         
   |  113 ++++
 sw/qa/extras/layout/data/i94666.odt                                            
   |binary
 sw/qa/extras/layout/data/section-nested-with-pagebreaks.fodt                   
   |  148 +++++
 sw/qa/extras/layout/layout.cxx                                                 
   |   46 +
 sw/qa/extras/layout/layout3.cxx                                                
   |  270 +++++++++
 sw/qa/extras/odfimport/data/tdf159549.fodt                                     
   |  121 ++++
 sw/qa/extras/odfimport/odfimport.cxx                                           
   |   22 
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx                                      
   |    4 
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx                                       
   |    2 
 sw/qa/extras/rtfexport/rtfexport4.cxx                                          
   |    2 
 sw/qa/extras/uiwriter/data/IndexElementsInHiddenSections.fodt                  
   |   63 ++
 sw/qa/extras/uiwriter/uiwriter2.cxx                                            
   |    2 
 sw/qa/extras/uiwriter/uiwriter9.cxx                                            
   |   43 +
 sw/qa/uitest/data/tdf163325.odt                                                
   |binary
 sw/qa/uitest/writer_tests5/tdf163325.py                                        
   |   35 +
 sw/source/core/doc/SwStyleNameMapper.cxx                                       
   |   28 -
 sw/source/core/doc/doctxm.cxx                                                  
   |   79 +-
 sw/source/core/docnode/section.cxx                                             
   |    4 
 sw/source/core/fields/ddetbl.cxx                                               
   |    6 
 sw/source/core/inc/flowfrm.hxx                                                 
   |    3 
 sw/source/core/inc/txtfrm.hxx                                                  
   |    3 
 sw/source/core/layout/calcmove.cxx                                             
   |   93 ++-
 sw/source/core/layout/flowfrm.cxx                                              
   |   53 +
 sw/source/core/layout/fly.cxx                                                  
   |    5 
 sw/source/core/layout/frmtool.cxx                                              
   |    2 
 sw/source/core/layout/layact.cxx                                               
   |    2 
 sw/source/core/layout/objectformattertxtfrm.cxx                                
   |    2 
 sw/source/core/layout/paintfrm.cxx                                             
   |    5 
 sw/source/core/layout/sectfrm.cxx                                              
   |   23 
 sw/source/core/layout/sortedobjs.cxx                                           
   |    6 
 sw/source/core/layout/tabfrm.cxx                                               
   |   24 
 sw/source/core/layout/trvlfrm.cxx                                              
   |    1 
 sw/source/core/layout/wsfrm.cxx                                                
   |    5 
 sw/source/core/text/guess.cxx                                                  
   |   26 
 sw/source/core/text/txtfrm.cxx                                                 
   |   21 
 sw/source/core/tox/tox.cxx                                                     
   |    3 
 sw/source/core/unocore/unostyle.cxx                                            
   |   14 
 sw/source/filter/ww8/rtfattributeoutput.cxx                                    
   |    2 
 sw/source/filter/ww8/ww8par.cxx                                                
   |   17 
 sw/source/filter/ww8/ww8par5.cxx                                               
   |    2 
 sw/source/filter/xml/xmlimpit.cxx                                              
   |    2 
 sw/source/uibase/inc/wrtsh.hxx                                                 
   |    2 
 ucb/source/ucp/webdav-curl/CurlSession.cxx                                     
   |  173 +++++-
 unotest/source/cpp/macros_test.cxx                                             
   |   57 ++
 vcl/source/gdi/metaact.cxx                                                     
   |   11 
 63 files changed, 2255 insertions(+), 228 deletions(-)

New commits:
commit d6fcdb2e8cb7ff75531fd149dd4818097d4f3e59
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Dec 5 12:22:14 2024 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Dec 12 15:41:08 2024 +0100

    tdf#159549 sw: fix ODF import of newly colliding Body Text styles
    
    Commit c83d241effbd09491e9f96d3e435ab91700f58b0 "tdf#154933 Rename "Text
    Body" para style to "Body Text"" introduced a regression when importing
    certain ODF documents, but the problem is actually pre-existing.
    
    What happens is that first the built-in "Text body" style is created,
    and then a non-built-in style with the same translated name as "Text
    body" is imported, and instead of creating a new style, the built-in one
    is found and used, and so its properties are overwritten.
    
    The root cause is that SwStyleNameMapper::FillProgName() and in
    particular SwStyleNameMapper::FillUIName() are defined poorly, ever
    since they were introduced in 2001 in commit
    4fbc9dd48b7cebb304010e7337b1bbc3936c7923
    
    It becomes obvious relatively quickly that the way style names work is
    that at the UNO API level, the "ProgName" (internal, non-localised)
    names are used, and at the core document level, the "UIName" (localised)
    names are used.
    
    This is in itself questionable - why is the translation from ProgName to
    UIName not done in the UI? - but also very expensive to change now.
    
    So then the UNO services are responsible for translating between
    ProgName and UIName.
    
    But the 2 functions don't do that properly; both need to check if the
    given name is a known ProgName *or* a known UIName, and rename it in
    case it collides with a known target name; also the 2 functions need to
    cancel each other out, not add " (user)" at the end in both directions.
    
    Fixing this causes numerous tests to fail, due to:
    
    1. the UNO services calling themselves with already converted style
       names, which are then translated a second time, which fails now.
       (or calling the wrong function like SwXStyleFamily::getByIndex())
    
    2. many tests call the UNO API with UINames instead of ProgNames
    
    3. somehow the writerfilter import is also changed, causing failures in
       e.g. testTdf113182 and testTdf104492
    
    4. buggy code elsewhere (lcl_getUsedPageStyles()), problem similar to
       1., for PageDescs
    
    5. potentially more buggy code yet to be discovered (definitely table
       styles, forgot which test that was)
    
    So limit this fix for now to only paragraph styles, and don't do it in
    writerfilter import, now at least sw.check passes.
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177858
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>
    Tested-by: Jenkins
    (cherry picked from commit bd727654ec8cc339292072b42073e57d566cc220)
    
    tdf#159549 sw: fix style name in SwXStyle::getParentStyle()
    
    For a style that isn't inserted yet, the m_sParentStyleName is converted
    to UIName by setParentStyle() but isn't converted back to ProgName in
    getParentStyle().
    
    This caused all of the writerfilter test failures in commit
    bd727654ec8cc339292072b42073e57d566cc220.
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177998
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 2b8d794e448a7d3c573ff79cffe9decc8d960262)
    
    tdf#159549 sw: add unit test
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178148
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Tested-by: Jenkins
    (cherry picked from commit bfdba3c86301e9680204de0a66bfbfc6383494b9)
    
    Change-Id: I5cbdf3e174622e83f9af8787c3671b88c0e37bac

diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx
index 035678349da4..7304935c0189 100644
--- a/sw/qa/extras/layout/layout3.cxx
+++ b/sw/qa/extras/layout/layout3.cxx
@@ -874,7 +874,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf155177)
 {
     createSwDoc("tdf155177-1-min.odt");
 
-    uno::Reference<beans::XPropertySet> 
xStyle(getStyles("ParagraphStyles")->getByName("Body Text"),
+    uno::Reference<beans::XPropertySet> 
xStyle(getStyles("ParagraphStyles")->getByName("Text body"),
                                                uno::UNO_QUERY_THROW);
     CPPUNIT_ASSERT_EQUAL(sal_Int32(210), getProperty<sal_Int32>(xStyle, 
"ParaTopMargin"));
 
diff --git a/sw/qa/extras/odfimport/data/tdf159549.fodt 
b/sw/qa/extras/odfimport/data/tdf159549.fodt
new file mode 100644
index 000000000000..891b4ed9fc8e
--- /dev/null
+++ b/sw/qa/extras/odfimport/data/tdf159549.fodt
@@ -0,0 +1,121 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<office:document xmlns:officeooo="http://openoffice.org/2009/office"; 
xmlns:css3t="http://www.w3.org/TR/css3-text/"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:dc="http://purl.org/dc/eleme
 nts/1.1/" xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 xmlns:math="http://www.w3.org/1998/Math/MathML"; 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0
 " xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:xforms="http://www.w3.org/2002/xforms"; office:version="1.2" 
office:mimetype="application/vnd.oasis.opendocument.text">
+ 
<office:meta><meta:creation-date>2024-12-09T13:36:04.154920066</meta:creation-date><dc:date>2024-12-09T14:09:04.311392385</dc:date><meta:editing-duration>PT32M56S</meta:editing-duration><meta:editing-cycles>2</meta:editing-cycles><meta:generator>CIB_OfficeDev/6.4.0.29$Linux_X86_64
 
LibreOffice_project/5374b230ff33d77a7f81d56046759f218a160036</meta:generator><meta:document-statistic
 meta:table-count="0" meta:image-count="0" meta:object-count="0" 
meta:page-count="1" meta:paragraph-count="3" meta:word-count="5" 
meta:character-count="37" 
meta:non-whitespace-character-count="35"/></office:meta>
+ <office:font-face-decls>
+  <style:font-face style:name="Liberation Serif" svg:font-family="'Liberation 
Serif'" style:font-family-generic="roman" style:font-pitch="variable"/>
+  <style:font-face style:name="Lucida Sans" svg:font-family="'Lucida Sans'" 
style:font-family-generic="system" style:font-pitch="variable"/>
+  <style:font-face style:name="Noto Serif CJK SC" svg:font-family="'Noto Serif 
CJK SC'" style:font-family-generic="system" style:font-pitch="variable"/>
+ </office:font-face-decls>
+ <office:styles>
+  <style:default-style style:family="graphic">
+   <style:graphic-properties svg:stroke-color="#3465a4" 
draw:fill-color="#729fcf" fo:wrap-option="no-wrap" draw:shadow-offset-x="0.3cm" 
draw:shadow-offset-y="0.3cm" draw:start-line-spacing-horizontal="0.283cm" 
draw:start-line-spacing-vertical="0.283cm" 
draw:end-line-spacing-horizontal="0.283cm" 
draw:end-line-spacing-vertical="0.283cm" style:flow-with-text="false"/>
+   <style:paragraph-properties style:text-autospace="ideograph-alpha" 
style:line-break="strict" style:font-independent-line-spacing="false">
+    <style:tab-stops/>
+   </style:paragraph-properties>
+   <style:text-properties style:use-window-font-color="true" 
style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="de" 
fo:country="DE" style:letter-kerning="true" style:font-name-asian="Noto Serif 
CJK SC" style:font-size-asian="10.5pt" style:language-asian="zh" 
style:country-asian="CN" style:font-name-complex="Lucida Sans" 
style:font-size-complex="12pt" style:language-complex="hi" 
style:country-complex="IN"/>
+  </style:default-style>
+  <style:default-style style:family="paragraph">
+   <style:paragraph-properties fo:orphans="2" fo:widows="2" 
fo:hyphenation-ladder-count="no-limit" style:text-autospace="ideograph-alpha" 
style:punctuation-wrap="hanging" style:line-break="strict" 
style:tab-stop-distance="1.251cm" style:writing-mode="page"/>
+   <style:text-properties style:use-window-font-color="true" 
style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="de" 
fo:country="DE" style:letter-kerning="true" style:font-name-asian="Noto Serif 
CJK SC" style:font-size-asian="10.5pt" style:language-asian="zh" 
style:country-asian="CN" style:font-name-complex="Lucida Sans" 
style:font-size-complex="12pt" style:language-complex="hi" 
style:country-complex="IN" fo:hyphenate="false" 
fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2" 
loext:hyphenation-no-caps="false"/>
+  </style:default-style>
+  <style:default-style style:family="table">
+   <style:table-properties table:border-model="collapsing"/>
+  </style:default-style>
+  <style:default-style style:family="table-row">
+   <style:table-row-properties fo:keep-together="auto"/>
+  </style:default-style>
+  <style:style style:name="Standard" style:family="paragraph" 
style:class="text"/>
+  <style:style style:name="Text_20_body" style:display-name="Text body" 
style:family="paragraph" style:parent-style-name="Standard" style:class="text">
+   <style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.247cm" 
loext:contextual-spacing="false" fo:line-height="115%"/>
+   <style:text-properties fo:font-size="32pt"/>
+  </style:style>
+  <style:style style:name="DerivedFromTextBody" style:family="paragraph" 
style:parent-style-name="Text_20_body"/>
+  <style:style style:name="Body_20_Text" style:display-name="Body Text" 
style:family="paragraph" style:parent-style-name="Standard">
+   <style:text-properties fo:font-size="16pt"/>
+  </style:style>
+  <text:outline-style style:name="Outline">
+   <text:outline-level-style text:level="1" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="2" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="3" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="4" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="5" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="6" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="7" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="8" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="9" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="10" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+  </text:outline-style>
+  <text:notes-configuration text:note-class="footnote" style:num-format="1" 
text:start-value="0" text:footnotes-position="page" 
text:start-numbering-at="document"/>
+  <text:notes-configuration text:note-class="endnote" style:num-format="i" 
text:start-value="0"/>
+  <text:linenumbering-configuration text:number-lines="false" 
text:offset="0.499cm" style:num-format="1" text:number-position="left" 
text:increment="5"/>
+ </office:styles>
+ <office:automatic-styles>
+  <style:style style:name="T1" style:family="text">
+   <style:text-properties/>
+  </style:style>
+  <style:page-layout style:name="pm1">
+   <style:page-layout-properties fo:page-width="21.001cm" 
fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" 
fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" 
fo:margin-right="2cm" style:writing-mode="lr-tb" 
style:layout-grid-color="#c0c0c0" style:layout-grid-lines="20" 
style:layout-grid-base-height="0.706cm" style:layout-grid-ruby-height="0.353cm" 
style:layout-grid-mode="none" style:layout-grid-ruby-below="false" 
style:layout-grid-print="false" style:layout-grid-display="false" 
style:footnote-max-height="0cm">
+    <style:footnote-sep style:width="0.018cm" 
style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" 
style:line-style="solid" style:adjustment="left" style:rel-width="25%" 
style:color="#000000"/>
+   </style:page-layout-properties>
+   <style:header-style/>
+   <style:footer-style/>
+  </style:page-layout>
+ </office:automatic-styles>
+ <office:master-styles>
+  <style:master-page style:name="Standard" style:page-layout-name="pm1"/>
+ </office:master-styles>
+ <office:body>
+  <office:text>
+   <text:sequence-decls>
+    <text:sequence-decl text:display-outline-level="0" 
text:name="Illustration"/>
+    <text:sequence-decl text:display-outline-level="0" text:name="Table"/>
+    <text:sequence-decl text:display-outline-level="0" text:name="Text"/>
+    <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
+    <text:sequence-decl text:display-outline-level="0" text:name="Figure"/>
+   </text:sequence-decls>
+   <text:p text:style-name="Text_20_body"><text:span text:style-name="T1">Text 
</text:span>Body</text:p>
+   <text:p text:style-name="DerivedFromTextBody">Derived<text:span 
text:style-name="T1">FromTextBody</text:span></text:p>
+   <text:p text:style-name="Body_20_Text">Body Text</text:p>
+  </office:text>
+ </office:body>
+</office:document>
\ No newline at end of file
diff --git a/sw/qa/extras/odfimport/odfimport.cxx 
b/sw/qa/extras/odfimport/odfimport.cxx
index dfbab89d53f5..3b877cbf898b 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -1212,6 +1212,28 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf133459)
     CPPUNIT_ASSERT_EQUAL(OUString("QQ YYYY"), getProperty<OUString>(xFormat, 
"FormatString"));
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf159549)
+{
+    createSwDoc("tdf159549.fodt");
+
+    uno::Reference<container::XNameAccess> 
xParaStyles(getStyles(u"ParagraphStyles"_ustr));
+
+    uno::Reference<beans::XPropertySet> xStyleBuiltin(xParaStyles->getByName(
+            u"Text body"_ustr), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(float(32), getProperty<float>(xStyleBuiltin, 
"CharHeight"));
+    CPPUNIT_ASSERT_EQUAL(OUString("Standard"), 
xStyleBuiltin.queryThrow<style::XStyle>()->getParentStyle());
+
+    uno::Reference<beans::XPropertySet> xStyleDerived(xParaStyles->getByName(
+            u"DerivedFromTextBody"_ustr), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(float(32), getProperty<float>(xStyleDerived, 
"CharHeight"));
+    CPPUNIT_ASSERT_EQUAL(OUString("Text body"), 
xStyleDerived.queryThrow<style::XStyle>()->getParentStyle());
+
+    uno::Reference<beans::XPropertySet> xStyleCustom(xParaStyles->getByName(
+            u"Body Text"_ustr), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(float(16), getProperty<float>(xStyleCustom, 
"CharHeight"));
+    CPPUNIT_ASSERT_EQUAL(OUString("Standard"), 
xStyleCustom.queryThrow<style::XStyle>()->getParentStyle());
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf134971)
 {
     createSwDoc("tdf134971a.odt");
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index c801d0477fe5..98170b2f5f57 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -475,7 +475,7 @@ DECLARE_OOXMLEXPORT_TEST(testKern, "kern.docx")
     // This failed: kerning was also enabled for the second paragraph.
     CPPUNIT_ASSERT(!getProperty<bool>(getRun(getParagraph(2), 1), 
"CharAutoKerning"));
 
-    uno::Reference<beans::XPropertySet> 
xStyle(getStyles("ParagraphStyles")->getByName("Default Paragraph Style"), 
uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> 
xStyle(getStyles("ParagraphStyles")->getByName("Standard"), uno::UNO_QUERY);
     //tdf107801: kerning normally isn't enabled by default for .docx
     CPPUNIT_ASSERT_EQUAL_MESSAGE("AutoKern should be false", false, 
getProperty<bool>(xStyle, "CharAutoKerning"));
 }
@@ -485,7 +485,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf89377, 
"tdf89377_tableWithBreakBeforeParaStyle.d
     // the paragraph style should set table's text-flow break-before-page
     CPPUNIT_ASSERT_EQUAL( 3, getPages() );
 
-    uno::Reference<beans::XPropertySet> 
xStyle(getStyles("ParagraphStyles")->getByName("Default Paragraph Style"), 
uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> 
xStyle(getStyles("ParagraphStyles")->getByName("Standard"), uno::UNO_QUERY);
     //tdf107801: kerning info wasn't exported previously.
     CPPUNIT_ASSERT_EQUAL_MESSAGE("AutoKern should be true", true, 
getProperty<bool>(xStyle, "CharAutoKerning"));
 }
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 5d5661f0fa0f..a8d3e024c4d7 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -731,7 +731,7 @@ CPPUNIT_TEST_FIXTURE(Test, testN820504)
     uno::Reference<style::XStyleFamiliesSupplier> 
xFamiliesSupplier(mxComponent, uno::UNO_QUERY);
     uno::Reference<container::XNameAccess> xFamiliesAccess = 
xFamiliesSupplier->getStyleFamilies();
     uno::Reference<container::XNameAccess> 
xStylesAccess(xFamiliesAccess->getByName("ParagraphStyles"), uno::UNO_QUERY);
-    uno::Reference<beans::XPropertySet> 
xStyle(xStylesAccess->getByName("Default Paragraph Style"), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> 
xStyle(xStylesAccess->getByName("Standard"), uno::UNO_QUERY);
     // The problem was that the CharColor was set to AUTO (-1) even if we have 
some default char color set
     CPPUNIT_ASSERT_EQUAL(Color(0x3da7bb), getProperty<Color>(xStyle, 
"CharColor"));
 
diff --git a/sw/qa/extras/rtfexport/rtfexport4.cxx 
b/sw/qa/extras/rtfexport/rtfexport4.cxx
index 2a470f3c9682..c7242517111b 100644
--- a/sw/qa/extras/rtfexport/rtfexport4.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport4.cxx
@@ -509,7 +509,7 @@ DECLARE_RTFEXPORT_TEST(testTdf136587_noStyleName, 
"tdf136587_noStyleName.rtf")
                          getProperty<sal_Int16>(xStyleProps, "ParaAdjust"));
 
     // The problem was that the default style wasn't imported at all, so the 
fontsize was only 12.
-    xStyleProps.set(paragraphStyles->getByName("Default Paragraph Style"), 
uno::UNO_QUERY_THROW);
+    xStyleProps.set(paragraphStyles->getByName("Standard"), 
uno::UNO_QUERY_THROW);
     CPPUNIT_ASSERT_EQUAL(32.0f, getProperty<float>(xStyleProps, "CharHeight"));
 }
 
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx 
b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 15852718f463..d20543bce5bf 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -2623,7 +2623,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, 
testRTLparaStyle_LocaleArabic)
     saveAndReload("Office Open XML Text");
 
     uno::Reference<beans::XPropertySet> xPageStyle(
-        getStyles("ParagraphStyles")->getByName("Default Paragraph Style"), 
uno::UNO_QUERY_THROW);
+        getStyles("ParagraphStyles")->getByName("Standard"), 
uno::UNO_QUERY_THROW);
     // Test the text Direction value for the -none- based paragraph styles
     CPPUNIT_ASSERT_EQUAL_MESSAGE("RTL Writing Mode", sal_Int32(1),
                                  getProperty<sal_Int32>(xPageStyle, 
"WritingMode"));
diff --git a/sw/source/core/doc/SwStyleNameMapper.cxx 
b/sw/source/core/doc/SwStyleNameMapper.cxx
index 17f732d6d31e..f01f121442b4 100644
--- a/sw/source/core/doc/SwStyleNameMapper.cxx
+++ b/sw/source/core/doc/SwStyleNameMapper.cxx
@@ -262,10 +262,18 @@ void SwStyleNameMapper::FillProgName(
         rFillName = rName;
         if (nId == USHRT_MAX )
         {
-            // It isn't ...make sure the suffix isn't already " (user)"...if 
it is,
-            // we need to add another one
-            if (lcl_SuffixIsUser(rFillName))
-                rFillName += " (user)";
+            if (eFlags == SwGetPoolIdFromName::TxtColl)
+            {
+                // check if it has a " (user)" suffix, if so remove it
+                lcl_CheckSuffixAndDelete(rFillName);
+            }
+            else // FIXME don't do this
+            {
+                // It isn't ...make sure the suffix isn't already " 
(user)"...if it is,
+                // we need to add another one
+                if (lcl_SuffixIsUser(rFillName))
+                    rFillName += " (user)";
+            }
         }
         else
         {
@@ -296,8 +304,16 @@ void SwStyleNameMapper::FillUIName(
     if ( nId == USHRT_MAX )
     {
         rFillName = aName;
-        // aName isn't in our Prog name table...check if it has a " (user)" 
suffix, if so remove it
-        lcl_CheckSuffixAndDelete ( rFillName );
+        if (eFlags != SwGetPoolIdFromName::TxtColl || // FIXME do it for all 
ids
+            GetPoolIdFromUIName(aName, eFlags) == USHRT_MAX)
+        {
+            // aName isn't in our Prog name table...check if it has a " 
(user)" suffix, if so remove it
+            lcl_CheckSuffixAndDelete(rFillName);
+        }
+        else
+        {
+            rFillName += " (user)";
+        }
     }
     else
     {
diff --git a/sw/source/core/unocore/unostyle.cxx 
b/sw/source/core/unocore/unostyle.cxx
index 665c1d2c6ac5..94b4304e6c4e 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -1018,7 +1018,7 @@ uno::Any XStyleFamily::getByIndex(sal_Int32 nIndex)
     OUString sStyleName;
     try
     {
-        SwStyleNameMapper::FillUIName(m_rEntry.translateIndex(nIndex), 
sStyleName);
+        SwStyleNameMapper::FillProgName(m_rEntry.translateIndex(nIndex), 
sStyleName);
     } catch(...) {}
     if (sStyleName.isEmpty())
         GetCountOrName(&sStyleName, nIndex);
@@ -1030,10 +1030,10 @@ uno::Any XStyleFamily::getByIndex(sal_Int32 nIndex)
 uno::Any XStyleFamily::getByName(const OUString& rName)
 {
     SolarMutexGuard aGuard;
-    OUString sStyleName;
-    SwStyleNameMapper::FillUIName(rName, sStyleName, m_rEntry.poolId());
     if(!m_pBasePool)
         throw uno::RuntimeException();
+    OUString sStyleName;
+    SwStyleNameMapper::FillUIName(rName, sStyleName, m_rEntry.poolId());
     SfxStyleSheetBase* pBase = m_pBasePool->Find(sStyleName, 
m_rEntry.family());
     if(!pBase)
         throw container::NoSuchElementException(rName);
@@ -1454,7 +1454,9 @@ OUString SwXStyle::getParentStyle()
     {
         if(!m_bIsDescriptor)
             throw uno::RuntimeException();
-        return m_sParentStyleName;
+        OUString ret;
+        SwStyleNameMapper::FillProgName(m_sParentStyleName, ret, 
lcl_GetSwEnumFromSfxEnum(m_rEntry.family()));
+        return ret;
     }
     SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName, 
m_rEntry.family());
     OUString aString;
@@ -1468,7 +1470,7 @@ void SwXStyle::setParentStyle(const OUString& 
rParentStyle)
 {
     SolarMutexGuard aGuard;
     OUString sParentStyle;
-    SwStyleNameMapper::FillUIName(rParentStyle, sParentStyle, 
lcl_GetSwEnumFromSfxEnum ( m_rEntry.family()) );
+    SwStyleNameMapper::FillUIName(rParentStyle, sParentStyle, 
lcl_GetSwEnumFromSfxEnum(m_rEntry.family()));
     if(!m_pBasePool)
     {
         if(!m_bIsDescriptor)
@@ -1476,7 +1478,7 @@ void SwXStyle::setParentStyle(const OUString& 
rParentStyle)
         m_sParentStyleName = sParentStyle;
         try
         {
-            const auto aAny = m_xStyleFamily->getByName(sParentStyle);
+            const auto aAny = m_xStyleFamily->getByName(rParentStyle);
             m_xStyleData = aAny.get<decltype(m_xStyleData)>();
         }
         catch(...)
commit a896c543115b9185b5f143630778189881ff847a
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sat Nov 23 11:02:07 2024 +0500
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Dec 12 15:41:08 2024 +0100

    tdf#162195: use SwFrame::IsHiddenNow when building index
    
    Before commit 0c96119895b347f8eb5bb89f393351bd3c02b9f1 (tdf#159565
    prerequisite: make hidden sections have zero-height frames, 2024-02-15),
    the hidden sections were absent from layout, so didn't appear in the
    SwTOXBaseSection::Update* functions. Now they are zero-height, but
    present, so their visibility must be taken into account explicitly.
    
    Change-Id: I95cc72b383a99e1f65152579c5458e253a3f60ea
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177079
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177102
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit a5edc358b158ec017f26ab83ca42e0af31ce0147)

diff --git a/sw/qa/extras/uiwriter/data/IndexElementsInHiddenSections.fodt 
b/sw/qa/extras/uiwriter/data/IndexElementsInHiddenSections.fodt
new file mode 100644
index 000000000000..5fb3d809404f
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/IndexElementsInHiddenSections.fodt
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
office:version="1.4" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:styles>
+  <style:style style:name="CustomTOCStyle" style:family="paragraph" 
style:class="text"/>
+ </office:styles>
+ <office:body>
+  <office:text>
+   <text:table-of-content>
+    <text:table-of-content-source text:outline-level="1" 
text:use-index-source-styles="true">
+     <text:index-title-template text:style-name="Contents_20_Heading">Table of 
Contents</text:index-title-template>
+     <text:table-of-content-entry-template text:outline-level="1" 
text:style-name="Contents_20_1">
+      <text:index-entry-link-start text:style-name="Index_20_Link"/>
+      <text:index-entry-chapter/>
+      <text:index-entry-text/>
+      <text:index-entry-tab-stop style:type="right" style:leader-char="."/>
+      <text:index-entry-page-number/>
+      <text:index-entry-link-end/>
+     </text:table-of-content-entry-template>
+     <text:index-source-styles text:outline-level="1">
+      <text:index-source-style text:style-name="CustomTOCStyle"/>
+     </text:index-source-styles>
+    </text:table-of-content-source>
+   </text:table-of-content>
+   <text:section text:name="Section Visible">
+    <text:h text:outline-level="1">Section Visible</text:h>
+    <text:p>foo</text:p>
+    <table:table table:name="Table1">
+     <table:table-column/>
+     <table:table-row>
+      <table:table-cell/>
+     </table:table-row>
+    </table:table>
+   </text:section>
+   <text:section text:name="Section Hidden" text:display="none">
+    <text:h text:outline-level="1">Section Hidden</text:h>
+    <text:p>bar</text:p>
+    <text:p/>
+    <text:p>A level-1 <text:toc-mark-start text:id="IMark1" 
text:outline-level="1"/>entry<text:toc-mark-end text:id="IMark1"/></text:p>
+    <text:p/>
+    <text:p text:style-name="CustomTOCStyle">CustomTOCStyle paragraph</text:p>
+    <table:table table:name="Table2">
+     <table:table-column/>
+     <table:table-row>
+      <table:table-cell/>
+     </table:table-row>
+    </table:table>
+   </text:section>
+   <text:table-index>
+    <text:table-index-source text:use-caption="false" 
text:caption-sequence-name="Table" text:caption-sequence-format="text">
+     <text:index-title-template 
text:style-name="Table_20_index_20_heading">Index of 
Tables</text:index-title-template>
+     <text:table-index-entry-template text:style-name="Table_20_index_20_1">
+      <text:index-entry-link-start text:style-name="Index_20_Link"/>
+      <text:index-entry-text/>
+      <text:index-entry-tab-stop style:type="right" style:leader-char="."/>
+      <text:index-entry-page-number/>
+      <text:index-entry-link-end/>
+     </text:table-index-entry-template>
+    </text:table-index-source>
+   </text:table-index>
+  </office:text>
+ </office:body>
+</office:document>
\ No newline at end of file
diff --git a/sw/qa/extras/uiwriter/uiwriter9.cxx 
b/sw/qa/extras/uiwriter/uiwriter9.cxx
index 96ad4b05638f..be341f700cc3 100644
--- a/sw/qa/extras/uiwriter/uiwriter9.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter9.cxx
@@ -285,6 +285,49 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf144752)
     CPPUNIT_ASSERT_EQUAL(u"Word"_ustr, pWrtShell->GetSelText());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf162195)
+{
+    // Given a document, which has some index entries in a hidden section
+    createSwDoc("IndexElementsInHiddenSections.fodt");
+
+    auto 
xIndexSupplier(mxComponent.queryThrow<css::text::XDocumentIndexesSupplier>());
+    auto xIndexes = xIndexSupplier->getDocumentIndexes();
+    CPPUNIT_ASSERT(xIndexes);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexes->getCount()); // A ToC and a 
table index
+
+    auto xToC(xIndexes->getByIndex(0).queryThrow<css::text::XDocumentIndex>());
+    xToC->update();
+    // Without the fix, all the elements from the hidden section appeared in 
the index
+    CPPUNIT_ASSERT_EQUAL(u"Table of Contents" SAL_NEWLINE_STRING "Section 
Visible      1"_ustr,
+                         xToC->getAnchor()->getString());
+
+    auto 
xTables(xIndexes->getByIndex(1).queryThrow<css::text::XDocumentIndex>());
+    xTables->update();
+    // Without the fix, all the elements from the hidden section appeared in 
the index
+    CPPUNIT_ASSERT_EQUAL(u"Index of Tables" SAL_NEWLINE_STRING "Table1 1"_ustr,
+                         xTables->getAnchor()->getString());
+
+    // Show the hidden section
+    auto xTextSectionsSupplier = 
mxComponent.queryThrow<css::text::XTextSectionsSupplier>();
+    auto xSections = xTextSectionsSupplier->getTextSections();
+    CPPUNIT_ASSERT(xSections);
+    auto xSection
+        = xSections->getByName(u"Section 
Hidden"_ustr).queryThrow<css::beans::XPropertySet>();
+    xSection->setPropertyValue(u"IsVisible"_ustr, css::uno::Any(true));
+
+    xToC->update();
+    CPPUNIT_ASSERT_EQUAL(u"Table of Contents" SAL_NEWLINE_STRING
+                         "Section Visible      1" SAL_NEWLINE_STRING
+                         "Section Hidden       1" SAL_NEWLINE_STRING "entry    
1" SAL_NEWLINE_STRING
+                         "CustomTOCStyle paragraph     1"_ustr,
+                         xToC->getAnchor()->getString());
+
+    xTables->update();
+    CPPUNIT_ASSERT_EQUAL(u"Index of Tables" SAL_NEWLINE_STRING "Table1 1" 
SAL_NEWLINE_STRING
+                         "Table2       1"_ustr,
+                         xTables->getAnchor()->getString());
+}
+
 } // end of anonymous namespace
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx
index a0ea88ec1936..61f12e7e951f 100644
--- a/sw/source/core/doc/doctxm.cxx
+++ b/sw/source/core/doc/doctxm.cxx
@@ -1344,6 +1344,48 @@ void SwTOXBaseSection::UpdateMarks(const 
SwTOXInternational& rIntl,
     }
 }
 
+static SwContentFrame* useContentNodeForIndex(const SwContentNode* node, bool 
fromChapter,
+                                              const SwTextNode* chapter, const 
SwRootFrame* layout)
+{
+    if (!node)
+        return nullptr;
+    if (!node->HasWriterListeners())
+        return nullptr;
+    if (!node->GetNodes().IsDocNodes())
+        return nullptr;
+    if (layout && layout->HasMergedParas() && node->GetRedlineMergeFlag() == 
SwNode::Merge::Hidden)
+        return nullptr;
+    auto pFrame = node->getLayoutFrame(layout);
+    if (!pFrame)
+        return nullptr;
+    if (fromChapter && !IsHeadingContained(chapter, *node))
+        return nullptr;
+    if (pFrame->IsHiddenNow())
+        return nullptr;
+
+    return pFrame;
+}
+
+static bool useTextNodeForIndex(const SwTextNode* node, int maxLevel, bool 
fromChapter,
+                                const SwTextNode* chapter, const SwRootFrame* 
layout)
+{
+    auto pTextFrame = static_cast<const 
SwTextFrame*>(useContentNodeForIndex(node, fromChapter, chapter, layout));
+    if (!pTextFrame)
+        return false;
+    if (node->Len() == 0)
+        return false;
+    if (maxLevel >= 0 && node->GetAttrOutlineLevel() > maxLevel)
+        return false;
+    if (node->IsHiddenByParaField())
+        return false;
+    if (node->HasHiddenCharAttribute(true))
+        return false;
+    if (layout && layout->HasMergedParas() && 
pTextFrame->GetTextNodeForParaProps() != node)
+        return false;
+
+    return true;
+}
+
 /// Generate table of contents from outline
 void SwTOXBaseSection::UpdateOutline( const SwTextNode* pOwnChapterNode,
         SwRootFrame const*const pLayout)
@@ -1356,14 +1398,7 @@ void SwTOXBaseSection::UpdateOutline( const SwTextNode* 
pOwnChapterNode,
     {
         ::SetProgressState( 0, pDoc->GetDocShell() );
         SwTextNode* pTextNd = pOutlineNode->GetTextNode();
-        if( pTextNd && pTextNd->Len() && pTextNd->HasWriterListeners() &&
-            o3tl::make_unsigned( pTextNd->GetAttrOutlineLevel()) <= GetLevel() 
&&
-            pTextNd->getLayoutFrame(pLayout) &&
-           !pTextNd->IsHiddenByParaField() &&
-           !pTextNd->HasHiddenCharAttribute( true ) &&
-           (!pLayout || !pLayout->HasMergedParas()
-                || 
static_cast<SwTextFrame*>(pTextNd->getLayoutFrame(pLayout))->GetTextNodeForParaProps()
 == pTextNd) &&
-            ( !IsFromChapter() || IsHeadingContained(pOwnChapterNode, 
*pTextNd) ))
+        if (useTextNodeForIndex(pTextNd, GetLevel(), IsFromChapter(), 
pOwnChapterNode, pLayout))
         {
             InsertSorted(MakeSwTOXSortTabBase<SwTOXPara>(pLayout, *pTextNd, 
SwTOXElement::OutlineLevel));
         }
@@ -1374,6 +1409,7 @@ void SwTOXBaseSection::UpdateOutline( const SwTextNode* 
pOwnChapterNode,
 void SwTOXBaseSection::UpdateTemplate(const SwTextNode* pOwnChapterNode,
         SwRootFrame const*const pLayout)
 {
+    int nMaxLevel = SwTOXBase::GetType() == TOX_CONTENT ? GetLevel() : -1;
     SwDoc* pDoc = GetFormat()->GetDoc();
     for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
     {
@@ -1398,15 +1434,7 @@ void SwTOXBaseSection::UpdateTemplate(const SwTextNode* 
pOwnChapterNode,
             {
                 ::SetProgressState( 0, pDoc->GetDocShell() );
 
-                if (pTextNd->GetText().getLength() &&
-                    pTextNd->getLayoutFrame(pLayout) &&
-                    pTextNd->GetNodes().IsDocNodes() &&
-                    // tdf#40142 - consider level settings of the various text 
nodes
-                    (TOX_CONTENT != SwTOXBase::GetType() ||
-                     o3tl::make_unsigned(pTextNd->GetAttrOutlineLevel()) <= 
GetLevel()) &&
-                    (!pLayout || !pLayout->HasMergedParas()
-                        || 
static_cast<SwTextFrame*>(pTextNd->getLayoutFrame(pLayout))->GetTextNodeForParaProps()
 == pTextNd) &&
-                    (!IsFromChapter() || IsHeadingContained(pOwnChapterNode, 
*pTextNd)))
+                if (useTextNodeForIndex(pTextNd, nMaxLevel, IsFromChapter(), 
pOwnChapterNode, pLayout))
                 {
                     InsertSorted(MakeSwTOXSortTabBase<SwTOXPara>(pLayout, 
*pTextNd, SwTOXElement::Template, i + 1));
                 }
@@ -1432,9 +1460,7 @@ void SwTOXBaseSection::UpdateSequence(const SwTextNode* 
pOwnChapterNode,
         SwTextNode& rTextNode = pTextField->GetTextNode();
         ::SetProgressState( 0, pDoc->GetDocShell() );
 
-        if (rTextNode.GetText().getLength() &&
-            rTextNode.getLayoutFrame(pLayout) &&
-            ( !IsFromChapter() || IsHeadingContained(pOwnChapterNode, 
rTextNode))
+        if (useTextNodeForIndex(&rTextNode, -1, IsFromChapter(), 
pOwnChapterNode, pLayout)
             && (!pLayout || !pLayout->IsHideRedlines()
                 || 
!sw::IsFieldDeletedInModel(pDoc->getIDocumentRedlineAccess(), *pTextField)))
         {
@@ -1475,8 +1501,7 @@ void SwTOXBaseSection::UpdateAuthorities(const 
SwTOXInternational& rIntl,
         const SwTextNode& rTextNode = 
pFormatField->GetTextField()->GetTextNode();
         ::SetProgressState( 0, pDoc->GetDocShell() );
 
-        if (rTextNode.GetText().getLength() &&
-            rTextNode.getLayoutFrame(pLayout) &&
+        if (useTextNodeForIndex(&rTextNode, -1, false, nullptr, pLayout) &&
             (!pLayout || !pLayout->IsHideRedlines()
                 || 
!sw::IsFieldDeletedInModel(pDoc->getIDocumentRedlineAccess(), *pTextField)))
         {
@@ -1624,10 +1649,7 @@ void SwTOXBaseSection::UpdateContent( SwTOXElement 
eMyType,
                 }
             }
 
-            if (pCNd->getLayoutFrame(pLayout)
-                && (!pLayout || !pLayout->HasMergedParas()
-                    || pCNd->GetRedlineMergeFlag() != SwNode::Merge::Hidden)
-                && ( !IsFromChapter() || IsHeadingContained(pOwnChapterNode, 
*pCNd)))
+            if (useContentNodeForIndex(pCNd, IsFromChapter(), pOwnChapterNode, 
pLayout))
             {
                 std::unique_ptr<SwTOXPara> pNew( 
MakeSwTOXSortTabBase<SwTOXPara>(
                         pLayout, *pCNd, eMyType,
@@ -1665,10 +1687,7 @@ void SwTOXBaseSection::UpdateTable(const SwTextNode* 
pOwnChapterNode,
             while( nullptr != ( pCNd = rNds.GoNext( &aContentIdx ) ) &&
                 aContentIdx.GetIndex() < pTableNd->EndOfSectionIndex() )
             {
-                if (pCNd->getLayoutFrame(pLayout)
-                    && (!pLayout || !pLayout->HasMergedParas()
-                        || pCNd->GetRedlineMergeFlag() != 
SwNode::Merge::Hidden)
-                    && (!IsFromChapter() || 
IsHeadingContained(pOwnChapterNode, *pCNd)))
+                if (useContentNodeForIndex(pCNd, IsFromChapter(), 
pOwnChapterNode, pLayout))
                 {
                     std::unique_ptr<SwTOXTable> pNew(new SwTOXTable( *pCNd ));
                     if( IsLevelFromChapter() && TOX_TABLES != 
SwTOXBase::GetType())
diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx
index b29bafde11f6..04f75df0f7c9 100644
--- a/sw/source/core/tox/tox.cxx
+++ b/sw/source/core/tox/tox.cxx
@@ -194,6 +194,9 @@ void SwTOXMark::Notify(const SfxHint& rHint)
         // Check for being hidden by hidden redlines
         if (pLayout && pLayout->HasMergedParas() && 
sw::IsMarkHintHidden(*pLayout, rNode, rTextMark))
             return;
+        // Check for being hidden by hidden sections
+        if (auto pFrame(rNode.getLayoutFrame(pLayout)); !pFrame || 
pFrame->IsHiddenNow())
+            return;
         pCollectLayoutHint->m_rMarks.push_back(rTextMark);
     }
 }
commit fe74b997a4d7b3bdd9f93bddfaf0103f8f92f365
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Fri Dec 6 14:24:12 2024 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Dec 12 15:12:31 2024 +0100

    sw: layout: ignore Keep-With-Next on hidden frames, part3
    
    SwTabFrame: :MakeAll(), SwRowFrame::ShouldRowKeepWithNext()
    Change-Id: I7cb6e558dc05736658a9bc75d6c735e6a47062b0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177977
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Tested-by: Jenkins
    (cherry picked from commit afab0fa906a1bb9281378774586fe07193cba41d)

diff --git a/sw/source/core/layout/flowfrm.cxx 
b/sw/source/core/layout/flowfrm.cxx
index 672997dd417f..e49af1e31549 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -258,6 +258,7 @@ bool SwFlowFrame::IsKeep(SvxFormatKeepItem const& rKeep,
         SvxFormatBreakItem const& rBreak,
         bool const bCheckIfLastRowShouldKeep) const
 {
+    assert(!m_rThis.IsHiddenNow()); // check it before?
     // 1. The keep attribute is ignored inside footnotes
     // 2. For compatibility reasons, the keep attribute is
     //    ignored for frames inside table cells
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 886b7e0ddaf4..c88099b31caf 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -2210,7 +2210,7 @@ void SwTabFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
         && !pAttrs->GetAttrSet().GetKeep().GetValue()
         && AreAllRowsKeepWithNext(GetFirstNonHeadlineRow(), 
/*bCheckParents=*/false);
     // The beloved keep attribute
-    const bool bKeep = IsKeep(pAttrs->GetAttrSet().GetKeep(), GetBreakItem(), 
bEmulateTableKeep);
+    const bool bKeep{!isHiddenNow && IsKeep(pAttrs->GetAttrSet().GetKeep(), 
GetBreakItem(), bEmulateTableKeep)};
 
     // Join follow table, if this table is not allowed to split:
     if ( bDontSplit )
@@ -2308,9 +2308,8 @@ void SwTabFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
                 }
                 aNotify.SetLowersComplete( false );
             }
-            SwFrame *pPre;
-            if ( bKeep || (nullptr != (pPre = FindPrev()) &&
-                pPre->GetAttrSet()->GetKeep().GetValue()) )
+            SwFrame const*const pPre{bKeep ? nullptr : FindPrevIgnoreHidden()};
+            if (bKeep || (nullptr != pPre && 
pPre->GetAttrSet()->GetKeep().GetValue()))
             {
                 m_bCalcLowers = true;
             }
@@ -2665,7 +2664,8 @@ void SwTabFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
                             oAccess.emplace(SwFrame::GetCache(), this);
                             pAttrs = oAccess->Get();
                         }
-                        if (IsKeep(pAttrs->GetAttrSet().GetKeep(), 
GetBreakItem(), true)
+                        if (!isHiddenNow
+                            && IsKeep(pAttrs->GetAttrSet().GetKeep(), 
GetBreakItem(), true)
                             && pLastRow->ShouldRowKeepWithNext())
                         {
                             bFormat = true;
@@ -5511,7 +5511,7 @@ bool SwRowFrame::ShouldRowKeepWithNext( const bool 
bCheckParents ) const
     const SwCellFrame* pCell = static_cast<const SwCellFrame*>(Lower());
     const SwFrame* pText = pCell->Lower();
 
-    return pText && pText->IsTextFrame() &&
+    return pText && pText->IsTextFrame() && !pText->IsHiddenNow() &&
            static_cast<const 
SwTextFrame*>(pText)->GetTextNodeForParaProps()->GetSwAttrSet().GetKeep(bCheckParents).GetValue();
 }
 
commit 19f4ce69602b8f7c659dc44043b4e5441b23805c
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Fri Dec 6 14:20:22 2024 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Dec 12 15:12:10 2024 +0100

    sw: layout: ignore Keep-With-Next on hidden frames, part2
    
    SwFrame::PrepareMake(), SwContentFrame::MakeAll(),
    SwContentFrame::WouldFit_()
    
    Change-Id: I2a909ac6d147668dddece97bd99e31fdddcf20eb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177976
    Tested-by: Michael Stahl <michael.st...@allotropia.de>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit a08b8fa2d01e630ef876b7944c37f0b6de09d407)

diff --git a/sw/source/core/layout/calcmove.cxx 
b/sw/source/core/layout/calcmove.cxx
index c69bf60d2e33..011cad8d901e 100644
--- a/sw/source/core/layout/calcmove.cxx
+++ b/sw/source/core/layout/calcmove.cxx
@@ -304,9 +304,17 @@ void SwFrame::PrepareMake(vcl::RenderContext* 
pRenderContext)
 
         // There is no format of previous frame, if current frame is a table
         // frame and its previous frame wants to keep with it.
-        const bool bFormatPrev = !bTab ||
-                                 !GetPrev() ||
-                                 
!GetPrev()->GetAttrSet()->GetKeep().GetValue();
+        bool bFormatPrev{!bTab};
+        if (!bFormatPrev)
+        {
+            SwFrame const* pPrev{this};
+            do
+            {
+                pPrev = pPrev->GetPrev();
+            }
+            while (pPrev && pPrev->IsHiddenNow());
+            bFormatPrev = pPrev && !pPrev->GetAttrSet()->GetKeep().GetValue();
+        }
         if ( bFormatPrev )
         {
             SwFrame *pFrame = GetUpper()->Lower();
@@ -1341,7 +1349,7 @@ void SwContentFrame::MakeAll(vcl::RenderContext* 
/*pRenderContext*/)
         oNotify->SetBordersJoinedWithPrev();
     }
 
-    const bool bKeep = IsKeep(rAttrs.GetAttrSet().GetKeep(), GetBreakItem());
+    const bool bKeep{!isHiddenNow && IsKeep(rAttrs.GetAttrSet().GetKeep(), 
GetBreakItem())};
 
     std::unique_ptr<SwSaveFootnoteHeight> pSaveFootnote;
     if ( bFootnote )
@@ -1759,7 +1767,7 @@ void SwContentFrame::MakeAll(vcl::RenderContext* 
/*pRenderContext*/)
 
         if( nBottomDist >= 0 )
         {
-            if ( bKeep && bMoveable )
+            if (bKeep && bMoveable && !isHiddenNow)
             {
                 // We make sure the successor will be formatted the same.
                 // This way, we keep control until (almost) everything is 
stable,
@@ -2086,8 +2094,18 @@ bool SwContentFrame::WouldFit_( SwTwips nSpace,
     const SwFrame *pTmpPrev = pNewUpper->Lower();
     if( pTmpPrev && pTmpPrev->IsFootnoteFrame() )
         pTmpPrev = static_cast<const SwFootnoteFrame*>(pTmpPrev)->Lower();
-    while ( pTmpPrev && pTmpPrev->GetNext() )
-        pTmpPrev = pTmpPrev->GetNext();
+    {
+        SwFrame const* pTmpNonHidden{pTmpPrev && pTmpPrev->IsHiddenNow() ? 
nullptr : pTmpPrev};
+        while (pTmpPrev && pTmpPrev->GetNext())
+        {
+            pTmpPrev = pTmpPrev->GetNext();
+            if (!pTmpPrev->IsHiddenNow())
+            {
+                pTmpNonHidden = pTmpPrev;
+            }
+        }
+        pTmpPrev = pTmpNonHidden;
+    }
 
     // tdf#156727 if the previous one has keep-with-next, ignore it on this 
one!
     bool const isIgnoreKeep(pTmpPrev && pTmpPrev->IsFlowFrame()
@@ -2096,6 +2114,14 @@ bool SwContentFrame::WouldFit_( SwTwips nSpace,
 
     do
     {
+        if (pFrame->IsHiddenNow())
+        {   // shortcut
+            assert(pFrame == this);
+            bRet = true;
+            pFrame = nullptr;
+            break;
+        }
+
         // #i46181#
         SwTwips nSecondCheck = 0;
         SwTwips nOldSpace = nSpace;
@@ -2261,8 +2287,8 @@ bool SwContentFrame::WouldFit_( SwTwips nSpace,
                     return true;
                 }
             }
-            SwFrame *pNxt;
-            if( nullptr != (pNxt = pFrame->FindNext()) && 
pNxt->IsContentFrame() &&
+            SwFrame *const pNxt{pFrame->FindNextIgnoreHidden()};
+            if (nullptr != pNxt && pNxt->IsContentFrame() &&
                 ( !pFootnoteFrame || ( pNxt->IsInFootnote() &&
                   pNxt->FindFootnoteFrame()->GetAttr() == 
pFootnoteFrame->GetAttr() ) ) )
             {
@@ -2288,10 +2314,7 @@ bool SwContentFrame::WouldFit_( SwTwips nSpace,
                     pTmpPrev = nullptr;
                 else
                 {
-                    if (pFrame->IsHiddenNow())
-                        pTmpPrev = lcl_NotHiddenPrev( pFrame );
-                    else
-                        pTmpPrev = pFrame;
+                    pTmpPrev = pFrame;
                 }
                 pFrame = static_cast<SwContentFrame*>(pNxt);
             }
commit dbfffbcec75d0cc26117a1ebe82c9ac2a09afc35
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Fri Dec 6 14:10:32 2024 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Dec 12 15:11:52 2024 +0100

    sw: layout: ignore Keep-With-Next on hidden frames, part1
    
    When a frame is hidden, don't consider it when evaluating keep-with-next
    attributes - this was the case for content in hidden sections before
    commit 0c96119895b347f8eb5bb89f393351bd3c02b9f1
    
    ~SwFrameNotify() invalidating position of hidden frame with keep
    attribute causes layout loops.
    
    Also skip hidden frames in SwFlowFrame::IsKeepFwdMoveAllowed(),
    SwFlowFrame::CheckKeep(), SwFlowFrame::IsPrevObjMove(),
    SwFlowFrame::MoveBwd(), CalcContent().
    
    Change-Id: I68556ba0a8e016d962399f3ce199e5eda0378867
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177975
    Tested-by: Michael Stahl <michael.st...@allotropia.de>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit cd8468bcba952ab9b0d6ca97152a63d7469a9209)

diff --git a/sw/source/core/inc/flowfrm.hxx b/sw/source/core/inc/flowfrm.hxx
index 3d271613bf6a..bfc99cc09961 100644
--- a/sw/source/core/inc/flowfrm.hxx
+++ b/sw/source/core/inc/flowfrm.hxx
@@ -184,6 +184,9 @@ public:
                 SvxFormatBreakItem const& rBreak,
                 bool bBreakCheck = false ) const;
 
+    SwFrame * FindPrevIgnoreHidden() const;
+    SwFrame * FindNextIgnoreHidden() const;
+
     bool HasLockedFollow() const;
 
     bool HasParaSpaceAtPages( bool bSct ) const;
diff --git a/sw/source/core/layout/flowfrm.cxx 
b/sw/source/core/layout/flowfrm.cxx
index e3d6a7b7e4ad..672997dd417f 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -131,7 +131,9 @@ bool SwFlowFrame::IsKeepFwdMoveAllowed( bool 
bIgnoreMyOwnKeepValue )
         if ( bIgnoreMyOwnKeepValue && pFrame->GetIndPrev() )
             pFrame = pFrame->GetIndPrev();
         do
-        {   if ( pFrame->GetAttrSet()->GetKeep().GetValue() )
+        {
+            if (pFrame->GetAttrSet()->GetKeep().GetValue()
+                || pFrame->IsHiddenNow())
                 pFrame = pFrame->GetIndPrev();
             else
                 return true;
@@ -150,22 +152,42 @@ void SwFlowFrame::CheckKeep()
     // it's possible for the whole troop to move back.
     SwFrame *pPre = m_rThis.GetIndPrev();
     assert(pPre);
+    while (pPre && pPre->IsHiddenNow())
+    {
+        pPre = pPre->GetIndPrev();
+    }
+    if (!pPre)
+    {
+        return;
+    }
     if( pPre->IsSctFrame() )
     {
         SwFrame *pLast = static_cast<SwSectionFrame*>(pPre)->FindLastContent();
+        while (pLast && pLast->IsHiddenNow())
+        {
+            pLast = pLast->GetIndPrev();
+        }
         if( pLast && pLast->FindSctFrame() == pPre )
             pPre = pLast;
         else
             return;
     }
-    SwFrame* pTmp;
+    SwFrame* pTmp{pPre};
     bool bKeep;
     while ( (bKeep = pPre->GetAttrSet()->GetKeep().GetValue()) &&
-            nullptr != ( pTmp = pPre->GetIndPrev() ) )
+            nullptr != (pTmp = pTmp->GetIndPrev()) )
     {
+        if (pTmp->IsHiddenNow())
+        {
+            continue;
+        }
         if( pTmp->IsSctFrame() )
         {
             SwFrame *pLast = 
static_cast<SwSectionFrame*>(pTmp)->FindLastContent();
+            while (pLast && pLast->IsHiddenNow())
+            {
+                pLast = pLast->GetIndPrev();
+            }
             if( pLast && pLast->FindSctFrame() == pTmp )
                 pTmp = pLast;
             else
@@ -338,6 +360,26 @@ bool SwFlowFrame::IsKeep(SvxFormatKeepItem const& rKeep,
     return bKeep;
 }
 
+SwFrame * SwFlowFrame::FindPrevIgnoreHidden() const
+{
+    SwFrame * pRet{m_rThis.FindPrev()};
+    while (pRet && pRet->IsHiddenNow())
+    {
+        pRet = pRet->FindPrev();
+    }
+    return pRet;
+}
+
+SwFrame * SwFlowFrame::FindNextIgnoreHidden() const
+{
+    SwFrame * pRet{m_rThis.FindNext()};
+    while (pRet && pRet->IsHiddenNow())
+    {
+        pRet = pRet->FindNext();
+    }
+    return pRet;
+}
+
 sal_uInt8 SwFlowFrame::BwdMoveNecessary( const SwPageFrame *pPage, const 
SwRect &rRect )
 {
     // The return value helps deciding whether we need to flow back (3),
@@ -1188,7 +1230,7 @@ bool SwFlowFrame::IsPrevObjMove() const
     if( pSh && pSh->GetViewOptions()->getBrowseMode() )
         return false;
 
-    SwFrame *pPre = m_rThis.FindPrev();
+    SwFrame *const pPre{FindPrevIgnoreHidden()};
 
     if ( pPre && pPre->GetDrawObjs() )
     {
@@ -2587,7 +2629,7 @@ bool SwFlowFrame::MoveBwd( bool &rbReformat )
     // keep with next frame and next frame is locked.
     // i#38232 - If next frame is a table, do *not* check,
     // if it's locked.
-    if ( pNewUpper && !IsFollow() &&
+    if ( pNewUpper && !IsFollow() && !m_rThis.IsHiddenNow() &&
          m_rThis.GetAttrSet()->GetKeep().GetValue() && m_rThis.GetIndNext() )
     {
         SwFrame* pIndNext = m_rThis.GetIndNext();
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index fd95ce192cf7..b4b8fbafb18d 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -1682,9 +1682,10 @@ void CalcContent( SwLayoutFrame *pLay, bool bNoColl )
             // frame due to its keep-attribute, if it can't move forward.
             // #i57765# - do not consider invalid previous
             // frame, if current frame has a column/page break before 
attribute.
-            SwFrame* pTmpPrev = pFrame->FindPrev();
+            assert(pFrame->IsFlowFrame());
+            SwFlowFrame* pTmpFlowFrame = SwFlowFrame::CastFlowFrame(pFrame);
+            SwFrame* pTmpPrev = pTmpFlowFrame->FindPrevIgnoreHidden();
             SwFlowFrame* pTmpPrevFlowFrame = pTmpPrev && 
pTmpPrev->IsFlowFrame() ? SwFlowFrame::CastFlowFrame(pTmpPrev) : nullptr;
-            SwFlowFrame* pTmpFlowFrame     = pFrame->IsFlowFrame() ? 
SwFlowFrame::CastFlowFrame(pFrame) : nullptr;
 
             bool bPrevInvalid = pTmpPrevFlowFrame && pTmpFlowFrame &&
                                !pTmpFlowFrame->IsFollow() &&
diff --git a/sw/source/core/layout/frmtool.cxx 
b/sw/source/core/layout/frmtool.cxx
index d7d97c64c189..48d93fbabbfc 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -155,7 +155,7 @@ void SwFrameNotify::ImplDestroy()
             {
                 if ( mbInvaKeep )
                 {
-                    SwFrame *pPre = mpFrame->FindPrev();
+                    SwFrame *pPre = pFlow->FindPrevIgnoreHidden();
                     if ( pPre && pPre->IsFlowFrame() )
                     {
                         // 1. pPre wants to keep with me:
commit b014c56ff6a8e0935ba2e07b202d6b67e878bd07
Author:     Andreas Heinisch <andreas.heini...@yahoo.de>
AuthorDate: Mon Nov 25 09:17:45 2024 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Dec 12 15:07:55 2024 +0100

    tdf#163325 - Check Lower() frame during ToC preview
    
    Change-Id: Ife0e974d66d5ddbe3c831c64e4da28442e476da4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177234
    Reviewed-by: Andreas Heinisch <andreas.heini...@yahoo.de>
    Tested-by: Jenkins
    (cherry picked from commit 2145204724049cad1585743c0b980ed2c6561212)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177529
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit 2d57e13895703b541b918c0933b7dc5bbe25c300)

diff --git a/sw/qa/uitest/data/tdf163325.odt b/sw/qa/uitest/data/tdf163325.odt
new file mode 100644
index 000000000000..3d2e6e8673cf
Binary files /dev/null and b/sw/qa/uitest/data/tdf163325.odt differ
diff --git a/sw/qa/uitest/writer_tests5/tdf163325.py 
b/sw/qa/uitest/writer_tests5/tdf163325.py
new file mode 100644
index 000000000000..391859cdb715
--- /dev/null
+++ b/sw/qa/uitest/writer_tests5/tdf163325.py
@@ -0,0 +1,35 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+import org.libreoffice.unotest
+from uitest.framework import UITestCase
+from uitest.uihelper.common import get_url_for_data_file, get_state_as_dict
+
+class tdf163325(UITestCase):
+
+    def test_tdf163325_toc_preview_crash(self):
+        with self.ui_test.load_file(get_url_for_data_file("tdf163325.odt")):
+            # Open ToC dialog and check index preview
+            with 
self.ui_test.execute_dialog_through_command(".uno:InsertMultiIndex") as 
xTocDialog:
+                xShowExample = xTocDialog.getChild("showexample")
+                xShowExample.executeAction("CLICK", tuple())
+                self.assertEqual(get_state_as_dict(xShowExample)["Selected"], 
"true")
+
+            # Save, reload and update all indexes in the document
+            self.xUITest.executeCommand('.uno:Save')
+            self.xUITest.executeCommand('.uno:Reload')
+            # Without the fix in place, this test would have crashed here
+            self.xUITest.executeCommand(".uno:UpdateAllIndexes")
+
+        with self.ui_test.load_file(get_url_for_data_file("tdf163325.odt")) as 
document:
+            # Check that the index is present
+            xDocumentIndexes = document.DocumentIndexes
+            self.assertEqual(len(xDocumentIndexes), 1)
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/source/core/layout/sectfrm.cxx 
b/sw/source/core/layout/sectfrm.cxx
index 578abc36e513..92f8c0cdc865 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -2754,7 +2754,8 @@ void SwSectionFrame::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
         }
 
         InvalidateFramesInSection(Lower());
-        Lower()->HideAndShowObjects(); // recursive
+        if (Lower())
+            Lower()->HideAndShowObjects(); // recursive
         // Check if any page-breaks have been unhidden, create the new pages.
         // Call IsHiddenNow() because a parent section could still hide.
         if (!IsFollow() && IsInDocBody() && !IsInTab() && !IsHiddenNow())
@@ -2783,8 +2784,9 @@ void SwSectionFrame::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
                 pFirstOnPage = pFirstOnPage->GetUpper();
             }
             assert(pFirstOnPage->IsContentFrame() || 
pFirstOnPage->IsTabFrame());
-            SwColumnFrame * pColumn{Lower()->IsColumnFrame()
-                    ? static_cast<SwColumnFrame*>(Lower()) : nullptr};
+            SwColumnFrame* pColumn{ Lower() && Lower()->IsColumnFrame()
+                                        ? static_cast<SwColumnFrame*>(Lower())
+                                        : nullptr };
             auto IterateLower = [&pColumn](SwFrame *const pLowerFrame) -> 
SwFrame*
             {
                 if (pLowerFrame->GetNext())
commit 028b5f7d64a83157533d177b6081ddf3b2d3308f
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Fri Nov 29 11:49:39 2024 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Dec 12 15:06:40 2024 +0100

    sw: layout: fix toggling Hidden Paragraphs not shrinking flys
    
    There are 2 as-char flys with 2 hidden paragraphs each, and when turning
    off show hidden paragraphs, the paragraphs shrink to height 0 but the
    flys don't - this is because due to other hidden paragraphs earlier, the
    position of the flys change and Shrink() is called before MakePos() and
    then it uses the old position to check and that results in a negative
    nRstHeight, so the upper doesn't actually shrink.
    
    Fix this by always calling MakePos() before MakeValidZeroHeight().
    
    (presumably regression from commit
     0c96119895b347f8eb5bb89f393351bd3c02b9f1 or one of its follow-ups)
    
    Change-Id: I9a4ffadff02b6a2bc59c6a37aa15abec429e1068
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177524
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Tested-by: Jenkins
    (cherry picked from commit 0795698c1c82b4026a0f6acdfba5c6b93c8e1412)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177559
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    (cherry picked from commit d3d71061c6e8842c7a215e68ef48f7ea2b271ff5)

diff --git a/sw/qa/extras/layout/data/hidden-para-as-char-fly.fodt 
b/sw/qa/extras/layout/data/hidden-para-as-char-fly.fodt
new file mode 100644
index 000000000000..a3a524691b5e
--- /dev/null
+++ b/sw/qa/extras/layout/data/hidden-para-as-char-fly.fodt
@@ -0,0 +1,279 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document xmlns:officeooo="http://openoffice.org/2009/office"; 
xmlns:css3t="http://www.w3.org/TR/css3-text/"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:dc="http://purl.org/dc/eleme
 nts/1.1/" xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 xmlns:math="http://www.w3.org/1998/Math/MathML"; 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0
 " xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:xforms="http://www.w3.org/2002/xforms"; office:version="1.2" 
office:mimetype="application/vnd.oasis.opendocument.text">
+ 
<office:meta><meta:creation-date>2024-11-29T14:11:48.126766636</meta:creation-date><dc:date>2024-11-29T14:16:02.135004394</dc:date><meta:editing-duration>PT4M14S</meta:editing-duration><meta:editing-cycles>1</meta:editing-cycles><meta:document-statistic
 meta:table-count="0" meta:image-count="0" meta:object-count="0" 
meta:page-count="1" meta:paragraph-count="2" meta:word-count="1" 
meta:character-count="3" 
meta:non-whitespace-character-count="3"/><meta:generator>CIB_OfficeDev/6.4.0.29$Linux_X86_64
 
LibreOffice_project/5374b230ff33d77a7f81d56046759f218a160036</meta:generator></office:meta>
+ <office:settings>
+  <config:config-item-set config:name="ooo:view-settings">
+   <config:config-item config:name="ViewAreaTop" 
config:type="long">0</config:config-item>
+   <config:config-item config:name="ViewAreaLeft" 
config:type="long">0</config:config-item>
+   <config:config-item config:name="ViewAreaWidth" 
config:type="long">24396</config:config-item>
+   <config:config-item config:name="ViewAreaHeight" 
config:type="long">15242</config:config-item>
+   <config:config-item config:name="ShowRedlineChanges" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="InBrowseMode" 
config:type="boolean">false</config:config-item>
+   <config:config-item-map-indexed config:name="Views">
+    <config:config-item-map-entry>
+     <config:config-item config:name="ViewId" 
config:type="string">view2</config:config-item>
+     <config:config-item config:name="ViewLeft" 
config:type="long">4050</config:config-item>
+     <config:config-item config:name="ViewTop" 
config:type="long">3341</config:config-item>
+     <config:config-item config:name="VisibleLeft" 
config:type="long">0</config:config-item>
+     <config:config-item config:name="VisibleTop" 
config:type="long">0</config:config-item>
+     <config:config-item config:name="VisibleRight" 
config:type="long">24395</config:config-item>
+     <config:config-item config:name="VisibleBottom" 
config:type="long">15240</config:config-item>
+     <config:config-item config:name="ZoomType" 
config:type="short">0</config:config-item>
+     <config:config-item config:name="ViewLayoutColumns" 
config:type="short">1</config:config-item>
+     <config:config-item config:name="ViewLayoutBookMode" 
config:type="boolean">false</config:config-item>
+     <config:config-item config:name="ZoomFactor" 
config:type="short">100</config:config-item>
+     <config:config-item config:name="IsSelectedFrame" 
config:type="boolean">false</config:config-item>
+     <config:config-item config:name="AnchoredTextOverflowLegacy" 
config:type="boolean">false</config:config-item>
+    </config:config-item-map-entry>
+   </config:config-item-map-indexed>
+  </config:config-item-set>
+  <config:config-item-set config:name="ooo:configuration-settings">
+   <config:config-item config:name="PrintProspect" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="PrintReversed" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="PrintSingleJobs" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="PrintLeftPages" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="PrintTables" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="PrintControls" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="PrintPageBackground" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="PrintDrawings" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="PrintBlackFonts" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="PrintAnnotationMode" 
config:type="short">0</config:config-item>
+   <config:config-item config:name="PrintTextPlaceholder" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="ProtectFields" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="ProtectBookmarks" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="EmptyDbFieldHidesPara" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="DisableOffPagePositioning" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="SubtractFlysAnchoredAtFlys" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="PropLineSpacingShrinksFirstLine" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="ApplyParagraphMarkFormatToNumbering" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="TreatSingleColumnBreakAsPageBreak" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="EmbedSystemFonts" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="EmbedComplexScriptFonts" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="EmbedAsianScriptFonts" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="EmbedLatinScriptFonts" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="EmbedOnlyUsedFonts" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="ContinuousEndnotes" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="EmbedFonts" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="ClippedPictures" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="FloattableNomargins" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="UnbreakableNumberings" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="HeaderSpacingBelowLastPara" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="AllowPrintJobCancel" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="UseOldPrinterMetrics" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="TabOverMargin" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="TabsRelativeToIndent" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="UseOldNumbering" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="InvertBorderSpacing" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="PrintPaperFromSetup" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="UpdateFromTemplate" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="CurrentDatabaseCommandType" 
config:type="int">0</config:config-item>
+   <config:config-item config:name="LinkUpdateMode" 
config:type="short">1</config:config-item>
+   <config:config-item config:name="AddParaSpacingToTableCells" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="CurrentDatabaseCommand" 
config:type="string"/>
+   <config:config-item config:name="PrinterIndependentLayout" 
config:type="string">high-resolution</config:config-item>
+   <config:config-item config:name="ApplyUserData" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="PrintFaxName" config:type="string"/>
+   <config:config-item config:name="CurrentDatabaseDataSource" 
config:type="string"/>
+   <config:config-item config:name="ClipAsCharacterAnchoredWriterFlyFrames" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="IsKernAsianPunctuation" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="SaveThumbnail" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="UseFormerTextWrapping" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="AddExternalLeading" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="AddParaTableSpacing" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="StylesNoDefault" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="ChartAutoUpdate" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="PrinterSetup" config:type="base64Binary"/>
+   <config:config-item config:name="AddParaTableSpacingAtStart" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="Rsid" 
config:type="int">1995778</config:config-item>
+   <config:config-item config:name="EmbeddedDatabaseName" 
config:type="string"/>
+   <config:config-item config:name="FieldAutoUpdate" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="OutlineLevelYieldsNumbering" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="AlignTabStopPosition" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="CharacterCompressionType" 
config:type="short">0</config:config-item>
+   <config:config-item config:name="PrinterName" config:type="string"/>
+   <config:config-item config:name="SaveGlobalDocumentLinks" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="PrinterPaperFromSetup" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="UseFormerLineSpacing" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="AddParaLineSpacingToTableCells" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="UseFormerObjectPositioning" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="PrintGraphics" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="SurroundTextWrapSmall" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="ConsiderTextWrapOnObjPos" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="MsWordCompTrailingBlanks" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="TabAtLeftIndentForParagraphsInList" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="PrintRightPages" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="IgnoreFirstLineIndentInNumbering" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="RedlineProtectionKey" 
config:type="base64Binary"/>
+   <config:config-item config:name="DoNotJustifyLinesWithManualBreak" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="PrintProspectRTL" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="PrintEmptyPages" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="DoNotResetParaAttrsForNumFont" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="AddFrameOffsets" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="IgnoreTabsAndBlanksForLineCalculation" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="LoadReadonly" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="DoNotCaptureDrawObjsOnPage" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="AddVerticalFrameOffsets" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="UnxForceZeroExtLeading" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="IsLabelDocument" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="TableRowKeep" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="RsidRoot" 
config:type="int">1995778</config:config-item>
+   <config:config-item config:name="PrintHiddenText" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="ProtectForm" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="MsWordCompMinLineHeightByFly" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="BackgroundParaOverDrawings" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="SaveVersionOnClose" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="MathBaselineAlignment" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="SmallCapsPercentage66" 
config:type="boolean">false</config:config-item>
+   <config:config-item config:name="CollapseEmptyCellPara" 
config:type="boolean">true</config:config-item>
+   <config:config-item config:name="TabOverflow" 
config:type="boolean">true</config:config-item>
+  </config:config-item-set>
+ </office:settings>
+ <office:scripts>
+  <office:script script:language="ooo:Basic">
+   <ooo:libraries xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:xlink="http://www.w3.org/1999/xlink"/>
+  </office:script>
+ </office:scripts>
+ <office:font-face-decls>
+  <style:font-face style:name="Lucida Sans1" svg:font-family="&apos;Lucida 
Sans&apos;" style:font-family-generic="swiss"/>
+  <style:font-face style:name="Liberation Serif" 
svg:font-family="&apos;Liberation Serif&apos;" 
style:font-family-generic="roman" style:font-pitch="variable"/>
+  <style:font-face style:name="Liberation Sans" 
svg:font-family="&apos;Liberation Sans&apos;" style:font-family-generic="swiss" 
style:font-pitch="variable"/>
+  <style:font-face style:name="Lucida Sans" svg:font-family="&apos;Lucida 
Sans&apos;" style:font-family-generic="system" style:font-pitch="variable"/>
+  <style:font-face style:name="Noto Sans CJK SC" svg:font-family="&apos;Noto 
Sans CJK SC&apos;" style:font-family-generic="system" 
style:font-pitch="variable"/>
+  <style:font-face style:name="Noto Serif CJK SC" svg:font-family="&apos;Noto 
Serif CJK SC&apos;" style:font-family-generic="system" 
style:font-pitch="variable"/>
+ </office:font-face-decls>
+ <office:styles>
+  <style:default-style style:family="graphic">
+   <style:graphic-properties svg:stroke-color="#3465a4" 
draw:fill-color="#729fcf" fo:wrap-option="no-wrap" draw:shadow-offset-x="0.3cm" 
draw:shadow-offset-y="0.3cm" draw:start-line-spacing-horizontal="0.283cm" 
draw:start-line-spacing-vertical="0.283cm" 
draw:end-line-spacing-horizontal="0.283cm" 
draw:end-line-spacing-vertical="0.283cm" style:flow-with-text="false"/>
+   <style:paragraph-properties style:text-autospace="ideograph-alpha" 
style:line-break="strict" style:writing-mode="lr-tb" 
style:font-independent-line-spacing="false">
+    <style:tab-stops/>
+   </style:paragraph-properties>
+   <style:text-properties style:use-window-font-color="true" 
style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="de" 
fo:country="DE" style:letter-kerning="true" style:font-name-asian="Noto Serif 
CJK SC" style:font-size-asian="10.5pt" style:language-asian="zh" 
style:country-asian="CN" style:font-name-complex="Lucida Sans" 
style:font-size-complex="12pt" style:language-complex="hi" 
style:country-complex="IN"/>
+  </style:default-style>
+  <style:default-style style:family="paragraph">
+   <style:paragraph-properties fo:orphans="2" fo:widows="2" 
fo:hyphenation-ladder-count="no-limit" style:text-autospace="ideograph-alpha" 
style:punctuation-wrap="hanging" style:line-break="strict" 
style:tab-stop-distance="1.251cm" style:writing-mode="page"/>
+   <style:text-properties style:use-window-font-color="true" 
style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="de" 
fo:country="DE" style:letter-kerning="true" style:font-name-asian="Noto Serif 
CJK SC" style:font-size-asian="10.5pt" style:language-asian="zh" 
style:country-asian="CN" style:font-name-complex="Lucida Sans" 
style:font-size-complex="12pt" style:language-complex="hi" 
style:country-complex="IN" fo:hyphenate="false" 
fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2" 
loext:hyphenation-no-caps="false"/>
+  </style:default-style>
+  <style:default-style style:family="table">
+   <style:table-properties table:border-model="collapsing"/>
+  </style:default-style>
+  <style:default-style style:family="table-row">
+   <style:table-row-properties fo:keep-together="auto"/>
+  </style:default-style>
+  <style:style style:name="Standard" style:family="paragraph" 
style:class="text"/>
+  <style:style style:name="Heading" style:family="paragraph" 
style:parent-style-name="Standard" style:next-style-name="Text_20_body" 
style:class="text">
+   <style:paragraph-properties fo:margin-top="0.423cm" 
fo:margin-bottom="0.212cm" loext:contextual-spacing="false" 
fo:keep-with-next="always"/>
+   <style:text-properties style:font-name="Liberation Sans" 
fo:font-family="&apos;Liberation Sans&apos;" style:font-family-generic="swiss" 
style:font-pitch="variable" fo:font-size="14pt" style:font-name-asian="Noto 
Sans CJK SC" style:font-family-asian="&apos;Noto Sans CJK SC&apos;" 
style:font-family-generic-asian="system" style:font-pitch-asian="variable" 
style:font-size-asian="14pt" style:font-name-complex="Lucida Sans" 
style:font-family-complex="&apos;Lucida Sans&apos;" 
style:font-family-generic-complex="system" style:font-pitch-complex="variable" 
style:font-size-complex="14pt"/>
+  </style:style>
+  <style:style style:name="Text_20_body" style:display-name="Text body" 
style:family="paragraph" style:parent-style-name="Standard" style:class="text">
+   <style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.247cm" 
loext:contextual-spacing="false" fo:line-height="115%"/>
+  </style:style>
+  <style:style style:name="List" style:family="paragraph" 
style:parent-style-name="Text_20_body" style:class="list">
+   <style:text-properties style:font-size-asian="12pt" 
style:font-name-complex="Lucida Sans1" style:font-family-complex="&apos;Lucida 
Sans&apos;" style:font-family-generic-complex="swiss"/>
+  </style:style>
+  <style:style style:name="Caption" style:family="paragraph" 
style:parent-style-name="Standard" style:class="extra">
+   <style:paragraph-properties fo:margin-top="0.212cm" 
fo:margin-bottom="0.212cm" loext:contextual-spacing="false" 
text:number-lines="false" text:line-number="0"/>
+   <style:text-properties fo:font-size="12pt" fo:font-style="italic" 
style:font-size-asian="12pt" style:font-style-asian="italic" 
style:font-name-complex="Lucida Sans1" style:font-family-complex="&apos;Lucida 
Sans&apos;" style:font-family-generic-complex="swiss" 
style:font-size-complex="12pt" style:font-style-complex="italic"/>
+  </style:style>
+  <style:style style:name="Index" style:family="paragraph" 
style:parent-style-name="Standard" style:class="index">
+   <style:paragraph-properties text:number-lines="false" text:line-number="0"/>
+   <style:text-properties style:font-size-asian="12pt" 
style:font-name-complex="Lucida Sans1" style:font-family-complex="&apos;Lucida 
Sans&apos;" style:font-family-generic-complex="swiss"/>
+  </style:style>
+  <style:style style:name="Frame_20_contents" style:display-name="Frame 
contents" style:family="paragraph" style:parent-style-name="Standard" 
style:class="extra"/>
+  <style:style style:name="Frame" style:family="graphic">
+   <style:graphic-properties text:anchor-type="paragraph" svg:x="0cm" 
svg:y="0cm" fo:margin-left="0.201cm" fo:margin-right="0.201cm" 
fo:margin-top="0.201cm" fo:margin-bottom="0.201cm" style:wrap="parallel" 
style:number-wrapped-paragraphs="no-limit" style:wrap-contour="false" 
style:vertical-pos="top" style:vertical-rel="paragraph-content" 
style:horizontal-pos="center" style:horizontal-rel="paragraph-content" 
fo:padding="0.15cm" fo:border="0.06pt solid #000000"/>
+  </style:style>
+  <text:outline-style style:name="Outline">
+   <text:outline-level-style text:level="1" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="2" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="3" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="4" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="5" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="6" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="7" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="8" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="9" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="10" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+  </text:outline-style>
+  <text:notes-configuration text:note-class="footnote" style:num-format="1" 
text:start-value="0" text:footnotes-position="page" 
text:start-numbering-at="document"/>
+  <text:notes-configuration text:note-class="endnote" style:num-format="i" 
text:start-value="0"/>
+  <text:linenumbering-configuration text:number-lines="false" 
text:offset="0.499cm" style:num-format="1" text:number-position="left" 
text:increment="5"/>
+ </office:styles>
+ <office:automatic-styles>
+  <style:style style:name="P1" style:family="paragraph" 
style:parent-style-name="Standard">
+   <style:text-properties officeooo:rsid="001e7402" 
officeooo:paragraph-rsid="001e7402"/>
+  </style:style>
+  <style:style style:name="fr1" style:family="graphic" 
style:parent-style-name="Frame">
+   <style:graphic-properties style:vertical-pos="top" 
style:vertical-rel="baseline"/>
+  </style:style>
+  <style:page-layout style:name="pm1">
+   <style:page-layout-properties fo:page-width="21.001cm" 
fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" 
fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" 
fo:margin-right="2cm" style:writing-mode="lr-tb" 
style:footnote-max-height="0cm">
+    <style:footnote-sep style:width="0.018cm" 
style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" 
style:line-style="solid" style:adjustment="left" style:rel-width="25%" 
style:color="#000000"/>
+   </style:page-layout-properties>
+   <style:header-style/>
+   <style:footer-style/>
+  </style:page-layout>
+ </office:automatic-styles>
+ <office:master-styles>
+  <style:master-page style:name="Standard" style:page-layout-name="pm1"/>
+ </office:master-styles>
+ <office:body>
+  <office:text>
+   <text:sequence-decls>
+    <text:sequence-decl text:display-outline-level="0" 
text:name="Illustration"/>
+    <text:sequence-decl text:display-outline-level="0" text:name="Table"/>
+    <text:sequence-decl text:display-outline-level="0" text:name="Text"/>
+    <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
+    <text:sequence-decl text:display-outline-level="0" text:name="Figure"/>
+   </text:sequence-decls>
+   <text:p text:style-name="P1">Foo</text:p>
+   <text:p 
text:style-name="P1"><text:line-break/><text:line-break/><text:line-break/><text:line-break/><text:line-break/><text:line-break/><text:line-break/><text:line-break/><text:line-break/><text:line-break/><text:line-break/><text:line-break/><text:line-break/><text:line-break/><text:line-break/><text:line-break/><text:line-break/><text:line-break/><text:line-break/><text:line-break/><text:line-break/><text:line-break/><text:line-break/><text:hidden-paragraph
 text:condition="ooow:TRUE" text:is-hidden="true"/></text:p>
+   <text:p text:style-name="P1"><draw:frame draw:style-name="fr1" 
draw:name="Frame1" text:anchor-type="as-char" svg:width="2cm" draw:z-index="0">
+     <draw:text-box fo:min-height="0.499cm">
+      <text:p text:style-name="Frame_20_contents"/>
+      <text:p text:style-name="Frame_20_contents"><text:hidden-paragraph 
text:condition="ooow:TRUE" text:is-hidden="true"/></text:p>
+     </draw:text-box>
+    </draw:frame></text:p>
+  </office:text>
+ </office:body>
+</office:document>
\ No newline at end of file
diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx
index 6bd96fb35215..035678349da4 100644
--- a/sw/qa/extras/layout/layout3.cxx
+++ b/sw/qa/extras/layout/layout3.cxx
@@ -2029,6 +2029,53 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, 
testHiddenParagraphFollowFrame)
     }
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testHiddenParagraphFlys)
+{
+    createSwDoc("hidden-para-as-char-fly.fodt");
+
+    uno::Any aOldValue{ queryDispatchStatus(mxComponent, m_xContext, 
".uno:ShowHiddenParagraphs") };
+
+    Resetter g([this, aOldValue] {
+        uno::Sequence<beans::PropertyValue> argsSH(
+            comphelper::InitPropertySequence({ { "ShowHiddenParagraphs", 
aOldValue } }));
+        dispatchCommand(mxComponent, ".uno:ShowHiddenParagraphs", argsSH);
+    });
+
+    uno::Sequence<beans::PropertyValue> argsSH(
+        comphelper::InitPropertySequence({ { "ShowHiddenParagraphs", 
uno::Any(true) } }));
+    dispatchCommand(mxComponent, ".uno:ShowHiddenParagraphs", argsSH);
+    uno::Sequence<beans::PropertyValue> args(
+        comphelper::InitPropertySequence({ { "Fieldnames", uno::Any(false) } 
}));
+    dispatchCommand(mxComponent, ".uno:Fieldnames", args);
+    Scheduler::ProcessEventsToIdle();
+
+    {
+        xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+        assertXPath(pXmlDoc, 
"/root/page/body/txt[3]/anchored/fly/infos/bounds", "height",
+                    u"724"_ustr);
+        discardDumpedLayout();
+    }
+
+    dispatchCommand(mxComponent, ".uno:ShowHiddenParagraphs", {});
+
+    {
+        xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+        // the problem was that this did not shrink
+        assertXPath(pXmlDoc, 
"/root/page/body/txt[3]/anchored/fly/infos/bounds", "height",
+                    u"448"_ustr);
+        discardDumpedLayout();
+    }
+
+    dispatchCommand(mxComponent, ".uno:ShowHiddenParagraphs", {});
+
+    {
+        xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+        assertXPath(pXmlDoc, 
"/root/page/body/txt[3]/anchored/fly/infos/bounds", "height",
+                    u"724"_ustr);
+        discardDumpedLayout();
+    }
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testSectionUnhide)
 {
     createSwDoc("hiddensection.fodt");
diff --git a/sw/source/core/layout/calcmove.cxx 
b/sw/source/core/layout/calcmove.cxx
index 45c8526d0b88..c69bf60d2e33 100644
--- a/sw/source/core/layout/calcmove.cxx
+++ b/sw/source/core/layout/calcmove.cxx
@@ -965,9 +965,6 @@ void SwLayoutFrame::MakeAll(vcl::RenderContext* 
/*pRenderContext*/)
     const SwLayNotify aNotify( this );
     bool bVert = IsVertical();
 
-    if (IsHiddenNow())
-        MakeValidZeroHeight();
-
     SwRectFn fnRect = ( IsNeighbourFrame() == bVert )? fnRectHori : ( 
IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert );
 
     std::optional<SwBorderAttrAccess> oAccess;
@@ -976,7 +973,14 @@ void SwLayoutFrame::MakeAll(vcl::RenderContext* 
/*pRenderContext*/)
     while ( !isFrameAreaPositionValid() || !isFrameAreaSizeValid() || 
!isFramePrintAreaValid() )
     {
         if ( !isFrameAreaPositionValid() )
+        {
             MakePos();
+        }
+
+        if (IsHiddenNow())
+        {
+            MakeValidZeroHeight();
+        }
 
         if ( GetUpper() )
         {
@@ -1291,7 +1295,6 @@ void SwContentFrame::MakeAll(vcl::RenderContext* 
/*pRenderContext*/)
         {
             static_cast<SwTextFrame&>(*this).JoinFrame();
         }
-        MakeValidZeroHeight();
         HideAndShowObjects();
     }
 
@@ -1468,10 +1471,11 @@ void SwContentFrame::MakeAll(vcl::RenderContext* 
/*pRenderContext*/)
         if ( !isFrameAreaPositionValid() )
         {
             MakePos();
-            if (isHiddenNow && !isFrameAreaSizeValid())
-            {   // in a table cell, might be invalidated by ~SwLayNotify
-                MakeValidZeroHeight();
-            }
+        }
+
+        if (isHiddenNow)
+        {   // call this after MakePos() otherwise Shrink may not work
+            MakeValidZeroHeight();
         }
 
         //Set FixSize. VarSize is being adjusted by Format().
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index b1fb92470516..886b7e0ddaf4 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -2263,9 +2263,6 @@ void SwTabFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
         }
     }
 
-    if (isHiddenNow)
-        MakeValidZeroHeight();
-
     int nUnSplitted = 5; // Just another loop control :-(
     int nThrowAwayValidLayoutLimit = 5; // And another one :-(
     PosSizeOscillationControl posSizeOscillationControl; // And yet another 
one.
@@ -2288,6 +2285,11 @@ void SwTabFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
         Point aOldPos( aRectFnSet.GetPos(getFrameArea()) );
         MakePos();
 
+        if (isHiddenNow)
+        {   // after MakePos()
+            MakeValidZeroHeight();
+        }
+
         if ( aOldPos != aRectFnSet.GetPos(getFrameArea()) )
         {
             if ( aOldPos.Y() != aRectFnSet.GetTop(getFrameArea()) )
diff --git a/sw/source/core/layout/trvlfrm.cxx 
b/sw/source/core/layout/trvlfrm.cxx
index c7a74a4bc359..df07d117c374 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -1752,7 +1752,6 @@ void SwFrame::MakeValidZeroHeight()
     }
     setFrameAreaSizeValid(true);
     setFramePrintAreaValid(true);
-    setFrameAreaPositionValid(false);
 }
 
 /** @return the physical page number */
commit 6105635b7c0cdd204cb2434d4984950b2be47219
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Nov 28 17:08:41 2024 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Dec 12 15:05:27 2024 +0100

    sw: layout: fix toggling Hidden Paragraphs that have follows
    
    When a hidden paragraph is split across pages, there is nothing that
    joins its follow (SwContentFrame::MakePrtArea() has code to do it but it
    wasn't called even before the previous commit?) and when the follow is
    formatted is doesn't move back.
    
    So just join all follows asap in SwContentFrame::MakeAll().
    
    (presumably regression from commit
     0c96119895b347f8eb5bb89f393351bd3c02b9f1 or one of its follow-ups)
    
    Change-Id: Icecdf17c1c1e11a3b62c7e5bf2c6624f234c94f3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177500
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Tested-by: Jenkins
    (cherry picked from commit a60f016a89787a818e868fbfa5b714853ff44a78)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177558
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    (cherry picked from commit c7548a5ffb856b9c78b1cb85905e57182f63154f)

diff --git a/sw/qa/extras/layout/data/hidden-para-follow-frame.fodt 
b/sw/qa/extras/layout/data/hidden-para-follow-frame.fodt
new file mode 100644
index 000000000000..20b67c13afc9
--- /dev/null
+++ b/sw/qa/extras/layout/data/hidden-para-follow-frame.fodt
@@ -0,0 +1,113 @@
+<?xml version='1.0' encoding='UTF-8'?>
-e 
... etc. - the rest is truncated

Reply via email to