sw/qa/extras/ooxmlexport/data/paragraph-mark2.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx           |   10 ++++++++++
 sw/source/core/unocore/unotext.cxx                 |   20 ++++++++++++++++++++
 3 files changed, 30 insertions(+)

New commits:
commit ac6d3c3841865891b92b2ceb15d8cf5b37f78792
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Fri May 15 13:32:07 2020 +0200
Commit:     Gabor Kelemen <kelemen.gab...@nisz.hu>
CommitDate: Tue Jul 14 18:10:53 2020 +0200

    tdf#127616 DOCX import: fix char style of empty paragraph
    
    When direct character formatting defined in w:pPr/w:rPr
    overwrites some character style properties (character
    style defined by w:pPr/w:rPr/w:rStyle), empty paragraphs
    lost such direct formatting, resulting for example,
    different page layout by different height of empty
    paragraphs. Also text of that originally empty paragraphs
    got different formatting during typing.
    
    Co-authored-by: Justin Luth <justin_l...@sil.org>
    
    Change-Id: Ic7b3a73d4d7364993cc58073c9e1a09a2711d1b3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94308
    Tested-by: Jenkins
    Reviewed-by: László Németh <nem...@numbertext.org>
    (cherry picked from commit fb001eab98934c5a4d0a8c6b9563f91337561b87)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98759
    Tested-by: Gabor Kelemen <kelemen.gab...@nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gab...@nisz.hu>

diff --git a/sw/qa/extras/ooxmlexport/data/paragraph-mark2.docx 
b/sw/qa/extras/ooxmlexport/data/paragraph-mark2.docx
new file mode 100644
index 000000000000..a465813dc668
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/paragraph-mark2.docx 
differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 10cb4292ef90..1185b7926e9f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -641,6 +641,16 @@ DECLARE_OOXMLEXPORT_TEST(testParagraphMark, 
"paragraph-mark.docx")
     CPPUNIT_ASSERT_EQUAL(OUString("Emphasis"), 
getProperty<OUString>(getRun(getParagraph(1), 1), "CharStyleName"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testParagraphMark2, "paragraph-mark2.docx")
+{
+    // The problem was that we didn't handle the situation when an empty 
paragraph's marker had both a char style and some direct formatting.
+
+    // This was Segoe UI, set by Char Style FontStyle11 presumably.
+    CPPUNIT_ASSERT_EQUAL(OUString("Arial"), 
getProperty<OUString>(getRun(getParagraph(1), 1), "CharFontName"));
+    // This was 11, set by Char Style FontStyle11 presumably.
+    CPPUNIT_ASSERT_EQUAL(10.f, getProperty<float>(getRun(getParagraph(1), 1), 
"CharHeight"));
+}
+
 DECLARE_OOXMLEXPORT_TEST(testParagraphMarkNonempty, 
"paragraph-mark-nonempty.odt")
 {
     if (xmlDocPtr pXmlDoc = parseExport())
diff --git a/sw/source/core/unocore/unotext.cxx 
b/sw/source/core/unocore/unotext.cxx
index 13a12215444d..f37aaa15bb1c 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -1280,6 +1280,26 @@ SwXText::Impl::finishOrAppendParagraph(
             aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH);
 
         SwUnoCursorHelper::SetPropertyValues(aPam, *pParaPropSet, rProperties);
+
+        // tdf#127616 keep direct character formatting of empty paragraphs,
+        // if character style of the paragraph sets also the same attributes
+        if (aPam.Start()->nNode.GetNode().GetTextNode()->Len() == 0)
+        {
+            auto itCharStyle = std::find_if(rProperties.begin(), 
rProperties.end(), [](const beans::PropertyValue& rValue)
+            {
+                return rValue.Name == "CharStyleName";
+            });
+            if ( itCharStyle != rProperties.end() )
+            {
+                for (const auto& rValue : rProperties)
+                {
+                    if ( rValue != *itCharStyle && 
rValue.Name.startsWith("Char") )
+                    {
+                        SwUnoCursorHelper::SetPropertyValue(aPam, 
*pParaPropSet, rValue.Name, rValue.Value);
+                    }
+                }
+            }
+        }
     }
     catch (const lang::IllegalArgumentException& rIllegal)
     {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to