[Libreoffice-commits] core.git: sw/qa sw/source

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Mon May 18 15:58:18 UTC 2020


 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 fb001eab98934c5a4d0a8c6b9563f91337561b87
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Fri May 15 13:32:07 2020 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Mon May 18 17:57:43 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_luth at sil.org>
    
    Change-Id: Ic7b3a73d4d7364993cc58073c9e1a09a2711d1b3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94308
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>

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 5f521b8067c4..ed5216c15a10 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -633,6 +633,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")
 {
     CPPUNIT_ASSERT_EQUAL(1, getPages());
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index 9ef0f55dc08c..ee5185b12f2b 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -1275,6 +1275,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)
     {


More information about the Libreoffice-commits mailing list