sw/qa/extras/layout/layout3.cxx            |    2 
 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      |    3 
 sw/qa/extras/uiwriter/uiwriter2.cxx        |    3 
 sw/source/core/doc/SwStyleNameMapper.cxx   |   28 +++++-
 sw/source/core/layout/flowfrm.cxx          |    1 
 sw/source/core/layout/tabfrm.cxx           |   12 +-
 sw/source/core/unocore/unostyle.cxx        |   14 +--
 11 files changed, 186 insertions(+), 26 deletions(-)

New commits:
commit e45f187870362ed4448f4a9fb96883b8431887fb
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Dec 5 12:22:14 2024 +0100
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Tue Dec 24 14:10:40 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
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178259
    Tested-by: Jenkins
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx
index 18d82ef1b089..6c4b6fc9852a 100644
--- a/sw/qa/extras/layout/layout3.cxx
+++ b/sw/qa/extras/layout/layout3.cxx
@@ -1041,7 +1041,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf155177)
     createSwDoc("tdf155177-1-min.odt");
 
     uno::Reference<beans::XPropertySet> xStyle(
-        getStyles(u"ParagraphStyles"_ustr)->getByName(u"Body Text"_ustr), 
uno::UNO_QUERY_THROW);
+        getStyles(u"ParagraphStyles"_ustr)->getByName(u"Text body"_ustr), 
uno::UNO_QUERY_THROW);
     CPPUNIT_ASSERT_EQUAL(sal_Int32(210), getProperty<sal_Int32>(xStyle, 
u"ParaTopMargin"_ustr));
 
     {
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 e4bfa18a442d..cf0a02a9e6b5 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -1215,6 +1215,28 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf133459)
     CPPUNIT_ASSERT_EQUAL(u"QQ YYYY"_ustr, getProperty<OUString>(xFormat, 
u"FormatString"_ustr));
 }
 
+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 3f181fc208a1..26cb80f305e5 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), 
u"CharAutoKerning"_ustr));
 
-    uno::Reference<beans::XPropertySet> 
xStyle(getStyles(u"ParagraphStyles"_ustr)->getByName(u"Default Paragraph 
Style"_ustr), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> 
xStyle(getStyles(u"ParagraphStyles"_ustr)->getByName(u"Standard"_ustr), 
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, u"CharAutoKerning"_ustr));
 }
@@ -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(u"ParagraphStyles"_ustr)->getByName(u"Default Paragraph 
Style"_ustr), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> 
xStyle(getStyles(u"ParagraphStyles"_ustr)->getByName(u"Standard"_ustr), 
uno::UNO_QUERY);
     //tdf107801: kerning info wasn't exported previously.
     CPPUNIT_ASSERT_EQUAL_MESSAGE("AutoKern should be true", true, 
getProperty<bool>(xStyle, u"CharAutoKerning"_ustr));
 }
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index eab15994c459..531a47646a13 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -736,7 +736,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(u"ParagraphStyles"_ustr), 
uno::UNO_QUERY);
-    uno::Reference<beans::XPropertySet> 
xStyle(xStylesAccess->getByName(u"Default Paragraph Style"_ustr), 
uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> 
xStyle(xStylesAccess->getByName(u"Standard"_ustr), 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, 
u"CharColor"_ustr));
 
diff --git a/sw/qa/extras/rtfexport/rtfexport4.cxx 
b/sw/qa/extras/rtfexport/rtfexport4.cxx
index 61c3b0963f18..b79fefd648d2 100644
--- a/sw/qa/extras/rtfexport/rtfexport4.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport4.cxx
@@ -685,8 +685,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf136587_noStyleName)
                              getProperty<sal_Int16>(xStyleProps, 
u"ParaAdjust"_ustr));
 
         // The problem was that the default style wasn't imported at all, so 
the fontsize was only 12.
-        xStyleProps.set(paragraphStyles->getByName(u"Default Paragraph 
Style"_ustr),
-                        uno::UNO_QUERY_THROW);
+        xStyleProps.set(paragraphStyles->getByName(u"Standard"_ustr), 
uno::UNO_QUERY_THROW);
         CPPUNIT_ASSERT_EQUAL(32.0f, getProperty<float>(xStyleProps, 
u"CharHeight"_ustr));
     };
     createSwDoc("tdf136587_noStyleName.rtf");
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx 
b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 7d7afac16253..ba590b600ddf 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -2620,8 +2620,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, 
testRTLparaStyle_LocaleArabic)
     saveAndReload(u"Office Open XML Text"_ustr);
 
     uno::Reference<beans::XPropertySet> xPageStyle(
-        getStyles(u"ParagraphStyles"_ustr)->getByName(u"Default Paragraph 
Style"_ustr),
-        uno::UNO_QUERY_THROW);
+        getStyles(u"ParagraphStyles"_ustr)->getByName(u"Standard"_ustr), 
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, 
u"WritingMode"_ustr));
diff --git a/sw/source/core/doc/SwStyleNameMapper.cxx 
b/sw/source/core/doc/SwStyleNameMapper.cxx
index a42a274b0526..0822f68ffa00 100644
--- a/sw/source/core/doc/SwStyleNameMapper.cxx
+++ b/sw/source/core/doc/SwStyleNameMapper.cxx
@@ -263,10 +263,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
         {
@@ -297,8 +305,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 45ba12a4e6fe..b163817d3aca 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -898,7 +898,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);
@@ -910,10 +910,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);
@@ -1355,7 +1355,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;
@@ -1369,7 +1371,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)
@@ -1377,7 +1379,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 0c2771cecef879d8f9c1877af34f0e57b3238a38
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Fri Dec 6 14:24:12 2024 +0100
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Tue Dec 24 14:10:27 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)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177997
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/sw/source/core/layout/flowfrm.cxx 
b/sw/source/core/layout/flowfrm.cxx
index 8a2bab2647bb..dbd9fbff238d 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 17482076099e..83a9414af546 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -2283,7 +2283,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 )
@@ -2403,9 +2403,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;
             }
@@ -2760,7 +2759,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;
@@ -5625,7 +5625,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();
 }
 

Reply via email to