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

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Tue Mar 17 14:38:27 UTC 2020


 sw/qa/extras/ooxmlexport/data/tdf119800.docx      |binary
 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx         |   15 +++++++++++++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |    9 ++++++---
 3 files changed, 21 insertions(+), 3 deletions(-)

New commits:
commit ab25bf4b2c51e5634bdfeaa1f84af4bb652f7a47
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Tue Mar 17 13:42:10 2020 +0100
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Tue Mar 17 15:37:49 2020 +0100

    tdf#119800 DOCX import: fix vanished objects
    
    Not hidden objects, for example shapes and tables were
    converted to hidden text, when they were anchored to
    empty hidden paragraphs (see w:vanish character property
    in OOXML).
    
    Note: now DOCX round-trip doesn't change the document
    layout (previously DOCX export hid the vanished object),
    but Writer shows also an extra empty paragraph with
    the fixed object, so the layout is still not the same
    here.
    
    Follow-up of commit 2be656908e9f30d0b0f795cc67096f0d673a3a21
    (tdf#128646 DOCX import: don't hide shape of hidden paragraph),
    extending the fix also for not table paragraphs.
    
    Change-Id: I2af4ad42dd9e67f0daf4392fcc6875855eb4ba7c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90617
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf119800.docx b/sw/qa/extras/ooxmlexport/data/tdf119800.docx
new file mode 100644
index 000000000000..35c4108d3b3d
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf119800.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index cc4cc8f33bfa..8615ee121f01 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -655,6 +655,21 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf128646, "tdf128646.docx")
         assertXPath(pXmlDoc,"/w:document/w:body/w:tbl/w:tr/w:tc/w:p[7]/w:r/w:rPr/w:vanish", "val", "false");
 }
 
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf119800, "tdf119800.docx")
+{
+    // The problem was that not hidden shapes anchored to empty hidden paragraphs were imported as hidden.
+    // (tdf#128646 solved the same only for table paragraphs)
+    xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+
+    assertXPath(pXmlDoc,"/w:document/w:body/w:p[2]/w:pPr/w:rPr/w:vanish", 1);
+    if (!mbExported)
+        // originally no <w:vanish> (the same as <w:vanish val="false">)
+        assertXPath(pXmlDoc,"/w:document/w:body/w:p[2]/w:r/w:rPr/w:vanish", 0);
+    else
+        // This was hidden (<w:vanish/>)
+        assertXPath(pXmlDoc,"/w:document/w:body/w:p[2]/w:r/w:rPr/w:vanish", "val", "false");
+}
+
 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFdo77129, "fdo77129.docx")
 {
     // The problem was that text after TOC field was missing if footer reference  comes in field.
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 207e1493e09d..c8095f2fa689 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1753,7 +1753,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
                 css::uno::Reference<css::beans::XPropertySet> xParaProps(xTextRange, uno::UNO_QUERY);
 
                 // table style precedence and not hidden shapes anchored to hidden empty table paragraphs
-                if (xParaProps && m_nTableDepth > 0)
+                if (xParaProps && (m_nTableDepth > 0 || !m_aAnchoredObjectAnchors.empty()) )
                 {
                     // table style has got bigger precedence than docDefault style
                     // collect these pending paragraph properties to process in endTable()
@@ -1763,8 +1763,11 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
                     uno::Reference<text::XTextCursor> xCur2 =  xTextRange->getText()->createTextCursorByRange(xCur);
                     uno::Reference<text::XParagraphCursor> xParaCursor(xCur2, uno::UNO_QUERY_THROW);
                     xParaCursor->gotoStartOfParagraph(false);
-                    TableParagraph aPending{xParaCursor, xCur, pParaContext, xParaProps};
-                    m_aParagraphsToEndTable.push_back(aPending);
+                    if (m_nTableDepth > 0)
+                    {
+                        TableParagraph aPending{xParaCursor, xCur, pParaContext, xParaProps};
+                        m_aParagraphsToEndTable.push_back(aPending);
+                    }
 
                     // hidden empty paragraph with a not hidden shape, set as not hidden
                     std::optional<PropertyMap::Property> pHidden;


More information about the Libreoffice-commits mailing list