[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-6-4' - sw/qa writerfilter/source

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Wed Sep 23 17:39:02 UTC 2020


 sw/qa/extras/ooxmlexport/data/tdf130690.docx      |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx        |    9 +++++++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   20 +++++++-------------
 3 files changed, 16 insertions(+), 13 deletions(-)

New commits:
commit 67f9f9f379089481c1d1ecabc0f5b59f1f736fb8
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Mon Mar 2 17:43:58 2020 +0100
Commit:     Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Wed Sep 23 19:38:27 2020 +0200

    tdf#130690: DOCX import: fix lost text formatting in cells
    
    by limiting paragraph-level character property expansion
    for the whole table paragraph based on all text portions.
    
    Follow-up of commit abb9c7db8bcc06f907d39a7811711882161d5803
    (tdf#130494: DOCX import: limit paragraph-level character property)
    
    regression from 2ab481b038b62b1ff576ac4d49d03c1798cd7f84
    (tdf#90069 DOCX: fix character style of new table rows)
    
    Change-Id: I4d14fd30c9fbc8464c2430726faf16e292f24e38
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89848
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>
    (cherry picked from commit 0045b6f36e5e1445d699f87a0f6597d665b4cfe4)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103199
    Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf130690.docx b/sw/qa/extras/ooxmlexport/data/tdf130690.docx
new file mode 100644
index 000000000000..ab08dd99a3df
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf130690.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 0a3d0a7b8aa3..6c596b7d1ca3 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -1141,6 +1141,15 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf130494, "tdf130494.docx")
     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc[1]/w:p/w:r/w:rPr/w:highlight", 0);
 }
 
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf130690, "tdf130690.docx")
+{
+    xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc[1]/w:p/w:pPr/w:rPr/w:highlight", "val", "yellow");
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc[1]/w:p/w:r[1]/w:rPr/w:highlight", 1);
+    // keep direct formatting of table cell paragraph with removed highlighting
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc[1]/w:p/w:r[2]/w:rPr/w:highlight", 0);
+}
+
 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf121597TrackedDeletionOfMultipleParagraphs, "tdf121597.odt")
 {
     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index b62f83c9b8c6..10f587bb750c 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1799,26 +1799,20 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
                 }
 
                 // fix table paragraph properties
-                if ( xParaProps && m_nTableDepth > 0 )
+                if ( xTextRange.is() && xParaProps && m_nTableDepth > 0 )
                 {
                     uno::Sequence< beans::PropertyValue > aParaProps = pParaContext->GetPropertyValues(false);
-
+                    uno::Reference<text::XTextCursor> xCur =  xTextRange->getText()->createTextCursorByRange(xTextRange);
+                    uno::Reference< beans::XPropertyState > xRunProperties( xCur, uno::UNO_QUERY_THROW );
                     // tdf#90069 in tables, apply paragraph level character style also on
                     // paragraph level to support its copy during insertion of new table rows
                     for( const auto& rParaProp : std::as_const(aParaProps) )
                     {
-                        if ( m_pLastCharacterContext.get() && rParaProp.Name.startsWith("Char") && rParaProp.Name != "CharStyleName" && rParaProp.Name != "CharInteropGrabBag" )
+                        if ( rParaProp.Name.startsWith("Char") && rParaProp.Name != "CharStyleName" && rParaProp.Name != "CharInteropGrabBag" &&
+                            // all text portions contain the same value, so next setPropertyValue() won't overwrite part of them
+                            xRunProperties->getPropertyState(rParaProp.Name) == css::beans::PropertyState_DIRECT_VALUE )
                         {
-                            const uno::Sequence< beans::PropertyValue > aLastCharProps = m_pLastCharacterContext->GetPropertyValues( );
-
-                            for( const auto& rLastCharProp : std::as_const(aLastCharProps) )
-                            {
-                                if ( rLastCharProp == rParaProp )
-                                {
-                                    xParaProps->setPropertyValue( rParaProp.Name, rParaProp.Value );
-                                    break;
-                                }
-                            }
+                            xParaProps->setPropertyValue( rParaProp.Name, rParaProp.Value );
                         }
                     }
 


More information about the Libreoffice-commits mailing list