[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - sw/qa writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Feb 2 20:12:02 UTC 2017


 sw/qa/extras/ooxmlexport/data/tdf103976.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx    |   10 ++++++++++
 writerfilter/source/dmapper/DomainMapper.cxx |   10 ++++++++--
 3 files changed, 18 insertions(+), 2 deletions(-)

New commits:
commit df18f96a3a30701286691bfeeacd34c3bba68ce0
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Jan 31 09:14:11 2017 +0100

    tdf#103976 DOCX import: disable incomplete w:before/afterLines style handling
    
    Regression from commit 9e7eb63989ef1cf4b9a0e0404b84ef890db3d8e3 (DOCX
    import: parse <w:spacing>'s w:before/afterLines attribute, 2014-10-17),
    the problem is that OOXML has 3 different attributes for the paragraph
    bottom margin (and other 3 for the top one), while in Writer we just
    have a top margin.
    
    Now the import filter tries to work out which one of these should have
    priority and ignore the rest, but this is way more complicated when
    style inheritance has to be taken into account as well.
    
    To avoid the regression just restrict w:before/afterLines handling for
    the case when it's used as direct formatting, that's why this was
    introduced after all.
    
    (cherry picked from commit 353a45aa1b1a15047aa2a92c1383996070e87405)
    
    Change-Id: Ie8642c7a9771596def6b8899e098b26c4f8be0b4
    Reviewed-on: https://gerrit.libreoffice.org/33774
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf103976.docx b/sw/qa/extras/ooxmlexport/data/tdf103976.docx
new file mode 100644
index 0000000..2081fcf
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf103976.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 0f05214..4dd08ae 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -191,6 +191,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf104150, "tdf104150.docx")
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1), getProperty<sal_Int32>(xPageStyle, "BackColor"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf103976, "tdf103976.docx")
+{
+    uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
+    uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
+    uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
+    // This was 0, table style inheritance went wrong and w:afterLines had priority over w:after.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(convertTwipToMm100(60)), getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaBottomMargin"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index f2a076c..823640c 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -377,7 +377,10 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
             break;
         case NS_ooxml::LN_CT_Spacing_beforeLines:
                 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "beforeLines", OUString::number(nIntValue));
-                if (m_pImpl->GetTopContext())
+                // We would need to make sure that this doesn't overwrite any
+                // NS_ooxml::LN_CT_Spacing_before in parent styles before style
+                // sheet support can be enabled.
+                if (m_pImpl->GetTopContext() && !IsStyleSheetImport())
                     m_pImpl->GetTopContext()->Insert(PROP_PARA_TOP_MARGIN, uno::makeAny(ConversionHelper::convertTwipToMM100(nIntValue * nSingleLineSpacing / 100)), false);
             break;
         case NS_ooxml::LN_CT_Spacing_after:
@@ -388,7 +391,10 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
             break;
         case NS_ooxml::LN_CT_Spacing_afterLines:
             m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "afterLines", OUString::number(nIntValue));
-            if (m_pImpl->GetTopContext())
+            // We would need to make sure that this doesn't overwrite any
+            // NS_ooxml::LN_CT_Spacing_after in parent styles before style
+            // sheet support can be enabled.
+            if (m_pImpl->GetTopContext() && !IsStyleSheetImport())
                 m_pImpl->GetTopContext()->Insert(PROP_PARA_BOTTOM_MARGIN, uno::makeAny(ConversionHelper::convertTwipToMM100(nIntValue * nSingleLineSpacing / 100)), false);
             break;
         case NS_ooxml::LN_CT_Spacing_line: //91434


More information about the Libreoffice-commits mailing list